@reformer/core 2.0.0-beta.6 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{behaviors-2HSqHPb4.js → behaviors-DyPzh2-X.js} +1 -1
- package/dist/behaviors.js +2 -2
- package/dist/core/nodes/array-node.d.ts +28 -4
- package/dist/core/types/form-proxy.d.ts +2 -2
- package/dist/core/utils/create-form.d.ts +8 -6
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/utils/unique-id.d.ts +26 -0
- package/dist/core/validation/validation-context.d.ts +27 -35
- package/dist/core/validation/validation-registry.d.ts +0 -5
- package/dist/index.js +489 -446
- package/dist/{registry-helpers-BRxAr6nG.js → registry-helpers--8-OogF8.js} +12 -25
- package/dist/{validators-gXoHPdqM.js → validators-CWdzevnC.js} +116 -137
- package/dist/validators.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { d as y, w as u, E, r as
|
|
2
|
-
import { i as
|
|
3
|
-
import { i as
|
|
4
|
-
import { g as
|
|
5
|
-
import { V as
|
|
6
|
-
import { R as
|
|
7
|
-
import { v4 as
|
|
8
|
-
import
|
|
1
|
+
import { d as y, w as u, E, r as j } from "./behaviors-DyPzh2-X.js";
|
|
2
|
+
import { i as Se } from "./behaviors-DyPzh2-X.js";
|
|
3
|
+
import { i as R, a as T, A as q, V as K, T as H } from "./validators-CWdzevnC.js";
|
|
4
|
+
import { g as Ae, c as Ve, d as ke, v as xe, b as Pe } from "./validators-CWdzevnC.js";
|
|
5
|
+
import { V as W, B as z, c as D } from "./registry-helpers--8-OogF8.js";
|
|
6
|
+
import { R as Fe, a as Ce, e as Re, b as Te, g as De, t as Ne } from "./registry-helpers--8-OogF8.js";
|
|
7
|
+
import { v4 as J } from "uuid";
|
|
8
|
+
import L, { useRef as G, useCallback as b } from "react";
|
|
9
9
|
class F {
|
|
10
10
|
// ============================================================================
|
|
11
11
|
// Protected состояние (для Template Method паттерна)
|
|
@@ -100,17 +100,17 @@ class F {
|
|
|
100
100
|
*/
|
|
101
101
|
getErrors(e) {
|
|
102
102
|
const t = this.errors.value;
|
|
103
|
-
return e ? t.filter((
|
|
104
|
-
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(
|
|
103
|
+
return e ? t.filter((r) => {
|
|
104
|
+
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(r.code) || e.message !== void 0 && !r.message.toLowerCase().includes(e.message.toLowerCase()))
|
|
105
105
|
return !1;
|
|
106
106
|
if (e.params !== void 0) {
|
|
107
|
-
if (!
|
|
107
|
+
if (!r.params)
|
|
108
108
|
return !1;
|
|
109
|
-
for (const [
|
|
110
|
-
if (
|
|
109
|
+
for (const [i, a] of Object.entries(e.params))
|
|
110
|
+
if (r.params[i] !== a)
|
|
111
111
|
return !1;
|
|
112
112
|
}
|
|
113
|
-
return !(e.predicate !== void 0 && !e.predicate(
|
|
113
|
+
return !(e.predicate !== void 0 && !e.predicate(r));
|
|
114
114
|
}) : t;
|
|
115
115
|
}
|
|
116
116
|
// ============================================================================
|
|
@@ -283,7 +283,7 @@ class F {
|
|
|
283
283
|
onEnable() {
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
class
|
|
286
|
+
class C {
|
|
287
287
|
/**
|
|
288
288
|
* Хранилище подписок
|
|
289
289
|
* Ключ: уникальный идентификатор подписки
|
|
@@ -451,7 +451,11 @@ class P {
|
|
|
451
451
|
this.clear();
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
|
|
454
|
+
let Y = 0;
|
|
455
|
+
function S(s) {
|
|
456
|
+
return `${s}-${++Y}`;
|
|
457
|
+
}
|
|
458
|
+
var V = /* @__PURE__ */ ((s) => (s.THROW = "throw", s.LOG = "log", s.CONVERT = "convert", s))(V || {});
|
|
455
459
|
class O {
|
|
456
460
|
/**
|
|
457
461
|
* Обработать ошибку согласно заданной стратегии
|
|
@@ -492,9 +496,9 @@ class O {
|
|
|
492
496
|
* }
|
|
493
497
|
* ```
|
|
494
498
|
*/
|
|
495
|
-
static handle(e, t,
|
|
496
|
-
const
|
|
497
|
-
switch (
|
|
499
|
+
static handle(e, t, r = "throw") {
|
|
500
|
+
const i = this.extractMessage(e);
|
|
501
|
+
switch (r) {
|
|
498
502
|
case "throw":
|
|
499
503
|
throw e;
|
|
500
504
|
case "log":
|
|
@@ -502,7 +506,7 @@ class O {
|
|
|
502
506
|
case "convert":
|
|
503
507
|
return {
|
|
504
508
|
code: "validator_error",
|
|
505
|
-
message:
|
|
509
|
+
message: i,
|
|
506
510
|
params: { field: t }
|
|
507
511
|
};
|
|
508
512
|
}
|
|
@@ -558,11 +562,11 @@ class O {
|
|
|
558
562
|
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
559
563
|
* ```
|
|
560
564
|
*/
|
|
561
|
-
static createValidationError(e, t,
|
|
565
|
+
static createValidationError(e, t, r) {
|
|
562
566
|
return {
|
|
563
567
|
code: e,
|
|
564
568
|
message: t,
|
|
565
|
-
params:
|
|
569
|
+
params: r ? { field: r } : void 0
|
|
566
570
|
};
|
|
567
571
|
}
|
|
568
572
|
/**
|
|
@@ -584,7 +588,7 @@ class O {
|
|
|
584
588
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
585
589
|
}
|
|
586
590
|
}
|
|
587
|
-
class
|
|
591
|
+
class Q extends F {
|
|
588
592
|
// ============================================================================
|
|
589
593
|
// Приватные сигналы
|
|
590
594
|
// ============================================================================
|
|
@@ -626,7 +630,7 @@ class J extends F {
|
|
|
626
630
|
* Менеджер подписок для централизованного cleanup
|
|
627
631
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
628
632
|
*/
|
|
629
|
-
disposers = new
|
|
633
|
+
disposers = new C();
|
|
630
634
|
component;
|
|
631
635
|
// ============================================================================
|
|
632
636
|
// Конструктор
|
|
@@ -645,12 +649,12 @@ class J extends F {
|
|
|
645
649
|
setValue(e, t) {
|
|
646
650
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
647
651
|
return;
|
|
648
|
-
const
|
|
652
|
+
const r = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
649
653
|
if (this.updateOn === "change") {
|
|
650
654
|
this.validate();
|
|
651
655
|
return;
|
|
652
656
|
}
|
|
653
|
-
|
|
657
|
+
i && r && this.validate();
|
|
654
658
|
}
|
|
655
659
|
patchValue(e) {
|
|
656
660
|
this.setValue(e);
|
|
@@ -729,15 +733,15 @@ class J extends F {
|
|
|
729
733
|
*/
|
|
730
734
|
async validate(e) {
|
|
731
735
|
const t = e?.debounce ?? this.debounceMs;
|
|
732
|
-
return t > 0 && this.asyncValidators.length > 0 ? new Promise((
|
|
733
|
-
const
|
|
734
|
-
this.validateDebounceResolve && this.validateDebounceResolve(!1), this.validateDebounceTimer && clearTimeout(this.validateDebounceTimer), this.validateDebounceResolve =
|
|
735
|
-
if (this.validateDebounceResolve = void 0,
|
|
736
|
-
|
|
736
|
+
return t > 0 && this.asyncValidators.length > 0 ? new Promise((r) => {
|
|
737
|
+
const i = this.currentValidationId;
|
|
738
|
+
this.validateDebounceResolve && this.validateDebounceResolve(!1), this.validateDebounceTimer && clearTimeout(this.validateDebounceTimer), this.validateDebounceResolve = r, this.validateDebounceTimer = setTimeout(async () => {
|
|
739
|
+
if (this.validateDebounceResolve = void 0, i !== this.currentValidationId) {
|
|
740
|
+
r(!1);
|
|
737
741
|
return;
|
|
738
742
|
}
|
|
739
|
-
const
|
|
740
|
-
|
|
743
|
+
const a = await this.validateImmediate();
|
|
744
|
+
r(a);
|
|
741
745
|
}, t);
|
|
742
746
|
}) : this.validateImmediate();
|
|
743
747
|
}
|
|
@@ -756,21 +760,21 @@ class J extends F {
|
|
|
756
760
|
this.currentAbortController = e;
|
|
757
761
|
const { signal: t } = e;
|
|
758
762
|
++this.currentValidationId;
|
|
759
|
-
const
|
|
760
|
-
for (const
|
|
761
|
-
const n =
|
|
762
|
-
n &&
|
|
763
|
+
const r = [];
|
|
764
|
+
for (const a of this.validators) {
|
|
765
|
+
const n = a(this._value.value);
|
|
766
|
+
n && r.push(n);
|
|
763
767
|
}
|
|
764
768
|
if (t.aborted)
|
|
765
769
|
return !1;
|
|
766
|
-
if (
|
|
767
|
-
return this._errors.value =
|
|
770
|
+
if (r.length > 0)
|
|
771
|
+
return this._errors.value = r, this._status.value = "invalid", !1;
|
|
768
772
|
if (this.asyncValidators.length > 0) {
|
|
769
773
|
if (t.aborted)
|
|
770
774
|
return !1;
|
|
771
775
|
this._pending.value = !0, this._status.value = "pending";
|
|
772
776
|
try {
|
|
773
|
-
const
|
|
777
|
+
const a = await Promise.all(
|
|
774
778
|
this.asyncValidators.map(async (o) => {
|
|
775
779
|
if (t.aborted)
|
|
776
780
|
throw new DOMException("Validation aborted", "AbortError");
|
|
@@ -785,7 +789,7 @@ class J extends F {
|
|
|
785
789
|
return O.handle(
|
|
786
790
|
l,
|
|
787
791
|
"FieldNode AsyncValidator",
|
|
788
|
-
|
|
792
|
+
V.CONVERT
|
|
789
793
|
);
|
|
790
794
|
}
|
|
791
795
|
})
|
|
@@ -793,13 +797,13 @@ class J extends F {
|
|
|
793
797
|
if (t.aborted)
|
|
794
798
|
return !1;
|
|
795
799
|
this._pending.value = !1;
|
|
796
|
-
const n =
|
|
800
|
+
const n = a.filter(Boolean);
|
|
797
801
|
if (n.length > 0)
|
|
798
802
|
return this._errors.value = n, this._status.value = "invalid", !1;
|
|
799
|
-
} catch (
|
|
800
|
-
if (
|
|
803
|
+
} catch (a) {
|
|
804
|
+
if (a instanceof DOMException && a.name === "AbortError")
|
|
801
805
|
return !1;
|
|
802
|
-
throw
|
|
806
|
+
throw a;
|
|
803
807
|
}
|
|
804
808
|
}
|
|
805
809
|
return t.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this._status.value = "valid"), this._errors.value.length === 0);
|
|
@@ -915,10 +919,10 @@ class J extends F {
|
|
|
915
919
|
*/
|
|
916
920
|
watch(e) {
|
|
917
921
|
const t = E(() => {
|
|
918
|
-
const
|
|
919
|
-
e(
|
|
920
|
-
}),
|
|
921
|
-
return this.disposers.add(
|
|
922
|
+
const i = this.value.value;
|
|
923
|
+
e(i);
|
|
924
|
+
}), r = S("watch");
|
|
925
|
+
return this.disposers.add(r, t);
|
|
922
926
|
}
|
|
923
927
|
/**
|
|
924
928
|
* Вычисляемое значение из других полей
|
|
@@ -943,11 +947,11 @@ class J extends F {
|
|
|
943
947
|
* ```
|
|
944
948
|
*/
|
|
945
949
|
computeFrom(e, t) {
|
|
946
|
-
const
|
|
947
|
-
const
|
|
950
|
+
const r = E(() => {
|
|
951
|
+
const a = e.map((o) => o.value), n = t(...a);
|
|
948
952
|
this.setValue(n, { emitEvent: !1 });
|
|
949
|
-
}),
|
|
950
|
-
return this.disposers.add(
|
|
953
|
+
}), i = S("computeFrom");
|
|
954
|
+
return this.disposers.add(i, r);
|
|
951
955
|
}
|
|
952
956
|
/**
|
|
953
957
|
* Очистить все ресурсы и таймеры
|
|
@@ -973,7 +977,7 @@ class J extends F {
|
|
|
973
977
|
this.disposers.dispose(), this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), this.validateDebounceResolve && (this.validateDebounceResolve(!1), this.validateDebounceResolve = void 0), this.currentAbortController && (this.currentAbortController.abort(), this.currentAbortController = void 0);
|
|
974
978
|
}
|
|
975
979
|
}
|
|
976
|
-
class
|
|
980
|
+
class X {
|
|
977
981
|
form;
|
|
978
982
|
constructor(e) {
|
|
979
983
|
this.form = e;
|
|
@@ -989,8 +993,8 @@ class Y {
|
|
|
989
993
|
* @param validators Зарегистрированные валидаторы
|
|
990
994
|
*/
|
|
991
995
|
async apply(e) {
|
|
992
|
-
const { validatorsByField: t, treeValidators:
|
|
993
|
-
await this.applyFieldValidators(t), this.applyTreeValidators(
|
|
996
|
+
const { validatorsByField: t, treeValidators: r } = this.groupValidators(e);
|
|
997
|
+
await this.applyFieldValidators(t), this.applyTreeValidators(r);
|
|
994
998
|
}
|
|
995
999
|
/**
|
|
996
1000
|
* Группировка валидаторов по типам
|
|
@@ -1003,15 +1007,15 @@ class Y {
|
|
|
1003
1007
|
* @returns Сгруппированные валидаторы
|
|
1004
1008
|
*/
|
|
1005
1009
|
groupValidators(e) {
|
|
1006
|
-
const t = /* @__PURE__ */ new Map(),
|
|
1007
|
-
for (const
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1010
|
+
const t = /* @__PURE__ */ new Map(), r = [];
|
|
1011
|
+
for (const i of e)
|
|
1012
|
+
if (i.type === "tree")
|
|
1013
|
+
r.push(i);
|
|
1010
1014
|
else {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1015
|
+
const a = t.get(i.fieldPath) || [];
|
|
1016
|
+
a.push(i), t.set(i.fieldPath, a);
|
|
1013
1017
|
}
|
|
1014
|
-
return { validatorsByField: t, treeValidators:
|
|
1018
|
+
return { validatorsByField: t, treeValidators: r };
|
|
1015
1019
|
}
|
|
1016
1020
|
/**
|
|
1017
1021
|
* Применение field валидаторов к полям
|
|
@@ -1025,37 +1029,44 @@ class Y {
|
|
|
1025
1029
|
* @param validatorsByField Валидаторы, сгруппированные по полям
|
|
1026
1030
|
*/
|
|
1027
1031
|
async applyFieldValidators(e) {
|
|
1028
|
-
for (const [t,
|
|
1029
|
-
const
|
|
1030
|
-
if (!
|
|
1032
|
+
for (const [t, r] of e) {
|
|
1033
|
+
const i = this.form.getFieldByPath(t);
|
|
1034
|
+
if (!i) {
|
|
1031
1035
|
console.warn(`Field ${t} not found in GroupNode`);
|
|
1032
1036
|
continue;
|
|
1033
1037
|
}
|
|
1034
|
-
if (!
|
|
1038
|
+
if (!R(i) && !T(i)) {
|
|
1035
1039
|
process.env.NODE_ENV !== "production" && console.warn(`Validation can only run on FieldNode or ArrayNode, skipping ${t}`);
|
|
1036
1040
|
continue;
|
|
1037
1041
|
}
|
|
1038
|
-
const
|
|
1042
|
+
const a = [];
|
|
1039
1043
|
let n;
|
|
1040
|
-
if (
|
|
1041
|
-
const o =
|
|
1042
|
-
n = new
|
|
1044
|
+
if (T(i)) {
|
|
1045
|
+
const o = i.getValue();
|
|
1046
|
+
n = new q(this.form, t, o);
|
|
1043
1047
|
} else
|
|
1044
|
-
n = new
|
|
1045
|
-
for (const o of
|
|
1048
|
+
n = new K(this.form, t, i);
|
|
1049
|
+
for (const o of r)
|
|
1046
1050
|
if (!(o.condition && !this.checkCondition(o.condition)))
|
|
1047
1051
|
try {
|
|
1048
1052
|
let l = null;
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1053
|
+
const h = n.value();
|
|
1054
|
+
if (o.type === "sync") {
|
|
1055
|
+
const m = o.validator;
|
|
1056
|
+
l = m(h, n);
|
|
1057
|
+
} else if (o.type === "async") {
|
|
1058
|
+
const m = o.validator;
|
|
1059
|
+
l = await m(h, n);
|
|
1060
|
+
}
|
|
1061
|
+
l && a.push(l);
|
|
1051
1062
|
} catch (l) {
|
|
1052
1063
|
O.handle(
|
|
1053
1064
|
l,
|
|
1054
1065
|
`ValidationApplicator: validator for ${t}`,
|
|
1055
|
-
|
|
1066
|
+
V.LOG
|
|
1056
1067
|
);
|
|
1057
1068
|
}
|
|
1058
|
-
|
|
1069
|
+
a.length > 0 ? i.setErrors(a) : i.clearErrors();
|
|
1059
1070
|
}
|
|
1060
1071
|
}
|
|
1061
1072
|
/**
|
|
@@ -1068,24 +1079,24 @@ class Y {
|
|
|
1068
1079
|
*/
|
|
1069
1080
|
applyTreeValidators(e) {
|
|
1070
1081
|
for (const t of e) {
|
|
1071
|
-
const
|
|
1082
|
+
const r = new H(this.form);
|
|
1072
1083
|
if (!(t.condition && !this.checkCondition(t.condition)))
|
|
1073
1084
|
try {
|
|
1074
1085
|
if (t.type !== "tree")
|
|
1075
1086
|
continue;
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
const
|
|
1079
|
-
if (
|
|
1080
|
-
const
|
|
1081
|
-
if (
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1087
|
+
const i = t.validator, a = i(r);
|
|
1088
|
+
if (a && t.options && "targetField" in t.options) {
|
|
1089
|
+
const n = t.options.targetField;
|
|
1090
|
+
if (n) {
|
|
1091
|
+
const o = this.form.getFieldByPath(String(n));
|
|
1092
|
+
if (o && R(o)) {
|
|
1093
|
+
const l = o.errors.value;
|
|
1094
|
+
o.setErrors([...l, a]);
|
|
1084
1095
|
}
|
|
1085
1096
|
}
|
|
1086
1097
|
}
|
|
1087
|
-
} catch (
|
|
1088
|
-
O.handle(
|
|
1098
|
+
} catch (i) {
|
|
1099
|
+
O.handle(i, "ValidationApplicator: tree validator", V.LOG);
|
|
1089
1100
|
}
|
|
1090
1101
|
}
|
|
1091
1102
|
}
|
|
@@ -1102,11 +1113,11 @@ class Y {
|
|
|
1102
1113
|
const t = this.form.getFieldByPath(e.fieldPath);
|
|
1103
1114
|
if (!t)
|
|
1104
1115
|
return !1;
|
|
1105
|
-
const
|
|
1106
|
-
return e.conditionFn(
|
|
1116
|
+
const r = t.value.value;
|
|
1117
|
+
return e.conditionFn(r);
|
|
1107
1118
|
}
|
|
1108
1119
|
}
|
|
1109
|
-
class
|
|
1120
|
+
class Z {
|
|
1110
1121
|
/**
|
|
1111
1122
|
* Парсит путь в массив сегментов
|
|
1112
1123
|
*
|
|
@@ -1133,22 +1144,22 @@ class Q {
|
|
|
1133
1144
|
*/
|
|
1134
1145
|
parsePath(e) {
|
|
1135
1146
|
const t = [];
|
|
1136
|
-
let
|
|
1137
|
-
for (let
|
|
1138
|
-
const n = e[
|
|
1139
|
-
n === "[" ? (
|
|
1147
|
+
let r = "", i = !1;
|
|
1148
|
+
for (let a = 0; a < e.length; a++) {
|
|
1149
|
+
const n = e[a];
|
|
1150
|
+
n === "[" ? (i = !0, r += n) : n === "]" ? (i = !1, r += n) : n === "." && !i ? r && (this.addSegment(t, r), r = "") : r += n;
|
|
1140
1151
|
}
|
|
1141
|
-
return
|
|
1152
|
+
return r && this.addSegment(t, r), t;
|
|
1142
1153
|
}
|
|
1143
1154
|
/**
|
|
1144
1155
|
* Добавляет сегмент в массив, обрабатывая массивы
|
|
1145
1156
|
* @private
|
|
1146
1157
|
*/
|
|
1147
1158
|
addSegment(e, t) {
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
key:
|
|
1151
|
-
index: parseInt(
|
|
1159
|
+
const r = t.match(/^(.+)\[(\d+)\]$/);
|
|
1160
|
+
r ? e.push({
|
|
1161
|
+
key: r[1],
|
|
1162
|
+
index: parseInt(r[2], 10)
|
|
1152
1163
|
}) : e.push({ key: t });
|
|
1153
1164
|
}
|
|
1154
1165
|
/**
|
|
@@ -1183,16 +1194,16 @@ class Q {
|
|
|
1183
1194
|
* ```
|
|
1184
1195
|
*/
|
|
1185
1196
|
getValueByPath(e, t) {
|
|
1186
|
-
const
|
|
1187
|
-
let
|
|
1188
|
-
for (const
|
|
1189
|
-
if (
|
|
1190
|
-
if (
|
|
1191
|
-
if (!Array.isArray(
|
|
1192
|
-
|
|
1197
|
+
const r = this.parsePath(t);
|
|
1198
|
+
let i = e;
|
|
1199
|
+
for (const a of r) {
|
|
1200
|
+
if (i == null) return;
|
|
1201
|
+
if (i = i[a.key], a.index !== void 0) {
|
|
1202
|
+
if (!Array.isArray(i)) return;
|
|
1203
|
+
i = i[a.index];
|
|
1193
1204
|
}
|
|
1194
1205
|
}
|
|
1195
|
-
return
|
|
1206
|
+
return i;
|
|
1196
1207
|
}
|
|
1197
1208
|
/**
|
|
1198
1209
|
* Устанавливает значение по пути в объекте (мутирует объект)
|
|
@@ -1221,31 +1232,31 @@ class Q {
|
|
|
1221
1232
|
* // obj3.items[0].title === 'New'
|
|
1222
1233
|
* ```
|
|
1223
1234
|
*/
|
|
1224
|
-
setValueByPath(e, t,
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1235
|
+
setValueByPath(e, t, r) {
|
|
1236
|
+
const i = this.parsePath(t);
|
|
1237
|
+
if (i.length === 0)
|
|
1227
1238
|
throw new Error("Cannot set value: empty path");
|
|
1228
|
-
let
|
|
1229
|
-
for (let o = 0; o <
|
|
1230
|
-
const l =
|
|
1231
|
-
let
|
|
1239
|
+
let a = e;
|
|
1240
|
+
for (let o = 0; o < i.length - 1; o++) {
|
|
1241
|
+
const l = i[o];
|
|
1242
|
+
let h = a[l.key];
|
|
1232
1243
|
if (l.index !== void 0) {
|
|
1233
|
-
if (!Array.isArray(
|
|
1234
|
-
throw new Error(`Expected array at path segment: ${l.key}, but got ${typeof
|
|
1235
|
-
|
|
1244
|
+
if (!Array.isArray(h))
|
|
1245
|
+
throw new Error(`Expected array at path segment: ${l.key}, but got ${typeof h}`);
|
|
1246
|
+
a = h[l.index];
|
|
1236
1247
|
} else
|
|
1237
|
-
|
|
1248
|
+
h == null && (a[l.key] = {}, h = a[l.key]), a = h;
|
|
1238
1249
|
}
|
|
1239
|
-
const n =
|
|
1250
|
+
const n = i[i.length - 1];
|
|
1240
1251
|
if (n.index !== void 0) {
|
|
1241
|
-
const o =
|
|
1252
|
+
const o = a[n.key];
|
|
1242
1253
|
if (!Array.isArray(o))
|
|
1243
1254
|
throw new Error(
|
|
1244
1255
|
`Expected array at path segment: ${n.key}, but got ${typeof o}`
|
|
1245
1256
|
);
|
|
1246
|
-
o[n.index] =
|
|
1257
|
+
o[n.index] = r;
|
|
1247
1258
|
} else
|
|
1248
|
-
|
|
1259
|
+
a[n.key] = r;
|
|
1249
1260
|
}
|
|
1250
1261
|
/**
|
|
1251
1262
|
* Получить значение из FormNode по пути
|
|
@@ -1282,9 +1293,9 @@ class Q {
|
|
|
1282
1293
|
* ```
|
|
1283
1294
|
*/
|
|
1284
1295
|
getFormNodeValue(e, t) {
|
|
1285
|
-
const
|
|
1286
|
-
if (
|
|
1287
|
-
return this.isFormNode(
|
|
1296
|
+
const r = this.getNodeByPath(e, t);
|
|
1297
|
+
if (r != null)
|
|
1298
|
+
return this.isFormNode(r) ? r.value.value : r;
|
|
1288
1299
|
}
|
|
1289
1300
|
/**
|
|
1290
1301
|
* Type guard для проверки, является ли объект FormNode
|
|
@@ -1342,40 +1353,40 @@ class Q {
|
|
|
1342
1353
|
* ```
|
|
1343
1354
|
*/
|
|
1344
1355
|
getNodeByPath(e, t) {
|
|
1345
|
-
const
|
|
1346
|
-
let
|
|
1347
|
-
for (const
|
|
1348
|
-
if (
|
|
1349
|
-
const n =
|
|
1356
|
+
const r = this.parsePath(t);
|
|
1357
|
+
let i = e;
|
|
1358
|
+
for (const a of r) {
|
|
1359
|
+
if (i == null) return null;
|
|
1360
|
+
const n = i;
|
|
1350
1361
|
if (n.fields && n.fields instanceof Map) {
|
|
1351
|
-
if (
|
|
1352
|
-
if (
|
|
1362
|
+
if (i = n.fields.get(a.key), a.index === void 0) {
|
|
1363
|
+
if (i == null) return null;
|
|
1353
1364
|
continue;
|
|
1354
1365
|
}
|
|
1355
|
-
} else if (
|
|
1366
|
+
} else if (a.index !== void 0 && n.items) {
|
|
1356
1367
|
const o = n.items.value || n.items;
|
|
1357
|
-
if (!Array.isArray(o) || (
|
|
1368
|
+
if (!Array.isArray(o) || (i = o[a.index], i == null)) return null;
|
|
1358
1369
|
continue;
|
|
1359
|
-
} else if (
|
|
1360
|
-
if (
|
|
1370
|
+
} else if (a.index === void 0) {
|
|
1371
|
+
if (i = n[a.key], i == null) return null;
|
|
1361
1372
|
continue;
|
|
1362
1373
|
}
|
|
1363
|
-
if (
|
|
1364
|
-
const o =
|
|
1374
|
+
if (i && a.index !== void 0 && i.items) {
|
|
1375
|
+
const o = i.items.value || i.items;
|
|
1365
1376
|
if (!Array.isArray(o)) return null;
|
|
1366
|
-
|
|
1367
|
-
} else if (
|
|
1377
|
+
i = o[a.index];
|
|
1378
|
+
} else if (i && a.index !== void 0 && !i.items)
|
|
1368
1379
|
return null;
|
|
1369
|
-
if (
|
|
1380
|
+
if (i == null) return null;
|
|
1370
1381
|
}
|
|
1371
|
-
return
|
|
1382
|
+
return i;
|
|
1372
1383
|
}
|
|
1373
1384
|
}
|
|
1374
|
-
class
|
|
1385
|
+
class w extends F {
|
|
1375
1386
|
// ============================================================================
|
|
1376
1387
|
// Приватные поля
|
|
1377
1388
|
// ============================================================================
|
|
1378
|
-
id =
|
|
1389
|
+
id = J();
|
|
1379
1390
|
/**
|
|
1380
1391
|
* Коллекция полей формы (упрощённый Map вместо FieldRegistry)
|
|
1381
1392
|
*/
|
|
@@ -1384,7 +1395,7 @@ class S extends F {
|
|
|
1384
1395
|
/**
|
|
1385
1396
|
* Менеджер подписок для централизованного cleanup
|
|
1386
1397
|
*/
|
|
1387
|
-
disposers = new
|
|
1398
|
+
disposers = new C();
|
|
1388
1399
|
/**
|
|
1389
1400
|
* Ссылка на Proxy-инстанс для использования в BehaviorContext
|
|
1390
1401
|
*/
|
|
@@ -1392,23 +1403,23 @@ class S extends F {
|
|
|
1392
1403
|
/**
|
|
1393
1404
|
* Навигатор для работы с путями к полям
|
|
1394
1405
|
*/
|
|
1395
|
-
pathNavigator = new
|
|
1406
|
+
pathNavigator = new Z();
|
|
1396
1407
|
/**
|
|
1397
1408
|
* Фабрика для создания узлов формы
|
|
1398
1409
|
*/
|
|
1399
|
-
nodeFactory = new
|
|
1410
|
+
nodeFactory = new ee();
|
|
1400
1411
|
/**
|
|
1401
1412
|
* Реестр валидаторов для этой формы
|
|
1402
1413
|
*/
|
|
1403
|
-
validationRegistry = new
|
|
1414
|
+
validationRegistry = new W();
|
|
1404
1415
|
/**
|
|
1405
1416
|
* Реестр behaviors для этой формы
|
|
1406
1417
|
*/
|
|
1407
|
-
behaviorRegistry = new
|
|
1418
|
+
behaviorRegistry = new z();
|
|
1408
1419
|
/**
|
|
1409
1420
|
* Аппликатор для применения валидаторов к форме
|
|
1410
1421
|
*/
|
|
1411
|
-
validationApplicator = new
|
|
1422
|
+
validationApplicator = new X(this);
|
|
1412
1423
|
// ============================================================================
|
|
1413
1424
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1414
1425
|
// ============================================================================
|
|
@@ -1432,30 +1443,28 @@ class S extends F {
|
|
|
1432
1443
|
submitting;
|
|
1433
1444
|
constructor(e) {
|
|
1434
1445
|
super();
|
|
1435
|
-
const t = "form" in e,
|
|
1436
|
-
for (const [
|
|
1437
|
-
const
|
|
1438
|
-
this._fields.set(
|
|
1446
|
+
const t = "form" in e, r = t ? e.form : e, i = t ? e.behavior : void 0, a = t ? e.validation : void 0;
|
|
1447
|
+
for (const [n, o] of Object.entries(r)) {
|
|
1448
|
+
const l = this.createNode(o);
|
|
1449
|
+
this._fields.set(n, l);
|
|
1439
1450
|
}
|
|
1440
1451
|
this.value = u(() => {
|
|
1441
|
-
const
|
|
1442
|
-
return this._fields.forEach((
|
|
1443
|
-
|
|
1444
|
-
}),
|
|
1445
|
-
}), this.valid = u(() => this._formErrors.value.length > 0 ? !1 : Array.from(this._fields.values()).every((
|
|
1446
|
-
() => Array.from(this._fields.values()).some((
|
|
1452
|
+
const n = {};
|
|
1453
|
+
return this._fields.forEach((o, l) => {
|
|
1454
|
+
n[l] = o.value.value;
|
|
1455
|
+
}), n;
|
|
1456
|
+
}), this.valid = u(() => this._formErrors.value.length > 0 ? !1 : Array.from(this._fields.values()).every((n) => n.valid.value)), this.invalid = u(() => !this.valid.value), this.pending = u(
|
|
1457
|
+
() => Array.from(this._fields.values()).some((n) => n.pending.value)
|
|
1447
1458
|
), this.touched = u(
|
|
1448
|
-
() => Array.from(this._fields.values()).some((
|
|
1459
|
+
() => Array.from(this._fields.values()).some((n) => n.touched.value)
|
|
1449
1460
|
), this.dirty = u(
|
|
1450
|
-
() => Array.from(this._fields.values()).some((
|
|
1461
|
+
() => Array.from(this._fields.values()).some((n) => n.dirty.value)
|
|
1451
1462
|
), this.errors = u(() => {
|
|
1452
|
-
const
|
|
1453
|
-
return this._fields.forEach((
|
|
1454
|
-
|
|
1455
|
-
}),
|
|
1456
|
-
}), this.status = u(() => this._disabled.value ? "disabled" : this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid"), this.submitting = u(() => this._submitting.value);
|
|
1457
|
-
const n = this.buildProxy();
|
|
1458
|
-
return this._proxyInstance = n, r && this.applyBehaviorSchema(r), s && this.applyValidationSchema(s), n;
|
|
1463
|
+
const n = [...this._formErrors.value];
|
|
1464
|
+
return this._fields.forEach((o) => {
|
|
1465
|
+
n.push(...o.errors.value);
|
|
1466
|
+
}), n;
|
|
1467
|
+
}), this.status = u(() => this._disabled.value ? "disabled" : this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid"), this.submitting = u(() => this._submitting.value), this._proxyInstance = this.buildProxy(), i && this.applyBehaviorSchema(i), a && this.applyValidationSchema(a);
|
|
1459
1468
|
}
|
|
1460
1469
|
// ============================================================================
|
|
1461
1470
|
// Приватный метод для создания Proxy (inline из ProxyBuilder)
|
|
@@ -1466,19 +1475,21 @@ class S extends F {
|
|
|
1466
1475
|
buildProxy() {
|
|
1467
1476
|
const e = this;
|
|
1468
1477
|
return new Proxy(this, {
|
|
1469
|
-
get: (t,
|
|
1470
|
-
if (
|
|
1471
|
-
return t[
|
|
1472
|
-
if (typeof
|
|
1473
|
-
|
|
1478
|
+
get: (t, r) => {
|
|
1479
|
+
if (r in t)
|
|
1480
|
+
return t[r];
|
|
1481
|
+
if (typeof r == "string" && e._fields.has(r)) {
|
|
1482
|
+
const i = e._fields.get(r);
|
|
1483
|
+
return i && typeof i.getProxy == "function" ? i.getProxy() : i;
|
|
1484
|
+
}
|
|
1474
1485
|
},
|
|
1475
|
-
set: (t,
|
|
1476
|
-
has: (t,
|
|
1486
|
+
set: (t, r, i) => typeof r == "string" && e._fields.has(r) ? !1 : (t[r] = i, !0),
|
|
1487
|
+
has: (t, r) => typeof r == "string" && e._fields.has(r) ? !0 : r in t,
|
|
1477
1488
|
ownKeys: (t) => {
|
|
1478
|
-
const
|
|
1479
|
-
return [.../* @__PURE__ */ new Set([...
|
|
1489
|
+
const r = Reflect.ownKeys(t), i = Array.from(e._fields.keys());
|
|
1490
|
+
return [.../* @__PURE__ */ new Set([...r, ...i])];
|
|
1480
1491
|
},
|
|
1481
|
-
getOwnPropertyDescriptor: (t,
|
|
1492
|
+
getOwnPropertyDescriptor: (t, r) => typeof r == "string" && e._fields.has(r) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(t, r)
|
|
1482
1493
|
});
|
|
1483
1494
|
}
|
|
1484
1495
|
// ============================================================================
|
|
@@ -1486,21 +1497,21 @@ class S extends F {
|
|
|
1486
1497
|
// ============================================================================
|
|
1487
1498
|
getValue() {
|
|
1488
1499
|
const e = {};
|
|
1489
|
-
return this._fields.forEach((t,
|
|
1490
|
-
e[
|
|
1500
|
+
return this._fields.forEach((t, r) => {
|
|
1501
|
+
e[r] = t.getValue();
|
|
1491
1502
|
}), e;
|
|
1492
1503
|
}
|
|
1493
1504
|
setValue(e, t) {
|
|
1494
|
-
for (const [
|
|
1495
|
-
const
|
|
1496
|
-
|
|
1505
|
+
for (const [r, i] of Object.entries(e)) {
|
|
1506
|
+
const a = this._fields.get(r);
|
|
1507
|
+
a && a.setValue(i, t);
|
|
1497
1508
|
}
|
|
1498
1509
|
}
|
|
1499
1510
|
patchValue(e) {
|
|
1500
|
-
|
|
1501
|
-
for (const [t,
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1511
|
+
j(() => {
|
|
1512
|
+
for (const [t, r] of Object.entries(e)) {
|
|
1513
|
+
const i = this._fields.get(t);
|
|
1514
|
+
i && r !== void 0 && i.setValue(r, { emitEvent: !1 });
|
|
1504
1515
|
}
|
|
1505
1516
|
});
|
|
1506
1517
|
}
|
|
@@ -1522,9 +1533,9 @@ class S extends F {
|
|
|
1522
1533
|
* ```
|
|
1523
1534
|
*/
|
|
1524
1535
|
reset(e) {
|
|
1525
|
-
this._fields.forEach((t,
|
|
1526
|
-
const
|
|
1527
|
-
t.reset(
|
|
1536
|
+
this._fields.forEach((t, r) => {
|
|
1537
|
+
const i = e?.[r];
|
|
1538
|
+
t.reset(i);
|
|
1528
1539
|
});
|
|
1529
1540
|
}
|
|
1530
1541
|
/**
|
|
@@ -1639,10 +1650,10 @@ class S extends F {
|
|
|
1639
1650
|
applyValidationSchema(e) {
|
|
1640
1651
|
this.validationRegistry.beginRegistration();
|
|
1641
1652
|
try {
|
|
1642
|
-
const t =
|
|
1653
|
+
const t = D();
|
|
1643
1654
|
e(t);
|
|
1644
|
-
const
|
|
1645
|
-
this.validationRegistry.endRegistration(
|
|
1655
|
+
const r = this.getProxy();
|
|
1656
|
+
this.validationRegistry.endRegistration(r);
|
|
1646
1657
|
} catch (t) {
|
|
1647
1658
|
throw console.error("Error applying validation schema:", t), t;
|
|
1648
1659
|
}
|
|
@@ -1654,7 +1665,7 @@ class S extends F {
|
|
|
1654
1665
|
applyBehaviorSchema(e) {
|
|
1655
1666
|
this.behaviorRegistry.beginRegistration();
|
|
1656
1667
|
try {
|
|
1657
|
-
const t =
|
|
1668
|
+
const t = D();
|
|
1658
1669
|
return e(t), this.behaviorRegistry.endRegistration(this.getProxy()).cleanup;
|
|
1659
1670
|
} catch (t) {
|
|
1660
1671
|
throw console.error("Error applying behavior schema:", t), t;
|
|
@@ -1695,18 +1706,18 @@ class S extends F {
|
|
|
1695
1706
|
const t = this.pathNavigator.parsePath(e);
|
|
1696
1707
|
if (t.length === 0)
|
|
1697
1708
|
return;
|
|
1698
|
-
let
|
|
1699
|
-
for (const
|
|
1700
|
-
if (!(
|
|
1701
|
-
if (
|
|
1702
|
-
if ("at" in
|
|
1703
|
-
const
|
|
1704
|
-
if (!
|
|
1705
|
-
|
|
1709
|
+
let r = this;
|
|
1710
|
+
for (const i of t) {
|
|
1711
|
+
if (!(r instanceof w) || (r = r.getField(i.key), !r)) return;
|
|
1712
|
+
if (i.index !== void 0)
|
|
1713
|
+
if ("at" in r && "length" in r && typeof r.at == "function") {
|
|
1714
|
+
const a = r.at(i.index);
|
|
1715
|
+
if (!a) return;
|
|
1716
|
+
r = a;
|
|
1706
1717
|
} else
|
|
1707
1718
|
return;
|
|
1708
1719
|
}
|
|
1709
|
-
return
|
|
1720
|
+
return r;
|
|
1710
1721
|
}
|
|
1711
1722
|
/**
|
|
1712
1723
|
* Применить contextual валидаторы к полям
|
|
@@ -1750,15 +1761,15 @@ class S extends F {
|
|
|
1750
1761
|
/**
|
|
1751
1762
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1752
1763
|
*/
|
|
1753
|
-
linkFields(e, t,
|
|
1754
|
-
const
|
|
1755
|
-
if (!
|
|
1764
|
+
linkFields(e, t, r) {
|
|
1765
|
+
const i = this._fields.get(e), a = this._fields.get(t);
|
|
1766
|
+
if (!i || !a)
|
|
1756
1767
|
return () => {
|
|
1757
1768
|
};
|
|
1758
1769
|
const n = E(() => {
|
|
1759
|
-
const l =
|
|
1760
|
-
|
|
1761
|
-
}), o =
|
|
1770
|
+
const l = i.value.value, h = r ? r(l) : l;
|
|
1771
|
+
a.setValue(h, { emitEvent: !1 });
|
|
1772
|
+
}), o = S("linkFields");
|
|
1762
1773
|
return this.disposers.add(o, n);
|
|
1763
1774
|
}
|
|
1764
1775
|
/**
|
|
@@ -1789,15 +1800,15 @@ class S extends F {
|
|
|
1789
1800
|
* ```
|
|
1790
1801
|
*/
|
|
1791
1802
|
watchField(e, t) {
|
|
1792
|
-
const
|
|
1793
|
-
if (!
|
|
1803
|
+
const r = this.getFieldByPath(e);
|
|
1804
|
+
if (!r)
|
|
1794
1805
|
return () => {
|
|
1795
1806
|
};
|
|
1796
|
-
const
|
|
1797
|
-
const n =
|
|
1807
|
+
const i = E(() => {
|
|
1808
|
+
const n = r.value.value;
|
|
1798
1809
|
t(n);
|
|
1799
|
-
}),
|
|
1800
|
-
return this.disposers.add(
|
|
1810
|
+
}), a = S("watchField");
|
|
1811
|
+
return this.disposers.add(a, i);
|
|
1801
1812
|
}
|
|
1802
1813
|
/**
|
|
1803
1814
|
* Hook: вызывается после disable()
|
|
@@ -1820,7 +1831,7 @@ class S extends F {
|
|
|
1820
1831
|
});
|
|
1821
1832
|
}
|
|
1822
1833
|
}
|
|
1823
|
-
class
|
|
1834
|
+
class N extends F {
|
|
1824
1835
|
// ============================================================================
|
|
1825
1836
|
// Приватные поля
|
|
1826
1837
|
// ============================================================================
|
|
@@ -1831,7 +1842,9 @@ class T extends F {
|
|
|
1831
1842
|
* Менеджер подписок для централизованного cleanup
|
|
1832
1843
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1833
1844
|
*/
|
|
1834
|
-
disposers = new
|
|
1845
|
+
disposers = new C();
|
|
1846
|
+
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1847
|
+
_arrayErrors = y([]);
|
|
1835
1848
|
// ============================================================================
|
|
1836
1849
|
// Приватные поля для сохранения схем
|
|
1837
1850
|
// ============================================================================
|
|
@@ -1854,13 +1867,13 @@ class T extends F {
|
|
|
1854
1867
|
// ============================================================================
|
|
1855
1868
|
constructor(e, t = []) {
|
|
1856
1869
|
super(), this.itemSchema = e, this.initialItems = t, this.items = y([]);
|
|
1857
|
-
for (const
|
|
1858
|
-
this.push(
|
|
1859
|
-
this.length = u(() => this.items.value.length), this.value = u(() => this.items.value.map((
|
|
1860
|
-
const
|
|
1861
|
-
return this.items.value.forEach((
|
|
1862
|
-
|
|
1863
|
-
}),
|
|
1870
|
+
for (const r of t)
|
|
1871
|
+
this.push(r);
|
|
1872
|
+
this.length = u(() => this.items.value.length), this.value = u(() => this.items.value.map((r) => r.value.value)), this.valid = u(() => this._arrayErrors.value.length > 0 ? !1 : this.items.value.every((r) => r.valid.value)), this.invalid = u(() => !this.valid.value), this.pending = u(() => this.items.value.some((r) => r.pending.value)), this.touched = u(() => this.items.value.some((r) => r.touched.value)), this.dirty = u(() => this.items.value.some((r) => r.dirty.value)), this.errors = u(() => {
|
|
1873
|
+
const r = [...this._arrayErrors.value];
|
|
1874
|
+
return this.items.value.forEach((i) => {
|
|
1875
|
+
r.push(...i.errors.value);
|
|
1876
|
+
}), r;
|
|
1864
1877
|
}), this.status = u(() => this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid");
|
|
1865
1878
|
}
|
|
1866
1879
|
// ============================================================================
|
|
@@ -1879,7 +1892,7 @@ class T extends F {
|
|
|
1879
1892
|
* @param index - Индекс элемента для удаления
|
|
1880
1893
|
*/
|
|
1881
1894
|
removeAt(e) {
|
|
1882
|
-
e < 0 || e >= this.items.value.length || (this.items.value = this.items.value.filter((t,
|
|
1895
|
+
e < 0 || e >= this.items.value.length || (this.items.value = this.items.value.filter((t, r) => r !== e));
|
|
1883
1896
|
}
|
|
1884
1897
|
/**
|
|
1885
1898
|
* Вставить элемент в массив
|
|
@@ -1889,8 +1902,8 @@ class T extends F {
|
|
|
1889
1902
|
insert(e, t) {
|
|
1890
1903
|
if (e < 0 || e > this.items.value.length)
|
|
1891
1904
|
return;
|
|
1892
|
-
const
|
|
1893
|
-
|
|
1905
|
+
const r = this.createItem(t), i = [...this.items.value];
|
|
1906
|
+
i.splice(e, 0, r), this.items.value = i;
|
|
1894
1907
|
}
|
|
1895
1908
|
/**
|
|
1896
1909
|
* Удалить все элементы массива
|
|
@@ -1901,10 +1914,12 @@ class T extends F {
|
|
|
1901
1914
|
/**
|
|
1902
1915
|
* Получить элемент по индексу
|
|
1903
1916
|
* @param index - Индекс элемента
|
|
1904
|
-
* @returns Типизированный GroupNode или undefined если индекс вне границ
|
|
1917
|
+
* @returns Типизированный GroupNode proxy или undefined если индекс вне границ
|
|
1905
1918
|
*/
|
|
1906
1919
|
at(e) {
|
|
1907
|
-
|
|
1920
|
+
const t = this.items.value[e];
|
|
1921
|
+
if (t)
|
|
1922
|
+
return t.getProxy();
|
|
1908
1923
|
}
|
|
1909
1924
|
// ============================================================================
|
|
1910
1925
|
// Реализация абстрактных методов
|
|
@@ -1913,12 +1928,12 @@ class T extends F {
|
|
|
1913
1928
|
return this.items.value.map((e) => e.getValue());
|
|
1914
1929
|
}
|
|
1915
1930
|
setValue(e, t) {
|
|
1916
|
-
this.clear(), e.forEach((
|
|
1931
|
+
this.clear(), e.forEach((r) => this.push(r)), t?.emitEvent !== !1 && this.validate().catch(() => {
|
|
1917
1932
|
});
|
|
1918
1933
|
}
|
|
1919
1934
|
patchValue(e) {
|
|
1920
|
-
e.forEach((t,
|
|
1921
|
-
this.items.value[
|
|
1935
|
+
e.forEach((t, r) => {
|
|
1936
|
+
this.items.value[r] && t !== void 0 && this.items.value[r].patchValue(t);
|
|
1922
1937
|
});
|
|
1923
1938
|
}
|
|
1924
1939
|
/**
|
|
@@ -1939,7 +1954,7 @@ class T extends F {
|
|
|
1939
1954
|
* ```
|
|
1940
1955
|
*/
|
|
1941
1956
|
reset(e) {
|
|
1942
|
-
this.clear(), e && e.forEach((t) => this.push(t));
|
|
1957
|
+
this._arrayErrors.value = [], this.clear(), e && e.forEach((t) => this.push(t));
|
|
1943
1958
|
}
|
|
1944
1959
|
/**
|
|
1945
1960
|
* Сбросить массив к исходным значениям (initialItems)
|
|
@@ -1970,15 +1985,38 @@ class T extends F {
|
|
|
1970
1985
|
* ```
|
|
1971
1986
|
*/
|
|
1972
1987
|
resetToInitial() {
|
|
1973
|
-
this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1988
|
+
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1974
1989
|
}
|
|
1975
1990
|
async validate() {
|
|
1976
1991
|
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean);
|
|
1977
1992
|
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Установить array-level validation errors
|
|
1995
|
+
*
|
|
1996
|
+
* @param errors - Массив ошибок валидации уровня массива
|
|
1997
|
+
*
|
|
1998
|
+
* @example
|
|
1999
|
+
* ```typescript
|
|
2000
|
+
* arrayNode.setErrors([{
|
|
2001
|
+
* code: 'minItems',
|
|
2002
|
+
* message: 'Минимум 1 элемент обязателен',
|
|
2003
|
+
* }]);
|
|
2004
|
+
* ```
|
|
2005
|
+
*/
|
|
1978
2006
|
setErrors(e) {
|
|
2007
|
+
this._arrayErrors.value = e;
|
|
1979
2008
|
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Очистить все errors (array-level + item-level)
|
|
2011
|
+
*
|
|
2012
|
+
* @example
|
|
2013
|
+
* ```typescript
|
|
2014
|
+
* arrayNode.clearErrors();
|
|
2015
|
+
* console.log(arrayNode.errors.value); // []
|
|
2016
|
+
* ```
|
|
2017
|
+
*/
|
|
1980
2018
|
clearErrors() {
|
|
1981
|
-
this.items.value.forEach((e) => e.clearErrors());
|
|
2019
|
+
this._arrayErrors.value = [], this.items.value.forEach((e) => e.clearErrors());
|
|
1982
2020
|
}
|
|
1983
2021
|
// ============================================================================
|
|
1984
2022
|
// Protected hooks (Template Method pattern)
|
|
@@ -2020,20 +2058,24 @@ class T extends F {
|
|
|
2020
2058
|
// ============================================================================
|
|
2021
2059
|
/**
|
|
2022
2060
|
* Итерировать по элементам массива
|
|
2023
|
-
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode
|
|
2061
|
+
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
2024
2062
|
*/
|
|
2025
2063
|
forEach(e) {
|
|
2026
|
-
this.items.value.forEach((t,
|
|
2027
|
-
|
|
2064
|
+
this.items.value.forEach((t, r) => {
|
|
2065
|
+
const i = t.getProxy();
|
|
2066
|
+
e(i, r);
|
|
2028
2067
|
});
|
|
2029
2068
|
}
|
|
2030
2069
|
/**
|
|
2031
2070
|
* Маппинг элементов массива
|
|
2032
|
-
* @param callback - Функция преобразования с типизированным GroupNode
|
|
2071
|
+
* @param callback - Функция преобразования с типизированным GroupNode proxy
|
|
2033
2072
|
* @returns Новый массив результатов
|
|
2034
2073
|
*/
|
|
2035
2074
|
map(e) {
|
|
2036
|
-
return this.items.value.map((t,
|
|
2075
|
+
return this.items.value.map((t, r) => {
|
|
2076
|
+
const i = t.getProxy();
|
|
2077
|
+
return e(i, r);
|
|
2078
|
+
});
|
|
2037
2079
|
}
|
|
2038
2080
|
// ============================================================================
|
|
2039
2081
|
// Private методы
|
|
@@ -2044,7 +2086,7 @@ class T extends F {
|
|
|
2044
2086
|
*/
|
|
2045
2087
|
createItem(e) {
|
|
2046
2088
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2047
|
-
const t = new
|
|
2089
|
+
const t = new w(this.itemSchema);
|
|
2048
2090
|
return e && t.patchValue(e), this.validationSchemaFn && "applyValidationSchema" in t && t.applyValidationSchema(this.validationSchemaFn), this.behaviorSchemaFn && "applyBehaviorSchema" in t && t.applyBehaviorSchema(this.behaviorSchemaFn), t;
|
|
2049
2091
|
}
|
|
2050
2092
|
throw new Error(
|
|
@@ -2131,14 +2173,14 @@ class T extends F {
|
|
|
2131
2173
|
* ```
|
|
2132
2174
|
*/
|
|
2133
2175
|
watchItems(e, t) {
|
|
2134
|
-
const
|
|
2135
|
-
const
|
|
2136
|
-
if (n instanceof
|
|
2176
|
+
const r = E(() => {
|
|
2177
|
+
const a = this.items.value.map((n) => {
|
|
2178
|
+
if (n instanceof w)
|
|
2137
2179
|
return n.getFieldByPath(e)?.value.value;
|
|
2138
2180
|
});
|
|
2139
|
-
t(
|
|
2140
|
-
}),
|
|
2141
|
-
return this.disposers.add(
|
|
2181
|
+
t(a);
|
|
2182
|
+
}), i = S("watchItems");
|
|
2183
|
+
return this.disposers.add(i, r);
|
|
2142
2184
|
}
|
|
2143
2185
|
/**
|
|
2144
2186
|
* Подписка на изменение длины массива
|
|
@@ -2164,10 +2206,10 @@ class T extends F {
|
|
|
2164
2206
|
*/
|
|
2165
2207
|
watchLength(e) {
|
|
2166
2208
|
const t = E(() => {
|
|
2167
|
-
const
|
|
2168
|
-
e(
|
|
2169
|
-
}),
|
|
2170
|
-
return this.disposers.add(
|
|
2209
|
+
const i = this.length.value;
|
|
2210
|
+
e(i);
|
|
2211
|
+
}), r = S("watchLength");
|
|
2212
|
+
return this.disposers.add(r, t);
|
|
2171
2213
|
}
|
|
2172
2214
|
/**
|
|
2173
2215
|
* Очистить все ресурсы узла
|
|
@@ -2230,7 +2272,7 @@ class T extends F {
|
|
|
2230
2272
|
});
|
|
2231
2273
|
}
|
|
2232
2274
|
}
|
|
2233
|
-
class
|
|
2275
|
+
class ee {
|
|
2234
2276
|
/**
|
|
2235
2277
|
* Создает узел формы на основе конфигурации
|
|
2236
2278
|
*
|
|
@@ -2280,16 +2322,16 @@ class X {
|
|
|
2280
2322
|
if (Array.isArray(e) && e.length >= 1)
|
|
2281
2323
|
return this.createArrayNodeFromArray(e);
|
|
2282
2324
|
if (this.isFieldConfig(e))
|
|
2283
|
-
return new
|
|
2325
|
+
return new Q(e);
|
|
2284
2326
|
if (this.isArrayConfig(e)) {
|
|
2285
2327
|
const t = e;
|
|
2286
|
-
return new
|
|
2328
|
+
return new N(
|
|
2287
2329
|
t.schema,
|
|
2288
2330
|
t.initialItems
|
|
2289
2331
|
);
|
|
2290
2332
|
}
|
|
2291
2333
|
if (this.isGroupConfig(e))
|
|
2292
|
-
return new
|
|
2334
|
+
return new w(e);
|
|
2293
2335
|
throw new Error(
|
|
2294
2336
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2295
2337
|
e
|
|
@@ -2323,11 +2365,11 @@ class X {
|
|
|
2323
2365
|
*/
|
|
2324
2366
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2325
2367
|
createArrayNodeFromArray(e) {
|
|
2326
|
-
const [t, ...
|
|
2327
|
-
this.isGroupConfig(t) &&
|
|
2328
|
-
for (const
|
|
2329
|
-
this.isGroupConfig(
|
|
2330
|
-
return new
|
|
2368
|
+
const [t, ...r] = e, i = [];
|
|
2369
|
+
this.isGroupConfig(t) && i.push(this.extractValues(t));
|
|
2370
|
+
for (const a of r)
|
|
2371
|
+
this.isGroupConfig(a) ? i.push(this.extractValues(a)) : i.push(a);
|
|
2372
|
+
return new N(t, i);
|
|
2331
2373
|
}
|
|
2332
2374
|
/**
|
|
2333
2375
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2365,8 +2407,8 @@ class X {
|
|
|
2365
2407
|
return e.map((t) => this.extractValues(t));
|
|
2366
2408
|
if (this.isGroupConfig(e)) {
|
|
2367
2409
|
const t = {};
|
|
2368
|
-
for (const [
|
|
2369
|
-
t[
|
|
2410
|
+
for (const [r, i] of Object.entries(e))
|
|
2411
|
+
t[r] = this.extractValues(i);
|
|
2370
2412
|
return t;
|
|
2371
2413
|
}
|
|
2372
2414
|
return e;
|
|
@@ -2446,7 +2488,7 @@ class X {
|
|
|
2446
2488
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2447
2489
|
}
|
|
2448
2490
|
}
|
|
2449
|
-
class
|
|
2491
|
+
class pe {
|
|
2450
2492
|
/**
|
|
2451
2493
|
* Создать Debouncer с заданной задержкой
|
|
2452
2494
|
*
|
|
@@ -2489,17 +2531,17 @@ class fe {
|
|
|
2489
2531
|
* ```
|
|
2490
2532
|
*/
|
|
2491
2533
|
async debounce(e) {
|
|
2492
|
-
return new Promise((t,
|
|
2534
|
+
return new Promise((t, r) => {
|
|
2493
2535
|
if (this.timer && clearTimeout(this.timer), this.delay === 0) {
|
|
2494
|
-
Promise.resolve().then(() => e()).then(t).catch(
|
|
2536
|
+
Promise.resolve().then(() => e()).then(t).catch(r);
|
|
2495
2537
|
return;
|
|
2496
2538
|
}
|
|
2497
2539
|
this.timer = setTimeout(async () => {
|
|
2498
2540
|
try {
|
|
2499
|
-
const
|
|
2500
|
-
t(
|
|
2501
|
-
} catch (
|
|
2502
|
-
i
|
|
2541
|
+
const i = await e();
|
|
2542
|
+
t(i);
|
|
2543
|
+
} catch (i) {
|
|
2544
|
+
r(i);
|
|
2503
2545
|
}
|
|
2504
2546
|
}, this.delay);
|
|
2505
2547
|
});
|
|
@@ -2571,39 +2613,39 @@ class fe {
|
|
|
2571
2613
|
return this.timer !== void 0;
|
|
2572
2614
|
}
|
|
2573
2615
|
}
|
|
2574
|
-
function
|
|
2575
|
-
return new
|
|
2616
|
+
function ye(s) {
|
|
2617
|
+
return new w(s).getProxy();
|
|
2576
2618
|
}
|
|
2577
|
-
function
|
|
2619
|
+
function te(s) {
|
|
2578
2620
|
return {
|
|
2579
2621
|
type: "static",
|
|
2580
2622
|
load: async () => ({
|
|
2581
|
-
items:
|
|
2582
|
-
totalCount:
|
|
2623
|
+
items: s,
|
|
2624
|
+
totalCount: s.length
|
|
2583
2625
|
})
|
|
2584
2626
|
};
|
|
2585
2627
|
}
|
|
2586
|
-
function
|
|
2628
|
+
function re(s) {
|
|
2587
2629
|
let e = null;
|
|
2588
2630
|
return {
|
|
2589
2631
|
type: "preload",
|
|
2590
2632
|
load: async (t) => {
|
|
2591
2633
|
if (!e) {
|
|
2592
|
-
const
|
|
2634
|
+
const r = await s(t);
|
|
2593
2635
|
e = {
|
|
2594
|
-
items:
|
|
2595
|
-
totalCount:
|
|
2636
|
+
items: r,
|
|
2637
|
+
totalCount: r.length
|
|
2596
2638
|
};
|
|
2597
2639
|
}
|
|
2598
2640
|
return e;
|
|
2599
2641
|
}
|
|
2600
2642
|
};
|
|
2601
2643
|
}
|
|
2602
|
-
function
|
|
2644
|
+
function ie(s) {
|
|
2603
2645
|
return {
|
|
2604
2646
|
type: "partial",
|
|
2605
2647
|
load: async (e) => {
|
|
2606
|
-
const t = await
|
|
2648
|
+
const t = await s(e);
|
|
2607
2649
|
return {
|
|
2608
2650
|
items: t,
|
|
2609
2651
|
totalCount: t.length
|
|
@@ -2612,133 +2654,133 @@ function te(a) {
|
|
|
2612
2654
|
}
|
|
2613
2655
|
};
|
|
2614
2656
|
}
|
|
2615
|
-
const
|
|
2616
|
-
static:
|
|
2617
|
-
preload:
|
|
2618
|
-
partial:
|
|
2657
|
+
const me = {
|
|
2658
|
+
static: te,
|
|
2659
|
+
preload: re,
|
|
2660
|
+
partial: ie
|
|
2619
2661
|
};
|
|
2620
|
-
var
|
|
2621
|
-
var
|
|
2622
|
-
function
|
|
2623
|
-
if (
|
|
2624
|
-
|
|
2625
|
-
var
|
|
2662
|
+
var A = { exports: {} }, x = {};
|
|
2663
|
+
var I;
|
|
2664
|
+
function se() {
|
|
2665
|
+
if (I) return x;
|
|
2666
|
+
I = 1;
|
|
2667
|
+
var s = L;
|
|
2626
2668
|
function e(c, f) {
|
|
2627
2669
|
return c === f && (c !== 0 || 1 / c === 1 / f) || c !== c && f !== f;
|
|
2628
2670
|
}
|
|
2629
|
-
var t = typeof Object.is == "function" ? Object.is : e,
|
|
2671
|
+
var t = typeof Object.is == "function" ? Object.is : e, r = s.useState, i = s.useEffect, a = s.useLayoutEffect, n = s.useDebugValue;
|
|
2630
2672
|
function o(c, f) {
|
|
2631
|
-
var
|
|
2632
|
-
return
|
|
2673
|
+
var d = f(), v = r({ inst: { value: d, getSnapshot: f } }), p = v[0].inst, g = v[1];
|
|
2674
|
+
return a(
|
|
2633
2675
|
function() {
|
|
2634
|
-
p.value =
|
|
2676
|
+
p.value = d, p.getSnapshot = f, l(p) && g({ inst: p });
|
|
2635
2677
|
},
|
|
2636
|
-
[c,
|
|
2637
|
-
),
|
|
2678
|
+
[c, d, f]
|
|
2679
|
+
), i(
|
|
2638
2680
|
function() {
|
|
2639
2681
|
return l(p) && g({ inst: p }), c(function() {
|
|
2640
2682
|
l(p) && g({ inst: p });
|
|
2641
2683
|
});
|
|
2642
2684
|
},
|
|
2643
2685
|
[c]
|
|
2644
|
-
), n(
|
|
2686
|
+
), n(d), d;
|
|
2645
2687
|
}
|
|
2646
2688
|
function l(c) {
|
|
2647
2689
|
var f = c.getSnapshot;
|
|
2648
2690
|
c = c.value;
|
|
2649
2691
|
try {
|
|
2650
|
-
var
|
|
2651
|
-
return !t(c,
|
|
2692
|
+
var d = f();
|
|
2693
|
+
return !t(c, d);
|
|
2652
2694
|
} catch {
|
|
2653
2695
|
return !0;
|
|
2654
2696
|
}
|
|
2655
2697
|
}
|
|
2656
|
-
function
|
|
2698
|
+
function h(c, f) {
|
|
2657
2699
|
return f();
|
|
2658
2700
|
}
|
|
2659
|
-
var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ?
|
|
2660
|
-
return
|
|
2701
|
+
var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? h : o;
|
|
2702
|
+
return x.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : m, x;
|
|
2661
2703
|
}
|
|
2662
|
-
var
|
|
2663
|
-
var
|
|
2664
|
-
function
|
|
2665
|
-
return
|
|
2666
|
-
function
|
|
2667
|
-
return
|
|
2704
|
+
var P = {};
|
|
2705
|
+
var M;
|
|
2706
|
+
function ae() {
|
|
2707
|
+
return M || (M = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2708
|
+
function s(d, v) {
|
|
2709
|
+
return d === v && (d !== 0 || 1 / d === 1 / v) || d !== d && v !== v;
|
|
2668
2710
|
}
|
|
2669
|
-
function e(
|
|
2670
|
-
m ||
|
|
2711
|
+
function e(d, v) {
|
|
2712
|
+
m || i.startTransition === void 0 || (m = !0, console.error(
|
|
2671
2713
|
"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."
|
|
2672
2714
|
));
|
|
2673
2715
|
var p = v();
|
|
2674
2716
|
if (!c) {
|
|
2675
2717
|
var g = v();
|
|
2676
|
-
|
|
2718
|
+
a(p, g) || (console.error(
|
|
2677
2719
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2678
2720
|
), c = !0);
|
|
2679
2721
|
}
|
|
2680
2722
|
g = n({
|
|
2681
2723
|
inst: { value: p, getSnapshot: v }
|
|
2682
2724
|
});
|
|
2683
|
-
var _ = g[0].inst,
|
|
2725
|
+
var _ = g[0].inst, k = g[1];
|
|
2684
2726
|
return l(
|
|
2685
2727
|
function() {
|
|
2686
|
-
_.value = p, _.getSnapshot = v, t(_) &&
|
|
2728
|
+
_.value = p, _.getSnapshot = v, t(_) && k({ inst: _ });
|
|
2687
2729
|
},
|
|
2688
|
-
[
|
|
2730
|
+
[d, p, v]
|
|
2689
2731
|
), o(
|
|
2690
2732
|
function() {
|
|
2691
|
-
return t(_) &&
|
|
2692
|
-
t(_) &&
|
|
2733
|
+
return t(_) && k({ inst: _ }), d(function() {
|
|
2734
|
+
t(_) && k({ inst: _ });
|
|
2693
2735
|
});
|
|
2694
2736
|
},
|
|
2695
|
-
[
|
|
2696
|
-
),
|
|
2737
|
+
[d]
|
|
2738
|
+
), h(p), p;
|
|
2697
2739
|
}
|
|
2698
|
-
function t(
|
|
2699
|
-
var v =
|
|
2700
|
-
|
|
2740
|
+
function t(d) {
|
|
2741
|
+
var v = d.getSnapshot;
|
|
2742
|
+
d = d.value;
|
|
2701
2743
|
try {
|
|
2702
2744
|
var p = v();
|
|
2703
|
-
return !
|
|
2745
|
+
return !a(d, p);
|
|
2704
2746
|
} catch {
|
|
2705
2747
|
return !0;
|
|
2706
2748
|
}
|
|
2707
2749
|
}
|
|
2708
|
-
function
|
|
2750
|
+
function r(d, v) {
|
|
2709
2751
|
return v();
|
|
2710
2752
|
}
|
|
2711
2753
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2712
|
-
var
|
|
2713
|
-
|
|
2714
|
-
})()),
|
|
2754
|
+
var i = L, a = typeof Object.is == "function" ? Object.is : s, n = i.useState, o = i.useEffect, l = i.useLayoutEffect, h = i.useDebugValue, m = !1, c = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
2755
|
+
P.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
2756
|
+
})()), P;
|
|
2715
2757
|
}
|
|
2716
|
-
var
|
|
2717
|
-
function
|
|
2718
|
-
return
|
|
2758
|
+
var B;
|
|
2759
|
+
function ne() {
|
|
2760
|
+
return B || (B = 1, process.env.NODE_ENV === "production" ? A.exports = se() : A.exports = ae()), A.exports;
|
|
2719
2761
|
}
|
|
2720
|
-
var
|
|
2721
|
-
function
|
|
2722
|
-
if (
|
|
2723
|
-
if (
|
|
2724
|
-
for (let t = 0; t <
|
|
2725
|
-
if (
|
|
2762
|
+
var U = ne();
|
|
2763
|
+
function oe(s, e) {
|
|
2764
|
+
if (s === e) return !0;
|
|
2765
|
+
if (s.length !== e.length) return !1;
|
|
2766
|
+
for (let t = 0; t < s.length; t++)
|
|
2767
|
+
if (s[t] !== e[t]) return !1;
|
|
2726
2768
|
return !0;
|
|
2727
2769
|
}
|
|
2728
|
-
function
|
|
2729
|
-
const
|
|
2730
|
-
if (
|
|
2770
|
+
function $(s, e, t) {
|
|
2771
|
+
const r = G(null);
|
|
2772
|
+
if (r.current === null) {
|
|
2731
2773
|
const n = {};
|
|
2732
|
-
for (const o in
|
|
2733
|
-
n[o] =
|
|
2734
|
-
|
|
2774
|
+
for (const o in s)
|
|
2775
|
+
n[o] = s[o].value;
|
|
2776
|
+
r.current = { ...n, __snapshot: null };
|
|
2735
2777
|
}
|
|
2736
|
-
const
|
|
2778
|
+
const i = b(
|
|
2737
2779
|
(n) => {
|
|
2738
2780
|
let o = !0;
|
|
2739
2781
|
return E(() => {
|
|
2740
|
-
for (const
|
|
2741
|
-
|
|
2782
|
+
for (const h in s)
|
|
2783
|
+
s[h].value;
|
|
2742
2784
|
if (o) {
|
|
2743
2785
|
o = !1;
|
|
2744
2786
|
return;
|
|
@@ -2746,43 +2788,43 @@ function G(a, e, t) {
|
|
|
2746
2788
|
n();
|
|
2747
2789
|
});
|
|
2748
2790
|
},
|
|
2749
|
-
[
|
|
2750
|
-
),
|
|
2751
|
-
const n =
|
|
2752
|
-
for (const
|
|
2753
|
-
o[
|
|
2791
|
+
[s]
|
|
2792
|
+
), a = b(() => {
|
|
2793
|
+
const n = r.current, o = {};
|
|
2794
|
+
for (const h in s)
|
|
2795
|
+
o[h] = s[h].value;
|
|
2754
2796
|
let l = !1;
|
|
2755
|
-
for (const
|
|
2756
|
-
const { key: m, useShallowArrayEqual: c } =
|
|
2797
|
+
for (const h of e) {
|
|
2798
|
+
const { key: m, useShallowArrayEqual: c } = h, f = o[m], d = n[m];
|
|
2757
2799
|
if (c) {
|
|
2758
|
-
if (!
|
|
2800
|
+
if (!oe(d, f)) {
|
|
2759
2801
|
l = !0;
|
|
2760
2802
|
break;
|
|
2761
2803
|
}
|
|
2762
|
-
} else if (
|
|
2804
|
+
} else if (d !== f) {
|
|
2763
2805
|
l = !0;
|
|
2764
2806
|
break;
|
|
2765
2807
|
}
|
|
2766
2808
|
}
|
|
2767
2809
|
if (!l && n.__snapshot)
|
|
2768
2810
|
return n.__snapshot;
|
|
2769
|
-
for (const
|
|
2770
|
-
n[
|
|
2811
|
+
for (const h in s)
|
|
2812
|
+
n[h] = o[h];
|
|
2771
2813
|
return n.__snapshot = t(o), n.__snapshot;
|
|
2772
|
-
}, [
|
|
2773
|
-
return
|
|
2814
|
+
}, [s, t]);
|
|
2815
|
+
return U.useSyncExternalStore(i, a, a);
|
|
2774
2816
|
}
|
|
2775
|
-
function
|
|
2817
|
+
function le(s) {
|
|
2776
2818
|
const e = {
|
|
2777
|
-
value:
|
|
2778
|
-
disabled:
|
|
2779
|
-
errors:
|
|
2780
|
-
pending:
|
|
2781
|
-
valid:
|
|
2782
|
-
invalid:
|
|
2783
|
-
touched:
|
|
2784
|
-
shouldShowError:
|
|
2785
|
-
componentProps:
|
|
2819
|
+
value: s.value,
|
|
2820
|
+
disabled: s.disabled,
|
|
2821
|
+
errors: s.errors,
|
|
2822
|
+
pending: s.pending,
|
|
2823
|
+
valid: s.valid,
|
|
2824
|
+
invalid: s.invalid,
|
|
2825
|
+
touched: s.touched,
|
|
2826
|
+
shouldShowError: s.shouldShowError,
|
|
2827
|
+
componentProps: s.componentProps
|
|
2786
2828
|
}, t = [
|
|
2787
2829
|
{ key: "value" },
|
|
2788
2830
|
{ key: "disabled" },
|
|
@@ -2793,32 +2835,32 @@ function ne(a) {
|
|
|
2793
2835
|
{ key: "touched" },
|
|
2794
2836
|
{ key: "shouldShowError" },
|
|
2795
2837
|
{ key: "componentProps" }
|
|
2796
|
-
],
|
|
2797
|
-
(
|
|
2798
|
-
value:
|
|
2799
|
-
pending:
|
|
2800
|
-
disabled:
|
|
2801
|
-
errors:
|
|
2802
|
-
valid:
|
|
2803
|
-
invalid:
|
|
2804
|
-
touched:
|
|
2805
|
-
shouldShowError:
|
|
2806
|
-
componentProps:
|
|
2838
|
+
], r = b(
|
|
2839
|
+
(i) => ({
|
|
2840
|
+
value: i.value,
|
|
2841
|
+
pending: i.pending,
|
|
2842
|
+
disabled: i.disabled,
|
|
2843
|
+
errors: i.errors,
|
|
2844
|
+
valid: i.valid,
|
|
2845
|
+
invalid: i.invalid,
|
|
2846
|
+
touched: i.touched,
|
|
2847
|
+
shouldShowError: i.shouldShowError,
|
|
2848
|
+
componentProps: i.componentProps
|
|
2807
2849
|
}),
|
|
2808
2850
|
[]
|
|
2809
2851
|
);
|
|
2810
|
-
return
|
|
2852
|
+
return $(e, t, r);
|
|
2811
2853
|
}
|
|
2812
|
-
function
|
|
2854
|
+
function ue(s) {
|
|
2813
2855
|
const e = {
|
|
2814
|
-
value:
|
|
2815
|
-
length:
|
|
2816
|
-
errors:
|
|
2817
|
-
pending:
|
|
2818
|
-
valid:
|
|
2819
|
-
invalid:
|
|
2820
|
-
touched:
|
|
2821
|
-
dirty:
|
|
2856
|
+
value: s.value,
|
|
2857
|
+
length: s.length,
|
|
2858
|
+
errors: s.errors,
|
|
2859
|
+
pending: s.pending,
|
|
2860
|
+
valid: s.valid,
|
|
2861
|
+
invalid: s.invalid,
|
|
2862
|
+
touched: s.touched,
|
|
2863
|
+
dirty: s.dirty
|
|
2822
2864
|
}, t = [
|
|
2823
2865
|
{ key: "value" },
|
|
2824
2866
|
{ key: "length" },
|
|
@@ -2828,24 +2870,24 @@ function oe(a) {
|
|
|
2828
2870
|
{ key: "invalid" },
|
|
2829
2871
|
{ key: "touched" },
|
|
2830
2872
|
{ key: "dirty" }
|
|
2831
|
-
],
|
|
2832
|
-
(
|
|
2833
|
-
value:
|
|
2834
|
-
length:
|
|
2835
|
-
pending:
|
|
2836
|
-
errors:
|
|
2837
|
-
valid:
|
|
2838
|
-
invalid:
|
|
2839
|
-
touched:
|
|
2840
|
-
dirty:
|
|
2873
|
+
], r = b(
|
|
2874
|
+
(i) => ({
|
|
2875
|
+
value: i.value,
|
|
2876
|
+
length: i.length,
|
|
2877
|
+
pending: i.pending,
|
|
2878
|
+
errors: i.errors,
|
|
2879
|
+
valid: i.valid,
|
|
2880
|
+
invalid: i.invalid,
|
|
2881
|
+
touched: i.touched,
|
|
2882
|
+
dirty: i.dirty
|
|
2841
2883
|
}),
|
|
2842
2884
|
[]
|
|
2843
2885
|
);
|
|
2844
|
-
return
|
|
2886
|
+
return $(e, t, r);
|
|
2845
2887
|
}
|
|
2846
|
-
function
|
|
2847
|
-
const e =
|
|
2848
|
-
return
|
|
2888
|
+
function ge(s) {
|
|
2889
|
+
const e = s && "length" in s && "map" in s;
|
|
2890
|
+
return s ? e ? ue(s) : le(s) : {
|
|
2849
2891
|
value: [],
|
|
2850
2892
|
length: 0,
|
|
2851
2893
|
pending: !1,
|
|
@@ -2856,56 +2898,57 @@ function ye(a) {
|
|
|
2856
2898
|
dirty: !1
|
|
2857
2899
|
};
|
|
2858
2900
|
}
|
|
2859
|
-
function
|
|
2860
|
-
const e =
|
|
2861
|
-
(
|
|
2862
|
-
let
|
|
2901
|
+
function _e(s) {
|
|
2902
|
+
const e = G({ value: s.value.value }), t = b(
|
|
2903
|
+
(i) => {
|
|
2904
|
+
let a = !0;
|
|
2863
2905
|
return E(() => {
|
|
2864
|
-
if (
|
|
2865
|
-
|
|
2906
|
+
if (s.value.value, a) {
|
|
2907
|
+
a = !1;
|
|
2866
2908
|
return;
|
|
2867
2909
|
}
|
|
2868
|
-
|
|
2910
|
+
i();
|
|
2869
2911
|
});
|
|
2870
2912
|
},
|
|
2871
|
-
[
|
|
2872
|
-
),
|
|
2873
|
-
const
|
|
2874
|
-
return e.current.value ===
|
|
2875
|
-
}, [
|
|
2876
|
-
return
|
|
2913
|
+
[s]
|
|
2914
|
+
), r = b(() => {
|
|
2915
|
+
const i = s.value.value;
|
|
2916
|
+
return e.current.value === i ? e.current.value : (e.current.value = i, i);
|
|
2917
|
+
}, [s]);
|
|
2918
|
+
return U.useSyncExternalStore(t, r, r);
|
|
2877
2919
|
}
|
|
2878
2920
|
export {
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2921
|
+
N as ArrayNode,
|
|
2922
|
+
pe as Debouncer,
|
|
2923
|
+
V as ErrorStrategy,
|
|
2924
|
+
Q as FieldNode,
|
|
2925
|
+
Z as FieldPathNavigator,
|
|
2884
2926
|
O as FormErrorHandler,
|
|
2885
2927
|
F as FormNode,
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2928
|
+
w as GroupNode,
|
|
2929
|
+
ee as NodeFactory,
|
|
2930
|
+
Fe as RegistryStack,
|
|
2931
|
+
me as Resources,
|
|
2932
|
+
C as SubscriptionManager,
|
|
2933
|
+
Se as behaviors,
|
|
2934
|
+
D as createFieldPath,
|
|
2935
|
+
ye as createForm,
|
|
2936
|
+
Ce as extractKey,
|
|
2937
|
+
Re as extractPath,
|
|
2938
|
+
Te as getCurrentBehaviorRegistry,
|
|
2897
2939
|
De as getCurrentValidationRegistry,
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2940
|
+
Ae as getNodeType,
|
|
2941
|
+
T as isArrayNode,
|
|
2942
|
+
R as isFieldNode,
|
|
2943
|
+
Ve as isFormNode,
|
|
2944
|
+
ke as isGroupNode,
|
|
2945
|
+
ie as partialResource,
|
|
2946
|
+
re as preloadResource,
|
|
2947
|
+
te as staticResource,
|
|
2948
|
+
Ne as toFieldPath,
|
|
2949
|
+
S as uniqueId,
|
|
2950
|
+
ge as useFormControl,
|
|
2951
|
+
_e as useFormControlValue,
|
|
2952
|
+
xe as validateForm,
|
|
2953
|
+
Pe as validators
|
|
2911
2954
|
};
|