Skip to content

Commit eb843c0

Browse files
committed
correct types for controlled radio/checkboxes
1 parent bfb64e5 commit eb843c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/forms/controlled/inputTypes.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ type MakeControlled<T extends React.ComponentType<any>> =
77
name: string;
88
emptyDisabledValue?: boolean;
99
};
10+
type MakeControlledCheckbox<T extends React.ComponentType<any>> =
11+
Omit<React.ComponentPropsWithoutRef<T>, 'checked'> & {
12+
name: string;
13+
emptyDisabledValue?: boolean;
14+
};
1015

1116
const useEmptyDisabledValue = (
1217
props: {disabled?: boolean; emptyDisabledValue?: boolean},
@@ -67,7 +72,7 @@ export const TextArea = (props: MakeControlled<typeof Uncontrolled.TextArea>) =>
6772
/>;
6873
};
6974

70-
export const Radio = (props: MakeControlled<typeof Uncontrolled.Radio>) => {
75+
export const Radio = (props: MakeControlledCheckbox<typeof Uncontrolled.Radio>) => {
7176
const {data, namespace, setInput} = useFormHelpers();
7277

7378
const onChangeValue = (value: string) => {
@@ -85,7 +90,7 @@ export const Radio = (props: MakeControlled<typeof Uncontrolled.Radio>) => {
8590
/>;
8691
};
8792

88-
export const Checkbox = (props: MakeControlled<typeof Uncontrolled.Checkbox>) => {
93+
export const Checkbox = (props: MakeControlledCheckbox<typeof Uncontrolled.Checkbox>) => {
8994
const {data, namespace, setInput} = useFormHelpers();
9095

9196
const onChangeValue = (value: boolean | undefined) => {

0 commit comments

Comments
 (0)