@reformer/core 2.0.0-beta.5 → 2.0.0-beta.6
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/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { d as y, w as u, E, r as U } from "./behaviors-
|
|
2
|
-
import { i as Ee } from "./behaviors-
|
|
3
|
-
import { i as
|
|
4
|
-
import { g as
|
|
5
|
-
import { V as H, B as W, c as
|
|
6
|
-
import { R as
|
|
1
|
+
import { d as y, w as u, E, r as U } from "./behaviors-2HSqHPb4.js";
|
|
2
|
+
import { i as Ee } from "./behaviors-2HSqHPb4.js";
|
|
3
|
+
import { i as C, a as D, A as j, V as q, T as K } from "./validators-gXoHPdqM.js";
|
|
4
|
+
import { g as Se, c as we, d as Ae, v as Ve, b as ke } from "./validators-gXoHPdqM.js";
|
|
5
|
+
import { V as H, B as W, c as R } from "./registry-helpers-BRxAr6nG.js";
|
|
6
|
+
import { R as Oe, a as Fe, e as Pe, b as Ce, g as De, t as Re } from "./registry-helpers-BRxAr6nG.js";
|
|
7
7
|
import { v4 as z } from "uuid";
|
|
8
|
-
import B, { useRef as L, useCallback as
|
|
9
|
-
class
|
|
8
|
+
import B, { useRef as L, useCallback as b } from "react";
|
|
9
|
+
class F {
|
|
10
10
|
// ============================================================================
|
|
11
11
|
// Protected состояние (для Template Method паттерна)
|
|
12
12
|
// ============================================================================
|
|
@@ -106,8 +106,8 @@ class O {
|
|
|
106
106
|
if (e.params !== void 0) {
|
|
107
107
|
if (!i.params)
|
|
108
108
|
return !1;
|
|
109
|
-
for (const [
|
|
110
|
-
if (i.params[
|
|
109
|
+
for (const [r, s] of Object.entries(e.params))
|
|
110
|
+
if (i.params[r] !== s)
|
|
111
111
|
return !1;
|
|
112
112
|
}
|
|
113
113
|
return !(e.predicate !== void 0 && !e.predicate(i));
|
|
@@ -451,8 +451,8 @@ class P {
|
|
|
451
451
|
this.clear();
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
var
|
|
455
|
-
class
|
|
454
|
+
var A = /* @__PURE__ */ ((a) => (a.THROW = "throw", a.LOG = "log", a.CONVERT = "convert", a))(A || {});
|
|
455
|
+
class O {
|
|
456
456
|
/**
|
|
457
457
|
* Обработать ошибку согласно заданной стратегии
|
|
458
458
|
*
|
|
@@ -493,7 +493,7 @@ class F {
|
|
|
493
493
|
* ```
|
|
494
494
|
*/
|
|
495
495
|
static handle(e, t, i = "throw") {
|
|
496
|
-
const
|
|
496
|
+
const r = this.extractMessage(e);
|
|
497
497
|
switch (i) {
|
|
498
498
|
case "throw":
|
|
499
499
|
throw e;
|
|
@@ -502,7 +502,7 @@ class F {
|
|
|
502
502
|
case "convert":
|
|
503
503
|
return {
|
|
504
504
|
code: "validator_error",
|
|
505
|
-
message:
|
|
505
|
+
message: r,
|
|
506
506
|
params: { field: t }
|
|
507
507
|
};
|
|
508
508
|
}
|
|
@@ -584,7 +584,7 @@ class F {
|
|
|
584
584
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
-
class J extends
|
|
587
|
+
class J extends F {
|
|
588
588
|
// ============================================================================
|
|
589
589
|
// Приватные сигналы
|
|
590
590
|
// ============================================================================
|
|
@@ -618,6 +618,7 @@ class J extends O {
|
|
|
618
618
|
updateOn;
|
|
619
619
|
initialValue;
|
|
620
620
|
currentValidationId = 0;
|
|
621
|
+
currentAbortController;
|
|
621
622
|
debounceMs;
|
|
622
623
|
validateDebounceTimer;
|
|
623
624
|
validateDebounceResolve;
|
|
@@ -644,12 +645,12 @@ class J extends O {
|
|
|
644
645
|
setValue(e, t) {
|
|
645
646
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
646
647
|
return;
|
|
647
|
-
const i = this.validators.length > 0 || this.asyncValidators.length > 0,
|
|
648
|
+
const i = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
|
|
648
649
|
if (this.updateOn === "change") {
|
|
649
650
|
this.validate();
|
|
650
651
|
return;
|
|
651
652
|
}
|
|
652
|
-
|
|
653
|
+
r && i && this.validate();
|
|
653
654
|
}
|
|
654
655
|
patchValue(e) {
|
|
655
656
|
this.setValue(e);
|
|
@@ -729,14 +730,14 @@ class J extends O {
|
|
|
729
730
|
async validate(e) {
|
|
730
731
|
const t = e?.debounce ?? this.debounceMs;
|
|
731
732
|
return t > 0 && this.asyncValidators.length > 0 ? new Promise((i) => {
|
|
732
|
-
const
|
|
733
|
+
const r = this.currentValidationId;
|
|
733
734
|
this.validateDebounceResolve && this.validateDebounceResolve(!1), this.validateDebounceTimer && clearTimeout(this.validateDebounceTimer), this.validateDebounceResolve = i, this.validateDebounceTimer = setTimeout(async () => {
|
|
734
|
-
if (this.validateDebounceResolve = void 0,
|
|
735
|
+
if (this.validateDebounceResolve = void 0, r !== this.currentValidationId) {
|
|
735
736
|
i(!1);
|
|
736
737
|
return;
|
|
737
738
|
}
|
|
738
|
-
const
|
|
739
|
-
i(
|
|
739
|
+
const s = await this.validateImmediate();
|
|
740
|
+
i(s);
|
|
740
741
|
}, t);
|
|
741
742
|
}) : this.validateImmediate();
|
|
742
743
|
}
|
|
@@ -744,47 +745,64 @@ class J extends O {
|
|
|
744
745
|
* Немедленная валидация без debounce
|
|
745
746
|
* @private
|
|
746
747
|
* @remarks
|
|
747
|
-
* Защищена от race conditions:
|
|
748
|
-
* -
|
|
749
|
-
* -
|
|
750
|
-
* -
|
|
751
|
-
* - Проверка перед обработкой async результатов
|
|
752
|
-
* - Проверка перед очисткой errors
|
|
748
|
+
* Защищена от race conditions через AbortController:
|
|
749
|
+
* - Отменяет предыдущую валидацию при запуске новой
|
|
750
|
+
* - Передаёт AbortSignal в async валидаторы для отмены операций (например, fetch)
|
|
751
|
+
* - Проверяет signal.aborted в ключевых точках
|
|
753
752
|
*/
|
|
754
753
|
async validateImmediate() {
|
|
755
|
-
|
|
754
|
+
this.currentAbortController?.abort();
|
|
755
|
+
const e = new AbortController();
|
|
756
|
+
this.currentAbortController = e;
|
|
757
|
+
const { signal: t } = e;
|
|
758
|
+
++this.currentValidationId;
|
|
759
|
+
const i = [];
|
|
756
760
|
for (const s of this.validators) {
|
|
757
|
-
const
|
|
758
|
-
|
|
761
|
+
const n = s(this._value.value);
|
|
762
|
+
n && i.push(n);
|
|
759
763
|
}
|
|
760
|
-
if (
|
|
764
|
+
if (t.aborted)
|
|
761
765
|
return !1;
|
|
762
|
-
if (
|
|
763
|
-
return this._errors.value =
|
|
766
|
+
if (i.length > 0)
|
|
767
|
+
return this._errors.value = i, this._status.value = "invalid", !1;
|
|
764
768
|
if (this.asyncValidators.length > 0) {
|
|
765
|
-
if (
|
|
769
|
+
if (t.aborted)
|
|
766
770
|
return !1;
|
|
767
771
|
this._pending.value = !0, this._status.value = "pending";
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
772
|
+
try {
|
|
773
|
+
const s = await Promise.all(
|
|
774
|
+
this.asyncValidators.map(async (o) => {
|
|
775
|
+
if (t.aborted)
|
|
776
|
+
throw new DOMException("Validation aborted", "AbortError");
|
|
777
|
+
try {
|
|
778
|
+
const l = await o(this._value.value, { signal: t });
|
|
779
|
+
if (t.aborted)
|
|
780
|
+
throw new DOMException("Validation aborted", "AbortError");
|
|
781
|
+
return l;
|
|
782
|
+
} catch (l) {
|
|
783
|
+
if (l instanceof DOMException && l.name === "AbortError")
|
|
784
|
+
throw l;
|
|
785
|
+
return O.handle(
|
|
786
|
+
l,
|
|
787
|
+
"FieldNode AsyncValidator",
|
|
788
|
+
A.CONVERT
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
})
|
|
792
|
+
);
|
|
793
|
+
if (t.aborted)
|
|
794
|
+
return !1;
|
|
795
|
+
this._pending.value = !1;
|
|
796
|
+
const n = s.filter(Boolean);
|
|
797
|
+
if (n.length > 0)
|
|
798
|
+
return this._errors.value = n, this._status.value = "invalid", !1;
|
|
799
|
+
} catch (s) {
|
|
800
|
+
if (s instanceof DOMException && s.name === "AbortError")
|
|
801
|
+
return !1;
|
|
802
|
+
throw s;
|
|
803
|
+
}
|
|
786
804
|
}
|
|
787
|
-
return
|
|
805
|
+
return t.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this._status.value = "valid"), this._errors.value.length === 0);
|
|
788
806
|
}
|
|
789
807
|
setErrors(e) {
|
|
790
808
|
this._errors.value = e, this._status.value = e.length > 0 ? "invalid" : "valid";
|
|
@@ -897,8 +915,8 @@ class J extends O {
|
|
|
897
915
|
*/
|
|
898
916
|
watch(e) {
|
|
899
917
|
const t = E(() => {
|
|
900
|
-
const
|
|
901
|
-
e(
|
|
918
|
+
const r = this.value.value;
|
|
919
|
+
e(r);
|
|
902
920
|
}), i = `watch-${Date.now()}-${Math.random()}`;
|
|
903
921
|
return this.disposers.add(i, t);
|
|
904
922
|
}
|
|
@@ -926,15 +944,22 @@ class J extends O {
|
|
|
926
944
|
*/
|
|
927
945
|
computeFrom(e, t) {
|
|
928
946
|
const i = E(() => {
|
|
929
|
-
const
|
|
930
|
-
this.setValue(
|
|
931
|
-
}),
|
|
932
|
-
return this.disposers.add(
|
|
947
|
+
const s = e.map((o) => o.value), n = t(...s);
|
|
948
|
+
this.setValue(n, { emitEvent: !1 });
|
|
949
|
+
}), r = `computeFrom-${Date.now()}-${Math.random()}`;
|
|
950
|
+
return this.disposers.add(r, i);
|
|
933
951
|
}
|
|
934
952
|
/**
|
|
935
953
|
* Очистить все ресурсы и таймеры
|
|
936
954
|
* Должен вызываться при unmount компонента
|
|
937
955
|
*
|
|
956
|
+
* @remarks
|
|
957
|
+
* Освобождает все ресурсы:
|
|
958
|
+
* - Отписывает все subscriptions через SubscriptionManager
|
|
959
|
+
* - Очищает debounce таймер
|
|
960
|
+
* - Resolve'ит висячий debounce промис (предотвращает утечку памяти)
|
|
961
|
+
* - Отменяет текущую async валидацию через AbortController
|
|
962
|
+
*
|
|
938
963
|
* @example
|
|
939
964
|
* ```typescript
|
|
940
965
|
* useEffect(() => {
|
|
@@ -945,7 +970,7 @@ class J extends O {
|
|
|
945
970
|
* ```
|
|
946
971
|
*/
|
|
947
972
|
dispose() {
|
|
948
|
-
this.disposers.dispose(), this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0);
|
|
973
|
+
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);
|
|
949
974
|
}
|
|
950
975
|
}
|
|
951
976
|
class Y {
|
|
@@ -979,12 +1004,12 @@ class Y {
|
|
|
979
1004
|
*/
|
|
980
1005
|
groupValidators(e) {
|
|
981
1006
|
const t = /* @__PURE__ */ new Map(), i = [];
|
|
982
|
-
for (const
|
|
983
|
-
if (
|
|
984
|
-
i.push(
|
|
1007
|
+
for (const r of e)
|
|
1008
|
+
if (r.type === "tree")
|
|
1009
|
+
i.push(r);
|
|
985
1010
|
else {
|
|
986
|
-
const
|
|
987
|
-
|
|
1011
|
+
const s = t.get(r.fieldPath) || [];
|
|
1012
|
+
s.push(r), t.set(r.fieldPath, s);
|
|
988
1013
|
}
|
|
989
1014
|
return { validatorsByField: t, treeValidators: i };
|
|
990
1015
|
}
|
|
@@ -1001,36 +1026,36 @@ class Y {
|
|
|
1001
1026
|
*/
|
|
1002
1027
|
async applyFieldValidators(e) {
|
|
1003
1028
|
for (const [t, i] of e) {
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1029
|
+
const r = this.form.getFieldByPath(t);
|
|
1030
|
+
if (!r) {
|
|
1006
1031
|
console.warn(`Field ${t} not found in GroupNode`);
|
|
1007
1032
|
continue;
|
|
1008
1033
|
}
|
|
1009
|
-
if (!
|
|
1034
|
+
if (!C(r) && !D(r)) {
|
|
1010
1035
|
process.env.NODE_ENV !== "production" && console.warn(`Validation can only run on FieldNode or ArrayNode, skipping ${t}`);
|
|
1011
1036
|
continue;
|
|
1012
1037
|
}
|
|
1013
|
-
const
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1038
|
+
const s = [];
|
|
1039
|
+
let n;
|
|
1040
|
+
if (D(r)) {
|
|
1041
|
+
const o = r.getValue();
|
|
1042
|
+
n = new j(this.form, t, o);
|
|
1018
1043
|
} else
|
|
1019
|
-
|
|
1020
|
-
for (const
|
|
1021
|
-
if (!(
|
|
1044
|
+
n = new q(this.form, t, r);
|
|
1045
|
+
for (const o of i)
|
|
1046
|
+
if (!(o.condition && !this.checkCondition(o.condition)))
|
|
1022
1047
|
try {
|
|
1023
1048
|
let l = null;
|
|
1024
|
-
const d =
|
|
1025
|
-
|
|
1049
|
+
const d = n.value(), m = o.validator;
|
|
1050
|
+
o.type === "sync" ? l = m(d, n) : o.type === "async" && (l = await m(d, n)), l && s.push(l);
|
|
1026
1051
|
} catch (l) {
|
|
1027
|
-
|
|
1052
|
+
O.handle(
|
|
1028
1053
|
l,
|
|
1029
1054
|
`ValidationApplicator: validator for ${t}`,
|
|
1030
|
-
|
|
1055
|
+
A.LOG
|
|
1031
1056
|
);
|
|
1032
1057
|
}
|
|
1033
|
-
|
|
1058
|
+
s.length > 0 ? r.setErrors(s) : r.clearErrors();
|
|
1034
1059
|
}
|
|
1035
1060
|
}
|
|
1036
1061
|
/**
|
|
@@ -1048,19 +1073,19 @@ class Y {
|
|
|
1048
1073
|
try {
|
|
1049
1074
|
if (t.type !== "tree")
|
|
1050
1075
|
continue;
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1076
|
+
const r = t.validator(i);
|
|
1077
|
+
if (r && t.options && "targetField" in t.options) {
|
|
1078
|
+
const s = t.options.targetField;
|
|
1079
|
+
if (s) {
|
|
1080
|
+
const n = this.form.getFieldByPath(String(s));
|
|
1081
|
+
if (n && C(n)) {
|
|
1082
|
+
const o = n.errors.value;
|
|
1083
|
+
n.setErrors([...o, r]);
|
|
1059
1084
|
}
|
|
1060
1085
|
}
|
|
1061
1086
|
}
|
|
1062
|
-
} catch (
|
|
1063
|
-
|
|
1087
|
+
} catch (r) {
|
|
1088
|
+
O.handle(r, "ValidationApplicator: tree validator", A.LOG);
|
|
1064
1089
|
}
|
|
1065
1090
|
}
|
|
1066
1091
|
}
|
|
@@ -1108,10 +1133,10 @@ class Q {
|
|
|
1108
1133
|
*/
|
|
1109
1134
|
parsePath(e) {
|
|
1110
1135
|
const t = [];
|
|
1111
|
-
let i = "",
|
|
1112
|
-
for (let
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1136
|
+
let i = "", r = !1;
|
|
1137
|
+
for (let s = 0; s < e.length; s++) {
|
|
1138
|
+
const n = e[s];
|
|
1139
|
+
n === "[" ? (r = !0, i += n) : n === "]" ? (r = !1, i += n) : n === "." && !r ? i && (this.addSegment(t, i), i = "") : i += n;
|
|
1115
1140
|
}
|
|
1116
1141
|
return i && this.addSegment(t, i), t;
|
|
1117
1142
|
}
|
|
@@ -1159,15 +1184,15 @@ class Q {
|
|
|
1159
1184
|
*/
|
|
1160
1185
|
getValueByPath(e, t) {
|
|
1161
1186
|
const i = this.parsePath(t);
|
|
1162
|
-
let
|
|
1163
|
-
for (const
|
|
1164
|
-
if (
|
|
1165
|
-
if (
|
|
1166
|
-
if (!Array.isArray(
|
|
1167
|
-
|
|
1187
|
+
let r = e;
|
|
1188
|
+
for (const s of i) {
|
|
1189
|
+
if (r == null) return;
|
|
1190
|
+
if (r = r[s.key], s.index !== void 0) {
|
|
1191
|
+
if (!Array.isArray(r)) return;
|
|
1192
|
+
r = r[s.index];
|
|
1168
1193
|
}
|
|
1169
1194
|
}
|
|
1170
|
-
return
|
|
1195
|
+
return r;
|
|
1171
1196
|
}
|
|
1172
1197
|
/**
|
|
1173
1198
|
* Устанавливает значение по пути в объекте (мутирует объект)
|
|
@@ -1197,30 +1222,30 @@ class Q {
|
|
|
1197
1222
|
* ```
|
|
1198
1223
|
*/
|
|
1199
1224
|
setValueByPath(e, t, i) {
|
|
1200
|
-
const
|
|
1201
|
-
if (
|
|
1225
|
+
const r = this.parsePath(t);
|
|
1226
|
+
if (r.length === 0)
|
|
1202
1227
|
throw new Error("Cannot set value: empty path");
|
|
1203
|
-
let
|
|
1204
|
-
for (let
|
|
1205
|
-
const l =
|
|
1206
|
-
let d =
|
|
1228
|
+
let s = e;
|
|
1229
|
+
for (let o = 0; o < r.length - 1; o++) {
|
|
1230
|
+
const l = r[o];
|
|
1231
|
+
let d = s[l.key];
|
|
1207
1232
|
if (l.index !== void 0) {
|
|
1208
1233
|
if (!Array.isArray(d))
|
|
1209
1234
|
throw new Error(`Expected array at path segment: ${l.key}, but got ${typeof d}`);
|
|
1210
|
-
|
|
1235
|
+
s = d[l.index];
|
|
1211
1236
|
} else
|
|
1212
|
-
d == null && (
|
|
1237
|
+
d == null && (s[l.key] = {}, d = s[l.key]), s = d;
|
|
1213
1238
|
}
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1216
|
-
const
|
|
1217
|
-
if (!Array.isArray(
|
|
1239
|
+
const n = r[r.length - 1];
|
|
1240
|
+
if (n.index !== void 0) {
|
|
1241
|
+
const o = s[n.key];
|
|
1242
|
+
if (!Array.isArray(o))
|
|
1218
1243
|
throw new Error(
|
|
1219
|
-
`Expected array at path segment: ${
|
|
1244
|
+
`Expected array at path segment: ${n.key}, but got ${typeof o}`
|
|
1220
1245
|
);
|
|
1221
|
-
n
|
|
1246
|
+
o[n.index] = i;
|
|
1222
1247
|
} else
|
|
1223
|
-
|
|
1248
|
+
s[n.key] = i;
|
|
1224
1249
|
}
|
|
1225
1250
|
/**
|
|
1226
1251
|
* Получить значение из FormNode по пути
|
|
@@ -1318,35 +1343,35 @@ class Q {
|
|
|
1318
1343
|
*/
|
|
1319
1344
|
getNodeByPath(e, t) {
|
|
1320
1345
|
const i = this.parsePath(t);
|
|
1321
|
-
let
|
|
1322
|
-
for (const
|
|
1323
|
-
if (
|
|
1324
|
-
const
|
|
1325
|
-
if (
|
|
1326
|
-
if (
|
|
1327
|
-
if (
|
|
1346
|
+
let r = e;
|
|
1347
|
+
for (const s of i) {
|
|
1348
|
+
if (r == null) return null;
|
|
1349
|
+
const n = r;
|
|
1350
|
+
if (n.fields && n.fields instanceof Map) {
|
|
1351
|
+
if (r = n.fields.get(s.key), s.index === void 0) {
|
|
1352
|
+
if (r == null) return null;
|
|
1328
1353
|
continue;
|
|
1329
1354
|
}
|
|
1330
|
-
} else if (
|
|
1331
|
-
const
|
|
1332
|
-
if (!Array.isArray(
|
|
1355
|
+
} else if (s.index !== void 0 && n.items) {
|
|
1356
|
+
const o = n.items.value || n.items;
|
|
1357
|
+
if (!Array.isArray(o) || (r = o[s.index], r == null)) return null;
|
|
1333
1358
|
continue;
|
|
1334
|
-
} else if (
|
|
1335
|
-
if (
|
|
1359
|
+
} else if (s.index === void 0) {
|
|
1360
|
+
if (r = n[s.key], r == null) return null;
|
|
1336
1361
|
continue;
|
|
1337
1362
|
}
|
|
1338
|
-
if (
|
|
1339
|
-
const
|
|
1340
|
-
if (!Array.isArray(
|
|
1341
|
-
|
|
1342
|
-
} else if (
|
|
1363
|
+
if (r && s.index !== void 0 && r.items) {
|
|
1364
|
+
const o = r.items.value || r.items;
|
|
1365
|
+
if (!Array.isArray(o)) return null;
|
|
1366
|
+
r = o[s.index];
|
|
1367
|
+
} else if (r && s.index !== void 0 && !r.items)
|
|
1343
1368
|
return null;
|
|
1344
|
-
if (
|
|
1369
|
+
if (r == null) return null;
|
|
1345
1370
|
}
|
|
1346
|
-
return
|
|
1371
|
+
return r;
|
|
1347
1372
|
}
|
|
1348
1373
|
}
|
|
1349
|
-
class
|
|
1374
|
+
class S extends F {
|
|
1350
1375
|
// ============================================================================
|
|
1351
1376
|
// Приватные поля
|
|
1352
1377
|
// ============================================================================
|
|
@@ -1407,30 +1432,30 @@ class b extends O {
|
|
|
1407
1432
|
submitting;
|
|
1408
1433
|
constructor(e) {
|
|
1409
1434
|
super();
|
|
1410
|
-
const t = "form" in e, i = t ? e.form : e,
|
|
1411
|
-
for (const [
|
|
1435
|
+
const t = "form" in e, i = t ? e.form : e, r = t ? e.behavior : void 0, s = t ? e.validation : void 0;
|
|
1436
|
+
for (const [o, l] of Object.entries(i)) {
|
|
1412
1437
|
const d = this.createNode(l);
|
|
1413
|
-
this._fields.set(
|
|
1438
|
+
this._fields.set(o, d);
|
|
1414
1439
|
}
|
|
1415
1440
|
this.value = u(() => {
|
|
1416
|
-
const
|
|
1441
|
+
const o = {};
|
|
1417
1442
|
return this._fields.forEach((l, d) => {
|
|
1418
|
-
|
|
1419
|
-
}),
|
|
1420
|
-
}), this.valid = u(() => this._formErrors.value.length > 0 ? !1 : Array.from(this._fields.values()).every((
|
|
1421
|
-
() => Array.from(this._fields.values()).some((
|
|
1443
|
+
o[d] = l.value.value;
|
|
1444
|
+
}), o;
|
|
1445
|
+
}), this.valid = u(() => this._formErrors.value.length > 0 ? !1 : Array.from(this._fields.values()).every((o) => o.valid.value)), this.invalid = u(() => !this.valid.value), this.pending = u(
|
|
1446
|
+
() => Array.from(this._fields.values()).some((o) => o.pending.value)
|
|
1422
1447
|
), this.touched = u(
|
|
1423
|
-
() => Array.from(this._fields.values()).some((
|
|
1448
|
+
() => Array.from(this._fields.values()).some((o) => o.touched.value)
|
|
1424
1449
|
), this.dirty = u(
|
|
1425
|
-
() => Array.from(this._fields.values()).some((
|
|
1450
|
+
() => Array.from(this._fields.values()).some((o) => o.dirty.value)
|
|
1426
1451
|
), this.errors = u(() => {
|
|
1427
|
-
const
|
|
1452
|
+
const o = [...this._formErrors.value];
|
|
1428
1453
|
return this._fields.forEach((l) => {
|
|
1429
|
-
|
|
1430
|
-
}),
|
|
1454
|
+
o.push(...l.errors.value);
|
|
1455
|
+
}), o;
|
|
1431
1456
|
}), this.status = u(() => this._disabled.value ? "disabled" : this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid"), this.submitting = u(() => this._submitting.value);
|
|
1432
|
-
const
|
|
1433
|
-
return this._proxyInstance =
|
|
1457
|
+
const n = this.buildProxy();
|
|
1458
|
+
return this._proxyInstance = n, r && this.applyBehaviorSchema(r), s && this.applyValidationSchema(s), n;
|
|
1434
1459
|
}
|
|
1435
1460
|
// ============================================================================
|
|
1436
1461
|
// Приватный метод для создания Proxy (inline из ProxyBuilder)
|
|
@@ -1447,11 +1472,11 @@ class b extends O {
|
|
|
1447
1472
|
if (typeof i == "string" && e._fields.has(i))
|
|
1448
1473
|
return e._fields.get(i);
|
|
1449
1474
|
},
|
|
1450
|
-
set: (t, i,
|
|
1475
|
+
set: (t, i, r) => typeof i == "string" && e._fields.has(i) ? !1 : (t[i] = r, !0),
|
|
1451
1476
|
has: (t, i) => typeof i == "string" && e._fields.has(i) ? !0 : i in t,
|
|
1452
1477
|
ownKeys: (t) => {
|
|
1453
|
-
const i = Reflect.ownKeys(t),
|
|
1454
|
-
return [.../* @__PURE__ */ new Set([...i, ...
|
|
1478
|
+
const i = Reflect.ownKeys(t), r = Array.from(e._fields.keys());
|
|
1479
|
+
return [.../* @__PURE__ */ new Set([...i, ...r])];
|
|
1455
1480
|
},
|
|
1456
1481
|
getOwnPropertyDescriptor: (t, i) => typeof i == "string" && e._fields.has(i) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(t, i)
|
|
1457
1482
|
});
|
|
@@ -1466,16 +1491,16 @@ class b extends O {
|
|
|
1466
1491
|
}), e;
|
|
1467
1492
|
}
|
|
1468
1493
|
setValue(e, t) {
|
|
1469
|
-
for (const [i,
|
|
1470
|
-
const
|
|
1471
|
-
|
|
1494
|
+
for (const [i, r] of Object.entries(e)) {
|
|
1495
|
+
const s = this._fields.get(i);
|
|
1496
|
+
s && s.setValue(r, t);
|
|
1472
1497
|
}
|
|
1473
1498
|
}
|
|
1474
1499
|
patchValue(e) {
|
|
1475
1500
|
U(() => {
|
|
1476
1501
|
for (const [t, i] of Object.entries(e)) {
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1502
|
+
const r = this._fields.get(t);
|
|
1503
|
+
r && i !== void 0 && r.setValue(i);
|
|
1479
1504
|
}
|
|
1480
1505
|
});
|
|
1481
1506
|
}
|
|
@@ -1498,8 +1523,8 @@ class b extends O {
|
|
|
1498
1523
|
*/
|
|
1499
1524
|
reset(e) {
|
|
1500
1525
|
this._fields.forEach((t, i) => {
|
|
1501
|
-
const
|
|
1502
|
-
t.reset(
|
|
1526
|
+
const r = e?.[i];
|
|
1527
|
+
t.reset(r);
|
|
1503
1528
|
});
|
|
1504
1529
|
}
|
|
1505
1530
|
/**
|
|
@@ -1614,7 +1639,7 @@ class b extends O {
|
|
|
1614
1639
|
applyValidationSchema(e) {
|
|
1615
1640
|
this.validationRegistry.beginRegistration();
|
|
1616
1641
|
try {
|
|
1617
|
-
const t =
|
|
1642
|
+
const t = R();
|
|
1618
1643
|
e(t);
|
|
1619
1644
|
const i = this.getProxy();
|
|
1620
1645
|
this.validationRegistry.endRegistration(i);
|
|
@@ -1629,7 +1654,7 @@ class b extends O {
|
|
|
1629
1654
|
applyBehaviorSchema(e) {
|
|
1630
1655
|
this.behaviorRegistry.beginRegistration();
|
|
1631
1656
|
try {
|
|
1632
|
-
const t =
|
|
1657
|
+
const t = R();
|
|
1633
1658
|
return e(t), this.behaviorRegistry.endRegistration(this.getProxy()).cleanup;
|
|
1634
1659
|
} catch (t) {
|
|
1635
1660
|
throw console.error("Error applying behavior schema:", t), t;
|
|
@@ -1671,13 +1696,13 @@ class b extends O {
|
|
|
1671
1696
|
if (t.length === 0)
|
|
1672
1697
|
return;
|
|
1673
1698
|
let i = this;
|
|
1674
|
-
for (const
|
|
1675
|
-
if (!(i instanceof
|
|
1676
|
-
if (
|
|
1699
|
+
for (const r of t) {
|
|
1700
|
+
if (!(i instanceof S) || (i = i.getField(r.key), !i)) return;
|
|
1701
|
+
if (r.index !== void 0)
|
|
1677
1702
|
if ("at" in i && "length" in i && typeof i.at == "function") {
|
|
1678
|
-
const
|
|
1679
|
-
if (!
|
|
1680
|
-
i =
|
|
1703
|
+
const s = i.at(r.index);
|
|
1704
|
+
if (!s) return;
|
|
1705
|
+
i = s;
|
|
1681
1706
|
} else
|
|
1682
1707
|
return;
|
|
1683
1708
|
}
|
|
@@ -1726,15 +1751,15 @@ class b extends O {
|
|
|
1726
1751
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1727
1752
|
*/
|
|
1728
1753
|
linkFields(e, t, i) {
|
|
1729
|
-
const
|
|
1730
|
-
if (!
|
|
1754
|
+
const r = this._fields.get(e), s = this._fields.get(t);
|
|
1755
|
+
if (!r || !s)
|
|
1731
1756
|
return () => {
|
|
1732
1757
|
};
|
|
1733
|
-
const
|
|
1734
|
-
const l =
|
|
1735
|
-
|
|
1736
|
-
}),
|
|
1737
|
-
return this.disposers.add(
|
|
1758
|
+
const n = E(() => {
|
|
1759
|
+
const l = r.value.value, d = i ? i(l) : l;
|
|
1760
|
+
s.setValue(d, { emitEvent: !1 });
|
|
1761
|
+
}), o = `linkFields-${Date.now()}-${Math.random()}`;
|
|
1762
|
+
return this.disposers.add(o, n);
|
|
1738
1763
|
}
|
|
1739
1764
|
/**
|
|
1740
1765
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1768,11 +1793,11 @@ class b extends O {
|
|
|
1768
1793
|
if (!i)
|
|
1769
1794
|
return () => {
|
|
1770
1795
|
};
|
|
1771
|
-
const
|
|
1772
|
-
const
|
|
1773
|
-
t(
|
|
1774
|
-
}),
|
|
1775
|
-
return this.disposers.add(
|
|
1796
|
+
const r = E(() => {
|
|
1797
|
+
const n = i.value.value;
|
|
1798
|
+
t(n);
|
|
1799
|
+
}), s = `watchField-${Date.now()}-${Math.random()}`;
|
|
1800
|
+
return this.disposers.add(s, r);
|
|
1776
1801
|
}
|
|
1777
1802
|
/**
|
|
1778
1803
|
* Hook: вызывается после disable()
|
|
@@ -1795,7 +1820,7 @@ class b extends O {
|
|
|
1795
1820
|
});
|
|
1796
1821
|
}
|
|
1797
1822
|
}
|
|
1798
|
-
class
|
|
1823
|
+
class T extends F {
|
|
1799
1824
|
// ============================================================================
|
|
1800
1825
|
// Приватные поля
|
|
1801
1826
|
// ============================================================================
|
|
@@ -1833,8 +1858,8 @@ class C extends O {
|
|
|
1833
1858
|
this.push(i);
|
|
1834
1859
|
this.length = u(() => this.items.value.length), this.value = u(() => this.items.value.map((i) => i.value.value)), this.valid = u(() => this.items.value.every((i) => i.valid.value)), this.invalid = u(() => !this.valid.value), this.pending = u(() => this.items.value.some((i) => i.pending.value)), this.touched = u(() => this.items.value.some((i) => i.touched.value)), this.dirty = u(() => this.items.value.some((i) => i.dirty.value)), this.errors = u(() => {
|
|
1835
1860
|
const i = [];
|
|
1836
|
-
return this.items.value.forEach((
|
|
1837
|
-
i.push(...
|
|
1861
|
+
return this.items.value.forEach((r) => {
|
|
1862
|
+
i.push(...r.errors.value);
|
|
1838
1863
|
}), i;
|
|
1839
1864
|
}), this.status = u(() => this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid");
|
|
1840
1865
|
}
|
|
@@ -1864,8 +1889,8 @@ class C extends O {
|
|
|
1864
1889
|
insert(e, t) {
|
|
1865
1890
|
if (e < 0 || e > this.items.value.length)
|
|
1866
1891
|
return;
|
|
1867
|
-
const i = this.createItem(t),
|
|
1868
|
-
|
|
1892
|
+
const i = this.createItem(t), r = [...this.items.value];
|
|
1893
|
+
r.splice(e, 0, i), this.items.value = r;
|
|
1869
1894
|
}
|
|
1870
1895
|
/**
|
|
1871
1896
|
* Удалить все элементы массива
|
|
@@ -2019,7 +2044,7 @@ class C extends O {
|
|
|
2019
2044
|
*/
|
|
2020
2045
|
createItem(e) {
|
|
2021
2046
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2022
|
-
const t = new
|
|
2047
|
+
const t = new S(this.itemSchema);
|
|
2023
2048
|
return e && t.patchValue(e), this.validationSchemaFn && "applyValidationSchema" in t && t.applyValidationSchema(this.validationSchemaFn), this.behaviorSchemaFn && "applyBehaviorSchema" in t && t.applyBehaviorSchema(this.behaviorSchemaFn), t;
|
|
2024
2049
|
}
|
|
2025
2050
|
throw new Error(
|
|
@@ -2107,13 +2132,13 @@ class C extends O {
|
|
|
2107
2132
|
*/
|
|
2108
2133
|
watchItems(e, t) {
|
|
2109
2134
|
const i = E(() => {
|
|
2110
|
-
const
|
|
2111
|
-
if (
|
|
2112
|
-
return
|
|
2135
|
+
const s = this.items.value.map((n) => {
|
|
2136
|
+
if (n instanceof S)
|
|
2137
|
+
return n.getFieldByPath(e)?.value.value;
|
|
2113
2138
|
});
|
|
2114
|
-
t(
|
|
2115
|
-
}),
|
|
2116
|
-
return this.disposers.add(
|
|
2139
|
+
t(s);
|
|
2140
|
+
}), r = `watchItems-${Date.now()}-${Math.random()}`;
|
|
2141
|
+
return this.disposers.add(r, i);
|
|
2117
2142
|
}
|
|
2118
2143
|
/**
|
|
2119
2144
|
* Подписка на изменение длины массива
|
|
@@ -2139,8 +2164,8 @@ class C extends O {
|
|
|
2139
2164
|
*/
|
|
2140
2165
|
watchLength(e) {
|
|
2141
2166
|
const t = E(() => {
|
|
2142
|
-
const
|
|
2143
|
-
e(
|
|
2167
|
+
const r = this.length.value;
|
|
2168
|
+
e(r);
|
|
2144
2169
|
}), i = `watchLength-${Date.now()}-${Math.random()}`;
|
|
2145
2170
|
return this.disposers.add(i, t);
|
|
2146
2171
|
}
|
|
@@ -2258,13 +2283,13 @@ class X {
|
|
|
2258
2283
|
return new J(e);
|
|
2259
2284
|
if (this.isArrayConfig(e)) {
|
|
2260
2285
|
const t = e;
|
|
2261
|
-
return new
|
|
2286
|
+
return new T(
|
|
2262
2287
|
t.schema,
|
|
2263
2288
|
t.initialItems
|
|
2264
2289
|
);
|
|
2265
2290
|
}
|
|
2266
2291
|
if (this.isGroupConfig(e))
|
|
2267
|
-
return new
|
|
2292
|
+
return new S(e);
|
|
2268
2293
|
throw new Error(
|
|
2269
2294
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2270
2295
|
e
|
|
@@ -2298,11 +2323,11 @@ class X {
|
|
|
2298
2323
|
*/
|
|
2299
2324
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2300
2325
|
createArrayNodeFromArray(e) {
|
|
2301
|
-
const [t, ...i] = e,
|
|
2302
|
-
this.isGroupConfig(t) &&
|
|
2303
|
-
for (const
|
|
2304
|
-
this.isGroupConfig(
|
|
2305
|
-
return new
|
|
2326
|
+
const [t, ...i] = e, r = [];
|
|
2327
|
+
this.isGroupConfig(t) && r.push(this.extractValues(t));
|
|
2328
|
+
for (const s of i)
|
|
2329
|
+
this.isGroupConfig(s) ? r.push(this.extractValues(s)) : r.push(s);
|
|
2330
|
+
return new T(t, r);
|
|
2306
2331
|
}
|
|
2307
2332
|
/**
|
|
2308
2333
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2340,8 +2365,8 @@ class X {
|
|
|
2340
2365
|
return e.map((t) => this.extractValues(t));
|
|
2341
2366
|
if (this.isGroupConfig(e)) {
|
|
2342
2367
|
const t = {};
|
|
2343
|
-
for (const [i,
|
|
2344
|
-
t[i] = this.extractValues(
|
|
2368
|
+
for (const [i, r] of Object.entries(e))
|
|
2369
|
+
t[i] = this.extractValues(r);
|
|
2345
2370
|
return t;
|
|
2346
2371
|
}
|
|
2347
2372
|
return e;
|
|
@@ -2471,10 +2496,10 @@ class fe {
|
|
|
2471
2496
|
}
|
|
2472
2497
|
this.timer = setTimeout(async () => {
|
|
2473
2498
|
try {
|
|
2474
|
-
const
|
|
2475
|
-
t(
|
|
2476
|
-
} catch (
|
|
2477
|
-
i(
|
|
2499
|
+
const r = await e();
|
|
2500
|
+
t(r);
|
|
2501
|
+
} catch (r) {
|
|
2502
|
+
i(r);
|
|
2478
2503
|
}
|
|
2479
2504
|
}, this.delay);
|
|
2480
2505
|
});
|
|
@@ -2546,25 +2571,25 @@ class fe {
|
|
|
2546
2571
|
return this.timer !== void 0;
|
|
2547
2572
|
}
|
|
2548
2573
|
}
|
|
2549
|
-
function ve(
|
|
2550
|
-
return new
|
|
2574
|
+
function ve(a) {
|
|
2575
|
+
return new S(a);
|
|
2551
2576
|
}
|
|
2552
|
-
function Z(
|
|
2577
|
+
function Z(a) {
|
|
2553
2578
|
return {
|
|
2554
2579
|
type: "static",
|
|
2555
2580
|
load: async () => ({
|
|
2556
|
-
items:
|
|
2557
|
-
totalCount:
|
|
2581
|
+
items: a,
|
|
2582
|
+
totalCount: a.length
|
|
2558
2583
|
})
|
|
2559
2584
|
};
|
|
2560
2585
|
}
|
|
2561
|
-
function ee(
|
|
2586
|
+
function ee(a) {
|
|
2562
2587
|
let e = null;
|
|
2563
2588
|
return {
|
|
2564
2589
|
type: "preload",
|
|
2565
2590
|
load: async (t) => {
|
|
2566
2591
|
if (!e) {
|
|
2567
|
-
const i = await
|
|
2592
|
+
const i = await a(t);
|
|
2568
2593
|
e = {
|
|
2569
2594
|
items: i,
|
|
2570
2595
|
totalCount: i.length
|
|
@@ -2574,11 +2599,11 @@ function ee(r) {
|
|
|
2574
2599
|
}
|
|
2575
2600
|
};
|
|
2576
2601
|
}
|
|
2577
|
-
function te(
|
|
2602
|
+
function te(a) {
|
|
2578
2603
|
return {
|
|
2579
2604
|
type: "partial",
|
|
2580
2605
|
load: async (e) => {
|
|
2581
|
-
const t = await
|
|
2606
|
+
const t = await a(e);
|
|
2582
2607
|
return {
|
|
2583
2608
|
items: t,
|
|
2584
2609
|
totalCount: t.length
|
|
@@ -2592,31 +2617,31 @@ const pe = {
|
|
|
2592
2617
|
preload: ee,
|
|
2593
2618
|
partial: te
|
|
2594
2619
|
};
|
|
2595
|
-
var
|
|
2596
|
-
var
|
|
2620
|
+
var w = { exports: {} }, k = {};
|
|
2621
|
+
var M;
|
|
2597
2622
|
function ie() {
|
|
2598
|
-
if (
|
|
2599
|
-
|
|
2600
|
-
var
|
|
2623
|
+
if (M) return k;
|
|
2624
|
+
M = 1;
|
|
2625
|
+
var a = B;
|
|
2601
2626
|
function e(c, f) {
|
|
2602
2627
|
return c === f && (c !== 0 || 1 / c === 1 / f) || c !== c && f !== f;
|
|
2603
2628
|
}
|
|
2604
|
-
var t = typeof Object.is == "function" ? Object.is : e, i =
|
|
2605
|
-
function
|
|
2629
|
+
var t = typeof Object.is == "function" ? Object.is : e, i = a.useState, r = a.useEffect, s = a.useLayoutEffect, n = a.useDebugValue;
|
|
2630
|
+
function o(c, f) {
|
|
2606
2631
|
var h = f(), v = i({ inst: { value: h, getSnapshot: f } }), p = v[0].inst, g = v[1];
|
|
2607
|
-
return
|
|
2632
|
+
return s(
|
|
2608
2633
|
function() {
|
|
2609
2634
|
p.value = h, p.getSnapshot = f, l(p) && g({ inst: p });
|
|
2610
2635
|
},
|
|
2611
2636
|
[c, h, f]
|
|
2612
|
-
),
|
|
2637
|
+
), r(
|
|
2613
2638
|
function() {
|
|
2614
2639
|
return l(p) && g({ inst: p }), c(function() {
|
|
2615
2640
|
l(p) && g({ inst: p });
|
|
2616
2641
|
});
|
|
2617
2642
|
},
|
|
2618
2643
|
[c]
|
|
2619
|
-
),
|
|
2644
|
+
), n(h), h;
|
|
2620
2645
|
}
|
|
2621
2646
|
function l(c) {
|
|
2622
2647
|
var f = c.getSnapshot;
|
|
@@ -2631,40 +2656,40 @@ function ie() {
|
|
|
2631
2656
|
function d(c, f) {
|
|
2632
2657
|
return f();
|
|
2633
2658
|
}
|
|
2634
|
-
var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d :
|
|
2635
|
-
return k.useSyncExternalStore =
|
|
2659
|
+
var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : o;
|
|
2660
|
+
return k.useSyncExternalStore = a.useSyncExternalStore !== void 0 ? a.useSyncExternalStore : m, k;
|
|
2636
2661
|
}
|
|
2637
2662
|
var x = {};
|
|
2638
|
-
var
|
|
2639
|
-
function
|
|
2640
|
-
return
|
|
2641
|
-
function
|
|
2663
|
+
var I;
|
|
2664
|
+
function re() {
|
|
2665
|
+
return I || (I = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2666
|
+
function a(h, v) {
|
|
2642
2667
|
return h === v && (h !== 0 || 1 / h === 1 / v) || h !== h && v !== v;
|
|
2643
2668
|
}
|
|
2644
2669
|
function e(h, v) {
|
|
2645
|
-
m ||
|
|
2670
|
+
m || r.startTransition === void 0 || (m = !0, console.error(
|
|
2646
2671
|
"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."
|
|
2647
2672
|
));
|
|
2648
2673
|
var p = v();
|
|
2649
2674
|
if (!c) {
|
|
2650
2675
|
var g = v();
|
|
2651
|
-
|
|
2676
|
+
s(p, g) || (console.error(
|
|
2652
2677
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2653
2678
|
), c = !0);
|
|
2654
2679
|
}
|
|
2655
|
-
g =
|
|
2680
|
+
g = n({
|
|
2656
2681
|
inst: { value: p, getSnapshot: v }
|
|
2657
2682
|
});
|
|
2658
|
-
var _ = g[0].inst,
|
|
2683
|
+
var _ = g[0].inst, V = g[1];
|
|
2659
2684
|
return l(
|
|
2660
2685
|
function() {
|
|
2661
|
-
_.value = p, _.getSnapshot = v, t(_) &&
|
|
2686
|
+
_.value = p, _.getSnapshot = v, t(_) && V({ inst: _ });
|
|
2662
2687
|
},
|
|
2663
2688
|
[h, p, v]
|
|
2664
|
-
),
|
|
2689
|
+
), o(
|
|
2665
2690
|
function() {
|
|
2666
|
-
return t(_) &&
|
|
2667
|
-
t(_) &&
|
|
2691
|
+
return t(_) && V({ inst: _ }), h(function() {
|
|
2692
|
+
t(_) && V({ inst: _ });
|
|
2668
2693
|
});
|
|
2669
2694
|
},
|
|
2670
2695
|
[h]
|
|
@@ -2675,7 +2700,7 @@ function se() {
|
|
|
2675
2700
|
h = h.value;
|
|
2676
2701
|
try {
|
|
2677
2702
|
var p = v();
|
|
2678
|
-
return !
|
|
2703
|
+
return !s(h, p);
|
|
2679
2704
|
} catch {
|
|
2680
2705
|
return !0;
|
|
2681
2706
|
}
|
|
@@ -2684,51 +2709,51 @@ function se() {
|
|
|
2684
2709
|
return v();
|
|
2685
2710
|
}
|
|
2686
2711
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2687
|
-
var
|
|
2688
|
-
x.useSyncExternalStore =
|
|
2712
|
+
var r = B, s = typeof Object.is == "function" ? Object.is : a, n = r.useState, o = r.useEffect, l = r.useLayoutEffect, d = r.useDebugValue, m = !1, c = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? i : e;
|
|
2713
|
+
x.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
2689
2714
|
})()), x;
|
|
2690
2715
|
}
|
|
2691
|
-
var
|
|
2692
|
-
function
|
|
2693
|
-
return
|
|
2716
|
+
var N;
|
|
2717
|
+
function se() {
|
|
2718
|
+
return N || (N = 1, process.env.NODE_ENV === "production" ? w.exports = ie() : w.exports = re()), w.exports;
|
|
2694
2719
|
}
|
|
2695
|
-
var $ =
|
|
2696
|
-
function ae(
|
|
2697
|
-
if (
|
|
2698
|
-
if (
|
|
2699
|
-
for (let t = 0; t <
|
|
2700
|
-
if (
|
|
2720
|
+
var $ = se();
|
|
2721
|
+
function ae(a, e) {
|
|
2722
|
+
if (a === e) return !0;
|
|
2723
|
+
if (a.length !== e.length) return !1;
|
|
2724
|
+
for (let t = 0; t < a.length; t++)
|
|
2725
|
+
if (a[t] !== e[t]) return !1;
|
|
2701
2726
|
return !0;
|
|
2702
2727
|
}
|
|
2703
|
-
function G(
|
|
2728
|
+
function G(a, e, t) {
|
|
2704
2729
|
const i = L(null);
|
|
2705
2730
|
if (i.current === null) {
|
|
2706
|
-
const
|
|
2707
|
-
for (const
|
|
2708
|
-
o
|
|
2709
|
-
i.current = { ...
|
|
2710
|
-
}
|
|
2711
|
-
const
|
|
2712
|
-
(
|
|
2713
|
-
let
|
|
2731
|
+
const n = {};
|
|
2732
|
+
for (const o in a)
|
|
2733
|
+
n[o] = a[o].value;
|
|
2734
|
+
i.current = { ...n, __snapshot: null };
|
|
2735
|
+
}
|
|
2736
|
+
const r = b(
|
|
2737
|
+
(n) => {
|
|
2738
|
+
let o = !0;
|
|
2714
2739
|
return E(() => {
|
|
2715
|
-
for (const d in
|
|
2716
|
-
|
|
2717
|
-
if (
|
|
2718
|
-
|
|
2740
|
+
for (const d in a)
|
|
2741
|
+
a[d].value;
|
|
2742
|
+
if (o) {
|
|
2743
|
+
o = !1;
|
|
2719
2744
|
return;
|
|
2720
2745
|
}
|
|
2721
|
-
|
|
2746
|
+
n();
|
|
2722
2747
|
});
|
|
2723
2748
|
},
|
|
2724
|
-
[
|
|
2725
|
-
),
|
|
2726
|
-
const
|
|
2727
|
-
for (const d in
|
|
2728
|
-
|
|
2749
|
+
[a]
|
|
2750
|
+
), s = b(() => {
|
|
2751
|
+
const n = i.current, o = {};
|
|
2752
|
+
for (const d in a)
|
|
2753
|
+
o[d] = a[d].value;
|
|
2729
2754
|
let l = !1;
|
|
2730
2755
|
for (const d of e) {
|
|
2731
|
-
const { key: m, useShallowArrayEqual: c } = d, f =
|
|
2756
|
+
const { key: m, useShallowArrayEqual: c } = d, f = o[m], h = n[m];
|
|
2732
2757
|
if (c) {
|
|
2733
2758
|
if (!ae(h, f)) {
|
|
2734
2759
|
l = !0;
|
|
@@ -2739,25 +2764,25 @@ function G(r, e, t) {
|
|
|
2739
2764
|
break;
|
|
2740
2765
|
}
|
|
2741
2766
|
}
|
|
2742
|
-
if (!l &&
|
|
2743
|
-
return
|
|
2744
|
-
for (const d in
|
|
2745
|
-
|
|
2746
|
-
return
|
|
2747
|
-
}, [
|
|
2748
|
-
return $.useSyncExternalStore(
|
|
2767
|
+
if (!l && n.__snapshot)
|
|
2768
|
+
return n.__snapshot;
|
|
2769
|
+
for (const d in a)
|
|
2770
|
+
n[d] = o[d];
|
|
2771
|
+
return n.__snapshot = t(o), n.__snapshot;
|
|
2772
|
+
}, [a, t]);
|
|
2773
|
+
return $.useSyncExternalStore(r, s, s);
|
|
2749
2774
|
}
|
|
2750
|
-
function ne(
|
|
2775
|
+
function ne(a) {
|
|
2751
2776
|
const e = {
|
|
2752
|
-
value:
|
|
2753
|
-
disabled:
|
|
2754
|
-
errors:
|
|
2755
|
-
pending:
|
|
2756
|
-
valid:
|
|
2757
|
-
invalid:
|
|
2758
|
-
touched:
|
|
2759
|
-
shouldShowError:
|
|
2760
|
-
componentProps:
|
|
2777
|
+
value: a.value,
|
|
2778
|
+
disabled: a.disabled,
|
|
2779
|
+
errors: a.errors,
|
|
2780
|
+
pending: a.pending,
|
|
2781
|
+
valid: a.valid,
|
|
2782
|
+
invalid: a.invalid,
|
|
2783
|
+
touched: a.touched,
|
|
2784
|
+
shouldShowError: a.shouldShowError,
|
|
2785
|
+
componentProps: a.componentProps
|
|
2761
2786
|
}, t = [
|
|
2762
2787
|
{ key: "value" },
|
|
2763
2788
|
{ key: "disabled" },
|
|
@@ -2768,32 +2793,32 @@ function ne(r) {
|
|
|
2768
2793
|
{ key: "touched" },
|
|
2769
2794
|
{ key: "shouldShowError" },
|
|
2770
2795
|
{ key: "componentProps" }
|
|
2771
|
-
], i =
|
|
2772
|
-
(
|
|
2773
|
-
value:
|
|
2774
|
-
pending:
|
|
2775
|
-
disabled:
|
|
2776
|
-
errors:
|
|
2777
|
-
valid:
|
|
2778
|
-
invalid:
|
|
2779
|
-
touched:
|
|
2780
|
-
shouldShowError:
|
|
2781
|
-
componentProps:
|
|
2796
|
+
], i = b(
|
|
2797
|
+
(r) => ({
|
|
2798
|
+
value: r.value,
|
|
2799
|
+
pending: r.pending,
|
|
2800
|
+
disabled: r.disabled,
|
|
2801
|
+
errors: r.errors,
|
|
2802
|
+
valid: r.valid,
|
|
2803
|
+
invalid: r.invalid,
|
|
2804
|
+
touched: r.touched,
|
|
2805
|
+
shouldShowError: r.shouldShowError,
|
|
2806
|
+
componentProps: r.componentProps
|
|
2782
2807
|
}),
|
|
2783
2808
|
[]
|
|
2784
2809
|
);
|
|
2785
2810
|
return G(e, t, i);
|
|
2786
2811
|
}
|
|
2787
|
-
function oe(
|
|
2812
|
+
function oe(a) {
|
|
2788
2813
|
const e = {
|
|
2789
|
-
value:
|
|
2790
|
-
length:
|
|
2791
|
-
errors:
|
|
2792
|
-
pending:
|
|
2793
|
-
valid:
|
|
2794
|
-
invalid:
|
|
2795
|
-
touched:
|
|
2796
|
-
dirty:
|
|
2814
|
+
value: a.value,
|
|
2815
|
+
length: a.length,
|
|
2816
|
+
errors: a.errors,
|
|
2817
|
+
pending: a.pending,
|
|
2818
|
+
valid: a.valid,
|
|
2819
|
+
invalid: a.invalid,
|
|
2820
|
+
touched: a.touched,
|
|
2821
|
+
dirty: a.dirty
|
|
2797
2822
|
}, t = [
|
|
2798
2823
|
{ key: "value" },
|
|
2799
2824
|
{ key: "length" },
|
|
@@ -2803,24 +2828,24 @@ function oe(r) {
|
|
|
2803
2828
|
{ key: "invalid" },
|
|
2804
2829
|
{ key: "touched" },
|
|
2805
2830
|
{ key: "dirty" }
|
|
2806
|
-
], i =
|
|
2807
|
-
(
|
|
2808
|
-
value:
|
|
2809
|
-
length:
|
|
2810
|
-
pending:
|
|
2811
|
-
errors:
|
|
2812
|
-
valid:
|
|
2813
|
-
invalid:
|
|
2814
|
-
touched:
|
|
2815
|
-
dirty:
|
|
2831
|
+
], i = b(
|
|
2832
|
+
(r) => ({
|
|
2833
|
+
value: r.value,
|
|
2834
|
+
length: r.length,
|
|
2835
|
+
pending: r.pending,
|
|
2836
|
+
errors: r.errors,
|
|
2837
|
+
valid: r.valid,
|
|
2838
|
+
invalid: r.invalid,
|
|
2839
|
+
touched: r.touched,
|
|
2840
|
+
dirty: r.dirty
|
|
2816
2841
|
}),
|
|
2817
2842
|
[]
|
|
2818
2843
|
);
|
|
2819
2844
|
return G(e, t, i);
|
|
2820
2845
|
}
|
|
2821
|
-
function ye(
|
|
2822
|
-
const e =
|
|
2823
|
-
return
|
|
2846
|
+
function ye(a) {
|
|
2847
|
+
const e = a && "length" in a && "map" in a;
|
|
2848
|
+
return a ? e ? oe(a) : ne(a) : {
|
|
2824
2849
|
value: [],
|
|
2825
2850
|
length: 0,
|
|
2826
2851
|
pending: !1,
|
|
@@ -2831,56 +2856,56 @@ function ye(r) {
|
|
|
2831
2856
|
dirty: !1
|
|
2832
2857
|
};
|
|
2833
2858
|
}
|
|
2834
|
-
function me(
|
|
2835
|
-
const e = L({ value:
|
|
2836
|
-
(
|
|
2837
|
-
let
|
|
2859
|
+
function me(a) {
|
|
2860
|
+
const e = L({ value: a.value.value }), t = b(
|
|
2861
|
+
(r) => {
|
|
2862
|
+
let s = !0;
|
|
2838
2863
|
return E(() => {
|
|
2839
|
-
if (
|
|
2840
|
-
|
|
2864
|
+
if (a.value.value, s) {
|
|
2865
|
+
s = !1;
|
|
2841
2866
|
return;
|
|
2842
2867
|
}
|
|
2843
|
-
|
|
2868
|
+
r();
|
|
2844
2869
|
});
|
|
2845
2870
|
},
|
|
2846
|
-
[
|
|
2847
|
-
), i =
|
|
2848
|
-
const
|
|
2849
|
-
return e.current.value ===
|
|
2850
|
-
}, [
|
|
2871
|
+
[a]
|
|
2872
|
+
), i = b(() => {
|
|
2873
|
+
const r = a.value.value;
|
|
2874
|
+
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
2875
|
+
}, [a]);
|
|
2851
2876
|
return $.useSyncExternalStore(t, i, i);
|
|
2852
2877
|
}
|
|
2853
2878
|
export {
|
|
2854
|
-
|
|
2879
|
+
T as ArrayNode,
|
|
2855
2880
|
fe as Debouncer,
|
|
2856
|
-
|
|
2881
|
+
A as ErrorStrategy,
|
|
2857
2882
|
J as FieldNode,
|
|
2858
2883
|
Q as FieldPathNavigator,
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2884
|
+
O as FormErrorHandler,
|
|
2885
|
+
F as FormNode,
|
|
2886
|
+
S as GroupNode,
|
|
2862
2887
|
X as NodeFactory,
|
|
2863
|
-
|
|
2888
|
+
Oe as RegistryStack,
|
|
2864
2889
|
pe as Resources,
|
|
2865
2890
|
P as SubscriptionManager,
|
|
2866
2891
|
Ee as behaviors,
|
|
2867
|
-
|
|
2892
|
+
R as createFieldPath,
|
|
2868
2893
|
ve as createForm,
|
|
2869
|
-
|
|
2894
|
+
Fe as extractKey,
|
|
2870
2895
|
Pe as extractPath,
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2896
|
+
Ce as getCurrentBehaviorRegistry,
|
|
2897
|
+
De as getCurrentValidationRegistry,
|
|
2898
|
+
Se as getNodeType,
|
|
2899
|
+
D as isArrayNode,
|
|
2900
|
+
C as isFieldNode,
|
|
2901
|
+
we as isFormNode,
|
|
2902
|
+
Ae as isGroupNode,
|
|
2878
2903
|
te as partialResource,
|
|
2879
2904
|
ee as preloadResource,
|
|
2880
2905
|
Z as staticResource,
|
|
2881
|
-
|
|
2906
|
+
Re as toFieldPath,
|
|
2882
2907
|
ye as useFormControl,
|
|
2883
2908
|
me as useFormControlValue,
|
|
2884
|
-
|
|
2909
|
+
Ve as validateForm,
|
|
2885
2910
|
ke as validators
|
|
2886
2911
|
};
|