@salt-ds/lab 1.0.0-alpha.30 → 1.0.0-alpha.31

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 (109) hide show
  1. package/css/salt-lab.css +101 -160
  2. package/dist-cjs/combo-box-next/ComboBoxNext.js +288 -290
  3. package/dist-cjs/combo-box-next/ComboBoxNext.js.map +1 -1
  4. package/dist-cjs/combo-box-next/useComboBoxNext.js.map +1 -1
  5. package/dist-cjs/content-status/internal/StatusIndicator.js +1 -3
  6. package/dist-cjs/content-status/internal/StatusIndicator.js.map +1 -1
  7. package/dist-cjs/dialog/Dialog.css.js +1 -1
  8. package/dist-cjs/dialog/Dialog.js +53 -48
  9. package/dist-cjs/dialog/Dialog.js.map +1 -1
  10. package/dist-cjs/dialog/DialogActions.js.map +1 -1
  11. package/dist-cjs/dialog/DialogContent.css.js +1 -1
  12. package/dist-cjs/dialog/DialogContent.js +17 -8
  13. package/dist-cjs/dialog/DialogContent.js.map +1 -1
  14. package/dist-cjs/dialog/DialogContext.js +3 -1
  15. package/dist-cjs/dialog/DialogContext.js.map +1 -1
  16. package/dist-cjs/dialog/DialogTitle.js +4 -5
  17. package/dist-cjs/dialog/DialogTitle.js.map +1 -1
  18. package/dist-cjs/dropdown-next/DropdownNext.js +303 -308
  19. package/dist-cjs/dropdown-next/DropdownNext.js.map +1 -1
  20. package/dist-cjs/index.js +0 -6
  21. package/dist-cjs/index.js.map +1 -1
  22. package/dist-cjs/list-control/ListControlContext.js.map +1 -1
  23. package/dist-cjs/list-control/ListControlState.js.map +1 -1
  24. package/dist-cjs/option/Option.js.map +1 -1
  25. package/dist-cjs/parent-child-layout/ParentChildLayout.css.js +1 -1
  26. package/dist-cjs/parent-child-layout/ParentChildLayout.js +30 -38
  27. package/dist-cjs/parent-child-layout/ParentChildLayout.js.map +1 -1
  28. package/dist-cjs/slider/Slider.css.js +1 -1
  29. package/dist-cjs/stepped-tracker/TrackerConnector/TrackerConnector.css.js +1 -1
  30. package/dist-es/combo-box-next/ComboBoxNext.js +288 -290
  31. package/dist-es/combo-box-next/ComboBoxNext.js.map +1 -1
  32. package/dist-es/combo-box-next/useComboBoxNext.js.map +1 -1
  33. package/dist-es/content-status/internal/StatusIndicator.js +1 -3
  34. package/dist-es/content-status/internal/StatusIndicator.js.map +1 -1
  35. package/dist-es/dialog/Dialog.css.js +1 -1
  36. package/dist-es/dialog/Dialog.js +55 -50
  37. package/dist-es/dialog/Dialog.js.map +1 -1
  38. package/dist-es/dialog/DialogActions.js.map +1 -1
  39. package/dist-es/dialog/DialogContent.css.js +1 -1
  40. package/dist-es/dialog/DialogContent.js +19 -10
  41. package/dist-es/dialog/DialogContent.js.map +1 -1
  42. package/dist-es/dialog/DialogContext.js +3 -1
  43. package/dist-es/dialog/DialogContext.js.map +1 -1
  44. package/dist-es/dialog/DialogTitle.js +4 -5
  45. package/dist-es/dialog/DialogTitle.js.map +1 -1
  46. package/dist-es/dropdown-next/DropdownNext.js +303 -308
  47. package/dist-es/dropdown-next/DropdownNext.js.map +1 -1
  48. package/dist-es/index.js +0 -3
  49. package/dist-es/index.js.map +1 -1
  50. package/dist-es/list-control/ListControlContext.js.map +1 -1
  51. package/dist-es/list-control/ListControlState.js.map +1 -1
  52. package/dist-es/option/Option.js.map +1 -1
  53. package/dist-es/parent-child-layout/ParentChildLayout.css.js +1 -1
  54. package/dist-es/parent-child-layout/ParentChildLayout.js +32 -40
  55. package/dist-es/parent-child-layout/ParentChildLayout.js.map +1 -1
  56. package/dist-es/slider/Slider.css.js +1 -1
  57. package/dist-es/stepped-tracker/TrackerConnector/TrackerConnector.css.js +1 -1
  58. package/dist-types/combo-box-next/ComboBoxNext.d.ts +5 -3
  59. package/dist-types/combo-box-next/useComboBoxNext.d.ts +11 -11
  60. package/dist-types/content-status/internal/StatusIndicator.d.ts +1 -1
  61. package/dist-types/dialog/Dialog.d.ts +9 -1
  62. package/dist-types/dialog/DialogContext.d.ts +0 -2
  63. package/dist-types/dialog/DialogTitle.d.ts +9 -3
  64. package/dist-types/dropdown-next/DropdownNext.d.ts +5 -3
  65. package/dist-types/index.d.ts +0 -2
  66. package/dist-types/list-control/ListControlContext.d.ts +10 -10
  67. package/dist-types/list-control/ListControlState.d.ts +15 -15
  68. package/dist-types/option/Option.d.ts +1 -1
  69. package/dist-types/parent-child-layout/ParentChildLayout.d.ts +8 -13
  70. package/package.json +2 -2
  71. package/dist-cjs/dialog/useDialog.js +0 -31
  72. package/dist-cjs/dialog/useDialog.js.map +0 -1
  73. package/dist-cjs/parent-child-item/ParentChildItem.css.js +0 -6
  74. package/dist-cjs/parent-child-item/ParentChildItem.css.js.map +0 -1
  75. package/dist-cjs/parent-child-item/ParentChildItem.js +0 -48
  76. package/dist-cjs/parent-child-item/ParentChildItem.js.map +0 -1
  77. package/dist-cjs/progress/CircularProgress/CircularProgress.css.js +0 -6
  78. package/dist-cjs/progress/CircularProgress/CircularProgress.css.js.map +0 -1
  79. package/dist-cjs/progress/CircularProgress/CircularProgress.js +0 -89
  80. package/dist-cjs/progress/CircularProgress/CircularProgress.js.map +0 -1
  81. package/dist-cjs/progress/Info.js +0 -20
  82. package/dist-cjs/progress/Info.js.map +0 -1
  83. package/dist-cjs/progress/LinearProgress/LinearProgress.css.js +0 -6
  84. package/dist-cjs/progress/LinearProgress/LinearProgress.css.js.map +0 -1
  85. package/dist-cjs/progress/LinearProgress/LinearProgress.js +0 -63
  86. package/dist-cjs/progress/LinearProgress/LinearProgress.js.map +0 -1
  87. package/dist-es/dialog/useDialog.js +0 -27
  88. package/dist-es/dialog/useDialog.js.map +0 -1
  89. package/dist-es/parent-child-item/ParentChildItem.css.js +0 -4
  90. package/dist-es/parent-child-item/ParentChildItem.css.js.map +0 -1
  91. package/dist-es/parent-child-item/ParentChildItem.js +0 -44
  92. package/dist-es/parent-child-item/ParentChildItem.js.map +0 -1
  93. package/dist-es/progress/CircularProgress/CircularProgress.css.js +0 -4
  94. package/dist-es/progress/CircularProgress/CircularProgress.css.js.map +0 -1
  95. package/dist-es/progress/CircularProgress/CircularProgress.js +0 -85
  96. package/dist-es/progress/CircularProgress/CircularProgress.js.map +0 -1
  97. package/dist-es/progress/Info.js +0 -16
  98. package/dist-es/progress/Info.js.map +0 -1
  99. package/dist-es/progress/LinearProgress/LinearProgress.css.js +0 -4
  100. package/dist-es/progress/LinearProgress/LinearProgress.css.js.map +0 -1
  101. package/dist-es/progress/LinearProgress/LinearProgress.js +0 -59
  102. package/dist-es/progress/LinearProgress/LinearProgress.js.map +0 -1
  103. package/dist-types/dialog/useDialog.d.ts +0 -25
  104. package/dist-types/parent-child-item/ParentChildItem.d.ts +0 -31
  105. package/dist-types/parent-child-item/index.d.ts +0 -1
  106. package/dist-types/progress/CircularProgress/CircularProgress.d.ts +0 -25
  107. package/dist-types/progress/Info.d.ts +0 -6
  108. package/dist-types/progress/LinearProgress/LinearProgress.d.ts +0 -26
  109. package/dist-types/progress/index.d.ts +0 -2
