@teamnovu/kit-vue-forms 0.1.15 → 0.1.16
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/dist/composables/useField.d.ts +3 -2
- package/dist/composables/useValidation.d.ts +1 -0
- package/dist/index.js +344 -315
- package/dist/utils/path.d.ts +4 -1
- package/package.json +1 -1
- package/src/composables/useField.ts +16 -4
- package/src/composables/useFieldRegistry.ts +2 -1
- package/src/composables/useForm.ts +47 -43
- package/src/composables/useValidation.ts +17 -0
- package/src/utils/path.ts +81 -52
- package/tests/useForm.test.ts +40 -0
- package/tests/useValidation.test.ts +26 -2
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { Awaitable } from '@vueuse/core';
|
|
1
2
|
import { MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
3
|
import { FormField } from '../types/form';
|
|
3
4
|
import { ValidationErrors } from '../types/validation';
|
|
4
|
-
import { Awaitable } from '@vueuse/core';
|
|
5
5
|
export interface UseFieldOptions<T, K extends string> {
|
|
6
6
|
value?: MaybeRef<T>;
|
|
7
7
|
initialValue?: MaybeRefOrGetter<Readonly<T>>;
|
|
8
8
|
path: K;
|
|
9
9
|
errors?: Ref<ValidationErrors>;
|
|
10
|
+
existsInForm?: MaybeRef<boolean>;
|
|
10
11
|
onBlur?: () => Awaitable<void>;
|
|
11
12
|
onFocus?: () => Awaitable<void>;
|
|
12
13
|
}
|
|
13
|
-
export declare function useField<T, K extends string>(
|
|
14
|
+
export declare function useField<T, K extends string>(fieldOptions: UseFieldOptions<T, K>): FormField<T, K>;
|
|
@@ -16,6 +16,7 @@ export declare function useValidation<T extends FormDataDefault>(formState: {
|
|
|
16
16
|
data: T;
|
|
17
17
|
}, options: ValidationOptions<T>): {
|
|
18
18
|
validateForm: () => Promise<ValidationResult>;
|
|
19
|
+
validateField: (path: string) => Promise<ValidationResult>;
|
|
19
20
|
defineValidator: <TData extends T>(options: ValidatorOptions<TData> | Ref<Validator<TData>>) => Ref<Validator<TData> | undefined, Validator<TData> | undefined>;
|
|
20
21
|
isValid: ComputedRef<boolean>;
|
|
21
22
|
reset: () => void;
|