reactaform 1.8.4 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/reactaform.cjs.js +3 -3
- package/dist/reactaform.es.js +449 -448
- package/package.json +1 -1
package/dist/reactaform.es.js
CHANGED
|
@@ -433,17 +433,17 @@ const Hr = () => /* @__PURE__ */ A(
|
|
|
433
433
|
]
|
|
434
434
|
}
|
|
435
435
|
), Br = ({ content: e, size: r = "medium", animation: t = !0 }) => {
|
|
436
|
-
const { t: n, theme: a, formStyle: o, fieldStyle: c } = j(), [i, s] = u.useState(!1), [m, l] = u.useState({ x: 0, y: 0 }), [f, d] = u.useState(!1), g = u.useRef(null),
|
|
436
|
+
const { t: n, theme: a, formStyle: o, fieldStyle: c } = j(), [i, s] = u.useState(!1), [m, l] = u.useState({ x: 0, y: 0 }), [f, d] = u.useState(!1), g = u.useRef(null), S = u.useRef(null), I = u.useRef(null), b = u.useId(), v = fe(a), [F, $] = u.useState(void 0);
|
|
437
437
|
u.useLayoutEffect(() => {
|
|
438
438
|
if (!g.current) return;
|
|
439
|
-
const
|
|
439
|
+
const x = "rgba(255,255,255,0.1)", y = getComputedStyle(g.current).getPropertyValue("--reactaform-primary-bg").trim();
|
|
440
440
|
if (y && typeof CSS < "u" && CSS.supports?.("color: color-mix(in srgb, red, blue)")) {
|
|
441
441
|
const C = jr(y) ? "black" : "white";
|
|
442
442
|
$(`color-mix(in srgb, var(--reactaform-primary-bg) 85%, ${C} 15%)`);
|
|
443
443
|
} else
|
|
444
|
-
$(
|
|
444
|
+
$(x);
|
|
445
445
|
}, []);
|
|
446
|
-
const
|
|
446
|
+
const V = u.useMemo(() => {
|
|
447
447
|
const h = {
|
|
448
448
|
icon: {
|
|
449
449
|
display: "inline-flex",
|
|
@@ -454,7 +454,7 @@ const Hr = () => /* @__PURE__ */ A(
|
|
|
454
454
|
fontSize: "0.9em",
|
|
455
455
|
fontWeight: "bold",
|
|
456
456
|
borderRadius: "50%",
|
|
457
|
-
backgroundColor:
|
|
457
|
+
backgroundColor: F ?? (v ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.1)"),
|
|
458
458
|
color: `var(--reactaform-text-color, ${v ? "#f0f0f0" : "#333"})`,
|
|
459
459
|
border: `1px solid ${v ? "rgba(255,255,255,0.2)" : "rgba(0,0,0,0.1)"}`,
|
|
460
460
|
cursor: "pointer",
|
|
@@ -488,26 +488,26 @@ const Hr = () => /* @__PURE__ */ A(
|
|
|
488
488
|
opacity: 1,
|
|
489
489
|
pointerEvents: "auto"
|
|
490
490
|
}
|
|
491
|
-
}, y = (
|
|
492
|
-
const H =
|
|
493
|
-
return (
|
|
491
|
+
}, y = (k, E, N) => {
|
|
492
|
+
const H = k?.[E];
|
|
493
|
+
return (N && H ? H[N] : void 0) ?? {};
|
|
494
494
|
};
|
|
495
495
|
return {
|
|
496
496
|
icon: { ...h.icon, ...y(o, "tooltip", "icon"), ...y(c, "tooltip", "icon") },
|
|
497
497
|
text: { ...h.text, ...y(o, "tooltip", "text"), ...y(c, "tooltip", "text") },
|
|
498
498
|
textVisible: h.textVisible
|
|
499
499
|
};
|
|
500
|
-
}, [v, r, t, o, c,
|
|
500
|
+
}, [v, r, t, o, c, F]);
|
|
501
501
|
u.useLayoutEffect(() => {
|
|
502
|
-
if (!i || !g.current || !
|
|
502
|
+
if (!i || !g.current || !S.current) {
|
|
503
503
|
d(!1);
|
|
504
504
|
return;
|
|
505
505
|
}
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
const h =
|
|
509
|
-
let
|
|
510
|
-
|
|
506
|
+
const x = g.current.getBoundingClientRect();
|
|
507
|
+
I.current = x;
|
|
508
|
+
const h = S.current.getBoundingClientRect(), y = 8, C = window.innerWidth, k = window.innerHeight, E = -4;
|
|
509
|
+
let N = x.right + y, P = x.top + x.height / 2 - h.height / 2 + E;
|
|
510
|
+
N + h.width > C - y && (N = x.left - y - h.width), N = Math.max(y, Math.min(N, C - h.width - y)), P = Math.max(y, Math.min(P, k - h.height - y)), l({ x: N, y: P }), d(!0);
|
|
511
511
|
const H = g.current.closest("[data-reactaform-theme]"), Y = document.getElementById("popup-root");
|
|
512
512
|
if (H && Y) {
|
|
513
513
|
const ne = getComputedStyle(H);
|
|
@@ -520,18 +520,18 @@ const Hr = () => /* @__PURE__ */ A(
|
|
|
520
520
|
);
|
|
521
521
|
}
|
|
522
522
|
}, [i]);
|
|
523
|
-
const
|
|
523
|
+
const w = typeof document < "u" ? document.getElementById("popup-root") : null, M = /* @__PURE__ */ p(
|
|
524
524
|
"div",
|
|
525
525
|
{
|
|
526
|
-
ref:
|
|
527
|
-
"data-tooltip-id":
|
|
526
|
+
ref: S,
|
|
527
|
+
"data-tooltip-id": b,
|
|
528
528
|
style: {
|
|
529
|
-
...
|
|
529
|
+
...V.text,
|
|
530
530
|
transform: f ? "translateY(0) scale(1)" : "translateY(-4px) scale(0.98)",
|
|
531
531
|
transition: "opacity 120ms ease, transform 120ms ease, visibility 120ms ease",
|
|
532
532
|
width: 240,
|
|
533
533
|
// When positioned is true, apply the visible styles
|
|
534
|
-
...f ?
|
|
534
|
+
...f ? V.textVisible : {},
|
|
535
535
|
top: m.y,
|
|
536
536
|
left: m.x
|
|
537
537
|
},
|
|
@@ -544,16 +544,16 @@ const Hr = () => /* @__PURE__ */ A(
|
|
|
544
544
|
{
|
|
545
545
|
"data-testid": "tooltip-icon",
|
|
546
546
|
ref: g,
|
|
547
|
-
"aria-describedby": i ?
|
|
547
|
+
"aria-describedby": i ? b : void 0,
|
|
548
548
|
onMouseEnter: () => s(!0),
|
|
549
549
|
onMouseLeave: () => s(!1),
|
|
550
550
|
style: {
|
|
551
|
-
...
|
|
551
|
+
...V.icon
|
|
552
552
|
},
|
|
553
553
|
children: /* @__PURE__ */ p(Hr, {})
|
|
554
554
|
}
|
|
555
555
|
),
|
|
556
|
-
i && (
|
|
556
|
+
i && (w ? me.createPortal(M, w) : M)
|
|
557
557
|
] });
|
|
558
558
|
}, tr = u.memo(Br), ve = u.memo(({
|
|
559
559
|
field: e,
|
|
@@ -927,25 +927,25 @@ const qe = [
|
|
|
927
927
|
d(i);
|
|
928
928
|
}, [i]);
|
|
929
929
|
const g = u.useCallback(
|
|
930
|
-
(
|
|
931
|
-
const
|
|
932
|
-
d(
|
|
933
|
-
target: { value:
|
|
930
|
+
(V) => {
|
|
931
|
+
const w = he(V.target.value);
|
|
932
|
+
d(w), l({
|
|
933
|
+
target: { value: w }
|
|
934
934
|
});
|
|
935
935
|
},
|
|
936
936
|
[l]
|
|
937
|
-
),
|
|
938
|
-
(
|
|
939
|
-
const
|
|
940
|
-
d(
|
|
941
|
-
target: { value:
|
|
937
|
+
), S = u.useCallback(
|
|
938
|
+
(V) => {
|
|
939
|
+
const w = he(V.target.value);
|
|
940
|
+
d(w), l({
|
|
941
|
+
target: { value: w }
|
|
942
942
|
});
|
|
943
943
|
},
|
|
944
944
|
[l]
|
|
945
|
-
),
|
|
946
|
-
() => new Set(qe.map((
|
|
945
|
+
), b = u.useMemo(
|
|
946
|
+
() => new Set(qe.map((V) => V.value)),
|
|
947
947
|
[]
|
|
948
|
-
).has(f), { r: v, g:
|
|
948
|
+
).has(f), { r: v, g: F, b: $ } = u.useMemo(
|
|
949
949
|
() => Qr(f),
|
|
950
950
|
[f]
|
|
951
951
|
);
|
|
@@ -964,19 +964,19 @@ const qe = [
|
|
|
964
964
|
{
|
|
965
965
|
id: e.name,
|
|
966
966
|
value: f,
|
|
967
|
-
onChange:
|
|
967
|
+
onChange: S,
|
|
968
968
|
className: q(
|
|
969
969
|
R.input,
|
|
970
970
|
R.inputSelect
|
|
971
971
|
),
|
|
972
972
|
"aria-invalid": !!m,
|
|
973
973
|
children: [
|
|
974
|
-
qe.map((
|
|
975
|
-
!
|
|
974
|
+
qe.map((V) => /* @__PURE__ */ p("option", { value: V.value, children: o(V.label) }, V.value)),
|
|
975
|
+
!b && /* @__PURE__ */ A("option", { value: f, children: [
|
|
976
976
|
"(",
|
|
977
977
|
v,
|
|
978
978
|
", ",
|
|
979
|
-
|
|
979
|
+
F,
|
|
980
980
|
", ",
|
|
981
981
|
$,
|
|
982
982
|
")"
|
|
@@ -1065,42 +1065,42 @@ const qe = [
|
|
|
1065
1065
|
onError: n,
|
|
1066
1066
|
error: a
|
|
1067
1067
|
}) => {
|
|
1068
|
-
const { t: o, theme: c, formStyle: i, fieldStyle: s } = j(), m = u.useRef(null), l = u.useRef(n), [f, d] = u.useState(!1), [g,
|
|
1068
|
+
const { t: o, theme: c, formStyle: i, fieldStyle: s } = j(), m = u.useRef(null), l = u.useRef(n), [f, d] = u.useState(!1), [g, S] = u.useState(null);
|
|
1069
1069
|
u.useEffect(() => {
|
|
1070
1070
|
l.current = n;
|
|
1071
1071
|
}, [n]);
|
|
1072
|
-
const
|
|
1072
|
+
const I = O(e, a), [b, v] = u.useState(null), F = u.useRef(null);
|
|
1073
1073
|
u.useEffect(() => {
|
|
1074
1074
|
const y = String(r ?? "");
|
|
1075
|
-
let C =
|
|
1075
|
+
let C = I(y);
|
|
1076
1076
|
if (C && e.options.length > 0) {
|
|
1077
|
-
const
|
|
1078
|
-
t?.(
|
|
1077
|
+
const k = String(e.options[0].value);
|
|
1078
|
+
t?.(k), C = null;
|
|
1079
1079
|
}
|
|
1080
|
-
C !==
|
|
1081
|
-
}, [r,
|
|
1080
|
+
C !== F.current && (F.current = C, v(C), l.current?.(C ?? null));
|
|
1081
|
+
}, [r, I, t, e.options]);
|
|
1082
1082
|
const $ = () => {
|
|
1083
1083
|
if (!m.current) return;
|
|
1084
1084
|
const y = m.current.getBoundingClientRect();
|
|
1085
|
-
|
|
1086
|
-
},
|
|
1087
|
-
const C =
|
|
1088
|
-
C !==
|
|
1089
|
-
},
|
|
1085
|
+
S({ x: y.left, y: y.bottom }), d((C) => !C);
|
|
1086
|
+
}, V = (y) => {
|
|
1087
|
+
const C = I(y);
|
|
1088
|
+
C !== F.current && (F.current = C, v(C), l.current?.(C ?? null)), t?.(y), d(!1);
|
|
1089
|
+
}, w = u.useMemo(() => {
|
|
1090
1090
|
const y = e.options.find((C) => String(C.value) === String(r));
|
|
1091
1091
|
return y ? o(y.label) : "";
|
|
1092
|
-
}, [e.options, r, o]),
|
|
1092
|
+
}, [e.options, r, o]), M = (y, C, k) => {
|
|
1093
1093
|
if (!C) return {};
|
|
1094
|
-
const
|
|
1095
|
-
return (
|
|
1096
|
-
},
|
|
1094
|
+
const N = y?.[C];
|
|
1095
|
+
return (k && N ? N[k] : void 0) ?? {};
|
|
1096
|
+
}, x = u.useMemo(() => ({
|
|
1097
1097
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
1098
1098
|
display: "flex",
|
|
1099
1099
|
alignItems: "center",
|
|
1100
1100
|
cursor: "pointer",
|
|
1101
1101
|
position: "relative",
|
|
1102
|
-
...
|
|
1103
|
-
...
|
|
1102
|
+
...M(i, "dropdown", "control"),
|
|
1103
|
+
...M(s, void 0, "control")
|
|
1104
1104
|
}), [i, s]), h = u.useMemo(() => ({
|
|
1105
1105
|
position: "absolute",
|
|
1106
1106
|
right: "0.7em",
|
|
@@ -1109,28 +1109,28 @@ const qe = [
|
|
|
1109
1109
|
pointerEvents: "none",
|
|
1110
1110
|
fontSize: "0.8em",
|
|
1111
1111
|
color: "var(--reactaform-text-muted, #999)",
|
|
1112
|
-
...
|
|
1113
|
-
...
|
|
1112
|
+
...M(i, "dropdown", "arrow"),
|
|
1113
|
+
...M(s, void 0, "arrow")
|
|
1114
1114
|
}), [i, s]);
|
|
1115
1115
|
return /* @__PURE__ */ A("div", { children: [
|
|
1116
|
-
/* @__PURE__ */ p(L, { field: e, error:
|
|
1116
|
+
/* @__PURE__ */ p(L, { field: e, error: b, children: /* @__PURE__ */ A(
|
|
1117
1117
|
"div",
|
|
1118
1118
|
{
|
|
1119
1119
|
ref: m,
|
|
1120
1120
|
className: "reactaform-input",
|
|
1121
|
-
style:
|
|
1121
|
+
style: x,
|
|
1122
1122
|
onClick: $,
|
|
1123
1123
|
tabIndex: 0,
|
|
1124
1124
|
role: "combobox",
|
|
1125
1125
|
"aria-haspopup": "listbox",
|
|
1126
1126
|
"aria-expanded": f,
|
|
1127
|
-
"aria-invalid": !!
|
|
1128
|
-
"aria-describedby":
|
|
1127
|
+
"aria-invalid": !!b,
|
|
1128
|
+
"aria-describedby": b ? `${e.name}-error` : void 0,
|
|
1129
1129
|
onKeyDown: (y) => {
|
|
1130
1130
|
(y.key === "Enter" || y.key === " ") && (y.preventDefault(), $());
|
|
1131
1131
|
},
|
|
1132
1132
|
children: [
|
|
1133
|
-
/* @__PURE__ */ p("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children:
|
|
1133
|
+
/* @__PURE__ */ p("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: w }),
|
|
1134
1134
|
/* @__PURE__ */ p("span", { style: h, "aria-hidden": !0, children: "▼" })
|
|
1135
1135
|
]
|
|
1136
1136
|
}
|
|
@@ -1141,7 +1141,7 @@ const qe = [
|
|
|
1141
1141
|
position: g,
|
|
1142
1142
|
options: e.options,
|
|
1143
1143
|
selectedValue: String(r),
|
|
1144
|
-
onSelect:
|
|
1144
|
+
onSelect: V,
|
|
1145
1145
|
onClose: () => d(!1),
|
|
1146
1146
|
controlRef: m,
|
|
1147
1147
|
theme: c,
|
|
@@ -1177,11 +1177,11 @@ const qe = [
|
|
|
1177
1177
|
);
|
|
1178
1178
|
}
|
|
1179
1179
|
}, [o]);
|
|
1180
|
-
const
|
|
1180
|
+
const S = (h, y, C) => {
|
|
1181
1181
|
if (!y) return {};
|
|
1182
|
-
const
|
|
1183
|
-
return (C &&
|
|
1184
|
-
},
|
|
1182
|
+
const E = h?.[y];
|
|
1183
|
+
return (C && E ? E[C] : void 0) ?? {};
|
|
1184
|
+
}, I = u.useMemo(() => ({
|
|
1185
1185
|
maxHeight: 200,
|
|
1186
1186
|
overflowY: "auto",
|
|
1187
1187
|
background: "var(--reactaform-secondary-bg, #fff)",
|
|
@@ -1192,17 +1192,17 @@ const qe = [
|
|
|
1192
1192
|
pointerEvents: "auto",
|
|
1193
1193
|
color: "var(--reactaform-text-color, #000)",
|
|
1194
1194
|
fontSize: "var(--reactaform-popup-font-size, 0.875rem)",
|
|
1195
|
-
...
|
|
1196
|
-
...
|
|
1197
|
-
}), [f, d]),
|
|
1195
|
+
...S(f, "dropdown", "popup"),
|
|
1196
|
+
...S(d, void 0, "popup")
|
|
1197
|
+
}), [f, d]), b = u.useMemo(() => ({
|
|
1198
1198
|
padding: "6px 8px",
|
|
1199
1199
|
cursor: "pointer",
|
|
1200
1200
|
display: "flex",
|
|
1201
1201
|
alignItems: "center",
|
|
1202
1202
|
background: "transparent",
|
|
1203
1203
|
color: "var(--reactaform-text-color, #000)",
|
|
1204
|
-
...
|
|
1205
|
-
...
|
|
1204
|
+
...S(f, "dropdown", "option"),
|
|
1205
|
+
...S(d, void 0, "option")
|
|
1206
1206
|
}), [f, d]);
|
|
1207
1207
|
u.useEffect(() => {
|
|
1208
1208
|
const h = (y) => {
|
|
@@ -1220,17 +1220,17 @@ const qe = [
|
|
|
1220
1220
|
const h = s.current.querySelector(`#opt-${m}`);
|
|
1221
1221
|
h && requestAnimationFrame(() => h.focus());
|
|
1222
1222
|
}, [m]);
|
|
1223
|
-
const v = 250,
|
|
1223
|
+
const v = 250, F = 200, [$, V] = u.useState(null), [w, M] = u.useState(null);
|
|
1224
1224
|
if (u.useEffect(() => {
|
|
1225
1225
|
if (typeof window > "u") return;
|
|
1226
1226
|
const h = () => {
|
|
1227
|
-
let
|
|
1227
|
+
let k = e.x, E = e.y, N = v;
|
|
1228
1228
|
const P = o?.current;
|
|
1229
1229
|
if (P) {
|
|
1230
1230
|
const H = P.getBoundingClientRect();
|
|
1231
|
-
|
|
1231
|
+
k = H.left, E = H.bottom, N = Math.max(80, Math.round(H.width));
|
|
1232
1232
|
}
|
|
1233
|
-
|
|
1233
|
+
k = Math.min(k, window.innerWidth - N), E = Math.min(E, window.innerHeight - F), V({ left: k, top: E }), M(N);
|
|
1234
1234
|
};
|
|
1235
1235
|
h(), window.addEventListener("scroll", h, !0), window.addEventListener("resize", h);
|
|
1236
1236
|
let y = null;
|
|
@@ -1239,8 +1239,8 @@ const qe = [
|
|
|
1239
1239
|
window.removeEventListener("scroll", h, !0), window.removeEventListener("resize", h), y && C && y.unobserve(C);
|
|
1240
1240
|
};
|
|
1241
1241
|
}, [o, e.x, e.y]), typeof window > "u") return null;
|
|
1242
|
-
let
|
|
1243
|
-
return
|
|
1242
|
+
let x = document.getElementById("popup-root");
|
|
1243
|
+
return x || (x = document.createElement("div"), x.id = "popup-root", document.body.appendChild(x)), me.createPortal(
|
|
1244
1244
|
/* @__PURE__ */ p(
|
|
1245
1245
|
"div",
|
|
1246
1246
|
{
|
|
@@ -1251,56 +1251,56 @@ const qe = [
|
|
|
1251
1251
|
position: "fixed",
|
|
1252
1252
|
top: $ ? $.top : e.y,
|
|
1253
1253
|
left: $ ? $.left : e.x,
|
|
1254
|
-
width:
|
|
1255
|
-
...
|
|
1254
|
+
width: w ?? v,
|
|
1255
|
+
...I
|
|
1256
1256
|
},
|
|
1257
1257
|
"data-reactaform-theme": c ?? "light",
|
|
1258
1258
|
children: r.map((h, y) => {
|
|
1259
|
-
const C = String(h.value) === t,
|
|
1260
|
-
...
|
|
1261
|
-
background: y === m ?
|
|
1259
|
+
const C = String(h.value) === t, k = g ? "var(--reactaform-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-hover-bg, #eee)", E = {
|
|
1260
|
+
...b,
|
|
1261
|
+
background: y === m ? k : b.background,
|
|
1262
1262
|
fontWeight: C ? "bold" : "normal"
|
|
1263
1263
|
};
|
|
1264
1264
|
return /* @__PURE__ */ p(
|
|
1265
1265
|
"div",
|
|
1266
1266
|
{
|
|
1267
1267
|
id: `opt-${y}`,
|
|
1268
|
-
onMouseDown: (
|
|
1269
|
-
|
|
1268
|
+
onMouseDown: (N) => {
|
|
1269
|
+
N.stopPropagation(), n(String(h.value));
|
|
1270
1270
|
},
|
|
1271
|
-
onKeyDown: (
|
|
1271
|
+
onKeyDown: (N) => {
|
|
1272
1272
|
const P = r.length;
|
|
1273
|
-
switch (
|
|
1273
|
+
switch (N.key) {
|
|
1274
1274
|
case "ArrowDown":
|
|
1275
|
-
|
|
1275
|
+
N.preventDefault(), l((H) => (H + 1) % P);
|
|
1276
1276
|
break;
|
|
1277
1277
|
case "ArrowUp":
|
|
1278
|
-
|
|
1278
|
+
N.preventDefault(), l((H) => (H - 1 + P) % P);
|
|
1279
1279
|
break;
|
|
1280
1280
|
case "Home":
|
|
1281
|
-
|
|
1281
|
+
N.preventDefault(), l(0);
|
|
1282
1282
|
break;
|
|
1283
1283
|
case "End":
|
|
1284
|
-
|
|
1284
|
+
N.preventDefault(), l(P - 1);
|
|
1285
1285
|
break;
|
|
1286
1286
|
case "Enter":
|
|
1287
1287
|
case " ":
|
|
1288
|
-
|
|
1288
|
+
N.preventDefault(), N.stopPropagation(), n(String(h.value));
|
|
1289
1289
|
break;
|
|
1290
1290
|
case "Escape":
|
|
1291
|
-
|
|
1291
|
+
N.preventDefault(), a(), o?.current?.focus();
|
|
1292
1292
|
break;
|
|
1293
1293
|
}
|
|
1294
1294
|
},
|
|
1295
1295
|
tabIndex: y === m ? 0 : -1,
|
|
1296
1296
|
role: "option",
|
|
1297
1297
|
"aria-selected": C,
|
|
1298
|
-
style:
|
|
1299
|
-
onMouseEnter: (
|
|
1300
|
-
|
|
1298
|
+
style: E,
|
|
1299
|
+
onMouseEnter: (N) => {
|
|
1300
|
+
N.currentTarget.style.background = k, l(y);
|
|
1301
1301
|
},
|
|
1302
|
-
onMouseLeave: (
|
|
1303
|
-
|
|
1302
|
+
onMouseLeave: (N) => {
|
|
1303
|
+
N.currentTarget.style.background = "transparent", l((P) => P === y ? -1 : P);
|
|
1304
1304
|
},
|
|
1305
1305
|
children: i(h.label)
|
|
1306
1306
|
},
|
|
@@ -1309,7 +1309,7 @@ const qe = [
|
|
|
1309
1309
|
})
|
|
1310
1310
|
}
|
|
1311
1311
|
),
|
|
1312
|
-
|
|
1312
|
+
x
|
|
1313
1313
|
);
|
|
1314
1314
|
}, at = ({
|
|
1315
1315
|
field: e,
|
|
@@ -1360,55 +1360,55 @@ const qe = [
|
|
|
1360
1360
|
u.useEffect(() => {
|
|
1361
1361
|
m.current = n;
|
|
1362
1362
|
}, [n]);
|
|
1363
|
-
const g = (
|
|
1364
|
-
(
|
|
1365
|
-
),
|
|
1363
|
+
const g = (w, M) => M.some(
|
|
1364
|
+
(x) => x.name === w.name && x.size === w.size && x.lastModified === w.lastModified
|
|
1365
|
+
), S = O(e, a);
|
|
1366
1366
|
u.useEffect(() => {
|
|
1367
|
-
const
|
|
1368
|
-
t?.(r),
|
|
1369
|
-
}, [r,
|
|
1370
|
-
const
|
|
1371
|
-
const
|
|
1372
|
-
let
|
|
1373
|
-
if (
|
|
1374
|
-
const y = Array.from(
|
|
1367
|
+
const w = S(r ?? []);
|
|
1368
|
+
t?.(r), w !== l.current && (l.current = w, d(w), m.current?.(w ?? null));
|
|
1369
|
+
}, [r, S]);
|
|
1370
|
+
const I = (w) => {
|
|
1371
|
+
const M = w.target.files;
|
|
1372
|
+
let x = null;
|
|
1373
|
+
if (M && M.length > 0) {
|
|
1374
|
+
const y = Array.from(M);
|
|
1375
1375
|
if (e.multiple) {
|
|
1376
|
-
const C = Array.isArray(r) ? r : [],
|
|
1377
|
-
|
|
1376
|
+
const C = Array.isArray(r) ? r : [], k = y.filter((E) => !g(E, C));
|
|
1377
|
+
x = [...C, ...k];
|
|
1378
1378
|
} else
|
|
1379
|
-
|
|
1379
|
+
x = y[0];
|
|
1380
1380
|
}
|
|
1381
|
-
const h =
|
|
1382
|
-
h !== l.current && (l.current = h, d(h), m.current?.(h ?? null)), t?.(
|
|
1383
|
-
},
|
|
1384
|
-
|
|
1385
|
-
const
|
|
1386
|
-
if (
|
|
1387
|
-
const
|
|
1381
|
+
const h = S(x ?? []);
|
|
1382
|
+
h !== l.current && (l.current = h, d(h), m.current?.(h ?? null)), t?.(x), w.target && (w.target.value = "");
|
|
1383
|
+
}, b = (w) => {
|
|
1384
|
+
w.preventDefault(), w.stopPropagation(), i(!1);
|
|
1385
|
+
const M = w.dataTransfer.files;
|
|
1386
|
+
if (M && M.length > 0) {
|
|
1387
|
+
const x = Array.from(M);
|
|
1388
1388
|
let h = null;
|
|
1389
1389
|
if (e.multiple) {
|
|
1390
|
-
const C = Array.isArray(r) ? r : [],
|
|
1391
|
-
h = [...C, ...
|
|
1390
|
+
const C = Array.isArray(r) ? r : [], k = x.filter((E) => !g(E, C));
|
|
1391
|
+
h = [...C, ...k];
|
|
1392
1392
|
} else
|
|
1393
|
-
h =
|
|
1394
|
-
const y =
|
|
1393
|
+
h = x[0];
|
|
1394
|
+
const y = S(h);
|
|
1395
1395
|
y !== l.current && (l.current = y, d(y), m.current?.(y ?? null)), t?.(h);
|
|
1396
1396
|
}
|
|
1397
|
-
}, v = (
|
|
1398
|
-
|
|
1399
|
-
},
|
|
1400
|
-
|
|
1401
|
-
}, $ = (
|
|
1402
|
-
if (Array.isArray(r) && typeof
|
|
1403
|
-
const
|
|
1404
|
-
h !== l.current && (l.current = h, d(h), m.current?.(h ?? null)), t?.(
|
|
1397
|
+
}, v = (w) => {
|
|
1398
|
+
w.preventDefault(), w.stopPropagation(), i(!0);
|
|
1399
|
+
}, F = (w) => {
|
|
1400
|
+
w.preventDefault(), w.stopPropagation(), i(!1);
|
|
1401
|
+
}, $ = (w) => {
|
|
1402
|
+
if (Array.isArray(r) && typeof w == "number") {
|
|
1403
|
+
const M = r.filter((y, C) => C !== w), x = M.length > 0 ? M : null, h = S(x ?? []);
|
|
1404
|
+
h !== l.current && (l.current = h, d(h), m.current?.(h ?? null)), t?.(x);
|
|
1405
1405
|
} else {
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1406
|
+
const M = S([]);
|
|
1407
|
+
M !== l.current && (l.current = M, d(M), m.current?.(M ?? null)), t?.(null);
|
|
1408
1408
|
}
|
|
1409
|
-
},
|
|
1410
|
-
const
|
|
1411
|
-
return
|
|
1409
|
+
}, V = () => {
|
|
1410
|
+
const w = Array.isArray(r) ? r : r ? [r] : [];
|
|
1411
|
+
return w.length === 0 ? null : /* @__PURE__ */ p("div", { style: {
|
|
1412
1412
|
marginTop: "8px",
|
|
1413
1413
|
marginLeft: "20px",
|
|
1414
1414
|
display: "flex",
|
|
@@ -1416,7 +1416,7 @@ const qe = [
|
|
|
1416
1416
|
gap: "6px",
|
|
1417
1417
|
maxHeight: "200px",
|
|
1418
1418
|
overflowY: "auto"
|
|
1419
|
-
}, children:
|
|
1419
|
+
}, children: w.map((M, x) => /* @__PURE__ */ A(
|
|
1420
1420
|
"div",
|
|
1421
1421
|
{
|
|
1422
1422
|
style: {
|
|
@@ -1429,10 +1429,10 @@ const qe = [
|
|
|
1429
1429
|
"input",
|
|
1430
1430
|
{
|
|
1431
1431
|
type: "text",
|
|
1432
|
-
value:
|
|
1432
|
+
value: M.name,
|
|
1433
1433
|
disabled: !0,
|
|
1434
1434
|
readOnly: !0,
|
|
1435
|
-
title:
|
|
1435
|
+
title: M.name,
|
|
1436
1436
|
className: "reactaform-input",
|
|
1437
1437
|
style: {
|
|
1438
1438
|
flex: 1,
|
|
@@ -1446,7 +1446,7 @@ const qe = [
|
|
|
1446
1446
|
"button",
|
|
1447
1447
|
{
|
|
1448
1448
|
type: "button",
|
|
1449
|
-
onClick: () => $(Array.isArray(r) ?
|
|
1449
|
+
onClick: () => $(Array.isArray(r) ? x : void 0),
|
|
1450
1450
|
"aria-label": o("Remove file"),
|
|
1451
1451
|
style: {
|
|
1452
1452
|
background: "transparent",
|
|
@@ -1471,7 +1471,7 @@ const qe = [
|
|
|
1471
1471
|
)
|
|
1472
1472
|
]
|
|
1473
1473
|
},
|
|
1474
|
-
`${
|
|
1474
|
+
`${M.name}-${x}`
|
|
1475
1475
|
)) });
|
|
1476
1476
|
};
|
|
1477
1477
|
return /* @__PURE__ */ p(L, { field: e, error: f, children: /* @__PURE__ */ A("div", { style: { width: "100%" }, children: [
|
|
@@ -1479,9 +1479,9 @@ const qe = [
|
|
|
1479
1479
|
"div",
|
|
1480
1480
|
{
|
|
1481
1481
|
className: "reactaform-input",
|
|
1482
|
-
onDrop:
|
|
1482
|
+
onDrop: b,
|
|
1483
1483
|
onDragOver: v,
|
|
1484
|
-
onDragLeave:
|
|
1484
|
+
onDragLeave: F,
|
|
1485
1485
|
style: {
|
|
1486
1486
|
position: "relative",
|
|
1487
1487
|
borderStyle: "dashed",
|
|
@@ -1504,8 +1504,8 @@ const qe = [
|
|
|
1504
1504
|
gap: "8px"
|
|
1505
1505
|
},
|
|
1506
1506
|
onClick: () => s.current?.click(),
|
|
1507
|
-
onKeyDown: (
|
|
1508
|
-
(
|
|
1507
|
+
onKeyDown: (w) => {
|
|
1508
|
+
(w.key === "Enter" || w.key === " ") && (w.preventDefault(), s.current?.click());
|
|
1509
1509
|
},
|
|
1510
1510
|
role: "button",
|
|
1511
1511
|
"aria-label": e.multiple ? o("Choose Files or Drag & Drop") : o("Choose File or Drag & Drop"),
|
|
@@ -1523,7 +1523,7 @@ const qe = [
|
|
|
1523
1523
|
style: {
|
|
1524
1524
|
display: "none"
|
|
1525
1525
|
},
|
|
1526
|
-
onChange:
|
|
1526
|
+
onChange: I
|
|
1527
1527
|
}
|
|
1528
1528
|
),
|
|
1529
1529
|
/* @__PURE__ */ p("div", { style: {
|
|
@@ -1550,7 +1550,7 @@ const qe = [
|
|
|
1550
1550
|
]
|
|
1551
1551
|
}
|
|
1552
1552
|
),
|
|
1553
|
-
|
|
1553
|
+
V()
|
|
1554
1554
|
] }) });
|
|
1555
1555
|
}, st = ({
|
|
1556
1556
|
field: e,
|
|
@@ -1629,38 +1629,38 @@ const ut = ({ field: e, value: r }) => {
|
|
|
1629
1629
|
}, c = typeof r == "string" ? r : "";
|
|
1630
1630
|
let i = c && c.trim() !== "" ? c : typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
1631
1631
|
i && !i.startsWith("/") && (i = `${lt()}${i}`);
|
|
1632
|
-
const s = e.localized?.split(";").map((
|
|
1632
|
+
const s = e.localized?.split(";").map((b) => b.trim()), [m, l] = u.useState(i || ""), f = u.useRef(i || null);
|
|
1633
1633
|
if (u.useEffect(() => {
|
|
1634
1634
|
if (!i) return;
|
|
1635
|
-
const
|
|
1636
|
-
if (
|
|
1637
|
-
const $ = v.substring(0,
|
|
1638
|
-
let
|
|
1639
|
-
s?.includes(t) && (
|
|
1640
|
-
const
|
|
1641
|
-
if (
|
|
1642
|
-
const
|
|
1643
|
-
fetch(
|
|
1644
|
-
const y = h.ok ?
|
|
1635
|
+
const b = i.split("/"), v = b.pop(), F = v.lastIndexOf(".");
|
|
1636
|
+
if (F === -1) return;
|
|
1637
|
+
const $ = v.substring(0, F), V = v.substring(F);
|
|
1638
|
+
let w = null;
|
|
1639
|
+
s?.includes(t) && (w = `${$}_${t}${V}`);
|
|
1640
|
+
const M = new AbortController();
|
|
1641
|
+
if (w) {
|
|
1642
|
+
const x = [...b, w].join("/");
|
|
1643
|
+
fetch(x, { method: "HEAD", signal: M.signal }).then((h) => {
|
|
1644
|
+
const y = h.ok ? x : i;
|
|
1645
1645
|
y !== f.current && (f.current = y, l(y));
|
|
1646
1646
|
}).catch(() => {
|
|
1647
1647
|
i !== f.current && (f.current = i, l(i));
|
|
1648
1648
|
});
|
|
1649
1649
|
} else {
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1650
|
+
const x = i;
|
|
1651
|
+
x !== f.current && (f.current = x, requestAnimationFrame(() => l(x)));
|
|
1652
1652
|
}
|
|
1653
1653
|
return () => {
|
|
1654
|
-
|
|
1654
|
+
M.abort();
|
|
1655
1655
|
};
|
|
1656
1656
|
}, [i, t, s]), !m) return null;
|
|
1657
|
-
const { width: d, height: g } = e,
|
|
1657
|
+
const { width: d, height: g } = e, S = {}, I = {
|
|
1658
1658
|
borderRadius: "8px",
|
|
1659
1659
|
objectFit: "contain",
|
|
1660
1660
|
boxShadow: "0 2px 6px rgba(0,0,0,0.1)",
|
|
1661
1661
|
margin: "0 0 8px 0"
|
|
1662
1662
|
};
|
|
1663
|
-
return d && g ? (
|
|
1663
|
+
return d && g ? (S.width = d, S.height = g, I.width = `${d}px`, I.height = `${g}px`) : d && !g ? (S.width = d, I.width = `${d}px`, I.height = "auto") : !d && g && (S.height = g, I.width = "auto", I.height = `${g}px`), /* @__PURE__ */ p(L, { field: e, children: /* @__PURE__ */ p(
|
|
1664
1664
|
"div",
|
|
1665
1665
|
{
|
|
1666
1666
|
"data-testid": "image-wrapper",
|
|
@@ -1674,8 +1674,8 @@ const ut = ({ field: e, value: r }) => {
|
|
|
1674
1674
|
{
|
|
1675
1675
|
src: m,
|
|
1676
1676
|
alt: n?.(e.displayName || "Image") || e.displayName || "Image",
|
|
1677
|
-
...
|
|
1678
|
-
style:
|
|
1677
|
+
...S,
|
|
1678
|
+
style: I
|
|
1679
1679
|
}
|
|
1680
1680
|
)
|
|
1681
1681
|
}
|
|
@@ -1779,28 +1779,28 @@ const ft = u.memo(fr), dt = ({
|
|
|
1779
1779
|
u.useEffect(() => {
|
|
1780
1780
|
o.current = n;
|
|
1781
1781
|
}, [n]);
|
|
1782
|
-
const { t: c, theme: i, formStyle: s, fieldStyle: m } = j(), l = (
|
|
1783
|
-
if (!
|
|
1784
|
-
const H =
|
|
1785
|
-
return (
|
|
1786
|
-
}, f = u.useRef(null), [d, g] = u.useState(!1), [
|
|
1787
|
-
() => e.options.map((
|
|
1782
|
+
const { t: c, theme: i, formStyle: s, fieldStyle: m } = j(), l = (k, E, N) => {
|
|
1783
|
+
if (!E) return {};
|
|
1784
|
+
const H = k?.[E];
|
|
1785
|
+
return (N && H ? H[N] : void 0) ?? {};
|
|
1786
|
+
}, f = u.useRef(null), [d, g] = u.useState(!1), [S, I] = u.useState(null), b = u.useMemo(
|
|
1787
|
+
() => e.options.map((k) => ({ value: k.value, label: c(k.label) })),
|
|
1788
1788
|
[e.options, c]
|
|
1789
1789
|
), v = u.useMemo(() => {
|
|
1790
|
-
const
|
|
1791
|
-
return
|
|
1792
|
-
}, [r,
|
|
1790
|
+
const k = Array.isArray(r) ? r : [], E = new Set(b.map((N) => N.value));
|
|
1791
|
+
return k.filter((N) => E.has(N));
|
|
1792
|
+
}, [r, b]), F = O(e, a), [$, V] = u.useState(null), w = u.useRef(null);
|
|
1793
1793
|
u.useEffect(() => {
|
|
1794
|
-
const
|
|
1795
|
-
|
|
1796
|
-
}, [r,
|
|
1797
|
-
const
|
|
1794
|
+
const k = F(Array.isArray(r) ? r : []);
|
|
1795
|
+
k !== w.current && (w.current = k, V(k), o.current?.(k ?? null));
|
|
1796
|
+
}, [r, F]);
|
|
1797
|
+
const M = () => {
|
|
1798
1798
|
if (!f.current) return;
|
|
1799
|
-
const
|
|
1800
|
-
|
|
1801
|
-
},
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1799
|
+
const k = f.current.getBoundingClientRect();
|
|
1800
|
+
I({ x: k.left, y: k.bottom }), g((E) => !E);
|
|
1801
|
+
}, x = (k) => {
|
|
1802
|
+
const E = v.includes(k) ? v.filter((P) => P !== k) : [...v, k], N = F(E);
|
|
1803
|
+
N !== w.current && (w.current = N, V(N), o.current?.(N ?? null)), t?.(E);
|
|
1804
1804
|
}, h = u.useMemo(
|
|
1805
1805
|
() => ({
|
|
1806
1806
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
@@ -1849,14 +1849,14 @@ const ft = u.memo(fr), dt = ({
|
|
|
1849
1849
|
ref: f,
|
|
1850
1850
|
className: "reactaform-multiselection-control reactaform-input",
|
|
1851
1851
|
style: h,
|
|
1852
|
-
onClick:
|
|
1852
|
+
onClick: M,
|
|
1853
1853
|
role: "button",
|
|
1854
1854
|
"aria-haspopup": "listbox",
|
|
1855
1855
|
"aria-expanded": d,
|
|
1856
1856
|
"aria-invalid": !!$,
|
|
1857
1857
|
"aria-describedby": $ ? `${e.name}-error` : void 0,
|
|
1858
|
-
onKeyDown: (
|
|
1859
|
-
(
|
|
1858
|
+
onKeyDown: (k) => {
|
|
1859
|
+
(k.key === "Enter" || k.key === " ") && (k.preventDefault(), M());
|
|
1860
1860
|
},
|
|
1861
1861
|
children: [
|
|
1862
1862
|
/* @__PURE__ */ A(
|
|
@@ -1866,7 +1866,7 @@ const ft = u.memo(fr), dt = ({
|
|
|
1866
1866
|
children: [
|
|
1867
1867
|
v.length,
|
|
1868
1868
|
" / ",
|
|
1869
|
-
|
|
1869
|
+
b.length,
|
|
1870
1870
|
" selected"
|
|
1871
1871
|
]
|
|
1872
1872
|
}
|
|
@@ -1876,8 +1876,8 @@ const ft = u.memo(fr), dt = ({
|
|
|
1876
1876
|
{
|
|
1877
1877
|
type: "button",
|
|
1878
1878
|
"aria-label": "Clear selections",
|
|
1879
|
-
onClick: (
|
|
1880
|
-
|
|
1879
|
+
onClick: (k) => {
|
|
1880
|
+
k.stopPropagation(), t?.([]);
|
|
1881
1881
|
},
|
|
1882
1882
|
style: y,
|
|
1883
1883
|
children: /* @__PURE__ */ p("span", { style: y, "aria-hidden": !0, children: "✖" })
|
|
@@ -1887,13 +1887,13 @@ const ft = u.memo(fr), dt = ({
|
|
|
1887
1887
|
]
|
|
1888
1888
|
}
|
|
1889
1889
|
) }) }),
|
|
1890
|
-
d &&
|
|
1890
|
+
d && S && /* @__PURE__ */ p(
|
|
1891
1891
|
gt,
|
|
1892
1892
|
{
|
|
1893
|
-
position:
|
|
1894
|
-
options:
|
|
1893
|
+
position: S,
|
|
1894
|
+
options: b,
|
|
1895
1895
|
selectedValues: v,
|
|
1896
|
-
onToggleOption:
|
|
1896
|
+
onToggleOption: x,
|
|
1897
1897
|
onClose: () => g(!1),
|
|
1898
1898
|
controlRef: f,
|
|
1899
1899
|
theme: i
|
|
@@ -1912,9 +1912,9 @@ const ft = u.memo(fr), dt = ({
|
|
|
1912
1912
|
const i = u.useRef(null), [s, m] = u.useState(-1), { formStyle: l, fieldStyle: f } = j(), d = fe(c ?? "light");
|
|
1913
1913
|
u.useLayoutEffect(() => {
|
|
1914
1914
|
if (!o.current) return;
|
|
1915
|
-
const
|
|
1916
|
-
if (
|
|
1917
|
-
const y = getComputedStyle(
|
|
1915
|
+
const x = o.current.closest("[data-reactaform-theme]"), h = document.getElementById("popup-root");
|
|
1916
|
+
if (x && h) {
|
|
1917
|
+
const y = getComputedStyle(x);
|
|
1918
1918
|
h.style.setProperty(
|
|
1919
1919
|
"--reactaform-secondary-bg",
|
|
1920
1920
|
y.getPropertyValue("--reactaform-secondary-bg")
|
|
@@ -1927,11 +1927,11 @@ const ft = u.memo(fr), dt = ({
|
|
|
1927
1927
|
);
|
|
1928
1928
|
}
|
|
1929
1929
|
}, [o]);
|
|
1930
|
-
const g = (
|
|
1930
|
+
const g = (x, h, y) => {
|
|
1931
1931
|
if (!h) return {};
|
|
1932
|
-
const
|
|
1933
|
-
return (y &&
|
|
1934
|
-
},
|
|
1932
|
+
const k = x?.[h];
|
|
1933
|
+
return (y && k ? k[y] : void 0) ?? {};
|
|
1934
|
+
}, S = u.useMemo(
|
|
1935
1935
|
() => ({
|
|
1936
1936
|
maxHeight: 200,
|
|
1937
1937
|
overflowY: "auto",
|
|
@@ -1947,7 +1947,7 @@ const ft = u.memo(fr), dt = ({
|
|
|
1947
1947
|
...g(f, void 0, "popup")
|
|
1948
1948
|
}),
|
|
1949
1949
|
[l, f]
|
|
1950
|
-
),
|
|
1950
|
+
), I = u.useMemo(
|
|
1951
1951
|
() => ({
|
|
1952
1952
|
padding: "6px 8px",
|
|
1953
1953
|
cursor: "pointer",
|
|
@@ -1961,43 +1961,43 @@ const ft = u.memo(fr), dt = ({
|
|
|
1961
1961
|
[l, f]
|
|
1962
1962
|
);
|
|
1963
1963
|
u.useEffect(() => {
|
|
1964
|
-
const
|
|
1964
|
+
const x = (h) => {
|
|
1965
1965
|
const y = h.target;
|
|
1966
1966
|
!i.current?.contains(y) && !o.current?.contains(y) && a();
|
|
1967
1967
|
};
|
|
1968
|
-
return document.addEventListener("mousedown",
|
|
1968
|
+
return document.addEventListener("mousedown", x), () => document.removeEventListener("mousedown", x);
|
|
1969
1969
|
}, [a, o]), u.useEffect(() => {
|
|
1970
1970
|
i.current && r.length > 0 && requestAnimationFrame(
|
|
1971
|
-
() => m((
|
|
1971
|
+
() => m((x) => x === -1 ? 0 : x)
|
|
1972
1972
|
);
|
|
1973
1973
|
}, [r.length]), u.useEffect(() => {
|
|
1974
1974
|
if (!i.current || s < 0) return;
|
|
1975
|
-
const
|
|
1975
|
+
const x = i.current.querySelector(
|
|
1976
1976
|
`#multi-opt-${s}`
|
|
1977
1977
|
);
|
|
1978
|
-
|
|
1978
|
+
x && requestAnimationFrame(() => x.focus());
|
|
1979
1979
|
}, [s]);
|
|
1980
|
-
const
|
|
1980
|
+
const b = 250, v = 200, [F, $] = u.useState(null), [V, w] = u.useState(null);
|
|
1981
1981
|
if (u.useEffect(() => {
|
|
1982
1982
|
if (typeof window > "u") return;
|
|
1983
|
-
const
|
|
1984
|
-
let C = e.x,
|
|
1985
|
-
const
|
|
1986
|
-
if (
|
|
1987
|
-
const P =
|
|
1988
|
-
C = P.left,
|
|
1983
|
+
const x = () => {
|
|
1984
|
+
let C = e.x, k = e.y, E = b;
|
|
1985
|
+
const N = o?.current;
|
|
1986
|
+
if (N) {
|
|
1987
|
+
const P = N.getBoundingClientRect();
|
|
1988
|
+
C = P.left, k = P.bottom, E = Math.max(80, Math.round(P.width));
|
|
1989
1989
|
}
|
|
1990
|
-
C = Math.min(C, window.innerWidth -
|
|
1990
|
+
C = Math.min(C, window.innerWidth - E), k = Math.min(k, window.innerHeight - v), $({ left: C, top: k }), w(E);
|
|
1991
1991
|
};
|
|
1992
|
-
|
|
1992
|
+
x(), window.addEventListener("scroll", x, !0), window.addEventListener("resize", x);
|
|
1993
1993
|
let h = null;
|
|
1994
1994
|
const y = o?.current;
|
|
1995
|
-
return typeof ResizeObserver < "u" && y && (h = new ResizeObserver(() =>
|
|
1996
|
-
window.removeEventListener("scroll",
|
|
1995
|
+
return typeof ResizeObserver < "u" && y && (h = new ResizeObserver(() => x()), h.observe(y)), () => {
|
|
1996
|
+
window.removeEventListener("scroll", x, !0), window.removeEventListener("resize", x), h && y && h.unobserve(y);
|
|
1997
1997
|
};
|
|
1998
1998
|
}, [o, e.x, e.y]), typeof window > "u") return null;
|
|
1999
|
-
let
|
|
2000
|
-
return
|
|
1999
|
+
let M = document.getElementById("popup-root");
|
|
2000
|
+
return M || (M = document.createElement("div"), M.id = "popup-root", document.body.appendChild(M)), me.createPortal(
|
|
2001
2001
|
/* @__PURE__ */ p(
|
|
2002
2002
|
"div",
|
|
2003
2003
|
{
|
|
@@ -2006,58 +2006,58 @@ const ft = u.memo(fr), dt = ({
|
|
|
2006
2006
|
"aria-activedescendant": s >= 0 ? `multi-opt-${s}` : void 0,
|
|
2007
2007
|
style: {
|
|
2008
2008
|
position: "fixed",
|
|
2009
|
-
top:
|
|
2010
|
-
left:
|
|
2011
|
-
width:
|
|
2009
|
+
top: F ? F.top : e.y,
|
|
2010
|
+
left: F ? F.left : e.x,
|
|
2011
|
+
width: V ?? b,
|
|
2012
2012
|
// spread the static popup styles
|
|
2013
|
-
...
|
|
2013
|
+
...S
|
|
2014
2014
|
},
|
|
2015
2015
|
"data-reactaform-theme": c ?? "light",
|
|
2016
|
-
children: r.map((
|
|
2017
|
-
const y = t.includes(
|
|
2018
|
-
...
|
|
2019
|
-
background: h === s ? C :
|
|
2016
|
+
children: r.map((x, h) => {
|
|
2017
|
+
const y = t.includes(x.value), C = d ? "var(--reactaform-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-hover-bg, #eee)", k = {
|
|
2018
|
+
...I,
|
|
2019
|
+
background: h === s ? C : I.background
|
|
2020
2020
|
};
|
|
2021
2021
|
return /* @__PURE__ */ A(
|
|
2022
2022
|
"div",
|
|
2023
2023
|
{
|
|
2024
2024
|
id: `multi-opt-${h}`,
|
|
2025
|
-
onMouseDown: (
|
|
2026
|
-
|
|
2025
|
+
onMouseDown: (E) => {
|
|
2026
|
+
E.stopPropagation(), n(x.value);
|
|
2027
2027
|
},
|
|
2028
|
-
onKeyDown: (
|
|
2029
|
-
const
|
|
2030
|
-
switch (
|
|
2028
|
+
onKeyDown: (E) => {
|
|
2029
|
+
const N = r.length;
|
|
2030
|
+
switch (E.key) {
|
|
2031
2031
|
case "ArrowDown":
|
|
2032
|
-
|
|
2032
|
+
E.preventDefault(), m((P) => (P + 1) % N);
|
|
2033
2033
|
break;
|
|
2034
2034
|
case "ArrowUp":
|
|
2035
|
-
|
|
2035
|
+
E.preventDefault(), m((P) => (P - 1 + N) % N);
|
|
2036
2036
|
break;
|
|
2037
2037
|
case "Home":
|
|
2038
|
-
|
|
2038
|
+
E.preventDefault(), m(0);
|
|
2039
2039
|
break;
|
|
2040
2040
|
case "End":
|
|
2041
|
-
|
|
2041
|
+
E.preventDefault(), m(N - 1);
|
|
2042
2042
|
break;
|
|
2043
2043
|
case "Enter":
|
|
2044
2044
|
case " ":
|
|
2045
|
-
|
|
2045
|
+
E.preventDefault(), E.stopPropagation(), n(x.value);
|
|
2046
2046
|
break;
|
|
2047
2047
|
case "Escape":
|
|
2048
|
-
|
|
2048
|
+
E.preventDefault(), a(), o?.current?.focus();
|
|
2049
2049
|
break;
|
|
2050
2050
|
}
|
|
2051
2051
|
},
|
|
2052
2052
|
tabIndex: h === s ? 0 : -1,
|
|
2053
2053
|
role: "option",
|
|
2054
2054
|
"aria-selected": y,
|
|
2055
|
-
style:
|
|
2056
|
-
onMouseEnter: (
|
|
2057
|
-
|
|
2055
|
+
style: k,
|
|
2056
|
+
onMouseEnter: (E) => {
|
|
2057
|
+
E.currentTarget.style.background = C, m(h);
|
|
2058
2058
|
},
|
|
2059
|
-
onMouseLeave: (
|
|
2060
|
-
|
|
2059
|
+
onMouseLeave: (E) => {
|
|
2060
|
+
E.currentTarget.style.background = "transparent", m((N) => N === h ? -1 : N);
|
|
2061
2061
|
},
|
|
2062
2062
|
children: [
|
|
2063
2063
|
/* @__PURE__ */ p(
|
|
@@ -2076,15 +2076,15 @@ const ft = u.memo(fr), dt = ({
|
|
|
2076
2076
|
}
|
|
2077
2077
|
}
|
|
2078
2078
|
),
|
|
2079
|
-
|
|
2079
|
+
x.label
|
|
2080
2080
|
]
|
|
2081
2081
|
},
|
|
2082
|
-
|
|
2082
|
+
x.value
|
|
2083
2083
|
);
|
|
2084
2084
|
})
|
|
2085
2085
|
}
|
|
2086
2086
|
),
|
|
2087
|
-
|
|
2087
|
+
M
|
|
2088
2088
|
);
|
|
2089
2089
|
}, ht = ({
|
|
2090
2090
|
field: e,
|
|
@@ -2152,30 +2152,28 @@ const ft = u.memo(fr), dt = ({
|
|
|
2152
2152
|
onError: n,
|
|
2153
2153
|
error: a
|
|
2154
2154
|
}) => {
|
|
2155
|
-
const { t: o } = j(), c = O(e, a), i = e.layout?.toLowerCase() === "horizontal" ? "row" : "column", s = u.useRef(
|
|
2155
|
+
const { t: o } = j(), c = O(e, a), i = e.layout?.toLowerCase() === "horizontal" ? "row" : "column", s = u.useRef(n);
|
|
2156
2156
|
u.useEffect(() => {
|
|
2157
|
-
|
|
2157
|
+
s.current = n;
|
|
2158
2158
|
}, [n]);
|
|
2159
|
-
const [
|
|
2160
|
-
(
|
|
2161
|
-
|
|
2159
|
+
const [m, l] = u.useState(null), f = u.useRef(null), d = u.useCallback(
|
|
2160
|
+
(b) => {
|
|
2161
|
+
b !== f.current && (f.current = b, l(b), s.current?.(b));
|
|
2162
2162
|
},
|
|
2163
2163
|
[]
|
|
2164
2164
|
);
|
|
2165
2165
|
u.useEffect(() => {
|
|
2166
|
-
const
|
|
2167
|
-
if (
|
|
2168
|
-
const
|
|
2169
|
-
t?.(
|
|
2170
|
-
N.checked = N.value === $;
|
|
2171
|
-
});
|
|
2166
|
+
const b = r != null ? String(r) : "", v = c(b);
|
|
2167
|
+
if (v && e.options.length > 0) {
|
|
2168
|
+
const F = String(e.options[0].value);
|
|
2169
|
+
t?.(F);
|
|
2172
2170
|
}
|
|
2173
|
-
|
|
2174
|
-
}, [r, e.options, c, t,
|
|
2175
|
-
const
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
},
|
|
2171
|
+
d(v);
|
|
2172
|
+
}, [r, e.options, c, t, d]);
|
|
2173
|
+
const g = (b) => {
|
|
2174
|
+
const v = b.target.value, F = c(v);
|
|
2175
|
+
d(F), t?.(v);
|
|
2176
|
+
}, S = {
|
|
2179
2177
|
display: "flex",
|
|
2180
2178
|
flexDirection: i,
|
|
2181
2179
|
flexWrap: i === "row" ? "wrap" : "nowrap",
|
|
@@ -2184,7 +2182,7 @@ const ft = u.memo(fr), dt = ({
|
|
|
2184
2182
|
width: "100%",
|
|
2185
2183
|
padding: i === "row" ? "8px" : void 0,
|
|
2186
2184
|
boxSizing: "border-box"
|
|
2187
|
-
},
|
|
2185
|
+
}, I = {
|
|
2188
2186
|
display: i === "column" ? "flex" : "inline-flex",
|
|
2189
2187
|
gap: "8px",
|
|
2190
2188
|
alignItems: "center",
|
|
@@ -2194,31 +2192,34 @@ const ft = u.memo(fr), dt = ({
|
|
|
2194
2192
|
width: i === "column" ? "100%" : void 0,
|
|
2195
2193
|
justifyContent: "flex-start"
|
|
2196
2194
|
};
|
|
2197
|
-
return /* @__PURE__ */ p(L, { field: e, error:
|
|
2195
|
+
return /* @__PURE__ */ p(L, { field: e, error: m, children: /* @__PURE__ */ p(
|
|
2198
2196
|
"div",
|
|
2199
2197
|
{
|
|
2200
|
-
ref: s,
|
|
2201
2198
|
className: R.input,
|
|
2202
|
-
role: "radiogroup",
|
|
2203
2199
|
"aria-labelledby": `${e.name}-label`,
|
|
2204
|
-
"aria-invalid": !!
|
|
2205
|
-
style:
|
|
2206
|
-
children: e.options.map((
|
|
2207
|
-
const
|
|
2200
|
+
"aria-invalid": !!m,
|
|
2201
|
+
style: S,
|
|
2202
|
+
children: e.options.map((b) => {
|
|
2203
|
+
const v = String(b.value), F = `${e.name}-${v}`;
|
|
2208
2204
|
return /* @__PURE__ */ A(
|
|
2209
2205
|
"label",
|
|
2210
2206
|
{
|
|
2211
2207
|
className: q(R.label),
|
|
2212
|
-
style:
|
|
2208
|
+
style: I,
|
|
2209
|
+
onMouseDown: ($) => $.preventDefault(),
|
|
2210
|
+
onClick: () => {
|
|
2211
|
+
String(r ?? "") !== v && g({ target: { value: v } });
|
|
2212
|
+
},
|
|
2213
2213
|
children: [
|
|
2214
2214
|
/* @__PURE__ */ p(
|
|
2215
2215
|
"input",
|
|
2216
2216
|
{
|
|
2217
|
+
id: F,
|
|
2217
2218
|
type: "radio",
|
|
2218
2219
|
name: e.name,
|
|
2219
|
-
value:
|
|
2220
|
-
checked: String(r ?? "") ===
|
|
2221
|
-
onChange:
|
|
2220
|
+
value: v,
|
|
2221
|
+
checked: String(r ?? "") === v,
|
|
2222
|
+
onChange: g,
|
|
2222
2223
|
style: { width: "1.1em", height: "1.1em" }
|
|
2223
2224
|
}
|
|
2224
2225
|
),
|
|
@@ -2231,12 +2232,12 @@ const ft = u.memo(fr), dt = ({
|
|
|
2231
2232
|
flex: i === "column" ? 1 : void 0,
|
|
2232
2233
|
fontWeight: 400
|
|
2233
2234
|
},
|
|
2234
|
-
children: o(
|
|
2235
|
+
children: o(b.label)
|
|
2235
2236
|
}
|
|
2236
2237
|
)
|
|
2237
2238
|
]
|
|
2238
2239
|
},
|
|
2239
|
-
|
|
2240
|
+
v
|
|
2240
2241
|
);
|
|
2241
2242
|
})
|
|
2242
2243
|
}
|
|
@@ -2257,30 +2258,30 @@ const ft = u.memo(fr), dt = ({
|
|
|
2257
2258
|
u.useEffect(() => {
|
|
2258
2259
|
n?.(g);
|
|
2259
2260
|
}, [g, n]);
|
|
2260
|
-
const
|
|
2261
|
-
(
|
|
2262
|
-
const v = Math.min(Math.max(
|
|
2261
|
+
const S = u.useCallback(
|
|
2262
|
+
(b) => {
|
|
2263
|
+
const v = Math.min(Math.max(b, 0), i);
|
|
2263
2264
|
c(v), t?.(v);
|
|
2264
2265
|
},
|
|
2265
2266
|
[i, c, t]
|
|
2266
|
-
),
|
|
2267
|
-
(
|
|
2268
|
-
switch (
|
|
2267
|
+
), I = u.useCallback(
|
|
2268
|
+
(b, v) => {
|
|
2269
|
+
switch (b.key) {
|
|
2269
2270
|
case "Enter":
|
|
2270
2271
|
case " ":
|
|
2271
|
-
|
|
2272
|
+
b.preventDefault(), S(v + 1);
|
|
2272
2273
|
break;
|
|
2273
2274
|
case "ArrowRight":
|
|
2274
2275
|
case "ArrowUp":
|
|
2275
|
-
|
|
2276
|
+
b.preventDefault(), f.current[Math.min(i - 1, v + 1)]?.focus();
|
|
2276
2277
|
break;
|
|
2277
2278
|
case "ArrowLeft":
|
|
2278
2279
|
case "ArrowDown":
|
|
2279
|
-
|
|
2280
|
+
b.preventDefault(), f.current[Math.max(0, v - 1)]?.focus();
|
|
2280
2281
|
break;
|
|
2281
2282
|
}
|
|
2282
2283
|
},
|
|
2283
|
-
[i,
|
|
2284
|
+
[i, S]
|
|
2284
2285
|
);
|
|
2285
2286
|
return /* @__PURE__ */ p(L, { field: e, error: g, children: /* @__PURE__ */ p(
|
|
2286
2287
|
"div",
|
|
@@ -2290,22 +2291,22 @@ const ft = u.memo(fr), dt = ({
|
|
|
2290
2291
|
"aria-invalid": !!g,
|
|
2291
2292
|
"aria-describedby": g ? `${e.name}-error` : void 0,
|
|
2292
2293
|
style: vt,
|
|
2293
|
-
children: Array.from({ length: i }, (
|
|
2294
|
-
const
|
|
2294
|
+
children: Array.from({ length: i }, (b, v) => {
|
|
2295
|
+
const F = v < d, V = m !== null && v <= m || F ? "gold" : "lightgray";
|
|
2295
2296
|
return /* @__PURE__ */ p(
|
|
2296
2297
|
"span",
|
|
2297
2298
|
{
|
|
2298
|
-
ref: (
|
|
2299
|
+
ref: (w) => f.current[v] = w,
|
|
2299
2300
|
role: "radio",
|
|
2300
2301
|
tabIndex: d > 0 ? v === d - 1 ? 0 : -1 : v === 0 ? 0 : -1,
|
|
2301
|
-
"aria-checked":
|
|
2302
|
+
"aria-checked": F,
|
|
2302
2303
|
"aria-label": `Rating ${v + 1}`,
|
|
2303
2304
|
title: o(`${e.displayName} ${v + 1}`),
|
|
2304
|
-
onClick: () =>
|
|
2305
|
-
onKeyDown: (
|
|
2305
|
+
onClick: () => S(v + 1),
|
|
2306
|
+
onKeyDown: (w) => I(w, v),
|
|
2306
2307
|
onMouseEnter: () => l(v),
|
|
2307
2308
|
onMouseLeave: () => l(null),
|
|
2308
|
-
style: { ...xt, color:
|
|
2309
|
+
style: { ...xt, color: V },
|
|
2309
2310
|
children: s
|
|
2310
2311
|
},
|
|
2311
2312
|
v
|
|
@@ -2374,8 +2375,8 @@ const ft = u.memo(fr), dt = ({
|
|
|
2374
2375
|
}, [l, n]);
|
|
2375
2376
|
const f = u.useCallback(
|
|
2376
2377
|
(g) => {
|
|
2377
|
-
const
|
|
2378
|
-
m(
|
|
2378
|
+
const S = g.target.value;
|
|
2379
|
+
m(S), o(S), t?.(S);
|
|
2379
2380
|
},
|
|
2380
2381
|
[o, t]
|
|
2381
2382
|
), d = isNaN(Number(s)) ? String(c) : String(Number(s));
|
|
@@ -2431,18 +2432,18 @@ const ft = u.memo(fr), dt = ({
|
|
|
2431
2432
|
u.useEffect(() => {
|
|
2432
2433
|
s === "realTime" && n?.(l);
|
|
2433
2434
|
}, [l, s, n]);
|
|
2434
|
-
const f = c, d = i, g = (
|
|
2435
|
-
if (!
|
|
2436
|
-
const
|
|
2437
|
-
return (
|
|
2438
|
-
},
|
|
2435
|
+
const f = c, d = i, g = (V, w, M) => {
|
|
2436
|
+
if (!w) return {};
|
|
2437
|
+
const x = V?.[w];
|
|
2438
|
+
return (M && x ? x[M] : void 0) ?? {};
|
|
2439
|
+
}, S = u.useMemo(() => ({
|
|
2439
2440
|
display: "inline-block",
|
|
2440
2441
|
position: "relative",
|
|
2441
2442
|
width: 44,
|
|
2442
2443
|
height: 24,
|
|
2443
2444
|
...g(f, "switch", "label"),
|
|
2444
2445
|
...g(d, void 0, "label")
|
|
2445
|
-
}), [f, d]),
|
|
2446
|
+
}), [f, d]), I = u.useMemo(() => ({
|
|
2446
2447
|
position: "absolute",
|
|
2447
2448
|
opacity: 0,
|
|
2448
2449
|
top: 0,
|
|
@@ -2455,7 +2456,7 @@ const ft = u.memo(fr), dt = ({
|
|
|
2455
2456
|
// Make hidden input non-interactive to avoid event conflicts
|
|
2456
2457
|
...g(f, "switch", "hiddenInput"),
|
|
2457
2458
|
...g(d, void 0, "hiddenInput")
|
|
2458
|
-
}), [f, d]),
|
|
2459
|
+
}), [f, d]), b = u.useMemo(() => ({
|
|
2459
2460
|
position: "absolute",
|
|
2460
2461
|
cursor: "pointer",
|
|
2461
2462
|
top: 0,
|
|
@@ -2486,8 +2487,8 @@ const ft = u.memo(fr), dt = ({
|
|
|
2486
2487
|
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.3)",
|
|
2487
2488
|
...g(f, "switch", "knob"),
|
|
2488
2489
|
...g(d, void 0, "knob")
|
|
2489
|
-
}), [f, d]),
|
|
2490
|
-
t?.(!
|
|
2490
|
+
}), [f, d]), F = !!r, $ = () => {
|
|
2491
|
+
t?.(!F);
|
|
2491
2492
|
};
|
|
2492
2493
|
return /* @__PURE__ */ p(L, { field: e, error: null, rightAlign: !1, children: /* @__PURE__ */ A("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }, children: [
|
|
2493
2494
|
/* @__PURE__ */ p(
|
|
@@ -2499,18 +2500,18 @@ const ft = u.memo(fr), dt = ({
|
|
|
2499
2500
|
children: o(e.displayName)
|
|
2500
2501
|
}
|
|
2501
2502
|
),
|
|
2502
|
-
/* @__PURE__ */ A("label", { style:
|
|
2503
|
+
/* @__PURE__ */ A("label", { style: S, children: [
|
|
2503
2504
|
/* @__PURE__ */ p(
|
|
2504
2505
|
"input",
|
|
2505
2506
|
{
|
|
2506
2507
|
id: e.name,
|
|
2507
2508
|
type: "checkbox",
|
|
2508
|
-
checked:
|
|
2509
|
+
checked: F,
|
|
2509
2510
|
readOnly: !0,
|
|
2510
2511
|
"aria-label": o(e.displayName),
|
|
2511
2512
|
"aria-invalid": !1,
|
|
2512
2513
|
"aria-describedby": void 0,
|
|
2513
|
-
style:
|
|
2514
|
+
style: I,
|
|
2514
2515
|
tabIndex: -1
|
|
2515
2516
|
}
|
|
2516
2517
|
),
|
|
@@ -2520,21 +2521,21 @@ const ft = u.memo(fr), dt = ({
|
|
|
2520
2521
|
role: "switch",
|
|
2521
2522
|
"data-testid": "switch",
|
|
2522
2523
|
tabIndex: 0,
|
|
2523
|
-
"aria-checked":
|
|
2524
|
+
"aria-checked": F,
|
|
2524
2525
|
"aria-invalid": !1,
|
|
2525
2526
|
"aria-describedby": void 0,
|
|
2526
2527
|
onClick: $,
|
|
2527
|
-
onKeyDown: (
|
|
2528
|
-
(
|
|
2528
|
+
onKeyDown: (V) => {
|
|
2529
|
+
(V.key === " " || V.key === "Spacebar" || V.key === "Space" || V.key === "Enter") && (V.preventDefault(), $());
|
|
2529
2530
|
},
|
|
2530
|
-
className: `reactaform-switch ${
|
|
2531
|
-
style:
|
|
2531
|
+
className: `reactaform-switch ${F ? "active checked on" : ""} `,
|
|
2532
|
+
style: F ? { ...b, backgroundColor: "var(--reactaform-switch-on-bg, #22c55e)", borderColor: "var(--reactaform-switch-on-border, #16a34a)" } : b,
|
|
2532
2533
|
children: /* @__PURE__ */ p(
|
|
2533
2534
|
"span",
|
|
2534
2535
|
{
|
|
2535
2536
|
style: {
|
|
2536
2537
|
...v,
|
|
2537
|
-
transform:
|
|
2538
|
+
transform: F ? "translateX(20px)" : void 0
|
|
2538
2539
|
}
|
|
2539
2540
|
}
|
|
2540
2541
|
)
|
|
@@ -2862,42 +2863,42 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2862
2863
|
t: c
|
|
2863
2864
|
}) => {
|
|
2864
2865
|
const [i, s] = u.useState(!1), [m, l] = u.useState(null), [f, d] = u.useState([]), g = u.useCallback(
|
|
2865
|
-
(
|
|
2866
|
+
(b) => {
|
|
2866
2867
|
if (e) return;
|
|
2867
2868
|
const v = parseFloat(r);
|
|
2868
2869
|
if (!Number.isFinite(v)) return;
|
|
2869
|
-
const
|
|
2870
|
-
l({ x:
|
|
2870
|
+
const F = b.currentTarget.getBoundingClientRect();
|
|
2871
|
+
l({ x: F.left, y: F.bottom });
|
|
2871
2872
|
const $ = [];
|
|
2872
2873
|
if (n === "temperature")
|
|
2873
|
-
a.units.forEach((
|
|
2874
|
-
const
|
|
2875
|
-
Number.isFinite(
|
|
2876
|
-
label: `${
|
|
2877
|
-
value:
|
|
2878
|
-
unit:
|
|
2874
|
+
a.units.forEach((w) => {
|
|
2875
|
+
const M = dr(t, w, v);
|
|
2876
|
+
Number.isFinite(M) && $.push({
|
|
2877
|
+
label: `${M.toFixed(6)} ${c(w)}`,
|
|
2878
|
+
value: M.toString(),
|
|
2879
|
+
unit: w
|
|
2879
2880
|
});
|
|
2880
2881
|
});
|
|
2881
2882
|
else {
|
|
2882
|
-
const
|
|
2883
|
-
|
|
2884
|
-
const h = v /
|
|
2883
|
+
const w = a.factors[t];
|
|
2884
|
+
w !== void 0 && Object.entries(a.factors).forEach(([M, x]) => {
|
|
2885
|
+
const h = v / w * x;
|
|
2885
2886
|
Number.isFinite(h) && $.push({
|
|
2886
|
-
label: `${h.toFixed(6)} ${c(
|
|
2887
|
+
label: `${h.toFixed(6)} ${c(M)}`,
|
|
2887
2888
|
value: h.toString(),
|
|
2888
|
-
unit:
|
|
2889
|
+
unit: M
|
|
2889
2890
|
});
|
|
2890
2891
|
});
|
|
2891
2892
|
}
|
|
2892
2893
|
d($), s($.length > 0);
|
|
2893
2894
|
},
|
|
2894
2895
|
[e, r, t, n, a, c]
|
|
2895
|
-
),
|
|
2896
|
-
(
|
|
2897
|
-
s(!1), l(null), o(
|
|
2896
|
+
), S = u.useCallback(
|
|
2897
|
+
(b) => {
|
|
2898
|
+
s(!1), l(null), o(b);
|
|
2898
2899
|
},
|
|
2899
2900
|
[o]
|
|
2900
|
-
),
|
|
2901
|
+
), I = u.useCallback(() => {
|
|
2901
2902
|
s(!1), l(null);
|
|
2902
2903
|
}, []);
|
|
2903
2904
|
return /* @__PURE__ */ A(Ne, { children: [
|
|
@@ -2930,8 +2931,8 @@ const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2930
2931
|
{
|
|
2931
2932
|
pos: m,
|
|
2932
2933
|
options: f,
|
|
2933
|
-
onClose:
|
|
2934
|
-
onClickOption:
|
|
2934
|
+
onClose: I,
|
|
2935
|
+
onClickOption: S
|
|
2935
2936
|
}
|
|
2936
2937
|
)
|
|
2937
2938
|
] });
|
|
@@ -2944,45 +2945,45 @@ const Mt = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
2944
2945
|
}, [s]), u.useEffect(() => {
|
|
2945
2946
|
g(m);
|
|
2946
2947
|
}, [m]);
|
|
2947
|
-
const
|
|
2948
|
+
const S = o([l, d]);
|
|
2948
2949
|
u.useEffect(() => {
|
|
2949
|
-
n?.(
|
|
2950
|
-
}, [
|
|
2951
|
-
const
|
|
2952
|
-
(
|
|
2953
|
-
const
|
|
2954
|
-
f(
|
|
2950
|
+
n?.(S);
|
|
2951
|
+
}, [S, n]);
|
|
2952
|
+
const I = u.useCallback(
|
|
2953
|
+
(V) => {
|
|
2954
|
+
const w = V.target.value;
|
|
2955
|
+
f(w), o([w, d]), t?.([w, d]);
|
|
2955
2956
|
},
|
|
2956
2957
|
[d, o, t]
|
|
2957
|
-
),
|
|
2958
|
-
(
|
|
2959
|
-
const
|
|
2960
|
-
g(
|
|
2958
|
+
), b = u.useCallback(
|
|
2959
|
+
(V) => {
|
|
2960
|
+
const w = V.target.value;
|
|
2961
|
+
g(w), o([l, w]), t?.([l, w]);
|
|
2961
2962
|
},
|
|
2962
2963
|
[l, o, t]
|
|
2963
2964
|
), v = u.useCallback(
|
|
2964
|
-
(
|
|
2965
|
-
f(
|
|
2965
|
+
(V) => {
|
|
2966
|
+
f(V.value), g(V.unit), t?.([V.value, V.unit]);
|
|
2966
2967
|
},
|
|
2967
2968
|
[t]
|
|
2968
|
-
),
|
|
2969
|
-
() => i ? i.units.map((
|
|
2969
|
+
), F = u.useMemo(
|
|
2970
|
+
() => i ? i.units.map((V) => /* @__PURE__ */ p("option", { value: V, children: a(V) }, V)) : [],
|
|
2970
2971
|
[i, a]
|
|
2971
2972
|
);
|
|
2972
2973
|
if (!c || !i) return null;
|
|
2973
|
-
const $ = !!
|
|
2974
|
-
return /* @__PURE__ */ p(L, { field: e, error:
|
|
2974
|
+
const $ = !!S || !l.trim();
|
|
2975
|
+
return /* @__PURE__ */ p(L, { field: e, error: S, children: /* @__PURE__ */ A("div", { style: { display: "flex", alignItems: "center", gap: "var(--reactaform-unit-gap, 8px)", width: "100%" }, children: [
|
|
2975
2976
|
/* @__PURE__ */ p(
|
|
2976
2977
|
"input",
|
|
2977
2978
|
{
|
|
2978
2979
|
id: e.name,
|
|
2979
2980
|
type: "text",
|
|
2980
2981
|
value: l,
|
|
2981
|
-
onChange:
|
|
2982
|
+
onChange: I,
|
|
2982
2983
|
style: { flex: "2 1 0" },
|
|
2983
2984
|
className: q(R.input, R.textInput),
|
|
2984
|
-
"aria-invalid": !!
|
|
2985
|
-
"aria-describedby":
|
|
2985
|
+
"aria-invalid": !!S,
|
|
2986
|
+
"aria-describedby": S ? `${e.name}-error` : void 0
|
|
2986
2987
|
}
|
|
2987
2988
|
),
|
|
2988
2989
|
/* @__PURE__ */ p(
|
|
@@ -2990,12 +2991,12 @@ const Mt = ({ field: e, value: r, onChange: t, onError: n }) => {
|
|
|
2990
2991
|
{
|
|
2991
2992
|
id: `${e.name}-unit`,
|
|
2992
2993
|
value: d,
|
|
2993
|
-
onChange:
|
|
2994
|
+
onChange: b,
|
|
2994
2995
|
style: { flex: "1 1 0" },
|
|
2995
2996
|
className: q(R.input, R.inputSelect),
|
|
2996
|
-
"aria-invalid": !!
|
|
2997
|
-
"aria-describedby":
|
|
2998
|
-
children:
|
|
2997
|
+
"aria-invalid": !!S,
|
|
2998
|
+
"aria-describedby": S ? `${e.name}-error` : void 0,
|
|
2999
|
+
children: F
|
|
2999
3000
|
}
|
|
3000
3001
|
),
|
|
3001
3002
|
/* @__PURE__ */ p(
|
|
@@ -3233,7 +3234,7 @@ const xr = (e, r, t, n, a) => {
|
|
|
3233
3234
|
/* @__PURE__ */ p("span", { children: s(e) }),
|
|
3234
3235
|
/* @__PURE__ */ p("span", { children: r ? "▼" : "▶" })
|
|
3235
3236
|
] }),
|
|
3236
|
-
r && t.map((
|
|
3237
|
+
r && t.map((S) => xr(S, n, a, o, c))
|
|
3237
3238
|
] });
|
|
3238
3239
|
});
|
|
3239
3240
|
wr.displayName = "FieldGroup";
|
|
@@ -3241,13 +3242,13 @@ const Lt = (e, r, t, n, a, o, c, i, s, m) => {
|
|
|
3241
3242
|
const l = r.slice(0, i).filter((g) => c[g.name]), f = zt(l), d = [];
|
|
3242
3243
|
return f.groups.forEach((g) => {
|
|
3243
3244
|
if (g.name) {
|
|
3244
|
-
const
|
|
3245
|
+
const S = e[g.name] ?? !0;
|
|
3245
3246
|
d.push(
|
|
3246
3247
|
/* @__PURE__ */ p(
|
|
3247
3248
|
wr,
|
|
3248
3249
|
{
|
|
3249
3250
|
groupName: g.name,
|
|
3250
|
-
isOpen:
|
|
3251
|
+
isOpen: S,
|
|
3251
3252
|
fields: g.fields,
|
|
3252
3253
|
valuesMap: t,
|
|
3253
3254
|
handleChange: a,
|
|
@@ -3260,7 +3261,7 @@ const Lt = (e, r, t, n, a, o, c, i, s, m) => {
|
|
|
3260
3261
|
)
|
|
3261
3262
|
);
|
|
3262
3263
|
} else
|
|
3263
|
-
g.fields.forEach((
|
|
3264
|
+
g.fields.forEach((S) => d.push(xr(S, t, a, o, m)));
|
|
3264
3265
|
}), d;
|
|
3265
3266
|
}, Ot = (e) => {
|
|
3266
3267
|
const r = {};
|
|
@@ -3338,21 +3339,21 @@ async function qt(e, r, t, n, a) {
|
|
|
3338
3339
|
if (g === "")
|
|
3339
3340
|
c[l] = 0;
|
|
3340
3341
|
else {
|
|
3341
|
-
const
|
|
3342
|
-
isNaN(
|
|
3342
|
+
const S = Number(g);
|
|
3343
|
+
isNaN(S) ? i.push(n("Invalid number format for field {{1}}", m.displayName || l)) : c[l] = S;
|
|
3343
3344
|
}
|
|
3344
3345
|
} else if (d === "int-array" || d === "float-array") {
|
|
3345
|
-
const g = String(f).split(",").map((
|
|
3346
|
-
let
|
|
3347
|
-
for (const
|
|
3348
|
-
const v = Number(
|
|
3346
|
+
const g = String(f).split(",").map((b) => b.trim()).filter(Boolean), S = [];
|
|
3347
|
+
let I = !1;
|
|
3348
|
+
for (const b of g) {
|
|
3349
|
+
const v = Number(b);
|
|
3349
3350
|
if (isNaN(v)) {
|
|
3350
|
-
i.push(n("Invalid number {{1}} in array for field {{2}}",
|
|
3351
|
+
i.push(n("Invalid number {{1}} in array for field {{2}}", b, m.displayName || l)), I = !0;
|
|
3351
3352
|
break;
|
|
3352
3353
|
}
|
|
3353
|
-
|
|
3354
|
+
S.push(v);
|
|
3354
3355
|
}
|
|
3355
|
-
|
|
3356
|
+
I || (c[l] = S);
|
|
3356
3357
|
}
|
|
3357
3358
|
} catch (g) {
|
|
3358
3359
|
i.push(n("Error processing field {{1}}: {{2}}", m.displayName || l, g instanceof Error ? g.message : String(g)));
|
|
@@ -3474,9 +3475,9 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3474
3475
|
const { properties: a, displayName: o } = e, c = j(), { t: i, formStyle: s, language: m } = c, l = {
|
|
3475
3476
|
...c,
|
|
3476
3477
|
definitionName: e?.name ?? c.definitionName
|
|
3477
|
-
}, [f, d] = u.useState("en"), [g,
|
|
3478
|
+
}, [f, d] = u.useState("en"), [g, S] = u.useState([]), [I, b] = u.useState({}), [v, F] = u.useState(
|
|
3478
3479
|
{}
|
|
3479
|
-
), [$,
|
|
3480
|
+
), [$, V] = u.useState({}), [w, M] = u.useState({}), [x, h] = u.useState({}), [y, C] = u.useState(null), [k, E] = u.useState(null), [N, P] = u.useState(0), [H, Y] = u.useState(!1), [ne, ae] = u.useState(r.name || ""), G = u.useRef(r), de = u.useRef(!1);
|
|
3480
3481
|
u.useEffect(() => {
|
|
3481
3482
|
const z = Object.fromEntries(
|
|
3482
3483
|
a.map((D) => [
|
|
@@ -3514,34 +3515,34 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3514
3515
|
D.group && !(D.group in K) && (K[D.group] = !0);
|
|
3515
3516
|
});
|
|
3516
3517
|
const X = requestAnimationFrame(() => {
|
|
3517
|
-
|
|
3518
|
+
S(B), b(z), F(U), V(
|
|
3518
3519
|
Tt(B, U, J, z)
|
|
3519
|
-
),
|
|
3520
|
+
), M(K), Y(!0), ae(r.name);
|
|
3520
3521
|
});
|
|
3521
3522
|
return () => cancelAnimationFrame(X);
|
|
3522
3523
|
}, [a, r, e]), u.useEffect(() => {
|
|
3523
|
-
if (!H ||
|
|
3524
|
+
if (!H || N >= g.length) return;
|
|
3524
3525
|
const z = setTimeout(() => {
|
|
3525
3526
|
P(
|
|
3526
3527
|
(B) => Math.min(B + t, g.length)
|
|
3527
3528
|
);
|
|
3528
3529
|
}, n);
|
|
3529
3530
|
return () => clearTimeout(z);
|
|
3530
|
-
}, [H,
|
|
3531
|
+
}, [H, N, g.length, t, n]);
|
|
3531
3532
|
const Vr = u.useCallback(
|
|
3532
3533
|
(z, B) => {
|
|
3533
|
-
C(null),
|
|
3534
|
-
const J = { ...U, [z]: B }, K =
|
|
3534
|
+
C(null), E(null), F((U) => {
|
|
3535
|
+
const J = { ...U, [z]: B }, K = I[z];
|
|
3535
3536
|
return K && [
|
|
3536
3537
|
"checkbox",
|
|
3537
3538
|
"dropdown",
|
|
3538
3539
|
"multi-select",
|
|
3539
3540
|
"radio",
|
|
3540
3541
|
"switch"
|
|
3541
|
-
].includes(K.type) &&
|
|
3542
|
+
].includes(K.type) && V(
|
|
3542
3543
|
(D) => jt(
|
|
3543
3544
|
D,
|
|
3544
|
-
|
|
3545
|
+
I,
|
|
3545
3546
|
J,
|
|
3546
3547
|
z,
|
|
3547
3548
|
String(B)
|
|
@@ -3549,12 +3550,12 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3549
3550
|
), J;
|
|
3550
3551
|
});
|
|
3551
3552
|
},
|
|
3552
|
-
[
|
|
3553
|
+
[I, C, E]
|
|
3553
3554
|
);
|
|
3554
3555
|
u.useEffect(() => {
|
|
3555
3556
|
let z = 0;
|
|
3556
3557
|
return z = requestAnimationFrame(() => {
|
|
3557
|
-
m !== f && (d(m || "en"), C(null),
|
|
3558
|
+
m !== f && (d(m || "en"), C(null), E(null));
|
|
3558
3559
|
}), () => cancelAnimationFrame(z);
|
|
3559
3560
|
}, [m, f]), u.useEffect(() => {
|
|
3560
3561
|
let z = 0;
|
|
@@ -3563,7 +3564,7 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3563
3564
|
de.current = !1, G.current = r, ae(r.name || "");
|
|
3564
3565
|
return;
|
|
3565
3566
|
}
|
|
3566
|
-
G.current = r, C(null),
|
|
3567
|
+
G.current = r, C(null), E(null), ae(r.name || "");
|
|
3567
3568
|
}), () => cancelAnimationFrame(z);
|
|
3568
3569
|
}, [r, r.name]);
|
|
3569
3570
|
const $r = u.useCallback((z, B) => {
|
|
@@ -3572,7 +3573,7 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3572
3573
|
de.current = !0;
|
|
3573
3574
|
const z = G.current?.name;
|
|
3574
3575
|
G.current.name = ne;
|
|
3575
|
-
let B =
|
|
3576
|
+
let B = x;
|
|
3576
3577
|
if (l.fieldValidationMode === "onSubmission") {
|
|
3577
3578
|
const X = {};
|
|
3578
3579
|
if (g.forEach((D) => {
|
|
@@ -3581,20 +3582,20 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3581
3582
|
const re = mr(l.definitionName, D, ee, i);
|
|
3582
3583
|
re && (X[D.name] = re);
|
|
3583
3584
|
}), h(X), B = X, Object.keys(X).length > 0) {
|
|
3584
|
-
C(i("Please fix validation errors before submitting the form.")),
|
|
3585
|
+
C(i("Please fix validation errors before submitting the form.")), E(!1);
|
|
3585
3586
|
return;
|
|
3586
3587
|
} else
|
|
3587
|
-
C(null),
|
|
3588
|
+
C(null), E(null);
|
|
3588
3589
|
}
|
|
3589
3590
|
const U = await qt(e, G.current, v, i, B), J = typeof U.message == "string" ? U.message : String(U.message), K = Object.values(U.errors ?? {}).join(`
|
|
3590
3591
|
`);
|
|
3591
3592
|
C(K ? J + `
|
|
3592
|
-
` + K : J),
|
|
3593
|
+
` + K : J), E(U.success), U.success || (G.current.name = z ?? G.current.name, ae(z ?? ""));
|
|
3593
3594
|
}, Ar = (z) => {
|
|
3594
|
-
|
|
3595
|
+
M((B) => ({ ...B, [z]: !B[z] }));
|
|
3595
3596
|
}, Dr = u.useMemo(
|
|
3596
|
-
() => l.fieldValidationMode === "realTime" ? Object.values(
|
|
3597
|
-
[
|
|
3597
|
+
() => l.fieldValidationMode === "realTime" ? Object.values(x).some(Boolean) : !1,
|
|
3598
|
+
[x, l.fieldValidationMode]
|
|
3598
3599
|
);
|
|
3599
3600
|
return /* @__PURE__ */ p(Ie.Provider, { value: l, children: /* @__PURE__ */ A("div", { style: s.container, children: [
|
|
3600
3601
|
o && /* @__PURE__ */ p("h2", { style: s.titleStyle, children: i(o) }),
|
|
@@ -3602,9 +3603,9 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3602
3603
|
kr,
|
|
3603
3604
|
{
|
|
3604
3605
|
message: y,
|
|
3605
|
-
success:
|
|
3606
|
+
success: k,
|
|
3606
3607
|
onDismiss: () => {
|
|
3607
|
-
C(null),
|
|
3608
|
+
C(null), E(null);
|
|
3608
3609
|
},
|
|
3609
3610
|
t: i
|
|
3610
3611
|
}
|
|
@@ -3614,31 +3615,31 @@ const Ut = ({ onClick: e, disabled: r = !1, t }) => {
|
|
|
3614
3615
|
{
|
|
3615
3616
|
name: ne,
|
|
3616
3617
|
onChange: (z) => {
|
|
3617
|
-
ae(z), C(null),
|
|
3618
|
+
ae(z), C(null), E(null);
|
|
3618
3619
|
}
|
|
3619
3620
|
}
|
|
3620
3621
|
),
|
|
3621
3622
|
/* @__PURE__ */ A(Ne, { children: [
|
|
3622
3623
|
Lt(
|
|
3623
|
-
|
|
3624
|
+
w,
|
|
3624
3625
|
g,
|
|
3625
3626
|
v,
|
|
3626
3627
|
i,
|
|
3627
3628
|
Vr,
|
|
3628
3629
|
$r,
|
|
3629
3630
|
$,
|
|
3630
|
-
|
|
3631
|
+
N,
|
|
3631
3632
|
Ar,
|
|
3632
|
-
|
|
3633
|
+
x
|
|
3633
3634
|
),
|
|
3634
|
-
|
|
3635
|
+
N < g.length && /* @__PURE__ */ p(
|
|
3635
3636
|
"div",
|
|
3636
3637
|
{
|
|
3637
3638
|
style: {
|
|
3638
3639
|
fontSize: "0.9em",
|
|
3639
3640
|
color: "var(--reactaform-text-muted, #666)"
|
|
3640
3641
|
},
|
|
3641
|
-
children: i(`Loading more fields... (${
|
|
3642
|
+
children: i(`Loading more fields... (${N}/${g.length})`)
|
|
3642
3643
|
}
|
|
3643
3644
|
)
|
|
3644
3645
|
] }),
|
|
@@ -4236,50 +4237,50 @@ const En = (e) => ({
|
|
|
4236
4237
|
const s = r, m = o, l = a, f = n, d = u.useMemo(
|
|
4237
4238
|
() => t ?? {},
|
|
4238
4239
|
[t]
|
|
4239
|
-
), [g,
|
|
4240
|
+
), [g, S] = u.useState({}), [I, b] = u.useState({});
|
|
4240
4241
|
u.useEffect(() => {
|
|
4241
|
-
let
|
|
4242
|
+
let x = !0;
|
|
4242
4243
|
return (async () => {
|
|
4243
4244
|
if (f === "en") {
|
|
4244
|
-
|
|
4245
|
+
x && (S({}), b({}));
|
|
4245
4246
|
return;
|
|
4246
4247
|
}
|
|
4247
4248
|
try {
|
|
4248
4249
|
const y = await Kt(f), C = y.success ? y.translations : {};
|
|
4249
|
-
|
|
4250
|
-
const
|
|
4251
|
-
|
|
4250
|
+
x && S(C);
|
|
4251
|
+
const k = await Gt(f, m), E = k.success ? k.translations : {};
|
|
4252
|
+
x && b(E);
|
|
4252
4253
|
} catch {
|
|
4253
|
-
|
|
4254
|
+
x && (S({}), b({}));
|
|
4254
4255
|
}
|
|
4255
4256
|
})(), () => {
|
|
4256
|
-
|
|
4257
|
+
x = !1;
|
|
4257
4258
|
};
|
|
4258
4259
|
}, [f, m]);
|
|
4259
|
-
const v = u.useMemo(() => En(d), [d]),
|
|
4260
|
-
() => Yt(f, g,
|
|
4261
|
-
[f, g,
|
|
4262
|
-
),
|
|
4263
|
-
(
|
|
4260
|
+
const v = u.useMemo(() => En(d), [d]), F = u.useMemo(() => Nn(d), [d]), $ = u.useMemo(
|
|
4261
|
+
() => Yt(f, g, I),
|
|
4262
|
+
[f, g, I]
|
|
4263
|
+
), V = u.useCallback(
|
|
4264
|
+
(x, ...h) => $(x, ...h),
|
|
4264
4265
|
[$]
|
|
4265
|
-
),
|
|
4266
|
+
), w = u.useMemo(
|
|
4266
4267
|
() => ({
|
|
4267
4268
|
definitionName: s,
|
|
4268
4269
|
language: f,
|
|
4269
4270
|
theme: l,
|
|
4270
4271
|
formStyle: v,
|
|
4271
|
-
fieldStyle:
|
|
4272
|
-
t:
|
|
4272
|
+
fieldStyle: F,
|
|
4273
|
+
t: V,
|
|
4273
4274
|
fieldValidationMode: c
|
|
4274
4275
|
}),
|
|
4275
|
-
[s, f, l,
|
|
4276
|
-
),
|
|
4277
|
-
return /* @__PURE__ */ p(Ie.Provider, { value:
|
|
4276
|
+
[s, f, l, F, v, V, c]
|
|
4277
|
+
), M = d?.height ? { height: "100%" } : void 0;
|
|
4278
|
+
return /* @__PURE__ */ p(Ie.Provider, { value: w, children: /* @__PURE__ */ p(
|
|
4278
4279
|
"div",
|
|
4279
4280
|
{
|
|
4280
4281
|
"data-reactaform-theme": l,
|
|
4281
4282
|
className: i,
|
|
4282
|
-
style:
|
|
4283
|
+
style: M,
|
|
4283
4284
|
children: e
|
|
4284
4285
|
}
|
|
4285
4286
|
) });
|
|
@@ -4765,22 +4766,22 @@ function Zn(e, r, t = {}) {
|
|
|
4765
4766
|
success: !1,
|
|
4766
4767
|
error: "Instance must be a valid object"
|
|
4767
4768
|
};
|
|
4768
|
-
const m = [], l = [], f = {}, g = (Fr(r) || Q(r) && Array.isArray(r.properties) ? r.properties : []).filter(Oe),
|
|
4769
|
-
for (const [
|
|
4770
|
-
if (i.includes(
|
|
4771
|
-
l.push(
|
|
4769
|
+
const m = [], l = [], f = {}, g = (Fr(r) || Q(r) && Array.isArray(r.properties) ? r.properties : []).filter(Oe), S = new Map(g.map((b) => [b.name, b]));
|
|
4770
|
+
for (const [b, v] of Object.entries(e)) {
|
|
4771
|
+
if (i.includes(b)) {
|
|
4772
|
+
l.push(b);
|
|
4772
4773
|
continue;
|
|
4773
4774
|
}
|
|
4774
|
-
if (s.length > 0 && !s.includes(
|
|
4775
|
-
l.push(
|
|
4775
|
+
if (s.length > 0 && !s.includes(b)) {
|
|
4776
|
+
l.push(b);
|
|
4776
4777
|
continue;
|
|
4777
4778
|
}
|
|
4778
4779
|
if (v === void 0) continue;
|
|
4779
|
-
const
|
|
4780
|
+
const F = S.get(b);
|
|
4780
4781
|
try {
|
|
4781
|
-
f[
|
|
4782
|
+
f[b] = Rn(v, F, { dateFormat: a, fileHandling: o });
|
|
4782
4783
|
} catch ($) {
|
|
4783
|
-
m.push(`Error serializing field '${
|
|
4784
|
+
m.push(`Error serializing field '${b}': ${String($)}`), f[b] = null;
|
|
4784
4785
|
}
|
|
4785
4786
|
}
|
|
4786
4787
|
return n && (f._metadata = {
|
|
@@ -4890,10 +4891,10 @@ function Qn(e, r, t = {}) {
|
|
|
4890
4891
|
let i;
|
|
4891
4892
|
try {
|
|
4892
4893
|
i = JSON.parse(e);
|
|
4893
|
-
} catch (
|
|
4894
|
+
} catch (I) {
|
|
4894
4895
|
return {
|
|
4895
4896
|
success: !1,
|
|
4896
|
-
error: `Invalid JSON: ${
|
|
4897
|
+
error: `Invalid JSON: ${I instanceof Error ? I.message : "Unknown parsing error"}`
|
|
4897
4898
|
};
|
|
4898
4899
|
}
|
|
4899
4900
|
if (!i || typeof i != "object")
|
|
@@ -4901,29 +4902,29 @@ function Qn(e, r, t = {}) {
|
|
|
4901
4902
|
success: !1,
|
|
4902
4903
|
error: "Parsed data must be an object"
|
|
4903
4904
|
};
|
|
4904
|
-
const s = [], m = [], l = {}, d = (Fr(r) || Q(r) && Array.isArray(r.properties) ? r.properties : []).filter(Oe), g = new Map(d.map((
|
|
4905
|
-
for (const
|
|
4906
|
-
const
|
|
4905
|
+
const s = [], m = [], l = {}, d = (Fr(r) || Q(r) && Array.isArray(r.properties) ? r.properties : []).filter(Oe), g = new Map(d.map((I) => [I.name, I]));
|
|
4906
|
+
for (const I of d) {
|
|
4907
|
+
const b = I.name, v = i[b];
|
|
4907
4908
|
if (v === void 0) {
|
|
4908
|
-
n &&
|
|
4909
|
+
n && I.required && m.push(`Required field '${b}' is missing`);
|
|
4909
4910
|
continue;
|
|
4910
4911
|
}
|
|
4911
4912
|
try {
|
|
4912
|
-
l[
|
|
4913
|
-
} catch (
|
|
4914
|
-
const $ = `Error deserializing field '${
|
|
4915
|
-
n ? m.push($) : (s.push($), l[
|
|
4913
|
+
l[b] = An(v, I, { validateTypes: a, dateFormat: c });
|
|
4914
|
+
} catch (F) {
|
|
4915
|
+
const $ = `Error deserializing field '${b}': ${String(F)}`;
|
|
4916
|
+
n ? m.push($) : (s.push($), l[b] = v);
|
|
4916
4917
|
}
|
|
4917
4918
|
}
|
|
4918
4919
|
if (o)
|
|
4919
|
-
for (const [
|
|
4920
|
-
!g.has(
|
|
4921
|
-
const
|
|
4920
|
+
for (const [I, b] of Object.entries(i))
|
|
4921
|
+
!g.has(I) && I !== "_metadata" && (n && s.push(`Unknown field '${I}' preserved`), l[I] = b);
|
|
4922
|
+
const S = m.length > 0;
|
|
4922
4923
|
return {
|
|
4923
|
-
success: !
|
|
4924
|
+
success: !S,
|
|
4924
4925
|
data: l,
|
|
4925
4926
|
warnings: s.length > 0 ? s : void 0,
|
|
4926
|
-
validationErrors:
|
|
4927
|
+
validationErrors: S ? m : void 0
|
|
4927
4928
|
};
|
|
4928
4929
|
} catch (n) {
|
|
4929
4930
|
return {
|
|
@@ -5039,8 +5040,8 @@ function ra(e, r = {}) {
|
|
|
5039
5040
|
s ? a.properties = s.map((l, f) => {
|
|
5040
5041
|
const d = Q(l) ? l : {}, g = { ...d };
|
|
5041
5042
|
if (!d.name) {
|
|
5042
|
-
const
|
|
5043
|
-
t ? c.push(
|
|
5043
|
+
const S = `Property at index ${f} missing 'name'`;
|
|
5044
|
+
t ? c.push(S) : (o.push(`${S}, using 'field_${f}'`), g.name = `field_${f}`);
|
|
5044
5045
|
}
|
|
5045
5046
|
return d.displayName || (g.displayName = d.name || `Field ${f}`), d.type || (t && n ? c.push(`Property '${d.name || f}' missing 'type'`) : (o.push(`Property '${d.name || f}' missing 'type', using 'string'`), g.type = "string")), d.defaultValue === void 0 && (g.defaultValue = null), d.required === void 0 && (g.required = !1), g;
|
|
5046
5047
|
}) : t ? c.push("Properties must be an array") : (o.push("Properties not found or invalid, using empty array"), a.properties = []);
|