@reformer/core 9.0.0-beta.2 → 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/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 +29 -28
- 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/{hooks → form/hooks}/types.d.ts +1 -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/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 +2 -2
- package/dist/{core → form}/nodes/model-array-node.d.ts +2 -2
- 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/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 +1 -1
- 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/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 +663 -1016
- package/dist/{core/model/behaviors.d.ts → state/behaviors-value.d.ts} +0 -53
- package/dist/state/form-model.d.ts +26 -0
- package/dist/state/index.d.ts +31 -0
- package/dist/{core/utils → state}/safe-effect.d.ts +4 -4
- 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/phone.d.ts +1 -1
- package/dist/validators/required.d.ts +1 -1
- package/dist/validators/url.d.ts +1 -1
- package/dist/validators.d.ts +6 -6
- package/llms.txt +161 -147
- package/package.json +5 -1
- package/dist/behaviors-Br4Im38V.js +0 -263
- 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 → form}/factories/index.d.ts +0 -0
- /package/dist/{core/utils → form}/form-submitter.d.ts +0 -0
- /package/dist/{hooks → form/hooks}/useSignalSubscription.d.ts +0 -0
- /package/dist/{core → form}/types/deep-schema.d.ts +0 -0
- /package/dist/{core → form}/types/form-proxy.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/required.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/url.d.ts +0 -0
- /package/dist/{core/utils → state}/derived-registry.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 L {
|
|
|
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
|
// ============================================================================
|
|
@@ -97,17 +101,17 @@ class L {
|
|
|
97
101
|
*/
|
|
98
102
|
getErrors(e) {
|
|
99
103
|
const t = this.errors.value;
|
|
100
|
-
return e ? t.filter((
|
|
101
|
-
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(
|
|
104
|
+
return e ? t.filter((s) => {
|
|
105
|
+
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(s.code) || e.message !== void 0 && !s.message.toLowerCase().includes(e.message.toLowerCase()))
|
|
102
106
|
return !1;
|
|
103
107
|
if (e.params !== void 0) {
|
|
104
|
-
if (!
|
|
108
|
+
if (!s.params)
|
|
105
109
|
return !1;
|
|
106
|
-
for (const [
|
|
107
|
-
if (
|
|
110
|
+
for (const [i, n] of Object.entries(e.params))
|
|
111
|
+
if (s.params[i] !== n)
|
|
108
112
|
return !1;
|
|
109
113
|
}
|
|
110
|
-
return !(e.predicate !== void 0 && !e.predicate(
|
|
114
|
+
return !(e.predicate !== void 0 && !e.predicate(s));
|
|
111
115
|
}) : t;
|
|
112
116
|
}
|
|
113
117
|
// ============================================================================
|
|
@@ -280,193 +284,119 @@ class L {
|
|
|
280
284
|
onEnable() {
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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);
|
|
287
|
+
const w = {
|
|
288
|
+
/** FieldNode.watch() */
|
|
289
|
+
Watch: "watch",
|
|
290
|
+
/** FieldNode.computeFrom() */
|
|
291
|
+
ComputeFrom: "computeFrom",
|
|
292
|
+
/** GroupNode.linkFields() */
|
|
293
|
+
LinkFields: "linkFields",
|
|
294
|
+
/** GroupNode.watchField() */
|
|
295
|
+
WatchField: "watchField",
|
|
296
|
+
/** ArrayNode.watchItems() */
|
|
297
|
+
WatchItems: "watchItems",
|
|
298
|
+
/** ArrayNode.watchLength() */
|
|
299
|
+
WatchLength: "watchLength"
|
|
300
|
+
};
|
|
301
|
+
let ae = 0;
|
|
302
|
+
function V(r) {
|
|
303
|
+
return `${r}-${++ae}`;
|
|
304
|
+
}
|
|
305
|
+
var A = /* @__PURE__ */ ((r) => (r.THROW = "throw", r.LOG = "log", r.CONVERT = "convert", r))(A || {});
|
|
306
|
+
class O {
|
|
307
|
+
static handle(e, t, s = "throw") {
|
|
308
|
+
const i = this.extractMessage(e);
|
|
309
|
+
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), s) {
|
|
310
|
+
case "throw":
|
|
311
|
+
throw e;
|
|
312
|
+
case "log":
|
|
313
|
+
return;
|
|
314
|
+
case "convert":
|
|
315
|
+
return {
|
|
316
|
+
code: "validator_error",
|
|
317
|
+
message: i,
|
|
318
|
+
params: { field: t }
|
|
319
|
+
};
|
|
320
|
+
}
|
|
320
321
|
}
|
|
321
322
|
/**
|
|
322
|
-
*
|
|
323
|
+
* Извлечь сообщение из ошибки
|
|
323
324
|
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
325
|
+
* Обрабатывает различные типы ошибок:
|
|
326
|
+
* - Error объекты → error.message
|
|
327
|
+
* - Строки → возвращает как есть
|
|
328
|
+
* - Объекты с message → извлекает message
|
|
329
|
+
* - Другое → String(error)
|
|
326
330
|
*
|
|
327
|
-
* @param
|
|
328
|
-
* @returns
|
|
331
|
+
* @param error Ошибка для извлечения сообщения
|
|
332
|
+
* @returns Сообщение ошибки
|
|
333
|
+
* @private
|
|
329
334
|
*
|
|
330
335
|
* @example
|
|
331
336
|
* ```typescript
|
|
332
|
-
*
|
|
333
|
-
*
|
|
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
|
-
* Очищает все подписки
|
|
337
|
+
* FormErrorHandler.extractMessage(new Error('Test'));
|
|
338
|
+
* // 'Test'
|
|
348
339
|
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
340
|
+
* FormErrorHandler.extractMessage('String error');
|
|
341
|
+
* // 'String error'
|
|
351
342
|
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* class FieldNode {
|
|
355
|
-
* private subscriptions = new SubscriptionManager();
|
|
343
|
+
* FormErrorHandler.extractMessage({ message: 'Object error' });
|
|
344
|
+
* // 'Object error'
|
|
356
345
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* this.subscriptions.clear();
|
|
360
|
-
* }
|
|
361
|
-
* }
|
|
346
|
+
* FormErrorHandler.extractMessage(null);
|
|
347
|
+
* // 'null'
|
|
362
348
|
* ```
|
|
363
349
|
*/
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
e();
|
|
367
|
-
}), this.subscriptions.clear();
|
|
350
|
+
static extractMessage(e) {
|
|
351
|
+
return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e ? String(e.message) : String(e);
|
|
368
352
|
}
|
|
369
353
|
/**
|
|
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
|
|
354
|
+
* Создать ValidationError с заданными параметрами
|
|
386
355
|
*
|
|
387
|
-
*
|
|
388
|
-
* console.log(manager.size()); // 0
|
|
389
|
-
* ```
|
|
390
|
-
*/
|
|
391
|
-
size() {
|
|
392
|
-
return this.subscriptions.size;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Проверяет, есть ли подписка с данным ключом
|
|
356
|
+
* Утилитная функция для создания ValidationError объектов
|
|
396
357
|
*
|
|
397
|
-
* @param
|
|
398
|
-
* @
|
|
358
|
+
* @param code Код ошибки
|
|
359
|
+
* @param message Сообщение ошибки
|
|
360
|
+
* @param field Поле (опционально)
|
|
361
|
+
* @returns ValidationError объект
|
|
399
362
|
*
|
|
400
363
|
* @example
|
|
401
364
|
* ```typescript
|
|
402
|
-
* const
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
365
|
+
* const error = FormErrorHandler.createValidationError(
|
|
366
|
+
* 'required',
|
|
367
|
+
* 'This field is required',
|
|
368
|
+
* 'email'
|
|
369
|
+
* );
|
|
370
|
+
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
407
371
|
* ```
|
|
408
372
|
*/
|
|
409
|
-
|
|
410
|
-
return
|
|
373
|
+
static createValidationError(e, t, s) {
|
|
374
|
+
return {
|
|
375
|
+
code: e,
|
|
376
|
+
message: t,
|
|
377
|
+
params: s ? { field: s } : void 0
|
|
378
|
+
};
|
|
411
379
|
}
|
|
412
380
|
/**
|
|
413
|
-
*
|
|
381
|
+
* Проверить, является ли объект ValidationError
|
|
414
382
|
*
|
|
415
|
-
*
|
|
383
|
+
* Type guard для ValidationError
|
|
416
384
|
*
|
|
417
|
-
* @
|
|
385
|
+
* @param value Значение для проверки
|
|
386
|
+
* @returns true если value является ValidationError
|
|
418
387
|
*
|
|
419
388
|
* @example
|
|
420
389
|
* ```typescript
|
|
421
|
-
*
|
|
422
|
-
*
|
|
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
|
-
* }
|
|
390
|
+
* if (FormErrorHandler.isValidationError(result)) {
|
|
391
|
+
* console.log(result.code); // OK, типобезопасно
|
|
444
392
|
* }
|
|
445
393
|
* ```
|
|
446
394
|
*/
|
|
447
|
-
|
|
448
|
-
|
|
395
|
+
static isValidationError(e) {
|
|
396
|
+
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
449
397
|
}
|
|
450
398
|
}
|
|
451
|
-
|
|
452
|
-
/** FieldNode.watch() */
|
|
453
|
-
Watch: "watch",
|
|
454
|
-
/** FieldNode.computeFrom() */
|
|
455
|
-
ComputeFrom: "computeFrom",
|
|
456
|
-
/** GroupNode.linkFields() */
|
|
457
|
-
LinkFields: "linkFields",
|
|
458
|
-
/** GroupNode.watchField() */
|
|
459
|
-
WatchField: "watchField",
|
|
460
|
-
/** ArrayNode.watchItems() */
|
|
461
|
-
WatchItems: "watchItems",
|
|
462
|
-
/** ArrayNode.watchLength() */
|
|
463
|
-
WatchLength: "watchLength"
|
|
464
|
-
};
|
|
465
|
-
let Ee = 0;
|
|
466
|
-
function k(s) {
|
|
467
|
-
return `${s}-${++Ee}`;
|
|
468
|
-
}
|
|
469
|
-
class Ae {
|
|
399
|
+
class oe {
|
|
470
400
|
/** Внутренний сигнал статуса */
|
|
471
401
|
_status;
|
|
472
402
|
/** Публичный read-only сигнал статуса */
|
|
@@ -483,7 +413,7 @@ class Ae {
|
|
|
483
413
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
484
414
|
*/
|
|
485
415
|
constructor(e = "valid") {
|
|
486
|
-
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");
|
|
487
417
|
}
|
|
488
418
|
/**
|
|
489
419
|
* Начать валидацию
|
|
@@ -611,7 +541,7 @@ class Ae {
|
|
|
611
541
|
return this._status.value !== "disabled";
|
|
612
542
|
}
|
|
613
543
|
}
|
|
614
|
-
class
|
|
544
|
+
class le extends C {
|
|
615
545
|
// ============================================================================
|
|
616
546
|
// Приватные сигналы
|
|
617
547
|
// ============================================================================
|
|
@@ -663,13 +593,13 @@ class Se extends L {
|
|
|
663
593
|
* Менеджер подписок для централизованного cleanup
|
|
664
594
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
665
595
|
*/
|
|
666
|
-
disposers = new
|
|
596
|
+
disposers = new I();
|
|
667
597
|
component;
|
|
668
598
|
// ============================================================================
|
|
669
599
|
// Конструктор
|
|
670
600
|
// ============================================================================
|
|
671
601
|
constructor(e) {
|
|
672
|
-
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(
|
|
673
603
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
674
604
|
);
|
|
675
605
|
}
|
|
@@ -682,12 +612,12 @@ class Se extends L {
|
|
|
682
612
|
setValue(e, t) {
|
|
683
613
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
684
614
|
return;
|
|
685
|
-
const
|
|
615
|
+
const s = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
686
616
|
if (this.updateOn === "change") {
|
|
687
617
|
this.validate();
|
|
688
618
|
return;
|
|
689
619
|
}
|
|
690
|
-
|
|
620
|
+
i && s && this.validate();
|
|
691
621
|
}
|
|
692
622
|
patchValue(e) {
|
|
693
623
|
this.setValue(e);
|
|
@@ -780,20 +710,20 @@ class Se extends L {
|
|
|
780
710
|
const t = e?.debounce ?? this.debounceMs;
|
|
781
711
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
782
712
|
return this.validateImmediate();
|
|
783
|
-
const
|
|
784
|
-
return new Promise((
|
|
785
|
-
this.pendingValidation = { resolve:
|
|
786
|
-
if (this.validateDebounceTimer = void 0,
|
|
787
|
-
|
|
713
|
+
const s = new AbortController();
|
|
714
|
+
return new Promise((i) => {
|
|
715
|
+
this.pendingValidation = { resolve: i, abortController: s }, this.validateDebounceTimer = setTimeout(async () => {
|
|
716
|
+
if (this.validateDebounceTimer = void 0, s.signal.aborted) {
|
|
717
|
+
i(!1);
|
|
788
718
|
return;
|
|
789
719
|
}
|
|
790
720
|
this.pendingValidation = void 0;
|
|
791
|
-
const n = await this.validateImmediate(
|
|
792
|
-
|
|
793
|
-
}, t),
|
|
721
|
+
const n = await this.validateImmediate(s);
|
|
722
|
+
i(n);
|
|
723
|
+
}, t), s.signal.addEventListener(
|
|
794
724
|
"abort",
|
|
795
725
|
() => {
|
|
796
|
-
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0),
|
|
726
|
+
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), i(!1);
|
|
797
727
|
},
|
|
798
728
|
{ once: !0 }
|
|
799
729
|
);
|
|
@@ -812,51 +742,51 @@ class Se extends L {
|
|
|
812
742
|
async validateImmediate(e) {
|
|
813
743
|
const t = e ?? new AbortController();
|
|
814
744
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
815
|
-
const { signal:
|
|
745
|
+
const { signal: s } = t, i = [];
|
|
816
746
|
for (const a of this.validators) {
|
|
817
747
|
const l = a(this._value.value);
|
|
818
|
-
l &&
|
|
748
|
+
l && i.push(l);
|
|
819
749
|
}
|
|
820
|
-
if (
|
|
750
|
+
if (s.aborted)
|
|
821
751
|
return !1;
|
|
822
|
-
if (
|
|
823
|
-
this._errors.value =
|
|
824
|
-
const a =
|
|
752
|
+
if (i.length > 0) {
|
|
753
|
+
this._errors.value = i;
|
|
754
|
+
const a = i.some((l) => l.severity !== "warning");
|
|
825
755
|
if (this.statusMachine.setErrors(a), a)
|
|
826
756
|
return !1;
|
|
827
757
|
}
|
|
828
758
|
if (this.asyncValidators.length > 0) {
|
|
829
|
-
if (
|
|
759
|
+
if (s.aborted)
|
|
830
760
|
return !1;
|
|
831
761
|
this.statusMachine.startValidation();
|
|
832
762
|
try {
|
|
833
763
|
const a = await Promise.all(
|
|
834
|
-
this.asyncValidators.map(async (
|
|
835
|
-
if (
|
|
764
|
+
this.asyncValidators.map(async (d) => {
|
|
765
|
+
if (s.aborted)
|
|
836
766
|
throw new DOMException("Validation aborted", "AbortError");
|
|
837
767
|
try {
|
|
838
|
-
const u = await
|
|
839
|
-
if (
|
|
768
|
+
const u = await d(this._value.value, { signal: s });
|
|
769
|
+
if (s.aborted)
|
|
840
770
|
throw new DOMException("Validation aborted", "AbortError");
|
|
841
771
|
return u;
|
|
842
772
|
} catch (u) {
|
|
843
773
|
if (u instanceof DOMException && u.name === "AbortError")
|
|
844
774
|
throw u;
|
|
845
|
-
return
|
|
775
|
+
return O.handle(
|
|
846
776
|
u,
|
|
847
777
|
"FieldNode AsyncValidator",
|
|
848
|
-
|
|
778
|
+
A.CONVERT
|
|
849
779
|
);
|
|
850
780
|
}
|
|
851
781
|
})
|
|
852
782
|
);
|
|
853
|
-
if (
|
|
783
|
+
if (s.aborted)
|
|
854
784
|
return !1;
|
|
855
|
-
const l = a.filter((
|
|
785
|
+
const l = a.filter((d) => d !== null);
|
|
856
786
|
if (l.length > 0) {
|
|
857
787
|
this._errors.value = l;
|
|
858
|
-
const
|
|
859
|
-
if (this.statusMachine.completeValidation(
|
|
788
|
+
const d = l.some((u) => u.severity !== "warning");
|
|
789
|
+
if (this.statusMachine.completeValidation(d), d)
|
|
860
790
|
return !1;
|
|
861
791
|
}
|
|
862
792
|
} catch (a) {
|
|
@@ -865,11 +795,11 @@ class Se extends L {
|
|
|
865
795
|
throw a;
|
|
866
796
|
}
|
|
867
797
|
}
|
|
868
|
-
return
|
|
798
|
+
return s.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
|
|
869
799
|
}
|
|
870
800
|
setErrors(e) {
|
|
871
801
|
this._errors.value = e;
|
|
872
|
-
const t = e.some((
|
|
802
|
+
const t = e.some((s) => s.severity !== "warning");
|
|
873
803
|
this.statusMachine.setErrors(t);
|
|
874
804
|
}
|
|
875
805
|
clearErrors() {
|
|
@@ -986,12 +916,12 @@ class Se extends L {
|
|
|
986
916
|
* ```
|
|
987
917
|
*/
|
|
988
918
|
watch(e) {
|
|
989
|
-
const t = new AbortController(),
|
|
919
|
+
const t = new AbortController(), s = b(() => {
|
|
990
920
|
const n = this.value.value;
|
|
991
921
|
e(n, t.signal);
|
|
992
|
-
}),
|
|
993
|
-
return this.disposers.add(
|
|
994
|
-
t.abort(),
|
|
922
|
+
}), i = V(w.Watch);
|
|
923
|
+
return this.disposers.add(i, () => {
|
|
924
|
+
t.abort(), s();
|
|
995
925
|
});
|
|
996
926
|
}
|
|
997
927
|
/**
|
|
@@ -1017,11 +947,11 @@ class Se extends L {
|
|
|
1017
947
|
* ```
|
|
1018
948
|
*/
|
|
1019
949
|
computeFrom(e, t) {
|
|
1020
|
-
const
|
|
950
|
+
const s = b(() => {
|
|
1021
951
|
const n = e.map((l) => l.value), a = t(...n);
|
|
1022
952
|
this.setValue(a, { emitEvent: !1 });
|
|
1023
|
-
}),
|
|
1024
|
-
return this.disposers.add(
|
|
953
|
+
}), i = V(w.ComputeFrom);
|
|
954
|
+
return this.disposers.add(i, s);
|
|
1025
955
|
}
|
|
1026
956
|
/**
|
|
1027
957
|
* Очистить все ресурсы и таймеры
|
|
@@ -1051,59 +981,59 @@ class Se extends L {
|
|
|
1051
981
|
}
|
|
1052
982
|
}
|
|
1053
983
|
}
|
|
1054
|
-
function
|
|
1055
|
-
const { getChildren: e, ownErrors: t, disabled:
|
|
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(() => {
|
|
1056
986
|
const o = [...t.value];
|
|
1057
|
-
for (const
|
|
1058
|
-
o.push(...
|
|
987
|
+
for (const p of e())
|
|
988
|
+
o.push(...p.errors.value);
|
|
1059
989
|
return o;
|
|
1060
|
-
}),
|
|
990
|
+
}), h = f(() => s?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
1061
991
|
return {
|
|
1062
|
-
valid:
|
|
992
|
+
valid: i,
|
|
1063
993
|
invalid: n,
|
|
1064
994
|
pending: a,
|
|
1065
995
|
touched: l,
|
|
1066
|
-
dirty:
|
|
996
|
+
dirty: d,
|
|
1067
997
|
errors: u,
|
|
1068
|
-
status:
|
|
998
|
+
status: h
|
|
1069
999
|
};
|
|
1070
1000
|
}
|
|
1071
|
-
function
|
|
1072
|
-
return typeof
|
|
1001
|
+
function W(r) {
|
|
1002
|
+
return typeof r == "object" && r !== null && "getProxy" in r && typeof r.getProxy == "function";
|
|
1073
1003
|
}
|
|
1074
|
-
const
|
|
1075
|
-
function
|
|
1004
|
+
const q = "$";
|
|
1005
|
+
function ue(r, e) {
|
|
1076
1006
|
let t;
|
|
1077
|
-
const
|
|
1007
|
+
const s = () => {
|
|
1078
1008
|
if (!t) {
|
|
1079
|
-
const
|
|
1009
|
+
const i = {};
|
|
1080
1010
|
e.forEach((n, a) => {
|
|
1081
|
-
|
|
1082
|
-
}), t =
|
|
1011
|
+
i[a] = n && W(n) ? n.getProxy() : n;
|
|
1012
|
+
}), t = i;
|
|
1083
1013
|
}
|
|
1084
1014
|
return t;
|
|
1085
1015
|
};
|
|
1086
|
-
return new Proxy(
|
|
1087
|
-
get: (
|
|
1088
|
-
if (n ===
|
|
1089
|
-
return
|
|
1090
|
-
if (n in
|
|
1091
|
-
return
|
|
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];
|
|
1092
1022
|
if (typeof n == "string" && e.has(n)) {
|
|
1093
1023
|
const a = e.get(n);
|
|
1094
|
-
return a &&
|
|
1024
|
+
return a && W(a) ? a.getProxy() : a;
|
|
1095
1025
|
}
|
|
1096
1026
|
},
|
|
1097
|
-
set: (
|
|
1098
|
-
has: (
|
|
1099
|
-
ownKeys: (
|
|
1100
|
-
const n = Reflect.ownKeys(
|
|
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());
|
|
1101
1031
|
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
1102
1032
|
},
|
|
1103
|
-
getOwnPropertyDescriptor: (
|
|
1033
|
+
getOwnPropertyDescriptor: (i, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, n)
|
|
1104
1034
|
});
|
|
1105
1035
|
}
|
|
1106
|
-
class
|
|
1036
|
+
class de {
|
|
1107
1037
|
/**
|
|
1108
1038
|
* @param form - Форма для отправки
|
|
1109
1039
|
*/
|
|
@@ -1111,7 +1041,7 @@ class ke {
|
|
|
1111
1041
|
this.form = e;
|
|
1112
1042
|
}
|
|
1113
1043
|
/** Внутренний сигнал состояния отправки */
|
|
1114
|
-
_submitting =
|
|
1044
|
+
_submitting = g(!1);
|
|
1115
1045
|
/** Публичный read-only сигнал состояния отправки */
|
|
1116
1046
|
submitting = f(() => this._submitting.value);
|
|
1117
1047
|
/**
|
|
@@ -1148,8 +1078,8 @@ class ke {
|
|
|
1148
1078
|
* ```
|
|
1149
1079
|
*/
|
|
1150
1080
|
async submit(e, t) {
|
|
1151
|
-
const { skipValidation:
|
|
1152
|
-
if (
|
|
1081
|
+
const { skipValidation: s = !1, skipTouch: i = !1 } = t || {};
|
|
1082
|
+
if (i || this.form.markAsTouched(), !s && !await this.form.validate())
|
|
1153
1083
|
return null;
|
|
1154
1084
|
this._submitting.value = !0;
|
|
1155
1085
|
try {
|
|
@@ -1183,8 +1113,8 @@ class ke {
|
|
|
1183
1113
|
* ```
|
|
1184
1114
|
*/
|
|
1185
1115
|
async submitWithResult(e, t) {
|
|
1186
|
-
const { skipValidation:
|
|
1187
|
-
if (
|
|
1116
|
+
const { skipValidation: s = !1, skipTouch: i = !1 } = t || {};
|
|
1117
|
+
if (i || this.form.markAsTouched(), !s && !await this.form.validate())
|
|
1188
1118
|
return { success: !1, data: null };
|
|
1189
1119
|
this._submitting.value = !0;
|
|
1190
1120
|
try {
|
|
@@ -1206,16 +1136,16 @@ class ke {
|
|
|
1206
1136
|
return this._submitting.value;
|
|
1207
1137
|
}
|
|
1208
1138
|
}
|
|
1209
|
-
function
|
|
1139
|
+
function ce(r) {
|
|
1210
1140
|
const e = [];
|
|
1211
|
-
for (const t of
|
|
1212
|
-
const
|
|
1213
|
-
if (!
|
|
1214
|
-
e.push(
|
|
1141
|
+
for (const t of r.split(".")) {
|
|
1142
|
+
const s = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1143
|
+
if (!s) return [];
|
|
1144
|
+
e.push(s[2] !== void 0 ? { key: s[1], index: Number(s[2]) } : { key: s[1] });
|
|
1215
1145
|
}
|
|
1216
1146
|
return e;
|
|
1217
1147
|
}
|
|
1218
|
-
|
|
1148
|
+
class S extends C {
|
|
1219
1149
|
// ============================================================================
|
|
1220
1150
|
// Приватные поля
|
|
1221
1151
|
// ============================================================================
|
|
@@ -1228,7 +1158,7 @@ let P = class ue extends L {
|
|
|
1228
1158
|
/**
|
|
1229
1159
|
* Менеджер подписок для централизованного cleanup
|
|
1230
1160
|
*/
|
|
1231
|
-
disposers = new
|
|
1161
|
+
disposers = new I();
|
|
1232
1162
|
/**
|
|
1233
1163
|
* Ссылка на Proxy-инстанс
|
|
1234
1164
|
*/
|
|
@@ -1240,7 +1170,7 @@ let P = class ue extends L {
|
|
|
1240
1170
|
/**
|
|
1241
1171
|
* Фабрика для создания узлов формы
|
|
1242
1172
|
*/
|
|
1243
|
-
nodeFactory = new
|
|
1173
|
+
nodeFactory = new he();
|
|
1244
1174
|
// ============================================================================
|
|
1245
1175
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1246
1176
|
// ============================================================================
|
|
@@ -1248,9 +1178,9 @@ let P = class ue extends L {
|
|
|
1248
1178
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1249
1179
|
formSubmitter;
|
|
1250
1180
|
/** Флаг disabled состояния */
|
|
1251
|
-
_disabled =
|
|
1181
|
+
_disabled = g(!1);
|
|
1252
1182
|
/** Form-level validation errors */
|
|
1253
|
-
_formErrors =
|
|
1183
|
+
_formErrors = g([]);
|
|
1254
1184
|
/**
|
|
1255
1185
|
* M1: валидация уровня модели/схемы (`validateFormModel(model, schema)`). Привязывается
|
|
1256
1186
|
* `createForm({ model, schema })`, т.к. под M1 валидаторы срезаны с FieldNode и живут на слое
|
|
@@ -1277,19 +1207,19 @@ let P = class ue extends L {
|
|
|
1277
1207
|
status;
|
|
1278
1208
|
submitting;
|
|
1279
1209
|
constructor(e) {
|
|
1280
|
-
super(), this.formSubmitter = new
|
|
1281
|
-
const t = e.form,
|
|
1282
|
-
for (const [l,
|
|
1283
|
-
const u = this.createNode(
|
|
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);
|
|
1284
1214
|
this._fields.set(l, u);
|
|
1285
1215
|
}
|
|
1286
1216
|
this.value = f(() => {
|
|
1287
1217
|
const l = {};
|
|
1288
|
-
return this._fields.forEach((
|
|
1289
|
-
l[u] =
|
|
1218
|
+
return this._fields.forEach((d, u) => {
|
|
1219
|
+
l[u] = d.value.value;
|
|
1290
1220
|
}), l;
|
|
1291
1221
|
});
|
|
1292
|
-
const a =
|
|
1222
|
+
const a = L({
|
|
1293
1223
|
getChildren: () => Array.from(this._fields.values()),
|
|
1294
1224
|
ownErrors: this._formErrors,
|
|
1295
1225
|
disabled: this._disabled
|
|
@@ -1304,35 +1234,35 @@ let P = class ue extends L {
|
|
|
1304
1234
|
* @see buildFormProxy
|
|
1305
1235
|
*/
|
|
1306
1236
|
buildProxy() {
|
|
1307
|
-
return
|
|
1237
|
+
return ue(this, this._fields);
|
|
1308
1238
|
}
|
|
1309
1239
|
// ============================================================================
|
|
1310
1240
|
// Реализация абстрактных методов FormNode
|
|
1311
1241
|
// ============================================================================
|
|
1312
1242
|
getValue() {
|
|
1313
1243
|
const e = {};
|
|
1314
|
-
return this._fields.forEach((t,
|
|
1315
|
-
e[
|
|
1244
|
+
return this._fields.forEach((t, s) => {
|
|
1245
|
+
e[s] = t.getValue();
|
|
1316
1246
|
}), e;
|
|
1317
1247
|
}
|
|
1318
1248
|
setValue(e, t) {
|
|
1319
|
-
for (const [
|
|
1320
|
-
const n = this._fields.get(
|
|
1249
|
+
for (const [s, i] of Object.entries(e)) {
|
|
1250
|
+
const n = this._fields.get(s);
|
|
1321
1251
|
if (n) {
|
|
1322
1252
|
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1323
1253
|
if (G(a)) continue;
|
|
1324
|
-
n.setValue(
|
|
1254
|
+
n.setValue(i, t);
|
|
1325
1255
|
}
|
|
1326
1256
|
}
|
|
1327
1257
|
}
|
|
1328
1258
|
patchValue(e) {
|
|
1329
|
-
|
|
1330
|
-
for (const [t,
|
|
1331
|
-
const
|
|
1332
|
-
if (
|
|
1333
|
-
const n = this._fieldSignals.get(
|
|
1259
|
+
ie(() => {
|
|
1260
|
+
for (const [t, s] of Object.entries(e)) {
|
|
1261
|
+
const i = this._fields.get(t);
|
|
1262
|
+
if (i && s !== void 0) {
|
|
1263
|
+
const n = this._fieldSignals.get(i) ?? i.value;
|
|
1334
1264
|
if (G(n)) continue;
|
|
1335
|
-
|
|
1265
|
+
i.setValue(s, { emitEvent: !1 });
|
|
1336
1266
|
}
|
|
1337
1267
|
}
|
|
1338
1268
|
});
|
|
@@ -1355,9 +1285,9 @@ let P = class ue extends L {
|
|
|
1355
1285
|
* ```
|
|
1356
1286
|
*/
|
|
1357
1287
|
reset(e) {
|
|
1358
|
-
this._formErrors.value = [], this._fields.forEach((t,
|
|
1359
|
-
const
|
|
1360
|
-
t.reset(
|
|
1288
|
+
this._formErrors.value = [], this._fields.forEach((t, s) => {
|
|
1289
|
+
const i = e?.[s];
|
|
1290
|
+
t.reset(i);
|
|
1361
1291
|
});
|
|
1362
1292
|
}
|
|
1363
1293
|
/**
|
|
@@ -1369,9 +1299,9 @@ let P = class ue extends L {
|
|
|
1369
1299
|
});
|
|
1370
1300
|
}
|
|
1371
1301
|
async validate() {
|
|
1372
|
-
this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((
|
|
1302
|
+
this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((s) => s.validate()));
|
|
1373
1303
|
const e = this._modelValidate ? await this._modelValidate() : !0, t = Array.from(this._fields.values()).every(
|
|
1374
|
-
(
|
|
1304
|
+
(s) => s.valid.value || s.disabled.value
|
|
1375
1305
|
);
|
|
1376
1306
|
return e && t;
|
|
1377
1307
|
}
|
|
@@ -1507,21 +1437,21 @@ let P = class ue extends L {
|
|
|
1507
1437
|
getFieldByPath(e) {
|
|
1508
1438
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1509
1439
|
return;
|
|
1510
|
-
const t =
|
|
1440
|
+
const t = ce(e);
|
|
1511
1441
|
if (t.length === 0)
|
|
1512
1442
|
return;
|
|
1513
|
-
let
|
|
1514
|
-
for (const
|
|
1515
|
-
if (!(
|
|
1516
|
-
if (
|
|
1517
|
-
if ("at" in
|
|
1518
|
-
const n =
|
|
1443
|
+
let s = this;
|
|
1444
|
+
for (const i of t) {
|
|
1445
|
+
if (!(s instanceof S) || (s = s.getField(i.key), !s)) return;
|
|
1446
|
+
if (i.index !== void 0)
|
|
1447
|
+
if ("at" in s && "length" in s && typeof s.at == "function") {
|
|
1448
|
+
const n = s.at(i.index);
|
|
1519
1449
|
if (!n) return;
|
|
1520
|
-
|
|
1450
|
+
s = n;
|
|
1521
1451
|
} else
|
|
1522
1452
|
return;
|
|
1523
1453
|
}
|
|
1524
|
-
return
|
|
1454
|
+
return s;
|
|
1525
1455
|
}
|
|
1526
1456
|
// ============================================================================
|
|
1527
1457
|
// Private методы для создания узлов
|
|
@@ -1550,16 +1480,16 @@ let P = class ue extends L {
|
|
|
1550
1480
|
/**
|
|
1551
1481
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1552
1482
|
*/
|
|
1553
|
-
linkFields(e, t,
|
|
1554
|
-
const
|
|
1555
|
-
if (!
|
|
1556
|
-
const
|
|
1557
|
-
throw new Error(`GroupNode.linkFields: field "${String(
|
|
1483
|
+
linkFields(e, t, s) {
|
|
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`);
|
|
1558
1488
|
}
|
|
1559
|
-
const a =
|
|
1560
|
-
const
|
|
1489
|
+
const a = b(() => {
|
|
1490
|
+
const d = i.value.value, u = s ? s(d) : d;
|
|
1561
1491
|
n.setValue(u, { emitEvent: !1 });
|
|
1562
|
-
}), l =
|
|
1492
|
+
}), l = V(w.LinkFields);
|
|
1563
1493
|
return this.disposers.add(l, a);
|
|
1564
1494
|
}
|
|
1565
1495
|
/**
|
|
@@ -1591,26 +1521,26 @@ let P = class ue extends L {
|
|
|
1591
1521
|
*/
|
|
1592
1522
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1593
1523
|
watchField(e, t) {
|
|
1594
|
-
const
|
|
1595
|
-
if (!
|
|
1524
|
+
const s = this.getFieldByPath(e);
|
|
1525
|
+
if (!s)
|
|
1596
1526
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1597
|
-
const
|
|
1598
|
-
t(
|
|
1599
|
-
}), n =
|
|
1600
|
-
return this.disposers.add(n,
|
|
1527
|
+
const i = b(() => {
|
|
1528
|
+
t(s.value.value);
|
|
1529
|
+
}), n = V(w.WatchField);
|
|
1530
|
+
return this.disposers.add(n, i);
|
|
1601
1531
|
}
|
|
1602
1532
|
/**
|
|
1603
1533
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
1604
1534
|
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1605
1535
|
*/
|
|
1606
1536
|
watchFieldByPath(e, t) {
|
|
1607
|
-
const
|
|
1608
|
-
if (!
|
|
1537
|
+
const s = this.getFieldByPath(e);
|
|
1538
|
+
if (!s)
|
|
1609
1539
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1610
|
-
const
|
|
1611
|
-
t(
|
|
1612
|
-
}), n =
|
|
1613
|
-
return this.disposers.add(n,
|
|
1540
|
+
const i = b(() => {
|
|
1541
|
+
t(s.value.value);
|
|
1542
|
+
}), n = V(w.WatchField);
|
|
1543
|
+
return this.disposers.add(n, i);
|
|
1614
1544
|
}
|
|
1615
1545
|
/**
|
|
1616
1546
|
* Hook: вызывается после disable()
|
|
@@ -1657,7 +1587,8 @@ let P = class ue extends L {
|
|
|
1657
1587
|
"dispose" in e && typeof e.dispose == "function" && e.dispose();
|
|
1658
1588
|
});
|
|
1659
1589
|
}
|
|
1660
|
-
}
|
|
1590
|
+
}
|
|
1591
|
+
class H extends C {
|
|
1661
1592
|
// ============================================================================
|
|
1662
1593
|
// Приватные поля
|
|
1663
1594
|
// ============================================================================
|
|
@@ -1668,9 +1599,9 @@ let P = class ue extends L {
|
|
|
1668
1599
|
* Менеджер подписок для централизованного cleanup
|
|
1669
1600
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1670
1601
|
*/
|
|
1671
|
-
disposers = new
|
|
1602
|
+
disposers = new I();
|
|
1672
1603
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1673
|
-
_arrayErrors =
|
|
1604
|
+
_arrayErrors = g([]);
|
|
1674
1605
|
// ============================================================================
|
|
1675
1606
|
// Приватные поля для сохранения схем
|
|
1676
1607
|
// ============================================================================
|
|
@@ -1692,15 +1623,15 @@ let P = class ue extends L {
|
|
|
1692
1623
|
// Конструктор
|
|
1693
1624
|
// ============================================================================
|
|
1694
1625
|
constructor(e, t = []) {
|
|
1695
|
-
super(), this.itemSchema = e, this.initialItems = t, this.items =
|
|
1696
|
-
for (const
|
|
1697
|
-
this.push(
|
|
1698
|
-
this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((
|
|
1699
|
-
const
|
|
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({
|
|
1700
1631
|
getChildren: () => this.items.value,
|
|
1701
1632
|
ownErrors: this._arrayErrors
|
|
1702
1633
|
});
|
|
1703
|
-
this.valid =
|
|
1634
|
+
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;
|
|
1704
1635
|
}
|
|
1705
1636
|
// ============================================================================
|
|
1706
1637
|
// CRUD операции
|
|
@@ -1722,17 +1653,17 @@ let P = class ue extends L {
|
|
|
1722
1653
|
*/
|
|
1723
1654
|
removeAt(e) {
|
|
1724
1655
|
if (e < 0 || e >= this.items.value.length) {
|
|
1725
|
-
|
|
1656
|
+
O.handle(
|
|
1726
1657
|
new Error(
|
|
1727
1658
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1728
1659
|
),
|
|
1729
1660
|
"ArrayNode.removeAt",
|
|
1730
|
-
|
|
1661
|
+
A.LOG
|
|
1731
1662
|
);
|
|
1732
1663
|
return;
|
|
1733
1664
|
}
|
|
1734
1665
|
const t = this.items.value[e];
|
|
1735
|
-
this.items.value = this.items.value.filter((
|
|
1666
|
+
this.items.value = this.items.value.filter((s, i) => i !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1736
1667
|
}
|
|
1737
1668
|
/**
|
|
1738
1669
|
* Вставить элемент в массив
|
|
@@ -1741,17 +1672,17 @@ let P = class ue extends L {
|
|
|
1741
1672
|
*/
|
|
1742
1673
|
insert(e, t) {
|
|
1743
1674
|
if (e < 0 || e > this.items.value.length) {
|
|
1744
|
-
|
|
1675
|
+
O.handle(
|
|
1745
1676
|
new Error(
|
|
1746
1677
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1747
1678
|
),
|
|
1748
1679
|
"ArrayNode.insert",
|
|
1749
|
-
|
|
1680
|
+
A.LOG
|
|
1750
1681
|
);
|
|
1751
1682
|
return;
|
|
1752
1683
|
}
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1684
|
+
const s = this.createItem(t), i = [...this.items.value];
|
|
1685
|
+
i.splice(e, 0, s), this.items.value = i;
|
|
1755
1686
|
}
|
|
1756
1687
|
/**
|
|
1757
1688
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1770,18 +1701,18 @@ let P = class ue extends L {
|
|
|
1770
1701
|
* ```
|
|
1771
1702
|
*/
|
|
1772
1703
|
move(e, t) {
|
|
1773
|
-
const
|
|
1774
|
-
if (e < 0 || e >=
|
|
1775
|
-
|
|
1776
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${
|
|
1704
|
+
const s = this.items.value.length;
|
|
1705
|
+
if (e < 0 || e >= s || t < 0 || t >= s) {
|
|
1706
|
+
O.handle(
|
|
1707
|
+
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${s})`),
|
|
1777
1708
|
"ArrayNode.move",
|
|
1778
|
-
|
|
1709
|
+
A.LOG
|
|
1779
1710
|
);
|
|
1780
1711
|
return;
|
|
1781
1712
|
}
|
|
1782
1713
|
if (e === t) return;
|
|
1783
|
-
const
|
|
1784
|
-
|
|
1714
|
+
const i = [...this.items.value], [n] = i.splice(e, 1);
|
|
1715
|
+
i.splice(t, 0, n), this.items.value = i;
|
|
1785
1716
|
}
|
|
1786
1717
|
/**
|
|
1787
1718
|
* Поменять местами два элемента массива
|
|
@@ -1798,18 +1729,18 @@ let P = class ue extends L {
|
|
|
1798
1729
|
* ```
|
|
1799
1730
|
*/
|
|
1800
1731
|
swap(e, t) {
|
|
1801
|
-
const
|
|
1802
|
-
if (e < 0 || e >=
|
|
1803
|
-
|
|
1804
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${
|
|
1732
|
+
const s = this.items.value.length;
|
|
1733
|
+
if (e < 0 || e >= s || t < 0 || t >= s) {
|
|
1734
|
+
O.handle(
|
|
1735
|
+
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${s})`),
|
|
1805
1736
|
"ArrayNode.swap",
|
|
1806
|
-
|
|
1737
|
+
A.LOG
|
|
1807
1738
|
);
|
|
1808
1739
|
return;
|
|
1809
1740
|
}
|
|
1810
1741
|
if (e === t) return;
|
|
1811
|
-
const
|
|
1812
|
-
[
|
|
1742
|
+
const i = [...this.items.value];
|
|
1743
|
+
[i[e], i[t]] = [i[t], i[e]], this.items.value = i;
|
|
1813
1744
|
}
|
|
1814
1745
|
/**
|
|
1815
1746
|
* Удалить все элементы массива
|
|
@@ -1840,13 +1771,13 @@ let P = class ue extends L {
|
|
|
1840
1771
|
return this.items.value.map((e) => e.getValue());
|
|
1841
1772
|
}
|
|
1842
1773
|
setValue(e, t) {
|
|
1843
|
-
this.clear(), e.forEach((
|
|
1844
|
-
|
|
1774
|
+
this.clear(), e.forEach((s) => this.push(s)), t?.emitEvent !== !1 && this.validate().catch((s) => {
|
|
1775
|
+
O.handle(s, "ArrayNode.setValue", A.LOG);
|
|
1845
1776
|
});
|
|
1846
1777
|
}
|
|
1847
1778
|
patchValue(e) {
|
|
1848
|
-
e.forEach((t,
|
|
1849
|
-
this.items.value[
|
|
1779
|
+
e.forEach((t, s) => {
|
|
1780
|
+
this.items.value[s] && t !== void 0 && this.items.value[s].patchValue(t);
|
|
1850
1781
|
});
|
|
1851
1782
|
}
|
|
1852
1783
|
/**
|
|
@@ -1974,9 +1905,9 @@ let P = class ue extends L {
|
|
|
1974
1905
|
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
1975
1906
|
*/
|
|
1976
1907
|
forEach(e) {
|
|
1977
|
-
this.items.value.forEach((t,
|
|
1978
|
-
const
|
|
1979
|
-
e(
|
|
1908
|
+
this.items.value.forEach((t, s) => {
|
|
1909
|
+
const i = t.getProxy();
|
|
1910
|
+
e(i, s);
|
|
1980
1911
|
});
|
|
1981
1912
|
}
|
|
1982
1913
|
/**
|
|
@@ -1985,9 +1916,9 @@ let P = class ue extends L {
|
|
|
1985
1916
|
* @returns Новый массив результатов
|
|
1986
1917
|
*/
|
|
1987
1918
|
map(e) {
|
|
1988
|
-
return this.items.value.map((t,
|
|
1989
|
-
const
|
|
1990
|
-
return e(
|
|
1919
|
+
return this.items.value.map((t, s) => {
|
|
1920
|
+
const i = t.getProxy();
|
|
1921
|
+
return e(i, s);
|
|
1991
1922
|
});
|
|
1992
1923
|
}
|
|
1993
1924
|
// ============================================================================
|
|
@@ -1999,7 +1930,7 @@ let P = class ue extends L {
|
|
|
1999
1930
|
*/
|
|
2000
1931
|
createItem(e) {
|
|
2001
1932
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
2002
|
-
const t = new
|
|
1933
|
+
const t = new S(this.itemSchema);
|
|
2003
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;
|
|
2004
1935
|
}
|
|
2005
1936
|
throw new Error(
|
|
@@ -2086,14 +2017,14 @@ let P = class ue extends L {
|
|
|
2086
2017
|
* ```
|
|
2087
2018
|
*/
|
|
2088
2019
|
watchItems(e, t) {
|
|
2089
|
-
const
|
|
2020
|
+
const s = b(() => {
|
|
2090
2021
|
const n = this.items.value.map((a) => {
|
|
2091
|
-
if (a instanceof
|
|
2022
|
+
if (a instanceof S)
|
|
2092
2023
|
return a.getFieldByPath(e)?.value.value;
|
|
2093
2024
|
});
|
|
2094
2025
|
t(n);
|
|
2095
|
-
}),
|
|
2096
|
-
return this.disposers.add(
|
|
2026
|
+
}), i = V(w.WatchItems);
|
|
2027
|
+
return this.disposers.add(i, s);
|
|
2097
2028
|
}
|
|
2098
2029
|
/**
|
|
2099
2030
|
* Подписка на изменение длины массива
|
|
@@ -2118,11 +2049,11 @@ let P = class ue extends L {
|
|
|
2118
2049
|
* ```
|
|
2119
2050
|
*/
|
|
2120
2051
|
watchLength(e) {
|
|
2121
|
-
const t =
|
|
2122
|
-
const
|
|
2123
|
-
e(
|
|
2124
|
-
}),
|
|
2125
|
-
return this.disposers.add(
|
|
2052
|
+
const t = b(() => {
|
|
2053
|
+
const i = this.length.value;
|
|
2054
|
+
e(i);
|
|
2055
|
+
}), s = V(w.WatchLength);
|
|
2056
|
+
return this.disposers.add(s, t);
|
|
2126
2057
|
}
|
|
2127
2058
|
/**
|
|
2128
2059
|
* Очистить все ресурсы узла
|
|
@@ -2184,8 +2115,8 @@ let P = class ue extends L {
|
|
|
2184
2115
|
e.enable();
|
|
2185
2116
|
});
|
|
2186
2117
|
}
|
|
2187
|
-
}
|
|
2188
|
-
class
|
|
2118
|
+
}
|
|
2119
|
+
class he {
|
|
2189
2120
|
/**
|
|
2190
2121
|
* Создает узел формы на основе конфигурации
|
|
2191
2122
|
*
|
|
@@ -2235,14 +2166,14 @@ class Ne {
|
|
|
2235
2166
|
if (Array.isArray(e) && e.length >= 1)
|
|
2236
2167
|
return this.createArrayNodeFromArray(e);
|
|
2237
2168
|
if (this.isFieldConfig(e))
|
|
2238
|
-
return new
|
|
2169
|
+
return new le(e);
|
|
2239
2170
|
if (this.isArrayConfig(e))
|
|
2240
|
-
return new
|
|
2171
|
+
return new H(
|
|
2241
2172
|
e.schema,
|
|
2242
2173
|
e.initialItems
|
|
2243
2174
|
);
|
|
2244
2175
|
if (this.isGroupConfig(e))
|
|
2245
|
-
return new
|
|
2176
|
+
return new S(e);
|
|
2246
2177
|
throw new Error(
|
|
2247
2178
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
2248
2179
|
e
|
|
@@ -2276,11 +2207,11 @@ class Ne {
|
|
|
2276
2207
|
*/
|
|
2277
2208
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2278
2209
|
createArrayNodeFromArray(e) {
|
|
2279
|
-
const [t, ...
|
|
2280
|
-
this.isGroupConfig(t) &&
|
|
2281
|
-
for (const n of
|
|
2282
|
-
this.isGroupConfig(n) ?
|
|
2283
|
-
return new
|
|
2210
|
+
const [t, ...s] = e, i = [];
|
|
2211
|
+
this.isGroupConfig(t) && i.push(this.extractValues(t));
|
|
2212
|
+
for (const n of s)
|
|
2213
|
+
this.isGroupConfig(n) ? i.push(this.extractValues(n)) : i.push(n);
|
|
2214
|
+
return new H(t, i);
|
|
2284
2215
|
}
|
|
2285
2216
|
/**
|
|
2286
2217
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2318,8 +2249,8 @@ class Ne {
|
|
|
2318
2249
|
return e.map((t) => this.extractValues(t));
|
|
2319
2250
|
if (this.isGroupConfig(e)) {
|
|
2320
2251
|
const t = {};
|
|
2321
|
-
for (const [
|
|
2322
|
-
t[
|
|
2252
|
+
for (const [s, i] of Object.entries(e))
|
|
2253
|
+
t[s] = this.extractValues(i);
|
|
2323
2254
|
return t;
|
|
2324
2255
|
}
|
|
2325
2256
|
return e;
|
|
@@ -2399,64 +2330,43 @@ class Ne {
|
|
|
2399
2330
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2400
2331
|
}
|
|
2401
2332
|
}
|
|
2402
|
-
|
|
2403
|
-
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2404
|
-
}
|
|
2405
|
-
function Oe(s) {
|
|
2406
|
-
return s == null ? !1 : R(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
|
|
2407
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2408
|
-
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2409
|
-
!("fields" in s) && !("items" in s);
|
|
2410
|
-
}
|
|
2411
|
-
function Fe(s) {
|
|
2412
|
-
return s == null ? !1 : R(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2413
|
-
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2414
|
-
}
|
|
2415
|
-
function Me(s) {
|
|
2416
|
-
return s == null ? !1 : R(s) && "items" in s && "length" in s && "push" in s && "removeAt" in s && "at" in s && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2417
|
-
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2418
|
-
typeof s.removeAt == "function";
|
|
2419
|
-
}
|
|
2420
|
-
function Qe(s) {
|
|
2421
|
-
return Oe(s) ? "FieldNode" : Fe(s) ? "GroupNode" : Me(s) ? "ArrayNode" : R(s) ? "FormNode" : "Unknown";
|
|
2422
|
-
}
|
|
2423
|
-
class Pe extends L {
|
|
2333
|
+
class fe extends C {
|
|
2424
2334
|
/**
|
|
2425
2335
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2426
2336
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
2427
2337
|
* импорта с `create-form`). Обычно `(item) => createForm({ model: item, schema: itemSchema(item) })`.
|
|
2428
2338
|
*/
|
|
2429
2339
|
constructor(e, t) {
|
|
2430
|
-
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync =
|
|
2431
|
-
const
|
|
2432
|
-
for (let u = 0; u <
|
|
2433
|
-
const
|
|
2434
|
-
if (!
|
|
2435
|
-
let o = this.cache.get(
|
|
2436
|
-
o || (o = t(
|
|
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);
|
|
2437
2347
|
}
|
|
2438
|
-
const l = new Set(n),
|
|
2348
|
+
const l = new Set(n), d = [];
|
|
2439
2349
|
for (const u of this.mountedModels) {
|
|
2440
2350
|
if (l.has(u)) continue;
|
|
2441
|
-
const
|
|
2442
|
-
this.cache.delete(u),
|
|
2351
|
+
const h = this.cache.get(u);
|
|
2352
|
+
this.cache.delete(u), h && d.push(h);
|
|
2443
2353
|
}
|
|
2444
|
-
this.mountedModels = n, this.itemNodes.value = a,
|
|
2445
|
-
}), this.length = f(() => this.itemNodes.value.length), this.value = f(() => this.itemNodes.value.map((
|
|
2446
|
-
const
|
|
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({
|
|
2447
2357
|
getChildren: () => this.itemNodes.value,
|
|
2448
2358
|
ownErrors: this._arrayErrors
|
|
2449
2359
|
});
|
|
2450
|
-
this.valid =
|
|
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;
|
|
2451
2361
|
}
|
|
2452
|
-
itemNodes =
|
|
2362
|
+
itemNodes = g([]);
|
|
2453
2363
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
2454
2364
|
cache = /* @__PURE__ */ new WeakMap();
|
|
2455
2365
|
// Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
|
|
2456
2366
|
// реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
|
|
2457
2367
|
mountedModels = [];
|
|
2458
2368
|
initial;
|
|
2459
|
-
_arrayErrors =
|
|
2369
|
+
_arrayErrors = g([]);
|
|
2460
2370
|
disposeSync;
|
|
2461
2371
|
/**
|
|
2462
2372
|
* Сигнал per-item форм. Публичен в т.ч. чтобы `isArrayNode` распознавал узел как массив
|
|
@@ -2479,10 +2389,10 @@ class Pe extends L {
|
|
|
2479
2389
|
return this.itemNodes.value[e];
|
|
2480
2390
|
}
|
|
2481
2391
|
map(e) {
|
|
2482
|
-
return this.itemNodes.value.map((t,
|
|
2392
|
+
return this.itemNodes.value.map((t, s) => e(t, s));
|
|
2483
2393
|
}
|
|
2484
2394
|
forEach(e) {
|
|
2485
|
-
this.itemNodes.value.forEach((t,
|
|
2395
|
+
this.itemNodes.value.forEach((t, s) => e(t, s));
|
|
2486
2396
|
}
|
|
2487
2397
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2488
2398
|
push(e) {
|
|
@@ -2582,621 +2492,358 @@ class Pe extends L {
|
|
|
2582
2492
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2583
2493
|
}
|
|
2584
2494
|
}
|
|
2585
|
-
const
|
|
2586
|
-
const e =
|
|
2495
|
+
const ve = (r) => {
|
|
2496
|
+
const e = r.componentProps;
|
|
2587
2497
|
return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
|
|
2588
|
-
},
|
|
2589
|
-
function F(
|
|
2590
|
-
if (
|
|
2591
|
-
if (Array.isArray(
|
|
2592
|
-
for (const a of
|
|
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);
|
|
2593
2503
|
return;
|
|
2594
2504
|
}
|
|
2595
|
-
const n =
|
|
2596
|
-
if (
|
|
2597
|
-
const a =
|
|
2598
|
-
for (const l of n.children) F(l, e, t, a,
|
|
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);
|
|
2599
2509
|
return;
|
|
2600
2510
|
}
|
|
2601
|
-
if (
|
|
2602
|
-
const a = n.componentProps.control, l = n.componentProps.itemComponent,
|
|
2603
|
-
for (let u = 0; u <
|
|
2604
|
-
const
|
|
2605
|
-
F(l(
|
|
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);
|
|
2606
2516
|
}
|
|
2607
2517
|
return;
|
|
2608
2518
|
}
|
|
2609
|
-
if (n.value instanceof
|
|
2610
|
-
const a = n.validators ?? [], l = n.asyncValidators ?? [],
|
|
2611
|
-
|
|
2612
|
-
for (const [u,
|
|
2613
|
-
u === "value" || u === "validators" || u === "asyncValidators" || F(
|
|
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
|
-
for (const a of Object.values(n)) F(a, e, t,
|
|
2526
|
+
for (const a of Object.values(n)) F(a, e, t, s, i);
|
|
2617
2527
|
}
|
|
2618
|
-
function
|
|
2528
|
+
function R(r, e) {
|
|
2619
2529
|
const t = { tasks: [], clearSignals: [] };
|
|
2620
|
-
return F(e,
|
|
2530
|
+
return F(e, r, r, !0, t), t;
|
|
2621
2531
|
}
|
|
2622
|
-
const
|
|
2623
|
-
(
|
|
2624
|
-
},
|
|
2625
|
-
for (const e of Object.values(
|
|
2532
|
+
const X = (r, e, t) => {
|
|
2533
|
+
(r[e] ??= []).push(t);
|
|
2534
|
+
}, B = (r) => {
|
|
2535
|
+
for (const e of Object.values(r))
|
|
2626
2536
|
for (const t of e) if (t.severity !== "warning") return !0;
|
|
2627
2537
|
return !1;
|
|
2628
2538
|
};
|
|
2629
|
-
function
|
|
2630
|
-
const { tasks: t } =
|
|
2631
|
-
for (const { signal:
|
|
2632
|
-
const l =
|
|
2633
|
-
for (const
|
|
2634
|
-
const u =
|
|
2635
|
-
u && typeof u.then == "function" || u &&
|
|
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);
|
|
2636
2546
|
}
|
|
2637
2547
|
}
|
|
2638
|
-
return { valid: !
|
|
2548
|
+
return { valid: !B(s), errors: s };
|
|
2639
2549
|
}
|
|
2640
|
-
async function
|
|
2641
|
-
const { tasks: t } =
|
|
2642
|
-
return { valid: !
|
|
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 };
|
|
2643
2553
|
}
|
|
2644
|
-
async function
|
|
2554
|
+
async function Z(r, e) {
|
|
2645
2555
|
const t = {};
|
|
2646
2556
|
return await Promise.all(
|
|
2647
|
-
|
|
2648
|
-
const a =
|
|
2649
|
-
for (const l of
|
|
2650
|
-
const
|
|
2651
|
-
|
|
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);
|
|
2652
2562
|
}
|
|
2653
2563
|
})
|
|
2654
2564
|
), t;
|
|
2655
2565
|
}
|
|
2656
|
-
async function
|
|
2657
|
-
const { tasks: t, clearSignals:
|
|
2566
|
+
async function me(r, e) {
|
|
2567
|
+
const { tasks: t, clearSignals: s } = R(r, e), i = await Z(t, r);
|
|
2658
2568
|
for (const { signal: n } of t)
|
|
2659
|
-
|
|
2660
|
-
for (const n of
|
|
2661
|
-
|
|
2662
|
-
return { valid: !
|
|
2569
|
+
U(n)?.setErrors(i[n.__path] ?? []);
|
|
2570
|
+
for (const n of s)
|
|
2571
|
+
U(n)?.setErrors([]);
|
|
2572
|
+
return { valid: !B(i), errors: i };
|
|
2663
2573
|
}
|
|
2664
|
-
const
|
|
2665
|
-
function
|
|
2666
|
-
if (
|
|
2667
|
-
if (Array.isArray(
|
|
2668
|
-
for (const n of
|
|
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);
|
|
2669
2579
|
return;
|
|
2670
2580
|
}
|
|
2671
|
-
const
|
|
2672
|
-
if (
|
|
2673
|
-
t.set(
|
|
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);
|
|
2674
2584
|
return;
|
|
2675
2585
|
}
|
|
2676
|
-
|
|
2677
|
-
component:
|
|
2678
|
-
componentProps:
|
|
2679
|
-
validators:
|
|
2680
|
-
asyncValidators:
|
|
2681
|
-
updateOn:
|
|
2682
|
-
disabled:
|
|
2683
|
-
debounce:
|
|
2684
|
-
}) : process.env.NODE_ENV !== "production" &&
|
|
2586
|
+
s.value instanceof z ? e.set(s.value, {
|
|
2587
|
+
component: s.component,
|
|
2588
|
+
componentProps: s.componentProps,
|
|
2589
|
+
validators: s.validators,
|
|
2590
|
+
asyncValidators: s.asyncValidators,
|
|
2591
|
+
updateOn: s.updateOn,
|
|
2592
|
+
disabled: s.disabled,
|
|
2593
|
+
debounce: s.debounce
|
|
2594
|
+
}) : process.env.NODE_ENV !== "production" && s.component !== void 0 && ("valueSignal" in s || s.value != null) && console.warn(
|
|
2685
2595
|
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2686
2596
|
);
|
|
2687
|
-
for (const [n, a] of Object.entries(
|
|
2688
|
-
n !== "value" &&
|
|
2597
|
+
for (const [n, a] of Object.entries(s))
|
|
2598
|
+
n !== "value" && D(a, e, t);
|
|
2689
2599
|
}
|
|
2690
|
-
function
|
|
2691
|
-
const
|
|
2600
|
+
function te(r, e, t, s) {
|
|
2601
|
+
const i = {};
|
|
2692
2602
|
for (const [n, a] of Object.entries(e)) {
|
|
2693
2603
|
const l = t === "" ? n : `${t}.${n}`;
|
|
2694
2604
|
if (Array.isArray(a))
|
|
2695
2605
|
continue;
|
|
2696
|
-
if (
|
|
2697
|
-
|
|
2606
|
+
if (ee(a)) {
|
|
2607
|
+
i[n] = te(r, a, l, s);
|
|
2698
2608
|
continue;
|
|
2699
2609
|
}
|
|
2700
|
-
const
|
|
2701
|
-
if (!
|
|
2702
|
-
const u =
|
|
2703
|
-
|
|
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 };
|
|
2704
2614
|
}
|
|
2705
|
-
return
|
|
2615
|
+
return i;
|
|
2706
2616
|
}
|
|
2707
|
-
function
|
|
2708
|
-
for (const [
|
|
2709
|
-
const n = e === "" ?
|
|
2710
|
-
Array.isArray(
|
|
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));
|
|
2711
2621
|
}
|
|
2712
2622
|
}
|
|
2713
|
-
function
|
|
2714
|
-
const { model: e, schema: t, behavior:
|
|
2715
|
-
t !== void 0 &&
|
|
2716
|
-
const a =
|
|
2717
|
-
for (const [o,
|
|
2718
|
-
if (!Array.isArray(
|
|
2719
|
-
const
|
|
2720
|
-
if (!
|
|
2721
|
-
const
|
|
2722
|
-
l.fields.set(o,
|
|
2723
|
-
}
|
|
2724
|
-
const u = l.getProxy(),
|
|
2725
|
-
|
|
2726
|
-
for (const o of
|
|
2727
|
-
const
|
|
2728
|
-
if (
|
|
2729
|
-
|
|
2730
|
-
const
|
|
2731
|
-
m instanceof
|
|
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);
|
|
2732
2642
|
}
|
|
2733
2643
|
}
|
|
2734
2644
|
if (t !== void 0) {
|
|
2735
2645
|
const o = t;
|
|
2736
|
-
l.attachModelValidator(async () => (await
|
|
2646
|
+
l.attachModelValidator(async () => (await me(e, o)).valid);
|
|
2737
2647
|
}
|
|
2738
|
-
return
|
|
2648
|
+
return s && l.attachBehaviorCleanup(s.__run(e, u)), u;
|
|
2739
2649
|
}
|
|
2740
|
-
const
|
|
2741
|
-
function
|
|
2742
|
-
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();
|
|
2743
2653
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
if (T(s)) {
|
|
2747
|
-
const e = {};
|
|
2748
|
-
for (const t of Object.keys(s)) e[t] = S(s[t]);
|
|
2749
|
-
return e;
|
|
2750
|
-
}
|
|
2751
|
-
return s;
|
|
2752
|
-
}, I = (s, e) => {
|
|
2753
|
-
if (s === e) return !0;
|
|
2754
|
-
if (Array.isArray(s) && Array.isArray(e))
|
|
2755
|
-
return s.length !== e.length ? !1 : s.every((t, i) => I(t, e[i]));
|
|
2756
|
-
if (T(s) && T(e)) {
|
|
2757
|
-
const t = Object.keys(s), i = Object.keys(e);
|
|
2758
|
-
return t.length !== i.length ? !1 : t.every((r) => I(s[r], e[r]));
|
|
2759
|
-
}
|
|
2760
|
-
return !1;
|
|
2761
|
-
};
|
|
2762
|
-
class De {
|
|
2763
|
-
constructor(e, t) {
|
|
2764
|
-
this.path = t;
|
|
2765
|
-
const i = y(e);
|
|
2766
|
-
i.__path = t, this.signal = i, this.initial = S(e);
|
|
2767
|
-
}
|
|
2768
|
-
kind = "leaf";
|
|
2769
|
-
signal;
|
|
2770
|
-
initial;
|
|
2771
|
-
rebase(e) {
|
|
2772
|
-
this.path = e, this.signal.__path = e;
|
|
2773
|
-
}
|
|
2774
|
-
/** Реактивное чтение (внутри effect/computed создаёт зависимость). */
|
|
2775
|
-
read() {
|
|
2776
|
-
return this.signal.value;
|
|
2777
|
-
}
|
|
2778
|
-
/** Нереактивный снимок. */
|
|
2779
|
-
peek() {
|
|
2780
|
-
return this.signal.peek();
|
|
2781
|
-
}
|
|
2782
|
-
set(e) {
|
|
2783
|
-
this.signal.value = e;
|
|
2784
|
-
}
|
|
2785
|
-
resetToInitial() {
|
|
2786
|
-
this.signal.value = S(this.initial);
|
|
2787
|
-
}
|
|
2788
|
-
captureInitial() {
|
|
2789
|
-
this.initial = S(this.signal.peek());
|
|
2790
|
-
}
|
|
2791
|
-
dirty() {
|
|
2792
|
-
return !I(this.signal.peek(), this.initial);
|
|
2793
|
-
}
|
|
2654
|
+
function x(r) {
|
|
2655
|
+
return r == null ? !1 : typeof r == "object" && "value" in r && "setValue" in r && "getValue" in r && "validate" in r;
|
|
2794
2656
|
}
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
}
|
|
2801
|
-
kind = "group";
|
|
2802
|
-
children = /* @__PURE__ */ new Map();
|
|
2803
|
-
rebase(e) {
|
|
2804
|
-
this.path = e;
|
|
2805
|
-
for (const [t, i] of this.children) i.rebase(A(e, t));
|
|
2806
|
-
}
|
|
2807
|
-
peek() {
|
|
2808
|
-
const e = {};
|
|
2809
|
-
for (const [t, i] of this.children) e[t] = i.peek();
|
|
2810
|
-
return e;
|
|
2811
|
-
}
|
|
2812
|
-
set(e) {
|
|
2813
|
-
if (e == null || typeof e != "object") return;
|
|
2814
|
-
const t = e;
|
|
2815
|
-
for (const [i, r] of this.children)
|
|
2816
|
-
i in t && (r.kind === "leaf" && G(r.signal) || r.set(t[i]));
|
|
2817
|
-
}
|
|
2818
|
-
resetToInitial() {
|
|
2819
|
-
for (const e of this.children.values()) e.resetToInitial();
|
|
2820
|
-
}
|
|
2821
|
-
captureInitial() {
|
|
2822
|
-
for (const e of this.children.values()) e.captureInitial();
|
|
2823
|
-
}
|
|
2824
|
-
dirty() {
|
|
2825
|
-
for (const e of this.children.values()) if (e.dirty()) return !0;
|
|
2826
|
-
return !1;
|
|
2827
|
-
}
|
|
2828
|
-
}
|
|
2829
|
-
class Le {
|
|
2830
|
-
constructor(e, t) {
|
|
2831
|
-
this.path = t, this.items = y(e.map((i, r) => x(i, A(t, r)))), this.initial = S(e);
|
|
2832
|
-
}
|
|
2833
|
-
kind = "array";
|
|
2834
|
-
items;
|
|
2835
|
-
initial;
|
|
2836
|
-
rebase(e) {
|
|
2837
|
-
this.path = e, this.items.peek().forEach((t, i) => t.rebase(A(e, i)));
|
|
2838
|
-
}
|
|
2839
|
-
reindex() {
|
|
2840
|
-
this.items.peek().forEach((e, t) => e.rebase(A(this.path, t)));
|
|
2841
|
-
}
|
|
2842
|
-
push(e) {
|
|
2843
|
-
const t = this.items.peek();
|
|
2844
|
-
this.items.value = [...t, x(e, A(this.path, t.length))];
|
|
2845
|
-
}
|
|
2846
|
-
insertAt(e, t) {
|
|
2847
|
-
const i = [...this.items.peek()];
|
|
2848
|
-
i.splice(e, 0, x(t, A(this.path, e))), this.items.value = i, this.reindex();
|
|
2849
|
-
}
|
|
2850
|
-
removeAt(e) {
|
|
2851
|
-
const t = [...this.items.peek()];
|
|
2852
|
-
t.splice(e, 1), this.items.value = t, this.reindex();
|
|
2853
|
-
}
|
|
2854
|
-
move(e, t) {
|
|
2855
|
-
const i = [...this.items.peek()], [r] = i.splice(e, 1);
|
|
2856
|
-
r && i.splice(t, 0, r), this.items.value = i, this.reindex();
|
|
2857
|
-
}
|
|
2858
|
-
swap(e, t) {
|
|
2859
|
-
const i = [...this.items.peek()];
|
|
2860
|
-
e < 0 || t < 0 || e >= i.length || t >= i.length || e === t || ([i[e], i[t]] = [i[t], i[e]], this.items.value = i, this.reindex());
|
|
2861
|
-
}
|
|
2862
|
-
clear() {
|
|
2863
|
-
this.items.value = [];
|
|
2864
|
-
}
|
|
2865
|
-
peek() {
|
|
2866
|
-
return this.items.peek().map((e) => e.peek());
|
|
2867
|
-
}
|
|
2868
|
-
set(e) {
|
|
2869
|
-
const t = Array.isArray(e) ? e : [];
|
|
2870
|
-
this.items.value = t.map((i, r) => x(i, A(this.path, r)));
|
|
2871
|
-
}
|
|
2872
|
-
resetToInitial() {
|
|
2873
|
-
this.set(S(this.initial));
|
|
2874
|
-
}
|
|
2875
|
-
captureInitial() {
|
|
2876
|
-
this.initial = S(this.peek());
|
|
2877
|
-
}
|
|
2878
|
-
dirty() {
|
|
2879
|
-
return !I(this.peek(), this.initial);
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
function x(s, e) {
|
|
2883
|
-
return Array.isArray(s) ? new Le(s, e) : T(s) ? new me(s, e) : new De(s, e);
|
|
2884
|
-
}
|
|
2885
|
-
function D(s) {
|
|
2886
|
-
if (s)
|
|
2887
|
-
return s.kind === "leaf" ? s.read() : s.kind === "group" ? Re(s) : ye(s);
|
|
2888
|
-
}
|
|
2889
|
-
function Re(s) {
|
|
2890
|
-
return new Proxy(
|
|
2891
|
-
{},
|
|
2892
|
-
{
|
|
2893
|
-
get: (e, t) => t === "__path" ? s.path : typeof t == "string" ? D(s.children.get(t)) : void 0,
|
|
2894
|
-
set: (e, t, i) => {
|
|
2895
|
-
if (typeof t != "string") return !1;
|
|
2896
|
-
const r = s.children.get(t);
|
|
2897
|
-
return r && r.set(i), !0;
|
|
2898
|
-
},
|
|
2899
|
-
has: (e, t) => typeof t == "string" && s.children.has(t),
|
|
2900
|
-
ownKeys: () => [...s.children.keys()],
|
|
2901
|
-
getOwnPropertyDescriptor: (e, t) => typeof t == "string" && s.children.has(t) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2902
|
-
}
|
|
2903
|
-
);
|
|
2904
|
-
}
|
|
2905
|
-
function $(s) {
|
|
2906
|
-
if (s)
|
|
2907
|
-
return s.kind === "group" ? ge(s) : s.kind === "array" ? ye(s) : s.read();
|
|
2908
|
-
}
|
|
2909
|
-
function ye(s) {
|
|
2910
|
-
const e = {
|
|
2911
|
-
get length() {
|
|
2912
|
-
return s.items.value.length;
|
|
2913
|
-
},
|
|
2914
|
-
push: (t) => s.push(t),
|
|
2915
|
-
insertAt: (t, i) => s.insertAt(t, i),
|
|
2916
|
-
removeAt: (t) => s.removeAt(t),
|
|
2917
|
-
move: (t, i) => s.move(t, i),
|
|
2918
|
-
swap: (t, i) => s.swap(t, i),
|
|
2919
|
-
clear: () => s.clear(),
|
|
2920
|
-
at: (t) => $(s.items.value[t]),
|
|
2921
|
-
map: (t) => s.items.value.map((i, r) => t($(i), r)),
|
|
2922
|
-
forEach: (t) => s.items.value.forEach((i, r) => t($(i), r)),
|
|
2923
|
-
toArray: () => s.peek(),
|
|
2924
|
-
[Symbol.iterator]: function* () {
|
|
2925
|
-
const t = s.items.value;
|
|
2926
|
-
for (let i = 0; i < t.length; i++) yield D(t[i]);
|
|
2927
|
-
}
|
|
2928
|
-
};
|
|
2929
|
-
return new Proxy(e, {
|
|
2930
|
-
get: (t, i, r) => i === "__path" ? s.path : typeof i == "string" && W(i) ? D(s.items.value[Number(i)]) : Reflect.get(t, i, r),
|
|
2931
|
-
has: (t, i) => typeof i == "string" && W(i) ? Number(i) < s.items.value.length : Reflect.has(t, i)
|
|
2932
|
-
});
|
|
2933
|
-
}
|
|
2934
|
-
function q(s) {
|
|
2935
|
-
if (s.kind === "leaf") return s.signal;
|
|
2936
|
-
if (s.kind === "group")
|
|
2937
|
-
return new Proxy(
|
|
2938
|
-
{},
|
|
2939
|
-
{
|
|
2940
|
-
get: (t, i) => {
|
|
2941
|
-
if (i === "__path") return s.path;
|
|
2942
|
-
if (typeof i != "string") return;
|
|
2943
|
-
const r = s.children.get(i);
|
|
2944
|
-
return r ? q(r) : void 0;
|
|
2945
|
-
},
|
|
2946
|
-
has: (t, i) => typeof i == "string" && s.children.has(i),
|
|
2947
|
-
ownKeys: () => [...s.children.keys()],
|
|
2948
|
-
getOwnPropertyDescriptor: (t, i) => typeof i == "string" && s.children.has(i) ? { enumerable: !0, configurable: !0 } : void 0
|
|
2949
|
-
}
|
|
2950
|
-
);
|
|
2951
|
-
const e = s;
|
|
2952
|
-
return new Proxy(
|
|
2953
|
-
{
|
|
2954
|
-
get length() {
|
|
2955
|
-
return e.items.value.length;
|
|
2956
|
-
}
|
|
2957
|
-
},
|
|
2958
|
-
{
|
|
2959
|
-
get: (t, i, r) => {
|
|
2960
|
-
if (i === "__path") return e.path;
|
|
2961
|
-
if (typeof i == "string" && W(i)) {
|
|
2962
|
-
const n = e.items.value[Number(i)];
|
|
2963
|
-
return n ? q(n) : void 0;
|
|
2964
|
-
}
|
|
2965
|
-
return Reflect.get(t, i, r);
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
);
|
|
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);
|
|
2969
2662
|
}
|
|
2970
|
-
function
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
for (const i of e.split(".")) {
|
|
2974
|
-
if (!t) return;
|
|
2975
|
-
if (t.kind === "group") t = t.children.get(i);
|
|
2976
|
-
else if (t.kind === "array") t = t.items.peek()[Number(i)];
|
|
2977
|
-
else return;
|
|
2978
|
-
}
|
|
2979
|
-
return t && t.kind === "leaf" ? t.signal : void 0;
|
|
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);
|
|
2980
2666
|
}
|
|
2981
|
-
|
|
2982
|
-
"
|
|
2983
|
-
"
|
|
2984
|
-
"
|
|
2985
|
-
"patch",
|
|
2986
|
-
"isDirty",
|
|
2987
|
-
"reset",
|
|
2988
|
-
"captureInitial",
|
|
2989
|
-
"signalAt"
|
|
2990
|
-
]), ie = /* @__PURE__ */ new WeakMap();
|
|
2991
|
-
function ge(s) {
|
|
2992
|
-
const e = ie.get(s);
|
|
2993
|
-
if (e) return e;
|
|
2994
|
-
const t = {
|
|
2995
|
-
$: q(s),
|
|
2996
|
-
get: () => s.peek(),
|
|
2997
|
-
set: (r) => s.set(r),
|
|
2998
|
-
patch: (r) => s.set(r),
|
|
2999
|
-
isDirty: () => s.dirty(),
|
|
3000
|
-
reset: () => s.resetToInitial(),
|
|
3001
|
-
captureInitial: () => s.captureInitial(),
|
|
3002
|
-
signalAt: (r) => $e(s, r)
|
|
3003
|
-
}, i = new Proxy(
|
|
3004
|
-
{},
|
|
3005
|
-
{
|
|
3006
|
-
get: (r, n) => {
|
|
3007
|
-
if (typeof n != "string") return;
|
|
3008
|
-
const a = s.children.get(n);
|
|
3009
|
-
if (a) return D(a);
|
|
3010
|
-
if (se.has(n)) return t[n];
|
|
3011
|
-
},
|
|
3012
|
-
set: (r, n, a) => {
|
|
3013
|
-
if (typeof n != "string") return !1;
|
|
3014
|
-
const l = s.children.get(n);
|
|
3015
|
-
return l ? (l.set(a), !0) : !1;
|
|
3016
|
-
},
|
|
3017
|
-
has: (r, n) => typeof n == "string" && (s.children.has(n) || se.has(n)),
|
|
3018
|
-
ownKeys: () => [...s.children.keys()],
|
|
3019
|
-
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && s.children.has(n) ? { enumerable: !0, configurable: !0 } : void 0
|
|
3020
|
-
}
|
|
3021
|
-
);
|
|
3022
|
-
return ie.set(s, i), i;
|
|
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";
|
|
3023
2671
|
}
|
|
3024
|
-
function
|
|
3025
|
-
|
|
3026
|
-
return ge(e);
|
|
2672
|
+
function Ie(r) {
|
|
2673
|
+
return ge(r) ? "FieldNode" : _e(r) ? "GroupNode" : be(r) ? "ArrayNode" : x(r) ? "FormNode" : "Unknown";
|
|
3027
2674
|
}
|
|
3028
|
-
var
|
|
3029
|
-
var
|
|
3030
|
-
function
|
|
3031
|
-
if (
|
|
3032
|
-
|
|
3033
|
-
var
|
|
3034
|
-
function e(o,
|
|
3035
|
-
return o ===
|
|
3036
|
-
}
|
|
3037
|
-
var t = typeof Object.is == "function" ? Object.is : e,
|
|
3038
|
-
function l(o,
|
|
3039
|
-
var
|
|
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];
|
|
3040
2687
|
return n(
|
|
3041
2688
|
function() {
|
|
3042
|
-
m.value =
|
|
2689
|
+
m.value = c, m.getSnapshot = p, d(m) && _({ inst: m });
|
|
3043
2690
|
},
|
|
3044
|
-
[o,
|
|
3045
|
-
),
|
|
2691
|
+
[o, c, p]
|
|
2692
|
+
), i(
|
|
3046
2693
|
function() {
|
|
3047
|
-
return
|
|
3048
|
-
|
|
2694
|
+
return d(m) && _({ inst: m }), o(function() {
|
|
2695
|
+
d(m) && _({ inst: m });
|
|
3049
2696
|
});
|
|
3050
2697
|
},
|
|
3051
2698
|
[o]
|
|
3052
|
-
), a(
|
|
2699
|
+
), a(c), c;
|
|
3053
2700
|
}
|
|
3054
|
-
function
|
|
3055
|
-
var
|
|
2701
|
+
function d(o) {
|
|
2702
|
+
var p = o.getSnapshot;
|
|
3056
2703
|
o = o.value;
|
|
3057
2704
|
try {
|
|
3058
|
-
var
|
|
3059
|
-
return !t(o,
|
|
2705
|
+
var c = p();
|
|
2706
|
+
return !t(o, c);
|
|
3060
2707
|
} catch {
|
|
3061
2708
|
return !0;
|
|
3062
2709
|
}
|
|
3063
2710
|
}
|
|
3064
|
-
function u(o,
|
|
3065
|
-
return
|
|
2711
|
+
function u(o, p) {
|
|
2712
|
+
return p();
|
|
3066
2713
|
}
|
|
3067
|
-
var
|
|
3068
|
-
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;
|
|
3069
2716
|
}
|
|
3070
|
-
var
|
|
3071
|
-
var
|
|
3072
|
-
function
|
|
3073
|
-
return
|
|
3074
|
-
function
|
|
3075
|
-
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;
|
|
3076
2723
|
}
|
|
3077
|
-
function e(
|
|
3078
|
-
|
|
2724
|
+
function e(c, v) {
|
|
2725
|
+
h || i.startTransition === void 0 || (h = !0, console.error(
|
|
3079
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."
|
|
3080
2727
|
));
|
|
3081
|
-
var m =
|
|
2728
|
+
var m = v();
|
|
3082
2729
|
if (!o) {
|
|
3083
|
-
var
|
|
3084
|
-
n(m,
|
|
2730
|
+
var _ = v();
|
|
2731
|
+
n(m, _) || (console.error(
|
|
3085
2732
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
3086
2733
|
), o = !0);
|
|
3087
2734
|
}
|
|
3088
|
-
|
|
3089
|
-
inst: { value: m, getSnapshot:
|
|
2735
|
+
_ = a({
|
|
2736
|
+
inst: { value: m, getSnapshot: v }
|
|
3090
2737
|
});
|
|
3091
|
-
var
|
|
3092
|
-
return
|
|
2738
|
+
var y = _[0].inst, k = _[1];
|
|
2739
|
+
return d(
|
|
3093
2740
|
function() {
|
|
3094
|
-
|
|
2741
|
+
y.value = m, y.getSnapshot = v, t(y) && k({ inst: y });
|
|
3095
2742
|
},
|
|
3096
|
-
[
|
|
2743
|
+
[c, m, v]
|
|
3097
2744
|
), l(
|
|
3098
2745
|
function() {
|
|
3099
|
-
return t(
|
|
3100
|
-
t(
|
|
2746
|
+
return t(y) && k({ inst: y }), c(function() {
|
|
2747
|
+
t(y) && k({ inst: y });
|
|
3101
2748
|
});
|
|
3102
2749
|
},
|
|
3103
|
-
[
|
|
2750
|
+
[c]
|
|
3104
2751
|
), u(m), m;
|
|
3105
2752
|
}
|
|
3106
|
-
function t(
|
|
3107
|
-
var
|
|
3108
|
-
|
|
2753
|
+
function t(c) {
|
|
2754
|
+
var v = c.getSnapshot;
|
|
2755
|
+
c = c.value;
|
|
3109
2756
|
try {
|
|
3110
|
-
var m =
|
|
3111
|
-
return !n(
|
|
2757
|
+
var m = v();
|
|
2758
|
+
return !n(c, m);
|
|
3112
2759
|
} catch {
|
|
3113
2760
|
return !0;
|
|
3114
2761
|
}
|
|
3115
2762
|
}
|
|
3116
|
-
function
|
|
3117
|
-
return
|
|
2763
|
+
function s(c, v) {
|
|
2764
|
+
return v();
|
|
3118
2765
|
}
|
|
3119
2766
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
3120
|
-
var
|
|
3121
|
-
|
|
3122
|
-
})()),
|
|
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;
|
|
3123
2770
|
}
|
|
3124
|
-
var
|
|
3125
|
-
function
|
|
3126
|
-
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;
|
|
3127
2774
|
}
|
|
3128
|
-
var
|
|
3129
|
-
function
|
|
3130
|
-
if (
|
|
3131
|
-
if (
|
|
3132
|
-
for (let t = 0; t <
|
|
3133
|
-
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;
|
|
3134
2781
|
return !0;
|
|
3135
2782
|
}
|
|
3136
|
-
function
|
|
3137
|
-
const
|
|
3138
|
-
n.current =
|
|
3139
|
-
const a =
|
|
2783
|
+
function j(r, e, t, s) {
|
|
2784
|
+
const i = N(null), n = N(r);
|
|
2785
|
+
n.current = r;
|
|
2786
|
+
const a = N(e);
|
|
3140
2787
|
a.current = e;
|
|
3141
|
-
const l =
|
|
3142
|
-
if (l.current = t,
|
|
3143
|
-
const
|
|
3144
|
-
for (const o in
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
}
|
|
3148
|
-
const
|
|
3149
|
-
(
|
|
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) => {
|
|
3150
2797
|
let o = !0;
|
|
3151
|
-
return
|
|
3152
|
-
const
|
|
3153
|
-
for (const
|
|
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
|
-
[
|
|
2809
|
+
[s]
|
|
3163
2810
|
), u = E(() => {
|
|
3164
|
-
const
|
|
3165
|
-
for (const
|
|
3166
|
-
v
|
|
3167
|
-
let
|
|
3168
|
-
for (const
|
|
3169
|
-
const { key: m, useShallowArrayEqual:
|
|
3170
|
-
if (
|
|
3171
|
-
if (!
|
|
3172
|
-
|
|
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
|
-
dirty:
|
|
3198
|
-
shouldShowError:
|
|
3199
|
-
componentProps:
|
|
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
|
|
3200
2847
|
}, t = [
|
|
3201
2848
|
{ key: "value" },
|
|
3202
2849
|
{ key: "disabled" },
|
|
@@ -3208,34 +2855,34 @@ function We(s) {
|
|
|
3208
2855
|
{ key: "dirty" },
|
|
3209
2856
|
{ key: "shouldShowError" },
|
|
3210
2857
|
{ key: "componentProps" }
|
|
3211
|
-
],
|
|
3212
|
-
(
|
|
3213
|
-
value:
|
|
3214
|
-
pending:
|
|
3215
|
-
disabled:
|
|
3216
|
-
errors:
|
|
3217
|
-
valid:
|
|
3218
|
-
invalid:
|
|
3219
|
-
touched:
|
|
3220
|
-
dirty:
|
|
3221
|
-
shouldShowError:
|
|
3222
|
-
componentProps:
|
|
2858
|
+
], s = E(
|
|
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
|
|
3223
2870
|
}),
|
|
3224
2871
|
[]
|
|
3225
2872
|
);
|
|
3226
|
-
return
|
|
2873
|
+
return j(e, t, s, r);
|
|
3227
2874
|
}
|
|
3228
|
-
function
|
|
2875
|
+
function ke(r) {
|
|
3229
2876
|
const e = {
|
|
3230
|
-
value:
|
|
3231
|
-
length:
|
|
3232
|
-
errors:
|
|
3233
|
-
pending:
|
|
3234
|
-
valid:
|
|
3235
|
-
invalid:
|
|
3236
|
-
touched:
|
|
3237
|
-
dirty:
|
|
3238
|
-
disabled:
|
|
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
|
|
3239
2886
|
}, t = [
|
|
3240
2887
|
{ key: "value" },
|
|
3241
2888
|
{ key: "length" },
|
|
@@ -3246,24 +2893,24 @@ function qe(s) {
|
|
|
3246
2893
|
{ key: "touched" },
|
|
3247
2894
|
{ key: "dirty" },
|
|
3248
2895
|
{ key: "disabled" }
|
|
3249
|
-
],
|
|
3250
|
-
(
|
|
3251
|
-
value:
|
|
3252
|
-
length:
|
|
3253
|
-
pending:
|
|
3254
|
-
errors:
|
|
3255
|
-
valid:
|
|
3256
|
-
invalid:
|
|
3257
|
-
touched:
|
|
3258
|
-
dirty:
|
|
3259
|
-
disabled:
|
|
2896
|
+
], s = E(
|
|
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
|
|
3260
2907
|
}),
|
|
3261
2908
|
[]
|
|
3262
2909
|
);
|
|
3263
|
-
return
|
|
2910
|
+
return j(e, t, s, r);
|
|
3264
2911
|
}
|
|
3265
|
-
function
|
|
3266
|
-
const
|
|
2912
|
+
function Oe() {
|
|
2913
|
+
const r = E(
|
|
3267
2914
|
() => ({
|
|
3268
2915
|
value: [],
|
|
3269
2916
|
length: 0,
|
|
@@ -3277,93 +2924,93 @@ function Ke() {
|
|
|
3277
2924
|
}),
|
|
3278
2925
|
[]
|
|
3279
2926
|
);
|
|
3280
|
-
return
|
|
2927
|
+
return j({}, [], r);
|
|
3281
2928
|
}
|
|
3282
|
-
function
|
|
3283
|
-
const e =
|
|
3284
|
-
return
|
|
2929
|
+
function Le(r) {
|
|
2930
|
+
const e = r && "length" in r && "map" in r;
|
|
2931
|
+
return r ? e ? ke(r) : Ve(r) : Oe();
|
|
3285
2932
|
}
|
|
3286
|
-
function
|
|
3287
|
-
const e =
|
|
3288
|
-
(
|
|
2933
|
+
function Re(r) {
|
|
2934
|
+
const e = N({ value: r.value.value }), t = E(
|
|
2935
|
+
(i) => {
|
|
3289
2936
|
let n = !0;
|
|
3290
|
-
return
|
|
3291
|
-
if (
|
|
2937
|
+
return b(() => {
|
|
2938
|
+
if (r.value.value, n) {
|
|
3292
2939
|
n = !1;
|
|
3293
2940
|
return;
|
|
3294
2941
|
}
|
|
3295
|
-
|
|
2942
|
+
i();
|
|
3296
2943
|
});
|
|
3297
2944
|
},
|
|
3298
|
-
[
|
|
3299
|
-
),
|
|
3300
|
-
const
|
|
3301
|
-
return e.current.value ===
|
|
3302
|
-
}, [
|
|
3303
|
-
return
|
|
2945
|
+
[r]
|
|
2946
|
+
), s = E(() => {
|
|
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);
|
|
3304
2951
|
}
|
|
3305
|
-
function
|
|
3306
|
-
const e =
|
|
3307
|
-
(
|
|
2952
|
+
function Be(r) {
|
|
2953
|
+
const e = N({ length: r.length.value }), t = E(
|
|
2954
|
+
(i) => {
|
|
3308
2955
|
let n = !0;
|
|
3309
|
-
return
|
|
3310
|
-
if (
|
|
2956
|
+
return b(() => {
|
|
2957
|
+
if (r.length.value, n) {
|
|
3311
2958
|
n = !1;
|
|
3312
2959
|
return;
|
|
3313
2960
|
}
|
|
3314
|
-
|
|
2961
|
+
i();
|
|
3315
2962
|
});
|
|
3316
2963
|
},
|
|
3317
|
-
[
|
|
3318
|
-
),
|
|
3319
|
-
const
|
|
3320
|
-
return e.current.length ===
|
|
3321
|
-
}, [
|
|
3322
|
-
return
|
|
2964
|
+
[r]
|
|
2965
|
+
), s = E(() => {
|
|
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);
|
|
3323
2970
|
}
|
|
3324
2971
|
export {
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
2972
|
+
H as ArrayNode,
|
|
2973
|
+
A as ErrorStrategy,
|
|
2974
|
+
le as FieldNode,
|
|
2975
|
+
O as FormErrorHandler,
|
|
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,
|
|
3346
2993
|
G as isDerived,
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
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,
|
|
3006
|
+
V as uniqueId,
|
|
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
|
|
3369
3016
|
};
|