/
common.d.ts
74 lines (62 loc) · 2.49 KB
/
common.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import numbro from 'numbro';
// These types represent default known values, but users can extend with their own, leading to the need for assertions.
// Using type arguments (ex `_GridSettings<CellValue, CellType, SourceData>`) would solve this and provide very strict
// type-checking, but adds a lot of noise for no benefit in the most common use cases.
/**
* A cell value, which can be anything to support custom cell data types, but by default is `string | number | boolean | undefined`.
*/
export type CellValue = any;
/**
* A cell change represented by `[row, column, prevValue, nextValue]`.
*/
export type CellChange = [number, string | number, CellValue, CellValue];
/**
* A row object, one of the two ways to supply data to the table, the alternative being an array of values.
* Row objects can have any data assigned to them, not just column data, and can define a `__children` array for nested rows.
*/
export interface RowObject {
[prop: string]: any;
}
/**
* An object containing possible options to use in SelectEditor.
*/
export interface SelectOptionsObject {
[prop: string]: string;
}
/**
* A single row of source data, which can be represented as an array of values, or an object with key/value pairs.
*/
export type SourceRowData = RowObject | CellValue[];
export interface SimpleCellCoords {
row: number;
col: number;
}
export interface RangeType {
startRow: number;
startCol: number;
endRow: number;
endCol: number;
}
/**
* The default sources for which the table triggers hooks.
*/
export type ChangeSource = 'auto' | 'edit' | 'loadData' | 'populateFromArray' | 'spliceCol' |
'spliceRow' | 'timeValidate' | 'dateValidate' | 'validateCells' |
'Autofill.fill' | 'ContextMenu.clearColumns' | 'ContextMenu.columnLeft' |
'ContextMenu.columnRight' | 'ContextMenu.removeColumn' |
'ContextMenu.removeRow' | 'ContextMenu.rowAbove' | 'ContextMenu.rowBelow' |
'CopyPaste.paste' | 'UndoRedo.redo' | 'UndoRedo.undo' | 'ColumnSummary.set' |
'ColumnSummary.reset';
export interface LabelOptions {
property?: string;
position?: 'before' | 'after';
value?: string | (() => string);
}
export interface NumericFormatOptions {
pattern: string | numbro.Format;
culture?: string;
}
export interface ColumnDataGetterSetterFunction {
(row: RowObject | CellValue[]): CellValue;
(row: RowObject | CellValue[], value: CellValue): void;
}