@reformer/core 9.0.0 → 9.1.0
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/README.md +52 -57
- package/dist/behaviors-node-BMOI2JJF.js +26 -0
- package/dist/behaviors-value-lCpqicfa.js +148 -0
- package/dist/behaviors.d.ts +2 -133
- package/dist/behaviors.js +148 -147
- package/dist/{core/utils → form}/aggregate-signals.d.ts +2 -2
- package/dist/form/behaviors-node.d.ts +55 -0
- package/dist/form/behaviors.d.ts +133 -0
- package/dist/{core/utils → form}/create-form.d.ts +5 -4
- package/dist/{core/utils → form}/error-handler.d.ts +1 -1
- package/dist/{core → form}/factories/node-factory.d.ts +1 -1
- package/dist/{core/utils → form}/form-proxy-builder.d.ts +2 -2
- package/dist/{core/utils → form}/form-submitter.d.ts +6 -1
- package/dist/{hooks → form/hooks}/types.d.ts +31 -1
- package/dist/{hooks → form/hooks}/useArrayLength.d.ts +1 -1
- package/dist/{hooks → form/hooks}/useFormControl.d.ts +3 -3
- package/dist/{hooks → form/hooks}/useFormControlValue.d.ts +2 -2
- package/dist/{hooks → form/hooks}/useSignalSubscription.d.ts +8 -1
- package/dist/form/index.d.ts +36 -0
- package/dist/{core → form}/nodes/array-node.d.ts +1 -1
- package/dist/{core → form}/nodes/field-node.d.ts +1 -1
- package/dist/{core → form}/nodes/form-node.d.ts +1 -1
- package/dist/{core → form}/nodes/group-node.d.ts +34 -4
- package/dist/{core → form}/nodes/model-array-node.d.ts +10 -3
- package/dist/{core/utils → form}/signal-node-registry.d.ts +1 -1
- package/dist/{core/utils → form}/status-machine.d.ts +1 -1
- package/dist/{core/utils → form}/type-guards.d.ts +5 -5
- package/dist/{core/types/index.d.ts → form/types/contracts.d.ts} +11 -90
- package/dist/{core → form}/types/deep-schema.d.ts +23 -1
- package/dist/{core → form}/types/form-proxy.d.ts +26 -1
- package/dist/form/types/index.d.ts +91 -0
- package/dist/{core → form}/types/schema-node.d.ts +1 -1
- package/dist/{core → form}/types/validation-schema.d.ts +19 -9
- package/dist/{core/model/validate-model.d.ts → form/validate-model-core.d.ts} +25 -25
- package/dist/form/validate-model.d.ts +27 -0
- package/dist/{core → form}/validation/validators/required.d.ts +2 -1
- package/dist/form/validators.d.ts +6 -0
- package/dist/form-model-C8Fi83k4.js +439 -0
- package/dist/index.d.ts +11 -16
- package/dist/index.js +666 -1011
- package/dist/{core/model/behaviors.d.ts → state/behaviors-value.d.ts} +0 -38
- package/dist/{core/utils → state}/derived-registry.d.ts +29 -0
- package/dist/state/form-model.d.ts +26 -0
- package/dist/state/index.d.ts +31 -0
- package/dist/state/safe-effect.d.ts +93 -0
- package/dist/{core/model → state}/types.d.ts +14 -11
- package/dist/state.d.ts +2 -0
- package/dist/state.js +19 -0
- package/dist/validators/email.d.ts +1 -1
- package/dist/validators/future-date.d.ts +1 -1
- package/dist/validators/integer.d.ts +1 -1
- package/dist/validators/is-date.d.ts +1 -1
- package/dist/validators/is-number.d.ts +1 -1
- package/dist/validators/max-age.d.ts +1 -1
- package/dist/validators/max-date.d.ts +1 -1
- package/dist/validators/max-length.d.ts +1 -1
- package/dist/validators/max.d.ts +1 -1
- package/dist/validators/min-age.d.ts +1 -1
- package/dist/validators/min-date.d.ts +1 -1
- package/dist/validators/min-length.d.ts +1 -1
- package/dist/validators/min.d.ts +1 -1
- package/dist/validators/multiple-of.d.ts +1 -1
- package/dist/validators/non-negative.d.ts +1 -1
- package/dist/validators/non-zero.d.ts +1 -1
- package/dist/validators/past-date.d.ts +1 -1
- package/dist/validators/pattern.d.ts +1 -1
- package/dist/validators/pattern.js +7 -6
- package/dist/validators/phone.d.ts +1 -1
- package/dist/validators/required.d.ts +1 -1
- package/dist/validators/required.js +5 -9
- package/dist/validators/url.d.ts +1 -1
- package/dist/validators.d.ts +6 -6
- package/llms.txt +307 -166
- package/package.json +5 -1
- package/dist/behaviors-O9a1Djj9.js +0 -147
- package/dist/core/model/form-model.d.ts +0 -18
- package/dist/core/model/index.d.ts +0 -12
- package/dist/core/utils/index.d.ts +0 -18
- package/dist/core/utils/safe-effect.d.ts +0 -73
- /package/dist/{core → form}/factories/index.d.ts +0 -0
- /package/dist/{core/utils → form}/unique-id.d.ts +0 -0
- /package/dist/{core → form}/validation/index.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/date-utils.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/email.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/future-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/index.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/integer.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/is-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/is-number.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max-age.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max-length.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min-age.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min-length.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/multiple-of.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/non-negative.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/non-zero.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/past-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/pattern.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/phone.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/url.d.ts +0 -0
- /package/dist/{core/utils → state}/subscription-manager.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { default as
|
|
6
|
-
|
|
1
|
+
import { S as I } from "./form-model-C8Fi83k4.js";
|
|
2
|
+
import { c as Ge } from "./form-model-C8Fi83k4.js";
|
|
3
|
+
import { i as G } from "./behaviors-value-lCpqicfa.js";
|
|
4
|
+
import { c as We, a as qe, m as He, r as Ke, b as Je, d as Ye, e as ze, f as Qe, s as Xe, t as Ze, u as et, w as tt } from "./behaviors-value-lCpqicfa.js";
|
|
5
|
+
import { default as rt } from "./validators.js";
|
|
6
|
+
import { signal as g, computed as f, effect as b, batch as ie, Signal as z } from "@preact/signals-core";
|
|
7
|
+
import { g as U, r as ne } from "./behaviors-node-BMOI2JJF.js";
|
|
8
|
+
import { d as nt, e as at } from "./behaviors-node-BMOI2JJF.js";
|
|
9
|
+
import Q, { useRef as N, useCallback as E } from "react";
|
|
10
|
+
class C {
|
|
7
11
|
// ============================================================================
|
|
8
12
|
// Protected состояние (для Template Method паттерна)
|
|
9
13
|
// ============================================================================
|
|
@@ -11,17 +15,17 @@ class D {
|
|
|
11
15
|
* Пользователь взаимодействовал с узлом (touched)
|
|
12
16
|
* Protected: наследники могут читать/изменять через методы
|
|
13
17
|
*/
|
|
14
|
-
_touched =
|
|
18
|
+
_touched = g(!1);
|
|
15
19
|
/**
|
|
16
20
|
* Значение узла было изменено (dirty)
|
|
17
21
|
* Protected: наследники могут читать/изменять через методы
|
|
18
22
|
*/
|
|
19
|
-
_dirty =
|
|
23
|
+
_dirty = g(!1);
|
|
20
24
|
/**
|
|
21
25
|
* Текущий статус узла
|
|
22
26
|
* Protected: наследники могут читать/изменять через методы
|
|
23
27
|
*/
|
|
24
|
-
_status =
|
|
28
|
+
_status = g("valid");
|
|
25
29
|
// ============================================================================
|
|
26
30
|
// Публичные computed signals (readonly для внешнего мира)
|
|
27
31
|
// ============================================================================
|
|
@@ -29,33 +33,33 @@ class D {
|
|
|
29
33
|
* Пользователь взаимодействовал с узлом (touched)
|
|
30
34
|
* Computed из _touched для предоставления readonly интерфейса
|
|
31
35
|
*/
|
|
32
|
-
touched =
|
|
36
|
+
touched = f(() => this._touched.value);
|
|
33
37
|
/**
|
|
34
38
|
* Пользователь не взаимодействовал с узлом (untouched)
|
|
35
39
|
*/
|
|
36
|
-
untouched =
|
|
40
|
+
untouched = f(() => !this._touched.value);
|
|
37
41
|
/**
|
|
38
42
|
* Значение узла было изменено (dirty)
|
|
39
43
|
* Computed из _dirty для предоставления readonly интерфейса
|
|
40
44
|
*/
|
|
41
|
-
dirty =
|
|
45
|
+
dirty = f(() => this._dirty.value);
|
|
42
46
|
/**
|
|
43
47
|
* Значение узла не было изменено (pristine)
|
|
44
48
|
*/
|
|
45
|
-
pristine =
|
|
49
|
+
pristine = f(() => !this._dirty.value);
|
|
46
50
|
/**
|
|
47
51
|
* Текущий статус узла
|
|
48
52
|
* Computed из _status для предоставления readonly интерфейса
|
|
49
53
|
*/
|
|
50
|
-
status =
|
|
54
|
+
status = f(() => this._status.value);
|
|
51
55
|
/**
|
|
52
56
|
* Узел отключен (disabled)
|
|
53
57
|
*/
|
|
54
|
-
disabled =
|
|
58
|
+
disabled = f(() => this._status.value === "disabled");
|
|
55
59
|
/**
|
|
56
60
|
* Узел включен (enabled)
|
|
57
61
|
*/
|
|
58
|
-
enabled =
|
|
62
|
+
enabled = f(() => this._status.value !== "disabled");
|
|
59
63
|
/**
|
|
60
64
|
* Получить ошибки валидации с фильтрацией
|
|
61
65
|
*
|
|
@@ -103,8 +107,8 @@ class D {
|
|
|
103
107
|
if (e.params !== void 0) {
|
|
104
108
|
if (!s.params)
|
|
105
109
|
return !1;
|
|
106
|
-
for (const [
|
|
107
|
-
if (s.params[
|
|
110
|
+
for (const [i, n] of Object.entries(e.params))
|
|
111
|
+
if (s.params[i] !== n)
|
|
108
112
|
return !1;
|
|
109
113
|
}
|
|
110
114
|
return !(e.predicate !== void 0 && !e.predicate(s));
|
|
@@ -280,175 +284,7 @@ class D {
|
|
|
280
284
|
onEnable() {
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Хранилище подписок
|
|
286
|
-
* Ключ: уникальный идентификатор подписки
|
|
287
|
-
* Значение: функция отписки (dispose)
|
|
288
|
-
*/
|
|
289
|
-
subscriptions = /* @__PURE__ */ new Map();
|
|
290
|
-
/**
|
|
291
|
-
* Добавляет подписку
|
|
292
|
-
*
|
|
293
|
-
* Если подписка с таким ключом уже существует, отписывается от неё
|
|
294
|
-
* и заменяет новой. Это предотвращает утечки памяти при повторной
|
|
295
|
-
* регистрации подписки с тем же ключом.
|
|
296
|
-
*
|
|
297
|
-
* @param key Уникальный ключ подписки
|
|
298
|
-
* @param dispose Функция отписки (обычно возвращаемая из effect())
|
|
299
|
-
* @returns Функция для отписки от этой конкретной подписки
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```typescript
|
|
303
|
-
* const manager = new SubscriptionManager();
|
|
304
|
-
*
|
|
305
|
-
* // Добавление подписки
|
|
306
|
-
* const unsubscribe = manager.add('mySubscription', () => {
|
|
307
|
-
* console.log('Disposing subscription');
|
|
308
|
-
* });
|
|
309
|
-
*
|
|
310
|
-
* // Отписка через возвращаемую функцию
|
|
311
|
-
* unsubscribe();
|
|
312
|
-
*
|
|
313
|
-
* // Или через manager.remove()
|
|
314
|
-
* manager.add('anotherSub', disposeFn);
|
|
315
|
-
* manager.remove('anotherSub');
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
add(e, t) {
|
|
319
|
-
return this.subscriptions.has(e) && (process.env.NODE_ENV !== "production" && console.warn(`[SubscriptionManager] Subscription "${e}" already exists, replacing`), this.subscriptions.get(e)?.()), this.subscriptions.set(e, t), () => this.remove(e);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Удаляет подписку по ключу
|
|
323
|
-
*
|
|
324
|
-
* Вызывает функцию отписки и удаляет подписку из хранилища.
|
|
325
|
-
* Если подписка с таким ключом не найдена, ничего не делает.
|
|
326
|
-
*
|
|
327
|
-
* @param key Ключ подписки
|
|
328
|
-
* @returns true, если подписка была удалена, false если не найдена
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```typescript
|
|
332
|
-
* const manager = new SubscriptionManager();
|
|
333
|
-
* manager.add('mySub', disposeFn);
|
|
334
|
-
*
|
|
335
|
-
* // Удаление подписки
|
|
336
|
-
* const removed = manager.remove('mySub'); // true
|
|
337
|
-
*
|
|
338
|
-
* // Попытка удалить несуществующую подписку
|
|
339
|
-
* const removed2 = manager.remove('nonExistent'); // false
|
|
340
|
-
* ```
|
|
341
|
-
*/
|
|
342
|
-
remove(e) {
|
|
343
|
-
const t = this.subscriptions.get(e);
|
|
344
|
-
return t ? (t(), this.subscriptions.delete(e), !0) : !1;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Очищает все подписки
|
|
348
|
-
*
|
|
349
|
-
* Вызывает функции отписки для всех активных подписок
|
|
350
|
-
* и очищает хранилище. Обычно используется при dispose узла формы.
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```typescript
|
|
354
|
-
* class FieldNode {
|
|
355
|
-
* private subscriptions = new SubscriptionManager();
|
|
356
|
-
*
|
|
357
|
-
* dispose() {
|
|
358
|
-
* // Отписываемся от всех effect
|
|
359
|
-
* this.subscriptions.clear();
|
|
360
|
-
* }
|
|
361
|
-
* }
|
|
362
|
-
* ```
|
|
363
|
-
*/
|
|
364
|
-
clear() {
|
|
365
|
-
this.subscriptions.forEach((e) => {
|
|
366
|
-
e();
|
|
367
|
-
}), this.subscriptions.clear();
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Возвращает количество активных подписок
|
|
371
|
-
*
|
|
372
|
-
* Полезно для отладки утечек памяти. Если количество подписок
|
|
373
|
-
* растет без ограничений, это может указывать на то, что
|
|
374
|
-
* компоненты не отписываются должным образом.
|
|
375
|
-
*
|
|
376
|
-
* @returns Количество активных подписок
|
|
377
|
-
*
|
|
378
|
-
* @example
|
|
379
|
-
* ```typescript
|
|
380
|
-
* const manager = new SubscriptionManager();
|
|
381
|
-
* console.log(manager.size()); // 0
|
|
382
|
-
*
|
|
383
|
-
* manager.add('sub1', disposeFn1);
|
|
384
|
-
* manager.add('sub2', disposeFn2);
|
|
385
|
-
* console.log(manager.size()); // 2
|
|
386
|
-
*
|
|
387
|
-
* manager.clear();
|
|
388
|
-
* console.log(manager.size()); // 0
|
|
389
|
-
* ```
|
|
390
|
-
*/
|
|
391
|
-
size() {
|
|
392
|
-
return this.subscriptions.size;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Проверяет, есть ли подписка с данным ключом
|
|
396
|
-
*
|
|
397
|
-
* @param key Ключ подписки
|
|
398
|
-
* @returns true, если подписка существует
|
|
399
|
-
*
|
|
400
|
-
* @example
|
|
401
|
-
* ```typescript
|
|
402
|
-
* const manager = new SubscriptionManager();
|
|
403
|
-
* manager.add('mySub', disposeFn);
|
|
404
|
-
*
|
|
405
|
-
* console.log(manager.has('mySub')); // true
|
|
406
|
-
* console.log(manager.has('nonExistent')); // false
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
has(e) {
|
|
410
|
-
return this.subscriptions.has(e);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Возвращает список всех ключей активных подписок
|
|
414
|
-
*
|
|
415
|
-
* Полезно для отладки: можно увидеть, какие подписки активны.
|
|
416
|
-
*
|
|
417
|
-
* @returns Массив ключей всех активных подписок
|
|
418
|
-
*
|
|
419
|
-
* @example
|
|
420
|
-
* ```typescript
|
|
421
|
-
* const manager = new SubscriptionManager();
|
|
422
|
-
* manager.add('watch-value', disposeFn1);
|
|
423
|
-
* manager.add('watch-errors', disposeFn2);
|
|
424
|
-
*
|
|
425
|
-
* console.log(manager.getKeys()); // ['watch-value', 'watch-errors']
|
|
426
|
-
* ```
|
|
427
|
-
*/
|
|
428
|
-
getKeys() {
|
|
429
|
-
return Array.from(this.subscriptions.keys());
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Отписывается от всех подписок (алиас для clear())
|
|
433
|
-
*
|
|
434
|
-
* Используется при dispose() узла формы для совместимости с ожидаемым API.
|
|
435
|
-
*
|
|
436
|
-
* @example
|
|
437
|
-
* ```typescript
|
|
438
|
-
* class FieldNode {
|
|
439
|
-
* private subscriptions = new SubscriptionManager();
|
|
440
|
-
*
|
|
441
|
-
* dispose() {
|
|
442
|
-
* this.subscriptions.dispose();
|
|
443
|
-
* }
|
|
444
|
-
* }
|
|
445
|
-
* ```
|
|
446
|
-
*/
|
|
447
|
-
dispose() {
|
|
448
|
-
this.clear();
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
const k = {
|
|
287
|
+
const w = {
|
|
452
288
|
/** FieldNode.watch() */
|
|
453
289
|
Watch: "watch",
|
|
454
290
|
/** FieldNode.computeFrom() */
|
|
@@ -462,15 +298,15 @@ const k = {
|
|
|
462
298
|
/** ArrayNode.watchLength() */
|
|
463
299
|
WatchLength: "watchLength"
|
|
464
300
|
};
|
|
465
|
-
let
|
|
466
|
-
function V(
|
|
467
|
-
return `${
|
|
301
|
+
let ae = 0;
|
|
302
|
+
function V(r) {
|
|
303
|
+
return `${r}-${++ae}`;
|
|
468
304
|
}
|
|
469
|
-
var
|
|
305
|
+
var A = /* @__PURE__ */ ((r) => (r.THROW = "throw", r.LOG = "log", r.CONVERT = "convert", r))(A || {});
|
|
470
306
|
class O {
|
|
471
307
|
static handle(e, t, s = "throw") {
|
|
472
|
-
const
|
|
473
|
-
switch (s) {
|
|
308
|
+
const i = this.extractMessage(e);
|
|
309
|
+
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), s) {
|
|
474
310
|
case "throw":
|
|
475
311
|
throw e;
|
|
476
312
|
case "log":
|
|
@@ -478,7 +314,7 @@ class O {
|
|
|
478
314
|
case "convert":
|
|
479
315
|
return {
|
|
480
316
|
code: "validator_error",
|
|
481
|
-
message:
|
|
317
|
+
message: i,
|
|
482
318
|
params: { field: t }
|
|
483
319
|
};
|
|
484
320
|
}
|
|
@@ -560,7 +396,7 @@ class O {
|
|
|
560
396
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
561
397
|
}
|
|
562
398
|
}
|
|
563
|
-
class
|
|
399
|
+
class oe {
|
|
564
400
|
/** Внутренний сигнал статуса */
|
|
565
401
|
_status;
|
|
566
402
|
/** Публичный read-only сигнал статуса */
|
|
@@ -577,7 +413,7 @@ class be {
|
|
|
577
413
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
578
414
|
*/
|
|
579
415
|
constructor(e = "valid") {
|
|
580
|
-
this._status =
|
|
416
|
+
this._status = g(e), this.status = f(() => this._status.value), this.valid = f(() => this._status.value === "valid"), this.invalid = f(() => this._status.value === "invalid"), this.pending = f(() => this._status.value === "pending"), this.disabled = f(() => this._status.value === "disabled");
|
|
581
417
|
}
|
|
582
418
|
/**
|
|
583
419
|
* Начать валидацию
|
|
@@ -705,7 +541,7 @@ class be {
|
|
|
705
541
|
return this._status.value !== "disabled";
|
|
706
542
|
}
|
|
707
543
|
}
|
|
708
|
-
class
|
|
544
|
+
class le extends C {
|
|
709
545
|
// ============================================================================
|
|
710
546
|
// Приватные сигналы
|
|
711
547
|
// ============================================================================
|
|
@@ -757,13 +593,13 @@ class _e extends D {
|
|
|
757
593
|
* Менеджер подписок для централизованного cleanup
|
|
758
594
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
759
595
|
*/
|
|
760
|
-
disposers = new
|
|
596
|
+
disposers = new I();
|
|
761
597
|
component;
|
|
762
598
|
// ============================================================================
|
|
763
599
|
// Конструктор
|
|
764
600
|
// ============================================================================
|
|
765
601
|
constructor(e) {
|
|
766
|
-
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 ??
|
|
602
|
+
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 oe(e.disabled ? "disabled" : "valid"), this.value = f(() => this._value.value), this.valid = f(() => this.statusMachine.valid.value), this.invalid = f(() => this.statusMachine.invalid.value), this.pending = f(() => this.statusMachine.pending.value), this.status = f(() => this.statusMachine.status.value), this.disabled = f(() => this.statusMachine.disabled.value), this.errors = f(() => this._errors.value), this.componentProps = f(() => this._componentProps.value), this.shouldShowError = f(
|
|
767
603
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
768
604
|
);
|
|
769
605
|
}
|
|
@@ -776,12 +612,12 @@ class _e extends D {
|
|
|
776
612
|
setValue(e, t) {
|
|
777
613
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
778
614
|
return;
|
|
779
|
-
const s = this.validators.length > 0 || this.asyncValidators.length > 0,
|
|
615
|
+
const s = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
780
616
|
if (this.updateOn === "change") {
|
|
781
617
|
this.validate();
|
|
782
618
|
return;
|
|
783
619
|
}
|
|
784
|
-
|
|
620
|
+
i && s && this.validate();
|
|
785
621
|
}
|
|
786
622
|
patchValue(e) {
|
|
787
623
|
this.setValue(e);
|
|
@@ -875,19 +711,19 @@ class _e extends D {
|
|
|
875
711
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
876
712
|
return this.validateImmediate();
|
|
877
713
|
const s = new AbortController();
|
|
878
|
-
return new Promise((
|
|
879
|
-
this.pendingValidation = { resolve:
|
|
714
|
+
return new Promise((i) => {
|
|
715
|
+
this.pendingValidation = { resolve: i, abortController: s }, this.validateDebounceTimer = setTimeout(async () => {
|
|
880
716
|
if (this.validateDebounceTimer = void 0, s.signal.aborted) {
|
|
881
|
-
|
|
717
|
+
i(!1);
|
|
882
718
|
return;
|
|
883
719
|
}
|
|
884
720
|
this.pendingValidation = void 0;
|
|
885
721
|
const n = await this.validateImmediate(s);
|
|
886
|
-
|
|
722
|
+
i(n);
|
|
887
723
|
}, t), s.signal.addEventListener(
|
|
888
724
|
"abort",
|
|
889
725
|
() => {
|
|
890
|
-
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0),
|
|
726
|
+
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), i(!1);
|
|
891
727
|
},
|
|
892
728
|
{ once: !0 }
|
|
893
729
|
);
|
|
@@ -906,16 +742,16 @@ class _e extends D {
|
|
|
906
742
|
async validateImmediate(e) {
|
|
907
743
|
const t = e ?? new AbortController();
|
|
908
744
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
909
|
-
const { signal: s } = t,
|
|
745
|
+
const { signal: s } = t, i = [];
|
|
910
746
|
for (const a of this.validators) {
|
|
911
|
-
const
|
|
912
|
-
|
|
747
|
+
const l = a(this._value.value);
|
|
748
|
+
l && i.push(l);
|
|
913
749
|
}
|
|
914
750
|
if (s.aborted)
|
|
915
751
|
return !1;
|
|
916
|
-
if (
|
|
917
|
-
this._errors.value =
|
|
918
|
-
const a =
|
|
752
|
+
if (i.length > 0) {
|
|
753
|
+
this._errors.value = i;
|
|
754
|
+
const a = i.some((l) => l.severity !== "warning");
|
|
919
755
|
if (this.statusMachine.setErrors(a), a)
|
|
920
756
|
return !1;
|
|
921
757
|
}
|
|
@@ -925,11 +761,11 @@ class _e extends D {
|
|
|
925
761
|
this.statusMachine.startValidation();
|
|
926
762
|
try {
|
|
927
763
|
const a = await Promise.all(
|
|
928
|
-
this.asyncValidators.map(async (
|
|
764
|
+
this.asyncValidators.map(async (d) => {
|
|
929
765
|
if (s.aborted)
|
|
930
766
|
throw new DOMException("Validation aborted", "AbortError");
|
|
931
767
|
try {
|
|
932
|
-
const u = await
|
|
768
|
+
const u = await d(this._value.value, { signal: s });
|
|
933
769
|
if (s.aborted)
|
|
934
770
|
throw new DOMException("Validation aborted", "AbortError");
|
|
935
771
|
return u;
|
|
@@ -939,18 +775,18 @@ class _e extends D {
|
|
|
939
775
|
return O.handle(
|
|
940
776
|
u,
|
|
941
777
|
"FieldNode AsyncValidator",
|
|
942
|
-
|
|
778
|
+
A.CONVERT
|
|
943
779
|
);
|
|
944
780
|
}
|
|
945
781
|
})
|
|
946
782
|
);
|
|
947
783
|
if (s.aborted)
|
|
948
784
|
return !1;
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
951
|
-
this._errors.value =
|
|
952
|
-
const
|
|
953
|
-
if (this.statusMachine.completeValidation(
|
|
785
|
+
const l = a.filter((d) => d !== null);
|
|
786
|
+
if (l.length > 0) {
|
|
787
|
+
this._errors.value = l;
|
|
788
|
+
const d = l.some((u) => u.severity !== "warning");
|
|
789
|
+
if (this.statusMachine.completeValidation(d), d)
|
|
954
790
|
return !1;
|
|
955
791
|
}
|
|
956
792
|
} catch (a) {
|
|
@@ -1080,11 +916,11 @@ class _e extends D {
|
|
|
1080
916
|
* ```
|
|
1081
917
|
*/
|
|
1082
918
|
watch(e) {
|
|
1083
|
-
const t = new AbortController(), s =
|
|
919
|
+
const t = new AbortController(), s = b(() => {
|
|
1084
920
|
const n = this.value.value;
|
|
1085
921
|
e(n, t.signal);
|
|
1086
|
-
}),
|
|
1087
|
-
return this.disposers.add(
|
|
922
|
+
}), i = V(w.Watch);
|
|
923
|
+
return this.disposers.add(i, () => {
|
|
1088
924
|
t.abort(), s();
|
|
1089
925
|
});
|
|
1090
926
|
}
|
|
@@ -1111,11 +947,11 @@ class _e extends D {
|
|
|
1111
947
|
* ```
|
|
1112
948
|
*/
|
|
1113
949
|
computeFrom(e, t) {
|
|
1114
|
-
const s =
|
|
1115
|
-
const n = e.map((
|
|
950
|
+
const s = b(() => {
|
|
951
|
+
const n = e.map((l) => l.value), a = t(...n);
|
|
1116
952
|
this.setValue(a, { emitEvent: !1 });
|
|
1117
|
-
}),
|
|
1118
|
-
return this.disposers.add(
|
|
953
|
+
}), i = V(w.ComputeFrom);
|
|
954
|
+
return this.disposers.add(i, s);
|
|
1119
955
|
}
|
|
1120
956
|
/**
|
|
1121
957
|
* Очистить все ресурсы и таймеры
|
|
@@ -1145,46 +981,59 @@ class _e extends D {
|
|
|
1145
981
|
}
|
|
1146
982
|
}
|
|
1147
983
|
}
|
|
1148
|
-
function
|
|
1149
|
-
const { getChildren: e, ownErrors: t, disabled: s } =
|
|
1150
|
-
const
|
|
1151
|
-
for (const
|
|
1152
|
-
|
|
1153
|
-
return
|
|
1154
|
-
}),
|
|
984
|
+
function L(r) {
|
|
985
|
+
const { getChildren: e, ownErrors: t, disabled: s } = r, i = f(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = f(() => !i.value), a = f(() => e().some((o) => o.pending.value)), l = f(() => e().some((o) => o.touched.value)), d = f(() => e().some((o) => o.dirty.value)), u = f(() => {
|
|
986
|
+
const o = [...t.value];
|
|
987
|
+
for (const p of e())
|
|
988
|
+
o.push(...p.errors.value);
|
|
989
|
+
return o;
|
|
990
|
+
}), h = f(() => s?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
1155
991
|
return {
|
|
1156
|
-
valid:
|
|
992
|
+
valid: i,
|
|
1157
993
|
invalid: n,
|
|
1158
994
|
pending: a,
|
|
1159
|
-
touched:
|
|
1160
|
-
dirty:
|
|
995
|
+
touched: l,
|
|
996
|
+
dirty: d,
|
|
1161
997
|
errors: u,
|
|
1162
|
-
status:
|
|
998
|
+
status: h
|
|
1163
999
|
};
|
|
1164
1000
|
}
|
|
1165
|
-
function
|
|
1166
|
-
return typeof
|
|
1001
|
+
function W(r) {
|
|
1002
|
+
return typeof r == "object" && r !== null && "getProxy" in r && typeof r.getProxy == "function";
|
|
1167
1003
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1004
|
+
const q = "$";
|
|
1005
|
+
function ue(r, e) {
|
|
1006
|
+
let t;
|
|
1007
|
+
const s = () => {
|
|
1008
|
+
if (!t) {
|
|
1009
|
+
const i = {};
|
|
1010
|
+
e.forEach((n, a) => {
|
|
1011
|
+
i[a] = n && W(n) ? n.getProxy() : n;
|
|
1012
|
+
}), t = i;
|
|
1013
|
+
}
|
|
1014
|
+
return t;
|
|
1015
|
+
};
|
|
1016
|
+
return new Proxy(r, {
|
|
1017
|
+
get: (i, n) => {
|
|
1018
|
+
if (n === q)
|
|
1019
|
+
return s();
|
|
1020
|
+
if (n in i)
|
|
1021
|
+
return i[n];
|
|
1022
|
+
if (typeof n == "string" && e.has(n)) {
|
|
1023
|
+
const a = e.get(n);
|
|
1024
|
+
return a && W(a) ? a.getProxy() : a;
|
|
1176
1025
|
}
|
|
1177
1026
|
},
|
|
1178
|
-
set: (
|
|
1179
|
-
has: (
|
|
1180
|
-
ownKeys: (
|
|
1181
|
-
const
|
|
1182
|
-
return [.../* @__PURE__ */ new Set([...
|
|
1027
|
+
set: (i, n, a) => typeof n == "string" && e.has(n) ? !1 : (i[n] = a, !0),
|
|
1028
|
+
has: (i, n) => n === q || typeof n == "string" && e.has(n) ? !0 : n in i,
|
|
1029
|
+
ownKeys: (i) => {
|
|
1030
|
+
const n = Reflect.ownKeys(i), a = Array.from(e.keys());
|
|
1031
|
+
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
1183
1032
|
},
|
|
1184
|
-
getOwnPropertyDescriptor: (
|
|
1033
|
+
getOwnPropertyDescriptor: (i, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, n)
|
|
1185
1034
|
});
|
|
1186
1035
|
}
|
|
1187
|
-
class
|
|
1036
|
+
class de {
|
|
1188
1037
|
/**
|
|
1189
1038
|
* @param form - Форма для отправки
|
|
1190
1039
|
*/
|
|
@@ -1192,9 +1041,9 @@ class we {
|
|
|
1192
1041
|
this.form = e;
|
|
1193
1042
|
}
|
|
1194
1043
|
/** Внутренний сигнал состояния отправки */
|
|
1195
|
-
_submitting =
|
|
1044
|
+
_submitting = g(!1);
|
|
1196
1045
|
/** Публичный read-only сигнал состояния отправки */
|
|
1197
|
-
submitting =
|
|
1046
|
+
submitting = f(() => this._submitting.value);
|
|
1198
1047
|
/**
|
|
1199
1048
|
* Отправить форму
|
|
1200
1049
|
*
|
|
@@ -1206,7 +1055,12 @@ class we {
|
|
|
1206
1055
|
*
|
|
1207
1056
|
* @param onSubmit - Callback для отправки данных
|
|
1208
1057
|
* @param options - Опции submit
|
|
1209
|
-
* @returns Результат от onSubmit или null если валидация не пройдена
|
|
1058
|
+
* @returns Результат от onSubmit или `null` если валидация не пройдена
|
|
1059
|
+
*
|
|
1060
|
+
* @remarks
|
|
1061
|
+
* Возвращаемый `null` неоднозначен: он сигналит и провал валидации, и легитимный `null`,
|
|
1062
|
+
* который вернул `onSubmit` (или void-обработчик). Чтобы различать эти случаи, используйте
|
|
1063
|
+
* {@link submitWithResult} — он отдаёт явный флаг `success`.
|
|
1210
1064
|
*
|
|
1211
1065
|
* @example
|
|
1212
1066
|
* ```typescript
|
|
@@ -1224,8 +1078,8 @@ class we {
|
|
|
1224
1078
|
* ```
|
|
1225
1079
|
*/
|
|
1226
1080
|
async submit(e, t) {
|
|
1227
|
-
const { skipValidation: s = !1, skipTouch:
|
|
1228
|
-
if (
|
|
1081
|
+
const { skipValidation: s = !1, skipTouch: i = !1 } = t || {};
|
|
1082
|
+
if (i || this.form.markAsTouched(), !s && !await this.form.validate())
|
|
1229
1083
|
return null;
|
|
1230
1084
|
this._submitting.value = !0;
|
|
1231
1085
|
try {
|
|
@@ -1259,8 +1113,8 @@ class we {
|
|
|
1259
1113
|
* ```
|
|
1260
1114
|
*/
|
|
1261
1115
|
async submitWithResult(e, t) {
|
|
1262
|
-
const { skipValidation: s = !1, skipTouch:
|
|
1263
|
-
if (
|
|
1116
|
+
const { skipValidation: s = !1, skipTouch: i = !1 } = t || {};
|
|
1117
|
+
if (i || this.form.markAsTouched(), !s && !await this.form.validate())
|
|
1264
1118
|
return { success: !1, data: null };
|
|
1265
1119
|
this._submitting.value = !0;
|
|
1266
1120
|
try {
|
|
@@ -1282,16 +1136,16 @@ class we {
|
|
|
1282
1136
|
return this._submitting.value;
|
|
1283
1137
|
}
|
|
1284
1138
|
}
|
|
1285
|
-
function
|
|
1139
|
+
function ce(r) {
|
|
1286
1140
|
const e = [];
|
|
1287
|
-
for (const t of
|
|
1141
|
+
for (const t of r.split(".")) {
|
|
1288
1142
|
const s = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1289
1143
|
if (!s) return [];
|
|
1290
1144
|
e.push(s[2] !== void 0 ? { key: s[1], index: Number(s[2]) } : { key: s[1] });
|
|
1291
1145
|
}
|
|
1292
1146
|
return e;
|
|
1293
1147
|
}
|
|
1294
|
-
|
|
1148
|
+
class S extends C {
|
|
1295
1149
|
// ============================================================================
|
|
1296
1150
|
// Приватные поля
|
|
1297
1151
|
// ============================================================================
|
|
@@ -1304,7 +1158,7 @@ let x = class ae extends D {
|
|
|
1304
1158
|
/**
|
|
1305
1159
|
* Менеджер подписок для централизованного cleanup
|
|
1306
1160
|
*/
|
|
1307
|
-
disposers = new
|
|
1161
|
+
disposers = new I();
|
|
1308
1162
|
/**
|
|
1309
1163
|
* Ссылка на Proxy-инстанс
|
|
1310
1164
|
*/
|
|
@@ -1316,7 +1170,7 @@ let x = class ae extends D {
|
|
|
1316
1170
|
/**
|
|
1317
1171
|
* Фабрика для создания узлов формы
|
|
1318
1172
|
*/
|
|
1319
|
-
nodeFactory = new
|
|
1173
|
+
nodeFactory = new he();
|
|
1320
1174
|
// ============================================================================
|
|
1321
1175
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1322
1176
|
// ============================================================================
|
|
@@ -1324,9 +1178,22 @@ let x = class ae extends D {
|
|
|
1324
1178
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1325
1179
|
formSubmitter;
|
|
1326
1180
|
/** Флаг disabled состояния */
|
|
1327
|
-
_disabled =
|
|
1181
|
+
_disabled = g(!1);
|
|
1328
1182
|
/** Form-level validation errors */
|
|
1329
|
-
_formErrors =
|
|
1183
|
+
_formErrors = g([]);
|
|
1184
|
+
/**
|
|
1185
|
+
* M1: валидация уровня модели/схемы (`validateFormModel(model, schema)`). Привязывается
|
|
1186
|
+
* `createForm({ model, schema })`, т.к. под M1 валидаторы срезаны с FieldNode и живут на слое
|
|
1187
|
+
* модели. Без неё `validate()`/`submit()` пропускали бы все schema-валидаторы. @internal
|
|
1188
|
+
*/
|
|
1189
|
+
_modelValidate;
|
|
1190
|
+
/**
|
|
1191
|
+
* M1: связь листовой ноды-ребёнка → её сигнал модели (тот, что помечает `markDerived`).
|
|
1192
|
+
* Нужна bulk-сеттерам (`setValue`/`patchValue`), чтобы корректно определять derived-поля:
|
|
1193
|
+
* `field.value` — computed-обёртка, отличная от записываемого сигнала модели. @internal
|
|
1194
|
+
*/
|
|
1195
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1196
|
+
_fieldSignals = /* @__PURE__ */ new WeakMap();
|
|
1330
1197
|
// ============================================================================
|
|
1331
1198
|
// Публичные computed signals
|
|
1332
1199
|
// ============================================================================
|
|
@@ -1340,24 +1207,24 @@ let x = class ae extends D {
|
|
|
1340
1207
|
status;
|
|
1341
1208
|
submitting;
|
|
1342
1209
|
constructor(e) {
|
|
1343
|
-
super(), this.formSubmitter = new
|
|
1344
|
-
const s = "form" in e ? e.form : e;
|
|
1345
|
-
for (const [
|
|
1346
|
-
const
|
|
1347
|
-
this._fields.set(
|
|
1210
|
+
super(), this.formSubmitter = new de(this);
|
|
1211
|
+
const t = e.form, s = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !s ? e.form : e;
|
|
1212
|
+
for (const [l, d] of Object.entries(n)) {
|
|
1213
|
+
const u = this.createNode(d);
|
|
1214
|
+
this._fields.set(l, u);
|
|
1348
1215
|
}
|
|
1349
|
-
this.value =
|
|
1350
|
-
const
|
|
1351
|
-
return this._fields.forEach((
|
|
1352
|
-
|
|
1353
|
-
}),
|
|
1216
|
+
this.value = f(() => {
|
|
1217
|
+
const l = {};
|
|
1218
|
+
return this._fields.forEach((d, u) => {
|
|
1219
|
+
l[u] = d.value.value;
|
|
1220
|
+
}), l;
|
|
1354
1221
|
});
|
|
1355
|
-
const
|
|
1222
|
+
const a = L({
|
|
1356
1223
|
getChildren: () => Array.from(this._fields.values()),
|
|
1357
1224
|
ownErrors: this._formErrors,
|
|
1358
1225
|
disabled: this._disabled
|
|
1359
1226
|
});
|
|
1360
|
-
this.valid =
|
|
1227
|
+
this.valid = a.valid, this.invalid = a.invalid, this.pending = a.pending, this.touched = a.touched, this.dirty = a.dirty, this.errors = a.errors, this.status = a.status, this.submitting = this.formSubmitter.submitting;
|
|
1361
1228
|
}
|
|
1362
1229
|
// ============================================================================
|
|
1363
1230
|
// Приватный метод для создания Proxy
|
|
@@ -1367,7 +1234,7 @@ let x = class ae extends D {
|
|
|
1367
1234
|
* @see buildFormProxy
|
|
1368
1235
|
*/
|
|
1369
1236
|
buildProxy() {
|
|
1370
|
-
return
|
|
1237
|
+
return ue(this, this._fields);
|
|
1371
1238
|
}
|
|
1372
1239
|
// ============================================================================
|
|
1373
1240
|
// Реализация абстрактных методов FormNode
|
|
@@ -1379,21 +1246,23 @@ let x = class ae extends D {
|
|
|
1379
1246
|
}), e;
|
|
1380
1247
|
}
|
|
1381
1248
|
setValue(e, t) {
|
|
1382
|
-
for (const [s,
|
|
1249
|
+
for (const [s, i] of Object.entries(e)) {
|
|
1383
1250
|
const n = this._fields.get(s);
|
|
1384
1251
|
if (n) {
|
|
1385
|
-
|
|
1386
|
-
|
|
1252
|
+
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1253
|
+
if (G(a)) continue;
|
|
1254
|
+
n.setValue(i, t);
|
|
1387
1255
|
}
|
|
1388
1256
|
}
|
|
1389
1257
|
}
|
|
1390
1258
|
patchValue(e) {
|
|
1391
|
-
|
|
1259
|
+
ie(() => {
|
|
1392
1260
|
for (const [t, s] of Object.entries(e)) {
|
|
1393
|
-
const
|
|
1394
|
-
if (
|
|
1395
|
-
|
|
1396
|
-
|
|
1261
|
+
const i = this._fields.get(t);
|
|
1262
|
+
if (i && s !== void 0) {
|
|
1263
|
+
const n = this._fieldSignals.get(i) ?? i.value;
|
|
1264
|
+
if (G(n)) continue;
|
|
1265
|
+
i.setValue(s, { emitEvent: !1 });
|
|
1397
1266
|
}
|
|
1398
1267
|
}
|
|
1399
1268
|
});
|
|
@@ -1416,23 +1285,25 @@ let x = class ae extends D {
|
|
|
1416
1285
|
* ```
|
|
1417
1286
|
*/
|
|
1418
1287
|
reset(e) {
|
|
1419
|
-
this._fields.forEach((t, s) => {
|
|
1420
|
-
const
|
|
1421
|
-
t.reset(
|
|
1288
|
+
this._formErrors.value = [], this._fields.forEach((t, s) => {
|
|
1289
|
+
const i = e?.[s];
|
|
1290
|
+
t.reset(i);
|
|
1422
1291
|
});
|
|
1423
1292
|
}
|
|
1424
1293
|
/**
|
|
1425
1294
|
* Сбросить форму к исходным значениям (initialValues)
|
|
1426
1295
|
*/
|
|
1427
1296
|
resetToInitial() {
|
|
1428
|
-
this._fields.forEach((e) => {
|
|
1297
|
+
this._formErrors.value = [], this._fields.forEach((e) => {
|
|
1429
1298
|
"resetToInitial" in e && typeof e.resetToInitial == "function" ? e.resetToInitial() : e.reset();
|
|
1430
1299
|
});
|
|
1431
1300
|
}
|
|
1432
1301
|
async validate() {
|
|
1433
|
-
|
|
1434
|
-
|
|
1302
|
+
this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((s) => s.validate()));
|
|
1303
|
+
const e = this._modelValidate ? await this._modelValidate() : !0, t = Array.from(this._fields.values()).every(
|
|
1304
|
+
(s) => s.valid.value || s.disabled.value
|
|
1435
1305
|
);
|
|
1306
|
+
return e && t;
|
|
1436
1307
|
}
|
|
1437
1308
|
/**
|
|
1438
1309
|
* Установить form-level validation errors
|
|
@@ -1514,7 +1385,12 @@ let x = class ae extends D {
|
|
|
1514
1385
|
*
|
|
1515
1386
|
* @param onSubmit - Callback для отправки данных
|
|
1516
1387
|
* @param options - Опции submit (skipValidation, skipTouch)
|
|
1517
|
-
* @returns Результат от onSubmit или null если валидация не пройдена
|
|
1388
|
+
* @returns Результат от onSubmit или `null` если валидация не пройдена
|
|
1389
|
+
*
|
|
1390
|
+
* @remarks
|
|
1391
|
+
* `null` перегружен: он означает и «валидация не пройдена», и легитимный `null`-результат
|
|
1392
|
+
* `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
|
|
1393
|
+
* используйте {@link submitWithResult}, который возвращает явный флаг `success`.
|
|
1518
1394
|
*/
|
|
1519
1395
|
async submit(e, t) {
|
|
1520
1396
|
return this.formSubmitter.submit(e, t);
|
|
@@ -1561,15 +1437,15 @@ let x = class ae extends D {
|
|
|
1561
1437
|
getFieldByPath(e) {
|
|
1562
1438
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1563
1439
|
return;
|
|
1564
|
-
const t =
|
|
1440
|
+
const t = ce(e);
|
|
1565
1441
|
if (t.length === 0)
|
|
1566
1442
|
return;
|
|
1567
1443
|
let s = this;
|
|
1568
|
-
for (const
|
|
1569
|
-
if (!(s instanceof
|
|
1570
|
-
if (
|
|
1444
|
+
for (const i of t) {
|
|
1445
|
+
if (!(s instanceof S) || (s = s.getField(i.key), !s)) return;
|
|
1446
|
+
if (i.index !== void 0)
|
|
1571
1447
|
if ("at" in s && "length" in s && typeof s.at == "function") {
|
|
1572
|
-
const n = s.at(
|
|
1448
|
+
const n = s.at(i.index);
|
|
1573
1449
|
if (!n) return;
|
|
1574
1450
|
s = n;
|
|
1575
1451
|
} else
|
|
@@ -1605,16 +1481,16 @@ let x = class ae extends D {
|
|
|
1605
1481
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1606
1482
|
*/
|
|
1607
1483
|
linkFields(e, t, s) {
|
|
1608
|
-
const
|
|
1609
|
-
if (!
|
|
1610
|
-
const
|
|
1611
|
-
throw new Error(`GroupNode.linkFields: field "${String(
|
|
1484
|
+
const i = this._fields.get(e), n = this._fields.get(t);
|
|
1485
|
+
if (!i || !n) {
|
|
1486
|
+
const d = i ? t : e;
|
|
1487
|
+
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1612
1488
|
}
|
|
1613
|
-
const a =
|
|
1614
|
-
const
|
|
1489
|
+
const a = b(() => {
|
|
1490
|
+
const d = i.value.value, u = s ? s(d) : d;
|
|
1615
1491
|
n.setValue(u, { emitEvent: !1 });
|
|
1616
|
-
}),
|
|
1617
|
-
return this.disposers.add(
|
|
1492
|
+
}), l = V(w.LinkFields);
|
|
1493
|
+
return this.disposers.add(l, a);
|
|
1618
1494
|
}
|
|
1619
1495
|
/**
|
|
1620
1496
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1648,10 +1524,10 @@ let x = class ae extends D {
|
|
|
1648
1524
|
const s = this.getFieldByPath(e);
|
|
1649
1525
|
if (!s)
|
|
1650
1526
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1651
|
-
const
|
|
1527
|
+
const i = b(() => {
|
|
1652
1528
|
t(s.value.value);
|
|
1653
|
-
}), n = V(
|
|
1654
|
-
return this.disposers.add(n,
|
|
1529
|
+
}), n = V(w.WatchField);
|
|
1530
|
+
return this.disposers.add(n, i);
|
|
1655
1531
|
}
|
|
1656
1532
|
/**
|
|
1657
1533
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
@@ -1661,10 +1537,10 @@ let x = class ae extends D {
|
|
|
1661
1537
|
const s = this.getFieldByPath(e);
|
|
1662
1538
|
if (!s)
|
|
1663
1539
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1664
|
-
const
|
|
1540
|
+
const i = b(() => {
|
|
1665
1541
|
t(s.value.value);
|
|
1666
|
-
}), n = V(
|
|
1667
|
-
return this.disposers.add(n,
|
|
1542
|
+
}), n = V(w.WatchField);
|
|
1543
|
+
return this.disposers.add(n, i);
|
|
1668
1544
|
}
|
|
1669
1545
|
/**
|
|
1670
1546
|
* Hook: вызывается после disable()
|
|
@@ -1685,6 +1561,24 @@ let x = class ae extends D {
|
|
|
1685
1561
|
attachBehaviorCleanup(e) {
|
|
1686
1562
|
this._behaviorCleanup = e;
|
|
1687
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Прикрепить валидацию уровня модели/схемы (M1). Вызывается `createForm({ model, schema })`,
|
|
1566
|
+
* чтобы `validate()`/`submit()` прогоняли schema-валидаторы (`validateFormModel`), а не только
|
|
1567
|
+
* пустые FieldNode. Возвращаемый флаг — валидна ли модель по схеме.
|
|
1568
|
+
* @internal
|
|
1569
|
+
*/
|
|
1570
|
+
attachModelValidator(e) {
|
|
1571
|
+
this._modelValidate = e;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Связать листовую ноду-ребёнка с её сигналом модели (M1). Вызывается `createForm` для каждого
|
|
1575
|
+
* листового поля на его владеющей группе — используется bulk-сеттерами для derived-guard (F9).
|
|
1576
|
+
* @internal
|
|
1577
|
+
*/
|
|
1578
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1579
|
+
registerFieldSignal(e, t) {
|
|
1580
|
+
this._fieldSignals.set(e, t);
|
|
1581
|
+
}
|
|
1688
1582
|
/**
|
|
1689
1583
|
* Очистить все ресурсы узла
|
|
1690
1584
|
*/
|
|
@@ -1693,7 +1587,8 @@ let x = class ae extends D {
|
|
|
1693
1587
|
"dispose" in e && typeof e.dispose == "function" && e.dispose();
|
|
1694
1588
|
});
|
|
1695
1589
|
}
|
|
1696
|
-
}
|
|
1590
|
+
}
|
|
1591
|
+
class H extends C {
|
|
1697
1592
|
// ============================================================================
|
|
1698
1593
|
// Приватные поля
|
|
1699
1594
|
// ============================================================================
|
|
@@ -1704,9 +1599,9 @@ let x = class ae extends D {
|
|
|
1704
1599
|
* Менеджер подписок для централизованного cleanup
|
|
1705
1600
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1706
1601
|
*/
|
|
1707
|
-
disposers = new
|
|
1602
|
+
disposers = new I();
|
|
1708
1603
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1709
|
-
_arrayErrors =
|
|
1604
|
+
_arrayErrors = g([]);
|
|
1710
1605
|
// ============================================================================
|
|
1711
1606
|
// Приватные поля для сохранения схем
|
|
1712
1607
|
// ============================================================================
|
|
@@ -1728,11 +1623,11 @@ let x = class ae extends D {
|
|
|
1728
1623
|
// Конструктор
|
|
1729
1624
|
// ============================================================================
|
|
1730
1625
|
constructor(e, t = []) {
|
|
1731
|
-
super(), this.itemSchema = e, this.initialItems = t, this.items =
|
|
1732
|
-
for (const
|
|
1733
|
-
this.push(
|
|
1734
|
-
this.length =
|
|
1735
|
-
const s =
|
|
1626
|
+
super(), this.itemSchema = e, this.initialItems = t, this.items = g([]);
|
|
1627
|
+
for (const i of t)
|
|
1628
|
+
this.push(i);
|
|
1629
|
+
this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((i) => i.value.value));
|
|
1630
|
+
const s = L({
|
|
1736
1631
|
getChildren: () => this.items.value,
|
|
1737
1632
|
ownErrors: this._arrayErrors
|
|
1738
1633
|
});
|
|
@@ -1763,12 +1658,12 @@ let x = class ae extends D {
|
|
|
1763
1658
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1764
1659
|
),
|
|
1765
1660
|
"ArrayNode.removeAt",
|
|
1766
|
-
|
|
1661
|
+
A.LOG
|
|
1767
1662
|
);
|
|
1768
1663
|
return;
|
|
1769
1664
|
}
|
|
1770
1665
|
const t = this.items.value[e];
|
|
1771
|
-
this.items.value = this.items.value.filter((s,
|
|
1666
|
+
this.items.value = this.items.value.filter((s, i) => i !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1772
1667
|
}
|
|
1773
1668
|
/**
|
|
1774
1669
|
* Вставить элемент в массив
|
|
@@ -1782,12 +1677,12 @@ let x = class ae extends D {
|
|
|
1782
1677
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1783
1678
|
),
|
|
1784
1679
|
"ArrayNode.insert",
|
|
1785
|
-
|
|
1680
|
+
A.LOG
|
|
1786
1681
|
);
|
|
1787
1682
|
return;
|
|
1788
1683
|
}
|
|
1789
|
-
const s = this.createItem(t),
|
|
1790
|
-
|
|
1684
|
+
const s = this.createItem(t), i = [...this.items.value];
|
|
1685
|
+
i.splice(e, 0, s), this.items.value = i;
|
|
1791
1686
|
}
|
|
1792
1687
|
/**
|
|
1793
1688
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1811,13 +1706,13 @@ let x = class ae extends D {
|
|
|
1811
1706
|
O.handle(
|
|
1812
1707
|
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${s})`),
|
|
1813
1708
|
"ArrayNode.move",
|
|
1814
|
-
|
|
1709
|
+
A.LOG
|
|
1815
1710
|
);
|
|
1816
1711
|
return;
|
|
1817
1712
|
}
|
|
1818
1713
|
if (e === t) return;
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1714
|
+
const i = [...this.items.value], [n] = i.splice(e, 1);
|
|
1715
|
+
i.splice(t, 0, n), this.items.value = i;
|
|
1821
1716
|
}
|
|
1822
1717
|
/**
|
|
1823
1718
|
* Поменять местами два элемента массива
|
|
@@ -1839,13 +1734,13 @@ let x = class ae extends D {
|
|
|
1839
1734
|
O.handle(
|
|
1840
1735
|
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${s})`),
|
|
1841
1736
|
"ArrayNode.swap",
|
|
1842
|
-
|
|
1737
|
+
A.LOG
|
|
1843
1738
|
);
|
|
1844
1739
|
return;
|
|
1845
1740
|
}
|
|
1846
1741
|
if (e === t) return;
|
|
1847
|
-
const
|
|
1848
|
-
[
|
|
1742
|
+
const i = [...this.items.value];
|
|
1743
|
+
[i[e], i[t]] = [i[t], i[e]], this.items.value = i;
|
|
1849
1744
|
}
|
|
1850
1745
|
/**
|
|
1851
1746
|
* Удалить все элементы массива
|
|
@@ -1877,7 +1772,7 @@ let x = class ae extends D {
|
|
|
1877
1772
|
}
|
|
1878
1773
|
setValue(e, t) {
|
|
1879
1774
|
this.clear(), e.forEach((s) => this.push(s)), t?.emitEvent !== !1 && this.validate().catch((s) => {
|
|
1880
|
-
O.handle(s, "ArrayNode.setValue",
|
|
1775
|
+
O.handle(s, "ArrayNode.setValue", A.LOG);
|
|
1881
1776
|
});
|
|
1882
1777
|
}
|
|
1883
1778
|
patchValue(e) {
|
|
@@ -1937,7 +1832,7 @@ let x = class ae extends D {
|
|
|
1937
1832
|
this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
|
|
1938
1833
|
}
|
|
1939
1834
|
async validate() {
|
|
1940
|
-
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean);
|
|
1835
|
+
return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean) && this._arrayErrors.value.length === 0;
|
|
1941
1836
|
}
|
|
1942
1837
|
/**
|
|
1943
1838
|
* Установить array-level validation errors
|
|
@@ -2011,8 +1906,8 @@ let x = class ae extends D {
|
|
|
2011
1906
|
*/
|
|
2012
1907
|
forEach(e) {
|
|
2013
1908
|
this.items.value.forEach((t, s) => {
|
|
2014
|
-
const
|
|
2015
|
-
e(
|
|
1909
|
+
const i = t.getProxy();
|
|
1910
|
+
e(i, s);
|
|
2016
1911
|
});
|
|
2017
1912
|
}
|
|
2018
1913
|
/**
|
|
@@ -2022,8 +1917,8 @@ let x = class ae extends D {
|
|
|
2022
1917
|
*/
|
|
2023
1918
|
map(e) {
|
|
2024
1919
|
return this.items.value.map((t, s) => {
|
|
2025
|
-
const
|
|
2026
|
-
return e(
|
|
1920
|
+
const i = t.getProxy();
|
|
1921
|
+
return e(i, s);
|
|
2027
1922
|
});
|
|
2028
1923
|
}
|
|
2029
1924
|
// ============================================================================
|
|
@@ -2035,7 +1930,7 @@ let x = class ae extends D {
|
|
|
2035
1930
|
*/
|
|
2036
1931
|
createItem(e) {
|
|
2037
1932
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2038
|
-
const t = new
|
|
1933
|
+
const t = new S(this.itemSchema);
|
|
2039
1934
|
return e && t.patchValue(e), this.validationSchemaFn && "applyValidationSchema" in t && t.applyValidationSchema(this.validationSchemaFn), this.behaviorSchemaFn && "applyBehaviorSchema" in t && t.applyBehaviorSchema(this.behaviorSchemaFn), t;
|
|
2040
1935
|
}
|
|
2041
1936
|
throw new Error(
|
|
@@ -2122,14 +2017,14 @@ let x = class ae extends D {
|
|
|
2122
2017
|
* ```
|
|
2123
2018
|
*/
|
|
2124
2019
|
watchItems(e, t) {
|
|
2125
|
-
const s =
|
|
2020
|
+
const s = b(() => {
|
|
2126
2021
|
const n = this.items.value.map((a) => {
|
|
2127
|
-
if (a instanceof
|
|
2022
|
+
if (a instanceof S)
|
|
2128
2023
|
return a.getFieldByPath(e)?.value.value;
|
|
2129
2024
|
});
|
|
2130
2025
|
t(n);
|
|
2131
|
-
}),
|
|
2132
|
-
return this.disposers.add(
|
|
2026
|
+
}), i = V(w.WatchItems);
|
|
2027
|
+
return this.disposers.add(i, s);
|
|
2133
2028
|
}
|
|
2134
2029
|
/**
|
|
2135
2030
|
* Подписка на изменение длины массива
|
|
@@ -2154,10 +2049,10 @@ let x = class ae extends D {
|
|
|
2154
2049
|
* ```
|
|
2155
2050
|
*/
|
|
2156
2051
|
watchLength(e) {
|
|
2157
|
-
const t =
|
|
2158
|
-
const
|
|
2159
|
-
e(
|
|
2160
|
-
}), s = V(
|
|
2052
|
+
const t = b(() => {
|
|
2053
|
+
const i = this.length.value;
|
|
2054
|
+
e(i);
|
|
2055
|
+
}), s = V(w.WatchLength);
|
|
2161
2056
|
return this.disposers.add(s, t);
|
|
2162
2057
|
}
|
|
2163
2058
|
/**
|
|
@@ -2220,8 +2115,8 @@ let x = class ae extends D {
|
|
|
2220
2115
|
e.enable();
|
|
2221
2116
|
});
|
|
2222
2117
|
}
|
|
2223
|
-
}
|
|
2224
|
-
class
|
|
2118
|
+
}
|
|
2119
|
+
class he {
|
|
2225
2120
|
/**
|
|
2226
2121
|
* Создает узел формы на основе конфигурации
|
|
2227
2122
|
*
|
|
@@ -2271,14 +2166,14 @@ class ke {
|
|
|
2271
2166
|
if (Array.isArray(e) && e.length >= 1)
|
|
2272
2167
|
return this.createArrayNodeFromArray(e);
|
|
2273
2168
|
if (this.isFieldConfig(e))
|
|
2274
|
-
return new
|
|
2169
|
+
return new le(e);
|
|
2275
2170
|
if (this.isArrayConfig(e))
|
|
2276
|
-
return new
|
|
2171
|
+
return new H(
|
|
2277
2172
|
e.schema,
|
|
2278
2173
|
e.initialItems
|
|
2279
2174
|
);
|
|
2280
2175
|
if (this.isGroupConfig(e))
|
|
2281
|
-
return new
|
|
2176
|
+
return new S(e);
|
|
2282
2177
|
throw new Error(
|
|
2283
2178
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2284
2179
|
e
|
|
@@ -2312,11 +2207,11 @@ class ke {
|
|
|
2312
2207
|
*/
|
|
2313
2208
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2314
2209
|
createArrayNodeFromArray(e) {
|
|
2315
|
-
const [t, ...s] = e,
|
|
2316
|
-
this.isGroupConfig(t) &&
|
|
2210
|
+
const [t, ...s] = e, i = [];
|
|
2211
|
+
this.isGroupConfig(t) && i.push(this.extractValues(t));
|
|
2317
2212
|
for (const n of s)
|
|
2318
|
-
this.isGroupConfig(n) ?
|
|
2319
|
-
return new
|
|
2213
|
+
this.isGroupConfig(n) ? i.push(this.extractValues(n)) : i.push(n);
|
|
2214
|
+
return new H(t, i);
|
|
2320
2215
|
}
|
|
2321
2216
|
/**
|
|
2322
2217
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2354,8 +2249,8 @@ class ke {
|
|
|
2354
2249
|
return e.map((t) => this.extractValues(t));
|
|
2355
2250
|
if (this.isGroupConfig(e)) {
|
|
2356
2251
|
const t = {};
|
|
2357
|
-
for (const [s,
|
|
2358
|
-
t[s] = this.extractValues(
|
|
2252
|
+
for (const [s, i] of Object.entries(e))
|
|
2253
|
+
t[s] = this.extractValues(i);
|
|
2359
2254
|
return t;
|
|
2360
2255
|
}
|
|
2361
2256
|
return e;
|
|
@@ -2380,7 +2275,7 @@ class ke {
|
|
|
2380
2275
|
* ```
|
|
2381
2276
|
*/
|
|
2382
2277
|
isFieldConfig(e) {
|
|
2383
|
-
return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e
|
|
2278
|
+
return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e ? "component" in e || "componentProps" in e || "validators" in e || "asyncValidators" in e || "updateOn" in e || "debounce" in e : !1;
|
|
2384
2279
|
}
|
|
2385
2280
|
/**
|
|
2386
2281
|
* Проверяет, является ли конфиг конфигурацией массива (ArrayConfig)
|
|
@@ -2435,55 +2330,43 @@ class ke {
|
|
|
2435
2330
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2436
2331
|
}
|
|
2437
2332
|
}
|
|
2438
|
-
|
|
2439
|
-
return i == null ? !1 : typeof i == "object" && "value" in i && "setValue" in i && "getValue" in i && "validate" in i;
|
|
2440
|
-
}
|
|
2441
|
-
function Ve(i) {
|
|
2442
|
-
return i == null ? !1 : I(i) && "validators" in i && "asyncValidators" in i && // FieldNode имеет markAsTouched метод
|
|
2443
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2444
|
-
typeof i.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2445
|
-
!("fields" in i) && !("items" in i);
|
|
2446
|
-
}
|
|
2447
|
-
function Oe(i) {
|
|
2448
|
-
return i == null ? !1 : I(i) && "getFieldByPath" in i && "fields" in i && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2449
|
-
!("items" in i) && !("push" in i) && !("removeAt" in i);
|
|
2450
|
-
}
|
|
2451
|
-
function Ne(i) {
|
|
2452
|
-
return i == null ? !1 : I(i) && "items" in i && "length" in i && "push" in i && "removeAt" in i && "at" in i && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2453
|
-
typeof i.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2454
|
-
typeof i.removeAt == "function";
|
|
2455
|
-
}
|
|
2456
|
-
function ze(i) {
|
|
2457
|
-
return Ve(i) ? "FieldNode" : Oe(i) ? "GroupNode" : Ne(i) ? "ArrayNode" : I(i) ? "FormNode" : "Unknown";
|
|
2458
|
-
}
|
|
2459
|
-
class Fe extends D {
|
|
2333
|
+
class fe extends C {
|
|
2460
2334
|
/**
|
|
2461
2335
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2462
2336
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
2463
2337
|
* импорта с `create-form`). Обычно `(item) => createForm({ model: item, schema: itemSchema(item) })`.
|
|
2464
2338
|
*/
|
|
2465
2339
|
constructor(e, t) {
|
|
2466
|
-
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync =
|
|
2467
|
-
const
|
|
2468
|
-
for (let
|
|
2469
|
-
const
|
|
2470
|
-
if (!
|
|
2471
|
-
let
|
|
2472
|
-
|
|
2340
|
+
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = b(() => {
|
|
2341
|
+
const i = e.length, n = [], a = [];
|
|
2342
|
+
for (let u = 0; u < i; u++) {
|
|
2343
|
+
const h = e.at(u);
|
|
2344
|
+
if (!h) continue;
|
|
2345
|
+
let o = this.cache.get(h);
|
|
2346
|
+
o || (o = t(h), this.cache.set(h, o)), n.push(h), a.push(o);
|
|
2473
2347
|
}
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2348
|
+
const l = new Set(n), d = [];
|
|
2349
|
+
for (const u of this.mountedModels) {
|
|
2350
|
+
if (l.has(u)) continue;
|
|
2351
|
+
const h = this.cache.get(u);
|
|
2352
|
+
this.cache.delete(u), h && d.push(h);
|
|
2353
|
+
}
|
|
2354
|
+
this.mountedModels = n, this.itemNodes.value = a, d.forEach((u) => this.disposeItemNode(u));
|
|
2355
|
+
}), this.length = f(() => this.itemNodes.value.length), this.value = f(() => this.itemNodes.value.map((i) => i.value.value));
|
|
2356
|
+
const s = L({
|
|
2477
2357
|
getChildren: () => this.itemNodes.value,
|
|
2478
2358
|
ownErrors: this._arrayErrors
|
|
2479
2359
|
});
|
|
2480
2360
|
this.valid = s.valid, this.invalid = s.invalid, this.pending = s.pending, this.touched = s.touched, this.dirty = s.dirty, this.errors = s.errors, this.status = s.status;
|
|
2481
2361
|
}
|
|
2482
|
-
itemNodes =
|
|
2362
|
+
itemNodes = g([]);
|
|
2483
2363
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
2484
2364
|
cache = /* @__PURE__ */ new WeakMap();
|
|
2365
|
+
// Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
|
|
2366
|
+
// реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
|
|
2367
|
+
mountedModels = [];
|
|
2485
2368
|
initial;
|
|
2486
|
-
_arrayErrors =
|
|
2369
|
+
_arrayErrors = g([]);
|
|
2487
2370
|
disposeSync;
|
|
2488
2371
|
/**
|
|
2489
2372
|
* Сигнал per-item форм. Публичен в т.ч. чтобы `isArrayNode` распознавал узел как массив
|
|
@@ -2596,24 +2479,111 @@ class Fe extends D {
|
|
|
2596
2479
|
onEnable() {
|
|
2597
2480
|
this.itemNodes.value.forEach((e) => e.enable?.());
|
|
2598
2481
|
}
|
|
2599
|
-
/**
|
|
2482
|
+
/** Диспозит форму элемента (эффекты/поведения/вложенные подписки); терпима к не-GroupNode. */
|
|
2483
|
+
disposeItemNode(e) {
|
|
2484
|
+
e.dispose?.();
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* Очистка подписки синхронизации И детерминированный teardown всех форм элементов.
|
|
2488
|
+
* Без пробрасывания dispose в itemNodes эффекты/поведения каждой формы элемента (в т.ч. disposeSync
|
|
2489
|
+
* вложенных ModelArrayNode) остались бы жить после teardown формы — утечка подписок.
|
|
2490
|
+
*/
|
|
2600
2491
|
dispose() {
|
|
2601
|
-
this.disposeSync();
|
|
2492
|
+
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2602
2493
|
}
|
|
2603
2494
|
}
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2495
|
+
const ve = (r) => {
|
|
2496
|
+
const e = r.componentProps;
|
|
2497
|
+
return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
|
|
2498
|
+
}, pe = (r) => typeof r.when == "function" && Array.isArray(r.children);
|
|
2499
|
+
function F(r, e, t, s, i) {
|
|
2500
|
+
if (r == null || typeof r != "object") return;
|
|
2501
|
+
if (Array.isArray(r)) {
|
|
2502
|
+
for (const a of r) F(a, e, t, s, i);
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
const n = r;
|
|
2506
|
+
if (pe(n)) {
|
|
2507
|
+
const a = s && !!n.when(e, t);
|
|
2508
|
+
for (const l of n.children) F(l, e, t, a, i);
|
|
2609
2509
|
return;
|
|
2610
2510
|
}
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2511
|
+
if (ve(n)) {
|
|
2512
|
+
const a = n.componentProps.control, l = n.componentProps.itemComponent, d = a.length;
|
|
2513
|
+
for (let u = 0; u < d; u++) {
|
|
2514
|
+
const h = a.at(u);
|
|
2515
|
+
F(l(h), h, t, s, i);
|
|
2516
|
+
}
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
if (n.value instanceof z) {
|
|
2520
|
+
const a = n.validators ?? [], l = n.asyncValidators ?? [], d = l.length ? [...a, ...l] : a;
|
|
2521
|
+
d.length > 0 && (s ? i.tasks.push({ signal: n.value, validators: d, scope: e }) : i.clearSignals.push(n.value));
|
|
2522
|
+
for (const [u, h] of Object.entries(n))
|
|
2523
|
+
u === "value" || u === "validators" || u === "asyncValidators" || F(h, e, t, s, i);
|
|
2614
2524
|
return;
|
|
2615
2525
|
}
|
|
2616
|
-
|
|
2526
|
+
for (const a of Object.values(n)) F(a, e, t, s, i);
|
|
2527
|
+
}
|
|
2528
|
+
function R(r, e) {
|
|
2529
|
+
const t = { tasks: [], clearSignals: [] };
|
|
2530
|
+
return F(e, r, r, !0, t), t;
|
|
2531
|
+
}
|
|
2532
|
+
const X = (r, e, t) => {
|
|
2533
|
+
(r[e] ??= []).push(t);
|
|
2534
|
+
}, B = (r) => {
|
|
2535
|
+
for (const e of Object.values(r))
|
|
2536
|
+
for (const t of e) if (t.severity !== "warning") return !0;
|
|
2537
|
+
return !1;
|
|
2538
|
+
};
|
|
2539
|
+
function Pe(r, e) {
|
|
2540
|
+
const { tasks: t } = R(r, e), s = {};
|
|
2541
|
+
for (const { signal: i, validators: n, scope: a } of t) {
|
|
2542
|
+
const l = i.peek();
|
|
2543
|
+
for (const d of n) {
|
|
2544
|
+
const u = d(l, a, r);
|
|
2545
|
+
u && typeof u.then == "function" || u && X(s, i.__path, u);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
return { valid: !B(s), errors: s };
|
|
2549
|
+
}
|
|
2550
|
+
async function Te(r, e) {
|
|
2551
|
+
const { tasks: t } = R(r, e), s = await Z(t, r);
|
|
2552
|
+
return { valid: !B(s), errors: s };
|
|
2553
|
+
}
|
|
2554
|
+
async function Z(r, e) {
|
|
2555
|
+
const t = {};
|
|
2556
|
+
return await Promise.all(
|
|
2557
|
+
r.map(async ({ signal: s, validators: i, scope: n }) => {
|
|
2558
|
+
const a = s.peek();
|
|
2559
|
+
for (const l of i) {
|
|
2560
|
+
const d = await l(a, n, e);
|
|
2561
|
+
d && X(t, s.__path, d);
|
|
2562
|
+
}
|
|
2563
|
+
})
|
|
2564
|
+
), t;
|
|
2565
|
+
}
|
|
2566
|
+
async function me(r, e) {
|
|
2567
|
+
const { tasks: t, clearSignals: s } = R(r, e), i = await Z(t, r);
|
|
2568
|
+
for (const { signal: n } of t)
|
|
2569
|
+
U(n)?.setErrors(i[n.__path] ?? []);
|
|
2570
|
+
for (const n of s)
|
|
2571
|
+
U(n)?.setErrors([]);
|
|
2572
|
+
return { valid: !B(i), errors: i };
|
|
2573
|
+
}
|
|
2574
|
+
const ee = (r) => r !== null && typeof r == "object" && !Array.isArray(r) && !(r instanceof Date) && !(typeof Blob < "u" && r instanceof Blob) && !(typeof File < "u" && r instanceof File);
|
|
2575
|
+
function D(r, e, t) {
|
|
2576
|
+
if (r == null || typeof r != "object") return;
|
|
2577
|
+
if (Array.isArray(r)) {
|
|
2578
|
+
for (const n of r) D(n, e, t);
|
|
2579
|
+
return;
|
|
2580
|
+
}
|
|
2581
|
+
const s = r, i = s.array;
|
|
2582
|
+
if (i && typeof i.__path == "string" && typeof s.item == "function") {
|
|
2583
|
+
t.set(i.__path, s.item);
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
s.value instanceof z ? e.set(s.value, {
|
|
2617
2587
|
component: s.component,
|
|
2618
2588
|
componentProps: s.componentProps,
|
|
2619
2589
|
validators: s.validators,
|
|
@@ -2621,581 +2591,259 @@ function G(i, e, t) {
|
|
|
2621
2591
|
updateOn: s.updateOn,
|
|
2622
2592
|
disabled: s.disabled,
|
|
2623
2593
|
debounce: s.debounce
|
|
2624
|
-
})
|
|
2594
|
+
}) : process.env.NODE_ENV !== "production" && s.component !== void 0 && ("valueSignal" in s || s.value != null) && console.warn(
|
|
2595
|
+
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2596
|
+
);
|
|
2625
2597
|
for (const [n, a] of Object.entries(s))
|
|
2626
|
-
n !== "value" &&
|
|
2598
|
+
n !== "value" && D(a, e, t);
|
|
2627
2599
|
}
|
|
2628
|
-
function
|
|
2629
|
-
const
|
|
2600
|
+
function te(r, e, t, s) {
|
|
2601
|
+
const i = {};
|
|
2630
2602
|
for (const [n, a] of Object.entries(e)) {
|
|
2631
|
-
const
|
|
2603
|
+
const l = t === "" ? n : `${t}.${n}`;
|
|
2632
2604
|
if (Array.isArray(a))
|
|
2633
2605
|
continue;
|
|
2634
|
-
if (
|
|
2635
|
-
|
|
2606
|
+
if (ee(a)) {
|
|
2607
|
+
i[n] = te(r, a, l, s);
|
|
2636
2608
|
continue;
|
|
2637
2609
|
}
|
|
2638
|
-
const
|
|
2639
|
-
if (!
|
|
2640
|
-
const u = s.get(
|
|
2641
|
-
|
|
2642
|
-
}
|
|
2643
|
-
return r;
|
|
2644
|
-
}
|
|
2645
|
-
function ue(i, e, t) {
|
|
2646
|
-
for (const [s, r] of Object.entries(i)) {
|
|
2647
|
-
const n = e === "" ? s : `${e}.${s}`;
|
|
2648
|
-
Array.isArray(r) || (oe(r) ? ue(r, n, t) : t.push(n));
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
function ce(i) {
|
|
2652
|
-
const { model: e, schema: t, behavior: s } = i, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2653
|
-
t !== void 0 && G(t, r, n);
|
|
2654
|
-
const a = le(e, e.get(), "", r), o = new x(a), l = e.get();
|
|
2655
|
-
for (const [c, f] of Object.entries(l)) {
|
|
2656
|
-
if (!Array.isArray(f)) continue;
|
|
2657
|
-
const d = n.get(c);
|
|
2658
|
-
if (!d) continue;
|
|
2659
|
-
const p = e[c], v = (b) => ce({ model: b, schema: d(b) }), g = new Fe(p, v);
|
|
2660
|
-
o.fields.set(c, g);
|
|
2661
|
-
}
|
|
2662
|
-
const u = o.getProxy(), m = [];
|
|
2663
|
-
ue(e.get(), "", m);
|
|
2664
|
-
for (const c of m) {
|
|
2665
|
-
const f = e.signalAt(c), d = o.getFieldByPath(c);
|
|
2666
|
-
f && d && ye(f, d);
|
|
2667
|
-
}
|
|
2668
|
-
return s && o.attachBehaviorCleanup(s.__run(e, u)), u;
|
|
2669
|
-
}
|
|
2670
|
-
const xe = (i) => i != null && typeof i == "object" && "model" in i && typeof i.model?.signalAt == "function";
|
|
2671
|
-
function Je(i) {
|
|
2672
|
-
return xe(i) ? ce(i) : new x(i).getProxy();
|
|
2673
|
-
}
|
|
2674
|
-
const M = (i) => !(i === null || typeof i != "object" || Array.isArray(i) || i instanceof Date || typeof Blob < "u" && i instanceof Blob || typeof File < "u" && i instanceof File), A = (i, e) => i === "" ? String(e) : `${i}.${e}`, U = (i) => /^\d+$/.test(i), w = (i) => {
|
|
2675
|
-
if (Array.isArray(i)) return i.map(w);
|
|
2676
|
-
if (M(i)) {
|
|
2677
|
-
const e = {};
|
|
2678
|
-
for (const t of Object.keys(i)) e[t] = w(i[t]);
|
|
2679
|
-
return e;
|
|
2610
|
+
const d = r.signalAt(l);
|
|
2611
|
+
if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2612
|
+
const u = s.get(d) ?? {}, { validators: h, asyncValidators: o, ...p } = u;
|
|
2613
|
+
i[n] = { ...p, valueSignal: d };
|
|
2680
2614
|
}
|
|
2681
2615
|
return i;
|
|
2682
|
-
}, C = (i, e) => {
|
|
2683
|
-
if (i === e) return !0;
|
|
2684
|
-
if (Array.isArray(i) && Array.isArray(e))
|
|
2685
|
-
return i.length !== e.length ? !1 : i.every((t, s) => C(t, e[s]));
|
|
2686
|
-
if (M(i) && M(e)) {
|
|
2687
|
-
const t = Object.keys(i), s = Object.keys(e);
|
|
2688
|
-
return t.length !== s.length ? !1 : t.every((r) => C(i[r], e[r]));
|
|
2689
|
-
}
|
|
2690
|
-
return !1;
|
|
2691
|
-
};
|
|
2692
|
-
class Pe {
|
|
2693
|
-
constructor(e, t) {
|
|
2694
|
-
this.path = t;
|
|
2695
|
-
const s = y(e);
|
|
2696
|
-
s.__path = t, this.signal = s, this.initial = w(e);
|
|
2697
|
-
}
|
|
2698
|
-
kind = "leaf";
|
|
2699
|
-
signal;
|
|
2700
|
-
initial;
|
|
2701
|
-
rebase(e) {
|
|
2702
|
-
this.path = e, this.signal.__path = e;
|
|
2703
|
-
}
|
|
2704
|
-
/** Реактивное чтение (внутри effect/computed создаёт зависимость). */
|
|
2705
|
-
read() {
|
|
2706
|
-
return this.signal.value;
|
|
2707
|
-
}
|
|
2708
|
-
/** Нереактивный снимок. */
|
|
2709
|
-
peek() {
|
|
2710
|
-
return this.signal.peek();
|
|
2711
|
-
}
|
|
2712
|
-
set(e) {
|
|
2713
|
-
this.signal.value = e;
|
|
2714
|
-
}
|
|
2715
|
-
resetToInitial() {
|
|
2716
|
-
this.signal.value = w(this.initial);
|
|
2717
|
-
}
|
|
2718
|
-
captureInitial() {
|
|
2719
|
-
this.initial = w(this.signal.peek());
|
|
2720
|
-
}
|
|
2721
|
-
dirty() {
|
|
2722
|
-
return !C(this.signal.peek(), this.initial);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
class he {
|
|
2726
|
-
constructor(e, t) {
|
|
2727
|
-
this.path = t;
|
|
2728
|
-
for (const s of Object.keys(e))
|
|
2729
|
-
this.children.set(s, F(e[s], A(t, s)));
|
|
2730
|
-
}
|
|
2731
|
-
kind = "group";
|
|
2732
|
-
children = /* @__PURE__ */ new Map();
|
|
2733
|
-
rebase(e) {
|
|
2734
|
-
this.path = e;
|
|
2735
|
-
for (const [t, s] of this.children) s.rebase(A(e, t));
|
|
2736
|
-
}
|
|
2737
|
-
peek() {
|
|
2738
|
-
const e = {};
|
|
2739
|
-
for (const [t, s] of this.children) e[t] = s.peek();
|
|
2740
|
-
return e;
|
|
2741
|
-
}
|
|
2742
|
-
set(e) {
|
|
2743
|
-
if (e == null || typeof e != "object") return;
|
|
2744
|
-
const t = e;
|
|
2745
|
-
for (const [s, r] of this.children)
|
|
2746
|
-
s in t && (r.kind === "leaf" && B(r.signal) || r.set(t[s]));
|
|
2747
|
-
}
|
|
2748
|
-
resetToInitial() {
|
|
2749
|
-
for (const e of this.children.values()) e.resetToInitial();
|
|
2750
|
-
}
|
|
2751
|
-
captureInitial() {
|
|
2752
|
-
for (const e of this.children.values()) e.captureInitial();
|
|
2753
|
-
}
|
|
2754
|
-
dirty() {
|
|
2755
|
-
for (const e of this.children.values()) if (e.dirty()) return !0;
|
|
2756
|
-
return !1;
|
|
2757
|
-
}
|
|
2758
2616
|
}
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
kind = "array";
|
|
2764
|
-
items;
|
|
2765
|
-
initial;
|
|
2766
|
-
rebase(e) {
|
|
2767
|
-
this.path = e, this.items.peek().forEach((t, s) => t.rebase(A(e, s)));
|
|
2768
|
-
}
|
|
2769
|
-
reindex() {
|
|
2770
|
-
this.items.peek().forEach((e, t) => e.rebase(A(this.path, t)));
|
|
2771
|
-
}
|
|
2772
|
-
push(e) {
|
|
2773
|
-
const t = this.items.peek();
|
|
2774
|
-
this.items.value = [...t, F(e, A(this.path, t.length))];
|
|
2775
|
-
}
|
|
2776
|
-
insertAt(e, t) {
|
|
2777
|
-
const s = [...this.items.peek()];
|
|
2778
|
-
s.splice(e, 0, F(t, A(this.path, e))), this.items.value = s, this.reindex();
|
|
2779
|
-
}
|
|
2780
|
-
removeAt(e) {
|
|
2781
|
-
const t = [...this.items.peek()];
|
|
2782
|
-
t.splice(e, 1), this.items.value = t, this.reindex();
|
|
2783
|
-
}
|
|
2784
|
-
move(e, t) {
|
|
2785
|
-
const s = [...this.items.peek()], [r] = s.splice(e, 1);
|
|
2786
|
-
r && s.splice(t, 0, r), this.items.value = s, this.reindex();
|
|
2787
|
-
}
|
|
2788
|
-
swap(e, t) {
|
|
2789
|
-
const s = [...this.items.peek()];
|
|
2790
|
-
e < 0 || t < 0 || e >= s.length || t >= s.length || e === t || ([s[e], s[t]] = [s[t], s[e]], this.items.value = s, this.reindex());
|
|
2791
|
-
}
|
|
2792
|
-
clear() {
|
|
2793
|
-
this.items.value = [];
|
|
2794
|
-
}
|
|
2795
|
-
peek() {
|
|
2796
|
-
return this.items.peek().map((e) => e.peek());
|
|
2797
|
-
}
|
|
2798
|
-
set(e) {
|
|
2799
|
-
const t = Array.isArray(e) ? e : [];
|
|
2800
|
-
this.items.value = t.map((s, r) => F(s, A(this.path, r)));
|
|
2801
|
-
}
|
|
2802
|
-
resetToInitial() {
|
|
2803
|
-
this.set(w(this.initial));
|
|
2804
|
-
}
|
|
2805
|
-
captureInitial() {
|
|
2806
|
-
this.initial = w(this.peek());
|
|
2807
|
-
}
|
|
2808
|
-
dirty() {
|
|
2809
|
-
return !C(this.peek(), this.initial);
|
|
2617
|
+
function se(r, e, t) {
|
|
2618
|
+
for (const [s, i] of Object.entries(r)) {
|
|
2619
|
+
const n = e === "" ? s : `${e}.${s}`;
|
|
2620
|
+
Array.isArray(i) || (ee(i) ? se(i, n, t) : t.push(n));
|
|
2810
2621
|
}
|
|
2811
2622
|
}
|
|
2812
|
-
function
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
getOwnPropertyDescriptor: (e, t) => typeof t == "string" && i.children.has(t) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2623
|
+
function re(r) {
|
|
2624
|
+
const { model: e, schema: t, behavior: s } = r, i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2625
|
+
t !== void 0 && D(t, i, n);
|
|
2626
|
+
const a = te(e, e.get(), "", i), l = new S(a), d = e.get();
|
|
2627
|
+
for (const [o, p] of Object.entries(d)) {
|
|
2628
|
+
if (!Array.isArray(p)) continue;
|
|
2629
|
+
const c = n.get(o);
|
|
2630
|
+
if (!c) continue;
|
|
2631
|
+
const v = e[o], m = (y) => re({ model: y, schema: c(y) }), _ = new fe(v, m);
|
|
2632
|
+
l.fields.set(o, _);
|
|
2633
|
+
}
|
|
2634
|
+
const u = l.getProxy(), h = [];
|
|
2635
|
+
se(e.get(), "", h);
|
|
2636
|
+
for (const o of h) {
|
|
2637
|
+
const p = e.signalAt(o), c = l.getFieldByPath(o);
|
|
2638
|
+
if (p && c) {
|
|
2639
|
+
ne(p, c);
|
|
2640
|
+
const v = o.lastIndexOf("."), m = v === -1 ? l : l.getFieldByPath(o.slice(0, v));
|
|
2641
|
+
m instanceof S && m.registerFieldSignal(c, p);
|
|
2832
2642
|
}
|
|
2833
|
-
);
|
|
2834
|
-
}
|
|
2835
|
-
function j(i) {
|
|
2836
|
-
if (i)
|
|
2837
|
-
return i.kind === "group" ? fe(i) : i.kind === "array" ? de(i) : i.read();
|
|
2838
|
-
}
|
|
2839
|
-
function de(i) {
|
|
2840
|
-
const e = {
|
|
2841
|
-
get length() {
|
|
2842
|
-
return i.items.value.length;
|
|
2843
|
-
},
|
|
2844
|
-
push: (t) => i.push(t),
|
|
2845
|
-
insertAt: (t, s) => i.insertAt(t, s),
|
|
2846
|
-
removeAt: (t) => i.removeAt(t),
|
|
2847
|
-
move: (t, s) => i.move(t, s),
|
|
2848
|
-
swap: (t, s) => i.swap(t, s),
|
|
2849
|
-
clear: () => i.clear(),
|
|
2850
|
-
at: (t) => j(i.items.value[t]),
|
|
2851
|
-
map: (t) => i.items.value.map((s, r) => t(j(s), r)),
|
|
2852
|
-
forEach: (t) => i.items.value.forEach((s, r) => t(j(s), r)),
|
|
2853
|
-
toArray: () => i.peek(),
|
|
2854
|
-
[Symbol.iterator]: function* () {
|
|
2855
|
-
const t = i.items.value;
|
|
2856
|
-
for (let s = 0; s < t.length; s++) yield T(t[s]);
|
|
2857
|
-
}
|
|
2858
|
-
};
|
|
2859
|
-
return new Proxy(e, {
|
|
2860
|
-
get: (t, s, r) => s === "__path" ? i.path : typeof s == "string" && U(s) ? T(i.items.value[Number(s)]) : Reflect.get(t, s, r),
|
|
2861
|
-
has: (t, s) => typeof s == "string" && U(s) ? Number(s) < i.items.value.length : Reflect.has(t, s)
|
|
2862
|
-
});
|
|
2863
|
-
}
|
|
2864
|
-
function W(i) {
|
|
2865
|
-
if (i.kind === "leaf") return i.signal;
|
|
2866
|
-
if (i.kind === "group")
|
|
2867
|
-
return new Proxy(
|
|
2868
|
-
{},
|
|
2869
|
-
{
|
|
2870
|
-
get: (t, s) => {
|
|
2871
|
-
if (s === "__path") return i.path;
|
|
2872
|
-
if (typeof s != "string") return;
|
|
2873
|
-
const r = i.children.get(s);
|
|
2874
|
-
return r ? W(r) : void 0;
|
|
2875
|
-
},
|
|
2876
|
-
has: (t, s) => typeof s == "string" && i.children.has(s),
|
|
2877
|
-
ownKeys: () => [...i.children.keys()],
|
|
2878
|
-
getOwnPropertyDescriptor: (t, s) => typeof s == "string" && i.children.has(s) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2879
|
-
}
|
|
2880
|
-
);
|
|
2881
|
-
const e = i;
|
|
2882
|
-
return new Proxy(
|
|
2883
|
-
{
|
|
2884
|
-
get length() {
|
|
2885
|
-
return e.items.value.length;
|
|
2886
|
-
}
|
|
2887
|
-
},
|
|
2888
|
-
{
|
|
2889
|
-
get: (t, s, r) => {
|
|
2890
|
-
if (s === "__path") return e.path;
|
|
2891
|
-
if (typeof s == "string" && U(s)) {
|
|
2892
|
-
const n = e.items.value[Number(s)];
|
|
2893
|
-
return n ? W(n) : void 0;
|
|
2894
|
-
}
|
|
2895
|
-
return Reflect.get(t, s, r);
|
|
2896
|
-
}
|
|
2897
|
-
}
|
|
2898
|
-
);
|
|
2899
|
-
}
|
|
2900
|
-
function Te(i, e) {
|
|
2901
|
-
if (!e) return;
|
|
2902
|
-
let t = i;
|
|
2903
|
-
for (const s of e.split(".")) {
|
|
2904
|
-
if (!t) return;
|
|
2905
|
-
if (t.kind === "group") t = t.children.get(s);
|
|
2906
|
-
else if (t.kind === "array") t = t.items.peek()[Number(s)];
|
|
2907
|
-
else return;
|
|
2908
|
-
}
|
|
2909
|
-
return t && t.kind === "leaf" ? t.signal : void 0;
|
|
2910
|
-
}
|
|
2911
|
-
const Z = /* @__PURE__ */ new Set([
|
|
2912
|
-
"$",
|
|
2913
|
-
"get",
|
|
2914
|
-
"set",
|
|
2915
|
-
"patch",
|
|
2916
|
-
"isDirty",
|
|
2917
|
-
"reset",
|
|
2918
|
-
"captureInitial",
|
|
2919
|
-
"signalAt"
|
|
2920
|
-
]), ee = /* @__PURE__ */ new WeakMap();
|
|
2921
|
-
function fe(i) {
|
|
2922
|
-
const e = ee.get(i);
|
|
2923
|
-
if (e) return e;
|
|
2924
|
-
const t = {
|
|
2925
|
-
$: W(i),
|
|
2926
|
-
get: () => i.peek(),
|
|
2927
|
-
set: (r) => i.set(r),
|
|
2928
|
-
patch: (r) => i.set(r),
|
|
2929
|
-
isDirty: () => i.dirty(),
|
|
2930
|
-
reset: () => i.resetToInitial(),
|
|
2931
|
-
captureInitial: () => i.captureInitial(),
|
|
2932
|
-
signalAt: (r) => Te(i, r)
|
|
2933
|
-
}, s = new Proxy(
|
|
2934
|
-
{},
|
|
2935
|
-
{
|
|
2936
|
-
get: (r, n) => {
|
|
2937
|
-
if (typeof n != "string") return;
|
|
2938
|
-
const a = i.children.get(n);
|
|
2939
|
-
if (a) return T(a);
|
|
2940
|
-
if (Z.has(n)) return t[n];
|
|
2941
|
-
},
|
|
2942
|
-
set: (r, n, a) => {
|
|
2943
|
-
if (typeof n != "string") return !1;
|
|
2944
|
-
const o = i.children.get(n);
|
|
2945
|
-
return o ? (o.set(a), !0) : !1;
|
|
2946
|
-
},
|
|
2947
|
-
has: (r, n) => typeof n == "string" && (i.children.has(n) || Z.has(n)),
|
|
2948
|
-
ownKeys: () => [...i.children.keys()],
|
|
2949
|
-
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && i.children.has(n) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2950
|
-
}
|
|
2951
|
-
);
|
|
2952
|
-
return ee.set(i, s), s;
|
|
2953
|
-
}
|
|
2954
|
-
function Ye(i) {
|
|
2955
|
-
const e = new he(i, "");
|
|
2956
|
-
return fe(e);
|
|
2957
|
-
}
|
|
2958
|
-
const De = (i) => {
|
|
2959
|
-
const e = i.componentProps;
|
|
2960
|
-
return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
|
|
2961
|
-
}, Ie = (i) => typeof i.when == "function" && Array.isArray(i.children);
|
|
2962
|
-
function N(i, e, t, s, r) {
|
|
2963
|
-
if (i == null || typeof i != "object") return;
|
|
2964
|
-
if (Array.isArray(i)) {
|
|
2965
|
-
for (const a of i) N(a, e, t, s, r);
|
|
2966
|
-
return;
|
|
2967
2643
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
for (const o of n.children) N(o, e, t, a, r);
|
|
2972
|
-
return;
|
|
2973
|
-
}
|
|
2974
|
-
if (De(n)) {
|
|
2975
|
-
const a = n.componentProps.control, o = n.componentProps.itemComponent, l = a.length;
|
|
2976
|
-
for (let u = 0; u < l; u++) {
|
|
2977
|
-
const m = a.at(u);
|
|
2978
|
-
N(o(m), m, t, s, r);
|
|
2979
|
-
}
|
|
2980
|
-
return;
|
|
2981
|
-
}
|
|
2982
|
-
if (n.value instanceof re) {
|
|
2983
|
-
const a = n.validators ?? [];
|
|
2984
|
-
a.length > 0 && (s ? r.tasks.push({ signal: n.value, validators: a, scope: e }) : r.clearSignals.push(n.value));
|
|
2985
|
-
for (const [o, l] of Object.entries(n))
|
|
2986
|
-
o === "value" || o === "validators" || N(l, e, t, s, r);
|
|
2987
|
-
return;
|
|
2644
|
+
if (t !== void 0) {
|
|
2645
|
+
const o = t;
|
|
2646
|
+
l.attachModelValidator(async () => (await me(e, o)).valid);
|
|
2988
2647
|
}
|
|
2989
|
-
|
|
2648
|
+
return s && l.attachBehaviorCleanup(s.__run(e, u)), u;
|
|
2990
2649
|
}
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
return
|
|
2650
|
+
const ye = (r) => r != null && typeof r == "object" && "model" in r && typeof r.model?.signalAt == "function";
|
|
2651
|
+
function De(r) {
|
|
2652
|
+
return ye(r) ? re(r) : new S(r).getProxy();
|
|
2994
2653
|
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
};
|
|
2998
|
-
function Qe(i, e) {
|
|
2999
|
-
const { tasks: t } = z(i, e), s = {};
|
|
3000
|
-
for (const { signal: r, validators: n, scope: a } of t) {
|
|
3001
|
-
const o = r.peek();
|
|
3002
|
-
for (const l of n) {
|
|
3003
|
-
const u = l(o, a, i);
|
|
3004
|
-
u && typeof u.then == "function" || u && pe(s, r.__path, u);
|
|
3005
|
-
}
|
|
3006
|
-
}
|
|
3007
|
-
return { valid: Object.keys(s).length === 0, errors: s };
|
|
2654
|
+
function x(r) {
|
|
2655
|
+
return r == null ? !1 : typeof r == "object" && "value" in r && "setValue" in r && "getValue" in r && "validate" in r;
|
|
3008
2656
|
}
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
2657
|
+
function ge(r) {
|
|
2658
|
+
return r == null ? !1 : x(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
|
|
2659
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2660
|
+
typeof r.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2661
|
+
!("fields" in r) && !("items" in r);
|
|
3012
2662
|
}
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
i.map(async ({ signal: s, validators: r, scope: n }) => {
|
|
3017
|
-
const a = s.peek();
|
|
3018
|
-
for (const o of r) {
|
|
3019
|
-
const l = await o(a, n, e);
|
|
3020
|
-
l && pe(t, s.__path, l);
|
|
3021
|
-
}
|
|
3022
|
-
})
|
|
3023
|
-
), t;
|
|
2663
|
+
function _e(r) {
|
|
2664
|
+
return r == null ? !1 : x(r) && "getFieldByPath" in r && "fields" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2665
|
+
!("items" in r) && !("push" in r) && !("removeAt" in r);
|
|
3024
2666
|
}
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
for (const n of s)
|
|
3030
|
-
Q(n)?.setErrors([]);
|
|
3031
|
-
return { valid: Object.keys(r).length === 0, errors: r };
|
|
2667
|
+
function be(r) {
|
|
2668
|
+
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
|
|
2669
|
+
typeof r.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2670
|
+
typeof r.removeAt == "function";
|
|
3032
2671
|
}
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
2672
|
+
function Ie(r) {
|
|
2673
|
+
return ge(r) ? "FieldNode" : _e(r) ? "GroupNode" : be(r) ? "ArrayNode" : x(r) ? "FormNode" : "Unknown";
|
|
2674
|
+
}
|
|
2675
|
+
var M = { exports: {} }, P = {};
|
|
2676
|
+
var K;
|
|
2677
|
+
function Ee() {
|
|
2678
|
+
if (K) return P;
|
|
2679
|
+
K = 1;
|
|
2680
|
+
var r = Q;
|
|
2681
|
+
function e(o, p) {
|
|
2682
|
+
return o === p && (o !== 0 || 1 / o === 1 / p) || o !== o && p !== p;
|
|
2683
|
+
}
|
|
2684
|
+
var t = typeof Object.is == "function" ? Object.is : e, s = r.useState, i = r.useEffect, n = r.useLayoutEffect, a = r.useDebugValue;
|
|
2685
|
+
function l(o, p) {
|
|
2686
|
+
var c = p(), v = s({ inst: { value: c, getSnapshot: p } }), m = v[0].inst, _ = v[1];
|
|
3045
2687
|
return n(
|
|
3046
2688
|
function() {
|
|
3047
|
-
|
|
2689
|
+
m.value = c, m.getSnapshot = p, d(m) && _({ inst: m });
|
|
3048
2690
|
},
|
|
3049
|
-
[
|
|
3050
|
-
),
|
|
2691
|
+
[o, c, p]
|
|
2692
|
+
), i(
|
|
3051
2693
|
function() {
|
|
3052
|
-
return
|
|
3053
|
-
|
|
2694
|
+
return d(m) && _({ inst: m }), o(function() {
|
|
2695
|
+
d(m) && _({ inst: m });
|
|
3054
2696
|
});
|
|
3055
2697
|
},
|
|
3056
|
-
[
|
|
3057
|
-
), a(
|
|
2698
|
+
[o]
|
|
2699
|
+
), a(c), c;
|
|
3058
2700
|
}
|
|
3059
|
-
function
|
|
3060
|
-
var
|
|
3061
|
-
|
|
2701
|
+
function d(o) {
|
|
2702
|
+
var p = o.getSnapshot;
|
|
2703
|
+
o = o.value;
|
|
3062
2704
|
try {
|
|
3063
|
-
var
|
|
3064
|
-
return !t(
|
|
2705
|
+
var c = p();
|
|
2706
|
+
return !t(o, c);
|
|
3065
2707
|
} catch {
|
|
3066
2708
|
return !0;
|
|
3067
2709
|
}
|
|
3068
2710
|
}
|
|
3069
|
-
function u(
|
|
3070
|
-
return
|
|
2711
|
+
function u(o, p) {
|
|
2712
|
+
return p();
|
|
3071
2713
|
}
|
|
3072
|
-
var
|
|
3073
|
-
return
|
|
2714
|
+
var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2715
|
+
return P.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : h, P;
|
|
3074
2716
|
}
|
|
3075
|
-
var
|
|
3076
|
-
var
|
|
3077
|
-
function
|
|
3078
|
-
return
|
|
3079
|
-
function
|
|
3080
|
-
return
|
|
2717
|
+
var T = {};
|
|
2718
|
+
var J;
|
|
2719
|
+
function Se() {
|
|
2720
|
+
return J || (J = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2721
|
+
function r(c, v) {
|
|
2722
|
+
return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
|
|
3081
2723
|
}
|
|
3082
|
-
function e(
|
|
3083
|
-
|
|
2724
|
+
function e(c, v) {
|
|
2725
|
+
h || i.startTransition === void 0 || (h = !0, console.error(
|
|
3084
2726
|
"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."
|
|
3085
2727
|
));
|
|
3086
|
-
var
|
|
3087
|
-
if (!
|
|
3088
|
-
var
|
|
3089
|
-
n(
|
|
2728
|
+
var m = v();
|
|
2729
|
+
if (!o) {
|
|
2730
|
+
var _ = v();
|
|
2731
|
+
n(m, _) || (console.error(
|
|
3090
2732
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
3091
|
-
),
|
|
2733
|
+
), o = !0);
|
|
3092
2734
|
}
|
|
3093
|
-
|
|
3094
|
-
inst: { value:
|
|
2735
|
+
_ = a({
|
|
2736
|
+
inst: { value: m, getSnapshot: v }
|
|
3095
2737
|
});
|
|
3096
|
-
var
|
|
3097
|
-
return
|
|
2738
|
+
var y = _[0].inst, k = _[1];
|
|
2739
|
+
return d(
|
|
3098
2740
|
function() {
|
|
3099
|
-
|
|
2741
|
+
y.value = m, y.getSnapshot = v, t(y) && k({ inst: y });
|
|
3100
2742
|
},
|
|
3101
|
-
[
|
|
3102
|
-
),
|
|
2743
|
+
[c, m, v]
|
|
2744
|
+
), l(
|
|
3103
2745
|
function() {
|
|
3104
|
-
return t(
|
|
3105
|
-
t(
|
|
2746
|
+
return t(y) && k({ inst: y }), c(function() {
|
|
2747
|
+
t(y) && k({ inst: y });
|
|
3106
2748
|
});
|
|
3107
2749
|
},
|
|
3108
|
-
[
|
|
3109
|
-
), u(
|
|
2750
|
+
[c]
|
|
2751
|
+
), u(m), m;
|
|
3110
2752
|
}
|
|
3111
|
-
function t(
|
|
3112
|
-
var
|
|
3113
|
-
|
|
2753
|
+
function t(c) {
|
|
2754
|
+
var v = c.getSnapshot;
|
|
2755
|
+
c = c.value;
|
|
3114
2756
|
try {
|
|
3115
|
-
var
|
|
3116
|
-
return !n(
|
|
2757
|
+
var m = v();
|
|
2758
|
+
return !n(c, m);
|
|
3117
2759
|
} catch {
|
|
3118
2760
|
return !0;
|
|
3119
2761
|
}
|
|
3120
2762
|
}
|
|
3121
|
-
function s(
|
|
3122
|
-
return
|
|
2763
|
+
function s(c, v) {
|
|
2764
|
+
return v();
|
|
3123
2765
|
}
|
|
3124
2766
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
3125
|
-
var
|
|
3126
|
-
|
|
3127
|
-
})()),
|
|
2767
|
+
var i = Q, n = typeof Object.is == "function" ? Object.is : r, a = i.useState, l = i.useEffect, d = i.useLayoutEffect, u = i.useDebugValue, h = !1, o = !1, p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : e;
|
|
2768
|
+
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());
|
|
2769
|
+
})()), T;
|
|
3128
2770
|
}
|
|
3129
|
-
var
|
|
3130
|
-
function
|
|
3131
|
-
return
|
|
2771
|
+
var Y;
|
|
2772
|
+
function Ae() {
|
|
2773
|
+
return Y || (Y = 1, process.env.NODE_ENV === "production" ? M.exports = Ee() : M.exports = Se()), M.exports;
|
|
3132
2774
|
}
|
|
3133
|
-
var
|
|
3134
|
-
function
|
|
3135
|
-
if (
|
|
3136
|
-
if (
|
|
3137
|
-
for (let t = 0; t <
|
|
3138
|
-
if (
|
|
2775
|
+
var $ = Ae();
|
|
2776
|
+
function we(r, e) {
|
|
2777
|
+
if (r === e) return !0;
|
|
2778
|
+
if (r.length !== e.length) return !1;
|
|
2779
|
+
for (let t = 0; t < r.length; t++)
|
|
2780
|
+
if (r[t] !== e[t]) return !1;
|
|
3139
2781
|
return !0;
|
|
3140
2782
|
}
|
|
3141
|
-
function
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
2783
|
+
function j(r, e, t, s) {
|
|
2784
|
+
const i = N(null), n = N(r);
|
|
2785
|
+
n.current = r;
|
|
2786
|
+
const a = N(e);
|
|
2787
|
+
a.current = e;
|
|
2788
|
+
const l = N(t);
|
|
2789
|
+
if (l.current = t, i.current === null) {
|
|
2790
|
+
const h = {};
|
|
2791
|
+
for (const o in r)
|
|
2792
|
+
h[o] = r[o].value;
|
|
2793
|
+
i.current = { ...h, __snapshot: null };
|
|
2794
|
+
}
|
|
2795
|
+
const d = E(
|
|
2796
|
+
(h) => {
|
|
3151
2797
|
let o = !0;
|
|
3152
|
-
return
|
|
3153
|
-
|
|
3154
|
-
|
|
2798
|
+
return b(() => {
|
|
2799
|
+
const c = n.current;
|
|
2800
|
+
for (const v in c)
|
|
2801
|
+
c[v].value;
|
|
3155
2802
|
if (o) {
|
|
3156
2803
|
o = !1;
|
|
3157
2804
|
return;
|
|
3158
2805
|
}
|
|
3159
|
-
|
|
2806
|
+
h();
|
|
3160
2807
|
});
|
|
3161
2808
|
},
|
|
3162
|
-
[
|
|
3163
|
-
),
|
|
3164
|
-
const
|
|
3165
|
-
for (const
|
|
3166
|
-
|
|
3167
|
-
let
|
|
3168
|
-
for (const
|
|
3169
|
-
const { key: m, useShallowArrayEqual:
|
|
3170
|
-
if (
|
|
3171
|
-
if (
|
|
3172
|
-
|
|
2809
|
+
[s]
|
|
2810
|
+
), u = E(() => {
|
|
2811
|
+
const h = i.current, o = n.current, p = {};
|
|
2812
|
+
for (const v in o)
|
|
2813
|
+
p[v] = o[v].value;
|
|
2814
|
+
let c = !1;
|
|
2815
|
+
for (const v of a.current) {
|
|
2816
|
+
const { key: m, useShallowArrayEqual: _ } = v, y = p[m], k = h[m];
|
|
2817
|
+
if (_) {
|
|
2818
|
+
if (!we(k, y)) {
|
|
2819
|
+
c = !0;
|
|
3173
2820
|
break;
|
|
3174
2821
|
}
|
|
3175
|
-
} else if (
|
|
3176
|
-
|
|
2822
|
+
} else if (k !== y) {
|
|
2823
|
+
c = !0;
|
|
3177
2824
|
break;
|
|
3178
2825
|
}
|
|
3179
2826
|
}
|
|
3180
|
-
if (!
|
|
3181
|
-
return
|
|
3182
|
-
for (const
|
|
3183
|
-
|
|
3184
|
-
return
|
|
3185
|
-
}, [
|
|
3186
|
-
return
|
|
2827
|
+
if (!c && h.__snapshot)
|
|
2828
|
+
return h.__snapshot;
|
|
2829
|
+
for (const v in o)
|
|
2830
|
+
h[v] = p[v];
|
|
2831
|
+
return h.__snapshot = l.current(p), h.__snapshot;
|
|
2832
|
+
}, [s]);
|
|
2833
|
+
return $.useSyncExternalStore(d, u, u);
|
|
3187
2834
|
}
|
|
3188
|
-
function
|
|
2835
|
+
function Ve(r) {
|
|
3189
2836
|
const e = {
|
|
3190
|
-
value:
|
|
3191
|
-
disabled:
|
|
3192
|
-
errors:
|
|
3193
|
-
pending:
|
|
3194
|
-
valid:
|
|
3195
|
-
invalid:
|
|
3196
|
-
touched:
|
|
3197
|
-
|
|
3198
|
-
|
|
2837
|
+
value: r.value,
|
|
2838
|
+
disabled: r.disabled,
|
|
2839
|
+
errors: r.errors,
|
|
2840
|
+
pending: r.pending,
|
|
2841
|
+
valid: r.valid,
|
|
2842
|
+
invalid: r.invalid,
|
|
2843
|
+
touched: r.touched,
|
|
2844
|
+
dirty: r.dirty,
|
|
2845
|
+
shouldShowError: r.shouldShowError,
|
|
2846
|
+
componentProps: r.componentProps
|
|
3199
2847
|
}, t = [
|
|
3200
2848
|
{ key: "value" },
|
|
3201
2849
|
{ key: "disabled" },
|
|
@@ -3204,34 +2852,37 @@ function Be(i) {
|
|
|
3204
2852
|
{ key: "valid" },
|
|
3205
2853
|
{ key: "invalid" },
|
|
3206
2854
|
{ key: "touched" },
|
|
2855
|
+
{ key: "dirty" },
|
|
3207
2856
|
{ key: "shouldShowError" },
|
|
3208
2857
|
{ key: "componentProps" }
|
|
3209
2858
|
], s = E(
|
|
3210
|
-
(
|
|
3211
|
-
value:
|
|
3212
|
-
pending:
|
|
3213
|
-
disabled:
|
|
3214
|
-
errors:
|
|
3215
|
-
valid:
|
|
3216
|
-
invalid:
|
|
3217
|
-
touched:
|
|
3218
|
-
|
|
3219
|
-
|
|
2859
|
+
(i) => ({
|
|
2860
|
+
value: i.value,
|
|
2861
|
+
pending: i.pending,
|
|
2862
|
+
disabled: i.disabled,
|
|
2863
|
+
errors: i.errors,
|
|
2864
|
+
valid: i.valid,
|
|
2865
|
+
invalid: i.invalid,
|
|
2866
|
+
touched: i.touched,
|
|
2867
|
+
dirty: i.dirty,
|
|
2868
|
+
shouldShowError: i.shouldShowError,
|
|
2869
|
+
componentProps: i.componentProps
|
|
3220
2870
|
}),
|
|
3221
2871
|
[]
|
|
3222
2872
|
);
|
|
3223
|
-
return
|
|
2873
|
+
return j(e, t, s, r);
|
|
3224
2874
|
}
|
|
3225
|
-
function
|
|
2875
|
+
function ke(r) {
|
|
3226
2876
|
const e = {
|
|
3227
|
-
value:
|
|
3228
|
-
length:
|
|
3229
|
-
errors:
|
|
3230
|
-
pending:
|
|
3231
|
-
valid:
|
|
3232
|
-
invalid:
|
|
3233
|
-
touched:
|
|
3234
|
-
dirty:
|
|
2877
|
+
value: r.value,
|
|
2878
|
+
length: r.length,
|
|
2879
|
+
errors: r.errors,
|
|
2880
|
+
pending: r.pending,
|
|
2881
|
+
valid: r.valid,
|
|
2882
|
+
invalid: r.invalid,
|
|
2883
|
+
touched: r.touched,
|
|
2884
|
+
dirty: r.dirty,
|
|
2885
|
+
disabled: r.disabled
|
|
3235
2886
|
}, t = [
|
|
3236
2887
|
{ key: "value" },
|
|
3237
2888
|
{ key: "length" },
|
|
@@ -3240,24 +2891,26 @@ function Ge(i) {
|
|
|
3240
2891
|
{ key: "valid" },
|
|
3241
2892
|
{ key: "invalid" },
|
|
3242
2893
|
{ key: "touched" },
|
|
3243
|
-
{ key: "dirty" }
|
|
2894
|
+
{ key: "dirty" },
|
|
2895
|
+
{ key: "disabled" }
|
|
3244
2896
|
], s = E(
|
|
3245
|
-
(
|
|
3246
|
-
value:
|
|
3247
|
-
length:
|
|
3248
|
-
pending:
|
|
3249
|
-
errors:
|
|
3250
|
-
valid:
|
|
3251
|
-
invalid:
|
|
3252
|
-
touched:
|
|
3253
|
-
dirty:
|
|
2897
|
+
(i) => ({
|
|
2898
|
+
value: i.value,
|
|
2899
|
+
length: i.length,
|
|
2900
|
+
pending: i.pending,
|
|
2901
|
+
errors: i.errors,
|
|
2902
|
+
valid: i.valid,
|
|
2903
|
+
invalid: i.invalid,
|
|
2904
|
+
touched: i.touched,
|
|
2905
|
+
dirty: i.dirty,
|
|
2906
|
+
disabled: i.disabled
|
|
3254
2907
|
}),
|
|
3255
2908
|
[]
|
|
3256
2909
|
);
|
|
3257
|
-
return
|
|
2910
|
+
return j(e, t, s, r);
|
|
3258
2911
|
}
|
|
3259
|
-
function
|
|
3260
|
-
const
|
|
2912
|
+
function Oe() {
|
|
2913
|
+
const r = E(
|
|
3261
2914
|
() => ({
|
|
3262
2915
|
value: [],
|
|
3263
2916
|
length: 0,
|
|
@@ -3266,96 +2919,98 @@ function Ue() {
|
|
|
3266
2919
|
valid: !0,
|
|
3267
2920
|
invalid: !1,
|
|
3268
2921
|
touched: !1,
|
|
3269
|
-
dirty: !1
|
|
2922
|
+
dirty: !1,
|
|
2923
|
+
disabled: !1
|
|
3270
2924
|
}),
|
|
3271
2925
|
[]
|
|
3272
2926
|
);
|
|
3273
|
-
return
|
|
2927
|
+
return j({}, [], r);
|
|
3274
2928
|
}
|
|
3275
|
-
function
|
|
3276
|
-
const e =
|
|
3277
|
-
return
|
|
2929
|
+
function Le(r) {
|
|
2930
|
+
const e = r && "length" in r && "map" in r;
|
|
2931
|
+
return r ? e ? ke(r) : Ve(r) : Oe();
|
|
3278
2932
|
}
|
|
3279
|
-
function
|
|
3280
|
-
const e =
|
|
3281
|
-
(
|
|
2933
|
+
function Re(r) {
|
|
2934
|
+
const e = N({ value: r.value.value }), t = E(
|
|
2935
|
+
(i) => {
|
|
3282
2936
|
let n = !0;
|
|
3283
|
-
return
|
|
3284
|
-
if (
|
|
2937
|
+
return b(() => {
|
|
2938
|
+
if (r.value.value, n) {
|
|
3285
2939
|
n = !1;
|
|
3286
2940
|
return;
|
|
3287
2941
|
}
|
|
3288
|
-
|
|
2942
|
+
i();
|
|
3289
2943
|
});
|
|
3290
2944
|
},
|
|
3291
|
-
[
|
|
2945
|
+
[r]
|
|
3292
2946
|
), s = E(() => {
|
|
3293
|
-
const
|
|
3294
|
-
return e.current.value ===
|
|
3295
|
-
}, [
|
|
3296
|
-
return
|
|
2947
|
+
const i = r.value.value;
|
|
2948
|
+
return e.current.value === i ? e.current.value : (e.current.value = i, i);
|
|
2949
|
+
}, [r]);
|
|
2950
|
+
return $.useSyncExternalStore(t, s, s);
|
|
3297
2951
|
}
|
|
3298
|
-
function
|
|
3299
|
-
const e =
|
|
3300
|
-
(
|
|
2952
|
+
function Be(r) {
|
|
2953
|
+
const e = N({ length: r.length.value }), t = E(
|
|
2954
|
+
(i) => {
|
|
3301
2955
|
let n = !0;
|
|
3302
|
-
return
|
|
3303
|
-
if (
|
|
2956
|
+
return b(() => {
|
|
2957
|
+
if (r.length.value, n) {
|
|
3304
2958
|
n = !1;
|
|
3305
2959
|
return;
|
|
3306
2960
|
}
|
|
3307
|
-
|
|
2961
|
+
i();
|
|
3308
2962
|
});
|
|
3309
2963
|
},
|
|
3310
|
-
[
|
|
2964
|
+
[r]
|
|
3311
2965
|
), s = E(() => {
|
|
3312
|
-
const
|
|
3313
|
-
return e.current.length ===
|
|
3314
|
-
}, [
|
|
3315
|
-
return
|
|
2966
|
+
const i = r.length.value;
|
|
2967
|
+
return e.current.length === i ? e.current.length : (e.current.length = i, i);
|
|
2968
|
+
}, [r]);
|
|
2969
|
+
return $.useSyncExternalStore(t, s, s);
|
|
3316
2970
|
}
|
|
3317
2971
|
export {
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
2972
|
+
H as ArrayNode,
|
|
2973
|
+
A as ErrorStrategy,
|
|
2974
|
+
le as FieldNode,
|
|
3321
2975
|
O as FormErrorHandler,
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
2976
|
+
C as FormNode,
|
|
2977
|
+
oe as FormStatusMachine,
|
|
2978
|
+
de as FormSubmitter,
|
|
2979
|
+
S as GroupNode,
|
|
2980
|
+
fe as ModelArrayNode,
|
|
2981
|
+
he as NodeFactory,
|
|
2982
|
+
I as SubscriptionManager,
|
|
2983
|
+
We as computeFrom,
|
|
2984
|
+
qe as copyFrom,
|
|
2985
|
+
De as createForm,
|
|
2986
|
+
re as createFormFromModel,
|
|
2987
|
+
Ge as createModel,
|
|
2988
|
+
nt as disableWhen,
|
|
2989
|
+
at as enableWhen,
|
|
2990
|
+
U as getNodeForSignal,
|
|
2991
|
+
Ie as getNodeType,
|
|
2992
|
+
be as isArrayNode,
|
|
2993
|
+
G as isDerived,
|
|
2994
|
+
ge as isFieldNode,
|
|
2995
|
+
x as isFormNode,
|
|
2996
|
+
_e as isGroupNode,
|
|
2997
|
+
He as markDerived,
|
|
2998
|
+
ne as registerSignalNode,
|
|
2999
|
+
Ke as resetWhen,
|
|
3000
|
+
Je as revalidateWhen,
|
|
3001
|
+
Ye as runOutsideEffect,
|
|
3002
|
+
ze as safeCallback,
|
|
3003
|
+
Qe as safeDebouncedCallback,
|
|
3004
|
+
Xe as syncFields,
|
|
3005
|
+
Ze as transformValue,
|
|
3352
3006
|
V as uniqueId,
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3007
|
+
et as unmarkDerived,
|
|
3008
|
+
Be as useArrayLength,
|
|
3009
|
+
Le as useFormControl,
|
|
3010
|
+
Re as useFormControlValue,
|
|
3011
|
+
me as validateFormModel,
|
|
3012
|
+
Te as validateModel,
|
|
3013
|
+
Pe as validateModelSync,
|
|
3014
|
+
rt as validators,
|
|
3015
|
+
tt as watchField
|
|
3361
3016
|
};
|