reactaform 1.9.30 → 1.9.40
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/dist/reactaform.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as g, jsxs as z, Fragment as Fe } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
2
|
+
import * as c from "react";
|
|
3
3
|
import { createContext as st, useContext as ct, useRef as ge, useEffect as We, useCallback as he } from "react";
|
|
4
4
|
import * as fe from "react-dom";
|
|
5
5
|
const lt = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
@@ -448,7 +448,7 @@ class ae {
|
|
|
448
448
|
}
|
|
449
449
|
const ar = typeof process < "u" && process.env.NODE_ENV === "test";
|
|
450
450
|
function ut(e, r = 300, t) {
|
|
451
|
-
const n = ge(), o = ge(e), a = ge(null),
|
|
451
|
+
const n = ge(), o = ge(e), a = ge(null), s = t?.leading === !0, l = t?.trailing !== !1;
|
|
452
452
|
We(() => {
|
|
453
453
|
o.current = e;
|
|
454
454
|
}, [e]), We(() => () => {
|
|
@@ -458,7 +458,7 @@ function ut(e, r = 300, t) {
|
|
|
458
458
|
o.current(...f);
|
|
459
459
|
}, u = he(() => {
|
|
460
460
|
n.current && (clearTimeout(n.current), n.current = void 0), a.current = null;
|
|
461
|
-
}, []),
|
|
461
|
+
}, []), m = he(() => {
|
|
462
462
|
n.current && (clearTimeout(n.current), n.current = void 0), l && a.current && (i(a.current), a.current = null);
|
|
463
463
|
}, [l]);
|
|
464
464
|
return { callback: he(
|
|
@@ -467,13 +467,13 @@ function ut(e, r = 300, t) {
|
|
|
467
467
|
i(f);
|
|
468
468
|
return;
|
|
469
469
|
}
|
|
470
|
-
const h =
|
|
470
|
+
const h = s && !n.current;
|
|
471
471
|
a.current = f, h && i(f), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
|
|
472
472
|
n.current = void 0, l && a.current && (i(a.current), a.current = null);
|
|
473
473
|
}, r);
|
|
474
474
|
},
|
|
475
|
-
[
|
|
476
|
-
), cancel: u, flush:
|
|
475
|
+
[s, l, r]
|
|
476
|
+
), cancel: u, flush: m };
|
|
477
477
|
}
|
|
478
478
|
const R = {
|
|
479
479
|
field: "reactaform-field",
|
|
@@ -501,11 +501,11 @@ function mt(e) {
|
|
|
501
501
|
const r = e.trim();
|
|
502
502
|
let t = 0, n = 0, o = 0;
|
|
503
503
|
if (r.startsWith("#")) {
|
|
504
|
-
const
|
|
505
|
-
|
|
504
|
+
const s = r.substring(1);
|
|
505
|
+
s.length === 3 || s.length === 4 ? (t = parseInt(s[0] + s[0], 16), n = parseInt(s[1] + s[1], 16), o = parseInt(s[2] + s[2], 16)) : (s.length === 6 || s.length === 8) && (t = parseInt(s.substring(0, 2), 16), n = parseInt(s.substring(2, 4), 16), o = parseInt(s.substring(4, 6), 16));
|
|
506
506
|
} else if (r.startsWith("rgb")) {
|
|
507
|
-
const
|
|
508
|
-
|
|
507
|
+
const s = r.match(/\d+(\.\d+)?/g);
|
|
508
|
+
s && s.length >= 3 && (t = Math.min(255, Math.max(0, parseFloat(s[0]))), n = Math.min(255, Math.max(0, parseFloat(s[1]))), o = Math.min(255, Math.max(0, parseFloat(s[2]))));
|
|
509
509
|
} else
|
|
510
510
|
return !1;
|
|
511
511
|
return (t * 299 + n * 587 + o * 114) / 1e3 < 128;
|
|
@@ -527,17 +527,17 @@ const dt = () => /* @__PURE__ */ z(
|
|
|
527
527
|
]
|
|
528
528
|
}
|
|
529
529
|
), ft = ({ content: e, size: r = "medium", animation: t = !0 }) => {
|
|
530
|
-
const { t: n, theme: o, formStyle: a, fieldStyle:
|
|
531
|
-
|
|
530
|
+
const { t: n, theme: o, formStyle: a, fieldStyle: s } = j(), [l, i] = c.useState(!1), [u, m] = c.useState({ x: 0, y: 0 }), [d, f] = c.useState(!1), h = c.useRef(null), k = c.useRef(null), v = c.useRef(null), p = c.useId(), y = ce(o), [C, V] = c.useState(void 0);
|
|
531
|
+
c.useLayoutEffect(() => {
|
|
532
532
|
if (!h.current) return;
|
|
533
533
|
const F = "rgba(255,255,255,0.1)", x = getComputedStyle(h.current).getPropertyValue("--reactaform-primary-bg").trim();
|
|
534
534
|
if (x && typeof CSS < "u" && CSS.supports?.("color: color-mix(in srgb, red, blue)")) {
|
|
535
|
-
const
|
|
536
|
-
V(`color-mix(in srgb, var(--reactaform-primary-bg) 85%, ${
|
|
535
|
+
const E = mt(x) ? "black" : "white";
|
|
536
|
+
V(`color-mix(in srgb, var(--reactaform-primary-bg) 85%, ${E} 15%)`);
|
|
537
537
|
} else
|
|
538
538
|
V(F);
|
|
539
539
|
}, []);
|
|
540
|
-
const A =
|
|
540
|
+
const A = c.useMemo(() => {
|
|
541
541
|
const b = {
|
|
542
542
|
icon: {
|
|
543
543
|
display: "inline-flex",
|
|
@@ -582,50 +582,50 @@ const dt = () => /* @__PURE__ */ z(
|
|
|
582
582
|
opacity: 1,
|
|
583
583
|
pointerEvents: "auto"
|
|
584
584
|
}
|
|
585
|
-
}, x = (w, S,
|
|
586
|
-
const
|
|
587
|
-
return (
|
|
585
|
+
}, x = (w, S, N) => {
|
|
586
|
+
const L = w?.[S];
|
|
587
|
+
return (N && L ? L[N] : void 0) ?? {};
|
|
588
588
|
};
|
|
589
589
|
return {
|
|
590
|
-
icon: { ...b.icon, ...x(a, "tooltip", "icon"), ...x(
|
|
591
|
-
text: { ...b.text, ...x(a, "tooltip", "text"), ...x(
|
|
590
|
+
icon: { ...b.icon, ...x(a, "tooltip", "icon"), ...x(s, "tooltip", "icon") },
|
|
591
|
+
text: { ...b.text, ...x(a, "tooltip", "text"), ...x(s, "tooltip", "text") },
|
|
592
592
|
textVisible: b.textVisible
|
|
593
593
|
};
|
|
594
|
-
}, [y, r, t, a,
|
|
595
|
-
|
|
596
|
-
if (!l || !h.current || !
|
|
594
|
+
}, [y, r, t, a, s, C]);
|
|
595
|
+
c.useLayoutEffect(() => {
|
|
596
|
+
if (!l || !h.current || !k.current) {
|
|
597
597
|
f(!1);
|
|
598
598
|
return;
|
|
599
599
|
}
|
|
600
600
|
const F = h.current.getBoundingClientRect();
|
|
601
601
|
v.current = F;
|
|
602
|
-
const b =
|
|
603
|
-
let
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
if (
|
|
607
|
-
const
|
|
602
|
+
const b = k.current.getBoundingClientRect(), x = 8, E = window.innerWidth, w = window.innerHeight, S = -4;
|
|
603
|
+
let N = F.right + x, $ = F.top + F.height / 2 - b.height / 2 + S;
|
|
604
|
+
N + b.width > E - x && (N = F.left - x - b.width), N = Math.max(x, Math.min(N, E - b.width - x)), $ = Math.max(x, Math.min($, w - b.height - x)), m({ x: N, y: $ }), f(!0);
|
|
605
|
+
const L = h.current.closest("[data-reactaform-theme]"), q = document.getElementById("popup-root");
|
|
606
|
+
if (L && q) {
|
|
607
|
+
const X = getComputedStyle(L);
|
|
608
608
|
q.style.setProperty(
|
|
609
609
|
"--reactaform-tooltip-color-bg",
|
|
610
|
-
|
|
610
|
+
X.getPropertyValue("--reactaform-tooltip-color-bg")
|
|
611
611
|
), q.style.setProperty(
|
|
612
612
|
"--reactaform-tooltip-color",
|
|
613
|
-
|
|
613
|
+
X.getPropertyValue("--reactaform-tooltip-color")
|
|
614
614
|
);
|
|
615
615
|
}
|
|
616
616
|
}, [l]);
|
|
617
617
|
const I = typeof document < "u" ? document.getElementById("popup-root") : null, M = /* @__PURE__ */ g(
|
|
618
618
|
"div",
|
|
619
619
|
{
|
|
620
|
-
ref:
|
|
620
|
+
ref: k,
|
|
621
621
|
"data-tooltip-id": p,
|
|
622
622
|
style: {
|
|
623
623
|
...A.text,
|
|
624
|
-
transform:
|
|
624
|
+
transform: d ? "translateY(0) scale(1)" : "translateY(-4px) scale(0.98)",
|
|
625
625
|
transition: "opacity 120ms ease, transform 120ms ease, visibility 120ms ease",
|
|
626
626
|
width: 240,
|
|
627
627
|
// When positioned is true, apply the visible styles
|
|
628
|
-
...
|
|
628
|
+
...d ? A.textVisible : {},
|
|
629
629
|
top: u.y,
|
|
630
630
|
left: u.x
|
|
631
631
|
},
|
|
@@ -649,32 +649,32 @@ const dt = () => /* @__PURE__ */ z(
|
|
|
649
649
|
),
|
|
650
650
|
l && (I ? fe.createPortal(M, I) : M)
|
|
651
651
|
] });
|
|
652
|
-
}, ir =
|
|
652
|
+
}, ir = c.memo(ft), xe = c.memo(({
|
|
653
653
|
field: e,
|
|
654
654
|
error: r,
|
|
655
655
|
children: t,
|
|
656
656
|
showLabel: n = !0
|
|
657
657
|
}) => {
|
|
658
|
-
const { t: o } = j(), a = e.labelLayout === "column-center" ? "center" : "left",
|
|
658
|
+
const { t: o } = j(), a = e.labelLayout === "column-center" ? "center" : "left", s = c.useMemo(() => {
|
|
659
659
|
const u = {
|
|
660
660
|
display: "flex",
|
|
661
661
|
flexDirection: "column",
|
|
662
662
|
gap: "var(--reactaform-label-gap, 4px)"
|
|
663
663
|
};
|
|
664
664
|
return u["--label-align"] = a, u;
|
|
665
|
-
}, [a]), l =
|
|
665
|
+
}, [a]), l = c.useMemo(() => ({
|
|
666
666
|
textAlign: a,
|
|
667
667
|
width: "100%",
|
|
668
668
|
minWidth: "unset",
|
|
669
669
|
display: "block",
|
|
670
670
|
marginBottom: "10px"
|
|
671
|
-
}), [a]), i =
|
|
671
|
+
}), [a]), i = c.useMemo(() => ({
|
|
672
672
|
display: "flex",
|
|
673
673
|
alignItems: "center",
|
|
674
674
|
gap: "var(--reactaform-inline-gap, 8px)",
|
|
675
675
|
width: "100%"
|
|
676
676
|
}), []);
|
|
677
|
-
return /* @__PURE__ */ z("div", { className: `${R.field} column-layout`, style:
|
|
677
|
+
return /* @__PURE__ */ z("div", { className: `${R.field} column-layout`, style: s, children: [
|
|
678
678
|
n && /* @__PURE__ */ g(
|
|
679
679
|
"label",
|
|
680
680
|
{
|
|
@@ -693,13 +693,13 @@ const dt = () => /* @__PURE__ */ z(
|
|
|
693
693
|
] });
|
|
694
694
|
});
|
|
695
695
|
xe.displayName = "ColumnFieldLayout";
|
|
696
|
-
const sr =
|
|
696
|
+
const sr = c.memo(({
|
|
697
697
|
field: e,
|
|
698
698
|
error: r,
|
|
699
699
|
children: t,
|
|
700
700
|
rightAlign: n = !1
|
|
701
701
|
}) => {
|
|
702
|
-
const { t: o } = j(), a =
|
|
702
|
+
const { t: o } = j(), a = c.useMemo(() => ({
|
|
703
703
|
display: "flex",
|
|
704
704
|
alignItems: "center",
|
|
705
705
|
gap: "3px"
|
|
@@ -725,15 +725,15 @@ const sr = s.memo(({
|
|
|
725
725
|
] });
|
|
726
726
|
});
|
|
727
727
|
sr.displayName = "RowFieldLayout";
|
|
728
|
-
const
|
|
728
|
+
const B = c.memo(({
|
|
729
729
|
field: e,
|
|
730
730
|
error: r,
|
|
731
731
|
children: t,
|
|
732
732
|
rightAlign: n = !1
|
|
733
733
|
}) => e.labelLayout === "column-left" || e.labelLayout === "column-center" ? /* @__PURE__ */ g(xe, { field: e, error: r, showLabel: !0, children: t }) : e.type === "checkbox" || e.type === "switch" ? /* @__PURE__ */ g(xe, { field: e, error: r, showLabel: !1, children: t }) : /* @__PURE__ */ g(sr, { field: e, error: r, rightAlign: n, children: t }));
|
|
734
|
-
|
|
735
|
-
const Ve =
|
|
736
|
-
const t =
|
|
734
|
+
B.displayName = "StandardFieldLayout";
|
|
735
|
+
const Ve = c.memo(({ children: e, id: r }) => {
|
|
736
|
+
const t = c.useMemo(() => ({
|
|
737
737
|
color: "var(--reactaform-error-color, red)",
|
|
738
738
|
fontSize: "13px",
|
|
739
739
|
marginTop: "4px",
|
|
@@ -747,7 +747,7 @@ const Ve = s.memo(({ children: e, id: r }) => {
|
|
|
747
747
|
return /* @__PURE__ */ g("div", { id: r, style: t, children: e });
|
|
748
748
|
});
|
|
749
749
|
Ve.displayName = "ErrorDiv";
|
|
750
|
-
const cr =
|
|
750
|
+
const cr = c.memo(({ name: e, onChange: r }) => {
|
|
751
751
|
const { t } = j();
|
|
752
752
|
return /* @__PURE__ */ z("div", { style: { marginBottom: 16 }, children: [
|
|
753
753
|
/* @__PURE__ */ z("div", { style: { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 12, alignItems: "center" }, children: [
|
|
@@ -844,9 +844,9 @@ function pr(e, r, t, n) {
|
|
|
844
844
|
return null;
|
|
845
845
|
} else
|
|
846
846
|
return null;
|
|
847
|
-
const
|
|
848
|
-
let l = _e.get(
|
|
849
|
-
if (l === void 0 && (l = mr(o, a) || null, _e.set(
|
|
847
|
+
const s = `${o}:${a}`;
|
|
848
|
+
let l = _e.get(s);
|
|
849
|
+
if (l === void 0 && (l = mr(o, a) || null, _e.set(s, l)), l)
|
|
850
850
|
try {
|
|
851
851
|
return l(r.name, t, n) || null;
|
|
852
852
|
} catch (i) {
|
|
@@ -883,8 +883,8 @@ async function vt(e, r, t) {
|
|
|
883
883
|
}
|
|
884
884
|
function T(e, r) {
|
|
885
885
|
const { definitionName: t, t: n, fieldValidationMode: o } = j();
|
|
886
|
-
return
|
|
887
|
-
(a,
|
|
886
|
+
return c.useCallback(
|
|
887
|
+
(a, s = "change") => o === "onEdit" || o === "realTime" || o === "onBlur" && s === "blur" ? we(t, e, a, n) : r ?? null,
|
|
888
888
|
[t, e, n, o, r]
|
|
889
889
|
);
|
|
890
890
|
}
|
|
@@ -895,40 +895,40 @@ const gr = ({
|
|
|
895
895
|
onError: n,
|
|
896
896
|
error: o
|
|
897
897
|
}) => {
|
|
898
|
-
const { t: a } = j(),
|
|
899
|
-
|
|
898
|
+
const { t: a } = j(), s = T(e, o), l = c.useRef(n), [i, u] = c.useState(null), m = c.useRef(null);
|
|
899
|
+
c.useEffect(() => {
|
|
900
900
|
l.current = n;
|
|
901
|
-
}, [n]),
|
|
902
|
-
const p =
|
|
903
|
-
p !==
|
|
904
|
-
}, [r,
|
|
905
|
-
const
|
|
901
|
+
}, [n]), c.useEffect(() => {
|
|
902
|
+
const p = s(r, "sync");
|
|
903
|
+
p !== m.current && (m.current = p, u(p), o || l.current?.(p ?? null));
|
|
904
|
+
}, [r, s, o]);
|
|
905
|
+
const d = c.useCallback(
|
|
906
906
|
(p) => {
|
|
907
|
-
p !==
|
|
907
|
+
p !== m.current && (m.current = p, u(p), o || l.current?.(p ?? null));
|
|
908
908
|
},
|
|
909
909
|
[o]
|
|
910
|
-
), f =
|
|
910
|
+
), f = c.useCallback(
|
|
911
911
|
(p) => {
|
|
912
912
|
const y = p.target.checked;
|
|
913
|
-
|
|
913
|
+
d(s(y, "change")), t?.(y);
|
|
914
914
|
},
|
|
915
|
-
[t,
|
|
916
|
-
), h =
|
|
915
|
+
[t, d, s]
|
|
916
|
+
), h = c.useCallback(
|
|
917
917
|
(p) => {
|
|
918
918
|
if (p.key === " " || p.key === "Space" || p.key === "Spacebar" || p.code === "Space" || p.key === "Enter") {
|
|
919
919
|
p.preventDefault();
|
|
920
920
|
const C = !r;
|
|
921
|
-
|
|
921
|
+
d(s(C, "change")), t?.(C);
|
|
922
922
|
}
|
|
923
923
|
},
|
|
924
|
-
[t, r,
|
|
925
|
-
),
|
|
924
|
+
[t, r, d, s]
|
|
925
|
+
), k = c.useCallback(
|
|
926
926
|
(p) => {
|
|
927
|
-
|
|
927
|
+
d(s(p.target.checked, "blur"));
|
|
928
928
|
},
|
|
929
|
-
[
|
|
929
|
+
[d, s]
|
|
930
930
|
), v = e.name;
|
|
931
|
-
return /* @__PURE__ */ g(
|
|
931
|
+
return /* @__PURE__ */ g(B, { field: e, rightAlign: !1, error: i, children: /* @__PURE__ */ z(
|
|
932
932
|
"div",
|
|
933
933
|
{
|
|
934
934
|
style: {
|
|
@@ -956,7 +956,7 @@ const gr = ({
|
|
|
956
956
|
checked: r,
|
|
957
957
|
onChange: f,
|
|
958
958
|
onKeyDown: h,
|
|
959
|
-
onBlur:
|
|
959
|
+
onBlur: k,
|
|
960
960
|
"aria-checked": r,
|
|
961
961
|
"aria-invalid": !!i,
|
|
962
962
|
"aria-describedby": i ? `${e.name}-error` : void 0,
|
|
@@ -975,35 +975,43 @@ const gr = ({
|
|
|
975
975
|
) });
|
|
976
976
|
};
|
|
977
977
|
gr.displayName = "CheckboxInput";
|
|
978
|
-
const xt =
|
|
979
|
-
function K({ value: e,
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}, [
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
978
|
+
const xt = c.memo(gr);
|
|
979
|
+
function K({ value: e, disabled: r, onChange: t, onError: n, validate: o }) {
|
|
980
|
+
const a = c.useRef(null), s = c.useRef(null), l = c.useRef(n), [i, u] = c.useState(null);
|
|
981
|
+
c.useEffect(() => {
|
|
982
|
+
l.current = n;
|
|
983
|
+
}, [n]), c.useEffect(() => {
|
|
984
|
+
if (r) {
|
|
985
|
+
s.current !== null && (s.current = null, l.current?.(null), u(null));
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const f = String(e ?? "");
|
|
989
|
+
if (!(document.activeElement === a.current)) {
|
|
990
|
+
const k = o(f, "sync");
|
|
991
|
+
k !== s.current && (s.current = k, l.current?.(k ?? null), u(k)), a.current && a.current.value !== f && (a.current.value = f);
|
|
988
992
|
}
|
|
989
|
-
}, [e,
|
|
990
|
-
const
|
|
991
|
-
(
|
|
992
|
-
|
|
993
|
-
|
|
993
|
+
}, [e, o, r]);
|
|
994
|
+
const m = c.useCallback(
|
|
995
|
+
(f) => {
|
|
996
|
+
if (r)
|
|
997
|
+
return;
|
|
998
|
+
const h = f.target.value, k = o(h, "change");
|
|
999
|
+
k !== s.current && (s.current = k, u(k), l.current?.(k ?? null)), t?.(h);
|
|
994
1000
|
},
|
|
995
|
-
[
|
|
996
|
-
), d =
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1001
|
+
[t, o, r]
|
|
1002
|
+
), d = c.useCallback(() => {
|
|
1003
|
+
if (r)
|
|
1004
|
+
return;
|
|
1005
|
+
const f = String(a.current?.value ?? e ?? ""), h = o(f, "blur");
|
|
1006
|
+
h !== s.current && (s.current = h, u(h), l.current?.(h ?? null));
|
|
1007
|
+
}, [o, e, r]);
|
|
1008
|
+
return c.useEffect(() => {
|
|
1009
|
+
const f = a.current;
|
|
1010
|
+
if (f)
|
|
1011
|
+
return f.addEventListener("blur", d), () => {
|
|
1012
|
+
f.removeEventListener("blur", d);
|
|
1005
1013
|
};
|
|
1006
|
-
}, [d]), { inputRef:
|
|
1014
|
+
}, [d]), { inputRef: a, error: i, handleChange: m, handleBlur: d };
|
|
1007
1015
|
}
|
|
1008
1016
|
const Ge = [
|
|
1009
1017
|
{ label: "Black", value: "#000000" },
|
|
@@ -1038,42 +1046,42 @@ const Ge = [
|
|
|
1038
1046
|
onError: n,
|
|
1039
1047
|
error: o
|
|
1040
1048
|
}) => {
|
|
1041
|
-
const { t: a } = j(),
|
|
1049
|
+
const { t: a } = j(), s = T(e, o), l = c.useMemo(
|
|
1042
1050
|
() => be(r),
|
|
1043
1051
|
[r]
|
|
1044
|
-
), { inputRef: i, error: u, handleChange:
|
|
1052
|
+
), { inputRef: i, error: u, handleChange: m, handleBlur: d } = K({
|
|
1045
1053
|
value: l,
|
|
1046
1054
|
onChange: t,
|
|
1047
1055
|
onError: n,
|
|
1048
|
-
validate:
|
|
1049
|
-
}), [f, h] =
|
|
1050
|
-
|
|
1056
|
+
validate: s
|
|
1057
|
+
}), [f, h] = c.useState(l);
|
|
1058
|
+
c.useEffect(() => {
|
|
1051
1059
|
h(l);
|
|
1052
1060
|
}, [l]);
|
|
1053
|
-
const
|
|
1061
|
+
const k = c.useCallback(
|
|
1054
1062
|
(I) => {
|
|
1055
1063
|
const M = be(I.target.value);
|
|
1056
|
-
h(M),
|
|
1064
|
+
h(M), m({
|
|
1057
1065
|
target: { value: M }
|
|
1058
1066
|
});
|
|
1059
1067
|
},
|
|
1060
|
-
[
|
|
1061
|
-
), v =
|
|
1068
|
+
[m]
|
|
1069
|
+
), v = c.useCallback(
|
|
1062
1070
|
(I) => {
|
|
1063
1071
|
const M = be(I.target.value);
|
|
1064
|
-
h(M),
|
|
1072
|
+
h(M), m({
|
|
1065
1073
|
target: { value: M }
|
|
1066
1074
|
});
|
|
1067
1075
|
},
|
|
1068
|
-
[
|
|
1069
|
-
), y =
|
|
1076
|
+
[m]
|
|
1077
|
+
), y = c.useMemo(
|
|
1070
1078
|
() => new Set(Ge.map((I) => I.value)),
|
|
1071
1079
|
[]
|
|
1072
|
-
).has(f), { r: C, g: V, b: A } =
|
|
1080
|
+
).has(f), { r: C, g: V, b: A } = c.useMemo(
|
|
1073
1081
|
() => kt(f),
|
|
1074
1082
|
[f]
|
|
1075
1083
|
);
|
|
1076
|
-
return /* @__PURE__ */ g(
|
|
1084
|
+
return /* @__PURE__ */ g(B, { field: e, error: u, children: /* @__PURE__ */ z(
|
|
1077
1085
|
"div",
|
|
1078
1086
|
{
|
|
1079
1087
|
style: {
|
|
@@ -1089,7 +1097,7 @@ const Ge = [
|
|
|
1089
1097
|
id: e.name,
|
|
1090
1098
|
value: f,
|
|
1091
1099
|
onChange: v,
|
|
1092
|
-
onBlur:
|
|
1100
|
+
onBlur: d,
|
|
1093
1101
|
className: W(
|
|
1094
1102
|
R.input,
|
|
1095
1103
|
R.inputSelect
|
|
@@ -1129,8 +1137,8 @@ const Ge = [
|
|
|
1129
1137
|
id: `${e.name}-color`,
|
|
1130
1138
|
type: "color",
|
|
1131
1139
|
defaultValue: f,
|
|
1132
|
-
onChange:
|
|
1133
|
-
onBlur:
|
|
1140
|
+
onChange: k,
|
|
1141
|
+
onBlur: d,
|
|
1134
1142
|
style: { opacity: 0, width: "100%", height: "100%" },
|
|
1135
1143
|
"aria-invalid": !!u
|
|
1136
1144
|
}
|
|
@@ -1142,7 +1150,7 @@ const Ge = [
|
|
|
1142
1150
|
) });
|
|
1143
1151
|
};
|
|
1144
1152
|
hr.displayName = "ColorInput";
|
|
1145
|
-
const Nt =
|
|
1153
|
+
const Nt = c.memo(hr), Je = (e) => {
|
|
1146
1154
|
if (!e) return null;
|
|
1147
1155
|
const r = new Date(e);
|
|
1148
1156
|
return isNaN(r.getTime()) ? null : r;
|
|
@@ -1163,13 +1171,13 @@ const Nt = s.memo(hr), Je = (e) => {
|
|
|
1163
1171
|
onError: n,
|
|
1164
1172
|
error: o
|
|
1165
1173
|
}) => {
|
|
1166
|
-
const a = T(e, o),
|
|
1167
|
-
value:
|
|
1174
|
+
const a = T(e, o), s = Ye(r), { inputRef: l, error: i, handleChange: u } = K({
|
|
1175
|
+
value: s,
|
|
1168
1176
|
onChange: t,
|
|
1169
1177
|
onError: n,
|
|
1170
1178
|
validate: a
|
|
1171
1179
|
});
|
|
1172
|
-
return /* @__PURE__ */ g(
|
|
1180
|
+
return /* @__PURE__ */ g(B, { field: e, error: i, children: /* @__PURE__ */ g(
|
|
1173
1181
|
"input",
|
|
1174
1182
|
{
|
|
1175
1183
|
id: e.name,
|
|
@@ -1186,7 +1194,7 @@ const Nt = s.memo(hr), Je = (e) => {
|
|
|
1186
1194
|
) });
|
|
1187
1195
|
};
|
|
1188
1196
|
br.displayName = "DateInput";
|
|
1189
|
-
const Et =
|
|
1197
|
+
const Et = c.memo(br), yr = ({ field: e }) => {
|
|
1190
1198
|
const { t: r } = j(), { displayText: t = "", textAlign: n = "left", allowHtml: o = !1 } = e;
|
|
1191
1199
|
return /* @__PURE__ */ g(
|
|
1192
1200
|
"div",
|
|
@@ -1198,45 +1206,45 @@ const Et = s.memo(br), yr = ({ field: e }) => {
|
|
|
1198
1206
|
);
|
|
1199
1207
|
};
|
|
1200
1208
|
yr.displayName = "Description";
|
|
1201
|
-
const It =
|
|
1209
|
+
const It = c.memo(yr), vr = ({
|
|
1202
1210
|
field: e,
|
|
1203
1211
|
value: r,
|
|
1204
1212
|
onChange: t,
|
|
1205
1213
|
onError: n,
|
|
1206
1214
|
error: o
|
|
1207
1215
|
}) => {
|
|
1208
|
-
const { t: a, theme:
|
|
1209
|
-
|
|
1210
|
-
|
|
1216
|
+
const { t: a, theme: s, formStyle: l, fieldStyle: i } = j(), u = c.useRef(null), m = c.useRef(n), [d, f] = c.useState(!1), [h, k] = c.useState(null);
|
|
1217
|
+
c.useEffect(() => {
|
|
1218
|
+
m.current = n;
|
|
1211
1219
|
}, [n]);
|
|
1212
|
-
const v = T(e, o), [p, y] =
|
|
1213
|
-
|
|
1214
|
-
const
|
|
1215
|
-
let w = v(
|
|
1220
|
+
const v = T(e, o), [p, y] = c.useState(null), C = c.useRef(null);
|
|
1221
|
+
c.useEffect(() => {
|
|
1222
|
+
const E = String(r ?? "");
|
|
1223
|
+
let w = v(E, "sync");
|
|
1216
1224
|
if (w && e.options.length > 0) {
|
|
1217
1225
|
const S = String(e.options[0].value);
|
|
1218
1226
|
t?.(S), w = null;
|
|
1219
1227
|
}
|
|
1220
|
-
w !== C.current && (C.current = w, y(w),
|
|
1228
|
+
w !== C.current && (C.current = w, y(w), m.current?.(w ?? null));
|
|
1221
1229
|
}, [r, v, t, e.options]);
|
|
1222
1230
|
const V = () => {
|
|
1223
1231
|
if (!u.current) return;
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1226
|
-
}, A = (
|
|
1227
|
-
const w = v(
|
|
1228
|
-
w !== C.current && (C.current = w, y(w),
|
|
1229
|
-
}, I =
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
}, [v, r]), M =
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1235
|
-
}, [e.options, r, a]), F = (
|
|
1232
|
+
const E = u.current.getBoundingClientRect();
|
|
1233
|
+
k({ x: E.left, y: E.bottom }), f((w) => !w);
|
|
1234
|
+
}, A = (E) => {
|
|
1235
|
+
const w = v(E, "change");
|
|
1236
|
+
w !== C.current && (C.current = w, y(w), m.current?.(w ?? null)), t?.(E), f(!1);
|
|
1237
|
+
}, I = c.useCallback(() => {
|
|
1238
|
+
const E = v(String(r ?? ""), "blur");
|
|
1239
|
+
E !== C.current && (C.current = E, y(E), m.current?.(E ?? null));
|
|
1240
|
+
}, [v, r]), M = c.useMemo(() => {
|
|
1241
|
+
const E = e.options.find((w) => String(w.value) === String(r));
|
|
1242
|
+
return E ? a(E.label) : "";
|
|
1243
|
+
}, [e.options, r, a]), F = (E, w, S) => {
|
|
1236
1244
|
if (!w) return {};
|
|
1237
|
-
const $ =
|
|
1245
|
+
const $ = E?.[w];
|
|
1238
1246
|
return (S && $ ? $[S] : void 0) ?? {};
|
|
1239
|
-
}, b =
|
|
1247
|
+
}, b = c.useMemo(() => ({
|
|
1240
1248
|
height: "var(--reactaform-input-height, 2.5em)",
|
|
1241
1249
|
display: "flex",
|
|
1242
1250
|
alignItems: "center",
|
|
@@ -1247,7 +1255,7 @@ const It = s.memo(yr), vr = ({
|
|
|
1247
1255
|
textAlign: "left",
|
|
1248
1256
|
...F(l, "dropdown", "control"),
|
|
1249
1257
|
...F(i, void 0, "control")
|
|
1250
|
-
}), [l, i]), x =
|
|
1258
|
+
}), [l, i]), x = c.useMemo(() => ({
|
|
1251
1259
|
position: "absolute",
|
|
1252
1260
|
right: "0.7em",
|
|
1253
1261
|
top: "50%",
|
|
@@ -1259,7 +1267,7 @@ const It = s.memo(yr), vr = ({
|
|
|
1259
1267
|
...F(i, void 0, "arrow")
|
|
1260
1268
|
}), [l, i]);
|
|
1261
1269
|
return /* @__PURE__ */ z("div", { children: [
|
|
1262
|
-
/* @__PURE__ */ g(
|
|
1270
|
+
/* @__PURE__ */ g(B, { field: e, error: p, children: /* @__PURE__ */ z(
|
|
1263
1271
|
"div",
|
|
1264
1272
|
{
|
|
1265
1273
|
ref: u,
|
|
@@ -1269,11 +1277,11 @@ const It = s.memo(yr), vr = ({
|
|
|
1269
1277
|
tabIndex: 0,
|
|
1270
1278
|
role: "combobox",
|
|
1271
1279
|
"aria-haspopup": "listbox",
|
|
1272
|
-
"aria-expanded":
|
|
1280
|
+
"aria-expanded": d,
|
|
1273
1281
|
"aria-invalid": !!p,
|
|
1274
1282
|
"aria-describedby": p ? `${e.name}-error` : void 0,
|
|
1275
|
-
onKeyDown: (
|
|
1276
|
-
(
|
|
1283
|
+
onKeyDown: (E) => {
|
|
1284
|
+
(E.key === "Enter" || E.key === " ") && (E.preventDefault(), V());
|
|
1277
1285
|
},
|
|
1278
1286
|
onBlur: I,
|
|
1279
1287
|
children: [
|
|
@@ -1282,7 +1290,7 @@ const It = s.memo(yr), vr = ({
|
|
|
1282
1290
|
]
|
|
1283
1291
|
}
|
|
1284
1292
|
) }),
|
|
1285
|
-
|
|
1293
|
+
d && h && /* @__PURE__ */ g(
|
|
1286
1294
|
Ft,
|
|
1287
1295
|
{
|
|
1288
1296
|
position: h,
|
|
@@ -1291,7 +1299,7 @@ const It = s.memo(yr), vr = ({
|
|
|
1291
1299
|
onSelect: A,
|
|
1292
1300
|
onClose: () => f(!1),
|
|
1293
1301
|
controlRef: u,
|
|
1294
|
-
theme:
|
|
1302
|
+
theme: s,
|
|
1295
1303
|
t: a
|
|
1296
1304
|
}
|
|
1297
1305
|
)
|
|
@@ -1303,32 +1311,32 @@ const It = s.memo(yr), vr = ({
|
|
|
1303
1311
|
onSelect: n,
|
|
1304
1312
|
onClose: o,
|
|
1305
1313
|
controlRef: a,
|
|
1306
|
-
theme:
|
|
1314
|
+
theme: s,
|
|
1307
1315
|
t: l
|
|
1308
1316
|
}) => {
|
|
1309
|
-
const i =
|
|
1310
|
-
|
|
1317
|
+
const i = c.useRef(null), [u, m] = c.useState(-1), { formStyle: d, fieldStyle: f } = j(), h = ce(s ?? "light");
|
|
1318
|
+
c.useLayoutEffect(() => {
|
|
1311
1319
|
if (!a.current) return;
|
|
1312
1320
|
const b = a.current.closest("[data-reactaform-theme]"), x = document.getElementById("popup-root");
|
|
1313
1321
|
if (b && x) {
|
|
1314
|
-
const
|
|
1322
|
+
const E = getComputedStyle(b);
|
|
1315
1323
|
x.style.setProperty(
|
|
1316
1324
|
"--reactaform-secondary-bg",
|
|
1317
|
-
|
|
1325
|
+
E.getPropertyValue("--reactaform-secondary-bg")
|
|
1318
1326
|
), x.style.setProperty(
|
|
1319
1327
|
"--reactaform-text-color",
|
|
1320
|
-
|
|
1328
|
+
E.getPropertyValue("--reactaform-text-color")
|
|
1321
1329
|
), x.style.setProperty(
|
|
1322
1330
|
"--reactaform-option-menu-hover-bg",
|
|
1323
|
-
|
|
1331
|
+
E.getPropertyValue("--reactaform-option-menu-hover-bg")
|
|
1324
1332
|
);
|
|
1325
1333
|
}
|
|
1326
1334
|
}, [a]);
|
|
1327
|
-
const
|
|
1335
|
+
const k = (b, x, E) => {
|
|
1328
1336
|
if (!x) return {};
|
|
1329
1337
|
const S = b?.[x];
|
|
1330
|
-
return (
|
|
1331
|
-
}, v =
|
|
1338
|
+
return (E && S ? S[E] : void 0) ?? {};
|
|
1339
|
+
}, v = c.useMemo(() => ({
|
|
1332
1340
|
maxHeight: 200,
|
|
1333
1341
|
overflowY: "auto",
|
|
1334
1342
|
background: "var(--reactaform-secondary-bg, #fff)",
|
|
@@ -1339,51 +1347,51 @@ const It = s.memo(yr), vr = ({
|
|
|
1339
1347
|
pointerEvents: "auto",
|
|
1340
1348
|
color: "var(--reactaform-text-color, #000)",
|
|
1341
1349
|
fontSize: "var(--reactaform-popup-font-size, 0.875rem)",
|
|
1342
|
-
...
|
|
1343
|
-
...
|
|
1344
|
-
}), [
|
|
1350
|
+
...k(d, "dropdown", "popup"),
|
|
1351
|
+
...k(f, void 0, "popup")
|
|
1352
|
+
}), [d, f]), p = c.useMemo(() => ({
|
|
1345
1353
|
padding: "6px 8px",
|
|
1346
1354
|
cursor: "pointer",
|
|
1347
1355
|
display: "flex",
|
|
1348
1356
|
alignItems: "center",
|
|
1349
1357
|
background: "transparent",
|
|
1350
1358
|
color: "var(--reactaform-text-color, #000)",
|
|
1351
|
-
...
|
|
1352
|
-
...
|
|
1353
|
-
}), [
|
|
1354
|
-
|
|
1359
|
+
...k(d, "dropdown", "option"),
|
|
1360
|
+
...k(f, void 0, "option")
|
|
1361
|
+
}), [d, f]);
|
|
1362
|
+
c.useEffect(() => {
|
|
1355
1363
|
const b = (x) => {
|
|
1356
|
-
const
|
|
1357
|
-
!i.current?.contains(
|
|
1364
|
+
const E = x.target;
|
|
1365
|
+
!i.current?.contains(E) && !a.current?.contains(E) && o();
|
|
1358
1366
|
};
|
|
1359
1367
|
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
1360
|
-
}, [o, a]),
|
|
1368
|
+
}, [o, a]), c.useEffect(() => {
|
|
1361
1369
|
if (i.current && r.length > 0) {
|
|
1362
1370
|
const b = r.findIndex((x) => String(x.value) === t);
|
|
1363
|
-
requestAnimationFrame(() =>
|
|
1371
|
+
requestAnimationFrame(() => m(b >= 0 ? b : 0));
|
|
1364
1372
|
}
|
|
1365
|
-
}, [r, t]),
|
|
1373
|
+
}, [r, t]), c.useEffect(() => {
|
|
1366
1374
|
if (!i.current || u < 0) return;
|
|
1367
1375
|
const b = i.current.querySelector(`#opt-${u}`);
|
|
1368
1376
|
b && requestAnimationFrame(() => b.focus());
|
|
1369
1377
|
}, [u]);
|
|
1370
|
-
const y = 250, C = 200, [V, A] =
|
|
1371
|
-
if (
|
|
1378
|
+
const y = 250, C = 200, [V, A] = c.useState(null), [I, M] = c.useState(null);
|
|
1379
|
+
if (c.useEffect(() => {
|
|
1372
1380
|
if (typeof window > "u") return;
|
|
1373
1381
|
const b = () => {
|
|
1374
|
-
let w = e.x, S = e.y,
|
|
1382
|
+
let w = e.x, S = e.y, N = y;
|
|
1375
1383
|
const $ = a?.current;
|
|
1376
1384
|
if ($) {
|
|
1377
|
-
const
|
|
1378
|
-
w =
|
|
1385
|
+
const L = $.getBoundingClientRect();
|
|
1386
|
+
w = L.left, S = L.bottom, N = Math.max(80, Math.round(L.width));
|
|
1379
1387
|
}
|
|
1380
|
-
w = Math.min(w, window.innerWidth -
|
|
1388
|
+
w = Math.min(w, window.innerWidth - N), S = Math.min(S, window.innerHeight - C), A({ left: w, top: S }), M(N);
|
|
1381
1389
|
};
|
|
1382
1390
|
b(), window.addEventListener("scroll", b, !0), window.addEventListener("resize", b);
|
|
1383
1391
|
let x = null;
|
|
1384
|
-
const
|
|
1385
|
-
return typeof ResizeObserver < "u" &&
|
|
1386
|
-
window.removeEventListener("scroll", b, !0), window.removeEventListener("resize", b), x &&
|
|
1392
|
+
const E = a?.current;
|
|
1393
|
+
return typeof ResizeObserver < "u" && E && (x = new ResizeObserver(() => b()), x.observe(E)), () => {
|
|
1394
|
+
window.removeEventListener("scroll", b, !0), window.removeEventListener("resize", b), x && E && x.unobserve(E);
|
|
1387
1395
|
};
|
|
1388
1396
|
}, [a, e.x, e.y]), typeof window > "u") return null;
|
|
1389
1397
|
let F = document.getElementById("popup-root");
|
|
@@ -1401,53 +1409,53 @@ const It = s.memo(yr), vr = ({
|
|
|
1401
1409
|
width: I ?? y,
|
|
1402
1410
|
...v
|
|
1403
1411
|
},
|
|
1404
|
-
"data-reactaform-theme":
|
|
1412
|
+
"data-reactaform-theme": s ?? "light",
|
|
1405
1413
|
children: r.map((b, x) => {
|
|
1406
|
-
const
|
|
1414
|
+
const E = String(b.value) === t, w = h ? "var(--reactaform-option-menu-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-option-menu-hover-bg, #eee)", S = {
|
|
1407
1415
|
...p,
|
|
1408
1416
|
background: x === u ? w : p.background,
|
|
1409
|
-
fontWeight:
|
|
1417
|
+
fontWeight: E ? "bold" : "normal"
|
|
1410
1418
|
};
|
|
1411
1419
|
return /* @__PURE__ */ g(
|
|
1412
1420
|
"div",
|
|
1413
1421
|
{
|
|
1414
1422
|
id: `opt-${x}`,
|
|
1415
|
-
onMouseDown: (
|
|
1416
|
-
|
|
1423
|
+
onMouseDown: (N) => {
|
|
1424
|
+
N.stopPropagation(), n(String(b.value));
|
|
1417
1425
|
},
|
|
1418
|
-
onKeyDown: (
|
|
1426
|
+
onKeyDown: (N) => {
|
|
1419
1427
|
const $ = r.length;
|
|
1420
|
-
switch (
|
|
1428
|
+
switch (N.key) {
|
|
1421
1429
|
case "ArrowDown":
|
|
1422
|
-
|
|
1430
|
+
N.preventDefault(), m((L) => (L + 1) % $);
|
|
1423
1431
|
break;
|
|
1424
1432
|
case "ArrowUp":
|
|
1425
|
-
|
|
1433
|
+
N.preventDefault(), m((L) => (L - 1 + $) % $);
|
|
1426
1434
|
break;
|
|
1427
1435
|
case "Home":
|
|
1428
|
-
|
|
1436
|
+
N.preventDefault(), m(0);
|
|
1429
1437
|
break;
|
|
1430
1438
|
case "End":
|
|
1431
|
-
|
|
1439
|
+
N.preventDefault(), m($ - 1);
|
|
1432
1440
|
break;
|
|
1433
1441
|
case "Enter":
|
|
1434
1442
|
case " ":
|
|
1435
|
-
|
|
1443
|
+
N.preventDefault(), N.stopPropagation(), n(String(b.value));
|
|
1436
1444
|
break;
|
|
1437
1445
|
case "Escape":
|
|
1438
|
-
|
|
1446
|
+
N.preventDefault(), o(), a?.current?.focus();
|
|
1439
1447
|
break;
|
|
1440
1448
|
}
|
|
1441
1449
|
},
|
|
1442
1450
|
tabIndex: x === u ? 0 : -1,
|
|
1443
1451
|
role: "option",
|
|
1444
|
-
"aria-selected":
|
|
1452
|
+
"aria-selected": E,
|
|
1445
1453
|
style: S,
|
|
1446
|
-
onMouseEnter: (
|
|
1447
|
-
|
|
1454
|
+
onMouseEnter: (N) => {
|
|
1455
|
+
N.currentTarget.style.background = w, m(x);
|
|
1448
1456
|
},
|
|
1449
|
-
onMouseLeave: (
|
|
1450
|
-
|
|
1457
|
+
onMouseLeave: (N) => {
|
|
1458
|
+
N.currentTarget.style.background = "transparent", m(($) => $ === x ? -1 : $);
|
|
1451
1459
|
},
|
|
1452
1460
|
children: l(b.label)
|
|
1453
1461
|
},
|
|
@@ -1460,26 +1468,26 @@ const It = s.memo(yr), vr = ({
|
|
|
1460
1468
|
);
|
|
1461
1469
|
};
|
|
1462
1470
|
vr.displayName = "DropdownInput";
|
|
1463
|
-
const Mt =
|
|
1471
|
+
const Mt = c.memo(vr), xr = ({
|
|
1464
1472
|
field: e,
|
|
1465
1473
|
value: r,
|
|
1466
1474
|
onChange: t,
|
|
1467
1475
|
onError: n,
|
|
1468
1476
|
error: o
|
|
1469
1477
|
}) => {
|
|
1470
|
-
const a = T(e, o), { inputRef:
|
|
1478
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
1471
1479
|
value: r,
|
|
1472
1480
|
onChange: t,
|
|
1473
1481
|
onError: n,
|
|
1474
1482
|
validate: a
|
|
1475
1483
|
});
|
|
1476
|
-
return /* @__PURE__ */ g(
|
|
1484
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
1477
1485
|
"input",
|
|
1478
1486
|
{
|
|
1479
1487
|
id: e.name,
|
|
1480
1488
|
type: "email",
|
|
1481
1489
|
defaultValue: String(r ?? ""),
|
|
1482
|
-
ref:
|
|
1490
|
+
ref: s,
|
|
1483
1491
|
onChange: i,
|
|
1484
1492
|
className: W(R.input, R.textInput),
|
|
1485
1493
|
"aria-invalid": !!l,
|
|
@@ -1488,7 +1496,7 @@ const Mt = s.memo(vr), xr = ({
|
|
|
1488
1496
|
) });
|
|
1489
1497
|
};
|
|
1490
1498
|
xr.displayName = "EmailInput";
|
|
1491
|
-
const Vt =
|
|
1499
|
+
const Vt = c.memo(xr), wr = ({ field: e }) => {
|
|
1492
1500
|
const { theme: r } = j(), {
|
|
1493
1501
|
color: t = ce(r) ? "#444444" : "#CCCCCC",
|
|
1494
1502
|
thickness: n = 1,
|
|
@@ -1508,46 +1516,46 @@ const Vt = s.memo(xr), wr = ({ field: e }) => {
|
|
|
1508
1516
|
);
|
|
1509
1517
|
};
|
|
1510
1518
|
wr.displayName = "FieldSeparator";
|
|
1511
|
-
const $t =
|
|
1512
|
-
const { t: a, theme:
|
|
1513
|
-
|
|
1514
|
-
|
|
1519
|
+
const $t = c.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
1520
|
+
const { t: a, theme: s } = j(), [l, i] = c.useState(!1), u = c.useRef(null), m = c.useRef(n), d = c.useRef(null), [f, h] = c.useState(null), k = ce(s);
|
|
1521
|
+
c.useEffect(() => {
|
|
1522
|
+
m.current = n;
|
|
1515
1523
|
}, [n]);
|
|
1516
1524
|
const v = (w, S) => S.some(
|
|
1517
|
-
(
|
|
1518
|
-
), p = T(e, o), y =
|
|
1519
|
-
w !==
|
|
1525
|
+
(N) => N.name === w.name && N.size === w.size && N.lastModified === w.lastModified
|
|
1526
|
+
), p = T(e, o), y = c.useCallback((w) => {
|
|
1527
|
+
w !== d.current && (d.current = w, h(w), m.current?.(w ?? null));
|
|
1520
1528
|
}, []);
|
|
1521
|
-
|
|
1529
|
+
c.useEffect(() => {
|
|
1522
1530
|
const w = p(r ?? [], "sync");
|
|
1523
1531
|
t?.(r), y(w);
|
|
1524
1532
|
}, [r, p, y]);
|
|
1525
1533
|
const C = (w) => {
|
|
1526
1534
|
const S = w.target.files;
|
|
1527
|
-
let
|
|
1535
|
+
let N = null;
|
|
1528
1536
|
if (S && S.length > 0) {
|
|
1529
|
-
const
|
|
1537
|
+
const L = Array.from(S);
|
|
1530
1538
|
if (e.multiple) {
|
|
1531
|
-
const q = Array.isArray(r) ? r : [],
|
|
1532
|
-
|
|
1539
|
+
const q = Array.isArray(r) ? r : [], X = L.filter((te) => !v(te, q));
|
|
1540
|
+
N = [...q, ...X];
|
|
1533
1541
|
} else
|
|
1534
|
-
|
|
1542
|
+
N = L[0];
|
|
1535
1543
|
}
|
|
1536
|
-
const $ = p(
|
|
1537
|
-
y($), t?.(
|
|
1544
|
+
const $ = p(N ?? [], "change");
|
|
1545
|
+
y($), t?.(N), w.target && (w.target.value = "");
|
|
1538
1546
|
}, V = (w) => {
|
|
1539
1547
|
w.preventDefault(), w.stopPropagation(), i(!1);
|
|
1540
1548
|
const S = w.dataTransfer.files;
|
|
1541
1549
|
if (S && S.length > 0) {
|
|
1542
|
-
const
|
|
1550
|
+
const N = Array.from(S);
|
|
1543
1551
|
let $ = null;
|
|
1544
1552
|
if (e.multiple) {
|
|
1545
|
-
const q = Array.isArray(r) ? r : [],
|
|
1546
|
-
$ = [...q, ...
|
|
1553
|
+
const q = Array.isArray(r) ? r : [], X = N.filter((te) => !v(te, q));
|
|
1554
|
+
$ = [...q, ...X];
|
|
1547
1555
|
} else
|
|
1548
|
-
$ =
|
|
1549
|
-
const
|
|
1550
|
-
y(
|
|
1556
|
+
$ = N[0];
|
|
1557
|
+
const L = p($, "change");
|
|
1558
|
+
y(L), t?.($);
|
|
1551
1559
|
}
|
|
1552
1560
|
}, A = (w) => {
|
|
1553
1561
|
w.preventDefault(), w.stopPropagation(), i(!0);
|
|
@@ -1555,13 +1563,13 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1555
1563
|
w.preventDefault(), w.stopPropagation(), i(!1);
|
|
1556
1564
|
}, M = (w) => {
|
|
1557
1565
|
if (Array.isArray(r) && typeof w == "number") {
|
|
1558
|
-
const S = r.filter((
|
|
1559
|
-
y($), t?.(
|
|
1566
|
+
const S = r.filter((L, q) => q !== w), N = S.length > 0 ? S : null, $ = p(N ?? [], "change");
|
|
1567
|
+
y($), t?.(N);
|
|
1560
1568
|
} else {
|
|
1561
1569
|
const S = p([], "change");
|
|
1562
1570
|
y(S), t?.(null);
|
|
1563
1571
|
}
|
|
1564
|
-
}, F =
|
|
1572
|
+
}, F = c.useCallback(() => {
|
|
1565
1573
|
y(p(r ?? [], "blur"));
|
|
1566
1574
|
}, [y, p, r]), b = () => {
|
|
1567
1575
|
const w = Array.isArray(r) ? r : r ? [r] : [];
|
|
@@ -1573,7 +1581,7 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1573
1581
|
gap: "6px",
|
|
1574
1582
|
maxHeight: "200px",
|
|
1575
1583
|
overflowY: "auto"
|
|
1576
|
-
}, children: w.map((S,
|
|
1584
|
+
}, children: w.map((S, N) => /* @__PURE__ */ z(
|
|
1577
1585
|
"div",
|
|
1578
1586
|
{
|
|
1579
1587
|
style: {
|
|
@@ -1603,7 +1611,7 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1603
1611
|
"button",
|
|
1604
1612
|
{
|
|
1605
1613
|
type: "button",
|
|
1606
|
-
onClick: () => M(Array.isArray(r) ?
|
|
1614
|
+
onClick: () => M(Array.isArray(r) ? N : void 0),
|
|
1607
1615
|
"aria-label": a("Remove file"),
|
|
1608
1616
|
style: {
|
|
1609
1617
|
background: "transparent",
|
|
@@ -1628,10 +1636,10 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1628
1636
|
)
|
|
1629
1637
|
]
|
|
1630
1638
|
},
|
|
1631
|
-
`${S.name}-${
|
|
1639
|
+
`${S.name}-${N}`
|
|
1632
1640
|
)) });
|
|
1633
|
-
}, [x,
|
|
1634
|
-
return /* @__PURE__ */ g(
|
|
1641
|
+
}, [x, E] = c.useState(!1);
|
|
1642
|
+
return /* @__PURE__ */ g(B, { field: e, error: f, children: /* @__PURE__ */ z("div", { style: { width: "100%" }, children: [
|
|
1635
1643
|
/* @__PURE__ */ z(
|
|
1636
1644
|
"div",
|
|
1637
1645
|
{
|
|
@@ -1639,8 +1647,8 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1639
1647
|
onDrop: V,
|
|
1640
1648
|
onDragOver: A,
|
|
1641
1649
|
onDragLeave: I,
|
|
1642
|
-
onMouseEnter: () =>
|
|
1643
|
-
onMouseLeave: () =>
|
|
1650
|
+
onMouseEnter: () => E(!0),
|
|
1651
|
+
onMouseLeave: () => E(!1),
|
|
1644
1652
|
onBlur: F,
|
|
1645
1653
|
style: {
|
|
1646
1654
|
position: "relative",
|
|
@@ -1650,7 +1658,7 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1650
1658
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
1651
1659
|
padding: "8px 12px",
|
|
1652
1660
|
textAlign: "center",
|
|
1653
|
-
backgroundColor: l ? `var(--reactaform-bg-hover, ${
|
|
1661
|
+
backgroundColor: l ? `var(--reactaform-bg-hover, ${k ? "#070707" : "#eff6ff"})` : void 0,
|
|
1654
1662
|
transition: "all 0.2s ease",
|
|
1655
1663
|
cursor: "pointer",
|
|
1656
1664
|
minHeight: "var(--reactaform-input-height, 34px)",
|
|
@@ -1708,25 +1716,25 @@ const $t = s.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1708
1716
|
] }) });
|
|
1709
1717
|
};
|
|
1710
1718
|
Sr.displayName = "FileInput";
|
|
1711
|
-
const Rt =
|
|
1719
|
+
const Rt = c.memo(Sr), Cr = ({
|
|
1712
1720
|
field: e,
|
|
1713
1721
|
value: r,
|
|
1714
1722
|
onChange: t,
|
|
1715
1723
|
onError: n,
|
|
1716
1724
|
error: o
|
|
1717
1725
|
}) => {
|
|
1718
|
-
const a = T(e, o),
|
|
1719
|
-
value:
|
|
1726
|
+
const a = T(e, o), s = Array.isArray(r) ? r.join(", ") : String(r ?? ""), { inputRef: l, error: i, handleChange: u } = K({
|
|
1727
|
+
value: s,
|
|
1720
1728
|
onChange: t,
|
|
1721
1729
|
onError: n,
|
|
1722
1730
|
validate: a
|
|
1723
1731
|
});
|
|
1724
|
-
return /* @__PURE__ */ g(
|
|
1732
|
+
return /* @__PURE__ */ g(B, { field: e, error: i, children: /* @__PURE__ */ g(
|
|
1725
1733
|
"input",
|
|
1726
1734
|
{
|
|
1727
1735
|
id: e.name,
|
|
1728
1736
|
type: "text",
|
|
1729
|
-
defaultValue:
|
|
1737
|
+
defaultValue: s,
|
|
1730
1738
|
ref: l,
|
|
1731
1739
|
onChange: u,
|
|
1732
1740
|
className: W(R.input, R.textInput),
|
|
@@ -1737,25 +1745,25 @@ const Rt = s.memo(Sr), Cr = ({
|
|
|
1737
1745
|
) });
|
|
1738
1746
|
};
|
|
1739
1747
|
Cr.displayName = "FloatArrayInput";
|
|
1740
|
-
const At =
|
|
1748
|
+
const At = c.memo(Cr), kr = ({
|
|
1741
1749
|
field: e,
|
|
1742
1750
|
value: r,
|
|
1743
1751
|
onChange: t,
|
|
1744
1752
|
onError: n,
|
|
1745
1753
|
error: o
|
|
1746
1754
|
}) => {
|
|
1747
|
-
const a = T(e, o), { inputRef:
|
|
1755
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
1748
1756
|
value: r,
|
|
1749
1757
|
onChange: t,
|
|
1750
1758
|
onError: n,
|
|
1751
1759
|
validate: a
|
|
1752
1760
|
});
|
|
1753
|
-
return /* @__PURE__ */ g(
|
|
1761
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
1754
1762
|
"input",
|
|
1755
1763
|
{
|
|
1756
1764
|
id: e.name,
|
|
1757
1765
|
type: "text",
|
|
1758
|
-
ref:
|
|
1766
|
+
ref: s,
|
|
1759
1767
|
defaultValue: String(r ?? ""),
|
|
1760
1768
|
onChange: i,
|
|
1761
1769
|
className: W(
|
|
@@ -1768,7 +1776,7 @@ const At = s.memo(Cr), kr = ({
|
|
|
1768
1776
|
) });
|
|
1769
1777
|
};
|
|
1770
1778
|
kr.displayName = "FloatInput";
|
|
1771
|
-
const Dt =
|
|
1779
|
+
const Dt = c.memo(kr);
|
|
1772
1780
|
function zt() {
|
|
1773
1781
|
try {
|
|
1774
1782
|
return "/";
|
|
@@ -1786,11 +1794,11 @@ const Nr = ({ field: e, value: r }) => {
|
|
|
1786
1794
|
left: "flex-start",
|
|
1787
1795
|
center: "center",
|
|
1788
1796
|
right: "flex-end"
|
|
1789
|
-
},
|
|
1790
|
-
let l =
|
|
1797
|
+
}, s = typeof r == "string" ? r : "";
|
|
1798
|
+
let l = s && s.trim() !== "" ? s : typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
1791
1799
|
l && !l.startsWith("/") && (l = `${zt()}${l}`);
|
|
1792
|
-
const i = e.localized?.split(";").map((p) => p.trim()), [u,
|
|
1793
|
-
if (
|
|
1800
|
+
const i = e.localized?.split(";").map((p) => p.trim()), [u, m] = c.useState(l || ""), d = c.useRef(l || null);
|
|
1801
|
+
if (c.useEffect(() => {
|
|
1794
1802
|
if (!l) return;
|
|
1795
1803
|
const p = l.split("/"), y = p.pop(), C = y.lastIndexOf(".");
|
|
1796
1804
|
if (C === -1) return;
|
|
@@ -1802,25 +1810,25 @@ const Nr = ({ field: e, value: r }) => {
|
|
|
1802
1810
|
const F = [...p, I].join("/");
|
|
1803
1811
|
fetch(F, { method: "HEAD", signal: M.signal }).then((b) => {
|
|
1804
1812
|
const x = b.ok ? F : l;
|
|
1805
|
-
x !==
|
|
1813
|
+
x !== d.current && (d.current = x, m(x));
|
|
1806
1814
|
}).catch(() => {
|
|
1807
|
-
l !==
|
|
1815
|
+
l !== d.current && (d.current = l, m(l));
|
|
1808
1816
|
});
|
|
1809
1817
|
} else {
|
|
1810
1818
|
const F = l;
|
|
1811
|
-
F !==
|
|
1819
|
+
F !== d.current && (d.current = F, requestAnimationFrame(() => m(F)));
|
|
1812
1820
|
}
|
|
1813
1821
|
return () => {
|
|
1814
1822
|
M.abort();
|
|
1815
1823
|
};
|
|
1816
1824
|
}, [l, t, i]), !u) return null;
|
|
1817
|
-
const { width: f, height: h } = e,
|
|
1825
|
+
const { width: f, height: h } = e, k = {}, v = {
|
|
1818
1826
|
borderRadius: "8px",
|
|
1819
1827
|
objectFit: "contain",
|
|
1820
1828
|
boxShadow: "0 2px 6px rgba(0,0,0,0.1)",
|
|
1821
1829
|
margin: "0 0 8px 0"
|
|
1822
1830
|
};
|
|
1823
|
-
return f && h ? (
|
|
1831
|
+
return f && h ? (k.width = f, k.height = h, v.width = `${f}px`, v.height = `${h}px`) : f && !h ? (k.width = f, v.width = `${f}px`, v.height = "auto") : !f && h && (k.height = h, v.width = "auto", v.height = `${h}px`), /* @__PURE__ */ g(B, { field: e, children: /* @__PURE__ */ g(
|
|
1824
1832
|
"div",
|
|
1825
1833
|
{
|
|
1826
1834
|
"data-testid": "image-wrapper",
|
|
@@ -1834,7 +1842,7 @@ const Nr = ({ field: e, value: r }) => {
|
|
|
1834
1842
|
{
|
|
1835
1843
|
src: u,
|
|
1836
1844
|
alt: n?.(e.displayName || "Image") || e.displayName || "Image",
|
|
1837
|
-
...
|
|
1845
|
+
...k,
|
|
1838
1846
|
style: v
|
|
1839
1847
|
}
|
|
1840
1848
|
)
|
|
@@ -1842,25 +1850,25 @@ const Nr = ({ field: e, value: r }) => {
|
|
|
1842
1850
|
) });
|
|
1843
1851
|
};
|
|
1844
1852
|
Nr.displayName = "ImageDisplay";
|
|
1845
|
-
const Pt =
|
|
1853
|
+
const Pt = c.memo(Nr), Er = ({
|
|
1846
1854
|
field: e,
|
|
1847
1855
|
value: r,
|
|
1848
1856
|
onChange: t,
|
|
1849
1857
|
onError: n,
|
|
1850
1858
|
error: o
|
|
1851
1859
|
}) => {
|
|
1852
|
-
const a = T(e, o),
|
|
1853
|
-
value:
|
|
1860
|
+
const a = T(e, o), s = Array.isArray(r) ? r.join(", ") : String(r ?? ""), { inputRef: l, error: i, handleChange: u } = K({
|
|
1861
|
+
value: s,
|
|
1854
1862
|
onChange: t,
|
|
1855
1863
|
onError: n,
|
|
1856
1864
|
validate: a
|
|
1857
1865
|
});
|
|
1858
|
-
return /* @__PURE__ */ g(
|
|
1866
|
+
return /* @__PURE__ */ g(B, { field: e, error: i, children: /* @__PURE__ */ g(
|
|
1859
1867
|
"input",
|
|
1860
1868
|
{
|
|
1861
1869
|
id: e.name,
|
|
1862
1870
|
type: "text",
|
|
1863
|
-
defaultValue:
|
|
1871
|
+
defaultValue: s,
|
|
1864
1872
|
ref: l,
|
|
1865
1873
|
onChange: u,
|
|
1866
1874
|
className: W(R.input, R.textInput),
|
|
@@ -1871,26 +1879,26 @@ const Pt = s.memo(Nr), Er = ({
|
|
|
1871
1879
|
) });
|
|
1872
1880
|
};
|
|
1873
1881
|
Er.displayName = "IntegerArrayInput";
|
|
1874
|
-
const
|
|
1882
|
+
const Ot = c.memo(Er), Ir = ({
|
|
1875
1883
|
field: e,
|
|
1876
1884
|
value: r,
|
|
1877
1885
|
onChange: t,
|
|
1878
1886
|
onError: n,
|
|
1879
1887
|
error: o
|
|
1880
1888
|
}) => {
|
|
1881
|
-
const a = T(e, o), { inputRef:
|
|
1889
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
1882
1890
|
value: r,
|
|
1883
1891
|
onChange: t,
|
|
1884
1892
|
onError: n,
|
|
1885
1893
|
validate: a
|
|
1886
1894
|
});
|
|
1887
|
-
return /* @__PURE__ */ g(
|
|
1895
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
1888
1896
|
"input",
|
|
1889
1897
|
{
|
|
1890
1898
|
id: e.name,
|
|
1891
1899
|
type: "text",
|
|
1892
1900
|
defaultValue: String(r ?? ""),
|
|
1893
|
-
ref:
|
|
1901
|
+
ref: s,
|
|
1894
1902
|
onChange: i,
|
|
1895
1903
|
className: W(R.input, R.inputNumber),
|
|
1896
1904
|
"aria-invalid": !!l,
|
|
@@ -1899,25 +1907,25 @@ const Bt = s.memo(Er), Ir = ({
|
|
|
1899
1907
|
) });
|
|
1900
1908
|
};
|
|
1901
1909
|
Ir.displayName = "IntegerInput";
|
|
1902
|
-
const
|
|
1910
|
+
const Bt = c.memo(Ir), Fr = ({
|
|
1903
1911
|
field: e,
|
|
1904
1912
|
value: r,
|
|
1905
1913
|
onChange: t,
|
|
1906
1914
|
onError: n,
|
|
1907
1915
|
error: o
|
|
1908
1916
|
}) => {
|
|
1909
|
-
const a = T(e, o), { inputRef:
|
|
1917
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
1910
1918
|
value: r,
|
|
1911
1919
|
onChange: t,
|
|
1912
1920
|
onError: n,
|
|
1913
1921
|
validate: a
|
|
1914
1922
|
});
|
|
1915
|
-
return /* @__PURE__ */ g(
|
|
1923
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
1916
1924
|
"textarea",
|
|
1917
1925
|
{
|
|
1918
1926
|
id: e.name,
|
|
1919
1927
|
defaultValue: String(r ?? ""),
|
|
1920
|
-
ref:
|
|
1928
|
+
ref: s,
|
|
1921
1929
|
onChange: i,
|
|
1922
1930
|
style: {
|
|
1923
1931
|
resize: "vertical",
|
|
@@ -1932,45 +1940,45 @@ const Lt = s.memo(Ir), Fr = ({
|
|
|
1932
1940
|
) });
|
|
1933
1941
|
};
|
|
1934
1942
|
Fr.displayName = "MultilineTextInput";
|
|
1935
|
-
const
|
|
1943
|
+
const Lt = c.memo(Fr), Mr = ({
|
|
1936
1944
|
field: e,
|
|
1937
1945
|
value: r,
|
|
1938
1946
|
onChange: t,
|
|
1939
1947
|
onError: n,
|
|
1940
1948
|
error: o
|
|
1941
1949
|
}) => {
|
|
1942
|
-
const a =
|
|
1950
|
+
const a = c.useRef(
|
|
1943
1951
|
n
|
|
1944
1952
|
);
|
|
1945
|
-
|
|
1953
|
+
c.useEffect(() => {
|
|
1946
1954
|
a.current = n;
|
|
1947
1955
|
}, [n]);
|
|
1948
|
-
const { t:
|
|
1949
|
-
if (!
|
|
1950
|
-
const q = S?.[
|
|
1956
|
+
const { t: s, theme: l, formStyle: i, fieldStyle: u } = j(), m = (S, N, $) => {
|
|
1957
|
+
if (!N) return {};
|
|
1958
|
+
const q = S?.[N];
|
|
1951
1959
|
return ($ && q ? q[$] : void 0) ?? {};
|
|
1952
|
-
},
|
|
1953
|
-
() => e.options.map((S) => ({ value: S.value, label:
|
|
1954
|
-
[e.options,
|
|
1955
|
-
), y =
|
|
1956
|
-
const S = Array.isArray(r) ? r : [],
|
|
1957
|
-
return S.filter(($) =>
|
|
1958
|
-
}, [r, p]), C = T(e, o), [V, A] =
|
|
1959
|
-
|
|
1960
|
+
}, d = c.useRef(null), [f, h] = c.useState(!1), [k, v] = c.useState(null), p = c.useMemo(
|
|
1961
|
+
() => e.options.map((S) => ({ value: S.value, label: s(S.label) })),
|
|
1962
|
+
[e.options, s]
|
|
1963
|
+
), y = c.useMemo(() => {
|
|
1964
|
+
const S = Array.isArray(r) ? r : [], N = new Set(p.map(($) => $.value));
|
|
1965
|
+
return S.filter(($) => N.has($));
|
|
1966
|
+
}, [r, p]), C = T(e, o), [V, A] = c.useState(null), I = c.useRef(null);
|
|
1967
|
+
c.useEffect(() => {
|
|
1960
1968
|
const S = C(Array.isArray(r) ? r : [], "sync");
|
|
1961
1969
|
S !== I.current && (I.current = S, A(S), a.current?.(S ?? null));
|
|
1962
1970
|
}, [r, C]);
|
|
1963
1971
|
const M = () => {
|
|
1964
|
-
if (!
|
|
1965
|
-
const S =
|
|
1966
|
-
v({ x: S.left, y: S.bottom }), h((
|
|
1972
|
+
if (!d.current) return;
|
|
1973
|
+
const S = d.current.getBoundingClientRect();
|
|
1974
|
+
v({ x: S.left, y: S.bottom }), h((N) => !N);
|
|
1967
1975
|
}, F = (S) => {
|
|
1968
|
-
const
|
|
1969
|
-
$ !== I.current && (I.current = $, A($), a.current?.($ ?? null)), t?.(
|
|
1970
|
-
}, b =
|
|
1976
|
+
const N = y.includes(S) ? y.filter((L) => L !== S) : [...y, S], $ = C(N, "change");
|
|
1977
|
+
$ !== I.current && (I.current = $, A($), a.current?.($ ?? null)), t?.(N);
|
|
1978
|
+
}, b = c.useCallback(() => {
|
|
1971
1979
|
const S = C(y, "blur");
|
|
1972
1980
|
S !== I.current && (I.current = S, A(S), a.current?.(S ?? null));
|
|
1973
|
-
}, [y, C]), x =
|
|
1981
|
+
}, [y, C]), x = c.useMemo(
|
|
1974
1982
|
() => ({
|
|
1975
1983
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
1976
1984
|
display: "flex",
|
|
@@ -1978,11 +1986,11 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
1978
1986
|
cursor: "pointer",
|
|
1979
1987
|
position: "relative",
|
|
1980
1988
|
textAlign: "left",
|
|
1981
|
-
...
|
|
1982
|
-
...
|
|
1989
|
+
...m(i, "multiSelect", "control"),
|
|
1990
|
+
...m(u, void 0, "control")
|
|
1983
1991
|
}),
|
|
1984
1992
|
[i, u]
|
|
1985
|
-
),
|
|
1993
|
+
), E = c.useMemo(
|
|
1986
1994
|
() => ({
|
|
1987
1995
|
position: "absolute",
|
|
1988
1996
|
right: "1.5em",
|
|
@@ -1994,11 +2002,11 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
1994
2002
|
fontSize: "0.8em",
|
|
1995
2003
|
color: "var(--reactaform-text-muted, #999)",
|
|
1996
2004
|
padding: 0,
|
|
1997
|
-
...
|
|
1998
|
-
...
|
|
2005
|
+
...m(i, "multiSelect", "clearButton"),
|
|
2006
|
+
...m(u, void 0, "clearButton")
|
|
1999
2007
|
}),
|
|
2000
2008
|
[i, u]
|
|
2001
|
-
), w =
|
|
2009
|
+
), w = c.useMemo(
|
|
2002
2010
|
() => ({
|
|
2003
2011
|
position: "absolute",
|
|
2004
2012
|
right: "0.7em",
|
|
@@ -2007,16 +2015,16 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2007
2015
|
pointerEvents: "none",
|
|
2008
2016
|
fontSize: "0.8em",
|
|
2009
2017
|
color: "var(--reactaform-text-muted, #999)",
|
|
2010
|
-
...
|
|
2011
|
-
...
|
|
2018
|
+
...m(i, "multiSelect", "arrow"),
|
|
2019
|
+
...m(u, void 0, "arrow")
|
|
2012
2020
|
}),
|
|
2013
2021
|
[i, u]
|
|
2014
2022
|
);
|
|
2015
2023
|
return /* @__PURE__ */ z("div", { children: [
|
|
2016
|
-
/* @__PURE__ */ g(
|
|
2024
|
+
/* @__PURE__ */ g(B, { field: e, error: V, children: /* @__PURE__ */ g("div", { style: { width: "100%" }, children: /* @__PURE__ */ z(
|
|
2017
2025
|
"div",
|
|
2018
2026
|
{
|
|
2019
|
-
ref:
|
|
2027
|
+
ref: d,
|
|
2020
2028
|
className: "reactaform-multiselection-control reactaform-input",
|
|
2021
2029
|
style: x,
|
|
2022
2030
|
onClick: M,
|
|
@@ -2050,26 +2058,26 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2050
2058
|
"aria-label": "Clear selections",
|
|
2051
2059
|
onClick: (S) => {
|
|
2052
2060
|
S.stopPropagation();
|
|
2053
|
-
const
|
|
2054
|
-
|
|
2061
|
+
const N = C([], "change");
|
|
2062
|
+
N !== I.current && (I.current = N, A(N), a.current?.(N ?? null)), t?.([]);
|
|
2055
2063
|
},
|
|
2056
|
-
style:
|
|
2057
|
-
children: /* @__PURE__ */ g("span", { style:
|
|
2064
|
+
style: E,
|
|
2065
|
+
children: /* @__PURE__ */ g("span", { style: E, "aria-hidden": !0, children: "✖" })
|
|
2058
2066
|
}
|
|
2059
2067
|
),
|
|
2060
2068
|
/* @__PURE__ */ g("span", { style: w, "aria-hidden": !0, children: "▼" })
|
|
2061
2069
|
]
|
|
2062
2070
|
}
|
|
2063
2071
|
) }) }),
|
|
2064
|
-
f &&
|
|
2072
|
+
f && k && /* @__PURE__ */ g(
|
|
2065
2073
|
Tt,
|
|
2066
2074
|
{
|
|
2067
|
-
position:
|
|
2075
|
+
position: k,
|
|
2068
2076
|
options: p,
|
|
2069
2077
|
selectedValues: y,
|
|
2070
2078
|
onToggleOption: F,
|
|
2071
2079
|
onClose: () => h(!1),
|
|
2072
|
-
controlRef:
|
|
2080
|
+
controlRef: d,
|
|
2073
2081
|
theme: l
|
|
2074
2082
|
}
|
|
2075
2083
|
)
|
|
@@ -2081,10 +2089,10 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2081
2089
|
onToggleOption: n,
|
|
2082
2090
|
onClose: o,
|
|
2083
2091
|
controlRef: a,
|
|
2084
|
-
theme:
|
|
2092
|
+
theme: s
|
|
2085
2093
|
}) => {
|
|
2086
|
-
const l =
|
|
2087
|
-
|
|
2094
|
+
const l = c.useRef(null), [i, u] = c.useState(-1), { formStyle: m, fieldStyle: d } = j(), f = ce(s ?? "light");
|
|
2095
|
+
c.useLayoutEffect(() => {
|
|
2088
2096
|
if (!a.current) return;
|
|
2089
2097
|
const F = a.current.closest("[data-reactaform-theme]"), b = document.getElementById("popup-root");
|
|
2090
2098
|
if (F && b) {
|
|
@@ -2105,7 +2113,7 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2105
2113
|
if (!b) return {};
|
|
2106
2114
|
const w = F?.[b];
|
|
2107
2115
|
return (x && w ? w[x] : void 0) ?? {};
|
|
2108
|
-
},
|
|
2116
|
+
}, k = c.useMemo(
|
|
2109
2117
|
() => ({
|
|
2110
2118
|
maxHeight: 200,
|
|
2111
2119
|
overflowY: "auto",
|
|
@@ -2117,11 +2125,11 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2117
2125
|
pointerEvents: "auto",
|
|
2118
2126
|
color: "var(--reactaform-text-color, #000)",
|
|
2119
2127
|
fontSize: "var(--reactaform-popup-font-size, 0.875rem)",
|
|
2120
|
-
...h(
|
|
2121
|
-
...h(
|
|
2128
|
+
...h(m, "multiSelect", "popup"),
|
|
2129
|
+
...h(d, void 0, "popup")
|
|
2122
2130
|
}),
|
|
2123
|
-
[
|
|
2124
|
-
), v =
|
|
2131
|
+
[m, d]
|
|
2132
|
+
), v = c.useMemo(
|
|
2125
2133
|
() => ({
|
|
2126
2134
|
padding: "6px 8px",
|
|
2127
2135
|
cursor: "pointer",
|
|
@@ -2129,39 +2137,39 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2129
2137
|
alignItems: "center",
|
|
2130
2138
|
background: "transparent",
|
|
2131
2139
|
color: "var(--reactaform-text-color, #000)",
|
|
2132
|
-
...h(
|
|
2133
|
-
...h(
|
|
2140
|
+
...h(m, "multiSelect", "option"),
|
|
2141
|
+
...h(d, void 0, "option")
|
|
2134
2142
|
}),
|
|
2135
|
-
[
|
|
2143
|
+
[m, d]
|
|
2136
2144
|
);
|
|
2137
|
-
|
|
2145
|
+
c.useEffect(() => {
|
|
2138
2146
|
const F = (b) => {
|
|
2139
2147
|
const x = b.target;
|
|
2140
2148
|
!l.current?.contains(x) && !a.current?.contains(x) && o();
|
|
2141
2149
|
};
|
|
2142
2150
|
return document.addEventListener("mousedown", F), () => document.removeEventListener("mousedown", F);
|
|
2143
|
-
}, [o, a]),
|
|
2151
|
+
}, [o, a]), c.useEffect(() => {
|
|
2144
2152
|
l.current && r.length > 0 && requestAnimationFrame(
|
|
2145
2153
|
() => u((F) => F === -1 ? 0 : F)
|
|
2146
2154
|
);
|
|
2147
|
-
}, [r.length]),
|
|
2155
|
+
}, [r.length]), c.useEffect(() => {
|
|
2148
2156
|
if (!l.current || i < 0) return;
|
|
2149
2157
|
const F = l.current.querySelector(
|
|
2150
2158
|
`#multi-opt-${i}`
|
|
2151
2159
|
);
|
|
2152
2160
|
F && requestAnimationFrame(() => F.focus());
|
|
2153
2161
|
}, [i]);
|
|
2154
|
-
const p = 250, y = 200, [C, V] =
|
|
2155
|
-
if (
|
|
2162
|
+
const p = 250, y = 200, [C, V] = c.useState(null), [A, I] = c.useState(null);
|
|
2163
|
+
if (c.useEffect(() => {
|
|
2156
2164
|
if (typeof window > "u") return;
|
|
2157
2165
|
const F = () => {
|
|
2158
|
-
let
|
|
2159
|
-
const
|
|
2160
|
-
if (
|
|
2161
|
-
const $ =
|
|
2162
|
-
|
|
2166
|
+
let E = e.x, w = e.y, S = p;
|
|
2167
|
+
const N = a?.current;
|
|
2168
|
+
if (N) {
|
|
2169
|
+
const $ = N.getBoundingClientRect();
|
|
2170
|
+
E = $.left, w = $.bottom, S = Math.max(80, Math.round($.width));
|
|
2163
2171
|
}
|
|
2164
|
-
|
|
2172
|
+
E = Math.min(E, window.innerWidth - S), w = Math.min(w, window.innerHeight - y), V({ left: E, top: w }), I(S);
|
|
2165
2173
|
};
|
|
2166
2174
|
F(), window.addEventListener("scroll", F, !0), window.addEventListener("resize", F);
|
|
2167
2175
|
let b = null;
|
|
@@ -2184,13 +2192,13 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2184
2192
|
left: C ? C.left : e.x,
|
|
2185
2193
|
width: A ?? p,
|
|
2186
2194
|
// spread the static popup styles
|
|
2187
|
-
...
|
|
2195
|
+
...k
|
|
2188
2196
|
},
|
|
2189
|
-
"data-reactaform-theme":
|
|
2197
|
+
"data-reactaform-theme": s ?? "light",
|
|
2190
2198
|
children: r.map((F, b) => {
|
|
2191
|
-
const x = t.includes(F.value),
|
|
2199
|
+
const x = t.includes(F.value), E = f ? "var(--reactaform-option-menu-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-option-menu-hover-bg, #eee)", w = {
|
|
2192
2200
|
...v,
|
|
2193
|
-
background: b === i ?
|
|
2201
|
+
background: b === i ? E : v.background
|
|
2194
2202
|
};
|
|
2195
2203
|
return /* @__PURE__ */ z(
|
|
2196
2204
|
"div",
|
|
@@ -2200,19 +2208,19 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2200
2208
|
S.stopPropagation(), n(F.value);
|
|
2201
2209
|
},
|
|
2202
2210
|
onKeyDown: (S) => {
|
|
2203
|
-
const
|
|
2211
|
+
const N = r.length;
|
|
2204
2212
|
switch (S.key) {
|
|
2205
2213
|
case "ArrowDown":
|
|
2206
|
-
S.preventDefault(), u(($) => ($ + 1) %
|
|
2214
|
+
S.preventDefault(), u(($) => ($ + 1) % N);
|
|
2207
2215
|
break;
|
|
2208
2216
|
case "ArrowUp":
|
|
2209
|
-
S.preventDefault(), u(($) => ($ - 1 +
|
|
2217
|
+
S.preventDefault(), u(($) => ($ - 1 + N) % N);
|
|
2210
2218
|
break;
|
|
2211
2219
|
case "Home":
|
|
2212
2220
|
S.preventDefault(), u(0);
|
|
2213
2221
|
break;
|
|
2214
2222
|
case "End":
|
|
2215
|
-
S.preventDefault(), u(
|
|
2223
|
+
S.preventDefault(), u(N - 1);
|
|
2216
2224
|
break;
|
|
2217
2225
|
case "Enter":
|
|
2218
2226
|
case " ":
|
|
@@ -2228,10 +2236,10 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2228
2236
|
"aria-selected": x,
|
|
2229
2237
|
style: w,
|
|
2230
2238
|
onMouseEnter: (S) => {
|
|
2231
|
-
S.currentTarget.style.background =
|
|
2239
|
+
S.currentTarget.style.background = E, u(b);
|
|
2232
2240
|
},
|
|
2233
2241
|
onMouseLeave: (S) => {
|
|
2234
|
-
S.currentTarget.style.background = "transparent", u((
|
|
2242
|
+
S.currentTarget.style.background = "transparent", u((N) => N === b ? -1 : N);
|
|
2235
2243
|
},
|
|
2236
2244
|
children: [
|
|
2237
2245
|
/* @__PURE__ */ g(
|
|
@@ -2262,26 +2270,26 @@ const Ot = s.memo(Fr), Mr = ({
|
|
|
2262
2270
|
);
|
|
2263
2271
|
};
|
|
2264
2272
|
Mr.displayName = "MultiSelect";
|
|
2265
|
-
const jt =
|
|
2273
|
+
const jt = c.memo(Mr), Vr = ({
|
|
2266
2274
|
field: e,
|
|
2267
2275
|
value: r,
|
|
2268
2276
|
onChange: t,
|
|
2269
2277
|
onError: n,
|
|
2270
2278
|
error: o
|
|
2271
2279
|
}) => {
|
|
2272
|
-
const a = T(e, o), { inputRef:
|
|
2280
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
2273
2281
|
value: String(r ?? ""),
|
|
2274
2282
|
onChange: t,
|
|
2275
2283
|
onError: n,
|
|
2276
2284
|
validate: a
|
|
2277
2285
|
}), u = Math.max(1, Math.round(e.step ?? 1));
|
|
2278
|
-
return /* @__PURE__ */ g(
|
|
2286
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
2279
2287
|
"input",
|
|
2280
2288
|
{
|
|
2281
2289
|
id: e.name,
|
|
2282
2290
|
type: "number",
|
|
2283
2291
|
defaultValue: String(r ?? ""),
|
|
2284
|
-
ref:
|
|
2292
|
+
ref: s,
|
|
2285
2293
|
min: e.min ?? void 0,
|
|
2286
2294
|
max: e.max ?? void 0,
|
|
2287
2295
|
step: u,
|
|
@@ -2297,26 +2305,26 @@ const jt = s.memo(Mr), Vr = ({
|
|
|
2297
2305
|
) });
|
|
2298
2306
|
};
|
|
2299
2307
|
Vr.displayName = "NumericStepperInput";
|
|
2300
|
-
const Ht =
|
|
2308
|
+
const Ht = c.memo(Vr), $r = ({
|
|
2301
2309
|
field: e,
|
|
2302
2310
|
value: r,
|
|
2303
2311
|
onChange: t,
|
|
2304
2312
|
onError: n,
|
|
2305
2313
|
error: o
|
|
2306
2314
|
}) => {
|
|
2307
|
-
const a = T(e, o), { inputRef:
|
|
2315
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
2308
2316
|
value: r,
|
|
2309
2317
|
onChange: t,
|
|
2310
2318
|
onError: n,
|
|
2311
2319
|
validate: a
|
|
2312
2320
|
});
|
|
2313
|
-
return /* @__PURE__ */ g(
|
|
2321
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
2314
2322
|
"input",
|
|
2315
2323
|
{
|
|
2316
2324
|
id: e.name,
|
|
2317
2325
|
type: "tel",
|
|
2318
2326
|
defaultValue: String(r ?? ""),
|
|
2319
|
-
ref:
|
|
2327
|
+
ref: s,
|
|
2320
2328
|
onChange: i,
|
|
2321
2329
|
className: W(R.input, R.textInput),
|
|
2322
2330
|
"aria-invalid": !!l,
|
|
@@ -2325,40 +2333,40 @@ const Ht = s.memo(Vr), $r = ({
|
|
|
2325
2333
|
) });
|
|
2326
2334
|
};
|
|
2327
2335
|
$r.displayName = "PhoneInput";
|
|
2328
|
-
const qt =
|
|
2336
|
+
const qt = c.memo($r), Rr = ({
|
|
2329
2337
|
field: e,
|
|
2330
2338
|
value: r,
|
|
2331
2339
|
onChange: t,
|
|
2332
2340
|
onError: n,
|
|
2333
2341
|
error: o
|
|
2334
2342
|
}) => {
|
|
2335
|
-
const { t: a } = j(),
|
|
2336
|
-
|
|
2343
|
+
const { t: a } = j(), s = T(e, o), l = e.layout?.toLowerCase() === "horizontal" ? "row" : "column", i = c.useRef(n);
|
|
2344
|
+
c.useEffect(() => {
|
|
2337
2345
|
i.current = n;
|
|
2338
2346
|
}, [n]);
|
|
2339
|
-
const [u,
|
|
2347
|
+
const [u, m] = c.useState(null), d = c.useRef(null), f = c.useCallback(
|
|
2340
2348
|
(y) => {
|
|
2341
|
-
y !==
|
|
2349
|
+
y !== d.current && (d.current = y, m(y), i.current?.(y));
|
|
2342
2350
|
},
|
|
2343
2351
|
[]
|
|
2344
2352
|
);
|
|
2345
|
-
|
|
2346
|
-
const y = r != null ? String(r) : "", C =
|
|
2353
|
+
c.useEffect(() => {
|
|
2354
|
+
const y = r != null ? String(r) : "", C = s(y, "sync");
|
|
2347
2355
|
if (C && e.options.length > 0) {
|
|
2348
2356
|
const V = String(e.options[0].value);
|
|
2349
2357
|
t?.(V);
|
|
2350
2358
|
}
|
|
2351
2359
|
f(C);
|
|
2352
|
-
}, [r, e.options,
|
|
2360
|
+
}, [r, e.options, s, t, f]);
|
|
2353
2361
|
const h = (y) => {
|
|
2354
|
-
const C = y.target.value, V =
|
|
2362
|
+
const C = y.target.value, V = s(C, "change");
|
|
2355
2363
|
f(V), t?.(C);
|
|
2356
|
-
},
|
|
2364
|
+
}, k = c.useCallback(
|
|
2357
2365
|
(y) => {
|
|
2358
|
-
const C =
|
|
2366
|
+
const C = s(y.target.value, "blur");
|
|
2359
2367
|
f(C);
|
|
2360
2368
|
},
|
|
2361
|
-
[
|
|
2369
|
+
[s, f]
|
|
2362
2370
|
), v = {
|
|
2363
2371
|
display: "flex",
|
|
2364
2372
|
flexDirection: l,
|
|
@@ -2378,7 +2386,7 @@ const qt = s.memo($r), Rr = ({
|
|
|
2378
2386
|
width: l === "column" ? "100%" : void 0,
|
|
2379
2387
|
justifyContent: "flex-start"
|
|
2380
2388
|
};
|
|
2381
|
-
return /* @__PURE__ */ g(
|
|
2389
|
+
return /* @__PURE__ */ g(B, { field: e, error: u, children: /* @__PURE__ */ g(
|
|
2382
2390
|
"div",
|
|
2383
2391
|
{
|
|
2384
2392
|
className: R.input,
|
|
@@ -2406,7 +2414,7 @@ const qt = s.memo($r), Rr = ({
|
|
|
2406
2414
|
value: C,
|
|
2407
2415
|
checked: String(r ?? "") === C,
|
|
2408
2416
|
onChange: h,
|
|
2409
|
-
onBlur:
|
|
2417
|
+
onBlur: k,
|
|
2410
2418
|
style: { width: "1.1em", height: "1.1em" }
|
|
2411
2419
|
}
|
|
2412
2420
|
),
|
|
@@ -2431,7 +2439,7 @@ const qt = s.memo($r), Rr = ({
|
|
|
2431
2439
|
) });
|
|
2432
2440
|
};
|
|
2433
2441
|
Rr.displayName = "RadioInput";
|
|
2434
|
-
const Ut =
|
|
2442
|
+
const Ut = c.memo(Rr), Wt = {
|
|
2435
2443
|
display: "flex",
|
|
2436
2444
|
gap: 4
|
|
2437
2445
|
}, _t = {
|
|
@@ -2443,28 +2451,28 @@ const Ut = s.memo(Rr), Wt = {
|
|
|
2443
2451
|
userSelect: "none",
|
|
2444
2452
|
transition: "color 0.12s ease"
|
|
2445
2453
|
}, Ar = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
2446
|
-
const { t: a } = j(),
|
|
2447
|
-
|
|
2454
|
+
const { t: a } = j(), s = T(e, o), l = e.max ?? 5, i = e.icon?.trim() || "★", [u, m] = c.useState(null), d = c.useRef([]), [f, h] = c.useState(null), k = c.useRef(null), v = c.useRef(n);
|
|
2455
|
+
c.useEffect(() => {
|
|
2448
2456
|
v.current = n;
|
|
2449
2457
|
}, [n]);
|
|
2450
|
-
const p =
|
|
2451
|
-
I !==
|
|
2452
|
-
}, []), y =
|
|
2453
|
-
|
|
2454
|
-
p(
|
|
2455
|
-
}, [
|
|
2456
|
-
const C =
|
|
2458
|
+
const p = c.useCallback((I) => {
|
|
2459
|
+
I !== k.current && (k.current = I, h(I), v.current?.(I ?? null));
|
|
2460
|
+
}, []), y = c.useMemo(() => Math.min(Math.max(r ?? 0, 0), l), [r, l]);
|
|
2461
|
+
c.useEffect(() => {
|
|
2462
|
+
p(s(y, "sync") ?? null);
|
|
2463
|
+
}, [s, y, p]);
|
|
2464
|
+
const C = c.useCallback(
|
|
2457
2465
|
(I) => {
|
|
2458
2466
|
const M = Math.min(Math.max(I, 0), l);
|
|
2459
|
-
p(
|
|
2467
|
+
p(s(M, "change") ?? null), t?.(M);
|
|
2460
2468
|
},
|
|
2461
|
-
[l, t, p,
|
|
2462
|
-
), V =
|
|
2469
|
+
[l, t, p, s]
|
|
2470
|
+
), V = c.useCallback(
|
|
2463
2471
|
(I) => {
|
|
2464
|
-
I.currentTarget.contains(I.relatedTarget) || p(
|
|
2472
|
+
I.currentTarget.contains(I.relatedTarget) || p(s(y, "blur") ?? null);
|
|
2465
2473
|
},
|
|
2466
|
-
[y, p,
|
|
2467
|
-
), A =
|
|
2474
|
+
[y, p, s]
|
|
2475
|
+
), A = c.useCallback(
|
|
2468
2476
|
(I, M) => {
|
|
2469
2477
|
switch (I.key) {
|
|
2470
2478
|
case "Enter":
|
|
@@ -2473,17 +2481,17 @@ const Ut = s.memo(Rr), Wt = {
|
|
|
2473
2481
|
break;
|
|
2474
2482
|
case "ArrowRight":
|
|
2475
2483
|
case "ArrowUp":
|
|
2476
|
-
I.preventDefault(),
|
|
2484
|
+
I.preventDefault(), d.current[Math.min(l - 1, M + 1)]?.focus();
|
|
2477
2485
|
break;
|
|
2478
2486
|
case "ArrowLeft":
|
|
2479
2487
|
case "ArrowDown":
|
|
2480
|
-
I.preventDefault(),
|
|
2488
|
+
I.preventDefault(), d.current[Math.max(0, M - 1)]?.focus();
|
|
2481
2489
|
break;
|
|
2482
2490
|
}
|
|
2483
2491
|
},
|
|
2484
2492
|
[l, C]
|
|
2485
2493
|
);
|
|
2486
|
-
return /* @__PURE__ */ g(
|
|
2494
|
+
return /* @__PURE__ */ g(B, { field: e, error: f, children: /* @__PURE__ */ g(
|
|
2487
2495
|
"div",
|
|
2488
2496
|
{
|
|
2489
2497
|
role: "radiogroup",
|
|
@@ -2497,16 +2505,16 @@ const Ut = s.memo(Rr), Wt = {
|
|
|
2497
2505
|
return /* @__PURE__ */ g(
|
|
2498
2506
|
"span",
|
|
2499
2507
|
{
|
|
2500
|
-
ref: (
|
|
2508
|
+
ref: (E) => d.current[M] = E,
|
|
2501
2509
|
role: "radio",
|
|
2502
2510
|
tabIndex: y > 0 ? M === y - 1 ? 0 : -1 : M === 0 ? 0 : -1,
|
|
2503
2511
|
"aria-checked": F,
|
|
2504
2512
|
"aria-label": `Rating ${M + 1}`,
|
|
2505
2513
|
title: a(`${e.displayName} ${M + 1}`),
|
|
2506
2514
|
onClick: () => C(M + 1),
|
|
2507
|
-
onKeyDown: (
|
|
2508
|
-
onMouseEnter: () =>
|
|
2509
|
-
onMouseLeave: () =>
|
|
2515
|
+
onKeyDown: (E) => A(E, M),
|
|
2516
|
+
onMouseEnter: () => m(M),
|
|
2517
|
+
onMouseLeave: () => m(null),
|
|
2510
2518
|
style: { ..._t, color: x },
|
|
2511
2519
|
children: i
|
|
2512
2520
|
},
|
|
@@ -2517,25 +2525,25 @@ const Ut = s.memo(Rr), Wt = {
|
|
|
2517
2525
|
) });
|
|
2518
2526
|
};
|
|
2519
2527
|
Ar.displayName = "RatingInput";
|
|
2520
|
-
const Kt =
|
|
2528
|
+
const Kt = c.memo(Ar), Dr = ({
|
|
2521
2529
|
field: e,
|
|
2522
2530
|
value: r,
|
|
2523
2531
|
onChange: t,
|
|
2524
2532
|
onError: n,
|
|
2525
2533
|
error: o
|
|
2526
2534
|
}) => {
|
|
2527
|
-
const { t: a } = j(),
|
|
2535
|
+
const { t: a } = j(), s = T(e, o), { inputRef: l, error: i, handleChange: u } = K({
|
|
2528
2536
|
value: r,
|
|
2529
2537
|
onChange: t,
|
|
2530
2538
|
onError: n,
|
|
2531
|
-
validate:
|
|
2532
|
-
}), [
|
|
2533
|
-
return /* @__PURE__ */ g(
|
|
2539
|
+
validate: s
|
|
2540
|
+
}), [m, d] = c.useState(!1), f = () => d((h) => !h);
|
|
2541
|
+
return /* @__PURE__ */ g(B, { field: e, error: i, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", gap: 8, width: "100%" }, children: [
|
|
2534
2542
|
/* @__PURE__ */ g(
|
|
2535
2543
|
"input",
|
|
2536
2544
|
{
|
|
2537
2545
|
id: e.name,
|
|
2538
|
-
type:
|
|
2546
|
+
type: m ? "text" : "password",
|
|
2539
2547
|
defaultValue: String(r ?? ""),
|
|
2540
2548
|
ref: l,
|
|
2541
2549
|
onChange: u,
|
|
@@ -2550,7 +2558,7 @@ const Kt = s.memo(Ar), Dr = ({
|
|
|
2550
2558
|
{
|
|
2551
2559
|
type: "button",
|
|
2552
2560
|
onClick: f,
|
|
2553
|
-
"aria-label": a(
|
|
2561
|
+
"aria-label": a(m ? "Hide password" : "Show password"),
|
|
2554
2562
|
style: {
|
|
2555
2563
|
background: "transparent",
|
|
2556
2564
|
border: "none",
|
|
@@ -2560,43 +2568,43 @@ const Kt = s.memo(Ar), Dr = ({
|
|
|
2560
2568
|
padding: "4px 6px",
|
|
2561
2569
|
flexShrink: 0
|
|
2562
2570
|
},
|
|
2563
|
-
children:
|
|
2571
|
+
children: m ? "🙈" : "👁️"
|
|
2564
2572
|
}
|
|
2565
2573
|
)
|
|
2566
2574
|
] }) });
|
|
2567
2575
|
};
|
|
2568
2576
|
Dr.displayName = "PasswordInput";
|
|
2569
|
-
const Gt =
|
|
2570
|
-
const a = T(e, o),
|
|
2571
|
-
() => isNaN(Number(r)) ? String(
|
|
2577
|
+
const Gt = c.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
2578
|
+
const a = T(e, o), s = e.min ?? 0, l = e.max ?? 100, [i, u] = c.useState(
|
|
2579
|
+
() => isNaN(Number(r)) ? String(s) : String(Number(r))
|
|
2572
2580
|
);
|
|
2573
|
-
|
|
2574
|
-
const C = isNaN(Number(r)) ? String(
|
|
2581
|
+
c.useEffect(() => {
|
|
2582
|
+
const C = isNaN(Number(r)) ? String(s) : String(Number(r));
|
|
2575
2583
|
u(C);
|
|
2576
|
-
}, [r,
|
|
2577
|
-
const [
|
|
2578
|
-
|
|
2584
|
+
}, [r, s]);
|
|
2585
|
+
const [m, d] = c.useState(null), f = c.useRef(null), h = c.useRef(n);
|
|
2586
|
+
c.useEffect(() => {
|
|
2579
2587
|
h.current = n;
|
|
2580
2588
|
}, [n]);
|
|
2581
|
-
const
|
|
2582
|
-
C !== f.current && (f.current = C,
|
|
2589
|
+
const k = c.useCallback((C) => {
|
|
2590
|
+
C !== f.current && (f.current = C, d(C), h.current?.(C ?? null));
|
|
2583
2591
|
}, []);
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
}, [a, i,
|
|
2587
|
-
const v =
|
|
2592
|
+
c.useEffect(() => {
|
|
2593
|
+
k(a(i, "sync") ?? null);
|
|
2594
|
+
}, [a, i, k]);
|
|
2595
|
+
const v = c.useCallback(
|
|
2588
2596
|
(C) => {
|
|
2589
2597
|
const V = C.target.value;
|
|
2590
|
-
u(V),
|
|
2598
|
+
u(V), k(a(V, "change") ?? null), t?.(V);
|
|
2591
2599
|
},
|
|
2592
|
-
[t,
|
|
2593
|
-
), p =
|
|
2600
|
+
[t, k, a]
|
|
2601
|
+
), p = c.useCallback(
|
|
2594
2602
|
(C) => {
|
|
2595
|
-
|
|
2603
|
+
k(a(C.target.value, "blur") ?? null);
|
|
2596
2604
|
},
|
|
2597
|
-
[
|
|
2598
|
-
), y = isNaN(Number(i)) ? String(
|
|
2599
|
-
return /* @__PURE__ */ g(
|
|
2605
|
+
[k, a]
|
|
2606
|
+
), y = isNaN(Number(i)) ? String(s) : String(Number(i));
|
|
2607
|
+
return /* @__PURE__ */ g(B, { field: e, error: m, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" }, children: [
|
|
2600
2608
|
/* @__PURE__ */ g(
|
|
2601
2609
|
"input",
|
|
2602
2610
|
{
|
|
@@ -2605,7 +2613,7 @@ const Gt = s.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2605
2613
|
value: y,
|
|
2606
2614
|
onChange: v,
|
|
2607
2615
|
onBlur: p,
|
|
2608
|
-
min:
|
|
2616
|
+
min: s,
|
|
2609
2617
|
max: l,
|
|
2610
2618
|
step: "1.0",
|
|
2611
2619
|
style: {
|
|
@@ -2613,8 +2621,8 @@ const Gt = s.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2613
2621
|
flex: 1
|
|
2614
2622
|
},
|
|
2615
2623
|
className: R.rangeInput,
|
|
2616
|
-
"aria-invalid": !!
|
|
2617
|
-
"aria-describedby":
|
|
2624
|
+
"aria-invalid": !!m,
|
|
2625
|
+
"aria-describedby": m ? `${e.name}-error` : void 0
|
|
2618
2626
|
}
|
|
2619
2627
|
),
|
|
2620
2628
|
/* @__PURE__ */ g(
|
|
@@ -2634,42 +2642,42 @@ const Gt = s.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2634
2642
|
flexShrink: 0
|
|
2635
2643
|
},
|
|
2636
2644
|
className: W(R.input, R.textInput),
|
|
2637
|
-
"aria-invalid": !!
|
|
2638
|
-
"aria-describedby":
|
|
2645
|
+
"aria-invalid": !!m,
|
|
2646
|
+
"aria-describedby": m ? `${e.name}-error` : void 0
|
|
2639
2647
|
}
|
|
2640
2648
|
)
|
|
2641
2649
|
] }) });
|
|
2642
2650
|
};
|
|
2643
2651
|
zr.displayName = "SliderInput";
|
|
2644
|
-
const Jt =
|
|
2652
|
+
const Jt = c.memo(zr), Pr = ({
|
|
2645
2653
|
field: e,
|
|
2646
2654
|
value: r,
|
|
2647
2655
|
onChange: t,
|
|
2648
2656
|
onError: n,
|
|
2649
2657
|
error: o
|
|
2650
2658
|
}) => {
|
|
2651
|
-
const { t: a, formStyle:
|
|
2652
|
-
|
|
2659
|
+
const { t: a, formStyle: s, fieldStyle: l } = j(), i = T(e, o), [u, m] = c.useState(null), d = c.useRef(null), f = c.useRef(n);
|
|
2660
|
+
c.useEffect(() => {
|
|
2653
2661
|
f.current = n;
|
|
2654
2662
|
}, [n]);
|
|
2655
|
-
const h =
|
|
2656
|
-
b !==
|
|
2663
|
+
const h = c.useCallback((b) => {
|
|
2664
|
+
b !== d.current && (d.current = b, m(b), f.current?.(b ?? null));
|
|
2657
2665
|
}, []);
|
|
2658
|
-
|
|
2666
|
+
c.useEffect(() => {
|
|
2659
2667
|
h(i(!!r, "sync"));
|
|
2660
2668
|
}, [r, i, h]);
|
|
2661
|
-
const
|
|
2669
|
+
const k = s, v = l, p = (b, x, E) => {
|
|
2662
2670
|
if (!x) return {};
|
|
2663
2671
|
const w = b?.[x];
|
|
2664
|
-
return (
|
|
2665
|
-
}, y =
|
|
2672
|
+
return (E && w ? w[E] : void 0) ?? {};
|
|
2673
|
+
}, y = c.useMemo(() => ({
|
|
2666
2674
|
display: "inline-block",
|
|
2667
2675
|
position: "relative",
|
|
2668
2676
|
width: 44,
|
|
2669
2677
|
height: 24,
|
|
2670
|
-
...p(
|
|
2678
|
+
...p(k, "switch", "label"),
|
|
2671
2679
|
...p(v, void 0, "label")
|
|
2672
|
-
}), [
|
|
2680
|
+
}), [k, v]), C = c.useMemo(() => ({
|
|
2673
2681
|
position: "absolute",
|
|
2674
2682
|
opacity: 0,
|
|
2675
2683
|
top: 0,
|
|
@@ -2680,9 +2688,9 @@ const Jt = s.memo(zr), Pr = ({
|
|
|
2680
2688
|
cursor: "pointer",
|
|
2681
2689
|
pointerEvents: "none",
|
|
2682
2690
|
// Make hidden input non-interactive to avoid event conflicts
|
|
2683
|
-
...p(
|
|
2691
|
+
...p(k, "switch", "hiddenInput"),
|
|
2684
2692
|
...p(v, void 0, "hiddenInput")
|
|
2685
|
-
}), [
|
|
2693
|
+
}), [k, v]), V = c.useMemo(() => ({
|
|
2686
2694
|
position: "absolute",
|
|
2687
2695
|
cursor: "pointer",
|
|
2688
2696
|
top: 0,
|
|
@@ -2699,9 +2707,9 @@ const Jt = s.memo(zr), Pr = ({
|
|
|
2699
2707
|
borderWidth: 2,
|
|
2700
2708
|
borderStyle: "solid",
|
|
2701
2709
|
borderColor: "transparent",
|
|
2702
|
-
...p(
|
|
2710
|
+
...p(k, "switch", "slider"),
|
|
2703
2711
|
...p(v, void 0, "slider")
|
|
2704
|
-
}), [
|
|
2712
|
+
}), [k, v]), A = c.useMemo(() => ({
|
|
2705
2713
|
position: "absolute",
|
|
2706
2714
|
height: 16,
|
|
2707
2715
|
width: 16,
|
|
@@ -2711,15 +2719,15 @@ const Jt = s.memo(zr), Pr = ({
|
|
|
2711
2719
|
transition: "0.3s",
|
|
2712
2720
|
borderRadius: "50%",
|
|
2713
2721
|
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.3)",
|
|
2714
|
-
...p(
|
|
2722
|
+
...p(k, "switch", "knob"),
|
|
2715
2723
|
...p(v, void 0, "knob")
|
|
2716
|
-
}), [
|
|
2724
|
+
}), [k, v]), I = !!r, M = () => {
|
|
2717
2725
|
const b = !I;
|
|
2718
2726
|
h(i(b, "change")), t?.(b);
|
|
2719
|
-
}, F =
|
|
2727
|
+
}, F = c.useCallback(() => {
|
|
2720
2728
|
h(i(I, "blur"));
|
|
2721
2729
|
}, [I, h, i]);
|
|
2722
|
-
return /* @__PURE__ */ g(
|
|
2730
|
+
return /* @__PURE__ */ g(B, { field: e, error: u, rightAlign: !1, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }, children: [
|
|
2723
2731
|
/* @__PURE__ */ g(
|
|
2724
2732
|
"label",
|
|
2725
2733
|
{
|
|
@@ -2775,26 +2783,26 @@ const Jt = s.memo(zr), Pr = ({
|
|
|
2775
2783
|
] }) });
|
|
2776
2784
|
};
|
|
2777
2785
|
Pr.displayName = "SwitchInput";
|
|
2778
|
-
const Yt =
|
|
2786
|
+
const Yt = c.memo(Pr), Se = ({
|
|
2779
2787
|
field: e,
|
|
2780
2788
|
value: r,
|
|
2781
2789
|
onChange: t,
|
|
2782
2790
|
onError: n,
|
|
2783
2791
|
error: o
|
|
2784
2792
|
}) => {
|
|
2785
|
-
const a = T(e, o), { inputRef:
|
|
2793
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
2786
2794
|
value: r,
|
|
2787
2795
|
onChange: t,
|
|
2788
2796
|
onError: n,
|
|
2789
2797
|
validate: a
|
|
2790
2798
|
});
|
|
2791
|
-
return /* @__PURE__ */ g(
|
|
2799
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
2792
2800
|
"input",
|
|
2793
2801
|
{
|
|
2794
2802
|
id: e.name,
|
|
2795
2803
|
type: "text",
|
|
2796
2804
|
defaultValue: String(r ?? ""),
|
|
2797
|
-
ref:
|
|
2805
|
+
ref: s,
|
|
2798
2806
|
onChange: i,
|
|
2799
2807
|
className: W(R.input, R.textInput),
|
|
2800
2808
|
placeholder: e.placeholder,
|
|
@@ -2804,25 +2812,25 @@ const Yt = s.memo(Pr), Se = ({
|
|
|
2804
2812
|
) });
|
|
2805
2813
|
};
|
|
2806
2814
|
Se.displayName = "TextInput";
|
|
2807
|
-
const
|
|
2815
|
+
const Or = ({
|
|
2808
2816
|
field: e,
|
|
2809
2817
|
value: r,
|
|
2810
2818
|
onChange: t,
|
|
2811
2819
|
onError: n,
|
|
2812
2820
|
error: o
|
|
2813
2821
|
}) => {
|
|
2814
|
-
const a = T(e, o), { inputRef:
|
|
2822
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
2815
2823
|
value: r,
|
|
2816
2824
|
onChange: t,
|
|
2817
2825
|
onError: n,
|
|
2818
2826
|
validate: a
|
|
2819
2827
|
});
|
|
2820
|
-
return /* @__PURE__ */ g(
|
|
2828
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
2821
2829
|
"input",
|
|
2822
2830
|
{
|
|
2823
2831
|
id: e.name,
|
|
2824
2832
|
type: "time",
|
|
2825
|
-
ref:
|
|
2833
|
+
ref: s,
|
|
2826
2834
|
defaultValue: r,
|
|
2827
2835
|
step: e.includeSeconds ? 1 : 60,
|
|
2828
2836
|
onChange: i,
|
|
@@ -2834,30 +2842,30 @@ const Br = ({
|
|
|
2834
2842
|
}
|
|
2835
2843
|
) });
|
|
2836
2844
|
};
|
|
2837
|
-
|
|
2838
|
-
const Xt =
|
|
2845
|
+
Or.displayName = "TimeInput";
|
|
2846
|
+
const Xt = c.memo(Or);
|
|
2839
2847
|
function Zt({
|
|
2840
2848
|
pos: e,
|
|
2841
2849
|
options: r,
|
|
2842
2850
|
onClose: t,
|
|
2843
2851
|
onClickOption: n
|
|
2844
2852
|
}) {
|
|
2845
|
-
const o =
|
|
2853
|
+
const o = c.useRef(null), a = c.useRef(!1), [s, l] = c.useState({
|
|
2846
2854
|
top: e?.y ?? 0,
|
|
2847
2855
|
left: e?.x ?? 0,
|
|
2848
2856
|
ready: !1
|
|
2849
2857
|
}), i = typeof window < "u" ? document.getElementById("popup-root") || document.body : null;
|
|
2850
|
-
return
|
|
2851
|
-
function u(
|
|
2852
|
-
a.current ||
|
|
2858
|
+
return c.useEffect(() => {
|
|
2859
|
+
function u(m) {
|
|
2860
|
+
a.current || m.target.dataset?.popupMenu === "item" || o.current && m.target instanceof Node && !o.current.contains(m.target) && t();
|
|
2853
2861
|
}
|
|
2854
2862
|
return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
|
|
2855
|
-
}, [t]),
|
|
2863
|
+
}, [t]), c.useLayoutEffect(() => {
|
|
2856
2864
|
if (!o.current || !e || e.x == null || e.y == null)
|
|
2857
2865
|
return;
|
|
2858
|
-
const u = o.current.getBoundingClientRect(),
|
|
2866
|
+
const u = o.current.getBoundingClientRect(), m = window.innerWidth, d = window.innerHeight;
|
|
2859
2867
|
let f = e.x, h = e.y;
|
|
2860
|
-
f + u.width >
|
|
2868
|
+
f + u.width > m && (f = Math.max(0, m - u.width - 10)), h + u.height > d && (h = Math.max(0, e.y - u.height - 5)), l({ top: h, left: f, ready: !0 });
|
|
2861
2869
|
}, [e, r]), !i || r === void 0 || r.length === 0 || !e || e.x == null || e.y == null ? null : fe.createPortal(
|
|
2862
2870
|
/* @__PURE__ */ g(
|
|
2863
2871
|
"div",
|
|
@@ -2868,9 +2876,9 @@ function Zt({
|
|
|
2868
2876
|
},
|
|
2869
2877
|
style: {
|
|
2870
2878
|
position: "fixed",
|
|
2871
|
-
top:
|
|
2872
|
-
left:
|
|
2873
|
-
visibility:
|
|
2879
|
+
top: s.top,
|
|
2880
|
+
left: s.left,
|
|
2881
|
+
visibility: s.ready ? "visible" : "hidden",
|
|
2874
2882
|
backgroundColor: "var(--reactaform-primary-bg, #fff)",
|
|
2875
2883
|
border: "1px solid var(--reactaform-border-color, #ccc)",
|
|
2876
2884
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
@@ -2881,15 +2889,15 @@ function Zt({
|
|
|
2881
2889
|
overflowY: "auto",
|
|
2882
2890
|
pointerEvents: "auto"
|
|
2883
2891
|
},
|
|
2884
|
-
children: r.map((u,
|
|
2892
|
+
children: r.map((u, m) => /* @__PURE__ */ g(
|
|
2885
2893
|
"div",
|
|
2886
2894
|
{
|
|
2887
2895
|
"data-popup-menu": "item",
|
|
2888
|
-
onMouseDown: (
|
|
2889
|
-
|
|
2896
|
+
onMouseDown: (d) => {
|
|
2897
|
+
d.stopPropagation(), a.current = !0;
|
|
2890
2898
|
},
|
|
2891
|
-
onClick: (
|
|
2892
|
-
|
|
2899
|
+
onClick: (d) => {
|
|
2900
|
+
d.stopPropagation(), d.preventDefault(), n(u), t(), setTimeout(() => {
|
|
2893
2901
|
a.current = !1;
|
|
2894
2902
|
}, 100);
|
|
2895
2903
|
},
|
|
@@ -2897,18 +2905,18 @@ function Zt({
|
|
|
2897
2905
|
padding: "var(--reactaform-menu-item-padding, 8px 12px)",
|
|
2898
2906
|
cursor: "pointer",
|
|
2899
2907
|
fontSize: "var(--reactaform-menu-item-font-size, 0.8em)",
|
|
2900
|
-
borderBottom:
|
|
2908
|
+
borderBottom: m < r.length - 1 ? "1px solid var(--reactaform-border-light, #eee)" : void 0,
|
|
2901
2909
|
transition: "background-color 0.15s ease"
|
|
2902
2910
|
},
|
|
2903
|
-
onMouseEnter: (
|
|
2904
|
-
|
|
2911
|
+
onMouseEnter: (d) => {
|
|
2912
|
+
d.currentTarget.style.backgroundColor = "var(--reactaform-option-menu-hover-bg, #e0e0e0)";
|
|
2905
2913
|
},
|
|
2906
|
-
onMouseLeave: (
|
|
2907
|
-
|
|
2914
|
+
onMouseLeave: (d) => {
|
|
2915
|
+
d.currentTarget.style.backgroundColor = "transparent";
|
|
2908
2916
|
},
|
|
2909
2917
|
children: u.label
|
|
2910
2918
|
},
|
|
2911
|
-
u.label ??
|
|
2919
|
+
u.label ?? m
|
|
2912
2920
|
))
|
|
2913
2921
|
}
|
|
2914
2922
|
),
|
|
@@ -3040,23 +3048,23 @@ const Re = {
|
|
|
3040
3048
|
for (const e of Qt) {
|
|
3041
3049
|
const r = {}, t = Re[e] ?? [], n = Ae[e] ?? {}, o = De[e] ?? {};
|
|
3042
3050
|
for (const a of t) {
|
|
3043
|
-
const
|
|
3051
|
+
const s = n[a];
|
|
3044
3052
|
r[a] = {
|
|
3045
|
-
name: typeof
|
|
3053
|
+
name: typeof s == "string" ? s : String(a),
|
|
3046
3054
|
shortName: a,
|
|
3047
3055
|
factor: a in o ? o[a] : void 0
|
|
3048
3056
|
};
|
|
3049
3057
|
}
|
|
3050
|
-
for (const [a,
|
|
3058
|
+
for (const [a, s] of Object.entries(n))
|
|
3051
3059
|
if (!r[a]) {
|
|
3052
|
-
const l = typeof
|
|
3060
|
+
const l = typeof s == "string" ? s : String(a);
|
|
3053
3061
|
r[a] = { name: l, shortName: a, factor: a in o ? o[a] : void 0 };
|
|
3054
3062
|
}
|
|
3055
|
-
for (const [a,
|
|
3056
|
-
r[a] || (r[a] = { name: String(a), shortName: String(a), factor:
|
|
3063
|
+
for (const [a, s] of Object.entries(o))
|
|
3064
|
+
r[a] || (r[a] = { name: String(a), shortName: String(a), factor: s });
|
|
3057
3065
|
ze[e] = r;
|
|
3058
3066
|
}
|
|
3059
|
-
function
|
|
3067
|
+
function Br(e, r, t) {
|
|
3060
3068
|
if (e === "C") {
|
|
3061
3069
|
if (r === "F") return t * (9 / 5) + 32;
|
|
3062
3070
|
if (r === "K") return t + 273.15;
|
|
@@ -3069,12 +3077,12 @@ function Lr(e, r, t) {
|
|
|
3069
3077
|
}
|
|
3070
3078
|
return t;
|
|
3071
3079
|
}
|
|
3072
|
-
function
|
|
3080
|
+
function Lr(e) {
|
|
3073
3081
|
const r = ze[e];
|
|
3074
3082
|
if (!r) return null;
|
|
3075
3083
|
const t = {}, n = [];
|
|
3076
|
-
for (const [a,
|
|
3077
|
-
typeof
|
|
3084
|
+
for (const [a, s] of Object.entries(r))
|
|
3085
|
+
typeof s.factor == "number" && (t[a] = s.factor), n.push(a);
|
|
3078
3086
|
return {
|
|
3079
3087
|
default: Object.keys(r)[0] ?? "",
|
|
3080
3088
|
units: n,
|
|
@@ -3083,34 +3091,34 @@ function Or(e) {
|
|
|
3083
3091
|
}
|
|
3084
3092
|
const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3085
3093
|
__proto__: null,
|
|
3086
|
-
convertTemperature:
|
|
3094
|
+
convertTemperature: Br,
|
|
3087
3095
|
dimensionUnitDisplayMap: Ae,
|
|
3088
3096
|
dimensionUnitsMap: Re,
|
|
3089
3097
|
dimensonUnitFactorsMap: De,
|
|
3090
|
-
getUnitFactors:
|
|
3098
|
+
getUnitFactors: Lr,
|
|
3091
3099
|
unitsByDimension: ze
|
|
3092
|
-
}, Symbol.toStringTag, { value: "Module" })), Tr =
|
|
3100
|
+
}, Symbol.toStringTag, { value: "Module" })), Tr = c.memo(({
|
|
3093
3101
|
disabled: e,
|
|
3094
3102
|
inputValue: r,
|
|
3095
3103
|
selectedUnit: t,
|
|
3096
3104
|
dimension: n,
|
|
3097
3105
|
unitFactors: o,
|
|
3098
3106
|
onConversionSelect: a,
|
|
3099
|
-
t:
|
|
3107
|
+
t: s
|
|
3100
3108
|
}) => {
|
|
3101
|
-
const [l, i] =
|
|
3109
|
+
const [l, i] = c.useState(!1), [u, m] = c.useState(null), [d, f] = c.useState([]), h = c.useCallback(
|
|
3102
3110
|
(p) => {
|
|
3103
3111
|
if (e) return;
|
|
3104
3112
|
const y = parseFloat(r);
|
|
3105
3113
|
if (!Number.isFinite(y)) return;
|
|
3106
3114
|
const C = p.currentTarget.getBoundingClientRect();
|
|
3107
|
-
|
|
3115
|
+
m({ x: C.left, y: C.bottom });
|
|
3108
3116
|
const V = [];
|
|
3109
3117
|
if (n === "temperature")
|
|
3110
3118
|
o.units.forEach((I) => {
|
|
3111
|
-
const M =
|
|
3119
|
+
const M = Br(t, I, y);
|
|
3112
3120
|
Number.isFinite(M) && V.push({
|
|
3113
|
-
label: `${M.toFixed(6)} ${
|
|
3121
|
+
label: `${M.toFixed(6)} ${s(I)}`,
|
|
3114
3122
|
value: M.toString(),
|
|
3115
3123
|
unit: I
|
|
3116
3124
|
});
|
|
@@ -3120,7 +3128,7 @@ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3120
3128
|
I !== void 0 && Object.entries(o.factors).forEach(([M, F]) => {
|
|
3121
3129
|
const b = y / I * F;
|
|
3122
3130
|
Number.isFinite(b) && V.push({
|
|
3123
|
-
label: `${b.toFixed(6)} ${
|
|
3131
|
+
label: `${b.toFixed(6)} ${s(M)}`,
|
|
3124
3132
|
value: b.toString(),
|
|
3125
3133
|
unit: M
|
|
3126
3134
|
});
|
|
@@ -3128,14 +3136,14 @@ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3128
3136
|
}
|
|
3129
3137
|
f(V), i(V.length > 0);
|
|
3130
3138
|
},
|
|
3131
|
-
[e, r, t, n, o,
|
|
3132
|
-
),
|
|
3139
|
+
[e, r, t, n, o, s]
|
|
3140
|
+
), k = c.useCallback(
|
|
3133
3141
|
(p) => {
|
|
3134
|
-
i(!1),
|
|
3142
|
+
i(!1), m(null), a(p);
|
|
3135
3143
|
},
|
|
3136
3144
|
[a]
|
|
3137
|
-
), v =
|
|
3138
|
-
i(!1),
|
|
3145
|
+
), v = c.useCallback(() => {
|
|
3146
|
+
i(!1), m(null);
|
|
3139
3147
|
}, []);
|
|
3140
3148
|
return /* @__PURE__ */ z(Fe, { children: [
|
|
3141
3149
|
/* @__PURE__ */ g(
|
|
@@ -3164,59 +3172,59 @@ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3164
3172
|
children: /* @__PURE__ */ g("span", { style: { fontSize: "1em", pointerEvents: "none" }, children: "⇄" })
|
|
3165
3173
|
}
|
|
3166
3174
|
),
|
|
3167
|
-
l &&
|
|
3175
|
+
l && d.length > 0 && /* @__PURE__ */ g(
|
|
3168
3176
|
Zt,
|
|
3169
3177
|
{
|
|
3170
3178
|
pos: u,
|
|
3171
|
-
options:
|
|
3179
|
+
options: d,
|
|
3172
3180
|
onClose: v,
|
|
3173
|
-
onClickOption:
|
|
3181
|
+
onClickOption: k
|
|
3174
3182
|
}
|
|
3175
3183
|
)
|
|
3176
3184
|
] });
|
|
3177
3185
|
});
|
|
3178
3186
|
Tr.displayName = "ConversionButton";
|
|
3179
3187
|
const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
3180
|
-
const { t: o } = j(), a = T(e), [
|
|
3181
|
-
|
|
3188
|
+
const { t: o } = j(), a = T(e), [s, l] = c.useState(null), i = c.useRef(null), u = c.useRef(n);
|
|
3189
|
+
c.useEffect(() => {
|
|
3182
3190
|
u.current = n;
|
|
3183
3191
|
}, [n]);
|
|
3184
|
-
const
|
|
3192
|
+
const m = c.useCallback((x) => {
|
|
3185
3193
|
x !== i.current && (i.current = x, l(x), u.current?.(x ?? null));
|
|
3186
|
-
}, []),
|
|
3187
|
-
|
|
3194
|
+
}, []), d = e.dimension, f = c.useMemo(() => d ? Lr(d) : null, [d]), h = String(r?.[0] ?? ""), k = String(r?.[1] ?? f?.default ?? ""), [v, p] = c.useState(h), [y, C] = c.useState(k);
|
|
3195
|
+
c.useEffect(() => {
|
|
3188
3196
|
p(h);
|
|
3189
|
-
}, [h]),
|
|
3190
|
-
C(
|
|
3191
|
-
}, [
|
|
3192
|
-
|
|
3193
|
-
}, [v, y,
|
|
3194
|
-
const V =
|
|
3197
|
+
}, [h]), c.useEffect(() => {
|
|
3198
|
+
C(k);
|
|
3199
|
+
}, [k]), c.useEffect(() => {
|
|
3200
|
+
m(a([v, y], "sync"));
|
|
3201
|
+
}, [v, y, m, a]);
|
|
3202
|
+
const V = c.useCallback(
|
|
3195
3203
|
(x) => {
|
|
3196
|
-
const
|
|
3197
|
-
p(
|
|
3204
|
+
const E = x.target.value;
|
|
3205
|
+
p(E), m(a([E, y], "change")), t?.([E, y]);
|
|
3198
3206
|
},
|
|
3199
|
-
[y, a, t,
|
|
3200
|
-
), A =
|
|
3207
|
+
[y, a, t, m]
|
|
3208
|
+
), A = c.useCallback(
|
|
3201
3209
|
(x) => {
|
|
3202
|
-
const
|
|
3203
|
-
C(
|
|
3210
|
+
const E = x.target.value;
|
|
3211
|
+
C(E), m(a([v, E], "change")), t?.([v, E]);
|
|
3204
3212
|
},
|
|
3205
|
-
[v, a, t,
|
|
3206
|
-
), I =
|
|
3207
|
-
|
|
3208
|
-
}, [v, y,
|
|
3213
|
+
[v, a, t, m]
|
|
3214
|
+
), I = c.useCallback(() => {
|
|
3215
|
+
m(a([v, y], "blur"));
|
|
3216
|
+
}, [v, y, m, a]), M = c.useCallback(
|
|
3209
3217
|
(x) => {
|
|
3210
3218
|
p(x.value), C(x.unit), t?.([x.value, x.unit]);
|
|
3211
3219
|
},
|
|
3212
3220
|
[t]
|
|
3213
|
-
), F =
|
|
3221
|
+
), F = c.useMemo(
|
|
3214
3222
|
() => f ? f.units.map((x) => /* @__PURE__ */ g("option", { value: x, children: o(x) }, x)) : [],
|
|
3215
3223
|
[f, o]
|
|
3216
3224
|
);
|
|
3217
|
-
if (!
|
|
3218
|
-
const b = !!
|
|
3219
|
-
return /* @__PURE__ */ g(
|
|
3225
|
+
if (!d || !f) return null;
|
|
3226
|
+
const b = !!s || !v.trim();
|
|
3227
|
+
return /* @__PURE__ */ g(B, { field: e, error: s, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", gap: "var(--reactaform-unit-gap, 8px)", width: "100%" }, children: [
|
|
3220
3228
|
/* @__PURE__ */ g(
|
|
3221
3229
|
"input",
|
|
3222
3230
|
{
|
|
@@ -3227,8 +3235,8 @@ const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3227
3235
|
onBlur: I,
|
|
3228
3236
|
style: { flex: "2 1 0" },
|
|
3229
3237
|
className: W(R.input, R.textInput),
|
|
3230
|
-
"aria-invalid": !!
|
|
3231
|
-
"aria-describedby":
|
|
3238
|
+
"aria-invalid": !!s,
|
|
3239
|
+
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
3232
3240
|
}
|
|
3233
3241
|
),
|
|
3234
3242
|
/* @__PURE__ */ g(
|
|
@@ -3240,8 +3248,8 @@ const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3240
3248
|
onBlur: I,
|
|
3241
3249
|
style: { flex: "1 1 0" },
|
|
3242
3250
|
className: W(R.input, R.inputSelect),
|
|
3243
|
-
"aria-invalid": !!
|
|
3244
|
-
"aria-describedby":
|
|
3251
|
+
"aria-invalid": !!s,
|
|
3252
|
+
"aria-describedby": s ? `${e.name}-error` : void 0,
|
|
3245
3253
|
children: F
|
|
3246
3254
|
}
|
|
3247
3255
|
),
|
|
@@ -3251,7 +3259,7 @@ const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3251
3259
|
disabled: b,
|
|
3252
3260
|
inputValue: v,
|
|
3253
3261
|
selectedUnit: y,
|
|
3254
|
-
dimension:
|
|
3262
|
+
dimension: d,
|
|
3255
3263
|
unitFactors: f,
|
|
3256
3264
|
onConversionSelect: M,
|
|
3257
3265
|
t: o
|
|
@@ -3260,26 +3268,26 @@ const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3260
3268
|
] }) });
|
|
3261
3269
|
};
|
|
3262
3270
|
jr.displayName = "UnitValueInput";
|
|
3263
|
-
const en =
|
|
3271
|
+
const en = c.memo(jr), Hr = ({
|
|
3264
3272
|
field: e,
|
|
3265
3273
|
value: r,
|
|
3266
3274
|
onChange: t,
|
|
3267
3275
|
onError: n,
|
|
3268
3276
|
error: o
|
|
3269
3277
|
}) => {
|
|
3270
|
-
const a = T(e, o), { inputRef:
|
|
3278
|
+
const a = T(e, o), { inputRef: s, error: l, handleChange: i } = K({
|
|
3271
3279
|
value: r,
|
|
3272
3280
|
onChange: t,
|
|
3273
3281
|
onError: n,
|
|
3274
3282
|
validate: a
|
|
3275
3283
|
});
|
|
3276
|
-
return /* @__PURE__ */ g(
|
|
3284
|
+
return /* @__PURE__ */ g(B, { field: e, error: l, children: /* @__PURE__ */ g(
|
|
3277
3285
|
"input",
|
|
3278
3286
|
{
|
|
3279
3287
|
id: e.name,
|
|
3280
3288
|
type: "url",
|
|
3281
3289
|
defaultValue: String(r ?? ""),
|
|
3282
|
-
ref:
|
|
3290
|
+
ref: s,
|
|
3283
3291
|
onChange: i,
|
|
3284
3292
|
className: W(R.input, R.textInput),
|
|
3285
3293
|
placeholder: "https://example.com",
|
|
@@ -3289,7 +3297,7 @@ const en = s.memo(jr), Hr = ({
|
|
|
3289
3297
|
) });
|
|
3290
3298
|
};
|
|
3291
3299
|
Hr.displayName = "UrlInput";
|
|
3292
|
-
const rn =
|
|
3300
|
+
const rn = c.memo(Hr), le = new ae();
|
|
3293
3301
|
function po(e, r) {
|
|
3294
3302
|
le.register(e, r);
|
|
3295
3303
|
}
|
|
@@ -3311,7 +3319,7 @@ const qr = ({
|
|
|
3311
3319
|
handleChange: t,
|
|
3312
3320
|
handleError: n
|
|
3313
3321
|
}) => {
|
|
3314
|
-
const { t: o } = j(), [a,
|
|
3322
|
+
const { t: o } = j(), [a, s] = c.useState(!1), [l, i] = c.useState(null), u = c.useCallback(async () => {
|
|
3315
3323
|
if (!e.action) {
|
|
3316
3324
|
console.warn(`Button "${e.name}" has no action defined`);
|
|
3317
3325
|
return;
|
|
@@ -3322,20 +3330,20 @@ const qr = ({
|
|
|
3322
3330
|
console.error(h), i(h);
|
|
3323
3331
|
return;
|
|
3324
3332
|
}
|
|
3325
|
-
|
|
3333
|
+
s(!0), i(null);
|
|
3326
3334
|
try {
|
|
3327
3335
|
await f(r, t, n, o);
|
|
3328
3336
|
} catch (h) {
|
|
3329
|
-
const
|
|
3330
|
-
console.error(`Button handler "${e.action}" failed:`,
|
|
3337
|
+
const k = h instanceof Error ? h.message : String(h);
|
|
3338
|
+
console.error(`Button handler "${e.action}" failed:`, k), i(k);
|
|
3331
3339
|
} finally {
|
|
3332
|
-
|
|
3340
|
+
s(!1);
|
|
3333
3341
|
}
|
|
3334
|
-
}, [e, r, t, n, o]),
|
|
3342
|
+
}, [e, r, t, n, o]), d = { ...{
|
|
3335
3343
|
cursor: a ? "wait" : "pointer",
|
|
3336
3344
|
opacity: a ? 0.6 : 1
|
|
3337
3345
|
} };
|
|
3338
|
-
return e.width && typeof e.width == "number" && e.width > 0 && (
|
|
3346
|
+
return e.width && typeof e.width == "number" && e.width > 0 && (d.width = `${e.width}px`), /* @__PURE__ */ g(B, { field: e, rightAlign: !0, error: l, children: /* @__PURE__ */ g(
|
|
3339
3347
|
"button",
|
|
3340
3348
|
{
|
|
3341
3349
|
type: "button",
|
|
@@ -3344,13 +3352,13 @@ const qr = ({
|
|
|
3344
3352
|
disabled: a,
|
|
3345
3353
|
"aria-label": o(e.displayName),
|
|
3346
3354
|
"aria-busy": a,
|
|
3347
|
-
style:
|
|
3355
|
+
style: d,
|
|
3348
3356
|
children: o(a ? "Processing..." : e.displayName)
|
|
3349
3357
|
}
|
|
3350
3358
|
) });
|
|
3351
3359
|
};
|
|
3352
3360
|
qr.displayName = "Button";
|
|
3353
|
-
const nn =
|
|
3361
|
+
const nn = c.memo(qr), on = {
|
|
3354
3362
|
// No debounce
|
|
3355
3363
|
checkbox: !1,
|
|
3356
3364
|
switch: !1,
|
|
@@ -3394,10 +3402,10 @@ const nn = s.memo(qr), on = {
|
|
|
3394
3402
|
float: Dt,
|
|
3395
3403
|
"float-array": At,
|
|
3396
3404
|
image: Pt,
|
|
3397
|
-
int:
|
|
3398
|
-
"int-array":
|
|
3405
|
+
int: Bt,
|
|
3406
|
+
"int-array": Ot,
|
|
3399
3407
|
"multi-selection": jt,
|
|
3400
|
-
multiline:
|
|
3408
|
+
multiline: Lt,
|
|
3401
3409
|
password: Gt,
|
|
3402
3410
|
phone: qt,
|
|
3403
3411
|
radio: Ut,
|
|
@@ -3416,21 +3424,21 @@ function an(e) {
|
|
|
3416
3424
|
return e in Pe;
|
|
3417
3425
|
}
|
|
3418
3426
|
function sn(e, r) {
|
|
3419
|
-
const { wait: t = 200, leading: n, trailing: o } = r, a =
|
|
3420
|
-
const l =
|
|
3421
|
-
|
|
3422
|
-
l.current =
|
|
3423
|
-
}, [
|
|
3427
|
+
const { wait: t = 200, leading: n, trailing: o } = r, a = c.memo((s) => {
|
|
3428
|
+
const l = c.useRef(s.onChange);
|
|
3429
|
+
c.useEffect(() => {
|
|
3430
|
+
l.current = s.onChange;
|
|
3431
|
+
}, [s.onChange]);
|
|
3424
3432
|
const { callback: i, cancel: u } = ut(
|
|
3425
|
-
(...
|
|
3426
|
-
l.current?.(...
|
|
3433
|
+
(...m) => {
|
|
3434
|
+
l.current?.(...m);
|
|
3427
3435
|
},
|
|
3428
3436
|
t,
|
|
3429
3437
|
{ leading: n, trailing: o }
|
|
3430
3438
|
);
|
|
3431
|
-
return
|
|
3439
|
+
return c.useEffect(() => u, [u]), c.createElement(
|
|
3432
3440
|
e,
|
|
3433
|
-
{ ...
|
|
3441
|
+
{ ...s, onChange: i }
|
|
3434
3442
|
);
|
|
3435
3443
|
});
|
|
3436
3444
|
return a.displayName = "DebouncedFieldWrapper", a;
|
|
@@ -3464,66 +3472,82 @@ function cn() {
|
|
|
3464
3472
|
Ur(e, r, !0);
|
|
3465
3473
|
}), Xe = !0);
|
|
3466
3474
|
}
|
|
3467
|
-
const
|
|
3475
|
+
const Oe = c.memo(
|
|
3468
3476
|
({ field: e, valuesMap: r, handleChange: t, handleError: n, errorsMap: o }) => {
|
|
3469
|
-
const a = _r(e.type),
|
|
3470
|
-
(
|
|
3477
|
+
const a = _r(e.type), s = r[e.name], l = o ? o[e.name] ?? null : void 0, i = !!e.disabled, u = c.useMemo(() => s, [s]), m = c.useCallback(
|
|
3478
|
+
(f) => t(e.name, f),
|
|
3471
3479
|
[t, e.name]
|
|
3472
|
-
), d =
|
|
3473
|
-
(
|
|
3480
|
+
), d = c.useCallback(
|
|
3481
|
+
(f) => n?.(e.name, f),
|
|
3474
3482
|
[n, e.name]
|
|
3475
3483
|
);
|
|
3476
|
-
return a ? e.type === "button" ? /* @__PURE__ */ g(
|
|
3477
|
-
|
|
3478
|
-
value: null,
|
|
3479
|
-
valuesMap: r,
|
|
3480
|
-
handleChange: t,
|
|
3481
|
-
handleError: n || (() => {
|
|
3482
|
-
})
|
|
3483
|
-
} }) : /* @__PURE__ */ g(
|
|
3484
|
-
a,
|
|
3484
|
+
return a ? e.type === "button" ? /* @__PURE__ */ g(
|
|
3485
|
+
"div",
|
|
3485
3486
|
{
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3487
|
+
"aria-disabled": i,
|
|
3488
|
+
style: i ? { opacity: 0.6, pointerEvents: "none" } : void 0,
|
|
3489
|
+
children: /* @__PURE__ */ g(a, { ...{
|
|
3490
|
+
field: e,
|
|
3491
|
+
value: null,
|
|
3492
|
+
disabled: i,
|
|
3493
|
+
valuesMap: r,
|
|
3494
|
+
handleChange: t,
|
|
3495
|
+
handleError: n || (() => {
|
|
3496
|
+
})
|
|
3497
|
+
} })
|
|
3498
|
+
}
|
|
3499
|
+
) : /* @__PURE__ */ g(
|
|
3500
|
+
"div",
|
|
3501
|
+
{
|
|
3502
|
+
"aria-disabled": i,
|
|
3503
|
+
style: i ? { opacity: 0.6, pointerEvents: "none" } : void 0,
|
|
3504
|
+
children: /* @__PURE__ */ g(
|
|
3505
|
+
a,
|
|
3506
|
+
{
|
|
3507
|
+
field: e,
|
|
3508
|
+
value: u,
|
|
3509
|
+
disabled: i,
|
|
3510
|
+
onChange: m,
|
|
3511
|
+
onError: d,
|
|
3512
|
+
error: l
|
|
3513
|
+
}
|
|
3514
|
+
)
|
|
3491
3515
|
}
|
|
3492
3516
|
) : null;
|
|
3493
3517
|
},
|
|
3494
3518
|
(e, r) => e.field === r.field && e.valuesMap[e.field.name] === r.valuesMap[r.field.name] && e.handleChange === r.handleChange && e.handleError === r.handleError && e.errorsMap?.[e.field.name] === r.errorsMap?.[r.field.name]
|
|
3495
3519
|
);
|
|
3496
|
-
|
|
3497
|
-
const Kr =
|
|
3498
|
-
({ groupName: e, defaultOpen: r = !0, fields: t, valuesMap: n, handleChange: o, handleError: a, errorsMap:
|
|
3499
|
-
const [i, u] =
|
|
3520
|
+
Oe.displayName = "FieldRenderer";
|
|
3521
|
+
const Kr = c.memo(
|
|
3522
|
+
({ groupName: e, defaultOpen: r = !0, fields: t, valuesMap: n, handleChange: o, handleError: a, errorsMap: s, t: l }) => {
|
|
3523
|
+
const [i, u] = c.useState(r), m = c.useCallback(() => u((d) => !d), []);
|
|
3500
3524
|
return /* @__PURE__ */ z("fieldset", { className: "reactaform-group", children: [
|
|
3501
|
-
/* @__PURE__ */ z("legend", { onClick:
|
|
3525
|
+
/* @__PURE__ */ z("legend", { onClick: m, className: "reactaform-group_legend", children: [
|
|
3502
3526
|
/* @__PURE__ */ g("span", { children: l(e) }),
|
|
3503
3527
|
/* @__PURE__ */ g("span", { className: "reactaform-group_legend_arrow", children: i ? "▼" : "▶" })
|
|
3504
3528
|
] }),
|
|
3505
|
-
i && t.map((
|
|
3506
|
-
|
|
3529
|
+
i && t.map((d) => /* @__PURE__ */ g(
|
|
3530
|
+
Oe,
|
|
3507
3531
|
{
|
|
3508
|
-
field:
|
|
3532
|
+
field: d,
|
|
3509
3533
|
valuesMap: n,
|
|
3510
3534
|
handleChange: o,
|
|
3511
3535
|
handleError: a,
|
|
3512
|
-
errorsMap:
|
|
3536
|
+
errorsMap: s
|
|
3513
3537
|
},
|
|
3514
|
-
|
|
3538
|
+
d.name
|
|
3515
3539
|
))
|
|
3516
3540
|
] });
|
|
3517
3541
|
}
|
|
3518
3542
|
);
|
|
3519
3543
|
Kr.displayName = "FieldGroup";
|
|
3520
|
-
const
|
|
3544
|
+
const Be = (e, r, t, n) => {
|
|
3521
3545
|
const o = r[e];
|
|
3522
3546
|
if (!o?.children) return;
|
|
3523
|
-
const a = t[e],
|
|
3547
|
+
const a = t[e], s = a != null ? String(a) : "", l = o.children[s];
|
|
3524
3548
|
if (Array.isArray(l))
|
|
3525
3549
|
for (const i of l)
|
|
3526
|
-
typeof i == "string" && r[i] && (n[i] = !0,
|
|
3550
|
+
typeof i == "string" && r[i] && (n[i] = !0, Be(i, r, t, n));
|
|
3527
3551
|
}, Gr = (e, r, t) => {
|
|
3528
3552
|
const n = r[e];
|
|
3529
3553
|
if (!n?.children) return;
|
|
@@ -3533,15 +3557,15 @@ const Le = (e, r, t, n) => {
|
|
|
3533
3557
|
}, ln = (e, r, t, n) => {
|
|
3534
3558
|
const o = { ...t };
|
|
3535
3559
|
return e.forEach((a) => {
|
|
3536
|
-
(!a.parents || Object.keys(a.parents).length === 0) && (o[a.name] = !0,
|
|
3560
|
+
(!a.parents || Object.keys(a.parents).length === 0) && (o[a.name] = !0, Be(a.name, n, r, o));
|
|
3537
3561
|
}), o;
|
|
3538
3562
|
}, un = (e, r, t, n, o) => {
|
|
3539
|
-
const a = { ...e },
|
|
3540
|
-
if (Gr(n, r, a), o != null &&
|
|
3541
|
-
const l = String(o), i =
|
|
3563
|
+
const a = { ...e }, s = r[n];
|
|
3564
|
+
if (Gr(n, r, a), o != null && s?.children) {
|
|
3565
|
+
const l = String(o), i = s.children[l];
|
|
3542
3566
|
if (Array.isArray(i))
|
|
3543
3567
|
for (const u of i)
|
|
3544
|
-
typeof u == "string" && r[u] && (a[u] = !0,
|
|
3568
|
+
typeof u == "string" && r[u] && (a[u] = !0, Be(u, r, t, a));
|
|
3545
3569
|
}
|
|
3546
3570
|
for (const [l, i] of Object.entries(r))
|
|
3547
3571
|
i.parents && n in i.parents && (a[l] = Jr(l, r, t));
|
|
@@ -3559,7 +3583,7 @@ const Le = (e, r, t, n) => {
|
|
|
3559
3583
|
continue;
|
|
3560
3584
|
const i = a.map((u) => String(u));
|
|
3561
3585
|
if (Array.isArray(l)) {
|
|
3562
|
-
if (l.map((
|
|
3586
|
+
if (l.map((d) => String(d)).some((d) => i.includes(d)))
|
|
3563
3587
|
return !0;
|
|
3564
3588
|
} else {
|
|
3565
3589
|
const u = String(l);
|
|
@@ -3571,20 +3595,20 @@ const Le = (e, r, t, n) => {
|
|
|
3571
3595
|
}, mn = (e, r) => {
|
|
3572
3596
|
const t = /* @__PURE__ */ new Map();
|
|
3573
3597
|
let n = null, o = null, a = 0;
|
|
3574
|
-
for (const
|
|
3575
|
-
const l =
|
|
3598
|
+
for (const s of e) {
|
|
3599
|
+
const l = s.group;
|
|
3576
3600
|
if (!l) {
|
|
3577
3601
|
n = null, o = null;
|
|
3578
3602
|
continue;
|
|
3579
3603
|
}
|
|
3580
3604
|
if (l === n)
|
|
3581
|
-
r[
|
|
3605
|
+
r[s.name].group = o ?? l;
|
|
3582
3606
|
else {
|
|
3583
3607
|
if (!t.has(l))
|
|
3584
|
-
t.set(l, 1), o = null, r[
|
|
3608
|
+
t.set(l, 1), o = null, r[s.name].group = l;
|
|
3585
3609
|
else {
|
|
3586
3610
|
const i = t.get(l), u = `${l}(${i})`;
|
|
3587
|
-
t.set(l, i + 1), o = u, r[
|
|
3611
|
+
t.set(l, i + 1), o = u, r[s.name].group = u, a++;
|
|
3588
3612
|
}
|
|
3589
3613
|
n = l;
|
|
3590
3614
|
}
|
|
@@ -3592,30 +3616,30 @@ const Le = (e, r, t, n) => {
|
|
|
3592
3616
|
return a;
|
|
3593
3617
|
}, dn = (e, r = {}) => {
|
|
3594
3618
|
const { includeEmpty: t = !0 } = r, n = [];
|
|
3595
|
-
let o = null, a = [],
|
|
3619
|
+
let o = null, a = [], s = 0;
|
|
3596
3620
|
for (const i of e) {
|
|
3597
3621
|
const u = i.group || null;
|
|
3598
3622
|
u !== o ? ((a.length > 0 || t) && n.push({ name: o, fields: a }), o = u, a = [i]) : a.push(i);
|
|
3599
3623
|
}
|
|
3600
|
-
(a.length > 0 || t) && n.push({ name: o, fields: a }),
|
|
3624
|
+
(a.length > 0 || t) && n.push({ name: o, fields: a }), s = n.filter((i) => i.fields.length === 0).length;
|
|
3601
3625
|
const l = Math.max(0, ...n.map((i) => i.fields.length));
|
|
3602
3626
|
return {
|
|
3603
3627
|
groups: n,
|
|
3604
3628
|
metadata: {
|
|
3605
3629
|
totalGroups: n.length,
|
|
3606
|
-
emptyGroups:
|
|
3630
|
+
emptyGroups: s,
|
|
3607
3631
|
largestGroup: l
|
|
3608
3632
|
}
|
|
3609
3633
|
};
|
|
3610
|
-
},
|
|
3634
|
+
}, Le = new ae();
|
|
3611
3635
|
function Yr(e, r) {
|
|
3612
|
-
|
|
3636
|
+
Le.register(e, r);
|
|
3613
3637
|
}
|
|
3614
3638
|
function fn(e) {
|
|
3615
|
-
return
|
|
3639
|
+
return Le.get(e);
|
|
3616
3640
|
}
|
|
3617
3641
|
function pn(e) {
|
|
3618
|
-
return
|
|
3642
|
+
return Le.get(e);
|
|
3619
3643
|
}
|
|
3620
3644
|
Yr(
|
|
3621
3645
|
"Preset_AlertSubmitHandler",
|
|
@@ -3629,7 +3653,7 @@ Yr(
|
|
|
3629
3653
|
alert(o);
|
|
3630
3654
|
}
|
|
3631
3655
|
);
|
|
3632
|
-
async function gn(e, r, t, n, o, a,
|
|
3656
|
+
async function gn(e, r, t, n, o, a, s) {
|
|
3633
3657
|
const l = o ? Object.values(o).filter(Boolean) : [];
|
|
3634
3658
|
if (l.length > 0)
|
|
3635
3659
|
return {
|
|
@@ -3639,34 +3663,34 @@ async function gn(e, r, t, n, o, a, c) {
|
|
|
3639
3663
|
};
|
|
3640
3664
|
const i = { ...t }, u = [];
|
|
3641
3665
|
if (e && Array.isArray(e.properties))
|
|
3642
|
-
for (const
|
|
3643
|
-
const f =
|
|
3666
|
+
for (const d of e.properties) {
|
|
3667
|
+
const f = d.name, h = i[f];
|
|
3644
3668
|
if (h == null) continue;
|
|
3645
|
-
const
|
|
3669
|
+
const k = d.type;
|
|
3646
3670
|
try {
|
|
3647
|
-
if (
|
|
3671
|
+
if (k === "int") {
|
|
3648
3672
|
const v = String(h).trim();
|
|
3649
3673
|
if (v === "")
|
|
3650
3674
|
i[f] = 0;
|
|
3651
3675
|
else {
|
|
3652
3676
|
const p = Number(v);
|
|
3653
|
-
Number.isInteger(p) ? i[f] = Math.trunc(p) : u.push(n("Invalid integer format for field {{1}}",
|
|
3677
|
+
Number.isInteger(p) ? i[f] = Math.trunc(p) : u.push(n("Invalid integer format for field {{1}}", d.displayName || f));
|
|
3654
3678
|
}
|
|
3655
|
-
} else if (
|
|
3679
|
+
} else if (k === "number" || k === "float") {
|
|
3656
3680
|
const v = String(h).trim();
|
|
3657
3681
|
if (v === "")
|
|
3658
3682
|
i[f] = 0;
|
|
3659
3683
|
else {
|
|
3660
3684
|
const p = Number(v);
|
|
3661
|
-
isNaN(p) ? u.push(n("Invalid number format for field {{1}}",
|
|
3685
|
+
isNaN(p) ? u.push(n("Invalid number format for field {{1}}", d.displayName || f)) : i[f] = p;
|
|
3662
3686
|
}
|
|
3663
|
-
} else if (
|
|
3687
|
+
} else if (k === "int-array" || k === "float-array") {
|
|
3664
3688
|
const v = String(h).split(",").map((C) => C.trim()).filter(Boolean), p = [];
|
|
3665
3689
|
let y = !1;
|
|
3666
3690
|
for (const C of v) {
|
|
3667
3691
|
const V = Number(C);
|
|
3668
3692
|
if (isNaN(V)) {
|
|
3669
|
-
u.push(n("Invalid number {{1}} in array for field {{2}}", C,
|
|
3693
|
+
u.push(n("Invalid number {{1}} in array for field {{2}}", C, d.displayName || f)), y = !0;
|
|
3670
3694
|
break;
|
|
3671
3695
|
}
|
|
3672
3696
|
p.push(V);
|
|
@@ -3674,7 +3698,7 @@ async function gn(e, r, t, n, o, a, c) {
|
|
|
3674
3698
|
y || (i[f] = p);
|
|
3675
3699
|
}
|
|
3676
3700
|
} catch (v) {
|
|
3677
|
-
u.push(n("Error processing field {{1}}: {{2}}",
|
|
3701
|
+
u.push(n("Error processing field {{1}}: {{2}}", d.displayName || f, v instanceof Error ? v.message : String(v)));
|
|
3678
3702
|
}
|
|
3679
3703
|
}
|
|
3680
3704
|
if (u.length > 0)
|
|
@@ -3683,45 +3707,45 @@ async function gn(e, r, t, n, o, a, c) {
|
|
|
3683
3707
|
message: n("Data transformation errors occurred."),
|
|
3684
3708
|
errors: u
|
|
3685
3709
|
};
|
|
3686
|
-
if (
|
|
3687
|
-
const
|
|
3688
|
-
if (
|
|
3710
|
+
if (s) {
|
|
3711
|
+
const d = await s(i, n);
|
|
3712
|
+
if (d && d.length > 0)
|
|
3689
3713
|
return {
|
|
3690
3714
|
success: !1,
|
|
3691
3715
|
message: n("Validation failed"),
|
|
3692
|
-
errors:
|
|
3716
|
+
errors: d
|
|
3693
3717
|
};
|
|
3694
3718
|
} else {
|
|
3695
|
-
const
|
|
3696
|
-
if (
|
|
3719
|
+
const d = await vt(e, i, n);
|
|
3720
|
+
if (d && d.length > 0)
|
|
3697
3721
|
return {
|
|
3698
3722
|
success: !1,
|
|
3699
3723
|
message: n("Validation failed"),
|
|
3700
|
-
errors:
|
|
3724
|
+
errors: d
|
|
3701
3725
|
};
|
|
3702
3726
|
}
|
|
3703
|
-
const
|
|
3727
|
+
const m = (d) => d ? Array.isArray(d) ? d.map((f) => String(f)) : typeof d == "string" ? d.trim() ? [d] : [] : [String(d)] : [];
|
|
3704
3728
|
if (a)
|
|
3705
3729
|
try {
|
|
3706
|
-
const
|
|
3730
|
+
const d = await a(e, r?.name ?? null, i, n), f = m(d);
|
|
3707
3731
|
if (f.length > 0)
|
|
3708
3732
|
return {
|
|
3709
3733
|
success: !1,
|
|
3710
3734
|
message: n("Submission failed"),
|
|
3711
3735
|
errors: f
|
|
3712
3736
|
};
|
|
3713
|
-
} catch (
|
|
3737
|
+
} catch (d) {
|
|
3714
3738
|
return {
|
|
3715
3739
|
success: !1,
|
|
3716
3740
|
message: n("Submission handler error occurred"),
|
|
3717
|
-
errors: [String(
|
|
3741
|
+
errors: [String(d instanceof Error ? d.message : d)]
|
|
3718
3742
|
};
|
|
3719
3743
|
}
|
|
3720
3744
|
else if (e && typeof e.submitHandlerName == "string") {
|
|
3721
|
-
const
|
|
3722
|
-
if (
|
|
3745
|
+
const d = fn(e.submitHandlerName);
|
|
3746
|
+
if (d)
|
|
3723
3747
|
try {
|
|
3724
|
-
const f = await
|
|
3748
|
+
const f = await d(e, r?.name ?? null, i, n), h = m(f);
|
|
3725
3749
|
if (h.length > 0)
|
|
3726
3750
|
return {
|
|
3727
3751
|
success: !1,
|
|
@@ -3786,7 +3810,7 @@ const Xr = ({
|
|
|
3786
3810
|
) : null;
|
|
3787
3811
|
Xr.displayName = "SubmissionMessage";
|
|
3788
3812
|
const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
3789
|
-
const [n, o] =
|
|
3813
|
+
const [n, o] = c.useState(!1);
|
|
3790
3814
|
return /* @__PURE__ */ g(
|
|
3791
3815
|
"button",
|
|
3792
3816
|
{
|
|
@@ -3819,20 +3843,20 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3819
3843
|
chunkSize: o = 50,
|
|
3820
3844
|
chunkDelay: a = 50
|
|
3821
3845
|
}) => {
|
|
3822
|
-
const { properties:
|
|
3846
|
+
const { properties: s, displayName: l } = e, i = j(), { t: u, formStyle: m, language: d, displayInstanceName: f } = i, h = {
|
|
3823
3847
|
...i,
|
|
3824
3848
|
definitionName: e?.name ?? i.definitionName
|
|
3825
|
-
}, [
|
|
3849
|
+
}, [k, v] = c.useState("en"), [p, y] = c.useState([]), [C, V] = c.useState({}), [A, I] = c.useState(
|
|
3826
3850
|
{}
|
|
3827
|
-
), [M, F] =
|
|
3828
|
-
|
|
3851
|
+
), [M, F] = c.useState({}), [b, x] = c.useState({}), [E, w] = c.useState(null), [S, N] = c.useState(null), [$, L] = c.useState(0), [q, X] = c.useState(!1), [te, ie] = c.useState(r.name || ""), Z = c.useRef(r), pe = c.useRef(!1);
|
|
3852
|
+
c.useEffect(() => {
|
|
3829
3853
|
const P = Object.fromEntries(
|
|
3830
|
-
|
|
3854
|
+
s.map((D) => [
|
|
3831
3855
|
D.name,
|
|
3832
3856
|
{ ...D, children: {} }
|
|
3833
3857
|
])
|
|
3834
3858
|
);
|
|
3835
|
-
|
|
3859
|
+
s.forEach((D) => {
|
|
3836
3860
|
D.parents && Object.entries(D.parents).forEach(([J, ne]) => {
|
|
3837
3861
|
const Q = P[J];
|
|
3838
3862
|
Q && ne.forEach((it) => {
|
|
@@ -3844,41 +3868,44 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3844
3868
|
];
|
|
3845
3869
|
});
|
|
3846
3870
|
});
|
|
3847
|
-
}), mn(
|
|
3871
|
+
}), mn(s, P);
|
|
3848
3872
|
const U = Object.values(
|
|
3849
3873
|
P
|
|
3850
|
-
),
|
|
3874
|
+
), O = {};
|
|
3851
3875
|
U.forEach((D) => {
|
|
3852
3876
|
if (D.type === "unit") {
|
|
3853
3877
|
const J = typeof D.defaultValue == "number" ? String(D.defaultValue) : "", ne = typeof D.defaultUnit == "string" ? D.defaultUnit : String(D.defaultUnit ?? "m");
|
|
3854
|
-
|
|
3878
|
+
O[D.name] = [J, ne];
|
|
3855
3879
|
} else
|
|
3856
|
-
|
|
3880
|
+
O[D.name] = D.defaultValue;
|
|
3857
3881
|
}), Z.current = r, Object.keys(r.values).forEach((D) => {
|
|
3858
|
-
P[D] !== void 0 && (
|
|
3882
|
+
P[D] !== void 0 && (O[D] = r.values[D]);
|
|
3859
3883
|
});
|
|
3860
|
-
const
|
|
3861
|
-
y(U), V(P), I(
|
|
3862
|
-
ln(U,
|
|
3863
|
-
),
|
|
3884
|
+
const Y = Object.fromEntries(U.map((D) => [D.name, !1])), G = requestAnimationFrame(() => {
|
|
3885
|
+
y(U), V(P), I(O), F(
|
|
3886
|
+
ln(U, O, Y, P)
|
|
3887
|
+
), X(!0), ie(r.name);
|
|
3864
3888
|
});
|
|
3865
3889
|
return () => cancelAnimationFrame(G);
|
|
3866
|
-
}, [
|
|
3890
|
+
}, [s, r, e]), c.useEffect(() => {
|
|
3867
3891
|
if (!q || $ >= p.length) return;
|
|
3868
3892
|
const P = setTimeout(() => {
|
|
3869
|
-
|
|
3893
|
+
L(
|
|
3870
3894
|
(U) => Math.min(U + o, p.length)
|
|
3871
3895
|
);
|
|
3872
3896
|
}, a);
|
|
3873
3897
|
return () => clearTimeout(P);
|
|
3874
3898
|
}, [q, $, p.length, o, a]);
|
|
3875
|
-
const He =
|
|
3899
|
+
const He = c.useCallback(
|
|
3876
3900
|
(P, U) => {
|
|
3877
|
-
|
|
3878
|
-
|
|
3901
|
+
const O = C[P];
|
|
3902
|
+
if (!O)
|
|
3903
|
+
return;
|
|
3904
|
+
w(null), N(null), I((D) => ({ ...D, [P]: U }));
|
|
3905
|
+
const Y = O && O.children && Object.keys(O.children).length > 0, G = Object.values(C).some(
|
|
3879
3906
|
(D) => D.parents && P in D.parents
|
|
3880
3907
|
);
|
|
3881
|
-
(
|
|
3908
|
+
(Y || G) && F((D) => {
|
|
3882
3909
|
const J = { ...A, [P]: U };
|
|
3883
3910
|
return un(
|
|
3884
3911
|
D,
|
|
@@ -3891,24 +3918,28 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3891
3918
|
},
|
|
3892
3919
|
[C, A]
|
|
3893
3920
|
);
|
|
3894
|
-
|
|
3921
|
+
c.useEffect(() => {
|
|
3895
3922
|
let P = 0;
|
|
3896
3923
|
return P = requestAnimationFrame(() => {
|
|
3897
|
-
|
|
3924
|
+
d !== k && (v(d || "en"), w(null), N(null));
|
|
3898
3925
|
}), () => cancelAnimationFrame(P);
|
|
3899
|
-
}, [
|
|
3926
|
+
}, [d, k]), c.useEffect(() => {
|
|
3900
3927
|
let P = 0;
|
|
3901
3928
|
return P = requestAnimationFrame(() => {
|
|
3902
3929
|
if (pe.current) {
|
|
3903
3930
|
pe.current = !1, Z.current = r, ie(r.name || "");
|
|
3904
3931
|
return;
|
|
3905
3932
|
}
|
|
3906
|
-
Z.current = r, w(null),
|
|
3933
|
+
Z.current = r, w(null), N(null), ie(r.name || "");
|
|
3907
3934
|
}), () => cancelAnimationFrame(P);
|
|
3908
3935
|
}, [r, r.name]);
|
|
3909
|
-
const qe =
|
|
3910
|
-
|
|
3911
|
-
|
|
3936
|
+
const qe = c.useCallback((P, U) => {
|
|
3937
|
+
if (C[P]?.disabled) {
|
|
3938
|
+
x((O) => P in O ? Object.fromEntries(Object.entries(O).filter(([G]) => G !== P)) : O);
|
|
3939
|
+
return;
|
|
3940
|
+
}
|
|
3941
|
+
x((O) => U ? { ...O, [P]: String(U) } : Object.fromEntries(Object.entries(O).filter(([G]) => G !== P)));
|
|
3942
|
+
}, [C]), ot = async () => {
|
|
3912
3943
|
pe.current = !0;
|
|
3913
3944
|
const P = Z.current?.name;
|
|
3914
3945
|
Z.current.name = te;
|
|
@@ -3916,33 +3947,34 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3916
3947
|
if (h.fieldValidationMode === "onSubmission") {
|
|
3917
3948
|
const D = {};
|
|
3918
3949
|
if (p.forEach((J) => {
|
|
3950
|
+
if (J.disabled) return;
|
|
3919
3951
|
const ne = A[J.name];
|
|
3920
3952
|
if (ne === void 0) return;
|
|
3921
3953
|
const Q = we(h.definitionName, J, ne, u);
|
|
3922
3954
|
Q && (D[J.name] = Q);
|
|
3923
3955
|
}), x(D), U = D, Object.keys(D).length > 0) {
|
|
3924
|
-
w(u("Please fix validation errors before submitting the form.")),
|
|
3956
|
+
w(u("Please fix validation errors before submitting the form.")), N(!1);
|
|
3925
3957
|
return;
|
|
3926
3958
|
} else
|
|
3927
|
-
w(null),
|
|
3959
|
+
w(null), N(null);
|
|
3928
3960
|
}
|
|
3929
|
-
const
|
|
3961
|
+
const O = await gn(e, Z.current, A, u, U, t, n), Y = typeof O.message == "string" ? O.message : String(O.message), G = Object.values(O.errors ?? {}).join(`
|
|
3930
3962
|
`);
|
|
3931
|
-
w(G ?
|
|
3932
|
-
` + G :
|
|
3933
|
-
}, at =
|
|
3963
|
+
w(G ? Y + `
|
|
3964
|
+
` + G : Y), N(O.success), O.success || (Z.current.name = P ?? Z.current.name, ie(P ?? ""));
|
|
3965
|
+
}, at = c.useMemo(
|
|
3934
3966
|
() => h.fieldValidationMode === "onEdit" || h.fieldValidationMode === "onBlur" || h.fieldValidationMode === "realTime" ? Object.values(b).some(Boolean) : !1,
|
|
3935
3967
|
[b, h.fieldValidationMode]
|
|
3936
3968
|
);
|
|
3937
|
-
return /* @__PURE__ */ g(Me.Provider, { value: h, children: /* @__PURE__ */ z("div", { style:
|
|
3938
|
-
l && /* @__PURE__ */ g("h2", { style:
|
|
3969
|
+
return /* @__PURE__ */ g(Me.Provider, { value: h, children: /* @__PURE__ */ z("div", { style: m.container, children: [
|
|
3970
|
+
l && /* @__PURE__ */ g("h2", { style: m.titleStyle, children: u(l) }),
|
|
3939
3971
|
/* @__PURE__ */ g(
|
|
3940
3972
|
Xr,
|
|
3941
3973
|
{
|
|
3942
|
-
message:
|
|
3974
|
+
message: E,
|
|
3943
3975
|
success: S,
|
|
3944
3976
|
onDismiss: () => {
|
|
3945
|
-
w(null),
|
|
3977
|
+
w(null), N(null);
|
|
3946
3978
|
},
|
|
3947
3979
|
t: u
|
|
3948
3980
|
}
|
|
@@ -3952,28 +3984,28 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3952
3984
|
{
|
|
3953
3985
|
name: te,
|
|
3954
3986
|
onChange: (P) => {
|
|
3955
|
-
ie(P), w(null),
|
|
3987
|
+
ie(P), w(null), N(null);
|
|
3956
3988
|
}
|
|
3957
3989
|
}
|
|
3958
3990
|
),
|
|
3959
3991
|
/* @__PURE__ */ z(Fe, { children: [
|
|
3960
3992
|
(() => {
|
|
3961
|
-
const P = p.slice(0, $).filter((
|
|
3962
|
-
return U.map((
|
|
3993
|
+
const P = p.slice(0, $).filter((O) => M[O.name]), { groups: U } = dn(P);
|
|
3994
|
+
return U.map((O, Y) => O.name ? /* @__PURE__ */ g(
|
|
3963
3995
|
Kr,
|
|
3964
3996
|
{
|
|
3965
|
-
groupName:
|
|
3997
|
+
groupName: O.name,
|
|
3966
3998
|
defaultOpen: !0,
|
|
3967
|
-
fields:
|
|
3999
|
+
fields: O.fields,
|
|
3968
4000
|
valuesMap: A,
|
|
3969
4001
|
handleChange: He,
|
|
3970
4002
|
handleError: qe,
|
|
3971
4003
|
errorsMap: b,
|
|
3972
4004
|
t: u
|
|
3973
4005
|
},
|
|
3974
|
-
|
|
3975
|
-
) : /* @__PURE__ */ g(
|
|
3976
|
-
|
|
4006
|
+
O.name
|
|
4007
|
+
) : /* @__PURE__ */ g(c.Fragment, { children: O.fields.map((G) => /* @__PURE__ */ g(
|
|
4008
|
+
Oe,
|
|
3977
4009
|
{
|
|
3978
4010
|
field: G,
|
|
3979
4011
|
valuesMap: A,
|
|
@@ -3982,7 +4014,7 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3982
4014
|
errorsMap: b
|
|
3983
4015
|
},
|
|
3984
4016
|
G.name
|
|
3985
|
-
)) }, `ungrouped-${
|
|
4017
|
+
)) }, `ungrouped-${Y}`));
|
|
3986
4018
|
})(),
|
|
3987
4019
|
$ < p.length && /* @__PURE__ */ g(
|
|
3988
4020
|
"div",
|
|
@@ -4111,17 +4143,17 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
4111
4143
|
!a.includes("application/json") && !a.includes("text/json") && Qr() && console.warn(
|
|
4112
4144
|
`Translation file at ${n} has unexpected content-type: ${a}`
|
|
4113
4145
|
);
|
|
4114
|
-
const
|
|
4115
|
-
if (!
|
|
4146
|
+
const s = await o.text();
|
|
4147
|
+
if (!s) {
|
|
4116
4148
|
const u = "Empty translation file";
|
|
4117
4149
|
return oe.add(t), { success: !1, translations: {}, error: u };
|
|
4118
4150
|
}
|
|
4119
4151
|
let l;
|
|
4120
4152
|
try {
|
|
4121
|
-
l = JSON.parse(
|
|
4153
|
+
l = JSON.parse(s);
|
|
4122
4154
|
} catch (u) {
|
|
4123
|
-
const
|
|
4124
|
-
return oe.add(t), { success: !1, translations: {}, error:
|
|
4155
|
+
const m = `Invalid JSON in translation file: ${u instanceof Error ? u.message : String(u)}`;
|
|
4156
|
+
return oe.add(t), { success: !1, translations: {}, error: m };
|
|
4125
4157
|
}
|
|
4126
4158
|
if (!l || typeof l != "object") {
|
|
4127
4159
|
const u = "Invalid translation file format";
|
|
@@ -4132,9 +4164,9 @@ const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
4132
4164
|
};
|
|
4133
4165
|
}
|
|
4134
4166
|
const i = Object.fromEntries(
|
|
4135
|
-
Object.entries(l).map(([u,
|
|
4167
|
+
Object.entries(l).map(([u, m]) => [
|
|
4136
4168
|
u,
|
|
4137
|
-
typeof
|
|
4169
|
+
typeof m == "string" ? m : String(m)
|
|
4138
4170
|
])
|
|
4139
4171
|
);
|
|
4140
4172
|
return ue.set(t, i), Ce.set(t, {
|
|
@@ -4170,8 +4202,8 @@ function wn(e, r) {
|
|
|
4170
4202
|
});
|
|
4171
4203
|
}
|
|
4172
4204
|
const Sn = (e, r, t) => (n, ...o) => {
|
|
4173
|
-
let a = n,
|
|
4174
|
-
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (a = n,
|
|
4205
|
+
let a = n, s = !1;
|
|
4206
|
+
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (a = n, s = !0) : n in t ? (a = t[n], s = !0) : n in r ? (a = r[n], s = !0) : a = n, a = wn(a, o), !s && Qr() && console.debug(
|
|
4175
4207
|
`Missing translation for "${n}" in language "${e}"`
|
|
4176
4208
|
), a);
|
|
4177
4209
|
};
|
|
@@ -4297,20 +4329,20 @@ function Te(e, r, t, n, ...o) {
|
|
|
4297
4329
|
if (e.pattern == null)
|
|
4298
4330
|
return;
|
|
4299
4331
|
const a = String(r);
|
|
4300
|
-
let
|
|
4332
|
+
let s = null;
|
|
4301
4333
|
if (e.pattern) {
|
|
4302
4334
|
const l = ve.get(e);
|
|
4303
4335
|
if (l && l.pattern === e.pattern)
|
|
4304
|
-
|
|
4336
|
+
s = l.regex;
|
|
4305
4337
|
else
|
|
4306
4338
|
try {
|
|
4307
4339
|
const i = new RegExp(e.pattern);
|
|
4308
|
-
ve.set(e, { pattern: e.pattern, regex: i }),
|
|
4340
|
+
ve.set(e, { pattern: e.pattern, regex: i }), s = i;
|
|
4309
4341
|
} catch {
|
|
4310
|
-
ve.set(e, { pattern: e.pattern, regex: null }),
|
|
4342
|
+
ve.set(e, { pattern: e.pattern, regex: null }), s = null;
|
|
4311
4343
|
}
|
|
4312
4344
|
}
|
|
4313
|
-
if (
|
|
4345
|
+
if (s && !s.test(a))
|
|
4314
4346
|
return e.patternErrorMessage ? t(e.patternErrorMessage) : n ? t(n, ...o) : t("Input does not match pattern: {{1}}", e.pattern);
|
|
4315
4347
|
}
|
|
4316
4348
|
function me(e, r, t) {
|
|
@@ -4337,19 +4369,19 @@ function Dn(e, r, t) {
|
|
|
4337
4369
|
const n = String(r).trim(), o = ke(n);
|
|
4338
4370
|
if (o === null)
|
|
4339
4371
|
return t("Invalid date format");
|
|
4340
|
-
const { minTime: a, maxTime:
|
|
4372
|
+
const { minTime: a, maxTime: s } = An(e);
|
|
4341
4373
|
if (a !== null && o < a)
|
|
4342
4374
|
return t("Date must be on or after {{1}}", e.minDate);
|
|
4343
|
-
if (
|
|
4375
|
+
if (s !== null && o > s)
|
|
4344
4376
|
return t("Date must be on or before {{1}}", e.maxDate);
|
|
4345
4377
|
}
|
|
4346
4378
|
function zn(e, r, t) {
|
|
4347
4379
|
const n = String(r);
|
|
4348
4380
|
if (!n || n.trim() === "")
|
|
4349
4381
|
return e.required || e.min || e.max ? t("Value required") : void 0;
|
|
4350
|
-
const o = (
|
|
4351
|
-
const l =
|
|
4352
|
-
if (l.some((
|
|
4382
|
+
const o = (s) => {
|
|
4383
|
+
const l = s.split(":").map((m) => parseInt(m, 10));
|
|
4384
|
+
if (l.some((m) => Number.isNaN(m))) return NaN;
|
|
4353
4385
|
const i = l.length;
|
|
4354
4386
|
if (i < 2 || i > 3) return NaN;
|
|
4355
4387
|
if (i === 2 && (l[0] < 0 || l[0] > 23 || l[1] < 0 || l[1] > 59)) return NaN;
|
|
@@ -4367,28 +4399,28 @@ function zn(e, r, t) {
|
|
|
4367
4399
|
}, a = o(n);
|
|
4368
4400
|
if (Number.isNaN(a)) return t("Invalid time format");
|
|
4369
4401
|
if (e.min && typeof e.min == "string") {
|
|
4370
|
-
const
|
|
4371
|
-
if (!Number.isNaN(
|
|
4402
|
+
const s = o(e.min);
|
|
4403
|
+
if (!Number.isNaN(s) && a < s)
|
|
4372
4404
|
return t("Time must be on or after {{1}}", e.min);
|
|
4373
4405
|
}
|
|
4374
4406
|
if (e.max && typeof e.max == "string") {
|
|
4375
|
-
const
|
|
4376
|
-
if (!Number.isNaN(
|
|
4407
|
+
const s = o(e.max);
|
|
4408
|
+
if (!Number.isNaN(s) && a > s)
|
|
4377
4409
|
return t("Time must be on or before {{1}}", e.max);
|
|
4378
4410
|
}
|
|
4379
4411
|
}
|
|
4380
4412
|
function Pn(e) {
|
|
4381
4413
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
4382
4414
|
}
|
|
4383
|
-
function
|
|
4415
|
+
function On(e, r, t) {
|
|
4384
4416
|
const n = String(r ?? "").trim();
|
|
4385
4417
|
return n === "" ? e.required ? t("Value required") : void 0 : Pn(n) ? Te(e, r, t, t("Email does not match pattern: {{1}}", e.pattern)) : t("Must be valid email format");
|
|
4386
4418
|
}
|
|
4387
|
-
function
|
|
4419
|
+
function Bn(e, r, t) {
|
|
4388
4420
|
const n = String(r ?? "").trim();
|
|
4389
4421
|
return n === "" ? e.required ? t("Value required") : void 0 : Te(e, n, t, "Invalid phone number format");
|
|
4390
4422
|
}
|
|
4391
|
-
const
|
|
4423
|
+
const Ln = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i, Tn = (e) => {
|
|
4392
4424
|
try {
|
|
4393
4425
|
return new URL(e), !0;
|
|
4394
4426
|
} catch {
|
|
@@ -4399,7 +4431,7 @@ function jn(e, r, t) {
|
|
|
4399
4431
|
const n = String(r ?? "").trim();
|
|
4400
4432
|
if (n === "")
|
|
4401
4433
|
return e.required ? t("Value required") : void 0;
|
|
4402
|
-
if (!(
|
|
4434
|
+
if (!(Ln.test(n) || Tn(n))) {
|
|
4403
4435
|
if (e.allowRelative === !0) {
|
|
4404
4436
|
if (!n.startsWith("/") || encodeURI(n) !== n)
|
|
4405
4437
|
return t("Must be a valid URL");
|
|
@@ -4436,11 +4468,11 @@ function Wn(e, r, t) {
|
|
|
4436
4468
|
const o = String(r ?? "").trim();
|
|
4437
4469
|
if (o === "")
|
|
4438
4470
|
return e.required ? t("Value required") : void 0;
|
|
4439
|
-
const a = o.split(",").map((
|
|
4471
|
+
const a = o.split(",").map((s) => s.trim()).filter((s) => s !== "");
|
|
4440
4472
|
if (a.length === 0)
|
|
4441
4473
|
return e.required ? t("Value required") : void 0;
|
|
4442
|
-
for (const
|
|
4443
|
-
if (!e.options?.some((l) => String(l.value) ===
|
|
4474
|
+
for (const s of a)
|
|
4475
|
+
if (!e.options?.some((l) => String(l.value) === s))
|
|
4444
4476
|
return t("Invalid option selected");
|
|
4445
4477
|
}
|
|
4446
4478
|
const _n = /^#([0-9A-F]{3}){1,2}$/i, Kn = (e) => _n.test(e);
|
|
@@ -4467,15 +4499,15 @@ function Yn(e, r, t) {
|
|
|
4467
4499
|
return e.required ? t("Value required") : void 0;
|
|
4468
4500
|
const o = Number(n);
|
|
4469
4501
|
if (Number.isNaN(o)) return t("Must be a valid float");
|
|
4470
|
-
const a = e.min ?? 0,
|
|
4502
|
+
const a = e.min ?? 0, s = e.max ?? 100;
|
|
4471
4503
|
if (o < a)
|
|
4472
4504
|
return t("Must be ≥ {{1}}", a);
|
|
4473
|
-
if (o >
|
|
4474
|
-
return t("Must be ≤ {{1}}",
|
|
4505
|
+
if (o > s)
|
|
4506
|
+
return t("Must be ≤ {{1}}", s);
|
|
4475
4507
|
}
|
|
4476
4508
|
let er = !1;
|
|
4477
4509
|
function rt() {
|
|
4478
|
-
er || (H("int", Ze), H("stepper", Ze), H("int-array", In), H("float", et), H("slider", Yn), H("float-array", Rn), H("text", me), H("string", me), H("multiline", me), H("password", me), H("email",
|
|
4510
|
+
er || (H("int", Ze), H("stepper", Ze), H("int-array", In), H("float", et), H("slider", Yn), H("float-array", Rn), H("text", me), H("string", me), H("multiline", me), H("password", me), H("email", On), H("date", Dn), H("time", zn), H("url", jn), H("phone", Bn), H("unit", Hn), H("dropdown", Un), H("multi-selection", Wn), H("color", Gn), H("rating", Jn), H("file", qn), er = !0);
|
|
4479
4511
|
}
|
|
4480
4512
|
rt();
|
|
4481
4513
|
cn();
|
|
@@ -4587,15 +4619,15 @@ const Xn = (e) => ({
|
|
|
4587
4619
|
defaultLanguage: n = "en",
|
|
4588
4620
|
defaultTheme: o = "light",
|
|
4589
4621
|
defaultLocalizeName: a = "",
|
|
4590
|
-
defaultFieldValidationMode:
|
|
4622
|
+
defaultFieldValidationMode: s = "onEdit",
|
|
4591
4623
|
className: l = "reactaform-container",
|
|
4592
4624
|
defaultDisplayInstanceName: i = !0
|
|
4593
4625
|
}) => {
|
|
4594
|
-
const u = r,
|
|
4626
|
+
const u = r, m = a, d = o, f = n, h = c.useMemo(
|
|
4595
4627
|
() => t ?? {},
|
|
4596
4628
|
[t]
|
|
4597
|
-
), [
|
|
4598
|
-
|
|
4629
|
+
), [k, v] = c.useState({}), [p, y] = c.useState({});
|
|
4630
|
+
c.useEffect(() => {
|
|
4599
4631
|
let b = !0;
|
|
4600
4632
|
return (async () => {
|
|
4601
4633
|
if (f === "en") {
|
|
@@ -4603,49 +4635,49 @@ const Xn = (e) => ({
|
|
|
4603
4635
|
return;
|
|
4604
4636
|
}
|
|
4605
4637
|
try {
|
|
4606
|
-
const
|
|
4638
|
+
const E = await vn(f), w = E.success ? E.translations : {};
|
|
4607
4639
|
b && v(w);
|
|
4608
|
-
const S = await xn(f,
|
|
4609
|
-
b && y(
|
|
4640
|
+
const S = await xn(f, m), N = S.success ? S.translations : {};
|
|
4641
|
+
b && y(N);
|
|
4610
4642
|
} catch {
|
|
4611
4643
|
b && (v({}), y({}));
|
|
4612
4644
|
}
|
|
4613
4645
|
})(), () => {
|
|
4614
4646
|
b = !1;
|
|
4615
4647
|
};
|
|
4616
|
-
}, [f,
|
|
4617
|
-
const C =
|
|
4618
|
-
() => Sn(f,
|
|
4619
|
-
[f,
|
|
4620
|
-
), I =
|
|
4648
|
+
}, [f, m]);
|
|
4649
|
+
const C = c.useMemo(() => Xn(h), [h]), V = c.useMemo(() => Zn(h), [h]), A = c.useMemo(
|
|
4650
|
+
() => Sn(f, k, p),
|
|
4651
|
+
[f, k, p]
|
|
4652
|
+
), I = c.useCallback(
|
|
4621
4653
|
(b, ...x) => A(b, ...x),
|
|
4622
4654
|
[A]
|
|
4623
|
-
), M =
|
|
4655
|
+
), M = c.useMemo(
|
|
4624
4656
|
() => ({
|
|
4625
4657
|
definitionName: u,
|
|
4626
4658
|
language: f,
|
|
4627
|
-
theme:
|
|
4659
|
+
theme: d,
|
|
4628
4660
|
formStyle: C,
|
|
4629
4661
|
fieldStyle: V,
|
|
4630
4662
|
t: I,
|
|
4631
|
-
fieldValidationMode:
|
|
4663
|
+
fieldValidationMode: s,
|
|
4632
4664
|
displayInstanceName: i
|
|
4633
4665
|
}),
|
|
4634
4666
|
[
|
|
4635
4667
|
u,
|
|
4636
4668
|
f,
|
|
4637
|
-
|
|
4669
|
+
d,
|
|
4638
4670
|
V,
|
|
4639
4671
|
C,
|
|
4640
4672
|
I,
|
|
4641
|
-
|
|
4673
|
+
s,
|
|
4642
4674
|
i
|
|
4643
4675
|
]
|
|
4644
4676
|
), F = h?.height ? { height: "100%" } : void 0;
|
|
4645
4677
|
return /* @__PURE__ */ g(Me.Provider, { value: M, children: /* @__PURE__ */ g(
|
|
4646
4678
|
"div",
|
|
4647
4679
|
{
|
|
4648
|
-
"data-reactaform-theme":
|
|
4680
|
+
"data-reactaform-theme": d,
|
|
4649
4681
|
className: l,
|
|
4650
4682
|
style: F,
|
|
4651
4683
|
children: e
|
|
@@ -4722,8 +4754,8 @@ function ro(e, r) {
|
|
|
4722
4754
|
return Array.isArray(n) && n.forEach((o) => {
|
|
4723
4755
|
const a = o;
|
|
4724
4756
|
if (a.type === "unit") {
|
|
4725
|
-
const
|
|
4726
|
-
t.values[a.name] = [l || 0,
|
|
4757
|
+
const s = a.defaultUnit, l = Number(a.defaultValue) || void 0;
|
|
4758
|
+
t.values[a.name] = [l || 0, s || "m"];
|
|
4727
4759
|
} else
|
|
4728
4760
|
a.defaultValue !== void 0 && (t.values[a.name] = a.defaultValue);
|
|
4729
4761
|
}), { success: !0, instance: t };
|
|
@@ -4775,12 +4807,12 @@ function wo(e, r, t) {
|
|
|
4775
4807
|
(r.properties || []).forEach((i) => {
|
|
4776
4808
|
a[i.name] = i;
|
|
4777
4809
|
});
|
|
4778
|
-
const
|
|
4810
|
+
const s = (i, u, m) => {
|
|
4779
4811
|
if (i == null) return i;
|
|
4780
|
-
const
|
|
4812
|
+
const d = u.toLowerCase();
|
|
4781
4813
|
try {
|
|
4782
|
-
if (
|
|
4783
|
-
if (
|
|
4814
|
+
if (d === "string" || d === "text") return String(i);
|
|
4815
|
+
if (d === "int" || d === "integer" || d === "number" || d === "float") {
|
|
4784
4816
|
if (typeof i == "number") return i;
|
|
4785
4817
|
if (typeof i == "boolean") return i ? 1 : 0;
|
|
4786
4818
|
if (typeof i == "string") {
|
|
@@ -4791,7 +4823,7 @@ function wo(e, r, t) {
|
|
|
4791
4823
|
}
|
|
4792
4824
|
return 0;
|
|
4793
4825
|
}
|
|
4794
|
-
if (
|
|
4826
|
+
if (d === "boolean" || d === "bool" || d === "checkbox" || d === "switch") {
|
|
4795
4827
|
if (typeof i == "boolean") return i;
|
|
4796
4828
|
if (typeof i == "number") return i !== 0;
|
|
4797
4829
|
if (typeof i == "string") {
|
|
@@ -4800,29 +4832,29 @@ function wo(e, r, t) {
|
|
|
4800
4832
|
}
|
|
4801
4833
|
return !!i;
|
|
4802
4834
|
}
|
|
4803
|
-
if (
|
|
4835
|
+
if (d === "unit") {
|
|
4804
4836
|
if (Array.isArray(i) && i.length >= 2) return i;
|
|
4805
4837
|
if (Array.isArray(i) && i.length === 1)
|
|
4806
|
-
return [i[0],
|
|
4807
|
-
if (typeof i == "number") return [i,
|
|
4838
|
+
return [i[0], m && m.defaultUnit || "m"];
|
|
4839
|
+
if (typeof i == "number") return [i, m && m.defaultUnit || "m"];
|
|
4808
4840
|
if (typeof i == "string") {
|
|
4809
4841
|
const f = Number(i);
|
|
4810
|
-
return [Number.isNaN(f) ? 0 : f,
|
|
4842
|
+
return [Number.isNaN(f) ? 0 : f, m && m.defaultUnit || "m"];
|
|
4811
4843
|
}
|
|
4812
|
-
return [0,
|
|
4844
|
+
return [0, m && m.defaultUnit || "m"];
|
|
4813
4845
|
}
|
|
4814
|
-
if (
|
|
4846
|
+
if (d.endsWith("[]") || d === "array" || d === "int-array" || d === "float-array")
|
|
4815
4847
|
return Array.isArray(i) ? i : typeof i == "string" ? i.split(",").map((f) => f.trim()).filter(Boolean) : [i];
|
|
4816
4848
|
} catch {
|
|
4817
4849
|
}
|
|
4818
4850
|
return i;
|
|
4819
4851
|
}, l = e.values || {};
|
|
4820
4852
|
Object.keys(l).forEach((i) => {
|
|
4821
|
-
const u = l[i],
|
|
4822
|
-
if (!
|
|
4853
|
+
const u = l[i], m = a[i];
|
|
4854
|
+
if (!m)
|
|
4823
4855
|
return;
|
|
4824
|
-
const
|
|
4825
|
-
|
|
4856
|
+
const d = Array.isArray(u) ? "array" : u === null ? "null" : typeof u, f = (m.type || "").toLowerCase();
|
|
4857
|
+
d === f || f === "string" && typeof u == "string" ? o[i] = u : o[i] = s(u, f, m);
|
|
4826
4858
|
}), (r.properties || []).forEach((i) => {
|
|
4827
4859
|
const u = i.name;
|
|
4828
4860
|
u in o || (o[u] = i.defaultValue);
|
|
@@ -4841,19 +4873,19 @@ function wo(e, r, t) {
|
|
|
4841
4873
|
}
|
|
4842
4874
|
}
|
|
4843
4875
|
function to(e) {
|
|
4844
|
-
const [r, t] =
|
|
4845
|
-
return
|
|
4876
|
+
const [r, t] = c.useState(null);
|
|
4877
|
+
return c.useEffect(() => {
|
|
4846
4878
|
const n = document.querySelector("[data-reactaform-theme]");
|
|
4847
4879
|
if (!n) return;
|
|
4848
4880
|
const o = n.closest("[data-reactaform-theme]");
|
|
4849
4881
|
if (!o) return;
|
|
4850
4882
|
const a = () => t(o.getAttribute("data-reactaform-theme"));
|
|
4851
4883
|
a();
|
|
4852
|
-
const
|
|
4884
|
+
const s = new MutationObserver((l) => {
|
|
4853
4885
|
for (const i of l)
|
|
4854
4886
|
i.type === "attributes" && i.attributeName === "data-reactaform-theme" && a();
|
|
4855
4887
|
});
|
|
4856
|
-
return
|
|
4888
|
+
return s.observe(o, { attributes: !0, attributeFilter: ["data-reactaform-theme"] }), () => s.disconnect();
|
|
4857
4889
|
}, [e]), r;
|
|
4858
4890
|
}
|
|
4859
4891
|
const So = ({
|
|
@@ -4863,43 +4895,43 @@ const So = ({
|
|
|
4863
4895
|
className: n,
|
|
4864
4896
|
theme: o,
|
|
4865
4897
|
style: a,
|
|
4866
|
-
fieldValidationMode:
|
|
4898
|
+
fieldValidationMode: s = "onEdit",
|
|
4867
4899
|
displayInstanceName: l = !0,
|
|
4868
4900
|
onSubmit: i = void 0,
|
|
4869
4901
|
onValidation: u = void 0
|
|
4870
4902
|
}) => {
|
|
4871
|
-
const
|
|
4903
|
+
const m = c.useMemo(() => {
|
|
4872
4904
|
try {
|
|
4873
4905
|
return typeof e == "string" ? JSON.parse(e) : e ?? null;
|
|
4874
4906
|
} catch {
|
|
4875
4907
|
return null;
|
|
4876
4908
|
}
|
|
4877
|
-
}, [e]),
|
|
4878
|
-
|
|
4909
|
+
}, [e]), d = { fontSize: "inherit", fontFamily: "inherit", ...a }, f = to(), h = o ?? f ?? "light", k = t ?? "en";
|
|
4910
|
+
c.useEffect(() => {
|
|
4879
4911
|
let p = document.getElementById("popup-root");
|
|
4880
4912
|
p || (p = document.createElement("div"), p.id = "popup-root", document.body.appendChild(p));
|
|
4881
4913
|
}, []);
|
|
4882
|
-
const v =
|
|
4914
|
+
const v = c.useMemo(() => {
|
|
4883
4915
|
if (r) return r;
|
|
4884
|
-
if (!
|
|
4885
|
-
const p = ro(
|
|
4916
|
+
if (!m) return null;
|
|
4917
|
+
const p = ro(m, m.name);
|
|
4886
4918
|
return !p.success || !p.instance ? null : p.instance;
|
|
4887
|
-
}, [r,
|
|
4888
|
-
return
|
|
4919
|
+
}, [r, m]);
|
|
4920
|
+
return m ? v ? /* @__PURE__ */ g(
|
|
4889
4921
|
Qn,
|
|
4890
4922
|
{
|
|
4891
|
-
definitionName:
|
|
4892
|
-
defaultStyle:
|
|
4893
|
-
defaultLanguage:
|
|
4923
|
+
definitionName: m.name,
|
|
4924
|
+
defaultStyle: d,
|
|
4925
|
+
defaultLanguage: k,
|
|
4894
4926
|
defaultTheme: h,
|
|
4895
|
-
defaultLocalizeName:
|
|
4927
|
+
defaultLocalizeName: m.localization || "",
|
|
4896
4928
|
className: n,
|
|
4897
|
-
defaultFieldValidationMode:
|
|
4929
|
+
defaultFieldValidationMode: s,
|
|
4898
4930
|
defaultDisplayInstanceName: l,
|
|
4899
4931
|
children: /* @__PURE__ */ g(
|
|
4900
4932
|
bn,
|
|
4901
4933
|
{
|
|
4902
|
-
definition:
|
|
4934
|
+
definition: m,
|
|
4903
4935
|
instance: v,
|
|
4904
4936
|
onSubmit: i,
|
|
4905
4937
|
onValidation: u
|
|
@@ -4943,8 +4975,8 @@ function no(e) {
|
|
|
4943
4975
|
const n = _r(t);
|
|
4944
4976
|
if (n) {
|
|
4945
4977
|
let o;
|
|
4946
|
-
for (const [a,
|
|
4947
|
-
if (
|
|
4978
|
+
for (const [a, s] of ee)
|
|
4979
|
+
if (s.components && s.components[t] === n) {
|
|
4948
4980
|
o = a;
|
|
4949
4981
|
break;
|
|
4950
4982
|
}
|
|
@@ -4959,11 +4991,11 @@ function no(e) {
|
|
|
4959
4991
|
if (e.fieldCustomValidators)
|
|
4960
4992
|
for (const [t, n] of Object.entries(e.fieldCustomValidators))
|
|
4961
4993
|
for (const o of Object.keys(n)) {
|
|
4962
|
-
const
|
|
4963
|
-
mr(t, o) &&
|
|
4994
|
+
const s = _.fieldValidators.get(t)?.get(o);
|
|
4995
|
+
mr(t, o) && s && s !== e.name && r.push({
|
|
4964
4996
|
type: "fieldCustomValidator",
|
|
4965
4997
|
name: `${t}:${o}`,
|
|
4966
|
-
existingPlugin:
|
|
4998
|
+
existingPlugin: s,
|
|
4967
4999
|
newPlugin: e.name
|
|
4968
5000
|
});
|
|
4969
5001
|
}
|
|
@@ -4999,13 +5031,13 @@ function no(e) {
|
|
|
4999
5031
|
}
|
|
5000
5032
|
return r;
|
|
5001
5033
|
}
|
|
5002
|
-
function se(e, r, t, n, o, a,
|
|
5034
|
+
function se(e, r, t, n, o, a, s, l) {
|
|
5003
5035
|
for (const i of Object.keys(e)) {
|
|
5004
5036
|
let u;
|
|
5005
|
-
if (l ? u = o.find((
|
|
5037
|
+
if (l ? u = o.find((m) => m.type === "fieldCustomValidator" && m.name === `${l}:${i}`) : e === n.components ? u = o.find((m) => m.type === "component" && m.name === i) : e === n.formValidators ? u = o.find((m) => m.type === "formValidator" && m.name === i) : e === n.fieldTypeValidators ? u = o.find((m) => m.type === "fieldTypeValidator" && m.name === `type:${i}`) : e === n.submissionHandlers && (u = o.find((m) => m.type === "submissionHandler" && m.name === i)), tt(u || null, a, s))
|
|
5006
5038
|
if (l) {
|
|
5007
|
-
const
|
|
5008
|
-
|
|
5039
|
+
const m = r.get(l) || /* @__PURE__ */ new Map();
|
|
5040
|
+
m.set(i, n.name), r.set(l, m), t(i, e[i]);
|
|
5009
5041
|
} else
|
|
5010
5042
|
r === _.components ? r.set(
|
|
5011
5043
|
i,
|
|
@@ -5038,7 +5070,7 @@ function Co(e, r) {
|
|
|
5038
5070
|
se(
|
|
5039
5071
|
a,
|
|
5040
5072
|
_.fieldValidators,
|
|
5041
|
-
(
|
|
5073
|
+
(s, l) => ht(o, s, l),
|
|
5042
5074
|
e,
|
|
5043
5075
|
n,
|
|
5044
5076
|
t,
|
|
@@ -5082,8 +5114,8 @@ function ko(e, r = !1) {
|
|
|
5082
5114
|
for (const [n, o] of Object.entries(t.fieldCustomValidators)) {
|
|
5083
5115
|
const a = _.fieldValidators.get(n);
|
|
5084
5116
|
if (a) {
|
|
5085
|
-
for (const
|
|
5086
|
-
a.delete(
|
|
5117
|
+
for (const s of Object.keys(o))
|
|
5118
|
+
a.delete(s);
|
|
5087
5119
|
a.size === 0 && _.fieldValidators.delete(n);
|
|
5088
5120
|
}
|
|
5089
5121
|
}
|
|
@@ -5139,7 +5171,7 @@ function Mo(e, r, t = {}) {
|
|
|
5139
5171
|
includeMetadata: n = !1,
|
|
5140
5172
|
dateFormat: o = "iso",
|
|
5141
5173
|
fileHandling: a = "metadata",
|
|
5142
|
-
prettify:
|
|
5174
|
+
prettify: s = !1,
|
|
5143
5175
|
excludeFields: l = [],
|
|
5144
5176
|
includeOnlyFields: i = []
|
|
5145
5177
|
} = t;
|
|
@@ -5148,35 +5180,35 @@ function Mo(e, r, t = {}) {
|
|
|
5148
5180
|
success: !1,
|
|
5149
5181
|
error: "Instance must be a valid object"
|
|
5150
5182
|
};
|
|
5151
|
-
const u = [],
|
|
5183
|
+
const u = [], m = [], d = {}, h = (nt(r) || re(r) && Array.isArray(r.properties) ? r.properties : []).filter(je), k = new Map(h.map((p) => [p.name, p]));
|
|
5152
5184
|
for (const [p, y] of Object.entries(e)) {
|
|
5153
5185
|
if (l.includes(p)) {
|
|
5154
|
-
|
|
5186
|
+
m.push(p);
|
|
5155
5187
|
continue;
|
|
5156
5188
|
}
|
|
5157
5189
|
if (i.length > 0 && !i.includes(p)) {
|
|
5158
|
-
|
|
5190
|
+
m.push(p);
|
|
5159
5191
|
continue;
|
|
5160
5192
|
}
|
|
5161
5193
|
if (y === void 0) continue;
|
|
5162
|
-
const C =
|
|
5194
|
+
const C = k.get(p);
|
|
5163
5195
|
try {
|
|
5164
|
-
|
|
5196
|
+
d[p] = oo(y, C, { dateFormat: o, fileHandling: a });
|
|
5165
5197
|
} catch (V) {
|
|
5166
|
-
u.push(`Error serializing field '${p}': ${String(V)}`),
|
|
5198
|
+
u.push(`Error serializing field '${p}': ${String(V)}`), d[p] = null;
|
|
5167
5199
|
}
|
|
5168
5200
|
}
|
|
5169
|
-
return n && (
|
|
5201
|
+
return n && (d._metadata = {
|
|
5170
5202
|
serializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5171
5203
|
version: (re(r) ? r.version : void 0) || "1.0.0",
|
|
5172
|
-
fieldCount: Object.keys(
|
|
5204
|
+
fieldCount: Object.keys(d).length - 1
|
|
5173
5205
|
// Exclude metadata itself
|
|
5174
5206
|
}), {
|
|
5175
5207
|
success: !0,
|
|
5176
|
-
data:
|
|
5208
|
+
data: s ? JSON.stringify(d, null, 2) : JSON.stringify(d),
|
|
5177
5209
|
metadata: {
|
|
5178
|
-
fieldCount: Object.keys(
|
|
5179
|
-
excludedFields:
|
|
5210
|
+
fieldCount: Object.keys(d).length,
|
|
5211
|
+
excludedFields: m,
|
|
5180
5212
|
warnings: u
|
|
5181
5213
|
}
|
|
5182
5214
|
};
|
|
@@ -5263,7 +5295,7 @@ function Vo(e, r, t = {}) {
|
|
|
5263
5295
|
strict: n = !1,
|
|
5264
5296
|
validateTypes: o = !0,
|
|
5265
5297
|
preserveUnknownFields: a = !0,
|
|
5266
|
-
dateFormat:
|
|
5298
|
+
dateFormat: s = "auto"
|
|
5267
5299
|
} = t;
|
|
5268
5300
|
if (!e || typeof e != "string")
|
|
5269
5301
|
return {
|
|
@@ -5284,7 +5316,7 @@ function Vo(e, r, t = {}) {
|
|
|
5284
5316
|
success: !1,
|
|
5285
5317
|
error: "Parsed data must be an object"
|
|
5286
5318
|
};
|
|
5287
|
-
const i = [], u = [],
|
|
5319
|
+
const i = [], u = [], m = {}, f = (nt(r) || re(r) && Array.isArray(r.properties) ? r.properties : []).filter(je), h = new Map(f.map((v) => [v.name, v]));
|
|
5288
5320
|
for (const v of f) {
|
|
5289
5321
|
const p = v.name, y = l[p];
|
|
5290
5322
|
if (y === void 0) {
|
|
@@ -5292,21 +5324,21 @@ function Vo(e, r, t = {}) {
|
|
|
5292
5324
|
continue;
|
|
5293
5325
|
}
|
|
5294
5326
|
try {
|
|
5295
|
-
|
|
5327
|
+
m[p] = ao(y, v, { validateTypes: o, dateFormat: s });
|
|
5296
5328
|
} catch (C) {
|
|
5297
5329
|
const V = `Error deserializing field '${p}': ${String(C)}`;
|
|
5298
|
-
n ? u.push(V) : (i.push(V),
|
|
5330
|
+
n ? u.push(V) : (i.push(V), m[p] = y);
|
|
5299
5331
|
}
|
|
5300
5332
|
}
|
|
5301
5333
|
if (a)
|
|
5302
5334
|
for (const [v, p] of Object.entries(l))
|
|
5303
|
-
!h.has(v) && v !== "_metadata" && (n && i.push(`Unknown field '${v}' preserved`),
|
|
5304
|
-
const
|
|
5335
|
+
!h.has(v) && v !== "_metadata" && (n && i.push(`Unknown field '${v}' preserved`), m[v] = p);
|
|
5336
|
+
const k = u.length > 0;
|
|
5305
5337
|
return {
|
|
5306
|
-
success: !
|
|
5307
|
-
data:
|
|
5338
|
+
success: !k,
|
|
5339
|
+
data: m,
|
|
5308
5340
|
warnings: i.length > 0 ? i : void 0,
|
|
5309
|
-
validationErrors:
|
|
5341
|
+
validationErrors: k ? u : void 0
|
|
5310
5342
|
};
|
|
5311
5343
|
} catch (n) {
|
|
5312
5344
|
return {
|
|
@@ -5388,10 +5420,10 @@ function Ro(e, r = {}) {
|
|
|
5388
5420
|
if (typeof e == "string")
|
|
5389
5421
|
try {
|
|
5390
5422
|
o = JSON.parse(e);
|
|
5391
|
-
} catch (
|
|
5423
|
+
} catch (m) {
|
|
5392
5424
|
return {
|
|
5393
5425
|
success: !1,
|
|
5394
|
-
error: `Invalid JSON for definition: ${
|
|
5426
|
+
error: `Invalid JSON for definition: ${m instanceof Error ? m.message : "Unknown parsing error"}`
|
|
5395
5427
|
};
|
|
5396
5428
|
}
|
|
5397
5429
|
else if (e && typeof e == "object")
|
|
@@ -5401,13 +5433,13 @@ function Ro(e, r = {}) {
|
|
|
5401
5433
|
success: !1,
|
|
5402
5434
|
error: "Input must be a string or object"
|
|
5403
5435
|
};
|
|
5404
|
-
const a = [],
|
|
5405
|
-
for (const
|
|
5406
|
-
if (!(
|
|
5436
|
+
const a = [], s = [], l = ["name", "version", "displayName"];
|
|
5437
|
+
for (const m of l)
|
|
5438
|
+
if (!(m in o) || !o[m])
|
|
5407
5439
|
if (t)
|
|
5408
|
-
|
|
5440
|
+
s.push(`Required field '${m}' is missing`);
|
|
5409
5441
|
else
|
|
5410
|
-
switch (a.push(`Missing field '${
|
|
5442
|
+
switch (a.push(`Missing field '${m}', using default`), m) {
|
|
5411
5443
|
case "name":
|
|
5412
5444
|
o.name = "unnamed-definition";
|
|
5413
5445
|
break;
|
|
@@ -5419,20 +5451,20 @@ function Ro(e, r = {}) {
|
|
|
5419
5451
|
break;
|
|
5420
5452
|
}
|
|
5421
5453
|
const i = Array.isArray(o.properties) ? o.properties : null;
|
|
5422
|
-
i ? o.properties = i.map((
|
|
5423
|
-
const f = re(
|
|
5454
|
+
i ? o.properties = i.map((m, d) => {
|
|
5455
|
+
const f = re(m) ? m : {}, h = { ...f };
|
|
5424
5456
|
if (!f.name) {
|
|
5425
|
-
const
|
|
5426
|
-
t ?
|
|
5457
|
+
const k = `Property at index ${d} missing 'name'`;
|
|
5458
|
+
t ? s.push(k) : (a.push(`${k}, using 'field_${d}'`), h.name = `field_${d}`);
|
|
5427
5459
|
}
|
|
5428
|
-
return f.displayName || (h.displayName = f.name || `Field ${
|
|
5429
|
-
}) : t ?
|
|
5430
|
-
const u =
|
|
5460
|
+
return f.displayName || (h.displayName = f.name || `Field ${d}`), f.type || (t && n ? s.push(`Property '${f.name || d}' missing 'type'`) : (a.push(`Property '${f.name || d}' missing 'type', using 'string'`), h.type = "string")), f.defaultValue === void 0 && (h.defaultValue = null), f.required === void 0 && (h.required = !1), h;
|
|
5461
|
+
}) : t ? s.push("Properties must be an array") : (a.push("Properties not found or invalid, using empty array"), o.properties = []);
|
|
5462
|
+
const u = s.length > 0;
|
|
5431
5463
|
return {
|
|
5432
5464
|
success: !u,
|
|
5433
5465
|
data: o,
|
|
5434
5466
|
warnings: a.length > 0 ? a : void 0,
|
|
5435
|
-
validationErrors: u ?
|
|
5467
|
+
validationErrors: u ? s : void 0
|
|
5436
5468
|
};
|
|
5437
5469
|
} catch (t) {
|
|
5438
5470
|
return {
|
|
@@ -5554,7 +5586,7 @@ export {
|
|
|
5554
5586
|
So as ReactaForm,
|
|
5555
5587
|
Qn as ReactaFormProvider,
|
|
5556
5588
|
bn as ReactaFormRenderer,
|
|
5557
|
-
|
|
5589
|
+
B as StandardFieldLayout,
|
|
5558
5590
|
fo as Units,
|
|
5559
5591
|
W as combineClasses,
|
|
5560
5592
|
ro as createInstanceFromDefinition,
|