UNPKG

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