Skip to content

Commit 8e6767a

Browse files
Fix: form callback types (#202)
Co-authored-by: Sergey Garin <sergey.garin@cube.dev>
1 parent 107aed1 commit 8e6767a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/late-melons-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Improve typings of `onSubmit` and `onValuesChange` callbacks in `<Form />` component. Now they properly match with `FormInstance` and `useForm`.

src/components/forms/Form/Form.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ export interface CubeFormProps<T extends FieldTypes = FieldTypes>
6464
/** Form name */
6565
name?: string;
6666
/** Default field values */
67-
defaultValues?: { [K in keyof T]?: T[K] };
67+
defaultValues?: Partial<T>;
6868
/** Trigger when any value of Field changed */
69-
onValuesChange?: (data: CubeFormData<T>) => void | Promise<void>;
69+
onValuesChange?: CubeFormInstance<T>['onValuesChange'];
7070
/** Trigger when form submit and success */
71-
onSubmit?: (data: CubeFormData<T>) => void | Promise<void>;
71+
onSubmit?: CubeFormInstance<T>['onSubmit'];
7272
/** Trigger when form submit and failed */
7373
onSubmitFailed?: (any?) => void | Promise<any>;
7474
/** Set form instance created by useForm */

0 commit comments

Comments
 (0)