@volverjs/form-vue 1.0.0-beta.2 → 1.0.0-beta.20

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.
@@ -0,0 +1,99 @@
1
+ import { Component, InjectionKey, PropType, SlotsType } from 'vue';
2
+ import { z } from 'zod';
3
+ import { FormComponentOptions, FormSchema, FormTemplate, InjectedFormData } from './types';
4
+ import { FormStatus } from './enums';
5
+ export declare function defineForm<Schema extends FormSchema>(schema: Schema, provideKey: InjectionKey<InjectedFormData<Schema>>, options?: FormComponentOptions<Schema>, VvFormTemplate?: Component): {
6
+ clear: () => void;
7
+ errors: import('vue').Ref<z.inferFormattedError<Schema, string> | undefined, z.inferFormattedError<Schema, string> | undefined>;
8
+ formData: import('vue').Ref<Partial<z.TypeOf<Schema> | undefined>, Partial<z.TypeOf<Schema> | undefined>>;
9
+ ignoreUpdates: import('@vueuse/shared').IgnoredUpdater;
10
+ invalid: import('vue').ComputedRef<boolean>;
11
+ readonly: import('vue').Ref<boolean, boolean>;
12
+ reset: () => void;
13
+ status: import('vue').Ref<FormStatus | undefined, FormStatus | undefined>;
14
+ stopUpdatesWatch: import('vue').WatchStopHandle;
15
+ submit: () => Promise<boolean>;
16
+ validate: (value?: Partial<z.TypeOf<Schema> | undefined>, fields?: Set<string>) => Promise<boolean>;
17
+ VvForm: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
18
+ continuousValidation: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
22
+ modelValue: {
23
+ type: ObjectConstructor;
24
+ default: () => {};
25
+ };
26
+ readonly: {
27
+ type: BooleanConstructor;
28
+ default: boolean;
29
+ };
30
+ tag: {
31
+ type: StringConstructor;
32
+ default: string;
33
+ };
34
+ template: {
35
+ type: PropType<FormTemplate<Schema>>;
36
+ default: undefined;
37
+ };
38
+ }>, {
39
+ clear: () => void;
40
+ errors: Readonly<import('vue').Ref<import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
41
+ formData: import('vue').Ref<Partial<z.TypeOf<Schema> | undefined>, Partial<z.TypeOf<Schema> | undefined>>;
42
+ ignoreUpdates: import('@vueuse/shared').IgnoredUpdater;
43
+ invalid: import('vue').ComputedRef<boolean>;
44
+ isReadonly: import('vue').Ref<boolean, boolean>;
45
+ reset: () => void;
46
+ status: Readonly<import('vue').Ref<FormStatus | undefined, FormStatus | undefined>>;
47
+ stopUpdatesWatch: import('vue').WatchStopHandle;
48
+ submit: () => Promise<boolean>;
49
+ validate: (value?: Partial<z.TypeOf<Schema> | undefined>, fields?: Set<string>) => Promise<boolean>;
50
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "reset" | "update:modelValue" | "submit" | "update:readonly")[], "invalid" | "valid" | "reset" | "update:modelValue" | "submit" | "update:readonly", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
51
+ continuousValidation: {
52
+ type: BooleanConstructor;
53
+ default: boolean;
54
+ };
55
+ modelValue: {
56
+ type: ObjectConstructor;
57
+ default: () => {};
58
+ };
59
+ readonly: {
60
+ type: BooleanConstructor;
61
+ default: boolean;
62
+ };
63
+ tag: {
64
+ type: StringConstructor;
65
+ default: string;
66
+ };
67
+ template: {
68
+ type: PropType<FormTemplate<Schema>>;
69
+ default: undefined;
70
+ };
71
+ }>> & Readonly<{
72
+ onInvalid?: ((...args: any[]) => any) | undefined;
73
+ onValid?: ((...args: any[]) => any) | undefined;
74
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
75
+ onReset?: ((...args: any[]) => any) | undefined;
76
+ onSubmit?: ((...args: any[]) => any) | undefined;
77
+ "onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
78
+ }>, {
79
+ readonly: boolean;
80
+ template: FormTemplate<Schema>;
81
+ modelValue: Record<string, any>;
82
+ tag: string;
83
+ continuousValidation: boolean;
84
+ }, SlotsType<{
85
+ default: {
86
+ errors: Readonly<import('vue').Ref<import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
87
+ formData: import('vue').Ref<Partial<z.TypeOf<Schema> | undefined>, Partial<z.TypeOf<Schema> | undefined>>;
88
+ ignoreUpdates: import('@vueuse/shared').IgnoredUpdater;
89
+ invalid: import('vue').ComputedRef<boolean>;
90
+ readonly: import('vue').Ref<boolean, boolean>;
91
+ status: Readonly<import('vue').Ref<FormStatus | undefined, FormStatus | undefined>>;
92
+ stopUpdatesWatch: import('vue').WatchStopHandle;
93
+ submit: () => Promise<boolean>;
94
+ validate: (value?: Partial<z.TypeOf<Schema> | undefined>, fields?: Set<string>) => Promise<boolean>;
95
+ clear: () => void;
96
+ reset: () => void;
97
+ };
98
+ }>, {}, {}, "invalid" | "valid" | "reset" | "status" | "clear" | "errors" | "submit" | "validate" | "readonly" | "template" | "tag", import('vue').ComponentProvideOptions, true, {}, any>;
99
+ };
@@ -0,0 +1,130 @@
1
+ import { Component, ConcreteComponent, DeepReadonly, InjectionKey, PropType, Ref, SlotsType } from 'vue';
2
+ import { inferFormattedError, TypeOf, z } from 'zod';
3
+ import { FormFieldType } from './enums';
4
+ import { FormFieldComponentOptions, FormSchema, InjectedFormData, InjectedFormFieldData, InjectedFormWrapperData, Path } from './types';
5
+ export declare function defineFormField<Schema extends FormSchema>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>, formFieldInjectionKey: InjectionKey<InjectedFormFieldData<Schema>>, options?: FormFieldComponentOptions): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
+ type: {
7
+ type: PropType<`${FormFieldType}`>;
8
+ validator: (value: FormFieldType) => boolean;
9
+ default: FormFieldType;
10
+ };
11
+ is: {
12
+ type: PropType<Component | string>;
13
+ default: undefined;
14
+ };
15
+ name: {
16
+ type: PropType<Path<z.infer<Schema>>>;
17
+ required: true;
18
+ };
19
+ props: {
20
+ type: PropType<Partial<z.infer<Schema> | undefined | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined)>>;
21
+ default: () => {};
22
+ };
23
+ showValid: {
24
+ type: BooleanConstructor;
25
+ default: boolean;
26
+ };
27
+ defaultValue: {
28
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
29
+ default: undefined;
30
+ };
31
+ lazyLoad: {
32
+ type: BooleanConstructor;
33
+ default: boolean;
34
+ };
35
+ readonly: {
36
+ type: BooleanConstructor;
37
+ default: undefined;
38
+ };
39
+ }>, {
40
+ component: import('vue').ComputedRef<{
41
+ new (...args: any[]): any;
42
+ __isFragment?: never;
43
+ __isTeleport?: never;
44
+ __isSuspense?: never;
45
+ } | ConcreteComponent>;
46
+ hasProps: import('vue').ComputedRef<{
47
+ name: {} | ([{
48
+ type: PropType<Path<z.infer<Schema>>>;
49
+ required: true;
50
+ }] extends [import('vue').Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? import('@vue/shared').IfAny<V, V, D> : V : V : {
51
+ type: PropType<Path<z.infer<Schema>>>;
52
+ required: true;
53
+ });
54
+ invalid: boolean;
55
+ valid: boolean | undefined;
56
+ type: FormFieldType | undefined;
57
+ invalidLabel: any;
58
+ modelValue: any;
59
+ readonly: boolean;
60
+ 'onUpdate:modelValue': (value: unknown) => void;
61
+ }>;
62
+ invalid: import('vue').ComputedRef<boolean>;
63
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "update:formData" | "update:modelValue")[], "invalid" | "valid" | "update:formData" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
64
+ type: {
65
+ type: PropType<`${FormFieldType}`>;
66
+ validator: (value: FormFieldType) => boolean;
67
+ default: FormFieldType;
68
+ };
69
+ is: {
70
+ type: PropType<Component | string>;
71
+ default: undefined;
72
+ };
73
+ name: {
74
+ type: PropType<Path<z.infer<Schema>>>;
75
+ required: true;
76
+ };
77
+ props: {
78
+ type: PropType<Partial<z.infer<Schema> | undefined | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined)>>;
79
+ default: () => {};
80
+ };
81
+ showValid: {
82
+ type: BooleanConstructor;
83
+ default: boolean;
84
+ };
85
+ defaultValue: {
86
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
87
+ default: undefined;
88
+ };
89
+ lazyLoad: {
90
+ type: BooleanConstructor;
91
+ default: boolean;
92
+ };
93
+ readonly: {
94
+ type: BooleanConstructor;
95
+ default: undefined;
96
+ };
97
+ }>> & Readonly<{
98
+ onInvalid?: ((...args: any[]) => any) | undefined;
99
+ onValid?: ((...args: any[]) => any) | undefined;
100
+ "onUpdate:formData"?: ((...args: any[]) => any) | undefined;
101
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
102
+ }>, {
103
+ type: "number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom";
104
+ props: [{
105
+ type: PropType<Partial<z.infer<Schema> | undefined | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined)>>;
106
+ default: () => {};
107
+ }] extends [import('vue').Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? import('@vue/shared').IfAny<V, V, D> : V : V : {
108
+ type: PropType<Partial<z.infer<Schema> | undefined | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined)>>;
109
+ default: () => {};
110
+ };
111
+ is: string | Component;
112
+ showValid: boolean;
113
+ defaultValue: string | number | boolean | unknown[] | Record<string, any>;
114
+ lazyLoad: boolean;
115
+ readonly: boolean;
116
+ }, SlotsType<{
117
+ [key: string]: any;
118
+ default: {
119
+ errors: z.inferFormattedError<Schema>;
120
+ formData?: Partial<TypeOf<Schema>>;
121
+ formErrors?: DeepReadonly<inferFormattedError<Schema, string>>;
122
+ invalid: boolean;
123
+ invalidLabel: string;
124
+ modelValue: unknown;
125
+ onUpdate: (value: unknown) => void;
126
+ readonly: boolean;
127
+ submit?: InjectedFormData<Schema>["submit"];
128
+ validate?: InjectedFormData<Schema>["validate"];
129
+ };
130
+ }>, {}, {}, "invalid" | "type" | "component" | "errors" | "hasProps" | "invalidLabel" | "is", import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,40 @@
1
+ import { Component, DeepReadonly, InjectionKey, PropType, SlotsType, VNode } from 'vue';
2
+ import { FormSchema, InjectedFormData, FormTemplate } from './types';
3
+ import { inferFormattedError, TypeOf } from 'zod';
4
+ import { FormStatus } from './enums';
5
+ export declare function defineFormTemplate<Schema extends FormSchema>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, VvFormField: Component): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
+ schema: {
7
+ type: PropType<FormTemplate<Schema>>;
8
+ required: true;
9
+ };
10
+ scope: {
11
+ type: PropType<Record<string, unknown>>;
12
+ default: () => {};
13
+ };
14
+ }>, (() => (VNode<import('vue').RendererNode, import('vue').RendererElement, {
15
+ [key: string]: any;
16
+ }> | VNode<import('vue').RendererNode, import('vue').RendererElement, {
17
+ [key: string]: any;
18
+ }>[] | undefined)[]) | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
19
+ schema: {
20
+ type: PropType<FormTemplate<Schema>>;
21
+ required: true;
22
+ };
23
+ scope: {
24
+ type: PropType<Record<string, unknown>>;
25
+ default: () => {};
26
+ };
27
+ }>> & Readonly<{}>, {
28
+ scope: Record<string, unknown>;
29
+ }, SlotsType<{
30
+ default: {
31
+ errors?: DeepReadonly<inferFormattedError<Schema, string>>;
32
+ formData?: Partial<TypeOf<Schema>>;
33
+ invalid: boolean;
34
+ status?: FormStatus;
35
+ submit?: InjectedFormData<Schema>["submit"];
36
+ validate?: InjectedFormData<Schema>["validate"];
37
+ clear?: InjectedFormData<Schema>["clear"];
38
+ reset?: InjectedFormData<Schema>["reset"];
39
+ };
40
+ }>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,51 @@
1
+ import { DeepReadonly, InjectionKey, Ref, SlotsType } from 'vue';
2
+ import { inferFormattedError, TypeOf, z } from 'zod';
3
+ import { FormSchema, InjectedFormData, InjectedFormWrapperData } from './types';
4
+ export declare function defineFormWrapper<Schema extends FormSchema>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
+ name: {
6
+ type: StringConstructor;
7
+ required: true;
8
+ };
9
+ tag: {
10
+ type: StringConstructor;
11
+ default: undefined;
12
+ };
13
+ }>, {
14
+ clear: (() => void) | undefined;
15
+ errors: Readonly<Ref<DeepReadonly<inferFormattedError<Schema, string>> | undefined, DeepReadonly<inferFormattedError<Schema, string>> | undefined>> | undefined;
16
+ fields: Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
17
+ fieldsErrors: Ref<Map<string, inferFormattedError<Schema, string>>, Map<string, inferFormattedError<Schema, string>>>;
18
+ formData: Ref<Partial<TypeOf<Schema>> | undefined, Partial<TypeOf<Schema>> | undefined> | undefined;
19
+ invalid: import('vue').ComputedRef<boolean>;
20
+ reset: (() => void) | undefined;
21
+ submit: (() => Promise<boolean>) | undefined;
22
+ validate: ((formData?: Partial<TypeOf<Schema>> | undefined, fields?: Set<string>) => Promise<boolean>) | undefined;
23
+ validateWrapper: () => Promise<boolean>;
24
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid")[], "invalid" | "valid", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
25
+ name: {
26
+ type: StringConstructor;
27
+ required: true;
28
+ };
29
+ tag: {
30
+ type: StringConstructor;
31
+ default: undefined;
32
+ };
33
+ }>> & Readonly<{
34
+ onInvalid?: ((...args: any[]) => any) | undefined;
35
+ onValid?: ((...args: any[]) => any) | undefined;
36
+ }>, {
37
+ tag: string;
38
+ }, SlotsType<{
39
+ default: {
40
+ errors?: DeepReadonly<z.inferFormattedError<Schema>>;
41
+ formData?: Partial<TypeOf<Schema>>;
42
+ formErrors?: DeepReadonly<inferFormattedError<Schema, string>>;
43
+ invalid: boolean;
44
+ submit?: InjectedFormData<Schema>["submit"];
45
+ validate?: InjectedFormData<Schema>["validate"];
46
+ validateWrapper?: () => Promise<boolean>;
47
+ fieldsErrors: Map<string, inferFormattedError<Schema, string>>;
48
+ clear?: InjectedFormData<Schema>["clear"];
49
+ reset?: InjectedFormData<Schema>["reset"];
50
+ };
51
+ }>, {}, {}, "invalid" | "reset" | "clear" | "errors" | "submit" | "validate" | "formData" | "tag" | "fields" | "fieldsErrors" | "validateWrapper", import('vue').ComponentProvideOptions, true, {}, any>;
@@ -25,6 +25,7 @@ export declare enum FormStatus {
25
25
  invalid = "invalid",
26
26
  valid = "valid",
27
27
  submitting = "submitting",
28
+ reset = "reset",
28
29
  updated = "updated",
29
30
  unknown = "unknown"
30
31
  }