export type Writable = { -readonly [k in keyof T]: T[k]; }; export interface ColumnWidthItem { readonly width?: number; readonly widthMin?: number; readonly widthMax?: number; readonly widthFlex?: number; } export type RowHeight = number | ((i: number) => number) | "auto" | `fill:${number}`; export interface VirtualTarget { readonly getBoundingClientRect: () => Omit; readonly getClientRects?: () => Omit[]; readonly contextElement?: HTMLElement; } export type Row = number; export type Column = number; export type RowSpan = number; export type ColSpan = number; export type Empty = 0; export type RowColTuple = [RowSpan, ColSpan] | [Empty, Row, Column]; export interface SpanLayout { readonly rowTopStart: Row; readonly rowTopEnd: Row; readonly rowCenterStart: Row; readonly rowCenterEnd: Row; readonly rowCenterLast: Row; readonly rowBotStart: Row; readonly rowBotEnd: Row; readonly colStartStart: Column; readonly colStartEnd: Column; readonly colCenterStart: Column; readonly colCenterEnd: Column; readonly colCenterLast: Column; readonly colEndStart: Column; readonly colEndEnd: Column; } export type SpanFn = (r: Row, c: Column) => number; export type RowPredicate = (r: Row) => boolean; export type ScrollIntoViewFn = (p: { row?: number; column?: number; behavior: "instant"; }) => void; export type RootCellFn = (r: number, c: number) => PositionGridCell | PositionFullWidthRow | null; export type ColumnPin = "start" | "end" | null; export type RowPin = "top" | "bottom" | null; export type ColumnGroupVisibility = "always" | "close" | "open"; export interface RowSelectNode { readonly id: string; children?: Map; selected?: boolean; } export interface RowSelectionLinked { readonly kind: "linked"; readonly selected: boolean; readonly children: Map; } export interface RowSelectionIsolated { readonly kind: "isolated"; readonly selected: boolean; readonly exceptions: Set; } export type RowSelectionState = RowSelectionIsolated | RowSelectionLinked; export interface RowSelectNodeWithParent { readonly id: string; parent: RowSelectNodeWithParent | RowSelectionLinkedWithParent; selected?: boolean; children?: Map; } export interface RowSelectionLinkedWithParent { readonly kind: "linked"; readonly selected: boolean; readonly children: Map; } export type RowSelectionStateWithParent = RowSelectionLinkedWithParent | RowSelectionIsolated; export interface ColumnAbstract { readonly id: string; readonly name?: string; readonly type?: "string" | "number" | "date" | "datetime" | ({} & string); readonly width?: number; readonly widthMax?: number; readonly widthMin?: number; readonly widthFlex?: number; readonly groupVisibility?: ColumnGroupVisibility; readonly groupPath?: string[]; readonly pin?: ColumnPin; readonly hide?: boolean; readonly resizable?: boolean; readonly movable?: boolean; } export interface RowAtom { readonly get: () => T; readonly useValue: () => T; } export interface RowSource { readonly useRowCount: () => number; readonly useTopCount: () => number; readonly useBottomCount: () => number; readonly useRows: () => { get: (i: number) => RowNode | null | undefined; size: number; }; readonly useMaxRowGroupDepth: () => number; readonly rowIndexToRowId: (index: number) => string | null | undefined; readonly rowIdToRowIndex: (id: string) => number | null | undefined; readonly rowByIndex: (row: number) => RowAtom | null>; readonly rowById: (id: string) => RowNode | null; readonly rowParents: (id: string) => string[]; readonly rowSiblings: (id: string) => string[]; readonly rowIsSelected: (id: string) => boolean; readonly rowChildren: (id: string) => string[]; readonly rowLeafs: (id: string) => string[]; readonly rowsBetween: (start: string, end: string) => string[]; readonly rowInvalidate: (row?: number) => void; readonly rowsSelected: () => { state: RowSelectionState; rows: RowNode[]; }; readonly rowSelectionState: () => RowSelectionState; readonly rowGroupExpansionChange: (deltaChanges: Record) => void; readonly useSelectionState: () => RowSelectionState; readonly onViewChange: (view: SpanLayout) => void; readonly onRowsUpdated: (rows: Map, T>) => void; readonly onRowsSelected: (params: { readonly selected: string[] | "all"; readonly deselect?: boolean; readonly mode: "single" | "multiple" | "none"; }) => void; } export type PathField = { kind: "path"; path: string; }; export type Field = string | number | PathField | ((params: { row: RowNode; }) => unknown); export type Dimension = { name?: string; field: Field; } | { id: string; field?: Field; }; export type DimensionSort = { dim: Dimension | SortFn; descending?: boolean; }; export type DimensionAgg = { dim: { id: string; field?: Field; }; fn: Aggregator | string; }; export type LeafIdFn = (d: T, index: number, section: "top" | "center" | "bottom") => string; export type GroupIdFn = (path: (string | null)[]) => string; export type SortFn = (left: RowNode, right: RowNode) => number; export type FilterFn = (node: RowLeaf) => boolean; export type GroupFn = (node: RowLeaf) => (string | null)[] | null; export type AggregationFn = (data: RowLeaf[]) => Record; export type Aggregator = (field: Field, data: RowLeaf[]) => unknown; export interface RowLeaf { readonly id: string; readonly loading?: boolean; readonly error?: unknown; readonly parentId?: string | null | undefined; readonly kind: "leaf"; readonly depth: number; readonly data: T; } export interface RowGroup { readonly id: string; readonly kind: "branch"; readonly key: string | null; readonly data: Record; readonly depth: number; readonly last: boolean; readonly expanded: boolean; readonly expandable: boolean; readonly loading?: boolean; readonly error?: unknown; readonly errorGroup?: unknown; readonly loadingGroup?: boolean; readonly parentId: null | string; } export interface RowAggregated { readonly id: string; readonly kind: "aggregated"; readonly data: Record; readonly depth: number; readonly loading?: boolean; readonly error?: unknown; } export type RowNode = RowLeaf | RowGroup | RowAggregated; export interface PositionDetailCell { readonly kind: "detail"; readonly rowIndex: number; readonly colIndex: number; } export interface PositionFloatingCell { readonly kind: "floating-cell"; readonly colIndex: number; } export interface PositionFullWidthRow { readonly kind: "full-width"; readonly rowIndex: number; readonly colIndex: number; } export interface PositionGridCell { readonly kind: "cell"; readonly rowIndex: number; readonly colIndex: number; readonly root: PositionGridCellRoot | null; } export interface PositionGridCellRoot { readonly colIndex: number; readonly rowIndex: number; readonly rowSpan: number; readonly colSpan: number; } export interface PositionHeaderCell { readonly kind: "header-cell"; readonly colIndex: number; } export interface PositionHeaderGroupCell { readonly kind: "header-group-cell"; readonly columnStartIndex: number; readonly columnEndIndex: number; readonly hierarchyRowIndex: number; readonly colIndex: number; } export type PositionUnion = PositionGridCell | PositionFloatingCell | PositionHeaderCell | PositionDetailCell | PositionFullWidthRow | PositionHeaderGroupCell; export interface GridSections { /** Total number of rows provided by the row source. */ readonly rowCount: number; /** Number of rows pinned to the top of the viewport. */ readonly topCount: number; /** Number of scrollable rows. Equals rowCount − topCount − bottomCount. */ readonly centerCount: number; /** Number of rows pinned to the bottom of the viewport. */ readonly bottomCount: number; /** Number of columns pinned to the start edge of the viewport. */ readonly startCount: number; /** Number of columns pinned to the end edge of the viewport. */ readonly endCount: number; /** Number of scrollable (unpinned) columns. */ readonly colCenterCount: number; /** Row index of the first scrollable row — where top-pinned rows end. */ readonly topCutoff: number; /** Row index of the first bottom-pinned row — where scrollable rows end. */ readonly bottomCutoff: number; /** Column index of the first scrollable column — where start-pinned columns end. */ readonly startCutoff: number; /** Column index of the first end-pinned column — where scrollable columns end. */ readonly endCutoff: number; /** The total header height in px */ readonly topRowOffset: number; /** * Pixel distance from the top of the viewport to the first scrollable row. * Includes the total header height plus the height of all top-pinned rows. */ readonly topOffset: number; /** Pixel height of the bottom-pinned row area. */ readonly bottomOffset: number; /** Pixel width of the start-pinned column area. */ readonly startOffset: number; /** Pixel width of the end-pinned column area. */ readonly endOffset: number; } export type PartialMandatory = { [k in keyof Required]: Required[k] | undefined; };