mobx-formly 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-formly",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Framework-agnostic observable forms for MobX with granular field state and Zod or Valibot validation",
5
5
  "homepage": "https://js2me.github.io/mobx-formly/",
6
6
  "repository": {
@@ -19,17 +19,6 @@
19
19
  "import": "./dist/index.js"
20
20
  }
21
21
  },
22
- "scripts": {
23
- "build": "tsc -p tsconfig.json",
24
- "check": "tsc --noEmit -p tsconfig.json",
25
- "test": "vitest run",
26
- "test:performance": "vitest run tests/performance",
27
- "test:coverage": "vitest run --coverage",
28
- "test:types": "tsc --noEmit -p tsconfig.types.json",
29
- "docs:dev": "docusite dev",
30
- "docs:build": "docusite build",
31
- "docs:preview": "docusite preview"
32
- },
33
22
  "keywords": [
34
23
  "mobx",
35
24
  "mobx-form",
@@ -70,7 +59,6 @@
70
59
  "access": "public"
71
60
  },
72
61
  "type": "module",
73
- "packageManager": "pnpm@11.24.0",
74
62
  "dependencies": {
75
63
  "mobx": "^6.16.1",
76
64
  "yummies": "^7.20.1"
@@ -84,5 +72,16 @@
84
72
  "valibot": "^1.4.2",
85
73
  "vitest": "^4.1.11",
86
74
  "zod": "^4.4.3"
75
+ },
76
+ "scripts": {
77
+ "build": "tsc -p tsconfig.json",
78
+ "check": "tsc --noEmit -p tsconfig.json",
79
+ "test": "vitest run",
80
+ "test:performance": "vitest run tests/performance",
81
+ "test:coverage": "vitest run --coverage",
82
+ "test:types": "tsc --noEmit -p tsconfig.types.json",
83
+ "docs:dev": "docusite dev",
84
+ "docs:build": "docusite build",
85
+ "docs:preview": "docusite preview"
87
86
  }
