@reformer/core 10.0.0-beta.2 → 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/index.js CHANGED
@@ -1,13 +1,15 @@
1
- import { S as D } from "./form-model-C8Fi83k4.js";
2
- import { c as Ce } from "./form-model-C8Fi83k4.js";
3
- import { i as B } from "./behaviors-value-lCpqicfa.js";
4
- import { c as Pe, a as Te, m as De, r as Ie, b as Le, d as Re, e as Be, f as $e, s as Ge, t as je, u as Ue, w as We } from "./behaviors-value-lCpqicfa.js";
5
- import { default as He } from "./validators.js";
6
- import { signal as g, computed as c, effect as _, batch as X, Signal as $ } from "@preact/signals-core";
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 Je } from "./signal-node-registry-tiwel-TV.js";
9
- import { d as ze, e as Qe } from "./behaviors-node-DUrqAqp1.js";
10
- import K, { useRef as O, useCallback as E } from "react";
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 ee = 0;
304
+ let ie = 0;
303
305
  function V(r) {
304
- return `${r}-${++ee}`;
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 te {
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 se extends M {
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 D();
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 te(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(
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 (h) => {
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 h(this._value.value, { signal: s });
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((h) => h !== null);
788
+ const l = n.filter((d) => d !== null);
787
789
  if (l.length > 0) {
788
790
  this._errors.value = l;
789
- const h = l.some((u) => u.severity !== "warning");
790
- if (this.statusMachine.completeValidation(h), h)
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 I(r) {
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)), h = c(() => e().some((o) => o.dirty.value)), u = c(() => {
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: h,
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 ie(r, e) {
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 re {
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 ae(r) {
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 D();
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 ne();
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 re(this);
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, h] of Object.entries(a)) {
1208
- const u = this.createNode(h);
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((h, u) => {
1214
- l[u] = h.value.value;
1215
+ return this._fields.forEach((d, u) => {
1216
+ l[u] = d.value.value;
1215
1217
  }), l;
1216
1218
  });
1217
- const n = I({
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 ie(this, this._fields);
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 = ae(e);
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 h = i ? t : e;
1480
- throw new Error(`GroupNode.linkFields: field "${String(h)}" not found`);
1481
+ const d = i ? t : e;
1482
+ throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
1481
1483
  }
1482
- const n = _(() => {
1483
- const h = i.value.value, u = s ? s(h) : h;
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 D();
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 = I({
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 ne {
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 se(e);
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 oe extends M {
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), h = [];
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 && h.push(v);
2338
+ this.cache.delete(u), v && d.push(v);
2337
2339
  }
2338
- this.mountedModels = a, this.itemNodes.value = n, h.forEach((u) => this.disposeItemNode(u));
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 = I({
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 T(r, e, t) {
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) T(a, e, t);
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" && T(n, e, t);
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 h = r.signalAt(l);
2516
- if (!h) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
2517
- const u = s.get(h) ?? {}, { validators: v, asyncValidators: o, ...p } = u;
2518
- i[a] = { ...p, valueSignal: h };
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 && T(t, i, a);
2531
- const n = Y(e, e.get(), "", i), l = new S(n), h = e.get();
2532
- for (const [o, p] of Object.entries(h)) {
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 d = a.get(o);
2535
- if (!d) continue;
2536
- const f = e[o], m = (y) => Q({ model: y, schema: d(y) }), b = new oe(f, m);
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), d = l.getFieldByPath(o);
2543
- if (p && d) {
2544
- Z(p, d);
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(d, p);
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 le = (r) => r != null && typeof r == "object" && "model" in r && typeof r.model?.signalAt == "function";
2552
- function we(r) {
2553
- return le(r) ? Q(r) : new S(r).getProxy();
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 C(r) {
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 ue(r) {
2559
- return r == null ? !1 : C(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
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 de(r) {
2565
- return r == null ? !1 : C(r) && "getFieldByPath" in r && "fields" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
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 he(r) {
2569
- return r == null ? !1 : C(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
+ 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 Ve(r) {
2574
- return ue(r) ? "FieldNode" : de(r) ? "GroupNode" : he(r) ? "ArrayNode" : C(r) ? "FormNode" : "Unknown";
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: {} }, x = {};
2578
+ var N = { exports: {} }, P = {};
2577
2579
  var W;
2578
- function ce() {
2579
- if (W) return x;
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 d = p(), f = s({ inst: { value: d, getSnapshot: p } }), m = f[0].inst, b = f[1];
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 = d, m.getSnapshot = p, h(m) && b({ inst: m });
2592
+ m.value = h, m.getSnapshot = p, d(m) && b({ inst: m });
2591
2593
  },
2592
- [o, d, p]
2594
+ [o, h, p]
2593
2595
  ), i(
2594
2596
  function() {
2595
- return h(m) && b({ inst: m }), o(function() {
2596
- h(m) && b({ inst: m });
2597
+ return d(m) && b({ inst: m }), o(function() {
2598
+ d(m) && b({ inst: m });
2597
2599
  });
2598
2600
  },
2599
2601
  [o]
2600
- ), n(d), d;
2602
+ ), n(h), h;
2601
2603
  }
2602
- function h(o) {
2604
+ function d(o) {
2603
2605
  var p = o.getSnapshot;
2604
2606
  o = o.value;
2605
2607
  try {
2606
- var d = p();
2607
- return !t(o, d);
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 x.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : v, x;
2618
+ return P.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : v, P;
2617
2619
  }
2618
- var P = {};
2620
+ var T = {};
2619
2621
  var q;
2620
- function fe() {
2622
+ function me() {
2621
2623
  return q || (q = 1, process.env.NODE_ENV !== "production" && (function() {
2622
- function r(d, f) {
2623
- return d === f && (d !== 0 || 1 / d === 1 / f) || d !== d && f !== f;
2624
+ function r(h, f) {
2625
+ return h === f && (h !== 0 || 1 / h === 1 / f) || h !== h && f !== f;
2624
2626
  }
2625
- function e(d, f) {
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 h(
2642
+ return d(
2641
2643
  function() {
2642
2644
  y.value = m, y.getSnapshot = f, t(y) && k({ inst: y });
2643
2645
  },
2644
- [d, m, f]
2646
+ [h, m, f]
2645
2647
  ), l(
2646
2648
  function() {
2647
- return t(y) && k({ inst: y }), d(function() {
2649
+ return t(y) && k({ inst: y }), h(function() {
2648
2650
  t(y) && k({ inst: y });
2649
2651
  });
2650
2652
  },
2651
- [d]
2653
+ [h]
2652
2654
  ), u(m), m;
2653
2655
  }
2654
- function t(d) {
2655
- var f = d.getSnapshot;
2656
- d = d.value;
2656
+ function t(h) {
2657
+ var f = h.getSnapshot;
2658
+ h = h.value;
2657
2659
  try {
2658
2660
  var m = f();
2659
- return !a(d, m);
2661
+ return !a(h, m);
2660
2662
  } catch {
2661
2663
  return !0;
2662
2664
  }
2663
2665
  }
2664
- function s(d, f) {
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, h = i.useLayoutEffect, u = i.useDebugValue, v = !1, o = !1, p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : e;
2669
- P.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());
2670
- })()), P;
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 ve() {
2674
- return H || (H = 1, process.env.NODE_ENV === "production" ? N.exports = ce() : N.exports = fe()), 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 L = ve();
2677
- function pe(r, e) {
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 h = E(
2698
+ const d = _(
2697
2699
  (v) => {
2698
2700
  let o = !0;
2699
- return _(() => {
2700
- const d = a.current;
2701
- for (const f in d)
2702
- d[f].value;
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 = E(() => {
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 d = !1;
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 (!pe(k, y)) {
2720
- d = !0;
2721
+ if (!ge(k, y)) {
2722
+ h = !0;
2721
2723
  break;
2722
2724
  }
2723
2725
  } else if (k !== y) {
2724
- d = !0;
2726
+ h = !0;
2725
2727
  break;
2726
2728
  }
2727
2729
  }
2728
- if (!d && v.__snapshot)
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 L.useSyncExternalStore(h, u, u);
2736
+ return C.useSyncExternalStore(d, u, u);
2735
2737
  }
2736
- function me(r) {
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 = E(
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 ye(r) {
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 = E(
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 ge() {
2814
- const r = E(
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 ke(r) {
2832
+ function Me(r) {
2831
2833
  const e = r && "length" in r && "map" in r;
2832
- return r ? e ? ye(r) : me(r) : ge();
2834
+ return r ? e ? Ee(r) : be(r) : _e();
2833
2835
  }
2834
- function Fe(r) {
2835
- const e = O({ value: r.value.value }), t = E(
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 = E(() => {
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 L.useSyncExternalStore(t, s, s);
2853
+ return C.useSyncExternalStore(t, s, s);
2852
2854
  }
2853
- function Oe(r) {
2854
- const e = O({ length: r.length.value }), t = E(
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 = E(() => {
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 L.useSyncExternalStore(t, s, s);
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
- se as FieldNode,
2891
+ ae as FieldNode,
2876
2892
  F as FormErrorHandler,
2877
2893
  M as FormNode,
2878
- te as FormStatusMachine,
2879
- re as FormSubmitter,
2894
+ re as FormStatusMachine,
2895
+ oe as FormSubmitter,
2880
2896
  S as GroupNode,
2881
- oe as ModelArrayNode,
2882
- ne as NodeFactory,
2883
- D as SubscriptionManager,
2884
- Pe as computeFrom,
2885
- Te as copyFrom,
2886
- we as createForm,
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
- Ce as createModel,
2889
- ze as disableWhen,
2890
- Qe as enableWhen,
2891
- Je as getNodeForSignal,
2892
- Ve as getNodeType,
2893
- he as isArrayNode,
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
- ue as isFieldNode,
2896
- C as isFormNode,
2897
- de as isGroupNode,
2898
- De as markDerived,
2911
+ ce as isFieldNode,
2912
+ x as isFormNode,
2913
+ fe as isGroupNode,
2914
+ Ye as markDerived,
2899
2915
  Z as registerSignalNode,
2900
- Ie as resetWhen,
2901
- Le as revalidateWhen,
2902
- Re as runOutsideEffect,
2903
- Be as safeCallback,
2904
- $e as safeDebouncedCallback,
2905
- Ge as syncFields,
2906
- je as transformValue,
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
- Ue as unmarkDerived,
2909
- Oe as useArrayLength,
2910
- ke as useFormControl,
2911
- Fe as useFormControlValue,
2912
- He as validators,
2913
- We as watchField
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
  };