notform 2.2.0 → 2.2.1

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +57 -29
  2. package/package.json +12 -12
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Component, ComputedRef, MaybeRefOrGetter, Raw, Ref } from "vue";
2
2
  import { StandardSchemaV1 } from "@standard-schema/spec";
3
3
  import { Get, PartialDeep, Paths as Paths$1 } from "type-fest";
4
-
5
4
  //#region src/types/shared.d.ts
6
5
  /**
7
6
  * The validation mode determines when validation occurs.
@@ -97,9 +96,13 @@ interface UseNotFormConfig<TSchema extends ObjectSchema> {
97
96
  * @template TSchema The form schema.
98
97
  */
99
98
  type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
100
- /** The values the form was initialised or last reset with. */readonly initialValues: UseNotFormConfig<TSchema>['initialValues']; /** The errors the form was initialised or last reset with. */
101
- readonly initialErrors: UseNotFormConfig<TSchema>['initialErrors']; /** The resolved validation triggers for this form. */
102
- readonly validateOn: Required<NonNullable<UseNotFormConfig<TSchema>['validateOn']>>; /** The resolved validation mode for this form. */
99
+ /** The values the form was initialised or last reset with. */
100
+ readonly initialValues: UseNotFormConfig<TSchema>['initialValues'];
101
+ /** The errors the form was initialised or last reset with. */
102
+ readonly initialErrors: UseNotFormConfig<TSchema>['initialErrors'];
103
+ /** The resolved validation triggers for this form. */
104
+ readonly validateOn: Required<NonNullable<UseNotFormConfig<TSchema>['validateOn']>>;
105
+ /** The resolved validation mode for this form. */
103
106
  readonly validationMode: Required<NonNullable<UseNotFormConfig<TSchema>['validationMode']>>;
104
107
  /**
105
108
  * Deeply reactive object of field values.
@@ -134,20 +137,24 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
134
137
  * The set of field paths the user has interacted with.
135
138
  * Populated for all paths when the form is submitted.
136
139
  */
137
- touchedFields: Set<Paths<StandardSchemaV1.InferInput<TSchema>>>; /** Whether any field has been touched. */
140
+ touchedFields: Set<Paths<StandardSchemaV1.InferInput<TSchema>>>;
141
+ /** Whether any field has been touched. */
138
142
  isTouched: ComputedRef<boolean>;
139
143
  /**
140
144
  * Marks a field as touched.
141
145
  * Called automatically by the field's `onBlur` handler.
142
146
  */
143
- touchField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void; /** The set of field paths whose current value differs from the initial value. */
144
- dirtyFields: Set<Paths<StandardSchemaV1.InferInput<TSchema>>>; /** Whether any field value differs from its initial value. */
147
+ touchField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
148
+ /** The set of field paths whose current value differs from the initial value. */
149
+ dirtyFields: Set<Paths<StandardSchemaV1.InferInput<TSchema>>>;
150
+ /** Whether any field value differs from its initial value. */
145
151
  isDirty: ComputedRef<boolean>;
146
152
  /**
147
153
  * Marks a field as dirty.
148
154
  * Called automatically when a field value changes.
149
155
  */
150
- dirtyField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void; /** The raw validation issues produced by the last validation run. */
156
+ dirtyField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
157
+ /** The raw validation issues produced by the last validation run. */
151
158
  errors: Array<StandardSchemaV1.Issue>;
152
159
  /**
153
160
  * A flat map of field path to its first error message.
@@ -165,8 +172,10 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
165
172
  * Replaces an existing error for the same path, or appends it if none exists.
166
173
  * Useful for setting server-side errors after submission.
167
174
  */
168
- setError: (error: StandardSchemaV1.Issue) => void; /** Replaces all current errors with the provided issues. */
169
- setErrors: (errors: Array<StandardSchemaV1.Issue>) => void; /** Removes all active validation errors. */
175
+ setError: (error: StandardSchemaV1.Issue) => void;
176
+ /** Replaces all current errors with the provided issues. */
177
+ setErrors: (errors: Array<StandardSchemaV1.Issue>) => void;
178
+ /** Removes all active validation errors. */
170
179
  clearErrors: () => void;
