import "./date_filter.css"; import type * as React from "react"; import { useRender } from "@base-ui/react/use-render"; import { type StyleProps } from "./style_props"; export type PresetId = "today" | "yesterday" | "tomorrow" | "this_week" | "this_month" | "last_month" | "this_quarter" | "last_quarter" | "this_year" | "last_year"; /** Display order — every id SETS a range, and they run by GRAIN, shortest * first. */ export declare const PRESET_IDS: PresetId[]; /** Resolve a preset relative to `now`. The boundary math matches the view-page * filter, so a resolved range round-trips back to the same preset. */ export declare function getPresetValue(id: PresetId, now: Date): DateFilterValue; /** * THE COMPARATOR for a selected range — the period a report means by "so với kỳ * trước", derived from the range the reader already picked. * * A range that IS a whole calendar month, quarter or year steps back one WHOLE * period, never a fixed number of days: sliding a 31-day window back would * compare March against the last three days of January plus February. Any other * complete range steps back by its own LENGTH, ending the day before it starts. * * Whole days only; the bounds come back day-aligned and untimed. `null` when * either bound is missing — an open range names no period. */ export declare function previousPeriod(value: DateFilterValue): DateFilterValue | null; /** A selected period read against the clock, with its comparator already cut. */ export interface PeriodToDate { /** The selection, ending at `now` while the period is still RUNNING. */ current: DateFilterValue; /** `previousPeriod`, cut to the same elapsed days; `null` for an open-ended * selection. */ previous: DateFilterValue | null; /** `now` falls before the selection's last day. */ running: boolean; /** Days of the selection already behind us — 0 for a period still ahead. */ elapsedDays: number; totalDays: number; } /** * A RUNNING period is compared TO DATE: both sides cut to the days that have * actually elapsed, because six days of this month beside a whole previous month * reads as a collapse that never happened. The cut is clamped to the previous * period's own end, so thirty elapsed days of March compare against all 28 of * February rather than running past it. * * A period already closed keeps both sides whole. A period entirely in the * future has nothing elapsed: `current` holds its first day and `elapsedDays` * is 0, so a caller can say it has not started instead of drawing a −100%. * * `null` when either bound is missing, matching `previousPeriod`. */ export declare function periodToDate(value: DateFilterValue, now: Date): PeriodToDate | null; export interface DateFilterValue { start: { date: Date | null; time: string | null; }; end: { date: Date | null; time: string | null; }; } /** Translated labels — the preset names and the range-display strings. */ export interface DateFilterLabels { today: string; yesterday: string; tomorrow: string; thisWeek: string; thisMonth: string; lastMonth: string; thisQuarter: string; lastQuarter: string; thisYear: string; lastYear: string; from: string; to: string; /** Accessible name of the `field` variant's trigger. */ selectDateRange: string; /** Stands in for a bound that has no date yet — the open half of a range. */ selectDate: string; } /** What the `field` variant adds: its footer's two verbs and its resting text. */ export interface DateFilterFieldLabels extends DateFilterLabels { clear: string; done: string; placeholder: string; } interface DateFilterCommonProps extends StyleProps { value: DateFilterValue; onValueChange: (value: DateFilterValue) => void; includeTime?: boolean; /** BCP-47 locale for the calendar and date display. */ locale?: string; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** The panel alone (default): the surface around it owns the trigger and the * footer, as a grid column header does. */ export interface DateFilterPanelProps extends DateFilterCommonProps { variant?: "panel"; labels?: Partial; } /** The same panel behind a FIELD: a trigger naming the period filtered by, the * panel in a popover, and a Clear / Done footer. */ export interface DateFilterFieldProps extends DateFilterCommonProps { variant: "field"; labels?: Partial; } export type DateFilterProps = DateFilterPanelProps | DateFilterFieldProps; export declare function DateFilter(props: DateFilterProps): React.JSX.Element; export {};