@strapi/ui-primitives 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Collection.d.ts +2 -2
- package/dist/components/Combobox/Combobox.d.ts +3 -4
- package/dist/components/Combobox/Combobox.test.d.ts +1 -0
- package/dist/components/Combobox/VirtualizedViewport.d.ts +1 -2
- package/dist/components/Select/Select.d.ts +6 -6
- package/dist/components/Select/Select.test.d.ts +1 -0
- package/dist/index.js +1 -2315
- package/dist/index.mjs +1187 -1852
- package/package.json +9 -5
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,216 +1,169 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
4
|
-
import { createContextScope, createContext } from "@radix-ui/react-context";
|
|
5
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
-
import { composeEventHandlers as
|
|
7
|
-
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
8
|
-
import { useFocusGuards } from "@radix-ui/react-focus-guards";
|
|
9
|
-
import { FocusScope } from "@radix-ui/react-focus-scope";
|
|
10
|
-
import { useId } from "@radix-ui/react-id";
|
|
11
|
-
import * as
|
|
12
|
-
import { createPopperScope } from "@radix-ui/react-popper";
|
|
13
|
-
import { Portal as
|
|
14
|
-
import { Primitive } from "@radix-ui/react-primitive";
|
|
15
|
-
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
16
|
-
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
|
17
|
-
import { hideOthers } from "aria-hidden";
|
|
18
|
-
import * as
|
|
19
|
-
import { RemoveScroll } from "react-remove-scroll";
|
|
20
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
21
|
-
import { clamp } from "@radix-ui/number";
|
|
22
|
-
import { createCollection as
|
|
23
|
-
import { useDirection } from "@radix-ui/react-direction";
|
|
24
|
-
import { usePrevious } from "@radix-ui/react-use-previous";
|
|
25
|
-
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
|
|
29
|
-
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
1
|
+
import { jsx as d, jsxs as ye, Fragment as Se } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import { useComposedRefs as A } from "@radix-ui/react-compose-refs";
|
|
4
|
+
import { createContextScope as st, createContext as it } from "@radix-ui/react-context";
|
|
5
|
+
import { Slot as Ee } from "@radix-ui/react-slot";
|
|
6
|
+
import { composeEventHandlers as P } from "@radix-ui/primitive";
|
|
7
|
+
import { DismissableLayer as ct } from "@radix-ui/react-dismissable-layer";
|
|
8
|
+
import { useFocusGuards as at } from "@radix-ui/react-focus-guards";
|
|
9
|
+
import { FocusScope as ut } from "@radix-ui/react-focus-scope";
|
|
10
|
+
import { useId as se } from "@radix-ui/react-id";
|
|
11
|
+
import * as ie from "@radix-ui/react-popper";
|
|
12
|
+
import { createPopperScope as dt } from "@radix-ui/react-popper";
|
|
13
|
+
import { Portal as pt } from "@radix-ui/react-portal";
|
|
14
|
+
import { Primitive as N } from "@radix-ui/react-primitive";
|
|
15
|
+
import { useControllableState as de } from "@radix-ui/react-use-controllable-state";
|
|
16
|
+
import { useLayoutEffect as $ } from "@radix-ui/react-use-layout-effect";
|
|
17
|
+
import { hideOthers as ft } from "aria-hidden";
|
|
18
|
+
import * as we from "react-dom";
|
|
19
|
+
import { RemoveScroll as mt } from "react-remove-scroll";
|
|
20
|
+
import { useVirtualizer as jt } from "@tanstack/react-virtual";
|
|
21
|
+
import { clamp as rt } from "@radix-ui/number";
|
|
22
|
+
import { createCollection as Yt } from "@radix-ui/react-collection";
|
|
23
|
+
import { useDirection as qt } from "@radix-ui/react-direction";
|
|
24
|
+
import { usePrevious as Xt } from "@radix-ui/react-use-previous";
|
|
25
|
+
import { VisuallyHidden as Zt } from "@radix-ui/react-visually-hidden";
|
|
26
|
+
function Jt(o) {
|
|
27
|
+
const i = `${o}CollectionProvider`, [e, t] = st(i), [n, r] = e(i, {
|
|
30
28
|
collectionRef: { current: null },
|
|
31
29
|
itemMap: /* @__PURE__ */ new Map(),
|
|
32
30
|
listeners: /* @__PURE__ */ new Set()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const ref = React.useRef(null);
|
|
37
|
-
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
38
|
-
const listeners = React.useRef(/* @__PURE__ */ new Set()).current;
|
|
39
|
-
return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, listeners, children });
|
|
31
|
+
}), c = (u) => {
|
|
32
|
+
const { scope: f, children: h } = u, b = s.useRef(null), x = s.useRef(/* @__PURE__ */ new Map()).current, p = s.useRef(/* @__PURE__ */ new Set()).current;
|
|
33
|
+
return /* @__PURE__ */ d(n, { scope: f, itemMap: x, collectionRef: b, listeners: p, children: h });
|
|
40
34
|
};
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
46
|
-
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
47
|
-
return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });
|
|
35
|
+
c.displayName = i;
|
|
36
|
+
const l = `${o}CollectionSlot`, a = s.forwardRef((u, f) => {
|
|
37
|
+
const { scope: h, children: b } = u, x = r(l, h), p = A(f, x.collectionRef);
|
|
38
|
+
return /* @__PURE__ */ d(Ee, { ref: p, children: b });
|
|
48
39
|
});
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
React.useEffect(() => {
|
|
58
|
-
const previousMap = Array.from(context.itemMap.values());
|
|
59
|
-
context.itemMap.set(ref, { ref, ...itemData });
|
|
60
|
-
context.listeners.forEach((listener) => listener(Array.from(context.itemMap.values()), previousMap));
|
|
61
|
-
return () => {
|
|
62
|
-
const previousMap2 = Array.from(context.itemMap.values());
|
|
63
|
-
context.itemMap.delete(ref);
|
|
64
|
-
context.listeners.forEach((listener) => listener(Array.from(context.itemMap.values()), previousMap2));
|
|
40
|
+
a.displayName = l;
|
|
41
|
+
const m = `${o}CollectionItemSlot`, C = "data-radix-collection-item", v = s.forwardRef((u, f) => {
|
|
42
|
+
const { scope: h, children: b, ...x } = u, p = s.useRef(null), y = A(f, p), E = r(m, h);
|
|
43
|
+
return s.useEffect(() => {
|
|
44
|
+
const O = Array.from(E.itemMap.values());
|
|
45
|
+
return E.itemMap.set(p, { ref: p, ...x }), E.listeners.forEach((F) => F(Array.from(E.itemMap.values()), O)), () => {
|
|
46
|
+
const F = Array.from(E.itemMap.values());
|
|
47
|
+
E.itemMap.delete(p), E.listeners.forEach((_) => _(Array.from(E.itemMap.values()), F));
|
|
65
48
|
};
|
|
66
|
-
});
|
|
67
|
-
return /* @__PURE__ */ jsx(Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
49
|
+
}), /* @__PURE__ */ d(Ee, { [C]: "", ref: y, children: b });
|
|
68
50
|
});
|
|
69
|
-
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const items = Array.from(context.itemMap.values());
|
|
78
|
-
const orderedItems = items.sort(
|
|
79
|
-
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
51
|
+
v.displayName = m;
|
|
52
|
+
function g(u) {
|
|
53
|
+
const f = r(`${o}CollectionConsumer`, u), h = s.useCallback(() => {
|
|
54
|
+
const x = f.collectionRef.current;
|
|
55
|
+
if (!x) return [];
|
|
56
|
+
const p = Array.from(x.querySelectorAll(`[${C}]`));
|
|
57
|
+
return Array.from(f.itemMap.values()).sort(
|
|
58
|
+
(O, F) => p.indexOf(O.ref.current) - p.indexOf(F.ref.current)
|
|
80
59
|
);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
(listener) => {
|
|
85
|
-
context.listeners.add(listener);
|
|
86
|
-
return () => context.listeners.delete(listener);
|
|
87
|
-
},
|
|
88
|
-
[context.listeners]
|
|
60
|
+
}, [f.collectionRef, f.itemMap]), b = s.useCallback(
|
|
61
|
+
(x) => (f.listeners.add(x), () => f.listeners.delete(x)),
|
|
62
|
+
[f.listeners]
|
|
89
63
|
);
|
|
90
|
-
return { getItems, subscribe };
|
|
64
|
+
return { getItems: h, subscribe: b };
|
|
91
65
|
}
|
|
92
66
|
return [
|
|
93
|
-
{ Provider:
|
|
94
|
-
|
|
95
|
-
|
|
67
|
+
{ Provider: c, Slot: a, ItemSlot: v },
|
|
68
|
+
g,
|
|
69
|
+
t
|
|
96
70
|
];
|
|
97
71
|
}
|
|
98
|
-
const
|
|
99
|
-
function
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
cache.set(cacheKey, formatter);
|
|
106
|
-
return formatter;
|
|
72
|
+
const Pe = /* @__PURE__ */ new Map();
|
|
73
|
+
function Qt(o, i) {
|
|
74
|
+
const e = o + (i ? Object.entries(i).sort((n, r) => n[0] < r[0] ? -1 : 1).join() : "");
|
|
75
|
+
if (Pe.has(e))
|
|
76
|
+
return Pe.get(e);
|
|
77
|
+
const t = new Intl.Collator(o, i);
|
|
78
|
+
return Pe.set(e, t), t;
|
|
107
79
|
}
|
|
108
|
-
function
|
|
109
|
-
const
|
|
80
|
+
function De(o, i) {
|
|
81
|
+
const e = Qt(o, {
|
|
110
82
|
usage: "search",
|
|
111
|
-
...
|
|
83
|
+
...i
|
|
112
84
|
});
|
|
113
85
|
return {
|
|
114
|
-
startsWith(
|
|
115
|
-
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
string = string.normalize("NFC");
|
|
119
|
-
substring = substring.normalize("NFC");
|
|
120
|
-
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
86
|
+
startsWith(t, n) {
|
|
87
|
+
return n.length === 0 ? !0 : (t = t.normalize("NFC"), n = n.normalize("NFC"), e.compare(t.slice(0, n.length), n) === 0);
|
|
121
88
|
},
|
|
122
|
-
endsWith(
|
|
123
|
-
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
string = string.normalize("NFC");
|
|
127
|
-
substring = substring.normalize("NFC");
|
|
128
|
-
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
89
|
+
endsWith(t, n) {
|
|
90
|
+
return n.length === 0 ? !0 : (t = t.normalize("NFC"), n = n.normalize("NFC"), e.compare(t.slice(-n.length), n) === 0);
|
|
129
91
|
},
|
|
130
|
-
contains(
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
92
|
+
contains(t, n) {
|
|
93
|
+
if (n.length === 0)
|
|
94
|
+
return !0;
|
|
95
|
+
t = t.normalize("NFC"), n = n.normalize("NFC");
|
|
96
|
+
let r = 0;
|
|
97
|
+
const c = n.length;
|
|
98
|
+
for (; r + c <= t.length; r++) {
|
|
99
|
+
const l = t.slice(r, r + c);
|
|
100
|
+
if (e.compare(n, l) === 0)
|
|
101
|
+
return !0;
|
|
133
102
|
}
|
|
134
|
-
|
|
135
|
-
substring = substring.normalize("NFC");
|
|
136
|
-
let scan = 0;
|
|
137
|
-
const sliceLen = substring.length;
|
|
138
|
-
for (; scan + sliceLen <= string.length; scan++) {
|
|
139
|
-
const slice = string.slice(scan, scan + sliceLen);
|
|
140
|
-
if (collator.compare(substring, slice) === 0) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return false;
|
|
103
|
+
return !1;
|
|
145
104
|
}
|
|
146
105
|
};
|
|
147
106
|
}
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
estimateSize: () => estimatedItemSize,
|
|
164
|
-
overscan
|
|
165
|
-
});
|
|
166
|
-
const virtualItems = virtualizer.getVirtualItems();
|
|
167
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
168
|
-
/* @__PURE__ */ jsx(
|
|
107
|
+
const eo = (o) => {
|
|
108
|
+
const i = s.useRef();
|
|
109
|
+
return s.useEffect(() => {
|
|
110
|
+
i.current = o;
|
|
111
|
+
}), i.current;
|
|
112
|
+
}, ht = s.forwardRef(
|
|
113
|
+
({ children: o, estimatedItemSize: i = 40, overscan: e = 5, getItemCount: t, onViewportChange: n, ...r }, c) => {
|
|
114
|
+
const l = s.useRef(null), a = A(c, l, n), m = s.useMemo(() => s.Children.toArray(o), [o]), C = jt({
|
|
115
|
+
count: t(),
|
|
116
|
+
getScrollElement: () => l.current,
|
|
117
|
+
estimateSize: () => i,
|
|
118
|
+
overscan: e
|
|
119
|
+
}), v = C.getVirtualItems();
|
|
120
|
+
return /* @__PURE__ */ ye(Se, { children: [
|
|
121
|
+
/* @__PURE__ */ d(
|
|
169
122
|
"style",
|
|
170
123
|
{
|
|
171
124
|
dangerouslySetInnerHTML: {
|
|
172
|
-
__html:
|
|
125
|
+
__html: "[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}"
|
|
173
126
|
}
|
|
174
127
|
}
|
|
175
128
|
),
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
|
|
129
|
+
/* @__PURE__ */ d(
|
|
130
|
+
N.div,
|
|
178
131
|
{
|
|
179
132
|
"data-radix-combobox-viewport": "",
|
|
180
133
|
role: "presentation",
|
|
181
|
-
...
|
|
182
|
-
ref:
|
|
134
|
+
...r,
|
|
135
|
+
ref: a,
|
|
183
136
|
style: {
|
|
184
137
|
position: "relative",
|
|
185
138
|
flex: 1,
|
|
186
139
|
overflow: "auto",
|
|
187
|
-
...
|
|
140
|
+
...r.style
|
|
188
141
|
},
|
|
189
|
-
children: /* @__PURE__ */
|
|
142
|
+
children: /* @__PURE__ */ d(
|
|
190
143
|
"div",
|
|
191
144
|
{
|
|
192
145
|
style: {
|
|
193
|
-
height: `${
|
|
146
|
+
height: `${C.getTotalSize()}px`,
|
|
194
147
|
width: "100%",
|
|
195
148
|
position: "relative"
|
|
196
149
|
},
|
|
197
|
-
children:
|
|
198
|
-
const
|
|
199
|
-
return /* @__PURE__ */
|
|
150
|
+
children: v.map((g) => {
|
|
151
|
+
const u = m[g.index];
|
|
152
|
+
return /* @__PURE__ */ d(
|
|
200
153
|
"div",
|
|
201
154
|
{
|
|
202
|
-
"data-index":
|
|
203
|
-
ref:
|
|
155
|
+
"data-index": g.index,
|
|
156
|
+
ref: C.measureElement,
|
|
204
157
|
style: {
|
|
205
158
|
position: "absolute",
|
|
206
159
|
top: 0,
|
|
207
160
|
left: 0,
|
|
208
161
|
width: "100%",
|
|
209
|
-
transform: `translateY(${
|
|
162
|
+
transform: `translateY(${g.start}px)`
|
|
210
163
|
},
|
|
211
|
-
children:
|
|
164
|
+
children: u
|
|
212
165
|
},
|
|
213
|
-
|
|
166
|
+
g.key
|
|
214
167
|
);
|
|
215
168
|
})
|
|
216
169
|
}
|
|
@@ -220,515 +173,352 @@ const VirtualizedViewport = React.forwardRef(
|
|
|
220
173
|
] });
|
|
221
174
|
}
|
|
222
175
|
);
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME);
|
|
232
|
-
const ComboboxProviders = ({ children }) => /* @__PURE__ */ jsx(PopperPrimitive.Root, { children: /* @__PURE__ */ jsx(Collection$1.Provider, { scope: void 0, children }) });
|
|
233
|
-
const formatAutocomplete = (autocomplete) => {
|
|
234
|
-
if (typeof autocomplete === "string") {
|
|
235
|
-
if (autocomplete === "none") {
|
|
236
|
-
return {
|
|
237
|
-
type: autocomplete,
|
|
238
|
-
filter: void 0
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
type: autocomplete,
|
|
243
|
-
filter: "startsWith"
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
return autocomplete;
|
|
247
|
-
};
|
|
248
|
-
const Combobox = (props) => {
|
|
176
|
+
ht.displayName = "VirtualizedViewport";
|
|
177
|
+
const to = [" ", "Enter", "ArrowUp", "ArrowDown"], oo = ["Enter"], no = (o) => !!(o.length === 1 && o.match(/\S| /)), gt = "Combobox", [re, xe] = Jt(gt), [ro, Y] = it(gt), lo = ({ children: o }) => /* @__PURE__ */ d(ie.Root, { children: /* @__PURE__ */ d(re.Provider, { scope: void 0, children: o }) }), so = (o) => typeof o == "string" ? o === "none" ? {
|
|
178
|
+
type: o,
|
|
179
|
+
filter: void 0
|
|
180
|
+
} : {
|
|
181
|
+
type: o,
|
|
182
|
+
filter: "startsWith"
|
|
183
|
+
} : o, io = (o) => {
|
|
249
184
|
const {
|
|
250
|
-
allowCustomValue =
|
|
251
|
-
autocomplete = "none",
|
|
252
|
-
children,
|
|
253
|
-
open:
|
|
254
|
-
defaultOpen,
|
|
255
|
-
onOpenChange,
|
|
256
|
-
value:
|
|
257
|
-
defaultValue,
|
|
258
|
-
onValueChange,
|
|
259
|
-
disabled,
|
|
260
|
-
required =
|
|
261
|
-
locale = "en-EN",
|
|
262
|
-
onTextValueChange,
|
|
263
|
-
textValue:
|
|
264
|
-
defaultTextValue,
|
|
265
|
-
filterValue:
|
|
266
|
-
defaultFilterValue,
|
|
267
|
-
onFilterValueChange,
|
|
268
|
-
isPrintableCharacter =
|
|
269
|
-
visible =
|
|
270
|
-
virtualized = "auto",
|
|
271
|
-
estimatedItemSize = 40,
|
|
272
|
-
overscan = 5
|
|
273
|
-
} =
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const id = useId();
|
|
299
|
-
const focusFirst = React.useCallback(
|
|
300
|
-
(candidates, items) => {
|
|
301
|
-
const allItems = items.map((item) => item.ref.current);
|
|
302
|
-
const [firstItem, ...restItems] = allItems;
|
|
303
|
-
const [lastItem] = restItems.slice(-1);
|
|
304
|
-
const PREVIOUSLY_FOCUSED_ELEMENT = visuallyFocussedItem ?? items.find((item) => item.value === value)?.ref.current;
|
|
305
|
-
for (const candidate of candidates) {
|
|
306
|
-
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
|
|
307
|
-
return;
|
|
308
|
-
candidate?.scrollIntoView({ block: "nearest" });
|
|
309
|
-
if (candidate === firstItem && viewport)
|
|
310
|
-
viewport.scrollTop = 0;
|
|
311
|
-
if (candidate === lastItem && viewport)
|
|
312
|
-
viewport.scrollTop = viewport.scrollHeight;
|
|
313
|
-
setVisuallyFocussedItem(candidate);
|
|
314
|
-
if (autocomplete === "both") {
|
|
315
|
-
const item = items.find((item2) => item2.ref.current === candidate);
|
|
316
|
-
if (item) {
|
|
317
|
-
setTextValue(item.textValue);
|
|
318
|
-
}
|
|
185
|
+
allowCustomValue: i = !1,
|
|
186
|
+
autocomplete: e = "none",
|
|
187
|
+
children: t,
|
|
188
|
+
open: n,
|
|
189
|
+
defaultOpen: r,
|
|
190
|
+
onOpenChange: c,
|
|
191
|
+
value: l,
|
|
192
|
+
defaultValue: a,
|
|
193
|
+
onValueChange: m,
|
|
194
|
+
disabled: C,
|
|
195
|
+
required: v = !1,
|
|
196
|
+
locale: g = "en-EN",
|
|
197
|
+
onTextValueChange: u,
|
|
198
|
+
textValue: f,
|
|
199
|
+
defaultTextValue: h,
|
|
200
|
+
filterValue: b,
|
|
201
|
+
defaultFilterValue: x,
|
|
202
|
+
onFilterValueChange: p,
|
|
203
|
+
isPrintableCharacter: y = no,
|
|
204
|
+
visible: E = !1,
|
|
205
|
+
virtualized: O = "auto",
|
|
206
|
+
estimatedItemSize: F = 40,
|
|
207
|
+
overscan: _ = 5
|
|
208
|
+
} = o, [k, Z] = s.useState(null), [U, z] = s.useState(null), [R, H] = s.useState(null), [L, W] = s.useState(null), [J = !1, Q] = de({
|
|
209
|
+
prop: n,
|
|
210
|
+
defaultProp: r,
|
|
211
|
+
onChange: c
|
|
212
|
+
}), [K, G] = de({
|
|
213
|
+
prop: l,
|
|
214
|
+
defaultProp: a,
|
|
215
|
+
onChange: m
|
|
216
|
+
}), [ce, ee] = de({
|
|
217
|
+
prop: f,
|
|
218
|
+
defaultProp: i && !h ? l : h,
|
|
219
|
+
onChange: u
|
|
220
|
+
}), [fe, me] = de({
|
|
221
|
+
prop: b,
|
|
222
|
+
defaultProp: x,
|
|
223
|
+
onChange: p
|
|
224
|
+
}), te = se(), ae = s.useCallback(
|
|
225
|
+
(S, I) => {
|
|
226
|
+
var j;
|
|
227
|
+
const M = I.map((D) => D.ref.current), [V, ...T] = M, [w] = T.slice(-1), B = L ?? ((j = I.find((D) => D.value === K)) == null ? void 0 : j.ref.current);
|
|
228
|
+
for (const D of S) {
|
|
229
|
+
if (D === B) return;
|
|
230
|
+
if (D == null || D.scrollIntoView({ block: "nearest" }), D === V && U && (U.scrollTop = 0), D === w && U && (U.scrollTop = U.scrollHeight), W(D), e === "both") {
|
|
231
|
+
const ue = I.find((he) => he.ref.current === D);
|
|
232
|
+
ue && ee(ue.textValue);
|
|
319
233
|
}
|
|
320
|
-
if (
|
|
321
|
-
return;
|
|
234
|
+
if (D !== B) return;
|
|
322
235
|
}
|
|
323
236
|
},
|
|
324
|
-
[
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
React.useEffect(() => {
|
|
333
|
-
if (content && trigger)
|
|
334
|
-
return hideOthers([content, trigger]);
|
|
335
|
-
}, [content, trigger]);
|
|
336
|
-
return /* @__PURE__ */ jsx(ComboboxProviders, { children: /* @__PURE__ */ jsx(
|
|
337
|
-
ComboboxProvider,
|
|
237
|
+
[e, ee, U, L, K]
|
|
238
|
+
), ne = so(e);
|
|
239
|
+
return s.useEffect(() => {
|
|
240
|
+
e !== "both" && W(null);
|
|
241
|
+
}, [ce, e]), s.useEffect(() => {
|
|
242
|
+
if (R && k) return ft([R, k]);
|
|
243
|
+
}, [R, k]), /* @__PURE__ */ d(lo, { children: /* @__PURE__ */ d(
|
|
244
|
+
ro,
|
|
338
245
|
{
|
|
339
|
-
allowCustomValue,
|
|
340
|
-
autocomplete:
|
|
341
|
-
required,
|
|
342
|
-
trigger,
|
|
343
|
-
onTriggerChange:
|
|
344
|
-
contentId:
|
|
345
|
-
value,
|
|
346
|
-
onValueChange:
|
|
347
|
-
open,
|
|
348
|
-
onOpenChange:
|
|
349
|
-
disabled,
|
|
350
|
-
locale,
|
|
351
|
-
focusFirst,
|
|
352
|
-
textValue,
|
|
353
|
-
onTextValueChange:
|
|
354
|
-
onViewportChange:
|
|
355
|
-
onContentChange:
|
|
356
|
-
visuallyFocussedItem,
|
|
357
|
-
filterValue,
|
|
358
|
-
onFilterValueChange:
|
|
359
|
-
onVisuallyFocussedItemChange:
|
|
360
|
-
isPrintableCharacter,
|
|
361
|
-
visible,
|
|
362
|
-
virtualized,
|
|
363
|
-
estimatedItemSize,
|
|
364
|
-
overscan,
|
|
365
|
-
children
|
|
246
|
+
allowCustomValue: i,
|
|
247
|
+
autocomplete: ne,
|
|
248
|
+
required: v,
|
|
249
|
+
trigger: k,
|
|
250
|
+
onTriggerChange: Z,
|
|
251
|
+
contentId: te,
|
|
252
|
+
value: K,
|
|
253
|
+
onValueChange: G,
|
|
254
|
+
open: J,
|
|
255
|
+
onOpenChange: Q,
|
|
256
|
+
disabled: C,
|
|
257
|
+
locale: g,
|
|
258
|
+
focusFirst: ae,
|
|
259
|
+
textValue: ce,
|
|
260
|
+
onTextValueChange: ee,
|
|
261
|
+
onViewportChange: z,
|
|
262
|
+
onContentChange: H,
|
|
263
|
+
visuallyFocussedItem: L,
|
|
264
|
+
filterValue: fe,
|
|
265
|
+
onFilterValueChange: me,
|
|
266
|
+
onVisuallyFocussedItemChange: W,
|
|
267
|
+
isPrintableCharacter: y,
|
|
268
|
+
visible: E,
|
|
269
|
+
virtualized: O,
|
|
270
|
+
estimatedItemSize: F,
|
|
271
|
+
overscan: _,
|
|
272
|
+
children: t
|
|
366
273
|
}
|
|
367
274
|
) });
|
|
368
|
-
}
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
const { ...triggerProps } = props;
|
|
372
|
-
const context = useComboboxContext(TRIGGER_NAME$1);
|
|
373
|
-
const handleOpen = () => {
|
|
374
|
-
if (!context.disabled) {
|
|
375
|
-
context.onOpenChange(true);
|
|
376
|
-
}
|
|
275
|
+
}, xt = "ComboboxTrigger", Ct = s.forwardRef((o, i) => {
|
|
276
|
+
const { ...e } = o, t = Y(xt), n = () => {
|
|
277
|
+
t.disabled || t.onOpenChange(!0);
|
|
377
278
|
};
|
|
378
|
-
return /* @__PURE__ */
|
|
379
|
-
|
|
279
|
+
return /* @__PURE__ */ d(ie.Anchor, { asChild: !0, children: /* @__PURE__ */ d(
|
|
280
|
+
ut,
|
|
380
281
|
{
|
|
381
|
-
asChild:
|
|
382
|
-
trapped:
|
|
383
|
-
onMountAutoFocus: (
|
|
384
|
-
|
|
282
|
+
asChild: !0,
|
|
283
|
+
trapped: t.open,
|
|
284
|
+
onMountAutoFocus: (r) => {
|
|
285
|
+
r.preventDefault();
|
|
385
286
|
},
|
|
386
|
-
onUnmountAutoFocus: (
|
|
387
|
-
|
|
388
|
-
document.getSelection()
|
|
389
|
-
event.preventDefault();
|
|
287
|
+
onUnmountAutoFocus: (r) => {
|
|
288
|
+
var c, l;
|
|
289
|
+
(c = t.trigger) == null || c.focus({ preventScroll: !0 }), (l = document.getSelection()) == null || l.empty(), r.preventDefault();
|
|
390
290
|
},
|
|
391
|
-
children: /* @__PURE__ */
|
|
291
|
+
children: /* @__PURE__ */ d(
|
|
392
292
|
"div",
|
|
393
293
|
{
|
|
394
|
-
ref:
|
|
395
|
-
"data-disabled":
|
|
396
|
-
...
|
|
397
|
-
onClick:
|
|
398
|
-
|
|
399
|
-
|
|
294
|
+
ref: i,
|
|
295
|
+
"data-disabled": t.disabled ? "" : void 0,
|
|
296
|
+
...e,
|
|
297
|
+
onClick: P(e.onClick, (r) => {
|
|
298
|
+
var c;
|
|
299
|
+
if (t.disabled) {
|
|
300
|
+
r.preventDefault();
|
|
400
301
|
return;
|
|
401
302
|
}
|
|
402
|
-
|
|
303
|
+
(c = t.trigger) == null || c.focus();
|
|
403
304
|
}),
|
|
404
|
-
onPointerDown:
|
|
405
|
-
|
|
406
|
-
|
|
305
|
+
onPointerDown: P(e.onPointerDown, (r) => {
|
|
306
|
+
var a;
|
|
307
|
+
if (t.disabled) {
|
|
308
|
+
r.preventDefault();
|
|
407
309
|
return;
|
|
408
310
|
}
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
target.releasePointerCapture(event.pointerId);
|
|
412
|
-
}
|
|
413
|
-
const buttonTarg = target.closest("button") ?? target.closest("div");
|
|
414
|
-
if (buttonTarg !== event.currentTarget) {
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (event.button === 0 && event.ctrlKey === false) {
|
|
418
|
-
handleOpen();
|
|
419
|
-
context.trigger?.focus();
|
|
420
|
-
}
|
|
311
|
+
const c = r.target;
|
|
312
|
+
c.hasPointerCapture(r.pointerId) && c.releasePointerCapture(r.pointerId), (c.closest("button") ?? c.closest("div")) === r.currentTarget && r.button === 0 && r.ctrlKey === !1 && (n(), (a = t.trigger) == null || a.focus());
|
|
421
313
|
})
|
|
422
314
|
}
|
|
423
315
|
)
|
|
424
316
|
}
|
|
425
317
|
) });
|
|
426
318
|
});
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (!isDisabled) {
|
|
438
|
-
context.onOpenChange(true);
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
const previousFilter = usePrev(context.filterValue);
|
|
442
|
-
useLayoutEffect(() => {
|
|
443
|
-
const timeout = setTimeout(() => {
|
|
444
|
-
if (context.textValue === "" || context.textValue === void 0 || context.filterValue === "" || context.filterValue === void 0)
|
|
319
|
+
Ct.displayName = xt;
|
|
320
|
+
const vt = "ComboboxInput", bt = s.forwardRef((o, i) => {
|
|
321
|
+
var C;
|
|
322
|
+
const e = Y(vt), t = s.useRef(null), { getItems: n } = xe(void 0), { startsWith: r } = De(e.locale, { sensitivity: "base" }), c = e.disabled, l = A(t, i, e.onTriggerChange), a = () => {
|
|
323
|
+
c || e.onOpenChange(!0);
|
|
324
|
+
}, m = eo(e.filterValue);
|
|
325
|
+
return $(() => {
|
|
326
|
+
const v = setTimeout(() => {
|
|
327
|
+
var f;
|
|
328
|
+
if (e.textValue === "" || e.textValue === void 0 || e.filterValue === "" || e.filterValue === void 0)
|
|
445
329
|
return;
|
|
446
|
-
const
|
|
447
|
-
(
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
if (firstItem && !context.visuallyFocussedItem && characterChangedAtIndex === context.filterValue.length) {
|
|
451
|
-
inputRef.current?.setSelectionRange(context.filterValue.length, context.textValue.length);
|
|
452
|
-
}
|
|
330
|
+
const g = n().find(
|
|
331
|
+
(h) => h.type === "option" && r(h.textValue, e.textValue)
|
|
332
|
+
), u = wo(m ?? "", e.filterValue);
|
|
333
|
+
g && !e.visuallyFocussedItem && u === e.filterValue.length && ((f = t.current) == null || f.setSelectionRange(e.filterValue.length, e.textValue.length));
|
|
453
334
|
});
|
|
454
|
-
return () => clearTimeout(
|
|
455
|
-
}, [
|
|
456
|
-
return /* @__PURE__ */ jsx(
|
|
335
|
+
return () => clearTimeout(v);
|
|
336
|
+
}, [e.textValue, e.filterValue, r, e.visuallyFocussedItem, n, m]), /* @__PURE__ */ d(
|
|
457
337
|
"input",
|
|
458
338
|
{
|
|
459
339
|
type: "text",
|
|
460
340
|
role: "combobox",
|
|
461
|
-
"aria-controls":
|
|
462
|
-
"aria-expanded":
|
|
463
|
-
"aria-required":
|
|
464
|
-
"aria-autocomplete":
|
|
465
|
-
"data-state":
|
|
466
|
-
"aria-disabled":
|
|
467
|
-
"aria-activedescendant":
|
|
468
|
-
disabled:
|
|
469
|
-
"data-disabled":
|
|
470
|
-
"data-placeholder":
|
|
471
|
-
value:
|
|
472
|
-
...
|
|
473
|
-
ref:
|
|
474
|
-
onKeyDown:
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
486
|
-
const currentElement = context.visuallyFocussedItem ?? getItems().find((item) => item.value === context.value)?.ref.current;
|
|
487
|
-
if (currentElement) {
|
|
488
|
-
let currentIndex = candidateNodes.indexOf(currentElement);
|
|
489
|
-
if (currentIndex === candidateNodes.length - 1) {
|
|
490
|
-
currentIndex = -1;
|
|
491
|
-
}
|
|
492
|
-
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
341
|
+
"aria-controls": e.contentId,
|
|
342
|
+
"aria-expanded": e.open,
|
|
343
|
+
"aria-required": e.required,
|
|
344
|
+
"aria-autocomplete": e.autocomplete.type,
|
|
345
|
+
"data-state": e.open ? "open" : "closed",
|
|
346
|
+
"aria-disabled": c,
|
|
347
|
+
"aria-activedescendant": (C = e.visuallyFocussedItem) == null ? void 0 : C.id,
|
|
348
|
+
disabled: c,
|
|
349
|
+
"data-disabled": c ? "" : void 0,
|
|
350
|
+
"data-placeholder": e.textValue === void 0 ? "" : void 0,
|
|
351
|
+
value: e.textValue ?? "",
|
|
352
|
+
...o,
|
|
353
|
+
ref: l,
|
|
354
|
+
onKeyDown: P(o.onKeyDown, (v) => {
|
|
355
|
+
var g, u;
|
|
356
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(v.key))
|
|
357
|
+
e.open || a(), setTimeout(() => {
|
|
358
|
+
var b;
|
|
359
|
+
let h = n().filter((x) => !x.disabled && x.isVisible).map((x) => x.ref.current);
|
|
360
|
+
if (["ArrowUp", "End"].includes(v.key) && (h = h.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(v.key)) {
|
|
361
|
+
const x = e.visuallyFocussedItem ?? ((b = n().find((p) => p.value === e.value)) == null ? void 0 : b.ref.current);
|
|
362
|
+
if (x) {
|
|
363
|
+
let p = h.indexOf(x);
|
|
364
|
+
p === h.length - 1 && (p = -1), h = h.slice(p + 1);
|
|
493
365
|
}
|
|
494
366
|
}
|
|
495
|
-
if (["ArrowDown"].includes(
|
|
496
|
-
const [
|
|
497
|
-
|
|
498
|
-
if (context.textValue === firstItemText) {
|
|
499
|
-
candidateNodes = restItems;
|
|
500
|
-
}
|
|
367
|
+
if (["ArrowDown"].includes(v.key) && e.autocomplete.type === "both" && h.length > 1) {
|
|
368
|
+
const [x, ...p] = h, y = n().find((E) => E.ref.current === x).textValue;
|
|
369
|
+
e.textValue === y && (h = p);
|
|
501
370
|
}
|
|
502
|
-
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
371
|
+
e.focusFirst(h, n());
|
|
372
|
+
}), v.preventDefault();
|
|
373
|
+
else if (["Tab"].includes(v.key) && e.open)
|
|
374
|
+
v.preventDefault();
|
|
375
|
+
else if (["Escape"].includes(v.key))
|
|
376
|
+
e.open ? e.onOpenChange(!1) : (e.onValueChange(void 0), e.onTextValueChange("")), v.preventDefault();
|
|
377
|
+
else if (oo.includes(v.key)) {
|
|
378
|
+
if (e.visuallyFocussedItem) {
|
|
379
|
+
const f = n().find((h) => h.ref.current === e.visuallyFocussedItem);
|
|
380
|
+
f && (e.onValueChange(f.value), e.onTextValueChange(f.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(f.textValue), (g = f.ref.current) == null || g.click());
|
|
510
381
|
} else {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
event.preventDefault();
|
|
515
|
-
} else if (SELECTION_KEYS$1.includes(event.key)) {
|
|
516
|
-
if (context.visuallyFocussedItem) {
|
|
517
|
-
const focussedItem = getItems().find((item) => item.ref.current === context.visuallyFocussedItem);
|
|
518
|
-
if (focussedItem) {
|
|
519
|
-
context.onValueChange(focussedItem.value);
|
|
520
|
-
context.onTextValueChange(focussedItem.textValue);
|
|
521
|
-
if (context.autocomplete.type === "both") {
|
|
522
|
-
context.onFilterValueChange(focussedItem.textValue);
|
|
523
|
-
}
|
|
524
|
-
focussedItem.ref.current?.click();
|
|
525
|
-
}
|
|
526
|
-
} else {
|
|
527
|
-
const matchedItem = getItems().find(
|
|
528
|
-
(item) => item.type === "option" && !item.disabled && item.textValue === context.textValue
|
|
382
|
+
const f = n().find(
|
|
383
|
+
(h) => h.type === "option" && !h.disabled && h.textValue === e.textValue
|
|
529
384
|
);
|
|
530
|
-
|
|
531
|
-
context.onValueChange(matchedItem.value);
|
|
532
|
-
context.onTextValueChange(matchedItem.textValue);
|
|
533
|
-
if (context.autocomplete.type === "both") {
|
|
534
|
-
context.onFilterValueChange(matchedItem.textValue);
|
|
535
|
-
}
|
|
536
|
-
matchedItem.ref.current?.click();
|
|
537
|
-
}
|
|
385
|
+
f && (e.onValueChange(f.value), e.onTextValueChange(f.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(f.textValue), (u = f.ref.current) == null || u.click());
|
|
538
386
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
context.onVisuallyFocussedItemChange(null);
|
|
543
|
-
}
|
|
387
|
+
e.onOpenChange(!1), v.preventDefault();
|
|
388
|
+
} else
|
|
389
|
+
e.onVisuallyFocussedItemChange(null);
|
|
544
390
|
}),
|
|
545
|
-
onChange:
|
|
546
|
-
|
|
547
|
-
if (context.autocomplete.type === "both") {
|
|
548
|
-
context.onFilterValueChange(event.currentTarget.value);
|
|
549
|
-
}
|
|
391
|
+
onChange: P(o.onChange, (v) => {
|
|
392
|
+
e.onTextValueChange(v.currentTarget.value), e.autocomplete.type === "both" && e.onFilterValueChange(v.currentTarget.value);
|
|
550
393
|
}),
|
|
551
|
-
onKeyUp:
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const value = context.filterValue;
|
|
558
|
-
const firstItem = getItems().find((item) => startsWith(item.textValue, value));
|
|
559
|
-
if (firstItem) {
|
|
560
|
-
context.onTextValueChange(firstItem.textValue);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
if (context.autocomplete.type === "none" && context.isPrintableCharacter(event.key)) {
|
|
565
|
-
const value = context.textValue ?? "";
|
|
566
|
-
const nextItem = getItems().find((item) => startsWith(item.textValue, value));
|
|
567
|
-
if (nextItem) {
|
|
568
|
-
context.onVisuallyFocussedItemChange(nextItem.ref.current);
|
|
569
|
-
nextItem.ref.current?.scrollIntoView();
|
|
394
|
+
onKeyUp: P(o.onKeyUp, (v) => {
|
|
395
|
+
var g;
|
|
396
|
+
if (!e.open && (e.isPrintableCharacter(v.key) || ["Backspace"].includes(v.key)) && a(), setTimeout(() => {
|
|
397
|
+
if (e.autocomplete.type === "both" && e.isPrintableCharacter(v.key) && e.filterValue !== void 0) {
|
|
398
|
+
const u = e.filterValue, f = n().find((h) => r(h.textValue, u));
|
|
399
|
+
f && e.onTextValueChange(f.textValue);
|
|
570
400
|
}
|
|
401
|
+
}), e.autocomplete.type === "none" && e.isPrintableCharacter(v.key)) {
|
|
402
|
+
const u = e.textValue ?? "", f = n().find((h) => r(h.textValue, u));
|
|
403
|
+
f && (e.onVisuallyFocussedItemChange(f.ref.current), (g = f.ref.current) == null || g.scrollIntoView());
|
|
571
404
|
}
|
|
572
405
|
}),
|
|
573
|
-
onBlur:
|
|
574
|
-
if (
|
|
406
|
+
onBlur: P(o.onBlur, () => {
|
|
407
|
+
if (e.open)
|
|
575
408
|
return;
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
(item) => item.textValue === context.textValue && item.type === "option"
|
|
409
|
+
e.onVisuallyFocussedItemChange(null);
|
|
410
|
+
const [v] = n().filter(
|
|
411
|
+
(u) => u.textValue === e.textValue && u.type === "option"
|
|
580
412
|
);
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
if (context.autocomplete.type === "both") {
|
|
584
|
-
context.onFilterValueChange(activeItem.textValue);
|
|
585
|
-
}
|
|
413
|
+
if (v) {
|
|
414
|
+
e.onValueChange(v.value), e.autocomplete.type === "both" && e.onFilterValueChange(v.textValue);
|
|
586
415
|
return;
|
|
587
416
|
}
|
|
588
|
-
if (
|
|
589
|
-
|
|
590
|
-
if (context.autocomplete.type === "both") {
|
|
591
|
-
context.onFilterValueChange(context.textValue);
|
|
592
|
-
}
|
|
417
|
+
if (e.allowCustomValue) {
|
|
418
|
+
e.onValueChange(e.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(e.textValue);
|
|
593
419
|
return;
|
|
594
420
|
}
|
|
595
|
-
const [
|
|
596
|
-
|
|
597
|
-
context.onTextValueChange(previousItem.textValue);
|
|
598
|
-
if (context.autocomplete.type === "both") {
|
|
599
|
-
context.onFilterValueChange(previousItem.textValue);
|
|
600
|
-
}
|
|
601
|
-
} else {
|
|
602
|
-
context.onValueChange(void 0);
|
|
603
|
-
context.onTextValueChange("");
|
|
604
|
-
}
|
|
421
|
+
const [g] = n().filter((u) => u.value === e.value && u.type === "option");
|
|
422
|
+
g && e.textValue !== "" ? (e.onTextValueChange(g.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(g.textValue)) : (e.onValueChange(void 0), e.onTextValueChange(""));
|
|
605
423
|
})
|
|
606
424
|
}
|
|
607
425
|
);
|
|
608
426
|
});
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
const { children, ...
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const handleOpen = () => {
|
|
615
|
-
if (!isDisabled) {
|
|
616
|
-
context.onOpenChange(true);
|
|
617
|
-
context.trigger?.focus();
|
|
618
|
-
}
|
|
427
|
+
bt.displayName = "ComboboxTextInput";
|
|
428
|
+
const yt = s.forwardRef((o, i) => {
|
|
429
|
+
const { children: e, ...t } = o, n = Y(vt), r = n.disabled, c = () => {
|
|
430
|
+
var l;
|
|
431
|
+
r || (n.onOpenChange(!0), (l = n.trigger) == null || l.focus());
|
|
619
432
|
};
|
|
620
|
-
return /* @__PURE__ */
|
|
621
|
-
|
|
433
|
+
return /* @__PURE__ */ d(
|
|
434
|
+
N.button,
|
|
622
435
|
{
|
|
623
|
-
"aria-hidden":
|
|
436
|
+
"aria-hidden": !0,
|
|
624
437
|
type: "button",
|
|
625
|
-
"aria-disabled":
|
|
626
|
-
"aria-controls":
|
|
627
|
-
"aria-expanded":
|
|
628
|
-
disabled:
|
|
629
|
-
"data-disabled":
|
|
630
|
-
...
|
|
438
|
+
"aria-disabled": r,
|
|
439
|
+
"aria-controls": n.contentId,
|
|
440
|
+
"aria-expanded": n.open,
|
|
441
|
+
disabled: r,
|
|
442
|
+
"data-disabled": r ? "" : void 0,
|
|
443
|
+
...t,
|
|
631
444
|
tabIndex: -1,
|
|
632
|
-
ref:
|
|
633
|
-
onClick:
|
|
634
|
-
|
|
445
|
+
ref: i,
|
|
446
|
+
onClick: P(t.onClick, () => {
|
|
447
|
+
var l;
|
|
448
|
+
(l = n.trigger) == null || l.focus();
|
|
635
449
|
}),
|
|
636
|
-
onPointerDown:
|
|
637
|
-
|
|
638
|
-
handleOpen();
|
|
639
|
-
event.preventDefault();
|
|
640
|
-
}
|
|
450
|
+
onPointerDown: P(t.onPointerDown, (l) => {
|
|
451
|
+
l.button === 0 && l.ctrlKey === !1 && (c(), l.preventDefault());
|
|
641
452
|
}),
|
|
642
|
-
onKeyDown:
|
|
643
|
-
|
|
644
|
-
handleOpen();
|
|
645
|
-
event.preventDefault();
|
|
646
|
-
}
|
|
453
|
+
onKeyDown: P(t.onKeyDown, (l) => {
|
|
454
|
+
to.includes(l.key) && (c(), l.preventDefault());
|
|
647
455
|
}),
|
|
648
|
-
children:
|
|
456
|
+
children: e || "▼"
|
|
649
457
|
}
|
|
650
458
|
);
|
|
651
459
|
});
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
};
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}, [])
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
}, [getItems, context.autocomplete, context.value, context.open]);
|
|
674
|
-
if (!context.open) {
|
|
675
|
-
const frag = fragment;
|
|
676
|
-
return frag ? ReactDOM.createPortal(
|
|
677
|
-
/* @__PURE__ */ jsx(Collection$1.Slot, { scope: void 0, children: /* @__PURE__ */ jsx("div", { children: props.children }) }),
|
|
678
|
-
frag
|
|
460
|
+
yt.displayName = "ComboboxIcon";
|
|
461
|
+
const co = "ComboboxPortal", St = (o) => /* @__PURE__ */ d(pt, { asChild: !0, ...o });
|
|
462
|
+
St.displayName = co;
|
|
463
|
+
const ke = "ComboboxContent", wt = s.forwardRef((o, i) => {
|
|
464
|
+
const e = Y(ke), { getItems: t } = xe(void 0), [n, r] = s.useState();
|
|
465
|
+
if ($(() => {
|
|
466
|
+
r(new DocumentFragment());
|
|
467
|
+
}, []), $(() => {
|
|
468
|
+
e.open && e.autocomplete.type === "none" && setTimeout(() => {
|
|
469
|
+
var l;
|
|
470
|
+
const c = t().find((a) => a.value === e.value);
|
|
471
|
+
(l = c == null ? void 0 : c.ref.current) == null || l.scrollIntoView({ block: "nearest" });
|
|
472
|
+
});
|
|
473
|
+
}, [t, e.autocomplete, e.value, e.open]), !e.open) {
|
|
474
|
+
const c = n;
|
|
475
|
+
return c ? we.createPortal(
|
|
476
|
+
/* @__PURE__ */ d(re.Slot, { scope: void 0, children: /* @__PURE__ */ d("div", { children: o.children }) }),
|
|
477
|
+
c
|
|
679
478
|
) : null;
|
|
680
479
|
}
|
|
681
|
-
return /* @__PURE__ */
|
|
480
|
+
return /* @__PURE__ */ d(It, { ...o, ref: i });
|
|
682
481
|
});
|
|
683
|
-
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
const { onOpenChange } = context;
|
|
691
|
-
useFocusGuards();
|
|
692
|
-
React.useEffect(() => {
|
|
693
|
-
const close = () => {
|
|
694
|
-
onOpenChange(false);
|
|
482
|
+
wt.displayName = ke;
|
|
483
|
+
const ao = 10, It = s.forwardRef(
|
|
484
|
+
(o, i) => {
|
|
485
|
+
const { onEscapeKeyDown: e, onPointerDownOutside: t, ...n } = o, r = Y(ke), c = A(i, (a) => r.onContentChange(a)), { onOpenChange: l } = r;
|
|
486
|
+
return at(), s.useEffect(() => {
|
|
487
|
+
const a = () => {
|
|
488
|
+
l(!1);
|
|
695
489
|
};
|
|
696
|
-
window.addEventListener("blur",
|
|
697
|
-
|
|
698
|
-
return () => {
|
|
699
|
-
window.removeEventListener("blur", close);
|
|
700
|
-
window.removeEventListener("resize", close);
|
|
490
|
+
return window.addEventListener("blur", a), window.addEventListener("resize", a), () => {
|
|
491
|
+
window.removeEventListener("blur", a), window.removeEventListener("resize", a);
|
|
701
492
|
};
|
|
702
|
-
}, [
|
|
703
|
-
|
|
704
|
-
DismissableLayer,
|
|
493
|
+
}, [l]), /* @__PURE__ */ d(mt, { allowPinchZoom: !0, children: /* @__PURE__ */ d(
|
|
494
|
+
ct,
|
|
705
495
|
{
|
|
706
|
-
asChild:
|
|
707
|
-
onEscapeKeyDown,
|
|
708
|
-
onPointerDownOutside,
|
|
709
|
-
onFocusOutside: (
|
|
710
|
-
|
|
496
|
+
asChild: !0,
|
|
497
|
+
onEscapeKeyDown: e,
|
|
498
|
+
onPointerDownOutside: t,
|
|
499
|
+
onFocusOutside: (a) => {
|
|
500
|
+
a.preventDefault();
|
|
711
501
|
},
|
|
712
502
|
onDismiss: () => {
|
|
713
|
-
|
|
714
|
-
|
|
503
|
+
var a;
|
|
504
|
+
r.onOpenChange(!1), (a = r.trigger) == null || a.focus({ preventScroll: !0 });
|
|
715
505
|
},
|
|
716
|
-
children: /* @__PURE__ */
|
|
717
|
-
|
|
506
|
+
children: /* @__PURE__ */ d(
|
|
507
|
+
Tt,
|
|
718
508
|
{
|
|
719
509
|
role: "listbox",
|
|
720
|
-
id:
|
|
721
|
-
"data-state":
|
|
722
|
-
onContextMenu: (
|
|
723
|
-
...
|
|
724
|
-
ref:
|
|
510
|
+
id: r.contentId,
|
|
511
|
+
"data-state": r.open ? "open" : "closed",
|
|
512
|
+
onContextMenu: (a) => a.preventDefault(),
|
|
513
|
+
...n,
|
|
514
|
+
ref: c,
|
|
725
515
|
style: {
|
|
726
516
|
// flex layout so we can place the scroll buttons properly
|
|
727
517
|
display: "flex",
|
|
728
518
|
flexDirection: "column",
|
|
729
519
|
// reset the outline by default as the content MAY get focused
|
|
730
520
|
outline: "none",
|
|
731
|
-
...
|
|
521
|
+
...n.style
|
|
732
522
|
}
|
|
733
523
|
}
|
|
734
524
|
)
|
|
@@ -736,71 +526,60 @@ const ComboboxContentImpl = React.forwardRef(
|
|
|
736
526
|
) });
|
|
737
527
|
}
|
|
738
528
|
);
|
|
739
|
-
|
|
740
|
-
const
|
|
741
|
-
(
|
|
742
|
-
const { align = "start", collisionPadding =
|
|
743
|
-
return /* @__PURE__ */
|
|
744
|
-
|
|
529
|
+
It.displayName = "ComboboxContentImpl";
|
|
530
|
+
const Tt = s.forwardRef(
|
|
531
|
+
(o, i) => {
|
|
532
|
+
const { align: e = "start", collisionPadding: t = ao, ...n } = o;
|
|
533
|
+
return /* @__PURE__ */ d(
|
|
534
|
+
ie.Content,
|
|
745
535
|
{
|
|
746
|
-
...
|
|
747
|
-
ref:
|
|
748
|
-
align,
|
|
749
|
-
collisionPadding,
|
|
536
|
+
...n,
|
|
537
|
+
ref: i,
|
|
538
|
+
align: e,
|
|
539
|
+
collisionPadding: t,
|
|
750
540
|
style: {
|
|
751
541
|
// Ensure border-box for floating-ui calculations
|
|
752
542
|
boxSizing: "border-box",
|
|
753
|
-
...
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
"--radix-combobox-trigger-width": "var(--radix-popper-anchor-width)",
|
|
760
|
-
"--radix-combobox-trigger-height": "var(--radix-popper-anchor-height)"
|
|
761
|
-
}
|
|
543
|
+
...n.style,
|
|
544
|
+
"--radix-combobox-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
545
|
+
"--radix-combobox-content-available-width": "var(--radix-popper-available-width)",
|
|
546
|
+
"--radix-combobox-content-available-height": "var(--radix-popper-available-height)",
|
|
547
|
+
"--radix-combobox-trigger-width": "var(--radix-popper-anchor-width)",
|
|
548
|
+
"--radix-combobox-trigger-height": "var(--radix-popper-anchor-height)"
|
|
762
549
|
}
|
|
763
550
|
}
|
|
764
551
|
);
|
|
765
552
|
}
|
|
766
553
|
);
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
estimatedItemSize: comboboxContext.estimatedItemSize,
|
|
783
|
-
overscan: comboboxContext.overscan,
|
|
784
|
-
onViewportChange: comboboxContext.onViewportChange
|
|
785
|
-
}
|
|
786
|
-
) });
|
|
787
|
-
}
|
|
788
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
789
|
-
/* @__PURE__ */ jsx(
|
|
554
|
+
Tt.displayName = "ComboboxPopperPosition";
|
|
555
|
+
const Vt = "ComboboxViewport", Pt = s.forwardRef((o, i) => {
|
|
556
|
+
const e = Y(Vt), t = A(i, e.onViewportChange), r = s.useMemo(() => s.Children.toArray(o.children), [o.children]).length;
|
|
557
|
+
return e.virtualized === !0 || e.virtualized === "auto" && r > 100 ? /* @__PURE__ */ d(re.Slot, { scope: void 0, children: /* @__PURE__ */ d(
|
|
558
|
+
ht,
|
|
559
|
+
{
|
|
560
|
+
...o,
|
|
561
|
+
ref: t,
|
|
562
|
+
getItemCount: () => r,
|
|
563
|
+
estimatedItemSize: e.estimatedItemSize,
|
|
564
|
+
overscan: e.overscan,
|
|
565
|
+
onViewportChange: e.onViewportChange
|
|
566
|
+
}
|
|
567
|
+
) }) : /* @__PURE__ */ ye(Se, { children: [
|
|
568
|
+
/* @__PURE__ */ d(
|
|
790
569
|
"style",
|
|
791
570
|
{
|
|
792
571
|
dangerouslySetInnerHTML: {
|
|
793
|
-
__html:
|
|
572
|
+
__html: "[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}"
|
|
794
573
|
}
|
|
795
574
|
}
|
|
796
575
|
),
|
|
797
|
-
/* @__PURE__ */
|
|
798
|
-
|
|
576
|
+
/* @__PURE__ */ d(re.Slot, { scope: void 0, children: /* @__PURE__ */ d(
|
|
577
|
+
N.div,
|
|
799
578
|
{
|
|
800
579
|
"data-radix-combobox-viewport": "",
|
|
801
580
|
role: "presentation",
|
|
802
|
-
...
|
|
803
|
-
ref:
|
|
581
|
+
...o,
|
|
582
|
+
ref: t,
|
|
804
583
|
style: {
|
|
805
584
|
// we use position: 'relative' here on the `viewport` so that when we call
|
|
806
585
|
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
@@ -808,774 +587,542 @@ const ComboboxViewport = React.forwardRef((props, forwardedRef) => {
|
|
|
808
587
|
position: "relative",
|
|
809
588
|
flex: 1,
|
|
810
589
|
overflow: "auto",
|
|
811
|
-
...
|
|
590
|
+
...o.style
|
|
812
591
|
}
|
|
813
592
|
}
|
|
814
593
|
) })
|
|
815
594
|
] });
|
|
816
595
|
});
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
const [
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
const [fragment, setFragment] = React.useState();
|
|
823
|
-
useLayoutEffect(() => {
|
|
824
|
-
setFragment(new DocumentFragment());
|
|
596
|
+
Pt.displayName = Vt;
|
|
597
|
+
const Ie = "ComboboxItem", [lt, Fe] = it(Ie), Le = s.forwardRef((o, i) => {
|
|
598
|
+
const { value: e, disabled: t = !1, textValue: n, ...r } = o, [c, l] = s.useState();
|
|
599
|
+
$(() => {
|
|
600
|
+
l(new DocumentFragment());
|
|
825
601
|
}, []);
|
|
826
|
-
const { onTextValueChange, textValue:
|
|
827
|
-
|
|
828
|
-
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
829
|
-
const isSelected = context.value === value;
|
|
830
|
-
const { startsWith, contains } = useFilter(context.locale, { sensitivity: "base" });
|
|
831
|
-
const handleTextValueChange = React.useCallback((node) => {
|
|
832
|
-
setTextValue((prevTextValue) => {
|
|
833
|
-
return prevTextValue || (node?.textContent ?? "").trim();
|
|
834
|
-
});
|
|
602
|
+
const { onTextValueChange: a, textValue: m, ...C } = Y(Ie), v = se(), [g, u] = s.useState(n ?? ""), f = C.value === e, { startsWith: h, contains: b } = De(C.locale, { sensitivity: "base" }), x = s.useCallback((p) => {
|
|
603
|
+
u((y) => y || ((p == null ? void 0 : p.textContent) ?? "").trim());
|
|
835
604
|
}, []);
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
),
|
|
864
|
-
fragment
|
|
865
|
-
) : null;
|
|
866
|
-
}
|
|
867
|
-
return /* @__PURE__ */ jsx(
|
|
868
|
-
ComboboxItemProvider,
|
|
605
|
+
return s.useEffect(() => {
|
|
606
|
+
f && m === void 0 && g !== "" && a(g);
|
|
607
|
+
}, [g, f, m, a]), C.autocomplete.type === "both" && g && C.filterValue && !h(g, C.filterValue) || C.autocomplete.type === "list" && C.autocomplete.filter === "startsWith" && g && m && !h(g, m) || C.autocomplete.type === "list" && C.autocomplete.filter === "contains" && g && m && !b(g, m) ? c ? we.createPortal(
|
|
608
|
+
/* @__PURE__ */ d(
|
|
609
|
+
lt,
|
|
610
|
+
{
|
|
611
|
+
textId: v,
|
|
612
|
+
onTextValueChange: x,
|
|
613
|
+
isSelected: f,
|
|
614
|
+
textValue: g,
|
|
615
|
+
children: /* @__PURE__ */ d(
|
|
616
|
+
re.ItemSlot,
|
|
617
|
+
{
|
|
618
|
+
scope: void 0,
|
|
619
|
+
value: e,
|
|
620
|
+
textValue: g,
|
|
621
|
+
disabled: t,
|
|
622
|
+
type: "option",
|
|
623
|
+
isVisible: !1,
|
|
624
|
+
children: /* @__PURE__ */ d(Ne, { ref: i, value: e, disabled: t, ...r })
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
}
|
|
628
|
+
),
|
|
629
|
+
c
|
|
630
|
+
) : null : /* @__PURE__ */ d(
|
|
631
|
+
lt,
|
|
869
632
|
{
|
|
870
|
-
textId,
|
|
871
|
-
onTextValueChange:
|
|
872
|
-
isSelected,
|
|
873
|
-
textValue,
|
|
874
|
-
children: /* @__PURE__ */
|
|
875
|
-
|
|
633
|
+
textId: v,
|
|
634
|
+
onTextValueChange: x,
|
|
635
|
+
isSelected: f,
|
|
636
|
+
textValue: g,
|
|
637
|
+
children: /* @__PURE__ */ d(
|
|
638
|
+
re.ItemSlot,
|
|
876
639
|
{
|
|
877
640
|
scope: void 0,
|
|
878
|
-
value,
|
|
879
|
-
textValue,
|
|
880
|
-
disabled,
|
|
641
|
+
value: e,
|
|
642
|
+
textValue: g,
|
|
643
|
+
disabled: t,
|
|
881
644
|
type: "option",
|
|
882
|
-
isVisible:
|
|
883
|
-
children: /* @__PURE__ */
|
|
645
|
+
isVisible: !0,
|
|
646
|
+
children: /* @__PURE__ */ d(Ne, { ref: i, value: e, disabled: t, ...r })
|
|
884
647
|
}
|
|
885
648
|
)
|
|
886
649
|
}
|
|
887
650
|
);
|
|
888
651
|
});
|
|
889
|
-
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
context.onValueChange(value);
|
|
901
|
-
onTextValueChange(textValue);
|
|
902
|
-
context.onOpenChange(false);
|
|
903
|
-
if (context.autocomplete.type === "both") {
|
|
904
|
-
context.onFilterValueChange(textValue);
|
|
905
|
-
}
|
|
906
|
-
context.trigger?.focus({ preventScroll: true });
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
const isFocused = React.useMemo(() => {
|
|
910
|
-
return visuallyFocussedItem === getItems().find((item) => item.ref.current === itemRef.current)?.ref.current;
|
|
911
|
-
}, [getItems, visuallyFocussedItem]);
|
|
912
|
-
const id = useId();
|
|
913
|
-
return /* @__PURE__ */ jsx(
|
|
914
|
-
Primitive.div,
|
|
652
|
+
Le.displayName = Ie;
|
|
653
|
+
const Et = "ComboboxItemImpl", Ne = s.forwardRef((o, i) => {
|
|
654
|
+
const { value: e, disabled: t = !1, ...n } = o, r = s.useRef(null), c = A(i, r), { getItems: l } = xe(void 0), { onTextValueChange: a, visuallyFocussedItem: m, ...C } = Y(Ie), { isSelected: v, textValue: g, textId: u } = Fe(Et), f = () => {
|
|
655
|
+
var x;
|
|
656
|
+
t || (C.onValueChange(e), a(g), C.onOpenChange(!1), C.autocomplete.type === "both" && C.onFilterValueChange(g), (x = C.trigger) == null || x.focus({ preventScroll: !0 }));
|
|
657
|
+
}, h = s.useMemo(() => {
|
|
658
|
+
var x;
|
|
659
|
+
return m === ((x = l().find((p) => p.ref.current === r.current)) == null ? void 0 : x.ref.current);
|
|
660
|
+
}, [l, m]), b = se();
|
|
661
|
+
return /* @__PURE__ */ d(
|
|
662
|
+
N.div,
|
|
915
663
|
{
|
|
916
664
|
role: "option",
|
|
917
|
-
"aria-labelledby":
|
|
918
|
-
"data-highlighted":
|
|
919
|
-
"aria-selected":
|
|
920
|
-
"data-state":
|
|
921
|
-
"aria-disabled":
|
|
922
|
-
"data-disabled":
|
|
923
|
-
tabIndex:
|
|
924
|
-
...
|
|
925
|
-
id,
|
|
926
|
-
ref:
|
|
927
|
-
onPointerUp:
|
|
665
|
+
"aria-labelledby": u,
|
|
666
|
+
"data-highlighted": h ? "" : void 0,
|
|
667
|
+
"aria-selected": v && h,
|
|
668
|
+
"data-state": v ? "checked" : "unchecked",
|
|
669
|
+
"aria-disabled": t || void 0,
|
|
670
|
+
"data-disabled": t ? "" : void 0,
|
|
671
|
+
tabIndex: t ? void 0 : -1,
|
|
672
|
+
...n,
|
|
673
|
+
id: b,
|
|
674
|
+
ref: c,
|
|
675
|
+
onPointerUp: P(n.onPointerUp, f)
|
|
928
676
|
}
|
|
929
677
|
);
|
|
930
678
|
});
|
|
931
|
-
|
|
932
|
-
const
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
const itemContext = useComboboxItemContext(ITEM_TEXT_NAME$1);
|
|
936
|
-
const composedRefs = useComposedRefs(forwardedRef, itemContext.onTextValueChange);
|
|
937
|
-
return /* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs });
|
|
679
|
+
Ne.displayName = Et;
|
|
680
|
+
const Nt = "ComboboxItemText", Rt = s.forwardRef((o, i) => {
|
|
681
|
+
const { className: e, style: t, ...n } = o, r = Fe(Nt), c = A(i, r.onTextValueChange);
|
|
682
|
+
return /* @__PURE__ */ d(N.span, { id: r.textId, ...n, ref: c });
|
|
938
683
|
});
|
|
939
|
-
|
|
940
|
-
const
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
return isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...props, ref: forwardedRef }) : null;
|
|
684
|
+
Rt.displayName = Nt;
|
|
685
|
+
const At = "ComboboxItemIndicator", _t = s.forwardRef((o, i) => {
|
|
686
|
+
const { isSelected: e } = Fe(At);
|
|
687
|
+
return e ? /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...o, ref: i }) : null;
|
|
944
688
|
});
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
const ComboboxNoValueFound = React.forwardRef((props, ref) => {
|
|
689
|
+
_t.displayName = At;
|
|
690
|
+
const Be = "ComboboxNoValueFound", Mt = s.forwardRef((o, i) => {
|
|
948
691
|
const {
|
|
949
|
-
textValue = "",
|
|
950
|
-
filterValue = "",
|
|
951
|
-
visible =
|
|
952
|
-
locale,
|
|
953
|
-
autocomplete
|
|
954
|
-
} =
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
setItems(filteredItems);
|
|
963
|
-
} else {
|
|
964
|
-
setItems(state);
|
|
965
|
-
}
|
|
692
|
+
textValue: e = "",
|
|
693
|
+
filterValue: t = "",
|
|
694
|
+
visible: n = !1,
|
|
695
|
+
locale: r,
|
|
696
|
+
autocomplete: c
|
|
697
|
+
} = Y(Be), [l, a] = s.useState([]), { subscribe: m } = xe(void 0), { startsWith: C, contains: v } = De(r, { sensitivity: "base" });
|
|
698
|
+
return s.useEffect(() => {
|
|
699
|
+
const g = m((u) => {
|
|
700
|
+
if (n) {
|
|
701
|
+
const f = u.filter((h) => h.type !== "create");
|
|
702
|
+
a(f);
|
|
703
|
+
} else
|
|
704
|
+
a(u);
|
|
966
705
|
});
|
|
967
706
|
return () => {
|
|
968
|
-
|
|
707
|
+
g();
|
|
969
708
|
};
|
|
970
|
-
}, [
|
|
971
|
-
if (autocomplete.type === "none" && items.length > 0)
|
|
972
|
-
return null;
|
|
973
|
-
if (autocomplete.type === "list" && autocomplete.filter === "startsWith" && items.some((item) => startsWith(item.textValue, textValue))) {
|
|
974
|
-
return null;
|
|
975
|
-
}
|
|
976
|
-
if (autocomplete.type === "both" && items.some((item) => startsWith(item.textValue, filterValue))) {
|
|
977
|
-
return null;
|
|
978
|
-
}
|
|
979
|
-
if (autocomplete.type === "list" && autocomplete.filter === "contains" && items.some((item) => contains(item.textValue, textValue))) {
|
|
980
|
-
return null;
|
|
981
|
-
}
|
|
982
|
-
return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref });
|
|
709
|
+
}, [n, m]), c.type === "none" && l.length > 0 || c.type === "list" && c.filter === "startsWith" && l.some((g) => C(g.textValue, e)) || c.type === "both" && l.some((g) => C(g.textValue, t)) || c.type === "list" && c.filter === "contains" && l.some((g) => v(g.textValue, e)) ? null : /* @__PURE__ */ d(N.div, { ...o, ref: i });
|
|
983
710
|
});
|
|
984
|
-
|
|
985
|
-
const
|
|
986
|
-
const { disabled =
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
const composedRefs = useComposedRefs(ref, itemRef);
|
|
993
|
-
const isFocused = React.useMemo(() => {
|
|
994
|
-
return visuallyFocussedItem === getItems().find((item) => item.ref.current === itemRef.current)?.ref.current;
|
|
995
|
-
}, [getItems, visuallyFocussedItem]);
|
|
996
|
-
const id = useId();
|
|
997
|
-
const handleSelect = () => {
|
|
998
|
-
if (!disabled && textValue) {
|
|
999
|
-
context.onValueChange(textValue);
|
|
1000
|
-
context.onTextValueChange(textValue);
|
|
1001
|
-
context.onOpenChange(false);
|
|
1002
|
-
if (context.autocomplete.type === "both") {
|
|
1003
|
-
context.onFilterValueChange(textValue);
|
|
1004
|
-
}
|
|
1005
|
-
context.trigger?.focus({ preventScroll: true });
|
|
1006
|
-
}
|
|
711
|
+
Mt.displayName = Be;
|
|
712
|
+
const Ot = s.forwardRef((o, i) => {
|
|
713
|
+
const { disabled: e = !1, ...t } = o, n = Y(Be), { textValue: r, visuallyFocussedItem: c } = n, { getItems: l, subscribe: a } = xe(void 0), m = s.useRef(null), [C, v] = s.useState(!1), g = A(i, m), u = s.useMemo(() => {
|
|
714
|
+
var b;
|
|
715
|
+
return c === ((b = l().find((x) => x.ref.current === m.current)) == null ? void 0 : b.ref.current);
|
|
716
|
+
}, [l, c]), f = se(), h = () => {
|
|
717
|
+
var b;
|
|
718
|
+
!e && r && (n.onValueChange(r), n.onTextValueChange(r), n.onOpenChange(!1), n.autocomplete.type === "both" && n.onFilterValueChange(r), (b = n.trigger) == null || b.focus({ preventScroll: !0 }));
|
|
1007
719
|
};
|
|
1008
|
-
|
|
1009
|
-
const
|
|
1010
|
-
|
|
720
|
+
return $(() => {
|
|
721
|
+
const b = a((x) => {
|
|
722
|
+
v(!x.some((p) => p.textValue === r && p.type !== "create"));
|
|
1011
723
|
});
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
return () => {
|
|
1016
|
-
unsub();
|
|
724
|
+
return l().length === 0 && v(!0), () => {
|
|
725
|
+
b();
|
|
1017
726
|
};
|
|
1018
|
-
}, [
|
|
1019
|
-
|
|
1020
|
-
return null;
|
|
1021
|
-
}
|
|
1022
|
-
return /* @__PURE__ */ jsx(
|
|
1023
|
-
Collection$1.ItemSlot,
|
|
727
|
+
}, [r, a, l]), (!r || !C) && !n.visible ? null : /* @__PURE__ */ d(
|
|
728
|
+
re.ItemSlot,
|
|
1024
729
|
{
|
|
1025
730
|
scope: void 0,
|
|
1026
|
-
value:
|
|
1027
|
-
textValue:
|
|
1028
|
-
disabled,
|
|
1029
|
-
isVisible:
|
|
731
|
+
value: r ?? "",
|
|
732
|
+
textValue: r ?? "",
|
|
733
|
+
disabled: e,
|
|
734
|
+
isVisible: !0,
|
|
1030
735
|
type: "create",
|
|
1031
|
-
children: /* @__PURE__ */
|
|
1032
|
-
|
|
736
|
+
children: /* @__PURE__ */ d(
|
|
737
|
+
N.div,
|
|
1033
738
|
{
|
|
1034
739
|
role: "option",
|
|
1035
|
-
tabIndex:
|
|
1036
|
-
"aria-disabled":
|
|
1037
|
-
"data-disabled":
|
|
1038
|
-
"data-highlighted":
|
|
1039
|
-
...
|
|
1040
|
-
id,
|
|
1041
|
-
ref:
|
|
1042
|
-
onPointerUp:
|
|
740
|
+
tabIndex: e ? void 0 : -1,
|
|
741
|
+
"aria-disabled": e || void 0,
|
|
742
|
+
"data-disabled": e ? "" : void 0,
|
|
743
|
+
"data-highlighted": u ? "" : void 0,
|
|
744
|
+
...t,
|
|
745
|
+
id: f,
|
|
746
|
+
ref: g,
|
|
747
|
+
onPointerUp: P(t.onPointerUp, h)
|
|
1043
748
|
}
|
|
1044
749
|
)
|
|
1045
750
|
}
|
|
1046
751
|
);
|
|
1047
752
|
});
|
|
1048
|
-
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
const Item$1 = ComboboxItem;
|
|
1057
|
-
const ItemText$1 = ComboboxItemText;
|
|
1058
|
-
const ItemIndicator$1 = ComboboxItemIndicator;
|
|
1059
|
-
const NoValueFound = ComboboxNoValueFound;
|
|
1060
|
-
const CreateItem = ComboboxCreateItem;
|
|
1061
|
-
function findChangedIndex(a, b) {
|
|
1062
|
-
const length = Math.min(a.length, b.length);
|
|
1063
|
-
for (let i = 0; i < length; i++) {
|
|
1064
|
-
if (a[i] !== b[i]) {
|
|
1065
|
-
return i;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
return length;
|
|
753
|
+
Ot.displayName = "ComboboxCreateItem";
|
|
754
|
+
const uo = io, po = Ct, fo = bt, mo = yt, ho = St, go = wt, xo = Pt, Co = Le, vo = Rt, bo = _t, yo = Mt, So = Ot;
|
|
755
|
+
function wo(o, i) {
|
|
756
|
+
const e = Math.min(o.length, i.length);
|
|
757
|
+
for (let t = 0; t < e; t++)
|
|
758
|
+
if (o[t] !== i[t])
|
|
759
|
+
return t;
|
|
760
|
+
return e;
|
|
1069
761
|
}
|
|
1070
|
-
const
|
|
762
|
+
const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1071
763
|
__proto__: null,
|
|
1072
|
-
ComboboxItem,
|
|
1073
|
-
Content:
|
|
1074
|
-
CreateItem,
|
|
1075
|
-
Icon:
|
|
1076
|
-
Item:
|
|
1077
|
-
ItemIndicator:
|
|
1078
|
-
ItemText:
|
|
1079
|
-
NoValueFound,
|
|
1080
|
-
Portal:
|
|
1081
|
-
Root:
|
|
1082
|
-
TextInput,
|
|
1083
|
-
Trigger:
|
|
1084
|
-
Viewport:
|
|
764
|
+
ComboboxItem: Le,
|
|
765
|
+
Content: go,
|
|
766
|
+
CreateItem: So,
|
|
767
|
+
Icon: mo,
|
|
768
|
+
Item: Co,
|
|
769
|
+
ItemIndicator: bo,
|
|
770
|
+
ItemText: vo,
|
|
771
|
+
NoValueFound: yo,
|
|
772
|
+
Portal: ho,
|
|
773
|
+
Root: uo,
|
|
774
|
+
TextInput: fo,
|
|
775
|
+
Trigger: po,
|
|
776
|
+
Viewport: xo
|
|
1085
777
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1086
|
-
function
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
})
|
|
1091
|
-
|
|
778
|
+
function Io(o) {
|
|
779
|
+
const i = s.useRef(o);
|
|
780
|
+
return s.useEffect(() => {
|
|
781
|
+
i.current = o;
|
|
782
|
+
}), s.useMemo(() => (...e) => {
|
|
783
|
+
var t;
|
|
784
|
+
return (t = i.current) == null ? void 0 : t.call(i, ...e);
|
|
785
|
+
}, []);
|
|
1092
786
|
}
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
|
|
1098
|
-
createCollectionScope,
|
|
1099
|
-
createPopperScope
|
|
1100
|
-
]);
|
|
1101
|
-
const usePopperScope = createPopperScope();
|
|
1102
|
-
const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
1103
|
-
const [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
|
1104
|
-
const Select = (props) => {
|
|
787
|
+
const To = [" ", "Enter", "ArrowUp", "ArrowDown"], Vo = [" ", "Enter"], Ce = "Select", [Te, ve, Po] = Yt(Ce), [pe, Eo] = st(Ce, [
|
|
788
|
+
Po,
|
|
789
|
+
dt
|
|
790
|
+
]), Ve = dt(), [No, X] = pe(Ce), [Ro, Ao] = pe(Ce), $e = (o) => {
|
|
1105
791
|
const {
|
|
1106
|
-
__scopeSelect,
|
|
1107
|
-
children,
|
|
1108
|
-
open:
|
|
1109
|
-
defaultOpen,
|
|
1110
|
-
onOpenChange,
|
|
1111
|
-
value:
|
|
1112
|
-
defaultValue,
|
|
1113
|
-
onValueChange,
|
|
1114
|
-
dir,
|
|
792
|
+
__scopeSelect: i,
|
|
793
|
+
children: e,
|
|
794
|
+
open: t,
|
|
795
|
+
defaultOpen: n,
|
|
796
|
+
onOpenChange: r,
|
|
797
|
+
value: c,
|
|
798
|
+
defaultValue: l,
|
|
799
|
+
onValueChange: a,
|
|
800
|
+
dir: m,
|
|
1115
801
|
// name,
|
|
1116
802
|
// autoComplete,
|
|
1117
|
-
disabled,
|
|
1118
|
-
required,
|
|
1119
|
-
multi =
|
|
1120
|
-
} =
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
onChange: onOpenChange
|
|
1130
|
-
});
|
|
1131
|
-
const [value, setValue] = useControllableState({
|
|
1132
|
-
prop: valueProp,
|
|
1133
|
-
defaultProp: defaultValue,
|
|
1134
|
-
onChange(value2) {
|
|
1135
|
-
if (onValueChange) {
|
|
1136
|
-
if (Array.isArray(value2)) {
|
|
1137
|
-
onValueChange(value2);
|
|
1138
|
-
} else {
|
|
1139
|
-
onValueChange(value2);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
803
|
+
disabled: C,
|
|
804
|
+
required: v,
|
|
805
|
+
multi: g = !1
|
|
806
|
+
} = o, u = Ve(i), [f, h] = s.useState(null), [b, x] = s.useState(null), [p, y] = s.useState(!1), E = qt(m), [O = !1, F] = de({
|
|
807
|
+
prop: t,
|
|
808
|
+
defaultProp: n,
|
|
809
|
+
onChange: r
|
|
810
|
+
}), [_, k] = de({
|
|
811
|
+
prop: c,
|
|
812
|
+
defaultProp: l,
|
|
813
|
+
onChange(R) {
|
|
814
|
+
a && (Array.isArray(R), a(R));
|
|
1142
815
|
}
|
|
1143
|
-
});
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(
|
|
1147
|
-
SelectProvider,
|
|
816
|
+
}), Z = s.useRef(null), [U, z] = s.useState(/* @__PURE__ */ new Set());
|
|
817
|
+
return /* @__PURE__ */ d(ie.Root, { ...u, children: /* @__PURE__ */ d(
|
|
818
|
+
No,
|
|
1148
819
|
{
|
|
1149
|
-
required,
|
|
1150
|
-
scope:
|
|
1151
|
-
trigger,
|
|
1152
|
-
onTriggerChange:
|
|
1153
|
-
valueNode,
|
|
1154
|
-
onValueNodeChange:
|
|
1155
|
-
valueNodeHasChildren,
|
|
1156
|
-
onValueNodeHasChildrenChange:
|
|
1157
|
-
contentId:
|
|
1158
|
-
value,
|
|
1159
|
-
onValueChange:
|
|
1160
|
-
open,
|
|
1161
|
-
onOpenChange:
|
|
1162
|
-
dir:
|
|
1163
|
-
triggerPointerDownPosRef,
|
|
1164
|
-
disabled,
|
|
1165
|
-
multi,
|
|
1166
|
-
children: /* @__PURE__ */
|
|
1167
|
-
|
|
820
|
+
required: v,
|
|
821
|
+
scope: i,
|
|
822
|
+
trigger: f,
|
|
823
|
+
onTriggerChange: h,
|
|
824
|
+
valueNode: b,
|
|
825
|
+
onValueNodeChange: x,
|
|
826
|
+
valueNodeHasChildren: p,
|
|
827
|
+
onValueNodeHasChildrenChange: y,
|
|
828
|
+
contentId: se(),
|
|
829
|
+
value: _,
|
|
830
|
+
onValueChange: k,
|
|
831
|
+
open: O,
|
|
832
|
+
onOpenChange: F,
|
|
833
|
+
dir: E,
|
|
834
|
+
triggerPointerDownPosRef: Z,
|
|
835
|
+
disabled: C,
|
|
836
|
+
multi: g,
|
|
837
|
+
children: /* @__PURE__ */ d(Te.Provider, { scope: i, children: /* @__PURE__ */ d(
|
|
838
|
+
Ro,
|
|
1168
839
|
{
|
|
1169
|
-
scope:
|
|
1170
|
-
onNativeOptionAdd:
|
|
1171
|
-
|
|
840
|
+
scope: o.__scopeSelect,
|
|
841
|
+
onNativeOptionAdd: s.useCallback((R) => {
|
|
842
|
+
z((H) => new Set(H).add(R));
|
|
1172
843
|
}, []),
|
|
1173
|
-
onNativeOptionRemove:
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
return optionsSet;
|
|
844
|
+
onNativeOptionRemove: s.useCallback((R) => {
|
|
845
|
+
z((H) => {
|
|
846
|
+
const L = new Set(H);
|
|
847
|
+
return L.delete(R), L;
|
|
1178
848
|
});
|
|
1179
849
|
}, []),
|
|
1180
|
-
children
|
|
850
|
+
children: e
|
|
1181
851
|
}
|
|
1182
852
|
) })
|
|
1183
853
|
}
|
|
1184
854
|
) });
|
|
1185
855
|
};
|
|
1186
|
-
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
1195
|
-
const getItems = useCollection(__scopeSelect);
|
|
1196
|
-
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
|
|
1197
|
-
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
1198
|
-
const currentItem = enabledItems.find((item) => item.value === context.value);
|
|
1199
|
-
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
1200
|
-
if (nextItem !== void 0 && !Array.isArray(nextItem.value)) {
|
|
1201
|
-
const newValue = context.multi ? [nextItem.value] : nextItem.value;
|
|
1202
|
-
context.onValueChange(newValue);
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
|
-
const handleOpen = () => {
|
|
1206
|
-
if (!isDisabled) {
|
|
1207
|
-
context.onOpenChange(true);
|
|
1208
|
-
resetTypeahead();
|
|
856
|
+
$e.displayName = Ce;
|
|
857
|
+
const Dt = "SelectTrigger", Ue = s.forwardRef(
|
|
858
|
+
(o, i) => {
|
|
859
|
+
const { __scopeSelect: e, ...t } = o, n = Ve(e), r = X(Dt, e), c = r.disabled, l = A(i, r.onTriggerChange), a = ve(e), [m, C, v] = zt((u) => {
|
|
860
|
+
const f = a().filter((x) => !x.disabled), h = f.find((x) => x.value === r.value), b = Kt(f, u, h);
|
|
861
|
+
if (b !== void 0 && !Array.isArray(b.value)) {
|
|
862
|
+
const x = r.multi ? [b.value] : b.value;
|
|
863
|
+
r.onValueChange(x);
|
|
1209
864
|
}
|
|
865
|
+
}), g = () => {
|
|
866
|
+
c || (r.onOpenChange(!0), v());
|
|
1210
867
|
};
|
|
1211
|
-
return /* @__PURE__ */
|
|
1212
|
-
|
|
868
|
+
return /* @__PURE__ */ d(ie.Anchor, { asChild: !0, ...n, children: /* @__PURE__ */ d(
|
|
869
|
+
N.div,
|
|
1213
870
|
{
|
|
1214
871
|
role: "combobox",
|
|
1215
|
-
"aria-controls":
|
|
1216
|
-
"aria-expanded":
|
|
1217
|
-
"aria-required":
|
|
872
|
+
"aria-controls": r.contentId,
|
|
873
|
+
"aria-expanded": r.open,
|
|
874
|
+
"aria-required": r.required,
|
|
1218
875
|
"aria-autocomplete": "none",
|
|
1219
|
-
dir:
|
|
1220
|
-
"data-state":
|
|
1221
|
-
"data-disabled":
|
|
1222
|
-
"data-placeholder":
|
|
1223
|
-
tabIndex:
|
|
1224
|
-
...
|
|
1225
|
-
ref:
|
|
1226
|
-
onClick:
|
|
1227
|
-
|
|
876
|
+
dir: r.dir,
|
|
877
|
+
"data-state": r.open ? "open" : "closed",
|
|
878
|
+
"data-disabled": c ? "" : void 0,
|
|
879
|
+
"data-placeholder": r.value === void 0 ? "" : void 0,
|
|
880
|
+
tabIndex: c ? void 0 : 0,
|
|
881
|
+
...t,
|
|
882
|
+
ref: l,
|
|
883
|
+
onClick: P(t.onClick, (u) => {
|
|
884
|
+
u.currentTarget.focus();
|
|
1228
885
|
}),
|
|
1229
|
-
onPointerDown:
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
if (buttonTarg !== event.currentTarget) {
|
|
1236
|
-
return;
|
|
1237
|
-
}
|
|
1238
|
-
if (event.button === 0 && event.ctrlKey === false) {
|
|
1239
|
-
handleOpen();
|
|
1240
|
-
context.triggerPointerDownPosRef.current = {
|
|
1241
|
-
x: Math.round(event.pageX),
|
|
1242
|
-
y: Math.round(event.pageY)
|
|
1243
|
-
};
|
|
1244
|
-
event.preventDefault();
|
|
1245
|
-
}
|
|
886
|
+
onPointerDown: P(t.onPointerDown, (u) => {
|
|
887
|
+
const f = u.target;
|
|
888
|
+
f.hasPointerCapture(u.pointerId) && f.releasePointerCapture(u.pointerId), (f.closest("button") ?? f.closest("div")) === u.currentTarget && u.button === 0 && u.ctrlKey === !1 && (g(), r.triggerPointerDownPosRef.current = {
|
|
889
|
+
x: Math.round(u.pageX),
|
|
890
|
+
y: Math.round(u.pageY)
|
|
891
|
+
}, u.preventDefault());
|
|
1246
892
|
}),
|
|
1247
|
-
onKeyDown:
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
const target = event.target;
|
|
1251
|
-
const buttonTarg = target.closest("button") ?? target.closest("div");
|
|
1252
|
-
if (buttonTarg !== event.currentTarget) {
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
if (!isModifierKey && event.key.length === 1)
|
|
1256
|
-
handleTypeaheadSearch(event.key);
|
|
1257
|
-
if (isTypingAhead && event.key === " ")
|
|
1258
|
-
return;
|
|
1259
|
-
if (OPEN_KEYS.includes(event.key)) {
|
|
1260
|
-
handleOpen();
|
|
1261
|
-
event.preventDefault();
|
|
1262
|
-
}
|
|
893
|
+
onKeyDown: P(t.onKeyDown, (u) => {
|
|
894
|
+
const f = m.current !== "", h = u.ctrlKey || u.altKey || u.metaKey, b = u.target;
|
|
895
|
+
(b.closest("button") ?? b.closest("div")) === u.currentTarget && (!h && u.key.length === 1 && C(u.key), !(f && u.key === " ") && To.includes(u.key) && (g(), u.preventDefault()));
|
|
1263
896
|
})
|
|
1264
897
|
}
|
|
1265
898
|
) });
|
|
1266
899
|
}
|
|
1267
900
|
);
|
|
1268
|
-
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
React.useLayoutEffect(() => {
|
|
1283
|
-
if (Array.isArray(context.value) && valuedItems.length !== context.value.length) {
|
|
1284
|
-
const timeout = setTimeout(() => {
|
|
1285
|
-
const valuedItems2 = getItems().filter(
|
|
1286
|
-
(item) => !Array.isArray(item.value) ? context.value?.includes(item.value) : false
|
|
901
|
+
Ue.displayName = Dt;
|
|
902
|
+
const kt = "SelectValue", He = s.forwardRef(
|
|
903
|
+
(o, i) => {
|
|
904
|
+
const { __scopeSelect: e, children: t, placeholder: n, ...r } = o, c = X(kt, e), { onValueNodeHasChildrenChange: l } = c, a = t !== void 0, m = A(i, c.onValueNodeChange), [C, v] = s.useState([]), g = ve(e);
|
|
905
|
+
$(() => {
|
|
906
|
+
l(a);
|
|
907
|
+
}, [l, a]), s.useLayoutEffect(() => {
|
|
908
|
+
if (Array.isArray(c.value) && C.length !== c.value.length) {
|
|
909
|
+
const f = setTimeout(() => {
|
|
910
|
+
const h = g().filter(
|
|
911
|
+
(b) => {
|
|
912
|
+
var x;
|
|
913
|
+
return Array.isArray(b.value) ? !1 : (x = c.value) == null ? void 0 : x.includes(b.value);
|
|
914
|
+
}
|
|
1287
915
|
);
|
|
1288
|
-
|
|
916
|
+
v(h);
|
|
1289
917
|
});
|
|
1290
918
|
return () => {
|
|
1291
|
-
clearTimeout(
|
|
919
|
+
clearTimeout(f);
|
|
1292
920
|
};
|
|
1293
921
|
}
|
|
1294
|
-
}, [
|
|
1295
|
-
let
|
|
1296
|
-
if ((
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
if (Array.isArray(
|
|
1300
|
-
const
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
return null;
|
|
1304
|
-
}
|
|
1305
|
-
return children({ value, textValue: valueItem?.textValue });
|
|
922
|
+
}, [c.value, g, C]);
|
|
923
|
+
let u;
|
|
924
|
+
if ((c.value === void 0 || c.value.length === 0) && n !== void 0)
|
|
925
|
+
u = /* @__PURE__ */ d("span", { children: n });
|
|
926
|
+
else if (typeof t == "function")
|
|
927
|
+
if (Array.isArray(c.value)) {
|
|
928
|
+
const f = c.value.map((h) => {
|
|
929
|
+
const b = C.find((x) => x.value === h);
|
|
930
|
+
return b ? t({ value: h, textValue: b == null ? void 0 : b.textValue }) : null;
|
|
1306
931
|
});
|
|
1307
|
-
|
|
1308
|
-
} else
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
}
|
|
1314
|
-
return /* @__PURE__ */ jsx(Primitive.span, { ...valueProps, ref: composedRefs, children: renderValue || null });
|
|
932
|
+
u = f.every((h) => h === null) ? n : f;
|
|
933
|
+
} else
|
|
934
|
+
u = t(c.value);
|
|
935
|
+
else
|
|
936
|
+
u = t;
|
|
937
|
+
return /* @__PURE__ */ d(N.span, { ...r, ref: m, children: u || null });
|
|
1315
938
|
}
|
|
1316
939
|
);
|
|
1317
|
-
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "▼" });
|
|
940
|
+
He.displayName = kt;
|
|
941
|
+
const _o = "SelectIcon", We = s.forwardRef(
|
|
942
|
+
(o, i) => {
|
|
943
|
+
const { __scopeSelect: e, children: t, ...n } = o;
|
|
944
|
+
return /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...n, ref: i, children: t || "▼" });
|
|
1323
945
|
}
|
|
1324
946
|
);
|
|
1325
|
-
|
|
1326
|
-
const
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}, []);
|
|
1339
|
-
if (!context.open) {
|
|
1340
|
-
const frag = fragment;
|
|
1341
|
-
return frag ? ReactDOM.createPortal(
|
|
1342
|
-
/* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
|
|
1343
|
-
frag
|
|
947
|
+
We.displayName = _o;
|
|
948
|
+
const Mo = "SelectPortal", ze = (o) => /* @__PURE__ */ d(pt, { asChild: !0, ...o });
|
|
949
|
+
ze.displayName = Mo;
|
|
950
|
+
const le = "SelectContent", Ke = s.forwardRef(
|
|
951
|
+
(o, i) => {
|
|
952
|
+
const e = X(le, o.__scopeSelect), [t, n] = s.useState();
|
|
953
|
+
if ($(() => {
|
|
954
|
+
n(new DocumentFragment());
|
|
955
|
+
}, []), !e.open) {
|
|
956
|
+
const r = t;
|
|
957
|
+
return r ? we.createPortal(
|
|
958
|
+
/* @__PURE__ */ d(Ft, { scope: o.__scopeSelect, children: /* @__PURE__ */ d(Te.Slot, { scope: o.__scopeSelect, children: /* @__PURE__ */ d("div", { children: o.children }) }) }),
|
|
959
|
+
r
|
|
1344
960
|
) : null;
|
|
1345
961
|
}
|
|
1346
|
-
return /* @__PURE__ */
|
|
962
|
+
return /* @__PURE__ */ d(Lt, { ...o, ref: i });
|
|
1347
963
|
}
|
|
1348
964
|
);
|
|
1349
|
-
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1352
|
-
const CONTENT_IMPL_NAME = "SelectContentImpl";
|
|
1353
|
-
const SelectContentImpl = React.forwardRef(
|
|
1354
|
-
(props, forwardedRef) => {
|
|
965
|
+
Ke.displayName = le;
|
|
966
|
+
const q = 10, [Ft, oe] = pe(le), Oo = "SelectContentImpl", Lt = s.forwardRef(
|
|
967
|
+
(o, i) => {
|
|
1355
968
|
const {
|
|
1356
|
-
__scopeSelect,
|
|
1357
|
-
position = "item-aligned",
|
|
1358
|
-
onCloseAutoFocus,
|
|
1359
|
-
onEscapeKeyDown,
|
|
1360
|
-
onPointerDownOutside,
|
|
969
|
+
__scopeSelect: e,
|
|
970
|
+
position: t = "item-aligned",
|
|
971
|
+
onCloseAutoFocus: n,
|
|
972
|
+
onEscapeKeyDown: r,
|
|
973
|
+
onPointerDownOutside: c,
|
|
1361
974
|
//
|
|
1362
975
|
// PopperContent props
|
|
1363
|
-
side,
|
|
1364
|
-
sideOffset,
|
|
1365
|
-
align,
|
|
1366
|
-
alignOffset,
|
|
1367
|
-
arrowPadding,
|
|
1368
|
-
collisionBoundary,
|
|
1369
|
-
collisionPadding,
|
|
1370
|
-
sticky,
|
|
1371
|
-
hideWhenDetached,
|
|
1372
|
-
avoidCollisions,
|
|
976
|
+
side: l,
|
|
977
|
+
sideOffset: a,
|
|
978
|
+
align: m,
|
|
979
|
+
alignOffset: C,
|
|
980
|
+
arrowPadding: v,
|
|
981
|
+
collisionBoundary: g,
|
|
982
|
+
collisionPadding: u,
|
|
983
|
+
sticky: f,
|
|
984
|
+
hideWhenDetached: h,
|
|
985
|
+
avoidCollisions: b,
|
|
1373
986
|
//
|
|
1374
|
-
...
|
|
1375
|
-
} =
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
const firstValidItemFoundRef = React.useRef(false);
|
|
1385
|
-
React.useEffect(() => {
|
|
1386
|
-
if (content)
|
|
1387
|
-
return hideOthers(content);
|
|
1388
|
-
}, [content]);
|
|
1389
|
-
useFocusGuards();
|
|
1390
|
-
const focusFirst = React.useCallback(
|
|
1391
|
-
(candidates) => {
|
|
1392
|
-
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
|
1393
|
-
const [lastItem] = restItems.slice(-1);
|
|
1394
|
-
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
1395
|
-
for (const candidate of candidates) {
|
|
1396
|
-
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
|
|
1397
|
-
return;
|
|
1398
|
-
candidate?.scrollIntoView({ block: "nearest" });
|
|
1399
|
-
if (candidate === firstItem && viewport)
|
|
1400
|
-
viewport.scrollTop = 0;
|
|
1401
|
-
if (candidate === lastItem && viewport)
|
|
1402
|
-
viewport.scrollTop = viewport.scrollHeight;
|
|
1403
|
-
candidate?.focus();
|
|
1404
|
-
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT)
|
|
1405
|
-
return;
|
|
1406
|
-
}
|
|
987
|
+
...x
|
|
988
|
+
} = o, p = X(le, e), [y, E] = s.useState(null), [O, F] = s.useState(null), _ = A(i, (S) => E(S)), [k, Z] = s.useState(null), [U, z] = s.useState(null), R = ve(e), [H, L] = s.useState(!1), W = s.useRef(!1);
|
|
989
|
+
s.useEffect(() => {
|
|
990
|
+
if (y) return ft(y);
|
|
991
|
+
}, [y]), at();
|
|
992
|
+
const J = s.useCallback(
|
|
993
|
+
(S) => {
|
|
994
|
+
const [I, ...M] = R().map((w) => w.ref.current), [V] = M.slice(-1), T = document.activeElement;
|
|
995
|
+
for (const w of S)
|
|
996
|
+
if (w === T || (w == null || w.scrollIntoView({ block: "nearest" }), w === I && O && (O.scrollTop = 0), w === V && O && (O.scrollTop = O.scrollHeight), w == null || w.focus(), document.activeElement !== T)) return;
|
|
1407
997
|
},
|
|
1408
|
-
[
|
|
998
|
+
[R, O]
|
|
999
|
+
), Q = s.useCallback(
|
|
1000
|
+
() => J([k, y]),
|
|
1001
|
+
[J, k, y]
|
|
1409
1002
|
);
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
if (
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
let pointerMoveDelta = { x: 0, y: 0 };
|
|
1423
|
-
const handlePointerMove = (event) => {
|
|
1424
|
-
pointerMoveDelta = {
|
|
1425
|
-
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
|
1426
|
-
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
|
1003
|
+
s.useEffect(() => {
|
|
1004
|
+
H && Q();
|
|
1005
|
+
}, [H, Q]);
|
|
1006
|
+
const { onOpenChange: K, triggerPointerDownPosRef: G } = p;
|
|
1007
|
+
s.useEffect(() => {
|
|
1008
|
+
if (y) {
|
|
1009
|
+
let S = { x: 0, y: 0 };
|
|
1010
|
+
const I = (V) => {
|
|
1011
|
+
var T, w;
|
|
1012
|
+
S = {
|
|
1013
|
+
x: Math.abs(Math.round(V.pageX) - (((T = G.current) == null ? void 0 : T.x) ?? 0)),
|
|
1014
|
+
y: Math.abs(Math.round(V.pageY) - (((w = G.current) == null ? void 0 : w.y) ?? 0))
|
|
1427
1015
|
};
|
|
1016
|
+
}, M = (V) => {
|
|
1017
|
+
S.x <= 10 && S.y <= 10 ? V.preventDefault() : y.contains(V.target) || K(!1), document.removeEventListener("pointermove", I), G.current = null;
|
|
1428
1018
|
};
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
event.preventDefault();
|
|
1432
|
-
} else if (!content.contains(event.target)) {
|
|
1433
|
-
onOpenChange(false);
|
|
1434
|
-
}
|
|
1435
|
-
document.removeEventListener("pointermove", handlePointerMove);
|
|
1436
|
-
triggerPointerDownPosRef.current = null;
|
|
1437
|
-
};
|
|
1438
|
-
if (triggerPointerDownPosRef.current !== null) {
|
|
1439
|
-
document.addEventListener("pointermove", handlePointerMove);
|
|
1440
|
-
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
|
1441
|
-
}
|
|
1442
|
-
return () => {
|
|
1443
|
-
document.removeEventListener("pointermove", handlePointerMove);
|
|
1444
|
-
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
|
1019
|
+
return G.current !== null && (document.addEventListener("pointermove", I), document.addEventListener("pointerup", M, { capture: !0, once: !0 })), () => {
|
|
1020
|
+
document.removeEventListener("pointermove", I), document.removeEventListener("pointerup", M, { capture: !0 });
|
|
1445
1021
|
};
|
|
1446
1022
|
}
|
|
1447
|
-
}, [
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
window.addEventListener("resize", close);
|
|
1452
|
-
return () => {
|
|
1453
|
-
window.removeEventListener("blur", close);
|
|
1454
|
-
window.removeEventListener("resize", close);
|
|
1023
|
+
}, [y, K, G]), s.useEffect(() => {
|
|
1024
|
+
const S = () => K(!1);
|
|
1025
|
+
return window.addEventListener("blur", S), window.addEventListener("resize", S), () => {
|
|
1026
|
+
window.removeEventListener("blur", S), window.removeEventListener("resize", S);
|
|
1455
1027
|
};
|
|
1456
|
-
}, [
|
|
1457
|
-
const [
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
});
|
|
1465
|
-
const itemRefCallback = React.useCallback(
|
|
1466
|
-
(node, value, disabled) => {
|
|
1467
|
-
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
1468
|
-
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
1469
|
-
if (isSelectedItem || isFirstValidItem) {
|
|
1470
|
-
setSelectedItem(node);
|
|
1471
|
-
if (isFirstValidItem)
|
|
1472
|
-
firstValidItemFoundRef.current = true;
|
|
1473
|
-
}
|
|
1028
|
+
}, [K]);
|
|
1029
|
+
const [ce, ee] = zt((S) => {
|
|
1030
|
+
const I = R().filter((T) => !T.disabled), M = I.find((T) => T.ref.current === document.activeElement), V = Kt(I, S, M);
|
|
1031
|
+
V && setTimeout(() => V.ref.current.focus());
|
|
1032
|
+
}), fe = s.useCallback(
|
|
1033
|
+
(S, I, M) => {
|
|
1034
|
+
const V = !W.current && !M;
|
|
1035
|
+
(p.value !== void 0 && p.value === I || V) && (Z(S), V && (W.current = !0));
|
|
1474
1036
|
},
|
|
1475
|
-
[
|
|
1476
|
-
)
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
setSelectedItemText(node);
|
|
1484
|
-
}
|
|
1037
|
+
[p.value]
|
|
1038
|
+
), me = s.useCallback(() => y == null ? void 0 : y.focus(), [y]), te = s.useCallback(
|
|
1039
|
+
(S, I, M) => {
|
|
1040
|
+
const V = !W.current && !M;
|
|
1041
|
+
(p.value !== void 0 && (Array.isArray(I) ? I.every((w) => {
|
|
1042
|
+
var B;
|
|
1043
|
+
return (B = p.value) == null ? void 0 : B.includes(w);
|
|
1044
|
+
}) : p.value === I) || V) && z(S);
|
|
1485
1045
|
},
|
|
1486
|
-
[
|
|
1487
|
-
)
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
hideWhenDetached,
|
|
1499
|
-
avoidCollisions
|
|
1046
|
+
[p.value]
|
|
1047
|
+
), ae = t === "popper" ? Re : Bt, ne = ae === Re ? {
|
|
1048
|
+
side: l,
|
|
1049
|
+
sideOffset: a,
|
|
1050
|
+
align: m,
|
|
1051
|
+
alignOffset: C,
|
|
1052
|
+
arrowPadding: v,
|
|
1053
|
+
collisionBoundary: g,
|
|
1054
|
+
collisionPadding: u,
|
|
1055
|
+
sticky: f,
|
|
1056
|
+
hideWhenDetached: h,
|
|
1057
|
+
avoidCollisions: b
|
|
1500
1058
|
} : {};
|
|
1501
|
-
return /* @__PURE__ */
|
|
1502
|
-
|
|
1059
|
+
return /* @__PURE__ */ d(
|
|
1060
|
+
Ft,
|
|
1503
1061
|
{
|
|
1504
|
-
scope:
|
|
1505
|
-
content,
|
|
1506
|
-
viewport,
|
|
1507
|
-
onViewportChange:
|
|
1508
|
-
itemRefCallback,
|
|
1509
|
-
selectedItem,
|
|
1510
|
-
onItemLeave:
|
|
1511
|
-
itemTextRefCallback,
|
|
1512
|
-
focusSelectedItem,
|
|
1513
|
-
selectedItemText,
|
|
1514
|
-
position,
|
|
1515
|
-
isPositioned,
|
|
1516
|
-
searchRef,
|
|
1517
|
-
children: /* @__PURE__ */
|
|
1518
|
-
|
|
1062
|
+
scope: e,
|
|
1063
|
+
content: y,
|
|
1064
|
+
viewport: O,
|
|
1065
|
+
onViewportChange: F,
|
|
1066
|
+
itemRefCallback: fe,
|
|
1067
|
+
selectedItem: k,
|
|
1068
|
+
onItemLeave: me,
|
|
1069
|
+
itemTextRefCallback: te,
|
|
1070
|
+
focusSelectedItem: Q,
|
|
1071
|
+
selectedItemText: U,
|
|
1072
|
+
position: t,
|
|
1073
|
+
isPositioned: H,
|
|
1074
|
+
searchRef: ce,
|
|
1075
|
+
children: /* @__PURE__ */ d(mt, { as: Ee, allowPinchZoom: !0, children: /* @__PURE__ */ d(
|
|
1076
|
+
ut,
|
|
1519
1077
|
{
|
|
1520
|
-
asChild:
|
|
1521
|
-
trapped:
|
|
1522
|
-
onMountAutoFocus: (
|
|
1523
|
-
|
|
1078
|
+
asChild: !0,
|
|
1079
|
+
trapped: p.open,
|
|
1080
|
+
onMountAutoFocus: (S) => {
|
|
1081
|
+
S.preventDefault();
|
|
1524
1082
|
},
|
|
1525
|
-
onUnmountAutoFocus:
|
|
1526
|
-
|
|
1527
|
-
document.getSelection()
|
|
1528
|
-
event.preventDefault();
|
|
1083
|
+
onUnmountAutoFocus: P(n, (S) => {
|
|
1084
|
+
var I, M;
|
|
1085
|
+
(I = p.trigger) == null || I.focus({ preventScroll: !0 }), (M = document.getSelection()) == null || M.empty(), S.preventDefault();
|
|
1529
1086
|
}),
|
|
1530
|
-
children: /* @__PURE__ */
|
|
1531
|
-
|
|
1087
|
+
children: /* @__PURE__ */ d(
|
|
1088
|
+
ct,
|
|
1532
1089
|
{
|
|
1533
|
-
asChild:
|
|
1534
|
-
disableOutsidePointerEvents:
|
|
1535
|
-
onEscapeKeyDown,
|
|
1536
|
-
onPointerDownOutside,
|
|
1537
|
-
onFocusOutside: (
|
|
1538
|
-
onDismiss: () =>
|
|
1539
|
-
children: /* @__PURE__ */
|
|
1540
|
-
|
|
1090
|
+
asChild: !0,
|
|
1091
|
+
disableOutsidePointerEvents: !0,
|
|
1092
|
+
onEscapeKeyDown: r,
|
|
1093
|
+
onPointerDownOutside: c,
|
|
1094
|
+
onFocusOutside: (S) => S.preventDefault(),
|
|
1095
|
+
onDismiss: () => p.onOpenChange(!1),
|
|
1096
|
+
children: /* @__PURE__ */ d(
|
|
1097
|
+
ae,
|
|
1541
1098
|
{
|
|
1542
1099
|
role: "listbox",
|
|
1543
|
-
id:
|
|
1544
|
-
"data-state":
|
|
1545
|
-
"aria-multiselectable":
|
|
1546
|
-
dir:
|
|
1547
|
-
onContextMenu: (
|
|
1548
|
-
...
|
|
1549
|
-
...
|
|
1550
|
-
onPlaced: () =>
|
|
1551
|
-
ref:
|
|
1100
|
+
id: p.contentId,
|
|
1101
|
+
"data-state": p.open ? "open" : "closed",
|
|
1102
|
+
"aria-multiselectable": p.multi ? "true" : void 0,
|
|
1103
|
+
dir: p.dir,
|
|
1104
|
+
onContextMenu: (S) => S.preventDefault(),
|
|
1105
|
+
...x,
|
|
1106
|
+
...ne,
|
|
1107
|
+
onPlaced: () => L(!0),
|
|
1108
|
+
ref: _,
|
|
1552
1109
|
style: {
|
|
1553
1110
|
// flex layout so we can place the scroll buttons properly
|
|
1554
1111
|
display: "flex",
|
|
1555
1112
|
flexDirection: "column",
|
|
1556
1113
|
// reset the outline by default as the content MAY get focused
|
|
1557
1114
|
outline: "none",
|
|
1558
|
-
...
|
|
1115
|
+
...x.style
|
|
1559
1116
|
},
|
|
1560
|
-
onKeyDown:
|
|
1561
|
-
const
|
|
1562
|
-
if (
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
const items = getItems().filter((item) => !item.disabled);
|
|
1568
|
-
let candidateNodes = items.map((item) => item.ref.current);
|
|
1569
|
-
if (["ArrowUp", "End"].includes(event.key)) {
|
|
1570
|
-
candidateNodes = candidateNodes.slice().reverse();
|
|
1571
|
-
}
|
|
1572
|
-
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
1573
|
-
const currentElement = event.target;
|
|
1574
|
-
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
1575
|
-
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
1117
|
+
onKeyDown: P(x.onKeyDown, (S) => {
|
|
1118
|
+
const I = S.ctrlKey || S.altKey || S.metaKey;
|
|
1119
|
+
if (S.key === "Tab" && S.preventDefault(), !I && S.key.length === 1 && ee(S.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(S.key)) {
|
|
1120
|
+
let V = R().filter((T) => !T.disabled).map((T) => T.ref.current);
|
|
1121
|
+
if (["ArrowUp", "End"].includes(S.key) && (V = V.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(S.key)) {
|
|
1122
|
+
const T = S.target, w = V.indexOf(T);
|
|
1123
|
+
V = V.slice(w + 1);
|
|
1576
1124
|
}
|
|
1577
|
-
setTimeout(() =>
|
|
1578
|
-
event.preventDefault();
|
|
1125
|
+
setTimeout(() => J(V)), S.preventDefault();
|
|
1579
1126
|
}
|
|
1580
1127
|
})
|
|
1581
1128
|
}
|
|
@@ -1588,153 +1135,93 @@ const SelectContentImpl = React.forwardRef(
|
|
|
1588
1135
|
);
|
|
1589
1136
|
}
|
|
1590
1137
|
);
|
|
1591
|
-
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
1601
|
-
const getItems = useCollection(__scopeSelect);
|
|
1602
|
-
const shouldExpandOnScrollRef = React.useRef(false);
|
|
1603
|
-
const shouldRepositionRef = React.useRef(true);
|
|
1604
|
-
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
|
1605
|
-
const position = React.useCallback(() => {
|
|
1606
|
-
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
1607
|
-
const triggerRect = context.trigger.getBoundingClientRect();
|
|
1608
|
-
const contentRect = content.getBoundingClientRect();
|
|
1609
|
-
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
1610
|
-
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
1611
|
-
if (context.dir !== "rtl") {
|
|
1612
|
-
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
1613
|
-
const left = valueNodeRect.left - itemTextOffset;
|
|
1614
|
-
const leftDelta = triggerRect.left - left;
|
|
1615
|
-
const minContentWidth = triggerRect.width + leftDelta;
|
|
1616
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
1617
|
-
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
|
1618
|
-
const clampedLeft = clamp(left, [CONTENT_MARGIN, rightEdge - contentWidth]);
|
|
1619
|
-
contentWrapper.style.minWidth = `${minContentWidth}px`;
|
|
1620
|
-
contentWrapper.style.left = `${clampedLeft}px`;
|
|
1138
|
+
Lt.displayName = Oo;
|
|
1139
|
+
const Do = "SelectItemAlignedPosition", Bt = s.forwardRef(
|
|
1140
|
+
(o, i) => {
|
|
1141
|
+
const { __scopeSelect: e, onPlaced: t, ...n } = o, r = X(le, e), c = oe(le, e), [l, a] = s.useState(null), [m, C] = s.useState(null), v = A(i, (_) => C(_)), g = ve(e), u = s.useRef(!1), f = s.useRef(!0), { viewport: h, selectedItem: b, selectedItemText: x, focusSelectedItem: p } = c, y = s.useCallback(() => {
|
|
1142
|
+
if (r.trigger && r.valueNode && l && m && h && b && x) {
|
|
1143
|
+
const _ = r.trigger.getBoundingClientRect(), k = m.getBoundingClientRect(), Z = r.valueNode.getBoundingClientRect(), U = x.getBoundingClientRect();
|
|
1144
|
+
if (r.dir !== "rtl") {
|
|
1145
|
+
const T = U.left - k.left, w = Z.left - T, B = _.left - w, j = _.width + B, D = Math.max(j, k.width), ue = window.innerWidth - q, he = rt(w, [q, ue - D]);
|
|
1146
|
+
l.style.minWidth = `${j}px`, l.style.left = `${he}px`;
|
|
1621
1147
|
} else {
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1624
|
-
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
1625
|
-
const minContentWidth = triggerRect.width + rightDelta;
|
|
1626
|
-
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
1627
|
-
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
|
1628
|
-
const clampedRight = clamp(right, [CONTENT_MARGIN, leftEdge - contentWidth]);
|
|
1629
|
-
contentWrapper.style.minWidth = `${minContentWidth}px`;
|
|
1630
|
-
contentWrapper.style.right = `${clampedRight}px`;
|
|
1148
|
+
const T = k.right - U.right, w = window.innerWidth - Z.right - T, B = window.innerWidth - _.right - w, j = _.width + B, D = Math.max(j, k.width), ue = window.innerWidth - q, he = rt(w, [q, ue - D]);
|
|
1149
|
+
l.style.minWidth = `${j}px`, l.style.right = `${he}px`;
|
|
1631
1150
|
}
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
const viewportStyles = window.getComputedStyle(viewport);
|
|
1643
|
-
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
1644
|
-
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
1645
|
-
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
|
1646
|
-
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
1647
|
-
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
1648
|
-
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
1649
|
-
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
1650
|
-
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
1651
|
-
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
1652
|
-
if (willAlignWithoutTopOverflow) {
|
|
1653
|
-
const isLastItem = selectedItem === items[items.length - 1].ref.current;
|
|
1654
|
-
contentWrapper.style.bottom = `${0}px`;
|
|
1655
|
-
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
1656
|
-
const clampedTriggerMiddleToBottomEdge = Math.max(
|
|
1657
|
-
triggerMiddleToBottomEdge,
|
|
1658
|
-
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
1659
|
-
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
|
1660
|
-
);
|
|
1661
|
-
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
1662
|
-
contentWrapper.style.height = `${height}px`;
|
|
1151
|
+
const z = g(), R = window.innerHeight - q * 2, H = h.scrollHeight, L = window.getComputedStyle(m), W = parseInt(L.borderTopWidth, 10), J = parseInt(L.paddingTop, 10), Q = parseInt(L.borderBottomWidth, 10), K = parseInt(L.paddingBottom, 10), G = W + J + H + K + Q, ce = Math.min(b.offsetHeight * 5, G), ee = window.getComputedStyle(h), fe = parseInt(ee.paddingTop, 10), me = parseInt(ee.paddingBottom, 10), te = _.top + _.height / 2 - q, ae = R - te, ne = b.offsetHeight / 2, S = b.offsetTop + ne, I = W + J + S, M = G - I;
|
|
1152
|
+
if (I <= te) {
|
|
1153
|
+
const T = b === z[z.length - 1].ref.current;
|
|
1154
|
+
l.style.bottom = "0px";
|
|
1155
|
+
const w = m.clientHeight - h.offsetTop - h.offsetHeight, B = Math.max(
|
|
1156
|
+
ae,
|
|
1157
|
+
ne + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
1158
|
+
(T ? me : 0) + w + Q
|
|
1159
|
+
), j = I + B;
|
|
1160
|
+
l.style.height = `${j}px`;
|
|
1663
1161
|
} else {
|
|
1664
|
-
const
|
|
1665
|
-
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
(
|
|
1670
|
-
);
|
|
1671
|
-
|
|
1672
|
-
contentWrapper.style.height = `${height}px`;
|
|
1673
|
-
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
1162
|
+
const T = b === z[0].ref.current;
|
|
1163
|
+
l.style.top = "0px";
|
|
1164
|
+
const B = Math.max(
|
|
1165
|
+
te,
|
|
1166
|
+
W + h.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
1167
|
+
(T ? fe : 0) + ne
|
|
1168
|
+
) + M;
|
|
1169
|
+
l.style.height = `${B}px`, h.scrollTop = I - te + h.offsetTop;
|
|
1674
1170
|
}
|
|
1675
|
-
|
|
1676
|
-
contentWrapper.style.minHeight = `${minContentHeight}px`;
|
|
1677
|
-
contentWrapper.style.maxHeight = `${availableHeight}px`;
|
|
1678
|
-
onPlaced?.();
|
|
1679
|
-
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
|
1171
|
+
l.style.margin = `${q}px 0`, l.style.minHeight = `${ce}px`, l.style.maxHeight = `${R}px`, t == null || t(), requestAnimationFrame(() => u.current = !0);
|
|
1680
1172
|
}
|
|
1681
1173
|
}, [
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1174
|
+
g,
|
|
1175
|
+
r.trigger,
|
|
1176
|
+
r.valueNode,
|
|
1177
|
+
l,
|
|
1178
|
+
m,
|
|
1179
|
+
h,
|
|
1180
|
+
b,
|
|
1181
|
+
x,
|
|
1182
|
+
r.dir,
|
|
1183
|
+
t
|
|
1692
1184
|
]);
|
|
1693
|
-
|
|
1694
|
-
const [
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
if (node && shouldRepositionRef.current === true) {
|
|
1702
|
-
position();
|
|
1703
|
-
focusSelectedItem?.();
|
|
1704
|
-
shouldRepositionRef.current = false;
|
|
1705
|
-
}
|
|
1185
|
+
$(() => y(), [y]);
|
|
1186
|
+
const [E, O] = s.useState();
|
|
1187
|
+
$(() => {
|
|
1188
|
+
m && O(window.getComputedStyle(m).zIndex);
|
|
1189
|
+
}, [m]);
|
|
1190
|
+
const F = s.useCallback(
|
|
1191
|
+
(_) => {
|
|
1192
|
+
_ && f.current === !0 && (y(), p == null || p(), f.current = !1);
|
|
1706
1193
|
},
|
|
1707
|
-
[
|
|
1194
|
+
[y, p]
|
|
1708
1195
|
);
|
|
1709
|
-
return /* @__PURE__ */
|
|
1710
|
-
|
|
1196
|
+
return /* @__PURE__ */ d(
|
|
1197
|
+
Fo,
|
|
1711
1198
|
{
|
|
1712
|
-
scope:
|
|
1713
|
-
contentWrapper,
|
|
1714
|
-
shouldExpandOnScrollRef,
|
|
1715
|
-
onScrollButtonChange:
|
|
1716
|
-
children: /* @__PURE__ */
|
|
1199
|
+
scope: e,
|
|
1200
|
+
contentWrapper: l,
|
|
1201
|
+
shouldExpandOnScrollRef: u,
|
|
1202
|
+
onScrollButtonChange: F,
|
|
1203
|
+
children: /* @__PURE__ */ d(
|
|
1717
1204
|
"div",
|
|
1718
1205
|
{
|
|
1719
|
-
ref:
|
|
1206
|
+
ref: a,
|
|
1720
1207
|
style: {
|
|
1721
1208
|
display: "flex",
|
|
1722
1209
|
flexDirection: "column",
|
|
1723
1210
|
position: "fixed",
|
|
1724
|
-
zIndex:
|
|
1211
|
+
zIndex: E
|
|
1725
1212
|
},
|
|
1726
|
-
children: /* @__PURE__ */
|
|
1727
|
-
|
|
1213
|
+
children: /* @__PURE__ */ d(
|
|
1214
|
+
N.div,
|
|
1728
1215
|
{
|
|
1729
|
-
...
|
|
1730
|
-
ref:
|
|
1216
|
+
...n,
|
|
1217
|
+
ref: v,
|
|
1731
1218
|
style: {
|
|
1732
1219
|
// When we get the height of the content, it includes borders. If we were to set
|
|
1733
1220
|
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
1734
1221
|
boxSizing: "border-box",
|
|
1735
1222
|
// We need to ensure the content doesn't get taller than the wrapper
|
|
1736
1223
|
maxHeight: "100%",
|
|
1737
|
-
...
|
|
1224
|
+
...n.style
|
|
1738
1225
|
}
|
|
1739
1226
|
}
|
|
1740
1227
|
)
|
|
@@ -1744,66 +1231,55 @@ const SelectItemAlignedPosition = React.forwardRef(
|
|
|
1744
1231
|
);
|
|
1745
1232
|
}
|
|
1746
1233
|
);
|
|
1747
|
-
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
return /* @__PURE__ */ jsx(
|
|
1754
|
-
PopperPrimitive.Content,
|
|
1234
|
+
Bt.displayName = Do;
|
|
1235
|
+
const ko = "SelectPopperPosition", Re = s.forwardRef(
|
|
1236
|
+
(o, i) => {
|
|
1237
|
+
const { __scopeSelect: e, align: t = "start", collisionPadding: n = q, ...r } = o, c = Ve(e);
|
|
1238
|
+
return /* @__PURE__ */ d(
|
|
1239
|
+
ie.Content,
|
|
1755
1240
|
{
|
|
1756
|
-
...
|
|
1757
|
-
...
|
|
1758
|
-
ref:
|
|
1759
|
-
align,
|
|
1760
|
-
collisionPadding,
|
|
1241
|
+
...c,
|
|
1242
|
+
...r,
|
|
1243
|
+
ref: i,
|
|
1244
|
+
align: t,
|
|
1245
|
+
collisionPadding: n,
|
|
1761
1246
|
style: {
|
|
1762
1247
|
// Ensure border-box for floating-ui calculations
|
|
1763
1248
|
boxSizing: "border-box",
|
|
1764
|
-
...
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1771
|
-
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1772
|
-
}
|
|
1249
|
+
...r.style,
|
|
1250
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1251
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
1252
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
1253
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1254
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1773
1255
|
}
|
|
1774
1256
|
}
|
|
1775
1257
|
);
|
|
1776
1258
|
}
|
|
1777
1259
|
);
|
|
1778
|
-
|
|
1779
|
-
const [
|
|
1780
|
-
|
|
1260
|
+
Re.displayName = ko;
|
|
1261
|
+
const [Fo, Ge] = pe(
|
|
1262
|
+
le,
|
|
1781
1263
|
{}
|
|
1782
|
-
)
|
|
1783
|
-
|
|
1784
|
-
const
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
|
|
1788
|
-
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
|
|
1789
|
-
const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
|
|
1790
|
-
const prevScrollTopRef = React.useRef(0);
|
|
1791
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1792
|
-
/* @__PURE__ */ jsx(
|
|
1264
|
+
), Ae = "SelectViewport", je = s.forwardRef(
|
|
1265
|
+
(o, i) => {
|
|
1266
|
+
const { __scopeSelect: e, ...t } = o, n = oe(Ae, e), r = Ge(Ae, e), c = A(i, n.onViewportChange), l = s.useRef(0);
|
|
1267
|
+
return /* @__PURE__ */ ye(Se, { children: [
|
|
1268
|
+
/* @__PURE__ */ d(
|
|
1793
1269
|
"style",
|
|
1794
1270
|
{
|
|
1795
1271
|
dangerouslySetInnerHTML: {
|
|
1796
|
-
__html:
|
|
1272
|
+
__html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
|
|
1797
1273
|
}
|
|
1798
1274
|
}
|
|
1799
1275
|
),
|
|
1800
|
-
/* @__PURE__ */
|
|
1801
|
-
|
|
1276
|
+
/* @__PURE__ */ d(Te.Slot, { scope: e, children: /* @__PURE__ */ d(
|
|
1277
|
+
N.div,
|
|
1802
1278
|
{
|
|
1803
1279
|
"data-radix-select-viewport": "",
|
|
1804
1280
|
role: "presentation",
|
|
1805
|
-
...
|
|
1806
|
-
ref:
|
|
1281
|
+
...t,
|
|
1282
|
+
ref: c,
|
|
1807
1283
|
style: {
|
|
1808
1284
|
// we use position: 'relative' here on the `viewport` so that when we call
|
|
1809
1285
|
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
@@ -1811,139 +1287,104 @@ const SelectViewport = React.forwardRef(
|
|
|
1811
1287
|
position: "relative",
|
|
1812
1288
|
flex: 1,
|
|
1813
1289
|
overflow: "auto",
|
|
1814
|
-
...
|
|
1290
|
+
...t.style
|
|
1815
1291
|
},
|
|
1816
|
-
onScroll:
|
|
1817
|
-
const
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
1826
|
-
if (prevHeight < availableHeight) {
|
|
1827
|
-
const nextHeight = prevHeight + scrolledBy;
|
|
1828
|
-
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
1829
|
-
const heightDiff = nextHeight - clampedNextHeight;
|
|
1830
|
-
contentWrapper.style.height = `${clampedNextHeight}px`;
|
|
1831
|
-
if (contentWrapper.style.bottom === "0px") {
|
|
1832
|
-
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
1833
|
-
contentWrapper.style.justifyContent = "flex-end";
|
|
1834
|
-
}
|
|
1292
|
+
onScroll: P(t.onScroll, (a) => {
|
|
1293
|
+
const m = a.currentTarget, { contentWrapper: C, shouldExpandOnScrollRef: v } = r;
|
|
1294
|
+
if (v != null && v.current && C) {
|
|
1295
|
+
const g = Math.abs(l.current - m.scrollTop);
|
|
1296
|
+
if (g > 0) {
|
|
1297
|
+
const u = window.innerHeight - q * 2, f = parseFloat(C.style.minHeight), h = parseFloat(C.style.height), b = Math.max(f, h);
|
|
1298
|
+
if (b < u) {
|
|
1299
|
+
const x = b + g, p = Math.min(u, x), y = x - p;
|
|
1300
|
+
C.style.height = `${p}px`, C.style.bottom === "0px" && (m.scrollTop = y > 0 ? y : 0, C.style.justifyContent = "flex-end");
|
|
1835
1301
|
}
|
|
1836
1302
|
}
|
|
1837
1303
|
}
|
|
1838
|
-
|
|
1304
|
+
l.current = m.scrollTop;
|
|
1839
1305
|
})
|
|
1840
1306
|
}
|
|
1841
1307
|
) })
|
|
1842
1308
|
] });
|
|
1843
1309
|
}
|
|
1844
1310
|
);
|
|
1845
|
-
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
const { __scopeSelect, ...groupProps } = props;
|
|
1851
|
-
const groupId = useId();
|
|
1852
|
-
return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
|
1311
|
+
je.displayName = Ae;
|
|
1312
|
+
const $t = "SelectGroup", [Lo, Bo] = pe($t), Ye = s.forwardRef(
|
|
1313
|
+
(o, i) => {
|
|
1314
|
+
const { __scopeSelect: e, ...t } = o, n = se();
|
|
1315
|
+
return /* @__PURE__ */ d(Lo, { scope: e, id: n, children: /* @__PURE__ */ d(N.div, { role: "group", "aria-labelledby": n, ...t, ref: i }) });
|
|
1853
1316
|
}
|
|
1854
1317
|
);
|
|
1855
|
-
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
1861
|
-
return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
|
1318
|
+
Ye.displayName = $t;
|
|
1319
|
+
const Ut = "SelectLabel", qe = s.forwardRef(
|
|
1320
|
+
(o, i) => {
|
|
1321
|
+
const { __scopeSelect: e, ...t } = o, n = Bo(Ut, e);
|
|
1322
|
+
return /* @__PURE__ */ d(N.div, { id: n.id, ...t, ref: i });
|
|
1862
1323
|
}
|
|
1863
1324
|
);
|
|
1864
|
-
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
)
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
let newValue = context.multi && typeof value === "string" ? [value] : value;
|
|
1884
|
-
if (isIntermediate && !isSelected) {
|
|
1885
|
-
context.onValueChange(newValue);
|
|
1886
|
-
} else if (Array.isArray(context.value)) {
|
|
1887
|
-
newValue = toggleArrayValue(value, context.value);
|
|
1888
|
-
}
|
|
1889
|
-
context.onValueChange(newValue);
|
|
1890
|
-
if (!context.multi) {
|
|
1891
|
-
context.onOpenChange(false);
|
|
1892
|
-
}
|
|
1325
|
+
qe.displayName = Ut;
|
|
1326
|
+
const be = "SelectItem", [$o, Ht] = pe(be), Xe = s.forwardRef(
|
|
1327
|
+
(o, i) => {
|
|
1328
|
+
const { __scopeSelect: e, value: t, disabled: n = !1, textValue: r, ...c } = o, l = X(be, e), a = oe(be, e), m = typeof t == "string" ? Array.isArray(l.value) ? l.value.includes(t) : l.value === t : t.every((p) => {
|
|
1329
|
+
var y;
|
|
1330
|
+
return (y = l.value) == null ? void 0 : y.includes(p);
|
|
1331
|
+
}), C = Array.isArray(l.value) && Array.isArray(t) && t.some((p) => {
|
|
1332
|
+
var y;
|
|
1333
|
+
return (y = l.value) == null ? void 0 : y.includes(p);
|
|
1334
|
+
}), [v, g] = s.useState(r ?? ""), [u, f] = s.useState(!1), h = A(
|
|
1335
|
+
i,
|
|
1336
|
+
(p) => {
|
|
1337
|
+
var y;
|
|
1338
|
+
return (y = a.itemRefCallback) == null ? void 0 : y.call(a, p, t, n);
|
|
1339
|
+
}
|
|
1340
|
+
), b = se(), x = () => {
|
|
1341
|
+
if (!n) {
|
|
1342
|
+
let p = l.multi && typeof t == "string" ? [t] : t;
|
|
1343
|
+
C && !m ? l.onValueChange(p) : Array.isArray(l.value) && (p = Gt(t, l.value)), l.onValueChange(p), l.multi || l.onOpenChange(!1);
|
|
1893
1344
|
}
|
|
1894
1345
|
};
|
|
1895
|
-
if (!
|
|
1346
|
+
if (!l.multi && Array.isArray(t))
|
|
1896
1347
|
throw new Error("You can only pass an array of values in multi selects");
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
SelectItemContextProvider,
|
|
1348
|
+
return /* @__PURE__ */ d(
|
|
1349
|
+
$o,
|
|
1900
1350
|
{
|
|
1901
|
-
scope:
|
|
1902
|
-
value,
|
|
1903
|
-
disabled,
|
|
1904
|
-
textId,
|
|
1905
|
-
isSelected,
|
|
1906
|
-
isIntermediate,
|
|
1907
|
-
onItemTextChange:
|
|
1908
|
-
|
|
1351
|
+
scope: e,
|
|
1352
|
+
value: t,
|
|
1353
|
+
disabled: n,
|
|
1354
|
+
textId: b,
|
|
1355
|
+
isSelected: m,
|
|
1356
|
+
isIntermediate: C,
|
|
1357
|
+
onItemTextChange: s.useCallback((p) => {
|
|
1358
|
+
g((y) => y || ((p == null ? void 0 : p.textContent) ?? "").trim());
|
|
1909
1359
|
}, []),
|
|
1910
|
-
children: /* @__PURE__ */
|
|
1911
|
-
|
|
1360
|
+
children: /* @__PURE__ */ d(Te.ItemSlot, { scope: e, value: t, disabled: n, textValue: v, children: /* @__PURE__ */ d(
|
|
1361
|
+
N.div,
|
|
1912
1362
|
{
|
|
1913
1363
|
role: "option",
|
|
1914
|
-
"aria-labelledby":
|
|
1915
|
-
"data-highlighted":
|
|
1916
|
-
"aria-selected":
|
|
1917
|
-
"aria-checked":
|
|
1918
|
-
"data-state":
|
|
1919
|
-
"aria-disabled":
|
|
1920
|
-
"data-disabled":
|
|
1921
|
-
tabIndex:
|
|
1922
|
-
...
|
|
1923
|
-
ref:
|
|
1924
|
-
onFocus:
|
|
1925
|
-
onBlur:
|
|
1926
|
-
onPointerUp:
|
|
1927
|
-
onPointerMove:
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
} else {
|
|
1931
|
-
event.currentTarget.focus({ preventScroll: true });
|
|
1932
|
-
}
|
|
1364
|
+
"aria-labelledby": b,
|
|
1365
|
+
"data-highlighted": u ? "" : void 0,
|
|
1366
|
+
"aria-selected": l.multi ? void 0 : m && u,
|
|
1367
|
+
"aria-checked": l.multi ? m : void 0,
|
|
1368
|
+
"data-state": m ? "checked" : "unchecked",
|
|
1369
|
+
"aria-disabled": n || void 0,
|
|
1370
|
+
"data-disabled": n ? "" : void 0,
|
|
1371
|
+
tabIndex: n ? void 0 : -1,
|
|
1372
|
+
...c,
|
|
1373
|
+
ref: h,
|
|
1374
|
+
onFocus: P(c.onFocus, () => f(!0)),
|
|
1375
|
+
onBlur: P(c.onBlur, () => f(!1)),
|
|
1376
|
+
onPointerUp: P(c.onPointerUp, x),
|
|
1377
|
+
onPointerMove: P(c.onPointerMove, (p) => {
|
|
1378
|
+
var y;
|
|
1379
|
+
n ? (y = a.onItemLeave) == null || y.call(a) : p.currentTarget.focus({ preventScroll: !0 });
|
|
1933
1380
|
}),
|
|
1934
|
-
onPointerLeave:
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
}
|
|
1381
|
+
onPointerLeave: P(c.onPointerLeave, (p) => {
|
|
1382
|
+
var y;
|
|
1383
|
+
p.currentTarget === document.activeElement && ((y = a.onItemLeave) == null || y.call(a));
|
|
1938
1384
|
}),
|
|
1939
|
-
onKeyDown:
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
return;
|
|
1943
|
-
if (SELECTION_KEYS.includes(event.key))
|
|
1944
|
-
handleSelect();
|
|
1945
|
-
if (event.key === " ")
|
|
1946
|
-
event.preventDefault();
|
|
1385
|
+
onKeyDown: P(c.onKeyDown, (p) => {
|
|
1386
|
+
var E;
|
|
1387
|
+
((E = a.searchRef) == null ? void 0 : E.current) !== "" && p.key === " " || (Vo.includes(p.key) && x(), p.key === " " && p.preventDefault());
|
|
1947
1388
|
})
|
|
1948
1389
|
}
|
|
1949
1390
|
) })
|
|
@@ -1951,345 +1392,239 @@ const SelectItem = React.forwardRef(
|
|
|
1951
1392
|
);
|
|
1952
1393
|
}
|
|
1953
1394
|
);
|
|
1954
|
-
|
|
1955
|
-
const
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
(
|
|
1967
|
-
itemContext.onItemTextChange,
|
|
1968
|
-
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
|
1969
|
-
);
|
|
1970
|
-
const textContent = itemTextNode?.textContent;
|
|
1971
|
-
const nativeOption = React.useMemo(
|
|
1972
|
-
() => /* @__PURE__ */ jsx(
|
|
1395
|
+
Xe.displayName = be;
|
|
1396
|
+
const ge = "SelectItemText", Ze = s.forwardRef(
|
|
1397
|
+
(o, i) => {
|
|
1398
|
+
const { __scopeSelect: e, className: t, style: n, ...r } = o, c = X(ge, e), l = oe(ge, e), a = Ht(ge, e), m = Ao(ge, e), [C, v] = s.useState(null), g = A(
|
|
1399
|
+
i,
|
|
1400
|
+
(x) => v(x),
|
|
1401
|
+
a.onItemTextChange,
|
|
1402
|
+
(x) => {
|
|
1403
|
+
var p;
|
|
1404
|
+
return (p = l.itemTextRefCallback) == null ? void 0 : p.call(l, x, a.value, a.disabled);
|
|
1405
|
+
}
|
|
1406
|
+
), u = C == null ? void 0 : C.textContent, f = s.useMemo(
|
|
1407
|
+
() => /* @__PURE__ */ d(
|
|
1973
1408
|
"option",
|
|
1974
1409
|
{
|
|
1975
|
-
value:
|
|
1976
|
-
disabled:
|
|
1977
|
-
children:
|
|
1410
|
+
value: a.value,
|
|
1411
|
+
disabled: a.disabled,
|
|
1412
|
+
children: u
|
|
1978
1413
|
},
|
|
1979
|
-
Array.isArray(
|
|
1414
|
+
Array.isArray(a.value) ? a.value.join(";") : a.value
|
|
1980
1415
|
),
|
|
1981
|
-
[
|
|
1982
|
-
);
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
return () => onNativeOptionRemove(nativeOption);
|
|
1987
|
-
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
|
1988
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1989
|
-
/* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
|
1990
|
-
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
|
|
1416
|
+
[a.disabled, a.value, u]
|
|
1417
|
+
), { onNativeOptionAdd: h, onNativeOptionRemove: b } = m;
|
|
1418
|
+
return $(() => (h(f), () => b(f)), [h, b, f]), /* @__PURE__ */ ye(Se, { children: [
|
|
1419
|
+
/* @__PURE__ */ d(N.span, { id: a.textId, ...r, ref: g }),
|
|
1420
|
+
a.isSelected && c.valueNode && !c.valueNodeHasChildren ? we.createPortal(r.children, c.valueNode) : null
|
|
1991
1421
|
] });
|
|
1992
1422
|
}
|
|
1993
1423
|
);
|
|
1994
|
-
|
|
1995
|
-
const
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
isSelected: itemContext.isSelected,
|
|
2003
|
-
isIntermediate: itemContext.isIntermediate
|
|
2004
|
-
}) });
|
|
2005
|
-
}
|
|
2006
|
-
return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef, children }) : null;
|
|
1424
|
+
Ze.displayName = ge;
|
|
1425
|
+
const Wt = "SelectItemIndicator", Je = s.forwardRef(
|
|
1426
|
+
(o, i) => {
|
|
1427
|
+
const { __scopeSelect: e, children: t, ...n } = o, r = Ht(Wt, e);
|
|
1428
|
+
return typeof t == "function" ? /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...n, ref: i, children: t({
|
|
1429
|
+
isSelected: r.isSelected,
|
|
1430
|
+
isIntermediate: r.isIntermediate
|
|
1431
|
+
}) }) : r.isSelected ? /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...n, ref: i, children: t }) : null;
|
|
2007
1432
|
}
|
|
2008
1433
|
);
|
|
2009
|
-
|
|
2010
|
-
const
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
if (contentContext.viewport && contentContext.isPositioned) {
|
|
2019
|
-
const viewport = contentContext.viewport;
|
|
2020
|
-
const handleScroll = () => {
|
|
2021
|
-
const canScrollUp2 = viewport.scrollTop > 0;
|
|
2022
|
-
setCanScrollUp(canScrollUp2);
|
|
1434
|
+
Je.displayName = Wt;
|
|
1435
|
+
const _e = "SelectScrollUpButton", Qe = s.forwardRef(
|
|
1436
|
+
(o, i) => {
|
|
1437
|
+
const e = oe(_e, o.__scopeSelect), t = Ge(_e, o.__scopeSelect), [n, r] = s.useState(!1), c = A(i, t.onScrollButtonChange);
|
|
1438
|
+
return $(() => {
|
|
1439
|
+
if (e.viewport && e.isPositioned) {
|
|
1440
|
+
const l = e.viewport, a = () => {
|
|
1441
|
+
const m = l.scrollTop > 0;
|
|
1442
|
+
r(m);
|
|
2023
1443
|
};
|
|
2024
|
-
|
|
2025
|
-
viewport.addEventListener("scroll", handleScroll);
|
|
2026
|
-
return () => viewport.removeEventListener("scroll", handleScroll);
|
|
1444
|
+
return a(), l.addEventListener("scroll", a), () => l.removeEventListener("scroll", a);
|
|
2027
1445
|
}
|
|
2028
|
-
}, [
|
|
2029
|
-
|
|
2030
|
-
SelectScrollButtonImpl,
|
|
1446
|
+
}, [e.viewport, e.isPositioned]), n ? /* @__PURE__ */ d(
|
|
1447
|
+
tt,
|
|
2031
1448
|
{
|
|
2032
|
-
...
|
|
2033
|
-
ref:
|
|
1449
|
+
...o,
|
|
1450
|
+
ref: c,
|
|
2034
1451
|
onAutoScroll: () => {
|
|
2035
|
-
const { viewport, selectedItem } =
|
|
2036
|
-
|
|
2037
|
-
viewport.scrollTop -= selectedItem.offsetHeight;
|
|
2038
|
-
}
|
|
1452
|
+
const { viewport: l, selectedItem: a } = e;
|
|
1453
|
+
l && a && (l.scrollTop -= a.offsetHeight);
|
|
2039
1454
|
}
|
|
2040
1455
|
}
|
|
2041
1456
|
) : null;
|
|
2042
1457
|
}
|
|
2043
1458
|
);
|
|
2044
|
-
|
|
2045
|
-
const
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
if (contentContext.viewport && contentContext.isPositioned) {
|
|
2054
|
-
const viewport = contentContext.viewport;
|
|
2055
|
-
const handleScroll = () => {
|
|
2056
|
-
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
|
2057
|
-
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
2058
|
-
setCanScrollDown(canScrollDown2);
|
|
1459
|
+
Qe.displayName = _e;
|
|
1460
|
+
const Me = "SelectScrollDownButton", et = s.forwardRef(
|
|
1461
|
+
(o, i) => {
|
|
1462
|
+
const e = oe(Me, o.__scopeSelect), t = Ge(Me, o.__scopeSelect), [n, r] = s.useState(!1), c = A(i, t.onScrollButtonChange);
|
|
1463
|
+
return $(() => {
|
|
1464
|
+
if (e.viewport && e.isPositioned) {
|
|
1465
|
+
const l = e.viewport, a = () => {
|
|
1466
|
+
const m = l.scrollHeight - l.clientHeight, C = Math.ceil(l.scrollTop) < m;
|
|
1467
|
+
r(C);
|
|
2059
1468
|
};
|
|
2060
|
-
|
|
2061
|
-
viewport.addEventListener("scroll", handleScroll);
|
|
2062
|
-
return () => viewport.removeEventListener("scroll", handleScroll);
|
|
1469
|
+
return a(), l.addEventListener("scroll", a), () => l.removeEventListener("scroll", a);
|
|
2063
1470
|
}
|
|
2064
|
-
}, [
|
|
2065
|
-
|
|
2066
|
-
SelectScrollButtonImpl,
|
|
1471
|
+
}, [e.viewport, e.isPositioned]), n ? /* @__PURE__ */ d(
|
|
1472
|
+
tt,
|
|
2067
1473
|
{
|
|
2068
|
-
...
|
|
2069
|
-
ref:
|
|
1474
|
+
...o,
|
|
1475
|
+
ref: c,
|
|
2070
1476
|
onAutoScroll: () => {
|
|
2071
|
-
const { viewport, selectedItem } =
|
|
2072
|
-
|
|
2073
|
-
viewport.scrollTop += selectedItem.offsetHeight;
|
|
2074
|
-
}
|
|
1477
|
+
const { viewport: l, selectedItem: a } = e;
|
|
1478
|
+
l && a && (l.scrollTop += a.offsetHeight);
|
|
2075
1479
|
}
|
|
2076
1480
|
}
|
|
2077
1481
|
) : null;
|
|
2078
1482
|
}
|
|
2079
1483
|
);
|
|
2080
|
-
|
|
2081
|
-
const
|
|
2082
|
-
(
|
|
2083
|
-
const { __scopeSelect, onAutoScroll, ...
|
|
2084
|
-
|
|
2085
|
-
const autoScrollTimerRef = React.useRef(null);
|
|
2086
|
-
const getItems = useCollection(__scopeSelect);
|
|
2087
|
-
const clearAutoScrollTimer = React.useCallback(() => {
|
|
2088
|
-
if (autoScrollTimerRef.current !== null) {
|
|
2089
|
-
window.clearInterval(autoScrollTimerRef.current);
|
|
2090
|
-
autoScrollTimerRef.current = null;
|
|
2091
|
-
}
|
|
1484
|
+
et.displayName = Me;
|
|
1485
|
+
const tt = s.forwardRef(
|
|
1486
|
+
(o, i) => {
|
|
1487
|
+
const { __scopeSelect: e, onAutoScroll: t, ...n } = o, r = oe("SelectScrollButton", e), c = s.useRef(null), l = ve(e), a = s.useCallback(() => {
|
|
1488
|
+
c.current !== null && (window.clearInterval(c.current), c.current = null);
|
|
2092
1489
|
}, []);
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
}, [getItems]);
|
|
2100
|
-
return /* @__PURE__ */ jsx(
|
|
2101
|
-
Primitive.div,
|
|
1490
|
+
return s.useEffect(() => () => a(), [a]), $(() => {
|
|
1491
|
+
var C;
|
|
1492
|
+
const m = l().find((v) => v.ref.current === document.activeElement);
|
|
1493
|
+
(C = m == null ? void 0 : m.ref.current) == null || C.scrollIntoView({ block: "nearest" });
|
|
1494
|
+
}, [l]), /* @__PURE__ */ d(
|
|
1495
|
+
N.div,
|
|
2102
1496
|
{
|
|
2103
|
-
"aria-hidden":
|
|
2104
|
-
...
|
|
2105
|
-
ref:
|
|
2106
|
-
style: { flexShrink: 0, ...
|
|
2107
|
-
onPointerMove:
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
2111
|
-
}
|
|
1497
|
+
"aria-hidden": !0,
|
|
1498
|
+
...n,
|
|
1499
|
+
ref: i,
|
|
1500
|
+
style: { flexShrink: 0, ...n.style },
|
|
1501
|
+
onPointerMove: P(n.onPointerMove, () => {
|
|
1502
|
+
var m;
|
|
1503
|
+
(m = r.onItemLeave) == null || m.call(r), c.current === null && (c.current = window.setInterval(t, 50));
|
|
2112
1504
|
}),
|
|
2113
|
-
onPointerLeave:
|
|
2114
|
-
|
|
1505
|
+
onPointerLeave: P(n.onPointerLeave, () => {
|
|
1506
|
+
a();
|
|
2115
1507
|
})
|
|
2116
1508
|
}
|
|
2117
1509
|
);
|
|
2118
1510
|
}
|
|
2119
1511
|
);
|
|
2120
|
-
|
|
2121
|
-
const
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
|
1512
|
+
tt.displayName = "SelectScrollButtonImpl";
|
|
1513
|
+
const Uo = "SelectSeparator", ot = s.forwardRef(
|
|
1514
|
+
(o, i) => {
|
|
1515
|
+
const { __scopeSelect: e, ...t } = o;
|
|
1516
|
+
return /* @__PURE__ */ d(N.div, { "aria-hidden": !0, ...t, ref: i });
|
|
2126
1517
|
}
|
|
2127
1518
|
);
|
|
2128
|
-
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
const popperScope = usePopperScope(__scopeSelect);
|
|
2134
|
-
const context = useSelectContext(ARROW_NAME, __scopeSelect);
|
|
2135
|
-
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
2136
|
-
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
|
1519
|
+
ot.displayName = Uo;
|
|
1520
|
+
const Oe = "SelectArrow", nt = s.forwardRef(
|
|
1521
|
+
(o, i) => {
|
|
1522
|
+
const { __scopeSelect: e, ...t } = o, n = Ve(e), r = X(Oe, e), c = oe(Oe, e);
|
|
1523
|
+
return r.open && c.position === "popper" ? /* @__PURE__ */ d(ie.Arrow, { ...n, ...t, ref: i }) : null;
|
|
2137
1524
|
}
|
|
2138
1525
|
);
|
|
2139
|
-
|
|
2140
|
-
const
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
React.useEffect(() => {
|
|
2149
|
-
const select = ref.current;
|
|
2150
|
-
const selectProto = window.HTMLSelectElement.prototype;
|
|
2151
|
-
const descriptor = Object.getOwnPropertyDescriptor(selectProto, "value");
|
|
2152
|
-
const setValue = descriptor.set;
|
|
2153
|
-
if (prevValue !== value && setValue) {
|
|
2154
|
-
const event = new Event("change", { bubbles: true });
|
|
2155
|
-
setValue.call(select, value);
|
|
2156
|
-
select.dispatchEvent(event);
|
|
1526
|
+
nt.displayName = Oe;
|
|
1527
|
+
const Ho = "BubbleSelect", Wo = s.forwardRef(
|
|
1528
|
+
(o, i) => {
|
|
1529
|
+
const { value: e, ...t } = o, n = s.useRef(null), r = A(i, n), c = Xt(e), l = X(Ho, void 0);
|
|
1530
|
+
s.useEffect(() => {
|
|
1531
|
+
const m = n.current, C = window.HTMLSelectElement.prototype, g = Object.getOwnPropertyDescriptor(C, "value").set;
|
|
1532
|
+
if (c !== e && g) {
|
|
1533
|
+
const u = new Event("change", { bubbles: !0 });
|
|
1534
|
+
g.call(m, e), m.dispatchEvent(u);
|
|
2157
1535
|
}
|
|
2158
|
-
}, [
|
|
2159
|
-
let
|
|
2160
|
-
|
|
2161
|
-
defaultValue = [];
|
|
2162
|
-
}
|
|
2163
|
-
return /* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1536
|
+
}, [c, e]);
|
|
1537
|
+
let a = e;
|
|
1538
|
+
return l.multi && !Array.isArray(e) && (a = []), /* @__PURE__ */ d(Zt, { asChild: !0, children: /* @__PURE__ */ d(
|
|
2164
1539
|
"select",
|
|
2165
1540
|
{
|
|
2166
|
-
...
|
|
2167
|
-
multiple:
|
|
2168
|
-
ref:
|
|
2169
|
-
defaultValue
|
|
1541
|
+
...t,
|
|
1542
|
+
multiple: l.multi ? !0 : void 0,
|
|
1543
|
+
ref: r,
|
|
1544
|
+
defaultValue: a
|
|
2170
1545
|
}
|
|
2171
1546
|
) });
|
|
2172
1547
|
}
|
|
2173
1548
|
);
|
|
2174
|
-
|
|
2175
|
-
function
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
handleSearchChange(search);
|
|
2183
|
-
(function updateSearch(value) {
|
|
2184
|
-
searchRef.current = value;
|
|
2185
|
-
window.clearTimeout(timerRef.current);
|
|
2186
|
-
if (value !== "")
|
|
2187
|
-
timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
2188
|
-
})(search);
|
|
1549
|
+
Wo.displayName = "BubbleSelect";
|
|
1550
|
+
function zt(o) {
|
|
1551
|
+
const i = Io(o), e = s.useRef(""), t = s.useRef(0), n = s.useCallback(
|
|
1552
|
+
(c) => {
|
|
1553
|
+
const l = e.current + c;
|
|
1554
|
+
i(l), function a(m) {
|
|
1555
|
+
e.current = m, window.clearTimeout(t.current), m !== "" && (t.current = window.setTimeout(() => a(""), 1e3));
|
|
1556
|
+
}(l);
|
|
2189
1557
|
},
|
|
2190
|
-
[
|
|
2191
|
-
)
|
|
2192
|
-
|
|
2193
|
-
searchRef.current = "";
|
|
2194
|
-
window.clearTimeout(timerRef.current);
|
|
1558
|
+
[i]
|
|
1559
|
+
), r = s.useCallback(() => {
|
|
1560
|
+
e.current = "", window.clearTimeout(t.current);
|
|
2195
1561
|
}, []);
|
|
2196
|
-
|
|
2197
|
-
return () => window.clearTimeout(timerRef.current);
|
|
2198
|
-
}, []);
|
|
2199
|
-
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
|
1562
|
+
return s.useEffect(() => () => window.clearTimeout(t.current), []), [e, n, r];
|
|
2200
1563
|
}
|
|
2201
|
-
function
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
if (excludeCurrentItem)
|
|
2208
|
-
wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
|
2209
|
-
const nextItem = wrappedItems.find((item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase()));
|
|
2210
|
-
return nextItem !== currentItem ? nextItem : void 0;
|
|
1564
|
+
function Kt(o, i, e) {
|
|
1565
|
+
const n = i.length > 1 && Array.from(i).every((m) => m === i[0]) ? i[0] : i, r = e ? o.indexOf(e) : -1;
|
|
1566
|
+
let c = zo(o, Math.max(r, 0));
|
|
1567
|
+
n.length === 1 && (c = c.filter((m) => m !== e));
|
|
1568
|
+
const a = c.find((m) => m.textValue.toLowerCase().startsWith(n.toLowerCase()));
|
|
1569
|
+
return a !== e ? a : void 0;
|
|
2211
1570
|
}
|
|
2212
|
-
function
|
|
2213
|
-
return
|
|
1571
|
+
function zo(o, i) {
|
|
1572
|
+
return o.map((e, t) => o[(i + t) % o.length]);
|
|
2214
1573
|
}
|
|
2215
|
-
const
|
|
2216
|
-
if (Array.isArray(
|
|
2217
|
-
return
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
return [...array, value];
|
|
2222
|
-
}
|
|
2223
|
-
return [...array.slice(0, index), ...array.slice(index + 1)];
|
|
2224
|
-
};
|
|
2225
|
-
const Root = Select;
|
|
2226
|
-
const Trigger = SelectTrigger;
|
|
2227
|
-
const Value = SelectValue;
|
|
2228
|
-
const Icon = SelectIcon;
|
|
2229
|
-
const Portal = SelectPortal;
|
|
2230
|
-
const Content = SelectContent;
|
|
2231
|
-
const Viewport = SelectViewport;
|
|
2232
|
-
const Group = SelectGroup;
|
|
2233
|
-
const Label = SelectLabel;
|
|
2234
|
-
const Item = SelectItem;
|
|
2235
|
-
const ItemText = SelectItemText;
|
|
2236
|
-
const ItemIndicator = SelectItemIndicator;
|
|
2237
|
-
const ScrollUpButton = SelectScrollUpButton;
|
|
2238
|
-
const ScrollDownButton = SelectScrollDownButton;
|
|
2239
|
-
const Separator = SelectSeparator;
|
|
2240
|
-
const Arrow = SelectArrow;
|
|
2241
|
-
const Select$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1574
|
+
const Gt = (o, i = []) => {
|
|
1575
|
+
if (Array.isArray(o))
|
|
1576
|
+
return o.reduce((t, n) => Gt(n, t), i);
|
|
1577
|
+
const e = i.indexOf(o);
|
|
1578
|
+
return e === -1 ? [...i, o] : [...i.slice(0, e), ...i.slice(e + 1)];
|
|
1579
|
+
}, Ko = $e, Go = Ue, jo = He, Yo = We, qo = ze, Xo = Ke, Zo = je, Jo = Ye, Qo = qe, en = Xe, tn = Ze, on = Je, nn = Qe, rn = et, ln = ot, sn = nt, An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2242
1580
|
__proto__: null,
|
|
2243
|
-
Arrow,
|
|
2244
|
-
Content,
|
|
2245
|
-
Group,
|
|
2246
|
-
Icon,
|
|
2247
|
-
Item,
|
|
2248
|
-
ItemIndicator,
|
|
2249
|
-
ItemText,
|
|
2250
|
-
Label,
|
|
2251
|
-
Portal,
|
|
2252
|
-
Root,
|
|
2253
|
-
ScrollDownButton,
|
|
2254
|
-
ScrollUpButton,
|
|
2255
|
-
Select,
|
|
2256
|
-
SelectArrow,
|
|
2257
|
-
SelectContent,
|
|
2258
|
-
SelectGroup,
|
|
2259
|
-
SelectIcon,
|
|
2260
|
-
SelectItem,
|
|
2261
|
-
SelectItemIndicator,
|
|
2262
|
-
SelectItemText,
|
|
2263
|
-
SelectLabel,
|
|
2264
|
-
SelectPortal,
|
|
2265
|
-
SelectScrollDownButton,
|
|
2266
|
-
SelectScrollUpButton,
|
|
2267
|
-
SelectSeparator,
|
|
2268
|
-
SelectTrigger,
|
|
2269
|
-
SelectValue,
|
|
2270
|
-
SelectViewport,
|
|
2271
|
-
Separator,
|
|
2272
|
-
Trigger,
|
|
2273
|
-
Value,
|
|
2274
|
-
Viewport,
|
|
2275
|
-
createSelectScope
|
|
1581
|
+
Arrow: sn,
|
|
1582
|
+
Content: Xo,
|
|
1583
|
+
Group: Jo,
|
|
1584
|
+
Icon: Yo,
|
|
1585
|
+
Item: en,
|
|
1586
|
+
ItemIndicator: on,
|
|
1587
|
+
ItemText: tn,
|
|
1588
|
+
Label: Qo,
|
|
1589
|
+
Portal: qo,
|
|
1590
|
+
Root: Ko,
|
|
1591
|
+
ScrollDownButton: rn,
|
|
1592
|
+
ScrollUpButton: nn,
|
|
1593
|
+
Select: $e,
|
|
1594
|
+
SelectArrow: nt,
|
|
1595
|
+
SelectContent: Ke,
|
|
1596
|
+
SelectGroup: Ye,
|
|
1597
|
+
SelectIcon: We,
|
|
1598
|
+
SelectItem: Xe,
|
|
1599
|
+
SelectItemIndicator: Je,
|
|
1600
|
+
SelectItemText: Ze,
|
|
1601
|
+
SelectLabel: qe,
|
|
1602
|
+
SelectPortal: ze,
|
|
1603
|
+
SelectScrollDownButton: et,
|
|
1604
|
+
SelectScrollUpButton: Qe,
|
|
1605
|
+
SelectSeparator: ot,
|
|
1606
|
+
SelectTrigger: Ue,
|
|
1607
|
+
SelectValue: He,
|
|
1608
|
+
SelectViewport: je,
|
|
1609
|
+
Separator: ln,
|
|
1610
|
+
Trigger: Go,
|
|
1611
|
+
Value: jo,
|
|
1612
|
+
Viewport: Zo,
|
|
1613
|
+
createSelectScope: Eo
|
|
2276
1614
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2277
|
-
function
|
|
2278
|
-
return function
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
return ourEventHandler?.(event);
|
|
2282
|
-
}
|
|
1615
|
+
function _n(o, i, { checkForDefaultPrevented: e = !0 } = {}) {
|
|
1616
|
+
return function(n) {
|
|
1617
|
+
if (o == null || o(n), e === !1 || !n.defaultPrevented)
|
|
1618
|
+
return i == null ? void 0 : i(n);
|
|
2283
1619
|
};
|
|
2284
1620
|
}
|
|
2285
1621
|
export {
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
composeEventHandlers,
|
|
2289
|
-
createCollection,
|
|
2290
|
-
useCallbackRef,
|
|
2291
|
-
useCollator,
|
|
2292
|
-
useFilter,
|
|
2293
|
-
usePrev
|
|
1622
|
+
Rn as Combobox,
|
|
1623
|
+
An as Select,
|
|
1624
|
+
_n as composeEventHandlers,
|
|
1625
|
+
Jt as createCollection,
|
|
1626
|
+
Io as useCallbackRef,
|
|
1627
|
+
Qt as useCollator,
|
|
1628
|
+
De as useFilter,
|
|
1629
|
+
eo as usePrev
|
|
2294
1630
|
};
|
|
2295
|
-
//# sourceMappingURL=index.mjs.map
|