@ultraviolet/ui 3.4.0 → 3.5.1

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 (225) hide show
  1. package/dist/components/Alert/index.js +1 -1
  2. package/dist/components/Alert/styles.css.d.ts +8 -8
  3. package/dist/components/Alert/styles.css.js +1 -1
  4. package/dist/components/Avatar/styles.css.d.ts +36 -36
  5. package/dist/components/Avatar/styles.css.js +4 -4
  6. package/dist/components/Badge/styles.css.d.ts +28 -28
  7. package/dist/components/Badge/styles.css.js +1 -1
  8. package/dist/components/Banner/index.js +1 -1
  9. package/dist/components/Banner/styles.css.d.ts +2 -2
  10. package/dist/components/Banner/styles.css.js +2 -2
  11. package/dist/components/BarStack/styles.css.d.ts +7 -7
  12. package/dist/components/BarStack/styles.css.js +1 -1
  13. package/dist/components/Bullet/styles.css.d.ts +13 -13
  14. package/dist/components/Bullet/styles.css.js +1 -1
  15. package/dist/components/Button/index.d.ts +2 -2
  16. package/dist/components/Button/index.d.ts.map +1 -1
  17. package/dist/components/Button/styles.css.d.ts +39 -39
  18. package/dist/components/Button/styles.css.js +1 -1
  19. package/dist/components/Checkbox/index.js +4 -4
  20. package/dist/components/Chip/ChipIcon.d.ts.map +1 -1
  21. package/dist/components/Chip/ChipIcon.js +4 -1
  22. package/dist/components/Chip/index.d.ts +1 -1
  23. package/dist/components/CopyButton/index.js +1 -1
  24. package/dist/components/DateInput/components/CalendarContent.js +7 -7
  25. package/dist/components/DateInput/components/CalendarDaily.js +1 -1
  26. package/dist/components/DateInput/components/CalendarMonthly.d.ts.map +1 -1
  27. package/dist/components/DateInput/components/CalendarMonthly.js +1 -1
  28. package/dist/components/DateInput/helpers.d.ts.map +1 -1
  29. package/dist/components/Dialog/components/Buttons.js +1 -1
  30. package/dist/components/Dialog/index.d.ts +2 -2
  31. package/dist/components/Drawer/styles.css.js +1 -1
  32. package/dist/components/EmptyState/styles.css.d.ts +11 -11
  33. package/dist/components/EmptyState/styles.css.js +2 -2
  34. package/dist/components/Expandable/index.js +1 -1
  35. package/dist/components/ExpandableCard/styles.css.d.ts.map +1 -1
  36. package/dist/components/FileInput/index.js +1 -1
  37. package/dist/components/FileInput/styles.css.d.ts +11 -11
  38. package/dist/components/FileInput/styles.css.js +5 -5
  39. package/dist/components/GlobalAlert/styles.css.js +1 -1
  40. package/dist/components/Key/styles.css.d.ts +12 -12
  41. package/dist/components/Key/styles.css.js +1 -1
  42. package/dist/components/Label/index.d.ts.map +1 -1
  43. package/dist/components/Label/index.js +41 -28
  44. package/dist/components/Label/styles.css.js +1 -1
  45. package/dist/components/Link/styles.css.d.ts.map +1 -1
  46. package/dist/components/List/ListContext.d.ts +2 -2
  47. package/dist/components/List/ListContext.d.ts.map +1 -1
  48. package/dist/components/List/Row.d.ts +1 -1
  49. package/dist/components/List/Row.d.ts.map +1 -1
  50. package/dist/components/List/SelectBar.d.ts +1 -1
  51. package/dist/components/List/SelectBar.d.ts.map +1 -1
  52. package/dist/components/List/SkeletonRows.d.ts.map +1 -1
  53. package/dist/components/List/index.d.ts +2 -5
  54. package/dist/components/List/index.d.ts.map +1 -1
  55. package/dist/components/List/styles.css.d.ts +3 -3
  56. package/dist/components/List/styles.css.js +1 -1
  57. package/dist/components/Menu/styles.css.js +1 -1
  58. package/dist/components/Modal/ModalContent.d.ts.map +1 -1
  59. package/dist/components/Modal/components/Dialog.d.ts.map +1 -1
  60. package/dist/components/Modal/components/Dialog.js +1 -1
  61. package/dist/components/Modal/index.js +3 -3
  62. package/dist/components/Modal/styles.css.d.ts +17 -17
  63. package/dist/components/Modal/styles.css.js +1 -1
  64. package/dist/components/NumberInput/index.d.ts +1 -1
  65. package/dist/components/NumberInput/index.js +2 -2
  66. package/dist/components/NumberInput/styles.css.d.ts +48 -48
  67. package/dist/components/NumberInput/styles.css.d.ts.map +1 -1
  68. package/dist/components/NumberInput/styles.css.js +4 -4
  69. package/dist/components/Pagination/getPageNumbers.d.ts +1 -1
  70. package/dist/components/Pagination/styles.css.js +2 -2
  71. package/dist/components/PieChart/index.js +3 -3
  72. package/dist/components/PieChart/styles.css.d.ts +7 -7
  73. package/dist/components/PieChart/styles.css.js +3 -3
  74. package/dist/components/Popover/index.js +1 -1
  75. package/dist/components/Popover/styles.css.d.ts +3 -3
  76. package/dist/components/Popup/helpers.js +2 -2
  77. package/dist/components/Popup/index.js +19 -19
  78. package/dist/components/Popup/styles.css.d.ts +6 -6
  79. package/dist/components/Popup/styles.css.js +1 -1
  80. package/dist/components/Radio/index.d.ts.map +1 -1
  81. package/dist/components/Radio/index.js +14 -11
  82. package/dist/components/RadioGroup/index.js +1 -1
  83. package/dist/components/Row/styles.css.d.ts +19 -19
  84. package/dist/components/Row/styles.css.d.ts.map +1 -1
  85. package/dist/components/Row/styles.css.js +2 -2
  86. package/dist/components/Row/variables.css.d.ts +1 -1
  87. package/dist/components/Row/variables.css.d.ts.map +1 -1
  88. package/dist/components/Row/variables.css.js +2 -2
  89. package/dist/components/SelectInput/components/Dropdown.d.ts +14 -1
  90. package/dist/components/SelectInput/components/Dropdown.d.ts.map +1 -1
  91. package/dist/components/SelectInput/components/Dropdown.js +398 -222
  92. package/dist/components/SelectInput/components/SearchBarDropdown.d.ts.map +1 -1
  93. package/dist/components/SelectInput/components/SearchBarDropdown.js +25 -19
  94. package/dist/components/SelectInput/components/SelectBar.d.ts.map +1 -1
  95. package/dist/components/SelectInput/components/SelectBar.js +8 -11
  96. package/dist/components/SelectInput/components/dropdown.css.d.ts +2 -0
  97. package/dist/components/SelectInput/components/dropdown.css.d.ts.map +1 -1
  98. package/dist/components/SelectInput/components/dropdown.css.js +13 -9
  99. package/dist/components/SelectInput/components/selectBar.css.d.ts +43 -43
  100. package/dist/components/SelectInput/components/selectBar.css.d.ts.map +1 -1
  101. package/dist/components/SelectInput/components/selectBar.css.js +2 -2
  102. package/dist/components/SelectInput/constants.d.ts +13 -0
  103. package/dist/components/SelectInput/constants.d.ts.map +1 -0
  104. package/dist/components/SelectInput/constants.js +18 -0
  105. package/dist/components/SelectInput/findOptionInOptions.js +3 -3
  106. package/dist/components/SelectInput/index.d.ts +11 -5
  107. package/dist/components/SelectInput/index.d.ts.map +1 -1
  108. package/dist/components/SelectInput/index.js +8 -2
  109. package/dist/components/SelectInput/types.d.ts +0 -5
  110. package/dist/components/SelectInput/types.d.ts.map +1 -1
  111. package/dist/components/SelectableCard/index.d.ts.map +1 -1
  112. package/dist/components/SelectableCard/index.js +8 -5
  113. package/dist/components/SelectableCard/styles.css.d.ts +9 -9
  114. package/dist/components/SelectableCard/styles.css.js +3 -2
  115. package/dist/components/SelectableCard/variables.css.js +0 -1
  116. package/dist/components/Separator/index.d.ts.map +1 -1
  117. package/dist/components/Separator/index.js +33 -31
  118. package/dist/components/Skeleton/Block.d.ts.map +1 -1
  119. package/dist/components/Skeleton/Block.js +7 -4
  120. package/dist/components/Skeleton/Blocks.d.ts.map +1 -1
  121. package/dist/components/Skeleton/Blocks.js +7 -4
  122. package/dist/components/Skeleton/BoxWithIcon.d.ts.map +1 -1
  123. package/dist/components/Skeleton/BoxWithIcon.js +7 -4
  124. package/dist/components/Skeleton/List.d.ts.map +1 -1
  125. package/dist/components/Skeleton/List.js +8 -2
  126. package/dist/components/Skeleton/Slider.d.ts.map +1 -1
  127. package/dist/components/Skeleton/Slider.js +4 -1
  128. package/dist/components/Skeleton/index.d.ts.map +1 -1
  129. package/dist/components/Skeleton/index.js +17 -14
  130. package/dist/components/Slider/components/DoubleSlider.d.ts +1 -1
  131. package/dist/components/Slider/components/DoubleSlider.d.ts.map +1 -1
  132. package/dist/components/Slider/components/DoubleSlider.js +24 -20
  133. package/dist/components/Slider/components/SingleSlider.d.ts +1 -1
  134. package/dist/components/Slider/components/SingleSlider.d.ts.map +1 -1
  135. package/dist/components/Slider/components/SingleSlider.js +9 -3
  136. package/dist/components/Slider/index.d.ts +1 -1
  137. package/dist/components/Slider/index.d.ts.map +1 -1
  138. package/dist/components/Slider/index.js +3 -0
  139. package/dist/components/Slider/styles.css.d.ts +47 -43
  140. package/dist/components/Slider/styles.css.d.ts.map +1 -1
  141. package/dist/components/Slider/styles.css.js +5 -5
  142. package/dist/components/Slider/types.d.ts +5 -0
  143. package/dist/components/Slider/types.d.ts.map +1 -1
  144. package/dist/components/Snippet/index.js +1 -1
  145. package/dist/components/Snippet/styles.css.d.ts +12 -12
  146. package/dist/components/Snippet/styles.css.js +7 -7
  147. package/dist/components/Stack/index.d.ts +2 -3
  148. package/dist/components/Stack/index.d.ts.map +1 -1
  149. package/dist/components/Stack/index.js +67 -65
  150. package/dist/components/Stack/styles.css.d.ts +87 -87
  151. package/dist/components/Stack/styles.css.js +4 -4
  152. package/dist/components/Status/styles.css.d.ts +1 -1
  153. package/dist/components/StepList/styles.css.d.ts +7 -7
  154. package/dist/components/StepList/styles.css.js +2 -2
  155. package/dist/components/Stepper/index.d.ts.map +1 -1
  156. package/dist/components/Stepper/index.js +13 -10
  157. package/dist/components/Stepper/styles.css.d.ts +45 -45
  158. package/dist/components/Stepper/styles.css.js +6 -6
  159. package/dist/components/SwitchButton/index.js +3 -3
  160. package/dist/components/SwitchButton/styles.css.js +3 -3
  161. package/dist/components/Table/HeaderRow.d.ts.map +1 -1
  162. package/dist/components/Table/HeaderRow.js +25 -22
  163. package/dist/components/Table/Row.d.ts +1 -1
  164. package/dist/components/Table/Row.d.ts.map +1 -1
  165. package/dist/components/Table/SelectBar.d.ts +1 -1
  166. package/dist/components/Table/SelectBar.d.ts.map +1 -1
  167. package/dist/components/Table/SkeletonRows.d.ts.map +1 -1
  168. package/dist/components/Table/index.d.ts +4 -4
  169. package/dist/components/Table/index.d.ts.map +1 -1
  170. package/dist/components/Table/styles.css.d.ts +21 -21
  171. package/dist/components/Table/styles.css.js +2 -2
  172. package/dist/components/Tabs/Tab.js +1 -1
  173. package/dist/components/Tabs/index.d.ts +1 -1
  174. package/dist/components/Tabs/styles.css.js +1 -1
  175. package/dist/components/Tag/styles.css.d.ts +10 -10
  176. package/dist/components/Tag/styles.css.js +1 -1
  177. package/dist/components/TagInput/index.js +5 -5
  178. package/dist/components/TagInput/styles.css.d.ts +4 -4
  179. package/dist/components/TagInput/styles.css.js +1 -1
  180. package/dist/components/TagList/index.d.ts.map +1 -1
  181. package/dist/components/TagList/index.js +1 -1
  182. package/dist/components/Text/style.css.d.ts +26 -26
  183. package/dist/components/Text/style.css.d.ts.map +1 -1
  184. package/dist/components/Text/style.css.js +1 -1
  185. package/dist/components/TextArea/index.d.ts.map +1 -1
  186. package/dist/components/TextArea/index.js +14 -7
  187. package/dist/components/TextArea/styles.css.d.ts +2 -2
  188. package/dist/components/TextArea/styles.css.js +1 -1
  189. package/dist/components/TextInput/index.d.ts +1 -1
  190. package/dist/components/TextInput/index.js +2 -2
  191. package/dist/components/TimeInput/helpers.d.ts.map +1 -1
  192. package/dist/components/TimeInput/helpers.js +2 -1
  193. package/dist/components/TimeInput/index.js +4 -4
  194. package/dist/components/TimeInput/styles.css.d.ts +22 -22
  195. package/dist/components/TimeInput/styles.css.js +1 -1
  196. package/dist/components/Toaster/constants.d.ts.map +1 -1
  197. package/dist/components/Toggle/styles.css.d.ts +53 -53
  198. package/dist/components/Toggle/styles.css.js +2 -2
  199. package/dist/components/Tooltip/index.d.ts +1 -1
  200. package/dist/components/TreeMapChart/index.d.ts +1 -1
  201. package/dist/components/TreeMapChart/index.d.ts.map +1 -1
  202. package/dist/components/TreeMapChart/index.js +39 -42
  203. package/dist/components/TreeMapChart/styles.css.d.ts +1 -1
  204. package/dist/components/TreeMapChart/styles.css.d.ts.map +1 -1
  205. package/dist/components/TreeMapChart/styles.css.js +2 -2
  206. package/dist/components/UnitInput/index.js +1 -1
  207. package/dist/components/UnitInput/styles.css.js +3 -3
  208. package/dist/components/VerificationCode/index.d.ts.map +1 -1
  209. package/dist/components/VerificationCode/index.js +2 -2
  210. package/dist/components/VerificationCode/styles.css.js +1 -1
  211. package/dist/components/compositions/OptionSelector/index.d.ts.map +1 -1
  212. package/dist/components/compositions/OptionSelector/index.js +91 -59
  213. package/dist/components/compositions/OptionSelector/styles.css.d.ts +2 -0
  214. package/dist/components/compositions/OptionSelector/styles.css.d.ts.map +1 -1
  215. package/dist/components/compositions/OptionSelector/styles.css.js +4 -0
  216. package/dist/helpers/treeMap.d.ts +4 -5
  217. package/dist/helpers/treeMap.d.ts.map +1 -1
  218. package/dist/helpers/treeMap.js +7 -5
  219. package/dist/theme/ThemeProvider.d.ts +33 -0
  220. package/dist/theme/ThemeProvider.d.ts.map +1 -1
  221. package/dist/theme/index.d.ts +33 -0
  222. package/dist/theme/index.d.ts.map +1 -1
  223. package/dist/ui.css +1 -1
  224. package/package.json +6 -6
  225. package/dist/components/SelectInput/types.js +0 -9
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import { PlusIcon } from "@ultraviolet/icons";
3
4
  import { useTheme } from "@ultraviolet/themes";
