@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
|
@@ -47,7 +47,7 @@ export const createCreditApplicationModel = (): FormModel<CreditApplicationForm>
|
|
|
47
47
|
// forms/credit-application/form.schema.ts
|
|
48
48
|
import type { FormModel } from '@reformer/core';
|
|
49
49
|
export const creditApplicationSchema = (model: FormModel<CreditApplicationForm>) => ({
|
|
50
|
-
loanType: { value: model.$.loanType, component:
|
|
50
|
+
loanType: { value: model.$.loanType, component: SelectField, componentProps: { /* ... */ } },
|
|
51
51
|
personalData: personalDataNodes(model.$.personalData),
|
|
52
52
|
properties: { array: model.properties, item: propertyItem },
|
|
53
53
|
});
|
|
@@ -94,9 +94,9 @@ forms/
|
|
|
94
94
|
│
|
|
95
95
|
├── schema/ # The form definition
|
|
96
96
|
│ ├── model.ts # createModel factory + initial values + array-element factories
|
|
97
|
-
│ ├── schema.ts
|
|
97
|
+
│ ├── form.schema.ts # schema builder (model) => tree ({ value: model.$.x, component })
|
|
98
98
|
│ ├── validation.ts # defineValidationSchema + validateModel config ({ validateStep, validateAll })
|
|
99
|
-
│ ├── behavior.ts
|
|
99
|
+
│ ├── form.behavior.ts # defineFormBehavior(...)
|
|
100
100
|
│ └── create-form.ts # Assembly: createCoreForm({ model, schema, behavior, validation })
|
|
101
101
|
│
|
|
102
102
|
└── components/
|
|
@@ -107,7 +107,7 @@ forms/
|
|
|
107
107
|
|
|
108
108
|
Rule of thumb for this layout: **domain raw material → `lib/`; anything describing the form →
|
|
109
109
|
`schema/`; React layout → `components/`; root = entry + `index.ts`.** In very large forms you
|
|
110
|
-
may co-locate each step's `schema.ts` / `validation.ts` / `behavior.ts` inside its
|
|
110
|
+
may co-locate each step's `form.schema.ts` / `validation.ts` / `form.behavior.ts` inside its
|
|
111
111
|
`steps/[Step]/` folder, keeping only the shared `model` and cross-step rules in `schema/` — see
|
|
112
112
|
the guide below.
|
|
113
113
|
|
|
@@ -124,6 +124,7 @@ the guide below.
|
|
|
124
124
|
> is `minimalist`.
|
|
125
125
|
|
|
126
126
|
> Cross-target variants (renderer-react `renderer.schema.ts` + `renderer.behavior.ts` /
|
|
127
|
-
> renderer-json `renderer.schema.
|
|
128
|
-
>
|
|
129
|
-
> **form-directory-layout** guide (`@reformer/mcp`)
|
|
127
|
+
> renderer-json `renderer.schema.ts` + `renderer.behavior.ts` + `registry.ts`, plus an optional
|
|
128
|
+
> `renderer.wizard.tsx` shim), the `.tsx` / `.json` schema variants, the centralized-vs-co-located
|
|
129
|
+
> choice, and the full reuse map live in the **form-directory-layout** guide (`@reformer/mcp`) —
|
|
130
|
+
> `find_recipe directory-layout`.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
>
|
|
8
8
|
> Канонический schema-driven подход:
|
|
9
9
|
>
|
|
10
|
-
> - **компонент** объявляется в схеме как `component:
|
|
10
|
+
> - **компонент** объявляется в схеме как `component: InputField` (или `Select`, `Checkbox`, etc.)
|
|
11
11
|
> - **пропсы** компонента — в `componentProps: { label, placeholder, options, type, ... }`
|
|
12
12
|
> - **JSX рендерит**: `<FormField control={form.x} />` БЕЗ дополнительных props
|
|
13
13
|
>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
```tsx
|
|
20
20
|
import { useMemo } from 'react';
|
|
21
21
|
import { createModel, createForm } from '@reformer/core';
|
|
22
|
-
import { FormField,
|
|
22
|
+
import { FormField, InputField, SelectField, CheckboxField, Button } from '@reformer/ui-kit';
|
|
23
23
|
|
|
24
24
|
type RegistrationForm = {
|
|
25
25
|
email: string;
|
|
@@ -33,12 +33,12 @@ function RegistrationPage() {
|
|
|
33
33
|
const schema = {
|
|
34
34
|
email: {
|
|
35
35
|
value: model.$.email,
|
|
36
|
-
component:
|
|
36
|
+
component: InputField,
|
|
37
37
|
componentProps: { label: 'Email', type: 'email', placeholder: 'you@example.com' },
|
|
38
38
|
},
|
|
39
39
|
country: {
|
|
40
40
|
value: model.$.country,
|
|
41
|
-
component:
|
|
41
|
+
component: SelectField,
|
|
42
42
|
componentProps: {
|
|
43
43
|
label: 'Country',
|
|
44
44
|
options: [
|
|
@@ -49,7 +49,7 @@ function RegistrationPage() {
|
|
|
49
49
|
},
|
|
50
50
|
agree: {
|
|
51
51
|
value: model.$.agree,
|
|
52
|
-
component:
|
|
52
|
+
component: CheckboxField,
|
|
53
53
|
componentProps: { label: 'I agree to terms' },
|
|
54
54
|
},
|
|
55
55
|
};
|
|
@@ -92,7 +92,7 @@ function RegistrationPage() {
|
|
|
92
92
|
✅ Всё это в схеме:
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
|
-
{ email: { component:
|
|
95
|
+
{ email: { component: InputField, componentProps: { label: 'Email' } } }
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
```tsx
|
|
@@ -64,8 +64,8 @@ const schema = {
|
|
|
64
64
|
|
|
65
65
|
// CORRECT - layout только связывает поле с сигналом модели...
|
|
66
66
|
const layout = {
|
|
67
|
-
name: { value: model.$.name, component:
|
|
68
|
-
email: { value: model.$.email, component:
|
|
67
|
+
name: { value: model.$.name, component: InputField, componentProps: { label: 'Name' } },
|
|
68
|
+
email: { value: model.$.email, component: InputField, componentProps: { label: 'Email' } },
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// ...а правила — отдельная ambient-схема (прогоняется раннером validateModel):
|
|
@@ -31,16 +31,16 @@ Initial values задаются в `createModel(initial)`; `reset()` возвр
|
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { createModel, createForm } from '@reformer/core';
|
|
34
|
-
import {
|
|
34
|
+
import { InputField, SelectField } from '@reformer/ui-kit';
|
|
35
35
|
|
|
36
36
|
type ProfileForm = { username: string; language: 'ru' | 'en'; marketing: boolean };
|
|
37
37
|
|
|
38
38
|
const model = createModel<ProfileForm>({ username: '', language: 'ru', marketing: true });
|
|
39
39
|
const schema = {
|
|
40
|
-
username: { value: model.$.username, component:
|
|
40
|
+
username: { value: model.$.username, component: InputField, componentProps: { label: 'Username' } },
|
|
41
41
|
language: {
|
|
42
42
|
value: model.$.language,
|
|
43
|
-
component:
|
|
43
|
+
component: SelectField,
|
|
44
44
|
componentProps: {
|
|
45
45
|
label: 'Язык',
|
|
46
46
|
options: [
|
|
@@ -49,7 +49,7 @@ const schema = {
|
|
|
49
49
|
],
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
-
marketing: { value: model.$.marketing, component:
|
|
52
|
+
marketing: { value: model.$.marketing, component: InputField, componentProps: { type: 'checkbox' } },
|
|
53
53
|
};
|
|
54
54
|
const form = createForm({ model, schema });
|
|
55
55
|
// model.get() === { username: '', language: 'ru', marketing: true }
|
|
@@ -59,7 +59,7 @@ Layout-схема БЕЗ валидаторов — правила живут в
|
|
|
59
59
|
const model = createModel<CreditApplicationForm>(initial);
|
|
60
60
|
|
|
61
61
|
const schema = {
|
|
62
|
-
loanAmount: { value: model.$.loanAmount, component:
|
|
62
|
+
loanAmount: { value: model.$.loanAmount, component: InputField },
|
|
63
63
|
// вложенная группа — builder, принимающий ModelSignals<Sub>
|
|
64
64
|
personalData: personalDataNodes(model.$.personalData),
|
|
65
65
|
// массив — { array, item }
|