@reformer/core 8.0.0 → 9.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -57
- package/dist/behaviors-Br4Im38V.js +263 -0
- package/dist/behaviors.js +146 -146
- package/dist/core/factories/node-factory.d.ts +5 -4
- package/dist/core/model/behaviors.d.ts +15 -0
- package/dist/core/model/types.d.ts +41 -12
- package/dist/core/model/validate-model.d.ts +8 -4
- package/dist/core/nodes/field-node.d.ts +2 -2
- package/dist/core/nodes/group-node.d.ts +39 -3
- package/dist/core/nodes/model-array-node.d.ts +13 -1
- package/dist/core/types/deep-schema.d.ts +39 -5
- package/dist/core/types/form-proxy.d.ts +27 -2
- package/dist/core/types/index.d.ts +4 -10
- package/dist/core/types/schema-node.d.ts +79 -0
- package/dist/core/types/validation-schema.d.ts +37 -16
- package/dist/core/utils/create-form.d.ts +4 -3
- package/dist/core/utils/derived-registry.d.ts +29 -0
- package/dist/core/utils/error-handler.d.ts +4 -1
- package/dist/core/utils/form-submitter.d.ts +8 -4
- package/dist/core/utils/index.d.ts +1 -1
- package/dist/core/utils/safe-effect.d.ts +27 -7
- package/dist/core/utils/type-guards.d.ts +3 -3
- package/dist/core/validation/validators/date-utils.d.ts +5 -1
- package/dist/core/validation/validators/integer.d.ts +1 -1
- package/dist/core/validation/validators/is-number.d.ts +1 -1
- package/dist/core/validation/validators/max.d.ts +1 -1
- package/dist/core/validation/validators/min.d.ts +1 -1
- package/dist/core/validation/validators/multiple-of.d.ts +1 -1
- package/dist/core/validation/validators/non-negative.d.ts +1 -1
- package/dist/core/validation/validators/non-zero.d.ts +1 -1
- package/dist/core/validation/validators/required.d.ts +2 -1
- package/dist/{date-utils-xUWFslTj.js → date-utils-dTT_x_Be.js} +12 -10
- package/dist/hooks/types.d.ts +31 -1
- package/dist/hooks/useArrayLength.d.ts +1 -2
- package/dist/hooks/useFormControl.d.ts +2 -2
- package/dist/hooks/useSignalSubscription.d.ts +8 -1
- package/dist/index.js +625 -617
- package/dist/signals.d.ts +13 -0
- package/dist/signals.js +9 -0
- package/dist/validators/future-date.js +1 -1
- package/dist/validators/is-date.js +1 -1
- package/dist/validators/max-age.js +1 -1
- package/dist/validators/max-date.js +1 -1
- package/dist/validators/min-age.js +1 -1
- package/dist/validators/min-date.js +1 -1
- package/dist/validators/multiple-of.js +11 -7
- package/dist/validators/past-date.js +1 -1
- package/dist/validators/pattern.js +7 -6
- package/dist/validators/required.js +5 -9
- package/llms.txt +715 -175
- package/package.json +6 -2
- package/dist/behaviors-O9a1Djj9.js +0 -147
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { signal as y, computed as
|
|
2
|
-
import {
|
|
3
|
-
import { j as
|
|
4
|
-
import
|
|
5
|
-
import { default as
|
|
6
|
-
class
|
|
1
|
+
import { signal as y, computed as f, effect as _, batch as be, Signal as oe } from "@preact/signals-core";
|
|
2
|
+
import { F as N, E as O, i as G, g as X, d as _e } from "./behaviors-Br4Im38V.js";
|
|
3
|
+
import { j as ot, c as lt, k as ut, e as ct, m as ht, a as dt, b as ft, r as pt, f as vt, h as mt, s as yt, t as gt, u as bt, w as _t } from "./behaviors-Br4Im38V.js";
|
|
4
|
+
import le, { useRef as M, useCallback as E } from "react";
|
|
5
|
+
import { default as At } from "./validators.js";
|
|
6
|
+
class L {
|
|
7
7
|
// ============================================================================
|
|
8
8
|
// Protected состояние (для Template Method паттерна)
|
|
9
9
|
// ============================================================================
|
|
@@ -29,33 +29,33 @@ class I {
|
|
|
29
29
|
* Пользователь взаимодействовал с узлом (touched)
|
|
30
30
|
* Computed из _touched для предоставления readonly интерфейса
|
|
31
31
|
*/
|
|
32
|
-
touched =
|
|
32
|
+
touched = f(() => this._touched.value);
|
|
33
33
|
/**
|
|
34
34
|
* Пользователь не взаимодействовал с узлом (untouched)
|
|
35
35
|
*/
|
|
36
|
-
untouched =
|
|
36
|
+
untouched = f(() => !this._touched.value);
|
|
37
37
|
/**
|
|
38
38
|
* Значение узла было изменено (dirty)
|
|
39
39
|
* Computed из _dirty для предоставления readonly интерфейса
|
|
40
40
|
*/
|
|
41
|
-
dirty =
|
|
41
|
+
dirty = f(() => this._dirty.value);
|
|
42
42
|
/**
|
|
43
43
|
* Значение узла не было изменено (pristine)
|
|
44
44
|
*/
|
|
45
|
-
pristine =
|
|
45
|
+
pristine = f(() => !this._dirty.value);
|
|
46
46
|
/**
|
|
47
47
|
* Текущий статус узла
|
|
48
48
|
* Computed из _status для предоставления readonly интерфейса
|
|
49
49
|
*/
|
|
50
|
-
status =
|
|
50
|
+
status = f(() => this._status.value);
|
|
51
51
|
/**
|
|
52
52
|
* Узел отключен (disabled)
|
|
53
53
|
*/
|
|
54
|
-
disabled =
|
|
54
|
+
disabled = f(() => this._status.value === "disabled");
|
|
55
55
|
/**
|
|
56
56
|
* Узел включен (enabled)
|
|
57
57
|
*/
|
|
58
|
-
enabled =
|
|
58
|
+
enabled = f(() => this._status.value !== "disabled");
|
|
59
59
|
/**
|
|
60
60
|
* Получить ошибки валидации с фильтрацией
|
|
61
61
|
*
|
|
@@ -448,7 +448,7 @@ class K {
|
|
|
448
448
|
this.clear();
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
const
|
|
451
|
+
const w = {
|
|
452
452
|
/** FieldNode.watch() */
|
|
453
453
|
Watch: "watch",
|
|
454
454
|
/** FieldNode.computeFrom() */
|
|
@@ -462,144 +462,11 @@ const O = {
|
|
|
462
462
|
/** ArrayNode.watchLength() */
|
|
463
463
|
WatchLength: "watchLength"
|
|
464
464
|
};
|
|
465
|
-
let
|
|
466
|
-
function
|
|
467
|
-
return `${s}-${++
|
|
465
|
+
let Ee = 0;
|
|
466
|
+
function k(s) {
|
|
467
|
+
return `${s}-${++Ee}`;
|
|
468
468
|
}
|
|
469
|
-
|
|
470
|
-
class k {
|
|
471
|
-
/**
|
|
472
|
-
* Обработать ошибку согласно заданной стратегии
|
|
473
|
-
*
|
|
474
|
-
* @param error Ошибка для обработки (Error | string | unknown)
|
|
475
|
-
* @param context Контекст ошибки для логирования (например, 'AsyncValidator', 'BehaviorRegistry')
|
|
476
|
-
* @param strategy Стратегия обработки (THROW | LOG | CONVERT)
|
|
477
|
-
* @returns ValidationError если strategy = CONVERT, undefined если strategy = LOG, никогда не возвращается если strategy = THROW
|
|
478
|
-
*
|
|
479
|
-
* @example
|
|
480
|
-
* ```typescript
|
|
481
|
-
* // THROW - пробросить ошибку
|
|
482
|
-
* try {
|
|
483
|
-
* riskyOperation();
|
|
484
|
-
* } catch (error) {
|
|
485
|
-
* FormErrorHandler.handle(error, 'RiskyOperation', ErrorStrategy.THROW);
|
|
486
|
-
* // Этот код никогда не выполнится
|
|
487
|
-
* }
|
|
488
|
-
*
|
|
489
|
-
* // LOG - залогировать и продолжить
|
|
490
|
-
* try {
|
|
491
|
-
* nonCriticalOperation();
|
|
492
|
-
* } catch (error) {
|
|
493
|
-
* FormErrorHandler.handle(error, 'NonCritical', ErrorStrategy.LOG);
|
|
494
|
-
* // Продолжаем выполнение
|
|
495
|
-
* }
|
|
496
|
-
*
|
|
497
|
-
* // CONVERT - конвертировать в ValidationError
|
|
498
|
-
* try {
|
|
499
|
-
* await validator(value);
|
|
500
|
-
* } catch (error) {
|
|
501
|
-
* const validationError = FormErrorHandler.handle(
|
|
502
|
-
* error,
|
|
503
|
-
* 'AsyncValidator',
|
|
504
|
-
* ErrorStrategy.CONVERT
|
|
505
|
-
* );
|
|
506
|
-
* return validationError;
|
|
507
|
-
* }
|
|
508
|
-
* ```
|
|
509
|
-
*/
|
|
510
|
-
static handle(e, t, i = "throw") {
|
|
511
|
-
const r = this.extractMessage(e);
|
|
512
|
-
switch (i) {
|
|
513
|
-
case "throw":
|
|
514
|
-
throw e;
|
|
515
|
-
case "log":
|
|
516
|
-
return;
|
|
517
|
-
case "convert":
|
|
518
|
-
return {
|
|
519
|
-
code: "validator_error",
|
|
520
|
-
message: r,
|
|
521
|
-
params: { field: t }
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Извлечь сообщение из ошибки
|
|
527
|
-
*
|
|
528
|
-
* Обрабатывает различные типы ошибок:
|
|
529
|
-
* - Error объекты → error.message
|
|
530
|
-
* - Строки → возвращает как есть
|
|
531
|
-
* - Объекты с message → извлекает message
|
|
532
|
-
* - Другое → String(error)
|
|
533
|
-
*
|
|
534
|
-
* @param error Ошибка для извлечения сообщения
|
|
535
|
-
* @returns Сообщение ошибки
|
|
536
|
-
* @private
|
|
537
|
-
*
|
|
538
|
-
* @example
|
|
539
|
-
* ```typescript
|
|
540
|
-
* FormErrorHandler.extractMessage(new Error('Test'));
|
|
541
|
-
* // 'Test'
|
|
542
|
-
*
|
|
543
|
-
* FormErrorHandler.extractMessage('String error');
|
|
544
|
-
* // 'String error'
|
|
545
|
-
*
|
|
546
|
-
* FormErrorHandler.extractMessage({ message: 'Object error' });
|
|
547
|
-
* // 'Object error'
|
|
548
|
-
*
|
|
549
|
-
* FormErrorHandler.extractMessage(null);
|
|
550
|
-
* // 'null'
|
|
551
|
-
* ```
|
|
552
|
-
*/
|
|
553
|
-
static extractMessage(e) {
|
|
554
|
-
return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e ? String(e.message) : String(e);
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Создать ValidationError с заданными параметрами
|
|
558
|
-
*
|
|
559
|
-
* Утилитная функция для создания ValidationError объектов
|
|
560
|
-
*
|
|
561
|
-
* @param code Код ошибки
|
|
562
|
-
* @param message Сообщение ошибки
|
|
563
|
-
* @param field Поле (опционально)
|
|
564
|
-
* @returns ValidationError объект
|
|
565
|
-
*
|
|
566
|
-
* @example
|
|
567
|
-
* ```typescript
|
|
568
|
-
* const error = FormErrorHandler.createValidationError(
|
|
569
|
-
* 'required',
|
|
570
|
-
* 'This field is required',
|
|
571
|
-
* 'email'
|
|
572
|
-
* );
|
|
573
|
-
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
574
|
-
* ```
|
|
575
|
-
*/
|
|
576
|
-
static createValidationError(e, t, i) {
|
|
577
|
-
return {
|
|
578
|
-
code: e,
|
|
579
|
-
message: t,
|
|
580
|
-
params: i ? { field: i } : void 0
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Проверить, является ли объект ValidationError
|
|
585
|
-
*
|
|
586
|
-
* Type guard для ValidationError
|
|
587
|
-
*
|
|
588
|
-
* @param value Значение для проверки
|
|
589
|
-
* @returns true если value является ValidationError
|
|
590
|
-
*
|
|
591
|
-
* @example
|
|
592
|
-
* ```typescript
|
|
593
|
-
* if (FormErrorHandler.isValidationError(result)) {
|
|
594
|
-
* console.log(result.code); // OK, типобезопасно
|
|
595
|
-
* }
|
|
596
|
-
* ```
|
|
597
|
-
*/
|
|
598
|
-
static isValidationError(e) {
|
|
599
|
-
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
class be {
|
|
469
|
+
class Ae {
|
|
603
470
|
/** Внутренний сигнал статуса */
|
|
604
471
|
_status;
|
|
605
472
|
/** Публичный read-only сигнал статуса */
|
|
@@ -616,7 +483,7 @@ class be {
|
|
|
616
483
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
617
484
|
*/
|
|
618
485
|
constructor(e = "valid") {
|
|
619
|
-
this._status = y(e), this.status =
|
|
486
|
+
this._status = y(e), this.status = f(() => this._status.value), this.valid = f(() => this._status.value === "valid"), this.invalid = f(() => this._status.value === "invalid"), this.pending = f(() => this._status.value === "pending"), this.disabled = f(() => this._status.value === "disabled");
|
|
620
487
|
}
|
|
621
488
|
/**
|
|
622
489
|
* Начать валидацию
|
|
@@ -649,7 +516,7 @@ class be {
|
|
|
649
516
|
* ```
|
|
650
517
|
*/
|
|
651
518
|
completeValidation(e) {
|
|
652
|
-
|
|
519
|
+
this._status.value !== "disabled" && (this._status.value = e ? "invalid" : "valid");
|
|
653
520
|
}
|
|
654
521
|
/**
|
|
655
522
|
* Установить ошибки напрямую (без перехода через pending)
|
|
@@ -744,7 +611,7 @@ class be {
|
|
|
744
611
|
return this._status.value !== "disabled";
|
|
745
612
|
}
|
|
746
613
|
}
|
|
747
|
-
class
|
|
614
|
+
class Se extends L {
|
|
748
615
|
// ============================================================================
|
|
749
616
|
// Приватные сигналы
|
|
750
617
|
// ============================================================================
|
|
@@ -752,7 +619,6 @@ class _e extends I {
|
|
|
752
619
|
_errors;
|
|
753
620
|
// _touched, _dirty наследуются от FormNode (protected)
|
|
754
621
|
// _status управляется через statusMachine
|
|
755
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
756
622
|
_componentProps;
|
|
757
623
|
/**
|
|
758
624
|
* State machine для управления статусом поля
|
|
@@ -772,7 +638,6 @@ class _e extends I {
|
|
|
772
638
|
disabled;
|
|
773
639
|
// touched, dirty наследуются от FormNode
|
|
774
640
|
errors;
|
|
775
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
776
641
|
componentProps;
|
|
777
642
|
/**
|
|
778
643
|
* Вычисляемое свойство: нужно ли показывать ошибку
|
|
@@ -804,7 +669,7 @@ class _e extends I {
|
|
|
804
669
|
// Конструктор
|
|
805
670
|
// ============================================================================
|
|
806
671
|
constructor(e) {
|
|
807
|
-
super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? y(e.value), this.initialValue = this._value.peek(), this._errors = y([]), this._componentProps = y(e.componentProps || {}), this.statusMachine = new
|
|
672
|
+
super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? y(e.value), this.initialValue = this._value.peek(), this._errors = y([]), this._componentProps = y(e.componentProps || {}), this.statusMachine = new Ae(e.disabled ? "disabled" : "valid"), this.value = f(() => this._value.value), this.valid = f(() => this.statusMachine.valid.value), this.invalid = f(() => this.statusMachine.invalid.value), this.pending = f(() => this.statusMachine.pending.value), this.status = f(() => this.statusMachine.status.value), this.disabled = f(() => this.statusMachine.disabled.value), this.errors = f(() => this._errors.value), this.componentProps = f(() => this._componentProps.value), this.shouldShowError = f(
|
|
808
673
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
809
674
|
);
|
|
810
675
|
}
|
|
@@ -949,14 +814,14 @@ class _e extends I {
|
|
|
949
814
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
950
815
|
const { signal: i } = t, r = [];
|
|
951
816
|
for (const a of this.validators) {
|
|
952
|
-
const
|
|
953
|
-
|
|
817
|
+
const l = a(this._value.value);
|
|
818
|
+
l && r.push(l);
|
|
954
819
|
}
|
|
955
820
|
if (i.aborted)
|
|
956
821
|
return !1;
|
|
957
822
|
if (r.length > 0) {
|
|
958
823
|
this._errors.value = r;
|
|
959
|
-
const a = r.some((
|
|
824
|
+
const a = r.some((l) => l.severity !== "warning");
|
|
960
825
|
if (this.statusMachine.setErrors(a), a)
|
|
961
826
|
return !1;
|
|
962
827
|
}
|
|
@@ -966,32 +831,32 @@ class _e extends I {
|
|
|
966
831
|
this.statusMachine.startValidation();
|
|
967
832
|
try {
|
|
968
833
|
const a = await Promise.all(
|
|
969
|
-
this.asyncValidators.map(async (
|
|
834
|
+
this.asyncValidators.map(async (c) => {
|
|
970
835
|
if (i.aborted)
|
|
971
836
|
throw new DOMException("Validation aborted", "AbortError");
|
|
972
837
|
try {
|
|
973
|
-
const u = await
|
|
838
|
+
const u = await c(this._value.value, { signal: i });
|
|
974
839
|
if (i.aborted)
|
|
975
840
|
throw new DOMException("Validation aborted", "AbortError");
|
|
976
841
|
return u;
|
|
977
842
|
} catch (u) {
|
|
978
843
|
if (u instanceof DOMException && u.name === "AbortError")
|
|
979
844
|
throw u;
|
|
980
|
-
return
|
|
845
|
+
return N.handle(
|
|
981
846
|
u,
|
|
982
847
|
"FieldNode AsyncValidator",
|
|
983
|
-
|
|
848
|
+
O.CONVERT
|
|
984
849
|
);
|
|
985
850
|
}
|
|
986
851
|
})
|
|
987
852
|
);
|
|
988
853
|
if (i.aborted)
|
|
989
854
|
return !1;
|
|
990
|
-
const
|
|
991
|
-
if (
|
|
992
|
-
this._errors.value =
|
|
993
|
-
const
|
|
994
|
-
if (this.statusMachine.completeValidation(
|
|
855
|
+
const l = a.filter((c) => c !== null);
|
|
856
|
+
if (l.length > 0) {
|
|
857
|
+
this._errors.value = l;
|
|
858
|
+
const c = l.some((u) => u.severity !== "warning");
|
|
859
|
+
if (this.statusMachine.completeValidation(c), c)
|
|
995
860
|
return !1;
|
|
996
861
|
}
|
|
997
862
|
} catch (a) {
|
|
@@ -1048,7 +913,6 @@ class _e extends I {
|
|
|
1048
913
|
* });
|
|
1049
914
|
* ```
|
|
1050
915
|
*/
|
|
1051
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1052
916
|
updateComponentProps(e) {
|
|
1053
917
|
this._componentProps.value = {
|
|
1054
918
|
...this._componentProps.value,
|
|
@@ -1125,7 +989,7 @@ class _e extends I {
|
|
|
1125
989
|
const t = new AbortController(), i = _(() => {
|
|
1126
990
|
const n = this.value.value;
|
|
1127
991
|
e(n, t.signal);
|
|
1128
|
-
}), r =
|
|
992
|
+
}), r = k(w.Watch);
|
|
1129
993
|
return this.disposers.add(r, () => {
|
|
1130
994
|
t.abort(), i();
|
|
1131
995
|
});
|
|
@@ -1154,9 +1018,9 @@ class _e extends I {
|
|
|
1154
1018
|
*/
|
|
1155
1019
|
computeFrom(e, t) {
|
|
1156
1020
|
const i = _(() => {
|
|
1157
|
-
const n = e.map((
|
|
1021
|
+
const n = e.map((l) => l.value), a = t(...n);
|
|
1158
1022
|
this.setValue(a, { emitEvent: !1 });
|
|
1159
|
-
}), r =
|
|
1023
|
+
}), r = k(w.ComputeFrom);
|
|
1160
1024
|
return this.disposers.add(r, i);
|
|
1161
1025
|
}
|
|
1162
1026
|
/**
|
|
@@ -1188,45 +1052,58 @@ class _e extends I {
|
|
|
1188
1052
|
}
|
|
1189
1053
|
}
|
|
1190
1054
|
function H(s) {
|
|
1191
|
-
const { getChildren: e, ownErrors: t, disabled: i } = s, r =
|
|
1192
|
-
const
|
|
1193
|
-
for (const
|
|
1194
|
-
|
|
1195
|
-
return
|
|
1196
|
-
}),
|
|
1055
|
+
const { getChildren: e, ownErrors: t, disabled: i } = s, r = f(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = f(() => !r.value), a = f(() => e().some((o) => o.pending.value)), l = f(() => e().some((o) => o.touched.value)), c = f(() => e().some((o) => o.dirty.value)), u = f(() => {
|
|
1056
|
+
const o = [...t.value];
|
|
1057
|
+
for (const v of e())
|
|
1058
|
+
o.push(...v.errors.value);
|
|
1059
|
+
return o;
|
|
1060
|
+
}), d = f(() => i?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
1197
1061
|
return {
|
|
1198
1062
|
valid: r,
|
|
1199
1063
|
invalid: n,
|
|
1200
1064
|
pending: a,
|
|
1201
|
-
touched:
|
|
1202
|
-
dirty:
|
|
1065
|
+
touched: l,
|
|
1066
|
+
dirty: c,
|
|
1203
1067
|
errors: u,
|
|
1204
|
-
status:
|
|
1068
|
+
status: d
|
|
1205
1069
|
};
|
|
1206
1070
|
}
|
|
1207
|
-
function
|
|
1071
|
+
function Z(s) {
|
|
1208
1072
|
return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
|
|
1209
1073
|
}
|
|
1210
|
-
|
|
1074
|
+
const ee = "$";
|
|
1075
|
+
function we(s, e) {
|
|
1076
|
+
let t;
|
|
1077
|
+
const i = () => {
|
|
1078
|
+
if (!t) {
|
|
1079
|
+
const r = {};
|
|
1080
|
+
e.forEach((n, a) => {
|
|
1081
|
+
r[a] = n && Z(n) ? n.getProxy() : n;
|
|
1082
|
+
}), t = r;
|
|
1083
|
+
}
|
|
1084
|
+
return t;
|
|
1085
|
+
};
|
|
1211
1086
|
return new Proxy(s, {
|
|
1212
|
-
get: (
|
|
1213
|
-
if (
|
|
1214
|
-
return
|
|
1215
|
-
if (
|
|
1216
|
-
|
|
1217
|
-
|
|
1087
|
+
get: (r, n) => {
|
|
1088
|
+
if (n === ee)
|
|
1089
|
+
return i();
|
|
1090
|
+
if (n in r)
|
|
1091
|
+
return r[n];
|
|
1092
|
+
if (typeof n == "string" && e.has(n)) {
|
|
1093
|
+
const a = e.get(n);
|
|
1094
|
+
return a && Z(a) ? a.getProxy() : a;
|
|
1218
1095
|
}
|
|
1219
1096
|
},
|
|
1220
|
-
set: (
|
|
1221
|
-
has: (
|
|
1222
|
-
ownKeys: (
|
|
1223
|
-
const
|
|
1224
|
-
return [.../* @__PURE__ */ new Set([...
|
|
1097
|
+
set: (r, n, a) => typeof n == "string" && e.has(n) ? !1 : (r[n] = a, !0),
|
|
1098
|
+
has: (r, n) => n === ee || typeof n == "string" && e.has(n) ? !0 : n in r,
|
|
1099
|
+
ownKeys: (r) => {
|
|
1100
|
+
const n = Reflect.ownKeys(r), a = Array.from(e.keys());
|
|
1101
|
+
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
1225
1102
|
},
|
|
1226
|
-
getOwnPropertyDescriptor: (
|
|
1103
|
+
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(r, n)
|
|
1227
1104
|
});
|
|
1228
1105
|
}
|
|
1229
|
-
class
|
|
1106
|
+
class ke {
|
|
1230
1107
|
/**
|
|
1231
1108
|
* @param form - Форма для отправки
|
|
1232
1109
|
*/
|
|
@@ -1236,7 +1113,7 @@ class Se {
|
|
|
1236
1113
|
/** Внутренний сигнал состояния отправки */
|
|
1237
1114
|
_submitting = y(!1);
|
|
1238
1115
|
/** Публичный read-only сигнал состояния отправки */
|
|
1239
|
-
submitting =
|
|
1116
|
+
submitting = f(() => this._submitting.value);
|
|
1240
1117
|
/**
|
|
1241
1118
|
* Отправить форму
|
|
1242
1119
|
*
|
|
@@ -1248,7 +1125,12 @@ class Se {
|
|
|
1248
1125
|
*
|
|
1249
1126
|
* @param onSubmit - Callback для отправки данных
|
|
1250
1127
|
* @param options - Опции submit
|
|
1251
|
-
* @returns Результат от onSubmit или null если валидация не пройдена
|
|
1128
|
+
* @returns Результат от onSubmit или `null` если валидация не пройдена
|
|
1129
|
+
*
|
|
1130
|
+
* @remarks
|
|
1131
|
+
* Возвращаемый `null` неоднозначен: он сигналит и провал валидации, и легитимный `null`,
|
|
1132
|
+
* который вернул `onSubmit` (или void-обработчик). Чтобы различать эти случаи, используйте
|
|
1133
|
+
* {@link submitWithResult} — он отдаёт явный флаг `success`.
|
|
1252
1134
|
*
|
|
1253
1135
|
* @example
|
|
1254
1136
|
* ```typescript
|
|
@@ -1324,7 +1206,7 @@ class Se {
|
|
|
1324
1206
|
return this._submitting.value;
|
|
1325
1207
|
}
|
|
1326
1208
|
}
|
|
1327
|
-
function
|
|
1209
|
+
function Ve(s) {
|
|
1328
1210
|
const e = [];
|
|
1329
1211
|
for (const t of s.split(".")) {
|
|
1330
1212
|
const i = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
@@ -1333,7 +1215,7 @@ function we(s) {
|
|
|
1333
1215
|
}
|
|
1334
1216
|
return e;
|
|
1335
1217
|
}
|
|
1336
|
-
let
|
|
1218
|
+
let P = class ue extends L {
|
|
1337
1219
|
// ============================================================================
|
|
1338
1220
|
// Приватные поля
|
|
1339
1221
|
// ============================================================================
|
|
@@ -1358,7 +1240,7 @@ let x = class ne extends I {
|
|
|
1358
1240
|
/**
|
|
1359
1241
|
* Фабрика для создания узлов формы
|
|
1360
1242
|
*/
|
|
1361
|
-
nodeFactory = new
|
|
1243
|
+
nodeFactory = new Ne();
|
|
1362
1244
|
// ============================================================================
|
|
1363
1245
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1364
1246
|
// ============================================================================
|
|
@@ -1369,6 +1251,19 @@ let x = class ne extends I {
|
|
|
1369
1251
|
_disabled = y(!1);
|
|
1370
1252
|
/** Form-level validation errors */
|
|
1371
1253
|
_formErrors = y([]);
|
|
1254
|
+
/**
|
|
1255
|
+
* M1: валидация уровня модели/схемы (`validateFormModel(model, schema)`). Привязывается
|
|
1256
|
+
* `createForm({ model, schema })`, т.к. под M1 валидаторы срезаны с FieldNode и живут на слое
|
|
1257
|
+
* модели. Без неё `validate()`/`submit()` пропускали бы все schema-валидаторы. @internal
|
|
1258
|
+
*/
|
|
1259
|
+
_modelValidate;
|
|
1260
|
+
/**
|
|
1261
|
+
* M1: связь листовой ноды-ребёнка → её сигнал модели (тот, что помечает `markDerived`).
|
|
1262
|
+
* Нужна bulk-сеттерам (`setValue`/`patchValue`), чтобы корректно определять derived-поля:
|
|
1263
|
+
* `field.value` — computed-обёртка, отличная от записываемого сигнала модели. @internal
|
|
1264
|
+
*/
|
|
1265
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1266
|
+
_fieldSignals = /* @__PURE__ */ new WeakMap();
|
|
1372
1267
|
// ============================================================================
|
|
1373
1268
|
// Публичные computed signals
|
|
1374
1269
|
// ============================================================================
|
|
@@ -1382,24 +1277,24 @@ let x = class ne extends I {
|
|
|
1382
1277
|
status;
|
|
1383
1278
|
submitting;
|
|
1384
1279
|
constructor(e) {
|
|
1385
|
-
super(), this.formSubmitter = new
|
|
1386
|
-
const i = "form" in e ? e.form : e;
|
|
1387
|
-
for (const [
|
|
1388
|
-
const
|
|
1389
|
-
this._fields.set(
|
|
1280
|
+
super(), this.formSubmitter = new ke(this);
|
|
1281
|
+
const t = e.form, i = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !i ? e.form : e;
|
|
1282
|
+
for (const [l, c] of Object.entries(n)) {
|
|
1283
|
+
const u = this.createNode(c);
|
|
1284
|
+
this._fields.set(l, u);
|
|
1390
1285
|
}
|
|
1391
|
-
this.value =
|
|
1392
|
-
const
|
|
1393
|
-
return this._fields.forEach((
|
|
1394
|
-
|
|
1395
|
-
}),
|
|
1286
|
+
this.value = f(() => {
|
|
1287
|
+
const l = {};
|
|
1288
|
+
return this._fields.forEach((c, u) => {
|
|
1289
|
+
l[u] = c.value.value;
|
|
1290
|
+
}), l;
|
|
1396
1291
|
});
|
|
1397
|
-
const
|
|
1292
|
+
const a = H({
|
|
1398
1293
|
getChildren: () => Array.from(this._fields.values()),
|
|
1399
1294
|
ownErrors: this._formErrors,
|
|
1400
1295
|
disabled: this._disabled
|
|
1401
1296
|
});
|
|
1402
|
-
this.valid =
|
|
1297
|
+
this.valid = a.valid, this.invalid = a.invalid, this.pending = a.pending, this.touched = a.touched, this.dirty = a.dirty, this.errors = a.errors, this.status = a.status, this.submitting = this.formSubmitter.submitting;
|
|
1403
1298
|
}
|
|
1404
1299
|
// ============================================================================
|
|
1405
1300
|
// Приватный метод для создания Proxy
|
|
@@ -1409,7 +1304,7 @@ let x = class ne extends I {
|
|
|
1409
1304
|
* @see buildFormProxy
|
|
1410
1305
|
*/
|
|
1411
1306
|
buildProxy() {
|
|
1412
|
-
return
|
|
1307
|
+
return we(this, this._fields);
|
|
1413
1308
|
}
|
|
1414
1309
|
// ============================================================================
|
|
1415
1310
|
// Реализация абстрактных методов FormNode
|
|
@@ -1424,17 +1319,19 @@ let x = class ne extends I {
|
|
|
1424
1319
|
for (const [i, r] of Object.entries(e)) {
|
|
1425
1320
|
const n = this._fields.get(i);
|
|
1426
1321
|
if (n) {
|
|
1427
|
-
|
|
1322
|
+
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1323
|
+
if (G(a)) continue;
|
|
1428
1324
|
n.setValue(r, t);
|
|
1429
1325
|
}
|
|
1430
1326
|
}
|
|
1431
1327
|
}
|
|
1432
1328
|
patchValue(e) {
|
|
1433
|
-
|
|
1329
|
+
be(() => {
|
|
1434
1330
|
for (const [t, i] of Object.entries(e)) {
|
|
1435
1331
|
const r = this._fields.get(t);
|
|
1436
1332
|
if (r && i !== void 0) {
|
|
1437
|
-
|
|
1333
|
+
const n = this._fieldSignals.get(r) ?? r.value;
|
|
1334
|
+
if (G(n)) continue;
|
|
1438
1335
|
r.setValue(i, { emitEvent: !1 });
|
|
1439
1336
|
}
|
|
1440
1337
|
}
|
|
@@ -1458,7 +1355,7 @@ let x = class ne extends I {
|
|
|
1458
1355
|
* ```
|
|
1459
1356
|
*/
|
|
1460
1357
|
reset(e) {
|
|
1461
|
-
this._fields.forEach((t, i) => {
|
|
1358
|
+
this._formErrors.value = [], this._fields.forEach((t, i) => {
|
|
1462
1359
|
const r = e?.[i];
|
|
1463
1360
|
t.reset(r);
|
|
1464
1361
|
});
|
|
@@ -1467,14 +1364,16 @@ let x = class ne extends I {
|
|
|
1467
1364
|
* Сбросить форму к исходным значениям (initialValues)
|
|
1468
1365
|
*/
|
|
1469
1366
|
resetToInitial() {
|
|
1470
|
-
this._fields.forEach((e) => {
|
|
1367
|
+
this._formErrors.value = [], this._fields.forEach((e) => {
|
|
1471
1368
|
"resetToInitial" in e && typeof e.resetToInitial == "function" ? e.resetToInitial() : e.reset();
|
|
1472
1369
|
});
|
|
1473
1370
|
}
|
|
1474
1371
|
async validate() {
|
|
1475
|
-
|
|
1476
|
-
|
|
1372
|
+
this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((i) => i.validate()));
|
|
1373
|
+
const e = this._modelValidate ? await this._modelValidate() : !0, t = Array.from(this._fields.values()).every(
|
|
1374
|
+
(i) => i.valid.value || i.disabled.value
|
|
1477
1375
|
);
|
|
1376
|
+
return e && t;
|
|
1478
1377
|
}
|
|
1479
1378
|
/**
|
|
1480
1379
|
* Установить form-level validation errors
|
|
@@ -1556,7 +1455,12 @@ let x = class ne extends I {
|
|
|
1556
1455
|
*
|
|
1557
1456
|
* @param onSubmit - Callback для отправки данных
|
|
1558
1457
|
* @param options - Опции submit (skipValidation, skipTouch)
|
|
1559
|
-
* @returns Результат от onSubmit или null если валидация не пройдена
|
|
1458
|
+
* @returns Результат от onSubmit или `null` если валидация не пройдена
|
|
1459
|
+
*
|
|
1460
|
+
* @remarks
|
|
1461
|
+
* `null` перегружен: он означает и «валидация не пройдена», и легитимный `null`-результат
|
|
1462
|
+
* `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
|
|
1463
|
+
* используйте {@link submitWithResult}, который возвращает явный флаг `success`.
|
|
1560
1464
|
*/
|
|
1561
1465
|
async submit(e, t) {
|
|
1562
1466
|
return this.formSubmitter.submit(e, t);
|
|
@@ -1603,12 +1507,12 @@ let x = class ne extends I {
|
|
|
1603
1507
|
getFieldByPath(e) {
|
|
1604
1508
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1605
1509
|
return;
|
|
1606
|
-
const t =
|
|
1510
|
+
const t = Ve(e);
|
|
1607
1511
|
if (t.length === 0)
|
|
1608
1512
|
return;
|
|
1609
1513
|
let i = this;
|
|
1610
1514
|
for (const r of t) {
|
|
1611
|
-
if (!(i instanceof
|
|
1515
|
+
if (!(i instanceof ue) || (i = i.getField(r.key), !i)) return;
|
|
1612
1516
|
if (r.index !== void 0)
|
|
1613
1517
|
if ("at" in i && "length" in i && typeof i.at == "function") {
|
|
1614
1518
|
const n = i.at(r.index);
|
|
@@ -1649,14 +1553,14 @@ let x = class ne extends I {
|
|
|
1649
1553
|
linkFields(e, t, i) {
|
|
1650
1554
|
const r = this._fields.get(e), n = this._fields.get(t);
|
|
1651
1555
|
if (!r || !n) {
|
|
1652
|
-
const
|
|
1653
|
-
throw new Error(`GroupNode.linkFields: field "${String(
|
|
1556
|
+
const c = r ? t : e;
|
|
1557
|
+
throw new Error(`GroupNode.linkFields: field "${String(c)}" not found`);
|
|
1654
1558
|
}
|
|
1655
1559
|
const a = _(() => {
|
|
1656
|
-
const
|
|
1560
|
+
const c = r.value.value, u = i ? i(c) : c;
|
|
1657
1561
|
n.setValue(u, { emitEvent: !1 });
|
|
1658
|
-
}),
|
|
1659
|
-
return this.disposers.add(
|
|
1562
|
+
}), l = k(w.LinkFields);
|
|
1563
|
+
return this.disposers.add(l, a);
|
|
1660
1564
|
}
|
|
1661
1565
|
/**
|
|
1662
1566
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1685,14 +1589,27 @@ let x = class ne extends I {
|
|
|
1685
1589
|
* useEffect(() => dispose, []);
|
|
1686
1590
|
* ```
|
|
1687
1591
|
*/
|
|
1592
|
+
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1688
1593
|
watchField(e, t) {
|
|
1689
1594
|
const i = this.getFieldByPath(e);
|
|
1690
1595
|
if (!i)
|
|
1691
1596
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1692
1597
|
const r = _(() => {
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1598
|
+
t(i.value.value);
|
|
1599
|
+
}), n = k(w.WatchField);
|
|
1600
|
+
return this.disposers.add(n, r);
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
1604
|
+
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1605
|
+
*/
|
|
1606
|
+
watchFieldByPath(e, t) {
|
|
1607
|
+
const i = this.getFieldByPath(e);
|
|
1608
|
+
if (!i)
|
|
1609
|
+
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1610
|
+
const r = _(() => {
|
|
1611
|
+
t(i.value.value);
|
|
1612
|
+
}), n = k(w.WatchField);
|
|
1696
1613
|
return this.disposers.add(n, r);
|
|
1697
1614
|
}
|
|
1698
1615
|
/**
|
|
@@ -1714,6 +1631,24 @@ let x = class ne extends I {
|
|
|
1714
1631
|
attachBehaviorCleanup(e) {
|
|
1715
1632
|
this._behaviorCleanup = e;
|
|
1716
1633
|
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Прикрепить валидацию уровня модели/схемы (M1). Вызывается `createForm({ model, schema })`,
|
|
1636
|
+
* чтобы `validate()`/`submit()` прогоняли schema-валидаторы (`validateFormModel`), а не только
|
|
1637
|
+
* пустые FieldNode. Возвращаемый флаг — валидна ли модель по схеме.
|
|
1638
|
+
* @internal
|
|
1639
|
+
*/
|
|
1640
|
+
attachModelValidator(e) {
|
|
1641
|
+
this._modelValidate = e;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Связать листовую ноду-ребёнка с её сигналом модели (M1). Вызывается `createForm` для каждого
|
|
1645
|
+
* листового поля на его владеющей группе — используется bulk-сеттерами для derived-guard (F9).
|
|
1646
|
+
* @internal
|
|
1647
|
+
*/
|
|
1648
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1649
|
+
registerFieldSignal(e, t) {
|
|
1650
|
+
this._fieldSignals.set(e, t);
|
|
1651
|
+
}
|
|
1717
1652
|
/**
|
|
1718
1653
|
* Очистить все ресурсы узла
|
|
1719
1654
|
*/
|
|
@@ -1722,7 +1657,7 @@ let x = class ne extends I {
|
|
|
1722
1657
|
"dispose" in e && typeof e.dispose == "function" && e.dispose();
|
|
1723
1658
|
});
|
|
1724
1659
|
}
|
|
1725
|
-
},
|
|
1660
|
+
}, te = class extends L {
|
|
1726
1661
|
// ============================================================================
|
|
1727
1662
|
// Приватные поля
|
|
1728
1663
|
// ============================================================================
|
|
@@ -1760,7 +1695,7 @@ let x = class ne extends I {
|
|
|
1760
1695
|
super(), this.itemSchema = e, this.initialItems = t, this.items = y([]);
|
|
1761
1696
|
for (const r of t)
|
|
1762
1697
|
this.push(r);
|
|
1763
|
-
this.length =
|
|
1698
|
+
this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((r) => r.value.value));
|
|
1764
1699
|
const i = H({
|
|
1765
1700
|
getChildren: () => this.items.value,
|
|
1766
1701
|
ownErrors: this._arrayErrors
|
|
@@ -1787,12 +1722,12 @@ let x = class ne extends I {
|
|
|
1787
1722
|
*/
|
|
1788
1723
|
removeAt(e) {
|
|
1789
1724
|
if (e < 0 || e >= this.items.value.length) {
|
|
1790
|
-
|
|
1725
|
+
N.handle(
|
|
1791
1726
|
new Error(
|
|
1792
1727
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1793
1728
|
),
|
|
1794
1729
|
"ArrayNode.removeAt",
|
|
1795
|
-
|
|
1730
|
+
O.LOG
|
|
1796
1731
|
);
|
|
1797
1732
|
return;
|
|
1798
1733
|
}
|
|
@@ -1806,12 +1741,12 @@ let x = class ne extends I {
|
|
|
1806
1741
|
*/
|
|
1807
1742
|
insert(e, t) {
|
|
1808
1743
|
if (e < 0 || e > this.items.value.length) {
|
|
1809
|
-
|
|
1744
|
+
N.handle(
|
|
1810
1745
|
new Error(
|
|
1811
1746
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1812
1747
|
),
|
|
1813
1748
|
"ArrayNode.insert",
|
|
1814
|
-
|
|
1749
|
+
O.LOG
|
|
1815
1750
|
);
|
|
1816
1751
|
return;
|
|
1817
1752
|
}
|
|
@@ -1837,10 +1772,10 @@ let x = class ne extends I {
|
|
|
1837
1772
|
move(e, t) {
|
|
1838
1773
|
const i = this.items.value.length;
|
|
1839
1774
|
if (e < 0 || e >= i || t < 0 || t >= i) {
|
|
1840
|
-
|
|
1775
|
+
N.handle(
|
|
1841
1776
|
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${i})`),
|
|
1842
1777
|
"ArrayNode.move",
|
|
1843
|
-
|
|
1778
|
+
O.LOG
|
|
1844
1779
|
);
|
|
1845
1780
|
return;
|
|
1846
1781
|
}
|
|
@@ -1865,10 +1800,10 @@ let x = class ne extends I {
|
|
|
1865
1800
|
swap(e, t) {
|
|
1866
1801
|
const i = this.items.value.length;
|
|
1867
1802
|
if (e < 0 || e >= i || t < 0 || t >= i) {
|
|
1868
|
-
|
|
1803
|
+
N.handle(
|
|
1869
1804
|
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${i})`),
|
|
1870
1805
|
"ArrayNode.swap",
|
|
1871
|
-
|
|
1806
|
+
O.LOG
|
|
1872
1807
|
);
|
|
1873
1808
|
return;
|
|
1874
1809
|
}
|
|
@@ -1906,7 +1841,7 @@ let x = class ne extends I {
|
|
|
1906
1841
|
}
|
|
1907
1842
|
setValue(e, t) {
|
|
1908
1843
|
this.clear(), e.forEach((i) => this.push(i)), t?.emitEvent !== !1 && this.validate().catch((i) => {
|
|
1909
|
-
|
|
1844
|
+
N.handle(i, "ArrayNode.setValue", O.LOG);
|
|
1910
1845
|
});
|
|
1911
1846
|
}
|
|
1912
1847
|
patchValue(e) {
|
|
@@ -1966,7 +1901,7 @@ let x = class ne extends I {
|
|
|
1966
1901
|
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1967
1902
|
}
|
|
1968
1903
|
async validate() {
|
|
1969
|
-
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean);
|
|
1904
|
+
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean) && this._arrayErrors.value.length === 0;
|
|
1970
1905
|
}
|
|
1971
1906
|
/**
|
|
1972
1907
|
* Установить array-level validation errors
|
|
@@ -2064,7 +1999,7 @@ let x = class ne extends I {
|
|
|
2064
1999
|
*/
|
|
2065
2000
|
createItem(e) {
|
|
2066
2001
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2067
|
-
const t = new
|
|
2002
|
+
const t = new P(this.itemSchema);
|
|
2068
2003
|
return e && t.patchValue(e), this.validationSchemaFn && "applyValidationSchema" in t && t.applyValidationSchema(this.validationSchemaFn), this.behaviorSchemaFn && "applyBehaviorSchema" in t && t.applyBehaviorSchema(this.behaviorSchemaFn), t;
|
|
2069
2004
|
}
|
|
2070
2005
|
throw new Error(
|
|
@@ -2153,11 +2088,11 @@ let x = class ne extends I {
|
|
|
2153
2088
|
watchItems(e, t) {
|
|
2154
2089
|
const i = _(() => {
|
|
2155
2090
|
const n = this.items.value.map((a) => {
|
|
2156
|
-
if (a instanceof
|
|
2091
|
+
if (a instanceof P)
|
|
2157
2092
|
return a.getFieldByPath(e)?.value.value;
|
|
2158
2093
|
});
|
|
2159
2094
|
t(n);
|
|
2160
|
-
}), r =
|
|
2095
|
+
}), r = k(w.WatchItems);
|
|
2161
2096
|
return this.disposers.add(r, i);
|
|
2162
2097
|
}
|
|
2163
2098
|
/**
|
|
@@ -2186,7 +2121,7 @@ let x = class ne extends I {
|
|
|
2186
2121
|
const t = _(() => {
|
|
2187
2122
|
const r = this.length.value;
|
|
2188
2123
|
e(r);
|
|
2189
|
-
}), i =
|
|
2124
|
+
}), i = k(w.WatchLength);
|
|
2190
2125
|
return this.disposers.add(i, t);
|
|
2191
2126
|
}
|
|
2192
2127
|
/**
|
|
@@ -2250,7 +2185,7 @@ let x = class ne extends I {
|
|
|
2250
2185
|
});
|
|
2251
2186
|
}
|
|
2252
2187
|
};
|
|
2253
|
-
class
|
|
2188
|
+
class Ne {
|
|
2254
2189
|
/**
|
|
2255
2190
|
* Создает узел формы на основе конфигурации
|
|
2256
2191
|
*
|
|
@@ -2300,16 +2235,14 @@ class ke {
|
|
|
2300
2235
|
if (Array.isArray(e) && e.length >= 1)
|
|
2301
2236
|
return this.createArrayNodeFromArray(e);
|
|
2302
2237
|
if (this.isFieldConfig(e))
|
|
2303
|
-
return new
|
|
2304
|
-
if (this.isArrayConfig(e))
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
t.initialItems
|
|
2238
|
+
return new Se(e);
|
|
2239
|
+
if (this.isArrayConfig(e))
|
|
2240
|
+
return new te(
|
|
2241
|
+
e.schema,
|
|
2242
|
+
e.initialItems
|
|
2309
2243
|
);
|
|
2310
|
-
}
|
|
2311
2244
|
if (this.isGroupConfig(e))
|
|
2312
|
-
return new
|
|
2245
|
+
return new P(e);
|
|
2313
2246
|
throw new Error(
|
|
2314
2247
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2315
2248
|
e
|
|
@@ -2347,7 +2280,7 @@ class ke {
|
|
|
2347
2280
|
this.isGroupConfig(t) && r.push(this.extractValues(t));
|
|
2348
2281
|
for (const n of i)
|
|
2349
2282
|
this.isGroupConfig(n) ? r.push(this.extractValues(n)) : r.push(n);
|
|
2350
|
-
return new
|
|
2283
|
+
return new te(t, r);
|
|
2351
2284
|
}
|
|
2352
2285
|
/**
|
|
2353
2286
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2411,7 +2344,7 @@ class ke {
|
|
|
2411
2344
|
* ```
|
|
2412
2345
|
*/
|
|
2413
2346
|
isFieldConfig(e) {
|
|
2414
|
-
return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e
|
|
2347
|
+
return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e ? "component" in e || "componentProps" in e || "validators" in e || "asyncValidators" in e || "updateOn" in e || "debounce" in e : !1;
|
|
2415
2348
|
}
|
|
2416
2349
|
/**
|
|
2417
2350
|
* Проверяет, является ли конфиг конфигурацией массива (ArrayConfig)
|
|
@@ -2466,28 +2399,28 @@ class ke {
|
|
|
2466
2399
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2467
2400
|
}
|
|
2468
2401
|
}
|
|
2469
|
-
function
|
|
2402
|
+
function R(s) {
|
|
2470
2403
|
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2471
2404
|
}
|
|
2472
|
-
function
|
|
2473
|
-
return s == null ? !1 :
|
|
2405
|
+
function Oe(s) {
|
|
2406
|
+
return s == null ? !1 : R(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
|
|
2474
2407
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2475
2408
|
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2476
2409
|
!("fields" in s) && !("items" in s);
|
|
2477
2410
|
}
|
|
2478
|
-
function
|
|
2479
|
-
return s == null ? !1 :
|
|
2411
|
+
function Fe(s) {
|
|
2412
|
+
return s == null ? !1 : R(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2480
2413
|
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2481
2414
|
}
|
|
2482
|
-
function
|
|
2483
|
-
return s == null ? !1 :
|
|
2415
|
+
function Me(s) {
|
|
2416
|
+
return s == null ? !1 : R(s) && "items" in s && "length" in s && "push" in s && "removeAt" in s && "at" in s && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2484
2417
|
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2485
2418
|
typeof s.removeAt == "function";
|
|
2486
2419
|
}
|
|
2487
|
-
function
|
|
2488
|
-
return
|
|
2420
|
+
function Qe(s) {
|
|
2421
|
+
return Oe(s) ? "FieldNode" : Fe(s) ? "GroupNode" : Me(s) ? "ArrayNode" : R(s) ? "FormNode" : "Unknown";
|
|
2489
2422
|
}
|
|
2490
|
-
class
|
|
2423
|
+
class Pe extends L {
|
|
2491
2424
|
/**
|
|
2492
2425
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2493
2426
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
@@ -2495,15 +2428,21 @@ class Fe extends I {
|
|
|
2495
2428
|
*/
|
|
2496
2429
|
constructor(e, t) {
|
|
2497
2430
|
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = _(() => {
|
|
2498
|
-
const r = e.length, n = [];
|
|
2499
|
-
for (let
|
|
2500
|
-
const
|
|
2501
|
-
if (!
|
|
2502
|
-
let
|
|
2503
|
-
|
|
2431
|
+
const r = e.length, n = [], a = [];
|
|
2432
|
+
for (let u = 0; u < r; u++) {
|
|
2433
|
+
const d = e.at(u);
|
|
2434
|
+
if (!d) continue;
|
|
2435
|
+
let o = this.cache.get(d);
|
|
2436
|
+
o || (o = t(d), this.cache.set(d, o)), n.push(d), a.push(o);
|
|
2504
2437
|
}
|
|
2505
|
-
|
|
2506
|
-
|
|
2438
|
+
const l = new Set(n), c = [];
|
|
2439
|
+
for (const u of this.mountedModels) {
|
|
2440
|
+
if (l.has(u)) continue;
|
|
2441
|
+
const d = this.cache.get(u);
|
|
2442
|
+
this.cache.delete(u), d && c.push(d);
|
|
2443
|
+
}
|
|
2444
|
+
this.mountedModels = n, this.itemNodes.value = a, c.forEach((u) => this.disposeItemNode(u));
|
|
2445
|
+
}), this.length = f(() => this.itemNodes.value.length), this.value = f(() => this.itemNodes.value.map((r) => r.value.value));
|
|
2507
2446
|
const i = H({
|
|
2508
2447
|
getChildren: () => this.itemNodes.value,
|
|
2509
2448
|
ownErrors: this._arrayErrors
|
|
@@ -2513,6 +2452,9 @@ class Fe extends I {
|
|
|
2513
2452
|
itemNodes = y([]);
|
|
2514
2453
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
2515
2454
|
cache = /* @__PURE__ */ new WeakMap();
|
|
2455
|
+
// Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
|
|
2456
|
+
// реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
|
|
2457
|
+
mountedModels = [];
|
|
2516
2458
|
initial;
|
|
2517
2459
|
_arrayErrors = y([]);
|
|
2518
2460
|
disposeSync;
|
|
@@ -2598,21 +2540,132 @@ class Fe extends I {
|
|
|
2598
2540
|
);
|
|
2599
2541
|
}
|
|
2600
2542
|
// ── Hooks (forward к элементам) ────────────────────────────────────────────
|
|
2543
|
+
// Агрегатное состояние (touched/dirty/status) выводится из детей (createAggregateSignals), поэтому
|
|
2544
|
+
// базовые сигналы бесполезны для чтения — состояние меняется ТОЛЬКО через per-item формы. Форвардим
|
|
2545
|
+
// ВСЕ hook'и (как ArrayNode), иначе markAsUntouched/Pristine/Dirty/disable/enable молча no-op.
|
|
2601
2546
|
onMarkAsTouched() {
|
|
2602
2547
|
this.itemNodes.value.forEach(
|
|
2603
2548
|
(e) => e.markAsTouched?.()
|
|
2604
2549
|
);
|
|
2605
2550
|
}
|
|
2606
|
-
|
|
2551
|
+
onMarkAsUntouched() {
|
|
2552
|
+
this.itemNodes.value.forEach(
|
|
2553
|
+
(e) => e.markAsUntouched?.()
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2556
|
+
onMarkAsDirty() {
|
|
2557
|
+
this.itemNodes.value.forEach(
|
|
2558
|
+
(e) => e.markAsDirty?.()
|
|
2559
|
+
);
|
|
2560
|
+
}
|
|
2561
|
+
onMarkAsPristine() {
|
|
2562
|
+
this.itemNodes.value.forEach(
|
|
2563
|
+
(e) => e.markAsPristine?.()
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
onDisable() {
|
|
2567
|
+
this.itemNodes.value.forEach((e) => e.disable?.());
|
|
2568
|
+
}
|
|
2569
|
+
onEnable() {
|
|
2570
|
+
this.itemNodes.value.forEach((e) => e.enable?.());
|
|
2571
|
+
}
|
|
2572
|
+
/** Диспозит форму элемента (эффекты/поведения/вложенные подписки); терпима к не-GroupNode. */
|
|
2573
|
+
disposeItemNode(e) {
|
|
2574
|
+
e.dispose?.();
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Очистка подписки синхронизации И детерминированный teardown всех форм элементов.
|
|
2578
|
+
* Без пробрасывания dispose в itemNodes эффекты/поведения каждой формы элемента (в т.ч. disposeSync
|
|
2579
|
+
* вложенных ModelArrayNode) остались бы жить после teardown формы — утечка подписок.
|
|
2580
|
+
*/
|
|
2607
2581
|
dispose() {
|
|
2608
|
-
this.disposeSync();
|
|
2582
|
+
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2609
2583
|
}
|
|
2610
2584
|
}
|
|
2611
|
-
const
|
|
2612
|
-
|
|
2585
|
+
const xe = (s) => {
|
|
2586
|
+
const e = s.componentProps;
|
|
2587
|
+
return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
|
|
2588
|
+
}, Ce = (s) => typeof s.when == "function" && Array.isArray(s.children);
|
|
2589
|
+
function F(s, e, t, i, r) {
|
|
2613
2590
|
if (s == null || typeof s != "object") return;
|
|
2614
2591
|
if (Array.isArray(s)) {
|
|
2615
|
-
for (const
|
|
2592
|
+
for (const a of s) F(a, e, t, i, r);
|
|
2593
|
+
return;
|
|
2594
|
+
}
|
|
2595
|
+
const n = s;
|
|
2596
|
+
if (Ce(n)) {
|
|
2597
|
+
const a = i && !!n.when(e, t);
|
|
2598
|
+
for (const l of n.children) F(l, e, t, a, r);
|
|
2599
|
+
return;
|
|
2600
|
+
}
|
|
2601
|
+
if (xe(n)) {
|
|
2602
|
+
const a = n.componentProps.control, l = n.componentProps.itemComponent, c = a.length;
|
|
2603
|
+
for (let u = 0; u < c; u++) {
|
|
2604
|
+
const d = a.at(u);
|
|
2605
|
+
F(l(d), d, t, i, r);
|
|
2606
|
+
}
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
if (n.value instanceof oe) {
|
|
2610
|
+
const a = n.validators ?? [], l = n.asyncValidators ?? [], c = l.length ? [...a, ...l] : a;
|
|
2611
|
+
c.length > 0 && (i ? r.tasks.push({ signal: n.value, validators: c, scope: e }) : r.clearSignals.push(n.value));
|
|
2612
|
+
for (const [u, d] of Object.entries(n))
|
|
2613
|
+
u === "value" || u === "validators" || u === "asyncValidators" || F(d, e, t, i, r);
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
for (const a of Object.values(n)) F(a, e, t, i, r);
|
|
2617
|
+
}
|
|
2618
|
+
function z(s, e) {
|
|
2619
|
+
const t = { tasks: [], clearSignals: [] };
|
|
2620
|
+
return F(e, s, s, !0, t), t;
|
|
2621
|
+
}
|
|
2622
|
+
const ce = (s, e, t) => {
|
|
2623
|
+
(s[e] ??= []).push(t);
|
|
2624
|
+
}, J = (s) => {
|
|
2625
|
+
for (const e of Object.values(s))
|
|
2626
|
+
for (const t of e) if (t.severity !== "warning") return !0;
|
|
2627
|
+
return !1;
|
|
2628
|
+
};
|
|
2629
|
+
function Xe(s, e) {
|
|
2630
|
+
const { tasks: t } = z(s, e), i = {};
|
|
2631
|
+
for (const { signal: r, validators: n, scope: a } of t) {
|
|
2632
|
+
const l = r.peek();
|
|
2633
|
+
for (const c of n) {
|
|
2634
|
+
const u = c(l, a, s);
|
|
2635
|
+
u && typeof u.then == "function" || u && ce(i, r.__path, u);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
return { valid: !J(i), errors: i };
|
|
2639
|
+
}
|
|
2640
|
+
async function Ze(s, e) {
|
|
2641
|
+
const { tasks: t } = z(s, e), i = await he(t, s);
|
|
2642
|
+
return { valid: !J(i), errors: i };
|
|
2643
|
+
}
|
|
2644
|
+
async function he(s, e) {
|
|
2645
|
+
const t = {};
|
|
2646
|
+
return await Promise.all(
|
|
2647
|
+
s.map(async ({ signal: i, validators: r, scope: n }) => {
|
|
2648
|
+
const a = i.peek();
|
|
2649
|
+
for (const l of r) {
|
|
2650
|
+
const c = await l(a, n, e);
|
|
2651
|
+
c && ce(t, i.__path, c);
|
|
2652
|
+
}
|
|
2653
|
+
})
|
|
2654
|
+
), t;
|
|
2655
|
+
}
|
|
2656
|
+
async function Te(s, e) {
|
|
2657
|
+
const { tasks: t, clearSignals: i } = z(s, e), r = await he(t, s);
|
|
2658
|
+
for (const { signal: n } of t)
|
|
2659
|
+
X(n)?.setErrors(r[n.__path] ?? []);
|
|
2660
|
+
for (const n of i)
|
|
2661
|
+
X(n)?.setErrors([]);
|
|
2662
|
+
return { valid: !J(r), errors: r };
|
|
2663
|
+
}
|
|
2664
|
+
const de = (s) => s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(typeof Blob < "u" && s instanceof Blob) && !(typeof File < "u" && s instanceof File);
|
|
2665
|
+
function U(s, e, t) {
|
|
2666
|
+
if (s == null || typeof s != "object") return;
|
|
2667
|
+
if (Array.isArray(s)) {
|
|
2668
|
+
for (const n of s) U(n, e, t);
|
|
2616
2669
|
return;
|
|
2617
2670
|
}
|
|
2618
2671
|
const i = s, r = i.array;
|
|
@@ -2620,7 +2673,7 @@ function G(s, e, t) {
|
|
|
2620
2673
|
t.set(r.__path, i.item);
|
|
2621
2674
|
return;
|
|
2622
2675
|
}
|
|
2623
|
-
i.value instanceof
|
|
2676
|
+
i.value instanceof oe ? e.set(i.value, {
|
|
2624
2677
|
component: i.component,
|
|
2625
2678
|
componentProps: i.componentProps,
|
|
2626
2679
|
validators: i.validators,
|
|
@@ -2628,79 +2681,89 @@ function G(s, e, t) {
|
|
|
2628
2681
|
updateOn: i.updateOn,
|
|
2629
2682
|
disabled: i.disabled,
|
|
2630
2683
|
debounce: i.debounce
|
|
2631
|
-
})
|
|
2684
|
+
}) : process.env.NODE_ENV !== "production" && i.component !== void 0 && ("valueSignal" in i || i.value != null) && console.warn(
|
|
2685
|
+
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2686
|
+
);
|
|
2632
2687
|
for (const [n, a] of Object.entries(i))
|
|
2633
|
-
n !== "value" &&
|
|
2688
|
+
n !== "value" && U(a, e, t);
|
|
2634
2689
|
}
|
|
2635
|
-
function
|
|
2690
|
+
function fe(s, e, t, i) {
|
|
2636
2691
|
const r = {};
|
|
2637
2692
|
for (const [n, a] of Object.entries(e)) {
|
|
2638
|
-
const
|
|
2693
|
+
const l = t === "" ? n : `${t}.${n}`;
|
|
2639
2694
|
if (Array.isArray(a))
|
|
2640
2695
|
continue;
|
|
2641
|
-
if (
|
|
2642
|
-
r[n] =
|
|
2696
|
+
if (de(a)) {
|
|
2697
|
+
r[n] = fe(s, a, l, i);
|
|
2643
2698
|
continue;
|
|
2644
2699
|
}
|
|
2645
|
-
const
|
|
2646
|
-
if (!
|
|
2647
|
-
const u = i.get(
|
|
2648
|
-
r[n] = { ...
|
|
2700
|
+
const c = s.signalAt(l);
|
|
2701
|
+
if (!c) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2702
|
+
const u = i.get(c) ?? {}, { validators: d, asyncValidators: o, ...v } = u;
|
|
2703
|
+
r[n] = { ...v, valueSignal: c };
|
|
2649
2704
|
}
|
|
2650
2705
|
return r;
|
|
2651
2706
|
}
|
|
2652
|
-
function
|
|
2707
|
+
function pe(s, e, t) {
|
|
2653
2708
|
for (const [i, r] of Object.entries(s)) {
|
|
2654
2709
|
const n = e === "" ? i : `${e}.${i}`;
|
|
2655
|
-
Array.isArray(r) || (
|
|
2710
|
+
Array.isArray(r) || (de(r) ? pe(r, n, t) : t.push(n));
|
|
2656
2711
|
}
|
|
2657
2712
|
}
|
|
2658
|
-
function
|
|
2713
|
+
function ve(s) {
|
|
2659
2714
|
const { model: e, schema: t, behavior: i } = s, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2660
|
-
t !== void 0 &&
|
|
2661
|
-
const a =
|
|
2662
|
-
for (const [
|
|
2663
|
-
if (!Array.isArray(
|
|
2664
|
-
const
|
|
2665
|
-
if (!
|
|
2666
|
-
const p = e[
|
|
2667
|
-
|
|
2668
|
-
}
|
|
2669
|
-
const u =
|
|
2670
|
-
|
|
2671
|
-
for (const
|
|
2672
|
-
const
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2715
|
+
t !== void 0 && U(t, r, n);
|
|
2716
|
+
const a = fe(e, e.get(), "", r), l = new P(a), c = e.get();
|
|
2717
|
+
for (const [o, v] of Object.entries(c)) {
|
|
2718
|
+
if (!Array.isArray(v)) continue;
|
|
2719
|
+
const h = n.get(o);
|
|
2720
|
+
if (!h) continue;
|
|
2721
|
+
const p = e[o], m = (g) => ve({ model: g, schema: h(g) }), b = new Pe(p, m);
|
|
2722
|
+
l.fields.set(o, b);
|
|
2723
|
+
}
|
|
2724
|
+
const u = l.getProxy(), d = [];
|
|
2725
|
+
pe(e.get(), "", d);
|
|
2726
|
+
for (const o of d) {
|
|
2727
|
+
const v = e.signalAt(o), h = l.getFieldByPath(o);
|
|
2728
|
+
if (v && h) {
|
|
2729
|
+
_e(v, h);
|
|
2730
|
+
const p = o.lastIndexOf("."), m = p === -1 ? l : l.getFieldByPath(o.slice(0, p));
|
|
2731
|
+
m instanceof P && m.registerFieldSignal(h, v);
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
if (t !== void 0) {
|
|
2735
|
+
const o = t;
|
|
2736
|
+
l.attachModelValidator(async () => (await Te(e, o)).valid);
|
|
2737
|
+
}
|
|
2738
|
+
return i && l.attachBehaviorCleanup(i.__run(e, u)), u;
|
|
2676
2739
|
}
|
|
2677
|
-
const
|
|
2678
|
-
function
|
|
2679
|
-
return
|
|
2740
|
+
const Ie = (s) => s != null && typeof s == "object" && "model" in s && typeof s.model?.signalAt == "function";
|
|
2741
|
+
function et(s) {
|
|
2742
|
+
return Ie(s) ? ve(s) : new P(s).getProxy();
|
|
2680
2743
|
}
|
|
2681
|
-
const
|
|
2682
|
-
if (Array.isArray(s)) return s.map(
|
|
2683
|
-
if (
|
|
2744
|
+
const T = (s) => !(s === null || typeof s != "object" || Array.isArray(s) || s instanceof Date || typeof Blob < "u" && s instanceof Blob || typeof File < "u" && s instanceof File), A = (s, e) => s === "" ? String(e) : `${s}.${e}`, W = (s) => /^\d+$/.test(s), S = (s) => {
|
|
2745
|
+
if (Array.isArray(s)) return s.map(S);
|
|
2746
|
+
if (T(s)) {
|
|
2684
2747
|
const e = {};
|
|
2685
|
-
for (const t of Object.keys(s)) e[t] =
|
|
2748
|
+
for (const t of Object.keys(s)) e[t] = S(s[t]);
|
|
2686
2749
|
return e;
|
|
2687
2750
|
}
|
|
2688
2751
|
return s;
|
|
2689
|
-
},
|
|
2752
|
+
}, I = (s, e) => {
|
|
2690
2753
|
if (s === e) return !0;
|
|
2691
2754
|
if (Array.isArray(s) && Array.isArray(e))
|
|
2692
|
-
return s.length !== e.length ? !1 : s.every((t, i) =>
|
|
2693
|
-
if (
|
|
2755
|
+
return s.length !== e.length ? !1 : s.every((t, i) => I(t, e[i]));
|
|
2756
|
+
if (T(s) && T(e)) {
|
|
2694
2757
|
const t = Object.keys(s), i = Object.keys(e);
|
|
2695
|
-
return t.length !== i.length ? !1 : t.every((r) =>
|
|
2758
|
+
return t.length !== i.length ? !1 : t.every((r) => I(s[r], e[r]));
|
|
2696
2759
|
}
|
|
2697
2760
|
return !1;
|
|
2698
2761
|
};
|
|
2699
|
-
class
|
|
2762
|
+
class De {
|
|
2700
2763
|
constructor(e, t) {
|
|
2701
2764
|
this.path = t;
|
|
2702
2765
|
const i = y(e);
|
|
2703
|
-
i.__path = t, this.signal = i, this.initial =
|
|
2766
|
+
i.__path = t, this.signal = i, this.initial = S(e);
|
|
2704
2767
|
}
|
|
2705
2768
|
kind = "leaf";
|
|
2706
2769
|
signal;
|
|
@@ -2720,26 +2783,26 @@ class Me {
|
|
|
2720
2783
|
this.signal.value = e;
|
|
2721
2784
|
}
|
|
2722
2785
|
resetToInitial() {
|
|
2723
|
-
this.signal.value =
|
|
2786
|
+
this.signal.value = S(this.initial);
|
|
2724
2787
|
}
|
|
2725
2788
|
captureInitial() {
|
|
2726
|
-
this.initial =
|
|
2789
|
+
this.initial = S(this.signal.peek());
|
|
2727
2790
|
}
|
|
2728
2791
|
dirty() {
|
|
2729
|
-
return !
|
|
2792
|
+
return !I(this.signal.peek(), this.initial);
|
|
2730
2793
|
}
|
|
2731
2794
|
}
|
|
2732
|
-
class
|
|
2795
|
+
class me {
|
|
2733
2796
|
constructor(e, t) {
|
|
2734
2797
|
this.path = t;
|
|
2735
2798
|
for (const i of Object.keys(e))
|
|
2736
|
-
this.children.set(i,
|
|
2799
|
+
this.children.set(i, x(e[i], A(t, i)));
|
|
2737
2800
|
}
|
|
2738
2801
|
kind = "group";
|
|
2739
2802
|
children = /* @__PURE__ */ new Map();
|
|
2740
2803
|
rebase(e) {
|
|
2741
2804
|
this.path = e;
|
|
2742
|
-
for (const [t, i] of this.children) i.rebase(
|
|
2805
|
+
for (const [t, i] of this.children) i.rebase(A(e, t));
|
|
2743
2806
|
}
|
|
2744
2807
|
peek() {
|
|
2745
2808
|
const e = {};
|
|
@@ -2750,7 +2813,7 @@ class ce {
|
|
|
2750
2813
|
if (e == null || typeof e != "object") return;
|
|
2751
2814
|
const t = e;
|
|
2752
2815
|
for (const [i, r] of this.children)
|
|
2753
|
-
i in t && (r.kind === "leaf" &&
|
|
2816
|
+
i in t && (r.kind === "leaf" && G(r.signal) || r.set(t[i]));
|
|
2754
2817
|
}
|
|
2755
2818
|
resetToInitial() {
|
|
2756
2819
|
for (const e of this.children.values()) e.resetToInitial();
|
|
@@ -2763,26 +2826,26 @@ class ce {
|
|
|
2763
2826
|
return !1;
|
|
2764
2827
|
}
|
|
2765
2828
|
}
|
|
2766
|
-
class
|
|
2829
|
+
class Le {
|
|
2767
2830
|
constructor(e, t) {
|
|
2768
|
-
this.path = t, this.items = y(e.map((i, r) =>
|
|
2831
|
+
this.path = t, this.items = y(e.map((i, r) => x(i, A(t, r)))), this.initial = S(e);
|
|
2769
2832
|
}
|
|
2770
2833
|
kind = "array";
|
|
2771
2834
|
items;
|
|
2772
2835
|
initial;
|
|
2773
2836
|
rebase(e) {
|
|
2774
|
-
this.path = e, this.items.peek().forEach((t, i) => t.rebase(
|
|
2837
|
+
this.path = e, this.items.peek().forEach((t, i) => t.rebase(A(e, i)));
|
|
2775
2838
|
}
|
|
2776
2839
|
reindex() {
|
|
2777
|
-
this.items.peek().forEach((e, t) => e.rebase(
|
|
2840
|
+
this.items.peek().forEach((e, t) => e.rebase(A(this.path, t)));
|
|
2778
2841
|
}
|
|
2779
2842
|
push(e) {
|
|
2780
2843
|
const t = this.items.peek();
|
|
2781
|
-
this.items.value = [...t,
|
|
2844
|
+
this.items.value = [...t, x(e, A(this.path, t.length))];
|
|
2782
2845
|
}
|
|
2783
2846
|
insertAt(e, t) {
|
|
2784
2847
|
const i = [...this.items.peek()];
|
|
2785
|
-
i.splice(e, 0,
|
|
2848
|
+
i.splice(e, 0, x(t, A(this.path, e))), this.items.value = i, this.reindex();
|
|
2786
2849
|
}
|
|
2787
2850
|
removeAt(e) {
|
|
2788
2851
|
const t = [...this.items.peek()];
|
|
@@ -2804,30 +2867,30 @@ class Pe {
|
|
|
2804
2867
|
}
|
|
2805
2868
|
set(e) {
|
|
2806
2869
|
const t = Array.isArray(e) ? e : [];
|
|
2807
|
-
this.items.value = t.map((i, r) =>
|
|
2870
|
+
this.items.value = t.map((i, r) => x(i, A(this.path, r)));
|
|
2808
2871
|
}
|
|
2809
2872
|
resetToInitial() {
|
|
2810
|
-
this.set(
|
|
2873
|
+
this.set(S(this.initial));
|
|
2811
2874
|
}
|
|
2812
2875
|
captureInitial() {
|
|
2813
|
-
this.initial =
|
|
2876
|
+
this.initial = S(this.peek());
|
|
2814
2877
|
}
|
|
2815
2878
|
dirty() {
|
|
2816
|
-
return !
|
|
2879
|
+
return !I(this.peek(), this.initial);
|
|
2817
2880
|
}
|
|
2818
2881
|
}
|
|
2819
|
-
function
|
|
2820
|
-
return Array.isArray(s) ? new
|
|
2882
|
+
function x(s, e) {
|
|
2883
|
+
return Array.isArray(s) ? new Le(s, e) : T(s) ? new me(s, e) : new De(s, e);
|
|
2821
2884
|
}
|
|
2822
|
-
function
|
|
2885
|
+
function D(s) {
|
|
2823
2886
|
if (s)
|
|
2824
|
-
return s.kind === "leaf" ? s.read() : s.kind === "group" ?
|
|
2887
|
+
return s.kind === "leaf" ? s.read() : s.kind === "group" ? Re(s) : ye(s);
|
|
2825
2888
|
}
|
|
2826
|
-
function
|
|
2889
|
+
function Re(s) {
|
|
2827
2890
|
return new Proxy(
|
|
2828
2891
|
{},
|
|
2829
2892
|
{
|
|
2830
|
-
get: (e, t) => t === "__path" ? s.path : typeof t == "string" ?
|
|
2893
|
+
get: (e, t) => t === "__path" ? s.path : typeof t == "string" ? D(s.children.get(t)) : void 0,
|
|
2831
2894
|
set: (e, t, i) => {
|
|
2832
2895
|
if (typeof t != "string") return !1;
|
|
2833
2896
|
const r = s.children.get(t);
|
|
@@ -2839,11 +2902,11 @@ function Ce(s) {
|
|
|
2839
2902
|
}
|
|
2840
2903
|
);
|
|
2841
2904
|
}
|
|
2842
|
-
function
|
|
2905
|
+
function $(s) {
|
|
2843
2906
|
if (s)
|
|
2844
|
-
return s.kind === "group" ?
|
|
2907
|
+
return s.kind === "group" ? ge(s) : s.kind === "array" ? ye(s) : s.read();
|
|
2845
2908
|
}
|
|
2846
|
-
function
|
|
2909
|
+
function ye(s) {
|
|
2847
2910
|
const e = {
|
|
2848
2911
|
get length() {
|
|
2849
2912
|
return s.items.value.length;
|
|
@@ -2854,21 +2917,21 @@ function he(s) {
|
|
|
2854
2917
|
move: (t, i) => s.move(t, i),
|
|
2855
2918
|
swap: (t, i) => s.swap(t, i),
|
|
2856
2919
|
clear: () => s.clear(),
|
|
2857
|
-
at: (t) =>
|
|
2858
|
-
map: (t) => s.items.value.map((i, r) => t(
|
|
2859
|
-
forEach: (t) => s.items.value.forEach((i, r) => t(
|
|
2920
|
+
at: (t) => $(s.items.value[t]),
|
|
2921
|
+
map: (t) => s.items.value.map((i, r) => t($(i), r)),
|
|
2922
|
+
forEach: (t) => s.items.value.forEach((i, r) => t($(i), r)),
|
|
2860
2923
|
toArray: () => s.peek(),
|
|
2861
2924
|
[Symbol.iterator]: function* () {
|
|
2862
2925
|
const t = s.items.value;
|
|
2863
|
-
for (let i = 0; i < t.length; i++) yield
|
|
2926
|
+
for (let i = 0; i < t.length; i++) yield D(t[i]);
|
|
2864
2927
|
}
|
|
2865
2928
|
};
|
|
2866
2929
|
return new Proxy(e, {
|
|
2867
|
-
get: (t, i, r) => i === "__path" ? s.path : typeof i == "string" &&
|
|
2868
|
-
has: (t, i) => typeof i == "string" &&
|
|
2930
|
+
get: (t, i, r) => i === "__path" ? s.path : typeof i == "string" && W(i) ? D(s.items.value[Number(i)]) : Reflect.get(t, i, r),
|
|
2931
|
+
has: (t, i) => typeof i == "string" && W(i) ? Number(i) < s.items.value.length : Reflect.has(t, i)
|
|
2869
2932
|
});
|
|
2870
2933
|
}
|
|
2871
|
-
function
|
|
2934
|
+
function q(s) {
|
|
2872
2935
|
if (s.kind === "leaf") return s.signal;
|
|
2873
2936
|
if (s.kind === "group")
|
|
2874
2937
|
return new Proxy(
|
|
@@ -2878,7 +2941,7 @@ function W(s) {
|
|
|
2878
2941
|
if (i === "__path") return s.path;
|
|
2879
2942
|
if (typeof i != "string") return;
|
|
2880
2943
|
const r = s.children.get(i);
|
|
2881
|
-
return r ?
|
|
2944
|
+
return r ? q(r) : void 0;
|
|
2882
2945
|
},
|
|
2883
2946
|
has: (t, i) => typeof i == "string" && s.children.has(i),
|
|
2884
2947
|
ownKeys: () => [...s.children.keys()],
|
|
@@ -2895,16 +2958,16 @@ function W(s) {
|
|
|
2895
2958
|
{
|
|
2896
2959
|
get: (t, i, r) => {
|
|
2897
2960
|
if (i === "__path") return e.path;
|
|
2898
|
-
if (typeof i == "string" &&
|
|
2961
|
+
if (typeof i == "string" && W(i)) {
|
|
2899
2962
|
const n = e.items.value[Number(i)];
|
|
2900
|
-
return n ?
|
|
2963
|
+
return n ? q(n) : void 0;
|
|
2901
2964
|
}
|
|
2902
2965
|
return Reflect.get(t, i, r);
|
|
2903
2966
|
}
|
|
2904
2967
|
}
|
|
2905
2968
|
);
|
|
2906
2969
|
}
|
|
2907
|
-
function
|
|
2970
|
+
function $e(s, e) {
|
|
2908
2971
|
if (!e) return;
|
|
2909
2972
|
let t = s;
|
|
2910
2973
|
for (const i of e.split(".")) {
|
|
@@ -2915,7 +2978,7 @@ function Te(s, e) {
|
|
|
2915
2978
|
}
|
|
2916
2979
|
return t && t.kind === "leaf" ? t.signal : void 0;
|
|
2917
2980
|
}
|
|
2918
|
-
const
|
|
2981
|
+
const se = /* @__PURE__ */ new Set([
|
|
2919
2982
|
"$",
|
|
2920
2983
|
"get",
|
|
2921
2984
|
"set",
|
|
@@ -2924,275 +2987,205 @@ const X = /* @__PURE__ */ new Set([
|
|
|
2924
2987
|
"reset",
|
|
2925
2988
|
"captureInitial",
|
|
2926
2989
|
"signalAt"
|
|
2927
|
-
]),
|
|
2928
|
-
function
|
|
2929
|
-
const e =
|
|
2990
|
+
]), ie = /* @__PURE__ */ new WeakMap();
|
|
2991
|
+
function ge(s) {
|
|
2992
|
+
const e = ie.get(s);
|
|
2930
2993
|
if (e) return e;
|
|
2931
2994
|
const t = {
|
|
2932
|
-
$:
|
|
2995
|
+
$: q(s),
|
|
2933
2996
|
get: () => s.peek(),
|
|
2934
2997
|
set: (r) => s.set(r),
|
|
2935
2998
|
patch: (r) => s.set(r),
|
|
2936
2999
|
isDirty: () => s.dirty(),
|
|
2937
3000
|
reset: () => s.resetToInitial(),
|
|
2938
3001
|
captureInitial: () => s.captureInitial(),
|
|
2939
|
-
signalAt: (r) =>
|
|
3002
|
+
signalAt: (r) => $e(s, r)
|
|
2940
3003
|
}, i = new Proxy(
|
|
2941
3004
|
{},
|
|
2942
3005
|
{
|
|
2943
3006
|
get: (r, n) => {
|
|
2944
3007
|
if (typeof n != "string") return;
|
|
2945
3008
|
const a = s.children.get(n);
|
|
2946
|
-
if (a) return
|
|
2947
|
-
if (
|
|
3009
|
+
if (a) return D(a);
|
|
3010
|
+
if (se.has(n)) return t[n];
|
|
2948
3011
|
},
|
|
2949
3012
|
set: (r, n, a) => {
|
|
2950
3013
|
if (typeof n != "string") return !1;
|
|
2951
|
-
const
|
|
2952
|
-
return
|
|
3014
|
+
const l = s.children.get(n);
|
|
3015
|
+
return l ? (l.set(a), !0) : !1;
|
|
2953
3016
|
},
|
|
2954
|
-
has: (r, n) => typeof n == "string" && (s.children.has(n) ||
|
|
3017
|
+
has: (r, n) => typeof n == "string" && (s.children.has(n) || se.has(n)),
|
|
2955
3018
|
ownKeys: () => [...s.children.keys()],
|
|
2956
3019
|
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && s.children.has(n) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2957
3020
|
}
|
|
2958
3021
|
);
|
|
2959
|
-
return
|
|
2960
|
-
}
|
|
2961
|
-
function Je(s) {
|
|
2962
|
-
const e = new ce(s, "");
|
|
2963
|
-
return de(e);
|
|
2964
|
-
}
|
|
2965
|
-
const Ie = (s) => {
|
|
2966
|
-
const e = s.componentProps;
|
|
2967
|
-
return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
|
|
2968
|
-
}, De = (s) => typeof s.when == "function" && Array.isArray(s.children);
|
|
2969
|
-
function V(s, e, t, i, r) {
|
|
2970
|
-
if (s == null || typeof s != "object") return;
|
|
2971
|
-
if (Array.isArray(s)) {
|
|
2972
|
-
for (const a of s) V(a, e, t, i, r);
|
|
2973
|
-
return;
|
|
2974
|
-
}
|
|
2975
|
-
const n = s;
|
|
2976
|
-
if (De(n)) {
|
|
2977
|
-
const a = i && !!n.when(e, t);
|
|
2978
|
-
for (const o of n.children) V(o, e, t, a, r);
|
|
2979
|
-
return;
|
|
2980
|
-
}
|
|
2981
|
-
if (Ie(n)) {
|
|
2982
|
-
const a = n.componentProps.control, o = n.componentProps.itemComponent, l = a.length;
|
|
2983
|
-
for (let u = 0; u < l; u++) {
|
|
2984
|
-
const m = a.at(u);
|
|
2985
|
-
V(o(m), m, t, i, r);
|
|
2986
|
-
}
|
|
2987
|
-
return;
|
|
2988
|
-
}
|
|
2989
|
-
if (n.value instanceof ie) {
|
|
2990
|
-
const a = n.validators ?? [];
|
|
2991
|
-
a.length > 0 && (i ? r.tasks.push({ signal: n.value, validators: a, scope: e }) : r.clearSignals.push(n.value));
|
|
2992
|
-
for (const [o, l] of Object.entries(n))
|
|
2993
|
-
o === "value" || o === "validators" || V(l, e, t, i, r);
|
|
2994
|
-
return;
|
|
2995
|
-
}
|
|
2996
|
-
for (const a of Object.values(n)) V(a, e, t, i, r);
|
|
3022
|
+
return ie.set(s, i), i;
|
|
2997
3023
|
}
|
|
2998
|
-
function
|
|
2999
|
-
const
|
|
3000
|
-
return
|
|
3001
|
-
}
|
|
3002
|
-
const fe = (s, e, t) => {
|
|
3003
|
-
(s[e] ??= []).push(t);
|
|
3004
|
-
};
|
|
3005
|
-
function Ye(s, e) {
|
|
3006
|
-
const { tasks: t } = z(s, e), i = {};
|
|
3007
|
-
for (const { signal: r, validators: n, scope: a } of t) {
|
|
3008
|
-
const o = r.peek();
|
|
3009
|
-
for (const l of n) {
|
|
3010
|
-
const u = l(o, a, s);
|
|
3011
|
-
u && typeof u.then == "function" || u && fe(i, r.__path, u);
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
return { valid: Object.keys(i).length === 0, errors: i };
|
|
3015
|
-
}
|
|
3016
|
-
async function Qe(s, e) {
|
|
3017
|
-
const { tasks: t } = z(s, e), i = await pe(t, s);
|
|
3018
|
-
return { valid: Object.keys(i).length === 0, errors: i };
|
|
3019
|
-
}
|
|
3020
|
-
async function pe(s, e) {
|
|
3021
|
-
const t = {};
|
|
3022
|
-
return await Promise.all(
|
|
3023
|
-
s.map(async ({ signal: i, validators: r, scope: n }) => {
|
|
3024
|
-
const a = i.peek();
|
|
3025
|
-
for (const o of r) {
|
|
3026
|
-
const l = await o(a, n, e);
|
|
3027
|
-
l && fe(t, i.__path, l);
|
|
3028
|
-
}
|
|
3029
|
-
})
|
|
3030
|
-
), t;
|
|
3031
|
-
}
|
|
3032
|
-
async function Xe(s, e) {
|
|
3033
|
-
const { tasks: t, clearSignals: i } = z(s, e), r = await pe(t, s);
|
|
3034
|
-
for (const { signal: n } of t)
|
|
3035
|
-
Y(n)?.setErrors(r[n.__path] ?? []);
|
|
3036
|
-
for (const n of i)
|
|
3037
|
-
Y(n)?.setErrors([]);
|
|
3038
|
-
return { valid: Object.keys(r).length === 0, errors: r };
|
|
3024
|
+
function tt(s) {
|
|
3025
|
+
const e = new me(s, "");
|
|
3026
|
+
return ge(e);
|
|
3039
3027
|
}
|
|
3040
|
-
var
|
|
3041
|
-
var
|
|
3042
|
-
function
|
|
3043
|
-
if (
|
|
3044
|
-
|
|
3045
|
-
var s =
|
|
3046
|
-
function e(
|
|
3047
|
-
return
|
|
3028
|
+
var C = { exports: {} }, j = {};
|
|
3029
|
+
var re;
|
|
3030
|
+
function je() {
|
|
3031
|
+
if (re) return j;
|
|
3032
|
+
re = 1;
|
|
3033
|
+
var s = le;
|
|
3034
|
+
function e(o, v) {
|
|
3035
|
+
return o === v && (o !== 0 || 1 / o === 1 / v) || o !== o && v !== v;
|
|
3048
3036
|
}
|
|
3049
3037
|
var t = typeof Object.is == "function" ? Object.is : e, i = s.useState, r = s.useEffect, n = s.useLayoutEffect, a = s.useDebugValue;
|
|
3050
|
-
function o
|
|
3051
|
-
var
|
|
3038
|
+
function l(o, v) {
|
|
3039
|
+
var h = v(), p = i({ inst: { value: h, getSnapshot: v } }), m = p[0].inst, b = p[1];
|
|
3052
3040
|
return n(
|
|
3053
3041
|
function() {
|
|
3054
|
-
|
|
3042
|
+
m.value = h, m.getSnapshot = v, c(m) && b({ inst: m });
|
|
3055
3043
|
},
|
|
3056
|
-
[
|
|
3044
|
+
[o, h, v]
|
|
3057
3045
|
), r(
|
|
3058
3046
|
function() {
|
|
3059
|
-
return
|
|
3060
|
-
|
|
3047
|
+
return c(m) && b({ inst: m }), o(function() {
|
|
3048
|
+
c(m) && b({ inst: m });
|
|
3061
3049
|
});
|
|
3062
3050
|
},
|
|
3063
|
-
[
|
|
3064
|
-
), a(
|
|
3051
|
+
[o]
|
|
3052
|
+
), a(h), h;
|
|
3065
3053
|
}
|
|
3066
|
-
function
|
|
3067
|
-
var
|
|
3068
|
-
|
|
3054
|
+
function c(o) {
|
|
3055
|
+
var v = o.getSnapshot;
|
|
3056
|
+
o = o.value;
|
|
3069
3057
|
try {
|
|
3070
|
-
var
|
|
3071
|
-
return !t(
|
|
3058
|
+
var h = v();
|
|
3059
|
+
return !t(o, h);
|
|
3072
3060
|
} catch {
|
|
3073
3061
|
return !0;
|
|
3074
3062
|
}
|
|
3075
3063
|
}
|
|
3076
|
-
function u(
|
|
3077
|
-
return
|
|
3064
|
+
function u(o, v) {
|
|
3065
|
+
return v();
|
|
3078
3066
|
}
|
|
3079
|
-
var
|
|
3080
|
-
return
|
|
3067
|
+
var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
3068
|
+
return j.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : d, j;
|
|
3081
3069
|
}
|
|
3082
|
-
var
|
|
3083
|
-
var
|
|
3084
|
-
function
|
|
3085
|
-
return
|
|
3086
|
-
function s(
|
|
3087
|
-
return
|
|
3070
|
+
var B = {};
|
|
3071
|
+
var ne;
|
|
3072
|
+
function Be() {
|
|
3073
|
+
return ne || (ne = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
3074
|
+
function s(h, p) {
|
|
3075
|
+
return h === p && (h !== 0 || 1 / h === 1 / p) || h !== h && p !== p;
|
|
3088
3076
|
}
|
|
3089
|
-
function e(
|
|
3090
|
-
|
|
3077
|
+
function e(h, p) {
|
|
3078
|
+
d || r.startTransition === void 0 || (d = !0, console.error(
|
|
3091
3079
|
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
3092
3080
|
));
|
|
3093
|
-
var
|
|
3094
|
-
if (!
|
|
3095
|
-
var
|
|
3096
|
-
n(
|
|
3081
|
+
var m = p();
|
|
3082
|
+
if (!o) {
|
|
3083
|
+
var b = p();
|
|
3084
|
+
n(m, b) || (console.error(
|
|
3097
3085
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
3098
|
-
),
|
|
3086
|
+
), o = !0);
|
|
3099
3087
|
}
|
|
3100
|
-
|
|
3101
|
-
inst: { value:
|
|
3088
|
+
b = a({
|
|
3089
|
+
inst: { value: m, getSnapshot: p }
|
|
3102
3090
|
});
|
|
3103
|
-
var
|
|
3104
|
-
return
|
|
3091
|
+
var g = b[0].inst, V = b[1];
|
|
3092
|
+
return c(
|
|
3105
3093
|
function() {
|
|
3106
|
-
|
|
3094
|
+
g.value = m, g.getSnapshot = p, t(g) && V({ inst: g });
|
|
3107
3095
|
},
|
|
3108
|
-
[
|
|
3109
|
-
),
|
|
3096
|
+
[h, m, p]
|
|
3097
|
+
), l(
|
|
3110
3098
|
function() {
|
|
3111
|
-
return t(
|
|
3112
|
-
t(
|
|
3099
|
+
return t(g) && V({ inst: g }), h(function() {
|
|
3100
|
+
t(g) && V({ inst: g });
|
|
3113
3101
|
});
|
|
3114
3102
|
},
|
|
3115
|
-
[
|
|
3116
|
-
), u(
|
|
3103
|
+
[h]
|
|
3104
|
+
), u(m), m;
|
|
3117
3105
|
}
|
|
3118
|
-
function t(
|
|
3119
|
-
var p =
|
|
3120
|
-
|
|
3106
|
+
function t(h) {
|
|
3107
|
+
var p = h.getSnapshot;
|
|
3108
|
+
h = h.value;
|
|
3121
3109
|
try {
|
|
3122
|
-
var
|
|
3123
|
-
return !n(
|
|
3110
|
+
var m = p();
|
|
3111
|
+
return !n(h, m);
|
|
3124
3112
|
} catch {
|
|
3125
3113
|
return !0;
|
|
3126
3114
|
}
|
|
3127
3115
|
}
|
|
3128
|
-
function i(
|
|
3116
|
+
function i(h, p) {
|
|
3129
3117
|
return p();
|
|
3130
3118
|
}
|
|
3131
3119
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
3132
|
-
var r =
|
|
3133
|
-
|
|
3134
|
-
})()),
|
|
3120
|
+
var r = le, n = typeof Object.is == "function" ? Object.is : s, a = r.useState, l = r.useEffect, c = r.useLayoutEffect, u = r.useDebugValue, d = !1, o = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? i : e;
|
|
3121
|
+
B.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
3122
|
+
})()), B;
|
|
3135
3123
|
}
|
|
3136
|
-
var
|
|
3137
|
-
function
|
|
3138
|
-
return
|
|
3124
|
+
var ae;
|
|
3125
|
+
function Ge() {
|
|
3126
|
+
return ae || (ae = 1, process.env.NODE_ENV === "production" ? C.exports = je() : C.exports = Be()), C.exports;
|
|
3139
3127
|
}
|
|
3140
|
-
var
|
|
3141
|
-
function
|
|
3128
|
+
var Y = Ge();
|
|
3129
|
+
function Ue(s, e) {
|
|
3142
3130
|
if (s === e) return !0;
|
|
3143
3131
|
if (s.length !== e.length) return !1;
|
|
3144
3132
|
for (let t = 0; t < s.length; t++)
|
|
3145
3133
|
if (s[t] !== e[t]) return !1;
|
|
3146
3134
|
return !0;
|
|
3147
3135
|
}
|
|
3148
|
-
function
|
|
3149
|
-
const
|
|
3150
|
-
|
|
3151
|
-
|
|
3136
|
+
function Q(s, e, t, i) {
|
|
3137
|
+
const r = M(null), n = M(s);
|
|
3138
|
+
n.current = s;
|
|
3139
|
+
const a = M(e);
|
|
3140
|
+
a.current = e;
|
|
3141
|
+
const l = M(t);
|
|
3142
|
+
if (l.current = t, r.current === null) {
|
|
3143
|
+
const d = {};
|
|
3152
3144
|
for (const o in s)
|
|
3153
|
-
|
|
3154
|
-
|
|
3145
|
+
d[o] = s[o].value;
|
|
3146
|
+
r.current = { ...d, __snapshot: null };
|
|
3155
3147
|
}
|
|
3156
|
-
const
|
|
3157
|
-
(
|
|
3148
|
+
const c = E(
|
|
3149
|
+
(d) => {
|
|
3158
3150
|
let o = !0;
|
|
3159
3151
|
return _(() => {
|
|
3160
|
-
|
|
3161
|
-
|
|
3152
|
+
const h = n.current;
|
|
3153
|
+
for (const p in h)
|
|
3154
|
+
h[p].value;
|
|
3162
3155
|
if (o) {
|
|
3163
3156
|
o = !1;
|
|
3164
3157
|
return;
|
|
3165
3158
|
}
|
|
3166
|
-
|
|
3159
|
+
d();
|
|
3167
3160
|
});
|
|
3168
3161
|
},
|
|
3169
|
-
[
|
|
3170
|
-
),
|
|
3171
|
-
const
|
|
3172
|
-
for (const
|
|
3173
|
-
|
|
3174
|
-
let
|
|
3175
|
-
for (const
|
|
3176
|
-
const { key: m, useShallowArrayEqual:
|
|
3177
|
-
if (
|
|
3178
|
-
if (
|
|
3179
|
-
|
|
3162
|
+
[i]
|
|
3163
|
+
), u = E(() => {
|
|
3164
|
+
const d = r.current, o = n.current, v = {};
|
|
3165
|
+
for (const p in o)
|
|
3166
|
+
v[p] = o[p].value;
|
|
3167
|
+
let h = !1;
|
|
3168
|
+
for (const p of a.current) {
|
|
3169
|
+
const { key: m, useShallowArrayEqual: b } = p, g = v[m], V = d[m];
|
|
3170
|
+
if (b) {
|
|
3171
|
+
if (!Ue(V, g)) {
|
|
3172
|
+
h = !0;
|
|
3180
3173
|
break;
|
|
3181
3174
|
}
|
|
3182
|
-
} else if (
|
|
3183
|
-
|
|
3175
|
+
} else if (V !== g) {
|
|
3176
|
+
h = !0;
|
|
3184
3177
|
break;
|
|
3185
3178
|
}
|
|
3186
3179
|
}
|
|
3187
|
-
if (!
|
|
3188
|
-
return
|
|
3189
|
-
for (const
|
|
3190
|
-
|
|
3191
|
-
return
|
|
3192
|
-
}, [
|
|
3193
|
-
return
|
|
3180
|
+
if (!h && d.__snapshot)
|
|
3181
|
+
return d.__snapshot;
|
|
3182
|
+
for (const p in o)
|
|
3183
|
+
d[p] = v[p];
|
|
3184
|
+
return d.__snapshot = l.current(v), d.__snapshot;
|
|
3185
|
+
}, [i]);
|
|
3186
|
+
return Y.useSyncExternalStore(c, u, u);
|
|
3194
3187
|
}
|
|
3195
|
-
function
|
|
3188
|
+
function We(s) {
|
|
3196
3189
|
const e = {
|
|
3197
3190
|
value: s.value,
|
|
3198
3191
|
disabled: s.disabled,
|
|
@@ -3201,6 +3194,7 @@ function Be(s) {
|
|
|
3201
3194
|
valid: s.valid,
|
|
3202
3195
|
invalid: s.invalid,
|
|
3203
3196
|
touched: s.touched,
|
|
3197
|
+
dirty: s.dirty,
|
|
3204
3198
|
shouldShowError: s.shouldShowError,
|
|
3205
3199
|
componentProps: s.componentProps
|
|
3206
3200
|
}, t = [
|
|
@@ -3211,9 +3205,10 @@ function Be(s) {
|
|
|
3211
3205
|
{ key: "valid" },
|
|
3212
3206
|
{ key: "invalid" },
|
|
3213
3207
|
{ key: "touched" },
|
|
3208
|
+
{ key: "dirty" },
|
|
3214
3209
|
{ key: "shouldShowError" },
|
|
3215
3210
|
{ key: "componentProps" }
|
|
3216
|
-
], i =
|
|
3211
|
+
], i = E(
|
|
3217
3212
|
(r) => ({
|
|
3218
3213
|
value: r.value,
|
|
3219
3214
|
pending: r.pending,
|
|
@@ -3222,14 +3217,15 @@ function Be(s) {
|
|
|
3222
3217
|
valid: r.valid,
|
|
3223
3218
|
invalid: r.invalid,
|
|
3224
3219
|
touched: r.touched,
|
|
3220
|
+
dirty: r.dirty,
|
|
3225
3221
|
shouldShowError: r.shouldShowError,
|
|
3226
3222
|
componentProps: r.componentProps
|
|
3227
3223
|
}),
|
|
3228
3224
|
[]
|
|
3229
3225
|
);
|
|
3230
|
-
return
|
|
3226
|
+
return Q(e, t, i, s);
|
|
3231
3227
|
}
|
|
3232
|
-
function
|
|
3228
|
+
function qe(s) {
|
|
3233
3229
|
const e = {
|
|
3234
3230
|
value: s.value,
|
|
3235
3231
|
length: s.length,
|
|
@@ -3238,7 +3234,8 @@ function Ge(s) {
|
|
|
3238
3234
|
valid: s.valid,
|
|
3239
3235
|
invalid: s.invalid,
|
|
3240
3236
|
touched: s.touched,
|
|
3241
|
-
dirty: s.dirty
|
|
3237
|
+
dirty: s.dirty,
|
|
3238
|
+
disabled: s.disabled
|
|
3242
3239
|
}, t = [
|
|
3243
3240
|
{ key: "value" },
|
|
3244
3241
|
{ key: "length" },
|
|
@@ -3247,8 +3244,9 @@ function Ge(s) {
|
|
|
3247
3244
|
{ key: "valid" },
|
|
3248
3245
|
{ key: "invalid" },
|
|
3249
3246
|
{ key: "touched" },
|
|
3250
|
-
{ key: "dirty" }
|
|
3251
|
-
|
|
3247
|
+
{ key: "dirty" },
|
|
3248
|
+
{ key: "disabled" }
|
|
3249
|
+
], i = E(
|
|
3252
3250
|
(r) => ({
|
|
3253
3251
|
value: r.value,
|
|
3254
3252
|
length: r.length,
|
|
@@ -3257,27 +3255,36 @@ function Ge(s) {
|
|
|
3257
3255
|
valid: r.valid,
|
|
3258
3256
|
invalid: r.invalid,
|
|
3259
3257
|
touched: r.touched,
|
|
3260
|
-
dirty: r.dirty
|
|
3258
|
+
dirty: r.dirty,
|
|
3259
|
+
disabled: r.disabled
|
|
3260
|
+
}),
|
|
3261
|
+
[]
|
|
3262
|
+
);
|
|
3263
|
+
return Q(e, t, i, s);
|
|
3264
|
+
}
|
|
3265
|
+
function Ke() {
|
|
3266
|
+
const s = E(
|
|
3267
|
+
() => ({
|
|
3268
|
+
value: [],
|
|
3269
|
+
length: 0,
|
|
3270
|
+
pending: !1,
|
|
3271
|
+
errors: [],
|
|
3272
|
+
valid: !0,
|
|
3273
|
+
invalid: !1,
|
|
3274
|
+
touched: !1,
|
|
3275
|
+
dirty: !1,
|
|
3276
|
+
disabled: !1
|
|
3261
3277
|
}),
|
|
3262
3278
|
[]
|
|
3263
3279
|
);
|
|
3264
|
-
return
|
|
3280
|
+
return Q({}, [], s);
|
|
3265
3281
|
}
|
|
3266
|
-
function
|
|
3282
|
+
function st(s) {
|
|
3267
3283
|
const e = s && "length" in s && "map" in s;
|
|
3268
|
-
return s ? e ?
|
|
3269
|
-
value: [],
|
|
3270
|
-
length: 0,
|
|
3271
|
-
pending: !1,
|
|
3272
|
-
errors: [],
|
|
3273
|
-
valid: !0,
|
|
3274
|
-
invalid: !1,
|
|
3275
|
-
touched: !1,
|
|
3276
|
-
dirty: !1
|
|
3277
|
-
};
|
|
3284
|
+
return s ? e ? qe(s) : We(s) : Ke();
|
|
3278
3285
|
}
|
|
3279
|
-
function
|
|
3280
|
-
const e =
|
|
3286
|
+
function it(s) {
|
|
3287
|
+
const e = M({ value: s.value.value }), t = E(
|
|
3281
3288
|
(r) => {
|
|
3282
3289
|
let n = !0;
|
|
3283
3290
|
return _(() => {
|
|
@@ -3289,14 +3296,14 @@ function et(s) {
|
|
|
3289
3296
|
});
|
|
3290
3297
|
},
|
|
3291
3298
|
[s]
|
|
3292
|
-
), i =
|
|
3299
|
+
), i = E(() => {
|
|
3293
3300
|
const r = s.value.value;
|
|
3294
3301
|
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
3295
3302
|
}, [s]);
|
|
3296
|
-
return
|
|
3303
|
+
return Y.useSyncExternalStore(t, i, i);
|
|
3297
3304
|
}
|
|
3298
|
-
function
|
|
3299
|
-
const e =
|
|
3305
|
+
function rt(s) {
|
|
3306
|
+
const e = M({ length: s.length.value }), t = E(
|
|
3300
3307
|
(r) => {
|
|
3301
3308
|
let n = !0;
|
|
3302
3309
|
return _(() => {
|
|
@@ -3308,54 +3315,55 @@ function tt(s) {
|
|
|
3308
3315
|
});
|
|
3309
3316
|
},
|
|
3310
3317
|
[s]
|
|
3311
|
-
), i =
|
|
3318
|
+
), i = E(() => {
|
|
3312
3319
|
const r = s.length.value;
|
|
3313
3320
|
return e.current.length === r ? e.current.length : (e.current.length = r, r);
|
|
3314
3321
|
}, [s]);
|
|
3315
|
-
return
|
|
3322
|
+
return Y.useSyncExternalStore(t, i, i);
|
|
3316
3323
|
}
|
|
3317
3324
|
export {
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3325
|
+
te as ArrayNode,
|
|
3326
|
+
O as ErrorStrategy,
|
|
3327
|
+
Se as FieldNode,
|
|
3328
|
+
N as FormErrorHandler,
|
|
3329
|
+
L as FormNode,
|
|
3330
|
+
Ae as FormStatusMachine,
|
|
3331
|
+
ke as FormSubmitter,
|
|
3332
|
+
P as GroupNode,
|
|
3333
|
+
Pe as ModelArrayNode,
|
|
3334
|
+
Ne as NodeFactory,
|
|
3328
3335
|
K as SubscriptionManager,
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3336
|
+
ot as computeFrom,
|
|
3337
|
+
lt as copyFrom,
|
|
3338
|
+
et as createForm,
|
|
3339
|
+
ve as createFormFromModel,
|
|
3340
|
+
tt as createModel,
|
|
3341
|
+
ut as disableWhen,
|
|
3342
|
+
ct as enableWhen,
|
|
3343
|
+
X as getNodeForSignal,
|
|
3344
|
+
Qe as getNodeType,
|
|
3345
|
+
Me as isArrayNode,
|
|
3346
|
+
G as isDerived,
|
|
3347
|
+
Oe as isFieldNode,
|
|
3348
|
+
R as isFormNode,
|
|
3349
|
+
Fe as isGroupNode,
|
|
3350
|
+
ht as markDerived,
|
|
3351
|
+
_e as registerSignalNode,
|
|
3352
|
+
dt as resetWhen,
|
|
3353
|
+
ft as revalidateWhen,
|
|
3354
|
+
pt as runOutsideEffect,
|
|
3355
|
+
vt as safeCallback,
|
|
3356
|
+
mt as safeDebouncedCallback,
|
|
3357
|
+
yt as syncFields,
|
|
3358
|
+
gt as transformValue,
|
|
3359
|
+
k as uniqueId,
|
|
3360
|
+
bt as unmarkDerived,
|
|
3361
|
+
rt as useArrayLength,
|
|
3362
|
+
st as useFormControl,
|
|
3363
|
+
it as useFormControlValue,
|
|
3364
|
+
Te as validateFormModel,
|
|
3365
|
+
Ze as validateModel,
|
|
3366
|
+
Xe as validateModelSync,
|
|
3367
|
+
At as validators,
|
|
3368
|
+
_t as watchField
|
|
3361
3369
|
};
|