@reformer/core 11.0.0-beta.4 → 11.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/create-form.d.ts +6 -4
- package/dist/form/factories/node-factory.d.ts +1 -0
- package/dist/form/nodes/field-node.d.ts +3 -0
- package/dist/form/validators/email.d.ts +5 -6
- package/dist/form/validators/file-type.d.ts +5 -6
- package/dist/form/validators/future-date.d.ts +5 -6
- package/dist/form/validators/index.d.ts +3 -2
- package/dist/form/validators/integer.d.ts +5 -6
- package/dist/form/validators/is-date.d.ts +5 -6
- package/dist/form/validators/is-number.d.ts +5 -6
- package/dist/form/validators/max-age.d.ts +5 -6
- package/dist/form/validators/max-date.d.ts +5 -6
- package/dist/form/validators/max-file-size.d.ts +5 -6
- package/dist/form/validators/max-files.d.ts +5 -6
- package/dist/form/validators/max-length.d.ts +6 -7
- package/dist/form/validators/max-total-file-size.d.ts +5 -6
- package/dist/form/validators/max.d.ts +6 -7
- package/dist/form/validators/min-age.d.ts +5 -6
- package/dist/form/validators/min-date.d.ts +5 -6
- package/dist/form/validators/min-file-size.d.ts +5 -6
- package/dist/form/validators/min-files.d.ts +5 -6
- package/dist/form/validators/min-length.d.ts +6 -7
- package/dist/form/validators/min.d.ts +6 -7
- package/dist/form/validators/multiple-of.d.ts +5 -6
- package/dist/form/validators/non-negative.d.ts +5 -6
- package/dist/form/validators/non-zero.d.ts +5 -6
- package/dist/form/validators/past-date.d.ts +5 -6
- package/dist/form/validators/pattern.d.ts +6 -14
- package/dist/form/validators/phone.d.ts +5 -6
- package/dist/form/validators/required.d.ts +7 -12
- package/dist/form/validators/url.d.ts +7 -12
- package/dist/index.js +423 -376
- 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/index.d.ts +4 -0
- package/docs/llms/02-quick-start.md +3 -3
- package/docs/llms/03-api-signatures.md +4 -4
- package/docs/llms/09-formschema.md +5 -5
- package/docs/llms/10-arrays.md +2 -2
- package/docs/llms/15-project-structure.md +19 -16
- package/docs/llms/16-ui-components.md +34 -7
- package/docs/llms/17-nonexistent-api.md +14 -0
- package/docs/llms/29-async-preload.md +3 -3
- package/docs/llms/30-type-safety-recipes.md +1 -1
- package/llms-index.json +1 -0
- package/llms.txt +2146 -68
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { e as
|
|
3
|
-
import { a as
|
|
4
|
-
import { i as
|
|
5
|
-
import { c as
|
|
6
|
-
import { signal as g, computed as m, effect as _, batch as
|
|
7
|
-
import { r as
|
|
8
|
-
import { g as
|
|
9
|
-
import { f as
|
|
10
|
-
import { d as
|
|
11
|
-
import
|
|
1
|
+
import { c as te } from "./create-model-Dxh9cfLp.js";
|
|
2
|
+
import { e as tt } from "./create-model-Dxh9cfLp.js";
|
|
3
|
+
import { a as B } from "./model-signals-proxy-mV3WGdlO.js";
|
|
4
|
+
import { i as rt, m as it, u as nt } from "./model-signals-proxy-mV3WGdlO.js";
|
|
5
|
+
import { c as ot, a as lt, r as ut, b as dt, d as ct, e as ht, f as ft, s as vt, t as mt, w as pt } from "./behaviors-value-C7dSEhCc.js";
|
|
6
|
+
import { signal as g, computed as m, effect as _, batch as se, Signal as G } from "@preact/signals-core";
|
|
7
|
+
import { r as re } from "./signal-node-registry-tiwel-TV.js";
|
|
8
|
+
import { g as gt } from "./signal-node-registry-tiwel-TV.js";
|
|
9
|
+
import { f as ie, h as D, g as ne, d as ae } from "./strategy-DA3JwxsR.js";
|
|
10
|
+
import { d as Et, e as _t } from "./node-DGEFMTQu.js";
|
|
11
|
+
import Y, { useRef as A, useCallback as E, useMemo as oe, useEffect as J, useState as le, useImperativeHandle as ue } from "react";
|
|
12
12
|
class M {
|
|
13
13
|
// ============================================================================
|
|
14
14
|
// Protected состояние (для Template Method паттерна)
|
|
@@ -90,8 +90,8 @@ class M {
|
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
92
|
getErrors(e) {
|
|
93
|
-
const
|
|
94
|
-
return e ?
|
|
93
|
+
const s = this.errors.value;
|
|
94
|
+
return e ? s.filter((r) => {
|
|
95
95
|
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(r.code) || e.message !== void 0 && !r.message.toLowerCase().includes(e.message.toLowerCase()))
|
|
96
96
|
return !1;
|
|
97
97
|
if (e.params !== void 0) {
|
|
@@ -102,7 +102,7 @@ class M {
|
|
|
102
102
|
return !1;
|
|
103
103
|
}
|
|
104
104
|
return !(e.predicate !== void 0 && !e.predicate(r));
|
|
105
|
-
}) :
|
|
105
|
+
}) : s;
|
|
106
106
|
}
|
|
107
107
|
// ============================================================================
|
|
108
108
|
// Методы управления состоянием (Template Method)
|
|
@@ -274,7 +274,7 @@ class M {
|
|
|
274
274
|
onEnable() {
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
class
|
|
277
|
+
class R {
|
|
278
278
|
/**
|
|
279
279
|
* Хранилище подписок
|
|
280
280
|
* Ключ: уникальный идентификатор подписки
|
|
@@ -309,8 +309,8 @@ class L {
|
|
|
309
309
|
* manager.remove('anotherSub');
|
|
310
310
|
* ```
|
|
311
311
|
*/
|
|
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,
|
|
312
|
+
add(e, s) {
|
|
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, s), () => this.remove(e);
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
316
|
* Удаляет подписку по ключу
|
|
@@ -334,8 +334,8 @@ class L {
|
|
|
334
334
|
* ```
|
|
335
335
|
*/
|
|
336
336
|
remove(e) {
|
|
337
|
-
const
|
|
338
|
-
return
|
|
337
|
+
const s = this.subscriptions.get(e);
|
|
338
|
+
return s ? (s(), this.subscriptions.delete(e), !0) : !1;
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
341
341
|
* Очищает все подписки
|
|
@@ -442,7 +442,7 @@ class L {
|
|
|
442
442
|
this.clear();
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
const
|
|
445
|
+
const F = {
|
|
446
446
|
/** FieldNode.watch() */
|
|
447
447
|
Watch: "watch",
|
|
448
448
|
/** FieldNode.computeFrom() */
|
|
@@ -452,15 +452,15 @@ const O = {
|
|
|
452
452
|
/** GroupNode.watchField() */
|
|
453
453
|
WatchField: "watchField"
|
|
454
454
|
};
|
|
455
|
-
let
|
|
456
|
-
function
|
|
457
|
-
return `${
|
|
455
|
+
let de = 0;
|
|
456
|
+
function O(t) {
|
|
457
|
+
return `${t}-${++de}`;
|
|
458
458
|
}
|
|
459
|
-
var S = /* @__PURE__ */ ((
|
|
460
|
-
class
|
|
461
|
-
static handle(e,
|
|
459
|
+
var S = /* @__PURE__ */ ((t) => (t.THROW = "throw", t.LOG = "log", t.CONVERT = "convert", t))(S || {});
|
|
460
|
+
class k {
|
|
461
|
+
static handle(e, s, r = "throw") {
|
|
462
462
|
const i = this.extractMessage(e);
|
|
463
|
-
switch (process.env.NODE_ENV !== "production" && console.error(`[${
|
|
463
|
+
switch (process.env.NODE_ENV !== "production" && console.error(`[${s}]`, e), r) {
|
|
464
464
|
case "throw":
|
|
465
465
|
throw e;
|
|
466
466
|
case "log":
|
|
@@ -469,7 +469,7 @@ class V {
|
|
|
469
469
|
return {
|
|
470
470
|
code: "validator_error",
|
|
471
471
|
message: i,
|
|
472
|
-
params: { field:
|
|
472
|
+
params: { field: s }
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
475
|
}
|
|
@@ -524,10 +524,10 @@ class V {
|
|
|
524
524
|
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
525
525
|
* ```
|
|
526
526
|
*/
|
|
527
|
-
static createValidationError(e,
|
|
527
|
+
static createValidationError(e, s, r) {
|
|
528
528
|
return {
|
|
529
529
|
code: e,
|
|
530
|
-
message:
|
|
530
|
+
message: s,
|
|
531
531
|
params: r ? { field: r } : void 0
|
|
532
532
|
};
|
|
533
533
|
}
|
|
@@ -550,7 +550,7 @@ class V {
|
|
|
550
550
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
-
class
|
|
553
|
+
class ce {
|
|
554
554
|
/** Внутренний сигнал статуса */
|
|
555
555
|
_status;
|
|
556
556
|
/** Публичный read-only сигнал статуса */
|
|
@@ -650,7 +650,7 @@ class ue {
|
|
|
650
650
|
this._status.value = e ? "invalid" : "valid";
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
-
class
|
|
653
|
+
class he extends M {
|
|
654
654
|
// ============================================================================
|
|
655
655
|
// Приватные сигналы
|
|
656
656
|
// ============================================================================
|
|
@@ -702,13 +702,13 @@ class de extends M {
|
|
|
702
702
|
* Менеджер подписок для централизованного cleanup
|
|
703
703
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
704
704
|
*/
|
|
705
|
-
disposers = new
|
|
705
|
+
disposers = new R();
|
|
706
706
|
component;
|
|
707
707
|
// ============================================================================
|
|
708
708
|
// Конструктор
|
|
709
709
|
// ============================================================================
|
|
710
710
|
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 ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new
|
|
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 ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new ce(e.disabled ? "disabled" : "valid"), this.value = m(() => this._value.value), this.valid = m(() => this.statusMachine.valid.value), this.invalid = m(() => this.statusMachine.invalid.value), this.pending = m(() => this.statusMachine.pending.value), this.status = m(() => this.statusMachine.status.value), this.disabled = m(() => this.statusMachine.disabled.value), this.errors = m(() => this._errors.value), this.componentProps = m(() => this._componentProps.value), this.shouldShowError = m(
|
|
712
712
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
713
713
|
);
|
|
714
714
|
}
|
|
@@ -718,8 +718,8 @@ class de extends M {
|
|
|
718
718
|
getValue() {
|
|
719
719
|
return this._value.peek();
|
|
720
720
|
}
|
|
721
|
-
setValue(e,
|
|
722
|
-
if (this._value.value = e, this._dirty.value = !0,
|
|
721
|
+
setValue(e, s) {
|
|
722
|
+
if (this._value.value = e, this._dirty.value = !0, s?.emitEvent === !1)
|
|
723
723
|
return;
|
|
724
724
|
const r = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
725
725
|
if (this.updateOn === "change") {
|
|
@@ -816,8 +816,8 @@ class de extends M {
|
|
|
816
816
|
* ```
|
|
817
817
|
*/
|
|
818
818
|
async validate(e) {
|
|
819
|
-
const
|
|
820
|
-
if (this.cancelPendingValidation(),
|
|
819
|
+
const s = e?.debounce ?? this.debounceMs;
|
|
820
|
+
if (this.cancelPendingValidation(), s <= 0 || this.asyncValidators.length === 0)
|
|
821
821
|
return this.validateImmediate();
|
|
822
822
|
const r = new AbortController();
|
|
823
823
|
return new Promise((i) => {
|
|
@@ -829,7 +829,7 @@ class de extends M {
|
|
|
829
829
|
this.pendingValidation = void 0;
|
|
830
830
|
const n = await this.validateImmediate(r);
|
|
831
831
|
i(n);
|
|
832
|
-
},
|
|
832
|
+
}, s), r.signal.addEventListener(
|
|
833
833
|
"abort",
|
|
834
834
|
() => {
|
|
835
835
|
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), i(!1);
|
|
@@ -849,9 +849,9 @@ class de extends M {
|
|
|
849
849
|
* - Проверяет signal.aborted в ключевых точках
|
|
850
850
|
*/
|
|
851
851
|
async validateImmediate(e) {
|
|
852
|
-
const
|
|
853
|
-
e || this.currentAbortController?.abort(), this.currentAbortController =
|
|
854
|
-
const { signal: r } =
|
|
852
|
+
const s = e ?? new AbortController();
|
|
853
|
+
e || this.currentAbortController?.abort(), this.currentAbortController = s;
|
|
854
|
+
const { signal: r } = s, i = [];
|
|
855
855
|
for (const a of this.validators) {
|
|
856
856
|
const l = a(this._value.value);
|
|
857
857
|
l && i.push(l);
|
|
@@ -881,7 +881,7 @@ class de extends M {
|
|
|
881
881
|
} catch (u) {
|
|
882
882
|
if (u instanceof DOMException && u.name === "AbortError")
|
|
883
883
|
throw u;
|
|
884
|
-
return
|
|
884
|
+
return k.handle(
|
|
885
885
|
u,
|
|
886
886
|
"FieldNode AsyncValidator",
|
|
887
887
|
S.CONVERT
|
|
@@ -908,8 +908,8 @@ class de extends M {
|
|
|
908
908
|
}
|
|
909
909
|
setErrors(e) {
|
|
910
910
|
this._errors.value = e;
|
|
911
|
-
const
|
|
912
|
-
this.statusMachine.setErrors(
|
|
911
|
+
const s = e.some((r) => r.severity !== "warning");
|
|
912
|
+
this.statusMachine.setErrors(s);
|
|
913
913
|
}
|
|
914
914
|
clearErrors() {
|
|
915
915
|
this._errors.value = [], this.statusMachine.setErrors(!1);
|
|
@@ -965,6 +965,8 @@ class de extends M {
|
|
|
965
965
|
* @param updateOn - новый триггер валидации: 'change' | 'blur' | 'submit'
|
|
966
966
|
*
|
|
967
967
|
* @example
|
|
968
|
+
* Пример node-level: плоская схема с инлайн-значениями (back-compat путь до M1). В layout-схеме
|
|
969
|
+
* `createForm({ model, schema })` поля `validators` нет — правила живут в `defineValidationSchema`.
|
|
968
970
|
* ```typescript
|
|
969
971
|
* // Сценарий 1: Instant feedback после submit
|
|
970
972
|
* const form = createForm({
|
|
@@ -1025,12 +1027,12 @@ class de extends M {
|
|
|
1025
1027
|
* ```
|
|
1026
1028
|
*/
|
|
1027
1029
|
watch(e) {
|
|
1028
|
-
const
|
|
1030
|
+
const s = new AbortController(), r = _(() => {
|
|
1029
1031
|
const n = this.value.value;
|
|
1030
|
-
e(n,
|
|
1031
|
-
}), i =
|
|
1032
|
+
e(n, s.signal);
|
|
1033
|
+
}), i = O(F.Watch);
|
|
1032
1034
|
return this.disposers.add(i, () => {
|
|
1033
|
-
|
|
1035
|
+
s.abort(), r();
|
|
1034
1036
|
});
|
|
1035
1037
|
}
|
|
1036
1038
|
/**
|
|
@@ -1055,11 +1057,11 @@ class de extends M {
|
|
|
1055
1057
|
* useEffect(() => dispose, []);
|
|
1056
1058
|
* ```
|
|
1057
1059
|
*/
|
|
1058
|
-
computeFrom(e,
|
|
1060
|
+
computeFrom(e, s) {
|
|
1059
1061
|
const r = _(() => {
|
|
1060
|
-
const n = e.map((l) => l.value), a =
|
|
1062
|
+
const n = e.map((l) => l.value), a = s(...n);
|
|
1061
1063
|
this.setValue(a, { emitEvent: !1 });
|
|
1062
|
-
}), i =
|
|
1064
|
+
}), i = O(F.ComputeFrom);
|
|
1063
1065
|
return this.disposers.add(i, r);
|
|
1064
1066
|
}
|
|
1065
1067
|
/**
|
|
@@ -1090,9 +1092,9 @@ class de extends M {
|
|
|
1090
1092
|
}
|
|
1091
1093
|
}
|
|
1092
1094
|
}
|
|
1093
|
-
function
|
|
1094
|
-
const { getChildren: e, ownErrors:
|
|
1095
|
-
const o = [...
|
|
1095
|
+
function L(t) {
|
|
1096
|
+
const { getChildren: e, ownErrors: s, disabled: r } = t, i = m(() => s.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = m(() => !i.value), a = m(() => e().some((o) => o.pending.value)), l = m(() => e().some((o) => o.touched.value)), d = m(() => e().some((o) => o.dirty.value)), u = m(() => {
|
|
1097
|
+
const o = [...s.value];
|
|
1096
1098
|
for (const f of e())
|
|
1097
1099
|
o.push(...f.errors.value);
|
|
1098
1100
|
return o;
|
|
@@ -1107,22 +1109,22 @@ function R(s) {
|
|
|
1107
1109
|
status: h
|
|
1108
1110
|
};
|
|
1109
1111
|
}
|
|
1110
|
-
function
|
|
1111
|
-
return typeof
|
|
1112
|
+
function j(t) {
|
|
1113
|
+
return typeof t == "object" && t !== null && "getProxy" in t && typeof t.getProxy == "function";
|
|
1112
1114
|
}
|
|
1113
1115
|
const U = "$";
|
|
1114
|
-
function
|
|
1115
|
-
let
|
|
1116
|
+
function fe(t, e) {
|
|
1117
|
+
let s;
|
|
1116
1118
|
const r = () => {
|
|
1117
|
-
if (!
|
|
1119
|
+
if (!s) {
|
|
1118
1120
|
const i = {};
|
|
1119
1121
|
e.forEach((n, a) => {
|
|
1120
|
-
i[a] = n &&
|
|
1121
|
-
}),
|
|
1122
|
+
i[a] = n && j(n) ? n.getProxy() : n;
|
|
1123
|
+
}), s = i;
|
|
1122
1124
|
}
|
|
1123
|
-
return
|
|
1125
|
+
return s;
|
|
1124
1126
|
};
|
|
1125
|
-
return new Proxy(
|
|
1127
|
+
return new Proxy(t, {
|
|
1126
1128
|
get: (i, n) => {
|
|
1127
1129
|
if (n === U)
|
|
1128
1130
|
return r();
|
|
@@ -1130,7 +1132,7 @@ function ce(s, e) {
|
|
|
1130
1132
|
return i[n];
|
|
1131
1133
|
if (typeof n == "string" && e.has(n)) {
|
|
1132
1134
|
const a = e.get(n);
|
|
1133
|
-
return a &&
|
|
1135
|
+
return a && j(a) ? a.getProxy() : a;
|
|
1134
1136
|
}
|
|
1135
1137
|
},
|
|
1136
1138
|
set: (i, n, a) => typeof n == "string" && e.has(n) ? !1 : (i[n] = a, !0),
|
|
@@ -1142,7 +1144,7 @@ function ce(s, e) {
|
|
|
1142
1144
|
getOwnPropertyDescriptor: (i, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, n)
|
|
1143
1145
|
});
|
|
1144
1146
|
}
|
|
1145
|
-
class
|
|
1147
|
+
class ve {
|
|
1146
1148
|
/**
|
|
1147
1149
|
* @param form - Форма для отправки
|
|
1148
1150
|
*/
|
|
@@ -1186,8 +1188,8 @@ class he {
|
|
|
1186
1188
|
* }
|
|
1187
1189
|
* ```
|
|
1188
1190
|
*/
|
|
1189
|
-
async submit(e,
|
|
1190
|
-
const { skipValidation: r = !1, skipTouch: i = !1 } =
|
|
1191
|
+
async submit(e, s) {
|
|
1192
|
+
const { skipValidation: r = !1, skipTouch: i = !1 } = s || {};
|
|
1191
1193
|
if (i || this.form.markAsTouched(), !r && !await this.form.validate())
|
|
1192
1194
|
return null;
|
|
1193
1195
|
this._submitting.value = !0;
|
|
@@ -1221,8 +1223,8 @@ class he {
|
|
|
1221
1223
|
* }
|
|
1222
1224
|
* ```
|
|
1223
1225
|
*/
|
|
1224
|
-
async submitWithResult(e,
|
|
1225
|
-
const { skipValidation: r = !1, skipTouch: i = !1 } =
|
|
1226
|
+
async submitWithResult(e, s) {
|
|
1227
|
+
const { skipValidation: r = !1, skipTouch: i = !1 } = s || {};
|
|
1226
1228
|
if (i || this.form.markAsTouched(), !r && !await this.form.validate())
|
|
1227
1229
|
return { success: !1, data: null };
|
|
1228
1230
|
this._submitting.value = !0;
|
|
@@ -1239,16 +1241,16 @@ class he {
|
|
|
1239
1241
|
}
|
|
1240
1242
|
}
|
|
1241
1243
|
}
|
|
1242
|
-
function
|
|
1244
|
+
function me(t) {
|
|
1243
1245
|
const e = [];
|
|
1244
|
-
for (const
|
|
1245
|
-
const r = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(
|
|
1246
|
+
for (const s of t.split(".")) {
|
|
1247
|
+
const r = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(s);
|
|
1246
1248
|
if (!r) return [];
|
|
1247
1249
|
e.push(r[2] !== void 0 ? { key: r[1], index: Number(r[2]) } : { key: r[1] });
|
|
1248
1250
|
}
|
|
1249
1251
|
return e;
|
|
1250
1252
|
}
|
|
1251
|
-
class
|
|
1253
|
+
class w extends M {
|
|
1252
1254
|
// ============================================================================
|
|
1253
1255
|
// Приватные поля
|
|
1254
1256
|
// ============================================================================
|
|
@@ -1261,7 +1263,7 @@ class A extends M {
|
|
|
1261
1263
|
/**
|
|
1262
1264
|
* Менеджер подписок для централизованного cleanup
|
|
1263
1265
|
*/
|
|
1264
|
-
disposers = new
|
|
1266
|
+
disposers = new R();
|
|
1265
1267
|
/**
|
|
1266
1268
|
* Ссылка на Proxy-инстанс
|
|
1267
1269
|
*/
|
|
@@ -1273,7 +1275,7 @@ class A extends M {
|
|
|
1273
1275
|
/**
|
|
1274
1276
|
* Фабрика для создания узлов формы
|
|
1275
1277
|
*/
|
|
1276
|
-
nodeFactory = new
|
|
1278
|
+
nodeFactory = new pe();
|
|
1277
1279
|
// ============================================================================
|
|
1278
1280
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1279
1281
|
// ============================================================================
|
|
@@ -1304,8 +1306,8 @@ class A extends M {
|
|
|
1304
1306
|
status;
|
|
1305
1307
|
submitting;
|
|
1306
1308
|
constructor(e) {
|
|
1307
|
-
super(), this.formSubmitter = new
|
|
1308
|
-
const
|
|
1309
|
+
super(), this.formSubmitter = new ve(this);
|
|
1310
|
+
const s = e.form, r = s != null && typeof s == "object" && ("valueSignal" in s || "value" in s), n = "form" in e && !r ? e.form : e;
|
|
1309
1311
|
for (const [l, d] of Object.entries(n)) {
|
|
1310
1312
|
const u = this.createNode(d);
|
|
1311
1313
|
this._fields.set(l, u);
|
|
@@ -1316,7 +1318,7 @@ class A extends M {
|
|
|
1316
1318
|
l[u] = d.value.value;
|
|
1317
1319
|
}), l;
|
|
1318
1320
|
});
|
|
1319
|
-
const a =
|
|
1321
|
+
const a = L({
|
|
1320
1322
|
getChildren: () => Array.from(this._fields.values()),
|
|
1321
1323
|
ownErrors: this._formErrors,
|
|
1322
1324
|
disabled: this._disabled
|
|
@@ -1331,34 +1333,34 @@ class A extends M {
|
|
|
1331
1333
|
* @see buildFormProxy
|
|
1332
1334
|
*/
|
|
1333
1335
|
buildProxy() {
|
|
1334
|
-
return
|
|
1336
|
+
return fe(this, this._fields);
|
|
1335
1337
|
}
|
|
1336
1338
|
// ============================================================================
|
|
1337
1339
|
// Реализация абстрактных методов FormNode
|
|
1338
1340
|
// ============================================================================
|
|
1339
1341
|
getValue() {
|
|
1340
1342
|
const e = {};
|
|
1341
|
-
return this._fields.forEach((
|
|
1342
|
-
e[r] =
|
|
1343
|
+
return this._fields.forEach((s, r) => {
|
|
1344
|
+
e[r] = s.getValue();
|
|
1343
1345
|
}), e;
|
|
1344
1346
|
}
|
|
1345
|
-
setValue(e,
|
|
1347
|
+
setValue(e, s) {
|
|
1346
1348
|
for (const [r, i] of Object.entries(e)) {
|
|
1347
1349
|
const n = this._fields.get(r);
|
|
1348
1350
|
if (n) {
|
|
1349
1351
|
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1350
|
-
if (
|
|
1351
|
-
n.setValue(i,
|
|
1352
|
+
if (B(a)) continue;
|
|
1353
|
+
n.setValue(i, s);
|
|
1352
1354
|
}
|
|
1353
1355
|
}
|
|
1354
1356
|
}
|
|
1355
1357
|
patchValue(e) {
|
|
1356
|
-
|
|
1357
|
-
for (const [
|
|
1358
|
-
const i = this._fields.get(
|
|
1358
|
+
se(() => {
|
|
1359
|
+
for (const [s, r] of Object.entries(e)) {
|
|
1360
|
+
const i = this._fields.get(s);
|
|
1359
1361
|
if (i && r !== void 0) {
|
|
1360
1362
|
const n = this._fieldSignals.get(i) ?? i.value;
|
|
1361
|
-
if (
|
|
1363
|
+
if (B(n)) continue;
|
|
1362
1364
|
i.setValue(r, { emitEvent: !1 });
|
|
1363
1365
|
}
|
|
1364
1366
|
}
|
|
@@ -1382,9 +1384,9 @@ class A extends M {
|
|
|
1382
1384
|
* ```
|
|
1383
1385
|
*/
|
|
1384
1386
|
reset(e) {
|
|
1385
|
-
this._formErrors.value = [], this._fields.forEach((
|
|
1387
|
+
this._formErrors.value = [], this._fields.forEach((s, r) => {
|
|
1386
1388
|
const i = e?.[r];
|
|
1387
|
-
|
|
1389
|
+
s.reset(i);
|
|
1388
1390
|
});
|
|
1389
1391
|
}
|
|
1390
1392
|
/**
|
|
@@ -1396,8 +1398,8 @@ class A extends M {
|
|
|
1396
1398
|
});
|
|
1397
1399
|
}
|
|
1398
1400
|
async validate() {
|
|
1399
|
-
return this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((
|
|
1400
|
-
(
|
|
1401
|
+
return this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((s) => s.validate())), Array.from(this._fields.values()).every(
|
|
1402
|
+
(s) => s.valid.value || s.disabled.value
|
|
1401
1403
|
);
|
|
1402
1404
|
}
|
|
1403
1405
|
/**
|
|
@@ -1483,8 +1485,8 @@ class A extends M {
|
|
|
1483
1485
|
* `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
|
|
1484
1486
|
* используйте {@link submitWithResult}, который возвращает явный флаг `success`.
|
|
1485
1487
|
*/
|
|
1486
|
-
async submit(e,
|
|
1487
|
-
return this.formSubmitter.submit(e,
|
|
1488
|
+
async submit(e, s) {
|
|
1489
|
+
return this.formSubmitter.submit(e, s);
|
|
1488
1490
|
}
|
|
1489
1491
|
/**
|
|
1490
1492
|
* Отправить форму с расширенным результатом
|
|
@@ -1493,8 +1495,8 @@ class A extends M {
|
|
|
1493
1495
|
* @param options - Опции submit
|
|
1494
1496
|
* @returns Объект SubmitResult с данными, статусом и возможной ошибкой
|
|
1495
1497
|
*/
|
|
1496
|
-
async submitWithResult(e,
|
|
1497
|
-
return this.formSubmitter.submitWithResult(e,
|
|
1498
|
+
async submitWithResult(e, s) {
|
|
1499
|
+
return this.formSubmitter.submitWithResult(e, s);
|
|
1498
1500
|
}
|
|
1499
1501
|
/**
|
|
1500
1502
|
* Получить вложенное поле по пути
|
|
@@ -1528,12 +1530,12 @@ class A extends M {
|
|
|
1528
1530
|
getFieldByPath(e) {
|
|
1529
1531
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1530
1532
|
return;
|
|
1531
|
-
const
|
|
1532
|
-
if (
|
|
1533
|
+
const s = me(e);
|
|
1534
|
+
if (s.length === 0)
|
|
1533
1535
|
return;
|
|
1534
1536
|
let r = this;
|
|
1535
|
-
for (const i of
|
|
1536
|
-
if (!(r instanceof
|
|
1537
|
+
for (const i of s) {
|
|
1538
|
+
if (!(r instanceof w) || (r = r.getField(i.key), !r)) return;
|
|
1537
1539
|
if (i.index !== void 0)
|
|
1538
1540
|
if ("at" in r && "length" in r && typeof r.at == "function") {
|
|
1539
1541
|
const n = r.at(i.index);
|
|
@@ -1571,16 +1573,16 @@ class A extends M {
|
|
|
1571
1573
|
/**
|
|
1572
1574
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1573
1575
|
*/
|
|
1574
|
-
linkFields(e,
|
|
1575
|
-
const i = this._fields.get(e), n = this._fields.get(
|
|
1576
|
+
linkFields(e, s, r) {
|
|
1577
|
+
const i = this._fields.get(e), n = this._fields.get(s);
|
|
1576
1578
|
if (!i || !n) {
|
|
1577
|
-
const d = i ?
|
|
1579
|
+
const d = i ? s : e;
|
|
1578
1580
|
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1579
1581
|
}
|
|
1580
1582
|
const a = _(() => {
|
|
1581
1583
|
const d = i.value.value, u = r ? r(d) : d;
|
|
1582
1584
|
n.setValue(u, { emitEvent: !1 });
|
|
1583
|
-
}), l =
|
|
1585
|
+
}), l = O(F.LinkFields);
|
|
1584
1586
|
return this.disposers.add(l, a);
|
|
1585
1587
|
}
|
|
1586
1588
|
/**
|
|
@@ -1611,26 +1613,26 @@ class A extends M {
|
|
|
1611
1613
|
* ```
|
|
1612
1614
|
*/
|
|
1613
1615
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1614
|
-
watchField(e,
|
|
1616
|
+
watchField(e, s) {
|
|
1615
1617
|
const r = this.getFieldByPath(e);
|
|
1616
1618
|
if (!r)
|
|
1617
1619
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1618
1620
|
const i = _(() => {
|
|
1619
|
-
|
|
1620
|
-
}), n =
|
|
1621
|
+
s(r.value.value);
|
|
1622
|
+
}), n = O(F.WatchField);
|
|
1621
1623
|
return this.disposers.add(n, i);
|
|
1622
1624
|
}
|
|
1623
1625
|
/**
|
|
1624
1626
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
1625
1627
|
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1626
1628
|
*/
|
|
1627
|
-
watchFieldByPath(e,
|
|
1629
|
+
watchFieldByPath(e, s) {
|
|
1628
1630
|
const r = this.getFieldByPath(e);
|
|
1629
1631
|
if (!r)
|
|
1630
1632
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1631
1633
|
const i = _(() => {
|
|
1632
|
-
|
|
1633
|
-
}), n =
|
|
1634
|
+
s(r.value.value);
|
|
1635
|
+
}), n = O(F.WatchField);
|
|
1634
1636
|
return this.disposers.add(n, i);
|
|
1635
1637
|
}
|
|
1636
1638
|
/**
|
|
@@ -1658,8 +1660,8 @@ class A extends M {
|
|
|
1658
1660
|
* @internal
|
|
1659
1661
|
*/
|
|
1660
1662
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1661
|
-
registerFieldSignal(e,
|
|
1662
|
-
this._fieldSignals.set(e,
|
|
1663
|
+
registerFieldSignal(e, s) {
|
|
1664
|
+
this._fieldSignals.set(e, s);
|
|
1663
1665
|
}
|
|
1664
1666
|
/**
|
|
1665
1667
|
* Очистить все ресурсы узла
|
|
@@ -1681,7 +1683,7 @@ class W extends M {
|
|
|
1681
1683
|
* Менеджер подписок для централизованного cleanup
|
|
1682
1684
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1683
1685
|
*/
|
|
1684
|
-
disposers = new
|
|
1686
|
+
disposers = new R();
|
|
1685
1687
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1686
1688
|
_arrayErrors = g([]);
|
|
1687
1689
|
// ============================================================================
|
|
@@ -1699,12 +1701,12 @@ class W extends M {
|
|
|
1699
1701
|
// ============================================================================
|
|
1700
1702
|
// Конструктор
|
|
1701
1703
|
// ============================================================================
|
|
1702
|
-
constructor(e,
|
|
1703
|
-
super(), this.itemSchema = e, this.initialItems =
|
|
1704
|
-
for (const i of
|
|
1704
|
+
constructor(e, s = []) {
|
|
1705
|
+
super(), this.itemSchema = e, this.initialItems = s, this.items = g([]);
|
|
1706
|
+
for (const i of s)
|
|
1705
1707
|
this.push(i);
|
|
1706
1708
|
this.length = m(() => this.items.value.length), this.value = m(() => this.items.value.map((i) => i.value.value));
|
|
1707
|
-
const r =
|
|
1709
|
+
const r = L({
|
|
1708
1710
|
getChildren: () => this.items.value,
|
|
1709
1711
|
ownErrors: this._arrayErrors
|
|
1710
1712
|
});
|
|
@@ -1718,8 +1720,8 @@ class W extends M {
|
|
|
1718
1720
|
* @param initialValue - Начальные значения для нового элемента
|
|
1719
1721
|
*/
|
|
1720
1722
|
push(e) {
|
|
1721
|
-
const
|
|
1722
|
-
this.items.value = [...this.items.value,
|
|
1723
|
+
const s = this.createItem(e);
|
|
1724
|
+
this.items.value = [...this.items.value, s];
|
|
1723
1725
|
}
|
|
1724
1726
|
/**
|
|
1725
1727
|
* Удалить элемент по индексу
|
|
@@ -1730,7 +1732,7 @@ class W extends M {
|
|
|
1730
1732
|
*/
|
|
1731
1733
|
removeAt(e) {
|
|
1732
1734
|
if (e < 0 || e >= this.items.value.length) {
|
|
1733
|
-
|
|
1735
|
+
k.handle(
|
|
1734
1736
|
new Error(
|
|
1735
1737
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1736
1738
|
),
|
|
@@ -1739,17 +1741,17 @@ class W extends M {
|
|
|
1739
1741
|
);
|
|
1740
1742
|
return;
|
|
1741
1743
|
}
|
|
1742
|
-
const
|
|
1743
|
-
this.items.value = this.items.value.filter((r, i) => i !== e),
|
|
1744
|
+
const s = this.items.value[e];
|
|
1745
|
+
this.items.value = this.items.value.filter((r, i) => i !== e), s && "dispose" in s && typeof s.dispose == "function" && s.dispose();
|
|
1744
1746
|
}
|
|
1745
1747
|
/**
|
|
1746
1748
|
* Вставить элемент в массив
|
|
1747
1749
|
* @param index - Индекс для вставки
|
|
1748
1750
|
* @param initialValue - Начальные значения для нового элемента
|
|
1749
1751
|
*/
|
|
1750
|
-
insert(e,
|
|
1752
|
+
insert(e, s) {
|
|
1751
1753
|
if (e < 0 || e > this.items.value.length) {
|
|
1752
|
-
|
|
1754
|
+
k.handle(
|
|
1753
1755
|
new Error(
|
|
1754
1756
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1755
1757
|
),
|
|
@@ -1758,7 +1760,7 @@ class W extends M {
|
|
|
1758
1760
|
);
|
|
1759
1761
|
return;
|
|
1760
1762
|
}
|
|
1761
|
-
const r = this.createItem(
|
|
1763
|
+
const r = this.createItem(s), i = [...this.items.value];
|
|
1762
1764
|
i.splice(e, 0, r), this.items.value = i;
|
|
1763
1765
|
}
|
|
1764
1766
|
/**
|
|
@@ -1777,19 +1779,19 @@ class W extends M {
|
|
|
1777
1779
|
* form.items.move(2, 1);
|
|
1778
1780
|
* ```
|
|
1779
1781
|
*/
|
|
1780
|
-
move(e,
|
|
1782
|
+
move(e, s) {
|
|
1781
1783
|
const r = this.items.value.length;
|
|
1782
|
-
if (e < 0 || e >= r ||
|
|
1783
|
-
|
|
1784
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${
|
|
1784
|
+
if (e < 0 || e >= r || s < 0 || s >= r) {
|
|
1785
|
+
k.handle(
|
|
1786
|
+
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${s}, length=${r})`),
|
|
1785
1787
|
"ArrayNode.move",
|
|
1786
1788
|
S.LOG
|
|
1787
1789
|
);
|
|
1788
1790
|
return;
|
|
1789
1791
|
}
|
|
1790
|
-
if (e ===
|
|
1792
|
+
if (e === s) return;
|
|
1791
1793
|
const i = [...this.items.value], [n] = i.splice(e, 1);
|
|
1792
|
-
i.splice(
|
|
1794
|
+
i.splice(s, 0, n), this.items.value = i;
|
|
1793
1795
|
}
|
|
1794
1796
|
/**
|
|
1795
1797
|
* Поменять местами два элемента массива
|
|
@@ -1805,19 +1807,19 @@ class W extends M {
|
|
|
1805
1807
|
* form.items.swap(0, 2);
|
|
1806
1808
|
* ```
|
|
1807
1809
|
*/
|
|
1808
|
-
swap(e,
|
|
1810
|
+
swap(e, s) {
|
|
1809
1811
|
const r = this.items.value.length;
|
|
1810
|
-
if (e < 0 || e >= r ||
|
|
1811
|
-
|
|
1812
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${
|
|
1812
|
+
if (e < 0 || e >= r || s < 0 || s >= r) {
|
|
1813
|
+
k.handle(
|
|
1814
|
+
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${s}, length=${r})`),
|
|
1813
1815
|
"ArrayNode.swap",
|
|
1814
1816
|
S.LOG
|
|
1815
1817
|
);
|
|
1816
1818
|
return;
|
|
1817
1819
|
}
|
|
1818
|
-
if (e ===
|
|
1820
|
+
if (e === s) return;
|
|
1819
1821
|
const i = [...this.items.value];
|
|
1820
|
-
[i[e], i[
|
|
1822
|
+
[i[e], i[s]] = [i[s], i[e]], this.items.value = i;
|
|
1821
1823
|
}
|
|
1822
1824
|
/**
|
|
1823
1825
|
* Удалить все элементы массива
|
|
@@ -1827,8 +1829,8 @@ class W extends M {
|
|
|
1827
1829
|
*/
|
|
1828
1830
|
clear() {
|
|
1829
1831
|
const e = [...this.items.value];
|
|
1830
|
-
this.items.value = [], e.forEach((
|
|
1831
|
-
"dispose" in
|
|
1832
|
+
this.items.value = [], e.forEach((s) => {
|
|
1833
|
+
"dispose" in s && typeof s.dispose == "function" && s.dispose();
|
|
1832
1834
|
});
|
|
1833
1835
|
}
|
|
1834
1836
|
/**
|
|
@@ -1837,9 +1839,9 @@ class W extends M {
|
|
|
1837
1839
|
* @returns Типизированный GroupNode proxy или undefined если индекс вне границ
|
|
1838
1840
|
*/
|
|
1839
1841
|
at(e) {
|
|
1840
|
-
const
|
|
1841
|
-
if (
|
|
1842
|
-
return
|
|
1842
|
+
const s = this.items.value[e];
|
|
1843
|
+
if (s)
|
|
1844
|
+
return s.getProxy();
|
|
1843
1845
|
}
|
|
1844
1846
|
// ============================================================================
|
|
1845
1847
|
// Реализация абстрактных методов
|
|
@@ -1847,14 +1849,14 @@ class W extends M {
|
|
|
1847
1849
|
getValue() {
|
|
1848
1850
|
return this.items.value.map((e) => e.getValue());
|
|
1849
1851
|
}
|
|
1850
|
-
setValue(e,
|
|
1851
|
-
this.clear(), e.forEach((r) => this.push(r)),
|
|
1852
|
-
|
|
1852
|
+
setValue(e, s) {
|
|
1853
|
+
this.clear(), e.forEach((r) => this.push(r)), s?.emitEvent !== !1 && this.validate().catch((r) => {
|
|
1854
|
+
k.handle(r, "ArrayNode.setValue", S.LOG);
|
|
1853
1855
|
});
|
|
1854
1856
|
}
|
|
1855
1857
|
patchValue(e) {
|
|
1856
|
-
e.forEach((
|
|
1857
|
-
this.items.value[r] &&
|
|
1858
|
+
e.forEach((s, r) => {
|
|
1859
|
+
this.items.value[r] && s !== void 0 && this.items.value[r].patchValue(s);
|
|
1858
1860
|
});
|
|
1859
1861
|
}
|
|
1860
1862
|
/**
|
|
@@ -1875,7 +1877,7 @@ class W extends M {
|
|
|
1875
1877
|
* ```
|
|
1876
1878
|
*/
|
|
1877
1879
|
reset(e) {
|
|
1878
|
-
this._arrayErrors.value = [], this.clear(), e && e.forEach((
|
|
1880
|
+
this._arrayErrors.value = [], this.clear(), e && e.forEach((s) => this.push(s));
|
|
1879
1881
|
}
|
|
1880
1882
|
/**
|
|
1881
1883
|
* Сбросить массив к исходным значениям (initialItems)
|
|
@@ -1909,7 +1911,7 @@ class W extends M {
|
|
|
1909
1911
|
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1910
1912
|
}
|
|
1911
1913
|
async validate() {
|
|
1912
|
-
return (await Promise.all(this.items.value.map((
|
|
1914
|
+
return (await Promise.all(this.items.value.map((s) => s.validate()))).every(Boolean) && this._arrayErrors.value.length === 0;
|
|
1913
1915
|
}
|
|
1914
1916
|
/**
|
|
1915
1917
|
* Установить array-level validation errors
|
|
@@ -1982,8 +1984,8 @@ class W extends M {
|
|
|
1982
1984
|
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
1983
1985
|
*/
|
|
1984
1986
|
forEach(e) {
|
|
1985
|
-
this.items.value.forEach((
|
|
1986
|
-
const i =
|
|
1987
|
+
this.items.value.forEach((s, r) => {
|
|
1988
|
+
const i = s.getProxy();
|
|
1987
1989
|
e(i, r);
|
|
1988
1990
|
});
|
|
1989
1991
|
}
|
|
@@ -1993,8 +1995,8 @@ class W extends M {
|
|
|
1993
1995
|
* @returns Новый массив результатов
|
|
1994
1996
|
*/
|
|
1995
1997
|
map(e) {
|
|
1996
|
-
return this.items.value.map((
|
|
1997
|
-
const i =
|
|
1998
|
+
return this.items.value.map((s, r) => {
|
|
1999
|
+
const i = s.getProxy();
|
|
1998
2000
|
return e(i, r);
|
|
1999
2001
|
});
|
|
2000
2002
|
}
|
|
@@ -2007,8 +2009,8 @@ class W extends M {
|
|
|
2007
2009
|
*/
|
|
2008
2010
|
createItem(e) {
|
|
2009
2011
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2010
|
-
const
|
|
2011
|
-
return e &&
|
|
2012
|
+
const s = new w(this.itemSchema);
|
|
2013
|
+
return e && s.patchValue(e), s;
|
|
2012
2014
|
}
|
|
2013
2015
|
throw new Error(
|
|
2014
2016
|
"ArrayNode поддерживает только GroupNode элементы. Для массива примитивов используйте обычное поле с типом массива."
|
|
@@ -2085,7 +2087,7 @@ class W extends M {
|
|
|
2085
2087
|
});
|
|
2086
2088
|
}
|
|
2087
2089
|
}
|
|
2088
|
-
class
|
|
2090
|
+
class pe {
|
|
2089
2091
|
/**
|
|
2090
2092
|
* Создает узел формы на основе конфигурации
|
|
2091
2093
|
*
|
|
@@ -2104,6 +2106,7 @@ class ve {
|
|
|
2104
2106
|
* ```typescript
|
|
2105
2107
|
* const factory = new NodeFactory();
|
|
2106
2108
|
*
|
|
2109
|
+
* Конфиг node-level (не layout-схема M1, где `validators` уже нет).
|
|
2107
2110
|
* // FieldNode
|
|
2108
2111
|
* const field = factory.createNode({
|
|
2109
2112
|
* value: 'test@mail.com',
|
|
@@ -2135,14 +2138,14 @@ class ve {
|
|
|
2135
2138
|
if (Array.isArray(e) && e.length >= 1)
|
|
2136
2139
|
return this.createArrayNodeFromArray(e);
|
|
2137
2140
|
if (this.isFieldConfig(e))
|
|
2138
|
-
return new
|
|
2141
|
+
return new he(e);
|
|
2139
2142
|
if (this.isArrayConfig(e))
|
|
2140
2143
|
return new W(
|
|
2141
2144
|
e.schema,
|
|
2142
2145
|
e.initialItems
|
|
2143
2146
|
);
|
|
2144
2147
|
if (this.isGroupConfig(e))
|
|
2145
|
-
return new
|
|
2148
|
+
return new w(e);
|
|
2146
2149
|
throw new Error(
|
|
2147
2150
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2148
2151
|
e
|
|
@@ -2176,11 +2179,11 @@ class ve {
|
|
|
2176
2179
|
*/
|
|
2177
2180
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2178
2181
|
createArrayNodeFromArray(e) {
|
|
2179
|
-
const [
|
|
2180
|
-
this.isGroupConfig(
|
|
2182
|
+
const [s, ...r] = e, i = [];
|
|
2183
|
+
this.isGroupConfig(s) && i.push(this.extractValues(s));
|
|
2181
2184
|
for (const n of r)
|
|
2182
2185
|
this.isGroupConfig(n) ? i.push(this.extractValues(n)) : i.push(n);
|
|
2183
|
-
return new W(
|
|
2186
|
+
return new W(s, i);
|
|
2184
2187
|
}
|
|
2185
2188
|
/**
|
|
2186
2189
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2215,12 +2218,12 @@ class ve {
|
|
|
2215
2218
|
if (this.isFieldConfig(e))
|
|
2216
2219
|
return e.value;
|
|
2217
2220
|
if (Array.isArray(e))
|
|
2218
|
-
return e.map((
|
|
2221
|
+
return e.map((s) => this.extractValues(s));
|
|
2219
2222
|
if (this.isGroupConfig(e)) {
|
|
2220
|
-
const
|
|
2223
|
+
const s = {};
|
|
2221
2224
|
for (const [r, i] of Object.entries(e))
|
|
2222
|
-
|
|
2223
|
-
return
|
|
2225
|
+
s[r] = this.extractValues(i);
|
|
2226
|
+
return s;
|
|
2224
2227
|
}
|
|
2225
2228
|
return e;
|
|
2226
2229
|
}
|
|
@@ -2299,20 +2302,20 @@ class ve {
|
|
|
2299
2302
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2300
2303
|
}
|
|
2301
2304
|
}
|
|
2302
|
-
class
|
|
2305
|
+
class ye extends M {
|
|
2303
2306
|
/**
|
|
2304
2307
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2305
2308
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
2306
2309
|
* импорта с `create-form`). Обычно `(item) => createForm({ model: item, schema: itemSchema(item) })`.
|
|
2307
2310
|
*/
|
|
2308
|
-
constructor(e,
|
|
2309
|
-
super(), this.control = e, this.buildItem =
|
|
2311
|
+
constructor(e, s) {
|
|
2312
|
+
super(), this.control = e, this.buildItem = s, this.initial = e.toArray(), this.disposeSync = _(() => {
|
|
2310
2313
|
const i = e.length, n = [], a = [];
|
|
2311
2314
|
for (let u = 0; u < i; u++) {
|
|
2312
2315
|
const h = e.at(u);
|
|
2313
2316
|
if (!h) continue;
|
|
2314
2317
|
let o = this.cache.get(h);
|
|
2315
|
-
o || (o =
|
|
2318
|
+
o || (o = s(h), this.cache.set(h, o)), n.push(h), a.push(o);
|
|
2316
2319
|
}
|
|
2317
2320
|
const l = new Set(n), d = [];
|
|
2318
2321
|
for (const u of this.mountedModels) {
|
|
@@ -2322,7 +2325,7 @@ class me extends M {
|
|
|
2322
2325
|
}
|
|
2323
2326
|
this.mountedModels = n, this.itemNodes.value = a, d.forEach((u) => this.disposeItemNode(u));
|
|
2324
2327
|
}), this.length = m(() => this.itemNodes.value.length), this.value = m(() => this.itemNodes.value.map((i) => i.value.value));
|
|
2325
|
-
const r =
|
|
2328
|
+
const r = L({
|
|
2326
2329
|
getChildren: () => this.itemNodes.value,
|
|
2327
2330
|
ownErrors: this._arrayErrors
|
|
2328
2331
|
});
|
|
@@ -2358,17 +2361,17 @@ class me extends M {
|
|
|
2358
2361
|
return this.itemNodes.value[e];
|
|
2359
2362
|
}
|
|
2360
2363
|
map(e) {
|
|
2361
|
-
return this.itemNodes.value.map((
|
|
2364
|
+
return this.itemNodes.value.map((s, r) => e(s, r));
|
|
2362
2365
|
}
|
|
2363
2366
|
forEach(e) {
|
|
2364
|
-
this.itemNodes.value.forEach((
|
|
2367
|
+
this.itemNodes.value.forEach((s, r) => e(s, r));
|
|
2365
2368
|
}
|
|
2366
2369
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2367
2370
|
push(e) {
|
|
2368
2371
|
this.control.push(e ?? {});
|
|
2369
2372
|
}
|
|
2370
|
-
insert(e,
|
|
2371
|
-
this.control.insertAt(e,
|
|
2373
|
+
insert(e, s) {
|
|
2374
|
+
this.control.insertAt(e, s ?? {});
|
|
2372
2375
|
}
|
|
2373
2376
|
removeAt(e) {
|
|
2374
2377
|
this.control.removeAt(e);
|
|
@@ -2377,12 +2380,12 @@ class me extends M {
|
|
|
2377
2380
|
* Переместить элемент модель-массива. Делегирует мутацию массиву модели; внутренний `effect`
|
|
2378
2381
|
* пересоберёт `itemNodes` в новом порядке (per-item формы сохраняются по кешу идентичности).
|
|
2379
2382
|
*/
|
|
2380
|
-
move(e,
|
|
2381
|
-
this.control.move(e,
|
|
2383
|
+
move(e, s) {
|
|
2384
|
+
this.control.move(e, s);
|
|
2382
2385
|
}
|
|
2383
2386
|
/** Поменять местами два элемента модель-массива (см. {@link move}). */
|
|
2384
|
-
swap(e,
|
|
2385
|
-
this.control.swap(e,
|
|
2387
|
+
swap(e, s) {
|
|
2388
|
+
this.control.swap(e, s);
|
|
2386
2389
|
}
|
|
2387
2390
|
clear() {
|
|
2388
2391
|
this.control.clear();
|
|
@@ -2392,7 +2395,7 @@ class me extends M {
|
|
|
2392
2395
|
return this.control.toArray();
|
|
2393
2396
|
}
|
|
2394
2397
|
setValue(e) {
|
|
2395
|
-
this.control.clear(), (e ?? []).forEach((
|
|
2398
|
+
this.control.clear(), (e ?? []).forEach((s) => this.control.push(s));
|
|
2396
2399
|
}
|
|
2397
2400
|
patchValue(e) {
|
|
2398
2401
|
this.setValue(e);
|
|
@@ -2406,7 +2409,7 @@ class me extends M {
|
|
|
2406
2409
|
async validate() {
|
|
2407
2410
|
return (await Promise.all(
|
|
2408
2411
|
this.itemNodes.value.map(
|
|
2409
|
-
(
|
|
2412
|
+
(s) => s.validate()
|
|
2410
2413
|
)
|
|
2411
2414
|
)).every(Boolean) && this._arrayErrors.value.length === 0;
|
|
2412
2415
|
}
|
|
@@ -2461,25 +2464,25 @@ class me extends M {
|
|
|
2461
2464
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2462
2465
|
}
|
|
2463
2466
|
}
|
|
2464
|
-
const
|
|
2465
|
-
function I(
|
|
2466
|
-
if (
|
|
2467
|
-
if (typeof
|
|
2467
|
+
const Q = (t) => t !== null && typeof t == "object" && !Array.isArray(t) && !(t instanceof Date) && !(typeof Blob < "u" && t instanceof Blob) && !(typeof File < "u" && t instanceof File);
|
|
2468
|
+
function I(t, e, s) {
|
|
2469
|
+
if (t == null || typeof t != "object" || t instanceof G) return;
|
|
2470
|
+
if (typeof t.getProxy == "function") {
|
|
2468
2471
|
process.env.NODE_ENV !== "production" && console.warn(
|
|
2469
2472
|
"[reformer] createForm({ schema }): в схему попал узел формы (FormProxy) — он пропущен. Стройте дерево для createForm БЕЗ формы, а форму донесите до узла вторым проходом (билдер `(model, form?) => …`) либо через render-behavior `patchProps({ form })`."
|
|
2470
2473
|
);
|
|
2471
2474
|
return;
|
|
2472
2475
|
}
|
|
2473
|
-
if (Array.isArray(
|
|
2474
|
-
for (const n of
|
|
2476
|
+
if (Array.isArray(t)) {
|
|
2477
|
+
for (const n of t) I(n, e, s);
|
|
2475
2478
|
return;
|
|
2476
2479
|
}
|
|
2477
|
-
const r =
|
|
2480
|
+
const r = t, i = r.array;
|
|
2478
2481
|
if (i && typeof i.__path == "string" && typeof r.item == "function") {
|
|
2479
|
-
|
|
2482
|
+
s.set(i.__path, r.item);
|
|
2480
2483
|
return;
|
|
2481
2484
|
}
|
|
2482
|
-
r.value instanceof
|
|
2485
|
+
r.value instanceof G ? e.set(r.value, {
|
|
2483
2486
|
component: r.component,
|
|
2484
2487
|
componentProps: r.componentProps,
|
|
2485
2488
|
updateOn: r.updateOn,
|
|
@@ -2489,68 +2492,68 @@ function I(s, e, t) {
|
|
|
2489
2492
|
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2490
2493
|
);
|
|
2491
2494
|
for (const [n, a] of Object.entries(r))
|
|
2492
|
-
n !== "value" && I(a, e,
|
|
2495
|
+
n !== "value" && I(a, e, s);
|
|
2493
2496
|
}
|
|
2494
|
-
function
|
|
2497
|
+
function X(t, e, s, r) {
|
|
2495
2498
|
const i = {};
|
|
2496
2499
|
for (const [n, a] of Object.entries(e)) {
|
|
2497
|
-
const l =
|
|
2500
|
+
const l = s === "" ? n : `${s}.${n}`;
|
|
2498
2501
|
if (Array.isArray(a))
|
|
2499
2502
|
continue;
|
|
2500
|
-
if (
|
|
2501
|
-
i[n] =
|
|
2503
|
+
if (Q(a)) {
|
|
2504
|
+
i[n] = X(t, a, l, r);
|
|
2502
2505
|
continue;
|
|
2503
2506
|
}
|
|
2504
|
-
const d =
|
|
2507
|
+
const d = t.signalAt(l);
|
|
2505
2508
|
if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2506
2509
|
const u = r.get(d) ?? {};
|
|
2507
2510
|
i[n] = { ...u, valueSignal: d };
|
|
2508
2511
|
}
|
|
2509
2512
|
return i;
|
|
2510
2513
|
}
|
|
2511
|
-
function
|
|
2512
|
-
for (const [r, i] of Object.entries(
|
|
2514
|
+
function Z(t, e, s) {
|
|
2515
|
+
for (const [r, i] of Object.entries(t)) {
|
|
2513
2516
|
const n = e === "" ? r : `${e}.${r}`;
|
|
2514
|
-
Array.isArray(i) || (
|
|
2517
|
+
Array.isArray(i) || (Q(i) ? Z(i, n, s) : s.push(n));
|
|
2515
2518
|
}
|
|
2516
2519
|
}
|
|
2517
|
-
function
|
|
2518
|
-
const { model: e, schema:
|
|
2519
|
-
|
|
2520
|
-
const a =
|
|
2520
|
+
function ee(t) {
|
|
2521
|
+
const { model: e, schema: s, behavior: r } = t, i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2522
|
+
s !== void 0 && I(s, i, n);
|
|
2523
|
+
const a = X(e, e.get(), "", i), l = new w(a), d = e.get();
|
|
2521
2524
|
for (const [o, f] of Object.entries(d)) {
|
|
2522
2525
|
if (!Array.isArray(f)) continue;
|
|
2523
2526
|
const c = n.get(o);
|
|
2524
2527
|
if (!c) continue;
|
|
2525
|
-
const v = e[o], p = (y) =>
|
|
2528
|
+
const v = e[o], p = (y) => ee({ model: y, schema: c(y) }), b = new ye(v, p);
|
|
2526
2529
|
l.fields.set(o, b);
|
|
2527
2530
|
}
|
|
2528
2531
|
const u = l.getProxy(), h = [];
|
|
2529
|
-
|
|
2532
|
+
Z(e.get(), "", h);
|
|
2530
2533
|
for (const o of h) {
|
|
2531
2534
|
const f = e.signalAt(o), c = l.getFieldByPath(o);
|
|
2532
2535
|
if (f && c) {
|
|
2533
|
-
|
|
2536
|
+
re(f, c);
|
|
2534
2537
|
const v = o.lastIndexOf("."), p = v === -1 ? l : l.getFieldByPath(o.slice(0, v));
|
|
2535
|
-
p instanceof
|
|
2538
|
+
p instanceof w && p.registerFieldSignal(c, f);
|
|
2536
2539
|
}
|
|
2537
2540
|
}
|
|
2538
2541
|
return r && l.attachBehaviorCleanup(r.__run(e, u)), u;
|
|
2539
2542
|
}
|
|
2540
|
-
const
|
|
2541
|
-
function
|
|
2542
|
-
return
|
|
2543
|
+
const ge = (t) => t != null && typeof t == "object" && "model" in t && typeof t.model?.signalAt == "function";
|
|
2544
|
+
function be(t) {
|
|
2545
|
+
return ge(t) ? ee(t) : new w(t).getProxy();
|
|
2543
2546
|
}
|
|
2544
|
-
const
|
|
2547
|
+
const Ee = () => {
|
|
2545
2548
|
};
|
|
2546
|
-
function
|
|
2549
|
+
function _e(t, e) {
|
|
2547
2550
|
if (!e) return;
|
|
2548
|
-
const
|
|
2549
|
-
() =>
|
|
2551
|
+
const s = typeof e == "function" ? { schema: e } : e, r = Object.keys(s.steps ?? {}), i = r.map((o) => s.steps?.[o]).filter((o) => o != null), n = s.schema ?? ie(
|
|
2552
|
+
() => ae(...i, ...s.extras ? [s.extras] : [])
|
|
2550
2553
|
), a = (o) => {
|
|
2551
2554
|
const f = typeof o == "number" ? r[o - 1] : o;
|
|
2552
|
-
return (f != null ?
|
|
2553
|
-
}, { strategy: l, debounce: d, liveAfterSubmit: u } =
|
|
2555
|
+
return (f != null ? s.steps?.[f] : null) ?? null;
|
|
2556
|
+
}, { strategy: l, debounce: d, liveAfterSubmit: u } = s, h = D(t, n, {
|
|
2554
2557
|
strategy: l,
|
|
2555
2558
|
debounce: d,
|
|
2556
2559
|
liveAfterSubmit: u
|
|
@@ -2560,59 +2563,59 @@ function be(s, e) {
|
|
|
2560
2563
|
stepSelectors: r,
|
|
2561
2564
|
validate: () => h.validate(),
|
|
2562
2565
|
validateAll: () => h.validate(),
|
|
2563
|
-
validateStep: (o) =>
|
|
2566
|
+
validateStep: (o) => ne(t, a(o) ?? Ee, { touch: !0 }),
|
|
2564
2567
|
createStepController: (o) => {
|
|
2565
2568
|
if (!l || l === "submit") return null;
|
|
2566
2569
|
const f = a(o);
|
|
2567
|
-
return f ? D(
|
|
2570
|
+
return f ? D(t, f, { strategy: l, debounce: d, liveAfterSubmit: u }) : null;
|
|
2568
2571
|
},
|
|
2569
2572
|
controller: h,
|
|
2570
2573
|
validating: h.validating
|
|
2571
2574
|
};
|
|
2572
2575
|
}
|
|
2573
|
-
function
|
|
2574
|
-
if (!
|
|
2576
|
+
function je(t) {
|
|
2577
|
+
if (!t.model && t.initial === void 0)
|
|
2575
2578
|
throw new Error("createCoreForm: provide either `initial` (to create a model) or `model`.");
|
|
2576
|
-
const e =
|
|
2577
|
-
|
|
2578
|
-
const
|
|
2579
|
+
const e = t.model ?? te(t.initial);
|
|
2580
|
+
t.seed?.(e);
|
|
2581
|
+
const s = be({
|
|
2579
2582
|
model: e,
|
|
2580
|
-
...
|
|
2581
|
-
...
|
|
2582
|
-
}), r =
|
|
2583
|
-
return
|
|
2583
|
+
...t.schema ? { schema: t.schema(e) } : {},
|
|
2584
|
+
...t.behavior ? { behavior: t.behavior } : {}
|
|
2585
|
+
}), r = _e(e, t.validation), i = { model: e, form: s, ...r ? { validation: r } : {} };
|
|
2586
|
+
return t.setup?.(i), i;
|
|
2584
2587
|
}
|
|
2585
|
-
function
|
|
2586
|
-
return
|
|
2588
|
+
function C(t) {
|
|
2589
|
+
return t == null ? !1 : typeof t == "object" && "value" in t && "setValue" in t && "getValue" in t && "validate" in t;
|
|
2587
2590
|
}
|
|
2588
|
-
function
|
|
2589
|
-
return
|
|
2591
|
+
function Se(t) {
|
|
2592
|
+
return C(t) && "validators" in t && "asyncValidators" in t && // FieldNode имеет markAsTouched метод
|
|
2590
2593
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2591
|
-
typeof
|
|
2592
|
-
!("fields" in
|
|
2594
|
+
typeof t.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2595
|
+
!("fields" in t) && !("items" in t);
|
|
2593
2596
|
}
|
|
2594
|
-
function
|
|
2595
|
-
return
|
|
2596
|
-
!("items" in
|
|
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);
|
|
2597
2600
|
}
|
|
2598
|
-
function
|
|
2599
|
-
return
|
|
2600
|
-
typeof
|
|
2601
|
-
typeof
|
|
2601
|
+
function we(t) {
|
|
2602
|
+
return C(t) && "items" in t && "length" in t && "push" in t && "removeAt" in t && "at" in t && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2603
|
+
typeof t.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2604
|
+
typeof t.removeAt == "function";
|
|
2602
2605
|
}
|
|
2603
|
-
function
|
|
2604
|
-
return
|
|
2606
|
+
function Ue(t) {
|
|
2607
|
+
return Se(t) ? "FieldNode" : Ae(t) ? "GroupNode" : we(t) ? "ArrayNode" : C(t) ? "FormNode" : "Unknown";
|
|
2605
2608
|
}
|
|
2606
|
-
var
|
|
2609
|
+
var N = { exports: {} }, P = {};
|
|
2607
2610
|
var q;
|
|
2608
|
-
function
|
|
2611
|
+
function Ve() {
|
|
2609
2612
|
if (q) return P;
|
|
2610
2613
|
q = 1;
|
|
2611
|
-
var
|
|
2614
|
+
var t = Y;
|
|
2612
2615
|
function e(o, f) {
|
|
2613
2616
|
return o === f && (o !== 0 || 1 / o === 1 / f) || o !== o && f !== f;
|
|
2614
2617
|
}
|
|
2615
|
-
var
|
|
2618
|
+
var s = typeof Object.is == "function" ? Object.is : e, r = t.useState, i = t.useEffect, n = t.useLayoutEffect, a = t.useDebugValue;
|
|
2616
2619
|
function l(o, f) {
|
|
2617
2620
|
var c = f(), v = r({ inst: { value: c, getSnapshot: f } }), p = v[0].inst, b = v[1];
|
|
2618
2621
|
return n(
|
|
@@ -2634,7 +2637,7 @@ function Ae() {
|
|
|
2634
2637
|
o = o.value;
|
|
2635
2638
|
try {
|
|
2636
2639
|
var c = f();
|
|
2637
|
-
return !
|
|
2640
|
+
return !s(o, c);
|
|
2638
2641
|
} catch {
|
|
2639
2642
|
return !0;
|
|
2640
2643
|
}
|
|
@@ -2643,13 +2646,13 @@ function Ae() {
|
|
|
2643
2646
|
return f();
|
|
2644
2647
|
}
|
|
2645
2648
|
var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2646
|
-
return P.useSyncExternalStore =
|
|
2649
|
+
return P.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : h, P;
|
|
2647
2650
|
}
|
|
2648
2651
|
var T = {};
|
|
2649
|
-
var
|
|
2650
|
-
function
|
|
2651
|
-
return
|
|
2652
|
-
function
|
|
2652
|
+
var H;
|
|
2653
|
+
function ke() {
|
|
2654
|
+
return H || (H = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2655
|
+
function t(c, v) {
|
|
2653
2656
|
return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
|
|
2654
2657
|
}
|
|
2655
2658
|
function e(c, v) {
|
|
@@ -2666,22 +2669,22 @@ function we() {
|
|
|
2666
2669
|
b = a({
|
|
2667
2670
|
inst: { value: p, getSnapshot: v }
|
|
2668
2671
|
});
|
|
2669
|
-
var y = b[0].inst,
|
|
2672
|
+
var y = b[0].inst, V = b[1];
|
|
2670
2673
|
return d(
|
|
2671
2674
|
function() {
|
|
2672
|
-
y.value = p, y.getSnapshot = v,
|
|
2675
|
+
y.value = p, y.getSnapshot = v, s(y) && V({ inst: y });
|
|
2673
2676
|
},
|
|
2674
2677
|
[c, p, v]
|
|
2675
2678
|
), l(
|
|
2676
2679
|
function() {
|
|
2677
|
-
return
|
|
2678
|
-
|
|
2680
|
+
return s(y) && V({ inst: y }), c(function() {
|
|
2681
|
+
s(y) && V({ inst: y });
|
|
2679
2682
|
});
|
|
2680
2683
|
},
|
|
2681
2684
|
[c]
|
|
2682
2685
|
), u(p), p;
|
|
2683
2686
|
}
|
|
2684
|
-
function
|
|
2687
|
+
function s(c) {
|
|
2685
2688
|
var v = c.getSnapshot;
|
|
2686
2689
|
c = c.value;
|
|
2687
2690
|
try {
|
|
@@ -2695,32 +2698,32 @@ function we() {
|
|
|
2695
2698
|
return v();
|
|
2696
2699
|
}
|
|
2697
2700
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2698
|
-
var i =
|
|
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;
|
|
2699
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());
|
|
2700
2703
|
})()), T;
|
|
2701
2704
|
}
|
|
2702
|
-
var
|
|
2703
|
-
function
|
|
2704
|
-
return
|
|
2705
|
+
var K;
|
|
2706
|
+
function Fe() {
|
|
2707
|
+
return K || (K = 1, process.env.NODE_ENV === "production" ? N.exports = Ve() : N.exports = ke()), N.exports;
|
|
2705
2708
|
}
|
|
2706
|
-
var
|
|
2707
|
-
function
|
|
2708
|
-
if (
|
|
2709
|
-
if (
|
|
2710
|
-
for (let
|
|
2711
|
-
if (s
|
|
2709
|
+
var x = Fe();
|
|
2710
|
+
function Oe(t, e) {
|
|
2711
|
+
if (t === e) return !0;
|
|
2712
|
+
if (t.length !== e.length) return !1;
|
|
2713
|
+
for (let s = 0; s < t.length; s++)
|
|
2714
|
+
if (t[s] !== e[s]) return !1;
|
|
2712
2715
|
return !0;
|
|
2713
2716
|
}
|
|
2714
|
-
function $(
|
|
2715
|
-
const i =
|
|
2716
|
-
n.current =
|
|
2717
|
-
const a =
|
|
2717
|
+
function $(t, e, s, r) {
|
|
2718
|
+
const i = A(null), n = A(t);
|
|
2719
|
+
n.current = t;
|
|
2720
|
+
const a = A(e);
|
|
2718
2721
|
a.current = e;
|
|
2719
|
-
const l =
|
|
2720
|
-
if (l.current =
|
|
2722
|
+
const l = A(s);
|
|
2723
|
+
if (l.current = s, i.current === null) {
|
|
2721
2724
|
const h = {};
|
|
2722
|
-
for (const o in
|
|
2723
|
-
h[o] =
|
|
2725
|
+
for (const o in t)
|
|
2726
|
+
h[o] = t[o].value;
|
|
2724
2727
|
i.current = { ...h, __snapshot: null };
|
|
2725
2728
|
}
|
|
2726
2729
|
const d = E(
|
|
@@ -2749,13 +2752,13 @@ function $(s, e, t, r) {
|
|
|
2749
2752
|
f[v] = o[v].value;
|
|
2750
2753
|
let c = !1;
|
|
2751
2754
|
for (const v of a.current) {
|
|
2752
|
-
const { key: p, useShallowArrayEqual: b } = v, y = f[p],
|
|
2755
|
+
const { key: p, useShallowArrayEqual: b } = v, y = f[p], V = h[p];
|
|
2753
2756
|
if (b) {
|
|
2754
|
-
if (!
|
|
2757
|
+
if (!Oe(V, y)) {
|
|
2755
2758
|
c = !0;
|
|
2756
2759
|
break;
|
|
2757
2760
|
}
|
|
2758
|
-
} else if (
|
|
2761
|
+
} else if (V !== y) {
|
|
2759
2762
|
c = !0;
|
|
2760
2763
|
break;
|
|
2761
2764
|
}
|
|
@@ -2766,21 +2769,21 @@ function $(s, e, t, r) {
|
|
|
2766
2769
|
h[v] = f[v];
|
|
2767
2770
|
return h.__snapshot = l.current(f), h.__snapshot;
|
|
2768
2771
|
}, [r]);
|
|
2769
|
-
return
|
|
2772
|
+
return x.useSyncExternalStore(d, u, u);
|
|
2770
2773
|
}
|
|
2771
|
-
function
|
|
2774
|
+
function Ne(t) {
|
|
2772
2775
|
const e = {
|
|
2773
|
-
value:
|
|
2774
|
-
disabled:
|
|
2775
|
-
errors:
|
|
2776
|
-
pending:
|
|
2777
|
-
valid:
|
|
2778
|
-
invalid:
|
|
2779
|
-
touched:
|
|
2780
|
-
dirty:
|
|
2781
|
-
shouldShowError:
|
|
2782
|
-
componentProps:
|
|
2783
|
-
},
|
|
2776
|
+
value: t.value,
|
|
2777
|
+
disabled: t.disabled,
|
|
2778
|
+
errors: t.errors,
|
|
2779
|
+
pending: t.pending,
|
|
2780
|
+
valid: t.valid,
|
|
2781
|
+
invalid: t.invalid,
|
|
2782
|
+
touched: t.touched,
|
|
2783
|
+
dirty: t.dirty,
|
|
2784
|
+
shouldShowError: t.shouldShowError,
|
|
2785
|
+
componentProps: t.componentProps
|
|
2786
|
+
}, s = [
|
|
2784
2787
|
{ key: "value" },
|
|
2785
2788
|
{ key: "disabled" },
|
|
2786
2789
|
{ key: "errors", useShallowArrayEqual: !0 },
|
|
@@ -2806,20 +2809,20 @@ function Oe(s) {
|
|
|
2806
2809
|
}),
|
|
2807
2810
|
[]
|
|
2808
2811
|
);
|
|
2809
|
-
return $(e,
|
|
2812
|
+
return $(e, s, r, t);
|
|
2810
2813
|
}
|
|
2811
|
-
function
|
|
2814
|
+
function Me(t) {
|
|
2812
2815
|
const e = {
|
|
2813
|
-
value:
|
|
2814
|
-
length:
|
|
2815
|
-
errors:
|
|
2816
|
-
pending:
|
|
2817
|
-
valid:
|
|
2818
|
-
invalid:
|
|
2819
|
-
touched:
|
|
2820
|
-
dirty:
|
|
2821
|
-
disabled:
|
|
2822
|
-
},
|
|
2816
|
+
value: t.value,
|
|
2817
|
+
length: t.length,
|
|
2818
|
+
errors: t.errors,
|
|
2819
|
+
pending: t.pending,
|
|
2820
|
+
valid: t.valid,
|
|
2821
|
+
invalid: t.invalid,
|
|
2822
|
+
touched: t.touched,
|
|
2823
|
+
dirty: t.dirty,
|
|
2824
|
+
disabled: t.disabled
|
|
2825
|
+
}, s = [
|
|
2823
2826
|
{ key: "value" },
|
|
2824
2827
|
{ key: "length" },
|
|
2825
2828
|
{ key: "errors", useShallowArrayEqual: !0 },
|
|
@@ -2843,10 +2846,10 @@ function Ne(s) {
|
|
|
2843
2846
|
}),
|
|
2844
2847
|
[]
|
|
2845
2848
|
);
|
|
2846
|
-
return $(e,
|
|
2849
|
+
return $(e, s, r, t);
|
|
2847
2850
|
}
|
|
2848
|
-
function
|
|
2849
|
-
const
|
|
2851
|
+
function Ce() {
|
|
2852
|
+
const t = E(
|
|
2850
2853
|
() => ({
|
|
2851
2854
|
value: [],
|
|
2852
2855
|
length: 0,
|
|
@@ -2860,57 +2863,57 @@ function Fe() {
|
|
|
2860
2863
|
}),
|
|
2861
2864
|
[]
|
|
2862
2865
|
);
|
|
2863
|
-
return $({}, [],
|
|
2866
|
+
return $({}, [], t);
|
|
2864
2867
|
}
|
|
2865
|
-
function
|
|
2866
|
-
const e =
|
|
2867
|
-
return
|
|
2868
|
+
function We(t) {
|
|
2869
|
+
const e = t && "length" in t && "map" in t;
|
|
2870
|
+
return t ? e ? Me(t) : Ne(t) : Ce();
|
|
2868
2871
|
}
|
|
2869
|
-
function
|
|
2870
|
-
const e =
|
|
2872
|
+
function qe(t) {
|
|
2873
|
+
const e = A({ value: t.value.value }), s = E(
|
|
2871
2874
|
(i) => {
|
|
2872
2875
|
let n = !0;
|
|
2873
2876
|
return _(() => {
|
|
2874
|
-
if (
|
|
2877
|
+
if (t.value.value, n) {
|
|
2875
2878
|
n = !1;
|
|
2876
2879
|
return;
|
|
2877
2880
|
}
|
|
2878
2881
|
i();
|
|
2879
2882
|
});
|
|
2880
2883
|
},
|
|
2881
|
-
[
|
|
2884
|
+
[t]
|
|
2882
2885
|
), r = E(() => {
|
|
2883
|
-
const i =
|
|
2886
|
+
const i = t.value.value;
|
|
2884
2887
|
return e.current.value === i ? e.current.value : (e.current.value = i, i);
|
|
2885
|
-
}, [
|
|
2886
|
-
return
|
|
2888
|
+
}, [t]);
|
|
2889
|
+
return x.useSyncExternalStore(s, r, r);
|
|
2887
2890
|
}
|
|
2888
|
-
function
|
|
2889
|
-
const e =
|
|
2891
|
+
function He(t) {
|
|
2892
|
+
const e = A({ length: t.length.value }), s = E(
|
|
2890
2893
|
(i) => {
|
|
2891
2894
|
let n = !0;
|
|
2892
2895
|
return _(() => {
|
|
2893
|
-
if (
|
|
2896
|
+
if (t.length.value, n) {
|
|
2894
2897
|
n = !1;
|
|
2895
2898
|
return;
|
|
2896
2899
|
}
|
|
2897
2900
|
i();
|
|
2898
2901
|
});
|
|
2899
2902
|
},
|
|
2900
|
-
[
|
|
2903
|
+
[t]
|
|
2901
2904
|
), r = E(() => {
|
|
2902
|
-
const i =
|
|
2905
|
+
const i = t.length.value;
|
|
2903
2906
|
return e.current.length === i ? e.current.length : (e.current.length = i, i);
|
|
2904
|
-
}, [
|
|
2905
|
-
return
|
|
2907
|
+
}, [t]);
|
|
2908
|
+
return x.useSyncExternalStore(s, r, r);
|
|
2906
2909
|
}
|
|
2907
|
-
function
|
|
2908
|
-
const { model: e, schema:
|
|
2909
|
-
() => D(e,
|
|
2910
|
-
[e,
|
|
2910
|
+
function Ke(t) {
|
|
2911
|
+
const { model: e, schema: s, strategy: r, debounce: i, liveAfterSubmit: n } = t, a = oe(
|
|
2912
|
+
() => D(e, s, { strategy: r, debounce: i, liveAfterSubmit: n }),
|
|
2913
|
+
[e, s, r, i, n]
|
|
2911
2914
|
);
|
|
2912
|
-
|
|
2913
|
-
const l =
|
|
2915
|
+
J(() => a.start(), [a]);
|
|
2916
|
+
const l = x.useSyncExternalStore(
|
|
2914
2917
|
E((u) => a.validating.subscribe(u), [a]),
|
|
2915
2918
|
() => a.validating.peek(),
|
|
2916
2919
|
() => !1
|
|
@@ -2918,55 +2921,99 @@ function je(s) {
|
|
|
2918
2921
|
), d = E(() => a.validate(), [a]);
|
|
2919
2922
|
return { submit: d, validate: d, isValidating: l };
|
|
2920
2923
|
}
|
|
2921
|
-
function
|
|
2922
|
-
const [e] =
|
|
2923
|
-
return
|
|
2924
|
+
function ze(t) {
|
|
2925
|
+
const [e] = le(t), s = e.validation?.controller;
|
|
2926
|
+
return J(() => s?.start(), [s]), e;
|
|
2927
|
+
}
|
|
2928
|
+
const xe = ["labelTooltip"];
|
|
2929
|
+
function Ye(t) {
|
|
2930
|
+
if (!(t == null || typeof t != "function" && typeof t != "object"))
|
|
2931
|
+
return t.reformerAdapter;
|
|
2932
|
+
}
|
|
2933
|
+
const z = (t) => t;
|
|
2934
|
+
function Je(t, e, s = {}) {
|
|
2935
|
+
const r = { ...s };
|
|
2936
|
+
for (const n of xe) delete r[n];
|
|
2937
|
+
for (const n of t?.strip ?? []) delete r[n];
|
|
2938
|
+
if (!t)
|
|
2939
|
+
return { ...r, value: e.value, onChange: e.onChange, onBlur: e.onBlur };
|
|
2940
|
+
const i = t.fromEmit ?? z;
|
|
2941
|
+
return {
|
|
2942
|
+
...r,
|
|
2943
|
+
[t.valueProp ?? "value"]: (t.toValue ?? z)(e.value),
|
|
2944
|
+
[t.changeProp ?? "onChange"]: (n) => e.onChange(i(n, r)),
|
|
2945
|
+
...t.bindBlur ? t.bindBlur(e.onBlur) : { onBlur: e.onBlur }
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
function Pe(t) {
|
|
2949
|
+
return {
|
|
2950
|
+
focus: () => t.current?.focus(),
|
|
2951
|
+
blur: () => t.current?.blur(),
|
|
2952
|
+
scrollIntoView: (e) => t.current?.scrollIntoView(e),
|
|
2953
|
+
getElement: () => t.current
|
|
2954
|
+
};
|
|
2955
|
+
}
|
|
2956
|
+
function Te(t) {
|
|
2957
|
+
return typeof t == "object" && t !== null && t.nodeType === 1;
|
|
2958
|
+
}
|
|
2959
|
+
function Qe(t) {
|
|
2960
|
+
const e = A(null);
|
|
2961
|
+
return ue(t, () => De(e)), e;
|
|
2962
|
+
}
|
|
2963
|
+
function De(t) {
|
|
2964
|
+
const e = t.current;
|
|
2965
|
+
return e == null || Te(e) ? Pe(t) : e;
|
|
2924
2966
|
}
|
|
2925
|
-
const
|
|
2967
|
+
const Xe = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2926
2968
|
export {
|
|
2927
2969
|
W as ArrayNode,
|
|
2928
|
-
|
|
2970
|
+
Xe as CORE_RUNTIME_TOKEN,
|
|
2929
2971
|
S as ErrorStrategy,
|
|
2930
|
-
|
|
2931
|
-
|
|
2972
|
+
xe as FIELD_WRAPPER_ONLY_PROPS,
|
|
2973
|
+
he as FieldNode,
|
|
2974
|
+
k as FormErrorHandler,
|
|
2932
2975
|
M as FormNode,
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
ee as
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2976
|
+
ve as FormSubmitter,
|
|
2977
|
+
w as GroupNode,
|
|
2978
|
+
ye as ModelArrayNode,
|
|
2979
|
+
pe as NodeFactory,
|
|
2980
|
+
R as SubscriptionManager,
|
|
2981
|
+
Je as bindFieldProps,
|
|
2982
|
+
_e as buildValidation,
|
|
2983
|
+
ot as computeFrom,
|
|
2984
|
+
lt as copyFrom,
|
|
2985
|
+
je as createCoreForm,
|
|
2986
|
+
be as createForm,
|
|
2987
|
+
ee as createFormFromModel,
|
|
2988
|
+
te as createModel,
|
|
2989
|
+
Et as disableWhen,
|
|
2990
|
+
tt as eachLeafSignal,
|
|
2991
|
+
_t as enableWhen,
|
|
2992
|
+
Ye as getFieldAdapter,
|
|
2993
|
+
gt as getNodeForSignal,
|
|
2994
|
+
Ue as getNodeType,
|
|
2995
|
+
we as isArrayNode,
|
|
2996
|
+
B as isDerived,
|
|
2997
|
+
Se as isFieldNode,
|
|
2998
|
+
C as isFormNode,
|
|
2999
|
+
Ae as isGroupNode,
|
|
3000
|
+
rt as isModelContainerSignal,
|
|
3001
|
+
Pe as makeElementFieldHandle,
|
|
3002
|
+
it as markDerived,
|
|
3003
|
+
re as registerSignalNode,
|
|
3004
|
+
ut as resetWhen,
|
|
3005
|
+
dt as revalidateWhen,
|
|
3006
|
+
ct as runOutsideEffect,
|
|
3007
|
+
ht as safeCallback,
|
|
3008
|
+
ft as safeDebouncedCallback,
|
|
3009
|
+
vt as syncFields,
|
|
3010
|
+
mt as transformValue,
|
|
3011
|
+
nt as unmarkDerived,
|
|
3012
|
+
He as useArrayLength,
|
|
3013
|
+
Qe as useFieldHandleRef,
|
|
3014
|
+
ze as useFormBundle,
|
|
3015
|
+
We as useFormControl,
|
|
3016
|
+
qe as useFormControlValue,
|
|
3017
|
+
Ke as useFormValidation,
|
|
3018
|
+
pt as watchField
|
|
2972
3019
|
};
|