jaguar-form 1.0.5 → 1.0.7

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 +29 -2
  2. package/dist/Cascader-iWlk7VJR.js +226 -0
  3. package/dist/Select-CoEW4UIq.js +422 -0
  4. package/dist/TreeSelect-BWksr9iW.js +350 -0
  5. package/dist/{compound-BhkceJal.js → compound-BW6G7E_-.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-B-BSf2n1.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-DpZdLaoP.js} +233 -130
  18. package/dist/{useSelection-BUBndjzo.js → lazy-tree-C9l9lzQw.js} +117 -19
  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,15 @@
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.7
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
+ Choice buttons use a transparent resting surface and a theme-tinted selected state. Select option indexing, selection membership and remote cache recency are optimized. See [1.0.7 changelog](docs/CHANGELOG-1.0.7.md).
8
+
9
+ ## 1.0.6
10
+
11
+ 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).
12
+
13
+ The 1.0.5 APIs remain available; see [1.0.5 enhancements](docs/enhancements.md).
8
14
 
9
15
  ## Installation
10
16
 
@@ -148,3 +154,24 @@ Refined default theme: 34/42/48px controls, 10px radius, cool neutral colors, le
148
154
  ```
149
155
 
150
156
  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`.
157
+
158
+
159
+ ### Segmented: pill view switch
160
+
161
+ `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.
162
+
163
+ ```tsx
164
+ <Segmented variant="pill" iconOnly value={view} onChange={setView}
165
+ options={[{value:'grid',label:'Grid view',icon:<GridIcon/>},
166
+ {value:'list',label:'List view',icon:<ListIcon/>}]} />
167
+ ```
168
+
169
+ ### Dark theme — Slate
170
+
171
+ `<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.
172
+
173
+ 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.
174
+
175
+ ### Control shell styling
176
+
177
+ 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-C9l9lzQw.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,422 @@
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-C9l9lzQw.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() ? (a.delete(e), a.set(e, n), u(n.state)) : (n && a.delete(e), 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 = n(() => new Set([...l, ...d.options].map((e) => e.value)), [l, d.options]), 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 = n(() => {
123
+ let e = /* @__PURE__ */ new Map(), t = new Set(c);
124
+ for (let n of t) {
125
+ let t = h.current.get(n);
126
+ t && e.set(n, t);
127
+ }
128
+ for (let n of g) t.has(n.value) && e.set(n.value, n);
129
+ for (let t of l) e.set(t.value, t);
130
+ if (C !== l) for (let t of C) e.set(t.value, t);
131
+ return e;
132
+ }, [
133
+ v,
134
+ l,
135
+ C,
136
+ g
137
+ ]);
138
+ return e(() => {
139
+ h.current = new Map(c.flatMap((e) => {
140
+ let t = w.get(e);
141
+ return t ? [[e, t]] : [];
142
+ }));
143
+ }, [v, w]), {
144
+ options: C,
145
+ map: w,
146
+ loading: p && a && d.loading,
147
+ error: p && a && d.error,
148
+ hasMore: p && a && d.hasMore,
149
+ more: m.more,
150
+ retry: m.retry
151
+ };
152
+ }
153
+ // src/components/select/Select.tsx
154
+ function x(e) {
155
+ return /* @__PURE__ */ _(w, {
156
+ ...e,
157
+ multiple: !1
158
+ });
159
+ }
160
+ function S(e) {
161
+ return /* @__PURE__ */ _(w, {
162
+ ...e,
163
+ multiple: !0
164
+ });
165
+ }
166
+ var C = (e) => e.value;
167
+ function w(r) {
168
+ 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, te = n(() => T === E ? T : T.concat(E), [T, E]), B = b(r.loadOptions, S, A, r.searchDebounce ?? 300, te, r.options, r), V = B.map, H = r.optionsLoading || B.loading, U = n(() => new Set(E), [E]), W = (e) => V.get(e) ?? {
169
+ value: e,
170
+ label: String(e)
171
+ }, ne = n(() => E.map(W), [E, V]), G = n(() => T.map(W), [T, V]), K = n(() => {
172
+ if (r.loadOptions || !A) return B.options;
173
+ let e = A.toLocaleLowerCase();
174
+ return B.options.filter((t) => (t.searchText ?? (typeof t.label == "string" ? t.label : String(t.value))).toLocaleLowerCase().includes(e));
175
+ }, [
176
+ B.options,
177
+ A,
178
+ r.loadOptions
179
+ ]), 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), [
180
+ B.options,
181
+ K,
182
+ r.selectAllScope
183
+ ]), X = n(() => Y.reduce((e, t) => e + Number(U.has(t)), 0), [Y, U]), Z = Y.length > 0 && X === Y.length, re = !Z && U.size + Y.length - X > (r.maxCount ?? 1e400), Q = Z ? "all" : X ? "partial" : "none";
184
+ e(() => {
185
+ S || (j(""), F(-1), N(!1));
186
+ }, [S]);
187
+ let ie = (e) => {
188
+ O || r.readOnly || e.disabled || (r.multiple ? D(p(E, [e.value], r.maxCount)) : (D([e.value]), r.needConfirm || w(!1)));
189
+ }, $ = () => D(E.filter((e) => V.get(e)?.disabled)), ae = (e) => {
190
+ V.get(e)?.disabled || D(E.filter((t) => t !== e));
191
+ }, oe = () => {
192
+ O || (S || w(!0), N(!0));
193
+ }, se = (e) => {
194
+ !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));
195
+ }, ce = (e) => {
196
+ if (e.nativeEvent.isComposing || e.keyCode === 229 || M) return;
197
+ let t = e.target;
198
+ t instanceof HTMLElement && t.matches(".rfe-search,.rfe-list,.rfe-option") && (t instanceof HTMLInputElement && [
199
+ "Home",
200
+ "End",
201
+ " "
202
+ ].includes(e.key) || ([
203
+ "ArrowDown",
204
+ "ArrowUp",
205
+ "Home",
206
+ "End"
207
+ ].includes(e.key) ? (e.preventDefault(), F(a(K.length, J, e.key, q))) : ["Enter", " "].includes(e.key) && J >= 0 && (e.preventDefault(), ie(K[J]))));
208
+ };
209
+ return /* @__PURE__ */ _(s, {
210
+ ...r,
211
+ layout: "selection",
212
+ open: S,
213
+ onOpenChange: w,
214
+ label: z,
215
+ trigger: (e, t) => /* @__PURE__ */ _("div", {
216
+ ref: t,
217
+ className: "rfe-anchor",
218
+ onKeyDown: se,
219
+ onBlur: (e) => {
220
+ !S && !e.currentTarget.contains(e.relatedTarget) && r.onBlur?.();
221
+ },
222
+ children: /* @__PURE__ */ _(c, {
223
+ ...r,
224
+ id: r.id ?? I,
225
+ disabled: r.disabled || r.loading,
226
+ floatingFilled: T.length > 0,
227
+ floatingOpen: S,
228
+ actions: /* @__PURE__ */ v(g, { children: [r.clearable !== !1 && /* @__PURE__ */ _(o, {
229
+ name: "clear",
230
+ source: r.icons?.clear,
231
+ label: y.clear,
232
+ hidden: !T.length,
233
+ disabled: k,
234
+ onClick: $
235
+ }), /* @__PURE__ */ _("button", {
236
+ type: "button",
237
+ ...e,
238
+ id: r.id ?? I,
239
+ className: "rfe-trigger-arrow",
240
+ disabled: O,
241
+ "aria-invalid": r["aria-invalid"] ?? r.status === "error",
242
+ "aria-describedby": r["aria-describedby"],
243
+ "aria-label": z,
244
+ onClick: () => w(!S),
245
+ "data-open": S,
246
+ children: /* @__PURE__ */ _(m, {
247
+ name: "dropdown",
248
+ source: r.icons?.dropdown
249
+ })
250
+ })] }),
251
+ children: /* @__PURE__ */ _("div", {
252
+ className: "rfe-value",
253
+ onClick: () => w(!S),
254
+ children: r.multiple ? /* @__PURE__ */ _(d, {
255
+ options: G,
256
+ mode: r.displayMode,
257
+ maxTagCount: r.maxTagCount,
258
+ maxTagRows: r.maxTagRows,
259
+ onRemove: ae,
260
+ onInspect: oe,
261
+ readOnly: k,
262
+ placeholder: r.placeholder
263
+ }) : /* @__PURE__ */ _("span", {
264
+ className: G.length ? "rfe-single-value" : "rfe-placeholder",
265
+ children: G[0]?.label ?? r.placeholder ?? y.choose
266
+ })
267
+ })
268
+ })
269
+ }),
270
+ children: /* @__PURE__ */ v("div", {
271
+ className: "rfe-selection-body",
272
+ onKeyDown: ce,
273
+ "data-selection-style": r.selectionStyle ?? (r.multiple ? "subtle" : "accent"),
274
+ children: [r.multiple && M ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v("button", {
275
+ type: "button",
276
+ className: "rfe-link",
277
+ onClick: () => N(!1),
278
+ children: [/* @__PURE__ */ _(m, { name: "previous" }), y.choose]
279
+ }), /* @__PURE__ */ _(u, {
280
+ options: ne,
281
+ onRemove: ae,
282
+ onClear: $,
283
+ readOnly: r.readOnly
284
+ })] }) : /* @__PURE__ */ v(g, { children: [
285
+ r.searchable !== !1 && /* @__PURE__ */ _("input", {
286
+ className: "rfe-search",
287
+ role: "combobox",
288
+ "aria-expanded": "true",
289
+ "aria-controls": K.length ? L : void 0,
290
+ "aria-activedescendant": J >= 0 ? R(J) : void 0,
291
+ "aria-autocomplete": "list",
292
+ "aria-label": y.search,
293
+ placeholder: y.search,
294
+ value: A,
295
+ onChange: (e) => {
296
+ j(e.target.value), F(-1);
297
+ }
298
+ }),
299
+ r.multiple && r.showSelectAll && !r.readOnly && /* @__PURE__ */ v("div", {
300
+ className: "rfe-toolbar",
301
+ children: [/* @__PURE__ */ v("button", {
302
+ type: "button",
303
+ className: "rfe-select-all",
304
+ role: "checkbox",
305
+ "aria-checked": Z ? !0 : X ? "mixed" : !1,
306
+ "aria-label": y.all,
307
+ title: re ? x("max", { max: r.maxCount ?? 0 }) : void 0,
308
+ disabled: !Y.length || re,
309
+ onClick: () => D(p(E, Y, r.maxCount)),
310
+ children: [/* @__PURE__ */ _("span", {
311
+ className: "rfe-option-check",
312
+ "data-checked": Q !== "none",
313
+ children: Q !== "none" && /* @__PURE__ */ _(m, { name: Q === "all" ? "check" : "minus" })
314
+ }), Z ? y.deselectAll : y.all]
315
+ }), /* @__PURE__ */ _("button", {
316
+ type: "button",
317
+ className: "rfe-link",
318
+ onClick: $,
319
+ children: y.clear
320
+ })]
321
+ }),
322
+ H && /* @__PURE__ */ v("div", {
323
+ className: "rfe-options-loading",
324
+ role: "status",
325
+ children: [/* @__PURE__ */ _(m, { name: "loading" }), y.loading]
326
+ }),
327
+ K.length ? /* @__PURE__ */ _(f, {
328
+ items: K,
329
+ getKey: C,
330
+ id: L,
331
+ role: "listbox",
332
+ label: z,
333
+ multiple: r.multiple,
334
+ tabIndex: 0,
335
+ activeIndex: J,
336
+ activeId: J >= 0 ? R(J) : void 0,
337
+ variableHeight: r.variableHeight,
338
+ render: (e, t) => /* @__PURE__ */ v("button", {
339
+ id: R(t),
340
+ type: "button",
341
+ role: "option",
342
+ tabIndex: -1,
343
+ "aria-selected": U.has(e.value),
344
+ "aria-posinset": t + 1,
345
+ "aria-setsize": K.length,
346
+ "data-active": J === t || void 0,
347
+ "data-selected": U.has(e.value) || void 0,
348
+ className: "rfe-option",
349
+ disabled: e.disabled || r.readOnly || O,
350
+ onMouseEnter: () => F(t),
351
+ onClick: () => ie(e),
352
+ children: [
353
+ r.multiple && /* @__PURE__ */ _("span", {
354
+ className: "rfe-option-check",
355
+ "data-checked": U.has(e.value),
356
+ children: U.has(e.value) && /* @__PURE__ */ _(m, { name: "check" })
357
+ }),
358
+ /* @__PURE__ */ _("span", {
359
+ className: "rfe-option-label",
360
+ children: r.renderOption ? r.renderOption(e, U.has(e.value)) : /* @__PURE__ */ v(g, { children: [
361
+ e.icon,
362
+ e.label,
363
+ e.description && /* @__PURE__ */ _("small", { children: e.description })
364
+ ] })
365
+ }),
366
+ !r.multiple && U.has(e.value) && /* @__PURE__ */ _(m, {
367
+ name: "check",
368
+ source: r.icons?.check
369
+ })
370
+ ]
371
+ })
372
+ }) : !H && !B.error && /* @__PURE__ */ v("div", {
373
+ className: "rfe-empty",
374
+ role: "status",
375
+ children: [/* @__PURE__ */ _(m, { name: "empty" }), y.empty]
376
+ }),
377
+ B.error && /* @__PURE__ */ _("button", {
378
+ type: "button",
379
+ className: "rfe-link",
380
+ onClick: () => void B.retry(),
381
+ children: y.retry
382
+ }),
383
+ B.hasMore && !B.error && /* @__PURE__ */ _("button", {
384
+ type: "button",
385
+ className: "rfe-link",
386
+ disabled: B.loading,
387
+ onClick: () => void B.more(),
388
+ children: y.next
389
+ })
390
+ ] }), (r.multiple || r.needConfirm) && /* @__PURE__ */ v("div", {
391
+ className: "rfe-footer",
392
+ children: [
393
+ /* @__PURE__ */ v("button", {
394
+ type: "button",
395
+ className: "rfe-link",
396
+ onClick: () => N(!M),
397
+ children: [
398
+ y.selected,
399
+ " ",
400
+ E.length
401
+ ]
402
+ }),
403
+ /* @__PURE__ */ _("span", { className: "rfe-spacer" }),
404
+ r.needConfirm && /* @__PURE__ */ _("button", {
405
+ type: "button",
406
+ className: "rfe-link",
407
+ onClick: () => w(!1),
408
+ children: y.cancel
409
+ }),
410
+ /* @__PURE__ */ _("button", {
411
+ className: "rfe-button",
412
+ "data-variant": "primary",
413
+ type: "button",
414
+ onClick: ee,
415
+ children: y.done
416
+ })
417
+ ]
418
+ })]
419
+ })
420
+ });
421
+ }
422
+ export { x as n, S as t };