@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.47 kB
TypeScript
import type { ReactNode, ChangeEvent } from 'react';
import { type FieldValues, type Path, type Control, type RegisterOptions } from 'react-hook-form';
import { type NativeSelectProps } from '@mui/material/NativeSelect';
import type { FormHelperTextProps, FormLabelProps, StrNumObjOption } from '../../types';
type InputNativeSelectProps = Omit<NativeSelectProps, 'name' | 'id' | 'labelId' | 'error' | 'onChange' | 'value'>;
export type RHFNativeSelectProps<T extends FieldValues> = {
fieldName: Path<T>;
control: Control<T>;
registerOptions?: RegisterOptions<T, Path<T>>;
options: StrNumObjOption[];
labelKey?: string;
valueKey?: string;
onValueChange?: (value: StrNumObjOption, event: ChangeEvent<HTMLSelectElement>) => void;
defaultOptionText?: string;
showLabelAboveFormField?: boolean;
formLabelProps?: FormLabelProps;
label?: ReactNode;
helperText?: ReactNode;
errorMessage?: ReactNode;
hideErrorMessage?: boolean;
formHelperTextProps?: FormHelperTextProps;
} & InputNativeSelectProps;
declare const RHFNativeSelect: <T extends FieldValues>({ fieldName, control, registerOptions, options, labelKey, valueKey, onValueChange, defaultOptionText, showLabelAboveFormField, formLabelProps, label, required, helperText, errorMessage, hideErrorMessage, formHelperTextProps, sx, ...otherNativeSelectProps }: RHFNativeSelectProps<T>) => import("react/jsx-runtime").JSX.Element;
export default RHFNativeSelect;