@volverjs/form-vue 1.0.0-beta.29 → 1.0.0-beta.30

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.
@@ -1,5 +1,5 @@
1
1
  import { Component, ConcreteComponent, DeepReadonly, InjectionKey, PropType, Ref, SlotsType, readonly } from 'vue';
2
- import { inferFormattedError, z } from 'zod';
2
+ import { z } from 'zod';
3
3
  import { FormFieldType } from './enums';
4
4
  import { FormFieldComponentOptions, FormSchema, InjectedFormData, InjectedFormFieldData, InjectedFormWrapperData, Path } from './types';
5
5
  export declare function defineFormField<Schema extends FormSchema, Type>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>, formFieldInjectionKey: InjectionKey<InjectedFormFieldData<Schema>>, options?: FormFieldComponentOptions): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
@@ -116,9 +116,9 @@ export declare function defineFormField<Schema extends FormSchema, Type>(formPro
116
116
  }, SlotsType<{
117
117
  [key: string]: any;
118
118
  default: {
119
- errors: z.inferFormattedError<Schema>;
119
+ errors: DeepReadonly<z.inferFormattedError<Schema>>;
120
120
  formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined;
121
- formErrors?: DeepReadonly<inferFormattedError<Schema, string>> | undefined;
121
+ formErrors?: DeepReadonly<z.inferFormattedError<Schema, string>> | undefined;
122
122
  invalid: boolean;
123
123
  invalidLabel?: string[] | undefined;
124
124
  modelValue: any;
@@ -1,5 +1,5 @@
1
1
  import { Component, DeepReadonly, InjectionKey, PropType, Ref, SlotsType, readonly } from 'vue';
2
- import { inferFormattedError, z } from 'zod';
2
+ import { z } from 'zod';
3
3
  import { FormSchema, InjectedFormData, InjectedFormFieldsGroupData, InjectedFormWrapperData, Path } from './types';
4
4
  export declare function defineFormFieldsGroup<Schema extends FormSchema, Type>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>, formFieldsGroupInjectionKey: InjectionKey<InjectedFormFieldsGroupData<Schema>>): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
5
  is: {
@@ -93,9 +93,9 @@ export declare function defineFormFieldsGroup<Schema extends FormSchema, Type>(f
93
93
  }, SlotsType<{
94
94
  [key: string]: any;
95
95
  default: {
96
- errors?: Record<Path<z.TypeOf<Schema>>, inferFormattedError<Schema, string>> | undefined;
96
+ errors?: Record<Path<z.TypeOf<Schema>>, z.inferFormattedError<Schema, string>> | undefined;
97
97
  formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined;
98
- formErrors?: DeepReadonly<inferFormattedError<Schema, string>> | undefined;
98
+ formErrors?: DeepReadonly<z.inferFormattedError<Schema, string>> | undefined;
99
99
  invalid: boolean;
100
100
  invalids: Record<string, boolean>;
101
101
  invalidLabels?: Record<string, string[]> | undefined;
@@ -1,6 +1,6 @@
1
1
  import { Component, DeepReadonly, InjectionKey, PropType, SlotsType, VNode } from 'vue';
2
2
  import { FormSchema, InjectedFormData, FormTemplate } from './types';
3
- import { z, inferFormattedError } from 'zod';
3
+ import { z } from 'zod';
4
4
  import { FormStatus } from './enums';
5
5
  export declare function defineFormTemplate<Schema extends FormSchema, Type>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, VvFormField: Component): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
6
  schema: {
@@ -28,7 +28,7 @@ export declare function defineFormTemplate<Schema extends FormSchema, Type>(form
28
28
  scope: Record<string, unknown>;
29
29
  }, SlotsType<{
30
30
  default: {
31
- errors?: DeepReadonly<inferFormattedError<Schema, string>>;
31
+ errors?: DeepReadonly<z.inferFormattedError<Schema>>;
32
32
  formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type;
33
33
  invalid: boolean;
34
34
  status?: FormStatus;
@@ -1,5 +1,5 @@
1
1
  import { DeepReadonly, InjectionKey, Ref, SlotsType } from 'vue';
2
- import { inferFormattedError, z } from 'zod';
2
+ import { z } from 'zod';
3
3
  import { FormSchema, InjectedFormData, InjectedFormWrapperData } from './types';
4
4
  export declare function defineFormWrapper<Schema extends FormSchema, Type>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
5
  name: {
@@ -11,9 +11,9 @@ export declare function defineFormWrapper<Schema extends FormSchema, Type>(formP
11
11
  default: undefined;
12
12
  };
13
13
  }>, {
14
- errors: Readonly<Ref<DeepReadonly<inferFormattedError<Schema, string>> | undefined, DeepReadonly<inferFormattedError<Schema, string>> | undefined>> | undefined;
14
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>> | undefined;
15
15
  fields: Ref<Map<string, string> & Omit<Map<string, string>, keyof Map<any, any>>, Map<string, string> | (Map<string, string> & Omit<Map<string, string>, keyof Map<any, any>>)>;
16
- fieldsErrors: Ref<Map<string, inferFormattedError<Schema, string>>, Map<string, inferFormattedError<Schema, string>>>;
16
+ fieldsErrors: Ref<Map<string, z.inferFormattedError<Schema, string>>, Map<string, z.inferFormattedError<Schema, string>>>;
17
17
  formData: Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined> | undefined;
18
18
  invalid: import('vue').ComputedRef<boolean>;
19
19
  clear: (() => void) | undefined;
@@ -38,9 +38,9 @@ export declare function defineFormWrapper<Schema extends FormSchema, Type>(formP
38
38
  }, SlotsType<{
39
39
  default: {
40
40
  errors?: DeepReadonly<z.inferFormattedError<Schema>>;
41
- fieldsErrors: Map<string, inferFormattedError<Schema, string>>;
41
+ fieldsErrors: Map<string, z.inferFormattedError<Schema>>;
42
42
  formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type;
43
- formErrors?: DeepReadonly<inferFormattedError<Schema, string>>;
43
+ formErrors?: DeepReadonly<z.inferFormattedError<Schema>>;
44
44
  invalid: boolean;
45
45
  clear?: InjectedFormData<Schema, Type>['clear'];
46
46
  reset?: InjectedFormData<Schema, Type>['reset'];
package/dist/index.d.ts CHANGED
@@ -1,13 +1,10 @@
1
1
  import { InjectionKey, Plugin } from 'vue';
2
- import { AnyZodObject } from 'zod';
3
2
  import { defineForm } from './VvForm';
4
3
  import { defineFormField } from './VvFormField';
5
4
  import { defineFormFieldsGroup } from './VvFormFieldsGroup';
6
5
  import { defineFormWrapper } from './VvFormWrapper';
7
6
  import { InjectedFormData, InjectedFormWrapperData, InjectedFormFieldData, FormComposableOptions, FormPluginOptions, FormTemplateItem, Path, PathValue, FormSchema, FormTemplate } from './types';
8
- export declare const pluginInjectionKey: InjectionKey<FormPluginOptions>;
9
- export declare function createForm(options: FormPluginOptions): Plugin & Partial<ReturnType<typeof useForm>>;
10
- export declare function useForm<Schema extends FormSchema, Type>(schema: Schema, options?: FormComposableOptions<Schema, Type>): {
7
+ declare function _formType<Schema extends FormSchema, Type>(schema: Schema, options?: FormComposableOptions<Schema, Type>): {
11
8
  clear: () => void;
12
9
  errors: import('vue').Ref<import('zod').inferFormattedError<Schema, string> | undefined, import('zod').inferFormattedError<Schema, string> | undefined>;
13
10
  formData: import('vue').Ref<(undefined extends Type ? Partial<import('zod').TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<import('zod').TypeOf<Schema>> : Type) | undefined>;
@@ -221,7 +218,7 @@ export declare function useForm<Schema extends FormSchema, Type>(schema: Schema,
221
218
  }, import('vue').SlotsType<{
222
219
  [key: string]: any;
223
220
  default: {
224
- errors: import('zod').inferFormattedError<Schema, string>;
221
+ errors: import('vue').DeepReadonly<import('zod').inferFormattedError<Schema, string>>;
225
222
  formData?: (undefined extends Type ? Partial<import('zod').TypeOf<Schema>> : Type) | undefined;
226
223
  formErrors?: import('vue').DeepReadonly<import('zod').inferFormattedError<Schema, string>> | undefined;
227
224
  invalid: boolean;
@@ -423,511 +420,10 @@ export declare function useForm<Schema extends FormSchema, Type>(schema: Schema,
423
420
  validateWrapper?: (() => Promise<boolean>) | undefined;
424
421
  };
425
422
  }>, {}, {}, "invalid" | "reset" | "clear" | "submit" | "errors" | "tag" | "validate" | "formData" | "fields" | "fieldsErrors" | "validateWrapper", import('vue').ComponentProvideOptions, true, {}, any>;
426
- } | {
427
- clear: () => void;
428
- errors: import('vue').Ref<import('zod').inferFormattedError<AnyZodObject, string> | undefined, import('zod').inferFormattedError<AnyZodObject, string> | undefined>;
429
- formData: import('vue').Ref<(undefined extends Type ? Partial<{
430
- [x: string]: any;
431
- }> : Type) | undefined, (undefined extends Type ? Partial<{
432
- [x: string]: any;
433
- }> : Type) | undefined>;
434
- formFieldInjectionKey: InjectionKey<InjectedFormFieldData<AnyZodObject>>;
435
- formInjectionKey: InjectionKey<InjectedFormData<AnyZodObject, Type>>;
436
- formWrapperInjectionKey: InjectionKey<InjectedFormWrapperData<AnyZodObject>>;
437
- ignoreUpdates: import('@vueuse/core').IgnoredUpdater;
438
- invalid: import('vue').ComputedRef<boolean>;
439
- readonly: import('vue').Ref<boolean, boolean>;
440
- reset: () => void;
441
- status: import('vue').Ref<import('./enums').FormStatus | undefined, import('./enums').FormStatus | undefined>;
442
- stopUpdatesWatch: import('vue').WatchStopHandle;
443
- submit: () => Promise<boolean>;
444
- validate: (value?: (undefined extends Type ? Partial<{
445
- [x: string]: any;
446
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>;
447
- wrappers: Map<string, InjectedFormWrapperData<AnyZodObject>>;
448
- VvForm: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
449
- continuousValidation: {
450
- type: BooleanConstructor;
451
- default: boolean;
452
- };
453
- modelValue: {
454
- type: ObjectConstructor;
455
- default: () => {};
456
- };
457
- readonly: {
458
- type: BooleanConstructor;
459
- default: boolean;
460
- };
461
- tag: {
462
- type: StringConstructor;
463
- default: string;
464
- };
465
- template: {
466
- type: import('vue').PropType<FormTemplate<AnyZodObject, Type>>;
467
- default: undefined;
468
- };
469
- }>, {
470
- clear: () => void;
471
- errors: Readonly<import('vue').Ref<{
472
- readonly [x: string]: {
473
- readonly _errors: readonly string[];
474
- } | undefined;
475
- readonly _errors: readonly string[];
476
- } | undefined, {
477
- readonly [x: string]: {
478
- readonly _errors: readonly string[];
479
- } | undefined;
480
- readonly _errors: readonly string[];
481
- } | undefined>>;
482
- formData: import('vue').Ref<(undefined extends Type ? Partial<{
483
- [x: string]: any;
484
- }> : Type) | undefined, (undefined extends Type ? Partial<{
485
- [x: string]: any;
486
- }> : Type) | undefined>;
487
- ignoreUpdates: import('@vueuse/core').IgnoredUpdater;
488
- invalid: import('vue').ComputedRef<boolean>;
489
- isReadonly: import('vue').Ref<boolean, boolean>;
490
- reset: () => void;
491
- status: Readonly<import('vue').Ref<import('./enums').FormStatus | undefined, import('./enums').FormStatus | undefined>>;
492
- stopUpdatesWatch: import('vue').WatchStopHandle;
493
- submit: () => Promise<boolean>;
494
- validate: (value?: (undefined extends Type ? Partial<{
495
- [x: string]: any;
496
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>;
497
- wrappers: Map<string, InjectedFormWrapperData<AnyZodObject>>;
498
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "reset" | "submit" | "update:modelValue" | "update:readonly")[], "invalid" | "valid" | "reset" | "submit" | "update:modelValue" | "update:readonly", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
499
- continuousValidation: {
500
- type: BooleanConstructor;
501
- default: boolean;
502
- };
503
- modelValue: {
504
- type: ObjectConstructor;
505
- default: () => {};
506
- };
507
- readonly: {
508
- type: BooleanConstructor;
509
- default: boolean;
510
- };
511
- tag: {
512
- type: StringConstructor;
513
- default: string;
514
- };
515
- template: {
516
- type: import('vue').PropType<FormTemplate<AnyZodObject, Type>>;
517
- default: undefined;
518
- };
519
- }>> & Readonly<{
520
- onInvalid?: ((...args: any[]) => any) | undefined;
521
- onValid?: ((...args: any[]) => any) | undefined;
522
- onReset?: ((...args: any[]) => any) | undefined;
523
- onSubmit?: ((...args: any[]) => any) | undefined;
524
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
525
- "onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
526
- }>, {
527
- readonly: boolean;
528
- tag: string;
529
- template: FormTemplate<AnyZodObject, Type>;
530
- continuousValidation: boolean;
531
- modelValue: Record<string, any>;
532
- }, import('vue').SlotsType<{
533
- default: {
534
- errors: {
535
- readonly [x: string]: {
536
- readonly _errors: readonly string[];
537
- } | undefined;
538
- readonly _errors: readonly string[];
539
- } | undefined;
540
- formData: (undefined extends Type ? Partial<{
541
- [x: string]: any;
542
- }> : Type) | undefined;
543
- invalid: boolean;
544
- readonly: boolean;
545
- status: import('./enums').FormStatus | undefined;
546
- wrappers: Map<string, InjectedFormWrapperData<AnyZodObject>>;
547
- clear: () => void;
548
- ignoreUpdates: import('@vueuse/core').IgnoredUpdater;
549
- reset: () => void;
550
- stopUpdatesWatch: import('vue').WatchStopHandle;
551
- submit: () => Promise<boolean>;
552
- validate: (value?: (undefined extends Type ? Partial<{
553
- [x: string]: any;
554
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>;
555
- };
556
- }>, {}, {}, "invalid" | "valid" | "reset" | "status" | "readonly" | "clear" | "submit" | "errors" | "tag" | "template" | "validate", import('vue').ComponentProvideOptions, true, {}, any>;
557
- VvFormField: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
558
- type: {
559
- type: import('vue').PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
560
- validator: (value: import('./enums').FormFieldType) => boolean;
561
- default: import('./enums').FormFieldType;
562
- };
563
- is: {
564
- type: import('vue').PropType<string | import('vue').Component>;
565
- default: undefined;
566
- };
567
- name: {
568
- type: import('vue').PropType<string>;
569
- required: true;
570
- };
571
- props: {
572
- type: import('vue').PropType<Partial<{
573
- [x: string]: any;
574
- } | ((formData?: import('vue').Ref<ObjectConstructor, ObjectConstructor> | undefined) => Partial<{
575
- [x: string]: any;
576
- }> | undefined) | undefined>>;
577
- default: () => {};
578
- };
579
- showValid: {
580
- type: BooleanConstructor;
581
- default: boolean;
582
- };
583
- defaultValue: {
584
- type: (ObjectConstructor | ArrayConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
585
- default: undefined;
586
- };
587
- lazyLoad: {
588
- type: BooleanConstructor;
589
- default: boolean;
590
- };
591
- readonly: {
592
- type: BooleanConstructor;
593
- default: undefined;
594
- };
595
- }>, {
596
- component: import('vue').ComputedRef<{
597
- new (...args: any[]): any;
598
- __isFragment?: undefined;
599
- __isTeleport?: undefined;
600
- __isSuspense?: undefined;
601
- } | import('vue').ConcreteComponent>;
602
- hasProps: import('vue').ComputedRef<{
603
- name: string | {};
604
- invalid: boolean;
605
- valid: boolean | undefined;
606
- type: import('./enums').FormFieldType | undefined;
607
- invalidLabel: any;
608
- modelValue: any;
609
- readonly: boolean;
610
- 'onUpdate:modelValue': (value: unknown) => void;
611
- }>;
612
- invalid: import('vue').ComputedRef<boolean>;
613
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
614
- type: {
615
- type: import('vue').PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
616
- validator: (value: import('./enums').FormFieldType) => boolean;
617
- default: import('./enums').FormFieldType;
618
- };
619
- is: {
620
- type: import('vue').PropType<string | import('vue').Component>;
621
- default: undefined;
622
- };
623
- name: {
624
- type: import('vue').PropType<string>;
625
- required: true;
626
- };
627
- props: {
628
- type: import('vue').PropType<Partial<{
629
- [x: string]: any;
630
- } | ((formData?: import('vue').Ref<ObjectConstructor, ObjectConstructor> | undefined) => Partial<{
631
- [x: string]: any;
632
- }> | undefined) | undefined>>;
633
- default: () => {};
634
- };
635
- showValid: {
636
- type: BooleanConstructor;
637
- default: boolean;
638
- };
639
- defaultValue: {
640
- type: (ObjectConstructor | ArrayConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
641
- default: undefined;
642
- };
643
- lazyLoad: {
644
- type: BooleanConstructor;
645
- default: boolean;
646
- };
647
- readonly: {
648
- type: BooleanConstructor;
649
- default: undefined;
650
- };
651
- }>> & Readonly<{
652
- onInvalid?: ((...args: any[]) => any) | undefined;
653
- onValid?: ((...args: any[]) => any) | undefined;
654
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
655
- "onUpdate:formData"?: ((...args: any[]) => any) | undefined;
656
- }>, {
657
- type: "number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom";
658
- readonly: boolean;
659
- props: Partial<{
660
- [x: string]: any;
661
- } | ((formData?: import('vue').Ref<ObjectConstructor, ObjectConstructor> | undefined) => Partial<{
662
- [x: string]: any;
663
- }> | undefined) | undefined>;
664
- is: string | import('vue').Component;
665
- showValid: boolean;
666
- defaultValue: string | number | boolean | unknown[] | Record<string, any>;
667
- lazyLoad: boolean;
668
- }, import('vue').SlotsType<{
669
- [key: string]: any;
670
- default: {
671
- errors: import('zod').inferFormattedError<AnyZodObject, string>;
672
- formData?: (undefined extends Type ? Partial<{
673
- [x: string]: any;
674
- }> : Type) | undefined;
675
- formErrors?: {
676
- readonly [x: string]: {
677
- readonly _errors: readonly string[];
678
- } | undefined;
679
- readonly _errors: readonly string[];
680
- } | undefined;
681
- invalid: boolean;
682
- invalidLabel?: string[] | undefined;
683
- modelValue: any;
684
- readonly: boolean;
685
- onUpdate: (value: unknown) => void;
686
- submit?: (() => Promise<boolean>) | undefined;
687
- validate?: ((formData?: (undefined extends Type ? Partial<{
688
- [x: string]: any;
689
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
690
- };
691
- }>, {}, {}, "invalid" | "type" | "errors" | "component" | "hasProps" | "invalidLabel" | "is", import('vue').ComponentProvideOptions, true, {}, any>;
692
- VvFormFieldsGroup: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
693
- is: {
694
- type: import('vue').PropType<string | import('vue').Component>;
695
- default: undefined;
696
- };
697
- names: {
698
- type: import('vue').PropType<string[] | Record<string, string>>;
699
- required: true;
700
- };
701
- props: {
702
- type: import('vue').PropType<Partial<{
703
- [x: string]: any;
704
- } | ((formData?: import('vue').Ref<ObjectConstructor, ObjectConstructor> | undefined) => Partial<{
705
- [x: string]: any;
706
- }> | undefined) | undefined>>;
707
- default: () => {};
708
- };
709
- showValid: {
710
- type: BooleanConstructor;
711
- default: boolean;
712
- };
713
- defaultValues: {
714
- type: import('vue').PropType<Record<string, any>>;
715
- default: undefined;
716
- };
717
- readonly: {
718
- type: BooleanConstructor;
719
- default: undefined;
720
- };
721
- }>, {
722
- component: import('vue').ComputedRef<{
723
- render(): import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
724
- [key: string]: any;
725
- }>[];
726
- }>;
727
- hasProps: import('vue').ComputedRef<{
728
- names: {};
729
- invalid: boolean;
730
- invalids: Record<string, boolean>;
731
- valid: boolean | undefined;
732
- invalidLabels: Record<string, string[]> | undefined;
733
- modelValue: Record<string, any>;
734
- readonly: boolean;
735
- }>;
736
- invalid: import('vue').ComputedRef<boolean>;
737
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
738
- is: {
739
- type: import('vue').PropType<string | import('vue').Component>;
740
- default: undefined;
741
- };
742
- names: {
743
- type: import('vue').PropType<string[] | Record<string, string>>;
744
- required: true;
745
- };
746
- props: {
747
- type: import('vue').PropType<Partial<{
748
- [x: string]: any;
749
- } | ((formData?: import('vue').Ref<ObjectConstructor, ObjectConstructor> | undefined) => Partial<{
750
- [x: string]: any;
751
- }> | undefined) | undefined>>;
752
- default: () => {};
753
- };
754
- showValid: {
755
- type: BooleanConstructor;
756
- default: boolean;
757
- };
758
- defaultValues: {
759
- type: import('vue').PropType<Record<string, any>>;
760
- default: undefined;
761
- };
762
- readonly: {
763
- type: BooleanConstructor;
764
- default: undefined;
765
- };
766
- }>> & Readonly<{
767
- onInvalid?: ((...args: any[]) => any) | undefined;
768
- onValid?: ((...args: any[]) => any) | undefined;
769
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
770
- "onUpdate:formData"?: ((...args: any[]) => any) | undefined;
771
- }>, {
772
- readonly: boolean;
773
- props: Partial<{
774
- [x: string]: any;
775
- } | ((formData?: import('vue').Ref<ObjectConstructor, ObjectConstructor> | undefined) => Partial<{
776
- [x: string]: any;
777
- }> | undefined) | undefined>;
778
- is: string | import('vue').Component;
779
- showValid: boolean;
780
- defaultValues: Record<string, any>;
781
- }, import('vue').SlotsType<{
782
- [key: string]: any;
783
- default: {
784
- errors?: Record<string, import('zod').inferFormattedError<AnyZodObject, string>> | undefined;
785
- formData?: (undefined extends Type ? Partial<{
786
- [x: string]: any;
787
- }> : Type) | undefined;
788
- formErrors?: {
789
- readonly [x: string]: {
790
- readonly _errors: readonly string[];
791
- } | undefined;
792
- readonly _errors: readonly string[];
793
- } | undefined;
794
- invalid: boolean;
795
- invalids: Record<string, boolean>;
796
- invalidLabels?: Record<string, string[]> | undefined;
797
- modelValue: Record<string, any>;
798
- onUpdate: (value: Record<string, any>) => void;
799
- onUpdateField: (name: string, value: any) => void;
800
- readonly: boolean;
801
- submit?: (() => Promise<boolean>) | undefined;
802
- validate?: ((formData?: (undefined extends Type ? Partial<{
803
- [x: string]: any;
804
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
805
- };
806
- }>, {}, {}, "invalid" | "errors" | "component" | "hasProps" | "is" | "invalidLabels", import('vue').ComponentProvideOptions, true, {}, any>;
807
- VvFormTemplate: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
808
- schema: {
809
- type: import('vue').PropType<FormTemplate<AnyZodObject, Type>>;
810
- required: true;
811
- };
812
- scope: {
813
- type: import('vue').PropType<Record<string, unknown>>;
814
- default: () => {};
815
- };
816
- }>, (() => (import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
817
- [key: string]: any;
818
- }> | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
819
- [key: string]: any;
820
- }>[] | undefined)[]) | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
821
- schema: {
822
- type: import('vue').PropType<FormTemplate<AnyZodObject, Type>>;
823
- required: true;
824
- };
825
- scope: {
826
- type: import('vue').PropType<Record<string, unknown>>;
827
- default: () => {};
828
- };
829
- }>> & Readonly<{}>, {
830
- scope: Record<string, unknown>;
831
- }, import('vue').SlotsType<{
832
- default: {
833
- errors?: {
834
- readonly [x: string]: {
835
- readonly _errors: readonly string[];
836
- } | undefined;
837
- readonly _errors: readonly string[];
838
- } | undefined;
839
- formData?: (undefined extends Type ? Partial<{
840
- [x: string]: any;
841
- }> : Type) | undefined;
842
- invalid: boolean;
843
- status?: import('./enums').FormStatus | undefined;
844
- submit?: (() => Promise<boolean>) | undefined;
845
- validate?: ((formData?: (undefined extends Type ? Partial<{
846
- [x: string]: any;
847
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
848
- clear?: (() => void) | undefined;
849
- reset?: (() => void) | undefined;
850
- };
851
- }>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
852
- VvFormWrapper: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
853
- name: {
854
- type: StringConstructor;
855
- required: true;
856
- };
857
- tag: {
858
- type: StringConstructor;
859
- default: undefined;
860
- };
861
- }>, {
862
- errors: Readonly<import('vue').Ref<{
863
- readonly [x: string]: {
864
- readonly _errors: readonly string[];
865
- } | undefined;
866
- readonly _errors: readonly string[];
867
- } | undefined, {
868
- readonly [x: string]: {
869
- readonly _errors: readonly string[];
870
- } | undefined;
871
- readonly _errors: readonly string[];
872
- } | undefined>> | undefined;
873
- fields: import('vue').Ref<Map<string, string> & Omit<Map<string, string>, keyof Map<any, any>>, Map<string, string> | (Map<string, string> & Omit<Map<string, string>, keyof Map<any, any>>)>;
874
- fieldsErrors: import('vue').Ref<Map<string, import('zod').inferFormattedError<AnyZodObject, string>>, Map<string, import('zod').inferFormattedError<AnyZodObject, string>>>;
875
- formData: import('vue').Ref<(undefined extends Type ? Partial<{
876
- [x: string]: any;
877
- }> : Type) | undefined, (undefined extends Type ? Partial<{
878
- [x: string]: any;
879
- }> : Type) | undefined> | undefined;
880
- invalid: import('vue').ComputedRef<boolean>;
881
- clear: (() => void) | undefined;
882
- reset: (() => void) | undefined;
883
- submit: (() => Promise<boolean>) | undefined;
884
- validate: ((formData?: (undefined extends Type ? Partial<{
885
- [x: string]: any;
886
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
887
- validateWrapper: () => Promise<boolean>;
888
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid")[], "invalid" | "valid", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
889
- name: {
890
- type: StringConstructor;
891
- required: true;
892
- };
893
- tag: {
894
- type: StringConstructor;
895
- default: undefined;
896
- };
897
- }>> & Readonly<{
898
- onInvalid?: ((...args: any[]) => any) | undefined;
899
- onValid?: ((...args: any[]) => any) | undefined;
900
- }>, {
901
- tag: string;
902
- }, import('vue').SlotsType<{
903
- default: {
904
- errors?: {
905
- readonly [x: string]: {
906
- readonly _errors: readonly string[];
907
- } | undefined;
908
- readonly _errors: readonly string[];
909
- } | undefined;
910
- fieldsErrors: Map<string, import('zod').inferFormattedError<AnyZodObject, string>>;
911
- formData?: (undefined extends Type ? Partial<{
912
- [x: string]: any;
913
- }> : Type) | undefined;
914
- formErrors?: {
915
- readonly [x: string]: {
916
- readonly _errors: readonly string[];
917
- } | undefined;
918
- readonly _errors: readonly string[];
919
- } | undefined;
920
- invalid: boolean;
921
- clear?: (() => void) | undefined;
922
- reset?: (() => void) | undefined;
923
- submit?: (() => Promise<boolean>) | undefined;
924
- validate?: ((formData?: (undefined extends Type ? Partial<{
925
- [x: string]: any;
926
- }> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
927
- validateWrapper?: (() => Promise<boolean>) | undefined;
928
- };
929
- }>, {}, {}, "invalid" | "reset" | "clear" | "submit" | "errors" | "tag" | "validate" | "formData" | "fields" | "fieldsErrors" | "validateWrapper", import('vue').ComponentProvideOptions, true, {}, any>;
930
423
  };
424
+ export declare const pluginInjectionKey: InjectionKey<FormPluginOptions>;
425
+ export declare function createForm(options: FormPluginOptions): Plugin & Partial<ReturnType<typeof useForm>>;
426
+ export declare function useForm<Schema extends FormSchema, Type>(schema: Schema, options?: FormComposableOptions<Schema, Type>): ReturnType<typeof _formType<Schema, Type>>;
931
427
  export { FormFieldType } from './enums';
932
428
  export { defaultObjectBySchema } from './utils';
933
429
  type FormComponent = ReturnType<typeof defineForm>;
@@ -1153,7 +649,7 @@ export declare function formType<Schema extends FormSchema, Type>(schema: Schema
1153
649
  }, import('vue').SlotsType<{
1154
650
  [key: string]: any;
1155
651
  default: {
1156
- errors: import('zod').inferFormattedError<Schema, string>;
652
+ errors: import('vue').DeepReadonly<import('zod').inferFormattedError<Schema, string>>;
1157
653
  formData?: (undefined extends Type ? Partial<import('zod').TypeOf<Schema>> : Type) | undefined;
1158
654
  formErrors?: import('vue').DeepReadonly<import('zod').inferFormattedError<Schema, string>> | undefined;
1159
655
  invalid: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@volverjs/form-vue",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.29",
4
+ "version": "1.0.0-beta.30",
5
5
  "description": "Vue 3 Forms with @volverjs/ui-vue",
6
6
  "author": "8 Wave S.r.l.",
7
7
  "license": "MIT",
@@ -57,8 +57,8 @@
57
57
  "zod": "^3.*"
58
58
  },
59
59
  "devDependencies": {
60
- "@antfu/eslint-config": "^3.10.0",
61
- "@nabla/vite-plugin-eslint": "^2.0.4",
60
+ "@antfu/eslint-config": "^3.11.2",
61
+ "@nabla/vite-plugin-eslint": "^2.0.5",
62
62
  "@playwright/experimental-ct-vue": "1.49.0",
63
63
  "@testing-library/vue": "^8.1.0",
64
64
  "@vitejs/plugin-vue": "^5.2.1",
@@ -68,9 +68,9 @@
68
68
  "@vue/test-utils": "^2.4.6",
69
69
  "copy": "^0.3.2",
70
70
  "eslint": "^9.15.0",
71
- "happy-dom": "^15.11.6",
71
+ "happy-dom": "^15.11.7",
72
72
  "typescript": "5.4.2",
73
- "vite": "^6.0.0",
73
+ "vite": "^6.0.1",
74
74
  "vite-plugin-dts": "^4.3.0",
75
75
  "vite-plugin-externalize-deps": "^0.8.0",
76
76
  "vitest": "^2.1.6"
@@ -22,7 +22,7 @@ import {
22
22
  watch,
23
23
  useId,
24
24
  } from 'vue'
25
- import type { inferFormattedError, z } from 'zod'
25
+ import type { z } from 'zod'
26
26
  import { FormFieldType } from './enums'
27
27
  import type {
28
28
  FormFieldComponentOptions,
@@ -101,9 +101,9 @@ export function defineFormField<Schema extends FormSchema, Type>(formProvideKey:
101
101
  slots: Object as SlotsType<{
102
102
  [key: string]: any
103
103
  default: {
104
- errors: z.inferFormattedError<Schema>
104
+ errors: DeepReadonly<z.inferFormattedError<Schema>>
105
105
  formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type
106
- formErrors?: DeepReadonly<inferFormattedError<Schema, string>>
106
+ formErrors?: DeepReadonly<z.inferFormattedError<Schema, string>>
107
107
  invalid: boolean
108
108
  invalidLabel?: string[]
109
109
  modelValue: any
@@ -19,7 +19,7 @@ import {
19
19
  useId,
20
20
  watch,
21
21
  } from 'vue'
22
- import type { inferFormattedError, z } from 'zod'
22
+ import type { z } from 'zod'
23
23
  import type {
24
24
  FormSchema,
25
25
  InjectedFormData,
@@ -88,7 +88,7 @@ export function defineFormFieldsGroup<Schema extends FormSchema, Type>(formProvi
88
88
  default: {
89
89
  errors?: Record<Path<z.infer<Schema>>, z.inferFormattedError<Schema>>
90
90
  formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type
91
- formErrors?: DeepReadonly<inferFormattedError<Schema, string>>
91
+ formErrors?: DeepReadonly<z.inferFormattedError<Schema>>
92
92
  invalid: boolean
93
93
  invalids: Record<string, boolean>
94
94
  invalidLabels?: Record<string, string[]>
@@ -12,7 +12,7 @@ import {
12
12
  unref,
13
13
  } from 'vue'
14
14
  import type { FormSchema, InjectedFormData, FormTemplate, RenderFunctionOutput } from './types'
15
- import type { z, inferFormattedError } from 'zod'
15
+ import type { z } from 'zod'
16
16
  import type { FormStatus } from './enums'
17
17
 
18
18
  export function defineFormTemplate<Schema extends FormSchema, Type>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, VvFormField: Component) {
@@ -30,7 +30,7 @@ export function defineFormTemplate<Schema extends FormSchema, Type>(formProvideK
30
30
  },
31
31
  slots: Object as SlotsType<{
32
32
  default: {
33
- errors?: DeepReadonly<inferFormattedError<Schema, string>>
33
+ errors?: DeepReadonly<z.inferFormattedError<Schema>>
34
34
  formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type
35
35
  invalid: boolean
36
36
  status?: FormStatus
@@ -15,7 +15,7 @@ import {
15
15
  toRefs,
16
16
  watch,
17
17
  } from 'vue'
18
- import type { inferFormattedError, z } from 'zod'
18
+ import type { z } from 'zod'
19
19
  import type {
20
20
  FormSchema,
21
21
  InjectedFormData,
@@ -52,9 +52,9 @@ export function defineFormWrapper<Schema extends FormSchema, Type>(formProvideKe
52
52
  slots: Object as SlotsType<{
53
53
  default: {
54
54
  errors?: DeepReadonly<z.inferFormattedError<Schema>>
55
- fieldsErrors: Map<string, inferFormattedError<Schema, string>>
55
+ fieldsErrors: Map<string, z.inferFormattedError<Schema>>
56
56
  formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type
57
- formErrors?: DeepReadonly<inferFormattedError<Schema, string>>
57
+ formErrors?: DeepReadonly<z.inferFormattedError<Schema>>
58
58
  invalid: boolean
59
59
  clear?: InjectedFormData<Schema, Type>['clear']
60
60
  reset?: InjectedFormData<Schema, Type>['reset']
package/src/index.ts CHANGED
@@ -131,9 +131,9 @@ export function createForm(options: FormPluginOptions): Plugin & Partial<ReturnT
131
131
  }
132
132
 
133
133
  const formInstances: Map<string, ReturnType<typeof _formType>> = new Map()
134
- export function useForm<Schema extends FormSchema, Type>(schema: Schema, options: FormComposableOptions<Schema, Type> = {}) {
134
+ export function useForm<Schema extends FormSchema, Type>(schema: Schema, options: FormComposableOptions<Schema, Type> = {}): ReturnType <typeof _formType<Schema, Type>> {
135
135
  if (options.scope && formInstances.has(options.scope)) {
136
- return formInstances.get(options.scope) as ReturnType<typeof _formType<Schema, Type>>
136
+ return formInstances.get(options.scope)
137
137
  }
138
138
  if (!getCurrentInstance()) {
139
139
  const toReturn = _formType(schema, options)
@@ -143,11 +143,11 @@ export function useForm<Schema extends FormSchema, Type>(schema: Schema, options
143
143
  return toReturn
144
144
  }
145
145
  const toReturn = _formType(
146
- schema as AnyZodObject,
146
+ schema,
147
147
  {
148
148
  ...inject(pluginInjectionKey, {}),
149
149
  ...options,
150
- } as FormComposableOptions<AnyZodObject, Type>,
150
+ } as FormComposableOptions<Schema, Type>,
151
151
  )
152
152
  if (options.scope) {
153
153
  formInstances.set(options.scope, toReturn)