/// import { FieldModel, IValidators, IMaybeError, BasicModel, ValidateOption, ModelRef, IModel, INormalizeBeforeSubmit } from './formulr'; import { Optional } from 'utility-types'; import { IFormControlProps } from './Control'; import { SingleDate, RangeDate } from '../date-picker'; export interface IRenderError { (error: IMaybeError): React.ReactNode; } export interface IFormFieldViewDrivenProps { name: string; defaultValue: T | (() => T); initialValue?: T; validators?: IValidators; destroyOnUnmount?: boolean; normalizeBeforeSubmit?: INormalizeBeforeSubmit; } export interface IFormFieldModelDrivenProps { model: FieldModel | ModelRef, FieldModel>; validators?: IValidators; defaultValue: T | (() => T); initialValue?: T; } export declare type IFormFieldModelProps = IFormFieldViewDrivenProps | IFormFieldModelDrivenProps; export declare function isViewDrivenProps(props: IFormFieldModelProps): props is IFormFieldViewDrivenProps; export declare enum ValidateOccasion { None = 0, Change = 1, Blur = 2, Default = 3 } export declare enum TouchWhen { Change = 0, Blur = 1 } export interface IFormFieldPropsBase extends Omit, Partial, 'value'>> { renderError?: IRenderError; helpDesc?: React.ReactNode; notice?: React.ReactNode; withoutError?: boolean; before?: React.ReactNode; after?: React.ReactNode; required?: boolean | string; validateOccasion?: ValidateOccasion; normalize?: (value: Value, prevValue: Value) => Value; normalizeBeforeBlur?: (value: Value) => Value; format?: (value: Value) => Value; getValidateOption?: (source: 'blur' | 'change') => ValidateOption | undefined; modelRef?: React.RefObject>; touchWhen?: TouchWhen; } export declare type IFormFieldProps = IFormFieldPropsBase & IFormFieldModelProps & { children(props: IFormFieldChildProps): React.ReactNode; }; export declare type IFormComponentProps = never> = (Omit, 'touchWhen' | OmitKeys> & { props?: Partial; }) & (Optional, 'defaultValue'> | Optional, 'defaultValue'>); export declare function dateDefaultValueFactory(): SingleDate; export declare function dateRangeDefaultValueFactory(): RangeDate; export declare function dateDefaultTimeFactory(): string; export declare function dateRangeDefaultTimeFactory(): [string, string]; export declare function defaultRenderError(error: IMaybeError): JSX.Element; export declare function useFormChild(model: BasicModel, scrollAnchorRef?: React.RefObject): void; export interface IFormFieldChildProps { value: Value; onChange(e: Value): void; onBlur: React.FocusEventHandler; onCompositionStart: React.CompositionEventHandler; onCompositionEnd: React.CompositionEventHandler; }