1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports["default"] = void 0;
|
9 |
|
10 | var _invariant = _interopRequireDefault(require("invariant"));
|
11 |
|
12 | var _getStringLabelKey = _interopRequireDefault(require("./getStringLabelKey"));
|
13 |
|
14 | var _hasOwnProperty = _interopRequireDefault(require("./hasOwnProperty"));
|
15 |
|
16 | var _nodash = require("./nodash");
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function getOptionLabel(option, labelKey) {
|
24 |
|
25 | if (!(0, _nodash.isString)(option) && ((0, _hasOwnProperty["default"])(option, 'paginationOption') || (0, _hasOwnProperty["default"])(option, 'customOption'))) {
|
26 | return option[(0, _getStringLabelKey["default"])(labelKey)];
|
27 | }
|
28 |
|
29 | var optionLabel;
|
30 |
|
31 | if ((0, _nodash.isFunction)(labelKey)) {
|
32 | optionLabel = labelKey(option);
|
33 | } else if ((0, _nodash.isString)(option)) {
|
34 | optionLabel = option;
|
35 | } else {
|
36 |
|
37 | optionLabel = option[labelKey];
|
38 | }
|
39 |
|
40 | !(0, _nodash.isString)(optionLabel) ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'One or more options does not have a valid label string. Check the ' + '`labelKey` prop to ensure that it matches the correct option key and ' + 'provides a string for filtering and display.') : (0, _invariant["default"])(false) : void 0;
|
41 | return optionLabel;
|
42 | }
|
43 |
|
44 | var _default = getOptionLabel;
|
45 | exports["default"] = _default; |
\ | No newline at end of file |