jaguar-form 1.0.4 → 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
@@ -1,10 +1,9 @@
1
1
  import { useLayoutEffect as e, useMemo as t, useRef as n, useState as r } from "react";
2
2
  import i from "dayjs";
3
3
  import { i as a } from "./locale-yHkdw2xz.js";
4
- import { a as o, t as s } from "./useControllable-Zax42z2F.js";
5
- import { n as c, t as l } from "./Control-B36bu6zQ.js";
6
- import { n as u, r as d } from "./selection-CIEa1uce.js";
7
- import { t as f } from "./icons-BI3fdIey.js";
4
+ import { a as o, t as s } from "./useControllable-Dhp7tTjy.js";
5
+ import { n as c, o as l, r as u, s as d } from "./selection-9NP9MXSn.js";
6
+ import { t as f } from "./icons-D79FYcGF.js";
8
7
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
9
8
  // src/utils/date.ts
10
9
  var g = (e) => String(e).padStart(2, "0");
@@ -258,8 +257,8 @@ function A({ value: t, kind: i, onSelect: a, start: s, end: c, p: u, hover: d, o
258
257
  });
259
258
  }
260
259
  // src/components/date-time/TimePanel.tsx
261
- function j({ column: r, length: i, value: a, p: s, onSelect: c }) {
262
- let l = o(), d = l.text, f = n(null), p = t(() => w(s, a, r), [
260
+ function j({ column: r, length: i, value: a, p: s, onSelect: l }) {
261
+ let u = o(), d = u.text, f = n(null), p = t(() => w(s, a, r), [
263
262
  s.minTime,
264
263
  s.maxTime,
265
264
  s.hourStep,
@@ -272,13 +271,13 @@ function j({ column: r, length: i, value: a, p: s, onSelect: c }) {
272
271
  d.hour,
273
272
  d.minute,
274
273
  d.second
275
- ][r], y = Array.from({ length: i }, (e, t) => g(t)), b = p.has(_) ? _ : y.find((e) => p.has(e)), x = t(() => new Intl.DateTimeFormat(l.code, {
274
+ ][r], y = Array.from({ length: i }, (e, t) => g(t)), b = p.has(_) ? _ : y.find((e) => p.has(e)), x = t(() => new Intl.DateTimeFormat(u.code, {
276
275
  hour: "numeric",
277
276
  timeZone: "UTC",
278
- hourCycle: s.hourCycle ?? l.hourCycle
277
+ hourCycle: s.hourCycle ?? u.hourCycle
279
278
  }), [
280
- l.code,
281
- l.hourCycle,
279
+ u.code,
280
+ u.hourCycle,
282
281
  s.hourCycle
283
282
  ]);
284
283
  return e(() => {
@@ -303,7 +302,7 @@ function j({ column: r, length: i, value: a, p: s, onSelect: c }) {
303
302
  "End"
304
303
  ].includes(e.key)) return;
305
304
  e.preventDefault();
306
- let n = u(y.length, y.indexOf(t.dataset.timeKey), e.key, (e) => p.has(y[e]));
305
+ let n = c(y.length, y.indexOf(t.dataset.timeKey), e.key, (e) => p.has(y[e]));
307
306
  n < 0 || f.current?.querySelector(`[data-time-key="${y[n]}"]`)?.focus();
308
307
  },
309
308
  children: y.map((e) => /* @__PURE__ */ m("button", {
@@ -316,7 +315,7 @@ function j({ column: r, length: i, value: a, p: s, onSelect: c }) {
316
315
  disabled: !p.has(e) || s.readOnly || s.disabled,
317
316
  onClick: () => {
318
317
  let t = p.get(e);
319
- t && c(t);
318
+ t && l(t);
320
319
  },
321
320
  children: r === 0 ? x.format(new Date(Date.UTC(2e3, 0, 1, Number(e)))) : e
322
321
  }, e))
@@ -353,7 +352,7 @@ function F(e, t) {
353
352
  let n = N(), r = te(P(), t) ?? (t.showSeconds === !1 ? "00:00" : "00:00:00");
354
353
  return e === "time" ? r : e === "datetime" ? `${n}T${r}` : e === "month" ? n.slice(0, 7) : e === "year" ? n.slice(0, 4) : n;
355
354
  }
356
- function I({ kind: t, range: u, p: g }) {
355
+ function I({ kind: t, range: c, p: g }) {
357
356
  let _ = o(), { text: y } = _, x = g, [S, C] = s(x.value, x.defaultValue ?? null, x.onChange), [w, T] = s(x.open, x.defaultOpen ?? !1, x.onOpenChange), E = !!(g.disabled || g.loading), D = w && !E, [k, j] = r([]), [N, I] = r(0), [L, R] = r(), [z, B] = r(!1), [V, H] = r(!1), [U, W] = r(() => (/* @__PURE__ */ new Date()).getFullYear() * 12 + (/* @__PURE__ */ new Date()).getMonth()), G = g.needConfirm ?? (t === "time" || t === "datetime"), K = Array.isArray(S) ? S : S ? [S] : [], q = n({
358
357
  open: !1,
359
358
  values: K
@@ -375,11 +374,11 @@ function I({ kind: t, range: u, p: g }) {
375
374
  }, [w, E]);
376
375
  let J = (e) => {
377
376
  e && E || (e && !D && ne(), !e && D && g.onBlur?.(), T(e));
378
- }, Y = (e) => O(e, t, u, g), X = (e, t = !0) => {
379
- E || g.readOnly || (!e.length && V ? (C(null), t && J(!1)) : Y(e) ? (B(!1), C(u ? [e[0], e[1]] : e[0]), t && J(!1)) : B(!0));
377
+ }, Y = (e) => O(e, t, c, g), X = (e, t = !0) => {
378
+ E || g.readOnly || (!e.length && V ? (C(null), t && J(!1)) : Y(e) ? (B(!1), C(c ? [e[0], e[1]] : e[0]), t && J(!1)) : B(!0));
380
379
  }, Z = (e, n = N) => {
381
380
  if (E || g.readOnly) return;
382
- if (B(!1), H(!1), !u) {
381
+ if (B(!1), H(!1), !c) {
383
382
  j([e]), G || X([e], t !== "time" && t !== "datetime");
384
383
  return;
385
384
  }
@@ -401,19 +400,19 @@ function I({ kind: t, range: u, p: g }) {
401
400
  }, g.showSeconds !== !1);
402
401
  let n = t === "time" ? `2000-01-01T${e}` : t === "month" ? `${e}-01` : t === "year" ? `${e}-01-01` : e;
403
402
  return i(n).format(g.format);
404
- }, $ = k[N] ?? F(t, x), re = u && [
403
+ }, $ = k[N] ?? F(t, x), re = c && [
405
404
  "date",
406
405
  "month",
407
406
  "year"
408
407
  ].includes(t), ie = t === "time" ? "clock" : "calendar", ae = () => {
409
408
  D && G ? (j([]), H(!0), B(!1)) : (C(null), j([]), B(!1));
410
409
  }, oe = g["aria-label"] ?? y.choose, se = (e) => te(e ?? P(), g) ?? e ?? P();
411
- return /* @__PURE__ */ m(d, {
410
+ return /* @__PURE__ */ m(u, {
412
411
  ...g,
413
412
  open: D,
414
413
  onOpenChange: J,
415
414
  label: oe,
416
- popupWidth: g.popupWidth ?? (u && (t === "time" || t === "datetime" || t === "date" && g.panels !== 1) ? 600 : t === "datetime" ? 480 : 300),
415
+ popupWidth: g.popupWidth ?? (c && (t === "time" || t === "datetime" || t === "date" && g.panels !== 1) ? 600 : t === "datetime" ? 480 : 300),
417
416
  popupMaxHeight: g.popupMaxHeight ?? 480,
418
417
  trigger: (e, n) => /* @__PURE__ */ m("div", {
419
418
  ref: n,
@@ -421,7 +420,7 @@ function I({ kind: t, range: u, p: g }) {
421
420
  onBlur: (e) => {
422
421
  !D && !e.currentTarget.contains(e.relatedTarget) && g.onBlur?.();
423
422
  },
424
- children: /* @__PURE__ */ m(c, {
423
+ children: /* @__PURE__ */ m(d, {
425
424
  ...g,
426
425
  className: [g.className, `rfe-picker-icon-${g.iconPosition ?? "start"}`].filter(Boolean).join(" "),
427
426
  actions: /* @__PURE__ */ h(p, { children: [g.clearable !== !1 && /* @__PURE__ */ m(l, {
@@ -452,7 +451,7 @@ function I({ kind: t, range: u, p: g }) {
452
451
  children: /* @__PURE__ */ m("div", {
453
452
  className: "rfe-value rfe-picker-value",
454
453
  onClick: () => J(!D),
455
- children: u ? /* @__PURE__ */ h(p, { children: [
454
+ children: c ? /* @__PURE__ */ h(p, { children: [
456
455
  /* @__PURE__ */ m("span", {
457
456
  className: K[0] ? "" : "rfe-placeholder",
458
457
  children: K[0] ? Q(K[0]) : g.placeholder ?? y.start
@@ -477,7 +476,7 @@ function I({ kind: t, range: u, p: g }) {
477
476
  className: "rfe-picker-panel",
478
477
  "data-readonly": g.readOnly || void 0,
479
478
  children: [
480
- u && /* @__PURE__ */ m("div", {
479
+ c && /* @__PURE__ */ m("div", {
481
480
  className: "rfe-range-tabs",
482
481
  role: "group",
483
482
  "aria-label": oe,
@@ -492,8 +491,8 @@ function I({ kind: t, range: u, p: g }) {
492
491
  }, e))
493
492
  }),
494
493
  t === "time" ? /* @__PURE__ */ m("div", {
495
- className: u ? "rfe-dual" : "",
496
- children: (u ? [0, 1] : [0]).map((e) => /* @__PURE__ */ m(M, {
494
+ className: c ? "rfe-dual" : "",
495
+ children: (c ? [0, 1] : [0]).map((e) => /* @__PURE__ */ m(M, {
497
496
  p: g,
498
497
  value: se(k[e]),
499
498
  onSelect: (t) => Z(t, e)
@@ -511,10 +510,10 @@ function I({ kind: t, range: u, p: g }) {
511
510
  onSelect: (e) => Z(`${$.slice(0, 10)}T${e}`, N)
512
511
  })]
513
512
  }) : /* @__PURE__ */ h("div", {
514
- className: u && t === "date" && g.panels !== 1 ? "rfe-dual rfe-date-dual" : void 0,
513
+ className: c && t === "date" && g.panels !== 1 ? "rfe-dual rfe-date-dual" : void 0,
515
514
  children: [/* @__PURE__ */ m(A, {
516
- monthCursor: u && t === "date" && g.panels !== 1 ? U : void 0,
517
- onMonthCursor: u && t === "date" && g.panels !== 1 ? W : void 0,
515
+ monthCursor: c && t === "date" && g.panels !== 1 ? U : void 0,
516
+ onMonthCursor: c && t === "date" && g.panels !== 1 ? W : void 0,
518
517
  kind: t,
519
518
  p: g,
520
519
  value: $,
@@ -523,7 +522,7 @@ function I({ kind: t, range: u, p: g }) {
523
522
  hover: L,
524
523
  onHover: R,
525
524
  onSelect: Z
526
- }), u && t === "date" && g.panels !== 1 && /* @__PURE__ */ m(A, {
525
+ }), c && t === "date" && g.panels !== 1 && /* @__PURE__ */ m(A, {
527
526
  monthCursor: U,
528
527
  onMonthCursor: W,
529
528
  kind: t,
@@ -567,7 +566,7 @@ function I({ kind: t, range: u, p: g }) {
567
566
  children: t === "time" ? y.now : y.today
568
567
  }),
569
568
  /* @__PURE__ */ m("span", { className: "rfe-spacer" }),
570
- (G || u || t === "time" || t === "datetime") && /* @__PURE__ */ h(p, { children: [G && /* @__PURE__ */ m("button", {
569
+ (G || c || t === "time" || t === "datetime") && /* @__PURE__ */ h(p, { children: [G && /* @__PURE__ */ m("button", {
571
570
  type: "button",
572
571
  className: "rfe-link",
573
572
  onClick: () => J(!1),
@@ -577,7 +576,7 @@ function I({ kind: t, range: u, p: g }) {
577
576
  "data-variant": "primary",
578
577
  type: "button",
579
578
  disabled: g.readOnly || E,
580
- onClick: () => X(V ? [] : k.length ? k : u ? [] : [F(t, x)]),
579
+ onClick: () => X(V ? [] : k.length ? k : c ? [] : [F(t, x)]),
581
580
  children: y.done
582
581
  })] })
583
582
  ]
package/dist/select.js CHANGED
@@ -1 +1 @@
1
- export { t as MultiSelect, n as Select } from "./Select-BG2H-YnK.js";
1
+ export { t as MultiSelect, n as Select } from "./Select-DiEHlcyU.js";
@@ -0,0 +1,190 @@
1
+ import { a as e, i as t, r as n, s as r } from "./useControllable-Dhp7tTjy.js";
2
+ import { t as i } from "./icons-D79FYcGF.js";
3
+ import { createContext as a, useCallback as o, useContext as s, useId as c, useLayoutEffect as l, useState as u, useSyncExternalStore as d } from "react";
4
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
5
+ import { FloatingFocusManager as m, FloatingNode as h, FloatingOverlay as g, FloatingPortal as _, FloatingTree as v, autoUpdate as y, flip as b, offset as x, shift as S, size as C, useDismiss as w, useFloating as T, useFloatingNodeId as ee, useFloatingTree as E, useInteractions as D, useRole as O, useTransitionStyles as k } from "@floating-ui/react";
6
+ // src/primitives/Control.tsx
7
+ function A({ children: e, actions: n, prefix: a, suffix: o, prefixIcon: s, suffixIcon: c, size: l, variant: u, status: d, disabled: m, readOnly: h, className: g, style: _, "aria-invalid": v }) {
8
+ let y = t();
9
+ return /* @__PURE__ */ p("div", {
10
+ className: r("rfe-control", g),
11
+ style: _,
12
+ "data-size": l ?? y.size,
13
+ "data-variant": u ?? y.variant,
14
+ "data-status": v ? "error" : d ?? "default",
15
+ "data-disabled": m || void 0,
16
+ "data-readonly": h || void 0,
17
+ children: [
18
+ (s || a) && /* @__PURE__ */ p("span", {
19
+ className: "rfe-affix",
20
+ children: [/* @__PURE__ */ f(i, { source: s }), a]
21
+ }),
22
+ e,
23
+ (c || o) && /* @__PURE__ */ p("span", {
24
+ className: "rfe-affix",
25
+ children: [/* @__PURE__ */ f(i, { source: c }), o]
26
+ }),
27
+ n
28
+ ]
29
+ });
30
+ }
31
+ function j({ name: e, source: t, label: n, onClick: r, disabled: a, hidden: o }) {
32
+ return /* @__PURE__ */ f("button", {
33
+ className: "rfe-action",
34
+ type: "button",
35
+ "aria-label": n,
36
+ title: n,
37
+ disabled: a || o,
38
+ style: o ? { visibility: "hidden" } : void 0,
39
+ onMouseDown: (e) => e.preventDefault(),
40
+ onClick: (e) => {
41
+ e.stopPropagation(), r();
42
+ },
43
+ children: /* @__PURE__ */ f(i, {
44
+ name: e,
45
+ source: t
46
+ })
47
+ });
48
+ }
49
+ // src/components/compound/context.ts
50
+ var M = a(null), N = () => s(M), P = "(max-width: 560px)", te = (e) => {
51
+ let t = window.matchMedia(P);
52
+ return t.addEventListener("change", e), () => t.removeEventListener("change", e);
53
+ }, F = () => typeof window < "u" && window.matchMedia(P).matches;
54
+ function I(e) {
55
+ return E() ? /* @__PURE__ */ f(L, { ...e }) : /* @__PURE__ */ f(v, { children: /* @__PURE__ */ f(L, { ...e }) });
56
+ }
57
+ function L({ open: r, onOpenChange: i, children: a, trigger: s, placement: v = "bottom-start", popupWidth: E = "trigger", popupMaxHeight: A = 320, portalContainer: j, role: M = "dialog", label: P, popupMode: I, layout: L = "content", initialFocus: R = 0 }) {
58
+ let z = N(), [B, V] = u(null), H = t(), U = e(), W = c(), G = ee(), K = d(te, F, () => !1), q = I ?? H.popupMode, J = q === "sheet" || q === "auto" && K, [Y, X] = u(null), { refs: Z, floatingStyles: ne, context: Q, placement: re } = T({
59
+ nodeId: G,
60
+ open: r,
61
+ onOpenChange: i,
62
+ placement: v,
63
+ strategy: J ? "fixed" : "absolute",
64
+ whileElementsMounted: J ? void 0 : y,
65
+ middleware: J ? [] : [
66
+ x(6),
67
+ b(),
68
+ S({ padding: 8 }),
69
+ C({
70
+ padding: 8,
71
+ apply({ availableHeight: e, availableWidth: t, rects: n, elements: r }) {
72
+ Object.assign(r.floating.style, {
73
+ maxHeight: `${Math.max(0, Math.min(e, A))}px`,
74
+ maxWidth: `${Math.max(0, t)}px`,
75
+ width: `${Math.max(0, Math.min(t, E === "trigger" ? n.reference.width : E))}px`
76
+ });
77
+ }
78
+ })
79
+ ]
80
+ }), ie = o((e) => {
81
+ Z.setFloating(e), V(e);
82
+ }, [Z.setFloating]);
83
+ l(() => {
84
+ if (r && B) return z?.registerPopup(B);
85
+ }, [
86
+ r,
87
+ B,
88
+ z
89
+ ]);
90
+ let ae = o((e) => {
91
+ Z.setReference(e), X(e?.closest("dialog[open]") ?? null);
92
+ }, [Z.setReference]), oe = w(Q, { bubbles: {
93
+ escapeKey: !1,
94
+ outsidePress: !0
95
+ } }), se = O(Q, { role: M }), { getReferenceProps: ce, getFloatingProps: le } = D([oe, se]), { isMounted: ue, styles: de } = k(Q, {
96
+ duration: H.motion ? {
97
+ open: 160,
98
+ close: 100
99
+ } : 0,
100
+ initial: ({ side: e }) => ({
101
+ opacity: 0,
102
+ transform: J ? "translateY(16px)" : `translateY(${e === "top" ? 4 : -4}px) scale(.985)`
103
+ })
104
+ }), fe = {
105
+ lang: U.code,
106
+ dir: U.direction,
107
+ "data-theme": H.theme,
108
+ "data-density": H.density,
109
+ "data-motion": H.motion ? "on" : "off"
110
+ }, $ = /* @__PURE__ */ f(m, {
111
+ context: Q,
112
+ modal: J,
113
+ initialFocus: R,
114
+ disabled: !r,
115
+ returnFocus: !0,
116
+ children: /* @__PURE__ */ f("div", {
117
+ ...fe,
118
+ className: "rfe-scope rfe-popup-position",
119
+ "data-sheet": J || void 0,
120
+ ref: ie,
121
+ style: {
122
+ ...n(H.tokens),
123
+ ...J ? {
124
+ position: "fixed",
125
+ insetInline: 0,
126
+ bottom: 0,
127
+ width: "100%",
128
+ maxWidth: "100%",
129
+ maxHeight: "85dvh"
130
+ } : ne
131
+ },
132
+ ...le({
133
+ id: W,
134
+ "aria-label": P,
135
+ "aria-modal": J || void 0
136
+ }),
137
+ children: /* @__PURE__ */ p("div", {
138
+ className: "rfe-panel",
139
+ "data-layout": L,
140
+ "data-side": re.split("-")[0],
141
+ style: {
142
+ ...de,
143
+ pointerEvents: r ? "auto" : "none"
144
+ },
145
+ inert: !r,
146
+ children: [J && /* @__PURE__ */ f("span", {
147
+ className: "rfe-sheet-handle",
148
+ "aria-hidden": "true"
149
+ }), a]
150
+ })
151
+ })
152
+ });
153
+ return /* @__PURE__ */ p(h, {
154
+ id: G,
155
+ children: [s(ce({
156
+ "aria-expanded": r,
157
+ "aria-controls": r ? W : void 0
158
+ }), ae, W), ue && /* @__PURE__ */ f(_, {
159
+ root: j ?? Y ?? void 0,
160
+ children: J ? /* @__PURE__ */ f(g, {
161
+ lockScroll: r,
162
+ className: "rfe-sheet-overlay",
163
+ style: n(H.tokens),
164
+ children: $
165
+ }) : $
166
+ })]
167
+ });
168
+ }
169
+ // src/utils/selection.ts
170
+ function R(e, t, n, r) {
171
+ if (e <= 0) return -1;
172
+ let i = n === "ArrowUp" || n === "End", a = i ? -1 : 1, o = n === "Home" ? 0 : n === "End" ? e - 1 : t < 0 ? i ? e - 1 : 0 : t + a;
173
+ for (; o >= 0 && o < e;) {
174
+ if (r(o)) return o;
175
+ o += a;
176
+ }
177
+ return t >= 0 && t < e && r(t) ? t : -1;
178
+ }
179
+ function z(e, t, n, r, i = 1, a = 4) {
180
+ if (e <= 0 || i <= 0 || !n) return 0;
181
+ let o = (o) => {
182
+ let s = 1, c = 0, l = t.slice(0, o).map((t) => Math.min(t, e));
183
+ o < n && l.push(Math.min(r, e));
184
+ for (let t of l) if (c && c + a + t > e && (s++, c = 0), c += t + (c ? a : 0), s > i) return !1;
185
+ return !0;
186
+ }, s = Math.min(t.length, n);
187
+ for (; s > 0 && !o(s);) s--;
188
+ return s;
189
+ }
190
+ export { N as a, M as i, R as n, j as o, I as r, A as s, z as t };
@@ -1,5 +1,5 @@
1
1
  import { useId as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
- import { a, i as o, s, t as c } from "./useControllable-Zax42z2F.js";
2
+ import { a, i as o, s, t as c } from "./useControllable-Dhp7tTjy.js";
3
3
  import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
4
4
  // src/components/slider/math.ts
5
5
  function f(e = 0, t = 100, n = 1) {
package/dist/slider.js CHANGED
@@ -1 +1 @@
1
- export { t as RangeSlider, n as Slider } from "./slider-CNwkLMmo.js";
1
+ export { t as RangeSlider, n as Slider } from "./slider-C2T2wII7.js";
@@ -287,7 +287,7 @@ function O(r = {}, i = {}) {
287
287
  for (let e of n) I(e, { touched: !0 });
288
288
  F(n);
289
289
  }
290
- return t.shouldValidate ? W(n) : Promise.resolve(!0);
290
+ return t.shouldValidate ? H(n) : Promise.resolve(!0);
291
291
  }
292
292
  let o = new Map(a.map((e) => [e, P(e)]));
293
293
  c && (S = i), w++;
@@ -342,7 +342,7 @@ function O(r = {}, i = {}) {
342
342
  I(e, { validating: !1 }), F([e]);
343
343
  }
344
344
  };
345
- }, H = (e, t) => {
345
+ }, ee = (e, t) => {
346
346
  let n = j.get(e);
347
347
  if (n) {
348
348
  for (let t of n.dependsOn ?? []) {
@@ -355,7 +355,7 @@ function O(r = {}, i = {}) {
355
355
  t || M.set(n, t = /* @__PURE__ */ new Set()), t.add(e);
356
356
  }
357
357
  }
358
- }, U = (n, r) => {
358
+ }, te = (n, r) => {
359
359
  T++, L(n);
360
360
  let i = typeof r == "object" ? r : void 0, a = typeof r == "object" ? t(e("en-US"), r.code, r.params) : r;
361
361
  I(n, {
@@ -363,15 +363,15 @@ function O(r = {}, i = {}) {
363
363
  issue: i,
364
364
  validating: !1
365
365
  }), F([n]);
366
- }, W = async (e = [...j.keys()]) => {
366
+ }, H = async (e = [...j.keys()]) => {
367
367
  let t = w, n = T, r = [...j.entries()], i = await Promise.all(e.filter(R).map((e) => z(e)));
368
368
  return t === w && n === T && r.length === j.size && r.every(([e, t]) => j.get(e) === t) && i.every(Boolean);
369
- }, G = (e) => {
369
+ }, ne = (e) => {
370
370
  let t = B({ [e]: p(x, e) }, { shouldValidate: !1 });
371
371
  L(e), N.delete(e), E.delete(e), F([e]);
372
372
  let n = [...M.get(e) ?? []].filter((e) => R(e) && (P(e).touched || j.get(e)?.validateOn === "change"));
373
- return t.then(() => W(n));
374
- }, ee = (e, t) => {
373
+ return t.then(() => H(n));
374
+ }, re = (e, t) => {
375
375
  let n = p(S, e), r = Array.isArray(n) ? n : [], i = f(r, t);
376
376
  if (!c) return B({ [e]: i });
377
377
  let a = f(r.map((e, t) => t), t.type === "insert" ? {
@@ -403,15 +403,15 @@ function O(r = {}, i = {}) {
403
403
  }));
404
404
  }
405
405
  return T++, F(s), u;
406
- }, K = () => [...j.keys()].filter((e) => !R(e)), q = (e, t) => t ? e : u(e, K()), J = (e = !0) => m(c ? q(S, e) : Object.fromEntries(Object.entries(S).filter(([t]) => e || R(t)))), Y = (e = !0) => {
406
+ }, U = () => [...j.keys()].filter((e) => !R(e)), W = (e, t) => t ? e : u(e, U()), G = (e = !0) => m(c ? W(S, e) : Object.fromEntries(Object.entries(S).filter(([t]) => e || R(t)))), K = (e = !0) => {
407
407
  if (!c) return m(Object.fromEntries([...N].filter((t) => e || R(t)).map((e) => [e, S[e]])));
408
- let t = q(S, e), n = q(x, e);
408
+ let t = W(S, e), n = W(x, e);
409
409
  return m(Object.fromEntries(Object.entries(t).filter(([e, t]) => !D(t, n[e]))));
410
- }, X = (e = !1) => v(J(c || e), a, c, c && !e ? K() : []), te = (e = !1) => {
411
- if (!c) return y(Y(e), J(e), a);
412
- let t = Y(e);
413
- return y(Object.fromEntries(Object.keys(t).map((e) => [e, S[e]])), J(), a, !0, e ? [] : K());
414
- }, Z = (e) => {
410
+ }, q = (e = !1) => v(G(c || e), a, c, c && !e ? U() : []), ie = (e = !1) => {
411
+ if (!c) return y(K(e), G(e), a);
412
+ let t = K(e);
413
+ return y(Object.fromEntries(Object.keys(t).map((e) => [e, S[e]])), G(), a, !0, e ? [] : U());
414
+ }, J = (e) => {
415
415
  let t = /* @__PURE__ */ new Set([
416
416
  ...Object.keys(S),
417
417
  ...E.keys(),
@@ -421,11 +421,25 @@ function O(r = {}, i = {}) {
421
421
  ]);
422
422
  for (let e of A.keys()) L(e);
423
423
  e && (x = Object.assign(Object.create(null), m(c ? d(e) : e))), w++, S = Object.assign(Object.create(null), m(x)), E.clear(), N.clear(), F(t);
424
+ }, Y = !1, X = 0, Z, ae = (e) => (Z = e, () => {
425
+ Z === e && (Z = void 0);
426
+ }), oe = async (e, t) => {
427
+ let n = Z, r = e ?? n?.handler ?? i.onSubmit;
428
+ if (!r || n?.blocked || Y) return !1;
429
+ Y = !0, X++, F([]);
430
+ try {
431
+ let e = w;
432
+ return !await H() || e !== w ? (n?.invalid?.(), !1) : (await r(q(t ?? n?.includeHidden ?? !1)), !0);
433
+ } finally {
434
+ Y = !1, F([]);
435
+ }
424
436
  }, Q = -1, $ = {
425
437
  isDirty: !1,
426
438
  isValid: !0,
427
439
  isValidating: !1,
428
- errorCount: 0
440
+ errorCount: 0,
441
+ isSubmitting: !1,
442
+ submitCount: 0
429
443
  };
430
444
  return {
431
445
  getFormSummary: () => {
@@ -435,21 +449,25 @@ function O(r = {}, i = {}) {
435
449
  isDirty: c ? !D(S, x) : N.size > 0,
436
450
  isValid: t === 0,
437
451
  isValidating: e.some((e) => e.validating),
438
- errorCount: t
452
+ errorCount: t,
453
+ isSubmitting: Y,
454
+ submitCount: X
439
455
  }, Q = C;
440
456
  }
441
457
  return $;
442
458
  },
459
+ submit: oe,
460
+ bindSubmission: ae,
443
461
  loadValues: (e) => {
444
462
  let t = _(e, a, c), n = Object.fromEntries([...j].filter(([, e]) => e.defaultValue !== void 0).map(([e, t]) => [e, t.defaultValue]));
445
- Z(g(g(b, c ? d(n) : n), t));
463
+ J(g(g(b, c ? d(n) : n), t));
446
464
  },
447
- getOutputValues: X,
448
- getChangedOutputValues: te,
449
- editFieldArray: ee,
465
+ getOutputValues: q,
466
+ getChangedOutputValues: ie,
467
+ editFieldArray: re,
450
468
  getValue: (e) => p(S, e),
451
- getValues: () => J(),
452
- getSubmitValues: X,
469
+ getValues: () => G(),
470
+ getSubmitValues: q,
453
471
  getFieldState: P,
454
472
  getVersion: () => C,
455
473
  getDataVersion: () => w,
@@ -463,14 +481,14 @@ function O(r = {}, i = {}) {
463
481
  k.delete(e);
464
482
  }),
465
483
  registerField: V,
466
- updateField: H,
484
+ updateField: ee,
467
485
  setValues: B,
468
486
  setValue: (e, t, n) => B({ [e]: t }, n),
469
487
  touch: (e) => {
470
488
  P(e).touched || (I(e, { touched: !0 }), F([e]));
471
489
  },
472
490
  blur: (e) => (P(e).touched || (I(e, { touched: !0 }), F([e])), (j.get(e)?.validateOn ?? "blur") === "blur" ? z(e) : Promise.resolve(!0)),
473
- setError: U,
491
+ setError: te,
474
492
  clearErrors: (e = [...E.keys()]) => {
475
493
  T++;
476
494
  for (let t of e) L(t), I(t, {
@@ -481,11 +499,11 @@ function O(r = {}, i = {}) {
481
499
  F(e);
482
500
  },
483
501
  validateField: z,
484
- validateFields: W,
485
- validate: () => W(),
486
- resetField: G,
487
- reset: Z,
488
- getChangedValues: () => Y()
502
+ validateFields: H,
503
+ validate: () => H(),
504
+ resetField: ne,
505
+ reset: J,
506
+ getChangedValues: () => K()
489
507
  };
490
508
  }
491
509
  export { u as _, C as a, p as c, f as d, i as f, d as g, o as h, w as i, _ as l, a as m, D as n, y as o, c as p, T as r, m as s, O as t, v as u, s as v, l as y };