UNPKG

@nish1896/rhf-mui-components

Version:

A suite of 25+ production-ready react-hook-form components built with material-ui. Fully typed, tree-shakable, and optimized for enterprise-grade forms.

18 lines 1.08 kB
//#region src/common/types/components.d.ts type OptionPrimitive = string | number; /** * Generic type representing the possible value types for options * used in form components like select, radio group, checkbox group, etc. */ type OptionValue<Option, ValueKey extends string | undefined> = Option extends OptionPrimitive ? Option : ValueKey extends keyof Option ? Option[ValueKey] extends OptionPrimitive ? Option[ValueKey] : never : never; /** * RHF field value for Autocomplete components mirrors * MUI `AutocompleteValue<string, Multiple, DisableClearable, false>` for primitives. * Tuple checks avoid distributive `boolean` breaking the conditional. */ type AutocompleteNewValue<Multiple extends boolean, DisableClearable extends boolean> = [Multiple] extends [true] ? [DisableClearable] extends [true] ? string[] : string[] | null : [DisableClearable] extends [true] ? string : string | null; type CustomOnChangeProps<T, V> = T & { rhfOnChange: (value: V) => void; }; //#endregion export { AutocompleteNewValue, CustomOnChangeProps, OptionPrimitive, OptionValue };