@entur/dropdown 3.0.24 → 3.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +631 -0
- package/dist/dropdown.cjs.development.js +581 -402
- package/dist/dropdown.cjs.development.js.map +1 -1
- package/dist/dropdown.cjs.production.min.js +1 -1
- package/dist/dropdown.cjs.production.min.js.map +1 -1
- package/dist/dropdown.esm.js +581 -402
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +89 -73
- package/package.json +15 -21
|
@@ -27,55 +27,64 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
27
27
|
reject(error);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
+
|
|
30
31
|
if (info.done) {
|
|
31
32
|
resolve(value);
|
|
32
33
|
} else {
|
|
33
34
|
Promise.resolve(value).then(_next, _throw);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
|
|
36
38
|
function _asyncToGenerator(fn) {
|
|
37
39
|
return function () {
|
|
38
40
|
var self = this,
|
|
39
|
-
|
|
41
|
+
args = arguments;
|
|
40
42
|
return new Promise(function (resolve, reject) {
|
|
41
43
|
var gen = fn.apply(self, args);
|
|
44
|
+
|
|
42
45
|
function _next(value) {
|
|
43
46
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
44
47
|
}
|
|
48
|
+
|
|
45
49
|
function _throw(err) {
|
|
46
50
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
47
51
|
}
|
|
52
|
+
|
|
48
53
|
_next(undefined);
|
|
49
54
|
});
|
|
50
55
|
};
|
|
51
56
|
}
|
|
57
|
+
|
|
52
58
|
function _extends() {
|
|
53
59
|
_extends = Object.assign || function (target) {
|
|
54
60
|
for (var i = 1; i < arguments.length; i++) {
|
|
55
61
|
var source = arguments[i];
|
|
62
|
+
|
|
56
63
|
for (var key in source) {
|
|
57
64
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
58
65
|
target[key] = source[key];
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
}
|
|
69
|
+
|
|
62
70
|
return target;
|
|
63
71
|
};
|
|
72
|
+
|
|
64
73
|
return _extends.apply(this, arguments);
|
|
65
74
|
}
|
|
66
|
-
|
|
67
|
-
if (obj == null) throw new TypeError("Cannot destructure undefined");
|
|
68
|
-
}
|
|
75
|
+
|
|
69
76
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
70
77
|
if (source == null) return {};
|
|
71
78
|
var target = {};
|
|
72
79
|
var sourceKeys = Object.keys(source);
|
|
73
80
|
var key, i;
|
|
81
|
+
|
|
74
82
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
75
83
|
key = sourceKeys[i];
|
|
76
84
|
if (excluded.indexOf(key) >= 0) continue;
|
|
77
85
|
target[key] = source[key];
|
|
78
86
|
}
|
|
87
|
+
|
|
79
88
|
return target;
|
|
80
89
|
}
|
|
81
90
|
|
|
@@ -83,41 +92,47 @@ var _excluded$a = ["children", "onChange", "onInputValueChange", "highlightFirst
|
|
|
83
92
|
var DownshiftContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
84
93
|
var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
85
94
|
var children = _ref.children,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
_ref$onChange = _ref.onChange,
|
|
96
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
97
|
+
return undefined;
|
|
98
|
+
} : _ref$onChange,
|
|
99
|
+
_ref$onInputValueChan = _ref.onInputValueChange,
|
|
100
|
+
onInputValueChange = _ref$onInputValueChan === void 0 ? function () {
|
|
101
|
+
return undefined;
|
|
102
|
+
} : _ref$onInputValueChan,
|
|
103
|
+
_ref$highlightFirstIt = _ref.highlightFirstItemOnOpen,
|
|
104
|
+
highlightFirstItemOnOpen = _ref$highlightFirstIt === void 0 ? false : _ref$highlightFirstIt,
|
|
105
|
+
className = _ref.className,
|
|
106
|
+
style = _ref.style,
|
|
107
|
+
_ref$searchable = _ref.searchable,
|
|
108
|
+
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
109
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
110
|
+
|
|
101
111
|
var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
|
|
102
112
|
if (changes.type === Downshift__default["default"].stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
103
113
|
return;
|
|
104
114
|
}
|
|
115
|
+
|
|
105
116
|
if ('selectedItem' in changes) {
|
|
106
117
|
onChange(changes.selectedItem, stateAndHelpers);
|
|
107
118
|
} else if ('inputValue' in changes) {
|
|
108
119
|
onInputValueChange(changes.inputValue);
|
|
109
120
|
}
|
|
110
121
|
};
|
|
122
|
+
|
|
111
123
|
var stateReducer = function stateReducer(_, changes) {
|
|
112
124
|
var highlightFirstOnOpen = highlightFirstItemOnOpen && 'isOpen' in changes && changes.isOpen;
|
|
113
125
|
var highlightFirstItemIndex = highlightFirstOnOpen ? {
|
|
114
126
|
highlightedIndex: 0
|
|
115
127
|
} : {};
|
|
128
|
+
|
|
116
129
|
if (searchable) {
|
|
117
130
|
var type = changes.type;
|
|
131
|
+
|
|
118
132
|
switch (type) {
|
|
119
133
|
case '__autocomplete_change_input__':
|
|
120
134
|
return _extends({}, changes, highlightFirstItemIndex);
|
|
135
|
+
|
|
121
136
|
case '__autocomplete_click_item__':
|
|
122
137
|
case '__autocomplete_keydown_enter__':
|
|
123
138
|
case '__autocomplete_blur_input__':
|
|
@@ -127,6 +142,7 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
127
142
|
// we will reset input field value to blank
|
|
128
143
|
inputValue: ''
|
|
129
144
|
}, highlightFirstItemIndex);
|
|
145
|
+
|
|
130
146
|
default:
|
|
131
147
|
return _extends({}, changes, highlightFirstItemIndex);
|
|
132
148
|
}
|
|
@@ -134,6 +150,7 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
134
150
|
return _extends({}, changes, highlightFirstItemIndex);
|
|
135
151
|
}
|
|
136
152
|
};
|
|
153
|
+
|
|
137
154
|
return React__default["default"].createElement(Downshift__default["default"], _extends({
|
|
138
155
|
itemToString: function itemToString(item) {
|
|
139
156
|
return item ? item.label : '';
|
|
@@ -151,29 +168,32 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
151
168
|
};
|
|
152
169
|
var useDownshift = function useDownshift() {
|
|
153
170
|
var context = React__default["default"].useContext(DownshiftContext);
|
|
171
|
+
|
|
154
172
|
if (!context) {
|
|
155
173
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
156
174
|
}
|
|
175
|
+
|
|
157
176
|
return context;
|
|
158
177
|
};
|
|
159
178
|
|
|
160
179
|
var _excluded$9 = ["items"];
|
|
161
180
|
var DropdownList$1 = function DropdownList(_ref) {
|
|
162
181
|
var items = _ref.items,
|
|
163
|
-
|
|
182
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
183
|
+
|
|
164
184
|
var _useDownshift = useDownshift(),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
185
|
+
highlightedIndex = _useDownshift.highlightedIndex,
|
|
186
|
+
isOpen = _useDownshift.isOpen,
|
|
187
|
+
selectedItem = _useDownshift.selectedItem,
|
|
188
|
+
getItemProps = _useDownshift.getItemProps,
|
|
189
|
+
getMenuProps = _useDownshift.getMenuProps;
|
|
190
|
+
|
|
170
191
|
return React__default["default"].createElement("ul", _extends({
|
|
171
192
|
className: classNames__default["default"]('eds-dropdown-list', {
|
|
172
193
|
'eds-dropdown-list--open': isOpen
|
|
173
194
|
})
|
|
174
195
|
}, getMenuProps(), rest), isOpen ? items.map(function (item, index) {
|
|
175
|
-
return (
|
|
176
|
-
// eslint-disable-next-line react/jsx-key
|
|
196
|
+
return (// eslint-disable-next-line react/jsx-key
|
|
177
197
|
React__default["default"].createElement("li", _extends({
|
|
178
198
|
className: classNames__default["default"]('eds-dropdown-list__item', {
|
|
179
199
|
'eds-dropdown-list__item--highlighted': highlightedIndex === index,
|
|
@@ -196,8 +216,9 @@ var DropdownList$1 = function DropdownList(_ref) {
|
|
|
196
216
|
|
|
197
217
|
var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
198
218
|
var _useDownshift = useDownshift(),
|
|
199
|
-
|
|
200
|
-
|
|
219
|
+
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
220
|
+
isOpen = _useDownshift.isOpen;
|
|
221
|
+
|
|
201
222
|
return React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
202
223
|
className: classNames__default["default"]('eds-dropdown__toggle-button', {
|
|
203
224
|
'eds-dropdown__toggle-button--open': isOpen
|
|
@@ -211,8 +232,9 @@ var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
|
211
232
|
var _excluded$8 = ["className", "children"];
|
|
212
233
|
var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
|
|
213
234
|
var className = _ref.className,
|
|
214
|
-
|
|
215
|
-
|
|
235
|
+
children = _ref.children,
|
|
236
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
237
|
+
|
|
216
238
|
return React__default["default"].createElement("div", _extends({
|
|
217
239
|
className: classNames__default["default"]('eds-inline-spinner', className)
|
|
218
240
|
}, rest), React__default["default"].createElement(loader.LoadingDots, null), React__default["default"].createElement(a11y.VisuallyHidden, null, children));
|
|
@@ -221,22 +243,24 @@ var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
|
|
|
221
243
|
var _excluded$7 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
|
|
222
244
|
var BaseDropdown = function BaseDropdown(_ref) {
|
|
223
245
|
var children = _ref.children,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
246
|
+
className = _ref.className,
|
|
247
|
+
items = _ref.items,
|
|
248
|
+
_ref$loading = _ref.loading,
|
|
249
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
250
|
+
_ref$loadingText = _ref.loadingText,
|
|
251
|
+
loadingText = _ref$loadingText === void 0 ? 'Loading...' : _ref$loadingText,
|
|
252
|
+
style = _ref.style,
|
|
253
|
+
listStyle = _ref.listStyle,
|
|
254
|
+
clearable = _ref.clearable,
|
|
255
|
+
label = _ref.label,
|
|
256
|
+
_ref$isFilled = _ref.isFilled,
|
|
257
|
+
isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
|
|
258
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
259
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
260
|
+
|
|
238
261
|
var _useDownshift = useDownshift(),
|
|
239
|
-
|
|
262
|
+
getLabelProps = _useDownshift.getLabelProps;
|
|
263
|
+
|
|
240
264
|
return React__default["default"].createElement("div", {
|
|
241
265
|
className: "eds-dropdown-wrapper",
|
|
242
266
|
style: style
|
|
@@ -260,11 +284,14 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
260
284
|
}, listStyle)
|
|
261
285
|
}, rest)));
|
|
262
286
|
};
|
|
287
|
+
|
|
263
288
|
var ClearButton$1 = function ClearButton(_ref2) {
|
|
264
|
-
var props = _extends({},
|
|
289
|
+
var props = _extends({}, _ref2);
|
|
290
|
+
|
|
265
291
|
var _useDownshift2 = useDownshift(),
|
|
266
|
-
|
|
267
|
-
|
|
292
|
+
clearSelection = _useDownshift2.clearSelection,
|
|
293
|
+
selectedItem = _useDownshift2.selectedItem;
|
|
294
|
+
|
|
268
295
|
return React__default["default"].createElement(React__default["default"].Fragment, null, selectedItem && React__default["default"].createElement("button", _extends({
|
|
269
296
|
className: "eds-dropdown__clear-button",
|
|
270
297
|
type: "button",
|
|
@@ -276,46 +303,52 @@ var ClearButton$1 = function ClearButton(_ref2) {
|
|
|
276
303
|
className: "eds-dropdown__divider"
|
|
277
304
|
}));
|
|
278
305
|
};
|
|
306
|
+
|
|
279
307
|
var Appendix$2 = function Appendix(_ref3) {
|
|
280
308
|
var clearable = _ref3.clearable,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
309
|
+
loading = _ref3.loading,
|
|
310
|
+
loadingText = _ref3.loadingText,
|
|
311
|
+
readOnly = _ref3.readOnly;
|
|
312
|
+
|
|
284
313
|
if (loading) {
|
|
285
314
|
return React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
286
315
|
}
|
|
316
|
+
|
|
287
317
|
if (readOnly) {
|
|
288
318
|
return null;
|
|
289
319
|
}
|
|
320
|
+
|
|
290
321
|
return clearable ? React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(ClearButton$1, null), " ", React__default["default"].createElement(DropdownToggleButton$1, null)) : React__default["default"].createElement(DropdownToggleButton$1, null);
|
|
291
322
|
};
|
|
292
323
|
|
|
293
324
|
var _excluded$6 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
|
|
294
325
|
var RegularDropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
295
326
|
var disabled = _ref.disabled,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
327
|
+
_ref$placeholder = _ref.placeholder,
|
|
328
|
+
placeholder = _ref$placeholder === void 0 ? 'Vennligst velg' : _ref$placeholder,
|
|
329
|
+
_ref$selectOnTab = _ref.selectOnTab,
|
|
330
|
+
selectOnTab = _ref$selectOnTab === void 0 ? false : _ref$selectOnTab,
|
|
331
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
332
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
333
|
+
listStyle = _ref.listStyle,
|
|
334
|
+
items = _ref.items,
|
|
335
|
+
label = _ref.label,
|
|
336
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
337
|
+
loading = _ref.loading,
|
|
338
|
+
loadingText = _ref.loadingText,
|
|
339
|
+
className = _ref.className,
|
|
340
|
+
clearable = _ref.clearable,
|
|
341
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
342
|
+
|
|
311
343
|
var _useDownshift = useDownshift(),
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
344
|
+
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
345
|
+
selectedItem = _useDownshift.selectedItem,
|
|
346
|
+
selectHighlightedItem = _useDownshift.selectHighlightedItem,
|
|
347
|
+
openMenu = _useDownshift.openMenu,
|
|
348
|
+
isOpen = _useDownshift.isOpen,
|
|
349
|
+
highlightedIndex = _useDownshift.highlightedIndex,
|
|
350
|
+
setHighlightedIndex = _useDownshift.setHighlightedIndex;
|
|
351
|
+
|
|
319
352
|
return React__default["default"].createElement(BaseDropdown, _extends({
|
|
320
353
|
disabled: disabled,
|
|
321
354
|
listStyle: listStyle,
|
|
@@ -338,6 +371,7 @@ var RegularDropdown = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
338
371
|
if (selectOnTab && e.key === 'Tab') {
|
|
339
372
|
selectHighlightedItem();
|
|
340
373
|
}
|
|
374
|
+
|
|
341
375
|
if (isOpen) {
|
|
342
376
|
var keyDownValue = e.key;
|
|
343
377
|
var matchedItems = items.map(function (item, index) {
|
|
@@ -351,6 +385,7 @@ var RegularDropdown = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
351
385
|
var nextHighlightItem = matchedItems.find(function (item) {
|
|
352
386
|
return item.index > (highlightedIndex != null ? highlightedIndex : 0);
|
|
353
387
|
});
|
|
388
|
+
|
|
354
389
|
if (nextHighlightItem) {
|
|
355
390
|
setHighlightedIndex(nextHighlightItem.index);
|
|
356
391
|
} else if (matchedItems.length > 0) {
|
|
@@ -369,49 +404,55 @@ var RegularDropdown = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
369
404
|
});
|
|
370
405
|
|
|
371
406
|
var _excluded$5 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
|
|
407
|
+
|
|
372
408
|
function LowerCaseFilterTest(item, input) {
|
|
373
409
|
if (!input) {
|
|
374
410
|
return true;
|
|
375
411
|
}
|
|
412
|
+
|
|
376
413
|
var sanitizeEscapeCharacters = input.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
377
414
|
var inputRegex = new RegExp(sanitizeEscapeCharacters, 'i');
|
|
378
415
|
return inputRegex.test(item.label);
|
|
379
416
|
}
|
|
417
|
+
|
|
380
418
|
var SearchableDropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
381
419
|
var _ref$disabled = _ref.disabled,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
420
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
421
|
+
className = _ref.className,
|
|
422
|
+
items = _ref.items,
|
|
423
|
+
loading = _ref.loading,
|
|
424
|
+
loadingText = _ref.loadingText,
|
|
425
|
+
_ref$readOnly = _ref.readOnly,
|
|
426
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
427
|
+
prepend = _ref.prepend,
|
|
428
|
+
_ref$selectOnTab = _ref.selectOnTab,
|
|
429
|
+
selectOnTab = _ref$selectOnTab === void 0 ? false : _ref$selectOnTab,
|
|
430
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
431
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
432
|
+
listStyle = _ref.listStyle,
|
|
433
|
+
clearable = _ref.clearable,
|
|
434
|
+
_ref$itemFilter = _ref.itemFilter,
|
|
435
|
+
itemFilter = _ref$itemFilter === void 0 ? function (item, inputValue) {
|
|
436
|
+
return LowerCaseFilterTest(item, inputValue);
|
|
437
|
+
} : _ref$itemFilter,
|
|
438
|
+
label = _ref.label,
|
|
439
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
440
|
+
placeholder = _ref.placeholder,
|
|
441
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
442
|
+
|
|
404
443
|
var _useDownshift = useDownshift(),
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
444
|
+
getInputProps = _useDownshift.getInputProps,
|
|
445
|
+
inputValue = _useDownshift.inputValue,
|
|
446
|
+
selectHighlightedItem = _useDownshift.selectHighlightedItem,
|
|
447
|
+
isOpen = _useDownshift.isOpen,
|
|
448
|
+
openMenu = _useDownshift.openMenu,
|
|
449
|
+
closeMenu = _useDownshift.closeMenu,
|
|
450
|
+
selectedItem = _useDownshift.selectedItem;
|
|
451
|
+
|
|
412
452
|
var _useState = React.useState(false),
|
|
413
|
-
|
|
414
|
-
|
|
453
|
+
hideSelectedItem = _useState[0],
|
|
454
|
+
setHideSelectedItem = _useState[1];
|
|
455
|
+
|
|
415
456
|
var inputRef = React.useRef(null);
|
|
416
457
|
var filteredItems = React__default["default"].useMemo(function () {
|
|
417
458
|
return items.filter(function (item) {
|
|
@@ -437,6 +478,7 @@ var SearchableDropdown = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
|
437
478
|
className: "eds-dropdown__searchable-selected-item",
|
|
438
479
|
onClick: function onClick() {
|
|
439
480
|
var _inputRef$current;
|
|
481
|
+
|
|
440
482
|
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
441
483
|
}
|
|
442
484
|
}, selectedItem.label)), React__default["default"].createElement("input", _extends({}, getInputProps(_extends({
|
|
@@ -462,10 +504,10 @@ var SearchableDropdown = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
|
462
504
|
|
|
463
505
|
var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
464
506
|
var children = _ref.children,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
507
|
+
feedback = _ref.feedback,
|
|
508
|
+
variant = _ref.variant,
|
|
509
|
+
className = _ref.className,
|
|
510
|
+
style = _ref.style;
|
|
469
511
|
return React__default["default"].createElement(form.VariantProvider, {
|
|
470
512
|
variant: variant
|
|
471
513
|
}, React__default["default"].createElement("div", {
|
|
@@ -484,16 +526,19 @@ var runtime = {exports: {}};
|
|
|
484
526
|
* This source code is licensed under the MIT license found in the
|
|
485
527
|
* LICENSE file in the root directory of this source tree.
|
|
486
528
|
*/
|
|
529
|
+
|
|
487
530
|
(function (module) {
|
|
488
531
|
var runtime = /*#__PURE__*/function (exports) {
|
|
489
532
|
|
|
490
533
|
var Op = Object.prototype;
|
|
491
534
|
var hasOwn = Op.hasOwnProperty;
|
|
492
535
|
var undefined$1; // More compressible than void 0.
|
|
536
|
+
|
|
493
537
|
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
494
538
|
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
495
539
|
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
496
540
|
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
541
|
+
|
|
497
542
|
function define(obj, key, value) {
|
|
498
543
|
Object.defineProperty(obj, key, {
|
|
499
544
|
value: value,
|
|
@@ -503,6 +548,7 @@ var runtime = {exports: {}};
|
|
|
503
548
|
});
|
|
504
549
|
return obj[key];
|
|
505
550
|
}
|
|
551
|
+
|
|
506
552
|
try {
|
|
507
553
|
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
508
554
|
define({}, "");
|
|
@@ -511,20 +557,19 @@ var runtime = {exports: {}};
|
|
|
511
557
|
return obj[key] = value;
|
|
512
558
|
};
|
|
513
559
|
}
|
|
560
|
+
|
|
514
561
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
515
562
|
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
516
563
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
517
564
|
var generator = Object.create(protoGenerator.prototype);
|
|
518
|
-
var context = new Context(tryLocsList || []);
|
|
519
|
-
|
|
520
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
565
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
521
566
|
// .throw, and .return methods.
|
|
567
|
+
|
|
522
568
|
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
523
569
|
return generator;
|
|
524
570
|
}
|
|
525
|
-
exports.wrap = wrap;
|
|
526
571
|
|
|
527
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
572
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
528
573
|
// record like context.tryEntries[i].completion. This interface could
|
|
529
574
|
// have been (and was previously) designed to take a closure to be
|
|
530
575
|
// invoked without arguments, but in all the cases we care about we
|
|
@@ -534,6 +579,7 @@ var runtime = {exports: {}};
|
|
|
534
579
|
// in every case, so we don't have to touch the arguments object. The
|
|
535
580
|
// only additional allocation required is the completion record, which
|
|
536
581
|
// has a stable shape and so hopefully should be cheap to allocate.
|
|
582
|
+
|
|
537
583
|
function tryCatch(fn, obj, arg) {
|
|
538
584
|
try {
|
|
539
585
|
return {
|
|
@@ -547,44 +593,47 @@ var runtime = {exports: {}};
|
|
|
547
593
|
};
|
|
548
594
|
}
|
|
549
595
|
}
|
|
596
|
+
|
|
550
597
|
var GenStateSuspendedStart = "suspendedStart";
|
|
551
598
|
var GenStateSuspendedYield = "suspendedYield";
|
|
552
599
|
var GenStateExecuting = "executing";
|
|
553
|
-
var GenStateCompleted = "completed";
|
|
554
|
-
|
|
555
|
-
// Returning this object from the innerFn has the same effect as
|
|
600
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
556
601
|
// breaking out of the dispatch switch statement.
|
|
557
|
-
var ContinueSentinel = {};
|
|
558
602
|
|
|
559
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
603
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
560
604
|
// .constructor.prototype properties for functions that return Generator
|
|
561
605
|
// objects. For full spec compliance, you may wish to configure your
|
|
562
606
|
// minifier not to mangle the names of these two functions.
|
|
607
|
+
|
|
563
608
|
function Generator() {}
|
|
609
|
+
|
|
564
610
|
function GeneratorFunction() {}
|
|
565
|
-
function GeneratorFunctionPrototype() {}
|
|
566
611
|
|
|
567
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
612
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
568
613
|
// don't natively support it.
|
|
614
|
+
|
|
615
|
+
|
|
569
616
|
var IteratorPrototype = {};
|
|
570
|
-
|
|
617
|
+
|
|
618
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
571
619
|
return this;
|
|
572
|
-
}
|
|
620
|
+
};
|
|
621
|
+
|
|
573
622
|
var getProto = Object.getPrototypeOf;
|
|
574
623
|
var NativeIteratorPrototype = getProto && /*#__PURE__*/getProto( /*#__PURE__*/getProto( /*#__PURE__*/values([])));
|
|
624
|
+
|
|
575
625
|
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
576
626
|
// This environment has a native %IteratorPrototype%; use it instead
|
|
577
627
|
// of the polyfill.
|
|
578
628
|
IteratorPrototype = NativeIteratorPrototype;
|
|
579
629
|
}
|
|
580
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
|
|
581
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
582
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
583
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
584
|
-
GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
585
630
|
|
|
586
|
-
|
|
631
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
|
|
632
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
633
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
634
|
+
GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
587
635
|
// Iterator interface in terms of a single ._invoke method.
|
|
636
|
+
|
|
588
637
|
function defineIteratorMethods(prototype) {
|
|
589
638
|
["next", "throw", "return"].forEach(function (method) {
|
|
590
639
|
define(prototype, method, function (arg) {
|
|
@@ -592,13 +641,14 @@ var runtime = {exports: {}};
|
|
|
592
641
|
});
|
|
593
642
|
});
|
|
594
643
|
}
|
|
644
|
+
|
|
595
645
|
exports.isGeneratorFunction = function (genFun) {
|
|
596
646
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
597
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
598
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
647
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
599
648
|
// do is to check its .name property.
|
|
600
649
|
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
601
650
|
};
|
|
651
|
+
|
|
602
652
|
exports.mark = function (genFun) {
|
|
603
653
|
if (Object.setPrototypeOf) {
|
|
604
654
|
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
@@ -606,27 +656,31 @@ var runtime = {exports: {}};
|
|
|
606
656
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
607
657
|
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
608
658
|
}
|
|
659
|
+
|
|
609
660
|
genFun.prototype = Object.create(Gp);
|
|
610
661
|
return genFun;
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
// Within the body of any async function, `await x` is transformed to
|
|
662
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
614
663
|
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
615
664
|
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
616
665
|
// meant to be awaited.
|
|
666
|
+
|
|
667
|
+
|
|
617
668
|
exports.awrap = function (arg) {
|
|
618
669
|
return {
|
|
619
670
|
__await: arg
|
|
620
671
|
};
|
|
621
672
|
};
|
|
673
|
+
|
|
622
674
|
function AsyncIterator(generator, PromiseImpl) {
|
|
623
675
|
function invoke(method, arg, resolve, reject) {
|
|
624
676
|
var record = tryCatch(generator[method], generator, arg);
|
|
677
|
+
|
|
625
678
|
if (record.type === "throw") {
|
|
626
679
|
reject(record.arg);
|
|
627
680
|
} else {
|
|
628
681
|
var result = record.arg;
|
|
629
682
|
var value = result.value;
|
|
683
|
+
|
|
630
684
|
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
631
685
|
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
632
686
|
invoke("next", value, resolve, reject);
|
|
@@ -634,6 +688,7 @@ var runtime = {exports: {}};
|
|
|
634
688
|
invoke("throw", err, resolve, reject);
|
|
635
689
|
});
|
|
636
690
|
}
|
|
691
|
+
|
|
637
692
|
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
638
693
|
// When a yielded Promise is resolved, its final value becomes
|
|
639
694
|
// the .value of the Promise<{value,done}> result for the
|
|
@@ -647,15 +702,17 @@ var runtime = {exports: {}};
|
|
|
647
702
|
});
|
|
648
703
|
}
|
|
649
704
|
}
|
|
705
|
+
|
|
650
706
|
var previousPromise;
|
|
707
|
+
|
|
651
708
|
function enqueue(method, arg) {
|
|
652
709
|
function callInvokeWithMethodAndArg() {
|
|
653
710
|
return new PromiseImpl(function (resolve, reject) {
|
|
654
711
|
invoke(method, arg, resolve, reject);
|
|
655
712
|
});
|
|
656
713
|
}
|
|
657
|
-
|
|
658
|
-
// If enqueue has been called before, then we want to wait until
|
|
714
|
+
|
|
715
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
659
716
|
// all previous Promises have been resolved before calling invoke,
|
|
660
717
|
// so that results are always delivered in the correct order. If
|
|
661
718
|
// enqueue has not been called before, then it is important to
|
|
@@ -667,25 +724,26 @@ var runtime = {exports: {}};
|
|
|
667
724
|
// execute code before the first await. Since we implement simple
|
|
668
725
|
// async functions in terms of async generators, it is especially
|
|
669
726
|
// important to get this right, even though it requires care.
|
|
670
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
671
|
-
// Avoid propagating failures to Promises returned by later
|
|
727
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
672
728
|
// invocations of the iterator.
|
|
673
729
|
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// Define the unified helper method that is used to implement .next,
|
|
730
|
+
} // Define the unified helper method that is used to implement .next,
|
|
677
731
|
// .throw, and .return (see defineIteratorMethods).
|
|
732
|
+
|
|
733
|
+
|
|
678
734
|
this._invoke = enqueue;
|
|
679
735
|
}
|
|
736
|
+
|
|
680
737
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
681
|
-
|
|
738
|
+
|
|
739
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
682
740
|
return this;
|
|
683
|
-
}
|
|
684
|
-
exports.AsyncIterator = AsyncIterator;
|
|
741
|
+
};
|
|
685
742
|
|
|
686
|
-
// Note that simple async functions are implemented on top of
|
|
743
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
687
744
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
688
745
|
// the final result produced by the iterator.
|
|
746
|
+
|
|
689
747
|
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
690
748
|
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
691
749
|
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
@@ -694,32 +752,39 @@ var runtime = {exports: {}};
|
|
|
694
752
|
return result.done ? result.value : iter.next();
|
|
695
753
|
});
|
|
696
754
|
};
|
|
755
|
+
|
|
697
756
|
function makeInvokeMethod(innerFn, self, context) {
|
|
698
757
|
var state = GenStateSuspendedStart;
|
|
699
758
|
return function invoke(method, arg) {
|
|
700
759
|
if (state === GenStateExecuting) {
|
|
701
760
|
throw new Error("Generator is already running");
|
|
702
761
|
}
|
|
762
|
+
|
|
703
763
|
if (state === GenStateCompleted) {
|
|
704
764
|
if (method === "throw") {
|
|
705
765
|
throw arg;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
766
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
709
767
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
768
|
+
|
|
769
|
+
|
|
710
770
|
return doneResult();
|
|
711
771
|
}
|
|
772
|
+
|
|
712
773
|
context.method = method;
|
|
713
774
|
context.arg = arg;
|
|
775
|
+
|
|
714
776
|
while (true) {
|
|
715
777
|
var delegate = context.delegate;
|
|
778
|
+
|
|
716
779
|
if (delegate) {
|
|
717
780
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
781
|
+
|
|
718
782
|
if (delegateResult) {
|
|
719
783
|
if (delegateResult === ContinueSentinel) continue;
|
|
720
784
|
return delegateResult;
|
|
721
785
|
}
|
|
722
786
|
}
|
|
787
|
+
|
|
723
788
|
if (context.method === "next") {
|
|
724
789
|
// Setting context._sent for legacy support of Babel's
|
|
725
790
|
// function.sent implementation.
|
|
@@ -729,44 +794,51 @@ var runtime = {exports: {}};
|
|
|
729
794
|
state = GenStateCompleted;
|
|
730
795
|
throw context.arg;
|
|
731
796
|
}
|
|
797
|
+
|
|
732
798
|
context.dispatchException(context.arg);
|
|
733
799
|
} else if (context.method === "return") {
|
|
734
800
|
context.abrupt("return", context.arg);
|
|
735
801
|
}
|
|
802
|
+
|
|
736
803
|
state = GenStateExecuting;
|
|
737
804
|
var record = tryCatch(innerFn, self, context);
|
|
805
|
+
|
|
738
806
|
if (record.type === "normal") {
|
|
739
807
|
// If an exception is thrown from innerFn, we leave state ===
|
|
740
808
|
// GenStateExecuting and loop back for another invocation.
|
|
741
809
|
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
810
|
+
|
|
742
811
|
if (record.arg === ContinueSentinel) {
|
|
743
812
|
continue;
|
|
744
813
|
}
|
|
814
|
+
|
|
745
815
|
return {
|
|
746
816
|
value: record.arg,
|
|
747
817
|
done: context.done
|
|
748
818
|
};
|
|
749
819
|
} else if (record.type === "throw") {
|
|
750
|
-
state = GenStateCompleted;
|
|
751
|
-
// Dispatch the exception by looping back around to the
|
|
820
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
752
821
|
// context.dispatchException(context.arg) call above.
|
|
822
|
+
|
|
753
823
|
context.method = "throw";
|
|
754
824
|
context.arg = record.arg;
|
|
755
825
|
}
|
|
756
826
|
}
|
|
757
827
|
};
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
828
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
761
829
|
// result, either by returning a { value, done } result from the
|
|
762
830
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
763
831
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
832
|
+
|
|
833
|
+
|
|
764
834
|
function maybeInvokeDelegate(delegate, context) {
|
|
765
835
|
var method = delegate.iterator[context.method];
|
|
836
|
+
|
|
766
837
|
if (method === undefined$1) {
|
|
767
838
|
// A .throw or .return when the delegate iterator has no .throw
|
|
768
839
|
// method always terminates the yield* loop.
|
|
769
840
|
context.delegate = null;
|
|
841
|
+
|
|
770
842
|
if (context.method === "throw") {
|
|
771
843
|
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
772
844
|
if (delegate.iterator["return"]) {
|
|
@@ -775,45 +847,51 @@ var runtime = {exports: {}};
|
|
|
775
847
|
context.method = "return";
|
|
776
848
|
context.arg = undefined$1;
|
|
777
849
|
maybeInvokeDelegate(delegate, context);
|
|
850
|
+
|
|
778
851
|
if (context.method === "throw") {
|
|
779
852
|
// If maybeInvokeDelegate(context) changed context.method from
|
|
780
853
|
// "return" to "throw", let that override the TypeError below.
|
|
781
854
|
return ContinueSentinel;
|
|
782
855
|
}
|
|
783
856
|
}
|
|
857
|
+
|
|
784
858
|
context.method = "throw";
|
|
785
859
|
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
786
860
|
}
|
|
861
|
+
|
|
787
862
|
return ContinueSentinel;
|
|
788
863
|
}
|
|
864
|
+
|
|
789
865
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
866
|
+
|
|
790
867
|
if (record.type === "throw") {
|
|
791
868
|
context.method = "throw";
|
|
792
869
|
context.arg = record.arg;
|
|
793
870
|
context.delegate = null;
|
|
794
871
|
return ContinueSentinel;
|
|
795
872
|
}
|
|
873
|
+
|
|
796
874
|
var info = record.arg;
|
|
875
|
+
|
|
797
876
|
if (!info) {
|
|
798
877
|
context.method = "throw";
|
|
799
878
|
context.arg = new TypeError("iterator result is not an object");
|
|
800
879
|
context.delegate = null;
|
|
801
880
|
return ContinueSentinel;
|
|
802
881
|
}
|
|
882
|
+
|
|
803
883
|
if (info.done) {
|
|
804
884
|
// Assign the result of the finished delegate to the temporary
|
|
805
885
|
// variable specified by delegate.resultName (see delegateYield).
|
|
806
|
-
context[delegate.resultName] = info.value;
|
|
807
|
-
|
|
808
|
-
// Resume execution at the desired location (see delegateYield).
|
|
809
|
-
context.next = delegate.nextLoc;
|
|
886
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
810
887
|
|
|
811
|
-
// If context.method was "throw" but the delegate handled the
|
|
888
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
812
889
|
// exception, let the outer generator proceed normally. If
|
|
813
890
|
// context.method was "next", forget context.arg since it has been
|
|
814
891
|
// "consumed" by the delegate iterator. If context.method was
|
|
815
892
|
// "return", allow the original .return call to continue in the
|
|
816
893
|
// outer generator.
|
|
894
|
+
|
|
817
895
|
if (context.method !== "return") {
|
|
818
896
|
context.method = "next";
|
|
819
897
|
context.arg = undefined$1;
|
|
@@ -821,49 +899,55 @@ var runtime = {exports: {}};
|
|
|
821
899
|
} else {
|
|
822
900
|
// Re-yield the result returned by the delegate method.
|
|
823
901
|
return info;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
902
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
827
903
|
// the outer generator.
|
|
904
|
+
|
|
905
|
+
|
|
828
906
|
context.delegate = null;
|
|
829
907
|
return ContinueSentinel;
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
908
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
833
909
|
// unified ._invoke helper method.
|
|
834
|
-
defineIteratorMethods(Gp);
|
|
835
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
836
910
|
|
|
837
|
-
|
|
911
|
+
|
|
912
|
+
defineIteratorMethods(Gp);
|
|
913
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
838
914
|
// @@iterator function is called on it. Some browsers' implementations of the
|
|
839
915
|
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
840
916
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
841
917
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
842
|
-
|
|
918
|
+
|
|
919
|
+
Gp[iteratorSymbol] = function () {
|
|
843
920
|
return this;
|
|
844
|
-
}
|
|
845
|
-
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
Gp.toString = function () {
|
|
846
924
|
return "[object Generator]";
|
|
847
|
-
}
|
|
925
|
+
};
|
|
926
|
+
|
|
848
927
|
function pushTryEntry(locs) {
|
|
849
928
|
var entry = {
|
|
850
929
|
tryLoc: locs[0]
|
|
851
930
|
};
|
|
931
|
+
|
|
852
932
|
if (1 in locs) {
|
|
853
933
|
entry.catchLoc = locs[1];
|
|
854
934
|
}
|
|
935
|
+
|
|
855
936
|
if (2 in locs) {
|
|
856
937
|
entry.finallyLoc = locs[2];
|
|
857
938
|
entry.afterLoc = locs[3];
|
|
858
939
|
}
|
|
940
|
+
|
|
859
941
|
this.tryEntries.push(entry);
|
|
860
942
|
}
|
|
943
|
+
|
|
861
944
|
function resetTryEntry(entry) {
|
|
862
945
|
var record = entry.completion || {};
|
|
863
946
|
record.type = "normal";
|
|
864
947
|
delete record.arg;
|
|
865
948
|
entry.completion = record;
|
|
866
949
|
}
|
|
950
|
+
|
|
867
951
|
function Context(tryLocsList) {
|
|
868
952
|
// The root entry object (effectively a try statement without a catch
|
|
869
953
|
// or a finally block) gives us a place to store values thrown from
|
|
@@ -874,84 +958,97 @@ var runtime = {exports: {}};
|
|
|
874
958
|
tryLocsList.forEach(pushTryEntry, this);
|
|
875
959
|
this.reset(true);
|
|
876
960
|
}
|
|
961
|
+
|
|
877
962
|
exports.keys = function (object) {
|
|
878
963
|
var keys = [];
|
|
964
|
+
|
|
879
965
|
for (var key in object) {
|
|
880
966
|
keys.push(key);
|
|
881
967
|
}
|
|
882
|
-
keys.reverse();
|
|
883
968
|
|
|
884
|
-
// Rather than returning an object with a next method, we keep
|
|
969
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
885
970
|
// things simple and return the next function itself.
|
|
971
|
+
|
|
886
972
|
return function next() {
|
|
887
973
|
while (keys.length) {
|
|
888
974
|
var key = keys.pop();
|
|
975
|
+
|
|
889
976
|
if (key in object) {
|
|
890
977
|
next.value = key;
|
|
891
978
|
next.done = false;
|
|
892
979
|
return next;
|
|
893
980
|
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
// To avoid creating an additional object, we just hang the .value
|
|
981
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
897
982
|
// and .done properties off the next function object itself. This
|
|
898
983
|
// also ensures that the minifier will not anonymize the function.
|
|
984
|
+
|
|
985
|
+
|
|
899
986
|
next.done = true;
|
|
900
987
|
return next;
|
|
901
988
|
};
|
|
902
989
|
};
|
|
990
|
+
|
|
903
991
|
function values(iterable) {
|
|
904
992
|
if (iterable) {
|
|
905
993
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
994
|
+
|
|
906
995
|
if (iteratorMethod) {
|
|
907
996
|
return iteratorMethod.call(iterable);
|
|
908
997
|
}
|
|
998
|
+
|
|
909
999
|
if (typeof iterable.next === "function") {
|
|
910
1000
|
return iterable;
|
|
911
1001
|
}
|
|
1002
|
+
|
|
912
1003
|
if (!isNaN(iterable.length)) {
|
|
913
1004
|
var i = -1,
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}
|
|
1005
|
+
next = function next() {
|
|
1006
|
+
while (++i < iterable.length) {
|
|
1007
|
+
if (hasOwn.call(iterable, i)) {
|
|
1008
|
+
next.value = iterable[i];
|
|
1009
|
+
next.done = false;
|
|
1010
|
+
return next;
|
|
921
1011
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
next.value = undefined$1;
|
|
1015
|
+
next.done = true;
|
|
1016
|
+
return next;
|
|
1017
|
+
};
|
|
1018
|
+
|
|
926
1019
|
return next.next = next;
|
|
927
1020
|
}
|
|
928
|
-
}
|
|
1021
|
+
} // Return an iterator with no values.
|
|
1022
|
+
|
|
929
1023
|
|
|
930
|
-
// Return an iterator with no values.
|
|
931
1024
|
return {
|
|
932
1025
|
next: doneResult
|
|
933
1026
|
};
|
|
934
1027
|
}
|
|
1028
|
+
|
|
935
1029
|
exports.values = values;
|
|
1030
|
+
|
|
936
1031
|
function doneResult() {
|
|
937
1032
|
return {
|
|
938
1033
|
value: undefined$1,
|
|
939
1034
|
done: true
|
|
940
1035
|
};
|
|
941
1036
|
}
|
|
1037
|
+
|
|
942
1038
|
Context.prototype = {
|
|
943
1039
|
constructor: Context,
|
|
944
1040
|
reset: function reset(skipTempReset) {
|
|
945
1041
|
this.prev = 0;
|
|
946
|
-
this.next = 0;
|
|
947
|
-
// Resetting context._sent for legacy support of Babel's
|
|
1042
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
948
1043
|
// function.sent implementation.
|
|
1044
|
+
|
|
949
1045
|
this.sent = this._sent = undefined$1;
|
|
950
1046
|
this.done = false;
|
|
951
1047
|
this.delegate = null;
|
|
952
1048
|
this.method = "next";
|
|
953
1049
|
this.arg = undefined$1;
|
|
954
1050
|
this.tryEntries.forEach(resetTryEntry);
|
|
1051
|
+
|
|
955
1052
|
if (!skipTempReset) {
|
|
956
1053
|
for (var name in this) {
|
|
957
1054
|
// Not sure about the optimal order of these conditions:
|
|
@@ -965,40 +1062,50 @@ var runtime = {exports: {}};
|
|
|
965
1062
|
this.done = true;
|
|
966
1063
|
var rootEntry = this.tryEntries[0];
|
|
967
1064
|
var rootRecord = rootEntry.completion;
|
|
1065
|
+
|
|
968
1066
|
if (rootRecord.type === "throw") {
|
|
969
1067
|
throw rootRecord.arg;
|
|
970
1068
|
}
|
|
1069
|
+
|
|
971
1070
|
return this.rval;
|
|
972
1071
|
},
|
|
973
1072
|
dispatchException: function dispatchException(exception) {
|
|
974
1073
|
if (this.done) {
|
|
975
1074
|
throw exception;
|
|
976
1075
|
}
|
|
1076
|
+
|
|
977
1077
|
var context = this;
|
|
1078
|
+
|
|
978
1079
|
function handle(loc, caught) {
|
|
979
1080
|
record.type = "throw";
|
|
980
1081
|
record.arg = exception;
|
|
981
1082
|
context.next = loc;
|
|
1083
|
+
|
|
982
1084
|
if (caught) {
|
|
983
1085
|
// If the dispatched exception was caught by a catch block,
|
|
984
1086
|
// then let that catch block handle the exception normally.
|
|
985
1087
|
context.method = "next";
|
|
986
1088
|
context.arg = undefined$1;
|
|
987
1089
|
}
|
|
1090
|
+
|
|
988
1091
|
return !!caught;
|
|
989
1092
|
}
|
|
1093
|
+
|
|
990
1094
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
991
1095
|
var entry = this.tryEntries[i];
|
|
992
1096
|
var record = entry.completion;
|
|
1097
|
+
|
|
993
1098
|
if (entry.tryLoc === "root") {
|
|
994
1099
|
// Exception thrown outside of any try block that could handle
|
|
995
1100
|
// it, so set the completion value of the entire function to
|
|
996
1101
|
// throw the exception.
|
|
997
1102
|
return handle("end");
|
|
998
1103
|
}
|
|
1104
|
+
|
|
999
1105
|
if (entry.tryLoc <= this.prev) {
|
|
1000
1106
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1001
1107
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1108
|
+
|
|
1002
1109
|
if (hasCatch && hasFinally) {
|
|
1003
1110
|
if (this.prev < entry.catchLoc) {
|
|
1004
1111
|
return handle(entry.catchLoc, true);
|
|
@@ -1022,30 +1129,36 @@ var runtime = {exports: {}};
|
|
|
1022
1129
|
abrupt: function abrupt(type, arg) {
|
|
1023
1130
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1024
1131
|
var entry = this.tryEntries[i];
|
|
1132
|
+
|
|
1025
1133
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1026
1134
|
var finallyEntry = entry;
|
|
1027
1135
|
break;
|
|
1028
1136
|
}
|
|
1029
1137
|
}
|
|
1138
|
+
|
|
1030
1139
|
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1031
1140
|
// Ignore the finally entry if control is not jumping to a
|
|
1032
1141
|
// location outside the try/catch block.
|
|
1033
1142
|
finallyEntry = null;
|
|
1034
1143
|
}
|
|
1144
|
+
|
|
1035
1145
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1036
1146
|
record.type = type;
|
|
1037
1147
|
record.arg = arg;
|
|
1148
|
+
|
|
1038
1149
|
if (finallyEntry) {
|
|
1039
1150
|
this.method = "next";
|
|
1040
1151
|
this.next = finallyEntry.finallyLoc;
|
|
1041
1152
|
return ContinueSentinel;
|
|
1042
1153
|
}
|
|
1154
|
+
|
|
1043
1155
|
return this.complete(record);
|
|
1044
1156
|
},
|
|
1045
1157
|
complete: function complete(record, afterLoc) {
|
|
1046
1158
|
if (record.type === "throw") {
|
|
1047
1159
|
throw record.arg;
|
|
1048
1160
|
}
|
|
1161
|
+
|
|
1049
1162
|
if (record.type === "break" || record.type === "continue") {
|
|
1050
1163
|
this.next = record.arg;
|
|
1051
1164
|
} else if (record.type === "return") {
|
|
@@ -1055,11 +1168,13 @@ var runtime = {exports: {}};
|
|
|
1055
1168
|
} else if (record.type === "normal" && afterLoc) {
|
|
1056
1169
|
this.next = afterLoc;
|
|
1057
1170
|
}
|
|
1171
|
+
|
|
1058
1172
|
return ContinueSentinel;
|
|
1059
1173
|
},
|
|
1060
1174
|
finish: function finish(finallyLoc) {
|
|
1061
1175
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1062
1176
|
var entry = this.tryEntries[i];
|
|
1177
|
+
|
|
1063
1178
|
if (entry.finallyLoc === finallyLoc) {
|
|
1064
1179
|
this.complete(entry.completion, entry.afterLoc);
|
|
1065
1180
|
resetTryEntry(entry);
|
|
@@ -1070,18 +1185,21 @@ var runtime = {exports: {}};
|
|
|
1070
1185
|
"catch": function _catch(tryLoc) {
|
|
1071
1186
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1072
1187
|
var entry = this.tryEntries[i];
|
|
1188
|
+
|
|
1073
1189
|
if (entry.tryLoc === tryLoc) {
|
|
1074
1190
|
var record = entry.completion;
|
|
1191
|
+
|
|
1075
1192
|
if (record.type === "throw") {
|
|
1076
1193
|
var thrown = record.arg;
|
|
1077
1194
|
resetTryEntry(entry);
|
|
1078
1195
|
}
|
|
1196
|
+
|
|
1079
1197
|
return thrown;
|
|
1080
1198
|
}
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
// The context.catch method must only be called with a location
|
|
1199
|
+
} // The context.catch method must only be called with a location
|
|
1084
1200
|
// argument that corresponds to a known catch block.
|
|
1201
|
+
|
|
1202
|
+
|
|
1085
1203
|
throw new Error("illegal catch attempt");
|
|
1086
1204
|
},
|
|
1087
1205
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
@@ -1090,46 +1208,43 @@ var runtime = {exports: {}};
|
|
|
1090
1208
|
resultName: resultName,
|
|
1091
1209
|
nextLoc: nextLoc
|
|
1092
1210
|
};
|
|
1211
|
+
|
|
1093
1212
|
if (this.method === "next") {
|
|
1094
1213
|
// Deliberately forget the last sent value so that we don't
|
|
1095
1214
|
// accidentally pass it on to the delegate.
|
|
1096
1215
|
this.arg = undefined$1;
|
|
1097
1216
|
}
|
|
1217
|
+
|
|
1098
1218
|
return ContinueSentinel;
|
|
1099
1219
|
}
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
1220
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1103
1221
|
// or not, return the runtime object so that we can declare the variable
|
|
1104
1222
|
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1105
1223
|
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1224
|
+
|
|
1106
1225
|
return exports;
|
|
1107
|
-
}(
|
|
1108
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
1226
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1109
1227
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1110
1228
|
// object. Either way, the resulting object will be used to initialize
|
|
1111
1229
|
// the regeneratorRuntime variable at the top of this file.
|
|
1112
1230
|
module.exports );
|
|
1231
|
+
|
|
1113
1232
|
try {
|
|
1114
1233
|
regeneratorRuntime = runtime;
|
|
1115
1234
|
} catch (accidentalStrictMode) {
|
|
1116
1235
|
// This module should not be running in strict mode, so the above
|
|
1117
1236
|
// assignment should always work unless something is misconfigured. Just
|
|
1118
|
-
// in case runtime.js accidentally runs in strict mode,
|
|
1119
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
1237
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
1120
1238
|
// strict mode using a global Function call. This could conceivably fail
|
|
1121
1239
|
// if a Content Security Policy forbids using Function, but in that case
|
|
1122
1240
|
// the proper solution is to fix the accidental strict mode problem. If
|
|
1123
1241
|
// you've misconfigured your bundler to force strict mode and applied a
|
|
1124
1242
|
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1125
1243
|
// problems, please detail your unique predicament in a GitHub issue.
|
|
1126
|
-
|
|
1127
|
-
globalThis.regeneratorRuntime = runtime;
|
|
1128
|
-
} else {
|
|
1129
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1130
|
-
}
|
|
1244
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1131
1245
|
}
|
|
1132
1246
|
})(runtime);
|
|
1247
|
+
|
|
1133
1248
|
var _regeneratorRuntime = runtime.exports;
|
|
1134
1249
|
|
|
1135
1250
|
var useNormalizedItems = function useNormalizedItems(items) {
|
|
@@ -1141,11 +1256,13 @@ var useNormalizedItems = function useNormalizedItems(items) {
|
|
|
1141
1256
|
label: item
|
|
1142
1257
|
};
|
|
1143
1258
|
}
|
|
1259
|
+
|
|
1144
1260
|
if (!('value' in item)) {
|
|
1145
1261
|
return _extends({}, item, {
|
|
1146
1262
|
value: item.label
|
|
1147
1263
|
});
|
|
1148
1264
|
}
|
|
1265
|
+
|
|
1149
1266
|
return item;
|
|
1150
1267
|
});
|
|
1151
1268
|
}, [items]);
|
|
@@ -1160,6 +1277,7 @@ var useIsMounted = function useIsMounted() {
|
|
|
1160
1277
|
}, []);
|
|
1161
1278
|
return isMountedRef.current;
|
|
1162
1279
|
};
|
|
1280
|
+
|
|
1163
1281
|
var reducer = function reducer(_state, action) {
|
|
1164
1282
|
switch (action.type) {
|
|
1165
1283
|
case 'request results':
|
|
@@ -1167,6 +1285,7 @@ var reducer = function reducer(_state, action) {
|
|
|
1167
1285
|
items: [],
|
|
1168
1286
|
loading: true
|
|
1169
1287
|
};
|
|
1288
|
+
|
|
1170
1289
|
case 'received results':
|
|
1171
1290
|
return {
|
|
1172
1291
|
items: action.payload,
|
|
@@ -1174,34 +1293,40 @@ var reducer = function reducer(_state, action) {
|
|
|
1174
1293
|
};
|
|
1175
1294
|
}
|
|
1176
1295
|
};
|
|
1177
|
-
|
|
1178
|
-
|
|
1296
|
+
|
|
1297
|
+
var useResolvedItems = function useResolvedItems(
|
|
1298
|
+
/** The list of items, or an async function that resolves the list of items */
|
|
1299
|
+
itemsOrItemsResolver,
|
|
1300
|
+
/** The time to wait after the input changes to the fetchItems method is called */
|
|
1179
1301
|
debounceTimeout) {
|
|
1180
1302
|
if (debounceTimeout === void 0) {
|
|
1181
1303
|
debounceTimeout = 250;
|
|
1182
1304
|
}
|
|
1183
|
-
|
|
1184
|
-
// Here, we normalize the itemsResolver argument to an async function, so we
|
|
1305
|
+
|
|
1306
|
+
var isItemsFunction = typeof itemsOrItemsResolver === 'function'; // Here, we normalize the itemsResolver argument to an async function, so we
|
|
1185
1307
|
// can use it without thinking about the differences later
|
|
1308
|
+
|
|
1186
1309
|
var itemsResolver = React__default["default"].useMemo(function () {
|
|
1187
1310
|
return isItemsFunction ? itemsOrItemsResolver : function () {
|
|
1188
1311
|
return Promise.resolve(itemsOrItemsResolver);
|
|
1189
1312
|
};
|
|
1190
1313
|
}, [itemsOrItemsResolver, isItemsFunction]);
|
|
1314
|
+
|
|
1191
1315
|
var _React$useReducer = React__default["default"].useReducer(reducer, {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
// This is a way to check whether or not the dropdown is still in the
|
|
1316
|
+
items: isItemsFunction ? [] : itemsOrItemsResolver,
|
|
1317
|
+
loading: false
|
|
1318
|
+
}),
|
|
1319
|
+
_React$useReducer$ = _React$useReducer[0],
|
|
1320
|
+
items = _React$useReducer$.items,
|
|
1321
|
+
loading = _React$useReducer$.loading,
|
|
1322
|
+
dispatch = _React$useReducer[1]; // This is a way to check whether or not the dropdown is still in the
|
|
1200
1323
|
// document. We use it below to make sure we're not updating the state of
|
|
1201
1324
|
// an unmounted component.
|
|
1202
|
-
|
|
1203
|
-
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
var isMounted = useIsMounted(); // Next, let's create the fetching function. This should be called whenever
|
|
1204
1328
|
// the input value changes
|
|
1329
|
+
|
|
1205
1330
|
var fetchItems = React__default["default"].useCallback( /*#__PURE__*/function () {
|
|
1206
1331
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
|
|
1207
1332
|
var resolvedItems;
|
|
@@ -1213,21 +1338,26 @@ debounceTimeout) {
|
|
|
1213
1338
|
_context.next = 2;
|
|
1214
1339
|
break;
|
|
1215
1340
|
}
|
|
1341
|
+
|
|
1216
1342
|
return _context.abrupt("return");
|
|
1343
|
+
|
|
1217
1344
|
case 2:
|
|
1218
1345
|
dispatch({
|
|
1219
1346
|
type: 'request results'
|
|
1220
1347
|
});
|
|
1221
1348
|
_context.next = 5;
|
|
1222
1349
|
return itemsResolver(inputValue);
|
|
1350
|
+
|
|
1223
1351
|
case 5:
|
|
1224
1352
|
resolvedItems = _context.sent;
|
|
1353
|
+
|
|
1225
1354
|
if (isMounted) {
|
|
1226
1355
|
dispatch({
|
|
1227
1356
|
type: 'received results',
|
|
1228
1357
|
payload: resolvedItems
|
|
1229
1358
|
});
|
|
1230
1359
|
}
|
|
1360
|
+
|
|
1231
1361
|
case 7:
|
|
1232
1362
|
case "end":
|
|
1233
1363
|
return _context.stop();
|
|
@@ -1235,6 +1365,7 @@ debounceTimeout) {
|
|
|
1235
1365
|
}
|
|
1236
1366
|
}, _callee);
|
|
1237
1367
|
}));
|
|
1368
|
+
|
|
1238
1369
|
return function (_x) {
|
|
1239
1370
|
return _ref.apply(this, arguments);
|
|
1240
1371
|
};
|
|
@@ -1256,36 +1387,38 @@ debounceTimeout) {
|
|
|
1256
1387
|
var _excluded$4 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
|
|
1257
1388
|
var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
1258
1389
|
var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1390
|
+
debounceTimeout = _ref.debounceTimeout,
|
|
1391
|
+
disabled = _ref.disabled,
|
|
1392
|
+
feedback = _ref.feedback,
|
|
1393
|
+
items = _ref.items,
|
|
1394
|
+
label = _ref.label,
|
|
1395
|
+
loadingText = _ref.loadingText,
|
|
1396
|
+
_ref$onChange = _ref.onChange,
|
|
1397
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
1398
|
+
return undefined;
|
|
1399
|
+
} : _ref$onChange,
|
|
1400
|
+
placeholder = _ref.placeholder,
|
|
1401
|
+
prepend = _ref.prepend,
|
|
1402
|
+
readOnly = _ref.readOnly,
|
|
1403
|
+
searchable = _ref.searchable,
|
|
1404
|
+
selectOnTab = _ref.selectOnTab,
|
|
1405
|
+
openOnFocus = _ref.openOnFocus,
|
|
1406
|
+
variant = _ref.variant,
|
|
1407
|
+
value = _ref.value,
|
|
1408
|
+
_ref$clearable = _ref.clearable,
|
|
1409
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
1410
|
+
className = _ref.className,
|
|
1411
|
+
style = _ref.style,
|
|
1412
|
+
listStyle = _ref.listStyle,
|
|
1413
|
+
itemFilter = _ref.itemFilter,
|
|
1414
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
1415
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
1416
|
+
|
|
1285
1417
|
var _useResolvedItems = useResolvedItems(items, debounceTimeout),
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1418
|
+
normalizedItems = _useResolvedItems.items,
|
|
1419
|
+
loading = _useResolvedItems.loading,
|
|
1420
|
+
fetchItems = _useResolvedItems.fetchItems;
|
|
1421
|
+
|
|
1289
1422
|
var selectedItem = value === undefined ? undefined : normalizedItems.find(function (item) {
|
|
1290
1423
|
return value === item.value;
|
|
1291
1424
|
}) || null;
|
|
@@ -1331,30 +1464,34 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
|
1331
1464
|
var _excluded$3 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
|
|
1332
1465
|
var NativeDropdown = function NativeDropdown(_ref) {
|
|
1333
1466
|
var className = _ref.className,
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1467
|
+
_ref$disabled = _ref.disabled,
|
|
1468
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
1469
|
+
_ref$readOnly = _ref.readOnly,
|
|
1470
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
1471
|
+
items = _ref.items,
|
|
1472
|
+
loadingText = _ref.loadingText,
|
|
1473
|
+
prepend = _ref.prepend,
|
|
1474
|
+
style = _ref.style,
|
|
1475
|
+
label = _ref.label,
|
|
1476
|
+
variant = _ref.variant,
|
|
1477
|
+
feedback = _ref.feedback,
|
|
1478
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
1479
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
1480
|
+
|
|
1347
1481
|
var _useResolvedItems = useResolvedItems(items),
|
|
1348
|
-
|
|
1349
|
-
|
|
1482
|
+
normalizedItems = _useResolvedItems.items,
|
|
1483
|
+
loading = _useResolvedItems.loading;
|
|
1484
|
+
|
|
1350
1485
|
var rightSideIcon = React__default["default"].createElement(icons.DownArrowIcon, {
|
|
1351
1486
|
inline: true
|
|
1352
1487
|
});
|
|
1488
|
+
|
|
1353
1489
|
if (disabled || readOnly) {
|
|
1354
1490
|
rightSideIcon = null;
|
|
1355
1491
|
} else if (loading) {
|
|
1356
1492
|
rightSideIcon = React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
1357
1493
|
}
|
|
1494
|
+
|
|
1358
1495
|
var nativeDropdownId = utils.useRandomId('eds-native-dropdown');
|
|
1359
1496
|
return React__default["default"].createElement(form.BaseFormControl, {
|
|
1360
1497
|
disabled: disabled,
|
|
@@ -1383,18 +1520,22 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
1383
1520
|
|
|
1384
1521
|
var _excluded$2 = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
|
|
1385
1522
|
var MultiSelectContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
1523
|
+
|
|
1386
1524
|
var useMultiSelectContext = function useMultiSelectContext() {
|
|
1387
1525
|
var context = React__default["default"].useContext(MultiSelectContext);
|
|
1526
|
+
|
|
1388
1527
|
if (!context) {
|
|
1389
1528
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
1390
1529
|
}
|
|
1530
|
+
|
|
1391
1531
|
return context;
|
|
1392
1532
|
};
|
|
1393
|
-
|
|
1394
|
-
//StateChangeOptions<NormalizedDropdownItemType>,
|
|
1533
|
+
|
|
1534
|
+
function stateReducer(state, //StateChangeOptions<NormalizedDropdownItemType>,
|
|
1395
1535
|
actionAndChanges) {
|
|
1396
1536
|
var changes = actionAndChanges.changes,
|
|
1397
|
-
|
|
1537
|
+
type = actionAndChanges.type;
|
|
1538
|
+
|
|
1398
1539
|
switch (type) {
|
|
1399
1540
|
case Downshift.useSelect.stateChangeTypes.MenuKeyDownEnter:
|
|
1400
1541
|
case Downshift.useSelect.stateChangeTypes.MenuKeyDownSpaceButton:
|
|
@@ -1403,84 +1544,96 @@ actionAndChanges) {
|
|
|
1403
1544
|
isOpen: true,
|
|
1404
1545
|
highlightedIndex: state.highlightedIndex
|
|
1405
1546
|
});
|
|
1547
|
+
|
|
1406
1548
|
default:
|
|
1407
1549
|
return changes;
|
|
1408
1550
|
}
|
|
1409
1551
|
}
|
|
1552
|
+
|
|
1410
1553
|
var MultiSelect = function MultiSelect(_ref) {
|
|
1411
1554
|
var input = _ref.items,
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1555
|
+
_ref$itemsSelectedLab = _ref.itemsSelectedLabel,
|
|
1556
|
+
itemsSelectedLabel = _ref$itemsSelectedLab === void 0 ? function (items) {
|
|
1557
|
+
return SelectedItemsLabel(items);
|
|
1558
|
+
} : _ref$itemsSelectedLab,
|
|
1559
|
+
label = _ref.label,
|
|
1560
|
+
feedback = _ref.feedback,
|
|
1561
|
+
variant = _ref.variant,
|
|
1562
|
+
disabled = _ref.disabled,
|
|
1563
|
+
_ref$readOnly = _ref.readOnly,
|
|
1564
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
1565
|
+
_ref$onChange = _ref.onChange,
|
|
1566
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
1567
|
+
return undefined;
|
|
1568
|
+
} : _ref$onChange,
|
|
1569
|
+
className = _ref.className,
|
|
1570
|
+
_ref$clearable = _ref.clearable,
|
|
1571
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
1572
|
+
_ref$loading = _ref.loading,
|
|
1573
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
1574
|
+
_ref$loadingText = _ref.loadingText,
|
|
1575
|
+
loadingText = _ref$loadingText === void 0 ? '' : _ref$loadingText,
|
|
1576
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
1577
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
1578
|
+
style = _ref.style,
|
|
1579
|
+
listStyle = _ref.listStyle,
|
|
1580
|
+
_ref$initialSelectedI = _ref.initialSelectedItems,
|
|
1581
|
+
initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
|
|
1582
|
+
debounceTimeout = _ref.debounceTimeout,
|
|
1583
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1584
|
+
|
|
1441
1585
|
var _useResolvedItems = useResolvedItems(input, debounceTimeout),
|
|
1442
|
-
|
|
1586
|
+
items = _useResolvedItems.items;
|
|
1587
|
+
|
|
1443
1588
|
var _useState = React.useState(initialSelectedItems),
|
|
1444
|
-
|
|
1445
|
-
|
|
1589
|
+
selectedItems = _useState[0],
|
|
1590
|
+
setSelectedItems = _useState[1];
|
|
1591
|
+
|
|
1446
1592
|
var reset = React__default["default"].useCallback(function () {
|
|
1447
1593
|
setSelectedItems([]);
|
|
1448
1594
|
}, []);
|
|
1595
|
+
|
|
1449
1596
|
function isSelected(selectedCheckboxItem) {
|
|
1450
1597
|
return selectedItems.some(function (selected) {
|
|
1451
1598
|
return selected.value === selectedCheckboxItem.value;
|
|
1452
1599
|
});
|
|
1453
1600
|
}
|
|
1601
|
+
|
|
1454
1602
|
var _useSelect = Downshift.useSelect(_extends({
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
var itemIsFound = isSelected(selectedItem);
|
|
1464
|
-
if (itemIsFound) {
|
|
1465
|
-
var slicedItemList = selectedItems.filter(function (item) {
|
|
1466
|
-
return item.value !== selectedItem.value;
|
|
1467
|
-
});
|
|
1468
|
-
setSelectedItems(slicedItemList);
|
|
1469
|
-
onChange(slicedItemList);
|
|
1470
|
-
} else {
|
|
1471
|
-
var _slicedItemList = [].concat(selectedItems, [selectedItem]);
|
|
1472
|
-
setSelectedItems(_slicedItemList);
|
|
1473
|
-
onChange(_slicedItemList);
|
|
1474
|
-
}
|
|
1603
|
+
items: items,
|
|
1604
|
+
stateReducer: stateReducer,
|
|
1605
|
+
selectedItem: null,
|
|
1606
|
+
onSelectedItemChange: function onSelectedItemChange(_ref2) {
|
|
1607
|
+
var selectedItem = _ref2.selectedItem;
|
|
1608
|
+
|
|
1609
|
+
if (!selectedItem) {
|
|
1610
|
+
return;
|
|
1475
1611
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1612
|
+
|
|
1613
|
+
var itemIsFound = isSelected(selectedItem);
|
|
1614
|
+
|
|
1615
|
+
if (itemIsFound) {
|
|
1616
|
+
var slicedItemList = selectedItems.filter(function (item) {
|
|
1617
|
+
return item.value !== selectedItem.value;
|
|
1618
|
+
});
|
|
1619
|
+
setSelectedItems(slicedItemList);
|
|
1620
|
+
onChange(slicedItemList);
|
|
1621
|
+
} else {
|
|
1622
|
+
var _slicedItemList = [].concat(selectedItems, [selectedItem]);
|
|
1623
|
+
|
|
1624
|
+
setSelectedItems(_slicedItemList);
|
|
1625
|
+
onChange(_slicedItemList);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}, rest)),
|
|
1629
|
+
isOpen = _useSelect.isOpen,
|
|
1630
|
+
getToggleButtonProps = _useSelect.getToggleButtonProps,
|
|
1631
|
+
getLabelProps = _useSelect.getLabelProps,
|
|
1632
|
+
getMenuProps = _useSelect.getMenuProps,
|
|
1633
|
+
highlightedIndex = _useSelect.highlightedIndex,
|
|
1634
|
+
getItemProps = _useSelect.getItemProps,
|
|
1635
|
+
openMenu = _useSelect.openMenu;
|
|
1636
|
+
|
|
1484
1637
|
var buttonText = selectedItems.length ? itemsSelectedLabel(selectedItems) : '';
|
|
1485
1638
|
var multiSelectId = utils.useRandomId('eds-multiselect');
|
|
1486
1639
|
return React__default["default"].createElement(MultiSelectContext.Provider, {
|
|
@@ -1557,10 +1710,13 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
1557
1710
|
})));
|
|
1558
1711
|
}))));
|
|
1559
1712
|
};
|
|
1713
|
+
|
|
1560
1714
|
var ClearButton = function ClearButton(_ref3) {
|
|
1561
|
-
var props = _extends({},
|
|
1715
|
+
var props = _extends({}, _ref3);
|
|
1716
|
+
|
|
1562
1717
|
var _useMultiSelectContex = useMultiSelectContext(),
|
|
1563
|
-
|
|
1718
|
+
reset = _useMultiSelectContex.reset;
|
|
1719
|
+
|
|
1564
1720
|
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("button", _extends({
|
|
1565
1721
|
className: "eds-dropdown__clear-button",
|
|
1566
1722
|
type: "button",
|
|
@@ -1572,25 +1728,31 @@ var ClearButton = function ClearButton(_ref3) {
|
|
|
1572
1728
|
className: "eds-dropdown__divider"
|
|
1573
1729
|
}));
|
|
1574
1730
|
};
|
|
1731
|
+
|
|
1575
1732
|
var Appendix$1 = function Appendix(_ref4) {
|
|
1576
1733
|
var loading = _ref4.loading,
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1734
|
+
loadingText = _ref4.loadingText,
|
|
1735
|
+
readOnly = _ref4.readOnly,
|
|
1736
|
+
hasSelected = _ref4.hasSelected;
|
|
1737
|
+
|
|
1580
1738
|
if (loading) {
|
|
1581
1739
|
return React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
1582
1740
|
}
|
|
1741
|
+
|
|
1583
1742
|
if (readOnly) {
|
|
1584
1743
|
return null;
|
|
1585
1744
|
}
|
|
1745
|
+
|
|
1586
1746
|
return hasSelected ? React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(ClearButton, null), React__default["default"].createElement(DropdownToggleButton, null)) : React__default["default"].createElement(DropdownToggleButton, null);
|
|
1587
1747
|
};
|
|
1748
|
+
|
|
1588
1749
|
var DropdownToggleButton = function DropdownToggleButton() {
|
|
1589
1750
|
var _useMultiSelectContex2 = useMultiSelectContext(),
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1751
|
+
getToggleButtonProps = _useMultiSelectContex2.getToggleButtonProps,
|
|
1752
|
+
isOpen = _useMultiSelectContex2.isOpen,
|
|
1753
|
+
openMenu = _useMultiSelectContex2.openMenu,
|
|
1754
|
+
openOnFocus = _useMultiSelectContex2.openOnFocus;
|
|
1755
|
+
|
|
1594
1756
|
return React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
1595
1757
|
className: classNames__default["default"]('eds-dropdown__toggle-button', {
|
|
1596
1758
|
'eds-dropdown__toggle-button--open': isOpen
|
|
@@ -1604,6 +1766,7 @@ var DropdownToggleButton = function DropdownToggleButton() {
|
|
|
1604
1766
|
type: "button"
|
|
1605
1767
|
}), React__default["default"].createElement(icons.DownArrowIcon, null));
|
|
1606
1768
|
};
|
|
1769
|
+
|
|
1607
1770
|
var CheckboxIcon = function CheckboxIcon() {
|
|
1608
1771
|
return React__default["default"].createElement("svg", {
|
|
1609
1772
|
className: "eds-checkbox-icon",
|
|
@@ -1616,6 +1779,7 @@ var CheckboxIcon = function CheckboxIcon() {
|
|
|
1616
1779
|
fill: "none"
|
|
1617
1780
|
}));
|
|
1618
1781
|
};
|
|
1782
|
+
|
|
1619
1783
|
function SelectedItemsLabel(items) {
|
|
1620
1784
|
return items.length < 3 ? items.map(function (item) {
|
|
1621
1785
|
return item.label;
|
|
@@ -1625,13 +1789,14 @@ function SelectedItemsLabel(items) {
|
|
|
1625
1789
|
var _excluded$1 = ["selectedItem", "isOpen", "getMenuProps", "getItemProps", "filteredItems", "highlightedIndex", "listStyle"];
|
|
1626
1790
|
var DropdownList = function DropdownList(_ref) {
|
|
1627
1791
|
var selectedItem = _ref.selectedItem,
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1792
|
+
isOpen = _ref.isOpen,
|
|
1793
|
+
getMenuProps = _ref.getMenuProps,
|
|
1794
|
+
getItemProps = _ref.getItemProps,
|
|
1795
|
+
filteredItems = _ref.filteredItems,
|
|
1796
|
+
highlightedIndex = _ref.highlightedIndex,
|
|
1797
|
+
listStyle = _ref.listStyle,
|
|
1798
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1799
|
+
|
|
1635
1800
|
return React__default["default"].createElement("ul", _extends({
|
|
1636
1801
|
className: classNames__default["default"]('eds-searchable-dropdown__list', {
|
|
1637
1802
|
'eds-searchable-dropdown__list--open': isOpen
|
|
@@ -1639,8 +1804,7 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1639
1804
|
}, getMenuProps(), {
|
|
1640
1805
|
style: _extends({}, rest.style, listStyle)
|
|
1641
1806
|
}), isOpen ? filteredItems.map(function (item, index) {
|
|
1642
|
-
return (
|
|
1643
|
-
// eslint-disable-next-line react/jsx-key
|
|
1807
|
+
return (// eslint-disable-next-line react/jsx-key
|
|
1644
1808
|
React__default["default"].createElement("li", _extends({
|
|
1645
1809
|
className: classNames__default["default"]('eds-searchable-dropdown__list__item', {
|
|
1646
1810
|
'eds-searchable-dropdown__list__item--highlighted': highlightedIndex === index,
|
|
@@ -1662,45 +1826,53 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1662
1826
|
};
|
|
1663
1827
|
|
|
1664
1828
|
var _excluded = ["items", "selectedItem", "onChange", "label", "placeholder", "clearable", "openOnFocus", "readonly", "feedback", "variant", "className", "listStyle"];
|
|
1829
|
+
|
|
1665
1830
|
function lowerCaseFilterTest(item, input) {
|
|
1666
1831
|
if (!input) {
|
|
1667
1832
|
return true;
|
|
1668
1833
|
}
|
|
1834
|
+
|
|
1669
1835
|
var sanitizeEscapeCharacters = input.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
1670
1836
|
var inputRegex = new RegExp(sanitizeEscapeCharacters, 'i');
|
|
1671
1837
|
return inputRegex.test(item.label);
|
|
1672
|
-
}
|
|
1673
|
-
// TODO Husk å @deprecate searchable-prop-en til Dropdown når denne komponenten skal ha official release
|
|
1838
|
+
} // TODO Husk å @deprecate searchable-prop-en til Dropdown når denne komponenten skal ha official release
|
|
1674
1839
|
// TODO Husk å generelt legge inn støtte for typeof value === string
|
|
1840
|
+
|
|
1841
|
+
|
|
1675
1842
|
var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
1676
1843
|
var _selectedItem$label;
|
|
1844
|
+
|
|
1677
1845
|
var items = _ref.items,
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1846
|
+
value = _ref.selectedItem,
|
|
1847
|
+
onChange = _ref.onChange,
|
|
1848
|
+
label = _ref.label,
|
|
1849
|
+
placeholder = _ref.placeholder,
|
|
1850
|
+
_ref$clearable = _ref.clearable,
|
|
1851
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
1852
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
1853
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
1854
|
+
_ref$readonly = _ref.readonly,
|
|
1855
|
+
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
1856
|
+
feedback = _ref.feedback,
|
|
1857
|
+
_ref$variant = _ref.variant,
|
|
1858
|
+
variant = _ref$variant === void 0 ? 'info' : _ref$variant,
|
|
1859
|
+
className = _ref.className,
|
|
1860
|
+
listStyle = _ref.listStyle,
|
|
1861
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1862
|
+
|
|
1694
1863
|
var _React$useState = React__default["default"].useState(items),
|
|
1695
|
-
|
|
1696
|
-
|
|
1864
|
+
filteredItems = _React$useState[0],
|
|
1865
|
+
setFilteredItems = _React$useState[1];
|
|
1866
|
+
|
|
1697
1867
|
var _useState = React.useState(false),
|
|
1698
|
-
|
|
1699
|
-
|
|
1868
|
+
hideSelectedItem = _useState[0],
|
|
1869
|
+
setHideSelectedItem = _useState[1];
|
|
1870
|
+
|
|
1700
1871
|
var inputRef = React.useRef(null);
|
|
1701
1872
|
var stateReducer = React__default["default"].useCallback(function (_, actionAndChanges) {
|
|
1702
1873
|
var type = actionAndChanges.type,
|
|
1703
|
-
|
|
1874
|
+
changes = actionAndChanges.changes;
|
|
1875
|
+
|
|
1704
1876
|
switch (type) {
|
|
1705
1877
|
case Downshift.useCombobox.stateChangeTypes.ItemClick:
|
|
1706
1878
|
case Downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
@@ -1709,40 +1881,43 @@ var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
|
1709
1881
|
return _extends({}, changes, changes.selectedItem && {
|
|
1710
1882
|
inputValue: ''
|
|
1711
1883
|
});
|
|
1884
|
+
|
|
1712
1885
|
default:
|
|
1713
1886
|
return changes;
|
|
1714
1887
|
}
|
|
1715
1888
|
}, []);
|
|
1889
|
+
|
|
1716
1890
|
var _useCombobox = Downshift.useCombobox(_extends({
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1891
|
+
onInputValueChange: function onInputValueChange(_ref2) {
|
|
1892
|
+
var inputValue = _ref2.inputValue;
|
|
1893
|
+
setFilteredItems(items.filter(function (item) {
|
|
1894
|
+
return lowerCaseFilterTest(item, inputValue);
|
|
1895
|
+
}));
|
|
1896
|
+
},
|
|
1897
|
+
items: filteredItems,
|
|
1898
|
+
itemToString: function itemToString(item) {
|
|
1899
|
+
if (item) return item.value;
|
|
1900
|
+
return '';
|
|
1901
|
+
},
|
|
1902
|
+
stateReducer: stateReducer,
|
|
1903
|
+
selectedItem: value,
|
|
1904
|
+
onSelectedItemChange: function onSelectedItemChange(_ref3) {
|
|
1905
|
+
var newSelectedItem = _ref3.selectedItem;
|
|
1906
|
+
return onChange(newSelectedItem != null ? newSelectedItem : null);
|
|
1907
|
+
}
|
|
1908
|
+
}, rest)),
|
|
1909
|
+
isOpen = _useCombobox.isOpen,
|
|
1910
|
+
getToggleButtonProps = _useCombobox.getToggleButtonProps,
|
|
1911
|
+
getLabelProps = _useCombobox.getLabelProps,
|
|
1912
|
+
getMenuProps = _useCombobox.getMenuProps,
|
|
1913
|
+
getInputProps = _useCombobox.getInputProps,
|
|
1914
|
+
getComboboxProps = _useCombobox.getComboboxProps,
|
|
1915
|
+
highlightedIndex = _useCombobox.highlightedIndex,
|
|
1916
|
+
getItemProps = _useCombobox.getItemProps,
|
|
1917
|
+
selectedItem = _useCombobox.selectedItem,
|
|
1918
|
+
openMenu = _useCombobox.openMenu,
|
|
1919
|
+
inputValue = _useCombobox.inputValue;
|
|
1920
|
+
|
|
1746
1921
|
return React__default["default"].createElement("div", {
|
|
1747
1922
|
className: "eds-searchable-dropdown__wrapper"
|
|
1748
1923
|
}, React__default["default"].createElement(form.BaseFormControl, _extends({
|
|
@@ -1769,6 +1944,7 @@ var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
|
1769
1944
|
className: "eds-searchable-dropdown__selected-item",
|
|
1770
1945
|
onClick: function onClick() {
|
|
1771
1946
|
var _inputRef$current;
|
|
1947
|
+
|
|
1772
1948
|
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
1773
1949
|
}
|
|
1774
1950
|
}, selectedItem.label)), React__default["default"].createElement("input", _extends({
|
|
@@ -1793,13 +1969,15 @@ var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
|
1793
1969
|
getItemProps: getItemProps
|
|
1794
1970
|
}));
|
|
1795
1971
|
};
|
|
1972
|
+
|
|
1796
1973
|
var Appendix = function Appendix(_ref4) {
|
|
1797
1974
|
var clearable = _ref4.clearable,
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1975
|
+
readOnly = _ref4.readOnly,
|
|
1976
|
+
getToggleButtonProps = _ref4.getToggleButtonProps,
|
|
1977
|
+
selectedItem = _ref4.selectedItem,
|
|
1978
|
+
isOpen = _ref4.isOpen,
|
|
1979
|
+
onChange = _ref4.onChange;
|
|
1980
|
+
|
|
1803
1981
|
// TODO implement loading / async
|
|
1804
1982
|
// if (loading) {
|
|
1805
1983
|
// return <DropdownLoadingDots>{loadingText}</DropdownLoadingDots>;
|
|
@@ -1807,6 +1985,7 @@ var Appendix = function Appendix(_ref4) {
|
|
|
1807
1985
|
if (readOnly) {
|
|
1808
1986
|
return null;
|
|
1809
1987
|
}
|
|
1988
|
+
|
|
1810
1989
|
return React__default["default"].createElement("div", {
|
|
1811
1990
|
style: {
|
|
1812
1991
|
display: 'flex',
|