react-konva-grid
Version:
Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets
83 lines (82 loc) • 4.51 kB
TypeScript
import { ItemSizer, InstanceInterface, AreaProps, CellInterface, CellMetaData, SelectionArea } from "./Grid";
declare enum Align {
start = "start",
end = "end",
center = "center",
auto = "auto",
smart = "smart"
}
declare enum ItemType {
row = "row",
column = "column"
}
export interface IItemMetaData {
itemType: ItemType;
offset: number;
index: number;
rowCount: number;
columnCount: number;
rowHeight: ItemSizer;
columnWidth: ItemSizer;
instanceProps: InstanceInterface;
}
export declare const getRowStartIndexForOffset: ({ rowHeight, columnWidth, rowCount, columnCount, instanceProps, offset, }: Omit<IItemMetaData, "index" | "itemType">) => number;
interface IRowStopIndex extends Omit<IItemMetaData, "itemType" | "index" | "offset" | "columnCount"> {
startIndex: number;
containerHeight: number;
scrollTop: number;
}
export declare const getRowStopIndexForStartIndex: ({ startIndex, rowCount, rowHeight, columnWidth, scrollTop, containerHeight, instanceProps, }: IRowStopIndex) => number;
export declare const getColumnStartIndexForOffset: ({ rowHeight, columnWidth, rowCount, columnCount, instanceProps, offset, }: Omit<IItemMetaData, "index" | "itemType">) => number;
interface IColumnStopIndex extends Omit<IItemMetaData, "itemType" | "index" | "offset" | "rowCount"> {
startIndex: number;
containerWidth: number;
scrollLeft: number;
}
export declare const getColumnStopIndexForStartIndex: ({ startIndex, rowHeight, columnWidth, instanceProps, containerWidth, scrollLeft, columnCount, }: IColumnStopIndex) => number;
export declare const getBoundedCells: (area: AreaProps | null | undefined) => Set<unknown>;
export declare const itemKey: ({ rowIndex, columnIndex }: CellInterface) => string;
export declare const getRowOffset: ({ index, rowHeight, columnWidth, instanceProps, }: Omit<IGetItemMetadata, "itemType">) => number;
export declare const getColumnOffset: ({ index, rowHeight, columnWidth, instanceProps, }: Omit<IGetItemMetadata, "itemType">) => number;
export declare const getRowHeight: (index: number, instanceProps: InstanceInterface) => number;
export declare const getColumnWidth: (index: number, instanceProps: InstanceInterface) => number;
interface IGetItemMetadata extends Pick<IItemMetaData, "itemType" | "index" | "rowHeight" | "columnWidth" | "instanceProps"> {
}
export declare const getItemMetadata: ({ itemType, index, rowHeight, columnWidth, instanceProps, }: IGetItemMetadata) => CellMetaData;
export declare const getEstimatedTotalHeight: (rowCount: number, instanceProps: InstanceInterface) => number;
export declare const getEstimatedTotalWidth: (columnCount: number, instanceProps: InstanceInterface) => number;
export declare const cellIndentifier: (rowIndex: number, columnIndex: number) => string;
/**
* @desc Throttle fn
* @param func function
* @param limit Delay in milliseconds
*/
export declare function throttle(func: Function, limit: number): Function;
export declare function debounce<T extends Function>(cb: T, wait?: number): T;
export declare function rafThrottle(callback: Function): (e: any) => void;
export interface AlignmentProps extends Omit<IItemMetaData, "offset"> {
containerHeight: number;
containerWidth: number;
align?: Align;
scrollOffset: number;
scrollbarSize: number;
frozenOffset: number;
}
export declare const getOffsetForIndexAndAlignment: ({ itemType, containerHeight, containerWidth, rowHeight, columnWidth, columnCount, rowCount, index, align, scrollOffset, instanceProps, scrollbarSize, frozenOffset, }: AlignmentProps) => number;
export declare const getOffsetForColumnAndAlignment: (props: Omit<AlignmentProps, "itemType">) => number;
export declare const getOffsetForRowAndAlignment: (props: Omit<AlignmentProps, "itemType">) => number;
export declare type TimeoutID = {
id: number;
};
export declare function cancelTimeout(timeoutID: TimeoutID): void;
export declare function requestTimeout(callback: Function, delay: number): TimeoutID;
export declare const selectionFromActiveCell: (activeCell: CellInterface | null) => SelectionArea[];
export declare const prepareClipboardData: (rows: string[][]) => [string, string];
/**
* Cycles active cell within selecton bounds
* @param activeCellBounds
* @param selectionBounds
* @param direction
*/
export declare const findNextCellWithinBounds: (activeCellBounds: AreaProps, selectionBounds: AreaProps, direction?: string) => CellInterface | null;
export {};