@reformer/core 2.0.0-beta.5 → 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-DzYL8kY_.js → behaviors-DyPzh2-X.js} +13 -4
- package/dist/behaviors.js +2 -2
- package/dist/core/nodes/array-node.d.ts +28 -4
- package/dist/core/nodes/field-node.d.ts +12 -6
- package/dist/core/types/form-proxy.d.ts +2 -2
- package/dist/core/types/index.d.ts +35 -1
- 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 +546 -478
- 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,12 +1,12 @@
|
|
|
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 Fe, a as
|
|
7
|
-
import { v4 as
|
|
8
|
-
import
|
|
9
|
-
class
|
|
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
|
+
class F {
|
|
10
10
|
// ============================================================================
|
|
11
11
|
// Protected состояние (для Template Method паттерна)
|
|
12
12
|
// ============================================================================
|
|
@@ -100,17 +100,17 @@ class O {
|
|
|
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 O {
|
|
|
283
283
|
onEnable() {
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
class
|
|
286
|
+
class C {
|
|
287
287
|
/**
|
|
288
288
|
* Хранилище подписок
|
|
289
289
|
* Ключ: уникальный идентификатор подписки
|
|
@@ -451,8 +451,12 @@ class P {
|
|
|
451
451
|
this.clear();
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
|
|
455
|
-
|
|
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 || {});
|
|
459
|
+
class O {
|
|
456
460
|
/**
|
|
457
461
|
* Обработать ошибку согласно заданной стратегии
|
|
458
462
|
*
|
|
@@ -492,9 +496,9 @@ class F {
|
|
|
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 F {
|
|
|
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 F {
|
|
|
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 F {
|
|
|
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
|
// ============================================================================
|
|
@@ -618,6 +622,7 @@ class J extends O {
|
|
|
618
622
|
updateOn;
|
|
619
623
|
initialValue;
|
|
620
624
|
currentValidationId = 0;
|
|
625
|
+
currentAbortController;
|
|
621
626
|
debounceMs;
|
|
622
627
|
validateDebounceTimer;
|
|
623
628
|
validateDebounceResolve;
|
|
@@ -625,7 +630,7 @@ class J extends O {
|
|
|
625
630
|
* Менеджер подписок для централизованного cleanup
|
|
626
631
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
627
632
|
*/
|
|
628
|
-
disposers = new
|
|
633
|
+
disposers = new C();
|
|
629
634
|
component;
|
|
630
635
|
// ============================================================================
|
|
631
636
|
// Конструктор
|
|
@@ -644,12 +649,12 @@ class J extends O {
|
|
|
644
649
|
setValue(e, t) {
|
|
645
650
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
646
651
|
return;
|
|
647
|
-
const
|
|
652
|
+
const r = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
648
653
|
if (this.updateOn === "change") {
|
|
649
654
|
this.validate();
|
|
650
655
|
return;
|
|
651
656
|
}
|
|
652
|
-
|
|
657
|
+
i && r && this.validate();
|
|
653
658
|
}
|
|
654
659
|
patchValue(e) {
|
|
655
660
|
this.setValue(e);
|
|
@@ -728,15 +733,15 @@ class J extends O {
|
|
|
728
733
|
*/
|
|
729
734
|
async validate(e) {
|
|
730
735
|
const t = e?.debounce ?? this.debounceMs;
|
|
731
|
-
return t > 0 && this.asyncValidators.length > 0 ? new Promise((
|
|
732
|
-
const
|
|
733
|
-
this.validateDebounceResolve && this.validateDebounceResolve(!1), this.validateDebounceTimer && clearTimeout(this.validateDebounceTimer), this.validateDebounceResolve =
|
|
734
|
-
if (this.validateDebounceResolve = void 0,
|
|
735
|
-
|
|
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);
|
|
736
741
|
return;
|
|
737
742
|
}
|
|
738
743
|
const a = await this.validateImmediate();
|
|
739
|
-
|
|
744
|
+
r(a);
|
|
740
745
|
}, t);
|
|
741
746
|
}) : this.validateImmediate();
|
|
742
747
|
}
|
|
@@ -744,47 +749,64 @@ class J extends O {
|
|
|
744
749
|
* Немедленная валидация без debounce
|
|
745
750
|
* @private
|
|
746
751
|
* @remarks
|
|
747
|
-
* Защищена от race conditions:
|
|
748
|
-
* -
|
|
749
|
-
* -
|
|
750
|
-
* -
|
|
751
|
-
* - Проверка перед обработкой async результатов
|
|
752
|
-
* - Проверка перед очисткой errors
|
|
752
|
+
* Защищена от race conditions через AbortController:
|
|
753
|
+
* - Отменяет предыдущую валидацию при запуске новой
|
|
754
|
+
* - Передаёт AbortSignal в async валидаторы для отмены операций (например, fetch)
|
|
755
|
+
* - Проверяет signal.aborted в ключевых точках
|
|
753
756
|
*/
|
|
754
757
|
async validateImmediate() {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
758
|
+
this.currentAbortController?.abort();
|
|
759
|
+
const e = new AbortController();
|
|
760
|
+
this.currentAbortController = e;
|
|
761
|
+
const { signal: t } = e;
|
|
762
|
+
++this.currentValidationId;
|
|
763
|
+
const r = [];
|
|
764
|
+
for (const a of this.validators) {
|
|
765
|
+
const n = a(this._value.value);
|
|
766
|
+
n && r.push(n);
|
|
759
767
|
}
|
|
760
|
-
if (
|
|
768
|
+
if (t.aborted)
|
|
761
769
|
return !1;
|
|
762
|
-
if (
|
|
763
|
-
return this._errors.value =
|
|
770
|
+
if (r.length > 0)
|
|
771
|
+
return this._errors.value = r, this._status.value = "invalid", !1;
|
|
764
772
|
if (this.asyncValidators.length > 0) {
|
|
765
|
-
if (
|
|
773
|
+
if (t.aborted)
|
|
766
774
|
return !1;
|
|
767
775
|
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
|
-
|
|
776
|
+
try {
|
|
777
|
+
const a = await Promise.all(
|
|
778
|
+
this.asyncValidators.map(async (o) => {
|
|
779
|
+
if (t.aborted)
|
|
780
|
+
throw new DOMException("Validation aborted", "AbortError");
|
|
781
|
+
try {
|
|
782
|
+
const l = await o(this._value.value, { signal: t });
|
|
783
|
+
if (t.aborted)
|
|
784
|
+
throw new DOMException("Validation aborted", "AbortError");
|
|
785
|
+
return l;
|
|
786
|
+
} catch (l) {
|
|
787
|
+
if (l instanceof DOMException && l.name === "AbortError")
|
|
788
|
+
throw l;
|
|
789
|
+
return O.handle(
|
|
790
|
+
l,
|
|
791
|
+
"FieldNode AsyncValidator",
|
|
792
|
+
V.CONVERT
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
})
|
|
796
|
+
);
|
|
797
|
+
if (t.aborted)
|
|
798
|
+
return !1;
|
|
799
|
+
this._pending.value = !1;
|
|
800
|
+
const n = a.filter(Boolean);
|
|
801
|
+
if (n.length > 0)
|
|
802
|
+
return this._errors.value = n, this._status.value = "invalid", !1;
|
|
803
|
+
} catch (a) {
|
|
804
|
+
if (a instanceof DOMException && a.name === "AbortError")
|
|
805
|
+
return !1;
|
|
806
|
+
throw a;
|
|
807
|
+
}
|
|
786
808
|
}
|
|
787
|
-
return
|
|
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);
|
|
788
810
|
}
|
|
789
811
|
setErrors(e) {
|
|
790
812
|
this._errors.value = e, this._status.value = e.length > 0 ? "invalid" : "valid";
|
|
@@ -897,10 +919,10 @@ class J extends O {
|
|
|
897
919
|
*/
|
|
898
920
|
watch(e) {
|
|
899
921
|
const t = E(() => {
|
|
900
|
-
const
|
|
901
|
-
e(
|
|
902
|
-
}),
|
|
903
|
-
return this.disposers.add(
|
|
922
|
+
const i = this.value.value;
|
|
923
|
+
e(i);
|
|
924
|
+
}), r = S("watch");
|
|
925
|
+
return this.disposers.add(r, t);
|
|
904
926
|
}
|
|
905
927
|
/**
|
|
906
928
|
* Вычисляемое значение из других полей
|
|
@@ -925,16 +947,23 @@ class J extends O {
|
|
|
925
947
|
* ```
|
|
926
948
|
*/
|
|
927
949
|
computeFrom(e, t) {
|
|
928
|
-
const
|
|
929
|
-
const a = e.map((
|
|
930
|
-
this.setValue(
|
|
931
|
-
}),
|
|
932
|
-
return this.disposers.add(
|
|
950
|
+
const r = E(() => {
|
|
951
|
+
const a = e.map((o) => o.value), n = t(...a);
|
|
952
|
+
this.setValue(n, { emitEvent: !1 });
|
|
953
|
+
}), i = S("computeFrom");
|
|
954
|
+
return this.disposers.add(i, r);
|
|
933
955
|
}
|
|
934
956
|
/**
|
|
935
957
|
* Очистить все ресурсы и таймеры
|
|
936
958
|
* Должен вызываться при unmount компонента
|
|
937
959
|
*
|
|
960
|
+
* @remarks
|
|
961
|
+
* Освобождает все ресурсы:
|
|
962
|
+
* - Отписывает все subscriptions через SubscriptionManager
|
|
963
|
+
* - Очищает debounce таймер
|
|
964
|
+
* - Resolve'ит висячий debounce промис (предотвращает утечку памяти)
|
|
965
|
+
* - Отменяет текущую async валидацию через AbortController
|
|
966
|
+
*
|
|
938
967
|
* @example
|
|
939
968
|
* ```typescript
|
|
940
969
|
* useEffect(() => {
|
|
@@ -945,10 +974,10 @@ class J extends O {
|
|
|
945
974
|
* ```
|
|
946
975
|
*/
|
|
947
976
|
dispose() {
|
|
948
|
-
this.disposers.dispose(), this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0);
|
|
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);
|
|
949
978
|
}
|
|
950
979
|
}
|
|
951
|
-
class
|
|
980
|
+
class X {
|
|
952
981
|
form;
|
|
953
982
|
constructor(e) {
|
|
954
983
|
this.form = e;
|
|
@@ -964,8 +993,8 @@ class Y {
|
|
|
964
993
|
* @param validators Зарегистрированные валидаторы
|
|
965
994
|
*/
|
|
966
995
|
async apply(e) {
|
|
967
|
-
const { validatorsByField: t, treeValidators:
|
|
968
|
-
await this.applyFieldValidators(t), this.applyTreeValidators(
|
|
996
|
+
const { validatorsByField: t, treeValidators: r } = this.groupValidators(e);
|
|
997
|
+
await this.applyFieldValidators(t), this.applyTreeValidators(r);
|
|
969
998
|
}
|
|
970
999
|
/**
|
|
971
1000
|
* Группировка валидаторов по типам
|
|
@@ -978,15 +1007,15 @@ class Y {
|
|
|
978
1007
|
* @returns Сгруппированные валидаторы
|
|
979
1008
|
*/
|
|
980
1009
|
groupValidators(e) {
|
|
981
|
-
const t = /* @__PURE__ */ new Map(),
|
|
982
|
-
for (const
|
|
983
|
-
if (
|
|
984
|
-
|
|
1010
|
+
const t = /* @__PURE__ */ new Map(), r = [];
|
|
1011
|
+
for (const i of e)
|
|
1012
|
+
if (i.type === "tree")
|
|
1013
|
+
r.push(i);
|
|
985
1014
|
else {
|
|
986
|
-
const a = t.get(
|
|
987
|
-
a.push(
|
|
1015
|
+
const a = t.get(i.fieldPath) || [];
|
|
1016
|
+
a.push(i), t.set(i.fieldPath, a);
|
|
988
1017
|
}
|
|
989
|
-
return { validatorsByField: t, treeValidators:
|
|
1018
|
+
return { validatorsByField: t, treeValidators: r };
|
|
990
1019
|
}
|
|
991
1020
|
/**
|
|
992
1021
|
* Применение field валидаторов к полям
|
|
@@ -1000,37 +1029,44 @@ class Y {
|
|
|
1000
1029
|
* @param validatorsByField Валидаторы, сгруппированные по полям
|
|
1001
1030
|
*/
|
|
1002
1031
|
async applyFieldValidators(e) {
|
|
1003
|
-
for (const [t,
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1032
|
+
for (const [t, r] of e) {
|
|
1033
|
+
const i = this.form.getFieldByPath(t);
|
|
1034
|
+
if (!i) {
|
|
1006
1035
|
console.warn(`Field ${t} not found in GroupNode`);
|
|
1007
1036
|
continue;
|
|
1008
1037
|
}
|
|
1009
|
-
if (!
|
|
1038
|
+
if (!R(i) && !T(i)) {
|
|
1010
1039
|
process.env.NODE_ENV !== "production" && console.warn(`Validation can only run on FieldNode or ArrayNode, skipping ${t}`);
|
|
1011
1040
|
continue;
|
|
1012
1041
|
}
|
|
1013
1042
|
const a = [];
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1043
|
+
let n;
|
|
1044
|
+
if (T(i)) {
|
|
1045
|
+
const o = i.getValue();
|
|
1046
|
+
n = new q(this.form, t, o);
|
|
1018
1047
|
} else
|
|
1019
|
-
|
|
1020
|
-
for (const
|
|
1021
|
-
if (!(
|
|
1048
|
+
n = new K(this.form, t, i);
|
|
1049
|
+
for (const o of r)
|
|
1050
|
+
if (!(o.condition && !this.checkCondition(o.condition)))
|
|
1022
1051
|
try {
|
|
1023
1052
|
let l = null;
|
|
1024
|
-
const
|
|
1025
|
-
|
|
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);
|
|
1026
1062
|
} catch (l) {
|
|
1027
|
-
|
|
1063
|
+
O.handle(
|
|
1028
1064
|
l,
|
|
1029
1065
|
`ValidationApplicator: validator for ${t}`,
|
|
1030
|
-
|
|
1066
|
+
V.LOG
|
|
1031
1067
|
);
|
|
1032
1068
|
}
|
|
1033
|
-
a.length > 0 ?
|
|
1069
|
+
a.length > 0 ? i.setErrors(a) : i.clearErrors();
|
|
1034
1070
|
}
|
|
1035
1071
|
}
|
|
1036
1072
|
/**
|
|
@@ -1043,24 +1079,24 @@ class Y {
|
|
|
1043
1079
|
*/
|
|
1044
1080
|
applyTreeValidators(e) {
|
|
1045
1081
|
for (const t of e) {
|
|
1046
|
-
const
|
|
1082
|
+
const r = new H(this.form);
|
|
1047
1083
|
if (!(t.condition && !this.checkCondition(t.condition)))
|
|
1048
1084
|
try {
|
|
1049
1085
|
if (t.type !== "tree")
|
|
1050
1086
|
continue;
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1055
|
-
const o = this.form.getFieldByPath(String(
|
|
1056
|
-
if (o &&
|
|
1057
|
-
const
|
|
1058
|
-
o.setErrors([...
|
|
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]);
|
|
1059
1095
|
}
|
|
1060
1096
|
}
|
|
1061
1097
|
}
|
|
1062
|
-
} catch (
|
|
1063
|
-
|
|
1098
|
+
} catch (i) {
|
|
1099
|
+
O.handle(i, "ValidationApplicator: tree validator", V.LOG);
|
|
1064
1100
|
}
|
|
1065
1101
|
}
|
|
1066
1102
|
}
|
|
@@ -1077,11 +1113,11 @@ class Y {
|
|
|
1077
1113
|
const t = this.form.getFieldByPath(e.fieldPath);
|
|
1078
1114
|
if (!t)
|
|
1079
1115
|
return !1;
|
|
1080
|
-
const
|
|
1081
|
-
return e.conditionFn(
|
|
1116
|
+
const r = t.value.value;
|
|
1117
|
+
return e.conditionFn(r);
|
|
1082
1118
|
}
|
|
1083
1119
|
}
|
|
1084
|
-
class
|
|
1120
|
+
class Z {
|
|
1085
1121
|
/**
|
|
1086
1122
|
* Парсит путь в массив сегментов
|
|
1087
1123
|
*
|
|
@@ -1108,22 +1144,22 @@ class Q {
|
|
|
1108
1144
|
*/
|
|
1109
1145
|
parsePath(e) {
|
|
1110
1146
|
const t = [];
|
|
1111
|
-
let
|
|
1147
|
+
let r = "", i = !1;
|
|
1112
1148
|
for (let a = 0; a < e.length; a++) {
|
|
1113
|
-
const
|
|
1114
|
-
|
|
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;
|
|
1115
1151
|
}
|
|
1116
|
-
return
|
|
1152
|
+
return r && this.addSegment(t, r), t;
|
|
1117
1153
|
}
|
|
1118
1154
|
/**
|
|
1119
1155
|
* Добавляет сегмент в массив, обрабатывая массивы
|
|
1120
1156
|
* @private
|
|
1121
1157
|
*/
|
|
1122
1158
|
addSegment(e, t) {
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
key:
|
|
1126
|
-
index: parseInt(
|
|
1159
|
+
const r = t.match(/^(.+)\[(\d+)\]$/);
|
|
1160
|
+
r ? e.push({
|
|
1161
|
+
key: r[1],
|
|
1162
|
+
index: parseInt(r[2], 10)
|
|
1127
1163
|
}) : e.push({ key: t });
|
|
1128
1164
|
}
|
|
1129
1165
|
/**
|
|
@@ -1158,16 +1194,16 @@ class Q {
|
|
|
1158
1194
|
* ```
|
|
1159
1195
|
*/
|
|
1160
1196
|
getValueByPath(e, t) {
|
|
1161
|
-
const
|
|
1162
|
-
let
|
|
1163
|
-
for (const a of
|
|
1164
|
-
if (
|
|
1165
|
-
if (
|
|
1166
|
-
if (!Array.isArray(
|
|
1167
|
-
|
|
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];
|
|
1168
1204
|
}
|
|
1169
1205
|
}
|
|
1170
|
-
return
|
|
1206
|
+
return i;
|
|
1171
1207
|
}
|
|
1172
1208
|
/**
|
|
1173
1209
|
* Устанавливает значение по пути в объекте (мутирует объект)
|
|
@@ -1196,31 +1232,31 @@ class Q {
|
|
|
1196
1232
|
* // obj3.items[0].title === 'New'
|
|
1197
1233
|
* ```
|
|
1198
1234
|
*/
|
|
1199
|
-
setValueByPath(e, t,
|
|
1200
|
-
const
|
|
1201
|
-
if (
|
|
1235
|
+
setValueByPath(e, t, r) {
|
|
1236
|
+
const i = this.parsePath(t);
|
|
1237
|
+
if (i.length === 0)
|
|
1202
1238
|
throw new Error("Cannot set value: empty path");
|
|
1203
1239
|
let a = e;
|
|
1204
|
-
for (let
|
|
1205
|
-
const l =
|
|
1206
|
-
let
|
|
1240
|
+
for (let o = 0; o < i.length - 1; o++) {
|
|
1241
|
+
const l = i[o];
|
|
1242
|
+
let h = a[l.key];
|
|
1207
1243
|
if (l.index !== void 0) {
|
|
1208
|
-
if (!Array.isArray(
|
|
1209
|
-
throw new Error(`Expected array at path segment: ${l.key}, but got ${typeof
|
|
1210
|
-
a =
|
|
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];
|
|
1211
1247
|
} else
|
|
1212
|
-
|
|
1248
|
+
h == null && (a[l.key] = {}, h = a[l.key]), a = h;
|
|
1213
1249
|
}
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1216
|
-
const
|
|
1217
|
-
if (!Array.isArray(
|
|
1250
|
+
const n = i[i.length - 1];
|
|
1251
|
+
if (n.index !== void 0) {
|
|
1252
|
+
const o = a[n.key];
|
|
1253
|
+
if (!Array.isArray(o))
|
|
1218
1254
|
throw new Error(
|
|
1219
|
-
`Expected array at path segment: ${
|
|
1255
|
+
`Expected array at path segment: ${n.key}, but got ${typeof o}`
|
|
1220
1256
|
);
|
|
1221
|
-
n
|
|
1257
|
+
o[n.index] = r;
|
|
1222
1258
|
} else
|
|
1223
|
-
a[
|
|
1259
|
+
a[n.key] = r;
|
|
1224
1260
|
}
|
|
1225
1261
|
/**
|
|
1226
1262
|
* Получить значение из FormNode по пути
|
|
@@ -1257,9 +1293,9 @@ class Q {
|
|
|
1257
1293
|
* ```
|
|
1258
1294
|
*/
|
|
1259
1295
|
getFormNodeValue(e, t) {
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1262
|
-
return this.isFormNode(
|
|
1296
|
+
const r = this.getNodeByPath(e, t);
|
|
1297
|
+
if (r != null)
|
|
1298
|
+
return this.isFormNode(r) ? r.value.value : r;
|
|
1263
1299
|
}
|
|
1264
1300
|
/**
|
|
1265
1301
|
* Type guard для проверки, является ли объект FormNode
|
|
@@ -1317,40 +1353,40 @@ class Q {
|
|
|
1317
1353
|
* ```
|
|
1318
1354
|
*/
|
|
1319
1355
|
getNodeByPath(e, t) {
|
|
1320
|
-
const
|
|
1321
|
-
let
|
|
1322
|
-
for (const a of
|
|
1323
|
-
if (
|
|
1324
|
-
const
|
|
1325
|
-
if (
|
|
1326
|
-
if (
|
|
1327
|
-
if (
|
|
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;
|
|
1361
|
+
if (n.fields && n.fields instanceof Map) {
|
|
1362
|
+
if (i = n.fields.get(a.key), a.index === void 0) {
|
|
1363
|
+
if (i == null) return null;
|
|
1328
1364
|
continue;
|
|
1329
1365
|
}
|
|
1330
|
-
} else if (a.index !== void 0 &&
|
|
1331
|
-
const
|
|
1332
|
-
if (!Array.isArray(
|
|
1366
|
+
} else if (a.index !== void 0 && n.items) {
|
|
1367
|
+
const o = n.items.value || n.items;
|
|
1368
|
+
if (!Array.isArray(o) || (i = o[a.index], i == null)) return null;
|
|
1333
1369
|
continue;
|
|
1334
1370
|
} else if (a.index === void 0) {
|
|
1335
|
-
if (
|
|
1371
|
+
if (i = n[a.key], i == null) return null;
|
|
1336
1372
|
continue;
|
|
1337
1373
|
}
|
|
1338
|
-
if (
|
|
1339
|
-
const
|
|
1340
|
-
if (!Array.isArray(
|
|
1341
|
-
|
|
1342
|
-
} else if (
|
|
1374
|
+
if (i && a.index !== void 0 && i.items) {
|
|
1375
|
+
const o = i.items.value || i.items;
|
|
1376
|
+
if (!Array.isArray(o)) return null;
|
|
1377
|
+
i = o[a.index];
|
|
1378
|
+
} else if (i && a.index !== void 0 && !i.items)
|
|
1343
1379
|
return null;
|
|
1344
|
-
if (
|
|
1380
|
+
if (i == null) return null;
|
|
1345
1381
|
}
|
|
1346
|
-
return
|
|
1382
|
+
return i;
|
|
1347
1383
|
}
|
|
1348
1384
|
}
|
|
1349
|
-
class
|
|
1385
|
+
class w extends F {
|
|
1350
1386
|
// ============================================================================
|
|
1351
1387
|
// Приватные поля
|
|
1352
1388
|
// ============================================================================
|
|
1353
|
-
id =
|
|
1389
|
+
id = J();
|
|
1354
1390
|
/**
|
|
1355
1391
|
* Коллекция полей формы (упрощённый Map вместо FieldRegistry)
|
|
1356
1392
|
*/
|
|
@@ -1359,7 +1395,7 @@ class b extends O {
|
|
|
1359
1395
|
/**
|
|
1360
1396
|
* Менеджер подписок для централизованного cleanup
|
|
1361
1397
|
*/
|
|
1362
|
-
disposers = new
|
|
1398
|
+
disposers = new C();
|
|
1363
1399
|
/**
|
|
1364
1400
|
* Ссылка на Proxy-инстанс для использования в BehaviorContext
|
|
1365
1401
|
*/
|
|
@@ -1367,23 +1403,23 @@ class b extends O {
|
|
|
1367
1403
|
/**
|
|
1368
1404
|
* Навигатор для работы с путями к полям
|
|
1369
1405
|
*/
|
|
1370
|
-
pathNavigator = new
|
|
1406
|
+
pathNavigator = new Z();
|
|
1371
1407
|
/**
|
|
1372
1408
|
* Фабрика для создания узлов формы
|
|
1373
1409
|
*/
|
|
1374
|
-
nodeFactory = new
|
|
1410
|
+
nodeFactory = new ee();
|
|
1375
1411
|
/**
|
|
1376
1412
|
* Реестр валидаторов для этой формы
|
|
1377
1413
|
*/
|
|
1378
|
-
validationRegistry = new
|
|
1414
|
+
validationRegistry = new W();
|
|
1379
1415
|
/**
|
|
1380
1416
|
* Реестр behaviors для этой формы
|
|
1381
1417
|
*/
|
|
1382
|
-
behaviorRegistry = new
|
|
1418
|
+
behaviorRegistry = new z();
|
|
1383
1419
|
/**
|
|
1384
1420
|
* Аппликатор для применения валидаторов к форме
|
|
1385
1421
|
*/
|
|
1386
|
-
validationApplicator = new
|
|
1422
|
+
validationApplicator = new X(this);
|
|
1387
1423
|
// ============================================================================
|
|
1388
1424
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1389
1425
|
// ============================================================================
|
|
@@ -1407,15 +1443,15 @@ class b extends O {
|
|
|
1407
1443
|
submitting;
|
|
1408
1444
|
constructor(e) {
|
|
1409
1445
|
super();
|
|
1410
|
-
const t = "form" in e,
|
|
1411
|
-
for (const [n,
|
|
1412
|
-
const
|
|
1413
|
-
this._fields.set(n,
|
|
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);
|
|
1414
1450
|
}
|
|
1415
1451
|
this.value = u(() => {
|
|
1416
1452
|
const n = {};
|
|
1417
|
-
return this._fields.forEach((
|
|
1418
|
-
n[
|
|
1453
|
+
return this._fields.forEach((o, l) => {
|
|
1454
|
+
n[l] = o.value.value;
|
|
1419
1455
|
}), n;
|
|
1420
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(
|
|
1421
1457
|
() => Array.from(this._fields.values()).some((n) => n.pending.value)
|
|
@@ -1425,12 +1461,10 @@ class b extends O {
|
|
|
1425
1461
|
() => Array.from(this._fields.values()).some((n) => n.dirty.value)
|
|
1426
1462
|
), this.errors = u(() => {
|
|
1427
1463
|
const n = [...this._formErrors.value];
|
|
1428
|
-
return this._fields.forEach((
|
|
1429
|
-
n.push(...
|
|
1464
|
+
return this._fields.forEach((o) => {
|
|
1465
|
+
n.push(...o.errors.value);
|
|
1430
1466
|
}), n;
|
|
1431
|
-
}), this.status = u(() => this._disabled.value ? "disabled" : this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid"), this.submitting = u(() => this._submitting.value);
|
|
1432
|
-
const o = this.buildProxy();
|
|
1433
|
-
return this._proxyInstance = o, s && this.applyBehaviorSchema(s), a && this.applyValidationSchema(a), o;
|
|
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);
|
|
1434
1468
|
}
|
|
1435
1469
|
// ============================================================================
|
|
1436
1470
|
// Приватный метод для создания Proxy (inline из ProxyBuilder)
|
|
@@ -1441,19 +1475,21 @@ class b extends O {
|
|
|
1441
1475
|
buildProxy() {
|
|
1442
1476
|
const e = this;
|
|
1443
1477
|
return new Proxy(this, {
|
|
1444
|
-
get: (t,
|
|
1445
|
-
if (
|
|
1446
|
-
return t[
|
|
1447
|
-
if (typeof
|
|
1448
|
-
|
|
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
|
+
}
|
|
1449
1485
|
},
|
|
1450
|
-
set: (t,
|
|
1451
|
-
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,
|
|
1452
1488
|
ownKeys: (t) => {
|
|
1453
|
-
const
|
|
1454
|
-
return [.../* @__PURE__ */ new Set([...
|
|
1489
|
+
const r = Reflect.ownKeys(t), i = Array.from(e._fields.keys());
|
|
1490
|
+
return [.../* @__PURE__ */ new Set([...r, ...i])];
|
|
1455
1491
|
},
|
|
1456
|
-
getOwnPropertyDescriptor: (t,
|
|
1492
|
+
getOwnPropertyDescriptor: (t, r) => typeof r == "string" && e._fields.has(r) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(t, r)
|
|
1457
1493
|
});
|
|
1458
1494
|
}
|
|
1459
1495
|
// ============================================================================
|
|
@@ -1461,21 +1497,21 @@ class b extends O {
|
|
|
1461
1497
|
// ============================================================================
|
|
1462
1498
|
getValue() {
|
|
1463
1499
|
const e = {};
|
|
1464
|
-
return this._fields.forEach((t,
|
|
1465
|
-
e[
|
|
1500
|
+
return this._fields.forEach((t, r) => {
|
|
1501
|
+
e[r] = t.getValue();
|
|
1466
1502
|
}), e;
|
|
1467
1503
|
}
|
|
1468
1504
|
setValue(e, t) {
|
|
1469
|
-
for (const [
|
|
1470
|
-
const a = this._fields.get(
|
|
1471
|
-
a && a.setValue(
|
|
1505
|
+
for (const [r, i] of Object.entries(e)) {
|
|
1506
|
+
const a = this._fields.get(r);
|
|
1507
|
+
a && a.setValue(i, t);
|
|
1472
1508
|
}
|
|
1473
1509
|
}
|
|
1474
1510
|
patchValue(e) {
|
|
1475
|
-
|
|
1476
|
-
for (const [t,
|
|
1477
|
-
const
|
|
1478
|
-
|
|
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 });
|
|
1479
1515
|
}
|
|
1480
1516
|
});
|
|
1481
1517
|
}
|
|
@@ -1497,9 +1533,9 @@ class b extends O {
|
|
|
1497
1533
|
* ```
|
|
1498
1534
|
*/
|
|
1499
1535
|
reset(e) {
|
|
1500
|
-
this._fields.forEach((t,
|
|
1501
|
-
const
|
|
1502
|
-
t.reset(
|
|
1536
|
+
this._fields.forEach((t, r) => {
|
|
1537
|
+
const i = e?.[r];
|
|
1538
|
+
t.reset(i);
|
|
1503
1539
|
});
|
|
1504
1540
|
}
|
|
1505
1541
|
/**
|
|
@@ -1614,10 +1650,10 @@ class b extends O {
|
|
|
1614
1650
|
applyValidationSchema(e) {
|
|
1615
1651
|
this.validationRegistry.beginRegistration();
|
|
1616
1652
|
try {
|
|
1617
|
-
const t =
|
|
1653
|
+
const t = D();
|
|
1618
1654
|
e(t);
|
|
1619
|
-
const
|
|
1620
|
-
this.validationRegistry.endRegistration(
|
|
1655
|
+
const r = this.getProxy();
|
|
1656
|
+
this.validationRegistry.endRegistration(r);
|
|
1621
1657
|
} catch (t) {
|
|
1622
1658
|
throw console.error("Error applying validation schema:", t), t;
|
|
1623
1659
|
}
|
|
@@ -1629,7 +1665,7 @@ class b extends O {
|
|
|
1629
1665
|
applyBehaviorSchema(e) {
|
|
1630
1666
|
this.behaviorRegistry.beginRegistration();
|
|
1631
1667
|
try {
|
|
1632
|
-
const t =
|
|
1668
|
+
const t = D();
|
|
1633
1669
|
return e(t), this.behaviorRegistry.endRegistration(this.getProxy()).cleanup;
|
|
1634
1670
|
} catch (t) {
|
|
1635
1671
|
throw console.error("Error applying behavior schema:", t), t;
|
|
@@ -1670,18 +1706,18 @@ class b extends O {
|
|
|
1670
1706
|
const t = this.pathNavigator.parsePath(e);
|
|
1671
1707
|
if (t.length === 0)
|
|
1672
1708
|
return;
|
|
1673
|
-
let
|
|
1674
|
-
for (const
|
|
1675
|
-
if (!(
|
|
1676
|
-
if (
|
|
1677
|
-
if ("at" in
|
|
1678
|
-
const a =
|
|
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);
|
|
1679
1715
|
if (!a) return;
|
|
1680
|
-
|
|
1716
|
+
r = a;
|
|
1681
1717
|
} else
|
|
1682
1718
|
return;
|
|
1683
1719
|
}
|
|
1684
|
-
return
|
|
1720
|
+
return r;
|
|
1685
1721
|
}
|
|
1686
1722
|
/**
|
|
1687
1723
|
* Применить contextual валидаторы к полям
|
|
@@ -1725,16 +1761,16 @@ class b extends O {
|
|
|
1725
1761
|
/**
|
|
1726
1762
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1727
1763
|
*/
|
|
1728
|
-
linkFields(e, t,
|
|
1729
|
-
const
|
|
1730
|
-
if (!
|
|
1764
|
+
linkFields(e, t, r) {
|
|
1765
|
+
const i = this._fields.get(e), a = this._fields.get(t);
|
|
1766
|
+
if (!i || !a)
|
|
1731
1767
|
return () => {
|
|
1732
1768
|
};
|
|
1733
|
-
const
|
|
1734
|
-
const l =
|
|
1735
|
-
a.setValue(
|
|
1736
|
-
}),
|
|
1737
|
-
return this.disposers.add(
|
|
1769
|
+
const n = E(() => {
|
|
1770
|
+
const l = i.value.value, h = r ? r(l) : l;
|
|
1771
|
+
a.setValue(h, { emitEvent: !1 });
|
|
1772
|
+
}), o = S("linkFields");
|
|
1773
|
+
return this.disposers.add(o, n);
|
|
1738
1774
|
}
|
|
1739
1775
|
/**
|
|
1740
1776
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1764,15 +1800,15 @@ class b extends O {
|
|
|
1764
1800
|
* ```
|
|
1765
1801
|
*/
|
|
1766
1802
|
watchField(e, t) {
|
|
1767
|
-
const
|
|
1768
|
-
if (!
|
|
1803
|
+
const r = this.getFieldByPath(e);
|
|
1804
|
+
if (!r)
|
|
1769
1805
|
return () => {
|
|
1770
1806
|
};
|
|
1771
|
-
const
|
|
1772
|
-
const
|
|
1773
|
-
t(
|
|
1774
|
-
}), a =
|
|
1775
|
-
return this.disposers.add(a,
|
|
1807
|
+
const i = E(() => {
|
|
1808
|
+
const n = r.value.value;
|
|
1809
|
+
t(n);
|
|
1810
|
+
}), a = S("watchField");
|
|
1811
|
+
return this.disposers.add(a, i);
|
|
1776
1812
|
}
|
|
1777
1813
|
/**
|
|
1778
1814
|
* Hook: вызывается после disable()
|
|
@@ -1795,7 +1831,7 @@ class b extends O {
|
|
|
1795
1831
|
});
|
|
1796
1832
|
}
|
|
1797
1833
|
}
|
|
1798
|
-
class
|
|
1834
|
+
class N extends F {
|
|
1799
1835
|
// ============================================================================
|
|
1800
1836
|
// Приватные поля
|
|
1801
1837
|
// ============================================================================
|
|
@@ -1806,7 +1842,9 @@ class C extends O {
|
|
|
1806
1842
|
* Менеджер подписок для централизованного cleanup
|
|
1807
1843
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1808
1844
|
*/
|
|
1809
|
-
disposers = new
|
|
1845
|
+
disposers = new C();
|
|
1846
|
+
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1847
|
+
_arrayErrors = y([]);
|
|
1810
1848
|
// ============================================================================
|
|
1811
1849
|
// Приватные поля для сохранения схем
|
|
1812
1850
|
// ============================================================================
|
|
@@ -1829,13 +1867,13 @@ class C extends O {
|
|
|
1829
1867
|
// ============================================================================
|
|
1830
1868
|
constructor(e, t = []) {
|
|
1831
1869
|
super(), this.itemSchema = e, this.initialItems = t, this.items = y([]);
|
|
1832
|
-
for (const
|
|
1833
|
-
this.push(
|
|
1834
|
-
this.length = u(() => this.items.value.length), this.value = u(() => this.items.value.map((
|
|
1835
|
-
const
|
|
1836
|
-
return this.items.value.forEach((
|
|
1837
|
-
|
|
1838
|
-
}),
|
|
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;
|
|
1839
1877
|
}), this.status = u(() => this.pending.value ? "pending" : this.invalid.value ? "invalid" : "valid");
|
|
1840
1878
|
}
|
|
1841
1879
|
// ============================================================================
|
|
@@ -1854,7 +1892,7 @@ class C extends O {
|
|
|
1854
1892
|
* @param index - Индекс элемента для удаления
|
|
1855
1893
|
*/
|
|
1856
1894
|
removeAt(e) {
|
|
1857
|
-
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));
|
|
1858
1896
|
}
|
|
1859
1897
|
/**
|
|
1860
1898
|
* Вставить элемент в массив
|
|
@@ -1864,8 +1902,8 @@ class C extends O {
|
|
|
1864
1902
|
insert(e, t) {
|
|
1865
1903
|
if (e < 0 || e > this.items.value.length)
|
|
1866
1904
|
return;
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1905
|
+
const r = this.createItem(t), i = [...this.items.value];
|
|
1906
|
+
i.splice(e, 0, r), this.items.value = i;
|
|
1869
1907
|
}
|
|
1870
1908
|
/**
|
|
1871
1909
|
* Удалить все элементы массива
|
|
@@ -1876,10 +1914,12 @@ class C extends O {
|
|
|
1876
1914
|
/**
|
|
1877
1915
|
* Получить элемент по индексу
|
|
1878
1916
|
* @param index - Индекс элемента
|
|
1879
|
-
* @returns Типизированный GroupNode или undefined если индекс вне границ
|
|
1917
|
+
* @returns Типизированный GroupNode proxy или undefined если индекс вне границ
|
|
1880
1918
|
*/
|
|
1881
1919
|
at(e) {
|
|
1882
|
-
|
|
1920
|
+
const t = this.items.value[e];
|
|
1921
|
+
if (t)
|
|
1922
|
+
return t.getProxy();
|
|
1883
1923
|
}
|
|
1884
1924
|
// ============================================================================
|
|
1885
1925
|
// Реализация абстрактных методов
|
|
@@ -1888,12 +1928,12 @@ class C extends O {
|
|
|
1888
1928
|
return this.items.value.map((e) => e.getValue());
|
|
1889
1929
|
}
|
|
1890
1930
|
setValue(e, t) {
|
|
1891
|
-
this.clear(), e.forEach((
|
|
1931
|
+
this.clear(), e.forEach((r) => this.push(r)), t?.emitEvent !== !1 && this.validate().catch(() => {
|
|
1892
1932
|
});
|
|
1893
1933
|
}
|
|
1894
1934
|
patchValue(e) {
|
|
1895
|
-
e.forEach((t,
|
|
1896
|
-
this.items.value[
|
|
1935
|
+
e.forEach((t, r) => {
|
|
1936
|
+
this.items.value[r] && t !== void 0 && this.items.value[r].patchValue(t);
|
|
1897
1937
|
});
|
|
1898
1938
|
}
|
|
1899
1939
|
/**
|
|
@@ -1914,7 +1954,7 @@ class C extends O {
|
|
|
1914
1954
|
* ```
|
|
1915
1955
|
*/
|
|
1916
1956
|
reset(e) {
|
|
1917
|
-
this.clear(), e && e.forEach((t) => this.push(t));
|
|
1957
|
+
this._arrayErrors.value = [], this.clear(), e && e.forEach((t) => this.push(t));
|
|
1918
1958
|
}
|
|
1919
1959
|
/**
|
|
1920
1960
|
* Сбросить массив к исходным значениям (initialItems)
|
|
@@ -1945,15 +1985,38 @@ class C extends O {
|
|
|
1945
1985
|
* ```
|
|
1946
1986
|
*/
|
|
1947
1987
|
resetToInitial() {
|
|
1948
|
-
this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1988
|
+
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1949
1989
|
}
|
|
1950
1990
|
async validate() {
|
|
1951
1991
|
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean);
|
|
1952
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
|
+
*/
|
|
1953
2006
|
setErrors(e) {
|
|
2007
|
+
this._arrayErrors.value = e;
|
|
1954
2008
|
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Очистить все errors (array-level + item-level)
|
|
2011
|
+
*
|
|
2012
|
+
* @example
|
|
2013
|
+
* ```typescript
|
|
2014
|
+
* arrayNode.clearErrors();
|
|
2015
|
+
* console.log(arrayNode.errors.value); // []
|
|
2016
|
+
* ```
|
|
2017
|
+
*/
|
|
1955
2018
|
clearErrors() {
|
|
1956
|
-
this.items.value.forEach((e) => e.clearErrors());
|
|
2019
|
+
this._arrayErrors.value = [], this.items.value.forEach((e) => e.clearErrors());
|
|
1957
2020
|
}
|
|
1958
2021
|
// ============================================================================
|
|
1959
2022
|
// Protected hooks (Template Method pattern)
|
|
@@ -1995,20 +2058,24 @@ class C extends O {
|
|
|
1995
2058
|
// ============================================================================
|
|
1996
2059
|
/**
|
|
1997
2060
|
* Итерировать по элементам массива
|
|
1998
|
-
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode
|
|
2061
|
+
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
1999
2062
|
*/
|
|
2000
2063
|
forEach(e) {
|
|
2001
|
-
this.items.value.forEach((t,
|
|
2002
|
-
|
|
2064
|
+
this.items.value.forEach((t, r) => {
|
|
2065
|
+
const i = t.getProxy();
|
|
2066
|
+
e(i, r);
|
|
2003
2067
|
});
|
|
2004
2068
|
}
|
|
2005
2069
|
/**
|
|
2006
2070
|
* Маппинг элементов массива
|
|
2007
|
-
* @param callback - Функция преобразования с типизированным GroupNode
|
|
2071
|
+
* @param callback - Функция преобразования с типизированным GroupNode proxy
|
|
2008
2072
|
* @returns Новый массив результатов
|
|
2009
2073
|
*/
|
|
2010
2074
|
map(e) {
|
|
2011
|
-
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
|
+
});
|
|
2012
2079
|
}
|
|
2013
2080
|
// ============================================================================
|
|
2014
2081
|
// Private методы
|
|
@@ -2019,7 +2086,7 @@ class C extends O {
|
|
|
2019
2086
|
*/
|
|
2020
2087
|
createItem(e) {
|
|
2021
2088
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2022
|
-
const t = new
|
|
2089
|
+
const t = new w(this.itemSchema);
|
|
2023
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;
|
|
2024
2091
|
}
|
|
2025
2092
|
throw new Error(
|
|
@@ -2106,14 +2173,14 @@ class C extends O {
|
|
|
2106
2173
|
* ```
|
|
2107
2174
|
*/
|
|
2108
2175
|
watchItems(e, t) {
|
|
2109
|
-
const
|
|
2110
|
-
const a = this.items.value.map((
|
|
2111
|
-
if (
|
|
2112
|
-
return
|
|
2176
|
+
const r = E(() => {
|
|
2177
|
+
const a = this.items.value.map((n) => {
|
|
2178
|
+
if (n instanceof w)
|
|
2179
|
+
return n.getFieldByPath(e)?.value.value;
|
|
2113
2180
|
});
|
|
2114
2181
|
t(a);
|
|
2115
|
-
}),
|
|
2116
|
-
return this.disposers.add(
|
|
2182
|
+
}), i = S("watchItems");
|
|
2183
|
+
return this.disposers.add(i, r);
|
|
2117
2184
|
}
|
|
2118
2185
|
/**
|
|
2119
2186
|
* Подписка на изменение длины массива
|
|
@@ -2139,10 +2206,10 @@ class C extends O {
|
|
|
2139
2206
|
*/
|
|
2140
2207
|
watchLength(e) {
|
|
2141
2208
|
const t = E(() => {
|
|
2142
|
-
const
|
|
2143
|
-
e(
|
|
2144
|
-
}),
|
|
2145
|
-
return this.disposers.add(
|
|
2209
|
+
const i = this.length.value;
|
|
2210
|
+
e(i);
|
|
2211
|
+
}), r = S("watchLength");
|
|
2212
|
+
return this.disposers.add(r, t);
|
|
2146
2213
|
}
|
|
2147
2214
|
/**
|
|
2148
2215
|
* Очистить все ресурсы узла
|
|
@@ -2205,7 +2272,7 @@ class C extends O {
|
|
|
2205
2272
|
});
|
|
2206
2273
|
}
|
|
2207
2274
|
}
|
|
2208
|
-
class
|
|
2275
|
+
class ee {
|
|
2209
2276
|
/**
|
|
2210
2277
|
* Создает узел формы на основе конфигурации
|
|
2211
2278
|
*
|
|
@@ -2255,16 +2322,16 @@ class X {
|
|
|
2255
2322
|
if (Array.isArray(e) && e.length >= 1)
|
|
2256
2323
|
return this.createArrayNodeFromArray(e);
|
|
2257
2324
|
if (this.isFieldConfig(e))
|
|
2258
|
-
return new
|
|
2325
|
+
return new Q(e);
|
|
2259
2326
|
if (this.isArrayConfig(e)) {
|
|
2260
2327
|
const t = e;
|
|
2261
|
-
return new
|
|
2328
|
+
return new N(
|
|
2262
2329
|
t.schema,
|
|
2263
2330
|
t.initialItems
|
|
2264
2331
|
);
|
|
2265
2332
|
}
|
|
2266
2333
|
if (this.isGroupConfig(e))
|
|
2267
|
-
return new
|
|
2334
|
+
return new w(e);
|
|
2268
2335
|
throw new Error(
|
|
2269
2336
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2270
2337
|
e
|
|
@@ -2298,11 +2365,11 @@ class X {
|
|
|
2298
2365
|
*/
|
|
2299
2366
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2300
2367
|
createArrayNodeFromArray(e) {
|
|
2301
|
-
const [t, ...
|
|
2302
|
-
this.isGroupConfig(t) &&
|
|
2303
|
-
for (const a of
|
|
2304
|
-
this.isGroupConfig(a) ?
|
|
2305
|
-
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);
|
|
2306
2373
|
}
|
|
2307
2374
|
/**
|
|
2308
2375
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2340,8 +2407,8 @@ class X {
|
|
|
2340
2407
|
return e.map((t) => this.extractValues(t));
|
|
2341
2408
|
if (this.isGroupConfig(e)) {
|
|
2342
2409
|
const t = {};
|
|
2343
|
-
for (const [
|
|
2344
|
-
t[
|
|
2410
|
+
for (const [r, i] of Object.entries(e))
|
|
2411
|
+
t[r] = this.extractValues(i);
|
|
2345
2412
|
return t;
|
|
2346
2413
|
}
|
|
2347
2414
|
return e;
|
|
@@ -2421,7 +2488,7 @@ class X {
|
|
|
2421
2488
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2422
2489
|
}
|
|
2423
2490
|
}
|
|
2424
|
-
class
|
|
2491
|
+
class pe {
|
|
2425
2492
|
/**
|
|
2426
2493
|
* Создать Debouncer с заданной задержкой
|
|
2427
2494
|
*
|
|
@@ -2464,17 +2531,17 @@ class fe {
|
|
|
2464
2531
|
* ```
|
|
2465
2532
|
*/
|
|
2466
2533
|
async debounce(e) {
|
|
2467
|
-
return new Promise((t,
|
|
2534
|
+
return new Promise((t, r) => {
|
|
2468
2535
|
if (this.timer && clearTimeout(this.timer), this.delay === 0) {
|
|
2469
|
-
Promise.resolve().then(() => e()).then(t).catch(
|
|
2536
|
+
Promise.resolve().then(() => e()).then(t).catch(r);
|
|
2470
2537
|
return;
|
|
2471
2538
|
}
|
|
2472
2539
|
this.timer = setTimeout(async () => {
|
|
2473
2540
|
try {
|
|
2474
|
-
const
|
|
2475
|
-
t(
|
|
2476
|
-
} catch (
|
|
2477
|
-
i
|
|
2541
|
+
const i = await e();
|
|
2542
|
+
t(i);
|
|
2543
|
+
} catch (i) {
|
|
2544
|
+
r(i);
|
|
2478
2545
|
}
|
|
2479
2546
|
}, this.delay);
|
|
2480
2547
|
});
|
|
@@ -2546,39 +2613,39 @@ class fe {
|
|
|
2546
2613
|
return this.timer !== void 0;
|
|
2547
2614
|
}
|
|
2548
2615
|
}
|
|
2549
|
-
function
|
|
2550
|
-
return new
|
|
2616
|
+
function ye(s) {
|
|
2617
|
+
return new w(s).getProxy();
|
|
2551
2618
|
}
|
|
2552
|
-
function
|
|
2619
|
+
function te(s) {
|
|
2553
2620
|
return {
|
|
2554
2621
|
type: "static",
|
|
2555
2622
|
load: async () => ({
|
|
2556
|
-
items:
|
|
2557
|
-
totalCount:
|
|
2623
|
+
items: s,
|
|
2624
|
+
totalCount: s.length
|
|
2558
2625
|
})
|
|
2559
2626
|
};
|
|
2560
2627
|
}
|
|
2561
|
-
function
|
|
2628
|
+
function re(s) {
|
|
2562
2629
|
let e = null;
|
|
2563
2630
|
return {
|
|
2564
2631
|
type: "preload",
|
|
2565
2632
|
load: async (t) => {
|
|
2566
2633
|
if (!e) {
|
|
2567
|
-
const
|
|
2634
|
+
const r = await s(t);
|
|
2568
2635
|
e = {
|
|
2569
|
-
items:
|
|
2570
|
-
totalCount:
|
|
2636
|
+
items: r,
|
|
2637
|
+
totalCount: r.length
|
|
2571
2638
|
};
|
|
2572
2639
|
}
|
|
2573
2640
|
return e;
|
|
2574
2641
|
}
|
|
2575
2642
|
};
|
|
2576
2643
|
}
|
|
2577
|
-
function
|
|
2644
|
+
function ie(s) {
|
|
2578
2645
|
return {
|
|
2579
2646
|
type: "partial",
|
|
2580
2647
|
load: async (e) => {
|
|
2581
|
-
const t = await
|
|
2648
|
+
const t = await s(e);
|
|
2582
2649
|
return {
|
|
2583
2650
|
items: t,
|
|
2584
2651
|
totalCount: t.length
|
|
@@ -2587,62 +2654,62 @@ function te(r) {
|
|
|
2587
2654
|
}
|
|
2588
2655
|
};
|
|
2589
2656
|
}
|
|
2590
|
-
const
|
|
2591
|
-
static:
|
|
2592
|
-
preload:
|
|
2593
|
-
partial:
|
|
2657
|
+
const me = {
|
|
2658
|
+
static: te,
|
|
2659
|
+
preload: re,
|
|
2660
|
+
partial: ie
|
|
2594
2661
|
};
|
|
2595
|
-
var
|
|
2596
|
-
var
|
|
2597
|
-
function
|
|
2598
|
-
if (
|
|
2599
|
-
|
|
2600
|
-
var
|
|
2662
|
+
var A = { exports: {} }, x = {};
|
|
2663
|
+
var I;
|
|
2664
|
+
function se() {
|
|
2665
|
+
if (I) return x;
|
|
2666
|
+
I = 1;
|
|
2667
|
+
var s = L;
|
|
2601
2668
|
function e(c, f) {
|
|
2602
2669
|
return c === f && (c !== 0 || 1 / c === 1 / f) || c !== c && f !== f;
|
|
2603
2670
|
}
|
|
2604
|
-
var t = typeof Object.is == "function" ? Object.is : e,
|
|
2605
|
-
function
|
|
2606
|
-
var
|
|
2671
|
+
var t = typeof Object.is == "function" ? Object.is : e, r = s.useState, i = s.useEffect, a = s.useLayoutEffect, n = s.useDebugValue;
|
|
2672
|
+
function o(c, f) {
|
|
2673
|
+
var d = f(), v = r({ inst: { value: d, getSnapshot: f } }), p = v[0].inst, g = v[1];
|
|
2607
2674
|
return a(
|
|
2608
2675
|
function() {
|
|
2609
|
-
p.value =
|
|
2676
|
+
p.value = d, p.getSnapshot = f, l(p) && g({ inst: p });
|
|
2610
2677
|
},
|
|
2611
|
-
[c,
|
|
2612
|
-
),
|
|
2678
|
+
[c, d, f]
|
|
2679
|
+
), i(
|
|
2613
2680
|
function() {
|
|
2614
2681
|
return l(p) && g({ inst: p }), c(function() {
|
|
2615
2682
|
l(p) && g({ inst: p });
|
|
2616
2683
|
});
|
|
2617
2684
|
},
|
|
2618
2685
|
[c]
|
|
2619
|
-
),
|
|
2686
|
+
), n(d), d;
|
|
2620
2687
|
}
|
|
2621
2688
|
function l(c) {
|
|
2622
2689
|
var f = c.getSnapshot;
|
|
2623
2690
|
c = c.value;
|
|
2624
2691
|
try {
|
|
2625
|
-
var
|
|
2626
|
-
return !t(c,
|
|
2692
|
+
var d = f();
|
|
2693
|
+
return !t(c, d);
|
|
2627
2694
|
} catch {
|
|
2628
2695
|
return !0;
|
|
2629
2696
|
}
|
|
2630
2697
|
}
|
|
2631
|
-
function
|
|
2698
|
+
function h(c, f) {
|
|
2632
2699
|
return f();
|
|
2633
2700
|
}
|
|
2634
|
-
var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ?
|
|
2635
|
-
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;
|
|
2636
2703
|
}
|
|
2637
|
-
var
|
|
2638
|
-
var
|
|
2639
|
-
function
|
|
2640
|
-
return
|
|
2641
|
-
function
|
|
2642
|
-
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;
|
|
2643
2710
|
}
|
|
2644
|
-
function e(
|
|
2645
|
-
m ||
|
|
2711
|
+
function e(d, v) {
|
|
2712
|
+
m || i.startTransition === void 0 || (m = !0, console.error(
|
|
2646
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."
|
|
2647
2714
|
));
|
|
2648
2715
|
var p = v();
|
|
@@ -2652,112 +2719,112 @@ function se() {
|
|
|
2652
2719
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2653
2720
|
), c = !0);
|
|
2654
2721
|
}
|
|
2655
|
-
g =
|
|
2722
|
+
g = n({
|
|
2656
2723
|
inst: { value: p, getSnapshot: v }
|
|
2657
2724
|
});
|
|
2658
|
-
var _ = g[0].inst,
|
|
2725
|
+
var _ = g[0].inst, k = g[1];
|
|
2659
2726
|
return l(
|
|
2660
2727
|
function() {
|
|
2661
|
-
_.value = p, _.getSnapshot = v, t(_) &&
|
|
2728
|
+
_.value = p, _.getSnapshot = v, t(_) && k({ inst: _ });
|
|
2662
2729
|
},
|
|
2663
|
-
[
|
|
2664
|
-
),
|
|
2730
|
+
[d, p, v]
|
|
2731
|
+
), o(
|
|
2665
2732
|
function() {
|
|
2666
|
-
return t(_) &&
|
|
2667
|
-
t(_) &&
|
|
2733
|
+
return t(_) && k({ inst: _ }), d(function() {
|
|
2734
|
+
t(_) && k({ inst: _ });
|
|
2668
2735
|
});
|
|
2669
2736
|
},
|
|
2670
|
-
[
|
|
2671
|
-
),
|
|
2737
|
+
[d]
|
|
2738
|
+
), h(p), p;
|
|
2672
2739
|
}
|
|
2673
|
-
function t(
|
|
2674
|
-
var v =
|
|
2675
|
-
|
|
2740
|
+
function t(d) {
|
|
2741
|
+
var v = d.getSnapshot;
|
|
2742
|
+
d = d.value;
|
|
2676
2743
|
try {
|
|
2677
2744
|
var p = v();
|
|
2678
|
-
return !a(
|
|
2745
|
+
return !a(d, p);
|
|
2679
2746
|
} catch {
|
|
2680
2747
|
return !0;
|
|
2681
2748
|
}
|
|
2682
2749
|
}
|
|
2683
|
-
function
|
|
2750
|
+
function r(d, v) {
|
|
2684
2751
|
return v();
|
|
2685
2752
|
}
|
|
2686
2753
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2687
|
-
var
|
|
2688
|
-
|
|
2689
|
-
})()),
|
|
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;
|
|
2690
2757
|
}
|
|
2691
|
-
var
|
|
2692
|
-
function
|
|
2693
|
-
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;
|
|
2694
2761
|
}
|
|
2695
|
-
var
|
|
2696
|
-
function
|
|
2697
|
-
if (
|
|
2698
|
-
if (
|
|
2699
|
-
for (let t = 0; t <
|
|
2700
|
-
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;
|
|
2701
2768
|
return !0;
|
|
2702
2769
|
}
|
|
2703
|
-
function
|
|
2704
|
-
const
|
|
2705
|
-
if (
|
|
2706
|
-
const
|
|
2707
|
-
for (const
|
|
2708
|
-
o
|
|
2709
|
-
|
|
2710
|
-
}
|
|
2711
|
-
const
|
|
2712
|
-
(
|
|
2713
|
-
let
|
|
2770
|
+
function $(s, e, t) {
|
|
2771
|
+
const r = G(null);
|
|
2772
|
+
if (r.current === null) {
|
|
2773
|
+
const n = {};
|
|
2774
|
+
for (const o in s)
|
|
2775
|
+
n[o] = s[o].value;
|
|
2776
|
+
r.current = { ...n, __snapshot: null };
|
|
2777
|
+
}
|
|
2778
|
+
const i = b(
|
|
2779
|
+
(n) => {
|
|
2780
|
+
let o = !0;
|
|
2714
2781
|
return E(() => {
|
|
2715
|
-
for (const
|
|
2716
|
-
|
|
2717
|
-
if (
|
|
2718
|
-
|
|
2782
|
+
for (const h in s)
|
|
2783
|
+
s[h].value;
|
|
2784
|
+
if (o) {
|
|
2785
|
+
o = !1;
|
|
2719
2786
|
return;
|
|
2720
2787
|
}
|
|
2721
|
-
|
|
2788
|
+
n();
|
|
2722
2789
|
});
|
|
2723
2790
|
},
|
|
2724
|
-
[
|
|
2725
|
-
), a =
|
|
2726
|
-
const
|
|
2727
|
-
for (const
|
|
2728
|
-
|
|
2791
|
+
[s]
|
|
2792
|
+
), a = b(() => {
|
|
2793
|
+
const n = r.current, o = {};
|
|
2794
|
+
for (const h in s)
|
|
2795
|
+
o[h] = s[h].value;
|
|
2729
2796
|
let l = !1;
|
|
2730
|
-
for (const
|
|
2731
|
-
const { key: m, useShallowArrayEqual: c } =
|
|
2797
|
+
for (const h of e) {
|
|
2798
|
+
const { key: m, useShallowArrayEqual: c } = h, f = o[m], d = n[m];
|
|
2732
2799
|
if (c) {
|
|
2733
|
-
if (!
|
|
2800
|
+
if (!oe(d, f)) {
|
|
2734
2801
|
l = !0;
|
|
2735
2802
|
break;
|
|
2736
2803
|
}
|
|
2737
|
-
} else if (
|
|
2804
|
+
} else if (d !== f) {
|
|
2738
2805
|
l = !0;
|
|
2739
2806
|
break;
|
|
2740
2807
|
}
|
|
2741
2808
|
}
|
|
2742
|
-
if (!l &&
|
|
2743
|
-
return
|
|
2744
|
-
for (const
|
|
2745
|
-
|
|
2746
|
-
return
|
|
2747
|
-
}, [
|
|
2748
|
-
return
|
|
2809
|
+
if (!l && n.__snapshot)
|
|
2810
|
+
return n.__snapshot;
|
|
2811
|
+
for (const h in s)
|
|
2812
|
+
n[h] = o[h];
|
|
2813
|
+
return n.__snapshot = t(o), n.__snapshot;
|
|
2814
|
+
}, [s, t]);
|
|
2815
|
+
return U.useSyncExternalStore(i, a, a);
|
|
2749
2816
|
}
|
|
2750
|
-
function
|
|
2817
|
+
function le(s) {
|
|
2751
2818
|
const e = {
|
|
2752
|
-
value:
|
|
2753
|
-
disabled:
|
|
2754
|
-
errors:
|
|
2755
|
-
pending:
|
|
2756
|
-
valid:
|
|
2757
|
-
invalid:
|
|
2758
|
-
touched:
|
|
2759
|
-
shouldShowError:
|
|
2760
|
-
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
|
|
2761
2828
|
}, t = [
|
|
2762
2829
|
{ key: "value" },
|
|
2763
2830
|
{ key: "disabled" },
|
|
@@ -2768,32 +2835,32 @@ function ne(r) {
|
|
|
2768
2835
|
{ key: "touched" },
|
|
2769
2836
|
{ key: "shouldShowError" },
|
|
2770
2837
|
{ key: "componentProps" }
|
|
2771
|
-
],
|
|
2772
|
-
(
|
|
2773
|
-
value:
|
|
2774
|
-
pending:
|
|
2775
|
-
disabled:
|
|
2776
|
-
errors:
|
|
2777
|
-
valid:
|
|
2778
|
-
invalid:
|
|
2779
|
-
touched:
|
|
2780
|
-
shouldShowError:
|
|
2781
|
-
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
|
|
2782
2849
|
}),
|
|
2783
2850
|
[]
|
|
2784
2851
|
);
|
|
2785
|
-
return
|
|
2852
|
+
return $(e, t, r);
|
|
2786
2853
|
}
|
|
2787
|
-
function
|
|
2854
|
+
function ue(s) {
|
|
2788
2855
|
const e = {
|
|
2789
|
-
value:
|
|
2790
|
-
length:
|
|
2791
|
-
errors:
|
|
2792
|
-
pending:
|
|
2793
|
-
valid:
|
|
2794
|
-
invalid:
|
|
2795
|
-
touched:
|
|
2796
|
-
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
|
|
2797
2864
|
}, t = [
|
|
2798
2865
|
{ key: "value" },
|
|
2799
2866
|
{ key: "length" },
|
|
@@ -2803,24 +2870,24 @@ function oe(r) {
|
|
|
2803
2870
|
{ key: "invalid" },
|
|
2804
2871
|
{ key: "touched" },
|
|
2805
2872
|
{ key: "dirty" }
|
|
2806
|
-
],
|
|
2807
|
-
(
|
|
2808
|
-
value:
|
|
2809
|
-
length:
|
|
2810
|
-
pending:
|
|
2811
|
-
errors:
|
|
2812
|
-
valid:
|
|
2813
|
-
invalid:
|
|
2814
|
-
touched:
|
|
2815
|
-
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
|
|
2816
2883
|
}),
|
|
2817
2884
|
[]
|
|
2818
2885
|
);
|
|
2819
|
-
return
|
|
2886
|
+
return $(e, t, r);
|
|
2820
2887
|
}
|
|
2821
|
-
function
|
|
2822
|
-
const e =
|
|
2823
|
-
return
|
|
2888
|
+
function ge(s) {
|
|
2889
|
+
const e = s && "length" in s && "map" in s;
|
|
2890
|
+
return s ? e ? ue(s) : le(s) : {
|
|
2824
2891
|
value: [],
|
|
2825
2892
|
length: 0,
|
|
2826
2893
|
pending: !1,
|
|
@@ -2831,56 +2898,57 @@ function ye(r) {
|
|
|
2831
2898
|
dirty: !1
|
|
2832
2899
|
};
|
|
2833
2900
|
}
|
|
2834
|
-
function
|
|
2835
|
-
const e =
|
|
2836
|
-
(
|
|
2901
|
+
function _e(s) {
|
|
2902
|
+
const e = G({ value: s.value.value }), t = b(
|
|
2903
|
+
(i) => {
|
|
2837
2904
|
let a = !0;
|
|
2838
2905
|
return E(() => {
|
|
2839
|
-
if (
|
|
2906
|
+
if (s.value.value, a) {
|
|
2840
2907
|
a = !1;
|
|
2841
2908
|
return;
|
|
2842
2909
|
}
|
|
2843
|
-
|
|
2910
|
+
i();
|
|
2844
2911
|
});
|
|
2845
2912
|
},
|
|
2846
|
-
[
|
|
2847
|
-
),
|
|
2848
|
-
const
|
|
2849
|
-
return e.current.value ===
|
|
2850
|
-
}, [
|
|
2851
|
-
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);
|
|
2852
2919
|
}
|
|
2853
2920
|
export {
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2921
|
+
N as ArrayNode,
|
|
2922
|
+
pe as Debouncer,
|
|
2923
|
+
V as ErrorStrategy,
|
|
2924
|
+
Q as FieldNode,
|
|
2925
|
+
Z as FieldPathNavigator,
|
|
2926
|
+
O as FormErrorHandler,
|
|
2927
|
+
F as FormNode,
|
|
2928
|
+
w as GroupNode,
|
|
2929
|
+
ee as NodeFactory,
|
|
2863
2930
|
Fe as RegistryStack,
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
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,
|
|
2871
2938
|
Te as getCurrentBehaviorRegistry,
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2939
|
+
De as getCurrentValidationRegistry,
|
|
2940
|
+
Ae as getNodeType,
|
|
2941
|
+
T as isArrayNode,
|
|
2942
|
+
R as isFieldNode,
|
|
2876
2943
|
Ve as isFormNode,
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
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
|
|
2886
2954
|
};
|