UNPKG

@visualjs/grid

Version:
119 lines (118 loc) 5 kB
import { BaseColumnOptions, Boundary, CellPosition, ColumnOptions, ColumnsDef, Coordinate, GridOptions, GroupData, MenuItem, Pinned, RowData, Unsubscribe } from '../types'; import defaultRender from '../views'; import { Root, RootState } from '../grid/store'; import { Store as GridStore } from '../grid/store/grid'; import { Store as RowStore } from '../grid/store/row'; import { Store as CellStore } from '../grid/store/cell'; import { Store as ColumnStore } from '../grid/store/column'; import CellRange from '../selection/CellRange'; import { Observer, Handlers } from './Observer'; import Actions from './Actions'; import { EventsDef } from './Events'; export interface Stores { grid: GridStore; row: RowStore; cell: CellStore; column: ColumnStore; } export declare type Store = Root<Stores>; export declare type State = RootState<Stores>; export declare class Grid { protected container: HTMLElement; protected root: Store; protected observer: Observer<EventsDef, typeof Actions>; constructor(container: HTMLElement, props: GridOptions, render?: typeof defaultRender); getRoot(): Store; appendChild<T extends Node>(node: T): T; removeChild<T extends Node>(node: T): T; getRootElement(): HTMLElement; on<K extends keyof typeof Actions | keyof EventsDef, H extends Handlers<typeof Actions, EventsDef>>(event: K, handler: H[K]): Unsubscribe; trigger<K extends keyof EventsDef>(e: K, ...args: Parameters<EventsDef[K]>): boolean; /** * Internal */ getSelectBoundary(row: string, column: string): Boundary | undefined; getFillingBoundary(row: string, column: string): Boundary | undefined; getContextMenuItems(pos: CellPosition): MenuItem[]; getColumnMenuItems(column: string): MenuItem[]; getState(): State; store<K extends keyof Stores>(s: K): import("../grid/store").Stores<Stores>[K]; state<K extends keyof Stores>(s: K): RootState<Stores>[K]; /** * Actions for grid */ destroy(): Promise<void>; setLoading(loading: boolean): void; isLoading(): boolean; copySelection(): void; pasteFromClipboard(plainText?: boolean): void; /** * Actions for cell */ getCoordinate(row: string, col: string): Coordinate; getCellPosition(coord: Coordinate): CellPosition; getRawCellValue(row: string, column: string): any; getRawCellValueByCoord(coord: Coordinate): any; getCellValue(row: string, column: string): any; getCellValueByCoord(coord: Coordinate): any; setCellValue(row: string, column: string, value: any, force?: boolean): void; setCellValueByCoord(coord: Coordinate, value: any): void; stopEditing(): void; setEditing(pos?: CellPosition): void; selectCells(start: Coordinate, end: Coordinate): void; deselectAllCells(): void; getCoordLocatedRange(coord: Coordinate): CellRange | undefined; /** * Actions for column */ getColumnOptions(column: string, row?: string): ColumnOptions; getColumnOptionsByIndex(x: number, y?: number): ColumnOptions; getColumnByIndex(x: number): string; getPinnedLeftColumns(): string[]; getPinnedRightColumns(): string[]; getNoPinnedColumns(): string[]; setColumns(columns: ColumnsDef, defaultOptions?: BaseColumnOptions): void; setColumnName(field: string, name: string): void; setColumnPinned(field: string, pinned: Pinned): void; setColumnVisible(field: string, visible: boolean): void; setColumnWidth(field: string, params: { width?: number; flex?: number; }): void; setColumnHeight(height: number): void; getGroups(): GroupData[]; getGroupData(group: string): GroupData | undefined; setGroupCollapsed(group: string, collapsed: boolean): void; toggleGroupCollapsed(group: string): void; setGroupName(group: string, name: string): void; /** * Actions for row */ getRowIdByIndex(y: number): string; getRowIndex(id: string): number; getRowInternalIndex(id: string): number; getRowDataByIndex(y: number): RowData; getRowData(row: string): RowData; appendRows(rows: RowData[]): void; appendRowsBefore(index: number, rows: RowData[]): void; removeRows(rows: string[]): void; clearRows(): void; getSelectedRows(): string[]; selectRows(rows: string[]): void; appendSelectedRows(rows: string[]): void; takeSelectedRow(row: string): void; getRowIds(): string[]; getRowsBetween(start: number, end: number): string[]; getPinnedTopRows(): string[]; setPinnedTopRows(rows: string[]): void; appendPinnedTopRows(rows: string[]): void; getPinnedBottomRows(): string[]; setPinnedBottomRows(rows: string[]): void; appendPinnedBottomRows(rows: string[]): void; takePinnedRows(rows: string[]): void; isPinnedTop(row: string): boolean; isPinnedBottom(row: string): boolean; isPinnedRow(row: string): boolean; setRowBaseHeight(height: number): void; } export default Grid;