@entur/dropdown 2.2.1 → 2.2.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 +7 -0
- package/dist/dropdown.cjs.development.js +935 -133
- 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 +872 -72
- package/dist/dropdown.esm.js.map +1 -1
- package/package.json +14 -14
|
@@ -2,20 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var utils = require('@entur/utils');
|
|
8
6
|
var React = require('react');
|
|
9
|
-
var React__default = _interopDefault(React);
|
|
10
7
|
var Downshift = require('downshift');
|
|
11
|
-
var
|
|
12
|
-
var classNames = _interopDefault(require('classnames'));
|
|
8
|
+
var classNames = require('classnames');
|
|
13
9
|
var form = require('@entur/form');
|
|
14
10
|
var icons = require('@entur/icons');
|
|
15
11
|
var a11y = require('@entur/a11y');
|
|
16
12
|
var loader = require('@entur/loader');
|
|
17
13
|
var tokens = require('@entur/tokens');
|
|
18
14
|
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
+
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
18
|
+
var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
|
|
19
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
20
|
+
|
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
22
|
+
try {
|
|
23
|
+
var info = gen[key](arg);
|
|
24
|
+
var value = info.value;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
reject(error);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (info.done) {
|
|
31
|
+
resolve(value);
|
|
32
|
+
} else {
|
|
33
|
+
Promise.resolve(value).then(_next, _throw);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _asyncToGenerator(fn) {
|
|
38
|
+
return function () {
|
|
39
|
+
var self = this,
|
|
40
|
+
args = arguments;
|
|
41
|
+
return new Promise(function (resolve, reject) {
|
|
42
|
+
var gen = fn.apply(self, args);
|
|
43
|
+
|
|
44
|
+
function _next(value) {
|
|
45
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _throw(err) {
|
|
49
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_next(undefined);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
19
57
|
function _extends() {
|
|
20
58
|
_extends = Object.assign || function (target) {
|
|
21
59
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -49,7 +87,8 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
49
87
|
return target;
|
|
50
88
|
}
|
|
51
89
|
|
|
52
|
-
var
|
|
90
|
+
var _excluded$8 = ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"];
|
|
91
|
+
var DownshiftContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
53
92
|
var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
54
93
|
var children = _ref.children,
|
|
55
94
|
_ref$onChange = _ref.onChange,
|
|
@@ -66,10 +105,10 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
66
105
|
style = _ref.style,
|
|
67
106
|
_ref$searchable = _ref.searchable,
|
|
68
107
|
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
69
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
108
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
70
109
|
|
|
71
110
|
var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
|
|
72
|
-
if (changes.type === Downshift__default.stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
111
|
+
if (changes.type === Downshift__default["default"].stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
73
112
|
return;
|
|
74
113
|
}
|
|
75
114
|
|
|
@@ -111,23 +150,23 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
111
150
|
}
|
|
112
151
|
};
|
|
113
152
|
|
|
114
|
-
return React__default.createElement(Downshift__default,
|
|
153
|
+
return React__default["default"].createElement(Downshift__default["default"], _extends({
|
|
115
154
|
itemToString: function itemToString(item) {
|
|
116
155
|
return item ? item.label : '';
|
|
117
156
|
},
|
|
118
157
|
onStateChange: handleStateChange,
|
|
119
158
|
stateReducer: stateReducer
|
|
120
159
|
}, rest), function (args) {
|
|
121
|
-
return React__default.createElement("div", {
|
|
122
|
-
className:
|
|
160
|
+
return React__default["default"].createElement("div", {
|
|
161
|
+
className: classNames__default["default"]('eds-input-group', className),
|
|
123
162
|
style: style
|
|
124
|
-
}, React__default.createElement(DownshiftContext.Provider, {
|
|
163
|
+
}, React__default["default"].createElement(DownshiftContext.Provider, {
|
|
125
164
|
value: args
|
|
126
165
|
}, children));
|
|
127
166
|
});
|
|
128
167
|
};
|
|
129
168
|
var useDownshift = function useDownshift() {
|
|
130
|
-
var context = React__default.useContext(DownshiftContext);
|
|
169
|
+
var context = React__default["default"].useContext(DownshiftContext);
|
|
131
170
|
|
|
132
171
|
if (!context) {
|
|
133
172
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
@@ -136,9 +175,10 @@ var useDownshift = function useDownshift() {
|
|
|
136
175
|
return context;
|
|
137
176
|
};
|
|
138
177
|
|
|
178
|
+
var _excluded$7 = ["items"];
|
|
139
179
|
var DropdownList = function DropdownList(_ref) {
|
|
140
180
|
var items = _ref.items,
|
|
141
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
181
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
142
182
|
|
|
143
183
|
var _useDownshift = useDownshift(),
|
|
144
184
|
highlightedIndex = _useDownshift.highlightedIndex,
|
|
@@ -147,14 +187,14 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
147
187
|
getItemProps = _useDownshift.getItemProps,
|
|
148
188
|
getMenuProps = _useDownshift.getMenuProps;
|
|
149
189
|
|
|
150
|
-
return React__default.createElement("ul",
|
|
151
|
-
className:
|
|
190
|
+
return React__default["default"].createElement("ul", _extends({
|
|
191
|
+
className: classNames__default["default"]('eds-dropdown-list', {
|
|
152
192
|
'eds-dropdown-list--open': isOpen
|
|
153
193
|
})
|
|
154
194
|
}, getMenuProps(), rest), isOpen ? items.map(function (item, index) {
|
|
155
195
|
return (// eslint-disable-next-line react/jsx-key
|
|
156
|
-
React__default.createElement("li",
|
|
157
|
-
className:
|
|
196
|
+
React__default["default"].createElement("li", _extends({
|
|
197
|
+
className: classNames__default["default"]('eds-dropdown-list__item', {
|
|
158
198
|
'eds-dropdown-list__item--highlighted': highlightedIndex === index,
|
|
159
199
|
'eds-dropdown-list__item--selected': selectedItem === item
|
|
160
200
|
})
|
|
@@ -162,42 +202,44 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
162
202
|
key: "" + index + item.value,
|
|
163
203
|
item: item,
|
|
164
204
|
index: index
|
|
165
|
-
})), React__default.createElement("span", null, item.label), item.icons && React__default.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
166
|
-
return React__default.createElement(Icon, {
|
|
205
|
+
})), React__default["default"].createElement("span", null, item.label), item.icons && React__default["default"].createElement("span", null, item.icons.map(function (Icon, index) {
|
|
206
|
+
return React__default["default"].createElement(Icon, {
|
|
167
207
|
key: index,
|
|
168
208
|
inline: true,
|
|
169
209
|
className: "eds-dropdown-list__item-icon"
|
|
170
210
|
});
|
|
171
|
-
})), selectedItem === item && React__default.createElement(icons.CheckIcon, null))
|
|
211
|
+
})), selectedItem === item && React__default["default"].createElement(icons.CheckIcon, null))
|
|
172
212
|
);
|
|
173
213
|
}) : null);
|
|
174
214
|
};
|
|
175
215
|
|
|
176
|
-
var DropdownToggleButton = function DropdownToggleButton() {
|
|
216
|
+
var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
177
217
|
var _useDownshift = useDownshift(),
|
|
178
218
|
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
179
219
|
isOpen = _useDownshift.isOpen;
|
|
180
220
|
|
|
181
|
-
return React__default.createElement("button",
|
|
182
|
-
className:
|
|
221
|
+
return React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
222
|
+
className: classNames__default["default"]('eds-dropdown__toggle-button', {
|
|
183
223
|
'eds-dropdown__toggle-button--open': isOpen
|
|
184
224
|
})
|
|
185
225
|
}), {
|
|
186
226
|
tabIndex: "-1",
|
|
187
227
|
type: "button"
|
|
188
|
-
}), React__default.createElement(icons.DownArrowIcon, null));
|
|
228
|
+
}), React__default["default"].createElement(icons.DownArrowIcon, null));
|
|
189
229
|
};
|
|
190
230
|
|
|
231
|
+
var _excluded$6 = ["className", "children"];
|
|
191
232
|
var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
|
|
192
233
|
var className = _ref.className,
|
|
193
234
|
children = _ref.children,
|
|
194
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
235
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
195
236
|
|
|
196
|
-
return React__default.createElement("div",
|
|
197
|
-
className:
|
|
198
|
-
}, rest), React__default.createElement(loader.LoadingDots, null), React__default.createElement(a11y.VisuallyHidden, null, children));
|
|
237
|
+
return React__default["default"].createElement("div", _extends({
|
|
238
|
+
className: classNames__default["default"]('eds-inline-spinner', className)
|
|
239
|
+
}, rest), React__default["default"].createElement(loader.LoadingDots, null), React__default["default"].createElement(a11y.VisuallyHidden, null, children));
|
|
199
240
|
};
|
|
200
241
|
|
|
242
|
+
var _excluded$5 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
|
|
201
243
|
var BaseDropdown = function BaseDropdown(_ref) {
|
|
202
244
|
var children = _ref.children,
|
|
203
245
|
className = _ref.className,
|
|
@@ -213,16 +255,16 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
213
255
|
_ref$isFilled = _ref.isFilled,
|
|
214
256
|
isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
|
|
215
257
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
216
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
258
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
217
259
|
|
|
218
260
|
var _useDownshift = useDownshift(),
|
|
219
261
|
getLabelProps = _useDownshift.getLabelProps;
|
|
220
262
|
|
|
221
|
-
return React__default.createElement("div", {
|
|
263
|
+
return React__default["default"].createElement("div", {
|
|
222
264
|
className: "eds-dropdown-wrapper",
|
|
223
265
|
style: style
|
|
224
|
-
}, React__default.createElement(form.BaseFormControl,
|
|
225
|
-
append: React__default.createElement(Appendix, {
|
|
266
|
+
}, React__default["default"].createElement(form.BaseFormControl, _extends({
|
|
267
|
+
append: React__default["default"].createElement(Appendix$1, {
|
|
226
268
|
clearable: clearable,
|
|
227
269
|
loading: loading,
|
|
228
270
|
loadingText: loadingText,
|
|
@@ -233,7 +275,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
233
275
|
isFilled: isFilled,
|
|
234
276
|
labelProps: getLabelProps(),
|
|
235
277
|
disableLabelAnimation: disableLabelAnimation
|
|
236
|
-
}, rest), children), React__default.createElement(DropdownList,
|
|
278
|
+
}, rest), children), React__default["default"].createElement(DropdownList, _extends({
|
|
237
279
|
items: items,
|
|
238
280
|
style: _extends({
|
|
239
281
|
position: 'absolute',
|
|
@@ -242,42 +284,43 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
242
284
|
}, rest)));
|
|
243
285
|
};
|
|
244
286
|
|
|
245
|
-
var ClearButton = function ClearButton(_ref2) {
|
|
287
|
+
var ClearButton$1 = function ClearButton(_ref2) {
|
|
246
288
|
var props = _extends({}, _ref2);
|
|
247
289
|
|
|
248
290
|
var _useDownshift2 = useDownshift(),
|
|
249
291
|
clearSelection = _useDownshift2.clearSelection,
|
|
250
292
|
selectedItem = _useDownshift2.selectedItem;
|
|
251
293
|
|
|
252
|
-
return React__default.createElement(React__default.Fragment, null, selectedItem && React__default.createElement("button",
|
|
294
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, selectedItem && React__default["default"].createElement("button", _extends({
|
|
253
295
|
className: "eds-dropdown__clear-button",
|
|
254
296
|
type: "button",
|
|
255
297
|
tabIndex: -1,
|
|
256
298
|
onClick: function onClick() {
|
|
257
299
|
return clearSelection();
|
|
258
300
|
}
|
|
259
|
-
}, props), React__default.createElement(icons.CloseSmallIcon, null)), selectedItem && React__default.createElement("div", {
|
|
301
|
+
}, props), React__default["default"].createElement(icons.CloseSmallIcon, null)), selectedItem && React__default["default"].createElement("div", {
|
|
260
302
|
className: "eds-dropdown__divider"
|
|
261
303
|
}));
|
|
262
304
|
};
|
|
263
305
|
|
|
264
|
-
var Appendix = function Appendix(_ref3) {
|
|
306
|
+
var Appendix$1 = function Appendix(_ref3) {
|
|
265
307
|
var clearable = _ref3.clearable,
|
|
266
308
|
loading = _ref3.loading,
|
|
267
309
|
loadingText = _ref3.loadingText,
|
|
268
310
|
readOnly = _ref3.readOnly;
|
|
269
311
|
|
|
270
312
|
if (loading) {
|
|
271
|
-
return React__default.createElement(DropdownLoadingDots, null, loadingText);
|
|
313
|
+
return React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
272
314
|
}
|
|
273
315
|
|
|
274
316
|
if (readOnly) {
|
|
275
317
|
return null;
|
|
276
318
|
}
|
|
277
319
|
|
|
278
|
-
return clearable ? React__default.createElement(React__default.Fragment, null, React__default.createElement(ClearButton, null), " ", React__default.createElement(DropdownToggleButton, null)) : React__default.createElement(DropdownToggleButton, null);
|
|
320
|
+
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);
|
|
279
321
|
};
|
|
280
322
|
|
|
323
|
+
var _excluded$4 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
|
|
281
324
|
var RegularDropdown = function RegularDropdown(_ref) {
|
|
282
325
|
var disabled = _ref.disabled,
|
|
283
326
|
_ref$placeholder = _ref.placeholder,
|
|
@@ -294,7 +337,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
294
337
|
loadingText = _ref.loadingText,
|
|
295
338
|
className = _ref.className,
|
|
296
339
|
clearable = _ref.clearable,
|
|
297
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
340
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
298
341
|
|
|
299
342
|
var _useDownshift = useDownshift(),
|
|
300
343
|
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
@@ -305,7 +348,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
305
348
|
highlightedIndex = _useDownshift.highlightedIndex,
|
|
306
349
|
setHighlightedIndex = _useDownshift.setHighlightedIndex;
|
|
307
350
|
|
|
308
|
-
return React__default.createElement(BaseDropdown,
|
|
351
|
+
return React__default["default"].createElement(BaseDropdown, _extends({
|
|
309
352
|
disabled: disabled,
|
|
310
353
|
listStyle: listStyle,
|
|
311
354
|
items: items,
|
|
@@ -316,7 +359,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
316
359
|
loadingText: loadingText,
|
|
317
360
|
className: className,
|
|
318
361
|
clearable: clearable
|
|
319
|
-
}, rest), React__default.createElement("button",
|
|
362
|
+
}, rest), React__default["default"].createElement("button", _extends({}, getToggleButtonProps(_extends({
|
|
320
363
|
className: 'eds-form-control eds-dropdown__selected-item',
|
|
321
364
|
style: {
|
|
322
365
|
textAlign: 'left'
|
|
@@ -339,7 +382,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
339
382
|
return firstCharacter === keyDownValue;
|
|
340
383
|
});
|
|
341
384
|
var nextHighlightItem = matchedItems.find(function (item) {
|
|
342
|
-
return item.index > (highlightedIndex
|
|
385
|
+
return item.index > (highlightedIndex != null ? highlightedIndex : 0);
|
|
343
386
|
});
|
|
344
387
|
|
|
345
388
|
if (nextHighlightItem) {
|
|
@@ -357,6 +400,8 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
357
400
|
}, rest))), selectedItem ? selectedItem.label : placeholder));
|
|
358
401
|
};
|
|
359
402
|
|
|
403
|
+
var _excluded$3 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
|
|
404
|
+
|
|
360
405
|
function LowerCaseFilterTest(item, input) {
|
|
361
406
|
if (!input) {
|
|
362
407
|
return true;
|
|
@@ -390,7 +435,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
390
435
|
label = _ref.label,
|
|
391
436
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
392
437
|
placeholder = _ref.placeholder,
|
|
393
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
438
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
394
439
|
|
|
395
440
|
var _useDownshift = useDownshift(),
|
|
396
441
|
getInputProps = _useDownshift.getInputProps,
|
|
@@ -400,12 +445,12 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
400
445
|
openMenu = _useDownshift.openMenu,
|
|
401
446
|
selectedItem = _useDownshift.selectedItem;
|
|
402
447
|
|
|
403
|
-
var filteredItems = React__default.useMemo(function () {
|
|
448
|
+
var filteredItems = React__default["default"].useMemo(function () {
|
|
404
449
|
return items.filter(function (item) {
|
|
405
450
|
return itemFilter(item, inputValue);
|
|
406
451
|
});
|
|
407
452
|
}, [inputValue, items, itemFilter]);
|
|
408
|
-
return React__default.createElement(BaseDropdown, {
|
|
453
|
+
return React__default["default"].createElement(BaseDropdown, {
|
|
409
454
|
items: filteredItems,
|
|
410
455
|
disabled: disabled,
|
|
411
456
|
readOnly: readOnly,
|
|
@@ -418,9 +463,9 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
418
463
|
label: label,
|
|
419
464
|
isFilled: selectedItem ? true : false,
|
|
420
465
|
disableLabelAnimation: disableLabelAnimation
|
|
421
|
-
}, selectedItem && !inputValue && React__default.createElement("span", {
|
|
466
|
+
}, selectedItem && !inputValue && React__default["default"].createElement("span", {
|
|
422
467
|
className: "eds-dropdown__searchable-selected-item"
|
|
423
|
-
}, selectedItem.label), React__default.createElement("input",
|
|
468
|
+
}, selectedItem.label), React__default["default"].createElement("input", _extends({}, getInputProps(_extends({
|
|
424
469
|
disabled: disabled,
|
|
425
470
|
readOnly: readOnly,
|
|
426
471
|
className: 'eds-form-control eds-dropdown__input',
|
|
@@ -444,18 +489,747 @@ var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
|
444
489
|
variant = _ref.variant,
|
|
445
490
|
className = _ref.className,
|
|
446
491
|
style = _ref.style;
|
|
447
|
-
return React__default.createElement(form.VariantProvider, {
|
|
492
|
+
return React__default["default"].createElement(form.VariantProvider, {
|
|
448
493
|
variant: variant
|
|
449
|
-
}, React__default.createElement("div", {
|
|
494
|
+
}, React__default["default"].createElement("div", {
|
|
450
495
|
className: className,
|
|
451
496
|
style: style
|
|
452
|
-
}, children, feedback && variant && React__default.createElement(form.FeedbackText, {
|
|
497
|
+
}, children, feedback && variant && React__default["default"].createElement(form.FeedbackText, {
|
|
453
498
|
variant: variant
|
|
454
499
|
}, feedback)));
|
|
455
500
|
};
|
|
456
501
|
|
|
502
|
+
var runtime = {exports: {}};
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
506
|
+
*
|
|
507
|
+
* This source code is licensed under the MIT license found in the
|
|
508
|
+
* LICENSE file in the root directory of this source tree.
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
(function (module) {
|
|
512
|
+
var runtime = /*#__PURE__*/function (exports) {
|
|
513
|
+
|
|
514
|
+
var Op = Object.prototype;
|
|
515
|
+
var hasOwn = Op.hasOwnProperty;
|
|
516
|
+
var undefined$1; // More compressible than void 0.
|
|
517
|
+
|
|
518
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
519
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
520
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
521
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
522
|
+
|
|
523
|
+
function define(obj, key, value) {
|
|
524
|
+
Object.defineProperty(obj, key, {
|
|
525
|
+
value: value,
|
|
526
|
+
enumerable: true,
|
|
527
|
+
configurable: true,
|
|
528
|
+
writable: true
|
|
529
|
+
});
|
|
530
|
+
return obj[key];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
try {
|
|
534
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
535
|
+
define({}, "");
|
|
536
|
+
} catch (err) {
|
|
537
|
+
define = function define(obj, key, value) {
|
|
538
|
+
return obj[key] = value;
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
543
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
544
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
545
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
546
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
547
|
+
// .throw, and .return methods.
|
|
548
|
+
|
|
549
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
550
|
+
return generator;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
554
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
555
|
+
// have been (and was previously) designed to take a closure to be
|
|
556
|
+
// invoked without arguments, but in all the cases we care about we
|
|
557
|
+
// already have an existing method we want to call, so there's no need
|
|
558
|
+
// to create a new function object. We can even get away with assuming
|
|
559
|
+
// the method takes exactly one argument, since that happens to be true
|
|
560
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
561
|
+
// only additional allocation required is the completion record, which
|
|
562
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
563
|
+
|
|
564
|
+
function tryCatch(fn, obj, arg) {
|
|
565
|
+
try {
|
|
566
|
+
return {
|
|
567
|
+
type: "normal",
|
|
568
|
+
arg: fn.call(obj, arg)
|
|
569
|
+
};
|
|
570
|
+
} catch (err) {
|
|
571
|
+
return {
|
|
572
|
+
type: "throw",
|
|
573
|
+
arg: err
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
579
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
580
|
+
var GenStateExecuting = "executing";
|
|
581
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
582
|
+
// breaking out of the dispatch switch statement.
|
|
583
|
+
|
|
584
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
585
|
+
// .constructor.prototype properties for functions that return Generator
|
|
586
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
587
|
+
// minifier not to mangle the names of these two functions.
|
|
588
|
+
|
|
589
|
+
function Generator() {}
|
|
590
|
+
|
|
591
|
+
function GeneratorFunction() {}
|
|
592
|
+
|
|
593
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
594
|
+
// don't natively support it.
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
var IteratorPrototype = {};
|
|
598
|
+
|
|
599
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
600
|
+
return this;
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
var getProto = Object.getPrototypeOf;
|
|
604
|
+
var NativeIteratorPrototype = getProto && /*#__PURE__*/getProto( /*#__PURE__*/getProto( /*#__PURE__*/values([])));
|
|
605
|
+
|
|
606
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
607
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
608
|
+
// of the polyfill.
|
|
609
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
|
|
613
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
614
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
615
|
+
GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
616
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
617
|
+
|
|
618
|
+
function defineIteratorMethods(prototype) {
|
|
619
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
620
|
+
define(prototype, method, function (arg) {
|
|
621
|
+
return this._invoke(method, arg);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
627
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
628
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
629
|
+
// do is to check its .name property.
|
|
630
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
exports.mark = function (genFun) {
|
|
634
|
+
if (Object.setPrototypeOf) {
|
|
635
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
636
|
+
} else {
|
|
637
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
638
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
genFun.prototype = Object.create(Gp);
|
|
642
|
+
return genFun;
|
|
643
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
644
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
645
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
646
|
+
// meant to be awaited.
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
exports.awrap = function (arg) {
|
|
650
|
+
return {
|
|
651
|
+
__await: arg
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
656
|
+
function invoke(method, arg, resolve, reject) {
|
|
657
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
658
|
+
|
|
659
|
+
if (record.type === "throw") {
|
|
660
|
+
reject(record.arg);
|
|
661
|
+
} else {
|
|
662
|
+
var result = record.arg;
|
|
663
|
+
var value = result.value;
|
|
664
|
+
|
|
665
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
666
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
667
|
+
invoke("next", value, resolve, reject);
|
|
668
|
+
}, function (err) {
|
|
669
|
+
invoke("throw", err, resolve, reject);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
674
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
675
|
+
// the .value of the Promise<{value,done}> result for the
|
|
676
|
+
// current iteration.
|
|
677
|
+
result.value = unwrapped;
|
|
678
|
+
resolve(result);
|
|
679
|
+
}, function (error) {
|
|
680
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
681
|
+
// into the async generator function so it can be handled there.
|
|
682
|
+
return invoke("throw", error, resolve, reject);
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
var previousPromise;
|
|
688
|
+
|
|
689
|
+
function enqueue(method, arg) {
|
|
690
|
+
function callInvokeWithMethodAndArg() {
|
|
691
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
692
|
+
invoke(method, arg, resolve, reject);
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
697
|
+
// all previous Promises have been resolved before calling invoke,
|
|
698
|
+
// so that results are always delivered in the correct order. If
|
|
699
|
+
// enqueue has not been called before, then it is important to
|
|
700
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
701
|
+
// so that the async generator function has the opportunity to do
|
|
702
|
+
// any necessary setup in a predictable way. This predictability
|
|
703
|
+
// is why the Promise constructor synchronously invokes its
|
|
704
|
+
// executor callback, and why async functions synchronously
|
|
705
|
+
// execute code before the first await. Since we implement simple
|
|
706
|
+
// async functions in terms of async generators, it is especially
|
|
707
|
+
// important to get this right, even though it requires care.
|
|
708
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
709
|
+
// invocations of the iterator.
|
|
710
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
711
|
+
} // Define the unified helper method that is used to implement .next,
|
|
712
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
this._invoke = enqueue;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
719
|
+
|
|
720
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
721
|
+
return this;
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
725
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
726
|
+
// the final result produced by the iterator.
|
|
727
|
+
|
|
728
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
729
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
730
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
731
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
732
|
+
: iter.next().then(function (result) {
|
|
733
|
+
return result.done ? result.value : iter.next();
|
|
734
|
+
});
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
738
|
+
var state = GenStateSuspendedStart;
|
|
739
|
+
return function invoke(method, arg) {
|
|
740
|
+
if (state === GenStateExecuting) {
|
|
741
|
+
throw new Error("Generator is already running");
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (state === GenStateCompleted) {
|
|
745
|
+
if (method === "throw") {
|
|
746
|
+
throw arg;
|
|
747
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
748
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
return doneResult();
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
context.method = method;
|
|
755
|
+
context.arg = arg;
|
|
756
|
+
|
|
757
|
+
while (true) {
|
|
758
|
+
var delegate = context.delegate;
|
|
759
|
+
|
|
760
|
+
if (delegate) {
|
|
761
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
762
|
+
|
|
763
|
+
if (delegateResult) {
|
|
764
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
765
|
+
return delegateResult;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (context.method === "next") {
|
|
770
|
+
// Setting context._sent for legacy support of Babel's
|
|
771
|
+
// function.sent implementation.
|
|
772
|
+
context.sent = context._sent = context.arg;
|
|
773
|
+
} else if (context.method === "throw") {
|
|
774
|
+
if (state === GenStateSuspendedStart) {
|
|
775
|
+
state = GenStateCompleted;
|
|
776
|
+
throw context.arg;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
context.dispatchException(context.arg);
|
|
780
|
+
} else if (context.method === "return") {
|
|
781
|
+
context.abrupt("return", context.arg);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
state = GenStateExecuting;
|
|
785
|
+
var record = tryCatch(innerFn, self, context);
|
|
786
|
+
|
|
787
|
+
if (record.type === "normal") {
|
|
788
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
789
|
+
// GenStateExecuting and loop back for another invocation.
|
|
790
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
791
|
+
|
|
792
|
+
if (record.arg === ContinueSentinel) {
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return {
|
|
797
|
+
value: record.arg,
|
|
798
|
+
done: context.done
|
|
799
|
+
};
|
|
800
|
+
} else if (record.type === "throw") {
|
|
801
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
802
|
+
// context.dispatchException(context.arg) call above.
|
|
803
|
+
|
|
804
|
+
context.method = "throw";
|
|
805
|
+
context.arg = record.arg;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
810
|
+
// result, either by returning a { value, done } result from the
|
|
811
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
812
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
816
|
+
var method = delegate.iterator[context.method];
|
|
817
|
+
|
|
818
|
+
if (method === undefined$1) {
|
|
819
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
820
|
+
// method always terminates the yield* loop.
|
|
821
|
+
context.delegate = null;
|
|
822
|
+
|
|
823
|
+
if (context.method === "throw") {
|
|
824
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
825
|
+
if (delegate.iterator["return"]) {
|
|
826
|
+
// If the delegate iterator has a return method, give it a
|
|
827
|
+
// chance to clean up.
|
|
828
|
+
context.method = "return";
|
|
829
|
+
context.arg = undefined$1;
|
|
830
|
+
maybeInvokeDelegate(delegate, context);
|
|
831
|
+
|
|
832
|
+
if (context.method === "throw") {
|
|
833
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
834
|
+
// "return" to "throw", let that override the TypeError below.
|
|
835
|
+
return ContinueSentinel;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
context.method = "throw";
|
|
840
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return ContinueSentinel;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
847
|
+
|
|
848
|
+
if (record.type === "throw") {
|
|
849
|
+
context.method = "throw";
|
|
850
|
+
context.arg = record.arg;
|
|
851
|
+
context.delegate = null;
|
|
852
|
+
return ContinueSentinel;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
var info = record.arg;
|
|
856
|
+
|
|
857
|
+
if (!info) {
|
|
858
|
+
context.method = "throw";
|
|
859
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
860
|
+
context.delegate = null;
|
|
861
|
+
return ContinueSentinel;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (info.done) {
|
|
865
|
+
// Assign the result of the finished delegate to the temporary
|
|
866
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
867
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
868
|
+
|
|
869
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
870
|
+
// exception, let the outer generator proceed normally. If
|
|
871
|
+
// context.method was "next", forget context.arg since it has been
|
|
872
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
873
|
+
// "return", allow the original .return call to continue in the
|
|
874
|
+
// outer generator.
|
|
875
|
+
|
|
876
|
+
if (context.method !== "return") {
|
|
877
|
+
context.method = "next";
|
|
878
|
+
context.arg = undefined$1;
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
// Re-yield the result returned by the delegate method.
|
|
882
|
+
return info;
|
|
883
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
884
|
+
// the outer generator.
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
context.delegate = null;
|
|
888
|
+
return ContinueSentinel;
|
|
889
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
890
|
+
// unified ._invoke helper method.
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
defineIteratorMethods(Gp);
|
|
894
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
895
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
896
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
897
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
898
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
899
|
+
|
|
900
|
+
Gp[iteratorSymbol] = function () {
|
|
901
|
+
return this;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
Gp.toString = function () {
|
|
905
|
+
return "[object Generator]";
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
function pushTryEntry(locs) {
|
|
909
|
+
var entry = {
|
|
910
|
+
tryLoc: locs[0]
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
if (1 in locs) {
|
|
914
|
+
entry.catchLoc = locs[1];
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
if (2 in locs) {
|
|
918
|
+
entry.finallyLoc = locs[2];
|
|
919
|
+
entry.afterLoc = locs[3];
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
this.tryEntries.push(entry);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function resetTryEntry(entry) {
|
|
926
|
+
var record = entry.completion || {};
|
|
927
|
+
record.type = "normal";
|
|
928
|
+
delete record.arg;
|
|
929
|
+
entry.completion = record;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
function Context(tryLocsList) {
|
|
933
|
+
// The root entry object (effectively a try statement without a catch
|
|
934
|
+
// or a finally block) gives us a place to store values thrown from
|
|
935
|
+
// locations where there is no enclosing try statement.
|
|
936
|
+
this.tryEntries = [{
|
|
937
|
+
tryLoc: "root"
|
|
938
|
+
}];
|
|
939
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
940
|
+
this.reset(true);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
exports.keys = function (object) {
|
|
944
|
+
var keys = [];
|
|
945
|
+
|
|
946
|
+
for (var key in object) {
|
|
947
|
+
keys.push(key);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
951
|
+
// things simple and return the next function itself.
|
|
952
|
+
|
|
953
|
+
return function next() {
|
|
954
|
+
while (keys.length) {
|
|
955
|
+
var key = keys.pop();
|
|
956
|
+
|
|
957
|
+
if (key in object) {
|
|
958
|
+
next.value = key;
|
|
959
|
+
next.done = false;
|
|
960
|
+
return next;
|
|
961
|
+
}
|
|
962
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
963
|
+
// and .done properties off the next function object itself. This
|
|
964
|
+
// also ensures that the minifier will not anonymize the function.
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
next.done = true;
|
|
968
|
+
return next;
|
|
969
|
+
};
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
function values(iterable) {
|
|
973
|
+
if (iterable) {
|
|
974
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
975
|
+
|
|
976
|
+
if (iteratorMethod) {
|
|
977
|
+
return iteratorMethod.call(iterable);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
if (typeof iterable.next === "function") {
|
|
981
|
+
return iterable;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
if (!isNaN(iterable.length)) {
|
|
985
|
+
var i = -1,
|
|
986
|
+
next = function next() {
|
|
987
|
+
while (++i < iterable.length) {
|
|
988
|
+
if (hasOwn.call(iterable, i)) {
|
|
989
|
+
next.value = iterable[i];
|
|
990
|
+
next.done = false;
|
|
991
|
+
return next;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
next.value = undefined$1;
|
|
996
|
+
next.done = true;
|
|
997
|
+
return next;
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
return next.next = next;
|
|
1001
|
+
}
|
|
1002
|
+
} // Return an iterator with no values.
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
return {
|
|
1006
|
+
next: doneResult
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
exports.values = values;
|
|
1011
|
+
|
|
1012
|
+
function doneResult() {
|
|
1013
|
+
return {
|
|
1014
|
+
value: undefined$1,
|
|
1015
|
+
done: true
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
Context.prototype = {
|
|
1020
|
+
constructor: Context,
|
|
1021
|
+
reset: function reset(skipTempReset) {
|
|
1022
|
+
this.prev = 0;
|
|
1023
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1024
|
+
// function.sent implementation.
|
|
1025
|
+
|
|
1026
|
+
this.sent = this._sent = undefined$1;
|
|
1027
|
+
this.done = false;
|
|
1028
|
+
this.delegate = null;
|
|
1029
|
+
this.method = "next";
|
|
1030
|
+
this.arg = undefined$1;
|
|
1031
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
1032
|
+
|
|
1033
|
+
if (!skipTempReset) {
|
|
1034
|
+
for (var name in this) {
|
|
1035
|
+
// Not sure about the optimal order of these conditions:
|
|
1036
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
1037
|
+
this[name] = undefined$1;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
stop: function stop() {
|
|
1043
|
+
this.done = true;
|
|
1044
|
+
var rootEntry = this.tryEntries[0];
|
|
1045
|
+
var rootRecord = rootEntry.completion;
|
|
1046
|
+
|
|
1047
|
+
if (rootRecord.type === "throw") {
|
|
1048
|
+
throw rootRecord.arg;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
return this.rval;
|
|
1052
|
+
},
|
|
1053
|
+
dispatchException: function dispatchException(exception) {
|
|
1054
|
+
if (this.done) {
|
|
1055
|
+
throw exception;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
var context = this;
|
|
1059
|
+
|
|
1060
|
+
function handle(loc, caught) {
|
|
1061
|
+
record.type = "throw";
|
|
1062
|
+
record.arg = exception;
|
|
1063
|
+
context.next = loc;
|
|
1064
|
+
|
|
1065
|
+
if (caught) {
|
|
1066
|
+
// If the dispatched exception was caught by a catch block,
|
|
1067
|
+
// then let that catch block handle the exception normally.
|
|
1068
|
+
context.method = "next";
|
|
1069
|
+
context.arg = undefined$1;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
return !!caught;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1076
|
+
var entry = this.tryEntries[i];
|
|
1077
|
+
var record = entry.completion;
|
|
1078
|
+
|
|
1079
|
+
if (entry.tryLoc === "root") {
|
|
1080
|
+
// Exception thrown outside of any try block that could handle
|
|
1081
|
+
// it, so set the completion value of the entire function to
|
|
1082
|
+
// throw the exception.
|
|
1083
|
+
return handle("end");
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
if (entry.tryLoc <= this.prev) {
|
|
1087
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1088
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1089
|
+
|
|
1090
|
+
if (hasCatch && hasFinally) {
|
|
1091
|
+
if (this.prev < entry.catchLoc) {
|
|
1092
|
+
return handle(entry.catchLoc, true);
|
|
1093
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
1094
|
+
return handle(entry.finallyLoc);
|
|
1095
|
+
}
|
|
1096
|
+
} else if (hasCatch) {
|
|
1097
|
+
if (this.prev < entry.catchLoc) {
|
|
1098
|
+
return handle(entry.catchLoc, true);
|
|
1099
|
+
}
|
|
1100
|
+
} else if (hasFinally) {
|
|
1101
|
+
if (this.prev < entry.finallyLoc) {
|
|
1102
|
+
return handle(entry.finallyLoc);
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
throw new Error("try statement without catch or finally");
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
abrupt: function abrupt(type, arg) {
|
|
1111
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1112
|
+
var entry = this.tryEntries[i];
|
|
1113
|
+
|
|
1114
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1115
|
+
var finallyEntry = entry;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1121
|
+
// Ignore the finally entry if control is not jumping to a
|
|
1122
|
+
// location outside the try/catch block.
|
|
1123
|
+
finallyEntry = null;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1127
|
+
record.type = type;
|
|
1128
|
+
record.arg = arg;
|
|
1129
|
+
|
|
1130
|
+
if (finallyEntry) {
|
|
1131
|
+
this.method = "next";
|
|
1132
|
+
this.next = finallyEntry.finallyLoc;
|
|
1133
|
+
return ContinueSentinel;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return this.complete(record);
|
|
1137
|
+
},
|
|
1138
|
+
complete: function complete(record, afterLoc) {
|
|
1139
|
+
if (record.type === "throw") {
|
|
1140
|
+
throw record.arg;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
if (record.type === "break" || record.type === "continue") {
|
|
1144
|
+
this.next = record.arg;
|
|
1145
|
+
} else if (record.type === "return") {
|
|
1146
|
+
this.rval = this.arg = record.arg;
|
|
1147
|
+
this.method = "return";
|
|
1148
|
+
this.next = "end";
|
|
1149
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
1150
|
+
this.next = afterLoc;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
return ContinueSentinel;
|
|
1154
|
+
},
|
|
1155
|
+
finish: function finish(finallyLoc) {
|
|
1156
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1157
|
+
var entry = this.tryEntries[i];
|
|
1158
|
+
|
|
1159
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
1160
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
1161
|
+
resetTryEntry(entry);
|
|
1162
|
+
return ContinueSentinel;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
"catch": function _catch(tryLoc) {
|
|
1167
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1168
|
+
var entry = this.tryEntries[i];
|
|
1169
|
+
|
|
1170
|
+
if (entry.tryLoc === tryLoc) {
|
|
1171
|
+
var record = entry.completion;
|
|
1172
|
+
|
|
1173
|
+
if (record.type === "throw") {
|
|
1174
|
+
var thrown = record.arg;
|
|
1175
|
+
resetTryEntry(entry);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
return thrown;
|
|
1179
|
+
}
|
|
1180
|
+
} // The context.catch method must only be called with a location
|
|
1181
|
+
// argument that corresponds to a known catch block.
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
throw new Error("illegal catch attempt");
|
|
1185
|
+
},
|
|
1186
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1187
|
+
this.delegate = {
|
|
1188
|
+
iterator: values(iterable),
|
|
1189
|
+
resultName: resultName,
|
|
1190
|
+
nextLoc: nextLoc
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
if (this.method === "next") {
|
|
1194
|
+
// Deliberately forget the last sent value so that we don't
|
|
1195
|
+
// accidentally pass it on to the delegate.
|
|
1196
|
+
this.arg = undefined$1;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
return ContinueSentinel;
|
|
1200
|
+
}
|
|
1201
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1202
|
+
// or not, return the runtime object so that we can declare the variable
|
|
1203
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1204
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1205
|
+
|
|
1206
|
+
return exports;
|
|
1207
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1208
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1209
|
+
// object. Either way, the resulting object will be used to initialize
|
|
1210
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
1211
|
+
module.exports );
|
|
1212
|
+
|
|
1213
|
+
try {
|
|
1214
|
+
regeneratorRuntime = runtime;
|
|
1215
|
+
} catch (accidentalStrictMode) {
|
|
1216
|
+
// This module should not be running in strict mode, so the above
|
|
1217
|
+
// assignment should always work unless something is misconfigured. Just
|
|
1218
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
1219
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
1220
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
1221
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
1222
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
1223
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1224
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
1225
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1226
|
+
}
|
|
1227
|
+
})(runtime);
|
|
1228
|
+
|
|
1229
|
+
var _regeneratorRuntime = runtime.exports;
|
|
1230
|
+
|
|
457
1231
|
var useNormalizedItems = function useNormalizedItems(items) {
|
|
458
|
-
return React__default.useMemo(function () {
|
|
1232
|
+
return React__default["default"].useMemo(function () {
|
|
459
1233
|
return items.map(function (item) {
|
|
460
1234
|
if (typeof item == 'string') {
|
|
461
1235
|
return {
|
|
@@ -476,8 +1250,8 @@ var useNormalizedItems = function useNormalizedItems(items) {
|
|
|
476
1250
|
};
|
|
477
1251
|
|
|
478
1252
|
var useIsMounted = function useIsMounted() {
|
|
479
|
-
var isMountedRef = React__default.useRef(true);
|
|
480
|
-
React__default.useEffect(function () {
|
|
1253
|
+
var isMountedRef = React__default["default"].useRef(true);
|
|
1254
|
+
React__default["default"].useEffect(function () {
|
|
481
1255
|
return function () {
|
|
482
1256
|
isMountedRef.current = false;
|
|
483
1257
|
};
|
|
@@ -513,13 +1287,13 @@ debounceTimeout) {
|
|
|
513
1287
|
var isItemsFunction = typeof itemsOrItemsResolver === 'function'; // Here, we normalize the itemsResolver argument to an async function, so we
|
|
514
1288
|
// can use it without thinking about the differences later
|
|
515
1289
|
|
|
516
|
-
var itemsResolver = React__default.useMemo(function () {
|
|
1290
|
+
var itemsResolver = React__default["default"].useMemo(function () {
|
|
517
1291
|
return isItemsFunction ? itemsOrItemsResolver : function () {
|
|
518
1292
|
return Promise.resolve(itemsOrItemsResolver);
|
|
519
1293
|
};
|
|
520
1294
|
}, [itemsOrItemsResolver, isItemsFunction]);
|
|
521
1295
|
|
|
522
|
-
var _React$useReducer = React__default.useReducer(reducer, {
|
|
1296
|
+
var _React$useReducer = React__default["default"].useReducer(reducer, {
|
|
523
1297
|
items: isItemsFunction ? [] : itemsOrItemsResolver,
|
|
524
1298
|
loading: false
|
|
525
1299
|
}),
|
|
@@ -534,29 +1308,51 @@ debounceTimeout) {
|
|
|
534
1308
|
var isMounted = useIsMounted(); // Next, let's create the fetching function. This should be called whenever
|
|
535
1309
|
// the input value changes
|
|
536
1310
|
|
|
537
|
-
var fetchItems = React__default.useCallback(function (
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
1311
|
+
var fetchItems = React__default["default"].useCallback( /*#__PURE__*/function () {
|
|
1312
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
|
|
1313
|
+
var resolvedItems;
|
|
1314
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1315
|
+
while (1) {
|
|
1316
|
+
switch (_context.prev = _context.next) {
|
|
1317
|
+
case 0:
|
|
1318
|
+
if (isMounted) {
|
|
1319
|
+
_context.next = 2;
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
return _context.abrupt("return");
|
|
1324
|
+
|
|
1325
|
+
case 2:
|
|
1326
|
+
dispatch({
|
|
1327
|
+
type: 'request results'
|
|
1328
|
+
});
|
|
1329
|
+
_context.next = 5;
|
|
1330
|
+
return itemsResolver(inputValue);
|
|
1331
|
+
|
|
1332
|
+
case 5:
|
|
1333
|
+
resolvedItems = _context.sent;
|
|
1334
|
+
|
|
1335
|
+
if (isMounted) {
|
|
1336
|
+
dispatch({
|
|
1337
|
+
type: 'received results',
|
|
1338
|
+
payload: resolvedItems
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
case 7:
|
|
1343
|
+
case "end":
|
|
1344
|
+
return _context.stop();
|
|
1345
|
+
}
|
|
552
1346
|
}
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
1347
|
+
}, _callee);
|
|
1348
|
+
}));
|
|
1349
|
+
|
|
1350
|
+
return function (_x) {
|
|
1351
|
+
return _ref.apply(this, arguments);
|
|
1352
|
+
};
|
|
1353
|
+
}(), [itemsResolver, isMounted]);
|
|
558
1354
|
var normalizedItems = useNormalizedItems(items);
|
|
559
|
-
React__default.useEffect(function () {
|
|
1355
|
+
React__default["default"].useEffect(function () {
|
|
560
1356
|
// Let's fetch the list initially if it's specified
|
|
561
1357
|
if (isItemsFunction) {
|
|
562
1358
|
fetchItems('');
|
|
@@ -569,6 +1365,7 @@ debounceTimeout) {
|
|
|
569
1365
|
};
|
|
570
1366
|
};
|
|
571
1367
|
|
|
1368
|
+
var _excluded$2 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
|
|
572
1369
|
var Dropdown = function Dropdown(_ref) {
|
|
573
1370
|
var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
|
|
574
1371
|
debounceTimeout = _ref.debounceTimeout,
|
|
@@ -596,7 +1393,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
596
1393
|
listStyle = _ref.listStyle,
|
|
597
1394
|
itemFilter = _ref.itemFilter,
|
|
598
1395
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
599
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
1396
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
600
1397
|
|
|
601
1398
|
var _useResolvedItems = useResolvedItems(items, debounceTimeout),
|
|
602
1399
|
normalizedItems = _useResolvedItems.items,
|
|
@@ -615,7 +1412,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
615
1412
|
name: rest.name,
|
|
616
1413
|
'data-cy': rest['data-cy']
|
|
617
1414
|
};
|
|
618
|
-
return React__default.createElement(DownshiftProvider,
|
|
1415
|
+
return React__default["default"].createElement(DownshiftProvider, _extends({
|
|
619
1416
|
selectedItem: selectedItem,
|
|
620
1417
|
onInputValueChange: fetchItems,
|
|
621
1418
|
onChange: onChange,
|
|
@@ -624,10 +1421,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
624
1421
|
className: className,
|
|
625
1422
|
style: style,
|
|
626
1423
|
searchable: searchable
|
|
627
|
-
}, rest), React__default.createElement(DropdownInputGroup, {
|
|
1424
|
+
}, rest), React__default["default"].createElement(DropdownInputGroup, {
|
|
628
1425
|
feedback: feedback,
|
|
629
1426
|
variant: variant
|
|
630
|
-
}, React__default.createElement(RenderedDropdown,
|
|
1427
|
+
}, React__default["default"].createElement(RenderedDropdown, _extends({
|
|
631
1428
|
label: label,
|
|
632
1429
|
items: normalizedItems,
|
|
633
1430
|
loading: loading,
|
|
@@ -644,6 +1441,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
644
1441
|
}, searchAbleProps))));
|
|
645
1442
|
};
|
|
646
1443
|
|
|
1444
|
+
var _excluded$1 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
|
|
647
1445
|
var NativeDropdown = function NativeDropdown(_ref) {
|
|
648
1446
|
var className = _ref.className,
|
|
649
1447
|
_ref$disabled = _ref.disabled,
|
|
@@ -658,24 +1456,24 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
658
1456
|
variant = _ref.variant,
|
|
659
1457
|
feedback = _ref.feedback,
|
|
660
1458
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
661
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
1459
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
662
1460
|
|
|
663
1461
|
var _useResolvedItems = useResolvedItems(items),
|
|
664
1462
|
normalizedItems = _useResolvedItems.items,
|
|
665
1463
|
loading = _useResolvedItems.loading;
|
|
666
1464
|
|
|
667
|
-
var rightSideIcon = React__default.createElement(icons.DownArrowIcon, {
|
|
1465
|
+
var rightSideIcon = React__default["default"].createElement(icons.DownArrowIcon, {
|
|
668
1466
|
inline: true
|
|
669
1467
|
});
|
|
670
1468
|
|
|
671
1469
|
if (disabled || readOnly) {
|
|
672
1470
|
rightSideIcon = null;
|
|
673
1471
|
} else if (loading) {
|
|
674
|
-
rightSideIcon = React__default.createElement(DropdownLoadingDots, null, loadingText);
|
|
1472
|
+
rightSideIcon = React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
675
1473
|
}
|
|
676
1474
|
|
|
677
1475
|
var nativeDropdownId = utils.useRandomId('eds-native-dropdown');
|
|
678
|
-
return React__default.createElement(form.BaseFormControl, {
|
|
1476
|
+
return React__default["default"].createElement(form.BaseFormControl, {
|
|
679
1477
|
disabled: disabled,
|
|
680
1478
|
readOnly: readOnly,
|
|
681
1479
|
prepend: prepend,
|
|
@@ -688,22 +1486,23 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
688
1486
|
labelId: nativeDropdownId,
|
|
689
1487
|
disableLabelAnimation: disableLabelAnimation,
|
|
690
1488
|
isFilled: true
|
|
691
|
-
}, React__default.createElement("select",
|
|
1489
|
+
}, React__default["default"].createElement("select", _extends({
|
|
692
1490
|
"aria-invalid": variant === 'error',
|
|
693
1491
|
className: "eds-form-control eds-dropdown",
|
|
694
1492
|
disabled: disabled || readOnly
|
|
695
1493
|
}, rest), normalizedItems.map(function (item) {
|
|
696
|
-
return React__default.createElement("option", {
|
|
1494
|
+
return React__default["default"].createElement("option", {
|
|
697
1495
|
key: item.value,
|
|
698
1496
|
value: item.value
|
|
699
1497
|
}, item.label);
|
|
700
1498
|
})));
|
|
701
1499
|
};
|
|
702
1500
|
|
|
703
|
-
var
|
|
1501
|
+
var _excluded = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
|
|
1502
|
+
var MultiSelectContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
704
1503
|
|
|
705
1504
|
var useMultiSelectContext = function useMultiSelectContext() {
|
|
706
|
-
var context = React__default.useContext(MultiSelectContext);
|
|
1505
|
+
var context = React__default["default"].useContext(MultiSelectContext);
|
|
707
1506
|
|
|
708
1507
|
if (!context) {
|
|
709
1508
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
@@ -761,7 +1560,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
761
1560
|
_ref$initialSelectedI = _ref.initialSelectedItems,
|
|
762
1561
|
initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
|
|
763
1562
|
debounceTimeout = _ref.debounceTimeout,
|
|
764
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
1563
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
765
1564
|
|
|
766
1565
|
var _useResolvedItems = useResolvedItems(input, debounceTimeout),
|
|
767
1566
|
items = _useResolvedItems.items;
|
|
@@ -770,10 +1569,16 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
770
1569
|
selectedItems = _useState[0],
|
|
771
1570
|
setSelectedItems = _useState[1];
|
|
772
1571
|
|
|
773
|
-
var reset = React__default.useCallback(function () {
|
|
1572
|
+
var reset = React__default["default"].useCallback(function () {
|
|
774
1573
|
setSelectedItems([]);
|
|
775
1574
|
}, []);
|
|
776
1575
|
|
|
1576
|
+
function isSelected(selectedCheckboxItem) {
|
|
1577
|
+
return selectedItems.some(function (selected) {
|
|
1578
|
+
return selected.value === selectedCheckboxItem.value;
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
|
|
777
1582
|
var _useSelect = Downshift.useSelect(_extends({
|
|
778
1583
|
items: items,
|
|
779
1584
|
stateReducer: stateReducer,
|
|
@@ -785,22 +1590,19 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
785
1590
|
return;
|
|
786
1591
|
}
|
|
787
1592
|
|
|
788
|
-
var
|
|
1593
|
+
var itemIsFound = isSelected(selectedItem);
|
|
789
1594
|
|
|
790
|
-
if (
|
|
791
|
-
var slicedItemList =
|
|
1595
|
+
if (itemIsFound) {
|
|
1596
|
+
var slicedItemList = selectedItems.filter(function (item) {
|
|
1597
|
+
return item.value !== selectedItem.value;
|
|
1598
|
+
});
|
|
792
1599
|
setSelectedItems(slicedItemList);
|
|
793
1600
|
onChange(slicedItemList);
|
|
794
|
-
} else
|
|
795
|
-
var _slicedItemList = [].concat(selectedItems
|
|
1601
|
+
} else {
|
|
1602
|
+
var _slicedItemList = [].concat(selectedItems, [selectedItem]);
|
|
796
1603
|
|
|
797
1604
|
setSelectedItems(_slicedItemList);
|
|
798
1605
|
onChange(_slicedItemList);
|
|
799
|
-
} else {
|
|
800
|
-
var _slicedItemList2 = [].concat(selectedItems, [selectedItem]);
|
|
801
|
-
|
|
802
|
-
setSelectedItems(_slicedItemList2);
|
|
803
|
-
onChange(_slicedItemList2);
|
|
804
1606
|
}
|
|
805
1607
|
}
|
|
806
1608
|
}, rest)),
|
|
@@ -814,7 +1616,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
814
1616
|
|
|
815
1617
|
var buttonText = selectedItems.length ? itemsSelectedLabel(selectedItems) : '';
|
|
816
1618
|
var multiSelectId = utils.useRandomId('eds-multiselect');
|
|
817
|
-
return React__default.createElement(MultiSelectContext.Provider, {
|
|
1619
|
+
return React__default["default"].createElement(MultiSelectContext.Provider, {
|
|
818
1620
|
value: {
|
|
819
1621
|
isOpen: isOpen,
|
|
820
1622
|
reset: reset,
|
|
@@ -822,10 +1624,10 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
822
1624
|
openMenu: openMenu,
|
|
823
1625
|
openOnFocus: openOnFocus
|
|
824
1626
|
}
|
|
825
|
-
}, React__default.createElement("div", {
|
|
826
|
-
className:
|
|
1627
|
+
}, React__default["default"].createElement("div", {
|
|
1628
|
+
className: classNames__default["default"]('eds-multiselect', 'eds-dropdown-wrapper', className),
|
|
827
1629
|
style: style
|
|
828
|
-
}, React__default.createElement(form.BaseFormControl, {
|
|
1630
|
+
}, React__default["default"].createElement(form.BaseFormControl, {
|
|
829
1631
|
label: label,
|
|
830
1632
|
labelId: multiSelectId,
|
|
831
1633
|
labelProps: getLabelProps(),
|
|
@@ -834,20 +1636,20 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
834
1636
|
isFilled: selectedItems.length > 0 || isOpen,
|
|
835
1637
|
disabled: disabled,
|
|
836
1638
|
readOnly: readOnly,
|
|
837
|
-
append: React__default.createElement(Appendix
|
|
1639
|
+
append: React__default["default"].createElement(Appendix, {
|
|
838
1640
|
hasSelected: clearable && selectedItems.length > 0,
|
|
839
1641
|
loading: loading,
|
|
840
1642
|
loadingText: loadingText,
|
|
841
1643
|
readOnly: readOnly
|
|
842
1644
|
})
|
|
843
|
-
}, React__default.createElement("button",
|
|
1645
|
+
}, React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
844
1646
|
style: {
|
|
845
1647
|
textAlign: 'left'
|
|
846
1648
|
},
|
|
847
1649
|
type: 'button',
|
|
848
1650
|
className: 'eds-form-control eds-multiselect__button'
|
|
849
|
-
})), buttonText)), React__default.createElement("ul",
|
|
850
|
-
className:
|
|
1651
|
+
})), buttonText)), React__default["default"].createElement("ul", _extends({
|
|
1652
|
+
className: classNames__default["default"]('eds-dropdown-list', {
|
|
851
1653
|
'eds-dropdown-list--open': isOpen
|
|
852
1654
|
})
|
|
853
1655
|
}, getMenuProps({
|
|
@@ -856,12 +1658,12 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
856
1658
|
top: tokens.space.extraLarge3 + tokens.space.extraSmall + "px"
|
|
857
1659
|
}, listStyle)
|
|
858
1660
|
})), isOpen && items.map(function (item, index) {
|
|
859
|
-
return React__default.createElement("li",
|
|
860
|
-
className:
|
|
1661
|
+
return React__default["default"].createElement("li", _extends({
|
|
1662
|
+
className: classNames__default["default"]('eds-dropdown-list__item', {
|
|
861
1663
|
'eds-dropdown-list__item--highlighted': highlightedIndex === index,
|
|
862
|
-
'eds-dropdown-list__item--selected':
|
|
1664
|
+
'eds-dropdown-list__item--selected': isSelected(item)
|
|
863
1665
|
}),
|
|
864
|
-
key: "" + item + index
|
|
1666
|
+
key: "" + item.value + index
|
|
865
1667
|
}, getItemProps({
|
|
866
1668
|
item: item,
|
|
867
1669
|
index: index
|
|
@@ -869,18 +1671,18 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
869
1671
|
style: {
|
|
870
1672
|
display: 'flex'
|
|
871
1673
|
}
|
|
872
|
-
}), React__default.createElement("span", {
|
|
1674
|
+
}), React__default["default"].createElement("span", {
|
|
873
1675
|
style: {
|
|
874
1676
|
display: 'flex'
|
|
875
1677
|
}
|
|
876
|
-
}, React__default.createElement("span", {
|
|
877
|
-
className:
|
|
878
|
-
'eds-multiselect-checkbox--checked':
|
|
1678
|
+
}, React__default["default"].createElement("span", {
|
|
1679
|
+
className: classNames__default["default"]('eds-multiselect-checkbox', {
|
|
1680
|
+
'eds-multiselect-checkbox--checked': isSelected(item)
|
|
879
1681
|
})
|
|
880
|
-
}, React__default.createElement(CheckboxIcon, null)), React__default.createElement("span", {
|
|
1682
|
+
}, React__default["default"].createElement(CheckboxIcon, null)), React__default["default"].createElement("span", {
|
|
881
1683
|
className: "eds-multiselect__item-label"
|
|
882
|
-
}, item.label)), item.icons && React__default.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
883
|
-
return React__default.createElement(Icon, {
|
|
1684
|
+
}, item.label)), item.icons && React__default["default"].createElement("span", null, item.icons.map(function (Icon, index) {
|
|
1685
|
+
return React__default["default"].createElement(Icon, {
|
|
884
1686
|
key: index,
|
|
885
1687
|
inline: true,
|
|
886
1688
|
className: "eds-dropdown-list__item-icon"
|
|
@@ -889,50 +1691,50 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
889
1691
|
}))));
|
|
890
1692
|
};
|
|
891
1693
|
|
|
892
|
-
var ClearButton
|
|
1694
|
+
var ClearButton = function ClearButton(_ref3) {
|
|
893
1695
|
var props = _extends({}, _ref3);
|
|
894
1696
|
|
|
895
1697
|
var _useMultiSelectContex = useMultiSelectContext(),
|
|
896
1698
|
reset = _useMultiSelectContex.reset;
|
|
897
1699
|
|
|
898
|
-
return React__default.createElement(React__default.Fragment, null, React__default.createElement("button",
|
|
1700
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("button", _extends({
|
|
899
1701
|
className: "eds-dropdown__clear-button",
|
|
900
1702
|
type: "button",
|
|
901
1703
|
tabIndex: -1,
|
|
902
1704
|
onClick: function onClick() {
|
|
903
1705
|
return reset();
|
|
904
1706
|
}
|
|
905
|
-
}, props), React__default.createElement(icons.CloseIcon, null)), React__default.createElement("div", {
|
|
1707
|
+
}, props), React__default["default"].createElement(icons.CloseIcon, null)), React__default["default"].createElement("div", {
|
|
906
1708
|
className: "eds-dropdown__divider"
|
|
907
1709
|
}));
|
|
908
1710
|
};
|
|
909
1711
|
|
|
910
|
-
var Appendix
|
|
1712
|
+
var Appendix = function Appendix(_ref4) {
|
|
911
1713
|
var loading = _ref4.loading,
|
|
912
1714
|
loadingText = _ref4.loadingText,
|
|
913
1715
|
readOnly = _ref4.readOnly,
|
|
914
1716
|
hasSelected = _ref4.hasSelected;
|
|
915
1717
|
|
|
916
1718
|
if (loading) {
|
|
917
|
-
return React__default.createElement(DropdownLoadingDots, null, loadingText);
|
|
1719
|
+
return React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
918
1720
|
}
|
|
919
1721
|
|
|
920
1722
|
if (readOnly) {
|
|
921
1723
|
return null;
|
|
922
1724
|
}
|
|
923
1725
|
|
|
924
|
-
return hasSelected ? React__default.createElement(React__default.Fragment, null, React__default.createElement(ClearButton
|
|
1726
|
+
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);
|
|
925
1727
|
};
|
|
926
1728
|
|
|
927
|
-
var DropdownToggleButton
|
|
1729
|
+
var DropdownToggleButton = function DropdownToggleButton() {
|
|
928
1730
|
var _useMultiSelectContex2 = useMultiSelectContext(),
|
|
929
1731
|
getToggleButtonProps = _useMultiSelectContex2.getToggleButtonProps,
|
|
930
1732
|
isOpen = _useMultiSelectContex2.isOpen,
|
|
931
1733
|
openMenu = _useMultiSelectContex2.openMenu,
|
|
932
1734
|
openOnFocus = _useMultiSelectContex2.openOnFocus;
|
|
933
1735
|
|
|
934
|
-
return React__default.createElement("button",
|
|
935
|
-
className:
|
|
1736
|
+
return React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
1737
|
+
className: classNames__default["default"]('eds-dropdown__toggle-button', {
|
|
936
1738
|
'eds-dropdown__toggle-button--open': isOpen
|
|
937
1739
|
}),
|
|
938
1740
|
onFocus: function onFocus() {
|
|
@@ -942,16 +1744,16 @@ var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
|
942
1744
|
}
|
|
943
1745
|
}), {
|
|
944
1746
|
type: "button"
|
|
945
|
-
}), React__default.createElement(icons.DownArrowIcon, null));
|
|
1747
|
+
}), React__default["default"].createElement(icons.DownArrowIcon, null));
|
|
946
1748
|
};
|
|
947
1749
|
|
|
948
1750
|
var CheckboxIcon = function CheckboxIcon() {
|
|
949
|
-
return React__default.createElement("svg", {
|
|
1751
|
+
return React__default["default"].createElement("svg", {
|
|
950
1752
|
className: "eds-checkbox-icon",
|
|
951
1753
|
width: "11px",
|
|
952
1754
|
height: "9px",
|
|
953
1755
|
viewBox: "6 11 37 33"
|
|
954
|
-
}, React__default.createElement("path", {
|
|
1756
|
+
}, React__default["default"].createElement("path", {
|
|
955
1757
|
className: "eds-checkbox-icon__path",
|
|
956
1758
|
d: "M14.1 27.2l7.1 7.2 14.6-14.8",
|
|
957
1759
|
fill: "none"
|