@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.
@@ -0,0 +1,97 @@
1
+ import { type GridModel } from './model';
2
+ import type { CellStyle, CellValue } from './types';
3
+ export interface WorkbookData {
4
+ sheets: SheetData[];
5
+ activeSheet?: number;
6
+ }
7
+ export interface SheetData {
8
+ name?: string;
9
+ rowCount?: number;
10
+ columnCount?: number;
11
+ columns?: Array<{
12
+ index: number;
13
+ header?: string | null;
14
+ width?: number | null;
15
+ hidden?: boolean;
16
+ format?: string | null;
17
+ }>;
18
+ rows?: Array<{
19
+ index: number;
20
+ height?: number | null;
21
+ hidden?: boolean;
22
+ }>;
23
+ cells?: CellData[];
24
+ merges?: Array<{
25
+ row: number;
26
+ col: number;
27
+ rowSpan: number;
28
+ colSpan: number;
29
+ }>;
30
+ frozenRows?: number;
31
+ frozenColumns?: number;
32
+ autoFilter?: boolean;
33
+ /** Auto filter range (e.g. "A2:H61"). Empty: from A1 to the last cell. */
34
+ autoFilterRange?: string | null;
35
+ }
36
+ export interface CellData {
37
+ row: number;
38
+ col: number;
39
+ text?: string | null;
40
+ number?: number | null;
41
+ bool?: boolean | null;
42
+ /** ISO date text (e.g. "2026-03-01T00:00:00"). */
43
+ date?: string | null;
44
+ error?: string | null;
45
+ formula?: string | null;
46
+ style?: CellStyle | null;
47
+ }
48
+ /** Load options. */
49
+ export interface LoadSheetOptions {
50
+ /** Use the first row as column headers (default true). If false, A, B, C… */
51
+ headerRow?: boolean;
52
+ /** Infer column kinds (number, date, check) from the values (default true). */
53
+ detectKinds?: boolean;
54
+ }
55
+ export declare function cellValueOf(c: CellData): CellValue;
56
+ /** Fills the model from data (without recording undo). */
57
+ export declare function loadSheetIntoModel(model: GridModel, sheet: SheetData, o?: LoadSheetOptions): {
58
+ frozenRows: number;
59
+ frozenColumns: number;
60
+ autoFilter: boolean;
61
+ };
62
+ /** Footer row cell for sheet data: a formula (SUBTOTAL) or a value. */
63
+ export interface FooterCell {
64
+ formula?: string;
65
+ value?: CellValue;
66
+ }
67
+ /**
68
+ * Model → data. With headerRow, column headers go in the first row (plus one row per header group level)
69
+ * and formula references shift down. With footer, a summary row is added after the data.
70
+ */
71
+ export declare function sheetFromModel(model: GridModel, o?: {
72
+ headerRow?: boolean;
73
+ frozenRows?: number;
74
+ frozenColumns?: number;
75
+ autoFilter?: boolean;
76
+ footer?: Array<FooterCell | null>;
77
+ }): SheetData;
78
+ /** CSV export options. */
79
+ export interface CsvOptions {
80
+ /** Delimiter (default ','). */
81
+ delimiter?: string;
82
+ /**
83
+ * Raw values instead of the displayed text: numbers without formatting (1234.5), check boxes as true/false,
84
+ * dates as yyyy-MM-dd HH:mm:ss (yyyy-MM-dd without a time). Default false (as shown on screen, e.g. 1,234.5 and TRUE).
85
+ */
86
+ raw?: boolean;
87
+ /** Columns to export, by name, field or index, in this order. Default: every visible column. */
88
+ columns?: Array<string | number>;
89
+ /** Header row (default true). */
90
+ headers?: boolean;
91
+ /** Only rows that pass the filters (default true). False exports every row. */
92
+ visibleRowsOnly?: boolean;
93
+ /** Subtotal rows made by addSubtotals (default true). */
94
+ subtotals?: boolean;
95
+ }
96
+ /** Builds CSV from display text (visible rows and columns, header on the first line). */
97
+ export declare function csvFromModel(model: GridModel, options?: string | CsvOptions): string;
@@ -0,0 +1,2 @@
1
+ /** Injects the grid's default CSS into the document once. */
2
+ export declare function injectStyles(): void;
@@ -0,0 +1,254 @@
1
+ import type { FormulaError } from './formula/values';
2
+ /** Cell value (the computed result for formula cells; FormulaError on error). */
3
+ export type CellValue = string | number | boolean | Date | FormulaError | null | undefined;
4
+ /** Column kind (same concept as the desktop NoxColumnKind). */
5
+ export type ColumnKind = 'text' | 'number' | 'date' | 'check' | 'combo' | 'button' | 'label' | 'image' | 'progress';
6
+ export type HorizontalAlignment = 'general' | 'left' | 'center' | 'right';
7
+ export type VerticalAlignment = 'top' | 'middle' | 'bottom';
8
+ /** How cells with the same value are merged. */
9
+ export type MergeMode = 'none' | 'always' | 'restricted';
10
+ /** What the footer (summary) row shows for a column. */
11
+ export type FooterFunction = 'none' | 'sum' | 'avg' | 'count' | 'min' | 'max' | 'text';
12
+ export type SortOrder = 'asc' | 'desc';
13
+ /** One side of a border. */
14
+ export interface BorderLine {
15
+ color?: string;
16
+ width?: number;
17
+ }
18
+ /** Cell border. */
19
+ export interface CellBorders {
20
+ left?: BorderLine | null;
21
+ top?: BorderLine | null;
22
+ right?: BorderLine | null;
23
+ bottom?: BorderLine | null;
24
+ }
25
+ /** Cell style (unset properties inherit from the column, row, or grid). */
26
+ export interface CellStyle {
27
+ backColor?: string;
28
+ foreColor?: string;
29
+ bold?: boolean;
30
+ italic?: boolean;
31
+ underline?: boolean;
32
+ strikeout?: boolean;
33
+ fontSize?: number;
34
+ fontFamily?: string;
35
+ align?: HorizontalAlignment;
36
+ verticalAlignment?: VerticalAlignment;
37
+ wrapText?: boolean;
38
+ format?: string;
39
+ readOnly?: boolean;
40
+ borders?: CellBorders;
41
+ }
42
+ /** Combo box item. */
43
+ export interface ComboItem {
44
+ value: CellValue;
45
+ text: string;
46
+ }
47
+ /** Column options. */
48
+ export interface ColumnOptions {
49
+ /** Name used to look up the column in code. */
50
+ name?: string;
51
+ /** Header text. */
52
+ header?: string;
53
+ /** Field name in the bound data. */
54
+ field?: string;
55
+ kind?: ColumnKind;
56
+ width?: number;
57
+ minWidth?: number;
58
+ visible?: boolean;
59
+ readOnly?: boolean;
60
+ /** Header click sorts. Default true; false for 'check', 'combo', 'button', 'image' and 'progress' columns (same as the desktop grid and DataGridView). */
61
+ sortable?: boolean;
62
+ /**
63
+ * Compares two values of this column when sorting (like the desktop SortCompare). Return the ascending result
64
+ * (negative: a first); the grid reverses it for a descending sort, and 0 keeps the current order. Empty values are passed too.
65
+ * Without it, text compares in natural Korean order (2 before 10) and empty cells always go last.
66
+ */
67
+ sortCompare?: (a: CellValue, b: CellValue, rowA: number, rowB: number) => number;
68
+ /**
69
+ * The value to sort by instead of the cell value: receives the bound object of the row (undefined when unbound) and the row index.
70
+ * E.g. a status column shown as text but sorted by a number: `sortValue: (row) => row?.daysLeft`.
71
+ */
72
+ sortValue?: (row: Record<string, unknown> | undefined, rowIndex: number) => CellValue;
73
+ /**
74
+ * Share of the grid's spare width this column takes (like the desktop FillWeight). Columns with a fill weight grow so the
75
+ * columns fill the grid; `width` is then the minimum. 0 (default) keeps the column at its width.
76
+ */
77
+ fillWeight?: number;
78
+ /** Text shown in empty cells (e.g. '-'). Display only: values, sorting and CSV are not affected. */
79
+ emptyText?: string;
80
+ /**
81
+ * The cells react to clicks (your cellClick handler opens something): pointer cursor, and the text is underlined under the mouse.
82
+ * A function decides per row, e.g. `(row) => row?.sent === 'Y'`.
83
+ */
84
+ clickable?: boolean | ((row: Record<string, unknown> | undefined, rowIndex: number) => boolean);
85
+ /** Tooltip for the column header (e.g. a code behind the header text), or a function of the column index. Like the desktop column ToolTipText. */
86
+ headerToolTip?: string | ((col: number) => string | undefined);
87
+ /**
88
+ * Check columns: a check box in the header that checks or unchecks every shown row (filtered-out and subtotal rows are left
89
+ * as they are). It shows a mixed state when some rows are checked. Clicking the header toggles it (no sorting); raises
90
+ * headerCheckChanged. Like the desktop HeaderCheckBox.
91
+ */
92
+ headerCheckBox?: boolean;
93
+ /** Tooltip for the cells of this column (e.g. the address behind a link icon). Return '' or undefined for none. Shown on mouse hover. */
94
+ toolTip?: (row: Record<string, unknown> | undefined, rowIndex: number) => string | undefined;
95
+ resizable?: boolean;
96
+ filterable?: boolean;
97
+ /** Number or date format (e.g. "#,##0", "0.00%", "yyyy-MM-dd"). */
98
+ format?: string;
99
+ align?: HorizontalAlignment;
100
+ verticalAlignment?: VerticalAlignment;
101
+ wrapText?: boolean;
102
+ backColor?: string;
103
+ foreColor?: string;
104
+ bold?: boolean;
105
+ mergeMode?: MergeMode;
106
+ /** Combo box items. */
107
+ items?: Array<string | ComboItem>;
108
+ /** Button text (the cell value if omitted). */
109
+ buttonText?: string;
110
+ /** Image column: maps a value to an image URL or image. */
111
+ images?: Record<string, string | HTMLImageElement>;
112
+ /** Maximum value for a progress column (default 100). */
113
+ maximum?: number;
114
+ required?: boolean;
115
+ minimum?: number;
116
+ maxLength?: number;
117
+ /** Regular expression. */
118
+ pattern?: string;
119
+ /** Allowed values. */
120
+ valueList?: CellValue[];
121
+ validationMessage?: string;
122
+ /**
123
+ * Group header above the column header (multi-row headers). Adjacent columns with the same group share one merged cell.
124
+ * Levels from the top: `'2026 H1|January'` or `['2026 H1', 'January']`.
125
+ */
126
+ group?: string | string[];
127
+ /** What the footer row (grid `footerVisible`) shows for this column. */
128
+ footer?: FooterFunction;
129
+ /** Footer text when `footer` is `'text'` (e.g. "Total"). */
130
+ footerText?: string | ((ctx: {
131
+ visibleRowCount: number;
132
+ rowCount: number;
133
+ }) => string);
134
+ /** Format of the footer value (default: the column format; count uses "#,##0"). */
135
+ footerFormat?: string;
136
+ /** User-defined data. */
137
+ tag?: unknown;
138
+ }
139
+ /** Grid options. */
140
+ export interface GridOptions {
141
+ columns?: ColumnOptions[];
142
+ rowCount?: number;
143
+ /** Binds an array of objects (values are read and written via each column's field). */
144
+ data?: Record<string, unknown>[];
145
+ rowHeight?: number;
146
+ headerHeight?: number;
147
+ /** Shows the footer (summary) row fixed at the bottom (set `footer` on the columns). */
148
+ footerVisible?: boolean;
149
+ rowHeaderWidth?: number;
150
+ rowHeadersVisible?: boolean;
151
+ columnHeadersVisible?: boolean;
152
+ frozenRows?: number;
153
+ frozenColumns?: number;
154
+ /**
155
+ * The grid's height follows its rows (header, rows and footer), so the page scrolls instead of the grid.
156
+ * Use it for small tables such as order lines. The container then needs no fixed height. Default false.
157
+ */
158
+ autoHeight?: boolean;
159
+ /** With autoHeight: the grid grows up to this height (px) and scrolls inside beyond it. 0 = no limit. */
160
+ maxHeight?: number;
161
+ /** What clicking a header cycles through: 'ascDesc' (default) or 'ascDescNone' (the third click removes the sort and restores the bound array's order). */
162
+ sortCycle?: 'ascDesc' | 'ascDescNone';
163
+ /** 'cell' (default) selects cells; 'fullRow' selects whole rows (like the desktop FullRowSelect): clicks select the row, copying copies rows. */
164
+ selectionMode?: 'cell' | 'fullRow';
165
+ /** 'none': nothing is shown as selected until the user clicks a cell or row or uses the keyboard in the grid (for lists; clicking a header to sort does not show it). Default 'first' (the first cell). */
166
+ initialSelection?: 'first' | 'none';
167
+ /** Highlights the row under the mouse (color: setColors({ hoverBack })). Default false. */
168
+ hoverRow?: boolean;
169
+ /**
170
+ * Where Ctrl+F opens the grid's find dialog. 'grid' (default): when the grid has focus.
171
+ * 'page': anywhere on the page while this is the only grid on screen (the browser's own find cannot search a canvas).
172
+ * It takes Ctrl+F away from the browser, so it is off by default.
173
+ */
174
+ captureFind?: 'grid' | 'page';
175
+ /** Shows the whole text in a tooltip when the mouse is over a cell or column header whose text is cut off. Default false. */
176
+ showCellToolTips?: boolean;
177
+ /** Text drawn in the middle of the grid when no rows are shown (no data, or everything filtered out), e.g. 'No results'. */
178
+ emptyMessage?: string;
179
+ /**
180
+ * Selected cells keep the background set by the cell, row, column or a conditional format (and its text color); only cells
181
+ * without their own background use selBack. The selection is still outlined (color: setColors({ selBorder })). Default false.
182
+ */
183
+ selectionKeepsBackColors?: boolean;
184
+ /**
185
+ * Bound data: the field that identifies a row (like the desktop RowKeyMember). indexOfKey(key) finds the row.
186
+ * Unbound grids set keys with setRowKey(row, key).
187
+ */
188
+ rowKey?: string;
189
+ /**
190
+ * Pasting more lines than there are rows below adds rows at the end (same undo step; bound rows get newRowData()).
191
+ * Default false: the extra lines are dropped and the pasted event reports droppedRows.
192
+ */
193
+ pasteAddsRows?: boolean;
194
+ /** Bound data: the object for each new row (insertRows, pasteAddsRows), e.g. () => ({ qty: 1, kind: 'equipment' }). Default {}. */
195
+ newRowData?: () => Record<string, unknown>;
196
+ /** Selected cells use the selection text color instead of colors set on the cell, row, column or by conditional formats. Default false: those colors are kept on selected rows (like the desktop SelectionOverridesCellColors). */
197
+ selectionOverridesCellColors?: boolean;
198
+ /** Turns off every user change at once (typing, paste, Delete clearing, replace). Selecting, copying and find still work. */
199
+ readOnly?: boolean;
200
+ /** Color scheme. Also sets the default for vertical grid lines (off for modern schemes) unless verticalGridLines is set. */
201
+ colorScheme?: ColorSchemeName;
202
+ alternatingRows?: boolean;
203
+ /** Vertical lines between body cells. When set, changing colorScheme keeps it. */
204
+ verticalGridLines?: boolean;
205
+ horizontalGridLines?: boolean;
206
+ fontFamily?: string;
207
+ fontSize?: number;
208
+ allowSort?: boolean;
209
+ allowFilter?: boolean;
210
+ allowColumnResize?: boolean;
211
+ allowEdit?: boolean;
212
+ /** Show validation errors. */
213
+ showValidationErrors?: boolean;
214
+ /** Number of undo steps. */
215
+ undoLimit?: number;
216
+ /** Ctrl+Z / Ctrl+Y undo (default true). False for read-only lists and screens that stay open all day (no history is kept). */
217
+ allowUndo?: boolean;
218
+ /** Lets users type or paste formulas starting with =. */
219
+ allowUserFormulas?: boolean;
220
+ /** Find and replace via Ctrl+F, Ctrl+H, F3 (default true). */
221
+ allowFind?: boolean;
222
+ /** UI text language: 'en' (default) or 'ko' (applies to all grids). */
223
+ locale?: 'ko' | 'en';
224
+ /** Sheet name used to refer to this grid in formulas. */
225
+ sheetName?: string;
226
+ }
227
+ /** Color scheme name (same as the desktop NoxGridColorScheme). */
228
+ export type ColorSchemeName = 'default' | 'blue' | 'green' | 'gray' | 'orange' | 'classic' | 'dark' | 'modern' | 'teal' | 'purple' | 'rose' | 'midnight'
229
+ /** Nox signature: night navy, cyan selection (NovNox brand colors). */
230
+ | 'nox';
231
+ /** Cell position. */
232
+ export interface CellAddress {
233
+ row: number;
234
+ col: number;
235
+ }
236
+ /** Cell range (inclusive). */
237
+ export interface CellRange {
238
+ row: number;
239
+ col: number;
240
+ row2: number;
241
+ col2: number;
242
+ }
243
+ /** Merged area. */
244
+ export interface MergeArea {
245
+ row: number;
246
+ col: number;
247
+ rowSpan: number;
248
+ colSpan: number;
249
+ }
250
+ /** Sort condition. */
251
+ export interface SortSpec {
252
+ col: number;
253
+ order?: SortOrder;
254
+ }
@@ -0,0 +1,28 @@
1
+ /** Undo entry. */
2
+ export interface UndoEntry {
3
+ undo(): void;
4
+ redo(): void;
5
+ }
6
+ /** Undo history. Changes inside a transaction are undone together. */
7
+ export declare class UndoStack {
8
+ limit: number;
9
+ private done;
10
+ private undone;
11
+ private batch;
12
+ private depth;
13
+ /** Undoing in progress (changes made now are not recorded). */
14
+ replaying: boolean;
15
+ enabled: boolean;
16
+ constructor(limit?: number);
17
+ get canUndo(): boolean;
18
+ get canRedo(): boolean;
19
+ /** Whether recording is active. */
20
+ get recording(): boolean;
21
+ push(e: UndoEntry): void;
22
+ /** Groups multiple changes into one. */
23
+ transaction<T>(fn: () => T): T;
24
+ undo(): boolean;
25
+ redo(): boolean;
26
+ clear(): void;
27
+ private replay;
28
+ }
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@novnox/grid",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "NoxGrid Web Edition: a fast custom-drawn (Canvas) data grid and spreadsheet. Works with any framework: plain HTML, React, Vue, Angular, Blazor.",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "author": "Nox <novnox.dev@gmail.com> (https://novnox.dev)",
7
+ "homepage": "https://novnox.dev",
8
+ "bugs": {
9
+ "email": "novnox.dev@gmail.com"
10
+ },
11
+ "type": "module",
12
+ "main": "./dist/nox-grid.min.js",
13
+ "module": "./dist/nox-grid.min.js",
14
+ "types": "./dist/types/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/types/index.d.ts",
18
+ "import": "./dist/nox-grid.min.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist/nox-grid.min.js",
23
+ "dist/nox-grid.iife.js",
24
+ "dist/types/**/*.d.ts",
25
+ "LICENSE.txt",
26
+ "README.md"
27
+ ],
28
+ "sideEffects": false,
29
+ "keywords": [
30
+ "grid",
31
+ "datagrid",
32
+ "spreadsheet",
33
+ "canvas",
34
+ "nox"
35
+ ],
36
+ "scripts": {
37
+ "build": "node build.mjs",
38
+ "check": "tsc --noEmit"
39
+ }
40
+ }