compote-ui
Version:
An opinionated UI component library for Svelte, built on top of [Ark UI](https://ark-ui.com) with additional components and features not available in the core Ark UI library.
32 lines (31 loc) • 1.71 kB
TypeScript
/**
* Calendar-day range filters for date and date-time columns.
*
* The filter value is `[from?, to?]`, each an ISO calendar date (`YYYY-MM-DD`) or empty — no
* time, no zone, so it serializes cleanly. Both bounds are inclusive days. A cell matches
* when the day it shows in the display zone (see `readDateInZone`) falls inside the range.
* For an instant that is the half-open interval [start of `from`, start of the day after
* `to`) in that zone, with day starts taken from the calendar — so 23- and 25-hour DST days
* need no special handling.
*/
import { CalendarDate } from '@internationalized/date';
/** A date range filter value as stored in table state. */
export type DateRangeFilterValue = [from?: string, to?: string];
/** A filter value read into calendar dates; an absent bound leaves that end open. */
export type DateRange = {
from?: CalendarDate;
to?: CalendarDate;
};
/**
* The range a filter value stands for. Invalid bounds are dropped and a reversed range is
* swapped (as TanStack's `inNumberRange` does). Always returns a range — never undefined —
* because the table falls back to the raw value when `resolveFilterValue` returns nullish.
*/
export declare function resolveDateRange(filterValue: unknown): DateRange;
/** Whether a filter value has no usable bound, so the filter should be removed. */
export declare function isEmptyDateRange(filterValue: unknown): boolean;
/**
* Whether a cell value falls in `range`, judged by the calendar day it shows in `timeZone`.
* Empty or unparseable cell values never match while the filter is active.
*/
export declare function matchesDateRange(value: unknown, range: DateRange, timeZone: string): boolean;