@nish1896/rhf-mui-components
Version:
A suite of 20+ reusable Material UI components for React Hook Form to minimize your time and effort in creating and styling forms
25 lines (24 loc) • 1.42 kB
TypeScript
import { type ReactNode } from 'react';
import { type FieldValues, type Path, type Control, type RegisterOptions } from 'react-hook-form';
import { type SelectChangeEvent } from '@mui/material/Select';
import type { FormLabelProps, FormHelperTextProps, StrNumObjOption, SelectProps } from '../../types';
type SelectValueType = StrNumObjOption | StrNumObjOption[];
export type RHFSelectProps<T extends FieldValues> = {
fieldName: Path<T>;
control: Control<T>;
registerOptions?: RegisterOptions<T, Path<T>>;
options: StrNumObjOption[];
labelKey?: string;
valueKey?: string;
showDefaultOption?: boolean;
defaultOptionText?: string;
onValueChange?: (newValue: SelectValueType, event: SelectChangeEvent<SelectValueType>, child: ReactNode) => void;
showLabelAboveFormField?: boolean;
formLabelProps?: FormLabelProps;
helperText?: ReactNode;
errorMessage?: ReactNode;
hideErrorMessage?: boolean;
formHelperTextProps?: FormHelperTextProps;
} & SelectProps;
declare const RHFSelect: <T extends FieldValues>({ fieldName, control, registerOptions, options, labelKey, valueKey, showDefaultOption, defaultOptionText, onValueChange, label, showLabelAboveFormField, formLabelProps, multiple, required, helperText, errorMessage, hideErrorMessage, formHelperTextProps, ...otherSelectProps }: RHFSelectProps<T>) => import("react/jsx-runtime").JSX.Element;
export default RHFSelect;