@entur/dropdown 3.0.24 → 3.0.25

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