jaguar-form 1.0.3 → 1.0.5

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