@zendeskgarden/react-dropdowns 9.0.0-next.1 → 9.0.0-next.11

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