@reformer/core 1.0.0-beta.1 → 1.0.0-beta.2
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/compute-from.js +3 -3
- package/dist/behaviors/enable-when.js +5 -5
- package/dist/behaviors/reset-when.js +1 -1
- package/dist/behaviors/revalidate-when.js +1 -1
- package/dist/behaviors/sync-fields.js +5 -5
- package/dist/behaviors/watch-field.js +3 -3
- package/dist/behaviors.js +2 -2
- package/dist/core/types/field-path.d.ts +2 -2
- package/dist/core/types/index.d.ts +1 -1
- package/dist/core/types/validation-schema.d.ts +21 -50
- package/dist/core/validation/core/index.d.ts +0 -1
- package/dist/core/validation/core/validate-async.d.ts +9 -15
- package/dist/core/validation/core/validate.d.ts +15 -15
- package/dist/core/validation/index.d.ts +5 -3
- package/dist/core/validation/validation-applicator.d.ts +2 -56
- package/dist/core/validation/validation-registry.d.ts +18 -16
- package/dist/core/validation/validators/array-validators.d.ts +6 -31
- package/dist/core/validation/validators/email.d.ts +5 -29
- package/dist/core/validation/validators/future-date.d.ts +6 -28
- package/dist/core/validation/validators/index.d.ts +12 -4
- package/dist/core/validation/validators/integer.d.ts +13 -0
- package/dist/core/validation/validators/is-date.d.ts +5 -28
- package/dist/core/validation/validators/is-number.d.ts +14 -0
- package/dist/core/validation/validators/max-age.d.ts +6 -29
- package/dist/core/validation/validators/max-date.d.ts +6 -29
- package/dist/core/validation/validators/max-length.d.ts +5 -30
- package/dist/core/validation/validators/max.d.ts +7 -29
- package/dist/core/validation/validators/min-age.d.ts +6 -29
- package/dist/core/validation/validators/min-date.d.ts +6 -29
- package/dist/core/validation/validators/min-length.d.ts +5 -30
- package/dist/core/validation/validators/min.d.ts +7 -29
- package/dist/core/validation/validators/multiple-of.d.ts +13 -0
- package/dist/core/validation/validators/non-negative.d.ts +13 -0
- package/dist/core/validation/validators/non-zero.d.ts +13 -0
- package/dist/core/validation/validators/past-date.d.ts +5 -28
- package/dist/core/validation/validators/pattern.d.ts +5 -32
- package/dist/core/validation/validators/phone.d.ts +9 -19
- package/dist/core/validation/validators/required.d.ts +10 -31
- package/dist/core/validation/validators/url.d.ts +13 -15
- package/dist/{index-D25LsbRm.js → index-DLh_Ryb2.js} +1 -1
- package/dist/index.js +465 -397
- package/dist/{registry-helpers-Bv_BJ1s-.js → registry-helpers-CLPXad2B.js} +152 -292
- package/dist/validators/email.js +7 -9
- package/dist/validators/future-date.js +11 -12
- package/dist/validators/integer.d.ts +2 -0
- package/dist/validators/integer.js +10 -0
- package/dist/validators/is-date.js +6 -7
- package/dist/validators/is-number.d.ts +2 -0
- package/dist/validators/is-number.js +10 -0
- package/dist/validators/max-age.js +11 -12
- package/dist/validators/max-date.js +11 -12
- package/dist/validators/max-length.js +12 -8
- package/dist/validators/max.js +5 -6
- package/dist/validators/min-age.js +10 -11
- package/dist/validators/min-date.js +12 -13
- package/dist/validators/min-length.js +12 -8
- package/dist/validators/min.js +6 -7
- package/dist/validators/multiple-of.d.ts +2 -0
- package/dist/validators/multiple-of.js +10 -0
- package/dist/validators/non-negative.d.ts +2 -0
- package/dist/validators/non-negative.js +10 -0
- package/dist/validators/non-zero.d.ts +2 -0
- package/dist/validators/non-zero.js +10 -0
- package/dist/validators/past-date.js +11 -12
- package/dist/validators/pattern.js +6 -7
- package/dist/validators/phone.js +14 -32
- package/dist/validators/required.js +9 -10
- package/dist/validators/url.js +19 -16
- package/dist/validators-xJyP-jLZ.js +169 -0
- package/dist/validators.js +54 -50
- package/llms.txt +505 -790
- package/package.json +20 -4
- package/dist/core/validation/core/validate-tree.d.ts +0 -35
- package/dist/core/validation/validation-context.d.ts +0 -86
- package/dist/core/validation/validators/number.d.ts +0 -31
- package/dist/validate-C3XiA_zf.js +0 -10
- package/dist/validators/number.d.ts +0 -2
- package/dist/validators/number.js +0 -35
- package/dist/validators-BGsNOgT1.js +0 -207
|
@@ -1,137 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
class y {
|
|
3
|
-
/**
|
|
4
|
-
* Обработать ошибку согласно заданной стратегии
|
|
5
|
-
*
|
|
6
|
-
* @param error Ошибка для обработки (Error | string | unknown)
|
|
7
|
-
* @param context Контекст ошибки для логирования (например, 'AsyncValidator', 'BehaviorRegistry')
|
|
8
|
-
* @param strategy Стратегия обработки (THROW | LOG | CONVERT)
|
|
9
|
-
* @returns ValidationError если strategy = CONVERT, undefined если strategy = LOG, никогда не возвращается если strategy = THROW
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // THROW - пробросить ошибку
|
|
14
|
-
* try {
|
|
15
|
-
* riskyOperation();
|
|
16
|
-
* } catch (error) {
|
|
17
|
-
* FormErrorHandler.handle(error, 'RiskyOperation', ErrorStrategy.THROW);
|
|
18
|
-
* // Этот код никогда не выполнится
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* // LOG - залогировать и продолжить
|
|
22
|
-
* try {
|
|
23
|
-
* nonCriticalOperation();
|
|
24
|
-
* } catch (error) {
|
|
25
|
-
* FormErrorHandler.handle(error, 'NonCritical', ErrorStrategy.LOG);
|
|
26
|
-
* // Продолжаем выполнение
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* // CONVERT - конвертировать в ValidationError
|
|
30
|
-
* try {
|
|
31
|
-
* await validator(value);
|
|
32
|
-
* } catch (error) {
|
|
33
|
-
* const validationError = FormErrorHandler.handle(
|
|
34
|
-
* error,
|
|
35
|
-
* 'AsyncValidator',
|
|
36
|
-
* ErrorStrategy.CONVERT
|
|
37
|
-
* );
|
|
38
|
-
* return validationError;
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
static handle(t, e, i = "throw") {
|
|
43
|
-
const n = this.extractMessage(t);
|
|
44
|
-
switch (i) {
|
|
45
|
-
case "throw":
|
|
46
|
-
throw t;
|
|
47
|
-
case "log":
|
|
48
|
-
return;
|
|
49
|
-
case "convert":
|
|
50
|
-
return {
|
|
51
|
-
code: "validator_error",
|
|
52
|
-
message: n,
|
|
53
|
-
params: { field: e }
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Извлечь сообщение из ошибки
|
|
59
|
-
*
|
|
60
|
-
* Обрабатывает различные типы ошибок:
|
|
61
|
-
* - Error объекты → error.message
|
|
62
|
-
* - Строки → возвращает как есть
|
|
63
|
-
* - Объекты с message → извлекает message
|
|
64
|
-
* - Другое → String(error)
|
|
65
|
-
*
|
|
66
|
-
* @param error Ошибка для извлечения сообщения
|
|
67
|
-
* @returns Сообщение ошибки
|
|
68
|
-
* @private
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* FormErrorHandler.extractMessage(new Error('Test'));
|
|
73
|
-
* // 'Test'
|
|
74
|
-
*
|
|
75
|
-
* FormErrorHandler.extractMessage('String error');
|
|
76
|
-
* // 'String error'
|
|
77
|
-
*
|
|
78
|
-
* FormErrorHandler.extractMessage({ message: 'Object error' });
|
|
79
|
-
* // 'Object error'
|
|
80
|
-
*
|
|
81
|
-
* FormErrorHandler.extractMessage(null);
|
|
82
|
-
* // 'null'
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
static extractMessage(t) {
|
|
86
|
-
return t instanceof Error ? t.message : typeof t == "string" ? t : typeof t == "object" && t !== null && "message" in t ? String(t.message) : String(t);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Создать ValidationError с заданными параметрами
|
|
90
|
-
*
|
|
91
|
-
* Утилитная функция для создания ValidationError объектов
|
|
92
|
-
*
|
|
93
|
-
* @param code Код ошибки
|
|
94
|
-
* @param message Сообщение ошибки
|
|
95
|
-
* @param field Поле (опционально)
|
|
96
|
-
* @returns ValidationError объект
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* const error = FormErrorHandler.createValidationError(
|
|
101
|
-
* 'required',
|
|
102
|
-
* 'This field is required',
|
|
103
|
-
* 'email'
|
|
104
|
-
* );
|
|
105
|
-
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
static createValidationError(t, e, i) {
|
|
109
|
-
return {
|
|
110
|
-
code: t,
|
|
111
|
-
message: e,
|
|
112
|
-
params: i ? { field: i } : void 0
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Проверить, является ли объект ValidationError
|
|
117
|
-
*
|
|
118
|
-
* Type guard для ValidationError
|
|
119
|
-
*
|
|
120
|
-
* @param value Значение для проверки
|
|
121
|
-
* @returns true если value является ValidationError
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```typescript
|
|
125
|
-
* if (FormErrorHandler.isValidationError(result)) {
|
|
126
|
-
* console.log(result.code); // OK, типобезопасно
|
|
127
|
-
* }
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
static isValidationError(t) {
|
|
131
|
-
return typeof t == "object" && t !== null && "code" in t && "message" in t && typeof t.code == "string" && typeof t.message == "string";
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
class m {
|
|
1
|
+
class f {
|
|
135
2
|
stack = [];
|
|
136
3
|
/**
|
|
137
4
|
* Добавить элемент в стек
|
|
@@ -185,79 +52,7 @@ class m {
|
|
|
185
52
|
this.stack = [];
|
|
186
53
|
}
|
|
187
54
|
}
|
|
188
|
-
|
|
189
|
-
class o {
|
|
190
|
-
/** Флаг активной регистрации */
|
|
191
|
-
isRegistering = !1;
|
|
192
|
-
/** Массив зарегистрированных элементов */
|
|
193
|
-
registrations = [];
|
|
194
|
-
/**
|
|
195
|
-
* Получить стек для конкретного класса реестра
|
|
196
|
-
* Создает новый стек если не существует
|
|
197
|
-
*
|
|
198
|
-
* @param ctor - Конструктор класса реестра
|
|
199
|
-
* @returns RegistryStack для данного класса
|
|
200
|
-
*/
|
|
201
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
-
static getStack(t) {
|
|
203
|
-
return l.has(t) || l.set(t, new m()), l.get(t);
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Получить текущий активный реестр из стека
|
|
207
|
-
* Должен быть переопределен в наследниках как static метод
|
|
208
|
-
*
|
|
209
|
-
* @param ctor - Конструктор класса реестра
|
|
210
|
-
* @returns Текущий активный реестр или null
|
|
211
|
-
*/
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
213
|
-
static getCurrentFromStack(t) {
|
|
214
|
-
return this.getStack(t).getCurrent();
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Начать регистрацию
|
|
218
|
-
*
|
|
219
|
-
* Помещает this в global stack для изоляции форм
|
|
220
|
-
* Вызывает hook onBeginRegistration()
|
|
221
|
-
*/
|
|
222
|
-
beginRegistration() {
|
|
223
|
-
this.isRegistering = !0, this.registrations = [], o.getStack(this.constructor).push(this), this.onBeginRegistration();
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Проверить, активна ли регистрация
|
|
227
|
-
*/
|
|
228
|
-
isActive() {
|
|
229
|
-
return this.isRegistering;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Получить зарегистрированные элементы
|
|
233
|
-
*/
|
|
234
|
-
getRegistrations() {
|
|
235
|
-
return this.registrations;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Hook: вызывается в начале регистрации
|
|
239
|
-
* Может быть переопределен в наследниках для инициализации
|
|
240
|
-
*/
|
|
241
|
-
onBeginRegistration() {
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Завершить регистрацию и извлечь из стека
|
|
245
|
-
*
|
|
246
|
-
* @param registryName - Имя реестра для отладки
|
|
247
|
-
*/
|
|
248
|
-
completeRegistration(t) {
|
|
249
|
-
this.isRegistering = !1, o.getStack(this.constructor).verify(this, t);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Отменить регистрацию без применения
|
|
253
|
-
*
|
|
254
|
-
* @param registryName - Имя реестра для отладки
|
|
255
|
-
*/
|
|
256
|
-
cancelRegistration(t) {
|
|
257
|
-
this.isRegistering = !1, this.registrations = [], o.getStack(this.constructor).verify(this, t);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
class x {
|
|
55
|
+
class y {
|
|
261
56
|
validators = [];
|
|
262
57
|
conditionStack = [];
|
|
263
58
|
/**
|
|
@@ -289,10 +84,13 @@ class x {
|
|
|
289
84
|
return this.validators;
|
|
290
85
|
}
|
|
291
86
|
}
|
|
292
|
-
class
|
|
293
|
-
/**
|
|
87
|
+
class a {
|
|
88
|
+
/**
|
|
89
|
+
* Global stack активных реестров
|
|
90
|
+
* Используется для изоляции форм друг от друга
|
|
91
|
+
*/
|
|
92
|
+
static registryStack = new f();
|
|
294
93
|
contextStack = [];
|
|
295
|
-
/** Финальные валидаторы после завершения регистрации */
|
|
296
94
|
validators = [];
|
|
297
95
|
/**
|
|
298
96
|
* Получить текущий активный реестр из global stack
|
|
@@ -311,18 +109,16 @@ class d extends o {
|
|
|
311
109
|
* ```
|
|
312
110
|
*/
|
|
313
111
|
static getCurrent() {
|
|
314
|
-
return
|
|
112
|
+
return a.registryStack.getCurrent();
|
|
315
113
|
}
|
|
316
114
|
/**
|
|
317
115
|
* Начать регистрацию валидаторов для формы
|
|
318
116
|
*
|
|
319
117
|
* Помещает this в global stack для изоляции форм
|
|
320
|
-
* Создает новый RegistrationContext для condition management
|
|
321
118
|
*/
|
|
322
119
|
beginRegistration() {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return this.contextStack.push(t), t;
|
|
120
|
+
const t = new y();
|
|
121
|
+
return this.contextStack.push(t), a.registryStack.push(this), t;
|
|
326
122
|
}
|
|
327
123
|
/**
|
|
328
124
|
* Завершить регистрацию и применить валидаторы к GroupNode
|
|
@@ -335,7 +131,7 @@ class d extends o {
|
|
|
335
131
|
const e = this.contextStack.pop();
|
|
336
132
|
if (!e)
|
|
337
133
|
throw new Error("No active registration context");
|
|
338
|
-
|
|
134
|
+
a.registryStack.verify(this, "ValidationRegistry"), this.validators = e.getValidators(), this.applyValidators(t, this.validators), this.applyArrayItemValidators(t, this.validators);
|
|
339
135
|
}
|
|
340
136
|
/**
|
|
341
137
|
* Отменить регистрацию без применения валидаторов
|
|
@@ -346,7 +142,7 @@ class d extends o {
|
|
|
346
142
|
cancelRegistration() {
|
|
347
143
|
if (!this.contextStack.pop())
|
|
348
144
|
throw new Error("No active registration context to cancel");
|
|
349
|
-
|
|
145
|
+
a.registryStack.verify(this, "ValidationRegistry");
|
|
350
146
|
}
|
|
351
147
|
/**
|
|
352
148
|
* Получить текущий контекст регистрации
|
|
@@ -357,53 +153,39 @@ class d extends o {
|
|
|
357
153
|
/**
|
|
358
154
|
* Зарегистрировать синхронный валидатор
|
|
359
155
|
*/
|
|
360
|
-
registerSync(t, e,
|
|
361
|
-
const
|
|
362
|
-
if (!
|
|
156
|
+
registerSync(t, e, r) {
|
|
157
|
+
const i = this.getCurrentContext();
|
|
158
|
+
if (!i)
|
|
363
159
|
throw new Error("Validators can only be registered inside a validation schema function");
|
|
364
|
-
|
|
160
|
+
i.addValidator({
|
|
365
161
|
fieldPath: t,
|
|
366
162
|
type: "sync",
|
|
367
163
|
validator: e,
|
|
368
|
-
options:
|
|
164
|
+
options: r
|
|
369
165
|
});
|
|
370
166
|
}
|
|
371
167
|
/**
|
|
372
168
|
* Зарегистрировать асинхронный валидатор
|
|
373
169
|
*/
|
|
374
|
-
registerAsync(t, e,
|
|
375
|
-
const n = this.getCurrentContext();
|
|
376
|
-
if (!n)
|
|
377
|
-
throw new Error("Validators can only be registered inside a validation schema function");
|
|
378
|
-
n.addValidator({
|
|
379
|
-
fieldPath: t,
|
|
380
|
-
type: "async",
|
|
381
|
-
validator: e,
|
|
382
|
-
options: i
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Зарегистрировать tree валидатор
|
|
387
|
-
*/
|
|
388
|
-
registerTree(t, e) {
|
|
170
|
+
registerAsync(t, e, r) {
|
|
389
171
|
const i = this.getCurrentContext();
|
|
390
172
|
if (!i)
|
|
391
173
|
throw new Error("Validators can only be registered inside a validation schema function");
|
|
392
174
|
i.addValidator({
|
|
393
|
-
fieldPath:
|
|
394
|
-
type: "
|
|
395
|
-
validator:
|
|
396
|
-
options:
|
|
175
|
+
fieldPath: t,
|
|
176
|
+
type: "async",
|
|
177
|
+
validator: e,
|
|
178
|
+
options: r
|
|
397
179
|
});
|
|
398
180
|
}
|
|
399
181
|
/**
|
|
400
182
|
* Войти в условный блок
|
|
401
183
|
*/
|
|
402
184
|
enterCondition(t, e) {
|
|
403
|
-
const
|
|
404
|
-
if (!
|
|
185
|
+
const r = this.getCurrentContext();
|
|
186
|
+
if (!r)
|
|
405
187
|
throw new Error("Conditions can only be used inside a validation schema function");
|
|
406
|
-
|
|
188
|
+
r.enterCondition(t, e);
|
|
407
189
|
}
|
|
408
190
|
/**
|
|
409
191
|
* Выйти из условного блока
|
|
@@ -424,12 +206,12 @@ class d extends o {
|
|
|
424
206
|
* @param itemSchemaFn - Validation schema для элемента массива
|
|
425
207
|
*/
|
|
426
208
|
registerArrayItemValidation(t, e) {
|
|
427
|
-
const
|
|
428
|
-
if (!
|
|
209
|
+
const r = this.getCurrentContext();
|
|
210
|
+
if (!r)
|
|
429
211
|
throw new Error(
|
|
430
212
|
"Array item validators can only be registered inside a validation schema function"
|
|
431
213
|
);
|
|
432
|
-
|
|
214
|
+
r.addValidator({
|
|
433
215
|
fieldPath: t,
|
|
434
216
|
type: "array-items",
|
|
435
217
|
validator: e,
|
|
@@ -445,28 +227,36 @@ class d extends o {
|
|
|
445
227
|
getValidators() {
|
|
446
228
|
return this.validators;
|
|
447
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Применить зарегистрированные валидаторы к GroupNode
|
|
232
|
+
* @private
|
|
233
|
+
*/
|
|
234
|
+
applyValidators(t, e) {
|
|
235
|
+
const r = /* @__PURE__ */ new Map();
|
|
236
|
+
for (const i of e) {
|
|
237
|
+
if (i.type === "array-items")
|
|
238
|
+
continue;
|
|
239
|
+
const s = r.get(i.fieldPath) || [];
|
|
240
|
+
s.push(i), r.set(i.fieldPath, s);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
448
243
|
/**
|
|
449
244
|
* Применить array-items validators к ArrayNode элементам
|
|
450
245
|
* @private
|
|
451
246
|
*/
|
|
452
247
|
applyArrayItemValidators(t, e) {
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
for (const
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
y.handle(
|
|
462
|
-
new Error(`Field ${n.fieldPath} is not an ArrayNode or doesn't exist`),
|
|
463
|
-
"ValidationRegistry.applyArrayItemValidators",
|
|
464
|
-
f.LOG
|
|
465
|
-
);
|
|
248
|
+
const r = e.filter((i) => i.type === "array-items");
|
|
249
|
+
if (r.length !== 0)
|
|
250
|
+
for (const i of r) {
|
|
251
|
+
const s = t[i.fieldPath.split(".")[0]];
|
|
252
|
+
if (s && "applyValidationSchema" in s) {
|
|
253
|
+
const n = i.validator;
|
|
254
|
+
s.applyValidationSchema(n);
|
|
255
|
+
}
|
|
466
256
|
}
|
|
467
257
|
}
|
|
468
258
|
}
|
|
469
|
-
class
|
|
259
|
+
class k {
|
|
470
260
|
/**
|
|
471
261
|
* Форма с типизированным Proxy-доступом к полям
|
|
472
262
|
*/
|
|
@@ -486,8 +276,8 @@ class C {
|
|
|
486
276
|
* @param value - Новое значение
|
|
487
277
|
*/
|
|
488
278
|
setFieldValue(t, e) {
|
|
489
|
-
const
|
|
490
|
-
|
|
279
|
+
const r = typeof t == "string" ? t : t.__path, i = this._form.getFieldByPath(r);
|
|
280
|
+
i && i.setValue(e, { emitEvent: !1 });
|
|
491
281
|
}
|
|
492
282
|
/**
|
|
493
283
|
* Получить поле формы по строковому пути
|
|
@@ -503,7 +293,79 @@ class C {
|
|
|
503
293
|
return this._form.getFieldByPath(t);
|
|
504
294
|
}
|
|
505
295
|
}
|
|
506
|
-
|
|
296
|
+
const l = /* @__PURE__ */ new Map();
|
|
297
|
+
class c {
|
|
298
|
+
/** Флаг активной регистрации */
|
|
299
|
+
isRegistering = !1;
|
|
300
|
+
/** Массив зарегистрированных элементов */
|
|
301
|
+
registrations = [];
|
|
302
|
+
/**
|
|
303
|
+
* Получить стек для конкретного класса реестра
|
|
304
|
+
* Создает новый стек если не существует
|
|
305
|
+
*
|
|
306
|
+
* @param ctor - Конструктор класса реестра
|
|
307
|
+
* @returns RegistryStack для данного класса
|
|
308
|
+
*/
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
310
|
+
static getStack(t) {
|
|
311
|
+
return l.has(t) || l.set(t, new f()), l.get(t);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Получить текущий активный реестр из стека
|
|
315
|
+
* Должен быть переопределен в наследниках как static метод
|
|
316
|
+
*
|
|
317
|
+
* @param ctor - Конструктор класса реестра
|
|
318
|
+
* @returns Текущий активный реестр или null
|
|
319
|
+
*/
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
321
|
+
static getCurrentFromStack(t) {
|
|
322
|
+
return this.getStack(t).getCurrent();
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Начать регистрацию
|
|
326
|
+
*
|
|
327
|
+
* Помещает this в global stack для изоляции форм
|
|
328
|
+
* Вызывает hook onBeginRegistration()
|
|
329
|
+
*/
|
|
330
|
+
beginRegistration() {
|
|
331
|
+
this.isRegistering = !0, this.registrations = [], c.getStack(this.constructor).push(this), this.onBeginRegistration();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Проверить, активна ли регистрация
|
|
335
|
+
*/
|
|
336
|
+
isActive() {
|
|
337
|
+
return this.isRegistering;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Получить зарегистрированные элементы
|
|
341
|
+
*/
|
|
342
|
+
getRegistrations() {
|
|
343
|
+
return this.registrations;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Hook: вызывается в начале регистрации
|
|
347
|
+
* Может быть переопределен в наследниках для инициализации
|
|
348
|
+
*/
|
|
349
|
+
onBeginRegistration() {
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Завершить регистрацию и извлечь из стека
|
|
353
|
+
*
|
|
354
|
+
* @param registryName - Имя реестра для отладки
|
|
355
|
+
*/
|
|
356
|
+
completeRegistration(t) {
|
|
357
|
+
this.isRegistering = !1, c.getStack(this.constructor).verify(this, t);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Отменить регистрацию без применения
|
|
361
|
+
*
|
|
362
|
+
* @param registryName - Имя реестра для отладки
|
|
363
|
+
*/
|
|
364
|
+
cancelRegistration(t) {
|
|
365
|
+
this.isRegistering = !1, this.registrations = [], c.getStack(this.constructor).verify(this, t);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
class d extends c {
|
|
507
369
|
/**
|
|
508
370
|
* Получить текущий активный реестр из context stack
|
|
509
371
|
*
|
|
@@ -521,7 +383,7 @@ class h extends o {
|
|
|
521
383
|
* ```
|
|
522
384
|
*/
|
|
523
385
|
static getCurrent() {
|
|
524
|
-
return
|
|
386
|
+
return c.getCurrentFromStack(d);
|
|
525
387
|
}
|
|
526
388
|
/**
|
|
527
389
|
* Зарегистрировать behavior handler
|
|
@@ -552,35 +414,35 @@ class h extends o {
|
|
|
552
414
|
* @returns Количество зарегистрированных behaviors и функция cleanup
|
|
553
415
|
*/
|
|
554
416
|
endRegistration(t) {
|
|
555
|
-
const e = this.registrations.length,
|
|
556
|
-
for (const
|
|
557
|
-
const
|
|
558
|
-
|
|
417
|
+
const e = this.registrations.length, r = new k(t), i = [];
|
|
418
|
+
for (const n of this.registrations) {
|
|
419
|
+
const h = this.createEffect(n, t, r);
|
|
420
|
+
h && i.push(h);
|
|
559
421
|
}
|
|
560
422
|
return this.completeRegistration("BehaviorRegistry"), { count: e, cleanup: () => {
|
|
561
|
-
|
|
423
|
+
i.forEach((n) => n());
|
|
562
424
|
} };
|
|
563
425
|
}
|
|
564
426
|
/**
|
|
565
427
|
* Создать effect подписку для behavior
|
|
566
428
|
* @private
|
|
567
429
|
*/
|
|
568
|
-
createEffect(t, e,
|
|
569
|
-
const { handler:
|
|
570
|
-
let
|
|
571
|
-
const
|
|
572
|
-
|
|
430
|
+
createEffect(t, e, r) {
|
|
431
|
+
const { handler: i, debounce: s = 0 } = t;
|
|
432
|
+
let n = null;
|
|
433
|
+
const h = (u) => {
|
|
434
|
+
s > 0 ? (n && clearTimeout(n), n = setTimeout(u, s)) : u();
|
|
573
435
|
}, p = () => {
|
|
574
|
-
|
|
575
|
-
}, g =
|
|
436
|
+
n && (clearTimeout(n), n = null);
|
|
437
|
+
}, g = i(e, r, h);
|
|
576
438
|
return g ? () => {
|
|
577
439
|
p(), g && g();
|
|
578
440
|
} : null;
|
|
579
441
|
}
|
|
580
442
|
}
|
|
581
|
-
function
|
|
582
|
-
const
|
|
583
|
-
return
|
|
443
|
+
function x() {
|
|
444
|
+
const o = a.getCurrent();
|
|
445
|
+
return o || {
|
|
584
446
|
registerSync: () => {
|
|
585
447
|
},
|
|
586
448
|
registerAsync: () => {
|
|
@@ -595,21 +457,19 @@ function k() {
|
|
|
595
457
|
}
|
|
596
458
|
};
|
|
597
459
|
}
|
|
598
|
-
function
|
|
599
|
-
const
|
|
600
|
-
return
|
|
460
|
+
function C() {
|
|
461
|
+
const o = d.getCurrent();
|
|
462
|
+
return o || {
|
|
601
463
|
register: () => {
|
|
602
464
|
}
|
|
603
465
|
};
|
|
604
466
|
}
|
|
605
467
|
export {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
f as
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
C as
|
|
613
|
-
V as b,
|
|
614
|
-
k as g
|
|
468
|
+
c as A,
|
|
469
|
+
d as B,
|
|
470
|
+
f as R,
|
|
471
|
+
a as V,
|
|
472
|
+
k as a,
|
|
473
|
+
x as b,
|
|
474
|
+
C as g
|
|
615
475
|
};
|
package/dist/validators/email.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
const s = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
5
|
-
m(e, (a) => a ? s.test(a) ? null : {
|
|
1
|
+
const s = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2
|
+
function n(e) {
|
|
3
|
+
return (r) => r ? s.test(r) ? null : {
|
|
6
4
|
code: "email",
|
|
7
|
-
message:
|
|
8
|
-
params:
|
|
9
|
-
} : null
|
|
5
|
+
message: e?.message ?? "invalid",
|
|
6
|
+
params: e?.params
|
|
7
|
+
} : null;
|
|
10
8
|
}
|
|
11
9
|
export {
|
|
12
|
-
|
|
10
|
+
n as email
|
|
13
11
|
};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
a && o(a, (r) => {
|
|
1
|
+
import { p as s, n as l, g as o } from "../date-utils-xUWFslTj.js";
|
|
2
|
+
function i(a) {
|
|
3
|
+
return (r) => {
|
|
5
4
|
if (r == null || r === "")
|
|
6
5
|
return null;
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
6
|
+
const e = s(r);
|
|
7
|
+
if (e === null)
|
|
9
8
|
return null;
|
|
10
|
-
const n = l(
|
|
11
|
-
return n <
|
|
9
|
+
const n = l(e), t = o();
|
|
10
|
+
return n < t ? {
|
|
12
11
|
code: "date_past",
|
|
13
|
-
message:
|
|
14
|
-
params:
|
|
12
|
+
message: a?.message ?? "invalid",
|
|
13
|
+
params: a?.params
|
|
15
14
|
} : null;
|
|
16
|
-
}
|
|
15
|
+
};
|
|
17
16
|
}
|
|
18
17
|
export {
|
|
19
|
-
|
|
18
|
+
i as futureDate
|
|
20
19
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
a && s(a, (r) => r == null || r === "" ? null : n(r) === null ? {
|
|
1
|
+
import { p as a } from "../date-utils-xUWFslTj.js";
|
|
2
|
+
function t(e) {
|
|
3
|
+
return (r) => r == null || r === "" ? null : a(r) === null ? {
|
|
5
4
|
code: "date_invalid",
|
|
6
|
-
message: e?.message
|
|
5
|
+
message: e?.message ?? "invalid",
|
|
7
6
|
params: e?.params
|
|
8
|
-
} : null
|
|
7
|
+
} : null;
|
|
9
8
|
}
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
t as isDate
|
|
12
11
|
};
|