@republicroad/seal-editor 1.24.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/field-picker-popup-DynXyvQG.js +2453 -0
- package/dist/field-picker-popup-DynXyvQG.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +6023 -5434
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils-CX-Pz5p6.js +10 -0
- package/dist/utils-CX-Pz5p6.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2453 @@
|
|
|
1
|
+
import { t as e } from "./utils-CX-Pz5p6.js";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
import { CheckIcon as a, ChevronDownIcon as o, ChevronLeftIcon as s, ChevronRightIcon as c, LoaderCircleIcon as l, MinusIcon as u, RotateCwIcon as d, XIcon as f } from "lucide-react";
|
|
5
|
+
import { mergeProps as p } from "@base-ui/react/merge-props";
|
|
6
|
+
import { useRender as m } from "@base-ui/react/use-render";
|
|
7
|
+
import { ScrollArea as h } from "@base-ui/react/scroll-area";
|
|
8
|
+
import { Combobox as g } from "@base-ui/react";
|
|
9
|
+
import { useDirection as _ } from "@base-ui/react/direction-provider";
|
|
10
|
+
//#region src/reui/scroll-area.tsx
|
|
11
|
+
function v({ className: t, children: n, ...a }) {
|
|
12
|
+
return /* @__PURE__ */ i(h.Root, {
|
|
13
|
+
"data-slot": "scroll-area",
|
|
14
|
+
className: e("relative", t),
|
|
15
|
+
...a,
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ r(h.Viewport, {
|
|
18
|
+
"data-slot": "scroll-area-viewport",
|
|
19
|
+
className: "size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",
|
|
20
|
+
children: n
|
|
21
|
+
}),
|
|
22
|
+
/* @__PURE__ */ r(y, {}),
|
|
23
|
+
/* @__PURE__ */ r(h.Corner, {})
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function y({ className: t, orientation: n = "vertical", ...i }) {
|
|
28
|
+
return /* @__PURE__ */ r(h.Scrollbar, {
|
|
29
|
+
"data-slot": "scroll-area-scrollbar",
|
|
30
|
+
orientation: n,
|
|
31
|
+
className: e("flex touch-none select-none p-px opacity-0 transition-opacity duration-150 data-[hovering]:opacity-100 data-[scrolling]:opacity-100", n === "vertical" ? "w-2.5 border-l border-l-transparent" : "h-2.5 border-t border-t-transparent", t),
|
|
32
|
+
...i,
|
|
33
|
+
children: /* @__PURE__ */ r(h.Thumb, {
|
|
34
|
+
"data-slot": "scroll-area-thumb",
|
|
35
|
+
className: "relative flex-1 rounded-full bg-border"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/reui/cascader/cascader-context.tsx
|
|
41
|
+
var b = t.createContext(void 0);
|
|
42
|
+
function x() {
|
|
43
|
+
let e = t.useContext(b);
|
|
44
|
+
if (!e) throw Error("useCascaderState must be used within a Cascader");
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
var S = t.createContext(void 0);
|
|
48
|
+
function C() {
|
|
49
|
+
let e = t.useContext(S);
|
|
50
|
+
if (!e) throw Error("useCascaderActions must be used within a Cascader");
|
|
51
|
+
return e;
|
|
52
|
+
}
|
|
53
|
+
var ee = t.createContext({});
|
|
54
|
+
function w() {
|
|
55
|
+
return t.useContext(ee);
|
|
56
|
+
}
|
|
57
|
+
var T = {
|
|
58
|
+
index: -1,
|
|
59
|
+
value: null
|
|
60
|
+
};
|
|
61
|
+
function E() {
|
|
62
|
+
let e = T, t = /* @__PURE__ */ new Set();
|
|
63
|
+
return {
|
|
64
|
+
subscribe(e) {
|
|
65
|
+
return t.add(e), () => {
|
|
66
|
+
t.delete(e);
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
getSnapshot() {
|
|
70
|
+
return e;
|
|
71
|
+
},
|
|
72
|
+
set(n) {
|
|
73
|
+
if (n.index !== e.index || n.value !== e.value) {
|
|
74
|
+
e = n;
|
|
75
|
+
for (let e of t) e();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var D = E(), O = t.createContext(D), k = "\0root", A = "\0more:", j = "max-h-[min(var(--available-height,100vh),var(--cascader-max-height,24rem))]", M = "[--cascader-list-pad:4px]", te = "size-full min-h-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain **:data-[slot=scroll-area-viewport]:scroll-py-[max(var(--cascader-list-pad,4px),4px)]", ne = "p-(--cascader-list-pad,4px) data-empty:p-0", re = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])", ie = "[data-slot=\"scroll-area-viewport\"]", ae = "[hidden],[inert],[aria-hidden='true']";
|
|
81
|
+
function N(e) {
|
|
82
|
+
return Array.from(e.querySelectorAll(re)).filter((e) => e.getAttribute("tabindex") !== "-1" && !e.matches(ie) && !e.closest(ae));
|
|
83
|
+
}
|
|
84
|
+
function oe(e) {
|
|
85
|
+
let t = e.matches("[data-slot=\"cascader-footer\"]") ? e : e.querySelector("[data-slot=\"cascader-footer\"]");
|
|
86
|
+
return t ? N(t) : [];
|
|
87
|
+
}
|
|
88
|
+
function se(e, t, n) {
|
|
89
|
+
let r = N(e);
|
|
90
|
+
if (r.length === 0 || !t) return null;
|
|
91
|
+
let i = r.indexOf(t);
|
|
92
|
+
if (i !== -1) return r[i + (n ? -1 : 1)] ?? null;
|
|
93
|
+
if (n) {
|
|
94
|
+
for (let e = r.length - 1; e >= 0; --e) if (t.compareDocumentPosition(r[e]) & Node.DOCUMENT_POSITION_PRECEDING) return r[e];
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
for (let e of r) if (t.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING) return e;
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
function P(e, t) {
|
|
101
|
+
if (t === "rtl") return !0;
|
|
102
|
+
let n = e.closest("[dir]")?.getAttribute("dir")?.toLowerCase();
|
|
103
|
+
return n === "rtl" || n !== "ltr" && e.ownerDocument?.defaultView?.getComputedStyle(e).direction === "rtl";
|
|
104
|
+
}
|
|
105
|
+
function F(e, t = 0) {
|
|
106
|
+
return {
|
|
107
|
+
value: `${A}${e}`,
|
|
108
|
+
label: "",
|
|
109
|
+
count: t
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function ce(e) {
|
|
113
|
+
return e.value.startsWith(A);
|
|
114
|
+
}
|
|
115
|
+
function le(e) {
|
|
116
|
+
return ce(e) ? e.value.slice(6) : null;
|
|
117
|
+
}
|
|
118
|
+
function ue(e, t) {
|
|
119
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [], s = (e, t) => {
|
|
120
|
+
let n = r.get(e);
|
|
121
|
+
n ? n.push(t) : r.set(e, [t]);
|
|
122
|
+
};
|
|
123
|
+
if (t) {
|
|
124
|
+
for (let t of e ?? []) {
|
|
125
|
+
if (t == null) {
|
|
126
|
+
process.env.NODE_ENV !== "production" && z("nullish-entry", "Ignored a null or undefined entry in `items` or `children`. Check the arrays you pass in.");
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
n.has(t.value) || (n.set(t.value, t), o.push(t));
|
|
130
|
+
}
|
|
131
|
+
for (let e of o) {
|
|
132
|
+
let r = t(e), a = r != null && n.has(r) ? r : null;
|
|
133
|
+
i.set(e.value, a), s(a ?? "\0root", e);
|
|
134
|
+
}
|
|
135
|
+
for (let e of o) {
|
|
136
|
+
let t = 0, n = i.get(e.value) ?? null, r = /* @__PURE__ */ new Set([e.value]);
|
|
137
|
+
for (; n != null && !r.has(n);) r.add(n), t += 1, n = i.get(n) ?? null;
|
|
138
|
+
a.set(e.value, t);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
let t = (e, r, c) => {
|
|
142
|
+
for (let l of e ?? []) {
|
|
143
|
+
if (l == null) {
|
|
144
|
+
process.env.NODE_ENV !== "production" && z("nullish-entry", "Ignored a null or undefined entry in `items` or `children`. Check the arrays you pass in.");
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
n.has(l.value) || (n.set(l.value, l), i.set(l.value, r), a.set(l.value, c), o.push(l), s(r ?? "\0root", l), l.children?.length && t(l.children, l.value, c + 1));
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
t(e, null, 0);
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
byValue: n,
|
|
154
|
+
childrenOf: r,
|
|
155
|
+
parentOf: i,
|
|
156
|
+
depthOf: a,
|
|
157
|
+
roots: r.get("\0root") ?? [],
|
|
158
|
+
all: o
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function de(e, t, n) {
|
|
162
|
+
if (t.size === 0 && !n?.size) return e;
|
|
163
|
+
let r = new Map(e.byValue), i = new Map(e.childrenOf), a = new Map(e.parentOf), o = new Map(e.depthOf), s = /* @__PURE__ */ new Set(), c = (e, t) => {
|
|
164
|
+
let n = i.get(e);
|
|
165
|
+
s.has(e) || (n = n ? n.slice() : [], i.set(e, n), s.add(e)), n.push(t);
|
|
166
|
+
}, l = (e, t) => {
|
|
167
|
+
for (let n of t) r.has(n.value) || (r.set(n.value, n), a.set(n.value, e === "\0root" ? null : e), c(e, n), n.children?.length && l(n.value, n.children));
|
|
168
|
+
};
|
|
169
|
+
for (let [e, n] of t) l(e, n);
|
|
170
|
+
for (let e of r.keys()) {
|
|
171
|
+
if (o.has(e)) continue;
|
|
172
|
+
let t = 0, n = a.get(e) ?? null, r = /* @__PURE__ */ new Set([e]);
|
|
173
|
+
for (; n != null && !r.has(n);) r.add(n), t += 1, n = a.get(n) ?? null;
|
|
174
|
+
o.set(e, t);
|
|
175
|
+
}
|
|
176
|
+
let u = i.get("\0root") ?? [], d = [], f = /* @__PURE__ */ new Set(), p = (e) => {
|
|
177
|
+
for (let t of e) {
|
|
178
|
+
if (f.has(t.value)) continue;
|
|
179
|
+
f.add(t.value), d.push(t);
|
|
180
|
+
let e = i.get(t.value);
|
|
181
|
+
e?.length && p(e);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
p(u);
|
|
185
|
+
for (let [e, t] of r) f.has(e) || (f.add(e), d.push(t));
|
|
186
|
+
if (n) for (let [e, t] of n) r.has(e) || r.set(e, t);
|
|
187
|
+
return {
|
|
188
|
+
byValue: r,
|
|
189
|
+
childrenOf: i,
|
|
190
|
+
parentOf: a,
|
|
191
|
+
depthOf: o,
|
|
192
|
+
roots: u,
|
|
193
|
+
all: d
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function fe(e, t) {
|
|
197
|
+
return e.childrenOf.get(t ?? "\0root") ?? [];
|
|
198
|
+
}
|
|
199
|
+
function pe(e, t) {
|
|
200
|
+
return t.hasChildren ? !0 : (e.childrenOf.get(t.value)?.length ?? 0) > 0;
|
|
201
|
+
}
|
|
202
|
+
function me(e, t) {
|
|
203
|
+
return typeof t.count == "number" ? t.count : e.childrenOf.get(t.value)?.length ?? 0;
|
|
204
|
+
}
|
|
205
|
+
function he(e, t) {
|
|
206
|
+
if (t.disabled || e.byValue.get(t.value)?.disabled) return !0;
|
|
207
|
+
let n = /* @__PURE__ */ new Set([t.value]), r = e.parentOf.get(t.value) ?? null;
|
|
208
|
+
for (; r != null && !n.has(r);) {
|
|
209
|
+
if (n.add(r), e.byValue.get(r)?.disabled) return !0;
|
|
210
|
+
r = e.parentOf.get(r) ?? null;
|
|
211
|
+
}
|
|
212
|
+
return !1;
|
|
213
|
+
}
|
|
214
|
+
function ge(e, t, n) {
|
|
215
|
+
return ce(t) || he(e, t) ? !1 : typeof n == "function" ? n(t) : n === "any" || !pe(e, t);
|
|
216
|
+
}
|
|
217
|
+
function _e(e, t) {
|
|
218
|
+
if (t == null) return [];
|
|
219
|
+
let n = [], r = /* @__PURE__ */ new Set(), i = t;
|
|
220
|
+
for (; i != null && !r.has(i);) {
|
|
221
|
+
r.add(i);
|
|
222
|
+
let t = e.byValue.get(i);
|
|
223
|
+
if (!t) break;
|
|
224
|
+
n.push(t), i = e.parentOf.get(i) ?? null;
|
|
225
|
+
}
|
|
226
|
+
return n.reverse();
|
|
227
|
+
}
|
|
228
|
+
function ve(e) {
|
|
229
|
+
return e.toLocaleLowerCase();
|
|
230
|
+
}
|
|
231
|
+
function ye(e) {
|
|
232
|
+
return ve(e.trim());
|
|
233
|
+
}
|
|
234
|
+
function be(e, t) {
|
|
235
|
+
if (!t || ve(e.label ?? "").includes(t)) return !0;
|
|
236
|
+
if (e.keywords) {
|
|
237
|
+
for (let n of e.keywords) if (ve(n).includes(t)) return !0;
|
|
238
|
+
}
|
|
239
|
+
return !1;
|
|
240
|
+
}
|
|
241
|
+
function I(e, t, n = be) {
|
|
242
|
+
let r = ye(t);
|
|
243
|
+
return r ? e.filter((e) => n(e, r)) : e;
|
|
244
|
+
}
|
|
245
|
+
function L(e, t, n = {}) {
|
|
246
|
+
let r = ye(t);
|
|
247
|
+
if (!r) return [];
|
|
248
|
+
let { within: i, limit: a = 200, matches: o = be } = n, s = [], c = i == null ? null : /* @__PURE__ */ new Map(), l = (t) => {
|
|
249
|
+
if (i == null || !c) return !0;
|
|
250
|
+
let n = [], r = !1, a = e.parentOf.get(t.value);
|
|
251
|
+
for (; a != null;) {
|
|
252
|
+
if (a === i) {
|
|
253
|
+
r = !0;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
let t = c.get(a);
|
|
257
|
+
if (t !== void 0) {
|
|
258
|
+
r = t;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
c.set(a, !1), n.push(a), a = e.parentOf.get(a) ?? null;
|
|
262
|
+
}
|
|
263
|
+
if (r) for (let e of n) c.set(e, !0);
|
|
264
|
+
return r;
|
|
265
|
+
};
|
|
266
|
+
for (let t of e.all) {
|
|
267
|
+
if (s.length >= a) break;
|
|
268
|
+
o(t, r) && l(t) && s.push(t);
|
|
269
|
+
}
|
|
270
|
+
return s;
|
|
271
|
+
}
|
|
272
|
+
function R(e, t, n) {
|
|
273
|
+
let r = [], i = (a, o, s) => {
|
|
274
|
+
let c = n?.has(o) ?? !1, l = a.length + +!!c;
|
|
275
|
+
for (let n = 0; n < a.length; n += 1) {
|
|
276
|
+
let o = a[n], c = pe(e, o), u = c && t.has(o.value);
|
|
277
|
+
r.push({
|
|
278
|
+
node: o,
|
|
279
|
+
depth: s,
|
|
280
|
+
branch: c,
|
|
281
|
+
expanded: u,
|
|
282
|
+
setSize: l,
|
|
283
|
+
posInSet: n + 1
|
|
284
|
+
}), u && i(e.childrenOf.get(o.value) ?? [], o.value, s + 1);
|
|
285
|
+
}
|
|
286
|
+
c && r.push({
|
|
287
|
+
node: F(o, a.length),
|
|
288
|
+
depth: s,
|
|
289
|
+
branch: !1,
|
|
290
|
+
expanded: !1,
|
|
291
|
+
setSize: l,
|
|
292
|
+
posInSet: l
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
return i(e.roots, k, 0), r;
|
|
296
|
+
}
|
|
297
|
+
function xe(e, t = {}) {
|
|
298
|
+
let { maxSegments: n = 3, collapse: r = "middle" } = t, i = (e) => e.map((e) => ({
|
|
299
|
+
type: "node",
|
|
300
|
+
node: e
|
|
301
|
+
}));
|
|
302
|
+
if (r === "none" || n <= 0 || e.length <= n) return i(e);
|
|
303
|
+
if (r === "start") {
|
|
304
|
+
let t = e.slice(e.length - n);
|
|
305
|
+
return [{
|
|
306
|
+
type: "ellipsis",
|
|
307
|
+
hidden: e.slice(0, e.length - n)
|
|
308
|
+
}, ...i(t)];
|
|
309
|
+
}
|
|
310
|
+
let a = e.slice(0, 1), o = n - 1, s = e.slice(e.length - o), c = e.slice(1, e.length - o);
|
|
311
|
+
return c.length === 0 ? i(e) : [
|
|
312
|
+
...i(a),
|
|
313
|
+
{
|
|
314
|
+
type: "ellipsis",
|
|
315
|
+
hidden: c
|
|
316
|
+
},
|
|
317
|
+
...i(s)
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
function Se(e, t) {
|
|
321
|
+
let n = e.byValue.get(t);
|
|
322
|
+
if (!n) return [];
|
|
323
|
+
let r = [], i = /* @__PURE__ */ new Set(), a = (t) => {
|
|
324
|
+
if (i.has(t.value)) return;
|
|
325
|
+
i.add(t.value), r.push(t);
|
|
326
|
+
let n = e.childrenOf.get(t.value);
|
|
327
|
+
if (n) for (let e of n) a(e);
|
|
328
|
+
};
|
|
329
|
+
return a(n), r;
|
|
330
|
+
}
|
|
331
|
+
function Ce(e, t, n, r, i = () => !0) {
|
|
332
|
+
let a = new Set(t), o = Se(e, n);
|
|
333
|
+
o.length === 0 && (r ? a.add(n) : a.delete(n));
|
|
334
|
+
for (let e of o) (e.value === n || i(e)) && (r ? a.add(e.value) : a.delete(e.value));
|
|
335
|
+
let s = /* @__PURE__ */ new Set([n]), c = e.parentOf.get(n) ?? null;
|
|
336
|
+
for (; c != null && !s.has(c);) {
|
|
337
|
+
s.add(c);
|
|
338
|
+
let t = e.byValue.get(c), n = (e.childrenOf.get(c) ?? []).filter((e) => i(e));
|
|
339
|
+
n.length > 0 && n.every((e) => a.has(e.value)) && t && i(t) ? a.add(c) : a.delete(c), c = e.parentOf.get(c) ?? null;
|
|
340
|
+
}
|
|
341
|
+
return Array.from(a);
|
|
342
|
+
}
|
|
343
|
+
function we(e, t) {
|
|
344
|
+
let n = /* @__PURE__ */ new Map();
|
|
345
|
+
for (let r of t) {
|
|
346
|
+
let t = /* @__PURE__ */ new Set([r]), i = e.parentOf.get(r) ?? null;
|
|
347
|
+
for (; i != null && !t.has(i);) t.add(i), n.set(i, (n.get(i) ?? 0) + 1), i = e.parentOf.get(i) ?? null;
|
|
348
|
+
}
|
|
349
|
+
return n;
|
|
350
|
+
}
|
|
351
|
+
function Te(e, t) {
|
|
352
|
+
let n = new Set(t), r = /* @__PURE__ */ new Set();
|
|
353
|
+
for (let [t, i] of e) i > 0 && !n.has(t) && r.add(t);
|
|
354
|
+
return r;
|
|
355
|
+
}
|
|
356
|
+
var Ee = /* @__PURE__ */ new Set();
|
|
357
|
+
function z(e, t) {
|
|
358
|
+
process.env.NODE_ENV !== "production" && (Ee.has(e) || (Ee.add(e), console.warn(`[Cascader] ${t}`)));
|
|
359
|
+
}
|
|
360
|
+
function De(e, t) {
|
|
361
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = [], a = (e) => {
|
|
362
|
+
for (let t of e ?? []) t != null && (n.has(t.value) ? r.add(t.value) : n.add(t.value), i.push(t), t.children?.length && a(t.children));
|
|
363
|
+
};
|
|
364
|
+
a(e);
|
|
365
|
+
let o = [];
|
|
366
|
+
if (t) {
|
|
367
|
+
let e = /* @__PURE__ */ new Map();
|
|
368
|
+
for (let r of i) {
|
|
369
|
+
if (e.has(r.value)) continue;
|
|
370
|
+
let i = t(r);
|
|
371
|
+
e.set(r.value, i != null && n.has(i) ? i : null);
|
|
372
|
+
}
|
|
373
|
+
for (let t of i) {
|
|
374
|
+
let n = /* @__PURE__ */ new Set([t.value]), r = e.get(t.value) ?? null;
|
|
375
|
+
for (; r != null;) {
|
|
376
|
+
if (n.has(r)) {
|
|
377
|
+
o.push(t.value);
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
n.add(r), r = e.get(r) ?? null;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
duplicates: Array.from(r),
|
|
386
|
+
cycles: o
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/reui/cascader/cascader-async.tsx
|
|
391
|
+
var Oe = 150, ke = "\0search", B = "\0resolve:", Ae = {
|
|
392
|
+
loading: !1,
|
|
393
|
+
error: !1,
|
|
394
|
+
hasMore: !1
|
|
395
|
+
}, je = [];
|
|
396
|
+
function Me() {
|
|
397
|
+
return {
|
|
398
|
+
pages: /* @__PURE__ */ new Map(),
|
|
399
|
+
states: /* @__PURE__ */ new Map(),
|
|
400
|
+
detached: /* @__PURE__ */ new Map()
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function Ne(e, t) {
|
|
404
|
+
return e.loading === t.loading && e.error === t.error && e.hasMore === t.hasMore && e.cursor === t.cursor;
|
|
405
|
+
}
|
|
406
|
+
function Pe(e, t, n) {
|
|
407
|
+
let r = e.states.get(t) ?? Ae, i = n(r);
|
|
408
|
+
if (e.states.has(t) && Ne(r, i)) return e;
|
|
409
|
+
let a = new Map(e.states);
|
|
410
|
+
return a.set(t, i), {
|
|
411
|
+
pages: e.pages,
|
|
412
|
+
states: a,
|
|
413
|
+
detached: e.detached
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function Fe(e, t, n, r) {
|
|
417
|
+
let i = r.append ? e.pages.get(t) ?? [] : [], a = new Set(i.map((e) => e.value)), o = i.slice();
|
|
418
|
+
for (let e of n) a.has(e.value) || (a.add(e.value), o.push(e));
|
|
419
|
+
let s = new Map(e.pages);
|
|
420
|
+
s.set(t, o);
|
|
421
|
+
let c = new Map(e.states);
|
|
422
|
+
return c.set(t, {
|
|
423
|
+
loading: !1,
|
|
424
|
+
error: !1,
|
|
425
|
+
hasMore: r.hasMore,
|
|
426
|
+
cursor: r.cursor
|
|
427
|
+
}), {
|
|
428
|
+
pages: s,
|
|
429
|
+
states: c,
|
|
430
|
+
detached: e.detached
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function Ie(e, t) {
|
|
434
|
+
let n = null;
|
|
435
|
+
for (let r of t) e.detached.get(r.value) !== r && (n ??= new Map(e.detached), n.set(r.value, r));
|
|
436
|
+
return n ? {
|
|
437
|
+
pages: e.pages,
|
|
438
|
+
states: e.states,
|
|
439
|
+
detached: n
|
|
440
|
+
} : e;
|
|
441
|
+
}
|
|
442
|
+
function Le(e, t) {
|
|
443
|
+
if (t.length === 0) return e;
|
|
444
|
+
let n = new Map(e.pages), r = new Map(e.detached), i = k;
|
|
445
|
+
for (let e of t) {
|
|
446
|
+
let t = n.get(i);
|
|
447
|
+
t ? t.some((t) => t.value === e.value) || n.set(i, [...t, e]) : n.set(i, [e]), r.set(e.value, e), i = e.value;
|
|
448
|
+
}
|
|
449
|
+
return {
|
|
450
|
+
pages: n,
|
|
451
|
+
states: e.states,
|
|
452
|
+
detached: r
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function Re({ base: e, getChildren: n, onSearch: r, resolveValue: i, searchDebounce: a = 250, loadKey: o, prefetch: s = !1, onLoadError: c, enabled: l, query: u, levels: d, path: f, values: p }) {
|
|
456
|
+
let [m, h] = t.useState(Me), [g, _] = t.useState(null), v = t.useRef({
|
|
457
|
+
base: e,
|
|
458
|
+
store: m,
|
|
459
|
+
getChildren: n,
|
|
460
|
+
onSearch: r,
|
|
461
|
+
resolveValue: i,
|
|
462
|
+
onLoadError: c,
|
|
463
|
+
prefetch: s,
|
|
464
|
+
path: f
|
|
465
|
+
});
|
|
466
|
+
t.useEffect(() => {
|
|
467
|
+
v.current = {
|
|
468
|
+
base: e,
|
|
469
|
+
store: m,
|
|
470
|
+
getChildren: n,
|
|
471
|
+
onSearch: r,
|
|
472
|
+
resolveValue: i,
|
|
473
|
+
onLoadError: c,
|
|
474
|
+
prefetch: s,
|
|
475
|
+
path: f
|
|
476
|
+
};
|
|
477
|
+
});
|
|
478
|
+
let y = t.useRef(/* @__PURE__ */ new Map()), b = t.useRef(/* @__PURE__ */ new Map()), x = t.useRef(/* @__PURE__ */ new Map()), S = t.useRef(/* @__PURE__ */ new Map()), C = t.useRef(/* @__PURE__ */ new Set()), ee = t.useRef(/* @__PURE__ */ new Map()), w = t.useRef({ prefetch: null }), T = t.useRef(0), E = t.useCallback((e) => {
|
|
479
|
+
let t = ee.current, n = (e) => {
|
|
480
|
+
for (let r of e) t.set(r.value, r), r.children?.length && n(r.children);
|
|
481
|
+
};
|
|
482
|
+
n(e);
|
|
483
|
+
}, []), D = t.useCallback((e) => {
|
|
484
|
+
let t = y.current.get(e);
|
|
485
|
+
t && (y.current.delete(e), x.current.delete(e), t.abort());
|
|
486
|
+
}, []), O = t.useCallback((e, t, n, r) => {
|
|
487
|
+
let { getChildren: i, base: a } = v.current;
|
|
488
|
+
if (!i) return;
|
|
489
|
+
let o = `${r ? "1" : "0"}:${n ?? ""}`;
|
|
490
|
+
if (x.current.get(e) === o) return;
|
|
491
|
+
D(e);
|
|
492
|
+
let s = new AbortController();
|
|
493
|
+
y.current.set(e, s), x.current.set(e, o);
|
|
494
|
+
let c = (b.current.get(e) ?? 0) + 1;
|
|
495
|
+
b.current.set(e, c);
|
|
496
|
+
let l = T.current, u = e === "\0root" ? null : a.byValue.get(e) ?? ee.current.get(e) ?? null;
|
|
497
|
+
h((t) => Pe(t, e, (e) => ({
|
|
498
|
+
...e,
|
|
499
|
+
loading: !0,
|
|
500
|
+
error: !1
|
|
501
|
+
})));
|
|
502
|
+
let d = () => {
|
|
503
|
+
x.current.get(e) === o && x.current.delete(e), y.current.get(e) === s && y.current.delete(e);
|
|
504
|
+
}, f = () => s.signal.aborted || l !== T.current || c !== b.current.get(e);
|
|
505
|
+
Promise.resolve().then(() => i(u, {
|
|
506
|
+
signal: s.signal,
|
|
507
|
+
cursor: n,
|
|
508
|
+
reason: t
|
|
509
|
+
})).then((t) => {
|
|
510
|
+
if (d(), f()) return;
|
|
511
|
+
let n = Array.isArray(t) ? t : t.items, i = Array.isArray(t) ? void 0 : t.nextCursor, a = Array.isArray(t) ? !1 : t.hasMore ?? i != null;
|
|
512
|
+
r || S.current.delete(e), E(n), h((t) => Fe(t, e, n, {
|
|
513
|
+
append: r,
|
|
514
|
+
hasMore: a,
|
|
515
|
+
cursor: i
|
|
516
|
+
}));
|
|
517
|
+
}).catch((n) => {
|
|
518
|
+
d(), !f() && (h((t) => Pe(t, e, (e) => ({
|
|
519
|
+
...e,
|
|
520
|
+
loading: !1,
|
|
521
|
+
error: !0
|
|
522
|
+
}))), v.current.onLoadError?.(n, {
|
|
523
|
+
parent: e === "\0root" ? null : e,
|
|
524
|
+
reason: t
|
|
525
|
+
}));
|
|
526
|
+
});
|
|
527
|
+
}, [D, E]), k = t.useCallback((e, t) => {
|
|
528
|
+
let { getChildren: n, store: r, base: i } = v.current;
|
|
529
|
+
n && (r.states.has(e) || i.childrenOf.has(e) || O(e, t, void 0, !1));
|
|
530
|
+
}, [O]), A = t.useCallback((e) => {
|
|
531
|
+
let { getChildren: t, store: n } = v.current;
|
|
532
|
+
if (!t) return;
|
|
533
|
+
let r = n.states.get(e);
|
|
534
|
+
if (!r || r.loading || !r.hasMore) return;
|
|
535
|
+
let i = `${n.pages.get(e)?.length ?? 0}:${r.cursor ?? ""}`;
|
|
536
|
+
S.current.get(e) !== i && (S.current.set(e, i), O(e, "more", r.cursor, !0));
|
|
537
|
+
}, [O]), j = t.useCallback((e) => {
|
|
538
|
+
let { getChildren: t, store: n } = v.current;
|
|
539
|
+
if (!t) return;
|
|
540
|
+
let r = n.states.get(e);
|
|
541
|
+
if (!r?.error) return;
|
|
542
|
+
let i = n.pages.get(e)?.length ?? 0;
|
|
543
|
+
S.current.delete(e), O(e, "retry", i > 0 ? r.cursor : void 0, i > 0);
|
|
544
|
+
}, [O]), M = t.useCallback((e) => {
|
|
545
|
+
let t = e ?? "\0root";
|
|
546
|
+
D(t), b.current.set(t, (b.current.get(t) ?? 0) + 1), S.current.delete(t), h((e) => {
|
|
547
|
+
if (!e.states.has(t) && !e.pages.has(t)) return e;
|
|
548
|
+
let n = new Map(e.states);
|
|
549
|
+
n.delete(t);
|
|
550
|
+
let r = new Map(e.pages);
|
|
551
|
+
return r.delete(t), {
|
|
552
|
+
pages: r,
|
|
553
|
+
states: n,
|
|
554
|
+
detached: e.detached
|
|
555
|
+
};
|
|
556
|
+
});
|
|
557
|
+
}, [D]), te = t.useCallback((e) => {
|
|
558
|
+
let { prefetch: t, getChildren: n, store: r } = v.current;
|
|
559
|
+
if (!t || !n || !e || ce(e) || !e.hasChildren || r.states.has(e.value)) return;
|
|
560
|
+
let i = w.current;
|
|
561
|
+
i.prefetch && clearTimeout(i.prefetch), i.prefetch = setTimeout(() => {
|
|
562
|
+
i.prefetch = null, k(e.value, "prefetch");
|
|
563
|
+
}, Oe);
|
|
564
|
+
}, [k]), ne = t.useCallback((e) => {
|
|
565
|
+
let { onSearch: t, path: n } = v.current;
|
|
566
|
+
if (!t) return;
|
|
567
|
+
D(ke);
|
|
568
|
+
let r = new AbortController();
|
|
569
|
+
y.current.set(ke, r);
|
|
570
|
+
let i = (b.current.get(ke) ?? 0) + 1;
|
|
571
|
+
b.current.set(ke, i);
|
|
572
|
+
let a = T.current;
|
|
573
|
+
_((t) => ({
|
|
574
|
+
query: e,
|
|
575
|
+
results: t?.results ?? [],
|
|
576
|
+
loading: !0,
|
|
577
|
+
error: !1
|
|
578
|
+
}));
|
|
579
|
+
let o = () => {
|
|
580
|
+
y.current.get(ke) === r && y.current.delete(ke);
|
|
581
|
+
}, s = () => r.signal.aborted || a !== T.current || i !== b.current.get(ke);
|
|
582
|
+
Promise.resolve().then(() => t(e, {
|
|
583
|
+
signal: r.signal,
|
|
584
|
+
path: n
|
|
585
|
+
})).then((t) => {
|
|
586
|
+
if (o(), s()) return;
|
|
587
|
+
let n = Array.isArray(t) ? t : t.items;
|
|
588
|
+
E(n), h((e) => Ie(e, n)), _({
|
|
589
|
+
query: e,
|
|
590
|
+
results: n,
|
|
591
|
+
loading: !1,
|
|
592
|
+
error: !1
|
|
593
|
+
});
|
|
594
|
+
}).catch((t) => {
|
|
595
|
+
o(), !s() && (_((t) => ({
|
|
596
|
+
query: e,
|
|
597
|
+
results: t?.results ?? [],
|
|
598
|
+
loading: !1,
|
|
599
|
+
error: !0
|
|
600
|
+
})), v.current.onLoadError?.(t, {
|
|
601
|
+
parent: null,
|
|
602
|
+
reason: "search"
|
|
603
|
+
}));
|
|
604
|
+
});
|
|
605
|
+
}, [D, E]), re = t.useCallback((e) => {
|
|
606
|
+
let { resolveValue: t } = v.current;
|
|
607
|
+
if (!t) return;
|
|
608
|
+
let n = `${B}${e}`;
|
|
609
|
+
D(n);
|
|
610
|
+
let r = new AbortController();
|
|
611
|
+
y.current.set(n, r);
|
|
612
|
+
let i = T.current, a = () => {
|
|
613
|
+
y.current.get(n) === r && y.current.delete(n);
|
|
614
|
+
};
|
|
615
|
+
Promise.resolve().then(() => t(e, {
|
|
616
|
+
signal: r.signal,
|
|
617
|
+
reason: "resolve"
|
|
618
|
+
})).then((e) => {
|
|
619
|
+
a(), !(r.signal.aborted || i !== T.current) && e?.length && (E(e), h((t) => Le(t, e)));
|
|
620
|
+
}).catch((t) => {
|
|
621
|
+
a(), C.current.delete(e), !(r.signal.aborted || i !== T.current) && v.current.onLoadError?.(t, {
|
|
622
|
+
parent: null,
|
|
623
|
+
reason: "resolve"
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
}, [D, E]), ie = t.useCallback(() => {
|
|
627
|
+
let e = Array.from(y.current.keys());
|
|
628
|
+
for (let e of y.current.values()) e.abort();
|
|
629
|
+
y.current.clear(), x.current.clear();
|
|
630
|
+
let t = w.current;
|
|
631
|
+
t.prefetch &&= (clearTimeout(t.prefetch), null), e.length !== 0 && (h((t) => {
|
|
632
|
+
let n = null;
|
|
633
|
+
for (let r of e) {
|
|
634
|
+
let e = t.states.get(r);
|
|
635
|
+
e?.loading && (n ??= new Map(t.states), (t.pages.get(r)?.length ?? 0) > 0 ? n.set(r, {
|
|
636
|
+
...e,
|
|
637
|
+
loading: !1
|
|
638
|
+
}) : n.delete(r));
|
|
639
|
+
}
|
|
640
|
+
return n ? {
|
|
641
|
+
...t,
|
|
642
|
+
states: n
|
|
643
|
+
} : t;
|
|
644
|
+
}), _((e) => e?.loading ? {
|
|
645
|
+
...e,
|
|
646
|
+
loading: !1
|
|
647
|
+
} : e));
|
|
648
|
+
}, []), ae = t.useRef(null);
|
|
649
|
+
t.useEffect(() => {
|
|
650
|
+
let e = ae.current;
|
|
651
|
+
if (ae.current = { key: o }, !e || Object.is(e.key, o)) return;
|
|
652
|
+
T.current += 1;
|
|
653
|
+
for (let e of y.current.values()) e.abort();
|
|
654
|
+
y.current.clear(), x.current.clear(), S.current.clear(), C.current.clear(), ee.current.clear();
|
|
655
|
+
let t = w.current;
|
|
656
|
+
t.prefetch &&= (clearTimeout(t.prefetch), null), h(Me), _(null);
|
|
657
|
+
}, [o]), t.useEffect(() => {
|
|
658
|
+
l || y.current.size !== 0 && ie();
|
|
659
|
+
}, [l, ie]), t.useEffect(() => {
|
|
660
|
+
let e = y.current, t = w.current, n = x.current, r = b.current;
|
|
661
|
+
return () => {
|
|
662
|
+
for (let t of e.values()) t.abort();
|
|
663
|
+
e.clear(), n.clear(), r.clear(), t.prefetch && clearTimeout(t.prefetch);
|
|
664
|
+
};
|
|
665
|
+
}, []);
|
|
666
|
+
let N = typeof n == "function", oe = typeof r == "function", se = typeof i == "function", P = u.trim(), F = JSON.stringify(d), le = JSON.stringify(p);
|
|
667
|
+
t.useEffect(() => {
|
|
668
|
+
if (l && N) for (let e of d) k(e, "level");
|
|
669
|
+
}, [
|
|
670
|
+
l,
|
|
671
|
+
N,
|
|
672
|
+
F,
|
|
673
|
+
m,
|
|
674
|
+
k
|
|
675
|
+
]), t.useEffect(() => {
|
|
676
|
+
if (!oe) return;
|
|
677
|
+
if (!l || !P) {
|
|
678
|
+
D(ke), _((e) => e === null ? e : null);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
let e = setTimeout(() => ne(P), a);
|
|
682
|
+
return () => {
|
|
683
|
+
clearTimeout(e), D(ke);
|
|
684
|
+
};
|
|
685
|
+
}, [
|
|
686
|
+
oe,
|
|
687
|
+
l,
|
|
688
|
+
P,
|
|
689
|
+
a,
|
|
690
|
+
D,
|
|
691
|
+
ne
|
|
692
|
+
]), t.useEffect(() => {
|
|
693
|
+
if (l && se) for (let t of p) t && (C.current.has(t) || e.byValue.has(t) || ee.current.has(t) || (C.current.add(t), re(t)));
|
|
694
|
+
}, [
|
|
695
|
+
l,
|
|
696
|
+
se,
|
|
697
|
+
le,
|
|
698
|
+
e,
|
|
699
|
+
re
|
|
700
|
+
]);
|
|
701
|
+
let ue = t.useMemo(() => !oe || !P ? null : !g || g.query !== P ? je : g.results, [
|
|
702
|
+
oe,
|
|
703
|
+
P,
|
|
704
|
+
g
|
|
705
|
+
]), de = t.useMemo(() => {
|
|
706
|
+
if (!oe || !P) return null;
|
|
707
|
+
let e = g?.query === P;
|
|
708
|
+
return {
|
|
709
|
+
loading: !e || !!g?.loading,
|
|
710
|
+
error: e && !!g?.error,
|
|
711
|
+
hasMore: !1
|
|
712
|
+
};
|
|
713
|
+
}, [
|
|
714
|
+
oe,
|
|
715
|
+
P,
|
|
716
|
+
g
|
|
717
|
+
]);
|
|
718
|
+
return t.useMemo(() => ({
|
|
719
|
+
active: N,
|
|
720
|
+
store: m,
|
|
721
|
+
states: m.states,
|
|
722
|
+
searchResults: ue,
|
|
723
|
+
searchState: de,
|
|
724
|
+
ensureLevel: k,
|
|
725
|
+
loadMore: A,
|
|
726
|
+
retryLevel: j,
|
|
727
|
+
invalidateLevel: M,
|
|
728
|
+
prefetchNode: te
|
|
729
|
+
}), [
|
|
730
|
+
N,
|
|
731
|
+
m,
|
|
732
|
+
ue,
|
|
733
|
+
de,
|
|
734
|
+
k,
|
|
735
|
+
A,
|
|
736
|
+
j,
|
|
737
|
+
M,
|
|
738
|
+
te
|
|
739
|
+
]);
|
|
740
|
+
}
|
|
741
|
+
function ze(e) {
|
|
742
|
+
let { loadStates: t } = x();
|
|
743
|
+
return t.get(e ?? "\0root") ?? null;
|
|
744
|
+
}
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region src/reui/cascader/cascader-i18n.tsx
|
|
747
|
+
var Be = "Top level", V = (e) => `${e} ${e === 1 ? "item" : "items"}`, Ve = {
|
|
748
|
+
search: (e) => e ? `Search ${e}...` : "Search...",
|
|
749
|
+
back: "Back",
|
|
750
|
+
loading: "Loading...",
|
|
751
|
+
loadingMore: "Loading more...",
|
|
752
|
+
loadMore: "Load more",
|
|
753
|
+
error: "Could not load items.",
|
|
754
|
+
retry: "Retry",
|
|
755
|
+
empty: "No results found.",
|
|
756
|
+
selectedCount: (e) => `${e} selected`,
|
|
757
|
+
breadcrumbLabel: "Breadcrumb",
|
|
758
|
+
chipsLabel: "Selected items",
|
|
759
|
+
removeChip: (e) => `Remove ${e}`,
|
|
760
|
+
pathSeparator: "/",
|
|
761
|
+
rootLevel: Be,
|
|
762
|
+
itemCount: V,
|
|
763
|
+
branchAffordance: "submenu",
|
|
764
|
+
selectedState: "selected",
|
|
765
|
+
partiallySelectedState: "partially selected",
|
|
766
|
+
columnsLabel: "Levels",
|
|
767
|
+
actionsLabel: "Actions",
|
|
768
|
+
submenuAffordance: "opens a menu",
|
|
769
|
+
panelLabel: "Options",
|
|
770
|
+
keyboardHint: (e, t) => {
|
|
771
|
+
let n = t === "rtl" ? "Left" : "Right", r = t === "rtl" ? "Right" : "Left";
|
|
772
|
+
return e === "tree" ? `Use the ${n} Arrow key to expand and the ${r} Arrow key to collapse.` : e === "columns" ? `Use the ${n} Arrow key to open the next column and the ${r} Arrow key to go back.` : `Use the ${n} Arrow key to open a branch and the ${r} Arrow key to go back.`;
|
|
773
|
+
},
|
|
774
|
+
rootAnnouncement: (e) => `${Be}, ${V(e)}`,
|
|
775
|
+
expandedAnnouncement: (e, t) => `${e} expanded, ${V(t)}`,
|
|
776
|
+
collapsedAnnouncement: (e) => `${e} collapsed`,
|
|
777
|
+
levelAnnouncement: (e, t, n) => `${e}, level ${t}, ${V(n)}`,
|
|
778
|
+
resultsAnnouncement: (e) => e === 1 ? "1 result" : `${e} results`,
|
|
779
|
+
maxReachedAnnouncement: (e) => `Selection limit of ${e} reached`,
|
|
780
|
+
cascadeAnnouncement: (e, t, n) => `${e} ${n ? "selected" : "deselected"}, ${V(t)} followed`,
|
|
781
|
+
searchingAnnouncement: "Searching..."
|
|
782
|
+
};
|
|
783
|
+
function He(e) {
|
|
784
|
+
return e ? {
|
|
785
|
+
...Ve,
|
|
786
|
+
...e
|
|
787
|
+
} : Ve;
|
|
788
|
+
}
|
|
789
|
+
function Ue(e, t) {
|
|
790
|
+
return typeof e.search == "function" ? e.search(t) : e.search;
|
|
791
|
+
}
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/reui/cascader/icon-placeholder.tsx
|
|
794
|
+
var H = {
|
|
795
|
+
CheckIcon: a,
|
|
796
|
+
ChevronDownIcon: o,
|
|
797
|
+
ChevronLeftIcon: s,
|
|
798
|
+
ChevronRightIcon: c,
|
|
799
|
+
LoaderCircleIcon: l,
|
|
800
|
+
MinusIcon: u,
|
|
801
|
+
RotateCwIcon: d,
|
|
802
|
+
XIcon: f
|
|
803
|
+
};
|
|
804
|
+
function U({ lucide: e, tabler: t, hugeicons: n, phosphor: i, remixicon: a, ...o }) {
|
|
805
|
+
let s = H[e] ?? c;
|
|
806
|
+
return /* @__PURE__ */ r(s, { ...o });
|
|
807
|
+
}
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/reui/cascader/cascader.tsx
|
|
810
|
+
var We = [], Ge = [], Ke = [], qe = "", Je = 150;
|
|
811
|
+
function Ye(e, n, r, i) {
|
|
812
|
+
let [a, o] = t.useState(n), s = e !== void 0, c = s ? e : a, l = t.useRef(s);
|
|
813
|
+
t.useEffect(() => {
|
|
814
|
+
if (process.env.NODE_ENV === "production" || l.current === s || !i) return;
|
|
815
|
+
let e = l.current ? "controlled" : "uncontrolled", t = s ? "controlled" : "uncontrolled";
|
|
816
|
+
l.current = s, z(`controlled-switch:${i}`, `\`${i}\` switched from ${e} to ${t}. Decide once: pass \`${i}\` for the whole life of the component, or pass only the default and let the cascader own it.`);
|
|
817
|
+
}, [s, i]);
|
|
818
|
+
let u = t.useRef({
|
|
819
|
+
value: c,
|
|
820
|
+
isControlled: s,
|
|
821
|
+
onChange: r
|
|
822
|
+
});
|
|
823
|
+
t.useEffect(() => {
|
|
824
|
+
u.current = {
|
|
825
|
+
value: c,
|
|
826
|
+
isControlled: s,
|
|
827
|
+
onChange: r
|
|
828
|
+
};
|
|
829
|
+
});
|
|
830
|
+
let d = t.useRef(e);
|
|
831
|
+
return t.useEffect(() => {
|
|
832
|
+
d.current = e;
|
|
833
|
+
}), [c, t.useCallback((e) => {
|
|
834
|
+
let t = u.current.value, n = typeof e == "function" ? e(t) : e;
|
|
835
|
+
(!Object.is(n, t) || u.current.isControlled && !Object.is(n, d.current)) && (u.current = {
|
|
836
|
+
...u.current,
|
|
837
|
+
value: n
|
|
838
|
+
}, u.current.isControlled || o(n), u.current.onChange?.(n));
|
|
839
|
+
}, [])];
|
|
840
|
+
}
|
|
841
|
+
function Xe(e, t) {
|
|
842
|
+
let n = e, r = t, i = Object.keys(n);
|
|
843
|
+
if (i.length !== Object.keys(r).length) return !1;
|
|
844
|
+
for (let e of i) if (!Object.is(n[e], r[e])) return !1;
|
|
845
|
+
return !0;
|
|
846
|
+
}
|
|
847
|
+
function Ze(e, t) {
|
|
848
|
+
if (e.length !== t.length) return !1;
|
|
849
|
+
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n] && !Xe(e[n], t[n])) return !1;
|
|
850
|
+
return !0;
|
|
851
|
+
}
|
|
852
|
+
function Qe(e, n) {
|
|
853
|
+
let [r, i] = t.useState(e);
|
|
854
|
+
return Object.is(e, r) || typeof e == "object" && e && typeof r == "object" && r && n(e, r) ? r : (i(e), e);
|
|
855
|
+
}
|
|
856
|
+
function $e(e) {
|
|
857
|
+
return e == null ? [] : Array.isArray(e) ? e.filter((e) => e !== "") : e === "" ? [] : [e];
|
|
858
|
+
}
|
|
859
|
+
function et(e) {
|
|
860
|
+
let { items: n, getParent: r, mode: i, multiple: a, cascade: o, indicator: s, selectable: c, searchScope: l, max: u, value: d, defaultValue: f, hasExpanded: p, hasPath: m, hasOnSearch: h } = e, g = t.useMemo(() => process.env.NODE_ENV === "production" ? null : De(n, r), [n, r]);
|
|
861
|
+
t.useEffect(() => {
|
|
862
|
+
if (process.env.NODE_ENV !== "production") {
|
|
863
|
+
for (let e of g?.duplicates ?? []) z(`duplicate-value:${e}`, `Duplicate node value ${JSON.stringify(e)}. \`value\` is the selection key, so only the first occurrence is indexed and the rest never render.`);
|
|
864
|
+
for (let e of g?.cycles ?? []) z(`cycle:${e}`, `\`getParent\` puts ${JSON.stringify(e)} on a cycle. The depth walk is cycle-guarded so nothing hangs, but every depth on that chain is clamped rather than derived.`);
|
|
865
|
+
}
|
|
866
|
+
}, [g]), t.useEffect(() => {
|
|
867
|
+
if (process.env.NODE_ENV !== "production") {
|
|
868
|
+
for (let [e, t] of [["value", d], ["defaultValue", f]]) t != null && (a && !Array.isArray(t) ? z(`value-shape:multiple:${e}`, `\`multiple\` is set but \`${e}\` is a string. Multi-select reads and writes a \`string[]\`; a string is treated as no selection at all.`) : !a && Array.isArray(t) && z(`value-shape:single:${e}`, `\`${e}\` is an array but \`multiple\` is not set. Single-select reads and writes a \`string\`; only the first entry would survive a commit.`));
|
|
869
|
+
o && !a && z("cascade-without-multiple", "`cascade` does nothing without `multiple`: a single selection has no subtree to propagate over."), o && c === "leaf" && z("cascade-with-leaf-selectable", "`cascade` does nothing while `selectable=\"leaf\"`: no branch can be committed, so no commit ever has a subtree under it. Pass `selectable=\"any\"` or a predicate that accepts branches."), !s && a && z("indicator-false-with-multiple", "`indicator={false}` does nothing with `multiple`: the checkbox is the selection control rather than a decoration, so it and its gutter stay. Mark selection your own way from `data-selected` on the row, and drop the prop."), u != null && !a && z("max-without-multiple", "`max` does nothing without `multiple`: there is only ever one selection to cap."), p && i !== "tree" && z(`expanded-outside-tree:${i}`, `\`expanded\` only does something in \`mode="tree"\`, and this cascader is in \`mode="${i}"\`. Drill and columns navigate with \`path\`.`), m && i === "tree" && z("path-in-tree", "`path` does nothing in `mode=\"tree\"`: branches expand in place rather than replacing the level. Use `expanded`."), l === "deep" && i === "tree" && z("deep-search-in-tree", "`searchScope=\"deep\"` does nothing in `mode=\"tree\"`: a tree query already matches at any depth and auto-expands the ancestors of every hit."), l === "global" && i === "tree" && z("global-search-in-tree", "`searchScope=\"global\"` does nothing in `mode=\"tree\"`: a tree query already searches the whole tree and auto-expands the ancestors of every hit."), h && i === "tree" && z("onsearch-in-tree", "`onSearch` does nothing in `mode=\"tree\"`: a tree query filters the loaded tree in place, and a server hit belongs to no visible branch, so its results would never render. The request is not fired. Filter the tree locally, or use drill or columns for server search.");
|
|
870
|
+
}
|
|
871
|
+
}, [
|
|
872
|
+
i,
|
|
873
|
+
a,
|
|
874
|
+
o,
|
|
875
|
+
s,
|
|
876
|
+
c,
|
|
877
|
+
l,
|
|
878
|
+
u,
|
|
879
|
+
d,
|
|
880
|
+
f,
|
|
881
|
+
p,
|
|
882
|
+
m,
|
|
883
|
+
h
|
|
884
|
+
]);
|
|
885
|
+
}
|
|
886
|
+
function tt({ items: e, getParent: n, getChildren: i, onSearch: a, searchDebounce: o, resolveValue: s, loadKey: c, prefetch: l, onLoadError: u, value: d, defaultValue: f, onValueChange: p, multiple: m = !1, selectable: h = "leaf", indicator: _ = !0, actions: v, cascade: y = !1, max: x, mode: C = "drill", expandTrigger: w, path: T, defaultPath: D, onPathChange: A, expanded: j, defaultExpanded: M, onExpandedChange: te, open: ne, defaultOpen: re = !1, onOpenChange: ie, closeOnSelect: ae = !0, inputValue: N, defaultInputValue: oe = "", onInputValueChange: se, searchScope: P = "level", filter: le, revealSelected: ve = !0, maxHeight: xe, virtualize: Se, virtualizeThreshold: Ee = 100, estimateRowSize: z = 32, overscan: De = 8, labels: Oe, renderItem: ke, renderLabel: B, disabled: Ae, name: je, form: Me, id: Ne, required: Pe, readOnly: Fe, invalid: Ie, inputRef: Le, inline: ze, children: Be }) {
|
|
887
|
+
let V = t.useMemo(() => ue(e, n), [e]), Ve = t.useId(), Ue = Qe(Oe, Xe), H = t.useMemo(() => He(Ue), [Ue]);
|
|
888
|
+
et({
|
|
889
|
+
items: e,
|
|
890
|
+
getParent: n,
|
|
891
|
+
mode: C,
|
|
892
|
+
multiple: m,
|
|
893
|
+
cascade: y,
|
|
894
|
+
indicator: _,
|
|
895
|
+
selectable: h,
|
|
896
|
+
searchScope: P,
|
|
897
|
+
max: x,
|
|
898
|
+
value: d,
|
|
899
|
+
defaultValue: f,
|
|
900
|
+
hasExpanded: j !== void 0 || M !== void 0 || te !== void 0,
|
|
901
|
+
hasPath: T !== void 0 || D !== void 0 || A !== void 0,
|
|
902
|
+
hasOnSearch: a !== void 0
|
|
903
|
+
});
|
|
904
|
+
let U = p, [tt, nt] = Ye(d, f ?? (m ? [] : ""), void 0, "value"), rt = t.useRef("external"), it = t.useRef("none"), [W, at] = Ye(T, D ?? [], (e) => A?.(e, { reason: rt.current }), "path"), [ot, st] = Ye(j, M ?? [], te, "expanded"), [ct, lt] = Ye(ne, re, (e) => ie?.(e, { reason: it.current }), "open"), G = t.useCallback((e, t) => {
|
|
905
|
+
rt.current = t;
|
|
906
|
+
try {
|
|
907
|
+
at(e);
|
|
908
|
+
} finally {
|
|
909
|
+
rt.current = "external";
|
|
910
|
+
}
|
|
911
|
+
}, [at]), [K, q] = Ye(N, oe, se, "inputValue"), J = t.useMemo(() => new Set(ot), [ot]), Y = t.useMemo(() => $e(tt), [tt]), ut = t.useMemo(() => C === "tree" ? [k, ...ot] : C === "columns" ? [k, ...W] : [W.length ? W[W.length - 1] : k], [
|
|
912
|
+
C,
|
|
913
|
+
W,
|
|
914
|
+
ot
|
|
915
|
+
]), dt = Re({
|
|
916
|
+
base: V,
|
|
917
|
+
getChildren: i,
|
|
918
|
+
onSearch: C === "tree" ? void 0 : a,
|
|
919
|
+
resolveValue: s,
|
|
920
|
+
searchDebounce: o,
|
|
921
|
+
loadKey: c,
|
|
922
|
+
prefetch: l,
|
|
923
|
+
onLoadError: u,
|
|
924
|
+
enabled: ct || !!ze,
|
|
925
|
+
query: K,
|
|
926
|
+
levels: ut,
|
|
927
|
+
path: P === "global" ? Ke : W,
|
|
928
|
+
values: Y
|
|
929
|
+
}), X = dt.states, { ensureLevel: ft, retryLevel: pt, invalidateLevel: mt } = dt, ht = t.useCallback((e) => {
|
|
930
|
+
if (!dt.active) return !1;
|
|
931
|
+
let t = X.get(e.value);
|
|
932
|
+
return t ? t.loading || t.error : !V.childrenOf.has(e.value);
|
|
933
|
+
}, [
|
|
934
|
+
dt.active,
|
|
935
|
+
X,
|
|
936
|
+
V
|
|
937
|
+
]), Z = t.useMemo(() => de(V, dt.store.pages, dt.store.detached), [
|
|
938
|
+
V,
|
|
939
|
+
dt.store.pages,
|
|
940
|
+
dt.store.detached
|
|
941
|
+
]), gt = t.useCallback((e, t) => {
|
|
942
|
+
let n = X.get(e);
|
|
943
|
+
return n ? t > 0 ? n.hasMore || n.loading || n.error : C === "tree" && (n.loading || n.error) : !1;
|
|
944
|
+
}, [X, C]), _t = t.useRef(/* @__PURE__ */ new Map());
|
|
945
|
+
for (let e of Y) {
|
|
946
|
+
let t = Z.byValue.get(e);
|
|
947
|
+
t && _t.current.set(e, t);
|
|
948
|
+
}
|
|
949
|
+
let vt = t.useCallback((e) => Z.byValue.get(e) ?? _t.current.get(e) ?? {
|
|
950
|
+
value: e,
|
|
951
|
+
label: e
|
|
952
|
+
}, [Z]), yt = W.length ? W[W.length - 1] : null, bt = yt ? Z.byValue.get(yt) ?? null : null, xt = yt ?? "\0root", St = (P === "deep" || P === "global") && K.trim().length > 0 && C !== "tree", Ct = P === "global" ? null : yt, wt = t.useMemo(() => St ? L(Z, K, {
|
|
953
|
+
within: Ct,
|
|
954
|
+
matches: le
|
|
955
|
+
}) : null, [
|
|
956
|
+
St,
|
|
957
|
+
Z,
|
|
958
|
+
K,
|
|
959
|
+
Ct,
|
|
960
|
+
le
|
|
961
|
+
]), Tt = dt.searchResults ?? wt, Et = t.useMemo(() => I(fe(Z, yt), K, le), [
|
|
962
|
+
Z,
|
|
963
|
+
yt,
|
|
964
|
+
K,
|
|
965
|
+
le
|
|
966
|
+
]), Dt = t.useMemo(() => Tt || (gt(xt, Et.length) ? [...Et, F(xt, Et.length)] : Et), [
|
|
967
|
+
Tt,
|
|
968
|
+
Et,
|
|
969
|
+
xt,
|
|
970
|
+
gt
|
|
971
|
+
]), Ot = t.useMemo(() => {
|
|
972
|
+
if (C !== "columns") return [];
|
|
973
|
+
let e = [];
|
|
974
|
+
for (let t = 0; t <= W.length; t += 1) {
|
|
975
|
+
let n = t === 0 ? null : W[t - 1], r = n ? Z.byValue.get(n) ?? null : null, i = t === W.length, a;
|
|
976
|
+
if (i) a = Dt;
|
|
977
|
+
else {
|
|
978
|
+
let e = n ?? "\0root", t = fe(Z, n);
|
|
979
|
+
a = gt(e, t.length) ? [...t, F(e, t.length)] : t;
|
|
980
|
+
}
|
|
981
|
+
e.push({
|
|
982
|
+
parent: r,
|
|
983
|
+
depth: t,
|
|
984
|
+
activeValue: W[t] ?? null,
|
|
985
|
+
active: i,
|
|
986
|
+
items: a
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
return e;
|
|
990
|
+
}, [
|
|
991
|
+
C,
|
|
992
|
+
W,
|
|
993
|
+
Z,
|
|
994
|
+
Dt,
|
|
995
|
+
gt
|
|
996
|
+
]), kt = t.useMemo(() => {
|
|
997
|
+
if (C !== "tree") return;
|
|
998
|
+
let e = /* @__PURE__ */ new Set(), t = (t) => {
|
|
999
|
+
gt(t, Z.childrenOf.get(t)?.length ?? 0) && e.add(t);
|
|
1000
|
+
};
|
|
1001
|
+
t(k);
|
|
1002
|
+
for (let e of J) t(e);
|
|
1003
|
+
return e.size ? e : void 0;
|
|
1004
|
+
}, [
|
|
1005
|
+
C,
|
|
1006
|
+
Z,
|
|
1007
|
+
J,
|
|
1008
|
+
gt
|
|
1009
|
+
]), At = t.useMemo(() => {
|
|
1010
|
+
if (C !== "tree") return [];
|
|
1011
|
+
let e = R(Z, J, kt), t = ye(K);
|
|
1012
|
+
if (!t) return e;
|
|
1013
|
+
let n = /* @__PURE__ */ new Set();
|
|
1014
|
+
for (let e of Z.all) if (le ? le(e, t) : be(e, t)) for (let t of _e(Z, e.value)) n.add(t.value);
|
|
1015
|
+
return R(Z, /* @__PURE__ */ new Set([...J, ...n])).filter((e) => n.has(e.node.value));
|
|
1016
|
+
}, [
|
|
1017
|
+
C,
|
|
1018
|
+
Z,
|
|
1019
|
+
J,
|
|
1020
|
+
kt,
|
|
1021
|
+
K,
|
|
1022
|
+
le
|
|
1023
|
+
]), jt = t.useMemo(() => C === "tree" ? At.map((e) => e.node) : Dt, [
|
|
1024
|
+
C,
|
|
1025
|
+
At,
|
|
1026
|
+
Dt
|
|
1027
|
+
]), Mt = yt ?? "", [Nt, Pt] = t.useState({
|
|
1028
|
+
key: Mt,
|
|
1029
|
+
active: !1
|
|
1030
|
+
});
|
|
1031
|
+
Nt.key !== Mt && Pt({
|
|
1032
|
+
key: Mt,
|
|
1033
|
+
active: !0
|
|
1034
|
+
});
|
|
1035
|
+
let Ft = Nt.active && Nt.key === Mt;
|
|
1036
|
+
t.useLayoutEffect(() => {
|
|
1037
|
+
Nt.active && Pt((e) => ({
|
|
1038
|
+
...e,
|
|
1039
|
+
active: !1
|
|
1040
|
+
}));
|
|
1041
|
+
}, [Nt.active]);
|
|
1042
|
+
let It = t.useCallback(() => {
|
|
1043
|
+
Pt((e) => e.active ? e : {
|
|
1044
|
+
...e,
|
|
1045
|
+
active: !0
|
|
1046
|
+
});
|
|
1047
|
+
}, []), [Lt, Rt] = t.useState(0), zt = t.useCallback(() => (Rt((e) => e + 1), () => Rt((e) => Math.max(0, e - 1))), []), Bt = Lt > 0, Vt = Se ?? jt.length >= Ee, [Ht, Ut] = t.useState({
|
|
1048
|
+
key: Mt,
|
|
1049
|
+
on: !1
|
|
1050
|
+
}), Wt = Bt && (Ht.key === Mt && Ht.on || Vt);
|
|
1051
|
+
Bt ? Ht.key === Mt ? Wt && !Ht.on && Ut({
|
|
1052
|
+
key: Mt,
|
|
1053
|
+
on: !0
|
|
1054
|
+
}) : Ut({
|
|
1055
|
+
key: Mt,
|
|
1056
|
+
on: Wt
|
|
1057
|
+
}) : (Ht.on || Ht.key !== Mt) && Ut({
|
|
1058
|
+
key: Mt,
|
|
1059
|
+
on: !1
|
|
1060
|
+
});
|
|
1061
|
+
let [Gt, Kt] = t.useState(0);
|
|
1062
|
+
t.useEffect(() => {
|
|
1063
|
+
Wt && Kt((e) => e + 1);
|
|
1064
|
+
}, [Wt]), t.useEffect(() => {
|
|
1065
|
+
if (process.env.NODE_ENV === "production" || Se !== !0 || Bt) return;
|
|
1066
|
+
let e = setTimeout(() => {
|
|
1067
|
+
console.error("[Cascader] `virtualize` is true but no windowing renderer is mounted. Render <CascaderVirtualItems /> inside <CascaderList>, or <CascaderVirtualColumn /> through the <CascaderColumns> slot.");
|
|
1068
|
+
}, 0);
|
|
1069
|
+
return () => clearTimeout(e);
|
|
1070
|
+
}, [Se, Bt]);
|
|
1071
|
+
let [qt, Jt] = t.useState({
|
|
1072
|
+
seq: 0,
|
|
1073
|
+
toggled: null,
|
|
1074
|
+
notice: null
|
|
1075
|
+
}), Q = t.useCallback((e) => {
|
|
1076
|
+
Jt((t) => ({
|
|
1077
|
+
seq: t.seq + 1,
|
|
1078
|
+
toggled: e,
|
|
1079
|
+
notice: null
|
|
1080
|
+
}));
|
|
1081
|
+
}, []), Yt = t.useCallback((e) => {
|
|
1082
|
+
Jt((t) => ({
|
|
1083
|
+
seq: t.seq + 1,
|
|
1084
|
+
toggled: null,
|
|
1085
|
+
notice: e
|
|
1086
|
+
}));
|
|
1087
|
+
}, []), [$, Xt] = t.useState(null), Zt = t.useCallback((e, t) => {
|
|
1088
|
+
Xt(t), pt(e.value), ft(e.value, "level"), Q(null);
|
|
1089
|
+
}, [
|
|
1090
|
+
pt,
|
|
1091
|
+
ft,
|
|
1092
|
+
Q
|
|
1093
|
+
]), Qt = t.useCallback((e) => {
|
|
1094
|
+
G((t) => [...t, e], "drill"), q(""), Q(null);
|
|
1095
|
+
}, [
|
|
1096
|
+
G,
|
|
1097
|
+
q,
|
|
1098
|
+
Q
|
|
1099
|
+
]), $t = t.useCallback(() => {
|
|
1100
|
+
G((e) => e.length ? e.slice(0, -1) : e, "back"), q(""), Xt(null), Q(null);
|
|
1101
|
+
}, [
|
|
1102
|
+
G,
|
|
1103
|
+
q,
|
|
1104
|
+
Q
|
|
1105
|
+
]), en = t.useCallback((e) => {
|
|
1106
|
+
G((t) => t.slice(0, Math.max(0, e)), "breadcrumb"), q(""), Xt(null), Q(null);
|
|
1107
|
+
}, [
|
|
1108
|
+
G,
|
|
1109
|
+
q,
|
|
1110
|
+
Q
|
|
1111
|
+
]), tn = t.useCallback((e) => {
|
|
1112
|
+
st((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), Q(e);
|
|
1113
|
+
}, [st, Q]), nn = t.useCallback((e) => pe(Z, e), [Z]), rn = t.useCallback((e) => ge(Z, e, h), [Z, h]), an = t.useCallback((e) => he(Z, e), [Z]), on = h !== "leaf", sn = t.useRef(/* @__PURE__ */ new Set()), cn = t.useCallback((e, t) => {
|
|
1114
|
+
t ? sn.current.add(e) : sn.current.delete(e);
|
|
1115
|
+
}, []), ln = t.useCallback(() => sn.current.size > 0, []), un = Qe(v, Ze), dn = t.useMemo(() => un ?? Ge, [un]), fn = t.useMemo(() => new Set(Y), [Y]), pn = t.useCallback((e) => fn.has(e.value), [fn]), mn = t.useMemo(() => we(Z, Y), [Z, Y]), hn = t.useCallback((e) => mn.get(e.value) ?? 0, [mn]), gn = t.useMemo(() => !y || !m ? null : Te(mn, Y), [
|
|
1116
|
+
y,
|
|
1117
|
+
m,
|
|
1118
|
+
mn,
|
|
1119
|
+
Y
|
|
1120
|
+
]), _n = t.useCallback((e) => gn?.has(e.value) ?? !1, [gn]), vn = t.useRef(null), yn = t.useCallback(() => vn.current, []), [bn] = t.useState(E), xn = t.useMemo(() => X.get(xt) ?? null, [X, xt]), Sn = dt.searchState, Cn = t.useMemo(() => {
|
|
1121
|
+
if (Tt) return Tt.length;
|
|
1122
|
+
let e = ye(K);
|
|
1123
|
+
if (!e) return 0;
|
|
1124
|
+
let t = le ?? be;
|
|
1125
|
+
return jt.filter((n) => !ce(n) && t(n, e)).length;
|
|
1126
|
+
}, [
|
|
1127
|
+
Tt,
|
|
1128
|
+
jt,
|
|
1129
|
+
K,
|
|
1130
|
+
le
|
|
1131
|
+
]), wn = t.useMemo(() => {
|
|
1132
|
+
if (!ct && !ze) return {
|
|
1133
|
+
text: "",
|
|
1134
|
+
defer: !1
|
|
1135
|
+
};
|
|
1136
|
+
let e = jt.length, t = qe.repeat(qt.seq % 2);
|
|
1137
|
+
if (qt.notice) return {
|
|
1138
|
+
text: `${qt.notice}${t}`,
|
|
1139
|
+
defer: !1
|
|
1140
|
+
};
|
|
1141
|
+
let n = C === "tree" && qt.toggled ? Z.byValue.get(qt.toggled) ?? null : null, r = $ ? X.get($.value) ?? null : null, i = K.trim() ? Sn : xn, a, o = !1;
|
|
1142
|
+
return r?.error ? a = H.error : $ ? a = H.loading : i?.error ? a = H.error : i?.loading ? a = K.trim() ? H.searchingAnnouncement : e > 0 ? H.loadingMore : H.loading : K.trim() ? (a = Cn === 0 ? H.empty : H.resultsAnnouncement(Cn), o = !0) : a = n ? J.has(n.value) ? H.expandedAnnouncement(n.label, me(Z, n)) : H.collapsedAnnouncement(n.label) : bt ? H.levelAnnouncement(bt.label, W.length + 1, e) : H.rootAnnouncement(e), {
|
|
1143
|
+
text: `${a}${t}`,
|
|
1144
|
+
defer: o
|
|
1145
|
+
};
|
|
1146
|
+
}, [
|
|
1147
|
+
ct,
|
|
1148
|
+
ze,
|
|
1149
|
+
C,
|
|
1150
|
+
Z,
|
|
1151
|
+
J,
|
|
1152
|
+
qt,
|
|
1153
|
+
K,
|
|
1154
|
+
H,
|
|
1155
|
+
jt.length,
|
|
1156
|
+
Cn,
|
|
1157
|
+
bt,
|
|
1158
|
+
W.length,
|
|
1159
|
+
xn,
|
|
1160
|
+
Sn,
|
|
1161
|
+
$,
|
|
1162
|
+
X
|
|
1163
|
+
]), [Tn, En] = t.useState(wn);
|
|
1164
|
+
!wn.defer && Tn.text !== wn.text && En(wn), t.useEffect(() => {
|
|
1165
|
+
if (!wn.defer) return;
|
|
1166
|
+
let e = setTimeout(() => En(wn), Je);
|
|
1167
|
+
return () => clearTimeout(e);
|
|
1168
|
+
}, [wn]);
|
|
1169
|
+
let Dn = Tn.text, On = t.useMemo(() => ({
|
|
1170
|
+
index: Z,
|
|
1171
|
+
path: W,
|
|
1172
|
+
expanded: J,
|
|
1173
|
+
query: K,
|
|
1174
|
+
currentParent: bt,
|
|
1175
|
+
levelItems: Et,
|
|
1176
|
+
deepResults: Tt,
|
|
1177
|
+
renderedItems: jt,
|
|
1178
|
+
columns: Ot,
|
|
1179
|
+
treeRows: At,
|
|
1180
|
+
selectedValues: Y,
|
|
1181
|
+
selectedDescendants: mn,
|
|
1182
|
+
loadStates: X,
|
|
1183
|
+
searchState: Sn,
|
|
1184
|
+
announcement: Dn
|
|
1185
|
+
}), [
|
|
1186
|
+
Z,
|
|
1187
|
+
W,
|
|
1188
|
+
J,
|
|
1189
|
+
K,
|
|
1190
|
+
bt,
|
|
1191
|
+
Et,
|
|
1192
|
+
Tt,
|
|
1193
|
+
jt,
|
|
1194
|
+
Ot,
|
|
1195
|
+
At,
|
|
1196
|
+
Y,
|
|
1197
|
+
mn,
|
|
1198
|
+
X,
|
|
1199
|
+
Sn,
|
|
1200
|
+
Dn
|
|
1201
|
+
]), kn = t.useRef({
|
|
1202
|
+
index: Z,
|
|
1203
|
+
state: On,
|
|
1204
|
+
mode: C,
|
|
1205
|
+
multiple: m,
|
|
1206
|
+
cascade: y,
|
|
1207
|
+
max: x,
|
|
1208
|
+
labels: H,
|
|
1209
|
+
closeOnSelect: ae,
|
|
1210
|
+
selectedValues: Y,
|
|
1211
|
+
deepResults: Tt,
|
|
1212
|
+
onValueChange: U,
|
|
1213
|
+
resolveNode: vt,
|
|
1214
|
+
isSelectable: rn,
|
|
1215
|
+
needsChildren: ht,
|
|
1216
|
+
expanded: J
|
|
1217
|
+
});
|
|
1218
|
+
t.useEffect(() => {
|
|
1219
|
+
kn.current = {
|
|
1220
|
+
index: Z,
|
|
1221
|
+
state: On,
|
|
1222
|
+
mode: C,
|
|
1223
|
+
multiple: m,
|
|
1224
|
+
cascade: y,
|
|
1225
|
+
max: x,
|
|
1226
|
+
labels: H,
|
|
1227
|
+
closeOnSelect: ae,
|
|
1228
|
+
selectedValues: Y,
|
|
1229
|
+
deepResults: Tt,
|
|
1230
|
+
onValueChange: U,
|
|
1231
|
+
resolveNode: vt,
|
|
1232
|
+
isSelectable: rn,
|
|
1233
|
+
needsChildren: ht,
|
|
1234
|
+
expanded: J
|
|
1235
|
+
};
|
|
1236
|
+
});
|
|
1237
|
+
let An = t.useCallback(() => kn.current.index, []), jn = t.useCallback(() => kn.current.state, []), Mn = t.useCallback((e, t) => {
|
|
1238
|
+
G((n) => [...n.slice(0, Math.max(0, t)), e], "drill"), q(""), Q(null);
|
|
1239
|
+
}, [
|
|
1240
|
+
G,
|
|
1241
|
+
q,
|
|
1242
|
+
Q
|
|
1243
|
+
]), Nn = t.useCallback((e) => {
|
|
1244
|
+
let { path: t } = kn.current.state;
|
|
1245
|
+
e.length === t.length && e.every((e, n) => e === t[n]) ? It() : G(e, "drill"), q(""), Q(null);
|
|
1246
|
+
}, [
|
|
1247
|
+
G,
|
|
1248
|
+
It,
|
|
1249
|
+
q,
|
|
1250
|
+
Q
|
|
1251
|
+
]), Pn = t.useCallback((e, t) => {
|
|
1252
|
+
if (!he(kn.current.index, e)) {
|
|
1253
|
+
if (kn.current.mode === "tree") {
|
|
1254
|
+
tn(e.value);
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
if (kn.current.needsChildren(e)) {
|
|
1258
|
+
Zt(e, {
|
|
1259
|
+
value: e.value,
|
|
1260
|
+
kind: "at",
|
|
1261
|
+
depth: t
|
|
1262
|
+
});
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
Mn(e.value, t);
|
|
1266
|
+
}
|
|
1267
|
+
}, [
|
|
1268
|
+
tn,
|
|
1269
|
+
Mn,
|
|
1270
|
+
Zt
|
|
1271
|
+
]), Fn = t.useCallback((e) => {
|
|
1272
|
+
let { mode: t, deepResults: n, index: r, expanded: i, needsChildren: a } = kn.current;
|
|
1273
|
+
if (!he(r, e)) {
|
|
1274
|
+
if (t === "tree") {
|
|
1275
|
+
if (!i.has(e.value) && a(e)) {
|
|
1276
|
+
Zt(e, {
|
|
1277
|
+
value: e.value,
|
|
1278
|
+
kind: "expand",
|
|
1279
|
+
depth: 0
|
|
1280
|
+
});
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
tn(e.value);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (n) {
|
|
1287
|
+
let t = _e(r, e.value).map((e) => e.value);
|
|
1288
|
+
if (a(e)) {
|
|
1289
|
+
Zt(e, {
|
|
1290
|
+
value: e.value,
|
|
1291
|
+
kind: "trail",
|
|
1292
|
+
trail: t
|
|
1293
|
+
});
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
Nn(t);
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (a(e)) {
|
|
1300
|
+
Zt(e, {
|
|
1301
|
+
value: e.value,
|
|
1302
|
+
kind: "push",
|
|
1303
|
+
depth: 0
|
|
1304
|
+
});
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
Qt(e.value);
|
|
1308
|
+
}
|
|
1309
|
+
}, [
|
|
1310
|
+
tn,
|
|
1311
|
+
Nn,
|
|
1312
|
+
Qt,
|
|
1313
|
+
Zt
|
|
1314
|
+
]);
|
|
1315
|
+
t.useEffect(() => {
|
|
1316
|
+
if (!$) return;
|
|
1317
|
+
let e = X.get($.value);
|
|
1318
|
+
if (!e || e.loading || e.error) return;
|
|
1319
|
+
Xt(null);
|
|
1320
|
+
let t = Z.byValue.get($.value);
|
|
1321
|
+
if (!(t && an(t))) {
|
|
1322
|
+
if ($.kind === "expand") {
|
|
1323
|
+
tn($.value);
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
if ($.kind === "trail") {
|
|
1327
|
+
Nn($.trail);
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
if ($.kind === "at") {
|
|
1331
|
+
Mn($.value, $.depth);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
Qt($.value);
|
|
1335
|
+
}
|
|
1336
|
+
}, [
|
|
1337
|
+
$,
|
|
1338
|
+
X,
|
|
1339
|
+
Z,
|
|
1340
|
+
an,
|
|
1341
|
+
tn,
|
|
1342
|
+
Nn,
|
|
1343
|
+
Mn,
|
|
1344
|
+
Qt
|
|
1345
|
+
]), t.useEffect(() => {
|
|
1346
|
+
!ct && !ze && Xt(null);
|
|
1347
|
+
}, [ct, ze]);
|
|
1348
|
+
let In = t.useCallback((e, t, n) => {
|
|
1349
|
+
let { selectedValues: r, multiple: i, onValueChange: a, index: o, resolveNode: s } = kn.current;
|
|
1350
|
+
if (e.length === r.length && e.every((e, t) => e === r[t])) return;
|
|
1351
|
+
let c = i ? e : e[0] ?? "";
|
|
1352
|
+
if (nt(c), !a) return;
|
|
1353
|
+
let l = t ? _e(o, t.value) : [];
|
|
1354
|
+
a(c, {
|
|
1355
|
+
node: t,
|
|
1356
|
+
path: t ? l.length ? l : [t] : [],
|
|
1357
|
+
nodes: e.map(s),
|
|
1358
|
+
reason: n
|
|
1359
|
+
});
|
|
1360
|
+
}, [nt]), Ln = t.useCallback((e, t) => {
|
|
1361
|
+
let { selectedValues: n, resolveNode: r } = kn.current, i = new Set(n), a = new Set(e), o = e.find((e) => !i.has(e)), s = n.find((e) => !a.has(e));
|
|
1362
|
+
if (t === "clear") {
|
|
1363
|
+
In(e, null, "clear");
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
if (o) {
|
|
1367
|
+
In(e, r(o), t ?? "select");
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
if (s) {
|
|
1371
|
+
In(e, r(s), t ?? "deselect");
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
In(e, null, t ?? "select");
|
|
1375
|
+
}, [In]), Rn = t.useCallback((e) => {
|
|
1376
|
+
let { multiple: t, cascade: n, selectedValues: r, max: i, index: a, isSelectable: o, labels: s, closeOnSelect: c } = kn.current, l = !t || !r.includes(e.value);
|
|
1377
|
+
if (!(l && he(a, e))) {
|
|
1378
|
+
if (!t) {
|
|
1379
|
+
In([e.value], e, "select"), c ? (it.current = "item-press", lt(!1)) : q("");
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
if (n) {
|
|
1383
|
+
let t = Ce(a, r, e.value, l, o);
|
|
1384
|
+
if (l && i != null && t.length > i && t.length > r.length) {
|
|
1385
|
+
Yt(s.maxReachedAnnouncement(i));
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
In(t, e, l ? "select" : "deselect");
|
|
1389
|
+
let n = new Set(r), c = new Set(t), u = 0;
|
|
1390
|
+
for (let i of l ? t : r) i !== e.value && (l ? !n.has(i) : !c.has(i)) && (u += 1);
|
|
1391
|
+
u > 0 && Yt(s.cascadeAnnouncement(e.label ?? e.value, u, l)), q("");
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
r.includes(e.value) ? In(r.filter((t) => t !== e.value), e, "deselect") : i == null || r.length < i ? In([...r, e.value], e, "select") : Yt(s.maxReachedAnnouncement(i)), q("");
|
|
1395
|
+
}
|
|
1396
|
+
}, [
|
|
1397
|
+
In,
|
|
1398
|
+
lt,
|
|
1399
|
+
q,
|
|
1400
|
+
Yt
|
|
1401
|
+
]), zn = t.useCallback((e, t) => {
|
|
1402
|
+
if (!m) {
|
|
1403
|
+
let n = Array.isArray(e) ? e[0] ?? null : e;
|
|
1404
|
+
if (n && ce(n)) {
|
|
1405
|
+
t.cancel();
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
if (n && an(n)) {
|
|
1409
|
+
t.cancel();
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
if (n && !rn(n) && nn(n)) {
|
|
1413
|
+
t.cancel(), Fn(n);
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
n && (ae || t.cancel(), Rn(n));
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
let n = Array.isArray(e) ? e : [], r = new Set(Y), i = n.find((e) => !r.has(e.value));
|
|
1420
|
+
if (i && (ce(i) || an(i))) {
|
|
1421
|
+
t.cancel();
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
if (i && !rn(i) && nn(i)) {
|
|
1425
|
+
t.cancel(), Fn(i);
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
if (y) {
|
|
1429
|
+
let e = new Set(n.map((e) => e.value)), t = Y.find((t) => !e.has(t)), r = i ?? (t == null ? null : vt(t));
|
|
1430
|
+
r && Rn(r);
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
if (x != null && n.length > Y.length && n.length > x) {
|
|
1434
|
+
t.cancel(), Yt(H.maxReachedAnnouncement(x));
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
Ln(n.map((e) => e.value)), q("");
|
|
1438
|
+
}, [
|
|
1439
|
+
m,
|
|
1440
|
+
Y,
|
|
1441
|
+
x,
|
|
1442
|
+
y,
|
|
1443
|
+
ae,
|
|
1444
|
+
H,
|
|
1445
|
+
Yt,
|
|
1446
|
+
rn,
|
|
1447
|
+
an,
|
|
1448
|
+
nn,
|
|
1449
|
+
Fn,
|
|
1450
|
+
Rn,
|
|
1451
|
+
vt,
|
|
1452
|
+
Ln,
|
|
1453
|
+
q
|
|
1454
|
+
]), Bn = t.useCallback((e, t) => {
|
|
1455
|
+
if (!t.isCanceled) {
|
|
1456
|
+
if (!e && t.reason === "escape-key" && ln()) {
|
|
1457
|
+
t.cancel();
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
if (it.current = t.reason ?? "none", lt(e), !e) {
|
|
1461
|
+
q("");
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (ve) {
|
|
1465
|
+
q("");
|
|
1466
|
+
let e = $e(tt)[0];
|
|
1467
|
+
G(e ? _e(Z, e).slice(0, -1).map((e) => e.value) : [], "reveal");
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}, [
|
|
1471
|
+
lt,
|
|
1472
|
+
q,
|
|
1473
|
+
ve,
|
|
1474
|
+
tt,
|
|
1475
|
+
Z,
|
|
1476
|
+
G,
|
|
1477
|
+
ln
|
|
1478
|
+
]), Vn = t.useMemo(() => ({
|
|
1479
|
+
renderItem: ke,
|
|
1480
|
+
renderLabel: B
|
|
1481
|
+
}), [ke, B]), { active: Hn, loadMore: Un, retryLevel: Wn, prefetchNode: Gn } = dt, Kn = t.useMemo(() => ({
|
|
1482
|
+
index: Z,
|
|
1483
|
+
mode: C,
|
|
1484
|
+
multiple: m,
|
|
1485
|
+
cascade: y,
|
|
1486
|
+
branchesSelectable: on,
|
|
1487
|
+
indicator: _,
|
|
1488
|
+
expandTrigger: w,
|
|
1489
|
+
actions: dn,
|
|
1490
|
+
searchScope: P,
|
|
1491
|
+
maxHeight: xe,
|
|
1492
|
+
inline: !!ze,
|
|
1493
|
+
invalid: !!Ie,
|
|
1494
|
+
baseId: Ve,
|
|
1495
|
+
labels: H,
|
|
1496
|
+
virtualized: Wt,
|
|
1497
|
+
registerVirtualRenderer: zt,
|
|
1498
|
+
virtualize: Se,
|
|
1499
|
+
virtualizeThreshold: Ee,
|
|
1500
|
+
estimateRowSize: z,
|
|
1501
|
+
overscan: De,
|
|
1502
|
+
hasLoader: Hn,
|
|
1503
|
+
loadMore: Un,
|
|
1504
|
+
retryLevel: Wn,
|
|
1505
|
+
invalidateLevel: mt,
|
|
1506
|
+
getIndex: An,
|
|
1507
|
+
getState: jn,
|
|
1508
|
+
getHighlighted: yn,
|
|
1509
|
+
setPath: at,
|
|
1510
|
+
pushLevel: Qt,
|
|
1511
|
+
popLevel: $t,
|
|
1512
|
+
goToDepth: en,
|
|
1513
|
+
toggleExpanded: tn,
|
|
1514
|
+
setFlyoutOpen: cn,
|
|
1515
|
+
hasOpenFlyout: ln,
|
|
1516
|
+
setQuery: q,
|
|
1517
|
+
setSelection: Ln,
|
|
1518
|
+
commit: Rn,
|
|
1519
|
+
navigate: Fn,
|
|
1520
|
+
navigateAt: Pn,
|
|
1521
|
+
resolveNode: vt,
|
|
1522
|
+
isBranch: nn,
|
|
1523
|
+
isSelectable: rn,
|
|
1524
|
+
isDisabled: an,
|
|
1525
|
+
isSelected: pn,
|
|
1526
|
+
isIndeterminate: _n,
|
|
1527
|
+
selectedDescendantCount: hn
|
|
1528
|
+
}), [
|
|
1529
|
+
Z,
|
|
1530
|
+
C,
|
|
1531
|
+
m,
|
|
1532
|
+
y,
|
|
1533
|
+
on,
|
|
1534
|
+
_,
|
|
1535
|
+
w,
|
|
1536
|
+
dn,
|
|
1537
|
+
P,
|
|
1538
|
+
xe,
|
|
1539
|
+
ze,
|
|
1540
|
+
Ie,
|
|
1541
|
+
Ve,
|
|
1542
|
+
H,
|
|
1543
|
+
Wt,
|
|
1544
|
+
zt,
|
|
1545
|
+
Se,
|
|
1546
|
+
Ee,
|
|
1547
|
+
z,
|
|
1548
|
+
De,
|
|
1549
|
+
Hn,
|
|
1550
|
+
Un,
|
|
1551
|
+
Wn,
|
|
1552
|
+
mt,
|
|
1553
|
+
An,
|
|
1554
|
+
jn,
|
|
1555
|
+
yn,
|
|
1556
|
+
at,
|
|
1557
|
+
Qt,
|
|
1558
|
+
$t,
|
|
1559
|
+
en,
|
|
1560
|
+
tn,
|
|
1561
|
+
cn,
|
|
1562
|
+
ln,
|
|
1563
|
+
q,
|
|
1564
|
+
Ln,
|
|
1565
|
+
Rn,
|
|
1566
|
+
Fn,
|
|
1567
|
+
Pn,
|
|
1568
|
+
vt,
|
|
1569
|
+
nn,
|
|
1570
|
+
rn,
|
|
1571
|
+
an,
|
|
1572
|
+
pn,
|
|
1573
|
+
_n,
|
|
1574
|
+
hn
|
|
1575
|
+
]), qn = t.useMemo(() => Wt ? jt.slice() : jt, [
|
|
1576
|
+
jt,
|
|
1577
|
+
Wt,
|
|
1578
|
+
Gt
|
|
1579
|
+
]), Jn = t.useMemo(() => m ? Y.map(vt) : Y.length ? vt(Y[0]) : null, [
|
|
1580
|
+
m,
|
|
1581
|
+
Y,
|
|
1582
|
+
vt
|
|
1583
|
+
]);
|
|
1584
|
+
return /* @__PURE__ */ r(S.Provider, {
|
|
1585
|
+
value: Kn,
|
|
1586
|
+
children: /* @__PURE__ */ r(b.Provider, {
|
|
1587
|
+
value: On,
|
|
1588
|
+
children: /* @__PURE__ */ r(O.Provider, {
|
|
1589
|
+
value: bn,
|
|
1590
|
+
children: /* @__PURE__ */ r(ee.Provider, {
|
|
1591
|
+
value: Vn,
|
|
1592
|
+
children: /* @__PURE__ */ r(g.Root, {
|
|
1593
|
+
items: jt,
|
|
1594
|
+
filteredItems: Ft ? We : qn,
|
|
1595
|
+
filter: null,
|
|
1596
|
+
value: Jn,
|
|
1597
|
+
onValueChange: zn,
|
|
1598
|
+
open: ct,
|
|
1599
|
+
onOpenChange: Bn,
|
|
1600
|
+
inputValue: K,
|
|
1601
|
+
onInputValueChange: (e) => q(e),
|
|
1602
|
+
multiple: m,
|
|
1603
|
+
disabled: Ae,
|
|
1604
|
+
name: je,
|
|
1605
|
+
...Me == null ? null : { form: Me },
|
|
1606
|
+
...Ne == null ? null : { id: Ne },
|
|
1607
|
+
...Pe == null ? null : { required: Pe },
|
|
1608
|
+
...Fe == null ? null : { readOnly: Fe },
|
|
1609
|
+
...Le ? { inputRef: Le } : null,
|
|
1610
|
+
inline: ze,
|
|
1611
|
+
virtualized: Wt,
|
|
1612
|
+
itemToStringValue: (e) => e?.value ?? "",
|
|
1613
|
+
itemToStringLabel: (e) => e?.label ?? "",
|
|
1614
|
+
isItemEqualToValue: (e, t) => e?.value === t?.value,
|
|
1615
|
+
onItemHighlighted: (e, t) => {
|
|
1616
|
+
vn.current = e ?? null, bn.set({
|
|
1617
|
+
index: t.index,
|
|
1618
|
+
value: e?.value ?? null
|
|
1619
|
+
}), Gn(e);
|
|
1620
|
+
},
|
|
1621
|
+
children: Be
|
|
1622
|
+
})
|
|
1623
|
+
})
|
|
1624
|
+
})
|
|
1625
|
+
})
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
function nt({ className: n, children: a, showIcon: o = !0, ref: s, ...c }) {
|
|
1629
|
+
let { invalid: l } = C(), u = t.useRef(null), d = t.useCallback((e) => {
|
|
1630
|
+
u.current = e, typeof s == "function" ? s(e) : s && (s.current = e);
|
|
1631
|
+
}, [s]);
|
|
1632
|
+
return t.useEffect(() => {
|
|
1633
|
+
if (process.env.NODE_ENV === "production") return;
|
|
1634
|
+
let e = u.current;
|
|
1635
|
+
e && (e.hasAttribute("aria-label") || e.hasAttribute("aria-labelledby") || e.closest("label") !== null || e.id !== "" && e.ownerDocument.querySelector(`label[for="${CSS.escape(e.id)}"]`) !== null || z("trigger-unnamed", "`CascaderTrigger` has no accessible name. Its contents are the field's VALUE - they change with the selection - so a screen reader hears what is picked but never what the field is for. Pass `aria-label` or `aria-labelledby`, or reference the trigger's `id` from a `<label>`."));
|
|
1636
|
+
}), /* @__PURE__ */ i(g.Trigger, {
|
|
1637
|
+
ref: d,
|
|
1638
|
+
"data-slot": "cascader-trigger",
|
|
1639
|
+
...l ? {
|
|
1640
|
+
"aria-invalid": !0,
|
|
1641
|
+
"data-invalid": ""
|
|
1642
|
+
} : null,
|
|
1643
|
+
className: e(it, n),
|
|
1644
|
+
...c,
|
|
1645
|
+
children: [a, o ? /* @__PURE__ */ r(U, {
|
|
1646
|
+
lucide: "ChevronDownIcon",
|
|
1647
|
+
tabler: "IconChevronDown",
|
|
1648
|
+
hugeicons: "ArrowDown01Icon",
|
|
1649
|
+
phosphor: "CaretDownIcon",
|
|
1650
|
+
remixicon: "RiArrowDownSLine",
|
|
1651
|
+
className: `${rt} pointer-events-none shrink-0`
|
|
1652
|
+
}) : null]
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
var rt = "text-muted-foreground size-4", it = "[&_svg:not([class*='size-'])]:size-4", W = "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 overflow-hidden ring-1 duration-100 ring-foreground/10 shadow-md rounded-lg data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2", at = "text-muted-foreground hidden w-full justify-center py-2 text-center group-data-empty/combobox-content:flex text-sm";
|
|
1656
|
+
function ot({ className: n, side: i = "bottom", sideOffset: a = 6, align: o = "start", alignOffset: s = 0, anchor: c, collisionBoundary: l, collisionPadding: u, sticky: d, positionMethod: f, container: p, ref: m, ...h }) {
|
|
1657
|
+
let { labels: _ } = C(), v = t.useRef(null), y = t.useCallback((e) => {
|
|
1658
|
+
v.current = e, typeof m == "function" ? m(e) : m && (m.current = e);
|
|
1659
|
+
}, [m]), b = t.useCallback((e) => {
|
|
1660
|
+
let t = v.current;
|
|
1661
|
+
return t ? e === "touch" ? t : t.querySelector("[data-slot=\"cascader-input\"]") ?? !0 : !0;
|
|
1662
|
+
}, []);
|
|
1663
|
+
return /* @__PURE__ */ r(g.Portal, {
|
|
1664
|
+
...p === void 0 ? null : { container: p },
|
|
1665
|
+
children: /* @__PURE__ */ r(g.Positioner, {
|
|
1666
|
+
side: i,
|
|
1667
|
+
sideOffset: a,
|
|
1668
|
+
align: o,
|
|
1669
|
+
alignOffset: s,
|
|
1670
|
+
anchor: c,
|
|
1671
|
+
...l === void 0 ? null : { collisionBoundary: l },
|
|
1672
|
+
...u === void 0 ? null : { collisionPadding: u },
|
|
1673
|
+
...d === void 0 ? null : { sticky: d },
|
|
1674
|
+
...f === void 0 ? null : { positionMethod: f },
|
|
1675
|
+
className: "isolate z-50",
|
|
1676
|
+
children: /* @__PURE__ */ r(g.Popup, {
|
|
1677
|
+
ref: y,
|
|
1678
|
+
"data-slot": "cascader-content",
|
|
1679
|
+
"data-menu-target": "",
|
|
1680
|
+
"aria-label": _.panelLabel,
|
|
1681
|
+
initialFocus: b,
|
|
1682
|
+
className: e(W, "group/combobox-content relative flex max-h-(--available-height) max-w-(--available-width) min-w-(--anchor-width) origin-(--transform-origin) flex-col", n),
|
|
1683
|
+
...h
|
|
1684
|
+
})
|
|
1685
|
+
})
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
function st({ className: n, ...r }) {
|
|
1689
|
+
let { mode: i } = C(), a = {
|
|
1690
|
+
"data-slot": "cascader-panel",
|
|
1691
|
+
"data-mode": i,
|
|
1692
|
+
onKeyDown: t.useCallback((e) => {
|
|
1693
|
+
if (e.key !== "Tab" || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
1694
|
+
let t = e.currentTarget, n = e.target;
|
|
1695
|
+
if (!n || !t.contains(n)) return;
|
|
1696
|
+
let r = se(t, n, e.shiftKey);
|
|
1697
|
+
r && (e.preventDefault(), r.focus());
|
|
1698
|
+
}, []),
|
|
1699
|
+
className: e("flex max-h-full min-h-0 w-full flex-col", n)
|
|
1700
|
+
};
|
|
1701
|
+
return m({
|
|
1702
|
+
defaultTagName: "div",
|
|
1703
|
+
render: r.render,
|
|
1704
|
+
props: p(a, r)
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
function ct({ className: t, style: n, maxHeight: i, ...a }) {
|
|
1708
|
+
let { maxHeight: o, mode: s, labels: c, baseId: l, virtualized: u, searchScope: d } = C(), { currentParent: f, deepResults: p } = x(), m = i ?? o, h = d === "global" && p ? c.rootLevel : f?.label ?? c.rootLevel;
|
|
1709
|
+
return /* @__PURE__ */ r("div", {
|
|
1710
|
+
"data-slot": "cascader-list-shell",
|
|
1711
|
+
style: m == null ? n : {
|
|
1712
|
+
...n,
|
|
1713
|
+
"--cascader-max-height": typeof m == "number" ? `${m}px` : m
|
|
1714
|
+
},
|
|
1715
|
+
className: e("relative flex max-h-full min-h-0", M),
|
|
1716
|
+
children: /* @__PURE__ */ r("div", {
|
|
1717
|
+
"data-slot": "cascader-list-bounds",
|
|
1718
|
+
className: e("flex w-full min-w-0 flex-col overscroll-contain", j),
|
|
1719
|
+
children: /* @__PURE__ */ r(v, {
|
|
1720
|
+
className: te,
|
|
1721
|
+
children: /* @__PURE__ */ r(g.List, {
|
|
1722
|
+
"data-slot": "cascader-list",
|
|
1723
|
+
"aria-label": h,
|
|
1724
|
+
id: `${l}-column-0`,
|
|
1725
|
+
...s === "tree" ? { role: "tree" } : null,
|
|
1726
|
+
...u ? { "data-virtualized": !0 } : null,
|
|
1727
|
+
className: e(ne, u && "relative", t),
|
|
1728
|
+
...a
|
|
1729
|
+
})
|
|
1730
|
+
})
|
|
1731
|
+
})
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
function lt({ className: t, children: n, skeletonRows: a, ...o }) {
|
|
1735
|
+
let { labels: s, retryLevel: c } = C(), { query: l, path: u, searchState: d } = x(), f = u.length ? u[u.length - 1] : k, p = ze(f), m = l.trim() ? d ?? p : p, h = n ?? s.empty;
|
|
1736
|
+
return m?.error ? h = /* @__PURE__ */ i("span", {
|
|
1737
|
+
"data-slot": "cascader-error",
|
|
1738
|
+
className: "flex flex-col items-center gap-1.5",
|
|
1739
|
+
children: [/* @__PURE__ */ r("span", { children: s.error }), /* @__PURE__ */ r("button", {
|
|
1740
|
+
type: "button",
|
|
1741
|
+
"data-slot": "cascader-retry",
|
|
1742
|
+
onClick: () => c(f),
|
|
1743
|
+
className: "text-foreground hover:bg-accent focus-visible:ring-ring/50 rounded-md px-2 py-0.5 font-medium outline-hidden transition-colors focus-visible:ring-2",
|
|
1744
|
+
children: s.retry
|
|
1745
|
+
})]
|
|
1746
|
+
}) : m?.loading && (h = /* @__PURE__ */ r("span", {
|
|
1747
|
+
"data-slot": "cascader-loading",
|
|
1748
|
+
className: "flex w-full items-center justify-center",
|
|
1749
|
+
children: s.loading
|
|
1750
|
+
})), /* @__PURE__ */ r(g.Empty, {
|
|
1751
|
+
"data-slot": "cascader-empty",
|
|
1752
|
+
"data-state": m?.error ? "error" : m?.loading ? "loading" : "empty",
|
|
1753
|
+
className: e(at, t),
|
|
1754
|
+
role: void 0,
|
|
1755
|
+
"aria-live": void 0,
|
|
1756
|
+
"aria-atomic": void 0,
|
|
1757
|
+
...o,
|
|
1758
|
+
children: h
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
function G({ className: t, children: n, ...i }) {
|
|
1762
|
+
let { announcement: a } = x();
|
|
1763
|
+
return /* @__PURE__ */ r(g.Status, {
|
|
1764
|
+
"data-slot": "cascader-status",
|
|
1765
|
+
className: e("sr-only", t),
|
|
1766
|
+
...i,
|
|
1767
|
+
children: n ?? a
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
//#endregion
|
|
1771
|
+
//#region src/reui/spinner.tsx
|
|
1772
|
+
function K({ className: t, ...n }) {
|
|
1773
|
+
return /* @__PURE__ */ r("span", {
|
|
1774
|
+
"data-slot": "spinner",
|
|
1775
|
+
className: e("inline-flex shrink-0 items-center justify-center", t),
|
|
1776
|
+
...n,
|
|
1777
|
+
children: /* @__PURE__ */ r(l, { className: "size-full animate-spin" })
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
//#endregion
|
|
1781
|
+
//#region src/reui/cascader/cascader-item.tsx
|
|
1782
|
+
var q = "[--cascader-row-inset:6px]", J = "ps-[var(--cascader-row-inset,8px)]! pe-[var(--cascader-row-inset,8px)]!", Y = "ps-[var(--cascader-row-inset,8px)]! pe-[calc(var(--cascader-row-inset,8px)*2_+_16px)]!", ut = "pointer-events-none absolute flex items-center justify-center size-4 end-[var(--cascader-row-inset,8px)]! rtl:right-auto!", dt = "data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground [&_svg:not([class*='size-'])]:size-4 rounded-md py-1", X = "gap-2", ft = "text-sm", pt = `${dt} relative flex w-full cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 ${q}`, mt = `${pt} ${X} ${ft}`, ht = `${q} ${J}`;
|
|
1783
|
+
`${pt}${ft}${J}`;
|
|
1784
|
+
var Z = "flex size-5 shrink-0 items-center justify-center rounded-sm", gt = "transition-[background-color,box-shadow,color] hover:bg-background hover:text-foreground! hover:**:text-foreground! hover:shadow-xs", _t = "text-primary-foreground! **:text-primary-foreground!", vt = "text-foreground! **:text-foreground!", yt = 150, bt = t.memo(function({ node: a, index: o, depth: s, showPath: c = !1, as: l = "option", expanded: u, indent: d = 16, branch: f, selectable: p, selected: m, indeterminate: h, selectedCount: _, loading: v, error: y, childrenLoading: b = !1, childrenError: x = !1, className: S, children: ee, onClick: T, onMouseUp: E, style: D, ...O }) {
|
|
1785
|
+
let { index: k, mode: A, labels: j, isBranch: M, isSelectable: te, isDisabled: ne, isSelected: re, isIndeterminate: ie, selectedDescendantCount: ae, multiple: N, branchesSelectable: oe, indicator: se, expandTrigger: P = "click", navigate: F, navigateAt: ue, toggleExpanded: de, commit: fe, getState: pe, virtualized: he, loadMore: ge, retryLevel: ve } = C(), { renderItem: ye, renderLabel: be } = w(), I = f ?? M(a), L = p ?? te(a), R = ne(a), xe = m ?? re(a), Se = !xe && (h ?? ie(a)), Ce = I ? me(k, a) : 0, we = s ?? k.depthOf.get(a.value) ?? 0, Te = I ? _ ?? ae(a) : 0, Ee = N && Te > 0, z = Ee ? Te : Ce, De = z > 0, Oe = A === "tree" && N, ke = se || N, B = t.useCallback((e) => {
|
|
1786
|
+
e.preventBaseUIHandler?.();
|
|
1787
|
+
}, []), Ae = t.useCallback((e) => {
|
|
1788
|
+
T?.(e), !R && I && !L && (B(e), F(a));
|
|
1789
|
+
}, [
|
|
1790
|
+
T,
|
|
1791
|
+
a,
|
|
1792
|
+
R,
|
|
1793
|
+
I,
|
|
1794
|
+
L,
|
|
1795
|
+
B,
|
|
1796
|
+
F
|
|
1797
|
+
]), je = t.useCallback((e) => {
|
|
1798
|
+
E?.(e), !R && I && !L && B(e);
|
|
1799
|
+
}, [
|
|
1800
|
+
E,
|
|
1801
|
+
R,
|
|
1802
|
+
I,
|
|
1803
|
+
L,
|
|
1804
|
+
B
|
|
1805
|
+
]), Me = t.useCallback((e) => {
|
|
1806
|
+
e.stopPropagation(), B(e), u ? (!R || pe().expanded.has(a.value)) && de(a.value) : R || F(a);
|
|
1807
|
+
}, [
|
|
1808
|
+
B,
|
|
1809
|
+
a,
|
|
1810
|
+
R,
|
|
1811
|
+
u,
|
|
1812
|
+
pe,
|
|
1813
|
+
de,
|
|
1814
|
+
F
|
|
1815
|
+
]), Ne = t.useCallback((e) => {
|
|
1816
|
+
e.stopPropagation(), B(e);
|
|
1817
|
+
}, [B]), Pe = t.useCallback((e) => {
|
|
1818
|
+
e.stopPropagation(), B(e), !R && (l === "button" ? ue(a, s ?? 0) : F(a));
|
|
1819
|
+
}, [
|
|
1820
|
+
B,
|
|
1821
|
+
a,
|
|
1822
|
+
R,
|
|
1823
|
+
l,
|
|
1824
|
+
ue,
|
|
1825
|
+
s,
|
|
1826
|
+
F
|
|
1827
|
+
]), Fe = t.useCallback((e) => B(e), [B]), Ie = t.useCallback((e) => {
|
|
1828
|
+
e.preventDefault();
|
|
1829
|
+
}, []), Le = t.useCallback((e) => {
|
|
1830
|
+
if (T?.(e), !R) {
|
|
1831
|
+
if (I && !L) {
|
|
1832
|
+
ue(a, s ?? 0);
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
L && fe(a);
|
|
1836
|
+
}
|
|
1837
|
+
}, [
|
|
1838
|
+
T,
|
|
1839
|
+
a,
|
|
1840
|
+
R,
|
|
1841
|
+
I,
|
|
1842
|
+
L,
|
|
1843
|
+
ue,
|
|
1844
|
+
s,
|
|
1845
|
+
fe
|
|
1846
|
+
]), Re = t.useCallback((e) => {
|
|
1847
|
+
T?.(e), B(e);
|
|
1848
|
+
let t = le(a);
|
|
1849
|
+
t != null && (y ? ve(t) : v || ge(t));
|
|
1850
|
+
}, [
|
|
1851
|
+
T,
|
|
1852
|
+
B,
|
|
1853
|
+
a,
|
|
1854
|
+
y,
|
|
1855
|
+
v,
|
|
1856
|
+
ve,
|
|
1857
|
+
ge
|
|
1858
|
+
]), ze = P === "hover" && A === "columns" && l === "option" && I && !R, Be = t.useRef(null), V = t.useCallback(() => {
|
|
1859
|
+
Be.current != null && (window.clearTimeout(Be.current), Be.current = null);
|
|
1860
|
+
}, []), Ve = t.useCallback(() => {
|
|
1861
|
+
V(), Be.current = window.setTimeout(() => {
|
|
1862
|
+
Be.current = null, F(a);
|
|
1863
|
+
}, yt);
|
|
1864
|
+
}, [
|
|
1865
|
+
V,
|
|
1866
|
+
F,
|
|
1867
|
+
a
|
|
1868
|
+
]);
|
|
1869
|
+
if (t.useEffect(() => {
|
|
1870
|
+
ze || V();
|
|
1871
|
+
}, [ze, V]), t.useEffect(() => V, [V]), ce(a)) {
|
|
1872
|
+
let t = y ? j.error : v ? a.count ? j.loadingMore : j.loading : j.loadMore, s = A === "tree" && we > 0 ? {
|
|
1873
|
+
...D,
|
|
1874
|
+
"--cascader-indent": `${we * d}px`
|
|
1875
|
+
} : D, c = {
|
|
1876
|
+
"data-slot": "cascader-item",
|
|
1877
|
+
"data-more": "",
|
|
1878
|
+
"data-state": y ? "error" : v ? "loading" : "idle",
|
|
1879
|
+
"data-depth": we,
|
|
1880
|
+
style: s,
|
|
1881
|
+
className: e(pt, J, "text-muted-foreground justify-center gap-1.5 text-xs", !y && !v && "hover:text-foreground", A === "tree" && "ps-[calc(var(--cascader-row-inset,8px)_+_var(--cascader-indent,0px))]!", S)
|
|
1882
|
+
}, u = ee ?? /* @__PURE__ */ i(n, { children: [
|
|
1883
|
+
v ? /* @__PURE__ */ r(U, {
|
|
1884
|
+
lucide: "LoaderCircleIcon",
|
|
1885
|
+
tabler: "IconLoader2",
|
|
1886
|
+
hugeicons: "Loading02Icon",
|
|
1887
|
+
phosphor: "CircleNotchIcon",
|
|
1888
|
+
remixicon: "RiLoader4Line",
|
|
1889
|
+
className: "size-3.5 animate-spin",
|
|
1890
|
+
"aria-hidden": !0
|
|
1891
|
+
}) : null,
|
|
1892
|
+
/* @__PURE__ */ r("span", { children: t }),
|
|
1893
|
+
y ? /* @__PURE__ */ r("span", {
|
|
1894
|
+
className: "text-foreground font-medium",
|
|
1895
|
+
children: j.retry
|
|
1896
|
+
}) : null
|
|
1897
|
+
] });
|
|
1898
|
+
if (l === "button") {
|
|
1899
|
+
let e = { ...O };
|
|
1900
|
+
return delete e["aria-setsize"], delete e["aria-posinset"], delete e["aria-level"], /* @__PURE__ */ r("button", {
|
|
1901
|
+
type: "button",
|
|
1902
|
+
...c,
|
|
1903
|
+
tabIndex: -1,
|
|
1904
|
+
onClick: Re,
|
|
1905
|
+
...e,
|
|
1906
|
+
children: u
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
return /* @__PURE__ */ r(g.Item, {
|
|
1910
|
+
...c,
|
|
1911
|
+
value: a,
|
|
1912
|
+
...he && o != null ? { index: o } : null,
|
|
1913
|
+
...A === "tree" ? {
|
|
1914
|
+
role: "treeitem",
|
|
1915
|
+
"aria-level": we + 1
|
|
1916
|
+
} : null,
|
|
1917
|
+
onClick: Re,
|
|
1918
|
+
onMouseUp: B,
|
|
1919
|
+
...O,
|
|
1920
|
+
children: u
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
let He = {
|
|
1924
|
+
branch: I,
|
|
1925
|
+
selected: xe,
|
|
1926
|
+
disabled: R,
|
|
1927
|
+
depth: we,
|
|
1928
|
+
count: Ce,
|
|
1929
|
+
path: c ? _e(k, a.value).slice(0, -1) : []
|
|
1930
|
+
}, Ue = ye?.(a, He), H = be?.(a, He), We = [
|
|
1931
|
+
I ? j.itemCount(Ce) : null,
|
|
1932
|
+
Ee ? j.selectedCount(Te) : null,
|
|
1933
|
+
I && A !== "tree" ? j.branchAffordance : null,
|
|
1934
|
+
l === "button" && xe ? j.selectedState : null,
|
|
1935
|
+
l === "button" && Se ? j.partiallySelectedState : null
|
|
1936
|
+
].filter(Boolean).map((e) => `, ${e}`).join(""), Ge = /* @__PURE__ */ r("span", {
|
|
1937
|
+
"data-slot": "cascader-item-checkbox",
|
|
1938
|
+
className: "border-input in-data-[selected]:bg-primary in-data-[selected]:border-primary in-data-[selected]:text-primary-foreground in-data-[indeterminate]:bg-primary in-data-[indeterminate]:border-primary in-data-[indeterminate]:text-primary-foreground flex size-4 shrink-0 items-center justify-center rounded-[4px] border transition-colors",
|
|
1939
|
+
children: Se ? /* @__PURE__ */ r(U, {
|
|
1940
|
+
lucide: "MinusIcon",
|
|
1941
|
+
tabler: "IconMinus",
|
|
1942
|
+
hugeicons: "MinusSignIcon",
|
|
1943
|
+
phosphor: "MinusIcon",
|
|
1944
|
+
remixicon: "RiSubtractLine",
|
|
1945
|
+
"data-slot": "cascader-item-dash",
|
|
1946
|
+
className: e(_t, "size-3")
|
|
1947
|
+
}) : /* @__PURE__ */ r(U, {
|
|
1948
|
+
lucide: "CheckIcon",
|
|
1949
|
+
tabler: "IconCheck",
|
|
1950
|
+
hugeicons: "Tick02Icon",
|
|
1951
|
+
phosphor: "CheckIcon",
|
|
1952
|
+
remixicon: "RiCheckLine",
|
|
1953
|
+
"data-slot": "cascader-item-tick",
|
|
1954
|
+
className: e(_t, "size-3 opacity-0 in-data-[selected]:opacity-100")
|
|
1955
|
+
})
|
|
1956
|
+
}), Ke = /* @__PURE__ */ r(n, { children: N ? Ge : /* @__PURE__ */ r(U, {
|
|
1957
|
+
lucide: "CheckIcon",
|
|
1958
|
+
tabler: "IconCheck",
|
|
1959
|
+
hugeicons: "Tick02Icon",
|
|
1960
|
+
phosphor: "CheckIcon",
|
|
1961
|
+
remixicon: "RiCheckLine",
|
|
1962
|
+
"data-slot": "cascader-item-check",
|
|
1963
|
+
className: e("pointer-events-none", vt)
|
|
1964
|
+
}) }), qe = Ue ?? ee ?? /* @__PURE__ */ i(n, { children: [
|
|
1965
|
+
A === "tree" && I ? /* @__PURE__ */ r("span", {
|
|
1966
|
+
"data-slot": "cascader-item-expander",
|
|
1967
|
+
"aria-hidden": "true",
|
|
1968
|
+
"data-state": x ? "error" : b ? "loading" : "idle",
|
|
1969
|
+
onClick: Me,
|
|
1970
|
+
onMouseUp: Ne,
|
|
1971
|
+
className: e("-ms-0.5", x ? "text-destructive" : "text-muted-foreground", Z, gt, R && u && "pointer-events-auto", b && "pointer-events-none"),
|
|
1972
|
+
children: b ? /* @__PURE__ */ r(K, {
|
|
1973
|
+
"aria-hidden": "true",
|
|
1974
|
+
className: "size-4"
|
|
1975
|
+
}) : x ? /* @__PURE__ */ r(U, {
|
|
1976
|
+
lucide: "RotateCwIcon",
|
|
1977
|
+
tabler: "IconRefresh",
|
|
1978
|
+
hugeicons: "RefreshIcon",
|
|
1979
|
+
phosphor: "ArrowClockwiseIcon",
|
|
1980
|
+
remixicon: "RiRefreshLine",
|
|
1981
|
+
className: "size-4"
|
|
1982
|
+
}) : /* @__PURE__ */ r(U, {
|
|
1983
|
+
lucide: "ChevronRightIcon",
|
|
1984
|
+
tabler: "IconChevronRight",
|
|
1985
|
+
hugeicons: "ArrowRight01Icon",
|
|
1986
|
+
phosphor: "CaretRightIcon",
|
|
1987
|
+
remixicon: "RiArrowRightSLine",
|
|
1988
|
+
className: e("size-4 transition-transform", u ? "rotate-90" : "rtl:-scale-x-100")
|
|
1989
|
+
})
|
|
1990
|
+
}) : A === "tree" ? /* @__PURE__ */ r("span", {
|
|
1991
|
+
"data-slot": "cascader-item-expander-spacer",
|
|
1992
|
+
"aria-hidden": "true",
|
|
1993
|
+
className: e("-ms-0.5", Z)
|
|
1994
|
+
}) : null,
|
|
1995
|
+
Oe ? L ? Ge : /* @__PURE__ */ r("span", {
|
|
1996
|
+
"data-slot": "cascader-item-checkbox-spacer",
|
|
1997
|
+
"aria-hidden": "true",
|
|
1998
|
+
className: "size-4 shrink-0"
|
|
1999
|
+
}) : null,
|
|
2000
|
+
a.icon ? /* @__PURE__ */ r("span", {
|
|
2001
|
+
"data-slot": "cascader-item-icon",
|
|
2002
|
+
className: "text-muted-foreground flex shrink-0 items-center justify-center",
|
|
2003
|
+
children: a.icon
|
|
2004
|
+
}) : null,
|
|
2005
|
+
/* @__PURE__ */ i("span", {
|
|
2006
|
+
className: "flex min-w-0 flex-1 flex-col items-start gap-0.5",
|
|
2007
|
+
children: [H ?? /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r("span", {
|
|
2008
|
+
className: "w-full truncate text-start",
|
|
2009
|
+
children: a.label
|
|
2010
|
+
}), a.description ? /* @__PURE__ */ r("span", {
|
|
2011
|
+
"data-slot": "cascader-item-description",
|
|
2012
|
+
className: "text-muted-foreground w-full truncate text-start text-xs",
|
|
2013
|
+
children: a.description
|
|
2014
|
+
}) : null] }), c ? /* @__PURE__ */ r(xt, { node: a }) : null]
|
|
2015
|
+
}),
|
|
2016
|
+
We ? /* @__PURE__ */ r("span", {
|
|
2017
|
+
"data-slot": "cascader-item-details",
|
|
2018
|
+
className: "sr-only",
|
|
2019
|
+
children: We
|
|
2020
|
+
}) : null,
|
|
2021
|
+
I && A !== "tree" ? /* @__PURE__ */ i("span", {
|
|
2022
|
+
"data-slot": "cascader-item-trailing",
|
|
2023
|
+
"aria-hidden": "true",
|
|
2024
|
+
className: "text-muted-foreground ms-auto flex shrink-0 items-center gap-1 text-xs tabular-nums",
|
|
2025
|
+
children: [De ? /* @__PURE__ */ r("span", {
|
|
2026
|
+
"data-slot": "cascader-item-count",
|
|
2027
|
+
...Ee ? { "data-selected-count": "" } : null,
|
|
2028
|
+
className: e(Ee && "text-primary!"),
|
|
2029
|
+
children: z
|
|
2030
|
+
}) : null, /* @__PURE__ */ r("span", {
|
|
2031
|
+
"data-slot": "cascader-item-chevron",
|
|
2032
|
+
"data-state": x ? "error" : b ? "loading" : "idle",
|
|
2033
|
+
onClick: L ? Pe : void 0,
|
|
2034
|
+
onMouseUp: L ? Fe : void 0,
|
|
2035
|
+
onMouseDown: l === "button" ? Ie : void 0,
|
|
2036
|
+
className: e("-me-0.5", Z, L && gt, x && "text-destructive", b && "pointer-events-none"),
|
|
2037
|
+
children: b ? /* @__PURE__ */ r(K, {
|
|
2038
|
+
"aria-hidden": "true",
|
|
2039
|
+
className: "size-4"
|
|
2040
|
+
}) : x ? /* @__PURE__ */ r(U, {
|
|
2041
|
+
lucide: "RotateCwIcon",
|
|
2042
|
+
tabler: "IconRefresh",
|
|
2043
|
+
hugeicons: "RefreshIcon",
|
|
2044
|
+
phosphor: "ArrowClockwiseIcon",
|
|
2045
|
+
remixicon: "RiRefreshLine",
|
|
2046
|
+
className: "size-4"
|
|
2047
|
+
}) : /* @__PURE__ */ r(U, {
|
|
2048
|
+
lucide: "ChevronRightIcon",
|
|
2049
|
+
tabler: "IconChevronRight",
|
|
2050
|
+
hugeicons: "ArrowRight01Icon",
|
|
2051
|
+
phosphor: "CaretRightIcon",
|
|
2052
|
+
remixicon: "RiArrowRightSLine",
|
|
2053
|
+
className: "size-4 rtl:-scale-x-100"
|
|
2054
|
+
})
|
|
2055
|
+
})]
|
|
2056
|
+
}) : null,
|
|
2057
|
+
I && A === "tree" && De ? /* @__PURE__ */ r("span", {
|
|
2058
|
+
"data-slot": "cascader-item-count",
|
|
2059
|
+
...Ee ? { "data-selected-count": "" } : null,
|
|
2060
|
+
"aria-hidden": "true",
|
|
2061
|
+
className: e("text-muted-foreground ms-auto shrink-0 text-xs tabular-nums", Ee && "text-primary!"),
|
|
2062
|
+
children: z
|
|
2063
|
+
}) : null,
|
|
2064
|
+
L && !Oe && ke ? l === "button" ? (N || xe) && /* @__PURE__ */ r("span", {
|
|
2065
|
+
"data-slot": "cascader-item-indicator",
|
|
2066
|
+
className: ut,
|
|
2067
|
+
children: Ke
|
|
2068
|
+
}) : /* @__PURE__ */ r(g.ItemIndicator, {
|
|
2069
|
+
keepMounted: N || Se,
|
|
2070
|
+
render: /* @__PURE__ */ r("span", {
|
|
2071
|
+
"data-slot": "cascader-item-indicator",
|
|
2072
|
+
className: ut
|
|
2073
|
+
}),
|
|
2074
|
+
children: Ke
|
|
2075
|
+
}) : null
|
|
2076
|
+
] }), Je = A === "tree" && we > 0 ? {
|
|
2077
|
+
...D,
|
|
2078
|
+
"--cascader-indent": `${we * d}px`
|
|
2079
|
+
} : D, Ye = {
|
|
2080
|
+
"data-slot": "cascader-item",
|
|
2081
|
+
"data-branch": I || void 0,
|
|
2082
|
+
"data-selected": xe || void 0,
|
|
2083
|
+
"data-indeterminate": Se || void 0,
|
|
2084
|
+
"data-depth": we,
|
|
2085
|
+
"data-expanded": u || void 0,
|
|
2086
|
+
style: Je,
|
|
2087
|
+
className: e(mt, Oe || !ke || I && !oe ? J : Y, A === "tree" && "ps-[calc(var(--cascader-row-inset,8px)_+_var(--cascader-indent,0px))]!", S)
|
|
2088
|
+
};
|
|
2089
|
+
if (l === "button") {
|
|
2090
|
+
let e = { ...O };
|
|
2091
|
+
return delete e["aria-setsize"], delete e["aria-posinset"], delete e["aria-level"], /* @__PURE__ */ r("button", {
|
|
2092
|
+
type: "button",
|
|
2093
|
+
...Ye,
|
|
2094
|
+
tabIndex: -1,
|
|
2095
|
+
disabled: R,
|
|
2096
|
+
"aria-disabled": R || void 0,
|
|
2097
|
+
onClick: Le,
|
|
2098
|
+
onMouseDown: Ie,
|
|
2099
|
+
...e,
|
|
2100
|
+
children: qe
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
return /* @__PURE__ */ r(g.Item, {
|
|
2104
|
+
...Ye,
|
|
2105
|
+
value: a,
|
|
2106
|
+
...he && o != null ? { index: o } : null,
|
|
2107
|
+
disabled: R,
|
|
2108
|
+
...A === "tree" ? {
|
|
2109
|
+
role: "treeitem",
|
|
2110
|
+
"aria-level": we + 1,
|
|
2111
|
+
...I ? { "aria-expanded": !!u } : null
|
|
2112
|
+
} : I ? { "aria-haspopup": "listbox" } : null,
|
|
2113
|
+
...Se ? { "aria-checked": "mixed" } : null,
|
|
2114
|
+
...ze ? {
|
|
2115
|
+
onPointerEnter: Ve,
|
|
2116
|
+
onPointerLeave: V
|
|
2117
|
+
} : null,
|
|
2118
|
+
onClick: Ae,
|
|
2119
|
+
onMouseUp: je,
|
|
2120
|
+
...O,
|
|
2121
|
+
children: qe
|
|
2122
|
+
});
|
|
2123
|
+
});
|
|
2124
|
+
function xt({ node: e }) {
|
|
2125
|
+
let { index: n, labels: a } = C(), o = _e(n, e.value).slice(0, -1);
|
|
2126
|
+
return o.length ? /* @__PURE__ */ r("span", {
|
|
2127
|
+
"data-slot": "cascader-item-path",
|
|
2128
|
+
className: "text-muted-foreground flex w-full items-center gap-0.5 truncate text-start text-xs",
|
|
2129
|
+
children: o.map((e, n) => /* @__PURE__ */ i(t.Fragment, { children: [n > 0 ? /* @__PURE__ */ r("span", {
|
|
2130
|
+
"aria-hidden": "true",
|
|
2131
|
+
children: a.pathSeparator
|
|
2132
|
+
}) : null, /* @__PURE__ */ r("span", {
|
|
2133
|
+
className: "truncate",
|
|
2134
|
+
children: e.label
|
|
2135
|
+
})] }, e.value))
|
|
2136
|
+
}) : null;
|
|
2137
|
+
}
|
|
2138
|
+
function St(e, t) {
|
|
2139
|
+
let n = le(e);
|
|
2140
|
+
if (n == null) {
|
|
2141
|
+
let n = t.get(e.value);
|
|
2142
|
+
return {
|
|
2143
|
+
loading: !1,
|
|
2144
|
+
error: !1,
|
|
2145
|
+
childrenLoading: !!n?.loading,
|
|
2146
|
+
childrenError: !!n?.error
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
let r = t.get(n);
|
|
2150
|
+
return {
|
|
2151
|
+
loading: !!r?.loading,
|
|
2152
|
+
error: !!r?.error,
|
|
2153
|
+
childrenLoading: !1,
|
|
2154
|
+
childrenError: !1
|
|
2155
|
+
};
|
|
2156
|
+
}
|
|
2157
|
+
function Ct({ children: e }) {
|
|
2158
|
+
let { mode: i, isBranch: a, isSelectable: o, isSelected: s, isIndeterminate: c } = C(), { renderedItems: l, deepResults: u, treeRows: d, loadStates: f } = x(), p = u !== null;
|
|
2159
|
+
return i === "tree" ? /* @__PURE__ */ r(n, { children: d.map((n, i) => e ? /* @__PURE__ */ r(t.Fragment, { children: e(n.node, i) }, n.node.value) : /* @__PURE__ */ r(bt, {
|
|
2160
|
+
node: n.node,
|
|
2161
|
+
depth: n.depth,
|
|
2162
|
+
expanded: n.expanded,
|
|
2163
|
+
branch: n.branch,
|
|
2164
|
+
selectable: o(n.node),
|
|
2165
|
+
selected: s(n.node),
|
|
2166
|
+
indeterminate: c(n.node),
|
|
2167
|
+
...St(n.node, f),
|
|
2168
|
+
"aria-setsize": n.setSize,
|
|
2169
|
+
"aria-posinset": n.posInSet
|
|
2170
|
+
}, n.node.value)) }) : /* @__PURE__ */ r(n, { children: l.map((n, i) => e ? /* @__PURE__ */ r(t.Fragment, { children: e(n, i) }, n.value) : /* @__PURE__ */ r(bt, {
|
|
2171
|
+
node: n,
|
|
2172
|
+
showPath: p,
|
|
2173
|
+
branch: a(n),
|
|
2174
|
+
selectable: o(n),
|
|
2175
|
+
selected: s(n),
|
|
2176
|
+
indeterminate: c(n),
|
|
2177
|
+
...St(n, f),
|
|
2178
|
+
"aria-setsize": l.length,
|
|
2179
|
+
"aria-posinset": i + 1
|
|
2180
|
+
}, n.value)) });
|
|
2181
|
+
}
|
|
2182
|
+
t.createContext(!1), `${ht}`;
|
|
2183
|
+
//#endregion
|
|
2184
|
+
//#region src/reui/cascader/cascader-nav.tsx
|
|
2185
|
+
function wt() {
|
|
2186
|
+
return /* @__PURE__ */ r(U, {
|
|
2187
|
+
lucide: "ChevronRightIcon",
|
|
2188
|
+
tabler: "IconChevronRight",
|
|
2189
|
+
hugeicons: "ArrowRight01Icon",
|
|
2190
|
+
phosphor: "CaretRightIcon",
|
|
2191
|
+
remixicon: "RiArrowRightSLine",
|
|
2192
|
+
className: "size-3 shrink-0 opacity-50 rtl:-scale-x-100"
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
function Tt({ className: t, ...n }) {
|
|
2196
|
+
let r = {
|
|
2197
|
+
"data-slot": "cascader-nav",
|
|
2198
|
+
className: e("border-border/60 flex shrink-0 flex-col gap-1 border-b px-1.5 py-1", t)
|
|
2199
|
+
};
|
|
2200
|
+
return m({
|
|
2201
|
+
defaultTagName: "div",
|
|
2202
|
+
render: n.render,
|
|
2203
|
+
props: p(r, n)
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
function Et({ className: t, children: n, ...i }) {
|
|
2207
|
+
let { popLevel: a, labels: o, mode: s } = C(), { path: c } = x(), l = s !== "drill" || c.length === 0, u = {
|
|
2208
|
+
"data-slot": "cascader-back",
|
|
2209
|
+
type: "button",
|
|
2210
|
+
"aria-label": o.back,
|
|
2211
|
+
onClick: () => a(),
|
|
2212
|
+
className: e("text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:ring-ring/50 flex shrink-0 items-center justify-center rounded-md outline-hidden transition-colors focus-visible:ring-2", "size-6", t),
|
|
2213
|
+
children: n ?? /* @__PURE__ */ r(U, {
|
|
2214
|
+
lucide: "ChevronLeftIcon",
|
|
2215
|
+
tabler: "IconChevronLeft",
|
|
2216
|
+
hugeicons: "ArrowLeft01Icon",
|
|
2217
|
+
phosphor: "CaretLeftIcon",
|
|
2218
|
+
remixicon: "RiArrowLeftSLine",
|
|
2219
|
+
className: "size-4 rtl:-scale-x-100"
|
|
2220
|
+
})
|
|
2221
|
+
}, d = m({
|
|
2222
|
+
defaultTagName: "button",
|
|
2223
|
+
render: i.render,
|
|
2224
|
+
props: p(u, i)
|
|
2225
|
+
});
|
|
2226
|
+
return l ? null : d;
|
|
2227
|
+
}
|
|
2228
|
+
function Dt({ className: n, maxSegments: a = 3, collapse: o = "middle", interactive: s = !0, ...c }) {
|
|
2229
|
+
let { goToDepth: l, mode: u, labels: d } = C(), { path: f, index: h } = x(), g = f.map((e) => h.byValue.get(e)).filter(Boolean), _ = xe(g, {
|
|
2230
|
+
maxSegments: a,
|
|
2231
|
+
collapse: o
|
|
2232
|
+
}), v = g.length ? g[g.length - 1].value : null, y = u !== "drill" || g.length === 0, b = (e) => {
|
|
2233
|
+
let t = f.indexOf(e.value);
|
|
2234
|
+
t < 0 || l(t + 1);
|
|
2235
|
+
}, S = {
|
|
2236
|
+
"data-slot": "cascader-breadcrumb",
|
|
2237
|
+
"aria-label": d.breadcrumbLabel,
|
|
2238
|
+
className: e("text-muted-foreground flex min-w-0 shrink-0 items-center gap-0.5 pt-1.5 pb-0.5 text-xs", "px-2.5", n),
|
|
2239
|
+
children: _.map((n, a) => /* @__PURE__ */ i(t.Fragment, { children: [a > 0 ? /* @__PURE__ */ r(wt, {}) : null, n.type === "ellipsis" ? /* @__PURE__ */ r("span", {
|
|
2240
|
+
"data-slot": "cascader-breadcrumb-ellipsis",
|
|
2241
|
+
title: n.hidden.map((e) => e.label).join(` ${d.pathSeparator} `),
|
|
2242
|
+
className: "shrink-0",
|
|
2243
|
+
children: "…"
|
|
2244
|
+
}) : s && n.node.value !== v ? /* @__PURE__ */ r("button", {
|
|
2245
|
+
type: "button",
|
|
2246
|
+
"data-slot": "cascader-breadcrumb-item",
|
|
2247
|
+
onClick: () => b(n.node),
|
|
2248
|
+
className: "hover:text-foreground focus-visible:ring-ring/50 max-w-32 truncate rounded-sm outline-hidden transition-colors focus-visible:ring-2",
|
|
2249
|
+
children: n.node.label
|
|
2250
|
+
}) : /* @__PURE__ */ r("span", {
|
|
2251
|
+
"data-slot": "cascader-breadcrumb-item",
|
|
2252
|
+
...n.node.value === v ? { "aria-current": "page" } : null,
|
|
2253
|
+
className: e("max-w-32 truncate", n.node.value === v && "text-foreground font-medium"),
|
|
2254
|
+
children: n.node.label
|
|
2255
|
+
})] }, n.type === "node" ? n.node.value : `gap-${a}`))
|
|
2256
|
+
}, ee = m({
|
|
2257
|
+
defaultTagName: "nav",
|
|
2258
|
+
render: c.render,
|
|
2259
|
+
props: p(S, c)
|
|
2260
|
+
});
|
|
2261
|
+
return y ? null : ee;
|
|
2262
|
+
}
|
|
2263
|
+
function Ot({ className: n, showBack: a = !0, placeholder: o, onKeyDown: s, "aria-describedby": c, ...l }) {
|
|
2264
|
+
let { labels: u, popLevel: d, mode: f, getHighlighted: p, isBranch: m, isDisabled: h, navigate: v, index: y, toggleExpanded: b, inline: S, invalid: ee, baseId: w, searchScope: T } = C(), E = _(), { currentParent: D, query: O, path: k, expanded: A, renderedItems: j, treeRows: M } = x(), te = o ?? Ue(u, T === "global" ? void 0 : D?.label), ne = a && f === "drill" && k.length > 0, re = `${w}-hint`, ie = `${w}-column-${f === "columns" ? k.length : 0}`, ae = t.useRef(null), [N, se] = t.useState("ltr");
|
|
2265
|
+
t.useLayoutEffect(() => {
|
|
2266
|
+
let e = ae.current;
|
|
2267
|
+
e && se(P(e, E) ? "rtl" : "ltr");
|
|
2268
|
+
}, [E]);
|
|
2269
|
+
let F = (e, t) => {
|
|
2270
|
+
let n = () => {
|
|
2271
|
+
let e = p();
|
|
2272
|
+
return e ? M.findIndex((t) => t.node.value === e.value) : -1;
|
|
2273
|
+
}, r = n();
|
|
2274
|
+
for (let i = 0; i < M.length; i += 1) {
|
|
2275
|
+
if (r === -1 || r === t) return;
|
|
2276
|
+
let i = r > t ? "ArrowUp" : "ArrowDown";
|
|
2277
|
+
e.dispatchEvent(new KeyboardEvent("keydown", {
|
|
2278
|
+
key: i,
|
|
2279
|
+
bubbles: !0,
|
|
2280
|
+
cancelable: !0
|
|
2281
|
+
}));
|
|
2282
|
+
let a = n();
|
|
2283
|
+
if (a === -1 || !(i === "ArrowUp" ? a < r && a >= t : a > r && a <= t)) return;
|
|
2284
|
+
r = a;
|
|
2285
|
+
}
|
|
2286
|
+
}, ce = (e, t, n, r, i, a) => {
|
|
2287
|
+
let o = e.key === i;
|
|
2288
|
+
if (!o && e.key !== a || (o ? !r : !n)) return;
|
|
2289
|
+
let s = p();
|
|
2290
|
+
if (!s) return;
|
|
2291
|
+
let c = M.findIndex((e) => e.node.value === s.value);
|
|
2292
|
+
if (c < 0) return;
|
|
2293
|
+
let l = M[c];
|
|
2294
|
+
if (o) {
|
|
2295
|
+
if (!l.branch) return;
|
|
2296
|
+
if (e.preventDefault(), !l.expanded) {
|
|
2297
|
+
v(l.node);
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
let n = M[c + 1];
|
|
2301
|
+
n && n.depth === l.depth + 1 && F(t, c + 1);
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
let u = h(l.node) && !A.has(l.node.value);
|
|
2305
|
+
if (l.branch && l.expanded && !u) {
|
|
2306
|
+
e.preventDefault(), b(l.node.value);
|
|
2307
|
+
return;
|
|
2308
|
+
}
|
|
2309
|
+
let d = y.parentOf.get(l.node.value);
|
|
2310
|
+
if (!d) return;
|
|
2311
|
+
let f = M.findIndex((e) => e.node.value === d);
|
|
2312
|
+
f < 0 || (e.preventDefault(), F(t, f));
|
|
2313
|
+
};
|
|
2314
|
+
return /* @__PURE__ */ i("div", {
|
|
2315
|
+
"data-slot": "cascader-input-row",
|
|
2316
|
+
className: e("flex shrink-0 items-center gap-1", "h-8"),
|
|
2317
|
+
children: [
|
|
2318
|
+
a ? /* @__PURE__ */ r(Et, {}) : null,
|
|
2319
|
+
/* @__PURE__ */ r(g.Input, {
|
|
2320
|
+
"data-slot": "cascader-input",
|
|
2321
|
+
placeholder: te,
|
|
2322
|
+
onKeyDown: (e) => {
|
|
2323
|
+
if (s?.(e), e.defaultPrevented) return;
|
|
2324
|
+
let t = e.currentTarget, n = t.selectionStart === 0 && t.selectionEnd === 0, r = t.selectionStart === O.length && t.selectionEnd === O.length;
|
|
2325
|
+
if (e.key === "ArrowDown" && !e.altKey) {
|
|
2326
|
+
let n = f === "tree" ? M.length : j.length, r = f === "tree" ? M[n - 1]?.node.value : j[n - 1]?.value, i = p();
|
|
2327
|
+
if (n === 0 || i != null && i.value === r) {
|
|
2328
|
+
let n = t.closest("[data-slot=\"cascader-panel\"]"), r = n ? oe(n)[0] : void 0;
|
|
2329
|
+
if (r) {
|
|
2330
|
+
e.preventDefault(), r.focus();
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
let i = P(t, E), a = i ? "ArrowLeft" : "ArrowRight", o = i ? "ArrowRight" : "ArrowLeft";
|
|
2336
|
+
if (f === "tree") {
|
|
2337
|
+
ce(e, t, n, r, a, o);
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
if (e.key === a && r) {
|
|
2341
|
+
let t = p();
|
|
2342
|
+
if (t && m(t)) {
|
|
2343
|
+
e.preventDefault(), v(t);
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
(e.key === o && n || e.key === "Backspace" && O.length === 0) && k.length > 0 && (e.preventDefault(), d());
|
|
2348
|
+
},
|
|
2349
|
+
"aria-describedby": [c, re].filter(Boolean).join(" "),
|
|
2350
|
+
...f === "tree" ? { "aria-haspopup": "tree" } : null,
|
|
2351
|
+
...S ? {
|
|
2352
|
+
"aria-expanded": !0,
|
|
2353
|
+
"aria-controls": ie
|
|
2354
|
+
} : null,
|
|
2355
|
+
...ee ? {
|
|
2356
|
+
"aria-invalid": !0,
|
|
2357
|
+
"data-invalid": ""
|
|
2358
|
+
} : null,
|
|
2359
|
+
className: e("placeholder:text-muted-foreground h-full w-full min-w-0 flex-1 bg-transparent px-1.5 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", ne && "ps-0", n),
|
|
2360
|
+
...l
|
|
2361
|
+
}),
|
|
2362
|
+
/* @__PURE__ */ r("span", {
|
|
2363
|
+
id: re,
|
|
2364
|
+
ref: ae,
|
|
2365
|
+
className: "sr-only",
|
|
2366
|
+
children: u.keyboardHint(f, N)
|
|
2367
|
+
})
|
|
2368
|
+
]
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
function kt({ className: a, display: o = "path", maxSegments: s = 3, collapse: c = "middle", separator: l, showIcon: u = !0, placeholder: d, children: f, ...h }) {
|
|
2372
|
+
let { labels: g, multiple: _, resolveNode: v } = C(), { index: y, selectedValues: b } = x(), S = b.map(v), ee = b.length === 1 ? _e(y, b[0]) : [], w = ee.length > 0 ? ee : S.length === 1 ? S : [], T;
|
|
2373
|
+
if (f) T = f(S, w);
|
|
2374
|
+
else if (b.length === 0) T = /* @__PURE__ */ r("span", {
|
|
2375
|
+
className: "text-muted-foreground truncate",
|
|
2376
|
+
children: d
|
|
2377
|
+
});
|
|
2378
|
+
else if (o === "count" || _ && b.length > 1) T = g.selectedCount(b.length);
|
|
2379
|
+
else {
|
|
2380
|
+
let a = w[w.length - 1] ?? S[0], d = o === "leaf" ? [{
|
|
2381
|
+
type: "node",
|
|
2382
|
+
node: a
|
|
2383
|
+
}] : xe(w, {
|
|
2384
|
+
maxSegments: s,
|
|
2385
|
+
collapse: c
|
|
2386
|
+
});
|
|
2387
|
+
T = /* @__PURE__ */ i(n, { children: [u && a?.icon ? /* @__PURE__ */ r("span", {
|
|
2388
|
+
"data-slot": "cascader-value-icon",
|
|
2389
|
+
className: "text-muted-foreground flex shrink-0 items-center",
|
|
2390
|
+
children: a.icon
|
|
2391
|
+
}) : null, d.map((n, a) => /* @__PURE__ */ i(t.Fragment, { children: [a > 0 ? l ?? /* @__PURE__ */ r(wt, {}) : null, n.type === "ellipsis" ? /* @__PURE__ */ r("span", {
|
|
2392
|
+
"data-slot": "cascader-value-ellipsis",
|
|
2393
|
+
title: n.hidden.map((e) => e.label).join(` ${g.pathSeparator} `),
|
|
2394
|
+
className: "text-muted-foreground shrink-0",
|
|
2395
|
+
children: "…"
|
|
2396
|
+
}) : /* @__PURE__ */ r("span", {
|
|
2397
|
+
className: e("truncate", a < d.length - 1 && "text-muted-foreground"),
|
|
2398
|
+
children: n.node?.label
|
|
2399
|
+
})] }, n.type === "node" ? n.node.value : `gap-${a}`))] });
|
|
2400
|
+
}
|
|
2401
|
+
let E = {
|
|
2402
|
+
"data-slot": "cascader-value",
|
|
2403
|
+
className: e("flex min-w-0 items-center gap-1 truncate", a),
|
|
2404
|
+
children: T
|
|
2405
|
+
};
|
|
2406
|
+
return m({
|
|
2407
|
+
defaultTagName: "span",
|
|
2408
|
+
render: h.render,
|
|
2409
|
+
props: p(E, h)
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
//#endregion
|
|
2413
|
+
//#region src/reui/cascader/field-picker-popup.tsx
|
|
2414
|
+
function At({ nodes: e, onPick: t, onClose: n, disabled: a, triggerClassName: s, triggerLabel: c, placeholder: l }) {
|
|
2415
|
+
return /* @__PURE__ */ i(tt, {
|
|
2416
|
+
items: e,
|
|
2417
|
+
mode: "tree",
|
|
2418
|
+
searchScope: "global",
|
|
2419
|
+
selectable: "any",
|
|
2420
|
+
defaultOpen: !0,
|
|
2421
|
+
onOpenChange: (e) => {
|
|
2422
|
+
e || n();
|
|
2423
|
+
},
|
|
2424
|
+
onValueChange: (e) => {
|
|
2425
|
+
e != null && t(String(e));
|
|
2426
|
+
},
|
|
2427
|
+
children: [/* @__PURE__ */ r(nt, {
|
|
2428
|
+
render: /* @__PURE__ */ i("button", {
|
|
2429
|
+
type: "button",
|
|
2430
|
+
className: s,
|
|
2431
|
+
disabled: a,
|
|
2432
|
+
children: [/* @__PURE__ */ r("span", {
|
|
2433
|
+
className: "min-w-0 flex-1 truncate text-left",
|
|
2434
|
+
children: c
|
|
2435
|
+
}), /* @__PURE__ */ r(o, { className: "size-3.5 shrink-0 opacity-60" })]
|
|
2436
|
+
}),
|
|
2437
|
+
children: /* @__PURE__ */ r(kt, { placeholder: l })
|
|
2438
|
+
}), /* @__PURE__ */ r(ot, {
|
|
2439
|
+
className: "w-72",
|
|
2440
|
+
children: /* @__PURE__ */ i(st, { children: [
|
|
2441
|
+
/* @__PURE__ */ r(Tt, { children: /* @__PURE__ */ r(Ot, { placeholder: l }) }),
|
|
2442
|
+
/* @__PURE__ */ r(Dt, {}),
|
|
2443
|
+
/* @__PURE__ */ r(lt, {}),
|
|
2444
|
+
/* @__PURE__ */ r(ct, { children: /* @__PURE__ */ r(Ct, {}) }),
|
|
2445
|
+
/* @__PURE__ */ r(G, {})
|
|
2446
|
+
] })
|
|
2447
|
+
})]
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
//#endregion
|
|
2451
|
+
export { At as default };
|
|
2452
|
+
|
|
2453
|
+
//# sourceMappingURL=field-picker-popup-DynXyvQG.js.map
|