4
5
  import { cn } from "@ultraviolet/utils";
5
6
  import { assignInlineVars } from "@vanilla-extract/dynamic";
@@ -10,12 +11,11 @@ import { Popup } from "../../Popup/index.js";
10
11
  import { Skeleton } from "../../Skeleton/index.js";
11
12
  import { Stack } from "../../Stack/index.js";
12
13
  import { Text } from "../../Text/index.js";
14
+ import { DROPDOWN_MAX_HEIGHT, INPUT_SIZE_HEIGHT, OPTION_SELECTOR } from "../constants.js";
13
15
  import { useSelectInput } from "../SelectInputProvider.js";
14
- import { INPUT_SIZE_HEIGHT } from "../types.js";
15
16
  import { DisplayOption } from "./DropdownOption.js";
16
- import { footer, dropdown, dropdownWidth, dropdownEmptyState, dropdownContainer, dropdownCheckbox, dropdownItem, dropdownGroupWrapper, dropdownGroupSelectable, dropdownGroup, dropdownLoadMore, dropdownContainerUnGrouped } from "./dropdown.css.js";
17
+ import { footer, dropdown, dropdownWidth, dropdownEmptyState, comboboxCreate, dropdownCheckbox, dropdownItem, dropdownLoadMore, dropdownContainer, dropdownContainerUnGrouped, dropdownGroupWrapper, dropdownGroupSelectable, dropdownGroup, emptyStateGroupStyle } from "./dropdown.css.js";
17
18
  import { SearchBarDropdown } from "./SearchBarDropdown.js";
