@zendeskgarden/react-dropdowns.legacy 9.0.0-next.3

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.
Files changed (58) hide show
  1. package/LICENSE.md +176 -0
  2. package/README.md +100 -0
  3. package/dist/index.cjs.js +2082 -0
  4. package/dist/index.esm.js +2032 -0
  5. package/dist/typings/elements/Autocomplete/Autocomplete.d.ts +14 -0
  6. package/dist/typings/elements/Combobox/Combobox.d.ts +14 -0
  7. package/dist/typings/elements/Dropdown/Dropdown.d.ts +26 -0
  8. package/dist/typings/elements/Fields/Field.d.ts +11 -0
  9. package/dist/typings/elements/Fields/Hint.d.ts +11 -0
  10. package/dist/typings/elements/Fields/Label.d.ts +12 -0
  11. package/dist/typings/elements/Fields/Message.d.ts +12 -0
  12. package/dist/typings/elements/Menu/Items/AddItem.d.ts +12 -0
  13. package/dist/typings/elements/Menu/Items/HeaderIcon.d.ts +11 -0
  14. package/dist/typings/elements/Menu/Items/HeaderItem.d.ts +12 -0
  15. package/dist/typings/elements/Menu/Items/Item.d.ts +12 -0
  16. package/dist/typings/elements/Menu/Items/ItemMeta.d.ts +11 -0
  17. package/dist/typings/elements/Menu/Items/MediaBody.d.ts +11 -0
  18. package/dist/typings/elements/Menu/Items/MediaFigure.d.ts +11 -0
  19. package/dist/typings/elements/Menu/Items/MediaItem.d.ts +12 -0
  20. package/dist/typings/elements/Menu/Items/NextItem.d.ts +12 -0
  21. package/dist/typings/elements/Menu/Items/PreviousItem.d.ts +12 -0
  22. package/dist/typings/elements/Menu/Menu.d.ts +14 -0
  23. package/dist/typings/elements/Menu/Separator.d.ts +11 -0
  24. package/dist/typings/elements/Multiselect/Multiselect.d.ts +14 -0
  25. package/dist/typings/elements/Select/Select.d.ts +14 -0
  26. package/dist/typings/elements/Trigger/Trigger.d.ts +24 -0
  27. package/dist/typings/index.d.ts +31 -0
  28. package/dist/typings/styled/index.d.ts +29 -0
  29. package/dist/typings/styled/items/StyledAddItem.d.ts +13 -0
  30. package/dist/typings/styled/items/StyledItem.d.ts +20 -0
  31. package/dist/typings/styled/items/StyledItemIcon.d.ts +17 -0
  32. package/dist/typings/styled/items/StyledItemMeta.d.ts +18 -0
  33. package/dist/typings/styled/items/StyledNextIcon.d.ts +12 -0
  34. package/dist/typings/styled/items/StyledNextItem.d.ts +13 -0
  35. package/dist/typings/styled/items/StyledPreviousIcon.d.ts +12 -0
  36. package/dist/typings/styled/items/StyledPreviousItem.d.ts +13 -0
  37. package/dist/typings/styled/items/header/StyledHeaderIcon.d.ts +14 -0
  38. package/dist/typings/styled/items/header/StyledHeaderItem.d.ts +16 -0
  39. package/dist/typings/styled/items/media/StyledMediaBody.d.ts +17 -0
  40. package/dist/typings/styled/items/media/StyledMediaFigure.d.ts +287 -0
  41. package/dist/typings/styled/items/media/StyledMediaItem.d.ts +13 -0
  42. package/dist/typings/styled/menu/StyledMenu.d.ts +20 -0
  43. package/dist/typings/styled/menu/StyledMenuWrapper.d.ts +16 -0
  44. package/dist/typings/styled/menu/StyledSeparator.d.ts +10 -0
  45. package/dist/typings/styled/multiselect/StyledMultiselectInput.d.ts +22 -0
  46. package/dist/typings/styled/multiselect/StyledMultiselectItemWrapper.d.ts +10 -0
  47. package/dist/typings/styled/multiselect/StyledMultiselectItemsContainer.d.ts +16 -0
  48. package/dist/typings/styled/multiselect/StyledMultiselectMoreAnchor.d.ts +15 -0
  49. package/dist/typings/styled/select/StyledFauxInput.d.ts +22 -0
  50. package/dist/typings/styled/select/StyledInput.d.ts +15 -0
  51. package/dist/typings/styled/select/StyledSelect.d.ts +10 -0
  52. package/dist/typings/types/index.d.ts +150 -0
  53. package/dist/typings/utils/garden-placements.d.ts +26 -0
  54. package/dist/typings/utils/useDropdownContext.d.ts +28 -0
  55. package/dist/typings/utils/useFieldContext.d.ts +17 -0
  56. package/dist/typings/utils/useItemContext.d.ts +16 -0
  57. package/dist/typings/utils/useMenuContext.d.ts +17 -0
  58. package/package.json +56 -0
