@reformer/core 11.0.0-beta.1 → 11.0.0-beta.3
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.js +134 -134
- package/dist/form/create-core-form.d.ts +70 -0
- package/dist/form/hooks/use-form-bundle.d.ts +26 -0
- package/dist/form/index.d.ts +6 -0
- package/dist/form/validation-config.d.ts +73 -0
- package/dist/form/validation-strategy.d.ts +8 -2
- package/dist/form-model-DhW2HZOB.js +323 -0
- package/dist/index.js +535 -481
- package/dist/state/form-model.d.ts +14 -0
- package/dist/state/index.d.ts +2 -1
- package/dist/state/types.d.ts +39 -11
- package/dist/state.js +18 -18
- package/dist/validation.js +92 -92
- package/docs/llms/02-quick-start.md +14 -7
- package/docs/llms/15-project-structure.md +12 -8
- package/docs/llms/19-reading-values.md +30 -1
- package/docs/llms/20-compute-vs-watch.md +9 -0
- package/llms.txt +374 -20
- package/package.json +1 -1
- package/dist/derived-registry-CluZCQ7U.js +0 -16
- package/dist/form-model-DYCzGGKF.js +0 -286
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { createFormValidation as se } from "./validation.js";
|
|
1
|
+
import { a as G, c as ee } from "./form-model-DhW2HZOB.js";
|
|
2
|
+
import { i as Ke, m as He, u as Ye } from "./form-model-DhW2HZOB.js";
|
|
3
|
+
import { c as Je, a as Qe, r as Xe, b as Ze, d as et, e as tt, f as st, s as rt, t as it, w as nt } from "./behaviors-value-C7dSEhCc.js";
|
|
4
|
+
import { S as L } from "./subscription-manager-705bls97.js";
|
|
5
|
+
import { signal as g, computed as m, effect as _, batch as te, Signal as j } from "@preact/signals-core";
|
|
6
|
+
import { r as se } from "./signal-node-registry-tiwel-TV.js";
|
|
7
|
+
import { g as ot } from "./signal-node-registry-tiwel-TV.js";
|
|
8
|
+
import { defineValidationSchema as re, createFormValidation as D, validateModel as ie, apply as ne } from "./validation.js";
|
|
9
|
+
import Y, { useState as ae, useEffect as z, useRef as V, useCallback as E, useMemo as oe } from "react";
|
|
10
|
+
import { d as ut, e as dt } from "./behaviors-node-DGEFMTQu.js";
|
|
12
11
|
class M {
|
|
13
12
|
// ============================================================================
|
|
14
13
|
// Protected состояние (для Template Method паттерна)
|
|
@@ -35,21 +34,21 @@ class M {
|
|
|
35
34
|
* Пользователь взаимодействовал с узлом (touched)
|
|
36
35
|
* Computed из _touched для предоставления readonly интерфейса
|
|
37
36
|
*/
|
|
38
|
-
touched =
|
|
37
|
+
touched = m(() => this._touched.value);
|
|
39
38
|
/**
|
|
40
39
|
* Значение узла было изменено (dirty)
|
|
41
40
|
* Computed из _dirty для предоставления readonly интерфейса
|
|
42
41
|
*/
|
|
43
|
-
dirty =
|
|
42
|
+
dirty = m(() => this._dirty.value);
|
|
44
43
|
/**
|
|
45
44
|
* Текущий статус узла
|
|
46
45
|
* Computed из _status для предоставления readonly интерфейса
|
|
47
46
|
*/
|
|
48
|
-
status =
|
|
47
|
+
status = m(() => this._status.value);
|
|
49
48
|
/**
|
|
50
49
|
* Узел отключен (disabled)
|
|
51
50
|
*/
|
|
52
|
-
disabled =
|
|
51
|
+
disabled = m(() => this._status.value === "disabled");
|
|
53
52
|
/**
|
|
54
53
|
* Получить ошибки валидации с фильтрацией
|
|
55
54
|
*
|
|
@@ -91,17 +90,17 @@ class M {
|
|
|
91
90
|
*/
|
|
92
91
|
getErrors(e) {
|
|
93
92
|
const t = this.errors.value;
|
|
94
|
-
return e ? t.filter((
|
|
95
|
-
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(
|
|
93
|
+
return e ? t.filter((r) => {
|
|
94
|
+
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()))
|
|
96
95
|
return !1;
|
|
97
96
|
if (e.params !== void 0) {
|
|
98
|
-
if (!
|
|
97
|
+
if (!r.params)
|
|
99
98
|
return !1;
|
|
100
|
-
for (const [
|
|
101
|
-
if (
|
|
99
|
+
for (const [i, n] of Object.entries(e.params))
|
|
100
|
+
if (r.params[i] !== n)
|
|
102
101
|
return !1;
|
|
103
102
|
}
|
|
104
|
-
return !(e.predicate !== void 0 && !e.predicate(
|
|
103
|
+
return !(e.predicate !== void 0 && !e.predicate(r));
|
|
105
104
|
}) : t;
|
|
106
105
|
}
|
|
107
106
|
// ============================================================================
|
|
@@ -284,15 +283,15 @@ const O = {
|
|
|
284
283
|
/** GroupNode.watchField() */
|
|
285
284
|
WatchField: "watchField"
|
|
286
285
|
};
|
|
287
|
-
let
|
|
288
|
-
function
|
|
289
|
-
return `${
|
|
286
|
+
let le = 0;
|
|
287
|
+
function F(s) {
|
|
288
|
+
return `${s}-${++le}`;
|
|
290
289
|
}
|
|
291
|
-
var
|
|
290
|
+
var S = /* @__PURE__ */ ((s) => (s.THROW = "throw", s.LOG = "log", s.CONVERT = "convert", s))(S || {});
|
|
292
291
|
class k {
|
|
293
|
-
static handle(e, t,
|
|
294
|
-
const
|
|
295
|
-
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e),
|
|
292
|
+
static handle(e, t, r = "throw") {
|
|
293
|
+
const i = this.extractMessage(e);
|
|
294
|
+
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), r) {
|
|
296
295
|
case "throw":
|
|
297
296
|
throw e;
|
|
298
297
|
case "log":
|
|
@@ -300,7 +299,7 @@ class k {
|
|
|
300
299
|
case "convert":
|
|
301
300
|
return {
|
|
302
301
|
code: "validator_error",
|
|
303
|
-
message:
|
|
302
|
+
message: i,
|
|
304
303
|
params: { field: t }
|
|
305
304
|
};
|
|
306
305
|
}
|
|
@@ -356,11 +355,11 @@ class k {
|
|
|
356
355
|
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
357
356
|
* ```
|
|
358
357
|
*/
|
|
359
|
-
static createValidationError(e, t,
|
|
358
|
+
static createValidationError(e, t, r) {
|
|
360
359
|
return {
|
|
361
360
|
code: e,
|
|
362
361
|
message: t,
|
|
363
|
-
params:
|
|
362
|
+
params: r ? { field: r } : void 0
|
|
364
363
|
};
|
|
365
364
|
}
|
|
366
365
|
/**
|
|
@@ -382,7 +381,7 @@ class k {
|
|
|
382
381
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
383
382
|
}
|
|
384
383
|
}
|
|
385
|
-
class
|
|
384
|
+
class ue {
|
|
386
385
|
/** Внутренний сигнал статуса */
|
|
387
386
|
_status;
|
|
388
387
|
/** Публичный read-only сигнал статуса */
|
|
@@ -399,7 +398,7 @@ class ie {
|
|
|
399
398
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
400
399
|
*/
|
|
401
400
|
constructor(e = "valid") {
|
|
402
|
-
this._status = g(e), this.status =
|
|
401
|
+
this._status = g(e), this.status = m(() => this._status.value), this.valid = m(() => this._status.value === "valid"), this.invalid = m(() => this._status.value === "invalid"), this.pending = m(() => this._status.value === "pending"), this.disabled = m(() => this._status.value === "disabled");
|
|
403
402
|
}
|
|
404
403
|
/**
|
|
405
404
|
* Начать валидацию
|
|
@@ -482,7 +481,7 @@ class ie {
|
|
|
482
481
|
this._status.value = e ? "invalid" : "valid";
|
|
483
482
|
}
|
|
484
483
|
}
|
|
485
|
-
class
|
|
484
|
+
class de extends M {
|
|
486
485
|
// ============================================================================
|
|
487
486
|
// Приватные сигналы
|
|
488
487
|
// ============================================================================
|
|
@@ -534,13 +533,13 @@ class ne extends M {
|
|
|
534
533
|
* Менеджер подписок для централизованного cleanup
|
|
535
534
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
536
535
|
*/
|
|
537
|
-
disposers = new
|
|
536
|
+
disposers = new L();
|
|
538
537
|
component;
|
|
539
538
|
// ============================================================================
|
|
540
539
|
// Конструктор
|
|
541
540
|
// ============================================================================
|
|
542
541
|
constructor(e) {
|
|
543
|
-
super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new
|
|
542
|
+
super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new ue(e.disabled ? "disabled" : "valid"), this.value = m(() => this._value.value), this.valid = m(() => this.statusMachine.valid.value), this.invalid = m(() => this.statusMachine.invalid.value), this.pending = m(() => this.statusMachine.pending.value), this.status = m(() => this.statusMachine.status.value), this.disabled = m(() => this.statusMachine.disabled.value), this.errors = m(() => this._errors.value), this.componentProps = m(() => this._componentProps.value), this.shouldShowError = m(
|
|
544
543
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
545
544
|
);
|
|
546
545
|
}
|
|
@@ -553,12 +552,12 @@ class ne extends M {
|
|
|
553
552
|
setValue(e, t) {
|
|
554
553
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
555
554
|
return;
|
|
556
|
-
const
|
|
555
|
+
const r = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
557
556
|
if (this.updateOn === "change") {
|
|
558
557
|
this.validate();
|
|
559
558
|
return;
|
|
560
559
|
}
|
|
561
|
-
|
|
560
|
+
i && r && this.validate();
|
|
562
561
|
}
|
|
563
562
|
patchValue(e) {
|
|
564
563
|
this.setValue(e);
|
|
@@ -651,20 +650,20 @@ class ne extends M {
|
|
|
651
650
|
const t = e?.debounce ?? this.debounceMs;
|
|
652
651
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
653
652
|
return this.validateImmediate();
|
|
654
|
-
const
|
|
655
|
-
return new Promise((
|
|
656
|
-
this.pendingValidation = { resolve:
|
|
657
|
-
if (this.validateDebounceTimer = void 0,
|
|
658
|
-
|
|
653
|
+
const r = new AbortController();
|
|
654
|
+
return new Promise((i) => {
|
|
655
|
+
this.pendingValidation = { resolve: i, abortController: r }, this.validateDebounceTimer = setTimeout(async () => {
|
|
656
|
+
if (this.validateDebounceTimer = void 0, r.signal.aborted) {
|
|
657
|
+
i(!1);
|
|
659
658
|
return;
|
|
660
659
|
}
|
|
661
660
|
this.pendingValidation = void 0;
|
|
662
|
-
const n = await this.validateImmediate(
|
|
663
|
-
|
|
664
|
-
}, t),
|
|
661
|
+
const n = await this.validateImmediate(r);
|
|
662
|
+
i(n);
|
|
663
|
+
}, t), r.signal.addEventListener(
|
|
665
664
|
"abort",
|
|
666
665
|
() => {
|
|
667
|
-
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0),
|
|
666
|
+
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), i(!1);
|
|
668
667
|
},
|
|
669
668
|
{ once: !0 }
|
|
670
669
|
);
|
|
@@ -683,31 +682,31 @@ class ne extends M {
|
|
|
683
682
|
async validateImmediate(e) {
|
|
684
683
|
const t = e ?? new AbortController();
|
|
685
684
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
686
|
-
const { signal:
|
|
685
|
+
const { signal: r } = t, i = [];
|
|
687
686
|
for (const a of this.validators) {
|
|
688
687
|
const l = a(this._value.value);
|
|
689
|
-
l &&
|
|
688
|
+
l && i.push(l);
|
|
690
689
|
}
|
|
691
|
-
if (
|
|
690
|
+
if (r.aborted)
|
|
692
691
|
return !1;
|
|
693
|
-
if (
|
|
694
|
-
this._errors.value =
|
|
695
|
-
const a =
|
|
692
|
+
if (i.length > 0) {
|
|
693
|
+
this._errors.value = i;
|
|
694
|
+
const a = i.some((l) => l.severity !== "warning");
|
|
696
695
|
if (this.statusMachine.setErrors(a), a)
|
|
697
696
|
return !1;
|
|
698
697
|
}
|
|
699
698
|
if (this.asyncValidators.length > 0) {
|
|
700
|
-
if (
|
|
699
|
+
if (r.aborted)
|
|
701
700
|
return !1;
|
|
702
701
|
this.statusMachine.startValidation();
|
|
703
702
|
try {
|
|
704
703
|
const a = await Promise.all(
|
|
705
704
|
this.asyncValidators.map(async (d) => {
|
|
706
|
-
if (
|
|
705
|
+
if (r.aborted)
|
|
707
706
|
throw new DOMException("Validation aborted", "AbortError");
|
|
708
707
|
try {
|
|
709
|
-
const u = await d(this._value.value, { signal:
|
|
710
|
-
if (
|
|
708
|
+
const u = await d(this._value.value, { signal: r });
|
|
709
|
+
if (r.aborted)
|
|
711
710
|
throw new DOMException("Validation aborted", "AbortError");
|
|
712
711
|
return u;
|
|
713
712
|
} catch (u) {
|
|
@@ -716,12 +715,12 @@ class ne extends M {
|
|
|
716
715
|
return k.handle(
|
|
717
716
|
u,
|
|
718
717
|
"FieldNode AsyncValidator",
|
|
719
|
-
|
|
718
|
+
S.CONVERT
|
|
720
719
|
);
|
|
721
720
|
}
|
|
722
721
|
})
|
|
723
722
|
);
|
|
724
|
-
if (
|
|
723
|
+
if (r.aborted)
|
|
725
724
|
return !1;
|
|
726
725
|
const l = a.filter((d) => d !== null);
|
|
727
726
|
if (l.length > 0) {
|
|
@@ -736,11 +735,11 @@ class ne extends M {
|
|
|
736
735
|
throw a;
|
|
737
736
|
}
|
|
738
737
|
}
|
|
739
|
-
return
|
|
738
|
+
return r.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
|
|
740
739
|
}
|
|
741
740
|
setErrors(e) {
|
|
742
741
|
this._errors.value = e;
|
|
743
|
-
const t = e.some((
|
|
742
|
+
const t = e.some((r) => r.severity !== "warning");
|
|
744
743
|
this.statusMachine.setErrors(t);
|
|
745
744
|
}
|
|
746
745
|
clearErrors() {
|
|
@@ -857,12 +856,12 @@ class ne extends M {
|
|
|
857
856
|
* ```
|
|
858
857
|
*/
|
|
859
858
|
watch(e) {
|
|
860
|
-
const t = new AbortController(),
|
|
859
|
+
const t = new AbortController(), r = _(() => {
|
|
861
860
|
const n = this.value.value;
|
|
862
861
|
e(n, t.signal);
|
|
863
|
-
}),
|
|
864
|
-
return this.disposers.add(
|
|
865
|
-
t.abort(),
|
|
862
|
+
}), i = F(O.Watch);
|
|
863
|
+
return this.disposers.add(i, () => {
|
|
864
|
+
t.abort(), r();
|
|
866
865
|
});
|
|
867
866
|
}
|
|
868
867
|
/**
|
|
@@ -888,11 +887,11 @@ class ne extends M {
|
|
|
888
887
|
* ```
|
|
889
888
|
*/
|
|
890
889
|
computeFrom(e, t) {
|
|
891
|
-
const
|
|
890
|
+
const r = _(() => {
|
|
892
891
|
const n = e.map((l) => l.value), a = t(...n);
|
|
893
892
|
this.setValue(a, { emitEvent: !1 });
|
|
894
|
-
}),
|
|
895
|
-
return this.disposers.add(
|
|
893
|
+
}), i = F(O.ComputeFrom);
|
|
894
|
+
return this.disposers.add(i, r);
|
|
896
895
|
}
|
|
897
896
|
/**
|
|
898
897
|
* Очистить все ресурсы и таймеры
|
|
@@ -922,59 +921,59 @@ class ne extends M {
|
|
|
922
921
|
}
|
|
923
922
|
}
|
|
924
923
|
}
|
|
925
|
-
function
|
|
926
|
-
const { getChildren: e, ownErrors: t, disabled:
|
|
924
|
+
function R(s) {
|
|
925
|
+
const { getChildren: e, ownErrors: t, disabled: r } = s, i = m(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = m(() => !i.value), a = m(() => e().some((o) => o.pending.value)), l = m(() => e().some((o) => o.touched.value)), d = m(() => e().some((o) => o.dirty.value)), u = m(() => {
|
|
927
926
|
const o = [...t.value];
|
|
928
|
-
for (const
|
|
929
|
-
o.push(...
|
|
927
|
+
for (const f of e())
|
|
928
|
+
o.push(...f.errors.value);
|
|
930
929
|
return o;
|
|
931
|
-
}),
|
|
930
|
+
}), h = m(() => r?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
932
931
|
return {
|
|
933
|
-
valid:
|
|
932
|
+
valid: i,
|
|
934
933
|
invalid: n,
|
|
935
934
|
pending: a,
|
|
936
935
|
touched: l,
|
|
937
936
|
dirty: d,
|
|
938
937
|
errors: u,
|
|
939
|
-
status:
|
|
938
|
+
status: h
|
|
940
939
|
};
|
|
941
940
|
}
|
|
942
|
-
function
|
|
943
|
-
return typeof
|
|
941
|
+
function B(s) {
|
|
942
|
+
return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
|
|
944
943
|
}
|
|
945
944
|
const U = "$";
|
|
946
|
-
function
|
|
945
|
+
function ce(s, e) {
|
|
947
946
|
let t;
|
|
948
|
-
const
|
|
947
|
+
const r = () => {
|
|
949
948
|
if (!t) {
|
|
950
|
-
const
|
|
949
|
+
const i = {};
|
|
951
950
|
e.forEach((n, a) => {
|
|
952
|
-
|
|
953
|
-
}), t =
|
|
951
|
+
i[a] = n && B(n) ? n.getProxy() : n;
|
|
952
|
+
}), t = i;
|
|
954
953
|
}
|
|
955
954
|
return t;
|
|
956
955
|
};
|
|
957
|
-
return new Proxy(
|
|
958
|
-
get: (
|
|
956
|
+
return new Proxy(s, {
|
|
957
|
+
get: (i, n) => {
|
|
959
958
|
if (n === U)
|
|
960
|
-
return
|
|
961
|
-
if (n in
|
|
962
|
-
return
|
|
959
|
+
return r();
|
|
960
|
+
if (n in i)
|
|
961
|
+
return i[n];
|
|
963
962
|
if (typeof n == "string" && e.has(n)) {
|
|
964
963
|
const a = e.get(n);
|
|
965
|
-
return a &&
|
|
964
|
+
return a && B(a) ? a.getProxy() : a;
|
|
966
965
|
}
|
|
967
966
|
},
|
|
968
|
-
set: (
|
|
969
|
-
has: (
|
|
970
|
-
ownKeys: (
|
|
971
|
-
const n = Reflect.ownKeys(
|
|
967
|
+
set: (i, n, a) => typeof n == "string" && e.has(n) ? !1 : (i[n] = a, !0),
|
|
968
|
+
has: (i, n) => n === U || typeof n == "string" && e.has(n) ? !0 : n in i,
|
|
969
|
+
ownKeys: (i) => {
|
|
970
|
+
const n = Reflect.ownKeys(i), a = Array.from(e.keys());
|
|
972
971
|
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
973
972
|
},
|
|
974
|
-
getOwnPropertyDescriptor: (
|
|
973
|
+
getOwnPropertyDescriptor: (i, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, n)
|
|
975
974
|
});
|
|
976
975
|
}
|
|
977
|
-
class
|
|
976
|
+
class he {
|
|
978
977
|
/**
|
|
979
978
|
* @param form - Форма для отправки
|
|
980
979
|
*/
|
|
@@ -984,7 +983,7 @@ class oe {
|
|
|
984
983
|
/** Внутренний сигнал состояния отправки */
|
|
985
984
|
_submitting = g(!1);
|
|
986
985
|
/** Публичный read-only сигнал состояния отправки */
|
|
987
|
-
submitting =
|
|
986
|
+
submitting = m(() => this._submitting.value);
|
|
988
987
|
/**
|
|
989
988
|
* Отправить форму
|
|
990
989
|
*
|
|
@@ -1019,8 +1018,8 @@ class oe {
|
|
|
1019
1018
|
* ```
|
|
1020
1019
|
*/
|
|
1021
1020
|
async submit(e, t) {
|
|
1022
|
-
const { skipValidation:
|
|
1023
|
-
if (
|
|
1021
|
+
const { skipValidation: r = !1, skipTouch: i = !1 } = t || {};
|
|
1022
|
+
if (i || this.form.markAsTouched(), !r && !await this.form.validate())
|
|
1024
1023
|
return null;
|
|
1025
1024
|
this._submitting.value = !0;
|
|
1026
1025
|
try {
|
|
@@ -1054,8 +1053,8 @@ class oe {
|
|
|
1054
1053
|
* ```
|
|
1055
1054
|
*/
|
|
1056
1055
|
async submitWithResult(e, t) {
|
|
1057
|
-
const { skipValidation:
|
|
1058
|
-
if (
|
|
1056
|
+
const { skipValidation: r = !1, skipTouch: i = !1 } = t || {};
|
|
1057
|
+
if (i || this.form.markAsTouched(), !r && !await this.form.validate())
|
|
1059
1058
|
return { success: !1, data: null };
|
|
1060
1059
|
this._submitting.value = !0;
|
|
1061
1060
|
try {
|
|
@@ -1071,16 +1070,16 @@ class oe {
|
|
|
1071
1070
|
}
|
|
1072
1071
|
}
|
|
1073
1072
|
}
|
|
1074
|
-
function
|
|
1073
|
+
function fe(s) {
|
|
1075
1074
|
const e = [];
|
|
1076
|
-
for (const t of
|
|
1077
|
-
const
|
|
1078
|
-
if (!
|
|
1079
|
-
e.push(
|
|
1075
|
+
for (const t of s.split(".")) {
|
|
1076
|
+
const r = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1077
|
+
if (!r) return [];
|
|
1078
|
+
e.push(r[2] !== void 0 ? { key: r[1], index: Number(r[2]) } : { key: r[1] });
|
|
1080
1079
|
}
|
|
1081
1080
|
return e;
|
|
1082
1081
|
}
|
|
1083
|
-
class
|
|
1082
|
+
class A extends M {
|
|
1084
1083
|
// ============================================================================
|
|
1085
1084
|
// Приватные поля
|
|
1086
1085
|
// ============================================================================
|
|
@@ -1093,7 +1092,7 @@ class S extends M {
|
|
|
1093
1092
|
/**
|
|
1094
1093
|
* Менеджер подписок для централизованного cleanup
|
|
1095
1094
|
*/
|
|
1096
|
-
disposers = new
|
|
1095
|
+
disposers = new L();
|
|
1097
1096
|
/**
|
|
1098
1097
|
* Ссылка на Proxy-инстанс
|
|
1099
1098
|
*/
|
|
@@ -1105,7 +1104,7 @@ class S extends M {
|
|
|
1105
1104
|
/**
|
|
1106
1105
|
* Фабрика для создания узлов формы
|
|
1107
1106
|
*/
|
|
1108
|
-
nodeFactory = new
|
|
1107
|
+
nodeFactory = new ve();
|
|
1109
1108
|
// ============================================================================
|
|
1110
1109
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1111
1110
|
// ============================================================================
|
|
@@ -1136,19 +1135,19 @@ class S extends M {
|
|
|
1136
1135
|
status;
|
|
1137
1136
|
submitting;
|
|
1138
1137
|
constructor(e) {
|
|
1139
|
-
super(), this.formSubmitter = new
|
|
1140
|
-
const t = e.form,
|
|
1138
|
+
super(), this.formSubmitter = new he(this);
|
|
1139
|
+
const t = e.form, r = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !r ? e.form : e;
|
|
1141
1140
|
for (const [l, d] of Object.entries(n)) {
|
|
1142
1141
|
const u = this.createNode(d);
|
|
1143
1142
|
this._fields.set(l, u);
|
|
1144
1143
|
}
|
|
1145
|
-
this.value =
|
|
1144
|
+
this.value = m(() => {
|
|
1146
1145
|
const l = {};
|
|
1147
1146
|
return this._fields.forEach((d, u) => {
|
|
1148
1147
|
l[u] = d.value.value;
|
|
1149
1148
|
}), l;
|
|
1150
1149
|
});
|
|
1151
|
-
const a =
|
|
1150
|
+
const a = R({
|
|
1152
1151
|
getChildren: () => Array.from(this._fields.values()),
|
|
1153
1152
|
ownErrors: this._formErrors,
|
|
1154
1153
|
disabled: this._disabled
|
|
@@ -1163,35 +1162,35 @@ class S extends M {
|
|
|
1163
1162
|
* @see buildFormProxy
|
|
1164
1163
|
*/
|
|
1165
1164
|
buildProxy() {
|
|
1166
|
-
return
|
|
1165
|
+
return ce(this, this._fields);
|
|
1167
1166
|
}
|
|
1168
1167
|
// ============================================================================
|
|
1169
1168
|
// Реализация абстрактных методов FormNode
|
|
1170
1169
|
// ============================================================================
|
|
1171
1170
|
getValue() {
|
|
1172
1171
|
const e = {};
|
|
1173
|
-
return this._fields.forEach((t,
|
|
1174
|
-
e[
|
|
1172
|
+
return this._fields.forEach((t, r) => {
|
|
1173
|
+
e[r] = t.getValue();
|
|
1175
1174
|
}), e;
|
|
1176
1175
|
}
|
|
1177
1176
|
setValue(e, t) {
|
|
1178
|
-
for (const [
|
|
1179
|
-
const n = this._fields.get(
|
|
1177
|
+
for (const [r, i] of Object.entries(e)) {
|
|
1178
|
+
const n = this._fields.get(r);
|
|
1180
1179
|
if (n) {
|
|
1181
1180
|
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1182
|
-
if (
|
|
1183
|
-
n.setValue(
|
|
1181
|
+
if (G(a)) continue;
|
|
1182
|
+
n.setValue(i, t);
|
|
1184
1183
|
}
|
|
1185
1184
|
}
|
|
1186
1185
|
}
|
|
1187
1186
|
patchValue(e) {
|
|
1188
|
-
|
|
1189
|
-
for (const [t,
|
|
1190
|
-
const
|
|
1191
|
-
if (
|
|
1192
|
-
const n = this._fieldSignals.get(
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1187
|
+
te(() => {
|
|
1188
|
+
for (const [t, r] of Object.entries(e)) {
|
|
1189
|
+
const i = this._fields.get(t);
|
|
1190
|
+
if (i && r !== void 0) {
|
|
1191
|
+
const n = this._fieldSignals.get(i) ?? i.value;
|
|
1192
|
+
if (G(n)) continue;
|
|
1193
|
+
i.setValue(r, { emitEvent: !1 });
|
|
1195
1194
|
}
|
|
1196
1195
|
}
|
|
1197
1196
|
});
|
|
@@ -1214,9 +1213,9 @@ class S extends M {
|
|
|
1214
1213
|
* ```
|
|
1215
1214
|
*/
|
|
1216
1215
|
reset(e) {
|
|
1217
|
-
this._formErrors.value = [], this._fields.forEach((t,
|
|
1218
|
-
const
|
|
1219
|
-
t.reset(
|
|
1216
|
+
this._formErrors.value = [], this._fields.forEach((t, r) => {
|
|
1217
|
+
const i = e?.[r];
|
|
1218
|
+
t.reset(i);
|
|
1220
1219
|
});
|
|
1221
1220
|
}
|
|
1222
1221
|
/**
|
|
@@ -1360,21 +1359,21 @@ class S extends M {
|
|
|
1360
1359
|
getFieldByPath(e) {
|
|
1361
1360
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1362
1361
|
return;
|
|
1363
|
-
const t =
|
|
1362
|
+
const t = fe(e);
|
|
1364
1363
|
if (t.length === 0)
|
|
1365
1364
|
return;
|
|
1366
|
-
let
|
|
1367
|
-
for (const
|
|
1368
|
-
if (!(
|
|
1369
|
-
if (
|
|
1370
|
-
if ("at" in
|
|
1371
|
-
const n =
|
|
1365
|
+
let r = this;
|
|
1366
|
+
for (const i of t) {
|
|
1367
|
+
if (!(r instanceof A) || (r = r.getField(i.key), !r)) return;
|
|
1368
|
+
if (i.index !== void 0)
|
|
1369
|
+
if ("at" in r && "length" in r && typeof r.at == "function") {
|
|
1370
|
+
const n = r.at(i.index);
|
|
1372
1371
|
if (!n) return;
|
|
1373
|
-
|
|
1372
|
+
r = n;
|
|
1374
1373
|
} else
|
|
1375
1374
|
return;
|
|
1376
1375
|
}
|
|
1377
|
-
return
|
|
1376
|
+
return r;
|
|
1378
1377
|
}
|
|
1379
1378
|
// ============================================================================
|
|
1380
1379
|
// Private методы для создания узлов
|
|
@@ -1403,16 +1402,16 @@ class S extends M {
|
|
|
1403
1402
|
/**
|
|
1404
1403
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1405
1404
|
*/
|
|
1406
|
-
linkFields(e, t,
|
|
1407
|
-
const
|
|
1408
|
-
if (!
|
|
1409
|
-
const d =
|
|
1405
|
+
linkFields(e, t, r) {
|
|
1406
|
+
const i = this._fields.get(e), n = this._fields.get(t);
|
|
1407
|
+
if (!i || !n) {
|
|
1408
|
+
const d = i ? t : e;
|
|
1410
1409
|
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1411
1410
|
}
|
|
1412
1411
|
const a = _(() => {
|
|
1413
|
-
const d =
|
|
1412
|
+
const d = i.value.value, u = r ? r(d) : d;
|
|
1414
1413
|
n.setValue(u, { emitEvent: !1 });
|
|
1415
|
-
}), l =
|
|
1414
|
+
}), l = F(O.LinkFields);
|
|
1416
1415
|
return this.disposers.add(l, a);
|
|
1417
1416
|
}
|
|
1418
1417
|
/**
|
|
@@ -1444,26 +1443,26 @@ class S extends M {
|
|
|
1444
1443
|
*/
|
|
1445
1444
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1446
1445
|
watchField(e, t) {
|
|
1447
|
-
const
|
|
1448
|
-
if (!
|
|
1446
|
+
const r = this.getFieldByPath(e);
|
|
1447
|
+
if (!r)
|
|
1449
1448
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1450
|
-
const
|
|
1451
|
-
t(
|
|
1452
|
-
}), n =
|
|
1453
|
-
return this.disposers.add(n,
|
|
1449
|
+
const i = _(() => {
|
|
1450
|
+
t(r.value.value);
|
|
1451
|
+
}), n = F(O.WatchField);
|
|
1452
|
+
return this.disposers.add(n, i);
|
|
1454
1453
|
}
|
|
1455
1454
|
/**
|
|
1456
1455
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
1457
1456
|
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1458
1457
|
*/
|
|
1459
1458
|
watchFieldByPath(e, t) {
|
|
1460
|
-
const
|
|
1461
|
-
if (!
|
|
1459
|
+
const r = this.getFieldByPath(e);
|
|
1460
|
+
if (!r)
|
|
1462
1461
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1463
|
-
const
|
|
1464
|
-
t(
|
|
1465
|
-
}), n =
|
|
1466
|
-
return this.disposers.add(n,
|
|
1462
|
+
const i = _(() => {
|
|
1463
|
+
t(r.value.value);
|
|
1464
|
+
}), n = F(O.WatchField);
|
|
1465
|
+
return this.disposers.add(n, i);
|
|
1467
1466
|
}
|
|
1468
1467
|
/**
|
|
1469
1468
|
* Hook: вызывается после disable()
|
|
@@ -1502,7 +1501,7 @@ class S extends M {
|
|
|
1502
1501
|
});
|
|
1503
1502
|
}
|
|
1504
1503
|
}
|
|
1505
|
-
class
|
|
1504
|
+
class W extends M {
|
|
1506
1505
|
// ============================================================================
|
|
1507
1506
|
// Приватные поля
|
|
1508
1507
|
// ============================================================================
|
|
@@ -1513,7 +1512,7 @@ class B extends M {
|
|
|
1513
1512
|
* Менеджер подписок для централизованного cleanup
|
|
1514
1513
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1515
1514
|
*/
|
|
1516
|
-
disposers = new
|
|
1515
|
+
disposers = new L();
|
|
1517
1516
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1518
1517
|
_arrayErrors = g([]);
|
|
1519
1518
|
// ============================================================================
|
|
@@ -1533,14 +1532,14 @@ class B extends M {
|
|
|
1533
1532
|
// ============================================================================
|
|
1534
1533
|
constructor(e, t = []) {
|
|
1535
1534
|
super(), this.itemSchema = e, this.initialItems = t, this.items = g([]);
|
|
1536
|
-
for (const
|
|
1537
|
-
this.push(
|
|
1538
|
-
this.length =
|
|
1539
|
-
const
|
|
1535
|
+
for (const i of t)
|
|
1536
|
+
this.push(i);
|
|
1537
|
+
this.length = m(() => this.items.value.length), this.value = m(() => this.items.value.map((i) => i.value.value));
|
|
1538
|
+
const r = R({
|
|
1540
1539
|
getChildren: () => this.items.value,
|
|
1541
1540
|
ownErrors: this._arrayErrors
|
|
1542
1541
|
});
|
|
1543
|
-
this.valid =
|
|
1542
|
+
this.valid = r.valid, this.invalid = r.invalid, this.pending = r.pending, this.touched = r.touched, this.dirty = r.dirty, this.errors = r.errors, this.status = r.status;
|
|
1544
1543
|
}
|
|
1545
1544
|
// ============================================================================
|
|
1546
1545
|
// CRUD операции
|
|
@@ -1567,12 +1566,12 @@ class B extends M {
|
|
|
1567
1566
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1568
1567
|
),
|
|
1569
1568
|
"ArrayNode.removeAt",
|
|
1570
|
-
|
|
1569
|
+
S.LOG
|
|
1571
1570
|
);
|
|
1572
1571
|
return;
|
|
1573
1572
|
}
|
|
1574
1573
|
const t = this.items.value[e];
|
|
1575
|
-
this.items.value = this.items.value.filter((
|
|
1574
|
+
this.items.value = this.items.value.filter((r, i) => i !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1576
1575
|
}
|
|
1577
1576
|
/**
|
|
1578
1577
|
* Вставить элемент в массив
|
|
@@ -1586,12 +1585,12 @@ class B extends M {
|
|
|
1586
1585
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1587
1586
|
),
|
|
1588
1587
|
"ArrayNode.insert",
|
|
1589
|
-
|
|
1588
|
+
S.LOG
|
|
1590
1589
|
);
|
|
1591
1590
|
return;
|
|
1592
1591
|
}
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1592
|
+
const r = this.createItem(t), i = [...this.items.value];
|
|
1593
|
+
i.splice(e, 0, r), this.items.value = i;
|
|
1595
1594
|
}
|
|
1596
1595
|
/**
|
|
1597
1596
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1610,18 +1609,18 @@ class B extends M {
|
|
|
1610
1609
|
* ```
|
|
1611
1610
|
*/
|
|
1612
1611
|
move(e, t) {
|
|
1613
|
-
const
|
|
1614
|
-
if (e < 0 || e >=
|
|
1612
|
+
const r = this.items.value.length;
|
|
1613
|
+
if (e < 0 || e >= r || t < 0 || t >= r) {
|
|
1615
1614
|
k.handle(
|
|
1616
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${
|
|
1615
|
+
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${r})`),
|
|
1617
1616
|
"ArrayNode.move",
|
|
1618
|
-
|
|
1617
|
+
S.LOG
|
|
1619
1618
|
);
|
|
1620
1619
|
return;
|
|
1621
1620
|
}
|
|
1622
1621
|
if (e === t) return;
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1622
|
+
const i = [...this.items.value], [n] = i.splice(e, 1);
|
|
1623
|
+
i.splice(t, 0, n), this.items.value = i;
|
|
1625
1624
|
}
|
|
1626
1625
|
/**
|
|
1627
1626
|
* Поменять местами два элемента массива
|
|
@@ -1638,18 +1637,18 @@ class B extends M {
|
|
|
1638
1637
|
* ```
|
|
1639
1638
|
*/
|
|
1640
1639
|
swap(e, t) {
|
|
1641
|
-
const
|
|
1642
|
-
if (e < 0 || e >=
|
|
1640
|
+
const r = this.items.value.length;
|
|
1641
|
+
if (e < 0 || e >= r || t < 0 || t >= r) {
|
|
1643
1642
|
k.handle(
|
|
1644
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${
|
|
1643
|
+
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${r})`),
|
|
1645
1644
|
"ArrayNode.swap",
|
|
1646
|
-
|
|
1645
|
+
S.LOG
|
|
1647
1646
|
);
|
|
1648
1647
|
return;
|
|
1649
1648
|
}
|
|
1650
1649
|
if (e === t) return;
|
|
1651
|
-
const
|
|
1652
|
-
[
|
|
1650
|
+
const i = [...this.items.value];
|
|
1651
|
+
[i[e], i[t]] = [i[t], i[e]], this.items.value = i;
|
|
1653
1652
|
}
|
|
1654
1653
|
/**
|
|
1655
1654
|
* Удалить все элементы массива
|
|
@@ -1680,13 +1679,13 @@ class B extends M {
|
|
|
1680
1679
|
return this.items.value.map((e) => e.getValue());
|
|
1681
1680
|
}
|
|
1682
1681
|
setValue(e, t) {
|
|
1683
|
-
this.clear(), e.forEach((
|
|
1684
|
-
k.handle(
|
|
1682
|
+
this.clear(), e.forEach((r) => this.push(r)), t?.emitEvent !== !1 && this.validate().catch((r) => {
|
|
1683
|
+
k.handle(r, "ArrayNode.setValue", S.LOG);
|
|
1685
1684
|
});
|
|
1686
1685
|
}
|
|
1687
1686
|
patchValue(e) {
|
|
1688
|
-
e.forEach((t,
|
|
1689
|
-
this.items.value[
|
|
1687
|
+
e.forEach((t, r) => {
|
|
1688
|
+
this.items.value[r] && t !== void 0 && this.items.value[r].patchValue(t);
|
|
1690
1689
|
});
|
|
1691
1690
|
}
|
|
1692
1691
|
/**
|
|
@@ -1814,9 +1813,9 @@ class B extends M {
|
|
|
1814
1813
|
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
1815
1814
|
*/
|
|
1816
1815
|
forEach(e) {
|
|
1817
|
-
this.items.value.forEach((t,
|
|
1818
|
-
const
|
|
1819
|
-
e(
|
|
1816
|
+
this.items.value.forEach((t, r) => {
|
|
1817
|
+
const i = t.getProxy();
|
|
1818
|
+
e(i, r);
|
|
1820
1819
|
});
|
|
1821
1820
|
}
|
|
1822
1821
|
/**
|
|
@@ -1825,9 +1824,9 @@ class B extends M {
|
|
|
1825
1824
|
* @returns Новый массив результатов
|
|
1826
1825
|
*/
|
|
1827
1826
|
map(e) {
|
|
1828
|
-
return this.items.value.map((t,
|
|
1829
|
-
const
|
|
1830
|
-
return e(
|
|
1827
|
+
return this.items.value.map((t, r) => {
|
|
1828
|
+
const i = t.getProxy();
|
|
1829
|
+
return e(i, r);
|
|
1831
1830
|
});
|
|
1832
1831
|
}
|
|
1833
1832
|
// ============================================================================
|
|
@@ -1839,7 +1838,7 @@ class B extends M {
|
|
|
1839
1838
|
*/
|
|
1840
1839
|
createItem(e) {
|
|
1841
1840
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
1842
|
-
const t = new
|
|
1841
|
+
const t = new A(this.itemSchema);
|
|
1843
1842
|
return e && t.patchValue(e), t;
|
|
1844
1843
|
}
|
|
1845
1844
|
throw new Error(
|
|
@@ -1917,7 +1916,7 @@ class B extends M {
|
|
|
1917
1916
|
});
|
|
1918
1917
|
}
|
|
1919
1918
|
}
|
|
1920
|
-
class
|
|
1919
|
+
class ve {
|
|
1921
1920
|
/**
|
|
1922
1921
|
* Создает узел формы на основе конфигурации
|
|
1923
1922
|
*
|
|
@@ -1967,14 +1966,14 @@ class ue {
|
|
|
1967
1966
|
if (Array.isArray(e) && e.length >= 1)
|
|
1968
1967
|
return this.createArrayNodeFromArray(e);
|
|
1969
1968
|
if (this.isFieldConfig(e))
|
|
1970
|
-
return new
|
|
1969
|
+
return new de(e);
|
|
1971
1970
|
if (this.isArrayConfig(e))
|
|
1972
|
-
return new
|
|
1971
|
+
return new W(
|
|
1973
1972
|
e.schema,
|
|
1974
1973
|
e.initialItems
|
|
1975
1974
|
);
|
|
1976
1975
|
if (this.isGroupConfig(e))
|
|
1977
|
-
return new
|
|
1976
|
+
return new A(e);
|
|
1978
1977
|
throw new Error(
|
|
1979
1978
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
1980
1979
|
e
|
|
@@ -2008,11 +2007,11 @@ class ue {
|
|
|
2008
2007
|
*/
|
|
2009
2008
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2010
2009
|
createArrayNodeFromArray(e) {
|
|
2011
|
-
const [t, ...
|
|
2012
|
-
this.isGroupConfig(t) &&
|
|
2013
|
-
for (const n of
|
|
2014
|
-
this.isGroupConfig(n) ?
|
|
2015
|
-
return new
|
|
2010
|
+
const [t, ...r] = e, i = [];
|
|
2011
|
+
this.isGroupConfig(t) && i.push(this.extractValues(t));
|
|
2012
|
+
for (const n of r)
|
|
2013
|
+
this.isGroupConfig(n) ? i.push(this.extractValues(n)) : i.push(n);
|
|
2014
|
+
return new W(t, i);
|
|
2016
2015
|
}
|
|
2017
2016
|
/**
|
|
2018
2017
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2050,8 +2049,8 @@ class ue {
|
|
|
2050
2049
|
return e.map((t) => this.extractValues(t));
|
|
2051
2050
|
if (this.isGroupConfig(e)) {
|
|
2052
2051
|
const t = {};
|
|
2053
|
-
for (const [
|
|
2054
|
-
t[
|
|
2052
|
+
for (const [r, i] of Object.entries(e))
|
|
2053
|
+
t[r] = this.extractValues(i);
|
|
2055
2054
|
return t;
|
|
2056
2055
|
}
|
|
2057
2056
|
return e;
|
|
@@ -2131,7 +2130,7 @@ class ue {
|
|
|
2131
2130
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2132
2131
|
}
|
|
2133
2132
|
}
|
|
2134
|
-
class
|
|
2133
|
+
class me extends M {
|
|
2135
2134
|
/**
|
|
2136
2135
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2137
2136
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
@@ -2139,26 +2138,26 @@ class de extends M {
|
|
|
2139
2138
|
*/
|
|
2140
2139
|
constructor(e, t) {
|
|
2141
2140
|
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = _(() => {
|
|
2142
|
-
const
|
|
2143
|
-
for (let u = 0; u <
|
|
2144
|
-
const
|
|
2145
|
-
if (!
|
|
2146
|
-
let o = this.cache.get(
|
|
2147
|
-
o || (o = t(
|
|
2141
|
+
const i = e.length, n = [], a = [];
|
|
2142
|
+
for (let u = 0; u < i; u++) {
|
|
2143
|
+
const h = e.at(u);
|
|
2144
|
+
if (!h) continue;
|
|
2145
|
+
let o = this.cache.get(h);
|
|
2146
|
+
o || (o = t(h), this.cache.set(h, o)), n.push(h), a.push(o);
|
|
2148
2147
|
}
|
|
2149
2148
|
const l = new Set(n), d = [];
|
|
2150
2149
|
for (const u of this.mountedModels) {
|
|
2151
2150
|
if (l.has(u)) continue;
|
|
2152
|
-
const
|
|
2153
|
-
this.cache.delete(u),
|
|
2151
|
+
const h = this.cache.get(u);
|
|
2152
|
+
this.cache.delete(u), h && d.push(h);
|
|
2154
2153
|
}
|
|
2155
2154
|
this.mountedModels = n, this.itemNodes.value = a, d.forEach((u) => this.disposeItemNode(u));
|
|
2156
|
-
}), this.length =
|
|
2157
|
-
const
|
|
2155
|
+
}), this.length = m(() => this.itemNodes.value.length), this.value = m(() => this.itemNodes.value.map((i) => i.value.value));
|
|
2156
|
+
const r = R({
|
|
2158
2157
|
getChildren: () => this.itemNodes.value,
|
|
2159
2158
|
ownErrors: this._arrayErrors
|
|
2160
2159
|
});
|
|
2161
|
-
this.valid =
|
|
2160
|
+
this.valid = r.valid, this.invalid = r.invalid, this.pending = r.pending, this.touched = r.touched, this.dirty = r.dirty, this.errors = r.errors, this.status = r.status;
|
|
2162
2161
|
}
|
|
2163
2162
|
itemNodes = g([]);
|
|
2164
2163
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
@@ -2190,10 +2189,10 @@ class de extends M {
|
|
|
2190
2189
|
return this.itemNodes.value[e];
|
|
2191
2190
|
}
|
|
2192
2191
|
map(e) {
|
|
2193
|
-
return this.itemNodes.value.map((t,
|
|
2192
|
+
return this.itemNodes.value.map((t, r) => e(t, r));
|
|
2194
2193
|
}
|
|
2195
2194
|
forEach(e) {
|
|
2196
|
-
this.itemNodes.value.forEach((t,
|
|
2195
|
+
this.itemNodes.value.forEach((t, r) => e(t, r));
|
|
2197
2196
|
}
|
|
2198
2197
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2199
2198
|
push(e) {
|
|
@@ -2293,170 +2292,221 @@ class de extends M {
|
|
|
2293
2292
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2294
2293
|
}
|
|
2295
2294
|
}
|
|
2296
|
-
const
|
|
2297
|
-
function
|
|
2298
|
-
if (
|
|
2299
|
-
if (
|
|
2300
|
-
|
|
2295
|
+
const J = (s) => s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(typeof Blob < "u" && s instanceof Blob) && !(typeof File < "u" && s instanceof File);
|
|
2296
|
+
function I(s, e, t) {
|
|
2297
|
+
if (s == null || typeof s != "object" || s instanceof j) return;
|
|
2298
|
+
if (typeof s.getProxy == "function") {
|
|
2299
|
+
process.env.NODE_ENV !== "production" && console.warn(
|
|
2300
|
+
"[reformer] createForm({ schema }): в схему попал узел формы (FormProxy) — он пропущен. Стройте дерево для createForm БЕЗ формы, а форму донесите до узла вторым проходом (билдер `(model, form?) => …`) либо через render-behavior `patchProps({ form })`."
|
|
2301
|
+
);
|
|
2301
2302
|
return;
|
|
2302
2303
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
t.set(r.__path, s.item);
|
|
2304
|
+
if (Array.isArray(s)) {
|
|
2305
|
+
for (const n of s) I(n, e, t);
|
|
2306
2306
|
return;
|
|
2307
2307
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2308
|
+
const r = s, i = r.array;
|
|
2309
|
+
if (i && typeof i.__path == "string" && typeof r.item == "function") {
|
|
2310
|
+
t.set(i.__path, r.item);
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
r.value instanceof j ? e.set(r.value, {
|
|
2314
|
+
component: r.component,
|
|
2315
|
+
componentProps: r.componentProps,
|
|
2316
|
+
updateOn: r.updateOn,
|
|
2317
|
+
disabled: r.disabled,
|
|
2318
|
+
debounce: r.debounce
|
|
2319
|
+
}) : process.env.NODE_ENV !== "production" && r.component !== void 0 && ("valueSignal" in r || r.value != null) && console.warn(
|
|
2315
2320
|
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2316
2321
|
);
|
|
2317
|
-
for (const [n, a] of Object.entries(
|
|
2318
|
-
n !== "value" &&
|
|
2322
|
+
for (const [n, a] of Object.entries(r))
|
|
2323
|
+
n !== "value" && I(a, e, t);
|
|
2319
2324
|
}
|
|
2320
|
-
function
|
|
2321
|
-
const
|
|
2325
|
+
function Q(s, e, t, r) {
|
|
2326
|
+
const i = {};
|
|
2322
2327
|
for (const [n, a] of Object.entries(e)) {
|
|
2323
2328
|
const l = t === "" ? n : `${t}.${n}`;
|
|
2324
2329
|
if (Array.isArray(a))
|
|
2325
2330
|
continue;
|
|
2326
|
-
if (
|
|
2327
|
-
|
|
2331
|
+
if (J(a)) {
|
|
2332
|
+
i[n] = Q(s, a, l, r);
|
|
2328
2333
|
continue;
|
|
2329
2334
|
}
|
|
2330
|
-
const d =
|
|
2335
|
+
const d = s.signalAt(l);
|
|
2331
2336
|
if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2332
|
-
const u =
|
|
2333
|
-
|
|
2337
|
+
const u = r.get(d) ?? {};
|
|
2338
|
+
i[n] = { ...u, valueSignal: d };
|
|
2334
2339
|
}
|
|
2335
|
-
return
|
|
2340
|
+
return i;
|
|
2336
2341
|
}
|
|
2337
|
-
function
|
|
2338
|
-
for (const [
|
|
2339
|
-
const n = e === "" ?
|
|
2340
|
-
Array.isArray(
|
|
2342
|
+
function X(s, e, t) {
|
|
2343
|
+
for (const [r, i] of Object.entries(s)) {
|
|
2344
|
+
const n = e === "" ? r : `${e}.${r}`;
|
|
2345
|
+
Array.isArray(i) || (J(i) ? X(i, n, t) : t.push(n));
|
|
2341
2346
|
}
|
|
2342
2347
|
}
|
|
2343
|
-
function
|
|
2344
|
-
const { model: e, schema: t, behavior:
|
|
2345
|
-
t !== void 0 &&
|
|
2346
|
-
const a =
|
|
2347
|
-
for (const [o,
|
|
2348
|
-
if (!Array.isArray(
|
|
2348
|
+
function Z(s) {
|
|
2349
|
+
const { model: e, schema: t, behavior: r } = s, i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2350
|
+
t !== void 0 && I(t, i, n);
|
|
2351
|
+
const a = Q(e, e.get(), "", i), l = new A(a), d = e.get();
|
|
2352
|
+
for (const [o, f] of Object.entries(d)) {
|
|
2353
|
+
if (!Array.isArray(f)) continue;
|
|
2349
2354
|
const c = n.get(o);
|
|
2350
2355
|
if (!c) continue;
|
|
2351
|
-
const
|
|
2352
|
-
l.fields.set(o,
|
|
2353
|
-
}
|
|
2354
|
-
const u = l.getProxy(),
|
|
2355
|
-
|
|
2356
|
-
for (const o of
|
|
2357
|
-
const
|
|
2358
|
-
if (
|
|
2359
|
-
|
|
2360
|
-
const
|
|
2361
|
-
p instanceof
|
|
2356
|
+
const v = e[o], p = (y) => Z({ model: y, schema: c(y) }), b = new me(v, p);
|
|
2357
|
+
l.fields.set(o, b);
|
|
2358
|
+
}
|
|
2359
|
+
const u = l.getProxy(), h = [];
|
|
2360
|
+
X(e.get(), "", h);
|
|
2361
|
+
for (const o of h) {
|
|
2362
|
+
const f = e.signalAt(o), c = l.getFieldByPath(o);
|
|
2363
|
+
if (f && c) {
|
|
2364
|
+
se(f, c);
|
|
2365
|
+
const v = o.lastIndexOf("."), p = v === -1 ? l : l.getFieldByPath(o.slice(0, v));
|
|
2366
|
+
p instanceof A && p.registerFieldSignal(c, f);
|
|
2362
2367
|
}
|
|
2363
2368
|
}
|
|
2364
|
-
return
|
|
2369
|
+
return r && l.attachBehaviorCleanup(r.__run(e, u)), u;
|
|
2370
|
+
}
|
|
2371
|
+
const pe = (s) => s != null && typeof s == "object" && "model" in s && typeof s.model?.signalAt == "function";
|
|
2372
|
+
function ye(s) {
|
|
2373
|
+
return pe(s) ? Z(s) : new A(s).getProxy();
|
|
2374
|
+
}
|
|
2375
|
+
const ge = () => {
|
|
2376
|
+
};
|
|
2377
|
+
function be(s, e) {
|
|
2378
|
+
if (!e) return;
|
|
2379
|
+
const t = typeof e == "function" ? { schema: e } : e, r = Object.keys(t.steps ?? {}), i = r.map((o) => t.steps?.[o]).filter((o) => o != null), n = t.schema ?? re(
|
|
2380
|
+
() => ne(...i, ...t.extras ? [t.extras] : [])
|
|
2381
|
+
), a = (o) => {
|
|
2382
|
+
const f = typeof o == "number" ? r[o - 1] : o;
|
|
2383
|
+
return (f != null ? t.steps?.[f] : null) ?? null;
|
|
2384
|
+
}, { strategy: l, debounce: d, liveAfterSubmit: u } = t, h = D(s, n, {
|
|
2385
|
+
strategy: l,
|
|
2386
|
+
debounce: d,
|
|
2387
|
+
liveAfterSubmit: u
|
|
2388
|
+
});
|
|
2389
|
+
return {
|
|
2390
|
+
schema: n,
|
|
2391
|
+
stepSelectors: r,
|
|
2392
|
+
validate: () => h.validate(),
|
|
2393
|
+
validateAll: () => h.validate(),
|
|
2394
|
+
validateStep: (o) => ie(s, a(o) ?? ge, { touch: !0 }),
|
|
2395
|
+
createStepController: (o) => {
|
|
2396
|
+
if (!l || l === "submit") return null;
|
|
2397
|
+
const f = a(o);
|
|
2398
|
+
return f ? D(s, f, { strategy: l, debounce: d, liveAfterSubmit: u }) : null;
|
|
2399
|
+
},
|
|
2400
|
+
controller: h,
|
|
2401
|
+
validating: h.validating
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
function Ie(s) {
|
|
2405
|
+
if (!s.model && s.initial === void 0)
|
|
2406
|
+
throw new Error("createCoreForm: provide either `initial` (to create a model) or `model`.");
|
|
2407
|
+
const e = s.model ?? ee(s.initial);
|
|
2408
|
+
s.seed?.(e);
|
|
2409
|
+
const t = ye({
|
|
2410
|
+
model: e,
|
|
2411
|
+
...s.schema ? { schema: s.schema(e) } : {},
|
|
2412
|
+
...s.behavior ? { behavior: s.behavior } : {}
|
|
2413
|
+
}), r = be(e, s.validation), i = { model: e, form: t, ...r ? { validation: r } : {} };
|
|
2414
|
+
return s.setup?.(i), i;
|
|
2365
2415
|
}
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
return
|
|
2416
|
+
function Le(s) {
|
|
2417
|
+
const [e] = ae(s), t = e.validation?.controller;
|
|
2418
|
+
return z(() => t?.start(), [t]), e;
|
|
2369
2419
|
}
|
|
2370
|
-
function x(
|
|
2371
|
-
return
|
|
2420
|
+
function x(s) {
|
|
2421
|
+
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2372
2422
|
}
|
|
2373
|
-
function
|
|
2374
|
-
return x(
|
|
2423
|
+
function Ee(s) {
|
|
2424
|
+
return x(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
|
|
2375
2425
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2376
|
-
typeof
|
|
2377
|
-
!("fields" in
|
|
2426
|
+
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2427
|
+
!("fields" in s) && !("items" in s);
|
|
2378
2428
|
}
|
|
2379
|
-
function
|
|
2380
|
-
return x(
|
|
2381
|
-
!("items" in
|
|
2429
|
+
function _e(s) {
|
|
2430
|
+
return x(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2431
|
+
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2382
2432
|
}
|
|
2383
|
-
function
|
|
2384
|
-
return x(
|
|
2385
|
-
typeof
|
|
2386
|
-
typeof
|
|
2433
|
+
function Se(s) {
|
|
2434
|
+
return x(s) && "items" in s && "length" in s && "push" in s && "removeAt" in s && "at" in s && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2435
|
+
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2436
|
+
typeof s.removeAt == "function";
|
|
2387
2437
|
}
|
|
2388
|
-
function
|
|
2389
|
-
return
|
|
2438
|
+
function Re(s) {
|
|
2439
|
+
return Ee(s) ? "FieldNode" : _e(s) ? "GroupNode" : Se(s) ? "ArrayNode" : x(s) ? "FormNode" : "Unknown";
|
|
2390
2440
|
}
|
|
2391
|
-
var
|
|
2392
|
-
var
|
|
2393
|
-
function
|
|
2394
|
-
if (
|
|
2395
|
-
|
|
2396
|
-
var
|
|
2397
|
-
function e(o,
|
|
2398
|
-
return o ===
|
|
2399
|
-
}
|
|
2400
|
-
var t = typeof Object.is == "function" ? Object.is : e,
|
|
2401
|
-
function l(o,
|
|
2402
|
-
var c =
|
|
2441
|
+
var N = { exports: {} }, P = {};
|
|
2442
|
+
var q;
|
|
2443
|
+
function Ae() {
|
|
2444
|
+
if (q) return P;
|
|
2445
|
+
q = 1;
|
|
2446
|
+
var s = Y;
|
|
2447
|
+
function e(o, f) {
|
|
2448
|
+
return o === f && (o !== 0 || 1 / o === 1 / f) || o !== o && f !== f;
|
|
2449
|
+
}
|
|
2450
|
+
var t = typeof Object.is == "function" ? Object.is : e, r = s.useState, i = s.useEffect, n = s.useLayoutEffect, a = s.useDebugValue;
|
|
2451
|
+
function l(o, f) {
|
|
2452
|
+
var c = f(), v = r({ inst: { value: c, getSnapshot: f } }), p = v[0].inst, b = v[1];
|
|
2403
2453
|
return n(
|
|
2404
2454
|
function() {
|
|
2405
|
-
p.value = c, p.getSnapshot =
|
|
2455
|
+
p.value = c, p.getSnapshot = f, d(p) && b({ inst: p });
|
|
2406
2456
|
},
|
|
2407
|
-
[o, c,
|
|
2408
|
-
),
|
|
2457
|
+
[o, c, f]
|
|
2458
|
+
), i(
|
|
2409
2459
|
function() {
|
|
2410
|
-
return d(p) &&
|
|
2411
|
-
d(p) &&
|
|
2460
|
+
return d(p) && b({ inst: p }), o(function() {
|
|
2461
|
+
d(p) && b({ inst: p });
|
|
2412
2462
|
});
|
|
2413
2463
|
},
|
|
2414
2464
|
[o]
|
|
2415
2465
|
), a(c), c;
|
|
2416
2466
|
}
|
|
2417
2467
|
function d(o) {
|
|
2418
|
-
var
|
|
2468
|
+
var f = o.getSnapshot;
|
|
2419
2469
|
o = o.value;
|
|
2420
2470
|
try {
|
|
2421
|
-
var c =
|
|
2471
|
+
var c = f();
|
|
2422
2472
|
return !t(o, c);
|
|
2423
2473
|
} catch {
|
|
2424
2474
|
return !0;
|
|
2425
2475
|
}
|
|
2426
2476
|
}
|
|
2427
|
-
function u(o,
|
|
2428
|
-
return
|
|
2477
|
+
function u(o, f) {
|
|
2478
|
+
return f();
|
|
2429
2479
|
}
|
|
2430
|
-
var
|
|
2431
|
-
return P.useSyncExternalStore =
|
|
2480
|
+
var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2481
|
+
return P.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : h, P;
|
|
2432
2482
|
}
|
|
2433
2483
|
var T = {};
|
|
2434
|
-
var
|
|
2435
|
-
function
|
|
2436
|
-
return
|
|
2437
|
-
function
|
|
2438
|
-
return c ===
|
|
2484
|
+
var K;
|
|
2485
|
+
function we() {
|
|
2486
|
+
return K || (K = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2487
|
+
function s(c, v) {
|
|
2488
|
+
return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
|
|
2439
2489
|
}
|
|
2440
|
-
function e(c,
|
|
2441
|
-
|
|
2490
|
+
function e(c, v) {
|
|
2491
|
+
h || i.startTransition === void 0 || (h = !0, console.error(
|
|
2442
2492
|
"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."
|
|
2443
2493
|
));
|
|
2444
|
-
var p =
|
|
2494
|
+
var p = v();
|
|
2445
2495
|
if (!o) {
|
|
2446
|
-
var
|
|
2447
|
-
n(p,
|
|
2496
|
+
var b = v();
|
|
2497
|
+
n(p, b) || (console.error(
|
|
2448
2498
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2449
2499
|
), o = !0);
|
|
2450
2500
|
}
|
|
2451
|
-
|
|
2452
|
-
inst: { value: p, getSnapshot:
|
|
2501
|
+
b = a({
|
|
2502
|
+
inst: { value: p, getSnapshot: v }
|
|
2453
2503
|
});
|
|
2454
|
-
var y =
|
|
2504
|
+
var y = b[0].inst, w = b[1];
|
|
2455
2505
|
return d(
|
|
2456
2506
|
function() {
|
|
2457
|
-
y.value = p, y.getSnapshot =
|
|
2507
|
+
y.value = p, y.getSnapshot = v, t(y) && w({ inst: y });
|
|
2458
2508
|
},
|
|
2459
|
-
[c, p,
|
|
2509
|
+
[c, p, v]
|
|
2460
2510
|
), l(
|
|
2461
2511
|
function() {
|
|
2462
2512
|
return t(y) && w({ inst: y }), c(function() {
|
|
@@ -2467,71 +2517,71 @@ function pe() {
|
|
|
2467
2517
|
), u(p), p;
|
|
2468
2518
|
}
|
|
2469
2519
|
function t(c) {
|
|
2470
|
-
var
|
|
2520
|
+
var v = c.getSnapshot;
|
|
2471
2521
|
c = c.value;
|
|
2472
2522
|
try {
|
|
2473
|
-
var p =
|
|
2523
|
+
var p = v();
|
|
2474
2524
|
return !n(c, p);
|
|
2475
2525
|
} catch {
|
|
2476
2526
|
return !0;
|
|
2477
2527
|
}
|
|
2478
2528
|
}
|
|
2479
|
-
function
|
|
2480
|
-
return
|
|
2529
|
+
function r(c, v) {
|
|
2530
|
+
return v();
|
|
2481
2531
|
}
|
|
2482
2532
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2483
|
-
var
|
|
2484
|
-
T.useSyncExternalStore =
|
|
2533
|
+
var i = Y, n = typeof Object.is == "function" ? Object.is : s, a = i.useState, l = i.useEffect, d = i.useLayoutEffect, u = i.useDebugValue, h = !1, o = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
2534
|
+
T.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());
|
|
2485
2535
|
})()), T;
|
|
2486
2536
|
}
|
|
2487
|
-
var
|
|
2488
|
-
function
|
|
2489
|
-
return
|
|
2537
|
+
var H;
|
|
2538
|
+
function ke() {
|
|
2539
|
+
return H || (H = 1, process.env.NODE_ENV === "production" ? N.exports = Ae() : N.exports = we()), N.exports;
|
|
2490
2540
|
}
|
|
2491
|
-
var C =
|
|
2492
|
-
function
|
|
2493
|
-
if (
|
|
2494
|
-
if (
|
|
2495
|
-
for (let t = 0; t <
|
|
2496
|
-
if (
|
|
2541
|
+
var C = ke();
|
|
2542
|
+
function Ve(s, e) {
|
|
2543
|
+
if (s === e) return !0;
|
|
2544
|
+
if (s.length !== e.length) return !1;
|
|
2545
|
+
for (let t = 0; t < s.length; t++)
|
|
2546
|
+
if (s[t] !== e[t]) return !1;
|
|
2497
2547
|
return !0;
|
|
2498
2548
|
}
|
|
2499
|
-
function
|
|
2500
|
-
const
|
|
2501
|
-
n.current =
|
|
2549
|
+
function $(s, e, t, r) {
|
|
2550
|
+
const i = V(null), n = V(s);
|
|
2551
|
+
n.current = s;
|
|
2502
2552
|
const a = V(e);
|
|
2503
2553
|
a.current = e;
|
|
2504
2554
|
const l = V(t);
|
|
2505
|
-
if (l.current = t,
|
|
2506
|
-
const
|
|
2507
|
-
for (const o in
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
}
|
|
2511
|
-
const d =
|
|
2512
|
-
(
|
|
2555
|
+
if (l.current = t, i.current === null) {
|
|
2556
|
+
const h = {};
|
|
2557
|
+
for (const o in s)
|
|
2558
|
+
h[o] = s[o].value;
|
|
2559
|
+
i.current = { ...h, __snapshot: null };
|
|
2560
|
+
}
|
|
2561
|
+
const d = E(
|
|
2562
|
+
(h) => {
|
|
2513
2563
|
let o = !0;
|
|
2514
2564
|
return _(() => {
|
|
2515
2565
|
const c = n.current;
|
|
2516
|
-
for (const
|
|
2517
|
-
c[
|
|
2566
|
+
for (const v in c)
|
|
2567
|
+
c[v].value;
|
|
2518
2568
|
if (o) {
|
|
2519
2569
|
o = !1;
|
|
2520
2570
|
return;
|
|
2521
2571
|
}
|
|
2522
|
-
|
|
2572
|
+
h();
|
|
2523
2573
|
});
|
|
2524
2574
|
},
|
|
2525
|
-
[
|
|
2526
|
-
), u =
|
|
2527
|
-
const
|
|
2528
|
-
for (const
|
|
2529
|
-
|
|
2575
|
+
[r]
|
|
2576
|
+
), u = E(() => {
|
|
2577
|
+
const h = i.current, o = n.current, f = {};
|
|
2578
|
+
for (const v in o)
|
|
2579
|
+
f[v] = o[v].value;
|
|
2530
2580
|
let c = !1;
|
|
2531
|
-
for (const
|
|
2532
|
-
const { key: p, useShallowArrayEqual:
|
|
2533
|
-
if (
|
|
2534
|
-
if (!
|
|
2581
|
+
for (const v of a.current) {
|
|
2582
|
+
const { key: p, useShallowArrayEqual: b } = v, y = f[p], w = h[p];
|
|
2583
|
+
if (b) {
|
|
2584
|
+
if (!Ve(w, y)) {
|
|
2535
2585
|
c = !0;
|
|
2536
2586
|
break;
|
|
2537
2587
|
}
|
|
@@ -2540,26 +2590,26 @@ function R(i, e, t, s) {
|
|
|
2540
2590
|
break;
|
|
2541
2591
|
}
|
|
2542
2592
|
}
|
|
2543
|
-
if (!c &&
|
|
2544
|
-
return
|
|
2545
|
-
for (const
|
|
2546
|
-
v
|
|
2547
|
-
return
|
|
2548
|
-
}, [
|
|
2593
|
+
if (!c && h.__snapshot)
|
|
2594
|
+
return h.__snapshot;
|
|
2595
|
+
for (const v in o)
|
|
2596
|
+
h[v] = f[v];
|
|
2597
|
+
return h.__snapshot = l.current(f), h.__snapshot;
|
|
2598
|
+
}, [r]);
|
|
2549
2599
|
return C.useSyncExternalStore(d, u, u);
|
|
2550
2600
|
}
|
|
2551
|
-
function
|
|
2601
|
+
function Oe(s) {
|
|
2552
2602
|
const e = {
|
|
2553
|
-
value:
|
|
2554
|
-
disabled:
|
|
2555
|
-
errors:
|
|
2556
|
-
pending:
|
|
2557
|
-
valid:
|
|
2558
|
-
invalid:
|
|
2559
|
-
touched:
|
|
2560
|
-
dirty:
|
|
2561
|
-
shouldShowError:
|
|
2562
|
-
componentProps:
|
|
2603
|
+
value: s.value,
|
|
2604
|
+
disabled: s.disabled,
|
|
2605
|
+
errors: s.errors,
|
|
2606
|
+
pending: s.pending,
|
|
2607
|
+
valid: s.valid,
|
|
2608
|
+
invalid: s.invalid,
|
|
2609
|
+
touched: s.touched,
|
|
2610
|
+
dirty: s.dirty,
|
|
2611
|
+
shouldShowError: s.shouldShowError,
|
|
2612
|
+
componentProps: s.componentProps
|
|
2563
2613
|
}, t = [
|
|
2564
2614
|
{ key: "value" },
|
|
2565
2615
|
{ key: "disabled" },
|
|
@@ -2571,34 +2621,34 @@ function Ee(i) {
|
|
|
2571
2621
|
{ key: "dirty" },
|
|
2572
2622
|
{ key: "shouldShowError" },
|
|
2573
2623
|
{ key: "componentProps" }
|
|
2574
|
-
],
|
|
2575
|
-
(
|
|
2576
|
-
value:
|
|
2577
|
-
pending:
|
|
2578
|
-
disabled:
|
|
2579
|
-
errors:
|
|
2580
|
-
valid:
|
|
2581
|
-
invalid:
|
|
2582
|
-
touched:
|
|
2583
|
-
dirty:
|
|
2584
|
-
shouldShowError:
|
|
2585
|
-
componentProps:
|
|
2624
|
+
], r = E(
|
|
2625
|
+
(i) => ({
|
|
2626
|
+
value: i.value,
|
|
2627
|
+
pending: i.pending,
|
|
2628
|
+
disabled: i.disabled,
|
|
2629
|
+
errors: i.errors,
|
|
2630
|
+
valid: i.valid,
|
|
2631
|
+
invalid: i.invalid,
|
|
2632
|
+
touched: i.touched,
|
|
2633
|
+
dirty: i.dirty,
|
|
2634
|
+
shouldShowError: i.shouldShowError,
|
|
2635
|
+
componentProps: i.componentProps
|
|
2586
2636
|
}),
|
|
2587
2637
|
[]
|
|
2588
2638
|
);
|
|
2589
|
-
return
|
|
2639
|
+
return $(e, t, r, s);
|
|
2590
2640
|
}
|
|
2591
|
-
function
|
|
2641
|
+
function Fe(s) {
|
|
2592
2642
|
const e = {
|
|
2593
|
-
value:
|
|
2594
|
-
length:
|
|
2595
|
-
errors:
|
|
2596
|
-
pending:
|
|
2597
|
-
valid:
|
|
2598
|
-
invalid:
|
|
2599
|
-
touched:
|
|
2600
|
-
dirty:
|
|
2601
|
-
disabled:
|
|
2643
|
+
value: s.value,
|
|
2644
|
+
length: s.length,
|
|
2645
|
+
errors: s.errors,
|
|
2646
|
+
pending: s.pending,
|
|
2647
|
+
valid: s.valid,
|
|
2648
|
+
invalid: s.invalid,
|
|
2649
|
+
touched: s.touched,
|
|
2650
|
+
dirty: s.dirty,
|
|
2651
|
+
disabled: s.disabled
|
|
2602
2652
|
}, t = [
|
|
2603
2653
|
{ key: "value" },
|
|
2604
2654
|
{ key: "length" },
|
|
@@ -2609,24 +2659,24 @@ function be(i) {
|
|
|
2609
2659
|
{ key: "touched" },
|
|
2610
2660
|
{ key: "dirty" },
|
|
2611
2661
|
{ key: "disabled" }
|
|
2612
|
-
],
|
|
2613
|
-
(
|
|
2614
|
-
value:
|
|
2615
|
-
length:
|
|
2616
|
-
pending:
|
|
2617
|
-
errors:
|
|
2618
|
-
valid:
|
|
2619
|
-
invalid:
|
|
2620
|
-
touched:
|
|
2621
|
-
dirty:
|
|
2622
|
-
disabled:
|
|
2662
|
+
], r = E(
|
|
2663
|
+
(i) => ({
|
|
2664
|
+
value: i.value,
|
|
2665
|
+
length: i.length,
|
|
2666
|
+
pending: i.pending,
|
|
2667
|
+
errors: i.errors,
|
|
2668
|
+
valid: i.valid,
|
|
2669
|
+
invalid: i.invalid,
|
|
2670
|
+
touched: i.touched,
|
|
2671
|
+
dirty: i.dirty,
|
|
2672
|
+
disabled: i.disabled
|
|
2623
2673
|
}),
|
|
2624
2674
|
[]
|
|
2625
2675
|
);
|
|
2626
|
-
return
|
|
2676
|
+
return $(e, t, r, s);
|
|
2627
2677
|
}
|
|
2628
|
-
function
|
|
2629
|
-
const
|
|
2678
|
+
function Ne() {
|
|
2679
|
+
const s = E(
|
|
2630
2680
|
() => ({
|
|
2631
2681
|
value: [],
|
|
2632
2682
|
length: 0,
|
|
@@ -2640,104 +2690,108 @@ function _e() {
|
|
|
2640
2690
|
}),
|
|
2641
2691
|
[]
|
|
2642
2692
|
);
|
|
2643
|
-
return
|
|
2693
|
+
return $({}, [], s);
|
|
2644
2694
|
}
|
|
2645
|
-
function
|
|
2646
|
-
const e =
|
|
2647
|
-
return
|
|
2695
|
+
function $e(s) {
|
|
2696
|
+
const e = s && "length" in s && "map" in s;
|
|
2697
|
+
return s ? e ? Fe(s) : Oe(s) : Ne();
|
|
2648
2698
|
}
|
|
2649
|
-
function
|
|
2650
|
-
const e = V({ value:
|
|
2651
|
-
(
|
|
2699
|
+
function Ge(s) {
|
|
2700
|
+
const e = V({ value: s.value.value }), t = E(
|
|
2701
|
+
(i) => {
|
|
2652
2702
|
let n = !0;
|
|
2653
2703
|
return _(() => {
|
|
2654
|
-
if (
|
|
2704
|
+
if (s.value.value, n) {
|
|
2655
2705
|
n = !1;
|
|
2656
2706
|
return;
|
|
2657
2707
|
}
|
|
2658
|
-
|
|
2708
|
+
i();
|
|
2659
2709
|
});
|
|
2660
2710
|
},
|
|
2661
|
-
[
|
|
2662
|
-
),
|
|
2663
|
-
const
|
|
2664
|
-
return e.current.value ===
|
|
2665
|
-
}, [
|
|
2666
|
-
return C.useSyncExternalStore(t,
|
|
2711
|
+
[s]
|
|
2712
|
+
), r = E(() => {
|
|
2713
|
+
const i = s.value.value;
|
|
2714
|
+
return e.current.value === i ? e.current.value : (e.current.value = i, i);
|
|
2715
|
+
}, [s]);
|
|
2716
|
+
return C.useSyncExternalStore(t, r, r);
|
|
2667
2717
|
}
|
|
2668
|
-
function
|
|
2669
|
-
const e = V({ length:
|
|
2670
|
-
(
|
|
2718
|
+
function je(s) {
|
|
2719
|
+
const e = V({ length: s.length.value }), t = E(
|
|
2720
|
+
(i) => {
|
|
2671
2721
|
let n = !0;
|
|
2672
2722
|
return _(() => {
|
|
2673
|
-
if (
|
|
2723
|
+
if (s.length.value, n) {
|
|
2674
2724
|
n = !1;
|
|
2675
2725
|
return;
|
|
2676
2726
|
}
|
|
2677
|
-
|
|
2727
|
+
i();
|
|
2678
2728
|
});
|
|
2679
2729
|
},
|
|
2680
|
-
[
|
|
2681
|
-
),
|
|
2682
|
-
const
|
|
2683
|
-
return e.current.length ===
|
|
2684
|
-
}, [
|
|
2685
|
-
return C.useSyncExternalStore(t,
|
|
2730
|
+
[s]
|
|
2731
|
+
), r = E(() => {
|
|
2732
|
+
const i = s.length.value;
|
|
2733
|
+
return e.current.length === i ? e.current.length : (e.current.length = i, i);
|
|
2734
|
+
}, [s]);
|
|
2735
|
+
return C.useSyncExternalStore(t, r, r);
|
|
2686
2736
|
}
|
|
2687
|
-
function
|
|
2688
|
-
const { model: e, schema: t, strategy:
|
|
2689
|
-
() =>
|
|
2690
|
-
[e, t,
|
|
2737
|
+
function Be(s) {
|
|
2738
|
+
const { model: e, schema: t, strategy: r, debounce: i, liveAfterSubmit: n } = s, a = oe(
|
|
2739
|
+
() => D(e, t, { strategy: r, debounce: i, liveAfterSubmit: n }),
|
|
2740
|
+
[e, t, r, i, n]
|
|
2691
2741
|
);
|
|
2692
|
-
|
|
2742
|
+
z(() => a.start(), [a]);
|
|
2693
2743
|
const l = C.useSyncExternalStore(
|
|
2694
|
-
|
|
2744
|
+
E((u) => a.validating.subscribe(u), [a]),
|
|
2695
2745
|
() => a.validating.peek(),
|
|
2696
2746
|
() => !1
|
|
2697
2747
|
// SSR: прогон не идёт
|
|
2698
|
-
), d =
|
|
2748
|
+
), d = E(() => a.validate(), [a]);
|
|
2699
2749
|
return { submit: d, validate: d, isValidating: l };
|
|
2700
2750
|
}
|
|
2701
|
-
const
|
|
2751
|
+
const Ue = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2702
2752
|
export {
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2753
|
+
W as ArrayNode,
|
|
2754
|
+
Ue as CORE_RUNTIME_TOKEN,
|
|
2755
|
+
S as ErrorStrategy,
|
|
2756
|
+
de as FieldNode,
|
|
2707
2757
|
k as FormErrorHandler,
|
|
2708
2758
|
M as FormNode,
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2759
|
+
he as FormSubmitter,
|
|
2760
|
+
A as GroupNode,
|
|
2761
|
+
me as ModelArrayNode,
|
|
2762
|
+
ve as NodeFactory,
|
|
2763
|
+
L as SubscriptionManager,
|
|
2764
|
+
be as buildValidation,
|
|
2765
|
+
Je as computeFrom,
|
|
2766
|
+
Qe as copyFrom,
|
|
2767
|
+
Ie as createCoreForm,
|
|
2768
|
+
ye as createForm,
|
|
2769
|
+
Z as createFormFromModel,
|
|
2770
|
+
ee as createModel,
|
|
2771
|
+
ut as disableWhen,
|
|
2772
|
+
dt as enableWhen,
|
|
2773
|
+
ot as getNodeForSignal,
|
|
2774
|
+
Re as getNodeType,
|
|
2775
|
+
Se as isArrayNode,
|
|
2776
|
+
G as isDerived,
|
|
2777
|
+
Ee as isFieldNode,
|
|
2726
2778
|
x as isFormNode,
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2779
|
+
_e as isGroupNode,
|
|
2780
|
+
Ke as isModelContainerSignal,
|
|
2781
|
+
He as markDerived,
|
|
2782
|
+
se as registerSignalNode,
|
|
2783
|
+
Xe as resetWhen,
|
|
2784
|
+
Ze as revalidateWhen,
|
|
2785
|
+
et as runOutsideEffect,
|
|
2786
|
+
tt as safeCallback,
|
|
2787
|
+
st as safeDebouncedCallback,
|
|
2788
|
+
rt as syncFields,
|
|
2789
|
+
it as transformValue,
|
|
2790
|
+
Ye as unmarkDerived,
|
|
2791
|
+
je as useArrayLength,
|
|
2792
|
+
Le as useFormBundle,
|
|
2793
|
+
$e as useFormControl,
|
|
2794
|
+
Ge as useFormControlValue,
|
|
2795
|
+
Be as useFormValidation,
|
|
2796
|
+
nt as watchField
|
|
2743
2797
|
};
|