@reformer/core 11.0.0-beta.2 → 11.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behaviors.d.ts +1 -1
- package/dist/behaviors.js +37 -37
- package/dist/create-model-Dxh9cfLp.js +97 -0
- package/dist/form/behaviors/collections.d.ts +50 -0
- package/dist/form/behaviors/context.d.ts +23 -0
- package/dist/form/behaviors/index.d.ts +28 -0
- package/dist/form/behaviors/internals.d.ts +26 -0
- package/dist/form/{behaviors-node.d.ts → behaviors/node.d.ts} +3 -3
- package/dist/form/behaviors/operators.d.ts +51 -0
- package/dist/form/behaviors/types.d.ts +17 -0
- package/dist/form/create-core-form.d.ts +70 -0
- package/dist/form/create-form.d.ts +1 -1
- package/dist/form/index.d.ts +12 -12
- package/dist/form/nodes/model-array-node.d.ts +1 -1
- package/dist/form/types/contracts.d.ts +9 -6
- package/dist/form/types/validation-schema.d.ts +1 -1
- package/dist/form/validation/config.d.ts +73 -0
- package/dist/form/validation/context.d.ts +27 -0
- package/dist/form/{error-handler.d.ts → validation/error-handler.d.ts} +1 -1
- package/dist/form/validation/index.d.ts +23 -28
- package/dist/form/validation/operators.d.ts +42 -0
- package/dist/form/validation/run.d.ts +45 -0
- package/dist/form/{validation-strategy.d.ts → validation/strategy.d.ts} +10 -4
- package/dist/form/validation/types.d.ts +28 -0
- package/dist/form/{validation/validators → validators}/date-utils.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/email.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/file-type.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/file-utils.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/future-date.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/index.d.ts +6 -4
- package/dist/form/{validation/validators → validators}/integer.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/is-date.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/is-number.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max-age.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max-date.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max-file-size.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max-files.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max-length.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max-total-file-size.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/max.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/min-age.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/min-date.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/min-file-size.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/min-files.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/min-length.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/min.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/multiple-of.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/non-negative.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/non-zero.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/past-date.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/pattern.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/phone.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/required.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/url.d.ts +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +708 -479
- package/dist/{state/form-model.d.ts → model/create-model.d.ts} +0 -14
- package/dist/{state → model}/index.d.ts +10 -11
- package/dist/model/model-nodes.d.ts +60 -0
- package/dist/model/model-signals-proxy.d.ts +32 -0
- package/dist/model/model-value-proxy.d.ts +3 -0
- package/dist/{state → model}/safe-effect.d.ts +1 -1
- package/dist/model-signals-proxy-mV3WGdlO.js +233 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.js +21 -0
- package/dist/{form → platforms/react}/hooks/types.d.ts +1 -1
- package/dist/platforms/react/hooks/use-form-bundle.d.ts +26 -0
- package/dist/{form → platforms/react}/hooks/use-form-validation.d.ts +3 -3
- package/dist/{form → platforms/react}/hooks/useArrayLength.d.ts +1 -1
- package/dist/{form → platforms/react}/hooks/useFormControl.d.ts +3 -3
- package/dist/{form → platforms/react}/hooks/useFormControlValue.d.ts +2 -2
- package/dist/platforms/react/index.d.ts +23 -0
- package/dist/signals.d.ts +1 -1
- package/dist/strategy-DA3JwxsR.js +170 -0
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +10 -165
- 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 +1 -1
- package/docs/llms/02-quick-start.md +14 -7
- package/docs/llms/15-project-structure.md +12 -8
- package/llms.txt +329 -53
- package/package.json +4 -4
- package/dist/form/behaviors.d.ts +0 -133
- package/dist/form/validation-schema.d.ts +0 -106
- package/dist/form/validators.d.ts +0 -11
- package/dist/form-model-DhW2HZOB.js +0 -323
- package/dist/state.d.ts +0 -2
- package/dist/state.js +0 -21
- package/dist/subscription-manager-705bls97.js +0 -171
- /package/dist/{state → form/nodes}/subscription-manager.d.ts +0 -0
- /package/dist/{state → model}/behaviors-value.d.ts +0 -0
- /package/dist/{state → model}/derived-registry.d.ts +0 -0
- /package/dist/{state → model}/types.d.ts +0 -0
- /package/dist/{behaviors-node-DGEFMTQu.js → node-DGEFMTQu.js} +0 -0
- /package/dist/{form → platforms/react}/hooks/useSignalSubscription.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
1
|
+
import { c as ee } from "./create-model-Dxh9cfLp.js";
|
|
2
|
+
import { e as Ke } from "./create-model-Dxh9cfLp.js";
|
|
3
|
+
import { a as G } from "./model-signals-proxy-mV3WGdlO.js";
|
|
4
|
+
import { i as ze, m as Ye, u as Je } from "./model-signals-proxy-mV3WGdlO.js";
|
|
5
|
+
import { c as Xe, a as Ze, r as et, b as tt, d as st, e as rt, f as it, s as nt, t as at, w as ot } from "./behaviors-value-C7dSEhCc.js";
|
|
6
|
+
import { signal as g, computed as m, effect as _, batch as te, Signal as j } from "@preact/signals-core";
|
|
7
|
+
import { r as se } from "./signal-node-registry-tiwel-TV.js";
|
|
8
|
+
import { g as ut } from "./signal-node-registry-tiwel-TV.js";
|
|
9
|
+
import { f as re, h as D, g as ie, d as ne } from "./strategy-DA3JwxsR.js";
|
|
10
|
+
import { d as ct, e as ht } from "./node-DGEFMTQu.js";
|
|
11
|
+
import z, { useRef as k, useCallback as E, useMemo as ae, useEffect as Y, useState as oe } from "react";
|
|
11
12
|
class M {
|
|
12
13
|
// ============================================================================
|
|
13
14
|
// Protected состояние (для Template Method паттерна)
|
|
@@ -34,21 +35,21 @@ class M {
|
|
|
34
35
|
* Пользователь взаимодействовал с узлом (touched)
|
|
35
36
|
* Computed из _touched для предоставления readonly интерфейса
|
|
36
37
|
*/
|
|
37
|
-
touched =
|
|
38
|
+
touched = m(() => this._touched.value);
|
|
38
39
|
/**
|
|
39
40
|
* Значение узла было изменено (dirty)
|
|
40
41
|
* Computed из _dirty для предоставления readonly интерфейса
|
|
41
42
|
*/
|
|
42
|
-
dirty =
|
|
43
|
+
dirty = m(() => this._dirty.value);
|
|
43
44
|
/**
|
|
44
45
|
* Текущий статус узла
|
|
45
46
|
* Computed из _status для предоставления readonly интерфейса
|
|
46
47
|
*/
|
|
47
|
-
status =
|
|
48
|
+
status = m(() => this._status.value);
|
|
48
49
|
/**
|
|
49
50
|
* Узел отключен (disabled)
|
|
50
51
|
*/
|
|
51
|
-
disabled =
|
|
52
|
+
disabled = m(() => this._status.value === "disabled");
|
|
52
53
|
/**
|
|
53
54
|
* Получить ошибки валидации с фильтрацией
|
|
54
55
|
*
|
|
@@ -90,17 +91,17 @@ class M {
|
|
|
90
91
|
*/
|
|
91
92
|
getErrors(e) {
|
|
92
93
|
const t = this.errors.value;
|
|
93
|
-
return e ? t.filter((
|
|
94
|
-
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(
|
|
94
|
+
return e ? t.filter((r) => {
|
|
95
|
+
if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(r.code) || e.message !== void 0 && !r.message.toLowerCase().includes(e.message.toLowerCase()))
|
|
95
96
|
return !1;
|
|
96
97
|
if (e.params !== void 0) {
|
|
97
|
-
if (!
|
|
98
|
+
if (!r.params)
|
|
98
99
|
return !1;
|
|
99
|
-
for (const [
|
|
100
|
-
if (
|
|
100
|
+
for (const [i, n] of Object.entries(e.params))
|
|
101
|
+
if (r.params[i] !== n)
|
|
101
102
|
return !1;
|
|
102
103
|
}
|
|
103
|
-
return !(e.predicate !== void 0 && !e.predicate(
|
|
104
|
+
return !(e.predicate !== void 0 && !e.predicate(r));
|
|
104
105
|
}) : t;
|
|
105
106
|
}
|
|
106
107
|
// ============================================================================
|
|
@@ -273,6 +274,174 @@ class M {
|
|
|
273
274
|
onEnable() {
|
|
274
275
|
}
|
|
275
276
|
}
|
|
277
|
+
class L {
|
|
278
|
+
/**
|
|
279
|
+
* Хранилище подписок
|
|
280
|
+
* Ключ: уникальный идентификатор подписки
|
|
281
|
+
* Значение: функция отписки (dispose)
|
|
282
|
+
*/
|
|
283
|
+
subscriptions = /* @__PURE__ */ new Map();
|
|
284
|
+
/**
|
|
285
|
+
* Добавляет подписку
|
|
286
|
+
*
|
|
287
|
+
* Если подписка с таким ключом уже существует, отписывается от неё
|
|
288
|
+
* и заменяет новой. Это предотвращает утечки памяти при повторной
|
|
289
|
+
* регистрации подписки с тем же ключом.
|
|
290
|
+
*
|
|
291
|
+
* @param key Уникальный ключ подписки
|
|
292
|
+
* @param dispose Функция отписки (обычно возвращаемая из effect())
|
|
293
|
+
* @returns Функция для отписки от этой конкретной подписки
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const manager = new SubscriptionManager();
|
|
298
|
+
*
|
|
299
|
+
* // Добавление подписки
|
|
300
|
+
* const unsubscribe = manager.add('mySubscription', () => {
|
|
301
|
+
* console.log('Disposing subscription');
|
|
302
|
+
* });
|
|
303
|
+
*
|
|
304
|
+
* // Отписка через возвращаемую функцию
|
|
305
|
+
* unsubscribe();
|
|
306
|
+
*
|
|
307
|
+
* // Или через manager.remove()
|
|
308
|
+
* manager.add('anotherSub', disposeFn);
|
|
309
|
+
* manager.remove('anotherSub');
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
add(e, t) {
|
|
313
|
+
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);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Удаляет подписку по ключу
|
|
317
|
+
*
|
|
318
|
+
* Вызывает функцию отписки и удаляет подписку из хранилища.
|
|
319
|
+
* Если подписка с таким ключом не найдена, ничего не делает.
|
|
320
|
+
*
|
|
321
|
+
* @param key Ключ подписки
|
|
322
|
+
* @returns true, если подписка была удалена, false если не найдена
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const manager = new SubscriptionManager();
|
|
327
|
+
* manager.add('mySub', disposeFn);
|
|
328
|
+
*
|
|
329
|
+
* // Удаление подписки
|
|
330
|
+
* const removed = manager.remove('mySub'); // true
|
|
331
|
+
*
|
|
332
|
+
* // Попытка удалить несуществующую подписку
|
|
333
|
+
* const removed2 = manager.remove('nonExistent'); // false
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
remove(e) {
|
|
337
|
+
const t = this.subscriptions.get(e);
|
|
338
|
+
return t ? (t(), this.subscriptions.delete(e), !0) : !1;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Очищает все подписки
|
|
342
|
+
*
|
|
343
|
+
* Вызывает функции отписки для всех активных подписок
|
|
344
|
+
* и очищает хранилище. Обычно используется при dispose узла формы.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* class FieldNode {
|
|
349
|
+
* private subscriptions = new SubscriptionManager();
|
|
350
|
+
*
|
|
351
|
+
* dispose() {
|
|
352
|
+
* // Отписываемся от всех effect
|
|
353
|
+
* this.subscriptions.clear();
|
|
354
|
+
* }
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
clear() {
|
|
359
|
+
this.subscriptions.forEach((e) => {
|
|
360
|
+
e();
|
|
361
|
+
}), this.subscriptions.clear();
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Возвращает количество активных подписок
|
|
365
|
+
*
|
|
366
|
+
* Полезно для отладки утечек памяти. Если количество подписок
|
|
367
|
+
* растет без ограничений, это может указывать на то, что
|
|
368
|
+
* компоненты не отписываются должным образом.
|
|
369
|
+
*
|
|
370
|
+
* @returns Количество активных подписок
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* const manager = new SubscriptionManager();
|
|
375
|
+
* console.log(manager.size()); // 0
|
|
376
|
+
*
|
|
377
|
+
* manager.add('sub1', disposeFn1);
|
|
378
|
+
* manager.add('sub2', disposeFn2);
|
|
379
|
+
* console.log(manager.size()); // 2
|
|
380
|
+
*
|
|
381
|
+
* manager.clear();
|
|
382
|
+
* console.log(manager.size()); // 0
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
size() {
|
|
386
|
+
return this.subscriptions.size;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Проверяет, есть ли подписка с данным ключом
|
|
390
|
+
*
|
|
391
|
+
* @param key Ключ подписки
|
|
392
|
+
* @returns true, если подписка существует
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```typescript
|
|
396
|
+
* const manager = new SubscriptionManager();
|
|
397
|
+
* manager.add('mySub', disposeFn);
|
|
398
|
+
*
|
|
399
|
+
* console.log(manager.has('mySub')); // true
|
|
400
|
+
* console.log(manager.has('nonExistent')); // false
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
has(e) {
|
|
404
|
+
return this.subscriptions.has(e);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Возвращает список всех ключей активных подписок
|
|
408
|
+
*
|
|
409
|
+
* Полезно для отладки: можно увидеть, какие подписки активны.
|
|
410
|
+
*
|
|
411
|
+
* @returns Массив ключей всех активных подписок
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* const manager = new SubscriptionManager();
|
|
416
|
+
* manager.add('watch-value', disposeFn1);
|
|
417
|
+
* manager.add('watch-errors', disposeFn2);
|
|
418
|
+
*
|
|
419
|
+
* console.log(manager.getKeys()); // ['watch-value', 'watch-errors']
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
getKeys() {
|
|
423
|
+
return Array.from(this.subscriptions.keys());
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Отписывается от всех подписок (алиас для clear())
|
|
427
|
+
*
|
|
428
|
+
* Используется при dispose() узла формы для совместимости с ожидаемым API.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```typescript
|
|
432
|
+
* class FieldNode {
|
|
433
|
+
* private subscriptions = new SubscriptionManager();
|
|
434
|
+
*
|
|
435
|
+
* dispose() {
|
|
436
|
+
* this.subscriptions.dispose();
|
|
437
|
+
* }
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
dispose() {
|
|
442
|
+
this.clear();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
276
445
|
const O = {
|
|
277
446
|
/** FieldNode.watch() */
|
|
278
447
|
Watch: "watch",
|
|
@@ -283,15 +452,15 @@ const O = {
|
|
|
283
452
|
/** GroupNode.watchField() */
|
|
284
453
|
WatchField: "watchField"
|
|
285
454
|
};
|
|
286
|
-
let
|
|
287
|
-
function N(
|
|
288
|
-
return `${
|
|
455
|
+
let le = 0;
|
|
456
|
+
function N(s) {
|
|
457
|
+
return `${s}-${++le}`;
|
|
289
458
|
}
|
|
290
|
-
var S = /* @__PURE__ */ ((
|
|
291
|
-
class
|
|
292
|
-
static handle(e, t,
|
|
293
|
-
const
|
|
294
|
-
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e),
|
|
459
|
+
var S = /* @__PURE__ */ ((s) => (s.THROW = "throw", s.LOG = "log", s.CONVERT = "convert", s))(S || {});
|
|
460
|
+
class V {
|
|
461
|
+
static handle(e, t, r = "throw") {
|
|
462
|
+
const i = this.extractMessage(e);
|
|
463
|
+
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), r) {
|
|
295
464
|
case "throw":
|
|
296
465
|
throw e;
|
|
297
466
|
case "log":
|
|
@@ -299,7 +468,7 @@ class k {
|
|
|
299
468
|
case "convert":
|
|
300
469
|
return {
|
|
301
470
|
code: "validator_error",
|
|
302
|
-
message:
|
|
471
|
+
message: i,
|
|
303
472
|
params: { field: t }
|
|
304
473
|
};
|
|
305
474
|
}
|
|
@@ -355,11 +524,11 @@ class k {
|
|
|
355
524
|
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
356
525
|
* ```
|
|
357
526
|
*/
|
|
358
|
-
static createValidationError(e, t,
|
|
527
|
+
static createValidationError(e, t, r) {
|
|
359
528
|
return {
|
|
360
529
|
code: e,
|
|
361
530
|
message: t,
|
|
362
|
-
params:
|
|
531
|
+
params: r ? { field: r } : void 0
|
|
363
532
|
};
|
|
364
533
|
}
|
|
365
534
|
/**
|
|
@@ -381,7 +550,7 @@ class k {
|
|
|
381
550
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
382
551
|
}
|
|
383
552
|
}
|
|
384
|
-
class
|
|
553
|
+
class ue {
|
|
385
554
|
/** Внутренний сигнал статуса */
|
|
386
555
|
_status;
|
|
387
556
|
/** Публичный read-only сигнал статуса */
|
|
@@ -398,7 +567,7 @@ class ie {
|
|
|
398
567
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
399
568
|
*/
|
|
400
569
|
constructor(e = "valid") {
|
|
401
|
-
this._status = g(e), this.status =
|
|
570
|
+
this._status = g(e), this.status = m(() => this._status.value), this.valid = m(() => this._status.value === "valid"), this.invalid = m(() => this._status.value === "invalid"), this.pending = m(() => this._status.value === "pending"), this.disabled = m(() => this._status.value === "disabled");
|
|
402
571
|
}
|
|
403
572
|
/**
|
|
404
573
|
* Начать валидацию
|
|
@@ -481,7 +650,7 @@ class ie {
|
|
|
481
650
|
this._status.value = e ? "invalid" : "valid";
|
|
482
651
|
}
|
|
483
652
|
}
|
|
484
|
-
class
|
|
653
|
+
class de extends M {
|
|
485
654
|
// ============================================================================
|
|
486
655
|
// Приватные сигналы
|
|
487
656
|
// ============================================================================
|
|
@@ -533,13 +702,13 @@ class ne extends M {
|
|
|
533
702
|
* Менеджер подписок для централизованного cleanup
|
|
534
703
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
535
704
|
*/
|
|
536
|
-
disposers = new
|
|
705
|
+
disposers = new L();
|
|
537
706
|
component;
|
|
538
707
|
// ============================================================================
|
|
539
708
|
// Конструктор
|
|
540
709
|
// ============================================================================
|
|
541
710
|
constructor(e) {
|
|
542
|
-
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
|
|
711
|
+
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 ue(e.disabled ? "disabled" : "valid"), this.value = m(() => this._value.value), this.valid = m(() => this.statusMachine.valid.value), this.invalid = m(() => this.statusMachine.invalid.value), this.pending = m(() => this.statusMachine.pending.value), this.status = m(() => this.statusMachine.status.value), this.disabled = m(() => this.statusMachine.disabled.value), this.errors = m(() => this._errors.value), this.componentProps = m(() => this._componentProps.value), this.shouldShowError = m(
|
|
543
712
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
544
713
|
);
|
|
545
714
|
}
|
|
@@ -552,12 +721,12 @@ class ne extends M {
|
|
|
552
721
|
setValue(e, t) {
|
|
553
722
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
554
723
|
return;
|
|
555
|
-
const
|
|
724
|
+
const r = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
|
|
556
725
|
if (this.updateOn === "change") {
|
|
557
726
|
this.validate();
|
|
558
727
|
return;
|
|
559
728
|
}
|
|
560
|
-
|
|
729
|
+
i && r && this.validate();
|
|
561
730
|
}
|
|
562
731
|
patchValue(e) {
|
|
563
732
|
this.setValue(e);
|
|
@@ -650,20 +819,20 @@ class ne extends M {
|
|
|
650
819
|
const t = e?.debounce ?? this.debounceMs;
|
|
651
820
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
652
821
|
return this.validateImmediate();
|
|
653
|
-
const
|
|
654
|
-
return new Promise((
|
|
655
|
-
this.pendingValidation = { resolve:
|
|
656
|
-
if (this.validateDebounceTimer = void 0,
|
|
657
|
-
|
|
822
|
+
const r = new AbortController();
|
|
823
|
+
return new Promise((i) => {
|
|
824
|
+
this.pendingValidation = { resolve: i, abortController: r }, this.validateDebounceTimer = setTimeout(async () => {
|
|
825
|
+
if (this.validateDebounceTimer = void 0, r.signal.aborted) {
|
|
826
|
+
i(!1);
|
|
658
827
|
return;
|
|
659
828
|
}
|
|
660
829
|
this.pendingValidation = void 0;
|
|
661
|
-
const n = await this.validateImmediate(
|
|
662
|
-
|
|
663
|
-
}, t),
|
|
830
|
+
const n = await this.validateImmediate(r);
|
|
831
|
+
i(n);
|
|
832
|
+
}, t), r.signal.addEventListener(
|
|
664
833
|
"abort",
|
|
665
834
|
() => {
|
|
666
|
-
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0),
|
|
835
|
+
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), i(!1);
|
|
667
836
|
},
|
|
668
837
|
{ once: !0 }
|
|
669
838
|
);
|
|
@@ -682,37 +851,37 @@ class ne extends M {
|
|
|
682
851
|
async validateImmediate(e) {
|
|
683
852
|
const t = e ?? new AbortController();
|
|
684
853
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
685
|
-
const { signal:
|
|
854
|
+
const { signal: r } = t, i = [];
|
|
686
855
|
for (const a of this.validators) {
|
|
687
856
|
const l = a(this._value.value);
|
|
688
|
-
l &&
|
|
857
|
+
l && i.push(l);
|
|
689
858
|
}
|
|
690
|
-
if (
|
|
859
|
+
if (r.aborted)
|
|
691
860
|
return !1;
|
|
692
|
-
if (
|
|
693
|
-
this._errors.value =
|
|
694
|
-
const a =
|
|
861
|
+
if (i.length > 0) {
|
|
862
|
+
this._errors.value = i;
|
|
863
|
+
const a = i.some((l) => l.severity !== "warning");
|
|
695
864
|
if (this.statusMachine.setErrors(a), a)
|
|
696
865
|
return !1;
|
|
697
866
|
}
|
|
698
867
|
if (this.asyncValidators.length > 0) {
|
|
699
|
-
if (
|
|
868
|
+
if (r.aborted)
|
|
700
869
|
return !1;
|
|
701
870
|
this.statusMachine.startValidation();
|
|
702
871
|
try {
|
|
703
872
|
const a = await Promise.all(
|
|
704
873
|
this.asyncValidators.map(async (d) => {
|
|
705
|
-
if (
|
|
874
|
+
if (r.aborted)
|
|
706
875
|
throw new DOMException("Validation aborted", "AbortError");
|
|
707
876
|
try {
|
|
708
|
-
const u = await d(this._value.value, { signal:
|
|
709
|
-
if (
|
|
877
|
+
const u = await d(this._value.value, { signal: r });
|
|
878
|
+
if (r.aborted)
|
|
710
879
|
throw new DOMException("Validation aborted", "AbortError");
|
|
711
880
|
return u;
|
|
712
881
|
} catch (u) {
|
|
713
882
|
if (u instanceof DOMException && u.name === "AbortError")
|
|
714
883
|
throw u;
|
|
715
|
-
return
|
|
884
|
+
return V.handle(
|
|
716
885
|
u,
|
|
717
886
|
"FieldNode AsyncValidator",
|
|
718
887
|
S.CONVERT
|
|
@@ -720,7 +889,7 @@ class ne extends M {
|
|
|
720
889
|
}
|
|
721
890
|
})
|
|
722
891
|
);
|
|
723
|
-
if (
|
|
892
|
+
if (r.aborted)
|
|
724
893
|
return !1;
|
|
725
894
|
const l = a.filter((d) => d !== null);
|
|
726
895
|
if (l.length > 0) {
|
|
@@ -735,11 +904,11 @@ class ne extends M {
|
|
|
735
904
|
throw a;
|
|
736
905
|
}
|
|
737
906
|
}
|
|
738
|
-
return
|
|
907
|
+
return r.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"));
|
|
739
908
|
}
|
|
740
909
|
setErrors(e) {
|
|
741
910
|
this._errors.value = e;
|
|
742
|
-
const t = e.some((
|
|
911
|
+
const t = e.some((r) => r.severity !== "warning");
|
|
743
912
|
this.statusMachine.setErrors(t);
|
|
744
913
|
}
|
|
745
914
|
clearErrors() {
|
|
@@ -856,12 +1025,12 @@ class ne extends M {
|
|
|
856
1025
|
* ```
|
|
857
1026
|
*/
|
|
858
1027
|
watch(e) {
|
|
859
|
-
const t = new AbortController(),
|
|
1028
|
+
const t = new AbortController(), r = _(() => {
|
|
860
1029
|
const n = this.value.value;
|
|
861
1030
|
e(n, t.signal);
|
|
862
|
-
}),
|
|
863
|
-
return this.disposers.add(
|
|
864
|
-
t.abort(),
|
|
1031
|
+
}), i = N(O.Watch);
|
|
1032
|
+
return this.disposers.add(i, () => {
|
|
1033
|
+
t.abort(), r();
|
|
865
1034
|
});
|
|
866
1035
|
}
|
|
867
1036
|
/**
|
|
@@ -887,11 +1056,11 @@ class ne extends M {
|
|
|
887
1056
|
* ```
|
|
888
1057
|
*/
|
|
889
1058
|
computeFrom(e, t) {
|
|
890
|
-
const
|
|
1059
|
+
const r = _(() => {
|
|
891
1060
|
const n = e.map((l) => l.value), a = t(...n);
|
|
892
1061
|
this.setValue(a, { emitEvent: !1 });
|
|
893
|
-
}),
|
|
894
|
-
return this.disposers.add(
|
|
1062
|
+
}), i = N(O.ComputeFrom);
|
|
1063
|
+
return this.disposers.add(i, r);
|
|
895
1064
|
}
|
|
896
1065
|
/**
|
|
897
1066
|
* Очистить все ресурсы и таймеры
|
|
@@ -921,59 +1090,59 @@ class ne extends M {
|
|
|
921
1090
|
}
|
|
922
1091
|
}
|
|
923
1092
|
}
|
|
924
|
-
function
|
|
925
|
-
const { getChildren: e, ownErrors: t, disabled:
|
|
1093
|
+
function R(s) {
|
|
1094
|
+
const { getChildren: e, ownErrors: t, disabled: r } = s, i = m(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = m(() => !i.value), a = m(() => e().some((o) => o.pending.value)), l = m(() => e().some((o) => o.touched.value)), d = m(() => e().some((o) => o.dirty.value)), u = m(() => {
|
|
926
1095
|
const o = [...t.value];
|
|
927
|
-
for (const
|
|
928
|
-
o.push(...
|
|
1096
|
+
for (const f of e())
|
|
1097
|
+
o.push(...f.errors.value);
|
|
929
1098
|
return o;
|
|
930
|
-
}),
|
|
1099
|
+
}), h = m(() => r?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
931
1100
|
return {
|
|
932
|
-
valid:
|
|
1101
|
+
valid: i,
|
|
933
1102
|
invalid: n,
|
|
934
1103
|
pending: a,
|
|
935
1104
|
touched: l,
|
|
936
1105
|
dirty: d,
|
|
937
1106
|
errors: u,
|
|
938
|
-
status:
|
|
1107
|
+
status: h
|
|
939
1108
|
};
|
|
940
1109
|
}
|
|
941
|
-
function
|
|
942
|
-
return typeof
|
|
1110
|
+
function B(s) {
|
|
1111
|
+
return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
|
|
943
1112
|
}
|
|
944
1113
|
const U = "$";
|
|
945
|
-
function
|
|
1114
|
+
function ce(s, e) {
|
|
946
1115
|
let t;
|
|
947
|
-
const
|
|
1116
|
+
const r = () => {
|
|
948
1117
|
if (!t) {
|
|
949
|
-
const
|
|
1118
|
+
const i = {};
|
|
950
1119
|
e.forEach((n, a) => {
|
|
951
|
-
|
|
952
|
-
}), t =
|
|
1120
|
+
i[a] = n && B(n) ? n.getProxy() : n;
|
|
1121
|
+
}), t = i;
|
|
953
1122
|
}
|
|
954
1123
|
return t;
|
|
955
1124
|
};
|
|
956
|
-
return new Proxy(
|
|
957
|
-
get: (
|
|
1125
|
+
return new Proxy(s, {
|
|
1126
|
+
get: (i, n) => {
|
|
958
1127
|
if (n === U)
|
|
959
|
-
return
|
|
960
|
-
if (n in
|
|
961
|
-
return
|
|
1128
|
+
return r();
|
|
1129
|
+
if (n in i)
|
|
1130
|
+
return i[n];
|
|
962
1131
|
if (typeof n == "string" && e.has(n)) {
|
|
963
1132
|
const a = e.get(n);
|
|
964
|
-
return a &&
|
|
1133
|
+
return a && B(a) ? a.getProxy() : a;
|
|
965
1134
|
}
|
|
966
1135
|
},
|
|
967
|
-
set: (
|
|
968
|
-
has: (
|
|
969
|
-
ownKeys: (
|
|
970
|
-
const n = Reflect.ownKeys(
|
|
1136
|
+
set: (i, n, a) => typeof n == "string" && e.has(n) ? !1 : (i[n] = a, !0),
|
|
1137
|
+
has: (i, n) => n === U || typeof n == "string" && e.has(n) ? !0 : n in i,
|
|
1138
|
+
ownKeys: (i) => {
|
|
1139
|
+
const n = Reflect.ownKeys(i), a = Array.from(e.keys());
|
|
971
1140
|
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
972
1141
|
},
|
|
973
|
-
getOwnPropertyDescriptor: (
|
|
1142
|
+
getOwnPropertyDescriptor: (i, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, n)
|
|
974
1143
|
});
|
|
975
1144
|
}
|
|
976
|
-
class
|
|
1145
|
+
class he {
|
|
977
1146
|
/**
|
|
978
1147
|
* @param form - Форма для отправки
|
|
979
1148
|
*/
|
|
@@ -983,7 +1152,7 @@ class oe {
|
|
|
983
1152
|
/** Внутренний сигнал состояния отправки */
|
|
984
1153
|
_submitting = g(!1);
|
|
985
1154
|
/** Публичный read-only сигнал состояния отправки */
|
|
986
|
-
submitting =
|
|
1155
|
+
submitting = m(() => this._submitting.value);
|
|
987
1156
|
/**
|
|
988
1157
|
* Отправить форму
|
|
989
1158
|
*
|
|
@@ -1018,8 +1187,8 @@ class oe {
|
|
|
1018
1187
|
* ```
|
|
1019
1188
|
*/
|
|
1020
1189
|
async submit(e, t) {
|
|
1021
|
-
const { skipValidation:
|
|
1022
|
-
if (
|
|
1190
|
+
const { skipValidation: r = !1, skipTouch: i = !1 } = t || {};
|
|
1191
|
+
if (i || this.form.markAsTouched(), !r && !await this.form.validate())
|
|
1023
1192
|
return null;
|
|
1024
1193
|
this._submitting.value = !0;
|
|
1025
1194
|
try {
|
|
@@ -1053,8 +1222,8 @@ class oe {
|
|
|
1053
1222
|
* ```
|
|
1054
1223
|
*/
|
|
1055
1224
|
async submitWithResult(e, t) {
|
|
1056
|
-
const { skipValidation:
|
|
1057
|
-
if (
|
|
1225
|
+
const { skipValidation: r = !1, skipTouch: i = !1 } = t || {};
|
|
1226
|
+
if (i || this.form.markAsTouched(), !r && !await this.form.validate())
|
|
1058
1227
|
return { success: !1, data: null };
|
|
1059
1228
|
this._submitting.value = !0;
|
|
1060
1229
|
try {
|
|
@@ -1070,12 +1239,12 @@ class oe {
|
|
|
1070
1239
|
}
|
|
1071
1240
|
}
|
|
1072
1241
|
}
|
|
1073
|
-
function
|
|
1242
|
+
function fe(s) {
|
|
1074
1243
|
const e = [];
|
|
1075
|
-
for (const t of
|
|
1076
|
-
const
|
|
1077
|
-
if (!
|
|
1078
|
-
e.push(
|
|
1244
|
+
for (const t of s.split(".")) {
|
|
1245
|
+
const r = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1246
|
+
if (!r) return [];
|
|
1247
|
+
e.push(r[2] !== void 0 ? { key: r[1], index: Number(r[2]) } : { key: r[1] });
|
|
1079
1248
|
}
|
|
1080
1249
|
return e;
|
|
1081
1250
|
}
|
|
@@ -1092,7 +1261,7 @@ class A extends M {
|
|
|
1092
1261
|
/**
|
|
1093
1262
|
* Менеджер подписок для централизованного cleanup
|
|
1094
1263
|
*/
|
|
1095
|
-
disposers = new
|
|
1264
|
+
disposers = new L();
|
|
1096
1265
|
/**
|
|
1097
1266
|
* Ссылка на Proxy-инстанс
|
|
1098
1267
|
*/
|
|
@@ -1104,7 +1273,7 @@ class A extends M {
|
|
|
1104
1273
|
/**
|
|
1105
1274
|
* Фабрика для создания узлов формы
|
|
1106
1275
|
*/
|
|
1107
|
-
nodeFactory = new
|
|
1276
|
+
nodeFactory = new ve();
|
|
1108
1277
|
// ============================================================================
|
|
1109
1278
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1110
1279
|
// ============================================================================
|
|
@@ -1135,19 +1304,19 @@ class A extends M {
|
|
|
1135
1304
|
status;
|
|
1136
1305
|
submitting;
|
|
1137
1306
|
constructor(e) {
|
|
1138
|
-
super(), this.formSubmitter = new
|
|
1139
|
-
const t = e.form,
|
|
1307
|
+
super(), this.formSubmitter = new he(this);
|
|
1308
|
+
const t = e.form, r = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !r ? e.form : e;
|
|
1140
1309
|
for (const [l, d] of Object.entries(n)) {
|
|
1141
1310
|
const u = this.createNode(d);
|
|
1142
1311
|
this._fields.set(l, u);
|
|
1143
1312
|
}
|
|
1144
|
-
this.value =
|
|
1313
|
+
this.value = m(() => {
|
|
1145
1314
|
const l = {};
|
|
1146
1315
|
return this._fields.forEach((d, u) => {
|
|
1147
1316
|
l[u] = d.value.value;
|
|
1148
1317
|
}), l;
|
|
1149
1318
|
});
|
|
1150
|
-
const a =
|
|
1319
|
+
const a = R({
|
|
1151
1320
|
getChildren: () => Array.from(this._fields.values()),
|
|
1152
1321
|
ownErrors: this._formErrors,
|
|
1153
1322
|
disabled: this._disabled
|
|
@@ -1162,35 +1331,35 @@ class A extends M {
|
|
|
1162
1331
|
* @see buildFormProxy
|
|
1163
1332
|
*/
|
|
1164
1333
|
buildProxy() {
|
|
1165
|
-
return
|
|
1334
|
+
return ce(this, this._fields);
|
|
1166
1335
|
}
|
|
1167
1336
|
// ============================================================================
|
|
1168
1337
|
// Реализация абстрактных методов FormNode
|
|
1169
1338
|
// ============================================================================
|
|
1170
1339
|
getValue() {
|
|
1171
1340
|
const e = {};
|
|
1172
|
-
return this._fields.forEach((t,
|
|
1173
|
-
e[
|
|
1341
|
+
return this._fields.forEach((t, r) => {
|
|
1342
|
+
e[r] = t.getValue();
|
|
1174
1343
|
}), e;
|
|
1175
1344
|
}
|
|
1176
1345
|
setValue(e, t) {
|
|
1177
|
-
for (const [
|
|
1178
|
-
const n = this._fields.get(
|
|
1346
|
+
for (const [r, i] of Object.entries(e)) {
|
|
1347
|
+
const n = this._fields.get(r);
|
|
1179
1348
|
if (n) {
|
|
1180
1349
|
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1181
|
-
if (
|
|
1182
|
-
n.setValue(
|
|
1350
|
+
if (G(a)) continue;
|
|
1351
|
+
n.setValue(i, t);
|
|
1183
1352
|
}
|
|
1184
1353
|
}
|
|
1185
1354
|
}
|
|
1186
1355
|
patchValue(e) {
|
|
1187
|
-
|
|
1188
|
-
for (const [t,
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1191
|
-
const n = this._fieldSignals.get(
|
|
1192
|
-
if (
|
|
1193
|
-
|
|
1356
|
+
te(() => {
|
|
1357
|
+
for (const [t, r] of Object.entries(e)) {
|
|
1358
|
+
const i = this._fields.get(t);
|
|
1359
|
+
if (i && r !== void 0) {
|
|
1360
|
+
const n = this._fieldSignals.get(i) ?? i.value;
|
|
1361
|
+
if (G(n)) continue;
|
|
1362
|
+
i.setValue(r, { emitEvent: !1 });
|
|
1194
1363
|
}
|
|
1195
1364
|
}
|
|
1196
1365
|
});
|
|
@@ -1213,9 +1382,9 @@ class A extends M {
|
|
|
1213
1382
|
* ```
|
|
1214
1383
|
*/
|
|
1215
1384
|
reset(e) {
|
|
1216
|
-
this._formErrors.value = [], this._fields.forEach((t,
|
|
1217
|
-
const
|
|
1218
|
-
t.reset(
|
|
1385
|
+
this._formErrors.value = [], this._fields.forEach((t, r) => {
|
|
1386
|
+
const i = e?.[r];
|
|
1387
|
+
t.reset(i);
|
|
1219
1388
|
});
|
|
1220
1389
|
}
|
|
1221
1390
|
/**
|
|
@@ -1359,21 +1528,21 @@ class A extends M {
|
|
|
1359
1528
|
getFieldByPath(e) {
|
|
1360
1529
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1361
1530
|
return;
|
|
1362
|
-
const t =
|
|
1531
|
+
const t = fe(e);
|
|
1363
1532
|
if (t.length === 0)
|
|
1364
1533
|
return;
|
|
1365
|
-
let
|
|
1366
|
-
for (const
|
|
1367
|
-
if (!(
|
|
1368
|
-
if (
|
|
1369
|
-
if ("at" in
|
|
1370
|
-
const n =
|
|
1534
|
+
let r = this;
|
|
1535
|
+
for (const i of t) {
|
|
1536
|
+
if (!(r instanceof A) || (r = r.getField(i.key), !r)) return;
|
|
1537
|
+
if (i.index !== void 0)
|
|
1538
|
+
if ("at" in r && "length" in r && typeof r.at == "function") {
|
|
1539
|
+
const n = r.at(i.index);
|
|
1371
1540
|
if (!n) return;
|
|
1372
|
-
|
|
1541
|
+
r = n;
|
|
1373
1542
|
} else
|
|
1374
1543
|
return;
|
|
1375
1544
|
}
|
|
1376
|
-
return
|
|
1545
|
+
return r;
|
|
1377
1546
|
}
|
|
1378
1547
|
// ============================================================================
|
|
1379
1548
|
// Private методы для создания узлов
|
|
@@ -1402,14 +1571,14 @@ class A extends M {
|
|
|
1402
1571
|
/**
|
|
1403
1572
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1404
1573
|
*/
|
|
1405
|
-
linkFields(e, t,
|
|
1406
|
-
const
|
|
1407
|
-
if (!
|
|
1408
|
-
const d =
|
|
1574
|
+
linkFields(e, t, r) {
|
|
1575
|
+
const i = this._fields.get(e), n = this._fields.get(t);
|
|
1576
|
+
if (!i || !n) {
|
|
1577
|
+
const d = i ? t : e;
|
|
1409
1578
|
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1410
1579
|
}
|
|
1411
1580
|
const a = _(() => {
|
|
1412
|
-
const d =
|
|
1581
|
+
const d = i.value.value, u = r ? r(d) : d;
|
|
1413
1582
|
n.setValue(u, { emitEvent: !1 });
|
|
1414
1583
|
}), l = N(O.LinkFields);
|
|
1415
1584
|
return this.disposers.add(l, a);
|
|
@@ -1443,26 +1612,26 @@ class A extends M {
|
|
|
1443
1612
|
*/
|
|
1444
1613
|
/** Подписка на top-level поле — value типизирован как `T[K]`. */
|
|
1445
1614
|
watchField(e, t) {
|
|
1446
|
-
const
|
|
1447
|
-
if (!
|
|
1615
|
+
const r = this.getFieldByPath(e);
|
|
1616
|
+
if (!r)
|
|
1448
1617
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1449
|
-
const
|
|
1450
|
-
t(
|
|
1618
|
+
const i = _(() => {
|
|
1619
|
+
t(r.value.value);
|
|
1451
1620
|
}), n = N(O.WatchField);
|
|
1452
|
-
return this.disposers.add(n,
|
|
1621
|
+
return this.disposers.add(n, i);
|
|
1453
1622
|
}
|
|
1454
1623
|
/**
|
|
1455
1624
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
1456
1625
|
* Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
|
|
1457
1626
|
*/
|
|
1458
1627
|
watchFieldByPath(e, t) {
|
|
1459
|
-
const
|
|
1460
|
-
if (!
|
|
1628
|
+
const r = this.getFieldByPath(e);
|
|
1629
|
+
if (!r)
|
|
1461
1630
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1462
|
-
const
|
|
1463
|
-
t(
|
|
1631
|
+
const i = _(() => {
|
|
1632
|
+
t(r.value.value);
|
|
1464
1633
|
}), n = N(O.WatchField);
|
|
1465
|
-
return this.disposers.add(n,
|
|
1634
|
+
return this.disposers.add(n, i);
|
|
1466
1635
|
}
|
|
1467
1636
|
/**
|
|
1468
1637
|
* Hook: вызывается после disable()
|
|
@@ -1501,7 +1670,7 @@ class A extends M {
|
|
|
1501
1670
|
});
|
|
1502
1671
|
}
|
|
1503
1672
|
}
|
|
1504
|
-
class
|
|
1673
|
+
class W extends M {
|
|
1505
1674
|
// ============================================================================
|
|
1506
1675
|
// Приватные поля
|
|
1507
1676
|
// ============================================================================
|
|
@@ -1512,7 +1681,7 @@ class B extends M {
|
|
|
1512
1681
|
* Менеджер подписок для централизованного cleanup
|
|
1513
1682
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1514
1683
|
*/
|
|
1515
|
-
disposers = new
|
|
1684
|
+
disposers = new L();
|
|
1516
1685
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1517
1686
|
_arrayErrors = g([]);
|
|
1518
1687
|
// ============================================================================
|
|
@@ -1532,14 +1701,14 @@ class B extends M {
|
|
|
1532
1701
|
// ============================================================================
|
|
1533
1702
|
constructor(e, t = []) {
|
|
1534
1703
|
super(), this.itemSchema = e, this.initialItems = t, this.items = g([]);
|
|
1535
|
-
for (const
|
|
1536
|
-
this.push(
|
|
1537
|
-
this.length =
|
|
1538
|
-
const
|
|
1704
|
+
for (const i of t)
|
|
1705
|
+
this.push(i);
|
|
1706
|
+
this.length = m(() => this.items.value.length), this.value = m(() => this.items.value.map((i) => i.value.value));
|
|
1707
|
+
const r = R({
|
|
1539
1708
|
getChildren: () => this.items.value,
|
|
1540
1709
|
ownErrors: this._arrayErrors
|
|
1541
1710
|
});
|
|
1542
|
-
this.valid =
|
|
1711
|
+
this.valid = r.valid, this.invalid = r.invalid, this.pending = r.pending, this.touched = r.touched, this.dirty = r.dirty, this.errors = r.errors, this.status = r.status;
|
|
1543
1712
|
}
|
|
1544
1713
|
// ============================================================================
|
|
1545
1714
|
// CRUD операции
|
|
@@ -1561,7 +1730,7 @@ class B extends M {
|
|
|
1561
1730
|
*/
|
|
1562
1731
|
removeAt(e) {
|
|
1563
1732
|
if (e < 0 || e >= this.items.value.length) {
|
|
1564
|
-
|
|
1733
|
+
V.handle(
|
|
1565
1734
|
new Error(
|
|
1566
1735
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1567
1736
|
),
|
|
@@ -1571,7 +1740,7 @@ class B extends M {
|
|
|
1571
1740
|
return;
|
|
1572
1741
|
}
|
|
1573
1742
|
const t = this.items.value[e];
|
|
1574
|
-
this.items.value = this.items.value.filter((
|
|
1743
|
+
this.items.value = this.items.value.filter((r, i) => i !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1575
1744
|
}
|
|
1576
1745
|
/**
|
|
1577
1746
|
* Вставить элемент в массив
|
|
@@ -1580,7 +1749,7 @@ class B extends M {
|
|
|
1580
1749
|
*/
|
|
1581
1750
|
insert(e, t) {
|
|
1582
1751
|
if (e < 0 || e > this.items.value.length) {
|
|
1583
|
-
|
|
1752
|
+
V.handle(
|
|
1584
1753
|
new Error(
|
|
1585
1754
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1586
1755
|
),
|
|
@@ -1589,8 +1758,8 @@ class B extends M {
|
|
|
1589
1758
|
);
|
|
1590
1759
|
return;
|
|
1591
1760
|
}
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1761
|
+
const r = this.createItem(t), i = [...this.items.value];
|
|
1762
|
+
i.splice(e, 0, r), this.items.value = i;
|
|
1594
1763
|
}
|
|
1595
1764
|
/**
|
|
1596
1765
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1609,18 +1778,18 @@ class B extends M {
|
|
|
1609
1778
|
* ```
|
|
1610
1779
|
*/
|
|
1611
1780
|
move(e, t) {
|
|
1612
|
-
const
|
|
1613
|
-
if (e < 0 || e >=
|
|
1614
|
-
|
|
1615
|
-
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${
|
|
1781
|
+
const r = this.items.value.length;
|
|
1782
|
+
if (e < 0 || e >= r || t < 0 || t >= r) {
|
|
1783
|
+
V.handle(
|
|
1784
|
+
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${r})`),
|
|
1616
1785
|
"ArrayNode.move",
|
|
1617
1786
|
S.LOG
|
|
1618
1787
|
);
|
|
1619
1788
|
return;
|
|
1620
1789
|
}
|
|
1621
1790
|
if (e === t) return;
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1791
|
+
const i = [...this.items.value], [n] = i.splice(e, 1);
|
|
1792
|
+
i.splice(t, 0, n), this.items.value = i;
|
|
1624
1793
|
}
|
|
1625
1794
|
/**
|
|
1626
1795
|
* Поменять местами два элемента массива
|
|
@@ -1637,18 +1806,18 @@ class B extends M {
|
|
|
1637
1806
|
* ```
|
|
1638
1807
|
*/
|
|
1639
1808
|
swap(e, t) {
|
|
1640
|
-
const
|
|
1641
|
-
if (e < 0 || e >=
|
|
1642
|
-
|
|
1643
|
-
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${
|
|
1809
|
+
const r = this.items.value.length;
|
|
1810
|
+
if (e < 0 || e >= r || t < 0 || t >= r) {
|
|
1811
|
+
V.handle(
|
|
1812
|
+
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${r})`),
|
|
1644
1813
|
"ArrayNode.swap",
|
|
1645
1814
|
S.LOG
|
|
1646
1815
|
);
|
|
1647
1816
|
return;
|
|
1648
1817
|
}
|
|
1649
1818
|
if (e === t) return;
|
|
1650
|
-
const
|
|
1651
|
-
[
|
|
1819
|
+
const i = [...this.items.value];
|
|
1820
|
+
[i[e], i[t]] = [i[t], i[e]], this.items.value = i;
|
|
1652
1821
|
}
|
|
1653
1822
|
/**
|
|
1654
1823
|
* Удалить все элементы массива
|
|
@@ -1679,13 +1848,13 @@ class B extends M {
|
|
|
1679
1848
|
return this.items.value.map((e) => e.getValue());
|
|
1680
1849
|
}
|
|
1681
1850
|
setValue(e, t) {
|
|
1682
|
-
this.clear(), e.forEach((
|
|
1683
|
-
|
|
1851
|
+
this.clear(), e.forEach((r) => this.push(r)), t?.emitEvent !== !1 && this.validate().catch((r) => {
|
|
1852
|
+
V.handle(r, "ArrayNode.setValue", S.LOG);
|
|
1684
1853
|
});
|
|
1685
1854
|
}
|
|
1686
1855
|
patchValue(e) {
|
|
1687
|
-
e.forEach((t,
|
|
1688
|
-
this.items.value[
|
|
1856
|
+
e.forEach((t, r) => {
|
|
1857
|
+
this.items.value[r] && t !== void 0 && this.items.value[r].patchValue(t);
|
|
1689
1858
|
});
|
|
1690
1859
|
}
|
|
1691
1860
|
/**
|
|
@@ -1813,9 +1982,9 @@ class B extends M {
|
|
|
1813
1982
|
* @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
|
|
1814
1983
|
*/
|
|
1815
1984
|
forEach(e) {
|
|
1816
|
-
this.items.value.forEach((t,
|
|
1817
|
-
const
|
|
1818
|
-
e(
|
|
1985
|
+
this.items.value.forEach((t, r) => {
|
|
1986
|
+
const i = t.getProxy();
|
|
1987
|
+
e(i, r);
|
|
1819
1988
|
});
|
|
1820
1989
|
}
|
|
1821
1990
|
/**
|
|
@@ -1824,9 +1993,9 @@ class B extends M {
|
|
|
1824
1993
|
* @returns Новый массив результатов
|
|
1825
1994
|
*/
|
|
1826
1995
|
map(e) {
|
|
1827
|
-
return this.items.value.map((t,
|
|
1828
|
-
const
|
|
1829
|
-
return e(
|
|
1996
|
+
return this.items.value.map((t, r) => {
|
|
1997
|
+
const i = t.getProxy();
|
|
1998
|
+
return e(i, r);
|
|
1830
1999
|
});
|
|
1831
2000
|
}
|
|
1832
2001
|
// ============================================================================
|
|
@@ -1916,7 +2085,7 @@ class B extends M {
|
|
|
1916
2085
|
});
|
|
1917
2086
|
}
|
|
1918
2087
|
}
|
|
1919
|
-
class
|
|
2088
|
+
class ve {
|
|
1920
2089
|
/**
|
|
1921
2090
|
* Создает узел формы на основе конфигурации
|
|
1922
2091
|
*
|
|
@@ -1966,9 +2135,9 @@ class ue {
|
|
|
1966
2135
|
if (Array.isArray(e) && e.length >= 1)
|
|
1967
2136
|
return this.createArrayNodeFromArray(e);
|
|
1968
2137
|
if (this.isFieldConfig(e))
|
|
1969
|
-
return new
|
|
2138
|
+
return new de(e);
|
|
1970
2139
|
if (this.isArrayConfig(e))
|
|
1971
|
-
return new
|
|
2140
|
+
return new W(
|
|
1972
2141
|
e.schema,
|
|
1973
2142
|
e.initialItems
|
|
1974
2143
|
);
|
|
@@ -2007,11 +2176,11 @@ class ue {
|
|
|
2007
2176
|
*/
|
|
2008
2177
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2009
2178
|
createArrayNodeFromArray(e) {
|
|
2010
|
-
const [t, ...
|
|
2011
|
-
this.isGroupConfig(t) &&
|
|
2012
|
-
for (const n of
|
|
2013
|
-
this.isGroupConfig(n) ?
|
|
2014
|
-
return new
|
|
2179
|
+
const [t, ...r] = e, i = [];
|
|
2180
|
+
this.isGroupConfig(t) && i.push(this.extractValues(t));
|
|
2181
|
+
for (const n of r)
|
|
2182
|
+
this.isGroupConfig(n) ? i.push(this.extractValues(n)) : i.push(n);
|
|
2183
|
+
return new W(t, i);
|
|
2015
2184
|
}
|
|
2016
2185
|
/**
|
|
2017
2186
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2049,8 +2218,8 @@ class ue {
|
|
|
2049
2218
|
return e.map((t) => this.extractValues(t));
|
|
2050
2219
|
if (this.isGroupConfig(e)) {
|
|
2051
2220
|
const t = {};
|
|
2052
|
-
for (const [
|
|
2053
|
-
t[
|
|
2221
|
+
for (const [r, i] of Object.entries(e))
|
|
2222
|
+
t[r] = this.extractValues(i);
|
|
2054
2223
|
return t;
|
|
2055
2224
|
}
|
|
2056
2225
|
return e;
|
|
@@ -2130,7 +2299,7 @@ class ue {
|
|
|
2130
2299
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2131
2300
|
}
|
|
2132
2301
|
}
|
|
2133
|
-
class
|
|
2302
|
+
class me extends M {
|
|
2134
2303
|
/**
|
|
2135
2304
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2136
2305
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
@@ -2138,26 +2307,26 @@ class de extends M {
|
|
|
2138
2307
|
*/
|
|
2139
2308
|
constructor(e, t) {
|
|
2140
2309
|
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = _(() => {
|
|
2141
|
-
const
|
|
2142
|
-
for (let u = 0; u <
|
|
2143
|
-
const
|
|
2144
|
-
if (!
|
|
2145
|
-
let o = this.cache.get(
|
|
2146
|
-
o || (o = t(
|
|
2310
|
+
const i = e.length, n = [], a = [];
|
|
2311
|
+
for (let u = 0; u < i; u++) {
|
|
2312
|
+
const h = e.at(u);
|
|
2313
|
+
if (!h) continue;
|
|
2314
|
+
let o = this.cache.get(h);
|
|
2315
|
+
o || (o = t(h), this.cache.set(h, o)), n.push(h), a.push(o);
|
|
2147
2316
|
}
|
|
2148
2317
|
const l = new Set(n), d = [];
|
|
2149
2318
|
for (const u of this.mountedModels) {
|
|
2150
2319
|
if (l.has(u)) continue;
|
|
2151
|
-
const
|
|
2152
|
-
this.cache.delete(u),
|
|
2320
|
+
const h = this.cache.get(u);
|
|
2321
|
+
this.cache.delete(u), h && d.push(h);
|
|
2153
2322
|
}
|
|
2154
2323
|
this.mountedModels = n, this.itemNodes.value = a, d.forEach((u) => this.disposeItemNode(u));
|
|
2155
|
-
}), this.length =
|
|
2156
|
-
const
|
|
2324
|
+
}), this.length = m(() => this.itemNodes.value.length), this.value = m(() => this.itemNodes.value.map((i) => i.value.value));
|
|
2325
|
+
const r = R({
|
|
2157
2326
|
getChildren: () => this.itemNodes.value,
|
|
2158
2327
|
ownErrors: this._arrayErrors
|
|
2159
2328
|
});
|
|
2160
|
-
this.valid =
|
|
2329
|
+
this.valid = r.valid, this.invalid = r.invalid, this.pending = r.pending, this.touched = r.touched, this.dirty = r.dirty, this.errors = r.errors, this.status = r.status;
|
|
2161
2330
|
}
|
|
2162
2331
|
itemNodes = g([]);
|
|
2163
2332
|
// Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
|
|
@@ -2189,10 +2358,10 @@ class de extends M {
|
|
|
2189
2358
|
return this.itemNodes.value[e];
|
|
2190
2359
|
}
|
|
2191
2360
|
map(e) {
|
|
2192
|
-
return this.itemNodes.value.map((t,
|
|
2361
|
+
return this.itemNodes.value.map((t, r) => e(t, r));
|
|
2193
2362
|
}
|
|
2194
2363
|
forEach(e) {
|
|
2195
|
-
this.itemNodes.value.forEach((t,
|
|
2364
|
+
this.itemNodes.value.forEach((t, r) => e(t, r));
|
|
2196
2365
|
}
|
|
2197
2366
|
// ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
|
|
2198
2367
|
push(e) {
|
|
@@ -2292,170 +2461,217 @@ class de extends M {
|
|
|
2292
2461
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2293
2462
|
}
|
|
2294
2463
|
}
|
|
2295
|
-
const
|
|
2296
|
-
function
|
|
2297
|
-
if (
|
|
2298
|
-
if (
|
|
2299
|
-
|
|
2464
|
+
const J = (s) => s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(typeof Blob < "u" && s instanceof Blob) && !(typeof File < "u" && s instanceof File);
|
|
2465
|
+
function I(s, e, t) {
|
|
2466
|
+
if (s == null || typeof s != "object" || s instanceof j) return;
|
|
2467
|
+
if (typeof s.getProxy == "function") {
|
|
2468
|
+
process.env.NODE_ENV !== "production" && console.warn(
|
|
2469
|
+
"[reformer] createForm({ schema }): в схему попал узел формы (FormProxy) — он пропущен. Стройте дерево для createForm БЕЗ формы, а форму донесите до узла вторым проходом (билдер `(model, form?) => …`) либо через render-behavior `patchProps({ form })`."
|
|
2470
|
+
);
|
|
2300
2471
|
return;
|
|
2301
2472
|
}
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
t.set(r.__path, s.item);
|
|
2473
|
+
if (Array.isArray(s)) {
|
|
2474
|
+
for (const n of s) I(n, e, t);
|
|
2305
2475
|
return;
|
|
2306
2476
|
}
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2477
|
+
const r = s, i = r.array;
|
|
2478
|
+
if (i && typeof i.__path == "string" && typeof r.item == "function") {
|
|
2479
|
+
t.set(i.__path, r.item);
|
|
2480
|
+
return;
|
|
2481
|
+
}
|
|
2482
|
+
r.value instanceof j ? e.set(r.value, {
|
|
2483
|
+
component: r.component,
|
|
2484
|
+
componentProps: r.componentProps,
|
|
2485
|
+
updateOn: r.updateOn,
|
|
2486
|
+
disabled: r.disabled,
|
|
2487
|
+
debounce: r.debounce
|
|
2488
|
+
}) : process.env.NODE_ENV !== "production" && r.component !== void 0 && ("valueSignal" in r || r.value != null) && console.warn(
|
|
2314
2489
|
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2315
2490
|
);
|
|
2316
|
-
for (const [n, a] of Object.entries(
|
|
2317
|
-
n !== "value" &&
|
|
2491
|
+
for (const [n, a] of Object.entries(r))
|
|
2492
|
+
n !== "value" && I(a, e, t);
|
|
2318
2493
|
}
|
|
2319
|
-
function
|
|
2320
|
-
const
|
|
2494
|
+
function Q(s, e, t, r) {
|
|
2495
|
+
const i = {};
|
|
2321
2496
|
for (const [n, a] of Object.entries(e)) {
|
|
2322
2497
|
const l = t === "" ? n : `${t}.${n}`;
|
|
2323
2498
|
if (Array.isArray(a))
|
|
2324
2499
|
continue;
|
|
2325
|
-
if (
|
|
2326
|
-
|
|
2500
|
+
if (J(a)) {
|
|
2501
|
+
i[n] = Q(s, a, l, r);
|
|
2327
2502
|
continue;
|
|
2328
2503
|
}
|
|
2329
|
-
const d =
|
|
2504
|
+
const d = s.signalAt(l);
|
|
2330
2505
|
if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2331
|
-
const u =
|
|
2332
|
-
|
|
2506
|
+
const u = r.get(d) ?? {};
|
|
2507
|
+
i[n] = { ...u, valueSignal: d };
|
|
2333
2508
|
}
|
|
2334
|
-
return
|
|
2509
|
+
return i;
|
|
2335
2510
|
}
|
|
2336
|
-
function
|
|
2337
|
-
for (const [
|
|
2338
|
-
const n = e === "" ?
|
|
2339
|
-
Array.isArray(
|
|
2511
|
+
function X(s, e, t) {
|
|
2512
|
+
for (const [r, i] of Object.entries(s)) {
|
|
2513
|
+
const n = e === "" ? r : `${e}.${r}`;
|
|
2514
|
+
Array.isArray(i) || (J(i) ? X(i, n, t) : t.push(n));
|
|
2340
2515
|
}
|
|
2341
2516
|
}
|
|
2342
|
-
function
|
|
2343
|
-
const { model: e, schema: t, behavior:
|
|
2344
|
-
t !== void 0 &&
|
|
2345
|
-
const a =
|
|
2346
|
-
for (const [o,
|
|
2347
|
-
if (!Array.isArray(
|
|
2517
|
+
function Z(s) {
|
|
2518
|
+
const { model: e, schema: t, behavior: r } = s, i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2519
|
+
t !== void 0 && I(t, i, n);
|
|
2520
|
+
const a = Q(e, e.get(), "", i), l = new A(a), d = e.get();
|
|
2521
|
+
for (const [o, f] of Object.entries(d)) {
|
|
2522
|
+
if (!Array.isArray(f)) continue;
|
|
2348
2523
|
const c = n.get(o);
|
|
2349
2524
|
if (!c) continue;
|
|
2350
|
-
const
|
|
2351
|
-
l.fields.set(o,
|
|
2352
|
-
}
|
|
2353
|
-
const u = l.getProxy(),
|
|
2354
|
-
|
|
2355
|
-
for (const o of
|
|
2356
|
-
const
|
|
2357
|
-
if (
|
|
2358
|
-
|
|
2359
|
-
const
|
|
2360
|
-
p instanceof A && p.registerFieldSignal(c,
|
|
2525
|
+
const v = e[o], p = (y) => Z({ model: y, schema: c(y) }), b = new me(v, p);
|
|
2526
|
+
l.fields.set(o, b);
|
|
2527
|
+
}
|
|
2528
|
+
const u = l.getProxy(), h = [];
|
|
2529
|
+
X(e.get(), "", h);
|
|
2530
|
+
for (const o of h) {
|
|
2531
|
+
const f = e.signalAt(o), c = l.getFieldByPath(o);
|
|
2532
|
+
if (f && c) {
|
|
2533
|
+
se(f, c);
|
|
2534
|
+
const v = o.lastIndexOf("."), p = v === -1 ? l : l.getFieldByPath(o.slice(0, v));
|
|
2535
|
+
p instanceof A && p.registerFieldSignal(c, f);
|
|
2361
2536
|
}
|
|
2362
2537
|
}
|
|
2363
|
-
return
|
|
2538
|
+
return r && l.attachBehaviorCleanup(r.__run(e, u)), u;
|
|
2539
|
+
}
|
|
2540
|
+
const pe = (s) => s != null && typeof s == "object" && "model" in s && typeof s.model?.signalAt == "function";
|
|
2541
|
+
function ye(s) {
|
|
2542
|
+
return pe(s) ? Z(s) : new A(s).getProxy();
|
|
2364
2543
|
}
|
|
2365
|
-
const
|
|
2366
|
-
|
|
2367
|
-
|
|
2544
|
+
const ge = () => {
|
|
2545
|
+
};
|
|
2546
|
+
function be(s, e) {
|
|
2547
|
+
if (!e) return;
|
|
2548
|
+
const t = typeof e == "function" ? { schema: e } : e, r = Object.keys(t.steps ?? {}), i = r.map((o) => t.steps?.[o]).filter((o) => o != null), n = t.schema ?? re(
|
|
2549
|
+
() => ne(...i, ...t.extras ? [t.extras] : [])
|
|
2550
|
+
), a = (o) => {
|
|
2551
|
+
const f = typeof o == "number" ? r[o - 1] : o;
|
|
2552
|
+
return (f != null ? t.steps?.[f] : null) ?? null;
|
|
2553
|
+
}, { strategy: l, debounce: d, liveAfterSubmit: u } = t, h = D(s, n, {
|
|
2554
|
+
strategy: l,
|
|
2555
|
+
debounce: d,
|
|
2556
|
+
liveAfterSubmit: u
|
|
2557
|
+
});
|
|
2558
|
+
return {
|
|
2559
|
+
schema: n,
|
|
2560
|
+
stepSelectors: r,
|
|
2561
|
+
validate: () => h.validate(),
|
|
2562
|
+
validateAll: () => h.validate(),
|
|
2563
|
+
validateStep: (o) => ie(s, a(o) ?? ge, { touch: !0 }),
|
|
2564
|
+
createStepController: (o) => {
|
|
2565
|
+
if (!l || l === "submit") return null;
|
|
2566
|
+
const f = a(o);
|
|
2567
|
+
return f ? D(s, f, { strategy: l, debounce: d, liveAfterSubmit: u }) : null;
|
|
2568
|
+
},
|
|
2569
|
+
controller: h,
|
|
2570
|
+
validating: h.validating
|
|
2571
|
+
};
|
|
2368
2572
|
}
|
|
2369
|
-
function
|
|
2370
|
-
|
|
2573
|
+
function Ie(s) {
|
|
2574
|
+
if (!s.model && s.initial === void 0)
|
|
2575
|
+
throw new Error("createCoreForm: provide either `initial` (to create a model) or `model`.");
|
|
2576
|
+
const e = s.model ?? ee(s.initial);
|
|
2577
|
+
s.seed?.(e);
|
|
2578
|
+
const t = ye({
|
|
2579
|
+
model: e,
|
|
2580
|
+
...s.schema ? { schema: s.schema(e) } : {},
|
|
2581
|
+
...s.behavior ? { behavior: s.behavior } : {}
|
|
2582
|
+
}), r = be(e, s.validation), i = { model: e, form: t, ...r ? { validation: r } : {} };
|
|
2583
|
+
return s.setup?.(i), i;
|
|
2371
2584
|
}
|
|
2372
|
-
function
|
|
2373
|
-
return
|
|
2585
|
+
function x(s) {
|
|
2586
|
+
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2587
|
+
}
|
|
2588
|
+
function Ee(s) {
|
|
2589
|
+
return x(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
|
|
2374
2590
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2375
|
-
typeof
|
|
2376
|
-
!("fields" in
|
|
2591
|
+
typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2592
|
+
!("fields" in s) && !("items" in s);
|
|
2377
2593
|
}
|
|
2378
|
-
function
|
|
2379
|
-
return
|
|
2380
|
-
!("items" in
|
|
2594
|
+
function _e(s) {
|
|
2595
|
+
return x(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2596
|
+
!("items" in s) && !("push" in s) && !("removeAt" in s);
|
|
2381
2597
|
}
|
|
2382
|
-
function
|
|
2383
|
-
return
|
|
2384
|
-
typeof
|
|
2385
|
-
typeof
|
|
2598
|
+
function Se(s) {
|
|
2599
|
+
return x(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
|
|
2600
|
+
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2601
|
+
typeof s.removeAt == "function";
|
|
2386
2602
|
}
|
|
2387
|
-
function
|
|
2388
|
-
return
|
|
2603
|
+
function Le(s) {
|
|
2604
|
+
return Ee(s) ? "FieldNode" : _e(s) ? "GroupNode" : Se(s) ? "ArrayNode" : x(s) ? "FormNode" : "Unknown";
|
|
2389
2605
|
}
|
|
2390
2606
|
var F = { exports: {} }, P = {};
|
|
2391
|
-
var
|
|
2392
|
-
function
|
|
2393
|
-
if (
|
|
2394
|
-
|
|
2395
|
-
var
|
|
2396
|
-
function e(o,
|
|
2397
|
-
return o ===
|
|
2398
|
-
}
|
|
2399
|
-
var t = typeof Object.is == "function" ? Object.is : e,
|
|
2400
|
-
function l(o,
|
|
2401
|
-
var c =
|
|
2607
|
+
var q;
|
|
2608
|
+
function Ae() {
|
|
2609
|
+
if (q) return P;
|
|
2610
|
+
q = 1;
|
|
2611
|
+
var s = z;
|
|
2612
|
+
function e(o, f) {
|
|
2613
|
+
return o === f && (o !== 0 || 1 / o === 1 / f) || o !== o && f !== f;
|
|
2614
|
+
}
|
|
2615
|
+
var t = typeof Object.is == "function" ? Object.is : e, r = s.useState, i = s.useEffect, n = s.useLayoutEffect, a = s.useDebugValue;
|
|
2616
|
+
function l(o, f) {
|
|
2617
|
+
var c = f(), v = r({ inst: { value: c, getSnapshot: f } }), p = v[0].inst, b = v[1];
|
|
2402
2618
|
return n(
|
|
2403
2619
|
function() {
|
|
2404
|
-
p.value = c, p.getSnapshot =
|
|
2620
|
+
p.value = c, p.getSnapshot = f, d(p) && b({ inst: p });
|
|
2405
2621
|
},
|
|
2406
|
-
[o, c,
|
|
2407
|
-
),
|
|
2622
|
+
[o, c, f]
|
|
2623
|
+
), i(
|
|
2408
2624
|
function() {
|
|
2409
|
-
return d(p) &&
|
|
2410
|
-
d(p) &&
|
|
2625
|
+
return d(p) && b({ inst: p }), o(function() {
|
|
2626
|
+
d(p) && b({ inst: p });
|
|
2411
2627
|
});
|
|
2412
2628
|
},
|
|
2413
2629
|
[o]
|
|
2414
2630
|
), a(c), c;
|
|
2415
2631
|
}
|
|
2416
2632
|
function d(o) {
|
|
2417
|
-
var
|
|
2633
|
+
var f = o.getSnapshot;
|
|
2418
2634
|
o = o.value;
|
|
2419
2635
|
try {
|
|
2420
|
-
var c =
|
|
2636
|
+
var c = f();
|
|
2421
2637
|
return !t(o, c);
|
|
2422
2638
|
} catch {
|
|
2423
2639
|
return !0;
|
|
2424
2640
|
}
|
|
2425
2641
|
}
|
|
2426
|
-
function u(o,
|
|
2427
|
-
return
|
|
2642
|
+
function u(o, f) {
|
|
2643
|
+
return f();
|
|
2428
2644
|
}
|
|
2429
|
-
var
|
|
2430
|
-
return P.useSyncExternalStore =
|
|
2645
|
+
var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2646
|
+
return P.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : h, P;
|
|
2431
2647
|
}
|
|
2432
2648
|
var T = {};
|
|
2433
|
-
var
|
|
2434
|
-
function
|
|
2435
|
-
return
|
|
2436
|
-
function
|
|
2437
|
-
return c ===
|
|
2649
|
+
var K;
|
|
2650
|
+
function we() {
|
|
2651
|
+
return K || (K = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2652
|
+
function s(c, v) {
|
|
2653
|
+
return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
|
|
2438
2654
|
}
|
|
2439
|
-
function e(c,
|
|
2440
|
-
|
|
2655
|
+
function e(c, v) {
|
|
2656
|
+
h || i.startTransition === void 0 || (h = !0, console.error(
|
|
2441
2657
|
"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."
|
|
2442
2658
|
));
|
|
2443
|
-
var p =
|
|
2659
|
+
var p = v();
|
|
2444
2660
|
if (!o) {
|
|
2445
|
-
var
|
|
2446
|
-
n(p,
|
|
2661
|
+
var b = v();
|
|
2662
|
+
n(p, b) || (console.error(
|
|
2447
2663
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2448
2664
|
), o = !0);
|
|
2449
2665
|
}
|
|
2450
|
-
|
|
2451
|
-
inst: { value: p, getSnapshot:
|
|
2666
|
+
b = a({
|
|
2667
|
+
inst: { value: p, getSnapshot: v }
|
|
2452
2668
|
});
|
|
2453
|
-
var y =
|
|
2669
|
+
var y = b[0].inst, w = b[1];
|
|
2454
2670
|
return d(
|
|
2455
2671
|
function() {
|
|
2456
|
-
y.value = p, y.getSnapshot =
|
|
2672
|
+
y.value = p, y.getSnapshot = v, t(y) && w({ inst: y });
|
|
2457
2673
|
},
|
|
2458
|
-
[c, p,
|
|
2674
|
+
[c, p, v]
|
|
2459
2675
|
), l(
|
|
2460
2676
|
function() {
|
|
2461
2677
|
return t(y) && w({ inst: y }), c(function() {
|
|
@@ -2466,71 +2682,76 @@ function pe() {
|
|
|
2466
2682
|
), u(p), p;
|
|
2467
2683
|
}
|
|
2468
2684
|
function t(c) {
|
|
2469
|
-
var
|
|
2685
|
+
var v = c.getSnapshot;
|
|
2470
2686
|
c = c.value;
|
|
2471
2687
|
try {
|
|
2472
|
-
var p =
|
|
2688
|
+
var p = v();
|
|
2473
2689
|
return !n(c, p);
|
|
2474
2690
|
} catch {
|
|
2475
2691
|
return !0;
|
|
2476
2692
|
}
|
|
2477
2693
|
}
|
|
2478
|
-
function
|
|
2479
|
-
return
|
|
2694
|
+
function r(c, v) {
|
|
2695
|
+
return v();
|
|
2480
2696
|
}
|
|
2481
2697
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2482
|
-
var
|
|
2483
|
-
T.useSyncExternalStore =
|
|
2698
|
+
var i = z, n = typeof Object.is == "function" ? Object.is : s, a = i.useState, l = i.useEffect, d = i.useLayoutEffect, u = i.useDebugValue, h = !1, o = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
2699
|
+
T.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
2484
2700
|
})()), T;
|
|
2485
2701
|
}
|
|
2486
|
-
var
|
|
2487
|
-
function
|
|
2488
|
-
return
|
|
2702
|
+
var H;
|
|
2703
|
+
function Ve() {
|
|
2704
|
+
return H || (H = 1, process.env.NODE_ENV === "production" ? F.exports = Ae() : F.exports = we()), F.exports;
|
|
2489
2705
|
}
|
|
2490
|
-
var
|
|
2491
|
-
function
|
|
2492
|
-
if (
|
|
2493
|
-
if (
|
|
2494
|
-
for (let t = 0; t <
|
|
2495
|
-
if (
|
|
2706
|
+
var C = Ve();
|
|
2707
|
+
function ke(s, e) {
|
|
2708
|
+
if (s === e) return !0;
|
|
2709
|
+
if (s.length !== e.length) return !1;
|
|
2710
|
+
for (let t = 0; t < s.length; t++)
|
|
2711
|
+
if (s[t] !== e[t]) return !1;
|
|
2496
2712
|
return !0;
|
|
2497
2713
|
}
|
|
2498
|
-
function
|
|
2499
|
-
const
|
|
2500
|
-
n.current =
|
|
2501
|
-
const a =
|
|
2714
|
+
function $(s, e, t, r) {
|
|
2715
|
+
const i = k(null), n = k(s);
|
|
2716
|
+
n.current = s;
|
|
2717
|
+
const a = k(e);
|
|
2502
2718
|
a.current = e;
|
|
2503
|
-
const l =
|
|
2504
|
-
if (l.current = t,
|
|
2505
|
-
const
|
|
2506
|
-
for (const o in
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
}
|
|
2510
|
-
const d =
|
|
2511
|
-
(
|
|
2719
|
+
const l = k(t);
|
|
2720
|
+
if (l.current = t, i.current === null) {
|
|
2721
|
+
const h = {};
|
|
2722
|
+
for (const o in s)
|
|
2723
|
+
h[o] = s[o].value;
|
|
2724
|
+
i.current = { ...h, __snapshot: null };
|
|
2725
|
+
}
|
|
2726
|
+
const d = E(
|
|
2727
|
+
(h) => {
|
|
2512
2728
|
let o = !0;
|
|
2513
2729
|
return _(() => {
|
|
2514
2730
|
const c = n.current;
|
|
2515
|
-
for (const
|
|
2516
|
-
c[
|
|
2731
|
+
for (const v in c)
|
|
2732
|
+
c[v].value;
|
|
2517
2733
|
if (o) {
|
|
2518
2734
|
o = !1;
|
|
2519
2735
|
return;
|
|
2520
2736
|
}
|
|
2521
|
-
|
|
2737
|
+
h();
|
|
2522
2738
|
});
|
|
2523
2739
|
},
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2740
|
+
// subscriptionKey намеренно не читается в теле — он здесь КЛЮЧ ИДЕНТИЧНОСТИ подписки (см. JSDoc
|
|
2741
|
+
// параметра). Убрать его (как предлагает автофикс) значит получить subscribe, созданный один раз
|
|
2742
|
+
// навсегда: подмена контрола на другой узел перестанет пересоздавать effect. Тот же приём ниже
|
|
2743
|
+
// у getSnapshot.
|
|
2744
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2745
|
+
[r]
|
|
2746
|
+
), u = E(() => {
|
|
2747
|
+
const h = i.current, o = n.current, f = {};
|
|
2748
|
+
for (const v in o)
|
|
2749
|
+
f[v] = o[v].value;
|
|
2529
2750
|
let c = !1;
|
|
2530
|
-
for (const
|
|
2531
|
-
const { key: p, useShallowArrayEqual:
|
|
2532
|
-
if (
|
|
2533
|
-
if (!
|
|
2751
|
+
for (const v of a.current) {
|
|
2752
|
+
const { key: p, useShallowArrayEqual: b } = v, y = f[p], w = h[p];
|
|
2753
|
+
if (b) {
|
|
2754
|
+
if (!ke(w, y)) {
|
|
2534
2755
|
c = !0;
|
|
2535
2756
|
break;
|
|
2536
2757
|
}
|
|
@@ -2539,26 +2760,26 @@ function R(i, e, t, s) {
|
|
|
2539
2760
|
break;
|
|
2540
2761
|
}
|
|
2541
2762
|
}
|
|
2542
|
-
if (!c &&
|
|
2543
|
-
return
|
|
2544
|
-
for (const
|
|
2545
|
-
v
|
|
2546
|
-
return
|
|
2547
|
-
}, [
|
|
2548
|
-
return
|
|
2763
|
+
if (!c && h.__snapshot)
|
|
2764
|
+
return h.__snapshot;
|
|
2765
|
+
for (const v in o)
|
|
2766
|
+
h[v] = f[v];
|
|
2767
|
+
return h.__snapshot = l.current(f), h.__snapshot;
|
|
2768
|
+
}, [r]);
|
|
2769
|
+
return C.useSyncExternalStore(d, u, u);
|
|
2549
2770
|
}
|
|
2550
|
-
function
|
|
2771
|
+
function Oe(s) {
|
|
2551
2772
|
const e = {
|
|
2552
|
-
value:
|
|
2553
|
-
disabled:
|
|
2554
|
-
errors:
|
|
2555
|
-
pending:
|
|
2556
|
-
valid:
|
|
2557
|
-
invalid:
|
|
2558
|
-
touched:
|
|
2559
|
-
dirty:
|
|
2560
|
-
shouldShowError:
|
|
2561
|
-
componentProps:
|
|
2773
|
+
value: s.value,
|
|
2774
|
+
disabled: s.disabled,
|
|
2775
|
+
errors: s.errors,
|
|
2776
|
+
pending: s.pending,
|
|
2777
|
+
valid: s.valid,
|
|
2778
|
+
invalid: s.invalid,
|
|
2779
|
+
touched: s.touched,
|
|
2780
|
+
dirty: s.dirty,
|
|
2781
|
+
shouldShowError: s.shouldShowError,
|
|
2782
|
+
componentProps: s.componentProps
|
|
2562
2783
|
}, t = [
|
|
2563
2784
|
{ key: "value" },
|
|
2564
2785
|
{ key: "disabled" },
|
|
@@ -2570,34 +2791,34 @@ function Ee(i) {
|
|
|
2570
2791
|
{ key: "dirty" },
|
|
2571
2792
|
{ key: "shouldShowError" },
|
|
2572
2793
|
{ key: "componentProps" }
|
|
2573
|
-
],
|
|
2574
|
-
(
|
|
2575
|
-
value:
|
|
2576
|
-
pending:
|
|
2577
|
-
disabled:
|
|
2578
|
-
errors:
|
|
2579
|
-
valid:
|
|
2580
|
-
invalid:
|
|
2581
|
-
touched:
|
|
2582
|
-
dirty:
|
|
2583
|
-
shouldShowError:
|
|
2584
|
-
componentProps:
|
|
2794
|
+
], r = E(
|
|
2795
|
+
(i) => ({
|
|
2796
|
+
value: i.value,
|
|
2797
|
+
pending: i.pending,
|
|
2798
|
+
disabled: i.disabled,
|
|
2799
|
+
errors: i.errors,
|
|
2800
|
+
valid: i.valid,
|
|
2801
|
+
invalid: i.invalid,
|
|
2802
|
+
touched: i.touched,
|
|
2803
|
+
dirty: i.dirty,
|
|
2804
|
+
shouldShowError: i.shouldShowError,
|
|
2805
|
+
componentProps: i.componentProps
|
|
2585
2806
|
}),
|
|
2586
2807
|
[]
|
|
2587
2808
|
);
|
|
2588
|
-
return
|
|
2809
|
+
return $(e, t, r, s);
|
|
2589
2810
|
}
|
|
2590
|
-
function
|
|
2811
|
+
function Ne(s) {
|
|
2591
2812
|
const e = {
|
|
2592
|
-
value:
|
|
2593
|
-
length:
|
|
2594
|
-
errors:
|
|
2595
|
-
pending:
|
|
2596
|
-
valid:
|
|
2597
|
-
invalid:
|
|
2598
|
-
touched:
|
|
2599
|
-
dirty:
|
|
2600
|
-
disabled:
|
|
2813
|
+
value: s.value,
|
|
2814
|
+
length: s.length,
|
|
2815
|
+
errors: s.errors,
|
|
2816
|
+
pending: s.pending,
|
|
2817
|
+
valid: s.valid,
|
|
2818
|
+
invalid: s.invalid,
|
|
2819
|
+
touched: s.touched,
|
|
2820
|
+
dirty: s.dirty,
|
|
2821
|
+
disabled: s.disabled
|
|
2601
2822
|
}, t = [
|
|
2602
2823
|
{ key: "value" },
|
|
2603
2824
|
{ key: "length" },
|
|
@@ -2608,24 +2829,24 @@ function be(i) {
|
|
|
2608
2829
|
{ key: "touched" },
|
|
2609
2830
|
{ key: "dirty" },
|
|
2610
2831
|
{ key: "disabled" }
|
|
2611
|
-
],
|
|
2612
|
-
(
|
|
2613
|
-
value:
|
|
2614
|
-
length:
|
|
2615
|
-
pending:
|
|
2616
|
-
errors:
|
|
2617
|
-
valid:
|
|
2618
|
-
invalid:
|
|
2619
|
-
touched:
|
|
2620
|
-
dirty:
|
|
2621
|
-
disabled:
|
|
2832
|
+
], r = E(
|
|
2833
|
+
(i) => ({
|
|
2834
|
+
value: i.value,
|
|
2835
|
+
length: i.length,
|
|
2836
|
+
pending: i.pending,
|
|
2837
|
+
errors: i.errors,
|
|
2838
|
+
valid: i.valid,
|
|
2839
|
+
invalid: i.invalid,
|
|
2840
|
+
touched: i.touched,
|
|
2841
|
+
dirty: i.dirty,
|
|
2842
|
+
disabled: i.disabled
|
|
2622
2843
|
}),
|
|
2623
2844
|
[]
|
|
2624
2845
|
);
|
|
2625
|
-
return
|
|
2846
|
+
return $(e, t, r, s);
|
|
2626
2847
|
}
|
|
2627
|
-
function
|
|
2628
|
-
const
|
|
2848
|
+
function Fe() {
|
|
2849
|
+
const s = E(
|
|
2629
2850
|
() => ({
|
|
2630
2851
|
value: [],
|
|
2631
2852
|
length: 0,
|
|
@@ -2639,105 +2860,113 @@ function _e() {
|
|
|
2639
2860
|
}),
|
|
2640
2861
|
[]
|
|
2641
2862
|
);
|
|
2642
|
-
return
|
|
2863
|
+
return $({}, [], s);
|
|
2643
2864
|
}
|
|
2644
|
-
function
|
|
2645
|
-
const e =
|
|
2646
|
-
return
|
|
2865
|
+
function Re(s) {
|
|
2866
|
+
const e = s && "length" in s && "map" in s;
|
|
2867
|
+
return s ? e ? Ne(s) : Oe(s) : Fe();
|
|
2647
2868
|
}
|
|
2648
|
-
function
|
|
2649
|
-
const e =
|
|
2650
|
-
(
|
|
2869
|
+
function $e(s) {
|
|
2870
|
+
const e = k({ value: s.value.value }), t = E(
|
|
2871
|
+
(i) => {
|
|
2651
2872
|
let n = !0;
|
|
2652
2873
|
return _(() => {
|
|
2653
|
-
if (
|
|
2874
|
+
if (s.value.value, n) {
|
|
2654
2875
|
n = !1;
|
|
2655
2876
|
return;
|
|
2656
2877
|
}
|
|
2657
|
-
|
|
2878
|
+
i();
|
|
2658
2879
|
});
|
|
2659
2880
|
},
|
|
2660
|
-
[
|
|
2661
|
-
),
|
|
2662
|
-
const
|
|
2663
|
-
return e.current.value ===
|
|
2664
|
-
}, [
|
|
2665
|
-
return
|
|
2881
|
+
[s]
|
|
2882
|
+
), r = E(() => {
|
|
2883
|
+
const i = s.value.value;
|
|
2884
|
+
return e.current.value === i ? e.current.value : (e.current.value = i, i);
|
|
2885
|
+
}, [s]);
|
|
2886
|
+
return C.useSyncExternalStore(t, r, r);
|
|
2666
2887
|
}
|
|
2667
|
-
function
|
|
2668
|
-
const e =
|
|
2669
|
-
(
|
|
2888
|
+
function Ge(s) {
|
|
2889
|
+
const e = k({ length: s.length.value }), t = E(
|
|
2890
|
+
(i) => {
|
|
2670
2891
|
let n = !0;
|
|
2671
2892
|
return _(() => {
|
|
2672
|
-
if (
|
|
2893
|
+
if (s.length.value, n) {
|
|
2673
2894
|
n = !1;
|
|
2674
2895
|
return;
|
|
2675
2896
|
}
|
|
2676
|
-
|
|
2897
|
+
i();
|
|
2677
2898
|
});
|
|
2678
2899
|
},
|
|
2679
|
-
[
|
|
2680
|
-
),
|
|
2681
|
-
const
|
|
2682
|
-
return e.current.length ===
|
|
2683
|
-
}, [
|
|
2684
|
-
return
|
|
2900
|
+
[s]
|
|
2901
|
+
), r = E(() => {
|
|
2902
|
+
const i = s.length.value;
|
|
2903
|
+
return e.current.length === i ? e.current.length : (e.current.length = i, i);
|
|
2904
|
+
}, [s]);
|
|
2905
|
+
return C.useSyncExternalStore(t, r, r);
|
|
2685
2906
|
}
|
|
2686
|
-
function
|
|
2687
|
-
const { model: e, schema: t, strategy:
|
|
2688
|
-
() =>
|
|
2689
|
-
[e, t,
|
|
2907
|
+
function je(s) {
|
|
2908
|
+
const { model: e, schema: t, strategy: r, debounce: i, liveAfterSubmit: n } = s, a = ae(
|
|
2909
|
+
() => D(e, t, { strategy: r, debounce: i, liveAfterSubmit: n }),
|
|
2910
|
+
[e, t, r, i, n]
|
|
2690
2911
|
);
|
|
2691
|
-
|
|
2692
|
-
const l =
|
|
2693
|
-
|
|
2912
|
+
Y(() => a.start(), [a]);
|
|
2913
|
+
const l = C.useSyncExternalStore(
|
|
2914
|
+
E((u) => a.validating.subscribe(u), [a]),
|
|
2694
2915
|
() => a.validating.peek(),
|
|
2695
2916
|
() => !1
|
|
2696
2917
|
// SSR: прогон не идёт
|
|
2697
|
-
), d =
|
|
2918
|
+
), d = E(() => a.validate(), [a]);
|
|
2698
2919
|
return { submit: d, validate: d, isValidating: l };
|
|
2699
2920
|
}
|
|
2700
|
-
|
|
2921
|
+
function Be(s) {
|
|
2922
|
+
const [e] = oe(s), t = e.validation?.controller;
|
|
2923
|
+
return Y(() => t?.start(), [t]), e;
|
|
2924
|
+
}
|
|
2925
|
+
const Ue = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2701
2926
|
export {
|
|
2702
|
-
|
|
2703
|
-
|
|
2927
|
+
W as ArrayNode,
|
|
2928
|
+
Ue as CORE_RUNTIME_TOKEN,
|
|
2704
2929
|
S as ErrorStrategy,
|
|
2705
|
-
|
|
2706
|
-
|
|
2930
|
+
de as FieldNode,
|
|
2931
|
+
V as FormErrorHandler,
|
|
2707
2932
|
M as FormNode,
|
|
2708
|
-
|
|
2933
|
+
he as FormSubmitter,
|
|
2709
2934
|
A as GroupNode,
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2935
|
+
me as ModelArrayNode,
|
|
2936
|
+
ve as NodeFactory,
|
|
2937
|
+
L as SubscriptionManager,
|
|
2938
|
+
be as buildValidation,
|
|
2939
|
+
Xe as computeFrom,
|
|
2940
|
+
Ze as copyFrom,
|
|
2941
|
+
Ie as createCoreForm,
|
|
2942
|
+
ye as createForm,
|
|
2943
|
+
Z as createFormFromModel,
|
|
2944
|
+
ee as createModel,
|
|
2945
|
+
ct as disableWhen,
|
|
2946
|
+
Ke as eachLeafSignal,
|
|
2947
|
+
ht as enableWhen,
|
|
2948
|
+
ut as getNodeForSignal,
|
|
2949
|
+
Le as getNodeType,
|
|
2950
|
+
Se as isArrayNode,
|
|
2951
|
+
G as isDerived,
|
|
2952
|
+
Ee as isFieldNode,
|
|
2953
|
+
x as isFormNode,
|
|
2954
|
+
_e as isGroupNode,
|
|
2955
|
+
ze as isModelContainerSignal,
|
|
2956
|
+
Ye as markDerived,
|
|
2957
|
+
se as registerSignalNode,
|
|
2958
|
+
et as resetWhen,
|
|
2959
|
+
tt as revalidateWhen,
|
|
2960
|
+
st as runOutsideEffect,
|
|
2961
|
+
rt as safeCallback,
|
|
2962
|
+
it as safeDebouncedCallback,
|
|
2963
|
+
nt as syncFields,
|
|
2964
|
+
at as transformValue,
|
|
2965
|
+
Je as unmarkDerived,
|
|
2966
|
+
Ge as useArrayLength,
|
|
2967
|
+
Be as useFormBundle,
|
|
2968
|
+
Re as useFormControl,
|
|
2969
|
+
$e as useFormControlValue,
|
|
2970
|
+
je as useFormValidation,
|
|
2971
|
+
ot as watchField
|
|
2743
2972
|
};
|