@teamnovu/kit-vue-forms 0.1.20 → 0.1.22
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/useFieldArray.d.ts +13 -0
- package/dist/composables/useFieldRegistry.d.ts +1 -1
- package/dist/composables/useSubform.d.ts +1 -1
- package/dist/index.js +406 -346
- package/dist/types/form.d.ts +16 -0
- package/dist/{composables/useSubmitHandler.d.ts → utils/submitHandler.d.ts} +1 -1
- package/package.json +1 -1
- package/src/composables/useField.ts +3 -1
- package/src/composables/useFieldArray.ts +144 -0
- package/src/composables/useFieldRegistry.ts +60 -60
- package/src/composables/useForm.ts +41 -47
- package/src/composables/useSubform.ts +66 -70
- package/src/types/form.ts +26 -0
- package/src/{composables/useSubmitHandler.ts → utils/submitHandler.ts} +2 -2
- package/tests/useFieldArray.test.ts +381 -0
- package/tests/useForm.test.ts +286 -257
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FieldArray, FieldArrayOptions, Form, FormDataDefault, HashFn } from '../types/form';
|
|
2
|
+
import { Paths, PickProps } from '../types/util';
|
|
3
|
+
export declare class HashStore<T, Item = unknown> {
|
|
4
|
+
private weakMap;
|
|
5
|
+
private map;
|
|
6
|
+
private hashFn;
|
|
7
|
+
constructor(hashFn?: HashFn<unknown, Item>);
|
|
8
|
+
private isReferenceType;
|
|
9
|
+
has(item: Item): boolean;
|
|
10
|
+
get(item: Item): T | undefined;
|
|
11
|
+
set(item: Item, value: T): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useFieldArray<T extends FormDataDefault, K extends Paths<T>>(form: Form<T>, path: PickProps<T, K> extends unknown[] ? K : never, options?: FieldArrayOptions<PickProps<T, K> extends (infer U)[] ? U : never>): FieldArray<PickProps<T, K> extends (infer U)[] ? U : never>;
|
|
@@ -5,7 +5,7 @@ import { Paths, PickProps } from '../types/util';
|
|
|
5
5
|
import { UseFieldOptions } from './useField';
|
|
6
6
|
import { ValidationState } from './useValidation';
|
|
7
7
|
export type ResolvedFormField<T, K extends Paths<T>> = FormField<PickProps<T, K>, K>;
|
|
8
|
-
export type DefineFieldOptions<F, K extends string> = Pick<UseFieldOptions<F, K>,
|
|
8
|
+
export type DefineFieldOptions<F, K extends string> = Pick<UseFieldOptions<F, K>, 'path'> & {
|
|
9
9
|
onBlur?: () => void;
|
|
10
10
|
onFocus?: () => void;
|
|
11
11
|
};
|
|
@@ -3,4 +3,4 @@ import { EntityPaths, PickEntity } from '../types/util';
|
|
|
3
3
|
import { UseFormOptions } from './useForm';
|
|
4
4
|
export interface SubformOptions<_T extends FormDataDefault> {
|
|
5
5
|
}
|
|
6
|
-
export declare function createSubformInterface<T extends FormDataDefault, K extends EntityPaths<T>>(mainForm:
|
|
6
|
+
export declare function createSubformInterface<T extends FormDataDefault, K extends EntityPaths<T>>(mainForm: Form<T>, path: K, formOptions?: UseFormOptions<T>, _options?: SubformOptions<PickEntity<T, K>>): Form<PickEntity<T, K>>;
|