reactaform 1.9.2 → 1.9.21
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.cjs.js +5 -5
- package/dist/reactaform.es.js +562 -536
- package/package.json +1 -1
package/dist/reactaform.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as p, jsxs as
|
|
1
|
+
import { jsx as p, jsxs as z, Fragment as Ie } from "react/jsx-runtime";
|
|
2
2
|
import * as l from "react";
|
|
3
|
-
import { createContext as
|
|
3
|
+
import { createContext as st, useContext as ct, useRef as pe, useEffect as Ue, useCallback as ge } from "react";
|
|
4
4
|
import * as de from "react-dom";
|
|
5
|
-
const
|
|
5
|
+
const lt = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
6
6
|
\r
|
|
7
7
|
/* Default Light Theme */\r
|
|
8
8
|
:root {\r
|
|
@@ -394,8 +394,8 @@ const ct = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
394
394
|
\r
|
|
395
395
|
\r
|
|
396
396
|
}\r
|
|
397
|
-
`, Ee =
|
|
398
|
-
const e =
|
|
397
|
+
`, Ee = st(void 0), B = () => {
|
|
398
|
+
const e = ct(Ee);
|
|
399
399
|
if (!e)
|
|
400
400
|
throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");
|
|
401
401
|
return e;
|
|
@@ -447,7 +447,7 @@ class ne {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
const or = typeof process < "u" && process.env.NODE_ENV === "test";
|
|
450
|
-
function
|
|
450
|
+
function ut(e, r = 300, t) {
|
|
451
451
|
const n = pe(), o = pe(e), a = pe(null), c = t?.leading === !0, s = t?.trailing !== !1;
|
|
452
452
|
Ue(() => {
|
|
453
453
|
o.current = e;
|
|
@@ -475,7 +475,7 @@ function lt(e, r = 300, t) {
|
|
|
475
475
|
[c, s, r]
|
|
476
476
|
), cancel: d, flush: m };
|
|
477
477
|
}
|
|
478
|
-
const
|
|
478
|
+
const $ = {
|
|
479
479
|
field: "reactaform-field",
|
|
480
480
|
label: "reactaform-label",
|
|
481
481
|
input: "reactaform-input",
|
|
@@ -496,7 +496,7 @@ const V = {
|
|
|
496
496
|
function ie(e) {
|
|
497
497
|
return e.toLowerCase().includes("dark");
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function mt(e) {
|
|
500
500
|
if (!e) return !1;
|
|
501
501
|
const r = e.trim();
|
|
502
502
|
let t = 0, n = 0, o = 0;
|
|
@@ -510,7 +510,7 @@ function ut(e) {
|
|
|
510
510
|
return !1;
|
|
511
511
|
return (t * 299 + n * 587 + o * 114) / 1e3 < 128;
|
|
512
512
|
}
|
|
513
|
-
const
|
|
513
|
+
const dt = () => /* @__PURE__ */ z(
|
|
514
514
|
"svg",
|
|
515
515
|
{
|
|
516
516
|
width: "1em",
|
|
@@ -526,18 +526,18 @@ const mt = () => /* @__PURE__ */ D(
|
|
|
526
526
|
/* @__PURE__ */ p("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
527
527
|
]
|
|
528
528
|
}
|
|
529
|
-
),
|
|
530
|
-
const { t: n, theme: o, formStyle: a, fieldStyle: c } = B(), [s, i] = l.useState(!1), [d, m] = l.useState({ x: 0, y: 0 }), [u, f] = l.useState(!1), b = l.useRef(null), C = l.useRef(null), N = l.useRef(null), h = l.useId(), y = ie(o), [E,
|
|
529
|
+
), ft = ({ content: e, size: r = "medium", animation: t = !0 }) => {
|
|
530
|
+
const { t: n, theme: o, formStyle: a, fieldStyle: c } = B(), [s, i] = l.useState(!1), [d, m] = l.useState({ x: 0, y: 0 }), [u, f] = l.useState(!1), b = l.useRef(null), C = l.useRef(null), N = l.useRef(null), h = l.useId(), y = ie(o), [E, M] = l.useState(void 0);
|
|
531
531
|
l.useLayoutEffect(() => {
|
|
532
532
|
if (!b.current) return;
|
|
533
533
|
const I = "rgba(255,255,255,0.1)", g = getComputedStyle(b.current).getPropertyValue("--reactaform-primary-bg").trim();
|
|
534
534
|
if (g && typeof CSS < "u" && CSS.supports?.("color: color-mix(in srgb, red, blue)")) {
|
|
535
|
-
const w =
|
|
536
|
-
|
|
535
|
+
const w = mt(g) ? "black" : "white";
|
|
536
|
+
M(`color-mix(in srgb, var(--reactaform-primary-bg) 85%, ${w} 15%)`);
|
|
537
537
|
} else
|
|
538
|
-
|
|
538
|
+
M(I);
|
|
539
539
|
}, []);
|
|
540
|
-
const
|
|
540
|
+
const F = l.useMemo(() => {
|
|
541
541
|
const v = {
|
|
542
542
|
icon: {
|
|
543
543
|
display: "inline-flex",
|
|
@@ -614,25 +614,25 @@ const mt = () => /* @__PURE__ */ D(
|
|
|
614
614
|
);
|
|
615
615
|
}
|
|
616
616
|
}, [s]);
|
|
617
|
-
const
|
|
617
|
+
const V = typeof document < "u" ? document.getElementById("popup-root") : null, R = /* @__PURE__ */ p(
|
|
618
618
|
"div",
|
|
619
619
|
{
|
|
620
620
|
ref: C,
|
|
621
621
|
"data-tooltip-id": h,
|
|
622
622
|
style: {
|
|
623
|
-
...
|
|
623
|
+
...F.text,
|
|
624
624
|
transform: u ? "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
|
-
...u ?
|
|
628
|
+
...u ? F.textVisible : {},
|
|
629
629
|
top: d.y,
|
|
630
630
|
left: d.x
|
|
631
631
|
},
|
|
632
632
|
children: n(e)
|
|
633
633
|
}
|
|
634
634
|
);
|
|
635
|
-
return /* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ z(Ie, { children: [
|
|
636
636
|
/* @__PURE__ */ p(
|
|
637
637
|
"span",
|
|
638
638
|
{
|
|
@@ -642,14 +642,14 @@ const mt = () => /* @__PURE__ */ D(
|
|
|
642
642
|
onMouseEnter: () => i(!0),
|
|
643
643
|
onMouseLeave: () => i(!1),
|
|
644
644
|
style: {
|
|
645
|
-
...
|
|
645
|
+
...F.icon
|
|
646
646
|
},
|
|
647
|
-
children: /* @__PURE__ */ p(
|
|
647
|
+
children: /* @__PURE__ */ p(dt, {})
|
|
648
648
|
}
|
|
649
649
|
),
|
|
650
|
-
s && (
|
|
650
|
+
s && (V ? de.createPortal(R, V) : R)
|
|
651
651
|
] });
|
|
652
|
-
}, ar = l.memo(
|
|
652
|
+
}, ar = l.memo(ft), ve = l.memo(({
|
|
653
653
|
field: e,
|
|
654
654
|
error: r,
|
|
655
655
|
children: t,
|
|
@@ -674,22 +674,22 @@ const mt = () => /* @__PURE__ */ D(
|
|
|
674
674
|
gap: "var(--reactaform-inline-gap, 8px)",
|
|
675
675
|
width: "100%"
|
|
676
676
|
}), []);
|
|
677
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ z("div", { className: `${$.field} column-layout`, style: c, children: [
|
|
678
678
|
n && /* @__PURE__ */ p(
|
|
679
679
|
"label",
|
|
680
680
|
{
|
|
681
681
|
id: `${e.name}-label`,
|
|
682
|
-
className:
|
|
682
|
+
className: $.label,
|
|
683
683
|
htmlFor: e.name,
|
|
684
684
|
style: s,
|
|
685
685
|
children: o(e.displayName)
|
|
686
686
|
}
|
|
687
687
|
),
|
|
688
|
-
/* @__PURE__ */
|
|
688
|
+
/* @__PURE__ */ z("div", { style: i, children: [
|
|
689
689
|
/* @__PURE__ */ p("div", { style: { flex: 1, minWidth: 0 }, children: t }),
|
|
690
690
|
e.tooltip && /* @__PURE__ */ p(ar, { content: e.tooltip })
|
|
691
691
|
] }),
|
|
692
|
-
r && /* @__PURE__ */ p(
|
|
692
|
+
r && /* @__PURE__ */ p(Fe, { id: `${e.name}-error`, children: r })
|
|
693
693
|
] });
|
|
694
694
|
});
|
|
695
695
|
ve.displayName = "ColumnFieldLayout";
|
|
@@ -704,35 +704,35 @@ const ir = l.memo(({
|
|
|
704
704
|
alignItems: "center",
|
|
705
705
|
gap: "3px"
|
|
706
706
|
}), []);
|
|
707
|
-
return /* @__PURE__ */
|
|
707
|
+
return /* @__PURE__ */ z("div", { className: `${$.field} row-layout`, children: [
|
|
708
708
|
/* @__PURE__ */ p(
|
|
709
709
|
"label",
|
|
710
710
|
{
|
|
711
711
|
id: `${e.name}-label`,
|
|
712
|
-
className:
|
|
712
|
+
className: $.label,
|
|
713
713
|
htmlFor: e.name,
|
|
714
714
|
style: { textAlign: "left" },
|
|
715
715
|
children: o(e.displayName)
|
|
716
716
|
}
|
|
717
717
|
),
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
/* @__PURE__ */
|
|
718
|
+
/* @__PURE__ */ z("div", { children: [
|
|
719
|
+
/* @__PURE__ */ z("div", { style: a, children: [
|
|
720
720
|
n ? /* @__PURE__ */ p("div", { style: { display: "flex", flex: 1, justifyContent: "flex-end" }, children: t }) : t,
|
|
721
721
|
e.tooltip && /* @__PURE__ */ p(ar, { content: e.tooltip })
|
|
722
722
|
] }),
|
|
723
|
-
r && /* @__PURE__ */ p(
|
|
723
|
+
r && /* @__PURE__ */ p(Fe, { id: `${e.name}-error`, children: r })
|
|
724
724
|
] })
|
|
725
725
|
] });
|
|
726
726
|
});
|
|
727
727
|
ir.displayName = "RowFieldLayout";
|
|
728
|
-
const
|
|
728
|
+
const L = l.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__ */ p(ve, { field: e, error: r, showLabel: !0, children: t }) : e.type === "checkbox" || e.type === "switch" ? /* @__PURE__ */ p(ve, { field: e, error: r, showLabel: !1, children: t }) : /* @__PURE__ */ p(ir, { field: e, error: r, rightAlign: n, children: t }));
|
|
734
|
-
|
|
735
|
-
const
|
|
734
|
+
L.displayName = "StandardFieldLayout";
|
|
735
|
+
const Fe = l.memo(({ children: e, id: r }) => {
|
|
736
736
|
const t = l.useMemo(() => ({
|
|
737
737
|
color: "var(--reactaform-error-color, red)",
|
|
738
738
|
fontSize: "13px",
|
|
@@ -746,11 +746,11 @@ const Me = l.memo(({ children: e, id: r }) => {
|
|
|
746
746
|
}), []);
|
|
747
747
|
return /* @__PURE__ */ p("div", { id: r, style: t, children: e });
|
|
748
748
|
});
|
|
749
|
-
|
|
749
|
+
Fe.displayName = "ErrorDiv";
|
|
750
750
|
const sr = l.memo(({ name: e, onChange: r }) => {
|
|
751
751
|
const { t } = B();
|
|
752
|
-
return /* @__PURE__ */
|
|
753
|
-
/* @__PURE__ */
|
|
752
|
+
return /* @__PURE__ */ z("div", { style: { marginBottom: 16 }, children: [
|
|
753
|
+
/* @__PURE__ */ z("div", { style: { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 12, alignItems: "center" }, children: [
|
|
754
754
|
/* @__PURE__ */ p(
|
|
755
755
|
"label",
|
|
756
756
|
{
|
|
@@ -770,7 +770,7 @@ const sr = l.memo(({ name: e, onChange: r }) => {
|
|
|
770
770
|
id: "instance-name-input",
|
|
771
771
|
type: "text",
|
|
772
772
|
value: e,
|
|
773
|
-
className: U(
|
|
773
|
+
className: U($.input, $.textInput),
|
|
774
774
|
onChange: (n) => r(n.target.value),
|
|
775
775
|
placeholder: t("Enter instance name")
|
|
776
776
|
}
|
|
@@ -780,7 +780,7 @@ const sr = l.memo(({ name: e, onChange: r }) => {
|
|
|
780
780
|
] });
|
|
781
781
|
});
|
|
782
782
|
sr.displayName = "InstanceName";
|
|
783
|
-
class
|
|
783
|
+
class pt extends ne {
|
|
784
784
|
registerInCategory(r, t, n) {
|
|
785
785
|
this.get(r) || this.register(r, {});
|
|
786
786
|
const o = this.get(r);
|
|
@@ -796,24 +796,24 @@ class ft extends ne {
|
|
|
796
796
|
return this.list();
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
|
-
const cr = new ne(), lr = new
|
|
800
|
-
function
|
|
799
|
+
const cr = new ne(), lr = new pt(), Me = new ne();
|
|
800
|
+
function gt(e, r) {
|
|
801
801
|
cr.register(e, r);
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function ht(e, r, t) {
|
|
804
804
|
lr.registerInCategory(e, r, t);
|
|
805
805
|
}
|
|
806
|
-
function
|
|
807
|
-
if (
|
|
806
|
+
function bt(e, r) {
|
|
807
|
+
if (an(e)) {
|
|
808
808
|
console.warn(
|
|
809
809
|
`[ReactaForm] Can't override builtin type field validation handler for type "${e}".`
|
|
810
810
|
);
|
|
811
811
|
return;
|
|
812
812
|
}
|
|
813
|
-
|
|
813
|
+
Me.register(e, r);
|
|
814
814
|
}
|
|
815
815
|
function H(e, r) {
|
|
816
|
-
|
|
816
|
+
Me.register(e, r);
|
|
817
817
|
}
|
|
818
818
|
function ur(e, r) {
|
|
819
819
|
return lr.getFromCategory(e, r) || null;
|
|
@@ -822,9 +822,9 @@ function mr(e) {
|
|
|
822
822
|
return cr.get(e) || null;
|
|
823
823
|
}
|
|
824
824
|
function dr(e) {
|
|
825
|
-
return
|
|
825
|
+
return Me.get(e) || null;
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function yt(e) {
|
|
828
828
|
return (typeof e == "object" || typeof e == "function") && e !== null && typeof e.then == "function";
|
|
829
829
|
}
|
|
830
830
|
const We = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map();
|
|
@@ -854,7 +854,7 @@ function fr(e, r, t, n) {
|
|
|
854
854
|
}
|
|
855
855
|
return null;
|
|
856
856
|
}
|
|
857
|
-
function
|
|
857
|
+
function mo(e, r, t, n) {
|
|
858
858
|
return fr(e, r, t, n);
|
|
859
859
|
}
|
|
860
860
|
function pr(e, r, t, n) {
|
|
@@ -867,7 +867,7 @@ function pr(e, r, t, n) {
|
|
|
867
867
|
return r.required ? n("Value required") : null;
|
|
868
868
|
return fr(e, r, t, n);
|
|
869
869
|
}
|
|
870
|
-
async function
|
|
870
|
+
async function vt(e, r, t) {
|
|
871
871
|
if (!e || typeof e.validationHandlerName != "string")
|
|
872
872
|
return null;
|
|
873
873
|
const n = e.validationHandlerName;
|
|
@@ -875,7 +875,7 @@ async function yt(e, r, t) {
|
|
|
875
875
|
if (o === void 0 && (o = mr(n) || null, _e.set(n, o)), o)
|
|
876
876
|
try {
|
|
877
877
|
const a = o(r, t);
|
|
878
|
-
return
|
|
878
|
+
return yt(a) ? await a || null : a || null;
|
|
879
879
|
} catch (a) {
|
|
880
880
|
return [String(a instanceof Error ? a.message : a)];
|
|
881
881
|
}
|
|
@@ -910,7 +910,7 @@ const gr = ({
|
|
|
910
910
|
},
|
|
911
911
|
[t, r]
|
|
912
912
|
), m = e.name;
|
|
913
|
-
return /* @__PURE__ */ p(
|
|
913
|
+
return /* @__PURE__ */ p(L, { field: e, rightAlign: !1, error: s, children: /* @__PURE__ */ z(
|
|
914
914
|
"div",
|
|
915
915
|
{
|
|
916
916
|
style: {
|
|
@@ -923,7 +923,7 @@ const gr = ({
|
|
|
923
923
|
/* @__PURE__ */ p(
|
|
924
924
|
"label",
|
|
925
925
|
{
|
|
926
|
-
className:
|
|
926
|
+
className: $.label,
|
|
927
927
|
htmlFor: m,
|
|
928
928
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
929
929
|
children: a(e.displayName)
|
|
@@ -956,7 +956,7 @@ const gr = ({
|
|
|
956
956
|
) });
|
|
957
957
|
};
|
|
958
958
|
gr.displayName = "CheckboxInput";
|
|
959
|
-
const
|
|
959
|
+
const xt = l.memo(gr);
|
|
960
960
|
function _({ value: e, onChange: r, onError: t, validate: n }) {
|
|
961
961
|
const o = l.useRef(null), a = l.useRef(null), c = l.useRef(t), [s, i] = l.useState(null);
|
|
962
962
|
l.useEffect(() => {
|
|
@@ -992,11 +992,11 @@ const Ke = [
|
|
|
992
992
|
{ label: "Gray", value: "#808080" },
|
|
993
993
|
{ label: "Light Gray", value: "#d3d3d3" },
|
|
994
994
|
{ label: "Pink", value: "#ffc0cb" }
|
|
995
|
-
],
|
|
996
|
-
if (!e || !
|
|
995
|
+
], wt = /^#([0-9A-F]{3}){1,2}$/i, St = "#000000", Ct = (e) => wt.test(e), he = (e) => {
|
|
996
|
+
if (!e || !Ct(e)) return St;
|
|
997
997
|
const r = e.toLowerCase();
|
|
998
998
|
return r.length === 4 ? "#" + r.slice(1).split("").map((t) => t + t).join("") : r;
|
|
999
|
-
},
|
|
999
|
+
}, Nt = (e) => {
|
|
1000
1000
|
const r = parseInt(e.slice(1), 16);
|
|
1001
1001
|
return {
|
|
1002
1002
|
r: r >> 16 & 255,
|
|
@@ -1023,29 +1023,29 @@ const Ke = [
|
|
|
1023
1023
|
f(s);
|
|
1024
1024
|
}, [s]);
|
|
1025
1025
|
const b = l.useCallback(
|
|
1026
|
-
(
|
|
1027
|
-
const
|
|
1028
|
-
f(
|
|
1029
|
-
target: { value:
|
|
1026
|
+
(F) => {
|
|
1027
|
+
const V = he(F.target.value);
|
|
1028
|
+
f(V), m({
|
|
1029
|
+
target: { value: V }
|
|
1030
1030
|
});
|
|
1031
1031
|
},
|
|
1032
1032
|
[m]
|
|
1033
1033
|
), C = l.useCallback(
|
|
1034
|
-
(
|
|
1035
|
-
const
|
|
1036
|
-
f(
|
|
1037
|
-
target: { value:
|
|
1034
|
+
(F) => {
|
|
1035
|
+
const V = he(F.target.value);
|
|
1036
|
+
f(V), m({
|
|
1037
|
+
target: { value: V }
|
|
1038
1038
|
});
|
|
1039
1039
|
},
|
|
1040
1040
|
[m]
|
|
1041
1041
|
), h = l.useMemo(
|
|
1042
|
-
() => new Set(Ke.map((
|
|
1042
|
+
() => new Set(Ke.map((F) => F.value)),
|
|
1043
1043
|
[]
|
|
1044
|
-
).has(u), { r: y, g: E, b:
|
|
1045
|
-
() =>
|
|
1044
|
+
).has(u), { r: y, g: E, b: M } = l.useMemo(
|
|
1045
|
+
() => Nt(u),
|
|
1046
1046
|
[u]
|
|
1047
1047
|
);
|
|
1048
|
-
return /* @__PURE__ */ p(
|
|
1048
|
+
return /* @__PURE__ */ p(L, { field: e, error: d, children: /* @__PURE__ */ z(
|
|
1049
1049
|
"div",
|
|
1050
1050
|
{
|
|
1051
1051
|
style: {
|
|
@@ -1055,26 +1055,26 @@ const Ke = [
|
|
|
1055
1055
|
width: "100%"
|
|
1056
1056
|
},
|
|
1057
1057
|
children: [
|
|
1058
|
-
/* @__PURE__ */
|
|
1058
|
+
/* @__PURE__ */ z(
|
|
1059
1059
|
"select",
|
|
1060
1060
|
{
|
|
1061
1061
|
id: e.name,
|
|
1062
1062
|
value: u,
|
|
1063
1063
|
onChange: C,
|
|
1064
1064
|
className: U(
|
|
1065
|
-
|
|
1066
|
-
|
|
1065
|
+
$.input,
|
|
1066
|
+
$.inputSelect
|
|
1067
1067
|
),
|
|
1068
1068
|
"aria-invalid": !!d,
|
|
1069
1069
|
children: [
|
|
1070
|
-
Ke.map((
|
|
1071
|
-
!h && /* @__PURE__ */
|
|
1070
|
+
Ke.map((F) => /* @__PURE__ */ p("option", { value: F.value, children: a(F.label) }, F.value)),
|
|
1071
|
+
!h && /* @__PURE__ */ z("option", { value: u, children: [
|
|
1072
1072
|
"(",
|
|
1073
1073
|
y,
|
|
1074
1074
|
", ",
|
|
1075
1075
|
E,
|
|
1076
1076
|
", ",
|
|
1077
|
-
|
|
1077
|
+
M,
|
|
1078
1078
|
")"
|
|
1079
1079
|
] })
|
|
1080
1080
|
]
|
|
@@ -1112,7 +1112,7 @@ const Ke = [
|
|
|
1112
1112
|
) });
|
|
1113
1113
|
};
|
|
1114
1114
|
hr.displayName = "ColorInput";
|
|
1115
|
-
const
|
|
1115
|
+
const kt = l.memo(hr), Ge = (e) => {
|
|
1116
1116
|
if (!e) return null;
|
|
1117
1117
|
const r = new Date(e);
|
|
1118
1118
|
return isNaN(r.getTime()) ? null : r;
|
|
@@ -1139,7 +1139,7 @@ const Nt = l.memo(hr), Ge = (e) => {
|
|
|
1139
1139
|
onError: n,
|
|
1140
1140
|
validate: a
|
|
1141
1141
|
});
|
|
1142
|
-
return /* @__PURE__ */ p(
|
|
1142
|
+
return /* @__PURE__ */ p(L, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1143
1143
|
"input",
|
|
1144
1144
|
{
|
|
1145
1145
|
id: e.name,
|
|
@@ -1147,7 +1147,7 @@ const Nt = l.memo(hr), Ge = (e) => {
|
|
|
1147
1147
|
ref: s,
|
|
1148
1148
|
defaultValue: Je(r),
|
|
1149
1149
|
onChange: d,
|
|
1150
|
-
className: U(
|
|
1150
|
+
className: U($.input, $.textInput),
|
|
1151
1151
|
...e.minDate ? { min: e.minDate } : {},
|
|
1152
1152
|
...e.maxDate ? { max: e.maxDate } : {},
|
|
1153
1153
|
"aria-invalid": !!i,
|
|
@@ -1156,19 +1156,19 @@ const Nt = l.memo(hr), Ge = (e) => {
|
|
|
1156
1156
|
) });
|
|
1157
1157
|
};
|
|
1158
1158
|
br.displayName = "DateInput";
|
|
1159
|
-
const
|
|
1159
|
+
const It = l.memo(br), yr = ({ field: e }) => {
|
|
1160
1160
|
const { t: r } = B(), { displayText: t = "", textAlign: n = "left", allowHtml: o = !1 } = e;
|
|
1161
1161
|
return /* @__PURE__ */ p(
|
|
1162
1162
|
"div",
|
|
1163
1163
|
{
|
|
1164
|
-
className:
|
|
1164
|
+
className: $.description,
|
|
1165
1165
|
style: { textAlign: n },
|
|
1166
1166
|
...o ? { dangerouslySetInnerHTML: { __html: r(t) } } : { children: r(t) }
|
|
1167
1167
|
}
|
|
1168
1168
|
);
|
|
1169
1169
|
};
|
|
1170
1170
|
yr.displayName = "Description";
|
|
1171
|
-
const
|
|
1171
|
+
const Et = l.memo(yr), vr = ({
|
|
1172
1172
|
field: e,
|
|
1173
1173
|
value: r,
|
|
1174
1174
|
onChange: t,
|
|
@@ -1189,14 +1189,14 @@ const It = l.memo(yr), vr = ({
|
|
|
1189
1189
|
}
|
|
1190
1190
|
w !== E.current && (E.current = w, y(w), m.current?.(w ?? null));
|
|
1191
1191
|
}, [r, N, t, e.options]);
|
|
1192
|
-
const
|
|
1192
|
+
const M = () => {
|
|
1193
1193
|
if (!d.current) return;
|
|
1194
1194
|
const g = d.current.getBoundingClientRect();
|
|
1195
1195
|
C({ x: g.left, y: g.bottom }), f((w) => !w);
|
|
1196
|
-
},
|
|
1196
|
+
}, F = (g) => {
|
|
1197
1197
|
const w = N(g);
|
|
1198
1198
|
w !== E.current && (E.current = w, y(w), m.current?.(w ?? null)), t?.(g), f(!1);
|
|
1199
|
-
},
|
|
1199
|
+
}, V = l.useMemo(() => {
|
|
1200
1200
|
const g = e.options.find((w) => String(w.value) === String(r));
|
|
1201
1201
|
return g ? a(g.label) : "";
|
|
1202
1202
|
}, [e.options, r, a]), R = (g, w, x) => {
|
|
@@ -1225,14 +1225,14 @@ const It = l.memo(yr), vr = ({
|
|
|
1225
1225
|
...R(s, "dropdown", "arrow"),
|
|
1226
1226
|
...R(i, void 0, "arrow")
|
|
1227
1227
|
}), [s, i]);
|
|
1228
|
-
return /* @__PURE__ */
|
|
1229
|
-
/* @__PURE__ */ p(
|
|
1228
|
+
return /* @__PURE__ */ z("div", { children: [
|
|
1229
|
+
/* @__PURE__ */ p(L, { field: e, error: h, children: /* @__PURE__ */ z(
|
|
1230
1230
|
"div",
|
|
1231
1231
|
{
|
|
1232
1232
|
ref: d,
|
|
1233
1233
|
className: "reactaform-input",
|
|
1234
1234
|
style: I,
|
|
1235
|
-
onClick:
|
|
1235
|
+
onClick: M,
|
|
1236
1236
|
tabIndex: 0,
|
|
1237
1237
|
role: "combobox",
|
|
1238
1238
|
"aria-haspopup": "listbox",
|
|
@@ -1240,21 +1240,21 @@ const It = l.memo(yr), vr = ({
|
|
|
1240
1240
|
"aria-invalid": !!h,
|
|
1241
1241
|
"aria-describedby": h ? `${e.name}-error` : void 0,
|
|
1242
1242
|
onKeyDown: (g) => {
|
|
1243
|
-
(g.key === "Enter" || g.key === " ") && (g.preventDefault(),
|
|
1243
|
+
(g.key === "Enter" || g.key === " ") && (g.preventDefault(), M());
|
|
1244
1244
|
},
|
|
1245
1245
|
children: [
|
|
1246
|
-
/* @__PURE__ */ p("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", paddingRight: "1.8em", display: "block" }, children:
|
|
1246
|
+
/* @__PURE__ */ p("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", paddingRight: "1.8em", display: "block" }, children: V }),
|
|
1247
1247
|
/* @__PURE__ */ p("span", { style: v, "aria-hidden": !0, children: "▼" })
|
|
1248
1248
|
]
|
|
1249
1249
|
}
|
|
1250
1250
|
) }),
|
|
1251
1251
|
u && b && /* @__PURE__ */ p(
|
|
1252
|
-
|
|
1252
|
+
Ft,
|
|
1253
1253
|
{
|
|
1254
1254
|
position: b,
|
|
1255
1255
|
options: e.options,
|
|
1256
1256
|
selectedValue: String(r),
|
|
1257
|
-
onSelect:
|
|
1257
|
+
onSelect: F,
|
|
1258
1258
|
onClose: () => f(!1),
|
|
1259
1259
|
controlRef: d,
|
|
1260
1260
|
theme: c,
|
|
@@ -1262,7 +1262,7 @@ const It = l.memo(yr), vr = ({
|
|
|
1262
1262
|
}
|
|
1263
1263
|
)
|
|
1264
1264
|
] });
|
|
1265
|
-
},
|
|
1265
|
+
}, Ft = ({
|
|
1266
1266
|
position: e,
|
|
1267
1267
|
options: r,
|
|
1268
1268
|
selectedValue: t,
|
|
@@ -1333,7 +1333,7 @@ const It = l.memo(yr), vr = ({
|
|
|
1333
1333
|
const v = i.current.querySelector(`#opt-${d}`);
|
|
1334
1334
|
v && requestAnimationFrame(() => v.focus());
|
|
1335
1335
|
}, [d]);
|
|
1336
|
-
const y = 250, E = 200, [
|
|
1336
|
+
const y = 250, E = 200, [M, F] = l.useState(null), [V, R] = l.useState(null);
|
|
1337
1337
|
if (l.useEffect(() => {
|
|
1338
1338
|
if (typeof window > "u") return;
|
|
1339
1339
|
const v = () => {
|
|
@@ -1343,7 +1343,7 @@ const It = l.memo(yr), vr = ({
|
|
|
1343
1343
|
const j = A.getBoundingClientRect();
|
|
1344
1344
|
x = j.left, k = j.bottom, S = Math.max(80, Math.round(j.width));
|
|
1345
1345
|
}
|
|
1346
|
-
x = Math.min(x, window.innerWidth - S), k = Math.min(k, window.innerHeight - E),
|
|
1346
|
+
x = Math.min(x, window.innerWidth - S), k = Math.min(k, window.innerHeight - E), F({ left: x, top: k }), R(S);
|
|
1347
1347
|
};
|
|
1348
1348
|
v(), window.addEventListener("scroll", v, !0), window.addEventListener("resize", v);
|
|
1349
1349
|
let g = null;
|
|
@@ -1362,9 +1362,9 @@ const It = l.memo(yr), vr = ({
|
|
|
1362
1362
|
"aria-activedescendant": d >= 0 ? `opt-${d}` : void 0,
|
|
1363
1363
|
style: {
|
|
1364
1364
|
position: "fixed",
|
|
1365
|
-
top:
|
|
1366
|
-
left:
|
|
1367
|
-
width:
|
|
1365
|
+
top: M ? M.top : e.y,
|
|
1366
|
+
left: M ? M.left : e.x,
|
|
1367
|
+
width: V ?? y,
|
|
1368
1368
|
...N
|
|
1369
1369
|
},
|
|
1370
1370
|
"data-reactaform-theme": c ?? "light",
|
|
@@ -1439,7 +1439,7 @@ const Mt = l.memo(vr), xr = ({
|
|
|
1439
1439
|
onError: n,
|
|
1440
1440
|
validate: a
|
|
1441
1441
|
});
|
|
1442
|
-
return /* @__PURE__ */ p(
|
|
1442
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1443
1443
|
"input",
|
|
1444
1444
|
{
|
|
1445
1445
|
id: e.name,
|
|
@@ -1447,14 +1447,14 @@ const Mt = l.memo(vr), xr = ({
|
|
|
1447
1447
|
defaultValue: String(r ?? ""),
|
|
1448
1448
|
ref: c,
|
|
1449
1449
|
onChange: i,
|
|
1450
|
-
className: U(
|
|
1450
|
+
className: U($.input, $.textInput),
|
|
1451
1451
|
"aria-invalid": !!s,
|
|
1452
1452
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
1453
1453
|
}
|
|
1454
1454
|
) });
|
|
1455
1455
|
};
|
|
1456
1456
|
xr.displayName = "EmailInput";
|
|
1457
|
-
const
|
|
1457
|
+
const Vt = l.memo(xr), wr = ({ field: e }) => {
|
|
1458
1458
|
const { theme: r } = B(), {
|
|
1459
1459
|
color: t = ie(r) ? "#444444" : "#CCCCCC",
|
|
1460
1460
|
thickness: n = 1,
|
|
@@ -1513,11 +1513,11 @@ const $t = l.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1513
1513
|
const S = h(k);
|
|
1514
1514
|
S !== u.current && (u.current = S, b(S), m.current?.(S ?? null)), t?.(k);
|
|
1515
1515
|
}
|
|
1516
|
-
}, F = (g) => {
|
|
1517
|
-
g.preventDefault(), g.stopPropagation(), i(!0);
|
|
1518
1516
|
}, M = (g) => {
|
|
1517
|
+
g.preventDefault(), g.stopPropagation(), i(!0);
|
|
1518
|
+
}, F = (g) => {
|
|
1519
1519
|
g.preventDefault(), g.stopPropagation(), i(!1);
|
|
1520
|
-
},
|
|
1520
|
+
}, V = (g) => {
|
|
1521
1521
|
if (Array.isArray(r) && typeof g == "number") {
|
|
1522
1522
|
const w = r.filter((S, A) => A !== g), x = w.length > 0 ? w : null, k = h(x ?? []);
|
|
1523
1523
|
k !== u.current && (u.current = k, b(k), m.current?.(k ?? null)), t?.(x);
|
|
@@ -1535,7 +1535,7 @@ const $t = l.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1535
1535
|
gap: "6px",
|
|
1536
1536
|
maxHeight: "200px",
|
|
1537
1537
|
overflowY: "auto"
|
|
1538
|
-
}, children: g.map((w, x) => /* @__PURE__ */
|
|
1538
|
+
}, children: g.map((w, x) => /* @__PURE__ */ z(
|
|
1539
1539
|
"div",
|
|
1540
1540
|
{
|
|
1541
1541
|
style: {
|
|
@@ -1565,7 +1565,7 @@ const $t = l.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1565
1565
|
"button",
|
|
1566
1566
|
{
|
|
1567
1567
|
type: "button",
|
|
1568
|
-
onClick: () =>
|
|
1568
|
+
onClick: () => V(Array.isArray(r) ? x : void 0),
|
|
1569
1569
|
"aria-label": a("Remove file"),
|
|
1570
1570
|
style: {
|
|
1571
1571
|
background: "transparent",
|
|
@@ -1593,14 +1593,14 @@ const $t = l.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1593
1593
|
`${w.name}-${x}`
|
|
1594
1594
|
)) });
|
|
1595
1595
|
}, [I, v] = l.useState(!1);
|
|
1596
|
-
return /* @__PURE__ */ p(
|
|
1597
|
-
/* @__PURE__ */
|
|
1596
|
+
return /* @__PURE__ */ p(L, { field: e, error: f, children: /* @__PURE__ */ z("div", { style: { width: "100%" }, children: [
|
|
1597
|
+
/* @__PURE__ */ z(
|
|
1598
1598
|
"div",
|
|
1599
1599
|
{
|
|
1600
1600
|
className: "reactaform-input",
|
|
1601
1601
|
onDrop: E,
|
|
1602
|
-
onDragOver:
|
|
1603
|
-
onDragLeave:
|
|
1602
|
+
onDragOver: M,
|
|
1603
|
+
onDragLeave: F,
|
|
1604
1604
|
onMouseEnter: () => v(!0),
|
|
1605
1605
|
onMouseLeave: () => v(!1),
|
|
1606
1606
|
style: {
|
|
@@ -1668,7 +1668,7 @@ const $t = l.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1668
1668
|
] }) });
|
|
1669
1669
|
};
|
|
1670
1670
|
Sr.displayName = "FileInput";
|
|
1671
|
-
const
|
|
1671
|
+
const At = l.memo(Sr), Cr = ({
|
|
1672
1672
|
field: e,
|
|
1673
1673
|
value: r,
|
|
1674
1674
|
onChange: t,
|
|
@@ -1681,7 +1681,7 @@ const Vt = l.memo(Sr), Cr = ({
|
|
|
1681
1681
|
onError: n,
|
|
1682
1682
|
validate: a
|
|
1683
1683
|
});
|
|
1684
|
-
return /* @__PURE__ */ p(
|
|
1684
|
+
return /* @__PURE__ */ p(L, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1685
1685
|
"input",
|
|
1686
1686
|
{
|
|
1687
1687
|
id: e.name,
|
|
@@ -1689,7 +1689,7 @@ const Vt = l.memo(Sr), Cr = ({
|
|
|
1689
1689
|
defaultValue: c,
|
|
1690
1690
|
ref: s,
|
|
1691
1691
|
onChange: d,
|
|
1692
|
-
className: U(
|
|
1692
|
+
className: U($.input, $.textInput),
|
|
1693
1693
|
style: { flex: 1 },
|
|
1694
1694
|
"aria-invalid": !!i,
|
|
1695
1695
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
@@ -1697,7 +1697,7 @@ const Vt = l.memo(Sr), Cr = ({
|
|
|
1697
1697
|
) });
|
|
1698
1698
|
};
|
|
1699
1699
|
Cr.displayName = "FloatArrayInput";
|
|
1700
|
-
const
|
|
1700
|
+
const Rt = l.memo(Cr), Nr = ({
|
|
1701
1701
|
field: e,
|
|
1702
1702
|
value: r,
|
|
1703
1703
|
onChange: t,
|
|
@@ -1710,7 +1710,7 @@ const At = l.memo(Cr), Nr = ({
|
|
|
1710
1710
|
onError: n,
|
|
1711
1711
|
validate: a
|
|
1712
1712
|
});
|
|
1713
|
-
return /* @__PURE__ */ p(
|
|
1713
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1714
1714
|
"input",
|
|
1715
1715
|
{
|
|
1716
1716
|
id: e.name,
|
|
@@ -1719,8 +1719,8 @@ const At = l.memo(Cr), Nr = ({
|
|
|
1719
1719
|
defaultValue: String(r ?? ""),
|
|
1720
1720
|
onChange: i,
|
|
1721
1721
|
className: U(
|
|
1722
|
-
|
|
1723
|
-
|
|
1722
|
+
$.input,
|
|
1723
|
+
$.inputNumber
|
|
1724
1724
|
),
|
|
1725
1725
|
"aria-invalid": !!s,
|
|
1726
1726
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
@@ -1728,8 +1728,8 @@ const At = l.memo(Cr), Nr = ({
|
|
|
1728
1728
|
) });
|
|
1729
1729
|
};
|
|
1730
1730
|
Nr.displayName = "FloatInput";
|
|
1731
|
-
const
|
|
1732
|
-
function
|
|
1731
|
+
const Dt = l.memo(Nr);
|
|
1732
|
+
function zt() {
|
|
1733
1733
|
try {
|
|
1734
1734
|
return "/";
|
|
1735
1735
|
} catch {
|
|
@@ -1748,18 +1748,18 @@ const kr = ({ field: e, value: r }) => {
|
|
|
1748
1748
|
right: "flex-end"
|
|
1749
1749
|
}, c = typeof r == "string" ? r : "";
|
|
1750
1750
|
let s = c && c.trim() !== "" ? c : typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
1751
|
-
s && !s.startsWith("/") && (s = `${
|
|
1751
|
+
s && !s.startsWith("/") && (s = `${zt()}${s}`);
|
|
1752
1752
|
const i = e.localized?.split(";").map((h) => h.trim()), [d, m] = l.useState(s || ""), u = l.useRef(s || null);
|
|
1753
1753
|
if (l.useEffect(() => {
|
|
1754
1754
|
if (!s) return;
|
|
1755
1755
|
const h = s.split("/"), y = h.pop(), E = y.lastIndexOf(".");
|
|
1756
1756
|
if (E === -1) return;
|
|
1757
|
-
const
|
|
1758
|
-
let
|
|
1759
|
-
i?.includes(t) && (
|
|
1757
|
+
const M = y.substring(0, E), F = y.substring(E);
|
|
1758
|
+
let V = null;
|
|
1759
|
+
i?.includes(t) && (V = `${M}_${t}${F}`);
|
|
1760
1760
|
const R = new AbortController();
|
|
1761
|
-
if (
|
|
1762
|
-
const I = [...h,
|
|
1761
|
+
if (V) {
|
|
1762
|
+
const I = [...h, V].join("/");
|
|
1763
1763
|
fetch(I, { method: "HEAD", signal: R.signal }).then((v) => {
|
|
1764
1764
|
const g = v.ok ? I : s;
|
|
1765
1765
|
g !== u.current && (u.current = g, m(g));
|
|
@@ -1780,7 +1780,7 @@ const kr = ({ field: e, value: r }) => {
|
|
|
1780
1780
|
boxShadow: "0 2px 6px rgba(0,0,0,0.1)",
|
|
1781
1781
|
margin: "0 0 8px 0"
|
|
1782
1782
|
};
|
|
1783
|
-
return f && b ? (C.width = f, C.height = b, N.width = `${f}px`, N.height = `${b}px`) : f && !b ? (C.width = f, N.width = `${f}px`, N.height = "auto") : !f && b && (C.height = b, N.width = "auto", N.height = `${b}px`), /* @__PURE__ */ p(
|
|
1783
|
+
return f && b ? (C.width = f, C.height = b, N.width = `${f}px`, N.height = `${b}px`) : f && !b ? (C.width = f, N.width = `${f}px`, N.height = "auto") : !f && b && (C.height = b, N.width = "auto", N.height = `${b}px`), /* @__PURE__ */ p(L, { field: e, children: /* @__PURE__ */ p(
|
|
1784
1784
|
"div",
|
|
1785
1785
|
{
|
|
1786
1786
|
"data-testid": "image-wrapper",
|
|
@@ -1802,7 +1802,7 @@ const kr = ({ field: e, value: r }) => {
|
|
|
1802
1802
|
) });
|
|
1803
1803
|
};
|
|
1804
1804
|
kr.displayName = "ImageDisplay";
|
|
1805
|
-
const
|
|
1805
|
+
const Pt = l.memo(kr), Ir = ({
|
|
1806
1806
|
field: e,
|
|
1807
1807
|
value: r,
|
|
1808
1808
|
onChange: t,
|
|
@@ -1815,7 +1815,7 @@ const zt = l.memo(kr), Ir = ({
|
|
|
1815
1815
|
onError: n,
|
|
1816
1816
|
validate: a
|
|
1817
1817
|
});
|
|
1818
|
-
return /* @__PURE__ */ p(
|
|
1818
|
+
return /* @__PURE__ */ p(L, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1819
1819
|
"input",
|
|
1820
1820
|
{
|
|
1821
1821
|
id: e.name,
|
|
@@ -1823,7 +1823,7 @@ const zt = l.memo(kr), Ir = ({
|
|
|
1823
1823
|
defaultValue: c,
|
|
1824
1824
|
ref: s,
|
|
1825
1825
|
onChange: d,
|
|
1826
|
-
className: U(
|
|
1826
|
+
className: U($.input, $.textInput),
|
|
1827
1827
|
style: { flex: 1 },
|
|
1828
1828
|
"aria-invalid": !!i,
|
|
1829
1829
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
@@ -1831,7 +1831,7 @@ const zt = l.memo(kr), Ir = ({
|
|
|
1831
1831
|
) });
|
|
1832
1832
|
};
|
|
1833
1833
|
Ir.displayName = "IntegerArrayInput";
|
|
1834
|
-
const
|
|
1834
|
+
const Ot = l.memo(Ir), Er = ({
|
|
1835
1835
|
field: e,
|
|
1836
1836
|
value: r,
|
|
1837
1837
|
onChange: t,
|
|
@@ -1844,7 +1844,7 @@ const Pt = l.memo(Ir), Er = ({
|
|
|
1844
1844
|
onError: n,
|
|
1845
1845
|
validate: a
|
|
1846
1846
|
});
|
|
1847
|
-
return /* @__PURE__ */ p(
|
|
1847
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1848
1848
|
"input",
|
|
1849
1849
|
{
|
|
1850
1850
|
id: e.name,
|
|
@@ -1852,14 +1852,14 @@ const Pt = l.memo(Ir), Er = ({
|
|
|
1852
1852
|
defaultValue: String(r ?? ""),
|
|
1853
1853
|
ref: c,
|
|
1854
1854
|
onChange: i,
|
|
1855
|
-
className: U(
|
|
1855
|
+
className: U($.input, $.inputNumber),
|
|
1856
1856
|
"aria-invalid": !!s,
|
|
1857
1857
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
1858
1858
|
}
|
|
1859
1859
|
) });
|
|
1860
1860
|
};
|
|
1861
1861
|
Er.displayName = "IntegerInput";
|
|
1862
|
-
const Lt = l.memo(Er),
|
|
1862
|
+
const Lt = l.memo(Er), Fr = ({
|
|
1863
1863
|
field: e,
|
|
1864
1864
|
value: r,
|
|
1865
1865
|
onChange: t,
|
|
@@ -1872,7 +1872,7 @@ const Lt = l.memo(Er), Mr = ({
|
|
|
1872
1872
|
onError: n,
|
|
1873
1873
|
validate: a
|
|
1874
1874
|
});
|
|
1875
|
-
return /* @__PURE__ */ p(
|
|
1875
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1876
1876
|
"textarea",
|
|
1877
1877
|
{
|
|
1878
1878
|
id: e.name,
|
|
@@ -1885,14 +1885,14 @@ const Lt = l.memo(Er), Mr = ({
|
|
|
1885
1885
|
width: "100%",
|
|
1886
1886
|
boxSizing: "border-box"
|
|
1887
1887
|
},
|
|
1888
|
-
className: U(
|
|
1888
|
+
className: U($.input, $.textInput),
|
|
1889
1889
|
"aria-invalid": !!s,
|
|
1890
1890
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
1891
1891
|
}
|
|
1892
1892
|
) });
|
|
1893
1893
|
};
|
|
1894
|
-
|
|
1895
|
-
const
|
|
1894
|
+
Fr.displayName = "MultilineTextInput";
|
|
1895
|
+
const Tt = l.memo(Fr), Mr = ({
|
|
1896
1896
|
field: e,
|
|
1897
1897
|
value: r,
|
|
1898
1898
|
onChange: t,
|
|
@@ -1915,10 +1915,10 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
1915
1915
|
), y = l.useMemo(() => {
|
|
1916
1916
|
const x = Array.isArray(r) ? r : [], k = new Set(h.map((S) => S.value));
|
|
1917
1917
|
return x.filter((S) => k.has(S));
|
|
1918
|
-
}, [r, h]), E = T(e, o), [
|
|
1918
|
+
}, [r, h]), E = T(e, o), [M, F] = l.useState(null), V = l.useRef(null);
|
|
1919
1919
|
l.useEffect(() => {
|
|
1920
1920
|
const x = E(Array.isArray(r) ? r : []);
|
|
1921
|
-
x !==
|
|
1921
|
+
x !== V.current && (V.current = x, F(x), a.current?.(x ?? null));
|
|
1922
1922
|
}, [r, E]);
|
|
1923
1923
|
const R = () => {
|
|
1924
1924
|
if (!u.current) return;
|
|
@@ -1926,7 +1926,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
1926
1926
|
N({ x: x.left, y: x.bottom }), b((k) => !k);
|
|
1927
1927
|
}, I = (x) => {
|
|
1928
1928
|
const k = y.includes(x) ? y.filter((A) => A !== x) : [...y, x], S = E(k);
|
|
1929
|
-
S !==
|
|
1929
|
+
S !== V.current && (V.current = S, F(S), a.current?.(S ?? null)), t?.(k);
|
|
1930
1930
|
}, v = l.useMemo(
|
|
1931
1931
|
() => ({
|
|
1932
1932
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
@@ -1969,8 +1969,8 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
1969
1969
|
}),
|
|
1970
1970
|
[i, d]
|
|
1971
1971
|
);
|
|
1972
|
-
return /* @__PURE__ */
|
|
1973
|
-
/* @__PURE__ */ p(
|
|
1972
|
+
return /* @__PURE__ */ z("div", { children: [
|
|
1973
|
+
/* @__PURE__ */ p(L, { field: e, error: M, children: /* @__PURE__ */ p("div", { style: { width: "100%" }, children: /* @__PURE__ */ z(
|
|
1974
1974
|
"div",
|
|
1975
1975
|
{
|
|
1976
1976
|
ref: u,
|
|
@@ -1980,13 +1980,13 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
1980
1980
|
role: "button",
|
|
1981
1981
|
"aria-haspopup": "listbox",
|
|
1982
1982
|
"aria-expanded": f,
|
|
1983
|
-
"aria-invalid": !!
|
|
1984
|
-
"aria-describedby":
|
|
1983
|
+
"aria-invalid": !!M,
|
|
1984
|
+
"aria-describedby": M ? `${e.name}-error` : void 0,
|
|
1985
1985
|
onKeyDown: (x) => {
|
|
1986
1986
|
(x.key === "Enter" || x.key === " ") && (x.preventDefault(), R());
|
|
1987
1987
|
},
|
|
1988
1988
|
children: [
|
|
1989
|
-
/* @__PURE__ */
|
|
1989
|
+
/* @__PURE__ */ z(
|
|
1990
1990
|
"span",
|
|
1991
1991
|
{
|
|
1992
1992
|
style: { flex: 1, color: "var(--reactaform-text-muted, #888)" },
|
|
@@ -2015,7 +2015,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2015
2015
|
}
|
|
2016
2016
|
) }) }),
|
|
2017
2017
|
f && C && /* @__PURE__ */ p(
|
|
2018
|
-
|
|
2018
|
+
jt,
|
|
2019
2019
|
{
|
|
2020
2020
|
position: C,
|
|
2021
2021
|
options: h,
|
|
@@ -2027,7 +2027,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2027
2027
|
}
|
|
2028
2028
|
)
|
|
2029
2029
|
] });
|
|
2030
|
-
},
|
|
2030
|
+
}, jt = ({
|
|
2031
2031
|
position: e,
|
|
2032
2032
|
options: r,
|
|
2033
2033
|
selectedValues: t,
|
|
@@ -2104,7 +2104,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2104
2104
|
);
|
|
2105
2105
|
I && requestAnimationFrame(() => I.focus());
|
|
2106
2106
|
}, [i]);
|
|
2107
|
-
const h = 250, y = 200, [E,
|
|
2107
|
+
const h = 250, y = 200, [E, M] = l.useState(null), [F, V] = l.useState(null);
|
|
2108
2108
|
if (l.useEffect(() => {
|
|
2109
2109
|
if (typeof window > "u") return;
|
|
2110
2110
|
const I = () => {
|
|
@@ -2114,7 +2114,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2114
2114
|
const A = S.getBoundingClientRect();
|
|
2115
2115
|
w = A.left, x = A.bottom, k = Math.max(80, Math.round(A.width));
|
|
2116
2116
|
}
|
|
2117
|
-
w = Math.min(w, window.innerWidth - k), x = Math.min(x, window.innerHeight - y),
|
|
2117
|
+
w = Math.min(w, window.innerWidth - k), x = Math.min(x, window.innerHeight - y), M({ left: w, top: x }), V(k);
|
|
2118
2118
|
};
|
|
2119
2119
|
I(), window.addEventListener("scroll", I, !0), window.addEventListener("resize", I);
|
|
2120
2120
|
let v = null;
|
|
@@ -2135,7 +2135,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2135
2135
|
position: "fixed",
|
|
2136
2136
|
top: E ? E.top : e.y,
|
|
2137
2137
|
left: E ? E.left : e.x,
|
|
2138
|
-
width:
|
|
2138
|
+
width: F ?? h,
|
|
2139
2139
|
// spread the static popup styles
|
|
2140
2140
|
...C
|
|
2141
2141
|
},
|
|
@@ -2145,7 +2145,7 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2145
2145
|
...N,
|
|
2146
2146
|
background: v === i ? w : N.background
|
|
2147
2147
|
};
|
|
2148
|
-
return /* @__PURE__ */
|
|
2148
|
+
return /* @__PURE__ */ z(
|
|
2149
2149
|
"div",
|
|
2150
2150
|
{
|
|
2151
2151
|
id: `multi-opt-${v}`,
|
|
@@ -2214,8 +2214,8 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2214
2214
|
R
|
|
2215
2215
|
);
|
|
2216
2216
|
};
|
|
2217
|
-
|
|
2218
|
-
const
|
|
2217
|
+
Mr.displayName = "MultiSelect";
|
|
2218
|
+
const Bt = l.memo(Mr), Vr = ({
|
|
2219
2219
|
field: e,
|
|
2220
2220
|
value: r,
|
|
2221
2221
|
onChange: t,
|
|
@@ -2228,7 +2228,7 @@ const jt = l.memo(Fr), $r = ({
|
|
|
2228
2228
|
onError: n,
|
|
2229
2229
|
validate: a
|
|
2230
2230
|
}), d = Math.max(1, Math.round(e.step ?? 1));
|
|
2231
|
-
return /* @__PURE__ */ p(
|
|
2231
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2232
2232
|
"input",
|
|
2233
2233
|
{
|
|
2234
2234
|
id: e.name,
|
|
@@ -2243,14 +2243,14 @@ const jt = l.memo(Fr), $r = ({
|
|
|
2243
2243
|
width: "100%",
|
|
2244
2244
|
height: "100%"
|
|
2245
2245
|
},
|
|
2246
|
-
className:
|
|
2246
|
+
className: $.input,
|
|
2247
2247
|
"aria-invalid": !!s,
|
|
2248
2248
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
2249
2249
|
}
|
|
2250
2250
|
) });
|
|
2251
2251
|
};
|
|
2252
|
-
|
|
2253
|
-
const
|
|
2252
|
+
Vr.displayName = "NumericStepperInput";
|
|
2253
|
+
const Ht = l.memo(Vr), $r = ({
|
|
2254
2254
|
field: e,
|
|
2255
2255
|
value: r,
|
|
2256
2256
|
onChange: t,
|
|
@@ -2263,7 +2263,7 @@ const Bt = l.memo($r), Vr = ({
|
|
|
2263
2263
|
onError: n,
|
|
2264
2264
|
validate: a
|
|
2265
2265
|
});
|
|
2266
|
-
return /* @__PURE__ */ p(
|
|
2266
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2267
2267
|
"input",
|
|
2268
2268
|
{
|
|
2269
2269
|
id: e.name,
|
|
@@ -2271,14 +2271,14 @@ const Bt = l.memo($r), Vr = ({
|
|
|
2271
2271
|
defaultValue: String(r ?? ""),
|
|
2272
2272
|
ref: c,
|
|
2273
2273
|
onChange: i,
|
|
2274
|
-
className: U(
|
|
2274
|
+
className: U($.input, $.textInput),
|
|
2275
2275
|
"aria-invalid": !!s,
|
|
2276
2276
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
2277
2277
|
}
|
|
2278
2278
|
) });
|
|
2279
2279
|
};
|
|
2280
|
-
|
|
2281
|
-
const
|
|
2280
|
+
$r.displayName = "PhoneInput";
|
|
2281
|
+
const qt = l.memo($r), Ar = ({
|
|
2282
2282
|
field: e,
|
|
2283
2283
|
value: r,
|
|
2284
2284
|
onChange: t,
|
|
@@ -2325,21 +2325,21 @@ const Ht = l.memo(Vr), Ar = ({
|
|
|
2325
2325
|
width: s === "column" ? "100%" : void 0,
|
|
2326
2326
|
justifyContent: "flex-start"
|
|
2327
2327
|
};
|
|
2328
|
-
return /* @__PURE__ */ p(
|
|
2328
|
+
return /* @__PURE__ */ p(L, { field: e, error: d, children: /* @__PURE__ */ p(
|
|
2329
2329
|
"div",
|
|
2330
2330
|
{
|
|
2331
|
-
className:
|
|
2331
|
+
className: $.input,
|
|
2332
2332
|
"aria-labelledby": `${e.name}-label`,
|
|
2333
2333
|
"aria-invalid": !!d,
|
|
2334
2334
|
style: C,
|
|
2335
2335
|
children: e.options.map((h) => {
|
|
2336
2336
|
const y = String(h.value), E = `${e.name}-${y}`;
|
|
2337
|
-
return /* @__PURE__ */
|
|
2337
|
+
return /* @__PURE__ */ z(
|
|
2338
2338
|
"label",
|
|
2339
2339
|
{
|
|
2340
|
-
className: U(
|
|
2340
|
+
className: U($.label),
|
|
2341
2341
|
style: N,
|
|
2342
|
-
onMouseDown: (
|
|
2342
|
+
onMouseDown: (M) => M.preventDefault(),
|
|
2343
2343
|
onClick: () => {
|
|
2344
2344
|
String(r ?? "") !== y && b({ target: { value: y } });
|
|
2345
2345
|
},
|
|
@@ -2377,10 +2377,10 @@ const Ht = l.memo(Vr), Ar = ({
|
|
|
2377
2377
|
) });
|
|
2378
2378
|
};
|
|
2379
2379
|
Ar.displayName = "RadioInput";
|
|
2380
|
-
const
|
|
2380
|
+
const Ut = l.memo(Ar), Wt = {
|
|
2381
2381
|
display: "flex",
|
|
2382
2382
|
gap: 4
|
|
2383
|
-
},
|
|
2383
|
+
}, _t = {
|
|
2384
2384
|
cursor: "pointer",
|
|
2385
2385
|
fontSize: "1.5rem",
|
|
2386
2386
|
lineHeight: 1,
|
|
@@ -2418,30 +2418,30 @@ const qt = l.memo(Ar), Ut = {
|
|
|
2418
2418
|
},
|
|
2419
2419
|
[s, C]
|
|
2420
2420
|
);
|
|
2421
|
-
return /* @__PURE__ */ p(
|
|
2421
|
+
return /* @__PURE__ */ p(L, { field: e, error: b, children: /* @__PURE__ */ p(
|
|
2422
2422
|
"div",
|
|
2423
2423
|
{
|
|
2424
2424
|
role: "radiogroup",
|
|
2425
2425
|
"aria-labelledby": `${e.name}-label`,
|
|
2426
2426
|
"aria-invalid": !!b,
|
|
2427
2427
|
"aria-describedby": b ? `${e.name}-error` : void 0,
|
|
2428
|
-
style:
|
|
2428
|
+
style: Wt,
|
|
2429
2429
|
children: Array.from({ length: s }, (h, y) => {
|
|
2430
|
-
const E = y < f,
|
|
2430
|
+
const E = y < f, F = d !== null && y <= d || E ? "gold" : "lightgray";
|
|
2431
2431
|
return /* @__PURE__ */ p(
|
|
2432
2432
|
"span",
|
|
2433
2433
|
{
|
|
2434
|
-
ref: (
|
|
2434
|
+
ref: (V) => u.current[y] = V,
|
|
2435
2435
|
role: "radio",
|
|
2436
2436
|
tabIndex: f > 0 ? y === f - 1 ? 0 : -1 : y === 0 ? 0 : -1,
|
|
2437
2437
|
"aria-checked": E,
|
|
2438
2438
|
"aria-label": `Rating ${y + 1}`,
|
|
2439
2439
|
title: a(`${e.displayName} ${y + 1}`),
|
|
2440
2440
|
onClick: () => C(y + 1),
|
|
2441
|
-
onKeyDown: (
|
|
2441
|
+
onKeyDown: (V) => N(V, y),
|
|
2442
2442
|
onMouseEnter: () => m(y),
|
|
2443
2443
|
onMouseLeave: () => m(null),
|
|
2444
|
-
style: { ...
|
|
2444
|
+
style: { ..._t, color: F },
|
|
2445
2445
|
children: i
|
|
2446
2446
|
},
|
|
2447
2447
|
y
|
|
@@ -2451,7 +2451,7 @@ const qt = l.memo(Ar), Ut = {
|
|
|
2451
2451
|
) });
|
|
2452
2452
|
};
|
|
2453
2453
|
Rr.displayName = "RatingInput";
|
|
2454
|
-
const
|
|
2454
|
+
const Kt = l.memo(Rr), Dr = ({
|
|
2455
2455
|
field: e,
|
|
2456
2456
|
value: r,
|
|
2457
2457
|
onChange: t,
|
|
@@ -2464,7 +2464,7 @@ const _t = l.memo(Rr), Dr = ({
|
|
|
2464
2464
|
onError: n,
|
|
2465
2465
|
validate: c
|
|
2466
2466
|
}), [m, u] = l.useState(!1), f = () => u((b) => !b);
|
|
2467
|
-
return /* @__PURE__ */ p(
|
|
2467
|
+
return /* @__PURE__ */ p(L, { field: e, error: i, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", gap: 8, width: "100%" }, children: [
|
|
2468
2468
|
/* @__PURE__ */ p(
|
|
2469
2469
|
"input",
|
|
2470
2470
|
{
|
|
@@ -2473,7 +2473,7 @@ const _t = l.memo(Rr), Dr = ({
|
|
|
2473
2473
|
defaultValue: String(r ?? ""),
|
|
2474
2474
|
ref: s,
|
|
2475
2475
|
onChange: d,
|
|
2476
|
-
className: U(
|
|
2476
|
+
className: U($.input, $.textInput),
|
|
2477
2477
|
style: { flex: 1, minWidth: 0 },
|
|
2478
2478
|
"aria-invalid": !!i,
|
|
2479
2479
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
@@ -2500,7 +2500,7 @@ const _t = l.memo(Rr), Dr = ({
|
|
|
2500
2500
|
] }) });
|
|
2501
2501
|
};
|
|
2502
2502
|
Dr.displayName = "PasswordInput";
|
|
2503
|
-
const
|
|
2503
|
+
const Gt = l.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
2504
2504
|
const a = T(e, o), c = e.min ?? 0, s = e.max ?? 100, [i, d] = l.useState(
|
|
2505
2505
|
() => isNaN(Number(r)) ? String(c) : String(Number(r))
|
|
2506
2506
|
);
|
|
@@ -2519,7 +2519,7 @@ const Kt = l.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2519
2519
|
},
|
|
2520
2520
|
[t]
|
|
2521
2521
|
), f = isNaN(Number(i)) ? String(c) : String(Number(i));
|
|
2522
|
-
return /* @__PURE__ */ p(
|
|
2522
|
+
return /* @__PURE__ */ p(L, { field: e, error: m, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" }, children: [
|
|
2523
2523
|
/* @__PURE__ */ p(
|
|
2524
2524
|
"input",
|
|
2525
2525
|
{
|
|
@@ -2534,7 +2534,7 @@ const Kt = l.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2534
2534
|
padding: 0,
|
|
2535
2535
|
flex: 1
|
|
2536
2536
|
},
|
|
2537
|
-
className:
|
|
2537
|
+
className: $.rangeInput,
|
|
2538
2538
|
"aria-invalid": !!m,
|
|
2539
2539
|
"aria-describedby": m ? `${e.name}-error` : void 0
|
|
2540
2540
|
}
|
|
@@ -2554,7 +2554,7 @@ const Kt = l.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2554
2554
|
textAlign: "center",
|
|
2555
2555
|
flexShrink: 0
|
|
2556
2556
|
},
|
|
2557
|
-
className: U(
|
|
2557
|
+
className: U($.input, $.textInput),
|
|
2558
2558
|
"aria-invalid": !!m,
|
|
2559
2559
|
"aria-describedby": m ? `${e.name}-error` : void 0
|
|
2560
2560
|
}
|
|
@@ -2562,7 +2562,7 @@ const Kt = l.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2562
2562
|
] }) });
|
|
2563
2563
|
};
|
|
2564
2564
|
zr.displayName = "SliderInput";
|
|
2565
|
-
const
|
|
2565
|
+
const Jt = l.memo(zr), Pr = ({
|
|
2566
2566
|
field: e,
|
|
2567
2567
|
value: r,
|
|
2568
2568
|
onChange: t,
|
|
@@ -2573,10 +2573,10 @@ const Gt = l.memo(zr), Pr = ({
|
|
|
2573
2573
|
l.useEffect(() => {
|
|
2574
2574
|
n?.(d);
|
|
2575
2575
|
}, [d, n]);
|
|
2576
|
-
const m = c, u = s, f = (
|
|
2577
|
-
if (!
|
|
2578
|
-
const R =
|
|
2579
|
-
return (
|
|
2576
|
+
const m = c, u = s, f = (M, F, V) => {
|
|
2577
|
+
if (!F) return {};
|
|
2578
|
+
const R = M?.[F];
|
|
2579
|
+
return (V && R ? R[V] : void 0) ?? {};
|
|
2580
2580
|
}, b = l.useMemo(() => ({
|
|
2581
2581
|
display: "inline-block",
|
|
2582
2582
|
position: "relative",
|
|
@@ -2631,17 +2631,17 @@ const Gt = l.memo(zr), Pr = ({
|
|
|
2631
2631
|
}), [m, u]), y = !!r, E = () => {
|
|
2632
2632
|
t?.(!y);
|
|
2633
2633
|
};
|
|
2634
|
-
return /* @__PURE__ */ p(
|
|
2634
|
+
return /* @__PURE__ */ p(L, { field: e, error: null, rightAlign: !1, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }, children: [
|
|
2635
2635
|
/* @__PURE__ */ p(
|
|
2636
2636
|
"label",
|
|
2637
2637
|
{
|
|
2638
|
-
className:
|
|
2638
|
+
className: $.label,
|
|
2639
2639
|
htmlFor: e.name,
|
|
2640
2640
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
2641
2641
|
children: a(e.displayName)
|
|
2642
2642
|
}
|
|
2643
2643
|
),
|
|
2644
|
-
/* @__PURE__ */
|
|
2644
|
+
/* @__PURE__ */ z("label", { style: b, children: [
|
|
2645
2645
|
/* @__PURE__ */ p(
|
|
2646
2646
|
"input",
|
|
2647
2647
|
{
|
|
@@ -2666,8 +2666,8 @@ const Gt = l.memo(zr), Pr = ({
|
|
|
2666
2666
|
"aria-invalid": !1,
|
|
2667
2667
|
"aria-describedby": void 0,
|
|
2668
2668
|
onClick: E,
|
|
2669
|
-
onKeyDown: (
|
|
2670
|
-
(
|
|
2669
|
+
onKeyDown: (M) => {
|
|
2670
|
+
(M.key === " " || M.key === "Spacebar" || M.key === "Space" || M.key === "Enter") && (M.preventDefault(), E());
|
|
2671
2671
|
},
|
|
2672
2672
|
className: `reactaform-switch ${y ? "active checked on" : ""} `,
|
|
2673
2673
|
style: y ? { ...N, backgroundColor: "var(--reactaform-switch-on-bg, #22c55e)", borderColor: "var(--reactaform-switch-on-border, #16a34a)" } : N,
|
|
@@ -2686,7 +2686,7 @@ const Gt = l.memo(zr), Pr = ({
|
|
|
2686
2686
|
] }) });
|
|
2687
2687
|
};
|
|
2688
2688
|
Pr.displayName = "SwitchInput";
|
|
2689
|
-
const
|
|
2689
|
+
const Yt = l.memo(Pr), xe = ({
|
|
2690
2690
|
field: e,
|
|
2691
2691
|
value: r,
|
|
2692
2692
|
onChange: t,
|
|
@@ -2699,7 +2699,7 @@ const Jt = l.memo(Pr), xe = ({
|
|
|
2699
2699
|
onError: n,
|
|
2700
2700
|
validate: a
|
|
2701
2701
|
});
|
|
2702
|
-
return /* @__PURE__ */ p(
|
|
2702
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2703
2703
|
"input",
|
|
2704
2704
|
{
|
|
2705
2705
|
id: e.name,
|
|
@@ -2707,7 +2707,7 @@ const Jt = l.memo(Pr), xe = ({
|
|
|
2707
2707
|
defaultValue: String(r ?? ""),
|
|
2708
2708
|
ref: c,
|
|
2709
2709
|
onChange: i,
|
|
2710
|
-
className: U(
|
|
2710
|
+
className: U($.input, $.textInput),
|
|
2711
2711
|
placeholder: e.placeholder,
|
|
2712
2712
|
"aria-invalid": !!s,
|
|
2713
2713
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
@@ -2715,7 +2715,7 @@ const Jt = l.memo(Pr), xe = ({
|
|
|
2715
2715
|
) });
|
|
2716
2716
|
};
|
|
2717
2717
|
xe.displayName = "TextInput";
|
|
2718
|
-
const
|
|
2718
|
+
const Or = ({
|
|
2719
2719
|
field: e,
|
|
2720
2720
|
value: r,
|
|
2721
2721
|
onChange: t,
|
|
@@ -2728,7 +2728,7 @@ const Lr = ({
|
|
|
2728
2728
|
onError: n,
|
|
2729
2729
|
validate: a
|
|
2730
2730
|
});
|
|
2731
|
-
return /* @__PURE__ */ p(
|
|
2731
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2732
2732
|
"input",
|
|
2733
2733
|
{
|
|
2734
2734
|
id: e.name,
|
|
@@ -2739,15 +2739,15 @@ const Lr = ({
|
|
|
2739
2739
|
onChange: i,
|
|
2740
2740
|
min: typeof e.min == "string" ? e.min : void 0,
|
|
2741
2741
|
max: typeof e.max == "string" ? e.max : void 0,
|
|
2742
|
-
className: U(
|
|
2742
|
+
className: U($.input, $.textInput),
|
|
2743
2743
|
"aria-invalid": !!s,
|
|
2744
2744
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
2745
2745
|
}
|
|
2746
2746
|
) });
|
|
2747
2747
|
};
|
|
2748
|
-
|
|
2749
|
-
const
|
|
2750
|
-
function
|
|
2748
|
+
Or.displayName = "TimeInput";
|
|
2749
|
+
const Xt = l.memo(Or);
|
|
2750
|
+
function Zt({
|
|
2751
2751
|
pos: e,
|
|
2752
2752
|
options: r,
|
|
2753
2753
|
onClose: t,
|
|
@@ -2826,7 +2826,7 @@ function Xt({
|
|
|
2826
2826
|
i
|
|
2827
2827
|
);
|
|
2828
2828
|
}
|
|
2829
|
-
const
|
|
2829
|
+
const Ve = {
|
|
2830
2830
|
length: ["m", "cm", "mm", "km", "in", "ft", "yd", "mi"],
|
|
2831
2831
|
area: ["m^2", "cm^2", "mm^2", "in^2", "ft^2", "yd^2"],
|
|
2832
2832
|
volume: ["L", "m^3", "cm^3", "mL", "in^3", "ft^3", "yd^3"],
|
|
@@ -2834,7 +2834,7 @@ const $e = {
|
|
|
2834
2834
|
time: ["min", "s", "h", "ms", "d"],
|
|
2835
2835
|
temperature: ["C", "F", "K"],
|
|
2836
2836
|
angle: ["deg", "rad", "rev"]
|
|
2837
|
-
},
|
|
2837
|
+
}, $e = {
|
|
2838
2838
|
length: {
|
|
2839
2839
|
m: "Meter (m)",
|
|
2840
2840
|
mm: "Millimeter (mm)",
|
|
@@ -2943,13 +2943,13 @@ const $e = {
|
|
|
2943
2943
|
rad: Math.PI / 180,
|
|
2944
2944
|
rev: 1 / 360
|
|
2945
2945
|
}
|
|
2946
|
-
}, Re = {},
|
|
2947
|
-
...Object.keys($e),
|
|
2946
|
+
}, Re = {}, Qt = /* @__PURE__ */ new Set([
|
|
2948
2947
|
...Object.keys(Ve),
|
|
2948
|
+
...Object.keys($e),
|
|
2949
2949
|
...Object.keys(Ae)
|
|
2950
2950
|
]);
|
|
2951
|
-
for (const e of
|
|
2952
|
-
const r = {}, t =
|
|
2951
|
+
for (const e of Qt) {
|
|
2952
|
+
const r = {}, t = Ve[e] ?? [], n = $e[e] ?? {}, o = Ae[e] ?? {};
|
|
2953
2953
|
for (const a of t) {
|
|
2954
2954
|
const c = n[a];
|
|
2955
2955
|
r[a] = {
|
|
@@ -2967,7 +2967,7 @@ for (const e of Zt) {
|
|
|
2967
2967
|
r[a] || (r[a] = { name: String(a), shortName: String(a), factor: c });
|
|
2968
2968
|
Re[e] = r;
|
|
2969
2969
|
}
|
|
2970
|
-
function
|
|
2970
|
+
function Lr(e, r, t) {
|
|
2971
2971
|
if (e === "C") {
|
|
2972
2972
|
if (r === "F") return t * (9 / 5) + 32;
|
|
2973
2973
|
if (r === "K") return t + 273.15;
|
|
@@ -2992,11 +2992,11 @@ function Tr(e) {
|
|
|
2992
2992
|
factors: t
|
|
2993
2993
|
};
|
|
2994
2994
|
}
|
|
2995
|
-
const
|
|
2995
|
+
const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2996
2996
|
__proto__: null,
|
|
2997
|
-
convertTemperature:
|
|
2998
|
-
dimensionUnitDisplayMap:
|
|
2999
|
-
dimensionUnitsMap:
|
|
2997
|
+
convertTemperature: Lr,
|
|
2998
|
+
dimensionUnitDisplayMap: $e,
|
|
2999
|
+
dimensionUnitsMap: Ve,
|
|
3000
3000
|
dimensonUnitFactorsMap: Ae,
|
|
3001
3001
|
getUnitFactors: Tr,
|
|
3002
3002
|
unitsByDimension: Re
|
|
@@ -3016,28 +3016,28 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3016
3016
|
if (!Number.isFinite(y)) return;
|
|
3017
3017
|
const E = h.currentTarget.getBoundingClientRect();
|
|
3018
3018
|
m({ x: E.left, y: E.bottom });
|
|
3019
|
-
const
|
|
3019
|
+
const M = [];
|
|
3020
3020
|
if (n === "temperature")
|
|
3021
|
-
o.units.forEach((
|
|
3022
|
-
const R =
|
|
3023
|
-
Number.isFinite(R) &&
|
|
3024
|
-
label: `${R.toFixed(6)} ${c(
|
|
3021
|
+
o.units.forEach((V) => {
|
|
3022
|
+
const R = Lr(t, V, y);
|
|
3023
|
+
Number.isFinite(R) && M.push({
|
|
3024
|
+
label: `${R.toFixed(6)} ${c(V)}`,
|
|
3025
3025
|
value: R.toString(),
|
|
3026
|
-
unit:
|
|
3026
|
+
unit: V
|
|
3027
3027
|
});
|
|
3028
3028
|
});
|
|
3029
3029
|
else {
|
|
3030
|
-
const
|
|
3031
|
-
|
|
3032
|
-
const v = y /
|
|
3033
|
-
Number.isFinite(v) &&
|
|
3030
|
+
const V = o.factors[t];
|
|
3031
|
+
V !== void 0 && Object.entries(o.factors).forEach(([R, I]) => {
|
|
3032
|
+
const v = y / V * I;
|
|
3033
|
+
Number.isFinite(v) && M.push({
|
|
3034
3034
|
label: `${v.toFixed(6)} ${c(R)}`,
|
|
3035
3035
|
value: v.toString(),
|
|
3036
3036
|
unit: R
|
|
3037
3037
|
});
|
|
3038
3038
|
});
|
|
3039
3039
|
}
|
|
3040
|
-
f(
|
|
3040
|
+
f(M), i(M.length > 0);
|
|
3041
3041
|
},
|
|
3042
3042
|
[e, r, t, n, o, c]
|
|
3043
3043
|
), C = l.useCallback(
|
|
@@ -3048,7 +3048,7 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3048
3048
|
), N = l.useCallback(() => {
|
|
3049
3049
|
i(!1), m(null);
|
|
3050
3050
|
}, []);
|
|
3051
|
-
return /* @__PURE__ */
|
|
3051
|
+
return /* @__PURE__ */ z(Ie, { children: [
|
|
3052
3052
|
/* @__PURE__ */ p(
|
|
3053
3053
|
"button",
|
|
3054
3054
|
{
|
|
@@ -3076,7 +3076,7 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3076
3076
|
}
|
|
3077
3077
|
),
|
|
3078
3078
|
s && u.length > 0 && /* @__PURE__ */ p(
|
|
3079
|
-
|
|
3079
|
+
Zt,
|
|
3080
3080
|
{
|
|
3081
3081
|
pos: d,
|
|
3082
3082
|
options: u,
|
|
@@ -3099,29 +3099,29 @@ const Br = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3099
3099
|
n?.(C);
|
|
3100
3100
|
}, [C, n]);
|
|
3101
3101
|
const N = l.useCallback(
|
|
3102
|
-
(
|
|
3103
|
-
const
|
|
3104
|
-
u(
|
|
3102
|
+
(F) => {
|
|
3103
|
+
const V = F.target.value;
|
|
3104
|
+
u(V), a([V, f]), t?.([V, f]);
|
|
3105
3105
|
},
|
|
3106
3106
|
[f, a, t]
|
|
3107
3107
|
), h = l.useCallback(
|
|
3108
|
-
(
|
|
3109
|
-
const
|
|
3110
|
-
b(
|
|
3108
|
+
(F) => {
|
|
3109
|
+
const V = F.target.value;
|
|
3110
|
+
b(V), a([m, V]), t?.([m, V]);
|
|
3111
3111
|
},
|
|
3112
3112
|
[m, a, t]
|
|
3113
3113
|
), y = l.useCallback(
|
|
3114
|
-
(
|
|
3115
|
-
u(
|
|
3114
|
+
(F) => {
|
|
3115
|
+
u(F.value), b(F.unit), t?.([F.value, F.unit]);
|
|
3116
3116
|
},
|
|
3117
3117
|
[t]
|
|
3118
3118
|
), E = l.useMemo(
|
|
3119
|
-
() => s ? s.units.map((
|
|
3119
|
+
() => s ? s.units.map((F) => /* @__PURE__ */ p("option", { value: F, children: o(F) }, F)) : [],
|
|
3120
3120
|
[s, o]
|
|
3121
3121
|
);
|
|
3122
3122
|
if (!c || !s) return null;
|
|
3123
|
-
const
|
|
3124
|
-
return /* @__PURE__ */ p(
|
|
3123
|
+
const M = !!C || !m.trim();
|
|
3124
|
+
return /* @__PURE__ */ p(L, { field: e, error: C, children: /* @__PURE__ */ z("div", { style: { display: "flex", alignItems: "center", gap: "var(--reactaform-unit-gap, 8px)", width: "100%" }, children: [
|
|
3125
3125
|
/* @__PURE__ */ p(
|
|
3126
3126
|
"input",
|
|
3127
3127
|
{
|
|
@@ -3130,7 +3130,7 @@ const Br = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3130
3130
|
value: m,
|
|
3131
3131
|
onChange: N,
|
|
3132
3132
|
style: { flex: "2 1 0" },
|
|
3133
|
-
className: U(
|
|
3133
|
+
className: U($.input, $.textInput),
|
|
3134
3134
|
"aria-invalid": !!C,
|
|
3135
3135
|
"aria-describedby": C ? `${e.name}-error` : void 0
|
|
3136
3136
|
}
|
|
@@ -3142,7 +3142,7 @@ const Br = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3142
3142
|
value: f,
|
|
3143
3143
|
onChange: h,
|
|
3144
3144
|
style: { flex: "1 1 0" },
|
|
3145
|
-
className: U(
|
|
3145
|
+
className: U($.input, $.inputSelect),
|
|
3146
3146
|
"aria-invalid": !!C,
|
|
3147
3147
|
"aria-describedby": C ? `${e.name}-error` : void 0,
|
|
3148
3148
|
children: E
|
|
@@ -3151,7 +3151,7 @@ const Br = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3151
3151
|
/* @__PURE__ */ p(
|
|
3152
3152
|
jr,
|
|
3153
3153
|
{
|
|
3154
|
-
disabled:
|
|
3154
|
+
disabled: M,
|
|
3155
3155
|
inputValue: m,
|
|
3156
3156
|
selectedUnit: f,
|
|
3157
3157
|
dimension: c,
|
|
@@ -3163,7 +3163,7 @@ const Br = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3163
3163
|
] }) });
|
|
3164
3164
|
};
|
|
3165
3165
|
Br.displayName = "UnitValueInput";
|
|
3166
|
-
const
|
|
3166
|
+
const en = l.memo(Br), Hr = ({
|
|
3167
3167
|
field: e,
|
|
3168
3168
|
value: r,
|
|
3169
3169
|
onChange: t,
|
|
@@ -3176,7 +3176,7 @@ const Qt = l.memo(Br), Hr = ({
|
|
|
3176
3176
|
onError: n,
|
|
3177
3177
|
validate: a
|
|
3178
3178
|
});
|
|
3179
|
-
return /* @__PURE__ */ p(
|
|
3179
|
+
return /* @__PURE__ */ p(L, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
3180
3180
|
"input",
|
|
3181
3181
|
{
|
|
3182
3182
|
id: e.name,
|
|
@@ -3184,7 +3184,7 @@ const Qt = l.memo(Br), Hr = ({
|
|
|
3184
3184
|
defaultValue: String(r ?? ""),
|
|
3185
3185
|
ref: c,
|
|
3186
3186
|
onChange: i,
|
|
3187
|
-
className: U(
|
|
3187
|
+
className: U($.input, $.textInput),
|
|
3188
3188
|
placeholder: "https://example.com",
|
|
3189
3189
|
"aria-invalid": !!s,
|
|
3190
3190
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
@@ -3192,20 +3192,20 @@ const Qt = l.memo(Br), Hr = ({
|
|
|
3192
3192
|
) });
|
|
3193
3193
|
};
|
|
3194
3194
|
Hr.displayName = "UrlInput";
|
|
3195
|
-
const
|
|
3196
|
-
function
|
|
3195
|
+
const rn = l.memo(Hr), se = new ne();
|
|
3196
|
+
function po(e, r) {
|
|
3197
3197
|
se.register(e, r);
|
|
3198
3198
|
}
|
|
3199
|
-
function
|
|
3199
|
+
function tn(e) {
|
|
3200
3200
|
return se.get(e);
|
|
3201
3201
|
}
|
|
3202
|
-
function
|
|
3202
|
+
function go(e) {
|
|
3203
3203
|
return se.has(e);
|
|
3204
3204
|
}
|
|
3205
|
-
function
|
|
3205
|
+
function ho(e) {
|
|
3206
3206
|
return se.unregister(e);
|
|
3207
3207
|
}
|
|
3208
|
-
function
|
|
3208
|
+
function bo() {
|
|
3209
3209
|
return se.list();
|
|
3210
3210
|
}
|
|
3211
3211
|
const qr = ({
|
|
@@ -3219,7 +3219,7 @@ const qr = ({
|
|
|
3219
3219
|
console.warn(`Button "${e.name}" has no action defined`);
|
|
3220
3220
|
return;
|
|
3221
3221
|
}
|
|
3222
|
-
const f =
|
|
3222
|
+
const f = tn(e.action);
|
|
3223
3223
|
if (!f) {
|
|
3224
3224
|
const b = `Button handler "${e.action}" not found`;
|
|
3225
3225
|
console.error(b), i(b);
|
|
@@ -3238,11 +3238,11 @@ const qr = ({
|
|
|
3238
3238
|
cursor: a ? "wait" : "pointer",
|
|
3239
3239
|
opacity: a ? 0.6 : 1
|
|
3240
3240
|
} };
|
|
3241
|
-
return e.width && typeof e.width == "number" && e.width > 0 && (u.width = `${e.width}px`), /* @__PURE__ */ p(
|
|
3241
|
+
return e.width && typeof e.width == "number" && e.width > 0 && (u.width = `${e.width}px`), /* @__PURE__ */ p(L, { field: e, rightAlign: !0, error: s, children: /* @__PURE__ */ p(
|
|
3242
3242
|
"button",
|
|
3243
3243
|
{
|
|
3244
3244
|
type: "button",
|
|
3245
|
-
className:
|
|
3245
|
+
className: $.button,
|
|
3246
3246
|
onClick: d,
|
|
3247
3247
|
disabled: a,
|
|
3248
3248
|
"aria-label": o(e.displayName),
|
|
@@ -3253,7 +3253,7 @@ const qr = ({
|
|
|
3253
3253
|
) });
|
|
3254
3254
|
};
|
|
3255
3255
|
qr.displayName = "Button";
|
|
3256
|
-
const
|
|
3256
|
+
const nn = l.memo(qr), on = {
|
|
3257
3257
|
// No debounce
|
|
3258
3258
|
checkbox: !1,
|
|
3259
3259
|
switch: !1,
|
|
@@ -3286,45 +3286,45 @@ const tn = l.memo(qr), nn = {
|
|
|
3286
3286
|
slider: { wait: 100, leading: !0, trailing: !0 },
|
|
3287
3287
|
stepper: { wait: 100, leading: !0, trailing: !0 }
|
|
3288
3288
|
}, me = new ne(), De = {
|
|
3289
|
-
button:
|
|
3290
|
-
checkbox:
|
|
3291
|
-
color:
|
|
3292
|
-
date:
|
|
3293
|
-
description:
|
|
3289
|
+
button: nn,
|
|
3290
|
+
checkbox: xt,
|
|
3291
|
+
color: kt,
|
|
3292
|
+
date: It,
|
|
3293
|
+
description: Et,
|
|
3294
3294
|
dropdown: Mt,
|
|
3295
|
-
email:
|
|
3296
|
-
file:
|
|
3297
|
-
float:
|
|
3298
|
-
"float-array":
|
|
3299
|
-
image:
|
|
3295
|
+
email: Vt,
|
|
3296
|
+
file: At,
|
|
3297
|
+
float: Dt,
|
|
3298
|
+
"float-array": Rt,
|
|
3299
|
+
image: Pt,
|
|
3300
3300
|
int: Lt,
|
|
3301
|
-
"int-array":
|
|
3302
|
-
"multi-selection":
|
|
3303
|
-
multiline:
|
|
3304
|
-
password:
|
|
3305
|
-
phone:
|
|
3306
|
-
radio:
|
|
3307
|
-
rating:
|
|
3301
|
+
"int-array": Ot,
|
|
3302
|
+
"multi-selection": Bt,
|
|
3303
|
+
multiline: Tt,
|
|
3304
|
+
password: Gt,
|
|
3305
|
+
phone: qt,
|
|
3306
|
+
radio: Ut,
|
|
3307
|
+
rating: Kt,
|
|
3308
3308
|
separator: $t,
|
|
3309
|
-
slider:
|
|
3309
|
+
slider: Jt,
|
|
3310
3310
|
string: xe,
|
|
3311
|
-
stepper:
|
|
3312
|
-
switch:
|
|
3311
|
+
stepper: Ht,
|
|
3312
|
+
switch: Yt,
|
|
3313
3313
|
text: xe,
|
|
3314
|
-
time:
|
|
3315
|
-
unit:
|
|
3316
|
-
url:
|
|
3314
|
+
time: Xt,
|
|
3315
|
+
unit: en,
|
|
3316
|
+
url: rn
|
|
3317
3317
|
};
|
|
3318
|
-
function
|
|
3318
|
+
function an(e) {
|
|
3319
3319
|
return e in De;
|
|
3320
3320
|
}
|
|
3321
|
-
function
|
|
3321
|
+
function sn(e, r) {
|
|
3322
3322
|
const { wait: t = 200, leading: n, trailing: o } = r, a = l.memo((c) => {
|
|
3323
3323
|
const s = l.useRef(c.onChange);
|
|
3324
3324
|
l.useEffect(() => {
|
|
3325
3325
|
s.current = c.onChange;
|
|
3326
3326
|
}, [c.onChange]);
|
|
3327
|
-
const { callback: i, cancel: d } =
|
|
3327
|
+
const { callback: i, cancel: d } = ut(
|
|
3328
3328
|
(...m) => {
|
|
3329
3329
|
s.current?.(...m);
|
|
3330
3330
|
},
|
|
@@ -3344,7 +3344,7 @@ function Ur(e, r, t) {
|
|
|
3344
3344
|
console.warn(`Can't overwrite base component type "${e}".`);
|
|
3345
3345
|
return;
|
|
3346
3346
|
}
|
|
3347
|
-
const o =
|
|
3347
|
+
const o = on[e];
|
|
3348
3348
|
if (o === !1) {
|
|
3349
3349
|
me.register(e, n);
|
|
3350
3350
|
return;
|
|
@@ -3352,7 +3352,7 @@ function Ur(e, r, t) {
|
|
|
3352
3352
|
const a = o ?? { wait: 200 };
|
|
3353
3353
|
or ? me.register(e, n) : me.register(
|
|
3354
3354
|
e,
|
|
3355
|
-
|
|
3355
|
+
sn(n, a)
|
|
3356
3356
|
);
|
|
3357
3357
|
}
|
|
3358
3358
|
function Wr(e, r) {
|
|
@@ -3362,7 +3362,7 @@ function _r(e) {
|
|
|
3362
3362
|
return me.get(e);
|
|
3363
3363
|
}
|
|
3364
3364
|
let Ye = !1;
|
|
3365
|
-
function
|
|
3365
|
+
function cn() {
|
|
3366
3366
|
Ye || (Object.entries(De).forEach(([e, r]) => {
|
|
3367
3367
|
Ur(e, r, !0);
|
|
3368
3368
|
}), Ye = !0);
|
|
@@ -3400,8 +3400,8 @@ ze.displayName = "FieldRenderer";
|
|
|
3400
3400
|
const Kr = l.memo(
|
|
3401
3401
|
({ groupName: e, defaultOpen: r = !0, fields: t, valuesMap: n, handleChange: o, handleError: a, errorsMap: c, t: s }) => {
|
|
3402
3402
|
const [i, d] = l.useState(r), m = l.useCallback(() => d((u) => !u), []);
|
|
3403
|
-
return /* @__PURE__ */
|
|
3404
|
-
/* @__PURE__ */
|
|
3403
|
+
return /* @__PURE__ */ z("fieldset", { className: "reactaform-group", children: [
|
|
3404
|
+
/* @__PURE__ */ z("legend", { onClick: m, className: "reactaform-group_legend", children: [
|
|
3405
3405
|
/* @__PURE__ */ p("span", { children: s(e) }),
|
|
3406
3406
|
/* @__PURE__ */ p("span", { className: "reactaform-group_legend_arrow", children: i ? "▼" : "▶" })
|
|
3407
3407
|
] }),
|
|
@@ -3433,12 +3433,12 @@ const Pe = (e, r, t, n) => {
|
|
|
3433
3433
|
const o = Object.values(n.children).flat();
|
|
3434
3434
|
for (const a of o)
|
|
3435
3435
|
typeof a == "string" && a in t && (t[a] = !1, Gr(a, r, t));
|
|
3436
|
-
},
|
|
3436
|
+
}, ln = (e, r, t, n) => {
|
|
3437
3437
|
const o = { ...t };
|
|
3438
3438
|
return e.forEach((a) => {
|
|
3439
3439
|
(!a.parents || Object.keys(a.parents).length === 0) && (o[a.name] = !0, Pe(a.name, n, r, o));
|
|
3440
3440
|
}), o;
|
|
3441
|
-
},
|
|
3441
|
+
}, un = (e, r, t, n, o) => {
|
|
3442
3442
|
const a = { ...e }, c = r[n];
|
|
3443
3443
|
if (Gr(n, r, a), o != null && c?.children) {
|
|
3444
3444
|
const s = String(o), i = c.children[s];
|
|
@@ -3446,8 +3446,32 @@ const Pe = (e, r, t, n) => {
|
|
|
3446
3446
|
for (const d of i)
|
|
3447
3447
|
typeof d == "string" && r[d] && (a[d] = !0, Pe(d, r, t, a));
|
|
3448
3448
|
}
|
|
3449
|
+
for (const [s, i] of Object.entries(r))
|
|
3450
|
+
i.parents && n in i.parents && (a[s] = Jr(s, r, t));
|
|
3449
3451
|
return a;
|
|
3450
|
-
},
|
|
3452
|
+
}, Jr = (e, r, t) => {
|
|
3453
|
+
const n = r[e];
|
|
3454
|
+
if (!n) return !1;
|
|
3455
|
+
if (!n.parents || Object.keys(n.parents).length === 0)
|
|
3456
|
+
return !0;
|
|
3457
|
+
for (const [o, a] of Object.entries(n.parents)) {
|
|
3458
|
+
if (!r[o] || !Jr(o, r, t))
|
|
3459
|
+
continue;
|
|
3460
|
+
const s = t[o];
|
|
3461
|
+
if (s == null)
|
|
3462
|
+
continue;
|
|
3463
|
+
const i = a.map((d) => String(d));
|
|
3464
|
+
if (Array.isArray(s)) {
|
|
3465
|
+
if (s.map((u) => String(u)).some((u) => i.includes(u)))
|
|
3466
|
+
return !0;
|
|
3467
|
+
} else {
|
|
3468
|
+
const d = String(s);
|
|
3469
|
+
if (i.includes(d))
|
|
3470
|
+
return !0;
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
return !1;
|
|
3474
|
+
}, mn = (e, r) => {
|
|
3451
3475
|
const t = /* @__PURE__ */ new Map();
|
|
3452
3476
|
let n = null, o = null, a = 0;
|
|
3453
3477
|
for (const c of e) {
|
|
@@ -3469,7 +3493,7 @@ const Pe = (e, r, t, n) => {
|
|
|
3469
3493
|
}
|
|
3470
3494
|
}
|
|
3471
3495
|
return a;
|
|
3472
|
-
},
|
|
3496
|
+
}, dn = (e, r = {}) => {
|
|
3473
3497
|
const { includeEmpty: t = !0 } = r, n = [];
|
|
3474
3498
|
let o = null, a = [], c = 0;
|
|
3475
3499
|
for (const i of e) {
|
|
@@ -3486,17 +3510,17 @@ const Pe = (e, r, t, n) => {
|
|
|
3486
3510
|
largestGroup: s
|
|
3487
3511
|
}
|
|
3488
3512
|
};
|
|
3489
|
-
},
|
|
3490
|
-
function
|
|
3491
|
-
|
|
3492
|
-
}
|
|
3493
|
-
function dn(e) {
|
|
3494
|
-
return Le.get(e);
|
|
3513
|
+
}, Oe = new ne();
|
|
3514
|
+
function Yr(e, r) {
|
|
3515
|
+
Oe.register(e, r);
|
|
3495
3516
|
}
|
|
3496
3517
|
function fn(e) {
|
|
3497
|
-
return
|
|
3518
|
+
return Oe.get(e);
|
|
3498
3519
|
}
|
|
3499
|
-
|
|
3520
|
+
function pn(e) {
|
|
3521
|
+
return Oe.get(e);
|
|
3522
|
+
}
|
|
3523
|
+
Yr(
|
|
3500
3524
|
"Preset_AlertSubmitHandler",
|
|
3501
3525
|
(e, r, t) => {
|
|
3502
3526
|
const n = {
|
|
@@ -3508,7 +3532,7 @@ Jr(
|
|
|
3508
3532
|
alert(o);
|
|
3509
3533
|
}
|
|
3510
3534
|
);
|
|
3511
|
-
async function
|
|
3535
|
+
async function gn(e, r, t, n, o, a, c) {
|
|
3512
3536
|
const s = o ? Object.values(o).filter(Boolean) : [];
|
|
3513
3537
|
if (s.length > 0)
|
|
3514
3538
|
return {
|
|
@@ -3543,12 +3567,12 @@ async function pn(e, r, t, n, o, a, c) {
|
|
|
3543
3567
|
const N = String(b).split(",").map((E) => E.trim()).filter(Boolean), h = [];
|
|
3544
3568
|
let y = !1;
|
|
3545
3569
|
for (const E of N) {
|
|
3546
|
-
const
|
|
3547
|
-
if (isNaN(
|
|
3570
|
+
const M = Number(E);
|
|
3571
|
+
if (isNaN(M)) {
|
|
3548
3572
|
d.push(n("Invalid number {{1}} in array for field {{2}}", E, u.displayName || f)), y = !0;
|
|
3549
3573
|
break;
|
|
3550
3574
|
}
|
|
3551
|
-
h.push(
|
|
3575
|
+
h.push(M);
|
|
3552
3576
|
}
|
|
3553
3577
|
y || (i[f] = h);
|
|
3554
3578
|
}
|
|
@@ -3571,7 +3595,7 @@ async function pn(e, r, t, n, o, a, c) {
|
|
|
3571
3595
|
errors: u
|
|
3572
3596
|
};
|
|
3573
3597
|
} else {
|
|
3574
|
-
const u = await
|
|
3598
|
+
const u = await vt(e, i, n);
|
|
3575
3599
|
if (u && u.length > 0)
|
|
3576
3600
|
return {
|
|
3577
3601
|
success: !1,
|
|
@@ -3597,7 +3621,7 @@ async function pn(e, r, t, n, o, a, c) {
|
|
|
3597
3621
|
};
|
|
3598
3622
|
}
|
|
3599
3623
|
else if (e && typeof e.submitHandlerName == "string") {
|
|
3600
|
-
const u =
|
|
3624
|
+
const u = fn(e.submitHandlerName);
|
|
3601
3625
|
if (u)
|
|
3602
3626
|
try {
|
|
3603
3627
|
const f = await u(e, r?.name ?? null, i, n), b = m(f);
|
|
@@ -3621,12 +3645,12 @@ async function pn(e, r, t, n, o, a, c) {
|
|
|
3621
3645
|
data: i
|
|
3622
3646
|
};
|
|
3623
3647
|
}
|
|
3624
|
-
const
|
|
3648
|
+
const Xr = ({
|
|
3625
3649
|
message: e,
|
|
3626
3650
|
success: r,
|
|
3627
3651
|
onDismiss: t,
|
|
3628
3652
|
t: n
|
|
3629
|
-
}) => e ? /* @__PURE__ */
|
|
3653
|
+
}) => e ? /* @__PURE__ */ z(
|
|
3630
3654
|
"div",
|
|
3631
3655
|
{
|
|
3632
3656
|
role: "status",
|
|
@@ -3663,8 +3687,8 @@ const Yr = ({
|
|
|
3663
3687
|
]
|
|
3664
3688
|
}
|
|
3665
3689
|
) : null;
|
|
3666
|
-
|
|
3667
|
-
const
|
|
3690
|
+
Xr.displayName = "SubmissionMessage";
|
|
3691
|
+
const hn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
3668
3692
|
const [n, o] = l.useState(!1);
|
|
3669
3693
|
return /* @__PURE__ */ p(
|
|
3670
3694
|
"button",
|
|
@@ -3690,7 +3714,7 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3690
3714
|
children: t("Submit")
|
|
3691
3715
|
}
|
|
3692
3716
|
);
|
|
3693
|
-
},
|
|
3717
|
+
}, bn = ({
|
|
3694
3718
|
definition: e,
|
|
3695
3719
|
instance: r,
|
|
3696
3720
|
onSubmit: t = void 0,
|
|
@@ -3701,120 +3725,122 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3701
3725
|
const { properties: c, displayName: s } = e, i = B(), { t: d, formStyle: m, language: u, displayInstanceName: f } = i, b = {
|
|
3702
3726
|
...i,
|
|
3703
3727
|
definitionName: e?.name ?? i.definitionName
|
|
3704
|
-
}, [C, N] = l.useState("en"), [h, y] = l.useState([]), [E,
|
|
3728
|
+
}, [C, N] = l.useState("en"), [h, y] = l.useState([]), [E, M] = l.useState({}), [F, V] = l.useState(
|
|
3705
3729
|
{}
|
|
3706
|
-
), [R, I] = l.useState({}), [v, g] = l.useState({}), [w, x] = l.useState(null), [k, S] = l.useState(null), [A, j] = l.useState(0), [K, ce] = l.useState(!1), [je, oe] = l.useState(r.name || ""),
|
|
3730
|
+
), [R, I] = l.useState({}), [v, g] = l.useState({}), [w, x] = l.useState(null), [k, S] = l.useState(null), [A, j] = l.useState(0), [K, ce] = l.useState(!1), [je, oe] = l.useState(r.name || ""), X = l.useRef(r), fe = l.useRef(!1);
|
|
3707
3731
|
l.useEffect(() => {
|
|
3708
|
-
const
|
|
3709
|
-
c.map((
|
|
3710
|
-
|
|
3711
|
-
{ ...
|
|
3732
|
+
const P = Object.fromEntries(
|
|
3733
|
+
c.map((D) => [
|
|
3734
|
+
D.name,
|
|
3735
|
+
{ ...D, children: {} }
|
|
3712
3736
|
])
|
|
3713
3737
|
);
|
|
3714
|
-
c.forEach((
|
|
3715
|
-
|
|
3716
|
-
const
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
const qe = String(
|
|
3720
|
-
|
|
3721
|
-
...
|
|
3722
|
-
|
|
3738
|
+
c.forEach((D) => {
|
|
3739
|
+
D.parents && Object.entries(D.parents).forEach(([J, re]) => {
|
|
3740
|
+
const Z = P[J];
|
|
3741
|
+
Z && re.forEach((it) => {
|
|
3742
|
+
Z.children || (Z.children = {});
|
|
3743
|
+
const qe = String(it);
|
|
3744
|
+
Z.children[qe] = [
|
|
3745
|
+
...Z.children[qe] || [],
|
|
3746
|
+
D.name
|
|
3723
3747
|
];
|
|
3724
3748
|
});
|
|
3725
3749
|
});
|
|
3726
|
-
}),
|
|
3750
|
+
}), mn(c, P);
|
|
3727
3751
|
const q = Object.values(
|
|
3728
|
-
|
|
3729
|
-
),
|
|
3730
|
-
q.forEach((
|
|
3731
|
-
if (
|
|
3732
|
-
const
|
|
3733
|
-
|
|
3752
|
+
P
|
|
3753
|
+
), O = {};
|
|
3754
|
+
q.forEach((D) => {
|
|
3755
|
+
if (D.type === "unit") {
|
|
3756
|
+
const J = typeof D.defaultValue == "number" ? String(D.defaultValue) : "", re = typeof D.defaultUnit == "string" ? D.defaultUnit : String(D.defaultUnit ?? "m");
|
|
3757
|
+
O[D.name] = [J, re];
|
|
3734
3758
|
} else
|
|
3735
|
-
|
|
3736
|
-
}),
|
|
3737
|
-
|
|
3759
|
+
O[D.name] = D.defaultValue;
|
|
3760
|
+
}), X.current = r, Object.keys(r.values).forEach((D) => {
|
|
3761
|
+
P[D] !== void 0 && (O[D] = r.values[D]);
|
|
3738
3762
|
});
|
|
3739
|
-
const
|
|
3740
|
-
y(q),
|
|
3741
|
-
|
|
3763
|
+
const Y = Object.fromEntries(q.map((D) => [D.name, !1])), G = requestAnimationFrame(() => {
|
|
3764
|
+
y(q), M(P), V(O), I(
|
|
3765
|
+
ln(q, O, Y, P)
|
|
3742
3766
|
), ce(!0), oe(r.name);
|
|
3743
3767
|
});
|
|
3744
3768
|
return () => cancelAnimationFrame(G);
|
|
3745
3769
|
}, [c, r, e]), l.useEffect(() => {
|
|
3746
3770
|
if (!K || A >= h.length) return;
|
|
3747
|
-
const
|
|
3771
|
+
const P = setTimeout(() => {
|
|
3748
3772
|
j(
|
|
3749
3773
|
(q) => Math.min(q + o, h.length)
|
|
3750
3774
|
);
|
|
3751
3775
|
}, a);
|
|
3752
|
-
return () => clearTimeout(
|
|
3776
|
+
return () => clearTimeout(P);
|
|
3753
3777
|
}, [K, A, h.length, o, a]);
|
|
3754
3778
|
const Be = l.useCallback(
|
|
3755
|
-
(
|
|
3756
|
-
x(null), S(null),
|
|
3757
|
-
const
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3779
|
+
(P, q) => {
|
|
3780
|
+
x(null), S(null), V((D) => ({ ...D, [P]: q }));
|
|
3781
|
+
const O = E[P], Y = O && O.children && Object.keys(O.children).length > 0, G = Object.values(E).some(
|
|
3782
|
+
(D) => D.parents && P in D.parents
|
|
3783
|
+
);
|
|
3784
|
+
(Y || G) && I((D) => {
|
|
3785
|
+
const J = { ...F, [P]: q };
|
|
3786
|
+
return un(
|
|
3787
|
+
D,
|
|
3762
3788
|
E,
|
|
3763
|
-
|
|
3764
|
-
|
|
3789
|
+
J,
|
|
3790
|
+
P,
|
|
3765
3791
|
q
|
|
3766
3792
|
);
|
|
3767
3793
|
});
|
|
3768
3794
|
},
|
|
3769
|
-
[E,
|
|
3795
|
+
[E, F]
|
|
3770
3796
|
);
|
|
3771
3797
|
l.useEffect(() => {
|
|
3772
|
-
let
|
|
3773
|
-
return
|
|
3798
|
+
let P = 0;
|
|
3799
|
+
return P = requestAnimationFrame(() => {
|
|
3774
3800
|
u !== C && (N(u || "en"), x(null), S(null));
|
|
3775
|
-
}), () => cancelAnimationFrame(
|
|
3801
|
+
}), () => cancelAnimationFrame(P);
|
|
3776
3802
|
}, [u, C]), l.useEffect(() => {
|
|
3777
|
-
let
|
|
3778
|
-
return
|
|
3803
|
+
let P = 0;
|
|
3804
|
+
return P = requestAnimationFrame(() => {
|
|
3779
3805
|
if (fe.current) {
|
|
3780
|
-
fe.current = !1,
|
|
3806
|
+
fe.current = !1, X.current = r, oe(r.name || "");
|
|
3781
3807
|
return;
|
|
3782
3808
|
}
|
|
3783
|
-
|
|
3784
|
-
}), () => cancelAnimationFrame(
|
|
3809
|
+
X.current = r, x(null), S(null), oe(r.name || "");
|
|
3810
|
+
}), () => cancelAnimationFrame(P);
|
|
3785
3811
|
}, [r, r.name]);
|
|
3786
|
-
const He = l.useCallback((
|
|
3787
|
-
g((
|
|
3788
|
-
}, []),
|
|
3812
|
+
const He = l.useCallback((P, q) => {
|
|
3813
|
+
g((O) => q ? { ...O, [P]: String(q) } : Object.fromEntries(Object.entries(O).filter(([G]) => G !== P)));
|
|
3814
|
+
}, []), ot = async () => {
|
|
3789
3815
|
fe.current = !0;
|
|
3790
|
-
const
|
|
3791
|
-
|
|
3816
|
+
const P = X.current?.name;
|
|
3817
|
+
X.current.name = je;
|
|
3792
3818
|
let q = v;
|
|
3793
3819
|
if (b.fieldValidationMode === "onSubmission") {
|
|
3794
|
-
const
|
|
3795
|
-
if (h.forEach((
|
|
3796
|
-
const re =
|
|
3820
|
+
const D = {};
|
|
3821
|
+
if (h.forEach((J) => {
|
|
3822
|
+
const re = F[J.name];
|
|
3797
3823
|
if (re === void 0) return;
|
|
3798
|
-
const
|
|
3799
|
-
|
|
3800
|
-
}), g(
|
|
3824
|
+
const Z = pr(b.definitionName, J, re, d);
|
|
3825
|
+
Z && (D[J.name] = Z);
|
|
3826
|
+
}), g(D), q = D, Object.keys(D).length > 0) {
|
|
3801
3827
|
x(d("Please fix validation errors before submitting the form.")), S(!1);
|
|
3802
3828
|
return;
|
|
3803
3829
|
} else
|
|
3804
3830
|
x(null), S(null);
|
|
3805
3831
|
}
|
|
3806
|
-
const
|
|
3832
|
+
const O = await gn(e, X.current, F, d, q, t, n), Y = typeof O.message == "string" ? O.message : String(O.message), G = Object.values(O.errors ?? {}).join(`
|
|
3807
3833
|
`);
|
|
3808
|
-
x(G ?
|
|
3809
|
-
` + G :
|
|
3810
|
-
},
|
|
3834
|
+
x(G ? Y + `
|
|
3835
|
+
` + G : Y), S(O.success), O.success || (X.current.name = P ?? X.current.name, oe(P ?? ""));
|
|
3836
|
+
}, at = l.useMemo(
|
|
3811
3837
|
() => b.fieldValidationMode === "onEdit" || b.fieldValidationMode === "realTime" ? Object.values(v).some(Boolean) : !1,
|
|
3812
3838
|
[v, b.fieldValidationMode]
|
|
3813
3839
|
);
|
|
3814
|
-
return /* @__PURE__ */ p(Ee.Provider, { value: b, children: /* @__PURE__ */
|
|
3840
|
+
return /* @__PURE__ */ p(Ee.Provider, { value: b, children: /* @__PURE__ */ z("div", { style: m.container, children: [
|
|
3815
3841
|
s && /* @__PURE__ */ p("h2", { style: m.titleStyle, children: d(s) }),
|
|
3816
3842
|
/* @__PURE__ */ p(
|
|
3817
|
-
|
|
3843
|
+
Xr,
|
|
3818
3844
|
{
|
|
3819
3845
|
message: w,
|
|
3820
3846
|
success: k,
|
|
@@ -3828,38 +3854,38 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3828
3854
|
sr,
|
|
3829
3855
|
{
|
|
3830
3856
|
name: je,
|
|
3831
|
-
onChange: (
|
|
3832
|
-
oe(
|
|
3857
|
+
onChange: (P) => {
|
|
3858
|
+
oe(P), x(null), S(null);
|
|
3833
3859
|
}
|
|
3834
3860
|
}
|
|
3835
3861
|
),
|
|
3836
|
-
/* @__PURE__ */
|
|
3862
|
+
/* @__PURE__ */ z(Ie, { children: [
|
|
3837
3863
|
(() => {
|
|
3838
|
-
const
|
|
3839
|
-
return q.map((
|
|
3864
|
+
const P = h.slice(0, A).filter((O) => R[O.name]), { groups: q } = dn(P);
|
|
3865
|
+
return q.map((O, Y) => O.name ? /* @__PURE__ */ p(
|
|
3840
3866
|
Kr,
|
|
3841
3867
|
{
|
|
3842
|
-
groupName:
|
|
3868
|
+
groupName: O.name,
|
|
3843
3869
|
defaultOpen: !0,
|
|
3844
|
-
fields:
|
|
3845
|
-
valuesMap:
|
|
3870
|
+
fields: O.fields,
|
|
3871
|
+
valuesMap: F,
|
|
3846
3872
|
handleChange: Be,
|
|
3847
3873
|
handleError: He,
|
|
3848
3874
|
errorsMap: v,
|
|
3849
3875
|
t: d
|
|
3850
3876
|
},
|
|
3851
|
-
|
|
3852
|
-
) : /* @__PURE__ */ p(l.Fragment, { children:
|
|
3877
|
+
O.name
|
|
3878
|
+
) : /* @__PURE__ */ p(l.Fragment, { children: O.fields.map((G) => /* @__PURE__ */ p(
|
|
3853
3879
|
ze,
|
|
3854
3880
|
{
|
|
3855
3881
|
field: G,
|
|
3856
|
-
valuesMap:
|
|
3882
|
+
valuesMap: F,
|
|
3857
3883
|
handleChange: Be,
|
|
3858
3884
|
handleError: He,
|
|
3859
3885
|
errorsMap: v
|
|
3860
3886
|
},
|
|
3861
3887
|
G.name
|
|
3862
|
-
)) }, `ungrouped-${
|
|
3888
|
+
)) }, `ungrouped-${Y}`));
|
|
3863
3889
|
})(),
|
|
3864
3890
|
A < h.length && /* @__PURE__ */ p(
|
|
3865
3891
|
"div",
|
|
@@ -3872,9 +3898,9 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3872
3898
|
}
|
|
3873
3899
|
)
|
|
3874
3900
|
] }),
|
|
3875
|
-
/* @__PURE__ */ p(
|
|
3901
|
+
/* @__PURE__ */ p(hn, { onClick: ot, disabled: at, t: d })
|
|
3876
3902
|
] }) });
|
|
3877
|
-
},
|
|
3903
|
+
}, Zr = {
|
|
3878
3904
|
en: { name: "English", nativeName: "English" },
|
|
3879
3905
|
fr: { name: "French", nativeName: "Français" },
|
|
3880
3906
|
de: { name: "German", nativeName: "Deutsch" },
|
|
@@ -3905,13 +3931,13 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3905
3931
|
uk: { name: "Ukrainian", nativeName: "Українська" },
|
|
3906
3932
|
vi: { name: "Vietnamese", nativeName: "Tiếng Việt" },
|
|
3907
3933
|
"zh-tw": { name: "Chinese (Traditional)", nativeName: "繁體中文" }
|
|
3908
|
-
},
|
|
3934
|
+
}, yo = () => Zr, be = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set(), we = /* @__PURE__ */ new Map(), yn = async (e) => {
|
|
3909
3935
|
try {
|
|
3910
3936
|
let r = {};
|
|
3911
3937
|
const t = e.toLowerCase();
|
|
3912
3938
|
if (t === "en")
|
|
3913
3939
|
r = {};
|
|
3914
|
-
else if (
|
|
3940
|
+
else if (Zr[t]) {
|
|
3915
3941
|
const o = `https://reactaform.com/locales/${t}/common.json`, a = await fetch(o);
|
|
3916
3942
|
a.ok && (r = await a.json());
|
|
3917
3943
|
} else
|
|
@@ -3928,7 +3954,7 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3928
3954
|
error: `Failed to load common translations for ${e}: ${r}`
|
|
3929
3955
|
};
|
|
3930
3956
|
}
|
|
3931
|
-
},
|
|
3957
|
+
}, vn = async (e) => {
|
|
3932
3958
|
if (!e || e.toLowerCase() === "en")
|
|
3933
3959
|
return { success: !0, translations: {}, fromCache: !1 };
|
|
3934
3960
|
const r = e.toLowerCase();
|
|
@@ -3938,13 +3964,13 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3938
3964
|
translations: be.get(r) || {},
|
|
3939
3965
|
fromCache: !0
|
|
3940
3966
|
};
|
|
3941
|
-
const t = await
|
|
3967
|
+
const t = await yn(r);
|
|
3942
3968
|
return t.success && (be.set(r, t.translations), we.set(r, {
|
|
3943
3969
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
3944
3970
|
size: Object.keys(t.translations).length,
|
|
3945
3971
|
source: "common"
|
|
3946
3972
|
})), t;
|
|
3947
|
-
},
|
|
3973
|
+
}, xn = async (e, r) => {
|
|
3948
3974
|
if (!e || !r)
|
|
3949
3975
|
return {
|
|
3950
3976
|
success: !1,
|
|
@@ -3985,7 +4011,7 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3985
4011
|
fromCache: !1
|
|
3986
4012
|
});
|
|
3987
4013
|
const a = o.headers.get("content-type") || "";
|
|
3988
|
-
!a.includes("application/json") && !a.includes("text/json") &&
|
|
4014
|
+
!a.includes("application/json") && !a.includes("text/json") && Qr() && console.warn(
|
|
3989
4015
|
`Translation file at ${n} has unexpected content-type: ${a}`
|
|
3990
4016
|
);
|
|
3991
4017
|
const c = await o.text();
|
|
@@ -4032,7 +4058,7 @@ const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
4032
4058
|
};
|
|
4033
4059
|
}
|
|
4034
4060
|
};
|
|
4035
|
-
function
|
|
4061
|
+
function Qr() {
|
|
4036
4062
|
try {
|
|
4037
4063
|
if (typeof process < "u" && process?.env?.NODE_ENV === "development")
|
|
4038
4064
|
return !0;
|
|
@@ -4040,30 +4066,30 @@ function Zr() {
|
|
|
4040
4066
|
}
|
|
4041
4067
|
return !1;
|
|
4042
4068
|
}
|
|
4043
|
-
function
|
|
4069
|
+
function wn(e, r) {
|
|
4044
4070
|
return r.length === 0 ? e : e.replace(/\{\{(\d+)\}\}/g, (t, n) => {
|
|
4045
4071
|
const o = parseInt(n, 10) - 1, a = r[o];
|
|
4046
4072
|
return a == null ? t : String(a);
|
|
4047
4073
|
});
|
|
4048
4074
|
}
|
|
4049
|
-
const
|
|
4075
|
+
const Sn = (e, r, t) => (n, ...o) => {
|
|
4050
4076
|
let a = n, c = !1;
|
|
4051
|
-
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (a = n, c = !0) : n in t ? (a = t[n], c = !0) : n in r ? (a = r[n], c = !0) : a = n, a =
|
|
4077
|
+
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (a = n, c = !0) : n in t ? (a = t[n], c = !0) : n in r ? (a = r[n], c = !0) : a = n, a = wn(a, o), !c && Qr() && console.debug(
|
|
4052
4078
|
`Missing translation for "${n}" in language "${e}"`
|
|
4053
4079
|
), a);
|
|
4054
4080
|
};
|
|
4055
|
-
function
|
|
4081
|
+
function Cn(e) {
|
|
4056
4082
|
return /^[-+]?\d*$/.test(e);
|
|
4057
4083
|
}
|
|
4058
|
-
function
|
|
4084
|
+
function Nn(e) {
|
|
4059
4085
|
const r = /^[-+]?\d*$/;
|
|
4060
4086
|
return e.split(",").map((t) => t.trim()).every((t) => r.test(t));
|
|
4061
4087
|
}
|
|
4062
|
-
const
|
|
4088
|
+
const kn = ",", In = (e) => !e || e.trim() === "" ? [] : e.split(kn).map((r) => r.trim()).filter(Boolean).map((r) => Number(r)), Xe = (e, r, t) => {
|
|
4063
4089
|
const n = String(r);
|
|
4064
4090
|
if (n.trim() === "")
|
|
4065
4091
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
4066
|
-
if (!
|
|
4092
|
+
if (!Cn(n))
|
|
4067
4093
|
return t("Must be a valid integer");
|
|
4068
4094
|
const o = parseInt(n, 10);
|
|
4069
4095
|
if (Number.isNaN(o)) return t("Must be a valid integer");
|
|
@@ -4087,13 +4113,13 @@ const Nn = ",", kn = (e) => !e || e.trim() === "" ? [] : e.split(Nn).map((r) =>
|
|
|
4087
4113
|
return t("Must be a multiple of {{1}}", a);
|
|
4088
4114
|
}
|
|
4089
4115
|
};
|
|
4090
|
-
function
|
|
4116
|
+
function En(e, r, t) {
|
|
4091
4117
|
const n = String(r);
|
|
4092
4118
|
if (n.trim() === "")
|
|
4093
4119
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
4094
|
-
if (!
|
|
4120
|
+
if (!Nn(n))
|
|
4095
4121
|
return t("Each value must be a valid integer");
|
|
4096
|
-
const o =
|
|
4122
|
+
const o = In(n);
|
|
4097
4123
|
if (e.minCount !== void 0 && o.length < e.minCount)
|
|
4098
4124
|
return t("Minimum number of values: {{1}}", `${e.minCount}`);
|
|
4099
4125
|
if (e.maxCount !== void 0 && o.length > e.maxCount)
|
|
@@ -4113,7 +4139,7 @@ function In(e, r, t) {
|
|
|
4113
4139
|
);
|
|
4114
4140
|
}
|
|
4115
4141
|
}
|
|
4116
|
-
function
|
|
4142
|
+
function et(e, r, t) {
|
|
4117
4143
|
const n = String(r);
|
|
4118
4144
|
if (n.trim() === "")
|
|
4119
4145
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
@@ -4138,12 +4164,12 @@ function Qr(e, r, t) {
|
|
|
4138
4164
|
);
|
|
4139
4165
|
}
|
|
4140
4166
|
}
|
|
4141
|
-
const
|
|
4167
|
+
const Fn = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
4142
4168
|
function Mn(e) {
|
|
4143
|
-
return e.split(",").map((r) => r.trim()).every((r) =>
|
|
4169
|
+
return e.split(",").map((r) => r.trim()).every((r) => Fn.test(r));
|
|
4144
4170
|
}
|
|
4145
|
-
const
|
|
4146
|
-
function
|
|
4171
|
+
const Vn = ",", $n = (e) => !e || e.trim() === "" ? [] : e.split(Vn).map((r) => r.trim()).filter(Boolean).map((r) => Number(r));
|
|
4172
|
+
function An(e, r, t) {
|
|
4147
4173
|
const n = String(r);
|
|
4148
4174
|
if (n.trim() === "")
|
|
4149
4175
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
@@ -4170,7 +4196,7 @@ function Vn(e, r, t) {
|
|
|
4170
4196
|
}
|
|
4171
4197
|
}
|
|
4172
4198
|
const ye = /* @__PURE__ */ new WeakMap();
|
|
4173
|
-
function
|
|
4199
|
+
function Le(e, r, t, n, ...o) {
|
|
4174
4200
|
if (e.pattern == null)
|
|
4175
4201
|
return;
|
|
4176
4202
|
const a = String(r);
|
|
@@ -4195,32 +4221,32 @@ function ue(e, r, t) {
|
|
|
4195
4221
|
if (n === "")
|
|
4196
4222
|
return e.minLength !== void 0 || e.maxLength !== void 0 ? e.required ? t("Value required when minLength or maxLength is set") : void 0 : e.required ? t("Value required") : void 0;
|
|
4197
4223
|
const o = Math.max(e.minLength ?? 0, 0);
|
|
4198
|
-
return n.length < o ? t("Must be at least {{1}} characters", o) : e.maxLength !== void 0 && n.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) :
|
|
4224
|
+
return n.length < o ? t("Must be at least {{1}} characters", o) : e.maxLength !== void 0 && n.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) : Le(e, r, t, "Invalid text format");
|
|
4199
4225
|
}
|
|
4200
4226
|
const Se = (e) => {
|
|
4201
4227
|
if (!e) return null;
|
|
4202
4228
|
const r = Date.parse(e);
|
|
4203
4229
|
return Number.isNaN(r) ? null : r;
|
|
4204
|
-
}, Ze = /* @__PURE__ */ new WeakMap(),
|
|
4230
|
+
}, Ze = /* @__PURE__ */ new WeakMap(), Rn = (e) => {
|
|
4205
4231
|
let r = Ze.get(e);
|
|
4206
4232
|
return r || (r = {
|
|
4207
4233
|
minTime: Se(e.minDate),
|
|
4208
4234
|
maxTime: Se(e.maxDate)
|
|
4209
4235
|
}, Ze.set(e, r)), r;
|
|
4210
4236
|
};
|
|
4211
|
-
function
|
|
4237
|
+
function Dn(e, r, t) {
|
|
4212
4238
|
if (r == null || String(r).trim() === "")
|
|
4213
4239
|
return e.required ? t("Value required") : void 0;
|
|
4214
4240
|
const n = String(r).trim(), o = Se(n);
|
|
4215
4241
|
if (o === null)
|
|
4216
4242
|
return t("Invalid date format");
|
|
4217
|
-
const { minTime: a, maxTime: c } =
|
|
4243
|
+
const { minTime: a, maxTime: c } = Rn(e);
|
|
4218
4244
|
if (a !== null && o < a)
|
|
4219
4245
|
return t("Date must be on or after {{1}}", e.minDate);
|
|
4220
4246
|
if (c !== null && o > c)
|
|
4221
4247
|
return t("Date must be on or before {{1}}", e.maxDate);
|
|
4222
4248
|
}
|
|
4223
|
-
function
|
|
4249
|
+
function zn(e, r, t) {
|
|
4224
4250
|
const n = String(r);
|
|
4225
4251
|
if (!n || n.trim() === "")
|
|
4226
4252
|
return e.required || e.min || e.max ? t("Value required") : void 0;
|
|
@@ -4254,29 +4280,29 @@ function Dn(e, r, t) {
|
|
|
4254
4280
|
return t("Time must be on or before {{1}}", e.max);
|
|
4255
4281
|
}
|
|
4256
4282
|
}
|
|
4257
|
-
function
|
|
4283
|
+
function Pn(e) {
|
|
4258
4284
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
4259
4285
|
}
|
|
4260
|
-
function
|
|
4286
|
+
function On(e, r, t) {
|
|
4261
4287
|
const n = String(r ?? "").trim();
|
|
4262
|
-
return n === "" ? e.required ? t("Value required") : void 0 :
|
|
4288
|
+
return n === "" ? e.required ? t("Value required") : void 0 : Pn(n) ? Le(e, r, t, t("Email does not match pattern: {{1}}", e.pattern)) : t("Must be valid email format");
|
|
4263
4289
|
}
|
|
4264
4290
|
function Ln(e, r, t) {
|
|
4265
4291
|
const n = String(r ?? "").trim();
|
|
4266
|
-
return n === "" ? e.required ? t("Value required") : void 0 :
|
|
4292
|
+
return n === "" ? e.required ? t("Value required") : void 0 : Le(e, n, t, "Invalid phone number format");
|
|
4267
4293
|
}
|
|
4268
|
-
const
|
|
4294
|
+
const Tn = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i, jn = (e) => {
|
|
4269
4295
|
try {
|
|
4270
4296
|
return new URL(e), !0;
|
|
4271
4297
|
} catch {
|
|
4272
4298
|
return !1;
|
|
4273
4299
|
}
|
|
4274
4300
|
};
|
|
4275
|
-
function
|
|
4301
|
+
function Bn(e, r, t) {
|
|
4276
4302
|
const n = String(r ?? "").trim();
|
|
4277
4303
|
if (n === "")
|
|
4278
4304
|
return e.required ? t("Value required") : void 0;
|
|
4279
|
-
if (!(
|
|
4305
|
+
if (!(Tn.test(n) || jn(n))) {
|
|
4280
4306
|
if (e.allowRelative === !0) {
|
|
4281
4307
|
if (!n.startsWith("/") || encodeURI(n) !== n)
|
|
4282
4308
|
return t("Must be a valid URL");
|
|
@@ -4290,11 +4316,11 @@ function jn(e, r, t) {
|
|
|
4290
4316
|
return t("Must be a valid URL");
|
|
4291
4317
|
}
|
|
4292
4318
|
}
|
|
4293
|
-
function
|
|
4319
|
+
function Hn(e, r, t) {
|
|
4294
4320
|
const n = Array.isArray(r) ? r : [], o = n[0], a = n[1] ? String(n[1]).trim() : "";
|
|
4295
|
-
return String(o ?? "").trim() === "" || a === "" ? e.required ? t("Value required") : void 0 :
|
|
4321
|
+
return String(o ?? "").trim() === "" || a === "" ? e.required ? t("Value required") : void 0 : et(e, o, t);
|
|
4296
4322
|
}
|
|
4297
|
-
function
|
|
4323
|
+
function qn(e, r, t) {
|
|
4298
4324
|
if (Array.isArray(r))
|
|
4299
4325
|
return r.length === 0 ? t("Select a file") : r.every((n) => n instanceof File) ? void 0 : t("Invalid file input");
|
|
4300
4326
|
if (!(r instanceof File)) {
|
|
@@ -4302,14 +4328,14 @@ function Hn(e, r, t) {
|
|
|
4302
4328
|
return e.required && (r == null || typeof n == "string" && n.trim() === "") ? t("Select a file") : t("Invalid file input: {{1}}", n);
|
|
4303
4329
|
}
|
|
4304
4330
|
}
|
|
4305
|
-
function
|
|
4331
|
+
function Un(e, r, t) {
|
|
4306
4332
|
const n = String(r);
|
|
4307
4333
|
if (n === "" || n === null || n === void 0)
|
|
4308
4334
|
return e.required ? t("Value required") : void 0;
|
|
4309
4335
|
if (!e.options?.some((o) => String(o.value) === n))
|
|
4310
4336
|
return t("Invalid option selected");
|
|
4311
4337
|
}
|
|
4312
|
-
function
|
|
4338
|
+
function Wn(e, r, t) {
|
|
4313
4339
|
const o = String(r ?? "").trim();
|
|
4314
4340
|
if (o === "")
|
|
4315
4341
|
return e.required ? t("Value required") : void 0;
|
|
@@ -4320,15 +4346,15 @@ function Un(e, r, t) {
|
|
|
4320
4346
|
if (!e.options?.some((s) => String(s.value) === c))
|
|
4321
4347
|
return t("Invalid option selected");
|
|
4322
4348
|
}
|
|
4323
|
-
const
|
|
4324
|
-
function
|
|
4349
|
+
const _n = /^#([0-9A-F]{3}){1,2}$/i, Kn = (e) => _n.test(e);
|
|
4350
|
+
function Gn(e, r, t) {
|
|
4325
4351
|
const n = String(r).trim();
|
|
4326
4352
|
if (n === "")
|
|
4327
4353
|
return e.required ? t("Value required") : void 0;
|
|
4328
|
-
if (!
|
|
4354
|
+
if (!Kn(n))
|
|
4329
4355
|
return t("Invalid color format");
|
|
4330
4356
|
}
|
|
4331
|
-
function
|
|
4357
|
+
function Jn(e, r, t) {
|
|
4332
4358
|
const n = String(r ?? "").trim();
|
|
4333
4359
|
if (n === "")
|
|
4334
4360
|
return e.required ? t("Value required") : void 0;
|
|
@@ -4338,7 +4364,7 @@ function Gn(e, r, t) {
|
|
|
4338
4364
|
if (e.max !== void 0 && o > e.max)
|
|
4339
4365
|
return t("Must be ≤ {{1}}", e.max);
|
|
4340
4366
|
}
|
|
4341
|
-
function
|
|
4367
|
+
function Yn(e, r, t) {
|
|
4342
4368
|
const n = String(r);
|
|
4343
4369
|
if (n.trim() === "")
|
|
4344
4370
|
return e.required ? t("Value required") : void 0;
|
|
@@ -4351,13 +4377,13 @@ function Jn(e, r, t) {
|
|
|
4351
4377
|
return t("Must be ≤ {{1}}", c);
|
|
4352
4378
|
}
|
|
4353
4379
|
let Qe = !1;
|
|
4354
|
-
function
|
|
4355
|
-
Qe || (H("int", Xe), H("stepper", Xe), H("int-array",
|
|
4380
|
+
function rt() {
|
|
4381
|
+
Qe || (H("int", Xe), H("stepper", Xe), H("int-array", En), H("float", et), H("slider", Yn), H("float-array", An), H("text", ue), H("string", ue), H("multiline", ue), H("password", ue), H("email", On), H("date", Dn), H("time", zn), H("url", Bn), H("phone", Ln), H("unit", Hn), H("dropdown", Un), H("multi-selection", Wn), H("color", Gn), H("rating", Jn), H("file", qn), Qe = !0);
|
|
4356
4382
|
}
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
const
|
|
4383
|
+
rt();
|
|
4384
|
+
cn();
|
|
4385
|
+
rt();
|
|
4386
|
+
const Xn = (e) => ({
|
|
4361
4387
|
container: {
|
|
4362
4388
|
padding: "var(--reactaform-space-sm, 8px)",
|
|
4363
4389
|
margin: "0 auto",
|
|
@@ -4398,7 +4424,7 @@ const Yn = (e) => ({
|
|
|
4398
4424
|
lineHeight: "1.2",
|
|
4399
4425
|
textAlign: "left"
|
|
4400
4426
|
}
|
|
4401
|
-
}),
|
|
4427
|
+
}), Zn = (e) => {
|
|
4402
4428
|
const r = {
|
|
4403
4429
|
color: "var(--reactaform-color-text)",
|
|
4404
4430
|
fontFamily: e?.fontFamily || "var(--reactaform-font-family, inherit)",
|
|
@@ -4457,7 +4483,7 @@ const Yn = (e) => ({
|
|
|
4457
4483
|
display: "block"
|
|
4458
4484
|
}
|
|
4459
4485
|
};
|
|
4460
|
-
},
|
|
4486
|
+
}, Qn = ({
|
|
4461
4487
|
children: e,
|
|
4462
4488
|
definitionName: r = "",
|
|
4463
4489
|
defaultStyle: t,
|
|
@@ -4480,9 +4506,9 @@ const Yn = (e) => ({
|
|
|
4480
4506
|
return;
|
|
4481
4507
|
}
|
|
4482
4508
|
try {
|
|
4483
|
-
const w = await
|
|
4509
|
+
const w = await vn(f), x = w.success ? w.translations : {};
|
|
4484
4510
|
v && N(x);
|
|
4485
|
-
const k = await
|
|
4511
|
+
const k = await xn(f, m), S = k.success ? k.translations : {};
|
|
4486
4512
|
v && y(S);
|
|
4487
4513
|
} catch {
|
|
4488
4514
|
v && (N({}), y({}));
|
|
@@ -4491,20 +4517,20 @@ const Yn = (e) => ({
|
|
|
4491
4517
|
v = !1;
|
|
4492
4518
|
};
|
|
4493
4519
|
}, [f, m]);
|
|
4494
|
-
const E = l.useMemo(() =>
|
|
4495
|
-
() =>
|
|
4520
|
+
const E = l.useMemo(() => Xn(b), [b]), M = l.useMemo(() => Zn(b), [b]), F = l.useMemo(
|
|
4521
|
+
() => Sn(f, C, h),
|
|
4496
4522
|
[f, C, h]
|
|
4497
|
-
),
|
|
4498
|
-
(v, ...g) =>
|
|
4499
|
-
[
|
|
4523
|
+
), V = l.useCallback(
|
|
4524
|
+
(v, ...g) => F(v, ...g),
|
|
4525
|
+
[F]
|
|
4500
4526
|
), R = l.useMemo(
|
|
4501
4527
|
() => ({
|
|
4502
4528
|
definitionName: d,
|
|
4503
4529
|
language: f,
|
|
4504
4530
|
theme: u,
|
|
4505
4531
|
formStyle: E,
|
|
4506
|
-
fieldStyle:
|
|
4507
|
-
t:
|
|
4532
|
+
fieldStyle: M,
|
|
4533
|
+
t: V,
|
|
4508
4534
|
fieldValidationMode: c,
|
|
4509
4535
|
displayInstanceName: i
|
|
4510
4536
|
}),
|
|
@@ -4512,9 +4538,9 @@ const Yn = (e) => ({
|
|
|
4512
4538
|
d,
|
|
4513
4539
|
f,
|
|
4514
4540
|
u,
|
|
4515
|
-
|
|
4541
|
+
M,
|
|
4516
4542
|
E,
|
|
4517
|
-
|
|
4543
|
+
V,
|
|
4518
4544
|
c,
|
|
4519
4545
|
i
|
|
4520
4546
|
]
|
|
@@ -4529,7 +4555,7 @@ const Yn = (e) => ({
|
|
|
4529
4555
|
}
|
|
4530
4556
|
) });
|
|
4531
4557
|
};
|
|
4532
|
-
function
|
|
4558
|
+
function eo(e) {
|
|
4533
4559
|
if (!e || typeof e != "object")
|
|
4534
4560
|
return "Definition must be an object";
|
|
4535
4561
|
const r = e;
|
|
@@ -4557,7 +4583,7 @@ function Qn(e) {
|
|
|
4557
4583
|
}
|
|
4558
4584
|
return null;
|
|
4559
4585
|
}
|
|
4560
|
-
async function
|
|
4586
|
+
async function vo(e, r = {}) {
|
|
4561
4587
|
const { validateSchema: t = !0 } = r;
|
|
4562
4588
|
try {
|
|
4563
4589
|
if (!e || typeof e != "string")
|
|
@@ -4575,7 +4601,7 @@ async function yo(e, r = {}) {
|
|
|
4575
4601
|
};
|
|
4576
4602
|
}
|
|
4577
4603
|
if (t) {
|
|
4578
|
-
const a =
|
|
4604
|
+
const a = eo(o);
|
|
4579
4605
|
if (a)
|
|
4580
4606
|
return { success: !1, error: `Schema validation failed: ${a}` };
|
|
4581
4607
|
}
|
|
@@ -4584,7 +4610,7 @@ async function yo(e, r = {}) {
|
|
|
4584
4610
|
return { success: !1, error: `Unexpected error loading definition: ${n instanceof Error ? n.message : "Unknown error"}` };
|
|
4585
4611
|
}
|
|
4586
4612
|
}
|
|
4587
|
-
function
|
|
4613
|
+
function ro(e, r) {
|
|
4588
4614
|
try {
|
|
4589
4615
|
if (!e)
|
|
4590
4616
|
return { success: !1, error: "Definition is required" };
|
|
@@ -4611,7 +4637,7 @@ function eo(e, r) {
|
|
|
4611
4637
|
};
|
|
4612
4638
|
}
|
|
4613
4639
|
}
|
|
4614
|
-
function
|
|
4640
|
+
function xo(e) {
|
|
4615
4641
|
try {
|
|
4616
4642
|
if (!e)
|
|
4617
4643
|
return { success: !1, error: "Instance data is required" };
|
|
@@ -4635,7 +4661,7 @@ function vo(e) {
|
|
|
4635
4661
|
};
|
|
4636
4662
|
}
|
|
4637
4663
|
}
|
|
4638
|
-
function
|
|
4664
|
+
function wo(e, r, t) {
|
|
4639
4665
|
try {
|
|
4640
4666
|
if (!e)
|
|
4641
4667
|
return { success: !1, error: "Instance is required" };
|
|
@@ -4717,7 +4743,7 @@ function xo(e, r, t) {
|
|
|
4717
4743
|
};
|
|
4718
4744
|
}
|
|
4719
4745
|
}
|
|
4720
|
-
function
|
|
4746
|
+
function to(e) {
|
|
4721
4747
|
const [r, t] = l.useState(null);
|
|
4722
4748
|
return l.useEffect(() => {
|
|
4723
4749
|
const n = document.querySelector("[data-reactaform-theme]");
|
|
@@ -4733,7 +4759,7 @@ function ro(e) {
|
|
|
4733
4759
|
return c.observe(o, { attributes: !0, attributeFilter: ["data-reactaform-theme"] }), () => c.disconnect();
|
|
4734
4760
|
}, [e]), r;
|
|
4735
4761
|
}
|
|
4736
|
-
const
|
|
4762
|
+
const So = ({
|
|
4737
4763
|
definitionData: e,
|
|
4738
4764
|
instance: r,
|
|
4739
4765
|
language: t,
|
|
@@ -4751,7 +4777,7 @@ const wo = ({
|
|
|
4751
4777
|
} catch {
|
|
4752
4778
|
return null;
|
|
4753
4779
|
}
|
|
4754
|
-
}, [e]), u = { fontSize: "inherit", fontFamily: "inherit", ...a }, f =
|
|
4780
|
+
}, [e]), u = { fontSize: "inherit", fontFamily: "inherit", ...a }, f = to(), b = o ?? f ?? "light", C = t ?? "en";
|
|
4755
4781
|
l.useEffect(() => {
|
|
4756
4782
|
let h = document.getElementById("popup-root");
|
|
4757
4783
|
h || (h = document.createElement("div"), h.id = "popup-root", document.body.appendChild(h));
|
|
@@ -4759,11 +4785,11 @@ const wo = ({
|
|
|
4759
4785
|
const N = l.useMemo(() => {
|
|
4760
4786
|
if (r) return r;
|
|
4761
4787
|
if (!m) return null;
|
|
4762
|
-
const h =
|
|
4788
|
+
const h = ro(m, m.name);
|
|
4763
4789
|
return !h.success || !h.instance ? null : h.instance;
|
|
4764
4790
|
}, [r, m]);
|
|
4765
4791
|
return m ? N ? /* @__PURE__ */ p(
|
|
4766
|
-
|
|
4792
|
+
Qn,
|
|
4767
4793
|
{
|
|
4768
4794
|
definitionName: m.name,
|
|
4769
4795
|
defaultStyle: u,
|
|
@@ -4774,7 +4800,7 @@ const wo = ({
|
|
|
4774
4800
|
defaultFieldValidationMode: c,
|
|
4775
4801
|
defaultDisplayInstanceName: s,
|
|
4776
4802
|
children: /* @__PURE__ */ p(
|
|
4777
|
-
|
|
4803
|
+
bn,
|
|
4778
4804
|
{
|
|
4779
4805
|
definition: m,
|
|
4780
4806
|
instance: N,
|
|
@@ -4784,7 +4810,7 @@ const wo = ({
|
|
|
4784
4810
|
)
|
|
4785
4811
|
}
|
|
4786
4812
|
) : /* @__PURE__ */ p("div", { style: { color: "red" }, children: "Error: Failed to create instance from definition." }) : /* @__PURE__ */ p("div", { style: { color: "red" }, children: "Error: No form definition provided." });
|
|
4787
|
-
},
|
|
4813
|
+
}, Q = /* @__PURE__ */ new Map(), W = {
|
|
4788
4814
|
components: /* @__PURE__ */ new Map(),
|
|
4789
4815
|
fieldValidators: /* @__PURE__ */ new Map(),
|
|
4790
4816
|
// category -> name -> plugin
|
|
@@ -4792,7 +4818,7 @@ const wo = ({
|
|
|
4792
4818
|
formValidators: /* @__PURE__ */ new Map(),
|
|
4793
4819
|
submissionHandlers: /* @__PURE__ */ new Map()
|
|
4794
4820
|
};
|
|
4795
|
-
function
|
|
4821
|
+
function tt(e, r, t) {
|
|
4796
4822
|
if (!e) return !0;
|
|
4797
4823
|
if (t && !t(e))
|
|
4798
4824
|
return !1;
|
|
@@ -4813,14 +4839,14 @@ function rt(e, r, t) {
|
|
|
4813
4839
|
return !1;
|
|
4814
4840
|
}
|
|
4815
4841
|
}
|
|
4816
|
-
function
|
|
4842
|
+
function no(e) {
|
|
4817
4843
|
const r = [];
|
|
4818
4844
|
if (e.components)
|
|
4819
4845
|
for (const t of Object.keys(e.components)) {
|
|
4820
4846
|
const n = _r(t);
|
|
4821
4847
|
if (n) {
|
|
4822
4848
|
let o;
|
|
4823
|
-
for (const [a, c] of
|
|
4849
|
+
for (const [a, c] of Q)
|
|
4824
4850
|
if (c.components && c.components[t] === n) {
|
|
4825
4851
|
o = a;
|
|
4826
4852
|
break;
|
|
@@ -4866,7 +4892,7 @@ function to(e) {
|
|
|
4866
4892
|
}
|
|
4867
4893
|
if (e.submissionHandlers)
|
|
4868
4894
|
for (const t of Object.keys(e.submissionHandlers)) {
|
|
4869
|
-
const n =
|
|
4895
|
+
const n = pn(t), o = W.submissionHandlers.get(t);
|
|
4870
4896
|
n && o && o !== e.name && r.push({
|
|
4871
4897
|
type: "submissionHandler",
|
|
4872
4898
|
name: t,
|
|
@@ -4879,7 +4905,7 @@ function to(e) {
|
|
|
4879
4905
|
function ae(e, r, t, n, o, a, c, s) {
|
|
4880
4906
|
for (const i of Object.keys(e)) {
|
|
4881
4907
|
let d;
|
|
4882
|
-
if (s ? d = o.find((m) => m.type === "fieldCustomValidator" && m.name === `${s}:${i}`) : e === n.components ? d = o.find((m) => m.type === "component" && m.name === i) : e === n.formValidators ? d = o.find((m) => m.type === "formValidator" && m.name === i) : e === n.fieldTypeValidators ? d = o.find((m) => m.type === "fieldTypeValidator" && m.name === `type:${i}`) : e === n.submissionHandlers && (d = o.find((m) => m.type === "submissionHandler" && m.name === i)),
|
|
4908
|
+
if (s ? d = o.find((m) => m.type === "fieldCustomValidator" && m.name === `${s}:${i}`) : e === n.components ? d = o.find((m) => m.type === "component" && m.name === i) : e === n.formValidators ? d = o.find((m) => m.type === "formValidator" && m.name === i) : e === n.fieldTypeValidators ? d = o.find((m) => m.type === "fieldTypeValidator" && m.name === `type:${i}`) : e === n.submissionHandlers && (d = o.find((m) => m.type === "submissionHandler" && m.name === i)), tt(d || null, a, c))
|
|
4883
4909
|
if (s) {
|
|
4884
4910
|
const m = r.get(s) || /* @__PURE__ */ new Map();
|
|
4885
4911
|
m.set(i, n.name), r.set(s, m), t(i, e[i]);
|
|
@@ -4890,18 +4916,18 @@ function ae(e, r, t, n, o, a, c, s) {
|
|
|
4890
4916
|
) : r.set(i, n.name), t(i, e[i]);
|
|
4891
4917
|
}
|
|
4892
4918
|
}
|
|
4893
|
-
function
|
|
4919
|
+
function Co(e, r) {
|
|
4894
4920
|
const t = r?.conflictResolution || "error";
|
|
4895
|
-
if (
|
|
4921
|
+
if (Q.has(e.name)) {
|
|
4896
4922
|
const o = {
|
|
4897
4923
|
type: "plugin",
|
|
4898
4924
|
name: e.name,
|
|
4899
4925
|
existingPlugin: e.name,
|
|
4900
4926
|
newPlugin: e.name
|
|
4901
4927
|
};
|
|
4902
|
-
if (!
|
|
4928
|
+
if (!tt(o, t, r?.onConflict)) return;
|
|
4903
4929
|
}
|
|
4904
|
-
const n =
|
|
4930
|
+
const n = no(e);
|
|
4905
4931
|
if (e.components && ae(
|
|
4906
4932
|
e.components,
|
|
4907
4933
|
W.components,
|
|
@@ -4915,7 +4941,7 @@ function So(e, r) {
|
|
|
4915
4941
|
ae(
|
|
4916
4942
|
a,
|
|
4917
4943
|
W.fieldValidators,
|
|
4918
|
-
(c, s) =>
|
|
4944
|
+
(c, s) => ht(o, c, s),
|
|
4919
4945
|
e,
|
|
4920
4946
|
n,
|
|
4921
4947
|
t,
|
|
@@ -4925,7 +4951,7 @@ function So(e, r) {
|
|
|
4925
4951
|
e.formValidators && ae(
|
|
4926
4952
|
e.formValidators,
|
|
4927
4953
|
W.formValidators,
|
|
4928
|
-
|
|
4954
|
+
gt,
|
|
4929
4955
|
e,
|
|
4930
4956
|
n,
|
|
4931
4957
|
t,
|
|
@@ -4933,7 +4959,7 @@ function So(e, r) {
|
|
|
4933
4959
|
), e.fieldTypeValidators && ae(
|
|
4934
4960
|
e.fieldTypeValidators,
|
|
4935
4961
|
W.fieldTypeValidators,
|
|
4936
|
-
|
|
4962
|
+
bt,
|
|
4937
4963
|
e,
|
|
4938
4964
|
n,
|
|
4939
4965
|
t,
|
|
@@ -4941,15 +4967,15 @@ function So(e, r) {
|
|
|
4941
4967
|
), e.submissionHandlers && ae(
|
|
4942
4968
|
e.submissionHandlers,
|
|
4943
4969
|
W.submissionHandlers,
|
|
4944
|
-
|
|
4970
|
+
Yr,
|
|
4945
4971
|
e,
|
|
4946
4972
|
n,
|
|
4947
4973
|
t,
|
|
4948
4974
|
r?.onConflict
|
|
4949
|
-
), e.setup && e.setup(),
|
|
4975
|
+
), e.setup && e.setup(), Q.set(e.name, e);
|
|
4950
4976
|
}
|
|
4951
|
-
function
|
|
4952
|
-
const t =
|
|
4977
|
+
function No(e, r = !1) {
|
|
4978
|
+
const t = Q.get(e);
|
|
4953
4979
|
if (!t) return !1;
|
|
4954
4980
|
if (t.cleanup && t.cleanup(), r) {
|
|
4955
4981
|
if (t.components)
|
|
@@ -4974,18 +5000,18 @@ function Co(e, r = !1) {
|
|
|
4974
5000
|
for (const n of Object.keys(t.submissionHandlers))
|
|
4975
5001
|
W.submissionHandlers.delete(n);
|
|
4976
5002
|
}
|
|
4977
|
-
return
|
|
4978
|
-
}
|
|
4979
|
-
function No(e) {
|
|
4980
|
-
return Z.get(e);
|
|
5003
|
+
return Q.delete(e), !0;
|
|
4981
5004
|
}
|
|
4982
|
-
function ko() {
|
|
4983
|
-
return
|
|
5005
|
+
function ko(e) {
|
|
5006
|
+
return Q.get(e);
|
|
4984
5007
|
}
|
|
4985
|
-
function Io(
|
|
4986
|
-
return
|
|
5008
|
+
function Io() {
|
|
5009
|
+
return Array.from(Q.values());
|
|
4987
5010
|
}
|
|
4988
5011
|
function Eo(e) {
|
|
5012
|
+
return Q.has(e);
|
|
5013
|
+
}
|
|
5014
|
+
function Fo(e) {
|
|
4989
5015
|
for (const [r, t] of Object.entries(e))
|
|
4990
5016
|
Wr(r, t);
|
|
4991
5017
|
}
|
|
@@ -4997,7 +5023,7 @@ function Te(e) {
|
|
|
4997
5023
|
const r = e;
|
|
4998
5024
|
return typeof r.name == "string" && typeof r.displayName == "string";
|
|
4999
5025
|
}
|
|
5000
|
-
function
|
|
5026
|
+
function nt(e) {
|
|
5001
5027
|
if (!ee(e)) return !1;
|
|
5002
5028
|
const r = e;
|
|
5003
5029
|
return typeof r.name != "string" || typeof r.version != "string" || !Array.isArray(r.properties) ? !1 : r.properties.every((t) => Te(t));
|
|
@@ -5025,7 +5051,7 @@ function Mo(e, r, t = {}) {
|
|
|
5025
5051
|
success: !1,
|
|
5026
5052
|
error: "Instance must be a valid object"
|
|
5027
5053
|
};
|
|
5028
|
-
const d = [], m = [], u = {}, b = (
|
|
5054
|
+
const d = [], m = [], u = {}, b = (nt(r) || ee(r) && Array.isArray(r.properties) ? r.properties : []).filter(Te), C = new Map(b.map((h) => [h.name, h]));
|
|
5029
5055
|
for (const [h, y] of Object.entries(e)) {
|
|
5030
5056
|
if (s.includes(h)) {
|
|
5031
5057
|
m.push(h);
|
|
@@ -5038,9 +5064,9 @@ function Mo(e, r, t = {}) {
|
|
|
5038
5064
|
if (y === void 0) continue;
|
|
5039
5065
|
const E = C.get(h);
|
|
5040
5066
|
try {
|
|
5041
|
-
u[h] =
|
|
5042
|
-
} catch (
|
|
5043
|
-
d.push(`Error serializing field '${h}': ${String(
|
|
5067
|
+
u[h] = oo(y, E, { dateFormat: o, fileHandling: a });
|
|
5068
|
+
} catch (M) {
|
|
5069
|
+
d.push(`Error serializing field '${h}': ${String(M)}`), u[h] = null;
|
|
5044
5070
|
}
|
|
5045
5071
|
}
|
|
5046
5072
|
return n && (u._metadata = {
|
|
@@ -5064,7 +5090,7 @@ function Mo(e, r, t = {}) {
|
|
|
5064
5090
|
};
|
|
5065
5091
|
}
|
|
5066
5092
|
}
|
|
5067
|
-
function
|
|
5093
|
+
function oo(e, r, t = {}) {
|
|
5068
5094
|
const { dateFormat: n = "iso", fileHandling: o = "metadata" } = t;
|
|
5069
5095
|
if (e == null)
|
|
5070
5096
|
return null;
|
|
@@ -5134,7 +5160,7 @@ function tr(e, r) {
|
|
|
5134
5160
|
_note: "Base64 encoding requires async implementation"
|
|
5135
5161
|
};
|
|
5136
5162
|
}
|
|
5137
|
-
function
|
|
5163
|
+
function Vo(e, r, t = {}) {
|
|
5138
5164
|
try {
|
|
5139
5165
|
const {
|
|
5140
5166
|
strict: n = !1,
|
|
@@ -5161,7 +5187,7 @@ function Fo(e, r, t = {}) {
|
|
|
5161
5187
|
success: !1,
|
|
5162
5188
|
error: "Parsed data must be an object"
|
|
5163
5189
|
};
|
|
5164
|
-
const i = [], d = [], m = {}, f = (
|
|
5190
|
+
const i = [], d = [], m = {}, f = (nt(r) || ee(r) && Array.isArray(r.properties) ? r.properties : []).filter(Te), b = new Map(f.map((N) => [N.name, N]));
|
|
5165
5191
|
for (const N of f) {
|
|
5166
5192
|
const h = N.name, y = s[h];
|
|
5167
5193
|
if (y === void 0) {
|
|
@@ -5169,10 +5195,10 @@ function Fo(e, r, t = {}) {
|
|
|
5169
5195
|
continue;
|
|
5170
5196
|
}
|
|
5171
5197
|
try {
|
|
5172
|
-
m[h] =
|
|
5198
|
+
m[h] = ao(y, N, { validateTypes: o, dateFormat: c });
|
|
5173
5199
|
} catch (E) {
|
|
5174
|
-
const
|
|
5175
|
-
n ? d.push(
|
|
5200
|
+
const M = `Error deserializing field '${h}': ${String(E)}`;
|
|
5201
|
+
n ? d.push(M) : (i.push(M), m[h] = y);
|
|
5176
5202
|
}
|
|
5177
5203
|
}
|
|
5178
5204
|
if (a)
|
|
@@ -5192,7 +5218,7 @@ function Fo(e, r, t = {}) {
|
|
|
5192
5218
|
};
|
|
5193
5219
|
}
|
|
5194
5220
|
}
|
|
5195
|
-
function
|
|
5221
|
+
function ao(e, r, t = {}) {
|
|
5196
5222
|
const { validateTypes: n = !0, dateFormat: o = "auto" } = t;
|
|
5197
5223
|
if (e == null)
|
|
5198
5224
|
return e;
|
|
@@ -5201,7 +5227,7 @@ function oo(e, r, t = {}) {
|
|
|
5201
5227
|
case "date":
|
|
5202
5228
|
case "datetime":
|
|
5203
5229
|
case "date-time":
|
|
5204
|
-
return
|
|
5230
|
+
return io(e, o, n);
|
|
5205
5231
|
case "int":
|
|
5206
5232
|
case "integer":
|
|
5207
5233
|
return Ne(e, n);
|
|
@@ -5209,7 +5235,7 @@ function oo(e, r, t = {}) {
|
|
|
5209
5235
|
case "number":
|
|
5210
5236
|
return ke(e, n);
|
|
5211
5237
|
case "boolean":
|
|
5212
|
-
return
|
|
5238
|
+
return so(e, n);
|
|
5213
5239
|
case "int-array":
|
|
5214
5240
|
return nr(e, "integer", n);
|
|
5215
5241
|
case "float-array":
|
|
@@ -5258,7 +5284,7 @@ function $o(e, r = {}) {
|
|
|
5258
5284
|
};
|
|
5259
5285
|
}
|
|
5260
5286
|
}
|
|
5261
|
-
function
|
|
5287
|
+
function Ao(e, r = {}) {
|
|
5262
5288
|
try {
|
|
5263
5289
|
const { strict: t = !1, validateTypes: n = !0 } = r;
|
|
5264
5290
|
let o;
|
|
@@ -5318,7 +5344,7 @@ function Vo(e, r = {}) {
|
|
|
5318
5344
|
};
|
|
5319
5345
|
}
|
|
5320
5346
|
}
|
|
5321
|
-
function
|
|
5347
|
+
function io(e, r, t) {
|
|
5322
5348
|
if (e instanceof Date)
|
|
5323
5349
|
return e;
|
|
5324
5350
|
if (typeof e == "number") {
|
|
@@ -5383,7 +5409,7 @@ function ke(e, r) {
|
|
|
5383
5409
|
throw new Error(`Cannot convert ${typeof e} to number`);
|
|
5384
5410
|
return e;
|
|
5385
5411
|
}
|
|
5386
|
-
function
|
|
5412
|
+
function so(e, r) {
|
|
5387
5413
|
if (typeof e == "boolean")
|
|
5388
5414
|
return e;
|
|
5389
5415
|
if (typeof e == "string") {
|
|
@@ -5417,55 +5443,55 @@ function nr(e, r, t) {
|
|
|
5417
5443
|
}
|
|
5418
5444
|
});
|
|
5419
5445
|
}
|
|
5420
|
-
function
|
|
5446
|
+
function co() {
|
|
5421
5447
|
if (!document.getElementById("reactaform-styles"))
|
|
5422
5448
|
try {
|
|
5423
5449
|
const e = document.createElement("style");
|
|
5424
|
-
e.id = "reactaform-styles", e.textContent =
|
|
5450
|
+
e.id = "reactaform-styles", e.textContent = lt, document.head.appendChild(e);
|
|
5425
5451
|
} catch {
|
|
5426
5452
|
}
|
|
5427
5453
|
}
|
|
5428
|
-
typeof document < "u" &&
|
|
5454
|
+
typeof document < "u" && co();
|
|
5429
5455
|
export {
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5456
|
+
$ as CSS_CLASSES,
|
|
5457
|
+
So as ReactaForm,
|
|
5458
|
+
Qn as ReactaFormProvider,
|
|
5459
|
+
bn as ReactaFormRenderer,
|
|
5460
|
+
L as StandardFieldLayout,
|
|
5461
|
+
fo as Units,
|
|
5436
5462
|
U as combineClasses,
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5463
|
+
ro as createInstanceFromDefinition,
|
|
5464
|
+
Ao as deserializeDefinition,
|
|
5465
|
+
Vo as deserializeInstance,
|
|
5466
|
+
Io as getAllPlugins,
|
|
5467
|
+
tn as getButtonHandler,
|
|
5442
5468
|
_r as getComponent,
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5469
|
+
ko as getPlugin,
|
|
5470
|
+
yo as getSupportedLanguages,
|
|
5471
|
+
go as hasButtonHandler,
|
|
5472
|
+
Eo as hasPlugin,
|
|
5473
|
+
co as injectReactaFormStyles,
|
|
5448
5474
|
ie as isDarkTheme,
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5475
|
+
bo as listButtonHandlers,
|
|
5476
|
+
xo as loadInstance,
|
|
5477
|
+
vo as loadJsonDefinition,
|
|
5478
|
+
po as registerButtonHandler,
|
|
5453
5479
|
Wr as registerComponent,
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5480
|
+
Fo as registerComponents,
|
|
5481
|
+
ht as registerFieldCustomValidationHandler,
|
|
5482
|
+
bt as registerFieldTypeValidationHandler,
|
|
5483
|
+
gt as registerFormValidationHandler,
|
|
5484
|
+
Co as registerPlugin,
|
|
5485
|
+
Yr as registerSubmissionHandler,
|
|
5460
5486
|
$o as serializeDefinition,
|
|
5461
5487
|
Mo as serializeInstance,
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5488
|
+
ho as unregisterButtonHandler,
|
|
5489
|
+
No as unregisterPlugin,
|
|
5490
|
+
wo as upgradeInstanceToLatestDefinition,
|
|
5491
|
+
ut as useDebouncedCallback,
|
|
5466
5492
|
T as useFieldValidator,
|
|
5467
5493
|
B as useReactaFormContext,
|
|
5468
5494
|
_ as useUncontrolledValidatedInput,
|
|
5469
|
-
|
|
5495
|
+
mo as validateFieldValue,
|
|
5470
5496
|
fr as validateFieldWithCustomHandler
|
|
5471
5497
|
};
|