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