UNPKG

@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.

56 lines (55 loc) 2.34 kB
import { OptionValue, StrNumObjOption } from "../../types/common.js"; import { FormHelperTextProps, FormLabelProps, SelectProps as SelectProps$1 } from "../../types/mui.js"; import { ReactNode } from "react"; import * as react_jsx_runtime0 from "react/jsx-runtime"; import { Control, FieldValues, Path, RegisterOptions } from "react-hook-form"; import { SelectChangeEvent } from "@mui/material/Select"; //#region src/mui/select/index.d.ts type SelectValue<Value, Multiple extends boolean> = Multiple extends true ? Value[] : Value; type RHFSelectProps<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>, Multiple extends boolean = false, Value = OptionValue<Option, ValueKey>> = { fieldName: Path<T>; control: Control<T>; registerOptions?: RegisterOptions<T, Path<T>>; options: Option[]; labelKey?: LabelKey; valueKey?: ValueKey; multiple?: Multiple; showDefaultOption?: boolean; defaultOptionText?: string; onValueChange?: (newValue: SelectValue<Value, Multiple>, event: SelectChangeEvent<SelectValue<Value, Multiple>>, child: ReactNode) => void; showLabelAboveFormField?: boolean; formLabelProps?: FormLabelProps; helperText?: ReactNode; errorMessage?: ReactNode; hideErrorMessage?: boolean; formHelperTextProps?: FormHelperTextProps; placeholder?: string; } & SelectProps$1; declare const RHFSelect: <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>, Multiple extends boolean = false>({ fieldName, control, registerOptions, options, labelKey, valueKey, multiple, showDefaultOption, defaultOptionText, onValueChange, disabled: muiDisabled, label, showLabelAboveFormField, formLabelProps, required, helperText, errorMessage, hideErrorMessage, formHelperTextProps, onBlur, autoComplete, renderValue, placeholder, ...otherSelectProps }: RHFSelectProps<T, Option, LabelKey, ValueKey, Multiple>) => react_jsx_runtime0.JSX.Element; //#endregion export { RHFSelectProps, RHFSelect as default };