import { GridState } from './gridState'; import { ColumnDef, Coord, DataRow, Size } from './types'; export interface ColumnBoundary { /** * The left hand edge (inclusive) of the column (excluding border), from the grid origin */ left: number; /** * The right hand edge (exclusive) of the column (excluding border), from the grid origin */ right: number; } export declare class GridGeometry { /** * Calculate the boundaries of all columns in the grid, excluding borders. The 'left's are inclusive, * the 'right's are exclusive. */ static calculateColumnBoundaries: (columns: ColumnDef[], borderWidth: number) => ColumnBoundary[]; /** * Calculate the total size of the grid, including borders, but excluding gutters */ static calculateGridSize: (data: DataRow[], columnBoundaries: ColumnBoundary[], rowHeight: number, borderWidth: number) => Size; /** * Calculates the total size of the grid, including scrollbar gutters */ static calculateGridPlusGutterSize: (gridSize: Size, rootSize: Size | null) => Size; static calculateCanvasSize: (gridPlusGutterSize: Size, rootSize: Size | null) => Size; static calculateFrozenRowsHeight: (rowHeight: number, borderWidth: number, frozenRows: number) => number; static calculateFrozenColsWidth: (columnBoundaries: ColumnBoundary[], frozenCols: number, borderWidth: number) => number; static calculateGridCellCoordsFromGridState: (event: { clientX: number; clientY: number; }, rootRef: HTMLDivElement | null, gridState: GridState) => Coord; /** * Calculate the column & row index (i.e. "grid cell coordinates") that contains a mouse event. The event coordinates * are given in the window/viewport's frame of reference. The grid cell coordinates account for frozen cells. */ static calculateGridCellCoords: (event: { clientX: number; clientY: number; }, columnBoundaries: ColumnBoundary[], borderWidth: number, rowHeight: number, frozenColsWidth: number, frozenRowsHeight: number, gridOffset: Coord, maxRow: number, root: HTMLDivElement | null) => Coord; static calculateGridPixelCoords: (event: { clientX: number; clientY: number; }, gridOffset: Coord, frozenColsWidth: number, frozenRowsHeight: number, root: HTMLDivElement | null) => Coord; static calculateCellBounds: (colIndex: number, rowIndex: number, rowHeight: number, borderWidth: number, columnBoundaries: ColumnBoundary[]) => ClientRect; static calculateGridOffsetFromFraction: (fraction: number, gridLength: number, canvasLength: number) => number; static truncateGridOffset: (oldOffset: Coord, gridSize: Size, canvasSize: Size) => Coord | null; /** * Takes an offset in CSS pixels and returns an offset also in CSS pixels, but quantised to * values that produce an integer offset in canvas pixels. This avoids the canvas elements trying * to do any sub-pixel rendering, and thus avoids bluriness in the grid. */ static quantiseGridOffset: (offset: Coord, dpr: number) => { x: number; y: number; }; static calculateGridOffsetForTargetColumn: (oldOffset: Coord, canvasSize: Size, frozenColsWidth: number, targetColIndex: number, columnBoundaries: ColumnBoundary[], verticalScrollGutter: ClientRect | null) => Coord; static calculateGridOffsetForTargetRow: (oldOffset: Coord, canvasSize: Size, frozenRowsHeight: number, targetRowIndex: number, rowHeight: number, borderWidth: number, numRows: number, horizontalScrollGutter: ClientRect | null) => Coord; static calculateGridOffsetForTargetCell: (oldOffset: Coord, canvasSize: Size, frozenColsWidth: number, frozenRowsHeight: number, targetCell: Coord, columnBoundaries: ColumnBoundary[], rowHeight: number, borderWidth: number, numRows: number, verticalScrollGutter: ClientRect | null, horizontalScrollGutter: ClientRect | null) => Coord; static calculateGridOffsetXForTargetColumn: (oldX: number, canvasSize: Size, frozenColsWidth: number, targetColIndex: number, columnBoundaries: ColumnBoundary[], verticalScrollGutter: ClientRect | null) => number; static calculateGridOffsetYForTargetRow: (oldY: number, canvasSize: Size, frozenRowsHeight: number, targetRowIndex: number, rowHeight: number, borderWidth: number, numRows: number, horizontalScrollGutter: ClientRect | null) => number; /** * Calculates the area of the grid visible on the canvas */ static calculateVisibleRect: (gridOffset: Coord, canvasSize: Size) => ClientRect; static isWindowPixelWithinComponent: (event: { clientX: number; clientY: number; }, root: HTMLDivElement | null) => boolean; static calculateComponentPixel: (event: { clientX: number; clientY: number; }, root: HTMLDivElement | null) => Coord; private static windowPixelToComponentPixel; /** * Converts a coordinate in the window / viewport frame of reference into grid pixel coordinates. The grid * coordinates take account of frozen cells - i.e. if the window pixel is over a frozen cell, the grid coordinate * is for a pxiel in that frozen cell, not an non-frozen cell that has been scrolled underneath it. */ private static windowPixelToGridPixel; private static gridPixelToGridCell; }