@ultraviolet/ui 3.4.0 → 3.5.0

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 (200) 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 -5
  6. package/dist/components/Avatar/variables.css.js +1 -0
  7. package/dist/components/Badge/styles.css.d.ts +28 -28
  8. package/dist/components/Badge/styles.css.js +1 -1
  9. package/dist/components/Banner/index.js +1 -1
  10. package/dist/components/Banner/styles.css.d.ts +2 -2
  11. package/dist/components/Banner/styles.css.js +2 -2
  12. package/dist/components/BarStack/styles.css.d.ts +7 -7
  13. package/dist/components/BarStack/styles.css.js +1 -1
  14. package/dist/components/Bullet/styles.css.d.ts +13 -13
  15. package/dist/components/Bullet/styles.css.js +1 -1
  16. package/dist/components/Button/index.d.ts +2 -2
  17. package/dist/components/Button/index.d.ts.map +1 -1
  18. package/dist/components/Button/styles.css.d.ts +39 -39
  19. package/dist/components/Button/styles.css.js +1 -1
  20. package/dist/components/Checkbox/index.js +4 -4
  21. package/dist/components/Chip/ChipIcon.d.ts.map +1 -1
  22. package/dist/components/Chip/ChipIcon.js +4 -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 +31 -31
  46. package/dist/components/Link/styles.css.js +1 -1
  47. package/dist/components/List/ListContext.d.ts +2 -2
  48. package/dist/components/List/ListContext.d.ts.map +1 -1
  49. package/dist/components/List/Row.d.ts +1 -1
  50. package/dist/components/List/Row.d.ts.map +1 -1
  51. package/dist/components/List/SelectBar.d.ts +1 -1
  52. package/dist/components/List/SelectBar.d.ts.map +1 -1
  53. package/dist/components/List/SkeletonRows.d.ts.map +1 -1
  54. package/dist/components/List/index.d.ts +2 -2
  55. package/dist/components/List/index.d.ts.map +1 -1
  56. package/dist/components/List/styles.css.d.ts +3 -3
  57. package/dist/components/List/styles.css.js +1 -1
  58. package/dist/components/Menu/styles.css.js +1 -1
  59. package/dist/components/Modal/ModalContent.d.ts.map +1 -1
  60. package/dist/components/Modal/components/Dialog.d.ts.map +1 -1
  61. package/dist/components/Modal/components/Dialog.js +1 -1
  62. package/dist/components/Modal/index.js +3 -3
  63. package/dist/components/Modal/styles.css.d.ts +17 -17
  64. package/dist/components/Modal/styles.css.js +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.map +1 -1
  90. package/dist/components/SelectInput/components/Dropdown.js +194 -191
  91. package/dist/components/SelectInput/components/SearchBarDropdown.js +15 -15
  92. package/dist/components/SelectInput/components/SelectBar.js +7 -7
  93. package/dist/components/SelectInput/components/dropdown.css.d.ts +5 -5
  94. package/dist/components/SelectInput/components/dropdown.css.js +1 -1
  95. package/dist/components/SelectInput/components/selectBar.css.d.ts +43 -43
  96. package/dist/components/SelectInput/components/selectBar.css.d.ts.map +1 -1
  97. package/dist/components/SelectInput/components/selectBar.css.js +2 -2
  98. package/dist/components/SelectInput/findOptionInOptions.js +3 -3
  99. package/dist/components/SelectInput/index.d.ts.map +1 -1
  100. package/dist/components/SelectInput/index.js +1 -1
  101. package/dist/components/SelectableCard/index.d.ts.map +1 -1
  102. package/dist/components/SelectableCard/index.js +8 -5
  103. package/dist/components/SelectableCard/styles.css.d.ts +9 -9
  104. package/dist/components/SelectableCard/styles.css.js +3 -2
  105. package/dist/components/SelectableCard/variables.css.js +0 -1
  106. package/dist/components/Separator/index.d.ts.map +1 -1
  107. package/dist/components/Separator/index.js +33 -31
  108. package/dist/components/Skeleton/Block.d.ts.map +1 -1
  109. package/dist/components/Skeleton/Block.js +7 -4
  110. package/dist/components/Skeleton/Blocks.d.ts.map +1 -1
  111. package/dist/components/Skeleton/Blocks.js +7 -4
  112. package/dist/components/Skeleton/BoxWithIcon.d.ts.map +1 -1
  113. package/dist/components/Skeleton/BoxWithIcon.js +7 -4
  114. package/dist/components/Skeleton/List.d.ts.map +1 -1
  115. package/dist/components/Skeleton/List.js +8 -2
  116. package/dist/components/Skeleton/Slider.d.ts.map +1 -1
  117. package/dist/components/Skeleton/Slider.js +4 -1
  118. package/dist/components/Skeleton/index.d.ts.map +1 -1
  119. package/dist/components/Skeleton/index.js +17 -14
  120. package/dist/components/Slider/components/DoubleSlider.js +10 -10
  121. package/dist/components/Slider/components/SingleSlider.js +1 -1
  122. package/dist/components/Slider/styles.css.d.ts +47 -43
  123. package/dist/components/Slider/styles.css.d.ts.map +1 -1
  124. package/dist/components/Slider/styles.css.js +5 -5
  125. package/dist/components/Snippet/index.js +1 -1
  126. package/dist/components/Snippet/styles.css.d.ts +12 -12
  127. package/dist/components/Snippet/styles.css.js +7 -7
  128. package/dist/components/Stack/styles.css.d.ts +87 -87
  129. package/dist/components/Stack/styles.css.js +4 -4
  130. package/dist/components/Status/styles.css.d.ts +1 -1
  131. package/dist/components/StepList/styles.css.d.ts +7 -7
  132. package/dist/components/StepList/styles.css.js +2 -2
  133. package/dist/components/Stepper/index.d.ts.map +1 -1
  134. package/dist/components/Stepper/index.js +13 -10
  135. package/dist/components/Stepper/styles.css.d.ts +45 -45
  136. package/dist/components/Stepper/styles.css.js +6 -6
  137. package/dist/components/SwitchButton/index.js +3 -3
  138. package/dist/components/SwitchButton/styles.css.js +3 -3
  139. package/dist/components/Table/HeaderRow.d.ts.map +1 -1
  140. package/dist/components/Table/HeaderRow.js +25 -22
  141. package/dist/components/Table/Row.d.ts +1 -1
  142. package/dist/components/Table/Row.d.ts.map +1 -1
  143. package/dist/components/Table/SelectBar.d.ts +1 -1
  144. package/dist/components/Table/SelectBar.d.ts.map +1 -1
  145. package/dist/components/Table/SkeletonRows.d.ts.map +1 -1
  146. package/dist/components/Table/index.d.ts +4 -4
  147. package/dist/components/Table/index.d.ts.map +1 -1
  148. package/dist/components/Table/styles.css.d.ts +21 -21
  149. package/dist/components/Table/styles.css.js +2 -2
  150. package/dist/components/Tabs/Tab.js +1 -1
  151. package/dist/components/Tabs/styles.css.js +1 -1
  152. package/dist/components/Tag/styles.css.d.ts +10 -10
  153. package/dist/components/Tag/styles.css.js +1 -1
  154. package/dist/components/TagInput/index.js +5 -5
  155. package/dist/components/TagInput/styles.css.d.ts +4 -4
  156. package/dist/components/TagInput/styles.css.js +1 -1
  157. package/dist/components/TagList/index.d.ts.map +1 -1
  158. package/dist/components/TagList/index.js +1 -1
  159. package/dist/components/Text/style.css.d.ts +26 -26
  160. package/dist/components/Text/style.css.d.ts.map +1 -1
  161. package/dist/components/Text/style.css.js +1 -2
  162. package/dist/components/Text/variables.css.js +1 -0
  163. package/dist/components/TextArea/index.d.ts.map +1 -1
  164. package/dist/components/TextArea/index.js +14 -7
  165. package/dist/components/TextArea/styles.css.d.ts +2 -2
  166. package/dist/components/TextArea/styles.css.js +1 -1
  167. package/dist/components/TextInput/index.js +2 -2
  168. package/dist/components/TimeInput/helpers.d.ts.map +1 -1
  169. package/dist/components/TimeInput/helpers.js +2 -1
  170. package/dist/components/TimeInput/index.js +4 -4
  171. package/dist/components/TimeInput/styles.css.d.ts +22 -22
  172. package/dist/components/TimeInput/styles.css.js +1 -1
  173. package/dist/components/Toaster/constants.d.ts.map +1 -1
  174. package/dist/components/Toggle/styles.css.d.ts +53 -53
  175. package/dist/components/Toggle/styles.css.js +2 -2
  176. package/dist/components/TreeMapChart/index.d.ts +1 -1
  177. package/dist/components/TreeMapChart/index.d.ts.map +1 -1
  178. package/dist/components/TreeMapChart/index.js +39 -42
  179. package/dist/components/TreeMapChart/styles.css.d.ts +1 -1
  180. package/dist/components/TreeMapChart/styles.css.d.ts.map +1 -1
  181. package/dist/components/TreeMapChart/styles.css.js +2 -2
  182. package/dist/components/UnitInput/index.js +1 -1
  183. package/dist/components/UnitInput/styles.css.js +3 -3
  184. package/dist/components/VerificationCode/index.d.ts.map +1 -1
  185. package/dist/components/VerificationCode/index.js +2 -2
  186. package/dist/components/VerificationCode/styles.css.js +1 -1
  187. package/dist/components/compositions/OptionSelector/index.d.ts.map +1 -1
  188. package/dist/components/compositions/OptionSelector/index.js +91 -59
  189. package/dist/components/compositions/OptionSelector/styles.css.d.ts +2 -0
  190. package/dist/components/compositions/OptionSelector/styles.css.d.ts.map +1 -1
  191. package/dist/components/compositions/OptionSelector/styles.css.js +4 -0
  192. package/dist/helpers/treeMap.d.ts +4 -5
  193. package/dist/helpers/treeMap.d.ts.map +1 -1
  194. package/dist/helpers/treeMap.js +7 -5
  195. package/dist/theme/ThemeProvider.d.ts +33 -0
  196. package/dist/theme/ThemeProvider.d.ts.map +1 -1
  197. package/dist/theme/index.d.ts +33 -0
  198. package/dist/theme/index.d.ts.map +1 -1
  199. package/dist/ui.css +1 -1
  200. package/package.json +6 -6
