reactaform 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactaform.cjs.js +6 -6
- package/dist/reactaform.css +1 -1
- package/dist/reactaform.es.js +1568 -1445
- package/package.json +2 -1
package/dist/reactaform.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import F, { createContext as yr, useContext as xr, useRef as E, useEffect as k, useCallback as X, useState as V, useMemo as J, memo as ve } from "react";
|
|
2
|
+
import $e from "react-dom";
|
|
3
3
|
const vr = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
4
4
|
\r
|
|
5
5
|
/* Default Light Theme */\r
|
|
@@ -140,7 +140,7 @@ const vr = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
140
140
|
line-height: 1.4;\r
|
|
141
141
|
min-width: 100px;\r
|
|
142
142
|
color: var(--reactaform-text-color);\r
|
|
143
|
-
font-weight:
|
|
143
|
+
font-weight: 600;\r
|
|
144
144
|
font-size: var(--reactaform-font-size);\r
|
|
145
145
|
user-select: none;\r
|
|
146
146
|
}\r
|
|
@@ -287,28 +287,28 @@ const vr = `/* ReactaForm CSS Custom Properties (CSS Variables) */\r
|
|
|
287
287
|
\r
|
|
288
288
|
}\r
|
|
289
289
|
`;
|
|
290
|
-
var be = { exports: {} },
|
|
290
|
+
var be = { exports: {} }, fe = {};
|
|
291
291
|
var qe;
|
|
292
292
|
function wr() {
|
|
293
|
-
if (qe) return
|
|
293
|
+
if (qe) return fe;
|
|
294
294
|
qe = 1;
|
|
295
295
|
var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
296
|
-
function n(
|
|
296
|
+
function n(a, t, o) {
|
|
297
297
|
var s = null;
|
|
298
|
-
if (
|
|
299
|
-
|
|
298
|
+
if (o !== void 0 && (s = "" + o), t.key !== void 0 && (s = "" + t.key), "key" in t) {
|
|
299
|
+
o = {};
|
|
300
300
|
for (var i in t)
|
|
301
|
-
i !== "key" && (
|
|
302
|
-
} else
|
|
303
|
-
return t =
|
|
301
|
+
i !== "key" && (o[i] = t[i]);
|
|
302
|
+
} else o = t;
|
|
303
|
+
return t = o.ref, {
|
|
304
304
|
$$typeof: e,
|
|
305
|
-
type:
|
|
305
|
+
type: a,
|
|
306
306
|
key: s,
|
|
307
307
|
ref: t !== void 0 ? t : null,
|
|
308
|
-
props:
|
|
308
|
+
props: o
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
return
|
|
311
|
+
return fe.Fragment = r, fe.jsx = n, fe.jsxs = n, fe;
|
|
312
312
|
}
|
|
313
313
|
var pe = {};
|
|
314
314
|
var Be;
|
|
@@ -317,20 +317,20 @@ function Sr() {
|
|
|
317
317
|
function e(h) {
|
|
318
318
|
if (h == null) return null;
|
|
319
319
|
if (typeof h == "function")
|
|
320
|
-
return h.$$typeof ===
|
|
320
|
+
return h.$$typeof === O ? null : h.displayName || h.name || null;
|
|
321
321
|
if (typeof h == "string") return h;
|
|
322
322
|
switch (h) {
|
|
323
323
|
case y:
|
|
324
324
|
return "Fragment";
|
|
325
|
-
case v:
|
|
326
|
-
return "Profiler";
|
|
327
325
|
case x:
|
|
326
|
+
return "Profiler";
|
|
327
|
+
case C:
|
|
328
328
|
return "StrictMode";
|
|
329
|
-
case
|
|
329
|
+
case w:
|
|
330
330
|
return "Suspense";
|
|
331
331
|
case I:
|
|
332
332
|
return "SuspenseList";
|
|
333
|
-
case
|
|
333
|
+
case $:
|
|
334
334
|
return "Activity";
|
|
335
335
|
}
|
|
336
336
|
if (typeof h == "object")
|
|
@@ -339,19 +339,19 @@ function Sr() {
|
|
|
339
339
|
), h.$$typeof) {
|
|
340
340
|
case f:
|
|
341
341
|
return "Portal";
|
|
342
|
-
case
|
|
342
|
+
case N:
|
|
343
343
|
return h.displayName || "Context";
|
|
344
|
-
case
|
|
344
|
+
case j:
|
|
345
345
|
return (h._context.displayName || "Context") + ".Consumer";
|
|
346
|
-
case
|
|
347
|
-
var
|
|
348
|
-
return h = h.displayName, h || (h =
|
|
349
|
-
case S:
|
|
350
|
-
return E = h.displayName || null, E !== null ? E : e(h.type) || "Memo";
|
|
346
|
+
case v:
|
|
347
|
+
var S = h.render;
|
|
348
|
+
return h = h.displayName, h || (h = S.displayName || S.name || "", h = h !== "" ? "ForwardRef(" + h + ")" : "ForwardRef"), h;
|
|
351
349
|
case A:
|
|
352
|
-
|
|
350
|
+
return S = h.displayName || null, S !== null ? S : e(h.type) || "Memo";
|
|
351
|
+
case R:
|
|
352
|
+
S = h._payload, h = h._init;
|
|
353
353
|
try {
|
|
354
|
-
return e(h(
|
|
354
|
+
return e(h(S));
|
|
355
355
|
} catch {
|
|
356
356
|
}
|
|
357
357
|
}
|
|
@@ -363,74 +363,74 @@ function Sr() {
|
|
|
363
363
|
function n(h) {
|
|
364
364
|
try {
|
|
365
365
|
r(h);
|
|
366
|
-
var
|
|
366
|
+
var S = !1;
|
|
367
367
|
} catch {
|
|
368
|
-
|
|
368
|
+
S = !0;
|
|
369
369
|
}
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
var
|
|
373
|
-
return
|
|
374
|
-
|
|
370
|
+
if (S) {
|
|
371
|
+
S = console;
|
|
372
|
+
var z = S.error, Y = typeof Symbol == "function" && Symbol.toStringTag && h[Symbol.toStringTag] || h.constructor.name || "Object";
|
|
373
|
+
return z.call(
|
|
374
|
+
S,
|
|
375
375
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
376
|
-
|
|
376
|
+
Y
|
|
377
377
|
), r(h);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function a(h) {
|
|
381
381
|
if (h === y) return "<>";
|
|
382
|
-
if (typeof h == "object" && h !== null && h.$$typeof ===
|
|
382
|
+
if (typeof h == "object" && h !== null && h.$$typeof === R)
|
|
383
383
|
return "<...>";
|
|
384
384
|
try {
|
|
385
|
-
var
|
|
386
|
-
return
|
|
385
|
+
var S = e(h);
|
|
386
|
+
return S ? "<" + S + ">" : "<...>";
|
|
387
387
|
} catch {
|
|
388
388
|
return "<...>";
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
function t() {
|
|
392
|
-
var h =
|
|
392
|
+
var h = P.A;
|
|
393
393
|
return h === null ? null : h.getOwner();
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function o() {
|
|
396
396
|
return Error("react-stack-top-frame");
|
|
397
397
|
}
|
|
398
398
|
function s(h) {
|
|
399
|
-
if (
|
|
400
|
-
var
|
|
401
|
-
if (
|
|
399
|
+
if (W.call(h, "key")) {
|
|
400
|
+
var S = Object.getOwnPropertyDescriptor(h, "key").get;
|
|
401
|
+
if (S && S.isReactWarning) return !1;
|
|
402
402
|
}
|
|
403
403
|
return h.key !== void 0;
|
|
404
404
|
}
|
|
405
|
-
function i(h,
|
|
406
|
-
function
|
|
405
|
+
function i(h, S) {
|
|
406
|
+
function z() {
|
|
407
407
|
ue || (ue = !0, console.error(
|
|
408
408
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
409
|
-
|
|
409
|
+
S
|
|
410
410
|
));
|
|
411
411
|
}
|
|
412
|
-
|
|
413
|
-
get:
|
|
412
|
+
z.isReactWarning = !0, Object.defineProperty(h, "key", {
|
|
413
|
+
get: z,
|
|
414
414
|
configurable: !0
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function m() {
|
|
418
418
|
var h = e(this.type);
|
|
419
419
|
return Q[h] || (Q[h] = !0, console.error(
|
|
420
420
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
421
421
|
)), h = this.props.ref, h !== void 0 ? h : null;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
424
|
-
var
|
|
423
|
+
function d(h, S, z, Y, te, se) {
|
|
424
|
+
var q = z.ref;
|
|
425
425
|
return h = {
|
|
426
426
|
$$typeof: b,
|
|
427
427
|
type: h,
|
|
428
|
-
key:
|
|
429
|
-
props:
|
|
430
|
-
_owner:
|
|
431
|
-
}, (
|
|
428
|
+
key: S,
|
|
429
|
+
props: z,
|
|
430
|
+
_owner: Y
|
|
431
|
+
}, (q !== void 0 ? q : null) !== null ? Object.defineProperty(h, "ref", {
|
|
432
432
|
enumerable: !1,
|
|
433
|
-
get:
|
|
433
|
+
get: m
|
|
434
434
|
}) : Object.defineProperty(h, "ref", { enumerable: !1, value: null }), h._store = {}, Object.defineProperty(h._store, "validated", {
|
|
435
435
|
configurable: !1,
|
|
436
436
|
enumerable: !1,
|
|
@@ -445,99 +445,99 @@ function Sr() {
|
|
|
445
445
|
configurable: !1,
|
|
446
446
|
enumerable: !1,
|
|
447
447
|
writable: !0,
|
|
448
|
-
value:
|
|
448
|
+
value: te
|
|
449
449
|
}), Object.defineProperty(h, "_debugTask", {
|
|
450
450
|
configurable: !1,
|
|
451
451
|
enumerable: !1,
|
|
452
452
|
writable: !0,
|
|
453
|
-
value:
|
|
453
|
+
value: se
|
|
454
454
|
}), Object.freeze && (Object.freeze(h.props), Object.freeze(h)), h;
|
|
455
455
|
}
|
|
456
|
-
function l(h,
|
|
457
|
-
var
|
|
458
|
-
if (
|
|
459
|
-
if (
|
|
460
|
-
if (
|
|
461
|
-
for (
|
|
462
|
-
|
|
463
|
-
Object.freeze && Object.freeze(
|
|
456
|
+
function l(h, S, z, Y, te, se) {
|
|
457
|
+
var q = S.children;
|
|
458
|
+
if (q !== void 0)
|
|
459
|
+
if (Y)
|
|
460
|
+
if (ae(q)) {
|
|
461
|
+
for (Y = 0; Y < q.length; Y++)
|
|
462
|
+
u(q[Y]);
|
|
463
|
+
Object.freeze && Object.freeze(q);
|
|
464
464
|
} else
|
|
465
465
|
console.error(
|
|
466
466
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
467
467
|
);
|
|
468
|
-
else
|
|
469
|
-
if (
|
|
470
|
-
|
|
471
|
-
var
|
|
472
|
-
return
|
|
468
|
+
else u(q);
|
|
469
|
+
if (W.call(S, "key")) {
|
|
470
|
+
q = e(h);
|
|
471
|
+
var D = Object.keys(S).filter(function(K) {
|
|
472
|
+
return K !== "key";
|
|
473
473
|
});
|
|
474
|
-
|
|
474
|
+
Y = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", T[q + Y] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
475
475
|
`A props object containing a "key" prop is being spread into JSX:
|
|
476
476
|
let props = %s;
|
|
477
477
|
<%s {...props} />
|
|
478
478
|
React keys must be passed directly to JSX without using spread:
|
|
479
479
|
let props = %s;
|
|
480
480
|
<%s key={someKey} {...props} />`,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
),
|
|
481
|
+
Y,
|
|
482
|
+
q,
|
|
483
|
+
D,
|
|
484
|
+
q
|
|
485
|
+
), T[q + Y] = !0);
|
|
486
486
|
}
|
|
487
|
-
if (
|
|
488
|
-
|
|
489
|
-
for (var
|
|
490
|
-
|
|
491
|
-
} else
|
|
492
|
-
return
|
|
493
|
-
|
|
487
|
+
if (q = null, z !== void 0 && (n(z), q = "" + z), s(S) && (n(S.key), q = "" + S.key), "key" in S) {
|
|
488
|
+
z = {};
|
|
489
|
+
for (var _ in S)
|
|
490
|
+
_ !== "key" && (z[_] = S[_]);
|
|
491
|
+
} else z = S;
|
|
492
|
+
return q && i(
|
|
493
|
+
z,
|
|
494
494
|
typeof h == "function" ? h.displayName || h.name || "Unknown" : h
|
|
495
|
-
),
|
|
495
|
+
), d(
|
|
496
496
|
h,
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
q,
|
|
498
|
+
z,
|
|
499
499
|
t(),
|
|
500
|
-
|
|
501
|
-
|
|
500
|
+
te,
|
|
501
|
+
se
|
|
502
502
|
);
|
|
503
503
|
}
|
|
504
|
-
function
|
|
505
|
-
c(h) ? h._store && (h._store.validated = 1) : typeof h == "object" && h !== null && h.$$typeof ===
|
|
504
|
+
function u(h) {
|
|
505
|
+
c(h) ? h._store && (h._store.validated = 1) : typeof h == "object" && h !== null && h.$$typeof === R && (h._payload.status === "fulfilled" ? c(h._payload.value) && h._payload.value._store && (h._payload.value._store.validated = 1) : h._store && (h._store.validated = 1));
|
|
506
506
|
}
|
|
507
507
|
function c(h) {
|
|
508
508
|
return typeof h == "object" && h !== null && h.$$typeof === b;
|
|
509
509
|
}
|
|
510
|
-
var
|
|
510
|
+
var p = F, b = Symbol.for("react.transitional.element"), f = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), j = Symbol.for("react.consumer"), N = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), I = Symbol.for("react.suspense_list"), A = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), $ = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), P = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, W = Object.prototype.hasOwnProperty, ae = Array.isArray, re = console.createTask ? console.createTask : function() {
|
|
511
511
|
return null;
|
|
512
512
|
};
|
|
513
|
-
|
|
513
|
+
p = {
|
|
514
514
|
react_stack_bottom_frame: function(h) {
|
|
515
515
|
return h();
|
|
516
516
|
}
|
|
517
517
|
};
|
|
518
|
-
var ue, Q = {}, oe =
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
)(),
|
|
522
|
-
pe.Fragment = y, pe.jsx = function(h,
|
|
523
|
-
var
|
|
518
|
+
var ue, Q = {}, oe = p.react_stack_bottom_frame.bind(
|
|
519
|
+
p,
|
|
520
|
+
o
|
|
521
|
+
)(), Z = re(a(o)), T = {};
|
|
522
|
+
pe.Fragment = y, pe.jsx = function(h, S, z) {
|
|
523
|
+
var Y = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
524
524
|
return l(
|
|
525
525
|
h,
|
|
526
|
-
|
|
527
|
-
|
|
526
|
+
S,
|
|
527
|
+
z,
|
|
528
528
|
!1,
|
|
529
|
-
|
|
530
|
-
|
|
529
|
+
Y ? Error("react-stack-top-frame") : oe,
|
|
530
|
+
Y ? re(a(h)) : Z
|
|
531
531
|
);
|
|
532
|
-
}, pe.jsxs = function(h,
|
|
533
|
-
var
|
|
532
|
+
}, pe.jsxs = function(h, S, z) {
|
|
533
|
+
var Y = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
534
534
|
return l(
|
|
535
535
|
h,
|
|
536
|
-
|
|
537
|
-
|
|
536
|
+
S,
|
|
537
|
+
z,
|
|
538
538
|
!0,
|
|
539
|
-
|
|
540
|
-
|
|
539
|
+
Y ? Error("react-stack-top-frame") : oe,
|
|
540
|
+
Y ? re(a(h)) : Z
|
|
541
541
|
);
|
|
542
542
|
};
|
|
543
543
|
})()), pe;
|
|
@@ -547,8 +547,8 @@ function Cr() {
|
|
|
547
547
|
return He || (He = 1, process.env.NODE_ENV === "production" ? be.exports = wr() : be.exports = Sr()), be.exports;
|
|
548
548
|
}
|
|
549
549
|
var g = Cr();
|
|
550
|
-
const
|
|
551
|
-
const e = xr(
|
|
550
|
+
const Me = yr(void 0), L = () => {
|
|
551
|
+
const e = xr(Me);
|
|
552
552
|
if (!e)
|
|
553
553
|
throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");
|
|
554
554
|
return e;
|
|
@@ -584,7 +584,7 @@ class we {
|
|
|
584
584
|
}
|
|
585
585
|
// Batch operations for better performance
|
|
586
586
|
registerAll(r) {
|
|
587
|
-
Array.isArray(r) ? r.forEach(([n,
|
|
587
|
+
Array.isArray(r) ? r.forEach(([n, a]) => this.register(n, a)) : Object.entries(r).forEach(([n, a]) => this.register(n, a));
|
|
588
588
|
}
|
|
589
589
|
// Get with fallback
|
|
590
590
|
getOrDefault(r, n) {
|
|
@@ -592,41 +592,41 @@ class we {
|
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
594
|
function jr(e, r = 300, n) {
|
|
595
|
-
const
|
|
596
|
-
|
|
595
|
+
const a = E(void 0), t = E(e), o = E(null), s = E(!1);
|
|
596
|
+
k(() => {
|
|
597
597
|
t.current = e;
|
|
598
|
-
}, [e]),
|
|
598
|
+
}, [e]), k(
|
|
599
599
|
() => () => {
|
|
600
|
-
|
|
600
|
+
a.current !== void 0 && (window.clearTimeout(a.current), a.current = void 0);
|
|
601
601
|
},
|
|
602
602
|
[]
|
|
603
603
|
);
|
|
604
|
-
const i =
|
|
605
|
-
|
|
606
|
-
}, []),
|
|
607
|
-
if (
|
|
604
|
+
const i = X(() => {
|
|
605
|
+
a.current !== void 0 && (window.clearTimeout(a.current), a.current = void 0), o.current = null, s.current = !1;
|
|
606
|
+
}, []), m = X(() => {
|
|
607
|
+
if (a.current !== void 0 && (window.clearTimeout(a.current), a.current = void 0), o.current)
|
|
608
608
|
try {
|
|
609
|
-
t.current(...
|
|
609
|
+
t.current(...o.current);
|
|
610
610
|
} finally {
|
|
611
|
-
|
|
611
|
+
o.current = null, s.current = !1;
|
|
612
612
|
}
|
|
613
613
|
}, []);
|
|
614
|
-
return { callback:
|
|
614
|
+
return { callback: X(
|
|
615
615
|
(...l) => {
|
|
616
616
|
if (n?.leading === !0 && !s.current) {
|
|
617
|
-
s.current = !0, t.current(...l), window.clearTimeout(
|
|
618
|
-
s.current = !1,
|
|
617
|
+
s.current = !0, t.current(...l), window.clearTimeout(a.current), a.current = window.setTimeout(() => {
|
|
618
|
+
s.current = !1, a.current = void 0;
|
|
619
619
|
}, r);
|
|
620
620
|
return;
|
|
621
621
|
}
|
|
622
|
-
|
|
623
|
-
|
|
622
|
+
o.current = l, window.clearTimeout(a.current), a.current = window.setTimeout(() => {
|
|
623
|
+
a.current = void 0, o.current && (t.current(...o.current), o.current = null, s.current = !1);
|
|
624
624
|
}, r);
|
|
625
625
|
},
|
|
626
626
|
[r, n?.leading]
|
|
627
|
-
), cancel: i, flush:
|
|
627
|
+
), cancel: i, flush: m };
|
|
628
628
|
}
|
|
629
|
-
const
|
|
629
|
+
const M = {
|
|
630
630
|
field: "reactaform-field",
|
|
631
631
|
label: "reactaform-label",
|
|
632
632
|
input: "reactaform-input",
|
|
@@ -635,16 +635,16 @@ const $ = {
|
|
|
635
635
|
inputSelect: "reactaform-select",
|
|
636
636
|
rangeInput: "reactaform-input--range",
|
|
637
637
|
button: "reactaform-button"
|
|
638
|
-
},
|
|
638
|
+
}, G = (...e) => {
|
|
639
639
|
const r = [];
|
|
640
640
|
for (const n of e)
|
|
641
|
-
n && (typeof n == "string" ? r.push(n) : typeof n == "object" && Object.entries(n).forEach(([
|
|
642
|
-
t && r.push(
|
|
641
|
+
n && (typeof n == "string" ? r.push(n) : typeof n == "object" && Object.entries(n).forEach(([a, t]) => {
|
|
642
|
+
t && r.push(a);
|
|
643
643
|
}));
|
|
644
644
|
return r.join(" ");
|
|
645
645
|
}, er = ({ content: e, size: r = "medium", animation: n = !0 }) => {
|
|
646
|
-
const { t:
|
|
647
|
-
const
|
|
646
|
+
const { t: a, darkMode: t, formStyle: o, fieldStyle: s } = L(), [i, m] = V(!1), [d, l] = V({ x: 0, y: 0 }), [u, c] = V(!1), p = E(null), b = E(null), f = E(null), y = J(() => {
|
|
647
|
+
const N = {
|
|
648
648
|
icon: {
|
|
649
649
|
display: "inline-flex",
|
|
650
650
|
alignItems: "center",
|
|
@@ -686,58 +686,58 @@ const $ = {
|
|
|
686
686
|
opacity: 1,
|
|
687
687
|
visibility: "visible"
|
|
688
688
|
}
|
|
689
|
-
},
|
|
690
|
-
const
|
|
691
|
-
return (
|
|
689
|
+
}, v = (I, A, R) => {
|
|
690
|
+
const O = I?.[A];
|
|
691
|
+
return (R && O ? O[R] : void 0) ?? {};
|
|
692
692
|
};
|
|
693
693
|
return {
|
|
694
|
-
icon: { ...
|
|
695
|
-
text: { ...
|
|
696
|
-
textVisible:
|
|
694
|
+
icon: { ...N.icon, ...v(o, "tooltip", "icon"), ...v(s, "tooltip", "icon") },
|
|
695
|
+
text: { ...N.text, ...v(o, "tooltip", "text"), ...v(s, "tooltip", "text") },
|
|
696
|
+
textVisible: N.textVisible
|
|
697
697
|
};
|
|
698
|
-
}, [t, r, n,
|
|
699
|
-
|
|
698
|
+
}, [t, r, n, o, s]);
|
|
699
|
+
k(() => {
|
|
700
700
|
if (i) {
|
|
701
|
-
const
|
|
702
|
-
if (
|
|
703
|
-
const
|
|
704
|
-
f.current =
|
|
705
|
-
const I =
|
|
706
|
-
l({ x: I, y:
|
|
701
|
+
const j = requestAnimationFrame(() => c(!1)), N = requestAnimationFrame(() => {
|
|
702
|
+
if (p.current) {
|
|
703
|
+
const v = p.current.getBoundingClientRect(), w = 8;
|
|
704
|
+
f.current = v;
|
|
705
|
+
const I = v.right + w, A = v.top;
|
|
706
|
+
l({ x: I, y: A }), c(!0);
|
|
707
707
|
}
|
|
708
708
|
});
|
|
709
709
|
return () => {
|
|
710
|
-
cancelAnimationFrame(
|
|
710
|
+
cancelAnimationFrame(N), cancelAnimationFrame(j);
|
|
711
711
|
};
|
|
712
712
|
} else
|
|
713
713
|
requestAnimationFrame(() => c(!1));
|
|
714
|
-
}, [i]),
|
|
715
|
-
if (!
|
|
716
|
-
const
|
|
714
|
+
}, [i]), k(() => {
|
|
715
|
+
if (!u) return;
|
|
716
|
+
const j = requestAnimationFrame(() => {
|
|
717
717
|
if (!b.current) return;
|
|
718
|
-
const
|
|
719
|
-
let
|
|
720
|
-
const
|
|
721
|
-
|
|
718
|
+
const N = b.current.getBoundingClientRect(), v = 8, w = typeof window < "u" ? window.innerWidth : 1024, I = typeof window < "u" ? window.innerHeight : 768;
|
|
719
|
+
let A = d.x, R = d.y;
|
|
720
|
+
const $ = f.current;
|
|
721
|
+
$ && (A = $.right + v, R = $.top + $.height / 2 - N.height / 2 + -4, A + N.width > w - v && (A = $.left - v - N.width)), A + N.width > w - v && (A = Math.max(v, w - N.width - v)), A < v && (A = v), R + N.height > I - v && (R = Math.max(v, I - N.height - v)), R < v && (R = v), (A !== d.x || R !== d.y) && l({ x: A, y: R });
|
|
722
722
|
});
|
|
723
|
-
return () => cancelAnimationFrame(
|
|
724
|
-
}, [
|
|
725
|
-
const
|
|
723
|
+
return () => cancelAnimationFrame(j);
|
|
724
|
+
}, [u, d.x, d.y]);
|
|
725
|
+
const C = typeof document < "u" ? document.getElementById("popup-root") : null, x = /* @__PURE__ */ g.jsx(
|
|
726
726
|
"div",
|
|
727
727
|
{
|
|
728
728
|
ref: b,
|
|
729
729
|
style: {
|
|
730
730
|
...y.text,
|
|
731
|
-
transform:
|
|
731
|
+
transform: u ? "translateY(0) scale(1)" : "translateY(-4px) scale(0.98)",
|
|
732
732
|
transition: "opacity 120ms ease, transform 120ms ease, visibility 120ms ease",
|
|
733
733
|
width: 240,
|
|
734
734
|
// When positioned is true, apply the visible styles
|
|
735
|
-
...
|
|
736
|
-
top:
|
|
737
|
-
left:
|
|
735
|
+
...u ? y.textVisible : {},
|
|
736
|
+
top: d.y,
|
|
737
|
+
left: d.x
|
|
738
738
|
},
|
|
739
739
|
"data-reactaform-theme": t ? "dark" : "light",
|
|
740
|
-
children:
|
|
740
|
+
children: a(e)
|
|
741
741
|
}
|
|
742
742
|
);
|
|
743
743
|
return /* @__PURE__ */ g.jsxs(g.Fragment, { children: [
|
|
@@ -745,45 +745,47 @@ const $ = {
|
|
|
745
745
|
"span",
|
|
746
746
|
{
|
|
747
747
|
"data-testid": "tooltip-icon",
|
|
748
|
-
ref:
|
|
749
|
-
onMouseEnter: () =>
|
|
750
|
-
onMouseLeave: () =>
|
|
748
|
+
ref: p,
|
|
749
|
+
onMouseEnter: () => m(!0),
|
|
750
|
+
onMouseLeave: () => m(!1),
|
|
751
751
|
style: {
|
|
752
752
|
...y.icon
|
|
753
753
|
},
|
|
754
754
|
children: "?"
|
|
755
755
|
}
|
|
756
756
|
),
|
|
757
|
-
i && (
|
|
757
|
+
i && (C ? $e.createPortal(x, C) : x)
|
|
758
758
|
] });
|
|
759
759
|
}, Re = ve(({
|
|
760
760
|
field: e,
|
|
761
761
|
error: r,
|
|
762
762
|
children: n,
|
|
763
|
-
showLabel:
|
|
763
|
+
showLabel: a = !0
|
|
764
764
|
}) => {
|
|
765
|
-
const { t } =
|
|
765
|
+
const { t } = L(), o = e?.labelLayout === "column-center" ? "center" : "left";
|
|
766
766
|
return /* @__PURE__ */ g.jsxs(
|
|
767
767
|
"div",
|
|
768
768
|
{
|
|
769
|
-
className: `${
|
|
769
|
+
className: `${M.field} column-layout`,
|
|
770
770
|
style: {
|
|
771
771
|
display: "flex",
|
|
772
772
|
flexDirection: "column",
|
|
773
773
|
gap: "var(--reactaform-label-gap, 4px)",
|
|
774
|
-
"--label-align":
|
|
774
|
+
"--label-align": o
|
|
775
775
|
},
|
|
776
776
|
children: [
|
|
777
|
-
|
|
777
|
+
a && /* @__PURE__ */ g.jsx("div", { style: { textAlign: o, width: "100%" }, children: /* @__PURE__ */ g.jsx(
|
|
778
778
|
"label",
|
|
779
779
|
{
|
|
780
|
-
|
|
780
|
+
id: `${e.name}-label`,
|
|
781
|
+
className: M.label,
|
|
781
782
|
htmlFor: e.name,
|
|
782
783
|
style: {
|
|
783
|
-
textAlign:
|
|
784
|
+
textAlign: o,
|
|
784
785
|
width: "100%",
|
|
785
786
|
minWidth: "unset",
|
|
786
|
-
display: "block"
|
|
787
|
+
display: "block",
|
|
788
|
+
marginBottom: "10px"
|
|
787
789
|
},
|
|
788
790
|
children: t(e.displayName)
|
|
789
791
|
}
|
|
@@ -803,7 +805,7 @@ const $ = {
|
|
|
803
805
|
]
|
|
804
806
|
}
|
|
805
807
|
),
|
|
806
|
-
r && /* @__PURE__ */ g.jsx(
|
|
808
|
+
r && /* @__PURE__ */ g.jsx(Oe, { id: `${e.name}-error`, children: r })
|
|
807
809
|
]
|
|
808
810
|
}
|
|
809
811
|
);
|
|
@@ -813,31 +815,32 @@ const rr = ve(({
|
|
|
813
815
|
field: e,
|
|
814
816
|
error: r,
|
|
815
817
|
children: n,
|
|
816
|
-
rightAlign:
|
|
818
|
+
rightAlign: a = !1
|
|
817
819
|
}) => {
|
|
818
|
-
const { t } =
|
|
820
|
+
const { t } = L(), o = J(() => ({
|
|
819
821
|
display: "flex",
|
|
820
822
|
flexDirection: "column",
|
|
821
823
|
gap: 0
|
|
822
|
-
}), []), s =
|
|
824
|
+
}), []), s = J(() => ({
|
|
823
825
|
display: "flex",
|
|
824
826
|
flexDirection: "row",
|
|
825
827
|
alignItems: "center",
|
|
826
828
|
gap: "3px"
|
|
827
829
|
}), []);
|
|
828
|
-
return /* @__PURE__ */ g.jsxs("div", { className: `${
|
|
830
|
+
return /* @__PURE__ */ g.jsxs("div", { className: `${M.field} row-layout`, children: [
|
|
829
831
|
/* @__PURE__ */ g.jsx(
|
|
830
832
|
"label",
|
|
831
833
|
{
|
|
832
|
-
|
|
834
|
+
id: `${e.name}-label`,
|
|
835
|
+
className: M.label,
|
|
833
836
|
htmlFor: e.name,
|
|
834
837
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
835
838
|
children: t(e.displayName)
|
|
836
839
|
}
|
|
837
840
|
),
|
|
838
|
-
/* @__PURE__ */ g.jsxs("div", { style:
|
|
841
|
+
/* @__PURE__ */ g.jsxs("div", { style: o, children: [
|
|
839
842
|
/* @__PURE__ */ g.jsxs("div", { style: s, children: [
|
|
840
|
-
|
|
843
|
+
a ? /* @__PURE__ */ g.jsx(
|
|
841
844
|
"div",
|
|
842
845
|
{
|
|
843
846
|
style: {
|
|
@@ -852,18 +855,18 @@ const rr = ve(({
|
|
|
852
855
|
) : n,
|
|
853
856
|
e.tooltip && /* @__PURE__ */ g.jsx(er, { content: e.tooltip })
|
|
854
857
|
] }),
|
|
855
|
-
r && /* @__PURE__ */ g.jsx(
|
|
858
|
+
r && /* @__PURE__ */ g.jsx(Oe, { id: `${e.name}-error`, children: r })
|
|
856
859
|
] })
|
|
857
860
|
] });
|
|
858
861
|
});
|
|
859
862
|
rr.displayName = "RowFieldLayout";
|
|
860
|
-
const
|
|
863
|
+
const U = ({
|
|
861
864
|
field: e,
|
|
862
865
|
error: r,
|
|
863
866
|
children: n,
|
|
864
|
-
rightAlign:
|
|
865
|
-
}) => e
|
|
866
|
-
const
|
|
867
|
+
rightAlign: a = !1
|
|
868
|
+
}) => e.labelLayout === "column-left" || e.labelLayout === "column-center" ? /* @__PURE__ */ g.jsx(Re, { field: e, error: r, showLabel: !0, children: n }) : e.type === "checkbox" || e.type === "switch" ? /* @__PURE__ */ g.jsx(Re, { field: e, error: r, showLabel: !1, children: n }) : /* @__PURE__ */ g.jsx(rr, { field: e, error: r, rightAlign: a, children: n }), Oe = ve(({ children: e, id: r }) => {
|
|
869
|
+
const n = J(() => ({
|
|
867
870
|
color: "var(--reactaform-error-color)",
|
|
868
871
|
fontSize: "13px",
|
|
869
872
|
marginTop: "4px",
|
|
@@ -873,11 +876,11 @@ const W = ({
|
|
|
873
876
|
justifyContent: "flex-start",
|
|
874
877
|
alignItems: "flex-start"
|
|
875
878
|
}), []);
|
|
876
|
-
return /* @__PURE__ */ g.jsx("div", {
|
|
879
|
+
return /* @__PURE__ */ g.jsx("div", { id: r, style: n, children: e });
|
|
877
880
|
});
|
|
878
|
-
|
|
881
|
+
Oe.displayName = "ErrorDiv";
|
|
879
882
|
const tr = ve(({ name: e, onChange: r }) => {
|
|
880
|
-
const { t: n } =
|
|
883
|
+
const { t: n } = L();
|
|
881
884
|
return /* @__PURE__ */ g.jsxs("div", { style: { marginBottom: 16 }, children: [
|
|
882
885
|
/* @__PURE__ */ g.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 12, alignItems: "center" }, children: [
|
|
883
886
|
/* @__PURE__ */ g.jsx(
|
|
@@ -899,7 +902,7 @@ const tr = ve(({ name: e, onChange: r }) => {
|
|
|
899
902
|
id: "instance-name-input",
|
|
900
903
|
type: "text",
|
|
901
904
|
value: e,
|
|
902
|
-
onChange: (
|
|
905
|
+
onChange: (a) => r(a.target.value),
|
|
903
906
|
style: {
|
|
904
907
|
width: "100%",
|
|
905
908
|
padding: "var(--reactaform-input-padding, 8px 12px)",
|
|
@@ -919,10 +922,10 @@ const tr = ve(({ name: e, onChange: r }) => {
|
|
|
919
922
|
});
|
|
920
923
|
tr.displayName = "InstanceName";
|
|
921
924
|
class kr extends we {
|
|
922
|
-
registerInCategory(r, n,
|
|
925
|
+
registerInCategory(r, n, a) {
|
|
923
926
|
this.get(r) || this.register(r, {});
|
|
924
927
|
const t = this.get(r);
|
|
925
|
-
t[n] =
|
|
928
|
+
t[n] = a;
|
|
926
929
|
}
|
|
927
930
|
getFromCategory(r, n) {
|
|
928
931
|
return this.get(r)?.[n];
|
|
@@ -934,123 +937,123 @@ class kr extends we {
|
|
|
934
937
|
return this.list();
|
|
935
938
|
}
|
|
936
939
|
}
|
|
937
|
-
const nr = new we(),
|
|
940
|
+
const nr = new we(), ar = new kr();
|
|
938
941
|
function Zt(e, r) {
|
|
939
942
|
nr.register(e, r);
|
|
940
943
|
}
|
|
941
944
|
function Qt(e, r, n) {
|
|
942
|
-
|
|
945
|
+
ar.registerInCategory(e, r, n);
|
|
943
946
|
}
|
|
944
947
|
function Rr(e, r) {
|
|
945
|
-
return
|
|
948
|
+
return ar.getFromCategory(e, r) || null;
|
|
946
949
|
}
|
|
947
950
|
function Er(e) {
|
|
948
951
|
return nr.get(e) || null;
|
|
949
952
|
}
|
|
950
953
|
const Ce = /* @__PURE__ */ new Map(), je = /* @__PURE__ */ new Map();
|
|
951
|
-
function
|
|
954
|
+
function H(e, r, n, a) {
|
|
952
955
|
if (r && typeof r.validationHandlerName == "string") {
|
|
953
956
|
const t = `${e}:${r.validationHandlerName}`;
|
|
954
957
|
if (!Ce.has(t)) {
|
|
955
958
|
const s = Rr(e, r.validationHandlerName);
|
|
956
959
|
Ce.set(t, s);
|
|
957
960
|
}
|
|
958
|
-
const
|
|
959
|
-
if (
|
|
960
|
-
return
|
|
961
|
+
const o = Ce.get(t);
|
|
962
|
+
if (o)
|
|
963
|
+
return o(n, a) || null;
|
|
961
964
|
}
|
|
962
965
|
return null;
|
|
963
966
|
}
|
|
964
967
|
function Nr(e, r, n) {
|
|
965
968
|
if (e && typeof e.validationHandlerName == "string") {
|
|
966
|
-
const
|
|
967
|
-
if (!je.has(
|
|
968
|
-
const
|
|
969
|
-
je.set(
|
|
969
|
+
const a = e.validationHandlerName;
|
|
970
|
+
if (!je.has(a)) {
|
|
971
|
+
const o = Er(a);
|
|
972
|
+
je.set(a, o);
|
|
970
973
|
}
|
|
971
|
-
const t = je.get(
|
|
974
|
+
const t = je.get(a);
|
|
972
975
|
if (t)
|
|
973
976
|
return t(r, n) || null;
|
|
974
977
|
}
|
|
975
978
|
return null;
|
|
976
979
|
}
|
|
977
|
-
function
|
|
980
|
+
function ce(e) {
|
|
978
981
|
return typeof e == "object" && e !== null;
|
|
979
982
|
}
|
|
980
|
-
function
|
|
981
|
-
if (!
|
|
983
|
+
function De(e) {
|
|
984
|
+
if (!ce(e)) return !1;
|
|
982
985
|
const r = e;
|
|
983
986
|
return typeof r.name == "string" && typeof r.displayName == "string";
|
|
984
987
|
}
|
|
985
|
-
function
|
|
986
|
-
if (!
|
|
988
|
+
function or(e) {
|
|
989
|
+
if (!ce(e)) return !1;
|
|
987
990
|
const r = e;
|
|
988
|
-
return typeof r.name != "string" || typeof r.version != "string" || !Array.isArray(r.properties) ? !1 : r.properties.every((n) =>
|
|
991
|
+
return typeof r.name != "string" || typeof r.version != "string" || !Array.isArray(r.properties) ? !1 : r.properties.every((n) => De(n));
|
|
989
992
|
}
|
|
990
993
|
function Ee(e) {
|
|
991
994
|
try {
|
|
992
995
|
return typeof File < "u" && e instanceof File;
|
|
993
996
|
} catch {
|
|
994
|
-
const r =
|
|
997
|
+
const r = ce(e) ? e : void 0;
|
|
995
998
|
return !!r && typeof r.name == "string" && typeof r.size == "number";
|
|
996
999
|
}
|
|
997
1000
|
}
|
|
998
1001
|
function en(e, r, n = {}) {
|
|
999
1002
|
try {
|
|
1000
1003
|
const {
|
|
1001
|
-
includeMetadata:
|
|
1004
|
+
includeMetadata: a = !1,
|
|
1002
1005
|
dateFormat: t = "iso",
|
|
1003
|
-
fileHandling:
|
|
1006
|
+
fileHandling: o = "metadata",
|
|
1004
1007
|
prettify: s = !1,
|
|
1005
1008
|
excludeFields: i = [],
|
|
1006
|
-
includeOnlyFields:
|
|
1009
|
+
includeOnlyFields: m = []
|
|
1007
1010
|
} = n;
|
|
1008
1011
|
if (!e || typeof e != "object")
|
|
1009
1012
|
return {
|
|
1010
1013
|
success: !1,
|
|
1011
1014
|
error: "Instance must be a valid object"
|
|
1012
1015
|
};
|
|
1013
|
-
const
|
|
1014
|
-
for (const [y,
|
|
1016
|
+
const d = [], l = [], u = {}, p = (or(r) || ce(r) && Array.isArray(r.properties) ? r.properties : []).filter(De), b = new Map(p.map((y) => [y.name, y]));
|
|
1017
|
+
for (const [y, C] of Object.entries(e)) {
|
|
1015
1018
|
if (i.includes(y)) {
|
|
1016
1019
|
l.push(y);
|
|
1017
1020
|
continue;
|
|
1018
1021
|
}
|
|
1019
|
-
if (
|
|
1022
|
+
if (m.length > 0 && !m.includes(y)) {
|
|
1020
1023
|
l.push(y);
|
|
1021
1024
|
continue;
|
|
1022
1025
|
}
|
|
1023
|
-
if (
|
|
1024
|
-
const
|
|
1026
|
+
if (C === void 0) continue;
|
|
1027
|
+
const x = b.get(y);
|
|
1025
1028
|
try {
|
|
1026
|
-
|
|
1027
|
-
} catch (
|
|
1028
|
-
|
|
1029
|
+
u[y] = Ir(C, x, { dateFormat: t, fileHandling: o });
|
|
1030
|
+
} catch (j) {
|
|
1031
|
+
d.push(`Error serializing field '${y}': ${String(j)}`), u[y] = null;
|
|
1029
1032
|
}
|
|
1030
1033
|
}
|
|
1031
|
-
return
|
|
1034
|
+
return a && (u._metadata = {
|
|
1032
1035
|
serializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1033
|
-
version: (
|
|
1034
|
-
fieldCount: Object.keys(
|
|
1036
|
+
version: (ce(r) ? r.version : void 0) || "1.0.0",
|
|
1037
|
+
fieldCount: Object.keys(u).length - 1
|
|
1035
1038
|
// Exclude metadata itself
|
|
1036
1039
|
}), {
|
|
1037
1040
|
success: !0,
|
|
1038
|
-
data: s ? JSON.stringify(
|
|
1041
|
+
data: s ? JSON.stringify(u, null, 2) : JSON.stringify(u),
|
|
1039
1042
|
metadata: {
|
|
1040
|
-
fieldCount: Object.keys(
|
|
1043
|
+
fieldCount: Object.keys(u).length,
|
|
1041
1044
|
excludedFields: l,
|
|
1042
|
-
warnings:
|
|
1045
|
+
warnings: d
|
|
1043
1046
|
}
|
|
1044
1047
|
};
|
|
1045
|
-
} catch (
|
|
1048
|
+
} catch (a) {
|
|
1046
1049
|
return {
|
|
1047
1050
|
success: !1,
|
|
1048
|
-
error: `Serialization failed: ${
|
|
1051
|
+
error: `Serialization failed: ${a instanceof Error ? a.message : "Unknown error"}`
|
|
1049
1052
|
};
|
|
1050
1053
|
}
|
|
1051
1054
|
}
|
|
1052
1055
|
function Ir(e, r, n = {}) {
|
|
1053
|
-
const { dateFormat:
|
|
1056
|
+
const { dateFormat: a = "iso", fileHandling: t = "metadata" } = n;
|
|
1054
1057
|
if (e == null)
|
|
1055
1058
|
return null;
|
|
1056
1059
|
if (r)
|
|
@@ -1058,7 +1061,7 @@ function Ir(e, r, n = {}) {
|
|
|
1058
1061
|
case "date":
|
|
1059
1062
|
case "datetime":
|
|
1060
1063
|
case "date-time":
|
|
1061
|
-
return Ue(e,
|
|
1064
|
+
return Ue(e, a);
|
|
1062
1065
|
case "file":
|
|
1063
1066
|
return We(e, t);
|
|
1064
1067
|
case "int":
|
|
@@ -1071,20 +1074,20 @@ function Ir(e, r, n = {}) {
|
|
|
1071
1074
|
return typeof e == "string" ? e === "true" : !!e;
|
|
1072
1075
|
case "int-array":
|
|
1073
1076
|
case "float-array":
|
|
1074
|
-
return Array.isArray(e) ? e.map((
|
|
1077
|
+
return Array.isArray(e) ? e.map((o) => typeof o == "string" ? Number(o) : o) : e;
|
|
1075
1078
|
default:
|
|
1076
1079
|
return e;
|
|
1077
1080
|
}
|
|
1078
|
-
return e instanceof Date ? Ue(e,
|
|
1081
|
+
return e instanceof Date ? Ue(e, a) : Ee(e) || Array.isArray(e) && Ee(e[0]) ? We(e, t) : e;
|
|
1079
1082
|
}
|
|
1080
1083
|
function Ue(e, r) {
|
|
1081
1084
|
let n = null;
|
|
1082
1085
|
if (e instanceof Date)
|
|
1083
1086
|
n = e;
|
|
1084
1087
|
else if (typeof e == "string") {
|
|
1085
|
-
const
|
|
1086
|
-
if (!isNaN(
|
|
1087
|
-
n =
|
|
1088
|
+
const a = new Date(e);
|
|
1089
|
+
if (!isNaN(a.getTime()))
|
|
1090
|
+
n = a;
|
|
1088
1091
|
else
|
|
1089
1092
|
return e;
|
|
1090
1093
|
} else
|
|
@@ -1122,9 +1125,9 @@ function Ye(e, r) {
|
|
|
1122
1125
|
function rn(e, r, n = {}) {
|
|
1123
1126
|
try {
|
|
1124
1127
|
const {
|
|
1125
|
-
strict:
|
|
1128
|
+
strict: a = !1,
|
|
1126
1129
|
validateTypes: t = !0,
|
|
1127
|
-
preserveUnknownFields:
|
|
1130
|
+
preserveUnknownFields: o = !0,
|
|
1128
1131
|
dateFormat: s = "auto"
|
|
1129
1132
|
} = n;
|
|
1130
1133
|
if (!e || typeof e != "string")
|
|
@@ -1146,39 +1149,39 @@ function rn(e, r, n = {}) {
|
|
|
1146
1149
|
success: !1,
|
|
1147
1150
|
error: "Parsed data must be an object"
|
|
1148
1151
|
};
|
|
1149
|
-
const
|
|
1152
|
+
const m = [], d = [], l = {}, c = (or(r) || ce(r) && Array.isArray(r.properties) ? r.properties : []).filter(De), p = new Map(c.map((f) => [f.name, f]));
|
|
1150
1153
|
for (const f of c) {
|
|
1151
|
-
const y = f.name,
|
|
1152
|
-
if (
|
|
1153
|
-
|
|
1154
|
+
const y = f.name, C = i[y];
|
|
1155
|
+
if (C === void 0) {
|
|
1156
|
+
a && f.required && d.push(`Required field '${y}' is missing`);
|
|
1154
1157
|
continue;
|
|
1155
1158
|
}
|
|
1156
1159
|
try {
|
|
1157
|
-
l[y] = Ar(
|
|
1158
|
-
} catch (
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1160
|
+
l[y] = Ar(C, f, { validateTypes: t, dateFormat: s });
|
|
1161
|
+
} catch (x) {
|
|
1162
|
+
const j = `Error deserializing field '${y}': ${String(x)}`;
|
|
1163
|
+
a ? d.push(j) : (m.push(j), l[y] = C);
|
|
1161
1164
|
}
|
|
1162
1165
|
}
|
|
1163
|
-
if (
|
|
1166
|
+
if (o)
|
|
1164
1167
|
for (const [f, y] of Object.entries(i))
|
|
1165
|
-
!
|
|
1166
|
-
const b =
|
|
1168
|
+
!p.has(f) && f !== "_metadata" && (a && m.push(`Unknown field '${f}' preserved`), l[f] = y);
|
|
1169
|
+
const b = d.length > 0;
|
|
1167
1170
|
return {
|
|
1168
1171
|
success: !b,
|
|
1169
1172
|
data: l,
|
|
1170
|
-
warnings:
|
|
1171
|
-
validationErrors: b ?
|
|
1173
|
+
warnings: m.length > 0 ? m : void 0,
|
|
1174
|
+
validationErrors: b ? d : void 0
|
|
1172
1175
|
};
|
|
1173
|
-
} catch (
|
|
1176
|
+
} catch (a) {
|
|
1174
1177
|
return {
|
|
1175
1178
|
success: !1,
|
|
1176
|
-
error: `Deserialization failed: ${
|
|
1179
|
+
error: `Deserialization failed: ${a instanceof Error ? a.message : "Unknown error"}`
|
|
1177
1180
|
};
|
|
1178
1181
|
}
|
|
1179
1182
|
}
|
|
1180
1183
|
function Ar(e, r, n = {}) {
|
|
1181
|
-
const { validateTypes:
|
|
1184
|
+
const { validateTypes: a = !0, dateFormat: t = "auto" } = n;
|
|
1182
1185
|
if (e == null)
|
|
1183
1186
|
return e;
|
|
1184
1187
|
try {
|
|
@@ -1186,44 +1189,44 @@ function Ar(e, r, n = {}) {
|
|
|
1186
1189
|
case "date":
|
|
1187
1190
|
case "datetime":
|
|
1188
1191
|
case "date-time":
|
|
1189
|
-
return Fr(e, t,
|
|
1192
|
+
return Fr(e, t, a);
|
|
1190
1193
|
case "int":
|
|
1191
1194
|
case "integer":
|
|
1192
|
-
return Ne(e,
|
|
1195
|
+
return Ne(e, a);
|
|
1193
1196
|
case "float":
|
|
1194
1197
|
case "number":
|
|
1195
|
-
return Ie(e,
|
|
1198
|
+
return Ie(e, a);
|
|
1196
1199
|
case "boolean":
|
|
1197
|
-
return
|
|
1200
|
+
return $r(e, a);
|
|
1198
1201
|
case "int-array":
|
|
1199
|
-
return Je(e, "integer",
|
|
1202
|
+
return Je(e, "integer", a);
|
|
1200
1203
|
case "float-array":
|
|
1201
|
-
return Je(e, "number",
|
|
1204
|
+
return Je(e, "number", a);
|
|
1202
1205
|
case "string":
|
|
1203
1206
|
case "text":
|
|
1204
1207
|
case "email":
|
|
1205
1208
|
case "url":
|
|
1206
1209
|
case "phone":
|
|
1207
|
-
return
|
|
1210
|
+
return a ? String(e) : e;
|
|
1208
1211
|
default:
|
|
1209
1212
|
return e;
|
|
1210
1213
|
}
|
|
1211
|
-
} catch (
|
|
1212
|
-
if (
|
|
1213
|
-
throw new Error(`Type conversion failed: ${String(
|
|
1214
|
+
} catch (o) {
|
|
1215
|
+
if (a)
|
|
1216
|
+
throw new Error(`Type conversion failed: ${String(o)}`);
|
|
1214
1217
|
return e;
|
|
1215
1218
|
}
|
|
1216
1219
|
}
|
|
1217
1220
|
function tn(e, r = {}) {
|
|
1218
1221
|
try {
|
|
1219
|
-
const { prettify: n = !0, includeMetadata:
|
|
1222
|
+
const { prettify: n = !0, includeMetadata: a = !0 } = r;
|
|
1220
1223
|
if (!e || typeof e != "object")
|
|
1221
1224
|
return {
|
|
1222
1225
|
success: !1,
|
|
1223
1226
|
error: "Definition must be a valid object"
|
|
1224
1227
|
};
|
|
1225
1228
|
const t = { ...e };
|
|
1226
|
-
return
|
|
1229
|
+
return a && (t._metadata = {
|
|
1227
1230
|
serializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1228
1231
|
version: t.version || "1.0.0",
|
|
1229
1232
|
propertyCount: (Array.isArray(t.properties) ? t.properties.length : 0) || 0
|
|
@@ -1245,7 +1248,7 @@ function tn(e, r = {}) {
|
|
|
1245
1248
|
}
|
|
1246
1249
|
function nn(e, r = {}) {
|
|
1247
1250
|
try {
|
|
1248
|
-
const { strict: n = !1, validateTypes:
|
|
1251
|
+
const { strict: n = !1, validateTypes: a = !0 } = r;
|
|
1249
1252
|
let t;
|
|
1250
1253
|
if (typeof e == "string")
|
|
1251
1254
|
try {
|
|
@@ -1263,13 +1266,13 @@ function nn(e, r = {}) {
|
|
|
1263
1266
|
success: !1,
|
|
1264
1267
|
error: "Input must be a string or object"
|
|
1265
1268
|
};
|
|
1266
|
-
const
|
|
1269
|
+
const o = [], s = [], i = ["name", "version", "displayName"];
|
|
1267
1270
|
for (const l of i)
|
|
1268
1271
|
if (!t[l])
|
|
1269
1272
|
if (n)
|
|
1270
1273
|
s.push(`Required field '${l}' is missing`);
|
|
1271
1274
|
else
|
|
1272
|
-
switch (
|
|
1275
|
+
switch (o.push(`Missing field '${l}', using default`), l) {
|
|
1273
1276
|
case "name":
|
|
1274
1277
|
t.name = "unnamed-definition";
|
|
1275
1278
|
break;
|
|
@@ -1280,21 +1283,21 @@ function nn(e, r = {}) {
|
|
|
1280
1283
|
t.displayName = t.name || "Unnamed Definition";
|
|
1281
1284
|
break;
|
|
1282
1285
|
}
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
const c =
|
|
1286
|
+
const m = Array.isArray(t.properties) ? t.properties : null;
|
|
1287
|
+
m ? t.properties = m.map((l, u) => {
|
|
1288
|
+
const c = ce(l) ? l : {}, p = { ...c };
|
|
1286
1289
|
if (!c.name) {
|
|
1287
|
-
const b = `Property at index ${
|
|
1288
|
-
n ? s.push(b) : (
|
|
1290
|
+
const b = `Property at index ${u} missing 'name'`;
|
|
1291
|
+
n ? s.push(b) : (o.push(`${b}, using 'field_${u}'`), p.name = `field_${u}`);
|
|
1289
1292
|
}
|
|
1290
|
-
return c.displayName || (
|
|
1291
|
-
}) : n ? s.push("Properties must be an array") : (
|
|
1292
|
-
const
|
|
1293
|
+
return c.displayName || (p.displayName = c.name || `Field ${u}`), c.type || (n && a ? s.push(`Property '${c.name || u}' missing 'type'`) : (o.push(`Property '${c.name || u}' missing 'type', using 'string'`), p.type = "string")), c.defaultValue === void 0 && (p.defaultValue = null), c.required === void 0 && (p.required = !1), p;
|
|
1294
|
+
}) : n ? s.push("Properties must be an array") : (o.push("Properties not found or invalid, using empty array"), t.properties = []);
|
|
1295
|
+
const d = s.length > 0;
|
|
1293
1296
|
return {
|
|
1294
|
-
success: !
|
|
1297
|
+
success: !d,
|
|
1295
1298
|
data: t,
|
|
1296
|
-
warnings:
|
|
1297
|
-
validationErrors:
|
|
1299
|
+
warnings: o.length > 0 ? o : void 0,
|
|
1300
|
+
validationErrors: d ? s : void 0
|
|
1298
1301
|
};
|
|
1299
1302
|
} catch (n) {
|
|
1300
1303
|
return {
|
|
@@ -1307,16 +1310,16 @@ function Fr(e, r, n) {
|
|
|
1307
1310
|
if (e instanceof Date)
|
|
1308
1311
|
return e;
|
|
1309
1312
|
if (typeof e == "number") {
|
|
1310
|
-
const
|
|
1311
|
-
if (n && isNaN(
|
|
1313
|
+
const a = new Date(e);
|
|
1314
|
+
if (n && isNaN(a.getTime()))
|
|
1312
1315
|
throw new Error(`Invalid timestamp: ${e}`);
|
|
1313
|
-
return
|
|
1316
|
+
return a;
|
|
1314
1317
|
}
|
|
1315
1318
|
if (typeof e == "string") {
|
|
1316
|
-
const
|
|
1317
|
-
if (n && isNaN(
|
|
1319
|
+
const a = new Date(e);
|
|
1320
|
+
if (n && isNaN(a.getTime()))
|
|
1318
1321
|
throw new Error(`Invalid date string: ${e}`);
|
|
1319
|
-
return
|
|
1322
|
+
return a;
|
|
1320
1323
|
}
|
|
1321
1324
|
if (n)
|
|
1322
1325
|
throw new Error(`Cannot convert ${typeof e} to Date`);
|
|
@@ -1348,7 +1351,7 @@ function Ie(e, r) {
|
|
|
1348
1351
|
throw new Error(`Cannot convert ${typeof e} to number`);
|
|
1349
1352
|
return e;
|
|
1350
1353
|
}
|
|
1351
|
-
function
|
|
1354
|
+
function $r(e, r) {
|
|
1352
1355
|
if (typeof e == "boolean")
|
|
1353
1356
|
return e;
|
|
1354
1357
|
if (typeof e == "string") {
|
|
@@ -1372,56 +1375,56 @@ function Je(e, r, n) {
|
|
|
1372
1375
|
throw new Error(`Expected array, got ${typeof e}`);
|
|
1373
1376
|
return e;
|
|
1374
1377
|
}
|
|
1375
|
-
return e.map((
|
|
1378
|
+
return e.map((a, t) => {
|
|
1376
1379
|
try {
|
|
1377
|
-
return r === "integer" ? Ne(
|
|
1378
|
-
} catch (
|
|
1380
|
+
return r === "integer" ? Ne(a, n) : Ie(a, n);
|
|
1381
|
+
} catch (o) {
|
|
1379
1382
|
if (n)
|
|
1380
|
-
throw new Error(`Array element ${t}: ${
|
|
1381
|
-
return
|
|
1383
|
+
throw new Error(`Array element ${t}: ${o}`);
|
|
1384
|
+
return a;
|
|
1382
1385
|
}
|
|
1383
1386
|
});
|
|
1384
1387
|
}
|
|
1385
|
-
const
|
|
1388
|
+
const Mr = (e, r) => {
|
|
1386
1389
|
const n = /* @__PURE__ */ new Map();
|
|
1387
|
-
let
|
|
1390
|
+
let a = null, t = null, o = 0;
|
|
1388
1391
|
for (const s of e) {
|
|
1389
1392
|
const i = s.group;
|
|
1390
1393
|
if (!i) {
|
|
1391
|
-
|
|
1394
|
+
a = null, t = null;
|
|
1392
1395
|
continue;
|
|
1393
1396
|
}
|
|
1394
|
-
if (i ===
|
|
1397
|
+
if (i === a)
|
|
1395
1398
|
r[s.name].group = t ?? i;
|
|
1396
1399
|
else {
|
|
1397
1400
|
if (!n.has(i))
|
|
1398
1401
|
n.set(i, 1), t = null, r[s.name].group = i;
|
|
1399
1402
|
else {
|
|
1400
|
-
const
|
|
1401
|
-
n.set(i,
|
|
1403
|
+
const m = n.get(i), d = `${i}(${m})`;
|
|
1404
|
+
n.set(i, m + 1), t = d, r[s.name].group = d, o++;
|
|
1402
1405
|
}
|
|
1403
|
-
|
|
1406
|
+
a = i;
|
|
1404
1407
|
}
|
|
1405
1408
|
}
|
|
1406
|
-
return
|
|
1407
|
-
},
|
|
1408
|
-
const { includeEmpty: n = !0 } = r,
|
|
1409
|
-
let t = null,
|
|
1410
|
-
for (const
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1409
|
+
return o;
|
|
1410
|
+
}, Or = (e, r = {}) => {
|
|
1411
|
+
const { includeEmpty: n = !0 } = r, a = [];
|
|
1412
|
+
let t = null, o = [], s = 0;
|
|
1413
|
+
for (const m of e) {
|
|
1414
|
+
const d = m.group || null;
|
|
1415
|
+
d !== t ? ((o.length > 0 || n) && (o.length === 0 && s++, a.push({ name: t, fields: o })), t = d, o = [m]) : o.push(m);
|
|
1413
1416
|
}
|
|
1414
|
-
(
|
|
1415
|
-
const i = Math.max(0, ...
|
|
1417
|
+
(o.length > 0 || n) && (o.length === 0 && s++, a.push({ name: t, fields: o }));
|
|
1418
|
+
const i = Math.max(0, ...a.map((m) => m.fields.length));
|
|
1416
1419
|
return {
|
|
1417
|
-
groups:
|
|
1420
|
+
groups: a,
|
|
1418
1421
|
metadata: {
|
|
1419
|
-
totalGroups:
|
|
1422
|
+
totalGroups: a.length,
|
|
1420
1423
|
emptyGroups: s,
|
|
1421
1424
|
largestGroup: i
|
|
1422
1425
|
}
|
|
1423
1426
|
};
|
|
1424
|
-
}, ke = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Map(),
|
|
1427
|
+
}, ke = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Map(), ie = /* @__PURE__ */ new Set(), Ae = /* @__PURE__ */ new Map(), Dr = async (e) => {
|
|
1425
1428
|
try {
|
|
1426
1429
|
let r;
|
|
1427
1430
|
switch (e.toLowerCase()) {
|
|
@@ -1455,7 +1458,7 @@ const Or = (e, r) => {
|
|
|
1455
1458
|
error: `Failed to load common translations for ${e}: ${r}`
|
|
1456
1459
|
};
|
|
1457
1460
|
}
|
|
1458
|
-
},
|
|
1461
|
+
}, Vr = async (e) => {
|
|
1459
1462
|
if (!e)
|
|
1460
1463
|
return { success: !1, translations: {}, error: "Language is required" };
|
|
1461
1464
|
const r = e.toLowerCase();
|
|
@@ -1467,7 +1470,7 @@ const Or = (e, r) => {
|
|
|
1467
1470
|
translations: ke.get(r) || {},
|
|
1468
1471
|
fromCache: !0
|
|
1469
1472
|
};
|
|
1470
|
-
const n = await
|
|
1473
|
+
const n = await Dr(r);
|
|
1471
1474
|
return n.success && (ke.set(r, n.translations), Ae.set(r, {
|
|
1472
1475
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
1473
1476
|
size: Object.keys(n.translations).length,
|
|
@@ -1481,7 +1484,7 @@ const Or = (e, r) => {
|
|
|
1481
1484
|
error: "Both language and localizeName are required"
|
|
1482
1485
|
};
|
|
1483
1486
|
const n = `${e.toLowerCase()}/${r}`;
|
|
1484
|
-
if (
|
|
1487
|
+
if (ie.has(n))
|
|
1485
1488
|
return {
|
|
1486
1489
|
success: !1,
|
|
1487
1490
|
translations: {},
|
|
@@ -1495,11 +1498,11 @@ const Or = (e, r) => {
|
|
|
1495
1498
|
fromCache: !0
|
|
1496
1499
|
};
|
|
1497
1500
|
try {
|
|
1498
|
-
let
|
|
1499
|
-
!r.includes("/") && !r.includes(".") && (
|
|
1500
|
-
const t = await fetch(
|
|
1501
|
+
let a = r;
|
|
1502
|
+
!r.includes("/") && !r.includes(".") && (a = `/locales/${e}/${r}.json`);
|
|
1503
|
+
const t = await fetch(a);
|
|
1501
1504
|
if (!t.ok) {
|
|
1502
|
-
const
|
|
1505
|
+
const d = `HTTP ${t.status}: ${t.statusText}`;
|
|
1503
1506
|
return t.status === 404 ? (ye.set(n, {}), Ae.set(n, {
|
|
1504
1507
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
1505
1508
|
size: 0,
|
|
@@ -1508,62 +1511,62 @@ const Or = (e, r) => {
|
|
|
1508
1511
|
success: !0,
|
|
1509
1512
|
translations: {},
|
|
1510
1513
|
fromCache: !1
|
|
1511
|
-
}) : (
|
|
1514
|
+
}) : (ie.add(n), {
|
|
1512
1515
|
success: !1,
|
|
1513
1516
|
translations: {},
|
|
1514
|
-
error:
|
|
1517
|
+
error: d
|
|
1515
1518
|
});
|
|
1516
1519
|
}
|
|
1517
|
-
const
|
|
1518
|
-
!
|
|
1519
|
-
`Translation file at ${
|
|
1520
|
+
const o = t.headers.get("content-type") || "";
|
|
1521
|
+
!o.includes("application/json") && !o.includes("text/json") && sr() && console.warn(
|
|
1522
|
+
`Translation file at ${a} has unexpected content-type: ${o}`
|
|
1520
1523
|
);
|
|
1521
1524
|
const s = await t.text();
|
|
1522
1525
|
if (!s) {
|
|
1523
|
-
const
|
|
1524
|
-
return
|
|
1526
|
+
const d = "Empty translation file";
|
|
1527
|
+
return ie.add(n), { success: !1, translations: {}, error: d };
|
|
1525
1528
|
}
|
|
1526
1529
|
let i;
|
|
1527
1530
|
try {
|
|
1528
1531
|
i = JSON.parse(s);
|
|
1529
|
-
} catch (
|
|
1530
|
-
const l = `Invalid JSON in translation file: ${
|
|
1531
|
-
return
|
|
1532
|
+
} catch (d) {
|
|
1533
|
+
const l = `Invalid JSON in translation file: ${d instanceof Error ? d.message : String(d)}`;
|
|
1534
|
+
return ie.add(n), { success: !1, translations: {}, error: l };
|
|
1532
1535
|
}
|
|
1533
1536
|
if (!i || typeof i != "object") {
|
|
1534
|
-
const
|
|
1535
|
-
return
|
|
1537
|
+
const d = "Invalid translation file format";
|
|
1538
|
+
return ie.add(n), {
|
|
1536
1539
|
success: !1,
|
|
1537
1540
|
translations: {},
|
|
1538
|
-
error:
|
|
1541
|
+
error: d
|
|
1539
1542
|
};
|
|
1540
1543
|
}
|
|
1541
|
-
const
|
|
1542
|
-
Object.entries(i).map(([
|
|
1543
|
-
|
|
1544
|
+
const m = Object.fromEntries(
|
|
1545
|
+
Object.entries(i).map(([d, l]) => [
|
|
1546
|
+
d,
|
|
1544
1547
|
typeof l == "string" ? l : String(l)
|
|
1545
1548
|
])
|
|
1546
1549
|
);
|
|
1547
|
-
if (!
|
|
1548
|
-
const
|
|
1549
|
-
return
|
|
1550
|
+
if (!m || typeof m != "object") {
|
|
1551
|
+
const d = "Invalid translation file format";
|
|
1552
|
+
return ie.add(n), {
|
|
1550
1553
|
success: !1,
|
|
1551
1554
|
translations: {},
|
|
1552
|
-
error:
|
|
1555
|
+
error: d
|
|
1553
1556
|
};
|
|
1554
1557
|
}
|
|
1555
|
-
return ye.set(n,
|
|
1558
|
+
return ye.set(n, m), Ae.set(n, {
|
|
1556
1559
|
loadedAt: /* @__PURE__ */ new Date(),
|
|
1557
|
-
size: Object.keys(
|
|
1560
|
+
size: Object.keys(m).length,
|
|
1558
1561
|
source: "user"
|
|
1559
1562
|
}), {
|
|
1560
1563
|
success: !0,
|
|
1561
|
-
translations:
|
|
1564
|
+
translations: m,
|
|
1562
1565
|
fromCache: !1
|
|
1563
1566
|
};
|
|
1564
|
-
} catch (
|
|
1565
|
-
const t = `Failed to load user translations: ${
|
|
1566
|
-
return
|
|
1567
|
+
} catch (a) {
|
|
1568
|
+
const t = `Failed to load user translations: ${a instanceof Error ? a.message : "Unknown error"}`;
|
|
1569
|
+
return ie.add(n), {
|
|
1567
1570
|
success: !1,
|
|
1568
1571
|
translations: {},
|
|
1569
1572
|
error: t
|
|
@@ -1579,23 +1582,23 @@ function sr() {
|
|
|
1579
1582
|
return !1;
|
|
1580
1583
|
}
|
|
1581
1584
|
function Tr(e, r) {
|
|
1582
|
-
return r.length === 0 ? e : e.replace(/\{\{(\d+)\}\}/g, (n,
|
|
1583
|
-
const t = parseInt(
|
|
1584
|
-
if (
|
|
1585
|
+
return r.length === 0 ? e : e.replace(/\{\{(\d+)\}\}/g, (n, a) => {
|
|
1586
|
+
const t = parseInt(a, 10) - 1, o = r[t];
|
|
1587
|
+
if (o == null)
|
|
1585
1588
|
return n;
|
|
1586
1589
|
try {
|
|
1587
|
-
return String(
|
|
1590
|
+
return String(o);
|
|
1588
1591
|
} catch {
|
|
1589
1592
|
return n;
|
|
1590
1593
|
}
|
|
1591
1594
|
});
|
|
1592
1595
|
}
|
|
1593
|
-
const Lr = (e, r, n) => (
|
|
1594
|
-
let
|
|
1595
|
-
return !
|
|
1596
|
-
`Missing translation for "${
|
|
1597
|
-
),
|
|
1598
|
-
},
|
|
1596
|
+
const Lr = (e, r, n) => (a, ...t) => {
|
|
1597
|
+
let o = a, s = !1;
|
|
1598
|
+
return !a || typeof a != "string" ? String(a || "") : (e.toLowerCase() === "en" ? (o = a, s = !0) : Object.prototype.hasOwnProperty.call(n, a) ? (o = n[a], s = !0) : Object.prototype.hasOwnProperty.call(r, a) ? (o = r[a], s = !0) : o = a, o = Tr(o, t), !s && sr() && console.debug(
|
|
1599
|
+
`Missing translation for "${a}" in language "${e}"`
|
|
1600
|
+
), o);
|
|
1601
|
+
}, Ve = {
|
|
1599
1602
|
length: ["m", "cm", "mm", "km", "in", "ft", "yd", "mi"],
|
|
1600
1603
|
area: ["m^2", "cm^2", "mm^2", "in^2", "ft^2", "yd^2"],
|
|
1601
1604
|
volume: ["L", "m^3", "cm^3", "mL", "in^3", "ft^3", "yd^3"],
|
|
@@ -1713,74 +1716,76 @@ const Lr = (e, r, n) => (o, ...t) => {
|
|
|
1713
1716
|
rev: 1 / 360
|
|
1714
1717
|
}
|
|
1715
1718
|
}, Le = {}, Pr = /* @__PURE__ */ new Set([
|
|
1716
|
-
...Object.keys(
|
|
1719
|
+
...Object.keys(Ve),
|
|
1717
1720
|
...Object.keys(ze),
|
|
1718
1721
|
...Object.keys(Te)
|
|
1719
1722
|
]);
|
|
1720
1723
|
for (const e of Pr) {
|
|
1721
|
-
const r = {}, n =
|
|
1722
|
-
for (const
|
|
1723
|
-
const s = o
|
|
1724
|
-
r[
|
|
1725
|
-
name: typeof s == "string" ? s : String(
|
|
1726
|
-
shortName:
|
|
1727
|
-
factor: Object.prototype.hasOwnProperty.call(t,
|
|
1724
|
+
const r = {}, n = Ve[e] ?? [], a = ze[e] ?? {}, t = Te[e] ?? {};
|
|
1725
|
+
for (const o of n) {
|
|
1726
|
+
const s = a[o];
|
|
1727
|
+
r[o] = {
|
|
1728
|
+
name: typeof s == "string" ? s : String(o),
|
|
1729
|
+
shortName: o,
|
|
1730
|
+
factor: Object.prototype.hasOwnProperty.call(t, o) ? t[o] : void 0
|
|
1728
1731
|
};
|
|
1729
1732
|
}
|
|
1730
|
-
for (const [
|
|
1731
|
-
if (!r[
|
|
1732
|
-
const i = typeof s == "string" ? s : String(
|
|
1733
|
-
r[
|
|
1733
|
+
for (const [o, s] of Object.entries(a))
|
|
1734
|
+
if (!r[o]) {
|
|
1735
|
+
const i = typeof s == "string" ? s : String(o);
|
|
1736
|
+
r[o] = { name: i, shortName: o, factor: Object.prototype.hasOwnProperty.call(t, o) ? t[o] : void 0 };
|
|
1734
1737
|
}
|
|
1735
|
-
for (const [
|
|
1736
|
-
r[
|
|
1738
|
+
for (const [o, s] of Object.entries(t))
|
|
1739
|
+
r[o] || (r[o] = { name: String(o), shortName: String(o), factor: s });
|
|
1737
1740
|
Le[e] = r;
|
|
1738
1741
|
}
|
|
1739
|
-
const
|
|
1742
|
+
const an = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1740
1743
|
__proto__: null,
|
|
1741
1744
|
dimensionUnitDisplayMap: ze,
|
|
1742
|
-
dimensionUnitsMap:
|
|
1745
|
+
dimensionUnitsMap: Ve,
|
|
1743
1746
|
dimensonUnitFactorsMap: Te,
|
|
1744
1747
|
unitsByDimension: Le
|
|
1745
1748
|
}, Symbol.toStringTag, { value: "Module" })), _r = ({
|
|
1746
1749
|
field: e,
|
|
1747
1750
|
value: r,
|
|
1748
1751
|
onChange: n,
|
|
1749
|
-
onError:
|
|
1752
|
+
onError: a
|
|
1750
1753
|
}) => {
|
|
1751
|
-
const { definitionName: t, t:
|
|
1752
|
-
|
|
1753
|
-
s.current =
|
|
1754
|
-
}, [
|
|
1755
|
-
const
|
|
1756
|
-
s.current?.(
|
|
1757
|
-
}, [r, e, t,
|
|
1758
|
-
const i = (
|
|
1759
|
-
const
|
|
1760
|
-
n?.(
|
|
1761
|
-
},
|
|
1762
|
-
(
|
|
1763
|
-
},
|
|
1764
|
-
return /* @__PURE__ */ g.jsx(
|
|
1754
|
+
const { definitionName: t, t: o } = L(), s = E(a);
|
|
1755
|
+
k(() => {
|
|
1756
|
+
s.current = a;
|
|
1757
|
+
}, [a]), k(() => {
|
|
1758
|
+
const u = H(t, e, r ?? !1, o);
|
|
1759
|
+
s.current?.(u ?? null);
|
|
1760
|
+
}, [r, e, t, o]);
|
|
1761
|
+
const i = (u) => {
|
|
1762
|
+
const c = u.target.checked;
|
|
1763
|
+
n?.(c, null);
|
|
1764
|
+
}, m = (u) => {
|
|
1765
|
+
(u.key === " " || u.key === "Spacebar" || u.key === "Space" || u.key === "Enter") && (u.preventDefault(), n?.(!r, null));
|
|
1766
|
+
}, d = e.name, l = H(t, e, r ?? !1, o);
|
|
1767
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, rightAlign: !1, children: /* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }, children: [
|
|
1765
1768
|
/* @__PURE__ */ g.jsx(
|
|
1766
1769
|
"label",
|
|
1767
1770
|
{
|
|
1768
|
-
className:
|
|
1769
|
-
htmlFor:
|
|
1771
|
+
className: M.label,
|
|
1772
|
+
htmlFor: d,
|
|
1770
1773
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
1771
|
-
children:
|
|
1774
|
+
children: o(e.displayName)
|
|
1772
1775
|
}
|
|
1773
1776
|
),
|
|
1774
1777
|
/* @__PURE__ */ g.jsx(
|
|
1775
1778
|
"input",
|
|
1776
1779
|
{
|
|
1777
|
-
id:
|
|
1780
|
+
id: d,
|
|
1778
1781
|
"data-testid": "boolean-checkbox",
|
|
1779
1782
|
type: "checkbox",
|
|
1780
1783
|
checked: !!r,
|
|
1781
1784
|
onChange: i,
|
|
1782
|
-
onKeyDown:
|
|
1785
|
+
onKeyDown: m,
|
|
1783
1786
|
"aria-checked": !!r,
|
|
1787
|
+
"aria-invalid": !!l,
|
|
1788
|
+
"aria-describedby": l ? `${e.name}-error` : void 0,
|
|
1784
1789
|
style: {
|
|
1785
1790
|
cursor: "pointer",
|
|
1786
1791
|
margin: "8px 0 8px 0",
|
|
@@ -1825,45 +1830,47 @@ function qr(e) {
|
|
|
1825
1830
|
function cr(e) {
|
|
1826
1831
|
return e ? (e = e.toLowerCase(), /^#([a-f0-9]){3}$/i.test(e) ? "#" + e.slice(1).split("").map((r) => r + r).join("") : e) : "#000000";
|
|
1827
1832
|
}
|
|
1828
|
-
const Br = ({ field: e, value: r, onChange: n, onError:
|
|
1829
|
-
const { t, definitionName:
|
|
1830
|
-
|
|
1831
|
-
l.current =
|
|
1832
|
-
}, [
|
|
1833
|
-
const x = r && ir(r) ? r : "#000000",
|
|
1834
|
-
i(
|
|
1835
|
-
}, [r]),
|
|
1836
|
-
const x =
|
|
1833
|
+
const Br = ({ field: e, value: r, onChange: n, onError: a }) => {
|
|
1834
|
+
const { t, definitionName: o } = L(), [s, i] = V("#000000"), m = F.useRef(null), d = F.useRef(null), l = F.useRef(a);
|
|
1835
|
+
F.useEffect(() => {
|
|
1836
|
+
l.current = a;
|
|
1837
|
+
}, [a]), k(() => {
|
|
1838
|
+
const x = r && ir(r) ? r : "#000000", j = cr(x);
|
|
1839
|
+
i(j);
|
|
1840
|
+
}, [r]), F.useEffect(() => {
|
|
1841
|
+
const x = H(o, e, r ?? "#000000", t);
|
|
1837
1842
|
l.current?.(x ?? null);
|
|
1838
|
-
}, [r, e,
|
|
1839
|
-
const
|
|
1840
|
-
const
|
|
1841
|
-
i(
|
|
1842
|
-
},
|
|
1843
|
-
const
|
|
1844
|
-
i(
|
|
1845
|
-
},
|
|
1843
|
+
}, [r, e, o, t]);
|
|
1844
|
+
const u = H(o, e, r ?? "#000000", t), c = (x) => {
|
|
1845
|
+
const j = x.target.value;
|
|
1846
|
+
i(j), n?.(j, null);
|
|
1847
|
+
}, p = (x) => {
|
|
1848
|
+
const j = x.target.value;
|
|
1849
|
+
i(j), n?.(j, null);
|
|
1850
|
+
}, b = Ge.find(
|
|
1846
1851
|
(x) => x.value === s
|
|
1847
|
-
), { r:
|
|
1848
|
-
return /* @__PURE__ */ g.jsx(
|
|
1852
|
+
), { r: f, g: y, b: C } = qr(s) || { r: 0, g: 0, b: 0 };
|
|
1853
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: u, children: /* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" }, children: [
|
|
1849
1854
|
/* @__PURE__ */ g.jsxs(
|
|
1850
1855
|
"select",
|
|
1851
1856
|
{
|
|
1852
|
-
ref:
|
|
1857
|
+
ref: m,
|
|
1853
1858
|
id: e.name,
|
|
1854
1859
|
value: s,
|
|
1855
|
-
onChange:
|
|
1860
|
+
onChange: c,
|
|
1856
1861
|
style: { minWidth: "120px", flex: 1 },
|
|
1857
|
-
className:
|
|
1862
|
+
className: G(M.input, M.inputSelect),
|
|
1863
|
+
"aria-invalid": !!u,
|
|
1864
|
+
"aria-describedby": u ? `${e.name}-error` : void 0,
|
|
1858
1865
|
children: [
|
|
1859
1866
|
Ge.map((x) => /* @__PURE__ */ g.jsx("option", { value: x.value, children: t(x.label) }, x.value)),
|
|
1860
|
-
|
|
1867
|
+
b ? null : /* @__PURE__ */ g.jsxs("option", { value: s, children: [
|
|
1861
1868
|
"(",
|
|
1862
|
-
b,
|
|
1863
|
-
", ",
|
|
1864
1869
|
f,
|
|
1865
1870
|
", ",
|
|
1866
1871
|
y,
|
|
1872
|
+
", ",
|
|
1873
|
+
C,
|
|
1867
1874
|
")"
|
|
1868
1875
|
] }, s)
|
|
1869
1876
|
]
|
|
@@ -1886,10 +1893,11 @@ const Br = ({ field: e, value: r, onChange: n, onError: o }) => {
|
|
|
1886
1893
|
children: /* @__PURE__ */ g.jsx(
|
|
1887
1894
|
"input",
|
|
1888
1895
|
{
|
|
1889
|
-
ref:
|
|
1896
|
+
ref: d,
|
|
1897
|
+
id: `${e.name}-color`,
|
|
1890
1898
|
type: "color",
|
|
1891
1899
|
value: s,
|
|
1892
|
-
onChange:
|
|
1900
|
+
onChange: p,
|
|
1893
1901
|
style: {
|
|
1894
1902
|
opacity: 0,
|
|
1895
1903
|
width: "100%",
|
|
@@ -1897,7 +1905,9 @@ const Br = ({ field: e, value: r, onChange: n, onError: o }) => {
|
|
|
1897
1905
|
border: "none",
|
|
1898
1906
|
padding: 0,
|
|
1899
1907
|
cursor: "pointer"
|
|
1900
|
-
}
|
|
1908
|
+
},
|
|
1909
|
+
"aria-invalid": !!u,
|
|
1910
|
+
"aria-describedby": u ? `${e.name}-error` : void 0
|
|
1901
1911
|
}
|
|
1902
1912
|
)
|
|
1903
1913
|
}
|
|
@@ -1913,21 +1923,21 @@ const Br = ({ field: e, value: r, onChange: n, onError: o }) => {
|
|
|
1913
1923
|
return ge(e) ? e : "";
|
|
1914
1924
|
const n = ge(e);
|
|
1915
1925
|
if (n) {
|
|
1916
|
-
const
|
|
1917
|
-
return `${
|
|
1926
|
+
const a = n.getFullYear(), t = String(n.getMonth() + 1).padStart(2, "0"), o = String(n.getDate()).padStart(2, "0");
|
|
1927
|
+
return `${a}-${t}-${o}`;
|
|
1918
1928
|
}
|
|
1919
1929
|
return "";
|
|
1920
1930
|
}, Ur = ({
|
|
1921
1931
|
field: e,
|
|
1922
1932
|
value: r,
|
|
1923
1933
|
onChange: n,
|
|
1924
|
-
onError:
|
|
1934
|
+
onError: a
|
|
1925
1935
|
}) => {
|
|
1926
|
-
const { t, definitionName:
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
}, [
|
|
1930
|
-
const l =
|
|
1936
|
+
const { t, definitionName: o } = L(), { name: s, required: i } = e, m = E(null), d = E(a);
|
|
1937
|
+
k(() => {
|
|
1938
|
+
d.current = a;
|
|
1939
|
+
}, [a]);
|
|
1940
|
+
const l = F.useCallback((c) => {
|
|
1931
1941
|
if (!c || c.trim() === "")
|
|
1932
1942
|
return i ? t("Value required") : null;
|
|
1933
1943
|
if (c) {
|
|
@@ -1944,22 +1954,22 @@ const Br = ({ field: e, value: r, onChange: n, onError: o }) => {
|
|
|
1944
1954
|
return t("Date must be on or before {{1}}", e.maxDate);
|
|
1945
1955
|
}
|
|
1946
1956
|
}
|
|
1947
|
-
return
|
|
1948
|
-
}, [e,
|
|
1949
|
-
const
|
|
1950
|
-
n?.(
|
|
1957
|
+
return H(o, e, c, t) ?? null;
|
|
1958
|
+
}, [e, o, t, i]), u = (c) => {
|
|
1959
|
+
const p = c.target.value, b = l(p);
|
|
1960
|
+
n?.(p, b);
|
|
1951
1961
|
};
|
|
1952
|
-
return
|
|
1962
|
+
return k(() => {
|
|
1953
1963
|
const c = l(r);
|
|
1954
|
-
c !==
|
|
1955
|
-
}, [r, l]), /* @__PURE__ */ g.jsx(
|
|
1964
|
+
c !== m.current && (m.current = c, d.current?.(c ?? null));
|
|
1965
|
+
}, [r, l]), /* @__PURE__ */ g.jsx(U, { field: e, error: l(r), children: /* @__PURE__ */ g.jsx(
|
|
1956
1966
|
"input",
|
|
1957
1967
|
{
|
|
1958
1968
|
id: s,
|
|
1959
1969
|
type: "date",
|
|
1960
1970
|
value: Hr(r),
|
|
1961
|
-
onChange:
|
|
1962
|
-
className:
|
|
1971
|
+
onChange: u,
|
|
1972
|
+
className: G(M.input, M.textInput),
|
|
1963
1973
|
...e.minDate ? { min: e.minDate } : {},
|
|
1964
1974
|
...e.maxDate ? { max: e.maxDate } : {},
|
|
1965
1975
|
"aria-invalid": !!l(r),
|
|
@@ -1970,37 +1980,40 @@ const Br = ({ field: e, value: r, onChange: n, onError: o }) => {
|
|
|
1970
1980
|
field: e,
|
|
1971
1981
|
value: r,
|
|
1972
1982
|
onChange: n,
|
|
1973
|
-
onError:
|
|
1983
|
+
onError: a
|
|
1974
1984
|
}) => {
|
|
1975
|
-
const { t, definitionName:
|
|
1976
|
-
|
|
1977
|
-
i.current =
|
|
1978
|
-
}, [
|
|
1979
|
-
const
|
|
1980
|
-
(l) => l === "" || l === null || l === void 0 ? t("Value required") : !e.options || e.options.length === 0 ? null : e.options.some((c) => c.value === l) ?
|
|
1981
|
-
[e, t,
|
|
1985
|
+
const { t, definitionName: o } = L(), s = E(null), i = E(a);
|
|
1986
|
+
k(() => {
|
|
1987
|
+
i.current = a;
|
|
1988
|
+
}, [a]);
|
|
1989
|
+
const m = X(
|
|
1990
|
+
(l) => l === "" || l === null || l === void 0 ? t("Value required") : !e.options || e.options.length === 0 ? null : e.options.some((c) => c.value === l) ? H(o, e, l, t) ?? null : t("Invalid option selected"),
|
|
1991
|
+
[e, t, o]
|
|
1982
1992
|
);
|
|
1983
|
-
|
|
1984
|
-
const l = r != null ? String(r) : "",
|
|
1985
|
-
if (
|
|
1993
|
+
k(() => {
|
|
1994
|
+
const l = r != null ? String(r) : "", u = m(l);
|
|
1995
|
+
if (u && e.options && e.options.length > 0) {
|
|
1986
1996
|
const c = String(e.options[0].value);
|
|
1987
1997
|
s.current && (s.current.value = c), n?.(c, null), i.current?.(null);
|
|
1988
1998
|
} else
|
|
1989
|
-
s.current && (s.current.value = l), i.current?.(
|
|
1990
|
-
}, [r,
|
|
1991
|
-
const
|
|
1992
|
-
const
|
|
1993
|
-
n?.(
|
|
1999
|
+
s.current && (s.current.value = l), i.current?.(u ?? null);
|
|
2000
|
+
}, [r, m, n, e.options]);
|
|
2001
|
+
const d = (l) => {
|
|
2002
|
+
const u = l.target.value, c = m(u);
|
|
2003
|
+
n?.(u, c);
|
|
1994
2004
|
};
|
|
1995
|
-
return /* @__PURE__ */ g.jsx(
|
|
2005
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: m(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
1996
2006
|
"select",
|
|
1997
2007
|
{
|
|
2008
|
+
id: e.name,
|
|
2009
|
+
"aria-invalid": !!m(String(r ?? "")),
|
|
2010
|
+
"aria-describedby": m(String(r ?? "")) ? `${e.name}-error` : void 0,
|
|
1998
2011
|
defaultValue: String(r ?? ""),
|
|
1999
2012
|
ref: s,
|
|
2000
|
-
onChange:
|
|
2001
|
-
className:
|
|
2002
|
-
|
|
2003
|
-
|
|
2013
|
+
onChange: d,
|
|
2014
|
+
className: G(
|
|
2015
|
+
M.input,
|
|
2016
|
+
M.inputSelect
|
|
2004
2017
|
),
|
|
2005
2018
|
children: (e.options ?? []).map((l) => /* @__PURE__ */ g.jsx("option", { value: String(l.value), children: t(l.label) }, String(l.value)))
|
|
2006
2019
|
}
|
|
@@ -2013,40 +2026,42 @@ const Jr = ({
|
|
|
2013
2026
|
field: e,
|
|
2014
2027
|
value: r,
|
|
2015
2028
|
onChange: n,
|
|
2016
|
-
onError:
|
|
2029
|
+
onError: a
|
|
2017
2030
|
}) => {
|
|
2018
|
-
const { definitionName: t, t:
|
|
2019
|
-
(
|
|
2020
|
-
const c =
|
|
2021
|
-
return c === "" ? e.required ?
|
|
2031
|
+
const { definitionName: t, t: o } = L(), s = E(null), i = F.useCallback(
|
|
2032
|
+
(u) => {
|
|
2033
|
+
const c = u.trim();
|
|
2034
|
+
return c === "" ? e.required ? o("Value required") : null : Yr(c) ? e.pattern && !new RegExp(e.pattern).test(c) ? e.patternErrorMessage ? o(e.patternErrorMessage) : o("Email does not match pattern: {{%1}}", {
|
|
2022
2035
|
"%1": `${e.pattern}`
|
|
2023
|
-
}) :
|
|
2036
|
+
}) : H(t, e, u, o) ?? null : o("Must be valid email format");
|
|
2024
2037
|
},
|
|
2025
|
-
[e, t,
|
|
2026
|
-
),
|
|
2027
|
-
const c =
|
|
2028
|
-
n?.(c,
|
|
2029
|
-
},
|
|
2030
|
-
return
|
|
2031
|
-
l.current =
|
|
2032
|
-
}, [
|
|
2033
|
-
const
|
|
2034
|
-
s.current && s.current.value !== String(
|
|
2035
|
-
}, [r, i]), /* @__PURE__ */ g.jsx(
|
|
2038
|
+
[e, t, o]
|
|
2039
|
+
), m = (u) => {
|
|
2040
|
+
const c = u.target.value, p = i(c);
|
|
2041
|
+
n?.(c, p);
|
|
2042
|
+
}, d = E(null), l = E(a);
|
|
2043
|
+
return k(() => {
|
|
2044
|
+
l.current = a;
|
|
2045
|
+
}, [a]), k(() => {
|
|
2046
|
+
const u = r ?? "", c = i(u);
|
|
2047
|
+
s.current && s.current.value !== String(u) && (s.current.value = String(u)), c !== d.current && (d.current = c, l.current?.(c ?? null));
|
|
2048
|
+
}, [r, i]), /* @__PURE__ */ g.jsx(U, { field: e, error: i(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
2036
2049
|
"input",
|
|
2037
2050
|
{
|
|
2038
2051
|
id: e.name,
|
|
2039
2052
|
type: "email",
|
|
2040
2053
|
defaultValue: String(r ?? ""),
|
|
2041
2054
|
ref: s,
|
|
2042
|
-
onChange:
|
|
2043
|
-
className:
|
|
2055
|
+
onChange: m,
|
|
2056
|
+
className: G(M.input, M.textInput),
|
|
2057
|
+
"aria-invalid": !!i(String(r ?? "")),
|
|
2058
|
+
"aria-describedby": i(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
2044
2059
|
}
|
|
2045
2060
|
) });
|
|
2046
2061
|
}, Gr = ({ field: e }) => {
|
|
2047
|
-
const { darkMode: r } =
|
|
2062
|
+
const { darkMode: r } = L(), {
|
|
2048
2063
|
color: n = r ? "#444444" : "#CCCCCC",
|
|
2049
|
-
thickness:
|
|
2064
|
+
thickness: a = 1,
|
|
2050
2065
|
margin: t = "8px 0"
|
|
2051
2066
|
} = e;
|
|
2052
2067
|
return /* @__PURE__ */ g.jsx(
|
|
@@ -2056,63 +2071,63 @@ const Jr = ({
|
|
|
2056
2071
|
width: "auto",
|
|
2057
2072
|
height: "0",
|
|
2058
2073
|
// ensures only 1 line
|
|
2059
|
-
borderTop: `${
|
|
2074
|
+
borderTop: `${a}px solid ${n}`,
|
|
2060
2075
|
margin: t
|
|
2061
2076
|
}
|
|
2062
2077
|
}
|
|
2063
2078
|
);
|
|
2064
|
-
}, Kr = ({ field: e, value: r, onChange: n, onError:
|
|
2065
|
-
const { t, definitionName:
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
}, [
|
|
2069
|
-
const l =
|
|
2070
|
-
(
|
|
2071
|
-
[e,
|
|
2072
|
-
),
|
|
2073
|
-
|
|
2074
|
-
const
|
|
2075
|
-
n?.(r,
|
|
2079
|
+
}, Kr = ({ field: e, value: r, onChange: n, onError: a }) => {
|
|
2080
|
+
const { t, definitionName: o } = L(), [s, i] = V(!1), m = E(null), d = E(a);
|
|
2081
|
+
k(() => {
|
|
2082
|
+
d.current = a;
|
|
2083
|
+
}, [a]);
|
|
2084
|
+
const l = F.useCallback(
|
|
2085
|
+
(x) => e.required && (!x || Array.isArray(x) && x.length === 0) ? t("Value required") : H(o, e, x, t) ?? null,
|
|
2086
|
+
[e, o, t]
|
|
2087
|
+
), u = F.useMemo(() => l(r), [r, l]);
|
|
2088
|
+
k(() => {
|
|
2089
|
+
const x = l(r);
|
|
2090
|
+
n?.(r, x), d.current?.(x ?? null);
|
|
2076
2091
|
}, [r, l]);
|
|
2077
|
-
const c = (
|
|
2078
|
-
const
|
|
2079
|
-
let
|
|
2080
|
-
if (
|
|
2081
|
-
const
|
|
2082
|
-
e.multiple ?
|
|
2092
|
+
const c = (x) => {
|
|
2093
|
+
const j = x.target.files;
|
|
2094
|
+
let N = null;
|
|
2095
|
+
if (j && j.length > 0) {
|
|
2096
|
+
const w = Array.from(j);
|
|
2097
|
+
e.multiple ? N = [...Array.isArray(r) ? r : [], ...w] : N = w[0];
|
|
2083
2098
|
}
|
|
2084
|
-
const
|
|
2085
|
-
n?.(
|
|
2086
|
-
},
|
|
2087
|
-
|
|
2088
|
-
const
|
|
2089
|
-
if (
|
|
2090
|
-
const
|
|
2091
|
-
let
|
|
2092
|
-
e.multiple ?
|
|
2093
|
-
const
|
|
2094
|
-
n?.(
|
|
2099
|
+
const v = l(N);
|
|
2100
|
+
n?.(N, v);
|
|
2101
|
+
}, p = (x) => {
|
|
2102
|
+
x.preventDefault(), x.stopPropagation(), i(!1);
|
|
2103
|
+
const j = x.dataTransfer.files;
|
|
2104
|
+
if (j && j.length > 0) {
|
|
2105
|
+
const N = Array.from(j);
|
|
2106
|
+
let v = null;
|
|
2107
|
+
e.multiple ? v = [...Array.isArray(r) ? r : [], ...N] : v = N[0];
|
|
2108
|
+
const w = l(v);
|
|
2109
|
+
n?.(v, w);
|
|
2095
2110
|
}
|
|
2096
|
-
}, b = (
|
|
2097
|
-
|
|
2098
|
-
}, f = (
|
|
2099
|
-
|
|
2100
|
-
}, y = (
|
|
2101
|
-
if (Array.isArray(r) && typeof
|
|
2102
|
-
const
|
|
2103
|
-
n?.(
|
|
2111
|
+
}, b = (x) => {
|
|
2112
|
+
x.preventDefault(), x.stopPropagation(), i(!0);
|
|
2113
|
+
}, f = (x) => {
|
|
2114
|
+
x.preventDefault(), x.stopPropagation(), i(!1);
|
|
2115
|
+
}, y = (x) => {
|
|
2116
|
+
if (Array.isArray(r) && typeof x == "number") {
|
|
2117
|
+
const j = r.filter((w, I) => I !== x), N = j.length > 0 ? j : null, v = l(N);
|
|
2118
|
+
n?.(N, v);
|
|
2104
2119
|
} else {
|
|
2105
|
-
const
|
|
2106
|
-
n?.(null,
|
|
2120
|
+
const j = l(null);
|
|
2121
|
+
n?.(null, j);
|
|
2107
2122
|
}
|
|
2108
|
-
},
|
|
2109
|
-
const
|
|
2110
|
-
return
|
|
2123
|
+
}, C = () => {
|
|
2124
|
+
const x = Array.isArray(r) ? r : r ? [r] : [];
|
|
2125
|
+
return x.length === 0 ? null : /* @__PURE__ */ g.jsx("div", { style: {
|
|
2111
2126
|
marginTop: "8px",
|
|
2112
2127
|
display: "flex",
|
|
2113
2128
|
flexDirection: "column",
|
|
2114
2129
|
gap: "6px"
|
|
2115
|
-
}, children:
|
|
2130
|
+
}, children: x.map((j, N) => /* @__PURE__ */ g.jsxs(
|
|
2116
2131
|
"div",
|
|
2117
2132
|
{
|
|
2118
2133
|
style: {
|
|
@@ -2133,12 +2148,12 @@ const Jr = ({
|
|
|
2133
2148
|
overflow: "hidden",
|
|
2134
2149
|
textOverflow: "ellipsis",
|
|
2135
2150
|
whiteSpace: "nowrap"
|
|
2136
|
-
}, children:
|
|
2151
|
+
}, children: j.name }),
|
|
2137
2152
|
/* @__PURE__ */ g.jsx(
|
|
2138
2153
|
"button",
|
|
2139
2154
|
{
|
|
2140
2155
|
type: "button",
|
|
2141
|
-
onClick: () => y(Array.isArray(r) ?
|
|
2156
|
+
onClick: () => y(Array.isArray(r) ? N : void 0),
|
|
2142
2157
|
"aria-label": t("Remove file"),
|
|
2143
2158
|
style: {
|
|
2144
2159
|
background: "transparent",
|
|
@@ -2152,30 +2167,30 @@ const Jr = ({
|
|
|
2152
2167
|
transition: "background-color 0.2s",
|
|
2153
2168
|
flexShrink: 0
|
|
2154
2169
|
},
|
|
2155
|
-
onMouseEnter: (
|
|
2156
|
-
|
|
2170
|
+
onMouseEnter: (v) => {
|
|
2171
|
+
v.currentTarget.style.backgroundColor = "var(--reactaform-bg-hover, #fee)";
|
|
2157
2172
|
},
|
|
2158
|
-
onMouseLeave: (
|
|
2159
|
-
|
|
2173
|
+
onMouseLeave: (v) => {
|
|
2174
|
+
v.currentTarget.style.backgroundColor = "transparent";
|
|
2160
2175
|
},
|
|
2161
2176
|
children: "×"
|
|
2162
2177
|
}
|
|
2163
2178
|
)
|
|
2164
2179
|
]
|
|
2165
2180
|
},
|
|
2166
|
-
`${
|
|
2181
|
+
`${j.name}-${N}`
|
|
2167
2182
|
)) });
|
|
2168
2183
|
};
|
|
2169
|
-
return /* @__PURE__ */ g.jsx(
|
|
2184
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: u, children: /* @__PURE__ */ g.jsxs("div", { style: { width: "100%" }, children: [
|
|
2170
2185
|
/* @__PURE__ */ g.jsxs(
|
|
2171
2186
|
"div",
|
|
2172
2187
|
{
|
|
2173
|
-
onDrop:
|
|
2188
|
+
onDrop: p,
|
|
2174
2189
|
onDragOver: b,
|
|
2175
2190
|
onDragLeave: f,
|
|
2176
2191
|
style: {
|
|
2177
2192
|
position: "relative",
|
|
2178
|
-
border: `1px dashed ${s ? "var(--reactaform-color-primary, #2563eb)" :
|
|
2193
|
+
border: `1px dashed ${s ? "var(--reactaform-color-primary, #2563eb)" : u ? "var(--reactaform-color-error, #ef4444)" : "var(--reactaform-border-color, #d1d5db)"}`,
|
|
2179
2194
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
2180
2195
|
padding: "8px 12px",
|
|
2181
2196
|
textAlign: "center",
|
|
@@ -2192,13 +2207,20 @@ const Jr = ({
|
|
|
2192
2207
|
justifyContent: "center",
|
|
2193
2208
|
gap: "8px"
|
|
2194
2209
|
},
|
|
2195
|
-
onClick: () =>
|
|
2210
|
+
onClick: () => m.current?.click(),
|
|
2211
|
+
onKeyDown: (x) => {
|
|
2212
|
+
(x.key === "Enter" || x.key === " ") && (x.preventDefault(), m.current?.click());
|
|
2213
|
+
},
|
|
2214
|
+
role: "button",
|
|
2215
|
+
"aria-label": e.multiple ? t("Choose Files or Drag & Drop") : t("Choose File or Drag & Drop"),
|
|
2216
|
+
"aria-invalid": !!u,
|
|
2217
|
+
"aria-describedby": u ? `${e.name}-error` : void 0,
|
|
2196
2218
|
children: [
|
|
2197
2219
|
/* @__PURE__ */ g.jsx(
|
|
2198
2220
|
"input",
|
|
2199
2221
|
{
|
|
2200
2222
|
id: e.name,
|
|
2201
|
-
ref:
|
|
2223
|
+
ref: m,
|
|
2202
2224
|
type: "file",
|
|
2203
2225
|
accept: e.accept,
|
|
2204
2226
|
multiple: e.multiple,
|
|
@@ -2232,7 +2254,7 @@ const Jr = ({
|
|
|
2232
2254
|
]
|
|
2233
2255
|
}
|
|
2234
2256
|
),
|
|
2235
|
-
|
|
2257
|
+
C()
|
|
2236
2258
|
] }) });
|
|
2237
2259
|
}, Xr = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
2238
2260
|
function Zr(e) {
|
|
@@ -2242,22 +2264,22 @@ const Qr = (e) => !e || e.trim() === "" ? [] : e.split(",").map((r) => r.trim())
|
|
|
2242
2264
|
field: e,
|
|
2243
2265
|
value: r,
|
|
2244
2266
|
onChange: n,
|
|
2245
|
-
onError:
|
|
2267
|
+
onError: a
|
|
2246
2268
|
}) => {
|
|
2247
|
-
const { t, definitionName:
|
|
2269
|
+
const { t, definitionName: o } = L(), [s, i] = V(
|
|
2248
2270
|
Array.isArray(r) ? r.join(", ") : String(r ?? "")
|
|
2249
|
-
),
|
|
2271
|
+
), m = F.useCallback(
|
|
2250
2272
|
(c) => {
|
|
2251
2273
|
if (c.trim() === "")
|
|
2252
2274
|
return e.required ? t("Value required") : null;
|
|
2253
2275
|
if (!Zr(c))
|
|
2254
2276
|
return t("Each value must be a valid float");
|
|
2255
|
-
const
|
|
2256
|
-
if (e.minCount !== void 0 &&
|
|
2277
|
+
const p = Qr(c);
|
|
2278
|
+
if (e.minCount !== void 0 && p.length < e.minCount)
|
|
2257
2279
|
return t("Minimum number of values: {{1}}", e.minCount);
|
|
2258
|
-
if (e.maxCount !== void 0 &&
|
|
2280
|
+
if (e.maxCount !== void 0 && p.length > e.maxCount)
|
|
2259
2281
|
return t("Maximum number of values: {{1}}", e.maxCount);
|
|
2260
|
-
for (const f of
|
|
2282
|
+
for (const f of p) {
|
|
2261
2283
|
if (e.min !== void 0 && (e.minInclusive ? f < e.min : f <= e.min))
|
|
2262
2284
|
return t(
|
|
2263
2285
|
"Each value must be {{1}} {{2}}",
|
|
@@ -2271,26 +2293,29 @@ const Qr = (e) => !e || e.trim() === "" ? [] : e.split(",").map((r) => r.trim())
|
|
|
2271
2293
|
e.max
|
|
2272
2294
|
);
|
|
2273
2295
|
}
|
|
2274
|
-
return
|
|
2296
|
+
return H(o, e, p, t) ?? null;
|
|
2275
2297
|
},
|
|
2276
|
-
[
|
|
2277
|
-
),
|
|
2278
|
-
const
|
|
2279
|
-
i(
|
|
2280
|
-
}, l =
|
|
2281
|
-
return
|
|
2282
|
-
|
|
2283
|
-
}, [
|
|
2284
|
-
const c = Array.isArray(r) ? r.join(", ") : String(r ?? ""),
|
|
2285
|
-
|
|
2286
|
-
}, [r, e.required,
|
|
2298
|
+
[o, e, t]
|
|
2299
|
+
), d = (c) => {
|
|
2300
|
+
const p = c.target.value, b = m(p);
|
|
2301
|
+
i(p), n?.(p, b);
|
|
2302
|
+
}, l = E(null), u = E(a);
|
|
2303
|
+
return k(() => {
|
|
2304
|
+
u.current = a;
|
|
2305
|
+
}, [a]), k(() => {
|
|
2306
|
+
const c = Array.isArray(r) ? r.join(", ") : String(r ?? ""), p = m(c);
|
|
2307
|
+
p !== l.current && (l.current = p, u.current?.(p ?? null));
|
|
2308
|
+
}, [r, e.required, m, t]), /* @__PURE__ */ g.jsx(U, { field: e, error: m(s), children: /* @__PURE__ */ g.jsx(
|
|
2287
2309
|
"input",
|
|
2288
2310
|
{
|
|
2311
|
+
id: e.name,
|
|
2289
2312
|
type: "text",
|
|
2290
2313
|
value: s,
|
|
2291
|
-
onChange:
|
|
2292
|
-
className:
|
|
2293
|
-
style: { flex: 1 }
|
|
2314
|
+
onChange: d,
|
|
2315
|
+
className: G(M.input, M.textInput),
|
|
2316
|
+
style: { flex: 1 },
|
|
2317
|
+
"aria-invalid": !!m(s),
|
|
2318
|
+
"aria-describedby": m(s) ? `${e.name}-error` : void 0
|
|
2294
2319
|
}
|
|
2295
2320
|
) });
|
|
2296
2321
|
}, rt = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/, tt = (e) => {
|
|
@@ -2300,15 +2325,15 @@ const Qr = (e) => !e || e.trim() === "" ? [] : e.split(",").map((r) => r.trim())
|
|
|
2300
2325
|
field: e,
|
|
2301
2326
|
value: r,
|
|
2302
2327
|
onChange: n,
|
|
2303
|
-
onError:
|
|
2328
|
+
onError: a
|
|
2304
2329
|
}) => {
|
|
2305
|
-
const { t, definitionName:
|
|
2306
|
-
(
|
|
2307
|
-
if (
|
|
2330
|
+
const { t, definitionName: o } = L(), s = E(null), i = F.useCallback(
|
|
2331
|
+
(u) => {
|
|
2332
|
+
if (u.trim() === "")
|
|
2308
2333
|
return e.required ? t("Value required") : null;
|
|
2309
|
-
if (!rt.test(
|
|
2334
|
+
if (!rt.test(u))
|
|
2310
2335
|
return t("Must be a valid float");
|
|
2311
|
-
const c = tt(
|
|
2336
|
+
const c = tt(u);
|
|
2312
2337
|
return c === null ? t("Must be a valid float") : e.min !== void 0 && (e.minInclusive ? c < e.min : c <= e.min) ? t(
|
|
2313
2338
|
"Must be {{1}} {{2}}",
|
|
2314
2339
|
e.minInclusive ? "≥" : ">",
|
|
@@ -2317,21 +2342,21 @@ const Qr = (e) => !e || e.trim() === "" ? [] : e.split(",").map((r) => r.trim())
|
|
|
2317
2342
|
"Must be {{1}} {{2}}",
|
|
2318
2343
|
e.maxInclusive ? "≤" : "<",
|
|
2319
2344
|
e.max
|
|
2320
|
-
) :
|
|
2345
|
+
) : H(o, e, c, t) ?? null;
|
|
2321
2346
|
},
|
|
2322
|
-
[e,
|
|
2323
|
-
),
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
}, [
|
|
2327
|
-
const
|
|
2328
|
-
c !==
|
|
2347
|
+
[e, o, t]
|
|
2348
|
+
), m = E(null), d = E(a);
|
|
2349
|
+
k(() => {
|
|
2350
|
+
d.current = a;
|
|
2351
|
+
}, [a]), k(() => {
|
|
2352
|
+
const u = String(r ?? ""), c = i(u);
|
|
2353
|
+
c !== m.current && (m.current = c, d.current?.(c ?? null)), s.current && document.activeElement !== s.current && (s.current.value = u);
|
|
2329
2354
|
}, [r, e, i, t]);
|
|
2330
|
-
const l = (
|
|
2331
|
-
const c =
|
|
2332
|
-
n?.(c,
|
|
2355
|
+
const l = (u) => {
|
|
2356
|
+
const c = u.target.value, p = i(c);
|
|
2357
|
+
n?.(c, p);
|
|
2333
2358
|
};
|
|
2334
|
-
return /* @__PURE__ */ g.jsx(
|
|
2359
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: i(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
2335
2360
|
"input",
|
|
2336
2361
|
{
|
|
2337
2362
|
id: e.name,
|
|
@@ -2339,14 +2364,16 @@ const Qr = (e) => !e || e.trim() === "" ? [] : e.split(",").map((r) => r.trim())
|
|
|
2339
2364
|
defaultValue: String(r ?? ""),
|
|
2340
2365
|
ref: s,
|
|
2341
2366
|
onChange: l,
|
|
2342
|
-
className:
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
)
|
|
2367
|
+
className: G(
|
|
2368
|
+
M.input,
|
|
2369
|
+
M.inputNumber
|
|
2370
|
+
),
|
|
2371
|
+
"aria-invalid": !!i(String(r ?? "")),
|
|
2372
|
+
"aria-describedby": i(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
2346
2373
|
}
|
|
2347
2374
|
) });
|
|
2348
2375
|
};
|
|
2349
|
-
function
|
|
2376
|
+
function at() {
|
|
2350
2377
|
try {
|
|
2351
2378
|
return "/";
|
|
2352
2379
|
} catch {
|
|
@@ -2358,59 +2385,59 @@ function ot() {
|
|
|
2358
2385
|
}
|
|
2359
2386
|
return "/";
|
|
2360
2387
|
}
|
|
2361
|
-
const
|
|
2362
|
-
const { language: n, t:
|
|
2388
|
+
const ot = ({ field: e, value: r }) => {
|
|
2389
|
+
const { language: n, t: a } = L(), t = e.alignment || "center", o = {
|
|
2363
2390
|
left: "flex-start",
|
|
2364
2391
|
center: "center",
|
|
2365
2392
|
right: "flex-end"
|
|
2366
2393
|
}, s = typeof r == "string" ? r : "";
|
|
2367
2394
|
let i = s && s.trim() !== "" ? s : typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
2368
|
-
i && !i.startsWith("/") && (i = `${
|
|
2369
|
-
const
|
|
2370
|
-
if (
|
|
2395
|
+
i && !i.startsWith("/") && (i = `${at()}${i}`);
|
|
2396
|
+
const m = e.localized?.split(";").map((y) => y.trim()), [d, l] = V(i || ""), u = E(i || null);
|
|
2397
|
+
if (k(() => {
|
|
2371
2398
|
if (!i) return;
|
|
2372
|
-
const y = i.split("/"),
|
|
2373
|
-
if (
|
|
2374
|
-
const
|
|
2375
|
-
let
|
|
2376
|
-
|
|
2377
|
-
const
|
|
2378
|
-
if (
|
|
2379
|
-
const I = [...y,
|
|
2380
|
-
fetch(I, { method: "HEAD", signal:
|
|
2381
|
-
const
|
|
2382
|
-
|
|
2399
|
+
const y = i.split("/"), C = y.pop(), x = C.lastIndexOf(".");
|
|
2400
|
+
if (x === -1) return;
|
|
2401
|
+
const j = C.substring(0, x), N = C.substring(x);
|
|
2402
|
+
let v = null;
|
|
2403
|
+
m?.includes(n) && (v = `${j}_${n}${N}`);
|
|
2404
|
+
const w = new AbortController();
|
|
2405
|
+
if (v) {
|
|
2406
|
+
const I = [...y, v].join("/");
|
|
2407
|
+
fetch(I, { method: "HEAD", signal: w.signal }).then((A) => {
|
|
2408
|
+
const R = A.ok ? I : i;
|
|
2409
|
+
R !== u.current && (u.current = R, l(R));
|
|
2383
2410
|
}).catch(() => {
|
|
2384
|
-
i !==
|
|
2411
|
+
i !== u.current && (u.current = i, l(i));
|
|
2385
2412
|
});
|
|
2386
2413
|
} else {
|
|
2387
2414
|
const I = i;
|
|
2388
|
-
I !==
|
|
2415
|
+
I !== u.current && (u.current = I, requestAnimationFrame(() => l(I)));
|
|
2389
2416
|
}
|
|
2390
2417
|
return () => {
|
|
2391
|
-
|
|
2418
|
+
w.abort();
|
|
2392
2419
|
};
|
|
2393
|
-
}, [i, n,
|
|
2394
|
-
const { width: c, height:
|
|
2420
|
+
}, [i, n, m]), !d) return null;
|
|
2421
|
+
const { width: c, height: p } = e, b = {}, f = {
|
|
2395
2422
|
borderRadius: "8px",
|
|
2396
2423
|
objectFit: "contain",
|
|
2397
2424
|
boxShadow: "0 2px 6px rgba(0,0,0,0.1)",
|
|
2398
2425
|
margin: "0 0 8px 0"
|
|
2399
2426
|
};
|
|
2400
|
-
return c &&
|
|
2427
|
+
return c && p ? (b.width = c, b.height = p, f.width = `${c}px`, f.height = `${p}px`) : c && !p ? (b.width = c, f.width = `${c}px`, f.height = "auto") : !c && p && (b.height = p, f.width = "auto", f.height = `${p}px`), /* @__PURE__ */ g.jsx(U, { field: e, children: /* @__PURE__ */ g.jsx(
|
|
2401
2428
|
"div",
|
|
2402
2429
|
{
|
|
2403
2430
|
"data-testid": "image-wrapper",
|
|
2404
2431
|
style: {
|
|
2405
2432
|
display: "flex",
|
|
2406
|
-
justifyContent:
|
|
2433
|
+
justifyContent: o[t] || "center",
|
|
2407
2434
|
margin: "0 0"
|
|
2408
2435
|
},
|
|
2409
2436
|
children: /* @__PURE__ */ g.jsx(
|
|
2410
2437
|
"img",
|
|
2411
2438
|
{
|
|
2412
|
-
src:
|
|
2413
|
-
alt:
|
|
2439
|
+
src: d,
|
|
2440
|
+
alt: a?.(e.displayName || "Image") || e.displayName || "Image",
|
|
2414
2441
|
...b,
|
|
2415
2442
|
style: f
|
|
2416
2443
|
}
|
|
@@ -2426,22 +2453,22 @@ const it = ({
|
|
|
2426
2453
|
field: e,
|
|
2427
2454
|
value: r,
|
|
2428
2455
|
onChange: n,
|
|
2429
|
-
onError:
|
|
2456
|
+
onError: a
|
|
2430
2457
|
}) => {
|
|
2431
|
-
const { t, definitionName:
|
|
2458
|
+
const { t, definitionName: o } = L(), s = ",", [i, m] = V(
|
|
2432
2459
|
Array.isArray(r) ? r.join(s + " ") : String(r ?? "")
|
|
2433
|
-
),
|
|
2434
|
-
(
|
|
2435
|
-
if (
|
|
2460
|
+
), d = (f) => !f || f.trim() === "" ? [] : f.split(s).map((y) => y.trim()).filter(Boolean).map((y) => Number(y)), l = F.useCallback(
|
|
2461
|
+
(f) => {
|
|
2462
|
+
if (f.trim() === "")
|
|
2436
2463
|
return e.required ? t("Value required") : null;
|
|
2437
|
-
if (!st(
|
|
2464
|
+
if (!st(f))
|
|
2438
2465
|
return t("Each value must be a valid integer");
|
|
2439
|
-
const
|
|
2440
|
-
if (e.minCount !== void 0 &&
|
|
2466
|
+
const y = d(f);
|
|
2467
|
+
if (e.minCount !== void 0 && y.length < e.minCount)
|
|
2441
2468
|
return t("Minimum number of values: {{1}}", `${e.minCount}`);
|
|
2442
|
-
if (e.maxCount !== void 0 &&
|
|
2469
|
+
if (e.maxCount !== void 0 && y.length > e.maxCount)
|
|
2443
2470
|
return t("Maximum number of values: {{1}}", `${e.maxCount}`);
|
|
2444
|
-
for (const x of
|
|
2471
|
+
for (const x of y) {
|
|
2445
2472
|
if (e.min !== void 0 && (e.minInclusive ? x < e.min : x <= e.min))
|
|
2446
2473
|
return t(
|
|
2447
2474
|
"Each value must be {{1}} {{2}}",
|
|
@@ -2455,28 +2482,33 @@ const it = ({
|
|
|
2455
2482
|
e.max
|
|
2456
2483
|
);
|
|
2457
2484
|
}
|
|
2458
|
-
return
|
|
2485
|
+
return H(o, e, y, t) ?? null;
|
|
2459
2486
|
},
|
|
2460
|
-
[
|
|
2461
|
-
),
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2464
|
-
}, c =
|
|
2465
|
-
|
|
2487
|
+
[o, e, t]
|
|
2488
|
+
), u = (f) => {
|
|
2489
|
+
const y = f.target.value, C = l(y);
|
|
2490
|
+
m(y), n?.(y, C);
|
|
2491
|
+
}, c = E(null), p = E(
|
|
2492
|
+
a
|
|
2466
2493
|
);
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
}, [
|
|
2470
|
-
const
|
|
2471
|
-
|
|
2472
|
-
}, [r, e.required, l, t])
|
|
2494
|
+
k(() => {
|
|
2495
|
+
p.current = a;
|
|
2496
|
+
}, [a]), k(() => {
|
|
2497
|
+
const f = Array.isArray(r) ? r.join(s + " ") : String(r ?? ""), y = l(f);
|
|
2498
|
+
y !== c.current && (c.current = y, p.current?.(y ?? null));
|
|
2499
|
+
}, [r, e.required, l, t]);
|
|
2500
|
+
const b = l(i);
|
|
2501
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: b, children: /* @__PURE__ */ g.jsx(
|
|
2473
2502
|
"input",
|
|
2474
2503
|
{
|
|
2504
|
+
id: e.name,
|
|
2475
2505
|
type: "text",
|
|
2476
2506
|
value: i,
|
|
2477
|
-
onChange:
|
|
2478
|
-
className:
|
|
2479
|
-
style: { flex: 1 }
|
|
2507
|
+
onChange: u,
|
|
2508
|
+
className: G(M.input, M.textInput),
|
|
2509
|
+
style: { flex: 1 },
|
|
2510
|
+
"aria-invalid": !!b,
|
|
2511
|
+
"aria-describedby": b ? `${e.name}-error` : void 0
|
|
2480
2512
|
}
|
|
2481
2513
|
) });
|
|
2482
2514
|
};
|
|
@@ -2487,135 +2519,145 @@ const lt = ({
|
|
|
2487
2519
|
field: e,
|
|
2488
2520
|
value: r,
|
|
2489
2521
|
onChange: n,
|
|
2490
|
-
onError:
|
|
2522
|
+
onError: a
|
|
2491
2523
|
}) => {
|
|
2492
|
-
const { t, definitionName:
|
|
2493
|
-
const
|
|
2494
|
-
return Number.isNaN(
|
|
2495
|
-
}, []),
|
|
2496
|
-
(
|
|
2497
|
-
if (
|
|
2524
|
+
const { t, definitionName: o } = L(), s = E(null), i = X((p) => {
|
|
2525
|
+
const b = parseInt(p, 10);
|
|
2526
|
+
return Number.isNaN(b) ? null : b;
|
|
2527
|
+
}, []), m = F.useCallback(
|
|
2528
|
+
(p) => {
|
|
2529
|
+
if (p.trim() === "")
|
|
2498
2530
|
return e.required ? t("Value required") : null;
|
|
2499
|
-
if (!ct(
|
|
2531
|
+
if (!ct(p))
|
|
2500
2532
|
return t("Must be a valid integer");
|
|
2501
|
-
const
|
|
2502
|
-
if (
|
|
2503
|
-
if (e.min !== void 0 && (e.minInclusive ?
|
|
2533
|
+
const b = i(p);
|
|
2534
|
+
if (b === null) return t("Must be a valid integer");
|
|
2535
|
+
if (e.min !== void 0 && (e.minInclusive ? b < e.min : b <= e.min))
|
|
2504
2536
|
return t(
|
|
2505
2537
|
"Must be {{1}} {{2}}",
|
|
2506
2538
|
e.minInclusive ? "≥" : ">",
|
|
2507
2539
|
e.min
|
|
2508
2540
|
);
|
|
2509
|
-
if (e.max !== void 0 && (e.maxInclusive ?
|
|
2541
|
+
if (e.max !== void 0 && (e.maxInclusive ? b > e.max : b >= e.max))
|
|
2510
2542
|
return t(
|
|
2511
2543
|
"Must be {{1}} {{2}}",
|
|
2512
2544
|
e.maxInclusive ? "≤" : "<",
|
|
2513
2545
|
e.max
|
|
2514
2546
|
);
|
|
2515
2547
|
if (e.step !== void 0) {
|
|
2516
|
-
const
|
|
2517
|
-
if (!Number.isInteger(
|
|
2548
|
+
const y = Number(e.step);
|
|
2549
|
+
if (!Number.isInteger(y))
|
|
2518
2550
|
return t("Invalid step value");
|
|
2519
|
-
if (
|
|
2520
|
-
return t("Must be a multiple of {{1}}",
|
|
2551
|
+
if (b % y !== 0)
|
|
2552
|
+
return t("Must be a multiple of {{1}}", y);
|
|
2521
2553
|
}
|
|
2522
|
-
return
|
|
2554
|
+
return H(o, e, b, t) ?? null;
|
|
2523
2555
|
},
|
|
2524
|
-
[e,
|
|
2525
|
-
),
|
|
2526
|
-
|
|
2527
|
-
l.current =
|
|
2528
|
-
}, [
|
|
2529
|
-
const
|
|
2530
|
-
|
|
2531
|
-
}, [r, e,
|
|
2532
|
-
const
|
|
2533
|
-
const
|
|
2534
|
-
n?.(
|
|
2535
|
-
};
|
|
2536
|
-
return /* @__PURE__ */ g.jsx(
|
|
2556
|
+
[e, o, t, i]
|
|
2557
|
+
), d = E(null), l = E(a);
|
|
2558
|
+
k(() => {
|
|
2559
|
+
l.current = a;
|
|
2560
|
+
}, [a]), k(() => {
|
|
2561
|
+
const p = String(r ?? ""), b = m(p);
|
|
2562
|
+
b !== d.current && (d.current = b, l.current?.(b ?? null)), s.current && document.activeElement !== s.current && (s.current.value = p);
|
|
2563
|
+
}, [r, e, m, t]);
|
|
2564
|
+
const u = (p) => {
|
|
2565
|
+
const b = p.target.value, f = m(b);
|
|
2566
|
+
n?.(b, f);
|
|
2567
|
+
}, c = m(String(r ?? ""));
|
|
2568
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: c, children: /* @__PURE__ */ g.jsx(
|
|
2537
2569
|
"input",
|
|
2538
2570
|
{
|
|
2539
2571
|
id: e.name,
|
|
2540
2572
|
type: "text",
|
|
2541
2573
|
defaultValue: String(r ?? ""),
|
|
2542
2574
|
ref: s,
|
|
2543
|
-
onChange:
|
|
2544
|
-
className:
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
)
|
|
2575
|
+
onChange: u,
|
|
2576
|
+
className: G(
|
|
2577
|
+
M.input,
|
|
2578
|
+
M.inputNumber
|
|
2579
|
+
),
|
|
2580
|
+
"aria-invalid": !!c,
|
|
2581
|
+
"aria-describedby": c ? `${e.name}-error` : void 0
|
|
2548
2582
|
}
|
|
2549
2583
|
) });
|
|
2550
2584
|
}, ut = ({
|
|
2551
2585
|
field: e,
|
|
2552
2586
|
value: r,
|
|
2553
2587
|
onChange: n,
|
|
2554
|
-
onError:
|
|
2588
|
+
onError: a
|
|
2555
2589
|
}) => {
|
|
2556
|
-
const { t, definitionName:
|
|
2557
|
-
|
|
2590
|
+
const { t, definitionName: o } = L(), s = e.minHeight ?? "80px", i = F.useRef(null), m = F.useRef(null), d = F.useRef(
|
|
2591
|
+
a
|
|
2558
2592
|
);
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
}, [
|
|
2562
|
-
const l =
|
|
2563
|
-
(
|
|
2564
|
-
[e,
|
|
2565
|
-
),
|
|
2566
|
-
const
|
|
2567
|
-
n?.(
|
|
2593
|
+
F.useEffect(() => {
|
|
2594
|
+
d.current = a;
|
|
2595
|
+
}, [a]);
|
|
2596
|
+
const l = F.useCallback(
|
|
2597
|
+
(b) => b.trim() === "" ? e.required ? t("Value required") : null : e.minLength !== void 0 && b.length < e.minLength ? t("Must be at least {{1}} characters", e.minLength) : e.maxLength !== void 0 && b.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) : H(o, e, b, t),
|
|
2598
|
+
[e, o, t]
|
|
2599
|
+
), u = (b) => {
|
|
2600
|
+
const f = b.target.value, y = l(f);
|
|
2601
|
+
n?.(f, y);
|
|
2568
2602
|
};
|
|
2569
|
-
|
|
2570
|
-
const
|
|
2571
|
-
|
|
2603
|
+
k(() => {
|
|
2604
|
+
const b = l(r);
|
|
2605
|
+
b !== m.current && (m.current = b, d.current?.(b ?? null)), i.current && i.current.value !== String(r ?? "") && (i.current.value = String(r ?? ""));
|
|
2572
2606
|
}, [r, l]);
|
|
2573
2607
|
const c = {
|
|
2608
|
+
id: e.name,
|
|
2574
2609
|
defaultValue: String(r ?? ""),
|
|
2575
2610
|
ref: i,
|
|
2576
|
-
onChange:
|
|
2611
|
+
onChange: u,
|
|
2577
2612
|
style: {
|
|
2578
2613
|
resize: "vertical",
|
|
2579
2614
|
minHeight: s,
|
|
2580
2615
|
width: "100%",
|
|
2581
2616
|
boxSizing: "border-box"
|
|
2582
2617
|
},
|
|
2583
|
-
className:
|
|
2584
|
-
};
|
|
2585
|
-
return /* @__PURE__ */ g.jsx(
|
|
2618
|
+
className: G(M.input, M.textInput)
|
|
2619
|
+
}, p = l(r);
|
|
2620
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: p, children: /* @__PURE__ */ g.jsx(
|
|
2621
|
+
"textarea",
|
|
2622
|
+
{
|
|
2623
|
+
...c,
|
|
2624
|
+
"aria-invalid": !!p,
|
|
2625
|
+
"aria-describedby": p ? `${e.name}-error` : void 0
|
|
2626
|
+
}
|
|
2627
|
+
) });
|
|
2586
2628
|
}, mt = ({
|
|
2587
2629
|
field: e,
|
|
2588
2630
|
value: r,
|
|
2589
2631
|
onChange: n,
|
|
2590
|
-
onError:
|
|
2632
|
+
onError: a
|
|
2591
2633
|
}) => {
|
|
2592
|
-
const t =
|
|
2593
|
-
|
|
2594
|
-
t.current =
|
|
2595
|
-
}, [
|
|
2596
|
-
const { t:
|
|
2597
|
-
if (
|
|
2598
|
-
const
|
|
2599
|
-
return (
|
|
2600
|
-
},
|
|
2634
|
+
const t = E(a);
|
|
2635
|
+
k(() => {
|
|
2636
|
+
t.current = a;
|
|
2637
|
+
}, [a]);
|
|
2638
|
+
const { t: o, darkMode: s, formStyle: i, fieldStyle: m, definitionName: d } = L(), l = (R, $, O) => {
|
|
2639
|
+
if (!$) return {};
|
|
2640
|
+
const W = R?.[$];
|
|
2641
|
+
return (O && W ? W[O] : void 0) ?? {};
|
|
2642
|
+
}, u = E(null), [c, p] = V(!1), [b, f] = V(
|
|
2601
2643
|
null
|
|
2602
|
-
), y =
|
|
2603
|
-
() => e.options.map((
|
|
2604
|
-
[e.options,
|
|
2605
|
-
),
|
|
2606
|
-
const
|
|
2607
|
-
return
|
|
2608
|
-
}, [r, y]),
|
|
2609
|
-
const
|
|
2610
|
-
return e.required &&
|
|
2611
|
-
},
|
|
2612
|
-
if (!
|
|
2613
|
-
const
|
|
2614
|
-
f({ x:
|
|
2615
|
-
},
|
|
2616
|
-
const
|
|
2617
|
-
t.current?.(
|
|
2618
|
-
},
|
|
2644
|
+
), y = J(
|
|
2645
|
+
() => e.options.map((R) => ({ value: R.value, label: o(R.label) })),
|
|
2646
|
+
[e.options, o]
|
|
2647
|
+
), C = J(() => {
|
|
2648
|
+
const R = Array.isArray(r) ? r : [], $ = new Set(y.map((O) => O.value));
|
|
2649
|
+
return R.filter((O) => $.has(O));
|
|
2650
|
+
}, [r, y]), x = (R) => {
|
|
2651
|
+
const $ = Array.isArray(R) ? R : [];
|
|
2652
|
+
return e.required && $.length === 0 ? o("Value required") : H(d, e, $, o) ?? null;
|
|
2653
|
+
}, j = () => {
|
|
2654
|
+
if (!u.current) return;
|
|
2655
|
+
const R = u.current.getBoundingClientRect();
|
|
2656
|
+
f({ x: R.left, y: R.bottom }), p(($) => !$);
|
|
2657
|
+
}, N = (R) => {
|
|
2658
|
+
const $ = C.includes(R) ? C.filter((P) => P !== R) : [...C, R], O = x($);
|
|
2659
|
+
t.current?.(O ?? null), n?.($, O);
|
|
2660
|
+
}, v = J(() => ({
|
|
2619
2661
|
height: "var(--reactaform-input-height, 2.5rem)",
|
|
2620
2662
|
padding: "var(--reactaform-input-padding, 8px)",
|
|
2621
2663
|
display: "flex",
|
|
@@ -2628,8 +2670,8 @@ const lt = ({
|
|
|
2628
2670
|
background: "var(--reactaform-secondary-bg, #fff)",
|
|
2629
2671
|
color: "var(--reactaform-text-color, #000)",
|
|
2630
2672
|
...l(i, "multiSelect", "control"),
|
|
2631
|
-
...l(
|
|
2632
|
-
}), [i,
|
|
2673
|
+
...l(m, void 0, "control")
|
|
2674
|
+
}), [i, m]), w = J(() => ({
|
|
2633
2675
|
position: "absolute",
|
|
2634
2676
|
right: "1.5em",
|
|
2635
2677
|
top: "50%",
|
|
@@ -2641,8 +2683,8 @@ const lt = ({
|
|
|
2641
2683
|
color: "var(--reactaform-text-muted, #999)",
|
|
2642
2684
|
padding: 0,
|
|
2643
2685
|
...l(i, "multiSelect", "clearButton"),
|
|
2644
|
-
...l(
|
|
2645
|
-
}), [i,
|
|
2686
|
+
...l(m, void 0, "clearButton")
|
|
2687
|
+
}), [i, m]), I = J(() => ({
|
|
2646
2688
|
position: "absolute",
|
|
2647
2689
|
right: "0.7em",
|
|
2648
2690
|
top: "50%",
|
|
@@ -2651,46 +2693,42 @@ const lt = ({
|
|
|
2651
2693
|
fontSize: "0.8em",
|
|
2652
2694
|
color: "var(--reactaform-text-muted, #999)",
|
|
2653
2695
|
...l(i, "multiSelect", "arrow"),
|
|
2654
|
-
...l(
|
|
2655
|
-
}), [i,
|
|
2696
|
+
...l(m, void 0, "arrow")
|
|
2697
|
+
}), [i, m]), A = x(Array.isArray(r) ? r : []);
|
|
2656
2698
|
return /* @__PURE__ */ g.jsxs("div", { children: [
|
|
2657
|
-
/* @__PURE__ */ g.jsx(
|
|
2699
|
+
/* @__PURE__ */ g.jsx(U, { field: e, error: null, children: /* @__PURE__ */ g.jsx("div", { style: { width: "100%" }, children: /* @__PURE__ */ g.jsxs(
|
|
2658
2700
|
"div",
|
|
2659
2701
|
{
|
|
2660
|
-
ref:
|
|
2702
|
+
ref: u,
|
|
2661
2703
|
className: "reactaform-multiselection-control",
|
|
2662
|
-
style:
|
|
2663
|
-
onClick:
|
|
2704
|
+
style: v,
|
|
2705
|
+
onClick: j,
|
|
2664
2706
|
tabIndex: 0,
|
|
2665
2707
|
role: "button",
|
|
2666
2708
|
"aria-haspopup": "listbox",
|
|
2667
2709
|
"aria-expanded": c,
|
|
2668
|
-
|
|
2669
|
-
|
|
2710
|
+
"aria-invalid": !!A,
|
|
2711
|
+
"aria-describedby": A ? `${e.name}-error` : void 0,
|
|
2712
|
+
onKeyDown: (R) => {
|
|
2713
|
+
(R.key === "Enter" || R.key === " ") && (R.preventDefault(), j());
|
|
2670
2714
|
},
|
|
2671
2715
|
children: [
|
|
2672
|
-
/* @__PURE__ */ g.jsxs(
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
y.length,
|
|
2680
|
-
" selected"
|
|
2681
|
-
]
|
|
2682
|
-
}
|
|
2683
|
-
),
|
|
2684
|
-
x.length > 0 && /* @__PURE__ */ g.jsx(
|
|
2716
|
+
/* @__PURE__ */ g.jsxs("span", { style: { flex: 1, color: "var(--reactaform-text-muted, #888)" }, children: [
|
|
2717
|
+
C.length,
|
|
2718
|
+
" / ",
|
|
2719
|
+
y.length,
|
|
2720
|
+
" selected"
|
|
2721
|
+
] }),
|
|
2722
|
+
C.length > 0 && /* @__PURE__ */ g.jsx(
|
|
2685
2723
|
"button",
|
|
2686
2724
|
{
|
|
2687
2725
|
type: "button",
|
|
2688
2726
|
"aria-label": "Clear selections",
|
|
2689
|
-
onClick: (
|
|
2690
|
-
|
|
2727
|
+
onClick: (R) => {
|
|
2728
|
+
R.stopPropagation(), n?.([], null);
|
|
2691
2729
|
},
|
|
2692
|
-
style:
|
|
2693
|
-
children: /* @__PURE__ */ g.jsx("span", { style:
|
|
2730
|
+
style: w,
|
|
2731
|
+
children: /* @__PURE__ */ g.jsx("span", { style: w, "aria-hidden": !0, children: "✖" })
|
|
2694
2732
|
}
|
|
2695
2733
|
),
|
|
2696
2734
|
/* @__PURE__ */ g.jsx("span", { style: I, "aria-hidden": !0, children: "▼" })
|
|
@@ -2698,32 +2736,32 @@ const lt = ({
|
|
|
2698
2736
|
}
|
|
2699
2737
|
) }) }),
|
|
2700
2738
|
c && b && /* @__PURE__ */ g.jsx(
|
|
2701
|
-
|
|
2739
|
+
dt,
|
|
2702
2740
|
{
|
|
2703
2741
|
position: b,
|
|
2704
2742
|
options: y,
|
|
2705
|
-
selectedValues:
|
|
2706
|
-
onToggleOption:
|
|
2707
|
-
onClose: () =>
|
|
2708
|
-
controlRef:
|
|
2743
|
+
selectedValues: C,
|
|
2744
|
+
onToggleOption: N,
|
|
2745
|
+
onClose: () => p(!1),
|
|
2746
|
+
controlRef: u,
|
|
2709
2747
|
darkMode: s
|
|
2710
2748
|
}
|
|
2711
2749
|
)
|
|
2712
2750
|
] });
|
|
2713
|
-
},
|
|
2751
|
+
}, dt = ({
|
|
2714
2752
|
position: e,
|
|
2715
2753
|
options: r,
|
|
2716
2754
|
selectedValues: n,
|
|
2717
|
-
onToggleOption:
|
|
2755
|
+
onToggleOption: a,
|
|
2718
2756
|
onClose: t,
|
|
2719
|
-
controlRef:
|
|
2757
|
+
controlRef: o,
|
|
2720
2758
|
darkMode: s
|
|
2721
2759
|
}) => {
|
|
2722
|
-
const i =
|
|
2760
|
+
const i = E(null), [m, d] = V(-1), { formStyle: l, fieldStyle: u } = L(), c = (w, I, A) => {
|
|
2723
2761
|
if (!I) return {};
|
|
2724
|
-
const
|
|
2725
|
-
return (
|
|
2726
|
-
},
|
|
2762
|
+
const $ = w?.[I];
|
|
2763
|
+
return (A && $ ? $[A] : void 0) ?? {};
|
|
2764
|
+
}, p = J(() => ({
|
|
2727
2765
|
maxHeight: 200,
|
|
2728
2766
|
overflowY: "auto",
|
|
2729
2767
|
background: "var(--reactaform-secondary-bg, #fff)",
|
|
@@ -2735,8 +2773,8 @@ const lt = ({
|
|
|
2735
2773
|
color: "var(--reactaform-text-color, #000)",
|
|
2736
2774
|
fontSize: "var(--reactaform-popup-font-size, 0.875rem)",
|
|
2737
2775
|
...c(l, "multiSelect", "popup"),
|
|
2738
|
-
...c(
|
|
2739
|
-
}), [l,
|
|
2776
|
+
...c(u, void 0, "popup")
|
|
2777
|
+
}), [l, u]), b = J(() => ({
|
|
2740
2778
|
padding: "6px 8px",
|
|
2741
2779
|
cursor: "pointer",
|
|
2742
2780
|
display: "flex",
|
|
@@ -2744,111 +2782,111 @@ const lt = ({
|
|
|
2744
2782
|
background: "transparent",
|
|
2745
2783
|
color: "var(--reactaform-text-color, #000)",
|
|
2746
2784
|
...c(l, "multiSelect", "option"),
|
|
2747
|
-
...c(
|
|
2748
|
-
}), [l,
|
|
2749
|
-
|
|
2750
|
-
const
|
|
2751
|
-
const
|
|
2752
|
-
!i.current?.contains(
|
|
2785
|
+
...c(u, void 0, "option")
|
|
2786
|
+
}), [l, u]);
|
|
2787
|
+
k(() => {
|
|
2788
|
+
const w = (I) => {
|
|
2789
|
+
const A = I.target;
|
|
2790
|
+
!i.current?.contains(A) && !o.current?.contains(A) && t();
|
|
2753
2791
|
};
|
|
2754
|
-
return document.addEventListener("mousedown",
|
|
2755
|
-
}, [t,
|
|
2756
|
-
i.current && r.length > 0 && requestAnimationFrame(() =>
|
|
2757
|
-
}, [r.length]),
|
|
2758
|
-
if (!i.current ||
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
}, [
|
|
2762
|
-
const f = 250, y = 200, [
|
|
2792
|
+
return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
|
|
2793
|
+
}, [t, o]), k(() => {
|
|
2794
|
+
i.current && r.length > 0 && requestAnimationFrame(() => d((w) => w === -1 ? 0 : w));
|
|
2795
|
+
}, [r.length]), k(() => {
|
|
2796
|
+
if (!i.current || m < 0) return;
|
|
2797
|
+
const w = i.current.querySelector(`#multi-opt-${m}`);
|
|
2798
|
+
w && requestAnimationFrame(() => w.focus());
|
|
2799
|
+
}, [m]);
|
|
2800
|
+
const f = 250, y = 200, [C, x] = V(
|
|
2763
2801
|
null
|
|
2764
|
-
), [
|
|
2765
|
-
if (
|
|
2802
|
+
), [j, N] = V(null);
|
|
2803
|
+
if (k(() => {
|
|
2766
2804
|
if (typeof window > "u") return;
|
|
2767
|
-
const
|
|
2768
|
-
let
|
|
2769
|
-
const
|
|
2770
|
-
if (
|
|
2771
|
-
const
|
|
2772
|
-
|
|
2805
|
+
const w = () => {
|
|
2806
|
+
let R = e.x, $ = e.y, O = f;
|
|
2807
|
+
const P = o?.current;
|
|
2808
|
+
if (P) {
|
|
2809
|
+
const W = P.getBoundingClientRect();
|
|
2810
|
+
R = W.left, $ = W.bottom, O = Math.max(80, Math.round(W.width));
|
|
2773
2811
|
}
|
|
2774
|
-
|
|
2812
|
+
R = Math.min(R, window.innerWidth - O), $ = Math.min($, window.innerHeight - y), x({ left: R, top: $ }), N(O);
|
|
2775
2813
|
};
|
|
2776
|
-
|
|
2814
|
+
w(), window.addEventListener("scroll", w, !0), window.addEventListener("resize", w);
|
|
2777
2815
|
let I = null;
|
|
2778
|
-
const
|
|
2779
|
-
return typeof ResizeObserver < "u" &&
|
|
2780
|
-
window.removeEventListener("scroll",
|
|
2816
|
+
const A = o?.current;
|
|
2817
|
+
return typeof ResizeObserver < "u" && A && (I = new ResizeObserver(() => w()), I.observe(A)), () => {
|
|
2818
|
+
window.removeEventListener("scroll", w, !0), window.removeEventListener("resize", w), I && A && I.unobserve(A);
|
|
2781
2819
|
};
|
|
2782
|
-
}, [
|
|
2783
|
-
let
|
|
2784
|
-
return
|
|
2820
|
+
}, [o, e.x, e.y]), typeof window > "u") return null;
|
|
2821
|
+
let v = document.getElementById("popup-root");
|
|
2822
|
+
return v || (v = document.createElement("div"), v.id = "popup-root", document.body.appendChild(v)), $e.createPortal(
|
|
2785
2823
|
/* @__PURE__ */ g.jsx(
|
|
2786
2824
|
"div",
|
|
2787
2825
|
{
|
|
2788
2826
|
ref: i,
|
|
2789
2827
|
role: "listbox",
|
|
2790
|
-
"aria-activedescendant":
|
|
2828
|
+
"aria-activedescendant": m >= 0 ? `multi-opt-${m}` : void 0,
|
|
2791
2829
|
style: {
|
|
2792
2830
|
position: "absolute",
|
|
2793
|
-
top:
|
|
2794
|
-
left:
|
|
2795
|
-
width:
|
|
2831
|
+
top: C ? C.top : e.y,
|
|
2832
|
+
left: C ? C.left : e.x,
|
|
2833
|
+
width: j ?? f,
|
|
2796
2834
|
// spread the static popup styles
|
|
2797
|
-
...
|
|
2835
|
+
...p
|
|
2798
2836
|
},
|
|
2799
2837
|
"data-reactaform-theme": s ? "dark" : "light",
|
|
2800
|
-
children: r.map((
|
|
2801
|
-
const
|
|
2838
|
+
children: r.map((w, I) => {
|
|
2839
|
+
const A = n.includes(w.value), R = s ? "var(--reactaform-hover-bg, rgba(255,255,255,0.01))" : "var(--reactaform-hover-bg, #eee)", $ = {
|
|
2802
2840
|
...b,
|
|
2803
|
-
background: I ===
|
|
2841
|
+
background: I === m ? R : b.background
|
|
2804
2842
|
};
|
|
2805
2843
|
return /* @__PURE__ */ g.jsxs(
|
|
2806
2844
|
"div",
|
|
2807
2845
|
{
|
|
2808
2846
|
id: `multi-opt-${I}`,
|
|
2809
|
-
onMouseDown: (
|
|
2810
|
-
|
|
2847
|
+
onMouseDown: (O) => {
|
|
2848
|
+
O.stopPropagation(), a(w.value);
|
|
2811
2849
|
},
|
|
2812
|
-
onKeyDown: (
|
|
2813
|
-
const
|
|
2814
|
-
switch (
|
|
2850
|
+
onKeyDown: (O) => {
|
|
2851
|
+
const P = r.length;
|
|
2852
|
+
switch (O.key) {
|
|
2815
2853
|
case "ArrowDown":
|
|
2816
|
-
|
|
2854
|
+
O.preventDefault(), d((W) => (W + 1) % P);
|
|
2817
2855
|
break;
|
|
2818
2856
|
case "ArrowUp":
|
|
2819
|
-
|
|
2857
|
+
O.preventDefault(), d((W) => (W - 1 + P) % P);
|
|
2820
2858
|
break;
|
|
2821
2859
|
case "Home":
|
|
2822
|
-
|
|
2860
|
+
O.preventDefault(), d(0);
|
|
2823
2861
|
break;
|
|
2824
2862
|
case "End":
|
|
2825
|
-
|
|
2863
|
+
O.preventDefault(), d(P - 1);
|
|
2826
2864
|
break;
|
|
2827
2865
|
case "Enter":
|
|
2828
2866
|
case " ":
|
|
2829
|
-
|
|
2867
|
+
O.preventDefault(), O.stopPropagation(), a(w.value);
|
|
2830
2868
|
break;
|
|
2831
2869
|
case "Escape":
|
|
2832
|
-
|
|
2870
|
+
O.preventDefault(), t(), o?.current?.focus();
|
|
2833
2871
|
break;
|
|
2834
2872
|
}
|
|
2835
2873
|
},
|
|
2836
|
-
tabIndex: I ===
|
|
2874
|
+
tabIndex: I === m ? 0 : -1,
|
|
2837
2875
|
role: "option",
|
|
2838
|
-
"aria-selected":
|
|
2839
|
-
style:
|
|
2840
|
-
onMouseEnter: (
|
|
2841
|
-
|
|
2876
|
+
"aria-selected": A,
|
|
2877
|
+
style: $,
|
|
2878
|
+
onMouseEnter: (O) => {
|
|
2879
|
+
O.currentTarget.style.background = R, d(I);
|
|
2842
2880
|
},
|
|
2843
|
-
onMouseLeave: (
|
|
2844
|
-
|
|
2881
|
+
onMouseLeave: (O) => {
|
|
2882
|
+
O.currentTarget.style.background = "transparent", d((P) => P === I ? -1 : P);
|
|
2845
2883
|
},
|
|
2846
2884
|
children: [
|
|
2847
2885
|
/* @__PURE__ */ g.jsx(
|
|
2848
2886
|
"input",
|
|
2849
2887
|
{
|
|
2850
2888
|
type: "checkbox",
|
|
2851
|
-
checked:
|
|
2889
|
+
checked: A,
|
|
2852
2890
|
readOnly: !0,
|
|
2853
2891
|
style: {
|
|
2854
2892
|
marginRight: 8,
|
|
@@ -2860,44 +2898,44 @@ const lt = ({
|
|
|
2860
2898
|
}
|
|
2861
2899
|
}
|
|
2862
2900
|
),
|
|
2863
|
-
|
|
2901
|
+
w.label
|
|
2864
2902
|
]
|
|
2865
2903
|
},
|
|
2866
|
-
|
|
2904
|
+
w.value
|
|
2867
2905
|
);
|
|
2868
2906
|
})
|
|
2869
2907
|
}
|
|
2870
2908
|
),
|
|
2871
|
-
|
|
2909
|
+
v
|
|
2872
2910
|
);
|
|
2873
|
-
},
|
|
2911
|
+
}, ft = ({
|
|
2874
2912
|
field: e,
|
|
2875
2913
|
value: r,
|
|
2876
2914
|
onChange: n,
|
|
2877
|
-
onError:
|
|
2915
|
+
onError: a
|
|
2878
2916
|
}) => {
|
|
2879
|
-
const { t, definitionName:
|
|
2880
|
-
(
|
|
2881
|
-
[
|
|
2882
|
-
),
|
|
2883
|
-
|
|
2917
|
+
const { t, definitionName: o } = L(), s = F.useRef(null), i = e.min ?? void 0, m = e.max ?? void 0, d = Math.max(1, Math.round(e.step ?? 1)), l = X(
|
|
2918
|
+
(y) => isNaN(y) ? t("Must be a valid integer") : Number.isInteger(y) ? i !== void 0 && y < i ? t("Must be �?{{1}}", i) : m !== void 0 && y > m ? t("Must be �?{{1}}", m) : H(o, e, y, t) ?? null : t("Must be an integer"),
|
|
2919
|
+
[o, e, t, i, m]
|
|
2920
|
+
), u = E(null), c = E(
|
|
2921
|
+
a
|
|
2884
2922
|
);
|
|
2885
|
-
|
|
2886
|
-
c.current =
|
|
2887
|
-
}, [
|
|
2923
|
+
k(() => {
|
|
2924
|
+
c.current = a;
|
|
2925
|
+
}, [a]), k(() => {
|
|
2888
2926
|
if (document.activeElement === s.current) return;
|
|
2889
|
-
const
|
|
2890
|
-
s.current && (s.current.value =
|
|
2927
|
+
const C = String(r), x = l(r);
|
|
2928
|
+
s.current && (s.current.value = C), x !== u.current && (u.current = x, c.current?.(x ?? null));
|
|
2891
2929
|
}, [r, l]);
|
|
2892
|
-
const
|
|
2893
|
-
if (
|
|
2894
|
-
const x = Number(
|
|
2930
|
+
const p = (y) => {
|
|
2931
|
+
if (y.trim() === "") return e.required ? t("Value required") : null;
|
|
2932
|
+
const x = Number(y);
|
|
2895
2933
|
return l(x);
|
|
2896
|
-
}, b = (
|
|
2897
|
-
const
|
|
2898
|
-
n?.(x,
|
|
2899
|
-
};
|
|
2900
|
-
return /* @__PURE__ */ g.jsx(
|
|
2934
|
+
}, b = (y) => {
|
|
2935
|
+
const C = y.target.value, x = y.target.valueAsNumber, j = p(C);
|
|
2936
|
+
n?.(x, j);
|
|
2937
|
+
}, f = p(String(r ?? ""));
|
|
2938
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: f, children: /* @__PURE__ */ g.jsx(
|
|
2901
2939
|
"input",
|
|
2902
2940
|
{
|
|
2903
2941
|
ref: s,
|
|
@@ -2905,108 +2943,129 @@ const lt = ({
|
|
|
2905
2943
|
type: "number",
|
|
2906
2944
|
defaultValue: String(r ?? ""),
|
|
2907
2945
|
min: i,
|
|
2908
|
-
max:
|
|
2909
|
-
step:
|
|
2946
|
+
max: m,
|
|
2947
|
+
step: d,
|
|
2910
2948
|
onChange: b,
|
|
2911
2949
|
style: { width: "100%", height: "100%" },
|
|
2912
|
-
className:
|
|
2950
|
+
className: M.input,
|
|
2951
|
+
"aria-invalid": !!f,
|
|
2952
|
+
"aria-describedby": f ? `${e.name}-error` : void 0
|
|
2913
2953
|
}
|
|
2914
2954
|
) });
|
|
2915
2955
|
}, pt = ({
|
|
2916
2956
|
field: e,
|
|
2917
2957
|
value: r,
|
|
2918
2958
|
onChange: n,
|
|
2919
|
-
onError:
|
|
2959
|
+
onError: a
|
|
2920
2960
|
}) => {
|
|
2921
|
-
const { t } =
|
|
2922
|
-
(
|
|
2923
|
-
const c = String(
|
|
2961
|
+
const { t } = L(), o = F.useRef(null), { definitionName: s } = L(), i = X(
|
|
2962
|
+
(u) => {
|
|
2963
|
+
const c = String(u ?? "").trim();
|
|
2924
2964
|
if (c === "")
|
|
2925
2965
|
return e.required ? t("Value required") : null;
|
|
2926
2966
|
if (e.pattern)
|
|
2927
2967
|
try {
|
|
2928
2968
|
if (!new RegExp(e.pattern).test(c))
|
|
2929
|
-
return t(
|
|
2969
|
+
return e.patternErrorMessage ? t(e.patternErrorMessage) : t(
|
|
2930
2970
|
"Phone number does not match pattern: {{1}}",
|
|
2931
2971
|
`${e.pattern}`
|
|
2932
2972
|
);
|
|
2933
2973
|
} catch {
|
|
2934
2974
|
}
|
|
2935
|
-
return
|
|
2975
|
+
return H(s, e, c, t);
|
|
2936
2976
|
},
|
|
2937
2977
|
[s, e, t]
|
|
2938
|
-
),
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
}, [
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2978
|
+
), m = E(null), d = E(a);
|
|
2979
|
+
k(() => {
|
|
2980
|
+
d.current = a;
|
|
2981
|
+
}, [a]), k(() => {
|
|
2982
|
+
const u = String(r ?? ""), c = i(u);
|
|
2983
|
+
o.current && o.current.value !== String(u) && (o.current.value = String(u)), c !== m.current && (m.current = c, d.current?.(c ?? null));
|
|
2944
2984
|
}, [r, i]);
|
|
2945
|
-
const l = (
|
|
2946
|
-
const c =
|
|
2985
|
+
const l = (u) => {
|
|
2986
|
+
const c = u.target.value, p = c.trim();
|
|
2947
2987
|
let b = null;
|
|
2948
|
-
if (
|
|
2988
|
+
if (p === "") {
|
|
2949
2989
|
b = e.required ? t("Value required") : null, n?.(c, b);
|
|
2950
2990
|
return;
|
|
2951
2991
|
}
|
|
2952
|
-
|
|
2992
|
+
b || (b = i(c)), n?.(c, b);
|
|
2953
2993
|
};
|
|
2954
|
-
return /* @__PURE__ */ g.jsx(
|
|
2994
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: i(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
2955
2995
|
"input",
|
|
2956
2996
|
{
|
|
2997
|
+
id: e.name,
|
|
2957
2998
|
type: "tel",
|
|
2958
2999
|
defaultValue: String(r ?? ""),
|
|
2959
|
-
ref:
|
|
3000
|
+
ref: o,
|
|
2960
3001
|
onChange: l,
|
|
2961
|
-
className:
|
|
3002
|
+
className: G(M.input, M.textInput),
|
|
3003
|
+
"aria-invalid": !!i(String(r ?? "")),
|
|
3004
|
+
"aria-describedby": i(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
2962
3005
|
}
|
|
2963
3006
|
) });
|
|
2964
|
-
}, gt = ({
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3007
|
+
}, gt = ({
|
|
3008
|
+
field: e,
|
|
3009
|
+
value: r,
|
|
3010
|
+
onChange: n,
|
|
3011
|
+
onError: a
|
|
3012
|
+
}) => {
|
|
3013
|
+
const { t, definitionName: o } = L(), s = e.layout?.toLowerCase() === "horizontal" ? "row" : "column", i = E(null), m = E(a);
|
|
3014
|
+
k(() => {
|
|
3015
|
+
m.current = a;
|
|
3016
|
+
}, [a]);
|
|
3017
|
+
const d = X(
|
|
3018
|
+
(u) => u === "" || u === null || u === void 0 ? t("Value required") : !e.options || e.options.length === 0 ? null : e.options.some((p) => p.value === u) ? H(o, e, u, t) ?? null : t("Invalid option selected"),
|
|
3019
|
+
[e, t, o]
|
|
2972
3020
|
);
|
|
2973
|
-
|
|
2974
|
-
const
|
|
2975
|
-
if (
|
|
2976
|
-
const
|
|
3021
|
+
k(() => {
|
|
3022
|
+
const u = r != null ? String(r) : "", c = d(u);
|
|
3023
|
+
if (m.current?.(c ?? null), i.current) {
|
|
3024
|
+
const p = Array.from(
|
|
2977
3025
|
i.current.querySelectorAll("input[type=radio]")
|
|
2978
3026
|
);
|
|
2979
3027
|
if (c && e.options && e.options.length > 0) {
|
|
2980
3028
|
const b = String(e.options[0].value);
|
|
2981
|
-
|
|
3029
|
+
p.forEach((f) => f.checked = f.value === b), n?.(b, null);
|
|
2982
3030
|
} else
|
|
2983
|
-
|
|
3031
|
+
p.forEach((b) => b.checked = b.value === u);
|
|
2984
3032
|
}
|
|
2985
|
-
}, [r,
|
|
2986
|
-
const l = (
|
|
2987
|
-
const c =
|
|
2988
|
-
|
|
3033
|
+
}, [r, d, n, e.options]);
|
|
3034
|
+
const l = (u) => {
|
|
3035
|
+
const c = u.target.value, p = d(c);
|
|
3036
|
+
m.current?.(p ?? null), n?.(c, p);
|
|
2989
3037
|
};
|
|
2990
|
-
return /* @__PURE__ */ g.jsx(
|
|
3038
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: d(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
2991
3039
|
"div",
|
|
2992
3040
|
{
|
|
3041
|
+
className: M.input,
|
|
3042
|
+
role: "radiogroup",
|
|
3043
|
+
"aria-labelledby": `${e.name}-label`,
|
|
3044
|
+
"aria-invalid": !!d(String(r ?? "")),
|
|
2993
3045
|
style: {
|
|
2994
3046
|
display: "flex",
|
|
2995
3047
|
flexDirection: s,
|
|
2996
3048
|
flexWrap: s === "row" ? "wrap" : "nowrap",
|
|
2997
3049
|
gap: s === "row" ? "12px" : "4px",
|
|
2998
|
-
alignItems: s === "row" ? "center" : "
|
|
2999
|
-
width: "100%"
|
|
3050
|
+
alignItems: s === "row" ? "center" : "stretch",
|
|
3051
|
+
width: "100%",
|
|
3052
|
+
padding: s === "row" ? "8px" : void 0,
|
|
3053
|
+
boxSizing: "border-box"
|
|
3000
3054
|
},
|
|
3001
3055
|
ref: i,
|
|
3002
|
-
children: (e.options ?? []).map((
|
|
3056
|
+
children: (e.options ?? []).map((u) => /* @__PURE__ */ g.jsxs(
|
|
3003
3057
|
"label",
|
|
3004
3058
|
{
|
|
3059
|
+
className: G(M.label),
|
|
3005
3060
|
style: {
|
|
3006
|
-
display: "flex",
|
|
3007
|
-
gap: "
|
|
3061
|
+
display: s === "column" ? "flex" : "inline-flex",
|
|
3062
|
+
gap: "8px",
|
|
3008
3063
|
alignItems: "center",
|
|
3009
|
-
whiteSpace: "nowrap"
|
|
3064
|
+
whiteSpace: "nowrap",
|
|
3065
|
+
marginBottom: s === "column" ? 6 : 0,
|
|
3066
|
+
cursor: "pointer",
|
|
3067
|
+
width: s === "column" ? "100%" : void 0,
|
|
3068
|
+
justifyContent: "flex-start"
|
|
3010
3069
|
},
|
|
3011
3070
|
children: [
|
|
3012
3071
|
/* @__PURE__ */ g.jsx(
|
|
@@ -3014,15 +3073,28 @@ const lt = ({
|
|
|
3014
3073
|
{
|
|
3015
3074
|
type: "radio",
|
|
3016
3075
|
name: e.name,
|
|
3017
|
-
value: String(
|
|
3018
|
-
defaultChecked: String(r ?? "") === String(
|
|
3019
|
-
onChange: l
|
|
3076
|
+
value: String(u.value),
|
|
3077
|
+
defaultChecked: String(r ?? "") === String(u.value),
|
|
3078
|
+
onChange: l,
|
|
3079
|
+
style: { width: "1.1em", height: "1.1em" }
|
|
3020
3080
|
}
|
|
3021
3081
|
),
|
|
3022
|
-
|
|
3082
|
+
/* @__PURE__ */ g.jsx(
|
|
3083
|
+
"span",
|
|
3084
|
+
{
|
|
3085
|
+
style: {
|
|
3086
|
+
userSelect: "none",
|
|
3087
|
+
textAlign: s === "column" ? "left" : void 0,
|
|
3088
|
+
flex: s === "column" ? 1 : void 0,
|
|
3089
|
+
fontWeight: 400
|
|
3090
|
+
// Use normal font weight for option labels
|
|
3091
|
+
},
|
|
3092
|
+
children: t(u.label)
|
|
3093
|
+
}
|
|
3094
|
+
)
|
|
3023
3095
|
]
|
|
3024
3096
|
},
|
|
3025
|
-
String(
|
|
3097
|
+
String(u.value)
|
|
3026
3098
|
))
|
|
3027
3099
|
}
|
|
3028
3100
|
) });
|
|
@@ -3041,74 +3113,101 @@ const lt = ({
|
|
|
3041
3113
|
field: e,
|
|
3042
3114
|
value: r,
|
|
3043
3115
|
onChange: n,
|
|
3044
|
-
onError:
|
|
3116
|
+
onError: a
|
|
3045
3117
|
}) => {
|
|
3046
|
-
const { t, definitionName:
|
|
3047
|
-
(
|
|
3048
|
-
[e, t,
|
|
3049
|
-
),
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
}, [
|
|
3053
|
-
let
|
|
3054
|
-
r < 0 && (
|
|
3055
|
-
const
|
|
3056
|
-
|
|
3057
|
-
}, [r,
|
|
3058
|
-
const
|
|
3059
|
-
const
|
|
3060
|
-
n?.(
|
|
3061
|
-
},
|
|
3062
|
-
let
|
|
3063
|
-
return
|
|
3118
|
+
const { t, definitionName: o } = L(), [s, i] = V(null), m = E([]), d = e.max || 5, l = X(
|
|
3119
|
+
(f) => e.required && f === 0 ? t("Value required") : H(o, e, f, t) ?? null,
|
|
3120
|
+
[e, t, o]
|
|
3121
|
+
), u = E(null), c = E(a);
|
|
3122
|
+
k(() => {
|
|
3123
|
+
c.current = a;
|
|
3124
|
+
}, [a]), k(() => {
|
|
3125
|
+
let f = r || 0;
|
|
3126
|
+
r < 0 && (f = 0), r > d && (f = d);
|
|
3127
|
+
const y = l(f);
|
|
3128
|
+
y !== u.current && (u.current = y, c.current?.(y ?? null));
|
|
3129
|
+
}, [r, l, d]);
|
|
3130
|
+
const p = (f) => {
|
|
3131
|
+
const y = l(f);
|
|
3132
|
+
n?.(f, y);
|
|
3133
|
+
}, b = (() => {
|
|
3134
|
+
let f = r || 0;
|
|
3135
|
+
return f < 0 && (f = 0), f > d && (f = d), f;
|
|
3064
3136
|
})();
|
|
3065
|
-
return /* @__PURE__ */ g.jsx(
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3137
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: l(b), children: /* @__PURE__ */ g.jsx(
|
|
3138
|
+
"div",
|
|
3139
|
+
{
|
|
3140
|
+
role: "radiogroup",
|
|
3141
|
+
"aria-labelledby": `${e.name}-label`,
|
|
3142
|
+
style: ht,
|
|
3143
|
+
"aria-invalid": !!l(b),
|
|
3144
|
+
"aria-describedby": l(b) ? `${e.name}-error` : void 0,
|
|
3145
|
+
children: (() => {
|
|
3146
|
+
const f = e.icon, y = f && String(f).trim() ? String(f) : "★";
|
|
3147
|
+
return [...Array(d)].map((C, x) => {
|
|
3148
|
+
const j = x < b, v = s !== null && x <= s || j ? "gold" : "lightgray";
|
|
3149
|
+
return /* @__PURE__ */ g.jsx(
|
|
3150
|
+
"span",
|
|
3151
|
+
{
|
|
3152
|
+
ref: (w) => m.current[x] = w,
|
|
3153
|
+
role: "radio",
|
|
3154
|
+
tabIndex: b > 0 ? x === b - 1 ? 0 : -1 : x === 0 ? 0 : -1,
|
|
3155
|
+
"aria-checked": j,
|
|
3156
|
+
onClick: () => p(x + 1),
|
|
3157
|
+
onKeyDown: (w) => {
|
|
3158
|
+
if (w.key === "Enter" || w.key === " ")
|
|
3159
|
+
w.preventDefault(), p(x + 1);
|
|
3160
|
+
else if (w.key === "ArrowRight" || w.key === "ArrowUp") {
|
|
3161
|
+
w.preventDefault();
|
|
3162
|
+
const I = Math.min(d - 1, x + 1);
|
|
3163
|
+
m.current[I]?.focus();
|
|
3164
|
+
} else if (w.key === "ArrowLeft" || w.key === "ArrowDown") {
|
|
3165
|
+
w.preventDefault();
|
|
3166
|
+
const I = Math.max(0, x - 1);
|
|
3167
|
+
m.current[I]?.focus();
|
|
3168
|
+
}
|
|
3169
|
+
},
|
|
3170
|
+
onMouseEnter: () => i(x),
|
|
3171
|
+
onMouseLeave: () => i(null),
|
|
3172
|
+
style: { ...bt, color: v },
|
|
3173
|
+
"aria-label": `Rating ${x + 1}`,
|
|
3174
|
+
title: t(`${e.displayName} ${x + 1}`),
|
|
3175
|
+
children: y
|
|
3176
|
+
},
|
|
3177
|
+
x
|
|
3178
|
+
);
|
|
3179
|
+
});
|
|
3180
|
+
})()
|
|
3181
|
+
}
|
|
3182
|
+
) });
|
|
3084
3183
|
}, xt = ({
|
|
3085
3184
|
field: e,
|
|
3086
3185
|
value: r,
|
|
3087
3186
|
onChange: n,
|
|
3088
|
-
onError:
|
|
3187
|
+
onError: a
|
|
3089
3188
|
}) => {
|
|
3090
|
-
const { t, definitionName:
|
|
3091
|
-
|
|
3189
|
+
const { t, definitionName: o } = L(), s = F.useRef(null), i = F.useRef(null), m = F.useRef(
|
|
3190
|
+
a
|
|
3092
3191
|
);
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
}, [
|
|
3096
|
-
const
|
|
3192
|
+
F.useEffect(() => {
|
|
3193
|
+
m.current = a;
|
|
3194
|
+
}, [a]);
|
|
3195
|
+
const d = J(
|
|
3097
3196
|
() => e.pattern ? new RegExp(e.pattern) : null,
|
|
3098
3197
|
[e.pattern]
|
|
3099
|
-
), l =
|
|
3100
|
-
(f) => f === "" ? e.required ? t("Value required") : null : e.minLength !== void 0 && f.length < e.minLength ? t("Must be at least {{1}} characters", e.minLength) : e.maxLength !== void 0 && f.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) :
|
|
3101
|
-
[e,
|
|
3102
|
-
),
|
|
3103
|
-
const y = f.target.value,
|
|
3104
|
-
n?.(y,
|
|
3198
|
+
), l = F.useCallback(
|
|
3199
|
+
(f) => f === "" ? e.required ? t("Value required") : null : e.minLength !== void 0 && f.length < e.minLength ? t("Must be at least {{1}} characters", e.minLength) : e.maxLength !== void 0 && f.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) : d && !d.test(f) ? e.patternErrorMessage ? t(e.patternErrorMessage) : t("Input does not match pattern: {{1}}", e.pattern) : H(o, e, f, t),
|
|
3200
|
+
[e, o, t, d]
|
|
3201
|
+
), u = (f) => {
|
|
3202
|
+
const y = f.target.value, C = l(y);
|
|
3203
|
+
n?.(y, C);
|
|
3105
3204
|
};
|
|
3106
|
-
|
|
3205
|
+
k(() => {
|
|
3107
3206
|
const f = l(r ?? "");
|
|
3108
|
-
s.current && s.current.value !== String(r ?? "") && (s.current.value = String(r ?? "")), f !== i.current && (i.current = f,
|
|
3207
|
+
s.current && s.current.value !== String(r ?? "") && (s.current.value = String(r ?? "")), f !== i.current && (i.current = f, m.current?.(f ?? null));
|
|
3109
3208
|
}, [r, l]);
|
|
3110
|
-
const [c,
|
|
3111
|
-
return /* @__PURE__ */ g.jsx(
|
|
3209
|
+
const [c, p] = F.useState(!1), b = () => p((f) => !f);
|
|
3210
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: l(String(r ?? "")), children: /* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, width: "100%" }, children: [
|
|
3112
3211
|
/* @__PURE__ */ g.jsx(
|
|
3113
3212
|
"input",
|
|
3114
3213
|
{
|
|
@@ -3116,9 +3215,11 @@ const lt = ({
|
|
|
3116
3215
|
type: c ? "text" : "password",
|
|
3117
3216
|
defaultValue: String(r ?? ""),
|
|
3118
3217
|
ref: s,
|
|
3119
|
-
onChange:
|
|
3120
|
-
className:
|
|
3121
|
-
style: { flex: 1, minWidth: 0 }
|
|
3218
|
+
onChange: u,
|
|
3219
|
+
className: G(M.input, M.textInput),
|
|
3220
|
+
style: { flex: 1, minWidth: 0 },
|
|
3221
|
+
"aria-invalid": !!l(String(r ?? "")),
|
|
3222
|
+
"aria-describedby": l(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
3122
3223
|
}
|
|
3123
3224
|
),
|
|
3124
3225
|
/* @__PURE__ */ g.jsx(
|
|
@@ -3148,9 +3249,9 @@ const St = ({
|
|
|
3148
3249
|
field: e,
|
|
3149
3250
|
value: r,
|
|
3150
3251
|
onChange: n,
|
|
3151
|
-
onError:
|
|
3252
|
+
onError: a
|
|
3152
3253
|
}) => {
|
|
3153
|
-
const { t, definitionName:
|
|
3254
|
+
const { t, definitionName: o } = L(), s = E(null), i = E(null), m = F.useCallback(
|
|
3154
3255
|
(b) => {
|
|
3155
3256
|
let f = null;
|
|
3156
3257
|
if (b.trim() === "")
|
|
@@ -3158,45 +3259,49 @@ const St = ({
|
|
|
3158
3259
|
if (!wt(b))
|
|
3159
3260
|
return t("Invalid number");
|
|
3160
3261
|
const y = Number(b);
|
|
3161
|
-
return typeof e.min == "number" && y < e.min ? t("Value should be at least {{1}}", e.min) : typeof e.max == "number" && y > e.max ? t("Value should be at most {{1}}", e.max) : (f || (f =
|
|
3262
|
+
return typeof e.min == "number" && y < e.min ? t("Value should be at least {{1}}", e.min) : typeof e.max == "number" && y > e.max ? t("Value should be at most {{1}}", e.max) : (f || (f = H(o, e, y, t)), f);
|
|
3162
3263
|
},
|
|
3163
|
-
[
|
|
3164
|
-
),
|
|
3165
|
-
|
|
3166
|
-
l.current =
|
|
3167
|
-
}, [
|
|
3168
|
-
const b = String(r), f =
|
|
3169
|
-
i.current && document.activeElement !== i.current && (i.current.value = isNaN(Number(b)) ? String(e.min ?? 0) : String(Number(b))), s.current && document.activeElement !== s.current && (s.current.value = b), f !==
|
|
3170
|
-
}, [r,
|
|
3171
|
-
const
|
|
3172
|
-
const f = b.target.value, y =
|
|
3264
|
+
[o, e, t]
|
|
3265
|
+
), d = E(null), l = E(a);
|
|
3266
|
+
k(() => {
|
|
3267
|
+
l.current = a;
|
|
3268
|
+
}, [a]), k(() => {
|
|
3269
|
+
const b = String(r), f = m(b);
|
|
3270
|
+
i.current && document.activeElement !== i.current && (i.current.value = isNaN(Number(b)) ? String(e.min ?? 0) : String(Number(b))), s.current && document.activeElement !== s.current && (s.current.value = b), f !== d.current && (d.current = f, l.current?.(f ?? null));
|
|
3271
|
+
}, [r, m, e.min]);
|
|
3272
|
+
const u = e.min ?? 0, c = e.max ?? 100, p = (b) => {
|
|
3273
|
+
const f = b.target.value, y = m(f);
|
|
3173
3274
|
n?.(f, y);
|
|
3174
3275
|
};
|
|
3175
|
-
return /* @__PURE__ */ g.jsx(
|
|
3276
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: m(String(r ?? "")), children: /* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" }, children: [
|
|
3176
3277
|
/* @__PURE__ */ g.jsx(
|
|
3177
3278
|
"input",
|
|
3178
3279
|
{
|
|
3179
3280
|
ref: i,
|
|
3281
|
+
id: `${e.name}-range`,
|
|
3180
3282
|
type: "range",
|
|
3181
|
-
defaultValue: isNaN(Number(r)) ? String(
|
|
3182
|
-
onChange:
|
|
3183
|
-
min:
|
|
3283
|
+
defaultValue: isNaN(Number(r)) ? String(u) : String(Number(r)),
|
|
3284
|
+
onChange: p,
|
|
3285
|
+
min: u,
|
|
3184
3286
|
max: c,
|
|
3185
3287
|
style: {
|
|
3186
3288
|
padding: "0px, 0px",
|
|
3187
3289
|
// Remove padding to make Chrome browser works fine.
|
|
3188
3290
|
flex: 1
|
|
3189
3291
|
},
|
|
3190
|
-
className:
|
|
3292
|
+
className: M.rangeInput,
|
|
3293
|
+
"aria-invalid": !!m(String(r ?? "")),
|
|
3294
|
+
"aria-describedby": m(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
3191
3295
|
}
|
|
3192
3296
|
),
|
|
3193
3297
|
/* @__PURE__ */ g.jsx(
|
|
3194
3298
|
"input",
|
|
3195
3299
|
{
|
|
3300
|
+
id: e.name,
|
|
3196
3301
|
ref: s,
|
|
3197
3302
|
type: "text",
|
|
3198
3303
|
defaultValue: String(r ?? ""),
|
|
3199
|
-
onChange:
|
|
3304
|
+
onChange: p,
|
|
3200
3305
|
required: !0,
|
|
3201
3306
|
style: {
|
|
3202
3307
|
width: "40px",
|
|
@@ -3205,7 +3310,9 @@ const St = ({
|
|
|
3205
3310
|
textAlign: "center",
|
|
3206
3311
|
flexShrink: 0
|
|
3207
3312
|
},
|
|
3208
|
-
className:
|
|
3313
|
+
className: G(M.input, M.textInput),
|
|
3314
|
+
"aria-invalid": !!m(String(r ?? "")),
|
|
3315
|
+
"aria-describedby": m(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
3209
3316
|
}
|
|
3210
3317
|
)
|
|
3211
3318
|
] }) });
|
|
@@ -3213,20 +3320,20 @@ const St = ({
|
|
|
3213
3320
|
field: e,
|
|
3214
3321
|
value: r,
|
|
3215
3322
|
onChange: n,
|
|
3216
|
-
onError:
|
|
3323
|
+
onError: a
|
|
3217
3324
|
}) => {
|
|
3218
|
-
const { t, formStyle:
|
|
3219
|
-
if (!
|
|
3220
|
-
const
|
|
3221
|
-
return (I &&
|
|
3222
|
-
},
|
|
3325
|
+
const { t, formStyle: o, fieldStyle: s, definitionName: i } = L(), m = o, d = s, l = (v, w, I) => {
|
|
3326
|
+
if (!w) return {};
|
|
3327
|
+
const A = v?.[w];
|
|
3328
|
+
return (I && A ? A[I] : void 0) ?? {};
|
|
3329
|
+
}, u = F.useMemo(() => ({
|
|
3223
3330
|
display: "inline-block",
|
|
3224
3331
|
position: "relative",
|
|
3225
3332
|
width: 44,
|
|
3226
3333
|
height: 24,
|
|
3227
|
-
...l(
|
|
3228
|
-
...l(
|
|
3229
|
-
}), [
|
|
3334
|
+
...l(m, "switch", "label"),
|
|
3335
|
+
...l(d, void 0, "label")
|
|
3336
|
+
}), [m, d]), c = F.useMemo(() => ({
|
|
3230
3337
|
position: "absolute",
|
|
3231
3338
|
opacity: 0,
|
|
3232
3339
|
top: 0,
|
|
@@ -3237,9 +3344,9 @@ const St = ({
|
|
|
3237
3344
|
cursor: "pointer",
|
|
3238
3345
|
pointerEvents: "none",
|
|
3239
3346
|
// Make hidden input non-interactive to avoid event conflicts
|
|
3240
|
-
...l(
|
|
3241
|
-
...l(
|
|
3242
|
-
}), [
|
|
3347
|
+
...l(m, "switch", "hiddenInput"),
|
|
3348
|
+
...l(d, void 0, "hiddenInput")
|
|
3349
|
+
}), [m, d]), p = F.useMemo(() => ({
|
|
3243
3350
|
position: "absolute",
|
|
3244
3351
|
cursor: "pointer",
|
|
3245
3352
|
top: 0,
|
|
@@ -3256,9 +3363,9 @@ const St = ({
|
|
|
3256
3363
|
borderWidth: 2,
|
|
3257
3364
|
borderStyle: "solid",
|
|
3258
3365
|
borderColor: "transparent",
|
|
3259
|
-
...l(
|
|
3260
|
-
...l(
|
|
3261
|
-
}), [
|
|
3366
|
+
...l(m, "switch", "slider"),
|
|
3367
|
+
...l(d, void 0, "slider")
|
|
3368
|
+
}), [m, d]), b = F.useMemo(() => ({
|
|
3262
3369
|
position: "absolute",
|
|
3263
3370
|
height: 16,
|
|
3264
3371
|
width: 16,
|
|
@@ -3268,30 +3375,30 @@ const St = ({
|
|
|
3268
3375
|
transition: "0.3s",
|
|
3269
3376
|
borderRadius: "50%",
|
|
3270
3377
|
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.3)",
|
|
3271
|
-
...l(
|
|
3272
|
-
...l(
|
|
3273
|
-
}), [
|
|
3274
|
-
const
|
|
3275
|
-
n?.(
|
|
3378
|
+
...l(m, "switch", "knob"),
|
|
3379
|
+
...l(d, void 0, "knob")
|
|
3380
|
+
}), [m, d]), f = !!r, y = F.useRef(null), C = F.useRef(a), x = F.useCallback((v) => v ? H(i, e, v, t) ?? null : e.required ? t("Value required") : null, [e, t, i]), j = () => {
|
|
3381
|
+
const v = !f, w = x(v);
|
|
3382
|
+
n?.(v, w);
|
|
3276
3383
|
};
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
}, [
|
|
3280
|
-
const
|
|
3281
|
-
|
|
3282
|
-
}, [f, e,
|
|
3283
|
-
const
|
|
3284
|
-
return /* @__PURE__ */ g.jsx(
|
|
3384
|
+
F.useEffect(() => {
|
|
3385
|
+
C.current = a;
|
|
3386
|
+
}, [a]), F.useEffect(() => {
|
|
3387
|
+
const v = x(f);
|
|
3388
|
+
v !== y.current && (y.current = v, C.current?.(v ?? null));
|
|
3389
|
+
}, [f, e, x]);
|
|
3390
|
+
const N = e.name;
|
|
3391
|
+
return /* @__PURE__ */ g.jsx(U, { field: e, error: x(f), rightAlign: !1, children: /* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }, children: [
|
|
3285
3392
|
/* @__PURE__ */ g.jsx(
|
|
3286
3393
|
"label",
|
|
3287
3394
|
{
|
|
3288
|
-
className:
|
|
3289
|
-
htmlFor:
|
|
3395
|
+
className: M.label,
|
|
3396
|
+
htmlFor: N,
|
|
3290
3397
|
style: { textAlign: "left", justifyContent: "flex-start" },
|
|
3291
3398
|
children: t(e.displayName)
|
|
3292
3399
|
}
|
|
3293
3400
|
),
|
|
3294
|
-
/* @__PURE__ */ g.jsxs("label", { style:
|
|
3401
|
+
/* @__PURE__ */ g.jsxs("label", { style: u, children: [
|
|
3295
3402
|
/* @__PURE__ */ g.jsx(
|
|
3296
3403
|
"input",
|
|
3297
3404
|
{
|
|
@@ -3300,6 +3407,8 @@ const St = ({
|
|
|
3300
3407
|
checked: f,
|
|
3301
3408
|
readOnly: !0,
|
|
3302
3409
|
"aria-label": t(e.displayName),
|
|
3410
|
+
"aria-invalid": !!x(f),
|
|
3411
|
+
"aria-describedby": x(f) ? `${e.name}-error` : void 0,
|
|
3303
3412
|
style: c,
|
|
3304
3413
|
tabIndex: -1
|
|
3305
3414
|
}
|
|
@@ -3311,12 +3420,14 @@ const St = ({
|
|
|
3311
3420
|
"data-testid": "switch",
|
|
3312
3421
|
tabIndex: 0,
|
|
3313
3422
|
"aria-checked": f,
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3423
|
+
"aria-invalid": !!x(f),
|
|
3424
|
+
"aria-describedby": x(f) ? `${e.name}-error` : void 0,
|
|
3425
|
+
onClick: j,
|
|
3426
|
+
onKeyDown: (v) => {
|
|
3427
|
+
(v.key === " " || v.key === "Spacebar" || v.key === "Space" || v.key === "Enter") && (v.preventDefault(), j());
|
|
3317
3428
|
},
|
|
3318
3429
|
className: `reactaform-switch ${f ? "active checked on" : ""} `,
|
|
3319
|
-
style: f ? { ...
|
|
3430
|
+
style: f ? { ...p, backgroundColor: "var(--reactaform-switch-on-bg, #22c55e)", borderColor: "var(--reactaform-switch-on-border, #16a34a)" } : p,
|
|
3320
3431
|
children: /* @__PURE__ */ g.jsx(
|
|
3321
3432
|
"span",
|
|
3322
3433
|
{
|
|
@@ -3334,95 +3445,99 @@ const St = ({
|
|
|
3334
3445
|
field: e,
|
|
3335
3446
|
value: r,
|
|
3336
3447
|
onChange: n,
|
|
3337
|
-
onError:
|
|
3448
|
+
onError: a
|
|
3338
3449
|
}) => {
|
|
3339
|
-
const { t, definitionName:
|
|
3340
|
-
|
|
3450
|
+
const { t, definitionName: o } = L(), s = F.useRef(null), i = F.useRef(null), m = F.useRef(
|
|
3451
|
+
a
|
|
3341
3452
|
);
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
}, [
|
|
3345
|
-
const
|
|
3453
|
+
F.useEffect(() => {
|
|
3454
|
+
m.current = a;
|
|
3455
|
+
}, [a]);
|
|
3456
|
+
const d = J(
|
|
3346
3457
|
() => e.pattern ? new RegExp(e.pattern) : null,
|
|
3347
3458
|
[e.pattern]
|
|
3348
|
-
), l =
|
|
3349
|
-
(c) => c.trim() === "" ? e.required ? t("Value required") : null : e.minLength !== void 0 && c.length < e.minLength ? t("Must be at least {{1}} characters", e.minLength) : e.maxLength !== void 0 && c.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) :
|
|
3350
|
-
[e,
|
|
3351
|
-
),
|
|
3352
|
-
const
|
|
3353
|
-
n?.(
|
|
3459
|
+
), l = F.useCallback(
|
|
3460
|
+
(c) => c.trim() === "" ? e.required ? t("Value required") : null : e.minLength !== void 0 && c.length < e.minLength ? t("Must be at least {{1}} characters", e.minLength) : e.maxLength !== void 0 && c.length > e.maxLength ? t("Must be at most {{1}} characters", e.maxLength) : d && !d.test(c) ? e.patternErrorMessage ? t(e.patternErrorMessage) : t("Input does not match pattern: {{1}}", e.pattern) : H(o, e, c, t),
|
|
3461
|
+
[e, o, t, d]
|
|
3462
|
+
), u = (c) => {
|
|
3463
|
+
const p = c.target.value, b = l(p);
|
|
3464
|
+
n?.(p, b);
|
|
3354
3465
|
};
|
|
3355
|
-
return
|
|
3466
|
+
return k(() => {
|
|
3356
3467
|
const c = l(r);
|
|
3357
|
-
s.current && s.current.value !== String(r ?? "") && (s.current.value = String(r ?? "")), c !== i.current && (i.current = c,
|
|
3358
|
-
}, [r, l]), /* @__PURE__ */ g.jsx(
|
|
3468
|
+
s.current && s.current.value !== String(r ?? "") && (s.current.value = String(r ?? "")), c !== i.current && (i.current = c, m.current?.(c ?? null));
|
|
3469
|
+
}, [r, l]), /* @__PURE__ */ g.jsx(U, { field: e, error: l(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
3359
3470
|
"input",
|
|
3360
3471
|
{
|
|
3361
3472
|
id: e.name,
|
|
3473
|
+
"aria-invalid": !!l(String(r ?? "")),
|
|
3474
|
+
"aria-describedby": l(String(r ?? "")) ? `${e.name}-error` : void 0,
|
|
3362
3475
|
type: "text",
|
|
3363
3476
|
defaultValue: String(r ?? ""),
|
|
3364
3477
|
ref: s,
|
|
3365
|
-
onChange:
|
|
3366
|
-
className:
|
|
3478
|
+
onChange: u,
|
|
3479
|
+
className: G(M.input, M.textInput)
|
|
3367
3480
|
}
|
|
3368
3481
|
) });
|
|
3369
3482
|
}, jt = ({
|
|
3370
3483
|
field: e,
|
|
3371
3484
|
value: r,
|
|
3372
3485
|
onChange: n,
|
|
3373
|
-
onError:
|
|
3486
|
+
onError: a
|
|
3374
3487
|
}) => {
|
|
3375
|
-
const { t, definitionName:
|
|
3376
|
-
|
|
3377
|
-
i.current =
|
|
3378
|
-
}, [
|
|
3379
|
-
const
|
|
3380
|
-
if (!
|
|
3488
|
+
const { t, definitionName: o } = L(), s = E(null), i = E(a), m = e.includeSeconds ?? !0;
|
|
3489
|
+
k(() => {
|
|
3490
|
+
i.current = a;
|
|
3491
|
+
}, [a]);
|
|
3492
|
+
const d = F.useCallback((u) => {
|
|
3493
|
+
if (!u || u.trim() === "")
|
|
3381
3494
|
return e.required || e.min || e.max ? t("Value required") : null;
|
|
3382
3495
|
const c = (f) => {
|
|
3383
|
-
const y = f.split(":").map((
|
|
3384
|
-
if (y.some((
|
|
3385
|
-
let
|
|
3496
|
+
const y = f.split(":").map((x) => parseInt(x, 10));
|
|
3497
|
+
if (y.some((x) => Number.isNaN(x))) return NaN;
|
|
3498
|
+
let C = 0;
|
|
3386
3499
|
if (y.length === 3)
|
|
3387
|
-
|
|
3500
|
+
C = y[0] * 3600 + y[1] * 60 + y[2];
|
|
3388
3501
|
else if (y.length === 2)
|
|
3389
|
-
|
|
3502
|
+
C = y[0] * 3600 + y[1] * 60;
|
|
3390
3503
|
else if (y.length === 1)
|
|
3391
|
-
|
|
3504
|
+
C = y[0] * 3600;
|
|
3392
3505
|
else
|
|
3393
3506
|
return NaN;
|
|
3394
|
-
return
|
|
3395
|
-
},
|
|
3396
|
-
if (Number.isNaN(
|
|
3507
|
+
return C;
|
|
3508
|
+
}, p = c(u);
|
|
3509
|
+
if (Number.isNaN(p)) return t("Invalid time format");
|
|
3397
3510
|
if (e.min && typeof e.min == "string") {
|
|
3398
3511
|
const f = c(e.min);
|
|
3399
|
-
if (!Number.isNaN(f) &&
|
|
3512
|
+
if (!Number.isNaN(f) && p < f)
|
|
3400
3513
|
return t("Time must be on or after {{1}}", e.min);
|
|
3401
3514
|
}
|
|
3402
3515
|
if (e.max && typeof e.max == "string") {
|
|
3403
3516
|
const f = c(e.max);
|
|
3404
|
-
if (!Number.isNaN(f) &&
|
|
3517
|
+
if (!Number.isNaN(f) && p > f)
|
|
3405
3518
|
return t("Time must be on or before {{1}}", e.max);
|
|
3406
3519
|
}
|
|
3407
|
-
return
|
|
3408
|
-
}, [e,
|
|
3409
|
-
const c =
|
|
3410
|
-
n?.(c,
|
|
3520
|
+
return H(o, e, u, t) ?? null;
|
|
3521
|
+
}, [e, o, t]), l = (u) => {
|
|
3522
|
+
const c = u.target.value, p = d(c);
|
|
3523
|
+
n?.(c, p);
|
|
3411
3524
|
};
|
|
3412
|
-
return
|
|
3413
|
-
const
|
|
3414
|
-
|
|
3415
|
-
}, [r,
|
|
3525
|
+
return k(() => {
|
|
3526
|
+
const u = d(r);
|
|
3527
|
+
u !== s.current && (s.current = u, i.current?.(u ?? null));
|
|
3528
|
+
}, [r, d]), /* @__PURE__ */ g.jsx(U, { field: e, error: d(r), children: /* @__PURE__ */ g.jsx(
|
|
3416
3529
|
"input",
|
|
3417
3530
|
{
|
|
3418
3531
|
id: e.name,
|
|
3419
3532
|
type: "time",
|
|
3420
3533
|
value: r,
|
|
3421
|
-
step:
|
|
3534
|
+
step: m ? 1 : 60,
|
|
3422
3535
|
onChange: l,
|
|
3423
3536
|
min: typeof e.min == "string" ? e.min : void 0,
|
|
3424
3537
|
max: typeof e.max == "string" ? e.max : void 0,
|
|
3425
|
-
className:
|
|
3538
|
+
className: G(M.input, M.textInput),
|
|
3539
|
+
"aria-invalid": !!d(r),
|
|
3540
|
+
"aria-describedby": d(r) ? `${e.name}-error` : void 0
|
|
3426
3541
|
}
|
|
3427
3542
|
) });
|
|
3428
3543
|
};
|
|
@@ -3430,28 +3545,28 @@ function kt({
|
|
|
3430
3545
|
pos: e,
|
|
3431
3546
|
options: r,
|
|
3432
3547
|
onClose: n,
|
|
3433
|
-
onClickOption:
|
|
3548
|
+
onClickOption: a
|
|
3434
3549
|
}) {
|
|
3435
|
-
const t =
|
|
3436
|
-
if (
|
|
3437
|
-
function
|
|
3438
|
-
|
|
3550
|
+
const t = E(null), o = E(!1), s = typeof window < "u" ? document.getElementById("popup-root") || document.body : null;
|
|
3551
|
+
if (k(() => {
|
|
3552
|
+
function p(b) {
|
|
3553
|
+
o.current || b.target.dataset?.popupMenu === "item" || t.current && b.target instanceof Node && !t.current.contains(b.target) && n();
|
|
3439
3554
|
}
|
|
3440
|
-
return document.addEventListener("mousedown",
|
|
3555
|
+
return document.addEventListener("mousedown", p), () => document.removeEventListener("mousedown", p);
|
|
3441
3556
|
}, [n]), !s || r === void 0 || r.length === 0 || !e || e.x == null || e.y == null) return null;
|
|
3442
|
-
const i = e.x,
|
|
3443
|
-
return
|
|
3557
|
+
const i = e.x, m = e.y, d = typeof window < "u" ? window.innerWidth : 1024, l = Math.max(0, d - 160), u = Math.max(0, Math.min(i, l)), c = Math.max(0, m);
|
|
3558
|
+
return $e.createPortal(
|
|
3444
3559
|
/* @__PURE__ */ g.jsx(
|
|
3445
3560
|
"div",
|
|
3446
3561
|
{
|
|
3447
3562
|
ref: t,
|
|
3448
|
-
onMouseDown: (
|
|
3449
|
-
|
|
3563
|
+
onMouseDown: (p) => {
|
|
3564
|
+
p.stopPropagation();
|
|
3450
3565
|
},
|
|
3451
3566
|
style: {
|
|
3452
3567
|
position: "fixed",
|
|
3453
3568
|
top: c,
|
|
3454
|
-
left:
|
|
3569
|
+
left: u,
|
|
3455
3570
|
backgroundColor: "var(--reactaform-primary-bg, #fff)",
|
|
3456
3571
|
border: "1px solid var(--reactaform-border-color, #ccc)",
|
|
3457
3572
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
@@ -3460,16 +3575,16 @@ function kt({
|
|
|
3460
3575
|
minWidth: "var(--reactaform-menu-min-width, 150px)",
|
|
3461
3576
|
pointerEvents: "auto"
|
|
3462
3577
|
},
|
|
3463
|
-
children: r.map((
|
|
3578
|
+
children: r.map((p, b) => /* @__PURE__ */ g.jsx(
|
|
3464
3579
|
"div",
|
|
3465
3580
|
{
|
|
3466
3581
|
"data-popup-menu": "item",
|
|
3467
3582
|
onMouseDown: (f) => {
|
|
3468
|
-
f.stopPropagation(),
|
|
3583
|
+
f.stopPropagation(), o.current = !0;
|
|
3469
3584
|
},
|
|
3470
3585
|
onClick: (f) => {
|
|
3471
|
-
f.stopPropagation(), f.preventDefault(),
|
|
3472
|
-
|
|
3586
|
+
f.stopPropagation(), f.preventDefault(), a(p), n(), setTimeout(() => {
|
|
3587
|
+
o.current = !1;
|
|
3473
3588
|
}, 100);
|
|
3474
3589
|
},
|
|
3475
3590
|
style: {
|
|
@@ -3485,9 +3600,9 @@ function kt({
|
|
|
3485
3600
|
onMouseLeave: (f) => {
|
|
3486
3601
|
f.currentTarget.style.backgroundColor = "transparent";
|
|
3487
3602
|
},
|
|
3488
|
-
children:
|
|
3603
|
+
children: p.label
|
|
3489
3604
|
},
|
|
3490
|
-
|
|
3605
|
+
p.label ?? b
|
|
3491
3606
|
))
|
|
3492
3607
|
}
|
|
3493
3608
|
),
|
|
@@ -3498,15 +3613,15 @@ const he = {};
|
|
|
3498
3613
|
function Rt(e, r) {
|
|
3499
3614
|
if (e in he)
|
|
3500
3615
|
return;
|
|
3501
|
-
const n = Le[e] ?? {},
|
|
3502
|
-
for (const [i,
|
|
3503
|
-
typeof
|
|
3616
|
+
const n = Le[e] ?? {}, a = {}, t = {}, o = {};
|
|
3617
|
+
for (const [i, m] of Object.entries(n))
|
|
3618
|
+
typeof m.factor == "number" && (a[i] = m.factor), t[i] = r(i), o[r(i)] = i;
|
|
3504
3619
|
const s = Object.keys(n)[0] ?? "";
|
|
3505
3620
|
he[e] = {
|
|
3506
3621
|
default: s,
|
|
3507
|
-
factors:
|
|
3622
|
+
factors: a,
|
|
3508
3623
|
labels: t,
|
|
3509
|
-
reverseLabels:
|
|
3624
|
+
reverseLabels: o
|
|
3510
3625
|
};
|
|
3511
3626
|
}
|
|
3512
3627
|
function Et(e, r, n) {
|
|
@@ -3525,14 +3640,14 @@ function Et(e, r, n) {
|
|
|
3525
3640
|
function Nt(e, r, n) {
|
|
3526
3641
|
if (!Number.isFinite(e)) return [];
|
|
3527
3642
|
if (n === he.temperature)
|
|
3528
|
-
return Object.keys(n.labels).map((
|
|
3529
|
-
const s = Et(r,
|
|
3530
|
-
return Number.isFinite(s) ? { label: `${s.toFixed(6)} ${
|
|
3643
|
+
return Object.keys(n.labels).map((o) => {
|
|
3644
|
+
const s = Et(r, o, e);
|
|
3645
|
+
return Number.isFinite(s) ? { label: `${s.toFixed(6)} ${o}`, value: s.toString(), unit: o } : { label: `${String(s)} ${o}`, value: String(s), unit: o };
|
|
3531
3646
|
});
|
|
3532
3647
|
const t = n.factors[r];
|
|
3533
|
-
return t === void 0 ? [] : Object.entries(n.factors).map(([
|
|
3648
|
+
return t === void 0 ? [] : Object.entries(n.factors).map(([o, s]) => {
|
|
3534
3649
|
const i = e / t * s;
|
|
3535
|
-
return Number.isFinite(i) ? { label: `${i.toFixed(6)} ${
|
|
3650
|
+
return Number.isFinite(i) ? { label: `${i.toFixed(6)} ${o}`, value: i.toString(), unit: o } : { label: `${String(i)} ${o}`, value: String(i), unit: o };
|
|
3536
3651
|
});
|
|
3537
3652
|
}
|
|
3538
3653
|
function xe(e, r) {
|
|
@@ -3542,71 +3657,71 @@ const It = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/, At = ({
|
|
|
3542
3657
|
unitFactors: e,
|
|
3543
3658
|
field: r,
|
|
3544
3659
|
value: n,
|
|
3545
|
-
onChange:
|
|
3660
|
+
onChange: a,
|
|
3546
3661
|
onError: t
|
|
3547
3662
|
}) => {
|
|
3548
|
-
const { t:
|
|
3549
|
-
(
|
|
3550
|
-
if (!
|
|
3551
|
-
return r.required ?
|
|
3552
|
-
if (!It.test(
|
|
3553
|
-
const
|
|
3554
|
-
return
|
|
3663
|
+
const { t: o, definitionName: s } = L(), i = E(null), m = E(null), d = E(null), [l, u] = V(null), [c, p] = V(null), [b, f] = V(!1), [y, C] = V(null), [x, j] = V([]), N = X(
|
|
3664
|
+
(T, h) => {
|
|
3665
|
+
if (!T || T.trim() === "")
|
|
3666
|
+
return r.required ? o("Value required") : null;
|
|
3667
|
+
if (!It.test(T)) return o("Must be a valid number");
|
|
3668
|
+
const S = H(s, r, [T, h], o);
|
|
3669
|
+
return S || null;
|
|
3555
3670
|
},
|
|
3556
|
-
[s, r,
|
|
3557
|
-
),
|
|
3558
|
-
Object.entries(e.labels).map(([
|
|
3671
|
+
[s, r, o]
|
|
3672
|
+
), v = e.reverseLabels !== void 0 ? e.reverseLabels : Object.fromEntries(
|
|
3673
|
+
Object.entries(e.labels).map(([T, h]) => [h, T])
|
|
3559
3674
|
);
|
|
3560
|
-
|
|
3561
|
-
const
|
|
3562
|
-
let
|
|
3563
|
-
|
|
3564
|
-
const
|
|
3565
|
-
|
|
3566
|
-
|
|
3675
|
+
k(() => {
|
|
3676
|
+
const T = String(n[0]);
|
|
3677
|
+
let h = n[1] ?? e.default;
|
|
3678
|
+
h = xe(h, e) || h;
|
|
3679
|
+
const S = document.activeElement;
|
|
3680
|
+
S === i.current || S === m.current || (i.current && (i.current.value = T), m.current && (m.current.value = h), d.current !== null && (cancelAnimationFrame(d.current), d.current = null), d.current = requestAnimationFrame(() => {
|
|
3681
|
+
d.current = null, u(null), p(null);
|
|
3567
3682
|
}));
|
|
3568
|
-
}, [n, e]),
|
|
3569
|
-
|
|
3683
|
+
}, [n, e]), k(() => () => {
|
|
3684
|
+
d.current !== null && (cancelAnimationFrame(d.current), d.current = null);
|
|
3570
3685
|
}, []);
|
|
3571
|
-
const
|
|
3686
|
+
const w = E(null), I = E(
|
|
3572
3687
|
t
|
|
3573
3688
|
);
|
|
3574
|
-
|
|
3689
|
+
k(() => {
|
|
3575
3690
|
I.current = t;
|
|
3576
|
-
}, [t]),
|
|
3577
|
-
const
|
|
3578
|
-
let
|
|
3579
|
-
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3582
|
-
}, [n, e,
|
|
3583
|
-
const
|
|
3584
|
-
const
|
|
3585
|
-
|
|
3586
|
-
},
|
|
3587
|
-
const
|
|
3588
|
-
|
|
3589
|
-
},
|
|
3590
|
-
const
|
|
3591
|
-
|
|
3592
|
-
},
|
|
3593
|
-
const
|
|
3594
|
-
if (
|
|
3691
|
+
}, [t]), k(() => {
|
|
3692
|
+
const T = String(n[0]);
|
|
3693
|
+
let h = n[1] ?? e.default;
|
|
3694
|
+
h = xe(h, e) || h;
|
|
3695
|
+
const S = N(T, h);
|
|
3696
|
+
S !== w.current && (w.current = S, I.current?.(S ?? null));
|
|
3697
|
+
}, [n, e, N]);
|
|
3698
|
+
const A = (T, h, S) => {
|
|
3699
|
+
const z = v[h] || h;
|
|
3700
|
+
a?.([T, z], S);
|
|
3701
|
+
}, R = (T) => {
|
|
3702
|
+
const h = T.target.value, S = m.current ? m.current.value : e.default, z = N(h, S);
|
|
3703
|
+
u(h), A(h, S, z);
|
|
3704
|
+
}, $ = (T) => {
|
|
3705
|
+
const h = T.target.value, S = i.current ? i.current.value : String(n[0] ?? ""), z = N(S, h);
|
|
3706
|
+
p(h), m.current && (m.current.value = h), A(S, h, z);
|
|
3707
|
+
}, O = (T) => {
|
|
3708
|
+
const h = i.current ? i.current.value : String(n[0] ?? ""), S = parseFloat(h), z = m.current ? m.current.value : e.default;
|
|
3709
|
+
if (N(h, z) || !h.trim() || !Number.isFinite(S))
|
|
3595
3710
|
return;
|
|
3596
|
-
const
|
|
3597
|
-
|
|
3598
|
-
const
|
|
3599
|
-
if (
|
|
3600
|
-
|
|
3711
|
+
const te = T.currentTarget.getBoundingClientRect(), se = te.left, q = te.bottom;
|
|
3712
|
+
C({ x: se, y: q });
|
|
3713
|
+
const D = Nt(S, z, e);
|
|
3714
|
+
if (D.length === 0) {
|
|
3715
|
+
j([]), f(!1);
|
|
3601
3716
|
return;
|
|
3602
3717
|
}
|
|
3603
|
-
|
|
3604
|
-
},
|
|
3605
|
-
const { value:
|
|
3606
|
-
f(!1),
|
|
3607
|
-
const
|
|
3608
|
-
|
|
3609
|
-
},
|
|
3718
|
+
j(D), f((_) => !_);
|
|
3719
|
+
}, P = (T) => {
|
|
3720
|
+
const { value: h, unit: S } = T;
|
|
3721
|
+
f(!1), C(null), i.current && (i.current.value = h), m.current && (m.current.value = S), u(h), p(S);
|
|
3722
|
+
const z = N(h, S);
|
|
3723
|
+
A(h, S, z);
|
|
3724
|
+
}, W = String(n[0] ?? ""), ae = xe(n[1] ?? e.default, e) || (n[1] ?? e.default), re = l ?? W, Q = !!N(re, c ?? ae) || !re.trim(), oe = {
|
|
3610
3725
|
width: "var(--reactaform-unit-btn-width, 2.5em)",
|
|
3611
3726
|
height: "var(--reactaform-unit-btn-height, 2.5em)",
|
|
3612
3727
|
padding: "var(--reactaform-unit-btn-padding, 0)",
|
|
@@ -3619,41 +3734,47 @@ const It = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/, At = ({
|
|
|
3619
3734
|
display: "flex",
|
|
3620
3735
|
alignItems: "center",
|
|
3621
3736
|
justifyContent: "center"
|
|
3622
|
-
};
|
|
3623
|
-
return /* @__PURE__ */ g.jsx(
|
|
3737
|
+
}, Z = N(W, ae);
|
|
3738
|
+
return /* @__PURE__ */ g.jsx(U, { field: r, error: Z, children: /* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "var(--reactaform-unit-gap, 8px)", width: "100%" }, children: [
|
|
3624
3739
|
/* @__PURE__ */ g.jsx(
|
|
3625
3740
|
"input",
|
|
3626
3741
|
{
|
|
3742
|
+
id: r.name,
|
|
3627
3743
|
type: "text",
|
|
3628
3744
|
ref: i,
|
|
3629
3745
|
defaultValue: String(n[0] ?? ""),
|
|
3630
|
-
onChange:
|
|
3746
|
+
onChange: R,
|
|
3631
3747
|
style: { width: "var(--reactaform-unit-input-width, 100px)" },
|
|
3632
|
-
className:
|
|
3748
|
+
className: G(M.input, M.textInput),
|
|
3749
|
+
"aria-invalid": !!Z,
|
|
3750
|
+
"aria-describedby": Z ? `${r.name}-error` : void 0
|
|
3633
3751
|
}
|
|
3634
3752
|
),
|
|
3635
3753
|
/* @__PURE__ */ g.jsx(
|
|
3636
3754
|
"select",
|
|
3637
3755
|
{
|
|
3638
|
-
|
|
3756
|
+
id: `${r.name}-unit`,
|
|
3757
|
+
ref: m,
|
|
3639
3758
|
defaultValue: xe(n[1] ?? e.default, e) || (n[1] ?? e.default),
|
|
3640
|
-
onChange:
|
|
3641
|
-
className:
|
|
3642
|
-
|
|
3643
|
-
|
|
3759
|
+
onChange: $,
|
|
3760
|
+
className: G(
|
|
3761
|
+
M.input,
|
|
3762
|
+
M.inputSelect
|
|
3644
3763
|
),
|
|
3645
|
-
|
|
3764
|
+
"aria-invalid": !!Z,
|
|
3765
|
+
"aria-describedby": Z ? `${r.name}-error` : void 0,
|
|
3766
|
+
children: Object.keys(e.labels).map((T) => /* @__PURE__ */ g.jsx("option", { value: T, children: e.labels[T] ?? T }, T))
|
|
3646
3767
|
}
|
|
3647
3768
|
),
|
|
3648
3769
|
/* @__PURE__ */ g.jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [
|
|
3649
3770
|
/* @__PURE__ */ g.jsx(
|
|
3650
3771
|
"button",
|
|
3651
3772
|
{
|
|
3652
|
-
onClick:
|
|
3773
|
+
onClick: O,
|
|
3653
3774
|
"aria-disabled": Q,
|
|
3654
3775
|
disabled: Q,
|
|
3655
3776
|
style: oe,
|
|
3656
|
-
className:
|
|
3777
|
+
className: M.button,
|
|
3657
3778
|
children: /* @__PURE__ */ g.jsx(
|
|
3658
3779
|
"span",
|
|
3659
3780
|
{
|
|
@@ -3668,29 +3789,29 @@ const It = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/, At = ({
|
|
|
3668
3789
|
)
|
|
3669
3790
|
}
|
|
3670
3791
|
),
|
|
3671
|
-
b &&
|
|
3792
|
+
b && x && /* @__PURE__ */ g.jsx(
|
|
3672
3793
|
kt,
|
|
3673
3794
|
{
|
|
3674
3795
|
pos: y,
|
|
3675
|
-
options:
|
|
3796
|
+
options: x,
|
|
3676
3797
|
onClose: () => {
|
|
3677
|
-
|
|
3798
|
+
C(null), f(!1);
|
|
3678
3799
|
},
|
|
3679
|
-
onClickOption:
|
|
3800
|
+
onClickOption: P
|
|
3680
3801
|
}
|
|
3681
3802
|
)
|
|
3682
3803
|
] })
|
|
3683
3804
|
] }) });
|
|
3684
3805
|
};
|
|
3685
3806
|
function Ft({ field: e, value: r, onChange: n }) {
|
|
3686
|
-
const { t:
|
|
3807
|
+
const { t: a } = L(), t = e.dimension;
|
|
3687
3808
|
if (!t) return null;
|
|
3688
|
-
he[t] || Rt(t,
|
|
3689
|
-
const
|
|
3690
|
-
return
|
|
3809
|
+
he[t] || Rt(t, a);
|
|
3810
|
+
const o = he[t];
|
|
3811
|
+
return o ? /* @__PURE__ */ g.jsx(
|
|
3691
3812
|
At,
|
|
3692
3813
|
{
|
|
3693
|
-
unitFactors:
|
|
3814
|
+
unitFactors: o,
|
|
3694
3815
|
field: e,
|
|
3695
3816
|
value: r,
|
|
3696
3817
|
onChange: n
|
|
@@ -3703,15 +3824,15 @@ const Xe = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]
|
|
|
3703
3824
|
} catch {
|
|
3704
3825
|
return !1;
|
|
3705
3826
|
}
|
|
3706
|
-
},
|
|
3827
|
+
}, $t = ({
|
|
3707
3828
|
field: e,
|
|
3708
3829
|
value: r,
|
|
3709
3830
|
onChange: n,
|
|
3710
|
-
onError:
|
|
3831
|
+
onError: a
|
|
3711
3832
|
}) => {
|
|
3712
|
-
const { t, definitionName:
|
|
3713
|
-
(
|
|
3714
|
-
const c =
|
|
3833
|
+
const { t, definitionName: o } = L(), s = E(null), i = X(
|
|
3834
|
+
(u) => {
|
|
3835
|
+
const c = u.trim();
|
|
3715
3836
|
if (c === "")
|
|
3716
3837
|
return e.required ? t("Value required") : null;
|
|
3717
3838
|
if (!Xe.test(c) && !Ze(c)) {
|
|
@@ -3727,32 +3848,34 @@ const Xe = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]
|
|
|
3727
3848
|
}
|
|
3728
3849
|
if (!f) return t("Must be a valid URL");
|
|
3729
3850
|
}
|
|
3730
|
-
return
|
|
3851
|
+
return H(o, e, c, t) ?? null;
|
|
3731
3852
|
},
|
|
3732
|
-
[
|
|
3733
|
-
),
|
|
3734
|
-
const c =
|
|
3735
|
-
n?.(c.trim(),
|
|
3736
|
-
},
|
|
3737
|
-
return
|
|
3738
|
-
l.current =
|
|
3739
|
-
}, [
|
|
3740
|
-
const
|
|
3741
|
-
s.current && s.current.value !== String(
|
|
3742
|
-
}, [r, i]), /* @__PURE__ */ g.jsx(
|
|
3853
|
+
[o, e, t]
|
|
3854
|
+
), m = (u) => {
|
|
3855
|
+
const c = u.target.value, p = i(c);
|
|
3856
|
+
n?.(c.trim(), p);
|
|
3857
|
+
}, d = E(null), l = E(a);
|
|
3858
|
+
return k(() => {
|
|
3859
|
+
l.current = a;
|
|
3860
|
+
}, [a]), k(() => {
|
|
3861
|
+
const u = r ?? "", c = i(u);
|
|
3862
|
+
s.current && s.current.value !== String(u) && (s.current.value = String(u)), c !== d.current && (d.current = c, l.current?.(c ?? null));
|
|
3863
|
+
}, [r, i]), /* @__PURE__ */ g.jsx(U, { field: e, error: i(String(r ?? "")), children: /* @__PURE__ */ g.jsx(
|
|
3743
3864
|
"input",
|
|
3744
3865
|
{
|
|
3745
3866
|
id: e.name,
|
|
3746
3867
|
type: "url",
|
|
3747
3868
|
defaultValue: String(r ?? ""),
|
|
3748
3869
|
ref: s,
|
|
3749
|
-
onChange:
|
|
3870
|
+
onChange: m,
|
|
3750
3871
|
style: { alignItems: "left" },
|
|
3751
|
-
className:
|
|
3752
|
-
placeholder: "https://example.com"
|
|
3872
|
+
className: G(M.input, M.textInput),
|
|
3873
|
+
placeholder: "https://example.com",
|
|
3874
|
+
"aria-invalid": !!i(String(r ?? "")),
|
|
3875
|
+
"aria-describedby": i(String(r ?? "")) ? `${e.name}-error` : void 0
|
|
3753
3876
|
}
|
|
3754
3877
|
) });
|
|
3755
|
-
}, Fe = new we(),
|
|
3878
|
+
}, Fe = new we(), Mt = /* @__PURE__ */ new Set([
|
|
3756
3879
|
"checkbox",
|
|
3757
3880
|
"switch",
|
|
3758
3881
|
"dropdown",
|
|
@@ -3771,7 +3894,7 @@ const Xe = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]
|
|
|
3771
3894
|
file: Kr,
|
|
3772
3895
|
float: nt,
|
|
3773
3896
|
"float-array": et,
|
|
3774
|
-
image:
|
|
3897
|
+
image: ot,
|
|
3775
3898
|
int: lt,
|
|
3776
3899
|
"int-array": it,
|
|
3777
3900
|
"multi-selection": mt,
|
|
@@ -3783,12 +3906,12 @@ const Xe = /^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]
|
|
|
3783
3906
|
separator: Gr,
|
|
3784
3907
|
slider: St,
|
|
3785
3908
|
string: Ke,
|
|
3786
|
-
stepper:
|
|
3909
|
+
stepper: ft,
|
|
3787
3910
|
switch: Ct,
|
|
3788
3911
|
text: Ke,
|
|
3789
3912
|
time: jt,
|
|
3790
3913
|
unit: Ft,
|
|
3791
|
-
url:
|
|
3914
|
+
url: $t
|
|
3792
3915
|
};
|
|
3793
3916
|
function ur(e, r, n) {
|
|
3794
3917
|
if (!n && e in lr) {
|
|
@@ -3797,28 +3920,28 @@ function ur(e, r, n) {
|
|
|
3797
3920
|
);
|
|
3798
3921
|
return;
|
|
3799
3922
|
}
|
|
3800
|
-
if (
|
|
3923
|
+
if (Mt.has(e)) {
|
|
3801
3924
|
Fe.register(e, r);
|
|
3802
3925
|
return;
|
|
3803
3926
|
}
|
|
3804
|
-
const
|
|
3927
|
+
const a = (t) => {
|
|
3805
3928
|
const { callback: s, cancel: i } = jr(
|
|
3806
|
-
(...
|
|
3807
|
-
const
|
|
3808
|
-
typeof
|
|
3929
|
+
(...m) => {
|
|
3930
|
+
const d = t.onChange;
|
|
3931
|
+
typeof d == "function" && d(...m);
|
|
3809
3932
|
},
|
|
3810
3933
|
200
|
|
3811
3934
|
);
|
|
3812
|
-
return
|
|
3935
|
+
return k(() => () => {
|
|
3813
3936
|
i();
|
|
3814
|
-
}, [i]),
|
|
3937
|
+
}, [i]), F.createElement(r, { ...t, onChange: s });
|
|
3815
3938
|
};
|
|
3816
|
-
Fe.register(e,
|
|
3939
|
+
Fe.register(e, a);
|
|
3817
3940
|
}
|
|
3818
|
-
function
|
|
3941
|
+
function on(e, r) {
|
|
3819
3942
|
ur(e, r, !1);
|
|
3820
3943
|
}
|
|
3821
|
-
function
|
|
3944
|
+
function Ot(e) {
|
|
3822
3945
|
return Fe.get(e);
|
|
3823
3946
|
}
|
|
3824
3947
|
let Qe = !1;
|
|
@@ -3827,63 +3950,63 @@ function mr() {
|
|
|
3827
3950
|
ur(e, r, !0);
|
|
3828
3951
|
}), Qe = !0);
|
|
3829
3952
|
}
|
|
3830
|
-
const
|
|
3831
|
-
function
|
|
3832
|
-
|
|
3953
|
+
const dr = new we();
|
|
3954
|
+
function Dt(e, r) {
|
|
3955
|
+
dr.register(e, r);
|
|
3833
3956
|
}
|
|
3834
|
-
function
|
|
3835
|
-
return
|
|
3957
|
+
function Vt(e) {
|
|
3958
|
+
return dr.get(e);
|
|
3836
3959
|
}
|
|
3837
|
-
|
|
3960
|
+
Dt(
|
|
3838
3961
|
"Preset_AlertSubmitHandler",
|
|
3839
3962
|
(e, r, n) => {
|
|
3840
|
-
const
|
|
3963
|
+
const a = {
|
|
3841
3964
|
name: r || "Unnamed Instance",
|
|
3842
3965
|
version: e.version,
|
|
3843
3966
|
definition: e.name,
|
|
3844
3967
|
values: n
|
|
3845
|
-
}, t = JSON.stringify(
|
|
3968
|
+
}, t = JSON.stringify(a, null, 2);
|
|
3846
3969
|
alert(t);
|
|
3847
3970
|
}
|
|
3848
3971
|
);
|
|
3849
|
-
const
|
|
3850
|
-
const t =
|
|
3851
|
-
(i,
|
|
3972
|
+
const fr = F.memo(({ field: e, value: r, handleChange: n, handleError: a }) => {
|
|
3973
|
+
const t = Ot(e.type), o = F.useCallback(
|
|
3974
|
+
(i, m) => n(e.name, i, m),
|
|
3852
3975
|
[n, e.name]
|
|
3853
|
-
), s =
|
|
3854
|
-
(i) =>
|
|
3855
|
-
[
|
|
3976
|
+
), s = F.useCallback(
|
|
3977
|
+
(i) => a?.(e.name, i),
|
|
3978
|
+
[a, e.name]
|
|
3856
3979
|
);
|
|
3857
3980
|
return t ? /* @__PURE__ */ g.jsx(
|
|
3858
3981
|
t,
|
|
3859
3982
|
{
|
|
3860
3983
|
field: e,
|
|
3861
3984
|
value: r,
|
|
3862
|
-
onChange:
|
|
3985
|
+
onChange: o,
|
|
3863
3986
|
onError: s
|
|
3864
3987
|
}
|
|
3865
3988
|
) : null;
|
|
3866
3989
|
}, (e, r) => e.field === r.field && e.value === r.value && e.handleChange === r.handleChange && e.handleError === r.handleError);
|
|
3867
|
-
|
|
3868
|
-
const pr = (e, r, n,
|
|
3869
|
-
|
|
3990
|
+
fr.displayName = "FieldWrapper";
|
|
3991
|
+
const pr = (e, r, n, a) => /* @__PURE__ */ g.jsx(
|
|
3992
|
+
fr,
|
|
3870
3993
|
{
|
|
3871
3994
|
field: e,
|
|
3872
3995
|
value: r[e.name],
|
|
3873
3996
|
handleChange: n,
|
|
3874
|
-
handleError:
|
|
3997
|
+
handleError: a
|
|
3875
3998
|
},
|
|
3876
3999
|
e.name
|
|
3877
|
-
), gr =
|
|
3878
|
-
const
|
|
4000
|
+
), gr = F.memo(({ groupName: e, isOpen: r, fields: n, valuesMap: a, handleChange: t, handleError: o, toggleGroup: s, t: i }) => {
|
|
4001
|
+
const m = F.useCallback(() => s(e), [s, e]), { formStyle: d, fieldStyle: l } = L(), u = F.useMemo(() => ({
|
|
3879
4002
|
border: "1px solid var(--reactaform-border-color, #bbb)",
|
|
3880
4003
|
padding: "var(--reactaform-fieldset-padding, 0.5em)",
|
|
3881
4004
|
borderRadius: "var(--reactaform-border-radius, 4px)",
|
|
3882
4005
|
marginBottom: "var(--reactaform-space, 8px)",
|
|
3883
4006
|
// allow per-form overrides if provider exposes them
|
|
3884
|
-
...
|
|
4007
|
+
...d?.fieldset || {},
|
|
3885
4008
|
...l?.fieldset || {}
|
|
3886
|
-
}), [
|
|
4009
|
+
}), [d, l]), c = F.useMemo(() => ({
|
|
3887
4010
|
fontWeight: "bold",
|
|
3888
4011
|
cursor: "pointer",
|
|
3889
4012
|
display: "flex",
|
|
@@ -3891,141 +4014,141 @@ const pr = (e, r, n, o) => /* @__PURE__ */ g.jsx(
|
|
|
3891
4014
|
alignItems: "center",
|
|
3892
4015
|
padding: "0 var(--reactaform-space, 8px)",
|
|
3893
4016
|
color: "var(--reactaform-text-color, inherit)",
|
|
3894
|
-
...
|
|
4017
|
+
...d?.legend || {},
|
|
3895
4018
|
...l?.legend || {}
|
|
3896
|
-
}), [
|
|
3897
|
-
return /* @__PURE__ */ g.jsxs("fieldset", { style:
|
|
3898
|
-
/* @__PURE__ */ g.jsxs("legend", { onClick:
|
|
4019
|
+
}), [d, l]);
|
|
4020
|
+
return /* @__PURE__ */ g.jsxs("fieldset", { style: u, children: [
|
|
4021
|
+
/* @__PURE__ */ g.jsxs("legend", { onClick: m, style: c, children: [
|
|
3899
4022
|
/* @__PURE__ */ g.jsx("span", { children: i(e) }),
|
|
3900
4023
|
/* @__PURE__ */ g.jsx("span", { children: r ? "▼" : "▶" })
|
|
3901
4024
|
] }),
|
|
3902
|
-
r && n.map((
|
|
4025
|
+
r && n.map((p) => /* @__PURE__ */ g.jsx("div", { children: pr(p, a, t, o) }, p.name))
|
|
3903
4026
|
] });
|
|
3904
4027
|
});
|
|
3905
4028
|
gr.displayName = "FieldGroup";
|
|
3906
|
-
const zt = (e, r, n,
|
|
3907
|
-
const
|
|
3908
|
-
return
|
|
3909
|
-
if (
|
|
3910
|
-
const b = e[
|
|
4029
|
+
const zt = (e, r, n, a, t, o, s, i, m) => {
|
|
4030
|
+
const d = r.slice(0, i).filter((p) => s[p.name]), u = Or(d).groups, c = [];
|
|
4031
|
+
return u.forEach((p) => {
|
|
4032
|
+
if (p.name) {
|
|
4033
|
+
const b = e[p.name] ?? !0;
|
|
3911
4034
|
c.push(
|
|
3912
4035
|
/* @__PURE__ */ g.jsx(
|
|
3913
4036
|
gr,
|
|
3914
4037
|
{
|
|
3915
|
-
groupName:
|
|
4038
|
+
groupName: p.name,
|
|
3916
4039
|
isOpen: b,
|
|
3917
|
-
fields:
|
|
4040
|
+
fields: p.fields,
|
|
3918
4041
|
valuesMap: n,
|
|
3919
4042
|
handleChange: t,
|
|
3920
|
-
handleError:
|
|
3921
|
-
toggleGroup:
|
|
3922
|
-
t:
|
|
4043
|
+
handleError: o,
|
|
4044
|
+
toggleGroup: m,
|
|
4045
|
+
t: a
|
|
3923
4046
|
},
|
|
3924
|
-
|
|
4047
|
+
p.name
|
|
3925
4048
|
)
|
|
3926
4049
|
);
|
|
3927
4050
|
} else
|
|
3928
|
-
|
|
4051
|
+
p.fields.forEach((b) => c.push(/* @__PURE__ */ g.jsx("div", { children: pr(b, n, t, o) }, b.name)));
|
|
3929
4052
|
}), c;
|
|
3930
4053
|
}, Tt = (e) => {
|
|
3931
4054
|
const r = {};
|
|
3932
4055
|
return e.forEach((n) => {
|
|
3933
4056
|
r[n.name] = !1;
|
|
3934
4057
|
}), r;
|
|
3935
|
-
}, Pe = (e, r, n,
|
|
4058
|
+
}, Pe = (e, r, n, a) => {
|
|
3936
4059
|
const t = r[e];
|
|
3937
4060
|
if (!t?.children) return;
|
|
3938
|
-
const
|
|
3939
|
-
(t.children[s] || []).forEach((
|
|
3940
|
-
|
|
4061
|
+
const o = n[e], s = o != null ? String(o) : "";
|
|
4062
|
+
(t.children[s] || []).forEach((m) => {
|
|
4063
|
+
a[m] = !0, Pe(m, r, n, a);
|
|
3941
4064
|
});
|
|
3942
4065
|
}, hr = (e, r, n) => {
|
|
3943
|
-
const
|
|
3944
|
-
|
|
4066
|
+
const a = r[e];
|
|
4067
|
+
a?.children && Object.values(a.children).flat().forEach((t) => {
|
|
3945
4068
|
n[t] = !1, hr(t, r, n);
|
|
3946
4069
|
});
|
|
3947
|
-
}, Lt = (e, r, n,
|
|
4070
|
+
}, Lt = (e, r, n, a) => {
|
|
3948
4071
|
const t = { ...n };
|
|
3949
|
-
return e.forEach((
|
|
3950
|
-
(!
|
|
4072
|
+
return e.forEach((o) => {
|
|
4073
|
+
(!o.parents || Object.keys(o.parents).length === 0) && (t[o.name] = !0, Pe(o.name, a, r, t));
|
|
3951
4074
|
}), t;
|
|
3952
|
-
}, Pt = (e, r, n,
|
|
3953
|
-
const
|
|
3954
|
-
if (hr(
|
|
3955
|
-
const s = r[
|
|
4075
|
+
}, Pt = (e, r, n, a, t) => {
|
|
4076
|
+
const o = { ...e };
|
|
4077
|
+
if (hr(a, r, o), t != null) {
|
|
4078
|
+
const s = r[a];
|
|
3956
4079
|
if (s?.children) {
|
|
3957
4080
|
const i = String(t);
|
|
3958
|
-
(s.children[i] || []).forEach((
|
|
3959
|
-
|
|
4081
|
+
(s.children[i] || []).forEach((d) => {
|
|
4082
|
+
o[d] = !0, Pe(d, r, n, o);
|
|
3960
4083
|
});
|
|
3961
4084
|
}
|
|
3962
4085
|
}
|
|
3963
|
-
return
|
|
4086
|
+
return o;
|
|
3964
4087
|
};
|
|
3965
|
-
function _t(e, r, n,
|
|
3966
|
-
const
|
|
3967
|
-
if (
|
|
4088
|
+
function _t(e, r, n, a, t) {
|
|
4089
|
+
const o = Object.values(t).filter(Boolean);
|
|
4090
|
+
if (o.length > 0)
|
|
3968
4091
|
return {
|
|
3969
4092
|
success: !1,
|
|
3970
|
-
message:
|
|
3971
|
-
errors:
|
|
4093
|
+
message: a("Please fix validation errors before submitting."),
|
|
4094
|
+
errors: o
|
|
3972
4095
|
};
|
|
3973
4096
|
const s = { ...n }, i = [];
|
|
3974
4097
|
if (e && Array.isArray(e.properties))
|
|
3975
|
-
for (const
|
|
3976
|
-
const l =
|
|
3977
|
-
if (
|
|
3978
|
-
const c =
|
|
4098
|
+
for (const d of e.properties) {
|
|
4099
|
+
const l = d.name, u = s[l];
|
|
4100
|
+
if (u == null) continue;
|
|
4101
|
+
const c = d.type;
|
|
3979
4102
|
try {
|
|
3980
4103
|
if (c === "int" || c === "number" || c === "float") {
|
|
3981
|
-
const
|
|
3982
|
-
isNaN(
|
|
4104
|
+
const p = Number(String(u).trim());
|
|
4105
|
+
isNaN(p) ? i.push(a(`Invalid number format for field ${d.displayName || l}`)) : s[l] = p;
|
|
3983
4106
|
} else if (c === "int-array" || c === "float-array") {
|
|
3984
|
-
const b = String(
|
|
4107
|
+
const b = String(u).split(",").map((f) => f.trim()).filter(Boolean).map((f) => {
|
|
3985
4108
|
const y = Number(f);
|
|
3986
|
-
return isNaN(y) ? (i.push(
|
|
4109
|
+
return isNaN(y) ? (i.push(a(`Invalid number "${f}" in array for field ${d.displayName || l}`)), 0) : y;
|
|
3987
4110
|
});
|
|
3988
4111
|
i.length === 0 && (s[l] = b);
|
|
3989
4112
|
}
|
|
3990
|
-
} catch (
|
|
3991
|
-
i.push(
|
|
4113
|
+
} catch (p) {
|
|
4114
|
+
i.push(a(`Error processing field ${d.displayName || l}: ${p}`));
|
|
3992
4115
|
}
|
|
3993
4116
|
}
|
|
3994
4117
|
if (i.length > 0)
|
|
3995
4118
|
return {
|
|
3996
4119
|
success: !1,
|
|
3997
|
-
message:
|
|
4120
|
+
message: a("Data transformation errors occurred."),
|
|
3998
4121
|
errors: i
|
|
3999
4122
|
};
|
|
4000
|
-
const
|
|
4001
|
-
if (
|
|
4123
|
+
const m = Nr(e, s, a);
|
|
4124
|
+
if (m && m.length > 0)
|
|
4002
4125
|
return {
|
|
4003
4126
|
success: !1,
|
|
4004
4127
|
message: "Validation Fail",
|
|
4005
|
-
errors:
|
|
4128
|
+
errors: m
|
|
4006
4129
|
};
|
|
4007
4130
|
if (e && typeof e.submitHandlerName == "string") {
|
|
4008
|
-
const
|
|
4009
|
-
if (
|
|
4131
|
+
const d = Vt(e.submitHandlerName);
|
|
4132
|
+
if (d)
|
|
4010
4133
|
try {
|
|
4011
|
-
const l =
|
|
4134
|
+
const l = d(e, r?.name ?? null, s, a);
|
|
4012
4135
|
if (l && l.length > 0)
|
|
4013
4136
|
return {
|
|
4014
4137
|
success: !1,
|
|
4015
|
-
message:
|
|
4138
|
+
message: a("Submission failed."),
|
|
4016
4139
|
errors: Array.isArray(l) ? l : [l]
|
|
4017
4140
|
};
|
|
4018
4141
|
} catch (l) {
|
|
4019
4142
|
return {
|
|
4020
4143
|
success: !1,
|
|
4021
|
-
message:
|
|
4144
|
+
message: a("Submission handler error occurred."),
|
|
4022
4145
|
errors: [String(l)]
|
|
4023
4146
|
};
|
|
4024
4147
|
}
|
|
4025
4148
|
}
|
|
4026
4149
|
return {
|
|
4027
4150
|
success: !0,
|
|
4028
|
-
message:
|
|
4151
|
+
message: a("Form submitted successfully."),
|
|
4029
4152
|
data: s
|
|
4030
4153
|
};
|
|
4031
4154
|
}
|
|
@@ -4033,122 +4156,122 @@ const qt = ({
|
|
|
4033
4156
|
definition: e,
|
|
4034
4157
|
instance: r,
|
|
4035
4158
|
chunkSize: n = 50,
|
|
4036
|
-
chunkDelay:
|
|
4159
|
+
chunkDelay: a = 50
|
|
4037
4160
|
}) => {
|
|
4038
|
-
const { properties: t, displayName:
|
|
4161
|
+
const { properties: t, displayName: o } = e, s = L(), { t: i, formStyle: m, language: d } = s, l = {
|
|
4039
4162
|
...s,
|
|
4040
4163
|
definitionName: e?.name ?? s.definitionName
|
|
4041
|
-
}, [
|
|
4164
|
+
}, [u, c] = V("en"), [p, b] = V([]), [f, y] = V({}), [C, x] = V(
|
|
4042
4165
|
{}
|
|
4043
|
-
), [
|
|
4044
|
-
|
|
4045
|
-
const
|
|
4046
|
-
t.map((
|
|
4047
|
-
|
|
4048
|
-
{ ...
|
|
4166
|
+
), [j, N] = V({}), [v, w] = V({}), [I, A] = V({}), [R, $] = V(null), [O, P] = V(null), [W, ae] = V(0), [re, ue] = V(!1), [Q, oe] = V(!1), [Z, T] = V(r.name || ""), h = E(r), S = E(!1);
|
|
4167
|
+
k(() => {
|
|
4168
|
+
const D = Object.fromEntries(
|
|
4169
|
+
t.map((B) => [
|
|
4170
|
+
B.name,
|
|
4171
|
+
{ ...B, children: {} }
|
|
4049
4172
|
])
|
|
4050
4173
|
);
|
|
4051
|
-
t.forEach((
|
|
4052
|
-
|
|
4053
|
-
const
|
|
4054
|
-
|
|
4055
|
-
|
|
4174
|
+
t.forEach((B) => {
|
|
4175
|
+
B.parents && Object.entries(B.parents).forEach(([me, Se]) => {
|
|
4176
|
+
const de = D[me];
|
|
4177
|
+
de && Se.forEach((br) => {
|
|
4178
|
+
de.children || (de.children = {});
|
|
4056
4179
|
const _e = String(br);
|
|
4057
|
-
|
|
4058
|
-
...
|
|
4059
|
-
|
|
4180
|
+
de.children[_e] = [
|
|
4181
|
+
...de.children[_e] || [],
|
|
4182
|
+
B.name
|
|
4060
4183
|
];
|
|
4061
4184
|
});
|
|
4062
4185
|
});
|
|
4063
|
-
}),
|
|
4064
|
-
const
|
|
4065
|
-
|
|
4066
|
-
),
|
|
4067
|
-
|
|
4068
|
-
if (
|
|
4069
|
-
const me = typeof
|
|
4070
|
-
|
|
4186
|
+
}), Mr(t, D);
|
|
4187
|
+
const _ = Object.values(
|
|
4188
|
+
D
|
|
4189
|
+
), K = {};
|
|
4190
|
+
_.forEach((B) => {
|
|
4191
|
+
if (B.type === "unit") {
|
|
4192
|
+
const me = typeof B.defaultValue == "number" ? String(B.defaultValue) : "", Se = typeof B.defaultUnit == "string" ? B.defaultUnit : String(B.defaultUnit ?? "m");
|
|
4193
|
+
K[B.name] = [me, Se];
|
|
4071
4194
|
} else
|
|
4072
|
-
|
|
4073
|
-
}), h.current = r, Object.keys(r.values).forEach((
|
|
4074
|
-
|
|
4195
|
+
K[B.name] = B.defaultValue;
|
|
4196
|
+
}), h.current = r, Object.keys(r.values).forEach((B) => {
|
|
4197
|
+
D[B] !== void 0 && (K[B] = r.values[B]);
|
|
4075
4198
|
});
|
|
4076
|
-
const ee = Tt(
|
|
4077
|
-
|
|
4078
|
-
|
|
4199
|
+
const ee = Tt(_), ne = {};
|
|
4200
|
+
_.forEach((B) => {
|
|
4201
|
+
B.group && !(B.group in ne) && (ne[B.group] = !0);
|
|
4079
4202
|
});
|
|
4080
4203
|
const le = requestAnimationFrame(() => {
|
|
4081
|
-
b(
|
|
4082
|
-
Lt(
|
|
4083
|
-
),
|
|
4204
|
+
b(_), y(D), x(K), N(
|
|
4205
|
+
Lt(_, K, ee, D)
|
|
4206
|
+
), w(ne), ue(!0), T(r.name);
|
|
4084
4207
|
});
|
|
4085
4208
|
return () => cancelAnimationFrame(le);
|
|
4086
|
-
}, [t, r, e]),
|
|
4087
|
-
if (!re ||
|
|
4088
|
-
const
|
|
4089
|
-
|
|
4090
|
-
(
|
|
4209
|
+
}, [t, r, e]), k(() => {
|
|
4210
|
+
if (!re || W >= p.length) return;
|
|
4211
|
+
const D = setTimeout(() => {
|
|
4212
|
+
ae(
|
|
4213
|
+
(_) => Math.min(_ + n, p.length)
|
|
4091
4214
|
);
|
|
4092
|
-
},
|
|
4093
|
-
return () => clearTimeout(
|
|
4094
|
-
}, [re,
|
|
4095
|
-
const
|
|
4096
|
-
(
|
|
4097
|
-
|
|
4098
|
-
const
|
|
4215
|
+
}, a);
|
|
4216
|
+
return () => clearTimeout(D);
|
|
4217
|
+
}, [re, W, p.length, n, a]);
|
|
4218
|
+
const z = X(
|
|
4219
|
+
(D, _, K) => {
|
|
4220
|
+
$(null), P(null), x((ee) => {
|
|
4221
|
+
const ne = { ...ee, [D]: _ }, le = f[D];
|
|
4099
4222
|
return le && [
|
|
4100
4223
|
"checkbox",
|
|
4101
4224
|
"dropdown",
|
|
4102
4225
|
"multi-select",
|
|
4103
4226
|
"radio",
|
|
4104
4227
|
"switch"
|
|
4105
|
-
].includes(le.type) &&
|
|
4228
|
+
].includes(le.type) && N(
|
|
4106
4229
|
(me) => Pt(
|
|
4107
4230
|
me,
|
|
4108
4231
|
f,
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
String(
|
|
4232
|
+
ne,
|
|
4233
|
+
D,
|
|
4234
|
+
String(_)
|
|
4112
4235
|
)
|
|
4113
|
-
),
|
|
4114
|
-
}),
|
|
4236
|
+
), ne;
|
|
4237
|
+
}), A((ee) => K ? { ...ee, [D]: K } : Object.fromEntries(Object.entries(ee).filter(([le]) => le !== D)));
|
|
4115
4238
|
},
|
|
4116
|
-
[f,
|
|
4239
|
+
[f, $, P]
|
|
4117
4240
|
);
|
|
4118
|
-
|
|
4119
|
-
let
|
|
4120
|
-
return
|
|
4121
|
-
|
|
4122
|
-
}), () => cancelAnimationFrame(
|
|
4123
|
-
}, [
|
|
4124
|
-
let
|
|
4125
|
-
return
|
|
4126
|
-
if (
|
|
4127
|
-
|
|
4241
|
+
k(() => {
|
|
4242
|
+
let D = 0;
|
|
4243
|
+
return D = requestAnimationFrame(() => {
|
|
4244
|
+
d !== u && (c(d || "en"), $(null), P(null));
|
|
4245
|
+
}), () => cancelAnimationFrame(D);
|
|
4246
|
+
}, [d, u]), k(() => {
|
|
4247
|
+
let D = 0;
|
|
4248
|
+
return D = requestAnimationFrame(() => {
|
|
4249
|
+
if (S.current) {
|
|
4250
|
+
S.current = !1, h.current = r, T(r.name || "");
|
|
4128
4251
|
return;
|
|
4129
4252
|
}
|
|
4130
|
-
h.current = r,
|
|
4131
|
-
}), () => cancelAnimationFrame(
|
|
4253
|
+
h.current = r, $(null), P(null), T(r.name || "");
|
|
4254
|
+
}), () => cancelAnimationFrame(D);
|
|
4132
4255
|
}, [r, r.name]);
|
|
4133
|
-
const
|
|
4134
|
-
|
|
4135
|
-
}, []),
|
|
4136
|
-
|
|
4137
|
-
const
|
|
4138
|
-
h.current.name =
|
|
4139
|
-
const
|
|
4256
|
+
const Y = X((D, _) => {
|
|
4257
|
+
A((K) => _ ? { ...K, [D]: String(_) } : Object.fromEntries(Object.entries(K).filter(([ne]) => ne !== D)));
|
|
4258
|
+
}, []), te = () => {
|
|
4259
|
+
S.current = !0;
|
|
4260
|
+
const D = h.current?.name;
|
|
4261
|
+
h.current.name = Z;
|
|
4262
|
+
const _ = _t(e, h.current, C, i, I), K = typeof _.message == "string" ? _.message : String(_.message), ee = Object.values(_.errors ?? {}).join(`
|
|
4140
4263
|
`);
|
|
4141
|
-
|
|
4142
|
-
` + ee :
|
|
4143
|
-
},
|
|
4144
|
-
|
|
4145
|
-
},
|
|
4264
|
+
$(ee ? K + `
|
|
4265
|
+
` + ee : K), P(_.success), _.success || (h.current.name = D ?? h.current.name, T(D ?? ""));
|
|
4266
|
+
}, se = (D) => {
|
|
4267
|
+
w((_) => ({ ..._, [D]: !_[D] }));
|
|
4268
|
+
}, q = J(
|
|
4146
4269
|
() => Object.values(I).some(Boolean),
|
|
4147
4270
|
[I]
|
|
4148
4271
|
);
|
|
4149
|
-
return /* @__PURE__ */ g.jsx(
|
|
4150
|
-
|
|
4151
|
-
|
|
4272
|
+
return /* @__PURE__ */ g.jsx(Me.Provider, { value: l, children: /* @__PURE__ */ g.jsxs("div", { style: m.container, children: [
|
|
4273
|
+
o && /* @__PURE__ */ g.jsx("h2", { style: m.titleStyle, children: i(o) }),
|
|
4274
|
+
R && /* @__PURE__ */ g.jsxs(
|
|
4152
4275
|
"div",
|
|
4153
4276
|
{
|
|
4154
4277
|
role: "status",
|
|
@@ -4156,20 +4279,20 @@ const qt = ({
|
|
|
4156
4279
|
marginBottom: 12,
|
|
4157
4280
|
padding: 12,
|
|
4158
4281
|
borderRadius: 6,
|
|
4159
|
-
backgroundColor:
|
|
4160
|
-
border: `1px solid ${
|
|
4161
|
-
color:
|
|
4282
|
+
backgroundColor: O ? "rgba(76, 175, 80, 0.12)" : "rgba(225, 29, 72, 0.06)",
|
|
4283
|
+
border: `1px solid ${O ? "rgba(76,175,80,0.3)" : "rgba(225,29,72,0.12)"}`,
|
|
4284
|
+
color: O ? "var(--reactaform-success-color, #4CAF50)" : "var(--reactaform-error-color, #e11d48)",
|
|
4162
4285
|
display: "flex",
|
|
4163
4286
|
alignItems: "center",
|
|
4164
4287
|
justifyContent: "space-between"
|
|
4165
4288
|
},
|
|
4166
4289
|
children: [
|
|
4167
|
-
/* @__PURE__ */ g.jsx("div", { style: { whiteSpace: "pre-wrap", flex: 1 }, children:
|
|
4290
|
+
/* @__PURE__ */ g.jsx("div", { style: { whiteSpace: "pre-wrap", flex: 1 }, children: R }),
|
|
4168
4291
|
/* @__PURE__ */ g.jsx(
|
|
4169
4292
|
"button",
|
|
4170
4293
|
{
|
|
4171
4294
|
onClick: () => {
|
|
4172
|
-
|
|
4295
|
+
$(null), P(null);
|
|
4173
4296
|
},
|
|
4174
4297
|
"aria-label": i("Dismiss"),
|
|
4175
4298
|
style: {
|
|
@@ -4190,25 +4313,25 @@ const qt = ({
|
|
|
4190
4313
|
r && /* @__PURE__ */ g.jsx(
|
|
4191
4314
|
tr,
|
|
4192
4315
|
{
|
|
4193
|
-
name:
|
|
4194
|
-
onChange: (
|
|
4195
|
-
|
|
4316
|
+
name: Z,
|
|
4317
|
+
onChange: (D) => {
|
|
4318
|
+
T(D), $(null), P(null);
|
|
4196
4319
|
}
|
|
4197
4320
|
}
|
|
4198
4321
|
),
|
|
4199
4322
|
/* @__PURE__ */ g.jsxs(g.Fragment, { children: [
|
|
4200
4323
|
zt(
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4324
|
+
v,
|
|
4325
|
+
p,
|
|
4326
|
+
C,
|
|
4204
4327
|
i,
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4328
|
+
z,
|
|
4329
|
+
Y,
|
|
4330
|
+
j,
|
|
4331
|
+
W,
|
|
4332
|
+
se
|
|
4210
4333
|
),
|
|
4211
|
-
|
|
4334
|
+
W < p.length && /* @__PURE__ */ g.jsx(
|
|
4212
4335
|
"div",
|
|
4213
4336
|
{
|
|
4214
4337
|
style: {
|
|
@@ -4221,23 +4344,23 @@ const qt = ({
|
|
|
4221
4344
|
/* @__PURE__ */ g.jsx(
|
|
4222
4345
|
"button",
|
|
4223
4346
|
{
|
|
4224
|
-
onClick:
|
|
4225
|
-
disabled:
|
|
4347
|
+
onClick: te,
|
|
4348
|
+
disabled: q,
|
|
4226
4349
|
onMouseEnter: () => oe(!0),
|
|
4227
4350
|
onMouseLeave: () => oe(!1),
|
|
4228
4351
|
style: {
|
|
4229
4352
|
padding: "var(--reactaform-button-padding, var(--reactaform-space) 12px)",
|
|
4230
|
-
backgroundColor:
|
|
4353
|
+
backgroundColor: q ? "var(--reactaform-button-disabled-bg, #cccccc)" : "var(--reactaform-button-bg, var(--reactaform-success-color))",
|
|
4231
4354
|
color: "var(--reactaform-button-text, #ffffff)",
|
|
4232
4355
|
border: "none",
|
|
4233
4356
|
borderRadius: "4px",
|
|
4234
|
-
cursor:
|
|
4357
|
+
cursor: q ? "var(--reactaform-button-disabled-cursor, not-allowed)" : "pointer",
|
|
4235
4358
|
fontSize: "var(--reactaform-button-font-size, 14px)",
|
|
4236
4359
|
fontWeight: "var(--reactaform-button-font-weight, 500)",
|
|
4237
4360
|
boxShadow: "var(--reactaform-button-shadow, none)",
|
|
4238
4361
|
marginTop: "var(--reactaform-button-margin-top, 0.5em)",
|
|
4239
4362
|
transition: "opacity 0.2s ease",
|
|
4240
|
-
opacity:
|
|
4363
|
+
opacity: q ? "var(--reactaform-button-disabled-opacity, 0.6)" : Q ? "var(--reactaform-button-hover-opacity, 0.9)" : "1"
|
|
4241
4364
|
},
|
|
4242
4365
|
children: i("Submit")
|
|
4243
4366
|
}
|
|
@@ -4349,57 +4472,57 @@ const Bt = (e, r = !1) => ({
|
|
|
4349
4472
|
children: e,
|
|
4350
4473
|
definitionName: r = "",
|
|
4351
4474
|
defaultStyle: n,
|
|
4352
|
-
defaultLanguage:
|
|
4475
|
+
defaultLanguage: a = "en",
|
|
4353
4476
|
defaultDarkMode: t = !1,
|
|
4354
|
-
defaultLocalizeName:
|
|
4477
|
+
defaultLocalizeName: o = "",
|
|
4355
4478
|
className: s = "reactaform-container"
|
|
4356
4479
|
}) => {
|
|
4357
|
-
const i = r,
|
|
4480
|
+
const i = r, m = o, d = t, l = a, u = J(
|
|
4358
4481
|
() => n ?? {},
|
|
4359
4482
|
[n]
|
|
4360
|
-
), [c,
|
|
4361
|
-
|
|
4362
|
-
let
|
|
4483
|
+
), [c, p] = V({}), [b, f] = V({}), [y, C] = V({}), [x, j] = V({});
|
|
4484
|
+
k(() => {
|
|
4485
|
+
let A = !0;
|
|
4363
4486
|
return (async () => {
|
|
4364
4487
|
if (l === "en") {
|
|
4365
|
-
|
|
4488
|
+
A && (p({}), f({}));
|
|
4366
4489
|
return;
|
|
4367
4490
|
}
|
|
4368
4491
|
try {
|
|
4369
|
-
const
|
|
4370
|
-
|
|
4371
|
-
const
|
|
4372
|
-
|
|
4492
|
+
const $ = await Vr(l), O = $.success ? $.translations : {};
|
|
4493
|
+
A && p(O);
|
|
4494
|
+
const P = await zr(l, m), W = P.success ? P.translations : {};
|
|
4495
|
+
A && f(W);
|
|
4373
4496
|
} catch {
|
|
4374
|
-
|
|
4497
|
+
A && (p({}), f({}));
|
|
4375
4498
|
}
|
|
4376
4499
|
})(), () => {
|
|
4377
|
-
|
|
4500
|
+
A = !1;
|
|
4378
4501
|
};
|
|
4379
|
-
}, [l,
|
|
4380
|
-
|
|
4381
|
-
}, [
|
|
4382
|
-
const
|
|
4502
|
+
}, [l, m]), k(() => {
|
|
4503
|
+
j(Bt(u, d)), C(Ht(u, d));
|
|
4504
|
+
}, [u, d]);
|
|
4505
|
+
const N = J(
|
|
4383
4506
|
() => Lr(l, c, b),
|
|
4384
4507
|
[l, c, b]
|
|
4385
|
-
),
|
|
4386
|
-
(
|
|
4387
|
-
[
|
|
4388
|
-
),
|
|
4508
|
+
), v = X(
|
|
4509
|
+
(A, ...R) => N(A, ...R),
|
|
4510
|
+
[N]
|
|
4511
|
+
), w = J(
|
|
4389
4512
|
() => ({
|
|
4390
4513
|
definitionName: i,
|
|
4391
4514
|
language: l,
|
|
4392
|
-
darkMode:
|
|
4393
|
-
formStyle:
|
|
4515
|
+
darkMode: d,
|
|
4516
|
+
formStyle: x,
|
|
4394
4517
|
fieldStyle: y,
|
|
4395
|
-
t:
|
|
4518
|
+
t: v
|
|
4396
4519
|
}),
|
|
4397
|
-
[i, l,
|
|
4398
|
-
), I =
|
|
4399
|
-
return /* @__PURE__ */ g.jsx(
|
|
4520
|
+
[i, l, d, y, x, v]
|
|
4521
|
+
), I = u?.height ? { height: "100%" } : void 0;
|
|
4522
|
+
return /* @__PURE__ */ g.jsx(Me.Provider, { value: w, children: /* @__PURE__ */ g.jsx(
|
|
4400
4523
|
"div",
|
|
4401
4524
|
{
|
|
4402
|
-
"data-reactaform-theme":
|
|
4525
|
+
"data-reactaform-theme": d ? "dark" : "light",
|
|
4403
4526
|
className: s,
|
|
4404
4527
|
style: I,
|
|
4405
4528
|
children: e
|
|
@@ -4414,10 +4537,10 @@ function Wt(e) {
|
|
|
4414
4537
|
if (r.properties !== void 0 && !Array.isArray(r.properties)) return "'properties' must be an array if provided";
|
|
4415
4538
|
if (Array.isArray(r.properties))
|
|
4416
4539
|
for (let n = 0; n < r.properties.length; n++) {
|
|
4417
|
-
const
|
|
4418
|
-
if (!
|
|
4419
|
-
if (!
|
|
4420
|
-
if (!
|
|
4540
|
+
const a = r.properties[n];
|
|
4541
|
+
if (!a || typeof a != "object") return `Property at index ${n} must be an object`;
|
|
4542
|
+
if (!a.name || typeof a.name != "string") return `Property at index ${n} must have a string 'name'`;
|
|
4543
|
+
if (!a.type || typeof a.type != "string") return `Property '${a.name}' must have a string 'type'`;
|
|
4421
4544
|
}
|
|
4422
4545
|
return null;
|
|
4423
4546
|
}
|
|
@@ -4426,26 +4549,26 @@ async function sn(e, r = {}) {
|
|
|
4426
4549
|
try {
|
|
4427
4550
|
if (!e || typeof e != "string")
|
|
4428
4551
|
return { success: !1, error: "jsonData must be a non-empty JSON string" };
|
|
4429
|
-
const
|
|
4430
|
-
if (!
|
|
4552
|
+
const a = e.trim();
|
|
4553
|
+
if (!a)
|
|
4431
4554
|
return { success: !1, error: "jsonData is empty" };
|
|
4432
4555
|
let t;
|
|
4433
4556
|
try {
|
|
4434
|
-
t = JSON.parse(
|
|
4435
|
-
} catch (
|
|
4557
|
+
t = JSON.parse(a);
|
|
4558
|
+
} catch (o) {
|
|
4436
4559
|
return {
|
|
4437
4560
|
success: !1,
|
|
4438
|
-
error: `Invalid JSON format: ${
|
|
4561
|
+
error: `Invalid JSON format: ${o instanceof Error ? o.message : "Unknown parsing error"}`
|
|
4439
4562
|
};
|
|
4440
4563
|
}
|
|
4441
4564
|
if (n) {
|
|
4442
|
-
const
|
|
4443
|
-
if (
|
|
4444
|
-
return { success: !1, error: `Schema validation failed: ${
|
|
4565
|
+
const o = Wt(t);
|
|
4566
|
+
if (o)
|
|
4567
|
+
return { success: !1, error: `Schema validation failed: ${o}` };
|
|
4445
4568
|
}
|
|
4446
4569
|
return { success: !0, definition: t };
|
|
4447
|
-
} catch (
|
|
4448
|
-
return { success: !1, error: `Unexpected error loading definition: ${
|
|
4570
|
+
} catch (a) {
|
|
4571
|
+
return { success: !1, error: `Unexpected error loading definition: ${a instanceof Error ? a.message : "Unknown error"}` };
|
|
4449
4572
|
}
|
|
4450
4573
|
}
|
|
4451
4574
|
function Yt(e, r) {
|
|
@@ -4459,10 +4582,10 @@ function Yt(e, r) {
|
|
|
4459
4582
|
definition: e.name ?? "unknown",
|
|
4460
4583
|
version: e.version ?? "1.0.0",
|
|
4461
4584
|
values: {}
|
|
4462
|
-
},
|
|
4463
|
-
return Array.isArray(
|
|
4464
|
-
const
|
|
4465
|
-
|
|
4585
|
+
}, a = e.properties || [];
|
|
4586
|
+
return Array.isArray(a) && a.forEach((t) => {
|
|
4587
|
+
const o = t;
|
|
4588
|
+
o.defaultValue !== void 0 && (n.values[o.name] = o.defaultValue);
|
|
4466
4589
|
}), { success: !0, instance: n };
|
|
4467
4590
|
} catch (n) {
|
|
4468
4591
|
return {
|
|
@@ -4497,17 +4620,17 @@ function cn(e) {
|
|
|
4497
4620
|
}
|
|
4498
4621
|
mr();
|
|
4499
4622
|
function Jt(e) {
|
|
4500
|
-
const [r, n] =
|
|
4501
|
-
return
|
|
4502
|
-
const
|
|
4503
|
-
if (!
|
|
4504
|
-
const t =
|
|
4623
|
+
const [r, n] = V(null);
|
|
4624
|
+
return k(() => {
|
|
4625
|
+
const a = document.querySelector("[data-reactaform-theme]");
|
|
4626
|
+
if (!a) return;
|
|
4627
|
+
const t = a.closest("[data-reactaform-theme]");
|
|
4505
4628
|
if (!t) return;
|
|
4506
|
-
const
|
|
4507
|
-
|
|
4629
|
+
const o = () => n(t.getAttribute("data-reactaform-theme"));
|
|
4630
|
+
o();
|
|
4508
4631
|
const s = new MutationObserver((i) => {
|
|
4509
|
-
for (const
|
|
4510
|
-
|
|
4632
|
+
for (const m of i)
|
|
4633
|
+
m.type === "attributes" && m.attributeName === "data-reactaform-theme" && o();
|
|
4511
4634
|
});
|
|
4512
4635
|
return s.observe(t, { attributes: !0, attributeFilter: ["data-reactaform-theme"] }), () => s.disconnect();
|
|
4513
4636
|
}, [e]), r;
|
|
@@ -4516,28 +4639,28 @@ const ln = ({
|
|
|
4516
4639
|
definitionData: e,
|
|
4517
4640
|
instance: r,
|
|
4518
4641
|
language: n,
|
|
4519
|
-
className:
|
|
4642
|
+
className: a,
|
|
4520
4643
|
darkMode: t,
|
|
4521
|
-
style:
|
|
4644
|
+
style: o
|
|
4522
4645
|
}) => {
|
|
4523
|
-
const s =
|
|
4646
|
+
const s = J(() => {
|
|
4524
4647
|
try {
|
|
4525
4648
|
return typeof e == "string" ? JSON.parse(e) : e ?? null;
|
|
4526
4649
|
} catch {
|
|
4527
4650
|
return null;
|
|
4528
4651
|
}
|
|
4529
|
-
}, [e]), i = { fontSize: "inherit", fontFamily: "inherit", ...
|
|
4530
|
-
if (
|
|
4652
|
+
}, [e]), i = { fontSize: "inherit", fontFamily: "inherit", ...o }, m = Jt(), d = t ?? m === "dark", l = n ?? "en";
|
|
4653
|
+
if (k(() => {
|
|
4531
4654
|
let c = document.getElementById("popup-root");
|
|
4532
4655
|
c || (c = document.createElement("div"), c.id = "popup-root", document.body.appendChild(c));
|
|
4533
4656
|
}, []), !s)
|
|
4534
4657
|
return /* @__PURE__ */ g.jsx("div", { style: { color: "red" }, children: "Error: No form definition provided." });
|
|
4535
|
-
let
|
|
4536
|
-
if (!
|
|
4658
|
+
let u = r;
|
|
4659
|
+
if (!u) {
|
|
4537
4660
|
const c = Yt(s, s.name);
|
|
4538
4661
|
if (!c.success || !c.instance)
|
|
4539
4662
|
return /* @__PURE__ */ g.jsx("div", { style: { color: "red" }, children: "Error: Failed to create instance from definition." });
|
|
4540
|
-
|
|
4663
|
+
u = c.instance;
|
|
4541
4664
|
}
|
|
4542
4665
|
return /* @__PURE__ */ g.jsx(
|
|
4543
4666
|
Ut,
|
|
@@ -4545,14 +4668,14 @@ const ln = ({
|
|
|
4545
4668
|
definitionName: s.name,
|
|
4546
4669
|
defaultStyle: i,
|
|
4547
4670
|
defaultLanguage: l,
|
|
4548
|
-
defaultDarkMode:
|
|
4671
|
+
defaultDarkMode: d,
|
|
4549
4672
|
defaultLocalizeName: s.localization || "",
|
|
4550
|
-
className:
|
|
4673
|
+
className: a,
|
|
4551
4674
|
children: /* @__PURE__ */ g.jsx(
|
|
4552
4675
|
qt,
|
|
4553
4676
|
{
|
|
4554
4677
|
definition: s,
|
|
4555
|
-
instance:
|
|
4678
|
+
instance: u
|
|
4556
4679
|
}
|
|
4557
4680
|
)
|
|
4558
4681
|
}
|
|
@@ -4568,27 +4691,27 @@ function Gt() {
|
|
|
4568
4691
|
}
|
|
4569
4692
|
Gt();
|
|
4570
4693
|
export {
|
|
4571
|
-
|
|
4694
|
+
M as CSS_CLASSES,
|
|
4572
4695
|
ln as ReactaForm,
|
|
4573
4696
|
Ut as ReactaFormProvider,
|
|
4574
4697
|
qt as ReactaFormRenderer,
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4698
|
+
U as StandardFieldLayout,
|
|
4699
|
+
an as Units,
|
|
4700
|
+
G as combineClasses,
|
|
4578
4701
|
Yt as createInstanceFromDefinition,
|
|
4579
4702
|
nn as deserializeDefinition,
|
|
4580
4703
|
rn as deserializeInstance,
|
|
4581
|
-
|
|
4704
|
+
Ot as getComponent,
|
|
4582
4705
|
cn as loadInstance,
|
|
4583
4706
|
sn as loadJsonDefinition,
|
|
4584
|
-
|
|
4707
|
+
on as registerComponent,
|
|
4585
4708
|
Qt as registerFieldValidationHandler,
|
|
4586
4709
|
Zt as registerFormValidationHandler,
|
|
4587
|
-
|
|
4710
|
+
Dt as registerSubmissionHandler,
|
|
4588
4711
|
tn as serializeDefinition,
|
|
4589
4712
|
en as serializeInstance,
|
|
4590
4713
|
jr as useDebouncedCallback,
|
|
4591
|
-
|
|
4592
|
-
|
|
4714
|
+
L as useReactaFormContext,
|
|
4715
|
+
H as validateFieldValue,
|
|
4593
4716
|
Nr as validateFormValues
|
|
4594
4717
|
};
|