@@ -19,328 +19,323 @@ function ExpandIcon({ open }) {
19
19
  });
20
20
  }
21
21
  const withBaseName = makePrefixer("saltDropdownNext");
22
- const DropdownNext = forwardRef(
23
- function DropdownNext2(props, ref) {
24
- var _a, _b;
25
- const {
26
- "aria-labelledby": ariaLabelledBy,
27
- "aria-describedby": ariaDescribedBy,
28
- children,
29
- className,
30
- disabled: disabledProp,
31
- emptyReadOnlyMarker = "\u2014",
32
- readOnly: readOnlyProp,
33
- multiselect,
34
- onSelectionChange,
35
- selected,
36
- defaultSelected,
37
- defaultOpen,
38
- defaultValue: defaultValueProp,
39
- value,
40
- onOpenChange,
41
- open,
42
- placeholder,
43
- startAdornment,
44
- required: requiredProp,
45
- variant = "primary",
46
- validationStatus: validationStatusProp,
47
- onClick,
48
- onKeyDown,
49
- onFocus,
50
- onBlur,
51
- ...rest
52
- } = props;
53
- const targetWindow = useWindow();
54
- useComponentCssInjection({
55
- testId: "salt-DropdownNext",
56
- css: css_248z,
57
- window: targetWindow
58
- });
59
- const {
60
- a11yProps: {
61
- "aria-describedby": formFieldDescribedBy,
62
- "aria-labelledby": formFieldLabelledBy
63
- } = {},
64
- disabled: formFieldDisabled,
65
- readOnly: formFieldReadOnly,
66
- necessity: formFieldRequired,
67
- validationStatus: formFieldValidationStatus
68
- } = useFormFieldProps();
69
- const disabled = Boolean(disabledProp) || formFieldDisabled;
70
- const readOnly = Boolean(readOnlyProp) || formFieldReadOnly;
71
- const validationStatus = validationStatusProp != null ? validationStatusProp : formFieldValidationStatus;
72
- const required = formFieldRequired ? ["required", "asterisk"].includes(formFieldRequired) : requiredProp;
73
- const isEmptyReadOnly = readOnly && !defaultValueProp && !value;
74
- const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
75
- const listControl = useListControl({
76
- open,
77
- defaultOpen,
78
- onOpenChange,
79
- multiselect,
80
- defaultSelected,
81
- selected,
82
- onSelectionChange,
83
- defaultValue,
84
- value
85
- });
86
- const {
87
- activeState,
88
- setActive,
89
- openState,
90
- setOpen,
91
- openKey,
92
- getOptionAtIndex,
93
- getIndexOfOption,
94
- getOptionsMatching,
95
- getOptionFromSearch,
96
- options,
97
- selectedState,
98
- select,
99
- valueState,
100
- setFocusVisibleState,
101
- focusedState,
102
- setFocusedState,
103
- listRef
104
- } = listControl;
105
- const { Component: FloatingComponent } = useFloatingComponent();
106
- const { x, y, strategy, elements, floating, reference } = useFloatingUI({
107
- open,
108
- placement: "bottom-start",
109
- middleware: [
110
- size({
111
- apply({ rects, elements: elements2, availableHeight }) {
112
- Object.assign(elements2.floating.style, {
113
- minWidth: `${rects.reference.width}px`,
114
- maxHeight: `max(calc((var(--salt-size-base) + var(--salt-spacing-100)) * 5), calc(${availableHeight}px - var(--salt-spacing-100)))`
115
- });
116
- }
117
- }),
118
- flip({ fallbackStrategy: "initialPlacement" })
119
- ]
120
- });
121
- const buttonRef = useRef(null);
122
- const handleTriggerRef = useForkRef(
123
- reference,
124
- buttonRef
125
- );
126
- const handleButtonRef = useForkRef(handleTriggerRef, ref);
127
- const handleClick = (event) => {
128
- if (!readOnly) {
129
- setFocusVisibleState(false);
130
- setOpen(event, !openState);
131
- }
132
- onClick == null ? void 0 : onClick(event);
133
- };
134
- const typeaheadString = useRef("");
135
- const typeaheadTimeout = useRef();
136
- const handleTypeahead = (event) => {
137
- if (typeaheadTimeout.current) {
138
- clearTimeout(typeaheadTimeout.current);
139
- }
140
- typeaheadString.current += event.key;
141
- typeaheadTimeout.current = window.setTimeout(() => {
142
- typeaheadString.current = "";
143
- }, 500);
144
- if (!openState) {
22
+ const DropdownNext = forwardRef(function DropdownNext2(props, ref) {
23
+ var _a, _b;
24
+ const {
25
+ "aria-labelledby": ariaLabelledBy,
26
+ "aria-describedby": ariaDescribedBy,
27
+ children,
28
+ className,
29
+ disabled: disabledProp,
30
+ emptyReadOnlyMarker = "\u2014",
31
+ readOnly: readOnlyProp,
32
+ multiselect,
33
+ onSelectionChange,
34
+ selected,
35
+ defaultSelected,
36
+ defaultOpen,
37
+ defaultValue: defaultValueProp,
38
+ value,
39
+ onOpenChange,
40
+ open,
41
+ placeholder,
42
+ startAdornment,
43
+ required: requiredProp,
44
+ variant = "primary",
45
+ validationStatus: validationStatusProp,
46
+ onClick,
47
+ onKeyDown,
48
+ onFocus,
49
+ onBlur,
50
+ ...rest
51
+ } = props;
52
+ const targetWindow = useWindow();
53
+ useComponentCssInjection({
54
+ testId: "salt-DropdownNext",
55
+ css: css_248z,
56
+ window: targetWindow
57
+ });
58
+ const {
59
+ a11yProps: {
60
+ "aria-describedby": formFieldDescribedBy,
61
+ "aria-labelledby": formFieldLabelledBy
62
+ } = {},
63
+ disabled: formFieldDisabled,
64
+ readOnly: formFieldReadOnly,
65
+ necessity: formFieldRequired,
66
+ validationStatus: formFieldValidationStatus
67
+ } = useFormFieldProps();
68
+ const disabled = Boolean(disabledProp) || formFieldDisabled;
69
+ const readOnly = Boolean(readOnlyProp) || formFieldReadOnly;
70
+ const validationStatus = validationStatusProp != null ? validationStatusProp : formFieldValidationStatus;
71
+ const required = formFieldRequired ? ["required", "asterisk"].includes(formFieldRequired) : requiredProp;
72
+ const isEmptyReadOnly = readOnly && !defaultValueProp && !value;
73
+ const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
74
+ const listControl = useListControl({
75
+ open,
76
+ defaultOpen,
77
+ onOpenChange,
78
+ multiselect,
79
+ defaultSelected,
80
+ selected,
81
+ onSelectionChange,
82
+ defaultValue,
83
+ value
84
+ });
85
+ const {
86
+ activeState,
87
+ setActive,
88
+ openState,
89
+ setOpen,
90
+ openKey,
91
+ getOptionAtIndex,
92
+ getIndexOfOption,
93
+ getOptionsMatching,
94
+ getOptionFromSearch,
95
+ options,
96
+ selectedState,
97
+ select,
98
+ valueState,
99
+ setFocusVisibleState,
100
+ focusedState,
101
+ setFocusedState,
102
+ listRef
103
+ } = listControl;
104
+ const { Component: FloatingComponent } = useFloatingComponent();
105
+ const { x, y, strategy, elements, floating, reference } = useFloatingUI({
106
+ open,
107
+ placement: "bottom-start",
108
+ middleware: [
109
+ size({
110
+ apply({ rects, elements: elements2, availableHeight }) {
111
+ Object.assign(elements2.floating.style, {
112
+ minWidth: `${rects.reference.width}px`,
113
+ maxHeight: `max(calc((var(--salt-size-base) + var(--salt-spacing-100)) * 5), calc(${availableHeight}px - var(--salt-spacing-100)))`
114
+ });
115
+ }
116
+ }),
117
+ flip({ fallbackStrategy: "initialPlacement" })
118
+ ]
119
+ });
120
+ const buttonRef = useRef(null);
121
+ const handleTriggerRef = useForkRef(reference, buttonRef);
122
+ const handleButtonRef = useForkRef(handleTriggerRef, ref);
123
+ const handleClick = (event) => {
124
+ if (!readOnly) {
125
+ setFocusVisibleState(false);
126
+ setOpen(event, !openState);
127
+ }
128
+ onClick == null ? void 0 : onClick(event);
129
+ };
130
+ const typeaheadString = useRef("");
131
+ const typeaheadTimeout = useRef();
132
+ const handleTypeahead = (event) => {
133
+ if (typeaheadTimeout.current) {
134
+ clearTimeout(typeaheadTimeout.current);
135
+ }
136
+ typeaheadString.current += event.key;
137
+ typeaheadTimeout.current = window.setTimeout(() => {
138
+ typeaheadString.current = "";
139
+ }, 500);
140
+ if (!openState) {
141
+ setOpen(event, true);
142
+ }
143
+ let newOption = getOptionFromSearch(typeaheadString.current, activeState);
144
+ if (!newOption) {
145
+ newOption = getOptionFromSearch(typeaheadString.current);
146
+ }
147
+ if (newOption) {
148
+ setActive(newOption);
149
+ setFocusVisibleState(true);
150
+ }
151
+ };
152
+ const handleKeyDown = (event) => {
153
+ const currentIndex = activeState ? getIndexOfOption(activeState) : -1;
154
+ const count = options.length - 1;
155
+ if (readOnly) {
156
+ return;
157
+ }
158
+ if (!openState) {
159
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
145
160
  setOpen(event, true);
146
- }
147
- let newOption = getOptionFromSearch(typeaheadString.current, activeState);
148
- if (!newOption) {
149
- newOption = getOptionFromSearch(typeaheadString.current);
150
- }
151
- if (newOption) {
152
- setActive(newOption);
153
- setFocusVisibleState(true);
154
- }
155
- };
156
- const handleKeyDown = (event) => {
157
- const currentIndex = activeState ? getIndexOfOption(activeState) : -1;
158
- const count = options.length - 1;
159
- if (readOnly) {
160
161
  return;
161
162
  }
162
- if (!openState) {
163
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
164
- setOpen(event, true);
163
+ }
164
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
165
+ event.preventDefault();
166
+ event.stopPropagation();
167
+ handleTypeahead(event);
168
+ }
169
+ let newActive;
170
+ switch (event.key) {
171
+ case "ArrowDown":
172
+ newActive = getOptionAtIndex(Math.min(count, currentIndex + 1));
173
+ break;
174
+ case "ArrowUp":
175
+ newActive = getOptionAtIndex(Math.max(0, currentIndex - 1));
176
+ break;
177
+ case "Home":
178
+ newActive = getOptionAtIndex(0);
179
+ break;
180
+ case "End":
181
+ newActive = getOptionAtIndex(count);
182
+ break;
183
+ case "PageUp":
184
+ newActive = getOptionAtIndex(Math.max(0, currentIndex - 10));
185
+ break;
186
+ case "PageDown":
187
+ newActive = getOptionAtIndex(Math.min(count, currentIndex + 10));
188
+ break;
189
+ case "Enter":
190
+ case " ":
191
+ if (openState && Boolean(activeState == null ? void 0 : activeState.disabled) || typeaheadString.current.trim().length > 0 && event.key === " ") {
192
+ event.preventDefault();
193
+ return;
194
+ }
195
+ if (!openState || !activeState) {
165
196
  return;
166
197
  }
167
- }
168
- if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
169
198
  event.preventDefault();
170
- event.stopPropagation();
171
- handleTypeahead(event);
172
- }
173
- let newActive;
174
- switch (event.key) {
175
- case "ArrowDown":
176
- newActive = getOptionAtIndex(Math.min(count, currentIndex + 1));
177
- break;
178
- case "ArrowUp":
179
- newActive = getOptionAtIndex(Math.max(0, currentIndex - 1));
180
- break;
181
- case "Home":
182
- newActive = getOptionAtIndex(0);
183
- break;
184
- case "End":
185
- newActive = getOptionAtIndex(count);
186
- break;
187
- case "PageUp":
188
- newActive = getOptionAtIndex(Math.max(0, currentIndex - 10));
189
- break;
190
- case "PageDown":
191
- newActive = getOptionAtIndex(Math.min(count, currentIndex + 10));
192
- break;
193
- case "Enter":
194
- case " ":
195
- if (openState && Boolean(activeState == null ? void 0 : activeState.disabled) || typeaheadString.current.trim().length > 0 && event.key === " ") {
196
- event.preventDefault();
197
- return;
198
- }
199
- if (!openState || !activeState) {
200
- return;
201
- }
202
- event.preventDefault();
203
- select(event, activeState);
204
- if (!multiselect) {
205
- setOpen(event, false);
206
- }
207
- break;
208
- case "Escape":
199
+ select(event, activeState);
200
+ if (!multiselect) {
209
201
  setOpen(event, false);
210
- break;
211
- case "Tab":
212
- if (!multiselect && activeState) {
213
- select(event, activeState);
214
- }
215
- break;
216
- }
217
- if (newActive && (newActive == null ? void 0 : newActive.id) != (activeState == null ? void 0 : activeState.id)) {
218
- event.preventDefault();
219
- setActive(newActive);
220
- setFocusVisibleState(true);
221
- }
222
- onKeyDown == null ? void 0 : onKeyDown(event);
223
- };
224
- const handleFocus = (event) => {
225
- setFocusedState(true);
226
- onFocus == null ? void 0 : onFocus(event);
227
- };
228
- const ignoreBlur = useRef(false);
229
- const handleBlur = (event) => {
230
- if (!ignoreBlur.current) {
202
+ }
203
+ break;
204
+ case "Escape":
231
205
  setOpen(event, false);
232
- }
233
- ignoreBlur.current = false;
234
- setFocusedState(false);
235
- onBlur == null ? void 0 : onBlur(event);
236
- };
237
- const handleListMouseOver = () => {
238
- setFocusVisibleState(false);
239
- };
240
- const handleListMouseDown = () => {
241
- ignoreBlur.current = true;
242
- };
243
- const handleListFocus = () => {
244
- var _a2;
245
- (_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
246
- };
247
- const handleListClick = () => {
248
- var _a2;
249
- (_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
250
- };
251
- useEffect(() => {
252
- const activeIndex = activeState ? getIndexOfOption(activeState) : -1;
253
- if (openState && activeIndex < 0) {
254
- if (openKey.current.key === "ArrowDown") {
255
- setActive(getOptionAtIndex(0));
256
- } else if (openKey.current.key === "ArrowUp") {
257
- setActive(getOptionAtIndex(options.length - 1));
258
- } else {
259
- if (selectedState.length > 0) {
260
- const selected2 = getOptionsMatching(
261
- (option) => option.value === selectedState[0]
262
- ).pop();
263
- if (selected2) {
264
- setActive(selected2);
265
- }
266
- } else {
267
- setActive(getOptionAtIndex(0));
206
+ break;
207
+ case "Tab":
208
+ if (!multiselect && activeState) {
209
+ select(event, activeState);
210
+ }
211
+ break;
212
+ }
213
+ if (newActive && (newActive == null ? void 0 : newActive.id) != (activeState == null ? void 0 : activeState.id)) {
214
+ event.preventDefault();
215
+ setActive(newActive);
216
+ setFocusVisibleState(true);
217
+ }
218
+ onKeyDown == null ? void 0 : onKeyDown(event);
219
+ };
220
+ const handleFocus = (event) => {
221
+ setFocusedState(true);
222
+ onFocus == null ? void 0 : onFocus(event);
223
+ };
224
+ const ignoreBlur = useRef(false);
225
+ const handleBlur = (event) => {
226
+ if (!ignoreBlur.current) {
227
+ setOpen(event, false);
228
+ }
229
+ ignoreBlur.current = false;
230
+ setFocusedState(false);
231
+ onBlur == null ? void 0 : onBlur(event);
232
+ };
233
+ const handleListMouseOver = () => {
234
+ setFocusVisibleState(false);
235
+ };
236
+ const handleListMouseDown = () => {
237
+ ignoreBlur.current = true;
238
+ };
239
+ const handleListFocus = () => {
240
+ var _a2;
241
+ (_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
242
+ };
243
+ const handleListClick = () => {
244
+ var _a2;
245
+ (_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
246
+ };
247
+ useEffect(() => {
248
+ const activeIndex = activeState ? getIndexOfOption(activeState) : -1;
249
+ if (openState && activeIndex < 0) {
250
+ if (openKey.current.key === "ArrowDown") {
251
+ setActive(getOptionAtIndex(0));
252
+ } else if (openKey.current.key === "ArrowUp") {
253
+ setActive(getOptionAtIndex(options.length - 1));
254
+ } else {
255
+ if (selectedState.length > 0) {
256
+ const selected2 = getOptionsMatching(
257
+ (option) => option.value === selectedState[0]
258
+ ).pop();
259
+ if (selected2) {
260
+ setActive(selected2);
268
261
  }
262
+ } else {
263
+ setActive(getOptionAtIndex(0));
269
264
  }
270
- } else if (!openState) {
271
- setActive(void 0);
272
265
  }
273
- }, [openState, children]);
274
- const listId = useId();
275
- return /* @__PURE__ */ jsxs(ListControlContext.Provider, {
276
- value: listControl,
277
- children: [
278
- /* @__PURE__ */ jsxs("button", {
279
- className: clsx(
280
- withBaseName(),
281
- withBaseName(variant),
282
- {
283
- [withBaseName("disabled")]: disabled,
284
- [withBaseName(validationStatus != null ? validationStatus : "")]: validationStatus
285
- },
286
- className
287
- ),
288
- ref: handleButtonRef,
289
- onClick: handleClick,
290
- onKeyDown: handleKeyDown,
291
- onFocus: handleFocus,
292
- onBlur: handleBlur,
293
- role: "combobox",
294
- type: "button",
295
- disabled,
296
- "aria-readonly": readOnly ? "true" : void 0,
297
- "aria-required": required ? "true" : void 0,
298
- "aria-expanded": openState,
299
- "aria-activedescendant": activeState == null ? void 0 : activeState.id,
300
- "aria-labelledby": clsx(formFieldLabelledBy, ariaLabelledBy) || void 0,
301
- "aria-describedby": clsx(formFieldDescribedBy, ariaDescribedBy) || void 0,
302
- "aria-multiselectable": multiselect,
303
- "aria-controls": openState ? listId : void 0,
304
- ...rest,
305
- children: [
306
- startAdornment,
307
- /* @__PURE__ */ jsx("span", {
308
- className: clsx(withBaseName("content"), {
309
- [withBaseName("placeholder")]: !valueState
310
- }),
311
- children: valueState != null ? valueState : placeholder
266
+ } else if (!openState) {
267
+ setActive(void 0);
268
+ }
269
+ }, [openState, children]);
270
+ const listId = useId();
271
+ return /* @__PURE__ */ jsxs(ListControlContext.Provider, {
272
+ value: listControl,
273
+ children: [
274
+ /* @__PURE__ */ jsxs("button", {
275
+ className: clsx(
276
+ withBaseName(),
277
+ withBaseName(variant),
278
+ {
279
+ [withBaseName("disabled")]: disabled,
280
+ [withBaseName(validationStatus != null ? validationStatus : "")]: validationStatus
281
+ },
282
+ className
283
+ ),
284
+ ref: handleButtonRef,
285
+ onClick: handleClick,
286
+ onKeyDown: handleKeyDown,
287
+ onFocus: handleFocus,
288
+ onBlur: handleBlur,
289
+ role: "combobox",
290
+ type: "button",
291
+ disabled,
292
+ "aria-readonly": readOnly ? "true" : void 0,
293
+ "aria-required": required ? "true" : void 0,
294
+ "aria-expanded": openState,
295
+ "aria-activedescendant": activeState == null ? void 0 : activeState.id,
296
+ "aria-labelledby": clsx(formFieldLabelledBy, ariaLabelledBy) || void 0,
297
+ "aria-describedby": clsx(formFieldDescribedBy, ariaDescribedBy) || void 0,
298
+ "aria-multiselectable": multiselect,
299
+ "aria-controls": openState ? listId : void 0,
300
+ ...rest,
301
+ children: [
302
+ startAdornment,
303
+ /* @__PURE__ */ jsx("span", {
304
+ className: clsx(withBaseName("content"), {
305
+ [withBaseName("placeholder")]: !valueState
312
306
  }),
313
- validationStatus && /* @__PURE__ */ jsx(StatusAdornment, {
314
- status: validationStatus
315
- }),
316
- !readOnly && /* @__PURE__ */ jsx(ExpandIcon, {
317
- open: openState
318
- })
319
- ]
320
- }),
321
- /* @__PURE__ */ jsx(FloatingComponent, {
322
- open: (openState || focusedState) && !readOnly,
323
- left: x != null ? x : 0,
324
- top: y != null ? y : 0,
325
- position: strategy,
326
- width: (_a = elements.floating) == null ? void 0 : _a.offsetWidth,
327
- height: (_b = elements.floating) == null ? void 0 : _b.offsetHeight,
328
- ref: floating,
329
- children: /* @__PURE__ */ jsx(OptionList, {
330
- id: listId,
331
- collapsed: !openState,
332
- onMouseOver: handleListMouseOver,
333
- onMouseDown: handleListMouseDown,
334
- onFocus: handleListFocus,
335
- onClick: handleListClick,
336
- ref: listRef,
337
- children
307
+ children: valueState != null ? valueState : placeholder
308
+ }),
309
+ validationStatus && /* @__PURE__ */ jsx(StatusAdornment, {
310
+ status: validationStatus
311
+ }),
312
+ !readOnly && /* @__PURE__ */ jsx(ExpandIcon, {
313
+ open: openState
338
314
  })
315
+ ]
316
+ }),
317
+ /* @__PURE__ */ jsx(FloatingComponent, {
318
+ open: (openState || focusedState) && !readOnly && children != void 0,
319
+ left: x != null ? x : 0,
320
+ top: y != null ? y : 0,
321
+ position: strategy,
322
+ width: (_a = elements.floating) == null ? void 0 : _a.offsetWidth,
323
+ height: (_b = elements.floating) == null ? void 0 : _b.offsetHeight,
324
+ ref: floating,
325
+ children: /* @__PURE__ */ jsx(OptionList, {
326
+ id: listId,
327
+ collapsed: !openState,
328
+ onMouseOver: handleListMouseOver,
329
+ onMouseDown: handleListMouseDown,
330
+ onFocus: handleListFocus,
331
+ onClick: handleListClick,
332
+ ref: listRef,
333
+ children
339
334
  })
340
- ]
341
- });
342
- }
343
- );
335
+ })
336
+ ]
337
+ });
338
+ });
344
339
 
345
340
  export { DropdownNext };
346
341
  //# sourceMappingURL=DropdownNext.js.map