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