jaguar-form 1.0.4 → 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 (64) hide show
  1. package/README.md +38 -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-D4_6P0d_.js → compound-BX_PoTK5.js} +100 -88
  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 +3 -3
  12. package/dist/{icons-BI3fdIey.js → icons-BwE05e0C.js} +1 -1
  13. package/dist/{image-upload-VtUlQgzJ.js → image-upload-D9oPG0Eh.js} +252 -179
  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-Dx3xOy9q.js +718 -0
  18. package/dist/{useSelection-C0OEFZUE.js → lazy-tree-NCX3ntYm.js} +96 -4
  19. package/dist/locale/load.js +7 -3
  20. package/dist/pickers-Bci1y8cc.js +634 -0
  21. package/dist/select.js +3 -1
  22. package/dist/selection-DCIzhR5q.js +197 -0
  23. package/dist/{slider-CNwkLMmo.js → slider-AM0Egz9P.js} +1 -1
  24. package/dist/slider.js +1 -1
  25. package/dist/store-CFSQW-Fv.js +622 -0
  26. package/dist/style.css +1 -1
  27. package/dist/tree-select.js +1 -1
  28. package/dist/types/components/compound/ControlGroup.d.ts +5 -2
  29. package/dist/types/components/compound/index.d.ts +10 -1
  30. package/dist/types/components/extended-inputs.d.ts +34 -0
  31. package/dist/types/components/image-upload/ManagedImageUpload.d.ts +11 -4
  32. package/dist/types/components/image-upload/index.d.ts +3 -2
  33. package/dist/types/components/image-upload/upload.d.ts +1 -1
  34. package/dist/types/components/image-upload/usePreparation.d.ts +7 -0
  35. package/dist/types/components/image-upload/validation.d.ts +16 -0
  36. package/dist/types/components/inputs.d.ts +42 -4
  37. package/dist/types/components/select/Cascader.d.ts +13 -0
  38. package/dist/types/components/select/types.d.ts +10 -1
  39. package/dist/types/components/select/useRemoteOptions.d.ts +18 -0
  40. package/dist/types/components/select.d.ts +3 -0
  41. package/dist/types/config/index.d.ts +3 -0
  42. package/dist/types/entries/input.d.ts +5 -2
  43. package/dist/types/entries/select.d.ts +3 -0
  44. package/dist/types/form/adapter.d.ts +1 -0
  45. package/dist/types/form/index.d.ts +85 -10
  46. package/dist/types/form/store.d.ts +21 -1
  47. package/dist/types/locale/load.d.ts +2 -1
  48. package/dist/types/primitives/Control.d.ts +3 -1
  49. package/dist/types/primitives/Popup.d.ts +1 -0
  50. package/dist/types/types.d.ts +1 -0
  51. package/dist/types/utils/cascader.d.ts +12 -0
  52. package/dist/types/utils/decimal.d.ts +22 -0
  53. package/dist/types/utils/remote-options.d.ts +24 -0
  54. package/dist/useControllable-QDX_UWRh.js +102 -0
  55. package/package.json +1 -1
  56. package/dist/Control-B36bu6zQ.js +0 -47
  57. package/dist/Select-BG2H-YnK.js +0 -252
  58. package/dist/TreeSelect-CkPtMg-g.js +0 -440
  59. package/dist/form-DTI0Sqsy.js +0 -413
  60. package/dist/inputs-BOP8Ryne.js +0 -403
  61. package/dist/pickers-C9QTR2XN.js +0 -631
  62. package/dist/selection-CIEa1uce.js +0 -146
  63. package/dist/store-DOn9K-EA.js +0 -491
  64. package/dist/useControllable-Zax42z2F.js +0 -87