171
180
  /**
172
181
  * Returns all validation issues for a specific field path.
@@ -175,7 +184,8 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
175
184
  * form.getFieldErrors('address.city')
176
185
  * ```
177
186
  */
178
- getFieldErrors: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Array<StandardSchemaV1.Issue>; /** Whether a validation run is currently in progress. */
187
+ getFieldErrors: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Array<StandardSchemaV1.Issue>;
188
+ /** Whether a validation run is currently in progress. */
179
189
  isValidating: Ref<boolean>;
180
190
  /**
181
191
  * Validates the entire form against the schema.
@@ -186,8 +196,10 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
186
196
  * Validates a single field against the schema.
187
197
  * Only replaces errors for that field — all other fields are left untouched.
188
198
  */
189
- validateField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>; /** Whether the form currently has no validation errors. */
190
- isValid: ComputedRef<boolean>; /** Whether the form is currently running its submit handler. */
199
+ validateField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>;
200
+ /** Whether the form currently has no validation errors. */
201
+ isValid: ComputedRef<boolean>;
202
+ /** Whether the form is currently running its submit handler. */
191
203
  isSubmitting: Ref<boolean>;
192
204
  /**
193
205
  * Validates the form and runs `onSubmit` if it passes.
@@ -294,9 +306,13 @@ interface NotArrayFieldItem {
294
306
  interface NotArrayFieldSlots<TSchema extends ObjectSchema, TItem = any> {
295
307
  /** The default slot receives the full array state and manipulation methods. */
