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

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