@formisch/vue 0.7.6 → 0.8.0

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/README.md CHANGED
@@ -53,7 +53,13 @@ In addition, Formisch offers several functions (we call them "methods") that can
53
53
 
54
54
  ## Comparison
55
55
 
56
- What makes Formisch unique is its framework-agnostic core, which is fully native to the framework you are using. It works by inserting framework-specific reactivity blocks when the core package is built. The result is a small bundle size and native performance for any UI update. This feature, along with a few others, distinguishes Formisch from other form libraries. My vision for Formisch is to create a framework-agnostic platform similar to [Vite](https://vite.dev/), but for forms.
56
+ What makes Formisch unique is its framework-agnostic core, which is fully native to the framework you are using. It works by inserting framework-specific reactivity blocks when the core package is built, giving you native performance for any UI update. A modular methods API keeps bundles starting at just ~2.5 kB by only including the methods you import, and end-to-end type safety covers deeply nested paths and field arrays with TypeScript inference that stays fast even as forms grow.
57
+
58
+ For a side-by-side look at how Formisch compares to VeeValidate, FormKit, and TanStack Form, see the [comparison guide](https://formisch.dev/vue/guides/comparison/).
59
+
60
+ ## Vision
61
+
62
+ My vision for Formisch is to create a framework-agnostic platform similar to [Vite](https://vite.dev/), but for forms — a shared core that lets the same mental model and codebase work natively across every modern UI framework.
57
63
 
58
64
  ## Partners
59
65
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import * as vue3 from "vue";
2
+ import * as vue1 from "vue";
3
3
  import { ComponentPublicInstance, MaybeRefOrGetter, ShallowRef as Signal } from "vue";
4
4
 
5
5
  //#region ../../packages/core/dist/index.vue.d.ts
@@ -9,9 +9,33 @@ import { ComponentPublicInstance, MaybeRefOrGetter, ShallowRef as Signal } from
9
9
  * Schema type.
10
10
  */
11
11
  type Schema = v.GenericSchema | v.GenericSchemaAsync;
12
+ /**
13
+ * Object schema type.
14
+ */
15
+ type ObjectSchema = v.LooseObjectSchema<v.ObjectEntries, v.ErrorMessage<v.LooseObjectIssue> | undefined> | v.ObjectSchema<v.ObjectEntries, v.ErrorMessage<v.ObjectIssue> | undefined> | v.StrictObjectSchema<v.ObjectEntries, v.ErrorMessage<v.StrictObjectIssue> | undefined> | v.VariantSchema<string, v.VariantOptions<string>, v.ErrorMessage<v.VariantIssue> | undefined>;
16
+ /**
17
+ * Object schema async type.
18
+ */
19
+ type ObjectSchemaAsync = v.LooseObjectSchemaAsync<v.ObjectEntriesAsync, v.ErrorMessage<v.LooseObjectIssue> | undefined> | v.ObjectSchemaAsync<v.ObjectEntriesAsync, v.ErrorMessage<v.ObjectIssue> | undefined> | v.StrictObjectSchemaAsync<v.ObjectEntriesAsync, v.ErrorMessage<v.StrictObjectIssue> | undefined> | v.VariantSchemaAsync<string, v.VariantOptionsAsync<string>, v.ErrorMessage<v.VariantIssue> | undefined>;
20
+ /**
21
+ * Object root schema type.
22
+ */
23
+ type ObjectRootSchema = ObjectSchema | v.IntersectSchema<ObjectSchema[], v.ErrorMessage<v.IntersectIssue> | undefined> | v.UnionSchema<ObjectSchema[], v.ErrorMessage<v.UnionIssue<v.BaseIssue<unknown>>> | undefined>;
24
+ /**
25
+ * Object root schema async type.
26
+ */
27
+ type ObjectRootSchemaAsync = ObjectSchemaAsync | v.IntersectSchemaAsync<(ObjectSchema | ObjectSchemaAsync)[], v.ErrorMessage<v.IntersectIssue> | undefined> | v.UnionSchemaAsync<(ObjectSchema | ObjectSchemaAsync)[], v.ErrorMessage<v.UnionIssue<v.BaseIssue<unknown>>> | undefined>;
28
+ /**
29
+ * Form schema type.
30
+ *
31
+ * Hint: Forms must have an object root, so only object schemas (sync or async),
32
+ * combinators (intersect, union, variant) whose options resolve to objects, and
33
+ * `lazy` schemas wrapping any of these are allowed at the top level. Use
34
+ * {@link Schema} for nested field schemas.
35
+ */
36
+ type FormSchema = ObjectRootSchema | ObjectRootSchemaAsync | v.LazySchema<ObjectRootSchema> | v.LazySchemaAsync<ObjectRootSchema | ObjectRootSchemaAsync>;
12
37
  //#endregion
13
38
  //#region src/types/signal/signal.d.ts
14
-
15
39
  /**
16
40
  * Batch interface.
17
41
  */
@@ -217,7 +241,7 @@ type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submi
217
241
  /**
218
242
  * Form config interface.
219
243
  */
220
- interface FormConfig<TSchema extends Schema = Schema> {
244
+ interface FormConfig<TSchema extends FormSchema = FormSchema> {
221
245
  /**
222
246
  * The schema of the form.
223
247
  */
@@ -238,7 +262,7 @@ interface FormConfig<TSchema extends Schema = Schema> {
238
262
  /**
239
263
  * Internal form store interface.
240
264
  */
241
- interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObjectStore {
265
+ interface InternalFormStore<TSchema extends FormSchema = FormSchema> extends InternalObjectStore {
242
266
  /**
243
267
  * The element of the form.
244
268
  */
@@ -275,7 +299,7 @@ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObj
275
299
  /**
276
300
  * Base form store interface.
277
301
  */
278
- interface BaseFormStore<TSchema extends Schema = Schema> {
302
+ interface BaseFormStore<TSchema extends FormSchema = FormSchema> {
279
303
  /**
280
304
  * The internal form store.
281
305
  *
@@ -286,11 +310,11 @@ interface BaseFormStore<TSchema extends Schema = Schema> {
286
310
  /**
287
311
  * Submit handler type.
288
312
  */
289
- type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
313
+ type SubmitHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
290
314
  /**
291
315
  * Submit event handler type.
292
316
  */
293
- type SubmitEventHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
317
+ type SubmitEventHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
294
318
  //#endregion
295
319
  //#region src/types/path/path.d.ts
296
320
  /**
@@ -393,6 +417,28 @@ type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path =
393
417
  * based on the given value.
394
418
  */
395
419
  type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
420
+ /**
421
+ * Recursive helper for `DirtyPath` that prepends `TKey` to each deeper path,
422
+ * or falls through to `never` when the child is not an object.
423
+ */
424
+ type DeepDirtyPath<TChild, TKey$1 extends PathKey, TDepth extends 0[]> = TChild extends Record<PropertyKey, unknown> ? readonly [TKey$1, ...DirtyPath<TChild, [...TDepth, 0]>] : never;
425
+ /**
426
+ * Returns the union of all `RequiredPath`s that `getDirtyPaths` can emit
427
+ * for a given input type. Object fields contribute their own path and the
428
+ * paths of their descendants; arrays and tuples are atomic and contribute
429
+ * only their own path, because dirty arrays are returned as complete units.
430
+ *
431
+ * Narrowing is exact for the first 5 levels of nesting; deeper paths fall
432
+ * back to `RequiredPath` to keep the result a complete superset of any
433
+ * path the runtime can address.
434
+ *
435
+ * Hint: Arrays and tuples are atomic because they don't structurally
436
+ * extend `Record<PropertyKey, unknown>` and so fall through to `never`
437
+ * via `DeepDirtyPath` — no explicit array check is needed. `TDepth` is
438
+ * a tuple-length counter capped at 5 to bound TypeScript instantiation
439
+ * cost.
440
+ */
441
+ type DirtyPath<TValue, TDepth extends 0[] = []> = TDepth["length"] extends 5 ? RequiredPath : TValue extends Record<PropertyKey, unknown> ? { [TKey in ExactKeysOf<TValue>]: readonly [TKey] | DeepDirtyPath<NonNullable<PropertiesOf<TValue>[TKey]>, TKey, TDepth> }[ExactKeysOf<TValue>] : never;
396
442
  //#endregion
397
443
  //#region src/array/copyItemState/copyItemState.d.ts
398
444
  /**
@@ -411,7 +457,7 @@ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArra
411
457
  /**
412
458
  * Focus field config interface.
413
459
  */
414
- interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
460
+ interface FocusFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
415
461
  /**
416
462
  * The path to the field to focus.
417
463
  */
@@ -425,7 +471,7 @@ interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPa
425
471
  * @param form The form store containing the field.
426
472
  * @param config The focus field configuration.
427
473
  */
428
- declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
474
+ declare function focus<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
429
475
  //#endregion
430
476
  //#region src/getAllErrors/getAllErrors.d.ts
431
477
  /**
@@ -439,6 +485,93 @@ declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(
439
485
  */
440
486
  declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
441
487
  //#endregion
488
+ //#region src/getDirtyInput/getDirtyInput.d.ts
489
+ /**
490
+ * Get form dirty input config interface.
491
+ */
492
+ interface GetFormDirtyInputConfig {
493
+ /**
494
+ * The path to a field. Leave undefined to get the dirty input of the entire
495
+ * form.
496
+ */
497
+ readonly path?: undefined;
498
+ }
499
+ /**
500
+ * Get field dirty input config interface.
501
+ */
502
+ interface GetFieldDirtyInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
503
+ /**
504
+ * The path to the field to retrieve the dirty input from.
505
+ */
506
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
507
+ }
508
+ /**
509
+ * Retrieves only the dirty input values of a specific field or the entire
510
+ * form. Arrays are treated as atomic and returned in full if any item is
511
+ * dirty, while object keys without a dirty descendant are omitted. Returns
512
+ * `undefined` if no field in the inspected subtree is dirty.
513
+ *
514
+ * @param form The form store to retrieve dirty input from.
515
+ *
516
+ * @returns The dirty input of the form or specified field, or `undefined`.
517
+ */
518
+ declare function getDirtyInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DeepPartial<v.InferInput<TSchema>> | undefined;
519
+ /**
520
+ * Retrieves only the dirty input values of a specific field or the entire
521
+ * form. Arrays are treated as atomic and returned in full if any item is
522
+ * dirty, while object keys without a dirty descendant are omitted. Returns
523
+ * `undefined` if no field in the inspected subtree is dirty.
524
+ *
525
+ * @param form The form store to retrieve dirty input from.
526
+ * @param config The get dirty input configuration.
527
+ *
528
+ * @returns The dirty input of the form or specified field, or `undefined`.
529
+ */
530
+ declare function getDirtyInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldDirtyInputConfig<TSchema, TFieldPath> : GetFormDirtyInputConfig): DeepPartial<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>> | undefined;
531
+ //#endregion
532
+ //#region src/getDirtyPaths/getDirtyPaths.d.ts
533
+ /**
534
+ * Get form dirty paths config interface.
535
+ */
536
+ interface GetFormDirtyPathsConfig {
537
+ /**
538
+ * The path to a field. Leave undefined to inspect the entire form.
539
+ */
540
+ readonly path?: undefined;
541
+ }
542
+ /**
543
+ * Get field dirty paths config interface.
544
+ */
545
+ interface GetFieldDirtyPathsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
546
+ /**
547
+ * The path to the field to inspect.
548
+ */
549
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
550
+ }
551
+ /**
552
+ * Returns a list of paths to the dirty fields of a specific field or the
553
+ * entire form. Arrays are treated as atomic and contribute only their own
554
+ * path if any item is dirty, while object branches are recursed into. Returns
555
+ * an empty list if no field in the inspected subtree is dirty.
556
+ *
557
+ * @param form The form store to inspect.
558
+ *
559
+ * @returns The list of paths to the dirty fields.
560
+ */
561
+ declare function getDirtyPaths<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DirtyPath<v.InferInput<TSchema>>[];
562
+ /**
563
+ * Returns a list of paths to the dirty fields of a specific field or the
564
+ * entire form. Arrays are treated as atomic and contribute only their own
565
+ * path if any item is dirty, while object branches are recursed into. Returns
566
+ * an empty list if no field in the inspected subtree is dirty.
567
+ *
568
+ * @param form The form store to inspect.
569
+ * @param config The get dirty paths configuration.
570
+ *
571
+ * @returns The list of paths to the dirty fields.
572
+ */
573
+ declare function getDirtyPaths<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldDirtyPathsConfig<TSchema, TFieldPath> : GetFormDirtyPathsConfig): DirtyPath<v.InferInput<TSchema>>[];
574
+ //#endregion
442
575
  //#region src/getErrors/getErrors.d.ts
443
576
  /**
444
577
  * Get form errors config interface.
@@ -452,7 +585,7 @@ interface GetFormErrorsConfig {
452
585
  /**
453
586
  * Get field errors config interface.
454
587
  */
455
- interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
588
+ interface GetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
456
589
  /**
457
590
  * The path to the field to retrieve errors from.
458
591
  */
@@ -467,7 +600,7 @@ interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
467
600
  *
468
601
  * @returns A non-empty array of error messages, or null if no errors exist.
469
602
  */
470
- declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
603
+ declare function getErrors<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
471
604
  /**
472
605
  * Retrieves error messages from the form. When called without a config,
473
606
  * returns form-level errors. When called with a path, returns errors for
@@ -478,7 +611,7 @@ declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>)
478
611
  *
479
612
  * @returns A non-empty array of error messages, or null if no errors exist.
480
613
  */
481
- declare function getErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldErrorsConfig<TSchema, TFieldPath> : GetFormErrorsConfig): [string, ...string[]] | null;
614
+ declare function getErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldErrorsConfig<TSchema, TFieldPath> : GetFormErrorsConfig): [string, ...string[]] | null;
482
615
  //#endregion
483
616
  //#region src/getInput/getInput.d.ts
484
617
  /**
@@ -493,7 +626,7 @@ interface GetFormInputConfig {
493
626
  /**
494
627
  * Get field input config interface.
495
628
  */
496
- interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
629
+ interface GetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
497
630
  /**
498
631
  * The path to the field to retrieve input from.
499
632
  */
@@ -507,7 +640,7 @@ interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
507
640
  *
508
641
  * @returns The partial input values of the form or the specified field.
509
642
  */
510
- declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
643
+ declare function getInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
511
644
  /**
512
645
  * Retrieves the current input value of a specific field or the entire form.
513
646
  * Returns a partial object as not all fields may have been set.
@@ -517,7 +650,7 @@ declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>):
517
650
  *
518
651
  * @returns The partial input values of the form or the specified field.
519
652
  */
520
- declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldInputConfig<TSchema, TFieldPath> : GetFormInputConfig): PartialValues<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>>;
653
+ declare function getInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldInputConfig<TSchema, TFieldPath> : GetFormInputConfig): PartialValues<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>>;
521
654
  //#endregion
522
655
  //#region src/handleSubmit/handleSubmit.d.ts
523
656
  /**
@@ -530,7 +663,7 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
530
663
  *
531
664
  * @returns A submit event handler function to attach to the form element.
532
665
  */
533
- declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
666
+ declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
534
667
  /**
535
668
  * Creates a submit event handler for the form that prevents default browser
536
669
  * submission, validates the form input, and calls the provided handler if
@@ -541,13 +674,13 @@ declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchem
541
674
  *
542
675
  * @returns A submit event handler function to attach to the form element.
543
676
  */
544
- declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
677
+ declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
545
678
  //#endregion
546
679
  //#region src/insert/insert.d.ts
547
680
  /**
548
681
  * Insert array field config interface.
549
682
  */
550
- interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
683
+ interface InsertConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
551
684
  /**
552
685
  * The path to the field array to insert into.
553
686
  */
@@ -568,13 +701,13 @@ interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
568
701
  * @param form The form store containing the field array.
569
702
  * @param config The insert configuration specifying the path, index, and initial value.
570
703
  */
571
- declare function insert<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
704
+ declare function insert<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
572
705
  //#endregion
573
706
  //#region src/move/move.d.ts
574
707
  /**
575
708
  * Move array field config interface.
576
709
  */
577
- interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
710
+ interface MoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
578
711
  /**
579
712
  * The path to the field array to move an item within.
580
713
  */
@@ -595,13 +728,38 @@ interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
595
728
  * @param form The form store containing the field array.
596
729
  * @param config The move configuration specifying the path and source/destination indices.
597
730
  */
598
- declare function move<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
731
+ declare function move<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
732
+ //#endregion
733
+ //#region src/pickDirty/pickDirty.d.ts
734
+ /**
735
+ * Pick dirty config interface.
736
+ */
737
+ interface PickDirtyConfig<TValue extends object> {
738
+ /**
739
+ * The value to filter down to its dirty parts. Must be structurally
740
+ * compatible with the form's schema.
741
+ */
742
+ readonly from: TValue;
743
+ }
744
+ /**
745
+ * Picks only the dirty parts of the given value, using the form's dirty fields
746
+ * as a structural mask. Arrays are treated as atomic and object keys without a
747
+ * dirty descendant are omitted. Returns `undefined` if no field is dirty.
748
+ * Useful for filtering a validated output down to its changed parts before
749
+ * submitting.
750
+ *
751
+ * @param form The form store providing the dirty mask.
752
+ * @param config The pick dirty configuration.
753
+ *
754
+ * @returns The dirty parts of the value, or `undefined`.
755
+ */
756
+ declare function pickDirty<TSchema extends FormSchema, TValue extends object>(form: BaseFormStore<TSchema>, config: PickDirtyConfig<TValue>): DeepPartial<TValue> | undefined;
599
757
  //#endregion
600
758
  //#region src/remove/remove.d.ts
601
759
  /**
602
760
  * Remove array field config interface.
603
761
  */
604
- interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
762
+ interface RemoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
605
763
  /**
606
764
  * The path to the field array to remove an item from.
607
765
  */
@@ -618,13 +776,13 @@ interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
618
776
  * @param form The form store containing the field array.
619
777
  * @param config The remove configuration specifying the path and index.
620
778
  */
621
- declare function remove<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
779
+ declare function remove<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
622
780
  //#endregion
623
781
  //#region src/replace/replace.d.ts
624
782
  /**
625
783
  * Replace array field config interface.
626
784
  */
627
- interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
785
+ interface ReplaceConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
628
786
  /**
629
787
  * The path to the field array to replace an item within.
630
788
  */
@@ -644,7 +802,7 @@ interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends Required
644
802
  * @param form The form store containing the field array.
645
803
  * @param config The replace configuration specifying the path, index, and initial input.
646
804
  */
647
- declare function replace<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
805
+ declare function replace<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
648
806
  //#endregion
649
807
  //#region src/reset/reset.d.ts
650
808
  /**
@@ -667,7 +825,7 @@ interface ResetBaseConfig {
667
825
  /**
668
826
  * Reset form config interface.
669
827
  */
670
- interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
828
+ interface ResetFormConfig<TSchema extends FormSchema> extends ResetBaseConfig {
671
829
  /**
672
830
  * The path to a field. Leave undefined to reset the entire form.
673
831
  */
@@ -685,7 +843,7 @@ interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
685
843
  /**
686
844
  * Reset field config interface.
687
845
  */
688
- interface ResetFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
846
+ interface ResetFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
689
847
  /**
690
848
  * The path to the field to reset.
691
849
  */
@@ -712,7 +870,7 @@ declare function reset(form: BaseFormStore): void;
712
870
  * @param form The form store to reset.
713
871
  * @param config The reset configuration specifying what to reset and what to keep.
714
872
  */
715
- declare function reset<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
873
+ declare function reset<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
716
874
  //#endregion
717
875
  //#region src/setErrors/setErrors.d.ts
718
876
  /**
@@ -731,7 +889,7 @@ interface SetFormErrorsConfig {
731
889
  /**
732
890
  * Set field errors config interface.
733
891
  */
734
- interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
892
+ interface SetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
735
893
  /**
736
894
  * The path to the field to set errors on.
737
895
  */
@@ -749,13 +907,13 @@ interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
749
907
  * @param form The form store to set errors on.
750
908
  * @param config The set errors configuration specifying the path and error messages.
751
909
  */
752
- declare function setErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
910
+ declare function setErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
753
911
  //#endregion
754
912
  //#region src/setInput/setInput.d.ts
755
913
  /**
756
914
  * Set form input config interface.
757
915
  */
758
- interface SetFormInputConfig<TSchema extends Schema> {
916
+ interface SetFormInputConfig<TSchema extends FormSchema> {
759
917
  /**
760
918
  * The path to a field. Leave undefined to set the entire form input.
761
919
  */
@@ -768,7 +926,7 @@ interface SetFormInputConfig<TSchema extends Schema> {
768
926
  /**
769
927
  * Set field input config interface.
770
928
  */
771
- interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
929
+ interface SetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
772
930
  /**
773
931
  * The path to the field to set input on.
774
932
  */
@@ -786,7 +944,7 @@ interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
786
944
  * @param form The form store to set input on.
787
945
  * @param config The set form input configuration specifying the new input values.
788
946
  */
789
- declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
947
+ declare function setInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
790
948
  /**
791
949
  * Sets the input value of a specific field or the entire form. This updates
792
950
  * the field value(s) and triggers validation if required by the form's
@@ -795,7 +953,7 @@ declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>,
795
953
  * @param form The form store to set input on.
796
954
  * @param config The set input configuration specifying the path and new value.
797
955
  */
798
- declare function setInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
956
+ declare function setInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
799
957
  //#endregion
800
958
  //#region src/submit/submit.d.ts
801
959
  /**
@@ -810,7 +968,7 @@ declare function submit(form: BaseFormStore): void;
810
968
  /**
811
969
  * Swap array field config interface.
812
970
  */
813
- interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
971
+ interface SwapConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
814
972
  /**
815
973
  * The path to the field array to swap items within.
816
974
  */
@@ -830,7 +988,7 @@ interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
830
988
  * @param form The form store containing the field array.
831
989
  * @param config The swap configuration specifying the path and indices to swap.
832
990
  */
833
- declare function swap<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
991
+ declare function swap<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
834
992
  //#endregion
835
993
  //#region src/validate/validate.d.ts
836
994
  /**
@@ -852,7 +1010,7 @@ interface ValidateFormConfig {
852
1010
  *
853
1011
  * @returns A promise resolving to the validation result.
854
1012
  */
855
- declare function validate<TSchema extends Schema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
1013
+ declare function validate<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
856
1014
  //#endregion
857
1015
  //#endregion
858
1016
  //#region src/types/field.d.ts
@@ -888,7 +1046,7 @@ interface FieldElementProps {
888
1046
  /**
889
1047
  * Field store interface.
890
1048
  */
891
- interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1049
+ interface FieldStore<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
892
1050
  /**
893
1051
  * The path to the field within the form.
894
1052
  */
@@ -925,7 +1083,7 @@ interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends Require
925
1083
  /**
926
1084
  * Field array store interface.
927
1085
  */
928
- interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1086
+ interface FieldArrayStore<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
929
1087
  /**
930
1088
  * The path to the array field within the form.
931
1089
  */
@@ -956,7 +1114,7 @@ interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath exten
956
1114
  /**
957
1115
  * Form store interface.
958
1116
  */
959
- interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSchema> {
1117
+ interface FormStore<TSchema extends FormSchema = FormSchema> extends BaseFormStore<TSchema> {
960
1118
  /**
961
1119
  * Whether the form is currently submitting.
962
1120
  */
@@ -994,7 +1152,7 @@ interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSche
994
1152
  /**
995
1153
  * Field component props interface.
996
1154
  */
997
- interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1155
+ interface FieldProps<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
998
1156
  /**
999
1157
  * The form store to which the field belongs.
1000
1158
  */
@@ -1004,15 +1162,15 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
1004
1162
  */
1005
1163
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
1006
1164
  }
1007
- declare const __VLS_export$2: <TSchema extends Schema, TFieldPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1008
- props: __VLS_PrettifyLocal$2<FieldProps<TSchema, TFieldPath>> & vue3.PublicProps;
1165
+ declare const __VLS_export$2: <TSchema extends FormSchema, TFieldPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1166
+ props: __VLS_PrettifyLocal$2<FieldProps<TSchema, TFieldPath>> & vue1.PublicProps;
1009
1167
  expose: (exposed: {}) => void;
1010
1168
  attrs: any;
1011
1169
  slots: {
1012
1170
  default(props: FieldStore<TSchema, TFieldPath>): any;
1013
1171
  };
1014
1172
  emit: {};
1015
- }>) => vue3.VNode & {
1173
+ }>) => vue1.VNode & {
1016
1174
  __ctx?: Awaited<typeof __VLS_setup>;
1017
1175
  };
1018
1176
  declare const _default: typeof __VLS_export$2;
@@ -1022,7 +1180,7 @@ type __VLS_PrettifyLocal$2<T> = { [K in keyof T as K]: T[K] } & {};
1022
1180
  /**
1023
1181
  * Field array component props interface.
1024
1182
  */
1025
- interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1183
+ interface FieldArrayProps<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1026
1184
  /**
1027
1185
  * The form store to which the field array belongs.
1028
1186
  */
@@ -1032,15 +1190,15 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
1032
1190
  */
1033
1191
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
1034
1192
  }
1035
- declare const __VLS_export$1: <TSchema extends Schema, TFieldArrayPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1036
- props: __VLS_PrettifyLocal$1<FieldArrayProps<TSchema, TFieldArrayPath>> & vue3.PublicProps;
1193
+ declare const __VLS_export$1: <TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1194
+ props: __VLS_PrettifyLocal$1<FieldArrayProps<TSchema, TFieldArrayPath>> & vue1.PublicProps;
1037
1195
  expose: (exposed: {}) => void;
1038
1196
  attrs: any;
1039
1197
  slots: {
1040
1198
  default(props: FieldArrayStore<TSchema, TFieldArrayPath>): any;
1041
1199
  };
1042
1200
  emit: {};
1043
- }>) => vue3.VNode & {
1201
+ }>) => vue1.VNode & {
1044
1202
  __ctx?: Awaited<typeof __VLS_setup>;
1045
1203
  };
1046
1204
  declare const _default$1: typeof __VLS_export$1;
@@ -1050,7 +1208,7 @@ type __VLS_PrettifyLocal$1<T> = { [K in keyof T as K]: T[K] } & {};
1050
1208
  /**
1051
1209
  * Form component props interface.
1052
1210
  */
1053
- interface FormProps<TSchema extends Schema = Schema> {
1211
+ interface FormProps<TSchema extends FormSchema = FormSchema> {
1054
1212
  /**
1055
1213
  * The form store instance.
1056
1214
  */
@@ -1060,15 +1218,15 @@ interface FormProps<TSchema extends Schema = Schema> {
1060
1218
  */
1061
1219
  onSubmit: SubmitEventHandler<TSchema>;
1062
1220
  }
1063
- declare const __VLS_export: <TSchema extends Schema = Schema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1064
- props: __VLS_PrettifyLocal<FormProps<TSchema>> & vue3.PublicProps;
1221
+ declare const __VLS_export: <TSchema extends FormSchema = FormSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1222
+ props: __VLS_PrettifyLocal<FormProps<TSchema>> & vue1.PublicProps;
1065
1223
  expose: (exposed: {}) => void;
1066
1224
  attrs: any;
1067
1225
  slots: {
1068
1226
  default?: (props: {}) => any;
1069
1227
  };
1070
1228
  emit: {};
1071
- }>) => vue3.VNode & {
1229
+ }>) => vue1.VNode & {
1072
1230
  __ctx?: Awaited<typeof __VLS_setup>;
1073
1231
  };
