Skip to content

Commit 4e68a6b

Browse files
committed
feat(inputs): enhance the text field props of mui components
1 parent 1ff2087 commit 4e68a6b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/TextField.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,32 @@ import { type Control, Controller, type FieldPath, type FieldValues } from 'reac
22
import { TextField as MuiTextField } from '@mui/material';
33
import type { TextFieldProps as MuiTextFieldProps } from '@mui/material';
44

5-
export interface TextFieldProps<T extends FieldValues> {
5+
// TODO: Make this interface a generic one
6+
interface MuiProps {
67
muiTextFieldProps?: MuiTextFieldProps;
8+
}
9+
10+
export interface TextFieldProps<T extends FieldValues> {
711
control: Control<T>;
812
name: FieldPath<T>;
913
label: string;
1014
isOptional?: boolean;
15+
muiProps?: MuiProps;
1116
}
1217

1318
export const TextField = <T extends FieldValues>({
1419
control,
1520
label,
1621
name,
1722
isOptional = false,
18-
muiTextFieldProps,
23+
muiProps,
1924
}: TextFieldProps<T>) => (
2025
<Controller
2126
control={control}
2227
name={name}
2328
render={({ field, fieldState: { invalid, error } }) => (
2429
<MuiTextField
25-
{...muiTextFieldProps}
30+
{...muiProps?.muiTextFieldProps}
2631
{...field}
2732
// TODO: Add all aria labels needed (could be a custom hook/function)
2833
aria-required={isOptional ? 'false' : 'true'}

0 commit comments

Comments
 (0)