296
308
  default: (props: {
297
- /** The dot-separated path to this array field. */path: string; /** The array items with stable keys and paths for use with `v-for`. */
298
- items: Array<NotArrayFieldItem>; /** All validation issues for this array field from the last validation run. */
299
- errors: Array<StandardSchemaV1.Issue>; /** Whether this array field currently has no validation errors. */
309
+ /** The dot-separated path to this array field. */
310
+ path: string;
311
+ /** The array items with stable keys and paths for use with `v-for`. */
312
+ items: Array<NotArrayFieldItem>;
313
+ /** All validation issues for this array field from the last validation run. */
314
+ errors: Array<StandardSchemaV1.Issue>;
315
+ /** Whether this array field currently has no validation errors. */
300
316
  isValid: boolean;
301
317
  /**
302
318
  * Whether any item in this array has been touched.
@@ -307,7 +323,8 @@ interface NotArrayFieldSlots<TSchema extends ObjectSchema, TItem = any> {
307
323
  * Whether any item in this array differs from its initial value.
308
324
  * Derived from the form's `dirtyFields` set.
309
325
  */
310
- isDirty: boolean; /** Whether validation is currently running for this array field. */
326
+ isDirty: boolean;
327
+ /** Whether validation is currently running for this array field. */
311
328
  isValidating: boolean;
312
329
  /**
313
330
  * Manually triggers validation for this array field.
@@ -369,7 +386,7 @@ declare const __VLS_export$3: <TSchema extends ObjectSchema, TItemSchema extends
369
386
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
370
387
  };
371
388
  declare const _default: typeof __VLS_export$3;
372
- type __VLS_PrettifyLocal$1<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
389
+ type __VLS_PrettifyLocal$1<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
373
390
  //#endregion
374
391
  //#region src/types/not-field.d.ts
375
392
  /** Props for the `NotField` component. */
@@ -433,17 +450,23 @@ interface NotFieldProps {
433
450
  interface NotFieldSlots<TSchema extends ObjectSchema> {
434
451
  /** The default slot receives the full field state and event handlers. */
435
452
  default?: (props: {
436
- /** The dot-separated path to this field. */path: string;
453
+ /** The dot-separated path to this field. */
454
+ path: string;
437
455
  /**
438
456
  * The current value of this field — read-only snapshot for display purposes.
439
457
  * Do not mutate directly or use with `v-model`.
440
458
  * For two-way binding use `v-model="form.values.fieldName"` instead.
441
459
  */
442
- value: any; /** All validation issues for this field from the last validation run. */
443
- errors: Array<StandardSchemaV1.Issue>; /** Whether this field currently has no validation errors. */
444
- isValid: boolean; /** Whether the user has interacted with this field, or the form has been submitted. */
445
- isTouched: boolean; /** Whether this field's current value differs from its initial value. */
446
- isDirty: boolean; /** Whether an async validator is currently running for this field. */
460
+ value: any;
461
+ /** All validation issues for this field from the last validation run. */
462
+ errors: Array<StandardSchemaV1.Issue>;
463
+ /** Whether this field currently has no validation errors. */
464
+ isValid: boolean;
465
+ /** Whether the user has interacted with this field, or the form has been submitted. */
466
+ isTouched: boolean;
467
+ /** Whether this field's current value differs from its initial value. */
468
+ isDirty: boolean;
469
+ /** Whether an async validator is currently running for this field. */
447
470
  isValidating: boolean;
448
471
  /**
449
472
  * Manually triggers validation for this field.
@@ -465,9 +488,13 @@ interface NotFieldSlots<TSchema extends ObjectSchema> {
465
488
  * ```
466
489
  */
467
490
  events: {
468
- /** Triggered when the field loses focus. */onBlur: () => void; /** Triggered on every keystroke or value change. */
469
- onInput: () => void; /** Triggered when the field value is committed. */
470
- onChange: () => void; /** Triggered when the field gains focus. */
491
+ /** Triggered when the field loses focus. */
492
+ onBlur: () => void;
493
+ /** Triggered on every keystroke or value change. */
494
+ onInput: () => void;
495
+ /** Triggered when the field value is committed. */
496
+ onChange: () => void;
497
+ /** Triggered when the field gains focus. */
471
498
  onFocus: () => void;
472
499
  };
473
500
  }) => any;
@@ -486,7 +513,7 @@ declare const __VLS_export$2: <TSchema extends ObjectSchema>(__VLS_props: NonNul
486
513
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
487
514
  };
488
515
  declare const _default$1: typeof __VLS_export$2;
489
- type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
516
+ type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
490
517
  //#endregion
491
518
  //#region src/components/not-form.vue.d.ts
492
519
  type __VLS_Slots$1 = NotFormSlots;
@@ -526,7 +553,8 @@ interface NotMessageProps {
526
553
  interface NotMessageSlots {
527
554
  /** The default slot receives the error message context for custom rendering */
528
555
  default?: (props: {
529
- /** The first active validation error message for the specified field */message?: string;
556
+ /** The first active validation error message for the specified field */
557
+ message?: string;
530
558
  }) => any;
531
559
  }
532
560
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "notform",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "private": false,
6
6
  "description": "Vue Forms Without the Friction",
7
7
  "author": "Favour Emeka <favorodera@gmail.com>",
@@ -45,22 +45,22 @@
45
45
  "dependencies": {
46
46
  "@standard-schema/spec": "^1.1.0",
47
47
  "dequal": "^2.0.3",
48
- "dot-prop": "^10.1.0",
48
+ "dot-prop": "^10.2.0",
49
49
  "klona": "^2.0.6"
50
50
  },
51
51
  "devDependencies": {
52
- "@favorodera/eslint-config": "^1.0.3",
53
- "@types/node": "^26.1.0",
54
- "@vitejs/plugin-vue": "^6.0.7",
55
- "@vitest/ui": "^4.1.9",
52
+ "@favorodera/eslint-config": "^1.0.4",
53
+ "@types/node": "^26.1.2",
54
+ "@vitejs/plugin-vue": "^6.0.8",
55
+ "@vitest/ui": "^4.1.10",
56
56
  "@vue/test-utils": "^2.4.11",
57
- "happy-dom": "^20.10.6",
58
- "tsdown": "^0.22.3",
57
+ "happy-dom": "^20.11.1",
58
+ "tsdown": "^0.22.14",
59
59
  "type-fest": "^5.7.0",
60
- "vite": "^8.1.3",
61
- "vitest": "^4.1.9",
62
- "vue": "^3.5.39",
63
- "vue-tsc": "^3.3.6"
60
+ "vite": "^8.2.0",
61
+ "vitest": "^4.1.10",
62
+ "vue": "^3.0.0",
63
+ "vue-tsc": "^3.3.9"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "tsdown",