@strapi/ui-primitives 0.0.0-3cf3ff39 → 0.0.0-622b91ef
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/dist/index.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { jsx as f, jsxs as
|
|
1
|
+
import { jsx as f, jsxs as Ae, Fragment as _e } from "react/jsx-runtime";
|
|
2
2
|
import * as l from "react";
|
|
3
|
-
import { useComposedRefs as
|
|
4
|
-
import { createContextScope as
|
|
5
|
-
import { Slot as
|
|
3
|
+
import { useComposedRefs as M } from "@radix-ui/react-compose-refs";
|
|
4
|
+
import { createContextScope as ot, createContext as nt } from "@radix-ui/react-context";
|
|
5
|
+
import { Slot as Te } from "@radix-ui/react-slot";
|
|
6
6
|
import { composeEventHandlers as T } from "@radix-ui/primitive";
|
|
7
|
-
import { composeEventHandlers as
|
|
8
|
-
import { DismissableLayer as
|
|
9
|
-
import { useFocusGuards as
|
|
10
|
-
import { FocusScope as
|
|
11
|
-
import { useId as
|
|
7
|
+
import { composeEventHandlers as An } from "@radix-ui/primitive";
|
|
8
|
+
import { DismissableLayer as rt } from "@radix-ui/react-dismissable-layer";
|
|
9
|
+
import { useFocusGuards as lt } from "@radix-ui/react-focus-guards";
|
|
10
|
+
import { FocusScope as st } from "@radix-ui/react-focus-scope";
|
|
11
|
+
import { useId as re } from "@radix-ui/react-id";
|
|
12
12
|
import * as le from "@radix-ui/react-popper";
|
|
13
|
-
import { createPopperScope as
|
|
14
|
-
import { Portal as
|
|
15
|
-
import { Primitive as
|
|
13
|
+
import { createPopperScope as ct } from "@radix-ui/react-popper";
|
|
14
|
+
import { Portal as it } from "@radix-ui/react-portal";
|
|
15
|
+
import { Primitive as N } from "@radix-ui/react-primitive";
|
|
16
16
|
import { useControllableState as ie } from "@radix-ui/react-use-controllable-state";
|
|
17
|
-
import { useLayoutEffect as
|
|
18
|
-
import { hideOthers as
|
|
19
|
-
import * as
|
|
20
|
-
import { RemoveScroll as
|
|
21
|
-
import { clamp as
|
|
22
|
-
import { createCollection as
|
|
23
|
-
import { useDirection as
|
|
24
|
-
import { usePrevious as
|
|
25
|
-
import { VisuallyHidden as
|
|
26
|
-
import { useCallbackRef as
|
|
27
|
-
import { useCallbackRef as
|
|
28
|
-
function
|
|
29
|
-
const
|
|
17
|
+
import { useLayoutEffect as L } from "@radix-ui/react-use-layout-effect";
|
|
18
|
+
import { hideOthers as at } from "aria-hidden";
|
|
19
|
+
import * as Ce from "react-dom";
|
|
20
|
+
import { RemoveScroll as ut } from "react-remove-scroll";
|
|
21
|
+
import { clamp as Qe } from "@radix-ui/number";
|
|
22
|
+
import { createCollection as Nt } from "@radix-ui/react-collection";
|
|
23
|
+
import { useDirection as At } from "@radix-ui/react-direction";
|
|
24
|
+
import { usePrevious as _t } from "@radix-ui/react-use-previous";
|
|
25
|
+
import { VisuallyHidden as Mt } from "@radix-ui/react-visually-hidden";
|
|
26
|
+
import { useCallbackRef as Ot } from "@radix-ui/react-use-callback-ref";
|
|
27
|
+
import { useCallbackRef as Mn } from "@radix-ui/react-use-callback-ref";
|
|
28
|
+
function Dt(r) {
|
|
29
|
+
const c = `${r}CollectionProvider`, [e, t] = ot(c), [o, n] = e(c, {
|
|
30
30
|
collectionRef: { current: null },
|
|
31
31
|
itemMap: /* @__PURE__ */ new Map(),
|
|
32
32
|
listeners: /* @__PURE__ */ new Set()
|
|
33
|
-
}), i = (
|
|
34
|
-
const { scope:
|
|
35
|
-
return /* @__PURE__ */ f(o, { scope:
|
|
33
|
+
}), i = (d) => {
|
|
34
|
+
const { scope: h, children: v } = d, C = l.useRef(null), b = l.useRef(/* @__PURE__ */ new Map()).current, g = l.useRef(/* @__PURE__ */ new Set()).current;
|
|
35
|
+
return /* @__PURE__ */ f(o, { scope: h, itemMap: b, collectionRef: C, listeners: g, children: v });
|
|
36
36
|
};
|
|
37
|
-
i.displayName =
|
|
38
|
-
const
|
|
39
|
-
const { scope:
|
|
40
|
-
return /* @__PURE__ */ f(
|
|
37
|
+
i.displayName = c;
|
|
38
|
+
const s = `${r}CollectionSlot`, a = l.forwardRef((d, h) => {
|
|
39
|
+
const { scope: v, children: C } = d, b = n(s, v), g = M(h, b.collectionRef);
|
|
40
|
+
return /* @__PURE__ */ f(Te, { ref: g, children: C });
|
|
41
41
|
});
|
|
42
|
-
a.displayName =
|
|
43
|
-
const
|
|
44
|
-
const { scope:
|
|
42
|
+
a.displayName = s;
|
|
43
|
+
const m = `${r}CollectionItemSlot`, u = "data-radix-collection-item", x = l.forwardRef((d, h) => {
|
|
44
|
+
const { scope: v, children: C, ...b } = d, g = l.useRef(null), I = M(h, g), E = n(m, v);
|
|
45
45
|
return l.useEffect(() => {
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
|
|
46
|
+
const O = Array.from(E.itemMap.values());
|
|
47
|
+
return E.itemMap.set(g, { ref: g, ...b }), E.listeners.forEach((A) => A(Array.from(E.itemMap.values()), O)), () => {
|
|
48
|
+
const A = Array.from(E.itemMap.values());
|
|
49
|
+
E.itemMap.delete(g), E.listeners.forEach((_) => _(Array.from(E.itemMap.values()), A));
|
|
50
50
|
};
|
|
51
|
-
}), /* @__PURE__ */ f(
|
|
51
|
+
}), /* @__PURE__ */ f(Te, { [u]: "", ref: I, children: C });
|
|
52
52
|
});
|
|
53
|
-
x.displayName =
|
|
54
|
-
function d
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
53
|
+
x.displayName = m;
|
|
54
|
+
function p(d) {
|
|
55
|
+
const h = n(`${r}CollectionConsumer`, d), v = l.useCallback(() => {
|
|
56
|
+
const b = h.collectionRef.current;
|
|
57
|
+
if (!b)
|
|
58
58
|
return [];
|
|
59
|
-
const
|
|
60
|
-
return Array.from(
|
|
61
|
-
(
|
|
59
|
+
const g = Array.from(b.querySelectorAll(`[${u}]`));
|
|
60
|
+
return Array.from(h.itemMap.values()).sort(
|
|
61
|
+
(O, A) => g.indexOf(O.ref.current) - g.indexOf(A.ref.current)
|
|
62
62
|
);
|
|
63
|
-
}, [
|
|
64
|
-
(
|
|
65
|
-
[
|
|
63
|
+
}, [h.collectionRef, h.itemMap]), C = l.useCallback(
|
|
64
|
+
(b) => (h.listeners.add(b), () => h.listeners.delete(b)),
|
|
65
|
+
[h.listeners]
|
|
66
66
|
);
|
|
67
|
-
return { getItems:
|
|
67
|
+
return { getItems: v, subscribe: C };
|
|
68
68
|
}
|
|
69
69
|
return [
|
|
70
70
|
{ Provider: i, Slot: a, ItemSlot: x },
|
|
71
|
-
|
|
71
|
+
p,
|
|
72
72
|
t
|
|
73
73
|
];
|
|
74
74
|
}
|
|
75
|
-
let
|
|
76
|
-
function
|
|
77
|
-
let e = r + (
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
80
|
-
let t = new Intl.Collator(r,
|
|
81
|
-
return
|
|
75
|
+
let ye = /* @__PURE__ */ new Map();
|
|
76
|
+
function kt(r, c) {
|
|
77
|
+
let e = r + (c ? Object.entries(c).sort((o, n) => o[0] < n[0] ? -1 : 1).join() : "");
|
|
78
|
+
if (ye.has(e))
|
|
79
|
+
return ye.get(e);
|
|
80
|
+
let t = new Intl.Collator(r, c);
|
|
81
|
+
return ye.set(e, t), t;
|
|
82
82
|
}
|
|
83
|
-
function Me(r,
|
|
84
|
-
let e =
|
|
83
|
+
function Me(r, c) {
|
|
84
|
+
let e = kt(r, {
|
|
85
85
|
usage: "search",
|
|
86
|
-
...
|
|
86
|
+
...c
|
|
87
87
|
});
|
|
88
88
|
return {
|
|
89
89
|
startsWith(t, o) {
|
|
@@ -98,111 +98,111 @@ function Me(r, s) {
|
|
|
98
98
|
t = t.normalize("NFC"), o = o.normalize("NFC");
|
|
99
99
|
let n = 0, i = o.length;
|
|
100
100
|
for (; n + i <= t.length; n++) {
|
|
101
|
-
let
|
|
102
|
-
if (e.compare(o,
|
|
101
|
+
let s = t.slice(n, n + i);
|
|
102
|
+
if (e.compare(o, s) === 0)
|
|
103
103
|
return !0;
|
|
104
104
|
}
|
|
105
105
|
return !1;
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
const
|
|
109
|
+
const Ft = (r) => {
|
|
110
|
+
const c = l.useRef();
|
|
111
111
|
return l.useEffect(() => {
|
|
112
|
-
|
|
113
|
-
}),
|
|
114
|
-
},
|
|
112
|
+
c.current = r;
|
|
113
|
+
}), c.current;
|
|
114
|
+
}, Lt = [" ", "Enter", "ArrowUp", "ArrowDown"], Bt = ["Enter"], Ht = (r) => !!(r.length === 1 && r.match(/\S| /)), dt = "Combobox", [ae, me] = Dt(dt), [$t, K] = nt(dt), Ut = ({ children: r }) => /* @__PURE__ */ f(le.Root, { children: /* @__PURE__ */ f(ae.Provider, { scope: void 0, children: r }) }), Kt = (r) => {
|
|
115
115
|
const {
|
|
116
|
-
allowCustomValue:
|
|
116
|
+
allowCustomValue: c = !1,
|
|
117
117
|
autocomplete: e = "none",
|
|
118
118
|
children: t,
|
|
119
119
|
open: o,
|
|
120
120
|
defaultOpen: n,
|
|
121
121
|
onOpenChange: i,
|
|
122
|
-
value:
|
|
122
|
+
value: s,
|
|
123
123
|
defaultValue: a,
|
|
124
|
-
onValueChange:
|
|
125
|
-
disabled:
|
|
124
|
+
onValueChange: m,
|
|
125
|
+
disabled: u,
|
|
126
126
|
required: x = !1,
|
|
127
|
-
locale:
|
|
128
|
-
onTextValueChange:
|
|
129
|
-
textValue:
|
|
130
|
-
defaultTextValue:
|
|
127
|
+
locale: p = "en-EN",
|
|
128
|
+
onTextValueChange: d,
|
|
129
|
+
textValue: h,
|
|
130
|
+
defaultTextValue: v,
|
|
131
131
|
filterValue: C,
|
|
132
|
-
defaultFilterValue:
|
|
133
|
-
onFilterValueChange:
|
|
134
|
-
isPrintableCharacter:
|
|
135
|
-
} = r, [
|
|
132
|
+
defaultFilterValue: b,
|
|
133
|
+
onFilterValueChange: g,
|
|
134
|
+
isPrintableCharacter: I = Ht
|
|
135
|
+
} = r, [E, O] = l.useState(null), [A, _] = l.useState(null), [k, q] = l.useState(null), [W, B] = l.useState(null), [D = !1, H] = ie({
|
|
136
136
|
prop: o,
|
|
137
137
|
defaultProp: n,
|
|
138
138
|
onChange: i
|
|
139
|
-
}), [F,
|
|
140
|
-
prop:
|
|
139
|
+
}), [F, z] = ie({
|
|
140
|
+
prop: s,
|
|
141
141
|
defaultProp: a,
|
|
142
|
-
onChange:
|
|
143
|
-
}), [
|
|
144
|
-
prop:
|
|
145
|
-
defaultProp:
|
|
146
|
-
onChange:
|
|
142
|
+
onChange: m
|
|
143
|
+
}), [G, $] = ie({
|
|
144
|
+
prop: h,
|
|
145
|
+
defaultProp: c && !v ? s : v,
|
|
146
|
+
onChange: d
|
|
147
147
|
}), [X, U] = ie({
|
|
148
148
|
prop: C,
|
|
149
|
-
defaultProp:
|
|
150
|
-
onChange:
|
|
151
|
-
}),
|
|
152
|
-
(
|
|
153
|
-
const Z = Q.map((y) => y.ref.current), [ce, ...ee] = Z, [S] = ee.slice(-1), V =
|
|
154
|
-
for (const y of
|
|
149
|
+
defaultProp: b,
|
|
150
|
+
onChange: g
|
|
151
|
+
}), de = re(), se = l.useCallback(
|
|
152
|
+
(fe, Q) => {
|
|
153
|
+
const Z = Q.map((y) => y.ref.current), [ce, ...ee] = Z, [S] = ee.slice(-1), V = W ?? Q.find((y) => y.value === F)?.ref.current;
|
|
154
|
+
for (const y of fe) {
|
|
155
155
|
if (y === V)
|
|
156
156
|
return;
|
|
157
|
-
if (y?.scrollIntoView({ block: "nearest" }), y === ce &&
|
|
158
|
-
const
|
|
159
|
-
|
|
157
|
+
if (y?.scrollIntoView({ block: "nearest" }), y === ce && A && (A.scrollTop = 0), y === S && A && (A.scrollTop = A.scrollHeight), B(y), e === "both") {
|
|
158
|
+
const w = Q.find((P) => P.ref.current === y);
|
|
159
|
+
w && $(w.textValue);
|
|
160
160
|
}
|
|
161
161
|
if (y !== V)
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
},
|
|
165
|
-
[e, $,
|
|
165
|
+
[e, $, A, W, F]
|
|
166
166
|
);
|
|
167
167
|
return l.useEffect(() => {
|
|
168
|
-
e !== "both" &&
|
|
169
|
-
}, [
|
|
170
|
-
if (k &&
|
|
171
|
-
return
|
|
172
|
-
}, [k,
|
|
173
|
-
|
|
168
|
+
e !== "both" && B(null);
|
|
169
|
+
}, [G, e]), l.useEffect(() => {
|
|
170
|
+
if (k && E)
|
|
171
|
+
return at([k, E]);
|
|
172
|
+
}, [k, E]), /* @__PURE__ */ f(Ut, { children: /* @__PURE__ */ f(
|
|
173
|
+
$t,
|
|
174
174
|
{
|
|
175
|
-
allowCustomValue:
|
|
175
|
+
allowCustomValue: c,
|
|
176
176
|
autocomplete: e,
|
|
177
177
|
required: x,
|
|
178
|
-
trigger:
|
|
179
|
-
onTriggerChange:
|
|
180
|
-
contentId:
|
|
178
|
+
trigger: E,
|
|
179
|
+
onTriggerChange: O,
|
|
180
|
+
contentId: de,
|
|
181
181
|
value: F,
|
|
182
|
-
onValueChange:
|
|
182
|
+
onValueChange: z,
|
|
183
183
|
open: D,
|
|
184
184
|
onOpenChange: H,
|
|
185
|
-
disabled:
|
|
186
|
-
locale:
|
|
185
|
+
disabled: u,
|
|
186
|
+
locale: p,
|
|
187
187
|
focusFirst: se,
|
|
188
|
-
textValue:
|
|
188
|
+
textValue: G,
|
|
189
189
|
onTextValueChange: $,
|
|
190
|
-
onViewportChange:
|
|
190
|
+
onViewportChange: _,
|
|
191
191
|
onContentChange: q,
|
|
192
|
-
visuallyFocussedItem:
|
|
192
|
+
visuallyFocussedItem: W,
|
|
193
193
|
filterValue: X,
|
|
194
194
|
onFilterValueChange: U,
|
|
195
|
-
onVisuallyFocussedItemChange:
|
|
196
|
-
isPrintableCharacter:
|
|
195
|
+
onVisuallyFocussedItemChange: B,
|
|
196
|
+
isPrintableCharacter: I,
|
|
197
197
|
children: t
|
|
198
198
|
}
|
|
199
199
|
) });
|
|
200
|
-
},
|
|
201
|
-
const { ...e } = r, t =
|
|
200
|
+
}, Wt = "ComboboxTrigger", zt = l.forwardRef((r, c) => {
|
|
201
|
+
const { ...e } = r, t = K(Wt), o = () => {
|
|
202
202
|
t.disabled || t.onOpenChange(!0);
|
|
203
203
|
};
|
|
204
204
|
return /* @__PURE__ */ f(le.Anchor, { asChild: !0, children: /* @__PURE__ */ f(
|
|
205
|
-
|
|
205
|
+
st,
|
|
206
206
|
{
|
|
207
207
|
asChild: !0,
|
|
208
208
|
trapped: t.open,
|
|
@@ -215,7 +215,7 @@ const Dt = (r) => {
|
|
|
215
215
|
children: /* @__PURE__ */ f(
|
|
216
216
|
"div",
|
|
217
217
|
{
|
|
218
|
-
ref:
|
|
218
|
+
ref: c,
|
|
219
219
|
"data-disabled": t.disabled ? "" : void 0,
|
|
220
220
|
...e,
|
|
221
221
|
onClick: T(e.onClick, () => {
|
|
@@ -229,21 +229,21 @@ const Dt = (r) => {
|
|
|
229
229
|
)
|
|
230
230
|
}
|
|
231
231
|
) });
|
|
232
|
-
}),
|
|
233
|
-
const e =
|
|
232
|
+
}), ft = "ComboboxInput", Gt = l.forwardRef((r, c) => {
|
|
233
|
+
const e = K(ft), t = l.useRef(null), { getItems: o } = me(void 0), { startsWith: n } = Me(e.locale, { sensitivity: "base" }), i = e.disabled, s = M(t, c, e.onTriggerChange), a = () => {
|
|
234
234
|
i || e.onOpenChange(!0);
|
|
235
|
-
},
|
|
236
|
-
return
|
|
237
|
-
const
|
|
235
|
+
}, m = Ft(e.filterValue);
|
|
236
|
+
return L(() => {
|
|
237
|
+
const u = setTimeout(() => {
|
|
238
238
|
if (e.textValue === "" || e.textValue === void 0 || e.filterValue === "" || e.filterValue === void 0)
|
|
239
239
|
return;
|
|
240
240
|
const x = o().find(
|
|
241
|
-
(
|
|
242
|
-
),
|
|
243
|
-
x && !e.visuallyFocussedItem &&
|
|
241
|
+
(d) => d.type === "option" && n(d.textValue, e.textValue)
|
|
242
|
+
), p = So(m ?? "", e.filterValue);
|
|
243
|
+
x && !e.visuallyFocussedItem && p === e.filterValue.length && t.current?.setSelectionRange(e.filterValue.length, e.textValue.length);
|
|
244
244
|
});
|
|
245
|
-
return () => clearTimeout(
|
|
246
|
-
}, [e.textValue, e.filterValue, n, e.visuallyFocussedItem, o,
|
|
245
|
+
return () => clearTimeout(u);
|
|
246
|
+
}, [e.textValue, e.filterValue, n, e.visuallyFocussedItem, o, m]), /* @__PURE__ */ f(
|
|
247
247
|
"input",
|
|
248
248
|
{
|
|
249
249
|
type: "text",
|
|
@@ -260,80 +260,82 @@ const Dt = (r) => {
|
|
|
260
260
|
"data-placeholder": e.textValue === void 0 ? "" : void 0,
|
|
261
261
|
value: e.textValue ?? "",
|
|
262
262
|
...r,
|
|
263
|
-
ref:
|
|
264
|
-
onKeyDown: T(r.onKeyDown, (
|
|
265
|
-
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(
|
|
266
|
-
setTimeout(() => {
|
|
267
|
-
let
|
|
268
|
-
if (["ArrowUp", "End"].includes(
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
let
|
|
272
|
-
|
|
263
|
+
ref: s,
|
|
264
|
+
onKeyDown: T(r.onKeyDown, (u) => {
|
|
265
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(u.key))
|
|
266
|
+
e.open || a(), setTimeout(() => {
|
|
267
|
+
let p = o().filter((d) => !d.disabled && d.isVisible).map((d) => d.ref.current);
|
|
268
|
+
if (["ArrowUp", "End"].includes(u.key) && (p = p.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(u.key)) {
|
|
269
|
+
const d = e.visuallyFocussedItem ?? o().find((h) => h.value === e.value)?.ref.current;
|
|
270
|
+
if (d) {
|
|
271
|
+
let h = p.indexOf(d);
|
|
272
|
+
h === p.length - 1 && (h = -1), p = p.slice(h + 1);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
-
if (["ArrowDown"].includes(
|
|
276
|
-
const [
|
|
277
|
-
e.textValue ===
|
|
275
|
+
if (["ArrowDown"].includes(u.key) && e.autocomplete === "both" && p.length > 1) {
|
|
276
|
+
const [d, ...h] = p, v = o().find((C) => C.ref.current === d).textValue;
|
|
277
|
+
e.textValue === v && (p = h);
|
|
278
278
|
}
|
|
279
|
-
e.focusFirst(
|
|
280
|
-
}),
|
|
281
|
-
else if (["Tab"].includes(
|
|
282
|
-
|
|
283
|
-
else if (["Escape"].includes(
|
|
284
|
-
e.open ? e.onOpenChange(!1) : (e.onValueChange(void 0), e.onTextValueChange("")),
|
|
285
|
-
else if (
|
|
279
|
+
e.focusFirst(p, o());
|
|
280
|
+
}), u.preventDefault();
|
|
281
|
+
else if (["Tab"].includes(u.key) && e.open)
|
|
282
|
+
u.preventDefault();
|
|
283
|
+
else if (["Escape"].includes(u.key))
|
|
284
|
+
e.open ? e.onOpenChange(!1) : (e.onValueChange(void 0), e.onTextValueChange("")), u.preventDefault();
|
|
285
|
+
else if (Bt.includes(u.key)) {
|
|
286
286
|
if (e.visuallyFocussedItem) {
|
|
287
|
-
const x = o().find((
|
|
287
|
+
const x = o().find((p) => p.ref.current === e.visuallyFocussedItem);
|
|
288
288
|
x && (e.onValueChange(x.value), e.onTextValueChange(x.textValue), e.autocomplete === "both" && e.onFilterValueChange(x.textValue), x.ref.current?.click());
|
|
289
289
|
} else {
|
|
290
290
|
const x = o().find(
|
|
291
|
-
(
|
|
291
|
+
(p) => p.type === "option" && !p.disabled && p.textValue === e.textValue
|
|
292
292
|
);
|
|
293
293
|
x && (e.onValueChange(x.value), e.onTextValueChange(x.textValue), e.autocomplete === "both" && e.onFilterValueChange(x.textValue), x.ref.current?.click());
|
|
294
294
|
}
|
|
295
|
-
e.onOpenChange(!1),
|
|
295
|
+
e.onOpenChange(!1), u.preventDefault();
|
|
296
296
|
} else
|
|
297
297
|
e.onVisuallyFocussedItemChange(null);
|
|
298
298
|
}),
|
|
299
|
-
onChange: T(r.onChange, (
|
|
300
|
-
e.onTextValueChange(
|
|
299
|
+
onChange: T(r.onChange, (u) => {
|
|
300
|
+
e.onTextValueChange(u.currentTarget.value), e.autocomplete === "both" && e.onFilterValueChange(u.currentTarget.value);
|
|
301
301
|
}),
|
|
302
|
-
onKeyUp: T(r.onKeyUp, (
|
|
303
|
-
if (!e.open && (e.isPrintableCharacter(
|
|
304
|
-
if (e.autocomplete === "both" && e.isPrintableCharacter(
|
|
305
|
-
const x = e.filterValue,
|
|
306
|
-
|
|
302
|
+
onKeyUp: T(r.onKeyUp, (u) => {
|
|
303
|
+
if (!e.open && (e.isPrintableCharacter(u.key) || ["Backspace"].includes(u.key)) && a(), setTimeout(() => {
|
|
304
|
+
if (e.autocomplete === "both" && e.isPrintableCharacter(u.key) && e.filterValue !== void 0) {
|
|
305
|
+
const x = e.filterValue, p = o().find((d) => n(d.textValue, x));
|
|
306
|
+
p && e.onTextValueChange(p.textValue);
|
|
307
307
|
}
|
|
308
|
-
}), e.autocomplete === "none" && e.isPrintableCharacter(
|
|
309
|
-
const x = e.textValue ?? "",
|
|
310
|
-
|
|
308
|
+
}), e.autocomplete === "none" && e.isPrintableCharacter(u.key)) {
|
|
309
|
+
const x = e.textValue ?? "", p = o().find((d) => n(d.textValue, x));
|
|
310
|
+
p && (e.onVisuallyFocussedItemChange(p.ref.current), p.ref.current?.scrollIntoView());
|
|
311
311
|
}
|
|
312
312
|
}),
|
|
313
313
|
onBlur: T(r.onBlur, () => {
|
|
314
|
+
if (e.open)
|
|
315
|
+
return;
|
|
314
316
|
e.onVisuallyFocussedItemChange(null);
|
|
315
|
-
const [
|
|
316
|
-
(
|
|
317
|
+
const [u] = o().filter(
|
|
318
|
+
(p) => p.textValue === e.textValue && p.type === "option"
|
|
317
319
|
);
|
|
318
|
-
if (
|
|
319
|
-
e.onValueChange(
|
|
320
|
+
if (u) {
|
|
321
|
+
e.onValueChange(u.value), e.autocomplete === "both" && e.onFilterValueChange(u.textValue);
|
|
320
322
|
return;
|
|
321
323
|
}
|
|
322
324
|
if (e.allowCustomValue) {
|
|
323
325
|
e.onValueChange(e.textValue), e.autocomplete === "both" && e.onFilterValueChange(e.textValue);
|
|
324
326
|
return;
|
|
325
327
|
}
|
|
326
|
-
const [x] = o().filter((
|
|
328
|
+
const [x] = o().filter((p) => p.value === e.value && p.type === "option");
|
|
327
329
|
x && e.textValue !== "" ? (e.onTextValueChange(x.textValue), e.autocomplete === "both" && e.onFilterValueChange(x.textValue)) : (e.onValueChange(void 0), e.onTextValueChange(""));
|
|
328
330
|
})
|
|
329
331
|
}
|
|
330
332
|
);
|
|
331
|
-
}),
|
|
332
|
-
const { children: e, ...t } = r, o =
|
|
333
|
+
}), jt = l.forwardRef((r, c) => {
|
|
334
|
+
const { children: e, ...t } = r, o = K(ft), n = o.disabled, i = () => {
|
|
333
335
|
n || (o.onOpenChange(!0), o.trigger?.focus());
|
|
334
336
|
};
|
|
335
337
|
return /* @__PURE__ */ f(
|
|
336
|
-
|
|
338
|
+
N.button,
|
|
337
339
|
{
|
|
338
340
|
"aria-hidden": !0,
|
|
339
341
|
type: "button",
|
|
@@ -344,45 +346,49 @@ const Dt = (r) => {
|
|
|
344
346
|
"data-disabled": n ? "" : void 0,
|
|
345
347
|
...t,
|
|
346
348
|
tabIndex: -1,
|
|
347
|
-
ref:
|
|
349
|
+
ref: c,
|
|
348
350
|
onClick: T(t.onClick, () => {
|
|
349
351
|
o.trigger?.focus();
|
|
350
352
|
}),
|
|
351
|
-
onPointerDown: T(t.onPointerDown, (
|
|
352
|
-
|
|
353
|
+
onPointerDown: T(t.onPointerDown, (s) => {
|
|
354
|
+
s.button === 0 && s.ctrlKey === !1 && (i(), s.preventDefault());
|
|
353
355
|
}),
|
|
354
|
-
onKeyDown: T(t.onKeyDown, (
|
|
355
|
-
|
|
356
|
+
onKeyDown: T(t.onKeyDown, (s) => {
|
|
357
|
+
Lt.includes(s.key) && (i(), s.preventDefault());
|
|
356
358
|
}),
|
|
357
359
|
children: e || "▼"
|
|
358
360
|
}
|
|
359
361
|
);
|
|
360
|
-
}),
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
const e =
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
}, []),
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
362
|
+
}), Yt = "ComboboxPortal", pt = (r) => /* @__PURE__ */ f(it, { asChild: !0, ...r });
|
|
363
|
+
pt.displayName = Yt;
|
|
364
|
+
const mt = "ComboboxContent", qt = l.forwardRef((r, c) => {
|
|
365
|
+
const e = K(mt), { getItems: t } = me(void 0), [o, n] = l.useState();
|
|
366
|
+
if (L(() => {
|
|
367
|
+
n(new DocumentFragment());
|
|
368
|
+
}, []), L(() => {
|
|
369
|
+
e.open && e.autocomplete === "none" && setTimeout(() => {
|
|
370
|
+
t().find((s) => s.value === e.value)?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
371
|
+
});
|
|
372
|
+
}, [t, e.autocomplete, e.value, e.open]), !e.open) {
|
|
373
|
+
const i = o;
|
|
374
|
+
return i ? Ce.createPortal(
|
|
375
|
+
/* @__PURE__ */ f(ae.Slot, { scope: void 0, children: /* @__PURE__ */ f("div", { children: r.children }) }),
|
|
376
|
+
i
|
|
371
377
|
) : null;
|
|
372
378
|
}
|
|
373
|
-
return /* @__PURE__ */ f(
|
|
374
|
-
}),
|
|
375
|
-
(r,
|
|
376
|
-
const { onEscapeKeyDown: e, onPointerDownOutside: t, ...o } = r, n =
|
|
377
|
-
return
|
|
379
|
+
return /* @__PURE__ */ f(Zt, { ...r, ref: c });
|
|
380
|
+
}), Xt = 10, Zt = l.forwardRef(
|
|
381
|
+
(r, c) => {
|
|
382
|
+
const { onEscapeKeyDown: e, onPointerDownOutside: t, ...o } = r, n = K(mt), i = M(c, (a) => n.onContentChange(a)), { onOpenChange: s } = n;
|
|
383
|
+
return lt(), l.useEffect(() => {
|
|
378
384
|
const a = () => {
|
|
379
|
-
|
|
385
|
+
s(!1);
|
|
380
386
|
};
|
|
381
387
|
return window.addEventListener("blur", a), window.addEventListener("resize", a), () => {
|
|
382
388
|
window.removeEventListener("blur", a), window.removeEventListener("resize", a);
|
|
383
389
|
};
|
|
384
|
-
}, [
|
|
385
|
-
|
|
390
|
+
}, [s]), /* @__PURE__ */ f(ut, { allowPinchZoom: !0, children: /* @__PURE__ */ f(
|
|
391
|
+
rt,
|
|
386
392
|
{
|
|
387
393
|
asChild: !0,
|
|
388
394
|
onEscapeKeyDown: e,
|
|
@@ -394,7 +400,7 @@ const ut = "ComboboxContent", jt = l.forwardRef((r, s) => {
|
|
|
394
400
|
n.onOpenChange(!1), n.trigger?.focus({ preventScroll: !0 });
|
|
395
401
|
},
|
|
396
402
|
children: /* @__PURE__ */ f(
|
|
397
|
-
|
|
403
|
+
Jt,
|
|
398
404
|
{
|
|
399
405
|
role: "listbox",
|
|
400
406
|
id: n.contentId,
|
|
@@ -415,14 +421,14 @@ const ut = "ComboboxContent", jt = l.forwardRef((r, s) => {
|
|
|
415
421
|
}
|
|
416
422
|
) });
|
|
417
423
|
}
|
|
418
|
-
),
|
|
419
|
-
(r,
|
|
420
|
-
const { align: e = "start", collisionPadding: t =
|
|
424
|
+
), Jt = l.forwardRef(
|
|
425
|
+
(r, c) => {
|
|
426
|
+
const { align: e = "start", collisionPadding: t = Xt, ...o } = r;
|
|
421
427
|
return /* @__PURE__ */ f(
|
|
422
428
|
le.Content,
|
|
423
429
|
{
|
|
424
430
|
...o,
|
|
425
|
-
ref:
|
|
431
|
+
ref: c,
|
|
426
432
|
align: e,
|
|
427
433
|
collisionPadding: t,
|
|
428
434
|
style: {
|
|
@@ -438,9 +444,9 @@ const ut = "ComboboxContent", jt = l.forwardRef((r, s) => {
|
|
|
438
444
|
}
|
|
439
445
|
);
|
|
440
446
|
}
|
|
441
|
-
),
|
|
442
|
-
const e =
|
|
443
|
-
return /* @__PURE__ */
|
|
447
|
+
), Qt = "ComboboxViewport", eo = l.forwardRef((r, c) => {
|
|
448
|
+
const e = K(Qt), t = M(c, e.onViewportChange);
|
|
449
|
+
return /* @__PURE__ */ Ae(_e, { children: [
|
|
444
450
|
/* @__PURE__ */ f(
|
|
445
451
|
"style",
|
|
446
452
|
{
|
|
@@ -449,8 +455,8 @@ const ut = "ComboboxContent", jt = l.forwardRef((r, s) => {
|
|
|
449
455
|
}
|
|
450
456
|
}
|
|
451
457
|
),
|
|
452
|
-
/* @__PURE__ */ f(
|
|
453
|
-
|
|
458
|
+
/* @__PURE__ */ f(ae.Slot, { scope: void 0, children: /* @__PURE__ */ f(
|
|
459
|
+
N.div,
|
|
454
460
|
{
|
|
455
461
|
"data-radix-combobox-viewport": "",
|
|
456
462
|
role: "presentation",
|
|
@@ -468,175 +474,215 @@ const ut = "ComboboxContent", jt = l.forwardRef((r, s) => {
|
|
|
468
474
|
}
|
|
469
475
|
) })
|
|
470
476
|
] });
|
|
471
|
-
}),
|
|
472
|
-
const { value: e, disabled: t = !1, textValue: o, ...n } = r, i
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
visuallyFocussedItem: x,
|
|
476
|
-
...d
|
|
477
|
-
} = j(dt), u = ne(), [m, b] = l.useState(o ?? ""), C = l.useMemo(() => x === a().find((E) => E.ref.current === i.current)?.ref.current, [a, x]), v = d.value === e, h = () => {
|
|
478
|
-
t || (d.onValueChange(e), g(m), d.onOpenChange(!1), d.autocomplete === "both" && d.onFilterValueChange(m), d.trigger?.focus({ preventScroll: !0 }));
|
|
479
|
-
}, { startsWith: w } = Me(d.locale, { sensitivity: "base" }), R = l.useCallback((E) => {
|
|
480
|
-
b((N) => N || (E?.textContent ?? "").trim());
|
|
477
|
+
}), Oe = "ComboboxItem", [et, De] = nt(Oe), ht = l.forwardRef((r, c) => {
|
|
478
|
+
const { value: e, disabled: t = !1, textValue: o, ...n } = r, [i, s] = l.useState();
|
|
479
|
+
L(() => {
|
|
480
|
+
s(new DocumentFragment());
|
|
481
481
|
}, []);
|
|
482
|
-
l.
|
|
483
|
-
|
|
484
|
-
}, [
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
482
|
+
const { onTextValueChange: a, textValue: m, ...u } = K(Oe), x = re(), [p, d] = l.useState(o ?? ""), h = u.value === e, { startsWith: v } = Me(u.locale, { sensitivity: "base" }), C = l.useCallback((b) => {
|
|
483
|
+
d((g) => g || (b?.textContent ?? "").trim());
|
|
484
|
+
}, []);
|
|
485
|
+
return l.useEffect(() => {
|
|
486
|
+
h && m === void 0 && p !== "" && a(p);
|
|
487
|
+
}, [p, h, m, a]), u.autocomplete === "both" && p && u.filterValue && !v(p, u.filterValue) || u.autocomplete === "list" && p && m && !v(p, m) ? i ? Ce.createPortal(
|
|
488
|
+
/* @__PURE__ */ f(
|
|
489
|
+
et,
|
|
490
|
+
{
|
|
491
|
+
textId: x,
|
|
492
|
+
onTextValueChange: C,
|
|
493
|
+
isSelected: h,
|
|
494
|
+
textValue: p,
|
|
495
|
+
children: /* @__PURE__ */ f(
|
|
496
|
+
ae.ItemSlot,
|
|
497
|
+
{
|
|
498
|
+
scope: void 0,
|
|
499
|
+
value: e,
|
|
500
|
+
textValue: p,
|
|
501
|
+
disabled: t,
|
|
502
|
+
type: "option",
|
|
503
|
+
isVisible: !1,
|
|
504
|
+
children: /* @__PURE__ */ f(tt, { ref: c, value: e, disabled: t, ...n })
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
}
|
|
508
|
+
),
|
|
509
|
+
i
|
|
510
|
+
) : null : /* @__PURE__ */ f(
|
|
511
|
+
et,
|
|
512
|
+
{
|
|
513
|
+
textId: x,
|
|
514
|
+
onTextValueChange: C,
|
|
515
|
+
isSelected: h,
|
|
516
|
+
textValue: p,
|
|
517
|
+
children: /* @__PURE__ */ f(
|
|
518
|
+
ae.ItemSlot,
|
|
519
|
+
{
|
|
520
|
+
scope: void 0,
|
|
521
|
+
value: e,
|
|
522
|
+
textValue: p,
|
|
523
|
+
disabled: t,
|
|
524
|
+
type: "option",
|
|
525
|
+
isVisible: !0,
|
|
526
|
+
children: /* @__PURE__ */ f(tt, { ref: c, value: e, disabled: t, ...n })
|
|
527
|
+
}
|
|
528
|
+
)
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
}), to = "ComboboxItemImpl", tt = l.forwardRef((r, c) => {
|
|
532
|
+
const { value: e, disabled: t = !1, ...o } = r, n = l.useRef(null), i = M(c, n), { getItems: s } = me(void 0), { onTextValueChange: a, visuallyFocussedItem: m, ...u } = K(Oe), { isSelected: x, textValue: p, textId: d } = De(to), h = () => {
|
|
533
|
+
t || (u.onValueChange(e), a(p), u.onOpenChange(!1), u.autocomplete === "both" && u.onFilterValueChange(p), u.trigger?.focus({ preventScroll: !0 }));
|
|
534
|
+
}, v = l.useMemo(() => m === s().find((b) => b.ref.current === n.current)?.ref.current, [s, m]), C = re();
|
|
535
|
+
return /* @__PURE__ */ f(
|
|
536
|
+
N.div,
|
|
492
537
|
{
|
|
493
538
|
role: "option",
|
|
494
|
-
"aria-labelledby":
|
|
495
|
-
"data-highlighted":
|
|
496
|
-
"aria-selected":
|
|
497
|
-
"data-state":
|
|
539
|
+
"aria-labelledby": d,
|
|
540
|
+
"data-highlighted": v ? "" : void 0,
|
|
541
|
+
"aria-selected": x && v,
|
|
542
|
+
"data-state": x ? "checked" : "unchecked",
|
|
498
543
|
"aria-disabled": t || void 0,
|
|
499
544
|
"data-disabled": t ? "" : void 0,
|
|
500
545
|
tabIndex: t ? void 0 : -1,
|
|
501
|
-
...
|
|
502
|
-
id:
|
|
503
|
-
ref:
|
|
504
|
-
onPointerUp: T(
|
|
546
|
+
...o,
|
|
547
|
+
id: C,
|
|
548
|
+
ref: i,
|
|
549
|
+
onPointerUp: T(o.onPointerUp, h)
|
|
505
550
|
}
|
|
506
|
-
)
|
|
507
|
-
}),
|
|
508
|
-
const { className: e, style: t, ...o } = r, n =
|
|
509
|
-
return /* @__PURE__ */ f(
|
|
510
|
-
}),
|
|
511
|
-
const { isSelected: e } =
|
|
512
|
-
return e ? /* @__PURE__ */ f(
|
|
513
|
-
}),
|
|
514
|
-
const { textValue: e = "",
|
|
551
|
+
);
|
|
552
|
+
}), oo = "ComboboxItemText", no = l.forwardRef((r, c) => {
|
|
553
|
+
const { className: e, style: t, ...o } = r, n = De(oo), i = M(c, n.onTextValueChange);
|
|
554
|
+
return /* @__PURE__ */ f(N.span, { id: n.textId, ...o, ref: i });
|
|
555
|
+
}), ro = "ComboboxItemIndicator", lo = l.forwardRef((r, c) => {
|
|
556
|
+
const { isSelected: e } = De(ro);
|
|
557
|
+
return e ? /* @__PURE__ */ f(N.span, { "aria-hidden": !0, ...r, ref: c }) : null;
|
|
558
|
+
}), gt = "ComboboxNoValueFound", so = l.forwardRef((r, c) => {
|
|
559
|
+
const { textValue: e = "", filterValue: t = "", locale: o, autocomplete: n } = K(gt), [i, s] = l.useState([]), { subscribe: a } = me(void 0), { startsWith: m } = Me(o, { sensitivity: "base" });
|
|
515
560
|
return l.useEffect(() => {
|
|
516
|
-
const
|
|
517
|
-
|
|
561
|
+
const u = a((x) => {
|
|
562
|
+
s(x);
|
|
518
563
|
});
|
|
519
564
|
return () => {
|
|
520
|
-
|
|
565
|
+
u();
|
|
521
566
|
};
|
|
522
|
-
}, [
|
|
523
|
-
}),
|
|
524
|
-
const { disabled: e = !1, ...t } = r, o =
|
|
567
|
+
}, [a]), i.length === 0 || n === "none" || n === "list" && i.some((u) => m(u.textValue, e)) || n === "both" && i.some((u) => m(u.textValue, t)) ? null : /* @__PURE__ */ f(N.div, { ...r, ref: c });
|
|
568
|
+
}), co = l.forwardRef((r, c) => {
|
|
569
|
+
const { disabled: e = !1, ...t } = r, o = K(gt), { textValue: n, visuallyFocussedItem: i } = o, { getItems: s, subscribe: a } = me(void 0), m = l.useRef(null), [u, x] = l.useState(!1), p = M(c, m), d = l.useMemo(() => i === s().find((C) => C.ref.current === m.current)?.ref.current, [s, i]), h = re(), v = () => {
|
|
525
570
|
!e && n && (o.onValueChange(n), o.onTextValueChange(n), o.onOpenChange(!1), o.autocomplete === "both" && o.onFilterValueChange(n), o.trigger?.focus({ preventScroll: !0 }));
|
|
526
571
|
};
|
|
527
|
-
return
|
|
528
|
-
const C = a((
|
|
529
|
-
x(!
|
|
572
|
+
return L(() => {
|
|
573
|
+
const C = a((b) => {
|
|
574
|
+
x(!b.some((g) => g.textValue === n && g.type !== "create"));
|
|
530
575
|
});
|
|
531
|
-
return
|
|
576
|
+
return s().length === 0 && x(!0), () => {
|
|
532
577
|
C();
|
|
533
578
|
};
|
|
534
|
-
}, [n, a,
|
|
535
|
-
|
|
579
|
+
}, [n, a, s]), !n || !u ? null : /* @__PURE__ */ f(
|
|
580
|
+
ae.ItemSlot,
|
|
536
581
|
{
|
|
537
582
|
scope: void 0,
|
|
538
583
|
value: n ?? "",
|
|
539
584
|
textValue: n ?? "",
|
|
540
585
|
disabled: e,
|
|
586
|
+
isVisible: !0,
|
|
541
587
|
type: "create",
|
|
542
588
|
children: /* @__PURE__ */ f(
|
|
543
|
-
|
|
589
|
+
N.div,
|
|
544
590
|
{
|
|
545
591
|
role: "option",
|
|
546
592
|
tabIndex: e ? void 0 : -1,
|
|
547
593
|
"aria-disabled": e || void 0,
|
|
548
594
|
"data-disabled": e ? "" : void 0,
|
|
549
|
-
"data-highlighted":
|
|
595
|
+
"data-highlighted": d ? "" : void 0,
|
|
550
596
|
...t,
|
|
551
|
-
id:
|
|
552
|
-
ref:
|
|
553
|
-
onPointerUp: T(t.onPointerUp,
|
|
597
|
+
id: h,
|
|
598
|
+
ref: p,
|
|
599
|
+
onPointerUp: T(t.onPointerUp, v)
|
|
554
600
|
}
|
|
555
601
|
)
|
|
556
602
|
}
|
|
557
603
|
);
|
|
558
|
-
}),
|
|
559
|
-
function
|
|
560
|
-
const e = Math.min(r.length,
|
|
604
|
+
}), io = Kt, ao = zt, uo = Gt, fo = jt, po = pt, mo = qt, ho = eo, go = ht, xo = no, Co = lo, vo = so, bo = co;
|
|
605
|
+
function So(r, c) {
|
|
606
|
+
const e = Math.min(r.length, c.length);
|
|
561
607
|
for (let t = 0; t < e; t++)
|
|
562
|
-
if (r[t] !==
|
|
608
|
+
if (r[t] !== c[t])
|
|
563
609
|
return t;
|
|
564
610
|
return e;
|
|
565
611
|
}
|
|
566
|
-
const
|
|
612
|
+
const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
567
613
|
__proto__: null,
|
|
568
|
-
ComboboxItem:
|
|
569
|
-
Content:
|
|
570
|
-
CreateItem:
|
|
571
|
-
Icon:
|
|
572
|
-
Item:
|
|
573
|
-
ItemIndicator:
|
|
574
|
-
ItemText:
|
|
575
|
-
NoValueFound:
|
|
576
|
-
Portal:
|
|
577
|
-
Root:
|
|
578
|
-
TextInput:
|
|
579
|
-
Trigger:
|
|
580
|
-
Viewport:
|
|
581
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
]),
|
|
614
|
+
ComboboxItem: ht,
|
|
615
|
+
Content: mo,
|
|
616
|
+
CreateItem: bo,
|
|
617
|
+
Icon: fo,
|
|
618
|
+
Item: go,
|
|
619
|
+
ItemIndicator: Co,
|
|
620
|
+
ItemText: xo,
|
|
621
|
+
NoValueFound: vo,
|
|
622
|
+
Portal: po,
|
|
623
|
+
Root: io,
|
|
624
|
+
TextInput: uo,
|
|
625
|
+
Trigger: ao,
|
|
626
|
+
Viewport: ho
|
|
627
|
+
}, Symbol.toStringTag, { value: "Module" })), Io = [" ", "Enter", "ArrowUp", "ArrowDown"], wo = [" ", "Enter"], he = "Select", [ve, ge, yo] = Nt(he), [ue, To] = ot(he, [
|
|
628
|
+
yo,
|
|
629
|
+
ct
|
|
630
|
+
]), be = ct(), [Vo, Y] = ue(he), [Po, Eo] = ue(he), ke = (r) => {
|
|
585
631
|
const {
|
|
586
|
-
__scopeSelect:
|
|
632
|
+
__scopeSelect: c,
|
|
587
633
|
children: e,
|
|
588
634
|
open: t,
|
|
589
635
|
defaultOpen: o,
|
|
590
636
|
onOpenChange: n,
|
|
591
637
|
value: i,
|
|
592
|
-
defaultValue:
|
|
638
|
+
defaultValue: s,
|
|
593
639
|
onValueChange: a,
|
|
594
|
-
dir:
|
|
640
|
+
dir: m,
|
|
595
641
|
// name,
|
|
596
642
|
// autoComplete,
|
|
597
|
-
disabled:
|
|
643
|
+
disabled: u,
|
|
598
644
|
required: x,
|
|
599
|
-
multi:
|
|
600
|
-
} = r,
|
|
645
|
+
multi: p = !1
|
|
646
|
+
} = r, d = be(c), [h, v] = l.useState(null), [C, b] = l.useState(null), [g, I] = l.useState(!1), E = At(m), [O = !1, A] = ie({
|
|
601
647
|
prop: t,
|
|
602
648
|
defaultProp: o,
|
|
603
649
|
onChange: n
|
|
604
|
-
}), [
|
|
650
|
+
}), [_, k] = ie({
|
|
605
651
|
prop: i,
|
|
606
|
-
defaultProp:
|
|
652
|
+
defaultProp: s,
|
|
607
653
|
onChange(D) {
|
|
608
654
|
a && (Array.isArray(D), a(D));
|
|
609
655
|
}
|
|
610
|
-
}), q = l.useRef(null), [
|
|
611
|
-
return /* @__PURE__ */ f(le.Root, { ...
|
|
612
|
-
|
|
656
|
+
}), q = l.useRef(null), [W, B] = l.useState(/* @__PURE__ */ new Set());
|
|
657
|
+
return /* @__PURE__ */ f(le.Root, { ...d, children: /* @__PURE__ */ f(
|
|
658
|
+
Vo,
|
|
613
659
|
{
|
|
614
660
|
required: x,
|
|
615
|
-
scope:
|
|
616
|
-
trigger:
|
|
617
|
-
onTriggerChange:
|
|
661
|
+
scope: c,
|
|
662
|
+
trigger: h,
|
|
663
|
+
onTriggerChange: v,
|
|
618
664
|
valueNode: C,
|
|
619
|
-
onValueNodeChange:
|
|
620
|
-
valueNodeHasChildren:
|
|
621
|
-
onValueNodeHasChildrenChange:
|
|
622
|
-
contentId:
|
|
623
|
-
value:
|
|
665
|
+
onValueNodeChange: b,
|
|
666
|
+
valueNodeHasChildren: g,
|
|
667
|
+
onValueNodeHasChildrenChange: I,
|
|
668
|
+
contentId: re(),
|
|
669
|
+
value: _,
|
|
624
670
|
onValueChange: k,
|
|
625
|
-
open:
|
|
626
|
-
onOpenChange:
|
|
627
|
-
dir:
|
|
671
|
+
open: O,
|
|
672
|
+
onOpenChange: A,
|
|
673
|
+
dir: E,
|
|
628
674
|
triggerPointerDownPosRef: q,
|
|
629
|
-
disabled:
|
|
630
|
-
multi:
|
|
631
|
-
children: /* @__PURE__ */ f(
|
|
632
|
-
|
|
675
|
+
disabled: u,
|
|
676
|
+
multi: p,
|
|
677
|
+
children: /* @__PURE__ */ f(ve.Provider, { scope: c, children: /* @__PURE__ */ f(
|
|
678
|
+
Po,
|
|
633
679
|
{
|
|
634
680
|
scope: r.__scopeSelect,
|
|
635
681
|
onNativeOptionAdd: l.useCallback((D) => {
|
|
636
|
-
|
|
682
|
+
B((H) => new Set(H).add(D));
|
|
637
683
|
}, []),
|
|
638
684
|
onNativeOptionRemove: l.useCallback((D) => {
|
|
639
|
-
|
|
685
|
+
B((H) => {
|
|
640
686
|
const F = new Set(H);
|
|
641
687
|
return F.delete(D), F;
|
|
642
688
|
});
|
|
@@ -647,20 +693,20 @@ const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
647
693
|
}
|
|
648
694
|
) });
|
|
649
695
|
};
|
|
650
|
-
|
|
651
|
-
const
|
|
652
|
-
(r,
|
|
653
|
-
const { __scopeSelect: e, ...t } = r, o =
|
|
654
|
-
const
|
|
696
|
+
ke.displayName = he;
|
|
697
|
+
const xt = "SelectTrigger", Fe = l.forwardRef(
|
|
698
|
+
(r, c) => {
|
|
699
|
+
const { __scopeSelect: e, ...t } = r, o = be(e), n = Y(xt, e), i = n.disabled, s = M(c, n.onTriggerChange), a = ge(e), [m, u, x] = Pt((d) => {
|
|
700
|
+
const h = a().filter((b) => !b.disabled), v = h.find((b) => b.value === n.value), C = Et(h, d, v);
|
|
655
701
|
if (C !== void 0 && !Array.isArray(C.value)) {
|
|
656
|
-
const
|
|
657
|
-
n.onValueChange(
|
|
702
|
+
const b = n.multi ? [C.value] : C.value;
|
|
703
|
+
n.onValueChange(b);
|
|
658
704
|
}
|
|
659
|
-
}),
|
|
705
|
+
}), p = () => {
|
|
660
706
|
i || (n.onOpenChange(!0), x());
|
|
661
707
|
};
|
|
662
708
|
return /* @__PURE__ */ f(le.Anchor, { asChild: !0, ...o, children: /* @__PURE__ */ f(
|
|
663
|
-
|
|
709
|
+
N.div,
|
|
664
710
|
{
|
|
665
711
|
role: "combobox",
|
|
666
712
|
"aria-controls": n.contentId,
|
|
@@ -673,89 +719,89 @@ const ht = "SelectTrigger", De = l.forwardRef(
|
|
|
673
719
|
"data-placeholder": n.value === void 0 ? "" : void 0,
|
|
674
720
|
tabIndex: i ? void 0 : 0,
|
|
675
721
|
...t,
|
|
676
|
-
ref:
|
|
677
|
-
onClick: T(t.onClick, (
|
|
678
|
-
|
|
722
|
+
ref: s,
|
|
723
|
+
onClick: T(t.onClick, (d) => {
|
|
724
|
+
d.currentTarget.focus();
|
|
679
725
|
}),
|
|
680
|
-
onPointerDown: T(t.onPointerDown, (
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
x: Math.round(
|
|
684
|
-
y: Math.round(
|
|
685
|
-
},
|
|
726
|
+
onPointerDown: T(t.onPointerDown, (d) => {
|
|
727
|
+
const h = d.target;
|
|
728
|
+
h.hasPointerCapture(d.pointerId) && h.releasePointerCapture(d.pointerId), (h.closest("button") ?? h.closest("div")) === d.currentTarget && d.button === 0 && d.ctrlKey === !1 && (p(), n.triggerPointerDownPosRef.current = {
|
|
729
|
+
x: Math.round(d.pageX),
|
|
730
|
+
y: Math.round(d.pageY)
|
|
731
|
+
}, d.preventDefault());
|
|
686
732
|
}),
|
|
687
|
-
onKeyDown: T(t.onKeyDown, (
|
|
688
|
-
const
|
|
689
|
-
(C.closest("button") ?? C.closest("div")) ===
|
|
733
|
+
onKeyDown: T(t.onKeyDown, (d) => {
|
|
734
|
+
const h = m.current !== "", v = d.ctrlKey || d.altKey || d.metaKey, C = d.target;
|
|
735
|
+
(C.closest("button") ?? C.closest("div")) === d.currentTarget && (!v && d.key.length === 1 && u(d.key), !(h && d.key === " ") && Io.includes(d.key) && (p(), d.preventDefault()));
|
|
690
736
|
})
|
|
691
737
|
}
|
|
692
738
|
) });
|
|
693
739
|
}
|
|
694
740
|
);
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
(r,
|
|
698
|
-
const { __scopeSelect: e, children: t, placeholder: o, ...n } = r, i = Y(
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
}, [
|
|
702
|
-
if (Array.isArray(i.value) &&
|
|
703
|
-
const
|
|
704
|
-
const
|
|
741
|
+
Fe.displayName = xt;
|
|
742
|
+
const Ct = "SelectValue", Le = l.forwardRef(
|
|
743
|
+
(r, c) => {
|
|
744
|
+
const { __scopeSelect: e, children: t, placeholder: o, ...n } = r, i = Y(Ct, e), { onValueNodeHasChildrenChange: s } = i, a = t !== void 0, m = M(c, i.onValueNodeChange), [u, x] = l.useState([]), p = ge(e);
|
|
745
|
+
L(() => {
|
|
746
|
+
s(a);
|
|
747
|
+
}, [s, a]), l.useLayoutEffect(() => {
|
|
748
|
+
if (Array.isArray(i.value) && u.length !== i.value.length) {
|
|
749
|
+
const h = setTimeout(() => {
|
|
750
|
+
const v = p().filter(
|
|
705
751
|
(C) => Array.isArray(C.value) ? !1 : i.value?.includes(C.value)
|
|
706
752
|
);
|
|
707
|
-
x(
|
|
753
|
+
x(v);
|
|
708
754
|
});
|
|
709
755
|
return () => {
|
|
710
|
-
clearTimeout(
|
|
756
|
+
clearTimeout(h);
|
|
711
757
|
};
|
|
712
758
|
}
|
|
713
|
-
}, [i.value,
|
|
714
|
-
let
|
|
759
|
+
}, [i.value, p, u]);
|
|
760
|
+
let d;
|
|
715
761
|
if ((i.value === void 0 || i.value.length === 0) && o !== void 0)
|
|
716
|
-
|
|
762
|
+
d = /* @__PURE__ */ f("span", { children: o });
|
|
717
763
|
else if (typeof t == "function")
|
|
718
764
|
if (Array.isArray(i.value)) {
|
|
719
|
-
const
|
|
720
|
-
const C =
|
|
721
|
-
return C ? t({ value:
|
|
765
|
+
const h = i.value.map((v) => {
|
|
766
|
+
const C = u.find((b) => b.value === v);
|
|
767
|
+
return C ? t({ value: v, textValue: C?.textValue }) : null;
|
|
722
768
|
});
|
|
723
|
-
|
|
769
|
+
d = h.every((v) => v === null) ? o : h;
|
|
724
770
|
} else
|
|
725
|
-
|
|
771
|
+
d = t(i.value);
|
|
726
772
|
else
|
|
727
|
-
|
|
728
|
-
return /* @__PURE__ */ f(
|
|
773
|
+
d = t;
|
|
774
|
+
return /* @__PURE__ */ f(N.span, { ...n, ref: m, children: d || null });
|
|
729
775
|
}
|
|
730
776
|
);
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
(r,
|
|
777
|
+
Le.displayName = Ct;
|
|
778
|
+
const Ro = "SelectIcon", Be = l.forwardRef(
|
|
779
|
+
(r, c) => {
|
|
734
780
|
const { __scopeSelect: e, children: t, ...o } = r;
|
|
735
|
-
return /* @__PURE__ */ f(
|
|
781
|
+
return /* @__PURE__ */ f(N.span, { "aria-hidden": !0, ...o, ref: c, children: t || "▼" });
|
|
736
782
|
}
|
|
737
783
|
);
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
(r,
|
|
743
|
-
const e = Y(
|
|
744
|
-
if (
|
|
784
|
+
Be.displayName = Ro;
|
|
785
|
+
const No = "SelectPortal", He = (r) => /* @__PURE__ */ f(it, { asChild: !0, ...r });
|
|
786
|
+
He.displayName = No;
|
|
787
|
+
const ne = "SelectContent", $e = l.forwardRef(
|
|
788
|
+
(r, c) => {
|
|
789
|
+
const e = Y(ne, r.__scopeSelect), [t, o] = l.useState();
|
|
790
|
+
if (L(() => {
|
|
745
791
|
o(new DocumentFragment());
|
|
746
792
|
}, []), !e.open) {
|
|
747
793
|
const n = t;
|
|
748
|
-
return n ?
|
|
749
|
-
/* @__PURE__ */ f(
|
|
794
|
+
return n ? Ce.createPortal(
|
|
795
|
+
/* @__PURE__ */ f(vt, { scope: r.__scopeSelect, children: /* @__PURE__ */ f(ve.Slot, { scope: r.__scopeSelect, children: /* @__PURE__ */ f("div", { children: r.children }) }) }),
|
|
750
796
|
n
|
|
751
797
|
) : null;
|
|
752
798
|
}
|
|
753
|
-
return /* @__PURE__ */ f(
|
|
799
|
+
return /* @__PURE__ */ f(bt, { ...r, ref: c });
|
|
754
800
|
}
|
|
755
801
|
);
|
|
756
|
-
|
|
757
|
-
const
|
|
758
|
-
(r,
|
|
802
|
+
$e.displayName = ne;
|
|
803
|
+
const j = 10, [vt, J] = ue(ne), Ao = "SelectContentImpl", bt = l.forwardRef(
|
|
804
|
+
(r, c) => {
|
|
759
805
|
const {
|
|
760
806
|
__scopeSelect: e,
|
|
761
807
|
position: t = "item-aligned",
|
|
@@ -764,153 +810,153 @@ const G = 10, [Ct, J] = ae(re), Ro = "SelectContentImpl", xt = l.forwardRef(
|
|
|
764
810
|
onPointerDownOutside: i,
|
|
765
811
|
//
|
|
766
812
|
// PopperContent props
|
|
767
|
-
side:
|
|
813
|
+
side: s,
|
|
768
814
|
sideOffset: a,
|
|
769
|
-
align:
|
|
770
|
-
alignOffset:
|
|
815
|
+
align: m,
|
|
816
|
+
alignOffset: u,
|
|
771
817
|
arrowPadding: x,
|
|
772
|
-
collisionBoundary:
|
|
773
|
-
collisionPadding:
|
|
774
|
-
sticky:
|
|
775
|
-
hideWhenDetached:
|
|
818
|
+
collisionBoundary: p,
|
|
819
|
+
collisionPadding: d,
|
|
820
|
+
sticky: h,
|
|
821
|
+
hideWhenDetached: v,
|
|
776
822
|
avoidCollisions: C,
|
|
777
823
|
//
|
|
778
|
-
...
|
|
779
|
-
} = r,
|
|
824
|
+
...b
|
|
825
|
+
} = r, g = Y(ne, e), [I, E] = l.useState(null), [O, A] = l.useState(null), _ = M(c, (S) => E(S)), [k, q] = l.useState(null), [W, B] = l.useState(null), D = ge(e), [H, F] = l.useState(!1), z = l.useRef(!1);
|
|
780
826
|
l.useEffect(() => {
|
|
781
|
-
if (
|
|
782
|
-
return
|
|
783
|
-
}, [
|
|
784
|
-
const
|
|
827
|
+
if (I)
|
|
828
|
+
return at(I);
|
|
829
|
+
}, [I]), lt();
|
|
830
|
+
const G = l.useCallback(
|
|
785
831
|
(S) => {
|
|
786
|
-
const [V, ...y] = D().map((
|
|
787
|
-
for (const
|
|
788
|
-
if (
|
|
832
|
+
const [V, ...y] = D().map((R) => R.ref.current), [w] = y.slice(-1), P = document.activeElement;
|
|
833
|
+
for (const R of S)
|
|
834
|
+
if (R === P || (R?.scrollIntoView({ block: "nearest" }), R === V && O && (O.scrollTop = 0), R === w && O && (O.scrollTop = O.scrollHeight), R?.focus(), document.activeElement !== P))
|
|
789
835
|
return;
|
|
790
836
|
},
|
|
791
|
-
[D,
|
|
837
|
+
[D, O]
|
|
792
838
|
), $ = l.useCallback(
|
|
793
|
-
() =>
|
|
794
|
-
[
|
|
839
|
+
() => G([k, I]),
|
|
840
|
+
[G, k, I]
|
|
795
841
|
);
|
|
796
842
|
l.useEffect(() => {
|
|
797
843
|
H && $();
|
|
798
844
|
}, [H, $]);
|
|
799
|
-
const { onOpenChange: X, triggerPointerDownPosRef: U } =
|
|
845
|
+
const { onOpenChange: X, triggerPointerDownPosRef: U } = g;
|
|
800
846
|
l.useEffect(() => {
|
|
801
|
-
if (
|
|
847
|
+
if (I) {
|
|
802
848
|
let S = { x: 0, y: 0 };
|
|
803
|
-
const V = (
|
|
849
|
+
const V = (w) => {
|
|
804
850
|
S = {
|
|
805
|
-
x: Math.abs(Math.round(
|
|
806
|
-
y: Math.abs(Math.round(
|
|
851
|
+
x: Math.abs(Math.round(w.pageX) - (U.current?.x ?? 0)),
|
|
852
|
+
y: Math.abs(Math.round(w.pageY) - (U.current?.y ?? 0))
|
|
807
853
|
};
|
|
808
|
-
}, y = (
|
|
809
|
-
S.x <= 10 && S.y <= 10 ?
|
|
854
|
+
}, y = (w) => {
|
|
855
|
+
S.x <= 10 && S.y <= 10 ? w.preventDefault() : I.contains(w.target) || X(!1), document.removeEventListener("pointermove", V), U.current = null;
|
|
810
856
|
};
|
|
811
857
|
return U.current !== null && (document.addEventListener("pointermove", V), document.addEventListener("pointerup", y, { capture: !0, once: !0 })), () => {
|
|
812
858
|
document.removeEventListener("pointermove", V), document.removeEventListener("pointerup", y, { capture: !0 });
|
|
813
859
|
};
|
|
814
860
|
}
|
|
815
|
-
}, [
|
|
861
|
+
}, [I, X, U]), l.useEffect(() => {
|
|
816
862
|
const S = () => X(!1);
|
|
817
863
|
return window.addEventListener("blur", S), window.addEventListener("resize", S), () => {
|
|
818
864
|
window.removeEventListener("blur", S), window.removeEventListener("resize", S);
|
|
819
865
|
};
|
|
820
866
|
}, [X]);
|
|
821
|
-
const [
|
|
822
|
-
const V = D().filter((P) => !P.disabled), y = V.find((P) => P.ref.current === document.activeElement),
|
|
823
|
-
|
|
824
|
-
}),
|
|
867
|
+
const [de, se] = Pt((S) => {
|
|
868
|
+
const V = D().filter((P) => !P.disabled), y = V.find((P) => P.ref.current === document.activeElement), w = Et(V, S, y);
|
|
869
|
+
w && setTimeout(() => w.ref.current.focus());
|
|
870
|
+
}), fe = l.useCallback(
|
|
825
871
|
(S, V, y) => {
|
|
826
|
-
const
|
|
827
|
-
(
|
|
872
|
+
const w = !z.current && !y;
|
|
873
|
+
(g.value !== void 0 && g.value === V || w) && (q(S), w && (z.current = !0));
|
|
828
874
|
},
|
|
829
|
-
[
|
|
830
|
-
), Q = l.useCallback(() =>
|
|
875
|
+
[g.value]
|
|
876
|
+
), Q = l.useCallback(() => I?.focus(), [I]), Z = l.useCallback(
|
|
831
877
|
(S, V, y) => {
|
|
832
|
-
const
|
|
833
|
-
(
|
|
878
|
+
const w = !z.current && !y;
|
|
879
|
+
(g.value !== void 0 && (Array.isArray(V) ? V.every((R) => g.value?.includes(R)) : g.value === V) || w) && B(S);
|
|
834
880
|
},
|
|
835
|
-
[
|
|
836
|
-
), ce = t === "popper" ?
|
|
837
|
-
side:
|
|
881
|
+
[g.value]
|
|
882
|
+
), ce = t === "popper" ? Ve : St, ee = ce === Ve ? {
|
|
883
|
+
side: s,
|
|
838
884
|
sideOffset: a,
|
|
839
|
-
align:
|
|
840
|
-
alignOffset:
|
|
885
|
+
align: m,
|
|
886
|
+
alignOffset: u,
|
|
841
887
|
arrowPadding: x,
|
|
842
|
-
collisionBoundary:
|
|
843
|
-
collisionPadding:
|
|
844
|
-
sticky:
|
|
845
|
-
hideWhenDetached:
|
|
888
|
+
collisionBoundary: p,
|
|
889
|
+
collisionPadding: d,
|
|
890
|
+
sticky: h,
|
|
891
|
+
hideWhenDetached: v,
|
|
846
892
|
avoidCollisions: C
|
|
847
893
|
} : {};
|
|
848
894
|
return /* @__PURE__ */ f(
|
|
849
|
-
|
|
895
|
+
vt,
|
|
850
896
|
{
|
|
851
897
|
scope: e,
|
|
852
|
-
content:
|
|
853
|
-
viewport:
|
|
854
|
-
onViewportChange:
|
|
855
|
-
itemRefCallback:
|
|
898
|
+
content: I,
|
|
899
|
+
viewport: O,
|
|
900
|
+
onViewportChange: A,
|
|
901
|
+
itemRefCallback: fe,
|
|
856
902
|
selectedItem: k,
|
|
857
903
|
onItemLeave: Q,
|
|
858
904
|
itemTextRefCallback: Z,
|
|
859
905
|
focusSelectedItem: $,
|
|
860
|
-
selectedItemText:
|
|
906
|
+
selectedItemText: W,
|
|
861
907
|
position: t,
|
|
862
908
|
isPositioned: H,
|
|
863
|
-
searchRef:
|
|
864
|
-
children: /* @__PURE__ */ f(
|
|
865
|
-
|
|
909
|
+
searchRef: de,
|
|
910
|
+
children: /* @__PURE__ */ f(ut, { as: Te, allowPinchZoom: !0, children: /* @__PURE__ */ f(
|
|
911
|
+
st,
|
|
866
912
|
{
|
|
867
913
|
asChild: !0,
|
|
868
|
-
trapped:
|
|
914
|
+
trapped: g.open,
|
|
869
915
|
onMountAutoFocus: (S) => {
|
|
870
916
|
S.preventDefault();
|
|
871
917
|
},
|
|
872
918
|
onUnmountAutoFocus: T(o, (S) => {
|
|
873
|
-
|
|
919
|
+
g.trigger?.focus({ preventScroll: !0 }), document.getSelection()?.empty(), S.preventDefault();
|
|
874
920
|
}),
|
|
875
921
|
children: /* @__PURE__ */ f(
|
|
876
|
-
|
|
922
|
+
rt,
|
|
877
923
|
{
|
|
878
924
|
asChild: !0,
|
|
879
925
|
disableOutsidePointerEvents: !0,
|
|
880
926
|
onEscapeKeyDown: n,
|
|
881
927
|
onPointerDownOutside: i,
|
|
882
928
|
onFocusOutside: (S) => S.preventDefault(),
|
|
883
|
-
onDismiss: () =>
|
|
929
|
+
onDismiss: () => g.onOpenChange(!1),
|
|
884
930
|
children: /* @__PURE__ */ f(
|
|
885
931
|
ce,
|
|
886
932
|
{
|
|
887
933
|
role: "listbox",
|
|
888
|
-
id:
|
|
889
|
-
"data-state":
|
|
890
|
-
"aria-multiselectable":
|
|
891
|
-
dir:
|
|
934
|
+
id: g.contentId,
|
|
935
|
+
"data-state": g.open ? "open" : "closed",
|
|
936
|
+
"aria-multiselectable": g.multi ? "true" : void 0,
|
|
937
|
+
dir: g.dir,
|
|
892
938
|
onContextMenu: (S) => S.preventDefault(),
|
|
893
|
-
...
|
|
939
|
+
...b,
|
|
894
940
|
...ee,
|
|
895
941
|
onPlaced: () => F(!0),
|
|
896
|
-
ref:
|
|
942
|
+
ref: _,
|
|
897
943
|
style: {
|
|
898
944
|
// flex layout so we can place the scroll buttons properly
|
|
899
945
|
display: "flex",
|
|
900
946
|
flexDirection: "column",
|
|
901
947
|
// reset the outline by default as the content MAY get focused
|
|
902
948
|
outline: "none",
|
|
903
|
-
...
|
|
949
|
+
...b.style
|
|
904
950
|
},
|
|
905
|
-
onKeyDown: T(
|
|
951
|
+
onKeyDown: T(b.onKeyDown, (S) => {
|
|
906
952
|
const V = S.ctrlKey || S.altKey || S.metaKey;
|
|
907
953
|
if (S.key === "Tab" && S.preventDefault(), !V && S.key.length === 1 && se(S.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(S.key)) {
|
|
908
|
-
let
|
|
909
|
-
if (["ArrowUp", "End"].includes(S.key) && (
|
|
910
|
-
const P = S.target,
|
|
911
|
-
|
|
954
|
+
let w = D().filter((P) => !P.disabled).map((P) => P.ref.current);
|
|
955
|
+
if (["ArrowUp", "End"].includes(S.key) && (w = w.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(S.key)) {
|
|
956
|
+
const P = S.target, R = w.indexOf(P);
|
|
957
|
+
w = w.slice(R + 1);
|
|
912
958
|
}
|
|
913
|
-
setTimeout(() =>
|
|
959
|
+
setTimeout(() => G(w)), S.preventDefault();
|
|
914
960
|
}
|
|
915
961
|
})
|
|
916
962
|
}
|
|
@@ -923,71 +969,71 @@ const G = 10, [Ct, J] = ae(re), Ro = "SelectContentImpl", xt = l.forwardRef(
|
|
|
923
969
|
);
|
|
924
970
|
}
|
|
925
971
|
);
|
|
926
|
-
|
|
927
|
-
const
|
|
928
|
-
(r,
|
|
929
|
-
const { __scopeSelect: e, onPlaced: t, ...o } = r, n = Y(
|
|
930
|
-
if (n.trigger && n.valueNode &&
|
|
931
|
-
const
|
|
972
|
+
bt.displayName = Ao;
|
|
973
|
+
const _o = "SelectItemAlignedPosition", St = l.forwardRef(
|
|
974
|
+
(r, c) => {
|
|
975
|
+
const { __scopeSelect: e, onPlaced: t, ...o } = r, n = Y(ne, e), i = J(ne, e), [s, a] = l.useState(null), [m, u] = l.useState(null), x = M(c, (_) => u(_)), p = ge(e), d = l.useRef(!1), h = l.useRef(!0), { viewport: v, selectedItem: C, selectedItemText: b, focusSelectedItem: g } = i, I = l.useCallback(() => {
|
|
976
|
+
if (n.trigger && n.valueNode && s && m && v && C && b) {
|
|
977
|
+
const _ = n.trigger.getBoundingClientRect(), k = m.getBoundingClientRect(), q = n.valueNode.getBoundingClientRect(), W = b.getBoundingClientRect();
|
|
932
978
|
if (n.dir !== "rtl") {
|
|
933
|
-
const P =
|
|
934
|
-
|
|
979
|
+
const P = W.left - k.left, R = q.left - P, te = _.left - R, oe = _.width + te, Se = Math.max(oe, k.width), Ie = window.innerWidth - j, we = Qe(R, [j, Ie - Se]);
|
|
980
|
+
s.style.minWidth = `${oe}px`, s.style.left = `${we}px`;
|
|
935
981
|
} else {
|
|
936
|
-
const P = k.right -
|
|
937
|
-
|
|
982
|
+
const P = k.right - W.right, R = window.innerWidth - q.right - P, te = window.innerWidth - _.right - R, oe = _.width + te, Se = Math.max(oe, k.width), Ie = window.innerWidth - j, we = Qe(R, [j, Ie - Se]);
|
|
983
|
+
s.style.minWidth = `${oe}px`, s.style.right = `${we}px`;
|
|
938
984
|
}
|
|
939
|
-
const
|
|
985
|
+
const B = p(), D = window.innerHeight - j * 2, H = v.scrollHeight, F = window.getComputedStyle(m), z = parseInt(F.borderTopWidth, 10), G = parseInt(F.paddingTop, 10), $ = parseInt(F.borderBottomWidth, 10), X = parseInt(F.paddingBottom, 10), U = z + G + H + X + $, de = Math.min(C.offsetHeight * 5, U), se = window.getComputedStyle(v), fe = parseInt(se.paddingTop, 10), Q = parseInt(se.paddingBottom, 10), Z = _.top + _.height / 2 - j, ce = D - Z, ee = C.offsetHeight / 2, S = C.offsetTop + ee, V = z + G + S, y = U - V;
|
|
940
986
|
if (V <= Z) {
|
|
941
|
-
const P = C ===
|
|
942
|
-
|
|
943
|
-
const
|
|
987
|
+
const P = C === B[B.length - 1].ref.current;
|
|
988
|
+
s.style.bottom = "0px";
|
|
989
|
+
const R = m.clientHeight - v.offsetTop - v.offsetHeight, te = Math.max(
|
|
944
990
|
ce,
|
|
945
991
|
ee + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
946
|
-
(P ? Q : 0) +
|
|
992
|
+
(P ? Q : 0) + R + $
|
|
947
993
|
), oe = V + te;
|
|
948
|
-
|
|
994
|
+
s.style.height = `${oe}px`;
|
|
949
995
|
} else {
|
|
950
|
-
const P = C ===
|
|
951
|
-
|
|
996
|
+
const P = C === B[0].ref.current;
|
|
997
|
+
s.style.top = "0px";
|
|
952
998
|
const te = Math.max(
|
|
953
999
|
Z,
|
|
954
|
-
|
|
955
|
-
(P ?
|
|
1000
|
+
z + v.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
1001
|
+
(P ? fe : 0) + ee
|
|
956
1002
|
) + y;
|
|
957
|
-
|
|
1003
|
+
s.style.height = `${te}px`, v.scrollTop = V - Z + v.offsetTop;
|
|
958
1004
|
}
|
|
959
|
-
|
|
1005
|
+
s.style.margin = `${j}px 0`, s.style.minHeight = `${de}px`, s.style.maxHeight = `${D}px`, t?.(), requestAnimationFrame(() => d.current = !0);
|
|
960
1006
|
}
|
|
961
1007
|
}, [
|
|
962
|
-
|
|
1008
|
+
p,
|
|
963
1009
|
n.trigger,
|
|
964
1010
|
n.valueNode,
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
b,
|
|
968
|
-
C,
|
|
1011
|
+
s,
|
|
1012
|
+
m,
|
|
969
1013
|
v,
|
|
1014
|
+
C,
|
|
1015
|
+
b,
|
|
970
1016
|
n.dir,
|
|
971
1017
|
t
|
|
972
1018
|
]);
|
|
973
|
-
|
|
974
|
-
const [
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
}, [
|
|
978
|
-
const
|
|
979
|
-
(
|
|
980
|
-
|
|
1019
|
+
L(() => I(), [I]);
|
|
1020
|
+
const [E, O] = l.useState();
|
|
1021
|
+
L(() => {
|
|
1022
|
+
m && O(window.getComputedStyle(m).zIndex);
|
|
1023
|
+
}, [m]);
|
|
1024
|
+
const A = l.useCallback(
|
|
1025
|
+
(_) => {
|
|
1026
|
+
_ && h.current === !0 && (I(), g?.(), h.current = !1);
|
|
981
1027
|
},
|
|
982
|
-
[
|
|
1028
|
+
[I, g]
|
|
983
1029
|
);
|
|
984
1030
|
return /* @__PURE__ */ f(
|
|
985
|
-
|
|
1031
|
+
Oo,
|
|
986
1032
|
{
|
|
987
1033
|
scope: e,
|
|
988
|
-
contentWrapper:
|
|
989
|
-
shouldExpandOnScrollRef:
|
|
990
|
-
onScrollButtonChange:
|
|
1034
|
+
contentWrapper: s,
|
|
1035
|
+
shouldExpandOnScrollRef: d,
|
|
1036
|
+
onScrollButtonChange: A,
|
|
991
1037
|
children: /* @__PURE__ */ f(
|
|
992
1038
|
"div",
|
|
993
1039
|
{
|
|
@@ -996,10 +1042,10 @@ const No = "SelectItemAlignedPosition", vt = l.forwardRef(
|
|
|
996
1042
|
display: "flex",
|
|
997
1043
|
flexDirection: "column",
|
|
998
1044
|
position: "fixed",
|
|
999
|
-
zIndex:
|
|
1045
|
+
zIndex: E
|
|
1000
1046
|
},
|
|
1001
1047
|
children: /* @__PURE__ */ f(
|
|
1002
|
-
|
|
1048
|
+
N.div,
|
|
1003
1049
|
{
|
|
1004
1050
|
...o,
|
|
1005
1051
|
ref: x,
|
|
@@ -1019,16 +1065,16 @@ const No = "SelectItemAlignedPosition", vt = l.forwardRef(
|
|
|
1019
1065
|
);
|
|
1020
1066
|
}
|
|
1021
1067
|
);
|
|
1022
|
-
|
|
1023
|
-
const
|
|
1024
|
-
(r,
|
|
1025
|
-
const { __scopeSelect: e, align: t = "start", collisionPadding: o =
|
|
1068
|
+
St.displayName = _o;
|
|
1069
|
+
const Mo = "SelectPopperPosition", Ve = l.forwardRef(
|
|
1070
|
+
(r, c) => {
|
|
1071
|
+
const { __scopeSelect: e, align: t = "start", collisionPadding: o = j, ...n } = r, i = be(e);
|
|
1026
1072
|
return /* @__PURE__ */ f(
|
|
1027
1073
|
le.Content,
|
|
1028
1074
|
{
|
|
1029
1075
|
...i,
|
|
1030
1076
|
...n,
|
|
1031
|
-
ref:
|
|
1077
|
+
ref: c,
|
|
1032
1078
|
align: t,
|
|
1033
1079
|
collisionPadding: o,
|
|
1034
1080
|
style: {
|
|
@@ -1045,14 +1091,14 @@ const Ao = "SelectPopperPosition", Te = l.forwardRef(
|
|
|
1045
1091
|
);
|
|
1046
1092
|
}
|
|
1047
1093
|
);
|
|
1048
|
-
|
|
1049
|
-
const [
|
|
1050
|
-
|
|
1094
|
+
Ve.displayName = Mo;
|
|
1095
|
+
const [Oo, Ue] = ue(
|
|
1096
|
+
ne,
|
|
1051
1097
|
{}
|
|
1052
|
-
),
|
|
1053
|
-
(r,
|
|
1054
|
-
const { __scopeSelect: e, ...t } = r, o = J(
|
|
1055
|
-
return /* @__PURE__ */
|
|
1098
|
+
), Pe = "SelectViewport", Ke = l.forwardRef(
|
|
1099
|
+
(r, c) => {
|
|
1100
|
+
const { __scopeSelect: e, ...t } = r, o = J(Pe, e), n = Ue(Pe, e), i = M(c, o.onViewportChange), s = l.useRef(0);
|
|
1101
|
+
return /* @__PURE__ */ Ae(_e, { children: [
|
|
1056
1102
|
/* @__PURE__ */ f(
|
|
1057
1103
|
"style",
|
|
1058
1104
|
{
|
|
@@ -1061,8 +1107,8 @@ const [_o, He] = ae(
|
|
|
1061
1107
|
}
|
|
1062
1108
|
}
|
|
1063
1109
|
),
|
|
1064
|
-
/* @__PURE__ */ f(
|
|
1065
|
-
|
|
1110
|
+
/* @__PURE__ */ f(ve.Slot, { scope: e, children: /* @__PURE__ */ f(
|
|
1111
|
+
N.div,
|
|
1066
1112
|
{
|
|
1067
1113
|
"data-radix-select-viewport": "",
|
|
1068
1114
|
role: "presentation",
|
|
@@ -1078,89 +1124,89 @@ const [_o, He] = ae(
|
|
|
1078
1124
|
...t.style
|
|
1079
1125
|
},
|
|
1080
1126
|
onScroll: T(t.onScroll, (a) => {
|
|
1081
|
-
const
|
|
1082
|
-
if (x?.current &&
|
|
1083
|
-
const
|
|
1084
|
-
if (
|
|
1085
|
-
const
|
|
1086
|
-
if (C <
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1127
|
+
const m = a.currentTarget, { contentWrapper: u, shouldExpandOnScrollRef: x } = n;
|
|
1128
|
+
if (x?.current && u) {
|
|
1129
|
+
const p = Math.abs(s.current - m.scrollTop);
|
|
1130
|
+
if (p > 0) {
|
|
1131
|
+
const d = window.innerHeight - j * 2, h = parseFloat(u.style.minHeight), v = parseFloat(u.style.height), C = Math.max(h, v);
|
|
1132
|
+
if (C < d) {
|
|
1133
|
+
const b = C + p, g = Math.min(d, b), I = b - g;
|
|
1134
|
+
u.style.height = `${g}px`, u.style.bottom === "0px" && (m.scrollTop = I > 0 ? I : 0, u.style.justifyContent = "flex-end");
|
|
1089
1135
|
}
|
|
1090
1136
|
}
|
|
1091
1137
|
}
|
|
1092
|
-
|
|
1138
|
+
s.current = m.scrollTop;
|
|
1093
1139
|
})
|
|
1094
1140
|
}
|
|
1095
1141
|
) })
|
|
1096
1142
|
] });
|
|
1097
1143
|
}
|
|
1098
1144
|
);
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
(r,
|
|
1102
|
-
const { __scopeSelect: e, ...t } = r, o =
|
|
1103
|
-
return /* @__PURE__ */ f(
|
|
1145
|
+
Ke.displayName = Pe;
|
|
1146
|
+
const It = "SelectGroup", [Do, ko] = ue(It), We = l.forwardRef(
|
|
1147
|
+
(r, c) => {
|
|
1148
|
+
const { __scopeSelect: e, ...t } = r, o = re();
|
|
1149
|
+
return /* @__PURE__ */ f(Do, { scope: e, id: o, children: /* @__PURE__ */ f(N.div, { role: "group", "aria-labelledby": o, ...t, ref: c }) });
|
|
1104
1150
|
}
|
|
1105
1151
|
);
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
(r,
|
|
1109
|
-
const { __scopeSelect: e, ...t } = r, o =
|
|
1110
|
-
return /* @__PURE__ */ f(
|
|
1152
|
+
We.displayName = It;
|
|
1153
|
+
const wt = "SelectLabel", ze = l.forwardRef(
|
|
1154
|
+
(r, c) => {
|
|
1155
|
+
const { __scopeSelect: e, ...t } = r, o = ko(wt, e);
|
|
1156
|
+
return /* @__PURE__ */ f(N.div, { id: o.id, ...t, ref: c });
|
|
1111
1157
|
}
|
|
1112
1158
|
);
|
|
1113
|
-
|
|
1114
|
-
const
|
|
1115
|
-
(r,
|
|
1116
|
-
const { __scopeSelect: e, value: t, disabled: o = !1, textValue: n, ...i } = r,
|
|
1117
|
-
|
|
1118
|
-
(
|
|
1119
|
-
), C =
|
|
1159
|
+
ze.displayName = wt;
|
|
1160
|
+
const xe = "SelectItem", [Fo, yt] = ue(xe), Ge = l.forwardRef(
|
|
1161
|
+
(r, c) => {
|
|
1162
|
+
const { __scopeSelect: e, value: t, disabled: o = !1, textValue: n, ...i } = r, s = Y(xe, e), a = J(xe, e), m = typeof t == "string" ? Array.isArray(s.value) ? s.value.includes(t) : s.value === t : t.every((g) => s.value?.includes(g)), u = Array.isArray(s.value) && Array.isArray(t) && t.some((g) => s.value?.includes(g)), [x, p] = l.useState(n ?? ""), [d, h] = l.useState(!1), v = M(
|
|
1163
|
+
c,
|
|
1164
|
+
(g) => a.itemRefCallback?.(g, t, o)
|
|
1165
|
+
), C = re(), b = () => {
|
|
1120
1166
|
if (!o) {
|
|
1121
|
-
let
|
|
1122
|
-
|
|
1167
|
+
let g = s.multi && typeof t == "string" ? [t] : t;
|
|
1168
|
+
u && !m ? s.onValueChange(g) : Array.isArray(s.value) && (g = Rt(t, s.value)), s.onValueChange(g), s.multi || s.onOpenChange(!1);
|
|
1123
1169
|
}
|
|
1124
1170
|
};
|
|
1125
|
-
if (!
|
|
1171
|
+
if (!s.multi && Array.isArray(t))
|
|
1126
1172
|
throw new Error("You can only pass an array of values in multi selects");
|
|
1127
1173
|
return /* @__PURE__ */ f(
|
|
1128
|
-
|
|
1174
|
+
Fo,
|
|
1129
1175
|
{
|
|
1130
1176
|
scope: e,
|
|
1131
1177
|
value: t,
|
|
1132
1178
|
disabled: o,
|
|
1133
1179
|
textId: C,
|
|
1134
|
-
isSelected:
|
|
1135
|
-
isIntermediate:
|
|
1136
|
-
onItemTextChange: l.useCallback((
|
|
1137
|
-
|
|
1180
|
+
isSelected: m,
|
|
1181
|
+
isIntermediate: u,
|
|
1182
|
+
onItemTextChange: l.useCallback((g) => {
|
|
1183
|
+
p((I) => I || (g?.textContent ?? "").trim());
|
|
1138
1184
|
}, []),
|
|
1139
|
-
children: /* @__PURE__ */ f(
|
|
1140
|
-
|
|
1185
|
+
children: /* @__PURE__ */ f(ve.ItemSlot, { scope: e, value: t, disabled: o, textValue: x, children: /* @__PURE__ */ f(
|
|
1186
|
+
N.div,
|
|
1141
1187
|
{
|
|
1142
1188
|
role: "option",
|
|
1143
1189
|
"aria-labelledby": C,
|
|
1144
|
-
"data-highlighted":
|
|
1145
|
-
"aria-selected":
|
|
1146
|
-
"aria-checked":
|
|
1147
|
-
"data-state":
|
|
1190
|
+
"data-highlighted": d ? "" : void 0,
|
|
1191
|
+
"aria-selected": s.multi ? void 0 : m && d,
|
|
1192
|
+
"aria-checked": s.multi ? m : void 0,
|
|
1193
|
+
"data-state": m ? "checked" : "unchecked",
|
|
1148
1194
|
"aria-disabled": o || void 0,
|
|
1149
1195
|
"data-disabled": o ? "" : void 0,
|
|
1150
1196
|
tabIndex: o ? void 0 : -1,
|
|
1151
1197
|
...i,
|
|
1152
|
-
ref:
|
|
1153
|
-
onFocus: T(i.onFocus, () =>
|
|
1154
|
-
onBlur: T(i.onBlur, () =>
|
|
1155
|
-
onPointerUp: T(i.onPointerUp,
|
|
1156
|
-
onPointerMove: T(i.onPointerMove, (
|
|
1157
|
-
o ? a.onItemLeave?.() :
|
|
1198
|
+
ref: v,
|
|
1199
|
+
onFocus: T(i.onFocus, () => h(!0)),
|
|
1200
|
+
onBlur: T(i.onBlur, () => h(!1)),
|
|
1201
|
+
onPointerUp: T(i.onPointerUp, b),
|
|
1202
|
+
onPointerMove: T(i.onPointerMove, (g) => {
|
|
1203
|
+
o ? a.onItemLeave?.() : g.currentTarget.focus({ preventScroll: !0 });
|
|
1158
1204
|
}),
|
|
1159
|
-
onPointerLeave: T(i.onPointerLeave, (
|
|
1160
|
-
|
|
1205
|
+
onPointerLeave: T(i.onPointerLeave, (g) => {
|
|
1206
|
+
g.currentTarget === document.activeElement && a.onItemLeave?.();
|
|
1161
1207
|
}),
|
|
1162
|
-
onKeyDown: T(i.onKeyDown, (
|
|
1163
|
-
a.searchRef?.current !== "" &&
|
|
1208
|
+
onKeyDown: T(i.onKeyDown, (g) => {
|
|
1209
|
+
a.searchRef?.current !== "" && g.key === " " || (wo.includes(g.key) && b(), g.key === " " && g.preventDefault());
|
|
1164
1210
|
})
|
|
1165
1211
|
}
|
|
1166
1212
|
) })
|
|
@@ -1168,106 +1214,106 @@ const ge = "SelectItem", [Do, wt] = ae(ge), We = l.forwardRef(
|
|
|
1168
1214
|
);
|
|
1169
1215
|
}
|
|
1170
1216
|
);
|
|
1171
|
-
|
|
1172
|
-
const
|
|
1173
|
-
(r,
|
|
1174
|
-
const { __scopeSelect: e, className: t, style: o, ...n } = r, i = Y(
|
|
1175
|
-
|
|
1176
|
-
(
|
|
1217
|
+
Ge.displayName = xe;
|
|
1218
|
+
const pe = "SelectItemText", je = l.forwardRef(
|
|
1219
|
+
(r, c) => {
|
|
1220
|
+
const { __scopeSelect: e, className: t, style: o, ...n } = r, i = Y(pe, e), s = J(pe, e), a = yt(pe, e), m = Eo(pe, e), [u, x] = l.useState(null), p = M(
|
|
1221
|
+
c,
|
|
1222
|
+
(b) => x(b),
|
|
1177
1223
|
a.onItemTextChange,
|
|
1178
|
-
(
|
|
1179
|
-
),
|
|
1224
|
+
(b) => s.itemTextRefCallback?.(b, a.value, a.disabled)
|
|
1225
|
+
), d = u?.textContent, h = l.useMemo(
|
|
1180
1226
|
() => /* @__PURE__ */ f(
|
|
1181
1227
|
"option",
|
|
1182
1228
|
{
|
|
1183
1229
|
value: a.value,
|
|
1184
1230
|
disabled: a.disabled,
|
|
1185
|
-
children:
|
|
1231
|
+
children: d
|
|
1186
1232
|
},
|
|
1187
1233
|
Array.isArray(a.value) ? a.value.join(";") : a.value
|
|
1188
1234
|
),
|
|
1189
|
-
[a.disabled, a.value,
|
|
1190
|
-
), { onNativeOptionAdd:
|
|
1191
|
-
return
|
|
1192
|
-
/* @__PURE__ */ f(
|
|
1193
|
-
a.isSelected && i.valueNode && !i.valueNodeHasChildren ?
|
|
1235
|
+
[a.disabled, a.value, d]
|
|
1236
|
+
), { onNativeOptionAdd: v, onNativeOptionRemove: C } = m;
|
|
1237
|
+
return L(() => (v(h), () => C(h)), [v, C, h]), /* @__PURE__ */ Ae(_e, { children: [
|
|
1238
|
+
/* @__PURE__ */ f(N.span, { id: a.textId, ...n, ref: p }),
|
|
1239
|
+
a.isSelected && i.valueNode && !i.valueNodeHasChildren ? Ce.createPortal(n.children, i.valueNode) : null
|
|
1194
1240
|
] });
|
|
1195
1241
|
}
|
|
1196
1242
|
);
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
(r,
|
|
1200
|
-
const { __scopeSelect: e, children: t, ...o } = r, n =
|
|
1201
|
-
return typeof t == "function" ? /* @__PURE__ */ f(
|
|
1243
|
+
je.displayName = pe;
|
|
1244
|
+
const Tt = "SelectItemIndicator", Ye = l.forwardRef(
|
|
1245
|
+
(r, c) => {
|
|
1246
|
+
const { __scopeSelect: e, children: t, ...o } = r, n = yt(Tt, e);
|
|
1247
|
+
return typeof t == "function" ? /* @__PURE__ */ f(N.span, { "aria-hidden": !0, ...o, ref: c, children: t({
|
|
1202
1248
|
isSelected: n.isSelected,
|
|
1203
1249
|
isIntermediate: n.isIntermediate
|
|
1204
|
-
}) }) : n.isSelected ? /* @__PURE__ */ f(
|
|
1250
|
+
}) }) : n.isSelected ? /* @__PURE__ */ f(N.span, { "aria-hidden": !0, ...o, ref: c, children: t }) : null;
|
|
1205
1251
|
}
|
|
1206
1252
|
);
|
|
1207
|
-
|
|
1208
|
-
const
|
|
1209
|
-
(r,
|
|
1210
|
-
const e = J(
|
|
1211
|
-
return
|
|
1253
|
+
Ye.displayName = Tt;
|
|
1254
|
+
const Ee = "SelectScrollUpButton", qe = l.forwardRef(
|
|
1255
|
+
(r, c) => {
|
|
1256
|
+
const e = J(Ee, r.__scopeSelect), t = Ue(Ee, r.__scopeSelect), [o, n] = l.useState(!1), i = M(c, t.onScrollButtonChange);
|
|
1257
|
+
return L(() => {
|
|
1212
1258
|
if (e.viewport && e.isPositioned) {
|
|
1213
|
-
const
|
|
1214
|
-
const
|
|
1215
|
-
n(
|
|
1259
|
+
const s = e.viewport, a = () => {
|
|
1260
|
+
const m = s.scrollTop > 0;
|
|
1261
|
+
n(m);
|
|
1216
1262
|
};
|
|
1217
|
-
return a(),
|
|
1263
|
+
return a(), s.addEventListener("scroll", a), () => s.removeEventListener("scroll", a);
|
|
1218
1264
|
}
|
|
1219
1265
|
}, [e.viewport, e.isPositioned]), o ? /* @__PURE__ */ f(
|
|
1220
|
-
|
|
1266
|
+
Vt,
|
|
1221
1267
|
{
|
|
1222
1268
|
...r,
|
|
1223
1269
|
ref: i,
|
|
1224
1270
|
onAutoScroll: () => {
|
|
1225
|
-
const { viewport:
|
|
1226
|
-
|
|
1271
|
+
const { viewport: s, selectedItem: a } = e;
|
|
1272
|
+
s && a && (s.scrollTop -= a.offsetHeight);
|
|
1227
1273
|
}
|
|
1228
1274
|
}
|
|
1229
1275
|
) : null;
|
|
1230
1276
|
}
|
|
1231
1277
|
);
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
(r,
|
|
1235
|
-
const e = J(
|
|
1236
|
-
return
|
|
1278
|
+
qe.displayName = Ee;
|
|
1279
|
+
const Re = "SelectScrollDownButton", Xe = l.forwardRef(
|
|
1280
|
+
(r, c) => {
|
|
1281
|
+
const e = J(Re, r.__scopeSelect), t = Ue(Re, r.__scopeSelect), [o, n] = l.useState(!1), i = M(c, t.onScrollButtonChange);
|
|
1282
|
+
return L(() => {
|
|
1237
1283
|
if (e.viewport && e.isPositioned) {
|
|
1238
|
-
const
|
|
1239
|
-
const
|
|
1240
|
-
n(
|
|
1284
|
+
const s = e.viewport, a = () => {
|
|
1285
|
+
const m = s.scrollHeight - s.clientHeight, u = Math.ceil(s.scrollTop) < m;
|
|
1286
|
+
n(u);
|
|
1241
1287
|
};
|
|
1242
|
-
return a(),
|
|
1288
|
+
return a(), s.addEventListener("scroll", a), () => s.removeEventListener("scroll", a);
|
|
1243
1289
|
}
|
|
1244
1290
|
}, [e.viewport, e.isPositioned]), o ? /* @__PURE__ */ f(
|
|
1245
|
-
|
|
1291
|
+
Vt,
|
|
1246
1292
|
{
|
|
1247
1293
|
...r,
|
|
1248
1294
|
ref: i,
|
|
1249
1295
|
onAutoScroll: () => {
|
|
1250
|
-
const { viewport:
|
|
1251
|
-
|
|
1296
|
+
const { viewport: s, selectedItem: a } = e;
|
|
1297
|
+
s && a && (s.scrollTop += a.offsetHeight);
|
|
1252
1298
|
}
|
|
1253
1299
|
}
|
|
1254
1300
|
) : null;
|
|
1255
1301
|
}
|
|
1256
1302
|
);
|
|
1257
|
-
|
|
1258
|
-
const
|
|
1259
|
-
(r,
|
|
1260
|
-
const { __scopeSelect: e, onAutoScroll: t, ...o } = r, n = J("SelectScrollButton", e), i = l.useRef(null),
|
|
1303
|
+
Xe.displayName = Re;
|
|
1304
|
+
const Vt = l.forwardRef(
|
|
1305
|
+
(r, c) => {
|
|
1306
|
+
const { __scopeSelect: e, onAutoScroll: t, ...o } = r, n = J("SelectScrollButton", e), i = l.useRef(null), s = ge(e), a = l.useCallback(() => {
|
|
1261
1307
|
i.current !== null && (window.clearInterval(i.current), i.current = null);
|
|
1262
1308
|
}, []);
|
|
1263
|
-
return l.useEffect(() => () => a(), [a]),
|
|
1264
|
-
|
|
1265
|
-
}, [
|
|
1266
|
-
|
|
1309
|
+
return l.useEffect(() => () => a(), [a]), L(() => {
|
|
1310
|
+
s().find((u) => u.ref.current === document.activeElement)?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
1311
|
+
}, [s]), /* @__PURE__ */ f(
|
|
1312
|
+
N.div,
|
|
1267
1313
|
{
|
|
1268
1314
|
"aria-hidden": !0,
|
|
1269
1315
|
...o,
|
|
1270
|
-
ref:
|
|
1316
|
+
ref: c,
|
|
1271
1317
|
style: { flexShrink: 0, ...o.style },
|
|
1272
1318
|
onPointerMove: T(o.onPointerMove, () => {
|
|
1273
1319
|
n.onItemLeave?.(), i.current === null && (i.current = window.setInterval(t, 50));
|
|
@@ -1278,112 +1324,112 @@ const yt = l.forwardRef(
|
|
|
1278
1324
|
}
|
|
1279
1325
|
);
|
|
1280
1326
|
}
|
|
1281
|
-
),
|
|
1282
|
-
(r,
|
|
1327
|
+
), Lo = "SelectSeparator", Ze = l.forwardRef(
|
|
1328
|
+
(r, c) => {
|
|
1283
1329
|
const { __scopeSelect: e, ...t } = r;
|
|
1284
|
-
return /* @__PURE__ */ f(
|
|
1330
|
+
return /* @__PURE__ */ f(N.div, { "aria-hidden": !0, ...t, ref: c });
|
|
1285
1331
|
}
|
|
1286
1332
|
);
|
|
1287
|
-
|
|
1288
|
-
const
|
|
1289
|
-
(r,
|
|
1290
|
-
const { __scopeSelect: e, ...t } = r, o =
|
|
1291
|
-
return n.open && i.position === "popper" ? /* @__PURE__ */ f(le.Arrow, { ...o, ...t, ref:
|
|
1333
|
+
Ze.displayName = Lo;
|
|
1334
|
+
const Ne = "SelectArrow", Je = l.forwardRef(
|
|
1335
|
+
(r, c) => {
|
|
1336
|
+
const { __scopeSelect: e, ...t } = r, o = be(e), n = Y(Ne, e), i = J(Ne, e);
|
|
1337
|
+
return n.open && i.position === "popper" ? /* @__PURE__ */ f(le.Arrow, { ...o, ...t, ref: c }) : null;
|
|
1292
1338
|
}
|
|
1293
1339
|
);
|
|
1294
|
-
|
|
1295
|
-
const
|
|
1296
|
-
(r,
|
|
1297
|
-
const { value: e, ...t } = r, o = l.useRef(null), n =
|
|
1340
|
+
Je.displayName = Ne;
|
|
1341
|
+
const Bo = "BubbleSelect", Ho = l.forwardRef(
|
|
1342
|
+
(r, c) => {
|
|
1343
|
+
const { value: e, ...t } = r, o = l.useRef(null), n = M(c, o), i = _t(e), s = Y(Bo, void 0);
|
|
1298
1344
|
l.useEffect(() => {
|
|
1299
|
-
const
|
|
1300
|
-
if (i !== e &&
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1345
|
+
const m = o.current, u = window.HTMLSelectElement.prototype, p = Object.getOwnPropertyDescriptor(u, "value").set;
|
|
1346
|
+
if (i !== e && p) {
|
|
1347
|
+
const d = new Event("change", { bubbles: !0 });
|
|
1348
|
+
p.call(m, e), m.dispatchEvent(d);
|
|
1303
1349
|
}
|
|
1304
1350
|
}, [i, e]);
|
|
1305
1351
|
let a = e;
|
|
1306
|
-
return
|
|
1352
|
+
return s.multi && !Array.isArray(e) && (a = []), /* @__PURE__ */ f(Mt, { asChild: !0, children: /* @__PURE__ */ f(
|
|
1307
1353
|
"select",
|
|
1308
1354
|
{
|
|
1309
1355
|
...t,
|
|
1310
|
-
multiple:
|
|
1356
|
+
multiple: s.multi ? !0 : void 0,
|
|
1311
1357
|
ref: n,
|
|
1312
1358
|
defaultValue: a
|
|
1313
1359
|
}
|
|
1314
1360
|
) });
|
|
1315
1361
|
}
|
|
1316
1362
|
);
|
|
1317
|
-
|
|
1318
|
-
function
|
|
1319
|
-
const
|
|
1363
|
+
Ho.displayName = "BubbleSelect";
|
|
1364
|
+
function Pt(r) {
|
|
1365
|
+
const c = Ot(r), e = l.useRef(""), t = l.useRef(0), o = l.useCallback(
|
|
1320
1366
|
(i) => {
|
|
1321
|
-
const
|
|
1322
|
-
s
|
|
1323
|
-
e.current =
|
|
1324
|
-
}(
|
|
1367
|
+
const s = e.current + i;
|
|
1368
|
+
c(s), function a(m) {
|
|
1369
|
+
e.current = m, window.clearTimeout(t.current), m !== "" && (t.current = window.setTimeout(() => a(""), 1e3));
|
|
1370
|
+
}(s);
|
|
1325
1371
|
},
|
|
1326
|
-
[
|
|
1372
|
+
[c]
|
|
1327
1373
|
), n = l.useCallback(() => {
|
|
1328
1374
|
e.current = "", window.clearTimeout(t.current);
|
|
1329
1375
|
}, []);
|
|
1330
1376
|
return l.useEffect(() => () => window.clearTimeout(t.current), []), [e, o, n];
|
|
1331
1377
|
}
|
|
1332
|
-
function
|
|
1333
|
-
const o =
|
|
1334
|
-
let i =
|
|
1335
|
-
o.length === 1 && (i = i.filter((
|
|
1336
|
-
const a = i.find((
|
|
1378
|
+
function Et(r, c, e) {
|
|
1379
|
+
const o = c.length > 1 && Array.from(c).every((m) => m === c[0]) ? c[0] : c, n = e ? r.indexOf(e) : -1;
|
|
1380
|
+
let i = $o(r, Math.max(n, 0));
|
|
1381
|
+
o.length === 1 && (i = i.filter((m) => m !== e));
|
|
1382
|
+
const a = i.find((m) => m.textValue.toLowerCase().startsWith(o.toLowerCase()));
|
|
1337
1383
|
return a !== e ? a : void 0;
|
|
1338
1384
|
}
|
|
1339
|
-
function
|
|
1340
|
-
return r.map((e, t) => r[(
|
|
1385
|
+
function $o(r, c) {
|
|
1386
|
+
return r.map((e, t) => r[(c + t) % r.length]);
|
|
1341
1387
|
}
|
|
1342
|
-
const
|
|
1388
|
+
const Rt = (r, c = []) => {
|
|
1343
1389
|
if (Array.isArray(r))
|
|
1344
|
-
return r.reduce((t, o) =>
|
|
1345
|
-
const e =
|
|
1346
|
-
return e === -1 ? [...
|
|
1347
|
-
},
|
|
1390
|
+
return r.reduce((t, o) => Rt(o, t), c);
|
|
1391
|
+
const e = c.indexOf(r);
|
|
1392
|
+
return e === -1 ? [...c, r] : [...c.slice(0, e), ...c.slice(e + 1)];
|
|
1393
|
+
}, Uo = ke, Ko = Fe, Wo = Le, zo = Be, Go = He, jo = $e, Yo = Ke, qo = We, Xo = ze, Zo = Ge, Jo = je, Qo = Ye, en = qe, tn = Xe, on = Ze, nn = Je, En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1348
1394
|
__proto__: null,
|
|
1349
|
-
Arrow:
|
|
1350
|
-
Content:
|
|
1351
|
-
Group:
|
|
1352
|
-
Icon:
|
|
1353
|
-
Item:
|
|
1354
|
-
ItemIndicator:
|
|
1355
|
-
ItemText:
|
|
1356
|
-
Label:
|
|
1357
|
-
Portal:
|
|
1358
|
-
Root:
|
|
1359
|
-
ScrollDownButton:
|
|
1360
|
-
ScrollUpButton:
|
|
1361
|
-
Select:
|
|
1362
|
-
SelectArrow:
|
|
1363
|
-
SelectContent:
|
|
1364
|
-
SelectGroup:
|
|
1365
|
-
SelectIcon:
|
|
1366
|
-
SelectItem:
|
|
1367
|
-
SelectItemIndicator:
|
|
1368
|
-
SelectItemText:
|
|
1369
|
-
SelectLabel:
|
|
1370
|
-
SelectPortal:
|
|
1371
|
-
SelectScrollDownButton:
|
|
1372
|
-
SelectScrollUpButton:
|
|
1373
|
-
SelectSeparator:
|
|
1374
|
-
SelectTrigger:
|
|
1375
|
-
SelectValue:
|
|
1376
|
-
SelectViewport:
|
|
1377
|
-
Separator:
|
|
1378
|
-
Trigger:
|
|
1379
|
-
Value:
|
|
1380
|
-
Viewport:
|
|
1381
|
-
createSelectScope:
|
|
1395
|
+
Arrow: nn,
|
|
1396
|
+
Content: jo,
|
|
1397
|
+
Group: qo,
|
|
1398
|
+
Icon: zo,
|
|
1399
|
+
Item: Zo,
|
|
1400
|
+
ItemIndicator: Qo,
|
|
1401
|
+
ItemText: Jo,
|
|
1402
|
+
Label: Xo,
|
|
1403
|
+
Portal: Go,
|
|
1404
|
+
Root: Uo,
|
|
1405
|
+
ScrollDownButton: tn,
|
|
1406
|
+
ScrollUpButton: en,
|
|
1407
|
+
Select: ke,
|
|
1408
|
+
SelectArrow: Je,
|
|
1409
|
+
SelectContent: $e,
|
|
1410
|
+
SelectGroup: We,
|
|
1411
|
+
SelectIcon: Be,
|
|
1412
|
+
SelectItem: Ge,
|
|
1413
|
+
SelectItemIndicator: Ye,
|
|
1414
|
+
SelectItemText: je,
|
|
1415
|
+
SelectLabel: ze,
|
|
1416
|
+
SelectPortal: He,
|
|
1417
|
+
SelectScrollDownButton: Xe,
|
|
1418
|
+
SelectScrollUpButton: qe,
|
|
1419
|
+
SelectSeparator: Ze,
|
|
1420
|
+
SelectTrigger: Fe,
|
|
1421
|
+
SelectValue: Le,
|
|
1422
|
+
SelectViewport: Ke,
|
|
1423
|
+
Separator: on,
|
|
1424
|
+
Trigger: Ko,
|
|
1425
|
+
Value: Wo,
|
|
1426
|
+
Viewport: Yo,
|
|
1427
|
+
createSelectScope: To
|
|
1382
1428
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1383
1429
|
export {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1430
|
+
Pn as Combobox,
|
|
1431
|
+
En as Select,
|
|
1432
|
+
An as composeEventHandlers,
|
|
1433
|
+
Dt as createCollection,
|
|
1434
|
+
Mn as useCallbackRef
|
|
1389
1435
|
};
|