@nish1896/rhf-mui-components
Version:
A suite of 20+ production-ready react-hook-form components built with material-ui. Fully typed, tree-shakable, and optimized for enterprise-grade forms.
52 lines (51 loc) • 2.15 kB
TypeScript
import { StrNumObjOption, StringOrNumber } from "../../types/common.js";
import { FormHelperTextProps, FormLabelProps } from "../../types/mui.js";
import { ChangeEvent, ReactNode } from "react";
import * as react_jsx_runtime0 from "react/jsx-runtime";
import { Control, FieldValues, Path, RegisterOptions } from "react-hook-form";
import { NativeSelectProps } from "@mui/material/NativeSelect";
//#region src/mui/native-select/index.d.ts
type InputNativeSelectProps = Omit<NativeSelectProps, 'name' | 'id' | 'labelId' | 'error' | 'onChange' | 'value'>;
type RHFNativeSelectProps<T extends FieldValues, Option extends StrNumObjOption = StrNumObjOption, LabelKey extends Extract<keyof Option, string> = Extract<keyof Option, string>, ValueKey extends Extract<keyof Option, string> = Extract<keyof Option, string>> = {
fieldName: Path<T>;
control: Control<T>;
registerOptions?: RegisterOptions<T, Path<T>>;
options: Option[];
labelKey?: LabelKey;
valueKey?: ValueKey;
onValueChange?: (value: StringOrNumber | StringOrNumber[], 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, Option extends StrNumObjOption = StrNumObjOption, LabelKey extends Extract<keyof Option, string> = Extract<keyof Option, string>, ValueKey extends Extract<keyof Option, string> = Extract<keyof Option, string>>({
fieldName,
control,
registerOptions,
options,
labelKey,
valueKey,
onValueChange,
disabled: muiDisabled,
defaultOptionText,
showLabelAboveFormField,
formLabelProps,
label,
required,
helperText,
errorMessage,
hideErrorMessage,
formHelperTextProps,
sx,
onBlur,
autoComplete,
placeholder,
...otherNativeSelectProps
}: RHFNativeSelectProps<T, Option, LabelKey, ValueKey>) => react_jsx_runtime0.JSX.Element;
//#endregion
export { RHFNativeSelectProps, RHFNativeSelect as default };