jaguar-form 1.0.5 → 1.0.6

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.
Files changed (55) hide show
  1. package/README.md +25 -2
  2. package/dist/Cascader-ZIkXvvC3.js +226 -0
  3. package/dist/Select-BIBk_TT6.js +415 -0
  4. package/dist/TreeSelect-BQCyCCqa.js +350 -0
  5. package/dist/{compound-BhkceJal.js → compound-BX_PoTK5.js} +95 -84
  6. package/dist/compound.js +1 -1
  7. package/dist/core.js +1 -1
  8. package/dist/date-time.js +1 -1
  9. package/dist/demo-plant.svg +1 -0
  10. package/dist/form-CSfUExUT.js +599 -0
  11. package/dist/form.js +2 -2
  12. package/dist/{icons-D79FYcGF.js → icons-BwE05e0C.js} +1 -1
  13. package/dist/{image-upload-BstB2jRd.js → image-upload-D9oPG0Eh.js} +252 -183
  14. package/dist/image-upload.js +1 -1
  15. package/dist/index.js +15 -14
  16. package/dist/input.js +1 -1
  17. package/dist/{inputs-Ch4x2nwn.js → inputs-Dx3xOy9q.js} +230 -127
  18. package/dist/{useSelection-BUBndjzo.js → lazy-tree-NCX3ntYm.js} +96 -3
  19. package/dist/pickers-Bci1y8cc.js +634 -0
  20. package/dist/select.js +3 -1
  21. package/dist/{selection-9NP9MXSn.js → selection-DCIzhR5q.js} +28 -21
  22. package/dist/{slider-C2T2wII7.js → slider-AM0Egz9P.js} +1 -1
  23. package/dist/slider.js +1 -1
  24. package/dist/store-CFSQW-Fv.js +622 -0
  25. package/dist/style.css +1 -1
  26. package/dist/tree-select.js +1 -1
  27. package/dist/types/components/compound/ControlGroup.d.ts +5 -2
  28. package/dist/types/components/compound/index.d.ts +10 -1
  29. package/dist/types/components/extended-inputs.d.ts +4 -0
  30. package/dist/types/components/image-upload/ManagedImageUpload.d.ts +2 -2
  31. package/dist/types/components/image-upload/index.d.ts +3 -2
  32. package/dist/types/components/image-upload/usePreparation.d.ts +7 -0
  33. package/dist/types/components/image-upload/validation.d.ts +16 -0
  34. package/dist/types/components/inputs.d.ts +19 -4
  35. package/dist/types/components/select/Cascader.d.ts +13 -0
  36. package/dist/types/components/select/types.d.ts +6 -0
  37. package/dist/types/components/select/useRemoteOptions.d.ts +8 -1
  38. package/dist/types/components/select.d.ts +2 -0
  39. package/dist/types/config/index.d.ts +3 -0
  40. package/dist/types/entries/input.d.ts +2 -2
  41. package/dist/types/entries/select.d.ts +2 -0
  42. package/dist/types/form/index.d.ts +54 -10
  43. package/dist/types/form/store.d.ts +12 -1
  44. package/dist/types/primitives/Control.d.ts +3 -1
  45. package/dist/types/types.d.ts +1 -0
  46. package/dist/types/utils/cascader.d.ts +12 -0
  47. package/dist/types/utils/decimal.d.ts +18 -0
  48. package/dist/types/utils/remote-options.d.ts +2 -1
  49. package/dist/{useControllable-Dhp7tTjy.js → useControllable-QDX_UWRh.js} +6 -1
  50. package/package.json +1 -1
  51. package/dist/Select-DiEHlcyU.js +0 -376
  52. package/dist/TreeSelect-1jpd43zZ.js +0 -439
  53. package/dist/form-CnRp3fRw.js +0 -457
  54. package/dist/pickers-D-ymAf_p.js +0 -630
  55. package/dist/store-BvcQ7xcl.js +0 -509
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  Modern React 19 form controls and schema-driven forms with validation, value adapters, internationalization and customizable themes.
4
4
 
5
- ## 1.0.5 enhancements
5
+ ## 1.0.6
6
6
 
7
- Theme-aware interaction states, shared form submission, remote selection, exact decimal strings, tags, autocomplete, mixed images and responsive layout. See [enhancements](docs/enhancements.md) for usage and limitations.
7
+ Single-image capacity fixes, mixed image management, broader floating labels, compound child state, async defaults, container grids, decimal bounds, remote label resolution and Cascader. See the [1.0.6 usage guide](docs/release-1.0.6.md), [changelog](docs/CHANGELOG-1.0.6.md) and [release verification](docs/RELEASE.md).
8
+
9
+ The 1.0.5 APIs remain available; see [1.0.5 enhancements](docs/enhancements.md).
8
10
 
