UNPKG

@kelvininc/ui-components

Version:
31 lines (30 loc) 1.24 kB
import type dayjs from 'dayjs'; import { ERelativeTimeRangeKey, EUnitReference } from './relative-time.types'; /** * Configuration for relative time offset calculations. * * @remarks * Supports two patterns: * - Simple offset: `{ offset: -5, unit: 'minutes' }` - Calculates by adding/subtracting offset units from current time * - Unit reference offset: `{ offset: 0, unit: 'day', unitReference: 'startOfUnit' }` - Calculates relative to the start/end of a time unit */ export type RelativeTimeOffsetConfig = { /** Number of units to add (positive) or subtract (negative) */ offset: number; /** The time unit to manipulate */ unit: dayjs.ManipulateType | dayjs.QUnitType; /** Optional: Reference point within the unit (start or end) */ unitReference?: EUnitReference; }; /** * Configuration mapping for all relative time range keys. * * @remarks * Defines how each `ERelativeTimeRangeKey` should be calculated: * - Simple offsets add/subtract units from current time * - Unit reference offsets align to start/end of time units * * @see {RelativeTimeOffsetConfig} * @see {getRelativeTimeCalculation} */ export declare const RELATIVE_TIME_OFFSETS: Record<ERelativeTimeRangeKey, RelativeTimeOffsetConfig>;