@novnox/grid 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +133 -0
- package/README.md +453 -2
- package/dist/nox-grid.iife.js +75 -0
- package/dist/nox-grid.min.js +74 -0
- package/dist/types/book.d.ts +74 -0
- package/dist/types/conditional.d.ts +79 -0
- package/dist/types/events.d.ts +129 -0
- package/dist/types/find.d.ts +37 -0
- package/dist/types/footer.d.ts +6 -0
- package/dist/types/format.d.ts +21 -0
- package/dist/types/formula/engine.d.ts +25 -0
- package/dist/types/formula/formula.d.ts +56 -0
- package/dist/types/formula/functions.d.ts +18 -0
- package/dist/types/formula/nodes.d.ts +71 -0
- package/dist/types/formula/parser.d.ts +6 -0
- package/dist/types/formula/values.d.ts +95 -0
- package/dist/types/formula/writer.d.ts +8 -0
- package/dist/types/grid.d.ts +573 -0
- package/dist/types/headerGroups.d.ts +23 -0
- package/dist/types/i18n.d.ts +66 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/license.d.ts +37 -0
- package/dist/types/model.d.ts +278 -0
- package/dist/types/outline.d.ts +41 -0
- package/dist/types/pageFind.d.ts +11 -0
- package/dist/types/print.d.ts +24 -0
- package/dist/types/refs.d.ts +95 -0
- package/dist/types/renderer.d.ts +48 -0
- package/dist/types/scheme.d.ts +28 -0
- package/dist/types/sheetData.d.ts +97 -0
- package/dist/types/styles.d.ts +2 -0
- package/dist/types/types.d.ts +254 -0
- package/dist/types/undo.d.ts +28 -0
- package/package.json +38 -4
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { NoxGrid, parseTsv } from './grid';
|
|
2
|
+
export { NoxGridBook } from './book';
|
|
3
|
+
export type { BookOptions, BookSheetOptions } from './book';
|
|
4
|
+
export type { GridLayout, HitInfo } from './grid';
|
|
5
|
+
export type { HeaderGroups, HeaderGroupCell } from './headerGroups';
|
|
6
|
+
export { Column, GridModel } from './model';
|
|
7
|
+
export type { ColumnFilter } from './model';
|
|
8
|
+
export { CellRef, RangeRef, ColumnCollection } from './refs';
|
|
9
|
+
export { ConditionalFormat, ConditionalFormatCollection } from './conditional';
|
|
10
|
+
export type { ConditionOperator, ConditionalFormatOptions, ConditionalLook, ConditionContext } from './conditional';
|
|
11
|
+
export { colorSchemes, colorSchemeNames } from './scheme';
|
|
12
|
+
export type { GridColors } from './scheme';
|
|
13
|
+
export { NoxFormula } from './formula/formula';
|
|
14
|
+
export { setLocale, getLocale } from './i18n';
|
|
15
|
+
export { setLicenseKey, getLicenseInfo, validateLicenseKey, LICENSE_URL } from './license';
|
|
16
|
+
export type { LicenseInfo, LicenseType } from './license';
|
|
17
|
+
export type { Locale } from './i18n';
|
|
18
|
+
export type { FindOptions } from './find';
|
|
19
|
+
export type { PrintOptions } from './print';
|
|
20
|
+
export { gridTableHtml, printDocumentHtml, printHtml } from './print';
|
|
21
|
+
export type { OutlineGroup, SubtotalFunction } from './outline';
|
|
22
|
+
export type { WorkbookData, SheetData, CellData, LoadSheetOptions, CsvOptions } from './sheetData';
|
|
23
|
+
export { cellValueOf } from './sheetData';
|
|
24
|
+
export { FormulaError, FormulaSyntaxError, RangeValue, toOADate, fromOADate } from './formula/values';
|
|
25
|
+
export type { FormulaSheet } from './formula/values';
|
|
26
|
+
export { columnName, cellName } from './formula/writer';
|
|
27
|
+
export { formatValue, formatNumber, formatDate, parseNumber, parseDate, compareValues } from './format';
|
|
28
|
+
export type { GridEventMap, GridEventName, ValueChangeSource } from './events';
|
|
29
|
+
export * from './types';
|
|
30
|
+
/** Package version. */
|
|
31
|
+
export declare const version = "1.0.0";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type LicenseType = 'none' | 'free1' | 'community' | 'commercial';
|
|
2
|
+
export interface LicenseInfo {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
type: LicenseType;
|
|
5
|
+
licensee?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
organization?: string;
|
|
8
|
+
maxMajor?: number;
|
|
9
|
+
issued?: string;
|
|
10
|
+
expires?: string;
|
|
11
|
+
domains: string[];
|
|
12
|
+
id?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
}
|
|
15
|
+
/** Major version of this product. */
|
|
16
|
+
export declare const PRODUCT_MAJOR = 1;
|
|
17
|
+
export declare const LICENSE_URL = "https://novnox.dev/license/";
|
|
18
|
+
/** Whether the host matches the domain list (*.example.com matches example.com and all its subdomains). */
|
|
19
|
+
export declare function domainMatches(host: string, domains: string[]): boolean;
|
|
20
|
+
/** Whether the host is a development address (no notice is drawn). */
|
|
21
|
+
export declare function isLocalHost(host: string): boolean;
|
|
22
|
+
/** Verifies a key (signature, product, version, period, domain). If host is given, the domain is checked too. */
|
|
23
|
+
export declare function validateLicenseKey(key: string, host?: string): Promise<LicenseInfo>;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the license key (for all grids). Verification runs asynchronously and grids are redrawn when it finishes.
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { setLicenseKey } from '@novnox/grid';
|
|
28
|
+
* setLicenseKey('NOX1....');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function setLicenseKey(key: string): Promise<LicenseInfo>;
|
|
32
|
+
/** Current license (null before verification). */
|
|
33
|
+
export declare function getLicenseInfo(): LicenseInfo | null;
|
|
34
|
+
/** Whether grids should draw the license notice. */
|
|
35
|
+
export declare function needsLicenseNotice(): boolean;
|
|
36
|
+
/** @internal Redraws once verification finishes. */
|
|
37
|
+
export declare function onLicenseChanged(fn: () => void): () => void;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { CellStyle, CellValue, ColumnKind, ColumnOptions, ComboItem, FooterFunction, HorizontalAlignment, MergeArea, MergeMode, SortOrder, SortSpec, VerticalAlignment } from './types';
|
|
2
|
+
import { UndoStack } from './undo';
|
|
3
|
+
import type { ValueChangeSource } from './events';
|
|
4
|
+
import type { NoxFormula } from './formula/formula';
|
|
5
|
+
import { type FormulaSheet } from './formula/values';
|
|
6
|
+
import { type OutlineGroup } from './outline';
|
|
7
|
+
/** Group path: "a|b" or ["a", "b"] → ["a", "b"] (empty parts removed). */
|
|
8
|
+
export declare function parseGroup(g: string | string[] | undefined): string[];
|
|
9
|
+
/** Column. */
|
|
10
|
+
export declare class Column {
|
|
11
|
+
/** Internal unique ID (key for cell data). */
|
|
12
|
+
readonly id: number;
|
|
13
|
+
name: string;
|
|
14
|
+
header: string;
|
|
15
|
+
field?: string;
|
|
16
|
+
kind: ColumnKind;
|
|
17
|
+
width: number;
|
|
18
|
+
minWidth: number;
|
|
19
|
+
visible: boolean;
|
|
20
|
+
readOnly: boolean;
|
|
21
|
+
sortable: boolean;
|
|
22
|
+
/** Custom sort comparison (see ColumnOptions.sortCompare). */
|
|
23
|
+
sortCompare?: (a: CellValue, b: CellValue, rowA: number, rowB: number) => number;
|
|
24
|
+
/** Value to sort by (see ColumnOptions.sortValue). */
|
|
25
|
+
sortValue?: (row: Record<string, unknown> | undefined, rowIndex: number) => CellValue;
|
|
26
|
+
/** Share of the spare width (see ColumnOptions.fillWeight). */
|
|
27
|
+
fillWeight: number;
|
|
28
|
+
/** Text for empty cells (see ColumnOptions.emptyText). */
|
|
29
|
+
emptyText?: string;
|
|
30
|
+
/** Clickable cells (see ColumnOptions.clickable). */
|
|
31
|
+
clickable: boolean | ((row: Record<string, unknown> | undefined, rowIndex: number) => boolean);
|
|
32
|
+
/** Header tooltip (see ColumnOptions.headerToolTip). */
|
|
33
|
+
headerToolTip?: string | ((col: number) => string | undefined);
|
|
34
|
+
/** Header check box (see ColumnOptions.headerCheckBox). */
|
|
35
|
+
headerCheckBox: boolean;
|
|
36
|
+
/** Tooltip (see ColumnOptions.toolTip). */
|
|
37
|
+
toolTip?: (row: Record<string, unknown> | undefined, rowIndex: number) => string | undefined;
|
|
38
|
+
resizable: boolean;
|
|
39
|
+
filterable: boolean;
|
|
40
|
+
format?: string;
|
|
41
|
+
align: HorizontalAlignment;
|
|
42
|
+
verticalAlignment: VerticalAlignment;
|
|
43
|
+
wrapText: boolean;
|
|
44
|
+
backColor?: string;
|
|
45
|
+
foreColor?: string;
|
|
46
|
+
bold: boolean;
|
|
47
|
+
mergeMode: MergeMode;
|
|
48
|
+
items: ComboItem[];
|
|
49
|
+
buttonText?: string;
|
|
50
|
+
images?: Record<string, string | HTMLImageElement>;
|
|
51
|
+
maximum?: number;
|
|
52
|
+
required: boolean;
|
|
53
|
+
minimum?: number;
|
|
54
|
+
maxLength?: number;
|
|
55
|
+
pattern?: string;
|
|
56
|
+
valueList?: CellValue[];
|
|
57
|
+
validationMessage?: string;
|
|
58
|
+
/** Group header levels from the top (multi-row headers). */
|
|
59
|
+
group: string[];
|
|
60
|
+
footer: FooterFunction;
|
|
61
|
+
footerText: string | ((ctx: {
|
|
62
|
+
visibleRowCount: number;
|
|
63
|
+
rowCount: number;
|
|
64
|
+
}) => string);
|
|
65
|
+
footerFormat?: string;
|
|
66
|
+
tag?: unknown;
|
|
67
|
+
/** @internal Applies new options to this column (keeps the current width when `o.width` is not given). */
|
|
68
|
+
update(o: ColumnOptions): void;
|
|
69
|
+
constructor(o?: ColumnOptions);
|
|
70
|
+
/** Default horizontal alignment (numbers and dates right; check boxes, buttons, and images centered). */
|
|
71
|
+
effectiveAlign(v: CellValue, style?: CellStyle): HorizontalAlignment;
|
|
72
|
+
/** Converts input text to a value of the column's kind. undefined if it cannot be converted. */
|
|
73
|
+
parse(text: string): CellValue;
|
|
74
|
+
/** Display text. */
|
|
75
|
+
text(v: CellValue, style?: CellStyle): string;
|
|
76
|
+
}
|
|
77
|
+
/** Cell data. */
|
|
78
|
+
export interface CellData {
|
|
79
|
+
v?: CellValue;
|
|
80
|
+
s?: CellStyle;
|
|
81
|
+
/** Formula. */
|
|
82
|
+
f?: NoxFormula;
|
|
83
|
+
}
|
|
84
|
+
/** Row data. */
|
|
85
|
+
export declare class RowData {
|
|
86
|
+
/** Row key set with setRowKey (unbound grids); it follows the row when rows are inserted, removed or sorted. */
|
|
87
|
+
key?: unknown;
|
|
88
|
+
cells?: Map<number, CellData>;
|
|
89
|
+
data?: Record<string, unknown>;
|
|
90
|
+
height?: number;
|
|
91
|
+
hidden?: boolean;
|
|
92
|
+
filtered?: boolean;
|
|
93
|
+
/** Group level (0 = not grouped). */
|
|
94
|
+
outline?: number;
|
|
95
|
+
/** First row of a group: bit flags of collapsed levels. */
|
|
96
|
+
collapsed?: number;
|
|
97
|
+
/** Hidden because it is inside a collapsed group (computed). */
|
|
98
|
+
outlineHidden?: boolean;
|
|
99
|
+
/** Subtotal row. */
|
|
100
|
+
subtotal?: boolean;
|
|
101
|
+
style?: CellStyle;
|
|
102
|
+
}
|
|
103
|
+
/** Visible order and positions along an axis (rows or columns). */
|
|
104
|
+
export declare class Axis {
|
|
105
|
+
private readonly count;
|
|
106
|
+
private readonly size;
|
|
107
|
+
private readonly visible;
|
|
108
|
+
private order;
|
|
109
|
+
private offsets;
|
|
110
|
+
private dirty;
|
|
111
|
+
constructor(count: () => number, size: (i: number) => number, visible: (i: number) => boolean);
|
|
112
|
+
invalidate(): void;
|
|
113
|
+
private ensure;
|
|
114
|
+
/** Number of visible items. */
|
|
115
|
+
get visibleCount(): number;
|
|
116
|
+
/** Visible index → actual index. */
|
|
117
|
+
physical(v: number): number;
|
|
118
|
+
/** Actual index → visible index (if hidden, the next visible index encoded as a negative: -(v+1)). */
|
|
119
|
+
visual(p: number): number;
|
|
120
|
+
/** Start position of visible index v. */
|
|
121
|
+
offset(v: number): number;
|
|
122
|
+
sizeAt(v: number): number;
|
|
123
|
+
get total(): number;
|
|
124
|
+
/** Position → visible index (clamped to the edges when out of range). */
|
|
125
|
+
indexAt(px: number): number;
|
|
126
|
+
/** Next visible actual index (moves `step` items, stops at the end). */
|
|
127
|
+
step(p: number, step: number): number;
|
|
128
|
+
}
|
|
129
|
+
/** Filter condition. */
|
|
130
|
+
export interface ColumnFilter {
|
|
131
|
+
/** Display text values to show. */
|
|
132
|
+
values?: Set<string>;
|
|
133
|
+
/** Custom predicate. */
|
|
134
|
+
predicate?: (value: CellValue, row: number) => boolean;
|
|
135
|
+
}
|
|
136
|
+
/** Grid data model (independent of rendering). */
|
|
137
|
+
export declare class GridModel {
|
|
138
|
+
columns: Column[];
|
|
139
|
+
rows: Array<RowData | undefined>;
|
|
140
|
+
merges: MergeArea[];
|
|
141
|
+
filters: Map<number, ColumnFilter>;
|
|
142
|
+
sortSpecs: Array<{
|
|
143
|
+
col: Column;
|
|
144
|
+
order: SortOrder;
|
|
145
|
+
}>;
|
|
146
|
+
defaultRowHeight: number;
|
|
147
|
+
/** @internal Bound objects in screen order (a copy: sorting reorders this, never the app's array). */
|
|
148
|
+
data: Record<string, unknown>[] | null;
|
|
149
|
+
/** The app's bound array. Sorting does not reorder it; inserted and removed rows are applied to it with the same objects. */
|
|
150
|
+
source: Record<string, unknown>[] | null;
|
|
151
|
+
readonly undo: UndoStack;
|
|
152
|
+
readonly rowAxis: Axis;
|
|
153
|
+
readonly colAxis: Axis;
|
|
154
|
+
/** Change notification (redraws the view). */
|
|
155
|
+
onChange: (kind: 'value' | 'layout' | 'style') => void;
|
|
156
|
+
/** Value change notification. */
|
|
157
|
+
onValueChanged: (row: number, col: number, oldValue: CellValue, newValue: CellValue | (() => CellValue), source: ValueChangeSource, recordedNested?: boolean) => void;
|
|
158
|
+
/** @internal Whether the change being made now happens inside a value-changed handler (set by the grid; kept in the undo record). */
|
|
159
|
+
isNestedChange: () => boolean;
|
|
160
|
+
/** @internal Extra width given to fillWeight columns (column id → px), set by the grid from its width. */
|
|
161
|
+
fillExtra: Map<number, number>;
|
|
162
|
+
/** @internal Why values are changing now (the grid sets it around user actions, undo and redo). */
|
|
163
|
+
valueSource: ValueChangeSource;
|
|
164
|
+
/** Name used to refer to this sheet in formulas (for cross-sheet references). */
|
|
165
|
+
sheetName: string | null;
|
|
166
|
+
/** Looks up another sheet (set by the workbook). */
|
|
167
|
+
resolveSheet: (name: string) => FormulaSheet | null;
|
|
168
|
+
/** Sheet that formulas read from. */
|
|
169
|
+
readonly formulaSheet: FormulaSheet;
|
|
170
|
+
/** Whether a formula has ever been set (skips scanning on structural changes). */
|
|
171
|
+
hasFormulas: boolean;
|
|
172
|
+
/** Whether row groups have ever been used. */
|
|
173
|
+
hasOutline: boolean;
|
|
174
|
+
/** Row groups (computed). */
|
|
175
|
+
outlineGroups: OutlineGroup[];
|
|
176
|
+
/** Deepest group level. */
|
|
177
|
+
outlineLevels: number;
|
|
178
|
+
constructor();
|
|
179
|
+
get rowCount(): number;
|
|
180
|
+
set rowCount(n: number);
|
|
181
|
+
layoutChanged(): void;
|
|
182
|
+
row(r: number, create: true): RowData;
|
|
183
|
+
row(r: number, create?: boolean): RowData | undefined;
|
|
184
|
+
/** @internal Bound data: the key field (GridOptions.rowKey). */
|
|
185
|
+
rowKeyField?: string;
|
|
186
|
+
/** Whether the cell is clickable (ColumnOptions.clickable, also as a function of the row). */
|
|
187
|
+
isClickable(r: number, c: number): boolean;
|
|
188
|
+
/** Key of a row: the rowKey field of the bound object, otherwise the key set with setRowKey. */
|
|
189
|
+
rowKeyOf(r: number): unknown;
|
|
190
|
+
/** @internal Bound data: makes the object for a new row (GridOptions.newRowData). */
|
|
191
|
+
newRowData?: () => Record<string, unknown>;
|
|
192
|
+
/** Inserts rows. */
|
|
193
|
+
insertRows(at: number, count: number, detached?: boolean): void;
|
|
194
|
+
/** Removes rows. */
|
|
195
|
+
removeRows(at: number, count: number): void;
|
|
196
|
+
private spliceRows;
|
|
197
|
+
private shiftMerges;
|
|
198
|
+
setRowHeight(r: number, h: number | undefined): void;
|
|
199
|
+
setRowHidden(r: number, hidden: boolean): void;
|
|
200
|
+
isRowVisible(r: number): boolean;
|
|
201
|
+
/** Rows left after filtering (not hidden or filtered out; subtotal rows not included, rows in collapsed groups included). */
|
|
202
|
+
visibleRows(): number[];
|
|
203
|
+
columnIndex(key: number | string | Column): number;
|
|
204
|
+
insertColumn(at: number, col: Column): void;
|
|
205
|
+
/** Updates formula references when column positions change. */
|
|
206
|
+
private remapFormulaColumns;
|
|
207
|
+
removeColumn(at: number): Column | undefined;
|
|
208
|
+
moveColumn(from: number, to: number): void;
|
|
209
|
+
private shiftMergeCols;
|
|
210
|
+
setColumnWidth(c: number, w: number): void;
|
|
211
|
+
getValue(r: number, c: number): CellValue;
|
|
212
|
+
/** Gets the cell's formula (undefined if none). */
|
|
213
|
+
formulaAt(r: number, c: number): NoxFormula | undefined;
|
|
214
|
+
/** Sets or clears a formula (recorded for undo). */
|
|
215
|
+
setFormula(r: number, c: number, f: NoxFormula | null): boolean;
|
|
216
|
+
/** Whether the reference points to this sheet. */
|
|
217
|
+
private selfTarget;
|
|
218
|
+
/** Cells that contain formulas. */
|
|
219
|
+
formulaCells(): Generator<{
|
|
220
|
+
row: number;
|
|
221
|
+
cell: CellData;
|
|
222
|
+
colId: number;
|
|
223
|
+
}>;
|
|
224
|
+
private snapshotFormulas;
|
|
225
|
+
private restoreFormulas;
|
|
226
|
+
/** Sets a value (recorded for undo). Returns true if it changed. */
|
|
227
|
+
setValue(r: number, c: number, v: CellValue): boolean;
|
|
228
|
+
private writeValue;
|
|
229
|
+
getCellStyle(r: number, c: number): CellStyle | undefined;
|
|
230
|
+
getRowStyle(r: number): CellStyle | undefined;
|
|
231
|
+
/** Partially updates a cell's style (undefined values clear the corresponding property). */
|
|
232
|
+
setCellStyle(r: number, c: number, patch: Partial<CellStyle> | null): void;
|
|
233
|
+
private replaceStyle;
|
|
234
|
+
/** Finds an explicit merge. */
|
|
235
|
+
mergeAt(r: number, c: number): MergeArea | undefined;
|
|
236
|
+
addMerge(m: MergeArea): void;
|
|
237
|
+
removeMerges(area: MergeArea): void;
|
|
238
|
+
private setMerges;
|
|
239
|
+
/**
|
|
240
|
+
* Vertical span of a same-value merge (column mergeMode). [start row, end row] (actual indexes, inclusive).
|
|
241
|
+
* Only visible rows are joined. limit is the maximum number of rows to scan up and down.
|
|
242
|
+
*/
|
|
243
|
+
valueMergeSpan(r: number, c: number, limit?: number): [number, number];
|
|
244
|
+
/** Sorts rows (reorders the actual rows and records undo). */
|
|
245
|
+
sort(specs: SortSpec[]): void;
|
|
246
|
+
/** Removes the sort and puts bound rows back in the order of the app's array (unbound rows keep their order). */
|
|
247
|
+
clearSort(restoreOrder?: boolean): void;
|
|
248
|
+
/** Reorders rows (perm[new position] = old position) as one undo step and sets the sort indicator. */
|
|
249
|
+
private reorder;
|
|
250
|
+
/** Removes the objects from the app's array; returns where they were (ascending) so undo can put them back. */
|
|
251
|
+
private sourceRemove;
|
|
252
|
+
/** Puts removed objects back at their old places in the app's array. */
|
|
253
|
+
private sourceRestore;
|
|
254
|
+
/** Inserts new objects into the app's array before `before` (the object that follows them on screen), or at the end. */
|
|
255
|
+
private sourceInsert;
|
|
256
|
+
/** Index of a screen row's object in the app's array (-1 if unbound or not found). */
|
|
257
|
+
sourceIndex(r: number): number;
|
|
258
|
+
/** perm[new position] = old position. */
|
|
259
|
+
private applyPermutation;
|
|
260
|
+
setFilter(c: number, f: ColumnFilter | null): void;
|
|
261
|
+
getFilter(c: number): ColumnFilter | undefined;
|
|
262
|
+
clearFilters(): void;
|
|
263
|
+
/** @internal Quick filter text (lower case) and its columns (null = every visible column). */
|
|
264
|
+
quickFilter: {
|
|
265
|
+
text: string;
|
|
266
|
+
cols: number[] | null;
|
|
267
|
+
} | null;
|
|
268
|
+
/** Whether any filter (column filters or the quick filter) is active. */
|
|
269
|
+
get hasFilters(): boolean;
|
|
270
|
+
/** Reapplies the filter (also called after values change). */
|
|
271
|
+
applyFilters(): void;
|
|
272
|
+
/** Distinct display text values in a column (for the filter list, sorted). */
|
|
273
|
+
distinctTexts(c: number, limit?: number): string[];
|
|
274
|
+
setData(data: Record<string, unknown>[] | null, keepSort?: boolean): void;
|
|
275
|
+
private setDataCore;
|
|
276
|
+
/** Validates a value. Returns null if valid, otherwise a message. */
|
|
277
|
+
validate(c: number, v: CellValue): string | null;
|
|
278
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GridModel } from './model';
|
|
2
|
+
export declare const MAX_OUTLINE = 7;
|
|
3
|
+
/** A single group (inclusive). */
|
|
4
|
+
export interface OutlineGroup {
|
|
5
|
+
level: number;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
/** Row where the [+]/[-] button is placed (the row below the group, else the row above, else -1). */
|
|
9
|
+
summary: number;
|
|
10
|
+
collapsed: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type SubtotalFunction = 'sum' | 'count' | 'average' | 'max' | 'min';
|
|
13
|
+
export interface SubtotalOptions {
|
|
14
|
+
/** Column to group by (a subtotal wherever its value changes). */
|
|
15
|
+
groupBy: number;
|
|
16
|
+
/** Columns to aggregate. */
|
|
17
|
+
columns: number[];
|
|
18
|
+
function?: SubtotalFunction;
|
|
19
|
+
/** Grand total at the bottom (default true). */
|
|
20
|
+
grandTotal?: boolean;
|
|
21
|
+
/** Style of subtotal rows. */
|
|
22
|
+
bold?: boolean;
|
|
23
|
+
backColor?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Recomputes groups and collapsed rows (called from layoutChanged). */
|
|
26
|
+
export declare function recomputeOutline(m: GridModel): void;
|
|
27
|
+
/** Raises (+1) or lowers (-1) the group level of a row range. Undoable. */
|
|
28
|
+
export declare function changeOutline(m: GridModel, r1: number, r2: number, delta: 1 | -1): void;
|
|
29
|
+
/** Group containing the row (deepest level if level is omitted; for a summary row, its group). */
|
|
30
|
+
export declare function groupAt(m: GridModel, row: number, level?: number): OutlineGroup | null;
|
|
31
|
+
/** Collapses or expands a group. */
|
|
32
|
+
export declare function setGroupCollapsed(m: GridModel, g: OutlineGroup, collapsed: boolean): void;
|
|
33
|
+
/** Shows only up to level n (1 = ungrouped rows only, outlineLevels + 1 = all). */
|
|
34
|
+
export declare function showOutlineLevel(m: GridModel, n: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* Inserts subtotals: adds a subtotal row (SUBTOTAL formula) below each point where the groupBy column value changes and groups the rows above it.
|
|
37
|
+
* Data must be sorted by the groupBy column. A single undo step.
|
|
38
|
+
*/
|
|
39
|
+
export declare function addSubtotals(m: GridModel, o: SubtotalOptions): number;
|
|
40
|
+
/** Removes subtotal rows and ungroups (a single undo step). */
|
|
41
|
+
export declare function removeSubtotals(m: GridModel): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface PageFindTarget {
|
|
2
|
+
/** The grid's root element (visibility and focus checks). */
|
|
3
|
+
readonly root: HTMLElement;
|
|
4
|
+
/** Whether find is allowed now (allowFind). */
|
|
5
|
+
readonly findAllowed: boolean;
|
|
6
|
+
/** Opens the grid's find dialog. */
|
|
7
|
+
openFind(): void;
|
|
8
|
+
}
|
|
9
|
+
/** Registers a grid for page-wide Ctrl+F. Returns the function that unregisters it. */
|
|
10
|
+
export declare function capturePageFind(t: PageFindTarget): () => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NoxGrid } from './grid';
|
|
2
|
+
export interface PrintOptions {
|
|
3
|
+
/** Title (top of the page). */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Selection only. */
|
|
6
|
+
selectionOnly?: boolean;
|
|
7
|
+
/** Landscape orientation. */
|
|
8
|
+
landscape?: boolean;
|
|
9
|
+
/** Margin (CSS, default 12mm). */
|
|
10
|
+
margin?: string;
|
|
11
|
+
/** Include column headers (default true). */
|
|
12
|
+
headers?: boolean;
|
|
13
|
+
/** Footer text at the bottom of the page (defaults to the date). */
|
|
14
|
+
footer?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Printable HTML table (one sheet). */
|
|
17
|
+
export declare function gridTableHtml(g: NoxGrid, o?: PrintOptions): string;
|
|
18
|
+
/** Full HTML of the print document (sections: title and table per sheet). */
|
|
19
|
+
export declare function printDocumentHtml(sections: Array<{
|
|
20
|
+
title?: string;
|
|
21
|
+
table: string;
|
|
22
|
+
}>, o?: PrintOptions): string;
|
|
23
|
+
/** Loads the document into a hidden frame and opens the print dialog. */
|
|
24
|
+
export declare function printHtml(html: string): Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { NoxGrid } from './grid';
|
|
2
|
+
import { Column } from './model';
|
|
3
|
+
import type { BorderLine, CellBorders, CellStyle, CellValue, ColumnOptions, HorizontalAlignment, VerticalAlignment } from './types';
|
|
4
|
+
/** Column collection. */
|
|
5
|
+
export declare class ColumnCollection {
|
|
6
|
+
private readonly grid;
|
|
7
|
+
constructor(grid: NoxGrid);
|
|
8
|
+
get count(): number;
|
|
9
|
+
/** Finds a column by index or name. */
|
|
10
|
+
get(key: number | string): Column | undefined;
|
|
11
|
+
indexOf(key: number | string | Column): number;
|
|
12
|
+
add(o?: ColumnOptions | Column): Column;
|
|
13
|
+
insert(at: number, o?: ColumnOptions | Column): Column;
|
|
14
|
+
remove(key: number | string | Column): void;
|
|
15
|
+
move(from: number | string, to: number): void;
|
|
16
|
+
clear(): void;
|
|
17
|
+
/** Applies column property changes to the view (width, visibility, etc.). */
|
|
18
|
+
refresh(): void;
|
|
19
|
+
/** Column width (undoable). */
|
|
20
|
+
setWidth(key: number | string, width: number): void;
|
|
21
|
+
/** Column visibility. */
|
|
22
|
+
setVisible(key: number | string, visible: boolean): void;
|
|
23
|
+
[Symbol.iterator](): Iterator<Column>;
|
|
24
|
+
toArray(): Column[];
|
|
25
|
+
}
|
|
26
|
+
/** Works with the styles and values of a range in bulk. Every setter is a single undo step. */
|
|
27
|
+
export declare class RangeRef {
|
|
28
|
+
protected readonly grid: NoxGrid;
|
|
29
|
+
readonly row: number;
|
|
30
|
+
readonly col: number;
|
|
31
|
+
readonly row2: number;
|
|
32
|
+
readonly col2: number;
|
|
33
|
+
constructor(grid: NoxGrid, row: number, col: number, row2: number, col2: number);
|
|
34
|
+
protected each(fn: (r: number, c: number) => void): void;
|
|
35
|
+
/** Applies a partial style. */
|
|
36
|
+
setStyle(patch: Partial<CellStyle>): this;
|
|
37
|
+
/** Clears styles. */
|
|
38
|
+
clearStyle(): this;
|
|
39
|
+
set value(v: CellValue);
|
|
40
|
+
set backColor(v: string | undefined);
|
|
41
|
+
set foreColor(v: string | undefined);
|
|
42
|
+
set bold(v: boolean | undefined);
|
|
43
|
+
set italic(v: boolean | undefined);
|
|
44
|
+
set underline(v: boolean | undefined);
|
|
45
|
+
set strikeout(v: boolean | undefined);
|
|
46
|
+
set fontSize(v: number | undefined);
|
|
47
|
+
set align(v: HorizontalAlignment | undefined);
|
|
48
|
+
set verticalAlignment(v: VerticalAlignment | undefined);
|
|
49
|
+
set wrapText(v: boolean | undefined);
|
|
50
|
+
set format(v: string | undefined);
|
|
51
|
+
set readOnly(v: boolean | undefined);
|
|
52
|
+
/** Sets the same border on every cell. */
|
|
53
|
+
set borders(v: CellBorders | undefined);
|
|
54
|
+
/** Sets the outer border of the range. */
|
|
55
|
+
setOutline(line?: BorderLine): this;
|
|
56
|
+
/** Merges the range. */
|
|
57
|
+
merge(): this;
|
|
58
|
+
unmerge(): this;
|
|
59
|
+
}
|
|
60
|
+
/** A single cell. */
|
|
61
|
+
export declare class CellRef extends RangeRef {
|
|
62
|
+
constructor(grid: NoxGrid, row: number, col: number);
|
|
63
|
+
private get style();
|
|
64
|
+
get value(): CellValue;
|
|
65
|
+
set value(v: CellValue);
|
|
66
|
+
get text(): string;
|
|
67
|
+
get backColor(): string | undefined;
|
|
68
|
+
set backColor(v: string | undefined);
|
|
69
|
+
get foreColor(): string | undefined;
|
|
70
|
+
set foreColor(v: string | undefined);
|
|
71
|
+
get bold(): boolean | undefined;
|
|
72
|
+
set bold(v: boolean | undefined);
|
|
73
|
+
get italic(): boolean | undefined;
|
|
74
|
+
set italic(v: boolean | undefined);
|
|
75
|
+
get underline(): boolean | undefined;
|
|
76
|
+
set underline(v: boolean | undefined);
|
|
77
|
+
get strikeout(): boolean | undefined;
|
|
78
|
+
set strikeout(v: boolean | undefined);
|
|
79
|
+
get fontSize(): number | undefined;
|
|
80
|
+
set fontSize(v: number | undefined);
|
|
81
|
+
get align(): HorizontalAlignment | undefined;
|
|
82
|
+
set align(v: HorizontalAlignment | undefined);
|
|
83
|
+
get verticalAlignment(): VerticalAlignment | undefined;
|
|
84
|
+
set verticalAlignment(v: VerticalAlignment | undefined);
|
|
85
|
+
get wrapText(): boolean | undefined;
|
|
86
|
+
set wrapText(v: boolean | undefined);
|
|
87
|
+
get format(): string | undefined;
|
|
88
|
+
set format(v: string | undefined);
|
|
89
|
+
get readOnly(): boolean;
|
|
90
|
+
set readOnly(v: boolean | undefined);
|
|
91
|
+
get borders(): CellBorders | undefined;
|
|
92
|
+
set borders(v: CellBorders | undefined);
|
|
93
|
+
/** Validation error (null if none). */
|
|
94
|
+
get validationError(): string | null;
|
|
95
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { NoxGrid } from './grid';
|
|
2
|
+
/** Custom-drawing (Canvas) renderer. */
|
|
3
|
+
export declare class Renderer {
|
|
4
|
+
private readonly g;
|
|
5
|
+
dpr: number;
|
|
6
|
+
private ctx;
|
|
7
|
+
private measureCache;
|
|
8
|
+
private images;
|
|
9
|
+
constructor(g: NoxGrid);
|
|
10
|
+
paint(): void;
|
|
11
|
+
/** Text in the middle of the body when no rows are shown (GridOptions.emptyMessage). */
|
|
12
|
+
private drawEmptyMessage;
|
|
13
|
+
private drawCells;
|
|
14
|
+
/** Draws a single cell. For merged cells, rect is the whole merge. */
|
|
15
|
+
private paintCell;
|
|
16
|
+
private font;
|
|
17
|
+
private drawText;
|
|
18
|
+
private wrapLines;
|
|
19
|
+
/** Text width (cached). */
|
|
20
|
+
measure(font: string, text: string): number;
|
|
21
|
+
private checkRect;
|
|
22
|
+
/** Whether the check box was clicked (a click anywhere in the cell counts). */
|
|
23
|
+
hitCheckBox(row: number, col: number, x: number, y: number): boolean;
|
|
24
|
+
private drawCheck;
|
|
25
|
+
private drawButton;
|
|
26
|
+
private drawImage;
|
|
27
|
+
private drawProgress;
|
|
28
|
+
private drawBorders;
|
|
29
|
+
/** Underline the next text (clickable cell under the mouse). */
|
|
30
|
+
private underlineNext;
|
|
31
|
+
private drawSelection;
|
|
32
|
+
private drawColumnHeaders;
|
|
33
|
+
private drawFooter;
|
|
34
|
+
private drawRowHeaders;
|
|
35
|
+
/** Row group lines and buttons (area to the left of the row header). */
|
|
36
|
+
private drawOutline;
|
|
37
|
+
private drawCorner;
|
|
38
|
+
/** Small notice at the bottom right when there is no license key (not drawn on development addresses). */
|
|
39
|
+
private drawLicenseNotice;
|
|
40
|
+
/** Maximum width of a column's contents. */
|
|
41
|
+
measureColumn(c: number): number;
|
|
42
|
+
private hline;
|
|
43
|
+
private vline;
|
|
44
|
+
}
|
|
45
|
+
/** Center x of the button for group level L. */
|
|
46
|
+
export declare function outlineX(level: number): number;
|
|
47
|
+
/** x position → group level (0 if none). */
|
|
48
|
+
export declare function outlineLevelAt(x: number): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ColorSchemeName } from './types';
|
|
2
|
+
/** Grid colors. */
|
|
3
|
+
export interface GridColors {
|
|
4
|
+
headerBack: string;
|
|
5
|
+
headerFore: string;
|
|
6
|
+
cellBack: string;
|
|
7
|
+
altBack: string;
|
|
8
|
+
gridLine: string;
|
|
9
|
+
selBack: string;
|
|
10
|
+
selFore: string;
|
|
11
|
+
accent: string;
|
|
12
|
+
readOnlyBack: string;
|
|
13
|
+
readOnlyFore: string;
|
|
14
|
+
/** Empty area outside the cells. */
|
|
15
|
+
back: string;
|
|
16
|
+
/** Default text color. */
|
|
17
|
+
fore: string;
|
|
18
|
+
/** Modern family: bold headers, horizontal lines only. */
|
|
19
|
+
modern: boolean;
|
|
20
|
+
/** Row under the mouse with hoverRow (default: a light tint of accent). */
|
|
21
|
+
hoverBack?: string;
|
|
22
|
+
/** Outline of the selection (default: accent). */
|
|
23
|
+
selBorder?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Color scheme table (same values as the desktop version). */
|
|
26
|
+
export declare const colorSchemes: Readonly<Record<ColorSchemeName, GridColors>>;
|
|
27
|
+
/** Color scheme names. */
|
|
28
|
+
export declare const colorSchemeNames: ColorSchemeName[];
|