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

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