@reformer/core 11.0.0-beta.6 → 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/types/contracts.d.ts +6 -0
- 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 +639 -736
- 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/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/{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/03-api-signatures.md +6 -0
- package/docs/llms/10-arrays.md +30 -0
- package/docs/llms/34-i18n.md +272 -0
- package/llms-index.json +1 -1
- package/llms.txt +1589 -98
- 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
|
|
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
|
*
|
|
@@ -90,19 +91,19 @@ class M {
|
|
|
90
91
|
* ```
|
|
91
92
|
*/
|
|
92
93
|
getErrors(e) {
|
|
93
|
-
const
|
|
94
|
-
return e ?
|
|
95
|
-
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(
|
|
94
|
+
const t = this.errors.value;
|
|
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
|
-
}) :
|
|
105
|
+
return !(e.predicate !== void 0 && !e.predicate(i));
|
|
106
|
+
}) : t;
|
|
106
107
|
}
|
|
107
108
|
// ============================================================================
|
|
108
109
|
// Методы управления состоянием (Template Method)
|
|
@@ -274,7 +275,7 @@ class M {
|
|
|
274
275
|
onEnable() {
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
|
-
class
|
|
278
|
+
class x {
|
|
278
279
|
/**
|
|
279
280
|
* Хранилище подписок
|
|
280
281
|
* Ключ: уникальный идентификатор подписки
|
|
@@ -309,8 +310,8 @@ class R {
|
|
|
309
310
|
* manager.remove('anotherSub');
|
|
310
311
|
* ```
|
|
311
312
|
*/
|
|
312
|
-
add(e,
|
|
313
|
-
return this.subscriptions.has(e) && (process.env.NODE_ENV !== "production" && console.warn(`[SubscriptionManager] Subscription "${e}" already exists, replacing`), this.subscriptions.get(e)?.()), this.subscriptions.set(e,
|
|
313
|
+
add(e, t) {
|
|
314
|
+
return this.subscriptions.has(e) && (process.env.NODE_ENV !== "production" && console.warn(`[SubscriptionManager] Subscription "${e}" already exists, replacing`), this.subscriptions.get(e)?.()), this.subscriptions.set(e, t), () => this.remove(e);
|
|
314
315
|
}
|
|
315
316
|
/**
|
|
316
317
|
* Удаляет подписку по ключу
|
|
@@ -334,8 +335,8 @@ class R {
|
|
|
334
335
|
* ```
|
|
335
336
|
*/
|
|
336
337
|
remove(e) {
|
|
337
|
-
const
|
|
338
|
-
return
|
|
338
|
+
const t = this.subscriptions.get(e);
|
|
339
|
+
return t ? (t(), this.subscriptions.delete(e), !0) : !1;
|
|
339
340
|
}
|
|
340
341
|
/**
|
|
341
342
|
* Очищает все подписки
|
|
@@ -442,7 +443,7 @@ class R {
|
|
|
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 F = {
|
|
|
452
453
|
/** GroupNode.watchField() */
|
|
453
454
|
WatchField: "watchField"
|
|
454
455
|
};
|
|
455
|
-
let
|
|
456
|
-
function
|
|
457
|
-
return `${
|
|
456
|
+
let ie = 0;
|
|
457
|
+
function V(s) {
|
|
458
|
+
return `${s}-${++ie}`;
|
|
458
459
|
}
|
|
459
|
-
var
|
|
460
|
-
class
|
|
461
|
-
static handle(e,
|
|
462
|
-
const
|
|
463
|
-
switch (process.env.NODE_ENV !== "production" && console.error(`[${
|
|
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,8 +469,8 @@ class k {
|
|
|
468
469
|
case "convert":
|
|
469
470
|
return {
|
|
470
471
|
code: "validator_error",
|
|
471
|
-
message:
|
|
472
|
-
params: { field:
|
|
472
|
+
message: r,
|
|
473
|
+
params: { field: t }
|
|
473
474
|
};
|
|
474
475
|
}
|
|
475
476
|
}
|
|
@@ -524,11 +525,11 @@ class k {
|
|
|
524
525
|
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
525
526
|
* ```
|
|
526
527
|
*/
|
|
527
|
-
static createValidationError(e,
|
|
528
|
+
static createValidationError(e, t, i) {
|
|
528
529
|
return {
|
|
529
530
|
code: e,
|
|
530
|
-
message:
|
|
531
|
-
params:
|
|
531
|
+
message: t,
|
|
532
|
+
params: i ? { field: i } : void 0
|
|
532
533
|
};
|
|
533
534
|
}
|
|
534
535
|
/**
|
|
@@ -550,7 +551,7 @@ class k {
|
|
|
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 ce {
|
|
|
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 ce {
|
|
|
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 he 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
|
}
|
|
@@ -718,15 +719,15 @@ class he extends M {
|
|
|
718
719
|
getValue() {
|
|
719
720
|
return this._value.peek();
|
|
720
721
|
}
|
|
721
|
-
setValue(e,
|
|
722
|
-
if (this._value.value = e, this._dirty.value = !0,
|
|
722
|
+
setValue(e, t) {
|
|
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);
|
|
@@ -816,23 +817,23 @@ class he extends M {
|
|
|
816
817
|
* ```
|
|
817
818
|
*/
|
|
818
819
|
async validate(e) {
|
|
819
|
-
const
|
|
820
|
-
if (this.cancelPendingValidation(),
|
|
820
|
+
const t = e?.debounce ?? this.debounceMs;
|
|
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
|
-
},
|
|
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
|
);
|
|
@@ -849,52 +850,52 @@ class he extends M {
|
|
|
849
850
|
* - Проверяет signal.aborted в ключевых точках
|
|
850
851
|
*/
|
|
851
852
|
async validateImmediate(e) {
|
|
852
|
-
const
|
|
853
|
-
e || this.currentAbortController?.abort(), this.currentAbortController =
|
|
854
|
-
const { signal:
|
|
853
|
+
const t = e ?? new AbortController();
|
|
854
|
+
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
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,12 +905,12 @@ class he 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
|
|
912
|
-
this.statusMachine.setErrors(
|
|
912
|
+
const t = e.some((i) => i.severity !== "warning");
|
|
913
|
+
this.statusMachine.setErrors(t);
|
|
913
914
|
}
|
|
914
915
|
clearErrors() {
|
|
915
916
|
this._errors.value = [], this.statusMachine.setErrors(!1);
|
|
@@ -1027,12 +1028,12 @@ class he extends M {
|
|
|
1027
1028
|
* ```
|
|
1028
1029
|
*/
|
|
1029
1030
|
watch(e) {
|
|
1030
|
-
const
|
|
1031
|
+
const t = new AbortController(), i = g(() => {
|
|
1031
1032
|
const n = this.value.value;
|
|
1032
|
-
e(n,
|
|
1033
|
-
}),
|
|
1034
|
-
return this.disposers.add(
|
|
1035
|
-
|
|
1033
|
+
e(n, t.signal);
|
|
1034
|
+
}), r = V(k.Watch);
|
|
1035
|
+
return this.disposers.add(r, () => {
|
|
1036
|
+
t.abort(), i();
|
|
1036
1037
|
});
|
|
1037
1038
|
}
|
|
1038
1039
|
/**
|
|
@@ -1057,12 +1058,12 @@ class he extends M {
|
|
|
1057
1058
|
* useEffect(() => dispose, []);
|
|
1058
1059
|
* ```
|
|
1059
1060
|
*/
|
|
1060
|
-
computeFrom(e,
|
|
1061
|
-
const
|
|
1062
|
-
const n = e.map((
|
|
1061
|
+
computeFrom(e, t) {
|
|
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 he extends M {
|
|
|
1092
1093
|
}
|
|
1093
1094
|
}
|
|
1094
1095
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const { getChildren: e, ownErrors:
|
|
1097
|
-
const o = [...
|
|
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(() => {
|
|
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
|
-
function
|
|
1113
|
-
return typeof
|
|
1113
|
+
function B(s) {
|
|
1114
|
+
return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
|
|
1114
1115
|
}
|
|
1115
|
-
const
|
|
1116
|
-
function
|
|
1117
|
-
let
|
|
1118
|
-
const
|
|
1119
|
-
if (!
|
|
1120
|
-
const
|
|
1116
|
+
const G = "$";
|
|
1117
|
+
function ae(s, e) {
|
|
1118
|
+
let t;
|
|
1119
|
+
const i = () => {
|
|
1120
|
+
if (!t) {
|
|
1121
|
+
const r = {};
|
|
1121
1122
|
e.forEach((n, a) => {
|
|
1122
|
-
|
|
1123
|
-
}),
|
|
1123
|
+
r[a] = n && B(n) ? n.getProxy() : n;
|
|
1124
|
+
}), t = r;
|
|
1124
1125
|
}
|
|
1125
|
-
return
|
|
1126
|
+
return t;
|
|
1126
1127
|
};
|
|
1127
|
-
return new Proxy(
|
|
1128
|
-
get: (
|
|
1129
|
-
if (n ===
|
|
1130
|
-
return
|
|
1131
|
-
if (n in
|
|
1132
|
-
return
|
|
1128
|
+
return new Proxy(s, {
|
|
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
|
-
return a &&
|
|
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 ve {
|
|
|
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
|
*
|
|
@@ -1188,9 +1189,9 @@ class ve {
|
|
|
1188
1189
|
* }
|
|
1189
1190
|
* ```
|
|
1190
1191
|
*/
|
|
1191
|
-
async submit(e,
|
|
1192
|
-
const { skipValidation:
|
|
1193
|
-
if (
|
|
1192
|
+
async submit(e, t) {
|
|
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 {
|
|
@@ -1223,9 +1224,9 @@ class ve {
|
|
|
1223
1224
|
* }
|
|
1224
1225
|
* ```
|
|
1225
1226
|
*/
|
|
1226
|
-
async submitWithResult(e,
|
|
1227
|
-
const { skipValidation:
|
|
1228
|
-
if (
|
|
1227
|
+
async submitWithResult(e, t) {
|
|
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 ve {
|
|
|
1241
1242
|
}
|
|
1242
1243
|
}
|
|
1243
1244
|
}
|
|
1244
|
-
function
|
|
1245
|
+
function le(s) {
|
|
1245
1246
|
const e = [];
|
|
1246
|
-
for (const
|
|
1247
|
-
const
|
|
1248
|
-
if (!
|
|
1249
|
-
e.push(
|
|
1247
|
+
for (const t of s.split(".")) {
|
|
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
|
|
1254
|
+
class A extends N {
|
|
1254
1255
|
// ============================================================================
|
|
1255
1256
|
// Приватные поля
|
|
1256
1257
|
// ============================================================================
|
|
@@ -1263,7 +1264,7 @@ class w 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 w 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 w 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 w extends M {
|
|
|
1306
1307
|
status;
|
|
1307
1308
|
submitting;
|
|
1308
1309
|
constructor(e) {
|
|
1309
|
-
super(), this.formSubmitter = new
|
|
1310
|
-
const
|
|
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 w 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((
|
|
1344
|
-
e[
|
|
1344
|
+
return this._fields.forEach((t, i) => {
|
|
1345
|
+
e[i] = t.getValue();
|
|
1345
1346
|
}), e;
|
|
1346
1347
|
}
|
|
1347
|
-
setValue(e,
|
|
1348
|
-
for (const [
|
|
1349
|
-
const n = this._fields.get(
|
|
1348
|
+
setValue(e, t) {
|
|
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 [
|
|
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 w extends M {
|
|
|
1384
1385
|
* ```
|
|
1385
1386
|
*/
|
|
1386
1387
|
reset(e) {
|
|
1387
|
-
this._formErrors.value = [], this._fields.forEach((
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1388
|
+
this._formErrors.value = [], this._fields.forEach((t, i) => {
|
|
1389
|
+
const r = e?.[i];
|
|
1390
|
+
t.reset(r);
|
|
1390
1391
|
});
|
|
1391
1392
|
}
|
|
1392
1393
|
/**
|
|
@@ -1398,8 +1399,8 @@ class w extends M {
|
|
|
1398
1399
|
});
|
|
1399
1400
|
}
|
|
1400
1401
|
async validate() {
|
|
1401
|
-
return this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((
|
|
1402
|
-
(
|
|
1402
|
+
return this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((t) => t.validate())), Array.from(this._fields.values()).every(
|
|
1403
|
+
(t) => t.valid.value || t.disabled.value
|
|
1403
1404
|
);
|
|
1404
1405
|
}
|
|
1405
1406
|
/**
|
|
@@ -1485,8 +1486,8 @@ class w extends M {
|
|
|
1485
1486
|
* `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
|
|
1486
1487
|
* используйте {@link submitWithResult}, который возвращает явный флаг `success`.
|
|
1487
1488
|
*/
|
|
1488
|
-
async submit(e,
|
|
1489
|
-
return this.formSubmitter.submit(e,
|
|
1489
|
+
async submit(e, t) {
|
|
1490
|
+
return this.formSubmitter.submit(e, t);
|
|
1490
1491
|
}
|
|
1491
1492
|
/**
|
|
1492
1493
|
* Отправить форму с расширенным результатом
|
|
@@ -1495,8 +1496,8 @@ class w extends M {
|
|
|
1495
1496
|
* @param options - Опции submit
|
|
1496
1497
|
* @returns Объект SubmitResult с данными, статусом и возможной ошибкой
|
|
1497
1498
|
*/
|
|
1498
|
-
async submitWithResult(e,
|
|
1499
|
-
return this.formSubmitter.submitWithResult(e,
|
|
1499
|
+
async submitWithResult(e, t) {
|
|
1500
|
+
return this.formSubmitter.submitWithResult(e, t);
|
|
1500
1501
|
}
|
|
1501
1502
|
/**
|
|
1502
1503
|
* Получить вложенное поле по пути
|
|
@@ -1530,21 +1531,21 @@ class w extends M {
|
|
|
1530
1531
|
getFieldByPath(e) {
|
|
1531
1532
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1532
1533
|
return;
|
|
1533
|
-
const
|
|
1534
|
-
if (
|
|
1534
|
+
const t = le(e);
|
|
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 w extends M {
|
|
|
1573
1574
|
/**
|
|
1574
1575
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1575
1576
|
*/
|
|
1576
|
-
linkFields(e,
|
|
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
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1613,27 +1614,27 @@ class w extends M {
|
|
|
1613
1614
|
* ```
|
|
1614
1615
|
*/
|
|
1615
1616
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1616
|
-
watchField(e,
|
|
1617
|
-
const
|
|
1618
|
-
if (!
|
|
1617
|
+
watchField(e, t) {
|
|
1618
|
+
const i = this.getFieldByPath(e);
|
|
1619
|
+
if (!i)
|
|
1619
1620
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1620
|
-
const
|
|
1621
|
-
|
|
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
|
-
watchFieldByPath(e,
|
|
1630
|
-
const
|
|
1631
|
-
if (!
|
|
1630
|
+
watchFieldByPath(e, t) {
|
|
1631
|
+
const i = this.getFieldByPath(e);
|
|
1632
|
+
if (!i)
|
|
1632
1633
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1633
|
-
const
|
|
1634
|
-
|
|
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()
|
|
@@ -1660,8 +1661,8 @@ class w extends M {
|
|
|
1660
1661
|
* @internal
|
|
1661
1662
|
*/
|
|
1662
1663
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1663
|
-
registerFieldSignal(e,
|
|
1664
|
-
this._fieldSignals.set(e,
|
|
1664
|
+
registerFieldSignal(e, t) {
|
|
1665
|
+
this._fieldSignals.set(e, t);
|
|
1665
1666
|
}
|
|
1666
1667
|
/**
|
|
1667
1668
|
* Очистить все ресурсы узла
|
|
@@ -1672,7 +1673,7 @@ class w 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
|
// ============================================================================
|
|
@@ -1701,16 +1702,16 @@ class W extends M {
|
|
|
1701
1702
|
// ============================================================================
|
|
1702
1703
|
// Конструктор
|
|
1703
1704
|
// ============================================================================
|
|
1704
|
-
constructor(e,
|
|
1705
|
-
super(), this.itemSchema = e, this.initialItems =
|
|
1706
|
-
for (const
|
|
1707
|
-
this.push(
|
|
1708
|
-
this.length =
|
|
1709
|
-
const
|
|
1705
|
+
constructor(e, t = []) {
|
|
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 операции
|
|
@@ -1720,8 +1721,8 @@ class W extends M {
|
|
|
1720
1721
|
* @param initialValue - Начальные значения для нового элемента
|
|
1721
1722
|
*/
|
|
1722
1723
|
push(e) {
|
|
1723
|
-
const
|
|
1724
|
-
this.items.value = [...this.items.value,
|
|
1724
|
+
const t = this.createItem(e);
|
|
1725
|
+
this.items.value = [...this.items.value, t];
|
|
1725
1726
|
}
|
|
1726
1727
|
/**
|
|
1727
1728
|
* Удалить элемент по индексу
|
|
@@ -1732,36 +1733,36 @@ 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
|
-
const
|
|
1745
|
-
this.items.value = this.items.value.filter((
|
|
1745
|
+
const t = this.items.value[e];
|
|
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
|
* Вставить элемент в массив
|
|
1749
1750
|
* @param index - Индекс для вставки
|
|
1750
1751
|
* @param initialValue - Начальные значения для нового элемента
|
|
1751
1752
|
*/
|
|
1752
|
-
insert(e,
|
|
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`
|
|
@@ -1779,19 +1780,19 @@ class W extends M {
|
|
|
1779
1780
|
* form.items.move(2, 1);
|
|
1780
1781
|
* ```
|
|
1781
1782
|
*/
|
|
1782
|
-
move(e,
|
|
1783
|
-
const
|
|
1784
|
-
if (e < 0 || e >=
|
|
1785
|
-
|
|
1786
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${
|
|
1783
|
+
move(e, t) {
|
|
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
|
-
if (e ===
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1793
|
+
if (e === t) return;
|
|
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
|
* Поменять местами два элемента массива
|
|
@@ -1807,19 +1808,19 @@ class W extends M {
|
|
|
1807
1808
|
* form.items.swap(0, 2);
|
|
1808
1809
|
* ```
|
|
1809
1810
|
*/
|
|
1810
|
-
swap(e,
|
|
1811
|
-
const
|
|
1812
|
-
if (e < 0 || e >=
|
|
1813
|
-
|
|
1814
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${
|
|
1811
|
+
swap(e, t) {
|
|
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
|
-
if (e ===
|
|
1821
|
-
const
|
|
1822
|
-
[
|
|
1821
|
+
if (e === t) return;
|
|
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
|
* Удалить все элементы массива
|
|
@@ -1829,8 +1830,8 @@ class W extends M {
|
|
|
1829
1830
|
*/
|
|
1830
1831
|
clear() {
|
|
1831
1832
|
const e = [...this.items.value];
|
|
1832
|
-
this.items.value = [], e.forEach((
|
|
1833
|
-
"dispose" in
|
|
1833
|
+
this.items.value = [], e.forEach((t) => {
|
|
1834
|
+
"dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1834
1835
|
});
|
|
1835
1836
|
}
|
|
1836
1837
|
/**
|
|
@@ -1839,9 +1840,9 @@ class W extends M {
|
|
|
1839
1840
|
* @returns Типизированный GroupNode proxy или undefined если индекс вне границ
|
|
1840
1841
|
*/
|
|
1841
1842
|
at(e) {
|
|
1842
|
-
const
|
|
1843
|
-
if (
|
|
1844
|
-
return
|
|
1843
|
+
const t = this.items.value[e];
|
|
1844
|
+
if (t)
|
|
1845
|
+
return t.getProxy();
|
|
1845
1846
|
}
|
|
1846
1847
|
// ============================================================================
|
|
1847
1848
|
// Реализация абстрактных методов
|
|
@@ -1849,14 +1850,14 @@ class W extends M {
|
|
|
1849
1850
|
getValue() {
|
|
1850
1851
|
return this.items.value.map((e) => e.getValue());
|
|
1851
1852
|
}
|
|
1852
|
-
setValue(e,
|
|
1853
|
-
this.clear(), e.forEach((
|
|
1854
|
-
|
|
1853
|
+
setValue(e, t) {
|
|
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((
|
|
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
|
/**
|
|
@@ -1877,7 +1878,7 @@ class W extends M {
|
|
|
1877
1878
|
* ```
|
|
1878
1879
|
*/
|
|
1879
1880
|
reset(e) {
|
|
1880
|
-
this._arrayErrors.value = [], this.clear(), e && e.forEach((
|
|
1881
|
+
this._arrayErrors.value = [], this.clear(), e && e.forEach((t) => this.push(t));
|
|
1881
1882
|
}
|
|
1882
1883
|
/**
|
|
1883
1884
|
* Сбросить массив к исходным значениям (initialItems)
|
|
@@ -1911,7 +1912,7 @@ class W extends M {
|
|
|
1911
1912
|
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1912
1913
|
}
|
|
1913
1914
|
async validate() {
|
|
1914
|
-
return (await Promise.all(this.items.value.map((
|
|
1915
|
+
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean) && this._arrayErrors.value.length === 0;
|
|
1915
1916
|
}
|
|
1916
1917
|
/**
|
|
1917
1918
|
* Установить array-level validation errors
|
|
@@ -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((
|
|
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((
|
|
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
|
// ============================================================================
|
|
@@ -2009,8 +2010,8 @@ class W extends M {
|
|
|
2009
2010
|
*/
|
|
2010
2011
|
createItem(e) {
|
|
2011
2012
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2012
|
-
const
|
|
2013
|
-
return e &&
|
|
2013
|
+
const t = new A(this.itemSchema);
|
|
2014
|
+
return e && t.patchValue(e), t;
|
|
2014
2015
|
}
|
|
2015
2016
|
throw new Error(
|
|
2016
2017
|
"ArrayNode поддерживает только GroupNode элементы. Для массива примитивов используйте обычное поле с типом массива."
|
|
@@ -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
|
*
|
|
@@ -2138,14 +2139,14 @@ class pe {
|
|
|
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
|
);
|
|
2147
2148
|
if (this.isGroupConfig(e))
|
|
2148
|
-
return new
|
|
2149
|
+
return new A(e);
|
|
2149
2150
|
throw new Error(
|
|
2150
2151
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2151
2152
|
e
|
|
@@ -2179,11 +2180,11 @@ class pe {
|
|
|
2179
2180
|
*/
|
|
2180
2181
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2181
2182
|
createArrayNodeFromArray(e) {
|
|
2182
|
-
const [
|
|
2183
|
-
this.isGroupConfig(
|
|
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
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2218,12 +2219,12 @@ class pe {
|
|
|
2218
2219
|
if (this.isFieldConfig(e))
|
|
2219
2220
|
return e.value;
|
|
2220
2221
|
if (Array.isArray(e))
|
|
2221
|
-
return e.map((
|
|
2222
|
+
return e.map((t) => this.extractValues(t));
|
|
2222
2223
|
if (this.isGroupConfig(e)) {
|
|
2223
|
-
const
|
|
2224
|
-
for (const [
|
|
2225
|
-
|
|
2226
|
-
return
|
|
2224
|
+
const t = {};
|
|
2225
|
+
for (const [i, r] of Object.entries(e))
|
|
2226
|
+
t[i] = this.extractValues(r);
|
|
2227
|
+
return t;
|
|
2227
2228
|
}
|
|
2228
2229
|
return e;
|
|
2229
2230
|
}
|
|
@@ -2302,43 +2303,43 @@ class pe {
|
|
|
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
|
-
constructor(e,
|
|
2312
|
-
super(), this.control = e, this.buildItem =
|
|
2313
|
-
const
|
|
2314
|
-
for (let
|
|
2315
|
-
const
|
|
2316
|
-
if (!
|
|
2317
|
-
let o = this.cache.get(
|
|
2318
|
-
o || (o =
|
|
2312
|
+
constructor(e, 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,17 +2362,17 @@ class ye extends M {
|
|
|
2361
2362
|
return this.itemNodes.value[e];
|
|
2362
2363
|
}
|
|
2363
2364
|
map(e) {
|
|
2364
|
-
return this.itemNodes.value.map((
|
|
2365
|
+
return this.itemNodes.value.map((t, i) => e(t, i));
|
|
2365
2366
|
}
|
|
2366
2367
|
forEach(e) {
|
|
2367
|
-
this.itemNodes.value.forEach((
|
|
2368
|
+
this.itemNodes.value.forEach((t, i) => e(t, i));
|
|
2368
2369
|
}
|
|
2369
2370
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2370
2371
|
push(e) {
|
|
2371
2372
|
this.control.push(e ?? {});
|
|
2372
2373
|
}
|
|
2373
|
-
insert(e,
|
|
2374
|
-
this.control.insertAt(e,
|
|
2374
|
+
insert(e, t) {
|
|
2375
|
+
this.control.insertAt(e, t ?? {});
|
|
2375
2376
|
}
|
|
2376
2377
|
removeAt(e) {
|
|
2377
2378
|
this.control.removeAt(e);
|
|
@@ -2380,12 +2381,12 @@ class ye extends M {
|
|
|
2380
2381
|
* Переместить элемент модель-массива. Делегирует мутацию массиву модели; внутренний `effect`
|
|
2381
2382
|
* пересоберёт `itemNodes` в новом порядке (per-item формы сохраняются по кешу идентичности).
|
|
2382
2383
|
*/
|
|
2383
|
-
move(e,
|
|
2384
|
-
this.control.move(e,
|
|
2384
|
+
move(e, t) {
|
|
2385
|
+
this.control.move(e, t);
|
|
2385
2386
|
}
|
|
2386
2387
|
/** Поменять местами два элемента модель-массива (см. {@link move}). */
|
|
2387
|
-
swap(e,
|
|
2388
|
-
this.control.swap(e,
|
|
2388
|
+
swap(e, t) {
|
|
2389
|
+
this.control.swap(e, t);
|
|
2389
2390
|
}
|
|
2390
2391
|
clear() {
|
|
2391
2392
|
this.control.clear();
|
|
@@ -2395,7 +2396,7 @@ class ye extends M {
|
|
|
2395
2396
|
return this.control.toArray();
|
|
2396
2397
|
}
|
|
2397
2398
|
setValue(e) {
|
|
2398
|
-
this.control.clear(), (e ?? []).forEach((
|
|
2399
|
+
this.control.clear(), (e ?? []).forEach((t) => this.control.push(t));
|
|
2399
2400
|
}
|
|
2400
2401
|
patchValue(e) {
|
|
2401
2402
|
this.setValue(e);
|
|
@@ -2409,7 +2410,7 @@ class ye extends M {
|
|
|
2409
2410
|
async validate() {
|
|
2410
2411
|
return (await Promise.all(
|
|
2411
2412
|
this.itemNodes.value.map(
|
|
2412
|
-
(
|
|
2413
|
+
(t) => t.validate()
|
|
2413
2414
|
)
|
|
2414
2415
|
)).every(Boolean) && this._arrayErrors.value.length === 0;
|
|
2415
2416
|
}
|
|
@@ -2464,280 +2465,180 @@ class ye extends M {
|
|
|
2464
2465
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2465
2466
|
}
|
|
2466
2467
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
if (
|
|
2470
|
-
if (typeof t.getProxy == "function") {
|
|
2468
|
+
function C(s, e, t) {
|
|
2469
|
+
if (s == null || typeof s != "object" || $(s)) return;
|
|
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 })`."
|
|
2473
2473
|
);
|
|
2474
2474
|
return;
|
|
2475
2475
|
}
|
|
2476
|
-
if (Array.isArray(
|
|
2477
|
-
for (const n of
|
|
2476
|
+
if (Array.isArray(s)) {
|
|
2477
|
+
for (const n of s) C(n, e, t);
|
|
2478
2478
|
return;
|
|
2479
2479
|
}
|
|
2480
|
-
const
|
|
2481
|
-
if (
|
|
2482
|
-
|
|
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 Z(t, e, s) {
|
|
2515
|
-
for (const [r, i] of Object.entries(t)) {
|
|
2516
|
-
const n = e === "" ? r : `${e}.${r}`;
|
|
2517
|
-
Array.isArray(i) || (Q(i) ? Z(i, n, s) : s.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:
|
|
2522
|
-
|
|
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 w && 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
|
|
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" ?
|
|
2555
|
-
return (f != null ?
|
|
2556
|
-
}, { strategy:
|
|
2557
|
-
strategy:
|
|
2556
|
+
const f = typeof o == "number" ? i[o - 1] : o;
|
|
2557
|
+
return (f != null ? t.steps?.[f] : null) ?? null;
|
|
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
|
|
2577
|
-
if (!
|
|
2578
|
+
function Oe(s) {
|
|
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 =
|
|
2580
|
-
|
|
2581
|
-
const
|
|
2581
|
+
const e = s.model ?? K(s.initial);
|
|
2582
|
+
s.seed?.(e);
|
|
2583
|
+
const t = he({
|
|
2582
2584
|
model: e,
|
|
2583
|
-
...
|
|
2584
|
-
...
|
|
2585
|
-
}),
|
|
2586
|
-
return
|
|
2585
|
+
...s.schema ? { schema: s.schema(e) } : {},
|
|
2586
|
+
...s.behavior ? { behavior: s.behavior } : {}
|
|
2587
|
+
}), i = ve(e, s.validation), r = { model: e, form: t, ...i ? { validation: i } : {} };
|
|
2588
|
+
return s.setup?.(r), r;
|
|
2587
2589
|
}
|
|
2588
|
-
function
|
|
2589
|
-
return
|
|
2590
|
+
function M(s) {
|
|
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
|
-
typeof
|
|
2595
|
-
!("fields" in
|
|
2596
|
-
}
|
|
2597
|
-
function Ae(t) {
|
|
2598
|
-
return C(t) && "getFieldByPath" in t && "fields" in t && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2599
|
-
!("items" in t) && !("push" in t) && !("removeAt" in t);
|
|
2596
|
+
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2597
|
+
!("fields" in s) && !("items" in s);
|
|
2600
2598
|
}
|
|
2601
|
-
function
|
|
2602
|
-
return
|
|
2603
|
-
|
|
2604
|
-
typeof t.removeAt == "function";
|
|
2605
|
-
}
|
|
2606
|
-
function Ue(t) {
|
|
2607
|
-
return Se(t) ? "FieldNode" : Ae(t) ? "GroupNode" : we(t) ? "ArrayNode" : C(t) ? "FormNode" : "Unknown";
|
|
2608
|
-
}
|
|
2609
|
-
var N = { exports: {} }, P = {};
|
|
2610
|
-
var q;
|
|
2611
|
-
function Ve() {
|
|
2612
|
-
if (q) return P;
|
|
2613
|
-
q = 1;
|
|
2614
|
-
var t = Y;
|
|
2615
|
-
function e(o, f) {
|
|
2616
|
-
return o === f && (o !== 0 || 1 / o === 1 / f) || o !== o && f !== f;
|
|
2617
|
-
}
|
|
2618
|
-
var s = typeof Object.is == "function" ? Object.is : e, r = t.useState, i = t.useEffect, n = t.useLayoutEffect, a = t.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 !s(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 = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : h, P;
|
|
2599
|
+
function pe(s) {
|
|
2600
|
+
return M(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2601
|
+
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2650
2602
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
function
|
|
2654
|
-
|
|
2655
|
-
function t(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, V = b[1];
|
|
2673
|
-
return d(
|
|
2674
|
-
function() {
|
|
2675
|
-
y.value = p, y.getSnapshot = v, s(y) && V({ inst: y });
|
|
2676
|
-
},
|
|
2677
|
-
[c, p, v]
|
|
2678
|
-
), l(
|
|
2679
|
-
function() {
|
|
2680
|
-
return s(y) && V({ inst: y }), c(function() {
|
|
2681
|
-
s(y) && V({ inst: y });
|
|
2682
|
-
});
|
|
2683
|
-
},
|
|
2684
|
-
[c]
|
|
2685
|
-
), u(p), p;
|
|
2686
|
-
}
|
|
2687
|
-
function s(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 = Y, n = typeof Object.is == "function" ? Object.is : t, 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;
|
|
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
|
|
2605
|
+
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2606
|
+
typeof s.removeAt == "function";
|
|
2704
2607
|
}
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
return K || (K = 1, process.env.NODE_ENV === "production" ? N.exports = Ve() : N.exports = ke()), N.exports;
|
|
2608
|
+
function Te(s) {
|
|
2609
|
+
return me(s) ? "FieldNode" : pe(s) ? "GroupNode" : ye(s) ? "ArrayNode" : M(s) ? "FormNode" : "Unknown";
|
|
2708
2610
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
if (
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
if (t[s] !== e[s]) return !1;
|
|
2611
|
+
function ge(s, e) {
|
|
2612
|
+
if (s === e) return !0;
|
|
2613
|
+
if (s.length !== e.length) return !1;
|
|
2614
|
+
for (let t = 0; t < s.length; t++)
|
|
2615
|
+
if (s[t] !== e[t]) return !1;
|
|
2715
2616
|
return !0;
|
|
2716
2617
|
}
|
|
2717
|
-
function
|
|
2718
|
-
const
|
|
2719
|
-
n.current =
|
|
2720
|
-
const a =
|
|
2618
|
+
function T(s, e, t, i) {
|
|
2619
|
+
const r = _(null), n = _(s);
|
|
2620
|
+
n.current = s;
|
|
2621
|
+
const a = _(e);
|
|
2721
2622
|
a.current = e;
|
|
2722
|
-
const
|
|
2723
|
-
if (
|
|
2724
|
-
const
|
|
2725
|
-
for (const o in
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
}
|
|
2729
|
-
const d =
|
|
2730
|
-
(
|
|
2623
|
+
const u = _(t);
|
|
2624
|
+
if (u.current = t, r.current === null) {
|
|
2625
|
+
const c = {};
|
|
2626
|
+
for (const o in s)
|
|
2627
|
+
c[o] = s[o].value;
|
|
2628
|
+
r.current = { ...c, __snapshot: null };
|
|
2629
|
+
}
|
|
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,45 +2646,45 @@ function $(t, e, s, 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
|
-
value:
|
|
2777
|
-
disabled:
|
|
2778
|
-
errors:
|
|
2779
|
-
pending:
|
|
2780
|
-
valid:
|
|
2781
|
-
invalid:
|
|
2782
|
-
touched:
|
|
2783
|
-
dirty:
|
|
2784
|
-
shouldShowError:
|
|
2785
|
-
componentProps:
|
|
2786
|
-
},
|
|
2677
|
+
value: s.value,
|
|
2678
|
+
disabled: s.disabled,
|
|
2679
|
+
errors: s.errors,
|
|
2680
|
+
pending: s.pending,
|
|
2681
|
+
valid: s.valid,
|
|
2682
|
+
invalid: s.invalid,
|
|
2683
|
+
touched: s.touched,
|
|
2684
|
+
dirty: s.dirty,
|
|
2685
|
+
shouldShowError: s.shouldShowError,
|
|
2686
|
+
componentProps: s.componentProps
|
|
2687
|
+
}, t = [
|
|
2787
2688
|
{ key: "value" },
|
|
2788
2689
|
{ key: "disabled" },
|
|
2789
2690
|
{ key: "errors", useShallowArrayEqual: !0 },
|
|
@@ -2794,35 +2695,35 @@ function Ne(t) {
|
|
|
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
|
-
value:
|
|
2817
|
-
length:
|
|
2818
|
-
errors:
|
|
2819
|
-
pending:
|
|
2820
|
-
valid:
|
|
2821
|
-
invalid:
|
|
2822
|
-
touched:
|
|
2823
|
-
dirty:
|
|
2824
|
-
disabled:
|
|
2825
|
-
},
|
|
2717
|
+
value: s.value,
|
|
2718
|
+
length: s.length,
|
|
2719
|
+
errors: s.errors,
|
|
2720
|
+
pending: s.pending,
|
|
2721
|
+
valid: s.valid,
|
|
2722
|
+
invalid: s.invalid,
|
|
2723
|
+
touched: s.touched,
|
|
2724
|
+
dirty: s.dirty,
|
|
2725
|
+
disabled: s.disabled
|
|
2726
|
+
}, t = [
|
|
2826
2727
|
{ key: "value" },
|
|
2827
2728
|
{ key: "length" },
|
|
2828
2729
|
{ key: "errors", useShallowArrayEqual: !0 },
|
|
@@ -2832,24 +2733,24 @@ function Me(t) {
|
|
|
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
|
|
2752
|
+
function _e() {
|
|
2753
|
+
const s = y(
|
|
2853
2754
|
() => ({
|
|
2854
2755
|
value: [],
|
|
2855
2756
|
length: 0,
|
|
@@ -2863,157 +2764,159 @@ function Ce() {
|
|
|
2863
2764
|
}),
|
|
2864
2765
|
[]
|
|
2865
2766
|
);
|
|
2866
|
-
return
|
|
2767
|
+
return T({}, [], s);
|
|
2867
2768
|
}
|
|
2868
|
-
function
|
|
2869
|
-
const e =
|
|
2870
|
-
return
|
|
2769
|
+
function De(s) {
|
|
2770
|
+
const e = s && "length" in s && "map" in s;
|
|
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
|
|
2877
|
-
if (
|
|
2777
|
+
return g(() => {
|
|
2778
|
+
if (s.value.value, n) {
|
|
2878
2779
|
n = !1;
|
|
2879
2780
|
return;
|
|
2880
2781
|
}
|
|
2881
|
-
|
|
2782
|
+
r();
|
|
2882
2783
|
});
|
|
2883
2784
|
},
|
|
2884
|
-
[
|
|
2885
|
-
),
|
|
2886
|
-
const
|
|
2887
|
-
return e.current.value ===
|
|
2888
|
-
}, [
|
|
2889
|
-
return
|
|
2785
|
+
[s]
|
|
2786
|
+
), i = y(() => {
|
|
2787
|
+
const r = s.value.value;
|
|
2788
|
+
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
2789
|
+
}, [s]);
|
|
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
|
|
2896
|
-
if (
|
|
2796
|
+
return g(() => {
|
|
2797
|
+
if (s.length.value, n) {
|
|
2897
2798
|
n = !1;
|
|
2898
2799
|
return;
|
|
2899
2800
|
}
|
|
2900
|
-
|
|
2801
|
+
r();
|
|
2901
2802
|
});
|
|
2902
2803
|
},
|
|
2903
|
-
[
|
|
2904
|
-
),
|
|
2905
|
-
const
|
|
2906
|
-
return e.current.length ===
|
|
2907
|
-
}, [
|
|
2908
|
-
return
|
|
2804
|
+
[s]
|
|
2805
|
+
), i = y(() => {
|
|
2806
|
+
const r = s.length.value;
|
|
2807
|
+
return e.current.length === r ? e.current.length : (e.current.length = r, r);
|
|
2808
|
+
}, [s]);
|
|
2809
|
+
return F.useSyncExternalStore(t, i, i);
|
|
2909
2810
|
}
|
|
2910
|
-
function
|
|
2911
|
-
const { model: e, schema:
|
|
2912
|
-
() =>
|
|
2913
|
-
[e,
|
|
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
|
-
function
|
|
2925
|
-
const [e] =
|
|
2926
|
-
return
|
|
2825
|
+
function Be(s) {
|
|
2826
|
+
const [e] = te(s), t = e.validation?.controller;
|
|
2827
|
+
return U(() => t?.start(), [t]), e;
|
|
2927
2828
|
}
|
|
2928
|
-
const
|
|
2929
|
-
function
|
|
2930
|
-
if (!(
|
|
2931
|
-
return
|
|
2829
|
+
const Ae = ["labelTooltip"];
|
|
2830
|
+
function Ge(s) {
|
|
2831
|
+
if (!(s == null || typeof s != "function" && typeof s != "object"))
|
|
2832
|
+
return s.reformerAdapter;
|
|
2932
2833
|
}
|
|
2933
|
-
const
|
|
2934
|
-
function
|
|
2935
|
-
const
|
|
2936
|
-
for (const n of
|
|
2937
|
-
for (const n of
|
|
2938
|
-
if (!
|
|
2939
|
-
return { ...
|
|
2940
|
-
const
|
|
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;
|
|
2941
2842
|
return {
|
|
2942
|
-
...
|
|
2943
|
-
[
|
|
2944
|
-
[
|
|
2945
|
-
...
|
|
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 }
|
|
2946
2847
|
};
|
|
2947
2848
|
}
|
|
2948
|
-
function
|
|
2849
|
+
function we(s) {
|
|
2949
2850
|
return {
|
|
2950
|
-
focus: () =>
|
|
2951
|
-
blur: () =>
|
|
2952
|
-
scrollIntoView: (e) =>
|
|
2953
|
-
getElement: () =>
|
|
2851
|
+
focus: () => s.current?.focus(),
|
|
2852
|
+
blur: () => s.current?.blur(),
|
|
2853
|
+
scrollIntoView: (e) => s.current?.scrollIntoView(e),
|
|
2854
|
+
getElement: () => s.current
|
|
2954
2855
|
};
|
|
2955
2856
|
}
|
|
2956
|
-
function
|
|
2957
|
-
return typeof
|
|
2857
|
+
function ke(s) {
|
|
2858
|
+
return typeof s == "object" && s !== null && s.nodeType === 1;
|
|
2958
2859
|
}
|
|
2959
|
-
function
|
|
2960
|
-
const e =
|
|
2961
|
-
return
|
|
2860
|
+
function We(s) {
|
|
2861
|
+
const e = _(null);
|
|
2862
|
+
return se(s, () => Ve(e)), e;
|
|
2962
2863
|
}
|
|
2963
|
-
function
|
|
2964
|
-
const e =
|
|
2965
|
-
return e == null ||
|
|
2864
|
+
function Ve(s) {
|
|
2865
|
+
const e = s.current;
|
|
2866
|
+
return e == null || ke(e) ? we(s) : e;
|
|
2966
2867
|
}
|
|
2967
|
-
const
|
|
2868
|
+
const Le = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2968
2869
|
export {
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
Qe as
|
|
3014
|
-
|
|
3015
|
-
We as
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
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,
|
|
2878
|
+
A as GroupNode,
|
|
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,
|
|
2910
|
+
rt as safeCallback,
|
|
2911
|
+
nt as safeDebouncedCallback,
|
|
2912
|
+
at as syncFields,
|
|
2913
|
+
ot as transformValue,
|
|
2914
|
+
Qe as unmarkDerived,
|
|
2915
|
+
Re as useArrayLength,
|
|
2916
|
+
We as useFieldHandleRef,
|
|
2917
|
+
Be as useFormBundle,
|
|
2918
|
+
De as useFormControl,
|
|
2919
|
+
Ie as useFormControlValue,
|
|
2920
|
+
$e as useFormValidation,
|
|
2921
|
+
lt as watchField
|
|
3019
2922
|
};
|