UNPKG

react-konva-grid

Version:

Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets

84 lines (83 loc) 2.09 kB
import React from "react"; import { ViewPortProps, GridRef, CellInterface, ItemSizer } from "./../Grid"; export interface IProps { /** * Used to access grid functions */ gridRef: React.MutableRefObject<GridRef>; /** * Value getter for a cell */ getValue: (cell: CellInterface) => any; /** * Visible rows when the grid is first visible, Since we do not know how many rows can fit */ initialVisibleRows?: number; /** * Restrict column width by this number */ minColumnWidth?: number; /** * Cell padding, used for width calculation */ cellSpacing?: number; /** * Scroll timeout */ timeout?: number; /** * Calculate width and resize the grid on scroll */ resizeOnScroll?: boolean; /** * Font used to calculate width */ font?: string; /** * Strategy used to calculate column width * lazy = visible rows * full = all rows * * columns are always lazy */ resizeStrategy?: ResizeStrategy; /** * No of rows in teh grid */ rowCount?: number; /** * Enable autoresize */ autoResize?: boolean; } export declare enum ResizeStrategy { "lazy" = "lazy", "full" = "full" } export interface AutoResizerResults { /** * Column width function consumed by the grid */ columnWidth?: ItemSizer; /** * Callback when viewport is changed */ onViewChange: (cells: ViewPortProps) => void; /** * Resize a column by index */ resizeColumn: (columnIndex: number) => void; /** * Text size getter */ getTextMetrics: (text: string) => TextMetrics | undefined; } /** * Auto sizer hook * @param param * * TODO * Dynamically resize columns after user has scrolled down/view port changed ? */ declare const useAutoSizer: ({ gridRef, getValue, initialVisibleRows, cellSpacing, minColumnWidth, timeout, resizeStrategy, rowCount, resizeOnScroll, font, autoResize, }: IProps) => AutoResizerResults; export default useAutoSizer;