@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.
15 lines • 830 B
TypeScript
//#region src/types/common.d.ts
type TrueOrFalse = true | false;
type StringOrNumber = string | number;
type StrNumArray = StringOrNumber[];
type KeyValueOption = Record<string, any>;
type StrNumObjOption = StringOrNumber | KeyValueOption;
type StrObjOption = string | KeyValueOption;
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;
//#endregion
export { KeyValueOption, OptionPrimitive, OptionValue, StrNumArray, StrNumObjOption, StrObjOption, StringOrNumber, TrueOrFalse };