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