UNPKG

@visualjs/grid

Version:
140 lines (139 loc) 3.93 kB
import { CellRenderer, CellEditor, CellTransformer } from "./grid/cell"; import { JSXInternal } from "preact/src/jsx"; import Grid from "./grid"; export declare type Unsubscribe = () => void; export interface MenuItem { separator?: boolean; disabled?: boolean; name?: string; icon?: string; action?: () => void; subMenus?: MenuItem[]; } export interface GetColumnMenuItemsParams { column: string; grid: Grid; } export interface GetContextMenuItemsParams { row: string; column: string; grid: Grid; } export interface RowParams { row: string; grid: Grid; } export interface ColumnParams { column: string; grid: Grid; } export interface CellParams { row: string; column: string; grid: Grid; } export interface Styles { [key: string]: string; } export interface CellPosition { row: string; column: string; } export interface Coordinate { x: number; y: number; } export interface Boundary { left: boolean; right: boolean; top: boolean; bottom: boolean; } export interface RowData { id: string; [key: string]: any; } interface ICellRenderer { new (): CellRenderer<unknown>; } interface ICellEditor { new (): CellEditor<unknown>; } export declare type RowPinned = 'top' | 'bottom' | undefined; export declare type ColumnPinned = 'left' | 'right' | undefined; export declare type Pinned = ColumnPinned; export interface GroupData { id: string; headerName: string; columns: string[]; groups: string[]; collapsed?: boolean; collapsible?: boolean; } export interface ColumnSelectorParams { row: string; gird: Grid; } export interface OverridableColumnOptions { readonly?: boolean; sortable?: boolean; transformer?: CellTransformer; cellRender?: ICellRenderer; cellEditor?: ICellEditor; cellParams?: any; cellStyle?: JSXInternal.CSSProperties; getCellStyle?: (params: CellParams) => JSXInternal.CSSProperties; cellClass?: string[]; getCellClass?: (params: CellParams) => string[]; headerStyle?: JSXInternal.CSSProperties; getHeaderStyle?: (params: ColumnParams) => JSXInternal.CSSProperties; headerClass?: string[]; getHeaderClass?: (params: ColumnParams) => string[]; } export interface BaseColumnOptions extends OverridableColumnOptions { width?: number; minWidth?: number; flex?: number; resizable?: boolean; visible?: boolean; pinned?: Pinned; rowDragable?: boolean | ((param: CellParams) => boolean); columnOptionsSelector?: (params: ColumnSelectorParams) => OverridableColumnOptions; } export interface ColumnOptions extends BaseColumnOptions { field: string; headerName?: string; } export interface ColumnGroupOptions { id?: string; headerName?: string; isPadding?: boolean; collapsed?: boolean; collapsible?: boolean; children: (ColumnGroupOptions | ColumnOptions)[]; } export declare type ColumnDef = (ColumnGroupOptions | ColumnOptions); export declare type ColumnsDef = ColumnDef[]; export declare type Fillable = 'x' | 'y' | 'xy' | undefined; export interface GridOptions { width?: string; height?: string; columns: ColumnsDef; defaultColumnOption?: BaseColumnOptions; getColumnMenuItems?: (params: GetColumnMenuItemsParams) => MenuItem[] | undefined; rows: RowData[]; headerHeight?: number; rowHeight?: number | ((id: string) => number); minRowHeight?: number; rowResizable?: boolean | ((id: string) => boolean); rowStyle?: JSXInternal.CSSProperties; getRowStyle?: (params: RowParams) => JSXInternal.CSSProperties; rowClass?: string[]; getRowClass?: (params: RowParams) => string[]; overscanRowCount?: number; overscanColumnCount?: number; scrollThrottleRate?: number; fillable?: Fillable; getContextMenuItems?: (params: GetContextMenuItemsParams) => MenuItem[]; } export {};