1074
1232
  declare const _default$2: typeof __VLS_export;
@@ -1078,7 +1236,7 @@ type __VLS_PrettifyLocal<T> = { [K in keyof T as K]: T[K] } & {};
1078
1236
  /**
1079
1237
  * Use field config interface.
1080
1238
  */
1081
- interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1239
+ interface UseFieldConfig<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
1082
1240
  /**
1083
1241
  * The path to the field within the form schema.
1084
1242
  */
@@ -1092,13 +1250,13 @@ interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends Req
1092
1250
  *
1093
1251
  * @returns The field store with reactive properties and element props.
1094
1252
  */
1095
- declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
1253
+ declare function useField<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
1096
1254
  //#endregion
1097
1255
  //#region src/composables/useFieldArray/useFieldArray.d.ts
1098
1256
  /**
1099
1257
  * Use field array config interface.
1100
1258
  */
1101
- interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1259
+ interface UseFieldArrayConfig<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1102
1260
  /**
1103
1261
  * The path to the field array within the form schema.
1104
1262
  */
@@ -1112,7 +1270,7 @@ interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath e
1112
1270
  *
1113
1271
  * @returns The field array store with reactive properties for array management.
1114
1272
  */
1115
- declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1273
+ declare function useFieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1116
1274
  //#endregion
