@reformer/core 11.0.0-beta.3 → 11.0.0-beta.5
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 +3 -3
- package/dist/form/create-form.d.ts +12 -10
- package/dist/form/factories/node-factory.d.ts +17 -16
- package/dist/form/index.d.ts +10 -16
- package/dist/form/nodes/array-node.d.ts +3 -3
- package/dist/form/nodes/field-node.d.ts +6 -3
- package/dist/form/nodes/group-node.d.ts +7 -7
- package/dist/form/nodes/model-array-node.d.ts +3 -3
- package/dist/form/types/contracts.d.ts +9 -6
- package/dist/form/types/deep-schema.d.ts +5 -5
- package/dist/form/types/validation-schema.d.ts +1 -1
- package/dist/form/{validation-config.d.ts → validation/config.d.ts} +3 -3
- 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} +2 -2
- 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 +6 -7
- package/dist/form/{validation/validators → validators}/file-type.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/file-utils.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/future-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/index.d.ts +7 -4
- package/dist/form/{validation/validators → validators}/integer.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/is-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/is-number.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-age.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-file-size.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-files.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-length.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/max-total-file-size.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/min-age.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-file-size.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-files.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-length.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/min.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/multiple-of.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/non-negative.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/non-zero.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/past-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/pattern.d.ts +7 -15
- package/dist/form/{validation/validators → validators}/phone.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/required.d.ts +8 -13
- package/dist/form/{validation/validators → validators}/url.d.ts +8 -13
- package/dist/index.d.ts +7 -4
- package/dist/index.js +272 -94
- 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/{form → platforms/react}/hooks/use-form-bundle.d.ts +1 -1
- 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 +6 -6
- package/docs/llms/03-api-signatures.md +3 -3
- package/docs/llms/05-common-mistakes.md +1 -1
- package/docs/llms/09-formschema.md +11 -11
- package/docs/llms/10-arrays.md +4 -4
- package/docs/llms/14-extended-mistakes.md +1 -1
- package/docs/llms/15-project-structure.md +8 -7
- package/docs/llms/16-ui-components.md +6 -6
- package/docs/llms/17-nonexistent-api.md +2 -2
- package/docs/llms/29-async-preload.md +4 -4
- package/docs/llms/30-type-safety-recipes.md +1 -1
- package/llms-index.json +1 -0
- package/llms.txt +2102 -262
- package/package.json +5 -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 {
|
|
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";
|
|
5
6
|
import { signal as g, computed as m, effect as _, batch as te, Signal as j } from "@preact/signals-core";
|
|
6
7
|
import { r as se } from "./signal-node-registry-tiwel-TV.js";
|
|
7
|
-
import { g as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
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 паттерна)
|
|
@@ -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",
|
|
@@ -284,11 +453,11 @@ const O = {
|
|
|
284
453
|
WatchField: "watchField"
|
|
285
454
|
};
|
|
286
455
|
let le = 0;
|
|
287
|
-
function
|
|
456
|
+
function N(s) {
|
|
288
457
|
return `${s}-${++le}`;
|
|
289
458
|
}
|
|
290
459
|
var S = /* @__PURE__ */ ((s) => (s.THROW = "throw", s.LOG = "log", s.CONVERT = "convert", s))(S || {});
|
|
291
|
-
class
|
|
460
|
+
class V {
|
|
292
461
|
static handle(e, t, r = "throw") {
|
|
293
462
|
const i = this.extractMessage(e);
|
|
294
463
|
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), r) {
|
|
@@ -603,7 +772,7 @@ class de extends M {
|
|
|
603
772
|
*
|
|
604
773
|
* @example
|
|
605
774
|
* ```typescript
|
|
606
|
-
* const field = new FieldNode({ value: 'initial', component:
|
|
775
|
+
* const field = new FieldNode({ value: 'initial', component: InputField });
|
|
607
776
|
*
|
|
608
777
|
* field.setValue('changed');
|
|
609
778
|
* field.reset('temp value');
|
|
@@ -712,7 +881,7 @@ class de extends M {
|
|
|
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
|
|
@@ -796,12 +965,14 @@ class de extends M {
|
|
|
796
965
|
* @param updateOn - новый триггер валидации: 'change' | 'blur' | 'submit'
|
|
797
966
|
*
|
|
798
967
|
* @example
|
|
968
|
+
* Пример node-level: плоская схема с инлайн-значениями (back-compat путь до M1). В layout-схеме
|
|
969
|
+
* `createForm({ model, schema })` поля `validators` нет — правила живут в `defineValidationSchema`.
|
|
799
970
|
* ```typescript
|
|
800
971
|
* // Сценарий 1: Instant feedback после submit
|
|
801
972
|
* const form = createForm({
|
|
802
973
|
* email: {
|
|
803
974
|
* value: '',
|
|
804
|
-
* component:
|
|
975
|
+
* component: InputField,
|
|
805
976
|
* updateOn: 'submit', // Изначально валидация только при submit
|
|
806
977
|
* validators: [required, email],
|
|
807
978
|
* },
|
|
@@ -859,7 +1030,7 @@ class de extends M {
|
|
|
859
1030
|
const t = new AbortController(), r = _(() => {
|
|
860
1031
|
const n = this.value.value;
|
|
861
1032
|
e(n, t.signal);
|
|
862
|
-
}), i =
|
|
1033
|
+
}), i = N(O.Watch);
|
|
863
1034
|
return this.disposers.add(i, () => {
|
|
864
1035
|
t.abort(), r();
|
|
865
1036
|
});
|
|
@@ -890,7 +1061,7 @@ class de extends M {
|
|
|
890
1061
|
const r = _(() => {
|
|
891
1062
|
const n = e.map((l) => l.value), a = t(...n);
|
|
892
1063
|
this.setValue(a, { emitEvent: !1 });
|
|
893
|
-
}), i =
|
|
1064
|
+
}), i = N(O.ComputeFrom);
|
|
894
1065
|
return this.disposers.add(i, r);
|
|
895
1066
|
}
|
|
896
1067
|
/**
|
|
@@ -1267,8 +1438,8 @@ class A extends M {
|
|
|
1267
1438
|
* @example
|
|
1268
1439
|
* ```typescript
|
|
1269
1440
|
* const form = new GroupNode({
|
|
1270
|
-
* email: { value: '', component:
|
|
1271
|
-
* name: { value: '', component:
|
|
1441
|
+
* email: { value: '', component: InputField },
|
|
1442
|
+
* name: { value: '', component: InputField },
|
|
1272
1443
|
* });
|
|
1273
1444
|
*
|
|
1274
1445
|
* const proxy = form.getProxy();
|
|
@@ -1342,11 +1513,11 @@ class A extends M {
|
|
|
1342
1513
|
* @example
|
|
1343
1514
|
* ```typescript
|
|
1344
1515
|
* const form = new GroupNode({
|
|
1345
|
-
* email: { value: '', component:
|
|
1516
|
+
* email: { value: '', component: InputField },
|
|
1346
1517
|
* address: {
|
|
1347
|
-
* city: { value: '', component:
|
|
1518
|
+
* city: { value: '', component: InputField }
|
|
1348
1519
|
* },
|
|
1349
|
-
* items: [{ name: { value: '', component:
|
|
1520
|
+
* items: [{ name: { value: '', component: InputField } }]
|
|
1350
1521
|
* });
|
|
1351
1522
|
*
|
|
1352
1523
|
* form.getFieldByPath('email'); // FieldNode
|
|
@@ -1411,7 +1582,7 @@ class A extends M {
|
|
|
1411
1582
|
const a = _(() => {
|
|
1412
1583
|
const d = i.value.value, u = r ? r(d) : d;
|
|
1413
1584
|
n.setValue(u, { emitEvent: !1 });
|
|
1414
|
-
}), l =
|
|
1585
|
+
}), l = N(O.LinkFields);
|
|
1415
1586
|
return this.disposers.add(l, a);
|
|
1416
1587
|
}
|
|
1417
1588
|
/**
|
|
@@ -1448,7 +1619,7 @@ class A extends M {
|
|
|
1448
1619
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1449
1620
|
const i = _(() => {
|
|
1450
1621
|
t(r.value.value);
|
|
1451
|
-
}), n =
|
|
1622
|
+
}), n = N(O.WatchField);
|
|
1452
1623
|
return this.disposers.add(n, i);
|
|
1453
1624
|
}
|
|
1454
1625
|
/**
|
|
@@ -1461,7 +1632,7 @@ class A extends M {
|
|
|
1461
1632
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1462
1633
|
const i = _(() => {
|
|
1463
1634
|
t(r.value.value);
|
|
1464
|
-
}), n =
|
|
1635
|
+
}), n = N(O.WatchField);
|
|
1465
1636
|
return this.disposers.add(n, i);
|
|
1466
1637
|
}
|
|
1467
1638
|
/**
|
|
@@ -1561,7 +1732,7 @@ class W extends M {
|
|
|
1561
1732
|
*/
|
|
1562
1733
|
removeAt(e) {
|
|
1563
1734
|
if (e < 0 || e >= this.items.value.length) {
|
|
1564
|
-
|
|
1735
|
+
V.handle(
|
|
1565
1736
|
new Error(
|
|
1566
1737
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1567
1738
|
),
|
|
@@ -1580,7 +1751,7 @@ class W extends M {
|
|
|
1580
1751
|
*/
|
|
1581
1752
|
insert(e, t) {
|
|
1582
1753
|
if (e < 0 || e > this.items.value.length) {
|
|
1583
|
-
|
|
1754
|
+
V.handle(
|
|
1584
1755
|
new Error(
|
|
1585
1756
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1586
1757
|
),
|
|
@@ -1611,7 +1782,7 @@ class W extends M {
|
|
|
1611
1782
|
move(e, t) {
|
|
1612
1783
|
const r = this.items.value.length;
|
|
1613
1784
|
if (e < 0 || e >= r || t < 0 || t >= r) {
|
|
1614
|
-
|
|
1785
|
+
V.handle(
|
|
1615
1786
|
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${r})`),
|
|
1616
1787
|
"ArrayNode.move",
|
|
1617
1788
|
S.LOG
|
|
@@ -1639,7 +1810,7 @@ class W extends M {
|
|
|
1639
1810
|
swap(e, t) {
|
|
1640
1811
|
const r = this.items.value.length;
|
|
1641
1812
|
if (e < 0 || e >= r || t < 0 || t >= r) {
|
|
1642
|
-
|
|
1813
|
+
V.handle(
|
|
1643
1814
|
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${r})`),
|
|
1644
1815
|
"ArrayNode.swap",
|
|
1645
1816
|
S.LOG
|
|
@@ -1680,7 +1851,7 @@ class W extends M {
|
|
|
1680
1851
|
}
|
|
1681
1852
|
setValue(e, t) {
|
|
1682
1853
|
this.clear(), e.forEach((r) => this.push(r)), t?.emitEvent !== !1 && this.validate().catch((r) => {
|
|
1683
|
-
|
|
1854
|
+
V.handle(r, "ArrayNode.setValue", S.LOG);
|
|
1684
1855
|
});
|
|
1685
1856
|
}
|
|
1686
1857
|
patchValue(e) {
|
|
@@ -1723,7 +1894,7 @@ class W extends M {
|
|
|
1723
1894
|
* @example
|
|
1724
1895
|
* ```typescript
|
|
1725
1896
|
* const arrayNode = new ArrayNode(
|
|
1726
|
-
* { name: { value: '', component:
|
|
1897
|
+
* { name: { value: '', component: InputField } },
|
|
1727
1898
|
* [{ name: 'Initial 1' }, { name: 'Initial 2' }]
|
|
1728
1899
|
* );
|
|
1729
1900
|
*
|
|
@@ -1935,28 +2106,29 @@ class ve {
|
|
|
1935
2106
|
* ```typescript
|
|
1936
2107
|
* const factory = new NodeFactory();
|
|
1937
2108
|
*
|
|
2109
|
+
* Конфиг node-level (не layout-схема M1, где `validators` уже нет).
|
|
1938
2110
|
* // FieldNode
|
|
1939
2111
|
* const field = factory.createNode({
|
|
1940
2112
|
* value: 'test@mail.com',
|
|
1941
|
-
* component:
|
|
2113
|
+
* component: InputField,
|
|
1942
2114
|
* validators: [required, email]
|
|
1943
2115
|
* });
|
|
1944
2116
|
*
|
|
1945
2117
|
* // GroupNode
|
|
1946
2118
|
* const group = factory.createNode({
|
|
1947
|
-
* email: { value: '', component:
|
|
1948
|
-
* password: { value: '', component:
|
|
2119
|
+
* email: { value: '', component: InputField },
|
|
2120
|
+
* password: { value: '', component: InputField }
|
|
1949
2121
|
* });
|
|
1950
2122
|
*
|
|
1951
2123
|
* // ArrayNode (объект)
|
|
1952
2124
|
* const array = factory.createNode({
|
|
1953
|
-
* schema: { title: { value: '', component:
|
|
2125
|
+
* schema: { title: { value: '', component: InputField } },
|
|
1954
2126
|
* initialItems: [{ title: 'Item 1' }]
|
|
1955
2127
|
* });
|
|
1956
2128
|
*
|
|
1957
2129
|
* // ArrayNode (массив) - новый формат
|
|
1958
2130
|
* const array2 = factory.createNode([
|
|
1959
|
-
* { title: { value: '', component:
|
|
2131
|
+
* { title: { value: '', component: InputField } }, // schema
|
|
1960
2132
|
* { title: 'Item 1' }, // initial item 1
|
|
1961
2133
|
* { title: 'Item 2' } // initial item 2
|
|
1962
2134
|
* ]);
|
|
@@ -1998,7 +2170,7 @@ class ve {
|
|
|
1998
2170
|
*
|
|
1999
2171
|
* // Массив с начальными элементами
|
|
2000
2172
|
* const array = factory.createArrayNodeFromArray([
|
|
2001
|
-
* { title: { value: '', component:
|
|
2173
|
+
* { title: { value: '', component: InputField } }, // schema
|
|
2002
2174
|
* { title: 'Item 1' }, // initial value
|
|
2003
2175
|
* { title: 'Item 2' } // initial value
|
|
2004
2176
|
* ]);
|
|
@@ -2019,7 +2191,7 @@ class ve {
|
|
|
2019
2191
|
* ✅ НОВОЕ: Извлечено из GroupNode для централизации логики
|
|
2020
2192
|
*
|
|
2021
2193
|
* Преобразует схему формы в объект со значениями:
|
|
2022
|
-
* - `{ name: { value: 'John', component:
|
|
2194
|
+
* - `{ name: { value: 'John', component: InputField } } → { name: 'John' }`
|
|
2023
2195
|
* - Поддерживает вложенные группы
|
|
2024
2196
|
* - Поддерживает массивы
|
|
2025
2197
|
*
|
|
@@ -2031,10 +2203,10 @@ class ve {
|
|
|
2031
2203
|
* const factory = new NodeFactory();
|
|
2032
2204
|
*
|
|
2033
2205
|
* const schema = {
|
|
2034
|
-
* name: { value: 'John', component:
|
|
2035
|
-
* age: { value: 30, component:
|
|
2206
|
+
* name: { value: 'John', component: InputField },
|
|
2207
|
+
* age: { value: 30, component: InputField },
|
|
2036
2208
|
* address: {
|
|
2037
|
-
* city: { value: 'Moscow', component:
|
|
2209
|
+
* city: { value: 'Moscow', component: InputField }
|
|
2038
2210
|
* }
|
|
2039
2211
|
* };
|
|
2040
2212
|
*
|
|
@@ -2069,7 +2241,7 @@ class ve {
|
|
|
2069
2241
|
* ```typescript
|
|
2070
2242
|
* const factory = new NodeFactory();
|
|
2071
2243
|
*
|
|
2072
|
-
* factory.isFieldConfig({ value: '', component:
|
|
2244
|
+
* factory.isFieldConfig({ value: '', component: InputField }); // true
|
|
2073
2245
|
* factory.isFieldConfig({ email: { value: '' } }); // false
|
|
2074
2246
|
* factory.isFieldConfig(null); // false
|
|
2075
2247
|
* ```
|
|
@@ -2094,7 +2266,7 @@ class ve {
|
|
|
2094
2266
|
* const factory = new NodeFactory();
|
|
2095
2267
|
*
|
|
2096
2268
|
* factory.isArrayConfig({ schema: {}, initialItems: [] }); // true
|
|
2097
|
-
* factory.isArrayConfig({ value: '', component:
|
|
2269
|
+
* factory.isArrayConfig({ value: '', component: InputField }); // false
|
|
2098
2270
|
* factory.isArrayConfig({ email: { value: '' } }); // false
|
|
2099
2271
|
* ```
|
|
2100
2272
|
*/
|
|
@@ -2117,11 +2289,11 @@ class ve {
|
|
|
2117
2289
|
* const factory = new NodeFactory();
|
|
2118
2290
|
*
|
|
2119
2291
|
* factory.isGroupConfig({
|
|
2120
|
-
* email: { value: '', component:
|
|
2121
|
-
* password: { value: '', component:
|
|
2292
|
+
* email: { value: '', component: InputField },
|
|
2293
|
+
* password: { value: '', component: InputField }
|
|
2122
2294
|
* }); // true
|
|
2123
2295
|
*
|
|
2124
|
-
* factory.isGroupConfig({ value: '', component:
|
|
2296
|
+
* factory.isGroupConfig({ value: '', component: InputField }); // false
|
|
2125
2297
|
* factory.isGroupConfig({ schema: {} }); // false
|
|
2126
2298
|
* factory.isGroupConfig(null); // false
|
|
2127
2299
|
* ```
|
|
@@ -2413,10 +2585,6 @@ function Ie(s) {
|
|
|
2413
2585
|
}), r = be(e, s.validation), i = { model: e, form: t, ...r ? { validation: r } : {} };
|
|
2414
2586
|
return s.setup?.(i), i;
|
|
2415
2587
|
}
|
|
2416
|
-
function Le(s) {
|
|
2417
|
-
const [e] = ae(s), t = e.validation?.controller;
|
|
2418
|
-
return z(() => t?.start(), [t]), e;
|
|
2419
|
-
}
|
|
2420
2588
|
function x(s) {
|
|
2421
2589
|
return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
|
|
2422
2590
|
}
|
|
@@ -2435,15 +2603,15 @@ function Se(s) {
|
|
|
2435
2603
|
typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2436
2604
|
typeof s.removeAt == "function";
|
|
2437
2605
|
}
|
|
2438
|
-
function
|
|
2606
|
+
function Le(s) {
|
|
2439
2607
|
return Ee(s) ? "FieldNode" : _e(s) ? "GroupNode" : Se(s) ? "ArrayNode" : x(s) ? "FormNode" : "Unknown";
|
|
2440
2608
|
}
|
|
2441
|
-
var
|
|
2609
|
+
var F = { exports: {} }, P = {};
|
|
2442
2610
|
var q;
|
|
2443
2611
|
function Ae() {
|
|
2444
2612
|
if (q) return P;
|
|
2445
2613
|
q = 1;
|
|
2446
|
-
var s =
|
|
2614
|
+
var s = z;
|
|
2447
2615
|
function e(o, f) {
|
|
2448
2616
|
return o === f && (o !== 0 || 1 / o === 1 / f) || o !== o && f !== f;
|
|
2449
2617
|
}
|
|
@@ -2530,16 +2698,16 @@ function we() {
|
|
|
2530
2698
|
return v();
|
|
2531
2699
|
}
|
|
2532
2700
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2533
|
-
var i =
|
|
2701
|
+
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;
|
|
2534
2702
|
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());
|
|
2535
2703
|
})()), T;
|
|
2536
2704
|
}
|
|
2537
2705
|
var H;
|
|
2538
|
-
function
|
|
2539
|
-
return H || (H = 1, process.env.NODE_ENV === "production" ?
|
|
2706
|
+
function Ve() {
|
|
2707
|
+
return H || (H = 1, process.env.NODE_ENV === "production" ? F.exports = Ae() : F.exports = we()), F.exports;
|
|
2540
2708
|
}
|
|
2541
|
-
var C =
|
|
2542
|
-
function
|
|
2709
|
+
var C = Ve();
|
|
2710
|
+
function ke(s, e) {
|
|
2543
2711
|
if (s === e) return !0;
|
|
2544
2712
|
if (s.length !== e.length) return !1;
|
|
2545
2713
|
for (let t = 0; t < s.length; t++)
|
|
@@ -2547,11 +2715,11 @@ function Ve(s, e) {
|
|
|
2547
2715
|
return !0;
|
|
2548
2716
|
}
|
|
2549
2717
|
function $(s, e, t, r) {
|
|
2550
|
-
const i =
|
|
2718
|
+
const i = k(null), n = k(s);
|
|
2551
2719
|
n.current = s;
|
|
2552
|
-
const a =
|
|
2720
|
+
const a = k(e);
|
|
2553
2721
|
a.current = e;
|
|
2554
|
-
const l =
|
|
2722
|
+
const l = k(t);
|
|
2555
2723
|
if (l.current = t, i.current === null) {
|
|
2556
2724
|
const h = {};
|
|
2557
2725
|
for (const o in s)
|
|
@@ -2572,6 +2740,11 @@ function $(s, e, t, r) {
|
|
|
2572
2740
|
h();
|
|
2573
2741
|
});
|
|
2574
2742
|
},
|
|
2743
|
+
// subscriptionKey намеренно не читается в теле — он здесь КЛЮЧ ИДЕНТИЧНОСТИ подписки (см. JSDoc
|
|
2744
|
+
// параметра). Убрать его (как предлагает автофикс) значит получить subscribe, созданный один раз
|
|
2745
|
+
// навсегда: подмена контрола на другой узел перестанет пересоздавать effect. Тот же приём ниже
|
|
2746
|
+
// у getSnapshot.
|
|
2747
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2575
2748
|
[r]
|
|
2576
2749
|
), u = E(() => {
|
|
2577
2750
|
const h = i.current, o = n.current, f = {};
|
|
@@ -2581,7 +2754,7 @@ function $(s, e, t, r) {
|
|
|
2581
2754
|
for (const v of a.current) {
|
|
2582
2755
|
const { key: p, useShallowArrayEqual: b } = v, y = f[p], w = h[p];
|
|
2583
2756
|
if (b) {
|
|
2584
|
-
if (!
|
|
2757
|
+
if (!ke(w, y)) {
|
|
2585
2758
|
c = !0;
|
|
2586
2759
|
break;
|
|
2587
2760
|
}
|
|
@@ -2638,7 +2811,7 @@ function Oe(s) {
|
|
|
2638
2811
|
);
|
|
2639
2812
|
return $(e, t, r, s);
|
|
2640
2813
|
}
|
|
2641
|
-
function
|
|
2814
|
+
function Ne(s) {
|
|
2642
2815
|
const e = {
|
|
2643
2816
|
value: s.value,
|
|
2644
2817
|
length: s.length,
|
|
@@ -2675,7 +2848,7 @@ function Fe(s) {
|
|
|
2675
2848
|
);
|
|
2676
2849
|
return $(e, t, r, s);
|
|
2677
2850
|
}
|
|
2678
|
-
function
|
|
2851
|
+
function Fe() {
|
|
2679
2852
|
const s = E(
|
|
2680
2853
|
() => ({
|
|
2681
2854
|
value: [],
|
|
@@ -2692,12 +2865,12 @@ function Ne() {
|
|
|
2692
2865
|
);
|
|
2693
2866
|
return $({}, [], s);
|
|
2694
2867
|
}
|
|
2695
|
-
function
|
|
2868
|
+
function Re(s) {
|
|
2696
2869
|
const e = s && "length" in s && "map" in s;
|
|
2697
|
-
return s ? e ?
|
|
2870
|
+
return s ? e ? Ne(s) : Oe(s) : Fe();
|
|
2698
2871
|
}
|
|
2699
|
-
function
|
|
2700
|
-
const e =
|
|
2872
|
+
function $e(s) {
|
|
2873
|
+
const e = k({ value: s.value.value }), t = E(
|
|
2701
2874
|
(i) => {
|
|
2702
2875
|
let n = !0;
|
|
2703
2876
|
return _(() => {
|
|
@@ -2715,8 +2888,8 @@ function Ge(s) {
|
|
|
2715
2888
|
}, [s]);
|
|
2716
2889
|
return C.useSyncExternalStore(t, r, r);
|
|
2717
2890
|
}
|
|
2718
|
-
function
|
|
2719
|
-
const e =
|
|
2891
|
+
function Ge(s) {
|
|
2892
|
+
const e = k({ length: s.length.value }), t = E(
|
|
2720
2893
|
(i) => {
|
|
2721
2894
|
let n = !0;
|
|
2722
2895
|
return _(() => {
|
|
@@ -2734,12 +2907,12 @@ function je(s) {
|
|
|
2734
2907
|
}, [s]);
|
|
2735
2908
|
return C.useSyncExternalStore(t, r, r);
|
|
2736
2909
|
}
|
|
2737
|
-
function
|
|
2738
|
-
const { model: e, schema: t, strategy: r, debounce: i, liveAfterSubmit: n } = s, a =
|
|
2910
|
+
function je(s) {
|
|
2911
|
+
const { model: e, schema: t, strategy: r, debounce: i, liveAfterSubmit: n } = s, a = ae(
|
|
2739
2912
|
() => D(e, t, { strategy: r, debounce: i, liveAfterSubmit: n }),
|
|
2740
2913
|
[e, t, r, i, n]
|
|
2741
2914
|
);
|
|
2742
|
-
|
|
2915
|
+
Y(() => a.start(), [a]);
|
|
2743
2916
|
const l = C.useSyncExternalStore(
|
|
2744
2917
|
E((u) => a.validating.subscribe(u), [a]),
|
|
2745
2918
|
() => a.validating.peek(),
|
|
@@ -2748,13 +2921,17 @@ function Be(s) {
|
|
|
2748
2921
|
), d = E(() => a.validate(), [a]);
|
|
2749
2922
|
return { submit: d, validate: d, isValidating: l };
|
|
2750
2923
|
}
|
|
2924
|
+
function Be(s) {
|
|
2925
|
+
const [e] = oe(s), t = e.validation?.controller;
|
|
2926
|
+
return Y(() => t?.start(), [t]), e;
|
|
2927
|
+
}
|
|
2751
2928
|
const Ue = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2752
2929
|
export {
|
|
2753
2930
|
W as ArrayNode,
|
|
2754
2931
|
Ue as CORE_RUNTIME_TOKEN,
|
|
2755
2932
|
S as ErrorStrategy,
|
|
2756
2933
|
de as FieldNode,
|
|
2757
|
-
|
|
2934
|
+
V as FormErrorHandler,
|
|
2758
2935
|
M as FormNode,
|
|
2759
2936
|
he as FormSubmitter,
|
|
2760
2937
|
A as GroupNode,
|
|
@@ -2762,36 +2939,37 @@ export {
|
|
|
2762
2939
|
ve as NodeFactory,
|
|
2763
2940
|
L as SubscriptionManager,
|
|
2764
2941
|
be as buildValidation,
|
|
2765
|
-
|
|
2766
|
-
|
|
2942
|
+
Xe as computeFrom,
|
|
2943
|
+
Ze as copyFrom,
|
|
2767
2944
|
Ie as createCoreForm,
|
|
2768
2945
|
ye as createForm,
|
|
2769
2946
|
Z as createFormFromModel,
|
|
2770
2947
|
ee as createModel,
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2948
|
+
ct as disableWhen,
|
|
2949
|
+
Ke as eachLeafSignal,
|
|
2950
|
+
ht as enableWhen,
|
|
2951
|
+
ut as getNodeForSignal,
|
|
2952
|
+
Le as getNodeType,
|
|
2775
2953
|
Se as isArrayNode,
|
|
2776
2954
|
G as isDerived,
|
|
2777
2955
|
Ee as isFieldNode,
|
|
2778
2956
|
x as isFormNode,
|
|
2779
2957
|
_e as isGroupNode,
|
|
2780
|
-
|
|
2781
|
-
|
|
2958
|
+
ze as isModelContainerSignal,
|
|
2959
|
+
Ye as markDerived,
|
|
2782
2960
|
se as registerSignalNode,
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2961
|
+
et as resetWhen,
|
|
2962
|
+
tt as revalidateWhen,
|
|
2963
|
+
st as runOutsideEffect,
|
|
2964
|
+
rt as safeCallback,
|
|
2965
|
+
it as safeDebouncedCallback,
|
|
2966
|
+
nt as syncFields,
|
|
2967
|
+
at as transformValue,
|
|
2968
|
+
Je as unmarkDerived,
|
|
2969
|
+
Ge as useArrayLength,
|
|
2970
|
+
Be as useFormBundle,
|
|
2971
|
+
Re as useFormControl,
|
|
2972
|
+
$e as useFormControlValue,
|
|
2973
|
+
je as useFormValidation,
|
|
2974
|
+
ot as watchField
|
|
2797
2975
|
};
|