UNPKG

9.61 kBTypeScriptView Raw
1import { IndexMapper } from './translations';
2import { Events } from './pluginHooks';
3import {
4 CellValue,
5 RowObject,
6 SimpleCellCoords,
7} from './common';
8import {
9 GridSettings,
10 CellMeta,
11 CellProperties,
12 ColumnSettings,
13} from './settings';
14import CellCoords from './3rdparty/walkontable/src/cell/coords';
15import CellRange from './3rdparty/walkontable/src/cell/range';
16import { BaseEditor } from './editors/baseEditor';
17import { BaseRenderer } from './renderers/base';
18import { BaseValidator } from './validators/base';
19import { Plugins } from './plugins';
20import { CellType } from './cellTypes';
21import { ShortcutManager } from './shortcuts';
22import { FocusManager } from './focusManager';
23
24type AlterActions = 'insert_row_above' | 'insert_row_below' |
25 'insert_col_start' | 'insert_col_end' |
26 'remove_row' | 'remove_col';
27
28export default class Core {
29 addHook<K extends keyof Events>(key: K, callback: Events[K] | Array<Events[K]>, orderIndex?: number): void;
30 addHookOnce<K extends keyof Events>(key: K, callback: Events[K] | Array<Events[K]>, orderIndex?: number): void;
31 alter(action: AlterActions, index?: number | Array<[number, number]>, amount?: number, source?: string, keepEmptyRows?: boolean): void;
32 batch<R>(wrappedOperations: () => R): R;
33 batchExecution<R>(wrappedOperations: () => R, forceFlushChanges: boolean): R;
34 batchRender<R>(wrappedOperations: () => R): R;
35 clear(): void;
36 clearUndo(): void;
37 colToProp(column: number): string | number;
38 columnIndexMapper: IndexMapper;
39 constructor(element: Element, options: GridSettings);
40 container: HTMLElement;
41 countCols(): number;
42 countEmptyCols(ending?: boolean): number;
43 countEmptyRows(ending?: boolean): number;
44 countRenderedCols(): number;
45 countRenderedRows(): number;
46 countRows(): number;
47 countSourceCols(): number;
48 countSourceRows(): number;
49 countVisibleCols(): number;
50 countVisibleRows(): number;
51 countRowHeaders(): number;
52 countColHeaders(): number;
53 deselectCell(): void;
54 destroy(): void;
55 destroyEditor(revertOriginal?: boolean, prepareEditorIfNeeded?: boolean): void;
56 emptySelectedCells(): void;
57 forceFullRender: boolean;
58 getActiveEditor(): BaseEditor | undefined;
59 getCell(row: number, column: number, topmost?: boolean): HTMLTableCellElement | null;
60 getCellEditor(cellMeta: CellMeta): BaseEditor;
61 getCellEditor(row: number, column: number): BaseEditor;
62 getCellMeta(row: number, column: number): CellProperties;
63 getCellMetaAtRow(row: number): CellProperties[];
64 getCellRenderer(cellMeta: CellMeta): BaseRenderer;
65 getCellRenderer(row: number, column: number): BaseRenderer;
66 getCellsMeta(): CellProperties[];
67 getCellValidator(cellMeta: CellMeta): BaseValidator | RegExp | undefined;
68 getCellValidator(row: number, column: number): BaseValidator | RegExp | undefined;
69 getColHeader(): Array<number | string>;
70 getColHeader(column: number, headerLevel?: number): number | string;
71 getColumnMeta(column: number): ColumnSettings;
72 getColWidth(column: number): number;
73 getCoords(element: Element | null): CellCoords;
74 getCopyableData(row: number, column: number): string;
75 getCopyableText(startRow: number, startColumn: number, endRow: number, endColumn: number): string;
76 getData(row?: number, column?: number, row2?: number, column2?: number): CellValue[];
77 getDataAtCell(row: number, column: number): CellValue;
78 getDataAtCol(column: number): CellValue[];
79 getDataAtProp(prop: string | number): CellValue[];
80 getDataAtRow(row: number): CellValue[];
81 getDataAtRowProp(row: number, prop: string): CellValue;
82 getDataType(rowFrom: number, columnFrom: number, rowTo: number, columnTo: number): CellType | 'mixed';
83 getDirectionFactor(): 1 | -1;
84 getFirstFullyVisibleColumn(): number | null;
85 getFirstFullyVisibleRow(): number | null;
86 getFirstPartiallyVisibleColumn(): number | null;
87 getFirstPartiallyVisibleRow(): number | null;
88 getFirstRenderedVisibleColumn(): number | null;
89 getFirstRenderedVisibleRow(): number | null;
90 getFocusManager(): FocusManager;
91 getInstance(): Core;
92 getLastFullyVisibleColumn(): number | null;
93 getLastFullyVisibleRow(): number | null;
94 getLastPartiallyVisibleColumn(): number | null;
95 getLastPartiallyVisibleRow(): number | null;
96 getLastRenderedVisibleColumn(): number | null;
97 getLastRenderedVisibleRow(): number | null;
98 getPlugin<T extends keyof Plugins>(pluginName: T): Plugins[T];
99 getPlugin(pluginName: string): Plugins['basePlugin'];
100 getRowHeader(): Array<string | number>;
101 getRowHeader(row: number): string | number;
102 getRowHeight(row: number): number;
103 getSchema(): RowObject;
104 getSelected(): Array<[number, number, number, number]> | undefined;
105 getSelectedLast(): number[] | undefined;
106 getSelectedRange(): CellRange[] | undefined;
107 getSelectedRangeLast(): CellRange | undefined;
108 getSettings(): GridSettings;
109 getShortcutManager(): ShortcutManager;
110 getSourceData(row?: number, column?: number, row2?: number, column2?: number): CellValue[][] | RowObject[];
111 getSourceDataArray(row?: number, column?: number, row2?: number, column2?: number): CellValue[][];
112 getSourceDataAtCell(row: number, column: number): CellValue;
113 getSourceDataAtCol(column: number): CellValue[];
114 getSourceDataAtRow(row: number): CellValue[] | RowObject;
115 getTranslatedPhrase(dictionaryKey: string, extraArguments: any): string | null;
116 getValue(): CellValue;
117 hasColHeaders(): boolean;
118 hasHook(key: keyof Events): boolean;
119 hasRowHeaders(): boolean;
120 init(): () => void;
121 isColumnModificationAllowed(): boolean;
122 isDestroyed: boolean;
123 isEmptyCol(column: number): boolean;
124 isEmptyRow(row: number): boolean;
125 isExecutionSuspended(): boolean;
126 isListening(): boolean;
127 isLtr(): boolean;
128 isRedoAvailable(): boolean;
129 isRenderSuspended(): boolean;
130 isRtl(): boolean;
131 isUndoAvailable(): boolean;
132 listen(): void;
133 loadData(data: CellValue[][] | RowObject[], source?: string): void;
134 populateFromArray(row: number, column: number, input: CellValue[][], endRow?: number,
135 endColumn?: number, source?: string, method?: 'shift_down' | 'shift_right' | 'overwrite'): void;
136 propToCol<T extends number | string>(prop: string | number): T;
137 redo(): void;
138 refreshDimensions(): void;
139 removeCellMeta(row: number, column: number, key: (keyof CellMeta) | string): void;
140 removeHook<K extends keyof Events>(key: K, callback: Events[K]): void;
141 render(): void;
142 renderCall: boolean;
143 resumeExecution(): void;
144 resumeRender(): void;
145 rootDocument: Document;
146 rootElement: HTMLElement;
147 rootWindow: Window;
148 rowIndexMapper: IndexMapper;
149 runHooks(key: keyof Events, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any, p6?: any): any;
150 scrollViewportTo(options: { row?: number, col?: number, verticalSnap?: 'top' | 'bottom', horizontalSnap?: 'start' | 'end', considerHiddenIndexes?: boolean }): boolean;
151 scrollViewportTo(row?: number, column?: number, snapToBottom?: boolean, snapToRight?: boolean, considerHiddenIndexes?: boolean): boolean;
152 scrollToFocusedCell(callback?: () => void): void;
153 selectAll(includeRowHeaders?: boolean, includeColumnHeaders?: boolean, options?: { focusPosition?: SimpleCellCoords | CellCoords, disableHeadersHighlight?: boolean }): void;
154 selectCell(row: number, column: number | string, endRow?: number, endColumn?: number | string, scrollToCell?: boolean, changeListener?: boolean): boolean;
155 selectCells(coords: Array<[number, number | string, number, number | string]> | CellRange[], scrollToCell?: boolean, changeListener?: boolean): boolean;
156 selectColumns(startColumn: number | string, endColumn?: number | string, focusPosition?: number | SimpleCellCoords | CellCoords): boolean;
157 selectRows(startRow: number, endRow?: number, focusPosition?: number | SimpleCellCoords | CellCoords): boolean;
158 setCellMeta(row: number, column: number, key: string, val: any): void;
159 setCellMeta<K extends keyof CellMeta>(row: number, column: number, key: K, val: CellMeta[K]): void;
160 setCellMetaObject(row: number, column: number, prop: CellMeta): void;
161 setDataAtCell(changes: Array<[number, number, CellValue]>, source?: string): void;
162 setDataAtCell(row: number, column: number, value: CellValue, source?: string): void;
163 setDataAtRowProp(changes: Array<[number, string | number, CellValue]>, source?: string): void;
164 setDataAtRowProp(row: number, prop: string, value: CellValue, source?: string): void;
165 setSourceDataAtCell(changes: Array<[number, string | number, CellValue]>, source?: string): void;
166 setSourceDataAtCell(row: number, column: number | string, value: CellValue, source?: string): void;
167 spliceCol(column: number, index: number, amount: number, ...elements: CellValue[]): void;
168 spliceRow(row: number, index: number, amount: number, ...elements: CellValue[]): void;
169 suspendExecution(): void;
170 suspendRender(): void;
171 table: HTMLTableElement;
172 toHTML(): string;
173 toPhysicalColumn(column: number): number;
174 toPhysicalRow(row: number): number;
175 toTableElement(): HTMLTableElement;
176 toVisualColumn(column: number): number;
177 toVisualRow(row: number): number;
178 undo(): void;
179 unlisten(): void;
180 updateData(data: CellValue[][] | RowObject[], source?: string): void;
181 updateSettings(settings: GridSettings, init?: boolean): void;
182 validateCell(value: any, cellProperties: CellProperties, callback: (valid: boolean) => void, source: string): void;
183 validateCells(callback?: (valid: boolean) => void): void;
184 validateColumns(columns: number[], callback?: (valid: boolean) => void): void;
185 validateRows(rows: number[], callback?: (valid: boolean) => void): void;
186}