1117
1275
  //#region src/composables/useForm/useForm.d.ts
1118
1276
  /**
@@ -1123,6 +1281,6 @@ declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends R
1123
1281
  *
1124
1282
  * @returns The form store with reactive properties.
1125
1283
  */
1126
- declare function useForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
1284
+ declare function useForm<TSchema extends FormSchema>(config: FormConfig<TSchema>): FormStore<TSchema>;
1127
1285
  //#endregion
1128
- export { type DeepPartial, _default as Field, _default$1 as FieldArray, FieldArrayStore, type FieldElement, FieldElementProps, FieldStore, FocusFieldConfig, _default$2 as Form, type FormConfig, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitEventHandler, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
1286
+ export { type DeepPartial, _default as Field, _default$1 as FieldArray, FieldArrayStore, type FieldElement, FieldElementProps, FieldStore, FocusFieldConfig, _default$2 as Form, type FormConfig, type FormSchema, FormStore, GetFieldDirtyInputConfig, GetFieldDirtyPathsConfig, GetFieldErrorsConfig, GetFieldInputConfig, GetFormDirtyInputConfig, GetFormDirtyPathsConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, PickDirtyConfig, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitEventHandler, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
package/dist/index.js CHANGED
@@ -253,20 +253,45 @@ function swapItemState(firstInternalFieldStore, secondInternalFieldStore) {
253
253
  });
254
254
  }
