import { PickerDateType } from '../models/pickers'; import { DateAdapter } from '../models/adapter'; /** * A range value with start and end dates. * * @example * ```tsx * import { PickerRangeValue } from '@hxnova/react-components/DatePickers'; * * const [range, setRange] = useState([null, null]); * * // Setting a range * setRange([dayjs('2024-01-01'), dayjs('2024-01-31')]); * * // Checking if range is set * const hasRange = range[0] && range[1]; * ``` */ export type PickerRangeValue = [PickerDateType | null, PickerDateType | null]; /** * The position in the range being selected (start or end). * Used to track which date the user is currently selecting in a range picker. * * @example * ```tsx * const [rangePosition, setRangePosition] = useState('start'); * * const handleDateClick = (date: PickerDateType) => { * if (rangePosition === 'start') { * setStartDate(date); * setRangePosition('end'); * } else { * setEndDate(date); * setRangePosition('start'); * } * }; * ``` */ export type RangePosition = 'start' | 'end'; /** * Checks if a range is valid (both dates are set and properly ordered). * * @param utils - The date adapter utilities * @param range - The range to validate * @returns True if the range is valid and properly ordered * * @example * ```tsx * import { isRangeValid } from '@hxnova/react-components/DatePickers'; * import { usePickerContext } from '@hxnova/react-components/DatePickers'; * * const { utils } = usePickerContext(); * const range = [dayjs('2024-01-01'), dayjs('2024-01-31')]; * * if (isRangeValid(utils, range)) { * console.log('Range is valid and properly ordered'); * } * ``` */ export declare function isRangeValid(utils: DateAdapter, range: PickerRangeValue): boolean; /** * Checks if a date is the start of a range. * Useful for styling range selection in calendars. * * @param utils - The date adapter utilities * @param day - The date to check * @param range - The current range * @returns True if the date is the start of the range * * @example * ```tsx * const isStartOfSelectedRange = isStartOfRange(utils, date, selectedRange); * return ( * * ); * ``` */ export declare function isStartOfRange(utils: DateAdapter, day: PickerDateType, range: PickerRangeValue): boolean; /** * Checks if a date is the end of a range. * Useful for styling range selection in calendars. * * @param utils - The date adapter utilities * @param day - The date to check * @param range - The current range * @returns True if the date is the end of the range * * @example * ```tsx * const isEndOfSelectedRange = isEndOfRange(utils, date, selectedRange); * return ( * * ); * ``` */ export declare function isEndOfRange(utils: DateAdapter, day: PickerDateType, range: PickerRangeValue): boolean; /** * Checks if a date is within a range (inclusive of bounds). * Useful for highlighting dates within the selected range. * * @param utils - The date adapter utilities * @param day - The date to check * @param range - The current range * @returns True if the date is within the range (inclusive) * * @example * ```tsx * const isWithinSelectedRange = isWithinRange(utils, date, selectedRange); * return ( * * ); * ``` */ export declare function isWithinRange(utils: DateAdapter, day: PickerDateType, range: PickerRangeValue): boolean; /** * Options for calculating range changes. * * @interface CalculateRangeChangeOptions */ interface CalculateRangeChangeOptions { /** * The utilities object for date manipulation */ utils: DateAdapter; /** * The current range value */ range: PickerRangeValue; /** * The newly selected date */ newDate: PickerDateType; /** * Whether the user is selecting the start or end of the range */ rangePosition: RangePosition; } /** * Result of range change calculation. * * @interface CalculateRangeChangeResult */ interface CalculateRangeChangeResult { /** * The new range value after the selection */ newRange: PickerRangeValue; /** * The next position that should be selected (start or end) */ nextSelection: RangePosition; } /** * Calculate the new range value based on the current selection. * Handles the logic for updating ranges when a user selects dates. * * @param options - The calculation options * @returns The new range and next selection position * * @example * ```tsx * const handleDateClick = (newDate: PickerDateType) => { * const result = calculateRangeChange({ * utils, * range: currentRange, * newDate, * rangePosition: currentRangePosition * }); * * setRange(result.newRange); * setRangePosition(result.nextSelection); * }; * ``` */ export declare function calculateRangeChange({ utils, range, newDate, rangePosition, }: CalculateRangeChangeOptions): CalculateRangeChangeResult; /** * Calculate the preview range when hovering over a date. * Used to show users what the range would look like before they click. * * @param options - The calculation options (same as calculateRangeChange) * @returns A preview range to display during hover * * @example * ```tsx * const handleDateHover = (hoveredDate: PickerDateType) => { * const previewRange = calculateRangePreview({ * utils, * range: currentRange, * newDate: hoveredDate, * rangePosition: currentRangePosition * }); * * setPreviewRange(previewRange); * }; * * const handleDateLeave = () => { * setPreviewRange([null, null]); * }; * ``` */ export declare function calculateRangePreview({ utils, range, newDate, rangePosition, }: CalculateRangeChangeOptions): PickerRangeValue; export {};