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