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 _getMatchBounds = _interopRequireDefault(require("./getMatchBounds"));
|
11 |
|
12 | var _getOptionLabel = _interopRequireDefault(require("./getOptionLabel"));
|
13 |
|
14 | var _hasOwnProperty = _interopRequireDefault(require("./hasOwnProperty"));
|
15 |
|
16 | var _nodash = require("./nodash");
|
17 |
|
18 | function getHintText(_ref) {
|
19 | var activeIndex = _ref.activeIndex,
|
20 | initialItem = _ref.initialItem,
|
21 | isFocused = _ref.isFocused,
|
22 | isMenuShown = _ref.isMenuShown,
|
23 | labelKey = _ref.labelKey,
|
24 | multiple = _ref.multiple,
|
25 | selected = _ref.selected,
|
26 | text = _ref.text;
|
27 |
|
28 |
|
29 | if (
|
30 | !text ||
|
31 | !isFocused ||
|
32 | !isMenuShown ||
|
33 | !initialItem ||
|
34 | !(0, _nodash.isString)(initialItem) && (0, _hasOwnProperty["default"])(initialItem, 'customOption') ||
|
35 | activeIndex > -1 ||
|
36 | !!selected.length && !multiple) {
|
37 | return '';
|
38 | }
|
39 |
|
40 | var initialItemStr = (0, _getOptionLabel["default"])(initialItem, labelKey);
|
41 | var bounds = (0, _getMatchBounds["default"])(initialItemStr.toLowerCase(), text.toLowerCase());
|
42 |
|
43 | if (!(bounds && bounds.start === 0)) {
|
44 | return '';
|
45 | }
|
46 |
|
47 |
|
48 |
|
49 | return text + initialItemStr.slice(bounds.end, initialItemStr.length);
|
50 | }
|
51 |
|
52 | var _default = getHintText;
|
53 | exports["default"] = _default; |
\ | No newline at end of file |