reactaform 1.9.0 → 1.9.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/dist/components/fields/Description.d.ts +10 -0
- package/dist/components/form/ReactaForm.d.ts +1 -1
- package/dist/components/form/ReactaFormProvider.d.ts +1 -1
- package/dist/core/reactaFormTypes.d.ts +11 -7
- package/dist/reactaform.cjs.js +20 -6
- package/dist/reactaform.css +1 -1
- package/dist/reactaform.es.js +937 -917
- package/dist/styles/cssClasses.d.ts +1 -0
- package/package.json +1 -1
package/dist/reactaform.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as p, jsxs as D, Fragment as Ie } from "react/jsx-runtime";
|
|
2
2
|
import * as l from "react";
|
|
3
|
-
import { createContext as
|
|
3
|
+
import { createContext as it, useContext as st, useRef as pe, useEffect as Ue, useCallback as ge } from "react";
|
|
4
4
|
import * as de from "react-dom";
|
|
5
|
-
const
|
|
5
|
+
const ct = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
6
6
|
\r
|
|
7
7
|
/* Default Light Theme */\r
|
|
8
8
|
:root {\r
|
|
@@ -65,7 +65,7 @@ const st = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
65
65
|
--reactaform-button-bg: var(--reactaform-success-color);\r
|
|
66
66
|
--reactaform-button-text: #ffffff;\r
|
|
67
67
|
--reactaform-button-padding: var(--reactaform-space) 12px;\r
|
|
68
|
-
--reactaform-button-border-radius:
|
|
68
|
+
--reactaform-button-border-radius: 6px;\r
|
|
69
69
|
--reactaform-button-font-size: 14px;\r
|
|
70
70
|
--reactaform-button-font-weight: var(--reactaform-font-weight);\r
|
|
71
71
|
--reactaform-button-hover-opacity: 0.9;\r
|
|
@@ -200,6 +200,15 @@ const st = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
200
200
|
user-select: none;\r
|
|
201
201
|
}\r
|
|
202
202
|
\r
|
|
203
|
+
/* Description (UI-only display text) */\r
|
|
204
|
+
.reactaform-description {\r
|
|
205
|
+
font-size: var(--reactaform-font-size, 14px);\r
|
|
206
|
+
font-weight: var(--reactaform-font-weight, 500);\r
|
|
207
|
+
margin: var(--reactaform-space, 8px) 0;\r
|
|
208
|
+
color: var(--reactaform-text-color, #000000);\r
|
|
209
|
+
user-select: none;\r
|
|
210
|
+
}\r
|
|
211
|
+
\r
|
|
203
212
|
/* Ensure row layout labels are left-aligned */\r
|
|
204
213
|
\r
|
|
205
214
|
\r
|
|
@@ -292,7 +301,7 @@ const st = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
292
301
|
background-color: var(--reactaform-button-bg, var(--reactaform-success-color, #4CAF50));\r
|
|
293
302
|
color: var(--reactaform-button-text, var(--reactaform-text-color, #000000));\r
|
|
294
303
|
padding: var(--reactaform-button-padding);\r
|
|
295
|
-
border-radius: var(--reactaform-button-border-radius);\r
|
|
304
|
+
border-radius: var(--reactaform-button-border-radius, 6px);\r
|
|
296
305
|
font-size: var(--reactaform-button-font-size);\r
|
|
297
306
|
font-weight: var(--reactaform-button-font-weight);\r
|
|
298
307
|
box-shadow: var(--reactaform-button-shadow);\r
|
|
@@ -300,10 +309,15 @@ const st = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
300
309
|
border: none;\r
|
|
301
310
|
cursor: pointer;\r
|
|
302
311
|
transition: opacity 0.2s ease;\r
|
|
312
|
+
width: 100%;\r
|
|
313
|
+
display: flex;\r
|
|
314
|
+
justify-content: center;\r
|
|
315
|
+
align-items: center;\r
|
|
303
316
|
}\r
|
|
304
317
|
\r
|
|
305
318
|
.reactaform-button:hover:not(:disabled) {\r
|
|
306
319
|
opacity: var(--reactaform-button-hover-opacity);\r
|
|
320
|
+
background-color: var(--reactaform-button-bg-hover, #0056b3);\r
|
|
307
321
|
}\r
|
|
308
322
|
\r
|
|
309
323
|
.reactaform-button:disabled {\r
|
|
@@ -380,8 +394,8 @@ const st = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
380
394
|
\r
|
|
381
395
|
\r
|
|
382
396
|
}\r
|
|
383
|
-
`, Ee =
|
|
384
|
-
const e =
|
|
397
|
+
`, Ee = it(void 0), B = () => {
|
|
398
|
+
const e = st(Ee);
|
|
385
399
|
if (!e)
|
|
386
400
|
throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");
|
|
387
401
|
return e;
|
|
@@ -432,30 +446,30 @@ class ne {
|
|
|
432
446
|
return n !== void 0 ? n : t;
|
|
433
447
|
}
|
|
434
448
|
}
|
|
435
|
-
const
|
|
436
|
-
function
|
|
437
|
-
const n = pe(),
|
|
449
|
+
const or = typeof process < "u" && process.env.NODE_ENV === "test";
|
|
450
|
+
function lt(e, r = 300, t) {
|
|
451
|
+
const n = pe(), o = pe(e), a = pe(null), c = t?.leading === !0, s = t?.trailing !== !1;
|
|
438
452
|
Ue(() => {
|
|
439
|
-
|
|
453
|
+
o.current = e;
|
|
440
454
|
}, [e]), Ue(() => () => {
|
|
441
455
|
n.current && clearTimeout(n.current);
|
|
442
456
|
}, []);
|
|
443
457
|
const i = (f) => {
|
|
444
|
-
|
|
458
|
+
o.current(...f);
|
|
445
459
|
}, d = ge(() => {
|
|
446
|
-
n.current && (clearTimeout(n.current), n.current = void 0),
|
|
460
|
+
n.current && (clearTimeout(n.current), n.current = void 0), a.current = null;
|
|
447
461
|
}, []), m = ge(() => {
|
|
448
|
-
n.current && (clearTimeout(n.current), n.current = void 0), s &&
|
|
462
|
+
n.current && (clearTimeout(n.current), n.current = void 0), s && a.current && (i(a.current), a.current = null);
|
|
449
463
|
}, [s]);
|
|
450
464
|
return { callback: ge(
|
|
451
465
|
(...f) => {
|
|
452
|
-
if (
|
|
466
|
+
if (or) {
|
|
453
467
|
i(f);
|
|
454
468
|
return;
|
|
455
469
|
}
|
|
456
470
|
const b = c && !n.current;
|
|
457
|
-
|
|
458
|
-
n.current = void 0, s &&
|
|
471
|
+
a.current = f, b && i(f), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
|
|
472
|
+
n.current = void 0, s && a.current && (i(a.current), a.current = null);
|
|
459
473
|
}, r);
|
|
460
474
|
},
|
|
461
475
|
[c, s, r]
|
|
@@ -469,33 +483,34 @@ const V = {
|
|
|
469
483
|
inputNumber: "reactaform-input--number",
|
|
470
484
|
inputSelect: "reactaform-select",
|
|
471
485
|
rangeInput: "reactaform-input--range",
|
|
472
|
-
button: "reactaform-button"
|
|
486
|
+
button: "reactaform-button",
|
|
487
|
+
description: "reactaform-description"
|
|
473
488
|
}, U = (...e) => {
|
|
474
489
|
const r = [];
|
|
475
490
|
for (const t of e)
|
|
476
|
-
t && (typeof t == "string" ? r.push(t) : typeof t == "object" && Object.entries(t).forEach(([n,
|
|
477
|
-
|
|
491
|
+
t && (typeof t == "string" ? r.push(t) : typeof t == "object" && Object.entries(t).forEach(([n, o]) => {
|
|
492
|
+
o && r.push(n);
|
|
478
493
|
}));
|
|
479
494
|
return r.join(" ");
|
|
480
495
|
};
|
|
481
496
|
function ie(e) {
|
|
482
497
|
return e.toLowerCase().includes("dark");
|
|
483
498
|
}
|
|
484
|
-
function
|
|
499
|
+
function ut(e) {
|
|
485
500
|
if (!e) return !1;
|
|
486
501
|
const r = e.trim();
|
|
487
|
-
let t = 0, n = 0,
|
|
502
|
+
let t = 0, n = 0, o = 0;
|
|
488
503
|
if (r.startsWith("#")) {
|
|
489
504
|
const c = r.substring(1);
|
|
490
|
-
c.length === 3 || c.length === 4 ? (t = parseInt(c[0] + c[0], 16), n = parseInt(c[1] + c[1], 16),
|
|
505
|
+
c.length === 3 || c.length === 4 ? (t = parseInt(c[0] + c[0], 16), n = parseInt(c[1] + c[1], 16), o = 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), o = parseInt(c.substring(4, 6), 16));
|
|
491
506
|
} else if (r.startsWith("rgb")) {
|
|
492
507
|
const c = r.match(/\d+(\.\d+)?/g);
|
|
493
|
-
c && c.length >= 3 && (t = Math.min(255, Math.max(0, parseFloat(c[0]))), n = Math.min(255, Math.max(0, parseFloat(c[1]))),
|
|
508
|
+
c && c.length >= 3 && (t = Math.min(255, Math.max(0, parseFloat(c[0]))), n = Math.min(255, Math.max(0, parseFloat(c[1]))), o = Math.min(255, Math.max(0, parseFloat(c[2]))));
|
|
494
509
|
} else
|
|
495
510
|
return !1;
|
|
496
|
-
return (t * 299 + n * 587 +
|
|
511
|
+
return (t * 299 + n * 587 + o * 114) / 1e3 < 128;
|
|
497
512
|
}
|
|
498
|
-
const
|
|
513
|
+
const mt = () => /* @__PURE__ */ D(
|
|
499
514
|
"svg",
|
|
500
515
|
{
|
|
501
516
|
width: "1em",
|
|
@@ -511,13 +526,13 @@ const ut = () => /* @__PURE__ */ D(
|
|
|
511
526
|
/* @__PURE__ */ p("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
512
527
|
]
|
|
513
528
|
}
|
|
514
|
-
),
|
|
515
|
-
const { t: n, theme:
|
|
529
|
+
), dt = ({ content: e, size: r = "medium", animation: t = !0 }) => {
|
|
530
|
+
const { t: n, theme: o, formStyle: a, fieldStyle: c } = B(), [s, i] = l.useState(!1), [d, m] = l.useState({ x: 0, y: 0 }), [u, f] = l.useState(!1), b = l.useRef(null), C = l.useRef(null), N = l.useRef(null), h = l.useId(), y = ie(o), [E, F] = l.useState(void 0);
|
|
516
531
|
l.useLayoutEffect(() => {
|
|
517
532
|
if (!b.current) return;
|
|
518
533
|
const I = "rgba(255,255,255,0.1)", g = getComputedStyle(b.current).getPropertyValue("--reactaform-primary-bg").trim();
|
|
519
534
|
if (g && typeof CSS < "u" && CSS.supports?.("color: color-mix(in srgb, red, blue)")) {
|
|
520
|
-
const w =
|
|
535
|
+
const w = ut(g) ? "black" : "white";
|
|
521
536
|
F(`color-mix(in srgb, var(--reactaform-primary-bg) 85%, ${w} 15%)`);
|
|
522
537
|
} else
|
|
523
538
|
F(I);
|
|
@@ -572,19 +587,19 @@ const ut = () => /* @__PURE__ */ D(
|
|
|
572
587
|
return (S && j ? j[S] : void 0) ?? {};
|
|
573
588
|
};
|
|
574
589
|
return {
|
|
575
|
-
icon: { ...v.icon, ...g(
|
|
576
|
-
text: { ...v.text, ...g(
|
|
590
|
+
icon: { ...v.icon, ...g(a, "tooltip", "icon"), ...g(c, "tooltip", "icon") },
|
|
591
|
+
text: { ...v.text, ...g(a, "tooltip", "text"), ...g(c, "tooltip", "text") },
|
|
577
592
|
textVisible: v.textVisible
|
|
578
593
|
};
|
|
579
|
-
}, [y, r, t,
|
|
594
|
+
}, [y, r, t, a, c, E]);
|
|
580
595
|
l.useLayoutEffect(() => {
|
|
581
|
-
if (!s || !b.current || !
|
|
596
|
+
if (!s || !b.current || !C.current) {
|
|
582
597
|
f(!1);
|
|
583
598
|
return;
|
|
584
599
|
}
|
|
585
600
|
const I = b.current.getBoundingClientRect();
|
|
586
|
-
|
|
587
|
-
const v =
|
|
601
|
+
N.current = I;
|
|
602
|
+
const v = C.current.getBoundingClientRect(), g = 8, w = window.innerWidth, x = window.innerHeight, k = -4;
|
|
588
603
|
let S = I.right + g, A = I.top + I.height / 2 - v.height / 2 + k;
|
|
589
604
|
S + v.width > w - g && (S = I.left - g - v.width), S = Math.max(g, Math.min(S, w - v.width - g)), A = Math.max(g, Math.min(A, x - v.height - g)), m({ x: S, y: A }), f(!0);
|
|
590
605
|
const j = b.current.closest("[data-reactaform-theme]"), K = document.getElementById("popup-root");
|
|
@@ -602,7 +617,7 @@ const ut = () => /* @__PURE__ */ D(
|
|
|
602
617
|
const $ = typeof document < "u" ? document.getElementById("popup-root") : null, R = /* @__PURE__ */ p(
|
|
603
618
|
"div",
|
|
604
619
|
{
|
|
605
|
-
ref:
|
|
620
|
+
ref: C,
|
|
606
621
|
"data-tooltip-id": h,
|
|
607
622
|
style: {
|
|
608
623
|
...M.text,
|
|
@@ -629,31 +644,31 @@ const ut = () => /* @__PURE__ */ D(
|
|
|
629
644
|
style: {
|
|
630
645
|
...M.icon
|
|
631
646
|
},
|
|
632
|
-
children: /* @__PURE__ */ p(
|
|
647
|
+
children: /* @__PURE__ */ p(mt, {})
|
|
633
648
|
}
|
|
634
649
|
),
|
|
635
650
|
s && ($ ? de.createPortal(R, $) : R)
|
|
636
651
|
] });
|
|
637
|
-
},
|
|
652
|
+
}, ar = l.memo(dt), ve = l.memo(({
|
|
638
653
|
field: e,
|
|
639
654
|
error: r,
|
|
640
655
|
children: t,
|
|
641
656
|
showLabel: n = !0
|
|
642
657
|
}) => {
|
|
643
|
-
const { t:
|
|
658
|
+
const { t: o } = B(), a = e.labelLayout === "column-center" ? "center" : "left", c = l.useMemo(() => {
|
|
644
659
|
const d = {
|
|
645
660
|
display: "flex",
|
|
646
661
|
flexDirection: "column",
|
|
647
662
|
gap: "var(--reactaform-label-gap, 4px)"
|
|
648
663
|
};
|
|
649
|
-
return d["--label-align"] =
|
|
650
|
-
}, [
|
|
651
|
-
textAlign:
|
|
664
|
+
return d["--label-align"] = a, d;
|
|
665
|
+
}, [a]), s = l.useMemo(() => ({
|
|
666
|
+
textAlign: a,
|
|
652
667
|
width: "100%",
|
|
653
668
|
minWidth: "unset",
|
|
654
669
|
display: "block",
|
|
655
670
|
marginBottom: "10px"
|
|
656
|
-
}), [
|
|
671
|
+
}), [a]), i = l.useMemo(() => ({
|
|
657
672
|
display: "flex",
|
|
658
673
|
alignItems: "center",
|
|
659
674
|
gap: "var(--reactaform-inline-gap, 8px)",
|
|
@@ -667,12 +682,12 @@ const ut = () => /* @__PURE__ */ D(
|
|
|
667
682
|
className: V.label,
|
|
668
683
|
htmlFor: e.name,
|
|
669
684
|
style: s,
|
|
670
|
-
children:
|
|
685
|
+
children: o(e.displayName)
|
|
671
686
|
}
|
|
672
687
|
),
|
|
673
688
|
/* @__PURE__ */ D("div", { style: i, children: [
|
|
674
689
|
/* @__PURE__ */ p("div", { style: { flex: 1, minWidth: 0 }, children: t }),
|
|
675
|
-
e.tooltip && /* @__PURE__ */ p(
|
|
690
|
+
e.tooltip && /* @__PURE__ */ p(ar, { content: e.tooltip })
|
|
676
691
|
] }),
|
|
677
692
|
r && /* @__PURE__ */ p(Me, { id: `${e.name}-error`, children: r })
|
|
678
693
|
] });
|
|
@@ -684,7 +699,7 @@ const ir = l.memo(({
|
|
|
684
699
|
children: t,
|
|
685
700
|
rightAlign: n = !1
|
|
686
701
|
}) => {
|
|
687
|
-
const { t:
|
|
702
|
+
const { t: o } = B(), a = l.useMemo(() => ({
|
|
688
703
|
display: "flex",
|
|
689
704
|
alignItems: "center",
|
|
690
705
|
gap: "3px"
|
|
@@ -697,13 +712,13 @@ const ir = l.memo(({
|
|
|
697
712
|
className: V.label,
|
|
698
713
|
htmlFor: e.name,
|
|
699
714
|
style: { textAlign: "left" },
|
|
700
|
-
children:
|
|
715
|
+
children: o(e.displayName)
|
|
701
716
|
}
|
|
702
717
|
),
|
|
703
718
|
/* @__PURE__ */ D("div", { children: [
|
|
704
|
-
/* @__PURE__ */ D("div", { style:
|
|
719
|
+
/* @__PURE__ */ D("div", { style: a, children: [
|
|
705
720
|
n ? /* @__PURE__ */ p("div", { style: { display: "flex", flex: 1, justifyContent: "flex-end" }, children: t }) : t,
|
|
706
|
-
e.tooltip && /* @__PURE__ */ p(
|
|
721
|
+
e.tooltip && /* @__PURE__ */ p(ar, { content: e.tooltip })
|
|
707
722
|
] }),
|
|
708
723
|
r && /* @__PURE__ */ p(Me, { id: `${e.name}-error`, children: r })
|
|
709
724
|
] })
|
|
@@ -733,7 +748,7 @@ const Me = l.memo(({ children: e, id: r }) => {
|
|
|
733
748
|
});
|
|
734
749
|
Me.displayName = "ErrorDiv";
|
|
735
750
|
const sr = l.memo(({ name: e, onChange: r }) => {
|
|
736
|
-
const { t } =
|
|
751
|
+
const { t } = B();
|
|
737
752
|
return /* @__PURE__ */ D("div", { style: { marginBottom: 16 }, children: [
|
|
738
753
|
/* @__PURE__ */ D("div", { style: { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 12, alignItems: "center" }, children: [
|
|
739
754
|
/* @__PURE__ */ p(
|
|
@@ -765,11 +780,11 @@ const sr = l.memo(({ name: e, onChange: r }) => {
|
|
|
765
780
|
] });
|
|
766
781
|
});
|
|
767
782
|
sr.displayName = "InstanceName";
|
|
768
|
-
class
|
|
783
|
+
class ft extends ne {
|
|
769
784
|
registerInCategory(r, t, n) {
|
|
770
785
|
this.get(r) || this.register(r, {});
|
|
771
|
-
const
|
|
772
|
-
|
|
786
|
+
const o = this.get(r);
|
|
787
|
+
o[t] = n;
|
|
773
788
|
}
|
|
774
789
|
getFromCategory(r, t) {
|
|
775
790
|
return this.get(r)?.[t];
|
|
@@ -781,15 +796,15 @@ class dt extends ne {
|
|
|
781
796
|
return this.list();
|
|
782
797
|
}
|
|
783
798
|
}
|
|
784
|
-
const cr = new ne(), lr = new
|
|
785
|
-
function
|
|
799
|
+
const cr = new ne(), lr = new ft(), Fe = new ne();
|
|
800
|
+
function pt(e, r) {
|
|
786
801
|
cr.register(e, r);
|
|
787
802
|
}
|
|
788
|
-
function
|
|
803
|
+
function gt(e, r, t) {
|
|
789
804
|
lr.registerInCategory(e, r, t);
|
|
790
805
|
}
|
|
791
|
-
function
|
|
792
|
-
if (
|
|
806
|
+
function ht(e, r) {
|
|
807
|
+
if (on(e)) {
|
|
793
808
|
console.warn(
|
|
794
809
|
`[ReactaForm] Can't override builtin type field validation handler for type "${e}".`
|
|
795
810
|
);
|
|
@@ -797,7 +812,7 @@ function gt(e, r) {
|
|
|
797
812
|
}
|
|
798
813
|
Fe.register(e, r);
|
|
799
814
|
}
|
|
800
|
-
function
|
|
815
|
+
function H(e, r) {
|
|
801
816
|
Fe.register(e, r);
|
|
802
817
|
}
|
|
803
818
|
function ur(e, r) {
|
|
@@ -809,29 +824,29 @@ function mr(e) {
|
|
|
809
824
|
function dr(e) {
|
|
810
825
|
return Fe.get(e) || null;
|
|
811
826
|
}
|
|
812
|
-
function
|
|
827
|
+
function bt(e) {
|
|
813
828
|
return (typeof e == "object" || typeof e == "function") && e !== null && typeof e.then == "function";
|
|
814
829
|
}
|
|
815
830
|
const We = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map();
|
|
816
831
|
function fr(e, r, t, n) {
|
|
817
832
|
if (!r || !r.validationHandlerName)
|
|
818
833
|
return null;
|
|
819
|
-
let
|
|
834
|
+
let o, a;
|
|
820
835
|
if (typeof r.validationHandlerName == "string")
|
|
821
|
-
|
|
836
|
+
o = e, a = r.validationHandlerName;
|
|
822
837
|
else if (Array.isArray(r.validationHandlerName)) {
|
|
823
838
|
const [i, d] = r.validationHandlerName;
|
|
824
839
|
if (d)
|
|
825
|
-
|
|
840
|
+
o = i, a = d;
|
|
826
841
|
else if (i)
|
|
827
|
-
|
|
842
|
+
o = e, a = i;
|
|
828
843
|
else
|
|
829
844
|
return null;
|
|
830
845
|
} else
|
|
831
846
|
return null;
|
|
832
|
-
const c = `${
|
|
847
|
+
const c = `${o}:${a}`;
|
|
833
848
|
let s = We.get(c);
|
|
834
|
-
if (s === void 0 && (s = ur(
|
|
849
|
+
if (s === void 0 && (s = ur(o, a) || null, We.set(c, s)), s)
|
|
835
850
|
try {
|
|
836
851
|
return s(r.name, t, n) || null;
|
|
837
852
|
} catch (i) {
|
|
@@ -839,38 +854,38 @@ function fr(e, r, t, n) {
|
|
|
839
854
|
}
|
|
840
855
|
return null;
|
|
841
856
|
}
|
|
842
|
-
function
|
|
857
|
+
function uo(e, r, t, n) {
|
|
843
858
|
return fr(e, r, t, n);
|
|
844
859
|
}
|
|
845
860
|
function pr(e, r, t, n) {
|
|
846
|
-
const
|
|
847
|
-
if (
|
|
848
|
-
const
|
|
849
|
-
if (
|
|
850
|
-
return
|
|
861
|
+
const o = dr(r.type);
|
|
862
|
+
if (o) {
|
|
863
|
+
const a = o(r, t, n);
|
|
864
|
+
if (a)
|
|
865
|
+
return a;
|
|
851
866
|
} else if (String(t ?? "").trim() === "")
|
|
852
867
|
return r.required ? n("Value required") : null;
|
|
853
868
|
return fr(e, r, t, n);
|
|
854
869
|
}
|
|
855
|
-
async function
|
|
870
|
+
async function yt(e, r, t) {
|
|
856
871
|
if (!e || typeof e.validationHandlerName != "string")
|
|
857
872
|
return null;
|
|
858
873
|
const n = e.validationHandlerName;
|
|
859
|
-
let
|
|
860
|
-
if (
|
|
874
|
+
let o = _e.get(n);
|
|
875
|
+
if (o === void 0 && (o = mr(n) || null, _e.set(n, o)), o)
|
|
861
876
|
try {
|
|
862
|
-
const
|
|
863
|
-
return
|
|
864
|
-
} catch (
|
|
865
|
-
return [String(
|
|
877
|
+
const a = o(r, t);
|
|
878
|
+
return bt(a) ? await a || null : a || null;
|
|
879
|
+
} catch (a) {
|
|
880
|
+
return [String(a instanceof Error ? a.message : a)];
|
|
866
881
|
}
|
|
867
882
|
return null;
|
|
868
883
|
}
|
|
869
884
|
function T(e, r) {
|
|
870
|
-
const { definitionName: t, t: n, fieldValidationMode:
|
|
885
|
+
const { definitionName: t, t: n, fieldValidationMode: o } = B();
|
|
871
886
|
return l.useCallback(
|
|
872
|
-
(
|
|
873
|
-
[t, e, n,
|
|
887
|
+
(a) => o === "onEdit" || o === "realTime" ? pr(t, e, a, n) : r ?? null,
|
|
888
|
+
[t, e, n, o, r]
|
|
874
889
|
);
|
|
875
890
|
}
|
|
876
891
|
const gr = ({
|
|
@@ -878,12 +893,12 @@ const gr = ({
|
|
|
878
893
|
value: r = !1,
|
|
879
894
|
onChange: t,
|
|
880
895
|
onError: n,
|
|
881
|
-
error:
|
|
896
|
+
error: o
|
|
882
897
|
}) => {
|
|
883
|
-
const { t:
|
|
898
|
+
const { t: a } = B(), s = T(e, o)(r);
|
|
884
899
|
l.useEffect(() => {
|
|
885
|
-
|
|
886
|
-
}, [s,
|
|
900
|
+
o || n?.(s);
|
|
901
|
+
}, [s, o, n]);
|
|
887
902
|
const i = l.useCallback(
|
|
888
903
|
(u) => {
|
|
889
904
|
t?.(u.target.checked);
|
|
@@ -911,7 +926,7 @@ const gr = ({
|
|
|
911
926
|
className: V.label,
|
|
912
927
|
htmlFor: m,
|
|
913
928
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
914
|
-
children:
|
|
929
|
+
children: a(e.displayName)
|
|
915
930
|
}
|
|
916
931
|
),
|
|
917
932
|
/* @__PURE__ */ p(
|
|
@@ -941,26 +956,26 @@ const gr = ({
|
|
|
941
956
|
) });
|
|
942
957
|
};
|
|
943
958
|
gr.displayName = "CheckboxInput";
|
|
944
|
-
const
|
|
959
|
+
const vt = l.memo(gr);
|
|
945
960
|
function _({ value: e, onChange: r, onError: t, validate: n }) {
|
|
946
|
-
const
|
|
961
|
+
const o = l.useRef(null), a = l.useRef(null), c = l.useRef(t), [s, i] = l.useState(null);
|
|
947
962
|
l.useEffect(() => {
|
|
948
963
|
c.current = t;
|
|
949
964
|
}, [t]), l.useEffect(() => {
|
|
950
965
|
const m = String(e ?? "");
|
|
951
|
-
if (!(document.activeElement ===
|
|
966
|
+
if (!(document.activeElement === o.current)) {
|
|
952
967
|
const f = n(m);
|
|
953
|
-
f !==
|
|
968
|
+
f !== a.current && (a.current = f, c.current?.(f ?? null), i(f)), o.current && o.current.value !== m && (o.current.value = m);
|
|
954
969
|
}
|
|
955
970
|
}, [e, n]);
|
|
956
971
|
const d = l.useCallback(
|
|
957
972
|
(m) => {
|
|
958
973
|
const u = m.target.value, f = n(u);
|
|
959
|
-
f !==
|
|
974
|
+
f !== a.current && (a.current = f, i(f), c.current?.(f ?? null)), r?.(u);
|
|
960
975
|
},
|
|
961
976
|
[r, n]
|
|
962
977
|
);
|
|
963
|
-
return { inputRef:
|
|
978
|
+
return { inputRef: o, error: s, handleChange: d };
|
|
964
979
|
}
|
|
965
980
|
const Ke = [
|
|
966
981
|
{ label: "Black", value: "#000000" },
|
|
@@ -977,11 +992,11 @@ const Ke = [
|
|
|
977
992
|
{ label: "Gray", value: "#808080" },
|
|
978
993
|
{ label: "Light Gray", value: "#d3d3d3" },
|
|
979
994
|
{ label: "Pink", value: "#ffc0cb" }
|
|
980
|
-
],
|
|
981
|
-
if (!e || !
|
|
995
|
+
], xt = /^#([0-9A-F]{3}){1,2}$/i, wt = "#000000", St = (e) => xt.test(e), he = (e) => {
|
|
996
|
+
if (!e || !St(e)) return wt;
|
|
982
997
|
const r = e.toLowerCase();
|
|
983
998
|
return r.length === 4 ? "#" + r.slice(1).split("").map((t) => t + t).join("") : r;
|
|
984
|
-
},
|
|
999
|
+
}, Ct = (e) => {
|
|
985
1000
|
const r = parseInt(e.slice(1), 16);
|
|
986
1001
|
return {
|
|
987
1002
|
r: r >> 16 & 255,
|
|
@@ -993,9 +1008,9 @@ const Ke = [
|
|
|
993
1008
|
value: r,
|
|
994
1009
|
onChange: t,
|
|
995
1010
|
onError: n,
|
|
996
|
-
error:
|
|
1011
|
+
error: o
|
|
997
1012
|
}) => {
|
|
998
|
-
const { t:
|
|
1013
|
+
const { t: a } = B(), c = T(e, o), s = l.useMemo(
|
|
999
1014
|
() => he(r),
|
|
1000
1015
|
[r]
|
|
1001
1016
|
), { inputRef: i, error: d, handleChange: m } = _({
|
|
@@ -1015,7 +1030,7 @@ const Ke = [
|
|
|
1015
1030
|
});
|
|
1016
1031
|
},
|
|
1017
1032
|
[m]
|
|
1018
|
-
),
|
|
1033
|
+
), C = l.useCallback(
|
|
1019
1034
|
(M) => {
|
|
1020
1035
|
const $ = he(M.target.value);
|
|
1021
1036
|
f($), m({
|
|
@@ -1027,7 +1042,7 @@ const Ke = [
|
|
|
1027
1042
|
() => new Set(Ke.map((M) => M.value)),
|
|
1028
1043
|
[]
|
|
1029
1044
|
).has(u), { r: y, g: E, b: F } = l.useMemo(
|
|
1030
|
-
() =>
|
|
1045
|
+
() => Ct(u),
|
|
1031
1046
|
[u]
|
|
1032
1047
|
);
|
|
1033
1048
|
return /* @__PURE__ */ p(O, { field: e, error: d, children: /* @__PURE__ */ D(
|
|
@@ -1045,14 +1060,14 @@ const Ke = [
|
|
|
1045
1060
|
{
|
|
1046
1061
|
id: e.name,
|
|
1047
1062
|
value: u,
|
|
1048
|
-
onChange:
|
|
1063
|
+
onChange: C,
|
|
1049
1064
|
className: U(
|
|
1050
1065
|
V.input,
|
|
1051
1066
|
V.inputSelect
|
|
1052
1067
|
),
|
|
1053
1068
|
"aria-invalid": !!d,
|
|
1054
1069
|
children: [
|
|
1055
|
-
Ke.map((M) => /* @__PURE__ */ p("option", { value: M.value, children:
|
|
1070
|
+
Ke.map((M) => /* @__PURE__ */ p("option", { value: M.value, children: a(M.label) }, M.value)),
|
|
1056
1071
|
!h && /* @__PURE__ */ D("option", { value: u, children: [
|
|
1057
1072
|
"(",
|
|
1058
1073
|
y,
|
|
@@ -1097,7 +1112,7 @@ const Ke = [
|
|
|
1097
1112
|
) });
|
|
1098
1113
|
};
|
|
1099
1114
|
hr.displayName = "ColorInput";
|
|
1100
|
-
const
|
|
1115
|
+
const Nt = l.memo(hr), Ge = (e) => {
|
|
1101
1116
|
if (!e) return null;
|
|
1102
1117
|
const r = new Date(e);
|
|
1103
1118
|
return isNaN(r.getTime()) ? null : r;
|
|
@@ -1107,8 +1122,8 @@ const Ct = l.memo(hr), Ge = (e) => {
|
|
|
1107
1122
|
return Ge(e) ? e : "";
|
|
1108
1123
|
const t = Ge(e);
|
|
1109
1124
|
if (t) {
|
|
1110
|
-
const n = t.getUTCFullYear(),
|
|
1111
|
-
return `${n}-${
|
|
1125
|
+
const n = t.getUTCFullYear(), o = String(t.getUTCMonth() + 1).padStart(2, "0"), a = String(t.getUTCDate()).padStart(2, "0");
|
|
1126
|
+
return `${n}-${o}-${a}`;
|
|
1112
1127
|
}
|
|
1113
1128
|
return "";
|
|
1114
1129
|
}, br = ({
|
|
@@ -1116,13 +1131,13 @@ const Ct = l.memo(hr), Ge = (e) => {
|
|
|
1116
1131
|
value: r,
|
|
1117
1132
|
onChange: t,
|
|
1118
1133
|
onError: n,
|
|
1119
|
-
error:
|
|
1134
|
+
error: o
|
|
1120
1135
|
}) => {
|
|
1121
|
-
const
|
|
1136
|
+
const a = T(e, o), c = Je(r), { inputRef: s, error: i, handleChange: d } = _({
|
|
1122
1137
|
value: c,
|
|
1123
1138
|
onChange: t,
|
|
1124
1139
|
onError: n,
|
|
1125
|
-
validate:
|
|
1140
|
+
validate: a
|
|
1126
1141
|
});
|
|
1127
1142
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1128
1143
|
"input",
|
|
@@ -1141,38 +1156,50 @@ const Ct = l.memo(hr), Ge = (e) => {
|
|
|
1141
1156
|
) });
|
|
1142
1157
|
};
|
|
1143
1158
|
br.displayName = "DateInput";
|
|
1144
|
-
const
|
|
1159
|
+
const kt = l.memo(br), yr = ({ field: e }) => {
|
|
1160
|
+
const { t: r } = B(), { displayText: t = "", textAlign: n = "left", allowHtml: o = !1 } = e;
|
|
1161
|
+
return /* @__PURE__ */ p(
|
|
1162
|
+
"div",
|
|
1163
|
+
{
|
|
1164
|
+
className: V.description,
|
|
1165
|
+
style: { textAlign: n },
|
|
1166
|
+
...o ? { dangerouslySetInnerHTML: { __html: r(t) } } : { children: r(t) }
|
|
1167
|
+
}
|
|
1168
|
+
);
|
|
1169
|
+
};
|
|
1170
|
+
yr.displayName = "Description";
|
|
1171
|
+
const It = l.memo(yr), vr = ({
|
|
1145
1172
|
field: e,
|
|
1146
1173
|
value: r,
|
|
1147
1174
|
onChange: t,
|
|
1148
1175
|
onError: n,
|
|
1149
|
-
error:
|
|
1176
|
+
error: o
|
|
1150
1177
|
}) => {
|
|
1151
|
-
const { t:
|
|
1178
|
+
const { t: a, theme: c, formStyle: s, fieldStyle: i } = B(), d = l.useRef(null), m = l.useRef(n), [u, f] = l.useState(!1), [b, C] = l.useState(null);
|
|
1152
1179
|
l.useEffect(() => {
|
|
1153
1180
|
m.current = n;
|
|
1154
1181
|
}, [n]);
|
|
1155
|
-
const
|
|
1182
|
+
const N = T(e, o), [h, y] = l.useState(null), E = l.useRef(null);
|
|
1156
1183
|
l.useEffect(() => {
|
|
1157
1184
|
const g = String(r ?? "");
|
|
1158
|
-
let w =
|
|
1185
|
+
let w = N(g);
|
|
1159
1186
|
if (w && e.options.length > 0) {
|
|
1160
1187
|
const x = String(e.options[0].value);
|
|
1161
1188
|
t?.(x), w = null;
|
|
1162
1189
|
}
|
|
1163
1190
|
w !== E.current && (E.current = w, y(w), m.current?.(w ?? null));
|
|
1164
|
-
}, [r,
|
|
1191
|
+
}, [r, N, t, e.options]);
|
|
1165
1192
|
const F = () => {
|
|
1166
1193
|
if (!d.current) return;
|
|
1167
1194
|
const g = d.current.getBoundingClientRect();
|
|
1168
|
-
|
|
1195
|
+
C({ x: g.left, y: g.bottom }), f((w) => !w);
|
|
1169
1196
|
}, M = (g) => {
|
|
1170
|
-
const w =
|
|
1197
|
+
const w = N(g);
|
|
1171
1198
|
w !== E.current && (E.current = w, y(w), m.current?.(w ?? null)), t?.(g), f(!1);
|
|
1172
1199
|
}, $ = l.useMemo(() => {
|
|
1173
1200
|
const g = e.options.find((w) => String(w.value) === String(r));
|
|
1174
|
-
return g ?
|
|
1175
|
-
}, [e.options, r,
|
|
1201
|
+
return g ? a(g.label) : "";
|
|
1202
|
+
}, [e.options, r, a]), R = (g, w, x) => {
|
|
1176
1203
|
if (!w) return {};
|
|
1177
1204
|
const S = g?.[w];
|
|
1178
1205
|
return (x && S ? S[x] : void 0) ?? {};
|
|
@@ -1222,7 +1249,7 @@ const Nt = l.memo(br), yr = ({
|
|
|
1222
1249
|
}
|
|
1223
1250
|
) }),
|
|
1224
1251
|
u && b && /* @__PURE__ */ p(
|
|
1225
|
-
|
|
1252
|
+
Et,
|
|
1226
1253
|
{
|
|
1227
1254
|
position: b,
|
|
1228
1255
|
options: e.options,
|
|
@@ -1231,24 +1258,24 @@ const Nt = l.memo(br), yr = ({
|
|
|
1231
1258
|
onClose: () => f(!1),
|
|
1232
1259
|
controlRef: d,
|
|
1233
1260
|
theme: c,
|
|
1234
|
-
t:
|
|
1261
|
+
t: a
|
|
1235
1262
|
}
|
|
1236
1263
|
)
|
|
1237
1264
|
] });
|
|
1238
|
-
},
|
|
1265
|
+
}, Et = ({
|
|
1239
1266
|
position: e,
|
|
1240
1267
|
options: r,
|
|
1241
1268
|
selectedValue: t,
|
|
1242
1269
|
onSelect: n,
|
|
1243
|
-
onClose:
|
|
1244
|
-
controlRef:
|
|
1270
|
+
onClose: o,
|
|
1271
|
+
controlRef: a,
|
|
1245
1272
|
theme: c,
|
|
1246
1273
|
t: s
|
|
1247
1274
|
}) => {
|
|
1248
|
-
const i = l.useRef(null), [d, m] = l.useState(-1), { formStyle: u, fieldStyle: f } =
|
|
1275
|
+
const i = l.useRef(null), [d, m] = l.useState(-1), { formStyle: u, fieldStyle: f } = B(), b = ie(c ?? "light");
|
|
1249
1276
|
l.useLayoutEffect(() => {
|
|
1250
|
-
if (!
|
|
1251
|
-
const v =
|
|
1277
|
+
if (!a.current) return;
|
|
1278
|
+
const v = a.current.closest("[data-reactaform-theme]"), g = document.getElementById("popup-root");
|
|
1252
1279
|
if (v && g) {
|
|
1253
1280
|
const w = getComputedStyle(v);
|
|
1254
1281
|
g.style.setProperty(
|
|
@@ -1262,12 +1289,12 @@ const Nt = l.memo(br), yr = ({
|
|
|
1262
1289
|
w.getPropertyValue("--reactaform-option-menu-hover-bg")
|
|
1263
1290
|
);
|
|
1264
1291
|
}
|
|
1265
|
-
}, [
|
|
1266
|
-
const
|
|
1292
|
+
}, [a]);
|
|
1293
|
+
const C = (v, g, w) => {
|
|
1267
1294
|
if (!g) return {};
|
|
1268
1295
|
const k = v?.[g];
|
|
1269
1296
|
return (w && k ? k[w] : void 0) ?? {};
|
|
1270
|
-
},
|
|
1297
|
+
}, N = l.useMemo(() => ({
|
|
1271
1298
|
maxHeight: 200,
|
|
1272
1299
|
overflowY: "auto",
|
|
1273
1300
|
background: "var(--reactaform-secondary-bg, #fff)",
|
|
@@ -1278,8 +1305,8 @@ const Nt = l.memo(br), yr = ({
|
|
|
1278
1305
|
pointerEvents: "auto",
|
|
1279
1306
|
color: "var(--reactaform-text-color, #000)",
|
|
1280
1307
|
fontSize: "var(--reactaform-popup-font-size, 0.875rem)",
|
|
1281
|
-
...
|
|
1282
|
-
...
|
|
1308
|
+
...C(u, "dropdown", "popup"),
|
|
1309
|
+
...C(f, void 0, "popup")
|
|
1283
1310
|
}), [u, f]), h = l.useMemo(() => ({
|
|
1284
1311
|
padding: "6px 8px",
|
|
1285
1312
|
cursor: "pointer",
|
|
@@ -1287,16 +1314,16 @@ const Nt = l.memo(br), yr = ({
|
|
|
1287
1314
|
alignItems: "center",
|
|
1288
1315
|
background: "transparent",
|
|
1289
1316
|
color: "var(--reactaform-text-color, #000)",
|
|
1290
|
-
...
|
|
1291
|
-
...
|
|
1317
|
+
...C(u, "dropdown", "option"),
|
|
1318
|
+
...C(f, void 0, "option")
|
|
1292
1319
|
}), [u, f]);
|
|
1293
1320
|
l.useEffect(() => {
|
|
1294
1321
|
const v = (g) => {
|
|
1295
1322
|
const w = g.target;
|
|
1296
|
-
!i.current?.contains(w) && !
|
|
1323
|
+
!i.current?.contains(w) && !a.current?.contains(w) && o();
|
|
1297
1324
|
};
|
|
1298
1325
|
return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
|
|
1299
|
-
}, [
|
|
1326
|
+
}, [o, a]), l.useEffect(() => {
|
|
1300
1327
|
if (i.current && r.length > 0) {
|
|
1301
1328
|
const v = r.findIndex((g) => String(g.value) === t);
|
|
1302
1329
|
requestAnimationFrame(() => m(v >= 0 ? v : 0));
|
|
@@ -1311,7 +1338,7 @@ const Nt = l.memo(br), yr = ({
|
|
|
1311
1338
|
if (typeof window > "u") return;
|
|
1312
1339
|
const v = () => {
|
|
1313
1340
|
let x = e.x, k = e.y, S = y;
|
|
1314
|
-
const A =
|
|
1341
|
+
const A = a?.current;
|
|
1315
1342
|
if (A) {
|
|
1316
1343
|
const j = A.getBoundingClientRect();
|
|
1317
1344
|
x = j.left, k = j.bottom, S = Math.max(80, Math.round(j.width));
|
|
@@ -1320,11 +1347,11 @@ const Nt = l.memo(br), yr = ({
|
|
|
1320
1347
|
};
|
|
1321
1348
|
v(), window.addEventListener("scroll", v, !0), window.addEventListener("resize", v);
|
|
1322
1349
|
let g = null;
|
|
1323
|
-
const w =
|
|
1350
|
+
const w = a?.current;
|
|
1324
1351
|
return typeof ResizeObserver < "u" && w && (g = new ResizeObserver(() => v()), g.observe(w)), () => {
|
|
1325
1352
|
window.removeEventListener("scroll", v, !0), window.removeEventListener("resize", v), g && w && g.unobserve(w);
|
|
1326
1353
|
};
|
|
1327
|
-
}, [
|
|
1354
|
+
}, [a, e.x, e.y]), typeof window > "u") return null;
|
|
1328
1355
|
let I = document.getElementById("popup-root");
|
|
1329
1356
|
return I || (I = document.createElement("div"), I.id = "popup-root", document.body.appendChild(I)), de.createPortal(
|
|
1330
1357
|
/* @__PURE__ */ p(
|
|
@@ -1338,7 +1365,7 @@ const Nt = l.memo(br), yr = ({
|
|
|
1338
1365
|
top: F ? F.top : e.y,
|
|
1339
1366
|
left: F ? F.left : e.x,
|
|
1340
1367
|
width: $ ?? y,
|
|
1341
|
-
...
|
|
1368
|
+
...N
|
|
1342
1369
|
},
|
|
1343
1370
|
"data-reactaform-theme": c ?? "light",
|
|
1344
1371
|
children: r.map((v, g) => {
|
|
@@ -1374,7 +1401,7 @@ const Nt = l.memo(br), yr = ({
|
|
|
1374
1401
|
S.preventDefault(), S.stopPropagation(), n(String(v.value));
|
|
1375
1402
|
break;
|
|
1376
1403
|
case "Escape":
|
|
1377
|
-
S.preventDefault(),
|
|
1404
|
+
S.preventDefault(), o(), a?.current?.focus();
|
|
1378
1405
|
break;
|
|
1379
1406
|
}
|
|
1380
1407
|
},
|
|
@@ -1398,19 +1425,19 @@ const Nt = l.memo(br), yr = ({
|
|
|
1398
1425
|
I
|
|
1399
1426
|
);
|
|
1400
1427
|
};
|
|
1401
|
-
|
|
1402
|
-
const
|
|
1428
|
+
vr.displayName = "DropdownInput";
|
|
1429
|
+
const Mt = l.memo(vr), xr = ({
|
|
1403
1430
|
field: e,
|
|
1404
1431
|
value: r,
|
|
1405
1432
|
onChange: t,
|
|
1406
1433
|
onError: n,
|
|
1407
|
-
error:
|
|
1434
|
+
error: o
|
|
1408
1435
|
}) => {
|
|
1409
|
-
const
|
|
1436
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
1410
1437
|
value: r,
|
|
1411
1438
|
onChange: t,
|
|
1412
1439
|
onError: n,
|
|
1413
|
-
validate:
|
|
1440
|
+
validate: a
|
|
1414
1441
|
});
|
|
1415
1442
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1416
1443
|
"input",
|
|
@@ -1426,12 +1453,12 @@ const It = l.memo(yr), vr = ({
|
|
|
1426
1453
|
}
|
|
1427
1454
|
) });
|
|
1428
1455
|
};
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
const { theme: r } =
|
|
1456
|
+
xr.displayName = "EmailInput";
|
|
1457
|
+
const Ft = l.memo(xr), wr = ({ field: e }) => {
|
|
1458
|
+
const { theme: r } = B(), {
|
|
1432
1459
|
color: t = ie(r) ? "#444444" : "#CCCCCC",
|
|
1433
1460
|
thickness: n = 1,
|
|
1434
|
-
margin:
|
|
1461
|
+
margin: o = "8px 0"
|
|
1435
1462
|
} = e;
|
|
1436
1463
|
return /* @__PURE__ */ p(
|
|
1437
1464
|
"div",
|
|
@@ -1441,20 +1468,20 @@ const Et = l.memo(vr), xr = ({ field: e }) => {
|
|
|
1441
1468
|
height: "0",
|
|
1442
1469
|
// ensures only 1 line
|
|
1443
1470
|
borderTop: `${n}px solid ${t}`,
|
|
1444
|
-
margin:
|
|
1471
|
+
margin: o
|
|
1445
1472
|
}
|
|
1446
1473
|
}
|
|
1447
1474
|
);
|
|
1448
1475
|
};
|
|
1449
|
-
|
|
1450
|
-
const
|
|
1451
|
-
const { t:
|
|
1476
|
+
wr.displayName = "FieldSeparator";
|
|
1477
|
+
const $t = l.memo(wr), Sr = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
1478
|
+
const { t: a, theme: c } = B(), [s, i] = l.useState(!1), d = l.useRef(null), m = l.useRef(n), u = l.useRef(null), [f, b] = l.useState(null), C = ie(c);
|
|
1452
1479
|
l.useEffect(() => {
|
|
1453
1480
|
m.current = n;
|
|
1454
1481
|
}, [n]);
|
|
1455
|
-
const
|
|
1482
|
+
const N = (g, w) => w.some(
|
|
1456
1483
|
(x) => x.name === g.name && x.size === g.size && x.lastModified === g.lastModified
|
|
1457
|
-
), h = T(e,
|
|
1484
|
+
), h = T(e, o);
|
|
1458
1485
|
l.useEffect(() => {
|
|
1459
1486
|
const g = h(r ?? []);
|
|
1460
1487
|
t?.(r), g !== u.current && (u.current = g, b(g), m.current?.(g ?? null));
|
|
@@ -1465,7 +1492,7 @@ const Mt = l.memo(xr), wr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1465
1492
|
if (w && w.length > 0) {
|
|
1466
1493
|
const S = Array.from(w);
|
|
1467
1494
|
if (e.multiple) {
|
|
1468
|
-
const A = Array.isArray(r) ? r : [], j = S.filter((K) => !
|
|
1495
|
+
const A = Array.isArray(r) ? r : [], j = S.filter((K) => !N(K, A));
|
|
1469
1496
|
x = [...A, ...j];
|
|
1470
1497
|
} else
|
|
1471
1498
|
x = S[0];
|
|
@@ -1479,7 +1506,7 @@ const Mt = l.memo(xr), wr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1479
1506
|
const x = Array.from(w);
|
|
1480
1507
|
let k = null;
|
|
1481
1508
|
if (e.multiple) {
|
|
1482
|
-
const A = Array.isArray(r) ? r : [], j = x.filter((K) => !
|
|
1509
|
+
const A = Array.isArray(r) ? r : [], j = x.filter((K) => !N(K, A));
|
|
1483
1510
|
k = [...A, ...j];
|
|
1484
1511
|
} else
|
|
1485
1512
|
k = x[0];
|
|
@@ -1539,7 +1566,7 @@ const Mt = l.memo(xr), wr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1539
1566
|
{
|
|
1540
1567
|
type: "button",
|
|
1541
1568
|
onClick: () => $(Array.isArray(r) ? x : void 0),
|
|
1542
|
-
"aria-label":
|
|
1569
|
+
"aria-label": a("Remove file"),
|
|
1543
1570
|
style: {
|
|
1544
1571
|
background: "transparent",
|
|
1545
1572
|
border: "none",
|
|
@@ -1584,7 +1611,7 @@ const Mt = l.memo(xr), wr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1584
1611
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
1585
1612
|
padding: "8px 12px",
|
|
1586
1613
|
textAlign: "center",
|
|
1587
|
-
backgroundColor: s ? `var(--reactaform-bg-hover, ${
|
|
1614
|
+
backgroundColor: s ? `var(--reactaform-bg-hover, ${C ? "#070707" : "#eff6ff"})` : void 0,
|
|
1588
1615
|
transition: "all 0.2s ease",
|
|
1589
1616
|
cursor: "pointer",
|
|
1590
1617
|
minHeight: "var(--reactaform-input-height, 34px)",
|
|
@@ -1603,7 +1630,7 @@ const Mt = l.memo(xr), wr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1603
1630
|
(g.key === "Enter" || g.key === " ") && (g.preventDefault(), d.current?.click());
|
|
1604
1631
|
},
|
|
1605
1632
|
role: "button",
|
|
1606
|
-
"aria-label": e.multiple ?
|
|
1633
|
+
"aria-label": e.multiple ? a("Choose Files or Drag & Drop") : a("Choose File or Drag & Drop"),
|
|
1607
1634
|
"aria-invalid": !!f,
|
|
1608
1635
|
"aria-describedby": f ? `${e.name}-error` : void 0,
|
|
1609
1636
|
children: [
|
|
@@ -1633,26 +1660,26 @@ const Mt = l.memo(xr), wr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
1633
1660
|
color: "var(--reactaform-text-color, #111827)",
|
|
1634
1661
|
flex: 1,
|
|
1635
1662
|
textAlign: "left"
|
|
1636
|
-
}, children: s ?
|
|
1663
|
+
}, children: s ? a("Drop files here") : e.multiple ? a("Choose Files or Drag & Drop") : a("Choose File or Drag & Drop") })
|
|
1637
1664
|
]
|
|
1638
1665
|
}
|
|
1639
1666
|
),
|
|
1640
1667
|
R()
|
|
1641
1668
|
] }) });
|
|
1642
1669
|
};
|
|
1643
|
-
|
|
1644
|
-
const
|
|
1670
|
+
Sr.displayName = "FileInput";
|
|
1671
|
+
const Vt = l.memo(Sr), Cr = ({
|
|
1645
1672
|
field: e,
|
|
1646
1673
|
value: r,
|
|
1647
1674
|
onChange: t,
|
|
1648
1675
|
onError: n,
|
|
1649
|
-
error:
|
|
1676
|
+
error: o
|
|
1650
1677
|
}) => {
|
|
1651
|
-
const
|
|
1678
|
+
const a = T(e, o), c = Array.isArray(r) ? r.join(", ") : String(r ?? ""), { inputRef: s, error: i, handleChange: d } = _({
|
|
1652
1679
|
value: c,
|
|
1653
1680
|
onChange: t,
|
|
1654
1681
|
onError: n,
|
|
1655
|
-
validate:
|
|
1682
|
+
validate: a
|
|
1656
1683
|
});
|
|
1657
1684
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1658
1685
|
"input",
|
|
@@ -1669,19 +1696,19 @@ const Ft = l.memo(wr), Sr = ({
|
|
|
1669
1696
|
}
|
|
1670
1697
|
) });
|
|
1671
1698
|
};
|
|
1672
|
-
|
|
1673
|
-
const
|
|
1699
|
+
Cr.displayName = "FloatArrayInput";
|
|
1700
|
+
const At = l.memo(Cr), Nr = ({
|
|
1674
1701
|
field: e,
|
|
1675
1702
|
value: r,
|
|
1676
1703
|
onChange: t,
|
|
1677
1704
|
onError: n,
|
|
1678
|
-
error:
|
|
1705
|
+
error: o
|
|
1679
1706
|
}) => {
|
|
1680
|
-
const
|
|
1707
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
1681
1708
|
value: r,
|
|
1682
1709
|
onChange: t,
|
|
1683
1710
|
onError: n,
|
|
1684
|
-
validate:
|
|
1711
|
+
validate: a
|
|
1685
1712
|
});
|
|
1686
1713
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1687
1714
|
"input",
|
|
@@ -1700,9 +1727,9 @@ const $t = l.memo(Sr), Cr = ({
|
|
|
1700
1727
|
}
|
|
1701
1728
|
) });
|
|
1702
1729
|
};
|
|
1703
|
-
|
|
1704
|
-
const
|
|
1705
|
-
function
|
|
1730
|
+
Nr.displayName = "FloatInput";
|
|
1731
|
+
const Rt = l.memo(Nr);
|
|
1732
|
+
function Dt() {
|
|
1706
1733
|
try {
|
|
1707
1734
|
return "/";
|
|
1708
1735
|
} catch {
|
|
@@ -1714,14 +1741,14 @@ function At() {
|
|
|
1714
1741
|
}
|
|
1715
1742
|
return "/";
|
|
1716
1743
|
}
|
|
1717
|
-
const
|
|
1718
|
-
const { language: t, t: n } =
|
|
1744
|
+
const kr = ({ field: e, value: r }) => {
|
|
1745
|
+
const { language: t, t: n } = B(), o = e.alignment || "center", a = {
|
|
1719
1746
|
left: "flex-start",
|
|
1720
1747
|
center: "center",
|
|
1721
1748
|
right: "flex-end"
|
|
1722
1749
|
}, c = typeof r == "string" ? r : "";
|
|
1723
1750
|
let s = c && c.trim() !== "" ? c : typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
1724
|
-
s && !s.startsWith("/") && (s = `${
|
|
1751
|
+
s && !s.startsWith("/") && (s = `${Dt()}${s}`);
|
|
1725
1752
|
const i = e.localized?.split(";").map((h) => h.trim()), [d, m] = l.useState(s || ""), u = l.useRef(s || null);
|
|
1726
1753
|
if (l.useEffect(() => {
|
|
1727
1754
|
if (!s) return;
|
|
@@ -1747,19 +1774,19 @@ const Nr = ({ field: e, value: r }) => {
|
|
|
1747
1774
|
R.abort();
|
|
1748
1775
|
};
|
|
1749
1776
|
}, [s, t, i]), !d) return null;
|
|
1750
|
-
const { width: f, height: b } = e,
|
|
1777
|
+
const { width: f, height: b } = e, C = {}, N = {
|
|
1751
1778
|
borderRadius: "8px",
|
|
1752
1779
|
objectFit: "contain",
|
|
1753
1780
|
boxShadow: "0 2px 6px rgba(0,0,0,0.1)",
|
|
1754
1781
|
margin: "0 0 8px 0"
|
|
1755
1782
|
};
|
|
1756
|
-
return f && b ? (
|
|
1783
|
+
return f && b ? (C.width = f, C.height = b, N.width = `${f}px`, N.height = `${b}px`) : f && !b ? (C.width = f, N.width = `${f}px`, N.height = "auto") : !f && b && (C.height = b, N.width = "auto", N.height = `${b}px`), /* @__PURE__ */ p(O, { field: e, children: /* @__PURE__ */ p(
|
|
1757
1784
|
"div",
|
|
1758
1785
|
{
|
|
1759
1786
|
"data-testid": "image-wrapper",
|
|
1760
1787
|
style: {
|
|
1761
1788
|
display: "flex",
|
|
1762
|
-
justifyContent: o
|
|
1789
|
+
justifyContent: a[o] || "center",
|
|
1763
1790
|
margin: "0 0"
|
|
1764
1791
|
},
|
|
1765
1792
|
children: /* @__PURE__ */ p(
|
|
@@ -1767,26 +1794,26 @@ const Nr = ({ field: e, value: r }) => {
|
|
|
1767
1794
|
{
|
|
1768
1795
|
src: d,
|
|
1769
1796
|
alt: n?.(e.displayName || "Image") || e.displayName || "Image",
|
|
1770
|
-
...
|
|
1771
|
-
style:
|
|
1797
|
+
...C,
|
|
1798
|
+
style: N
|
|
1772
1799
|
}
|
|
1773
1800
|
)
|
|
1774
1801
|
}
|
|
1775
1802
|
) });
|
|
1776
1803
|
};
|
|
1777
|
-
|
|
1778
|
-
const
|
|
1804
|
+
kr.displayName = "ImageDisplay";
|
|
1805
|
+
const zt = l.memo(kr), Ir = ({
|
|
1779
1806
|
field: e,
|
|
1780
1807
|
value: r,
|
|
1781
1808
|
onChange: t,
|
|
1782
1809
|
onError: n,
|
|
1783
|
-
error:
|
|
1810
|
+
error: o
|
|
1784
1811
|
}) => {
|
|
1785
|
-
const
|
|
1812
|
+
const a = T(e, o), c = Array.isArray(r) ? r.join(", ") : String(r ?? ""), { inputRef: s, error: i, handleChange: d } = _({
|
|
1786
1813
|
value: c,
|
|
1787
1814
|
onChange: t,
|
|
1788
1815
|
onError: n,
|
|
1789
|
-
validate:
|
|
1816
|
+
validate: a
|
|
1790
1817
|
});
|
|
1791
1818
|
return /* @__PURE__ */ p(O, { field: e, error: i, children: /* @__PURE__ */ p(
|
|
1792
1819
|
"input",
|
|
@@ -1803,19 +1830,19 @@ const Rt = l.memo(Nr), kr = ({
|
|
|
1803
1830
|
}
|
|
1804
1831
|
) });
|
|
1805
1832
|
};
|
|
1806
|
-
|
|
1807
|
-
const
|
|
1833
|
+
Ir.displayName = "IntegerArrayInput";
|
|
1834
|
+
const Pt = l.memo(Ir), Er = ({
|
|
1808
1835
|
field: e,
|
|
1809
1836
|
value: r,
|
|
1810
1837
|
onChange: t,
|
|
1811
1838
|
onError: n,
|
|
1812
|
-
error:
|
|
1839
|
+
error: o
|
|
1813
1840
|
}) => {
|
|
1814
|
-
const
|
|
1841
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
1815
1842
|
value: r,
|
|
1816
1843
|
onChange: t,
|
|
1817
1844
|
onError: n,
|
|
1818
|
-
validate:
|
|
1845
|
+
validate: a
|
|
1819
1846
|
});
|
|
1820
1847
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1821
1848
|
"input",
|
|
@@ -1831,19 +1858,19 @@ const Dt = l.memo(kr), Ir = ({
|
|
|
1831
1858
|
}
|
|
1832
1859
|
) });
|
|
1833
1860
|
};
|
|
1834
|
-
|
|
1835
|
-
const
|
|
1861
|
+
Er.displayName = "IntegerInput";
|
|
1862
|
+
const Lt = l.memo(Er), Mr = ({
|
|
1836
1863
|
field: e,
|
|
1837
1864
|
value: r,
|
|
1838
1865
|
onChange: t,
|
|
1839
1866
|
onError: n,
|
|
1840
|
-
error:
|
|
1867
|
+
error: o
|
|
1841
1868
|
}) => {
|
|
1842
|
-
const
|
|
1869
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
1843
1870
|
value: r,
|
|
1844
1871
|
onChange: t,
|
|
1845
1872
|
onError: n,
|
|
1846
|
-
validate:
|
|
1873
|
+
validate: a
|
|
1847
1874
|
});
|
|
1848
1875
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
1849
1876
|
"textarea",
|
|
@@ -1864,42 +1891,42 @@ const Pt = l.memo(Ir), Er = ({
|
|
|
1864
1891
|
}
|
|
1865
1892
|
) });
|
|
1866
1893
|
};
|
|
1867
|
-
|
|
1868
|
-
const
|
|
1894
|
+
Mr.displayName = "MultilineTextInput";
|
|
1895
|
+
const Ot = l.memo(Mr), Fr = ({
|
|
1869
1896
|
field: e,
|
|
1870
1897
|
value: r,
|
|
1871
1898
|
onChange: t,
|
|
1872
1899
|
onError: n,
|
|
1873
|
-
error:
|
|
1900
|
+
error: o
|
|
1874
1901
|
}) => {
|
|
1875
|
-
const
|
|
1902
|
+
const a = l.useRef(
|
|
1876
1903
|
n
|
|
1877
1904
|
);
|
|
1878
1905
|
l.useEffect(() => {
|
|
1879
|
-
|
|
1906
|
+
a.current = n;
|
|
1880
1907
|
}, [n]);
|
|
1881
|
-
const { t: c, theme: s, formStyle: i, fieldStyle: d } =
|
|
1908
|
+
const { t: c, theme: s, formStyle: i, fieldStyle: d } = B(), m = (x, k, S) => {
|
|
1882
1909
|
if (!k) return {};
|
|
1883
1910
|
const j = x?.[k];
|
|
1884
1911
|
return (S && j ? j[S] : void 0) ?? {};
|
|
1885
|
-
}, u = l.useRef(null), [f, b] = l.useState(!1), [
|
|
1912
|
+
}, u = l.useRef(null), [f, b] = l.useState(!1), [C, N] = l.useState(null), h = l.useMemo(
|
|
1886
1913
|
() => e.options.map((x) => ({ value: x.value, label: c(x.label) })),
|
|
1887
1914
|
[e.options, c]
|
|
1888
1915
|
), y = l.useMemo(() => {
|
|
1889
1916
|
const x = Array.isArray(r) ? r : [], k = new Set(h.map((S) => S.value));
|
|
1890
1917
|
return x.filter((S) => k.has(S));
|
|
1891
|
-
}, [r, h]), E = T(e,
|
|
1918
|
+
}, [r, h]), E = T(e, o), [F, M] = l.useState(null), $ = l.useRef(null);
|
|
1892
1919
|
l.useEffect(() => {
|
|
1893
1920
|
const x = E(Array.isArray(r) ? r : []);
|
|
1894
|
-
x !== $.current && ($.current = x, M(x),
|
|
1921
|
+
x !== $.current && ($.current = x, M(x), a.current?.(x ?? null));
|
|
1895
1922
|
}, [r, E]);
|
|
1896
1923
|
const R = () => {
|
|
1897
1924
|
if (!u.current) return;
|
|
1898
1925
|
const x = u.current.getBoundingClientRect();
|
|
1899
|
-
|
|
1926
|
+
N({ x: x.left, y: x.bottom }), b((k) => !k);
|
|
1900
1927
|
}, I = (x) => {
|
|
1901
1928
|
const k = y.includes(x) ? y.filter((A) => A !== x) : [...y, x], S = E(k);
|
|
1902
|
-
S !== $.current && ($.current = S, M(S),
|
|
1929
|
+
S !== $.current && ($.current = S, M(S), a.current?.(S ?? null)), t?.(k);
|
|
1903
1930
|
}, v = l.useMemo(
|
|
1904
1931
|
() => ({
|
|
1905
1932
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
@@ -1987,10 +2014,10 @@ const zt = l.memo(Er), Mr = ({
|
|
|
1987
2014
|
]
|
|
1988
2015
|
}
|
|
1989
2016
|
) }) }),
|
|
1990
|
-
f &&
|
|
1991
|
-
|
|
2017
|
+
f && C && /* @__PURE__ */ p(
|
|
2018
|
+
Tt,
|
|
1992
2019
|
{
|
|
1993
|
-
position:
|
|
2020
|
+
position: C,
|
|
1994
2021
|
options: h,
|
|
1995
2022
|
selectedValues: y,
|
|
1996
2023
|
onToggleOption: I,
|
|
@@ -2000,19 +2027,19 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2000
2027
|
}
|
|
2001
2028
|
)
|
|
2002
2029
|
] });
|
|
2003
|
-
},
|
|
2030
|
+
}, Tt = ({
|
|
2004
2031
|
position: e,
|
|
2005
2032
|
options: r,
|
|
2006
2033
|
selectedValues: t,
|
|
2007
2034
|
onToggleOption: n,
|
|
2008
|
-
onClose:
|
|
2009
|
-
controlRef:
|
|
2035
|
+
onClose: o,
|
|
2036
|
+
controlRef: a,
|
|
2010
2037
|
theme: c
|
|
2011
2038
|
}) => {
|
|
2012
|
-
const s = l.useRef(null), [i, d] = l.useState(-1), { formStyle: m, fieldStyle: u } =
|
|
2039
|
+
const s = l.useRef(null), [i, d] = l.useState(-1), { formStyle: m, fieldStyle: u } = B(), f = ie(c ?? "light");
|
|
2013
2040
|
l.useLayoutEffect(() => {
|
|
2014
|
-
if (!
|
|
2015
|
-
const I =
|
|
2041
|
+
if (!a.current) return;
|
|
2042
|
+
const I = a.current.closest("[data-reactaform-theme]"), v = document.getElementById("popup-root");
|
|
2016
2043
|
if (I && v) {
|
|
2017
2044
|
const g = getComputedStyle(I);
|
|
2018
2045
|
v.style.setProperty(
|
|
@@ -2026,12 +2053,12 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2026
2053
|
g.getPropertyValue("--reactaform-option-menu-hover-bg")
|
|
2027
2054
|
);
|
|
2028
2055
|
}
|
|
2029
|
-
}, [
|
|
2056
|
+
}, [a]);
|
|
2030
2057
|
const b = (I, v, g) => {
|
|
2031
2058
|
if (!v) return {};
|
|
2032
2059
|
const x = I?.[v];
|
|
2033
2060
|
return (g && x ? x[g] : void 0) ?? {};
|
|
2034
|
-
},
|
|
2061
|
+
}, C = l.useMemo(
|
|
2035
2062
|
() => ({
|
|
2036
2063
|
maxHeight: 200,
|
|
2037
2064
|
overflowY: "auto",
|
|
@@ -2047,7 +2074,7 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2047
2074
|
...b(u, void 0, "popup")
|
|
2048
2075
|
}),
|
|
2049
2076
|
[m, u]
|
|
2050
|
-
),
|
|
2077
|
+
), N = l.useMemo(
|
|
2051
2078
|
() => ({
|
|
2052
2079
|
padding: "6px 8px",
|
|
2053
2080
|
cursor: "pointer",
|
|
@@ -2063,10 +2090,10 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2063
2090
|
l.useEffect(() => {
|
|
2064
2091
|
const I = (v) => {
|
|
2065
2092
|
const g = v.target;
|
|
2066
|
-
!s.current?.contains(g) && !
|
|
2093
|
+
!s.current?.contains(g) && !a.current?.contains(g) && o();
|
|
2067
2094
|
};
|
|
2068
2095
|
return document.addEventListener("mousedown", I), () => document.removeEventListener("mousedown", I);
|
|
2069
|
-
}, [
|
|
2096
|
+
}, [o, a]), l.useEffect(() => {
|
|
2070
2097
|
s.current && r.length > 0 && requestAnimationFrame(
|
|
2071
2098
|
() => d((I) => I === -1 ? 0 : I)
|
|
2072
2099
|
);
|
|
@@ -2082,7 +2109,7 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2082
2109
|
if (typeof window > "u") return;
|
|
2083
2110
|
const I = () => {
|
|
2084
2111
|
let w = e.x, x = e.y, k = h;
|
|
2085
|
-
const S =
|
|
2112
|
+
const S = a?.current;
|
|
2086
2113
|
if (S) {
|
|
2087
2114
|
const A = S.getBoundingClientRect();
|
|
2088
2115
|
w = A.left, x = A.bottom, k = Math.max(80, Math.round(A.width));
|
|
@@ -2091,11 +2118,11 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2091
2118
|
};
|
|
2092
2119
|
I(), window.addEventListener("scroll", I, !0), window.addEventListener("resize", I);
|
|
2093
2120
|
let v = null;
|
|
2094
|
-
const g =
|
|
2121
|
+
const g = a?.current;
|
|
2095
2122
|
return typeof ResizeObserver < "u" && g && (v = new ResizeObserver(() => I()), v.observe(g)), () => {
|
|
2096
2123
|
window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I), v && g && v.unobserve(g);
|
|
2097
2124
|
};
|
|
2098
|
-
}, [
|
|
2125
|
+
}, [a, e.x, e.y]), typeof window > "u") return null;
|
|
2099
2126
|
let R = document.getElementById("popup-root");
|
|
2100
2127
|
return R || (R = document.createElement("div"), R.id = "popup-root", document.body.appendChild(R)), de.createPortal(
|
|
2101
2128
|
/* @__PURE__ */ p(
|
|
@@ -2110,13 +2137,13 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2110
2137
|
left: E ? E.left : e.x,
|
|
2111
2138
|
width: M ?? h,
|
|
2112
2139
|
// spread the static popup styles
|
|
2113
|
-
...
|
|
2140
|
+
...C
|
|
2114
2141
|
},
|
|
2115
2142
|
"data-reactaform-theme": c ?? "light",
|
|
2116
2143
|
children: r.map((I, v) => {
|
|
2117
2144
|
const g = t.includes(I.value), w = f ? "var(--reactaform-option-menu-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-option-menu-hover-bg, #eee)", x = {
|
|
2118
|
-
...
|
|
2119
|
-
background: v === i ? w :
|
|
2145
|
+
...N,
|
|
2146
|
+
background: v === i ? w : N.background
|
|
2120
2147
|
};
|
|
2121
2148
|
return /* @__PURE__ */ D(
|
|
2122
2149
|
"div",
|
|
@@ -2145,7 +2172,7 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2145
2172
|
k.preventDefault(), k.stopPropagation(), n(I.value);
|
|
2146
2173
|
break;
|
|
2147
2174
|
case "Escape":
|
|
2148
|
-
k.preventDefault(),
|
|
2175
|
+
k.preventDefault(), o(), a?.current?.focus();
|
|
2149
2176
|
break;
|
|
2150
2177
|
}
|
|
2151
2178
|
},
|
|
@@ -2187,19 +2214,19 @@ const zt = l.memo(Er), Mr = ({
|
|
|
2187
2214
|
R
|
|
2188
2215
|
);
|
|
2189
2216
|
};
|
|
2190
|
-
|
|
2191
|
-
const
|
|
2217
|
+
Fr.displayName = "MultiSelect";
|
|
2218
|
+
const jt = l.memo(Fr), $r = ({
|
|
2192
2219
|
field: e,
|
|
2193
2220
|
value: r,
|
|
2194
2221
|
onChange: t,
|
|
2195
2222
|
onError: n,
|
|
2196
|
-
error:
|
|
2223
|
+
error: o
|
|
2197
2224
|
}) => {
|
|
2198
|
-
const
|
|
2225
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
2199
2226
|
value: String(r ?? ""),
|
|
2200
2227
|
onChange: t,
|
|
2201
2228
|
onError: n,
|
|
2202
|
-
validate:
|
|
2229
|
+
validate: a
|
|
2203
2230
|
}), d = Math.max(1, Math.round(e.step ?? 1));
|
|
2204
2231
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2205
2232
|
"input",
|
|
@@ -2222,19 +2249,19 @@ const Ot = l.memo(Mr), Fr = ({
|
|
|
2222
2249
|
}
|
|
2223
2250
|
) });
|
|
2224
2251
|
};
|
|
2225
|
-
|
|
2226
|
-
const
|
|
2252
|
+
$r.displayName = "NumericStepperInput";
|
|
2253
|
+
const Bt = l.memo($r), Vr = ({
|
|
2227
2254
|
field: e,
|
|
2228
2255
|
value: r,
|
|
2229
2256
|
onChange: t,
|
|
2230
2257
|
onError: n,
|
|
2231
|
-
error:
|
|
2258
|
+
error: o
|
|
2232
2259
|
}) => {
|
|
2233
|
-
const
|
|
2260
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
2234
2261
|
value: r,
|
|
2235
2262
|
onChange: t,
|
|
2236
2263
|
onError: n,
|
|
2237
|
-
validate:
|
|
2264
|
+
validate: a
|
|
2238
2265
|
});
|
|
2239
2266
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2240
2267
|
"input",
|
|
@@ -2250,15 +2277,15 @@ const Tt = l.memo(Fr), $r = ({
|
|
|
2250
2277
|
}
|
|
2251
2278
|
) });
|
|
2252
2279
|
};
|
|
2253
|
-
|
|
2254
|
-
const
|
|
2280
|
+
Vr.displayName = "PhoneInput";
|
|
2281
|
+
const Ht = l.memo(Vr), Ar = ({
|
|
2255
2282
|
field: e,
|
|
2256
2283
|
value: r,
|
|
2257
2284
|
onChange: t,
|
|
2258
2285
|
onError: n,
|
|
2259
|
-
error:
|
|
2286
|
+
error: o
|
|
2260
2287
|
}) => {
|
|
2261
|
-
const { t:
|
|
2288
|
+
const { t: a } = B(), c = T(e, o), s = e.layout?.toLowerCase() === "horizontal" ? "row" : "column", i = l.useRef(n);
|
|
2262
2289
|
l.useEffect(() => {
|
|
2263
2290
|
i.current = n;
|
|
2264
2291
|
}, [n]);
|
|
@@ -2279,7 +2306,7 @@ const jt = l.memo($r), Vr = ({
|
|
|
2279
2306
|
const b = (h) => {
|
|
2280
2307
|
const y = h.target.value, E = c(y);
|
|
2281
2308
|
f(E), t?.(y);
|
|
2282
|
-
},
|
|
2309
|
+
}, C = {
|
|
2283
2310
|
display: "flex",
|
|
2284
2311
|
flexDirection: s,
|
|
2285
2312
|
flexWrap: s === "row" ? "wrap" : "nowrap",
|
|
@@ -2288,7 +2315,7 @@ const jt = l.memo($r), Vr = ({
|
|
|
2288
2315
|
width: "100%",
|
|
2289
2316
|
padding: s === "row" ? "8px" : void 0,
|
|
2290
2317
|
boxSizing: "border-box"
|
|
2291
|
-
},
|
|
2318
|
+
}, N = {
|
|
2292
2319
|
display: s === "column" ? "flex" : "inline-flex",
|
|
2293
2320
|
gap: "8px",
|
|
2294
2321
|
alignItems: "center",
|
|
@@ -2304,14 +2331,14 @@ const jt = l.memo($r), Vr = ({
|
|
|
2304
2331
|
className: V.input,
|
|
2305
2332
|
"aria-labelledby": `${e.name}-label`,
|
|
2306
2333
|
"aria-invalid": !!d,
|
|
2307
|
-
style:
|
|
2334
|
+
style: C,
|
|
2308
2335
|
children: e.options.map((h) => {
|
|
2309
2336
|
const y = String(h.value), E = `${e.name}-${y}`;
|
|
2310
2337
|
return /* @__PURE__ */ D(
|
|
2311
2338
|
"label",
|
|
2312
2339
|
{
|
|
2313
2340
|
className: U(V.label),
|
|
2314
|
-
style:
|
|
2341
|
+
style: N,
|
|
2315
2342
|
onMouseDown: (F) => F.preventDefault(),
|
|
2316
2343
|
onClick: () => {
|
|
2317
2344
|
String(r ?? "") !== y && b({ target: { value: y } });
|
|
@@ -2338,7 +2365,7 @@ const jt = l.memo($r), Vr = ({
|
|
|
2338
2365
|
flex: s === "column" ? 1 : void 0,
|
|
2339
2366
|
fontWeight: 400
|
|
2340
2367
|
},
|
|
2341
|
-
children:
|
|
2368
|
+
children: a(h.label)
|
|
2342
2369
|
}
|
|
2343
2370
|
)
|
|
2344
2371
|
]
|
|
@@ -2349,11 +2376,11 @@ const jt = l.memo($r), Vr = ({
|
|
|
2349
2376
|
}
|
|
2350
2377
|
) });
|
|
2351
2378
|
};
|
|
2352
|
-
|
|
2353
|
-
const
|
|
2379
|
+
Ar.displayName = "RadioInput";
|
|
2380
|
+
const qt = l.memo(Ar), Ut = {
|
|
2354
2381
|
display: "flex",
|
|
2355
2382
|
gap: 4
|
|
2356
|
-
},
|
|
2383
|
+
}, Wt = {
|
|
2357
2384
|
cursor: "pointer",
|
|
2358
2385
|
fontSize: "1.5rem",
|
|
2359
2386
|
lineHeight: 1,
|
|
@@ -2361,23 +2388,23 @@ const Bt = l.memo(Vr), Ht = {
|
|
|
2361
2388
|
marginRight: "0.25rem",
|
|
2362
2389
|
userSelect: "none",
|
|
2363
2390
|
transition: "color 0.12s ease"
|
|
2364
|
-
},
|
|
2365
|
-
const { t:
|
|
2391
|
+
}, Rr = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
2392
|
+
const { t: a } = B(), c = T(e, o), s = e.max ?? 5, i = e.icon?.trim() || "★", [d, m] = l.useState(null), u = l.useRef([]), f = l.useMemo(() => Math.min(Math.max(r ?? 0, 0), s), [r, s]), b = l.useMemo(() => c(f) ?? null, [c, f]);
|
|
2366
2393
|
l.useEffect(() => {
|
|
2367
2394
|
n?.(b);
|
|
2368
2395
|
}, [b, n]);
|
|
2369
|
-
const
|
|
2396
|
+
const C = l.useCallback(
|
|
2370
2397
|
(h) => {
|
|
2371
2398
|
const y = Math.min(Math.max(h, 0), s);
|
|
2372
2399
|
t?.(y);
|
|
2373
2400
|
},
|
|
2374
2401
|
[s, t]
|
|
2375
|
-
),
|
|
2402
|
+
), N = l.useCallback(
|
|
2376
2403
|
(h, y) => {
|
|
2377
2404
|
switch (h.key) {
|
|
2378
2405
|
case "Enter":
|
|
2379
2406
|
case " ":
|
|
2380
|
-
h.preventDefault(),
|
|
2407
|
+
h.preventDefault(), C(y + 1);
|
|
2381
2408
|
break;
|
|
2382
2409
|
case "ArrowRight":
|
|
2383
2410
|
case "ArrowUp":
|
|
@@ -2389,7 +2416,7 @@ const Bt = l.memo(Vr), Ht = {
|
|
|
2389
2416
|
break;
|
|
2390
2417
|
}
|
|
2391
2418
|
},
|
|
2392
|
-
[s,
|
|
2419
|
+
[s, C]
|
|
2393
2420
|
);
|
|
2394
2421
|
return /* @__PURE__ */ p(O, { field: e, error: b, children: /* @__PURE__ */ p(
|
|
2395
2422
|
"div",
|
|
@@ -2398,7 +2425,7 @@ const Bt = l.memo(Vr), Ht = {
|
|
|
2398
2425
|
"aria-labelledby": `${e.name}-label`,
|
|
2399
2426
|
"aria-invalid": !!b,
|
|
2400
2427
|
"aria-describedby": b ? `${e.name}-error` : void 0,
|
|
2401
|
-
style:
|
|
2428
|
+
style: Ut,
|
|
2402
2429
|
children: Array.from({ length: s }, (h, y) => {
|
|
2403
2430
|
const E = y < f, M = d !== null && y <= d || E ? "gold" : "lightgray";
|
|
2404
2431
|
return /* @__PURE__ */ p(
|
|
@@ -2409,12 +2436,12 @@ const Bt = l.memo(Vr), Ht = {
|
|
|
2409
2436
|
tabIndex: f > 0 ? y === f - 1 ? 0 : -1 : y === 0 ? 0 : -1,
|
|
2410
2437
|
"aria-checked": E,
|
|
2411
2438
|
"aria-label": `Rating ${y + 1}`,
|
|
2412
|
-
title:
|
|
2413
|
-
onClick: () =>
|
|
2414
|
-
onKeyDown: ($) =>
|
|
2439
|
+
title: a(`${e.displayName} ${y + 1}`),
|
|
2440
|
+
onClick: () => C(y + 1),
|
|
2441
|
+
onKeyDown: ($) => N($, y),
|
|
2415
2442
|
onMouseEnter: () => m(y),
|
|
2416
2443
|
onMouseLeave: () => m(null),
|
|
2417
|
-
style: { ...
|
|
2444
|
+
style: { ...Wt, color: M },
|
|
2418
2445
|
children: i
|
|
2419
2446
|
},
|
|
2420
2447
|
y
|
|
@@ -2423,15 +2450,15 @@ const Bt = l.memo(Vr), Ht = {
|
|
|
2423
2450
|
}
|
|
2424
2451
|
) });
|
|
2425
2452
|
};
|
|
2426
|
-
|
|
2427
|
-
const
|
|
2453
|
+
Rr.displayName = "RatingInput";
|
|
2454
|
+
const _t = l.memo(Rr), Dr = ({
|
|
2428
2455
|
field: e,
|
|
2429
2456
|
value: r,
|
|
2430
2457
|
onChange: t,
|
|
2431
2458
|
onError: n,
|
|
2432
|
-
error:
|
|
2459
|
+
error: o
|
|
2433
2460
|
}) => {
|
|
2434
|
-
const { t:
|
|
2461
|
+
const { t: a } = B(), c = T(e, o), { inputRef: s, error: i, handleChange: d } = _({
|
|
2435
2462
|
value: r,
|
|
2436
2463
|
onChange: t,
|
|
2437
2464
|
onError: n,
|
|
@@ -2457,7 +2484,7 @@ const Ut = l.memo(Ar), Rr = ({
|
|
|
2457
2484
|
{
|
|
2458
2485
|
type: "button",
|
|
2459
2486
|
onClick: f,
|
|
2460
|
-
"aria-label":
|
|
2487
|
+
"aria-label": a(m ? "Hide password" : "Show password"),
|
|
2461
2488
|
style: {
|
|
2462
2489
|
background: "transparent",
|
|
2463
2490
|
border: "none",
|
|
@@ -2472,23 +2499,23 @@ const Ut = l.memo(Ar), Rr = ({
|
|
|
2472
2499
|
)
|
|
2473
2500
|
] }) });
|
|
2474
2501
|
};
|
|
2475
|
-
|
|
2476
|
-
const
|
|
2477
|
-
const
|
|
2502
|
+
Dr.displayName = "PasswordInput";
|
|
2503
|
+
const Kt = l.memo(Dr), zr = ({ field: e, value: r, onChange: t, onError: n, error: o }) => {
|
|
2504
|
+
const a = T(e, o), c = e.min ?? 0, s = e.max ?? 100, [i, d] = l.useState(
|
|
2478
2505
|
() => isNaN(Number(r)) ? String(c) : String(Number(r))
|
|
2479
2506
|
);
|
|
2480
2507
|
l.useEffect(() => {
|
|
2481
2508
|
const b = isNaN(Number(r)) ? String(c) : String(Number(r));
|
|
2482
2509
|
d(b);
|
|
2483
2510
|
}, [r, c]);
|
|
2484
|
-
const m = l.useMemo(() =>
|
|
2511
|
+
const m = l.useMemo(() => a(i) ?? null, [a, i]);
|
|
2485
2512
|
l.useEffect(() => {
|
|
2486
2513
|
n?.(m);
|
|
2487
2514
|
}, [m, n]);
|
|
2488
2515
|
const u = l.useCallback(
|
|
2489
2516
|
(b) => {
|
|
2490
|
-
const
|
|
2491
|
-
d(
|
|
2517
|
+
const C = b.target.value;
|
|
2518
|
+
d(C), t?.(C);
|
|
2492
2519
|
},
|
|
2493
2520
|
[t]
|
|
2494
2521
|
), f = isNaN(Number(i)) ? String(c) : String(Number(i));
|
|
@@ -2534,15 +2561,15 @@ const Wt = l.memo(Rr), Dr = ({ field: e, value: r, onChange: t, onError: n, erro
|
|
|
2534
2561
|
)
|
|
2535
2562
|
] }) });
|
|
2536
2563
|
};
|
|
2537
|
-
|
|
2538
|
-
const
|
|
2564
|
+
zr.displayName = "SliderInput";
|
|
2565
|
+
const Gt = l.memo(zr), Pr = ({
|
|
2539
2566
|
field: e,
|
|
2540
2567
|
value: r,
|
|
2541
2568
|
onChange: t,
|
|
2542
2569
|
onError: n,
|
|
2543
|
-
error:
|
|
2570
|
+
error: o
|
|
2544
2571
|
}) => {
|
|
2545
|
-
const { t:
|
|
2572
|
+
const { t: a, formStyle: c, fieldStyle: s } = B(), d = T(e, o)(r);
|
|
2546
2573
|
l.useEffect(() => {
|
|
2547
2574
|
n?.(d);
|
|
2548
2575
|
}, [d, n]);
|
|
@@ -2557,7 +2584,7 @@ const _t = l.memo(Dr), Pr = ({
|
|
|
2557
2584
|
height: 24,
|
|
2558
2585
|
...f(m, "switch", "label"),
|
|
2559
2586
|
...f(u, void 0, "label")
|
|
2560
|
-
}), [m, u]),
|
|
2587
|
+
}), [m, u]), C = l.useMemo(() => ({
|
|
2561
2588
|
position: "absolute",
|
|
2562
2589
|
opacity: 0,
|
|
2563
2590
|
top: 0,
|
|
@@ -2570,7 +2597,7 @@ const _t = l.memo(Dr), Pr = ({
|
|
|
2570
2597
|
// Make hidden input non-interactive to avoid event conflicts
|
|
2571
2598
|
...f(m, "switch", "hiddenInput"),
|
|
2572
2599
|
...f(u, void 0, "hiddenInput")
|
|
2573
|
-
}), [m, u]),
|
|
2600
|
+
}), [m, u]), N = l.useMemo(() => ({
|
|
2574
2601
|
position: "absolute",
|
|
2575
2602
|
cursor: "pointer",
|
|
2576
2603
|
top: 0,
|
|
@@ -2611,7 +2638,7 @@ const _t = l.memo(Dr), Pr = ({
|
|
|
2611
2638
|
className: V.label,
|
|
2612
2639
|
htmlFor: e.name,
|
|
2613
2640
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
2614
|
-
children:
|
|
2641
|
+
children: a(e.displayName)
|
|
2615
2642
|
}
|
|
2616
2643
|
),
|
|
2617
2644
|
/* @__PURE__ */ D("label", { style: b, children: [
|
|
@@ -2622,10 +2649,10 @@ const _t = l.memo(Dr), Pr = ({
|
|
|
2622
2649
|
type: "checkbox",
|
|
2623
2650
|
checked: y,
|
|
2624
2651
|
readOnly: !0,
|
|
2625
|
-
"aria-label":
|
|
2652
|
+
"aria-label": a(e.displayName),
|
|
2626
2653
|
"aria-invalid": !1,
|
|
2627
2654
|
"aria-describedby": void 0,
|
|
2628
|
-
style:
|
|
2655
|
+
style: C,
|
|
2629
2656
|
tabIndex: -1
|
|
2630
2657
|
}
|
|
2631
2658
|
),
|
|
@@ -2643,7 +2670,7 @@ const _t = l.memo(Dr), Pr = ({
|
|
|
2643
2670
|
(F.key === " " || F.key === "Spacebar" || F.key === "Space" || F.key === "Enter") && (F.preventDefault(), E());
|
|
2644
2671
|
},
|
|
2645
2672
|
className: `reactaform-switch ${y ? "active checked on" : ""} `,
|
|
2646
|
-
style: y ? { ...
|
|
2673
|
+
style: y ? { ...N, backgroundColor: "var(--reactaform-switch-on-bg, #22c55e)", borderColor: "var(--reactaform-switch-on-border, #16a34a)" } : N,
|
|
2647
2674
|
children: /* @__PURE__ */ p(
|
|
2648
2675
|
"span",
|
|
2649
2676
|
{
|
|
@@ -2659,18 +2686,18 @@ const _t = l.memo(Dr), Pr = ({
|
|
|
2659
2686
|
] }) });
|
|
2660
2687
|
};
|
|
2661
2688
|
Pr.displayName = "SwitchInput";
|
|
2662
|
-
const
|
|
2689
|
+
const Jt = l.memo(Pr), xe = ({
|
|
2663
2690
|
field: e,
|
|
2664
2691
|
value: r,
|
|
2665
2692
|
onChange: t,
|
|
2666
2693
|
onError: n,
|
|
2667
|
-
error:
|
|
2694
|
+
error: o
|
|
2668
2695
|
}) => {
|
|
2669
|
-
const
|
|
2696
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
2670
2697
|
value: r,
|
|
2671
2698
|
onChange: t,
|
|
2672
2699
|
onError: n,
|
|
2673
|
-
validate:
|
|
2700
|
+
validate: a
|
|
2674
2701
|
});
|
|
2675
2702
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2676
2703
|
"input",
|
|
@@ -2688,18 +2715,18 @@ const Kt = l.memo(Pr), xe = ({
|
|
|
2688
2715
|
) });
|
|
2689
2716
|
};
|
|
2690
2717
|
xe.displayName = "TextInput";
|
|
2691
|
-
const
|
|
2718
|
+
const Lr = ({
|
|
2692
2719
|
field: e,
|
|
2693
2720
|
value: r,
|
|
2694
2721
|
onChange: t,
|
|
2695
2722
|
onError: n,
|
|
2696
|
-
error:
|
|
2723
|
+
error: o
|
|
2697
2724
|
}) => {
|
|
2698
|
-
const
|
|
2725
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
2699
2726
|
value: r,
|
|
2700
2727
|
onChange: t,
|
|
2701
2728
|
onError: n,
|
|
2702
|
-
validate:
|
|
2729
|
+
validate: a
|
|
2703
2730
|
});
|
|
2704
2731
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
2705
2732
|
"input",
|
|
@@ -2718,35 +2745,35 @@ const zr = ({
|
|
|
2718
2745
|
}
|
|
2719
2746
|
) });
|
|
2720
2747
|
};
|
|
2721
|
-
|
|
2722
|
-
const
|
|
2723
|
-
function
|
|
2748
|
+
Lr.displayName = "TimeInput";
|
|
2749
|
+
const Yt = l.memo(Lr);
|
|
2750
|
+
function Xt({
|
|
2724
2751
|
pos: e,
|
|
2725
2752
|
options: r,
|
|
2726
2753
|
onClose: t,
|
|
2727
2754
|
onClickOption: n
|
|
2728
2755
|
}) {
|
|
2729
|
-
const
|
|
2756
|
+
const o = l.useRef(null), a = l.useRef(!1), [c, s] = l.useState({
|
|
2730
2757
|
top: e?.y ?? 0,
|
|
2731
2758
|
left: e?.x ?? 0,
|
|
2732
2759
|
ready: !1
|
|
2733
2760
|
}), i = typeof window < "u" ? document.getElementById("popup-root") || document.body : null;
|
|
2734
2761
|
return l.useEffect(() => {
|
|
2735
2762
|
function d(m) {
|
|
2736
|
-
|
|
2763
|
+
a.current || m.target.dataset?.popupMenu === "item" || o.current && m.target instanceof Node && !o.current.contains(m.target) && t();
|
|
2737
2764
|
}
|
|
2738
2765
|
return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
|
|
2739
2766
|
}, [t]), l.useLayoutEffect(() => {
|
|
2740
|
-
if (!
|
|
2767
|
+
if (!o.current || !e || e.x == null || e.y == null)
|
|
2741
2768
|
return;
|
|
2742
|
-
const d =
|
|
2769
|
+
const d = o.current.getBoundingClientRect(), m = window.innerWidth, u = window.innerHeight;
|
|
2743
2770
|
let f = e.x, b = e.y;
|
|
2744
2771
|
f + d.width > m && (f = Math.max(0, m - d.width - 10)), b + d.height > u && (b = Math.max(0, e.y - d.height - 5)), s({ top: b, left: f, ready: !0 });
|
|
2745
2772
|
}, [e, r]), !i || r === void 0 || r.length === 0 || !e || e.x == null || e.y == null ? null : de.createPortal(
|
|
2746
2773
|
/* @__PURE__ */ p(
|
|
2747
2774
|
"div",
|
|
2748
2775
|
{
|
|
2749
|
-
ref:
|
|
2776
|
+
ref: o,
|
|
2750
2777
|
onMouseDown: (d) => {
|
|
2751
2778
|
d.stopPropagation();
|
|
2752
2779
|
},
|
|
@@ -2770,11 +2797,11 @@ function Jt({
|
|
|
2770
2797
|
{
|
|
2771
2798
|
"data-popup-menu": "item",
|
|
2772
2799
|
onMouseDown: (u) => {
|
|
2773
|
-
u.stopPropagation(),
|
|
2800
|
+
u.stopPropagation(), a.current = !0;
|
|
2774
2801
|
},
|
|
2775
2802
|
onClick: (u) => {
|
|
2776
2803
|
u.stopPropagation(), u.preventDefault(), n(d), t(), setTimeout(() => {
|
|
2777
|
-
|
|
2804
|
+
a.current = !1;
|
|
2778
2805
|
}, 100);
|
|
2779
2806
|
},
|
|
2780
2807
|
style: {
|
|
@@ -2916,31 +2943,31 @@ const $e = {
|
|
|
2916
2943
|
rad: Math.PI / 180,
|
|
2917
2944
|
rev: 1 / 360
|
|
2918
2945
|
}
|
|
2919
|
-
}, Re = {},
|
|
2946
|
+
}, Re = {}, Zt = /* @__PURE__ */ new Set([
|
|
2920
2947
|
...Object.keys($e),
|
|
2921
2948
|
...Object.keys(Ve),
|
|
2922
2949
|
...Object.keys(Ae)
|
|
2923
2950
|
]);
|
|
2924
|
-
for (const e of
|
|
2925
|
-
const r = {}, t = $e[e] ?? [], n = Ve[e] ?? {},
|
|
2926
|
-
for (const
|
|
2927
|
-
const c = n[
|
|
2928
|
-
r[
|
|
2929
|
-
name: typeof c == "string" ? c : String(
|
|
2930
|
-
shortName:
|
|
2931
|
-
factor:
|
|
2951
|
+
for (const e of Zt) {
|
|
2952
|
+
const r = {}, t = $e[e] ?? [], n = Ve[e] ?? {}, o = Ae[e] ?? {};
|
|
2953
|
+
for (const a of t) {
|
|
2954
|
+
const c = n[a];
|
|
2955
|
+
r[a] = {
|
|
2956
|
+
name: typeof c == "string" ? c : String(a),
|
|
2957
|
+
shortName: a,
|
|
2958
|
+
factor: a in o ? o[a] : void 0
|
|
2932
2959
|
};
|
|
2933
2960
|
}
|
|
2934
|
-
for (const [
|
|
2935
|
-
if (!r[
|
|
2936
|
-
const s = typeof c == "string" ? c : String(
|
|
2937
|
-
r[
|
|
2961
|
+
for (const [a, c] of Object.entries(n))
|
|
2962
|
+
if (!r[a]) {
|
|
2963
|
+
const s = typeof c == "string" ? c : String(a);
|
|
2964
|
+
r[a] = { name: s, shortName: a, factor: a in o ? o[a] : void 0 };
|
|
2938
2965
|
}
|
|
2939
|
-
for (const [
|
|
2940
|
-
r[
|
|
2966
|
+
for (const [a, c] of Object.entries(o))
|
|
2967
|
+
r[a] || (r[a] = { name: String(a), shortName: String(a), factor: c });
|
|
2941
2968
|
Re[e] = r;
|
|
2942
2969
|
}
|
|
2943
|
-
function
|
|
2970
|
+
function Or(e, r, t) {
|
|
2944
2971
|
if (e === "C") {
|
|
2945
2972
|
if (r === "F") return t * (9 / 5) + 32;
|
|
2946
2973
|
if (r === "K") return t + 273.15;
|
|
@@ -2953,33 +2980,33 @@ function Lr(e, r, t) {
|
|
|
2953
2980
|
}
|
|
2954
2981
|
return t;
|
|
2955
2982
|
}
|
|
2956
|
-
function
|
|
2983
|
+
function Tr(e) {
|
|
2957
2984
|
const r = Re[e];
|
|
2958
2985
|
if (!r) return null;
|
|
2959
2986
|
const t = {}, n = [];
|
|
2960
|
-
for (const [
|
|
2961
|
-
typeof c.factor == "number" && (t[
|
|
2987
|
+
for (const [a, c] of Object.entries(r))
|
|
2988
|
+
typeof c.factor == "number" && (t[a] = c.factor), n.push(a);
|
|
2962
2989
|
return {
|
|
2963
2990
|
default: Object.keys(r)[0] ?? "",
|
|
2964
2991
|
units: n,
|
|
2965
2992
|
factors: t
|
|
2966
2993
|
};
|
|
2967
2994
|
}
|
|
2968
|
-
const
|
|
2995
|
+
const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2969
2996
|
__proto__: null,
|
|
2970
|
-
convertTemperature:
|
|
2997
|
+
convertTemperature: Or,
|
|
2971
2998
|
dimensionUnitDisplayMap: Ve,
|
|
2972
2999
|
dimensionUnitsMap: $e,
|
|
2973
3000
|
dimensonUnitFactorsMap: Ae,
|
|
2974
|
-
getUnitFactors:
|
|
3001
|
+
getUnitFactors: Tr,
|
|
2975
3002
|
unitsByDimension: Re
|
|
2976
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3003
|
+
}, Symbol.toStringTag, { value: "Module" })), jr = l.memo(({
|
|
2977
3004
|
disabled: e,
|
|
2978
3005
|
inputValue: r,
|
|
2979
3006
|
selectedUnit: t,
|
|
2980
3007
|
dimension: n,
|
|
2981
|
-
unitFactors:
|
|
2982
|
-
onConversionSelect:
|
|
3008
|
+
unitFactors: o,
|
|
3009
|
+
onConversionSelect: a,
|
|
2983
3010
|
t: c
|
|
2984
3011
|
}) => {
|
|
2985
3012
|
const [s, i] = l.useState(!1), [d, m] = l.useState(null), [u, f] = l.useState([]), b = l.useCallback(
|
|
@@ -2991,8 +3018,8 @@ const la = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2991
3018
|
m({ x: E.left, y: E.bottom });
|
|
2992
3019
|
const F = [];
|
|
2993
3020
|
if (n === "temperature")
|
|
2994
|
-
|
|
2995
|
-
const R =
|
|
3021
|
+
o.units.forEach(($) => {
|
|
3022
|
+
const R = Or(t, $, y);
|
|
2996
3023
|
Number.isFinite(R) && F.push({
|
|
2997
3024
|
label: `${R.toFixed(6)} ${c($)}`,
|
|
2998
3025
|
value: R.toString(),
|
|
@@ -3000,8 +3027,8 @@ const la = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3000
3027
|
});
|
|
3001
3028
|
});
|
|
3002
3029
|
else {
|
|
3003
|
-
const $ =
|
|
3004
|
-
$ !== void 0 && Object.entries(
|
|
3030
|
+
const $ = o.factors[t];
|
|
3031
|
+
$ !== void 0 && Object.entries(o.factors).forEach(([R, I]) => {
|
|
3005
3032
|
const v = y / $ * I;
|
|
3006
3033
|
Number.isFinite(v) && F.push({
|
|
3007
3034
|
label: `${v.toFixed(6)} ${c(R)}`,
|
|
@@ -3012,13 +3039,13 @@ const la = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3012
3039
|
}
|
|
3013
3040
|
f(F), i(F.length > 0);
|
|
3014
3041
|
},
|
|
3015
|
-
[e, r, t, n,
|
|
3016
|
-
),
|
|
3042
|
+
[e, r, t, n, o, c]
|
|
3043
|
+
), C = l.useCallback(
|
|
3017
3044
|
(h) => {
|
|
3018
|
-
i(!1), m(null),
|
|
3045
|
+
i(!1), m(null), a(h);
|
|
3019
3046
|
},
|
|
3020
|
-
[
|
|
3021
|
-
),
|
|
3047
|
+
[a]
|
|
3048
|
+
), N = l.useCallback(() => {
|
|
3022
3049
|
i(!1), m(null);
|
|
3023
3050
|
}, []);
|
|
3024
3051
|
return /* @__PURE__ */ D(Ie, { children: [
|
|
@@ -3049,63 +3076,63 @@ const la = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3049
3076
|
}
|
|
3050
3077
|
),
|
|
3051
3078
|
s && u.length > 0 && /* @__PURE__ */ p(
|
|
3052
|
-
|
|
3079
|
+
Xt,
|
|
3053
3080
|
{
|
|
3054
3081
|
pos: d,
|
|
3055
3082
|
options: u,
|
|
3056
|
-
onClose:
|
|
3057
|
-
onClickOption:
|
|
3083
|
+
onClose: N,
|
|
3084
|
+
onClickOption: C
|
|
3058
3085
|
}
|
|
3059
3086
|
)
|
|
3060
3087
|
] });
|
|
3061
3088
|
});
|
|
3062
|
-
|
|
3063
|
-
const
|
|
3064
|
-
const { t:
|
|
3089
|
+
jr.displayName = "ConversionButton";
|
|
3090
|
+
const Br = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
3091
|
+
const { t: o } = B(), a = T(e), c = e.dimension, s = l.useMemo(() => c ? Tr(c) : null, [c]), i = String(r?.[0] ?? ""), d = String(r?.[1] ?? s?.default ?? ""), [m, u] = l.useState(i), [f, b] = l.useState(d);
|
|
3065
3092
|
l.useEffect(() => {
|
|
3066
3093
|
u(i);
|
|
3067
3094
|
}, [i]), l.useEffect(() => {
|
|
3068
3095
|
b(d);
|
|
3069
3096
|
}, [d]);
|
|
3070
|
-
const
|
|
3097
|
+
const C = a([m, f]);
|
|
3071
3098
|
l.useEffect(() => {
|
|
3072
|
-
n?.(
|
|
3073
|
-
}, [
|
|
3074
|
-
const
|
|
3099
|
+
n?.(C);
|
|
3100
|
+
}, [C, n]);
|
|
3101
|
+
const N = l.useCallback(
|
|
3075
3102
|
(M) => {
|
|
3076
3103
|
const $ = M.target.value;
|
|
3077
|
-
u($),
|
|
3104
|
+
u($), a([$, f]), t?.([$, f]);
|
|
3078
3105
|
},
|
|
3079
|
-
[f,
|
|
3106
|
+
[f, a, t]
|
|
3080
3107
|
), h = l.useCallback(
|
|
3081
3108
|
(M) => {
|
|
3082
3109
|
const $ = M.target.value;
|
|
3083
|
-
b($),
|
|
3110
|
+
b($), a([m, $]), t?.([m, $]);
|
|
3084
3111
|
},
|
|
3085
|
-
[m,
|
|
3112
|
+
[m, a, t]
|
|
3086
3113
|
), y = l.useCallback(
|
|
3087
3114
|
(M) => {
|
|
3088
3115
|
u(M.value), b(M.unit), t?.([M.value, M.unit]);
|
|
3089
3116
|
},
|
|
3090
3117
|
[t]
|
|
3091
3118
|
), E = l.useMemo(
|
|
3092
|
-
() => s ? s.units.map((M) => /* @__PURE__ */ p("option", { value: M, children:
|
|
3093
|
-
[s,
|
|
3119
|
+
() => s ? s.units.map((M) => /* @__PURE__ */ p("option", { value: M, children: o(M) }, M)) : [],
|
|
3120
|
+
[s, o]
|
|
3094
3121
|
);
|
|
3095
3122
|
if (!c || !s) return null;
|
|
3096
|
-
const F = !!
|
|
3097
|
-
return /* @__PURE__ */ p(O, { field: e, error:
|
|
3123
|
+
const F = !!C || !m.trim();
|
|
3124
|
+
return /* @__PURE__ */ p(O, { field: e, error: C, children: /* @__PURE__ */ D("div", { style: { display: "flex", alignItems: "center", gap: "var(--reactaform-unit-gap, 8px)", width: "100%" }, children: [
|
|
3098
3125
|
/* @__PURE__ */ p(
|
|
3099
3126
|
"input",
|
|
3100
3127
|
{
|
|
3101
3128
|
id: e.name,
|
|
3102
3129
|
type: "text",
|
|
3103
3130
|
value: m,
|
|
3104
|
-
onChange:
|
|
3131
|
+
onChange: N,
|
|
3105
3132
|
style: { flex: "2 1 0" },
|
|
3106
3133
|
className: U(V.input, V.textInput),
|
|
3107
|
-
"aria-invalid": !!
|
|
3108
|
-
"aria-describedby":
|
|
3134
|
+
"aria-invalid": !!C,
|
|
3135
|
+
"aria-describedby": C ? `${e.name}-error` : void 0
|
|
3109
3136
|
}
|
|
3110
3137
|
),
|
|
3111
3138
|
/* @__PURE__ */ p(
|
|
@@ -3116,13 +3143,13 @@ const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3116
3143
|
onChange: h,
|
|
3117
3144
|
style: { flex: "1 1 0" },
|
|
3118
3145
|
className: U(V.input, V.inputSelect),
|
|
3119
|
-
"aria-invalid": !!
|
|
3120
|
-
"aria-describedby":
|
|
3146
|
+
"aria-invalid": !!C,
|
|
3147
|
+
"aria-describedby": C ? `${e.name}-error` : void 0,
|
|
3121
3148
|
children: E
|
|
3122
3149
|
}
|
|
3123
3150
|
),
|
|
3124
3151
|
/* @__PURE__ */ p(
|
|
3125
|
-
|
|
3152
|
+
jr,
|
|
3126
3153
|
{
|
|
3127
3154
|
disabled: F,
|
|
3128
3155
|
inputValue: m,
|
|
@@ -3130,24 +3157,24 @@ const jr = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
3130
3157
|
dimension: c,
|
|
3131
3158
|
unitFactors: s,
|
|
3132
3159
|
onConversionSelect: y,
|
|
3133
|
-
t:
|
|
3160
|
+
t: o
|
|
3134
3161
|
}
|
|
3135
3162
|
)
|
|
3136
3163
|
] }) });
|
|
3137
3164
|
};
|
|
3138
|
-
|
|
3139
|
-
const
|
|
3165
|
+
Br.displayName = "UnitValueInput";
|
|
3166
|
+
const Qt = l.memo(Br), Hr = ({
|
|
3140
3167
|
field: e,
|
|
3141
3168
|
value: r,
|
|
3142
3169
|
onChange: t,
|
|
3143
3170
|
onError: n,
|
|
3144
|
-
error:
|
|
3171
|
+
error: o
|
|
3145
3172
|
}) => {
|
|
3146
|
-
const
|
|
3173
|
+
const a = T(e, o), { inputRef: c, error: s, handleChange: i } = _({
|
|
3147
3174
|
value: r,
|
|
3148
3175
|
onChange: t,
|
|
3149
3176
|
onError: n,
|
|
3150
|
-
validate:
|
|
3177
|
+
validate: a
|
|
3151
3178
|
});
|
|
3152
3179
|
return /* @__PURE__ */ p(O, { field: e, error: s, children: /* @__PURE__ */ p(
|
|
3153
3180
|
"input",
|
|
@@ -3164,78 +3191,69 @@ const Xt = l.memo(jr), Br = ({
|
|
|
3164
3191
|
}
|
|
3165
3192
|
) });
|
|
3166
3193
|
};
|
|
3167
|
-
|
|
3168
|
-
const
|
|
3169
|
-
function
|
|
3194
|
+
Hr.displayName = "UrlInput";
|
|
3195
|
+
const en = l.memo(Hr), se = new ne();
|
|
3196
|
+
function fo(e, r) {
|
|
3170
3197
|
se.register(e, r);
|
|
3171
3198
|
}
|
|
3172
|
-
function
|
|
3199
|
+
function rn(e) {
|
|
3173
3200
|
return se.get(e);
|
|
3174
3201
|
}
|
|
3175
|
-
function
|
|
3202
|
+
function po(e) {
|
|
3176
3203
|
return se.has(e);
|
|
3177
3204
|
}
|
|
3178
|
-
function
|
|
3205
|
+
function go(e) {
|
|
3179
3206
|
return se.unregister(e);
|
|
3180
3207
|
}
|
|
3181
|
-
function
|
|
3208
|
+
function ho() {
|
|
3182
3209
|
return se.list();
|
|
3183
3210
|
}
|
|
3184
|
-
const
|
|
3211
|
+
const qr = ({
|
|
3185
3212
|
field: e,
|
|
3186
3213
|
valuesMap: r,
|
|
3187
3214
|
handleChange: t,
|
|
3188
3215
|
handleError: n
|
|
3189
3216
|
}) => {
|
|
3190
|
-
const { t:
|
|
3217
|
+
const { t: o } = B(), [a, c] = l.useState(!1), [s, i] = l.useState(null), d = l.useCallback(async () => {
|
|
3191
3218
|
if (!e.action) {
|
|
3192
3219
|
console.warn(`Button "${e.name}" has no action defined`);
|
|
3193
3220
|
return;
|
|
3194
3221
|
}
|
|
3195
|
-
const
|
|
3196
|
-
if (!
|
|
3197
|
-
const
|
|
3198
|
-
console.error(
|
|
3222
|
+
const f = rn(e.action);
|
|
3223
|
+
if (!f) {
|
|
3224
|
+
const b = `Button handler "${e.action}" not found`;
|
|
3225
|
+
console.error(b), i(b);
|
|
3199
3226
|
return;
|
|
3200
3227
|
}
|
|
3201
3228
|
c(!0), i(null);
|
|
3202
3229
|
try {
|
|
3203
|
-
await
|
|
3204
|
-
} catch (
|
|
3205
|
-
const
|
|
3206
|
-
console.error(`Button handler "${e.action}" failed:`,
|
|
3230
|
+
await f(r, t, n, o);
|
|
3231
|
+
} catch (b) {
|
|
3232
|
+
const C = b instanceof Error ? b.message : String(b);
|
|
3233
|
+
console.error(`Button handler "${e.action}" failed:`, C), i(C);
|
|
3207
3234
|
} finally {
|
|
3208
3235
|
c(!1);
|
|
3209
3236
|
}
|
|
3210
|
-
}, [e, r, t, n,
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
minHeight: "var(--reactaform-input-height, 34px)"
|
|
3216
|
-
};
|
|
3217
|
-
return /* @__PURE__ */ p(O, { field: e, rightAlign: !1, error: s, children: /* @__PURE__ */ p(
|
|
3237
|
+
}, [e, r, t, n, o]), u = { ...{
|
|
3238
|
+
cursor: a ? "wait" : "pointer",
|
|
3239
|
+
opacity: a ? 0.6 : 1
|
|
3240
|
+
} };
|
|
3241
|
+
return e.width && typeof e.width == "number" && e.width > 0 && (u.width = `${e.width}px`), /* @__PURE__ */ p(O, { field: e, rightAlign: !0, error: s, children: /* @__PURE__ */ p(
|
|
3218
3242
|
"button",
|
|
3219
3243
|
{
|
|
3220
3244
|
type: "button",
|
|
3221
3245
|
className: V.button,
|
|
3222
3246
|
onClick: d,
|
|
3223
|
-
disabled:
|
|
3224
|
-
"aria-label":
|
|
3225
|
-
"aria-busy":
|
|
3226
|
-
style:
|
|
3227
|
-
|
|
3228
|
-
o || (u.currentTarget.style.backgroundColor = "var(--reactaform-button-bg-hover, var(--reactaform-success-color-hover, #0056b3))");
|
|
3229
|
-
},
|
|
3230
|
-
onMouseLeave: (u) => {
|
|
3231
|
-
o || (u.currentTarget.style.backgroundColor = "var(--reactaform-button-bg, var(--reactaform-success-color, #4CAF50))");
|
|
3232
|
-
},
|
|
3233
|
-
children: a(o ? "Processing..." : e.displayName)
|
|
3247
|
+
disabled: a,
|
|
3248
|
+
"aria-label": o(e.displayName),
|
|
3249
|
+
"aria-busy": a,
|
|
3250
|
+
style: u,
|
|
3251
|
+
children: o(a ? "Processing..." : e.displayName)
|
|
3234
3252
|
}
|
|
3235
3253
|
) });
|
|
3236
3254
|
};
|
|
3237
|
-
|
|
3238
|
-
const
|
|
3255
|
+
qr.displayName = "Button";
|
|
3256
|
+
const tn = l.memo(qr), nn = {
|
|
3239
3257
|
// No debounce
|
|
3240
3258
|
checkbox: !1,
|
|
3241
3259
|
switch: !1,
|
|
@@ -3247,6 +3265,7 @@ const en = l.memo(Hr), rn = {
|
|
|
3247
3265
|
file: !1,
|
|
3248
3266
|
image: !1,
|
|
3249
3267
|
separator: !1,
|
|
3268
|
+
description: !1,
|
|
3250
3269
|
button: !1,
|
|
3251
3270
|
// Buttons don't need debouncing
|
|
3252
3271
|
// Standard text inputs
|
|
@@ -3267,96 +3286,97 @@ const en = l.memo(Hr), rn = {
|
|
|
3267
3286
|
slider: { wait: 100, leading: !0, trailing: !0 },
|
|
3268
3287
|
stepper: { wait: 100, leading: !0, trailing: !0 }
|
|
3269
3288
|
}, me = new ne(), De = {
|
|
3270
|
-
button:
|
|
3271
|
-
checkbox:
|
|
3272
|
-
color:
|
|
3273
|
-
date:
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
"
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3289
|
+
button: tn,
|
|
3290
|
+
checkbox: vt,
|
|
3291
|
+
color: Nt,
|
|
3292
|
+
date: kt,
|
|
3293
|
+
description: It,
|
|
3294
|
+
dropdown: Mt,
|
|
3295
|
+
email: Ft,
|
|
3296
|
+
file: Vt,
|
|
3297
|
+
float: Rt,
|
|
3298
|
+
"float-array": At,
|
|
3299
|
+
image: zt,
|
|
3300
|
+
int: Lt,
|
|
3301
|
+
"int-array": Pt,
|
|
3302
|
+
"multi-selection": jt,
|
|
3303
|
+
multiline: Ot,
|
|
3304
|
+
password: Kt,
|
|
3305
|
+
phone: Ht,
|
|
3306
|
+
radio: qt,
|
|
3307
|
+
rating: _t,
|
|
3308
|
+
separator: $t,
|
|
3309
|
+
slider: Gt,
|
|
3290
3310
|
string: xe,
|
|
3291
|
-
stepper:
|
|
3292
|
-
switch:
|
|
3311
|
+
stepper: Bt,
|
|
3312
|
+
switch: Jt,
|
|
3293
3313
|
text: xe,
|
|
3294
|
-
time:
|
|
3295
|
-
unit:
|
|
3296
|
-
url:
|
|
3314
|
+
time: Yt,
|
|
3315
|
+
unit: Qt,
|
|
3316
|
+
url: en
|
|
3297
3317
|
};
|
|
3298
|
-
function
|
|
3318
|
+
function on(e) {
|
|
3299
3319
|
return e in De;
|
|
3300
3320
|
}
|
|
3301
|
-
function
|
|
3302
|
-
const { wait: t = 200, leading: n, trailing:
|
|
3321
|
+
function an(e, r) {
|
|
3322
|
+
const { wait: t = 200, leading: n, trailing: o } = r, a = l.memo((c) => {
|
|
3303
3323
|
const s = l.useRef(c.onChange);
|
|
3304
3324
|
l.useEffect(() => {
|
|
3305
3325
|
s.current = c.onChange;
|
|
3306
3326
|
}, [c.onChange]);
|
|
3307
|
-
const { callback: i, cancel: d } =
|
|
3327
|
+
const { callback: i, cancel: d } = lt(
|
|
3308
3328
|
(...m) => {
|
|
3309
3329
|
s.current?.(...m);
|
|
3310
3330
|
},
|
|
3311
3331
|
t,
|
|
3312
|
-
{ leading: n, trailing:
|
|
3332
|
+
{ leading: n, trailing: o }
|
|
3313
3333
|
);
|
|
3314
3334
|
return l.useEffect(() => d, [d]), l.createElement(
|
|
3315
3335
|
e,
|
|
3316
3336
|
{ ...c, onChange: i }
|
|
3317
3337
|
);
|
|
3318
3338
|
});
|
|
3319
|
-
return
|
|
3339
|
+
return a.displayName = "DebouncedFieldWrapper", a;
|
|
3320
3340
|
}
|
|
3321
|
-
function
|
|
3341
|
+
function Ur(e, r, t) {
|
|
3322
3342
|
const n = r;
|
|
3323
3343
|
if (!t && e in De) {
|
|
3324
3344
|
console.warn(`Can't overwrite base component type "${e}".`);
|
|
3325
3345
|
return;
|
|
3326
3346
|
}
|
|
3327
|
-
const
|
|
3328
|
-
if (
|
|
3347
|
+
const o = nn[e];
|
|
3348
|
+
if (o === !1) {
|
|
3329
3349
|
me.register(e, n);
|
|
3330
3350
|
return;
|
|
3331
3351
|
}
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3352
|
+
const a = o ?? { wait: 200 };
|
|
3353
|
+
or ? me.register(e, n) : me.register(
|
|
3334
3354
|
e,
|
|
3335
|
-
|
|
3355
|
+
an(n, a)
|
|
3336
3356
|
);
|
|
3337
3357
|
}
|
|
3338
|
-
function
|
|
3339
|
-
|
|
3358
|
+
function Wr(e, r) {
|
|
3359
|
+
Ur(e, r, !1);
|
|
3340
3360
|
}
|
|
3341
|
-
function
|
|
3361
|
+
function _r(e) {
|
|
3342
3362
|
return me.get(e);
|
|
3343
3363
|
}
|
|
3344
3364
|
let Ye = !1;
|
|
3345
|
-
function
|
|
3365
|
+
function sn() {
|
|
3346
3366
|
Ye || (Object.entries(De).forEach(([e, r]) => {
|
|
3347
|
-
|
|
3367
|
+
Ur(e, r, !0);
|
|
3348
3368
|
}), Ye = !0);
|
|
3349
3369
|
}
|
|
3350
|
-
const
|
|
3351
|
-
({ field: e, valuesMap: r, handleChange: t, handleError: n, errorsMap:
|
|
3352
|
-
const
|
|
3370
|
+
const ze = l.memo(
|
|
3371
|
+
({ field: e, valuesMap: r, handleChange: t, handleError: n, errorsMap: o }) => {
|
|
3372
|
+
const a = _r(e.type), c = r[e.name], s = o ? o[e.name] ?? null : void 0, i = l.useMemo(() => c, [c]), d = l.useCallback(
|
|
3353
3373
|
(u) => t(e.name, u),
|
|
3354
3374
|
[t, e.name]
|
|
3355
3375
|
), m = l.useCallback(
|
|
3356
3376
|
(u) => n?.(e.name, u),
|
|
3357
3377
|
[n, e.name]
|
|
3358
3378
|
);
|
|
3359
|
-
return
|
|
3379
|
+
return a ? e.type === "button" ? /* @__PURE__ */ p(a, { ...{
|
|
3360
3380
|
field: e,
|
|
3361
3381
|
value: null,
|
|
3362
3382
|
valuesMap: r,
|
|
@@ -3364,7 +3384,7 @@ const Pe = l.memo(
|
|
|
3364
3384
|
handleError: n || (() => {
|
|
3365
3385
|
})
|
|
3366
3386
|
} }) : /* @__PURE__ */ p(
|
|
3367
|
-
|
|
3387
|
+
a,
|
|
3368
3388
|
{
|
|
3369
3389
|
field: e,
|
|
3370
3390
|
value: i,
|
|
@@ -3376,9 +3396,9 @@ const Pe = l.memo(
|
|
|
3376
3396
|
},
|
|
3377
3397
|
(e, r) => e.field === r.field && e.valuesMap[e.field.name] === r.valuesMap[r.field.name] && e.handleChange === r.handleChange && e.handleError === r.handleError && e.errorsMap?.[e.field.name] === r.errorsMap?.[r.field.name]
|
|
3378
3398
|
);
|
|
3379
|
-
|
|
3380
|
-
const
|
|
3381
|
-
({ groupName: e, defaultOpen: r = !0, fields: t, valuesMap: n, handleChange:
|
|
3399
|
+
ze.displayName = "FieldRenderer";
|
|
3400
|
+
const Kr = l.memo(
|
|
3401
|
+
({ groupName: e, defaultOpen: r = !0, fields: t, valuesMap: n, handleChange: o, handleError: a, errorsMap: c, t: s }) => {
|
|
3382
3402
|
const [i, d] = l.useState(r), m = l.useCallback(() => d((u) => !u), []);
|
|
3383
3403
|
return /* @__PURE__ */ D("fieldset", { className: "reactaform-group", children: [
|
|
3384
3404
|
/* @__PURE__ */ D("legend", { onClick: m, className: "reactaform-group_legend", children: [
|
|
@@ -3386,12 +3406,12 @@ const _r = l.memo(
|
|
|
3386
3406
|
/* @__PURE__ */ p("span", { className: "reactaform-group_legend_arrow", children: i ? "▼" : "▶" })
|
|
3387
3407
|
] }),
|
|
3388
3408
|
i && t.map((u) => /* @__PURE__ */ p(
|
|
3389
|
-
|
|
3409
|
+
ze,
|
|
3390
3410
|
{
|
|
3391
3411
|
field: u,
|
|
3392
3412
|
valuesMap: n,
|
|
3393
|
-
handleChange:
|
|
3394
|
-
handleError:
|
|
3413
|
+
handleChange: o,
|
|
3414
|
+
handleError: a,
|
|
3395
3415
|
errorsMap: c
|
|
3396
3416
|
},
|
|
3397
3417
|
u.name
|
|
@@ -3399,64 +3419,64 @@ const _r = l.memo(
|
|
|
3399
3419
|
] });
|
|
3400
3420
|
}
|
|
3401
3421
|
);
|
|
3402
|
-
|
|
3403
|
-
const
|
|
3404
|
-
const
|
|
3405
|
-
if (!
|
|
3406
|
-
const
|
|
3422
|
+
Kr.displayName = "FieldGroup";
|
|
3423
|
+
const Pe = (e, r, t, n) => {
|
|
3424
|
+
const o = r[e];
|
|
3425
|
+
if (!o?.children) return;
|
|
3426
|
+
const a = t[e], c = a != null ? String(a) : "", s = o.children[c];
|
|
3407
3427
|
if (Array.isArray(s))
|
|
3408
3428
|
for (const i of s)
|
|
3409
|
-
typeof i == "string" && r[i] && (n[i] = !0,
|
|
3410
|
-
},
|
|
3429
|
+
typeof i == "string" && r[i] && (n[i] = !0, Pe(i, r, t, n));
|
|
3430
|
+
}, Gr = (e, r, t) => {
|
|
3411
3431
|
const n = r[e];
|
|
3412
3432
|
if (!n?.children) return;
|
|
3413
|
-
const
|
|
3414
|
-
for (const
|
|
3415
|
-
typeof
|
|
3416
|
-
},
|
|
3417
|
-
const
|
|
3418
|
-
return e.forEach((
|
|
3419
|
-
(!
|
|
3420
|
-
}),
|
|
3421
|
-
},
|
|
3422
|
-
const
|
|
3423
|
-
if (
|
|
3424
|
-
const s = String(
|
|
3433
|
+
const o = Object.values(n.children).flat();
|
|
3434
|
+
for (const a of o)
|
|
3435
|
+
typeof a == "string" && a in t && (t[a] = !1, Gr(a, r, t));
|
|
3436
|
+
}, cn = (e, r, t, n) => {
|
|
3437
|
+
const o = { ...t };
|
|
3438
|
+
return e.forEach((a) => {
|
|
3439
|
+
(!a.parents || Object.keys(a.parents).length === 0) && (o[a.name] = !0, Pe(a.name, n, r, o));
|
|
3440
|
+
}), o;
|
|
3441
|
+
}, ln = (e, r, t, n, o) => {
|
|
3442
|
+
const a = { ...e }, c = r[n];
|
|
3443
|
+
if (Gr(n, r, a), o != null && c?.children) {
|
|
3444
|
+
const s = String(o), i = c.children[s];
|
|
3425
3445
|
if (Array.isArray(i))
|
|
3426
3446
|
for (const d of i)
|
|
3427
|
-
typeof d == "string" && r[d] && (
|
|
3447
|
+
typeof d == "string" && r[d] && (a[d] = !0, Pe(d, r, t, a));
|
|
3428
3448
|
}
|
|
3429
|
-
return
|
|
3430
|
-
},
|
|
3449
|
+
return a;
|
|
3450
|
+
}, un = (e, r) => {
|
|
3431
3451
|
const t = /* @__PURE__ */ new Map();
|
|
3432
|
-
let n = null,
|
|
3452
|
+
let n = null, o = null, a = 0;
|
|
3433
3453
|
for (const c of e) {
|
|
3434
3454
|
const s = c.group;
|
|
3435
3455
|
if (!s) {
|
|
3436
|
-
n = null,
|
|
3456
|
+
n = null, o = null;
|
|
3437
3457
|
continue;
|
|
3438
3458
|
}
|
|
3439
3459
|
if (s === n)
|
|
3440
|
-
r[c.name].group =
|
|
3460
|
+
r[c.name].group = o ?? s;
|
|
3441
3461
|
else {
|
|
3442
3462
|
if (!t.has(s))
|
|
3443
|
-
t.set(s, 1),
|
|
3463
|
+
t.set(s, 1), o = null, r[c.name].group = s;
|
|
3444
3464
|
else {
|
|
3445
3465
|
const i = t.get(s), d = `${s}(${i})`;
|
|
3446
|
-
t.set(s, i + 1),
|
|
3466
|
+
t.set(s, i + 1), o = d, r[c.name].group = d, a++;
|
|
3447
3467
|
}
|
|
3448
3468
|
n = s;
|
|
3449
3469
|
}
|
|
3450
3470
|
}
|
|
3451
|
-
return
|
|
3452
|
-
},
|
|
3471
|
+
return a;
|
|
3472
|
+
}, mn = (e, r = {}) => {
|
|
3453
3473
|
const { includeEmpty: t = !0 } = r, n = [];
|
|
3454
|
-
let
|
|
3474
|
+
let o = null, a = [], c = 0;
|
|
3455
3475
|
for (const i of e) {
|
|
3456
3476
|
const d = i.group || null;
|
|
3457
|
-
d !==
|
|
3477
|
+
d !== o ? ((a.length > 0 || t) && n.push({ name: o, fields: a }), o = d, a = [i]) : a.push(i);
|
|
3458
3478
|
}
|
|
3459
|
-
(
|
|
3479
|
+
(a.length > 0 || t) && n.push({ name: o, fields: a }), c = n.filter((i) => i.fields.length === 0).length;
|
|
3460
3480
|
const s = Math.max(0, ...n.map((i) => i.fields.length));
|
|
3461
3481
|
return {
|
|
3462
3482
|
groups: n,
|
|
@@ -3467,16 +3487,16 @@ const ze = (e, r, t, n) => {
|
|
|
3467
3487
|
}
|
|
3468
3488
|
};
|
|
3469
3489
|
}, Le = new ne();
|
|
3470
|
-
function
|
|
3490
|
+
function Jr(e, r) {
|
|
3471
3491
|
Le.register(e, r);
|
|
3472
3492
|
}
|
|
3473
|
-
function
|
|
3493
|
+
function dn(e) {
|
|
3474
3494
|
return Le.get(e);
|
|
3475
3495
|
}
|
|
3476
|
-
function
|
|
3496
|
+
function fn(e) {
|
|
3477
3497
|
return Le.get(e);
|
|
3478
3498
|
}
|
|
3479
|
-
|
|
3499
|
+
Jr(
|
|
3480
3500
|
"Preset_AlertSubmitHandler",
|
|
3481
3501
|
(e, r, t) => {
|
|
3482
3502
|
const n = {
|
|
@@ -3484,12 +3504,12 @@ Gr(
|
|
|
3484
3504
|
version: e.version,
|
|
3485
3505
|
definition: e.name,
|
|
3486
3506
|
values: t
|
|
3487
|
-
},
|
|
3488
|
-
alert(
|
|
3507
|
+
}, o = JSON.stringify(n, null, 2);
|
|
3508
|
+
alert(o);
|
|
3489
3509
|
}
|
|
3490
3510
|
);
|
|
3491
|
-
async function
|
|
3492
|
-
const s =
|
|
3511
|
+
async function pn(e, r, t, n, o, a, c) {
|
|
3512
|
+
const s = o ? Object.values(o).filter(Boolean) : [];
|
|
3493
3513
|
if (s.length > 0)
|
|
3494
3514
|
return {
|
|
3495
3515
|
success: !1,
|
|
@@ -3501,28 +3521,28 @@ async function dn(e, r, t, n, a, o, c) {
|
|
|
3501
3521
|
for (const u of e.properties) {
|
|
3502
3522
|
const f = u.name, b = i[f];
|
|
3503
3523
|
if (b == null) continue;
|
|
3504
|
-
const
|
|
3524
|
+
const C = u.type;
|
|
3505
3525
|
try {
|
|
3506
|
-
if (
|
|
3507
|
-
const
|
|
3508
|
-
if (
|
|
3526
|
+
if (C === "int") {
|
|
3527
|
+
const N = String(b).trim();
|
|
3528
|
+
if (N === "")
|
|
3509
3529
|
i[f] = 0;
|
|
3510
3530
|
else {
|
|
3511
|
-
const h = Number(
|
|
3531
|
+
const h = Number(N);
|
|
3512
3532
|
Number.isInteger(h) ? i[f] = Math.trunc(h) : d.push(n("Invalid integer format for field {{1}}", u.displayName || f));
|
|
3513
3533
|
}
|
|
3514
|
-
} else if (
|
|
3515
|
-
const
|
|
3516
|
-
if (
|
|
3534
|
+
} else if (C === "number" || C === "float") {
|
|
3535
|
+
const N = String(b).trim();
|
|
3536
|
+
if (N === "")
|
|
3517
3537
|
i[f] = 0;
|
|
3518
3538
|
else {
|
|
3519
|
-
const h = Number(
|
|
3539
|
+
const h = Number(N);
|
|
3520
3540
|
isNaN(h) ? d.push(n("Invalid number format for field {{1}}", u.displayName || f)) : i[f] = h;
|
|
3521
3541
|
}
|
|
3522
|
-
} else if (
|
|
3523
|
-
const
|
|
3542
|
+
} else if (C === "int-array" || C === "float-array") {
|
|
3543
|
+
const N = String(b).split(",").map((E) => E.trim()).filter(Boolean), h = [];
|
|
3524
3544
|
let y = !1;
|
|
3525
|
-
for (const E of
|
|
3545
|
+
for (const E of N) {
|
|
3526
3546
|
const F = Number(E);
|
|
3527
3547
|
if (isNaN(F)) {
|
|
3528
3548
|
d.push(n("Invalid number {{1}} in array for field {{2}}", E, u.displayName || f)), y = !0;
|
|
@@ -3532,8 +3552,8 @@ async function dn(e, r, t, n, a, o, c) {
|
|
|
3532
3552
|
}
|
|
3533
3553
|
y || (i[f] = h);
|
|
3534
3554
|
}
|
|
3535
|
-
} catch (
|
|
3536
|
-
d.push(n("Error processing field {{1}}: {{2}}", u.displayName || f,
|
|
3555
|
+
} catch (N) {
|
|
3556
|
+
d.push(n("Error processing field {{1}}: {{2}}", u.displayName || f, N instanceof Error ? N.message : String(N)));
|
|
3537
3557
|
}
|
|
3538
3558
|
}
|
|
3539
3559
|
if (d.length > 0)
|
|
@@ -3551,7 +3571,7 @@ async function dn(e, r, t, n, a, o, c) {
|
|
|
3551
3571
|
errors: u
|
|
3552
3572
|
};
|
|
3553
3573
|
} else {
|
|
3554
|
-
const u = await
|
|
3574
|
+
const u = await yt(e, i, n);
|
|
3555
3575
|
if (u && u.length > 0)
|
|
3556
3576
|
return {
|
|
3557
3577
|
success: !1,
|
|
@@ -3560,9 +3580,9 @@ async function dn(e, r, t, n, a, o, c) {
|
|
|
3560
3580
|
};
|
|
3561
3581
|
}
|
|
3562
3582
|
const m = (u) => u ? Array.isArray(u) ? u.map((f) => String(f)) : typeof u == "string" ? u.trim() ? [u] : [] : [String(u)] : [];
|
|
3563
|
-
if (
|
|
3583
|
+
if (a)
|
|
3564
3584
|
try {
|
|
3565
|
-
const u = await
|
|
3585
|
+
const u = await a(e, r?.name ?? null, i, n), f = m(u);
|
|
3566
3586
|
if (f.length > 0)
|
|
3567
3587
|
return {
|
|
3568
3588
|
success: !1,
|
|
@@ -3577,7 +3597,7 @@ async function dn(e, r, t, n, a, o, c) {
|
|
|
3577
3597
|
};
|
|
3578
3598
|
}
|
|
3579
3599
|
else if (e && typeof e.submitHandlerName == "string") {
|
|
3580
|
-
const u =
|
|
3600
|
+
const u = dn(e.submitHandlerName);
|
|
3581
3601
|
if (u)
|
|
3582
3602
|
try {
|
|
3583
3603
|
const f = await u(e, r?.name ?? null, i, n), b = m(f);
|
|
@@ -3601,7 +3621,7 @@ async function dn(e, r, t, n, a, o, c) {
|
|
|
3601
3621
|
data: i
|
|
3602
3622
|
};
|
|
3603
3623
|
}
|
|
3604
|
-
const
|
|
3624
|
+
const Yr = ({
|
|
3605
3625
|
message: e,
|
|
3606
3626
|
success: r,
|
|
3607
3627
|
onDismiss: t,
|
|
@@ -3643,16 +3663,16 @@ const Jr = ({
|
|
|
3643
3663
|
]
|
|
3644
3664
|
}
|
|
3645
3665
|
) : null;
|
|
3646
|
-
|
|
3647
|
-
const
|
|
3648
|
-
const [n,
|
|
3666
|
+
Yr.displayName = "SubmissionMessage";
|
|
3667
|
+
const gn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
3668
|
+
const [n, o] = l.useState(!1);
|
|
3649
3669
|
return /* @__PURE__ */ p(
|
|
3650
3670
|
"button",
|
|
3651
3671
|
{
|
|
3652
3672
|
onClick: e,
|
|
3653
3673
|
disabled: r,
|
|
3654
|
-
onMouseEnter: () =>
|
|
3655
|
-
onMouseLeave: () =>
|
|
3674
|
+
onMouseEnter: () => o(!0),
|
|
3675
|
+
onMouseLeave: () => o(!1),
|
|
3656
3676
|
style: {
|
|
3657
3677
|
padding: "var(--reactaform-button-padding, var(--reactaform-space) 12px)",
|
|
3658
3678
|
backgroundColor: r ? "var(--reactaform-button-disabled-bg, #cccccc)" : "var(--reactaform-button-bg, var(--reactaform-success-color))",
|
|
@@ -3670,22 +3690,22 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3670
3690
|
children: t("Submit")
|
|
3671
3691
|
}
|
|
3672
3692
|
);
|
|
3673
|
-
},
|
|
3693
|
+
}, hn = ({
|
|
3674
3694
|
definition: e,
|
|
3675
3695
|
instance: r,
|
|
3676
3696
|
onSubmit: t = void 0,
|
|
3677
3697
|
onValidation: n = void 0,
|
|
3678
|
-
chunkSize:
|
|
3679
|
-
chunkDelay:
|
|
3698
|
+
chunkSize: o = 50,
|
|
3699
|
+
chunkDelay: a = 50
|
|
3680
3700
|
}) => {
|
|
3681
|
-
const { properties: c, displayName: s } = e, i =
|
|
3701
|
+
const { properties: c, displayName: s } = e, i = B(), { t: d, formStyle: m, language: u, displayInstanceName: f } = i, b = {
|
|
3682
3702
|
...i,
|
|
3683
3703
|
definitionName: e?.name ?? i.definitionName
|
|
3684
|
-
}, [
|
|
3704
|
+
}, [C, N] = l.useState("en"), [h, y] = l.useState([]), [E, F] = l.useState({}), [M, $] = l.useState(
|
|
3685
3705
|
{}
|
|
3686
|
-
), [R, I] = l.useState({}), [v, g] = l.useState({}), [w, x] = l.useState(null), [k, S] = l.useState(null), [A, j] = l.useState(0), [K, ce] = l.useState(!1), [je,
|
|
3706
|
+
), [R, I] = l.useState({}), [v, g] = l.useState({}), [w, x] = l.useState(null), [k, S] = l.useState(null), [A, j] = l.useState(0), [K, ce] = l.useState(!1), [je, oe] = l.useState(r.name || ""), Y = l.useRef(r), fe = l.useRef(!1);
|
|
3687
3707
|
l.useEffect(() => {
|
|
3688
|
-
const
|
|
3708
|
+
const z = Object.fromEntries(
|
|
3689
3709
|
c.map((L) => [
|
|
3690
3710
|
L.name,
|
|
3691
3711
|
{ ...L, children: {} }
|
|
@@ -3693,7 +3713,7 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3693
3713
|
);
|
|
3694
3714
|
c.forEach((L) => {
|
|
3695
3715
|
L.parents && Object.entries(L.parents).forEach(([Q, re]) => {
|
|
3696
|
-
const X =
|
|
3716
|
+
const X = z[Q];
|
|
3697
3717
|
X && re.forEach((at) => {
|
|
3698
3718
|
X.children || (X.children = {});
|
|
3699
3719
|
const qe = String(at);
|
|
@@ -3703,45 +3723,45 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3703
3723
|
];
|
|
3704
3724
|
});
|
|
3705
3725
|
});
|
|
3706
|
-
}),
|
|
3726
|
+
}), un(c, z);
|
|
3707
3727
|
const q = Object.values(
|
|
3708
|
-
|
|
3709
|
-
),
|
|
3728
|
+
z
|
|
3729
|
+
), P = {};
|
|
3710
3730
|
q.forEach((L) => {
|
|
3711
3731
|
if (L.type === "unit") {
|
|
3712
3732
|
const Q = typeof L.defaultValue == "number" ? String(L.defaultValue) : "", re = typeof L.defaultUnit == "string" ? L.defaultUnit : String(L.defaultUnit ?? "m");
|
|
3713
|
-
|
|
3733
|
+
P[L.name] = [Q, re];
|
|
3714
3734
|
} else
|
|
3715
|
-
|
|
3735
|
+
P[L.name] = L.defaultValue;
|
|
3716
3736
|
}), Y.current = r, Object.keys(r.values).forEach((L) => {
|
|
3717
|
-
|
|
3737
|
+
z[L] !== void 0 && (P[L] = r.values[L]);
|
|
3718
3738
|
});
|
|
3719
3739
|
const J = Object.fromEntries(q.map((L) => [L.name, !1])), G = requestAnimationFrame(() => {
|
|
3720
|
-
y(q), F(
|
|
3721
|
-
|
|
3722
|
-
), ce(!0),
|
|
3740
|
+
y(q), F(z), $(P), I(
|
|
3741
|
+
cn(q, P, J, z)
|
|
3742
|
+
), ce(!0), oe(r.name);
|
|
3723
3743
|
});
|
|
3724
3744
|
return () => cancelAnimationFrame(G);
|
|
3725
3745
|
}, [c, r, e]), l.useEffect(() => {
|
|
3726
3746
|
if (!K || A >= h.length) return;
|
|
3727
|
-
const
|
|
3747
|
+
const z = setTimeout(() => {
|
|
3728
3748
|
j(
|
|
3729
|
-
(q) => Math.min(q +
|
|
3749
|
+
(q) => Math.min(q + o, h.length)
|
|
3730
3750
|
);
|
|
3731
|
-
},
|
|
3732
|
-
return () => clearTimeout(
|
|
3733
|
-
}, [K, A, h.length,
|
|
3751
|
+
}, a);
|
|
3752
|
+
return () => clearTimeout(z);
|
|
3753
|
+
}, [K, A, h.length, o, a]);
|
|
3734
3754
|
const Be = l.useCallback(
|
|
3735
|
-
(
|
|
3736
|
-
x(null), S(null), $((J) => ({ ...J, [
|
|
3737
|
-
const
|
|
3738
|
-
|
|
3739
|
-
const G = { ...M, [
|
|
3740
|
-
return
|
|
3755
|
+
(z, q) => {
|
|
3756
|
+
x(null), S(null), $((J) => ({ ...J, [z]: q }));
|
|
3757
|
+
const P = E[z];
|
|
3758
|
+
P && P.children && Object.keys(P.children).length > 0 && I((J) => {
|
|
3759
|
+
const G = { ...M, [z]: q };
|
|
3760
|
+
return ln(
|
|
3741
3761
|
J,
|
|
3742
3762
|
E,
|
|
3743
3763
|
G,
|
|
3744
|
-
|
|
3764
|
+
z,
|
|
3745
3765
|
q
|
|
3746
3766
|
);
|
|
3747
3767
|
});
|
|
@@ -3749,25 +3769,25 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3749
3769
|
[E, M]
|
|
3750
3770
|
);
|
|
3751
3771
|
l.useEffect(() => {
|
|
3752
|
-
let
|
|
3753
|
-
return
|
|
3754
|
-
u !==
|
|
3755
|
-
}), () => cancelAnimationFrame(
|
|
3756
|
-
}, [u,
|
|
3757
|
-
let
|
|
3758
|
-
return
|
|
3772
|
+
let z = 0;
|
|
3773
|
+
return z = requestAnimationFrame(() => {
|
|
3774
|
+
u !== C && (N(u || "en"), x(null), S(null));
|
|
3775
|
+
}), () => cancelAnimationFrame(z);
|
|
3776
|
+
}, [u, C]), l.useEffect(() => {
|
|
3777
|
+
let z = 0;
|
|
3778
|
+
return z = requestAnimationFrame(() => {
|
|
3759
3779
|
if (fe.current) {
|
|
3760
|
-
fe.current = !1, Y.current = r,
|
|
3780
|
+
fe.current = !1, Y.current = r, oe(r.name || "");
|
|
3761
3781
|
return;
|
|
3762
3782
|
}
|
|
3763
|
-
Y.current = r, x(null), S(null),
|
|
3764
|
-
}), () => cancelAnimationFrame(
|
|
3783
|
+
Y.current = r, x(null), S(null), oe(r.name || "");
|
|
3784
|
+
}), () => cancelAnimationFrame(z);
|
|
3765
3785
|
}, [r, r.name]);
|
|
3766
|
-
const He = l.useCallback((
|
|
3767
|
-
g((
|
|
3768
|
-
}, []),
|
|
3786
|
+
const He = l.useCallback((z, q) => {
|
|
3787
|
+
g((P) => q ? { ...P, [z]: String(q) } : Object.fromEntries(Object.entries(P).filter(([G]) => G !== z)));
|
|
3788
|
+
}, []), nt = async () => {
|
|
3769
3789
|
fe.current = !0;
|
|
3770
|
-
const
|
|
3790
|
+
const z = Y.current?.name;
|
|
3771
3791
|
Y.current.name = je;
|
|
3772
3792
|
let q = v;
|
|
3773
3793
|
if (b.fieldValidationMode === "onSubmission") {
|
|
@@ -3783,18 +3803,18 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3783
3803
|
} else
|
|
3784
3804
|
x(null), S(null);
|
|
3785
3805
|
}
|
|
3786
|
-
const
|
|
3806
|
+
const P = await pn(e, Y.current, M, d, q, t, n), J = typeof P.message == "string" ? P.message : String(P.message), G = Object.values(P.errors ?? {}).join(`
|
|
3787
3807
|
`);
|
|
3788
3808
|
x(G ? J + `
|
|
3789
|
-
` + G : J), S(
|
|
3790
|
-
},
|
|
3791
|
-
() => b.fieldValidationMode === "realTime" ? Object.values(v).some(Boolean) : !1,
|
|
3809
|
+
` + G : J), S(P.success), P.success || (Y.current.name = z ?? Y.current.name, oe(z ?? ""));
|
|
3810
|
+
}, ot = l.useMemo(
|
|
3811
|
+
() => b.fieldValidationMode === "onEdit" || b.fieldValidationMode === "realTime" ? Object.values(v).some(Boolean) : !1,
|
|
3792
3812
|
[v, b.fieldValidationMode]
|
|
3793
3813
|
);
|
|
3794
3814
|
return /* @__PURE__ */ p(Ee.Provider, { value: b, children: /* @__PURE__ */ D("div", { style: m.container, children: [
|
|
3795
3815
|
s && /* @__PURE__ */ p("h2", { style: m.titleStyle, children: d(s) }),
|
|
3796
3816
|
/* @__PURE__ */ p(
|
|
3797
|
-
|
|
3817
|
+
Yr,
|
|
3798
3818
|
{
|
|
3799
3819
|
message: w,
|
|
3800
3820
|
success: k,
|
|
@@ -3808,29 +3828,29 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3808
3828
|
sr,
|
|
3809
3829
|
{
|
|
3810
3830
|
name: je,
|
|
3811
|
-
onChange: (
|
|
3812
|
-
|
|
3831
|
+
onChange: (z) => {
|
|
3832
|
+
oe(z), x(null), S(null);
|
|
3813
3833
|
}
|
|
3814
3834
|
}
|
|
3815
3835
|
),
|
|
3816
3836
|
/* @__PURE__ */ D(Ie, { children: [
|
|
3817
3837
|
(() => {
|
|
3818
|
-
const
|
|
3819
|
-
return q.map((
|
|
3820
|
-
|
|
3838
|
+
const z = h.slice(0, A).filter((P) => R[P.name]), { groups: q } = mn(z);
|
|
3839
|
+
return q.map((P, J) => P.name ? /* @__PURE__ */ p(
|
|
3840
|
+
Kr,
|
|
3821
3841
|
{
|
|
3822
|
-
groupName:
|
|
3842
|
+
groupName: P.name,
|
|
3823
3843
|
defaultOpen: !0,
|
|
3824
|
-
fields:
|
|
3844
|
+
fields: P.fields,
|
|
3825
3845
|
valuesMap: M,
|
|
3826
3846
|
handleChange: Be,
|
|
3827
3847
|
handleError: He,
|
|
3828
3848
|
errorsMap: v,
|
|
3829
3849
|
t: d
|
|
3830
3850
|
},
|
|
3831
|
-
|
|
3832
|
-
) : /* @__PURE__ */ p(l.Fragment, { children:
|
|
3833
|
-
|
|
3851
|
+
P.name
|
|
3852
|
+
) : /* @__PURE__ */ p(l.Fragment, { children: P.fields.map((G) => /* @__PURE__ */ p(
|
|
3853
|
+
ze,
|
|
3834
3854
|
{
|
|
3835
3855
|
field: G,
|
|
3836
3856
|
valuesMap: M,
|
|
@@ -3852,9 +3872,9 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3852
3872
|
}
|
|
3853
3873
|
)
|
|
3854
3874
|
] }),
|
|
3855
|
-
/* @__PURE__ */ p(
|
|
3875
|
+
/* @__PURE__ */ p(gn, { onClick: nt, disabled: ot, t: d })
|
|
3856
3876
|
] }) });
|
|
3857
|
-
},
|
|
3877
|
+
}, Xr = {
|
|
3858
3878
|
en: { name: "English", nativeName: "English" },
|
|
3859
3879
|
fr: { name: "French", nativeName: "Français" },
|
|
3860
3880
|
de: { name: "German", nativeName: "Deutsch" },
|
|
@@ -3885,15 +3905,15 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3885
3905
|
uk: { name: "Ukrainian", nativeName: "Українська" },
|
|
3886
3906
|
vi: { name: "Vietnamese", nativeName: "Tiếng Việt" },
|
|
3887
3907
|
"zh-tw": { name: "Chinese (Traditional)", nativeName: "繁體中文" }
|
|
3888
|
-
},
|
|
3908
|
+
}, bo = () => Xr, be = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set(), we = /* @__PURE__ */ new Map(), bn = async (e) => {
|
|
3889
3909
|
try {
|
|
3890
3910
|
let r = {};
|
|
3891
3911
|
const t = e.toLowerCase();
|
|
3892
3912
|
if (t === "en")
|
|
3893
3913
|
r = {};
|
|
3894
|
-
else if (
|
|
3895
|
-
const
|
|
3896
|
-
|
|
3914
|
+
else if (Xr[t]) {
|
|
3915
|
+
const o = `https://reactaform.com/locales/${t}/common.json`, a = await fetch(o);
|
|
3916
|
+
a.ok && (r = await a.json());
|
|
3897
3917
|
} else
|
|
3898
3918
|
r = {};
|
|
3899
3919
|
return {
|
|
@@ -3908,7 +3928,7 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3908
3928
|
error: `Failed to load common translations for ${e}: ${r}`
|
|
3909
3929
|
};
|
|
3910
3930
|
}
|
|
3911
|
-
},
|
|
3931
|
+
}, yn = async (e) => {
|
|
3912
3932
|
if (!e || e.toLowerCase() === "en")
|
|
3913
3933
|
return { success: !0, translations: {}, fromCache: !1 };
|
|
3914
3934
|
const r = e.toLowerCase();
|
|
@@ -3918,13 +3938,13 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3918
3938
|
translations: be.get(r) || {},
|
|
3919
3939
|
fromCache: !0
|
|
3920
3940
|
};
|
|
3921
|
-
const t = await
|
|
3941
|
+
const t = await bn(r);
|
|
3922
3942
|
return t.success && (be.set(r, t.translations), we.set(r, {
|
|
3923
3943
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
3924
3944
|
size: Object.keys(t.translations).length,
|
|
3925
3945
|
source: "common"
|
|
3926
3946
|
})), t;
|
|
3927
|
-
},
|
|
3947
|
+
}, vn = async (e, r) => {
|
|
3928
3948
|
if (!e || !r)
|
|
3929
3949
|
return {
|
|
3930
3950
|
success: !1,
|
|
@@ -3948,9 +3968,9 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3948
3968
|
try {
|
|
3949
3969
|
let n = r;
|
|
3950
3970
|
!r.includes("/") && !r.includes(".") && (n = `/locales/${e}/${r}.json`);
|
|
3951
|
-
const
|
|
3952
|
-
if (!
|
|
3953
|
-
return
|
|
3971
|
+
const o = await fetch(n);
|
|
3972
|
+
if (!o.ok)
|
|
3973
|
+
return o.status === 404 ? (le.set(t, {}), we.set(t, {
|
|
3954
3974
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
3955
3975
|
size: 0,
|
|
3956
3976
|
source: "user"
|
|
@@ -3961,14 +3981,14 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3961
3981
|
}) : (te.add(t), {
|
|
3962
3982
|
success: !1,
|
|
3963
3983
|
translations: {},
|
|
3964
|
-
error: `HTTP ${
|
|
3984
|
+
error: `HTTP ${o.status}`,
|
|
3965
3985
|
fromCache: !1
|
|
3966
3986
|
});
|
|
3967
|
-
const
|
|
3968
|
-
!
|
|
3969
|
-
`Translation file at ${n} has unexpected content-type: ${
|
|
3987
|
+
const a = o.headers.get("content-type") || "";
|
|
3988
|
+
!a.includes("application/json") && !a.includes("text/json") && Zr() && console.warn(
|
|
3989
|
+
`Translation file at ${n} has unexpected content-type: ${a}`
|
|
3970
3990
|
);
|
|
3971
|
-
const c = await
|
|
3991
|
+
const c = await o.text();
|
|
3972
3992
|
if (!c) {
|
|
3973
3993
|
const d = "Empty translation file";
|
|
3974
3994
|
return te.add(t), { success: !1, translations: {}, error: d };
|
|
@@ -4004,15 +4024,15 @@ const fn = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
4004
4024
|
fromCache: !1
|
|
4005
4025
|
};
|
|
4006
4026
|
} catch (n) {
|
|
4007
|
-
const
|
|
4027
|
+
const o = `Failed to load user translations: ${n instanceof Error ? n.message : "Unknown error"}`;
|
|
4008
4028
|
return te.add(t), {
|
|
4009
4029
|
success: !1,
|
|
4010
4030
|
translations: {},
|
|
4011
|
-
error:
|
|
4031
|
+
error: o
|
|
4012
4032
|
};
|
|
4013
4033
|
}
|
|
4014
4034
|
};
|
|
4015
|
-
function
|
|
4035
|
+
function Zr() {
|
|
4016
4036
|
try {
|
|
4017
4037
|
if (typeof process < "u" && process?.env?.NODE_ENV === "development")
|
|
4018
4038
|
return !0;
|
|
@@ -4020,72 +4040,72 @@ function Xr() {
|
|
|
4020
4040
|
}
|
|
4021
4041
|
return !1;
|
|
4022
4042
|
}
|
|
4023
|
-
function
|
|
4043
|
+
function xn(e, r) {
|
|
4024
4044
|
return r.length === 0 ? e : e.replace(/\{\{(\d+)\}\}/g, (t, n) => {
|
|
4025
|
-
const
|
|
4026
|
-
return
|
|
4045
|
+
const o = parseInt(n, 10) - 1, a = r[o];
|
|
4046
|
+
return a == null ? t : String(a);
|
|
4027
4047
|
});
|
|
4028
4048
|
}
|
|
4029
|
-
const
|
|
4030
|
-
let
|
|
4031
|
-
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (
|
|
4049
|
+
const wn = (e, r, t) => (n, ...o) => {
|
|
4050
|
+
let a = n, c = !1;
|
|
4051
|
+
return !n || typeof n != "string" ? String(n || "") : (e.toLowerCase() === "en" ? (a = n, c = !0) : n in t ? (a = t[n], c = !0) : n in r ? (a = r[n], c = !0) : a = n, a = xn(a, o), !c && Zr() && console.debug(
|
|
4032
4052
|
`Missing translation for "${n}" in language "${e}"`
|
|
4033
|
-
),
|
|
4053
|
+
), a);
|
|
4034
4054
|
};
|
|
4035
|
-
function
|
|
4055
|
+
function Sn(e) {
|
|
4036
4056
|
return /^[-+]?\d*$/.test(e);
|
|
4037
4057
|
}
|
|
4038
|
-
function
|
|
4058
|
+
function Cn(e) {
|
|
4039
4059
|
const r = /^[-+]?\d*$/;
|
|
4040
4060
|
return e.split(",").map((t) => t.trim()).every((t) => r.test(t));
|
|
4041
4061
|
}
|
|
4042
|
-
const
|
|
4062
|
+
const Nn = ",", kn = (e) => !e || e.trim() === "" ? [] : e.split(Nn).map((r) => r.trim()).filter(Boolean).map((r) => Number(r)), Xe = (e, r, t) => {
|
|
4043
4063
|
const n = String(r);
|
|
4044
4064
|
if (n.trim() === "")
|
|
4045
4065
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
4046
|
-
if (!
|
|
4066
|
+
if (!Sn(n))
|
|
4047
4067
|
return t("Must be a valid integer");
|
|
4048
|
-
const
|
|
4049
|
-
if (Number.isNaN(
|
|
4050
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
4068
|
+
const o = parseInt(n, 10);
|
|
4069
|
+
if (Number.isNaN(o)) return t("Must be a valid integer");
|
|
4070
|
+
if (e.min !== void 0 && (e.minInclusive ? o < e.min : o <= e.min))
|
|
4051
4071
|
return t(
|
|
4052
4072
|
"Must be {{1}} {{2}}",
|
|
4053
4073
|
e.minInclusive ? "≥" : ">",
|
|
4054
4074
|
e.min
|
|
4055
4075
|
);
|
|
4056
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
4076
|
+
if (e.max !== void 0 && (e.maxInclusive ? o > e.max : o >= e.max))
|
|
4057
4077
|
return t(
|
|
4058
4078
|
"Must be {{1}} {{2}}",
|
|
4059
4079
|
e.maxInclusive ? "≤" : "<",
|
|
4060
4080
|
e.max
|
|
4061
4081
|
);
|
|
4062
4082
|
if (e.step !== void 0) {
|
|
4063
|
-
const
|
|
4064
|
-
if (!Number.isInteger(
|
|
4083
|
+
const a = Number(e.step);
|
|
4084
|
+
if (!Number.isInteger(a))
|
|
4065
4085
|
return t("Invalid step value");
|
|
4066
|
-
if (
|
|
4067
|
-
return t("Must be a multiple of {{1}}",
|
|
4086
|
+
if (o % a !== 0)
|
|
4087
|
+
return t("Must be a multiple of {{1}}", a);
|
|
4068
4088
|
}
|
|
4069
4089
|
};
|
|
4070
|
-
function
|
|
4090
|
+
function In(e, r, t) {
|
|
4071
4091
|
const n = String(r);
|
|
4072
4092
|
if (n.trim() === "")
|
|
4073
4093
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
4074
|
-
if (!
|
|
4094
|
+
if (!Cn(n))
|
|
4075
4095
|
return t("Each value must be a valid integer");
|
|
4076
|
-
const
|
|
4077
|
-
if (e.minCount !== void 0 &&
|
|
4096
|
+
const o = kn(n);
|
|
4097
|
+
if (e.minCount !== void 0 && o.length < e.minCount)
|
|
4078
4098
|
return t("Minimum number of values: {{1}}", `${e.minCount}`);
|
|
4079
|
-
if (e.maxCount !== void 0 &&
|
|
4099
|
+
if (e.maxCount !== void 0 && o.length > e.maxCount)
|
|
4080
4100
|
return t("Maximum number of values: {{1}}", `${e.maxCount}`);
|
|
4081
|
-
for (const
|
|
4082
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
4101
|
+
for (const a of o) {
|
|
4102
|
+
if (e.min !== void 0 && (e.minInclusive ? a < e.min : a <= e.min))
|
|
4083
4103
|
return t(
|
|
4084
4104
|
"Each value must be {{1}} {{2}}",
|
|
4085
4105
|
e.minInclusive ? "≥" : ">",
|
|
4086
4106
|
e.min
|
|
4087
4107
|
);
|
|
4088
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
4108
|
+
if (e.max !== void 0 && (e.maxInclusive ? a > e.max : a >= e.max))
|
|
4089
4109
|
return t(
|
|
4090
4110
|
"Each value must be {{1}} {{2}}",
|
|
4091
4111
|
e.maxInclusive ? "≤" : "<",
|
|
@@ -4093,55 +4113,55 @@ function Nn(e, r, t) {
|
|
|
4093
4113
|
);
|
|
4094
4114
|
}
|
|
4095
4115
|
}
|
|
4096
|
-
function
|
|
4116
|
+
function Qr(e, r, t) {
|
|
4097
4117
|
const n = String(r);
|
|
4098
4118
|
if (n.trim() === "")
|
|
4099
4119
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
4100
|
-
const
|
|
4101
|
-
if (Number.isNaN(
|
|
4120
|
+
const o = Number(n);
|
|
4121
|
+
if (Number.isNaN(o)) return t("Must be a valid float");
|
|
4102
4122
|
if (e.min !== void 0) {
|
|
4103
|
-
const
|
|
4104
|
-
if (
|
|
4123
|
+
const a = e.type === "slider" ? !0 : e.minInclusive ?? !0;
|
|
4124
|
+
if (a ? o < e.min : o <= e.min)
|
|
4105
4125
|
return t(
|
|
4106
4126
|
"Must be {{1}} {{2}}",
|
|
4107
|
-
|
|
4127
|
+
a ? "≥" : ">",
|
|
4108
4128
|
e.min
|
|
4109
4129
|
);
|
|
4110
4130
|
}
|
|
4111
4131
|
if (e.max !== void 0) {
|
|
4112
|
-
const
|
|
4113
|
-
if (
|
|
4132
|
+
const a = e.type === "slider" ? !0 : e.maxInclusive ?? !0;
|
|
4133
|
+
if (a ? o > e.max : o >= e.max)
|
|
4114
4134
|
return t(
|
|
4115
4135
|
"Must be {{1}} {{2}}",
|
|
4116
|
-
|
|
4136
|
+
a ? "≤" : "<",
|
|
4117
4137
|
e.max
|
|
4118
4138
|
);
|
|
4119
4139
|
}
|
|
4120
4140
|
}
|
|
4121
|
-
const
|
|
4122
|
-
function
|
|
4123
|
-
return e.split(",").map((r) => r.trim()).every((r) =>
|
|
4141
|
+
const En = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
4142
|
+
function Mn(e) {
|
|
4143
|
+
return e.split(",").map((r) => r.trim()).every((r) => En.test(r));
|
|
4124
4144
|
}
|
|
4125
|
-
const
|
|
4126
|
-
function
|
|
4145
|
+
const Fn = ",", $n = (e) => !e || e.trim() === "" ? [] : e.split(Fn).map((r) => r.trim()).filter(Boolean).map((r) => Number(r));
|
|
4146
|
+
function Vn(e, r, t) {
|
|
4127
4147
|
const n = String(r);
|
|
4128
4148
|
if (n.trim() === "")
|
|
4129
4149
|
return e.min !== void 0 || e.max !== void 0 ? t("Value required when min or max constraints is set") : e.required ? t("Value required") : void 0;
|
|
4130
|
-
if (!
|
|
4150
|
+
if (!Mn(n))
|
|
4131
4151
|
return t("Each value must be a valid float");
|
|
4132
|
-
const
|
|
4133
|
-
if (e.minCount !== void 0 &&
|
|
4152
|
+
const o = $n(n);
|
|
4153
|
+
if (e.minCount !== void 0 && o.length < e.minCount)
|
|
4134
4154
|
return t("Minimum number of values: {{1}}", e.minCount);
|
|
4135
|
-
if (e.maxCount !== void 0 &&
|
|
4155
|
+
if (e.maxCount !== void 0 && o.length > e.maxCount)
|
|
4136
4156
|
return t("Maximum number of values: {{1}}", e.maxCount);
|
|
4137
|
-
for (const
|
|
4138
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
4157
|
+
for (const a of o) {
|
|
4158
|
+
if (e.min !== void 0 && (e.minInclusive ? a < e.min : a <= e.min))
|
|
4139
4159
|
return t(
|
|
4140
4160
|
"Each value must be {{1}} {{2}}",
|
|
4141
4161
|
e.minInclusive ? "≥" : ">",
|
|
4142
4162
|
e.min
|
|
4143
4163
|
);
|
|
4144
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
4164
|
+
if (e.max !== void 0 && (e.maxInclusive ? a > e.max : a >= e.max))
|
|
4145
4165
|
return t(
|
|
4146
4166
|
"Each value must be {{1}} {{2}}",
|
|
4147
4167
|
e.maxInclusive ? "≤" : "<",
|
|
@@ -4150,10 +4170,10 @@ function Fn(e, r, t) {
|
|
|
4150
4170
|
}
|
|
4151
4171
|
}
|
|
4152
4172
|
const ye = /* @__PURE__ */ new WeakMap();
|
|
4153
|
-
function Oe(e, r, t, n, ...
|
|
4173
|
+
function Oe(e, r, t, n, ...o) {
|
|
4154
4174
|
if (e.pattern == null)
|
|
4155
4175
|
return;
|
|
4156
|
-
const
|
|
4176
|
+
const a = String(r);
|
|
4157
4177
|
let c = null;
|
|
4158
4178
|
if (e.pattern) {
|
|
4159
4179
|
const s = ye.get(e);
|
|
@@ -4167,44 +4187,44 @@ function Oe(e, r, t, n, ...a) {
|
|
|
4167
4187
|
ye.set(e, { pattern: e.pattern, regex: null }), c = null;
|
|
4168
4188
|
}
|
|
4169
4189
|
}
|
|
4170
|
-
if (c && !c.test(
|
|
4171
|
-
return e.patternErrorMessage ? t(e.patternErrorMessage) : n ? t(n, ...
|
|
4190
|
+
if (c && !c.test(a))
|
|
4191
|
+
return e.patternErrorMessage ? t(e.patternErrorMessage) : n ? t(n, ...o) : t("Input does not match pattern: {{1}}", e.pattern);
|
|
4172
4192
|
}
|
|
4173
4193
|
function ue(e, r, t) {
|
|
4174
4194
|
const n = String(r);
|
|
4175
4195
|
if (n === "")
|
|
4176
4196
|
return e.minLength !== void 0 || e.maxLength !== void 0 ? e.required ? t("Value required when minLength or maxLength is set") : void 0 : e.required ? t("Value required") : void 0;
|
|
4177
|
-
const
|
|
4178
|
-
return n.length <
|
|
4197
|
+
const o = Math.max(e.minLength ?? 0, 0);
|
|
4198
|
+
return n.length < o ? t("Must be at least {{1}} characters", o) : e.maxLength !== void 0 && n.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) : Oe(e, r, t, "Invalid text format");
|
|
4179
4199
|
}
|
|
4180
4200
|
const Se = (e) => {
|
|
4181
4201
|
if (!e) return null;
|
|
4182
4202
|
const r = Date.parse(e);
|
|
4183
4203
|
return Number.isNaN(r) ? null : r;
|
|
4184
|
-
}, Ze = /* @__PURE__ */ new WeakMap(),
|
|
4204
|
+
}, Ze = /* @__PURE__ */ new WeakMap(), An = (e) => {
|
|
4185
4205
|
let r = Ze.get(e);
|
|
4186
4206
|
return r || (r = {
|
|
4187
4207
|
minTime: Se(e.minDate),
|
|
4188
4208
|
maxTime: Se(e.maxDate)
|
|
4189
4209
|
}, Ze.set(e, r)), r;
|
|
4190
4210
|
};
|
|
4191
|
-
function
|
|
4211
|
+
function Rn(e, r, t) {
|
|
4192
4212
|
if (r == null || String(r).trim() === "")
|
|
4193
4213
|
return e.required ? t("Value required") : void 0;
|
|
4194
|
-
const n = String(r).trim(),
|
|
4195
|
-
if (
|
|
4214
|
+
const n = String(r).trim(), o = Se(n);
|
|
4215
|
+
if (o === null)
|
|
4196
4216
|
return t("Invalid date format");
|
|
4197
|
-
const { minTime:
|
|
4198
|
-
if (
|
|
4217
|
+
const { minTime: a, maxTime: c } = An(e);
|
|
4218
|
+
if (a !== null && o < a)
|
|
4199
4219
|
return t("Date must be on or after {{1}}", e.minDate);
|
|
4200
|
-
if (c !== null &&
|
|
4220
|
+
if (c !== null && o > c)
|
|
4201
4221
|
return t("Date must be on or before {{1}}", e.maxDate);
|
|
4202
4222
|
}
|
|
4203
|
-
function
|
|
4223
|
+
function Dn(e, r, t) {
|
|
4204
4224
|
const n = String(r);
|
|
4205
4225
|
if (!n || n.trim() === "")
|
|
4206
4226
|
return e.required || e.min || e.max ? t("Value required") : void 0;
|
|
4207
|
-
const
|
|
4227
|
+
const o = (c) => {
|
|
4208
4228
|
const s = c.split(":").map((m) => parseInt(m, 10));
|
|
4209
4229
|
if (s.some((m) => Number.isNaN(m))) return NaN;
|
|
4210
4230
|
const i = s.length;
|
|
@@ -4221,42 +4241,42 @@ function An(e, r, t) {
|
|
|
4221
4241
|
else
|
|
4222
4242
|
return NaN;
|
|
4223
4243
|
return d;
|
|
4224
|
-
},
|
|
4225
|
-
if (Number.isNaN(
|
|
4244
|
+
}, a = o(n);
|
|
4245
|
+
if (Number.isNaN(a)) return t("Invalid time format");
|
|
4226
4246
|
if (e.min && typeof e.min == "string") {
|
|
4227
|
-
const c =
|
|
4228
|
-
if (!Number.isNaN(c) &&
|
|
4247
|
+
const c = o(e.min);
|
|
4248
|
+
if (!Number.isNaN(c) && a < c)
|
|
4229
4249
|
return t("Time must be on or after {{1}}", e.min);
|
|
4230
4250
|
}
|
|
4231
4251
|
if (e.max && typeof e.max == "string") {
|
|
4232
|
-
const c =
|
|
4233
|
-
if (!Number.isNaN(c) &&
|
|
4252
|
+
const c = o(e.max);
|
|
4253
|
+
if (!Number.isNaN(c) && a > c)
|
|
4234
4254
|
return t("Time must be on or before {{1}}", e.max);
|
|
4235
4255
|
}
|
|
4236
4256
|
}
|
|
4237
|
-
function
|
|
4257
|
+
function zn(e) {
|
|
4238
4258
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
4239
4259
|
}
|
|
4240
|
-
function
|
|
4260
|
+
function Pn(e, r, t) {
|
|
4241
4261
|
const n = String(r ?? "").trim();
|
|
4242
|
-
return n === "" ? e.required ? t("Value required") : void 0 :
|
|
4262
|
+
return n === "" ? e.required ? t("Value required") : void 0 : zn(n) ? Oe(e, r, t, t("Email does not match pattern: {{1}}", e.pattern)) : t("Must be valid email format");
|
|
4243
4263
|
}
|
|
4244
|
-
function
|
|
4264
|
+
function Ln(e, r, t) {
|
|
4245
4265
|
const n = String(r ?? "").trim();
|
|
4246
4266
|
return n === "" ? e.required ? t("Value required") : void 0 : Oe(e, n, t, "Invalid phone number format");
|
|
4247
4267
|
}
|
|
4248
|
-
const
|
|
4268
|
+
const On = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i, Tn = (e) => {
|
|
4249
4269
|
try {
|
|
4250
4270
|
return new URL(e), !0;
|
|
4251
4271
|
} catch {
|
|
4252
4272
|
return !1;
|
|
4253
4273
|
}
|
|
4254
4274
|
};
|
|
4255
|
-
function
|
|
4275
|
+
function jn(e, r, t) {
|
|
4256
4276
|
const n = String(r ?? "").trim();
|
|
4257
4277
|
if (n === "")
|
|
4258
4278
|
return e.required ? t("Value required") : void 0;
|
|
4259
|
-
if (!(
|
|
4279
|
+
if (!(On.test(n) || Tn(n))) {
|
|
4260
4280
|
if (e.allowRelative === !0) {
|
|
4261
4281
|
if (!n.startsWith("/") || encodeURI(n) !== n)
|
|
4262
4282
|
return t("Must be a valid URL");
|
|
@@ -4270,11 +4290,11 @@ function On(e, r, t) {
|
|
|
4270
4290
|
return t("Must be a valid URL");
|
|
4271
4291
|
}
|
|
4272
4292
|
}
|
|
4273
|
-
function
|
|
4274
|
-
const n = Array.isArray(r) ? r : [],
|
|
4275
|
-
return String(
|
|
4293
|
+
function Bn(e, r, t) {
|
|
4294
|
+
const n = Array.isArray(r) ? r : [], o = n[0], a = n[1] ? String(n[1]).trim() : "";
|
|
4295
|
+
return String(o ?? "").trim() === "" || a === "" ? e.required ? t("Value required") : void 0 : Qr(e, o, t);
|
|
4276
4296
|
}
|
|
4277
|
-
function
|
|
4297
|
+
function Hn(e, r, t) {
|
|
4278
4298
|
if (Array.isArray(r))
|
|
4279
4299
|
return r.length === 0 ? t("Select a file") : r.every((n) => n instanceof File) ? void 0 : t("Invalid file input");
|
|
4280
4300
|
if (!(r instanceof File)) {
|
|
@@ -4282,62 +4302,62 @@ function jn(e, r, t) {
|
|
|
4282
4302
|
return e.required && (r == null || typeof n == "string" && n.trim() === "") ? t("Select a file") : t("Invalid file input: {{1}}", n);
|
|
4283
4303
|
}
|
|
4284
4304
|
}
|
|
4285
|
-
function
|
|
4305
|
+
function qn(e, r, t) {
|
|
4286
4306
|
const n = String(r);
|
|
4287
4307
|
if (n === "" || n === null || n === void 0)
|
|
4288
4308
|
return e.required ? t("Value required") : void 0;
|
|
4289
|
-
if (!e.options?.some((
|
|
4309
|
+
if (!e.options?.some((o) => String(o.value) === n))
|
|
4290
4310
|
return t("Invalid option selected");
|
|
4291
4311
|
}
|
|
4292
|
-
function
|
|
4293
|
-
const
|
|
4294
|
-
if (
|
|
4312
|
+
function Un(e, r, t) {
|
|
4313
|
+
const o = String(r ?? "").trim();
|
|
4314
|
+
if (o === "")
|
|
4295
4315
|
return e.required ? t("Value required") : void 0;
|
|
4296
|
-
const
|
|
4297
|
-
if (
|
|
4316
|
+
const a = o.split(",").map((c) => c.trim()).filter((c) => c !== "");
|
|
4317
|
+
if (a.length === 0)
|
|
4298
4318
|
return e.required ? t("Value required") : void 0;
|
|
4299
|
-
for (const c of
|
|
4319
|
+
for (const c of a)
|
|
4300
4320
|
if (!e.options?.some((s) => String(s.value) === c))
|
|
4301
4321
|
return t("Invalid option selected");
|
|
4302
4322
|
}
|
|
4303
|
-
const
|
|
4304
|
-
function
|
|
4323
|
+
const Wn = /^#([0-9A-F]{3}){1,2}$/i, _n = (e) => Wn.test(e);
|
|
4324
|
+
function Kn(e, r, t) {
|
|
4305
4325
|
const n = String(r).trim();
|
|
4306
4326
|
if (n === "")
|
|
4307
4327
|
return e.required ? t("Value required") : void 0;
|
|
4308
|
-
if (!
|
|
4328
|
+
if (!_n(n))
|
|
4309
4329
|
return t("Invalid color format");
|
|
4310
4330
|
}
|
|
4311
|
-
function
|
|
4331
|
+
function Gn(e, r, t) {
|
|
4312
4332
|
const n = String(r ?? "").trim();
|
|
4313
4333
|
if (n === "")
|
|
4314
4334
|
return e.required ? t("Value required") : void 0;
|
|
4315
|
-
let
|
|
4316
|
-
if (typeof r != "number" && (
|
|
4335
|
+
let o = r;
|
|
4336
|
+
if (typeof r != "number" && (o = parseFloat(n)), Number.isNaN(o) || o <= 0)
|
|
4317
4337
|
return t("Invalid value");
|
|
4318
|
-
if (e.max !== void 0 &&
|
|
4338
|
+
if (e.max !== void 0 && o > e.max)
|
|
4319
4339
|
return t("Must be ≤ {{1}}", e.max);
|
|
4320
4340
|
}
|
|
4321
|
-
function
|
|
4341
|
+
function Jn(e, r, t) {
|
|
4322
4342
|
const n = String(r);
|
|
4323
4343
|
if (n.trim() === "")
|
|
4324
4344
|
return e.required ? t("Value required") : void 0;
|
|
4325
|
-
const
|
|
4326
|
-
if (Number.isNaN(
|
|
4327
|
-
const
|
|
4328
|
-
if (
|
|
4329
|
-
return t("Must be ≥ {{1}}",
|
|
4330
|
-
if (
|
|
4345
|
+
const o = Number(n);
|
|
4346
|
+
if (Number.isNaN(o)) return t("Must be a valid float");
|
|
4347
|
+
const a = e.min ?? 0, c = e.max ?? 100;
|
|
4348
|
+
if (o < a)
|
|
4349
|
+
return t("Must be ≥ {{1}}", a);
|
|
4350
|
+
if (o > c)
|
|
4331
4351
|
return t("Must be ≤ {{1}}", c);
|
|
4332
4352
|
}
|
|
4333
4353
|
let Qe = !1;
|
|
4334
|
-
function
|
|
4335
|
-
Qe || (
|
|
4354
|
+
function et() {
|
|
4355
|
+
Qe || (H("int", Xe), H("stepper", Xe), H("int-array", In), H("float", Qr), H("slider", Jn), H("float-array", Vn), H("text", ue), H("string", ue), H("multiline", ue), H("password", ue), H("email", Pn), H("date", Rn), H("time", Dn), H("url", jn), H("phone", Ln), H("unit", Bn), H("dropdown", qn), H("multi-selection", Un), H("color", Kn), H("rating", Gn), H("file", Hn), Qe = !0);
|
|
4336
4356
|
}
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
const
|
|
4357
|
+
et();
|
|
4358
|
+
sn();
|
|
4359
|
+
et();
|
|
4360
|
+
const Yn = (e) => ({
|
|
4341
4361
|
container: {
|
|
4342
4362
|
padding: "var(--reactaform-space-sm, 8px)",
|
|
4343
4363
|
margin: "0 auto",
|
|
@@ -4378,7 +4398,7 @@ const Gn = (e) => ({
|
|
|
4378
4398
|
lineHeight: "1.2",
|
|
4379
4399
|
textAlign: "left"
|
|
4380
4400
|
}
|
|
4381
|
-
}),
|
|
4401
|
+
}), Xn = (e) => {
|
|
4382
4402
|
const r = {
|
|
4383
4403
|
color: "var(--reactaform-color-text)",
|
|
4384
4404
|
fontFamily: e?.fontFamily || "var(--reactaform-font-family, inherit)",
|
|
@@ -4437,43 +4457,43 @@ const Gn = (e) => ({
|
|
|
4437
4457
|
display: "block"
|
|
4438
4458
|
}
|
|
4439
4459
|
};
|
|
4440
|
-
},
|
|
4460
|
+
}, Zn = ({
|
|
4441
4461
|
children: e,
|
|
4442
4462
|
definitionName: r = "",
|
|
4443
4463
|
defaultStyle: t,
|
|
4444
4464
|
defaultLanguage: n = "en",
|
|
4445
|
-
defaultTheme:
|
|
4446
|
-
defaultLocalizeName:
|
|
4447
|
-
defaultFieldValidationMode: c = "
|
|
4465
|
+
defaultTheme: o = "light",
|
|
4466
|
+
defaultLocalizeName: a = "",
|
|
4467
|
+
defaultFieldValidationMode: c = "onEdit",
|
|
4448
4468
|
className: s = "reactaform-container",
|
|
4449
4469
|
defaultDisplayInstanceName: i = !0
|
|
4450
4470
|
}) => {
|
|
4451
|
-
const d = r, m =
|
|
4471
|
+
const d = r, m = a, u = o, f = n, b = l.useMemo(
|
|
4452
4472
|
() => t ?? {},
|
|
4453
4473
|
[t]
|
|
4454
|
-
), [
|
|
4474
|
+
), [C, N] = l.useState({}), [h, y] = l.useState({});
|
|
4455
4475
|
l.useEffect(() => {
|
|
4456
4476
|
let v = !0;
|
|
4457
4477
|
return (async () => {
|
|
4458
4478
|
if (f === "en") {
|
|
4459
|
-
v && (
|
|
4479
|
+
v && (N({}), y({}));
|
|
4460
4480
|
return;
|
|
4461
4481
|
}
|
|
4462
4482
|
try {
|
|
4463
|
-
const w = await
|
|
4464
|
-
v &&
|
|
4465
|
-
const k = await
|
|
4483
|
+
const w = await yn(f), x = w.success ? w.translations : {};
|
|
4484
|
+
v && N(x);
|
|
4485
|
+
const k = await vn(f, m), S = k.success ? k.translations : {};
|
|
4466
4486
|
v && y(S);
|
|
4467
4487
|
} catch {
|
|
4468
|
-
v && (
|
|
4488
|
+
v && (N({}), y({}));
|
|
4469
4489
|
}
|
|
4470
4490
|
})(), () => {
|
|
4471
4491
|
v = !1;
|
|
4472
4492
|
};
|
|
4473
4493
|
}, [f, m]);
|
|
4474
|
-
const E = l.useMemo(() =>
|
|
4475
|
-
() =>
|
|
4476
|
-
[f,
|
|
4494
|
+
const E = l.useMemo(() => Yn(b), [b]), F = l.useMemo(() => Xn(b), [b]), M = l.useMemo(
|
|
4495
|
+
() => wn(f, C, h),
|
|
4496
|
+
[f, C, h]
|
|
4477
4497
|
), $ = l.useCallback(
|
|
4478
4498
|
(v, ...g) => M(v, ...g),
|
|
4479
4499
|
[M]
|
|
@@ -4509,7 +4529,7 @@ const Gn = (e) => ({
|
|
|
4509
4529
|
}
|
|
4510
4530
|
) });
|
|
4511
4531
|
};
|
|
4512
|
-
function
|
|
4532
|
+
function Qn(e) {
|
|
4513
4533
|
if (!e || typeof e != "object")
|
|
4514
4534
|
return "Definition must be an object";
|
|
4515
4535
|
const r = e;
|
|
@@ -4537,7 +4557,7 @@ function Xn(e) {
|
|
|
4537
4557
|
}
|
|
4538
4558
|
return null;
|
|
4539
4559
|
}
|
|
4540
|
-
async function
|
|
4560
|
+
async function yo(e, r = {}) {
|
|
4541
4561
|
const { validateSchema: t = !0 } = r;
|
|
4542
4562
|
try {
|
|
4543
4563
|
if (!e || typeof e != "string")
|
|
@@ -4545,26 +4565,26 @@ async function ga(e, r = {}) {
|
|
|
4545
4565
|
const n = e.trim();
|
|
4546
4566
|
if (!n)
|
|
4547
4567
|
return { success: !1, error: "jsonData is empty" };
|
|
4548
|
-
let
|
|
4568
|
+
let o;
|
|
4549
4569
|
try {
|
|
4550
|
-
|
|
4551
|
-
} catch (
|
|
4570
|
+
o = JSON.parse(n);
|
|
4571
|
+
} catch (a) {
|
|
4552
4572
|
return {
|
|
4553
4573
|
success: !1,
|
|
4554
|
-
error: `Invalid JSON format: ${
|
|
4574
|
+
error: `Invalid JSON format: ${a instanceof Error ? a.message : "Unknown parsing error"}`
|
|
4555
4575
|
};
|
|
4556
4576
|
}
|
|
4557
4577
|
if (t) {
|
|
4558
|
-
const
|
|
4559
|
-
if (
|
|
4560
|
-
return { success: !1, error: `Schema validation failed: ${
|
|
4578
|
+
const a = Qn(o);
|
|
4579
|
+
if (a)
|
|
4580
|
+
return { success: !1, error: `Schema validation failed: ${a}` };
|
|
4561
4581
|
}
|
|
4562
|
-
return { success: !0, definition:
|
|
4582
|
+
return { success: !0, definition: o };
|
|
4563
4583
|
} catch (n) {
|
|
4564
4584
|
return { success: !1, error: `Unexpected error loading definition: ${n instanceof Error ? n.message : "Unknown error"}` };
|
|
4565
4585
|
}
|
|
4566
4586
|
}
|
|
4567
|
-
function
|
|
4587
|
+
function eo(e, r) {
|
|
4568
4588
|
try {
|
|
4569
4589
|
if (!e)
|
|
4570
4590
|
return { success: !1, error: "Definition is required" };
|
|
@@ -4576,13 +4596,13 @@ function Zn(e, r) {
|
|
|
4576
4596
|
version: e.version ?? "1.0.0",
|
|
4577
4597
|
values: {}
|
|
4578
4598
|
}, n = e.properties || [];
|
|
4579
|
-
return Array.isArray(n) && n.forEach((
|
|
4580
|
-
const
|
|
4581
|
-
if (
|
|
4582
|
-
const c =
|
|
4583
|
-
t.values[
|
|
4599
|
+
return Array.isArray(n) && n.forEach((o) => {
|
|
4600
|
+
const a = o;
|
|
4601
|
+
if (a.type === "unit") {
|
|
4602
|
+
const c = a.defaultUnit, s = Number(a.defaultValue) || void 0;
|
|
4603
|
+
t.values[a.name] = [s || 0, c || "m"];
|
|
4584
4604
|
} else
|
|
4585
|
-
|
|
4605
|
+
a.defaultValue !== void 0 && (t.values[a.name] = a.defaultValue);
|
|
4586
4606
|
}), { success: !0, instance: t };
|
|
4587
4607
|
} catch (t) {
|
|
4588
4608
|
return {
|
|
@@ -4591,7 +4611,7 @@ function Zn(e, r) {
|
|
|
4591
4611
|
};
|
|
4592
4612
|
}
|
|
4593
4613
|
}
|
|
4594
|
-
function
|
|
4614
|
+
function vo(e) {
|
|
4595
4615
|
try {
|
|
4596
4616
|
if (!e)
|
|
4597
4617
|
return { success: !1, error: "Instance data is required" };
|
|
@@ -4615,7 +4635,7 @@ function ha(e) {
|
|
|
4615
4635
|
};
|
|
4616
4636
|
}
|
|
4617
4637
|
}
|
|
4618
|
-
function
|
|
4638
|
+
function xo(e, r, t) {
|
|
4619
4639
|
try {
|
|
4620
4640
|
if (!e)
|
|
4621
4641
|
return { success: !1, error: "Instance is required" };
|
|
@@ -4628,9 +4648,9 @@ function ba(e, r, t) {
|
|
|
4628
4648
|
definition: r.name,
|
|
4629
4649
|
version: r.version,
|
|
4630
4650
|
values: {}
|
|
4631
|
-
},
|
|
4651
|
+
}, o = n.values, a = {};
|
|
4632
4652
|
(r.properties || []).forEach((i) => {
|
|
4633
|
-
|
|
4653
|
+
a[i.name] = i;
|
|
4634
4654
|
});
|
|
4635
4655
|
const c = (i, d, m) => {
|
|
4636
4656
|
if (i == null) return i;
|
|
@@ -4675,14 +4695,14 @@ function ba(e, r, t) {
|
|
|
4675
4695
|
return i;
|
|
4676
4696
|
}, s = e.values || {};
|
|
4677
4697
|
Object.keys(s).forEach((i) => {
|
|
4678
|
-
const d = s[i], m =
|
|
4698
|
+
const d = s[i], m = a[i];
|
|
4679
4699
|
if (!m)
|
|
4680
4700
|
return;
|
|
4681
4701
|
const u = Array.isArray(d) ? "array" : d === null ? "null" : typeof d, f = (m.type || "").toLowerCase();
|
|
4682
|
-
u === f || f === "string" && typeof d == "string" ?
|
|
4702
|
+
u === f || f === "string" && typeof d == "string" ? o[i] = d : o[i] = c(d, f, m);
|
|
4683
4703
|
}), (r.properties || []).forEach((i) => {
|
|
4684
4704
|
const d = i.name;
|
|
4685
|
-
d in
|
|
4705
|
+
d in o || (o[d] = i.defaultValue);
|
|
4686
4706
|
});
|
|
4687
4707
|
try {
|
|
4688
4708
|
typeof t == "function" && t?.(e, n, r);
|
|
@@ -4697,30 +4717,30 @@ function ba(e, r, t) {
|
|
|
4697
4717
|
};
|
|
4698
4718
|
}
|
|
4699
4719
|
}
|
|
4700
|
-
function
|
|
4720
|
+
function ro(e) {
|
|
4701
4721
|
const [r, t] = l.useState(null);
|
|
4702
4722
|
return l.useEffect(() => {
|
|
4703
4723
|
const n = document.querySelector("[data-reactaform-theme]");
|
|
4704
4724
|
if (!n) return;
|
|
4705
|
-
const
|
|
4706
|
-
if (!
|
|
4707
|
-
const
|
|
4708
|
-
|
|
4725
|
+
const o = n.closest("[data-reactaform-theme]");
|
|
4726
|
+
if (!o) return;
|
|
4727
|
+
const a = () => t(o.getAttribute("data-reactaform-theme"));
|
|
4728
|
+
a();
|
|
4709
4729
|
const c = new MutationObserver((s) => {
|
|
4710
4730
|
for (const i of s)
|
|
4711
|
-
i.type === "attributes" && i.attributeName === "data-reactaform-theme" &&
|
|
4731
|
+
i.type === "attributes" && i.attributeName === "data-reactaform-theme" && a();
|
|
4712
4732
|
});
|
|
4713
|
-
return c.observe(
|
|
4733
|
+
return c.observe(o, { attributes: !0, attributeFilter: ["data-reactaform-theme"] }), () => c.disconnect();
|
|
4714
4734
|
}, [e]), r;
|
|
4715
4735
|
}
|
|
4716
|
-
const
|
|
4736
|
+
const wo = ({
|
|
4717
4737
|
definitionData: e,
|
|
4718
4738
|
instance: r,
|
|
4719
4739
|
language: t,
|
|
4720
4740
|
className: n,
|
|
4721
|
-
theme:
|
|
4722
|
-
style:
|
|
4723
|
-
fieldValidationMode: c = "
|
|
4741
|
+
theme: o,
|
|
4742
|
+
style: a,
|
|
4743
|
+
fieldValidationMode: c = "onEdit",
|
|
4724
4744
|
displayInstanceName: s = !0,
|
|
4725
4745
|
onSubmit: i = void 0,
|
|
4726
4746
|
onValidation: d = void 0
|
|
@@ -4731,33 +4751,33 @@ const ya = ({
|
|
|
4731
4751
|
} catch {
|
|
4732
4752
|
return null;
|
|
4733
4753
|
}
|
|
4734
|
-
}, [e]), u = { fontSize: "inherit", fontFamily: "inherit", ...
|
|
4754
|
+
}, [e]), u = { fontSize: "inherit", fontFamily: "inherit", ...a }, f = ro(), b = o ?? f ?? "light", C = t ?? "en";
|
|
4735
4755
|
l.useEffect(() => {
|
|
4736
4756
|
let h = document.getElementById("popup-root");
|
|
4737
4757
|
h || (h = document.createElement("div"), h.id = "popup-root", document.body.appendChild(h));
|
|
4738
4758
|
}, []);
|
|
4739
|
-
const
|
|
4759
|
+
const N = l.useMemo(() => {
|
|
4740
4760
|
if (r) return r;
|
|
4741
4761
|
if (!m) return null;
|
|
4742
|
-
const h =
|
|
4762
|
+
const h = eo(m, m.name);
|
|
4743
4763
|
return !h.success || !h.instance ? null : h.instance;
|
|
4744
4764
|
}, [r, m]);
|
|
4745
|
-
return m ?
|
|
4746
|
-
|
|
4765
|
+
return m ? N ? /* @__PURE__ */ p(
|
|
4766
|
+
Zn,
|
|
4747
4767
|
{
|
|
4748
4768
|
definitionName: m.name,
|
|
4749
4769
|
defaultStyle: u,
|
|
4750
|
-
defaultLanguage:
|
|
4770
|
+
defaultLanguage: C,
|
|
4751
4771
|
defaultTheme: b,
|
|
4752
4772
|
defaultLocalizeName: m.localization || "",
|
|
4753
4773
|
className: n,
|
|
4754
4774
|
defaultFieldValidationMode: c,
|
|
4755
4775
|
defaultDisplayInstanceName: s,
|
|
4756
4776
|
children: /* @__PURE__ */ p(
|
|
4757
|
-
|
|
4777
|
+
hn,
|
|
4758
4778
|
{
|
|
4759
4779
|
definition: m,
|
|
4760
|
-
instance:
|
|
4780
|
+
instance: N,
|
|
4761
4781
|
onSubmit: i,
|
|
4762
4782
|
onValidation: d
|
|
4763
4783
|
}
|
|
@@ -4772,7 +4792,7 @@ const ya = ({
|
|
|
4772
4792
|
formValidators: /* @__PURE__ */ new Map(),
|
|
4773
4793
|
submissionHandlers: /* @__PURE__ */ new Map()
|
|
4774
4794
|
};
|
|
4775
|
-
function
|
|
4795
|
+
function rt(e, r, t) {
|
|
4776
4796
|
if (!e) return !0;
|
|
4777
4797
|
if (t && !t(e))
|
|
4778
4798
|
return !1;
|
|
@@ -4793,73 +4813,73 @@ function et(e, r, t) {
|
|
|
4793
4813
|
return !1;
|
|
4794
4814
|
}
|
|
4795
4815
|
}
|
|
4796
|
-
function
|
|
4816
|
+
function to(e) {
|
|
4797
4817
|
const r = [];
|
|
4798
4818
|
if (e.components)
|
|
4799
4819
|
for (const t of Object.keys(e.components)) {
|
|
4800
|
-
const n =
|
|
4820
|
+
const n = _r(t);
|
|
4801
4821
|
if (n) {
|
|
4802
|
-
let
|
|
4803
|
-
for (const [
|
|
4822
|
+
let o;
|
|
4823
|
+
for (const [a, c] of Z)
|
|
4804
4824
|
if (c.components && c.components[t] === n) {
|
|
4805
|
-
|
|
4825
|
+
o = a;
|
|
4806
4826
|
break;
|
|
4807
4827
|
}
|
|
4808
|
-
|
|
4828
|
+
o && o !== e.name && r.push({
|
|
4809
4829
|
type: "component",
|
|
4810
4830
|
name: t,
|
|
4811
|
-
existingPlugin:
|
|
4831
|
+
existingPlugin: o,
|
|
4812
4832
|
newPlugin: e.name
|
|
4813
4833
|
});
|
|
4814
4834
|
}
|
|
4815
4835
|
}
|
|
4816
4836
|
if (e.fieldCustomValidators)
|
|
4817
4837
|
for (const [t, n] of Object.entries(e.fieldCustomValidators))
|
|
4818
|
-
for (const
|
|
4819
|
-
const c = W.fieldValidators.get(t)?.get(
|
|
4820
|
-
ur(t,
|
|
4838
|
+
for (const o of Object.keys(n)) {
|
|
4839
|
+
const c = W.fieldValidators.get(t)?.get(o);
|
|
4840
|
+
ur(t, o) && c && c !== e.name && r.push({
|
|
4821
4841
|
type: "fieldCustomValidator",
|
|
4822
|
-
name: `${t}:${
|
|
4842
|
+
name: `${t}:${o}`,
|
|
4823
4843
|
existingPlugin: c,
|
|
4824
4844
|
newPlugin: e.name
|
|
4825
4845
|
});
|
|
4826
4846
|
}
|
|
4827
4847
|
if (e.fieldTypeValidators)
|
|
4828
4848
|
for (const t of Object.keys(e.fieldTypeValidators)) {
|
|
4829
|
-
const n = dr(t),
|
|
4830
|
-
n &&
|
|
4849
|
+
const n = dr(t), o = W.fieldTypeValidators.get(t);
|
|
4850
|
+
n && o && o !== e.name && r.push({
|
|
4831
4851
|
type: "fieldTypeValidator",
|
|
4832
4852
|
name: `type:${t}`,
|
|
4833
|
-
existingPlugin:
|
|
4853
|
+
existingPlugin: o,
|
|
4834
4854
|
newPlugin: e.name
|
|
4835
4855
|
});
|
|
4836
4856
|
}
|
|
4837
4857
|
if (e.formValidators)
|
|
4838
4858
|
for (const t of Object.keys(e.formValidators)) {
|
|
4839
|
-
const n = mr(t),
|
|
4840
|
-
n &&
|
|
4859
|
+
const n = mr(t), o = W.formValidators.get(t);
|
|
4860
|
+
n && o && o !== e.name && r.push({
|
|
4841
4861
|
type: "formValidator",
|
|
4842
4862
|
name: t,
|
|
4843
|
-
existingPlugin:
|
|
4863
|
+
existingPlugin: o,
|
|
4844
4864
|
newPlugin: e.name
|
|
4845
4865
|
});
|
|
4846
4866
|
}
|
|
4847
4867
|
if (e.submissionHandlers)
|
|
4848
4868
|
for (const t of Object.keys(e.submissionHandlers)) {
|
|
4849
|
-
const n =
|
|
4850
|
-
n &&
|
|
4869
|
+
const n = fn(t), o = W.submissionHandlers.get(t);
|
|
4870
|
+
n && o && o !== e.name && r.push({
|
|
4851
4871
|
type: "submissionHandler",
|
|
4852
4872
|
name: t,
|
|
4853
|
-
existingPlugin:
|
|
4873
|
+
existingPlugin: o,
|
|
4854
4874
|
newPlugin: e.name
|
|
4855
4875
|
});
|
|
4856
4876
|
}
|
|
4857
4877
|
return r;
|
|
4858
4878
|
}
|
|
4859
|
-
function
|
|
4879
|
+
function ae(e, r, t, n, o, a, c, s) {
|
|
4860
4880
|
for (const i of Object.keys(e)) {
|
|
4861
4881
|
let d;
|
|
4862
|
-
if (s ? d =
|
|
4882
|
+
if (s ? d = o.find((m) => m.type === "fieldCustomValidator" && m.name === `${s}:${i}`) : e === n.components ? d = o.find((m) => m.type === "component" && m.name === i) : e === n.formValidators ? d = o.find((m) => m.type === "formValidator" && m.name === i) : e === n.fieldTypeValidators ? d = o.find((m) => m.type === "fieldTypeValidator" && m.name === `type:${i}`) : e === n.submissionHandlers && (d = o.find((m) => m.type === "submissionHandler" && m.name === i)), rt(d || null, a, c))
|
|
4863
4883
|
if (s) {
|
|
4864
4884
|
const m = r.get(s) || /* @__PURE__ */ new Map();
|
|
4865
4885
|
m.set(i, n.name), r.set(s, m), t(i, e[i]);
|
|
@@ -4870,65 +4890,65 @@ function oe(e, r, t, n, a, o, c, s) {
|
|
|
4870
4890
|
) : r.set(i, n.name), t(i, e[i]);
|
|
4871
4891
|
}
|
|
4872
4892
|
}
|
|
4873
|
-
function
|
|
4893
|
+
function So(e, r) {
|
|
4874
4894
|
const t = r?.conflictResolution || "error";
|
|
4875
4895
|
if (Z.has(e.name)) {
|
|
4876
|
-
const
|
|
4896
|
+
const o = {
|
|
4877
4897
|
type: "plugin",
|
|
4878
4898
|
name: e.name,
|
|
4879
4899
|
existingPlugin: e.name,
|
|
4880
4900
|
newPlugin: e.name
|
|
4881
4901
|
};
|
|
4882
|
-
if (!
|
|
4902
|
+
if (!rt(o, t, r?.onConflict)) return;
|
|
4883
4903
|
}
|
|
4884
|
-
const n =
|
|
4885
|
-
if (e.components &&
|
|
4904
|
+
const n = to(e);
|
|
4905
|
+
if (e.components && ae(
|
|
4886
4906
|
e.components,
|
|
4887
4907
|
W.components,
|
|
4888
|
-
|
|
4908
|
+
Wr,
|
|
4889
4909
|
e,
|
|
4890
4910
|
n,
|
|
4891
4911
|
t,
|
|
4892
4912
|
r?.onConflict
|
|
4893
4913
|
), e.fieldCustomValidators)
|
|
4894
|
-
for (const [
|
|
4895
|
-
|
|
4896
|
-
|
|
4914
|
+
for (const [o, a] of Object.entries(e.fieldCustomValidators))
|
|
4915
|
+
ae(
|
|
4916
|
+
a,
|
|
4897
4917
|
W.fieldValidators,
|
|
4898
|
-
(c, s) =>
|
|
4918
|
+
(c, s) => gt(o, c, s),
|
|
4899
4919
|
e,
|
|
4900
4920
|
n,
|
|
4901
4921
|
t,
|
|
4902
4922
|
r?.onConflict,
|
|
4903
|
-
|
|
4923
|
+
o
|
|
4904
4924
|
);
|
|
4905
|
-
e.formValidators &&
|
|
4925
|
+
e.formValidators && ae(
|
|
4906
4926
|
e.formValidators,
|
|
4907
4927
|
W.formValidators,
|
|
4908
|
-
|
|
4928
|
+
pt,
|
|
4909
4929
|
e,
|
|
4910
4930
|
n,
|
|
4911
4931
|
t,
|
|
4912
4932
|
r?.onConflict
|
|
4913
|
-
), e.fieldTypeValidators &&
|
|
4933
|
+
), e.fieldTypeValidators && ae(
|
|
4914
4934
|
e.fieldTypeValidators,
|
|
4915
4935
|
W.fieldTypeValidators,
|
|
4916
|
-
|
|
4936
|
+
ht,
|
|
4917
4937
|
e,
|
|
4918
4938
|
n,
|
|
4919
4939
|
t,
|
|
4920
4940
|
r?.onConflict
|
|
4921
|
-
), e.submissionHandlers &&
|
|
4941
|
+
), e.submissionHandlers && ae(
|
|
4922
4942
|
e.submissionHandlers,
|
|
4923
4943
|
W.submissionHandlers,
|
|
4924
|
-
|
|
4944
|
+
Jr,
|
|
4925
4945
|
e,
|
|
4926
4946
|
n,
|
|
4927
4947
|
t,
|
|
4928
4948
|
r?.onConflict
|
|
4929
4949
|
), e.setup && e.setup(), Z.set(e.name, e);
|
|
4930
4950
|
}
|
|
4931
|
-
function
|
|
4951
|
+
function Co(e, r = !1) {
|
|
4932
4952
|
const t = Z.get(e);
|
|
4933
4953
|
if (!t) return !1;
|
|
4934
4954
|
if (t.cleanup && t.cleanup(), r) {
|
|
@@ -4936,12 +4956,12 @@ function xa(e, r = !1) {
|
|
|
4936
4956
|
for (const n of Object.keys(t.components))
|
|
4937
4957
|
W.components.delete(n);
|
|
4938
4958
|
if (t.fieldCustomValidators)
|
|
4939
|
-
for (const [n,
|
|
4940
|
-
const
|
|
4941
|
-
if (
|
|
4942
|
-
for (const c of Object.keys(
|
|
4943
|
-
|
|
4944
|
-
|
|
4959
|
+
for (const [n, o] of Object.entries(t.fieldCustomValidators)) {
|
|
4960
|
+
const a = W.fieldValidators.get(n);
|
|
4961
|
+
if (a) {
|
|
4962
|
+
for (const c of Object.keys(o))
|
|
4963
|
+
a.delete(c);
|
|
4964
|
+
a.size === 0 && W.fieldValidators.delete(n);
|
|
4945
4965
|
}
|
|
4946
4966
|
}
|
|
4947
4967
|
if (t.formValidators)
|
|
@@ -4956,18 +4976,18 @@ function xa(e, r = !1) {
|
|
|
4956
4976
|
}
|
|
4957
4977
|
return Z.delete(e), !0;
|
|
4958
4978
|
}
|
|
4959
|
-
function
|
|
4979
|
+
function No(e) {
|
|
4960
4980
|
return Z.get(e);
|
|
4961
4981
|
}
|
|
4962
|
-
function
|
|
4982
|
+
function ko() {
|
|
4963
4983
|
return Array.from(Z.values());
|
|
4964
4984
|
}
|
|
4965
|
-
function
|
|
4985
|
+
function Io(e) {
|
|
4966
4986
|
return Z.has(e);
|
|
4967
4987
|
}
|
|
4968
|
-
function
|
|
4988
|
+
function Eo(e) {
|
|
4969
4989
|
for (const [r, t] of Object.entries(e))
|
|
4970
|
-
|
|
4990
|
+
Wr(r, t);
|
|
4971
4991
|
}
|
|
4972
4992
|
function ee(e) {
|
|
4973
4993
|
return typeof e == "object" && e !== null;
|
|
@@ -4977,7 +4997,7 @@ function Te(e) {
|
|
|
4977
4997
|
const r = e;
|
|
4978
4998
|
return typeof r.name == "string" && typeof r.displayName == "string";
|
|
4979
4999
|
}
|
|
4980
|
-
function
|
|
5000
|
+
function tt(e) {
|
|
4981
5001
|
if (!ee(e)) return !1;
|
|
4982
5002
|
const r = e;
|
|
4983
5003
|
return typeof r.name != "string" || typeof r.version != "string" || !Array.isArray(r.properties) ? !1 : r.properties.every((t) => Te(t));
|
|
@@ -4990,12 +5010,12 @@ function Ce(e) {
|
|
|
4990
5010
|
return !!r && typeof r.name == "string" && typeof r.size == "number";
|
|
4991
5011
|
}
|
|
4992
5012
|
}
|
|
4993
|
-
function
|
|
5013
|
+
function Mo(e, r, t = {}) {
|
|
4994
5014
|
try {
|
|
4995
5015
|
const {
|
|
4996
5016
|
includeMetadata: n = !1,
|
|
4997
|
-
dateFormat:
|
|
4998
|
-
fileHandling:
|
|
5017
|
+
dateFormat: o = "iso",
|
|
5018
|
+
fileHandling: a = "metadata",
|
|
4999
5019
|
prettify: c = !1,
|
|
5000
5020
|
excludeFields: s = [],
|
|
5001
5021
|
includeOnlyFields: i = []
|
|
@@ -5005,7 +5025,7 @@ function ka(e, r, t = {}) {
|
|
|
5005
5025
|
success: !1,
|
|
5006
5026
|
error: "Instance must be a valid object"
|
|
5007
5027
|
};
|
|
5008
|
-
const d = [], m = [], u = {}, b = (
|
|
5028
|
+
const d = [], m = [], u = {}, b = (tt(r) || ee(r) && Array.isArray(r.properties) ? r.properties : []).filter(Te), C = new Map(b.map((h) => [h.name, h]));
|
|
5009
5029
|
for (const [h, y] of Object.entries(e)) {
|
|
5010
5030
|
if (s.includes(h)) {
|
|
5011
5031
|
m.push(h);
|
|
@@ -5016,9 +5036,9 @@ function ka(e, r, t = {}) {
|
|
|
5016
5036
|
continue;
|
|
5017
5037
|
}
|
|
5018
5038
|
if (y === void 0) continue;
|
|
5019
|
-
const E =
|
|
5039
|
+
const E = C.get(h);
|
|
5020
5040
|
try {
|
|
5021
|
-
u[h] =
|
|
5041
|
+
u[h] = no(y, E, { dateFormat: o, fileHandling: a });
|
|
5022
5042
|
} catch (F) {
|
|
5023
5043
|
d.push(`Error serializing field '${h}': ${String(F)}`), u[h] = null;
|
|
5024
5044
|
}
|
|
@@ -5044,8 +5064,8 @@ function ka(e, r, t = {}) {
|
|
|
5044
5064
|
};
|
|
5045
5065
|
}
|
|
5046
5066
|
}
|
|
5047
|
-
function
|
|
5048
|
-
const { dateFormat: n = "iso", fileHandling:
|
|
5067
|
+
function no(e, r, t = {}) {
|
|
5068
|
+
const { dateFormat: n = "iso", fileHandling: o = "metadata" } = t;
|
|
5049
5069
|
if (e == null)
|
|
5050
5070
|
return null;
|
|
5051
5071
|
if (r)
|
|
@@ -5055,7 +5075,7 @@ function ra(e, r, t = {}) {
|
|
|
5055
5075
|
case "date-time":
|
|
5056
5076
|
return er(e, n);
|
|
5057
5077
|
case "file":
|
|
5058
|
-
return rr(e,
|
|
5078
|
+
return rr(e, o);
|
|
5059
5079
|
case "int":
|
|
5060
5080
|
case "integer":
|
|
5061
5081
|
return typeof e == "string" ? parseInt(e, 10) : e;
|
|
@@ -5066,11 +5086,11 @@ function ra(e, r, t = {}) {
|
|
|
5066
5086
|
return typeof e == "string" ? e === "true" : !!e;
|
|
5067
5087
|
case "int-array":
|
|
5068
5088
|
case "float-array":
|
|
5069
|
-
return Array.isArray(e) ? e.map((
|
|
5089
|
+
return Array.isArray(e) ? e.map((a) => typeof a == "string" ? Number(a) : a) : e;
|
|
5070
5090
|
default:
|
|
5071
5091
|
return e;
|
|
5072
5092
|
}
|
|
5073
|
-
return e instanceof Date ? er(e, n) : Ce(e) || Array.isArray(e) && Ce(e[0]) ? rr(e,
|
|
5093
|
+
return e instanceof Date ? er(e, n) : Ce(e) || Array.isArray(e) && Ce(e[0]) ? rr(e, o) : e;
|
|
5074
5094
|
}
|
|
5075
5095
|
function er(e, r) {
|
|
5076
5096
|
let t = null;
|
|
@@ -5114,12 +5134,12 @@ function tr(e, r) {
|
|
|
5114
5134
|
_note: "Base64 encoding requires async implementation"
|
|
5115
5135
|
};
|
|
5116
5136
|
}
|
|
5117
|
-
function
|
|
5137
|
+
function Fo(e, r, t = {}) {
|
|
5118
5138
|
try {
|
|
5119
5139
|
const {
|
|
5120
5140
|
strict: n = !1,
|
|
5121
|
-
validateTypes:
|
|
5122
|
-
preserveUnknownFields:
|
|
5141
|
+
validateTypes: o = !0,
|
|
5142
|
+
preserveUnknownFields: a = !0,
|
|
5123
5143
|
dateFormat: c = "auto"
|
|
5124
5144
|
} = t;
|
|
5125
5145
|
if (!e || typeof e != "string")
|
|
@@ -5130,10 +5150,10 @@ function Ia(e, r, t = {}) {
|
|
|
5130
5150
|
let s;
|
|
5131
5151
|
try {
|
|
5132
5152
|
s = JSON.parse(e);
|
|
5133
|
-
} catch (
|
|
5153
|
+
} catch (N) {
|
|
5134
5154
|
return {
|
|
5135
5155
|
success: !1,
|
|
5136
|
-
error: `Invalid JSON: ${
|
|
5156
|
+
error: `Invalid JSON: ${N instanceof Error ? N.message : "Unknown parsing error"}`
|
|
5137
5157
|
};
|
|
5138
5158
|
}
|
|
5139
5159
|
if (!s || typeof s != "object")
|
|
@@ -5141,29 +5161,29 @@ function Ia(e, r, t = {}) {
|
|
|
5141
5161
|
success: !1,
|
|
5142
5162
|
error: "Parsed data must be an object"
|
|
5143
5163
|
};
|
|
5144
|
-
const i = [], d = [], m = {}, f = (
|
|
5145
|
-
for (const
|
|
5146
|
-
const h =
|
|
5164
|
+
const i = [], d = [], m = {}, f = (tt(r) || ee(r) && Array.isArray(r.properties) ? r.properties : []).filter(Te), b = new Map(f.map((N) => [N.name, N]));
|
|
5165
|
+
for (const N of f) {
|
|
5166
|
+
const h = N.name, y = s[h];
|
|
5147
5167
|
if (y === void 0) {
|
|
5148
|
-
n &&
|
|
5168
|
+
n && N.required && d.push(`Required field '${h}' is missing`);
|
|
5149
5169
|
continue;
|
|
5150
5170
|
}
|
|
5151
5171
|
try {
|
|
5152
|
-
m[h] =
|
|
5172
|
+
m[h] = oo(y, N, { validateTypes: o, dateFormat: c });
|
|
5153
5173
|
} catch (E) {
|
|
5154
5174
|
const F = `Error deserializing field '${h}': ${String(E)}`;
|
|
5155
5175
|
n ? d.push(F) : (i.push(F), m[h] = y);
|
|
5156
5176
|
}
|
|
5157
5177
|
}
|
|
5158
|
-
if (
|
|
5159
|
-
for (const [
|
|
5160
|
-
!b.has(
|
|
5161
|
-
const
|
|
5178
|
+
if (a)
|
|
5179
|
+
for (const [N, h] of Object.entries(s))
|
|
5180
|
+
!b.has(N) && N !== "_metadata" && (n && i.push(`Unknown field '${N}' preserved`), m[N] = h);
|
|
5181
|
+
const C = d.length > 0;
|
|
5162
5182
|
return {
|
|
5163
|
-
success: !
|
|
5183
|
+
success: !C,
|
|
5164
5184
|
data: m,
|
|
5165
5185
|
warnings: i.length > 0 ? i : void 0,
|
|
5166
|
-
validationErrors:
|
|
5186
|
+
validationErrors: C ? d : void 0
|
|
5167
5187
|
};
|
|
5168
5188
|
} catch (n) {
|
|
5169
5189
|
return {
|
|
@@ -5172,8 +5192,8 @@ function Ia(e, r, t = {}) {
|
|
|
5172
5192
|
};
|
|
5173
5193
|
}
|
|
5174
5194
|
}
|
|
5175
|
-
function
|
|
5176
|
-
const { validateTypes: n = !0, dateFormat:
|
|
5195
|
+
function oo(e, r, t = {}) {
|
|
5196
|
+
const { validateTypes: n = !0, dateFormat: o = "auto" } = t;
|
|
5177
5197
|
if (e == null)
|
|
5178
5198
|
return e;
|
|
5179
5199
|
try {
|
|
@@ -5181,7 +5201,7 @@ function ta(e, r, t = {}) {
|
|
|
5181
5201
|
case "date":
|
|
5182
5202
|
case "datetime":
|
|
5183
5203
|
case "date-time":
|
|
5184
|
-
return
|
|
5204
|
+
return ao(e, o, n);
|
|
5185
5205
|
case "int":
|
|
5186
5206
|
case "integer":
|
|
5187
5207
|
return Ne(e, n);
|
|
@@ -5189,7 +5209,7 @@ function ta(e, r, t = {}) {
|
|
|
5189
5209
|
case "number":
|
|
5190
5210
|
return ke(e, n);
|
|
5191
5211
|
case "boolean":
|
|
5192
|
-
return
|
|
5212
|
+
return io(e, n);
|
|
5193
5213
|
case "int-array":
|
|
5194
5214
|
return nr(e, "integer", n);
|
|
5195
5215
|
case "float-array":
|
|
@@ -5203,13 +5223,13 @@ function ta(e, r, t = {}) {
|
|
|
5203
5223
|
default:
|
|
5204
5224
|
return e;
|
|
5205
5225
|
}
|
|
5206
|
-
} catch (
|
|
5226
|
+
} catch (a) {
|
|
5207
5227
|
if (n)
|
|
5208
|
-
throw new Error(`Type conversion failed: ${String(
|
|
5228
|
+
throw new Error(`Type conversion failed: ${String(a)}`);
|
|
5209
5229
|
return e;
|
|
5210
5230
|
}
|
|
5211
5231
|
}
|
|
5212
|
-
function
|
|
5232
|
+
function $o(e, r = {}) {
|
|
5213
5233
|
try {
|
|
5214
5234
|
const { prettify: t = !0, includeMetadata: n = !0 } = r;
|
|
5215
5235
|
if (!e || typeof e != "object")
|
|
@@ -5217,16 +5237,16 @@ function Ea(e, r = {}) {
|
|
|
5217
5237
|
success: !1,
|
|
5218
5238
|
error: "Definition must be a valid object"
|
|
5219
5239
|
};
|
|
5220
|
-
const
|
|
5221
|
-
return n && (
|
|
5240
|
+
const o = { ...e };
|
|
5241
|
+
return n && (o._metadata = {
|
|
5222
5242
|
serializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5223
|
-
version:
|
|
5224
|
-
propertyCount: (Array.isArray(
|
|
5243
|
+
version: o.version || "1.0.0",
|
|
5244
|
+
propertyCount: (Array.isArray(o.properties) ? o.properties.length : 0) || 0
|
|
5225
5245
|
}), {
|
|
5226
5246
|
success: !0,
|
|
5227
|
-
data: t ? JSON.stringify(
|
|
5247
|
+
data: t ? JSON.stringify(o, null, 2) : JSON.stringify(o),
|
|
5228
5248
|
metadata: {
|
|
5229
|
-
fieldCount: (Array.isArray(
|
|
5249
|
+
fieldCount: (Array.isArray(o.properties) ? o.properties.length : 0) || 0,
|
|
5230
5250
|
excludedFields: [],
|
|
5231
5251
|
warnings: []
|
|
5232
5252
|
}
|
|
@@ -5238,13 +5258,13 @@ function Ea(e, r = {}) {
|
|
|
5238
5258
|
};
|
|
5239
5259
|
}
|
|
5240
5260
|
}
|
|
5241
|
-
function
|
|
5261
|
+
function Vo(e, r = {}) {
|
|
5242
5262
|
try {
|
|
5243
5263
|
const { strict: t = !1, validateTypes: n = !0 } = r;
|
|
5244
|
-
let
|
|
5264
|
+
let o;
|
|
5245
5265
|
if (typeof e == "string")
|
|
5246
5266
|
try {
|
|
5247
|
-
|
|
5267
|
+
o = JSON.parse(e);
|
|
5248
5268
|
} catch (m) {
|
|
5249
5269
|
return {
|
|
5250
5270
|
success: !1,
|
|
@@ -5252,43 +5272,43 @@ function Ma(e, r = {}) {
|
|
|
5252
5272
|
};
|
|
5253
5273
|
}
|
|
5254
5274
|
else if (e && typeof e == "object")
|
|
5255
|
-
|
|
5275
|
+
o = { ...e };
|
|
5256
5276
|
else
|
|
5257
5277
|
return {
|
|
5258
5278
|
success: !1,
|
|
5259
5279
|
error: "Input must be a string or object"
|
|
5260
5280
|
};
|
|
5261
|
-
const
|
|
5281
|
+
const a = [], c = [], s = ["name", "version", "displayName"];
|
|
5262
5282
|
for (const m of s)
|
|
5263
|
-
if (!(m in
|
|
5283
|
+
if (!(m in o) || !o[m])
|
|
5264
5284
|
if (t)
|
|
5265
5285
|
c.push(`Required field '${m}' is missing`);
|
|
5266
5286
|
else
|
|
5267
|
-
switch (
|
|
5287
|
+
switch (a.push(`Missing field '${m}', using default`), m) {
|
|
5268
5288
|
case "name":
|
|
5269
|
-
|
|
5289
|
+
o.name = "unnamed-definition";
|
|
5270
5290
|
break;
|
|
5271
5291
|
case "version":
|
|
5272
|
-
|
|
5292
|
+
o.version = "1.0.0";
|
|
5273
5293
|
break;
|
|
5274
5294
|
case "displayName":
|
|
5275
|
-
|
|
5295
|
+
o.displayName = o.name || "Unnamed Definition";
|
|
5276
5296
|
break;
|
|
5277
5297
|
}
|
|
5278
|
-
const i = Array.isArray(
|
|
5279
|
-
i ?
|
|
5298
|
+
const i = Array.isArray(o.properties) ? o.properties : null;
|
|
5299
|
+
i ? o.properties = i.map((m, u) => {
|
|
5280
5300
|
const f = ee(m) ? m : {}, b = { ...f };
|
|
5281
5301
|
if (!f.name) {
|
|
5282
|
-
const
|
|
5283
|
-
t ? c.push(
|
|
5302
|
+
const C = `Property at index ${u} missing 'name'`;
|
|
5303
|
+
t ? c.push(C) : (a.push(`${C}, using 'field_${u}'`), b.name = `field_${u}`);
|
|
5284
5304
|
}
|
|
5285
|
-
return f.displayName || (b.displayName = f.name || `Field ${u}`), f.type || (t && n ? c.push(`Property '${f.name || u}' missing 'type'`) : (
|
|
5286
|
-
}) : t ? c.push("Properties must be an array") : (
|
|
5305
|
+
return f.displayName || (b.displayName = f.name || `Field ${u}`), f.type || (t && n ? c.push(`Property '${f.name || u}' missing 'type'`) : (a.push(`Property '${f.name || u}' missing 'type', using 'string'`), b.type = "string")), f.defaultValue === void 0 && (b.defaultValue = null), f.required === void 0 && (b.required = !1), b;
|
|
5306
|
+
}) : t ? c.push("Properties must be an array") : (a.push("Properties not found or invalid, using empty array"), o.properties = []);
|
|
5287
5307
|
const d = c.length > 0;
|
|
5288
5308
|
return {
|
|
5289
5309
|
success: !d,
|
|
5290
|
-
data:
|
|
5291
|
-
warnings:
|
|
5310
|
+
data: o,
|
|
5311
|
+
warnings: a.length > 0 ? a : void 0,
|
|
5292
5312
|
validationErrors: d ? c : void 0
|
|
5293
5313
|
};
|
|
5294
5314
|
} catch (t) {
|
|
@@ -5298,7 +5318,7 @@ function Ma(e, r = {}) {
|
|
|
5298
5318
|
};
|
|
5299
5319
|
}
|
|
5300
5320
|
}
|
|
5301
|
-
function
|
|
5321
|
+
function ao(e, r, t) {
|
|
5302
5322
|
if (e instanceof Date)
|
|
5303
5323
|
return e;
|
|
5304
5324
|
if (typeof e == "number") {
|
|
@@ -5363,7 +5383,7 @@ function ke(e, r) {
|
|
|
5363
5383
|
throw new Error(`Cannot convert ${typeof e} to number`);
|
|
5364
5384
|
return e;
|
|
5365
5385
|
}
|
|
5366
|
-
function
|
|
5386
|
+
function io(e, r) {
|
|
5367
5387
|
if (typeof e == "boolean")
|
|
5368
5388
|
return e;
|
|
5369
5389
|
if (typeof e == "string") {
|
|
@@ -5382,70 +5402,70 @@ function aa(e, r) {
|
|
|
5382
5402
|
function nr(e, r, t) {
|
|
5383
5403
|
if (!Array.isArray(e)) {
|
|
5384
5404
|
if (typeof e == "string")
|
|
5385
|
-
return e.split(",").map((
|
|
5405
|
+
return e.split(",").map((o) => o.trim()).filter(Boolean).map((o) => r === "integer" ? Ne(o, t) : ke(o, t));
|
|
5386
5406
|
if (t)
|
|
5387
5407
|
throw new Error(`Expected array, got ${typeof e}`);
|
|
5388
5408
|
return e;
|
|
5389
5409
|
}
|
|
5390
|
-
return e.map((n,
|
|
5410
|
+
return e.map((n, o) => {
|
|
5391
5411
|
try {
|
|
5392
5412
|
return r === "integer" ? Ne(n, t) : ke(n, t);
|
|
5393
|
-
} catch (
|
|
5413
|
+
} catch (a) {
|
|
5394
5414
|
if (t)
|
|
5395
|
-
throw new Error(`Array element ${
|
|
5415
|
+
throw new Error(`Array element ${o}: ${a}`);
|
|
5396
5416
|
return n;
|
|
5397
5417
|
}
|
|
5398
5418
|
});
|
|
5399
5419
|
}
|
|
5400
|
-
function
|
|
5420
|
+
function so() {
|
|
5401
5421
|
if (!document.getElementById("reactaform-styles"))
|
|
5402
5422
|
try {
|
|
5403
5423
|
const e = document.createElement("style");
|
|
5404
|
-
e.id = "reactaform-styles", e.textContent =
|
|
5424
|
+
e.id = "reactaform-styles", e.textContent = ct, document.head.appendChild(e);
|
|
5405
5425
|
} catch {
|
|
5406
5426
|
}
|
|
5407
5427
|
}
|
|
5408
|
-
typeof document < "u" &&
|
|
5428
|
+
typeof document < "u" && so();
|
|
5409
5429
|
export {
|
|
5410
5430
|
V as CSS_CLASSES,
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5431
|
+
wo as ReactaForm,
|
|
5432
|
+
Zn as ReactaFormProvider,
|
|
5433
|
+
hn as ReactaFormRenderer,
|
|
5414
5434
|
O as StandardFieldLayout,
|
|
5415
|
-
|
|
5435
|
+
mo as Units,
|
|
5416
5436
|
U as combineClasses,
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5437
|
+
eo as createInstanceFromDefinition,
|
|
5438
|
+
Vo as deserializeDefinition,
|
|
5439
|
+
Fo as deserializeInstance,
|
|
5440
|
+
ko as getAllPlugins,
|
|
5441
|
+
rn as getButtonHandler,
|
|
5442
|
+
_r as getComponent,
|
|
5443
|
+
No as getPlugin,
|
|
5444
|
+
bo as getSupportedLanguages,
|
|
5445
|
+
po as hasButtonHandler,
|
|
5446
|
+
Io as hasPlugin,
|
|
5447
|
+
so as injectReactaFormStyles,
|
|
5428
5448
|
ie as isDarkTheme,
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5449
|
+
ho as listButtonHandlers,
|
|
5450
|
+
vo as loadInstance,
|
|
5451
|
+
yo as loadJsonDefinition,
|
|
5452
|
+
fo as registerButtonHandler,
|
|
5453
|
+
Wr as registerComponent,
|
|
5454
|
+
Eo as registerComponents,
|
|
5455
|
+
gt as registerFieldCustomValidationHandler,
|
|
5456
|
+
ht as registerFieldTypeValidationHandler,
|
|
5457
|
+
pt as registerFormValidationHandler,
|
|
5458
|
+
So as registerPlugin,
|
|
5459
|
+
Jr as registerSubmissionHandler,
|
|
5460
|
+
$o as serializeDefinition,
|
|
5461
|
+
Mo as serializeInstance,
|
|
5462
|
+
go as unregisterButtonHandler,
|
|
5463
|
+
Co as unregisterPlugin,
|
|
5464
|
+
xo as upgradeInstanceToLatestDefinition,
|
|
5465
|
+
lt as useDebouncedCallback,
|
|
5446
5466
|
T as useFieldValidator,
|
|
5447
|
-
|
|
5467
|
+
B as useReactaFormContext,
|
|
5448
5468
|
_ as useUncontrolledValidatedInput,
|
|
5449
|
-
|
|
5469
|
+
uo as validateFieldValue,
|
|
5450
5470
|
fr as validateFieldWithCustomHandler
|
|
5451
5471
|
};
|