import type { Dayjs } from 'dayjs'; import type { TimeRangeOption } from '../types'; export interface UseTimeAxisOptions { range?: TimeRangeOption; stepMinutes: number; referenceDate: Dayjs; orientation: 'horizontal' | 'vertical'; /** 横向时每格宽度(px),竖向时每格高度(px) */ cellSizePx: number; } export interface TimeAxisState { rangeStart: Dayjs; rangeEnd: Dayjs; /** 每格起点时间序列(含 head / tail,对齐到 step 网格) */ ticks: Dayjs[]; /** 与 `ticks` 一一对应的格宽(px);head / tail 可 < cellSizePx,中间格 = cellSizePx */ cellWidthsPx: number[]; /** 时间转主轴偏移(px) */ timeToOffset: (t: Dayjs) => number; /** 主轴偏移(px)转时间(最近刻度,用于刻度对齐) */ offsetToTime: (offset: number) => Dayjs | null; /** 主轴偏移(px)转时间(连续插值,用于拖动时按分钟步长显示) */ offsetToTimeContinuous: (offset: number) => Dayjs | null; /** 主轴总长度(px) */ totalLengthPx: number; } /** * 时间轴刻度与时间↔像素换算。 * * 格子拆分策略见 {@link getAxisCells}:当 `range.start` / `range.end` 不在 `stepMinutes` 网格上时, * 首尾出现宽度按时间比例缩小的 head/tail 格,中间格保持 step 整步并落在网格整点上。 * * 时间→像素仍是线性映射 `dotOffsetPx + (t - rangeStart) / step × cellSize`,与 head/tail 是否存在无关: * `dotOffsetPx`(横向 = `cellSize/2`,竖向 = 0)为 rangeStart 在轴内的像素位置;轴两端各保留 `dotOffsetPx` * 留白以居中 rangeStart / rangeEnd。 */ export declare function useTimeAxis(options: UseTimeAxisOptions): TimeAxisState;