mui-extended
Version:
Extended UI Components built on Material UI
16 lines (15 loc) • 831 B
TypeScript
import { FunctionComponent, PropsWithChildren, ReactNode, RefAttributes } from "react";
export type ControlledInputAttributes = {
name: string;
value: unknown;
onChange: (name: string, value: unknown) => void;
onBlur: (name: string) => void;
};
export type FormFieldAttributes = ControlledInputAttributes & {
label?: ReactNode;
error?: boolean;
helperText?: ReactNode;
disabled?: boolean;
};
export type FormFieldProps<T extends FormFieldAttributes> = Omit<T, keyof ControlledInputAttributes> & Pick<ControlledInputAttributes, "name"> & Partial<Omit<ControlledInputAttributes, "name" | "value">> & RefAttributes<HTMLDivElement>;
export declare const withFormField: <T extends PropsWithChildren<FormFieldAttributes>>(FormFieldComponent: FunctionComponent<T>) => FunctionComponent<FormFieldProps<T>>;