jaguar-form 1.0.6 → 1.0.8
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/README.md +8 -0
- package/dist/{Cascader-ZIkXvvC3.js → Cascader-COGUcdDS.js} +4 -4
- package/dist/{Select-BIBk_TT6.js → Select-BxwT7MHH.js} +118 -107
- package/dist/{TreeSelect-BQCyCCqa.js → TreeSelect-W5sgU5nW.js} +4 -4
- package/dist/{compound-BX_PoTK5.js → compound-nXxRSVJu.js} +27 -27
- package/dist/compound.js +1 -1
- package/dist/core.js +1 -1
- package/dist/date-time.js +1 -1
- package/dist/{form-CSfUExUT.js → form-D6O5PqrZ.js} +62 -49
- package/dist/form.js +3 -3
- package/dist/{icons-BwE05e0C.js → icons-B1dOXz-r.js} +1 -1
- package/dist/{image-upload-D9oPG0Eh.js → image-upload-BFVs81x3.js} +46 -42
- package/dist/image-upload.js +1 -1
- package/dist/index.js +15 -15
- package/dist/input.js +1 -1
- package/dist/inputs-w_es2t_C.js +862 -0
- package/dist/{lazy-tree-NCX3ntYm.js → lazy-tree-DNvNf_Yv.js} +51 -43
- package/dist/{pickers-Bci1y8cc.js → pickers-5zLmSrsp.js} +3 -3
- package/dist/select.js +2 -2
- package/dist/selection-CA_66JX9.js +223 -0
- package/dist/{slider-AM0Egz9P.js → slider-Bhd1Z4LP.js} +35 -35
- package/dist/slider.js +1 -1
- package/dist/{store-CFSQW-Fv.js → store-C9eBd8Y7.js} +205 -194
- package/dist/style.css +1 -1
- package/dist/tree-select.js +1 -1
- package/dist/types/components/extended-inputs.d.ts +4 -1
- package/dist/types/components/image-upload/index.d.ts +1 -1
- package/dist/types/components/inputs.d.ts +28 -8
- package/dist/types/config/index.d.ts +32 -1
- package/dist/types/entries/input.d.ts +2 -2
- package/dist/types/form/index.d.ts +3 -0
- package/dist/types/form/store.d.ts +1 -0
- package/dist/types/primitives/Control.d.ts +7 -2
- package/dist/{useControllable-QDX_UWRh.js → useControllable-Dt38Jg9E.js} +54 -21
- package/package.json +1 -1
- package/dist/inputs-Dx3xOy9q.js +0 -718
- package/dist/selection-DCIzhR5q.js +0 -197
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
import { useEffect as e, useId as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
|
+
import { n as a, o, r as s, s as c } from "./selection-CA_66JX9.js";
|
|
3
|
+
import { c as l, l as u, s as d, t as f, u as p } from "./useControllable-Dt38Jg9E.js";
|
|
4
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
import { t as _ } from "./icons-B1dOXz-r.js";
|
|
6
|
+
// src/utils/decimal.ts
|
|
7
|
+
function v(e, t, n = "half-up") {
|
|
8
|
+
if (!/^-?\d+(\.\d*)?$/.test(e)) throw TypeError("Invalid decimal");
|
|
9
|
+
if (!Number.isInteger(t) || t < 0 || t > 100) throw RangeError("Invalid decimal scale");
|
|
10
|
+
let r = e.startsWith("-"), [i, a = ""] = e.replace(/^-/, "").split("."), o = BigInt(i + a.slice(0, t).padEnd(t, "0"));
|
|
11
|
+
n === "half-up" && Number(a[t] ?? 0) >= 5 && o++;
|
|
12
|
+
let s = o.toString().padStart(t + 1, "0");
|
|
13
|
+
return `${r && o !== 0n ? "-" : ""}${t ? `${s.slice(0, -t)}.${s.slice(-t)}` : s}`;
|
|
14
|
+
}
|
|
15
|
+
function y(e) {
|
|
16
|
+
return /^-?(?:\d+\.?\d*|\.\d+)$/.test(e) ? e.replace(/^(-?)\./, "$10.").replace(/\.$/, "") : null;
|
|
17
|
+
}
|
|
18
|
+
function b(e, t) {
|
|
19
|
+
let n = y(e);
|
|
20
|
+
if (n === null) throw TypeError("Invalid decimal");
|
|
21
|
+
let r = n.startsWith("-"), [i, a = ""] = n.replace(/^-/, "").split("."), o = BigInt(i + a.padEnd(t, "0"));
|
|
22
|
+
return r ? -o : o;
|
|
23
|
+
}
|
|
24
|
+
function x(e) {
|
|
25
|
+
return e.split(".")[1]?.length ?? 0;
|
|
26
|
+
}
|
|
27
|
+
function S(e, t) {
|
|
28
|
+
let n = Math.max(x(e), x(t)), r = b(e, n), i = b(t, n);
|
|
29
|
+
return r < i ? -1 : +(r > i);
|
|
30
|
+
}
|
|
31
|
+
function C(e, t, n = 1) {
|
|
32
|
+
let r = Math.max(x(e), x(t)), i = b(e, r) + BigInt(n) * b(t, r), a = (i < 0n ? -i : i).toString().padStart(r + 1, "0");
|
|
33
|
+
return `${i < 0n ? "-" : ""}${r ? a.slice(0, -r) + "." + a.slice(-r) : a}`;
|
|
34
|
+
}
|
|
35
|
+
function w(e, t, n) {
|
|
36
|
+
return t !== void 0 && S(e, t) < 0 ? t : n !== void 0 && S(e, n) > 0 ? n : e;
|
|
37
|
+
}
|
|
38
|
+
function T(e) {
|
|
39
|
+
let t = e.min === void 0 ? void 0 : y(e.min) ?? void 0, n = e.max === void 0 ? void 0 : y(e.max) ?? void 0;
|
|
40
|
+
return e.allowNegative === !1 && (t === void 0 || S(t, "0") < 0) && (t = "0"), t !== void 0 && n !== void 0 && S(n, t) < 0 && (n = t), {
|
|
41
|
+
min: t,
|
|
42
|
+
max: n
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function E(e, t = {}) {
|
|
46
|
+
let n = y(e);
|
|
47
|
+
if (n === null) return null;
|
|
48
|
+
let r = t.precision === void 0 || !Number.isFinite(t.precision) ? void 0 : Math.max(0, Math.min(100, Math.trunc(t.precision))), { min: i, max: a } = T(t);
|
|
49
|
+
return w(r === void 0 ? n : v(n, r, t.roundingMode), i, a);
|
|
50
|
+
}
|
|
51
|
+
function D(e, t, n = {}) {
|
|
52
|
+
let r = y(n.step ?? "1"), i = r !== null && S(r, "0") > 0 ? r : "1";
|
|
53
|
+
return E(C(y(e ?? "") ?? "0", i, t), n);
|
|
54
|
+
}
|
|
55
|
+
// src/components/extended-inputs.tsx
|
|
56
|
+
function O(e) {
|
|
57
|
+
let n = d().components?.NumberInput, r = {
|
|
58
|
+
controls: n?.controls,
|
|
59
|
+
size: n?.size,
|
|
60
|
+
variant: n?.variant,
|
|
61
|
+
clearable: n?.clearable,
|
|
62
|
+
pressRepeat: n?.pressRepeat,
|
|
63
|
+
repeatDelay: n?.repeatDelay,
|
|
64
|
+
repeatInterval: n?.repeatInterval,
|
|
65
|
+
...e
|
|
66
|
+
}, [a, s] = f(r.value, r.defaultValue ?? null, r.onChange), [u, p] = i(""), [_, v] = i(!1), b = l(), x = !!(r.disabled || r.readOnly || r.loading), C = t(), w = r.id ?? C, O = (e) => y(r.parser?.(e) ?? e), k = (e) => {
|
|
67
|
+
let t = O(e);
|
|
68
|
+
t === null ? r.allowEmpty !== !1 && s(null) : s(E(t, r));
|
|
69
|
+
}, A = T(r), j = r.pressRepeat ? {
|
|
70
|
+
delay: r.repeatDelay,
|
|
71
|
+
interval: r.repeatInterval
|
|
72
|
+
} : !1, M = (e) => {
|
|
73
|
+
if (x) return;
|
|
74
|
+
let t = D(_ ? O(u) ?? a : a, e, r);
|
|
75
|
+
p(t), s(t);
|
|
76
|
+
}, N = (e) => {
|
|
77
|
+
let t = y(a ?? ""), n = e === 1 ? A.max : A.min;
|
|
78
|
+
return t !== null && n !== void 0 && (e === 1 ? S(t, n) >= 0 : S(t, n) <= 0);
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ h(c, {
|
|
81
|
+
...r,
|
|
82
|
+
id: w,
|
|
83
|
+
floatingFilled: a !== null || _ && !!u,
|
|
84
|
+
disabled: r.disabled || r.loading,
|
|
85
|
+
actions: /* @__PURE__ */ g(m, { children: [r.clearable && /* @__PURE__ */ h(o, {
|
|
86
|
+
name: "clear",
|
|
87
|
+
label: b.t("clear"),
|
|
88
|
+
disabled: x || r.allowEmpty === !1,
|
|
89
|
+
hidden: a === null && !u,
|
|
90
|
+
onClick: () => {
|
|
91
|
+
p(""), s(null);
|
|
92
|
+
}
|
|
93
|
+
}), r.controls && r.controls !== "none" && /* @__PURE__ */ g("span", {
|
|
94
|
+
className: "rfe-step",
|
|
95
|
+
"data-controls": r.controls,
|
|
96
|
+
children: [/* @__PURE__ */ h(o, {
|
|
97
|
+
name: "minus",
|
|
98
|
+
label: b.t("decrease"),
|
|
99
|
+
disabled: x || N(-1),
|
|
100
|
+
repeat: j,
|
|
101
|
+
onClick: () => M(-1)
|
|
102
|
+
}), /* @__PURE__ */ h(o, {
|
|
103
|
+
name: "plus",
|
|
104
|
+
label: b.t("increase"),
|
|
105
|
+
disabled: x || N(1),
|
|
106
|
+
repeat: j,
|
|
107
|
+
onClick: () => M(1)
|
|
108
|
+
})]
|
|
109
|
+
})] }),
|
|
110
|
+
children: /* @__PURE__ */ h("input", {
|
|
111
|
+
id: w,
|
|
112
|
+
name: r.name,
|
|
113
|
+
className: "rfe-input",
|
|
114
|
+
inputMode: "decimal",
|
|
115
|
+
value: _ ? u : a === null ? "" : r.formatter?.(a) ?? a,
|
|
116
|
+
onFocus: () => {
|
|
117
|
+
p(a ?? ""), v(!0);
|
|
118
|
+
},
|
|
119
|
+
onChange: (e) => {
|
|
120
|
+
if (x) return;
|
|
121
|
+
let t = e.target.value, n = r.parser?.(t) ?? t;
|
|
122
|
+
if (!(!/^-?\d*(\.\d*)?$/.test(n) || r.allowNegative === !1 && n.startsWith("-")) && (p(t), !r.commitOnBlur)) {
|
|
123
|
+
let e = y(n);
|
|
124
|
+
(e !== null || r.allowEmpty !== !1) && s(e);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
onBlur: () => {
|
|
128
|
+
x || k(u), v(!1), p(""), r.onBlur?.();
|
|
129
|
+
},
|
|
130
|
+
onKeyDown: (e) => {
|
|
131
|
+
x || e.nativeEvent.isComposing || (e.key === "ArrowUp" || e.key === "ArrowDown" ? (e.preventDefault(), M(e.key === "ArrowUp" ? 1 : -1)) : e.key === "Enter" && e.currentTarget.blur());
|
|
132
|
+
},
|
|
133
|
+
placeholder: r.placeholder,
|
|
134
|
+
disabled: r.disabled || r.loading,
|
|
135
|
+
readOnly: r.readOnly,
|
|
136
|
+
"aria-label": r["aria-label"] ?? r.floatingLabel,
|
|
137
|
+
"aria-invalid": r.status === "error" || r["aria-invalid"],
|
|
138
|
+
"aria-describedby": r["aria-describedby"]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function k(e) {
|
|
143
|
+
let [t, n] = f(e.value, e.defaultValue ?? [], e.onChange), [r, a] = i(""), s = l(), u = !!(e.disabled || e.readOnly || e.loading), d = t.length >= (e.maxCount ?? 1e400), m = e.separators ?? [
|
|
144
|
+
",",
|
|
145
|
+
";",
|
|
146
|
+
"\n"
|
|
147
|
+
], _ = (r) => {
|
|
148
|
+
if (u) return;
|
|
149
|
+
let i = m.reduce((e, t) => t ? e.flatMap((e) => e.split(t)) : e, [r]), o = [...t];
|
|
150
|
+
for (let t of i) {
|
|
151
|
+
let n = t.trim();
|
|
152
|
+
n && o.length < (e.maxCount ?? 1e400) && (e.allowDuplicates || !o.includes(n)) && o.push(n);
|
|
153
|
+
}
|
|
154
|
+
n(o), a("");
|
|
155
|
+
};
|
|
156
|
+
return /* @__PURE__ */ g(c, {
|
|
157
|
+
...e,
|
|
158
|
+
disabled: e.disabled || e.loading,
|
|
159
|
+
className: p("rfe-tags-control", e.className),
|
|
160
|
+
children: [t.map((e, r) => /* @__PURE__ */ g("span", {
|
|
161
|
+
className: "rfe-tag",
|
|
162
|
+
children: [/* @__PURE__ */ h("span", {
|
|
163
|
+
className: "rfe-tag-label",
|
|
164
|
+
children: e
|
|
165
|
+
}), !u && /* @__PURE__ */ h(o, {
|
|
166
|
+
name: "clear",
|
|
167
|
+
label: `${s.t("remove")} ${e}`,
|
|
168
|
+
onClick: () => n(t.filter((e, t) => t !== r))
|
|
169
|
+
})]
|
|
170
|
+
}, `${e}-${r}`)), /* @__PURE__ */ h("input", {
|
|
171
|
+
id: e.id,
|
|
172
|
+
name: e.name,
|
|
173
|
+
className: "rfe-input",
|
|
174
|
+
value: r,
|
|
175
|
+
placeholder: d ? void 0 : e.placeholder,
|
|
176
|
+
disabled: e.disabled || e.loading,
|
|
177
|
+
readOnly: e.readOnly || d,
|
|
178
|
+
onChange: (e) => a(e.target.value),
|
|
179
|
+
onKeyDown: (e) => {
|
|
180
|
+
u || e.nativeEvent.isComposing || (e.key === "Enter" || m.includes(e.key) ? (e.preventDefault(), _(r)) : e.key === "Backspace" && !r && t.length && (e.preventDefault(), n(t.slice(0, -1))));
|
|
181
|
+
},
|
|
182
|
+
onPaste: (e) => {
|
|
183
|
+
let t = e.clipboardData.getData("text");
|
|
184
|
+
!u && m.some((e) => e && t.includes(e)) && (e.preventDefault(), _(r + t));
|
|
185
|
+
},
|
|
186
|
+
onBlur: () => {
|
|
187
|
+
r && _(r), e.onBlur?.();
|
|
188
|
+
},
|
|
189
|
+
"aria-label": e["aria-label"],
|
|
190
|
+
"aria-invalid": e.status === "error" || e["aria-invalid"],
|
|
191
|
+
"aria-describedby": e["aria-describedby"]
|
|
192
|
+
})]
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function A(e) {
|
|
196
|
+
let [n, r] = f(e.value, e.defaultValue ?? "", e.onChange), [o, u] = i(!1), [d, p] = i(-1), m = t(), g = l(), _ = !!(e.disabled || e.readOnly || e.loading), v = e.options.filter((t) => e.filterOption ? e.filterOption(t, n) : (t.searchText ?? (typeof t.label == "string" ? t.label : t.value)).toLocaleLowerCase().includes(n.toLocaleLowerCase())), y = (t) => {
|
|
197
|
+
_ || t.disabled || (r(t.value), e.onSelect?.(t), u(!1), p(-1));
|
|
198
|
+
}, b = o && !_ && v.length > 0;
|
|
199
|
+
return /* @__PURE__ */ h(s, {
|
|
200
|
+
open: b,
|
|
201
|
+
onOpenChange: u,
|
|
202
|
+
popupMode: "popover",
|
|
203
|
+
popupWidth: e.popupWidth,
|
|
204
|
+
layout: "selection",
|
|
205
|
+
initialFocus: -1,
|
|
206
|
+
trigger: (t, i) => /* @__PURE__ */ h("div", {
|
|
207
|
+
className: "rfe-anchor",
|
|
208
|
+
ref: i,
|
|
209
|
+
children: /* @__PURE__ */ h(c, {
|
|
210
|
+
...e,
|
|
211
|
+
disabled: e.disabled || e.loading,
|
|
212
|
+
children: /* @__PURE__ */ h("input", {
|
|
213
|
+
...t,
|
|
214
|
+
id: e.id,
|
|
215
|
+
name: e.name,
|
|
216
|
+
className: "rfe-input",
|
|
217
|
+
role: "combobox",
|
|
218
|
+
"aria-autocomplete": "list",
|
|
219
|
+
"aria-expanded": b,
|
|
220
|
+
"aria-controls": b ? `${m}-list` : void 0,
|
|
221
|
+
"aria-activedescendant": b && d >= 0 ? `${m}-${d}` : void 0,
|
|
222
|
+
value: n,
|
|
223
|
+
disabled: e.disabled || e.loading,
|
|
224
|
+
readOnly: e.readOnly,
|
|
225
|
+
placeholder: e.placeholder,
|
|
226
|
+
"aria-label": e["aria-label"] ?? g.t("search"),
|
|
227
|
+
"aria-invalid": e.status === "error" || e["aria-invalid"],
|
|
228
|
+
"aria-describedby": e["aria-describedby"],
|
|
229
|
+
onFocus: () => {
|
|
230
|
+
_ || p(-1);
|
|
231
|
+
},
|
|
232
|
+
onBlur: () => {
|
|
233
|
+
u(!1), e.onBlur?.();
|
|
234
|
+
},
|
|
235
|
+
onChange: (e) => {
|
|
236
|
+
r(e.target.value), p(-1), u(!0);
|
|
237
|
+
},
|
|
238
|
+
onKeyDown: (e) => {
|
|
239
|
+
_ || e.nativeEvent.isComposing || (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), u(!0), p(a(v.length, d, e.key, (e) => !v[e]?.disabled))) : e.key === "Enter" && b && v[d] ? (e.preventDefault(), y(v[d])) : e.key === "Escape" && u(!1));
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
244
|
+
children: /* @__PURE__ */ h("div", {
|
|
245
|
+
className: "rfe-list",
|
|
246
|
+
role: "listbox",
|
|
247
|
+
id: `${m}-list`,
|
|
248
|
+
"aria-label": g.t("choose"),
|
|
249
|
+
style: {
|
|
250
|
+
overflowY: "auto",
|
|
251
|
+
maxHeight: 216
|
|
252
|
+
},
|
|
253
|
+
children: v.map((e, t) => /* @__PURE__ */ h("button", {
|
|
254
|
+
type: "button",
|
|
255
|
+
role: "option",
|
|
256
|
+
id: `${m}-${t}`,
|
|
257
|
+
tabIndex: -1,
|
|
258
|
+
"aria-selected": t === d,
|
|
259
|
+
"data-active": t === d || void 0,
|
|
260
|
+
disabled: e.disabled,
|
|
261
|
+
className: "rfe-option",
|
|
262
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
263
|
+
onClick: () => y(e),
|
|
264
|
+
children: e.label
|
|
265
|
+
}, e.value))
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// src/utils/number.ts
|
|
270
|
+
var j = /* @__PURE__ */ new Map();
|
|
271
|
+
function M(e) {
|
|
272
|
+
let t = j.get(e);
|
|
273
|
+
if (t) return t;
|
|
274
|
+
let n = new Intl.NumberFormat(e).formatToParts(-12345.6), r = new Intl.NumberFormat(e, { useGrouping: !1 }), i = {
|
|
275
|
+
decimal: n.find((e) => e.type === "decimal")?.value ?? ".",
|
|
276
|
+
group: n.find((e) => e.type === "group")?.value ?? ",",
|
|
277
|
+
minus: n.find((e) => e.type === "minusSign")?.value ?? "-",
|
|
278
|
+
digits: Array.from({ length: 10 }, (e, t) => r.format(t))
|
|
279
|
+
};
|
|
280
|
+
return j.size >= 32 && j.clear(), j.set(e, i), i;
|
|
281
|
+
}
|
|
282
|
+
function N(e, t, n = !1) {
|
|
283
|
+
let { decimal: r, group: i, minus: a, digits: o } = M(t), s = e.replace(/[\u061c\u200e\u200f]/g, "");
|
|
284
|
+
for (let e = 0; e < o.length; e++) s = s.split(o[e]).join(String(e));
|
|
285
|
+
return s = s.split(a).join("-"), n && i !== r && (s = s.split(i).join("")), r !== "." && (s = s.split(r).join(".")), /^-?\d*(\.\d*)?$/.test(s) ? s : void 0;
|
|
286
|
+
}
|
|
287
|
+
function P(e, t, n, r = !1) {
|
|
288
|
+
return e === null || !Number.isFinite(e) ? "" : new Intl.NumberFormat(t, {
|
|
289
|
+
useGrouping: r,
|
|
290
|
+
minimumFractionDigits: n ?? 0,
|
|
291
|
+
maximumFractionDigits: n ?? 20
|
|
292
|
+
}).format(e);
|
|
293
|
+
}
|
|
294
|
+
// src/components/inputs.tsx
|
|
295
|
+
function F(e) {
|
|
296
|
+
let n = {
|
|
297
|
+
...d().components?.Input,
|
|
298
|
+
...e
|
|
299
|
+
}, [r, i] = f(n.value, n.defaultValue ?? "", n.onChange), a = u(), s = t(), l = !!n.floatingLabel, _ = n.id ?? (l ? s : void 0), v = /* @__PURE__ */ h("input", {
|
|
300
|
+
id: _,
|
|
301
|
+
name: n.name,
|
|
302
|
+
className: "rfe-input",
|
|
303
|
+
type: n.type ?? "text",
|
|
304
|
+
value: r,
|
|
305
|
+
onChange: (e) => i(e.target.value),
|
|
306
|
+
onBlur: n.onBlur,
|
|
307
|
+
onFocus: (e) => {
|
|
308
|
+
n.selectOnFocus && e.target.select();
|
|
309
|
+
},
|
|
310
|
+
onKeyDown: (e) => {
|
|
311
|
+
e.key === "Enter" && !e.nativeEvent.isComposing && n.onEnter?.();
|
|
312
|
+
},
|
|
313
|
+
placeholder: n.placeholder,
|
|
314
|
+
disabled: n.disabled || n.loading,
|
|
315
|
+
readOnly: n.readOnly,
|
|
316
|
+
maxLength: n.maxLength,
|
|
317
|
+
autoFocus: n.autoFocus,
|
|
318
|
+
autoComplete: n.autoComplete,
|
|
319
|
+
inputMode: n.inputMode,
|
|
320
|
+
"aria-label": n["aria-label"],
|
|
321
|
+
"aria-describedby": n["aria-describedby"],
|
|
322
|
+
"aria-invalid": n.status === "error" || n["aria-invalid"]
|
|
323
|
+
});
|
|
324
|
+
return /* @__PURE__ */ h(c, {
|
|
325
|
+
...n,
|
|
326
|
+
floatingLabel: void 0,
|
|
327
|
+
disabled: n.disabled || n.loading,
|
|
328
|
+
className: p(l && "rfe-floating-control", n.className),
|
|
329
|
+
actions: /* @__PURE__ */ g(m, { children: [
|
|
330
|
+
n.showCount && /* @__PURE__ */ g("span", {
|
|
331
|
+
className: "rfe-count",
|
|
332
|
+
children: [r.length, n.maxLength === void 0 ? "" : `/${n.maxLength}`]
|
|
333
|
+
}),
|
|
334
|
+
n.clearable && /* @__PURE__ */ h(o, {
|
|
335
|
+
name: "clear",
|
|
336
|
+
label: a.clear,
|
|
337
|
+
onClick: () => i(""),
|
|
338
|
+
disabled: n.disabled || n.readOnly || n.loading,
|
|
339
|
+
hidden: !r
|
|
340
|
+
}),
|
|
341
|
+
n.actions,
|
|
342
|
+
n.actionItems?.map((e, t) => /* @__PURE__ */ h(o, {
|
|
343
|
+
name: e.loading ? "loading" : "",
|
|
344
|
+
source: e.loading ? void 0 : e.icon,
|
|
345
|
+
label: e.label,
|
|
346
|
+
disabled: n.disabled || n.readOnly || n.loading || e.disabled || e.loading,
|
|
347
|
+
onClick: e.onClick
|
|
348
|
+
}, t))
|
|
349
|
+
] }),
|
|
350
|
+
children: l ? /* @__PURE__ */ g("span", {
|
|
351
|
+
className: "rfe-floating-content",
|
|
352
|
+
"data-filled": r.length > 0 || void 0,
|
|
353
|
+
children: [v, /* @__PURE__ */ h("label", {
|
|
354
|
+
className: "rfe-floating-label",
|
|
355
|
+
htmlFor: _,
|
|
356
|
+
children: n.floatingLabel
|
|
357
|
+
})]
|
|
358
|
+
}) : v
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function I({ label: e, ...t }) {
|
|
362
|
+
return /* @__PURE__ */ h(F, {
|
|
363
|
+
...t,
|
|
364
|
+
floatingLabel: e
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
function L(e) {
|
|
368
|
+
let t = u(), [n, r] = i(!1);
|
|
369
|
+
return /* @__PURE__ */ h(F, {
|
|
370
|
+
...e,
|
|
371
|
+
type: n ? "text" : "password",
|
|
372
|
+
actions: /* @__PURE__ */ h(o, {
|
|
373
|
+
name: n ? "passwordVisible" : "passwordHidden",
|
|
374
|
+
label: n ? t.hidePassword : t.showPassword,
|
|
375
|
+
disabled: e.disabled || e.loading,
|
|
376
|
+
onClick: () => r((e) => !e)
|
|
377
|
+
})
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
function R(e) {
|
|
381
|
+
return /* @__PURE__ */ h(F, {
|
|
382
|
+
prefixIcon: "search",
|
|
383
|
+
clearable: !0,
|
|
384
|
+
...e
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function z(e) {
|
|
388
|
+
let [t, i] = f(e.value, e.defaultValue ?? "", e.onChange), a = r(null), o = !!e.autoSize, s = typeof e.autoSize == "object" ? e.autoSize.minRows ?? e.rows ?? 3 : e.rows ?? 3, l = typeof e.autoSize == "object" ? e.autoSize.maxRows ?? 1e400 : 1e400;
|
|
389
|
+
return n(() => {
|
|
390
|
+
let e = a.current;
|
|
391
|
+
if (!e || !o) return;
|
|
392
|
+
let t = () => {
|
|
393
|
+
let t = getComputedStyle(e), n = parseFloat(t.lineHeight) || parseFloat(t.fontSize) * 1.5, r = parseFloat(t.paddingTop) + parseFloat(t.paddingBottom), i = n * Math.max(1, s) + r, a = n * Math.max(1, s, l) + r;
|
|
394
|
+
e.style.height = "0px", e.style.overflowY = "hidden";
|
|
395
|
+
let o = Math.max(i, Math.min(a, e.scrollHeight));
|
|
396
|
+
e.style.height = `${o}px`, e.style.overflowY = e.scrollHeight > e.clientHeight + 1 ? "auto" : "hidden";
|
|
397
|
+
};
|
|
398
|
+
t();
|
|
399
|
+
let n = e.clientWidth, r = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(() => {
|
|
400
|
+
e.clientWidth !== n && (n = e.clientWidth, t());
|
|
401
|
+
});
|
|
402
|
+
return r?.observe(e), () => {
|
|
403
|
+
r?.disconnect(), e.style.height = "", e.style.overflowY = "";
|
|
404
|
+
};
|
|
405
|
+
}, [
|
|
406
|
+
o,
|
|
407
|
+
s,
|
|
408
|
+
l,
|
|
409
|
+
t
|
|
410
|
+
]), /* @__PURE__ */ h(c, {
|
|
411
|
+
...e,
|
|
412
|
+
className: p("rfe-textarea-control", e.className),
|
|
413
|
+
actions: e.showCount && /* @__PURE__ */ g("span", {
|
|
414
|
+
className: "rfe-count",
|
|
415
|
+
children: [t.length, e.maxLength === void 0 ? "" : `/${e.maxLength}`]
|
|
416
|
+
}),
|
|
417
|
+
children: /* @__PURE__ */ h("textarea", {
|
|
418
|
+
ref: a,
|
|
419
|
+
style: o ? {
|
|
420
|
+
resize: "none",
|
|
421
|
+
minHeight: 0
|
|
422
|
+
} : void 0,
|
|
423
|
+
className: "rfe-input",
|
|
424
|
+
id: e.id,
|
|
425
|
+
name: e.name,
|
|
426
|
+
rows: e.rows ?? 3,
|
|
427
|
+
value: t,
|
|
428
|
+
onChange: (e) => i(e.target.value),
|
|
429
|
+
onBlur: e.onBlur,
|
|
430
|
+
placeholder: e.placeholder,
|
|
431
|
+
disabled: e.disabled || e.loading,
|
|
432
|
+
readOnly: e.readOnly,
|
|
433
|
+
maxLength: e.maxLength,
|
|
434
|
+
"aria-label": e["aria-label"],
|
|
435
|
+
"aria-describedby": e["aria-describedby"],
|
|
436
|
+
"aria-invalid": e.status === "error" || e["aria-invalid"]
|
|
437
|
+
})
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function B(e) {
|
|
441
|
+
return e.valueType === "string" ? /* @__PURE__ */ h(O, { ...e }) : /* @__PURE__ */ h(V, { ...e });
|
|
442
|
+
}
|
|
443
|
+
function V(n) {
|
|
444
|
+
let r = {
|
|
445
|
+
...d().components?.NumberInput,
|
|
446
|
+
...n
|
|
447
|
+
}, [a, s] = f(r.value, r.defaultValue ?? null, r.onChange), [u, p] = i(""), [_, v] = i(!1), y = l(), b = t(), x = r.id ?? b, S = r.locale ?? y.code, C = r.precision === void 0 ? void 0 : Math.max(0, Math.min(12, Math.trunc(r.precision))), w = (e, t = !1) => P(e, S, C, t), T = (e, t = !1) => r.parser ? r.parser(e) : N(e, S, t), E = r.allowNegative === !1 ? Math.max(0, r.min ?? 0) : r.min ?? -1e400, D = Math.max(E, r.max ?? 1e400), O = (e, t = !0) => {
|
|
448
|
+
let n = t ? Math.max(E, Math.min(D, e)) : e;
|
|
449
|
+
return Number(C === void 0 ? n.toPrecision(15) : n.toFixed(C));
|
|
450
|
+
}, k = r.disabled || r.readOnly || r.loading;
|
|
451
|
+
e(() => {
|
|
452
|
+
_ && p(P(a, S));
|
|
453
|
+
}, [S]);
|
|
454
|
+
let A = () => {
|
|
455
|
+
if (!k) {
|
|
456
|
+
let e = T(u), t = e && Number.isFinite(Number(e)) ? O(Number(e), r.clampOnBlur !== !1) : null;
|
|
457
|
+
(t !== null || r.allowEmpty !== !1) && s(t);
|
|
458
|
+
}
|
|
459
|
+
v(!1), p(""), r.onBlur?.();
|
|
460
|
+
}, j = (e) => {
|
|
461
|
+
if (k) return;
|
|
462
|
+
let t = _ ? T(u) : void 0, n = t && Number.isFinite(Number(t)) ? Number(t) : a ?? 0, i = Number.isFinite(r.step) && r.step > 0 ? r.step : 1, o = O(n + e * i);
|
|
463
|
+
p(w(o)), s(o);
|
|
464
|
+
}, M = (e) => {
|
|
465
|
+
let t = T(e);
|
|
466
|
+
if (!(t === void 0 || !/^[-]?\d*(\.\d*)?$/.test(t) || r.allowNegative === !1 && t.startsWith("-")) && (p(e), !r.commitOnBlur)) {
|
|
467
|
+
let e = t && Number.isFinite(Number(t)) ? Number(t) : null;
|
|
468
|
+
(e !== null || r.allowEmpty !== !1) && s(e);
|
|
469
|
+
}
|
|
470
|
+
}, F = r.pressRepeat ? {
|
|
471
|
+
delay: r.repeatDelay,
|
|
472
|
+
interval: r.repeatInterval
|
|
473
|
+
} : !1, I = /* @__PURE__ */ g(m, { children: [r.clearable && /* @__PURE__ */ h(o, {
|
|
474
|
+
name: "clear",
|
|
475
|
+
label: y.t("clear"),
|
|
476
|
+
disabled: k || r.allowEmpty === !1,
|
|
477
|
+
hidden: a === null && !u,
|
|
478
|
+
onClick: () => {
|
|
479
|
+
p(""), s(null);
|
|
480
|
+
}
|
|
481
|
+
}), r.controls !== "none" && /* @__PURE__ */ g("span", {
|
|
482
|
+
className: "rfe-step",
|
|
483
|
+
"data-controls": r.controls ?? "stepper",
|
|
484
|
+
children: [/* @__PURE__ */ h(o, {
|
|
485
|
+
name: "minus",
|
|
486
|
+
label: y.t("decrease"),
|
|
487
|
+
disabled: k || a !== null && a <= E,
|
|
488
|
+
repeat: F,
|
|
489
|
+
onClick: () => j(-1)
|
|
490
|
+
}), /* @__PURE__ */ h(o, {
|
|
491
|
+
name: "plus",
|
|
492
|
+
label: y.t("increase"),
|
|
493
|
+
disabled: k || a !== null && a >= D,
|
|
494
|
+
repeat: F,
|
|
495
|
+
onClick: () => j(1)
|
|
496
|
+
})]
|
|
497
|
+
})] });
|
|
498
|
+
return /* @__PURE__ */ h(c, {
|
|
499
|
+
...r,
|
|
500
|
+
id: x,
|
|
501
|
+
disabled: r.disabled || r.loading,
|
|
502
|
+
floatingFilled: a !== null || _ && !!u,
|
|
503
|
+
actions: I,
|
|
504
|
+
children: /* @__PURE__ */ h("input", {
|
|
505
|
+
className: "rfe-input",
|
|
506
|
+
id: x,
|
|
507
|
+
name: r.name,
|
|
508
|
+
inputMode: "decimal",
|
|
509
|
+
value: _ ? u : a !== null && r.formatter ? r.formatter(a) : w(a, r.useGrouping),
|
|
510
|
+
onFocus: () => {
|
|
511
|
+
p(w(a)), v(!0);
|
|
512
|
+
},
|
|
513
|
+
onChange: (e) => M(e.target.value),
|
|
514
|
+
onPaste: (e) => {
|
|
515
|
+
if (k) return;
|
|
516
|
+
let t = T(e.clipboardData.getData("text"), !0);
|
|
517
|
+
if (!(t === void 0 || !t || !Number.isFinite(Number(t)) || r.allowNegative === !1 && Number(t) < 0) && e.currentTarget.selectionStart === 0 && e.currentTarget.selectionEnd === e.currentTarget.value.length) {
|
|
518
|
+
e.preventDefault();
|
|
519
|
+
let n = Number(t);
|
|
520
|
+
p(P(n, S)), r.commitOnBlur || s(n);
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
onBlur: A,
|
|
524
|
+
onKeyDown: (e) => {
|
|
525
|
+
!k && ["ArrowUp", "ArrowDown"].includes(e.key) && (e.preventDefault(), j(e.key === "ArrowUp" ? 1 : -1)), e.key === "Enter" && e.currentTarget.blur();
|
|
526
|
+
},
|
|
527
|
+
disabled: r.disabled || r.loading,
|
|
528
|
+
readOnly: r.readOnly,
|
|
529
|
+
placeholder: r.placeholder,
|
|
530
|
+
"aria-label": r["aria-label"] ?? r.floatingLabel,
|
|
531
|
+
"aria-describedby": r["aria-describedby"],
|
|
532
|
+
"aria-invalid": r.status === "error" || r["aria-invalid"]
|
|
533
|
+
})
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
function H({ size: e, variant: t = "primary", icon: n, loading: r, iconPosition: i = "start", children: a, className: o, disabled: s, type: c = "button", ...l }) {
|
|
537
|
+
let u = d(), f = /* @__PURE__ */ h(_, {
|
|
538
|
+
name: r ? "loading" : void 0,
|
|
539
|
+
source: r ? void 0 : n
|
|
540
|
+
});
|
|
541
|
+
return /* @__PURE__ */ g("button", {
|
|
542
|
+
...l,
|
|
543
|
+
type: c,
|
|
544
|
+
className: p("rfe-button", o),
|
|
545
|
+
"data-size": e ?? u.size,
|
|
546
|
+
"data-variant": t,
|
|
547
|
+
disabled: s || r,
|
|
548
|
+
"aria-busy": r || void 0,
|
|
549
|
+
children: [
|
|
550
|
+
(n || r) && i === "start" && /* @__PURE__ */ h("span", {
|
|
551
|
+
className: r ? "rfe-spin" : void 0,
|
|
552
|
+
children: f
|
|
553
|
+
}),
|
|
554
|
+
a,
|
|
555
|
+
(n || r) && i === "end" && /* @__PURE__ */ h("span", {
|
|
556
|
+
className: r ? "rfe-spin" : void 0,
|
|
557
|
+
children: f
|
|
558
|
+
})
|
|
559
|
+
]
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
function U(e) {
|
|
563
|
+
return /* @__PURE__ */ h(H, {
|
|
564
|
+
variant: "ghost",
|
|
565
|
+
...e,
|
|
566
|
+
className: p("rfe-icon-button", e.className)
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function W(e) {
|
|
570
|
+
let t = d(), [n, r] = f(e.value, e.defaultValue ?? !1, e.onChange);
|
|
571
|
+
return /* @__PURE__ */ g("label", {
|
|
572
|
+
className: p("rfe-choice", e.className),
|
|
573
|
+
"data-size": e.size ?? t.size,
|
|
574
|
+
style: e.style,
|
|
575
|
+
"data-disabled": e.disabled || void 0,
|
|
576
|
+
children: [
|
|
577
|
+
/* @__PURE__ */ h("input", {
|
|
578
|
+
type: "checkbox",
|
|
579
|
+
id: e.id,
|
|
580
|
+
name: e.name,
|
|
581
|
+
checked: n,
|
|
582
|
+
ref: (t) => {
|
|
583
|
+
t && (t.indeterminate = !!e.indeterminate);
|
|
584
|
+
},
|
|
585
|
+
disabled: e.disabled || e.loading,
|
|
586
|
+
"aria-readonly": e.readOnly,
|
|
587
|
+
"aria-invalid": e.status === "error" || e["aria-invalid"],
|
|
588
|
+
"aria-describedby": e["aria-describedby"],
|
|
589
|
+
"aria-label": e["aria-label"],
|
|
590
|
+
onChange: (t) => {
|
|
591
|
+
e.readOnly || r(t.target.checked);
|
|
592
|
+
},
|
|
593
|
+
onBlur: e.onBlur
|
|
594
|
+
}),
|
|
595
|
+
/* @__PURE__ */ h("span", {
|
|
596
|
+
className: "rfe-checkbox-mark",
|
|
597
|
+
children: /* @__PURE__ */ h(_, { name: e.indeterminate ? "minus" : "check" })
|
|
598
|
+
}),
|
|
599
|
+
e.children
|
|
600
|
+
]
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
function G(t) {
|
|
604
|
+
let a = d(), o = {
|
|
605
|
+
...a.components?.Switch,
|
|
606
|
+
...t
|
|
607
|
+
}, [s, c] = i(o.defaultValue ?? !1), l = o.value ?? s, u = (e) => {
|
|
608
|
+
o.value === void 0 && c(e), o.onChange?.(e);
|
|
609
|
+
}, [f, m] = i(!1), _ = r(null), v = r({
|
|
610
|
+
p: o,
|
|
611
|
+
value: l,
|
|
612
|
+
setValue: u
|
|
613
|
+
});
|
|
614
|
+
v.current = {
|
|
615
|
+
p: o,
|
|
616
|
+
value: l,
|
|
617
|
+
setValue: u
|
|
618
|
+
};
|
|
619
|
+
let y = (e, t = !1) => {
|
|
620
|
+
_.current === e && (_.current = null, t && e.controller.abort(), m(!1), v.current.p.onLoadingChange?.(!1));
|
|
621
|
+
};
|
|
622
|
+
n(() => {
|
|
623
|
+
let e = _.current;
|
|
624
|
+
if (!e) return;
|
|
625
|
+
let t = e.optimistic ? e.next : e.previous;
|
|
626
|
+
(l !== t || o.disabled || o.readOnly || e.key !== o.requestKey) && y(e, !0);
|
|
627
|
+
}, [
|
|
628
|
+
l,
|
|
629
|
+
o.disabled,
|
|
630
|
+
o.readOnly,
|
|
631
|
+
o.requestKey
|
|
632
|
+
]), e(() => () => {
|
|
633
|
+
let e = _.current;
|
|
634
|
+
_.current = null, e?.controller.abort();
|
|
635
|
+
}, []);
|
|
636
|
+
let b = (e) => {
|
|
637
|
+
if (_.current || o.disabled || o.readOnly || o.loading || e === l) return;
|
|
638
|
+
if (!o.beforeChange) {
|
|
639
|
+
u(e);
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
let t = {
|
|
643
|
+
controller: new AbortController(),
|
|
644
|
+
previous: l,
|
|
645
|
+
next: e,
|
|
646
|
+
optimistic: o.asyncMode === "optimistic",
|
|
647
|
+
key: o.requestKey
|
|
648
|
+
};
|
|
649
|
+
_.current = t;
|
|
650
|
+
let n = (e, n) => {
|
|
651
|
+
if (_.current !== t || t.controller.signal.aborted) return;
|
|
652
|
+
let r = v.current;
|
|
653
|
+
try {
|
|
654
|
+
!r.p.disabled && !r.p.readOnly && (t.optimistic ? e || r.setValue(t.previous) : e && r.value === t.previous && r.setValue(t.next)), n !== void 0 && r.p.onError?.(n);
|
|
655
|
+
} finally {
|
|
656
|
+
y(t);
|
|
657
|
+
}
|
|
658
|
+
}, r;
|
|
659
|
+
try {
|
|
660
|
+
r = o.beforeChange(e, { signal: t.controller.signal });
|
|
661
|
+
} catch (e) {
|
|
662
|
+
_.current = null, t.controller.abort(), o.onError?.(e);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
typeof r == "boolean" ? (_.current = null, r && u(e)) : (m(!0), o.onLoadingChange?.(!0), t.optimistic && u(e), Promise.resolve(r).then((e) => n(e === !0), (e) => n(!1, e)));
|
|
666
|
+
}, x = !!(o.loading || f), S = o.shape ?? "round", C = (e) => typeof e == "number" ? `${Math.max(0, e)}px` : e, w = {
|
|
667
|
+
...o.style,
|
|
668
|
+
"--rfe-switch-radius": C(o.radius),
|
|
669
|
+
"--rfe-switch-thumb-radius": C(o.thumbRadius)
|
|
670
|
+
};
|
|
671
|
+
return /* @__PURE__ */ g("label", {
|
|
672
|
+
className: p("rfe-choice", "rfe-switch", o.className),
|
|
673
|
+
"data-shape": S,
|
|
674
|
+
"data-loading": x || void 0,
|
|
675
|
+
"data-disabled": o.disabled || void 0,
|
|
676
|
+
"data-readonly": o.readOnly || void 0,
|
|
677
|
+
"data-size": o.size ?? a.size,
|
|
678
|
+
style: w,
|
|
679
|
+
children: [
|
|
680
|
+
/* @__PURE__ */ h("input", {
|
|
681
|
+
id: o.id,
|
|
682
|
+
name: o.name,
|
|
683
|
+
type: "checkbox",
|
|
684
|
+
role: "switch",
|
|
685
|
+
checked: l,
|
|
686
|
+
disabled: o.disabled,
|
|
687
|
+
"aria-disabled": x || o.readOnly || void 0,
|
|
688
|
+
"aria-busy": x || void 0,
|
|
689
|
+
"aria-readonly": o.readOnly,
|
|
690
|
+
"aria-invalid": o.status === "error" || o["aria-invalid"],
|
|
691
|
+
"aria-describedby": o["aria-describedby"],
|
|
692
|
+
"aria-label": o["aria-label"],
|
|
693
|
+
onBlur: o.onBlur,
|
|
694
|
+
onChange: (e) => b(e.target.checked)
|
|
695
|
+
}),
|
|
696
|
+
/* @__PURE__ */ h("span", {
|
|
697
|
+
className: "rfe-switch-track",
|
|
698
|
+
"aria-hidden": "true",
|
|
699
|
+
children: x && o.loadingIndicator !== "none" && /* @__PURE__ */ h("span", {
|
|
700
|
+
className: "rfe-switch-loading",
|
|
701
|
+
"data-position": o.loadingIndicator ?? "thumb"
|
|
702
|
+
})
|
|
703
|
+
}),
|
|
704
|
+
o.children
|
|
705
|
+
]
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
function K(e) {
|
|
709
|
+
let t = d(), n = {
|
|
710
|
+
...t.components?.RadioGroup,
|
|
711
|
+
...e
|
|
712
|
+
}, [r, i] = f(n.value, n.defaultValue ?? null, n.onChange), a = q();
|
|
713
|
+
return /* @__PURE__ */ h("div", {
|
|
714
|
+
role: "radiogroup",
|
|
715
|
+
"aria-label": n["aria-label"],
|
|
716
|
+
"aria-invalid": n.status === "error" || n["aria-invalid"],
|
|
717
|
+
"aria-describedby": n["aria-describedby"],
|
|
718
|
+
className: p("rfe-choice-group", n.className),
|
|
719
|
+
style: n.style,
|
|
720
|
+
"data-direction": n.direction ?? "row",
|
|
721
|
+
"data-mode": n.variant ?? "default",
|
|
722
|
+
"data-size": n.size ?? t.size,
|
|
723
|
+
children: n.options.map((e, t) => /* @__PURE__ */ g("label", {
|
|
724
|
+
className: "rfe-choice",
|
|
725
|
+
"data-selected": r === e.value,
|
|
726
|
+
"data-disabled": n.disabled || e.disabled || void 0,
|
|
727
|
+
children: [
|
|
728
|
+
/* @__PURE__ */ h("input", {
|
|
729
|
+
id: t === 0 ? n.id : void 0,
|
|
730
|
+
name: n.name ?? a,
|
|
731
|
+
type: "radio",
|
|
732
|
+
checked: r === e.value,
|
|
733
|
+
disabled: n.disabled || e.disabled || n.loading,
|
|
734
|
+
onChange: () => {
|
|
735
|
+
n.readOnly || i(e.value);
|
|
736
|
+
},
|
|
737
|
+
onBlur: n.onBlur
|
|
738
|
+
}),
|
|
739
|
+
/* @__PURE__ */ h("span", { className: "rfe-radio-mark" }),
|
|
740
|
+
/* @__PURE__ */ g("span", { children: [
|
|
741
|
+
e.icon,
|
|
742
|
+
e.label,
|
|
743
|
+
n.variant === "card" && e.description && /* @__PURE__ */ h("small", { children: e.description })
|
|
744
|
+
] })
|
|
745
|
+
]
|
|
746
|
+
}, e.value))
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
var q = () => t();
|
|
750
|
+
function J(e) {
|
|
751
|
+
let t = d(), n = {
|
|
752
|
+
...t.components?.CheckboxGroup,
|
|
753
|
+
...e
|
|
754
|
+
}, [r, i] = f(n.value, n.defaultValue ?? [], n.onChange), a = new Set(r);
|
|
755
|
+
return /* @__PURE__ */ h("div", {
|
|
756
|
+
role: "group",
|
|
757
|
+
"aria-label": n["aria-label"],
|
|
758
|
+
"aria-invalid": n.status === "error" || n["aria-invalid"],
|
|
759
|
+
"aria-describedby": n["aria-describedby"],
|
|
760
|
+
className: p("rfe-choice-group", n.className),
|
|
761
|
+
style: n.style,
|
|
762
|
+
"data-direction": n.direction ?? "row",
|
|
763
|
+
"data-mode": n.variant ?? "default",
|
|
764
|
+
"data-size": n.size ?? t.size,
|
|
765
|
+
children: n.options.map((e) => /* @__PURE__ */ g(W, {
|
|
766
|
+
value: a.has(e.value),
|
|
767
|
+
size: n.size,
|
|
768
|
+
loading: n.loading,
|
|
769
|
+
disabled: n.disabled || e.disabled || !a.has(e.value) && n.maxCount !== void 0 && r.length >= n.maxCount,
|
|
770
|
+
readOnly: n.readOnly,
|
|
771
|
+
onBlur: n.onBlur,
|
|
772
|
+
onChange: (t) => i(t ? [...r, e.value] : r.filter((t) => t !== e.value)),
|
|
773
|
+
children: [e.icon, e.label]
|
|
774
|
+
}, e.value))
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
function Y(e) {
|
|
778
|
+
let { block: t, variant: a = "default", iconOnly: o = !1, optionWidth: s, radius: c, animated: l = !0, ...u } = {
|
|
779
|
+
...d().components?.Segmented,
|
|
780
|
+
...e
|
|
781
|
+
}, [m, _] = f(u.value, u.defaultValue ?? null, u.onChange), v = r(null), [y, b] = i({
|
|
782
|
+
x: 0,
|
|
783
|
+
width: 0
|
|
784
|
+
}), x = () => {
|
|
785
|
+
let e = v.current?.querySelector(".rfe-segmented");
|
|
786
|
+
if (!e) return;
|
|
787
|
+
let t = e.querySelector("label:has(input:checked)"), n = t ? {
|
|
788
|
+
x: e.offsetLeft + t.offsetLeft,
|
|
789
|
+
width: t.offsetWidth
|
|
790
|
+
} : {
|
|
791
|
+
x: 0,
|
|
792
|
+
width: 0
|
|
793
|
+
};
|
|
794
|
+
b((e) => e.x === n.x && e.width === n.width ? e : n);
|
|
795
|
+
};
|
|
796
|
+
n(x, [
|
|
797
|
+
m,
|
|
798
|
+
u.options,
|
|
799
|
+
t,
|
|
800
|
+
a,
|
|
801
|
+
o,
|
|
802
|
+
s,
|
|
803
|
+
c,
|
|
804
|
+
u.size
|
|
805
|
+
]), n(() => {
|
|
806
|
+
let e = v.current;
|
|
807
|
+
if (!e) return;
|
|
808
|
+
let t = e.querySelector(".rfe-segmented");
|
|
809
|
+
if (!t || typeof ResizeObserver > "u") return;
|
|
810
|
+
let n = new ResizeObserver(x);
|
|
811
|
+
return n.observe(e), n.observe(t), t.querySelectorAll("label").forEach((e) => n.observe(e)), () => n.disconnect();
|
|
812
|
+
}, [
|
|
813
|
+
u.options,
|
|
814
|
+
t,
|
|
815
|
+
a,
|
|
816
|
+
o,
|
|
817
|
+
s,
|
|
818
|
+
c,
|
|
819
|
+
u.size
|
|
820
|
+
]);
|
|
821
|
+
let S = (e) => typeof e == "number" ? `${e}px` : e, C = {
|
|
822
|
+
"--rfe-segment-option-width": S(s),
|
|
823
|
+
"--rfe-segment-radius": S(c)
|
|
824
|
+
}, w = u.options.map((e) => ({
|
|
825
|
+
...e,
|
|
826
|
+
icon: e.icon ? /* @__PURE__ */ h("span", {
|
|
827
|
+
className: "rfe-segment-icon",
|
|
828
|
+
"aria-hidden": "true",
|
|
829
|
+
children: e.icon
|
|
830
|
+
}) : void 0,
|
|
831
|
+
label: /* @__PURE__ */ h("span", {
|
|
832
|
+
className: o && e.icon ? "rfe-segment-sr" : "rfe-segment-label",
|
|
833
|
+
children: e.ariaLabel && o && e.icon ? e.ariaLabel : e.label
|
|
834
|
+
})
|
|
835
|
+
}));
|
|
836
|
+
return /* @__PURE__ */ g("div", {
|
|
837
|
+
ref: v,
|
|
838
|
+
className: "rfe-segment-shell",
|
|
839
|
+
"data-variant": a,
|
|
840
|
+
"data-block": t || void 0,
|
|
841
|
+
"data-icon-only": o || void 0,
|
|
842
|
+
"data-animated": l,
|
|
843
|
+
style: C,
|
|
844
|
+
children: [/* @__PURE__ */ h("span", {
|
|
845
|
+
className: "rfe-segment-indicator",
|
|
846
|
+
"aria-hidden": "true",
|
|
847
|
+
style: {
|
|
848
|
+
width: y.width,
|
|
849
|
+
transform: `translateX(${y.x}px)`,
|
|
850
|
+
opacity: +!!y.width
|
|
851
|
+
}
|
|
852
|
+
}), /* @__PURE__ */ h(K, {
|
|
853
|
+
...u,
|
|
854
|
+
options: w,
|
|
855
|
+
value: m,
|
|
856
|
+
onChange: _,
|
|
857
|
+
variant: "button",
|
|
858
|
+
className: p("rfe-segmented", u.className)
|
|
859
|
+
})]
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
export { U as a, L as c, Y as d, G as f, k as g, O as h, I as i, K as l, A as m, W as n, F as o, z as p, J as r, B as s, H as t, R as u };
|