@@ -0,0 +1,718 @@
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-DCIzhR5q.js";
3
+ import { a as l, i as u, o as d, s as f, t as p } from "./useControllable-QDX_UWRh.js";
4
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
5
+ import { t as _ } from "./icons-BwE05e0C.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, r] = p(e.value, e.defaultValue ?? null, e.onChange), [a, s] = i(""), [u, d] = i(!1), f = l(), _ = !!(e.disabled || e.readOnly || e.loading), v = t(), b = e.id ?? v, x = (t) => y(e.parser?.(t) ?? t), C = (t) => {
58
+ let n = x(t);
59
+ n === null ? e.allowEmpty !== !1 && r(null) : r(E(n, e));
60
+ }, w = T(e), O = (t) => {
61
+ if (_) return;
62
+ let i = D(u ? x(a) ?? n : n, t, e);
63
+ s(i), r(i);
64
+ }, k = (e) => {
65
+ let t = y(n ?? ""), r = e === 1 ? w.max : w.min;
66
+ return t !== null && r !== void 0 && (e === 1 ? S(t, r) >= 0 : S(t, r) <= 0);
67
+ };
68
+ return /* @__PURE__ */ h(c, {
69
+ ...e,
70
+ id: b,
71
+ floatingFilled: n !== null || u && !!a,
72
+ disabled: e.disabled || e.loading,
73
+ actions: /* @__PURE__ */ g(m, { children: [e.clearable && /* @__PURE__ */ h(o, {
74
+ name: "clear",
75
+ label: f.t("clear"),
76
+ disabled: _ || e.allowEmpty === !1,
77
+ hidden: n === null && !a,
78
+ onClick: () => {
79
+ s(""), r(null);
80
+ }
81
+ }), e.controls && e.controls !== "none" && /* @__PURE__ */ g("span", {
82
+ className: "rfe-step",
83
+ "data-controls": e.controls,
84
+ children: [/* @__PURE__ */ h(o, {
85
+ name: "minus",
86
+ label: f.t("decrease"),
87
+ disabled: _ || k(-1),
88
+ onClick: () => O(-1)
89
+ }), /* @__PURE__ */ h(o, {
90
+ name: "plus",
91
+ label: f.t("increase"),
92
+ disabled: _ || k(1),
93
+ onClick: () => O(1)
94
+ })]
95
+ })] }),
96
+ children: /* @__PURE__ */ h("input", {
97
+ id: b,
98
+ name: e.name,
99
+ className: "rfe-input",
100
+ inputMode: "decimal",
101
+ value: u ? a : n === null ? "" : e.formatter?.(n) ?? n,
102
+ onFocus: () => {
103
+ s(n ?? ""), d(!0);
104
+ },
105
+ onChange: (t) => {
106
+ if (_) return;
107
+ let n = t.target.value, i = e.parser?.(n) ?? n;
108
+ if (!(!/^-?\d*(\.\d*)?$/.test(i) || e.allowNegative === !1 && i.startsWith("-")) && (s(n), !e.commitOnBlur)) {
109
+ let t = y(i);
110
+ (t !== null || e.allowEmpty !== !1) && r(t);
111
+ }
112
+ },
113
+ onBlur: () => {
114
+ _ || C(a), d(!1), s(""), e.onBlur?.();
115
+ },
116
+ onKeyDown: (e) => {
117
+ _ || e.nativeEvent.isComposing || (e.key === "ArrowUp" || e.key === "ArrowDown" ? (e.preventDefault(), O(e.key === "ArrowUp" ? 1 : -1)) : e.key === "Enter" && e.currentTarget.blur());
118
+ },
119
+ placeholder: e.placeholder,
120
+ disabled: e.disabled || e.loading,
121
+ readOnly: e.readOnly,
122
+ "aria-label": e["aria-label"] ?? e.floatingLabel,
123
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
124
+ "aria-describedby": e["aria-describedby"]
125
+ })
126
+ });
127
+ }
128
+ function k(e) {
129
+ let [t, n] = p(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 ?? [
130
+ ",",
131
+ ";",
132
+ "\n"
133
+ ], _ = (r) => {
134
+ if (u) return;
135
+ let i = m.reduce((e, t) => t ? e.flatMap((e) => e.split(t)) : e, [r]), o = [...t];
136
+ for (let t of i) {
137
+ let n = t.trim();
138
+ n && o.length < (e.maxCount ?? 1e400) && (e.allowDuplicates || !o.includes(n)) && o.push(n);
139
+ }
140
+ n(o), a("");
141
+ };
142
+ return /* @__PURE__ */ g(c, {
143
+ ...e,
144
+ disabled: e.disabled || e.loading,
145
+ className: f("rfe-tags-control", e.className),
146
+ children: [t.map((e, r) => /* @__PURE__ */ g("span", {
147
+ className: "rfe-tag",
148
+ children: [/* @__PURE__ */ h("span", {
149
+ className: "rfe-tag-label",
150
+ children: e
151
+ }), !u && /* @__PURE__ */ h(o, {
152
+ name: "clear",
153
+ label: `${s.t("remove")} ${e}`,
154
+ onClick: () => n(t.filter((e, t) => t !== r))
155
+ })]
156
+ }, `${e}-${r}`)), /* @__PURE__ */ h("input", {
157
+ id: e.id,
158
+ name: e.name,
159
+ className: "rfe-input",
160
+ value: r,
161
+ placeholder: d ? void 0 : e.placeholder,
162
+ disabled: e.disabled || e.loading,
163
+ readOnly: e.readOnly || d,
164
+ onChange: (e) => a(e.target.value),
165
+ onKeyDown: (e) => {
166
+ 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))));
167
+ },
168
+ onPaste: (e) => {
169
+ let t = e.clipboardData.getData("text");
170
+ !u && m.some((e) => e && t.includes(e)) && (e.preventDefault(), _(r + t));
171
+ },
172
+ onBlur: () => {
173
+ r && _(r), e.onBlur?.();
174
+ },
175
+ "aria-label": e["aria-label"],
176
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
177
+ "aria-describedby": e["aria-describedby"]
178
+ })]
179
+ });
180
+ }
181
+ function A(e) {
182
+ let [n, r] = p(e.value, e.defaultValue ?? "", e.onChange), [o, u] = i(!1), [d, f] = 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) => {
183
+ _ || t.disabled || (r(t.value), e.onSelect?.(t), u(!1), f(-1));
184
+ }, b = o && !_ && v.length > 0;
185
+ return /* @__PURE__ */ h(s, {
186
+ open: b,
187
+ onOpenChange: u,
188
+ popupMode: "popover",
189
+ popupWidth: e.popupWidth,
190
+ layout: "selection",
191
+ initialFocus: -1,
192
+ trigger: (t, i) => /* @__PURE__ */ h("div", {
193
+ className: "rfe-anchor",
194
+ ref: i,
195
+ children: /* @__PURE__ */ h(c, {
196
+ ...e,
197
+ disabled: e.disabled || e.loading,
198
+ children: /* @__PURE__ */ h("input", {
199
+ ...t,
200
+ id: e.id,
201
+ name: e.name,
202
+ className: "rfe-input",
203
+ role: "combobox",
204
+ "aria-autocomplete": "list",
205
+ "aria-expanded": b,
206
+ "aria-controls": b ? `${m}-list` : void 0,
207
+ "aria-activedescendant": b && d >= 0 ? `${m}-${d}` : void 0,
208
+ value: n,
209
+ disabled: e.disabled || e.loading,
210
+ readOnly: e.readOnly,
211
+ placeholder: e.placeholder,
212
+ "aria-label": e["aria-label"] ?? g.t("search"),
213
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
214
+ "aria-describedby": e["aria-describedby"],
215
+ onFocus: () => {
216
+ _ || f(-1);
217
+ },
218
+ onBlur: () => {
219
+ u(!1), e.onBlur?.();
220
+ },
221
+ onChange: (e) => {
222
+ r(e.target.value), f(-1), u(!0);
223
+ },
224
+ onKeyDown: (e) => {
225
+ _ || e.nativeEvent.isComposing || (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), u(!0), f(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));
226
+ }
227
+ })
228
+ })
229
+ }),
230
+ children: /* @__PURE__ */ h("div", {
231
+ className: "rfe-list",
232
+ role: "listbox",
233
+ id: `${m}-list`,
234
+ "aria-label": g.t("choose"),
235
+ style: {
236
+ overflowY: "auto",
237
+ maxHeight: 216
238
+ },
239
+ children: v.map((e, t) => /* @__PURE__ */ h("button", {
240
+ type: "button",
241
+ role: "option",
242
+ id: `${m}-${t}`,
243
+ tabIndex: -1,
244
+ "aria-selected": t === d,
245
+ "data-active": t === d || void 0,
246
+ disabled: e.disabled,
247
+ className: "rfe-option",
248
+ onMouseDown: (e) => e.preventDefault(),
249
+ onClick: () => y(e),
250
+ children: e.label
251
+ }, e.value))
252
+ })
253
+ });
254
+ }
255
+ // src/utils/number.ts
256
+ var j = /* @__PURE__ */ new Map();
257
+ function M(e) {
258
+ let t = j.get(e);
259
+ if (t) return t;
260
+ let n = new Intl.NumberFormat(e).formatToParts(-12345.6), r = new Intl.NumberFormat(e, { useGrouping: !1 }), i = {
261
+ decimal: n.find((e) => e.type === "decimal")?.value ?? ".",
262
+ group: n.find((e) => e.type === "group")?.value ?? ",",
263
+ minus: n.find((e) => e.type === "minusSign")?.value ?? "-",
264
+ digits: Array.from({ length: 10 }, (e, t) => r.format(t))
265
+ };
266
+ return j.size >= 32 && j.clear(), j.set(e, i), i;
267
+ }
268
+ function N(e, t, n = !1) {
269
+ let { decimal: r, group: i, minus: a, digits: o } = M(t), s = e.replace(/[\u061c\u200e\u200f]/g, "");
270
+ for (let e = 0; e < o.length; e++) s = s.split(o[e]).join(String(e));
271
+ 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;
272
+ }
273
+ function P(e, t, n, r = !1) {
274
+ return e === null || !Number.isFinite(e) ? "" : new Intl.NumberFormat(t, {
275
+ useGrouping: r,
276
+ minimumFractionDigits: n ?? 0,
277
+ maximumFractionDigits: n ?? 20
278
+ }).format(e);
279
+ }
280
+ // src/components/inputs.tsx
281
+ function F(e) {
282
+ let [n, r] = p(e.value, e.defaultValue ?? "", e.onChange), i = d(), a = t(), s = !!e.floatingLabel, l = e.id ?? (s ? a : void 0), u = /* @__PURE__ */ h("input", {
283
+ id: l,
284
+ name: e.name,
285
+ className: "rfe-input",
286
+ type: e.type ?? "text",
287
+ value: n,
288
+ onChange: (e) => r(e.target.value),
289
+ onBlur: e.onBlur,
290
+ onFocus: (t) => {
291
+ e.selectOnFocus && t.target.select();
292
+ },
293
+ onKeyDown: (t) => {
294
+ t.key === "Enter" && !t.nativeEvent.isComposing && e.onEnter?.();
295
+ },
296
+ placeholder: e.placeholder,
297
+ disabled: e.disabled || e.loading,
298
+ readOnly: e.readOnly,
299
+ maxLength: e.maxLength,
300
+ autoFocus: e.autoFocus,
301
+ autoComplete: e.autoComplete,
302
+ inputMode: e.inputMode,
303
+ "aria-label": e["aria-label"],
304
+ "aria-describedby": e["aria-describedby"],
305
+ "aria-invalid": e.status === "error" || e["aria-invalid"]
306
+ });
307
+ return /* @__PURE__ */ h(c, {
308
+ ...e,
309
+ floatingLabel: void 0,
310
+ disabled: e.disabled || e.loading,
311
+ className: f(s && "rfe-floating-control", e.className),
312
+ actions: /* @__PURE__ */ g(m, { children: [
313
+ e.showCount && /* @__PURE__ */ g("span", {
314
+ className: "rfe-count",
315
+ children: [n.length, e.maxLength === void 0 ? "" : `/${e.maxLength}`]
316
+ }),
317
+ e.clearable && /* @__PURE__ */ h(o, {
318
+ name: "clear",
319
+ label: i.clear,
320
+ onClick: () => r(""),
321
+ disabled: e.disabled || e.readOnly || e.loading,
322
+ hidden: !n
323
+ }),
324
+ e.actions,
325
+ e.actionItems?.map((t, n) => /* @__PURE__ */ h(o, {
326
+ name: t.loading ? "loading" : "",
327
+ source: t.loading ? void 0 : t.icon,
328
+ label: t.label,
329
+ disabled: e.disabled || e.readOnly || e.loading || t.disabled || t.loading,
330
+ onClick: t.onClick
331
+ }, n))
332
+ ] }),
333
+ children: s ? /* @__PURE__ */ g("span", {
334
+ className: "rfe-floating-content",
335
+ "data-filled": n.length > 0 || void 0,
336
+ children: [u, /* @__PURE__ */ h("label", {
337
+ className: "rfe-floating-label",
338
+ htmlFor: l,
339
+ children: e.floatingLabel
340
+ })]
341
+ }) : u
342
+ });
343
+ }
344
+ function I({ label: e, ...t }) {
345
+ return /* @__PURE__ */ h(F, {
346
+ ...t,
347
+ floatingLabel: e
348
+ });
349
+ }
350
+ function L(e) {
351
+ let t = d(), [n, r] = i(!1);
352
+ return /* @__PURE__ */ h(F, {
353
+ ...e,
354
+ type: n ? "text" : "password",
355
+ actions: /* @__PURE__ */ h(o, {
356
+ name: n ? "passwordVisible" : "passwordHidden",
357
+ label: n ? t.hidePassword : t.showPassword,
358
+ disabled: e.disabled || e.loading,
359
+ onClick: () => r((e) => !e)
360
+ })
361
+ });
362
+ }
363
+ function R(e) {
364
+ return /* @__PURE__ */ h(F, {
365
+ prefixIcon: "search",
366
+ clearable: !0,
367
+ ...e
368
+ });
369
+ }
370
+ function z(e) {
371
+ let [t, n] = p(e.value, e.defaultValue ?? "", e.onChange);
372
+ return /* @__PURE__ */ h(c, {
373
+ ...e,
374
+ className: f("rfe-textarea-control", e.className),
375
+ actions: e.showCount && /* @__PURE__ */ g("span", {
376
+ className: "rfe-count",
377
+ children: [t.length, e.maxLength === void 0 ? "" : `/${e.maxLength}`]
378
+ }),
379
+ children: /* @__PURE__ */ h("textarea", {
380
+ className: "rfe-input",
381
+ id: e.id,
382
+ name: e.name,
383
+ rows: e.rows ?? 3,
384
+ value: t,
385
+ onChange: (e) => n(e.target.value),
386
+ onBlur: e.onBlur,
387
+ placeholder: e.placeholder,
388
+ disabled: e.disabled || e.loading,
389
+ readOnly: e.readOnly,
390
+ maxLength: e.maxLength,
391
+ "aria-label": e["aria-label"],
392
+ "aria-describedby": e["aria-describedby"],
393
+ "aria-invalid": e.status === "error" || e["aria-invalid"]
394
+ })
395
+ });
396
+ }
397
+ function B(e) {
398
+ return e.valueType === "string" ? /* @__PURE__ */ h(O, { ...e }) : /* @__PURE__ */ h(V, { ...e });
399
+ }
400
+ function V(n) {
401
+ let [r, a] = p(n.value, n.defaultValue ?? null, n.onChange), [s, u] = i(""), [d, f] = i(!1), _ = l(), v = t(), y = n.id ?? v, b = n.locale ?? _.code, x = n.precision === void 0 ? void 0 : Math.max(0, Math.min(12, Math.trunc(n.precision))), S = (e, t = !1) => P(e, b, x, t), C = (e, t = !1) => n.parser ? n.parser(e) : N(e, b, t), w = n.allowNegative === !1 ? Math.max(0, n.min ?? 0) : n.min ?? -1e400, T = Math.max(w, n.max ?? 1e400), E = (e, t = !0) => {
402
+ let n = t ? Math.max(w, Math.min(T, e)) : e;
403
+ return Number(x === void 0 ? n.toPrecision(15) : n.toFixed(x));
404
+ }, D = n.disabled || n.readOnly || n.loading;
405
+ e(() => {
406
+ d && u(P(r, b));
407
+ }, [b]);
408
+ let O = () => {
409
+ if (!D) {
410
+ let e = C(s), t = e && Number.isFinite(Number(e)) ? E(Number(e), n.clampOnBlur !== !1) : null;
411
+ (t !== null || n.allowEmpty !== !1) && a(t);
412
+ }
413
+ f(!1), u(""), n.onBlur?.();
414
+ }, k = (e) => {
415
+ if (D) return;
416
+ let t = d ? C(s) : void 0, i = t && Number.isFinite(Number(t)) ? Number(t) : r ?? 0, o = Number.isFinite(n.step) && n.step > 0 ? n.step : 1, c = E(i + e * o);
417
+ u(S(c)), a(c);
418
+ }, A = (e) => {
419
+ let t = C(e);
420
+ if (!(t === void 0 || !/^[-]?\d*(\.\d*)?$/.test(t) || n.allowNegative === !1 && t.startsWith("-")) && (u(e), !n.commitOnBlur)) {
421
+ let e = t && Number.isFinite(Number(t)) ? Number(t) : null;
422
+ (e !== null || n.allowEmpty !== !1) && a(e);
423
+ }
424
+ }, j = /* @__PURE__ */ g(m, { children: [n.clearable && /* @__PURE__ */ h(o, {
425
+ name: "clear",
426
+ label: _.t("clear"),
427
+ disabled: D || n.allowEmpty === !1,
428
+ hidden: r === null && !s,
429
+ onClick: () => {
430
+ u(""), a(null);
431
+ }
432
+ }), n.controls !== "none" && /* @__PURE__ */ g("span", {
433
+ className: "rfe-step",
434
+ "data-controls": n.controls ?? "stepper",
435
+ children: [/* @__PURE__ */ h(o, {
436
+ name: "minus",
437
+ label: _.t("decrease"),
438
+ disabled: D || r !== null && r <= w,
439
+ onClick: () => k(-1)
440
+ }), /* @__PURE__ */ h(o, {
441
+ name: "plus",
442
+ label: _.t("increase"),
443
+ disabled: D || r !== null && r >= T,
444
+ onClick: () => k(1)
445
+ })]
446
+ })] });
447
+ return /* @__PURE__ */ h(c, {
448
+ ...n,
449
+ id: y,
450
+ disabled: n.disabled || n.loading,
451
+ floatingFilled: r !== null || d && !!s,
452
+ actions: j,
453
+ children: /* @__PURE__ */ h("input", {
454
+ className: "rfe-input",
455
+ id: y,
456
+ name: n.name,
457
+ inputMode: "decimal",
458
+ value: d ? s : r !== null && n.formatter ? n.formatter(r) : S(r, n.useGrouping),
459
+ onFocus: () => {
460
+ u(S(r)), f(!0);
461
+ },
462
+ onChange: (e) => A(e.target.value),
463
+ onPaste: (e) => {
464
+ if (D) return;
465
+ let t = C(e.clipboardData.getData("text"), !0);
466
+ if (!(t === void 0 || !t || !Number.isFinite(Number(t)) || n.allowNegative === !1 && Number(t) < 0) && e.currentTarget.selectionStart === 0 && e.currentTarget.selectionEnd === e.currentTarget.value.length) {
467
+ e.preventDefault();
468
+ let r = Number(t);
469
+ u(P(r, b)), n.commitOnBlur || a(r);
470
+ }
471
+ },
472
+ onBlur: O,
473
+ onKeyDown: (e) => {
474
+ !D && ["ArrowUp", "ArrowDown"].includes(e.key) && (e.preventDefault(), k(e.key === "ArrowUp" ? 1 : -1)), e.key === "Enter" && e.currentTarget.blur();
475
+ },
476
+ disabled: n.disabled || n.loading,
477
+ readOnly: n.readOnly,
478
+ placeholder: n.placeholder,
479
+ "aria-label": n["aria-label"] ?? n.floatingLabel,
480
+ "aria-describedby": n["aria-describedby"],
481
+ "aria-invalid": n.status === "error" || n["aria-invalid"]
482
+ })
483
+ });
484
+ }
485
+ function H({ size: e, variant: t = "primary", icon: n, loading: r, iconPosition: i = "start", children: a, className: o, disabled: s, type: c = "button", ...l }) {
486
+ let d = u(), p = /* @__PURE__ */ h(_, {
487
+ name: r ? "loading" : void 0,
488
+ source: r ? void 0 : n
489
+ });
490
+ return /* @__PURE__ */ g("button", {
491
+ ...l,
492
+ type: c,
493
+ className: f("rfe-button", o),
494
+ "data-size": e ?? d.size,
495
+ "data-variant": t,
496
+ disabled: s || r,
497
+ "aria-busy": r || void 0,
498
+ children: [
499
+ (n || r) && i === "start" && /* @__PURE__ */ h("span", {
500
+ className: r ? "rfe-spin" : void 0,
501
+ children: p
502
+ }),
503
+ a,
504
+ (n || r) && i === "end" && /* @__PURE__ */ h("span", {
505
+ className: r ? "rfe-spin" : void 0,
506
+ children: p
507
+ })
508
+ ]
509
+ });
510
+ }
511
+ function U(e) {
512
+ return /* @__PURE__ */ h(H, {
513
+ variant: "ghost",
514
+ ...e,
515
+ className: f("rfe-icon-button", e.className)
516
+ });
517
+ }
518
+ function W(e) {
519
+ let t = u(), [n, r] = p(e.value, e.defaultValue ?? !1, e.onChange);
520
+ return /* @__PURE__ */ g("label", {
521
+ className: f("rfe-choice", e.className),
522
+ "data-size": e.size ?? t.size,
523
+ style: e.style,
524
+ "data-disabled": e.disabled || void 0,
525
+ children: [
526
+ /* @__PURE__ */ h("input", {
527
+ type: "checkbox",
528
+ id: e.id,
529
+ name: e.name,
530
+ checked: n,
531
+ ref: (t) => {
532
+ t && (t.indeterminate = !!e.indeterminate);
533
+ },
534
+ disabled: e.disabled || e.loading,
535
+ "aria-readonly": e.readOnly,
536
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
537
+ "aria-describedby": e["aria-describedby"],
538
+ "aria-label": e["aria-label"],
539
+ onChange: (t) => {
540
+ e.readOnly || r(t.target.checked);
541
+ },
542
+ onBlur: e.onBlur
543
+ }),
544
+ /* @__PURE__ */ h("span", {
545
+ className: "rfe-checkbox-mark",
546
+ children: /* @__PURE__ */ h(_, { name: e.indeterminate ? "minus" : "check" })
547
+ }),
548
+ e.children
549
+ ]
550
+ });
551
+ }
552
+ function G(e) {
553
+ let t = u(), [n, r] = p(e.value, e.defaultValue ?? !1, e.onChange);
554
+ return /* @__PURE__ */ g("label", {
555
+ className: f("rfe-choice", e.className),
556
+ "data-disabled": e.disabled || e.loading || void 0,
557
+ "data-size": e.size ?? t.size,
558
+ style: e.style,
559
+ children: [
560
+ /* @__PURE__ */ h("input", {
561
+ id: e.id,
562
+ name: e.name,
563
+ type: "checkbox",
564
+ role: "switch",
565
+ checked: n,
566
+ disabled: e.disabled || e.loading,
567
+ "aria-readonly": e.readOnly,
568
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
569
+ "aria-describedby": e["aria-describedby"],
570
+ "aria-label": e["aria-label"],
571
+ onBlur: e.onBlur,
572
+ onChange: (t) => {
573
+ e.readOnly || r(t.target.checked);
574
+ }
575
+ }),
576
+ /* @__PURE__ */ h("span", { className: "rfe-switch-track" }),
577
+ e.children
578
+ ]
579
+ });
580
+ }
581
+ function K(e) {
582
+ let [t, n] = p(e.value, e.defaultValue ?? null, e.onChange), r = u(), i = q();
583
+ return /* @__PURE__ */ h("div", {
584
+ role: "radiogroup",
585
+ "aria-label": e["aria-label"],
586
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
587
+ "aria-describedby": e["aria-describedby"],
588
+ className: f("rfe-choice-group", e.className),
589
+ style: e.style,
590
+ "data-direction": e.direction ?? "row",
591
+ "data-mode": e.variant ?? "default",
592
+ "data-size": e.size ?? r.size,
593
+ children: e.options.map((r, a) => /* @__PURE__ */ g("label", {
594
+ className: "rfe-choice",
595
+ "data-selected": t === r.value,
596
+ "data-disabled": e.disabled || r.disabled || void 0,
597
+ children: [
598
+ /* @__PURE__ */ h("input", {
599
+ id: a === 0 ? e.id : void 0,
600
+ name: e.name ?? i,
601
+ type: "radio",
602
+ checked: t === r.value,
603
+ disabled: e.disabled || r.disabled || e.loading,
604
+ onChange: () => {
605
+ e.readOnly || n(r.value);
606
+ },
607
+ onBlur: e.onBlur
608
+ }),
609
+ /* @__PURE__ */ h("span", { className: "rfe-radio-mark" }),
610
+ /* @__PURE__ */ g("span", { children: [
611
+ r.icon,
612
+ r.label,
613
+ e.variant === "card" && r.description && /* @__PURE__ */ h("small", { children: r.description })
614
+ ] })
615
+ ]
616
+ }, r.value))
617
+ });
618
+ }
619
+ var q = () => t();
620
+ function J(e) {
621
+ let [t, n] = p(e.value, e.defaultValue ?? [], e.onChange), r = u();
622
+ return /* @__PURE__ */ h("div", {
623
+ role: "group",
624
+ "aria-label": e["aria-label"],
625
+ "aria-invalid": e.status === "error" || e["aria-invalid"],
626
+ "aria-describedby": e["aria-describedby"],
627
+ className: f("rfe-choice-group", e.className),
628
+ style: e.style,
629
+ "data-direction": e.direction ?? "row",
630
+ "data-mode": e.variant ?? "default",
631
+ "data-size": e.size ?? r.size,
632
+ children: e.options.map((r) => /* @__PURE__ */ g(W, {
633
+ value: t.includes(r.value),
634
+ size: e.size,
635
+ loading: e.loading,
636
+ disabled: e.disabled || r.disabled || !t.includes(r.value) && e.maxCount !== void 0 && t.length >= e.maxCount,
637
+ readOnly: e.readOnly,
638
+ onBlur: e.onBlur,
639
+ onChange: (e) => n(e ? [...t, r.value] : t.filter((e) => e !== r.value)),
640
+ children: [r.icon, r.label]
641
+ }, r.value))
642
+ });
643
+ }
644
+ function Y({ block: e, variant: t = "default", iconOnly: a = !1, optionWidth: o, radius: s, animated: c = !0, ...l }) {
645
+ let [u, d] = p(l.value, l.defaultValue ?? null, l.onChange), m = r(null), [_, v] = i({
646
+ x: 0,
647
+ width: 0
648
+ });
649
+ n(() => {
650
+ let e = m.current;
651
+ if (!e) return;
652
+ let t = e.querySelector(".rfe-segmented");
653
+ if (!t) return;
654
+ let n = () => {
655
+ let e = t.querySelector("label:has(input:checked)"), n = e ? {
656
+ x: t.offsetLeft + e.offsetLeft,
657
+ width: e.offsetWidth
658
+ } : {
659
+ x: 0,
660
+ width: 0
661
+ };
662
+ v((e) => e.x === n.x && e.width === n.width ? e : n);
663
+ };
664
+ if (n(), typeof ResizeObserver > "u") return;
665
+ let r = new ResizeObserver(n);
666
+ return r.observe(e), r.observe(t), t.querySelectorAll("label").forEach((e) => r.observe(e)), () => r.disconnect();
667
+ }, [
668
+ u,
669
+ l.options,
670
+ e,
671
+ t,
672
+ a,
673
+ o,
674
+ s,
675
+ l.size
676
+ ]);
677
+ let y = (e) => typeof e == "number" ? `${e}px` : e, b = {
678
+ "--rfe-segment-option-width": y(o),
679
+ "--rfe-segment-radius": y(s)
680
+ }, x = l.options.map((e) => ({
681
+ ...e,
682
+ icon: e.icon ? /* @__PURE__ */ h("span", {
683
+ className: "rfe-segment-icon",
684
+ "aria-hidden": "true",
685
+ children: e.icon
686
+ }) : void 0,
687
+ label: /* @__PURE__ */ h("span", {
688
+ className: a && e.icon ? "rfe-segment-sr" : "rfe-segment-label",
689
+ children: e.ariaLabel && a && e.icon ? e.ariaLabel : e.label
690
+ })
691
+ }));
692
+ return /* @__PURE__ */ g("div", {
693
+ ref: m,
694
+ className: "rfe-segment-shell",
695
+ "data-variant": t,
696
+ "data-block": e || void 0,
697
+ "data-icon-only": a || void 0,
698
+ "data-animated": c,
699
+ style: b,
700
+ children: [/* @__PURE__ */ h("span", {
701
+ className: "rfe-segment-indicator",
702
+ "aria-hidden": "true",
703
+ style: {
704
+ width: _.width,
705
+ transform: `translateX(${_.x}px)`,
706
+ opacity: +!!_.width
707
+ }
708
+ }), /* @__PURE__ */ h(K, {
709
+ ...l,
710
+ options: x,
711
+ value: u,
712
+ onChange: d,
713
+ variant: "button",
714
+ className: f("rfe-segmented", l.className)
715
+ })]
716
+ });
717
+ }
718
+ 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 };