import { type VariantProps } from 'class-variance-authority'; import { triggerVariants } from '../_shared'; export interface DateRangePreset { label: string; range: () => { from: Date; to: Date; }; /** Optional group name — presets sharing a group render under one sub-heading. */ group?: string; } export interface DateRangeValue { from?: Date; to?: Date; } /** Time grain the range is queried at (Range Cockpit). */ export type DateRangeGranularity = 'day' | 'week' | 'month' | 'quarter'; /** How the comparison period is derived from the selected range. */ export type DateRangeCompareMode = 'previous' | 'lastYear'; /** Extra data emitted alongside a committed range (Range Cockpit). */ export interface DateRangeApplyMeta { granularity?: DateRangeGranularity; compareRange?: DateRangeValue; } /** Curated imperative handle exposed via `ref` — also consumed by the agent adapter. */ export interface DateRangePickerHandle { /** Get the current selected range. */ getRange: () => DateRangeValue; /** Replace the selected range. */ setRange: (range: DateRangeValue) => void; /** Clear the selected range. */ clear: () => void; /** Whether the popover is open. */ isOpen: () => boolean; /** Open the range calendar popover. */ open: () => void; /** Close the range calendar popover. */ close: () => void; /** Current granularity, or undefined when the control is disabled. */ getGranularity: () => DateRangeGranularity | undefined; /** Set the time granularity. */ setGranularity: (granularity: DateRangeGranularity) => void; /** Current comparison period, or undefined when compare is off/incomplete. */ getCompareRange: () => DateRangeValue | undefined; /** Turn compare-to-previous-period on or off. */ setCompare: (enabled: boolean) => void; /** Label of the preset matching the committed range, or undefined for a custom range. */ getActivePreset: () => string | undefined; /** Which endpoint the next calendar click will set, or null when the draft is complete. */ getActiveEnd: () => 'start' | 'end' | null; /** Commit the current draft (as the Apply / Done button does). */ apply: () => void; /** Discard the draft and close (as Cancel / Escape does). */ cancel: () => void; } export interface DateRangePickerProps extends Pick, 'size'> { /** Current range — controlled. */ value?: DateRangeValue; /** Default range — uncontrolled. */ defaultValue?: DateRangeValue; /** * Called when the range is committed. In `commitMode="auto"` (default) this * fires the instant the range becomes COMPLETE (both ends) — never on a * start-only partial. In `commitMode="apply"` it fires once, on Apply. */ onChange?: (range: DateRangeValue) => void; /** * Commit model. * - `'auto'` (default): manual selection updates a popover-local draft and * commits (`onChange`) the moment both ends exist; the popover stays open so * the user can refine, and the footer's Done button dismisses it. A preset * commits and closes. Right for cheap client-side filters. * - `'apply'`: every edit (presets, calendar, typed fields) mutates the draft * only; nothing commits until the Apply button. Escape / outside-click / * Cancel revert to the last committed value. Right for expensive queries * that must not fire on a half-picked range. */ commitMode?: 'auto' | 'apply'; /** * Called when the range is committed by a decisive action that CLOSES the * popover — a preset click, or the Apply button. Completing a range on the * calendar in `'auto'` mode fires `onChange` but keeps the popover open, so it * does not fire `onApply`. The optional second argument carries the Range * Cockpit metadata (granularity + resolved comparison range) when enabled. */ onApply?: (range: DateRangeValue, meta?: DateRangeApplyMeta) => void; /** Called when an `'apply'`-mode edit is cancelled (Cancel / Escape / dismiss). */ onCancel?: () => void; /** Show the footer Clear action. Defaults to `true`. */ showClear?: boolean; /** Number of month grids to render. Defaults to `2`. */ numberOfMonths?: number; /** * Shrink the popover for a tight host — a grid column filter, a toolbar. One * month instead of two, no title, no preset rail. The trigger is unaffected; * use `size` for that. */ compact?: boolean; /** * Range Cockpit — granularity. Passing `granularity` (controlled) or * `defaultGranularity` (uncontrolled) shows a Day / Week / Month / Quarter * segmented control in the header and names the queried grain. */ granularity?: DateRangeGranularity; defaultGranularity?: DateRangeGranularity; onGranularityChange?: (granularity: DateRangeGranularity) => void; /** * Restrict the granularity segmented control to a subset of * `'day' | 'week' | 'month' | 'quarter'` — e.g. `['month', 'quarter']` for * data with a coarser grain. Options always render in canonical * Day → Quarter order regardless of the array order passed. Defaults to all * four (an empty array is treated as all four). Only meaningful when the * Cockpit granularity control is enabled (via `granularity` / * `defaultGranularity`) — it does not enable the control on its own. A * `defaultGranularity` or controlled `granularity` outside the allowed set is * clamped to the first allowed option. */ allowedGranularities?: DateRangeGranularity[]; /** * Range Cockpit — compare. When `true`, a compare-to-previous-period toggle * appears; enabling it overlays a neutral secondary band on the calendar and * (on Apply) reports the resolved comparison range via `onApply` meta and * `onCompareChange`. */ compare?: boolean; /** * Controlled checked state of the compare toggle — the APPLIED compare * on/off value. Pair with `onCompareChange` and drive it from the consumer * so a reopened picker reflects the applied state. When omitted the toggle * is uncontrolled and seeded from `defaultCompare`. This is distinct from * `compare`, which only decides whether the control renders. Only * meaningful when `compare` is set. */ compareEnabled?: boolean; /** Start with compare enabled — uncontrolled initial checked state (only meaningful when `compare` is set). */ defaultCompare?: boolean; defaultCompareMode?: DateRangeCompareMode; onCompareChange?: (enabled: boolean, compareRange?: DateRangeValue) => void; /** Week start (0 = Sunday). Defaults to the locale's first day. */ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6; /** Minimum selectable date. */ minDate?: Date; /** Maximum selectable date. */ maxDate?: Date; /** Custom presets. Replaces defaults unless mergePresets is true. */ presets?: DateRangePreset[]; /** Merge custom presets with defaults instead of replacing. */ mergePresets?: boolean; /** Component size. */ size?: 'sm' | 'md' | 'lg'; /** * Trigger chrome. `'input'` (default) is the soft input look — fill + the * `--shadow-input` halo — that matches other form fields. `'button'` renders * the trigger as an outline Button (flat, `--radius-md`, no halo, `md` = 40px) * so the picker sits flush among Buttons in a toolbar. Use `'button'` only in * toolbars, not in forms: the input chrome's `--control-border` edge marks * the field at 3:1 (WCAG 1.4.11), whereas a button-chrome trigger relies on * its value/label like a Button does. */ chrome?: 'input' | 'button'; /** Disabled state. */ disabled?: boolean; /** Placeholder text. */ placeholder?: string; /** Additional class names. */ className?: string; /** id override. */ id?: string; } export declare const DateRangePicker: import("react").ForwardRefExoticComponent>; //# sourceMappingURL=date-range-picker.d.ts.map