import type { DateTime } from '@gravity-ui/date-utils'; import type { ValidationState } from "../../types/index.js"; import type { DateFieldSection, FormatInfo } from "../types.js"; export type BaseDateFieldStateOptions = { value: T | null; displayValue: T; placeholderValue?: DateTime; timeZone: string; validationState?: ValidationState; editableSections: DateFieldSection[]; formatInfo: FormatInfo; readOnly?: boolean; disabled?: boolean; selectedSectionIndexes: { startIndex: number; endIndex: number; } | null; selectedSections: number | 'all'; isEmpty: boolean; flushAllValidSections: () => void; flushValidSection: (sectionIndex: number) => void; setSelectedSections: (position: number | 'all') => void; setValue: (value: T) => void; setDate: (value: T | null) => void; adjustSection: (sectionIndex: number, amount: number) => void; setSection: (sectionIndex: number, amount: number) => void; getSectionValue: (sectionIndex: number) => DateTime; setSectionValue: (sectionIndex: number, currentValue: DateTime) => void; createPlaceholder: () => T; setValueFromString: (str: string) => boolean; }; export type DateFieldState = { /** The current field value. */ value: T | null; /** Is no part of value is filled. */ isEmpty: boolean; /** The current used value. value or placeholderValue */ displayValue: T; /** Sets the field's value. */ setValue: (value: T) => void; /** Sets the date value. */ setDate: (value: T | null) => void; /** Formatted value */ text: string; /** Whether the field is read only. */ readOnly?: boolean; /** Whether the field is disabled. */ disabled?: boolean; /** A list of segments for the current value. */ sections: DateFieldSection[]; /** Some info about available sections */ formatInfo: FormatInfo; /** * @deprecated use formatInfo.hasDate instead. * Whether the the format is containing date parts */ hasDate: boolean; /** * @deprecated use formatInfo.hasTime instead. * Whether the the format is containing time parts */ hasTime: boolean; /** Selected sections */ selectedSectionIndexes: { startIndex: number; endIndex: number; } | null; /** The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props. */ validationState?: ValidationState; /** Sets selection for segment in position. */ setSelectedSections: (position: number | 'all') => void; /** Focuses segment in position */ focusSectionInPosition: (position: number) => void; /** Focuses the next segment if present */ focusNextSection: () => void; /** Focuses the previous segment if present */ focusPreviousSection: () => void; /** Focuses the first segment */ focusFirstSection: () => void; /** Focuses the last segment */ focusLastSection: () => void; /** Increments the currently selected segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */ increment: () => void; /** Decrements the currently selected segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */ decrement: () => void; /** * Increments the currently selected segment by a larger amount, rounding it to the nearest increment. * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years. * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */ incrementPage: () => void; /** * Decrements the currently selected segment by a larger amount, rounding it to the nearest decrement. * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years. * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */ decrementPage: () => void; incrementToMax: () => void; decrementToMin: () => void; /** Clears the value of the currently selected segment, reverting it to the placeholder. */ clearSection: () => void; /** Clears all segments, reverting them to the placeholder. */ clearAll: () => void; /** Handles input key in the currently selected segment */ onInput: (key: string) => void; setValueFromString: (str: string) => boolean; }; export declare function useBaseDateFieldState(props: BaseDateFieldStateOptions): DateFieldState;