@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.
53 lines (52 loc) • 2.15 kB
TypeScript
import { StrNumObjOption } from "../../types/common.js";
import { FormControlLabelProps, FormHelperTextProps, FormLabelProps, RadioProps } 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 { RadioGroupProps } from "@mui/material/RadioGroup";
//#region src/mui/radio-group/index.d.ts
type RadioGroupInputProps = Omit<RadioGroupProps, 'name' | 'value' | 'onChange'>;
type RHFRadioGroupProps<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?: (selectedValue: string, event: ChangeEvent<HTMLInputElement>) => void;
disabled?: boolean;
label?: ReactNode;
showLabelAboveFormField?: boolean;
formLabelProps?: FormLabelProps;
radioProps?: RadioProps;
formControlLabelProps?: FormControlLabelProps;
helperText?: ReactNode;
required?: boolean;
errorMessage?: ReactNode;
hideErrorMessage?: boolean;
formHelperTextProps?: FormHelperTextProps;
} & RadioGroupInputProps;
declare const RHFRadioGroup: <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,
label,
showLabelAboveFormField,
formLabelProps,
radioProps,
formControlLabelProps,
required,
helperText,
errorMessage,
hideErrorMessage,
formHelperTextProps,
onBlur,
...rest
}: RHFRadioGroupProps<T, Option, LabelKey, ValueKey>) => react_jsx_runtime0.JSX.Element;
//#endregion
export { RHFRadioGroupProps, RHFRadioGroup as default };