18
- const DROPDOWN_MAX_HEIGHT = 256;
19
19
  const NON_SEARCHABLE_KEYS = [
20
20
  "Tab",
21
21
  " ",
@@ -29,9 +29,7 @@ const NON_SEARCHABLE_KEYS = [
29
29
  "Escape"
30
30
  ];
31
31
  const moveFocusDown = () => {
32
- const options = document.querySelectorAll(
33
- '#items > div[role="option"]:not([disabled])'
34
- );
32
+ const options = document.querySelectorAll(OPTION_SELECTOR);
35
33
  const activeItem = document.activeElement;
36
34
  if (options) {
37
35
  for (let i = 0; i < options?.length; i += 1) {
@@ -43,9 +41,7 @@ const moveFocusDown = () => {
43
41
  }
44
42
  };
45
43
  const moveFocusUp = () => {
46
- const options = document.querySelectorAll(
47
- '#items > div[role="option"]:not([disabled])'
48
- );
44
+ const options = document.querySelectorAll(OPTION_SELECTOR);
49
45
  const activeItem = document.activeElement;
50
46
  if (options) {
51
47
  for (let i = 0; i < options.length; i += 1) {
@@ -73,7 +69,16 @@ const handleKeyDown = (event, ref, options, searchBarActive, setSearch, setDefau
73
69
  const currentSearch = search + event.key;
74
70
  setSearch(currentSearch);
75
71
  ref.current.focus();
76
- if (!Array.isArray(options)) {
72
+ if (Array.isArray(options)) {
73
+ const closestOption = [...options].find(
74
+ (option) => option.searchText ? option.searchText.toLocaleLowerCase().startsWith(currentSearch) : option.value.toLocaleLowerCase().startsWith(currentSearch)
75
+ );
76
+ if (closestOption) {
77
+ setDefaultSearch(closestOption.searchText ?? closestOption.value);
78
+ } else {
79
+ setDefaultSearch(null);
80
+ }
81
+ } else {
77
82
  const closestOptions = { ...options };
78
83
  Object.keys(closestOptions).map((group) => {
79
84
  closestOptions[group] = closestOptions[group].filter(
@@ -87,15 +92,6 @@ const handleKeyDown = (event, ref, options, searchBarActive, setSearch, setDefau
87
92
  } else {
88
93
  setDefaultSearch(null);
89
94
  }
90
- } else {
91
- const closestOption = [...options].find(
92
- (option) => option.searchText ? option.searchText.toLocaleLowerCase().startsWith(currentSearch) : option.value.toLocaleLowerCase().startsWith(currentSearch)
93
- );
94
- if (closestOption) {
95
- setDefaultSearch(closestOption.searchText ?? closestOption.value);
96
- } else {
97
- setDefaultSearch(null);
98
- }
99
95
  }
100
96
  }
101
97
  };
@@ -106,7 +102,11 @@ const CreateDropdown = ({
106
102
  loadMore,
107
103
  optionalInfoPlacement,
108
104
  defaultSearchValue,
109
- isLoading
105
+ isLoading,
106
+ groupEmptyState,
107
+ groupError,
108
+ addOption,
109
+ searchable
110
110
  }) => {
111
111
  const {
112
112
  setIsDropdownVisible,
@@ -116,8 +116,11 @@ const CreateDropdown = ({
116
116
  selectAll,
117
117
  selectAllGroup,
118
118
  displayedOptions,
119
+ onSearch,
119
120
  setSelectedData,
120
- selectedData
121
+ selectedData,
122
+ searchInput,
123
+ setSearchInput
121
124
  } = useSelectInput();
122
125
  const focusedItemRef = useRef(null);
123
126
  useEffect(() => {
@@ -125,9 +128,56 @@ const CreateDropdown = ({
125
128
  focusedItemRef.current.focus();
126
129
  }
127
130
  }, [defaultSearchValue]);
128
- if (isEmpty) {
131
+ const handleClickCustomValue = () => {
132
+ const newOption = { label: searchInput, value: searchInput };
133
+ addOption?.onClick(searchInput);
134
+ onSearch([newOption]);
135
+ setIsDropdownVisible(multiselect);
136
+ setSearchInput("");
137
+ };
138
+ if (isEmpty && !addOption) {
129
139
  return /* @__PURE__ */ jsx(Stack, { alignItems: "center", className: dropdownEmptyState, gap: 2, children: emptyState ?? /* @__PURE__ */ jsx(Text, { as: "p", variant: "bodyStrong", children: "No options" }) });
130
140
  }
141
+ if (isEmpty && addOption && searchable) {
142
+ const text = /* @__PURE__ */ jsxs(Stack, { alignItems: "center", direction: "row", gap: "1", children: [
143
+ /* @__PURE__ */ jsx(PlusIcon, { sentiment: "primary", size: "small" }),
144
+ /* @__PURE__ */ jsxs(Text, { as: "span", sentiment: "primary", variant: "bodySmallStrong", children: [
145
+ addOption.text,
146
+ " ",
147
+ searchInput
148
+ ] })
149
+ ] });
150
+ const option = {
151
+ label: text,
152
+ searchText: searchInput,
153
+ value: `${addOption.text} ${searchInput}`
154
+ };
155
+ return /* @__PURE__ */ jsx(
156
+ "div",
157
+ {
158
+ "aria-selected": "false",
159
+ className: comboboxCreate,
160
+ "data-testid": "add-option",
161
+ id: "add-option",
162
+ onClick: handleClickCustomValue,
163
+ onKeyDown: (event) => {
164
+ if (["Enter", " "].includes(event.key)) {
165
+ handleClickCustomValue();
166
+ }
167
+ },
168
+ role: "option",
169
+ tabIndex: -1,
170
+ children: /* @__PURE__ */ jsx(
171
+ DisplayOption,
172
+ {
173
+ descriptionDirection: "row",
174
+ option,
175
+ optionalInfoPlacement: "left"
176
+ }
177
+ )
178
+ }
179
+ );
180
+ }
131
181
  const handleClick = ({
132
182
  clickedOption,
133
183
  group,
@@ -157,7 +207,9 @@ const CreateDropdown = ({
157
207
  onChange([]);
158
208
  } else {
159
209
  const allValues = [];
160
- if (!Array.isArray(options)) {
210
+ if (Array.isArray(options)) {
211
+ options.map((option) => allValues.push(option));
212
+ } else {
161
213
  Object.keys(options).map(
162
214
  (group) => options[group].map((option) => {
163
215
  if (!option.disabled) {
@@ -166,8 +218,6 @@ const CreateDropdown = ({
166
218
  return null;
167
219
  })
168
220
  );
169
- } else {
170
- options.map((option) => allValues.push(option));
171
221
  }
172
222
  onChange?.(allValues.map((value) => value.value));
173
223
  }
@@ -192,208 +242,51 @@ const CreateDropdown = ({
192
242
  }
193
243
  }
194
244
  };
195
- return !Array.isArray(displayedOptions) ? /* @__PURE__ */ jsxs(
245
+ return Array.isArray(displayedOptions) ? /* @__PURE__ */ jsxs(
196
246
  Stack,
197
247
  {
198
- className: dropdownContainer,
199
- "data-grouped": true,
248
+ className: cn(dropdownContainer, dropdownContainerUnGrouped),
249
+ gap: 0.25,
200
250
  id: "select-dropdown",
201
251
  onKeyDown: handleKeyDownSelect,
202
252
  role: "listbox",
203
253
  children: [
204
- isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
205
- selectAll && multiselect ? /* @__PURE__ */ jsx(Stack, { id: "items", children: /* @__PURE__ */ jsx(
206
- "div",
207
- {
208
- "aria-disabled": false,
209
- "aria-label": "select-all",
210
- "aria-selected": selectedData.allSelected,
211
- className: cn(
212
- dropdownItem({ selected: selectedData.allSelected })
213
- ),
214
- "data-testid": "select-all",
215
- id: "select-all",
216
- onClick: selectAllOptions,
217
- onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? selectAllOptions() : null,
218
- role: "option",
219
- tabIndex: 0,
220
- children: /* @__PURE__ */ jsx(
221
- Checkbox,
222
- {
223
- checked: selectedData.allSelected,
224
- className: dropdownCheckbox,
225
- "data-testid": "select-all-checkbox",
226
- disabled: false,
227
- name: "select-all",
228
- onChange: selectAllOptions,
229
- tabIndex: -1,
230
- value: "select-all",
231
- children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
232
- /* @__PURE__ */ jsx(Text, { as: "span", placement: "left", variant: "body", children: selectAll.label }),
233
- /* @__PURE__ */ jsx(
234
- Text,
235
- {
236
- as: "span",
237
- placement: "left",
238
- prominence: "weak",
239
- sentiment: "neutral",
240
- variant: "bodySmall",
241
- children: selectAll.description
242
- }
243
- )
244
- ] })
245
- }
246
- )
247
- }
248
- ) }) : null,
249
- Object.keys(displayedOptions).map((group, index) => /* @__PURE__ */ jsxs(Stack, { gap: 0.25, children: [
250
- displayedOptions[group].length > 0 ? /* @__PURE__ */ jsx(
251
- "div",
252
- {
253
- className: dropdownGroupWrapper,
254
- id: selectAllGroup ? "items" : void 0,
255
- children: group ? /* @__PURE__ */ jsx(
256
- "button",
257
- {
258
- className: cn(
259
- selectAllGroup ? dropdownGroupSelectable : "",
260
- dropdownGroup
261
- ),
262
- "data-selectgroup": selectAllGroup,
263
- "data-testid": `group-${index}`,
264
- onClick: () => selectAllGroup ? handleSelectGroup(group) : null,
265
- onKeyDown: (event) => {
266
- if ([" ", "Enter"].includes(event.key)) {
267
- event.preventDefault();
268
- handleSelectGroup(group);
269
- }
270
- },
271
- role: "group",
272
- tabIndex: selectAllGroup ? 0 : -1,
273
- type: "button",
274
- children: selectAllGroup ? /* @__PURE__ */ jsx(
275
- Checkbox,
276
- {
277
- checked: selectedData.selectedGroups.includes(group),
278
- className: dropdownCheckbox,
279
- "data-testid": "select-group",
280
- disabled: false,
281
- onChange: () => selectAllGroup ? handleSelectGroup(group) : null,
282
- tabIndex: -1,
283
- value: group,
284
- children: /* @__PURE__ */ jsx(
285
- Text,
286
- {
287
- as: "span",
288
- placement: "left",
289
- sentiment: "neutral",
290
- variant: "caption",
291
- children: group.toUpperCase()
292
- }
293
- )
294
- }
295
- ) : /* @__PURE__ */ jsx(
296
- Text,
297
- {
298
- as: "span",
299
- placement: "left",
300
- sentiment: "neutral",
301
- variant: "caption",
302
- children: group.toUpperCase()
303
- }
304
- )
305
- },
306
- group
307
- ) : null
254
+ addOption && searchInput && searchable ? /* @__PURE__ */ jsx(
255
+ "div",
256
+ {
257
+ "aria-selected": "false",
258
+ className: comboboxCreate,
259
+ "data-testid": "add-option",
260
+ id: "add-option",
261
+ onClick: handleClickCustomValue,
262
+ onKeyDown: (event) => {
263
+ if (["Enter", " "].includes(event.key)) {
264
+ handleClickCustomValue();
308
265
  }
309
- ) : null,
310
- /* @__PURE__ */ jsx(Stack, { gap: "0.25", id: "items", children: displayedOptions[group].map((option, indexOption) => /* @__PURE__ */ jsx(
311
- "div",
266
+ },
267
+ role: "option",
268
+ tabIndex: -1,
269
+ children: /* @__PURE__ */ jsx(
270
+ DisplayOption,
312
271
  {
313
- "aria-disabled": !!option.disabled,
314
- "aria-label": option.value,
315
- "aria-selected": selectedData.selectedValues.includes(option.value) && !option.disabled,
316
- className: cn(
317
- dropdownItem({
318
- disabled: !!option.disabled,
319
- selected: selectedData.selectedValues.includes(option.value) && !option.disabled
320
- })
321
- ),
322
- "data-testid": `option-${option.value}`,
323
- id: `option-${indexOption}`,
324
- onClick: (event) => {
325
- if (!option.disabled) {
326
- handleClick({
327
- clickedOption: option,
328
- event,
329
- group
330
- });
331
- }
272
+ descriptionDirection: "row",
273
+ option: {
274
+ label: /* @__PURE__ */ jsxs(Stack, { alignItems: "center", direction: "row", gap: "1", children: [
275
+ /* @__PURE__ */ jsx(PlusIcon, { sentiment: "primary", size: "small" }),
276
+ /* @__PURE__ */ jsxs(Text, { as: "span", sentiment: "primary", variant: "bodySmallStrong", children: [
277
+ addOption.text,
278
+ " ",
279
+ searchInput
280
+ ] })
281
+ ] }),
282
+ searchText: searchInput,
283
+ value: `${addOption.text} ${searchInput}`
332
284
  },
333
- onKeyDown: (event) => {
334
- const shouldClick = [" ", "Enter"].includes(event.key);
335
- if (shouldClick) {
336
- handleClick({
337
- clickedOption: option,
338
- event,
339
- group
340
- });
341
- }
342
- },
343
- ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null,
344
- role: "option",
345
- tabIndex: !option.disabled ? 0 : -1,
346
- children: multiselect ? /* @__PURE__ */ jsx(
347
- Checkbox,
348
- {
349
- checked: selectedData.selectedValues.includes(option.value) && !option.disabled,
350
- className: dropdownCheckbox,
351
- disabled: option.disabled,
352
- onChange: (event) => {
353
- if (!option.disabled) {
354
- handleClick({
355
- clickedOption: option,
356
- event,
357
- group
358
- });
359
- }
360
- },
361
- tabIndex: -1,
362
- value: option.value,
363
- children: /* @__PURE__ */ jsx(
364
- DisplayOption,
365
- {
366
- descriptionDirection,
367
- option,
368
- optionalInfoPlacement
369
- }
370
- )
371
- }
372
- ) : /* @__PURE__ */ jsx(
373
- DisplayOption,
374
- {
375
- descriptionDirection,
376
- option,
377
- optionalInfoPlacement
378
- }
379
- )
380
- },
381
- option.value
382
- )) })
383
- ] }, group))
384
- ] }),
385
- loadMore ? /* @__PURE__ */ jsx(Stack, { className: dropdownLoadMore, children: loadMore }) : null
386
- ]
387
- }
388
- ) : /* @__PURE__ */ jsxs(
389
- Stack,
390
- {
391
- className: cn(dropdownContainer, dropdownContainerUnGrouped),
392
- gap: 0.25,
393
- id: "select-dropdown",
394
- onKeyDown: handleKeyDownSelect,
395
- role: "listbox",
396
- children: [
285
+ optionalInfoPlacement: "left"
286
+ }
287
+ )
288
+ }
289
+ ) : null,
397
290
  selectAll && multiselect ? /* @__PURE__ */ jsx(Stack, { gap: 0.25, id: "items", tabIndex: -1, children: /* @__PURE__ */ jsx(
398
291
  "div",
399
292
  {
@@ -468,7 +361,7 @@ const CreateDropdown = ({
468
361
  },
469
362
  ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null,
470
363
  role: "option",
471
- tabIndex: !option.disabled ? 0 : -1,
364
+ tabIndex: option.disabled ? -1 : 0,
472
365
  children: multiselect ? /* @__PURE__ */ jsx(
473
366
  Checkbox,
474
367
  {
@@ -509,6 +402,282 @@ const CreateDropdown = ({
509
402
  ] })
510
403
  ]
511
404
  }
405
+ ) : /* @__PURE__ */ jsxs(
406
+ Stack,
407
+ {
408
+ className: dropdownContainer,
409
+ "data-grouped": true,
410
+ id: "select-dropdown",
411
+ onKeyDown: handleKeyDownSelect,
412
+ role: "listbox",
413
+ children: [
414
+ isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
415
+ addOption && searchInput && searchable ? /* @__PURE__ */ jsx(
416
+ "div",
417
+ {
418
+ "aria-selected": "false",
419
+ className: comboboxCreate,
420
+ "data-testid": "add-option",
421
+ id: "add-option",
422
+ onClick: handleClickCustomValue,
423
+ onKeyDown: (event) => {
424
+ if (["Enter", " "].includes(event.key)) {
425
+ handleClickCustomValue();
426
+ }
427
+ },
428
+ role: "option",
429
+ tabIndex: -1,
430
+ children: /* @__PURE__ */ jsx(
431
+ DisplayOption,
432
+ {
433
+ descriptionDirection: "row",
434
+ option: {
435
+ label: /* @__PURE__ */ jsxs(Stack, { alignItems: "center", direction: "row", gap: "1", children: [
436
+ /* @__PURE__ */ jsx(PlusIcon, { sentiment: "primary", size: "small" }),
437
+ /* @__PURE__ */ jsxs(
438
+ Text,
439
+ {
440
+ as: "span",
441
+ sentiment: "primary",
442
+ variant: "bodySmallStrong",
443
+ children: [
444
+ addOption.text,
445
+ " ",
446
+ searchInput
447
+ ]
448
+ }
449
+ )
450
+ ] }),
451
+ searchText: searchInput,
452
+ value: `${addOption.text} ${searchInput}`
453
+ },
454
+ optionalInfoPlacement: "left"
455
+ }
456
+ )
457
+ }
458
+ ) : null,
459
+ selectAll && multiselect ? /* @__PURE__ */ jsx(Stack, { id: "items", children: /* @__PURE__ */ jsx(
460
+ "div",
461
+ {
462
+ "aria-disabled": false,
463
+ "aria-label": "select-all",
464
+ "aria-selected": selectedData.allSelected,
465
+ className: cn(
466
+ dropdownItem({ selected: selectedData.allSelected })
467
+ ),
468
+ "data-testid": "select-all",
469
+ id: "select-all",
470
+ onClick: selectAllOptions,
471
+ onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? selectAllOptions() : null,
472
+ role: "option",
473
+ tabIndex: 0,
474
+ children: /* @__PURE__ */ jsx(
475
+ Checkbox,
476
+ {
477
+ checked: selectedData.allSelected,
478
+ className: dropdownCheckbox,
479
+ "data-testid": "select-all-checkbox",
480
+ disabled: false,
481
+ name: "select-all",
482
+ onChange: selectAllOptions,
483
+ tabIndex: -1,
484
+ value: "select-all",
485
+ children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
486
+ /* @__PURE__ */ jsx(Text, { as: "span", placement: "left", variant: "body", children: selectAll.label }),
487
+ /* @__PURE__ */ jsx(
488
+ Text,
489
+ {
490
+ as: "span",
491
+ placement: "left",
492
+ prominence: "weak",
493
+ sentiment: "neutral",
494
+ variant: "bodySmall",
495
+ children: selectAll.description
496
+ }
497
+ )
498
+ ] })
499
+ }
500
+ )
501
+ }
502
+ ) }) : null,
503
+ Object.keys(displayedOptions).map((group, index) => {
504
+ const hasElements = displayedOptions[group].length > 0;
505
+ const emptyStateGroup = groupEmptyState?.[group] ?? null;
506
+ const errorGroup = groupError?.[group] ?? null;
507
+ return /* @__PURE__ */ jsxs(Stack, { gap: 0.25, children: [
508
+ hasElements || emptyStateGroup ? /* @__PURE__ */ jsx(
509
+ "div",
510
+ {
511
+ className: dropdownGroupWrapper,
512
+ id: selectAllGroup ? "items" : void 0,
513
+ children: group ? (
514
+ // biome-ignore lint/a11y/noInteractiveElementToNoninteractiveRole: to fix
515
+ /* @__PURE__ */ jsx(
516
+ "button",
517
+ {
518
+ className: cn(
519
+ selectAllGroup ? dropdownGroupSelectable : "",
520
+ dropdownGroup
521
+ ),
522
+ "data-selectgroup": selectAllGroup,
523
+ "data-testid": `group-${index}`,
524
+ onClick: () => selectAllGroup ? handleSelectGroup(group) : null,
525
+ onKeyDown: (event) => {
526
+ if ([" ", "Enter"].includes(event.key)) {
527
+ event.preventDefault();
528
+ handleSelectGroup(group);
529
+ }
530
+ },
531
+ role: "group",
532
+ tabIndex: selectAllGroup ? 0 : -1,
533
+ type: "button",
534
+ children: selectAllGroup ? /* @__PURE__ */ jsx(
535
+ Checkbox,
536
+ {
537
+ checked: selectedData.selectedGroups.includes(
538
+ group
539
+ ),
540
+ className: dropdownCheckbox,
541
+ "data-testid": "select-group",
542
+ disabled: false,
543
+ onChange: () => selectAllGroup ? handleSelectGroup(group) : null,
544
+ tabIndex: -1,
545
+ value: group,
546
+ children: /* @__PURE__ */ jsx(
547
+ Text,
548
+ {
549
+ as: "span",
550
+ placement: "left",
551
+ sentiment: "neutral",
552
+ variant: "caption",
553
+ children: group.toUpperCase()
554
+ }
555
+ )
556
+ }
557
+ ) : /* @__PURE__ */ jsx(
558
+ Text,
559
+ {
560
+ as: "span",
561
+ placement: "left",
562
+ sentiment: "neutral",
563
+ variant: "caption",
564
+ children: group.toUpperCase()
565
+ }
566
+ )
567
+ },
568
+ group
569
+ )
570
+ ) : null
571
+ }
572
+ ) : null,
573
+ /* @__PURE__ */ jsxs(Stack, { gap: "0.25", id: "items", children: [
574
+ hasElements ? null : /* @__PURE__ */ jsx(
575
+ Text,
576
+ {
577
+ as: "span",
578
+ className: emptyStateGroupStyle,
579
+ prominence: "weak",
580
+ sentiment: "neutral",
581
+ variant: "body",
582
+ children: emptyStateGroup
583
+ }
584
+ ),
585
+ errorGroup ? /* @__PURE__ */ jsx(
586
+ Text,
587
+ {
588
+ as: "span",
589
+ className: emptyStateGroupStyle,
590
+ sentiment: "danger",
591
+ variant: "body",
592
+ children: errorGroup
593
+ }
594
+ ) : null,
595
+ displayedOptions[group].map(
596
+ (option, indexOption) => errorGroup ? null : /* @__PURE__ */ jsx(
597
+ "div",
598
+ {
599
+ "aria-disabled": !!option.disabled,
600
+ "aria-label": option.value,
601
+ "aria-selected": selectedData.selectedValues.includes(option.value) && !option.disabled,
602
+ className: cn(
603
+ dropdownItem({
604
+ disabled: !!option.disabled,
605
+ selected: selectedData.selectedValues.includes(
606
+ option.value
607
+ ) && !option.disabled
608
+ })
609
+ ),
610
+ "data-testid": `option-${option.value}`,
611
+ id: `option-${indexOption}`,
612
+ onClick: (event) => {
613
+ if (!option.disabled) {
614
+ handleClick({
615
+ clickedOption: option,
616
+ event,
617
+ group
618
+ });
619
+ }
620
+ },
621
+ onKeyDown: (event) => {
622
+ const shouldClick = [" ", "Enter"].includes(event.key);
623
+ if (shouldClick) {
624
+ handleClick({
625
+ clickedOption: option,
626
+ event,
627
+ group
628
+ });
629
+ }
630
+ },
631
+ ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null,
632
+ role: "option",
633
+ tabIndex: option.disabled ? -1 : 0,
634
+ children: multiselect ? /* @__PURE__ */ jsx(
635
+ Checkbox,
636
+ {
637
+ checked: selectedData.selectedValues.includes(
638
+ option.value
639
+ ) && !option.disabled,
640
+ className: dropdownCheckbox,
641
+ disabled: option.disabled,
642
+ onChange: (event) => {
643
+ if (!option.disabled) {
644
+ handleClick({
645
+ clickedOption: option,
646
+ event,
647
+ group
648
+ });
649
+ }
650
+ },
651
+ tabIndex: -1,
652
+ value: option.value,
653
+ children: /* @__PURE__ */ jsx(
654
+ DisplayOption,
655
+ {
656
+ descriptionDirection,
657
+ option,
658
+ optionalInfoPlacement
659
+ }
660
+ )
661
+ }
662
+ ) : /* @__PURE__ */ jsx(
663
+ DisplayOption,
664
+ {
665
+ descriptionDirection,
666
+ option,
667
+ optionalInfoPlacement
668
+ }
669
+ )
670
+ },
671
+ option.value
672
+ )
673
+ )
674
+ ] })
675
+ ] }, group);
676
+ })
677
+ ] }),
678
+ loadMore ? /* @__PURE__ */ jsx(Stack, { className: dropdownLoadMore, children: loadMore }) : null
679
+ ]
680
+ }
512
681
  );
513
682
  };
514
683
  const Dropdown = ({
@@ -525,7 +694,10 @@ const Dropdown = ({
525
694
  size,
526
695
  dropdownAlign,
527
696
  portalTarget,
528
- id
697
+ id,
698
+ groupError,
699
+ groupEmptyState,
700
+ addOption
529
701
  }) => {
530
702
  const {
531
703
  setIsDropdownVisible,
@@ -666,7 +838,7 @@ const Dropdown = ({
666
838
  }),
667
839
  tabIndex: -1,
668
840
  text: /* @__PURE__ */ jsxs(Stack, { children: [
669
- searchable && !isLoading && numberOfOptions >= 6 ? /* @__PURE__ */ jsx(
841
+ searchable && !isLoading && (numberOfOptions >= 6 || addOption) ? /* @__PURE__ */ jsx(
670
842
  SearchBarDropdown,
671
843
  {
672
844
  displayedOptions,
@@ -677,13 +849,17 @@ const Dropdown = ({
677
849
  /* @__PURE__ */ jsx(
678
850
  CreateDropdown,
679
851
  {
852
+ addOption,
680
853
  defaultSearchValue,
681
854
  descriptionDirection,
682
855
  emptyState,
856
+ groupEmptyState,
857
+ groupError,
683
858
  isEmpty,
684
859
  isLoading,
685
860
  loadMore,
686
- optionalInfoPlacement
861
+ optionalInfoPlacement,
862
+ searchable
687
863
  }
688
864
  ),
689
865
  computedFooter