import { JSXElementConstructor } from 'react'; import { GridSize, GridProps } from '@material-ui/core/Grid'; import { OutlinedInputProps } from '@material-ui/core/OutlinedInput'; import { StepperProps } from '@material-ui/core/Stepper'; import { Breakpoint } from '@material-ui/core/styles/createBreakpoints'; import { TextFieldProps } from '@material-ui/core/TextField'; import { ActionsFiles } from './inputsTypes/FileInput/Props'; import { StepsBuilder, StepValidator, FieldsBuilder, FieldBuilder } from './utils'; import { validators, InputValidator, InputsValidator } from './utils/validate'; export interface Message { ns?: string; message: string; /** * @description Properties to be passed to translate */ props?: any; } export interface EventField { target: { name: string; value: V; type?: string; }; } export declare type changeField = (e: (EventField | React.ChangeEvent) & { fieldProxy?: FieldBuilder; }, callback?: () => void) => void | (() => void); export interface ChangeField { changeField: changeField; } export declare type value = any; export declare type GlobalProps = () => { [key: string]: any; }; export declare type transPosition = string | boolean; export declare type activeStep = number; export interface InitialState { ns?: string; } interface GlobalPropsInterface { globalProps?: GlobalProps; } export interface InitialStateSteps extends InitialState, GlobalPropsInterface { validate?: boolean; steps: StepProps[]; activeStep: activeStep; loading?: boolean; footerSteps?: { [key: number]: Record<'next' | 'back', Message & { state?: boolean; }>; }; } export declare function buildFields(a: PropsField[]): PropsField[]; export declare type FieldsAll = PropsField[]; export interface InitialStateFields extends InitialState, GlobalPropsInterface { validate?: boolean | ((inputsValidator: InputsValidator) => boolean); fields: PropsField[]; } export interface ChangeValueField { field: FieldBuilder; action: EventField['target']; } export interface ChangeValueFields { fieldsBuilder: FieldsBuilder; action: EventField['target']; } export interface ChangeValueSteps { activeStep: activeStep; steps: StepValidator[]; action: ChangeValueFields['action']; } export declare type ValidateInputsValidator = ValidationsFields['validate']; interface GridRender { /** * @default true */ grid?: boolean; } export interface FieldsProps extends InitialState, GlobalPropsInterface, ValidationsFields, GridRender { fields: PropsField[]; } export interface StepProps extends FieldsProps { label: Message | string; stepper?: boolean; elevation?: number; } export interface StepsRender extends ChangeField { footerRender?: ({ stepsLength, activeStep, footerSteps, }: { stepsLength: number; activeStep: activeStep; footerSteps: Partial; }) => Record<'next' | 'back', Message & { state?: boolean; }>; handleNextStep: (activeStep: activeStep) => void; handleBackStep: (activeStep: activeStep) => void; gridProps?: Omit; stepperProps?: Omit; getSteps?: () => StepProps[]; stepsBuild: InitialStateSteps; } export declare type Rules = keyof typeof validators; export interface Validation extends Message { rule: Rules; args?: any; } export interface AllPropsValidationFunction extends Partial> { fieldsBuilder?: FieldsBuilder; field: FieldBuilder; stepsBuilder?: StepsBuilder; activeStep?: activeStep; } /** * @description * Defines the map of errors returned from failed validation checks. * * @publicApi */ export declare type ValidationError = string | React.ReactElement | Message; export declare type ValidationErrors = ValidationError[]; declare type ReturnValidationError = undefined | void | ValidationError; export declare type ValidationFunction = (all: AllPropsValidationFunction) => ReturnValidationError | Promise; export interface Validations { validate?: boolean | ((arg: any) => boolean); value: V; validations?: (Validation | ValidationFunction)[]; } export interface ValidationsField extends Validations { validate?: boolean | ((inputValidator: InputValidator) => boolean); } export interface ValidationsFields { validate?: boolean | ((inputsValidator: InputsValidator) => boolean); } export interface ExtraProps extends ActionsFiles { helpMessage?: boolean; searchField?: string | number | ((e: PropsField[]) => string | number); searchId?: string; search?: { state: boolean; value: string | number; }; renderItem?: React.ReactNode; timeConsult?: number; actions?: { onDelete(e: any): any; onAdd(e: any): any; }; loading?: boolean; accept?: string | string[]; extensions?: string[]; multiple?: boolean; validateExtensions?: boolean; validateAccept?: boolean; subLabel?: Message; } export declare type ChildrenRender = React.ReactElement>; export declare type RenderField = (element: { children: ChildrenRender; props: FieldProps; }) => React.CElement; export declare type ComponentField = React.ElementType; export interface ComponentErrorsProps { errors: ValidationErrors; fieldProxy?: FieldBuilder; } export declare type ComponentErrors = React.ElementType>; export declare type TypeTextField = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week' | 'datetime-local'; export declare type TypeField = 'component' | 'file' | TypeTextField; export declare function createField(params: PropsField): PropsField; export declare type TextFieldPropsField = Pick; export declare type LabelPropsField = string | React.ReactElement | Message; export declare type InputPropsField = ((a: { type: InputProps['type']; changeType: (type: InputProps['type'], callback?: () => void) => void; } & BaseRender) => Partial) | Partial; export declare type BreakpointsField = Partial>; export declare enum StatusField { 'VALID' = "VALID", 'INVALID' = "INVALID", 'PENDING' = "PENDING", 'DISABLED' = "DISABLED" } export interface PropsFieldBase { type?: TypeField; name: string; value: V; disabled?: boolean; defaultInputValue?: V; label?: LabelPropsField; onChange?: changeField; } export interface PropsField extends PropsFieldBase, ValidationsField, InitialState, GridRender { extraProps?: ExtraProps; render?: RenderField; fullWidth?: boolean; errors?: ValidationErrors; autoComplete?: string; InputProps?: InputPropsField; textFieldProps?: TextFieldPropsField; breakpoints?: BreakpointsField; component?: ComponentField; renderErrors?: ComponentErrors; } export interface Validate extends Validations { state?: boolean; } export interface BaseRender { fieldProxy: FieldBuilder; } export interface FieldProps extends BaseRender, ChangeField, GridRender { } export interface InputProps extends FieldProps { type?: TypeTextField; } export interface BaseBuilder extends ChangeField { getSteps?: () => StepProps[]; activeStep?: activeStep; getFields?: () => PropsField[]; } export declare type FieldRenderProps = BaseBuilder & BaseRender; export declare type FieldsRenderProps = FieldsProps & BaseBuilder; export declare type FieldRenderComponentProps = FieldRenderProps; export {};