/** * Periods for (Periods tab and the preset search). * * The panel has one tab per period: Daily · Weekly · Monthly · Quarterly · * Yearly. Each tab shows a few QUICK presets (relative: "Last month") and, * except Daily, a grid of SPECIFIC periods (fixed: "September 2026"). * * A preset is a label + a function that turns "today" into [start, end], so * teams can add their own. Its `group` decides the tab: a period key below, * or any other text to get a separate tab with that name. * * const lastFortnight: DatePreset = { * id: 'last-14-days', * label: 'Last 14 days', * group: 'day', * range: (today) => [addDays(today, -13), endOfDay(today)], * }; * * Week / month / quarter / year presets are CALENDAR based: on Wed 7 Oct * 2026, "Last 2 months" = 1 Aug – 30 Sep (the two full months before this * one). "Last N days" presets are rolling and include today. */ import { DateSpan } from './date-utils'; export type DatePeriod = 'day' | 'week' | 'month' | 'quarter' | 'year'; export declare const DATE_PERIODS: DatePeriod[]; /** Tab labels */ export declare const DATE_PERIOD_LABELS: Record; /** Settings a preset may need to resolve itself */ export interface DatePresetContext { weekStartsOn: 0 | 1; } export interface DatePreset { /** Stable id: emitted in selectionChange and accepted as an ngModel value */ id: string; label: string; /** Tab it is listed under: a DatePeriod, or any text for a custom tab */ group?: DatePeriod | string; /** true when the label already names the dates ("Q3 2026"), so the field doesn't repeat them */ fixed?: boolean; /** Resolves the period for the given day */ range: (today: Date, context: DatePresetContext) => DateSpan; } export type DatePresetId = 'today' | 'yesterday' | 'last-7-days' | 'last-30-days' | 'last-90-days' | 'this-week' | 'last-week' | 'last-2-weeks' | 'last-4-weeks' | 'this-month' | 'last-month' | 'last-2-months' | 'last-3-months' | 'last-6-months' | 'last-12-months' | 'this-quarter' | 'last-quarter' | 'this-year' | 'year-to-date' | 'last-year' | 'last-2-years'; /** Every built-in relative preset, by id */ export declare const DATE_PRESETS: Record; /** Quick choices shown when [presets] isn't set: at most 4 per tab */ export declare const DEFAULT_DATE_PRESETS: DatePresetId[]; /** One day as a period, e.g. "Oct 7, 2026" (picked on the Daily tab's calendar) */ export declare function dayPreset(date: Date): DatePreset; /** The 7 days starting at `start`, e.g. "Oct 5 – Oct 11, 2026" */ export declare function weekPreset(start: Date): DatePreset; /** A calendar month, e.g. monthPreset(2026, 8) = "September 2026" (month is 0-based) */ export declare function monthPreset(year: number, month: number): DatePreset; /** A specific quarter, e.g. quarterPreset(2026, 3) = "Q3 2026" (1 Jul – 30 Sep) */ export declare function quarterPreset(year: number, quarter: number): DatePreset; /** A whole calendar year, e.g. yearPreset(2025) = "2025" */ export declare function yearPreset(year: number): DatePreset; /** * Several consecutive periods of the same kind as one selection, e.g. * Aug 2026 … Mar 2027 → id "month-2026-08..month-2027-03", * label "Aug 2026 – Mar 2027". Works in either order. */ export declare function spanPreset(a: DatePreset, b: DatePreset): DatePreset; /** * "Last N days / weeks / months / quarters / years" for any N, e.g. * lastPeriodsPreset(5, 'month') = "Last 5 months" (id "last-5-months"). * Same rules as the built-ins: days are rolling (include today), the others * are the N full periods before the current one. N = 1 gives the built-in * ("Last month"; for days, "Today"). */ export declare function lastPeriodsPreset(n: number, unit: DatePeriod): DatePreset; /** A preset's dates for this "today", trimmed to min / max (null when fully outside) */ export declare function presetSpan(preset: DatePreset, today: Date, weekStartsOn: 0 | 1, min?: Date | null, max?: Date | null): DateSpan | null; /** Turns the [presets] input (ids and/or objects) into preset objects */ export declare function resolvePresets(list: (DatePresetId | DatePreset)[]): DatePreset[]; /** * Finds a preset by id: the given list first, then the built-ins, then the * fixed periods ("day-2026-10-07", "week-2026-10-05", "month-2026-09", * "q3-2026", "year-2025") and spans of them ("month-2026-08..month-2027-03"). * Used to restore a saved selection. */ export declare function findPreset(id: string, list: DatePreset[]): DatePreset | null; /** Which period tab a preset belongs to ('day'…'year' or its custom group) */ export declare function periodOf(preset: DatePreset): string;