@@ -13,7 +13,7 @@ import { Text } from "../../Text/index.js";
13
13
  import { useSelectInput } from "../SelectInputProvider.js";
14
14
  import { INPUT_SIZE_HEIGHT } from "../types.js";
15
15
  import { DisplayOption } from "./DropdownOption.js";
16
- import { footer, dropdown, dropdownWidth, dropdownEmptyState, dropdownContainer, dropdownCheckbox, dropdownItem, dropdownGroupWrapper, dropdownGroupSelectable, dropdownGroup, dropdownLoadMore, dropdownContainerUnGrouped } from "./dropdown.css.js";
16
+ import { footer, dropdown, dropdownWidth, dropdownEmptyState, dropdownCheckbox, dropdownItem, dropdownLoadMore, dropdownContainer, dropdownContainerUnGrouped, dropdownGroupWrapper, dropdownGroupSelectable, dropdownGroup } from "./dropdown.css.js";
17
17
  import { SearchBarDropdown } from "./SearchBarDropdown.js";
18
18
  const DROPDOWN_MAX_HEIGHT = 256;
19
19
  const NON_SEARCHABLE_KEYS = [
@@ -73,7 +73,16 @@ const handleKeyDown = (event, ref, options, searchBarActive, setSearch, setDefau
73
73
  const currentSearch = search + event.key;
74
74
  setSearch(currentSearch);
75
75
  ref.current.focus();
76
- if (!Array.isArray(options)) {
76
+ if (Array.isArray(options)) {
77
+ const closestOption = [...options].find(
78
+ (option) => option.searchText ? option.searchText.toLocaleLowerCase().startsWith(currentSearch) : option.value.toLocaleLowerCase().startsWith(currentSearch)
79
+ );
80
+ if (closestOption) {
81
+ setDefaultSearch(closestOption.searchText ?? closestOption.value);
82
+ } else {
83
+ setDefaultSearch(null);
84
+ }
85
+ } else {
77
86
  const closestOptions = { ...options };
78
87
  Object.keys(closestOptions).map((group) => {
79
88
  closestOptions[group] = closestOptions[group].filter(
@@ -87,15 +96,6 @@ const handleKeyDown = (event, ref, options, searchBarActive, setSearch, setDefau
87
96
  } else {
88
97
  setDefaultSearch(null);
89
98
  }
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
99
  }
100
100
  }
101
101
  };
@@ -157,7 +157,9 @@ const CreateDropdown = ({
157
157
  onChange([]);
158
158
  } else {
159
159
  const allValues = [];
160
- if (!Array.isArray(options)) {
160
+ if (Array.isArray(options)) {
161
+ options.map((option) => allValues.push(option));
162
+ } else {
161
163
  Object.keys(options).map(
162
164
  (group) => options[group].map((option) => {
163
165
  if (!option.disabled) {
@@ -166,8 +168,6 @@ const CreateDropdown = ({
166
168
  return null;
167
169
  })
168
170
  );
169
- } else {
170
- options.map((option) => allValues.push(option));
171
171
  }
172
172
  onChange?.(allValues.map((value) => value.value));
173
173
  }
@@ -192,7 +192,131 @@ const CreateDropdown = ({
192
192
  }
193
193
  }
194
194
  };
195
- return !Array.isArray(displayedOptions) ? /* @__PURE__ */ jsxs(
195
+ return Array.isArray(displayedOptions) ? /* @__PURE__ */ jsxs(
196
+ Stack,
197
+ {
198
+ className: cn(dropdownContainer, dropdownContainerUnGrouped),
199
+ gap: 0.25,
200
+ id: "select-dropdown",
201
+ onKeyDown: handleKeyDownSelect,
202
+ role: "listbox",
203
+ children: [
204
+ selectAll && multiselect ? /* @__PURE__ */ jsx(Stack, { gap: 0.25, id: "items", tabIndex: -1, children: /* @__PURE__ */ jsx(
205
+ "div",
206
+ {
207
+ "aria-disabled": false,
208
+ "aria-label": "select-all",
209
+ "aria-selected": selectedData.allSelected,
210
+ className: cn(dropdownItem({ selected: selectedData.allSelected })),
211
+ "data-testid": "select-all",
212
+ onClick: selectAllOptions,
213
+ onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? selectAllOptions() : null,
214
+ role: "option",
215
+ tabIndex: 0,
216
+ children: /* @__PURE__ */ jsx(
217
+ Checkbox,
218
+ {
219
+ checked: selectedData.allSelected,
220
+ className: dropdownCheckbox,
221
+ "data-testid": "select-all-checkbox",
222
+ disabled: false,
223
+ onChange: selectAllOptions,
224
+ tabIndex: -1,
225
+ value: "select-all",
226
+ children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
227
+ /* @__PURE__ */ jsx(Text, { as: "span", placement: "left", variant: "body", children: selectAll.label }),
228
+ /* @__PURE__ */ jsx(
229
+ Text,
230
+ {
231
+ as: "span",
232
+ placement: "left",
233
+ prominence: "weak",
234
+ sentiment: "neutral",
235
+ variant: "bodySmall",
236
+ children: selectAll.description
237
+ }
238
+ )
239
+ ] })
240
+ }
241
+ )
242
+ }
243
+ ) }) : null,
244
+ /* @__PURE__ */ jsxs(Stack, { gap: 0.25, id: "items", children: [
245
+ isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block" }) : displayedOptions.map((option, index) => /* @__PURE__ */ jsx(
246
+ "div",
247
+ {
248
+ "aria-disabled": !!option.disabled,
249
+ "aria-label": option.value,
250
+ "aria-selected": selectedData.selectedValues.includes(option.value) && !option.disabled,
251
+ className: cn(
252
+ dropdownItem({
253
+ disabled: !!option.disabled,
254
+ selected: selectedData.selectedValues.includes(option.value) && !option.disabled
255
+ })
256
+ ),
257
+ "data-testid": `option-${option.value}`,
258
+ id: `option-${index}`,
259
+ onClick: (event) => {
260
+ if (!option.disabled) {
261
+ handleClick({
262
+ clickedOption: option,
263
+ event
264
+ });
265
+ }
266
+ },
267
+ onKeyDown: (event) => {
268
+ const shouldClick = [" ", "Enter"].includes(event.key);
269
+ if (shouldClick) {
270
+ handleClick({
271
+ clickedOption: option,
272
+ event
273
+ });
274
+ }
275
+ },
276
+ ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null,
277
+ role: "option",
278
+ tabIndex: option.disabled ? -1 : 0,
279
+ children: multiselect ? /* @__PURE__ */ jsx(
280
+ Checkbox,
281
+ {
282
+ checked: selectedData.selectedValues.includes(option.value) && !option.disabled,
283
+ className: dropdownCheckbox,
284
+ disabled: option.disabled,
285
+ onChange: (event) => {
286
+ if (!option.disabled) {
287
+ handleClick({
288
+ clickedOption: option,
289
+ event
290
+ });
291
+ }
292
+ },
293
+ tabIndex: -1,
294
+ value: option.value,
295
+ children: /* @__PURE__ */ jsx(
296
+ DisplayOption,
297
+ {
298
+ descriptionDirection,
299
+ option,
300
+ optionalInfoPlacement
301
+ }
302
+ )
303
+ }
304
+ ) : /* @__PURE__ */ jsx(
305
+ DisplayOption,
306
+ {
307
+ descriptionDirection,
308
+ option,
309
+ optionalInfoPlacement
310
+ }
311
+ )
312
+ },
313
+ option.value
314
+ )),
315
+ loadMore ? /* @__PURE__ */ jsx(Stack, { className: dropdownLoadMore, children: loadMore }) : null
316
+ ] })
317
+ ]
318
+ }
319
+ ) : /* @__PURE__ */ jsxs(
196
320
  Stack,
197
321
  {
198
322
  className: dropdownContainer,
@@ -252,58 +376,61 @@ const CreateDropdown = ({
252
376
  {
253
377
  className: dropdownGroupWrapper,
254
378
  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
- }
379
+ children: group ? (
380
+ // biome-ignore lint/a11y/noInteractiveElementToNoninteractiveRole: to fix
381
+ /* @__PURE__ */ jsx(
382
+ "button",
383
+ {
384
+ className: cn(
385
+ selectAllGroup ? dropdownGroupSelectable : "",
386
+ dropdownGroup
387
+ ),
388
+ "data-selectgroup": selectAllGroup,
389
+ "data-testid": `group-${index}`,
390
+ onClick: () => selectAllGroup ? handleSelectGroup(group) : null,
391
+ onKeyDown: (event) => {
392
+ if ([" ", "Enter"].includes(event.key)) {
393
+ event.preventDefault();
394
+ handleSelectGroup(group);
395
+ }
396
+ },
397
+ role: "group",
398
+ tabIndex: selectAllGroup ? 0 : -1,
399
+ type: "button",
400
+ children: selectAllGroup ? /* @__PURE__ */ jsx(
401
+ Checkbox,
402
+ {
403
+ checked: selectedData.selectedGroups.includes(group),
404
+ className: dropdownCheckbox,
405
+ "data-testid": "select-group",
406
+ disabled: false,
407
+ onChange: () => selectAllGroup ? handleSelectGroup(group) : null,
408
+ tabIndex: -1,
409
+ value: group,
410
+ children: /* @__PURE__ */ jsx(
411
+ Text,
412
+ {
413
+ as: "span",
414
+ placement: "left",
415
+ sentiment: "neutral",
416
+ variant: "caption",
417
+ children: group.toUpperCase()
418
+ }
419
+ )
420
+ }
421
+ ) : /* @__PURE__ */ jsx(
422
+ Text,
423
+ {
424
+ as: "span",
425
+ placement: "left",
426
+ sentiment: "neutral",
427
+ variant: "caption",
428
+ children: group.toUpperCase()
429
+ }
430
+ )
270
431
  },
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
432
+ group
433
+ )
307
434
  ) : null
308
435
  }
309
436
  ) : null,
@@ -342,7 +469,7 @@ const CreateDropdown = ({
342
469
  },
343
470
  ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null,
344
471
  role: "option",
345
- tabIndex: !option.disabled ? 0 : -1,
472
+ tabIndex: option.disabled ? -1 : 0,
346
473
  children: multiselect ? /* @__PURE__ */ jsx(
347
474
  Checkbox,
348
475
  {
@@ -385,130 +512,6 @@ const CreateDropdown = ({
385
512
  loadMore ? /* @__PURE__ */ jsx(Stack, { className: dropdownLoadMore, children: loadMore }) : null
386
513
  ]
387
514
  }
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: [
397
- selectAll && multiselect ? /* @__PURE__ */ jsx(Stack, { gap: 0.25, id: "items", tabIndex: -1, children: /* @__PURE__ */ jsx(
398
- "div",
399
- {
400
- "aria-disabled": false,
401
- "aria-label": "select-all",
402
- "aria-selected": selectedData.allSelected,
403
- className: cn(dropdownItem({ selected: selectedData.allSelected })),
404
- "data-testid": "select-all",
405
- onClick: selectAllOptions,
406
- onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? selectAllOptions() : null,
407
- role: "option",
408
- tabIndex: 0,
409
- children: /* @__PURE__ */ jsx(
410
- Checkbox,
411
- {
412
- checked: selectedData.allSelected,
413
- className: dropdownCheckbox,
414
- "data-testid": "select-all-checkbox",
415
- disabled: false,
416
- onChange: selectAllOptions,
417
- tabIndex: -1,
418
- value: "select-all",
419
- children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
420
- /* @__PURE__ */ jsx(Text, { as: "span", placement: "left", variant: "body", children: selectAll.label }),
421
- /* @__PURE__ */ jsx(
422
- Text,
423
- {
424
- as: "span",
425
- placement: "left",
426
- prominence: "weak",
427
- sentiment: "neutral",
428
- variant: "bodySmall",
429
- children: selectAll.description
430
- }
431
- )
432
- ] })
433
- }
434
- )
435
- }
436
- ) }) : null,
437
- /* @__PURE__ */ jsxs(Stack, { gap: 0.25, id: "items", children: [
438
- isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block" }) : displayedOptions.map((option, index) => /* @__PURE__ */ jsx(
439
- "div",
440
- {
441
- "aria-disabled": !!option.disabled,
442
- "aria-label": option.value,
443
- "aria-selected": selectedData.selectedValues.includes(option.value) && !option.disabled,
444
- className: cn(
445
- dropdownItem({
446
- disabled: !!option.disabled,
447
- selected: selectedData.selectedValues.includes(option.value) && !option.disabled
448
- })
449
- ),
450
- "data-testid": `option-${option.value}`,
451
- id: `option-${index}`,
452
- onClick: (event) => {
453
- if (!option.disabled) {
454
- handleClick({
455
- clickedOption: option,
456
- event
457
- });
458
- }
459
- },
460
- onKeyDown: (event) => {
461
- const shouldClick = [" ", "Enter"].includes(event.key);
462
- if (shouldClick) {
463
- handleClick({
464
- clickedOption: option,
465
- event
466
- });
467
- }
468
- },
469
- ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null,
470
- role: "option",
471
- tabIndex: !option.disabled ? 0 : -1,
472
- children: multiselect ? /* @__PURE__ */ jsx(
473
- Checkbox,
474
- {
475
- checked: selectedData.selectedValues.includes(option.value) && !option.disabled,
476
- className: dropdownCheckbox,
477
- disabled: option.disabled,
478
- onChange: (event) => {
479
- if (!option.disabled) {
480
- handleClick({
481
- clickedOption: option,
482
- event
483
- });
484
- }
485
- },
486
- tabIndex: -1,
487
- value: option.value,
488
- children: /* @__PURE__ */ jsx(
489
- DisplayOption,
490
- {
491
- descriptionDirection,
492
- option,
493
- optionalInfoPlacement
494
- }
495
- )
496
- }
497
- ) : /* @__PURE__ */ jsx(
498
- DisplayOption,
499
- {
500
- descriptionDirection,
501
- option,
502
- optionalInfoPlacement
503
- }
504
- )
505
- },
506
- option.value
507
- )),
508
- loadMore ? /* @__PURE__ */ jsx(Stack, { className: dropdownLoadMore, children: loadMore }) : null
509
- ] })
510
- ]
511
- }
512
515
  );
513
516
  };
514
517
  const Dropdown = ({
@@ -22,7 +22,12 @@ const searchRegex = (data, query) => data.filter((option) => {
22
22
  });
23
23
  const findClosestOption = (options, searchInput) => {
24
24
  if (searchInput) {
25
- if (!Array.isArray(options)) {
25
+ if (Array.isArray(options)) {
26
+ const possibleOption = [...options].find((option) => !option.disabled);
27
+ if (possibleOption) {
28
+ return possibleOption;
29
+ }
30
+ } else {
26
31
  const possibleOptions = { ...options };
27
32
  Object.keys(possibleOptions).map((group) => {
28
33
  possibleOptions[group] = possibleOptions[group].filter(
@@ -36,11 +41,6 @@ const findClosestOption = (options, searchInput) => {
36
41
  const firstFit = Object.keys(possibleOptions).map((group) => possibleOptions[group][0]).find((value) => !!value);
37
42
  return firstFit;
38
43
  }
39
- } else {
40
- const possibleOption = [...options].find((option) => !option.disabled);
41
- if (possibleOption) {
42
- return possibleOption;
43
- }
44
44
  }
45
45
  }
46
46
  return null;
@@ -64,7 +64,13 @@ const SearchBarDropdown = ({
64
64
  } = useSelectInput();
65
65
  const handleChange = (search) => {
66
66
  if (search.length > 0) {
67
- if (!Array.isArray(options)) {
67
+ if (Array.isArray(options)) {
68
+ const filteredOptions = searchRegex(
69
+ [...options],
70
+ escapeRegExp(search.toString())
71
+ );
72
+ onSearch(filteredOptions);
73
+ } else {
68
74
  const filteredOptions = { ...options };
69
75
  Object.keys(filteredOptions).map((group) => {
70
76
  filteredOptions[group] = searchRegex(
@@ -74,12 +80,6 @@ const SearchBarDropdown = ({
74
80
  return null;
75
81
  });
76
82
  onSearch(filteredOptions);
77
- } else {
78
- const filteredOptions = searchRegex(
79
- [...options],
80
- escapeRegExp(search.toString())
81
- );
82
- onSearch(filteredOptions);
83
83
  }
84
84
  } else {
85
85
  onSearch(options);
@@ -93,9 +93,9 @@ const SearchBarDropdown = ({
93
93
  if (multiselect) {
94
94
  setSelectedData({
95
95
  clickedOption: closestOption,
96
- group: !Array.isArray(options) ? Object.keys(options).find(
96
+ group: Array.isArray(options) ? void 0 : Object.keys(options).find(
97
97
  (group) => options[group].includes(closestOption)
98
- ) : void 0,
98
+ ),
99
99
  type: "selectOption"
100
100
  });
101
101
  onChange?.(
@@ -67,7 +67,7 @@ const DisplayValues = ({
67
67
  className: selectBarTags.visible,
68
68
  "data-testid": "selected-options-tags",
69
69
  disabled,
70
- onClose: !readOnly ? (event) => {
70
+ onClose: readOnly ? void 0 : (event) => {
71
71
  event.stopPropagation();
72
72
  setSelectedData({
73
73
  clickedOption: option,
@@ -77,7 +77,7 @@ const DisplayValues = ({
77
77
  (val) => val !== option.value
78
78
  );
79
79
  onChange?.(newSelectedValues);
80
- } : void 0,
80
+ },
81
81
  sentiment: "neutral",
82
82
  style: index === nonOverflowedValues.length - 1 && overflow ? assignInlineVars({
83
83
  [minWidthTag]: "auto",
@@ -208,10 +208,10 @@ const SelectBar = ({
208
208
  const newAccumulatedWidth = accumulator.accumulatedWidth + elementWidth + SIZES_TAG.gap;
209
209
  const canBeVisible = newAccumulatedWidth <= innerWidth;
210
210
  return {
211
- accumulatedWidth: !canBeVisible ? accumulator.accumulatedWidth : newAccumulatedWidth,
211
+ accumulatedWidth: canBeVisible ? newAccumulatedWidth : accumulator.accumulatedWidth,
212
212
  lastVisibleElementWidth: canBeVisible ? elementWidth : accumulator.lastVisibleElementWidth,
213
213
  lastVisibleLabel: canBeVisible ? potentiallyNonOverflowedValues[index].label : accumulator.lastVisibleLabel,
214
- measuredHiddenTags: accumulator.measuredHiddenTags + (!canBeVisible ? 1 : 0),
214
+ measuredHiddenTags: accumulator.measuredHiddenTags + (canBeVisible ? 0 : 1),
215
215
  measuredVisibleTags: [
216
216
  ...accumulator.measuredVisibleTags,
217
217
  canBeVisible && potentiallyNonOverflowedValues[index]
@@ -300,10 +300,10 @@ const SelectBar = ({
300
300
  onClick: openable ? () => setIsDropdownVisible(!isDropdownVisible) : void 0,
301
301
  onKeyDown: (event) => {
302
302
  if (event.key === "ArrowDown") {
303
- if (!isDropdownVisible) {
304
- setIsDropdownVisible(true);
303
+ if (isDropdownVisible) {
304
+ document.getElementById("option-0")?.focus();
305
305
  } else {
306
- document.getElementById(`option-0`)?.focus();
306
+ setIsDropdownVisible(true);
307
307
  }
308
308
  }
309
309
  if (event.key === " ") {
@@ -7,11 +7,6 @@ export declare const dropdownGroupSelectable: string;
7
7
  export declare const dropdownGroupWrapper: string;
8
8
  export declare const dropdownItemBase: string;
9
9
  export declare const dropdownItem: import("@vanilla-extract/recipes").RuntimeFn<{
10
- selected: {
11
- true: {
12
- backgroundColor: `var(--${string})`;
13
- };
14
- };
15
10
  disabled: {
16
11
  true: {
17
12
  backgroundColor: `var(--${string})`;
@@ -26,6 +21,11 @@ export declare const dropdownItem: import("@vanilla-extract/recipes").RuntimeFn<
26
21
  };
27
22
  };
28
23
  };
24
+ selected: {
25
+ true: {
26
+ backgroundColor: `var(--${string})`;
27
+ };
28
+ };
29
29
  }>;
30
30
  export declare const footer: string;
31
31
  export declare const dropdownCheckbox: string;
@@ -7,7 +7,7 @@ var dropdownContainerUnGrouped = "uv_5kpm8k3";
7
7
  var dropdownGroup = "uv_5kpm8k4";
8
8
  var dropdownGroupSelectable = "uv_5kpm8k5";
9
9
  var dropdownGroupWrapper = "uv_5kpm8k6";
10
- var dropdownItem = createRuntimeFn({ defaultClassName: "uv_5kpm8k8 uv_5kpm8k7", variantClassNames: { selected: { true: "uv_5kpm8k9" }, disabled: { true: "uv_5kpm8ka" } }, defaultVariants: { disabled: false, selected: false }, compoundVariants: [] });
10
+ var dropdownItem = createRuntimeFn({ defaultClassName: "uv_5kpm8k8 uv_5kpm8k7", variantClassNames: { disabled: { true: "uv_5kpm8k9" }, selected: { true: "uv_5kpm8ka" } }, defaultVariants: { disabled: false, selected: false }, compoundVariants: [] });
11
11
  var footer = "uv_5kpm8kb";
12
12
  var dropdownCheckbox = "uv_5kpm8kc";
13
13
  var dropdownEmptyState = "uv_5kpm8kd";