@reformer/core 1.1.0-beta.2 → 1.1.0-beta.4

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.
@@ -1,6 +1,6 @@
1
- import { d, w as l, E as c, c as w, V as A, B as F } from "./create-field-path-CdPF3lIK.js";
2
- import { v4 as k } from "uuid";
3
- class g {
1
+ import { d, w as l, E as c, V as A, c as k, B as x } from "./create-field-path-DcXDTWil.js";
2
+ import { v4 as S } from "uuid";
3
+ class b {
4
4
  // ============================================================================
5
5
  // Protected состояние (для Template Method паттерна)
6
6
  // ============================================================================
@@ -277,7 +277,7 @@ class g {
277
277
  onEnable() {
278
278
  }
279
279
  }
280
- class _ {
280
+ class V {
281
281
  /**
282
282
  * Хранилище подписок
283
283
  * Ключ: уникальный идентификатор подписки
@@ -445,8 +445,8 @@ class _ {
445
445
  this.clear();
446
446
  }
447
447
  }
448
- var v = /* @__PURE__ */ ((r) => (r.THROW = "throw", r.LOG = "log", r.CONVERT = "convert", r))(v || {});
449
- class m {
448
+ var y = /* @__PURE__ */ ((r) => (r.THROW = "throw", r.LOG = "log", r.CONVERT = "convert", r))(y || {});
449
+ class p {
450
450
  /**
451
451
  * Обработать ошибку согласно заданной стратегии
452
452
  *
@@ -578,7 +578,7 @@ class m {
578
578
  return typeof t == "object" && t !== null && "code" in t && "message" in t && typeof t.code == "string" && typeof t.message == "string";
579
579
  }
580
580
  }
581
- class R extends g {
581
+ class F extends b {
582
582
  // ============================================================================
583
583
  // Приватные сигналы
584
584
  // ============================================================================
@@ -619,7 +619,7 @@ class R extends g {
619
619
  * Менеджер подписок для централизованного cleanup
620
620
  * Использует SubscriptionManager вместо массива для управления подписками
621
621
  */
622
- disposers = new _();
622
+ disposers = new V();
623
623
  component;
624
624
  // ============================================================================
625
625
  // Конструктор
@@ -764,10 +764,10 @@ class R extends g {
764
764
  try {
765
765
  return await n(this._value.value);
766
766
  } catch (o) {
767
- return m.handle(
767
+ return p.handle(
768
768
  o,
769
769
  "FieldNode AsyncValidator",
770
- v.CONVERT
770
+ y.CONVERT
771
771
  );
772
772
  }
773
773
  })
@@ -942,10 +942,10 @@ class R extends g {
942
942
  this.disposers.dispose(), this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0);
943
943
  }
944
944
  }
945
- function S() {
946
- return b("");
945
+ function R() {
946
+ return E("");
947
947
  }
948
- function b(r) {
948
+ function E(r) {
949
949
  return new Proxy({}, {
950
950
  get(t, e) {
951
951
  if (typeof e == "symbol")
@@ -972,14 +972,14 @@ function b(r) {
972
972
  if (n === "__path") return i;
973
973
  if (n === "__key") return e;
974
974
  if (n !== "__formType" && n !== "__fieldType" && !(n === "then" || n === "catch" || n === "finally" || n === "constructor" || n === "toString" || n === "valueOf" || n === "toJSON"))
975
- return b(`${i}.${n}`);
975
+ return E(`${i}.${n}`);
976
976
  }
977
977
  }
978
978
  });
979
979
  }
980
980
  });
981
981
  }
982
- function x(r) {
982
+ function M(r) {
983
983
  if (typeof r == "string")
984
984
  return r;
985
985
  if (r && typeof r == "object") {
@@ -989,11 +989,11 @@ function x(r) {
989
989
  }
990
990
  throw new Error("Invalid field path node: " + JSON.stringify(r));
991
991
  }
992
- function L(r) {
993
- const t = x(r);
994
- return b(t);
995
- }
996
992
  function K(r) {
993
+ const t = M(r);
994
+ return E(t);
995
+ }
996
+ function z(r) {
997
997
  if (r && typeof r == "object" && "__key" in r)
998
998
  return r.__key;
999
999
  if (typeof r == "string") {
@@ -1002,7 +1002,7 @@ function K(r) {
1002
1002
  }
1003
1003
  throw new Error("Invalid field path node");
1004
1004
  }
1005
- class E extends g {
1005
+ class m extends b {
1006
1006
  // ============================================================================
1007
1007
  // Приватные поля
1008
1008
  // ============================================================================
@@ -1013,7 +1013,7 @@ class E extends g {
1013
1013
  * Менеджер подписок для централизованного cleanup
1014
1014
  * Использует SubscriptionManager вместо массива для управления подписками
1015
1015
  */
1016
- disposers = new _();
1016
+ disposers = new V();
1017
1017
  // ============================================================================
1018
1018
  // Приватные поля для сохранения схем
1019
1019
  // ============================================================================
@@ -1226,7 +1226,7 @@ class E extends g {
1226
1226
  */
1227
1227
  createItem(t) {
1228
1228
  if (this.isGroupSchema(this.itemSchema)) {
1229
- const e = new y(this.itemSchema);
1229
+ const e = new f(this.itemSchema);
1230
1230
  return t && e.patchValue(t), this.validationSchemaFn && "applyValidationSchema" in e && e.applyValidationSchema(this.validationSchemaFn), this.behaviorSchemaFn && "applyBehaviorSchema" in e && e.applyBehaviorSchema(this.behaviorSchemaFn), e;
1231
1231
  }
1232
1232
  throw new Error(
@@ -1315,7 +1315,7 @@ class E extends g {
1315
1315
  watchItems(t, e) {
1316
1316
  const i = c(() => {
1317
1317
  const a = this.items.value.map((n) => {
1318
- if (n instanceof y)
1318
+ if (n instanceof f)
1319
1319
  return n.getFieldByPath(t)?.value.value;
1320
1320
  });
1321
1321
  e(a);
@@ -1412,28 +1412,44 @@ class E extends g {
1412
1412
  });
1413
1413
  }
1414
1414
  }
1415
- function f(r) {
1415
+ function g(r) {
1416
+ return r instanceof F ? [r] : r instanceof f ? Array.from(r.getAllFields()).flatMap(g) : r instanceof m ? r.map((t) => g(t)).flat() : [];
1417
+ }
1418
+ async function J(r, t) {
1419
+ const e = new A();
1420
+ e.beginRegistration();
1421
+ let i = [], s = !1;
1422
+ try {
1423
+ const a = R();
1424
+ t(a), i = e.getCurrentContext()?.getValidators() || [], e.cancelRegistration(), s = !0, r.clearErrors();
1425
+ const o = g(r);
1426
+ return await Promise.all(o.map((h) => h.validate())), i.length > 0 && await r.applyContextualValidators(i), r.valid.value;
1427
+ } catch (a) {
1428
+ throw s || e.cancelRegistration(), a;
1429
+ }
1430
+ }
1431
+ function v(r) {
1416
1432
  return r == null ? !1 : typeof r == "object" && "value" in r && "setValue" in r && "getValue" in r && "validate" in r;
1417
1433
  }
1418
- function p(r) {
1419
- return r == null ? !1 : f(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
1434
+ function _(r) {
1435
+ return r == null ? !1 : v(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
1420
1436
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1421
1437
  typeof r.markAsTouched == "function" && // У FieldNode нет fields или items
1422
1438
  !("fields" in r) && !("items" in r);
1423
1439
  }
1424
- function M(r) {
1425
- return r == null ? !1 : f(r) && "applyValidationSchema" in r && "applyBehaviorSchema" in r && "getFieldByPath" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode)
1440
+ function P(r) {
1441
+ return r == null ? !1 : v(r) && "applyValidationSchema" in r && "applyBehaviorSchema" in r && "getFieldByPath" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode)
1426
1442
  !("items" in r) && !("push" in r) && !("removeAt" in r);
1427
1443
  }
1428
- function P(r) {
1429
- return r == null ? !1 : f(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
1444
+ function N(r) {
1445
+ return r == null ? !1 : v(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
1430
1446
  typeof r.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
1431
1447
  typeof r.removeAt == "function";
1432
1448
  }
1433
- function z(r) {
1434
- return p(r) ? "FieldNode" : M(r) ? "GroupNode" : P(r) ? "ArrayNode" : f(r) ? "FormNode" : "Unknown";
1449
+ function W(r) {
1450
+ return _(r) ? "FieldNode" : P(r) ? "GroupNode" : N(r) ? "ArrayNode" : v(r) ? "FormNode" : "Unknown";
1435
1451
  }
1436
- class N {
1452
+ class I {
1437
1453
  _form;
1438
1454
  control;
1439
1455
  /**
@@ -1456,10 +1472,10 @@ class N {
1456
1472
  */
1457
1473
  setFieldValue(t, e) {
1458
1474
  const i = this._form.getFieldByPath(t);
1459
- i && f(i) && i.setValue(e, { emitEvent: !1 });
1475
+ i && v(i) && i.setValue(e, { emitEvent: !1 });
1460
1476
  }
1461
1477
  }
1462
- class I {
1478
+ class T {
1463
1479
  _form;
1464
1480
  /**
1465
1481
  * Форма с типизированным Proxy-доступом к полям
@@ -1474,10 +1490,10 @@ class I {
1474
1490
  */
1475
1491
  setFieldValue(t, e) {
1476
1492
  const i = this._form.getFieldByPath(t);
1477
- i && f(i) && i.setValue(e, { emitEvent: !1 });
1493
+ i && v(i) && i.setValue(e, { emitEvent: !1 });
1478
1494
  }
1479
1495
  }
1480
- class T {
1496
+ class D {
1481
1497
  form;
1482
1498
  constructor(t) {
1483
1499
  this.form = t;
@@ -1535,22 +1551,22 @@ class T {
1535
1551
  console.warn(`Field ${e} not found in GroupNode`);
1536
1552
  continue;
1537
1553
  }
1538
- if (!p(s)) {
1554
+ if (!_(s)) {
1539
1555
  process.env.NODE_ENV !== "production" && console.warn(`Validation can only run on FieldNode, skipping ${e}`);
1540
1556
  continue;
1541
1557
  }
1542
- const a = [], n = new N(this.form, e, s);
1558
+ const a = [], n = new I(this.form, e, s);
1543
1559
  for (const o of i)
1544
1560
  if (!(o.condition && !this.checkCondition(o.condition)))
1545
1561
  try {
1546
1562
  let h = null;
1547
- const u = n.value(), V = o.validator;
1548
- o.type === "sync" ? h = V(u, n) : o.type === "async" && (h = await V(u, n)), h && a.push(h);
1563
+ const u = n.value(), w = o.validator;
1564
+ o.type === "sync" ? h = w(u, n) : o.type === "async" && (h = await w(u, n)), h && a.push(h);
1549
1565
  } catch (h) {
1550
- m.handle(
1566
+ p.handle(
1551
1567
  h,
1552
1568
  `ValidationApplicator: validator for ${e}`,
1553
- v.LOG
1569
+ y.LOG
1554
1570
  );
1555
1571
  }
1556
1572
  a.length > 0 ? s.setErrors(a) : s.errors.value.length > 0 && !s.errors.value.some((o) => o.code !== "contextual") && s.clearErrors();
@@ -1566,7 +1582,7 @@ class T {
1566
1582
  */
1567
1583
  applyTreeValidators(t) {
1568
1584
  for (const e of t) {
1569
- const i = new I(this.form);
1585
+ const i = new T(this.form);
1570
1586
  if (!(e.condition && !this.checkCondition(e.condition)))
1571
1587
  try {
1572
1588
  if (e.type !== "tree")
@@ -1576,14 +1592,14 @@ class T {
1576
1592
  const a = e.options.targetField;
1577
1593
  if (a) {
1578
1594
  const n = this.form.getFieldByPath(String(a));
1579
- if (n && p(n)) {
1595
+ if (n && _(n)) {
1580
1596
  const o = n.errors.value;
1581
1597
  n.setErrors([...o, s]);
1582
1598
  }
1583
1599
  }
1584
1600
  }
1585
1601
  } catch (s) {
1586
- m.handle(s, "ValidationApplicator: tree validator", v.LOG);
1602
+ p.handle(s, "ValidationApplicator: tree validator", y.LOG);
1587
1603
  }
1588
1604
  }
1589
1605
  }
@@ -1604,7 +1620,7 @@ class T {
1604
1620
  return t.conditionFn(i);
1605
1621
  }
1606
1622
  }
1607
- class D {
1623
+ class B {
1608
1624
  form;
1609
1625
  behaviorRegistry;
1610
1626
  constructor(t, e) {
@@ -1645,16 +1661,16 @@ class D {
1645
1661
  apply(t) {
1646
1662
  this.behaviorRegistry.beginRegistration();
1647
1663
  try {
1648
- const e = w();
1664
+ const e = k();
1649
1665
  t(e);
1650
1666
  const i = this.form.getProxy();
1651
1667
  return this.behaviorRegistry.endRegistration(i).cleanup;
1652
1668
  } catch (e) {
1653
- throw m.handle(e, "BehaviorApplicator", v.THROW), e;
1669
+ throw p.handle(e, "BehaviorApplicator", y.THROW), e;
1654
1670
  }
1655
1671
  }
1656
1672
  }
1657
- class B {
1673
+ class C {
1658
1674
  /**
1659
1675
  * Парсит путь в массив сегментов
1660
1676
  *
@@ -2105,7 +2121,7 @@ class O {
2105
2121
  return this.fields;
2106
2122
  }
2107
2123
  }
2108
- class C {
2124
+ class $ {
2109
2125
  /**
2110
2126
  * @param fieldRegistry - Реестр полей для доступа к коллекции
2111
2127
  */
@@ -2198,7 +2214,7 @@ class C {
2198
2214
  });
2199
2215
  }
2200
2216
  }
2201
- class $ {
2217
+ class G {
2202
2218
  // ============================================================================
2203
2219
  // Конструктор
2204
2220
  // ============================================================================
@@ -2377,11 +2393,11 @@ class $ {
2377
2393
  return this._disabled.value;
2378
2394
  }
2379
2395
  }
2380
- class y extends g {
2396
+ class f extends b {
2381
2397
  // ============================================================================
2382
2398
  // Приватные поля
2383
2399
  // ============================================================================
2384
- id = k();
2400
+ id = S();
2385
2401
  /**
2386
2402
  * Реестр полей формы
2387
2403
  * Использует FieldRegistry для инкапсуляции логики управления коллекцией полей
@@ -2402,7 +2418,7 @@ class y extends g {
2402
2418
  * Менеджер подписок для централизованного cleanup
2403
2419
  * Использует SubscriptionManager вместо массива для управления подписками
2404
2420
  */
2405
- disposers = new _();
2421
+ disposers = new V();
2406
2422
  /**
2407
2423
  * Ссылка на Proxy-инстанс для использования в BehaviorContext
2408
2424
  * Устанавливается в конструкторе до применения behavior schema
@@ -2412,12 +2428,12 @@ class y extends g {
2412
2428
  * Навигатор для работы с путями к полям
2413
2429
  * Использует композицию вместо дублирования логики парсинга путей
2414
2430
  */
2415
- pathNavigator = new B();
2431
+ pathNavigator = new C();
2416
2432
  /**
2417
2433
  * Фабрика для создания узлов формы
2418
2434
  * Использует композицию для централизованного создания FieldNode/GroupNode/ArrayNode
2419
2435
  */
2420
- nodeFactory = new G();
2436
+ nodeFactory = new U();
2421
2437
  /**
2422
2438
  * Реестр валидаторов для этой формы
2423
2439
  * Использует композицию вместо глобального Singleton
@@ -2429,19 +2445,19 @@ class y extends g {
2429
2445
  * Использует композицию вместо глобального Singleton
2430
2446
  * Обеспечивает полную изоляцию форм друг от друга
2431
2447
  */
2432
- behaviorRegistry = new F();
2448
+ behaviorRegistry = new x();
2433
2449
  /**
2434
2450
  * Аппликатор для применения валидаторов к форме
2435
2451
  * Извлечен из GroupNode для соблюдения SRP
2436
2452
  * Использует композицию для управления процессом валидации
2437
2453
  */
2438
- validationApplicator = new T(this);
2454
+ validationApplicator = new D(this);
2439
2455
  /**
2440
2456
  * Аппликатор для применения behavior схемы к форме
2441
2457
  * Извлечен из GroupNode для соблюдения SRP
2442
2458
  * Использует композицию для управления процессом применения behaviors
2443
2459
  */
2444
- behaviorApplicator = new D(this, this.behaviorRegistry);
2460
+ behaviorApplicator = new B(this, this.behaviorRegistry);
2445
2461
  // ============================================================================
2446
2462
  // Публичные computed signals (делегированы в StateManager)
2447
2463
  // ============================================================================
@@ -2455,13 +2471,13 @@ class y extends g {
2455
2471
  status;
2456
2472
  submitting;
2457
2473
  constructor(t) {
2458
- super(), this.fieldRegistry = new O(), this.proxyBuilder = new C(this.fieldRegistry);
2474
+ super(), this.fieldRegistry = new O(), this.proxyBuilder = new $(this.fieldRegistry);
2459
2475
  const e = "form" in t, i = e ? t.form : t, s = e ? t.behavior : void 0, a = e ? t.validation : void 0;
2460
2476
  for (const [o, h] of Object.entries(i)) {
2461
2477
  const u = this.createNode(h);
2462
2478
  this.fieldRegistry.set(o, u);
2463
2479
  }
2464
- this.stateManager = new $(this.fieldRegistry), this.value = this.stateManager.value, this.valid = this.stateManager.valid, this.invalid = this.stateManager.invalid, this.touched = this.stateManager.touched, this.dirty = this.stateManager.dirty, this.pending = this.stateManager.pending, this.errors = this.stateManager.errors, this.status = this.stateManager.status, this.submitting = this.stateManager.submitting;
2480
+ this.stateManager = new G(this.fieldRegistry), this.value = this.stateManager.value, this.valid = this.stateManager.valid, this.invalid = this.stateManager.invalid, this.touched = this.stateManager.touched, this.dirty = this.stateManager.dirty, this.pending = this.stateManager.pending, this.errors = this.stateManager.errors, this.status = this.stateManager.status, this.submitting = this.stateManager.submitting;
2465
2481
  const n = this.proxyBuilder.build(this);
2466
2482
  return this._proxyInstance = n, s && this.applyBehaviorSchema(s), a && this.applyValidationSchema(a), n;
2467
2483
  }
@@ -2710,7 +2726,7 @@ class y extends g {
2710
2726
  applyValidationSchema(t) {
2711
2727
  this.validationRegistry.beginRegistration();
2712
2728
  try {
2713
- const e = S();
2729
+ const e = R();
2714
2730
  t(e);
2715
2731
  const i = this.getProxy();
2716
2732
  this.validationRegistry.endRegistration(i);
@@ -2796,7 +2812,7 @@ class y extends g {
2796
2812
  return;
2797
2813
  let i = this;
2798
2814
  for (const s of e) {
2799
- if (!(i instanceof y) || (i = i.getField(s.key), !i)) return;
2815
+ if (!(i instanceof f) || (i = i.getField(s.key), !i)) return;
2800
2816
  if (s.index !== void 0)
2801
2817
  if ("at" in i && "length" in i && typeof i.at == "function") {
2802
2818
  const a = i.at(s.index);
@@ -2960,7 +2976,7 @@ class y extends g {
2960
2976
  });
2961
2977
  }
2962
2978
  }
2963
- class G {
2979
+ class U {
2964
2980
  /**
2965
2981
  * Создает узел формы на основе конфигурации
2966
2982
  *
@@ -3010,16 +3026,16 @@ class G {
3010
3026
  if (Array.isArray(t) && t.length >= 1)
3011
3027
  return this.createArrayNodeFromArray(t);
3012
3028
  if (this.isFieldConfig(t))
3013
- return new R(t);
3029
+ return new F(t);
3014
3030
  if (this.isArrayConfig(t)) {
3015
3031
  const e = t;
3016
- return new E(
3032
+ return new m(
3017
3033
  e.schema,
3018
3034
  e.initialItems
3019
3035
  );
3020
3036
  }
3021
3037
  if (this.isGroupConfig(t))
3022
- return new y(t);
3038
+ return new f(t);
3023
3039
  throw new Error(
3024
3040
  `NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
3025
3041
  t
@@ -3057,7 +3073,7 @@ class G {
3057
3073
  this.isGroupConfig(e) && s.push(this.extractValues(e));
3058
3074
  for (const a of i)
3059
3075
  this.isGroupConfig(a) ? s.push(this.extractValues(a)) : s.push(a);
3060
- return new E(e, s);
3076
+ return new m(e, s);
3061
3077
  }
3062
3078
  /**
3063
3079
  * Извлечь значения из схемы (рекурсивно)
@@ -3177,24 +3193,25 @@ class G {
3177
3193
  }
3178
3194
  }
3179
3195
  export {
3180
- E as A,
3181
- v as E,
3182
- g as F,
3183
- y as G,
3184
- G as N,
3185
- _ as S,
3186
- I as T,
3187
- N as V,
3188
- R as a,
3189
- B as b,
3190
- p as c,
3191
- M as d,
3192
- P as e,
3193
- m as f,
3194
- z as g,
3195
- x as h,
3196
- f as i,
3197
- S as j,
3198
- K as k,
3199
- L as t
3196
+ m as A,
3197
+ y as E,
3198
+ b as F,
3199
+ f as G,
3200
+ U as N,
3201
+ V as S,
3202
+ T,
3203
+ I as V,
3204
+ F as a,
3205
+ C as b,
3206
+ _ as c,
3207
+ P as d,
3208
+ N as e,
3209
+ p as f,
3210
+ W as g,
3211
+ M as h,
3212
+ v as i,
3213
+ R as j,
3214
+ z as k,
3215
+ K as t,
3216
+ J as v
3200
3217
  };