@gridui/select 1.1.1 → 1.1.2
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.
- package/README.md +7 -6
- package/dist/combobox/combobox.d.ts +2 -5
- package/dist/index.js +342 -350
- package/dist/index.js.map +4 -4
- package/dist/multi-select/multi-select.d.ts +2 -8
- package/dist/select/select-options.d.ts +2 -6
- package/dist/select/style.d.ts +0 -2
- package/dist/shared/{selection-actions.d.ts → popup/selection-actions.d.ts} +2 -2
- package/dist/shared/{selection-popup.d.ts → popup/selection-popup.d.ts} +1 -1
- package/dist/shared/{use-selection-popup.d.ts → popup/use-selection-popup.d.ts} +2 -2
- package/dist/shared/{combobox-options.d.ts → search/combobox-options.d.ts} +3 -5
- package/dist/shared/{scroll-option.d.ts → search/scroll-option.d.ts} +1 -1
- package/dist/shared/{use-search-options.d.ts → search/use-search-options.d.ts} +2 -2
- package/dist/shared/style.d.ts +0 -1
- package/dist/shared/types.d.ts +16 -4
- package/dist/styles.css +55 -81
- package/docs/catalog.json +2 -3
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1,158 +1,33 @@
|
|
|
1
1
|
// src/shared/style.ts
|
|
2
|
-
import {
|
|
3
|
-
import { overlaySurfaceStyles } from "@gridui/overlay";
|
|
2
|
+
import { overlayListItemStyles, overlayListStyles } from "@gridui/overlay";
|
|
4
3
|
import { cn } from "@gridui/style-utils";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var selectActionsStyles = cva("gridui-u-shrink-0 gridui-u-border-t gridui-u-border-border gridui-u-pt-gridui-4");
|
|
5
|
+
var selectIconStyles = cva("gridui-u-select--inline-flex gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--[&_svg]:size-gridui-16");
|
|
6
|
+
var selectOptionContentStyles = cva("gridui-u-select--min-w-0 gridui-u-select--flex-1 gridui-u-select--whitespace-normal gridui-u-select--wrap-anywhere");
|
|
7
|
+
var selectOptionDescriptionStyles = cva("gridui-u-select--block gridui-u-select--text-muted gridui-u-select--type-caption gridui-u-select--mt-gridui-4");
|
|
8
|
+
var selectListStyles = cva("gridui-u-select--min-h-0 gridui-u-select--overflow-y-auto");
|
|
9
|
+
var selectEmptyStyles = cva("gridui-u-select--p-gridui-8 gridui-u-select--text-muted gridui-u-select--type-caption");
|
|
10
|
+
var selectActionsStyles = cva("gridui-u-select--shrink-0 gridui-u-select--border-t gridui-u-select--border-border");
|
|
13
11
|
var selectActionStyles = cva(cn(
|
|
14
|
-
|
|
15
|
-
"gridui-u-w-full gridui-u-text-start
|
|
12
|
+
overlayListItemStyles(),
|
|
13
|
+
"gridui-u-select--w-full gridui-u-select--text-start"
|
|
16
14
|
));
|
|
17
15
|
var comboboxContentStyles = cva(cn(
|
|
18
|
-
|
|
19
|
-
"gridui-u-
|
|
20
|
-
"gridui-combobox-content gridui-u-box-border gridui-u-flex gridui-u-flex-col gridui-u-overflow-hidden gridui-u-min-w-0 gridui-u-w-(--anchor-width) gridui-u-max-h-(--available-height) gridui-u-max-w-(--available-width)"
|
|
16
|
+
overlayListStyles(),
|
|
17
|
+
"gridui-combobox-content gridui-u-select--box-border gridui-u-select--flex gridui-u-select--flex-col gridui-u-select--overflow-hidden gridui-u-select--min-w-0 gridui-u-select--w-(--anchor-width) gridui-u-select--max-h-(--available-height) gridui-u-select--max-w-(--available-width)"
|
|
21
18
|
));
|
|
22
19
|
|
|
23
|
-
// src/shared/
|
|
24
|
-
import {
|
|
25
|
-
import { useInteractionOutline, useScrollbars } from "@gridui/overlay";
|
|
26
|
-
import { Check } from "lucide-react";
|
|
27
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
-
var ComboboxOptions = (props) => {
|
|
29
|
-
const { id, label, options, selected, multiple, active, optionId, onSelect, onHighlight } = props;
|
|
30
|
-
const scrollbarRef = useScrollbars();
|
|
31
|
-
const ref = useInteractionOutline({
|
|
32
|
-
ref: scrollbarRef,
|
|
33
|
-
selector: '[role="option"]'
|
|
34
|
-
});
|
|
35
|
-
const renderOption = (option) => {
|
|
36
|
-
const itemId = optionId(option.value);
|
|
37
|
-
const checked = typeof selected === "string" ? selected === option.value : selected.includes(option.value);
|
|
38
|
-
return /* @__PURE__ */ jsxs(
|
|
39
|
-
"div",
|
|
40
|
-
{
|
|
41
|
-
id: itemId,
|
|
42
|
-
role: "option",
|
|
43
|
-
"aria-selected": checked,
|
|
44
|
-
"aria-disabled": option.disabled,
|
|
45
|
-
"aria-labelledby": `${itemId}-label`,
|
|
46
|
-
"aria-describedby": option.description ? `${itemId}-description` : void 0,
|
|
47
|
-
"data-disabled": option.disabled ? "" : void 0,
|
|
48
|
-
"data-highlighted": active === option.value ? "" : void 0,
|
|
49
|
-
className: selectItemStyles(),
|
|
50
|
-
onPointerMove: () => {
|
|
51
|
-
onHighlight(option.value);
|
|
52
|
-
},
|
|
53
|
-
onPointerDown: (event) => {
|
|
54
|
-
event.preventDefault();
|
|
55
|
-
},
|
|
56
|
-
onClick: () => {
|
|
57
|
-
if (!option.disabled) {
|
|
58
|
-
onSelect(option);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ jsx(
|
|
63
|
-
"span",
|
|
64
|
-
{
|
|
65
|
-
className: dropdownIndicatorStyles(),
|
|
66
|
-
"aria-hidden": "true",
|
|
67
|
-
children: checked && /* @__PURE__ */ jsx(
|
|
68
|
-
Check,
|
|
69
|
-
{
|
|
70
|
-
size: 16
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
),
|
|
75
|
-
option.icon && /* @__PURE__ */ jsx(
|
|
76
|
-
"span",
|
|
77
|
-
{
|
|
78
|
-
className: selectIconStyles(),
|
|
79
|
-
"aria-hidden": "true",
|
|
80
|
-
children: option.icon
|
|
81
|
-
}
|
|
82
|
-
),
|
|
83
|
-
/* @__PURE__ */ jsxs(
|
|
84
|
-
"span",
|
|
85
|
-
{
|
|
86
|
-
className: selectOptionContentStyles(),
|
|
87
|
-
children: [
|
|
88
|
-
/* @__PURE__ */ jsx(
|
|
89
|
-
"span",
|
|
90
|
-
{
|
|
91
|
-
id: `${itemId}-label`,
|
|
92
|
-
children: option.label
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
option.description && /* @__PURE__ */ jsx(
|
|
96
|
-
"span",
|
|
97
|
-
{
|
|
98
|
-
id: `${itemId}-description`,
|
|
99
|
-
className: selectOptionDescriptionStyles(),
|
|
100
|
-
children: option.description
|
|
101
|
-
}
|
|
102
|
-
)
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
)
|
|
106
|
-
]
|
|
107
|
-
},
|
|
108
|
-
option.value
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
return /* @__PURE__ */ jsx(
|
|
112
|
-
"div",
|
|
113
|
-
{
|
|
114
|
-
ref,
|
|
115
|
-
id,
|
|
116
|
-
role: "listbox",
|
|
117
|
-
"aria-multiselectable": multiple || void 0,
|
|
118
|
-
"aria-label": label,
|
|
119
|
-
className: selectListStyles(),
|
|
120
|
-
children: options.map((entry, index) => {
|
|
121
|
-
return "options" in entry ? /* @__PURE__ */ jsxs(
|
|
122
|
-
"div",
|
|
123
|
-
{
|
|
124
|
-
role: "group",
|
|
125
|
-
"aria-labelledby": `${id}-group-${index}`,
|
|
126
|
-
children: [
|
|
127
|
-
/* @__PURE__ */ jsx(
|
|
128
|
-
"div",
|
|
129
|
-
{
|
|
130
|
-
id: `${id}-group-${index}`,
|
|
131
|
-
className: dropdownLabelStyles(),
|
|
132
|
-
children: entry.label
|
|
133
|
-
}
|
|
134
|
-
),
|
|
135
|
-
entry.options.map(renderOption)
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
entry.label
|
|
139
|
-
) : renderOption(entry);
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// src/shared/selection-actions.tsx
|
|
146
|
-
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
20
|
+
// src/shared/popup/selection-actions.tsx
|
|
21
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
147
22
|
var SelectionActions = (props) => {
|
|
148
23
|
const { actions, onAction } = props;
|
|
149
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, { children: actions.length > 0 && /* @__PURE__ */ jsx(
|
|
150
25
|
"div",
|
|
151
26
|
{
|
|
152
27
|
className: selectActionsStyles(),
|
|
153
28
|
children: actions.map((action) => {
|
|
154
|
-
const content = /* @__PURE__ */
|
|
155
|
-
action.icon && /* @__PURE__ */
|
|
29
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
action.icon && /* @__PURE__ */ jsx(
|
|
156
31
|
"span",
|
|
157
32
|
{
|
|
158
33
|
className: selectIconStyles(),
|
|
@@ -164,7 +39,7 @@ var SelectionActions = (props) => {
|
|
|
164
39
|
] });
|
|
165
40
|
const actionClass = selectActionStyles();
|
|
166
41
|
if (action.href !== void 0) {
|
|
167
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
168
43
|
"a",
|
|
169
44
|
{
|
|
170
45
|
href: action.disabled ? void 0 : action.href,
|
|
@@ -188,7 +63,7 @@ var SelectionActions = (props) => {
|
|
|
188
63
|
action.id
|
|
189
64
|
);
|
|
190
65
|
}
|
|
191
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
192
67
|
"button",
|
|
193
68
|
{
|
|
194
69
|
type: "button",
|
|
@@ -207,105 +82,18 @@ var SelectionActions = (props) => {
|
|
|
207
82
|
) });
|
|
208
83
|
};
|
|
209
84
|
|
|
210
|
-
// src/shared/selection-
|
|
211
|
-
import { focusInvalidControl, useFormReset } from "@gridui/form";
|
|
212
|
-
import { useLayoutEffect, useRef } from "react";
|
|
213
|
-
import { flushSync } from "react-dom";
|
|
214
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
215
|
-
var SelectionForm = (props) => {
|
|
216
|
-
const {
|
|
217
|
-
name,
|
|
218
|
-
form,
|
|
219
|
-
required,
|
|
220
|
-
disabled,
|
|
221
|
-
selectedValue,
|
|
222
|
-
allOptions,
|
|
223
|
-
onValueChange,
|
|
224
|
-
onReset,
|
|
225
|
-
onInvalid
|
|
226
|
-
} = props;
|
|
227
|
-
const nativeRef = useRef(null);
|
|
228
|
-
const resetSelection = useRef(onReset);
|
|
229
|
-
const currentValue = useRef(selectedValue);
|
|
230
|
-
useLayoutEffect(() => {
|
|
231
|
-
resetSelection.current = onReset;
|
|
232
|
-
currentValue.current = selectedValue;
|
|
233
|
-
}, [
|
|
234
|
-
onReset,
|
|
235
|
-
selectedValue
|
|
236
|
-
]);
|
|
237
|
-
useFormReset(nativeRef, () => {
|
|
238
|
-
flushSync(() => {
|
|
239
|
-
resetSelection.current();
|
|
240
|
-
});
|
|
241
|
-
if (nativeRef.current) {
|
|
242
|
-
nativeRef.current.value = currentValue.current;
|
|
243
|
-
}
|
|
244
|
-
}, form);
|
|
245
|
-
return /* @__PURE__ */ jsxs3(
|
|
246
|
-
"select",
|
|
247
|
-
{
|
|
248
|
-
ref: nativeRef,
|
|
249
|
-
"aria-hidden": "true",
|
|
250
|
-
tabIndex: -1,
|
|
251
|
-
className: "gridui-u-sr-only",
|
|
252
|
-
name,
|
|
253
|
-
form,
|
|
254
|
-
required,
|
|
255
|
-
disabled,
|
|
256
|
-
value: selectedValue,
|
|
257
|
-
onChange: (event) => {
|
|
258
|
-
onValueChange(event.currentTarget.value);
|
|
259
|
-
},
|
|
260
|
-
onInvalid: (event) => {
|
|
261
|
-
focusInvalidControl(event, onInvalid);
|
|
262
|
-
},
|
|
263
|
-
children: [
|
|
264
|
-
!allOptions.some((option) => {
|
|
265
|
-
return option.value === "";
|
|
266
|
-
}) && /* @__PURE__ */ jsx3(
|
|
267
|
-
"option",
|
|
268
|
-
{
|
|
269
|
-
value: ""
|
|
270
|
-
}
|
|
271
|
-
),
|
|
272
|
-
selectedValue !== "" && !allOptions.some((option) => {
|
|
273
|
-
return option.value === selectedValue;
|
|
274
|
-
}) && /* @__PURE__ */ jsx3(
|
|
275
|
-
"option",
|
|
276
|
-
{
|
|
277
|
-
value: selectedValue,
|
|
278
|
-
children: selectedValue
|
|
279
|
-
}
|
|
280
|
-
),
|
|
281
|
-
allOptions.map((option) => {
|
|
282
|
-
return /* @__PURE__ */ jsx3(
|
|
283
|
-
"option",
|
|
284
|
-
{
|
|
285
|
-
value: option.value,
|
|
286
|
-
disabled: option.disabled,
|
|
287
|
-
children: option.label
|
|
288
|
-
},
|
|
289
|
-
option.value
|
|
290
|
-
);
|
|
291
|
-
})
|
|
292
|
-
]
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
// src/shared/selection-popup.tsx
|
|
85
|
+
// src/shared/popup/selection-popup.tsx
|
|
298
86
|
import { isComposingKeyEvent } from "@gridui/interaction";
|
|
299
87
|
import { interactionLayerProps } from "@gridui/overlay";
|
|
300
88
|
import * as Primitive from "@radix-ui/react-popover";
|
|
301
|
-
import { jsx as
|
|
89
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
302
90
|
var SelectionPopup = (props) => {
|
|
303
91
|
const { container, anchorRef, initialFocus, finalFocus, onEscape, onDismiss, ...restProps } = props;
|
|
304
|
-
return /* @__PURE__ */
|
|
92
|
+
return /* @__PURE__ */ jsx2(
|
|
305
93
|
Primitive.Portal,
|
|
306
94
|
{
|
|
307
95
|
container,
|
|
308
|
-
children: /* @__PURE__ */
|
|
96
|
+
children: /* @__PURE__ */ jsx2(
|
|
309
97
|
Primitive.Content,
|
|
310
98
|
{
|
|
311
99
|
...interactionLayerProps,
|
|
@@ -350,6 +138,196 @@ var SelectionPopup = (props) => {
|
|
|
350
138
|
);
|
|
351
139
|
};
|
|
352
140
|
|
|
141
|
+
// src/shared/popup/use-selection-popup.ts
|
|
142
|
+
import { useEffect, useRef, useState } from "react";
|
|
143
|
+
import { flushSync } from "react-dom";
|
|
144
|
+
var useSelectionPopup = ({ disabled, readOnly, controlRef }) => {
|
|
145
|
+
const [
|
|
146
|
+
localOpen,
|
|
147
|
+
setLocalOpen
|
|
148
|
+
] = useState(false);
|
|
149
|
+
const popupRef = useRef(null);
|
|
150
|
+
const restoreFocus = useRef(true);
|
|
151
|
+
const unavailable = Boolean(disabled || readOnly);
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if (unavailable) {
|
|
154
|
+
setLocalOpen(false);
|
|
155
|
+
}
|
|
156
|
+
}, [unavailable]);
|
|
157
|
+
const available = () => {
|
|
158
|
+
return !unavailable && !controlRef.current?.matches(":disabled");
|
|
159
|
+
};
|
|
160
|
+
const changeOpen = (next) => {
|
|
161
|
+
if (next && !available()) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (next) {
|
|
165
|
+
restoreFocus.current = true;
|
|
166
|
+
}
|
|
167
|
+
setLocalOpen(next);
|
|
168
|
+
};
|
|
169
|
+
const close = () => {
|
|
170
|
+
restoreFocus.current = false;
|
|
171
|
+
setLocalOpen(false);
|
|
172
|
+
};
|
|
173
|
+
const focus = () => {
|
|
174
|
+
controlRef.current?.focus();
|
|
175
|
+
};
|
|
176
|
+
const finalFocus = () => {
|
|
177
|
+
const control = controlRef.current;
|
|
178
|
+
if (!restoreFocus.current || !control) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
const active = control.ownerDocument.activeElement;
|
|
182
|
+
if (active && active !== control.ownerDocument.body && active !== control && !popupRef.current?.contains(active)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
return control;
|
|
186
|
+
};
|
|
187
|
+
const runAction = (action) => {
|
|
188
|
+
if (action.disabled || !available()) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (action.closeOnAction !== false) {
|
|
192
|
+
flushSync(close);
|
|
193
|
+
focus();
|
|
194
|
+
}
|
|
195
|
+
action.onAction?.();
|
|
196
|
+
return true;
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
open: localOpen && !unavailable,
|
|
200
|
+
popupRef,
|
|
201
|
+
available,
|
|
202
|
+
changeOpen,
|
|
203
|
+
close,
|
|
204
|
+
focus,
|
|
205
|
+
finalFocus,
|
|
206
|
+
runAction
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// src/shared/search/combobox-options.tsx
|
|
211
|
+
import { overlayListIndicatorStyles, overlayListItemStyles as overlayListItemStyles2, overlayListLabelStyles, useInteractionOutline, useScrollbars } from "@gridui/overlay";
|
|
212
|
+
import { Check } from "lucide-react";
|
|
213
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
214
|
+
var ComboboxOptions = (props) => {
|
|
215
|
+
const { id, label, options, selected, multiple, active, optionId, onSelect, onHighlight } = props;
|
|
216
|
+
const scrollbarRef = useScrollbars();
|
|
217
|
+
const ref = useInteractionOutline({
|
|
218
|
+
ref: scrollbarRef,
|
|
219
|
+
selector: '[role="option"]'
|
|
220
|
+
});
|
|
221
|
+
const renderOption = (option) => {
|
|
222
|
+
const itemId = optionId(option.value);
|
|
223
|
+
const checked = typeof selected === "string" ? selected === option.value : selected.includes(option.value);
|
|
224
|
+
return /* @__PURE__ */ jsxs2(
|
|
225
|
+
"div",
|
|
226
|
+
{
|
|
227
|
+
id: itemId,
|
|
228
|
+
role: "option",
|
|
229
|
+
"aria-selected": checked,
|
|
230
|
+
"aria-disabled": option.disabled,
|
|
231
|
+
"aria-labelledby": `${itemId}-label`,
|
|
232
|
+
"aria-describedby": option.description ? `${itemId}-description` : void 0,
|
|
233
|
+
"data-disabled": option.disabled ? "" : void 0,
|
|
234
|
+
"data-highlighted": active === option.value ? "" : void 0,
|
|
235
|
+
className: overlayListItemStyles2(),
|
|
236
|
+
onPointerMove: () => {
|
|
237
|
+
onHighlight(option.value);
|
|
238
|
+
},
|
|
239
|
+
onPointerDown: (event) => {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
},
|
|
242
|
+
onClick: () => {
|
|
243
|
+
if (!option.disabled) {
|
|
244
|
+
onSelect(option);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
children: [
|
|
248
|
+
option.icon && /* @__PURE__ */ jsx3(
|
|
249
|
+
"span",
|
|
250
|
+
{
|
|
251
|
+
className: selectIconStyles(),
|
|
252
|
+
"aria-hidden": "true",
|
|
253
|
+
children: option.icon
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
/* @__PURE__ */ jsxs2(
|
|
257
|
+
"span",
|
|
258
|
+
{
|
|
259
|
+
className: selectOptionContentStyles(),
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ jsx3(
|
|
262
|
+
"span",
|
|
263
|
+
{
|
|
264
|
+
id: `${itemId}-label`,
|
|
265
|
+
children: option.label
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
option.description && /* @__PURE__ */ jsx3(
|
|
269
|
+
"span",
|
|
270
|
+
{
|
|
271
|
+
id: `${itemId}-description`,
|
|
272
|
+
className: selectOptionDescriptionStyles(),
|
|
273
|
+
children: option.description
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ jsx3(
|
|
280
|
+
"span",
|
|
281
|
+
{
|
|
282
|
+
className: overlayListIndicatorStyles(),
|
|
283
|
+
"aria-hidden": "true",
|
|
284
|
+
children: checked && /* @__PURE__ */ jsx3(
|
|
285
|
+
Check,
|
|
286
|
+
{
|
|
287
|
+
size: 16
|
|
288
|
+
}
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
]
|
|
293
|
+
},
|
|
294
|
+
option.value
|
|
295
|
+
);
|
|
296
|
+
};
|
|
297
|
+
return /* @__PURE__ */ jsx3(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
ref,
|
|
301
|
+
id,
|
|
302
|
+
role: "listbox",
|
|
303
|
+
"aria-multiselectable": multiple || void 0,
|
|
304
|
+
"aria-label": label,
|
|
305
|
+
className: selectListStyles(),
|
|
306
|
+
children: options.map((entry, index) => {
|
|
307
|
+
return "options" in entry ? /* @__PURE__ */ jsxs2(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
role: "group",
|
|
311
|
+
"aria-labelledby": `${id}-group-${index}`,
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ jsx3(
|
|
314
|
+
"div",
|
|
315
|
+
{
|
|
316
|
+
id: `${id}-group-${index}`,
|
|
317
|
+
className: overlayListLabelStyles(),
|
|
318
|
+
children: entry.label
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
entry.options.map(renderOption)
|
|
322
|
+
]
|
|
323
|
+
},
|
|
324
|
+
entry.label
|
|
325
|
+
) : renderOption(entry);
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
|
|
353
331
|
// src/shared/options.ts
|
|
354
332
|
var flattenOptions = (options) => {
|
|
355
333
|
return options.flatMap((entry) => {
|
|
@@ -378,7 +356,7 @@ var filterOptions = (options, query) => {
|
|
|
378
356
|
});
|
|
379
357
|
};
|
|
380
358
|
|
|
381
|
-
// src/shared/scroll-option.ts
|
|
359
|
+
// src/shared/search/scroll-option.ts
|
|
382
360
|
var scrollOption = (id) => {
|
|
383
361
|
const option = document.getElementById(id);
|
|
384
362
|
const list = option?.closest('[role="listbox"]');
|
|
@@ -394,8 +372,8 @@ var scrollOption = (id) => {
|
|
|
394
372
|
}
|
|
395
373
|
};
|
|
396
374
|
|
|
397
|
-
// src/shared/use-search-options.ts
|
|
398
|
-
import { useEffect, useRef as useRef2, useState } from "react";
|
|
375
|
+
// src/shared/search/use-search-options.ts
|
|
376
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
399
377
|
var INITIAL_SEARCH = {
|
|
400
378
|
query: null,
|
|
401
379
|
highlighted: null
|
|
@@ -404,7 +382,7 @@ var useSearchOptions = (options, selected, listId, open, searchProps = {}) => {
|
|
|
404
382
|
const [
|
|
405
383
|
search,
|
|
406
384
|
setSearch
|
|
407
|
-
] =
|
|
385
|
+
] = useState2(INITIAL_SEARCH);
|
|
408
386
|
const { query: controlledQuery, onQueryChange, filterOptions: shouldFilter = true, loading, errorLabel } = searchProps;
|
|
409
387
|
const wasOpen = useRef2(open);
|
|
410
388
|
const query = open ? controlledQuery ?? search.query : null;
|
|
@@ -430,7 +408,7 @@ var useSearchOptions = (options, selected, listId, open, searchProps = {}) => {
|
|
|
430
408
|
return `${listId}-${optionIndices.get(value) ?? -1}`;
|
|
431
409
|
};
|
|
432
410
|
const activeOptionId = active ? optionId(active.value) : void 0;
|
|
433
|
-
|
|
411
|
+
useEffect2(() => {
|
|
434
412
|
if (!open && wasOpen.current) {
|
|
435
413
|
setSearch(INITIAL_SEARCH);
|
|
436
414
|
onQueryChange?.("");
|
|
@@ -440,7 +418,7 @@ var useSearchOptions = (options, selected, listId, open, searchProps = {}) => {
|
|
|
440
418
|
open,
|
|
441
419
|
onQueryChange
|
|
442
420
|
]);
|
|
443
|
-
|
|
421
|
+
useEffect2(() => {
|
|
444
422
|
if (open && activeOptionId !== void 0) {
|
|
445
423
|
scrollOption(activeOptionId);
|
|
446
424
|
}
|
|
@@ -485,73 +463,91 @@ var useSearchOptions = (options, selected, listId, open, searchProps = {}) => {
|
|
|
485
463
|
};
|
|
486
464
|
};
|
|
487
465
|
|
|
488
|
-
// src/shared/
|
|
489
|
-
import {
|
|
466
|
+
// src/shared/selection-form.tsx
|
|
467
|
+
import { focusInvalidControl, useFormReset } from "@gridui/form";
|
|
468
|
+
import { useLayoutEffect, useRef as useRef3 } from "react";
|
|
490
469
|
import { flushSync as flushSync2 } from "react-dom";
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const focus = () => {
|
|
521
|
-
controlRef.current?.focus();
|
|
522
|
-
};
|
|
523
|
-
const finalFocus = () => {
|
|
524
|
-
const control = controlRef.current;
|
|
525
|
-
if (!restoreFocus.current || !control) {
|
|
526
|
-
return false;
|
|
527
|
-
}
|
|
528
|
-
const active = control.ownerDocument.activeElement;
|
|
529
|
-
if (active && active !== control.ownerDocument.body && active !== control && !popupRef.current?.contains(active)) {
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
return control;
|
|
533
|
-
};
|
|
534
|
-
const runAction = (action) => {
|
|
535
|
-
if (action.disabled || !available()) {
|
|
536
|
-
return false;
|
|
470
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
471
|
+
var SelectionForm = (props) => {
|
|
472
|
+
const {
|
|
473
|
+
name,
|
|
474
|
+
form,
|
|
475
|
+
required,
|
|
476
|
+
disabled,
|
|
477
|
+
selectedValue,
|
|
478
|
+
allOptions,
|
|
479
|
+
onValueChange,
|
|
480
|
+
onReset,
|
|
481
|
+
onInvalid
|
|
482
|
+
} = props;
|
|
483
|
+
const nativeRef = useRef3(null);
|
|
484
|
+
const resetSelection = useRef3(onReset);
|
|
485
|
+
const currentValue = useRef3(selectedValue);
|
|
486
|
+
useLayoutEffect(() => {
|
|
487
|
+
resetSelection.current = onReset;
|
|
488
|
+
currentValue.current = selectedValue;
|
|
489
|
+
}, [
|
|
490
|
+
onReset,
|
|
491
|
+
selectedValue
|
|
492
|
+
]);
|
|
493
|
+
useFormReset(nativeRef, () => {
|
|
494
|
+
flushSync2(() => {
|
|
495
|
+
resetSelection.current();
|
|
496
|
+
});
|
|
497
|
+
if (nativeRef.current) {
|
|
498
|
+
nativeRef.current.value = currentValue.current;
|
|
537
499
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
500
|
+
}, form);
|
|
501
|
+
return /* @__PURE__ */ jsxs3(
|
|
502
|
+
"select",
|
|
503
|
+
{
|
|
504
|
+
ref: nativeRef,
|
|
505
|
+
"aria-hidden": "true",
|
|
506
|
+
tabIndex: -1,
|
|
507
|
+
className: "gridui-u-select--sr-only",
|
|
508
|
+
name,
|
|
509
|
+
form,
|
|
510
|
+
required,
|
|
511
|
+
disabled,
|
|
512
|
+
value: selectedValue,
|
|
513
|
+
onChange: (event) => {
|
|
514
|
+
onValueChange(event.currentTarget.value);
|
|
515
|
+
},
|
|
516
|
+
onInvalid: (event) => {
|
|
517
|
+
focusInvalidControl(event, onInvalid);
|
|
518
|
+
},
|
|
519
|
+
children: [
|
|
520
|
+
!allOptions.some((option) => {
|
|
521
|
+
return option.value === "";
|
|
522
|
+
}) && /* @__PURE__ */ jsx4(
|
|
523
|
+
"option",
|
|
524
|
+
{
|
|
525
|
+
value: ""
|
|
526
|
+
}
|
|
527
|
+
),
|
|
528
|
+
selectedValue !== "" && !allOptions.some((option) => {
|
|
529
|
+
return option.value === selectedValue;
|
|
530
|
+
}) && /* @__PURE__ */ jsx4(
|
|
531
|
+
"option",
|
|
532
|
+
{
|
|
533
|
+
value: selectedValue,
|
|
534
|
+
children: selectedValue
|
|
535
|
+
}
|
|
536
|
+
),
|
|
537
|
+
allOptions.map((option) => {
|
|
538
|
+
return /* @__PURE__ */ jsx4(
|
|
539
|
+
"option",
|
|
540
|
+
{
|
|
541
|
+
value: option.value,
|
|
542
|
+
disabled: option.disabled,
|
|
543
|
+
children: option.label
|
|
544
|
+
},
|
|
545
|
+
option.value
|
|
546
|
+
);
|
|
547
|
+
})
|
|
548
|
+
]
|
|
541
549
|
}
|
|
542
|
-
|
|
543
|
-
return true;
|
|
544
|
-
};
|
|
545
|
-
return {
|
|
546
|
-
open: localOpen && !unavailable,
|
|
547
|
-
popupRef,
|
|
548
|
-
available,
|
|
549
|
-
changeOpen,
|
|
550
|
-
close,
|
|
551
|
-
focus,
|
|
552
|
-
finalFocus,
|
|
553
|
-
runAction
|
|
554
|
-
};
|
|
550
|
+
);
|
|
555
551
|
};
|
|
556
552
|
|
|
557
553
|
// src/shared/use-selection-value.ts
|
|
@@ -588,8 +584,8 @@ var useSelectionValue = (props, available) => {
|
|
|
588
584
|
|
|
589
585
|
// src/combobox/style.ts
|
|
590
586
|
import { cva as cva2 } from "class-variance-authority";
|
|
591
|
-
var comboboxInputStyles = cva2("gridui-u-pr-11 gridui-u-text-ellipsis");
|
|
592
|
-
var comboboxTriggerStyles = cva2("gridui-u-absolute gridui-u-inset-y-0 gridui-u-right-0 gridui-u-flex gridui-u-w-9 gridui-u-items-center gridui-u-justify-center gridui-u-rounded-control gridui-u-text-foreground gridui-u-cursor-pointer gridui-u-disabled:cursor-not-allowed gridui-u-disabled:opacity-50");
|
|
587
|
+
var comboboxInputStyles = cva2("gridui-u-select--pr-11 gridui-u-select--text-ellipsis");
|
|
588
|
+
var comboboxTriggerStyles = cva2("gridui-u-select--absolute gridui-u-select--inset-y-0 gridui-u-select--right-0 gridui-u-select--flex gridui-u-select--w-9 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--rounded-control gridui-u-select--text-foreground gridui-u-select--cursor-pointer gridui-u-select--disabled:cursor-not-allowed gridui-u-select--disabled:opacity-50");
|
|
593
589
|
|
|
594
590
|
// src/combobox/combobox.tsx
|
|
595
591
|
import { controlVariants } from "@gridui/input";
|
|
@@ -677,7 +673,7 @@ var Combobox = (props) => {
|
|
|
677
673
|
/* @__PURE__ */ jsxs4(
|
|
678
674
|
"div",
|
|
679
675
|
{
|
|
680
|
-
className: "gridui-u-relative gridui-u-flex gridui-u-min-w-0 gridui-u-w-full gridui-u-items-stretch gridui-u-gap-gridui-4",
|
|
676
|
+
className: "gridui-u-select--relative gridui-u-select--flex gridui-u-select--min-w-0 gridui-u-select--w-full gridui-u-select--items-stretch gridui-u-select--gap-gridui-4",
|
|
681
677
|
dir,
|
|
682
678
|
children: [
|
|
683
679
|
/* @__PURE__ */ jsx5(
|
|
@@ -688,7 +684,7 @@ var Combobox = (props) => {
|
|
|
688
684
|
"div",
|
|
689
685
|
{
|
|
690
686
|
ref: anchorRef,
|
|
691
|
-
className: "gridui-u-relative gridui-u-flex gridui-u-min-w-0 gridui-u-flex-1 gridui-u-items-stretch",
|
|
687
|
+
className: "gridui-u-select--relative gridui-u-select--flex gridui-u-select--min-w-0 gridui-u-select--flex-1 gridui-u-select--items-stretch",
|
|
692
688
|
children: [
|
|
693
689
|
/* @__PURE__ */ jsx5(
|
|
694
690
|
"input",
|
|
@@ -816,7 +812,7 @@ var Combobox = (props) => {
|
|
|
816
812
|
close();
|
|
817
813
|
focus();
|
|
818
814
|
},
|
|
819
|
-
className: cn2(controlVariants({ size: controlSize }), "gridui-u-flex gridui-u-w-auto gridui-u-shrink-0 gridui-u-items-center gridui-u-justify-center gridui-u-min-w-11 gridui-u-cursor-pointer"),
|
|
815
|
+
className: cn2(controlVariants({ size: controlSize }), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-11 gridui-u-select--cursor-pointer"),
|
|
820
816
|
children: /* @__PURE__ */ jsx5(
|
|
821
817
|
X,
|
|
822
818
|
{
|
|
@@ -866,7 +862,7 @@ var Combobox = (props) => {
|
|
|
866
862
|
{
|
|
867
863
|
role: "status",
|
|
868
864
|
"aria-atomic": "true",
|
|
869
|
-
className: cn2(selectEmptyStyles(), "gridui-u-empty:hidden"),
|
|
865
|
+
className: cn2(selectEmptyStyles(), "gridui-u-select--empty:hidden"),
|
|
870
866
|
children: loading ? loadingLabel : errorLabel ?? (visible.length ? resultCountLabel?.(visible.length) : emptyLabel)
|
|
871
867
|
}
|
|
872
868
|
),
|
|
@@ -981,7 +977,7 @@ var MultiSelect = (props) => {
|
|
|
981
977
|
/* @__PURE__ */ jsxs5(
|
|
982
978
|
"div",
|
|
983
979
|
{
|
|
984
|
-
className: "gridui-u-flex gridui-u-min-w-0 gridui-u-items-stretch gridui-u-gap-gridui-4",
|
|
980
|
+
className: "gridui-u-select--flex gridui-u-select--min-w-0 gridui-u-select--items-stretch gridui-u-select--gap-gridui-4",
|
|
985
981
|
dir: restProps.dir,
|
|
986
982
|
children: [
|
|
987
983
|
/* @__PURE__ */ jsx6(
|
|
@@ -1006,7 +1002,7 @@ var MultiSelect = (props) => {
|
|
|
1006
1002
|
ref.current = element;
|
|
1007
1003
|
}
|
|
1008
1004
|
},
|
|
1009
|
-
className: cn3(controlVariants2(), "gridui-u-flex gridui-u-flex-1 gridui-u-items-center gridui-u-gap-gridui-8 gridui-u-text-start", className),
|
|
1005
|
+
className: cn3(controlVariants2(), "gridui-u-select--flex gridui-u-select--flex-1 gridui-u-select--items-center gridui-u-select--gap-gridui-8 gridui-u-select--text-start", className),
|
|
1010
1006
|
onKeyDown: (event) => {
|
|
1011
1007
|
onKeyDown?.(event);
|
|
1012
1008
|
if (!event.defaultPrevented && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
|
|
@@ -1018,7 +1014,7 @@ var MultiSelect = (props) => {
|
|
|
1018
1014
|
/* @__PURE__ */ jsx6(
|
|
1019
1015
|
"span",
|
|
1020
1016
|
{
|
|
1021
|
-
className: "gridui-u-min-w-0 gridui-u-flex-1 gridui-u-wrap-anywhere",
|
|
1017
|
+
className: "gridui-u-select--min-w-0 gridui-u-select--flex-1 gridui-u-select--wrap-anywhere",
|
|
1022
1018
|
children: selected.length ? selected.map((entry) => {
|
|
1023
1019
|
return all.find((option) => {
|
|
1024
1020
|
return option.value === entry;
|
|
@@ -1044,7 +1040,7 @@ var MultiSelect = (props) => {
|
|
|
1044
1040
|
type: "button",
|
|
1045
1041
|
"aria-label": clearLabel,
|
|
1046
1042
|
disabled: disabled || readOnly || required || !selected.length,
|
|
1047
|
-
className: cn3(controlVariants2(), "gridui-u-flex gridui-u-w-auto gridui-u-shrink-0 gridui-u-items-center gridui-u-justify-center gridui-u-min-w-11 gridui-u-cursor-pointer"),
|
|
1043
|
+
className: cn3(controlVariants2(), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-11 gridui-u-select--cursor-pointer"),
|
|
1048
1044
|
onClick: () => {
|
|
1049
1045
|
change([]);
|
|
1050
1046
|
control.current?.focus();
|
|
@@ -1132,7 +1128,7 @@ var MultiSelect = (props) => {
|
|
|
1132
1128
|
"aria-controls": `${id}-list`,
|
|
1133
1129
|
"aria-activedescendant": activeOptionId,
|
|
1134
1130
|
value: query ?? "",
|
|
1135
|
-
className: cn3(controlVariants2({ size: "small" }), "gridui-u-
|
|
1131
|
+
className: cn3(controlVariants2({ size: "small" }), "gridui-u-select--m-gridui-8 gridui-u-select--w-auto gridui-u-select--shrink-0"),
|
|
1136
1132
|
onChange: (event) => {
|
|
1137
1133
|
searchOptions.changeQuery(event.target.value);
|
|
1138
1134
|
},
|
|
@@ -1174,7 +1170,7 @@ var MultiSelect = (props) => {
|
|
|
1174
1170
|
{
|
|
1175
1171
|
role: "status",
|
|
1176
1172
|
"aria-atomic": "true",
|
|
1177
|
-
className: cn3(selectEmptyStyles(), "gridui-u-empty:hidden"),
|
|
1173
|
+
className: cn3(selectEmptyStyles(), "gridui-u-select--empty:hidden"),
|
|
1178
1174
|
children: loading ? loadingLabel : errorLabel ?? (visible.length ? resultCountLabel?.(visible.length) : emptyLabel)
|
|
1179
1175
|
}
|
|
1180
1176
|
)
|
|
@@ -1186,29 +1182,8 @@ var MultiSelect = (props) => {
|
|
|
1186
1182
|
);
|
|
1187
1183
|
};
|
|
1188
1184
|
|
|
1189
|
-
// src/select/style.ts
|
|
1190
|
-
import { overlaySurfaceStyles as overlaySurfaceStyles2 } from "@gridui/overlay";
|
|
1191
|
-
import { cn as cn4 } from "@gridui/style-utils";
|
|
1192
|
-
import { cva as cva3 } from "class-variance-authority";
|
|
1193
|
-
var selectContentStyles = cva3(cn4(
|
|
1194
|
-
overlaySurfaceStyles2(),
|
|
1195
|
-
"gridui-u-z-(--gridui-z-popover) gridui-u-p-gridui-4 gridui-u-type-data",
|
|
1196
|
-
"gridui-select-content gridui-u-box-border gridui-u-relative gridui-u-flex gridui-u-flex-col gridui-u-overflow-hidden gridui-u-min-w-0 gridui-u-w-(--anchor-width) gridui-u-max-w-(--available-width) gridui-u-max-h-(--available-height)"
|
|
1197
|
-
));
|
|
1198
|
-
var selectMenuItemStyles = cva3(cn4(selectItemStyles(), "gridui-u-relative gridui-u-px-gridui-4 gridui-u-pr-9"));
|
|
1199
|
-
var selectIndicatorStyles = cva3("gridui-u-absolute gridui-u-inset-y-0 gridui-u-right-gridui-4 gridui-u-flex gridui-u-w-gridui-16 gridui-u-items-center gridui-u-justify-center gridui-u-text-foreground");
|
|
1200
|
-
var selectScrollArrowStyles = cva3("gridui-u-absolute gridui-u-inset-x-0 gridui-u-z-(--gridui-z-content) gridui-u-flex gridui-u-h-gridui-24 gridui-u-items-center gridui-u-justify-center gridui-u-bg-background gridui-u-text-foreground", {
|
|
1201
|
-
variants: {
|
|
1202
|
-
direction: {
|
|
1203
|
-
up: "gridui-u-top-0",
|
|
1204
|
-
down: "gridui-u-bottom-0"
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
|
|
1209
1185
|
// src/select/select-options.tsx
|
|
1210
|
-
import {
|
|
1211
|
-
import { useInteractionOutline as useInteractionOutline2, useScrollbars as useScrollbars2 } from "@gridui/overlay";
|
|
1186
|
+
import { overlayListIndicatorStyles as overlayListIndicatorStyles2, overlayListItemStyles as overlayListItemStyles3, overlayListLabelStyles as overlayListLabelStyles2, useInteractionOutline as useInteractionOutline2, useScrollbars as useScrollbars2 } from "@gridui/overlay";
|
|
1212
1187
|
import * as Primitive4 from "@radix-ui/react-select";
|
|
1213
1188
|
import { Check as Check2 } from "lucide-react";
|
|
1214
1189
|
import { useId as useId3 } from "react";
|
|
@@ -1245,7 +1220,7 @@ var SelectOptions = (props) => {
|
|
|
1245
1220
|
/* @__PURE__ */ jsx7(
|
|
1246
1221
|
Primitive4.Label,
|
|
1247
1222
|
{
|
|
1248
|
-
className:
|
|
1223
|
+
className: overlayListLabelStyles2(),
|
|
1249
1224
|
children: entry.label
|
|
1250
1225
|
}
|
|
1251
1226
|
),
|
|
@@ -1278,7 +1253,7 @@ var SelectOptionItem = (props) => {
|
|
|
1278
1253
|
"aria-describedby": option.description ? descriptionId : void 0,
|
|
1279
1254
|
textValue: option.label,
|
|
1280
1255
|
disabled: option.disabled,
|
|
1281
|
-
className:
|
|
1256
|
+
className: overlayListItemStyles3(),
|
|
1282
1257
|
children: [
|
|
1283
1258
|
option.icon && /* @__PURE__ */ jsx7(
|
|
1284
1259
|
"span",
|
|
@@ -1312,16 +1287,16 @@ var SelectOptionItem = (props) => {
|
|
|
1312
1287
|
}
|
|
1313
1288
|
),
|
|
1314
1289
|
/* @__PURE__ */ jsx7(
|
|
1315
|
-
|
|
1290
|
+
"span",
|
|
1316
1291
|
{
|
|
1317
|
-
className:
|
|
1292
|
+
className: overlayListIndicatorStyles2(),
|
|
1318
1293
|
"aria-hidden": "true",
|
|
1319
|
-
children: /* @__PURE__ */ jsx7(
|
|
1294
|
+
children: /* @__PURE__ */ jsx7(Primitive4.ItemIndicator, { children: /* @__PURE__ */ jsx7(
|
|
1320
1295
|
Check2,
|
|
1321
1296
|
{
|
|
1322
1297
|
size: 16
|
|
1323
1298
|
}
|
|
1324
|
-
)
|
|
1299
|
+
) })
|
|
1325
1300
|
}
|
|
1326
1301
|
)
|
|
1327
1302
|
]
|
|
@@ -1329,6 +1304,23 @@ var SelectOptionItem = (props) => {
|
|
|
1329
1304
|
);
|
|
1330
1305
|
};
|
|
1331
1306
|
|
|
1307
|
+
// src/select/style.ts
|
|
1308
|
+
import { overlayListStyles as overlayListStyles2 } from "@gridui/overlay";
|
|
1309
|
+
import { cn as cn4 } from "@gridui/style-utils";
|
|
1310
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
1311
|
+
var selectContentStyles = cva3(cn4(
|
|
1312
|
+
overlayListStyles2(),
|
|
1313
|
+
"gridui-select-content gridui-u-select--box-border gridui-u-select--relative gridui-u-select--flex gridui-u-select--flex-col gridui-u-select--overflow-hidden gridui-u-select--min-w-0 gridui-u-select--w-(--anchor-width) gridui-u-select--max-w-(--available-width) gridui-u-select--max-h-(--available-height)"
|
|
1314
|
+
));
|
|
1315
|
+
var selectScrollArrowStyles = cva3("gridui-u-select--absolute gridui-u-select--inset-x-0 gridui-u-select--z-(--gridui-z-content) gridui-u-select--flex gridui-u-select--h-gridui-24 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--bg-background gridui-u-select--text-foreground", {
|
|
1316
|
+
variants: {
|
|
1317
|
+
direction: {
|
|
1318
|
+
up: "gridui-u-select--top-0",
|
|
1319
|
+
down: "gridui-u-select--bottom-0"
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1332
1324
|
// src/select/select.tsx
|
|
1333
1325
|
import { controlVariants as controlVariants3 } from "@gridui/input";
|
|
1334
1326
|
import { interactionLayerProps as interactionLayerProps2 } from "@gridui/overlay";
|
|
@@ -1409,7 +1401,7 @@ var Select = (props) => {
|
|
|
1409
1401
|
/* @__PURE__ */ jsxs7(
|
|
1410
1402
|
"div",
|
|
1411
1403
|
{
|
|
1412
|
-
className: "gridui-u-relative gridui-u-flex gridui-u-min-w-0 gridui-u-w-full gridui-u-items-stretch gridui-u-gap-gridui-4",
|
|
1404
|
+
className: "gridui-u-select--relative gridui-u-select--flex gridui-u-select--min-w-0 gridui-u-select--w-full gridui-u-select--items-stretch gridui-u-select--gap-gridui-4",
|
|
1413
1405
|
dir,
|
|
1414
1406
|
children: [
|
|
1415
1407
|
/* @__PURE__ */ jsxs7(
|
|
@@ -1428,7 +1420,7 @@ var Select = (props) => {
|
|
|
1428
1420
|
ref.current = element;
|
|
1429
1421
|
}
|
|
1430
1422
|
},
|
|
1431
|
-
className: cn5(controlVariants3({ size: controlSize }), "gridui-u-flex gridui-u-flex-1 gridui-u-items-center gridui-u-gap-gridui-8 gridui-u-text-start", className),
|
|
1423
|
+
className: cn5(controlVariants3({ size: controlSize }), "gridui-u-select--flex gridui-u-select--flex-1 gridui-u-select--items-center gridui-u-select--gap-gridui-8 gridui-u-select--text-start", className),
|
|
1432
1424
|
children: [
|
|
1433
1425
|
selected?.icon && /* @__PURE__ */ jsx8(
|
|
1434
1426
|
"span",
|
|
@@ -1441,7 +1433,7 @@ var Select = (props) => {
|
|
|
1441
1433
|
/* @__PURE__ */ jsx8(
|
|
1442
1434
|
"span",
|
|
1443
1435
|
{
|
|
1444
|
-
className: "gridui-u-min-w-0 gridui-u-flex-1 gridui-u-whitespace-normal gridui-u-wrap-anywhere",
|
|
1436
|
+
className: "gridui-u-select--min-w-0 gridui-u-select--flex-1 gridui-u-select--whitespace-normal gridui-u-select--wrap-anywhere",
|
|
1445
1437
|
children: /* @__PURE__ */ jsx8(
|
|
1446
1438
|
Primitive5.Value,
|
|
1447
1439
|
{
|
|
@@ -1455,7 +1447,7 @@ var Select = (props) => {
|
|
|
1455
1447
|
ChevronDown3,
|
|
1456
1448
|
{
|
|
1457
1449
|
size: 16,
|
|
1458
|
-
className: "gridui-u-shrink-0",
|
|
1450
|
+
className: "gridui-u-select--shrink-0",
|
|
1459
1451
|
"aria-hidden": "true"
|
|
1460
1452
|
}
|
|
1461
1453
|
) })
|
|
@@ -1472,7 +1464,7 @@ var Select = (props) => {
|
|
|
1472
1464
|
change("");
|
|
1473
1465
|
controlRef.current?.focus();
|
|
1474
1466
|
},
|
|
1475
|
-
className: cn5(controlVariants3({ size: controlSize }), "gridui-u-flex gridui-u-w-auto gridui-u-shrink-0 gridui-u-items-center gridui-u-justify-center gridui-u-min-w-11 gridui-u-cursor-pointer"),
|
|
1467
|
+
className: cn5(controlVariants3({ size: controlSize }), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-11 gridui-u-select--cursor-pointer"),
|
|
1476
1468
|
children: /* @__PURE__ */ jsx8(
|
|
1477
1469
|
X3,
|
|
1478
1470
|
{
|
|
@@ -1560,7 +1552,7 @@ var Select = (props) => {
|
|
|
1560
1552
|
/* @__PURE__ */ jsxs7(
|
|
1561
1553
|
"div",
|
|
1562
1554
|
{
|
|
1563
|
-
className: "gridui-u-relative gridui-u-flex gridui-u-min-h-0 gridui-u-flex-col",
|
|
1555
|
+
className: "gridui-u-select--relative gridui-u-select--flex gridui-u-select--min-h-0 gridui-u-select--flex-col",
|
|
1564
1556
|
children: [
|
|
1565
1557
|
/* @__PURE__ */ jsx8(
|
|
1566
1558
|
Primitive5.ScrollUpButton,
|