@teamnovu/kit-vue-forms 0.2.2 → 0.2.3
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.
|
@@ -3,16 +3,14 @@ import { z } from 'zod';
|
|
|
3
3
|
import { Form, FormDataDefault } from '../types/form';
|
|
4
4
|
import { ValidationStrategy } from '../types/validation';
|
|
5
5
|
import { ValidationOptions } from './useValidation';
|
|
6
|
-
import { DeepPartial } from '../utils/type-helpers';
|
|
7
6
|
export interface UseFormOptions<T extends FormDataDefault, TOut = T> extends ValidationOptions<T, TOut> {
|
|
8
7
|
initialData: MaybeRefOrGetter<T>;
|
|
9
8
|
validationStrategy?: MaybeRef<ValidationStrategy>;
|
|
10
9
|
keepValuesOnUnmount?: MaybeRef<boolean>;
|
|
11
10
|
}
|
|
12
|
-
export declare function useForm<
|
|
13
|
-
schema:
|
|
14
|
-
|
|
15
|
-
}): Form<z.input<TSchema> & InitialData, z.output<TSchema> & InitialData>;
|
|
11
|
+
export declare function useForm<T extends FormDataDefault, TOut = T>(options: UseFormOptions<T, TOut> & {
|
|
12
|
+
schema: z.ZodType<TOut, T>;
|
|
13
|
+
}): Form<T, TOut>;
|
|
16
14
|
export declare function useForm<T extends FormDataDefault>(options: Omit<UseFormOptions<T, T>, 'schema'> & {
|
|
17
15
|
schema?: undefined;
|
|
18
16
|
}): Form<T, T>;
|
package/package.json
CHANGED
|
@@ -19,7 +19,6 @@ import { useFieldRegistry } from './useFieldRegistry'
|
|
|
19
19
|
import { useFormState } from './useFormState'
|
|
20
20
|
import { createSubformInterface } from './useSubform'
|
|
21
21
|
import { useValidation, type ValidationOptions } from './useValidation'
|
|
22
|
-
import type { DeepPartial } from '../utils/type-helpers'
|
|
23
22
|
|
|
24
23
|
export interface UseFormOptions<T extends FormDataDefault, TOut = T>
|
|
25
24
|
extends ValidationOptions<T, TOut> {
|
|
@@ -32,14 +31,9 @@ export interface UseFormOptions<T extends FormDataDefault, TOut = T>
|
|
|
32
31
|
// Overload: with schema - infer types from schema
|
|
33
32
|
// initialData can be partial, but provided fields must match schema types
|
|
34
33
|
export function useForm<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
>(
|
|
38
|
-
options: Omit<UseFormOptions<z.input<TSchema>, z.output<TSchema>>, 'initialData'> & {
|
|
39
|
-
schema: MaybeRef<TSchema>
|
|
40
|
-
initialData: MaybeRef<InitialData>
|
|
41
|
-
},
|
|
42
|
-
): Form<z.input<TSchema> & InitialData, z.output<TSchema> & InitialData>
|
|
34
|
+
T extends FormDataDefault,
|
|
35
|
+
TOut = T,
|
|
36
|
+
>(options: UseFormOptions<T, TOut> & { schema: z.ZodType<TOut, T> }): Form<T, TOut>
|
|
43
37
|
|
|
44
38
|
// Overload: without schema - infer types from initialData
|
|
45
39
|
export function useForm<T extends FormDataDefault>(
|