/* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from 'react' import * as Validator from 'validator' import { GetRef } from '../..' type Omit = Pick> type ParametersAfterFirst any> = T extends ( value: string, ...args: infer P ) => any ? P : never type Validators = Omit type Validations = { [Key in keyof Validators]: ParametersAfterFirst } interface FormComponentProps { /** Model name for Form */ name: string /** Disable the input; Will be removed from model in Form onSubmit callback */ disabled?: boolean /** Uniq id for input */ id?: string /** Mark input as required */ required?: boolean /** Regex Validation pattern */ regexValidation?: string /** Validations from validator.js */ validations?: Validations } export interface FormComponentInjectedProps extends FormComponentProps { isValid: boolean serverError: null | string hasError: boolean id: string } interface FormComponentOuterProps> extends Partial>, FormComponentProps, FormComponentRef {} type WithoutInjectedProps

= Omit< P, keyof FormComponentInjectedProps > type FormComponentRef> = { ref?: React.Ref<{ FormComponent: GetRef }> } declare function formComponent< T extends React.ComponentType

, P extends FormComponentInjectedProps >( component: T & React.ComponentType

): React.ComponentType & FormComponentOuterProps> // helper for applying hoc in .d.ts files export type ApplyFormComponent< T extends React.ComponentType

, P extends FormComponentInjectedProps = React.ComponentProps > = React.ComponentType & FormComponentOuterProps> export default formComponent