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