@reformer/core 2.0.0-beta.5 → 2.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- function k() {
1
+ function v() {
2
2
  return h("");
3
3
  }
4
4
  function h(i) {
@@ -58,7 +58,7 @@ function S(i) {
58
58
  }
59
59
  throw new Error("Invalid field path node");
60
60
  }
61
- class d {
61
+ class g {
62
62
  stack = [];
63
63
  /**
64
64
  * Добавить элемент в стек
@@ -149,7 +149,7 @@ class o {
149
149
  * Global stack активных реестров
150
150
  * Используется для изоляции форм друг от друга
151
151
  */
152
- static registryStack = new d();
152
+ static registryStack = new g();
153
153
  contextStack = [];
154
154
  validators = [];
155
155
  /**
@@ -191,7 +191,7 @@ class o {
191
191
  const e = this.contextStack.pop();
192
192
  if (!e)
193
193
  throw new Error("No active registration context");
194
- o.registryStack.verify(this, "ValidationRegistry"), this.validators = e.getValidators(), this.applyValidators(t, this.validators), this.applyArrayItemValidators(t, this.validators);
194
+ o.registryStack.verify(this, "ValidationRegistry"), this.validators = e.getValidators(), this.applyArrayItemValidators(t, this.validators);
195
195
  }
196
196
  /**
197
197
  * Отменить регистрацию без применения валидаторов
@@ -301,19 +301,6 @@ class o {
301
301
  getValidators() {
302
302
  return this.validators;
303
303
  }
304
- /**
305
- * Применить зарегистрированные валидаторы к GroupNode
306
- * @private
307
- */
308
- applyValidators(t, e) {
309
- const r = /* @__PURE__ */ new Map();
310
- for (const s of e) {
311
- if (s.type === "tree" || s.type === "array-items")
312
- continue;
313
- const a = r.get(s.fieldPath) || [];
314
- a.push(s), r.set(s.fieldPath, a);
315
- }
316
- }
317
304
  /**
318
305
  * Применить array-items validators к ArrayNode элементам
319
306
  * @private
@@ -330,7 +317,7 @@ class o {
330
317
  }
331
318
  }
332
319
  }
333
- class v {
320
+ class k {
334
321
  /**
335
322
  * Форма с типизированным Proxy-доступом к полям
336
323
  */
@@ -359,7 +346,7 @@ class c {
359
346
  * Stack активных контекстов регистрации
360
347
  * Используется для изоляции форм друг от друга
361
348
  */
362
- static contextStack = new d();
349
+ static contextStack = new g();
363
350
  registrations = [];
364
351
  isRegistering = !1;
365
352
  /**
@@ -422,7 +409,7 @@ class c {
422
409
  */
423
410
  endRegistration(t) {
424
411
  this.isRegistering = !1, c.contextStack.verify(this, "BehaviorRegistry");
425
- const e = new v(t), r = [];
412
+ const e = new k(t), r = [];
426
413
  for (const a of this.registrations) {
427
414
  const n = this.createEffect(a, t, e);
428
415
  n && r.push(n);
@@ -444,11 +431,11 @@ class c {
444
431
  let n = null;
445
432
  const f = (u) => {
446
433
  a > 0 ? (n && clearTimeout(n), n = setTimeout(u, a)) : u();
447
- }, g = () => {
434
+ }, d = () => {
448
435
  n && (clearTimeout(n), n = null);
449
436
  }, l = s(e, r, f);
450
437
  return l ? () => {
451
- g(), l && l();
438
+ d(), l && l();
452
439
  } : null;
453
440
  }
454
441
  }
@@ -478,12 +465,12 @@ function m() {
478
465
  }
479
466
  export {
480
467
  c as B,
481
- d as R,
468
+ g as R,
482
469
  o as V,
483
470
  S as a,
484
471
  m as b,
485
- k as c,
486
- v as d,
472
+ v as c,
473
+ k as d,
487
474
  y as e,
488
475
  _ as g,
489
476
  C as t
@@ -1,17 +1,17 @@
1
- import { e as u, g as c, t as d, c as o, V as y, a as w } from "./registry-helpers-BRxAr6nG.js";
1
+ import { e as c, g as i, t as y, c as d, V as x, a as $ } from "./registry-helpers--8-OogF8.js";
2
2
  function m(r, e, a) {
3
3
  if (!r) return;
4
- const t = u(r);
5
- c().registerSync(t, e, a);
4
+ const t = c(r);
5
+ i().registerSync(t, e, a);
6
6
  }
7
7
  function V(r, e, a) {
8
- const t = u(r);
9
- c().registerAsync(t, e, a);
10
- }
11
- function $(r, e) {
12
- c().registerTree(r, e);
8
+ const t = c(r);
9
+ i().registerAsync(t, e, a);
13
10
  }
14
11
  function b(r, e) {
12
+ i().registerTree(r, e);
13
+ }
14
+ function D(r, e) {
15
15
  if (!Array.isArray(r) && !Array.isArray(e) && r && !("__key" in r) && !("__path" in r)) {
16
16
  e(r);
17
17
  return;
@@ -20,22 +20,22 @@ function b(r, e) {
20
20
  Boolean
21
21
  ), t = Array.isArray(e) ? e : [e];
22
22
  for (const n of a) {
23
- const s = d(n);
24
- for (const l of t)
25
- l(s);
23
+ const s = y(n);
24
+ for (const u of t)
25
+ u(s);
26
26
  }
27
27
  }
28
- function D(r, e, a) {
29
- const t = u(r);
30
- c().enterCondition(t, e);
28
+ function N(r, e, a) {
29
+ const t = c(r);
30
+ i().enterCondition(t, e);
31
31
  try {
32
- const n = o();
32
+ const n = d();
33
33
  a(n);
34
34
  } finally {
35
- c().exitCondition();
35
+ i().exitCondition();
36
36
  }
37
37
  }
38
- function N(r, e) {
38
+ function R(r, e) {
39
39
  r && m(r, (a) => a == null || a === "" ? {
40
40
  code: "required",
41
41
  message: e?.message || "Поле обязательно для заполнения",
@@ -46,35 +46,35 @@ function N(r, e) {
46
46
  params: e?.params
47
47
  } : null);
48
48
  }
49
- function P(r, e, a) {
49
+ function C(r, e, a) {
50
50
  r && m(r, (t) => t == null ? null : t < e ? {
51
51
  code: "min",
52
52
  message: a?.message || `Минимальное значение: ${e}`,
53
53
  params: { min: e, actual: t, ...a?.params }
54
54
  } : null);
55
55
  }
56
- function R(r, e, a) {
56
+ function L(r, e, a) {
57
57
  r && m(r, (t) => t == null ? null : t > e ? {
58
58
  code: "max",
59
59
  message: a?.message || `Максимальное значение: ${e}`,
60
60
  params: { max: e, actual: t, ...a?.params }
61
61
  } : null);
62
62
  }
63
- function x(r, e, a) {
63
+ function A(r, e, a) {
64
64
  r && m(r, (t) => t && t.length < e ? {
65
65
  code: "minLength",
66
66
  message: a?.message || `Минимальная длина: ${e} символов`,
67
67
  params: { minLength: e, actualLength: t.length, ...a?.params }
68
68
  } : null);
69
69
  }
70
- function F(r, e, a) {
70
+ function T(r, e, a) {
71
71
  r && m(r, (t) => t && t.length > e ? {
72
72
  code: "maxLength",
73
73
  message: a?.message || `Максимальная длина: ${e} символов`,
74
74
  params: { maxLength: e, actualLength: t.length, ...a?.params }
75
75
  } : null);
76
76
  }
77
- function C(r, e) {
77
+ function P(r, e) {
78
78
  if (!r) return;
79
79
  const a = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
80
80
  m(r, (t) => t ? a.test(t) ? null : {
@@ -83,18 +83,18 @@ function C(r, e) {
83
83
  params: e?.params
84
84
  } : null);
85
85
  }
86
- function L(r, e, a) {
86
+ function F(r, e, a) {
87
87
  r && m(r, (t) => t ? e.test(t) ? null : {
88
88
  code: "pattern",
89
89
  message: a?.message || "Значение не соответствует требуемому формату",
90
90
  params: { pattern: e.source, ...a?.params }
91
91
  } : null);
92
92
  }
93
- function T(r, e) {
93
+ function I(r, e) {
94
94
  if (!r) return;
95
95
  const a = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/i, t = /^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/i;
96
96
  m(r, (n) => n ? (e?.requireProtocol ? t : a).test(n) ? e?.allowedProtocols && e.allowedProtocols.length > 0 && !e.allowedProtocols.some(
97
- (f) => n.toLowerCase().startsWith(`${f}://`)
97
+ (g) => n.toLowerCase().startsWith(`${g}://`)
98
98
  ) ? {
99
99
  code: "url_protocol",
100
100
  message: e?.message || `URL должен использовать один из протоколов: ${e.allowedProtocols.join(", ")}`,
@@ -105,7 +105,7 @@ function T(r, e) {
105
105
  params: e?.params
106
106
  } : null);
107
107
  }
108
- function I(r, e) {
108
+ function q(r, e) {
109
109
  if (!r) return;
110
110
  const a = e?.format || "any", t = {
111
111
  // Международный формат: +1234567890 или +1 234 567 8900
@@ -121,7 +121,7 @@ function I(r, e) {
121
121
  if (!n)
122
122
  return null;
123
123
  if (!t[a].test(n)) {
124
- const l = {
124
+ const u = {
125
125
  international: "Введите телефон в международном формате (например, +1234567890)",
126
126
  ru: "Введите российский номер телефона (например, +7 900 123-45-67)",
127
127
  us: "Введите американский номер телефона (например, (123) 456-7890)",
@@ -129,14 +129,14 @@ function I(r, e) {
129
129
  };
130
130
  return {
131
131
  code: "phone",
132
- message: e?.message || l[a],
132
+ message: e?.message || u[a],
133
133
  params: { format: a, ...e?.params }
134
134
  };
135
135
  }
136
136
  return null;
137
137
  });
138
138
  }
139
- function q(r, e) {
139
+ function z(r, e) {
140
140
  r && m(r, (a) => a == null ? null : typeof a != "number" || isNaN(a) ? {
141
141
  code: "number",
142
142
  message: e?.message || "Значение должно быть числом",
@@ -167,7 +167,7 @@ function q(r, e) {
167
167
  params: e?.params
168
168
  } : null);
169
169
  }
170
- function z(r, e) {
170
+ function j(r, e) {
171
171
  r && m(r, (a) => {
172
172
  if (!a)
173
173
  return null;
@@ -240,69 +240,61 @@ function z(r, e) {
240
240
  });
241
241
  }
242
242
  function B(r, e) {
243
- r && x(r, 1, {
243
+ r && A(r, 1, {
244
244
  message: e?.message || "Массив не должен быть пустым",
245
245
  params: { minLength: 1, ...e?.params }
246
246
  });
247
247
  }
248
- function j(r, e) {
248
+ function k(r, e) {
249
249
  if (!r) return;
250
- const a = u(r);
251
- c().registerArrayItemValidation(a, e);
250
+ const a = c(r);
251
+ i().registerArrayItemValidation(a, e);
252
252
  }
253
- function i(r) {
253
+ function l(r) {
254
254
  return r == null ? !1 : typeof r == "object" && "value" in r && "setValue" in r && "getValue" in r && "validate" in r;
255
255
  }
256
256
  function h(r) {
257
- return r == null ? !1 : i(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
257
+ return r == null ? !1 : l(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
258
258
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
259
259
  typeof r.markAsTouched == "function" && // У FieldNode нет fields или items
260
260
  !("fields" in r) && !("items" in r);
261
261
  }
262
- function A(r) {
263
- return r == null ? !1 : i(r) && "applyValidationSchema" in r && "applyBehaviorSchema" in r && "getFieldByPath" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode)
262
+ function _(r) {
263
+ return r == null ? !1 : l(r) && "applyValidationSchema" in r && "applyBehaviorSchema" in r && "getFieldByPath" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode)
264
264
  !("items" in r) && !("push" in r) && !("removeAt" in r);
265
265
  }
266
- function _(r) {
267
- return r == null ? !1 : i(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
266
+ function p(r) {
267
+ return r == null ? !1 : l(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
268
268
  typeof r.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
269
  typeof r.removeAt == "function";
270
270
  }
271
- function K(r) {
272
- return h(r) ? "FieldNode" : A(r) ? "GroupNode" : _(r) ? "ArrayNode" : i(r) ? "FormNode" : "Unknown";
271
+ function S(r) {
272
+ return h(r) ? "FieldNode" : _(r) ? "GroupNode" : p(r) ? "ArrayNode" : l(r) ? "FormNode" : "Unknown";
273
273
  }
274
- function g(r) {
275
- return h(r) ? [r] : A(r) ? Array.from(r.getAllFields()).flatMap(g) : _(r) ? r.map((e) => g(e)).flat() : [];
274
+ function f(r) {
275
+ return h(r) ? [r] : _(r) ? Array.from(r.getAllFields()).flatMap(f) : p(r) ? r.map((e) => f(e)).flat() : [];
276
276
  }
277
- async function E(r, e) {
278
- const a = new y();
277
+ async function M(r, e) {
278
+ const a = new x();
279
279
  a.beginRegistration();
280
280
  let t = [], n = !1;
281
281
  try {
282
- const s = o();
282
+ const s = d();
283
283
  e(s), t = a.getCurrentContext()?.getValidators() || [], a.cancelRegistration(), n = !0, r.clearErrors();
284
- const f = g(r);
285
- return await Promise.all(f.map((p) => p.validate())), t.length > 0 && await r.applyContextualValidators(t), r.valid.value;
284
+ const g = f(r);
285
+ return await Promise.all(g.map((w) => w.validate())), t.length > 0 && await r.applyContextualValidators(t), r.valid.value;
286
286
  } catch (s) {
287
287
  throw n || a.cancelRegistration(), s;
288
288
  }
289
289
  }
290
- class k {
290
+ class o {
291
291
  _form;
292
- control;
293
292
  /**
294
293
  * Форма с типизированным Proxy-доступом к полям
295
294
  */
296
295
  form;
297
- constructor(e, a, t) {
298
- this._form = e, this.control = t, this.form = e._proxyInstance || e.getProxy();
299
- }
300
- /**
301
- * Получить текущее значение поля (внутренний метод для validation-applicator)
302
- * @internal
303
- */
304
- value() {
305
- return this.control.value.value;
296
+ constructor(e) {
297
+ this._form = e, this.form = e._proxyInstance || e.getProxy();
306
298
  }
307
299
  /**
308
300
  * Безопасно установить значение поля по строковому пути
@@ -310,36 +302,31 @@ class k {
310
302
  */
311
303
  setFieldValue(e, a) {
312
304
  const t = this._form.getFieldByPath(e);
313
- t && i(t) && t.setValue(a, { emitEvent: !1 });
305
+ t && l(t) && t.setValue(a, { emitEvent: !1 });
314
306
  }
315
307
  }
316
- class M {
317
- _form;
318
- /**
319
- * Форма с типизированным Proxy-доступом к полям
320
- */
321
- form;
322
- constructor(e) {
323
- this._form = e, this.form = e._proxyInstance || e.getProxy();
308
+ class E extends o {
309
+ control;
310
+ constructor(e, a, t) {
311
+ super(e), this.control = t;
324
312
  }
325
313
  /**
326
- * Безопасно установить значение поля по строковому пути
327
- * Автоматически использует emitEvent: false для предотвращения циклов
314
+ * Получить текущее значение поля (внутренний метод для validation-applicator)
315
+ * @internal
328
316
  */
329
- setFieldValue(e, a) {
330
- const t = this._form.getFieldByPath(e);
331
- t && i(t) && t.setValue(a, { emitEvent: !1 });
317
+ value() {
318
+ return this.control.value.value;
332
319
  }
333
320
  }
334
- class S {
335
- _form;
321
+ class H extends o {
322
+ constructor(e) {
323
+ super(e);
324
+ }
325
+ }
326
+ class U extends o {
336
327
  arrayValue;
337
- /**
338
- * Форма с типизированным Proxy-доступом к полям
339
- */
340
- form;
341
328
  constructor(e, a, t) {
342
- this._form = e, this.arrayValue = t, this.form = e._proxyInstance || e.getProxy();
329
+ super(e), this.arrayValue = t;
343
330
  }
344
331
  /**
345
332
  * Получить текущее значение массива (для валидатора)
@@ -348,71 +335,63 @@ class S {
348
335
  value() {
349
336
  return this.arrayValue;
350
337
  }
351
- /**
352
- * Безопасно установить значение поля по строковому пути
353
- * Автоматически использует emitEvent: false для предотвращения циклов
354
- */
355
- setFieldValue(e, a) {
356
- const t = this._form.getFieldByPath(e);
357
- t && i(t) && t.setValue(a, { emitEvent: !1 });
358
- }
359
338
  }
360
- const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
339
+ const W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
361
340
  __proto__: null,
362
- TreeValidationContextImpl: M,
363
- ValidationContextImpl: k,
364
- ValidationRegistry: y,
365
- apply: b,
366
- applyWhen: D,
367
- createFieldPath: o,
368
- date: z,
369
- email: C,
370
- extractKey: w,
371
- extractPath: u,
372
- max: R,
373
- maxLength: F,
374
- min: P,
375
- minLength: x,
341
+ TreeValidationContextImpl: H,
342
+ ValidationContextImpl: E,
343
+ ValidationRegistry: x,
344
+ apply: D,
345
+ applyWhen: N,
346
+ createFieldPath: d,
347
+ date: j,
348
+ email: P,
349
+ extractKey: $,
350
+ extractPath: c,
351
+ max: L,
352
+ maxLength: T,
353
+ min: C,
354
+ minLength: A,
376
355
  notEmpty: B,
377
- number: q,
378
- pattern: L,
379
- phone: I,
380
- required: N,
381
- toFieldPath: d,
382
- url: T,
356
+ number: z,
357
+ pattern: F,
358
+ phone: q,
359
+ required: R,
360
+ toFieldPath: y,
361
+ url: I,
383
362
  validate: m,
384
363
  validateAsync: V,
385
- validateForm: E,
386
- validateItems: j,
387
- validateTree: $
364
+ validateForm: M,
365
+ validateItems: k,
366
+ validateTree: b
388
367
  }, Symbol.toStringTag, { value: "Module" }));
389
368
  export {
390
- S as A,
391
- M as T,
392
- k as V,
393
- _ as a,
394
- U as b,
395
- i as c,
396
- A as d,
369
+ U as A,
370
+ H as T,
371
+ E as V,
372
+ p as a,
373
+ W as b,
374
+ l as c,
375
+ _ as d,
397
376
  m as e,
398
377
  V as f,
399
- K as g,
400
- $ as h,
378
+ S as g,
379
+ b as h,
401
380
  h as i,
402
- b as j,
403
- D as k,
404
- R as l,
405
- P as m,
406
- x as n,
407
- F as o,
408
- C as p,
409
- L as q,
410
- N as r,
411
- I as s,
412
- q as t,
413
- T as u,
414
- E as v,
415
- z as w,
381
+ D as j,
382
+ N as k,
383
+ L as l,
384
+ C as m,
385
+ A as n,
386
+ T as o,
387
+ P as p,
388
+ F as q,
389
+ R as r,
390
+ q as s,
391
+ z as t,
392
+ I as u,
393
+ M as v,
394
+ j as w,
416
395
  B as x,
417
- j as y
396
+ k as y
418
397
  };
@@ -1,5 +1,5 @@
1
- import { T as t, V as s, j as i, k as l, w as r, b as n, p as m, l as o, o as d, m as p, n as x, x as h, t as y, q as v, s as c, r as u, u as V, e as f, f as g, v as F, y as I, h as P } from "./validators-gXoHPdqM.js";
2
- import { V as b, c as q, a as C, e as L, t as j } from "./registry-helpers-BRxAr6nG.js";
1
+ import { T as t, V as s, j as i, k as l, w as r, b as n, p as m, l as o, o as d, m as p, n as x, x as h, t as y, q as v, s as c, r as u, u as V, e as f, f as g, v as F, y as I, h as P } from "./validators-CWdzevnC.js";
2
+ import { V as b, c as q, a as C, e as L, t as j } from "./registry-helpers--8-OogF8.js";
3
3
  export {
4
4
  t as TreeValidationContextImpl,
5
5
  s as ValidationContextImpl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reformer/core",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.7",
4
4
  "description": "Reactive form state management library for React with signals-based architecture",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",