reactaform 1.8.1 → 1.8.2
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/README.md +247 -379
- package/dist/{common-DnEDu-7h.mjs → common-B4FQDljX.mjs} +8 -19
- package/dist/common-BeQ3x_ll.js +1 -0
- package/dist/common-C9xi6Anp.js +1 -0
- package/dist/{common-CsY8BnXg.mjs → common-CCGIMXY_.mjs} +7 -19
- package/dist/common-CiL5z7rS.js +1 -0
- package/dist/{common-BZgeDhcm.mjs → common-Dd94fy-Y.mjs} +2 -11
- package/dist/{common-CBecOKIA.mjs → common-Ws7ob6hh.mjs} +3 -14
- package/dist/common-pqSYL5rx.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/reactaform.cjs.js +5 -5
- package/dist/reactaform.es.js +821 -784
- package/dist/utils/translationCache.d.ts +8 -0
- package/package.json +1 -1
- package/dist/common-Awfy-0XP.js +0 -1
- package/dist/common-BmlrZtLZ.js +0 -1
- package/dist/common-D8L4oP0c.js +0 -1
- package/dist/common-udunqMU-.js +0 -1
package/dist/reactaform.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as p, jsxs as A, Fragment as
|
|
1
|
+
import { jsx as p, jsxs as A, Fragment as Ne } from "react/jsx-runtime";
|
|
2
2
|
import * as u from "react";
|
|
3
|
-
import { createContext as
|
|
3
|
+
import { createContext as zr, useContext as Or, useRef as pe, useEffect as je, useCallback as ge } from "react";
|
|
4
4
|
import * as me from "react-dom";
|
|
5
|
-
const
|
|
5
|
+
const Lr = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
6
6
|
\r
|
|
7
7
|
/* Default Light Theme */\r
|
|
8
8
|
:root {\r
|
|
@@ -301,8 +301,8 @@ const Or = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
301
301
|
\r
|
|
302
302
|
\r
|
|
303
303
|
}\r
|
|
304
|
-
`,
|
|
305
|
-
const e =
|
|
304
|
+
`, Ie = zr(void 0), j = () => {
|
|
305
|
+
const e = Or(Ie);
|
|
306
306
|
if (!e)
|
|
307
307
|
throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");
|
|
308
308
|
return e;
|
|
@@ -354,19 +354,19 @@ class se {
|
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
const rr = typeof process < "u" && process.env.NODE_ENV === "test";
|
|
357
|
-
function
|
|
358
|
-
const n = pe(),
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}, [e]),
|
|
357
|
+
function Tr(e, r = 300, t) {
|
|
358
|
+
const n = pe(), a = pe(e), o = pe(null), c = t?.leading === !0, i = t?.trailing !== !1;
|
|
359
|
+
je(() => {
|
|
360
|
+
a.current = e;
|
|
361
|
+
}, [e]), je(() => () => {
|
|
362
362
|
n.current && clearTimeout(n.current);
|
|
363
363
|
}, []);
|
|
364
364
|
const s = (d) => {
|
|
365
|
-
|
|
365
|
+
a.current(...d);
|
|
366
366
|
}, m = ge(() => {
|
|
367
|
-
n.current && (clearTimeout(n.current), n.current = void 0),
|
|
367
|
+
n.current && (clearTimeout(n.current), n.current = void 0), o.current = null;
|
|
368
368
|
}, []), l = ge(() => {
|
|
369
|
-
n.current && i &&
|
|
369
|
+
n.current && i && o.current && (clearTimeout(n.current), n.current = void 0, s(o.current), o.current = null);
|
|
370
370
|
}, [i]);
|
|
371
371
|
return { callback: ge(
|
|
372
372
|
(...d) => {
|
|
@@ -375,8 +375,8 @@ function Lr(e, r = 300, t) {
|
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
377
|
const g = c && !n.current;
|
|
378
|
-
|
|
379
|
-
n.current = void 0, i &&
|
|
378
|
+
o.current = d, g && s(d), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
|
|
379
|
+
n.current = void 0, i && o.current && (s(o.current), o.current = null);
|
|
380
380
|
}, r);
|
|
381
381
|
},
|
|
382
382
|
[c, i, r]
|
|
@@ -394,8 +394,8 @@ const R = {
|
|
|
394
394
|
}, U = (...e) => {
|
|
395
395
|
const r = [];
|
|
396
396
|
for (const t of e)
|
|
397
|
-
t && (typeof t == "string" ? r.push(t) : typeof t == "object" && Object.entries(t).forEach(([n,
|
|
398
|
-
|
|
397
|
+
t && (typeof t == "string" ? r.push(t) : typeof t == "object" && Object.entries(t).forEach(([n, a]) => {
|
|
398
|
+
a && r.push(n);
|
|
399
399
|
}));
|
|
400
400
|
return r.join(" ");
|
|
401
401
|
};
|
|
@@ -405,18 +405,18 @@ function fe(e) {
|
|
|
405
405
|
function jr(e) {
|
|
406
406
|
if (!e) return !1;
|
|
407
407
|
const r = e.trim();
|
|
408
|
-
let t = 0, n = 0,
|
|
408
|
+
let t = 0, n = 0, a = 0;
|
|
409
409
|
if (r.startsWith("#")) {
|
|
410
410
|
const c = r.substring(1);
|
|
411
|
-
c.length === 3 || c.length === 4 ? (t = parseInt(c[0] + c[0], 16), n = parseInt(c[1] + c[1], 16),
|
|
411
|
+
c.length === 3 || c.length === 4 ? (t = parseInt(c[0] + c[0], 16), n = parseInt(c[1] + c[1], 16), a = parseInt(c[2] + c[2], 16)) : (c.length === 6 || c.length === 8) && (t = parseInt(c.substring(0, 2), 16), n = parseInt(c.substring(2, 4), 16), a = parseInt(c.substring(4, 6), 16));
|
|
412
412
|
} else if (r.startsWith("rgb")) {
|
|
413
413
|
const c = r.match(/\d+(\.\d+)?/g);
|
|
414
|
-
c && c.length >= 3 && (t = parseFloat(c[0]), n = parseFloat(c[1]),
|
|
414
|
+
c && c.length >= 3 && (t = parseFloat(c[0]), n = parseFloat(c[1]), a = parseFloat(c[2]));
|
|
415
415
|
} else
|
|
416
416
|
return !1;
|
|
417
|
-
return (t * 299 + n * 587 +
|
|
417
|
+
return (t * 299 + n * 587 + a * 114) / 1e3 < 128;
|
|
418
418
|
}
|
|
419
|
-
const
|
|
419
|
+
const Hr = () => /* @__PURE__ */ A(
|
|
420
420
|
"svg",
|
|
421
421
|
{
|
|
422
422
|
width: "1em",
|
|
@@ -432,8 +432,8 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
432
432
|
/* @__PURE__ */ p("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
433
433
|
]
|
|
434
434
|
}
|
|
435
|
-
),
|
|
436
|
-
const { t: n, theme:
|
|
435
|
+
), Br = ({ content: e, size: r = "medium", animation: t = !0 }) => {
|
|
436
|
+
const { t: n, theme: a, formStyle: o, fieldStyle: c } = j(), [i, s] = u.useState(!1), [m, l] = u.useState({ x: 0, y: 0 }), [f, d] = u.useState(!1), g = u.useRef(null), w = u.useRef(null), F = u.useRef(null), S = u.useId(), v = fe(a), [k, $] = u.useState(void 0);
|
|
437
437
|
u.useLayoutEffect(() => {
|
|
438
438
|
if (!g.current) return;
|
|
439
439
|
const b = "rgba(255,255,255,0.1)", y = getComputedStyle(g.current).getPropertyValue("--reactaform-primary-bg").trim();
|
|
@@ -443,7 +443,7 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
443
443
|
} else
|
|
444
444
|
$(b);
|
|
445
445
|
}, []);
|
|
446
|
-
const
|
|
446
|
+
const N = u.useMemo(() => {
|
|
447
447
|
const h = {
|
|
448
448
|
icon: {
|
|
449
449
|
display: "inline-flex",
|
|
@@ -488,16 +488,16 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
488
488
|
opacity: 1,
|
|
489
489
|
pointerEvents: "auto"
|
|
490
490
|
}
|
|
491
|
-
}, y = (E,
|
|
492
|
-
const H = E?.[
|
|
493
|
-
return (
|
|
491
|
+
}, y = (E, I, M) => {
|
|
492
|
+
const H = E?.[I];
|
|
493
|
+
return (M && H ? H[M] : void 0) ?? {};
|
|
494
494
|
};
|
|
495
495
|
return {
|
|
496
|
-
icon: { ...h.icon, ...y(
|
|
497
|
-
text: { ...h.text, ...y(
|
|
496
|
+
icon: { ...h.icon, ...y(o, "tooltip", "icon"), ...y(c, "tooltip", "icon") },
|
|
497
|
+
text: { ...h.text, ...y(o, "tooltip", "text"), ...y(c, "tooltip", "text") },
|
|
498
498
|
textVisible: h.textVisible
|
|
499
499
|
};
|
|
500
|
-
}, [v, r, t,
|
|
500
|
+
}, [v, r, t, o, c, k]);
|
|
501
501
|
u.useLayoutEffect(() => {
|
|
502
502
|
if (!i || !g.current || !w.current) {
|
|
503
503
|
d(!1);
|
|
@@ -505,9 +505,9 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
505
505
|
}
|
|
506
506
|
const b = g.current.getBoundingClientRect();
|
|
507
507
|
F.current = b;
|
|
508
|
-
const h = w.current.getBoundingClientRect(), y = 8, C = window.innerWidth, E = window.innerHeight,
|
|
509
|
-
let
|
|
510
|
-
|
|
508
|
+
const h = w.current.getBoundingClientRect(), y = 8, C = window.innerWidth, E = window.innerHeight, I = -4;
|
|
509
|
+
let M = b.right + y, P = b.top + b.height / 2 - h.height / 2 + I;
|
|
510
|
+
M + h.width > C - y && (M = b.left - y - h.width), M = Math.max(y, Math.min(M, C - h.width - y)), P = Math.max(y, Math.min(P, E - h.height - y)), l({ x: M, y: P }), d(!0);
|
|
511
511
|
const H = g.current.closest("[data-reactaform-theme]"), Z = document.getElementById("popup-root");
|
|
512
512
|
if (H && Z) {
|
|
513
513
|
const ne = getComputedStyle(H);
|
|
@@ -526,19 +526,19 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
526
526
|
ref: w,
|
|
527
527
|
"data-tooltip-id": S,
|
|
528
528
|
style: {
|
|
529
|
-
...
|
|
529
|
+
...N.text,
|
|
530
530
|
transform: f ? "translateY(0) scale(1)" : "translateY(-4px) scale(0.98)",
|
|
531
531
|
transition: "opacity 120ms ease, transform 120ms ease, visibility 120ms ease",
|
|
532
532
|
width: 240,
|
|
533
533
|
// When positioned is true, apply the visible styles
|
|
534
|
-
...f ?
|
|
534
|
+
...f ? N.textVisible : {},
|
|
535
535
|
top: m.y,
|
|
536
536
|
left: m.x
|
|
537
537
|
},
|
|
538
538
|
children: n(e)
|
|
539
539
|
}
|
|
540
540
|
);
|
|
541
|
-
return /* @__PURE__ */ A(
|
|
541
|
+
return /* @__PURE__ */ A(Ne, { children: [
|
|
542
542
|
/* @__PURE__ */ p(
|
|
543
543
|
"span",
|
|
544
544
|
{
|
|
@@ -548,33 +548,33 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
548
548
|
onMouseEnter: () => s(!0),
|
|
549
549
|
onMouseLeave: () => s(!1),
|
|
550
550
|
style: {
|
|
551
|
-
...
|
|
551
|
+
...N.icon
|
|
552
552
|
},
|
|
553
|
-
children: /* @__PURE__ */ p(
|
|
553
|
+
children: /* @__PURE__ */ p(Hr, {})
|
|
554
554
|
}
|
|
555
555
|
),
|
|
556
556
|
i && (x ? me.createPortal(V, x) : V)
|
|
557
557
|
] });
|
|
558
|
-
}, tr = u.memo(
|
|
558
|
+
}, tr = u.memo(Br), ve = u.memo(({
|
|
559
559
|
field: e,
|
|
560
560
|
error: r,
|
|
561
561
|
children: t,
|
|
562
562
|
showLabel: n = !0
|
|
563
563
|
}) => {
|
|
564
|
-
const { t:
|
|
564
|
+
const { t: a } = j(), o = e.labelLayout === "column-center" ? "center" : "left", c = u.useMemo(() => {
|
|
565
565
|
const m = {
|
|
566
566
|
display: "flex",
|
|
567
567
|
flexDirection: "column",
|
|
568
568
|
gap: "var(--reactaform-label-gap, 4px)"
|
|
569
569
|
};
|
|
570
|
-
return m["--label-align"] =
|
|
571
|
-
}, [
|
|
572
|
-
textAlign:
|
|
570
|
+
return m["--label-align"] = o, m;
|
|
571
|
+
}, [o]), i = u.useMemo(() => ({
|
|
572
|
+
textAlign: o,
|
|
573
573
|
width: "100%",
|
|
574
574
|
minWidth: "unset",
|
|
575
575
|
display: "block",
|
|
576
576
|
marginBottom: "10px"
|
|
577
|
-
}), [
|
|
577
|
+
}), [o]), s = u.useMemo(() => ({
|
|
578
578
|
display: "flex",
|
|
579
579
|
alignItems: "center",
|
|
580
580
|
gap: "var(--reactaform-inline-gap, 8px)",
|
|
@@ -588,14 +588,14 @@ const Tr = () => /* @__PURE__ */ A(
|
|
|
588
588
|
className: R.label,
|
|
589
589
|
htmlFor: e.name,
|
|
590
590
|
style: i,
|
|
591
|
-
children:
|
|
591
|
+
children: a(e.displayName)
|
|
592
592
|
}
|
|
593
593
|
),
|
|
594
594
|
/* @__PURE__ */ A("div", { style: s, children: [
|
|
595
595
|
/* @__PURE__ */ p("div", { style: { flex: 1, minWidth: 0 }, children: t }),
|
|
596
596
|
e.tooltip && /* @__PURE__ */ p(tr, { content: e.tooltip })
|
|
597
597
|
] }),
|
|
598
|
-
r && /* @__PURE__ */ p(
|
|
598
|
+
r && /* @__PURE__ */ p(Me, { id: `${e.name}-error`, children: r })
|
|
599
599
|
] });
|
|
600
600
|
});
|
|
601
601
|
ve.displayName = "ColumnFieldLayout";
|
|
@@ -605,7 +605,7 @@ const nr = u.memo(({
|
|
|
605
605
|
children: t,
|
|
606
606
|
rightAlign: n = !1
|
|
607
607
|
}) => {
|
|
608
|
-
const { t:
|
|
608
|
+
const { t: a } = j(), o = u.useMemo(() => ({
|
|
609
609
|
display: "flex",
|
|
610
610
|
alignItems: "center",
|
|
611
611
|
gap: "3px"
|
|
@@ -617,15 +617,15 @@ const nr = u.memo(({
|
|
|
617
617
|
id: `${e.name}-label`,
|
|
618
618
|
className: R.label,
|
|
619
619
|
htmlFor: e.name,
|
|
620
|
-
children:
|
|
620
|
+
children: a(e.displayName)
|
|
621
621
|
}
|
|
622
622
|
),
|
|
623
623
|
/* @__PURE__ */ A("div", { children: [
|
|
624
|
-
/* @__PURE__ */ A("div", { style:
|
|
624
|
+
/* @__PURE__ */ A("div", { style: o, children: [
|
|
625
625
|
n ? /* @__PURE__ */ p("div", { style: { display: "flex", flex: 1, justifyContent: "flex-end" }, children: t }) : t,
|
|
626
626
|
e.tooltip && /* @__PURE__ */ p(tr, { content: e.tooltip })
|
|
627
627
|
] }),
|
|
628
|
-
r && /* @__PURE__ */ p(
|
|
628
|
+
r && /* @__PURE__ */ p(Me, { id: `${e.name}-error`, children: r })
|
|
629
629
|
] })
|
|
630
630
|
] });
|
|
631
631
|
});
|
|
@@ -637,7 +637,7 @@ const O = u.memo(({
|
|
|
637
637
|
rightAlign: n = !1
|
|
638
638
|
}) => 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(nr, { field: e, error: r, rightAlign: n, children: t }));
|
|
639
639
|
O.displayName = "StandardFieldLayout";
|
|
640
|
-
const
|
|
640
|
+
const Me = u.memo(({ children: e, id: r }) => {
|
|
641
641
|
const t = u.useMemo(() => ({
|
|
642
642
|
color: "var(--reactaform-error-color)",
|
|
643
643
|
fontSize: "13px",
|
|
@@ -650,9 +650,9 @@ const Ne = u.memo(({ children: e, id: r }) => {
|
|
|
650
650
|
}), []);
|
|
651
651
|
return /* @__PURE__ */ p("div", { id: r, style: t, children: e });
|
|
652
652
|
});
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
const { t } =
|
|
653
|
+
Me.displayName = "ErrorDiv";
|
|
654
|
+
const ar = u.memo(({ name: e, onChange: r }) => {
|
|
655
|
+
const { t } = j();
|
|
656
656
|
return /* @__PURE__ */ A("div", { style: { marginBottom: 16 }, children: [
|
|
657
657
|
/* @__PURE__ */ A("div", { style: { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 12, alignItems: "center" }, children: [
|
|
658
658
|
/* @__PURE__ */ p(
|
|
@@ -683,12 +683,12 @@ const or = u.memo(({ name: e, onChange: r }) => {
|
|
|
683
683
|
/* @__PURE__ */ p("div", { style: { height: "1px", backgroundColor: "var(--reactaform-separator, #e6e6e6)", marginTop: 12, marginBottom: 12 } })
|
|
684
684
|
] });
|
|
685
685
|
});
|
|
686
|
-
|
|
687
|
-
class
|
|
686
|
+
ar.displayName = "InstanceName";
|
|
687
|
+
class qr extends se {
|
|
688
688
|
registerInCategory(r, t, n) {
|
|
689
689
|
this.get(r) || this.register(r, {});
|
|
690
|
-
const
|
|
691
|
-
|
|
690
|
+
const a = this.get(r);
|
|
691
|
+
a[t] = n;
|
|
692
692
|
}
|
|
693
693
|
getFromCategory(r, t) {
|
|
694
694
|
return this.get(r)?.[t];
|
|
@@ -700,15 +700,15 @@ class Br extends se {
|
|
|
700
700
|
return this.list();
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
|
-
const
|
|
704
|
-
function
|
|
705
|
-
|
|
703
|
+
const or = new se(), ir = new qr(), Fe = new se();
|
|
704
|
+
function Ur(e, r) {
|
|
705
|
+
or.register(e, r);
|
|
706
706
|
}
|
|
707
|
-
function
|
|
707
|
+
function Wr(e, r, t) {
|
|
708
708
|
ir.registerInCategory(e, r, t);
|
|
709
709
|
}
|
|
710
|
-
function
|
|
711
|
-
if (
|
|
710
|
+
function _r(e, r) {
|
|
711
|
+
if (Rt(e)) {
|
|
712
712
|
console.warn(
|
|
713
713
|
`[ReactaForm] Can't override builtin type field validation handler for type "${e}".`
|
|
714
714
|
);
|
|
@@ -716,41 +716,41 @@ function Wr(e, r) {
|
|
|
716
716
|
}
|
|
717
717
|
Fe.register(e, r);
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function T(e, r) {
|
|
720
720
|
Fe.register(e, r);
|
|
721
721
|
}
|
|
722
722
|
function sr(e, r) {
|
|
723
723
|
return ir.getFromCategory(e, r) || null;
|
|
724
724
|
}
|
|
725
725
|
function cr(e) {
|
|
726
|
-
return
|
|
726
|
+
return or.get(e) || null;
|
|
727
727
|
}
|
|
728
728
|
function lr(e) {
|
|
729
729
|
return Fe.get(e) || null;
|
|
730
730
|
}
|
|
731
|
-
function
|
|
731
|
+
function Kr(e) {
|
|
732
732
|
return (typeof e == "object" || typeof e == "function") && e !== null && typeof e.then == "function";
|
|
733
733
|
}
|
|
734
734
|
const He = /* @__PURE__ */ new Map(), Be = /* @__PURE__ */ new Map();
|
|
735
735
|
function ur(e, r, t, n) {
|
|
736
736
|
if (!r || !r.validationHandlerName)
|
|
737
737
|
return null;
|
|
738
|
-
let
|
|
738
|
+
let a, o;
|
|
739
739
|
if (typeof r.validationHandlerName == "string")
|
|
740
|
-
|
|
740
|
+
a = e, o = r.validationHandlerName;
|
|
741
741
|
else if (Array.isArray(r.validationHandlerName)) {
|
|
742
742
|
const [s, m] = r.validationHandlerName;
|
|
743
743
|
if (m)
|
|
744
|
-
|
|
744
|
+
a = s, o = m;
|
|
745
745
|
else if (s)
|
|
746
|
-
|
|
746
|
+
a = e, o = s;
|
|
747
747
|
else
|
|
748
748
|
return null;
|
|
749
749
|
} else
|
|
750
750
|
return null;
|
|
751
|
-
const c = `${
|
|
751
|
+
const c = `${a}:${o}`;
|
|
752
752
|
let i = He.get(c);
|
|
753
|
-
if (i === void 0 && (i = sr(
|
|
753
|
+
if (i === void 0 && (i = sr(a, o) || null, He.set(c, i)), i)
|
|
754
754
|
try {
|
|
755
755
|
return i(r.name, t, n) || null;
|
|
756
756
|
} catch (s) {
|
|
@@ -758,51 +758,51 @@ function ur(e, r, t, n) {
|
|
|
758
758
|
}
|
|
759
759
|
return null;
|
|
760
760
|
}
|
|
761
|
-
function
|
|
761
|
+
function Tn(e, r, t, n) {
|
|
762
762
|
return ur(e, r, t, n);
|
|
763
763
|
}
|
|
764
764
|
function mr(e, r, t, n) {
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
769
|
-
return
|
|
765
|
+
const a = lr(r.type);
|
|
766
|
+
if (a) {
|
|
767
|
+
const o = a(r, t, n);
|
|
768
|
+
if (o)
|
|
769
|
+
return o;
|
|
770
770
|
} else if (String(t ?? "").trim() === "")
|
|
771
771
|
return r.required ? n("Value required") : null;
|
|
772
772
|
return ur(e, r, t, n);
|
|
773
773
|
}
|
|
774
|
-
async function
|
|
774
|
+
async function Gr(e, r, t) {
|
|
775
775
|
if (!e || typeof e.validationHandlerName != "string")
|
|
776
776
|
return null;
|
|
777
777
|
const n = e.validationHandlerName;
|
|
778
|
-
let
|
|
779
|
-
if (
|
|
778
|
+
let a = Be.get(n);
|
|
779
|
+
if (a === void 0 && (a = cr(n) || null, Be.set(n, a)), a)
|
|
780
780
|
try {
|
|
781
|
-
const
|
|
782
|
-
return
|
|
783
|
-
} catch (
|
|
784
|
-
return [String(
|
|
781
|
+
const o = a(r, t);
|
|
782
|
+
return Kr(o) ? await o || null : o || null;
|
|
783
|
+
} catch (o) {
|
|
784
|
+
return [String(o instanceof Error ? o.message : o)];
|
|
785
785
|
}
|
|
786
786
|
return null;
|
|
787
787
|
}
|
|
788
788
|
function L(e, r) {
|
|
789
|
-
const { definitionName: t, t: n, fieldValidationMode:
|
|
789
|
+
const { definitionName: t, t: n, fieldValidationMode: a } = j();
|
|
790
790
|
return u.useCallback(
|
|
791
|
-
(
|
|
792
|
-
[t, e, n,
|
|
791
|
+
(o) => a === "realTime" ? mr(t, e, o, n) : r ?? null,
|
|
792
|
+
[t, e, n, a, r]
|
|
793
793
|
);
|
|
794
794
|
}
|
|
795
|
-
const
|
|
795
|
+
const Jr = ({
|
|
796
796
|
field: e,
|
|
797
797
|
value: r = !1,
|
|
798
798
|
onChange: t,
|
|
799
799
|
onError: n,
|
|
800
|
-
error:
|
|
800
|
+
error: a
|
|
801
801
|
}) => {
|
|
802
|
-
const { t:
|
|
802
|
+
const { t: o } = j(), i = L(e, a)(r);
|
|
803
803
|
u.useEffect(() => {
|
|
804
|
-
|
|
805
|
-
}, [i,
|
|
804
|
+
a || n?.(i);
|
|
805
|
+
}, [i, a, n]);
|
|
806
806
|
const s = u.useCallback(
|
|
807
807
|
(f) => {
|
|
808
808
|
t?.(f.target.checked);
|
|
@@ -830,7 +830,7 @@ const Gr = ({
|
|
|
830
830
|
className: R.label,
|
|
831
831
|
htmlFor: l,
|
|
832
832
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
833
|
-
children:
|
|
833
|
+
children: o(e.displayName)
|
|
834
834
|
}
|
|
835
835
|
),
|
|
836
836
|
/* @__PURE__ */ p(
|
|
@@ -860,24 +860,24 @@ const Gr = ({
|
|
|
860
860
|
) });
|
|
861
861
|
};
|
|
862
862
|
function _({ value: e, onChange: r, onError: t, validate: n }) {
|
|
863
|
-
const
|
|
863
|
+
const a = u.useRef(null), o = u.useRef(null), c = u.useRef(t), [i, s] = u.useState(null);
|
|
864
864
|
u.useEffect(() => {
|
|
865
865
|
c.current = t;
|
|
866
866
|
}, [t]), u.useEffect(() => {
|
|
867
867
|
const l = String(e ?? "");
|
|
868
|
-
if (!(document.activeElement ===
|
|
868
|
+
if (!(document.activeElement === a.current)) {
|
|
869
869
|
const d = n(l);
|
|
870
|
-
d !==
|
|
870
|
+
d !== o.current && (o.current = d, c.current?.(d ?? null), s(d)), a.current && a.current.value !== l && (a.current.value = l);
|
|
871
871
|
}
|
|
872
872
|
}, [e, n]);
|
|
873
873
|
const m = u.useCallback(
|
|
874
874
|
(l) => {
|
|
875
875
|
const f = l.target.value, d = n(f);
|
|
876
|
-
d !==
|
|
876
|
+
d !== o.current && (o.current = d, s(d), c.current?.(d ?? null)), r?.(f);
|
|
877
877
|
},
|
|
878
878
|
[r, n]
|
|
879
879
|
);
|
|
880
|
-
return { inputRef:
|
|
880
|
+
return { inputRef: a, error: i, handleChange: m };
|
|
881
881
|
}
|
|
882
882
|
const qe = [
|
|
883
883
|
{ label: "Black", value: "#000000" },
|
|
@@ -894,25 +894,25 @@ const qe = [
|
|
|
894
894
|
{ label: "Gray", value: "#808080" },
|
|
895
895
|
{ label: "Light Gray", value: "#d3d3d3" },
|
|
896
896
|
{ label: "Pink", value: "#ffc0cb" }
|
|
897
|
-
],
|
|
898
|
-
if (!e || !
|
|
897
|
+
], Yr = /^#([0-9A-F]{3}){1,2}$/i, Xr = "#000000", Zr = (e) => Yr.test(e), he = (e) => {
|
|
898
|
+
if (!e || !Zr(e)) return Xr;
|
|
899
899
|
const r = e.toLowerCase();
|
|
900
900
|
return r.length === 4 ? "#" + r.slice(1).split("").map((t) => t + t).join("") : r;
|
|
901
|
-
},
|
|
901
|
+
}, Qr = (e) => {
|
|
902
902
|
const r = parseInt(e.slice(1), 16);
|
|
903
903
|
return {
|
|
904
904
|
r: r >> 16 & 255,
|
|
905
905
|
g: r >> 8 & 255,
|
|
906
906
|
b: r & 255
|
|
907
907
|
};
|
|
908
|
-
},
|
|
908
|
+
}, et = ({
|
|
909
909
|
field: e,
|
|
910
910
|
value: r,
|
|
911
911
|
onChange: t,
|
|
912
912
|
onError: n,
|
|
913
|
-
error:
|
|
913
|
+
error: a
|
|
914
914
|
}) => {
|
|
915
|
-
const { t:
|
|
915
|
+
const { t: o } = j(), c = L(e, a), i = u.useMemo(
|
|
916
916
|
() => he(r),
|
|
917
917
|
[r]
|
|
918
918
|
), { inputRef: s, error: m, handleChange: l } = _({
|
|
@@ -922,31 +922,31 @@ const qe = [
|
|
|
922
922
|
validate: c
|
|
923
923
|
}), [f, d] = u.useState(i);
|
|
924
924
|
u.useEffect(() => {
|
|
925
|
-
|
|
926
|
-
}, [m,
|
|
925
|
+
a || n?.(m);
|
|
926
|
+
}, [m, a, n]), u.useEffect(() => {
|
|
927
927
|
d(i);
|
|
928
928
|
}, [i]);
|
|
929
929
|
const g = u.useCallback(
|
|
930
|
-
(
|
|
931
|
-
const x = he(
|
|
930
|
+
(N) => {
|
|
931
|
+
const x = he(N.target.value);
|
|
932
932
|
d(x), l({
|
|
933
933
|
target: { value: x }
|
|
934
934
|
});
|
|
935
935
|
},
|
|
936
936
|
[l]
|
|
937
937
|
), w = u.useCallback(
|
|
938
|
-
(
|
|
939
|
-
const x = he(
|
|
938
|
+
(N) => {
|
|
939
|
+
const x = he(N.target.value);
|
|
940
940
|
d(x), l({
|
|
941
941
|
target: { value: x }
|
|
942
942
|
});
|
|
943
943
|
},
|
|
944
944
|
[l]
|
|
945
945
|
), S = u.useMemo(
|
|
946
|
-
() => new Set(qe.map((
|
|
946
|
+
() => new Set(qe.map((N) => N.value)),
|
|
947
947
|
[]
|
|
948
948
|
).has(f), { r: v, g: k, b: $ } = u.useMemo(
|
|
949
|
-
() =>
|
|
949
|
+
() => Qr(f),
|
|
950
950
|
[f]
|
|
951
951
|
);
|
|
952
952
|
return /* @__PURE__ */ p(O, { field: e, error: m, children: /* @__PURE__ */ A(
|
|
@@ -971,7 +971,7 @@ const qe = [
|
|
|
971
971
|
),
|
|
972
972
|
"aria-invalid": !!m,
|
|
973
973
|
children: [
|
|
974
|
-
qe.map((
|
|
974
|
+
qe.map((N) => /* @__PURE__ */ p("option", { value: N.value, children: o(N.label) }, N.value)),
|
|
975
975
|
!S && /* @__PURE__ */ A("option", { value: f, children: [
|
|
976
976
|
"(",
|
|
977
977
|
v,
|
|
@@ -1024,26 +1024,26 @@ const qe = [
|
|
|
1024
1024
|
return Ue(e) ? e : "";
|
|
1025
1025
|
const t = Ue(e);
|
|
1026
1026
|
if (t) {
|
|
1027
|
-
const n = t.getUTCFullYear(),
|
|
1028
|
-
return `${n}-${
|
|
1027
|
+
const n = t.getUTCFullYear(), a = String(t.getUTCMonth() + 1).padStart(2, "0"), o = String(t.getUTCDate()).padStart(2, "0");
|
|
1028
|
+
return `${n}-${a}-${o}`;
|
|
1029
1029
|
}
|
|
1030
1030
|
return "";
|
|
1031
|
-
},
|
|
1031
|
+
}, rt = ({
|
|
1032
1032
|
field: e,
|
|
1033
1033
|
value: r,
|
|
1034
1034
|
onChange: t,
|
|
1035
1035
|
onError: n,
|
|
1036
|
-
error:
|
|
1036
|
+
error: a
|
|
1037
1037
|
}) => {
|
|
1038
|
-
const
|
|
1038
|
+
const o = L(e, a), c = We(r), { inputRef: i, error: s, handleChange: m } = _({
|
|
1039
1039
|
value: c,
|
|
1040
1040
|
onChange: t,
|
|
1041
1041
|
onError: n,
|
|
1042
|
-
validate:
|
|
1042
|
+
validate: o
|
|
1043
1043
|
});
|
|
1044
1044
|
return u.useEffect(() => {
|
|
1045
|
-
|
|
1046
|
-
}, [s,
|
|
1045
|
+
a || n?.(s);
|
|
1046
|
+
}, [s, a, n]), /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1047
1047
|
"input",
|
|
1048
1048
|
{
|
|
1049
1049
|
id: e.name,
|
|
@@ -1058,18 +1058,18 @@ const qe = [
|
|
|
1058
1058
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
1059
1059
|
}
|
|
1060
1060
|
) });
|
|
1061
|
-
},
|
|
1061
|
+
}, tt = ({
|
|
1062
1062
|
field: e,
|
|
1063
1063
|
value: r,
|
|
1064
1064
|
onChange: t,
|
|
1065
1065
|
onError: n,
|
|
1066
|
-
error:
|
|
1066
|
+
error: a
|
|
1067
1067
|
}) => {
|
|
1068
|
-
const { t:
|
|
1068
|
+
const { t: o, theme: c, formStyle: i, fieldStyle: s } = j(), m = u.useRef(null), l = u.useRef(n), [f, d] = u.useState(!1), [g, w] = u.useState(null);
|
|
1069
1069
|
u.useEffect(() => {
|
|
1070
1070
|
l.current = n;
|
|
1071
1071
|
}, [n]);
|
|
1072
|
-
const F = L(e,
|
|
1072
|
+
const F = L(e, a), [S, v] = u.useState(null), k = u.useRef(null);
|
|
1073
1073
|
u.useEffect(() => {
|
|
1074
1074
|
const y = String(r ?? "");
|
|
1075
1075
|
let C = F(y);
|
|
@@ -1083,16 +1083,16 @@ const qe = [
|
|
|
1083
1083
|
if (!m.current) return;
|
|
1084
1084
|
const y = m.current.getBoundingClientRect();
|
|
1085
1085
|
w({ x: y.left, y: y.bottom }), d((C) => !C);
|
|
1086
|
-
},
|
|
1086
|
+
}, N = (y) => {
|
|
1087
1087
|
const C = F(y);
|
|
1088
1088
|
C !== k.current && (k.current = C, v(C), l.current?.(C ?? null)), t?.(y), d(!1);
|
|
1089
1089
|
}, x = u.useMemo(() => {
|
|
1090
1090
|
const y = e.options.find((C) => String(C.value) === String(r));
|
|
1091
|
-
return y ?
|
|
1092
|
-
}, [e.options, r,
|
|
1091
|
+
return y ? o(y.label) : "";
|
|
1092
|
+
}, [e.options, r, o]), V = (y, C, E) => {
|
|
1093
1093
|
if (!C) return {};
|
|
1094
|
-
const
|
|
1095
|
-
return (E &&
|
|
1094
|
+
const M = y?.[C];
|
|
1095
|
+
return (E && M ? M[E] : void 0) ?? {};
|
|
1096
1096
|
}, b = u.useMemo(() => ({
|
|
1097
1097
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
1098
1098
|
display: "flex",
|
|
@@ -1136,33 +1136,33 @@ const qe = [
|
|
|
1136
1136
|
}
|
|
1137
1137
|
) }),
|
|
1138
1138
|
f && g && /* @__PURE__ */ p(
|
|
1139
|
-
|
|
1139
|
+
nt,
|
|
1140
1140
|
{
|
|
1141
1141
|
position: g,
|
|
1142
1142
|
options: e.options,
|
|
1143
1143
|
selectedValue: String(r),
|
|
1144
|
-
onSelect:
|
|
1144
|
+
onSelect: N,
|
|
1145
1145
|
onClose: () => d(!1),
|
|
1146
1146
|
controlRef: m,
|
|
1147
1147
|
theme: c,
|
|
1148
|
-
t:
|
|
1148
|
+
t: o
|
|
1149
1149
|
}
|
|
1150
1150
|
)
|
|
1151
1151
|
] });
|
|
1152
|
-
},
|
|
1152
|
+
}, nt = ({
|
|
1153
1153
|
position: e,
|
|
1154
1154
|
options: r,
|
|
1155
1155
|
selectedValue: t,
|
|
1156
1156
|
onSelect: n,
|
|
1157
|
-
onClose:
|
|
1158
|
-
controlRef:
|
|
1157
|
+
onClose: a,
|
|
1158
|
+
controlRef: o,
|
|
1159
1159
|
theme: c,
|
|
1160
1160
|
t: i
|
|
1161
1161
|
}) => {
|
|
1162
|
-
const s = u.useRef(null), [m, l] = u.useState(-1), { formStyle: f, fieldStyle: d } =
|
|
1162
|
+
const s = u.useRef(null), [m, l] = u.useState(-1), { formStyle: f, fieldStyle: d } = j(), g = fe(c ?? "light");
|
|
1163
1163
|
u.useLayoutEffect(() => {
|
|
1164
|
-
if (!
|
|
1165
|
-
const h =
|
|
1164
|
+
if (!o.current) return;
|
|
1165
|
+
const h = o.current.closest("[data-reactaform-theme]"), y = document.getElementById("popup-root");
|
|
1166
1166
|
if (h && y) {
|
|
1167
1167
|
const C = getComputedStyle(h);
|
|
1168
1168
|
y.style.setProperty(
|
|
@@ -1176,11 +1176,11 @@ const qe = [
|
|
|
1176
1176
|
C.getPropertyValue("--reactaform-hover-bg")
|
|
1177
1177
|
);
|
|
1178
1178
|
}
|
|
1179
|
-
}, [
|
|
1179
|
+
}, [o]);
|
|
1180
1180
|
const w = (h, y, C) => {
|
|
1181
1181
|
if (!y) return {};
|
|
1182
|
-
const
|
|
1183
|
-
return (C &&
|
|
1182
|
+
const I = h?.[y];
|
|
1183
|
+
return (C && I ? I[C] : void 0) ?? {};
|
|
1184
1184
|
}, F = u.useMemo(() => ({
|
|
1185
1185
|
maxHeight: 200,
|
|
1186
1186
|
overflowY: "auto",
|
|
@@ -1207,10 +1207,10 @@ const qe = [
|
|
|
1207
1207
|
u.useEffect(() => {
|
|
1208
1208
|
const h = (y) => {
|
|
1209
1209
|
const C = y.target;
|
|
1210
|
-
!s.current?.contains(C) && !
|
|
1210
|
+
!s.current?.contains(C) && !o.current?.contains(C) && a();
|
|
1211
1211
|
};
|
|
1212
1212
|
return document.addEventListener("mousedown", h), () => document.removeEventListener("mousedown", h);
|
|
1213
|
-
}, [
|
|
1213
|
+
}, [a, o]), u.useEffect(() => {
|
|
1214
1214
|
if (s.current && r.length > 0) {
|
|
1215
1215
|
const h = r.findIndex((y) => String(y.value) === t);
|
|
1216
1216
|
requestAnimationFrame(() => l(h >= 0 ? h : 0));
|
|
@@ -1220,25 +1220,25 @@ const qe = [
|
|
|
1220
1220
|
const h = s.current.querySelector(`#opt-${m}`);
|
|
1221
1221
|
h && requestAnimationFrame(() => h.focus());
|
|
1222
1222
|
}, [m]);
|
|
1223
|
-
const v = 250, k = 200, [$,
|
|
1223
|
+
const v = 250, k = 200, [$, N] = u.useState(null), [x, V] = u.useState(null);
|
|
1224
1224
|
if (u.useEffect(() => {
|
|
1225
1225
|
if (typeof window > "u") return;
|
|
1226
1226
|
const h = () => {
|
|
1227
|
-
let E = e.x,
|
|
1228
|
-
const P =
|
|
1227
|
+
let E = e.x, I = e.y, M = v;
|
|
1228
|
+
const P = o?.current;
|
|
1229
1229
|
if (P) {
|
|
1230
1230
|
const H = P.getBoundingClientRect();
|
|
1231
|
-
E = H.left,
|
|
1231
|
+
E = H.left, I = H.bottom, M = Math.max(80, Math.round(H.width));
|
|
1232
1232
|
}
|
|
1233
|
-
E = Math.min(E, window.innerWidth -
|
|
1233
|
+
E = Math.min(E, window.innerWidth - M), I = Math.min(I, window.innerHeight - k), N({ left: E, top: I }), V(M);
|
|
1234
1234
|
};
|
|
1235
1235
|
h(), window.addEventListener("scroll", h, !0), window.addEventListener("resize", h);
|
|
1236
1236
|
let y = null;
|
|
1237
|
-
const C =
|
|
1237
|
+
const C = o?.current;
|
|
1238
1238
|
return typeof ResizeObserver < "u" && C && (y = new ResizeObserver(() => h()), y.observe(C)), () => {
|
|
1239
1239
|
window.removeEventListener("scroll", h, !0), window.removeEventListener("resize", h), y && C && y.unobserve(C);
|
|
1240
1240
|
};
|
|
1241
|
-
}, [
|
|
1241
|
+
}, [o, e.x, e.y]), typeof window > "u") return null;
|
|
1242
1242
|
let b = document.getElementById("popup-root");
|
|
1243
1243
|
return b || (b = document.createElement("div"), b.id = "popup-root", document.body.appendChild(b)), me.createPortal(
|
|
1244
1244
|
/* @__PURE__ */ p(
|
|
@@ -1256,7 +1256,7 @@ const qe = [
|
|
|
1256
1256
|
},
|
|
1257
1257
|
"data-reactaform-theme": c ?? "light",
|
|
1258
1258
|
children: r.map((h, y) => {
|
|
1259
|
-
const C = String(h.value) === t, E = g ? "var(--reactaform-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-hover-bg, #eee)",
|
|
1259
|
+
const C = String(h.value) === t, E = g ? "var(--reactaform-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-hover-bg, #eee)", I = {
|
|
1260
1260
|
...S,
|
|
1261
1261
|
background: y === m ? E : S.background,
|
|
1262
1262
|
fontWeight: C ? "bold" : "normal"
|
|
@@ -1265,42 +1265,42 @@ const qe = [
|
|
|
1265
1265
|
"div",
|
|
1266
1266
|
{
|
|
1267
1267
|
id: `opt-${y}`,
|
|
1268
|
-
onMouseDown: (
|
|
1269
|
-
|
|
1268
|
+
onMouseDown: (M) => {
|
|
1269
|
+
M.stopPropagation(), n(String(h.value));
|
|
1270
1270
|
},
|
|
1271
|
-
onKeyDown: (
|
|
1271
|
+
onKeyDown: (M) => {
|
|
1272
1272
|
const P = r.length;
|
|
1273
|
-
switch (
|
|
1273
|
+
switch (M.key) {
|
|
1274
1274
|
case "ArrowDown":
|
|
1275
|
-
|
|
1275
|
+
M.preventDefault(), l((H) => (H + 1) % P);
|
|
1276
1276
|
break;
|
|
1277
1277
|
case "ArrowUp":
|
|
1278
|
-
|
|
1278
|
+
M.preventDefault(), l((H) => (H - 1 + P) % P);
|
|
1279
1279
|
break;
|
|
1280
1280
|
case "Home":
|
|
1281
|
-
|
|
1281
|
+
M.preventDefault(), l(0);
|
|
1282
1282
|
break;
|
|
1283
1283
|
case "End":
|
|
1284
|
-
|
|
1284
|
+
M.preventDefault(), l(P - 1);
|
|
1285
1285
|
break;
|
|
1286
1286
|
case "Enter":
|
|
1287
1287
|
case " ":
|
|
1288
|
-
|
|
1288
|
+
M.preventDefault(), M.stopPropagation(), n(String(h.value));
|
|
1289
1289
|
break;
|
|
1290
1290
|
case "Escape":
|
|
1291
|
-
|
|
1291
|
+
M.preventDefault(), a(), o?.current?.focus();
|
|
1292
1292
|
break;
|
|
1293
1293
|
}
|
|
1294
1294
|
},
|
|
1295
1295
|
tabIndex: y === m ? 0 : -1,
|
|
1296
1296
|
role: "option",
|
|
1297
1297
|
"aria-selected": C,
|
|
1298
|
-
style:
|
|
1299
|
-
onMouseEnter: (
|
|
1300
|
-
|
|
1298
|
+
style: I,
|
|
1299
|
+
onMouseEnter: (M) => {
|
|
1300
|
+
M.currentTarget.style.background = E, l(y);
|
|
1301
1301
|
},
|
|
1302
|
-
onMouseLeave: (
|
|
1303
|
-
|
|
1302
|
+
onMouseLeave: (M) => {
|
|
1303
|
+
M.currentTarget.style.background = "transparent", l((P) => P === y ? -1 : P);
|
|
1304
1304
|
},
|
|
1305
1305
|
children: i(h.label)
|
|
1306
1306
|
},
|
|
@@ -1311,18 +1311,18 @@ const qe = [
|
|
|
1311
1311
|
),
|
|
1312
1312
|
b
|
|
1313
1313
|
);
|
|
1314
|
-
},
|
|
1314
|
+
}, at = ({
|
|
1315
1315
|
field: e,
|
|
1316
1316
|
value: r,
|
|
1317
1317
|
onChange: t,
|
|
1318
1318
|
onError: n,
|
|
1319
|
-
error:
|
|
1319
|
+
error: a
|
|
1320
1320
|
}) => {
|
|
1321
|
-
const
|
|
1321
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
1322
1322
|
value: r,
|
|
1323
1323
|
onChange: t,
|
|
1324
1324
|
onError: n,
|
|
1325
|
-
validate:
|
|
1325
|
+
validate: o
|
|
1326
1326
|
});
|
|
1327
1327
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1328
1328
|
"input",
|
|
@@ -1338,10 +1338,10 @@ const qe = [
|
|
|
1338
1338
|
}
|
|
1339
1339
|
) });
|
|
1340
1340
|
}, ot = ({ field: e }) => {
|
|
1341
|
-
const { theme: r } =
|
|
1341
|
+
const { theme: r } = j(), {
|
|
1342
1342
|
color: t = fe(r) ? "#444444" : "#CCCCCC",
|
|
1343
1343
|
thickness: n = 1,
|
|
1344
|
-
margin:
|
|
1344
|
+
margin: a = "8px 0"
|
|
1345
1345
|
} = e;
|
|
1346
1346
|
return /* @__PURE__ */ p(
|
|
1347
1347
|
"div",
|
|
@@ -1351,18 +1351,18 @@ const qe = [
|
|
|
1351
1351
|
height: "0",
|
|
1352
1352
|
// ensures only 1 line
|
|
1353
1353
|
borderTop: `${n}px solid ${t}`,
|
|
1354
|
-
margin:
|
|
1354
|
+
margin: a
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
1357
|
);
|
|
1358
|
-
},
|
|
1359
|
-
const { t:
|
|
1358
|
+
}, it = ({ field: e, value: r, onChange: t, onError: n, error: a }) => {
|
|
1359
|
+
const { t: o } = j(), [c, i] = u.useState(!1), s = u.useRef(null), m = u.useRef(n), l = u.useRef(null), [f, d] = u.useState(null);
|
|
1360
1360
|
u.useEffect(() => {
|
|
1361
1361
|
m.current = n;
|
|
1362
1362
|
}, [n]);
|
|
1363
1363
|
const g = (x, V) => V.some(
|
|
1364
1364
|
(b) => b.name === x.name && b.size === x.size && b.lastModified === x.lastModified
|
|
1365
|
-
), w = L(e,
|
|
1365
|
+
), w = L(e, a);
|
|
1366
1366
|
u.useEffect(() => {
|
|
1367
1367
|
const x = w(r ?? []);
|
|
1368
1368
|
t?.(r), x !== l.current && (l.current = x, d(x), m.current?.(x ?? null));
|
|
@@ -1373,7 +1373,7 @@ const qe = [
|
|
|
1373
1373
|
if (V && V.length > 0) {
|
|
1374
1374
|
const y = Array.from(V);
|
|
1375
1375
|
if (e.multiple) {
|
|
1376
|
-
const C = Array.isArray(r) ? r : [], E = y.filter((
|
|
1376
|
+
const C = Array.isArray(r) ? r : [], E = y.filter((I) => !g(I, C));
|
|
1377
1377
|
b = [...C, ...E];
|
|
1378
1378
|
} else
|
|
1379
1379
|
b = y[0];
|
|
@@ -1387,7 +1387,7 @@ const qe = [
|
|
|
1387
1387
|
const b = Array.from(V);
|
|
1388
1388
|
let h = null;
|
|
1389
1389
|
if (e.multiple) {
|
|
1390
|
-
const C = Array.isArray(r) ? r : [], E = b.filter((
|
|
1390
|
+
const C = Array.isArray(r) ? r : [], E = b.filter((I) => !g(I, C));
|
|
1391
1391
|
h = [...C, ...E];
|
|
1392
1392
|
} else
|
|
1393
1393
|
h = b[0];
|
|
@@ -1406,7 +1406,7 @@ const qe = [
|
|
|
1406
1406
|
const V = w([]);
|
|
1407
1407
|
V !== l.current && (l.current = V, d(V), m.current?.(V ?? null)), t?.(null);
|
|
1408
1408
|
}
|
|
1409
|
-
},
|
|
1409
|
+
}, N = () => {
|
|
1410
1410
|
const x = Array.isArray(r) ? r : r ? [r] : [];
|
|
1411
1411
|
return x.length === 0 ? null : /* @__PURE__ */ p("div", { style: {
|
|
1412
1412
|
marginTop: "8px",
|
|
@@ -1447,7 +1447,7 @@ const qe = [
|
|
|
1447
1447
|
{
|
|
1448
1448
|
type: "button",
|
|
1449
1449
|
onClick: () => $(Array.isArray(r) ? b : void 0),
|
|
1450
|
-
"aria-label":
|
|
1450
|
+
"aria-label": o("Remove file"),
|
|
1451
1451
|
style: {
|
|
1452
1452
|
background: "transparent",
|
|
1453
1453
|
border: "none",
|
|
@@ -1508,7 +1508,7 @@ const qe = [
|
|
|
1508
1508
|
(x.key === "Enter" || x.key === " ") && (x.preventDefault(), s.current?.click());
|
|
1509
1509
|
},
|
|
1510
1510
|
role: "button",
|
|
1511
|
-
"aria-label": e.multiple ?
|
|
1511
|
+
"aria-label": e.multiple ? o("Choose Files or Drag & Drop") : o("Choose File or Drag & Drop"),
|
|
1512
1512
|
"aria-invalid": !!f,
|
|
1513
1513
|
"aria-describedby": f ? `${e.name}-error` : void 0,
|
|
1514
1514
|
children: [
|
|
@@ -1538,7 +1538,7 @@ const qe = [
|
|
|
1538
1538
|
color: "var(--reactaform-text-color, #111827)",
|
|
1539
1539
|
flex: 1,
|
|
1540
1540
|
textAlign: "left"
|
|
1541
|
-
}, children: c ?
|
|
1541
|
+
}, children: c ? o("Drop files here") : e.multiple ? o("Choose Files or Drag & Drop") : o("Choose File or Drag & Drop") }),
|
|
1542
1542
|
e.accept && /* @__PURE__ */ p("div", { style: {
|
|
1543
1543
|
fontSize: "0.75rem",
|
|
1544
1544
|
color: "var(--reactaform-text-muted, #6b7280)",
|
|
@@ -1550,20 +1550,20 @@ const qe = [
|
|
|
1550
1550
|
]
|
|
1551
1551
|
}
|
|
1552
1552
|
),
|
|
1553
|
-
|
|
1553
|
+
N()
|
|
1554
1554
|
] }) });
|
|
1555
|
-
},
|
|
1555
|
+
}, st = ({
|
|
1556
1556
|
field: e,
|
|
1557
1557
|
value: r,
|
|
1558
1558
|
onChange: t,
|
|
1559
1559
|
onError: n,
|
|
1560
|
-
error:
|
|
1560
|
+
error: a
|
|
1561
1561
|
}) => {
|
|
1562
|
-
const
|
|
1562
|
+
const o = L(e, a), c = Array.isArray(r) ? r.join(", ") : String(r ?? ""), { inputRef: i, error: s, handleChange: m } = _({
|
|
1563
1563
|
value: c,
|
|
1564
1564
|
onChange: t,
|
|
1565
1565
|
onError: n,
|
|
1566
|
-
validate:
|
|
1566
|
+
validate: o
|
|
1567
1567
|
});
|
|
1568
1568
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1569
1569
|
"input",
|
|
@@ -1579,19 +1579,19 @@ const qe = [
|
|
|
1579
1579
|
"aria-describedby": s ? `${e.name}-error` : void 0
|
|
1580
1580
|
}
|
|
1581
1581
|
) });
|
|
1582
|
-
},
|
|
1582
|
+
}, ct = ({
|
|
1583
1583
|
field: e,
|
|
1584
1584
|
value: r,
|
|
1585
1585
|
onChange: t,
|
|
1586
1586
|
onError: n,
|
|
1587
|
-
error:
|
|
1587
|
+
error: a
|
|
1588
1588
|
}) => {
|
|
1589
|
-
const
|
|
1589
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
1590
1590
|
value: r,
|
|
1591
1591
|
onChange: t,
|
|
1592
1592
|
onError: n,
|
|
1593
|
-
validate:
|
|
1594
|
-
}), m =
|
|
1593
|
+
validate: o
|
|
1594
|
+
}), m = a ?? i;
|
|
1595
1595
|
return /* @__PURE__ */ p(O, { field: e, error: m, children: /* @__PURE__ */ p(
|
|
1596
1596
|
"input",
|
|
1597
1597
|
{
|
|
@@ -1609,7 +1609,7 @@ const qe = [
|
|
|
1609
1609
|
}
|
|
1610
1610
|
) });
|
|
1611
1611
|
};
|
|
1612
|
-
function
|
|
1612
|
+
function lt() {
|
|
1613
1613
|
try {
|
|
1614
1614
|
return "/";
|
|
1615
1615
|
} catch {
|
|
@@ -1621,22 +1621,22 @@ function ct() {
|
|
|
1621
1621
|
}
|
|
1622
1622
|
return "/";
|
|
1623
1623
|
}
|
|
1624
|
-
const
|
|
1625
|
-
const { language: t, t: n } =
|
|
1624
|
+
const ut = ({ field: e, value: r }) => {
|
|
1625
|
+
const { language: t, t: n } = j(), a = e.alignment || "center", o = {
|
|
1626
1626
|
left: "flex-start",
|
|
1627
1627
|
center: "center",
|
|
1628
1628
|
right: "flex-end"
|
|
1629
1629
|
}, c = typeof r == "string" ? r : "";
|
|
1630
1630
|
let i = c && c.trim() !== "" ? c : typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
1631
|
-
i && !i.startsWith("/") && (i = `${
|
|
1631
|
+
i && !i.startsWith("/") && (i = `${lt()}${i}`);
|
|
1632
1632
|
const s = e.localized?.split(";").map((S) => S.trim()), [m, l] = u.useState(i || ""), f = u.useRef(i || null);
|
|
1633
1633
|
if (u.useEffect(() => {
|
|
1634
1634
|
if (!i) return;
|
|
1635
1635
|
const S = i.split("/"), v = S.pop(), k = v.lastIndexOf(".");
|
|
1636
1636
|
if (k === -1) return;
|
|
1637
|
-
const $ = v.substring(0, k),
|
|
1637
|
+
const $ = v.substring(0, k), N = v.substring(k);
|
|
1638
1638
|
let x = null;
|
|
1639
|
-
s?.includes(t) && (x = `${$}_${t}${
|
|
1639
|
+
s?.includes(t) && (x = `${$}_${t}${N}`);
|
|
1640
1640
|
const V = new AbortController();
|
|
1641
1641
|
if (x) {
|
|
1642
1642
|
const b = [...S, x].join("/");
|
|
@@ -1666,7 +1666,7 @@ const lt = ({ field: e, value: r }) => {
|
|
|
1666
1666
|
"data-testid": "image-wrapper",
|
|
1667
1667
|
style: {
|
|
1668
1668
|
display: "flex",
|
|
1669
|
-
justifyContent: a
|
|
1669
|
+
justifyContent: o[a] || "center",
|
|
1670
1670
|
margin: "0 0"
|
|
1671
1671
|
},
|
|
1672
1672
|
children: /* @__PURE__ */ p(
|
|
@@ -1680,18 +1680,18 @@ const lt = ({ field: e, value: r }) => {
|
|
|
1680
1680
|
)
|
|
1681
1681
|
}
|
|
1682
1682
|
) });
|
|
1683
|
-
},
|
|
1683
|
+
}, mt = ({
|
|
1684
1684
|
field: e,
|
|
1685
1685
|
value: r,
|
|
1686
1686
|
onChange: t,
|
|
1687
1687
|
onError: n,
|
|
1688
|
-
error:
|
|
1688
|
+
error: a
|
|
1689
1689
|
}) => {
|
|
1690
|
-
const
|
|
1690
|
+
const o = L(e, a), c = Array.isArray(r) ? r.join(", ") : String(r ?? ""), { inputRef: i, error: s, handleChange: m } = _({
|
|
1691
1691
|
value: c,
|
|
1692
1692
|
onChange: t,
|
|
1693
1693
|
onError: n,
|
|
1694
|
-
validate:
|
|
1694
|
+
validate: o
|
|
1695
1695
|
});
|
|
1696
1696
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1697
1697
|
"input",
|
|
@@ -1712,13 +1712,13 @@ const lt = ({ field: e, value: r }) => {
|
|
|
1712
1712
|
value: r,
|
|
1713
1713
|
onChange: t,
|
|
1714
1714
|
onError: n,
|
|
1715
|
-
error:
|
|
1715
|
+
error: a
|
|
1716
1716
|
}) => {
|
|
1717
|
-
const
|
|
1717
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
1718
1718
|
value: r,
|
|
1719
1719
|
onChange: t,
|
|
1720
1720
|
onError: n,
|
|
1721
|
-
validate:
|
|
1721
|
+
validate: o
|
|
1722
1722
|
});
|
|
1723
1723
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1724
1724
|
"input",
|
|
@@ -1735,18 +1735,18 @@ const lt = ({ field: e, value: r }) => {
|
|
|
1735
1735
|
) });
|
|
1736
1736
|
};
|
|
1737
1737
|
fr.displayName = "IntegerInput";
|
|
1738
|
-
const
|
|
1738
|
+
const ft = u.memo(fr), dt = ({
|
|
1739
1739
|
field: e,
|
|
1740
1740
|
value: r,
|
|
1741
1741
|
onChange: t,
|
|
1742
1742
|
onError: n,
|
|
1743
|
-
error:
|
|
1743
|
+
error: a
|
|
1744
1744
|
}) => {
|
|
1745
|
-
const
|
|
1745
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
1746
1746
|
value: r,
|
|
1747
1747
|
onChange: t,
|
|
1748
1748
|
onError: n,
|
|
1749
|
-
validate:
|
|
1749
|
+
validate: o
|
|
1750
1750
|
});
|
|
1751
1751
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1752
1752
|
"textarea",
|
|
@@ -1766,41 +1766,41 @@ const mt = u.memo(fr), ft = ({
|
|
|
1766
1766
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
1767
1767
|
}
|
|
1768
1768
|
) });
|
|
1769
|
-
},
|
|
1769
|
+
}, pt = ({
|
|
1770
1770
|
field: e,
|
|
1771
1771
|
value: r,
|
|
1772
1772
|
onChange: t,
|
|
1773
1773
|
onError: n,
|
|
1774
|
-
error:
|
|
1774
|
+
error: a
|
|
1775
1775
|
}) => {
|
|
1776
|
-
const
|
|
1776
|
+
const o = u.useRef(
|
|
1777
1777
|
n
|
|
1778
1778
|
);
|
|
1779
1779
|
u.useEffect(() => {
|
|
1780
|
-
|
|
1780
|
+
o.current = n;
|
|
1781
1781
|
}, [n]);
|
|
1782
|
-
const { t: c, theme: i, formStyle: s, fieldStyle: m } =
|
|
1783
|
-
if (!
|
|
1784
|
-
const H = E?.[
|
|
1785
|
-
return (
|
|
1782
|
+
const { t: c, theme: i, formStyle: s, fieldStyle: m } = j(), l = (E, I, M) => {
|
|
1783
|
+
if (!I) return {};
|
|
1784
|
+
const H = E?.[I];
|
|
1785
|
+
return (M && H ? H[M] : void 0) ?? {};
|
|
1786
1786
|
}, f = u.useRef(null), [d, g] = u.useState(!1), [w, F] = u.useState(null), S = u.useMemo(
|
|
1787
1787
|
() => e.options.map((E) => ({ value: E.value, label: c(E.label) })),
|
|
1788
1788
|
[e.options, c]
|
|
1789
1789
|
), v = u.useMemo(() => {
|
|
1790
|
-
const E = Array.isArray(r) ? r : [],
|
|
1791
|
-
return E.filter((
|
|
1792
|
-
}, [r, S]), k = L(e,
|
|
1790
|
+
const E = Array.isArray(r) ? r : [], I = new Set(S.map((M) => M.value));
|
|
1791
|
+
return E.filter((M) => I.has(M));
|
|
1792
|
+
}, [r, S]), k = L(e, a), [$, N] = u.useState(null), x = u.useRef(null);
|
|
1793
1793
|
u.useEffect(() => {
|
|
1794
1794
|
const E = k(Array.isArray(r) ? r : []);
|
|
1795
|
-
E !== x.current && (x.current = E,
|
|
1795
|
+
E !== x.current && (x.current = E, N(E), o.current?.(E ?? null));
|
|
1796
1796
|
}, [r, k]);
|
|
1797
1797
|
const V = () => {
|
|
1798
1798
|
if (!f.current) return;
|
|
1799
1799
|
const E = f.current.getBoundingClientRect();
|
|
1800
|
-
F({ x: E.left, y: E.bottom }), g((
|
|
1800
|
+
F({ x: E.left, y: E.bottom }), g((I) => !I);
|
|
1801
1801
|
}, b = (E) => {
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1802
|
+
const I = v.includes(E) ? v.filter((P) => P !== E) : [...v, E], M = k(I);
|
|
1803
|
+
M !== x.current && (x.current = M, N(M), o.current?.(M ?? null)), t?.(I);
|
|
1804
1804
|
}, h = u.useMemo(
|
|
1805
1805
|
() => ({
|
|
1806
1806
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
@@ -1888,7 +1888,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
1888
1888
|
}
|
|
1889
1889
|
) }) }),
|
|
1890
1890
|
d && w && /* @__PURE__ */ p(
|
|
1891
|
-
|
|
1891
|
+
gt,
|
|
1892
1892
|
{
|
|
1893
1893
|
position: w,
|
|
1894
1894
|
options: S,
|
|
@@ -1900,19 +1900,19 @@ const mt = u.memo(fr), ft = ({
|
|
|
1900
1900
|
}
|
|
1901
1901
|
)
|
|
1902
1902
|
] });
|
|
1903
|
-
},
|
|
1903
|
+
}, gt = ({
|
|
1904
1904
|
position: e,
|
|
1905
1905
|
options: r,
|
|
1906
1906
|
selectedValues: t,
|
|
1907
1907
|
onToggleOption: n,
|
|
1908
|
-
onClose:
|
|
1909
|
-
controlRef:
|
|
1908
|
+
onClose: a,
|
|
1909
|
+
controlRef: o,
|
|
1910
1910
|
theme: c
|
|
1911
1911
|
}) => {
|
|
1912
|
-
const i = u.useRef(null), [s, m] = u.useState(-1), { formStyle: l, fieldStyle: f } =
|
|
1912
|
+
const i = u.useRef(null), [s, m] = u.useState(-1), { formStyle: l, fieldStyle: f } = j(), d = fe(c ?? "light");
|
|
1913
1913
|
u.useLayoutEffect(() => {
|
|
1914
|
-
if (!
|
|
1915
|
-
const b =
|
|
1914
|
+
if (!o.current) return;
|
|
1915
|
+
const b = o.current.closest("[data-reactaform-theme]"), h = document.getElementById("popup-root");
|
|
1916
1916
|
if (b && h) {
|
|
1917
1917
|
const y = getComputedStyle(b);
|
|
1918
1918
|
h.style.setProperty(
|
|
@@ -1926,7 +1926,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
1926
1926
|
y.getPropertyValue("--reactaform-hover-bg")
|
|
1927
1927
|
);
|
|
1928
1928
|
}
|
|
1929
|
-
}, [
|
|
1929
|
+
}, [o]);
|
|
1930
1930
|
const g = (b, h, y) => {
|
|
1931
1931
|
if (!h) return {};
|
|
1932
1932
|
const E = b?.[h];
|
|
@@ -1963,10 +1963,10 @@ const mt = u.memo(fr), ft = ({
|
|
|
1963
1963
|
u.useEffect(() => {
|
|
1964
1964
|
const b = (h) => {
|
|
1965
1965
|
const y = h.target;
|
|
1966
|
-
!i.current?.contains(y) && !
|
|
1966
|
+
!i.current?.contains(y) && !o.current?.contains(y) && a();
|
|
1967
1967
|
};
|
|
1968
1968
|
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
1969
|
-
}, [
|
|
1969
|
+
}, [a, o]), u.useEffect(() => {
|
|
1970
1970
|
i.current && r.length > 0 && requestAnimationFrame(
|
|
1971
1971
|
() => m((b) => b === -1 ? 0 : b)
|
|
1972
1972
|
);
|
|
@@ -1977,25 +1977,25 @@ const mt = u.memo(fr), ft = ({
|
|
|
1977
1977
|
);
|
|
1978
1978
|
b && requestAnimationFrame(() => b.focus());
|
|
1979
1979
|
}, [s]);
|
|
1980
|
-
const S = 250, v = 200, [k, $] = u.useState(null), [
|
|
1980
|
+
const S = 250, v = 200, [k, $] = u.useState(null), [N, x] = u.useState(null);
|
|
1981
1981
|
if (u.useEffect(() => {
|
|
1982
1982
|
if (typeof window > "u") return;
|
|
1983
1983
|
const b = () => {
|
|
1984
|
-
let C = e.x, E = e.y,
|
|
1985
|
-
const
|
|
1986
|
-
if (
|
|
1987
|
-
const P =
|
|
1988
|
-
C = P.left, E = P.bottom,
|
|
1984
|
+
let C = e.x, E = e.y, I = S;
|
|
1985
|
+
const M = o?.current;
|
|
1986
|
+
if (M) {
|
|
1987
|
+
const P = M.getBoundingClientRect();
|
|
1988
|
+
C = P.left, E = P.bottom, I = Math.max(80, Math.round(P.width));
|
|
1989
1989
|
}
|
|
1990
|
-
C = Math.min(C, window.innerWidth -
|
|
1990
|
+
C = Math.min(C, window.innerWidth - I), E = Math.min(E, window.innerHeight - v), $({ left: C, top: E }), x(I);
|
|
1991
1991
|
};
|
|
1992
1992
|
b(), window.addEventListener("scroll", b, !0), window.addEventListener("resize", b);
|
|
1993
1993
|
let h = null;
|
|
1994
|
-
const y =
|
|
1994
|
+
const y = o?.current;
|
|
1995
1995
|
return typeof ResizeObserver < "u" && y && (h = new ResizeObserver(() => b()), h.observe(y)), () => {
|
|
1996
1996
|
window.removeEventListener("scroll", b, !0), window.removeEventListener("resize", b), h && y && h.unobserve(y);
|
|
1997
1997
|
};
|
|
1998
|
-
}, [
|
|
1998
|
+
}, [o, e.x, e.y]), typeof window > "u") return null;
|
|
1999
1999
|
let V = document.getElementById("popup-root");
|
|
2000
2000
|
return V || (V = document.createElement("div"), V.id = "popup-root", document.body.appendChild(V)), me.createPortal(
|
|
2001
2001
|
/* @__PURE__ */ p(
|
|
@@ -2008,7 +2008,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
2008
2008
|
position: "fixed",
|
|
2009
2009
|
top: k ? k.top : e.y,
|
|
2010
2010
|
left: k ? k.left : e.x,
|
|
2011
|
-
width:
|
|
2011
|
+
width: N ?? S,
|
|
2012
2012
|
// spread the static popup styles
|
|
2013
2013
|
...w
|
|
2014
2014
|
},
|
|
@@ -2022,30 +2022,30 @@ const mt = u.memo(fr), ft = ({
|
|
|
2022
2022
|
"div",
|
|
2023
2023
|
{
|
|
2024
2024
|
id: `multi-opt-${h}`,
|
|
2025
|
-
onMouseDown: (
|
|
2026
|
-
|
|
2025
|
+
onMouseDown: (I) => {
|
|
2026
|
+
I.stopPropagation(), n(b.value);
|
|
2027
2027
|
},
|
|
2028
|
-
onKeyDown: (
|
|
2029
|
-
const
|
|
2030
|
-
switch (
|
|
2028
|
+
onKeyDown: (I) => {
|
|
2029
|
+
const M = r.length;
|
|
2030
|
+
switch (I.key) {
|
|
2031
2031
|
case "ArrowDown":
|
|
2032
|
-
|
|
2032
|
+
I.preventDefault(), m((P) => (P + 1) % M);
|
|
2033
2033
|
break;
|
|
2034
2034
|
case "ArrowUp":
|
|
2035
|
-
|
|
2035
|
+
I.preventDefault(), m((P) => (P - 1 + M) % M);
|
|
2036
2036
|
break;
|
|
2037
2037
|
case "Home":
|
|
2038
|
-
|
|
2038
|
+
I.preventDefault(), m(0);
|
|
2039
2039
|
break;
|
|
2040
2040
|
case "End":
|
|
2041
|
-
|
|
2041
|
+
I.preventDefault(), m(M - 1);
|
|
2042
2042
|
break;
|
|
2043
2043
|
case "Enter":
|
|
2044
2044
|
case " ":
|
|
2045
|
-
|
|
2045
|
+
I.preventDefault(), I.stopPropagation(), n(b.value);
|
|
2046
2046
|
break;
|
|
2047
2047
|
case "Escape":
|
|
2048
|
-
|
|
2048
|
+
I.preventDefault(), a(), o?.current?.focus();
|
|
2049
2049
|
break;
|
|
2050
2050
|
}
|
|
2051
2051
|
},
|
|
@@ -2053,11 +2053,11 @@ const mt = u.memo(fr), ft = ({
|
|
|
2053
2053
|
role: "option",
|
|
2054
2054
|
"aria-selected": y,
|
|
2055
2055
|
style: E,
|
|
2056
|
-
onMouseEnter: (
|
|
2057
|
-
|
|
2056
|
+
onMouseEnter: (I) => {
|
|
2057
|
+
I.currentTarget.style.background = C, m(h);
|
|
2058
2058
|
},
|
|
2059
|
-
onMouseLeave: (
|
|
2060
|
-
|
|
2059
|
+
onMouseLeave: (I) => {
|
|
2060
|
+
I.currentTarget.style.background = "transparent", m((M) => M === h ? -1 : M);
|
|
2061
2061
|
},
|
|
2062
2062
|
children: [
|
|
2063
2063
|
/* @__PURE__ */ p(
|
|
@@ -2086,18 +2086,18 @@ const mt = u.memo(fr), ft = ({
|
|
|
2086
2086
|
),
|
|
2087
2087
|
V
|
|
2088
2088
|
);
|
|
2089
|
-
},
|
|
2089
|
+
}, ht = ({
|
|
2090
2090
|
field: e,
|
|
2091
2091
|
value: r,
|
|
2092
2092
|
onChange: t,
|
|
2093
2093
|
onError: n,
|
|
2094
|
-
error:
|
|
2094
|
+
error: a
|
|
2095
2095
|
}) => {
|
|
2096
|
-
const
|
|
2096
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
2097
2097
|
value: String(r ?? ""),
|
|
2098
2098
|
onChange: t,
|
|
2099
2099
|
onError: n,
|
|
2100
|
-
validate:
|
|
2100
|
+
validate: o
|
|
2101
2101
|
}), m = Math.max(1, Math.round(e.step ?? 1));
|
|
2102
2102
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
2103
2103
|
"input",
|
|
@@ -2119,18 +2119,18 @@ const mt = u.memo(fr), ft = ({
|
|
|
2119
2119
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
2120
2120
|
}
|
|
2121
2121
|
) });
|
|
2122
|
-
},
|
|
2122
|
+
}, yt = ({
|
|
2123
2123
|
field: e,
|
|
2124
2124
|
value: r,
|
|
2125
2125
|
onChange: t,
|
|
2126
2126
|
onError: n,
|
|
2127
|
-
error:
|
|
2127
|
+
error: a
|
|
2128
2128
|
}) => {
|
|
2129
|
-
const
|
|
2129
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
2130
2130
|
value: r,
|
|
2131
2131
|
onChange: t,
|
|
2132
2132
|
onError: n,
|
|
2133
|
-
validate:
|
|
2133
|
+
validate: o
|
|
2134
2134
|
});
|
|
2135
2135
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
2136
2136
|
"input",
|
|
@@ -2145,14 +2145,14 @@ const mt = u.memo(fr), ft = ({
|
|
|
2145
2145
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
2146
2146
|
}
|
|
2147
2147
|
) });
|
|
2148
|
-
},
|
|
2148
|
+
}, bt = ({
|
|
2149
2149
|
field: e,
|
|
2150
2150
|
value: r,
|
|
2151
2151
|
onChange: t,
|
|
2152
2152
|
onError: n,
|
|
2153
|
-
error:
|
|
2153
|
+
error: a
|
|
2154
2154
|
}) => {
|
|
2155
|
-
const { t:
|
|
2155
|
+
const { t: o } = j(), c = L(e, a), i = e.layout?.toLowerCase() === "horizontal" ? "row" : "column", s = u.useRef(null), m = u.useRef(n);
|
|
2156
2156
|
u.useEffect(() => {
|
|
2157
2157
|
m.current = n;
|
|
2158
2158
|
}, [n]);
|
|
@@ -2166,8 +2166,8 @@ const mt = u.memo(fr), ft = ({
|
|
|
2166
2166
|
const v = r != null ? String(r) : "", k = c(v);
|
|
2167
2167
|
if (k && e.options.length > 0) {
|
|
2168
2168
|
const $ = String(e.options[0].value);
|
|
2169
|
-
t?.($), s.current?.querySelectorAll("input[type=radio]").forEach((
|
|
2170
|
-
|
|
2169
|
+
t?.($), s.current?.querySelectorAll("input[type=radio]").forEach((N) => {
|
|
2170
|
+
N.checked = N.value === $;
|
|
2171
2171
|
});
|
|
2172
2172
|
}
|
|
2173
2173
|
g(k);
|
|
@@ -2231,7 +2231,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
2231
2231
|
flex: i === "column" ? 1 : void 0,
|
|
2232
2232
|
fontWeight: 400
|
|
2233
2233
|
},
|
|
2234
|
-
children:
|
|
2234
|
+
children: o(v.label)
|
|
2235
2235
|
}
|
|
2236
2236
|
)
|
|
2237
2237
|
]
|
|
@@ -2241,10 +2241,10 @@ const mt = u.memo(fr), ft = ({
|
|
|
2241
2241
|
})
|
|
2242
2242
|
}
|
|
2243
2243
|
) });
|
|
2244
|
-
},
|
|
2244
|
+
}, vt = {
|
|
2245
2245
|
display: "flex",
|
|
2246
2246
|
gap: 4
|
|
2247
|
-
},
|
|
2247
|
+
}, xt = {
|
|
2248
2248
|
cursor: "pointer",
|
|
2249
2249
|
fontSize: "1.5rem",
|
|
2250
2250
|
lineHeight: 1,
|
|
@@ -2252,8 +2252,8 @@ const mt = u.memo(fr), ft = ({
|
|
|
2252
2252
|
marginRight: "0.25rem",
|
|
2253
2253
|
userSelect: "none",
|
|
2254
2254
|
transition: "color 0.12s ease"
|
|
2255
|
-
},
|
|
2256
|
-
const { t:
|
|
2255
|
+
}, wt = ({ field: e, value: r, onChange: t, onError: n, error: a }) => {
|
|
2256
|
+
const { t: o } = j(), c = L(e, a), i = e.max ?? 5, s = e.icon?.trim() || "★", [m, l] = u.useState(null), f = u.useRef([]), d = u.useMemo(() => Math.min(Math.max(r ?? 0, 0), i), [r, i]), g = u.useMemo(() => c(d) ?? null, [c, d]);
|
|
2257
2257
|
u.useEffect(() => {
|
|
2258
2258
|
n?.(g);
|
|
2259
2259
|
}, [g, n]);
|
|
@@ -2289,9 +2289,9 @@ const mt = u.memo(fr), ft = ({
|
|
|
2289
2289
|
"aria-labelledby": `${e.name}-label`,
|
|
2290
2290
|
"aria-invalid": !!g,
|
|
2291
2291
|
"aria-describedby": g ? `${e.name}-error` : void 0,
|
|
2292
|
-
style:
|
|
2292
|
+
style: vt,
|
|
2293
2293
|
children: Array.from({ length: i }, (S, v) => {
|
|
2294
|
-
const k = v < d,
|
|
2294
|
+
const k = v < d, N = m !== null && v <= m || k ? "gold" : "lightgray";
|
|
2295
2295
|
return /* @__PURE__ */ p(
|
|
2296
2296
|
"span",
|
|
2297
2297
|
{
|
|
@@ -2300,12 +2300,12 @@ const mt = u.memo(fr), ft = ({
|
|
|
2300
2300
|
tabIndex: d > 0 ? v === d - 1 ? 0 : -1 : v === 0 ? 0 : -1,
|
|
2301
2301
|
"aria-checked": k,
|
|
2302
2302
|
"aria-label": `Rating ${v + 1}`,
|
|
2303
|
-
title:
|
|
2303
|
+
title: o(`${e.displayName} ${v + 1}`),
|
|
2304
2304
|
onClick: () => w(v + 1),
|
|
2305
2305
|
onKeyDown: (x) => F(x, v),
|
|
2306
2306
|
onMouseEnter: () => l(v),
|
|
2307
2307
|
onMouseLeave: () => l(null),
|
|
2308
|
-
style: { ...
|
|
2308
|
+
style: { ...xt, color: N },
|
|
2309
2309
|
children: s
|
|
2310
2310
|
},
|
|
2311
2311
|
v
|
|
@@ -2313,14 +2313,14 @@ const mt = u.memo(fr), ft = ({
|
|
|
2313
2313
|
})
|
|
2314
2314
|
}
|
|
2315
2315
|
) });
|
|
2316
|
-
},
|
|
2316
|
+
}, St = ({
|
|
2317
2317
|
field: e,
|
|
2318
2318
|
value: r,
|
|
2319
2319
|
onChange: t,
|
|
2320
2320
|
onError: n,
|
|
2321
|
-
error:
|
|
2321
|
+
error: a
|
|
2322
2322
|
}) => {
|
|
2323
|
-
const { t:
|
|
2323
|
+
const { t: o } = j(), c = L(e, a), { inputRef: i, error: s, handleChange: m } = _({
|
|
2324
2324
|
value: r,
|
|
2325
2325
|
onChange: t,
|
|
2326
2326
|
onError: n,
|
|
@@ -2346,7 +2346,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
2346
2346
|
{
|
|
2347
2347
|
type: "button",
|
|
2348
2348
|
onClick: d,
|
|
2349
|
-
"aria-label":
|
|
2349
|
+
"aria-label": o(l ? "Hide password" : "Show password"),
|
|
2350
2350
|
style: {
|
|
2351
2351
|
background: "transparent",
|
|
2352
2352
|
border: "none",
|
|
@@ -2360,24 +2360,24 @@ const mt = u.memo(fr), ft = ({
|
|
|
2360
2360
|
}
|
|
2361
2361
|
)
|
|
2362
2362
|
] }) });
|
|
2363
|
-
},
|
|
2364
|
-
const
|
|
2363
|
+
}, Ct = ({ field: e, value: r, onChange: t, onError: n, error: a }) => {
|
|
2364
|
+
const o = L(e, a), c = e.min ?? 0, i = e.max ?? 100, [s, m] = u.useState(
|
|
2365
2365
|
() => isNaN(Number(r)) ? String(c) : String(Number(r))
|
|
2366
2366
|
);
|
|
2367
2367
|
u.useEffect(() => {
|
|
2368
2368
|
const g = isNaN(Number(r)) ? String(c) : String(Number(r));
|
|
2369
2369
|
m(g);
|
|
2370
2370
|
}, [r, c]);
|
|
2371
|
-
const l = u.useMemo(() =>
|
|
2371
|
+
const l = u.useMemo(() => o(s) ?? null, [o, s]);
|
|
2372
2372
|
u.useEffect(() => {
|
|
2373
2373
|
n?.(l);
|
|
2374
2374
|
}, [l, n]);
|
|
2375
2375
|
const f = u.useCallback(
|
|
2376
2376
|
(g) => {
|
|
2377
2377
|
const w = g.target.value;
|
|
2378
|
-
m(w),
|
|
2378
|
+
m(w), o(w), t?.(w);
|
|
2379
2379
|
},
|
|
2380
|
-
[
|
|
2380
|
+
[o, t]
|
|
2381
2381
|
), d = isNaN(Number(s)) ? String(c) : String(Number(s));
|
|
2382
2382
|
return /* @__PURE__ */ p(O, { field: e, error: l, children: /* @__PURE__ */ A("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" }, children: [
|
|
2383
2383
|
/* @__PURE__ */ p(
|
|
@@ -2420,20 +2420,20 @@ const mt = u.memo(fr), ft = ({
|
|
|
2420
2420
|
}
|
|
2421
2421
|
)
|
|
2422
2422
|
] }) });
|
|
2423
|
-
},
|
|
2423
|
+
}, kt = ({
|
|
2424
2424
|
field: e,
|
|
2425
2425
|
value: r,
|
|
2426
2426
|
onChange: t,
|
|
2427
2427
|
onError: n,
|
|
2428
|
-
error:
|
|
2428
|
+
error: a
|
|
2429
2429
|
}) => {
|
|
2430
|
-
const { t:
|
|
2430
|
+
const { t: o, formStyle: c, fieldStyle: i, fieldValidationMode: s } = j(), l = L(e, a)(r);
|
|
2431
2431
|
u.useEffect(() => {
|
|
2432
2432
|
s === "realTime" && n?.(l);
|
|
2433
2433
|
}, [l, s, n]);
|
|
2434
|
-
const f = c, d = i, g = (
|
|
2434
|
+
const f = c, d = i, g = (N, x, V) => {
|
|
2435
2435
|
if (!x) return {};
|
|
2436
|
-
const b =
|
|
2436
|
+
const b = N?.[x];
|
|
2437
2437
|
return (V && b ? b[V] : void 0) ?? {};
|
|
2438
2438
|
}, w = u.useMemo(() => ({
|
|
2439
2439
|
display: "inline-block",
|
|
@@ -2496,7 +2496,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
2496
2496
|
className: R.label,
|
|
2497
2497
|
htmlFor: e.name,
|
|
2498
2498
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
2499
|
-
children:
|
|
2499
|
+
children: o(e.displayName)
|
|
2500
2500
|
}
|
|
2501
2501
|
),
|
|
2502
2502
|
/* @__PURE__ */ A("label", { style: w, children: [
|
|
@@ -2507,7 +2507,7 @@ const mt = u.memo(fr), ft = ({
|
|
|
2507
2507
|
type: "checkbox",
|
|
2508
2508
|
checked: k,
|
|
2509
2509
|
readOnly: !0,
|
|
2510
|
-
"aria-label":
|
|
2510
|
+
"aria-label": o(e.displayName),
|
|
2511
2511
|
"aria-invalid": !1,
|
|
2512
2512
|
"aria-describedby": void 0,
|
|
2513
2513
|
style: F,
|
|
@@ -2524,8 +2524,8 @@ const mt = u.memo(fr), ft = ({
|
|
|
2524
2524
|
"aria-invalid": !1,
|
|
2525
2525
|
"aria-describedby": void 0,
|
|
2526
2526
|
onClick: $,
|
|
2527
|
-
onKeyDown: (
|
|
2528
|
-
(
|
|
2527
|
+
onKeyDown: (N) => {
|
|
2528
|
+
(N.key === " " || N.key === "Spacebar" || N.key === "Space" || N.key === "Enter") && (N.preventDefault(), $());
|
|
2529
2529
|
},
|
|
2530
2530
|
className: `reactaform-switch ${k ? "active checked on" : ""} `,
|
|
2531
2531
|
style: k ? { ...S, backgroundColor: "var(--reactaform-switch-on-bg, #22c55e)", borderColor: "var(--reactaform-switch-on-border, #16a34a)" } : S,
|
|
@@ -2547,13 +2547,13 @@ const mt = u.memo(fr), ft = ({
|
|
|
2547
2547
|
value: r,
|
|
2548
2548
|
onChange: t,
|
|
2549
2549
|
onError: n,
|
|
2550
|
-
error:
|
|
2550
|
+
error: a
|
|
2551
2551
|
}) => {
|
|
2552
|
-
const
|
|
2552
|
+
const o = L(e, a), { inputRef: c, error: i, handleChange: s } = _({
|
|
2553
2553
|
value: r,
|
|
2554
2554
|
onChange: t,
|
|
2555
2555
|
onError: n,
|
|
2556
|
-
validate:
|
|
2556
|
+
validate: o
|
|
2557
2557
|
});
|
|
2558
2558
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
2559
2559
|
"input",
|
|
@@ -2569,19 +2569,19 @@ const mt = u.memo(fr), ft = ({
|
|
|
2569
2569
|
"aria-describedby": i ? `${e.name}-error` : void 0
|
|
2570
2570
|
}
|
|
2571
2571
|
) });
|
|
2572
|
-
},
|
|
2572
|
+
}, Et = ({
|
|
2573
2573
|
field: e,
|
|
2574
2574
|
value: r,
|
|
2575
2575
|
onChange: t,
|
|
2576
2576
|
onError: n,
|
|
2577
|
-
error:
|
|
2577
|
+
error: a
|
|
2578
2578
|
}) => {
|
|
2579
|
-
const
|
|
2579
|
+
const o = L(e), { inputRef: c, error: i, handleChange: s } = _({
|
|
2580
2580
|
value: r,
|
|
2581
2581
|
onChange: t,
|
|
2582
2582
|
onError: n,
|
|
2583
|
-
validate:
|
|
2584
|
-
}), m =
|
|
2583
|
+
validate: o
|
|
2584
|
+
}), m = a ?? i;
|
|
2585
2585
|
return /* @__PURE__ */ p(O, { field: e, error: m, children: /* @__PURE__ */ p(
|
|
2586
2586
|
"input",
|
|
2587
2587
|
{
|
|
@@ -2599,33 +2599,33 @@ const mt = u.memo(fr), ft = ({
|
|
|
2599
2599
|
}
|
|
2600
2600
|
) });
|
|
2601
2601
|
};
|
|
2602
|
-
function
|
|
2602
|
+
function Nt({
|
|
2603
2603
|
pos: e,
|
|
2604
2604
|
options: r,
|
|
2605
2605
|
onClose: t,
|
|
2606
2606
|
onClickOption: n
|
|
2607
2607
|
}) {
|
|
2608
|
-
const
|
|
2608
|
+
const a = u.useRef(null), o = u.useRef(!1), [c, i] = u.useState({
|
|
2609
2609
|
top: e?.y ?? 0,
|
|
2610
2610
|
left: e?.x ?? 0,
|
|
2611
2611
|
ready: !1
|
|
2612
2612
|
}), s = typeof window < "u" ? document.getElementById("popup-root") || document.body : null;
|
|
2613
2613
|
return u.useEffect(() => {
|
|
2614
2614
|
function m(l) {
|
|
2615
|
-
|
|
2615
|
+
o.current || l.target.dataset?.popupMenu === "item" || a.current && l.target instanceof Node && !a.current.contains(l.target) && t();
|
|
2616
2616
|
}
|
|
2617
2617
|
return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
|
|
2618
2618
|
}, [t]), u.useLayoutEffect(() => {
|
|
2619
|
-
if (!
|
|
2619
|
+
if (!a.current || !e || e.x == null || e.y == null)
|
|
2620
2620
|
return;
|
|
2621
|
-
const m =
|
|
2621
|
+
const m = a.current.getBoundingClientRect(), l = window.innerWidth, f = window.innerHeight;
|
|
2622
2622
|
let d = e.x, g = e.y;
|
|
2623
2623
|
d + m.width > l && (d = Math.max(0, l - m.width - 10)), g + m.height > f && (g = Math.max(0, e.y - m.height - 5)), i({ top: g, left: d, ready: !0 });
|
|
2624
2624
|
}, [e, r]), !s || r === void 0 || r.length === 0 || !e || e.x == null || e.y == null ? null : me.createPortal(
|
|
2625
2625
|
/* @__PURE__ */ p(
|
|
2626
2626
|
"div",
|
|
2627
2627
|
{
|
|
2628
|
-
ref:
|
|
2628
|
+
ref: a,
|
|
2629
2629
|
onMouseDown: (m) => {
|
|
2630
2630
|
m.stopPropagation();
|
|
2631
2631
|
},
|
|
@@ -2649,11 +2649,11 @@ function Et({
|
|
|
2649
2649
|
{
|
|
2650
2650
|
"data-popup-menu": "item",
|
|
2651
2651
|
onMouseDown: (f) => {
|
|
2652
|
-
f.stopPropagation(),
|
|
2652
|
+
f.stopPropagation(), o.current = !0;
|
|
2653
2653
|
},
|
|
2654
2654
|
onClick: (f) => {
|
|
2655
2655
|
f.stopPropagation(), f.preventDefault(), n(m), t(), setTimeout(() => {
|
|
2656
|
-
|
|
2656
|
+
o.current = !1;
|
|
2657
2657
|
}, 100);
|
|
2658
2658
|
},
|
|
2659
2659
|
style: {
|
|
@@ -2801,22 +2801,22 @@ const Ve = {
|
|
|
2801
2801
|
...Object.keys(Re)
|
|
2802
2802
|
]);
|
|
2803
2803
|
for (const e of It) {
|
|
2804
|
-
const r = {}, t = Ve[e] ?? [], n = $e[e] ?? {},
|
|
2805
|
-
for (const
|
|
2806
|
-
const c = n[
|
|
2807
|
-
r[
|
|
2808
|
-
name: typeof c == "string" ? c : String(
|
|
2809
|
-
shortName:
|
|
2810
|
-
factor: Object.prototype.hasOwnProperty.call(
|
|
2804
|
+
const r = {}, t = Ve[e] ?? [], n = $e[e] ?? {}, a = Re[e] ?? {};
|
|
2805
|
+
for (const o of t) {
|
|
2806
|
+
const c = n[o];
|
|
2807
|
+
r[o] = {
|
|
2808
|
+
name: typeof c == "string" ? c : String(o),
|
|
2809
|
+
shortName: o,
|
|
2810
|
+
factor: Object.prototype.hasOwnProperty.call(a, o) ? a[o] : void 0
|
|
2811
2811
|
};
|
|
2812
2812
|
}
|
|
2813
|
-
for (const [
|
|
2814
|
-
if (!r[
|
|
2815
|
-
const i = typeof c == "string" ? c : String(
|
|
2816
|
-
r[
|
|
2813
|
+
for (const [o, c] of Object.entries(n))
|
|
2814
|
+
if (!r[o]) {
|
|
2815
|
+
const i = typeof c == "string" ? c : String(o);
|
|
2816
|
+
r[o] = { name: i, shortName: o, factor: Object.prototype.hasOwnProperty.call(a, o) ? a[o] : void 0 };
|
|
2817
2817
|
}
|
|
2818
|
-
for (const [
|
|
2819
|
-
r[
|
|
2818
|
+
for (const [o, c] of Object.entries(a))
|
|
2819
|
+
r[o] || (r[o] = { name: String(o), shortName: String(o), factor: c });
|
|
2820
2820
|
Ae[e] = r;
|
|
2821
2821
|
}
|
|
2822
2822
|
function dr(e, r, t) {
|
|
@@ -2836,8 +2836,8 @@ function pr(e) {
|
|
|
2836
2836
|
const r = Ae[e];
|
|
2837
2837
|
if (!r) return null;
|
|
2838
2838
|
const t = {}, n = [];
|
|
2839
|
-
for (const [
|
|
2840
|
-
typeof c.factor == "number" && (t[
|
|
2839
|
+
for (const [o, c] of Object.entries(r))
|
|
2840
|
+
typeof c.factor == "number" && (t[o] = c.factor), n.push(o);
|
|
2841
2841
|
return {
|
|
2842
2842
|
default: Object.keys(r)[0] ?? "",
|
|
2843
2843
|
units: n,
|
|
@@ -2857,8 +2857,8 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2857
2857
|
inputValue: r,
|
|
2858
2858
|
selectedUnit: t,
|
|
2859
2859
|
dimension: n,
|
|
2860
|
-
unitFactors:
|
|
2861
|
-
onConversionSelect:
|
|
2860
|
+
unitFactors: a,
|
|
2861
|
+
onConversionSelect: o,
|
|
2862
2862
|
t: c
|
|
2863
2863
|
}) => {
|
|
2864
2864
|
const [i, s] = u.useState(!1), [m, l] = u.useState(null), [f, d] = u.useState([]), g = u.useCallback(
|
|
@@ -2870,7 +2870,7 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2870
2870
|
l({ x: k.left, y: k.bottom });
|
|
2871
2871
|
const $ = [];
|
|
2872
2872
|
if (n === "temperature")
|
|
2873
|
-
|
|
2873
|
+
a.units.forEach((x) => {
|
|
2874
2874
|
const V = dr(t, x, v);
|
|
2875
2875
|
Number.isFinite(V) && $.push({
|
|
2876
2876
|
label: `${V.toFixed(6)} ${c(x)}`,
|
|
@@ -2879,8 +2879,8 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2879
2879
|
});
|
|
2880
2880
|
});
|
|
2881
2881
|
else {
|
|
2882
|
-
const x =
|
|
2883
|
-
x !== void 0 && Object.entries(
|
|
2882
|
+
const x = a.factors[t];
|
|
2883
|
+
x !== void 0 && Object.entries(a.factors).forEach(([V, b]) => {
|
|
2884
2884
|
const h = v / x * b;
|
|
2885
2885
|
Number.isFinite(h) && $.push({
|
|
2886
2886
|
label: `${h.toFixed(6)} ${c(V)}`,
|
|
@@ -2891,16 +2891,16 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2891
2891
|
}
|
|
2892
2892
|
d($), s($.length > 0);
|
|
2893
2893
|
},
|
|
2894
|
-
[e, r, t, n,
|
|
2894
|
+
[e, r, t, n, a, c]
|
|
2895
2895
|
), w = u.useCallback(
|
|
2896
2896
|
(S) => {
|
|
2897
|
-
s(!1), l(null),
|
|
2897
|
+
s(!1), l(null), o(S);
|
|
2898
2898
|
},
|
|
2899
|
-
[
|
|
2899
|
+
[o]
|
|
2900
2900
|
), F = u.useCallback(() => {
|
|
2901
2901
|
s(!1), l(null);
|
|
2902
2902
|
}, []);
|
|
2903
|
-
return /* @__PURE__ */ A(
|
|
2903
|
+
return /* @__PURE__ */ A(Ne, { children: [
|
|
2904
2904
|
/* @__PURE__ */ p(
|
|
2905
2905
|
"button",
|
|
2906
2906
|
{
|
|
@@ -2926,7 +2926,7 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2926
2926
|
}
|
|
2927
2927
|
),
|
|
2928
2928
|
i && f.length > 0 && /* @__PURE__ */ p(
|
|
2929
|
-
|
|
2929
|
+
Nt,
|
|
2930
2930
|
{
|
|
2931
2931
|
pos: m,
|
|
2932
2932
|
options: f,
|
|
@@ -2938,36 +2938,36 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2938
2938
|
});
|
|
2939
2939
|
gr.displayName = "ConversionButton";
|
|
2940
2940
|
const Mt = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
2941
|
-
const { t:
|
|
2941
|
+
const { t: a } = j(), o = L(e), c = e.dimension, i = u.useMemo(() => c ? pr(c) : null, [c]), s = String(r?.[0] ?? ""), m = String(r?.[1] ?? i?.default ?? ""), [l, f] = u.useState(s), [d, g] = u.useState(m);
|
|
2942
2942
|
u.useEffect(() => {
|
|
2943
2943
|
f(s);
|
|
2944
2944
|
}, [s]), u.useEffect(() => {
|
|
2945
2945
|
g(m);
|
|
2946
2946
|
}, [m]);
|
|
2947
|
-
const w =
|
|
2947
|
+
const w = o([l, d]);
|
|
2948
2948
|
u.useEffect(() => {
|
|
2949
2949
|
n?.(w);
|
|
2950
2950
|
}, [w, n]);
|
|
2951
2951
|
const F = u.useCallback(
|
|
2952
|
-
(
|
|
2953
|
-
const x =
|
|
2954
|
-
f(x),
|
|
2952
|
+
(N) => {
|
|
2953
|
+
const x = N.target.value;
|
|
2954
|
+
f(x), o([x, d]), t?.([x, d]);
|
|
2955
2955
|
},
|
|
2956
|
-
[d,
|
|
2956
|
+
[d, o, t]
|
|
2957
2957
|
), S = u.useCallback(
|
|
2958
|
-
(
|
|
2959
|
-
const x =
|
|
2960
|
-
g(x),
|
|
2958
|
+
(N) => {
|
|
2959
|
+
const x = N.target.value;
|
|
2960
|
+
g(x), o([l, x]), t?.([l, x]);
|
|
2961
2961
|
},
|
|
2962
|
-
[l,
|
|
2962
|
+
[l, o, t]
|
|
2963
2963
|
), v = u.useCallback(
|
|
2964
|
-
(
|
|
2965
|
-
f(
|
|
2964
|
+
(N) => {
|
|
2965
|
+
f(N.value), g(N.unit), t?.([N.value, N.unit]);
|
|
2966
2966
|
},
|
|
2967
2967
|
[t]
|
|
2968
2968
|
), k = u.useMemo(
|
|
2969
|
-
() => i ? i.units.map((
|
|
2970
|
-
[i,
|
|
2969
|
+
() => i ? i.units.map((N) => /* @__PURE__ */ p("option", { value: N, children: a(N) }, N)) : [],
|
|
2970
|
+
[i, a]
|
|
2971
2971
|
);
|
|
2972
2972
|
if (!c || !i) return null;
|
|
2973
2973
|
const $ = !!w || !l.trim();
|
|
@@ -3007,23 +3007,23 @@ const Mt = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3007
3007
|
dimension: c,
|
|
3008
3008
|
unitFactors: i,
|
|
3009
3009
|
onConversionSelect: v,
|
|
3010
|
-
t:
|
|
3010
|
+
t: a
|
|
3011
3011
|
}
|
|
3012
3012
|
)
|
|
3013
3013
|
] }) });
|
|
3014
|
-
},
|
|
3014
|
+
}, Ft = u.memo(Mt), Vt = ({
|
|
3015
3015
|
field: e,
|
|
3016
3016
|
value: r,
|
|
3017
3017
|
onChange: t,
|
|
3018
3018
|
onError: n,
|
|
3019
|
-
error:
|
|
3019
|
+
error: a
|
|
3020
3020
|
}) => {
|
|
3021
|
-
const
|
|
3021
|
+
const o = L(e), { inputRef: c, error: i, handleChange: s } = _({
|
|
3022
3022
|
value: r,
|
|
3023
3023
|
onChange: t,
|
|
3024
3024
|
onError: n,
|
|
3025
|
-
validate:
|
|
3026
|
-
}), m =
|
|
3025
|
+
validate: o
|
|
3026
|
+
}), m = a ?? i;
|
|
3027
3027
|
return /* @__PURE__ */ p(O, { field: e, error: m, children: /* @__PURE__ */ p(
|
|
3028
3028
|
"input",
|
|
3029
3029
|
{
|
|
@@ -3038,7 +3038,7 @@ const Mt = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3038
3038
|
"aria-describedby": m ? `${e.name}-error` : void 0
|
|
3039
3039
|
}
|
|
3040
3040
|
) });
|
|
3041
|
-
},
|
|
3041
|
+
}, $t = {
|
|
3042
3042
|
// No debounce
|
|
3043
3043
|
checkbox: !1,
|
|
3044
3044
|
switch: !1,
|
|
@@ -3068,55 +3068,55 @@ const Mt = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3068
3068
|
slider: { wait: 100, leading: !0, trailing: !0 },
|
|
3069
3069
|
stepper: { wait: 100, leading: !0, trailing: !0 }
|
|
3070
3070
|
}, ue = new se(), De = {
|
|
3071
|
-
checkbox:
|
|
3072
|
-
color:
|
|
3073
|
-
date:
|
|
3074
|
-
dropdown:
|
|
3075
|
-
email:
|
|
3076
|
-
file:
|
|
3077
|
-
float:
|
|
3078
|
-
"float-array":
|
|
3079
|
-
image:
|
|
3080
|
-
int:
|
|
3081
|
-
"int-array":
|
|
3082
|
-
"multi-selection":
|
|
3083
|
-
multiline:
|
|
3084
|
-
password:
|
|
3085
|
-
phone:
|
|
3086
|
-
radio:
|
|
3087
|
-
rating:
|
|
3071
|
+
checkbox: Jr,
|
|
3072
|
+
color: et,
|
|
3073
|
+
date: rt,
|
|
3074
|
+
dropdown: tt,
|
|
3075
|
+
email: at,
|
|
3076
|
+
file: it,
|
|
3077
|
+
float: ct,
|
|
3078
|
+
"float-array": st,
|
|
3079
|
+
image: ut,
|
|
3080
|
+
int: ft,
|
|
3081
|
+
"int-array": mt,
|
|
3082
|
+
"multi-selection": pt,
|
|
3083
|
+
multiline: dt,
|
|
3084
|
+
password: St,
|
|
3085
|
+
phone: yt,
|
|
3086
|
+
radio: bt,
|
|
3087
|
+
rating: wt,
|
|
3088
3088
|
separator: ot,
|
|
3089
|
-
slider:
|
|
3089
|
+
slider: Ct,
|
|
3090
3090
|
string: _e,
|
|
3091
|
-
stepper:
|
|
3092
|
-
switch:
|
|
3091
|
+
stepper: ht,
|
|
3092
|
+
switch: kt,
|
|
3093
3093
|
text: _e,
|
|
3094
|
-
time:
|
|
3095
|
-
unit:
|
|
3096
|
-
url:
|
|
3094
|
+
time: Et,
|
|
3095
|
+
unit: Ft,
|
|
3096
|
+
url: Vt
|
|
3097
3097
|
};
|
|
3098
|
-
function
|
|
3098
|
+
function Rt(e) {
|
|
3099
3099
|
return e in De;
|
|
3100
3100
|
}
|
|
3101
|
-
function
|
|
3102
|
-
const { wait: t = 200, leading: n, trailing:
|
|
3101
|
+
function At(e, r) {
|
|
3102
|
+
const { wait: t = 200, leading: n, trailing: a } = r, o = u.memo((c) => {
|
|
3103
3103
|
const i = u.useRef(c.onChange);
|
|
3104
3104
|
u.useEffect(() => {
|
|
3105
3105
|
i.current = c.onChange;
|
|
3106
3106
|
}, [c.onChange]);
|
|
3107
|
-
const { callback: s, cancel: m } =
|
|
3107
|
+
const { callback: s, cancel: m } = Tr(
|
|
3108
3108
|
(...l) => {
|
|
3109
3109
|
i.current?.(...l);
|
|
3110
3110
|
},
|
|
3111
3111
|
t,
|
|
3112
|
-
{ leading: n, trailing:
|
|
3112
|
+
{ leading: n, trailing: a }
|
|
3113
3113
|
);
|
|
3114
3114
|
return u.useEffect(() => m, [m]), u.createElement(
|
|
3115
3115
|
e,
|
|
3116
3116
|
{ ...c, onChange: s }
|
|
3117
3117
|
);
|
|
3118
3118
|
});
|
|
3119
|
-
return
|
|
3119
|
+
return o.displayName = "DebouncedFieldWrapper", o;
|
|
3120
3120
|
}
|
|
3121
3121
|
function hr(e, r, t) {
|
|
3122
3122
|
const n = r;
|
|
@@ -3124,15 +3124,15 @@ function hr(e, r, t) {
|
|
|
3124
3124
|
console.warn(`Can't overwrite base component type "${e}".`);
|
|
3125
3125
|
return;
|
|
3126
3126
|
}
|
|
3127
|
-
const
|
|
3128
|
-
if (
|
|
3127
|
+
const a = $t[e];
|
|
3128
|
+
if (a === !1) {
|
|
3129
3129
|
ue.register(e, n);
|
|
3130
3130
|
return;
|
|
3131
3131
|
}
|
|
3132
|
-
const
|
|
3132
|
+
const o = a ?? { wait: 200 };
|
|
3133
3133
|
rr ? ue.register(e, n) : ue.register(
|
|
3134
3134
|
e,
|
|
3135
|
-
|
|
3135
|
+
At(n, o)
|
|
3136
3136
|
);
|
|
3137
3137
|
}
|
|
3138
3138
|
function yr(e, r) {
|
|
@@ -3142,41 +3142,41 @@ function br(e) {
|
|
|
3142
3142
|
return ue.get(e);
|
|
3143
3143
|
}
|
|
3144
3144
|
let Ke = !1;
|
|
3145
|
-
function
|
|
3145
|
+
function Dt() {
|
|
3146
3146
|
Ke || (Object.entries(De).forEach(([e, r]) => {
|
|
3147
3147
|
hr(e, r, !0);
|
|
3148
3148
|
}), Ke = !0);
|
|
3149
3149
|
}
|
|
3150
|
-
const
|
|
3150
|
+
const Pt = (e, r) => {
|
|
3151
3151
|
const t = /* @__PURE__ */ new Map();
|
|
3152
|
-
let n = null,
|
|
3152
|
+
let n = null, a = null, o = 0;
|
|
3153
3153
|
for (const c of e) {
|
|
3154
3154
|
const i = c.group;
|
|
3155
3155
|
if (!i) {
|
|
3156
|
-
n = null,
|
|
3156
|
+
n = null, a = null;
|
|
3157
3157
|
continue;
|
|
3158
3158
|
}
|
|
3159
3159
|
if (i === n)
|
|
3160
|
-
r[c.name].group =
|
|
3160
|
+
r[c.name].group = a ?? i;
|
|
3161
3161
|
else {
|
|
3162
3162
|
if (!t.has(i))
|
|
3163
|
-
t.set(i, 1),
|
|
3163
|
+
t.set(i, 1), a = null, r[c.name].group = i;
|
|
3164
3164
|
else {
|
|
3165
3165
|
const s = t.get(i), m = `${i}(${s})`;
|
|
3166
|
-
t.set(i, s + 1),
|
|
3166
|
+
t.set(i, s + 1), a = m, r[c.name].group = m, o++;
|
|
3167
3167
|
}
|
|
3168
3168
|
n = i;
|
|
3169
3169
|
}
|
|
3170
3170
|
}
|
|
3171
|
-
return
|
|
3172
|
-
},
|
|
3171
|
+
return o;
|
|
3172
|
+
}, zt = (e, r = {}) => {
|
|
3173
3173
|
const { includeEmpty: t = !0 } = r, n = [];
|
|
3174
|
-
let
|
|
3174
|
+
let a = null, o = [], c = 0;
|
|
3175
3175
|
for (const s of e) {
|
|
3176
3176
|
const m = s.group || null;
|
|
3177
|
-
m !==
|
|
3177
|
+
m !== a ? ((o.length > 0 || t) && (o.length === 0 && c++, n.push({ name: a, fields: o })), a = m, o = [s]) : o.push(s);
|
|
3178
3178
|
}
|
|
3179
|
-
(
|
|
3179
|
+
(o.length > 0 || t) && (o.length === 0 && c++, n.push({ name: a, fields: o }));
|
|
3180
3180
|
const i = Math.max(0, ...n.map((s) => s.fields.length));
|
|
3181
3181
|
return {
|
|
3182
3182
|
groups: n,
|
|
@@ -3186,19 +3186,19 @@ const Dt = (e, r) => {
|
|
|
3186
3186
|
largestGroup: i
|
|
3187
3187
|
}
|
|
3188
3188
|
};
|
|
3189
|
-
}, vr = u.memo(({ field: e, value: r, handleChange: t, handleError: n, error:
|
|
3190
|
-
const
|
|
3189
|
+
}, vr = u.memo(({ field: e, value: r, handleChange: t, handleError: n, error: a }) => {
|
|
3190
|
+
const o = br(e.type), c = u.useMemo(() => r, [r]), i = u.useCallback(
|
|
3191
3191
|
(m, l) => t(e.name, m, l),
|
|
3192
3192
|
[t, e.name]
|
|
3193
3193
|
), s = u.useCallback(
|
|
3194
3194
|
(m) => n?.(e.name, m),
|
|
3195
3195
|
[n, e.name]
|
|
3196
3196
|
);
|
|
3197
|
-
return
|
|
3197
|
+
return o ? /* @__PURE__ */ p(o, { field: e, value: c, onChange: i, onError: s, error: a }) : null;
|
|
3198
3198
|
}, (e, r) => e.field === r.field && e.value === r.value && e.handleChange === r.handleChange && e.handleError === r.handleError && e.error === r.error);
|
|
3199
3199
|
vr.displayName = "FieldWrapper";
|
|
3200
|
-
const xr = (e, r, t, n,
|
|
3201
|
-
const
|
|
3200
|
+
const xr = (e, r, t, n, a) => {
|
|
3201
|
+
const o = a ? a[e.name] ?? null : void 0;
|
|
3202
3202
|
return /* @__PURE__ */ p(u.Fragment, { children: /* @__PURE__ */ p(
|
|
3203
3203
|
vr,
|
|
3204
3204
|
{
|
|
@@ -3206,11 +3206,11 @@ const xr = (e, r, t, n, o) => {
|
|
|
3206
3206
|
value: r[e.name],
|
|
3207
3207
|
handleChange: t,
|
|
3208
3208
|
handleError: n,
|
|
3209
|
-
error:
|
|
3209
|
+
error: o
|
|
3210
3210
|
}
|
|
3211
3211
|
) }, e.name);
|
|
3212
|
-
}, wr = u.memo(({ groupName: e, isOpen: r, fields: t, valuesMap: n, handleChange:
|
|
3213
|
-
const m = u.useCallback(() => i(e), [i, e]), { formStyle: l, fieldStyle: f } =
|
|
3212
|
+
}, wr = u.memo(({ groupName: e, isOpen: r, fields: t, valuesMap: n, handleChange: a, handleError: o, errorsMap: c, toggleGroup: i, t: s }) => {
|
|
3213
|
+
const m = u.useCallback(() => i(e), [i, e]), { formStyle: l, fieldStyle: f } = j(), d = u.useMemo(() => ({
|
|
3214
3214
|
border: "1px solid var(--reactaform-border-color, #bbb)",
|
|
3215
3215
|
padding: "var(--reactaform-fieldset-padding, 0.5em)",
|
|
3216
3216
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
@@ -3233,12 +3233,12 @@ const xr = (e, r, t, n, o) => {
|
|
|
3233
3233
|
/* @__PURE__ */ p("span", { children: s(e) }),
|
|
3234
3234
|
/* @__PURE__ */ p("span", { children: r ? "▼" : "▶" })
|
|
3235
3235
|
] }),
|
|
3236
|
-
r && t.map((w) => xr(w, n,
|
|
3236
|
+
r && t.map((w) => xr(w, n, a, o, c))
|
|
3237
3237
|
] });
|
|
3238
3238
|
});
|
|
3239
3239
|
wr.displayName = "FieldGroup";
|
|
3240
|
-
const
|
|
3241
|
-
const l = r.slice(0, i).filter((g) => c[g.name]), f =
|
|
3240
|
+
const Ot = (e, r, t, n, a, o, c, i, s, m) => {
|
|
3241
|
+
const l = r.slice(0, i).filter((g) => c[g.name]), f = zt(l), d = [];
|
|
3242
3242
|
return f.groups.forEach((g) => {
|
|
3243
3243
|
if (g.name) {
|
|
3244
3244
|
const w = e[g.name] ?? !0;
|
|
@@ -3250,8 +3250,8 @@ const zt = (e, r, t, n, o, a, c, i, s, m) => {
|
|
|
3250
3250
|
isOpen: w,
|
|
3251
3251
|
fields: g.fields,
|
|
3252
3252
|
valuesMap: t,
|
|
3253
|
-
handleChange:
|
|
3254
|
-
handleError:
|
|
3253
|
+
handleChange: a,
|
|
3254
|
+
handleError: o,
|
|
3255
3255
|
errorsMap: m,
|
|
3256
3256
|
toggleGroup: s,
|
|
3257
3257
|
t: n
|
|
@@ -3260,50 +3260,50 @@ const zt = (e, r, t, n, o, a, c, i, s, m) => {
|
|
|
3260
3260
|
)
|
|
3261
3261
|
);
|
|
3262
3262
|
} else
|
|
3263
|
-
g.fields.forEach((w) => d.push(xr(w, t,
|
|
3263
|
+
g.fields.forEach((w) => d.push(xr(w, t, a, o, m)));
|
|
3264
3264
|
}), d;
|
|
3265
|
-
},
|
|
3265
|
+
}, Lt = (e) => {
|
|
3266
3266
|
const r = {};
|
|
3267
3267
|
return e.forEach((t) => {
|
|
3268
3268
|
r[t.name] = !1;
|
|
3269
3269
|
}), r;
|
|
3270
3270
|
}, Pe = (e, r, t, n) => {
|
|
3271
|
-
const
|
|
3272
|
-
if (!
|
|
3273
|
-
const
|
|
3271
|
+
const a = r[e];
|
|
3272
|
+
if (!a || !a.children) return;
|
|
3273
|
+
const o = t[e], c = o != null ? String(o) : "", i = a.children[c];
|
|
3274
3274
|
!i || !Array.isArray(i) || i.forEach((s) => {
|
|
3275
3275
|
typeof s == "string" && (n[s] = !0, Pe(s, r, t, n));
|
|
3276
3276
|
});
|
|
3277
3277
|
}, Sr = (e, r, t) => {
|
|
3278
3278
|
const n = r[e];
|
|
3279
|
-
!n || !n.children || Object.values(n.children).filter(Array.isArray).flat().forEach((
|
|
3280
|
-
typeof
|
|
3279
|
+
!n || !n.children || Object.values(n.children).filter(Array.isArray).flat().forEach((a) => {
|
|
3280
|
+
typeof a == "string" && a in t && (t[a] = !1, Sr(a, r, t));
|
|
3281
3281
|
});
|
|
3282
|
-
},
|
|
3283
|
-
const
|
|
3284
|
-
return e.forEach((
|
|
3285
|
-
(!
|
|
3286
|
-
}),
|
|
3287
|
-
}, jt = (e, r, t, n,
|
|
3288
|
-
const
|
|
3289
|
-
if (Sr(n, r,
|
|
3282
|
+
}, Tt = (e, r, t, n) => {
|
|
3283
|
+
const a = { ...t };
|
|
3284
|
+
return e.forEach((o) => {
|
|
3285
|
+
(!o.parents || Object.keys(o.parents).length === 0) && (a[o.name] = !0, Pe(o.name, n, r, a));
|
|
3286
|
+
}), a;
|
|
3287
|
+
}, jt = (e, r, t, n, a) => {
|
|
3288
|
+
const o = { ...e };
|
|
3289
|
+
if (Sr(n, r, o), a != null) {
|
|
3290
3290
|
const c = r[n];
|
|
3291
3291
|
if (c && c.children) {
|
|
3292
|
-
const i = String(
|
|
3292
|
+
const i = String(a), s = c.children[i];
|
|
3293
3293
|
s && Array.isArray(s) && s.forEach((m) => {
|
|
3294
|
-
typeof m == "string" && (
|
|
3294
|
+
typeof m == "string" && (o[m] = !0, Pe(m, r, t, o));
|
|
3295
3295
|
});
|
|
3296
3296
|
}
|
|
3297
3297
|
}
|
|
3298
|
-
return
|
|
3298
|
+
return o;
|
|
3299
3299
|
}, ze = new se();
|
|
3300
3300
|
function Cr(e, r) {
|
|
3301
3301
|
ze.register(e, r);
|
|
3302
3302
|
}
|
|
3303
|
-
function
|
|
3303
|
+
function Ht(e) {
|
|
3304
3304
|
return ze.get(e);
|
|
3305
3305
|
}
|
|
3306
|
-
function
|
|
3306
|
+
function Bt(e) {
|
|
3307
3307
|
return ze.get(e);
|
|
3308
3308
|
}
|
|
3309
3309
|
Cr(
|
|
@@ -3314,17 +3314,17 @@ Cr(
|
|
|
3314
3314
|
version: e.version,
|
|
3315
3315
|
definition: e.name,
|
|
3316
3316
|
values: t
|
|
3317
|
-
},
|
|
3318
|
-
alert(
|
|
3317
|
+
}, a = JSON.stringify(n, null, 2);
|
|
3318
|
+
alert(a);
|
|
3319
3319
|
}
|
|
3320
3320
|
);
|
|
3321
|
-
async function
|
|
3322
|
-
const
|
|
3323
|
-
if (
|
|
3321
|
+
async function qt(e, r, t, n, a) {
|
|
3322
|
+
const o = Object.values(a).filter(Boolean);
|
|
3323
|
+
if (o.length > 0)
|
|
3324
3324
|
return {
|
|
3325
3325
|
success: !1,
|
|
3326
3326
|
message: n("Please fix validation errors before submitting."),
|
|
3327
|
-
errors:
|
|
3327
|
+
errors: o
|
|
3328
3328
|
};
|
|
3329
3329
|
const c = { ...t }, i = [];
|
|
3330
3330
|
if (e && Array.isArray(e.properties))
|
|
@@ -3364,7 +3364,7 @@ async function Bt(e, r, t, n, o) {
|
|
|
3364
3364
|
message: n("Data transformation errors occurred."),
|
|
3365
3365
|
errors: i
|
|
3366
3366
|
};
|
|
3367
|
-
const s = await
|
|
3367
|
+
const s = await Gr(e, c, n);
|
|
3368
3368
|
if (s && s.length > 0)
|
|
3369
3369
|
return {
|
|
3370
3370
|
success: !1,
|
|
@@ -3372,7 +3372,7 @@ async function Bt(e, r, t, n, o) {
|
|
|
3372
3372
|
errors: s
|
|
3373
3373
|
};
|
|
3374
3374
|
if (e && typeof e.submitHandlerName == "string") {
|
|
3375
|
-
const m =
|
|
3375
|
+
const m = Ht(e.submitHandlerName);
|
|
3376
3376
|
if (m)
|
|
3377
3377
|
try {
|
|
3378
3378
|
const l = await m(e, r?.name ?? null, c, n);
|
|
@@ -3439,15 +3439,15 @@ const kr = ({
|
|
|
3439
3439
|
}
|
|
3440
3440
|
) : null;
|
|
3441
3441
|
kr.displayName = "SubmissionMessage";
|
|
3442
|
-
const
|
|
3443
|
-
const [n,
|
|
3442
|
+
const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
3443
|
+
const [n, a] = u.useState(!1);
|
|
3444
3444
|
return /* @__PURE__ */ p(
|
|
3445
3445
|
"button",
|
|
3446
3446
|
{
|
|
3447
3447
|
onClick: e,
|
|
3448
3448
|
disabled: r,
|
|
3449
|
-
onMouseEnter: () =>
|
|
3450
|
-
onMouseLeave: () =>
|
|
3449
|
+
onMouseEnter: () => a(!0),
|
|
3450
|
+
onMouseLeave: () => a(!1),
|
|
3451
3451
|
style: {
|
|
3452
3452
|
padding: "var(--reactaform-button-padding, var(--reactaform-space) 12px)",
|
|
3453
3453
|
backgroundColor: r ? "var(--reactaform-button-disabled-bg, #cccccc)" : "var(--reactaform-button-bg, var(--reactaform-success-color))",
|
|
@@ -3465,38 +3465,38 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3465
3465
|
children: t("Submit")
|
|
3466
3466
|
}
|
|
3467
3467
|
);
|
|
3468
|
-
},
|
|
3468
|
+
}, Wt = ({
|
|
3469
3469
|
definition: e,
|
|
3470
3470
|
instance: r,
|
|
3471
3471
|
chunkSize: t = 50,
|
|
3472
3472
|
chunkDelay: n = 50
|
|
3473
3473
|
}) => {
|
|
3474
|
-
const { properties:
|
|
3474
|
+
const { properties: a, displayName: o } = e, c = j(), { t: i, formStyle: s, language: m } = c, l = {
|
|
3475
3475
|
...c,
|
|
3476
3476
|
definitionName: e?.name ?? c.definitionName
|
|
3477
3477
|
}, [f, d] = u.useState("en"), [g, w] = u.useState([]), [F, S] = u.useState({}), [v, k] = u.useState(
|
|
3478
3478
|
{}
|
|
3479
|
-
), [$,
|
|
3479
|
+
), [$, N] = u.useState({}), [x, V] = u.useState({}), [b, h] = u.useState({}), [y, C] = u.useState(null), [E, I] = u.useState(null), [M, P] = u.useState(0), [H, Z] = u.useState(!1), [ne, ae] = u.useState(r.name || ""), Y = u.useRef(r), de = u.useRef(!1);
|
|
3480
3480
|
u.useEffect(() => {
|
|
3481
3481
|
const D = Object.fromEntries(
|
|
3482
|
-
|
|
3482
|
+
a.map((z) => [
|
|
3483
3483
|
z.name,
|
|
3484
3484
|
{ ...z, children: {} }
|
|
3485
3485
|
])
|
|
3486
3486
|
);
|
|
3487
|
-
|
|
3487
|
+
a.forEach((z) => {
|
|
3488
3488
|
z.parents && Object.entries(z.parents).forEach(([X, re]) => {
|
|
3489
|
-
const
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
const
|
|
3493
|
-
|
|
3494
|
-
...
|
|
3489
|
+
const oe = D[X];
|
|
3490
|
+
oe && re.forEach((Pr) => {
|
|
3491
|
+
oe.children || (oe.children = {});
|
|
3492
|
+
const Te = String(Pr);
|
|
3493
|
+
oe.children[Te] = [
|
|
3494
|
+
...oe.children[Te] || [],
|
|
3495
3495
|
z.name
|
|
3496
3496
|
];
|
|
3497
3497
|
});
|
|
3498
3498
|
});
|
|
3499
|
-
}),
|
|
3499
|
+
}), Pt(a, D);
|
|
3500
3500
|
const B = Object.values(
|
|
3501
3501
|
D
|
|
3502
3502
|
), q = {};
|
|
@@ -3509,28 +3509,28 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3509
3509
|
}), Y.current = r, Object.keys(r.values).forEach((z) => {
|
|
3510
3510
|
D[z] !== void 0 && (q[z] = r.values[z]);
|
|
3511
3511
|
});
|
|
3512
|
-
const J =
|
|
3512
|
+
const J = Lt(B), K = {};
|
|
3513
3513
|
B.forEach((z) => {
|
|
3514
3514
|
z.group && !(z.group in K) && (K[z.group] = !0);
|
|
3515
3515
|
});
|
|
3516
3516
|
const G = requestAnimationFrame(() => {
|
|
3517
|
-
w(B), S(D), k(q),
|
|
3518
|
-
|
|
3519
|
-
), V(K), Z(!0),
|
|
3517
|
+
w(B), S(D), k(q), N(
|
|
3518
|
+
Tt(B, q, J, D)
|
|
3519
|
+
), V(K), Z(!0), ae(r.name);
|
|
3520
3520
|
});
|
|
3521
3521
|
return () => cancelAnimationFrame(G);
|
|
3522
|
-
}, [
|
|
3523
|
-
if (!H ||
|
|
3522
|
+
}, [a, r, e]), u.useEffect(() => {
|
|
3523
|
+
if (!H || M >= g.length) return;
|
|
3524
3524
|
const D = setTimeout(() => {
|
|
3525
3525
|
P(
|
|
3526
3526
|
(B) => Math.min(B + t, g.length)
|
|
3527
3527
|
);
|
|
3528
3528
|
}, n);
|
|
3529
3529
|
return () => clearTimeout(D);
|
|
3530
|
-
}, [H,
|
|
3531
|
-
const
|
|
3530
|
+
}, [H, M, g.length, t, n]);
|
|
3531
|
+
const Vr = u.useCallback(
|
|
3532
3532
|
(D, B, q) => {
|
|
3533
|
-
C(null),
|
|
3533
|
+
C(null), I(null), k((J) => {
|
|
3534
3534
|
const K = { ...J, [D]: B }, G = F[D];
|
|
3535
3535
|
return G && [
|
|
3536
3536
|
"checkbox",
|
|
@@ -3538,7 +3538,7 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3538
3538
|
"multi-select",
|
|
3539
3539
|
"radio",
|
|
3540
3540
|
"switch"
|
|
3541
|
-
].includes(G.type) &&
|
|
3541
|
+
].includes(G.type) && N(
|
|
3542
3542
|
(X) => jt(
|
|
3543
3543
|
X,
|
|
3544
3544
|
F,
|
|
@@ -3549,26 +3549,26 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3549
3549
|
), K;
|
|
3550
3550
|
}), h((J) => q ? { ...J, [D]: q } : Object.fromEntries(Object.entries(J).filter(([G]) => G !== D)));
|
|
3551
3551
|
},
|
|
3552
|
-
[F, C,
|
|
3552
|
+
[F, C, I]
|
|
3553
3553
|
);
|
|
3554
3554
|
u.useEffect(() => {
|
|
3555
3555
|
let D = 0;
|
|
3556
3556
|
return D = requestAnimationFrame(() => {
|
|
3557
|
-
m !== f && (d(m || "en"), C(null),
|
|
3557
|
+
m !== f && (d(m || "en"), C(null), I(null));
|
|
3558
3558
|
}), () => cancelAnimationFrame(D);
|
|
3559
3559
|
}, [m, f]), u.useEffect(() => {
|
|
3560
3560
|
let D = 0;
|
|
3561
3561
|
return D = requestAnimationFrame(() => {
|
|
3562
3562
|
if (de.current) {
|
|
3563
|
-
de.current = !1, Y.current = r,
|
|
3563
|
+
de.current = !1, Y.current = r, ae(r.name || "");
|
|
3564
3564
|
return;
|
|
3565
3565
|
}
|
|
3566
|
-
Y.current = r, C(null),
|
|
3566
|
+
Y.current = r, C(null), I(null), ae(r.name || "");
|
|
3567
3567
|
}), () => cancelAnimationFrame(D);
|
|
3568
3568
|
}, [r, r.name]);
|
|
3569
|
-
const
|
|
3569
|
+
const $r = u.useCallback((D, B) => {
|
|
3570
3570
|
h((q) => B ? { ...q, [D]: String(B) } : Object.fromEntries(Object.entries(q).filter(([K]) => K !== D)));
|
|
3571
|
-
}, []),
|
|
3571
|
+
}, []), Rr = async () => {
|
|
3572
3572
|
de.current = !0;
|
|
3573
3573
|
const D = Y.current?.name;
|
|
3574
3574
|
Y.current.name = ne;
|
|
@@ -3581,90 +3581,126 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3581
3581
|
const re = mr(l.definitionName, z, X, i);
|
|
3582
3582
|
re && (G[z.name] = re);
|
|
3583
3583
|
}), h(G), B = G, Object.keys(G).length > 0) {
|
|
3584
|
-
C(i("Please fix validation errors before submitting the form.")),
|
|
3584
|
+
C(i("Please fix validation errors before submitting the form.")), I(!1);
|
|
3585
3585
|
return;
|
|
3586
3586
|
} else
|
|
3587
|
-
C(null),
|
|
3587
|
+
C(null), I(null);
|
|
3588
3588
|
}
|
|
3589
|
-
const q = await
|
|
3589
|
+
const q = await qt(e, Y.current, v, i, B), J = typeof q.message == "string" ? q.message : String(q.message), K = Object.values(q.errors ?? {}).join(`
|
|
3590
3590
|
`);
|
|
3591
3591
|
C(K ? J + `
|
|
3592
|
-
` + K : J),
|
|
3593
|
-
},
|
|
3592
|
+
` + K : J), I(q.success), q.success || (Y.current.name = D ?? Y.current.name, ae(D ?? ""));
|
|
3593
|
+
}, Ar = (D) => {
|
|
3594
3594
|
V((B) => ({ ...B, [D]: !B[D] }));
|
|
3595
|
-
},
|
|
3595
|
+
}, Dr = u.useMemo(
|
|
3596
3596
|
() => l.fieldValidationMode === "realTime" ? Object.values(b).some(Boolean) : !1,
|
|
3597
3597
|
[b, l.fieldValidationMode]
|
|
3598
3598
|
);
|
|
3599
|
-
return /* @__PURE__ */ p(
|
|
3600
|
-
|
|
3599
|
+
return /* @__PURE__ */ p(Ie.Provider, { value: l, children: /* @__PURE__ */ A("div", { style: s.container, children: [
|
|
3600
|
+
o && /* @__PURE__ */ p("h2", { style: s.titleStyle, children: i(o) }),
|
|
3601
3601
|
/* @__PURE__ */ p(
|
|
3602
3602
|
kr,
|
|
3603
3603
|
{
|
|
3604
3604
|
message: y,
|
|
3605
3605
|
success: E,
|
|
3606
3606
|
onDismiss: () => {
|
|
3607
|
-
C(null),
|
|
3607
|
+
C(null), I(null);
|
|
3608
3608
|
},
|
|
3609
3609
|
t: i
|
|
3610
3610
|
}
|
|
3611
3611
|
),
|
|
3612
3612
|
r && /* @__PURE__ */ p(
|
|
3613
|
-
|
|
3613
|
+
ar,
|
|
3614
3614
|
{
|
|
3615
3615
|
name: ne,
|
|
3616
3616
|
onChange: (D) => {
|
|
3617
|
-
|
|
3617
|
+
ae(D), C(null), I(null);
|
|
3618
3618
|
}
|
|
3619
3619
|
}
|
|
3620
3620
|
),
|
|
3621
|
-
/* @__PURE__ */ A(
|
|
3622
|
-
|
|
3621
|
+
/* @__PURE__ */ A(Ne, { children: [
|
|
3622
|
+
Ot(
|
|
3623
3623
|
x,
|
|
3624
3624
|
g,
|
|
3625
3625
|
v,
|
|
3626
3626
|
i,
|
|
3627
|
-
Fr,
|
|
3628
3627
|
Vr,
|
|
3628
|
+
$r,
|
|
3629
3629
|
$,
|
|
3630
|
-
|
|
3631
|
-
|
|
3630
|
+
M,
|
|
3631
|
+
Ar,
|
|
3632
3632
|
b
|
|
3633
3633
|
),
|
|
3634
|
-
|
|
3634
|
+
M < g.length && /* @__PURE__ */ p(
|
|
3635
3635
|
"div",
|
|
3636
3636
|
{
|
|
3637
3637
|
style: {
|
|
3638
3638
|
fontSize: "0.9em",
|
|
3639
3639
|
color: "var(--reactaform-text-muted, #666)"
|
|
3640
3640
|
},
|
|
3641
|
-
children: i(`Loading more fields... (${
|
|
3641
|
+
children: i(`Loading more fields... (${M}/${g.length})`)
|
|
3642
3642
|
}
|
|
3643
3643
|
)
|
|
3644
3644
|
] }),
|
|
3645
|
-
/* @__PURE__ */ p(
|
|
3645
|
+
/* @__PURE__ */ p(Ut, { onClick: Rr, disabled: Dr, t: i })
|
|
3646
3646
|
] }) });
|
|
3647
|
-
},
|
|
3647
|
+
}, Er = {
|
|
3648
|
+
en: { name: "English", nativeName: "English" },
|
|
3649
|
+
fr: { name: "French", nativeName: "Français" },
|
|
3650
|
+
de: { name: "German", nativeName: "Deutsch" },
|
|
3651
|
+
es: { name: "Spanish", nativeName: "Español" },
|
|
3652
|
+
"zh-cn": { name: "Chinese (Simplified)", nativeName: "简体中文" },
|
|
3653
|
+
bg: { name: "Bulgarian", nativeName: "Български" },
|
|
3654
|
+
cs: { name: "Czech", nativeName: "Čeština" },
|
|
3655
|
+
da: { name: "Danish", nativeName: "Dansk" },
|
|
3656
|
+
el: { name: "Greek", nativeName: "Ελληνικά" },
|
|
3657
|
+
fi: { name: "Finnish", nativeName: "Suomi" },
|
|
3658
|
+
hi: { name: "Hindi", nativeName: "हिन्दी" },
|
|
3659
|
+
hu: { name: "Hungarian", nativeName: "Magyar" },
|
|
3660
|
+
id: { name: "Indonesian", nativeName: "Bahasa Indonesia" },
|
|
3661
|
+
it: { name: "Italian", nativeName: "Italiano" },
|
|
3662
|
+
ja: { name: "Japanese", nativeName: "日本語" },
|
|
3663
|
+
ko: { name: "Korean", nativeName: "한국어" },
|
|
3664
|
+
ms: { name: "Malay", nativeName: "Bahasa Melayu" },
|
|
3665
|
+
nl: { name: "Dutch", nativeName: "Nederlands" },
|
|
3666
|
+
no: { name: "Norwegian", nativeName: "Norsk" },
|
|
3667
|
+
pl: { name: "Polish", nativeName: "Polski" },
|
|
3668
|
+
pt: { name: "Portuguese", nativeName: "Português" },
|
|
3669
|
+
ro: { name: "Romanian", nativeName: "Română" },
|
|
3670
|
+
ru: { name: "Russian", nativeName: "Русский" },
|
|
3671
|
+
sk: { name: "Slovak", nativeName: "Slovenčina" },
|
|
3672
|
+
sv: { name: "Swedish", nativeName: "Svenska" },
|
|
3673
|
+
th: { name: "Thai", nativeName: "ไทย" },
|
|
3674
|
+
tr: { name: "Turkish", nativeName: "Türkçe" },
|
|
3675
|
+
uk: { name: "Ukrainian", nativeName: "Українська" },
|
|
3676
|
+
vi: { name: "Vietnamese", nativeName: "Tiếng Việt" },
|
|
3677
|
+
"zh-tw": { name: "Chinese (Traditional)", nativeName: "繁體中文" }
|
|
3678
|
+
}, Hn = () => Er, ye = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Map(), _t = async (e) => {
|
|
3648
3679
|
try {
|
|
3649
3680
|
let r = {};
|
|
3650
|
-
|
|
3681
|
+
const t = e.toLowerCase();
|
|
3682
|
+
switch (t) {
|
|
3651
3683
|
case "fr":
|
|
3652
|
-
r = (await import("./common-
|
|
3684
|
+
r = (await import("./common-CCGIMXY_.mjs")).default;
|
|
3653
3685
|
break;
|
|
3654
3686
|
case "de":
|
|
3655
|
-
r = (await import("./common-
|
|
3687
|
+
r = (await import("./common-B4FQDljX.mjs")).default;
|
|
3656
3688
|
break;
|
|
3657
3689
|
case "es":
|
|
3658
|
-
r = (await import("./common-
|
|
3690
|
+
r = (await import("./common-Ws7ob6hh.mjs")).default;
|
|
3659
3691
|
break;
|
|
3660
3692
|
case "zh-cn":
|
|
3661
|
-
r = (await import("./common-
|
|
3693
|
+
r = (await import("./common-Dd94fy-Y.mjs")).default;
|
|
3662
3694
|
break;
|
|
3663
3695
|
case "en":
|
|
3664
3696
|
r = {};
|
|
3665
3697
|
break;
|
|
3666
3698
|
default:
|
|
3667
|
-
|
|
3699
|
+
if (Er[t]) {
|
|
3700
|
+
const a = `https://reactaform.vercel.app/locales/${t}/common.json`, o = await fetch(a);
|
|
3701
|
+
o.ok && (r = await o.json());
|
|
3702
|
+
} else
|
|
3703
|
+
r = {};
|
|
3668
3704
|
}
|
|
3669
3705
|
return {
|
|
3670
3706
|
success: !0,
|
|
@@ -3678,7 +3714,7 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3678
3714
|
error: `Failed to load common translations for ${e}: ${r}`
|
|
3679
3715
|
};
|
|
3680
3716
|
}
|
|
3681
|
-
},
|
|
3717
|
+
}, Kt = async (e) => {
|
|
3682
3718
|
if (!e)
|
|
3683
3719
|
return { success: !1, translations: {}, error: "Language is required" };
|
|
3684
3720
|
if (!e || e.toLowerCase() === "en")
|
|
@@ -3690,13 +3726,13 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3690
3726
|
translations: ye.get(r) || {},
|
|
3691
3727
|
fromCache: !0
|
|
3692
3728
|
};
|
|
3693
|
-
const t = await
|
|
3729
|
+
const t = await _t(r);
|
|
3694
3730
|
return t.success && (ye.set(r, t.translations), xe.set(r, {
|
|
3695
3731
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
3696
3732
|
size: Object.keys(t.translations).length,
|
|
3697
3733
|
source: "common"
|
|
3698
3734
|
})), t;
|
|
3699
|
-
},
|
|
3735
|
+
}, Gt = async (e, r) => {
|
|
3700
3736
|
if (!e || !r)
|
|
3701
3737
|
return {
|
|
3702
3738
|
success: !1,
|
|
@@ -3720,9 +3756,9 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3720
3756
|
try {
|
|
3721
3757
|
let n = r;
|
|
3722
3758
|
!r.includes("/") && !r.includes(".") && (n = `/locales/${e}/${r}.json`);
|
|
3723
|
-
const
|
|
3724
|
-
if (!
|
|
3725
|
-
return
|
|
3759
|
+
const a = await fetch(n);
|
|
3760
|
+
if (!a.ok)
|
|
3761
|
+
return a.status === 404 ? (ce.set(t, {}), xe.set(t, {
|
|
3726
3762
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
3727
3763
|
size: 0,
|
|
3728
3764
|
source: "user"
|
|
@@ -3733,14 +3769,14 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3733
3769
|
}) : (te.add(t), {
|
|
3734
3770
|
success: !1,
|
|
3735
3771
|
translations: {},
|
|
3736
|
-
error: `HTTP ${
|
|
3772
|
+
error: `HTTP ${a.status}`,
|
|
3737
3773
|
fromCache: !1
|
|
3738
3774
|
});
|
|
3739
|
-
const
|
|
3740
|
-
!
|
|
3741
|
-
`Translation file at ${n} has unexpected content-type: ${
|
|
3775
|
+
const o = a.headers.get("content-type") || "";
|
|
3776
|
+
!o.includes("application/json") && !o.includes("text/json") && Nr() && console.warn(
|
|
3777
|
+
`Translation file at ${n} has unexpected content-type: ${o}`
|
|
3742
3778
|
);
|
|
3743
|
-
const c = await
|
|
3779
|
+
const c = await a.text();
|
|
3744
3780
|
if (!c) {
|
|
3745
3781
|
const m = "Empty translation file";
|
|
3746
3782
|
return te.add(t), { success: !1, translations: {}, error: m };
|
|
@@ -3776,15 +3812,15 @@ const qt = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3776
3812
|
fromCache: !1
|
|
3777
3813
|
};
|
|
3778
3814
|
} catch (n) {
|
|
3779
|
-
const
|
|
3815
|
+
const a = `Failed to load user translations: ${n instanceof Error ? n.message : "Unknown error"}`;
|
|
3780
3816
|
return te.add(t), {
|
|
3781
3817
|
success: !1,
|
|
3782
3818
|
translations: {},
|
|
3783
|
-
error:
|
|
3819
|
+
error: a
|
|
3784
3820
|
};
|
|
3785
3821
|
}
|
|
3786
3822
|
};
|
|
3787
|
-
function
|
|
3823
|
+
function Nr() {
|
|
3788
3824
|
try {
|
|
3789
3825
|
if (typeof process < "u" && process?.env?.NODE_ENV === "development")
|
|
3790
3826
|
return !0;
|
|
@@ -3792,73 +3828,73 @@ function Er() {
|
|
|
3792
3828
|
}
|
|
3793
3829
|
return !1;
|
|
3794
3830
|
}
|
|
3795
|
-
function
|
|
3831
|
+
function Jt(e, r) {
|
|
3796
3832
|
return r.length === 0 ? e : e.replace(/\{\{(\d+)\}\}/g, (t, n) => {
|
|
3797
|
-
const
|
|
3798
|
-
return
|
|
3833
|
+
const a = parseInt(n, 10) - 1, o = r[a];
|
|
3834
|
+
return o == null ? t : String(o);
|
|
3799
3835
|
});
|
|
3800
3836
|
}
|
|
3801
|
-
const
|
|
3802
|
-
let
|
|
3803
|
-
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (
|
|
3837
|
+
const Yt = (e, r, t) => (n, ...a) => {
|
|
3838
|
+
let o = n, c = !1;
|
|
3839
|
+
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (o = n, c = !0) : n in t ? (o = t[n], c = !0) : n in r ? (o = r[n], c = !0) : o = n, o = Jt(o, a), !c && Nr() && console.debug(
|
|
3804
3840
|
`Missing translation for "${n}" in language "${e}"`
|
|
3805
|
-
),
|
|
3841
|
+
), o);
|
|
3806
3842
|
};
|
|
3807
|
-
function
|
|
3843
|
+
function Xt(e) {
|
|
3808
3844
|
return /^[-+]?\d*$/.test(e);
|
|
3809
3845
|
}
|
|
3810
|
-
function
|
|
3846
|
+
function Zt(e) {
|
|
3811
3847
|
const r = /^[-+]?\d*$/;
|
|
3812
3848
|
return e.split(",").map((t) => t.trim()).every((t) => r.test(t));
|
|
3813
3849
|
}
|
|
3814
|
-
const
|
|
3850
|
+
const Qt = ",", en = (e) => !e || e.trim() === "" ? [] : e.split(Qt).map((r) => r.trim()).filter(Boolean).map((r) => Number(r)), Ge = (e, r, t) => {
|
|
3815
3851
|
const n = String(r);
|
|
3816
3852
|
if (n.trim() === "")
|
|
3817
3853
|
return e.required ? t("Value required") : null;
|
|
3818
|
-
if (!
|
|
3854
|
+
if (!Xt(n))
|
|
3819
3855
|
return t("Must be a valid integer");
|
|
3820
|
-
const
|
|
3821
|
-
if (Number.isNaN(
|
|
3822
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
3856
|
+
const a = parseInt(n, 10);
|
|
3857
|
+
if (Number.isNaN(a)) return t("Must be a valid integer");
|
|
3858
|
+
if (e.min !== void 0 && (e.minInclusive ? a < e.min : a <= e.min))
|
|
3823
3859
|
return t(
|
|
3824
3860
|
"Must be {{1}} {{2}}",
|
|
3825
3861
|
e.minInclusive ? "≥" : ">",
|
|
3826
3862
|
e.min
|
|
3827
3863
|
);
|
|
3828
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
3864
|
+
if (e.max !== void 0 && (e.maxInclusive ? a > e.max : a >= e.max))
|
|
3829
3865
|
return t(
|
|
3830
3866
|
"Must be {{1}} {{2}}",
|
|
3831
3867
|
e.maxInclusive ? "≤" : "<",
|
|
3832
3868
|
e.max
|
|
3833
3869
|
);
|
|
3834
3870
|
if (e.step !== void 0) {
|
|
3835
|
-
const
|
|
3836
|
-
if (!Number.isInteger(
|
|
3871
|
+
const o = Number(e.step);
|
|
3872
|
+
if (!Number.isInteger(o))
|
|
3837
3873
|
return t("Invalid step value");
|
|
3838
|
-
if (
|
|
3839
|
-
return t("Must be a multiple of {{1}}",
|
|
3874
|
+
if (a % o !== 0)
|
|
3875
|
+
return t("Must be a multiple of {{1}}", o);
|
|
3840
3876
|
}
|
|
3841
3877
|
return null;
|
|
3842
3878
|
};
|
|
3843
|
-
function
|
|
3879
|
+
function rn(e, r, t) {
|
|
3844
3880
|
const n = String(r);
|
|
3845
3881
|
if (n.trim() === "")
|
|
3846
3882
|
return e.required ? t("Value required") : null;
|
|
3847
|
-
if (!
|
|
3883
|
+
if (!Zt(n))
|
|
3848
3884
|
return t("Each value must be a valid integer");
|
|
3849
|
-
const
|
|
3850
|
-
if (e.minCount !== void 0 &&
|
|
3885
|
+
const a = en(n);
|
|
3886
|
+
if (e.minCount !== void 0 && a.length < e.minCount)
|
|
3851
3887
|
return t("Minimum number of values: {{1}}", `${e.minCount}`);
|
|
3852
|
-
if (e.maxCount !== void 0 &&
|
|
3888
|
+
if (e.maxCount !== void 0 && a.length > e.maxCount)
|
|
3853
3889
|
return t("Maximum number of values: {{1}}", `${e.maxCount}`);
|
|
3854
|
-
for (const
|
|
3855
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
3890
|
+
for (const o of a) {
|
|
3891
|
+
if (e.min !== void 0 && (e.minInclusive ? o < e.min : o <= e.min))
|
|
3856
3892
|
return t(
|
|
3857
3893
|
"Each value must be {{1}} {{2}}",
|
|
3858
3894
|
e.minInclusive ? "≥" : ">",
|
|
3859
3895
|
e.min
|
|
3860
3896
|
);
|
|
3861
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
3897
|
+
if (e.max !== void 0 && (e.maxInclusive ? o > e.max : o >= e.max))
|
|
3862
3898
|
return t(
|
|
3863
3899
|
"Each value must be {{1}} {{2}}",
|
|
3864
3900
|
e.maxInclusive ? "≤" : "<",
|
|
@@ -3871,52 +3907,52 @@ function we(e, r, t) {
|
|
|
3871
3907
|
const n = String(r);
|
|
3872
3908
|
if (n.trim() === "")
|
|
3873
3909
|
return e.required ? t("Value required") : null;
|
|
3874
|
-
const
|
|
3875
|
-
if (Number.isNaN(
|
|
3910
|
+
const a = Number(n);
|
|
3911
|
+
if (Number.isNaN(a)) return t("Must be a valid float");
|
|
3876
3912
|
if (e.min !== void 0) {
|
|
3877
|
-
const
|
|
3878
|
-
if (
|
|
3913
|
+
const o = e.type === "slider" ? !0 : e.minInclusive ?? !0;
|
|
3914
|
+
if (o ? a < e.min : a <= e.min)
|
|
3879
3915
|
return t(
|
|
3880
3916
|
"Must be {{1}} {{2}}",
|
|
3881
|
-
|
|
3917
|
+
o ? "≥" : ">",
|
|
3882
3918
|
e.min
|
|
3883
3919
|
);
|
|
3884
3920
|
}
|
|
3885
3921
|
if (e.max !== void 0) {
|
|
3886
|
-
const
|
|
3887
|
-
if (
|
|
3922
|
+
const o = e.type === "slider" ? !0 : e.maxInclusive ?? !0;
|
|
3923
|
+
if (o ? a > e.max : a >= e.max)
|
|
3888
3924
|
return t(
|
|
3889
3925
|
"Must be {{1}} {{2}}",
|
|
3890
|
-
|
|
3926
|
+
o ? "≤" : "<",
|
|
3891
3927
|
e.max
|
|
3892
3928
|
);
|
|
3893
3929
|
}
|
|
3894
3930
|
return null;
|
|
3895
3931
|
}
|
|
3896
|
-
const
|
|
3897
|
-
function
|
|
3898
|
-
return e.split(",").map((r) => r.trim()).every((r) =>
|
|
3932
|
+
const tn = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
3933
|
+
function nn(e) {
|
|
3934
|
+
return e.split(",").map((r) => r.trim()).every((r) => tn.test(r));
|
|
3899
3935
|
}
|
|
3900
|
-
const
|
|
3901
|
-
function
|
|
3936
|
+
const an = ",", on = (e) => !e || e.trim() === "" ? [] : e.split(an).map((r) => r.trim()).filter(Boolean).map((r) => Number(r));
|
|
3937
|
+
function sn(e, r, t) {
|
|
3902
3938
|
const n = String(r);
|
|
3903
3939
|
if (n.trim() === "")
|
|
3904
3940
|
return e.required ? t("Value required") : null;
|
|
3905
|
-
if (!
|
|
3941
|
+
if (!nn(n))
|
|
3906
3942
|
return t("Each value must be a valid float");
|
|
3907
|
-
const
|
|
3908
|
-
if (e.minCount !== void 0 &&
|
|
3943
|
+
const a = on(n);
|
|
3944
|
+
if (e.minCount !== void 0 && a.length < e.minCount)
|
|
3909
3945
|
return t("Minimum number of values: {{1}}", e.minCount);
|
|
3910
|
-
if (e.maxCount !== void 0 &&
|
|
3946
|
+
if (e.maxCount !== void 0 && a.length > e.maxCount)
|
|
3911
3947
|
return t("Maximum number of values: {{1}}", e.maxCount);
|
|
3912
|
-
for (const
|
|
3913
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
3948
|
+
for (const o of a) {
|
|
3949
|
+
if (e.min !== void 0 && (e.minInclusive ? o < e.min : o <= e.min))
|
|
3914
3950
|
return t(
|
|
3915
3951
|
"Each value must be {{1}} {{2}}",
|
|
3916
3952
|
e.minInclusive ? "≥" : ">",
|
|
3917
3953
|
e.min
|
|
3918
3954
|
);
|
|
3919
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
3955
|
+
if (e.max !== void 0 && (e.maxInclusive ? o > e.max : o >= e.max))
|
|
3920
3956
|
return t(
|
|
3921
3957
|
"Each value must be {{1}} {{2}}",
|
|
3922
3958
|
e.maxInclusive ? "≤" : "<",
|
|
@@ -3926,10 +3962,10 @@ function an(e, r, t) {
|
|
|
3926
3962
|
return null;
|
|
3927
3963
|
}
|
|
3928
3964
|
const be = /* @__PURE__ */ new WeakMap();
|
|
3929
|
-
function Oe(e, r, t, n, ...
|
|
3965
|
+
function Oe(e, r, t, n, ...a) {
|
|
3930
3966
|
if (e.pattern == null)
|
|
3931
3967
|
return null;
|
|
3932
|
-
const
|
|
3968
|
+
const o = String(r);
|
|
3933
3969
|
let c = null;
|
|
3934
3970
|
if (e.pattern) {
|
|
3935
3971
|
const i = be.get(e);
|
|
@@ -3943,7 +3979,7 @@ function Oe(e, r, t, n, ...o) {
|
|
|
3943
3979
|
be.set(e, { pattern: e.pattern, regex: null }), c = null;
|
|
3944
3980
|
}
|
|
3945
3981
|
}
|
|
3946
|
-
return c && !c.test(
|
|
3982
|
+
return c && !c.test(o) ? e.patternErrorMessage ? t(e.patternErrorMessage) : n ? t(n, ...a) : t("Input does not match pattern: {{1}}", e.pattern) : null;
|
|
3947
3983
|
}
|
|
3948
3984
|
function le(e, r, t) {
|
|
3949
3985
|
const n = String(r);
|
|
@@ -3953,27 +3989,27 @@ const Se = (e) => {
|
|
|
3953
3989
|
if (!e) return null;
|
|
3954
3990
|
const r = Date.parse(e);
|
|
3955
3991
|
return Number.isNaN(r) ? null : r;
|
|
3956
|
-
}, Je = /* @__PURE__ */ new WeakMap(),
|
|
3992
|
+
}, Je = /* @__PURE__ */ new WeakMap(), cn = (e) => {
|
|
3957
3993
|
let r = Je.get(e);
|
|
3958
3994
|
return r || (r = {
|
|
3959
3995
|
minTime: Se(e.minDate),
|
|
3960
3996
|
maxTime: Se(e.maxDate)
|
|
3961
3997
|
}, Je.set(e, r)), r;
|
|
3962
3998
|
};
|
|
3963
|
-
function
|
|
3999
|
+
function ln(e, r, t) {
|
|
3964
4000
|
if (r == null || String(r).trim() === "")
|
|
3965
4001
|
return e.required ? t("Value required") : null;
|
|
3966
|
-
const n = String(r).trim(),
|
|
3967
|
-
if (
|
|
4002
|
+
const n = String(r).trim(), a = Se(n);
|
|
4003
|
+
if (a === null)
|
|
3968
4004
|
return t("Invalid date format");
|
|
3969
|
-
const { minTime:
|
|
3970
|
-
return
|
|
4005
|
+
const { minTime: o, maxTime: c } = cn(e);
|
|
4006
|
+
return o !== null && a < o ? t("Date must be on or after {{1}}", e.minDate) : c !== null && a > c ? t("Date must be on or before {{1}}", e.maxDate) : null;
|
|
3971
4007
|
}
|
|
3972
|
-
function
|
|
4008
|
+
function un(e, r, t) {
|
|
3973
4009
|
const n = String(r);
|
|
3974
4010
|
if (!n || n.trim() === "")
|
|
3975
4011
|
return e.required || e.min || e.max ? t("Value required") : null;
|
|
3976
|
-
const
|
|
4012
|
+
const a = (c) => {
|
|
3977
4013
|
const i = c.split(":").map((l) => parseInt(l, 10));
|
|
3978
4014
|
if (i.some((l) => Number.isNaN(l))) return NaN;
|
|
3979
4015
|
const s = i.length;
|
|
@@ -3990,43 +4026,43 @@ function ln(e, r, t) {
|
|
|
3990
4026
|
else
|
|
3991
4027
|
return NaN;
|
|
3992
4028
|
return m;
|
|
3993
|
-
},
|
|
3994
|
-
if (Number.isNaN(
|
|
4029
|
+
}, o = a(n);
|
|
4030
|
+
if (Number.isNaN(o)) return t("Invalid time format");
|
|
3995
4031
|
if (e.min && typeof e.min == "string") {
|
|
3996
|
-
const c =
|
|
3997
|
-
if (!Number.isNaN(c) &&
|
|
4032
|
+
const c = a(e.min);
|
|
4033
|
+
if (!Number.isNaN(c) && o < c)
|
|
3998
4034
|
return t("Time must be on or after {{1}}", e.min);
|
|
3999
4035
|
}
|
|
4000
4036
|
if (e.max && typeof e.max == "string") {
|
|
4001
|
-
const c =
|
|
4002
|
-
if (!Number.isNaN(c) &&
|
|
4037
|
+
const c = a(e.max);
|
|
4038
|
+
if (!Number.isNaN(c) && o > c)
|
|
4003
4039
|
return t("Time must be on or before {{1}}", e.max);
|
|
4004
4040
|
}
|
|
4005
4041
|
return null;
|
|
4006
4042
|
}
|
|
4007
|
-
function
|
|
4043
|
+
function mn(e) {
|
|
4008
4044
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
4009
4045
|
}
|
|
4010
|
-
function
|
|
4046
|
+
function fn(e, r, t) {
|
|
4011
4047
|
const n = String(r ?? "").trim();
|
|
4012
|
-
return n === "" ? e.required ? t("Value required") : null :
|
|
4048
|
+
return n === "" ? e.required ? t("Value required") : null : mn(n) ? Oe(e, r, t, t("Email does not match pattern: {{1}}", e.pattern)) : t("Must be valid email format");
|
|
4013
4049
|
}
|
|
4014
|
-
function
|
|
4050
|
+
function dn(e, r, t) {
|
|
4015
4051
|
const n = String(r ?? "").trim();
|
|
4016
4052
|
return n === "" ? e.required ? t("Value required") : null : Oe(e, n, t, "Invalid phone number format");
|
|
4017
4053
|
}
|
|
4018
|
-
const
|
|
4054
|
+
const pn = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i, gn = (e) => {
|
|
4019
4055
|
try {
|
|
4020
4056
|
return new URL(e), !0;
|
|
4021
4057
|
} catch {
|
|
4022
4058
|
return !1;
|
|
4023
4059
|
}
|
|
4024
4060
|
};
|
|
4025
|
-
function
|
|
4061
|
+
function hn(e, r, t) {
|
|
4026
4062
|
const n = String(r ?? "").trim();
|
|
4027
4063
|
if (n === "")
|
|
4028
4064
|
return e.required ? t("Value required") : null;
|
|
4029
|
-
if (
|
|
4065
|
+
if (pn.test(n) || gn(n))
|
|
4030
4066
|
return null;
|
|
4031
4067
|
if (e.allowRelative === !0) {
|
|
4032
4068
|
if (!n.startsWith("/") || encodeURI(n) !== n)
|
|
@@ -4039,11 +4075,11 @@ function gn(e, r, t) {
|
|
|
4039
4075
|
}
|
|
4040
4076
|
return t("Must be a valid URL");
|
|
4041
4077
|
}
|
|
4042
|
-
function hn(e, r, t) {
|
|
4043
|
-
const n = Array.isArray(r) ? r : [], o = n[0], a = n[1] ? String(n[1]).trim() : "";
|
|
4044
|
-
return String(o ?? "").trim() === "" || a === "" ? e.required ? t("Value required") : null : we(e, o, t);
|
|
4045
|
-
}
|
|
4046
4078
|
function yn(e, r, t) {
|
|
4079
|
+
const n = Array.isArray(r) ? r : [], a = n[0], o = n[1] ? String(n[1]).trim() : "";
|
|
4080
|
+
return String(a ?? "").trim() === "" || o === "" ? e.required ? t("Value required") : null : we(e, a, t);
|
|
4081
|
+
}
|
|
4082
|
+
function bn(e, r, t) {
|
|
4047
4083
|
if (Array.isArray(r))
|
|
4048
4084
|
return r.length === 0 ? t("Select a file") : r.every((n) => n instanceof File) ? null : t("Invalid file input");
|
|
4049
4085
|
if (!(r instanceof File)) {
|
|
@@ -4052,42 +4088,42 @@ function yn(e, r, t) {
|
|
|
4052
4088
|
}
|
|
4053
4089
|
return null;
|
|
4054
4090
|
}
|
|
4055
|
-
function
|
|
4091
|
+
function vn(e, r, t) {
|
|
4056
4092
|
const n = String(r);
|
|
4057
|
-
return n === "" || n === null || n === void 0 ? e.required ? t("Value required") : null : e.options?.some((
|
|
4093
|
+
return n === "" || n === null || n === void 0 ? e.required ? t("Value required") : null : e.options?.some((a) => String(a.value) === n) ? null : t("Invalid option selected");
|
|
4058
4094
|
}
|
|
4059
|
-
function
|
|
4060
|
-
const
|
|
4061
|
-
if (
|
|
4095
|
+
function xn(e, r, t) {
|
|
4096
|
+
const a = String(r ?? "").trim();
|
|
4097
|
+
if (a === "")
|
|
4062
4098
|
return e.required ? t("Value required") : null;
|
|
4063
|
-
const
|
|
4064
|
-
if (
|
|
4099
|
+
const o = a.split(",").map((c) => c.trim()).filter((c) => c !== "");
|
|
4100
|
+
if (o.length === 0)
|
|
4065
4101
|
return e.required ? t("Value required") : null;
|
|
4066
|
-
for (const c of
|
|
4102
|
+
for (const c of o)
|
|
4067
4103
|
if (!e.options?.some((i) => String(i.value) === c))
|
|
4068
4104
|
return t("Invalid option selected");
|
|
4069
4105
|
return null;
|
|
4070
4106
|
}
|
|
4071
|
-
const
|
|
4072
|
-
function
|
|
4107
|
+
const wn = /^#([0-9A-F]{3}){1,2}$/i, Sn = (e) => wn.test(e);
|
|
4108
|
+
function Cn(e, r, t) {
|
|
4073
4109
|
const n = String(r).trim();
|
|
4074
|
-
return n === "" ? e.required ? t("Value required") : null :
|
|
4110
|
+
return n === "" ? e.required ? t("Value required") : null : Sn(n) ? null : t("Invalid color format");
|
|
4075
4111
|
}
|
|
4076
|
-
function
|
|
4112
|
+
function kn(e, r, t) {
|
|
4077
4113
|
const n = String(r ?? "").trim();
|
|
4078
4114
|
if (n === "")
|
|
4079
4115
|
return e.required ? t("Value required") : null;
|
|
4080
|
-
let
|
|
4081
|
-
return typeof r != "number" && (
|
|
4116
|
+
let a = r;
|
|
4117
|
+
return typeof r != "number" && (a = parseFloat(n)), Number.isNaN(a) || a <= 0 ? t("Invalid value") : e.max !== void 0 && a > e.max ? t("Must be ≤ {{1}}", e.max) : null;
|
|
4082
4118
|
}
|
|
4083
4119
|
let Ye = !1;
|
|
4084
4120
|
function Ir() {
|
|
4085
|
-
Ye || (
|
|
4121
|
+
Ye || (T("int", Ge), T("stepper", Ge), T("int-array", rn), T("float", we), T("slider", we), T("float-array", sn), T("text", le), T("string", le), T("multiline", le), T("password", le), T("email", fn), T("date", ln), T("time", un), T("url", hn), T("phone", dn), T("unit", yn), T("dropdown", vn), T("multi-selection", xn), T("color", Cn), T("rating", kn), T("file", bn), Ye = !0);
|
|
4086
4122
|
}
|
|
4087
4123
|
Ir();
|
|
4088
|
-
|
|
4124
|
+
Dt();
|
|
4089
4125
|
Ir();
|
|
4090
|
-
const
|
|
4126
|
+
const En = (e) => ({
|
|
4091
4127
|
container: {
|
|
4092
4128
|
padding: "var(--reactaform-space-sm, 8px)",
|
|
4093
4129
|
margin: "0 auto",
|
|
@@ -4128,7 +4164,7 @@ const kn = (e) => ({
|
|
|
4128
4164
|
lineHeight: "1.2",
|
|
4129
4165
|
textAlign: "left"
|
|
4130
4166
|
}
|
|
4131
|
-
}),
|
|
4167
|
+
}), Nn = (e) => {
|
|
4132
4168
|
const r = {
|
|
4133
4169
|
color: "var(--reactaform-color-text)",
|
|
4134
4170
|
fontFamily: e?.fontFamily || "var(--reactaform-font-family, inherit)",
|
|
@@ -4192,12 +4228,12 @@ const kn = (e) => ({
|
|
|
4192
4228
|
definitionName: r = "",
|
|
4193
4229
|
defaultStyle: t,
|
|
4194
4230
|
defaultLanguage: n = "en",
|
|
4195
|
-
defaultTheme:
|
|
4196
|
-
defaultLocalizeName:
|
|
4231
|
+
defaultTheme: a = "light",
|
|
4232
|
+
defaultLocalizeName: o = "",
|
|
4197
4233
|
defaultFieldValidationMode: c = "realTime",
|
|
4198
4234
|
className: i = "reactaform-container"
|
|
4199
4235
|
}) => {
|
|
4200
|
-
const s = r, m =
|
|
4236
|
+
const s = r, m = o, l = a, f = n, d = u.useMemo(
|
|
4201
4237
|
() => t ?? {},
|
|
4202
4238
|
[t]
|
|
4203
4239
|
), [g, w] = u.useState({}), [F, S] = u.useState({});
|
|
@@ -4209,10 +4245,10 @@ const kn = (e) => ({
|
|
|
4209
4245
|
return;
|
|
4210
4246
|
}
|
|
4211
4247
|
try {
|
|
4212
|
-
const y = await
|
|
4248
|
+
const y = await Kt(f), C = y.success ? y.translations : {};
|
|
4213
4249
|
b && w(C);
|
|
4214
|
-
const E = await
|
|
4215
|
-
b && S(
|
|
4250
|
+
const E = await Gt(f, m), I = E.success ? E.translations : {};
|
|
4251
|
+
b && S(I);
|
|
4216
4252
|
} catch {
|
|
4217
4253
|
b && (w({}), S({}));
|
|
4218
4254
|
}
|
|
@@ -4220,10 +4256,10 @@ const kn = (e) => ({
|
|
|
4220
4256
|
b = !1;
|
|
4221
4257
|
};
|
|
4222
4258
|
}, [f, m]);
|
|
4223
|
-
const v = u.useMemo(() =>
|
|
4224
|
-
() =>
|
|
4259
|
+
const v = u.useMemo(() => En(d), [d]), k = u.useMemo(() => Nn(d), [d]), $ = u.useMemo(
|
|
4260
|
+
() => Yt(f, g, F),
|
|
4225
4261
|
[f, g, F]
|
|
4226
|
-
),
|
|
4262
|
+
), N = u.useCallback(
|
|
4227
4263
|
(b, ...h) => $(b, ...h),
|
|
4228
4264
|
[$]
|
|
4229
4265
|
), x = u.useMemo(
|
|
@@ -4233,12 +4269,12 @@ const kn = (e) => ({
|
|
|
4233
4269
|
theme: l,
|
|
4234
4270
|
formStyle: v,
|
|
4235
4271
|
fieldStyle: k,
|
|
4236
|
-
t:
|
|
4272
|
+
t: N,
|
|
4237
4273
|
fieldValidationMode: c
|
|
4238
4274
|
}),
|
|
4239
|
-
[s, f, l, k, v,
|
|
4275
|
+
[s, f, l, k, v, N, c]
|
|
4240
4276
|
), V = d?.height ? { height: "100%" } : void 0;
|
|
4241
|
-
return /* @__PURE__ */ p(
|
|
4277
|
+
return /* @__PURE__ */ p(Ie.Provider, { value: x, children: /* @__PURE__ */ p(
|
|
4242
4278
|
"div",
|
|
4243
4279
|
{
|
|
4244
4280
|
"data-reactaform-theme": l,
|
|
@@ -4276,7 +4312,7 @@ function Mn(e) {
|
|
|
4276
4312
|
}
|
|
4277
4313
|
return null;
|
|
4278
4314
|
}
|
|
4279
|
-
async function
|
|
4315
|
+
async function Bn(e, r = {}) {
|
|
4280
4316
|
const { validateSchema: t = !0 } = r;
|
|
4281
4317
|
try {
|
|
4282
4318
|
if (!e || typeof e != "string")
|
|
@@ -4284,26 +4320,26 @@ async function Tn(e, r = {}) {
|
|
|
4284
4320
|
const n = e.trim();
|
|
4285
4321
|
if (!n)
|
|
4286
4322
|
return { success: !1, error: "jsonData is empty" };
|
|
4287
|
-
let
|
|
4323
|
+
let a;
|
|
4288
4324
|
try {
|
|
4289
|
-
|
|
4290
|
-
} catch (
|
|
4325
|
+
a = JSON.parse(n);
|
|
4326
|
+
} catch (o) {
|
|
4291
4327
|
return {
|
|
4292
4328
|
success: !1,
|
|
4293
|
-
error: `Invalid JSON format: ${
|
|
4329
|
+
error: `Invalid JSON format: ${o instanceof Error ? o.message : "Unknown parsing error"}`
|
|
4294
4330
|
};
|
|
4295
4331
|
}
|
|
4296
4332
|
if (t) {
|
|
4297
|
-
const
|
|
4298
|
-
if (
|
|
4299
|
-
return { success: !1, error: `Schema validation failed: ${
|
|
4333
|
+
const o = Mn(a);
|
|
4334
|
+
if (o)
|
|
4335
|
+
return { success: !1, error: `Schema validation failed: ${o}` };
|
|
4300
4336
|
}
|
|
4301
|
-
return { success: !0, definition:
|
|
4337
|
+
return { success: !0, definition: a };
|
|
4302
4338
|
} catch (n) {
|
|
4303
4339
|
return { success: !1, error: `Unexpected error loading definition: ${n instanceof Error ? n.message : "Unknown error"}` };
|
|
4304
4340
|
}
|
|
4305
4341
|
}
|
|
4306
|
-
function
|
|
4342
|
+
function Fn(e, r) {
|
|
4307
4343
|
try {
|
|
4308
4344
|
if (!e)
|
|
4309
4345
|
return { success: !1, error: "Definition is required" };
|
|
@@ -4315,13 +4351,13 @@ function Nn(e, r) {
|
|
|
4315
4351
|
version: e.version ?? "1.0.0",
|
|
4316
4352
|
values: {}
|
|
4317
4353
|
}, n = e.properties || [];
|
|
4318
|
-
return Array.isArray(n) && n.forEach((
|
|
4319
|
-
const
|
|
4320
|
-
if (
|
|
4321
|
-
const c =
|
|
4322
|
-
t.values[
|
|
4354
|
+
return Array.isArray(n) && n.forEach((a) => {
|
|
4355
|
+
const o = a;
|
|
4356
|
+
if (o.type === "unit") {
|
|
4357
|
+
const c = o.defaultUnit, i = Number(o.defaultValue) || void 0;
|
|
4358
|
+
t.values[o.name] = [i || 0, c || "m"];
|
|
4323
4359
|
} else
|
|
4324
|
-
|
|
4360
|
+
o.defaultValue !== void 0 && (t.values[o.name] = o.defaultValue);
|
|
4325
4361
|
}), { success: !0, instance: t };
|
|
4326
4362
|
} catch (t) {
|
|
4327
4363
|
return {
|
|
@@ -4330,7 +4366,7 @@ function Nn(e, r) {
|
|
|
4330
4366
|
};
|
|
4331
4367
|
}
|
|
4332
4368
|
}
|
|
4333
|
-
function
|
|
4369
|
+
function qn(e) {
|
|
4334
4370
|
try {
|
|
4335
4371
|
if (!e)
|
|
4336
4372
|
return { success: !1, error: "Instance data is required" };
|
|
@@ -4354,7 +4390,7 @@ function Hn(e) {
|
|
|
4354
4390
|
};
|
|
4355
4391
|
}
|
|
4356
4392
|
}
|
|
4357
|
-
function
|
|
4393
|
+
function Un(e, r, t) {
|
|
4358
4394
|
try {
|
|
4359
4395
|
if (!e)
|
|
4360
4396
|
return { success: !1, error: "Instance is required" };
|
|
@@ -4367,9 +4403,9 @@ function Bn(e, r, t) {
|
|
|
4367
4403
|
definition: r.name,
|
|
4368
4404
|
version: r.version,
|
|
4369
4405
|
values: {}
|
|
4370
|
-
},
|
|
4406
|
+
}, a = n.values, o = {};
|
|
4371
4407
|
(r.properties || []).forEach((s) => {
|
|
4372
|
-
|
|
4408
|
+
o[s.name] = s;
|
|
4373
4409
|
});
|
|
4374
4410
|
const c = (s, m, l) => {
|
|
4375
4411
|
if (s == null) return s;
|
|
@@ -4414,14 +4450,14 @@ function Bn(e, r, t) {
|
|
|
4414
4450
|
return s;
|
|
4415
4451
|
}, i = e.values || {};
|
|
4416
4452
|
Object.keys(i).forEach((s) => {
|
|
4417
|
-
const m = i[s], l =
|
|
4453
|
+
const m = i[s], l = o[s];
|
|
4418
4454
|
if (!l)
|
|
4419
4455
|
return;
|
|
4420
4456
|
const f = Array.isArray(m) ? "array" : m === null ? "null" : typeof m, d = (l.type || "").toLowerCase();
|
|
4421
|
-
f === d || d === "string" && typeof m == "string" ?
|
|
4457
|
+
f === d || d === "string" && typeof m == "string" ? a[s] = m : a[s] = c(m, d, l);
|
|
4422
4458
|
}), (r.properties || []).forEach((s) => {
|
|
4423
4459
|
const m = s.name;
|
|
4424
|
-
m in
|
|
4460
|
+
m in a || (a[m] = s.defaultValue);
|
|
4425
4461
|
});
|
|
4426
4462
|
try {
|
|
4427
4463
|
typeof t == "function" && t?.(e, n, r);
|
|
@@ -4436,29 +4472,29 @@ function Bn(e, r, t) {
|
|
|
4436
4472
|
};
|
|
4437
4473
|
}
|
|
4438
4474
|
}
|
|
4439
|
-
function
|
|
4475
|
+
function Vn(e) {
|
|
4440
4476
|
const [r, t] = u.useState(null);
|
|
4441
4477
|
return u.useEffect(() => {
|
|
4442
4478
|
const n = document.querySelector("[data-reactaform-theme]");
|
|
4443
4479
|
if (!n) return;
|
|
4444
|
-
const
|
|
4445
|
-
if (!
|
|
4446
|
-
const
|
|
4447
|
-
|
|
4480
|
+
const a = n.closest("[data-reactaform-theme]");
|
|
4481
|
+
if (!a) return;
|
|
4482
|
+
const o = () => t(a.getAttribute("data-reactaform-theme"));
|
|
4483
|
+
o();
|
|
4448
4484
|
const c = new MutationObserver((i) => {
|
|
4449
4485
|
for (const s of i)
|
|
4450
|
-
s.type === "attributes" && s.attributeName === "data-reactaform-theme" &&
|
|
4486
|
+
s.type === "attributes" && s.attributeName === "data-reactaform-theme" && o();
|
|
4451
4487
|
});
|
|
4452
|
-
return c.observe(
|
|
4488
|
+
return c.observe(a, { attributes: !0, attributeFilter: ["data-reactaform-theme"] }), () => c.disconnect();
|
|
4453
4489
|
}, [e]), r;
|
|
4454
4490
|
}
|
|
4455
|
-
const
|
|
4491
|
+
const Wn = ({
|
|
4456
4492
|
definitionData: e,
|
|
4457
4493
|
instance: r,
|
|
4458
4494
|
language: t,
|
|
4459
4495
|
className: n,
|
|
4460
|
-
theme:
|
|
4461
|
-
style:
|
|
4496
|
+
theme: a,
|
|
4497
|
+
style: o,
|
|
4462
4498
|
fieldValidationMode: c = "realTime"
|
|
4463
4499
|
}) => {
|
|
4464
4500
|
const i = u.useMemo(() => {
|
|
@@ -4467,7 +4503,7 @@ const qn = ({
|
|
|
4467
4503
|
} catch {
|
|
4468
4504
|
return null;
|
|
4469
4505
|
}
|
|
4470
|
-
}, [e]), s = { fontSize: "inherit", fontFamily: "inherit", ...
|
|
4506
|
+
}, [e]), s = { fontSize: "inherit", fontFamily: "inherit", ...o }, m = Vn(), l = a ?? m ?? "light", f = t ?? "en";
|
|
4471
4507
|
u.useEffect(() => {
|
|
4472
4508
|
let g = document.getElementById("popup-root");
|
|
4473
4509
|
g || (g = document.createElement("div"), g.id = "popup-root", document.body.appendChild(g));
|
|
@@ -4475,7 +4511,7 @@ const qn = ({
|
|
|
4475
4511
|
const d = u.useMemo(() => {
|
|
4476
4512
|
if (r) return r;
|
|
4477
4513
|
if (!i) return null;
|
|
4478
|
-
const g =
|
|
4514
|
+
const g = Fn(i, i.name);
|
|
4479
4515
|
return !g.success || !g.instance ? null : g.instance;
|
|
4480
4516
|
}, [r, i]);
|
|
4481
4517
|
return i ? d ? /* @__PURE__ */ p(
|
|
@@ -4489,7 +4525,7 @@ const qn = ({
|
|
|
4489
4525
|
className: n,
|
|
4490
4526
|
defaultFieldValidationMode: c,
|
|
4491
4527
|
children: /* @__PURE__ */ p(
|
|
4492
|
-
|
|
4528
|
+
Wt,
|
|
4493
4529
|
{
|
|
4494
4530
|
definition: i,
|
|
4495
4531
|
instance: d
|
|
@@ -4526,67 +4562,67 @@ function Mr(e, r, t) {
|
|
|
4526
4562
|
return !1;
|
|
4527
4563
|
}
|
|
4528
4564
|
}
|
|
4529
|
-
function
|
|
4565
|
+
function $n(e) {
|
|
4530
4566
|
const r = [];
|
|
4531
4567
|
if (e.components) {
|
|
4532
4568
|
for (const t of Object.keys(e.components))
|
|
4533
4569
|
if (br(t)) {
|
|
4534
|
-
const
|
|
4535
|
-
|
|
4570
|
+
const a = W.components.get(t);
|
|
4571
|
+
a && a !== e.name && r.push({
|
|
4536
4572
|
type: "component",
|
|
4537
4573
|
name: t,
|
|
4538
|
-
existingPlugin:
|
|
4574
|
+
existingPlugin: a,
|
|
4539
4575
|
newPlugin: e.name
|
|
4540
4576
|
});
|
|
4541
4577
|
}
|
|
4542
4578
|
}
|
|
4543
4579
|
if (e.fieldCustomValidators)
|
|
4544
4580
|
for (const [t, n] of Object.entries(e.fieldCustomValidators))
|
|
4545
|
-
for (const
|
|
4546
|
-
const c = W.fieldValidators.get(t)?.get(
|
|
4547
|
-
sr(t,
|
|
4581
|
+
for (const a of Object.keys(n)) {
|
|
4582
|
+
const c = W.fieldValidators.get(t)?.get(a);
|
|
4583
|
+
sr(t, a) && c && c !== e.name && r.push({
|
|
4548
4584
|
type: "fieldCustomValidator",
|
|
4549
|
-
name: `${t}:${
|
|
4585
|
+
name: `${t}:${a}`,
|
|
4550
4586
|
existingPlugin: c,
|
|
4551
4587
|
newPlugin: e.name
|
|
4552
4588
|
});
|
|
4553
4589
|
}
|
|
4554
4590
|
if (e.fieldTypeValidators)
|
|
4555
4591
|
for (const t of Object.keys(e.fieldTypeValidators)) {
|
|
4556
|
-
const n = lr(t),
|
|
4557
|
-
n &&
|
|
4592
|
+
const n = lr(t), a = W.fieldTypeValidators.get(t);
|
|
4593
|
+
n && a && a !== e.name && r.push({
|
|
4558
4594
|
type: "fieldTypeValidator",
|
|
4559
4595
|
name: `type:${t}`,
|
|
4560
|
-
existingPlugin:
|
|
4596
|
+
existingPlugin: a,
|
|
4561
4597
|
newPlugin: e.name
|
|
4562
4598
|
});
|
|
4563
4599
|
}
|
|
4564
4600
|
if (e.formValidators)
|
|
4565
4601
|
for (const t of Object.keys(e.formValidators)) {
|
|
4566
|
-
const n = cr(t),
|
|
4567
|
-
n &&
|
|
4602
|
+
const n = cr(t), a = W.formValidators.get(t);
|
|
4603
|
+
n && a && a !== e.name && r.push({
|
|
4568
4604
|
type: "formValidator",
|
|
4569
4605
|
name: t,
|
|
4570
|
-
existingPlugin:
|
|
4606
|
+
existingPlugin: a,
|
|
4571
4607
|
newPlugin: e.name
|
|
4572
4608
|
});
|
|
4573
4609
|
}
|
|
4574
4610
|
if (e.submissionHandlers)
|
|
4575
4611
|
for (const t of Object.keys(e.submissionHandlers)) {
|
|
4576
|
-
const n =
|
|
4577
|
-
n &&
|
|
4612
|
+
const n = Bt(t), a = W.submissionHandlers.get(t);
|
|
4613
|
+
n && a && a !== e.name && r.push({
|
|
4578
4614
|
type: "submissionHandler",
|
|
4579
4615
|
name: t,
|
|
4580
|
-
existingPlugin:
|
|
4616
|
+
existingPlugin: a,
|
|
4581
4617
|
newPlugin: e.name
|
|
4582
4618
|
});
|
|
4583
4619
|
}
|
|
4584
4620
|
return r;
|
|
4585
4621
|
}
|
|
4586
|
-
function ie(e, r, t, n,
|
|
4622
|
+
function ie(e, r, t, n, a, o, c, i) {
|
|
4587
4623
|
for (const s of Object.keys(e)) {
|
|
4588
4624
|
let m;
|
|
4589
|
-
if (i ? m =
|
|
4625
|
+
if (i ? m = a.find((l) => l.type === "fieldCustomValidator" && l.name === `${i}:${s}`) : e === n.components ? m = a.find((l) => l.type === "component" && l.name === s) : e === n.formValidators ? m = a.find((l) => l.type === "formValidator" && l.name === s) : e === n.fieldTypeValidators ? m = a.find((l) => l.type === "fieldTypeValidator" && l.name === `type:${s}`) : e === n.submissionHandlers && (m = a.find((l) => l.type === "submissionHandler" && l.name === s)), Mr(m || null, o, c))
|
|
4590
4626
|
if (i) {
|
|
4591
4627
|
const l = r.get(i) || /* @__PURE__ */ new Map();
|
|
4592
4628
|
l.set(s, n.name), r.set(i, l), t(s, e[s]);
|
|
@@ -4594,18 +4630,18 @@ function ie(e, r, t, n, o, a, c, i) {
|
|
|
4594
4630
|
r.set(s, n.name), t(s, e[s]);
|
|
4595
4631
|
}
|
|
4596
4632
|
}
|
|
4597
|
-
function
|
|
4633
|
+
function _n(e, r) {
|
|
4598
4634
|
const t = r?.conflictResolution || "error";
|
|
4599
4635
|
if (Q.has(e.name)) {
|
|
4600
|
-
const
|
|
4636
|
+
const a = {
|
|
4601
4637
|
type: "plugin",
|
|
4602
4638
|
name: e.name,
|
|
4603
4639
|
existingPlugin: e.name,
|
|
4604
4640
|
newPlugin: e.name
|
|
4605
4641
|
};
|
|
4606
|
-
if (!Mr(
|
|
4642
|
+
if (!Mr(a, t, r?.onConflict)) return;
|
|
4607
4643
|
}
|
|
4608
|
-
const n =
|
|
4644
|
+
const n = $n(e);
|
|
4609
4645
|
if (e.components && ie(
|
|
4610
4646
|
e.components,
|
|
4611
4647
|
W.components,
|
|
@@ -4615,21 +4651,21 @@ function Un(e, r) {
|
|
|
4615
4651
|
t,
|
|
4616
4652
|
r?.onConflict
|
|
4617
4653
|
), e.fieldCustomValidators)
|
|
4618
|
-
for (const [
|
|
4654
|
+
for (const [a, o] of Object.entries(e.fieldCustomValidators))
|
|
4619
4655
|
ie(
|
|
4620
|
-
|
|
4656
|
+
o,
|
|
4621
4657
|
W.fieldValidators,
|
|
4622
|
-
(c, i) =>
|
|
4658
|
+
(c, i) => Wr(a, c, i),
|
|
4623
4659
|
e,
|
|
4624
4660
|
n,
|
|
4625
4661
|
t,
|
|
4626
4662
|
r?.onConflict,
|
|
4627
|
-
|
|
4663
|
+
a
|
|
4628
4664
|
);
|
|
4629
4665
|
e.formValidators && ie(
|
|
4630
4666
|
e.formValidators,
|
|
4631
4667
|
W.formValidators,
|
|
4632
|
-
|
|
4668
|
+
Ur,
|
|
4633
4669
|
e,
|
|
4634
4670
|
n,
|
|
4635
4671
|
t,
|
|
@@ -4637,7 +4673,7 @@ function Un(e, r) {
|
|
|
4637
4673
|
), e.fieldTypeValidators && ie(
|
|
4638
4674
|
e.fieldTypeValidators,
|
|
4639
4675
|
W.fieldTypeValidators,
|
|
4640
|
-
|
|
4676
|
+
_r,
|
|
4641
4677
|
e,
|
|
4642
4678
|
n,
|
|
4643
4679
|
t,
|
|
@@ -4652,7 +4688,7 @@ function Un(e, r) {
|
|
|
4652
4688
|
r?.onConflict
|
|
4653
4689
|
), e.setup && e.setup(), Q.set(e.name, e);
|
|
4654
4690
|
}
|
|
4655
|
-
function
|
|
4691
|
+
function Kn(e, r = !1) {
|
|
4656
4692
|
const t = Q.get(e);
|
|
4657
4693
|
if (!t) return !1;
|
|
4658
4694
|
if (t.cleanup && t.cleanup(), r) {
|
|
@@ -4660,12 +4696,12 @@ function Wn(e, r = !1) {
|
|
|
4660
4696
|
for (const n of Object.keys(t.components))
|
|
4661
4697
|
W.components.delete(n);
|
|
4662
4698
|
if (t.fieldCustomValidators)
|
|
4663
|
-
for (const [n,
|
|
4664
|
-
const
|
|
4665
|
-
if (
|
|
4666
|
-
for (const c of Object.keys(
|
|
4667
|
-
|
|
4668
|
-
|
|
4699
|
+
for (const [n, a] of Object.entries(t.fieldCustomValidators)) {
|
|
4700
|
+
const o = W.fieldValidators.get(n);
|
|
4701
|
+
if (o) {
|
|
4702
|
+
for (const c of Object.keys(a))
|
|
4703
|
+
o.delete(c);
|
|
4704
|
+
o.size === 0 && W.fieldValidators.delete(n);
|
|
4669
4705
|
}
|
|
4670
4706
|
}
|
|
4671
4707
|
if (t.formValidators)
|
|
@@ -4680,16 +4716,16 @@ function Wn(e, r = !1) {
|
|
|
4680
4716
|
}
|
|
4681
4717
|
return Q.delete(e), !0;
|
|
4682
4718
|
}
|
|
4683
|
-
function
|
|
4719
|
+
function Gn(e) {
|
|
4684
4720
|
return Q.get(e);
|
|
4685
4721
|
}
|
|
4686
|
-
function
|
|
4722
|
+
function Jn() {
|
|
4687
4723
|
return Array.from(Q.values());
|
|
4688
4724
|
}
|
|
4689
|
-
function
|
|
4725
|
+
function Yn(e) {
|
|
4690
4726
|
return Q.has(e);
|
|
4691
4727
|
}
|
|
4692
|
-
function
|
|
4728
|
+
function Xn(e) {
|
|
4693
4729
|
for (const [r, t] of Object.entries(e))
|
|
4694
4730
|
yr(r, t);
|
|
4695
4731
|
}
|
|
@@ -4701,7 +4737,7 @@ function Le(e) {
|
|
|
4701
4737
|
const r = e;
|
|
4702
4738
|
return typeof r.name == "string" && typeof r.displayName == "string";
|
|
4703
4739
|
}
|
|
4704
|
-
function
|
|
4740
|
+
function Fr(e) {
|
|
4705
4741
|
if (!ee(e)) return !1;
|
|
4706
4742
|
const r = e;
|
|
4707
4743
|
return typeof r.name != "string" || typeof r.version != "string" || !Array.isArray(r.properties) ? !1 : r.properties.every((t) => Le(t));
|
|
@@ -4714,12 +4750,12 @@ function Ce(e) {
|
|
|
4714
4750
|
return !!r && typeof r.name == "string" && typeof r.size == "number";
|
|
4715
4751
|
}
|
|
4716
4752
|
}
|
|
4717
|
-
function
|
|
4753
|
+
function Zn(e, r, t = {}) {
|
|
4718
4754
|
try {
|
|
4719
4755
|
const {
|
|
4720
4756
|
includeMetadata: n = !1,
|
|
4721
|
-
dateFormat:
|
|
4722
|
-
fileHandling:
|
|
4757
|
+
dateFormat: a = "iso",
|
|
4758
|
+
fileHandling: o = "metadata",
|
|
4723
4759
|
prettify: c = !1,
|
|
4724
4760
|
excludeFields: i = [],
|
|
4725
4761
|
includeOnlyFields: s = []
|
|
@@ -4729,7 +4765,7 @@ function Yn(e, r, t = {}) {
|
|
|
4729
4765
|
success: !1,
|
|
4730
4766
|
error: "Instance must be a valid object"
|
|
4731
4767
|
};
|
|
4732
|
-
const m = [], l = [], f = {}, g = (
|
|
4768
|
+
const m = [], l = [], f = {}, g = (Fr(r) || ee(r) && Array.isArray(r.properties) ? r.properties : []).filter(Le), w = new Map(g.map((S) => [S.name, S]));
|
|
4733
4769
|
for (const [S, v] of Object.entries(e)) {
|
|
4734
4770
|
if (i.includes(S)) {
|
|
4735
4771
|
l.push(S);
|
|
@@ -4742,7 +4778,7 @@ function Yn(e, r, t = {}) {
|
|
|
4742
4778
|
if (v === void 0) continue;
|
|
4743
4779
|
const k = w.get(S);
|
|
4744
4780
|
try {
|
|
4745
|
-
f[S] =
|
|
4781
|
+
f[S] = Rn(v, k, { dateFormat: a, fileHandling: o });
|
|
4746
4782
|
} catch ($) {
|
|
4747
4783
|
m.push(`Error serializing field '${S}': ${String($)}`), f[S] = null;
|
|
4748
4784
|
}
|
|
@@ -4768,8 +4804,8 @@ function Yn(e, r, t = {}) {
|
|
|
4768
4804
|
};
|
|
4769
4805
|
}
|
|
4770
4806
|
}
|
|
4771
|
-
function
|
|
4772
|
-
const { dateFormat: n = "iso", fileHandling:
|
|
4807
|
+
function Rn(e, r, t = {}) {
|
|
4808
|
+
const { dateFormat: n = "iso", fileHandling: a = "metadata" } = t;
|
|
4773
4809
|
if (e == null)
|
|
4774
4810
|
return null;
|
|
4775
4811
|
if (r)
|
|
@@ -4779,7 +4815,7 @@ function $n(e, r, t = {}) {
|
|
|
4779
4815
|
case "date-time":
|
|
4780
4816
|
return Xe(e, n);
|
|
4781
4817
|
case "file":
|
|
4782
|
-
return Ze(e,
|
|
4818
|
+
return Ze(e, a);
|
|
4783
4819
|
case "int":
|
|
4784
4820
|
case "integer":
|
|
4785
4821
|
return typeof e == "string" ? parseInt(e, 10) : e;
|
|
@@ -4790,11 +4826,11 @@ function $n(e, r, t = {}) {
|
|
|
4790
4826
|
return typeof e == "string" ? e === "true" : !!e;
|
|
4791
4827
|
case "int-array":
|
|
4792
4828
|
case "float-array":
|
|
4793
|
-
return Array.isArray(e) ? e.map((
|
|
4829
|
+
return Array.isArray(e) ? e.map((o) => typeof o == "string" ? Number(o) : o) : e;
|
|
4794
4830
|
default:
|
|
4795
4831
|
return e;
|
|
4796
4832
|
}
|
|
4797
|
-
return e instanceof Date ? Xe(e, n) : Ce(e) || Array.isArray(e) && Ce(e[0]) ? Ze(e,
|
|
4833
|
+
return e instanceof Date ? Xe(e, n) : Ce(e) || Array.isArray(e) && Ce(e[0]) ? Ze(e, a) : e;
|
|
4798
4834
|
}
|
|
4799
4835
|
function Xe(e, r) {
|
|
4800
4836
|
let t = null;
|
|
@@ -4838,12 +4874,12 @@ function Qe(e, r) {
|
|
|
4838
4874
|
_note: "Base64 encoding requires async implementation"
|
|
4839
4875
|
};
|
|
4840
4876
|
}
|
|
4841
|
-
function
|
|
4877
|
+
function Qn(e, r, t = {}) {
|
|
4842
4878
|
try {
|
|
4843
4879
|
const {
|
|
4844
4880
|
strict: n = !1,
|
|
4845
|
-
validateTypes:
|
|
4846
|
-
preserveUnknownFields:
|
|
4881
|
+
validateTypes: a = !0,
|
|
4882
|
+
preserveUnknownFields: o = !0,
|
|
4847
4883
|
dateFormat: c = "auto"
|
|
4848
4884
|
} = t;
|
|
4849
4885
|
if (!e || typeof e != "string")
|
|
@@ -4865,7 +4901,7 @@ function Xn(e, r, t = {}) {
|
|
|
4865
4901
|
success: !1,
|
|
4866
4902
|
error: "Parsed data must be an object"
|
|
4867
4903
|
};
|
|
4868
|
-
const s = [], m = [], l = {}, d = (
|
|
4904
|
+
const s = [], m = [], l = {}, d = (Fr(r) || ee(r) && Array.isArray(r.properties) ? r.properties : []).filter(Le), g = new Map(d.map((F) => [F.name, F]));
|
|
4869
4905
|
for (const F of d) {
|
|
4870
4906
|
const S = F.name, v = i[S];
|
|
4871
4907
|
if (v === void 0) {
|
|
@@ -4873,13 +4909,13 @@ function Xn(e, r, t = {}) {
|
|
|
4873
4909
|
continue;
|
|
4874
4910
|
}
|
|
4875
4911
|
try {
|
|
4876
|
-
l[S] =
|
|
4912
|
+
l[S] = An(v, F, { validateTypes: a, dateFormat: c });
|
|
4877
4913
|
} catch (k) {
|
|
4878
4914
|
const $ = `Error deserializing field '${S}': ${String(k)}`;
|
|
4879
4915
|
n ? m.push($) : (s.push($), l[S] = v);
|
|
4880
4916
|
}
|
|
4881
4917
|
}
|
|
4882
|
-
if (
|
|
4918
|
+
if (o)
|
|
4883
4919
|
for (const [F, S] of Object.entries(i))
|
|
4884
4920
|
!g.has(F) && F !== "_metadata" && (n && s.push(`Unknown field '${F}' preserved`), l[F] = S);
|
|
4885
4921
|
const w = m.length > 0;
|
|
@@ -4896,8 +4932,8 @@ function Xn(e, r, t = {}) {
|
|
|
4896
4932
|
};
|
|
4897
4933
|
}
|
|
4898
4934
|
}
|
|
4899
|
-
function
|
|
4900
|
-
const { validateTypes: n = !0, dateFormat:
|
|
4935
|
+
function An(e, r, t = {}) {
|
|
4936
|
+
const { validateTypes: n = !0, dateFormat: a = "auto" } = t;
|
|
4901
4937
|
if (e == null)
|
|
4902
4938
|
return e;
|
|
4903
4939
|
try {
|
|
@@ -4905,7 +4941,7 @@ function Rn(e, r, t = {}) {
|
|
|
4905
4941
|
case "date":
|
|
4906
4942
|
case "datetime":
|
|
4907
4943
|
case "date-time":
|
|
4908
|
-
return
|
|
4944
|
+
return Dn(e, a, n);
|
|
4909
4945
|
case "int":
|
|
4910
4946
|
case "integer":
|
|
4911
4947
|
return ke(e, n);
|
|
@@ -4913,7 +4949,7 @@ function Rn(e, r, t = {}) {
|
|
|
4913
4949
|
case "number":
|
|
4914
4950
|
return Ee(e, n);
|
|
4915
4951
|
case "boolean":
|
|
4916
|
-
return
|
|
4952
|
+
return Pn(e, n);
|
|
4917
4953
|
case "int-array":
|
|
4918
4954
|
return er(e, "integer", n);
|
|
4919
4955
|
case "float-array":
|
|
@@ -4927,13 +4963,13 @@ function Rn(e, r, t = {}) {
|
|
|
4927
4963
|
default:
|
|
4928
4964
|
return e;
|
|
4929
4965
|
}
|
|
4930
|
-
} catch (
|
|
4966
|
+
} catch (o) {
|
|
4931
4967
|
if (n)
|
|
4932
|
-
throw new Error(`Type conversion failed: ${String(
|
|
4968
|
+
throw new Error(`Type conversion failed: ${String(o)}`);
|
|
4933
4969
|
return e;
|
|
4934
4970
|
}
|
|
4935
4971
|
}
|
|
4936
|
-
function
|
|
4972
|
+
function ea(e, r = {}) {
|
|
4937
4973
|
try {
|
|
4938
4974
|
const { prettify: t = !0, includeMetadata: n = !0 } = r;
|
|
4939
4975
|
if (!e || typeof e != "object")
|
|
@@ -4941,16 +4977,16 @@ function Zn(e, r = {}) {
|
|
|
4941
4977
|
success: !1,
|
|
4942
4978
|
error: "Definition must be a valid object"
|
|
4943
4979
|
};
|
|
4944
|
-
const
|
|
4945
|
-
return n && (
|
|
4980
|
+
const a = { ...e };
|
|
4981
|
+
return n && (a._metadata = {
|
|
4946
4982
|
serializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4947
|
-
version:
|
|
4948
|
-
propertyCount: (Array.isArray(
|
|
4983
|
+
version: a.version || "1.0.0",
|
|
4984
|
+
propertyCount: (Array.isArray(a.properties) ? a.properties.length : 0) || 0
|
|
4949
4985
|
}), {
|
|
4950
4986
|
success: !0,
|
|
4951
|
-
data: t ? JSON.stringify(
|
|
4987
|
+
data: t ? JSON.stringify(a, null, 2) : JSON.stringify(a),
|
|
4952
4988
|
metadata: {
|
|
4953
|
-
fieldCount: (Array.isArray(
|
|
4989
|
+
fieldCount: (Array.isArray(a.properties) ? a.properties.length : 0) || 0,
|
|
4954
4990
|
excludedFields: [],
|
|
4955
4991
|
warnings: []
|
|
4956
4992
|
}
|
|
@@ -4962,13 +4998,13 @@ function Zn(e, r = {}) {
|
|
|
4962
4998
|
};
|
|
4963
4999
|
}
|
|
4964
5000
|
}
|
|
4965
|
-
function
|
|
5001
|
+
function ra(e, r = {}) {
|
|
4966
5002
|
try {
|
|
4967
5003
|
const { strict: t = !1, validateTypes: n = !0 } = r;
|
|
4968
|
-
let
|
|
5004
|
+
let a;
|
|
4969
5005
|
if (typeof e == "string")
|
|
4970
5006
|
try {
|
|
4971
|
-
|
|
5007
|
+
a = JSON.parse(e);
|
|
4972
5008
|
} catch (l) {
|
|
4973
5009
|
return {
|
|
4974
5010
|
success: !1,
|
|
@@ -4976,43 +5012,43 @@ function Qn(e, r = {}) {
|
|
|
4976
5012
|
};
|
|
4977
5013
|
}
|
|
4978
5014
|
else if (e && typeof e == "object")
|
|
4979
|
-
|
|
5015
|
+
a = { ...e };
|
|
4980
5016
|
else
|
|
4981
5017
|
return {
|
|
4982
5018
|
success: !1,
|
|
4983
5019
|
error: "Input must be a string or object"
|
|
4984
5020
|
};
|
|
4985
|
-
const
|
|
5021
|
+
const o = [], c = [], i = ["name", "version", "displayName"];
|
|
4986
5022
|
for (const l of i)
|
|
4987
|
-
if (!(l in
|
|
5023
|
+
if (!(l in a) || !a[l])
|
|
4988
5024
|
if (t)
|
|
4989
5025
|
c.push(`Required field '${l}' is missing`);
|
|
4990
5026
|
else
|
|
4991
|
-
switch (
|
|
5027
|
+
switch (o.push(`Missing field '${l}', using default`), l) {
|
|
4992
5028
|
case "name":
|
|
4993
|
-
|
|
5029
|
+
a.name = "unnamed-definition";
|
|
4994
5030
|
break;
|
|
4995
5031
|
case "version":
|
|
4996
|
-
|
|
5032
|
+
a.version = "1.0.0";
|
|
4997
5033
|
break;
|
|
4998
5034
|
case "displayName":
|
|
4999
|
-
|
|
5035
|
+
a.displayName = a.name || "Unnamed Definition";
|
|
5000
5036
|
break;
|
|
5001
5037
|
}
|
|
5002
|
-
const s = Array.isArray(
|
|
5003
|
-
s ?
|
|
5038
|
+
const s = Array.isArray(a.properties) ? a.properties : null;
|
|
5039
|
+
s ? a.properties = s.map((l, f) => {
|
|
5004
5040
|
const d = ee(l) ? l : {}, g = { ...d };
|
|
5005
5041
|
if (!d.name) {
|
|
5006
5042
|
const w = `Property at index ${f} missing 'name'`;
|
|
5007
|
-
t ? c.push(w) : (
|
|
5043
|
+
t ? c.push(w) : (o.push(`${w}, using 'field_${f}'`), g.name = `field_${f}`);
|
|
5008
5044
|
}
|
|
5009
|
-
return d.displayName || (g.displayName = d.name || `Field ${f}`), d.type || (t && n ? c.push(`Property '${d.name || f}' missing 'type'`) : (
|
|
5010
|
-
}) : t ? c.push("Properties must be an array") : (
|
|
5045
|
+
return d.displayName || (g.displayName = d.name || `Field ${f}`), d.type || (t && n ? c.push(`Property '${d.name || f}' missing 'type'`) : (o.push(`Property '${d.name || f}' missing 'type', using 'string'`), g.type = "string")), d.defaultValue === void 0 && (g.defaultValue = null), d.required === void 0 && (g.required = !1), g;
|
|
5046
|
+
}) : t ? c.push("Properties must be an array") : (o.push("Properties not found or invalid, using empty array"), a.properties = []);
|
|
5011
5047
|
const m = c.length > 0;
|
|
5012
5048
|
return {
|
|
5013
5049
|
success: !m,
|
|
5014
|
-
data:
|
|
5015
|
-
warnings:
|
|
5050
|
+
data: a,
|
|
5051
|
+
warnings: o.length > 0 ? o : void 0,
|
|
5016
5052
|
validationErrors: m ? c : void 0
|
|
5017
5053
|
};
|
|
5018
5054
|
} catch (t) {
|
|
@@ -5022,7 +5058,7 @@ function Qn(e, r = {}) {
|
|
|
5022
5058
|
};
|
|
5023
5059
|
}
|
|
5024
5060
|
}
|
|
5025
|
-
function
|
|
5061
|
+
function Dn(e, r, t) {
|
|
5026
5062
|
if (e instanceof Date)
|
|
5027
5063
|
return e;
|
|
5028
5064
|
if (typeof e == "number") {
|
|
@@ -5087,7 +5123,7 @@ function Ee(e, r) {
|
|
|
5087
5123
|
throw new Error(`Cannot convert ${typeof e} to number`);
|
|
5088
5124
|
return e;
|
|
5089
5125
|
}
|
|
5090
|
-
function
|
|
5126
|
+
function Pn(e, r) {
|
|
5091
5127
|
if (typeof e == "boolean")
|
|
5092
5128
|
return e;
|
|
5093
5129
|
if (typeof e == "string") {
|
|
@@ -5106,64 +5142,65 @@ function Dn(e, r) {
|
|
|
5106
5142
|
function er(e, r, t) {
|
|
5107
5143
|
if (!Array.isArray(e)) {
|
|
5108
5144
|
if (typeof e == "string")
|
|
5109
|
-
return e.split(",").map((
|
|
5145
|
+
return e.split(",").map((a) => a.trim()).filter(Boolean).map((a) => r === "integer" ? ke(a, t) : Ee(a, t));
|
|
5110
5146
|
if (t)
|
|
5111
5147
|
throw new Error(`Expected array, got ${typeof e}`);
|
|
5112
5148
|
return e;
|
|
5113
5149
|
}
|
|
5114
|
-
return e.map((n,
|
|
5150
|
+
return e.map((n, a) => {
|
|
5115
5151
|
try {
|
|
5116
5152
|
return r === "integer" ? ke(n, t) : Ee(n, t);
|
|
5117
|
-
} catch (
|
|
5153
|
+
} catch (o) {
|
|
5118
5154
|
if (t)
|
|
5119
|
-
throw new Error(`Array element ${
|
|
5155
|
+
throw new Error(`Array element ${a}: ${o}`);
|
|
5120
5156
|
return n;
|
|
5121
5157
|
}
|
|
5122
5158
|
});
|
|
5123
5159
|
}
|
|
5124
|
-
function
|
|
5160
|
+
function zn() {
|
|
5125
5161
|
if (!document.getElementById("reactaform-styles"))
|
|
5126
5162
|
try {
|
|
5127
5163
|
const e = document.createElement("style");
|
|
5128
|
-
e.id = "reactaform-styles", e.textContent =
|
|
5164
|
+
e.id = "reactaform-styles", e.textContent = Lr, document.head.appendChild(e);
|
|
5129
5165
|
} catch {
|
|
5130
5166
|
}
|
|
5131
5167
|
}
|
|
5132
|
-
typeof document < "u" &&
|
|
5168
|
+
typeof document < "u" && zn();
|
|
5133
5169
|
export {
|
|
5134
5170
|
R as CSS_CLASSES,
|
|
5135
|
-
|
|
5171
|
+
Wn as ReactaForm,
|
|
5136
5172
|
In as ReactaFormProvider,
|
|
5137
|
-
|
|
5173
|
+
Wt as ReactaFormRenderer,
|
|
5138
5174
|
O as StandardFieldLayout,
|
|
5139
5175
|
jn as Units,
|
|
5140
5176
|
U as combineClasses,
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5177
|
+
Fn as createInstanceFromDefinition,
|
|
5178
|
+
ra as deserializeDefinition,
|
|
5179
|
+
Qn as deserializeInstance,
|
|
5180
|
+
Jn as getAllPlugins,
|
|
5145
5181
|
br as getComponent,
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5182
|
+
Gn as getPlugin,
|
|
5183
|
+
Hn as getSupportedLanguages,
|
|
5184
|
+
Yn as hasPlugin,
|
|
5185
|
+
zn as injectReactaFormStyles,
|
|
5149
5186
|
fe as isDarkTheme,
|
|
5150
|
-
|
|
5151
|
-
|
|
5187
|
+
qn as loadInstance,
|
|
5188
|
+
Bn as loadJsonDefinition,
|
|
5152
5189
|
yr as registerComponent,
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5190
|
+
Xn as registerComponents,
|
|
5191
|
+
Wr as registerFieldCustomValidationHandler,
|
|
5192
|
+
_r as registerFieldTypeValidationHandler,
|
|
5193
|
+
Ur as registerFormValidationHandler,
|
|
5194
|
+
_n as registerPlugin,
|
|
5158
5195
|
Cr as registerSubmissionHandler,
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5196
|
+
ea as serializeDefinition,
|
|
5197
|
+
Zn as serializeInstance,
|
|
5198
|
+
Kn as unregisterPlugin,
|
|
5199
|
+
Un as upgradeInstanceToLatestDefinition,
|
|
5200
|
+
Tr as useDebouncedCallback,
|
|
5164
5201
|
L as useFieldValidator,
|
|
5165
|
-
|
|
5202
|
+
j as useReactaFormContext,
|
|
5166
5203
|
_ as useUncontrolledValidatedInput,
|
|
5167
|
-
|
|
5204
|
+
Tn as validateFieldValue,
|
|
5168
5205
|
ur as validateFieldWithCustomHandler
|
|
5169
5206
|
};
|