@reformer/core 11.0.0-beta.5 → 11.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.js +124 -124
- package/dist/create-model-B8U-COv-.js +103 -0
- package/dist/en-CjAqn7h0.js +41 -0
- package/dist/form/behaviors/internals.d.ts +9 -0
- package/dist/form/create-form.d.ts +6 -6
- package/dist/form/factories/node-factory.d.ts +16 -16
- package/dist/form/nodes/array-node.d.ts +3 -3
- package/dist/form/nodes/field-node.d.ts +3 -3
- package/dist/form/nodes/group-node.d.ts +7 -7
- package/dist/form/nodes/model-array-node.d.ts +2 -2
- package/dist/form/types/contracts.d.ts +6 -0
- package/dist/form/types/deep-schema.d.ts +5 -5
- package/dist/form/types/validation-schema.d.ts +13 -1
- package/dist/form/validation/operators.d.ts +6 -1
- package/dist/form/validators/validation-error.d.ts +8 -0
- package/dist/i18n/descriptor.d.ts +54 -0
- package/dist/i18n/en.json.d.ts +45 -0
- package/dist/i18n/loader.d.ts +71 -0
- package/dist/i18n/locale-store.d.ts +39 -0
- package/dist/i18n/locale.d.ts +90 -0
- package/dist/i18n/message-format.d.ts +116 -0
- package/dist/i18n/resolve-localized.d.ts +17 -0
- package/dist/i18n/ru.json.d.ts +45 -0
- package/dist/i18n/translator.d.ts +50 -0
- package/dist/i18n/validation-message.d.ts +18 -0
- package/dist/i18n.d.ts +31 -0
- package/dist/i18n.js +303 -0
- package/dist/index-BrNkQj1y.js +105 -0
- package/dist/index.js +548 -601
- package/dist/loader-Dv_Hl7JC.js +216 -0
- package/dist/locale/en.d.ts +2 -0
- package/dist/locale/en.js +5 -0
- package/dist/locale/en.json +42 -0
- package/dist/locale/index.d.ts +18 -0
- package/dist/locale/ru.d.ts +2 -0
- package/dist/locale/ru.js +41 -0
- package/dist/locale/ru.json +42 -0
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +9 -0
- package/dist/model/create-model.d.ts +17 -3
- package/dist/model/index.d.ts +3 -3
- package/dist/model/model-signals-proxy.d.ts +25 -0
- package/dist/model/types.d.ts +19 -5
- package/dist/model-signals-proxy-2vqS243J.js +250 -0
- package/dist/model.js +18 -16
- package/dist/platforms/react/field-binding/field-adapter.d.ts +87 -0
- package/dist/platforms/react/field-binding/field-handle.d.ts +50 -0
- package/dist/platforms/react/hooks/types.d.ts +6 -3
- package/dist/platforms/react/hooks/useFormControlValue.d.ts +2 -1
- package/dist/platforms/react/i18n/context.d.ts +13 -0
- package/dist/platforms/react/i18n/hooks.d.ts +59 -0
- package/dist/platforms/react/i18n/provider.d.ts +52 -0
- package/dist/platforms/react/index.d.ts +4 -0
- package/dist/{strategy-DA3JwxsR.js → strategy-BXS_gBfz.js} +7 -7
- package/dist/validation-error-B-U3RsV0.js +11 -0
- package/dist/validation.js +1 -1
- package/dist/validators/email.js +5 -8
- package/dist/validators/future-date.js +8 -11
- package/dist/validators/integer.js +4 -7
- package/dist/validators/is-date.js +5 -8
- package/dist/validators/is-number.js +4 -7
- package/dist/validators/max-age.js +8 -11
- package/dist/validators/max-date.js +8 -11
- package/dist/validators/max-length.js +5 -8
- package/dist/validators/max.js +4 -7
- package/dist/validators/min-age.js +8 -11
- package/dist/validators/min-date.js +8 -11
- package/dist/validators/min-length.js +5 -8
- package/dist/validators/min.js +4 -7
- package/dist/validators/multiple-of.js +5 -8
- package/dist/validators/non-negative.js +4 -7
- package/dist/validators/non-zero.js +4 -7
- package/dist/validators/past-date.js +8 -11
- package/dist/validators/pattern.js +5 -8
- package/dist/validators/phone.js +6 -9
- package/dist/validators/required.js +4 -7
- package/dist/validators/url.js +9 -14
- package/dist/validators.js +84 -106
- package/docs/llms/02-quick-start.md +7 -7
- package/docs/llms/03-api-signatures.md +11 -5
- package/docs/llms/05-common-mistakes.md +1 -1
- package/docs/llms/09-formschema.md +12 -12
- package/docs/llms/10-arrays.md +34 -4
- package/docs/llms/14-extended-mistakes.md +1 -1
- package/docs/llms/15-project-structure.md +15 -13
- package/docs/llms/16-ui-components.md +36 -9
- package/docs/llms/17-nonexistent-api.md +16 -2
- package/docs/llms/29-async-preload.md +4 -4
- package/docs/llms/30-type-safety-recipes.md +1 -1
- package/docs/llms/34-i18n.md +272 -0
- package/llms-index.json +1 -1
- package/llms.txt +1925 -175
- package/package.json +22 -3
- package/dist/create-model-Dxh9cfLp.js +0 -97
- package/dist/model-signals-proxy-mV3WGdlO.js +0 -233
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { e as Ke } from "./create-model-
|
|
3
|
-
import { a as
|
|
4
|
-
import { i as
|
|
5
|
-
import { c as
|
|
6
|
-
import { signal as
|
|
7
|
-
import { r as
|
|
8
|
-
import { g as
|
|
9
|
-
import { f as
|
|
10
|
-
import { d as
|
|
11
|
-
import
|
|
12
|
-
|
|
1
|
+
import { c as K } from "./create-model-B8U-COv-.js";
|
|
2
|
+
import { e as He, a as Ke } from "./create-model-B8U-COv-.js";
|
|
3
|
+
import { b as R, d as L, a as $ } from "./model-signals-proxy-2vqS243J.js";
|
|
4
|
+
import { i as Ye, m as Je, u as Qe } from "./model-signals-proxy-2vqS243J.js";
|
|
5
|
+
import { c as Ze, a as et, r as tt, b as st, d as it, e as rt, f as nt, s as at, t as ot, w as lt } from "./behaviors-value-C7dSEhCc.js";
|
|
6
|
+
import { signal as m, computed as h, effect as g, batch as z, Signal as Y } from "@preact/signals-core";
|
|
7
|
+
import { r as J } from "./signal-node-registry-tiwel-TV.js";
|
|
8
|
+
import { g as dt } from "./signal-node-registry-tiwel-TV.js";
|
|
9
|
+
import { f as Q, h as P, g as X, d as Z } from "./strategy-BXS_gBfz.js";
|
|
10
|
+
import { d as ht, e as ft } from "./node-DGEFMTQu.js";
|
|
11
|
+
import { useRef as _, useCallback as y, useMemo as ee, useEffect as U, useState as te, useImperativeHandle as se } from "react";
|
|
12
|
+
import { s as F } from "./index-BrNkQj1y.js";
|
|
13
|
+
class N {
|
|
13
14
|
// ============================================================================
|
|
14
15
|
// Protected состояние (для Template Method паттерна)
|
|
15
16
|
// ============================================================================
|
|
@@ -17,17 +18,17 @@ class M {
|
|
|
17
18
|
* Пользователь взаимодействовал с узлом (touched)
|
|
18
19
|
* Protected: наследники могут читать/изменять через методы
|
|
19
20
|
*/
|
|
20
|
-
_touched =
|
|
21
|
+
_touched = m(!1);
|
|
21
22
|
/**
|
|
22
23
|
* Значение узла было изменено (dirty)
|
|
23
24
|
* Protected: наследники могут читать/изменять через методы
|
|
24
25
|
*/
|
|
25
|
-
_dirty =
|
|
26
|
+
_dirty = m(!1);
|
|
26
27
|
/**
|
|
27
28
|
* Текущий статус узла
|
|
28
29
|
* Protected: наследники могут читать/изменять через методы
|
|
29
30
|
*/
|
|
30
|
-
_status =
|
|
31
|
+
_status = m("valid");
|
|
31
32
|
// ============================================================================
|
|
32
33
|
// Публичные computed signals (readonly для внешнего мира)
|
|
33
34
|
// ============================================================================
|
|
@@ -35,21 +36,21 @@ class M {
|
|
|
35
36
|
* Пользователь взаимодействовал с узлом (touched)
|
|
36
37
|
* Computed из _touched для предоставления readonly интерфейса
|
|
37
38
|
*/
|
|
38
|
-
touched =
|
|
39
|
+
touched = h(() => this._touched.value);
|
|
39
40
|
/**
|
|
40
41
|
* Значение узла было изменено (dirty)
|
|
41
42
|
* Computed из _dirty для предоставления readonly интерфейса
|
|
42
43
|
*/
|
|
43
|
-
dirty =
|
|
44
|
+
dirty = h(() => this._dirty.value);
|
|
44
45
|
/**
|
|
45
46
|
* Текущий статус узла
|
|
46
47
|
* Computed из _status для предоставления readonly интерфейса
|
|
47
48
|
*/
|
|
48
|
-
status =
|
|
49
|
+
status = h(() => this._status.value);
|
|
49
50
|
/**
|
|
50
51
|
* Узел отключен (disabled)
|
|
51
52
|
*/
|
|
52
|
-
disabled =
|
|
53
|
+
disabled = h(() => this._status.value === "disabled");
|
|
53
54
|
/**
|
|
54
55
|
* Получить ошибки валидации с фильтрацией
|
|
55
56
|
*
|
|
@@ -91,17 +92,17 @@ class M {
|
|
|
91
92
|
*/
|
|
92
93
|
getErrors(e) {
|
|
93
94
|
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(
|
|
95
|
+
return e ? t.filter((i) => {
|
|
96
|
+
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(i.code) || e.message !== void 0 && !i.message.toLowerCase().includes(e.message.toLowerCase()))
|
|
96
97
|
return !1;
|
|
97
98
|
if (e.params !== void 0) {
|
|
98
|
-
if (!
|
|
99
|
+
if (!i.params)
|
|
99
100
|
return !1;
|
|
100
|
-
for (const [
|
|
101
|
-
if (
|
|
101
|
+
for (const [r, n] of Object.entries(e.params))
|
|
102
|
+
if (i.params[r] !== n)
|
|
102
103
|
return !1;
|
|
103
104
|
}
|
|
104
|
-
return !(e.predicate !== void 0 && !e.predicate(
|
|
105
|
+
return !(e.predicate !== void 0 && !e.predicate(i));
|
|
105
106
|
}) : t;
|
|
106
107
|
}
|
|
107
108
|
// ============================================================================
|
|
@@ -274,7 +275,7 @@ class M {
|
|
|
274
275
|
onEnable() {
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
|
-
class
|
|
278
|
+
class x {
|
|
278
279
|
/**
|
|
279
280
|
* Хранилище подписок
|
|
280
281
|
* Ключ: уникальный идентификатор подписки
|
|
@@ -442,7 +443,7 @@ class L {
|
|
|
442
443
|
this.clear();
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
|
-
const
|
|
446
|
+
const k = {
|
|
446
447
|
/** FieldNode.watch() */
|
|
447
448
|
Watch: "watch",
|
|
448
449
|
/** FieldNode.computeFrom() */
|
|
@@ -452,15 +453,15 @@ const O = {
|
|
|
452
453
|
/** GroupNode.watchField() */
|
|
453
454
|
WatchField: "watchField"
|
|
454
455
|
};
|
|
455
|
-
let
|
|
456
|
-
function
|
|
457
|
-
return `${s}-${++
|
|
456
|
+
let ie = 0;
|
|
457
|
+
function V(s) {
|
|
458
|
+
return `${s}-${++ie}`;
|
|
458
459
|
}
|
|
459
|
-
var
|
|
460
|
-
class
|
|
461
|
-
static handle(e, t,
|
|
462
|
-
const
|
|
463
|
-
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e),
|
|
460
|
+
var E = /* @__PURE__ */ ((s) => (s.THROW = "throw", s.LOG = "log", s.CONVERT = "convert", s))(E || {});
|
|
461
|
+
class w {
|
|
462
|
+
static handle(e, t, i = "throw") {
|
|
463
|
+
const r = this.extractMessage(e);
|
|
464
|
+
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), i) {
|
|
464
465
|
case "throw":
|
|
465
466
|
throw e;
|
|
466
467
|
case "log":
|
|
@@ -468,7 +469,7 @@ class V {
|
|
|
468
469
|
case "convert":
|
|
469
470
|
return {
|
|
470
471
|
code: "validator_error",
|
|
471
|
-
message:
|
|
472
|
+
message: r,
|
|
472
473
|
params: { field: t }
|
|
473
474
|
};
|
|
474
475
|
}
|
|
@@ -524,11 +525,11 @@ class V {
|
|
|
524
525
|
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
525
526
|
* ```
|
|
526
527
|
*/
|
|
527
|
-
static createValidationError(e, t,
|
|
528
|
+
static createValidationError(e, t, i) {
|
|
528
529
|
return {
|
|
529
530
|
code: e,
|
|
530
531
|
message: t,
|
|
531
|
-
params:
|
|
532
|
+
params: i ? { field: i } : void 0
|
|
532
533
|
};
|
|
533
534
|
}
|
|
534
535
|
/**
|
|
@@ -550,7 +551,7 @@ class V {
|
|
|
550
551
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
551
552
|
}
|
|
552
553
|
}
|
|
553
|
-
class
|
|
554
|
+
class re {
|
|
554
555
|
/** Внутренний сигнал статуса */
|
|
555
556
|
_status;
|
|
556
557
|
/** Публичный read-only сигнал статуса */
|
|
@@ -567,7 +568,7 @@ class ue {
|
|
|
567
568
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
568
569
|
*/
|
|
569
570
|
constructor(e = "valid") {
|
|
570
|
-
this._status =
|
|
571
|
+
this._status = m(e), this.status = h(() => this._status.value), this.valid = h(() => this._status.value === "valid"), this.invalid = h(() => this._status.value === "invalid"), this.pending = h(() => this._status.value === "pending"), this.disabled = h(() => this._status.value === "disabled");
|
|
571
572
|
}
|
|
572
573
|
/**
|
|
573
574
|
* Начать валидацию
|
|
@@ -650,7 +651,7 @@ class ue {
|
|
|
650
651
|
this._status.value = e ? "invalid" : "valid";
|
|
651
652
|
}
|
|
652
653
|
}
|
|
653
|
-
class
|
|
654
|
+
class ne extends N {
|
|
654
655
|
// ============================================================================
|
|
655
656
|
// Приватные сигналы
|
|
656
657
|
// ============================================================================
|
|
@@ -702,13 +703,13 @@ class de extends M {
|
|
|
702
703
|
* Менеджер подписок для централизованного cleanup
|
|
703
704
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
704
705
|
*/
|
|
705
|
-
disposers = new
|
|
706
|
+
disposers = new x();
|
|
706
707
|
component;
|
|
707
708
|
// ============================================================================
|
|
708
709
|
// Конструктор
|
|
709
710
|
// ============================================================================
|
|
710
711
|
constructor(e) {
|
|
711
|
-
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 ??
|
|
712
|
+
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 ?? m(e.value), this.initialValue = this._value.peek(), this._errors = m([]), this._componentProps = m(e.componentProps || {}), this.statusMachine = new re(e.disabled ? "disabled" : "valid"), this.value = h(() => this._value.value), this.valid = h(() => this.statusMachine.valid.value), this.invalid = h(() => this.statusMachine.invalid.value), this.pending = h(() => this.statusMachine.pending.value), this.status = h(() => this.statusMachine.status.value), this.disabled = h(() => this.statusMachine.disabled.value), this.errors = h(() => this._errors.value), this.componentProps = h(() => this._componentProps.value), this.shouldShowError = h(
|
|
712
713
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
713
714
|
);
|
|
714
715
|
}
|
|
@@ -721,12 +722,12 @@ class de extends M {
|
|
|
721
722
|
setValue(e, t) {
|
|
722
723
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
723
724
|
return;
|
|
724
|
-
const
|
|
725
|
+
const i = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
|
|
725
726
|
if (this.updateOn === "change") {
|
|
726
727
|
this.validate();
|
|
727
728
|
return;
|
|
728
729
|
}
|
|
729
|
-
|
|
730
|
+
r && i && this.validate();
|
|
730
731
|
}
|
|
731
732
|
patchValue(e) {
|
|
732
733
|
this.setValue(e);
|
|
@@ -772,7 +773,7 @@ class de extends M {
|
|
|
772
773
|
*
|
|
773
774
|
* @example
|
|
774
775
|
* ```typescript
|
|
775
|
-
* const field = new FieldNode({ value: 'initial', component:
|
|
776
|
+
* const field = new FieldNode({ value: 'initial', component: Input });
|
|
776
777
|
*
|
|
777
778
|
* field.setValue('changed');
|
|
778
779
|
* field.reset('temp value');
|
|
@@ -819,20 +820,20 @@ class de extends M {
|
|
|
819
820
|
const t = e?.debounce ?? this.debounceMs;
|
|
820
821
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
821
822
|
return this.validateImmediate();
|
|
822
|
-
const
|
|
823
|
-
return new Promise((
|
|
824
|
-
this.pendingValidation = { resolve:
|
|
825
|
-
if (this.validateDebounceTimer = void 0,
|
|
826
|
-
|
|
823
|
+
const i = new AbortController();
|
|
824
|
+
return new Promise((r) => {
|
|
825
|
+
this.pendingValidation = { resolve: r, abortController: i }, this.validateDebounceTimer = setTimeout(async () => {
|
|
826
|
+
if (this.validateDebounceTimer = void 0, i.signal.aborted) {
|
|
827
|
+
r(!1);
|
|
827
828
|
return;
|
|
828
829
|
}
|
|
829
830
|
this.pendingValidation = void 0;
|
|
830
|
-
const n = await this.validateImmediate(
|
|
831
|
-
|
|
832
|
-
}, t),
|
|
831
|
+
const n = await this.validateImmediate(i);
|
|
832
|
+
r(n);
|
|
833
|
+
}, t), i.signal.addEventListener(
|
|
833
834
|
"abort",
|
|
834
835
|
() => {
|
|
835
|
-
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0),
|
|
836
|
+
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), r(!1);
|
|
836
837
|
},
|
|
837
838
|
{ once: !0 }
|
|
838
839
|
);
|
|
@@ -851,50 +852,50 @@ class de extends M {
|
|
|
851
852
|
async validateImmediate(e) {
|
|
852
853
|
const t = e ?? new AbortController();
|
|
853
854
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
854
|
-
const { signal:
|
|
855
|
+
const { signal: i } = t, r = [];
|
|
855
856
|
for (const a of this.validators) {
|
|
856
|
-
const
|
|
857
|
-
|
|
857
|
+
const u = a(this._value.value);
|
|
858
|
+
u && r.push(u);
|
|
858
859
|
}
|
|
859
|
-
if (
|
|
860
|
+
if (i.aborted)
|
|
860
861
|
return !1;
|
|
861
|
-
if (
|
|
862
|
-
this._errors.value =
|
|
863
|
-
const a =
|
|
862
|
+
if (r.length > 0) {
|
|
863
|
+
this._errors.value = r;
|
|
864
|
+
const a = r.some((u) => u.severity !== "warning");
|
|
864
865
|
if (this.statusMachine.setErrors(a), a)
|
|
865
866
|
return !1;
|
|
866
867
|
}
|
|
867
868
|
if (this.asyncValidators.length > 0) {
|
|
868
|
-
if (
|
|
869
|
+
if (i.aborted)
|
|
869
870
|
return !1;
|
|
870
871
|
this.statusMachine.startValidation();
|
|
871
872
|
try {
|
|
872
873
|
const a = await Promise.all(
|
|
873
874
|
this.asyncValidators.map(async (d) => {
|
|
874
|
-
if (
|
|
875
|
+
if (i.aborted)
|
|
875
876
|
throw new DOMException("Validation aborted", "AbortError");
|
|
876
877
|
try {
|
|
877
|
-
const
|
|
878
|
-
if (
|
|
878
|
+
const l = await d(this._value.value, { signal: i });
|
|
879
|
+
if (i.aborted)
|
|
879
880
|
throw new DOMException("Validation aborted", "AbortError");
|
|
880
|
-
return
|
|
881
|
-
} catch (
|
|
882
|
-
if (
|
|
883
|
-
throw
|
|
884
|
-
return
|
|
885
|
-
|
|
881
|
+
return l;
|
|
882
|
+
} catch (l) {
|
|
883
|
+
if (l instanceof DOMException && l.name === "AbortError")
|
|
884
|
+
throw l;
|
|
885
|
+
return w.handle(
|
|
886
|
+
l,
|
|
886
887
|
"FieldNode AsyncValidator",
|
|
887
|
-
|
|
888
|
+
E.CONVERT
|
|
888
889
|
);
|
|
889
890
|
}
|
|
890
891
|
})
|
|
891
892
|
);
|
|
892
|
-
if (
|
|
893
|
+
if (i.aborted)
|
|
893
894
|
return !1;
|
|
894
|
-
const
|
|
895
|
-
if (
|
|
896
|
-
this._errors.value =
|
|
897
|
-
const d =
|
|
895
|
+
const u = a.filter((d) => d !== null);
|
|
896
|
+
if (u.length > 0) {
|
|
897
|
+
this._errors.value = u;
|
|
898
|
+
const d = u.some((l) => l.severity !== "warning");
|
|
898
899
|
if (this.statusMachine.completeValidation(d), d)
|
|
899
900
|
return !1;
|
|
900
901
|
}
|
|
@@ -904,11 +905,11 @@ class de extends M {
|
|
|
904
905
|
throw a;
|
|
905
906
|
}
|
|
906
907
|
}
|
|
907
|
-
return
|
|
908
|
+
return i.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
|
|
908
909
|
}
|
|
909
910
|
setErrors(e) {
|
|
910
911
|
this._errors.value = e;
|
|
911
|
-
const t = e.some((
|
|
912
|
+
const t = e.some((i) => i.severity !== "warning");
|
|
912
913
|
this.statusMachine.setErrors(t);
|
|
913
914
|
}
|
|
914
915
|
clearErrors() {
|
|
@@ -972,7 +973,7 @@ class de extends M {
|
|
|
972
973
|
* const form = createForm({
|
|
973
974
|
* email: {
|
|
974
975
|
* value: '',
|
|
975
|
-
* component:
|
|
976
|
+
* component: Input,
|
|
976
977
|
* updateOn: 'submit', // Изначально валидация только при submit
|
|
977
978
|
* validators: [required, email],
|
|
978
979
|
* },
|
|
@@ -1027,12 +1028,12 @@ class de extends M {
|
|
|
1027
1028
|
* ```
|
|
1028
1029
|
*/
|
|
1029
1030
|
watch(e) {
|
|
1030
|
-
const t = new AbortController(),
|
|
1031
|
+
const t = new AbortController(), i = g(() => {
|
|
1031
1032
|
const n = this.value.value;
|
|
1032
1033
|
e(n, t.signal);
|
|
1033
|
-
}),
|
|
1034
|
-
return this.disposers.add(
|
|
1035
|
-
t.abort(),
|
|
1034
|
+
}), r = V(k.Watch);
|
|
1035
|
+
return this.disposers.add(r, () => {
|
|
1036
|
+
t.abort(), i();
|
|
1036
1037
|
});
|
|
1037
1038
|
}
|
|
1038
1039
|
/**
|
|
@@ -1058,11 +1059,11 @@ class de extends M {
|
|
|
1058
1059
|
* ```
|
|
1059
1060
|
*/
|
|
1060
1061
|
computeFrom(e, t) {
|
|
1061
|
-
const
|
|
1062
|
-
const n = e.map((
|
|
1062
|
+
const i = g(() => {
|
|
1063
|
+
const n = e.map((u) => u.value), a = t(...n);
|
|
1063
1064
|
this.setValue(a, { emitEvent: !1 });
|
|
1064
|
-
}),
|
|
1065
|
-
return this.disposers.add(
|
|
1065
|
+
}), r = V(k.ComputeFrom);
|
|
1066
|
+
return this.disposers.add(r, i);
|
|
1066
1067
|
}
|
|
1067
1068
|
/**
|
|
1068
1069
|
* Очистить все ресурсы и таймеры
|
|
@@ -1092,59 +1093,59 @@ class de extends M {
|
|
|
1092
1093
|
}
|
|
1093
1094
|
}
|
|
1094
1095
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const { getChildren: e, ownErrors: t, disabled:
|
|
1096
|
+
function O(s) {
|
|
1097
|
+
const { getChildren: e, ownErrors: t, disabled: i } = s, r = h(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = h(() => !r.value), a = h(() => e().some((o) => o.pending.value)), u = h(() => e().some((o) => o.touched.value)), d = h(() => e().some((o) => o.dirty.value)), l = h(() => {
|
|
1097
1098
|
const o = [...t.value];
|
|
1098
1099
|
for (const f of e())
|
|
1099
1100
|
o.push(...f.errors.value);
|
|
1100
1101
|
return o;
|
|
1101
|
-
}),
|
|
1102
|
+
}), c = h(() => i?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
1102
1103
|
return {
|
|
1103
|
-
valid:
|
|
1104
|
+
valid: r,
|
|
1104
1105
|
invalid: n,
|
|
1105
1106
|
pending: a,
|
|
1106
|
-
touched:
|
|
1107
|
+
touched: u,
|
|
1107
1108
|
dirty: d,
|
|
1108
|
-
errors:
|
|
1109
|
-
status:
|
|
1109
|
+
errors: l,
|
|
1110
|
+
status: c
|
|
1110
1111
|
};
|
|
1111
1112
|
}
|
|
1112
1113
|
function B(s) {
|
|
1113
1114
|
return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
|
|
1114
1115
|
}
|
|
1115
|
-
const
|
|
1116
|
-
function
|
|
1116
|
+
const G = "$";
|
|
1117
|
+
function ae(s, e) {
|
|
1117
1118
|
let t;
|
|
1118
|
-
const
|
|
1119
|
+
const i = () => {
|
|
1119
1120
|
if (!t) {
|
|
1120
|
-
const
|
|
1121
|
+
const r = {};
|
|
1121
1122
|
e.forEach((n, a) => {
|
|
1122
|
-
|
|
1123
|
-
}), t =
|
|
1123
|
+
r[a] = n && B(n) ? n.getProxy() : n;
|
|
1124
|
+
}), t = r;
|
|
1124
1125
|
}
|
|
1125
1126
|
return t;
|
|
1126
1127
|
};
|
|
1127
1128
|
return new Proxy(s, {
|
|
1128
|
-
get: (
|
|
1129
|
-
if (n ===
|
|
1130
|
-
return
|
|
1131
|
-
if (n in
|
|
1132
|
-
return
|
|
1129
|
+
get: (r, n) => {
|
|
1130
|
+
if (n === G)
|
|
1131
|
+
return i();
|
|
1132
|
+
if (n in r)
|
|
1133
|
+
return r[n];
|
|
1133
1134
|
if (typeof n == "string" && e.has(n)) {
|
|
1134
1135
|
const a = e.get(n);
|
|
1135
1136
|
return a && B(a) ? a.getProxy() : a;
|
|
1136
1137
|
}
|
|
1137
1138
|
},
|
|
1138
|
-
set: (
|
|
1139
|
-
has: (
|
|
1140
|
-
ownKeys: (
|
|
1141
|
-
const n = Reflect.ownKeys(
|
|
1139
|
+
set: (r, n, a) => typeof n == "string" && e.has(n) ? !1 : (r[n] = a, !0),
|
|
1140
|
+
has: (r, n) => n === G || typeof n == "string" && e.has(n) ? !0 : n in r,
|
|
1141
|
+
ownKeys: (r) => {
|
|
1142
|
+
const n = Reflect.ownKeys(r), a = Array.from(e.keys());
|
|
1142
1143
|
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
1143
1144
|
},
|
|
1144
|
-
getOwnPropertyDescriptor: (
|
|
1145
|
+
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(r, n)
|
|
1145
1146
|
});
|
|
1146
1147
|
}
|
|
1147
|
-
class
|
|
1148
|
+
class oe {
|
|
1148
1149
|
/**
|
|
1149
1150
|
* @param form - Форма для отправки
|
|
1150
1151
|
*/
|
|
@@ -1152,9 +1153,9 @@ class he {
|
|
|
1152
1153
|
this.form = e;
|
|
1153
1154
|
}
|
|
1154
1155
|
/** Внутренний сигнал состояния отправки */
|
|
1155
|
-
_submitting =
|
|
1156
|
+
_submitting = m(!1);
|
|
1156
1157
|
/** Публичный read-only сигнал состояния отправки */
|
|
1157
|
-
submitting =
|
|
1158
|
+
submitting = h(() => this._submitting.value);
|
|
1158
1159
|
/**
|
|
1159
1160
|
* Отправить форму
|
|
1160
1161
|
*
|
|
@@ -1189,8 +1190,8 @@ class he {
|
|
|
1189
1190
|
* ```
|
|
1190
1191
|
*/
|
|
1191
1192
|
async submit(e, t) {
|
|
1192
|
-
const { skipValidation:
|
|
1193
|
-
if (
|
|
1193
|
+
const { skipValidation: i = !1, skipTouch: r = !1 } = t || {};
|
|
1194
|
+
if (r || this.form.markAsTouched(), !i && !await this.form.validate())
|
|
1194
1195
|
return null;
|
|
1195
1196
|
this._submitting.value = !0;
|
|
1196
1197
|
try {
|
|
@@ -1224,8 +1225,8 @@ class he {
|
|
|
1224
1225
|
* ```
|
|
1225
1226
|
*/
|
|
1226
1227
|
async submitWithResult(e, t) {
|
|
1227
|
-
const { skipValidation:
|
|
1228
|
-
if (
|
|
1228
|
+
const { skipValidation: i = !1, skipTouch: r = !1 } = t || {};
|
|
1229
|
+
if (r || this.form.markAsTouched(), !i && !await this.form.validate())
|
|
1229
1230
|
return { success: !1, data: null };
|
|
1230
1231
|
this._submitting.value = !0;
|
|
1231
1232
|
try {
|
|
@@ -1241,16 +1242,16 @@ class he {
|
|
|
1241
1242
|
}
|
|
1242
1243
|
}
|
|
1243
1244
|
}
|
|
1244
|
-
function
|
|
1245
|
+
function le(s) {
|
|
1245
1246
|
const e = [];
|
|
1246
1247
|
for (const t of s.split(".")) {
|
|
1247
|
-
const
|
|
1248
|
-
if (!
|
|
1249
|
-
e.push(
|
|
1248
|
+
const i = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1249
|
+
if (!i) return [];
|
|
1250
|
+
e.push(i[2] !== void 0 ? { key: i[1], index: Number(i[2]) } : { key: i[1] });
|
|
1250
1251
|
}
|
|
1251
1252
|
return e;
|
|
1252
1253
|
}
|
|
1253
|
-
class A extends
|
|
1254
|
+
class A extends N {
|
|
1254
1255
|
// ============================================================================
|
|
1255
1256
|
// Приватные поля
|
|
1256
1257
|
// ============================================================================
|
|
@@ -1263,7 +1264,7 @@ class A extends M {
|
|
|
1263
1264
|
/**
|
|
1264
1265
|
* Менеджер подписок для централизованного cleanup
|
|
1265
1266
|
*/
|
|
1266
|
-
disposers = new
|
|
1267
|
+
disposers = new x();
|
|
1267
1268
|
/**
|
|
1268
1269
|
* Ссылка на Proxy-инстанс
|
|
1269
1270
|
*/
|
|
@@ -1275,7 +1276,7 @@ class A extends M {
|
|
|
1275
1276
|
/**
|
|
1276
1277
|
* Фабрика для создания узлов формы
|
|
1277
1278
|
*/
|
|
1278
|
-
nodeFactory = new
|
|
1279
|
+
nodeFactory = new ue();
|
|
1279
1280
|
// ============================================================================
|
|
1280
1281
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1281
1282
|
// ============================================================================
|
|
@@ -1283,9 +1284,9 @@ class A extends M {
|
|
|
1283
1284
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1284
1285
|
formSubmitter;
|
|
1285
1286
|
/** Флаг disabled состояния */
|
|
1286
|
-
_disabled =
|
|
1287
|
+
_disabled = m(!1);
|
|
1287
1288
|
/** Form-level validation errors */
|
|
1288
|
-
_formErrors =
|
|
1289
|
+
_formErrors = m([]);
|
|
1289
1290
|
/**
|
|
1290
1291
|
* M1: связь листовой ноды-ребёнка → её сигнал модели (тот, что помечает `markDerived`).
|
|
1291
1292
|
* Нужна bulk-сеттерам (`setValue`/`patchValue`), чтобы корректно определять derived-поля:
|
|
@@ -1306,19 +1307,19 @@ class A extends M {
|
|
|
1306
1307
|
status;
|
|
1307
1308
|
submitting;
|
|
1308
1309
|
constructor(e) {
|
|
1309
|
-
super(), this.formSubmitter = new
|
|
1310
|
-
const t = e.form,
|
|
1311
|
-
for (const [
|
|
1312
|
-
const
|
|
1313
|
-
this._fields.set(
|
|
1310
|
+
super(), this.formSubmitter = new oe(this);
|
|
1311
|
+
const t = e.form, i = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !i ? e.form : e;
|
|
1312
|
+
for (const [u, d] of Object.entries(n)) {
|
|
1313
|
+
const l = this.createNode(d);
|
|
1314
|
+
this._fields.set(u, l);
|
|
1314
1315
|
}
|
|
1315
|
-
this.value =
|
|
1316
|
-
const
|
|
1317
|
-
return this._fields.forEach((d,
|
|
1318
|
-
l
|
|
1319
|
-
}),
|
|
1316
|
+
this.value = h(() => {
|
|
1317
|
+
const u = {};
|
|
1318
|
+
return this._fields.forEach((d, l) => {
|
|
1319
|
+
u[l] = d.value.value;
|
|
1320
|
+
}), u;
|
|
1320
1321
|
});
|
|
1321
|
-
const a =
|
|
1322
|
+
const a = O({
|
|
1322
1323
|
getChildren: () => Array.from(this._fields.values()),
|
|
1323
1324
|
ownErrors: this._formErrors,
|
|
1324
1325
|
disabled: this._disabled
|
|
@@ -1333,35 +1334,35 @@ class A extends M {
|
|
|
1333
1334
|
* @see buildFormProxy
|
|
1334
1335
|
*/
|
|
1335
1336
|
buildProxy() {
|
|
1336
|
-
return
|
|
1337
|
+
return ae(this, this._fields);
|
|
1337
1338
|
}
|
|
1338
1339
|
// ============================================================================
|
|
1339
1340
|
// Реализация абстрактных методов FormNode
|
|
1340
1341
|
// ============================================================================
|
|
1341
1342
|
getValue() {
|
|
1342
1343
|
const e = {};
|
|
1343
|
-
return this._fields.forEach((t,
|
|
1344
|
-
e[
|
|
1344
|
+
return this._fields.forEach((t, i) => {
|
|
1345
|
+
e[i] = t.getValue();
|
|
1345
1346
|
}), e;
|
|
1346
1347
|
}
|
|
1347
1348
|
setValue(e, t) {
|
|
1348
|
-
for (const [
|
|
1349
|
-
const n = this._fields.get(
|
|
1349
|
+
for (const [i, r] of Object.entries(e)) {
|
|
1350
|
+
const n = this._fields.get(i);
|
|
1350
1351
|
if (n) {
|
|
1351
1352
|
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1352
|
-
if (
|
|
1353
|
-
n.setValue(
|
|
1353
|
+
if (R(a)) continue;
|
|
1354
|
+
n.setValue(r, t);
|
|
1354
1355
|
}
|
|
1355
1356
|
}
|
|
1356
1357
|
}
|
|
1357
1358
|
patchValue(e) {
|
|
1358
|
-
|
|
1359
|
-
for (const [t,
|
|
1360
|
-
const
|
|
1361
|
-
if (
|
|
1362
|
-
const n = this._fieldSignals.get(
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
1359
|
+
z(() => {
|
|
1360
|
+
for (const [t, i] of Object.entries(e)) {
|
|
1361
|
+
const r = this._fields.get(t);
|
|
1362
|
+
if (r && i !== void 0) {
|
|
1363
|
+
const n = this._fieldSignals.get(r) ?? r.value;
|
|
1364
|
+
if (R(n)) continue;
|
|
1365
|
+
r.setValue(i, { emitEvent: !1 });
|
|
1365
1366
|
}
|
|
1366
1367
|
}
|
|
1367
1368
|
});
|
|
@@ -1384,9 +1385,9 @@ class A extends M {
|
|
|
1384
1385
|
* ```
|
|
1385
1386
|
*/
|
|
1386
1387
|
reset(e) {
|
|
1387
|
-
this._formErrors.value = [], this._fields.forEach((t,
|
|
1388
|
-
const
|
|
1389
|
-
t.reset(
|
|
1388
|
+
this._formErrors.value = [], this._fields.forEach((t, i) => {
|
|
1389
|
+
const r = e?.[i];
|
|
1390
|
+
t.reset(r);
|
|
1390
1391
|
});
|
|
1391
1392
|
}
|
|
1392
1393
|
/**
|
|
@@ -1438,8 +1439,8 @@ class A extends M {
|
|
|
1438
1439
|
* @example
|
|
1439
1440
|
* ```typescript
|
|
1440
1441
|
* const form = new GroupNode({
|
|
1441
|
-
* email: { value: '', component:
|
|
1442
|
-
* name: { value: '', component:
|
|
1442
|
+
* email: { value: '', component: Input },
|
|
1443
|
+
* name: { value: '', component: Input },
|
|
1443
1444
|
* });
|
|
1444
1445
|
*
|
|
1445
1446
|
* const proxy = form.getProxy();
|
|
@@ -1513,11 +1514,11 @@ class A extends M {
|
|
|
1513
1514
|
* @example
|
|
1514
1515
|
* ```typescript
|
|
1515
1516
|
* const form = new GroupNode({
|
|
1516
|
-
* email: { value: '', component:
|
|
1517
|
+
* email: { value: '', component: Input },
|
|
1517
1518
|
* address: {
|
|
1518
|
-
* city: { value: '', component:
|
|
1519
|
+
* city: { value: '', component: Input }
|
|
1519
1520
|
* },
|
|
1520
|
-
* items: [{ name: { value: '', component:
|
|
1521
|
+
* items: [{ name: { value: '', component: Input } }]
|
|
1521
1522
|
* });
|
|
1522
1523
|
*
|
|
1523
1524
|
* form.getFieldByPath('email'); // FieldNode
|
|
@@ -1530,21 +1531,21 @@ class A extends M {
|
|
|
1530
1531
|
getFieldByPath(e) {
|
|
1531
1532
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1532
1533
|
return;
|
|
1533
|
-
const t =
|
|
1534
|
+
const t = le(e);
|
|
1534
1535
|
if (t.length === 0)
|
|
1535
1536
|
return;
|
|
1536
|
-
let
|
|
1537
|
-
for (const
|
|
1538
|
-
if (!(
|
|
1539
|
-
if (
|
|
1540
|
-
if ("at" in
|
|
1541
|
-
const n =
|
|
1537
|
+
let i = this;
|
|
1538
|
+
for (const r of t) {
|
|
1539
|
+
if (!(i instanceof A) || (i = i.getField(r.key), !i)) return;
|
|
1540
|
+
if (r.index !== void 0)
|
|
1541
|
+
if ("at" in i && "length" in i && typeof i.at == "function") {
|
|
1542
|
+
const n = i.at(r.index);
|
|
1542
1543
|
if (!n) return;
|
|
1543
|
-
|
|
1544
|
+
i = n;
|
|
1544
1545
|
} else
|
|
1545
1546
|
return;
|
|
1546
1547
|
}
|
|
1547
|
-
return
|
|
1548
|
+
return i;
|
|
1548
1549
|
}
|
|
1549
1550
|
// ============================================================================
|
|
1550
1551
|
// Private методы для создания узлов
|
|
@@ -1573,17 +1574,17 @@ class A extends M {
|
|
|
1573
1574
|
/**
|
|
1574
1575
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1575
1576
|
*/
|
|
1576
|
-
linkFields(e, t,
|
|
1577
|
-
const
|
|
1578
|
-
if (!
|
|
1579
|
-
const d =
|
|
1577
|
+
linkFields(e, t, i) {
|
|
1578
|
+
const r = this._fields.get(e), n = this._fields.get(t);
|
|
1579
|
+
if (!r || !n) {
|
|
1580
|
+
const d = r ? t : e;
|
|
1580
1581
|
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1581
1582
|
}
|
|
1582
|
-
const a =
|
|
1583
|
-
const d =
|
|
1584
|
-
n.setValue(
|
|
1585
|
-
}),
|
|
1586
|
-
return this.disposers.add(
|
|
1583
|
+
const a = g(() => {
|
|
1584
|
+
const d = r.value.value, l = i ? i(d) : d;
|
|
1585
|
+
n.setValue(l, { emitEvent: !1 });
|
|
1586
|
+
}), u = V(k.LinkFields);
|
|
1587
|
+
return this.disposers.add(u, a);
|
|
1587
1588
|
}
|
|
1588
1589
|
/**
|
|
1589
1590
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1614,26 +1615,26 @@ class A extends M {
|
|
|
1614
1615
|
*/
|
|
1615
1616
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1616
1617
|
watchField(e, t) {
|
|
1617
|
-
const
|
|
1618
|
-
if (!
|
|
1618
|
+
const i = this.getFieldByPath(e);
|
|
1619
|
+
if (!i)
|
|
1619
1620
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1620
|
-
const
|
|
1621
|
-
t(
|
|
1622
|
-
}), n =
|
|
1623
|
-
return this.disposers.add(n,
|
|
1621
|
+
const r = g(() => {
|
|
1622
|
+
t(i.value.value);
|
|
1623
|
+
}), n = V(k.WatchField);
|
|
1624
|
+
return this.disposers.add(n, r);
|
|
1624
1625
|
}
|
|
1625
1626
|
/**
|
|
1626
1627
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
1627
1628
|
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1628
1629
|
*/
|
|
1629
1630
|
watchFieldByPath(e, t) {
|
|
1630
|
-
const
|
|
1631
|
-
if (!
|
|
1631
|
+
const i = this.getFieldByPath(e);
|
|
1632
|
+
if (!i)
|
|
1632
1633
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1633
|
-
const
|
|
1634
|
-
t(
|
|
1635
|
-
}), n =
|
|
1636
|
-
return this.disposers.add(n,
|
|
1634
|
+
const r = g(() => {
|
|
1635
|
+
t(i.value.value);
|
|
1636
|
+
}), n = V(k.WatchField);
|
|
1637
|
+
return this.disposers.add(n, r);
|
|
1637
1638
|
}
|
|
1638
1639
|
/**
|
|
1639
1640
|
* Hook: вызывается после disable()
|
|
@@ -1672,7 +1673,7 @@ class A extends M {
|
|
|
1672
1673
|
});
|
|
1673
1674
|
}
|
|
1674
1675
|
}
|
|
1675
|
-
class
|
|
1676
|
+
class j extends N {
|
|
1676
1677
|
// ============================================================================
|
|
1677
1678
|
// Приватные поля
|
|
1678
1679
|
// ============================================================================
|
|
@@ -1683,9 +1684,9 @@ class W extends M {
|
|
|
1683
1684
|
* Менеджер подписок для централизованного cleanup
|
|
1684
1685
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1685
1686
|
*/
|
|
1686
|
-
disposers = new
|
|
1687
|
+
disposers = new x();
|
|
1687
1688
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1688
|
-
_arrayErrors =
|
|
1689
|
+
_arrayErrors = m([]);
|
|
1689
1690
|
// ============================================================================
|
|
1690
1691
|
// Публичные computed signals
|
|
1691
1692
|
// ============================================================================
|
|
@@ -1702,15 +1703,15 @@ class W extends M {
|
|
|
1702
1703
|
// Конструктор
|
|
1703
1704
|
// ============================================================================
|
|
1704
1705
|
constructor(e, t = []) {
|
|
1705
|
-
super(), this.itemSchema = e, this.initialItems = t, this.items =
|
|
1706
|
-
for (const
|
|
1707
|
-
this.push(
|
|
1708
|
-
this.length =
|
|
1709
|
-
const
|
|
1706
|
+
super(), this.itemSchema = e, this.initialItems = t, this.items = m([]);
|
|
1707
|
+
for (const r of t)
|
|
1708
|
+
this.push(r);
|
|
1709
|
+
this.length = h(() => this.items.value.length), this.value = h(() => this.items.value.map((r) => r.value.value));
|
|
1710
|
+
const i = O({
|
|
1710
1711
|
getChildren: () => this.items.value,
|
|
1711
1712
|
ownErrors: this._arrayErrors
|
|
1712
1713
|
});
|
|
1713
|
-
this.valid =
|
|
1714
|
+
this.valid = i.valid, this.invalid = i.invalid, this.pending = i.pending, this.touched = i.touched, this.dirty = i.dirty, this.errors = i.errors, this.status = i.status;
|
|
1714
1715
|
}
|
|
1715
1716
|
// ============================================================================
|
|
1716
1717
|
// CRUD операции
|
|
@@ -1732,17 +1733,17 @@ class W extends M {
|
|
|
1732
1733
|
*/
|
|
1733
1734
|
removeAt(e) {
|
|
1734
1735
|
if (e < 0 || e >= this.items.value.length) {
|
|
1735
|
-
|
|
1736
|
+
w.handle(
|
|
1736
1737
|
new Error(
|
|
1737
1738
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1738
1739
|
),
|
|
1739
1740
|
"ArrayNode.removeAt",
|
|
1740
|
-
|
|
1741
|
+
E.LOG
|
|
1741
1742
|
);
|
|
1742
1743
|
return;
|
|
1743
1744
|
}
|
|
1744
1745
|
const t = this.items.value[e];
|
|
1745
|
-
this.items.value = this.items.value.filter((
|
|
1746
|
+
this.items.value = this.items.value.filter((i, r) => r !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1746
1747
|
}
|
|
1747
1748
|
/**
|
|
1748
1749
|
* Вставить элемент в массив
|
|
@@ -1751,17 +1752,17 @@ class W extends M {
|
|
|
1751
1752
|
*/
|
|
1752
1753
|
insert(e, t) {
|
|
1753
1754
|
if (e < 0 || e > this.items.value.length) {
|
|
1754
|
-
|
|
1755
|
+
w.handle(
|
|
1755
1756
|
new Error(
|
|
1756
1757
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1757
1758
|
),
|
|
1758
1759
|
"ArrayNode.insert",
|
|
1759
|
-
|
|
1760
|
+
E.LOG
|
|
1760
1761
|
);
|
|
1761
1762
|
return;
|
|
1762
1763
|
}
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1764
|
+
const i = this.createItem(t), r = [...this.items.value];
|
|
1765
|
+
r.splice(e, 0, i), this.items.value = r;
|
|
1765
1766
|
}
|
|
1766
1767
|
/**
|
|
1767
1768
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1780,18 +1781,18 @@ class W extends M {
|
|
|
1780
1781
|
* ```
|
|
1781
1782
|
*/
|
|
1782
1783
|
move(e, t) {
|
|
1783
|
-
const
|
|
1784
|
-
if (e < 0 || e >=
|
|
1785
|
-
|
|
1786
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${
|
|
1784
|
+
const i = this.items.value.length;
|
|
1785
|
+
if (e < 0 || e >= i || t < 0 || t >= i) {
|
|
1786
|
+
w.handle(
|
|
1787
|
+
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${i})`),
|
|
1787
1788
|
"ArrayNode.move",
|
|
1788
|
-
|
|
1789
|
+
E.LOG
|
|
1789
1790
|
);
|
|
1790
1791
|
return;
|
|
1791
1792
|
}
|
|
1792
1793
|
if (e === t) return;
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1794
|
+
const r = [...this.items.value], [n] = r.splice(e, 1);
|
|
1795
|
+
r.splice(t, 0, n), this.items.value = r;
|
|
1795
1796
|
}
|
|
1796
1797
|
/**
|
|
1797
1798
|
* Поменять местами два элемента массива
|
|
@@ -1808,18 +1809,18 @@ class W extends M {
|
|
|
1808
1809
|
* ```
|
|
1809
1810
|
*/
|
|
1810
1811
|
swap(e, t) {
|
|
1811
|
-
const
|
|
1812
|
-
if (e < 0 || e >=
|
|
1813
|
-
|
|
1814
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${
|
|
1812
|
+
const i = this.items.value.length;
|
|
1813
|
+
if (e < 0 || e >= i || t < 0 || t >= i) {
|
|
1814
|
+
w.handle(
|
|
1815
|
+
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${i})`),
|
|
1815
1816
|
"ArrayNode.swap",
|
|
1816
|
-
|
|
1817
|
+
E.LOG
|
|
1817
1818
|
);
|
|
1818
1819
|
return;
|
|
1819
1820
|
}
|
|
1820
1821
|
if (e === t) return;
|
|
1821
|
-
const
|
|
1822
|
-
[
|
|
1822
|
+
const r = [...this.items.value];
|
|
1823
|
+
[r[e], r[t]] = [r[t], r[e]], this.items.value = r;
|
|
1823
1824
|
}
|
|
1824
1825
|
/**
|
|
1825
1826
|
* Удалить все элементы массива
|
|
@@ -1850,13 +1851,13 @@ class W extends M {
|
|
|
1850
1851
|
return this.items.value.map((e) => e.getValue());
|
|
1851
1852
|
}
|
|
1852
1853
|
setValue(e, t) {
|
|
1853
|
-
this.clear(), e.forEach((
|
|
1854
|
-
|
|
1854
|
+
this.clear(), e.forEach((i) => this.push(i)), t?.emitEvent !== !1 && this.validate().catch((i) => {
|
|
1855
|
+
w.handle(i, "ArrayNode.setValue", E.LOG);
|
|
1855
1856
|
});
|
|
1856
1857
|
}
|
|
1857
1858
|
patchValue(e) {
|
|
1858
|
-
e.forEach((t,
|
|
1859
|
-
this.items.value[
|
|
1859
|
+
e.forEach((t, i) => {
|
|
1860
|
+
this.items.value[i] && t !== void 0 && this.items.value[i].patchValue(t);
|
|
1860
1861
|
});
|
|
1861
1862
|
}
|
|
1862
1863
|
/**
|
|
@@ -1894,7 +1895,7 @@ class W extends M {
|
|
|
1894
1895
|
* @example
|
|
1895
1896
|
* ```typescript
|
|
1896
1897
|
* const arrayNode = new ArrayNode(
|
|
1897
|
-
* { name: { value: '', component:
|
|
1898
|
+
* { name: { value: '', component: Input } },
|
|
1898
1899
|
* [{ name: 'Initial 1' }, { name: 'Initial 2' }]
|
|
1899
1900
|
* );
|
|
1900
1901
|
*
|
|
@@ -1984,9 +1985,9 @@ class W extends M {
|
|
|
1984
1985
|
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
1985
1986
|
*/
|
|
1986
1987
|
forEach(e) {
|
|
1987
|
-
this.items.value.forEach((t,
|
|
1988
|
-
const
|
|
1989
|
-
e(
|
|
1988
|
+
this.items.value.forEach((t, i) => {
|
|
1989
|
+
const r = t.getProxy();
|
|
1990
|
+
e(r, i);
|
|
1990
1991
|
});
|
|
1991
1992
|
}
|
|
1992
1993
|
/**
|
|
@@ -1995,9 +1996,9 @@ class W extends M {
|
|
|
1995
1996
|
* @returns Новый массив результатов
|
|
1996
1997
|
*/
|
|
1997
1998
|
map(e) {
|
|
1998
|
-
return this.items.value.map((t,
|
|
1999
|
-
const
|
|
2000
|
-
return e(
|
|
1999
|
+
return this.items.value.map((t, i) => {
|
|
2000
|
+
const r = t.getProxy();
|
|
2001
|
+
return e(r, i);
|
|
2001
2002
|
});
|
|
2002
2003
|
}
|
|
2003
2004
|
// ============================================================================
|
|
@@ -2087,7 +2088,7 @@ class W extends M {
|
|
|
2087
2088
|
});
|
|
2088
2089
|
}
|
|
2089
2090
|
}
|
|
2090
|
-
class
|
|
2091
|
+
class ue {
|
|
2091
2092
|
/**
|
|
2092
2093
|
* Создает узел формы на основе конфигурации
|
|
2093
2094
|
*
|
|
@@ -2110,25 +2111,25 @@ class ve {
|
|
|
2110
2111
|
* // FieldNode
|
|
2111
2112
|
* const field = factory.createNode({
|
|
2112
2113
|
* value: 'test@mail.com',
|
|
2113
|
-
* component:
|
|
2114
|
+
* component: Input,
|
|
2114
2115
|
* validators: [required, email]
|
|
2115
2116
|
* });
|
|
2116
2117
|
*
|
|
2117
2118
|
* // GroupNode
|
|
2118
2119
|
* const group = factory.createNode({
|
|
2119
|
-
* email: { value: '', component:
|
|
2120
|
-
* password: { value: '', component:
|
|
2120
|
+
* email: { value: '', component: Input },
|
|
2121
|
+
* password: { value: '', component: Input }
|
|
2121
2122
|
* });
|
|
2122
2123
|
*
|
|
2123
2124
|
* // ArrayNode (объект)
|
|
2124
2125
|
* const array = factory.createNode({
|
|
2125
|
-
* schema: { title: { value: '', component:
|
|
2126
|
+
* schema: { title: { value: '', component: Input } },
|
|
2126
2127
|
* initialItems: [{ title: 'Item 1' }]
|
|
2127
2128
|
* });
|
|
2128
2129
|
*
|
|
2129
2130
|
* // ArrayNode (массив) - новый формат
|
|
2130
2131
|
* const array2 = factory.createNode([
|
|
2131
|
-
* { title: { value: '', component:
|
|
2132
|
+
* { title: { value: '', component: Input } }, // schema
|
|
2132
2133
|
* { title: 'Item 1' }, // initial item 1
|
|
2133
2134
|
* { title: 'Item 2' } // initial item 2
|
|
2134
2135
|
* ]);
|
|
@@ -2138,9 +2139,9 @@ class ve {
|
|
|
2138
2139
|
if (Array.isArray(e) && e.length >= 1)
|
|
2139
2140
|
return this.createArrayNodeFromArray(e);
|
|
2140
2141
|
if (this.isFieldConfig(e))
|
|
2141
|
-
return new
|
|
2142
|
+
return new ne(e);
|
|
2142
2143
|
if (this.isArrayConfig(e))
|
|
2143
|
-
return new
|
|
2144
|
+
return new j(
|
|
2144
2145
|
e.schema,
|
|
2145
2146
|
e.initialItems
|
|
2146
2147
|
);
|
|
@@ -2170,7 +2171,7 @@ class ve {
|
|
|
2170
2171
|
*
|
|
2171
2172
|
* // Массив с начальными элементами
|
|
2172
2173
|
* const array = factory.createArrayNodeFromArray([
|
|
2173
|
-
* { title: { value: '', component:
|
|
2174
|
+
* { title: { value: '', component: Input } }, // schema
|
|
2174
2175
|
* { title: 'Item 1' }, // initial value
|
|
2175
2176
|
* { title: 'Item 2' } // initial value
|
|
2176
2177
|
* ]);
|
|
@@ -2179,11 +2180,11 @@ class ve {
|
|
|
2179
2180
|
*/
|
|
2180
2181
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2181
2182
|
createArrayNodeFromArray(e) {
|
|
2182
|
-
const [t, ...
|
|
2183
|
-
this.isGroupConfig(t) &&
|
|
2184
|
-
for (const n of
|
|
2185
|
-
this.isGroupConfig(n) ?
|
|
2186
|
-
return new
|
|
2183
|
+
const [t, ...i] = e, r = [];
|
|
2184
|
+
this.isGroupConfig(t) && r.push(this.extractValues(t));
|
|
2185
|
+
for (const n of i)
|
|
2186
|
+
this.isGroupConfig(n) ? r.push(this.extractValues(n)) : r.push(n);
|
|
2187
|
+
return new j(t, r);
|
|
2187
2188
|
}
|
|
2188
2189
|
/**
|
|
2189
2190
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2191,7 +2192,7 @@ class ve {
|
|
|
2191
2192
|
* ✅ НОВОЕ: Извлечено из GroupNode для централизации логики
|
|
2192
2193
|
*
|
|
2193
2194
|
* Преобразует схему формы в объект со значениями:
|
|
2194
|
-
* - `{ name: { value: 'John', component:
|
|
2195
|
+
* - `{ name: { value: 'John', component: Input } } → { name: 'John' }`
|
|
2195
2196
|
* - Поддерживает вложенные группы
|
|
2196
2197
|
* - Поддерживает массивы
|
|
2197
2198
|
*
|
|
@@ -2203,10 +2204,10 @@ class ve {
|
|
|
2203
2204
|
* const factory = new NodeFactory();
|
|
2204
2205
|
*
|
|
2205
2206
|
* const schema = {
|
|
2206
|
-
* name: { value: 'John', component:
|
|
2207
|
-
* age: { value: 30, component:
|
|
2207
|
+
* name: { value: 'John', component: Input },
|
|
2208
|
+
* age: { value: 30, component: Input },
|
|
2208
2209
|
* address: {
|
|
2209
|
-
* city: { value: 'Moscow', component:
|
|
2210
|
+
* city: { value: 'Moscow', component: Input }
|
|
2210
2211
|
* }
|
|
2211
2212
|
* };
|
|
2212
2213
|
*
|
|
@@ -2221,8 +2222,8 @@ class ve {
|
|
|
2221
2222
|
return e.map((t) => this.extractValues(t));
|
|
2222
2223
|
if (this.isGroupConfig(e)) {
|
|
2223
2224
|
const t = {};
|
|
2224
|
-
for (const [
|
|
2225
|
-
t[
|
|
2225
|
+
for (const [i, r] of Object.entries(e))
|
|
2226
|
+
t[i] = this.extractValues(r);
|
|
2226
2227
|
return t;
|
|
2227
2228
|
}
|
|
2228
2229
|
return e;
|
|
@@ -2241,7 +2242,7 @@ class ve {
|
|
|
2241
2242
|
* ```typescript
|
|
2242
2243
|
* const factory = new NodeFactory();
|
|
2243
2244
|
*
|
|
2244
|
-
* factory.isFieldConfig({ value: '', component:
|
|
2245
|
+
* factory.isFieldConfig({ value: '', component: Input }); // true
|
|
2245
2246
|
* factory.isFieldConfig({ email: { value: '' } }); // false
|
|
2246
2247
|
* factory.isFieldConfig(null); // false
|
|
2247
2248
|
* ```
|
|
@@ -2266,7 +2267,7 @@ class ve {
|
|
|
2266
2267
|
* const factory = new NodeFactory();
|
|
2267
2268
|
*
|
|
2268
2269
|
* factory.isArrayConfig({ schema: {}, initialItems: [] }); // true
|
|
2269
|
-
* factory.isArrayConfig({ value: '', component:
|
|
2270
|
+
* factory.isArrayConfig({ value: '', component: Input }); // false
|
|
2270
2271
|
* factory.isArrayConfig({ email: { value: '' } }); // false
|
|
2271
2272
|
* ```
|
|
2272
2273
|
*/
|
|
@@ -2289,11 +2290,11 @@ class ve {
|
|
|
2289
2290
|
* const factory = new NodeFactory();
|
|
2290
2291
|
*
|
|
2291
2292
|
* factory.isGroupConfig({
|
|
2292
|
-
* email: { value: '', component:
|
|
2293
|
-
* password: { value: '', component:
|
|
2293
|
+
* email: { value: '', component: Input },
|
|
2294
|
+
* password: { value: '', component: Input }
|
|
2294
2295
|
* }); // true
|
|
2295
2296
|
*
|
|
2296
|
-
* factory.isGroupConfig({ value: '', component:
|
|
2297
|
+
* factory.isGroupConfig({ value: '', component: Input }); // false
|
|
2297
2298
|
* factory.isGroupConfig({ schema: {} }); // false
|
|
2298
2299
|
* factory.isGroupConfig(null); // false
|
|
2299
2300
|
* ```
|
|
@@ -2302,43 +2303,43 @@ class ve {
|
|
|
2302
2303
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2303
2304
|
}
|
|
2304
2305
|
}
|
|
2305
|
-
class
|
|
2306
|
+
class de extends N {
|
|
2306
2307
|
/**
|
|
2307
2308
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2308
2309
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
2309
2310
|
* импорта с `create-form`). Обычно `(item) => createForm({ model: item, schema: itemSchema(item) })`.
|
|
2310
2311
|
*/
|
|
2311
2312
|
constructor(e, t) {
|
|
2312
|
-
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync =
|
|
2313
|
-
const
|
|
2314
|
-
for (let
|
|
2315
|
-
const
|
|
2316
|
-
if (!
|
|
2317
|
-
let o = this.cache.get(
|
|
2318
|
-
o || (o = t(
|
|
2313
|
+
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = g(() => {
|
|
2314
|
+
const r = e.length, n = [], a = [];
|
|
2315
|
+
for (let l = 0; l < r; l++) {
|
|
2316
|
+
const c = e.at(l);
|
|
2317
|
+
if (!c) continue;
|
|
2318
|
+
let o = this.cache.get(c);
|
|
2319
|
+
o || (o = t(c), this.cache.set(c, o)), n.push(c), a.push(o);
|
|
2319
2320
|
}
|
|
2320
|
-
const
|
|
2321
|
-
for (const
|
|
2322
|
-
if (
|
|
2323
|
-
const
|
|
2324
|
-
this.cache.delete(
|
|
2321
|
+
const u = new Set(n), d = [];
|
|
2322
|
+
for (const l of this.mountedModels) {
|
|
2323
|
+
if (u.has(l)) continue;
|
|
2324
|
+
const c = this.cache.get(l);
|
|
2325
|
+
this.cache.delete(l), c && d.push(c);
|
|
2325
2326
|
}
|
|
2326
|
-
this.mountedModels = n, this.itemNodes.value = a, d.forEach((
|
|
2327
|
-
}), this.length =
|
|
2328
|
-
const
|
|
2327
|
+
this.mountedModels = n, this.itemNodes.value = a, d.forEach((l) => this.disposeItemNode(l));
|
|
2328
|
+
}), this.length = h(() => this.itemNodes.value.length), this.value = h(() => this.itemNodes.value.map((r) => r.value.value));
|
|
2329
|
+
const i = O({
|
|
2329
2330
|
getChildren: () => this.itemNodes.value,
|
|
2330
2331
|
ownErrors: this._arrayErrors
|
|
2331
2332
|
});
|
|
2332
|
-
this.valid =
|
|
2333
|
+
this.valid = i.valid, this.invalid = i.invalid, this.pending = i.pending, this.touched = i.touched, this.dirty = i.dirty, this.errors = i.errors, this.status = i.status;
|
|
2333
2334
|
}
|
|
2334
|
-
itemNodes =
|
|
2335
|
+
itemNodes = m([]);
|
|
2335
2336
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
2336
2337
|
cache = /* @__PURE__ */ new WeakMap();
|
|
2337
2338
|
// Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
|
|
2338
2339
|
// реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
|
|
2339
2340
|
mountedModels = [];
|
|
2340
2341
|
initial;
|
|
2341
|
-
_arrayErrors =
|
|
2342
|
+
_arrayErrors = m([]);
|
|
2342
2343
|
disposeSync;
|
|
2343
2344
|
/**
|
|
2344
2345
|
* Сигнал per-item форм. Публичен в т.ч. чтобы `isArrayNode` распознавал узел как массив
|
|
@@ -2361,10 +2362,10 @@ class me extends M {
|
|
|
2361
2362
|
return this.itemNodes.value[e];
|
|
2362
2363
|
}
|
|
2363
2364
|
map(e) {
|
|
2364
|
-
return this.itemNodes.value.map((t,
|
|
2365
|
+
return this.itemNodes.value.map((t, i) => e(t, i));
|
|
2365
2366
|
}
|
|
2366
2367
|
forEach(e) {
|
|
2367
|
-
this.itemNodes.value.forEach((t,
|
|
2368
|
+
this.itemNodes.value.forEach((t, i) => e(t, i));
|
|
2368
2369
|
}
|
|
2369
2370
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2370
2371
|
push(e) {
|
|
@@ -2464,9 +2465,8 @@ class me extends M {
|
|
|
2464
2465
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2465
2466
|
}
|
|
2466
2467
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
if (s == null || typeof s != "object" || s instanceof j) return;
|
|
2468
|
+
function C(s, e, t) {
|
|
2469
|
+
if (s == null || typeof s != "object" || $(s)) return;
|
|
2470
2470
|
if (typeof s.getProxy == "function") {
|
|
2471
2471
|
process.env.NODE_ENV !== "production" && console.warn(
|
|
2472
2472
|
"[reformer] createForm({ schema }): в схему попал узел формы (FormProxy) — он пропущен. Стройте дерево для createForm БЕЗ формы, а форму донесите до узла вторым проходом (билдер `(model, form?) => …`) либо через render-behavior `patchProps({ form })`."
|
|
@@ -2474,270 +2474,171 @@ function I(s, e, t) {
|
|
|
2474
2474
|
return;
|
|
2475
2475
|
}
|
|
2476
2476
|
if (Array.isArray(s)) {
|
|
2477
|
-
for (const n of s)
|
|
2477
|
+
for (const n of s) C(n, e, t);
|
|
2478
2478
|
return;
|
|
2479
2479
|
}
|
|
2480
|
-
const
|
|
2481
|
-
if (
|
|
2482
|
-
t.set(
|
|
2480
|
+
const i = s, r = i.array;
|
|
2481
|
+
if (r && typeof r.__path == "string" && typeof i.item == "function") {
|
|
2482
|
+
t.set(r.__path, i.item);
|
|
2483
2483
|
return;
|
|
2484
2484
|
}
|
|
2485
|
-
|
|
2486
|
-
component:
|
|
2487
|
-
componentProps:
|
|
2488
|
-
updateOn:
|
|
2489
|
-
disabled:
|
|
2490
|
-
debounce:
|
|
2491
|
-
}) : process.env.NODE_ENV !== "production" &&
|
|
2492
|
-
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path
|
|
2485
|
+
$(i.value) ? e.set(i.value, {
|
|
2486
|
+
component: i.component,
|
|
2487
|
+
componentProps: i.componentProps,
|
|
2488
|
+
updateOn: i.updateOn,
|
|
2489
|
+
disabled: i.disabled,
|
|
2490
|
+
debounce: i.debounce
|
|
2491
|
+
}) : process.env.NODE_ENV !== "production" && i.component !== void 0 && ("valueSignal" in i || i.value != null) && console.warn(
|
|
2492
|
+
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>` (лист или массив); проверьте, что не передан `value: model.<path>` (value-прокси), группа или `valueSignal:`."
|
|
2493
2493
|
);
|
|
2494
|
-
for (const [n, a] of Object.entries(
|
|
2495
|
-
n !== "value" &&
|
|
2494
|
+
for (const [n, a] of Object.entries(i))
|
|
2495
|
+
n !== "value" && C(a, e, t);
|
|
2496
2496
|
}
|
|
2497
|
-
function
|
|
2498
|
-
const
|
|
2499
|
-
for (const
|
|
2500
|
-
const
|
|
2501
|
-
if (
|
|
2497
|
+
function q(s, e, t, i, r) {
|
|
2498
|
+
const n = {};
|
|
2499
|
+
for (const a of Object.keys(s)) {
|
|
2500
|
+
const u = e === "" ? a : `${e}.${a}`, d = s[a];
|
|
2501
|
+
if (L(d)) {
|
|
2502
|
+
const l = i.has(u) ? void 0 : t.get(d);
|
|
2503
|
+
if (l !== void 0) {
|
|
2504
|
+
const c = d;
|
|
2505
|
+
n[a] = { ...l, valueSignal: c }, r.push({ path: u, signal: c });
|
|
2506
|
+
}
|
|
2502
2507
|
continue;
|
|
2503
|
-
|
|
2504
|
-
|
|
2508
|
+
}
|
|
2509
|
+
if (d instanceof Y) {
|
|
2510
|
+
n[a] = { ...t.get(d) ?? {}, valueSignal: d }, r.push({ path: u, signal: d });
|
|
2505
2511
|
continue;
|
|
2506
2512
|
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
function X(s, e, t) {
|
|
2515
|
-
for (const [r, i] of Object.entries(s)) {
|
|
2516
|
-
const n = e === "" ? r : `${e}.${r}`;
|
|
2517
|
-
Array.isArray(i) || (J(i) ? X(i, n, t) : t.push(n));
|
|
2513
|
+
n[a] = q(
|
|
2514
|
+
d,
|
|
2515
|
+
u,
|
|
2516
|
+
t,
|
|
2517
|
+
i,
|
|
2518
|
+
r
|
|
2519
|
+
);
|
|
2518
2520
|
}
|
|
2521
|
+
return n;
|
|
2519
2522
|
}
|
|
2520
|
-
function
|
|
2521
|
-
const { model: e, schema: t, behavior:
|
|
2522
|
-
t !== void 0 &&
|
|
2523
|
-
const a =
|
|
2524
|
-
for (const
|
|
2525
|
-
if (!
|
|
2526
|
-
const
|
|
2527
|
-
if (!
|
|
2528
|
-
const
|
|
2523
|
+
function H(s) {
|
|
2524
|
+
const { model: e, schema: t, behavior: i } = s, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2525
|
+
t !== void 0 && C(t, r, n);
|
|
2526
|
+
const a = e.$, u = [], d = q(a, "", r, n, u), l = new A(d);
|
|
2527
|
+
for (const o of Object.keys(a)) {
|
|
2528
|
+
if (!L(a[o])) continue;
|
|
2529
|
+
const f = n.get(o);
|
|
2530
|
+
if (!f) continue;
|
|
2531
|
+
const p = e[o], v = (S) => H({ model: S, schema: f(S) }), b = new de(p, v);
|
|
2529
2532
|
l.fields.set(o, b);
|
|
2530
2533
|
}
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
p instanceof A && p.registerFieldSignal(c, f);
|
|
2534
|
+
const c = l.getProxy();
|
|
2535
|
+
for (const { path: o, signal: f } of u) {
|
|
2536
|
+
const p = l.getFieldByPath(o);
|
|
2537
|
+
if (p) {
|
|
2538
|
+
J(f, p);
|
|
2539
|
+
const v = o.lastIndexOf("."), b = v === -1 ? l : l.getFieldByPath(o.slice(0, v));
|
|
2540
|
+
b instanceof A && b.registerFieldSignal(p, f);
|
|
2539
2541
|
}
|
|
2540
2542
|
}
|
|
2541
|
-
return
|
|
2543
|
+
return i && l.attachBehaviorCleanup(i.__run(e, c)), c;
|
|
2542
2544
|
}
|
|
2543
|
-
const
|
|
2544
|
-
function
|
|
2545
|
-
return
|
|
2545
|
+
const ce = (s) => s != null && typeof s == "object" && "model" in s && typeof s.model?.signalAt == "function";
|
|
2546
|
+
function he(s) {
|
|
2547
|
+
return ce(s) ? H(s) : new A(s).getProxy();
|
|
2546
2548
|
}
|
|
2547
|
-
const
|
|
2549
|
+
const fe = () => {
|
|
2548
2550
|
};
|
|
2549
|
-
function
|
|
2551
|
+
function ve(s, e) {
|
|
2550
2552
|
if (!e) return;
|
|
2551
|
-
const t = typeof e == "function" ? { schema: e } : e,
|
|
2552
|
-
() =>
|
|
2553
|
+
const t = typeof e == "function" ? { schema: e } : e, i = Object.keys(t.steps ?? {}), r = i.map((o) => t.steps?.[o]).filter((o) => o != null), n = t.schema ?? Q(
|
|
2554
|
+
() => Z(...r, ...t.extras ? [t.extras] : [])
|
|
2553
2555
|
), a = (o) => {
|
|
2554
|
-
const f = typeof o == "number" ?
|
|
2556
|
+
const f = typeof o == "number" ? i[o - 1] : o;
|
|
2555
2557
|
return (f != null ? t.steps?.[f] : null) ?? null;
|
|
2556
|
-
}, { strategy:
|
|
2557
|
-
strategy:
|
|
2558
|
+
}, { strategy: u, debounce: d, liveAfterSubmit: l } = t, c = P(s, n, {
|
|
2559
|
+
strategy: u,
|
|
2558
2560
|
debounce: d,
|
|
2559
|
-
liveAfterSubmit:
|
|
2561
|
+
liveAfterSubmit: l
|
|
2560
2562
|
});
|
|
2561
2563
|
return {
|
|
2562
2564
|
schema: n,
|
|
2563
|
-
stepSelectors:
|
|
2564
|
-
validate: () =>
|
|
2565
|
-
validateAll: () =>
|
|
2566
|
-
validateStep: (o) =>
|
|
2565
|
+
stepSelectors: i,
|
|
2566
|
+
validate: () => c.validate(),
|
|
2567
|
+
validateAll: () => c.validate(),
|
|
2568
|
+
validateStep: (o) => X(s, a(o) ?? fe, { touch: !0 }),
|
|
2567
2569
|
createStepController: (o) => {
|
|
2568
|
-
if (!
|
|
2570
|
+
if (!u || u === "submit") return null;
|
|
2569
2571
|
const f = a(o);
|
|
2570
|
-
return f ?
|
|
2572
|
+
return f ? P(s, f, { strategy: u, debounce: d, liveAfterSubmit: l }) : null;
|
|
2571
2573
|
},
|
|
2572
|
-
controller:
|
|
2573
|
-
validating:
|
|
2574
|
+
controller: c,
|
|
2575
|
+
validating: c.validating
|
|
2574
2576
|
};
|
|
2575
2577
|
}
|
|
2576
|
-
function
|
|
2578
|
+
function Oe(s) {
|
|
2577
2579
|
if (!s.model && s.initial === void 0)
|
|
2578
2580
|
throw new Error("createCoreForm: provide either `initial` (to create a model) or `model`.");
|
|
2579
|
-
const e = s.model ??
|
|
2581
|
+
const e = s.model ?? K(s.initial);
|
|
2580
2582
|
s.seed?.(e);
|
|
2581
|
-
const t =
|
|
2583
|
+
const t = he({
|
|
2582
2584
|
model: e,
|
|
2583
2585
|
...s.schema ? { schema: s.schema(e) } : {},
|
|
2584
2586
|
...s.behavior ? { behavior: s.behavior } : {}
|
|
2585
|
-
}),
|
|
2586
|
-
return s.setup?.(
|
|
2587
|
+
}), i = ve(e, s.validation), r = { model: e, form: t, ...i ? { validation: i } : {} };
|
|
2588
|
+
return s.setup?.(r), r;
|
|
2587
2589
|
}
|
|
2588
|
-
function
|
|
2590
|
+
function M(s) {
|
|
2589
2591
|
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2590
2592
|
}
|
|
2591
|
-
function
|
|
2592
|
-
return
|
|
2593
|
+
function me(s) {
|
|
2594
|
+
return M(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
|
|
2593
2595
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2594
2596
|
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2595
2597
|
!("fields" in s) && !("items" in s);
|
|
2596
2598
|
}
|
|
2597
|
-
function
|
|
2598
|
-
return
|
|
2599
|
+
function pe(s) {
|
|
2600
|
+
return M(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2599
2601
|
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2600
2602
|
}
|
|
2601
|
-
function
|
|
2602
|
-
return
|
|
2603
|
+
function ye(s) {
|
|
2604
|
+
return M(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
|
|
2603
2605
|
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2604
2606
|
typeof s.removeAt == "function";
|
|
2605
2607
|
}
|
|
2606
|
-
function
|
|
2607
|
-
return
|
|
2608
|
-
}
|
|
2609
|
-
var F = { exports: {} }, P = {};
|
|
2610
|
-
var q;
|
|
2611
|
-
function Ae() {
|
|
2612
|
-
if (q) return P;
|
|
2613
|
-
q = 1;
|
|
2614
|
-
var s = z;
|
|
2615
|
-
function e(o, f) {
|
|
2616
|
-
return o === f && (o !== 0 || 1 / o === 1 / f) || o !== o && f !== f;
|
|
2617
|
-
}
|
|
2618
|
-
var t = typeof Object.is == "function" ? Object.is : e, r = s.useState, i = s.useEffect, n = s.useLayoutEffect, a = s.useDebugValue;
|
|
2619
|
-
function l(o, f) {
|
|
2620
|
-
var c = f(), v = r({ inst: { value: c, getSnapshot: f } }), p = v[0].inst, b = v[1];
|
|
2621
|
-
return n(
|
|
2622
|
-
function() {
|
|
2623
|
-
p.value = c, p.getSnapshot = f, d(p) && b({ inst: p });
|
|
2624
|
-
},
|
|
2625
|
-
[o, c, f]
|
|
2626
|
-
), i(
|
|
2627
|
-
function() {
|
|
2628
|
-
return d(p) && b({ inst: p }), o(function() {
|
|
2629
|
-
d(p) && b({ inst: p });
|
|
2630
|
-
});
|
|
2631
|
-
},
|
|
2632
|
-
[o]
|
|
2633
|
-
), a(c), c;
|
|
2634
|
-
}
|
|
2635
|
-
function d(o) {
|
|
2636
|
-
var f = o.getSnapshot;
|
|
2637
|
-
o = o.value;
|
|
2638
|
-
try {
|
|
2639
|
-
var c = f();
|
|
2640
|
-
return !t(o, c);
|
|
2641
|
-
} catch {
|
|
2642
|
-
return !0;
|
|
2643
|
-
}
|
|
2644
|
-
}
|
|
2645
|
-
function u(o, f) {
|
|
2646
|
-
return f();
|
|
2647
|
-
}
|
|
2648
|
-
var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2649
|
-
return P.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : h, P;
|
|
2650
|
-
}
|
|
2651
|
-
var T = {};
|
|
2652
|
-
var K;
|
|
2653
|
-
function we() {
|
|
2654
|
-
return K || (K = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2655
|
-
function s(c, v) {
|
|
2656
|
-
return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
|
|
2657
|
-
}
|
|
2658
|
-
function e(c, v) {
|
|
2659
|
-
h || i.startTransition === void 0 || (h = !0, console.error(
|
|
2660
|
-
"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."
|
|
2661
|
-
));
|
|
2662
|
-
var p = v();
|
|
2663
|
-
if (!o) {
|
|
2664
|
-
var b = v();
|
|
2665
|
-
n(p, b) || (console.error(
|
|
2666
|
-
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2667
|
-
), o = !0);
|
|
2668
|
-
}
|
|
2669
|
-
b = a({
|
|
2670
|
-
inst: { value: p, getSnapshot: v }
|
|
2671
|
-
});
|
|
2672
|
-
var y = b[0].inst, w = b[1];
|
|
2673
|
-
return d(
|
|
2674
|
-
function() {
|
|
2675
|
-
y.value = p, y.getSnapshot = v, t(y) && w({ inst: y });
|
|
2676
|
-
},
|
|
2677
|
-
[c, p, v]
|
|
2678
|
-
), l(
|
|
2679
|
-
function() {
|
|
2680
|
-
return t(y) && w({ inst: y }), c(function() {
|
|
2681
|
-
t(y) && w({ inst: y });
|
|
2682
|
-
});
|
|
2683
|
-
},
|
|
2684
|
-
[c]
|
|
2685
|
-
), u(p), p;
|
|
2686
|
-
}
|
|
2687
|
-
function t(c) {
|
|
2688
|
-
var v = c.getSnapshot;
|
|
2689
|
-
c = c.value;
|
|
2690
|
-
try {
|
|
2691
|
-
var p = v();
|
|
2692
|
-
return !n(c, p);
|
|
2693
|
-
} catch {
|
|
2694
|
-
return !0;
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
function r(c, v) {
|
|
2698
|
-
return v();
|
|
2699
|
-
}
|
|
2700
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2701
|
-
var i = z, 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;
|
|
2702
|
-
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());
|
|
2703
|
-
})()), T;
|
|
2704
|
-
}
|
|
2705
|
-
var H;
|
|
2706
|
-
function Ve() {
|
|
2707
|
-
return H || (H = 1, process.env.NODE_ENV === "production" ? F.exports = Ae() : F.exports = we()), F.exports;
|
|
2608
|
+
function Te(s) {
|
|
2609
|
+
return me(s) ? "FieldNode" : pe(s) ? "GroupNode" : ye(s) ? "ArrayNode" : M(s) ? "FormNode" : "Unknown";
|
|
2708
2610
|
}
|
|
2709
|
-
|
|
2710
|
-
function ke(s, e) {
|
|
2611
|
+
function ge(s, e) {
|
|
2711
2612
|
if (s === e) return !0;
|
|
2712
2613
|
if (s.length !== e.length) return !1;
|
|
2713
2614
|
for (let t = 0; t < s.length; t++)
|
|
2714
2615
|
if (s[t] !== e[t]) return !1;
|
|
2715
2616
|
return !0;
|
|
2716
2617
|
}
|
|
2717
|
-
function
|
|
2718
|
-
const
|
|
2618
|
+
function T(s, e, t, i) {
|
|
2619
|
+
const r = _(null), n = _(s);
|
|
2719
2620
|
n.current = s;
|
|
2720
|
-
const a =
|
|
2621
|
+
const a = _(e);
|
|
2721
2622
|
a.current = e;
|
|
2722
|
-
const
|
|
2723
|
-
if (
|
|
2724
|
-
const
|
|
2623
|
+
const u = _(t);
|
|
2624
|
+
if (u.current = t, r.current === null) {
|
|
2625
|
+
const c = {};
|
|
2725
2626
|
for (const o in s)
|
|
2726
|
-
|
|
2727
|
-
|
|
2627
|
+
c[o] = s[o].value;
|
|
2628
|
+
r.current = { ...c, __snapshot: null };
|
|
2728
2629
|
}
|
|
2729
|
-
const d =
|
|
2730
|
-
(
|
|
2630
|
+
const d = y(
|
|
2631
|
+
(c) => {
|
|
2731
2632
|
let o = !0;
|
|
2732
|
-
return
|
|
2733
|
-
const
|
|
2734
|
-
for (const v in
|
|
2735
|
-
|
|
2633
|
+
return g(() => {
|
|
2634
|
+
const p = n.current;
|
|
2635
|
+
for (const v in p)
|
|
2636
|
+
p[v].value;
|
|
2736
2637
|
if (o) {
|
|
2737
2638
|
o = !1;
|
|
2738
2639
|
return;
|
|
2739
2640
|
}
|
|
2740
|
-
|
|
2641
|
+
c();
|
|
2741
2642
|
});
|
|
2742
2643
|
},
|
|
2743
2644
|
// subscriptionKey намеренно не читается в теле — он здесь КЛЮЧ ИДЕНТИЧНОСТИ подписки (см. JSDoc
|
|
@@ -2745,33 +2646,33 @@ function $(s, e, t, r) {
|
|
|
2745
2646
|
// навсегда: подмена контрола на другой узел перестанет пересоздавать effect. Тот же приём ниже
|
|
2746
2647
|
// у getSnapshot.
|
|
2747
2648
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2748
|
-
[
|
|
2749
|
-
),
|
|
2750
|
-
const
|
|
2649
|
+
[i]
|
|
2650
|
+
), l = y(() => {
|
|
2651
|
+
const c = r.current, o = n.current, f = {};
|
|
2751
2652
|
for (const v in o)
|
|
2752
2653
|
f[v] = o[v].value;
|
|
2753
|
-
let
|
|
2654
|
+
let p = !1;
|
|
2754
2655
|
for (const v of a.current) {
|
|
2755
|
-
const { key:
|
|
2756
|
-
if (
|
|
2757
|
-
if (!
|
|
2758
|
-
|
|
2656
|
+
const { key: b, useShallowArrayEqual: S } = v, D = f[b], I = c[b];
|
|
2657
|
+
if (S) {
|
|
2658
|
+
if (!ge(I, D)) {
|
|
2659
|
+
p = !0;
|
|
2759
2660
|
break;
|
|
2760
2661
|
}
|
|
2761
|
-
} else if (
|
|
2762
|
-
|
|
2662
|
+
} else if (I !== D) {
|
|
2663
|
+
p = !0;
|
|
2763
2664
|
break;
|
|
2764
2665
|
}
|
|
2765
2666
|
}
|
|
2766
|
-
if (!
|
|
2767
|
-
return
|
|
2667
|
+
if (!p && c.__snapshot)
|
|
2668
|
+
return c.__snapshot;
|
|
2768
2669
|
for (const v in o)
|
|
2769
|
-
|
|
2770
|
-
return
|
|
2771
|
-
}, [
|
|
2772
|
-
return
|
|
2670
|
+
c[v] = f[v];
|
|
2671
|
+
return c.__snapshot = u.current(f), c.__snapshot;
|
|
2672
|
+
}, [i]);
|
|
2673
|
+
return F.useSyncExternalStore(d, l, l);
|
|
2773
2674
|
}
|
|
2774
|
-
function
|
|
2675
|
+
function be(s) {
|
|
2775
2676
|
const e = {
|
|
2776
2677
|
value: s.value,
|
|
2777
2678
|
disabled: s.disabled,
|
|
@@ -2794,24 +2695,24 @@ function Oe(s) {
|
|
|
2794
2695
|
{ key: "dirty" },
|
|
2795
2696
|
{ key: "shouldShowError" },
|
|
2796
2697
|
{ key: "componentProps" }
|
|
2797
|
-
],
|
|
2798
|
-
(
|
|
2799
|
-
value:
|
|
2800
|
-
pending:
|
|
2801
|
-
disabled:
|
|
2802
|
-
errors:
|
|
2803
|
-
valid:
|
|
2804
|
-
invalid:
|
|
2805
|
-
touched:
|
|
2806
|
-
dirty:
|
|
2807
|
-
shouldShowError:
|
|
2808
|
-
componentProps:
|
|
2698
|
+
], i = y(
|
|
2699
|
+
(r) => ({
|
|
2700
|
+
value: r.value,
|
|
2701
|
+
pending: r.pending,
|
|
2702
|
+
disabled: r.disabled,
|
|
2703
|
+
errors: r.errors,
|
|
2704
|
+
valid: r.valid,
|
|
2705
|
+
invalid: r.invalid,
|
|
2706
|
+
touched: r.touched,
|
|
2707
|
+
dirty: r.dirty,
|
|
2708
|
+
shouldShowError: r.shouldShowError,
|
|
2709
|
+
componentProps: r.componentProps
|
|
2809
2710
|
}),
|
|
2810
2711
|
[]
|
|
2811
2712
|
);
|
|
2812
|
-
return
|
|
2713
|
+
return T(e, t, i, s);
|
|
2813
2714
|
}
|
|
2814
|
-
function
|
|
2715
|
+
function Ee(s) {
|
|
2815
2716
|
const e = {
|
|
2816
2717
|
value: s.value,
|
|
2817
2718
|
length: s.length,
|
|
@@ -2832,24 +2733,24 @@ function Ne(s) {
|
|
|
2832
2733
|
{ key: "touched" },
|
|
2833
2734
|
{ key: "dirty" },
|
|
2834
2735
|
{ key: "disabled" }
|
|
2835
|
-
],
|
|
2836
|
-
(
|
|
2837
|
-
value:
|
|
2838
|
-
length:
|
|
2839
|
-
pending:
|
|
2840
|
-
errors:
|
|
2841
|
-
valid:
|
|
2842
|
-
invalid:
|
|
2843
|
-
touched:
|
|
2844
|
-
dirty:
|
|
2845
|
-
disabled:
|
|
2736
|
+
], i = y(
|
|
2737
|
+
(r) => ({
|
|
2738
|
+
value: r.value,
|
|
2739
|
+
length: r.length,
|
|
2740
|
+
pending: r.pending,
|
|
2741
|
+
errors: r.errors,
|
|
2742
|
+
valid: r.valid,
|
|
2743
|
+
invalid: r.invalid,
|
|
2744
|
+
touched: r.touched,
|
|
2745
|
+
dirty: r.dirty,
|
|
2746
|
+
disabled: r.disabled
|
|
2846
2747
|
}),
|
|
2847
2748
|
[]
|
|
2848
2749
|
);
|
|
2849
|
-
return
|
|
2750
|
+
return T(e, t, i, s);
|
|
2850
2751
|
}
|
|
2851
|
-
function
|
|
2852
|
-
const s =
|
|
2752
|
+
function _e() {
|
|
2753
|
+
const s = y(
|
|
2853
2754
|
() => ({
|
|
2854
2755
|
value: [],
|
|
2855
2756
|
length: 0,
|
|
@@ -2863,113 +2764,159 @@ function Fe() {
|
|
|
2863
2764
|
}),
|
|
2864
2765
|
[]
|
|
2865
2766
|
);
|
|
2866
|
-
return
|
|
2767
|
+
return T({}, [], s);
|
|
2867
2768
|
}
|
|
2868
|
-
function
|
|
2769
|
+
function De(s) {
|
|
2869
2770
|
const e = s && "length" in s && "map" in s;
|
|
2870
|
-
return s ? e ?
|
|
2771
|
+
return s ? e ? Ee(s) : be(s) : _e();
|
|
2871
2772
|
}
|
|
2872
|
-
function
|
|
2873
|
-
const e =
|
|
2874
|
-
(
|
|
2773
|
+
function Ie(s) {
|
|
2774
|
+
const e = _({ value: s.value.value }), t = y(
|
|
2775
|
+
(r) => {
|
|
2875
2776
|
let n = !0;
|
|
2876
|
-
return
|
|
2777
|
+
return g(() => {
|
|
2877
2778
|
if (s.value.value, n) {
|
|
2878
2779
|
n = !1;
|
|
2879
2780
|
return;
|
|
2880
2781
|
}
|
|
2881
|
-
|
|
2782
|
+
r();
|
|
2882
2783
|
});
|
|
2883
2784
|
},
|
|
2884
2785
|
[s]
|
|
2885
|
-
),
|
|
2886
|
-
const
|
|
2887
|
-
return e.current.value ===
|
|
2786
|
+
), i = y(() => {
|
|
2787
|
+
const r = s.value.value;
|
|
2788
|
+
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
2888
2789
|
}, [s]);
|
|
2889
|
-
return
|
|
2790
|
+
return F.useSyncExternalStore(t, i, i);
|
|
2890
2791
|
}
|
|
2891
|
-
function
|
|
2892
|
-
const e =
|
|
2893
|
-
(
|
|
2792
|
+
function Re(s) {
|
|
2793
|
+
const e = _({ length: s.length.value }), t = y(
|
|
2794
|
+
(r) => {
|
|
2894
2795
|
let n = !0;
|
|
2895
|
-
return
|
|
2796
|
+
return g(() => {
|
|
2896
2797
|
if (s.length.value, n) {
|
|
2897
2798
|
n = !1;
|
|
2898
2799
|
return;
|
|
2899
2800
|
}
|
|
2900
|
-
|
|
2801
|
+
r();
|
|
2901
2802
|
});
|
|
2902
2803
|
},
|
|
2903
2804
|
[s]
|
|
2904
|
-
),
|
|
2905
|
-
const
|
|
2906
|
-
return e.current.length ===
|
|
2805
|
+
), i = y(() => {
|
|
2806
|
+
const r = s.length.value;
|
|
2807
|
+
return e.current.length === r ? e.current.length : (e.current.length = r, r);
|
|
2907
2808
|
}, [s]);
|
|
2908
|
-
return
|
|
2809
|
+
return F.useSyncExternalStore(t, i, i);
|
|
2909
2810
|
}
|
|
2910
|
-
function
|
|
2911
|
-
const { model: e, schema: t, strategy:
|
|
2912
|
-
() =>
|
|
2913
|
-
[e, t,
|
|
2811
|
+
function $e(s) {
|
|
2812
|
+
const { model: e, schema: t, strategy: i, debounce: r, liveAfterSubmit: n } = s, a = ee(
|
|
2813
|
+
() => P(e, t, { strategy: i, debounce: r, liveAfterSubmit: n }),
|
|
2814
|
+
[e, t, i, r, n]
|
|
2914
2815
|
);
|
|
2915
|
-
|
|
2916
|
-
const
|
|
2917
|
-
|
|
2816
|
+
U(() => a.start(), [a]);
|
|
2817
|
+
const u = F.useSyncExternalStore(
|
|
2818
|
+
y((l) => a.validating.subscribe(l), [a]),
|
|
2918
2819
|
() => a.validating.peek(),
|
|
2919
2820
|
() => !1
|
|
2920
2821
|
// SSR: прогон не идёт
|
|
2921
|
-
), d =
|
|
2922
|
-
return { submit: d, validate: d, isValidating:
|
|
2822
|
+
), d = y(() => a.validate(), [a]);
|
|
2823
|
+
return { submit: d, validate: d, isValidating: u };
|
|
2923
2824
|
}
|
|
2924
2825
|
function Be(s) {
|
|
2925
|
-
const [e] =
|
|
2926
|
-
return
|
|
2826
|
+
const [e] = te(s), t = e.validation?.controller;
|
|
2827
|
+
return U(() => t?.start(), [t]), e;
|
|
2828
|
+
}
|
|
2829
|
+
const Ae = ["labelTooltip"];
|
|
2830
|
+
function Ge(s) {
|
|
2831
|
+
if (!(s == null || typeof s != "function" && typeof s != "object"))
|
|
2832
|
+
return s.reformerAdapter;
|
|
2833
|
+
}
|
|
2834
|
+
const W = (s) => s;
|
|
2835
|
+
function je(s, e, t = {}) {
|
|
2836
|
+
const i = { ...t };
|
|
2837
|
+
for (const n of Ae) delete i[n];
|
|
2838
|
+
for (const n of s?.strip ?? []) delete i[n];
|
|
2839
|
+
if (!s)
|
|
2840
|
+
return { ...i, value: e.value, onChange: e.onChange, onBlur: e.onBlur };
|
|
2841
|
+
const r = s.fromEmit ?? W;
|
|
2842
|
+
return {
|
|
2843
|
+
...i,
|
|
2844
|
+
[s.valueProp ?? "value"]: (s.toValue ?? W)(e.value),
|
|
2845
|
+
[s.changeProp ?? "onChange"]: (n) => e.onChange(r(n, i)),
|
|
2846
|
+
...s.bindBlur ? s.bindBlur(e.onBlur) : { onBlur: e.onBlur }
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
function we(s) {
|
|
2850
|
+
return {
|
|
2851
|
+
focus: () => s.current?.focus(),
|
|
2852
|
+
blur: () => s.current?.blur(),
|
|
2853
|
+
scrollIntoView: (e) => s.current?.scrollIntoView(e),
|
|
2854
|
+
getElement: () => s.current
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
function ke(s) {
|
|
2858
|
+
return typeof s == "object" && s !== null && s.nodeType === 1;
|
|
2859
|
+
}
|
|
2860
|
+
function We(s) {
|
|
2861
|
+
const e = _(null);
|
|
2862
|
+
return se(s, () => Ve(e)), e;
|
|
2863
|
+
}
|
|
2864
|
+
function Ve(s) {
|
|
2865
|
+
const e = s.current;
|
|
2866
|
+
return e == null || ke(e) ? we(s) : e;
|
|
2927
2867
|
}
|
|
2928
|
-
const
|
|
2868
|
+
const Le = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2929
2869
|
export {
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2870
|
+
j as ArrayNode,
|
|
2871
|
+
Le as CORE_RUNTIME_TOKEN,
|
|
2872
|
+
E as ErrorStrategy,
|
|
2873
|
+
Ae as FIELD_WRAPPER_ONLY_PROPS,
|
|
2874
|
+
ne as FieldNode,
|
|
2875
|
+
w as FormErrorHandler,
|
|
2876
|
+
N as FormNode,
|
|
2877
|
+
oe as FormSubmitter,
|
|
2937
2878
|
A as GroupNode,
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
Ze as
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2879
|
+
de as ModelArrayNode,
|
|
2880
|
+
ue as NodeFactory,
|
|
2881
|
+
x as SubscriptionManager,
|
|
2882
|
+
je as bindFieldProps,
|
|
2883
|
+
ve as buildValidation,
|
|
2884
|
+
Ze as computeFrom,
|
|
2885
|
+
et as copyFrom,
|
|
2886
|
+
Oe as createCoreForm,
|
|
2887
|
+
he as createForm,
|
|
2888
|
+
H as createFormFromModel,
|
|
2889
|
+
K as createModel,
|
|
2890
|
+
ht as disableWhen,
|
|
2891
|
+
He as eachLeafSignal,
|
|
2892
|
+
Ke as eachValueSignal,
|
|
2893
|
+
ft as enableWhen,
|
|
2894
|
+
Ge as getFieldAdapter,
|
|
2895
|
+
dt as getNodeForSignal,
|
|
2896
|
+
Te as getNodeType,
|
|
2897
|
+
ye as isArrayNode,
|
|
2898
|
+
R as isDerived,
|
|
2899
|
+
me as isFieldNode,
|
|
2900
|
+
M as isFormNode,
|
|
2901
|
+
pe as isGroupNode,
|
|
2902
|
+
Ye as isModelContainerSignal,
|
|
2903
|
+
$ as isValueSignal,
|
|
2904
|
+
we as makeElementFieldHandle,
|
|
2905
|
+
Je as markDerived,
|
|
2906
|
+
J as registerSignalNode,
|
|
2907
|
+
tt as resetWhen,
|
|
2908
|
+
st as revalidateWhen,
|
|
2909
|
+
it as runOutsideEffect,
|
|
2964
2910
|
rt as safeCallback,
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2911
|
+
nt as safeDebouncedCallback,
|
|
2912
|
+
at as syncFields,
|
|
2913
|
+
ot as transformValue,
|
|
2914
|
+
Qe as unmarkDerived,
|
|
2915
|
+
Re as useArrayLength,
|
|
2916
|
+
We as useFieldHandleRef,
|
|
2970
2917
|
Be as useFormBundle,
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2918
|
+
De as useFormControl,
|
|
2919
|
+
Ie as useFormControlValue,
|
|
2920
|
+
$e as useFormValidation,
|
|
2921
|
+
lt as watchField
|
|
2975
2922
|
};
|