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