@zendeskgarden/react-dropdowns 9.0.0-next.2 → 9.0.0-next.4

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