react-animated-select 0.7.7 → 0.8.1
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/base.css +1 -0
- package/dist/chip.cjs +1 -0
- package/dist/chip.css +1 -0
- package/dist/chip.js +113 -0
- package/dist/chipGeometry.cjs +1 -0
- package/dist/chipGeometry.js +37 -0
- package/dist/chipMotion.cjs +1 -0
- package/dist/chipMotion.js +85 -0
- package/dist/dropdown.cjs +1 -0
- package/dist/dropdown.js +70 -0
- package/dist/dropdownPosition.cjs +1 -0
- package/dist/dropdownPosition.js +97 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.js +13 -0
- package/dist/liveRegion.cjs +1 -0
- package/dist/liveRegion.js +42 -0
- package/dist/model.cjs +1 -0
- package/dist/model.js +138 -0
- package/dist/motion.cjs +1 -0
- package/dist/motion.js +122 -0
- package/dist/optionList.cjs +1 -0
- package/dist/optionList.js +105 -0
- package/dist/paging.cjs +1 -0
- package/dist/paging.js +47 -0
- package/dist/select.cjs +1 -0
- package/dist/select.js +165 -0
- package/dist/state.cjs +1 -0
- package/dist/state.js +50 -0
- package/dist/style.css +4 -0
- package/dist/theme.css +1 -0
- package/dist/trigger.cjs +1 -0
- package/dist/trigger.js +99 -0
- package/dist/useChipLayout.cjs +1 -0
- package/dist/useChipLayout.js +77 -0
- package/dist/useSelect.cjs +1 -0
- package/dist/useSelect.js +100 -0
- package/dist/useSelectBehavior.cjs +1 -0
- package/dist/useSelectBehavior.js +107 -0
- package/dist/useSelectModel.cjs +1 -0
- package/dist/useSelectModel.js +59 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.js +99 -0
- package/index.d.ts +41 -1
- package/package.json +4 -4
- package/dist/index.css +0 -1
- package/dist/index.es.js +0 -1299
package/dist/index.es.js
DELETED
|
@@ -1,1299 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as M, jsxs as ee } from "react/jsx-runtime";
|
|
3
|
-
import { createContext as Ae, useState as Q, useRef as G, useInsertionEffect as Ft, isValidElement as Ne, cloneElement as Ht, useMemo as Z, useLayoutEffect as X, useEffect as J, useCallback as Y, useContext as V, useEffectEvent as yt, Children as vt, useSyncExternalStore as ce, memo as ie, Fragment as wt, Component as Pt, useReducer as Vt, useId as zt, useImperativeHandle as Wt } from "react";
|
|
4
|
-
import { flushSync as et, createPortal as qt } from "react-dom";
|
|
5
|
-
import './index.css';const ne = Ae(null), ue = Ae(null), fe = Ae(null), Gt = (e, t) => {
|
|
6
|
-
const n = typeof t == "function" ? t(e) : t;
|
|
7
|
-
return n === e ? e : Object.keys(n).some((s) => !Object.is(n[s], e[s])) ? { ...e, ...n } : e;
|
|
8
|
-
}, xt = (e) => {
|
|
9
|
-
let t = e;
|
|
10
|
-
const n = /* @__PURE__ */ new Set();
|
|
11
|
-
return {
|
|
12
|
-
get: () => t,
|
|
13
|
-
set: (r) => {
|
|
14
|
-
Object.keys(r).every((s) => Object.is(r[s], t[s])) || (t = { ...t, ...r }, n.forEach((s) => s()));
|
|
15
|
-
},
|
|
16
|
-
subscribe: (r) => (n.add(r), () => n.delete(r))
|
|
17
|
-
};
|
|
18
|
-
}, _e = (e) => {
|
|
19
|
-
const t = G(e);
|
|
20
|
-
Ft(() => {
|
|
21
|
-
t.current = e;
|
|
22
|
-
});
|
|
23
|
-
const [n] = Q(() => Object.fromEntries(
|
|
24
|
-
Object.keys(e).map((r) => [r, (...s) => t.current[r](...s)])
|
|
25
|
-
));
|
|
26
|
-
return n;
|
|
27
|
-
}, Ot = (e, t) => {
|
|
28
|
-
const [n, r] = Q(e);
|
|
29
|
-
return n === e || t(n, e) ? n : (r(e), e);
|
|
30
|
-
}, Kt = (e, t) => e === t || !!e && !!t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every((n) => Object.is(e[n], t[n])), Te = (e, t, n = 0) => {
|
|
31
|
-
if (Object.is(e, t)) return !0;
|
|
32
|
-
if (n > 12 || typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
33
|
-
if (e.$$typeof || t.$$typeof) return e.$$typeof === t.$$typeof && e.type === t.type && e.key === t.key && Te(e.props, t.props, n + 1);
|
|
34
|
-
const r = Object.keys(e);
|
|
35
|
-
return r.length === Object.keys(t).length && r.every((s) => Object.hasOwn(t, s) && Te(e[s], t[s], n + 1));
|
|
36
|
-
}, _t = /* @__PURE__ */ new Set(["style", "texts", "icons", "attrs"]), Ut = (e, t) => {
|
|
37
|
-
const n = Object.keys(t);
|
|
38
|
-
return n.length === Object.keys(e).length && n.every(
|
|
39
|
-
(r) => _t.has(r) ? Kt(e[r], t[r]) : Object.is(e[r], t[r])
|
|
40
|
-
);
|
|
41
|
-
}, Yt = (e) => Ot(e, Ut), ze = (e) => Ot(e, Te), Se = {
|
|
42
|
-
XMark: ({ className: e = "", ...t }) => /* @__PURE__ */ M(
|
|
43
|
-
"svg",
|
|
44
|
-
{
|
|
45
|
-
className: e,
|
|
46
|
-
viewBox: "0 0 320 512",
|
|
47
|
-
fill: "currentColor",
|
|
48
|
-
"aria-hidden": "true",
|
|
49
|
-
height: "1em",
|
|
50
|
-
width: "1em",
|
|
51
|
-
...t,
|
|
52
|
-
children: /* @__PURE__ */ M("path", { d: "M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z" })
|
|
53
|
-
}
|
|
54
|
-
),
|
|
55
|
-
ArrowUp: ({ className: e = "", ...t }) => /* @__PURE__ */ M(
|
|
56
|
-
"svg",
|
|
57
|
-
{
|
|
58
|
-
className: e,
|
|
59
|
-
viewBox: "0 0 448 512",
|
|
60
|
-
fill: "currentColor",
|
|
61
|
-
"aria-hidden": "true",
|
|
62
|
-
height: "1em",
|
|
63
|
-
width: "1em",
|
|
64
|
-
...t,
|
|
65
|
-
children: /* @__PURE__ */ M("path", { d: "M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z" })
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
Checkmark: ({ className: e = "", ...t }) => /* @__PURE__ */ M(
|
|
69
|
-
"svg",
|
|
70
|
-
{
|
|
71
|
-
className: e,
|
|
72
|
-
viewBox: "0 0 24 24",
|
|
73
|
-
fill: "currentColor",
|
|
74
|
-
"aria-hidden": "true",
|
|
75
|
-
height: "1em",
|
|
76
|
-
width: "1em",
|
|
77
|
-
...t,
|
|
78
|
-
children: /* @__PURE__ */ M("path", { d: "M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z" })
|
|
79
|
-
}
|
|
80
|
-
)
|
|
81
|
-
}, he = (e, t) => {
|
|
82
|
-
if (!e) return null;
|
|
83
|
-
const n = (r = {}) => ({
|
|
84
|
-
...t,
|
|
85
|
-
...r,
|
|
86
|
-
style: {
|
|
87
|
-
...t?.style,
|
|
88
|
-
...r?.style
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
return typeof e == "string" ? /* @__PURE__ */ M("img", { src: e, ...n(), className: me("rac-icon", t?.className), alt: "" }) : Ne(e) ? Ht(e, n(e.props)) : typeof e == "function" || typeof e == "object" && e.$$typeof ? /* @__PURE__ */ M(e, { ...n() }) : null;
|
|
92
|
-
}, De = (e, t) => `${e}-${String(t).replace(/[^A-Za-z0-9-]/gu, (n) => `_${n.codePointAt(0).toString(36)}_`)}`, re = (e) => e ? "" : void 0, me = (e, t) => t ? `${e} ${t}` : e, Ue = (e, t, n) => e.jsx || (t && "original" in e ? t(e.original, { selected: n, disabled: !!e.disabled }) : null), Ye = /* @__PURE__ */ ee("span", { className: "rac-dots", "aria-hidden": "true", children: [
|
|
93
|
-
/* @__PURE__ */ M("i", {}),
|
|
94
|
-
/* @__PURE__ */ M("i", {}),
|
|
95
|
-
/* @__PURE__ */ M("i", {})
|
|
96
|
-
] }), Xt = (() => {
|
|
97
|
-
try {
|
|
98
|
-
return process.env.NODE_ENV !== "production";
|
|
99
|
-
} catch {
|
|
100
|
-
return !1;
|
|
101
|
-
}
|
|
102
|
-
})(), tt = /* @__PURE__ */ new Set(), le = (e, t) => {
|
|
103
|
-
!Xt || tt.has(e) || (tt.add(e), console.warn(`[react-animated-select] ${t}`));
|
|
104
|
-
}, oe = (e) => {
|
|
105
|
-
e?.stopPropagation(), e?.preventDefault();
|
|
106
|
-
}, Et = (e, t) => {
|
|
107
|
-
e?.currentTarget.contains(document.activeElement) && t.current?.focus();
|
|
108
|
-
}, Jt = { index: -1, fallback: -1, ready: !1 }, Ie = ({ index: e, fallback: t }) => e === -1 ? t : e, Zt = 10, Qt = 500, en = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End"]), tn = (e, t) => Z(() => {
|
|
109
|
-
const n = new Set(e.map((s) => s.group).filter(Boolean)), r = (s) => !!s && !s.disabled && !s.loading && (s.groupHeader ? n.has(s.name) : !s.group || t.has(s.group));
|
|
110
|
-
return { reach: r, list: e.flatMap((s, o) => r(s) ? [o] : []) };
|
|
111
|
-
}, [e, t]), nn = (e, t, n, r) => {
|
|
112
|
-
const s = e.length - 1;
|
|
113
|
-
if (s < 0) return -1;
|
|
114
|
-
if (n === "Home") return e[0];
|
|
115
|
-
if (n === "End") return e[s];
|
|
116
|
-
const o = n === "ArrowUp" || n === "PageUp" ? -1 : 1, i = e.indexOf(t);
|
|
117
|
-
if (i === -1) return e[o > 0 ? 0 : s];
|
|
118
|
-
const a = i + o * (n.startsWith("Page") ? Zt : 1);
|
|
119
|
-
return a >= 0 && a <= s ? e[a] : n.startsWith("Page") || r ? e[a < 0 ? 0 : s] : e[(a + e.length) % e.length];
|
|
120
|
-
}, rn = (e, t, n, r) => {
|
|
121
|
-
const s = [...r].every((l) => l === r[0]), o = s ? r[0] : r, i = t.filter((l) => "original" in e[l]), a = Math.max(i.indexOf(n) + (s ? 1 : 0), 0);
|
|
122
|
-
for (let l = 0; l < i.length; l++) {
|
|
123
|
-
const b = i[(a + l) % i.length];
|
|
124
|
-
if (String(e[b].name).toLowerCase().startsWith(o)) return b;
|
|
125
|
-
}
|
|
126
|
-
return -1;
|
|
127
|
-
};
|
|
128
|
-
function sn({ props: e, state: t, setState: n, normalizedOptions: r, expandedGroups: s, selected: o, selectedIDs: i, visibility: a, setVisibility: l, modelActions: b, loadMoreOnce: u, highlightStore: x }) {
|
|
129
|
-
const { disabled: d, multiple: c, hasMore: y, loadButton: w, loadOffset: p, loadAhead: f, icons: v, onFocus: A, onBlur: T, onKeyDown: H } = e, { selectOption: C, clear: g, removeOption: k } = b, { deleting: D } = t, { reach: R, list: I } = tn(r, s), B = G({ lastWindowFocusTime: 0, justFocused: !1, focusTimeout: null, query: "", queryTimeout: null }), m = Z(() => {
|
|
130
|
-
const h = new Set(c ? i.map((E) => E.id) : o ? [o.id] : []), O = h.size ? r.findIndex((E) => h.has(E.id) && R(E)) : -1;
|
|
131
|
-
return O !== -1 ? O : I.find((E) => !r[E].groupHeader) ?? I[0] ?? -1;
|
|
132
|
-
}, [r, o, i, c, R, I]), L = (h) => {
|
|
133
|
-
!w && a && y && h >= r.length - f && u();
|
|
134
|
-
};
|
|
135
|
-
X(() => {
|
|
136
|
-
const { index: h } = x.get();
|
|
137
|
-
x.set({ fallback: m, index: h !== -1 && R(r[h]) ? h : -1 }), L(Ie(x.get()));
|
|
138
|
-
}), J(() => {
|
|
139
|
-
const h = B.current, O = () => h.lastWindowFocusTime = Date.now();
|
|
140
|
-
return window.addEventListener("focus", O), () => {
|
|
141
|
-
window.removeEventListener("focus", O), clearTimeout(h.focusTimeout), clearTimeout(h.queryTimeout);
|
|
142
|
-
};
|
|
143
|
-
}, []);
|
|
144
|
-
const S = (h) => {
|
|
145
|
-
x.set({ index: h }), L(h);
|
|
146
|
-
}, F = (h, O) => {
|
|
147
|
-
const E = B.current;
|
|
148
|
-
clearTimeout(E.queryTimeout), E.queryTimeout = setTimeout(() => E.query = "", Qt), E.query += h.toLowerCase();
|
|
149
|
-
const $ = rn(r, I, O, E.query);
|
|
150
|
-
$ !== -1 && S($), a || l(!0);
|
|
151
|
-
};
|
|
152
|
-
return _e({
|
|
153
|
-
highlight: S,
|
|
154
|
-
handleListScroll: (h) => {
|
|
155
|
-
if (w) return;
|
|
156
|
-
const { scrollTop: O, scrollHeight: E, clientHeight: $ } = h.currentTarget;
|
|
157
|
-
E - O <= $ + p && u();
|
|
158
|
-
},
|
|
159
|
-
handleBlur: (h) => {
|
|
160
|
-
const O = h.relatedTarget?.closest(".rac-options");
|
|
161
|
-
h.currentTarget.contains(h.relatedTarget) || O || (T?.(h), D && n({ deleting: !1 }), a && l(!1));
|
|
162
|
-
},
|
|
163
|
-
// [DOC: select-behavior]
|
|
164
|
-
handleFocus: (h) => {
|
|
165
|
-
const O = h.currentTarget.contains(h.relatedTarget);
|
|
166
|
-
O || A?.(h), !(O || h.target !== h.currentTarget || a || d || D || document.hidden || Date.now() - B.current.lastWindowFocusTime < 100) && (clearTimeout(B.current.focusTimeout), B.current.focusTimeout = setTimeout(() => B.current.justFocused = !1, 200), B.current.justFocused = !0, l(!0));
|
|
167
|
-
},
|
|
168
|
-
toggleVisibility: (h) => {
|
|
169
|
-
if (D) {
|
|
170
|
-
oe(h), n({ deleting: !1 });
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
d || B.current.justFocused || l(!a);
|
|
174
|
-
},
|
|
175
|
-
handleKeyDown: (h) => {
|
|
176
|
-
if (H?.(h), h.defaultPrevented || d || h.nativeEvent?.isComposing) return;
|
|
177
|
-
const { key: O } = h;
|
|
178
|
-
if (h.target !== h.currentTarget && (O === "Enter" || O.length === 1)) return;
|
|
179
|
-
const E = Ie(x.get());
|
|
180
|
-
if (O.length === 1 && !h.ctrlKey && !h.metaKey && !h.altKey && (O !== " " || B.current.query)) {
|
|
181
|
-
h.preventDefault(), F(O, E);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (en.has(O)) {
|
|
185
|
-
h.preventDefault(), (a || O === "Home" || O === "End") && S(nn(I, E, O, !w && y)), a || l(!0);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
switch (O) {
|
|
189
|
-
case "Enter":
|
|
190
|
-
case " ":
|
|
191
|
-
h.preventDefault(), a ? E !== -1 && r[E] && (S(E), C(r[E], h)) : l(!0);
|
|
192
|
-
break;
|
|
193
|
-
// [DOC: select-behavior]
|
|
194
|
-
case "Escape":
|
|
195
|
-
if (D) n({ deleting: !1 });
|
|
196
|
-
else if (a) l(!1);
|
|
197
|
-
else break;
|
|
198
|
-
oe(h);
|
|
199
|
-
break;
|
|
200
|
-
case "Tab":
|
|
201
|
-
a && l(!1);
|
|
202
|
-
break;
|
|
203
|
-
// [DOC: select-behavior]
|
|
204
|
-
case "Backspace":
|
|
205
|
-
case "Delete": {
|
|
206
|
-
const $ = i.at(-1);
|
|
207
|
-
if (c && O === "Backspace" && v.remove && $) k($.id);
|
|
208
|
-
else if (v.clear && (o || $)) g();
|
|
209
|
-
else break;
|
|
210
|
-
h.preventDefault();
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
const on = ["group", "disabled", "options", "items", "children"], Xe = ["name", "label", "id", "value"], Oe = (e) => e != null && e !== "", St = (e) => e !== null && typeof e == "object" && !Array.isArray(e), Le = (e) => St(e) && [Object.prototype, null].includes(Object.getPrototypeOf(e)), an = (e) => {
|
|
218
|
-
try {
|
|
219
|
-
const t = String(e);
|
|
220
|
-
return t.startsWith("[object ") ? null : t;
|
|
221
|
-
} catch {
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
}, Je = (e, t = !1) => {
|
|
225
|
-
if (t && typeof e.group == "string") return e.group;
|
|
226
|
-
const n = Xe.find((o) => Oe(e[o]));
|
|
227
|
-
if (n) return String(e[n]);
|
|
228
|
-
const r = !Le(e) && an(e);
|
|
229
|
-
if (r) return r;
|
|
230
|
-
const s = Object.entries(e).find(([o, i]) => !on.includes(o) && Oe(i));
|
|
231
|
-
return s ? String(s[1]) : null;
|
|
232
|
-
}, cn = (e) => Le(e) && ("options" in e || "group" in e && !Xe.some((t) => t in e)), nt = (e, t, n, r, s, { emptyOption: o, invalidOption: i, disabledOption: a }) => {
|
|
233
|
-
const l = `${n}-${t}`;
|
|
234
|
-
if (e == null || e === "")
|
|
235
|
-
return { id: l, userId: null, name: o, raw: e, disabled: !0, type: "normal", group: r, groupDisabled: s };
|
|
236
|
-
if (typeof e == "function")
|
|
237
|
-
return { id: l, userId: null, name: i, raw: e, disabled: !0, invalid: !0, type: "normal", group: r };
|
|
238
|
-
if (St(e)) {
|
|
239
|
-
const b = s || e.disabled === !0, u = e.value !== void 0 ? e.value : e.id !== void 0 ? e.id : e, x = Je(e) || (b ? a : o);
|
|
240
|
-
return {
|
|
241
|
-
id: l,
|
|
242
|
-
userId: e.id ?? e.value ?? e.name ?? e.label,
|
|
243
|
-
name: x,
|
|
244
|
-
raw: u,
|
|
245
|
-
original: e,
|
|
246
|
-
disabled: b || x === o,
|
|
247
|
-
type: typeof u == "boolean" ? "boolean" : "normal",
|
|
248
|
-
group: r || e.group || null,
|
|
249
|
-
groupDisabled: s
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
return { id: l, userId: e, name: String(e), raw: e, original: e, disabled: s, type: typeof e == "boolean" ? "boolean" : "normal", group: r };
|
|
253
|
-
}, ln = ({
|
|
254
|
-
options: e,
|
|
255
|
-
jsxOptions: t,
|
|
256
|
-
childrenFirst: n,
|
|
257
|
-
hasMore: r,
|
|
258
|
-
loadButton: s,
|
|
259
|
-
loadPending: o,
|
|
260
|
-
loadingTitle: i,
|
|
261
|
-
emptyOption: a,
|
|
262
|
-
invalidOption: l,
|
|
263
|
-
disabledOption: b,
|
|
264
|
-
emptyGroup: u
|
|
265
|
-
}) => {
|
|
266
|
-
const x = { emptyOption: a, invalidOption: l, disabledOption: b }, d = /* @__PURE__ */ new Map(), c = [], y = /* @__PURE__ */ new Set(), w = (g) => {
|
|
267
|
-
let k = g;
|
|
268
|
-
for (let D = 1; y.has(k); D++) k = `${g}~${D}`;
|
|
269
|
-
return y.add(k), k;
|
|
270
|
-
}, p = t.map((g, k) => {
|
|
271
|
-
if (g.isGroupMarker) return { ...g, type: "group-marker" };
|
|
272
|
-
const D = !g.label && !Oe(g.userId) && !Oe(g.value) && !g.hasJsx;
|
|
273
|
-
return {
|
|
274
|
-
...g,
|
|
275
|
-
id: w(`jsx-${g.id}`),
|
|
276
|
-
index: k,
|
|
277
|
-
userId: g.userId,
|
|
278
|
-
raw: g.value,
|
|
279
|
-
original: g.value,
|
|
280
|
-
name: g.label || (Oe(g.value) ? String(g.value) : a),
|
|
281
|
-
disabled: !!g.disabled || D,
|
|
282
|
-
type: typeof g.value == "boolean" ? "boolean" : "normal",
|
|
283
|
-
group: g.group || null
|
|
284
|
-
};
|
|
285
|
-
});
|
|
286
|
-
let f = 0;
|
|
287
|
-
const v = (g, k = null, D = !1, R = "0") => {
|
|
288
|
-
Array.isArray(g) || (g = [g]), g.forEach((I, B) => {
|
|
289
|
-
const m = `${R}-${B}`;
|
|
290
|
-
if (cn(I)) {
|
|
291
|
-
const L = Je(I, !0) || u;
|
|
292
|
-
d.has(L) || d.set(L, { disabled: !!I.disabled, items: [] }), I.options ? v(I.options, L, D || !!I.disabled, m) : c.push({ id: `empty-${L}-${m}`, name: L, group: L, isPlaceholder: !0, type: "group-marker", index: f++ });
|
|
293
|
-
} else Le(I) && !Xe.some((L) => L in I) && !I.group ? Object.values(I).forEach((L, S) => c.push({ ...nt(L, `${m}-${S}`, "default", k, D, x), index: f++ })) : c.push({ ...nt(I, m, "default", k, D, x), index: f++ });
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
v(e);
|
|
297
|
-
const A = n ? [...p, ...c] : [...c, ...p], T = [], H = /* @__PURE__ */ new Set();
|
|
298
|
-
A.forEach((g) => {
|
|
299
|
-
if (!g.group) {
|
|
300
|
-
T.push({ type: "item", data: g });
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
H.has(g.group) || (H.add(g.group), T.push({ type: "group", name: g.group })), d.has(g.group) || d.set(g.group, { items: [] });
|
|
304
|
-
const k = d.get(g.group);
|
|
305
|
-
g.isGroupMarker ? (k.className = g.className, k.style = g.style, g.disabled && (k.disabled = !0)) : g.isPlaceholder || k.items.push(g);
|
|
306
|
-
});
|
|
307
|
-
const C = [];
|
|
308
|
-
return T.forEach((g) => {
|
|
309
|
-
if (g.type === "item") {
|
|
310
|
-
C.push(g.data);
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
const k = d.get(g.name);
|
|
314
|
-
C.push({
|
|
315
|
-
className: k?.className || "",
|
|
316
|
-
id: `group-header-${g.name}`,
|
|
317
|
-
disabled: !!k?.disabled,
|
|
318
|
-
style: k?.style || {},
|
|
319
|
-
groupHeader: !0,
|
|
320
|
-
name: g.name,
|
|
321
|
-
type: "group"
|
|
322
|
-
}), k?.items.forEach((D) => C.push(D));
|
|
323
|
-
}), r && s && C.push({ id: "special-load-more-id", name: i, loadMore: !0, loading: o, type: "special" }), C;
|
|
324
|
-
}, fr = (e) => {
|
|
325
|
-
const t = () => null;
|
|
326
|
-
return t.racKind = "define", t.racRender = e, t.displayName = `defineOption(${e.name || "anonymous"})`, t;
|
|
327
|
-
}, rt = { selected: null, selectedIDs: [] }, ye = (e) => {
|
|
328
|
-
try {
|
|
329
|
-
return JSON.stringify(e);
|
|
330
|
-
} catch {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
}, kt = (e, t) => e === t || e !== e && t !== t, Me = (e) => typeof e == "object" && e !== null, dn = (e, t) => kt(e, t) || Me(e) && Me(t) && ye(e) !== void 0 && ye(e) === ye(t), st = (e, t, n, r) => {
|
|
334
|
-
if (e == null || Array.isArray(e) && e.length === 0) return rt;
|
|
335
|
-
const s = r.length ? new Map(t.map((u) => [u.id, u])) : null, o = s ? [...r.map((u) => s.get(u)).filter(Boolean), ...t] : t, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), l = (u) => "original" in u && !i.has(u.id), b = (u) => {
|
|
336
|
-
const x = Me(u);
|
|
337
|
-
let d = o.find((f) => l(f) && kt(f.original, u));
|
|
338
|
-
const c = x ? ye(u) : void 0;
|
|
339
|
-
if (!d && c !== void 0 && (d = o.find((f) => l(f) && Me(f.original) && ye(f.original) === c)), d)
|
|
340
|
-
return i.add(d.id), d;
|
|
341
|
-
const y = String(x ? u.id || u.value || c || "object" : u), w = (a.get(y) ?? -1) + 1;
|
|
342
|
-
a.set(y, w);
|
|
343
|
-
const p = `virtual-${y}-${w}`;
|
|
344
|
-
return x ? { id: p, name: Je(u) || String(u.id || "Selected Object"), raw: u.value ?? u.id ?? u, original: u, userId: u.id ?? u.value ?? null, virtual: !0 } : { id: p, name: String(u), raw: u, original: u, userId: u, virtual: !0 };
|
|
345
|
-
};
|
|
346
|
-
return n ? { selected: null, selectedIDs: (Array.isArray(e) ? e : [e]).map(b) } : { selected: b(Array.isArray(e) ? e[0] : e), selectedIDs: rt.selectedIDs };
|
|
347
|
-
}, ot = {
|
|
348
|
-
x: ["width", "marginLeft", "marginRight", "paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"],
|
|
349
|
-
y: ["height", "marginTop", "marginBottom", "paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth"]
|
|
350
|
-
}, un = { x: { minWidth: "0px", maxWidth: "none" }, y: { minHeight: "0px", maxHeight: "none" } }, Ct = Ae(null);
|
|
351
|
-
let We = null;
|
|
352
|
-
const fn = () => We ??= (queueMicrotask(() => {
|
|
353
|
-
We = null;
|
|
354
|
-
}), {});
|
|
355
|
-
function de({
|
|
356
|
-
as: e = "div",
|
|
357
|
-
axis: t = "y",
|
|
358
|
-
fade: n = !1,
|
|
359
|
-
in: r,
|
|
360
|
-
unmountOnExit: s = !0,
|
|
361
|
-
easing: o,
|
|
362
|
-
duration: i,
|
|
363
|
-
group: a,
|
|
364
|
-
nodeRef: l,
|
|
365
|
-
onEntered: b,
|
|
366
|
-
onExited: u,
|
|
367
|
-
...x
|
|
368
|
-
}) {
|
|
369
|
-
const d = V(ne), c = V(Ct), y = r === void 0 && !!c, w = y ? c.present : !!r, p = i ?? (d?.duration ?? 300) / (y && c.swap ? 2 : 1), f = o ?? d?.easing ?? "ease", v = G(null), A = l ?? v, T = G(null), H = G(!1), C = G({ restart: () => {
|
|
370
|
-
} }), [g] = Q(() => y && c.appear ? !w : w), k = G(g), [D, R] = Q(!w);
|
|
371
|
-
w && D && R(!1);
|
|
372
|
-
const I = yt(() => {
|
|
373
|
-
if (a?.delete(C.current), w) {
|
|
374
|
-
T.current?.cancel(), T.current = null, b?.();
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
u?.(), y && c.onExited(), s && (T.current = null, R(!0));
|
|
378
|
-
});
|
|
379
|
-
return X(() => {
|
|
380
|
-
const m = A.current;
|
|
381
|
-
if (!m) return;
|
|
382
|
-
const L = n ? [...ot[t], "opacity"] : ot[t], S = { overflow: "hidden", textOverflow: "clip", ...un[t] }, F = { ...Object.fromEntries(L.map((N) => [N, N === "opacity" ? 0 : "0px"])), ...S }, h = () => {
|
|
383
|
-
const { overflow: N } = m.style;
|
|
384
|
-
m.style.overflow = "hidden";
|
|
385
|
-
const P = getComputedStyle(m), _ = { ...Object.fromEntries(L.map((z) => [z, P[z]])), ...S };
|
|
386
|
-
return m.style.overflow = N, _;
|
|
387
|
-
}, O = (N, P) => {
|
|
388
|
-
const _ = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, z = T.current = m.animate([N, P], { duration: _ ? 0 : p, easing: f, fill: k.current ? "backwards" : "both" });
|
|
389
|
-
if (z.onfinish = () => {
|
|
390
|
-
T.current === z && H.current && I();
|
|
391
|
-
}, C.current.frames = [N, P], !a) return;
|
|
392
|
-
const W = z.timeline?.currentTime;
|
|
393
|
-
W != null && (z.startTime = W, z.currentTime = 0), C.current.batch = fn(), a.add(C.current);
|
|
394
|
-
}, E = () => {
|
|
395
|
-
const [N, P] = C.current.frames, _ = T.current.effect.getComputedTiming().progress ?? 0, z = (W) => parseFloat(N[W]) + (parseFloat(P[W]) - parseFloat(N[W])) * _;
|
|
396
|
-
return { ...Object.fromEntries(L.map((W) => [W, W === "opacity" ? z(W) : `${z(W)}px`])), ...S };
|
|
397
|
-
};
|
|
398
|
-
if (C.current.restart = (N) => {
|
|
399
|
-
const P = T.current;
|
|
400
|
-
if (P?.playState !== "running" || !N && C.current.batch === We) return;
|
|
401
|
-
const _ = E();
|
|
402
|
-
P.cancel(), O(_, k.current ? h() : F);
|
|
403
|
-
}, k.current === w) {
|
|
404
|
-
!w && !T.current && m.animate && (T.current = m.animate([F, F], { fill: "forwards" }));
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
k.current = w;
|
|
408
|
-
const $ = T.current;
|
|
409
|
-
if ($?.playState === "running") {
|
|
410
|
-
if (!a) {
|
|
411
|
-
$.reverse();
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
C.current.restart(!0);
|
|
415
|
-
} else {
|
|
416
|
-
if ($?.cancel(), !m.animate) {
|
|
417
|
-
I();
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
w ? O(F, h()) : O(h(), F);
|
|
421
|
-
}
|
|
422
|
-
a?.forEach((N) => N !== C.current && N.restart());
|
|
423
|
-
}, [w, t, n, p, f, A, a]), X(() => {
|
|
424
|
-
const m = C.current;
|
|
425
|
-
return H.current = !0, T.current?.playState === "running" && a?.add(m), () => {
|
|
426
|
-
H.current = !1, a?.delete(m);
|
|
427
|
-
};
|
|
428
|
-
}, [a]), D && s ? null : /* @__PURE__ */ M(e, { ref: A, ...x });
|
|
429
|
-
}
|
|
430
|
-
const pn = ({ id: e, present: t, appear: n, swap: r, onExited: s, children: o }) => {
|
|
431
|
-
const i = Z(() => ({ present: t, appear: n, swap: r, onExited: () => s(e) }), [e, t, n, r, s]);
|
|
432
|
-
return /* @__PURE__ */ M(Ct.Provider, { value: i, children: o });
|
|
433
|
-
}, it = (e, t, n, r = !0) => {
|
|
434
|
-
const s = vt.toArray(t).filter(Ne), o = new Set(s.map((d) => d.key)), i = new Map(e.map((d) => [d.key, d])), a = s.map((d) => ({ key: d.key, el: d, present: !0, appear: i.get(d.key)?.appear ?? r }));
|
|
435
|
-
let l = 0;
|
|
436
|
-
const b = /* @__PURE__ */ new Set();
|
|
437
|
-
e.forEach((d) => {
|
|
438
|
-
if (o.has(d.key))
|
|
439
|
-
d.present && (l = a.findIndex((c) => c.key === d.key) + 1);
|
|
440
|
-
else if (!d.pending) {
|
|
441
|
-
const c = d.present ? { ...d, present: !1, swap: !1 } : d;
|
|
442
|
-
d.present && b.add(c), a.splice(l++, 0, c);
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
const u = (d) => d.present && (i.get(d.key)?.pending ?? !i.has(d.key)), x = n && (b.size > 0 || e.some((d) => d.pending)) && a.some((d) => !d.present) && a.some(u);
|
|
446
|
-
return { children: t, list: x ? a.map((d) => b.has(d) ? { ...d, swap: !0 } : u(d) ? { ...d, pending: !0, swap: !0 } : d) : a };
|
|
447
|
-
}, at = (e) => e.some((t) => !t.present) ? e : e.map((t) => t.pending ? { ...t, pending: !1 } : t);
|
|
448
|
-
function qe({ children: e, hold: t = !1, wait: n = !1 }) {
|
|
449
|
-
const [r, s] = Q(() => ({ ...it([], e, n, !1), hold: t }));
|
|
450
|
-
let o = r;
|
|
451
|
-
o.children !== e && (o = { ...o, ...it(o.list, e, n) }), o.hold !== t && (o = { ...o, hold: t, list: t ? o.list : at(o.list.filter((a) => a.present)) }), o !== r && s(o);
|
|
452
|
-
const i = Y((a) => s(
|
|
453
|
-
(l) => !l.hold && l.list.some((b) => b.key === a && !b.present) ? { ...l, list: at(l.list.filter((b) => b.key !== a)) } : l
|
|
454
|
-
), []);
|
|
455
|
-
return r.list.map(
|
|
456
|
-
({ key: a, el: l, present: b, appear: u, pending: x, swap: d = !1 }) => !x && /* @__PURE__ */ M(pn, { id: a, present: b, appear: u, swap: d, onExited: i, children: l }, a)
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
const Tt = "rac-chip-slot", $e = "rac-flip", Ze = "rac-resize", Qe = [], ct = { overflow: "hidden", textOverflow: "clip", boxSizing: "border-box", minWidth: "0px", maxWidth: "none", minHeight: "0px", maxHeight: "none" }, It = "(prefers-reduced-motion: reduce)", xe = () => !!window.matchMedia?.(It).matches, gn = (e) => {
|
|
460
|
-
const t = window.matchMedia?.(It);
|
|
461
|
-
return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
|
|
462
|
-
}, Ee = (e) => Array.from(e.children).filter((t) => t.classList.contains(Tt)), je = (e) => e.firstElementChild?.firstElementChild, Mt = (e, t) => !!e?.getAnimations?.().some((n) => n.constructor === Animation && t(n)), $t = (e, t) => Mt(e, (n) => n.playState === "running" && t(n)), At = (e) => Ee(e).some((t) => $t(je(t), (n) => n.id === Ze)), Re = (e) => Array.from(e.children).some((t) => $t(t, (n) => n.id !== $e)) || At(e), hn = (e, t) => e.length === t.length && e.every((n, r) => n === t[r]), mn = (e) => {
|
|
463
|
-
const t = [];
|
|
464
|
-
let n = -1 / 0;
|
|
465
|
-
for (const r of e) {
|
|
466
|
-
const s = r.getBoundingClientRect();
|
|
467
|
-
s.top >= n - 1 && (t.push([]), n = s.bottom), t.at(-1).push(r), n = Math.max(n, s.bottom);
|
|
468
|
-
}
|
|
469
|
-
return t;
|
|
470
|
-
}, Nt = (e, t, n, r, s) => {
|
|
471
|
-
const o = e.cloneNode(!0), { height: i, paddingInlineEnd: a } = getComputedStyle(e), l = s ? "" : `height: ${i}; min-height: 0;`;
|
|
472
|
-
o.style.cssText = `visibility: hidden; pointer-events: none; ${l} padding-inline-end: calc(${a} + ${n}px)`, o.querySelectorAll(`:scope > :not(.${Tt})`).forEach((c) => c.remove()), r && Ee(o).forEach((c) => r.has(c.dataset.id) || c.remove()), n && o.querySelectorAll(".rac-chip-del").forEach((c) => c.remove());
|
|
473
|
-
const b = Ee(o);
|
|
474
|
-
b.forEach((c) => s?.has(c.dataset.id) && Object.assign(je(c)?.style ?? {}, { minWidth: s.get(c.dataset.id), boxSizing: "border-box" }));
|
|
475
|
-
const u = new Map(b.map((c, y) => [c.dataset.id, y]));
|
|
476
|
-
t?.slice(1).forEach((c, y) => {
|
|
477
|
-
const w = Math.min(...c.map((f) => u.get(f) ?? 1 / 0)), p = Math.max(...t[y].map((f) => u.get(f) ?? -1).filter((f) => f < w));
|
|
478
|
-
p >= 0 && b[p].after(Object.assign(document.createElement("div"), { className: "rac-spacer" }));
|
|
479
|
-
}), e.style.position = "absolute", e.after(o), o.getAnimations?.({ subtree: !0 }).forEach((c) => c.effect?.getComputedTiming().endTime < 1 / 0 && c.finish());
|
|
480
|
-
const x = mn(b).map((c) => c.map((y) => y.dataset.id)), d = o.offsetHeight;
|
|
481
|
-
return o.remove(), e.style.position = "", { rows: x, fit: d };
|
|
482
|
-
}, Dt = (e, t) => {
|
|
483
|
-
const n = t ? t.slice(0, -1).map((s) => s.at(-1)) : Qe, { breaks: r } = e.get();
|
|
484
|
-
return hn(r, n) ? r : n;
|
|
485
|
-
}, lt = (e, t, n, r) => Dt(e, r && n.length ? Nt(t, null, r, new Set(n.map((s) => s.id))).rows : null), ke = (e, t, n) => {
|
|
486
|
-
const { rows: r, fit: s } = Nt(t, n.rows, n.reserve, null, n.floor);
|
|
487
|
-
Object.assign(n, { rows: r, fit: n.floor ? s : null }), e.set({ held: !0, breaks: Dt(e, r) });
|
|
488
|
-
}, bn = (e, t) => new Map(Ee(e).map((n) => {
|
|
489
|
-
const { left: r, top: s } = n.getBoundingClientRect(), o = t && je(n);
|
|
490
|
-
return [n, { left: r, top: s, label: o ? Lt(o) : null }];
|
|
491
|
-
})), dt = (e, t, n, r) => {
|
|
492
|
-
if (!e.animate) return;
|
|
493
|
-
e.getAnimations().forEach((a) => a.id === $e && a.cancel());
|
|
494
|
-
const s = e.getBoundingClientRect(), o = t.left - s.left, i = t.top - s.top;
|
|
495
|
-
(Math.abs(o) > 0.5 || Math.abs(i) > 0.5) && e.animate([{ transform: `translate(${o}px, ${i}px)` }, { transform: "none" }], { id: $e, duration: n, easing: r });
|
|
496
|
-
}, Lt = (e) => {
|
|
497
|
-
const t = getComputedStyle(e), n = (...r) => `${r.reduce((s, o) => s + parseFloat(t[o]), 0)}px`;
|
|
498
|
-
return t.boxSizing === "border-box" ? { width: t.width, height: t.height } : {
|
|
499
|
-
width: n("width", "paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"),
|
|
500
|
-
height: n("height", "paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth")
|
|
501
|
-
};
|
|
502
|
-
}, yn = (e) => {
|
|
503
|
-
const t = [];
|
|
504
|
-
e.forEach(({ label: r }, s) => {
|
|
505
|
-
const o = r && s.isConnected && je(s);
|
|
506
|
-
!o?.animate || Mt(s, (i) => i.id !== $e) || (o.getAnimations().forEach((i) => i.id === Ze && i.cancel()), t.push({ id: s.dataset.id, el: o, from: r }));
|
|
507
|
-
});
|
|
508
|
-
const n = (r, s) => Math.abs(parseFloat(r) - parseFloat(s)) > 0.5;
|
|
509
|
-
return t.map((r) => ({ ...r, to: Lt(r.el) })).filter(({ from: r, to: s }) => n(r.width, s.width) || n(r.height, s.height));
|
|
510
|
-
}, vn = (e, t, n, r) => e.forEach(({ el: s, from: o, to: i }) => {
|
|
511
|
-
s.animate([{ ...ct, ...o }, { ...ct, ...i }], { id: Ze, duration: t, easing: n }).onfinish = r;
|
|
512
|
-
}), Be = (e, t, n, r, s, o) => {
|
|
513
|
-
if (!e || n === t.value) return;
|
|
514
|
-
const i = getComputedStyle(e), a = t.anim ? i.height : t.root;
|
|
515
|
-
t.anim?.cancel(), o && Object.assign(o.style, { height: `${n}px`, boxSizing: "border-box" }), t.root = i.height, o && Object.assign(o.style, { height: "", boxSizing: "" });
|
|
516
|
-
const l = !t.value || a === t.root || !e.animate || xe();
|
|
517
|
-
if (t.value = n, t.anim = null, l) return;
|
|
518
|
-
const b = { overflow: "hidden", alignItems: "flex-start" }, u = t.anim = e.animate([{ ...b, height: a }, { ...b, height: t.root }], { duration: r, easing: s });
|
|
519
|
-
u.onfinish = () => {
|
|
520
|
-
t.anim === u && (t.anim = null);
|
|
521
|
-
};
|
|
522
|
-
}, wn = 0.25, xn = { hoverId: null, swipedId: null, held: !1, breaks: Qe };
|
|
523
|
-
function On(e) {
|
|
524
|
-
const { selectRef: t, duration: n, easing: r, multiple: s, deleteInline: o, deleteAlways: i, icons: a, valueAsOption: l, renderOption: b } = V(ne), { selectedIDs: u, deleting: x, visibility: d, active: c } = V(fe), { setDeleting: y, setVisibility: w } = V(ue), [p, f] = Q(0), [v] = Q(() => xt(xn)), [A] = Q(() => /* @__PURE__ */ new Set()), T = ce(v.subscribe, () => v.get().held, () => !1), H = ce(v.subscribe, () => v.get().breaks, () => Qe), C = ce(gn, xe, () => !1), g = G({ rows: null, reserve: 0, chips: e, swap: !1, duration: n, easing: r }), k = G(null), D = G({ value: 0, root: "", anim: null }), R = G(null), I = G(null), B = o && !i && !x && !!a.remove, m = B ? p + wn : 0, L = s && B && !p && e.length > 0, S = l ? b ? 2 : 1 : 0, F = yt((E, $) => {
|
|
525
|
-
const N = R.current, P = g.current;
|
|
526
|
-
if (!N) return;
|
|
527
|
-
const _ = At(N);
|
|
528
|
-
if (_ && $) return;
|
|
529
|
-
E && v.get().held && ke(v, N, P);
|
|
530
|
-
const z = P.swap ? P.duration / 2 : P.duration;
|
|
531
|
-
_ ? P.fit != null && Be(t.current, D.current, P.fit, z, P.easing, N) : ($ || D.current.value) && Be(t.current, D.current, N.offsetHeight, z, P.easing), v.get().held || v.set({ breaks: lt(v, N, P.chips, P.reserve) });
|
|
532
|
-
});
|
|
533
|
-
X(() => {
|
|
534
|
-
Object.assign(g.current, { duration: n, easing: r });
|
|
535
|
-
}, [n, r]), X(() => {
|
|
536
|
-
const E = g.current, $ = R.current, N = E.chips !== e;
|
|
537
|
-
Object.assign(E, { chips: e, reserve: m }), N && $ && Re($) && ke(v, $, E), F(!N);
|
|
538
|
-
}, [e, m, v]), X(() => {
|
|
539
|
-
const E = () => F(!0, !0), $ = typeof ResizeObserver > "u" ? null : new ResizeObserver(E);
|
|
540
|
-
return $ ? $.observe(R.current) : E(), document.fonts?.addEventListener("loadingdone", E), () => {
|
|
541
|
-
$?.disconnect(), document.fonts?.removeEventListener("loadingdone", E);
|
|
542
|
-
};
|
|
543
|
-
}, []);
|
|
544
|
-
const h = Y(() => {
|
|
545
|
-
const E = R.current;
|
|
546
|
-
if (!E || !v.get().held || Re(E)) return;
|
|
547
|
-
const $ = g.current, N = Ee(E), P = N.map((z) => z.getBoundingClientRect()), _ = lt(v, E, $.chips, $.reserve);
|
|
548
|
-
Object.assign($, { rows: null, floor: null, fit: null }), et(() => v.set({ held: !1, breaks: _ })), $.swap = Re(E), $.swap && et(() => ke(v, E, $)), xe() || N.forEach((z, W) => z.isConnected && dt(z, P[W], $.swap ? n / 2 : n, r));
|
|
549
|
-
}, [v, n, r]), O = Y((E) => {
|
|
550
|
-
R.current && (k.current = bn(R.current, E));
|
|
551
|
-
}, []);
|
|
552
|
-
return X(() => {
|
|
553
|
-
const E = R.current, $ = g.current;
|
|
554
|
-
if (!E || !k.current || !n || xe()) return;
|
|
555
|
-
const N = yn(k.current);
|
|
556
|
-
N.length && ($.floor = new Map(N.map(({ id: P, from: _ }) => [P, _.width])), ke(v, E, $), Be(t.current, D.current, $.fit, n, r, E), vn(N, n, r, () => {
|
|
557
|
-
h(), F(!1, !0);
|
|
558
|
-
}));
|
|
559
|
-
}, [S, v, n, r, t, h]), X(() => {
|
|
560
|
-
const E = k.current;
|
|
561
|
-
!E || H !== v.get().breaks || (k.current = null, xe() || E.forEach(($, N) => N.isConnected && dt(N, $, n, r)));
|
|
562
|
-
}, [H, e, S, v, n, r]), J(() => () => D.current.anim?.cancel(), []), J(() => {
|
|
563
|
-
x && d && w(!1), x && (!u.length || !c) && y(!1), v.set({ hoverId: null, ...!c && { swipedId: null } });
|
|
564
|
-
}, [u.length, x, d, c, y, w, v]), X(() => {
|
|
565
|
-
const E = I.current;
|
|
566
|
-
if (!L || !E) return;
|
|
567
|
-
const $ = getComputedStyle(E);
|
|
568
|
-
f(E.getBoundingClientRect().width + parseFloat($.marginLeft) + parseFloat($.marginRight));
|
|
569
|
-
}, [L]), { chipStore: v, delGroup: A, valueRef: R, delIconRef: I, probe: L, settle: h, held: T, snapshot: O, look: S, wait: n > 0 && !C };
|
|
570
|
-
}
|
|
571
|
-
const ut = 1, ft = 2, En = 600, Sn = 10, pt = 30, kn = ie(function({ element: t, deleting: n, locked: r, chipStore: s, delGroup: o }) {
|
|
572
|
-
const { selectRef: i, deleteInline: a, deleteAlways: l, icons: b, texts: u, valueAsOption: x, renderOption: d } = V(ne), c = !!b.remove, { setVisibility: y, setDeleting: w, removeOption: p } = V(ue), f = G({ longPressTimer: null, longPress: !1, x: 0, y: 0 }), v = ce(s.subscribe, () => {
|
|
573
|
-
const { hoverId: S, swipedId: F } = s.get();
|
|
574
|
-
return (S === t.id ? ut : 0) | (F === t.id ? ft : 0);
|
|
575
|
-
}, () => 0), A = !!(v & ut), T = !!(v & ft), H = Y((S) => {
|
|
576
|
-
const { clientX: F, clientY: h } = S.touches[0];
|
|
577
|
-
Object.assign(f.current, { x: F, y: h, longPress: !1 }), clearTimeout(f.current.longPressTimer), c && (f.current.longPressTimer = setTimeout(() => {
|
|
578
|
-
w(!0), f.current.longPress = !0, i.current?.focus(), y(!1), window.navigator.vibrate?.(50);
|
|
579
|
-
}, En));
|
|
580
|
-
}, [c, w, y, i]), C = Y((S) => {
|
|
581
|
-
const { clientX: F, clientY: h } = S.touches[0], O = f.current.x - F;
|
|
582
|
-
Math.hypot(O, f.current.y - h) > Sn && clearTimeout(f.current.longPressTimer), O > pt && !T ? s.set({ hoverId: null, swipedId: t.id }) : O < -pt && T && s.set({ swipedId: null });
|
|
583
|
-
}, [t.id, T, s]), g = Y((S) => {
|
|
584
|
-
clearTimeout(f.current.longPressTimer), f.current.longPress && S.cancelable && S.preventDefault(), f.current.longPress = !1;
|
|
585
|
-
}, []), k = Y(() => s.set({ hoverId: t.id, swipedId: null }), [t.id, s]), D = Y(() => {
|
|
586
|
-
s.get().hoverId === t.id && s.set({ hoverId: null });
|
|
587
|
-
}, [t.id, s]);
|
|
588
|
-
J(() => () => clearTimeout(f.current.longPressTimer), []);
|
|
589
|
-
const R = x ? Ue(t, d, !0) : null, I = R ? /* @__PURE__ */ M("div", { className: "rac-option-jsx", children: R }) : /* @__PURE__ */ M("span", { className: "rac-chip-text", children: t.name || u.emptyOption }), B = Y((S) => {
|
|
590
|
-
s.set({ swipedId: null }), Et(S, i), p(t.id), oe(S);
|
|
591
|
-
}, [t.id, p, s, i]), m = Y((S) => {
|
|
592
|
-
oe(S), n && B(S);
|
|
593
|
-
}, [n, B]), L = c && (l || !r && (A || T || n));
|
|
594
|
-
return /* @__PURE__ */ ee(
|
|
595
|
-
"div",
|
|
596
|
-
{
|
|
597
|
-
className: me("rac-chip", R && t.className),
|
|
598
|
-
style: R ? t.style : void 0,
|
|
599
|
-
...!r && { onTouchStart: H, onTouchMove: C, onTouchEnd: g, onTouchCancel: g, onMouseEnter: k, onMouseLeave: D, onClick: m },
|
|
600
|
-
children: [
|
|
601
|
-
I,
|
|
602
|
-
/* @__PURE__ */ M(
|
|
603
|
-
de,
|
|
604
|
-
{
|
|
605
|
-
"aria-label": `${u.remove} ${t.name ?? ""}`.trim(),
|
|
606
|
-
group: a && !l && !n ? o : void 0,
|
|
607
|
-
onMouseDown: oe,
|
|
608
|
-
onClick: B,
|
|
609
|
-
className: "rac-chip-del",
|
|
610
|
-
disabled: r,
|
|
611
|
-
tabIndex: -1,
|
|
612
|
-
type: "button",
|
|
613
|
-
in: L,
|
|
614
|
-
as: "button",
|
|
615
|
-
axis: "x",
|
|
616
|
-
children: he(b.remove)
|
|
617
|
-
}
|
|
618
|
-
)
|
|
619
|
-
]
|
|
620
|
-
}
|
|
621
|
-
);
|
|
622
|
-
}), Cn = ie(function({ element: t, chipStore: n, settle: r, ...s }) {
|
|
623
|
-
const o = ce(n.subscribe, () => n.get().breaks.includes(t.id), () => !1);
|
|
624
|
-
return /* @__PURE__ */ ee(wt, { children: [
|
|
625
|
-
/* @__PURE__ */ M(de, { className: "rac-chip-slot", onEntered: r, onExited: r, unmountOnExit: !1, "data-id": t.id, axis: "x", fade: !0, children: /* @__PURE__ */ M(kn, { element: t, chipStore: n, ...s }) }),
|
|
626
|
-
o && /* @__PURE__ */ M("div", { className: "rac-spacer" })
|
|
627
|
-
] });
|
|
628
|
-
}), Tn = { position: "absolute", visibility: "hidden", pointerEvents: "none" }, jt = [], In = () => {
|
|
629
|
-
}, Mn = (e) => e == null ? "" : typeof e == "object" ? ye(e) ?? "" : String(e), $n = ie(function() {
|
|
630
|
-
const { selectRef: t, multiple: n, name: r, form: s, required: o } = V(ne), { selected: i, selectedIDs: a, disabled: l, fieldsetDisabled: b } = V(fe), { reset: u, markInvalid: x } = V(ue), d = G(null);
|
|
631
|
-
J(() => {
|
|
632
|
-
const f = d.current?.getRootNode();
|
|
633
|
-
let v;
|
|
634
|
-
const A = (T) => {
|
|
635
|
-
T.target === d.current?.form && (clearTimeout(v), v = setTimeout(() => T.defaultPrevented || u()));
|
|
636
|
-
};
|
|
637
|
-
return f?.addEventListener("reset", A, !0), () => {
|
|
638
|
-
clearTimeout(v), f?.removeEventListener("reset", A, !0);
|
|
639
|
-
};
|
|
640
|
-
}, [u]);
|
|
641
|
-
const c = n ? a : i ? [i] : jt, y = !o && (!r || n && !c.length), w = y || !c.length ? [""] : c.map((f) => Mn(f.original)), p = () => t.current?.focus();
|
|
642
|
-
return w.map(
|
|
643
|
-
(f, v) => /* @__PURE__ */ M("input", { className: "rac-input", ref: v ? void 0 : d, name: y ? void 0 : r, form: s, value: f, hidden: y, required: o && !v, disabled: l && !b, tabIndex: -1, "aria-hidden": "true", autoComplete: "off", onChange: In, onInvalid: x, onFocus: p }, v)
|
|
644
|
-
);
|
|
645
|
-
});
|
|
646
|
-
class An extends Pt {
|
|
647
|
-
getSnapshotBeforeUpdate(t) {
|
|
648
|
-
const n = t.look !== this.props.look;
|
|
649
|
-
return (n || t.chips !== this.props.chips) && this.props.take(n), null;
|
|
650
|
-
}
|
|
651
|
-
componentDidUpdate() {
|
|
652
|
-
}
|
|
653
|
-
render() {
|
|
654
|
-
return null;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
const gt = (e, t) => {
|
|
658
|
-
const n = new Set(e.map((i) => i.id)), r = new Map(t.map(([i, a]) => [a.id, i])), s = t.filter(([, i]) => !n.has(i.id)), o = new Set(t.map(([i]) => i));
|
|
659
|
-
return e.map((i) => {
|
|
660
|
-
if (r.has(i.id)) return [r.get(i.id), i];
|
|
661
|
-
const a = s.findIndex(([, b]) => dn(b.original, i.original));
|
|
662
|
-
if (a >= 0) return [s.splice(a, 1)[0][0], i];
|
|
663
|
-
let l = i.id;
|
|
664
|
-
for (; o.has(l); ) l += "~";
|
|
665
|
-
return o.add(l), [l, i];
|
|
666
|
-
});
|
|
667
|
-
}, Nn = (e) => {
|
|
668
|
-
const [t, n] = Q(() => ({ chips: e, keyed: gt(e, []) }));
|
|
669
|
-
if (t.chips === e) return t.keyed;
|
|
670
|
-
const r = gt(e, t.keyed);
|
|
671
|
-
return n({ chips: e, keyed: r }), r;
|
|
672
|
-
}, Dn = ie(function() {
|
|
673
|
-
const { selectedText: t, icons: n, valueAsOption: r, renderOption: s } = V(ne), { selectedIDs: o, title: i, valueOption: a, hasActualValue: l, loading: b, error: u, deleting: x, active: d } = V(fe), c = o.length > 0 && !t, y = c ? o : jt, { chipStore: w, delGroup: p, valueRef: f, delIconRef: v, probe: A, settle: T, held: H, snapshot: C, look: g, wait: k } = On(y), D = Nn(y), [R] = Q(() => /* @__PURE__ */ new Set()), I = r && a ? Ue(a, s, !0) : null, B = b && !u && !l, m = `${I ? a.id : i}${B ? "-loading" : ""}`, L = a?.type === "boolean" ? String(a.raw) : void 0;
|
|
674
|
-
return /* @__PURE__ */ ee("div", { className: "rac-value", ref: f, children: [
|
|
675
|
-
/* @__PURE__ */ M(An, { chips: y, look: g, take: C }),
|
|
676
|
-
/* @__PURE__ */ M(qe, { children: !c && /* @__PURE__ */ ee(de, { axis: "x", fade: !0, group: R, className: me("rac-title", I && a.className), style: I ? a.style : void 0, "data-bool": L, onEntered: T, onExited: T, children: [
|
|
677
|
-
I ? /* @__PURE__ */ M("div", { className: "rac-option-jsx", children: I }) : i,
|
|
678
|
-
B && Ye
|
|
679
|
-
] }, m) }),
|
|
680
|
-
/* @__PURE__ */ M(qe, { hold: H, wait: k, children: D.map(
|
|
681
|
-
([S, F]) => /* @__PURE__ */ M(
|
|
682
|
-
Cn,
|
|
683
|
-
{
|
|
684
|
-
element: F,
|
|
685
|
-
deleting: x,
|
|
686
|
-
locked: !d,
|
|
687
|
-
chipStore: w,
|
|
688
|
-
delGroup: p,
|
|
689
|
-
settle: T
|
|
690
|
-
},
|
|
691
|
-
S
|
|
692
|
-
)
|
|
693
|
-
) }),
|
|
694
|
-
A && /* @__PURE__ */ M("button", { type: "button", className: "rac-chip-del", tabIndex: -1, "aria-hidden": "true", ref: v, style: Tn, children: he(n.remove) })
|
|
695
|
-
] });
|
|
696
|
-
}), Ln = ie(function() {
|
|
697
|
-
const { selectRef: t, selectId: n, highlightStore: r, className: s, style: o, duration: i, easing: a, deleteInline: l, icons: b, texts: u, placeholder: x, id: d, required: c, popup: y, attrs: w } = V(ne), { visibility: p, active: f, hasActualValue: v, deleting: A, loading: T, loadPending: H, error: C, invalid: g, normalizedOptions: k } = V(fe), { handleBlur: D, handleFocus: R, handleKeyDown: I, toggleVisibility: B, clear: m } = V(ue), L = ce(r.subscribe, () => {
|
|
698
|
-
const O = p ? k[Ie(r.get())] : null;
|
|
699
|
-
return O ? De(n, O.id) : void 0;
|
|
700
|
-
}, () => {
|
|
701
|
-
}), S = !!b.clear && v && f && !A, F = !!b.arrow && f && !A && y, h = y ? { role: "combobox", "aria-haspopup": "listbox", "aria-controls": `${n}-listbox`, "aria-expanded": p, "aria-activedescendant": L, "aria-required": c || void 0 } : { role: "group" };
|
|
702
|
-
return /* @__PURE__ */ ee(
|
|
703
|
-
"div",
|
|
704
|
-
{
|
|
705
|
-
...w,
|
|
706
|
-
id: d,
|
|
707
|
-
ref: t,
|
|
708
|
-
style: { "--rac-duration": `${i}ms`, "--rac-ease": a, ...o },
|
|
709
|
-
className: me("rac-select", s),
|
|
710
|
-
...f && {
|
|
711
|
-
onKeyDown: I,
|
|
712
|
-
onFocus: R,
|
|
713
|
-
onClick: B,
|
|
714
|
-
onBlur: D
|
|
715
|
-
},
|
|
716
|
-
...h,
|
|
717
|
-
"aria-disabled": !f,
|
|
718
|
-
tabIndex: f ? 0 : -1,
|
|
719
|
-
"aria-busy": T || H || void 0,
|
|
720
|
-
"aria-label": w["aria-label"] ?? (w["aria-labelledby"] ? void 0 : x),
|
|
721
|
-
"aria-invalid": g || w["aria-invalid"],
|
|
722
|
-
"aria-describedby": [w["aria-describedby"], C && `${n}-error`].filter(Boolean).join(" ") || void 0,
|
|
723
|
-
"data-inline-delete": re(l),
|
|
724
|
-
"data-empty": re(!v),
|
|
725
|
-
"data-deleting": re(A),
|
|
726
|
-
"data-error": re(C),
|
|
727
|
-
"data-invalid": re(g),
|
|
728
|
-
children: [
|
|
729
|
-
/* @__PURE__ */ M(Dn, {}),
|
|
730
|
-
/* @__PURE__ */ ee(qe, { children: [
|
|
731
|
-
S && /* @__PURE__ */ M(de, { as: "button", type: "button", axis: "x", className: "rac-clear", tabIndex: -1, "aria-label": u.clear, onMouseDown: oe, onClick: (O) => {
|
|
732
|
-
Et(O, t), m(O);
|
|
733
|
-
}, children: he(b.clear) }, "clear"),
|
|
734
|
-
F && /* @__PURE__ */ M(de, { axis: "x", className: "rac-arrow", "aria-hidden": "true", children: he(b.arrow) }, "arrow")
|
|
735
|
-
] }),
|
|
736
|
-
/* @__PURE__ */ M($n, {})
|
|
737
|
-
]
|
|
738
|
-
}
|
|
739
|
-
);
|
|
740
|
-
}), Fe = 0, jn = 1, ht = 2, Rt = (e) => {
|
|
741
|
-
const { highlightStore: t } = V(ne), n = G(null), r = ce(t.subscribe, () => {
|
|
742
|
-
const s = t.get();
|
|
743
|
-
return Ie(s) !== e ? Fe : s.ready ? ht : jn;
|
|
744
|
-
}, () => Fe);
|
|
745
|
-
return X(() => {
|
|
746
|
-
r === ht && n.current?.scrollIntoView?.({ block: "nearest" });
|
|
747
|
-
}, [r]), [n, r !== Fe];
|
|
748
|
-
}, Bt = (e, t) => `${De(e, t.id)}_l`, Rn = ie(function({ option: t, index: n, open: r, hasChildren: s }) {
|
|
749
|
-
const { selectId: o, icons: i, texts: a } = V(ne), { selectOption: l, highlight: b } = V(ue), [u, x] = Rt(n), d = s && !t.disabled;
|
|
750
|
-
return /* @__PURE__ */ ee(
|
|
751
|
-
"div",
|
|
752
|
-
{
|
|
753
|
-
className: me("rac-group", t.className),
|
|
754
|
-
onMouseEnter: () => d && b(n),
|
|
755
|
-
onClick: (c) => l(t, c),
|
|
756
|
-
"aria-label": d ? `${t.name}, ${r ? a.groupOpen : a.groupClosed}` : void 0,
|
|
757
|
-
"aria-disabled": !d || void 0,
|
|
758
|
-
"data-highlighted": re(x),
|
|
759
|
-
"data-disabled": re(t.disabled),
|
|
760
|
-
id: De(o, t.id),
|
|
761
|
-
"data-open": re(r),
|
|
762
|
-
"aria-selected": "false",
|
|
763
|
-
style: t.style,
|
|
764
|
-
role: "option",
|
|
765
|
-
ref: u,
|
|
766
|
-
children: [
|
|
767
|
-
/* @__PURE__ */ M("span", { className: "rac-group-text", id: Bt(o, t), children: t.name }),
|
|
768
|
-
/* @__PURE__ */ M(de, { axis: "x", in: s && !t.disabled, className: "rac-group-arrow", "aria-hidden": "true", children: he(i.arrow) })
|
|
769
|
-
]
|
|
770
|
-
}
|
|
771
|
-
);
|
|
772
|
-
}), Bn = ie(function({ option: t, index: n, isSelected: r, showCheckbox: s }) {
|
|
773
|
-
const { selectId: o, icons: i, renderOption: a } = V(ne), { selectOption: l, highlight: b } = V(ue), [u, x] = Rt(n), d = !t.disabled && !t.loading, c = Ue(t, a, r);
|
|
774
|
-
return /* @__PURE__ */ ee(
|
|
775
|
-
"div",
|
|
776
|
-
{
|
|
777
|
-
className: me("rac-option", t.className),
|
|
778
|
-
onMouseEnter: () => d && b(n),
|
|
779
|
-
onClick: (y) => !t.loading && l(t, y),
|
|
780
|
-
"aria-disabled": t.disabled || t.loading,
|
|
781
|
-
"data-invalid": re(t.invalid),
|
|
782
|
-
"data-bool": typeof t.raw == "boolean" ? String(t.raw) : void 0,
|
|
783
|
-
"data-highlighted": re(x),
|
|
784
|
-
"data-loading": re(t.loading),
|
|
785
|
-
id: De(o, t.id),
|
|
786
|
-
"aria-selected": r,
|
|
787
|
-
style: t.style,
|
|
788
|
-
role: "option",
|
|
789
|
-
ref: u,
|
|
790
|
-
children: [
|
|
791
|
-
c ? /* @__PURE__ */ M("div", { className: "rac-option-jsx", children: c }) : /* @__PURE__ */ M("span", { className: "rac-option-text", children: t.name }),
|
|
792
|
-
t.loading && Ye,
|
|
793
|
-
s && /* @__PURE__ */ ee("div", { className: "rac-check", "data-default": re(!i.checkbox), children: [
|
|
794
|
-
he(i.check, { className: "rac-checkmark" }),
|
|
795
|
-
he(i.checkbox, { className: "rac-check-icon" })
|
|
796
|
-
] })
|
|
797
|
-
]
|
|
798
|
-
}
|
|
799
|
-
);
|
|
800
|
-
}), Fn = ie(function() {
|
|
801
|
-
const { selectId: t, multiple: n } = V(ne), { normalizedOptions: r, selected: s, selectedIDs: o, expandedGroups: i } = V(fe), a = s?.id;
|
|
802
|
-
return Z(() => {
|
|
803
|
-
const l = new Set(o.map((p) => p.id)), b = r.reduce((p, f) => (f.group && (p[f.group] = (p[f.group] || 0) + 1), p), {}), u = [];
|
|
804
|
-
let x = [], d = null, c = null;
|
|
805
|
-
const y = () => {
|
|
806
|
-
d !== null && x.length && u.push(
|
|
807
|
-
/* @__PURE__ */ M(de, { axis: "y", in: i.has(d), className: "rac-group-items", role: "group", "aria-labelledby": c, children: x }, `slide-${d}`)
|
|
808
|
-
), x = [];
|
|
809
|
-
}, w = (p, f) => /* @__PURE__ */ M(
|
|
810
|
-
Bn,
|
|
811
|
-
{
|
|
812
|
-
isSelected: l.has(p.id) || a === p.id,
|
|
813
|
-
showCheckbox: n && !p.disabled && "original" in p,
|
|
814
|
-
option: p,
|
|
815
|
-
index: f
|
|
816
|
-
},
|
|
817
|
-
p.id
|
|
818
|
-
);
|
|
819
|
-
return r.forEach((p, f) => {
|
|
820
|
-
p.groupHeader ? (y(), d = p.name, c = Bt(t, p), u.push(
|
|
821
|
-
/* @__PURE__ */ M(
|
|
822
|
-
Rn,
|
|
823
|
-
{
|
|
824
|
-
hasChildren: b[p.name] > 0,
|
|
825
|
-
open: i.has(p.name),
|
|
826
|
-
option: p,
|
|
827
|
-
index: f
|
|
828
|
-
},
|
|
829
|
-
p.id
|
|
830
|
-
)
|
|
831
|
-
)) : p.group ? x.push(w(p, f)) : (y(), d = null, u.push(w(p, f)));
|
|
832
|
-
}), y(), u;
|
|
833
|
-
}, [r, a, o, i, n, t]);
|
|
834
|
-
}), Hn = (e, t, n, r) => {
|
|
835
|
-
const s = e.getBoundingClientRect(), o = getComputedStyle(e), i = s.left - parseFloat(o.marginLeft) - t.left, a = n ? s.bottom + parseFloat(o.marginBottom) - t.top + r : s.top - parseFloat(o.marginTop) - t.bottom - r;
|
|
836
|
-
Math.abs(i) > 0.5 && (e.style.left = `${t.left - i}px`), Math.abs(a) > 0.5 && (e.style[n ? "bottom" : "top"] = `${parseFloat(e.style[n ? "bottom" : "top"]) + (n ? a : -a)}px`);
|
|
837
|
-
}, Pn = (e, t) => {
|
|
838
|
-
e && e.dataset.placement !== (t ? "top" : "bottom") && (e.dataset.placement = t ? "top" : "bottom");
|
|
839
|
-
}, He = () => typeof IntersectionObserver < "u", mt = (e, t, n = window.innerHeight - e.bottom) => n < t && e.top > n, Vn = ({ selectRef: e, panelRef: t, open: n, frozen: r, offset: s, onFlip: o }) => {
|
|
840
|
-
const i = G(0), a = G(r), l = G(o);
|
|
841
|
-
X(() => {
|
|
842
|
-
a.current = r, l.current = o;
|
|
843
|
-
});
|
|
844
|
-
const b = Y((c) => [e.current, t.current].forEach((y) => Pn(y, c)), [e, t]), u = Y((c) => {
|
|
845
|
-
const y = e.current;
|
|
846
|
-
if (!y || !c) return;
|
|
847
|
-
c.scrollHeight && (i.current = c.scrollHeight);
|
|
848
|
-
const w = y.getBoundingClientRect(), p = c.dataset.placement, f = i.current, v = p === "top" ? w.top - s >= f : window.innerHeight - w.bottom - s >= f;
|
|
849
|
-
let A = p && (a.current || v) ? p === "top" : mt(w, f);
|
|
850
|
-
p && A !== (p === "top") && (l.current?.(), A = p === "top"), b(A), c.style.width = `${w.width}px`, c.style.left = `${w.left + window.scrollX}px`, c.style.top = A ? "auto" : `${w.bottom + window.scrollY + s}px`, c.style.bottom = A ? `${window.innerHeight - w.top - window.scrollY + s}px` : "auto", Hn(c, w, A, s);
|
|
851
|
-
}, [e, s, b]), x = Y((c) => {
|
|
852
|
-
c && u(c.parentElement);
|
|
853
|
-
}, [u]), d = Y((c) => {
|
|
854
|
-
c?.removeAttribute("data-placement"), u(c);
|
|
855
|
-
}, [u]);
|
|
856
|
-
return J(() => {
|
|
857
|
-
const c = e.current;
|
|
858
|
-
if (n || !c || !He()) return;
|
|
859
|
-
i.current ||= parseFloat(getComputedStyle(c).getPropertyValue("--rac-list-max-height")) || 250;
|
|
860
|
-
const y = { fits: !0, lower: !1 }, w = (f, v, A) => {
|
|
861
|
-
const T = new IntersectionObserver(([{ boundingClientRect: H, rootBounds: C }]) => {
|
|
862
|
-
C && (A(H, C), b(!y.fits && y.lower));
|
|
863
|
-
}, { rootMargin: f, threshold: v });
|
|
864
|
-
return T.observe(c), T;
|
|
865
|
-
}, p = [
|
|
866
|
-
w(`0px 0px ${-i.current}px 0px`, [0, 1], (f, v) => {
|
|
867
|
-
y.fits = f.bottom <= v.bottom;
|
|
868
|
-
}),
|
|
869
|
-
w("0px 0px -50% 0px", [0, 0.5, 1], (f, v) => {
|
|
870
|
-
y.lower = f.top + f.bottom > 2 * v.bottom;
|
|
871
|
-
})
|
|
872
|
-
];
|
|
873
|
-
return () => p.forEach((f) => f.disconnect());
|
|
874
|
-
}, [n, e, b]), X(() => {
|
|
875
|
-
const c = e.current;
|
|
876
|
-
if (!n || !c) return;
|
|
877
|
-
const y = c.ownerDocument, w = t.current;
|
|
878
|
-
let p = 0, f = 0, v = "", A = null;
|
|
879
|
-
const T = () => {
|
|
880
|
-
const m = c.getBoundingClientRect(), L = t.current?.getBoundingClientRect() ?? m, S = mt(m, i.current), F = i.current + s;
|
|
881
|
-
return [m.left - L.left, S ? m.top - L.bottom : m.bottom - L.top, m.width, window.innerHeight, t.current?.scrollHeight, S, m.top >= F, window.innerHeight - m.bottom >= F].join();
|
|
882
|
-
}, H = () => {
|
|
883
|
-
if (A?.disconnect(), !He()) return;
|
|
884
|
-
const m = c.getBoundingClientRect(), { clientWidth: L, clientHeight: S } = y.documentElement, F = [m.top, L - m.right, S - m.bottom, m.left].map((O) => `${-Math.floor(O)}px`).join(" ");
|
|
885
|
-
let h = !1;
|
|
886
|
-
A = new IntersectionObserver(([O]) => {
|
|
887
|
-
h && O.intersectionRatio < 1 && k(), h = O.intersectionRatio === 1;
|
|
888
|
-
}, { root: y, rootMargin: F, threshold: 1 }), A.observe(c);
|
|
889
|
-
}, C = () => T() === v ? !1 : (u(t.current), v = T(), !0), g = () => {
|
|
890
|
-
if (p = 0, C()) f = 0;
|
|
891
|
-
else if (++f > 1) return H();
|
|
892
|
-
p = requestAnimationFrame(g);
|
|
893
|
-
}, k = () => {
|
|
894
|
-
f = 0, p ||= requestAnimationFrame(g);
|
|
895
|
-
};
|
|
896
|
-
t.current?.removeAttribute("data-offscreen"), u(t.current), v = T(), H(), window.addEventListener("scroll", k, { capture: !0, passive: !0 }), window.addEventListener("resize", k);
|
|
897
|
-
const D = typeof ResizeObserver < "u" && new ResizeObserver(k);
|
|
898
|
-
D && [c, t.current].forEach((m) => m && D.observe(m));
|
|
899
|
-
const R = ({ target: m }) => !c.contains(m) && !t.current?.contains(m), I = typeof MutationObserver < "u" && new MutationObserver((m) => {
|
|
900
|
-
m.some(R) && C() && k();
|
|
901
|
-
});
|
|
902
|
-
I && I.observe(y.body, { subtree: !0, childList: !0, attributes: !0, characterData: !0 });
|
|
903
|
-
const B = He() && new IntersectionObserver(([{ isIntersecting: m, boundingClientRect: L, rootBounds: S }]) => {
|
|
904
|
-
const F = !m && !!S && L.bottom > S.top && L.top < S.bottom && L.right > S.left && L.left < S.right;
|
|
905
|
-
t.current?.toggleAttribute("data-offscreen", F);
|
|
906
|
-
});
|
|
907
|
-
return B && B.observe(c), () => {
|
|
908
|
-
cancelAnimationFrame(p), window.removeEventListener("scroll", k, { capture: !0 }), window.removeEventListener("resize", k);
|
|
909
|
-
for (const m of [D, I, B, A]) m && m.disconnect();
|
|
910
|
-
w?.removeAttribute("data-placement");
|
|
911
|
-
};
|
|
912
|
-
}, [n, u, s, e, t]), [x, d];
|
|
913
|
-
}, zn = (e = {}) => Object.fromEntries(Object.entries(e).filter(([t]) => t.startsWith("--"))), Wn = (e) => (typeof e == "function" ? e() : e) || document.body, qn = () => () => {
|
|
914
|
-
}, Gn = ie(function() {
|
|
915
|
-
const { selectRef: t, selectId: n, multiple: r, offset: s, duration: o, easing: i, animateOpacity: a, keepMounted: l, optionsClassName: b, style: u, container: x, hasMore: d, loadButton: c, texts: y, popup: w } = V(ne), { visibility: p, normalizedOptions: f, loading: v, error: A } = V(fe), { handleListScroll: T, setListReady: H } = V(ue), C = p && f.length > 0, g = ce(qn, () => !0, () => !1), [k, D] = Q(!1);
|
|
916
|
-
C && g && !k && D(!0);
|
|
917
|
-
const [R, I] = Q(null), B = Y(() => I((O) => O || "out"), []), m = G(null), [L, S] = Vn({ selectRef: t, panelRef: m, open: k, frozen: !C || R === "out", offset: s, onFlip: B }), F = () => {
|
|
918
|
-
if (R === "out" && C) {
|
|
919
|
-
S(m.current), I("in");
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
I(null), D(!1);
|
|
923
|
-
}, h = () => {
|
|
924
|
-
I(null), H(!0);
|
|
925
|
-
};
|
|
926
|
-
return !g || !w ? null : qt(
|
|
927
|
-
/* @__PURE__ */ M(
|
|
928
|
-
de,
|
|
929
|
-
{
|
|
930
|
-
axis: "y",
|
|
931
|
-
fade: a,
|
|
932
|
-
in: C && R !== "out",
|
|
933
|
-
duration: R ? o / 2 : void 0,
|
|
934
|
-
nodeRef: m,
|
|
935
|
-
unmountOnExit: !l && !(R && C),
|
|
936
|
-
onEntered: h,
|
|
937
|
-
onExited: F,
|
|
938
|
-
onMouseDown: (O) => O.preventDefault(),
|
|
939
|
-
className: me("rac-options", b),
|
|
940
|
-
style: { ...zn(u), "--rac-duration": `${o}ms`, "--rac-ease": i, pointerEvents: C ? "auto" : "none", position: "absolute" },
|
|
941
|
-
children: /* @__PURE__ */ ee(
|
|
942
|
-
"div",
|
|
943
|
-
{
|
|
944
|
-
onScroll: T,
|
|
945
|
-
className: "rac-list",
|
|
946
|
-
"aria-multiselectable": r,
|
|
947
|
-
id: `${n}-listbox`,
|
|
948
|
-
"aria-label": y.list,
|
|
949
|
-
role: "listbox",
|
|
950
|
-
tabIndex: "-1",
|
|
951
|
-
ref: L,
|
|
952
|
-
children: [
|
|
953
|
-
/* @__PURE__ */ M(Fn, {}),
|
|
954
|
-
A ? /* @__PURE__ */ M("div", { className: "rac-option", "data-error": "", children: /* @__PURE__ */ M("span", { className: "rac-option-text", children: y.error }) }) : (v || !c && d) && /* @__PURE__ */ ee("div", { className: "rac-option", "data-loading": "", children: [
|
|
955
|
-
/* @__PURE__ */ M("span", { className: "rac-option-text", children: v ? y.loading : y.loadingMore }),
|
|
956
|
-
Ye
|
|
957
|
-
] })
|
|
958
|
-
]
|
|
959
|
-
}
|
|
960
|
-
)
|
|
961
|
-
}
|
|
962
|
-
),
|
|
963
|
-
Wn(x)
|
|
964
|
-
);
|
|
965
|
-
}), Kn = 250, _n = 5e3, Un = [], Yn = () => () => {
|
|
966
|
-
}, be = (e, t) => typeof e == "function" ? e(t) : String(e ?? "").replace(/\{(n|label)\}/g, () => t), Xn = (e, t, n, r) => {
|
|
967
|
-
const s = [];
|
|
968
|
-
if (e.picked.length && !t.picked.length) s.push(be(n.cleared));
|
|
969
|
-
else if (r) {
|
|
970
|
-
const o = new Set(t.picked.map((l) => l.id)), i = new Set(e.picked.map((l) => l.id)), a = e.picked.filter((l) => !o.has(l.id));
|
|
971
|
-
a.length && s.push(be(n.removed, a.map((l) => l.name).join(", "))), t.picked.some((l) => !i.has(l.id)) && s.push(be(n.selected, t.picked.length));
|
|
972
|
-
}
|
|
973
|
-
return t.open && e.count && t.count > e.count && s.push(be(n.loaded, t.count - e.count)), t.error && !e.error && s.push(be(n.error)), s.filter(Boolean).join(". ");
|
|
974
|
-
}, Jn = ie(function() {
|
|
975
|
-
const { selectRef: t, selectId: n, multiple: r, texts: s } = V(ne), { selected: o, selectedIDs: i, normalizedOptions: a, visibility: l, deleting: b, error: u } = V(fe), x = ce(Yn, () => !0, () => !1), [d, c] = Q(""), y = G({ base: null, timer: 0, wipe: 0, latest: null }), w = Z(() => a.reduce((p, f) => "original" in f ? p + 1 : p, 0), [a]);
|
|
976
|
-
return J(() => {
|
|
977
|
-
const p = r ? i : o ? [o] : Un;
|
|
978
|
-
y.current.latest = { snap: { picked: p, count: w, open: l, error: !!u }, texts: s, multiple: r, deleting: b };
|
|
979
|
-
}), J(() => {
|
|
980
|
-
const p = y.current, { snap: f, deleting: v } = p.latest;
|
|
981
|
-
if (!p.base || !p.timer && !v && !t.current?.contains(document.activeElement)) {
|
|
982
|
-
p.base = f;
|
|
983
|
-
return;
|
|
984
|
-
}
|
|
985
|
-
clearTimeout(p.timer), p.timer = setTimeout(() => {
|
|
986
|
-
p.timer = 0;
|
|
987
|
-
const { snap: A, texts: T, multiple: H } = p.latest, C = Xn(p.base, A, T, H);
|
|
988
|
-
p.base = A, C && (c((g) => g === C ? `${C} ` : C), clearTimeout(p.wipe), p.wipe = setTimeout(() => c(""), _n));
|
|
989
|
-
}, Kn);
|
|
990
|
-
}, [o, i, w, u, t]), J(() => {
|
|
991
|
-
const p = y.current;
|
|
992
|
-
return () => {
|
|
993
|
-
clearTimeout(p.timer), clearTimeout(p.wipe);
|
|
994
|
-
};
|
|
995
|
-
}, []), x ? /* @__PURE__ */ ee("div", { className: "rac-live", children: [
|
|
996
|
-
/* @__PURE__ */ M("div", { "aria-live": "polite", "aria-atomic": "true", children: d }),
|
|
997
|
-
u && /* @__PURE__ */ M("div", { id: `${n}-error`, children: be(s.error) })
|
|
998
|
-
] }) : null;
|
|
999
|
-
}), Ge = [];
|
|
1000
|
-
function Zn({ props: e, jsxOptions: t, state: n, setState: r, setVisibility: s, loadMoreOnce: o }) {
|
|
1001
|
-
const { onChange: i, disabled: a, loading: l, error: b, multiple: u, childrenFirst: x, groupsClosed: d, hasMore: c, loadButton: y, placeholder: w, selectedText: p, texts: f } = e, { disabledOption: v, emptyOption: A, invalidOption: T, emptyGroup: H } = f, { loadPending: C, internalValue: g, toggledGroups: k, picked: D } = n, R = ze(e.options), I = ze(e.value), B = I !== void 0, m = B ? I : g, L = C ? f.loadingMore : f.loadMore, S = Z(() => ln({
|
|
1002
|
-
options: R,
|
|
1003
|
-
jsxOptions: t,
|
|
1004
|
-
childrenFirst: x,
|
|
1005
|
-
hasMore: c,
|
|
1006
|
-
loadButton: y,
|
|
1007
|
-
loadPending: C,
|
|
1008
|
-
loadingTitle: L,
|
|
1009
|
-
emptyOption: A,
|
|
1010
|
-
invalidOption: T,
|
|
1011
|
-
disabledOption: v,
|
|
1012
|
-
emptyGroup: H
|
|
1013
|
-
}), [R, t, x, c, y, C, L, A, T, v, H]), F = Z(() => new Set(
|
|
1014
|
-
S.filter((j) => j.groupHeader && !j.disabled && d === k.has(j.name)).map((j) => j.name)
|
|
1015
|
-
), [S, k, d]), { selected: h, selectedIDs: O } = Z(() => st(m, S, u, D), [m, S, u, D]), E = S.length > 0, $ = !a && E, N = m != null && !(Array.isArray(m) && !m.length) && !(Le(m) && !Object.keys(m).length), P = N && p ? null : h, _ = Z(() => N && p ? p : h ? h.name : b ? f.error : l ? f.loading : a ? f.disabled : E ? w : f.empty, [b, l, a, N, p, h, E, w, f]), z = (j) => r((K) => {
|
|
1016
|
-
const U = new Set(K.toggledGroups);
|
|
1017
|
-
return U.has(j) ? U.delete(j) : U.add(j), { toggledGroups: U };
|
|
1018
|
-
}), W = (j, K, U) => {
|
|
1019
|
-
r(B ? { picked: U } : { internalValue: j, picked: U }), i?.(j, K);
|
|
1020
|
-
}, ve = (j) => W(j.map((K) => K.original), j.map((K) => K.userId), j.map((K) => K.id)), we = _e({
|
|
1021
|
-
toggleGroup: z,
|
|
1022
|
-
selectOption: (j, K) => {
|
|
1023
|
-
if (j.groupHeader) {
|
|
1024
|
-
oe(K), j.disabled || z(j.name);
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
if (j.disabled || j.loadMore) {
|
|
1028
|
-
oe(K), j.loadMore && !j.loading && o();
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
if (u) {
|
|
1032
|
-
oe(K);
|
|
1033
|
-
const U = O.some((pe) => pe.id === j.id);
|
|
1034
|
-
ve(U ? O.filter((pe) => pe.id !== j.id) : [...O, j]);
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
h?.id !== j.id && W(j.original, j.userId, [j.id]), s(!1);
|
|
1038
|
-
},
|
|
1039
|
-
clear: (j) => {
|
|
1040
|
-
oe(j), W(u ? [] : null, u ? [] : null, Ge);
|
|
1041
|
-
},
|
|
1042
|
-
removeOption: (j) => ve(O.filter((K) => K.id !== j)),
|
|
1043
|
-
// [DOC: form-field]
|
|
1044
|
-
reset: () => {
|
|
1045
|
-
r({ deleting: !1, invalid: !1 }), s(!1);
|
|
1046
|
-
const j = u ? [] : null, K = e.defaultValue ?? j, { selected: U, selectedIDs: pe } = st(K, S, u, Ge), q = u ? pe : U ? [U] : [], te = u ? O : h ? [h] : [];
|
|
1047
|
-
Te(m ?? j, K) && q.length === te.length && q.every((ae, ge) => ae.id === te[ge].id) || W(K, u ? q.map((ae) => ae.userId) : U?.userId ?? null, q.map((ae) => ae.id));
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
|
-
return { normalizedOptions: S, expandedGroups: F, selected: h, selectedIDs: O, hasOptions: E, active: $, hasActualValue: N, title: _, valueOption: P, actions: we };
|
|
1051
|
-
}
|
|
1052
|
-
const Qn = (e) => ({
|
|
1053
|
-
internalVisibility: !1,
|
|
1054
|
-
deleting: !1,
|
|
1055
|
-
loadPending: !1,
|
|
1056
|
-
toggledGroups: /* @__PURE__ */ new Set(),
|
|
1057
|
-
internalValue: e.defaultValue,
|
|
1058
|
-
picked: Ge,
|
|
1059
|
-
fieldsetDisabled: !1,
|
|
1060
|
-
invalid: !1
|
|
1061
|
-
});
|
|
1062
|
-
function er(e, t) {
|
|
1063
|
-
const [n, r] = Vt(Gt, e, Qn), { internalVisibility: s, deleting: o, loadPending: i, fieldsetDisabled: a } = n, l = Z(() => a && !e.disabled ? { ...e, disabled: !0 } : e, [e, a]), { ref: b, open: u, onOpenChange: x, popup: d, hasMore: c, loadMore: y, loadButton: w, error: p, disabled: f, loading: v, required: A, texts: T } = l, H = zt(), C = Z(() => H.replace(/:/g, ""), [H]), g = G(null);
|
|
1064
|
-
Wt(b, () => g.current), X(() => {
|
|
1065
|
-
const q = g.current?.querySelector(".rac-input");
|
|
1066
|
-
if (!q) return;
|
|
1067
|
-
const te = () => r({ fieldsetDisabled: !e.disabled && q.matches(":disabled") });
|
|
1068
|
-
te();
|
|
1069
|
-
const ae = new MutationObserver(te);
|
|
1070
|
-
for (let ge = q.parentElement; ge; ge = ge.parentElement) ge.tagName === "FIELDSET" && ae.observe(ge, { attributeFilter: ["disabled"] });
|
|
1071
|
-
return () => ae.disconnect();
|
|
1072
|
-
}, [e.disabled]);
|
|
1073
|
-
const [k] = Q(() => xt(Jt)), D = u !== void 0, R = D ? !!u : s, I = G(!1), B = G(!1), m = _e({
|
|
1074
|
-
// [DOC: select-store]
|
|
1075
|
-
setVisibility: (q) => {
|
|
1076
|
-
q === R || q && !d || (D || r({ internalVisibility: q }), x?.(q));
|
|
1077
|
-
},
|
|
1078
|
-
// [DOC: select-store]
|
|
1079
|
-
loadMoreOnce: () => {
|
|
1080
|
-
if (!c || I.current) return;
|
|
1081
|
-
if (!y) return le("no loadMore", "`hasMore` is set, but there is no `loadMore` to call.");
|
|
1082
|
-
I.current = !0, r({ loadPending: !0 });
|
|
1083
|
-
const q = () => r({ loadPending: !1 });
|
|
1084
|
-
try {
|
|
1085
|
-
y()?.then?.(q, q);
|
|
1086
|
-
} catch (te) {
|
|
1087
|
-
I.current = !1, q(), (globalThis.reportError ?? console.error)(te);
|
|
1088
|
-
}
|
|
1089
|
-
},
|
|
1090
|
-
setListReady: (q) => k.set({ ready: q }),
|
|
1091
|
-
setDeleting: (q) => r({ deleting: q }),
|
|
1092
|
-
// [DOC: form-field]
|
|
1093
|
-
markInvalid: () => r({ invalid: !0 })
|
|
1094
|
-
}), L = Zn({ props: l, jsxOptions: t, state: n, setState: r, setVisibility: m.setVisibility, loadMoreOnce: m.loadMoreOnce }), { normalizedOptions: S, expandedGroups: F, selected: h, selectedIDs: O, hasOptions: E, active: $, hasActualValue: N, title: P, valueOption: _, actions: z } = L, W = $ && R && d, ve = sn({
|
|
1095
|
-
props: l,
|
|
1096
|
-
state: n,
|
|
1097
|
-
setState: r,
|
|
1098
|
-
normalizedOptions: S,
|
|
1099
|
-
expandedGroups: F,
|
|
1100
|
-
selected: h,
|
|
1101
|
-
selectedIDs: O,
|
|
1102
|
-
visibility: W,
|
|
1103
|
-
highlightStore: k,
|
|
1104
|
-
setVisibility: m.setVisibility,
|
|
1105
|
-
loadMoreOnce: m.loadMoreOnce,
|
|
1106
|
-
modelActions: z
|
|
1107
|
-
});
|
|
1108
|
-
J(() => {
|
|
1109
|
-
r({ loadPending: !1 });
|
|
1110
|
-
}, [S.length, c, w]), J(() => {
|
|
1111
|
-
i || (I.current = !1);
|
|
1112
|
-
}, [i]), J(() => {
|
|
1113
|
-
W && g.current && document.activeElement !== g.current && g.current.focus(), W || k.set({ index: -1, ready: !1 });
|
|
1114
|
-
}, [W, k]), J(() => {
|
|
1115
|
-
B.current && !$ && m.setVisibility(!1), B.current = $;
|
|
1116
|
-
}, [$, m]);
|
|
1117
|
-
const we = G(null), j = l.value !== void 0;
|
|
1118
|
-
J(() => {
|
|
1119
|
-
const q = { value: j, open: D };
|
|
1120
|
-
for (const te in q) we.current && we.current[te] !== q[te] && le(`switch ${te}`, `\`${te}\` switched between controlled and uncontrolled (\`undefined\`) after mount. Pick one mode for the lifetime of the Select, like a React input${te === "value" ? "; clear a controlled value with `null` or `[]`" : ""}.`);
|
|
1121
|
-
we.current = q;
|
|
1122
|
-
}, [j, D]), X(() => {
|
|
1123
|
-
g.current?.querySelector(".rac-input")?.setCustomValidity(A && !N && T.required || "");
|
|
1124
|
-
}, [A, N, T.required]);
|
|
1125
|
-
const K = n.invalid && A && !N && !f, U = Z(() => ({ ...m, ...z, ...ve }), [m, z, ve]), pe = Z(() => ({
|
|
1126
|
-
visibility: W,
|
|
1127
|
-
deleting: o,
|
|
1128
|
-
loadPending: i,
|
|
1129
|
-
expandedGroups: F,
|
|
1130
|
-
selectedIDs: O,
|
|
1131
|
-
normalizedOptions: S,
|
|
1132
|
-
selected: h,
|
|
1133
|
-
hasOptions: E,
|
|
1134
|
-
active: $,
|
|
1135
|
-
hasActualValue: N,
|
|
1136
|
-
title: P,
|
|
1137
|
-
valueOption: _,
|
|
1138
|
-
disabled: f,
|
|
1139
|
-
fieldsetDisabled: a,
|
|
1140
|
-
invalid: K,
|
|
1141
|
-
loading: v,
|
|
1142
|
-
error: p
|
|
1143
|
-
}), [W, o, i, F, O, S, h, E, $, N, P, _, f, a, K, v, p]);
|
|
1144
|
-
return { selectId: C, selectRef: g, highlightStore: k, state: pe, actions: U };
|
|
1145
|
-
}
|
|
1146
|
-
const tr = {}, se = (e) => e != null && e !== "", Ke = (e) => e ? typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(Ke).join(" ").replace(/\s+/g, " ").trim() : Ne(e) ? Ke(e.props.children) : "" : "", nr = ({ name: e, label: t, id: n, value: r, className: s, style: o, children: i, disabled: a, group: l }, b, u) => {
|
|
1147
|
-
const x = Ke(i), d = r !== void 0 ? r : x;
|
|
1148
|
-
return i != null && !x && !se(t) && !se(e) && !se(n) && !se(r) && le("no text", "<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."), {
|
|
1149
|
-
id: se(n) ? String(n) : b,
|
|
1150
|
-
userId: se(n) ? n : d,
|
|
1151
|
-
value: d,
|
|
1152
|
-
label: se(t) ? String(t) : se(e) ? String(e) : x || (se(n) ? String(n) : ""),
|
|
1153
|
-
jsx: i,
|
|
1154
|
-
hasJsx: i != null,
|
|
1155
|
-
className: s,
|
|
1156
|
-
style: o,
|
|
1157
|
-
disabled: !!a,
|
|
1158
|
-
group: l || u || null
|
|
1159
|
-
};
|
|
1160
|
-
}, rr = ({ name: e, label: t, value: n, id: r, disabled: s, className: o = "", style: i = tr }, a) => {
|
|
1161
|
-
const l = e ?? t ?? r ?? n;
|
|
1162
|
-
return { disabled: !!s, isGroupMarker: !0, group: se(l) ? String(l) : a, className: o, style: i };
|
|
1163
|
-
}, sr = (e) => `<${typeof e == "string" ? e : e?.displayName || e?.name || "Component"}>`, Ce = (e, t, n = null, r = "o", s = []) => (vt.toArray(e).forEach((o) => {
|
|
1164
|
-
if (!Ne(o)) {
|
|
1165
|
-
le("text", `Text inside <Select> or <OptGroup> is ignored ("${String(o).slice(0, 30)}"). Wrap it in <Option>.`);
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
const i = `${r}-${String(o.key).slice(1).replace(/[:$]/g, (l) => l === ":" ? "-" : "k").replace(/[^\p{L}\p{N}-]/gu, "")}`, a = o.type?.racKind;
|
|
1169
|
-
if (o.type === wt) Ce(o.props.children, t, n, i, s);
|
|
1170
|
-
else if (a === "option") s.push(nr(o.props, i, n));
|
|
1171
|
-
else if (a === "define") Ce(o.type.racRender(o.props), t, n, i, s);
|
|
1172
|
-
else if (a === "group") {
|
|
1173
|
-
const l = rr(o.props, t);
|
|
1174
|
-
s.push(l), Ce(o.props.children, t, l.group, i, s);
|
|
1175
|
-
} else {
|
|
1176
|
-
const l = sr(o.type);
|
|
1177
|
-
le(`child ${l}`, `${l} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`);
|
|
1178
|
-
}
|
|
1179
|
-
}), s), or = /* @__PURE__ */ new Set(["ref", "options", "value", "defaultValue", "onChange", "children", "loadMore", "open", "onOpenChange", "onFocus", "onBlur", "onKeyDown", "childrenFirst", "groupsClosed", "disabled", "loading", "error"]), ir = /^(aria|data)-/, Pe = {
|
|
1180
|
-
options: [],
|
|
1181
|
-
value: void 0,
|
|
1182
|
-
defaultValue: void 0,
|
|
1183
|
-
onChange: void 0,
|
|
1184
|
-
multiple: !1,
|
|
1185
|
-
childrenFirst: !1,
|
|
1186
|
-
groupsClosed: !1,
|
|
1187
|
-
disabled: !1,
|
|
1188
|
-
loading: !1,
|
|
1189
|
-
error: !1,
|
|
1190
|
-
open: void 0,
|
|
1191
|
-
onOpenChange: void 0,
|
|
1192
|
-
popup: !0,
|
|
1193
|
-
onFocus: void 0,
|
|
1194
|
-
onBlur: void 0,
|
|
1195
|
-
onKeyDown: void 0,
|
|
1196
|
-
id: void 0,
|
|
1197
|
-
name: void 0,
|
|
1198
|
-
form: void 0,
|
|
1199
|
-
required: !1,
|
|
1200
|
-
hasMore: !1,
|
|
1201
|
-
loadMore: void 0,
|
|
1202
|
-
loadButton: !1,
|
|
1203
|
-
loadOffset: 100,
|
|
1204
|
-
loadAhead: 3,
|
|
1205
|
-
placeholder: "Choose option",
|
|
1206
|
-
selectedText: void 0,
|
|
1207
|
-
texts: {
|
|
1208
|
-
empty: "No options",
|
|
1209
|
-
disabled: "Disabled",
|
|
1210
|
-
loading: "Loading",
|
|
1211
|
-
error: "Failed to load",
|
|
1212
|
-
clear: "Clear selection",
|
|
1213
|
-
remove: "Remove",
|
|
1214
|
-
loadMore: "Load more",
|
|
1215
|
-
loadingMore: "Loading",
|
|
1216
|
-
emptyOption: "Empty option",
|
|
1217
|
-
invalidOption: "Invalid option",
|
|
1218
|
-
disabledOption: "Disabled option",
|
|
1219
|
-
emptyGroup: "Empty group",
|
|
1220
|
-
groupOpen: "expanded",
|
|
1221
|
-
groupClosed: "collapsed",
|
|
1222
|
-
list: "Options",
|
|
1223
|
-
required: void 0,
|
|
1224
|
-
removed: "Removed {label}",
|
|
1225
|
-
cleared: "Selection cleared",
|
|
1226
|
-
selected: "{n} selected",
|
|
1227
|
-
loaded: "{n} more options loaded"
|
|
1228
|
-
},
|
|
1229
|
-
renderOption: void 0,
|
|
1230
|
-
valueAsOption: !1,
|
|
1231
|
-
icons: { arrow: Se.ArrowUp, clear: Se.XMark, remove: Se.XMark, check: Se.Checkmark, checkbox: void 0 },
|
|
1232
|
-
deleteInline: !1,
|
|
1233
|
-
deleteAlways: !1,
|
|
1234
|
-
className: "",
|
|
1235
|
-
optionsClassName: "",
|
|
1236
|
-
style: {},
|
|
1237
|
-
container: void 0,
|
|
1238
|
-
duration: 300,
|
|
1239
|
-
easing: "ease",
|
|
1240
|
-
offset: 1,
|
|
1241
|
-
animateOpacity: !0,
|
|
1242
|
-
keepMounted: !1
|
|
1243
|
-
}, bt = {
|
|
1244
|
-
visibility: "open",
|
|
1245
|
-
setVisibility: "onOpenChange",
|
|
1246
|
-
ownBehavior: "open without onOpenChange",
|
|
1247
|
-
onOpen: "onOpenChange",
|
|
1248
|
-
onClose: "onOpenChange",
|
|
1249
|
-
unmount: "keepMounted (inverted)",
|
|
1250
|
-
showDelete: "deleteAlways",
|
|
1251
|
-
OpenIcon: "icons.arrow",
|
|
1252
|
-
ClearIcon: "icons.clear",
|
|
1253
|
-
DelIcon: "icons.remove",
|
|
1254
|
-
Checkmark: "icons.check",
|
|
1255
|
-
Checkbox: "icons.checkbox",
|
|
1256
|
-
emptyText: "texts.empty",
|
|
1257
|
-
disabledText: "texts.disabled",
|
|
1258
|
-
loadingText: "texts.loading",
|
|
1259
|
-
errorText: "texts.error",
|
|
1260
|
-
clearText: "texts.clear",
|
|
1261
|
-
removeText: "texts.remove",
|
|
1262
|
-
loadButtonText: "texts.loadMore",
|
|
1263
|
-
loadMoreText: "texts.loadingMore",
|
|
1264
|
-
emptyOption: "texts.emptyOption",
|
|
1265
|
-
invalidOption: "texts.invalidOption",
|
|
1266
|
-
disabledOption: "texts.disabledOption"
|
|
1267
|
-
}, Ve = (e, t) => {
|
|
1268
|
-
const n = { ...e };
|
|
1269
|
-
for (const r in t) t[r] !== void 0 && (n[r] = t[r]);
|
|
1270
|
-
return n;
|
|
1271
|
-
};
|
|
1272
|
-
function pr(e) {
|
|
1273
|
-
for (const d in e) d in bt && le(`renamed ${d}`, `The \`${d}\` prop was removed. Use \`${bt[d]}\`.`);
|
|
1274
|
-
e.value !== void 0 && !e.onChange && le("read-only value", "`value` is set without `onChange`, so the Select is read-only. Pass `onChange`, or `defaultValue` instead of `value`.");
|
|
1275
|
-
const t = Ve(Pe, e);
|
|
1276
|
-
t.texts = Ve(Pe.texts, e.texts), t.icons = Ve(Pe.icons, e.icons);
|
|
1277
|
-
const n = t.texts.emptyGroup, r = ze(Z(() => Ce(t.children, n), [t.children, n])), { selectId: s, selectRef: o, highlightStore: i, state: a, actions: l } = er(t, r), b = {}, u = {};
|
|
1278
|
-
for (const d in t) or.has(d) || ((ir.test(d) ? u : b)[d] = t[d]);
|
|
1279
|
-
const x = Yt({ ...b, attrs: u, selectId: s, selectRef: o, highlightStore: i });
|
|
1280
|
-
return /* @__PURE__ */ M(ne.Provider, { value: x, children: /* @__PURE__ */ M(ue.Provider, { value: l, children: /* @__PURE__ */ ee(fe.Provider, { value: a, children: [
|
|
1281
|
-
/* @__PURE__ */ M(Ln, {}),
|
|
1282
|
-
/* @__PURE__ */ M(Gn, {}),
|
|
1283
|
-
/* @__PURE__ */ M(Jn, {})
|
|
1284
|
-
] }) }) });
|
|
1285
|
-
}
|
|
1286
|
-
function ar() {
|
|
1287
|
-
return le("option outside", "<Option/> was rendered outside <Select>, or inside a component that <Select> cannot read. Use it as a direct child, or wrap the component with defineOption()."), null;
|
|
1288
|
-
}
|
|
1289
|
-
ar.racKind = "option";
|
|
1290
|
-
function cr() {
|
|
1291
|
-
return null;
|
|
1292
|
-
}
|
|
1293
|
-
cr.racKind = "group";
|
|
1294
|
-
export {
|
|
1295
|
-
cr as OptGroup,
|
|
1296
|
-
ar as Option,
|
|
1297
|
-
pr as Select,
|
|
1298
|
-
fr as defineOption
|
|
1299
|
-
};
|