88
- }
87
+ }
@@ -1,11 +0,0 @@
1
- import { Form } from './form.js';
2
- import type { FieldValues, FormOptions, FormSchema, SchemaOutput } from './types.js';
3
- export type InferredFormValues<S> = Extract<SchemaOutput<S>, FieldValues>;
4
- /**
5
- * Creates a form with values inferred from its schema.
6
- *
7
- * [**Documentation**](https://js2me.github.io/mobx-formly/guide/getting-started.html)
8
- */
9
- export declare const createForm: <S extends FormSchema<any>>(options: FormOptions<InferredFormValues<S>> & {
10
- schema: S;
11
- }) => Form<InferredFormValues<S>>;
@@ -1,7 +0,0 @@
1
- import { Form } from './form.js';
2
- /**
3
- * Creates a form with values inferred from its schema.
4
- *
5
- * [**Documentation**](https://js2me.github.io/mobx-formly/guide/getting-started.html)
6
- */
7
- export const createForm = (options) => new Form(options);
package/dist/form.d.ts DELETED
@@ -1,193 +0,0 @@
1
- import { type Ref } from 'yummies/mobx';
2
- import type { FieldError, FieldPath, FieldPathValue, FieldState, FieldValues, FormOptions, RegisterOptions, RegisterReturn, ResetOptions, SetValueConfig, SubmitHandlers } from './types.js';
3
- export declare class Form<T extends FieldValues = FieldValues> {
4
- /**
5
- * Current form values.
6
- *
7
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#values)
8
- */
9
- values: T;
10
- /**
11
- * Errors keyed by field path.
12
- *
13
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#errors)
14
- */
15
- errors: Record<string, FieldError | undefined>;
16
- /**
17
- * Field paths whose values differ from their defaults.
18
- *
19
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#dirtyfields)
20
- */
21
- dirtyFields: Record<string, true | undefined>;
22
- /**
23
- * Field paths that have been touched.
24
- *
25
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#touchedfields)
26
- */
27
- touchedFields: Record<string, true | undefined>;
28
- /**
29
- * Field paths that are currently being validated.
30
- *
31
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#validatingfields)
32
- */
33
- validatingFields: Record<string, true | undefined>;
34
- /**
35
- * Observable state for each registered field.
36
- *
37
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#fieldstate)
38
- */
39
- fieldState: Record<string, FieldState | undefined>;
40
- /**
41
- * Whether a submission is currently running.
42
- *
43
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#issubmitting)
44
- */
45
- isSubmitting: boolean;
46
- /**
47
- * Whether the form has been submitted at least once.
48
- *
49
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#issubmitted)
50
- */
51
- isSubmitted: boolean;
52
- /**
53
- * Whether the latest submission succeeded.
54
- *
55
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#issubmitsuccessful)
56
- */
57
- isSubmitSuccessful: boolean;
58
- /**
59
- * Number of submission attempts.
60
- *
61
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#submitcount)
62
- */
63
- submitCount: number;
64
- /**
65
- * Refs registered for fields.
66
- *
67
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#refs)
68
- */
69
- readonly refs: Map<string, Ref<HTMLElement | null, import("yummies/types").AnyObject>>;
70
- private readonly defaultValues;
71
- private readonly options;
72
- private readonly fieldOptions;
73
- private valueObservers?;
74
- private observerTimer?;
75
- private readonly changedPaths;
76
- private isMutating;
77
- private observerTreeChanged;
78
- private activeSubmissions;
79
- private resetVersion;
80
- private validationVersion;
81
- private readonly fieldValidationVersions;
82
- /** Creates a form with optional initial values, schema, and validation settings.
83
- *
84
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#constructor-options)
85
- */
86
- constructor(options?: FormOptions<T>);
87
- /**
88
- * Whether registered event handlers ignore changes and blur events.
89
- *
90
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#disabled)
91
- */
92
- get disabled(): boolean;
93
- /**
94
- * Whether any field is dirty.
95
- *
96
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#isdirty)
97
- */
98
- get isDirty(): boolean;
99
- /**
100
- * Whether the form has no errors.
101
- *
102
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#isvalid)
103
- */
104
- get isValid(): boolean;
105
- /**
106
- * Registers a field and returns its ref and event handlers.
107
- *
108
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#registername-options)
109
- */
110
- register(name: FieldPath<T>, options?: RegisterOptions<T>): RegisterReturn;
111
- /**
112
- * Removes a field, its value, and its associated state.
113
- *
114
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#unregistername)
115
- */
116
- unregister(name: FieldPath<T>): void;
117
- /**
118
- * Updates a field value and optionally changes its state or validates it.
119
- *
120
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#setvaluename-value-config)
121
- */
122
- setValue<P extends FieldPath<T>>(name: P, value: FieldPathValue<T, P>, config?: SetValueConfig): void;
123
- /**
124
- * Groups direct value changes and processes their changed paths together.
125
- *
126
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#mutatemutator-config)
127
- */
128
- mutate(mutator: () => void, config?: SetValueConfig): void;
129
- private applyValueChange;
130
- private ensureValueObservers;
131
- private scheduleObserverCleanup;
132
- private disposeValueObservers;
133
- private observeValueTree;
134
- /**
135
- * Sets an error for a field.
136
- *
137
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#seterrorname-error)
138
- */
139
- setError(name: FieldPath<T>, error: FieldError): void;
140
- /**
141
- * Clears one, several, or all field errors.
142
- *
143
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#clearerrorsname)
144
- */
145
- clearErrors(name?: FieldPath<T> | FieldPath<T>[]): void;
146
- /**
147
- * Validates one field, several fields, or the complete form.
148
- *
149
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#triggername)
150
- */
151
- trigger(name?: FieldPath<T> | FieldPath<T>[]): Promise<boolean>;
152
- /**
153
- * Creates an asynchronous submit handler with validation and result callbacks.
154
- *
155
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#handlesubmithandlers)
156
- */
157
- handleSubmit({ onValid, onInvalid }: SubmitHandlers<T>): () => Promise<void>;
158
- /**
159
- * Resets values and selected form state.
160
- *
161
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#resetvalues-options)
162
- */
163
- reset(values?: Partial<T>, options?: ResetOptions): void;
164
- /**
165
- * Resets one field to its current default value and clears its state.
166
- *
167
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#resetfieldname)
168
- */
169
- resetField(name: FieldPath<T>): void;
170
- /**
171
- * Focuses a registered field when its ref points to a focusable element.
172
- *
173
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#setfocusname)
174
- */
175
- setFocus(name: FieldPath<T>): void;
176
- /**
177
- * Returns a plain copy of the current values.
178
- *
179
- * [**Documentation**](https://js2me.github.io/mobx-formly/api/form.html#snapshot)
180
- */
181
- get snapshot(): T;
182
- private markTouched;
183
- private updateDirty;
184
- private shouldValidateOnChange;
185
- private isValidationCurrent;
186
- private transformValue;
187
- private validateSchema;
188
- private normalizeSchemaErrors;
189
- private validateRules;
190
- private ensureFieldState;
191
- private applyFieldState;
192
- private applyError;
193
- }