import * as React from 'react'; import { MuiDateSectionName, MuiPickerFieldAdapter } from '../../models'; import { PickerStateValueManager } from '../usePickerState'; import { InferError, Validator } from '../validation/useValidation'; export interface UseFieldParams> { forwardedProps: TForwardedProps; internalProps: TInternalProps; valueManager: PickerStateValueManager; fieldValueManager: FieldValueManager>; validator: Validator>; } export interface UseFieldInternalProps { value?: TInputValue; onChange?: (value: TValue) => void; onError?: (error: TError, value: TInputValue) => void; /** * The default value. Use when the component is not controlled. */ defaultValue?: TInputValue; format?: string; /** * It prevents the user from changing the value of the field * (not from interacting with the field). * @default false */ readOnly?: boolean; } export interface UseFieldForwardedProps { onKeyDown?: React.KeyboardEventHandler; onClick?: () => void; onFocus?: () => void; onBlur?: () => void; } export interface UseFieldResponse { inputProps: UseFieldResponseInputProps; inputRef: React.RefObject; } export declare type UseFieldResponseInputProps = Omit & NonNullable & { value: string; error: boolean; }; export interface FieldSection { start: number; end: number; value: string; emptyValue: string; separator: string | null; dateSectionName: MuiDateSectionName; formatValue: string; query: string | null; } export interface FieldValueManager { getSectionsFromValue: (utils: MuiPickerFieldAdapter, prevSections: TSection[] | null, value: TValue, format: string) => TSection[]; getValueStrFromSections: (sections: TSection[]) => string; getValueFromSections: (utils: MuiPickerFieldAdapter, prevSections: TSection[], sections: TSection[], format: string) => { value: TValue; shouldPublish: boolean; }; getActiveDateFromActiveSection: (value: TValue, activeSection: TSection) => { value: TDate | null; update: (newActiveDate: TDate | null) => TValue; }; hasError: (error: TError) => boolean; isSameError: (error: TError, prevError: TError | null) => boolean; } export interface UseFieldState { valueStr: string; valueParsed: TValue; sections: TSections; selectedSectionIndexes: { start: number; end: number; } | null; } export declare type UseFieldValidationProps> = Omit & { value: TInputValue; }; export declare type AvailableAdjustKeyCode = 'ArrowUp' | 'ArrowDown' | 'PageUp' | 'PageDown' | 'Home' | 'End';