@reformer/core 10.0.0-beta.1 → 10.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{behaviors-node-DUrqAqp1.js → behaviors-node-DGEFMTQu.js} +1 -1
- package/dist/{behaviors-value-lCpqicfa.js → behaviors-value-C7dSEhCc.js} +43 -57
- package/dist/behaviors.js +108 -107
- package/dist/derived-registry-CluZCQ7U.js +16 -0
- package/dist/form/hooks/use-form-validation.d.ts +48 -0
- package/dist/form/index.d.ts +2 -0
- package/dist/form/validation-schema.d.ts +16 -3
- package/dist/form/validation-strategy.d.ts +55 -0
- package/dist/form-model-DYCzGGKF.js +286 -0
- package/dist/index.js +198 -181
- package/dist/state/form-model.d.ts +12 -1
- package/dist/state.js +17 -15
- package/dist/subscription-manager-705bls97.js +171 -0
- package/dist/validation.js +133 -81
- package/llms.txt +274 -1
- package/package.json +1 -1
- package/dist/form-model-C8Fi83k4.js +0 -439
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import { i as B } from "./
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { c as Ie } from "./form-model-DYCzGGKF.js";
|
|
2
|
+
import { c as Re, a as Be, r as $e, b as Ge, d as je, e as Ue, f as We, s as qe, t as He, w as Ke } from "./behaviors-value-C7dSEhCc.js";
|
|
3
|
+
import { i as B } from "./derived-registry-CluZCQ7U.js";
|
|
4
|
+
import { m as Ye, u as ze } from "./derived-registry-CluZCQ7U.js";
|
|
5
|
+
import { S as I } from "./subscription-manager-705bls97.js";
|
|
6
|
+
import { default as Xe } from "./validators.js";
|
|
7
|
+
import { signal as g, computed as c, effect as E, batch as X, Signal as $ } from "@preact/signals-core";
|
|
7
8
|
import { r as Z } from "./signal-node-registry-tiwel-TV.js";
|
|
8
|
-
import { g as
|
|
9
|
-
import { d as
|
|
10
|
-
import K, { useRef as O, useCallback as
|
|
9
|
+
import { g as et } from "./signal-node-registry-tiwel-TV.js";
|
|
10
|
+
import { d as st, e as it } from "./behaviors-node-DGEFMTQu.js";
|
|
11
|
+
import K, { useRef as O, useCallback as _, useMemo as ee, useEffect as te } from "react";
|
|
12
|
+
import { createFormValidation as se } from "./validation.js";
|
|
11
13
|
class M {
|
|
12
14
|
// ============================================================================
|
|
13
15
|
// Protected состояние (для Template Method паттерна)
|
|
@@ -299,9 +301,9 @@ const w = {
|
|
|
299
301
|
/** ArrayNode.watchLength() */
|
|
300
302
|
WatchLength: "watchLength"
|
|
301
303
|
};
|
|
302
|
-
let
|
|
304
|
+
let ie = 0;
|
|
303
305
|
function V(r) {
|
|
304
|
-
return `${r}-${++
|
|
306
|
+
return `${r}-${++ie}`;
|
|
305
307
|
}
|
|
306
308
|
var A = /* @__PURE__ */ ((r) => (r.THROW = "throw", r.LOG = "log", r.CONVERT = "convert", r))(A || {});
|
|
307
309
|
class F {
|
|
@@ -397,7 +399,7 @@ class F {
|
|
|
397
399
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
398
400
|
}
|
|
399
401
|
}
|
|
400
|
-
class
|
|
402
|
+
class re {
|
|
401
403
|
/** Внутренний сигнал статуса */
|
|
402
404
|
_status;
|
|
403
405
|
/** Публичный read-only сигнал статуса */
|
|
@@ -542,7 +544,7 @@ class te {
|
|
|
542
544
|
return this._status.value !== "disabled";
|
|
543
545
|
}
|
|
544
546
|
}
|
|
545
|
-
class
|
|
547
|
+
class ae extends M {
|
|
546
548
|
// ============================================================================
|
|
547
549
|
// Приватные сигналы
|
|
548
550
|
// ============================================================================
|
|
@@ -594,13 +596,13 @@ class se extends M {
|
|
|
594
596
|
* Менеджер подписок для централизованного cleanup
|
|
595
597
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
596
598
|
*/
|
|
597
|
-
disposers = new
|
|
599
|
+
disposers = new I();
|
|
598
600
|
component;
|
|
599
601
|
// ============================================================================
|
|
600
602
|
// Конструктор
|
|
601
603
|
// ============================================================================
|
|
602
604
|
constructor(e) {
|
|
603
|
-
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
|
|
605
|
+
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 re(e.disabled ? "disabled" : "valid"), this.value = c(() => this._value.value), this.valid = c(() => this.statusMachine.valid.value), this.invalid = c(() => this.statusMachine.invalid.value), this.pending = c(() => this.statusMachine.pending.value), this.status = c(() => this.statusMachine.status.value), this.disabled = c(() => this.statusMachine.disabled.value), this.errors = c(() => this._errors.value), this.componentProps = c(() => this._componentProps.value), this.shouldShowError = c(
|
|
604
606
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
605
607
|
);
|
|
606
608
|
}
|
|
@@ -762,11 +764,11 @@ class se extends M {
|
|
|
762
764
|
this.statusMachine.startValidation();
|
|
763
765
|
try {
|
|
764
766
|
const n = await Promise.all(
|
|
765
|
-
this.asyncValidators.map(async (
|
|
767
|
+
this.asyncValidators.map(async (d) => {
|
|
766
768
|
if (s.aborted)
|
|
767
769
|
throw new DOMException("Validation aborted", "AbortError");
|
|
768
770
|
try {
|
|
769
|
-
const u = await
|
|
771
|
+
const u = await d(this._value.value, { signal: s });
|
|
770
772
|
if (s.aborted)
|
|
771
773
|
throw new DOMException("Validation aborted", "AbortError");
|
|
772
774
|
return u;
|
|
@@ -783,11 +785,11 @@ class se extends M {
|
|
|
783
785
|
);
|
|
784
786
|
if (s.aborted)
|
|
785
787
|
return !1;
|
|
786
|
-
const l = n.filter((
|
|
788
|
+
const l = n.filter((d) => d !== null);
|
|
787
789
|
if (l.length > 0) {
|
|
788
790
|
this._errors.value = l;
|
|
789
|
-
const
|
|
790
|
-
if (this.statusMachine.completeValidation(
|
|
791
|
+
const d = l.some((u) => u.severity !== "warning");
|
|
792
|
+
if (this.statusMachine.completeValidation(d), d)
|
|
791
793
|
return !1;
|
|
792
794
|
}
|
|
793
795
|
} catch (n) {
|
|
@@ -917,7 +919,7 @@ class se extends M {
|
|
|
917
919
|
* ```
|
|
918
920
|
*/
|
|
919
921
|
watch(e) {
|
|
920
|
-
const t = new AbortController(), s =
|
|
922
|
+
const t = new AbortController(), s = E(() => {
|
|
921
923
|
const a = this.value.value;
|
|
922
924
|
e(a, t.signal);
|
|
923
925
|
}), i = V(w.Watch);
|
|
@@ -948,7 +950,7 @@ class se extends M {
|
|
|
948
950
|
* ```
|
|
949
951
|
*/
|
|
950
952
|
computeFrom(e, t) {
|
|
951
|
-
const s =
|
|
953
|
+
const s = E(() => {
|
|
952
954
|
const a = e.map((l) => l.value), n = t(...a);
|
|
953
955
|
this.setValue(n, { emitEvent: !1 });
|
|
954
956
|
}), i = V(w.ComputeFrom);
|
|
@@ -982,8 +984,8 @@ class se extends M {
|
|
|
982
984
|
}
|
|
983
985
|
}
|
|
984
986
|
}
|
|
985
|
-
function
|
|
986
|
-
const { getChildren: e, ownErrors: t, disabled: s } = r, i = c(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), a = c(() => !i.value), n = c(() => e().some((o) => o.pending.value)), l = c(() => e().some((o) => o.touched.value)),
|
|
987
|
+
function L(r) {
|
|
988
|
+
const { getChildren: e, ownErrors: t, disabled: s } = r, i = c(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), a = c(() => !i.value), n = c(() => e().some((o) => o.pending.value)), l = c(() => e().some((o) => o.touched.value)), d = c(() => e().some((o) => o.dirty.value)), u = c(() => {
|
|
987
989
|
const o = [...t.value];
|
|
988
990
|
for (const p of e())
|
|
989
991
|
o.push(...p.errors.value);
|
|
@@ -994,7 +996,7 @@ function I(r) {
|
|
|
994
996
|
invalid: a,
|
|
995
997
|
pending: n,
|
|
996
998
|
touched: l,
|
|
997
|
-
dirty:
|
|
999
|
+
dirty: d,
|
|
998
1000
|
errors: u,
|
|
999
1001
|
status: v
|
|
1000
1002
|
};
|
|
@@ -1003,7 +1005,7 @@ function G(r) {
|
|
|
1003
1005
|
return typeof r == "object" && r !== null && "getProxy" in r && typeof r.getProxy == "function";
|
|
1004
1006
|
}
|
|
1005
1007
|
const j = "$";
|
|
1006
|
-
function
|
|
1008
|
+
function ne(r, e) {
|
|
1007
1009
|
let t;
|
|
1008
1010
|
const s = () => {
|
|
1009
1011
|
if (!t) {
|
|
@@ -1034,7 +1036,7 @@ function ie(r, e) {
|
|
|
1034
1036
|
getOwnPropertyDescriptor: (i, a) => typeof a == "string" && e.has(a) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, a)
|
|
1035
1037
|
});
|
|
1036
1038
|
}
|
|
1037
|
-
class
|
|
1039
|
+
class oe {
|
|
1038
1040
|
/**
|
|
1039
1041
|
* @param form - Форма для отправки
|
|
1040
1042
|
*/
|
|
@@ -1137,7 +1139,7 @@ class re {
|
|
|
1137
1139
|
return this._submitting.value;
|
|
1138
1140
|
}
|
|
1139
1141
|
}
|
|
1140
|
-
function
|
|
1142
|
+
function le(r) {
|
|
1141
1143
|
const e = [];
|
|
1142
1144
|
for (const t of r.split(".")) {
|
|
1143
1145
|
const s = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
@@ -1159,7 +1161,7 @@ class S extends M {
|
|
|
1159
1161
|
/**
|
|
1160
1162
|
* Менеджер подписок для централизованного cleanup
|
|
1161
1163
|
*/
|
|
1162
|
-
disposers = new
|
|
1164
|
+
disposers = new I();
|
|
1163
1165
|
/**
|
|
1164
1166
|
* Ссылка на Proxy-инстанс
|
|
1165
1167
|
*/
|
|
@@ -1171,7 +1173,7 @@ class S extends M {
|
|
|
1171
1173
|
/**
|
|
1172
1174
|
* Фабрика для создания узлов формы
|
|
1173
1175
|
*/
|
|
1174
|
-
nodeFactory = new
|
|
1176
|
+
nodeFactory = new ue();
|
|
1175
1177
|
// ============================================================================
|
|
1176
1178
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1177
1179
|
// ============================================================================
|
|
@@ -1202,19 +1204,19 @@ class S extends M {
|
|
|
1202
1204
|
status;
|
|
1203
1205
|
submitting;
|
|
1204
1206
|
constructor(e) {
|
|
1205
|
-
super(), this.formSubmitter = new
|
|
1207
|
+
super(), this.formSubmitter = new oe(this);
|
|
1206
1208
|
const t = e.form, s = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), a = "form" in e && !s ? e.form : e;
|
|
1207
|
-
for (const [l,
|
|
1208
|
-
const u = this.createNode(
|
|
1209
|
+
for (const [l, d] of Object.entries(a)) {
|
|
1210
|
+
const u = this.createNode(d);
|
|
1209
1211
|
this._fields.set(l, u);
|
|
1210
1212
|
}
|
|
1211
1213
|
this.value = c(() => {
|
|
1212
1214
|
const l = {};
|
|
1213
|
-
return this._fields.forEach((
|
|
1214
|
-
l[u] =
|
|
1215
|
+
return this._fields.forEach((d, u) => {
|
|
1216
|
+
l[u] = d.value.value;
|
|
1215
1217
|
}), l;
|
|
1216
1218
|
});
|
|
1217
|
-
const n =
|
|
1219
|
+
const n = L({
|
|
1218
1220
|
getChildren: () => Array.from(this._fields.values()),
|
|
1219
1221
|
ownErrors: this._formErrors,
|
|
1220
1222
|
disabled: this._disabled
|
|
@@ -1229,7 +1231,7 @@ class S extends M {
|
|
|
1229
1231
|
* @see buildFormProxy
|
|
1230
1232
|
*/
|
|
1231
1233
|
buildProxy() {
|
|
1232
|
-
return
|
|
1234
|
+
return ne(this, this._fields);
|
|
1233
1235
|
}
|
|
1234
1236
|
// ============================================================================
|
|
1235
1237
|
// Реализация абстрактных методов FormNode
|
|
@@ -1430,7 +1432,7 @@ class S extends M {
|
|
|
1430
1432
|
getFieldByPath(e) {
|
|
1431
1433
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1432
1434
|
return;
|
|
1433
|
-
const t =
|
|
1435
|
+
const t = le(e);
|
|
1434
1436
|
if (t.length === 0)
|
|
1435
1437
|
return;
|
|
1436
1438
|
let s = this;
|
|
@@ -1476,11 +1478,11 @@ class S extends M {
|
|
|
1476
1478
|
linkFields(e, t, s) {
|
|
1477
1479
|
const i = this._fields.get(e), a = this._fields.get(t);
|
|
1478
1480
|
if (!i || !a) {
|
|
1479
|
-
const
|
|
1480
|
-
throw new Error(`GroupNode.linkFields: field "${String(
|
|
1481
|
+
const d = i ? t : e;
|
|
1482
|
+
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1481
1483
|
}
|
|
1482
|
-
const n =
|
|
1483
|
-
const
|
|
1484
|
+
const n = E(() => {
|
|
1485
|
+
const d = i.value.value, u = s ? s(d) : d;
|
|
1484
1486
|
a.setValue(u, { emitEvent: !1 });
|
|
1485
1487
|
}), l = V(w.LinkFields);
|
|
1486
1488
|
return this.disposers.add(l, n);
|
|
@@ -1517,7 +1519,7 @@ class S extends M {
|
|
|
1517
1519
|
const s = this.getFieldByPath(e);
|
|
1518
1520
|
if (!s)
|
|
1519
1521
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1520
|
-
const i =
|
|
1522
|
+
const i = E(() => {
|
|
1521
1523
|
t(s.value.value);
|
|
1522
1524
|
}), a = V(w.WatchField);
|
|
1523
1525
|
return this.disposers.add(a, i);
|
|
@@ -1530,7 +1532,7 @@ class S extends M {
|
|
|
1530
1532
|
const s = this.getFieldByPath(e);
|
|
1531
1533
|
if (!s)
|
|
1532
1534
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1533
|
-
const i =
|
|
1535
|
+
const i = E(() => {
|
|
1534
1536
|
t(s.value.value);
|
|
1535
1537
|
}), a = V(w.WatchField);
|
|
1536
1538
|
return this.disposers.add(a, i);
|
|
@@ -1583,7 +1585,7 @@ class U extends M {
|
|
|
1583
1585
|
* Менеджер подписок для централизованного cleanup
|
|
1584
1586
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1585
1587
|
*/
|
|
1586
|
-
disposers = new
|
|
1588
|
+
disposers = new I();
|
|
1587
1589
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1588
1590
|
_arrayErrors = g([]);
|
|
1589
1591
|
// ============================================================================
|
|
@@ -1611,7 +1613,7 @@ class U extends M {
|
|
|
1611
1613
|
for (const i of t)
|
|
1612
1614
|
this.push(i);
|
|
1613
1615
|
this.length = c(() => this.items.value.length), this.value = c(() => this.items.value.map((i) => i.value.value));
|
|
1614
|
-
const s =
|
|
1616
|
+
const s = L({
|
|
1615
1617
|
getChildren: () => this.items.value,
|
|
1616
1618
|
ownErrors: this._arrayErrors
|
|
1617
1619
|
});
|
|
@@ -2001,7 +2003,7 @@ class U extends M {
|
|
|
2001
2003
|
* ```
|
|
2002
2004
|
*/
|
|
2003
2005
|
watchItems(e, t) {
|
|
2004
|
-
const s =
|
|
2006
|
+
const s = E(() => {
|
|
2005
2007
|
const a = this.items.value.map((n) => {
|
|
2006
2008
|
if (n instanceof S)
|
|
2007
2009
|
return n.getFieldByPath(e)?.value.value;
|
|
@@ -2033,7 +2035,7 @@ class U extends M {
|
|
|
2033
2035
|
* ```
|
|
2034
2036
|
*/
|
|
2035
2037
|
watchLength(e) {
|
|
2036
|
-
const t =
|
|
2038
|
+
const t = E(() => {
|
|
2037
2039
|
const i = this.length.value;
|
|
2038
2040
|
e(i);
|
|
2039
2041
|
}), s = V(w.WatchLength);
|
|
@@ -2100,7 +2102,7 @@ class U extends M {
|
|
|
2100
2102
|
});
|
|
2101
2103
|
}
|
|
2102
2104
|
}
|
|
2103
|
-
class
|
|
2105
|
+
class ue {
|
|
2104
2106
|
/**
|
|
2105
2107
|
* Создает узел формы на основе конфигурации
|
|
2106
2108
|
*
|
|
@@ -2150,7 +2152,7 @@ class ne {
|
|
|
2150
2152
|
if (Array.isArray(e) && e.length >= 1)
|
|
2151
2153
|
return this.createArrayNodeFromArray(e);
|
|
2152
2154
|
if (this.isFieldConfig(e))
|
|
2153
|
-
return new
|
|
2155
|
+
return new ae(e);
|
|
2154
2156
|
if (this.isArrayConfig(e))
|
|
2155
2157
|
return new U(
|
|
2156
2158
|
e.schema,
|
|
@@ -2314,14 +2316,14 @@ class ne {
|
|
|
2314
2316
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2315
2317
|
}
|
|
2316
2318
|
}
|
|
2317
|
-
class
|
|
2319
|
+
class de extends M {
|
|
2318
2320
|
/**
|
|
2319
2321
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2320
2322
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
2321
2323
|
* импорта с `create-form`). Обычно `(item) => createForm({ model: item, schema: itemSchema(item) })`.
|
|
2322
2324
|
*/
|
|
2323
2325
|
constructor(e, t) {
|
|
2324
|
-
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync =
|
|
2326
|
+
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = E(() => {
|
|
2325
2327
|
const i = e.length, a = [], n = [];
|
|
2326
2328
|
for (let u = 0; u < i; u++) {
|
|
2327
2329
|
const v = e.at(u);
|
|
@@ -2329,15 +2331,15 @@ class oe extends M {
|
|
|
2329
2331
|
let o = this.cache.get(v);
|
|
2330
2332
|
o || (o = t(v), this.cache.set(v, o)), a.push(v), n.push(o);
|
|
2331
2333
|
}
|
|
2332
|
-
const l = new Set(a),
|
|
2334
|
+
const l = new Set(a), d = [];
|
|
2333
2335
|
for (const u of this.mountedModels) {
|
|
2334
2336
|
if (l.has(u)) continue;
|
|
2335
2337
|
const v = this.cache.get(u);
|
|
2336
|
-
this.cache.delete(u), v &&
|
|
2338
|
+
this.cache.delete(u), v && d.push(v);
|
|
2337
2339
|
}
|
|
2338
|
-
this.mountedModels = a, this.itemNodes.value = n,
|
|
2340
|
+
this.mountedModels = a, this.itemNodes.value = n, d.forEach((u) => this.disposeItemNode(u));
|
|
2339
2341
|
}), this.length = c(() => this.itemNodes.value.length), this.value = c(() => this.itemNodes.value.map((i) => i.value.value));
|
|
2340
|
-
const s =
|
|
2342
|
+
const s = L({
|
|
2341
2343
|
getChildren: () => this.itemNodes.value,
|
|
2342
2344
|
ownErrors: this._arrayErrors
|
|
2343
2345
|
});
|
|
@@ -2477,10 +2479,10 @@ class oe extends M {
|
|
|
2477
2479
|
}
|
|
2478
2480
|
}
|
|
2479
2481
|
const J = (r) => r !== null && typeof r == "object" && !Array.isArray(r) && !(r instanceof Date) && !(typeof Blob < "u" && r instanceof Blob) && !(typeof File < "u" && r instanceof File);
|
|
2480
|
-
function
|
|
2482
|
+
function D(r, e, t) {
|
|
2481
2483
|
if (r == null || typeof r != "object" || r instanceof $) return;
|
|
2482
2484
|
if (Array.isArray(r)) {
|
|
2483
|
-
for (const a of r)
|
|
2485
|
+
for (const a of r) D(a, e, t);
|
|
2484
2486
|
return;
|
|
2485
2487
|
}
|
|
2486
2488
|
const s = r, i = s.array;
|
|
@@ -2500,7 +2502,7 @@ function T(r, e, t) {
|
|
|
2500
2502
|
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2501
2503
|
);
|
|
2502
2504
|
for (const [a, n] of Object.entries(s))
|
|
2503
|
-
a !== "value" &&
|
|
2505
|
+
a !== "value" && D(n, e, t);
|
|
2504
2506
|
}
|
|
2505
2507
|
function Y(r, e, t, s) {
|
|
2506
2508
|
const i = {};
|
|
@@ -2512,10 +2514,10 @@ function Y(r, e, t, s) {
|
|
|
2512
2514
|
i[a] = Y(r, n, l, s);
|
|
2513
2515
|
continue;
|
|
2514
2516
|
}
|
|
2515
|
-
const
|
|
2516
|
-
if (!
|
|
2517
|
-
const u = s.get(
|
|
2518
|
-
i[a] = { ...p, valueSignal:
|
|
2517
|
+
const d = r.signalAt(l);
|
|
2518
|
+
if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2519
|
+
const u = s.get(d) ?? {}, { validators: v, asyncValidators: o, ...p } = u;
|
|
2520
|
+
i[a] = { ...p, valueSignal: d };
|
|
2519
2521
|
}
|
|
2520
2522
|
return i;
|
|
2521
2523
|
}
|
|
@@ -2527,56 +2529,56 @@ function z(r, e, t) {
|
|
|
2527
2529
|
}
|
|
2528
2530
|
function Q(r) {
|
|
2529
2531
|
const { model: e, schema: t, behavior: s } = r, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
2530
|
-
t !== void 0 &&
|
|
2531
|
-
const n = Y(e, e.get(), "", i), l = new S(n),
|
|
2532
|
-
for (const [o, p] of Object.entries(
|
|
2532
|
+
t !== void 0 && D(t, i, a);
|
|
2533
|
+
const n = Y(e, e.get(), "", i), l = new S(n), d = e.get();
|
|
2534
|
+
for (const [o, p] of Object.entries(d)) {
|
|
2533
2535
|
if (!Array.isArray(p)) continue;
|
|
2534
|
-
const
|
|
2535
|
-
if (!
|
|
2536
|
-
const f = e[o], m = (y) => Q({ model: y, schema:
|
|
2536
|
+
const h = a.get(o);
|
|
2537
|
+
if (!h) continue;
|
|
2538
|
+
const f = e[o], m = (y) => Q({ model: y, schema: h(y) }), b = new de(f, m);
|
|
2537
2539
|
l.fields.set(o, b);
|
|
2538
2540
|
}
|
|
2539
2541
|
const u = l.getProxy(), v = [];
|
|
2540
2542
|
z(e.get(), "", v);
|
|
2541
2543
|
for (const o of v) {
|
|
2542
|
-
const p = e.signalAt(o),
|
|
2543
|
-
if (p &&
|
|
2544
|
-
Z(p,
|
|
2544
|
+
const p = e.signalAt(o), h = l.getFieldByPath(o);
|
|
2545
|
+
if (p && h) {
|
|
2546
|
+
Z(p, h);
|
|
2545
2547
|
const f = o.lastIndexOf("."), m = f === -1 ? l : l.getFieldByPath(o.slice(0, f));
|
|
2546
|
-
m instanceof S && m.registerFieldSignal(
|
|
2548
|
+
m instanceof S && m.registerFieldSignal(h, p);
|
|
2547
2549
|
}
|
|
2548
2550
|
}
|
|
2549
2551
|
return s && l.attachBehaviorCleanup(s.__run(e, u)), u;
|
|
2550
2552
|
}
|
|
2551
|
-
const
|
|
2552
|
-
function
|
|
2553
|
-
return
|
|
2553
|
+
const he = (r) => r != null && typeof r == "object" && "model" in r && typeof r.model?.signalAt == "function";
|
|
2554
|
+
function Oe(r) {
|
|
2555
|
+
return he(r) ? Q(r) : new S(r).getProxy();
|
|
2554
2556
|
}
|
|
2555
|
-
function
|
|
2557
|
+
function x(r) {
|
|
2556
2558
|
return r == null ? !1 : typeof r == "object" && "value" in r && "setValue" in r && "getValue" in r && "validate" in r;
|
|
2557
2559
|
}
|
|
2558
|
-
function
|
|
2559
|
-
return r == null ? !1 :
|
|
2560
|
+
function ce(r) {
|
|
2561
|
+
return r == null ? !1 : x(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
|
|
2560
2562
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2561
2563
|
typeof r.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2562
2564
|
!("fields" in r) && !("items" in r);
|
|
2563
2565
|
}
|
|
2564
|
-
function
|
|
2565
|
-
return r == null ? !1 :
|
|
2566
|
+
function fe(r) {
|
|
2567
|
+
return r == null ? !1 : x(r) && "getFieldByPath" in r && "fields" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2566
2568
|
!("items" in r) && !("push" in r) && !("removeAt" in r);
|
|
2567
2569
|
}
|
|
2568
|
-
function
|
|
2569
|
-
return r == null ? !1 :
|
|
2570
|
+
function ve(r) {
|
|
2571
|
+
return r == null ? !1 : x(r) && "items" in r && "length" in r && "push" in r && "removeAt" in r && "at" in r && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2570
2572
|
typeof r.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2571
2573
|
typeof r.removeAt == "function";
|
|
2572
2574
|
}
|
|
2573
|
-
function
|
|
2574
|
-
return
|
|
2575
|
+
function Ne(r) {
|
|
2576
|
+
return ce(r) ? "FieldNode" : fe(r) ? "GroupNode" : ve(r) ? "ArrayNode" : x(r) ? "FormNode" : "Unknown";
|
|
2575
2577
|
}
|
|
2576
|
-
var N = { exports: {} },
|
|
2578
|
+
var N = { exports: {} }, P = {};
|
|
2577
2579
|
var W;
|
|
2578
|
-
function
|
|
2579
|
-
if (W) return
|
|
2580
|
+
function pe() {
|
|
2581
|
+
if (W) return P;
|
|
2580
2582
|
W = 1;
|
|
2581
2583
|
var r = K;
|
|
2582
2584
|
function e(o, p) {
|
|
@@ -2584,27 +2586,27 @@ function ce() {
|
|
|
2584
2586
|
}
|
|
2585
2587
|
var t = typeof Object.is == "function" ? Object.is : e, s = r.useState, i = r.useEffect, a = r.useLayoutEffect, n = r.useDebugValue;
|
|
2586
2588
|
function l(o, p) {
|
|
2587
|
-
var
|
|
2589
|
+
var h = p(), f = s({ inst: { value: h, getSnapshot: p } }), m = f[0].inst, b = f[1];
|
|
2588
2590
|
return a(
|
|
2589
2591
|
function() {
|
|
2590
|
-
m.value =
|
|
2592
|
+
m.value = h, m.getSnapshot = p, d(m) && b({ inst: m });
|
|
2591
2593
|
},
|
|
2592
|
-
[o,
|
|
2594
|
+
[o, h, p]
|
|
2593
2595
|
), i(
|
|
2594
2596
|
function() {
|
|
2595
|
-
return
|
|
2596
|
-
|
|
2597
|
+
return d(m) && b({ inst: m }), o(function() {
|
|
2598
|
+
d(m) && b({ inst: m });
|
|
2597
2599
|
});
|
|
2598
2600
|
},
|
|
2599
2601
|
[o]
|
|
2600
|
-
), n(
|
|
2602
|
+
), n(h), h;
|
|
2601
2603
|
}
|
|
2602
|
-
function
|
|
2604
|
+
function d(o) {
|
|
2603
2605
|
var p = o.getSnapshot;
|
|
2604
2606
|
o = o.value;
|
|
2605
2607
|
try {
|
|
2606
|
-
var
|
|
2607
|
-
return !t(o,
|
|
2608
|
+
var h = p();
|
|
2609
|
+
return !t(o, h);
|
|
2608
2610
|
} catch {
|
|
2609
2611
|
return !0;
|
|
2610
2612
|
}
|
|
@@ -2613,16 +2615,16 @@ function ce() {
|
|
|
2613
2615
|
return p();
|
|
2614
2616
|
}
|
|
2615
2617
|
var v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2616
|
-
return
|
|
2618
|
+
return P.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : v, P;
|
|
2617
2619
|
}
|
|
2618
|
-
var
|
|
2620
|
+
var T = {};
|
|
2619
2621
|
var q;
|
|
2620
|
-
function
|
|
2622
|
+
function me() {
|
|
2621
2623
|
return q || (q = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2622
|
-
function r(
|
|
2623
|
-
return
|
|
2624
|
+
function r(h, f) {
|
|
2625
|
+
return h === f && (h !== 0 || 1 / h === 1 / f) || h !== h && f !== f;
|
|
2624
2626
|
}
|
|
2625
|
-
function e(
|
|
2627
|
+
function e(h, f) {
|
|
2626
2628
|
v || i.startTransition === void 0 || (v = !0, console.error(
|
|
2627
2629
|
"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."
|
|
2628
2630
|
));
|
|
@@ -2637,44 +2639,44 @@ function fe() {
|
|
|
2637
2639
|
inst: { value: m, getSnapshot: f }
|
|
2638
2640
|
});
|
|
2639
2641
|
var y = b[0].inst, k = b[1];
|
|
2640
|
-
return
|
|
2642
|
+
return d(
|
|
2641
2643
|
function() {
|
|
2642
2644
|
y.value = m, y.getSnapshot = f, t(y) && k({ inst: y });
|
|
2643
2645
|
},
|
|
2644
|
-
[
|
|
2646
|
+
[h, m, f]
|
|
2645
2647
|
), l(
|
|
2646
2648
|
function() {
|
|
2647
|
-
return t(y) && k({ inst: y }),
|
|
2649
|
+
return t(y) && k({ inst: y }), h(function() {
|
|
2648
2650
|
t(y) && k({ inst: y });
|
|
2649
2651
|
});
|
|
2650
2652
|
},
|
|
2651
|
-
[
|
|
2653
|
+
[h]
|
|
2652
2654
|
), u(m), m;
|
|
2653
2655
|
}
|
|
2654
|
-
function t(
|
|
2655
|
-
var f =
|
|
2656
|
-
|
|
2656
|
+
function t(h) {
|
|
2657
|
+
var f = h.getSnapshot;
|
|
2658
|
+
h = h.value;
|
|
2657
2659
|
try {
|
|
2658
2660
|
var m = f();
|
|
2659
|
-
return !a(
|
|
2661
|
+
return !a(h, m);
|
|
2660
2662
|
} catch {
|
|
2661
2663
|
return !0;
|
|
2662
2664
|
}
|
|
2663
2665
|
}
|
|
2664
|
-
function s(
|
|
2666
|
+
function s(h, f) {
|
|
2665
2667
|
return f();
|
|
2666
2668
|
}
|
|
2667
2669
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2668
|
-
var i = K, a = typeof Object.is == "function" ? Object.is : r, n = i.useState, l = i.useEffect,
|
|
2669
|
-
|
|
2670
|
-
})()),
|
|
2670
|
+
var i = K, a = typeof Object.is == "function" ? Object.is : r, n = i.useState, l = i.useEffect, d = i.useLayoutEffect, u = i.useDebugValue, v = !1, o = !1, p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : e;
|
|
2671
|
+
T.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : p, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
2672
|
+
})()), T;
|
|
2671
2673
|
}
|
|
2672
2674
|
var H;
|
|
2673
|
-
function
|
|
2674
|
-
return H || (H = 1, process.env.NODE_ENV === "production" ? N.exports =
|
|
2675
|
+
function ye() {
|
|
2676
|
+
return H || (H = 1, process.env.NODE_ENV === "production" ? N.exports = pe() : N.exports = me()), N.exports;
|
|
2675
2677
|
}
|
|
2676
|
-
var
|
|
2677
|
-
function
|
|
2678
|
+
var C = ye();
|
|
2679
|
+
function ge(r, e) {
|
|
2678
2680
|
if (r === e) return !0;
|
|
2679
2681
|
if (r.length !== e.length) return !1;
|
|
2680
2682
|
for (let t = 0; t < r.length; t++)
|
|
@@ -2693,13 +2695,13 @@ function R(r, e, t, s) {
|
|
|
2693
2695
|
v[o] = r[o].value;
|
|
2694
2696
|
i.current = { ...v, __snapshot: null };
|
|
2695
2697
|
}
|
|
2696
|
-
const
|
|
2698
|
+
const d = _(
|
|
2697
2699
|
(v) => {
|
|
2698
2700
|
let o = !0;
|
|
2699
|
-
return
|
|
2700
|
-
const
|
|
2701
|
-
for (const f in
|
|
2702
|
-
|
|
2701
|
+
return E(() => {
|
|
2702
|
+
const h = a.current;
|
|
2703
|
+
for (const f in h)
|
|
2704
|
+
h[f].value;
|
|
2703
2705
|
if (o) {
|
|
2704
2706
|
o = !1;
|
|
2705
2707
|
return;
|
|
@@ -2708,32 +2710,32 @@ function R(r, e, t, s) {
|
|
|
2708
2710
|
});
|
|
2709
2711
|
},
|
|
2710
2712
|
[s]
|
|
2711
|
-
), u =
|
|
2713
|
+
), u = _(() => {
|
|
2712
2714
|
const v = i.current, o = a.current, p = {};
|
|
2713
2715
|
for (const f in o)
|
|
2714
2716
|
p[f] = o[f].value;
|
|
2715
|
-
let
|
|
2717
|
+
let h = !1;
|
|
2716
2718
|
for (const f of n.current) {
|
|
2717
2719
|
const { key: m, useShallowArrayEqual: b } = f, y = p[m], k = v[m];
|
|
2718
2720
|
if (b) {
|
|
2719
|
-
if (!
|
|
2720
|
-
|
|
2721
|
+
if (!ge(k, y)) {
|
|
2722
|
+
h = !0;
|
|
2721
2723
|
break;
|
|
2722
2724
|
}
|
|
2723
2725
|
} else if (k !== y) {
|
|
2724
|
-
|
|
2726
|
+
h = !0;
|
|
2725
2727
|
break;
|
|
2726
2728
|
}
|
|
2727
2729
|
}
|
|
2728
|
-
if (!
|
|
2730
|
+
if (!h && v.__snapshot)
|
|
2729
2731
|
return v.__snapshot;
|
|
2730
2732
|
for (const f in o)
|
|
2731
2733
|
v[f] = p[f];
|
|
2732
2734
|
return v.__snapshot = l.current(p), v.__snapshot;
|
|
2733
2735
|
}, [s]);
|
|
2734
|
-
return
|
|
2736
|
+
return C.useSyncExternalStore(d, u, u);
|
|
2735
2737
|
}
|
|
2736
|
-
function
|
|
2738
|
+
function be(r) {
|
|
2737
2739
|
const e = {
|
|
2738
2740
|
value: r.value,
|
|
2739
2741
|
disabled: r.disabled,
|
|
@@ -2756,7 +2758,7 @@ function me(r) {
|
|
|
2756
2758
|
{ key: "dirty" },
|
|
2757
2759
|
{ key: "shouldShowError" },
|
|
2758
2760
|
{ key: "componentProps" }
|
|
2759
|
-
], s =
|
|
2761
|
+
], s = _(
|
|
2760
2762
|
(i) => ({
|
|
2761
2763
|
value: i.value,
|
|
2762
2764
|
pending: i.pending,
|
|
@@ -2773,7 +2775,7 @@ function me(r) {
|
|
|
2773
2775
|
);
|
|
2774
2776
|
return R(e, t, s, r);
|
|
2775
2777
|
}
|
|
2776
|
-
function
|
|
2778
|
+
function Ee(r) {
|
|
2777
2779
|
const e = {
|
|
2778
2780
|
value: r.value,
|
|
2779
2781
|
length: r.length,
|
|
@@ -2794,7 +2796,7 @@ function ye(r) {
|
|
|
2794
2796
|
{ key: "touched" },
|
|
2795
2797
|
{ key: "dirty" },
|
|
2796
2798
|
{ key: "disabled" }
|
|
2797
|
-
], s =
|
|
2799
|
+
], s = _(
|
|
2798
2800
|
(i) => ({
|
|
2799
2801
|
value: i.value,
|
|
2800
2802
|
length: i.length,
|
|
@@ -2810,8 +2812,8 @@ function ye(r) {
|
|
|
2810
2812
|
);
|
|
2811
2813
|
return R(e, t, s, r);
|
|
2812
2814
|
}
|
|
2813
|
-
function
|
|
2814
|
-
const r =
|
|
2815
|
+
function _e() {
|
|
2816
|
+
const r = _(
|
|
2815
2817
|
() => ({
|
|
2816
2818
|
value: [],
|
|
2817
2819
|
length: 0,
|
|
@@ -2827,15 +2829,15 @@ function ge() {
|
|
|
2827
2829
|
);
|
|
2828
2830
|
return R({}, [], r);
|
|
2829
2831
|
}
|
|
2830
|
-
function
|
|
2832
|
+
function Me(r) {
|
|
2831
2833
|
const e = r && "length" in r && "map" in r;
|
|
2832
|
-
return r ? e ?
|
|
2834
|
+
return r ? e ? Ee(r) : be(r) : _e();
|
|
2833
2835
|
}
|
|
2834
|
-
function
|
|
2835
|
-
const e = O({ value: r.value.value }), t =
|
|
2836
|
+
function xe(r) {
|
|
2837
|
+
const e = O({ value: r.value.value }), t = _(
|
|
2836
2838
|
(i) => {
|
|
2837
2839
|
let a = !0;
|
|
2838
|
-
return
|
|
2840
|
+
return E(() => {
|
|
2839
2841
|
if (r.value.value, a) {
|
|
2840
2842
|
a = !1;
|
|
2841
2843
|
return;
|
|
@@ -2844,17 +2846,17 @@ function Fe(r) {
|
|
|
2844
2846
|
});
|
|
2845
2847
|
},
|
|
2846
2848
|
[r]
|
|
2847
|
-
), s =
|
|
2849
|
+
), s = _(() => {
|
|
2848
2850
|
const i = r.value.value;
|
|
2849
2851
|
return e.current.value === i ? e.current.value : (e.current.value = i, i);
|
|
2850
2852
|
}, [r]);
|
|
2851
|
-
return
|
|
2853
|
+
return C.useSyncExternalStore(t, s, s);
|
|
2852
2854
|
}
|
|
2853
|
-
function
|
|
2854
|
-
const e = O({ length: r.length.value }), t =
|
|
2855
|
+
function Ce(r) {
|
|
2856
|
+
const e = O({ length: r.length.value }), t = _(
|
|
2855
2857
|
(i) => {
|
|
2856
2858
|
let a = !0;
|
|
2857
|
-
return
|
|
2859
|
+
return E(() => {
|
|
2858
2860
|
if (r.length.value, a) {
|
|
2859
2861
|
a = !1;
|
|
2860
2862
|
return;
|
|
@@ -2863,52 +2865,67 @@ function Oe(r) {
|
|
|
2863
2865
|
});
|
|
2864
2866
|
},
|
|
2865
2867
|
[r]
|
|
2866
|
-
), s =
|
|
2868
|
+
), s = _(() => {
|
|
2867
2869
|
const i = r.length.value;
|
|
2868
2870
|
return e.current.length === i ? e.current.length : (e.current.length = i, i);
|
|
2869
2871
|
}, [r]);
|
|
2870
|
-
return
|
|
2872
|
+
return C.useSyncExternalStore(t, s, s);
|
|
2873
|
+
}
|
|
2874
|
+
function Pe(r) {
|
|
2875
|
+
const { model: e, schema: t, strategy: s, debounce: i, liveAfterSubmit: a } = r, n = ee(
|
|
2876
|
+
() => se(e, t, { strategy: s, debounce: i, liveAfterSubmit: a }),
|
|
2877
|
+
[e, t, s, i, a]
|
|
2878
|
+
);
|
|
2879
|
+
te(() => n.start(), [n]);
|
|
2880
|
+
const l = C.useSyncExternalStore(
|
|
2881
|
+
_((u) => n.validating.subscribe(u), [n]),
|
|
2882
|
+
() => n.validating.peek(),
|
|
2883
|
+
() => !1
|
|
2884
|
+
// SSR: прогон не идёт
|
|
2885
|
+
), d = _(() => n.validate(), [n]);
|
|
2886
|
+
return { submit: d, validate: d, isValidating: l };
|
|
2871
2887
|
}
|
|
2872
2888
|
export {
|
|
2873
2889
|
U as ArrayNode,
|
|
2874
2890
|
A as ErrorStrategy,
|
|
2875
|
-
|
|
2891
|
+
ae as FieldNode,
|
|
2876
2892
|
F as FormErrorHandler,
|
|
2877
2893
|
M as FormNode,
|
|
2878
|
-
|
|
2879
|
-
|
|
2894
|
+
re as FormStatusMachine,
|
|
2895
|
+
oe as FormSubmitter,
|
|
2880
2896
|
S as GroupNode,
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2897
|
+
de as ModelArrayNode,
|
|
2898
|
+
ue as NodeFactory,
|
|
2899
|
+
I as SubscriptionManager,
|
|
2900
|
+
Re as computeFrom,
|
|
2901
|
+
Be as copyFrom,
|
|
2902
|
+
Oe as createForm,
|
|
2887
2903
|
Q as createFormFromModel,
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2904
|
+
Ie as createModel,
|
|
2905
|
+
st as disableWhen,
|
|
2906
|
+
it as enableWhen,
|
|
2907
|
+
et as getNodeForSignal,
|
|
2908
|
+
Ne as getNodeType,
|
|
2909
|
+
ve as isArrayNode,
|
|
2894
2910
|
B as isDerived,
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2911
|
+
ce as isFieldNode,
|
|
2912
|
+
x as isFormNode,
|
|
2913
|
+
fe as isGroupNode,
|
|
2914
|
+
Ye as markDerived,
|
|
2899
2915
|
Z as registerSignalNode,
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2916
|
+
$e as resetWhen,
|
|
2917
|
+
Ge as revalidateWhen,
|
|
2918
|
+
je as runOutsideEffect,
|
|
2919
|
+
Ue as safeCallback,
|
|
2920
|
+
We as safeDebouncedCallback,
|
|
2921
|
+
qe as syncFields,
|
|
2922
|
+
He as transformValue,
|
|
2907
2923
|
V as uniqueId,
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2924
|
+
ze as unmarkDerived,
|
|
2925
|
+
Ce as useArrayLength,
|
|
2926
|
+
Me as useFormControl,
|
|
2927
|
+
xe as useFormControlValue,
|
|
2928
|
+
Pe as useFormValidation,
|
|
2929
|
+
Xe as validators,
|
|
2930
|
+
Ke as watchField
|
|
2914
2931
|
};
|