9
11
  ## Installation
10
12
 
@@ -148,3 +150,24 @@ Refined default theme: 34/42/48px controls, 10px radius, cool neutral colors, le
148
150
  ```
149
151
 
150
152
  Or use `<Input floatingLabel="Username" />`. The label moves to the top border on focus or when a value exists. Import `FloatingInput` from `jaguar-form` or `jaguar-form/input`.
153
+
154
+
155
+ ### Segmented: pill view switch
156
+
157
+ `variant="pill"` adds a rounded track and animated selected surface. `iconOnly` hides visual labels but retains accessible radio names; supply text `label` (or `ariaLabel` for icon-only custom labels). Existing default style is retained. Optional `optionWidth`, `radius`, `animated`, `block`, and `size` control geometry and motion.
158
+
159
+ ```tsx
160
+ <Segmented variant="pill" iconOnly value={view} onChange={setView}
161
+ options={[{value:'grid',label:'Grid view',icon:<GridIcon/>},
162
+ {value:'list',label:'List view',icon:<ListIcon/>}]} />
163
+ ```
164
+
165
+ ### Dark theme — Slate
166
+
167
+ `<ConfigProvider theme="dark">` uses a slate-blue palette matching dark management dashboards. `theme="system"` follows the system preference. Popup portals inherit the provider's theme and tokens. Override `colorBackground`, `colorPopup`, `colorSegmentTrack`, `colorSegmentSelected`, `colorSegmentActive`, `colorBorder` and `colorPrimary` via `tokens` as needed. Explicit light scopes reset the dark color scheme. Existing light control colors are retained.
168
+
169
+ Dark surface consistency: outlined and filled controls, compound groups, popup panels, image add tiles and both Segmented tracks share `colorBackground` (`#0f172a` by default in dark mode). `colorFilled`, `colorPopup`, `colorSegmentTrack` and `colorSegmentDefaultTrack` may be overridden explicitly. The selected segment uses `#334155`; secondary badges retain `colorSoft`. Light defaults are unchanged.
170
+
171
+ ### Control shell styling
172
+
173
+ Input, Password, NumberInput and Textarea use a single visual shell. The native editor is transparent and has no independent border or focus shadow. Style the shell via theme tokens instead of global native input rules. Host rules with higher specificity or `!important` may still override library styles.
@@ -0,0 +1,226 @@
1
+ import { useEffect as e, useId as t, useMemo as n, useRef as r, useState as i } from "react";
2
+ import { o as a, r as o, s } from "./selection-DCIzhR5q.js";
3
+ import { t as c } from "./icons-BwE05e0C.js";
4
+ import { a as l, t as u } from "./useControllable-QDX_UWRh.js";
5
+ import { n as d, r as f, t as p } from "./lazy-tree-NCX3ntYm.js";
6
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
7
+ // src/utils/cascader.ts
8
+ function _(e) {
9
+ return typeof e.label == "string" ? e.label : String(e.value);
10
+ }
11
+ function v(e, t, n = !1) {
12
+ let r = t.trim().toLocaleLowerCase(), i = [];
13
+ if (!r) return i;
14
+ let a = e.map((e) => ({
15
+ node: e,
16
+ path: [],
17
+ labels: [],
18
+ text: []
19
+ })).reverse();
20
+ for (; a.length;) {
21
+ let { node: e, path: t, labels: o, text: s } = a.pop();
22
+ if (e.disabled) continue;
23
+ let c = [...t, e.value], l = [...o, _(e)], u = [...s, e.searchText ?? _(e)];
24
+ if (e.selectable !== !1 && (n || !d(e)) && u.join(" / ").toLocaleLowerCase().includes(r) && i.push({
25
+ path: c,
26
+ labels: l
27
+ }), e.children) for (let t = e.children.length - 1; t >= 0; t--) a.push({
28
+ node: e.children[t],
29
+ path: c,
30
+ labels: l,
31
+ text: u
32
+ });
33
+ }
34
+ return i;
35
+ }
36
+ // src/components/select/Cascader.tsx
37
+ function y(y) {
38
+ let [b, x] = u(y.value, y.defaultValue ?? [], y.onChange), S = Array.isArray(b) ? b : [], [C, w] = i(!1), [T, E] = i([]), [D, O] = i(""), [k, A] = i(y.options), [j, M] = i(/* @__PURE__ */ new Map()), N = r(null), P = r(null), F = n(() => p(y.options, (e, t) => {
39
+ A(e), M(t);
40
+ }), [y.options]);
41
+ e(() => (A(y.options), M(/* @__PURE__ */ new Map()), F.dispose), [F, y.options]);
42
+ let I = l(), L = t(), R = y.id ?? L, z = !!(y.disabled || y.loading || y.readOnly), B = y["aria-label"] ?? y.floatingLabel ?? I.text.choose, V = y.displaySeparator ?? " / ", H = [k], U = k;
43
+ for (let e of T) {
44
+ let t = U.find((t) => t.value === e);
45
+ if (!t?.children?.length) break;
46
+ U = t.children, H.push(U);
47
+ }
48
+ let W = [];
49
+ U = k;
50
+ for (let e of S) {
51
+ let t = U.find((t) => t.value === e);
52
+ W.push(t ? _(t) : String(e)), U = t?.children ?? [];
53
+ }
54
+ e(() => {
55
+ if (!y.loadChildren) return;
56
+ let e = k;
57
+ for (let t = 0; t < S.length - 1; t++) {
58
+ let n = e.find((e) => e.value === S[t]);
59
+ if (!n || n.disabled) break;
60
+ if (f(n)) {
61
+ j.has(n.value) || F.load(n.value, y.loadChildren);
62
+ break;
63
+ }
64
+ e = n.children ?? [];
65
+ }
66
+ }, [
67
+ k,
68
+ S,
69
+ y.loadChildren,
70
+ F,
71
+ j
72
+ ]);
73
+ let G = (e) => {
74
+ e && z || (e ? (E(S), O("")) : (P.current = null, y.onBlur?.()), w(e));
75
+ };
76
+ e(() => {
77
+ z && (w(!1), P.current = null);
78
+ }, [z]);
79
+ let K = (e, t) => {
80
+ if (z || e.disabled) return;
81
+ let n = [...T.slice(0, t), e.value];
82
+ E(n), f(e) && y.loadChildren && F.load(e.value, y.loadChildren), (y.changeOnSelect || !d(e)) && e.selectable !== !1 && (x(n), d(e) || G(!1));
83
+ }, q = (e, t = !1) => {
84
+ let n = N.current?.querySelector(`[data-level="${e}"]`), r = t ? n?.querySelector("button[data-selected]:not(:disabled)") ?? n?.querySelector("button:not(:disabled)") : n?.querySelector("button:not(:disabled)");
85
+ return r?.focus(), !!r;
86
+ };
87
+ e(() => {
88
+ P.current !== null && q(P.current) && (P.current = null);
89
+ }, [
90
+ k,
91
+ T,
92
+ C
93
+ ]);
94
+ let J = (e) => {
95
+ if (e.nativeEvent.isComposing || !(e.target instanceof HTMLElement)) return;
96
+ let t = e.target;
97
+ if (t instanceof HTMLInputElement) {
98
+ e.key === "ArrowDown" && (e.preventDefault(), N.current?.querySelector("button.rfe-option:not(:disabled)")?.focus());
99
+ return;
100
+ }
101
+ let n = t.closest("button.rfe-option"), r = n?.closest("[data-level]");
102
+ if (!n || !r) return;
103
+ let i = [...r.querySelectorAll("button.rfe-option:not(:disabled)")], a = i.indexOf(n);
104
+ if ([
105
+ "ArrowDown",
106
+ "ArrowUp",
107
+ "Home",
108
+ "End"
109
+ ].includes(e.key)) {
110
+ e.preventDefault(), i[e.key === "Home" ? 0 : e.key === "End" ? i.length - 1 : e.key === "ArrowDown" ? Math.min(i.length - 1, a + 1) : Math.max(0, a - 1)]?.focus();
111
+ return;
112
+ }
113
+ let o = I.direction === "rtl" ? "ArrowLeft" : "ArrowRight", s = I.direction === "rtl" ? "ArrowRight" : "ArrowLeft", c = Number(r.dataset.level);
114
+ if (!D && e.key === o) {
115
+ let t = H[c]?.[Number(n.dataset.index)];
116
+ t && d(t) && (e.preventDefault(), P.current = c + 1, K(t, c));
117
+ }
118
+ !D && e.key === s && c > 0 && (e.preventDefault(), P.current = null, q(c - 1, !0));
119
+ }, Y = n(() => D.trim() ? v(k, D, !!y.changeOnSelect) : [], [
120
+ k,
121
+ D,
122
+ y.changeOnSelect
123
+ ]);
124
+ return /* @__PURE__ */ h(o, {
125
+ ...y,
126
+ layout: "selection",
127
+ open: C && !z,
128
+ onOpenChange: G,
129
+ label: B,
130
+ popupWidth: y.popupWidth ?? 360,
131
+ trigger: (e, t) => /* @__PURE__ */ h("div", {
132
+ className: "rfe-anchor",
133
+ ref: t,
134
+ onBlur: (e) => {
135
+ !C && !e.currentTarget.contains(e.relatedTarget) && y.onBlur?.();
136
+ },
137
+ children: /* @__PURE__ */ h(s, {
138
+ ...y,
139
+ id: R,
140
+ floatingFilled: S.length > 0,
141
+ floatingOpen: C,
142
+ disabled: y.disabled || y.loading,
143
+ actions: /* @__PURE__ */ g(m, { children: [y.clearable !== !1 && /* @__PURE__ */ h(a, {
144
+ name: "clear",
145
+ label: I.text.clear,
146
+ disabled: z,
147
+ hidden: !S.length,
148
+ onClick: () => x([])
149
+ }), /* @__PURE__ */ h("button", {
150
+ ...e,
151
+ id: R,
152
+ type: "button",
153
+ className: "rfe-trigger-arrow",
154
+ disabled: z,
155
+ "aria-label": B,
156
+ "aria-invalid": y["aria-invalid"] ?? y.status === "error",
157
+ "aria-describedby": y["aria-describedby"],
158
+ onClick: () => G(!C),
159
+ onKeyDown: (e) => {
160
+ e.key === "ArrowDown" && (e.preventDefault(), G(!0));
161
+ },
162
+ children: /* @__PURE__ */ h(c, { name: "dropdown" })
163
+ })] }),
164
+ children: /* @__PURE__ */ h("div", {
165
+ className: "rfe-value",
166
+ onClick: () => G(!C),
167
+ children: /* @__PURE__ */ h("span", {
168
+ className: S.length ? "rfe-single-value" : "rfe-placeholder",
169
+ children: S.length ? W.join(V) : y.placeholder ?? I.text.choose
170
+ })
171
+ })
172
+ })
173
+ }),
174
+ children: /* @__PURE__ */ g("div", {
175
+ ref: N,
176
+ className: "rfe-selection-body rfe-cascader-body",
177
+ onKeyDown: J,
178
+ children: [y.searchable && /* @__PURE__ */ h("input", {
179
+ className: "rfe-search",
180
+ placeholder: I.text.search,
181
+ "aria-label": I.text.search,
182
+ value: D,
183
+ onChange: (e) => O(e.target.value)
184
+ }), D.trim() ? /* @__PURE__ */ g("div", {
185
+ className: "rfe-list rfe-cascader-results",
186
+ role: "group",
187
+ "aria-label": B,
188
+ "data-level": 0,
189
+ children: [Y.map((e) => /* @__PURE__ */ h("button", {
190
+ type: "button",
191
+ className: "rfe-option",
192
+ onClick: () => {
193
+ z || (x(e.path), G(!1));
194
+ },
195
+ children: e.labels.join(V)
196
+ }, JSON.stringify(e.path))), !Y.length && /* @__PURE__ */ h("div", {
197
+ className: "rfe-empty",
198
+ children: I.text.empty
199
+ })]
200
+ }) : /* @__PURE__ */ h("div", {
201
+ className: "rfe-cascader-columns",
202
+ "aria-label": B,
203
+ children: H.map((e, t) => /* @__PURE__ */ h("div", {
204
+ className: "rfe-cascader-column",
205
+ "data-level": t,
206
+ role: "group",
207
+ "aria-label": `${B} ${t + 1}`,
208
+ children: e.map((e, n) => /* @__PURE__ */ g("button", {
209
+ type: "button",
210
+ className: "rfe-option",
211
+ "data-index": n,
212
+ "data-selected": T[t] === e.value || void 0,
213
+ "aria-pressed": T[t] === e.value,
214
+ disabled: z || e.disabled || j.get(e.value) === "loading",
215
+ onClick: () => K(e, t),
216
+ children: [/* @__PURE__ */ h("span", {
217
+ className: "rfe-option-label",
218
+ children: e.label
219
+ }), j.get(e.value) === "loading" ? /* @__PURE__ */ h(c, { name: "loading" }) : j.get(e.value) === "error" ? I.text.retry : d(e) ? /* @__PURE__ */ h(c, { name: I.direction === "rtl" ? "prev" : "next" }) : null]
220
+ }, e.value))
221
+ }, t))
222
+ })]
223
+ })
224
+ });
225
+ }
226
+ export { y as t };
@@ -0,0 +1,415 @@
1
+ import { useEffect as e, useId as t, useMemo as n, useRef as r, useState as i } from "react";
2
+ import { n as a, o, r as s, s as c } from "./selection-DCIzhR5q.js";
3
+ import { a as l, d as u, f as d, p as f, u as p } from "./lazy-tree-NCX3ntYm.js";
4
+ import { t as m } from "./icons-BwE05e0C.js";
5
+ import { a as h } from "./useControllable-QDX_UWRh.js";
6
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
7
+ // src/utils/remote-options.ts
8
+ function y(e, t, n, r = 0) {
9
+ let i = {
10
+ options: [],
11
+ loading: !1,
12
+ error: !1,
13
+ hasMore: !1,
14
+ page: 0
15
+ }, a = /* @__PURE__ */ new Map(), o = "", s = 0, c, l, u = (e) => {
16
+ i = {
17
+ ...i,
18
+ ...e
19
+ }, n(i);
20
+ }, d = () => {
21
+ s++, c?.abort(), c = void 0, l !== void 0 && clearTimeout(l), l = void 0;
22
+ }, f = async (n) => {
23
+ let l = ++s;
24
+ c?.abort();
25
+ let d = new AbortController();
26
+ c = d, u({
27
+ loading: !0,
28
+ error: !1
29
+ });
30
+ try {
31
+ let c = await e({
32
+ keyword: o,
33
+ page: n,
34
+ signal: d.signal
35
+ });
36
+ if (l !== s || d.signal.aborted) return;
37
+ let f = /* @__PURE__ */ new Map();
38
+ for (let e of [...n === 1 ? [] : i.options, ...c.options]) f.set(t(e), e);
39
+ u({
40
+ options: [...f.values()],
41
+ page: n,
42
+ hasMore: c.hasMore,
43
+ loading: !1
44
+ }), r > 0 && (a.delete(o), a.set(o, {
45
+ expires: Date.now() + r,
46
+ state: i
47
+ }), a.size > 32 && a.delete(a.keys().next().value));
48
+ } catch {
49
+ l === s && !d.signal.aborted && u({
50
+ error: !0,
51
+ loading: !1
52
+ });
53
+ }
54
+ };
55
+ return {
56
+ search(e, t = 0) {
57
+ d(), o = e;
58
+ let n = a.get(e);
59
+ n && n.expires > Date.now() ? u(n.state) : (u({
60
+ options: [],
61
+ page: 0,
62
+ hasMore: !1,
63
+ error: !1,
64
+ loading: !0
65
+ }), l = setTimeout(() => {
66
+ l = void 0, f(1);
67
+ }, Math.max(0, t)));
68
+ },
69
+ more() {
70
+ if (!i.loading && !i.error && i.hasMore) return f(i.page + 1);
71
+ },
72
+ retry() {
73
+ if (!i.loading && i.error) return f(i.page + 1);
74
+ },
75
+ clearCache() {
76
+ a.clear();
77
+ },
78
+ cancel: d
79
+ };
80
+ }
81
+ // src/components/select/useRemoteOptions.ts
82
+ function b(t, a, o, s, c, l, u = {}) {
83
+ let [d, f] = i({
84
+ options: [],
85
+ loading: !1,
86
+ error: !1,
87
+ hasMore: !1,
88
+ page: 0
89
+ }), p = !!t, m = n(() => y((e) => t(e), (e) => e.value, f, u.cacheTime), [
90
+ t,
91
+ u.cacheTime,
92
+ u.reloadKey
93
+ ]);
94
+ e(() => (p && a && o.length >= (u.minSearchLength ?? 0) ? m.search(o, s) : f({
95
+ options: [],
96
+ loading: !1,
97
+ error: !1,
98
+ hasMore: !1,
99
+ page: 0
100
+ }), m.cancel), [
101
+ m,
102
+ p,
103
+ a,
104
+ o,
105
+ s,
106
+ u.minSearchLength,
107
+ u.reloadKey
108
+ ]);
109
+ let h = r(/* @__PURE__ */ new Map()), [g, _] = i([]), v = JSON.stringify([...new Set(c)]), b = new Set([...l, ...d.options].map((e) => e.value)), x = [...new Set(c)].filter((e) => !b.has(e) && !h.current.has(e)), S = JSON.stringify(x);
110
+ e(() => {
111
+ if (!u.resolveOptions || !x.length) return;
112
+ let e = new AbortController();
113
+ return Promise.resolve().then(() => u.resolveOptions(x, { signal: e.signal })).then((t) => {
114
+ e.signal.aborted || _(t.filter((e) => x.includes(e.value)));
115
+ }, () => {}), () => e.abort();
116
+ }, [
117
+ u.resolveOptions,
118
+ v,
119
+ S,
120
+ u.reloadKey
121
+ ]);
122
+ let C = p ? d.options : l, w = /* @__PURE__ */ new Map();
123
+ for (let e of c) {
124
+ let t = h.current.get(e);
125
+ t && w.set(e, t);
126
+ }
127
+ for (let e of g) c.includes(e.value) && w.set(e.value, e);
128
+ for (let e of l) w.set(e.value, e);
129
+ for (let e of C) w.set(e.value, e);
130
+ return e(() => {
131
+ h.current = new Map(c.flatMap((e) => {
132
+ let t = w.get(e);
133
+ return t ? [[e, t]] : [];
134
+ }));
135
+ }, [
136
+ c,
137
+ l,
138
+ C,
139
+ g
140
+ ]), {
141
+ options: C,
142
+ map: w,
143
+ loading: p && a && d.loading,
144
+ error: p && a && d.error,
145
+ hasMore: p && a && d.hasMore,
146
+ more: m.more,
147
+ retry: m.retry
148
+ };
149
+ }
150
+ // src/components/select/Select.tsx
151
+ function x(e) {
152
+ return /* @__PURE__ */ _(w, {
153
+ ...e,
154
+ multiple: !1
155
+ });
156
+ }
157
+ function S(e) {
158
+ return /* @__PURE__ */ _(w, {
159
+ ...e,
160
+ multiple: !0
161
+ });
162
+ }
163
+ var C = (e) => e.value;
164
+ function w(r) {
165
+ let { text: y, t: x } = h(), { open: S, changeOpen: w, committed: T, selected: E, update: D, confirm: ee, blocked: O, triggerReadOnly: k } = l(r), [A, j] = i(""), [M, N] = i(!1), [P, F] = i(-1), I = t(), L = `${I}-options`, R = (e) => `${I}-option-${e}`, z = r["aria-label"] ?? r.floatingLabel ?? y.choose, B = b(r.loadOptions, S, A, r.searchDebounce ?? 300, T.concat(E), r.options, r), V = B.map, H = r.optionsLoading || B.loading, U = n(() => new Set(E), [E]), W = (e) => V.get(e) ?? {
166
+ value: e,
167
+ label: String(e)
168
+ }, te = n(() => E.map(W), [E, V]), G = n(() => T.map(W), [T, V]), K = n(() => B.options.filter((e) => (e.searchText ?? (typeof e.label == "string" ? e.label : String(e.value))).toLocaleLowerCase().includes(A.toLocaleLowerCase()) || !!r.loadOptions), [
169
+ B.options,
170
+ A,
171
+ r.loadOptions
172
+ ]), q = (e) => !K[e]?.disabled, J = P >= 0 && P < K.length && q(P) ? P : a(K.length, -1, "Home", q), Y = n(() => (r.selectAllScope === "all" ? B.options : K).filter((e) => !e.disabled).map((e) => e.value), [
173
+ B.options,
174
+ K,
175
+ r.selectAllScope
176
+ ]), X = Y.filter((e) => U.has(e)).length, Z = Y.length > 0 && X === Y.length, ne = !Z && U.size + Y.length - X > (r.maxCount ?? 1e400), Q = Z ? "all" : X ? "partial" : "none";
177
+ e(() => {
178
+ S || (j(""), F(-1), N(!1));
179
+ }, [S]);
180
+ let re = (e) => {
181
+ O || r.readOnly || e.disabled || (r.multiple ? D(p(E, [e.value], r.maxCount)) : (D([e.value]), r.needConfirm || w(!1)));
182
+ }, $ = () => D(E.filter((e) => V.get(e)?.disabled)), ie = (e) => {
183
+ V.get(e)?.disabled || D(E.filter((t) => t !== e));
184
+ }, ae = () => {
185
+ O || (S || w(!0), N(!0));
186
+ }, oe = (e) => {
187
+ !e.nativeEvent.isComposing && e.target instanceof HTMLElement && e.target.matches(".rfe-trigger-arrow") && ["ArrowDown", "ArrowUp"].includes(e.key) && (e.preventDefault(), F(a(K.length, -1, e.key, q)), w(!0));
188
+ }, se = (e) => {
189
+ if (e.nativeEvent.isComposing || e.keyCode === 229 || M) return;
190
+ let t = e.target;
191
+ t instanceof HTMLElement && t.matches(".rfe-search,.rfe-list,.rfe-option") && (t instanceof HTMLInputElement && [
192
+ "Home",
193
+ "End",
194
+ " "
195
+ ].includes(e.key) || ([
196
+ "ArrowDown",
197
+ "ArrowUp",
198
+ "Home",
199
+ "End"
200
+ ].includes(e.key) ? (e.preventDefault(), F(a(K.length, J, e.key, q))) : ["Enter", " "].includes(e.key) && J >= 0 && (e.preventDefault(), re(K[J]))));
201
+ };
202
+ return /* @__PURE__ */ _(s, {
203
+ ...r,
204
+ layout: "selection",
205
+ open: S,
206
+ onOpenChange: w,
207
+ label: z,
208
+ trigger: (e, t) => /* @__PURE__ */ _("div", {
209
+ ref: t,
210
+ className: "rfe-anchor",
211
+ onKeyDown: oe,
212
+ onBlur: (e) => {
213
+ !S && !e.currentTarget.contains(e.relatedTarget) && r.onBlur?.();
214
+ },
215
+ children: /* @__PURE__ */ _(c, {
216
+ ...r,
217
+ id: r.id ?? I,
218
+ disabled: r.disabled || r.loading,
219
+ floatingFilled: T.length > 0,
220
+ floatingOpen: S,
221
+ actions: /* @__PURE__ */ v(g, { children: [r.clearable !== !1 && /* @__PURE__ */ _(o, {
222
+ name: "clear",
223
+ source: r.icons?.clear,
224
+ label: y.clear,
225
+ hidden: !T.length,
226
+ disabled: k,
227
+ onClick: $
228
+ }), /* @__PURE__ */ _("button", {
229
+ type: "button",
230
+ ...e,
231
+ id: r.id ?? I,
232
+ className: "rfe-trigger-arrow",
233
+ disabled: O,
234
+ "aria-invalid": r["aria-invalid"] ?? r.status === "error",
235
+ "aria-describedby": r["aria-describedby"],
236
+ "aria-label": z,
237
+ onClick: () => w(!S),
238
+ "data-open": S,
239
+ children: /* @__PURE__ */ _(m, {
240
+ name: "dropdown",
241
+ source: r.icons?.dropdown
242
+ })
243
+ })] }),
244
+ children: /* @__PURE__ */ _("div", {
245
+ className: "rfe-value",
246
+ onClick: () => w(!S),
247
+ children: r.multiple ? /* @__PURE__ */ _(d, {
248
+ options: G,
249
+ mode: r.displayMode,
250
+ maxTagCount: r.maxTagCount,
251
+ maxTagRows: r.maxTagRows,
252
+ onRemove: ie,
253
+ onInspect: ae,
254
+ readOnly: k,
255
+ placeholder: r.placeholder
256
+ }) : /* @__PURE__ */ _("span", {
257
+ className: G.length ? "rfe-single-value" : "rfe-placeholder",
258
+ children: G[0]?.label ?? r.placeholder ?? y.choose
259
+ })
260
+ })
261
+ })
262
+ }),
263
+ children: /* @__PURE__ */ v("div", {
264
+ className: "rfe-selection-body",
265
+ onKeyDown: se,
266
+ "data-selection-style": r.selectionStyle ?? (r.multiple ? "subtle" : "accent"),
267
+ children: [r.multiple && M ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v("button", {
268
+ type: "button",
269
+ className: "rfe-link",
270
+ onClick: () => N(!1),
271
+ children: [/* @__PURE__ */ _(m, { name: "previous" }), y.choose]
272
+ }), /* @__PURE__ */ _(u, {
273
+ options: te,
274
+ onRemove: ie,
275
+ onClear: $,
276
+ readOnly: r.readOnly
277
+ })] }) : /* @__PURE__ */ v(g, { children: [
278
+ r.searchable !== !1 && /* @__PURE__ */ _("input", {
279
+ className: "rfe-search",
280
+ role: "combobox",
281
+ "aria-expanded": "true",
282
+ "aria-controls": K.length ? L : void 0,
283
+ "aria-activedescendant": J >= 0 ? R(J) : void 0,
284
+ "aria-autocomplete": "list",
285
+ "aria-label": y.search,
286
+ placeholder: y.search,
287
+ value: A,
288
+ onChange: (e) => {
289
+ j(e.target.value), F(-1);
290
+ }
291
+ }),
292
+ r.multiple && r.showSelectAll && !r.readOnly && /* @__PURE__ */ v("div", {
293
+ className: "rfe-toolbar",
294
+ children: [/* @__PURE__ */ v("button", {
295
+ type: "button",
296
+ className: "rfe-select-all",
297
+ role: "checkbox",
298
+ "aria-checked": Z ? !0 : X ? "mixed" : !1,
299
+ "aria-label": y.all,
300
+ title: ne ? x("max", { max: r.maxCount ?? 0 }) : void 0,
301
+ disabled: !Y.length || ne,
302
+ onClick: () => D(p(E, Y, r.maxCount)),
303
+ children: [/* @__PURE__ */ _("span", {
304
+ className: "rfe-option-check",
305
+ "data-checked": Q !== "none",
306
+ children: Q !== "none" && /* @__PURE__ */ _(m, { name: Q === "all" ? "check" : "minus" })
307
+ }), Z ? y.deselectAll : y.all]
308
+ }), /* @__PURE__ */ _("button", {
309
+ type: "button",
310
+ className: "rfe-link",
311
+ onClick: $,
312
+ children: y.clear
313
+ })]
314
+ }),
315
+ H && /* @__PURE__ */ v("div", {
316
+ className: "rfe-options-loading",
317
+ role: "status",
318
+ children: [/* @__PURE__ */ _(m, { name: "loading" }), y.loading]
319
+ }),
320
+ K.length ? /* @__PURE__ */ _(f, {
321
+ items: K,
322
+ getKey: C,
323
+ id: L,
324
+ role: "listbox",
325
+ label: z,
326
+ multiple: r.multiple,
327
+ tabIndex: 0,
328
+ activeIndex: J,
329
+ activeId: J >= 0 ? R(J) : void 0,
330
+ variableHeight: r.variableHeight,
331
+ render: (e, t) => /* @__PURE__ */ v("button", {
332
+ id: R(t),
333
+ type: "button",
334
+ role: "option",
335
+ tabIndex: -1,
336
+ "aria-selected": U.has(e.value),
337
+ "aria-posinset": t + 1,
338
+ "aria-setsize": K.length,
339
+ "data-active": J === t || void 0,
340
+ "data-selected": U.has(e.value) || void 0,
341
+ className: "rfe-option",
342
+ disabled: e.disabled || r.readOnly || O,
343
+ onMouseEnter: () => F(t),
344
+ onClick: () => re(e),
345
+ children: [
346
+ r.multiple && /* @__PURE__ */ _("span", {
347
+ className: "rfe-option-check",
348
+ "data-checked": U.has(e.value),
349
+ children: U.has(e.value) && /* @__PURE__ */ _(m, { name: "check" })
350
+ }),
351
+ /* @__PURE__ */ _("span", {
352
+ className: "rfe-option-label",
353
+ children: r.renderOption ? r.renderOption(e, U.has(e.value)) : /* @__PURE__ */ v(g, { children: [
354
+ e.icon,
355
+ e.label,
356
+ e.description && /* @__PURE__ */ _("small", { children: e.description })
357
+ ] })
358
+ }),
359
+ !r.multiple && U.has(e.value) && /* @__PURE__ */ _(m, {
360
+ name: "check",
361
+ source: r.icons?.check
362
+ })
363
+ ]
364
+ })
365
+ }) : !H && !B.error && /* @__PURE__ */ v("div", {
366
+ className: "rfe-empty",
367
+ role: "status",
368
+ children: [/* @__PURE__ */ _(m, { name: "empty" }), y.empty]
369
+ }),
370
+ B.error && /* @__PURE__ */ _("button", {
371
+ type: "button",
372
+ className: "rfe-link",
373
+ onClick: () => void B.retry(),
374
+ children: y.retry
375
+ }),
376
+ B.hasMore && !B.error && /* @__PURE__ */ _("button", {
377
+ type: "button",
378
+ className: "rfe-link",
379
+ disabled: B.loading,
380
+ onClick: () => void B.more(),
381
+ children: y.next
382
+ })
383
+ ] }), (r.multiple || r.needConfirm) && /* @__PURE__ */ v("div", {
384
+ className: "rfe-footer",
385
+ children: [
386
+ /* @__PURE__ */ v("button", {
387
+ type: "button",
388
+ className: "rfe-link",
389
+ onClick: () => N(!M),
390
+ children: [
391
+ y.selected,
392
+ " ",
393
+ E.length
394
+ ]
395
+ }),
396
+ /* @__PURE__ */ _("span", { className: "rfe-spacer" }),
397
+ r.needConfirm && /* @__PURE__ */ _("button", {
398
+ type: "button",
399
+ className: "rfe-link",
400
+ onClick: () => w(!1),
401
+ children: y.cancel
402
+ }),
403
+ /* @__PURE__ */ _("button", {
404
+ className: "rfe-button",
405
+ "data-variant": "primary",
406
+ type: "button",
407
+ onClick: ee,
408
+ children: y.done
409
+ })
410
+ ]
411
+ })]
412
+ })
413
+ });
414
+ }
415
+ export { x as n, S as t };