@entur/dropdown 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,42 @@ import { VisuallyHidden } from '@entur/a11y';
8
8
  import { LoadingDots } from '@entur/loader';
9
9
  import { space } from '@entur/tokens';
10
10
 
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
+ try {
13
+ var info = gen[key](arg);
14
+ var value = info.value;
15
+ } catch (error) {
16
+ reject(error);
17
+ return;
18
+ }
19
+
20
+ if (info.done) {
21
+ resolve(value);
22
+ } else {
23
+ Promise.resolve(value).then(_next, _throw);
24
+ }
25
+ }
26
+
27
+ function _asyncToGenerator(fn) {
28
+ return function () {
29
+ var self = this,
30
+ args = arguments;
31
+ return new Promise(function (resolve, reject) {
32
+ var gen = fn.apply(self, args);
33
+
34
+ function _next(value) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
36
+ }
37
+
38
+ function _throw(err) {
39
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
40
+ }
41
+
42
+ _next(undefined);
43
+ });
44
+ };
45
+ }
46
+
11
47
  function _extends() {
12
48
  _extends = Object.assign || function (target) {
13
49
  for (var i = 1; i < arguments.length; i++) {
@@ -41,6 +77,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
41
77
  return target;
42
78
  }
43
79
 
80
+ var _excluded$8 = ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"];
44
81
  var DownshiftContext = /*#__PURE__*/React.createContext(null);
45
82
  var DownshiftProvider = function DownshiftProvider(_ref) {
46
83
  var children = _ref.children,
@@ -58,7 +95,7 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
58
95
  style = _ref.style,
59
96
  _ref$searchable = _ref.searchable,
60
97
  searchable = _ref$searchable === void 0 ? false : _ref$searchable,
61
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"]);
98
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
62
99
 
63
100
  var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
64
101
  if (changes.type === Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem) {
@@ -103,7 +140,7 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
103
140
  }
104
141
  };
105
142
 
106
- return React.createElement(Downshift, Object.assign({
143
+ return React.createElement(Downshift, _extends({
107
144
  itemToString: function itemToString(item) {
108
145
  return item ? item.label : '';
109
146
  },
@@ -128,9 +165,10 @@ var useDownshift = function useDownshift() {
128
165
  return context;
129
166
  };
130
167
 
168
+ var _excluded$7 = ["items"];
131
169
  var DropdownList = function DropdownList(_ref) {
132
170
  var items = _ref.items,
133
- rest = _objectWithoutPropertiesLoose(_ref, ["items"]);
171
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
134
172
 
135
173
  var _useDownshift = useDownshift(),
136
174
  highlightedIndex = _useDownshift.highlightedIndex,
@@ -139,13 +177,13 @@ var DropdownList = function DropdownList(_ref) {
139
177
  getItemProps = _useDownshift.getItemProps,
140
178
  getMenuProps = _useDownshift.getMenuProps;
141
179
 
142
- return React.createElement("ul", Object.assign({
180
+ return React.createElement("ul", _extends({
143
181
  className: classNames('eds-dropdown-list', {
144
182
  'eds-dropdown-list--open': isOpen
145
183
  })
146
184
  }, getMenuProps(), rest), isOpen ? items.map(function (item, index) {
147
185
  return (// eslint-disable-next-line react/jsx-key
148
- React.createElement("li", Object.assign({
186
+ React.createElement("li", _extends({
149
187
  className: classNames('eds-dropdown-list__item', {
150
188
  'eds-dropdown-list__item--highlighted': highlightedIndex === index,
151
189
  'eds-dropdown-list__item--selected': selectedItem === item
@@ -165,12 +203,12 @@ var DropdownList = function DropdownList(_ref) {
165
203
  }) : null);
166
204
  };
167
205
 
168
- var DropdownToggleButton = function DropdownToggleButton() {
206
+ var DropdownToggleButton$1 = function DropdownToggleButton() {
169
207
  var _useDownshift = useDownshift(),
170
208
  getToggleButtonProps = _useDownshift.getToggleButtonProps,
171
209
  isOpen = _useDownshift.isOpen;
172
210
 
173
- return React.createElement("button", Object.assign({}, getToggleButtonProps({
211
+ return React.createElement("button", _extends({}, getToggleButtonProps({
174
212
  className: classNames('eds-dropdown__toggle-button', {
175
213
  'eds-dropdown__toggle-button--open': isOpen
176
214
  })
@@ -180,16 +218,18 @@ var DropdownToggleButton = function DropdownToggleButton() {
180
218
  }), React.createElement(DownArrowIcon, null));
181
219
  };
182
220
 
221
+ var _excluded$6 = ["className", "children"];
183
222
  var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
184
223
  var className = _ref.className,
185
224
  children = _ref.children,
186
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "children"]);
225
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
187
226
 
188
- return React.createElement("div", Object.assign({
227
+ return React.createElement("div", _extends({
189
228
  className: classNames('eds-inline-spinner', className)
190
229
  }, rest), React.createElement(LoadingDots, null), React.createElement(VisuallyHidden, null, children));
191
230
  };
192
231
 
232
+ var _excluded$5 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
193
233
  var BaseDropdown = function BaseDropdown(_ref) {
194
234
  var children = _ref.children,
195
235
  className = _ref.className,
@@ -205,7 +245,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
205
245
  _ref$isFilled = _ref.isFilled,
206
246
  isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
207
247
  disableLabelAnimation = _ref.disableLabelAnimation,
208
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"]);
248
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
209
249
 
210
250
  var _useDownshift = useDownshift(),
211
251
  getLabelProps = _useDownshift.getLabelProps;
@@ -213,8 +253,8 @@ var BaseDropdown = function BaseDropdown(_ref) {
213
253
  return React.createElement("div", {
214
254
  className: "eds-dropdown-wrapper",
215
255
  style: style
216
- }, React.createElement(BaseFormControl, Object.assign({
217
- append: React.createElement(Appendix, {
256
+ }, React.createElement(BaseFormControl, _extends({
257
+ append: React.createElement(Appendix$1, {
218
258
  clearable: clearable,
219
259
  loading: loading,
220
260
  loadingText: loadingText,
@@ -225,7 +265,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
225
265
  isFilled: isFilled,
226
266
  labelProps: getLabelProps(),
227
267
  disableLabelAnimation: disableLabelAnimation
228
- }, rest), children), React.createElement(DropdownList, Object.assign({
268
+ }, rest), children), React.createElement(DropdownList, _extends({
229
269
  items: items,
230
270
  style: _extends({
231
271
  position: 'absolute',
@@ -234,14 +274,14 @@ var BaseDropdown = function BaseDropdown(_ref) {
234
274
  }, rest)));
235
275
  };
236
276
 
237
- var ClearButton = function ClearButton(_ref2) {
277
+ var ClearButton$1 = function ClearButton(_ref2) {
238
278
  var props = _extends({}, _ref2);
239
279
 
240
280
  var _useDownshift2 = useDownshift(),
241
281
  clearSelection = _useDownshift2.clearSelection,
242
282
  selectedItem = _useDownshift2.selectedItem;
243
283
 
244
- return React.createElement(React.Fragment, null, selectedItem && React.createElement("button", Object.assign({
284
+ return React.createElement(React.Fragment, null, selectedItem && React.createElement("button", _extends({
245
285
  className: "eds-dropdown__clear-button",
246
286
  type: "button",
247
287
  tabIndex: -1,
@@ -253,7 +293,7 @@ var ClearButton = function ClearButton(_ref2) {
253
293
  }));
254
294
  };
255
295
 
256
- var Appendix = function Appendix(_ref3) {
296
+ var Appendix$1 = function Appendix(_ref3) {
257
297
  var clearable = _ref3.clearable,
258
298
  loading = _ref3.loading,
259
299
  loadingText = _ref3.loadingText,
@@ -267,9 +307,10 @@ var Appendix = function Appendix(_ref3) {
267
307
  return null;
268
308
  }
269
309
 
270
- return clearable ? React.createElement(React.Fragment, null, React.createElement(ClearButton, null), " ", React.createElement(DropdownToggleButton, null)) : React.createElement(DropdownToggleButton, null);
310
+ return clearable ? React.createElement(React.Fragment, null, React.createElement(ClearButton$1, null), " ", React.createElement(DropdownToggleButton$1, null)) : React.createElement(DropdownToggleButton$1, null);
271
311
  };
272
312
 
313
+ var _excluded$4 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
273
314
  var RegularDropdown = function RegularDropdown(_ref) {
274
315
  var disabled = _ref.disabled,
275
316
  _ref$placeholder = _ref.placeholder,
@@ -286,7 +327,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
286
327
  loadingText = _ref.loadingText,
287
328
  className = _ref.className,
288
329
  clearable = _ref.clearable,
289
- rest = _objectWithoutPropertiesLoose(_ref, ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"]);
330
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
290
331
 
291
332
  var _useDownshift = useDownshift(),
292
333
  getToggleButtonProps = _useDownshift.getToggleButtonProps,
@@ -297,7 +338,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
297
338
  highlightedIndex = _useDownshift.highlightedIndex,
298
339
  setHighlightedIndex = _useDownshift.setHighlightedIndex;
299
340
 
300
- return React.createElement(BaseDropdown, Object.assign({
341
+ return React.createElement(BaseDropdown, _extends({
301
342
  disabled: disabled,
302
343
  listStyle: listStyle,
303
344
  items: items,
@@ -308,7 +349,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
308
349
  loadingText: loadingText,
309
350
  className: className,
310
351
  clearable: clearable
311
- }, rest), React.createElement("button", Object.assign({}, getToggleButtonProps(_extends({
352
+ }, rest), React.createElement("button", _extends({}, getToggleButtonProps(_extends({
312
353
  className: 'eds-form-control eds-dropdown__selected-item',
313
354
  style: {
314
355
  textAlign: 'left'
@@ -331,7 +372,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
331
372
  return firstCharacter === keyDownValue;
332
373
  });
333
374
  var nextHighlightItem = matchedItems.find(function (item) {
334
- return item.index > (highlightedIndex !== null && highlightedIndex !== void 0 ? highlightedIndex : 0);
375
+ return item.index > (highlightedIndex != null ? highlightedIndex : 0);
335
376
  });
336
377
 
337
378
  if (nextHighlightItem) {
@@ -349,6 +390,8 @@ var RegularDropdown = function RegularDropdown(_ref) {
349
390
  }, rest))), selectedItem ? selectedItem.label : placeholder));
350
391
  };
351
392
 
393
+ var _excluded$3 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
394
+
352
395
  function LowerCaseFilterTest(item, input) {
353
396
  if (!input) {
354
397
  return true;
@@ -382,7 +425,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
382
425
  label = _ref.label,
383
426
  disableLabelAnimation = _ref.disableLabelAnimation,
384
427
  placeholder = _ref.placeholder,
385
- rest = _objectWithoutPropertiesLoose(_ref, ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"]);
428
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
386
429
 
387
430
  var _useDownshift = useDownshift(),
388
431
  getInputProps = _useDownshift.getInputProps,
@@ -412,7 +455,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
412
455
  disableLabelAnimation: disableLabelAnimation
413
456
  }, selectedItem && !inputValue && React.createElement("span", {
414
457
  className: "eds-dropdown__searchable-selected-item"
415
- }, selectedItem.label), React.createElement("input", Object.assign({}, getInputProps(_extends({
458
+ }, selectedItem.label), React.createElement("input", _extends({}, getInputProps(_extends({
416
459
  disabled: disabled,
417
460
  readOnly: readOnly,
418
461
  className: 'eds-form-control eds-dropdown__input',
@@ -446,6 +489,735 @@ var DropdownInputGroup = function DropdownInputGroup(_ref) {
446
489
  }, feedback)));
447
490
  };
448
491
 
492
+ var runtime = {exports: {}};
493
+
494
+ /**
495
+ * Copyright (c) 2014-present, Facebook, Inc.
496
+ *
497
+ * This source code is licensed under the MIT license found in the
498
+ * LICENSE file in the root directory of this source tree.
499
+ */
500
+
501
+ (function (module) {
502
+ var runtime = /*#__PURE__*/function (exports) {
503
+
504
+ var Op = Object.prototype;
505
+ var hasOwn = Op.hasOwnProperty;
506
+ var undefined$1; // More compressible than void 0.
507
+
508
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
509
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
510
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
511
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
512
+
513
+ function define(obj, key, value) {
514
+ Object.defineProperty(obj, key, {
515
+ value: value,
516
+ enumerable: true,
517
+ configurable: true,
518
+ writable: true
519
+ });
520
+ return obj[key];
521
+ }
522
+
523
+ try {
524
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
525
+ define({}, "");
526
+ } catch (err) {
527
+ define = function define(obj, key, value) {
528
+ return obj[key] = value;
529
+ };
530
+ }
531
+
532
+ function wrap(innerFn, outerFn, self, tryLocsList) {
533
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
534
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
535
+ var generator = Object.create(protoGenerator.prototype);
536
+ var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
537
+ // .throw, and .return methods.
538
+
539
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
540
+ return generator;
541
+ }
542
+
543
+ exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
544
+ // record like context.tryEntries[i].completion. This interface could
545
+ // have been (and was previously) designed to take a closure to be
546
+ // invoked without arguments, but in all the cases we care about we
547
+ // already have an existing method we want to call, so there's no need
548
+ // to create a new function object. We can even get away with assuming
549
+ // the method takes exactly one argument, since that happens to be true
550
+ // in every case, so we don't have to touch the arguments object. The
551
+ // only additional allocation required is the completion record, which
552
+ // has a stable shape and so hopefully should be cheap to allocate.
553
+
554
+ function tryCatch(fn, obj, arg) {
555
+ try {
556
+ return {
557
+ type: "normal",
558
+ arg: fn.call(obj, arg)
559
+ };
560
+ } catch (err) {
561
+ return {
562
+ type: "throw",
563
+ arg: err
564
+ };
565
+ }
566
+ }
567
+
568
+ var GenStateSuspendedStart = "suspendedStart";
569
+ var GenStateSuspendedYield = "suspendedYield";
570
+ var GenStateExecuting = "executing";
571
+ var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
572
+ // breaking out of the dispatch switch statement.
573
+
574
+ var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
575
+ // .constructor.prototype properties for functions that return Generator
576
+ // objects. For full spec compliance, you may wish to configure your
577
+ // minifier not to mangle the names of these two functions.
578
+
579
+ function Generator() {}
580
+
581
+ function GeneratorFunction() {}
582
+
583
+ function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
584
+ // don't natively support it.
585
+
586
+
587
+ var IteratorPrototype = {};
588
+
589
+ IteratorPrototype[iteratorSymbol] = function () {
590
+ return this;
591
+ };
592
+
593
+ var getProto = Object.getPrototypeOf;
594
+ var NativeIteratorPrototype = getProto && /*#__PURE__*/getProto( /*#__PURE__*/getProto( /*#__PURE__*/values([])));
595
+
596
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
597
+ // This environment has a native %IteratorPrototype%; use it instead
598
+ // of the polyfill.
599
+ IteratorPrototype = NativeIteratorPrototype;
600
+ }
601
+
602
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
603
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
604
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
605
+ GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
606
+ // Iterator interface in terms of a single ._invoke method.
607
+
608
+ function defineIteratorMethods(prototype) {
609
+ ["next", "throw", "return"].forEach(function (method) {
610
+ define(prototype, method, function (arg) {
611
+ return this._invoke(method, arg);
612
+ });
613
+ });
614
+ }
615
+
616
+ exports.isGeneratorFunction = function (genFun) {
617
+ var ctor = typeof genFun === "function" && genFun.constructor;
618
+ return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
619
+ // do is to check its .name property.
620
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
621
+ };
622
+
623
+ exports.mark = function (genFun) {
624
+ if (Object.setPrototypeOf) {
625
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
626
+ } else {
627
+ genFun.__proto__ = GeneratorFunctionPrototype;
628
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
629
+ }
630
+
631
+ genFun.prototype = Object.create(Gp);
632
+ return genFun;
633
+ }; // Within the body of any async function, `await x` is transformed to
634
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
635
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
636
+ // meant to be awaited.
637
+
638
+
639
+ exports.awrap = function (arg) {
640
+ return {
641
+ __await: arg
642
+ };
643
+ };
644
+
645
+ function AsyncIterator(generator, PromiseImpl) {
646
+ function invoke(method, arg, resolve, reject) {
647
+ var record = tryCatch(generator[method], generator, arg);
648
+
649
+ if (record.type === "throw") {
650
+ reject(record.arg);
651
+ } else {
652
+ var result = record.arg;
653
+ var value = result.value;
654
+
655
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
656
+ return PromiseImpl.resolve(value.__await).then(function (value) {
657
+ invoke("next", value, resolve, reject);
658
+ }, function (err) {
659
+ invoke("throw", err, resolve, reject);
660
+ });
661
+ }
662
+
663
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
664
+ // When a yielded Promise is resolved, its final value becomes
665
+ // the .value of the Promise<{value,done}> result for the
666
+ // current iteration.
667
+ result.value = unwrapped;
668
+ resolve(result);
669
+ }, function (error) {
670
+ // If a rejected Promise was yielded, throw the rejection back
671
+ // into the async generator function so it can be handled there.
672
+ return invoke("throw", error, resolve, reject);
673
+ });
674
+ }
675
+ }
676
+
677
+ var previousPromise;
678
+
679
+ function enqueue(method, arg) {
680
+ function callInvokeWithMethodAndArg() {
681
+ return new PromiseImpl(function (resolve, reject) {
682
+ invoke(method, arg, resolve, reject);
683
+ });
684
+ }
685
+
686
+ return previousPromise = // If enqueue has been called before, then we want to wait until
687
+ // all previous Promises have been resolved before calling invoke,
688
+ // so that results are always delivered in the correct order. If
689
+ // enqueue has not been called before, then it is important to
690
+ // call invoke immediately, without waiting on a callback to fire,
691
+ // so that the async generator function has the opportunity to do
692
+ // any necessary setup in a predictable way. This predictability
693
+ // is why the Promise constructor synchronously invokes its
694
+ // executor callback, and why async functions synchronously
695
+ // execute code before the first await. Since we implement simple
696
+ // async functions in terms of async generators, it is especially
697
+ // important to get this right, even though it requires care.
698
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
699
+ // invocations of the iterator.
700
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
701
+ } // Define the unified helper method that is used to implement .next,
702
+ // .throw, and .return (see defineIteratorMethods).
703
+
704
+
705
+ this._invoke = enqueue;
706
+ }
707
+
708
+ defineIteratorMethods(AsyncIterator.prototype);
709
+
710
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
711
+ return this;
712
+ };
713
+
714
+ exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
715
+ // AsyncIterator objects; they just return a Promise for the value of
716
+ // the final result produced by the iterator.
717
+
718
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
719
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
720
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
721
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
722
+ : iter.next().then(function (result) {
723
+ return result.done ? result.value : iter.next();
724
+ });
725
+ };
726
+
727
+ function makeInvokeMethod(innerFn, self, context) {
728
+ var state = GenStateSuspendedStart;
729
+ return function invoke(method, arg) {
730
+ if (state === GenStateExecuting) {
731
+ throw new Error("Generator is already running");
732
+ }
733
+
734
+ if (state === GenStateCompleted) {
735
+ if (method === "throw") {
736
+ throw arg;
737
+ } // Be forgiving, per 25.3.3.3.3 of the spec:
738
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
739
+
740
+
741
+ return doneResult();
742
+ }
743
+
744
+ context.method = method;
745
+ context.arg = arg;
746
+
747
+ while (true) {
748
+ var delegate = context.delegate;
749
+
750
+ if (delegate) {
751
+ var delegateResult = maybeInvokeDelegate(delegate, context);
752
+
753
+ if (delegateResult) {
754
+ if (delegateResult === ContinueSentinel) continue;
755
+ return delegateResult;
756
+ }
757
+ }
758
+
759
+ if (context.method === "next") {
760
+ // Setting context._sent for legacy support of Babel's
761
+ // function.sent implementation.
762
+ context.sent = context._sent = context.arg;
763
+ } else if (context.method === "throw") {
764
+ if (state === GenStateSuspendedStart) {
765
+ state = GenStateCompleted;
766
+ throw context.arg;
767
+ }
768
+
769
+ context.dispatchException(context.arg);
770
+ } else if (context.method === "return") {
771
+ context.abrupt("return", context.arg);
772
+ }
773
+
774
+ state = GenStateExecuting;
775
+ var record = tryCatch(innerFn, self, context);
776
+
777
+ if (record.type === "normal") {
778
+ // If an exception is thrown from innerFn, we leave state ===
779
+ // GenStateExecuting and loop back for another invocation.
780
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
781
+
782
+ if (record.arg === ContinueSentinel) {
783
+ continue;
784
+ }
785
+
786
+ return {
787
+ value: record.arg,
788
+ done: context.done
789
+ };
790
+ } else if (record.type === "throw") {
791
+ state = GenStateCompleted; // Dispatch the exception by looping back around to the
792
+ // context.dispatchException(context.arg) call above.
793
+
794
+ context.method = "throw";
795
+ context.arg = record.arg;
796
+ }
797
+ }
798
+ };
799
+ } // Call delegate.iterator[context.method](context.arg) and handle the
800
+ // result, either by returning a { value, done } result from the
801
+ // delegate iterator, or by modifying context.method and context.arg,
802
+ // setting context.delegate to null, and returning the ContinueSentinel.
803
+
804
+
805
+ function maybeInvokeDelegate(delegate, context) {
806
+ var method = delegate.iterator[context.method];
807
+
808
+ if (method === undefined$1) {
809
+ // A .throw or .return when the delegate iterator has no .throw
810
+ // method always terminates the yield* loop.
811
+ context.delegate = null;
812
+
813
+ if (context.method === "throw") {
814
+ // Note: ["return"] must be used for ES3 parsing compatibility.
815
+ if (delegate.iterator["return"]) {
816
+ // If the delegate iterator has a return method, give it a
817
+ // chance to clean up.
818
+ context.method = "return";
819
+ context.arg = undefined$1;
820
+ maybeInvokeDelegate(delegate, context);
821
+
822
+ if (context.method === "throw") {
823
+ // If maybeInvokeDelegate(context) changed context.method from
824
+ // "return" to "throw", let that override the TypeError below.
825
+ return ContinueSentinel;
826
+ }
827
+ }
828
+
829
+ context.method = "throw";
830
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
831
+ }
832
+
833
+ return ContinueSentinel;
834
+ }
835
+
836
+ var record = tryCatch(method, delegate.iterator, context.arg);
837
+
838
+ if (record.type === "throw") {
839
+ context.method = "throw";
840
+ context.arg = record.arg;
841
+ context.delegate = null;
842
+ return ContinueSentinel;
843
+ }
844
+
845
+ var info = record.arg;
846
+
847
+ if (!info) {
848
+ context.method = "throw";
849
+ context.arg = new TypeError("iterator result is not an object");
850
+ context.delegate = null;
851
+ return ContinueSentinel;
852
+ }
853
+
854
+ if (info.done) {
855
+ // Assign the result of the finished delegate to the temporary
856
+ // variable specified by delegate.resultName (see delegateYield).
857
+ context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
858
+
859
+ context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
860
+ // exception, let the outer generator proceed normally. If
861
+ // context.method was "next", forget context.arg since it has been
862
+ // "consumed" by the delegate iterator. If context.method was
863
+ // "return", allow the original .return call to continue in the
864
+ // outer generator.
865
+
866
+ if (context.method !== "return") {
867
+ context.method = "next";
868
+ context.arg = undefined$1;
869
+ }
870
+ } else {
871
+ // Re-yield the result returned by the delegate method.
872
+ return info;
873
+ } // The delegate iterator is finished, so forget it and continue with
874
+ // the outer generator.
875
+
876
+
877
+ context.delegate = null;
878
+ return ContinueSentinel;
879
+ } // Define Generator.prototype.{next,throw,return} in terms of the
880
+ // unified ._invoke helper method.
881
+
882
+
883
+ defineIteratorMethods(Gp);
884
+ define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
885
+ // @@iterator function is called on it. Some browsers' implementations of the
886
+ // iterator prototype chain incorrectly implement this, causing the Generator
887
+ // object to not be returned from this call. This ensures that doesn't happen.
888
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
889
+
890
+ Gp[iteratorSymbol] = function () {
891
+ return this;
892
+ };
893
+
894
+ Gp.toString = function () {
895
+ return "[object Generator]";
896
+ };
897
+
898
+ function pushTryEntry(locs) {
899
+ var entry = {
900
+ tryLoc: locs[0]
901
+ };
902
+
903
+ if (1 in locs) {
904
+ entry.catchLoc = locs[1];
905
+ }
906
+
907
+ if (2 in locs) {
908
+ entry.finallyLoc = locs[2];
909
+ entry.afterLoc = locs[3];
910
+ }
911
+
912
+ this.tryEntries.push(entry);
913
+ }
914
+
915
+ function resetTryEntry(entry) {
916
+ var record = entry.completion || {};
917
+ record.type = "normal";
918
+ delete record.arg;
919
+ entry.completion = record;
920
+ }
921
+
922
+ function Context(tryLocsList) {
923
+ // The root entry object (effectively a try statement without a catch
924
+ // or a finally block) gives us a place to store values thrown from
925
+ // locations where there is no enclosing try statement.
926
+ this.tryEntries = [{
927
+ tryLoc: "root"
928
+ }];
929
+ tryLocsList.forEach(pushTryEntry, this);
930
+ this.reset(true);
931
+ }
932
+
933
+ exports.keys = function (object) {
934
+ var keys = [];
935
+
936
+ for (var key in object) {
937
+ keys.push(key);
938
+ }
939
+
940
+ keys.reverse(); // Rather than returning an object with a next method, we keep
941
+ // things simple and return the next function itself.
942
+
943
+ return function next() {
944
+ while (keys.length) {
945
+ var key = keys.pop();
946
+
947
+ if (key in object) {
948
+ next.value = key;
949
+ next.done = false;
950
+ return next;
951
+ }
952
+ } // To avoid creating an additional object, we just hang the .value
953
+ // and .done properties off the next function object itself. This
954
+ // also ensures that the minifier will not anonymize the function.
955
+
956
+
957
+ next.done = true;
958
+ return next;
959
+ };
960
+ };
961
+
962
+ function values(iterable) {
963
+ if (iterable) {
964
+ var iteratorMethod = iterable[iteratorSymbol];
965
+
966
+ if (iteratorMethod) {
967
+ return iteratorMethod.call(iterable);
968
+ }
969
+
970
+ if (typeof iterable.next === "function") {
971
+ return iterable;
972
+ }
973
+
974
+ if (!isNaN(iterable.length)) {
975
+ var i = -1,
976
+ next = function next() {
977
+ while (++i < iterable.length) {
978
+ if (hasOwn.call(iterable, i)) {
979
+ next.value = iterable[i];
980
+ next.done = false;
981
+ return next;
982
+ }
983
+ }
984
+
985
+ next.value = undefined$1;
986
+ next.done = true;
987
+ return next;
988
+ };
989
+
990
+ return next.next = next;
991
+ }
992
+ } // Return an iterator with no values.
993
+
994
+
995
+ return {
996
+ next: doneResult
997
+ };
998
+ }
999
+
1000
+ exports.values = values;
1001
+
1002
+ function doneResult() {
1003
+ return {
1004
+ value: undefined$1,
1005
+ done: true
1006
+ };
1007
+ }
1008
+
1009
+ Context.prototype = {
1010
+ constructor: Context,
1011
+ reset: function reset(skipTempReset) {
1012
+ this.prev = 0;
1013
+ this.next = 0; // Resetting context._sent for legacy support of Babel's
1014
+ // function.sent implementation.
1015
+
1016
+ this.sent = this._sent = undefined$1;
1017
+ this.done = false;
1018
+ this.delegate = null;
1019
+ this.method = "next";
1020
+ this.arg = undefined$1;
1021
+ this.tryEntries.forEach(resetTryEntry);
1022
+
1023
+ if (!skipTempReset) {
1024
+ for (var name in this) {
1025
+ // Not sure about the optimal order of these conditions:
1026
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
1027
+ this[name] = undefined$1;
1028
+ }
1029
+ }
1030
+ }
1031
+ },
1032
+ stop: function stop() {
1033
+ this.done = true;
1034
+ var rootEntry = this.tryEntries[0];
1035
+ var rootRecord = rootEntry.completion;
1036
+
1037
+ if (rootRecord.type === "throw") {
1038
+ throw rootRecord.arg;
1039
+ }
1040
+
1041
+ return this.rval;
1042
+ },
1043
+ dispatchException: function dispatchException(exception) {
1044
+ if (this.done) {
1045
+ throw exception;
1046
+ }
1047
+
1048
+ var context = this;
1049
+
1050
+ function handle(loc, caught) {
1051
+ record.type = "throw";
1052
+ record.arg = exception;
1053
+ context.next = loc;
1054
+
1055
+ if (caught) {
1056
+ // If the dispatched exception was caught by a catch block,
1057
+ // then let that catch block handle the exception normally.
1058
+ context.method = "next";
1059
+ context.arg = undefined$1;
1060
+ }
1061
+
1062
+ return !!caught;
1063
+ }
1064
+
1065
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1066
+ var entry = this.tryEntries[i];
1067
+ var record = entry.completion;
1068
+
1069
+ if (entry.tryLoc === "root") {
1070
+ // Exception thrown outside of any try block that could handle
1071
+ // it, so set the completion value of the entire function to
1072
+ // throw the exception.
1073
+ return handle("end");
1074
+ }
1075
+
1076
+ if (entry.tryLoc <= this.prev) {
1077
+ var hasCatch = hasOwn.call(entry, "catchLoc");
1078
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
1079
+
1080
+ if (hasCatch && hasFinally) {
1081
+ if (this.prev < entry.catchLoc) {
1082
+ return handle(entry.catchLoc, true);
1083
+ } else if (this.prev < entry.finallyLoc) {
1084
+ return handle(entry.finallyLoc);
1085
+ }
1086
+ } else if (hasCatch) {
1087
+ if (this.prev < entry.catchLoc) {
1088
+ return handle(entry.catchLoc, true);
1089
+ }
1090
+ } else if (hasFinally) {
1091
+ if (this.prev < entry.finallyLoc) {
1092
+ return handle(entry.finallyLoc);
1093
+ }
1094
+ } else {
1095
+ throw new Error("try statement without catch or finally");
1096
+ }
1097
+ }
1098
+ }
1099
+ },
1100
+ abrupt: function abrupt(type, arg) {
1101
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1102
+ var entry = this.tryEntries[i];
1103
+
1104
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1105
+ var finallyEntry = entry;
1106
+ break;
1107
+ }
1108
+ }
1109
+
1110
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1111
+ // Ignore the finally entry if control is not jumping to a
1112
+ // location outside the try/catch block.
1113
+ finallyEntry = null;
1114
+ }
1115
+
1116
+ var record = finallyEntry ? finallyEntry.completion : {};
1117
+ record.type = type;
1118
+ record.arg = arg;
1119
+
1120
+ if (finallyEntry) {
1121
+ this.method = "next";
1122
+ this.next = finallyEntry.finallyLoc;
1123
+ return ContinueSentinel;
1124
+ }
1125
+
1126
+ return this.complete(record);
1127
+ },
1128
+ complete: function complete(record, afterLoc) {
1129
+ if (record.type === "throw") {
1130
+ throw record.arg;
1131
+ }
1132
+
1133
+ if (record.type === "break" || record.type === "continue") {
1134
+ this.next = record.arg;
1135
+ } else if (record.type === "return") {
1136
+ this.rval = this.arg = record.arg;
1137
+ this.method = "return";
1138
+ this.next = "end";
1139
+ } else if (record.type === "normal" && afterLoc) {
1140
+ this.next = afterLoc;
1141
+ }
1142
+
1143
+ return ContinueSentinel;
1144
+ },
1145
+ finish: function finish(finallyLoc) {
1146
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1147
+ var entry = this.tryEntries[i];
1148
+
1149
+ if (entry.finallyLoc === finallyLoc) {
1150
+ this.complete(entry.completion, entry.afterLoc);
1151
+ resetTryEntry(entry);
1152
+ return ContinueSentinel;
1153
+ }
1154
+ }
1155
+ },
1156
+ "catch": function _catch(tryLoc) {
1157
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1158
+ var entry = this.tryEntries[i];
1159
+
1160
+ if (entry.tryLoc === tryLoc) {
1161
+ var record = entry.completion;
1162
+
1163
+ if (record.type === "throw") {
1164
+ var thrown = record.arg;
1165
+ resetTryEntry(entry);
1166
+ }
1167
+
1168
+ return thrown;
1169
+ }
1170
+ } // The context.catch method must only be called with a location
1171
+ // argument that corresponds to a known catch block.
1172
+
1173
+
1174
+ throw new Error("illegal catch attempt");
1175
+ },
1176
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1177
+ this.delegate = {
1178
+ iterator: values(iterable),
1179
+ resultName: resultName,
1180
+ nextLoc: nextLoc
1181
+ };
1182
+
1183
+ if (this.method === "next") {
1184
+ // Deliberately forget the last sent value so that we don't
1185
+ // accidentally pass it on to the delegate.
1186
+ this.arg = undefined$1;
1187
+ }
1188
+
1189
+ return ContinueSentinel;
1190
+ }
1191
+ }; // Regardless of whether this script is executing as a CommonJS module
1192
+ // or not, return the runtime object so that we can declare the variable
1193
+ // regeneratorRuntime in the outer scope, which allows this module to be
1194
+ // injected easily by `bin/regenerator --include-runtime script.js`.
1195
+
1196
+ return exports;
1197
+ }( // If this script is executing as a CommonJS module, use module.exports
1198
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
1199
+ // object. Either way, the resulting object will be used to initialize
1200
+ // the regeneratorRuntime variable at the top of this file.
1201
+ module.exports );
1202
+
1203
+ try {
1204
+ regeneratorRuntime = runtime;
1205
+ } catch (accidentalStrictMode) {
1206
+ // This module should not be running in strict mode, so the above
1207
+ // assignment should always work unless something is misconfigured. Just
1208
+ // in case runtime.js accidentally runs in strict mode, we can escape
1209
+ // strict mode using a global Function call. This could conceivably fail
1210
+ // if a Content Security Policy forbids using Function, but in that case
1211
+ // the proper solution is to fix the accidental strict mode problem. If
1212
+ // you've misconfigured your bundler to force strict mode and applied a
1213
+ // CSP to forbid Function, and you're not willing to fix either of those
1214
+ // problems, please detail your unique predicament in a GitHub issue.
1215
+ Function("r", "regeneratorRuntime = r")(runtime);
1216
+ }
1217
+ })(runtime);
1218
+
1219
+ var _regeneratorRuntime = runtime.exports;
1220
+
449
1221
  var useNormalizedItems = function useNormalizedItems(items) {
450
1222
  return React.useMemo(function () {
451
1223
  return items.map(function (item) {
@@ -526,27 +1298,49 @@ debounceTimeout) {
526
1298
  var isMounted = useIsMounted(); // Next, let's create the fetching function. This should be called whenever
527
1299
  // the input value changes
528
1300
 
529
- var fetchItems = React.useCallback(function (inputValue) {
530
- try {
531
- if (!isMounted) {
532
- return Promise.resolve();
533
- }
534
-
535
- dispatch({
536
- type: 'request results'
537
- });
538
- return Promise.resolve(itemsResolver(inputValue)).then(function (resolvedItems) {
539
- if (isMounted) {
540
- dispatch({
541
- type: 'received results',
542
- payload: resolvedItems
543
- });
1301
+ var fetchItems = React.useCallback( /*#__PURE__*/function () {
1302
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
1303
+ var resolvedItems;
1304
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1305
+ while (1) {
1306
+ switch (_context.prev = _context.next) {
1307
+ case 0:
1308
+ if (isMounted) {
1309
+ _context.next = 2;
1310
+ break;
1311
+ }
1312
+
1313
+ return _context.abrupt("return");
1314
+
1315
+ case 2:
1316
+ dispatch({
1317
+ type: 'request results'
1318
+ });
1319
+ _context.next = 5;
1320
+ return itemsResolver(inputValue);
1321
+
1322
+ case 5:
1323
+ resolvedItems = _context.sent;
1324
+
1325
+ if (isMounted) {
1326
+ dispatch({
1327
+ type: 'received results',
1328
+ payload: resolvedItems
1329
+ });
1330
+ }
1331
+
1332
+ case 7:
1333
+ case "end":
1334
+ return _context.stop();
1335
+ }
544
1336
  }
545
- });
546
- } catch (e) {
547
- return Promise.reject(e);
548
- }
549
- }, [itemsResolver, isMounted]);
1337
+ }, _callee);
1338
+ }));
1339
+
1340
+ return function (_x) {
1341
+ return _ref.apply(this, arguments);
1342
+ };
1343
+ }(), [itemsResolver, isMounted]);
550
1344
  var normalizedItems = useNormalizedItems(items);
551
1345
  React.useEffect(function () {
552
1346
  // Let's fetch the list initially if it's specified
@@ -561,6 +1355,7 @@ debounceTimeout) {
561
1355
  };
562
1356
  };
563
1357
 
1358
+ var _excluded$2 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
564
1359
  var Dropdown = function Dropdown(_ref) {
565
1360
  var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
566
1361
  debounceTimeout = _ref.debounceTimeout,
@@ -588,7 +1383,7 @@ var Dropdown = function Dropdown(_ref) {
588
1383
  listStyle = _ref.listStyle,
589
1384
  itemFilter = _ref.itemFilter,
590
1385
  disableLabelAnimation = _ref.disableLabelAnimation,
591
- rest = _objectWithoutPropertiesLoose(_ref, ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"]);
1386
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
592
1387
 
593
1388
  var _useResolvedItems = useResolvedItems(items, debounceTimeout),
594
1389
  normalizedItems = _useResolvedItems.items,
@@ -607,7 +1402,7 @@ var Dropdown = function Dropdown(_ref) {
607
1402
  name: rest.name,
608
1403
  'data-cy': rest['data-cy']
609
1404
  };
610
- return React.createElement(DownshiftProvider, Object.assign({
1405
+ return React.createElement(DownshiftProvider, _extends({
611
1406
  selectedItem: selectedItem,
612
1407
  onInputValueChange: fetchItems,
613
1408
  onChange: onChange,
@@ -619,7 +1414,7 @@ var Dropdown = function Dropdown(_ref) {
619
1414
  }, rest), React.createElement(DropdownInputGroup, {
620
1415
  feedback: feedback,
621
1416
  variant: variant
622
- }, React.createElement(RenderedDropdown, Object.assign({
1417
+ }, React.createElement(RenderedDropdown, _extends({
623
1418
  label: label,
624
1419
  items: normalizedItems,
625
1420
  loading: loading,
@@ -636,6 +1431,7 @@ var Dropdown = function Dropdown(_ref) {
636
1431
  }, searchAbleProps))));
637
1432
  };
638
1433
 
1434
+ var _excluded$1 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
639
1435
  var NativeDropdown = function NativeDropdown(_ref) {
640
1436
  var className = _ref.className,
641
1437
  _ref$disabled = _ref.disabled,
@@ -650,7 +1446,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
650
1446
  variant = _ref.variant,
651
1447
  feedback = _ref.feedback,
652
1448
  disableLabelAnimation = _ref.disableLabelAnimation,
653
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"]);
1449
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
654
1450
 
655
1451
  var _useResolvedItems = useResolvedItems(items),
656
1452
  normalizedItems = _useResolvedItems.items,
@@ -680,7 +1476,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
680
1476
  labelId: nativeDropdownId,
681
1477
  disableLabelAnimation: disableLabelAnimation,
682
1478
  isFilled: true
683
- }, React.createElement("select", Object.assign({
1479
+ }, React.createElement("select", _extends({
684
1480
  "aria-invalid": variant === 'error',
685
1481
  className: "eds-form-control eds-dropdown",
686
1482
  disabled: disabled || readOnly
@@ -692,6 +1488,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
692
1488
  })));
693
1489
  };
694
1490
 
1491
+ var _excluded = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
695
1492
  var MultiSelectContext = /*#__PURE__*/React.createContext(null);
696
1493
 
697
1494
  var useMultiSelectContext = function useMultiSelectContext() {
@@ -753,7 +1550,7 @@ var MultiSelect = function MultiSelect(_ref) {
753
1550
  _ref$initialSelectedI = _ref.initialSelectedItems,
754
1551
  initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
755
1552
  debounceTimeout = _ref.debounceTimeout,
756
- rest = _objectWithoutPropertiesLoose(_ref, ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"]);
1553
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
757
1554
 
758
1555
  var _useResolvedItems = useResolvedItems(input, debounceTimeout),
759
1556
  items = _useResolvedItems.items;
@@ -766,6 +1563,12 @@ var MultiSelect = function MultiSelect(_ref) {
766
1563
  setSelectedItems([]);
767
1564
  }, []);
768
1565
 
1566
+ function isSelected(selectedCheckboxItem) {
1567
+ return selectedItems.some(function (selected) {
1568
+ return selected.value === selectedCheckboxItem.value;
1569
+ });
1570
+ }
1571
+
769
1572
  var _useSelect = useSelect(_extends({
770
1573
  items: items,
771
1574
  stateReducer: stateReducer,
@@ -777,22 +1580,19 @@ var MultiSelect = function MultiSelect(_ref) {
777
1580
  return;
778
1581
  }
779
1582
 
780
- var index = selectedItems.indexOf(selectedItem);
1583
+ var itemIsFound = isSelected(selectedItem);
781
1584
 
782
- if (index > 0) {
783
- var slicedItemList = [].concat(selectedItems.slice(0, index), selectedItems.slice(index + 1));
1585
+ if (itemIsFound) {
1586
+ var slicedItemList = selectedItems.filter(function (item) {
1587
+ return item.value !== selectedItem.value;
1588
+ });
784
1589
  setSelectedItems(slicedItemList);
785
1590
  onChange(slicedItemList);
786
- } else if (index === 0) {
787
- var _slicedItemList = [].concat(selectedItems.slice(1));
1591
+ } else {
1592
+ var _slicedItemList = [].concat(selectedItems, [selectedItem]);
788
1593
 
789
1594
  setSelectedItems(_slicedItemList);
790
1595
  onChange(_slicedItemList);
791
- } else {
792
- var _slicedItemList2 = [].concat(selectedItems, [selectedItem]);
793
-
794
- setSelectedItems(_slicedItemList2);
795
- onChange(_slicedItemList2);
796
1596
  }
797
1597
  }
798
1598
  }, rest)),
@@ -826,19 +1626,19 @@ var MultiSelect = function MultiSelect(_ref) {
826
1626
  isFilled: selectedItems.length > 0 || isOpen,
827
1627
  disabled: disabled,
828
1628
  readOnly: readOnly,
829
- append: React.createElement(Appendix$1, {
1629
+ append: React.createElement(Appendix, {
830
1630
  hasSelected: clearable && selectedItems.length > 0,
831
1631
  loading: loading,
832
1632
  loadingText: loadingText,
833
1633
  readOnly: readOnly
834
1634
  })
835
- }, React.createElement("button", Object.assign({}, getToggleButtonProps({
1635
+ }, React.createElement("button", _extends({}, getToggleButtonProps({
836
1636
  style: {
837
1637
  textAlign: 'left'
838
1638
  },
839
1639
  type: 'button',
840
1640
  className: 'eds-form-control eds-multiselect__button'
841
- })), buttonText)), React.createElement("ul", Object.assign({
1641
+ })), buttonText)), React.createElement("ul", _extends({
842
1642
  className: classNames('eds-dropdown-list', {
843
1643
  'eds-dropdown-list--open': isOpen
844
1644
  })
@@ -848,12 +1648,12 @@ var MultiSelect = function MultiSelect(_ref) {
848
1648
  top: space.extraLarge3 + space.extraSmall + "px"
849
1649
  }, listStyle)
850
1650
  })), isOpen && items.map(function (item, index) {
851
- return React.createElement("li", Object.assign({
1651
+ return React.createElement("li", _extends({
852
1652
  className: classNames('eds-dropdown-list__item', {
853
1653
  'eds-dropdown-list__item--highlighted': highlightedIndex === index,
854
- 'eds-dropdown-list__item--selected': selectedItems.includes(item)
1654
+ 'eds-dropdown-list__item--selected': isSelected(item)
855
1655
  }),
856
- key: "" + item + index
1656
+ key: "" + item.value + index
857
1657
  }, getItemProps({
858
1658
  item: item,
859
1659
  index: index
@@ -867,7 +1667,7 @@ var MultiSelect = function MultiSelect(_ref) {
867
1667
  }
868
1668
  }, React.createElement("span", {
869
1669
  className: classNames('eds-multiselect-checkbox', {
870
- 'eds-multiselect-checkbox--checked': selectedItems.includes(item)
1670
+ 'eds-multiselect-checkbox--checked': isSelected(item)
871
1671
  })
872
1672
  }, React.createElement(CheckboxIcon, null)), React.createElement("span", {
873
1673
  className: "eds-multiselect__item-label"
@@ -881,13 +1681,13 @@ var MultiSelect = function MultiSelect(_ref) {
881
1681
  }))));
882
1682
  };
883
1683
 
884
- var ClearButton$1 = function ClearButton(_ref3) {
1684
+ var ClearButton = function ClearButton(_ref3) {
885
1685
  var props = _extends({}, _ref3);
886
1686
 
887
1687
  var _useMultiSelectContex = useMultiSelectContext(),
888
1688
  reset = _useMultiSelectContex.reset;
889
1689
 
890
- return React.createElement(React.Fragment, null, React.createElement("button", Object.assign({
1690
+ return React.createElement(React.Fragment, null, React.createElement("button", _extends({
891
1691
  className: "eds-dropdown__clear-button",
892
1692
  type: "button",
893
1693
  tabIndex: -1,
@@ -899,7 +1699,7 @@ var ClearButton$1 = function ClearButton(_ref3) {
899
1699
  }));
900
1700
  };
901
1701
 
902
- var Appendix$1 = function Appendix(_ref4) {
1702
+ var Appendix = function Appendix(_ref4) {
903
1703
  var loading = _ref4.loading,
904
1704
  loadingText = _ref4.loadingText,
905
1705
  readOnly = _ref4.readOnly,
@@ -913,17 +1713,17 @@ var Appendix$1 = function Appendix(_ref4) {
913
1713
  return null;
914
1714
  }
915
1715
 
916
- return hasSelected ? React.createElement(React.Fragment, null, React.createElement(ClearButton$1, null), React.createElement(DropdownToggleButton$1, null)) : React.createElement(DropdownToggleButton$1, null);
1716
+ return hasSelected ? React.createElement(React.Fragment, null, React.createElement(ClearButton, null), React.createElement(DropdownToggleButton, null)) : React.createElement(DropdownToggleButton, null);
917
1717
  };
918
1718
 
919
- var DropdownToggleButton$1 = function DropdownToggleButton() {
1719
+ var DropdownToggleButton = function DropdownToggleButton() {
920
1720
  var _useMultiSelectContex2 = useMultiSelectContext(),
921
1721
  getToggleButtonProps = _useMultiSelectContex2.getToggleButtonProps,
922
1722
  isOpen = _useMultiSelectContex2.isOpen,
923
1723
  openMenu = _useMultiSelectContex2.openMenu,
924
1724
  openOnFocus = _useMultiSelectContex2.openOnFocus;
925
1725
 
926
- return React.createElement("button", Object.assign({}, getToggleButtonProps({
1726
+ return React.createElement("button", _extends({}, getToggleButtonProps({
927
1727
  className: classNames('eds-dropdown__toggle-button', {
928
1728
  'eds-dropdown__toggle-button--open': isOpen
929
1729
  }),