@@ -0,0 +1,2082 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var React = require('react');
11
+ var PropTypes = require('prop-types');
12
+ var styled = require('styled-components');
13
+ var Downshift = require('downshift');
14
+ var reactPopper = require('react-popper');
15
+ var containerUtilities = require('@zendeskgarden/container-utilities');
16
+ var reactTheming = require('@zendeskgarden/react-theming');
17
+ var polished = require('polished');
18
+ var reactForms = require('@zendeskgarden/react-forms');
19
+ var reactMergeRefs = require('react-merge-refs');
20
+ var containerSelection = require('@zendeskgarden/container-selection');
21
+ var reactDom = require('react-dom');
22
+
23
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
+
25
+ function _interopNamespace(e) {
26
+ if (e && e.__esModule) return e;
27
+ var n = Object.create(null);
28
+ if (e) {
29
+ Object.keys(e).forEach(function (k) {
30
+ if (k !== 'default') {
31
+ var d = Object.getOwnPropertyDescriptor(e, k);
32
+ Object.defineProperty(n, k, d.get ? d : {
33
+ enumerable: true,
34
+ get: function () { return e[k]; }
35
+ });
36
+ }
37
+ });
38
+ }
39
+ n.default = e;
40
+ return Object.freeze(n);
41
+ }
42
+
43
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
44
+ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
45
+ var styled__default = /*#__PURE__*/_interopDefault(styled);
46
+ var Downshift__default = /*#__PURE__*/_interopDefault(Downshift);
47
+
48
+ function _extends$5() {
49
+ _extends$5 = Object.assign ? Object.assign.bind() : function (target) {
50
+ for (var i = 1; i < arguments.length; i++) {
51
+ var source = arguments[i];
52
+ for (var key in source) {
53
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
54
+ target[key] = source[key];
55
+ }
56
+ }
57
+ }
58
+ return target;
59
+ };
60
+ return _extends$5.apply(this, arguments);
61
+ }
62
+
63
+ const DropdownContext = React__namespace.default.createContext(undefined);
64
+ const useDropdownContext = () => {
65
+ const dropdownContext = React.useContext(DropdownContext);
66
+ if (!dropdownContext) {
67
+ throw new Error('This component must be rendered within a `Dropdown` component.');
68
+ }
69
+ return dropdownContext;
70
+ };
71
+
72
+ const REMOVE_ITEM_STATE_TYPE = 'REMOVE_ITEM';
73
+ const Dropdown = props => {
74
+ const {
75
+ children,
76
+ isOpen,
77
+ selectedItem,
78
+ selectedItems,
79
+ highlightedIndex,
80
+ inputValue,
81
+ onSelect,
82
+ onStateChange,
83
+ onInputValueChange,
84
+ downshiftProps
85
+ } = props;
86
+ const itemIndexRef = React.useRef(0);
87
+ const previousItemRef = React.useRef(undefined);
88
+ const previousIndexRef = React.useRef(undefined);
89
+ const nextItemsHashRef = React.useRef({});
90
+ const containsMultiselectRef = React.useRef(false);
91
+ const itemSearchRegistry = React.useRef([]);
92
+ const [dropdownType, setDropdownType] = React.useState('');
93
+ const {
94
+ rtl
95
+ } = React.useContext(styled.ThemeContext);
96
+ const hasMenuRef = React.useRef(false);
97
+ const popperReferenceElementRef = React.useRef(null);
98
+ const customGetInputProps = (_ref, downshift) => {
99
+ let {
100
+ onKeyDown,
101
+ ...other
102
+ } = _ref;
103
+ return {
104
+ onKeyDown: containerUtilities.composeEventHandlers(onKeyDown, e => {
105
+ const PREVIOUS_KEY = rtl ? containerUtilities.KEY_CODES.RIGHT : containerUtilities.KEY_CODES.LEFT;
106
+ const NEXT_KEY = rtl ? containerUtilities.KEY_CODES.LEFT : containerUtilities.KEY_CODES.RIGHT;
107
+ if (downshift.isOpen) {
108
+ if (e.keyCode === PREVIOUS_KEY && previousIndexRef.current !== null && previousIndexRef.current !== undefined && !downshift.inputValue) {
109
+ e.preventDefault();
110
+ e.stopPropagation();
111
+ downshift.selectItemAtIndex(previousIndexRef.current);
112
+ }
113
+ if (e.keyCode === NEXT_KEY) {
114
+ const nextItemIndexes = Object.values(nextItemsHashRef.current);
115
+ if (nextItemIndexes.includes(downshift.highlightedIndex)) {
116
+ e.preventDefault();
117
+ e.stopPropagation();
118
+ downshift.selectItemAtIndex(downshift.highlightedIndex);
119
+ }
120
+ }
121
+ } else if ((e.keyCode === containerUtilities.KEY_CODES.ENTER || e.keyCode === containerUtilities.KEY_CODES.SPACE) && !downshift.isOpen && dropdownType !== 'combobox') {
122
+ e.preventDefault();
123
+ e.stopPropagation();
124
+ downshift.openMenu();
125
+ }
126
+ }),
127
+ ...other
128
+ };
129
+ };
130
+ const transformDownshift = _ref2 => {
131
+ let {
132
+ getInputProps,
133
+ getToggleButtonProps,
134
+ ...downshift
135
+ } = _ref2;
136
+ return {
137
+ getInputProps: p => getInputProps(customGetInputProps(p, downshift)),
138
+ getToggleButtonProps: p => getToggleButtonProps({
139
+ 'aria-label': undefined,
140
+ ...p
141
+ }),
142
+ ...downshift
143
+ };
144
+ };
145
+ return React__namespace.default.createElement(reactPopper.Manager, null, React__namespace.default.createElement(Downshift__default.default, _extends$5({
146
+ suppressRefError: true
147
+ ,
148
+ isOpen: isOpen,
149
+ highlightedIndex: highlightedIndex,
150
+ selectedItem: selectedItem || null
151
+ ,
152
+ inputValue: inputValue,
153
+ onInputValueChange: (inputVal, stateAndHelpers) => {
154
+ if (onInputValueChange) {
155
+ if (stateAndHelpers.isOpen) {
156
+ onInputValueChange(inputVal, stateAndHelpers);
157
+ } else if (dropdownType === 'multiselect') {
158
+ onInputValueChange('', stateAndHelpers);
159
+ }
160
+ }
161
+ },
162
+ onStateChange: (changes, stateAndHelpers) => {
163
+ if (dropdownType === 'autocomplete' && changes.isOpen === false && !changes.selectedItem) {
164
+ onSelect && onSelect(selectedItem, stateAndHelpers);
165
+ }
166
+ if (Object.prototype.hasOwnProperty.call(changes, 'selectedItem') && changes.selectedItem !== null) {
167
+ if (selectedItems) {
168
+ const {
169
+ itemToString
170
+ } = stateAndHelpers;
171
+ const existingItemIndex = selectedItems.findIndex(item => {
172
+ return itemToString(item) === itemToString(changes.selectedItem);
173
+ });
174
+ const updatedSelectedItems = Array.from(selectedItems);
175
+ if (existingItemIndex === -1) {
176
+ updatedSelectedItems.splice(updatedSelectedItems.length, 0, changes.selectedItem);
177
+ } else {
178
+ updatedSelectedItems.splice(existingItemIndex, 1);
179
+ }
180
+ changes.selectedItems = updatedSelectedItems;
181
+ delete changes.selectedItem;
182
+ onSelect && onSelect(updatedSelectedItems, stateAndHelpers);
183
+ } else {
184
+ onSelect && onSelect(changes.selectedItem, stateAndHelpers);
185
+ }
186
+ if (dropdownType === 'multiselect') {
187
+ stateAndHelpers.setState({
188
+ inputValue: ''
189
+ });
190
+ }
191
+ }
192
+ onStateChange && onStateChange(changes, stateAndHelpers);
193
+ },
194
+ stateReducer: (_state, changes) => {
195
+ switch (changes.type) {
196
+ case Downshift__default.default.stateChangeTypes.changeInput:
197
+ if (changes.inputValue === '' && dropdownType === 'combobox') {
198
+ return {
199
+ ...changes,
200
+ isOpen: false
201
+ };
202
+ }
203
+ return changes;
204
+ default:
205
+ return changes;
206
+ }
207
+ }
208
+ }, downshiftProps), downshift => React__namespace.default.createElement(DropdownContext.Provider, {
209
+ value: {
210
+ hasMenuRef,
211
+ itemIndexRef,
212
+ previousItemRef,
213
+ previousIndexRef,
214
+ nextItemsHashRef,
215
+ popperReferenceElementRef,
216
+ selectedItems,
217
+ downshift: transformDownshift(downshift),
218
+ containsMultiselectRef,
219
+ itemSearchRegistry,
220
+ setDropdownType
221
+ }
222
+ }, children)));
223
+ };
224
+ Dropdown.propTypes = {
225
+ isOpen: PropTypes__default.default.bool,
226
+ selectedItem: PropTypes__default.default.any,
227
+ selectedItems: PropTypes__default.default.arrayOf(PropTypes__default.default.any),
228
+ highlightedIndex: PropTypes__default.default.number,
229
+ inputValue: PropTypes__default.default.string,
230
+ onSelect: PropTypes__default.default.func,
231
+ onStateChange: PropTypes__default.default.func,
232
+ downshiftProps: PropTypes__default.default.object
233
+ };
234
+
235
+ function getPopperPlacement(gardenPlacement) {
236
+ switch (gardenPlacement) {
237
+ case 'end':
238
+ return 'right';
239
+ case 'end-top':
240
+ return 'right-start';
241
+ case 'end-bottom':
242
+ return 'right-end';
243
+ case 'start':
244
+ return 'left';
245
+ case 'start-top':
246
+ return 'left-start';
247
+ case 'start-bottom':
248
+ return 'left-end';
249
+ default:
250
+ return gardenPlacement;
251
+ }
252
+ }
253
+ function getRtlPopperPlacement(gardenPlacement) {
254
+ const popperPlacement = getPopperPlacement(gardenPlacement);
255
+ switch (popperPlacement) {
256
+ case 'left':
257
+ return 'right';
258
+ case 'left-start':
259
+ return 'right-start';
260
+ case 'left-end':
261
+ return 'right-end';
262
+ case 'top-start':
263
+ return 'top-end';
264
+ case 'top-end':
265
+ return 'top-start';
266
+ case 'right':
267
+ return 'left';
268
+ case 'right-start':
269
+ return 'left-start';
270
+ case 'right-end':
271
+ return 'left-end';
272
+ case 'bottom-start':
273
+ return 'bottom-end';
274
+ case 'bottom-end':
275
+ return 'bottom-start';
276
+ default:
277
+ return popperPlacement;
278
+ }
279
+ }
280
+ function getArrowPosition(popperPlacement) {
281
+ const arrowPositionMappings = {
282
+ auto: 'top',
283
+ top: 'bottom',
284
+ 'top-start': 'bottom-left',
285
+ 'top-end': 'bottom-right',
286
+ right: 'left',
287
+ 'right-start': 'left-top',
288
+ 'right-end': 'left-bottom',
289
+ bottom: 'top',
290
+ 'bottom-start': 'top-left',
291
+ 'bottom-end': 'top-right',
292
+ left: 'right',
293
+ 'left-start': 'right-top',
294
+ 'left-end': 'right-bottom'
295
+ };
296
+ return popperPlacement ? arrowPositionMappings[popperPlacement] : 'top';
297
+ }
298
+ function getMenuPosition(popperPlacement) {
299
+ if (popperPlacement === 'auto') {
300
+ return 'bottom';
301
+ }
302
+ return popperPlacement ? popperPlacement.split('-')[0] : 'bottom';
303
+ }
304
+
305
+ const COMPONENT_ID$m = 'dropdowns.menu';
306
+ const StyledMenu = styled__default.default.ul.attrs(props => ({
307
+ 'data-garden-id': COMPONENT_ID$m,
308
+ 'data-garden-version': '9.0.0-next.3',
309
+ className: props.isAnimated && 'is-animated'
310
+ })).withConfig({
311
+ displayName: "StyledMenu",
312
+ componentId: "sc-lzt5u6-0"
313
+ })(["position:static !important;max-height:", ";overflow-y:auto;", ";", ";"], props => props.maxHeight, props => props.hasArrow && reactTheming.arrowStyles(getArrowPosition(props.placement), {
314
+ size: `${props.theme.space.base * 2}px`,
315
+ inset: '2px',
316
+ animationModifier: props.isAnimated ? '.is-animated' : undefined
317
+ }), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$m, props));
318
+ StyledMenu.defaultProps = {
319
+ theme: reactTheming.DEFAULT_THEME
320
+ };
321
+
322
+ const COMPONENT_ID$l = 'dropdowns.menu_wrapper';
323
+ const StyledMenuWrapper = styled__default.default.div.attrs(props => ({
324
+ 'data-garden-id': COMPONENT_ID$l,
325
+ 'data-garden-version': '9.0.0-next.3',
326
+ className: props.isAnimated && 'is-animated'
327
+ })).withConfig({
328
+ displayName: "StyledMenuWrapper",
329
+ componentId: "sc-u70fn3-0"
330
+ })(["", ";", ";"], props => reactTheming.menuStyles(getMenuPosition(props.placement), {
331
+ theme: props.theme,
332
+ hidden: props.isHidden,
333
+ margin: `${props.theme.space.base * (props.hasArrow ? 2 : 1)}px`,
334
+ zIndex: props.zIndex,
335
+ animationModifier: props.isAnimated ? '.is-animated' : undefined
336
+ }), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$l, props));
337
+ StyledMenuWrapper.defaultProps = {
338
+ theme: reactTheming.DEFAULT_THEME
339
+ };
340
+
341
+ const COMPONENT_ID$k = 'dropdowns.separator';
342
+ const StyledSeparator = styled__default.default.li.attrs({
343
+ 'data-garden-id': COMPONENT_ID$k,
344
+ 'data-garden-version': '9.0.0-next.3',
345
+ role: 'separator'
346
+ }).withConfig({
347
+ displayName: "StyledSeparator",
348
+ componentId: "sc-oncsf0-0"
349
+ })(["display:block;margin:", "px 0;border-bottom:", ";", ";"], props => props.theme.space.base, props => `${props.theme.borders.sm} ${reactTheming.getColor('neutralHue', 200, props.theme)}`, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$k, props));
350
+ StyledSeparator.defaultProps = {
351
+ theme: reactTheming.DEFAULT_THEME
352
+ };
353
+
354
+ const COMPONENT_ID$j = 'dropdowns.item';
355
+ const getItemPaddingVertical = props => {
356
+ if (props.isCompact) {
357
+ return `${props.theme.space.base}px`;
358
+ }
359
+ return `${props.theme.space.base * 2}px`;
360
+ };
361
+ const getColorStyles = props => {
362
+ let foregroundColor;
363
+ let backgroundColor;
364
+ if (props.disabled) {
365
+ foregroundColor = reactTheming.getColor('neutralHue', 400, props.theme);
366
+ } else if (props.isDanger) {
367
+ foregroundColor = reactTheming.getColor('dangerHue', 600, props.theme);
368
+ backgroundColor = props.isFocused ? polished.rgba(foregroundColor, 0.08) : 'inherit';
369
+ } else {
370
+ foregroundColor = props.theme.colors.foreground;
371
+ backgroundColor = props.isFocused ? reactTheming.getColor('primaryHue', 600, props.theme, 0.08) : 'inherit';
372
+ }
373
+ return styled.css(["background-color:", ";color:", ";& a,& a:hover,& a:focus,& a:active{color:inherit;}"], backgroundColor, foregroundColor);
374
+ };
375
+ const StyledItem = styled__default.default.li.attrs(props => ({
376
+ 'data-garden-id': COMPONENT_ID$j,
377
+ 'data-garden-version': '9.0.0-next.3',
378
+ 'aria-disabled': props.disabled
379
+ })).withConfig({
380
+ displayName: "StyledItem",
381
+ componentId: "sc-x4h8aw-0"
382
+ })(["display:block;position:relative;z-index:0;cursor:", ";padding:", " ", "px;text-decoration:none;line-height:", "px;word-wrap:break-word;user-select:none;&:first-child{margin-top:", "px;}&:last-child{margin-bottom:", "px;}&:focus{outline:none;}& a,& a:hover,& a:focus,& a:active{text-decoration:none;}", ";", ";"], props => props.disabled ? 'default' : 'pointer', props => getItemPaddingVertical(props), props => props.theme.space.base * 9, props => props.theme.space.base * 5, props => props.theme.space.base, props => props.theme.space.base, props => getColorStyles(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$j, props));
383
+ StyledItem.defaultProps = {
384
+ theme: reactTheming.DEFAULT_THEME
385
+ };
386
+
387
+ const COMPONENT_ID$i = 'dropdowns.add_item';
388
+ const StyledAddItem = styled__default.default(StyledItem).attrs({
389
+ 'data-garden-id': COMPONENT_ID$i,
390
+ 'data-garden-version': '9.0.0-next.3'
391
+ }).withConfig({
392
+ displayName: "StyledAddItem",
393
+ componentId: "sc-mlto71-0"
394
+ })(["color:", ";", ";"], props => !props.disabled && reactTheming.getColor('primaryHue', 600, props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$i, props));
395
+ StyledAddItem.defaultProps = {
396
+ theme: reactTheming.DEFAULT_THEME
397
+ };
398
+
399
+ const COMPONENT_ID$h = 'dropdowns.item_meta';
400
+ const StyledItemMeta = styled__default.default.span.attrs({
401
+ 'data-garden-id': COMPONENT_ID$h,
402
+ 'data-garden-version': '9.0.0-next.3'
403
+ }).withConfig({
404
+ displayName: "StyledItemMeta",
405
+ componentId: "sc-1m3x8m1-0"
406
+ })(["display:block;line-height:", "px;color:", ";font-size:", ";", ";"], props => props.theme.space.base * (props.isCompact ? 3 : 4), props => reactTheming.getColor('neutralHue', props.isDisabled ? 400 : 600, props.theme), props => props.theme.fontSizes.sm, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$h, props));
407
+ StyledItemMeta.defaultProps = {
408
+ theme: reactTheming.DEFAULT_THEME
409
+ };
410
+
411
+ const COMPONENT_ID$g = 'dropdowns.item_icon';
412
+ const getSizeStyles = props => {
413
+ return styled.css(["width:", ";height:calc(", "px + ", ");"], props.theme.iconSizes.md, props.theme.space.base * 5, polished.math(`${getItemPaddingVertical(props)} * 2`));
414
+ };
415
+ const StyledItemIcon = styled__default.default.div.attrs({
416
+ 'data-garden-id': COMPONENT_ID$g,
417
+ 'data-garden-version': '9.0.0-next.3'
418
+ }).withConfig({
419
+ displayName: "StyledItemIcon",
420
+ componentId: "sc-pspm80-0"
421
+ })(["display:flex;position:absolute;top:0;", ":", "px;align-items:center;justify-content:center;transition:opacity 0.1s ease-in-out;opacity:", ";color:", ";", ";& > *{width:", ";height:", ";}"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 3, props => props.isVisible ? '1' : '0', props => props.isDisabled ? 'inherit' : reactTheming.getColor('primaryHue', 600, props.theme), props => getSizeStyles(props), props => props.theme.iconSizes.md, props => props.theme.iconSizes.md);
422
+ StyledItemIcon.defaultProps = {
423
+ theme: reactTheming.DEFAULT_THEME
424
+ };
425
+
426
+ const COMPONENT_ID$f = 'dropdowns.next_item';
427
+ const StyledNextItem = styled__default.default(StyledItem).attrs({
428
+ 'data-garden-id': COMPONENT_ID$f,
429
+ 'data-garden-version': '9.0.0-next.3'
430
+ }).withConfig({
431
+ displayName: "StyledNextItem",
432
+ componentId: "sc-1wrjlge-0"
433
+ })(["", "{right:", ";left:", ";}", ";"], StyledItemIcon, props => props.theme.rtl ? 'auto' : `${props.theme.space.base * 3}px`, props => props.theme.rtl ? `${props.theme.space.base * 3}px` : 'auto', props => reactTheming.retrieveComponentStyles(COMPONENT_ID$f, props));
434
+ StyledNextItem.defaultProps = {
435
+ theme: reactTheming.DEFAULT_THEME
436
+ };
437
+
438
+ var _path$4;
439
+ function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
440
+ var SvgChevronRightStroke = function SvgChevronRightStroke(props) {
441
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$4({
442
+ xmlns: "http://www.w3.org/2000/svg",
443
+ width: 16,
444
+ height: 16,
445
+ focusable: "false",
446
+ viewBox: "0 0 16 16",
447
+ "aria-hidden": "true"
448
+ }, props), _path$4 || (_path$4 = /*#__PURE__*/React__namespace.createElement("path", {
449
+ fill: "currentColor",
450
+ d: "M5.61 3.312a.5.5 0 01.718-.69l.062.066 4 5a.5.5 0 01.054.542l-.054.082-4 5a.5.5 0 01-.83-.55l.05-.074L9.359 8l-3.75-4.688z"
451
+ })));
452
+ };
453
+
454
+ const COMPONENT_ID$e = 'dropdowns.next_item_icon';
455
+ const NextIconComponent = _ref => {
456
+ let {
457
+ className
458
+ } = _ref;
459
+ return React__namespace.default.createElement(SvgChevronRightStroke, {
460
+ "data-garden-id": COMPONENT_ID$e,
461
+ "data-garden-version": '9.0.0-next.3',
462
+ className: className
463
+ });
464
+ };
465
+ const StyledNextIcon = styled__default.default(NextIconComponent).withConfig({
466
+ displayName: "StyledNextIcon",
467
+ componentId: "sc-1nzkdnq-0"
468
+ })(["transform:", ";color:", ";", ";"], props => props.theme.rtl && 'rotate(180deg)', props => props.isDisabled ? 'inherit' : reactTheming.getColor('neutralHue', 600, props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$e, props));
469
+ StyledNextIcon.defaultProps = {
470
+ theme: reactTheming.DEFAULT_THEME
471
+ };
472
+
473
+ const COMPONENT_ID$d = 'dropdowns.previous_item';
474
+ const StyledPreviousItem = styled__default.default(StyledItem).attrs({
475
+ 'data-garden-id': COMPONENT_ID$d,
476
+ 'data-garden-version': '9.0.0-next.3'
477
+ }).withConfig({
478
+ displayName: "StyledPreviousItem",
479
+ componentId: "sc-1qv9jwe-0"
480
+ })(["font-weight:", ";", ";"], props => props.theme.fontWeights.semibold, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$d, props));
481
+ StyledPreviousItem.defaultProps = {
482
+ theme: reactTheming.DEFAULT_THEME
483
+ };
484
+
485
+ var _path$3;
486
+ function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
487
+ var SvgChevronLeftStroke = function SvgChevronLeftStroke(props) {
488
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$3({
489
+ xmlns: "http://www.w3.org/2000/svg",
490
+ width: 16,
491
+ height: 16,
492
+ focusable: "false",
493
+ viewBox: "0 0 16 16",
494
+ "aria-hidden": "true"
495
+ }, props), _path$3 || (_path$3 = /*#__PURE__*/React__namespace.createElement("path", {
496
+ fill: "currentColor",
497
+ d: "M10.39 12.688a.5.5 0 01-.718.69l-.062-.066-4-5a.5.5 0 01-.054-.542l.054-.082 4-5a.5.5 0 01.83.55l-.05.074L6.641 8l3.75 4.688z"
498
+ })));
499
+ };
500
+
501
+ const COMPONENT_ID$c = 'dropdowns.previous_item_icon';
502
+ const PreviousIconComponent = _ref => {
503
+ let {
504
+ className
505
+ } = _ref;
506
+ return React__namespace.default.createElement(SvgChevronLeftStroke, {
507
+ "data-garden-id": COMPONENT_ID$c,
508
+ "data-garden-version": '9.0.0-next.3',
509
+ className: className
510
+ });
511
+ };
512
+ const StyledPreviousIcon = styled__default.default(PreviousIconComponent).withConfig({
513
+ displayName: "StyledPreviousIcon",
514
+ componentId: "sc-1n1t07s-0"
515
+ })(["transform:", ";color:", ";", ";"], props => props.theme.rtl && 'rotate(180deg)', props => props.isDisabled ? 'inherit' : reactTheming.getColor('neutralHue', 600, props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$c, props));
516
+ StyledPreviousIcon.defaultProps = {
517
+ theme: reactTheming.DEFAULT_THEME
518
+ };
519
+
520
+ const COMPONENT_ID$b = 'dropdowns.header_icon';
521
+ const StyledHeaderIcon = styled__default.default.div.attrs({
522
+ 'data-garden-id': COMPONENT_ID$b,
523
+ 'data-garden-version': '9.0.0-next.3'
524
+ }).withConfig({
525
+ displayName: "StyledHeaderIcon",
526
+ componentId: "sc-ow8s45-0"
527
+ })(["display:flex;position:absolute;top:0;bottom:0;align-items:center;justify-content:center;", ":", "px;color:", ";& > *{width:", ";height:", ";}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 3, props => reactTheming.getColor('neutralHue', 600, props.theme), props => props.theme.iconSizes.md, props => props.theme.iconSizes.md, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$b, props));
528
+ StyledHeaderIcon.defaultProps = {
529
+ theme: reactTheming.DEFAULT_THEME
530
+ };
531
+
532
+ const COMPONENT_ID$a = 'dropdowns.header_item';
533
+ const getHorizontalPadding = props => {
534
+ if (props.hasIcon) {
535
+ return undefined;
536
+ }
537
+ return `${props.theme.space.base * 3}px`;
538
+ };
539
+ const StyledHeaderItem = styled__default.default(StyledItem).attrs({
540
+ 'data-garden-id': COMPONENT_ID$a,
541
+ 'data-garden-version': '9.0.0-next.3'
542
+ }).withConfig({
543
+ displayName: "StyledHeaderItem",
544
+ componentId: "sc-1xosinr-0"
545
+ })(["cursor:default;padding-right:", ";padding-left:", ";font-weight:", ";", ";"], props => getHorizontalPadding(props), props => getHorizontalPadding(props), props => props.theme.fontWeights.semibold, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$a, props));
546
+ StyledHeaderItem.defaultProps = {
547
+ theme: reactTheming.DEFAULT_THEME
548
+ };
549
+
550
+ const COMPONENT_ID$9 = 'dropdowns.media_body';
551
+ const StyledMediaBody = styled__default.default.div.attrs({
552
+ 'data-garden-id': COMPONENT_ID$9,
553
+ 'data-garden-version': '9.0.0-next.3'
554
+ }).withConfig({
555
+ displayName: "StyledMediaBody",
556
+ componentId: "sc-133sssc-0"
557
+ })(["display:block;overflow:hidden;padding-", ":", "px;", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$9, props));
558
+ StyledMediaBody.defaultProps = {
559
+ theme: reactTheming.DEFAULT_THEME
560
+ };
561
+
562
+ const COMPONENT_ID$8 = 'dropdowns.media_figure';
563
+ const StyledMediaFigure = styled__default.default(
564
+ _ref => {
565
+ let {
566
+ children,
567
+ isCompact,
568
+ theme,
569
+ ...props
570
+ } = _ref;
571
+ return (
572
+ React__namespace.default.cloneElement(React.Children.only(children), props)
573
+ );
574
+ }).attrs({
575
+ 'data-garden-id': COMPONENT_ID$8,
576
+ 'data-garden-version': '9.0.0-next.3'
577
+ }).withConfig({
578
+ displayName: "StyledMediaFigure",
579
+ componentId: "sc-16vz3xj-0"
580
+ })(["float:", ";margin-top:", "px !important;width:", ";height:", ";", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 0.5, props => props.theme.iconSizes.md, props => props.theme.iconSizes.md, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$8, props));
581
+ StyledMediaFigure.defaultProps = {
582
+ theme: reactTheming.DEFAULT_THEME
583
+ };
584
+
585
+ const COMPONENT_ID$7 = 'dropdowns.media_item';
586
+ const StyledMediaItem = styled__default.default(StyledItem).attrs({
587
+ 'data-garden-id': COMPONENT_ID$7,
588
+ 'data-garden-version': '9.0.0-next.3'
589
+ }).withConfig({
590
+ displayName: "StyledMediaItem",
591
+ componentId: "sc-af4509-0"
592
+ })(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$7, props));
593
+ StyledMediaItem.defaultProps = {
594
+ theme: reactTheming.DEFAULT_THEME
595
+ };
596
+
597
+ const COMPONENT_ID$6 = 'dropdowns.faux_input';
598
+ const StyledFauxInput = styled__default.default(reactForms.FauxInput).attrs(props => ({
599
+ 'data-garden-id': COMPONENT_ID$6,
600
+ 'data-garden-version': '9.0.0-next.3',
601
+ mediaLayout: true,
602
+ theme: props.theme
603
+ })).withConfig({
604
+ displayName: "StyledFauxInput",
605
+ componentId: "sc-bk8odf-0"
606
+ })(["cursor:", ";min-width:", "px;", ";"], props => !props.disabled && 'pointer', props => props.theme.space.base * (props.isCompact ? 25 : 36), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props));
607
+ StyledFauxInput.defaultProps = {
608
+ theme: reactTheming.DEFAULT_THEME
609
+ };
610
+
611
+ const COMPONENT_ID$5 = 'dropdowns.input';
612
+ const hiddenStyling = styled.css(["position:fixed;border:0;clip:rect(1px,1px,1px,1px);padding:0;width:1px;height:1px;overflow:hidden;white-space:nowrap;"]);
613
+ const StyledInput = styled__default.default(reactForms.Input).attrs({
614
+ 'data-garden-id': COMPONENT_ID$5,
615
+ 'data-garden-version': '9.0.0-next.3',
616
+ isBare: true
617
+ }).withConfig({
618
+ displayName: "StyledInput",
619
+ componentId: "sc-kykaw8-0"
620
+ })(["", ";", ";"], props => props.isHidden && hiddenStyling, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props));
621
+ StyledInput.defaultProps = {
622
+ theme: reactTheming.DEFAULT_THEME
623
+ };
624
+
625
+ const COMPONENT_ID$4 = 'dropdowns.select';
626
+ const StyledSelect = styled__default.default.div.attrs({
627
+ 'data-garden-id': COMPONENT_ID$4,
628
+ 'data-garden-version': '9.0.0-next.3'
629
+ }).withConfig({
630
+ displayName: "StyledSelect",
631
+ componentId: "sc-xf4qjv-0"
632
+ })(["flex-grow:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
633
+ StyledSelect.defaultProps = {
634
+ theme: reactTheming.DEFAULT_THEME
635
+ };
636
+
637
+ const COMPONENT_ID$3 = 'dropdowns.multiselect_input';
638
+ const visibleStyling = props => {
639
+ const margin = props.isVisible ? `${props.theme.space.base / 2}px` : 0;
640
+ const minWidth = props.isVisible ? `${props.theme.space.base * 15}px` : 0;
641
+ let height = '0';
642
+ if (props.isVisible) {
643
+ height = `${props.theme.space.base * (props.isCompact ? 5 : 8)}px`;
644
+ }
645
+ return styled.css(["opacity:", ";margin:", ";width:", ";min-width:", ";height:", ";"], !props.isVisible && 0, margin, !props.isVisible && 0, minWidth, height);
646
+ };
647
+ const StyledMultiselectInput = styled__default.default(StyledInput).attrs({
648
+ 'data-garden-id': COMPONENT_ID$3,
649
+ 'data-garden-version': '9.0.0-next.3',
650
+ isBare: true
651
+ }).withConfig({
652
+ displayName: "StyledMultiselectInput",
653
+ componentId: "sc-iiow29-0"
654
+ })(["flex-basis:", "px;flex-grow:1;align-self:center;min-height:0;", ";", ";"], props => props.theme.space.base * 15, props => visibleStyling(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
655
+ StyledMultiselectInput.defaultProps = {
656
+ theme: reactTheming.DEFAULT_THEME
657
+ };
658
+
659
+ const COMPONENT_ID$2 = 'dropdowns.multiselect_items_container';
660
+ const sizeStyles = props => {
661
+ let margin;
662
+ let padding;
663
+ if (!props.isBare) {
664
+ const marginVertical = props.isCompact ? `-${props.theme.space.base * 1.5}px` : `-${props.theme.space.base * 2.5}px`;
665
+ margin = `${marginVertical} 0`;
666
+ const paddingVertical = props.isCompact ? '3px' : '1px';
667
+ const paddingEnd = `${props.theme.space.base}px`;
668
+ padding = `${paddingVertical} ${props.theme.rtl ? 0 : paddingEnd} ${paddingVertical} ${props.theme.rtl ? paddingEnd : 0}`;
669
+ }
670
+ return styled.css(["margin:", ";padding:", ";"], margin, padding);
671
+ };
672
+ const StyledMultiselectItemsContainer = styled__default.default.div.attrs({
673
+ 'data-garden-id': COMPONENT_ID$2,
674
+ 'data-garden-version': '9.0.0-next.3'
675
+ }).withConfig({
676
+ displayName: "StyledMultiselectItemsContainer",
677
+ componentId: "sc-1dxwjyz-0"
678
+ })(["display:inline-flex;flex-grow:1;flex-wrap:wrap;min-width:0;", ";", ";"], props => sizeStyles(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
679
+ StyledMultiselectItemsContainer.defaultProps = {
680
+ theme: reactTheming.DEFAULT_THEME
681
+ };
682
+
683
+ const COMPONENT_ID$1 = 'dropdowns.multiselect_item_wrapper';
684
+ const StyledMultiselectItemWrapper = styled__default.default.div.attrs({
685
+ 'data-garden-id': COMPONENT_ID$1,
686
+ 'data-garden-version': '9.0.0-next.3'
687
+ }).withConfig({
688
+ displayName: "StyledMultiselectItemWrapper",
689
+ componentId: "sc-vgr7nd-0"
690
+ })(["display:inline-flex;align-items:center;margin:", "px;max-width:100%;", ";"], props => props.theme.space.base / 2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
691
+ StyledMultiselectItemWrapper.defaultProps = {
692
+ theme: reactTheming.DEFAULT_THEME
693
+ };
694
+
695
+ const COMPONENT_ID = 'dropdowns.multiselect_more_anchor';
696
+ const StyledMultiselectMoreAnchor = styled__default.default.div.attrs({
697
+ 'data-garden-id': COMPONENT_ID,
698
+ 'data-garden-version': '9.0.0-next.3'
699
+ }).withConfig({
700
+ displayName: "StyledMultiselectMoreAnchor",
701
+ componentId: "sc-pkakky-0"
702
+ })(["display:inline-block;cursor:", ";padding:", "px 0;overflow:hidden;user-select:none;text-overflow:ellipsis;line-height:", ";white-space:nowrap;color:", ";:hover{text-decoration:", ";}", ";"], props => props.isDisabled ? 'default' : 'pointer', props => props.theme.space.base * (props.isCompact ? 0.75 : 1.5), props => props.isCompact ? '1em' : reactTheming.getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md), props => props.isDisabled ? reactTheming.getColor('neutralHue', 400, props.theme) : reactTheming.getColor('primaryHue', 600, props.theme), props => !props.isDisabled && 'underline', props => reactTheming.retrieveComponentStyles(COMPONENT_ID, props));
703
+ StyledMultiselectMoreAnchor.defaultProps = {
704
+ theme: reactTheming.DEFAULT_THEME
705
+ };
706
+
707
+ const Trigger = _ref => {
708
+ let {
709
+ children,
710
+ refKey,
711
+ ...triggerProps
712
+ } = _ref;
713
+ const {
714
+ hasMenuRef,
715
+ itemSearchRegistry,
716
+ downshift: {
717
+ getRootProps,
718
+ getToggleButtonProps,
719
+ getInputProps,
720
+ isOpen,
721
+ highlightedIndex,
722
+ selectItemAtIndex,
723
+ setHighlightedIndex
724
+ }
725
+ } = useDropdownContext();
726
+ const hiddenInputRef = React.useRef(null);
727
+ const triggerRef = React.useRef(null);
728
+ const previousIsOpenRef = React.useRef(undefined);
729
+ const [searchString, setSearchString] = React.useState('');
730
+ const searchTimeoutRef = React.useRef();
731
+ const currentSearchIndexRef = React.useRef(0);
732
+ React.useEffect(() => {
733
+ if (hiddenInputRef.current && isOpen && !previousIsOpenRef.current) {
734
+ hiddenInputRef.current.focus();
735
+ }
736
+ if (triggerRef.current && !isOpen && previousIsOpenRef.current) {
737
+ triggerRef.current.focus();
738
+ }
739
+ previousIsOpenRef.current = isOpen;
740
+ }, [isOpen, hasMenuRef]);
741
+ React.useEffect(() => {
742
+ if (hasMenuRef.current === false) {
743
+ hasMenuRef.current = true;
744
+ }
745
+ }, [hasMenuRef]);
746
+ React.useEffect(() => {
747
+ if (searchTimeoutRef.current) {
748
+ clearTimeout(searchTimeoutRef.current);
749
+ }
750
+ searchTimeoutRef.current = window.setTimeout(() => {
751
+ setSearchString('');
752
+ }, 500);
753
+ return () => {
754
+ clearTimeout(searchTimeoutRef.current);
755
+ };
756
+ }, [searchString]);
757
+ const searchItems = React.useCallback((searchValue, startIndex, endIndex) => {
758
+ for (let index = startIndex; index < endIndex; index++) {
759
+ const itemTextValue = itemSearchRegistry.current[index];
760
+ if (itemTextValue && itemTextValue.toUpperCase().indexOf(searchValue.toUpperCase()) === 0) {
761
+ return index;
762
+ }
763
+ }
764
+ return undefined;
765
+ }, [itemSearchRegistry]);
766
+ const onInputKeyDown = React.useCallback(e => {
767
+ if (e.keyCode === containerUtilities.KEY_CODES.SPACE) {
768
+ if (searchString) {
769
+ e.preventDefault();
770
+ e.stopPropagation();
771
+ } else if (highlightedIndex !== null && highlightedIndex !== undefined) {
772
+ e.preventDefault();
773
+ e.stopPropagation();
774
+ selectItemAtIndex(highlightedIndex);
775
+ }
776
+ }
777
+ if ((e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 65 || e.keyCode > 90) && e.keyCode !== containerUtilities.KEY_CODES.SPACE) {
778
+ return;
779
+ }
780
+ const character = String.fromCharCode(e.which || e.keyCode);
781
+ if (!character || character.length === 0) {
782
+ return;
783
+ }
784
+ if (!searchString) {
785
+ if (highlightedIndex === null || highlightedIndex === undefined) {
786
+ currentSearchIndexRef.current = -1;
787
+ } else {
788
+ currentSearchIndexRef.current = highlightedIndex;
789
+ }
790
+ }
791
+ const newSearchString = searchString + character;
792
+ setSearchString(newSearchString);
793
+ let matchingIndex = searchItems(newSearchString, currentSearchIndexRef.current + 1, itemSearchRegistry.current.length);
794
+ if (matchingIndex === undefined) {
795
+ matchingIndex = searchItems(newSearchString, 0, currentSearchIndexRef.current);
796
+ }
797
+ if (matchingIndex !== undefined) {
798
+ setHighlightedIndex(matchingIndex);
799
+ }
800
+ }, [searchString, searchItems, itemSearchRegistry, highlightedIndex, selectItemAtIndex, setHighlightedIndex]);
801
+ const renderChildren = popperRef => {
802
+ const {
803
+ ref: rootPropsRefCallback,
804
+ ...rootProps
805
+ } = getRootProps();
806
+ const listboxToggleProps = getToggleButtonProps({
807
+ ...rootProps,
808
+ role: null,
809
+ 'aria-labelledby': undefined,
810
+ ...triggerProps,
811
+ ...children.props
812
+ });
813
+ const menuToggleProps = {
814
+ ...listboxToggleProps,
815
+ 'aria-haspopup': 'true',
816
+ 'aria-controls': listboxToggleProps['aria-owns'],
817
+ 'aria-owns': null
818
+ };
819
+ const toggleButtonProps = hasMenuRef.current ? menuToggleProps : listboxToggleProps;
820
+ return React__namespace.default.cloneElement(React__namespace.default.Children.only(children), {
821
+ ...toggleButtonProps,
822
+ [refKey]: childRef => {
823
+ popperRef(childRef);
824
+ triggerRef.current = childRef;
825
+ rootPropsRefCallback(childRef);
826
+ }
827
+ });
828
+ };
829
+ return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
830
+ let {
831
+ ref: popperReference
832
+ } = _ref2;
833
+ return React__namespace.default.createElement(React__namespace.default.Fragment, null, renderChildren(popperReference), React__namespace.default.createElement(StyledInput, getInputProps({
834
+ readOnly: true,
835
+ isHidden: true,
836
+ tabIndex: -1,
837
+ ref: hiddenInputRef,
838
+ value: '',
839
+ onClick: e => {
840
+ if (isOpen) {
841
+ e.nativeEvent.preventDownshiftDefault = true;
842
+ }
843
+ },
844
+ onKeyDown: onInputKeyDown
845
+ })));
846
+ });
847
+ };
848
+ Trigger.propTypes = {
849
+ children: PropTypes__default.default.any,
850
+ refKey: PropTypes__default.default.string
851
+ };
852
+ Trigger.defaultProps = {
853
+ refKey: 'ref'
854
+ };
855
+
856
+ var _path$2;
857
+ function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
858
+ var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
859
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
860
+ xmlns: "http://www.w3.org/2000/svg",
861
+ width: 16,
862
+ height: 16,
863
+ focusable: "false",
864
+ viewBox: "0 0 16 16",
865
+ "aria-hidden": "true"
866
+ }, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
867
+ fill: "currentColor",
868
+ d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
869
+ })));
870
+ };
871
+
872
+ const FieldContext = React__namespace.default.createContext(undefined);
873
+ const useFieldContext = () => {
874
+ const fieldContext = React.useContext(FieldContext);
875
+ if (!fieldContext) {
876
+ throw new Error('This component must be rendered within a `Field` component.');
877
+ }
878
+ return fieldContext;
879
+ };
880
+
881
+ const Autocomplete = React.forwardRef((_ref, ref) => {
882
+ let {
883
+ children,
884
+ inputRef: controlledInputRef,
885
+ start,
886
+ ...props
887
+ } = _ref;
888
+ const {
889
+ popperReferenceElementRef,
890
+ downshift: {
891
+ getToggleButtonProps,
892
+ getInputProps,
893
+ getRootProps,
894
+ isOpen
895
+ },
896
+ setDropdownType
897
+ } = useDropdownContext();
898
+ const {
899
+ isLabelHovered
900
+ } = useFieldContext();
901
+ const inputRef = React.useRef();
902
+ const triggerRef = React.useRef();
903
+ const previousIsOpenRef = React.useRef(isOpen);
904
+ const [isHovered, setIsHovered] = React.useState(false);
905
+ const [isFocused, setIsFocused] = React.useState(false);
906
+ React.useEffect(() => {
907
+ if (inputRef.current && isOpen !== previousIsOpenRef.current) {
908
+ inputRef.current.focus();
909
+ }
910
+ previousIsOpenRef.current = isOpen;
911
+ }, [inputRef, isOpen]);
912
+ const {
913
+ type,
914
+ onKeyDown,
915
+ ...selectProps
916
+ } = getToggleButtonProps(getRootProps({
917
+ role: null,
918
+ ...props,
919
+ onKeyDown: e => {
920
+ if (isOpen) {
921
+ e.nativeEvent.preventDownshiftDefault = true;
922
+ }
923
+ },
924
+ onMouseEnter: containerUtilities.composeEventHandlers(props.onMouseEnter, () => setIsHovered(true)),
925
+ onMouseLeave: containerUtilities.composeEventHandlers(props.onMouseLeave, () => setIsHovered(false))
926
+ }));
927
+ const onSelectKeyDown = containerUtilities.composeEventHandlers(props.onKeyDown, onKeyDown);
928
+ const isContainerHovered = isLabelHovered && !isOpen;
929
+ const isContainerFocused = isOpen || isFocused;
930
+ React.useEffect(() => {
931
+ setDropdownType('autocomplete');
932
+ }, [setDropdownType]);
933
+ return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
934
+ let {
935
+ ref: popperReference
936
+ } = _ref2;
937
+ return React__namespace.default.createElement(StyledFauxInput, _extends$5({
938
+ isHovered: isContainerHovered,
939
+ isFocused: isContainerFocused,
940
+ tabIndex: null,
941
+ onKeyDown: onSelectKeyDown
942
+ }, selectProps, {
943
+ ref: selectRef => {
944
+ popperReference(selectRef);
945
+ reactMergeRefs.mergeRefs([triggerRef, ref])(selectRef);
946
+ popperReferenceElementRef.current = selectRef;
947
+ }
948
+ }), start && React__namespace.default.createElement(StyledFauxInput.StartIcon, {
949
+ isHovered: isHovered || isLabelHovered && !isOpen,
950
+ isFocused: isContainerFocused,
951
+ isDisabled: props.disabled
952
+ }, start), !isOpen && React__namespace.default.createElement(StyledSelect, null, children), React__namespace.default.createElement(StyledInput, getInputProps({
953
+ isHidden: !isOpen,
954
+ disabled: props.disabled,
955
+ onFocus: () => {
956
+ setIsFocused(true);
957
+ },
958
+ onBlur: () => {
959
+ setIsFocused(false);
960
+ },
961
+ onClick: e => {
962
+ if (isOpen) {
963
+ e.nativeEvent.preventDownshiftDefault = true;
964
+ }
965
+ },
966
+ role: 'combobox',
967
+ ref: reactMergeRefs.mergeRefs([inputRef, controlledInputRef || null])
968
+ })), !props.isBare && React__namespace.default.createElement(StyledFauxInput.EndIcon, {
969
+ isHovered: isHovered || isLabelHovered && !isOpen,
970
+ isFocused: isContainerFocused,
971
+ isDisabled: props.disabled,
972
+ isRotated: isOpen
973
+ }, React__namespace.default.createElement(SvgChevronDownStroke, null)));
974
+ });
975
+ });
976
+ Autocomplete.displayName = 'Autocomplete';
977
+ Autocomplete.propTypes = {
978
+ isCompact: PropTypes__default.default.bool,
979
+ isBare: PropTypes__default.default.bool,
980
+ disabled: PropTypes__default.default.bool,
981
+ focusInset: PropTypes__default.default.bool,
982
+ validation: PropTypes__default.default.oneOf(reactForms.VALIDATION)
983
+ };
984
+
985
+ const Combobox = React.forwardRef((_ref, ref) => {
986
+ let {
987
+ isCompact,
988
+ isBare,
989
+ disabled,
990
+ focusInset,
991
+ placeholder,
992
+ validation,
993
+ inputRef: inputRefProp = null,
994
+ start,
995
+ end,
996
+ ...props
997
+ } = _ref;
998
+ const {
999
+ popperReferenceElementRef,
1000
+ downshift: {
1001
+ getToggleButtonProps,
1002
+ getInputProps,
1003
+ getRootProps,
1004
+ isOpen
1005
+ },
1006
+ setDropdownType
1007
+ } = useDropdownContext();
1008
+ const wrapperRef = React.useRef();
1009
+ const inputRef = React.useRef();
1010
+ const isOpenRef = React.useRef(isOpen);
1011
+ const wrapperProps = getToggleButtonProps(getRootProps({
1012
+ role: null,
1013
+ type: null,
1014
+ onClick: event => {
1015
+ event.nativeEvent.preventDownshiftDefault = true;
1016
+ },
1017
+ ...props,
1018
+ onKeyDown: event => {
1019
+ event.nativeEvent.preventDownshiftDefault = true;
1020
+ }
1021
+ }));
1022
+ const inputProps = getInputProps({
1023
+ isCompact,
1024
+ isBare,
1025
+ disabled,
1026
+ focusInset,
1027
+ placeholder,
1028
+ validation,
1029
+ start,
1030
+ end,
1031
+ role: 'combobox',
1032
+ onKeyDown: event => {
1033
+ if (event.keyCode === containerUtilities.KEY_CODES.SPACE || !isOpen && [containerUtilities.KEY_CODES.DOWN, containerUtilities.KEY_CODES.UP].includes(event.keyCode)) {
1034
+ event.nativeEvent.preventDownshiftDefault = true;
1035
+ }
1036
+ },
1037
+ onClick: event => {
1038
+ event.nativeEvent.preventDownshiftDefault = true;
1039
+ }
1040
+ });
1041
+ React.useEffect(() => {
1042
+ if (inputRef.current && isOpen !== isOpenRef.current) {
1043
+ inputRef.current.focus();
1044
+ }
1045
+ isOpenRef.current = isOpen;
1046
+ }, [inputRef, isOpen]);
1047
+ React.useEffect(() => {
1048
+ setDropdownType('combobox');
1049
+ }, [setDropdownType]);
1050
+ return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
1051
+ let {
1052
+ ref: popperReference
1053
+ } = _ref2;
1054
+ const wrapperRefProp = element => {
1055
+ popperReference(element);
1056
+ reactMergeRefs.mergeRefs([wrapperRef, ref])(element);
1057
+ popperReferenceElementRef.current = element;
1058
+ };
1059
+ return React__namespace.default.createElement(reactForms.MediaInput, _extends$5({}, inputProps, {
1060
+ wrapperProps: wrapperProps,
1061
+ wrapperRef: wrapperRefProp,
1062
+ ref: reactMergeRefs.mergeRefs([inputRef, inputRefProp])
1063
+ }));
1064
+ });
1065
+ });
1066
+ Combobox.displayName = 'Combobox';
1067
+ Combobox.propTypes = {
1068
+ isCompact: PropTypes__default.default.bool,
1069
+ isBare: PropTypes__default.default.bool,
1070
+ disabled: PropTypes__default.default.bool,
1071
+ focusInset: PropTypes__default.default.bool,
1072
+ placeholder: PropTypes__default.default.string,
1073
+ validation: PropTypes__default.default.oneOf(reactForms.VALIDATION)
1074
+ };
1075
+
1076
+ const Multiselect = React__namespace.default.forwardRef((_ref, ref) => {
1077
+ let {
1078
+ renderItem,
1079
+ placeholder,
1080
+ maxItems,
1081
+ renderShowMore,
1082
+ inputRef: externalInputRef = null,
1083
+ start,
1084
+ onKeyDown,
1085
+ ...props
1086
+ } = _ref;
1087
+ const {
1088
+ popperReferenceElementRef,
1089
+ selectedItems = [],
1090
+ containsMultiselectRef,
1091
+ previousIndexRef,
1092
+ downshift: {
1093
+ getToggleButtonProps,
1094
+ getRootProps,
1095
+ getInputProps,
1096
+ isOpen,
1097
+ closeMenu,
1098
+ inputValue,
1099
+ setState: setDownshiftState,
1100
+ itemToString
1101
+ },
1102
+ setDropdownType
1103
+ } = useDropdownContext();
1104
+ const {
1105
+ isLabelHovered
1106
+ } = useFieldContext();
1107
+ const inputRef = React.useRef();
1108
+ const triggerRef = React.useRef();
1109
+ const blurTimeoutRef = React.useRef();
1110
+ const previousIsOpenRef = React.useRef(undefined);
1111
+ const previousIsFocusedRef = React.useRef(undefined);
1112
+ const [isHovered, setIsHovered] = React.useState(false);
1113
+ const [isFocused, setIsFocused] = React.useState(false);
1114
+ const [focusedItem, setFocusedItem] = React.useState(undefined);
1115
+ const themeContext = React.useContext(styled.ThemeContext);
1116
+ const environment = reactTheming.useDocument(themeContext);
1117
+ const {
1118
+ getContainerProps,
1119
+ getItemProps
1120
+ } = containerSelection.useSelection({
1121
+ rtl: themeContext.rtl,
1122
+ focusedItem,
1123
+ selectedItem: undefined,
1124
+ onFocus: item => {
1125
+ setFocusedItem(item);
1126
+ }
1127
+ });
1128
+ React.useEffect(() => {
1129
+ containsMultiselectRef.current = true;
1130
+ const tempRef = blurTimeoutRef;
1131
+ return () => {
1132
+ clearTimeout(tempRef.current);
1133
+ };
1134
+ }, []);
1135
+ React.useEffect(() => {
1136
+ if (inputRef.current) {
1137
+ if (isOpen && !previousIsOpenRef.current) {
1138
+ inputRef.current.focus();
1139
+ } else if (isFocused && !previousIsFocusedRef.current && focusedItem === undefined) {
1140
+ inputRef.current.focus();
1141
+ }
1142
+ }
1143
+ previousIsOpenRef.current = isOpen;
1144
+ previousIsFocusedRef.current = isFocused;
1145
+ }, [isOpen, inputRef, isFocused, focusedItem]);
1146
+ React.useEffect(() => {
1147
+ if (focusedItem !== undefined && isOpen) {
1148
+ closeMenu();
1149
+ }
1150
+ }, [focusedItem, isOpen, closeMenu]);
1151
+ const {
1152
+ type,
1153
+ ...selectProps
1154
+ } = getToggleButtonProps(getRootProps({
1155
+ tabIndex: props.disabled ? undefined : -1,
1156
+ onKeyDown: containerUtilities.composeEventHandlers(onKeyDown, e => {
1157
+ if (isOpen) {
1158
+ e.nativeEvent.preventDownshiftDefault = true;
1159
+ } else if (!inputValue && e.keyCode === containerUtilities.KEY_CODES.HOME) {
1160
+ setFocusedItem(selectedItems[0]);
1161
+ e.preventDefault();
1162
+ }
1163
+ }),
1164
+ onFocus: () => {
1165
+ setIsFocused(true);
1166
+ },
1167
+ onBlur: e => {
1168
+ const currentTarget = e.currentTarget;
1169
+ blurTimeoutRef.current = setTimeout(() => {
1170
+ if (environment && !currentTarget.contains(environment.activeElement)) {
1171
+ setIsFocused(false);
1172
+ }
1173
+ }, 0);
1174
+ },
1175
+ onMouseEnter: containerUtilities.composeEventHandlers(props.onMouseEnter, () => setIsHovered(true)),
1176
+ onMouseLeave: containerUtilities.composeEventHandlers(props.onMouseLeave, () => setIsHovered(false)),
1177
+ role: null,
1178
+ ...props
1179
+ }));
1180
+ const renderSelectableItem = React.useCallback((item, index) => {
1181
+ const removeValue = () => {
1182
+ setDownshiftState({
1183
+ type: REMOVE_ITEM_STATE_TYPE,
1184
+ selectedItem: item
1185
+ });
1186
+ inputRef.current && inputRef.current.focus();
1187
+ };
1188
+ const renderedItem = renderItem({
1189
+ value: item,
1190
+ removeValue
1191
+ });
1192
+ const focusRef = React__namespace.default.createRef();
1193
+ const clonedChild = React__namespace.default.cloneElement(renderedItem, {
1194
+ ...getItemProps({
1195
+ item,
1196
+ focusRef,
1197
+ onKeyDown: e => {
1198
+ if (e.keyCode === containerUtilities.KEY_CODES.DELETE || e.keyCode === containerUtilities.KEY_CODES.BACKSPACE) {
1199
+ e.preventDefault();
1200
+ removeValue();
1201
+ }
1202
+ if (e.keyCode === containerUtilities.KEY_CODES.END && !inputValue) {
1203
+ inputRef.current && inputRef.current.focus();
1204
+ e.preventDefault();
1205
+ }
1206
+ if (themeContext.rtl) {
1207
+ if (e.keyCode === containerUtilities.KEY_CODES.RIGHT && index === 0) {
1208
+ e.preventDefault();
1209
+ }
1210
+ if (e.keyCode === containerUtilities.KEY_CODES.LEFT && index === selectedItems.length - 1) {
1211
+ e.preventDefault();
1212
+ inputRef.current && inputRef.current.focus();
1213
+ }
1214
+ } else {
1215
+ if (e.keyCode === containerUtilities.KEY_CODES.LEFT && index === 0) {
1216
+ e.preventDefault();
1217
+ }
1218
+ if (e.keyCode === containerUtilities.KEY_CODES.RIGHT && index === selectedItems.length - 1) {
1219
+ e.preventDefault();
1220
+ inputRef.current && inputRef.current.focus();
1221
+ }
1222
+ }
1223
+ },
1224
+ onClick: e => {
1225
+ e.nativeEvent.preventDownshiftDefault = true;
1226
+ },
1227
+ tabIndex: -1
1228
+ }),
1229
+ size: props.isCompact ? 'medium' : 'large'
1230
+ });
1231
+ const key = `${itemToString(item)}-${index}`;
1232
+ return React__namespace.default.createElement(StyledMultiselectItemWrapper, {
1233
+ key: key
1234
+ }, clonedChild);
1235
+ }, [getItemProps, inputValue, renderItem, setDownshiftState, itemToString, selectedItems, props, inputRef, themeContext.rtl]);
1236
+ const items = React.useMemo(() => {
1237
+ const itemValues = selectedItems || [];
1238
+ const output = [];
1239
+ for (let x = 0; x < itemValues.length; x++) {
1240
+ const item = itemValues[x];
1241
+ if (x < maxItems) {
1242
+ if (props.disabled) {
1243
+ const renderedItem = React__namespace.default.cloneElement(renderItem({
1244
+ value: item,
1245
+ removeValue: () => {
1246
+ return undefined;
1247
+ }
1248
+ }), {
1249
+ size: props.isCompact ? 'medium' : 'large'
1250
+ });
1251
+ output.push( React__namespace.default.createElement(StyledMultiselectItemWrapper, {
1252
+ key: x
1253
+ }, renderedItem));
1254
+ } else {
1255
+ output.push(renderSelectableItem(item, x));
1256
+ }
1257
+ } else if (!isFocused && !inputValue || props.disabled) {
1258
+ output.push( React__namespace.default.createElement(StyledMultiselectItemWrapper, {
1259
+ key: "more-anchor"
1260
+ }, React__namespace.default.createElement(StyledMultiselectMoreAnchor, {
1261
+ isCompact: props.isCompact,
1262
+ isDisabled: props.disabled
1263
+ }, renderShowMore ? renderShowMore(itemValues.length - x) : `+ ${itemValues.length - x} more`)));
1264
+ break;
1265
+ } else {
1266
+ output.push(renderSelectableItem(item, x));
1267
+ }
1268
+ }
1269
+ return output;
1270
+ }, [isFocused, props.disabled, renderSelectableItem, selectedItems, renderItem, inputValue, maxItems, renderShowMore, props.isCompact]);
1271
+ const isContainerHovered = isLabelHovered && !isOpen;
1272
+ const isContainerFocused = isOpen || isFocused;
1273
+ React.useEffect(() => {
1274
+ setDropdownType('multiselect');
1275
+ }, [setDropdownType]);
1276
+ return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
1277
+ let {
1278
+ ref: popperReference
1279
+ } = _ref2;
1280
+ return React__namespace.default.createElement(StyledFauxInput, getContainerProps({
1281
+ ...selectProps,
1282
+ isHovered: isContainerHovered,
1283
+ isFocused: isContainerFocused,
1284
+ ref: selectRef => {
1285
+ popperReference(selectRef);
1286
+ reactMergeRefs.mergeRefs([triggerRef, popperReferenceElementRef, ref])(selectRef);
1287
+ }
1288
+ }), start && React__namespace.default.createElement(StyledFauxInput.StartIcon, {
1289
+ isHovered: isHovered || isLabelHovered && !isOpen,
1290
+ isFocused: isContainerFocused,
1291
+ isDisabled: props.disabled
1292
+ }, start), React__namespace.default.createElement(StyledMultiselectItemsContainer, {
1293
+ isBare: props.isBare,
1294
+ isCompact: props.isCompact
1295
+ }, items, React__namespace.default.createElement(StyledMultiselectInput, getInputProps({
1296
+ disabled: props.disabled,
1297
+ onFocus: () => {
1298
+ setFocusedItem(undefined);
1299
+ },
1300
+ onClick: e => {
1301
+ if (inputValue && inputValue.length > 0 && isOpen) {
1302
+ e.nativeEvent.preventDownshiftDefault = true;
1303
+ }
1304
+ },
1305
+ onKeyDown: e => {
1306
+ if (!inputValue) {
1307
+ if (themeContext.rtl && e.keyCode === containerUtilities.KEY_CODES.RIGHT && selectedItems.length > 0 && previousIndexRef.current === undefined) {
1308
+ setFocusedItem(selectedItems[selectedItems.length - 1]);
1309
+ } else if (!themeContext.rtl && e.keyCode === containerUtilities.KEY_CODES.LEFT && selectedItems.length > 0 && previousIndexRef.current === undefined) {
1310
+ setFocusedItem(selectedItems[selectedItems.length - 1]);
1311
+ } else if (e.keyCode === containerUtilities.KEY_CODES.BACKSPACE && selectedItems.length > 0) {
1312
+ setDownshiftState({
1313
+ type: REMOVE_ITEM_STATE_TYPE,
1314
+ selectedItem: selectedItems[selectedItems.length - 1]
1315
+ });
1316
+ e.nativeEvent.preventDownshiftDefault = true;
1317
+ e.preventDefault();
1318
+ e.stopPropagation();
1319
+ }
1320
+ }
1321
+ },
1322
+ isVisible: isFocused || inputValue || selectedItems.length === 0,
1323
+ isCompact: props.isCompact,
1324
+ role: 'combobox',
1325
+ ref: reactMergeRefs.mergeRefs([inputRef, externalInputRef]),
1326
+ placeholder: selectedItems.length === 0 ? placeholder : undefined
1327
+ }))), !props.isBare && React__namespace.default.createElement(StyledFauxInput.EndIcon, {
1328
+ isHovered: isHovered || isLabelHovered && !isOpen,
1329
+ isFocused: isContainerFocused,
1330
+ isDisabled: props.disabled,
1331
+ isRotated: isOpen
1332
+ }, React__namespace.default.createElement(SvgChevronDownStroke, null)));
1333
+ });
1334
+ });
1335
+ Multiselect.propTypes = {
1336
+ isCompact: PropTypes__default.default.bool,
1337
+ isBare: PropTypes__default.default.bool,
1338
+ disabled: PropTypes__default.default.bool,
1339
+ focusInset: PropTypes__default.default.bool,
1340
+ renderItem: PropTypes__default.default.func.isRequired,
1341
+ maxItems: PropTypes__default.default.number,
1342
+ validation: PropTypes__default.default.oneOf(['success', 'warning', 'error'])
1343
+ };
1344
+ Multiselect.defaultProps = {
1345
+ maxItems: 4
1346
+ };
1347
+ Multiselect.displayName = 'Multiselect';
1348
+
1349
+ const Select = React__namespace.default.forwardRef((_ref, ref) => {
1350
+ let {
1351
+ children,
1352
+ start,
1353
+ ...props
1354
+ } = _ref;
1355
+ const {
1356
+ popperReferenceElementRef,
1357
+ itemSearchRegistry,
1358
+ downshift: {
1359
+ getToggleButtonProps,
1360
+ getInputProps,
1361
+ isOpen,
1362
+ highlightedIndex,
1363
+ setHighlightedIndex,
1364
+ selectItemAtIndex,
1365
+ closeMenu
1366
+ }
1367
+ } = useDropdownContext();
1368
+ const {
1369
+ isLabelHovered
1370
+ } = useFieldContext();
1371
+ const [isHovered, setIsHovered] = React.useState(false);
1372
+ const [isFocused, setIsFocused] = React.useState(false);
1373
+ const hiddenInputRef = React.useRef();
1374
+ const triggerRef = React.useRef();
1375
+ const previousIsOpenRef = React.useRef(undefined);
1376
+ const [searchString, setSearchString] = React.useState('');
1377
+ const searchTimeoutRef = React.useRef();
1378
+ const currentSearchIndexRef = React.useRef(0);
1379
+ React.useEffect(() => {
1380
+ if (hiddenInputRef.current && isOpen && !previousIsOpenRef.current) {
1381
+ hiddenInputRef.current.focus();
1382
+ }
1383
+ if (triggerRef.current && !isOpen && previousIsOpenRef.current) {
1384
+ triggerRef.current.focus();
1385
+ }
1386
+ previousIsOpenRef.current = isOpen;
1387
+ }, [isOpen, triggerRef]);
1388
+ React.useEffect(() => {
1389
+ if (searchTimeoutRef.current) {
1390
+ clearTimeout(searchTimeoutRef.current);
1391
+ }
1392
+ searchTimeoutRef.current = window.setTimeout(() => {
1393
+ setSearchString('');
1394
+ }, 500);
1395
+ return () => {
1396
+ clearTimeout(searchTimeoutRef.current);
1397
+ };
1398
+ }, [searchString]);
1399
+ const searchItems = React.useCallback((searchValue, startIndex, endIndex) => {
1400
+ for (let index = startIndex; index < endIndex; index++) {
1401
+ const itemTextValue = itemSearchRegistry.current[index];
1402
+ if (itemTextValue && itemTextValue.toUpperCase().indexOf(searchValue.toUpperCase()) === 0) {
1403
+ return index;
1404
+ }
1405
+ }
1406
+ return undefined;
1407
+ }, [itemSearchRegistry]);
1408
+ const onInputKeyDown = React.useCallback(e => {
1409
+ if (e.keyCode === containerUtilities.KEY_CODES.SPACE) {
1410
+ if (searchString) {
1411
+ e.preventDefault();
1412
+ e.stopPropagation();
1413
+ } else if (highlightedIndex !== null && highlightedIndex !== undefined) {
1414
+ e.preventDefault();
1415
+ e.stopPropagation();
1416
+ selectItemAtIndex(highlightedIndex);
1417
+ closeMenu();
1418
+ }
1419
+ }
1420
+ if ((e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 65 || e.keyCode > 90) && e.keyCode !== containerUtilities.KEY_CODES.SPACE) {
1421
+ return;
1422
+ }
1423
+ const character = String.fromCharCode(e.which || e.keyCode);
1424
+ if (!character || character.length === 0) {
1425
+ return;
1426
+ }
1427
+ if (!searchString) {
1428
+ if (highlightedIndex === null || highlightedIndex === undefined) {
1429
+ currentSearchIndexRef.current = -1;
1430
+ } else {
1431
+ currentSearchIndexRef.current = highlightedIndex;
1432
+ }
1433
+ }
1434
+ const newSearchString = searchString + character;
1435
+ setSearchString(newSearchString);
1436
+ let matchingIndex = searchItems(newSearchString, currentSearchIndexRef.current + 1, itemSearchRegistry.current.length);
1437
+ if (matchingIndex === undefined) {
1438
+ matchingIndex = searchItems(newSearchString, 0, currentSearchIndexRef.current);
1439
+ }
1440
+ if (matchingIndex !== undefined) {
1441
+ setHighlightedIndex(matchingIndex);
1442
+ }
1443
+ }, [searchString, searchItems, itemSearchRegistry, highlightedIndex, selectItemAtIndex, closeMenu, setHighlightedIndex]);
1444
+ const {
1445
+ type,
1446
+ ...selectProps
1447
+ } = getToggleButtonProps({
1448
+ tabIndex: props.disabled ? undefined : 0,
1449
+ onMouseEnter: containerUtilities.composeEventHandlers(props.onMouseEnter, () => setIsHovered(true)),
1450
+ onMouseLeave: containerUtilities.composeEventHandlers(props.onMouseLeave, () => setIsHovered(false)),
1451
+ onFocus: containerUtilities.composeEventHandlers(props.onFocus, () => setIsFocused(true)),
1452
+ onBlur: containerUtilities.composeEventHandlers(props.onBlur, () => setIsFocused(false)),
1453
+ ...props
1454
+ });
1455
+ const isContainerHovered = isLabelHovered && !isOpen;
1456
+ const isContainerFocused = isFocused || isOpen;
1457
+ return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
1458
+ let {
1459
+ ref: popperReference
1460
+ } = _ref2;
1461
+ return React__namespace.default.createElement(StyledFauxInput, _extends$5({
1462
+ isHovered: isContainerHovered,
1463
+ isFocused: isContainerFocused
1464
+ }, selectProps, {
1465
+ role: "none",
1466
+ ref: selectRef => {
1467
+ popperReference(selectRef);
1468
+ reactMergeRefs.mergeRefs([triggerRef, ref, popperReferenceElementRef])(selectRef);
1469
+ }
1470
+ }), start && React__namespace.default.createElement(StyledFauxInput.StartIcon, {
1471
+ isHovered: isHovered || isLabelHovered && !isOpen,
1472
+ isFocused: isContainerFocused,
1473
+ isDisabled: props.disabled
1474
+ }, start), React__namespace.default.createElement(StyledSelect, null, children), React__namespace.default.createElement(StyledInput, getInputProps({
1475
+ readOnly: true,
1476
+ isHidden: true,
1477
+ tabIndex: -1,
1478
+ ref: hiddenInputRef,
1479
+ value: '',
1480
+ onClick: e => {
1481
+ if (isOpen) {
1482
+ e.nativeEvent.preventDownshiftDefault = true;
1483
+ }
1484
+ },
1485
+ onKeyDown: onInputKeyDown
1486
+ })), !props.isBare && React__namespace.default.createElement(StyledFauxInput.EndIcon, {
1487
+ isHovered: isHovered || isLabelHovered && !isOpen,
1488
+ isFocused: isContainerFocused,
1489
+ isDisabled: props.disabled,
1490
+ isRotated: isOpen
1491
+ }, React__namespace.default.createElement(SvgChevronDownStroke, null)));
1492
+ });
1493
+ });
1494
+ Select.displayName = 'Select';
1495
+ Select.propTypes = {
1496
+ isCompact: PropTypes__default.default.bool,
1497
+ isBare: PropTypes__default.default.bool,
1498
+ disabled: PropTypes__default.default.bool,
1499
+ focusInset: PropTypes__default.default.bool,
1500
+ validation: PropTypes__default.default.oneOf(reactForms.VALIDATION),
1501
+ start: PropTypes__default.default.any
1502
+ };
1503
+
1504
+ const Field = React.forwardRef((props, fieldRef) => {
1505
+ const {
1506
+ downshift: {
1507
+ getRootProps
1508
+ }
1509
+ } = useDropdownContext();
1510
+ const [isLabelHovered, setIsLabelHovered] = React.useState(false);
1511
+ const {
1512
+ ref
1513
+ } = getRootProps();
1514
+ const value = React.useMemo(() => ({
1515
+ isLabelHovered,
1516
+ setIsLabelHovered
1517
+ }), [isLabelHovered, setIsLabelHovered]);
1518
+ return React__namespace.default.createElement(FieldContext.Provider, {
1519
+ value: value
1520
+ }, React__namespace.default.createElement(reactForms.Field, _extends$5({
1521
+ ref: reactMergeRefs.mergeRefs([ref, fieldRef])
1522
+ }, props)));
1523
+ });
1524
+ Field.displayName = 'Field';
1525
+
1526
+ const Hint = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(reactForms.Hint, _extends$5({
1527
+ ref: ref
1528
+ }, props)));
1529
+ Hint.displayName = 'Hint';
1530
+
1531
+ const Label = React__namespace.default.forwardRef((_ref, ref) => {
1532
+ let {
1533
+ onMouseEnter,
1534
+ onMouseLeave,
1535
+ ...other
1536
+ } = _ref;
1537
+ const {
1538
+ downshift: {
1539
+ getLabelProps
1540
+ }
1541
+ } = useDropdownContext();
1542
+ const {
1543
+ setIsLabelHovered
1544
+ } = useFieldContext();
1545
+ const labelProps = getLabelProps({
1546
+ onMouseEnter: containerUtilities.composeEventHandlers(onMouseEnter, () => {
1547
+ setIsLabelHovered(true);
1548
+ }),
1549
+ onMouseLeave: containerUtilities.composeEventHandlers(onMouseLeave, () => {
1550
+ setIsLabelHovered(false);
1551
+ }),
1552
+ ...other
1553
+ });
1554
+ return React__namespace.default.createElement(reactForms.Label, _extends$5({
1555
+ ref: ref
1556
+ }, labelProps));
1557
+ });
1558
+ Label.displayName = 'Label';
1559
+ Label.propTypes = {
1560
+ isRegular: PropTypes__default.default.bool
1561
+ };
1562
+
1563
+ const Message = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(reactForms.Message, _extends$5({
1564
+ ref: ref
1565
+ }, props)));
1566
+ Message.displayName = 'Message';
1567
+ Message.propTypes = {
1568
+ validation: PropTypes__default.default.oneOf(reactForms.VALIDATION)
1569
+ };
1570
+
1571
+ const SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
1572
+ const PLACEMENT = [...SHARED_PLACEMENT, 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
1573
+
1574
+ const MenuContext = React__namespace.default.createContext(undefined);
1575
+ const useMenuContext = () => {
1576
+ const menuContext = React.useContext(MenuContext);
1577
+ if (!menuContext) {
1578
+ throw new Error('This component must be rendered within a `Menu` component.');
1579
+ }
1580
+ return menuContext;
1581
+ };
1582
+
1583
+ const Menu = React.forwardRef((props, menuRef) => {
1584
+ const {
1585
+ placement,
1586
+ popperModifiers,
1587
+ eventsEnabled,
1588
+ isAnimated,
1589
+ maxHeight,
1590
+ style: menuStyle,
1591
+ zIndex,
1592
+ isCompact,
1593
+ children,
1594
+ appendToNode,
1595
+ ...otherProps
1596
+ } = props;
1597
+ const {
1598
+ hasMenuRef,
1599
+ itemIndexRef,
1600
+ previousIndexRef,
1601
+ nextItemsHashRef,
1602
+ popperReferenceElementRef,
1603
+ itemSearchRegistry,
1604
+ downshift: {
1605
+ isOpen,
1606
+ getMenuProps
1607
+ }
1608
+ } = useDropdownContext();
1609
+ const scheduleUpdateRef = React.useRef(undefined);
1610
+ React.useEffect(() => {
1611
+ if (scheduleUpdateRef.current && isOpen) {
1612
+ scheduleUpdateRef.current();
1613
+ }
1614
+ });
1615
+ const [isVisible, setIsVisible] = React.useState(isOpen);
1616
+ React.useEffect(() => {
1617
+ let timeout;
1618
+ if (isOpen) {
1619
+ setIsVisible(true);
1620
+ } else if (isAnimated) {
1621
+ timeout = setTimeout(() => setIsVisible(false), 200);
1622
+ } else {
1623
+ setIsVisible(false);
1624
+ }
1625
+ return () => clearTimeout(timeout);
1626
+ }, [isOpen, isAnimated]);
1627
+ const themeContext = React.useContext(styled.ThemeContext);
1628
+ itemIndexRef.current = 0;
1629
+ nextItemsHashRef.current = {};
1630
+ previousIndexRef.current = undefined;
1631
+ itemSearchRegistry.current = [];
1632
+ const popperPlacement = themeContext.rtl ? getRtlPopperPlacement(placement) : getPopperPlacement(placement);
1633
+ return (
1634
+ React__namespace.default.createElement(MenuContext.Provider, {
1635
+ value: {
1636
+ itemIndexRef,
1637
+ isCompact
1638
+ }
1639
+ }, React__namespace.default.createElement(reactPopper.Popper, {
1640
+ placement: popperPlacement,
1641
+ modifiers: popperModifiers
1642
+ ,
1643
+ eventsEnabled: isOpen && eventsEnabled
1644
+ }, _ref => {
1645
+ let {
1646
+ ref,
1647
+ style,
1648
+ scheduleUpdate,
1649
+ placement: currentPlacement
1650
+ } = _ref;
1651
+ let computedStyle = menuStyle;
1652
+ scheduleUpdateRef.current = scheduleUpdate;
1653
+ if ((isOpen || isVisible) && popperReferenceElementRef.current && popperReferenceElementRef.current.getBoundingClientRect) {
1654
+ computedStyle = {
1655
+ width: popperReferenceElementRef.current.getBoundingClientRect().width,
1656
+ ...menuStyle
1657
+ };
1658
+ }
1659
+ const menuProps = getMenuProps({
1660
+ role: hasMenuRef.current ? 'menu' : 'listbox',
1661
+ placement: currentPlacement,
1662
+ isAnimated: isAnimated && (isOpen || isVisible),
1663
+ ...otherProps
1664
+ });
1665
+ const menu = React__namespace.default.createElement(StyledMenuWrapper, {
1666
+ ref: isOpen ? ref : undefined,
1667
+ hasArrow: menuProps.hasArrow,
1668
+ placement: menuProps.placement,
1669
+ style: style,
1670
+ isHidden: !isOpen,
1671
+ isAnimated: menuProps.isAnimated,
1672
+ zIndex: zIndex
1673
+ }, React__namespace.default.createElement(StyledMenu, _extends$5({
1674
+ ref: menuRef,
1675
+ isCompact: isCompact,
1676
+ maxHeight: maxHeight,
1677
+ style: computedStyle
1678
+ }, menuProps), (isOpen || isVisible) && children));
1679
+ return appendToNode ? reactDom.createPortal(menu, appendToNode) : menu;
1680
+ }))
1681
+ );
1682
+ });
1683
+ Menu.displayName = 'Menu';
1684
+ Menu.propTypes = {
1685
+ popperModifiers: PropTypes__default.default.any,
1686
+ eventsEnabled: PropTypes__default.default.bool,
1687
+ zIndex: PropTypes__default.default.number,
1688
+ style: PropTypes__default.default.object,
1689
+ placement: PropTypes__default.default.oneOf(PLACEMENT),
1690
+ isAnimated: PropTypes__default.default.bool,
1691
+ isCompact: PropTypes__default.default.bool,
1692
+ hasArrow: PropTypes__default.default.bool,
1693
+ maxHeight: PropTypes__default.default.string
1694
+ };
1695
+ Menu.defaultProps = {
1696
+ placement: 'bottom-start',
1697
+ isAnimated: true,
1698
+ eventsEnabled: true,
1699
+ maxHeight: '400px',
1700
+ zIndex: 1000
1701
+ };
1702
+
1703
+ const Separator = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(StyledSeparator, _extends$5({
1704
+ ref: ref
1705
+ }, props)));
1706
+ Separator.displayName = 'Separator';
1707
+
1708
+ var _path$1;
1709
+ function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
1710
+ var SvgPlusStroke = function SvgPlusStroke(props) {
1711
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
1712
+ xmlns: "http://www.w3.org/2000/svg",
1713
+ width: 16,
1714
+ height: 16,
1715
+ focusable: "false",
1716
+ viewBox: "0 0 16 16",
1717
+ "aria-hidden": "true"
1718
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
1719
+ stroke: "currentColor",
1720
+ strokeLinecap: "round",
1721
+ d: "M7.5 2.5v12m6-6h-12"
1722
+ })));
1723
+ };
1724
+
1725
+ var _path;
1726
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1727
+ var SvgCheckLgStroke = function SvgCheckLgStroke(props) {
1728
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends({
1729
+ xmlns: "http://www.w3.org/2000/svg",
1730
+ width: 16,
1731
+ height: 16,
1732
+ focusable: "false",
1733
+ viewBox: "0 0 16 16",
1734
+ "aria-hidden": "true"
1735
+ }, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
1736
+ fill: "none",
1737
+ stroke: "currentColor",
1738
+ strokeLinecap: "round",
1739
+ strokeLinejoin: "round",
1740
+ d: "M1 9l4 4L15 3"
1741
+ })));
1742
+ };
1743
+
1744
+ const ItemContext = React__namespace.default.createContext(undefined);
1745
+ const useItemContext = () => {
1746
+ const context = React.useContext(ItemContext);
1747
+ if (!context) {
1748
+ throw new Error('This component must be rendered within an `Item` component.');
1749
+ }
1750
+ return context;
1751
+ };
1752
+
1753
+ const Item = React__namespace.default.forwardRef((_ref, forwardRef) => {
1754
+ let {
1755
+ value,
1756
+ disabled,
1757
+ isDanger,
1758
+ component = StyledItem,
1759
+ hasIcon,
1760
+ children,
1761
+ ...props
1762
+ } = _ref;
1763
+ const {
1764
+ selectedItems,
1765
+ hasMenuRef,
1766
+ itemSearchRegistry,
1767
+ downshift: {
1768
+ isOpen,
1769
+ selectedItem,
1770
+ highlightedIndex,
1771
+ getItemProps,
1772
+ setHighlightedIndex,
1773
+ itemToString
1774
+ }
1775
+ } = useDropdownContext();
1776
+ const {
1777
+ itemIndexRef,
1778
+ isCompact
1779
+ } = useMenuContext();
1780
+ const itemRef = React.useRef();
1781
+ const Component = component;
1782
+ if ((value === undefined || value === null) && !disabled) {
1783
+ throw new Error('All Item components require a `value` prop');
1784
+ }
1785
+ const currentIndex = itemIndexRef.current;
1786
+ const isFocused = highlightedIndex === currentIndex;
1787
+ let isSelected;
1788
+ React.useEffect(() => {
1789
+ if (!disabled && itemRef.current) {
1790
+ const itemTextValue = itemRef.current.innerText;
1791
+ if (itemTextValue) {
1792
+ itemSearchRegistry.current[currentIndex] = itemTextValue;
1793
+ }
1794
+ }
1795
+ });
1796
+ if (value) {
1797
+ if (selectedItems) {
1798
+ isSelected = selectedItems.some(item => {
1799
+ return itemToString(item) === itemToString(value);
1800
+ });
1801
+ } else {
1802
+ isSelected = itemToString(selectedItem) === itemToString(value);
1803
+ }
1804
+ } else {
1805
+ isSelected = false;
1806
+ }
1807
+ React.useEffect(() => {
1808
+ if (isOpen && !disabled && !selectedItems && isSelected) {
1809
+ setHighlightedIndex(currentIndex);
1810
+ }
1811
+ }, [currentIndex, disabled, isOpen, isSelected, selectedItems, setHighlightedIndex]);
1812
+ const contextValue = React.useMemo(() => ({
1813
+ isDisabled: disabled
1814
+ }), [disabled]);
1815
+ const ref = reactMergeRefs.mergeRefs([itemRef, forwardRef]);
1816
+ if (disabled) {
1817
+ return React__namespace.default.createElement(ItemContext.Provider, {
1818
+ value: contextValue
1819
+ }, React__namespace.default.createElement(Component, _extends$5({
1820
+ ref: ref,
1821
+ disabled: disabled,
1822
+ isDanger: isDanger,
1823
+ isCompact: isCompact
1824
+ }, props), isSelected && !hasIcon && React__namespace.default.createElement(StyledItemIcon, {
1825
+ isCompact: isCompact,
1826
+ isVisible: isSelected,
1827
+ isDisabled: disabled
1828
+ }, React__namespace.default.createElement(SvgCheckLgStroke, null)), children));
1829
+ }
1830
+ itemIndexRef.current++;
1831
+ return React__namespace.default.createElement(ItemContext.Provider, {
1832
+ value: contextValue
1833
+ }, React__namespace.default.createElement(Component, getItemProps({
1834
+ item: value,
1835
+ isFocused,
1836
+ ref,
1837
+ isCompact,
1838
+ isDanger,
1839
+ ...(hasMenuRef.current && {
1840
+ role: 'menuitem',
1841
+ 'aria-selected': null
1842
+ }),
1843
+ ...props
1844
+ }), isSelected && !hasIcon && React__namespace.default.createElement(StyledItemIcon, {
1845
+ isCompact: isCompact,
1846
+ isVisible: isSelected
1847
+ }, React__namespace.default.createElement(SvgCheckLgStroke, null)), children));
1848
+ });
1849
+ Item.displayName = 'Item';
1850
+ Item.propTypes = {
1851
+ value: PropTypes__default.default.any,
1852
+ disabled: PropTypes__default.default.bool
1853
+ };
1854
+
1855
+ const AddItemComponent = React__namespace.default.forwardRef((_ref, ref) => {
1856
+ let {
1857
+ children,
1858
+ disabled,
1859
+ ...props
1860
+ } = _ref;
1861
+ const {
1862
+ isCompact
1863
+ } = useMenuContext();
1864
+ return React__namespace.default.createElement(StyledAddItem, _extends$5({
1865
+ ref: ref,
1866
+ disabled: disabled
1867
+ }, props), React__namespace.default.createElement(StyledItemIcon, {
1868
+ isCompact: isCompact,
1869
+ isVisible: true,
1870
+ isDisabled: disabled
1871
+ }, React__namespace.default.createElement(SvgPlusStroke, null)), children);
1872
+ });
1873
+ const AddItem = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(Item, _extends$5({
1874
+ component: AddItemComponent,
1875
+ ref: ref
1876
+ }, props, {
1877
+ hasIcon: true
1878
+ })));
1879
+ AddItem.displayName = 'AddItem';
1880
+ AddItem.propTypes = {
1881
+ value: PropTypes__default.default.any,
1882
+ disabled: PropTypes__default.default.bool
1883
+ };
1884
+
1885
+ const HeaderIcon = React__namespace.default.forwardRef((props, ref) => {
1886
+ const {
1887
+ isCompact
1888
+ } = useMenuContext();
1889
+ return React__namespace.default.createElement(StyledHeaderIcon, _extends$5({
1890
+ ref: ref,
1891
+ isCompact: isCompact
1892
+ }, props));
1893
+ });
1894
+ HeaderIcon.displayName = 'HeaderIcon';
1895
+
1896
+ const HeaderItem = React__namespace.default.forwardRef((props, ref) => {
1897
+ const {
1898
+ isCompact
1899
+ } = useMenuContext();
1900
+ return React__namespace.default.createElement(StyledHeaderItem, _extends$5({
1901
+ ref: ref,
1902
+ isCompact: isCompact
1903
+ }, props));
1904
+ });
1905
+ HeaderItem.displayName = 'HeaderItem';
1906
+
1907
+ const ItemMeta = React__namespace.default.forwardRef((props, ref) => {
1908
+ const {
1909
+ isCompact
1910
+ } = useMenuContext();
1911
+ const {
1912
+ isDisabled
1913
+ } = useItemContext();
1914
+ return React__namespace.default.createElement(StyledItemMeta, _extends$5({
1915
+ ref: ref,
1916
+ isCompact: isCompact,
1917
+ isDisabled: isDisabled
1918
+ }, props));
1919
+ });
1920
+ ItemMeta.displayName = 'ItemMeta';
1921
+
1922
+ const MediaBody = React__namespace.default.forwardRef((props, ref) => {
1923
+ const {
1924
+ isCompact
1925
+ } = useMenuContext();
1926
+ return React__namespace.default.createElement(StyledMediaBody, _extends$5({
1927
+ ref: ref,
1928
+ isCompact: isCompact
1929
+ }, props));
1930
+ });
1931
+ MediaBody.displayName = 'MediaBody';
1932
+
1933
+ const MediaFigure = props => {
1934
+ const {
1935
+ isCompact
1936
+ } = useMenuContext();
1937
+ return React__namespace.default.createElement(StyledMediaFigure, _extends$5({
1938
+ isCompact: isCompact
1939
+ }, props));
1940
+ };
1941
+
1942
+ const MediaItem = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(Item, _extends$5({
1943
+ component: StyledMediaItem,
1944
+ ref: ref
1945
+ }, props)));
1946
+ MediaItem.displayName = 'MediaItem';
1947
+ MediaItem.propTypes = {
1948
+ value: PropTypes__default.default.any,
1949
+ disabled: PropTypes__default.default.bool
1950
+ };
1951
+
1952
+ const NextItemComponent = React__namespace.default.forwardRef((_ref, ref) => {
1953
+ let {
1954
+ children,
1955
+ disabled,
1956
+ ...props
1957
+ } = _ref;
1958
+ const {
1959
+ isCompact
1960
+ } = useMenuContext();
1961
+ return React__namespace.default.createElement(StyledNextItem, _extends$5({
1962
+ ref: ref,
1963
+ disabled: disabled
1964
+ }, props), React__namespace.default.createElement(StyledItemIcon, {
1965
+ isCompact: isCompact,
1966
+ isDisabled: disabled,
1967
+ isVisible: true
1968
+ }, React__namespace.default.createElement(StyledNextIcon, {
1969
+ isDisabled: disabled
1970
+ })), children);
1971
+ });
1972
+ const NextItem = React__namespace.default.forwardRef((_ref2, ref) => {
1973
+ let {
1974
+ value,
1975
+ disabled,
1976
+ ...props
1977
+ } = _ref2;
1978
+ const {
1979
+ nextItemsHashRef,
1980
+ downshift: {
1981
+ itemToString
1982
+ }
1983
+ } = useDropdownContext();
1984
+ const {
1985
+ itemIndexRef
1986
+ } = useMenuContext();
1987
+ if (!disabled) {
1988
+ nextItemsHashRef.current[itemToString(value)] = itemIndexRef.current;
1989
+ }
1990
+ return React__namespace.default.createElement(Item, _extends$5({
1991
+ component: NextItemComponent,
1992
+ "aria-expanded": true,
1993
+ disabled: disabled,
1994
+ value: value,
1995
+ ref: ref
1996
+ }, props, {
1997
+ hasIcon: true
1998
+ }));
1999
+ });
2000
+ NextItem.displayName = 'NextItem';
2001
+ NextItem.propTypes = {
2002
+ value: PropTypes__default.default.any,
2003
+ disabled: PropTypes__default.default.bool
2004
+ };
2005
+
2006
+ const PreviousItemComponent = React__namespace.default.forwardRef((_ref, ref) => {
2007
+ let {
2008
+ children,
2009
+ disabled,
2010
+ ...props
2011
+ } = _ref;
2012
+ const {
2013
+ isCompact
2014
+ } = useMenuContext();
2015
+ return React__namespace.default.createElement(StyledPreviousItem, _extends$5({
2016
+ ref: ref,
2017
+ disabled: disabled
2018
+ }, props), React__namespace.default.createElement(StyledItemIcon, {
2019
+ isCompact: isCompact,
2020
+ isDisabled: disabled,
2021
+ isVisible: true
2022
+ }, React__namespace.default.createElement(StyledPreviousIcon, {
2023
+ isDisabled: disabled
2024
+ })), children);
2025
+ });
2026
+ const PreviousItem = React__namespace.default.forwardRef((_ref2, ref) => {
2027
+ let {
2028
+ value,
2029
+ disabled,
2030
+ ...props
2031
+ } = _ref2;
2032
+ const {
2033
+ previousIndexRef
2034
+ } = useDropdownContext();
2035
+ const {
2036
+ itemIndexRef
2037
+ } = useMenuContext();
2038
+ if (!disabled) {
2039
+ previousIndexRef.current = itemIndexRef.current;
2040
+ }
2041
+ return React__namespace.default.createElement(Item, _extends$5({
2042
+ component: PreviousItemComponent,
2043
+ "aria-expanded": true,
2044
+ value: value,
2045
+ disabled: disabled
2046
+ }, props, {
2047
+ ref: ref,
2048
+ hasIcon: true
2049
+ }));
2050
+ });
2051
+ PreviousItem.displayName = 'PreviousItem';
2052
+ PreviousItem.propTypes = {
2053
+ value: PropTypes__default.default.any,
2054
+ disabled: PropTypes__default.default.bool
2055
+ };
2056
+
2057
+ Object.defineProperty(exports, "resetIdCounter", {
2058
+ enumerable: true,
2059
+ get: function () { return Downshift.resetIdCounter; }
2060
+ });
2061
+ exports.AddItem = AddItem;
2062
+ exports.Autocomplete = Autocomplete;
2063
+ exports.Combobox = Combobox;
2064
+ exports.Dropdown = Dropdown;
2065
+ exports.Field = Field;
2066
+ exports.HeaderIcon = HeaderIcon;
2067
+ exports.HeaderItem = HeaderItem;
2068
+ exports.Hint = Hint;
2069
+ exports.Item = Item;
2070
+ exports.ItemMeta = ItemMeta;
2071
+ exports.Label = Label;
2072
+ exports.MediaBody = MediaBody;
2073
+ exports.MediaFigure = MediaFigure;
2074
+ exports.MediaItem = MediaItem;
2075
+ exports.Menu = Menu;
2076
+ exports.Message = Message;
2077
+ exports.Multiselect = Multiselect;
2078
+ exports.NextItem = NextItem;
2079
+ exports.PreviousItem = PreviousItem;
2080
+ exports.Select = Select;
2081
+ exports.Separator = Separator;
2082
+ exports.Trigger = Trigger;