255
255
  /**
256
- * Returns the current input of the field store. For arrays and objects,
257
- * recursively collects input from all children. Returns `null` or `undefined`
258
- * for nullish array/object inputs, or the primitive value for value fields.
256
+ * Returns whether the specified boolean property is true for the field store
257
+ * or any of its nested children. Recursively checks arrays and objects.
259
258
  *
260
- * @param internalFieldStore The field store to get input from.
259
+ * @param internalFieldStore The field store to check.
260
+ * @param type The boolean property type to check.
261
261
  *
262
- * @returns The field input.
262
+ * @returns Whether the property is true.
263
263
  */
264
264
  /* @__NO_SIDE_EFFECTS__ */
265
- function getFieldInput(internalFieldStore) {
265
+ function getFieldBool(internalFieldStore, type) {
266
+ if (internalFieldStore[type].value) return true;
267
+ if (internalFieldStore.kind === "array") {
268
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
269
+ return false;
270
+ }
271
+ if (internalFieldStore.kind == "object") {
272
+ for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
273
+ return false;
274
+ }
275
+ return false;
276
+ }
277
+ /**
278
+ * Returns only the dirty input of the field store. Arrays are treated as
279
+ * atomic and returned in full if any item is dirty, while object keys without
280
+ * a dirty descendant are omitted. Returns `undefined` if no descendant is
281
+ * dirty.
282
+ *
283
+ * @param internalFieldStore The field store to get dirty input from.
284
+ * @param dirtyOnly Whether to only include dirty fields. Defaults to `true`.
285
+ *
286
+ * @returns The dirty input, or `undefined` if no descendant is dirty.
287
+ */
288
+ /* @__NO_SIDE_EFFECTS__ */
289
+ function getDirtyFieldInput(internalFieldStore, dirtyOnly = true) {
290
+ if (dirtyOnly && !/* @__PURE__ */ getFieldBool(internalFieldStore, "isDirty")) return;
266
291
  if (internalFieldStore.kind === "array") {
267
292
  if (internalFieldStore.input.value) {
268
293
  const value = [];
269
- for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
294
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getDirtyFieldInput(internalFieldStore.children[index], false);
270
295
  return value;
271
296
  }
272
297
  return internalFieldStore.input.value;
@@ -274,7 +299,10 @@ function getFieldInput(internalFieldStore) {
274
299
  if (internalFieldStore.kind === "object") {
275
300
  if (internalFieldStore.input.value) {
276
301
  const value = {};
277
- for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
302
+ for (const key in internalFieldStore.children) {
303
+ const child = internalFieldStore.children[key];
304
+ if (!dirtyOnly || /* @__PURE__ */ getFieldBool(child, "isDirty")) value[key] = /* @__PURE__ */ getDirtyFieldInput(child, dirtyOnly);
305
+ }
278
306
  return value;
279
307
  }
280
308
  return internalFieldStore.input.value;
@@ -282,26 +310,33 @@ function getFieldInput(internalFieldStore) {
282
310
  return internalFieldStore.input.value;
283
311
  }
284
312
  /**
285
- * Returns whether the specified boolean property is true for the field store
286
- * or any of its nested children. Recursively checks arrays and objects.
313
+ * Returns the current input of the field store. For arrays and objects,
314
+ * recursively collects input from all children. Returns `null` or `undefined`
315
+ * for nullish array/object inputs, or the primitive value for value fields.
287
316
  *
288
- * @param internalFieldStore The field store to check.
289
- * @param type The boolean property type to check.
317
+ * @param internalFieldStore The field store to get input from.
290
318
  *
291
- * @returns Whether the property is true.
319
+ * @returns The field input.
292
320
  */
293
321
  /* @__NO_SIDE_EFFECTS__ */
294
- function getFieldBool(internalFieldStore, type) {
295
- if (internalFieldStore[type].value) return true;
322
+ function getFieldInput(internalFieldStore) {
296
323
  if (internalFieldStore.kind === "array") {
297
- for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
298
- return false;
324
+ if (internalFieldStore.input.value) {
325
+ const value = [];
326
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
327
+ return value;
328
+ }
329
+ return internalFieldStore.input.value;
299
330
  }
300
- if (internalFieldStore.kind == "object") {
301
- for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
302
- return false;
331
+ if (internalFieldStore.kind === "object") {
332
+ if (internalFieldStore.input.value) {
333
+ const value = {};
334
+ for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
335
+ return value;
336
+ }
337
+ return internalFieldStore.input.value;
303
338
  }
304
- return false;
339
+ return internalFieldStore.input.value;
305
340
  }
306
341
  /**
307
342
  * Returns the field store at the specified path by traversing the form store's
@@ -560,6 +595,17 @@ function getAllErrors(form) {
560
595
  return allErrors;
561
596
  }
562
597
  /* @__NO_SIDE_EFFECTS__ */
598
+ function getDirtyInput(form, config) {
599
+ return getDirtyFieldInput(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]);
600
+ }
601
+ /* @__NO_SIDE_EFFECTS__ */
602
+ function getDirtyPaths(form, config) {
603
+ config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL];
604
+ const paths = [];
605
+ config?.path && [...config.path];
606
+ return paths;
607
+ }
608
+ /* @__NO_SIDE_EFFECTS__ */
563
609
  function getErrors(form, config) {
564
610
  return (config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]).errors.value;
565
611
  }
@@ -653,6 +699,48 @@ function move(form, config) {
653
699
  });
654
700
  }
655
701
  /**
702
+ * Picks only the dirty parts of the given value, using the form's dirty fields
703
+ * as a structural mask. Arrays are treated as atomic and object keys without a
704
+ * dirty descendant are omitted. Returns `undefined` if no field is dirty.
705
+ * Useful for filtering a validated output down to its changed parts before
706
+ * submitting.
707
+ *
708
+ * @param form The form store providing the dirty mask.
709
+ * @param config The pick dirty configuration.
710
+ *
711
+ * @returns The dirty parts of the value, or `undefined`.
712
+ */
713
+ /* @__NO_SIDE_EFFECTS__ */
714
+ function pickDirty(form, config) {
715
+ if (!getFieldBool(form[INTERNAL], "isDirty")) return;
716
+ const result = /* @__PURE__ */ pickFieldValue(form[INTERNAL], config.from);
717
+ return Object.keys(result).length ? result : void 0;
718
+ }
719
+ /**
720
+ * Recursively picks the dirty parts of a value using the field store as a
721
+ * structural mask, reading from the supplied value rather than the form's own
722
+ * input. Objects with non-nullish input recurse into their dirty children that
723
+ * are present in the value, while arrays, primitives, nullish-cleared fields
724
+ * and shape-diverging values are returned as-is.
725
+ *
726
+ * @param internalFieldStore The field store used as the dirty mask.
727
+ * @param value The value to pick the dirty parts from.
728
+ *
729
+ * @returns The dirty parts of the value.
730
+ */
731
+ /* @__NO_SIDE_EFFECTS__ */
732
+ function pickFieldValue(internalFieldStore, value) {
733
+ if (internalFieldStore.kind === "object" && internalFieldStore.input.value && value && typeof value === "object" && !Array.isArray(value)) {
734
+ const result = {};
735
+ for (const key in internalFieldStore.children) {
736
+ const child = internalFieldStore.children[key];
737
+ if (getFieldBool(child, "isDirty") && key in value) result[key] = /* @__PURE__ */ pickFieldValue(child, value[key]);
738
+ }
739
+ return result;
740
+ }
741
+ return value;
742
+ }
743
+ /**
656
744
  * Removes an item from a field array at the specified index. All items after
657
745
  * the removed item are shifted down by one index.
658
746
  *
@@ -977,4 +1065,4 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
977
1065
  var Form_default = Form_vue_vue_type_script_setup_true_lang_default;
978
1066
 
979
1067
  //#endregion
980
- export { Field_default as Field, FieldArray_default as FieldArray, Form_default as Form, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
1068
+ export { Field_default as Field, FieldArray_default as FieldArray, Form_default as Form, focus, getAllErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formisch/vue",
3
3
  "description": "The lightweight, schema-first, and fully type-safe form library for Vue",
4
- "version": "0.7.6",
4
+ "version": "0.8.0",
5
5
  "license": "MIT",
6
6
  "author": "Fabian Hiller",
7
7
  "homepage": "https://formisch.dev",
@@ -56,14 +56,14 @@
56
56
  "tsdown": "^0.16.8",
57
57
  "typescript": "~5.8.3",
58
58
  "unplugin-vue": "^7.0.0",
59
- "valibot": "^1.2.0",
59
+ "valibot": "^1.4.1",
60
60
  "vitest": "^3.2.4",
61
61
  "vue": "^3.5.18",
62
62
  "vue-tsc": "^3.0.4"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "typescript": ">=5",
66
- "valibot": "^1.0.0",
66
+ "valibot": "^1.4.1",
67
67
  "vue": "^3.3.0"
68
68
  },
69
69
  "peerDependenciesMeta": {