@entur/dropdown 2.1.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,
@@ -56,7 +93,9 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
56
93
  highlightFirstItemOnOpen = _ref$highlightFirstIt === void 0 ? false : _ref$highlightFirstIt,
57
94
  className = _ref.className,
58
95
  style = _ref.style,
59
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style"]);
96
+ _ref$searchable = _ref.searchable,
97
+ searchable = _ref$searchable === void 0 ? false : _ref$searchable,
98
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
60
99
 
61
100
  var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
62
101
  if (changes.type === Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem) {
@@ -71,20 +110,37 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
71
110
  };
72
111
 
73
112
  var stateReducer = function stateReducer(_, changes) {
74
- if (highlightFirstItemOnOpen) {
75
- var wasJustOpened = 'isOpen' in changes && changes.isOpen;
76
-
77
- if (wasJustOpened) {
78
- return _extends({}, changes, {
79
- highlightedIndex: 0
80
- });
113
+ var highlightFirstOnOpen = highlightFirstItemOnOpen && 'isOpen' in changes && changes.isOpen;
114
+ var highlightFirstItemIndex = highlightFirstOnOpen ? {
115
+ highlightedIndex: 0
116
+ } : {};
117
+
118
+ if (searchable) {
119
+ var type = changes.type;
120
+
121
+ switch (type) {
122
+ case '__autocomplete_change_input__':
123
+ return _extends({}, changes, highlightFirstItemIndex);
124
+
125
+ case '__autocomplete_click_item__':
126
+ case '__autocomplete_keydown_enter__':
127
+ case '__autocomplete_blur_input__':
128
+ case '__autocomplete_mouseup__':
129
+ return _extends({}, changes, {
130
+ // if we had an item highlighted in the previous state.
131
+ // we will reset input field value to blank
132
+ inputValue: ''
133
+ }, highlightFirstItemIndex);
134
+
135
+ default:
136
+ return _extends({}, changes, highlightFirstItemIndex);
81
137
  }
138
+ } else {
139
+ return _extends({}, changes, highlightFirstItemIndex);
82
140
  }
83
-
84
- return changes;
85
141
  };
86
142
 
87
- return React.createElement(Downshift, Object.assign({
143
+ return React.createElement(Downshift, _extends({
88
144
  itemToString: function itemToString(item) {
89
145
  return item ? item.label : '';
90
146
  },
@@ -109,9 +165,10 @@ var useDownshift = function useDownshift() {
109
165
  return context;
110
166
  };
111
167
 
168
+ var _excluded$7 = ["items"];
112
169
  var DropdownList = function DropdownList(_ref) {
113
170
  var items = _ref.items,
114
- rest = _objectWithoutPropertiesLoose(_ref, ["items"]);
171
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
115
172
 
116
173
  var _useDownshift = useDownshift(),
117
174
  highlightedIndex = _useDownshift.highlightedIndex,
@@ -120,13 +177,13 @@ var DropdownList = function DropdownList(_ref) {
120
177
  getItemProps = _useDownshift.getItemProps,
121
178
  getMenuProps = _useDownshift.getMenuProps;
122
179
 
123
- return React.createElement("ul", Object.assign({
180
+ return React.createElement("ul", _extends({
124
181
  className: classNames('eds-dropdown-list', {
125
182
  'eds-dropdown-list--open': isOpen
126
183
  })
127
184
  }, getMenuProps(), rest), isOpen ? items.map(function (item, index) {
128
185
  return (// eslint-disable-next-line react/jsx-key
129
- React.createElement("li", Object.assign({
186
+ React.createElement("li", _extends({
130
187
  className: classNames('eds-dropdown-list__item', {
131
188
  'eds-dropdown-list__item--highlighted': highlightedIndex === index,
132
189
  'eds-dropdown-list__item--selected': selectedItem === item
@@ -146,12 +203,12 @@ var DropdownList = function DropdownList(_ref) {
146
203
  }) : null);
147
204
  };
148
205
 
149
- var DropdownToggleButton = function DropdownToggleButton() {
206
+ var DropdownToggleButton$1 = function DropdownToggleButton() {
150
207
  var _useDownshift = useDownshift(),
151
208
  getToggleButtonProps = _useDownshift.getToggleButtonProps,
152
209
  isOpen = _useDownshift.isOpen;
153
210
 
154
- return React.createElement("button", Object.assign({}, getToggleButtonProps({
211
+ return React.createElement("button", _extends({}, getToggleButtonProps({
155
212
  className: classNames('eds-dropdown__toggle-button', {
156
213
  'eds-dropdown__toggle-button--open': isOpen
157
214
  })
@@ -161,16 +218,18 @@ var DropdownToggleButton = function DropdownToggleButton() {
161
218
  }), React.createElement(DownArrowIcon, null));
162
219
  };
163
220
 
221
+ var _excluded$6 = ["className", "children"];
164
222
  var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
165
223
  var className = _ref.className,
166
224
  children = _ref.children,
167
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "children"]);
225
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
168
226
 
169
- return React.createElement("div", Object.assign({
227
+ return React.createElement("div", _extends({
170
228
  className: classNames('eds-inline-spinner', className)
171
229
  }, rest), React.createElement(LoadingDots, null), React.createElement(VisuallyHidden, null, children));
172
230
  };
173
231
 
232
+ var _excluded$5 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
174
233
  var BaseDropdown = function BaseDropdown(_ref) {
175
234
  var children = _ref.children,
176
235
  className = _ref.className,
@@ -186,7 +245,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
186
245
  _ref$isFilled = _ref.isFilled,
187
246
  isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
188
247
  disableLabelAnimation = _ref.disableLabelAnimation,
189
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"]);
248
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
190
249
 
191
250
  var _useDownshift = useDownshift(),
192
251
  getLabelProps = _useDownshift.getLabelProps;
@@ -194,8 +253,8 @@ var BaseDropdown = function BaseDropdown(_ref) {
194
253
  return React.createElement("div", {
195
254
  className: "eds-dropdown-wrapper",
196
255
  style: style
197
- }, React.createElement(BaseFormControl, Object.assign({
198
- append: React.createElement(Appendix, {
256
+ }, React.createElement(BaseFormControl, _extends({
257
+ append: React.createElement(Appendix$1, {
199
258
  clearable: clearable,
200
259
  loading: loading,
201
260
  loadingText: loadingText,
@@ -206,7 +265,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
206
265
  isFilled: isFilled,
207
266
  labelProps: getLabelProps(),
208
267
  disableLabelAnimation: disableLabelAnimation
209
- }, rest), children), React.createElement(DropdownList, Object.assign({
268
+ }, rest), children), React.createElement(DropdownList, _extends({
210
269
  items: items,
211
270
  style: _extends({
212
271
  position: 'absolute',
@@ -215,14 +274,14 @@ var BaseDropdown = function BaseDropdown(_ref) {
215
274
  }, rest)));
216
275
  };
217
276
 
218
- var ClearButton = function ClearButton(_ref2) {
277
+ var ClearButton$1 = function ClearButton(_ref2) {
219
278
  var props = _extends({}, _ref2);
220
279
 
221
280
  var _useDownshift2 = useDownshift(),
222
281
  clearSelection = _useDownshift2.clearSelection,
223
282
  selectedItem = _useDownshift2.selectedItem;
224
283
 
225
- return React.createElement(React.Fragment, null, selectedItem && React.createElement("button", Object.assign({
284
+ return React.createElement(React.Fragment, null, selectedItem && React.createElement("button", _extends({
226
285
  className: "eds-dropdown__clear-button",
227
286
  type: "button",
228
287
  tabIndex: -1,
@@ -234,7 +293,7 @@ var ClearButton = function ClearButton(_ref2) {
234
293
  }));
235
294
  };
236
295
 
237
- var Appendix = function Appendix(_ref3) {
296
+ var Appendix$1 = function Appendix(_ref3) {
238
297
  var clearable = _ref3.clearable,
239
298
  loading = _ref3.loading,
240
299
  loadingText = _ref3.loadingText,
@@ -248,9 +307,10 @@ var Appendix = function Appendix(_ref3) {
248
307
  return null;
249
308
  }
250
309
 
251
- 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);
252
311
  };
253
312
 
313
+ var _excluded$4 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
254
314
  var RegularDropdown = function RegularDropdown(_ref) {
255
315
  var disabled = _ref.disabled,
256
316
  _ref$placeholder = _ref.placeholder,
@@ -267,7 +327,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
267
327
  loadingText = _ref.loadingText,
268
328
  className = _ref.className,
269
329
  clearable = _ref.clearable,
270
- rest = _objectWithoutPropertiesLoose(_ref, ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"]);
330
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
271
331
 
272
332
  var _useDownshift = useDownshift(),
273
333
  getToggleButtonProps = _useDownshift.getToggleButtonProps,
@@ -278,7 +338,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
278
338
  highlightedIndex = _useDownshift.highlightedIndex,
279
339
  setHighlightedIndex = _useDownshift.setHighlightedIndex;
280
340
 
281
- return React.createElement(BaseDropdown, Object.assign({
341
+ return React.createElement(BaseDropdown, _extends({
282
342
  disabled: disabled,
283
343
  listStyle: listStyle,
284
344
  items: items,
@@ -289,7 +349,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
289
349
  loadingText: loadingText,
290
350
  className: className,
291
351
  clearable: clearable
292
- }, rest), React.createElement("button", Object.assign({}, getToggleButtonProps(_extends({
352
+ }, rest), React.createElement("button", _extends({}, getToggleButtonProps(_extends({
293
353
  className: 'eds-form-control eds-dropdown__selected-item',
294
354
  style: {
295
355
  textAlign: 'left'
@@ -312,7 +372,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
312
372
  return firstCharacter === keyDownValue;
313
373
  });
314
374
  var nextHighlightItem = matchedItems.find(function (item) {
315
- return item.index > (highlightedIndex !== null && highlightedIndex !== void 0 ? highlightedIndex : 0);
375
+ return item.index > (highlightedIndex != null ? highlightedIndex : 0);
316
376
  });
317
377
 
318
378
  if (nextHighlightItem) {
@@ -330,6 +390,8 @@ var RegularDropdown = function RegularDropdown(_ref) {
330
390
  }, rest))), selectedItem ? selectedItem.label : placeholder));
331
391
  };
332
392
 
393
+ var _excluded$3 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
394
+
333
395
  function LowerCaseFilterTest(item, input) {
334
396
  if (!input) {
335
397
  return true;
@@ -362,7 +424,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
362
424
  } : _ref$itemFilter,
363
425
  label = _ref.label,
364
426
  disableLabelAnimation = _ref.disableLabelAnimation,
365
- rest = _objectWithoutPropertiesLoose(_ref, ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation"]);
427
+ placeholder = _ref.placeholder,
428
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
366
429
 
367
430
  var _useDownshift = useDownshift(),
368
431
  getInputProps = _useDownshift.getInputProps,
@@ -390,7 +453,9 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
390
453
  label: label,
391
454
  isFilled: selectedItem ? true : false,
392
455
  disableLabelAnimation: disableLabelAnimation
393
- }, React.createElement("input", Object.assign({}, getInputProps(_extends({
456
+ }, selectedItem && !inputValue && React.createElement("span", {
457
+ className: "eds-dropdown__searchable-selected-item"
458
+ }, selectedItem.label), React.createElement("input", _extends({}, getInputProps(_extends({
394
459
  disabled: disabled,
395
460
  readOnly: readOnly,
396
461
  className: 'eds-form-control eds-dropdown__input',
@@ -403,7 +468,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
403
468
  if (openOnFocus) {
404
469
  !isOpen && openMenu();
405
470
  }
406
- }
471
+ },
472
+ placeholder: selectedItem ? undefined : placeholder
407
473
  }, rest)))));
408
474
  };
409
475
 
@@ -423,6 +489,735 @@ var DropdownInputGroup = function DropdownInputGroup(_ref) {
423
489
  }, feedback)));
424
490
  };
425
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
+
426
1221
  var useNormalizedItems = function useNormalizedItems(items) {
427
1222
  return React.useMemo(function () {
428
1223
  return items.map(function (item) {
@@ -503,27 +1298,49 @@ debounceTimeout) {
503
1298
  var isMounted = useIsMounted(); // Next, let's create the fetching function. This should be called whenever
504
1299
  // the input value changes
505
1300
 
506
- var fetchItems = React.useCallback(function (inputValue) {
507
- try {
508
- if (!isMounted) {
509
- return Promise.resolve();
510
- }
511
-
512
- dispatch({
513
- type: 'request results'
514
- });
515
- return Promise.resolve(itemsResolver(inputValue)).then(function (resolvedItems) {
516
- if (isMounted) {
517
- dispatch({
518
- type: 'received results',
519
- payload: resolvedItems
520
- });
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
+ }
521
1336
  }
522
- });
523
- } catch (e) {
524
- return Promise.reject(e);
525
- }
526
- }, [itemsResolver, isMounted]);
1337
+ }, _callee);
1338
+ }));
1339
+
1340
+ return function (_x) {
1341
+ return _ref.apply(this, arguments);
1342
+ };
1343
+ }(), [itemsResolver, isMounted]);
527
1344
  var normalizedItems = useNormalizedItems(items);
528
1345
  React.useEffect(function () {
529
1346
  // Let's fetch the list initially if it's specified
@@ -538,6 +1355,7 @@ debounceTimeout) {
538
1355
  };
539
1356
  };
540
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"];
541
1359
  var Dropdown = function Dropdown(_ref) {
542
1360
  var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
543
1361
  debounceTimeout = _ref.debounceTimeout,
@@ -565,7 +1383,7 @@ var Dropdown = function Dropdown(_ref) {
565
1383
  listStyle = _ref.listStyle,
566
1384
  itemFilter = _ref.itemFilter,
567
1385
  disableLabelAnimation = _ref.disableLabelAnimation,
568
- 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);
569
1387
 
570
1388
  var _useResolvedItems = useResolvedItems(items, debounceTimeout),
571
1389
  normalizedItems = _useResolvedItems.items,
@@ -584,18 +1402,19 @@ var Dropdown = function Dropdown(_ref) {
584
1402
  name: rest.name,
585
1403
  'data-cy': rest['data-cy']
586
1404
  };
587
- return React.createElement(DownshiftProvider, Object.assign({
1405
+ return React.createElement(DownshiftProvider, _extends({
588
1406
  selectedItem: selectedItem,
589
1407
  onInputValueChange: fetchItems,
590
1408
  onChange: onChange,
591
1409
  value: value,
592
1410
  highlightFirstItemOnOpen: highlightFirstItemOnOpen,
593
1411
  className: className,
594
- style: style
1412
+ style: style,
1413
+ searchable: searchable
595
1414
  }, rest), React.createElement(DropdownInputGroup, {
596
1415
  feedback: feedback,
597
1416
  variant: variant
598
- }, React.createElement(RenderedDropdown, Object.assign({
1417
+ }, React.createElement(RenderedDropdown, _extends({
599
1418
  label: label,
600
1419
  items: normalizedItems,
601
1420
  loading: loading,
@@ -612,6 +1431,7 @@ var Dropdown = function Dropdown(_ref) {
612
1431
  }, searchAbleProps))));
613
1432
  };
614
1433
 
1434
+ var _excluded$1 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
615
1435
  var NativeDropdown = function NativeDropdown(_ref) {
616
1436
  var className = _ref.className,
617
1437
  _ref$disabled = _ref.disabled,
@@ -626,7 +1446,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
626
1446
  variant = _ref.variant,
627
1447
  feedback = _ref.feedback,
628
1448
  disableLabelAnimation = _ref.disableLabelAnimation,
629
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"]);
1449
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
630
1450
 
631
1451
  var _useResolvedItems = useResolvedItems(items),
632
1452
  normalizedItems = _useResolvedItems.items,
@@ -656,7 +1476,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
656
1476
  labelId: nativeDropdownId,
657
1477
  disableLabelAnimation: disableLabelAnimation,
658
1478
  isFilled: true
659
- }, React.createElement("select", Object.assign({
1479
+ }, React.createElement("select", _extends({
660
1480
  "aria-invalid": variant === 'error',
661
1481
  className: "eds-form-control eds-dropdown",
662
1482
  disabled: disabled || readOnly
@@ -668,6 +1488,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
668
1488
  })));
669
1489
  };
670
1490
 
1491
+ var _excluded = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
671
1492
  var MultiSelectContext = /*#__PURE__*/React.createContext(null);
672
1493
 
673
1494
  var useMultiSelectContext = function useMultiSelectContext() {
@@ -729,7 +1550,7 @@ var MultiSelect = function MultiSelect(_ref) {
729
1550
  _ref$initialSelectedI = _ref.initialSelectedItems,
730
1551
  initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
731
1552
  debounceTimeout = _ref.debounceTimeout,
732
- 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);
733
1554
 
734
1555
  var _useResolvedItems = useResolvedItems(input, debounceTimeout),
735
1556
  items = _useResolvedItems.items;
@@ -742,6 +1563,12 @@ var MultiSelect = function MultiSelect(_ref) {
742
1563
  setSelectedItems([]);
743
1564
  }, []);
744
1565
 
1566
+ function isSelected(selectedCheckboxItem) {
1567
+ return selectedItems.some(function (selected) {
1568
+ return selected.value === selectedCheckboxItem.value;
1569
+ });
1570
+ }
1571
+
745
1572
  var _useSelect = useSelect(_extends({
746
1573
  items: items,
747
1574
  stateReducer: stateReducer,
@@ -753,22 +1580,19 @@ var MultiSelect = function MultiSelect(_ref) {
753
1580
  return;
754
1581
  }
755
1582
 
756
- var index = selectedItems.indexOf(selectedItem);
1583
+ var itemIsFound = isSelected(selectedItem);
757
1584
 
758
- if (index > 0) {
759
- 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
+ });
760
1589
  setSelectedItems(slicedItemList);
761
1590
  onChange(slicedItemList);
762
- } else if (index === 0) {
763
- var _slicedItemList = [].concat(selectedItems.slice(1));
1591
+ } else {
1592
+ var _slicedItemList = [].concat(selectedItems, [selectedItem]);
764
1593
 
765
1594
  setSelectedItems(_slicedItemList);
766
1595
  onChange(_slicedItemList);
767
- } else {
768
- var _slicedItemList2 = [].concat(selectedItems, [selectedItem]);
769
-
770
- setSelectedItems(_slicedItemList2);
771
- onChange(_slicedItemList2);
772
1596
  }
773
1597
  }
774
1598
  }, rest)),
@@ -802,19 +1626,19 @@ var MultiSelect = function MultiSelect(_ref) {
802
1626
  isFilled: selectedItems.length > 0 || isOpen,
803
1627
  disabled: disabled,
804
1628
  readOnly: readOnly,
805
- append: React.createElement(Appendix$1, {
1629
+ append: React.createElement(Appendix, {
806
1630
  hasSelected: clearable && selectedItems.length > 0,
807
1631
  loading: loading,
808
1632
  loadingText: loadingText,
809
1633
  readOnly: readOnly
810
1634
  })
811
- }, React.createElement("button", Object.assign({}, getToggleButtonProps({
1635
+ }, React.createElement("button", _extends({}, getToggleButtonProps({
812
1636
  style: {
813
1637
  textAlign: 'left'
814
1638
  },
815
1639
  type: 'button',
816
1640
  className: 'eds-form-control eds-multiselect__button'
817
- })), buttonText)), React.createElement("ul", Object.assign({
1641
+ })), buttonText)), React.createElement("ul", _extends({
818
1642
  className: classNames('eds-dropdown-list', {
819
1643
  'eds-dropdown-list--open': isOpen
820
1644
  })
@@ -824,12 +1648,12 @@ var MultiSelect = function MultiSelect(_ref) {
824
1648
  top: space.extraLarge3 + space.extraSmall + "px"
825
1649
  }, listStyle)
826
1650
  })), isOpen && items.map(function (item, index) {
827
- return React.createElement("li", Object.assign({
1651
+ return React.createElement("li", _extends({
828
1652
  className: classNames('eds-dropdown-list__item', {
829
1653
  'eds-dropdown-list__item--highlighted': highlightedIndex === index,
830
- 'eds-dropdown-list__item--selected': selectedItems.includes(item)
1654
+ 'eds-dropdown-list__item--selected': isSelected(item)
831
1655
  }),
832
- key: "" + item + index
1656
+ key: "" + item.value + index
833
1657
  }, getItemProps({
834
1658
  item: item,
835
1659
  index: index
@@ -843,7 +1667,7 @@ var MultiSelect = function MultiSelect(_ref) {
843
1667
  }
844
1668
  }, React.createElement("span", {
845
1669
  className: classNames('eds-multiselect-checkbox', {
846
- 'eds-multiselect-checkbox--checked': selectedItems.includes(item)
1670
+ 'eds-multiselect-checkbox--checked': isSelected(item)
847
1671
  })
848
1672
  }, React.createElement(CheckboxIcon, null)), React.createElement("span", {
849
1673
  className: "eds-multiselect__item-label"
@@ -857,13 +1681,13 @@ var MultiSelect = function MultiSelect(_ref) {
857
1681
  }))));
858
1682
  };
859
1683
 
860
- var ClearButton$1 = function ClearButton(_ref3) {
1684
+ var ClearButton = function ClearButton(_ref3) {
861
1685
  var props = _extends({}, _ref3);
862
1686
 
863
1687
  var _useMultiSelectContex = useMultiSelectContext(),
864
1688
  reset = _useMultiSelectContex.reset;
865
1689
 
866
- return React.createElement(React.Fragment, null, React.createElement("button", Object.assign({
1690
+ return React.createElement(React.Fragment, null, React.createElement("button", _extends({
867
1691
  className: "eds-dropdown__clear-button",
868
1692
  type: "button",
869
1693
  tabIndex: -1,
@@ -875,7 +1699,7 @@ var ClearButton$1 = function ClearButton(_ref3) {
875
1699
  }));
876
1700
  };
877
1701
 
878
- var Appendix$1 = function Appendix(_ref4) {
1702
+ var Appendix = function Appendix(_ref4) {
879
1703
  var loading = _ref4.loading,
880
1704
  loadingText = _ref4.loadingText,
881
1705
  readOnly = _ref4.readOnly,
@@ -889,17 +1713,17 @@ var Appendix$1 = function Appendix(_ref4) {
889
1713
  return null;
890
1714
  }
891
1715
 
892
- 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);
893
1717
  };
894
1718
 
895
- var DropdownToggleButton$1 = function DropdownToggleButton() {
1719
+ var DropdownToggleButton = function DropdownToggleButton() {
896
1720
  var _useMultiSelectContex2 = useMultiSelectContext(),
897
1721
  getToggleButtonProps = _useMultiSelectContex2.getToggleButtonProps,
898
1722
  isOpen = _useMultiSelectContex2.isOpen,
899
1723
  openMenu = _useMultiSelectContex2.openMenu,
900
1724
  openOnFocus = _useMultiSelectContex2.openOnFocus;
901
1725
 
902
- return React.createElement("button", Object.assign({}, getToggleButtonProps({
1726
+ return React.createElement("button", _extends({}, getToggleButtonProps({
903
1727
  className: classNames('eds-dropdown__toggle-button', {
904
1728
  'eds-dropdown__toggle-button--open': isOpen
905
1729
  }),