@reformer/core 9.0.0-beta.1 → 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/model/behaviors.d.ts +15 -0
- package/dist/core/nodes/group-node.d.ts +32 -2
- package/dist/core/nodes/model-array-node.d.ts +8 -1
- package/dist/core/types/deep-schema.d.ts +23 -1
- package/dist/core/types/form-proxy.d.ts +26 -1
- package/dist/core/types/validation-schema.d.ts +18 -8
- package/dist/core/utils/derived-registry.d.ts +29 -0
- package/dist/core/utils/form-submitter.d.ts +6 -1
- package/dist/core/utils/index.d.ts +1 -1
- package/dist/core/utils/safe-effect.d.ts +27 -7
- package/dist/core/validation/validators/required.d.ts +2 -1
- package/dist/hooks/types.d.ts +30 -0
- package/dist/hooks/useSignalSubscription.d.ts +8 -1
- package/dist/index.js +766 -758
- package/dist/validators/pattern.js +7 -6
- package/dist/validators/required.js +5 -9
- package/llms.txt +149 -22
- package/package.json +1 -1
- 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 D {
|
|
|
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
|
*
|
|
@@ -97,17 +97,17 @@ class D {
|
|
|
97
97
|
*/
|
|
98
98
|
getErrors(e) {
|
|
99
99
|
const t = this.errors.value;
|
|
100
|
-
return e ? t.filter((
|
|
101
|
-
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(
|
|
100
|
+
return e ? t.filter((i) => {
|
|
101
|
+
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(i.code) || e.message !== void 0 && !i.message.toLowerCase().includes(e.message.toLowerCase()))
|
|
102
102
|
return !1;
|
|
103
103
|
if (e.params !== void 0) {
|
|
104
|
-
if (!
|
|
104
|
+
if (!i.params)
|
|
105
105
|
return !1;
|
|
106
106
|
for (const [r, n] of Object.entries(e.params))
|
|
107
|
-
if (
|
|
107
|
+
if (i.params[r] !== n)
|
|
108
108
|
return !1;
|
|
109
109
|
}
|
|
110
|
-
return !(e.predicate !== void 0 && !e.predicate(
|
|
110
|
+
return !(e.predicate !== void 0 && !e.predicate(i));
|
|
111
111
|
}) : t;
|
|
112
112
|
}
|
|
113
113
|
// ============================================================================
|
|
@@ -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,105 +462,11 @@ const k = {
|
|
|
462
462
|
/** ArrayNode.watchLength() */
|
|
463
463
|
WatchLength: "watchLength"
|
|
464
464
|
};
|
|
465
|
-
let
|
|
466
|
-
function
|
|
467
|
-
return `${
|
|
465
|
+
let Ee = 0;
|
|
466
|
+
function k(s) {
|
|
467
|
+
return `${s}-${++Ee}`;
|
|
468
468
|
}
|
|
469
|
-
|
|
470
|
-
class O {
|
|
471
|
-
static handle(e, t, s = "throw") {
|
|
472
|
-
const r = this.extractMessage(e);
|
|
473
|
-
switch (s) {
|
|
474
|
-
case "throw":
|
|
475
|
-
throw e;
|
|
476
|
-
case "log":
|
|
477
|
-
return;
|
|
478
|
-
case "convert":
|
|
479
|
-
return {
|
|
480
|
-
code: "validator_error",
|
|
481
|
-
message: r,
|
|
482
|
-
params: { field: t }
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Извлечь сообщение из ошибки
|
|
488
|
-
*
|
|
489
|
-
* Обрабатывает различные типы ошибок:
|
|
490
|
-
* - Error объекты → error.message
|
|
491
|
-
* - Строки → возвращает как есть
|
|
492
|
-
* - Объекты с message → извлекает message
|
|
493
|
-
* - Другое → String(error)
|
|
494
|
-
*
|
|
495
|
-
* @param error Ошибка для извлечения сообщения
|
|
496
|
-
* @returns Сообщение ошибки
|
|
497
|
-
* @private
|
|
498
|
-
*
|
|
499
|
-
* @example
|
|
500
|
-
* ```typescript
|
|
501
|
-
* FormErrorHandler.extractMessage(new Error('Test'));
|
|
502
|
-
* // 'Test'
|
|
503
|
-
*
|
|
504
|
-
* FormErrorHandler.extractMessage('String error');
|
|
505
|
-
* // 'String error'
|
|
506
|
-
*
|
|
507
|
-
* FormErrorHandler.extractMessage({ message: 'Object error' });
|
|
508
|
-
* // 'Object error'
|
|
509
|
-
*
|
|
510
|
-
* FormErrorHandler.extractMessage(null);
|
|
511
|
-
* // 'null'
|
|
512
|
-
* ```
|
|
513
|
-
*/
|
|
514
|
-
static extractMessage(e) {
|
|
515
|
-
return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e ? String(e.message) : String(e);
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Создать ValidationError с заданными параметрами
|
|
519
|
-
*
|
|
520
|
-
* Утилитная функция для создания ValidationError объектов
|
|
521
|
-
*
|
|
522
|
-
* @param code Код ошибки
|
|
523
|
-
* @param message Сообщение ошибки
|
|
524
|
-
* @param field Поле (опционально)
|
|
525
|
-
* @returns ValidationError объект
|
|
526
|
-
*
|
|
527
|
-
* @example
|
|
528
|
-
* ```typescript
|
|
529
|
-
* const error = FormErrorHandler.createValidationError(
|
|
530
|
-
* 'required',
|
|
531
|
-
* 'This field is required',
|
|
532
|
-
* 'email'
|
|
533
|
-
* );
|
|
534
|
-
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
535
|
-
* ```
|
|
536
|
-
*/
|
|
537
|
-
static createValidationError(e, t, s) {
|
|
538
|
-
return {
|
|
539
|
-
code: e,
|
|
540
|
-
message: t,
|
|
541
|
-
params: s ? { field: s } : void 0
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Проверить, является ли объект ValidationError
|
|
546
|
-
*
|
|
547
|
-
* Type guard для ValidationError
|
|
548
|
-
*
|
|
549
|
-
* @param value Значение для проверки
|
|
550
|
-
* @returns true если value является ValidationError
|
|
551
|
-
*
|
|
552
|
-
* @example
|
|
553
|
-
* ```typescript
|
|
554
|
-
* if (FormErrorHandler.isValidationError(result)) {
|
|
555
|
-
* console.log(result.code); // OK, типобезопасно
|
|
556
|
-
* }
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
static isValidationError(e) {
|
|
560
|
-
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
class be {
|
|
469
|
+
class Ae {
|
|
564
470
|
/** Внутренний сигнал статуса */
|
|
565
471
|
_status;
|
|
566
472
|
/** Публичный read-only сигнал статуса */
|
|
@@ -577,7 +483,7 @@ class be {
|
|
|
577
483
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
578
484
|
*/
|
|
579
485
|
constructor(e = "valid") {
|
|
580
|
-
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");
|
|
581
487
|
}
|
|
582
488
|
/**
|
|
583
489
|
* Начать валидацию
|
|
@@ -705,7 +611,7 @@ class be {
|
|
|
705
611
|
return this._status.value !== "disabled";
|
|
706
612
|
}
|
|
707
613
|
}
|
|
708
|
-
class
|
|
614
|
+
class Se extends L {
|
|
709
615
|
// ============================================================================
|
|
710
616
|
// Приватные сигналы
|
|
711
617
|
// ============================================================================
|
|
@@ -763,7 +669,7 @@ class _e extends D {
|
|
|
763
669
|
// Конструктор
|
|
764
670
|
// ============================================================================
|
|
765
671
|
constructor(e) {
|
|
766
|
-
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(
|
|
767
673
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
768
674
|
);
|
|
769
675
|
}
|
|
@@ -776,12 +682,12 @@ class _e extends D {
|
|
|
776
682
|
setValue(e, t) {
|
|
777
683
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
778
684
|
return;
|
|
779
|
-
const
|
|
685
|
+
const i = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
|
|
780
686
|
if (this.updateOn === "change") {
|
|
781
687
|
this.validate();
|
|
782
688
|
return;
|
|
783
689
|
}
|
|
784
|
-
r &&
|
|
690
|
+
r && i && this.validate();
|
|
785
691
|
}
|
|
786
692
|
patchValue(e) {
|
|
787
693
|
this.setValue(e);
|
|
@@ -874,17 +780,17 @@ class _e extends D {
|
|
|
874
780
|
const t = e?.debounce ?? this.debounceMs;
|
|
875
781
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
876
782
|
return this.validateImmediate();
|
|
877
|
-
const
|
|
783
|
+
const i = new AbortController();
|
|
878
784
|
return new Promise((r) => {
|
|
879
|
-
this.pendingValidation = { resolve: r, abortController:
|
|
880
|
-
if (this.validateDebounceTimer = void 0,
|
|
785
|
+
this.pendingValidation = { resolve: r, abortController: i }, this.validateDebounceTimer = setTimeout(async () => {
|
|
786
|
+
if (this.validateDebounceTimer = void 0, i.signal.aborted) {
|
|
881
787
|
r(!1);
|
|
882
788
|
return;
|
|
883
789
|
}
|
|
884
790
|
this.pendingValidation = void 0;
|
|
885
|
-
const n = await this.validateImmediate(
|
|
791
|
+
const n = await this.validateImmediate(i);
|
|
886
792
|
r(n);
|
|
887
|
-
}, t),
|
|
793
|
+
}, t), i.signal.addEventListener(
|
|
888
794
|
"abort",
|
|
889
795
|
() => {
|
|
890
796
|
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), r(!1);
|
|
@@ -906,51 +812,51 @@ class _e extends D {
|
|
|
906
812
|
async validateImmediate(e) {
|
|
907
813
|
const t = e ?? new AbortController();
|
|
908
814
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
909
|
-
const { signal:
|
|
815
|
+
const { signal: i } = t, r = [];
|
|
910
816
|
for (const a of this.validators) {
|
|
911
|
-
const
|
|
912
|
-
|
|
817
|
+
const l = a(this._value.value);
|
|
818
|
+
l && r.push(l);
|
|
913
819
|
}
|
|
914
|
-
if (
|
|
820
|
+
if (i.aborted)
|
|
915
821
|
return !1;
|
|
916
822
|
if (r.length > 0) {
|
|
917
823
|
this._errors.value = r;
|
|
918
|
-
const a = r.some((
|
|
824
|
+
const a = r.some((l) => l.severity !== "warning");
|
|
919
825
|
if (this.statusMachine.setErrors(a), a)
|
|
920
826
|
return !1;
|
|
921
827
|
}
|
|
922
828
|
if (this.asyncValidators.length > 0) {
|
|
923
|
-
if (
|
|
829
|
+
if (i.aborted)
|
|
924
830
|
return !1;
|
|
925
831
|
this.statusMachine.startValidation();
|
|
926
832
|
try {
|
|
927
833
|
const a = await Promise.all(
|
|
928
|
-
this.asyncValidators.map(async (
|
|
929
|
-
if (
|
|
834
|
+
this.asyncValidators.map(async (c) => {
|
|
835
|
+
if (i.aborted)
|
|
930
836
|
throw new DOMException("Validation aborted", "AbortError");
|
|
931
837
|
try {
|
|
932
|
-
const u = await
|
|
933
|
-
if (
|
|
838
|
+
const u = await c(this._value.value, { signal: i });
|
|
839
|
+
if (i.aborted)
|
|
934
840
|
throw new DOMException("Validation aborted", "AbortError");
|
|
935
841
|
return u;
|
|
936
842
|
} catch (u) {
|
|
937
843
|
if (u instanceof DOMException && u.name === "AbortError")
|
|
938
844
|
throw u;
|
|
939
|
-
return
|
|
845
|
+
return N.handle(
|
|
940
846
|
u,
|
|
941
847
|
"FieldNode AsyncValidator",
|
|
942
|
-
|
|
848
|
+
O.CONVERT
|
|
943
849
|
);
|
|
944
850
|
}
|
|
945
851
|
})
|
|
946
852
|
);
|
|
947
|
-
if (
|
|
853
|
+
if (i.aborted)
|
|
948
854
|
return !1;
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
951
|
-
this._errors.value =
|
|
952
|
-
const
|
|
953
|
-
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)
|
|
954
860
|
return !1;
|
|
955
861
|
}
|
|
956
862
|
} catch (a) {
|
|
@@ -959,11 +865,11 @@ class _e extends D {
|
|
|
959
865
|
throw a;
|
|
960
866
|
}
|
|
961
867
|
}
|
|
962
|
-
return
|
|
868
|
+
return i.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
|
|
963
869
|
}
|
|
964
870
|
setErrors(e) {
|
|
965
871
|
this._errors.value = e;
|
|
966
|
-
const t = e.some((
|
|
872
|
+
const t = e.some((i) => i.severity !== "warning");
|
|
967
873
|
this.statusMachine.setErrors(t);
|
|
968
874
|
}
|
|
969
875
|
clearErrors() {
|
|
@@ -1080,12 +986,12 @@ class _e extends D {
|
|
|
1080
986
|
* ```
|
|
1081
987
|
*/
|
|
1082
988
|
watch(e) {
|
|
1083
|
-
const t = new AbortController(),
|
|
989
|
+
const t = new AbortController(), i = _(() => {
|
|
1084
990
|
const n = this.value.value;
|
|
1085
991
|
e(n, t.signal);
|
|
1086
|
-
}), r =
|
|
992
|
+
}), r = k(w.Watch);
|
|
1087
993
|
return this.disposers.add(r, () => {
|
|
1088
|
-
t.abort(),
|
|
994
|
+
t.abort(), i();
|
|
1089
995
|
});
|
|
1090
996
|
}
|
|
1091
997
|
/**
|
|
@@ -1111,11 +1017,11 @@ class _e extends D {
|
|
|
1111
1017
|
* ```
|
|
1112
1018
|
*/
|
|
1113
1019
|
computeFrom(e, t) {
|
|
1114
|
-
const
|
|
1115
|
-
const n = e.map((
|
|
1020
|
+
const i = _(() => {
|
|
1021
|
+
const n = e.map((l) => l.value), a = t(...n);
|
|
1116
1022
|
this.setValue(a, { emitEvent: !1 });
|
|
1117
|
-
}), r =
|
|
1118
|
-
return this.disposers.add(r,
|
|
1023
|
+
}), r = k(w.ComputeFrom);
|
|
1024
|
+
return this.disposers.add(r, i);
|
|
1119
1025
|
}
|
|
1120
1026
|
/**
|
|
1121
1027
|
* Очистить все ресурсы и таймеры
|
|
@@ -1145,46 +1051,59 @@ class _e extends D {
|
|
|
1145
1051
|
}
|
|
1146
1052
|
}
|
|
1147
1053
|
}
|
|
1148
|
-
function H(
|
|
1149
|
-
const { getChildren: e, ownErrors: t, disabled:
|
|
1150
|
-
const
|
|
1151
|
-
for (const
|
|
1152
|
-
|
|
1153
|
-
return
|
|
1154
|
-
}),
|
|
1054
|
+
function H(s) {
|
|
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");
|
|
1155
1061
|
return {
|
|
1156
1062
|
valid: r,
|
|
1157
1063
|
invalid: n,
|
|
1158
1064
|
pending: a,
|
|
1159
|
-
touched:
|
|
1160
|
-
dirty:
|
|
1065
|
+
touched: l,
|
|
1066
|
+
dirty: c,
|
|
1161
1067
|
errors: u,
|
|
1162
|
-
status:
|
|
1068
|
+
status: d
|
|
1163
1069
|
};
|
|
1164
1070
|
}
|
|
1165
|
-
function
|
|
1166
|
-
return typeof
|
|
1071
|
+
function Z(s) {
|
|
1072
|
+
return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
|
|
1167
1073
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
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
|
+
};
|
|
1086
|
+
return new Proxy(s, {
|
|
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;
|
|
1176
1095
|
}
|
|
1177
1096
|
},
|
|
1178
|
-
set: (
|
|
1179
|
-
has: (
|
|
1180
|
-
ownKeys: (
|
|
1181
|
-
const
|
|
1182
|
-
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])];
|
|
1183
1102
|
},
|
|
1184
|
-
getOwnPropertyDescriptor: (
|
|
1103
|
+
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(r, n)
|
|
1185
1104
|
});
|
|
1186
1105
|
}
|
|
1187
|
-
class
|
|
1106
|
+
class ke {
|
|
1188
1107
|
/**
|
|
1189
1108
|
* @param form - Форма для отправки
|
|
1190
1109
|
*/
|
|
@@ -1194,7 +1113,7 @@ class we {
|
|
|
1194
1113
|
/** Внутренний сигнал состояния отправки */
|
|
1195
1114
|
_submitting = y(!1);
|
|
1196
1115
|
/** Публичный read-only сигнал состояния отправки */
|
|
1197
|
-
submitting =
|
|
1116
|
+
submitting = f(() => this._submitting.value);
|
|
1198
1117
|
/**
|
|
1199
1118
|
* Отправить форму
|
|
1200
1119
|
*
|
|
@@ -1206,7 +1125,12 @@ class we {
|
|
|
1206
1125
|
*
|
|
1207
1126
|
* @param onSubmit - Callback для отправки данных
|
|
1208
1127
|
* @param options - Опции submit
|
|
1209
|
-
* @returns Результат от onSubmit или null если валидация не пройдена
|
|
1128
|
+
* @returns Результат от onSubmit или `null` если валидация не пройдена
|
|
1129
|
+
*
|
|
1130
|
+
* @remarks
|
|
1131
|
+
* Возвращаемый `null` неоднозначен: он сигналит и провал валидации, и легитимный `null`,
|
|
1132
|
+
* который вернул `onSubmit` (или void-обработчик). Чтобы различать эти случаи, используйте
|
|
1133
|
+
* {@link submitWithResult} — он отдаёт явный флаг `success`.
|
|
1210
1134
|
*
|
|
1211
1135
|
* @example
|
|
1212
1136
|
* ```typescript
|
|
@@ -1224,8 +1148,8 @@ class we {
|
|
|
1224
1148
|
* ```
|
|
1225
1149
|
*/
|
|
1226
1150
|
async submit(e, t) {
|
|
1227
|
-
const { skipValidation:
|
|
1228
|
-
if (r || this.form.markAsTouched(), !
|
|
1151
|
+
const { skipValidation: i = !1, skipTouch: r = !1 } = t || {};
|
|
1152
|
+
if (r || this.form.markAsTouched(), !i && !await this.form.validate())
|
|
1229
1153
|
return null;
|
|
1230
1154
|
this._submitting.value = !0;
|
|
1231
1155
|
try {
|
|
@@ -1259,8 +1183,8 @@ class we {
|
|
|
1259
1183
|
* ```
|
|
1260
1184
|
*/
|
|
1261
1185
|
async submitWithResult(e, t) {
|
|
1262
|
-
const { skipValidation:
|
|
1263
|
-
if (r || this.form.markAsTouched(), !
|
|
1186
|
+
const { skipValidation: i = !1, skipTouch: r = !1 } = t || {};
|
|
1187
|
+
if (r || this.form.markAsTouched(), !i && !await this.form.validate())
|
|
1264
1188
|
return { success: !1, data: null };
|
|
1265
1189
|
this._submitting.value = !0;
|
|
1266
1190
|
try {
|
|
@@ -1282,16 +1206,16 @@ class we {
|
|
|
1282
1206
|
return this._submitting.value;
|
|
1283
1207
|
}
|
|
1284
1208
|
}
|
|
1285
|
-
function
|
|
1209
|
+
function Ve(s) {
|
|
1286
1210
|
const e = [];
|
|
1287
|
-
for (const t of
|
|
1288
|
-
const
|
|
1289
|
-
if (!
|
|
1290
|
-
e.push(
|
|
1211
|
+
for (const t of s.split(".")) {
|
|
1212
|
+
const i = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1213
|
+
if (!i) return [];
|
|
1214
|
+
e.push(i[2] !== void 0 ? { key: i[1], index: Number(i[2]) } : { key: i[1] });
|
|
1291
1215
|
}
|
|
1292
1216
|
return e;
|
|
1293
1217
|
}
|
|
1294
|
-
let
|
|
1218
|
+
let P = class ue extends L {
|
|
1295
1219
|
// ============================================================================
|
|
1296
1220
|
// Приватные поля
|
|
1297
1221
|
// ============================================================================
|
|
@@ -1316,7 +1240,7 @@ let x = class ae extends D {
|
|
|
1316
1240
|
/**
|
|
1317
1241
|
* Фабрика для создания узлов формы
|
|
1318
1242
|
*/
|
|
1319
|
-
nodeFactory = new
|
|
1243
|
+
nodeFactory = new Ne();
|
|
1320
1244
|
// ============================================================================
|
|
1321
1245
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1322
1246
|
// ============================================================================
|
|
@@ -1327,6 +1251,19 @@ let x = class ae extends D {
|
|
|
1327
1251
|
_disabled = y(!1);
|
|
1328
1252
|
/** Form-level validation errors */
|
|
1329
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();
|
|
1330
1267
|
// ============================================================================
|
|
1331
1268
|
// Публичные computed signals
|
|
1332
1269
|
// ============================================================================
|
|
@@ -1340,24 +1277,24 @@ let x = class ae extends D {
|
|
|
1340
1277
|
status;
|
|
1341
1278
|
submitting;
|
|
1342
1279
|
constructor(e) {
|
|
1343
|
-
super(), this.formSubmitter = new
|
|
1344
|
-
const
|
|
1345
|
-
for (const [
|
|
1346
|
-
const
|
|
1347
|
-
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);
|
|
1348
1285
|
}
|
|
1349
|
-
this.value =
|
|
1350
|
-
const
|
|
1351
|
-
return this._fields.forEach((
|
|
1352
|
-
|
|
1353
|
-
}),
|
|
1286
|
+
this.value = f(() => {
|
|
1287
|
+
const l = {};
|
|
1288
|
+
return this._fields.forEach((c, u) => {
|
|
1289
|
+
l[u] = c.value.value;
|
|
1290
|
+
}), l;
|
|
1354
1291
|
});
|
|
1355
|
-
const
|
|
1292
|
+
const a = H({
|
|
1356
1293
|
getChildren: () => Array.from(this._fields.values()),
|
|
1357
1294
|
ownErrors: this._formErrors,
|
|
1358
1295
|
disabled: this._disabled
|
|
1359
1296
|
});
|
|
1360
|
-
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;
|
|
1361
1298
|
}
|
|
1362
1299
|
// ============================================================================
|
|
1363
1300
|
// Приватный метод для создания Proxy
|
|
@@ -1367,33 +1304,35 @@ let x = class ae extends D {
|
|
|
1367
1304
|
* @see buildFormProxy
|
|
1368
1305
|
*/
|
|
1369
1306
|
buildProxy() {
|
|
1370
|
-
return
|
|
1307
|
+
return we(this, this._fields);
|
|
1371
1308
|
}
|
|
1372
1309
|
// ============================================================================
|
|
1373
1310
|
// Реализация абстрактных методов FormNode
|
|
1374
1311
|
// ============================================================================
|
|
1375
1312
|
getValue() {
|
|
1376
1313
|
const e = {};
|
|
1377
|
-
return this._fields.forEach((t,
|
|
1378
|
-
e[
|
|
1314
|
+
return this._fields.forEach((t, i) => {
|
|
1315
|
+
e[i] = t.getValue();
|
|
1379
1316
|
}), e;
|
|
1380
1317
|
}
|
|
1381
1318
|
setValue(e, t) {
|
|
1382
|
-
for (const [
|
|
1383
|
-
const n = this._fields.get(
|
|
1319
|
+
for (const [i, r] of Object.entries(e)) {
|
|
1320
|
+
const n = this._fields.get(i);
|
|
1384
1321
|
if (n) {
|
|
1385
|
-
|
|
1322
|
+
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1323
|
+
if (G(a)) continue;
|
|
1386
1324
|
n.setValue(r, t);
|
|
1387
1325
|
}
|
|
1388
1326
|
}
|
|
1389
1327
|
}
|
|
1390
1328
|
patchValue(e) {
|
|
1391
|
-
|
|
1392
|
-
for (const [t,
|
|
1329
|
+
be(() => {
|
|
1330
|
+
for (const [t, i] of Object.entries(e)) {
|
|
1393
1331
|
const r = this._fields.get(t);
|
|
1394
|
-
if (r &&
|
|
1395
|
-
|
|
1396
|
-
|
|
1332
|
+
if (r && i !== void 0) {
|
|
1333
|
+
const n = this._fieldSignals.get(r) ?? r.value;
|
|
1334
|
+
if (G(n)) continue;
|
|
1335
|
+
r.setValue(i, { emitEvent: !1 });
|
|
1397
1336
|
}
|
|
1398
1337
|
}
|
|
1399
1338
|
});
|
|
@@ -1416,8 +1355,8 @@ let x = class ae extends D {
|
|
|
1416
1355
|
* ```
|
|
1417
1356
|
*/
|
|
1418
1357
|
reset(e) {
|
|
1419
|
-
this._fields.forEach((t,
|
|
1420
|
-
const r = e?.[
|
|
1358
|
+
this._formErrors.value = [], this._fields.forEach((t, i) => {
|
|
1359
|
+
const r = e?.[i];
|
|
1421
1360
|
t.reset(r);
|
|
1422
1361
|
});
|
|
1423
1362
|
}
|
|
@@ -1425,14 +1364,16 @@ let x = class ae extends D {
|
|
|
1425
1364
|
* Сбросить форму к исходным значениям (initialValues)
|
|
1426
1365
|
*/
|
|
1427
1366
|
resetToInitial() {
|
|
1428
|
-
this._fields.forEach((e) => {
|
|
1367
|
+
this._formErrors.value = [], this._fields.forEach((e) => {
|
|
1429
1368
|
"resetToInitial" in e && typeof e.resetToInitial == "function" ? e.resetToInitial() : e.reset();
|
|
1430
1369
|
});
|
|
1431
1370
|
}
|
|
1432
1371
|
async validate() {
|
|
1433
|
-
|
|
1434
|
-
|
|
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
|
|
1435
1375
|
);
|
|
1376
|
+
return e && t;
|
|
1436
1377
|
}
|
|
1437
1378
|
/**
|
|
1438
1379
|
* Установить form-level validation errors
|
|
@@ -1514,7 +1455,12 @@ let x = class ae extends D {
|
|
|
1514
1455
|
*
|
|
1515
1456
|
* @param onSubmit - Callback для отправки данных
|
|
1516
1457
|
* @param options - Опции submit (skipValidation, skipTouch)
|
|
1517
|
-
* @returns Результат от onSubmit или null если валидация не пройдена
|
|
1458
|
+
* @returns Результат от onSubmit или `null` если валидация не пройдена
|
|
1459
|
+
*
|
|
1460
|
+
* @remarks
|
|
1461
|
+
* `null` перегружен: он означает и «валидация не пройдена», и легитимный `null`-результат
|
|
1462
|
+
* `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
|
|
1463
|
+
* используйте {@link submitWithResult}, который возвращает явный флаг `success`.
|
|
1518
1464
|
*/
|
|
1519
1465
|
async submit(e, t) {
|
|
1520
1466
|
return this.formSubmitter.submit(e, t);
|
|
@@ -1561,21 +1507,21 @@ let x = class ae extends D {
|
|
|
1561
1507
|
getFieldByPath(e) {
|
|
1562
1508
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1563
1509
|
return;
|
|
1564
|
-
const t =
|
|
1510
|
+
const t = Ve(e);
|
|
1565
1511
|
if (t.length === 0)
|
|
1566
1512
|
return;
|
|
1567
|
-
let
|
|
1513
|
+
let i = this;
|
|
1568
1514
|
for (const r of t) {
|
|
1569
|
-
if (!(
|
|
1515
|
+
if (!(i instanceof ue) || (i = i.getField(r.key), !i)) return;
|
|
1570
1516
|
if (r.index !== void 0)
|
|
1571
|
-
if ("at" in
|
|
1572
|
-
const n =
|
|
1517
|
+
if ("at" in i && "length" in i && typeof i.at == "function") {
|
|
1518
|
+
const n = i.at(r.index);
|
|
1573
1519
|
if (!n) return;
|
|
1574
|
-
|
|
1520
|
+
i = n;
|
|
1575
1521
|
} else
|
|
1576
1522
|
return;
|
|
1577
1523
|
}
|
|
1578
|
-
return
|
|
1524
|
+
return i;
|
|
1579
1525
|
}
|
|
1580
1526
|
// ============================================================================
|
|
1581
1527
|
// Private методы для создания узлов
|
|
@@ -1604,17 +1550,17 @@ let x = class ae extends D {
|
|
|
1604
1550
|
/**
|
|
1605
1551
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1606
1552
|
*/
|
|
1607
|
-
linkFields(e, t,
|
|
1553
|
+
linkFields(e, t, i) {
|
|
1608
1554
|
const r = this._fields.get(e), n = this._fields.get(t);
|
|
1609
1555
|
if (!r || !n) {
|
|
1610
|
-
const
|
|
1611
|
-
throw new Error(`GroupNode.linkFields: field "${String(
|
|
1556
|
+
const c = r ? t : e;
|
|
1557
|
+
throw new Error(`GroupNode.linkFields: field "${String(c)}" not found`);
|
|
1612
1558
|
}
|
|
1613
1559
|
const a = _(() => {
|
|
1614
|
-
const
|
|
1560
|
+
const c = r.value.value, u = i ? i(c) : c;
|
|
1615
1561
|
n.setValue(u, { emitEvent: !1 });
|
|
1616
|
-
}),
|
|
1617
|
-
return this.disposers.add(
|
|
1562
|
+
}), l = k(w.LinkFields);
|
|
1563
|
+
return this.disposers.add(l, a);
|
|
1618
1564
|
}
|
|
1619
1565
|
/**
|
|
1620
1566
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1645,12 +1591,12 @@ let x = class ae extends D {
|
|
|
1645
1591
|
*/
|
|
1646
1592
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1647
1593
|
watchField(e, t) {
|
|
1648
|
-
const
|
|
1649
|
-
if (!
|
|
1594
|
+
const i = this.getFieldByPath(e);
|
|
1595
|
+
if (!i)
|
|
1650
1596
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1651
1597
|
const r = _(() => {
|
|
1652
|
-
t(
|
|
1653
|
-
}), n =
|
|
1598
|
+
t(i.value.value);
|
|
1599
|
+
}), n = k(w.WatchField);
|
|
1654
1600
|
return this.disposers.add(n, r);
|
|
1655
1601
|
}
|
|
1656
1602
|
/**
|
|
@@ -1658,12 +1604,12 @@ let x = class ae extends D {
|
|
|
1658
1604
|
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1659
1605
|
*/
|
|
1660
1606
|
watchFieldByPath(e, t) {
|
|
1661
|
-
const
|
|
1662
|
-
if (!
|
|
1607
|
+
const i = this.getFieldByPath(e);
|
|
1608
|
+
if (!i)
|
|
1663
1609
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1664
1610
|
const r = _(() => {
|
|
1665
|
-
t(
|
|
1666
|
-
}), n =
|
|
1611
|
+
t(i.value.value);
|
|
1612
|
+
}), n = k(w.WatchField);
|
|
1667
1613
|
return this.disposers.add(n, r);
|
|
1668
1614
|
}
|
|
1669
1615
|
/**
|
|
@@ -1685,6 +1631,24 @@ let x = class ae extends D {
|
|
|
1685
1631
|
attachBehaviorCleanup(e) {
|
|
1686
1632
|
this._behaviorCleanup = e;
|
|
1687
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
|
+
}
|
|
1688
1652
|
/**
|
|
1689
1653
|
* Очистить все ресурсы узла
|
|
1690
1654
|
*/
|
|
@@ -1693,7 +1657,7 @@ let x = class ae extends D {
|
|
|
1693
1657
|
"dispose" in e && typeof e.dispose == "function" && e.dispose();
|
|
1694
1658
|
});
|
|
1695
1659
|
}
|
|
1696
|
-
},
|
|
1660
|
+
}, te = class extends L {
|
|
1697
1661
|
// ============================================================================
|
|
1698
1662
|
// Приватные поля
|
|
1699
1663
|
// ============================================================================
|
|
@@ -1731,12 +1695,12 @@ let x = class ae extends D {
|
|
|
1731
1695
|
super(), this.itemSchema = e, this.initialItems = t, this.items = y([]);
|
|
1732
1696
|
for (const r of t)
|
|
1733
1697
|
this.push(r);
|
|
1734
|
-
this.length =
|
|
1735
|
-
const
|
|
1698
|
+
this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((r) => r.value.value));
|
|
1699
|
+
const i = H({
|
|
1736
1700
|
getChildren: () => this.items.value,
|
|
1737
1701
|
ownErrors: this._arrayErrors
|
|
1738
1702
|
});
|
|
1739
|
-
this.valid =
|
|
1703
|
+
this.valid = i.valid, this.invalid = i.invalid, this.pending = i.pending, this.touched = i.touched, this.dirty = i.dirty, this.errors = i.errors, this.status = i.status;
|
|
1740
1704
|
}
|
|
1741
1705
|
// ============================================================================
|
|
1742
1706
|
// CRUD операции
|
|
@@ -1758,17 +1722,17 @@ let x = class ae extends D {
|
|
|
1758
1722
|
*/
|
|
1759
1723
|
removeAt(e) {
|
|
1760
1724
|
if (e < 0 || e >= this.items.value.length) {
|
|
1761
|
-
|
|
1725
|
+
N.handle(
|
|
1762
1726
|
new Error(
|
|
1763
1727
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1764
1728
|
),
|
|
1765
1729
|
"ArrayNode.removeAt",
|
|
1766
|
-
|
|
1730
|
+
O.LOG
|
|
1767
1731
|
);
|
|
1768
1732
|
return;
|
|
1769
1733
|
}
|
|
1770
1734
|
const t = this.items.value[e];
|
|
1771
|
-
this.items.value = this.items.value.filter((
|
|
1735
|
+
this.items.value = this.items.value.filter((i, r) => r !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1772
1736
|
}
|
|
1773
1737
|
/**
|
|
1774
1738
|
* Вставить элемент в массив
|
|
@@ -1777,17 +1741,17 @@ let x = class ae extends D {
|
|
|
1777
1741
|
*/
|
|
1778
1742
|
insert(e, t) {
|
|
1779
1743
|
if (e < 0 || e > this.items.value.length) {
|
|
1780
|
-
|
|
1744
|
+
N.handle(
|
|
1781
1745
|
new Error(
|
|
1782
1746
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1783
1747
|
),
|
|
1784
1748
|
"ArrayNode.insert",
|
|
1785
|
-
|
|
1749
|
+
O.LOG
|
|
1786
1750
|
);
|
|
1787
1751
|
return;
|
|
1788
1752
|
}
|
|
1789
|
-
const
|
|
1790
|
-
r.splice(e, 0,
|
|
1753
|
+
const i = this.createItem(t), r = [...this.items.value];
|
|
1754
|
+
r.splice(e, 0, i), this.items.value = r;
|
|
1791
1755
|
}
|
|
1792
1756
|
/**
|
|
1793
1757
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1806,12 +1770,12 @@ let x = class ae extends D {
|
|
|
1806
1770
|
* ```
|
|
1807
1771
|
*/
|
|
1808
1772
|
move(e, t) {
|
|
1809
|
-
const
|
|
1810
|
-
if (e < 0 || e >=
|
|
1811
|
-
|
|
1812
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${
|
|
1773
|
+
const i = this.items.value.length;
|
|
1774
|
+
if (e < 0 || e >= i || t < 0 || t >= i) {
|
|
1775
|
+
N.handle(
|
|
1776
|
+
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${i})`),
|
|
1813
1777
|
"ArrayNode.move",
|
|
1814
|
-
|
|
1778
|
+
O.LOG
|
|
1815
1779
|
);
|
|
1816
1780
|
return;
|
|
1817
1781
|
}
|
|
@@ -1834,12 +1798,12 @@ let x = class ae extends D {
|
|
|
1834
1798
|
* ```
|
|
1835
1799
|
*/
|
|
1836
1800
|
swap(e, t) {
|
|
1837
|
-
const
|
|
1838
|
-
if (e < 0 || e >=
|
|
1839
|
-
|
|
1840
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${
|
|
1801
|
+
const i = this.items.value.length;
|
|
1802
|
+
if (e < 0 || e >= i || t < 0 || t >= i) {
|
|
1803
|
+
N.handle(
|
|
1804
|
+
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${i})`),
|
|
1841
1805
|
"ArrayNode.swap",
|
|
1842
|
-
|
|
1806
|
+
O.LOG
|
|
1843
1807
|
);
|
|
1844
1808
|
return;
|
|
1845
1809
|
}
|
|
@@ -1876,13 +1840,13 @@ let x = class ae extends D {
|
|
|
1876
1840
|
return this.items.value.map((e) => e.getValue());
|
|
1877
1841
|
}
|
|
1878
1842
|
setValue(e, t) {
|
|
1879
|
-
this.clear(), e.forEach((
|
|
1880
|
-
|
|
1843
|
+
this.clear(), e.forEach((i) => this.push(i)), t?.emitEvent !== !1 && this.validate().catch((i) => {
|
|
1844
|
+
N.handle(i, "ArrayNode.setValue", O.LOG);
|
|
1881
1845
|
});
|
|
1882
1846
|
}
|
|
1883
1847
|
patchValue(e) {
|
|
1884
|
-
e.forEach((t,
|
|
1885
|
-
this.items.value[
|
|
1848
|
+
e.forEach((t, i) => {
|
|
1849
|
+
this.items.value[i] && t !== void 0 && this.items.value[i].patchValue(t);
|
|
1886
1850
|
});
|
|
1887
1851
|
}
|
|
1888
1852
|
/**
|
|
@@ -1937,7 +1901,7 @@ let x = class ae extends D {
|
|
|
1937
1901
|
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1938
1902
|
}
|
|
1939
1903
|
async validate() {
|
|
1940
|
-
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;
|
|
1941
1905
|
}
|
|
1942
1906
|
/**
|
|
1943
1907
|
* Установить array-level validation errors
|
|
@@ -2010,9 +1974,9 @@ let x = class ae extends D {
|
|
|
2010
1974
|
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
2011
1975
|
*/
|
|
2012
1976
|
forEach(e) {
|
|
2013
|
-
this.items.value.forEach((t,
|
|
1977
|
+
this.items.value.forEach((t, i) => {
|
|
2014
1978
|
const r = t.getProxy();
|
|
2015
|
-
e(r,
|
|
1979
|
+
e(r, i);
|
|
2016
1980
|
});
|
|
2017
1981
|
}
|
|
2018
1982
|
/**
|
|
@@ -2021,9 +1985,9 @@ let x = class ae extends D {
|
|
|
2021
1985
|
* @returns Новый массив результатов
|
|
2022
1986
|
*/
|
|
2023
1987
|
map(e) {
|
|
2024
|
-
return this.items.value.map((t,
|
|
1988
|
+
return this.items.value.map((t, i) => {
|
|
2025
1989
|
const r = t.getProxy();
|
|
2026
|
-
return e(r,
|
|
1990
|
+
return e(r, i);
|
|
2027
1991
|
});
|
|
2028
1992
|
}
|
|
2029
1993
|
// ============================================================================
|
|
@@ -2035,7 +1999,7 @@ let x = class ae extends D {
|
|
|
2035
1999
|
*/
|
|
2036
2000
|
createItem(e) {
|
|
2037
2001
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2038
|
-
const t = new
|
|
2002
|
+
const t = new P(this.itemSchema);
|
|
2039
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;
|
|
2040
2004
|
}
|
|
2041
2005
|
throw new Error(
|
|
@@ -2122,14 +2086,14 @@ let x = class ae extends D {
|
|
|
2122
2086
|
* ```
|
|
2123
2087
|
*/
|
|
2124
2088
|
watchItems(e, t) {
|
|
2125
|
-
const
|
|
2089
|
+
const i = _(() => {
|
|
2126
2090
|
const n = this.items.value.map((a) => {
|
|
2127
|
-
if (a instanceof
|
|
2091
|
+
if (a instanceof P)
|
|
2128
2092
|
return a.getFieldByPath(e)?.value.value;
|
|
2129
2093
|
});
|
|
2130
2094
|
t(n);
|
|
2131
|
-
}), r =
|
|
2132
|
-
return this.disposers.add(r,
|
|
2095
|
+
}), r = k(w.WatchItems);
|
|
2096
|
+
return this.disposers.add(r, i);
|
|
2133
2097
|
}
|
|
2134
2098
|
/**
|
|
2135
2099
|
* Подписка на изменение длины массива
|
|
@@ -2157,8 +2121,8 @@ let x = class ae extends D {
|
|
|
2157
2121
|
const t = _(() => {
|
|
2158
2122
|
const r = this.length.value;
|
|
2159
2123
|
e(r);
|
|
2160
|
-
}),
|
|
2161
|
-
return this.disposers.add(
|
|
2124
|
+
}), i = k(w.WatchLength);
|
|
2125
|
+
return this.disposers.add(i, t);
|
|
2162
2126
|
}
|
|
2163
2127
|
/**
|
|
2164
2128
|
* Очистить все ресурсы узла
|
|
@@ -2221,7 +2185,7 @@ let x = class ae extends D {
|
|
|
2221
2185
|
});
|
|
2222
2186
|
}
|
|
2223
2187
|
};
|
|
2224
|
-
class
|
|
2188
|
+
class Ne {
|
|
2225
2189
|
/**
|
|
2226
2190
|
* Создает узел формы на основе конфигурации
|
|
2227
2191
|
*
|
|
@@ -2271,14 +2235,14 @@ class ke {
|
|
|
2271
2235
|
if (Array.isArray(e) && e.length >= 1)
|
|
2272
2236
|
return this.createArrayNodeFromArray(e);
|
|
2273
2237
|
if (this.isFieldConfig(e))
|
|
2274
|
-
return new
|
|
2238
|
+
return new Se(e);
|
|
2275
2239
|
if (this.isArrayConfig(e))
|
|
2276
|
-
return new
|
|
2240
|
+
return new te(
|
|
2277
2241
|
e.schema,
|
|
2278
2242
|
e.initialItems
|
|
2279
2243
|
);
|
|
2280
2244
|
if (this.isGroupConfig(e))
|
|
2281
|
-
return new
|
|
2245
|
+
return new P(e);
|
|
2282
2246
|
throw new Error(
|
|
2283
2247
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2284
2248
|
e
|
|
@@ -2312,11 +2276,11 @@ class ke {
|
|
|
2312
2276
|
*/
|
|
2313
2277
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2314
2278
|
createArrayNodeFromArray(e) {
|
|
2315
|
-
const [t, ...
|
|
2279
|
+
const [t, ...i] = e, r = [];
|
|
2316
2280
|
this.isGroupConfig(t) && r.push(this.extractValues(t));
|
|
2317
|
-
for (const n of
|
|
2281
|
+
for (const n of i)
|
|
2318
2282
|
this.isGroupConfig(n) ? r.push(this.extractValues(n)) : r.push(n);
|
|
2319
|
-
return new
|
|
2283
|
+
return new te(t, r);
|
|
2320
2284
|
}
|
|
2321
2285
|
/**
|
|
2322
2286
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2354,8 +2318,8 @@ class ke {
|
|
|
2354
2318
|
return e.map((t) => this.extractValues(t));
|
|
2355
2319
|
if (this.isGroupConfig(e)) {
|
|
2356
2320
|
const t = {};
|
|
2357
|
-
for (const [
|
|
2358
|
-
t[
|
|
2321
|
+
for (const [i, r] of Object.entries(e))
|
|
2322
|
+
t[i] = this.extractValues(r);
|
|
2359
2323
|
return t;
|
|
2360
2324
|
}
|
|
2361
2325
|
return e;
|
|
@@ -2380,7 +2344,7 @@ class ke {
|
|
|
2380
2344
|
* ```
|
|
2381
2345
|
*/
|
|
2382
2346
|
isFieldConfig(e) {
|
|
2383
|
-
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;
|
|
2384
2348
|
}
|
|
2385
2349
|
/**
|
|
2386
2350
|
* Проверяет, является ли конфиг конфигурацией массива (ArrayConfig)
|
|
@@ -2435,28 +2399,28 @@ class ke {
|
|
|
2435
2399
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2436
2400
|
}
|
|
2437
2401
|
}
|
|
2438
|
-
function
|
|
2439
|
-
return
|
|
2402
|
+
function R(s) {
|
|
2403
|
+
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2440
2404
|
}
|
|
2441
|
-
function
|
|
2442
|
-
return
|
|
2405
|
+
function Oe(s) {
|
|
2406
|
+
return s == null ? !1 : R(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
|
|
2443
2407
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2444
|
-
typeof
|
|
2445
|
-
!("fields" in
|
|
2408
|
+
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2409
|
+
!("fields" in s) && !("items" in s);
|
|
2446
2410
|
}
|
|
2447
|
-
function
|
|
2448
|
-
return
|
|
2449
|
-
!("items" in
|
|
2411
|
+
function Fe(s) {
|
|
2412
|
+
return s == null ? !1 : R(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2413
|
+
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2450
2414
|
}
|
|
2451
|
-
function
|
|
2452
|
-
return
|
|
2453
|
-
typeof
|
|
2454
|
-
typeof
|
|
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
|
|
2417
|
+
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2418
|
+
typeof s.removeAt == "function";
|
|
2455
2419
|
}
|
|
2456
|
-
function
|
|
2457
|
-
return
|
|
2420
|
+
function Qe(s) {
|
|
2421
|
+
return Oe(s) ? "FieldNode" : Fe(s) ? "GroupNode" : Me(s) ? "ArrayNode" : R(s) ? "FormNode" : "Unknown";
|
|
2458
2422
|
}
|
|
2459
|
-
class
|
|
2423
|
+
class Pe extends L {
|
|
2460
2424
|
/**
|
|
2461
2425
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2462
2426
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
@@ -2464,24 +2428,33 @@ class Fe extends D {
|
|
|
2464
2428
|
*/
|
|
2465
2429
|
constructor(e, t) {
|
|
2466
2430
|
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = _(() => {
|
|
2467
|
-
const r = e.length, n = [];
|
|
2468
|
-
for (let
|
|
2469
|
-
const
|
|
2470
|
-
if (!
|
|
2471
|
-
let
|
|
2472
|
-
|
|
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);
|
|
2473
2437
|
}
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
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));
|
|
2446
|
+
const i = H({
|
|
2477
2447
|
getChildren: () => this.itemNodes.value,
|
|
2478
2448
|
ownErrors: this._arrayErrors
|
|
2479
2449
|
});
|
|
2480
|
-
this.valid =
|
|
2450
|
+
this.valid = i.valid, this.invalid = i.invalid, this.pending = i.pending, this.touched = i.touched, this.dirty = i.dirty, this.errors = i.errors, this.status = i.status;
|
|
2481
2451
|
}
|
|
2482
2452
|
itemNodes = y([]);
|
|
2483
2453
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
2484
2454
|
cache = /* @__PURE__ */ new WeakMap();
|
|
2455
|
+
// Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
|
|
2456
|
+
// реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
|
|
2457
|
+
mountedModels = [];
|
|
2485
2458
|
initial;
|
|
2486
2459
|
_arrayErrors = y([]);
|
|
2487
2460
|
disposeSync;
|
|
@@ -2506,10 +2479,10 @@ class Fe extends D {
|
|
|
2506
2479
|
return this.itemNodes.value[e];
|
|
2507
2480
|
}
|
|
2508
2481
|
map(e) {
|
|
2509
|
-
return this.itemNodes.value.map((t,
|
|
2482
|
+
return this.itemNodes.value.map((t, i) => e(t, i));
|
|
2510
2483
|
}
|
|
2511
2484
|
forEach(e) {
|
|
2512
|
-
this.itemNodes.value.forEach((t,
|
|
2485
|
+
this.itemNodes.value.forEach((t, i) => e(t, i));
|
|
2513
2486
|
}
|
|
2514
2487
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2515
2488
|
push(e) {
|
|
@@ -2596,104 +2569,201 @@ class Fe extends D {
|
|
|
2596
2569
|
onEnable() {
|
|
2597
2570
|
this.itemNodes.value.forEach((e) => e.enable?.());
|
|
2598
2571
|
}
|
|
2599
|
-
/**
|
|
2572
|
+
/** Диспозит форму элемента (эффекты/поведения/вложенные подписки); терпима к не-GroupNode. */
|
|
2573
|
+
disposeItemNode(e) {
|
|
2574
|
+
e.dispose?.();
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Очистка подписки синхронизации И детерминированный teardown всех форм элементов.
|
|
2578
|
+
* Без пробрасывания dispose в itemNodes эффекты/поведения каждой формы элемента (в т.ч. disposeSync
|
|
2579
|
+
* вложенных ModelArrayNode) остались бы жить после teardown формы — утечка подписок.
|
|
2580
|
+
*/
|
|
2600
2581
|
dispose() {
|
|
2601
|
-
this.disposeSync();
|
|
2582
|
+
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2602
2583
|
}
|
|
2603
2584
|
}
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
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) {
|
|
2590
|
+
if (s == null || typeof s != "object") return;
|
|
2591
|
+
if (Array.isArray(s)) {
|
|
2592
|
+
for (const a of s) F(a, e, t, i, r);
|
|
2609
2593
|
return;
|
|
2610
2594
|
}
|
|
2611
|
-
const
|
|
2612
|
-
if (
|
|
2613
|
-
|
|
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);
|
|
2614
2599
|
return;
|
|
2615
2600
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
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;
|
|
2627
2655
|
}
|
|
2628
|
-
function
|
|
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);
|
|
2669
|
+
return;
|
|
2670
|
+
}
|
|
2671
|
+
const i = s, r = i.array;
|
|
2672
|
+
if (r && typeof r.__path == "string" && typeof i.item == "function") {
|
|
2673
|
+
t.set(r.__path, i.item);
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
i.value instanceof oe ? e.set(i.value, {
|
|
2677
|
+
component: i.component,
|
|
2678
|
+
componentProps: i.componentProps,
|
|
2679
|
+
validators: i.validators,
|
|
2680
|
+
asyncValidators: i.asyncValidators,
|
|
2681
|
+
updateOn: i.updateOn,
|
|
2682
|
+
disabled: i.disabled,
|
|
2683
|
+
debounce: i.debounce
|
|
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
|
+
);
|
|
2687
|
+
for (const [n, a] of Object.entries(i))
|
|
2688
|
+
n !== "value" && U(a, e, t);
|
|
2689
|
+
}
|
|
2690
|
+
function fe(s, e, t, i) {
|
|
2629
2691
|
const r = {};
|
|
2630
2692
|
for (const [n, a] of Object.entries(e)) {
|
|
2631
|
-
const
|
|
2693
|
+
const l = t === "" ? n : `${t}.${n}`;
|
|
2632
2694
|
if (Array.isArray(a))
|
|
2633
2695
|
continue;
|
|
2634
|
-
if (
|
|
2635
|
-
r[n] =
|
|
2696
|
+
if (de(a)) {
|
|
2697
|
+
r[n] = fe(s, a, l, i);
|
|
2636
2698
|
continue;
|
|
2637
2699
|
}
|
|
2638
|
-
const
|
|
2639
|
-
if (!
|
|
2640
|
-
const u =
|
|
2641
|
-
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 };
|
|
2642
2704
|
}
|
|
2643
2705
|
return r;
|
|
2644
2706
|
}
|
|
2645
|
-
function
|
|
2646
|
-
for (const [
|
|
2647
|
-
const n = e === "" ?
|
|
2648
|
-
Array.isArray(r) || (
|
|
2707
|
+
function pe(s, e, t) {
|
|
2708
|
+
for (const [i, r] of Object.entries(s)) {
|
|
2709
|
+
const n = e === "" ? i : `${e}.${i}`;
|
|
2710
|
+
Array.isArray(r) || (de(r) ? pe(r, n, t) : t.push(n));
|
|
2649
2711
|
}
|
|
2650
2712
|
}
|
|
2651
|
-
function
|
|
2652
|
-
const { model: e, schema: t, behavior:
|
|
2653
|
-
t !== void 0 &&
|
|
2654
|
-
const a =
|
|
2655
|
-
for (const [
|
|
2656
|
-
if (!Array.isArray(
|
|
2657
|
-
const
|
|
2658
|
-
if (!
|
|
2659
|
-
const p = e[
|
|
2660
|
-
|
|
2661
|
-
}
|
|
2662
|
-
const u =
|
|
2663
|
-
|
|
2664
|
-
for (const
|
|
2665
|
-
const
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2713
|
+
function ve(s) {
|
|
2714
|
+
const { model: e, schema: t, behavior: i } = s, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
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;
|
|
2669
2739
|
}
|
|
2670
|
-
const
|
|
2671
|
-
function
|
|
2672
|
-
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();
|
|
2673
2743
|
}
|
|
2674
|
-
const
|
|
2675
|
-
if (Array.isArray(
|
|
2676
|
-
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)) {
|
|
2677
2747
|
const e = {};
|
|
2678
|
-
for (const t of Object.keys(
|
|
2748
|
+
for (const t of Object.keys(s)) e[t] = S(s[t]);
|
|
2679
2749
|
return e;
|
|
2680
2750
|
}
|
|
2681
|
-
return
|
|
2682
|
-
},
|
|
2683
|
-
if (
|
|
2684
|
-
if (Array.isArray(
|
|
2685
|
-
return
|
|
2686
|
-
if (
|
|
2687
|
-
const t = Object.keys(
|
|
2688
|
-
return t.length !==
|
|
2751
|
+
return s;
|
|
2752
|
+
}, I = (s, e) => {
|
|
2753
|
+
if (s === e) return !0;
|
|
2754
|
+
if (Array.isArray(s) && Array.isArray(e))
|
|
2755
|
+
return s.length !== e.length ? !1 : s.every((t, i) => I(t, e[i]));
|
|
2756
|
+
if (T(s) && T(e)) {
|
|
2757
|
+
const t = Object.keys(s), i = Object.keys(e);
|
|
2758
|
+
return t.length !== i.length ? !1 : t.every((r) => I(s[r], e[r]));
|
|
2689
2759
|
}
|
|
2690
2760
|
return !1;
|
|
2691
2761
|
};
|
|
2692
|
-
class
|
|
2762
|
+
class De {
|
|
2693
2763
|
constructor(e, t) {
|
|
2694
2764
|
this.path = t;
|
|
2695
|
-
const
|
|
2696
|
-
|
|
2765
|
+
const i = y(e);
|
|
2766
|
+
i.__path = t, this.signal = i, this.initial = S(e);
|
|
2697
2767
|
}
|
|
2698
2768
|
kind = "leaf";
|
|
2699
2769
|
signal;
|
|
@@ -2713,37 +2783,37 @@ class Pe {
|
|
|
2713
2783
|
this.signal.value = e;
|
|
2714
2784
|
}
|
|
2715
2785
|
resetToInitial() {
|
|
2716
|
-
this.signal.value =
|
|
2786
|
+
this.signal.value = S(this.initial);
|
|
2717
2787
|
}
|
|
2718
2788
|
captureInitial() {
|
|
2719
|
-
this.initial =
|
|
2789
|
+
this.initial = S(this.signal.peek());
|
|
2720
2790
|
}
|
|
2721
2791
|
dirty() {
|
|
2722
|
-
return !
|
|
2792
|
+
return !I(this.signal.peek(), this.initial);
|
|
2723
2793
|
}
|
|
2724
2794
|
}
|
|
2725
|
-
class
|
|
2795
|
+
class me {
|
|
2726
2796
|
constructor(e, t) {
|
|
2727
2797
|
this.path = t;
|
|
2728
|
-
for (const
|
|
2729
|
-
this.children.set(
|
|
2798
|
+
for (const i of Object.keys(e))
|
|
2799
|
+
this.children.set(i, x(e[i], A(t, i)));
|
|
2730
2800
|
}
|
|
2731
2801
|
kind = "group";
|
|
2732
2802
|
children = /* @__PURE__ */ new Map();
|
|
2733
2803
|
rebase(e) {
|
|
2734
2804
|
this.path = e;
|
|
2735
|
-
for (const [t,
|
|
2805
|
+
for (const [t, i] of this.children) i.rebase(A(e, t));
|
|
2736
2806
|
}
|
|
2737
2807
|
peek() {
|
|
2738
2808
|
const e = {};
|
|
2739
|
-
for (const [t,
|
|
2809
|
+
for (const [t, i] of this.children) e[t] = i.peek();
|
|
2740
2810
|
return e;
|
|
2741
2811
|
}
|
|
2742
2812
|
set(e) {
|
|
2743
2813
|
if (e == null || typeof e != "object") return;
|
|
2744
2814
|
const t = e;
|
|
2745
|
-
for (const [
|
|
2746
|
-
|
|
2815
|
+
for (const [i, r] of this.children)
|
|
2816
|
+
i in t && (r.kind === "leaf" && G(r.signal) || r.set(t[i]));
|
|
2747
2817
|
}
|
|
2748
2818
|
resetToInitial() {
|
|
2749
2819
|
for (const e of this.children.values()) e.resetToInitial();
|
|
@@ -2756,38 +2826,38 @@ class he {
|
|
|
2756
2826
|
return !1;
|
|
2757
2827
|
}
|
|
2758
2828
|
}
|
|
2759
|
-
class
|
|
2829
|
+
class Le {
|
|
2760
2830
|
constructor(e, t) {
|
|
2761
|
-
this.path = t, this.items = y(e.map((
|
|
2831
|
+
this.path = t, this.items = y(e.map((i, r) => x(i, A(t, r)))), this.initial = S(e);
|
|
2762
2832
|
}
|
|
2763
2833
|
kind = "array";
|
|
2764
2834
|
items;
|
|
2765
2835
|
initial;
|
|
2766
2836
|
rebase(e) {
|
|
2767
|
-
this.path = e, this.items.peek().forEach((t,
|
|
2837
|
+
this.path = e, this.items.peek().forEach((t, i) => t.rebase(A(e, i)));
|
|
2768
2838
|
}
|
|
2769
2839
|
reindex() {
|
|
2770
2840
|
this.items.peek().forEach((e, t) => e.rebase(A(this.path, t)));
|
|
2771
2841
|
}
|
|
2772
2842
|
push(e) {
|
|
2773
2843
|
const t = this.items.peek();
|
|
2774
|
-
this.items.value = [...t,
|
|
2844
|
+
this.items.value = [...t, x(e, A(this.path, t.length))];
|
|
2775
2845
|
}
|
|
2776
2846
|
insertAt(e, t) {
|
|
2777
|
-
const
|
|
2778
|
-
|
|
2847
|
+
const i = [...this.items.peek()];
|
|
2848
|
+
i.splice(e, 0, x(t, A(this.path, e))), this.items.value = i, this.reindex();
|
|
2779
2849
|
}
|
|
2780
2850
|
removeAt(e) {
|
|
2781
2851
|
const t = [...this.items.peek()];
|
|
2782
2852
|
t.splice(e, 1), this.items.value = t, this.reindex();
|
|
2783
2853
|
}
|
|
2784
2854
|
move(e, t) {
|
|
2785
|
-
const
|
|
2786
|
-
r &&
|
|
2855
|
+
const i = [...this.items.peek()], [r] = i.splice(e, 1);
|
|
2856
|
+
r && i.splice(t, 0, r), this.items.value = i, this.reindex();
|
|
2787
2857
|
}
|
|
2788
2858
|
swap(e, t) {
|
|
2789
|
-
const
|
|
2790
|
-
e < 0 || t < 0 || e >=
|
|
2859
|
+
const i = [...this.items.peek()];
|
|
2860
|
+
e < 0 || t < 0 || e >= i.length || t >= i.length || e === t || ([i[e], i[t]] = [i[t], i[e]], this.items.value = i, this.reindex());
|
|
2791
2861
|
}
|
|
2792
2862
|
clear() {
|
|
2793
2863
|
this.items.value = [];
|
|
@@ -2797,88 +2867,88 @@ class Me {
|
|
|
2797
2867
|
}
|
|
2798
2868
|
set(e) {
|
|
2799
2869
|
const t = Array.isArray(e) ? e : [];
|
|
2800
|
-
this.items.value = t.map((
|
|
2870
|
+
this.items.value = t.map((i, r) => x(i, A(this.path, r)));
|
|
2801
2871
|
}
|
|
2802
2872
|
resetToInitial() {
|
|
2803
|
-
this.set(
|
|
2873
|
+
this.set(S(this.initial));
|
|
2804
2874
|
}
|
|
2805
2875
|
captureInitial() {
|
|
2806
|
-
this.initial =
|
|
2876
|
+
this.initial = S(this.peek());
|
|
2807
2877
|
}
|
|
2808
2878
|
dirty() {
|
|
2809
|
-
return !
|
|
2879
|
+
return !I(this.peek(), this.initial);
|
|
2810
2880
|
}
|
|
2811
2881
|
}
|
|
2812
|
-
function
|
|
2813
|
-
return Array.isArray(
|
|
2882
|
+
function x(s, e) {
|
|
2883
|
+
return Array.isArray(s) ? new Le(s, e) : T(s) ? new me(s, e) : new De(s, e);
|
|
2814
2884
|
}
|
|
2815
|
-
function
|
|
2816
|
-
if (
|
|
2817
|
-
return
|
|
2885
|
+
function D(s) {
|
|
2886
|
+
if (s)
|
|
2887
|
+
return s.kind === "leaf" ? s.read() : s.kind === "group" ? Re(s) : ye(s);
|
|
2818
2888
|
}
|
|
2819
|
-
function
|
|
2889
|
+
function Re(s) {
|
|
2820
2890
|
return new Proxy(
|
|
2821
2891
|
{},
|
|
2822
2892
|
{
|
|
2823
|
-
get: (e, t) => t === "__path" ?
|
|
2824
|
-
set: (e, t,
|
|
2893
|
+
get: (e, t) => t === "__path" ? s.path : typeof t == "string" ? D(s.children.get(t)) : void 0,
|
|
2894
|
+
set: (e, t, i) => {
|
|
2825
2895
|
if (typeof t != "string") return !1;
|
|
2826
|
-
const r =
|
|
2827
|
-
return r && r.set(
|
|
2896
|
+
const r = s.children.get(t);
|
|
2897
|
+
return r && r.set(i), !0;
|
|
2828
2898
|
},
|
|
2829
|
-
has: (e, t) => typeof t == "string" &&
|
|
2830
|
-
ownKeys: () => [...
|
|
2831
|
-
getOwnPropertyDescriptor: (e, t) => typeof t == "string" &&
|
|
2899
|
+
has: (e, t) => typeof t == "string" && s.children.has(t),
|
|
2900
|
+
ownKeys: () => [...s.children.keys()],
|
|
2901
|
+
getOwnPropertyDescriptor: (e, t) => typeof t == "string" && s.children.has(t) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2832
2902
|
}
|
|
2833
2903
|
);
|
|
2834
2904
|
}
|
|
2835
|
-
function
|
|
2836
|
-
if (
|
|
2837
|
-
return
|
|
2905
|
+
function $(s) {
|
|
2906
|
+
if (s)
|
|
2907
|
+
return s.kind === "group" ? ge(s) : s.kind === "array" ? ye(s) : s.read();
|
|
2838
2908
|
}
|
|
2839
|
-
function
|
|
2909
|
+
function ye(s) {
|
|
2840
2910
|
const e = {
|
|
2841
2911
|
get length() {
|
|
2842
|
-
return
|
|
2912
|
+
return s.items.value.length;
|
|
2843
2913
|
},
|
|
2844
|
-
push: (t) =>
|
|
2845
|
-
insertAt: (t,
|
|
2846
|
-
removeAt: (t) =>
|
|
2847
|
-
move: (t,
|
|
2848
|
-
swap: (t,
|
|
2849
|
-
clear: () =>
|
|
2850
|
-
at: (t) =>
|
|
2851
|
-
map: (t) =>
|
|
2852
|
-
forEach: (t) =>
|
|
2853
|
-
toArray: () =>
|
|
2914
|
+
push: (t) => s.push(t),
|
|
2915
|
+
insertAt: (t, i) => s.insertAt(t, i),
|
|
2916
|
+
removeAt: (t) => s.removeAt(t),
|
|
2917
|
+
move: (t, i) => s.move(t, i),
|
|
2918
|
+
swap: (t, i) => s.swap(t, i),
|
|
2919
|
+
clear: () => s.clear(),
|
|
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)),
|
|
2923
|
+
toArray: () => s.peek(),
|
|
2854
2924
|
[Symbol.iterator]: function* () {
|
|
2855
|
-
const t =
|
|
2856
|
-
for (let
|
|
2925
|
+
const t = s.items.value;
|
|
2926
|
+
for (let i = 0; i < t.length; i++) yield D(t[i]);
|
|
2857
2927
|
}
|
|
2858
2928
|
};
|
|
2859
2929
|
return new Proxy(e, {
|
|
2860
|
-
get: (t,
|
|
2861
|
-
has: (t,
|
|
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)
|
|
2862
2932
|
});
|
|
2863
2933
|
}
|
|
2864
|
-
function
|
|
2865
|
-
if (
|
|
2866
|
-
if (
|
|
2934
|
+
function q(s) {
|
|
2935
|
+
if (s.kind === "leaf") return s.signal;
|
|
2936
|
+
if (s.kind === "group")
|
|
2867
2937
|
return new Proxy(
|
|
2868
2938
|
{},
|
|
2869
2939
|
{
|
|
2870
|
-
get: (t,
|
|
2871
|
-
if (
|
|
2872
|
-
if (typeof
|
|
2873
|
-
const r =
|
|
2874
|
-
return r ?
|
|
2940
|
+
get: (t, i) => {
|
|
2941
|
+
if (i === "__path") return s.path;
|
|
2942
|
+
if (typeof i != "string") return;
|
|
2943
|
+
const r = s.children.get(i);
|
|
2944
|
+
return r ? q(r) : void 0;
|
|
2875
2945
|
},
|
|
2876
|
-
has: (t,
|
|
2877
|
-
ownKeys: () => [...
|
|
2878
|
-
getOwnPropertyDescriptor: (t,
|
|
2946
|
+
has: (t, i) => typeof i == "string" && s.children.has(i),
|
|
2947
|
+
ownKeys: () => [...s.children.keys()],
|
|
2948
|
+
getOwnPropertyDescriptor: (t, i) => typeof i == "string" && s.children.has(i) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2879
2949
|
}
|
|
2880
2950
|
);
|
|
2881
|
-
const e =
|
|
2951
|
+
const e = s;
|
|
2882
2952
|
return new Proxy(
|
|
2883
2953
|
{
|
|
2884
2954
|
get length() {
|
|
@@ -2886,29 +2956,29 @@ function W(i) {
|
|
|
2886
2956
|
}
|
|
2887
2957
|
},
|
|
2888
2958
|
{
|
|
2889
|
-
get: (t,
|
|
2890
|
-
if (
|
|
2891
|
-
if (typeof
|
|
2892
|
-
const n = e.items.value[Number(
|
|
2893
|
-
return n ?
|
|
2959
|
+
get: (t, i, r) => {
|
|
2960
|
+
if (i === "__path") return e.path;
|
|
2961
|
+
if (typeof i == "string" && W(i)) {
|
|
2962
|
+
const n = e.items.value[Number(i)];
|
|
2963
|
+
return n ? q(n) : void 0;
|
|
2894
2964
|
}
|
|
2895
|
-
return Reflect.get(t,
|
|
2965
|
+
return Reflect.get(t, i, r);
|
|
2896
2966
|
}
|
|
2897
2967
|
}
|
|
2898
2968
|
);
|
|
2899
2969
|
}
|
|
2900
|
-
function
|
|
2970
|
+
function $e(s, e) {
|
|
2901
2971
|
if (!e) return;
|
|
2902
|
-
let t =
|
|
2903
|
-
for (const
|
|
2972
|
+
let t = s;
|
|
2973
|
+
for (const i of e.split(".")) {
|
|
2904
2974
|
if (!t) return;
|
|
2905
|
-
if (t.kind === "group") t = t.children.get(
|
|
2906
|
-
else if (t.kind === "array") t = t.items.peek()[Number(
|
|
2975
|
+
if (t.kind === "group") t = t.children.get(i);
|
|
2976
|
+
else if (t.kind === "array") t = t.items.peek()[Number(i)];
|
|
2907
2977
|
else return;
|
|
2908
2978
|
}
|
|
2909
2979
|
return t && t.kind === "leaf" ? t.signal : void 0;
|
|
2910
2980
|
}
|
|
2911
|
-
const
|
|
2981
|
+
const se = /* @__PURE__ */ new Set([
|
|
2912
2982
|
"$",
|
|
2913
2983
|
"get",
|
|
2914
2984
|
"set",
|
|
@@ -2917,285 +2987,216 @@ const Z = /* @__PURE__ */ new Set([
|
|
|
2917
2987
|
"reset",
|
|
2918
2988
|
"captureInitial",
|
|
2919
2989
|
"signalAt"
|
|
2920
|
-
]),
|
|
2921
|
-
function
|
|
2922
|
-
const e =
|
|
2990
|
+
]), ie = /* @__PURE__ */ new WeakMap();
|
|
2991
|
+
function ge(s) {
|
|
2992
|
+
const e = ie.get(s);
|
|
2923
2993
|
if (e) return e;
|
|
2924
2994
|
const t = {
|
|
2925
|
-
$:
|
|
2926
|
-
get: () =>
|
|
2927
|
-
set: (r) =>
|
|
2928
|
-
patch: (r) =>
|
|
2929
|
-
isDirty: () =>
|
|
2930
|
-
reset: () =>
|
|
2931
|
-
captureInitial: () =>
|
|
2932
|
-
signalAt: (r) =>
|
|
2933
|
-
},
|
|
2995
|
+
$: q(s),
|
|
2996
|
+
get: () => s.peek(),
|
|
2997
|
+
set: (r) => s.set(r),
|
|
2998
|
+
patch: (r) => s.set(r),
|
|
2999
|
+
isDirty: () => s.dirty(),
|
|
3000
|
+
reset: () => s.resetToInitial(),
|
|
3001
|
+
captureInitial: () => s.captureInitial(),
|
|
3002
|
+
signalAt: (r) => $e(s, r)
|
|
3003
|
+
}, i = new Proxy(
|
|
2934
3004
|
{},
|
|
2935
3005
|
{
|
|
2936
3006
|
get: (r, n) => {
|
|
2937
3007
|
if (typeof n != "string") return;
|
|
2938
|
-
const a =
|
|
2939
|
-
if (a) return
|
|
2940
|
-
if (
|
|
3008
|
+
const a = s.children.get(n);
|
|
3009
|
+
if (a) return D(a);
|
|
3010
|
+
if (se.has(n)) return t[n];
|
|
2941
3011
|
},
|
|
2942
3012
|
set: (r, n, a) => {
|
|
2943
3013
|
if (typeof n != "string") return !1;
|
|
2944
|
-
const
|
|
2945
|
-
return
|
|
3014
|
+
const l = s.children.get(n);
|
|
3015
|
+
return l ? (l.set(a), !0) : !1;
|
|
2946
3016
|
},
|
|
2947
|
-
has: (r, n) => typeof n == "string" && (
|
|
2948
|
-
ownKeys: () => [...
|
|
2949
|
-
getOwnPropertyDescriptor: (r, n) => typeof n == "string" &&
|
|
3017
|
+
has: (r, n) => typeof n == "string" && (s.children.has(n) || se.has(n)),
|
|
3018
|
+
ownKeys: () => [...s.children.keys()],
|
|
3019
|
+
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && s.children.has(n) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2950
3020
|
}
|
|
2951
3021
|
);
|
|
2952
|
-
return
|
|
3022
|
+
return ie.set(s, i), i;
|
|
2953
3023
|
}
|
|
2954
|
-
function
|
|
2955
|
-
const e = new
|
|
2956
|
-
return
|
|
3024
|
+
function tt(s) {
|
|
3025
|
+
const e = new me(s, "");
|
|
3026
|
+
return ge(e);
|
|
2957
3027
|
}
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
const a = s && !!n.when(e, t);
|
|
2971
|
-
for (const o of n.children) N(o, e, t, a, r);
|
|
2972
|
-
return;
|
|
2973
|
-
}
|
|
2974
|
-
if (De(n)) {
|
|
2975
|
-
const a = n.componentProps.control, o = n.componentProps.itemComponent, l = a.length;
|
|
2976
|
-
for (let u = 0; u < l; u++) {
|
|
2977
|
-
const m = a.at(u);
|
|
2978
|
-
N(o(m), m, t, s, r);
|
|
2979
|
-
}
|
|
2980
|
-
return;
|
|
2981
|
-
}
|
|
2982
|
-
if (n.value instanceof re) {
|
|
2983
|
-
const a = n.validators ?? [];
|
|
2984
|
-
a.length > 0 && (s ? r.tasks.push({ signal: n.value, validators: a, scope: e }) : r.clearSignals.push(n.value));
|
|
2985
|
-
for (const [o, l] of Object.entries(n))
|
|
2986
|
-
o === "value" || o === "validators" || N(l, e, t, s, r);
|
|
2987
|
-
return;
|
|
2988
|
-
}
|
|
2989
|
-
for (const a of Object.values(n)) N(a, e, t, s, r);
|
|
2990
|
-
}
|
|
2991
|
-
function z(i, e) {
|
|
2992
|
-
const t = { tasks: [], clearSignals: [] };
|
|
2993
|
-
return N(e, i, i, !0, t), t;
|
|
2994
|
-
}
|
|
2995
|
-
const pe = (i, e, t) => {
|
|
2996
|
-
(i[e] ??= []).push(t);
|
|
2997
|
-
};
|
|
2998
|
-
function Qe(i, e) {
|
|
2999
|
-
const { tasks: t } = z(i, e), s = {};
|
|
3000
|
-
for (const { signal: r, validators: n, scope: a } of t) {
|
|
3001
|
-
const o = r.peek();
|
|
3002
|
-
for (const l of n) {
|
|
3003
|
-
const u = l(o, a, i);
|
|
3004
|
-
u && typeof u.then == "function" || u && pe(s, r.__path, u);
|
|
3005
|
-
}
|
|
3006
|
-
}
|
|
3007
|
-
return { valid: Object.keys(s).length === 0, errors: s };
|
|
3008
|
-
}
|
|
3009
|
-
async function Xe(i, e) {
|
|
3010
|
-
const { tasks: t } = z(i, e), s = await ve(t, i);
|
|
3011
|
-
return { valid: Object.keys(s).length === 0, errors: s };
|
|
3012
|
-
}
|
|
3013
|
-
async function ve(i, e) {
|
|
3014
|
-
const t = {};
|
|
3015
|
-
return await Promise.all(
|
|
3016
|
-
i.map(async ({ signal: s, validators: r, scope: n }) => {
|
|
3017
|
-
const a = s.peek();
|
|
3018
|
-
for (const o of r) {
|
|
3019
|
-
const l = await o(a, n, e);
|
|
3020
|
-
l && pe(t, s.__path, l);
|
|
3021
|
-
}
|
|
3022
|
-
})
|
|
3023
|
-
), t;
|
|
3024
|
-
}
|
|
3025
|
-
async function Ze(i, e) {
|
|
3026
|
-
const { tasks: t, clearSignals: s } = z(i, e), r = await ve(t, i);
|
|
3027
|
-
for (const { signal: n } of t)
|
|
3028
|
-
Q(n)?.setErrors(r[n.__path] ?? []);
|
|
3029
|
-
for (const n of s)
|
|
3030
|
-
Q(n)?.setErrors([]);
|
|
3031
|
-
return { valid: Object.keys(r).length === 0, errors: r };
|
|
3032
|
-
}
|
|
3033
|
-
var P = { exports: {} }, R = {};
|
|
3034
|
-
var te;
|
|
3035
|
-
function Le() {
|
|
3036
|
-
if (te) return R;
|
|
3037
|
-
te = 1;
|
|
3038
|
-
var i = ne;
|
|
3039
|
-
function e(c, f) {
|
|
3040
|
-
return c === f && (c !== 0 || 1 / c === 1 / f) || c !== c && f !== f;
|
|
3041
|
-
}
|
|
3042
|
-
var t = typeof Object.is == "function" ? Object.is : e, s = i.useState, r = i.useEffect, n = i.useLayoutEffect, a = i.useDebugValue;
|
|
3043
|
-
function o(c, f) {
|
|
3044
|
-
var d = f(), p = s({ inst: { value: d, getSnapshot: f } }), v = p[0].inst, g = p[1];
|
|
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;
|
|
3036
|
+
}
|
|
3037
|
+
var t = typeof Object.is == "function" ? Object.is : e, i = s.useState, r = s.useEffect, n = s.useLayoutEffect, a = s.useDebugValue;
|
|
3038
|
+
function l(o, v) {
|
|
3039
|
+
var h = v(), p = i({ inst: { value: h, getSnapshot: v } }), m = p[0].inst, b = p[1];
|
|
3045
3040
|
return n(
|
|
3046
3041
|
function() {
|
|
3047
|
-
|
|
3042
|
+
m.value = h, m.getSnapshot = v, c(m) && b({ inst: m });
|
|
3048
3043
|
},
|
|
3049
|
-
[
|
|
3044
|
+
[o, h, v]
|
|
3050
3045
|
), r(
|
|
3051
3046
|
function() {
|
|
3052
|
-
return
|
|
3053
|
-
|
|
3047
|
+
return c(m) && b({ inst: m }), o(function() {
|
|
3048
|
+
c(m) && b({ inst: m });
|
|
3054
3049
|
});
|
|
3055
3050
|
},
|
|
3056
|
-
[
|
|
3057
|
-
), a(
|
|
3051
|
+
[o]
|
|
3052
|
+
), a(h), h;
|
|
3058
3053
|
}
|
|
3059
|
-
function
|
|
3060
|
-
var
|
|
3061
|
-
|
|
3054
|
+
function c(o) {
|
|
3055
|
+
var v = o.getSnapshot;
|
|
3056
|
+
o = o.value;
|
|
3062
3057
|
try {
|
|
3063
|
-
var
|
|
3064
|
-
return !t(
|
|
3058
|
+
var h = v();
|
|
3059
|
+
return !t(o, h);
|
|
3065
3060
|
} catch {
|
|
3066
3061
|
return !0;
|
|
3067
3062
|
}
|
|
3068
3063
|
}
|
|
3069
|
-
function u(
|
|
3070
|
-
return
|
|
3064
|
+
function u(o, v) {
|
|
3065
|
+
return v();
|
|
3071
3066
|
}
|
|
3072
|
-
var
|
|
3073
|
-
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;
|
|
3074
3069
|
}
|
|
3075
|
-
var
|
|
3076
|
-
var
|
|
3077
|
-
function
|
|
3078
|
-
return
|
|
3079
|
-
function
|
|
3080
|
-
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;
|
|
3081
3076
|
}
|
|
3082
|
-
function e(
|
|
3083
|
-
|
|
3077
|
+
function e(h, p) {
|
|
3078
|
+
d || r.startTransition === void 0 || (d = !0, console.error(
|
|
3084
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."
|
|
3085
3080
|
));
|
|
3086
|
-
var
|
|
3087
|
-
if (!
|
|
3088
|
-
var
|
|
3089
|
-
n(
|
|
3081
|
+
var m = p();
|
|
3082
|
+
if (!o) {
|
|
3083
|
+
var b = p();
|
|
3084
|
+
n(m, b) || (console.error(
|
|
3090
3085
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
3091
|
-
),
|
|
3086
|
+
), o = !0);
|
|
3092
3087
|
}
|
|
3093
|
-
|
|
3094
|
-
inst: { value:
|
|
3088
|
+
b = a({
|
|
3089
|
+
inst: { value: m, getSnapshot: p }
|
|
3095
3090
|
});
|
|
3096
|
-
var
|
|
3097
|
-
return
|
|
3091
|
+
var g = b[0].inst, V = b[1];
|
|
3092
|
+
return c(
|
|
3098
3093
|
function() {
|
|
3099
|
-
|
|
3094
|
+
g.value = m, g.getSnapshot = p, t(g) && V({ inst: g });
|
|
3100
3095
|
},
|
|
3101
|
-
[
|
|
3102
|
-
),
|
|
3096
|
+
[h, m, p]
|
|
3097
|
+
), l(
|
|
3103
3098
|
function() {
|
|
3104
|
-
return t(
|
|
3105
|
-
t(
|
|
3099
|
+
return t(g) && V({ inst: g }), h(function() {
|
|
3100
|
+
t(g) && V({ inst: g });
|
|
3106
3101
|
});
|
|
3107
3102
|
},
|
|
3108
|
-
[
|
|
3109
|
-
), u(
|
|
3103
|
+
[h]
|
|
3104
|
+
), u(m), m;
|
|
3110
3105
|
}
|
|
3111
|
-
function t(
|
|
3112
|
-
var p =
|
|
3113
|
-
|
|
3106
|
+
function t(h) {
|
|
3107
|
+
var p = h.getSnapshot;
|
|
3108
|
+
h = h.value;
|
|
3114
3109
|
try {
|
|
3115
|
-
var
|
|
3116
|
-
return !n(
|
|
3110
|
+
var m = p();
|
|
3111
|
+
return !n(h, m);
|
|
3117
3112
|
} catch {
|
|
3118
3113
|
return !0;
|
|
3119
3114
|
}
|
|
3120
3115
|
}
|
|
3121
|
-
function
|
|
3116
|
+
function i(h, p) {
|
|
3122
3117
|
return p();
|
|
3123
3118
|
}
|
|
3124
3119
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
3125
|
-
var r =
|
|
3126
|
-
|
|
3127
|
-
})()),
|
|
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;
|
|
3128
3123
|
}
|
|
3129
|
-
var
|
|
3130
|
-
function
|
|
3131
|
-
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;
|
|
3132
3127
|
}
|
|
3133
|
-
var
|
|
3134
|
-
function
|
|
3135
|
-
if (
|
|
3136
|
-
if (
|
|
3137
|
-
for (let t = 0; t <
|
|
3138
|
-
if (
|
|
3128
|
+
var Y = Ge();
|
|
3129
|
+
function Ue(s, e) {
|
|
3130
|
+
if (s === e) return !0;
|
|
3131
|
+
if (s.length !== e.length) return !1;
|
|
3132
|
+
for (let t = 0; t < s.length; t++)
|
|
3133
|
+
if (s[t] !== e[t]) return !1;
|
|
3139
3134
|
return !0;
|
|
3140
3135
|
}
|
|
3141
|
-
function
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
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 = {};
|
|
3144
|
+
for (const o in s)
|
|
3145
|
+
d[o] = s[o].value;
|
|
3146
|
+
r.current = { ...d, __snapshot: null };
|
|
3147
|
+
}
|
|
3148
|
+
const c = E(
|
|
3149
|
+
(d) => {
|
|
3151
3150
|
let o = !0;
|
|
3152
3151
|
return _(() => {
|
|
3153
|
-
|
|
3154
|
-
|
|
3152
|
+
const h = n.current;
|
|
3153
|
+
for (const p in h)
|
|
3154
|
+
h[p].value;
|
|
3155
3155
|
if (o) {
|
|
3156
3156
|
o = !1;
|
|
3157
3157
|
return;
|
|
3158
3158
|
}
|
|
3159
|
-
|
|
3159
|
+
d();
|
|
3160
3160
|
});
|
|
3161
3161
|
},
|
|
3162
3162
|
[i]
|
|
3163
|
-
),
|
|
3164
|
-
const
|
|
3165
|
-
for (const
|
|
3166
|
-
|
|
3167
|
-
let
|
|
3168
|
-
for (const
|
|
3169
|
-
const { key: m, useShallowArrayEqual:
|
|
3170
|
-
if (
|
|
3171
|
-
if (
|
|
3172
|
-
|
|
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;
|
|
3173
3173
|
break;
|
|
3174
3174
|
}
|
|
3175
|
-
} else if (
|
|
3176
|
-
|
|
3175
|
+
} else if (V !== g) {
|
|
3176
|
+
h = !0;
|
|
3177
3177
|
break;
|
|
3178
3178
|
}
|
|
3179
3179
|
}
|
|
3180
|
-
if (!
|
|
3181
|
-
return
|
|
3182
|
-
for (const
|
|
3183
|
-
|
|
3184
|
-
return
|
|
3185
|
-
}, [i
|
|
3186
|
-
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);
|
|
3187
3187
|
}
|
|
3188
|
-
function
|
|
3188
|
+
function We(s) {
|
|
3189
3189
|
const e = {
|
|
3190
|
-
value:
|
|
3191
|
-
disabled:
|
|
3192
|
-
errors:
|
|
3193
|
-
pending:
|
|
3194
|
-
valid:
|
|
3195
|
-
invalid:
|
|
3196
|
-
touched:
|
|
3197
|
-
|
|
3198
|
-
|
|
3190
|
+
value: s.value,
|
|
3191
|
+
disabled: s.disabled,
|
|
3192
|
+
errors: s.errors,
|
|
3193
|
+
pending: s.pending,
|
|
3194
|
+
valid: s.valid,
|
|
3195
|
+
invalid: s.invalid,
|
|
3196
|
+
touched: s.touched,
|
|
3197
|
+
dirty: s.dirty,
|
|
3198
|
+
shouldShowError: s.shouldShowError,
|
|
3199
|
+
componentProps: s.componentProps
|
|
3199
3200
|
}, t = [
|
|
3200
3201
|
{ key: "value" },
|
|
3201
3202
|
{ key: "disabled" },
|
|
@@ -3204,9 +3205,10 @@ function Be(i) {
|
|
|
3204
3205
|
{ key: "valid" },
|
|
3205
3206
|
{ key: "invalid" },
|
|
3206
3207
|
{ key: "touched" },
|
|
3208
|
+
{ key: "dirty" },
|
|
3207
3209
|
{ key: "shouldShowError" },
|
|
3208
3210
|
{ key: "componentProps" }
|
|
3209
|
-
],
|
|
3211
|
+
], i = E(
|
|
3210
3212
|
(r) => ({
|
|
3211
3213
|
value: r.value,
|
|
3212
3214
|
pending: r.pending,
|
|
@@ -3215,23 +3217,25 @@ function Be(i) {
|
|
|
3215
3217
|
valid: r.valid,
|
|
3216
3218
|
invalid: r.invalid,
|
|
3217
3219
|
touched: r.touched,
|
|
3220
|
+
dirty: r.dirty,
|
|
3218
3221
|
shouldShowError: r.shouldShowError,
|
|
3219
3222
|
componentProps: r.componentProps
|
|
3220
3223
|
}),
|
|
3221
3224
|
[]
|
|
3222
3225
|
);
|
|
3223
|
-
return
|
|
3226
|
+
return Q(e, t, i, s);
|
|
3224
3227
|
}
|
|
3225
|
-
function
|
|
3228
|
+
function qe(s) {
|
|
3226
3229
|
const e = {
|
|
3227
|
-
value:
|
|
3228
|
-
length:
|
|
3229
|
-
errors:
|
|
3230
|
-
pending:
|
|
3231
|
-
valid:
|
|
3232
|
-
invalid:
|
|
3233
|
-
touched:
|
|
3234
|
-
dirty:
|
|
3230
|
+
value: s.value,
|
|
3231
|
+
length: s.length,
|
|
3232
|
+
errors: s.errors,
|
|
3233
|
+
pending: s.pending,
|
|
3234
|
+
valid: s.valid,
|
|
3235
|
+
invalid: s.invalid,
|
|
3236
|
+
touched: s.touched,
|
|
3237
|
+
dirty: s.dirty,
|
|
3238
|
+
disabled: s.disabled
|
|
3235
3239
|
}, t = [
|
|
3236
3240
|
{ key: "value" },
|
|
3237
3241
|
{ key: "length" },
|
|
@@ -3240,8 +3244,9 @@ function Ge(i) {
|
|
|
3240
3244
|
{ key: "valid" },
|
|
3241
3245
|
{ key: "invalid" },
|
|
3242
3246
|
{ key: "touched" },
|
|
3243
|
-
{ key: "dirty" }
|
|
3244
|
-
|
|
3247
|
+
{ key: "dirty" },
|
|
3248
|
+
{ key: "disabled" }
|
|
3249
|
+
], i = E(
|
|
3245
3250
|
(r) => ({
|
|
3246
3251
|
value: r.value,
|
|
3247
3252
|
length: r.length,
|
|
@@ -3250,14 +3255,15 @@ function Ge(i) {
|
|
|
3250
3255
|
valid: r.valid,
|
|
3251
3256
|
invalid: r.invalid,
|
|
3252
3257
|
touched: r.touched,
|
|
3253
|
-
dirty: r.dirty
|
|
3258
|
+
dirty: r.dirty,
|
|
3259
|
+
disabled: r.disabled
|
|
3254
3260
|
}),
|
|
3255
3261
|
[]
|
|
3256
3262
|
);
|
|
3257
|
-
return
|
|
3263
|
+
return Q(e, t, i, s);
|
|
3258
3264
|
}
|
|
3259
|
-
function
|
|
3260
|
-
const
|
|
3265
|
+
function Ke() {
|
|
3266
|
+
const s = E(
|
|
3261
3267
|
() => ({
|
|
3262
3268
|
value: [],
|
|
3263
3269
|
length: 0,
|
|
@@ -3266,96 +3272,98 @@ function Ue() {
|
|
|
3266
3272
|
valid: !0,
|
|
3267
3273
|
invalid: !1,
|
|
3268
3274
|
touched: !1,
|
|
3269
|
-
dirty: !1
|
|
3275
|
+
dirty: !1,
|
|
3276
|
+
disabled: !1
|
|
3270
3277
|
}),
|
|
3271
3278
|
[]
|
|
3272
3279
|
);
|
|
3273
|
-
return
|
|
3280
|
+
return Q({}, [], s);
|
|
3274
3281
|
}
|
|
3275
|
-
function
|
|
3276
|
-
const e =
|
|
3277
|
-
return
|
|
3282
|
+
function st(s) {
|
|
3283
|
+
const e = s && "length" in s && "map" in s;
|
|
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 _(() => {
|
|
3284
|
-
if (
|
|
3291
|
+
if (s.value.value, n) {
|
|
3285
3292
|
n = !1;
|
|
3286
3293
|
return;
|
|
3287
3294
|
}
|
|
3288
3295
|
r();
|
|
3289
3296
|
});
|
|
3290
3297
|
},
|
|
3291
|
-
[
|
|
3292
|
-
),
|
|
3293
|
-
const r =
|
|
3298
|
+
[s]
|
|
3299
|
+
), i = E(() => {
|
|
3300
|
+
const r = s.value.value;
|
|
3294
3301
|
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
3295
|
-
}, [
|
|
3296
|
-
return
|
|
3302
|
+
}, [s]);
|
|
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 _(() => {
|
|
3303
|
-
if (
|
|
3310
|
+
if (s.length.value, n) {
|
|
3304
3311
|
n = !1;
|
|
3305
3312
|
return;
|
|
3306
3313
|
}
|
|
3307
3314
|
r();
|
|
3308
3315
|
});
|
|
3309
3316
|
},
|
|
3310
|
-
[
|
|
3311
|
-
),
|
|
3312
|
-
const r =
|
|
3317
|
+
[s]
|
|
3318
|
+
), i = E(() => {
|
|
3319
|
+
const r = s.length.value;
|
|
3313
3320
|
return e.current.length === r ? e.current.length : (e.current.length = r, r);
|
|
3314
|
-
}, [
|
|
3315
|
-
return
|
|
3321
|
+
}, [s]);
|
|
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
|
};
|