y11n-spreadsheet 1.0.0 → 1.0.2
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/README.md +2 -2
- package/dist/components/y11n-format-toolbar.d.ts +17 -4
- package/dist/components/y11n-format-toolbar.d.ts.map +1 -1
- package/dist/components/y11n-formula-bar.d.ts +10 -3
- package/dist/components/y11n-formula-bar.d.ts.map +1 -1
- package/dist/controllers/clipboard-manager.d.ts +42 -11
- package/dist/controllers/clipboard-manager.d.ts.map +1 -1
- package/dist/controllers/selection-manager.d.ts +35 -6
- package/dist/controllers/selection-manager.d.ts.map +1 -1
- package/dist/engine/formula-engine.d.ts +73 -10
- package/dist/engine/formula-engine.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2413 -2186
- package/dist/types.d.ts +103 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/y11n-spreadsheet.d.ts +99 -13
- package/dist/y11n-spreadsheet.d.ts.map +1 -1
- package/package.json +13 -14
package/dist/types.d.ts
CHANGED
|
@@ -1,117 +1,198 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* A zero-indexed cell coordinate.
|
|
3
|
+
* (0, 0) corresponds to cell A1.
|
|
4
4
|
*/
|
|
5
5
|
export interface CellCoord {
|
|
6
|
+
/** 0-indexed row number (0 = row 1) */
|
|
6
7
|
row: number;
|
|
8
|
+
/** 0-indexed column number (0 = column A) */
|
|
7
9
|
col: number;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
|
-
* Cell-level formatting options
|
|
12
|
+
* Cell-level formatting options.
|
|
13
|
+
* All properties are optional; only set properties are applied.
|
|
11
14
|
*/
|
|
12
15
|
export interface CellFormat {
|
|
16
|
+
/** Whether the cell text is bold */
|
|
13
17
|
bold?: boolean;
|
|
18
|
+
/** Whether the cell text is italic */
|
|
14
19
|
italic?: boolean;
|
|
20
|
+
/** Whether the cell text is underlined */
|
|
15
21
|
underline?: boolean;
|
|
22
|
+
/** Whether the cell text has a strikethrough */
|
|
16
23
|
strikethrough?: boolean;
|
|
24
|
+
/** CSS color string for text (e.g. "#ff0000", "red") */
|
|
17
25
|
textColor?: string;
|
|
26
|
+
/** CSS color string for cell background */
|
|
18
27
|
backgroundColor?: string;
|
|
28
|
+
/** Horizontal text alignment */
|
|
19
29
|
textAlign?: 'left' | 'center' | 'right';
|
|
30
|
+
/** Font size in pixels */
|
|
20
31
|
fontSize?: number;
|
|
32
|
+
/** Numeric display format (e.g. currency, percent) */
|
|
33
|
+
numberFormat?: NumberFormatOptions;
|
|
34
|
+
}
|
|
35
|
+
/** Available preset number format types */
|
|
36
|
+
export type NumberFormatType = 'number' | 'currency' | 'percent' | 'scientific';
|
|
37
|
+
/** Options for number formatting */
|
|
38
|
+
export interface NumberFormatOptions {
|
|
39
|
+
type: NumberFormatType;
|
|
40
|
+
/** Number of decimal places (default: 2) */
|
|
41
|
+
decimals?: number;
|
|
42
|
+
/** Currency symbol (default: '$'), only used when type is 'currency' */
|
|
43
|
+
currencySymbol?: string;
|
|
44
|
+
/** Whether to use thousands separators (default: true for 'number' and 'currency') */
|
|
45
|
+
thousandsSep?: boolean;
|
|
21
46
|
}
|
|
22
47
|
/**
|
|
23
|
-
* Data
|
|
48
|
+
* Data for a single cell in the grid.
|
|
24
49
|
*/
|
|
25
50
|
export interface CellData {
|
|
51
|
+
/** The raw user-entered value (may be a formula starting with "=") */
|
|
26
52
|
rawValue: string;
|
|
53
|
+
/** The computed display string shown in the cell */
|
|
27
54
|
displayValue: string;
|
|
55
|
+
/** The resolved data type after evaluation */
|
|
28
56
|
type: 'text' | 'number' | 'boolean' | 'error';
|
|
57
|
+
/** Optional visual formatting applied to the cell */
|
|
29
58
|
format?: CellFormat;
|
|
30
59
|
}
|
|
31
60
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
61
|
+
* Sparse data map for the entire grid.
|
|
62
|
+
* Keys use the format `"${row}:${col}"` (e.g. `"0:0"` for A1, `"2:3"` for D3).
|
|
63
|
+
* Only cells with content are stored; absent keys represent empty cells.
|
|
34
64
|
*/
|
|
35
65
|
export type GridData = Map<string, CellData>;
|
|
36
66
|
/**
|
|
37
|
-
*
|
|
67
|
+
* A normalized rectangular selection range.
|
|
68
|
+
* `start` is always the top-left corner; `end` is always the bottom-right.
|
|
38
69
|
*/
|
|
39
70
|
export interface SelectionRange {
|
|
71
|
+
/** Top-left corner of the selection (minimum row and column) */
|
|
40
72
|
start: CellCoord;
|
|
73
|
+
/** Bottom-right corner of the selection (maximum row and column) */
|
|
41
74
|
end: CellCoord;
|
|
42
75
|
}
|
|
43
76
|
/**
|
|
44
|
-
*
|
|
45
|
-
* Passed to custom functions to allow them to access the grid
|
|
77
|
+
* Context object passed to custom formula functions, providing access to grid data.
|
|
46
78
|
*/
|
|
47
79
|
export interface FormulaContext {
|
|
80
|
+
/** Retrieve the evaluated value of a single cell by reference (e.g. "A1"). */
|
|
48
81
|
getCellValue: (ref: string) => unknown;
|
|
82
|
+
/** Retrieve a flat array of values for a rectangular range (e.g. "A1", "B5"). */
|
|
49
83
|
getRangeValues: (start: string, end: string) => unknown[];
|
|
50
84
|
}
|
|
51
85
|
/**
|
|
52
|
-
*
|
|
86
|
+
* Signature for user-defined formula functions.
|
|
87
|
+
*
|
|
88
|
+
* @param ctx - Provides access to cell/range values from the grid.
|
|
89
|
+
* @param args - Variadic evaluated arguments passed to the function in the formula.
|
|
90
|
+
* @returns The computed result (number, string, boolean, or error string).
|
|
53
91
|
*/
|
|
54
92
|
export type FormulaFunction = (ctx: FormulaContext, ...args: unknown[]) => unknown;
|
|
55
93
|
/**
|
|
56
|
-
*
|
|
94
|
+
* Detail for the `cell-change` event, fired when a single cell is edited.
|
|
57
95
|
*/
|
|
58
96
|
export interface CellChangeDetail {
|
|
97
|
+
/** Cell key in `"row:col"` format */
|
|
59
98
|
cellId: string;
|
|
99
|
+
/** New raw value of the cell */
|
|
60
100
|
value: string;
|
|
101
|
+
/** Previous raw value of the cell */
|
|
61
102
|
oldValue: string;
|
|
62
103
|
}
|
|
63
104
|
/**
|
|
64
|
-
*
|
|
105
|
+
* Detail for the `selection-change` event, fired when the selected range changes.
|
|
65
106
|
*/
|
|
66
107
|
export interface SelectionChangeDetail {
|
|
108
|
+
/** The current normalized selection range */
|
|
67
109
|
range: SelectionRange;
|
|
68
110
|
}
|
|
69
111
|
/**
|
|
70
|
-
*
|
|
112
|
+
* Detail for the `data-change` event, fired on bulk updates (paste, cut, clear, undo/redo).
|
|
71
113
|
*/
|
|
72
114
|
export interface DataChangeDetail {
|
|
115
|
+
/** Array of cell updates, each with a cell key and new raw value */
|
|
73
116
|
updates: Array<{
|
|
74
117
|
id: string;
|
|
75
118
|
value: string;
|
|
76
119
|
}>;
|
|
120
|
+
/** What triggered the change */
|
|
77
121
|
source?: 'user' | 'undo' | 'redo' | 'programmatic';
|
|
122
|
+
/** The type of operation that caused the change */
|
|
78
123
|
operation?: 'edit' | 'cut' | 'paste' | 'clear' | 'format';
|
|
79
124
|
}
|
|
80
125
|
/**
|
|
81
|
-
*
|
|
126
|
+
* Detail for the `format-change` event, fired when cell formatting is modified.
|
|
82
127
|
*/
|
|
83
128
|
export interface FormatChangeDetail {
|
|
129
|
+
/** Cell keys that were affected */
|
|
84
130
|
cellIds: string[];
|
|
131
|
+
/** The format properties that were applied (empty object for clear) */
|
|
85
132
|
format: CellFormat;
|
|
133
|
+
/** What triggered the format change */
|
|
86
134
|
source: 'user' | 'undo' | 'redo' | 'programmatic';
|
|
87
135
|
}
|
|
88
136
|
/**
|
|
89
|
-
*
|
|
137
|
+
* Compare two CellFormat objects for deep equality (key-order independent).
|
|
138
|
+
* Deep-compares the `numberFormat` sub-object.
|
|
139
|
+
*
|
|
140
|
+
* @param a - First format (or undefined)
|
|
141
|
+
* @param b - Second format (or undefined)
|
|
142
|
+
* @returns `true` if both formats are structurally equal
|
|
90
143
|
*/
|
|
91
144
|
export declare function formatsEqual(a: CellFormat | undefined, b: CellFormat | undefined): boolean;
|
|
92
145
|
/**
|
|
93
|
-
*
|
|
146
|
+
* Format a numeric value according to the given number format options.
|
|
147
|
+
*
|
|
148
|
+
* @param value - The numeric value to format
|
|
149
|
+
* @param opts - Formatting options (type, decimals, currency symbol, thousands separator)
|
|
150
|
+
* @returns The formatted string representation
|
|
151
|
+
*/
|
|
152
|
+
export declare function formatNumber(value: number, opts: NumberFormatOptions): string;
|
|
153
|
+
/**
|
|
154
|
+
* Creates a cell key string from row and column indices.
|
|
155
|
+
*
|
|
156
|
+
* @param row - 0-indexed row number
|
|
157
|
+
* @param col - 0-indexed column number
|
|
158
|
+
* @returns A key in `"row:col"` format (e.g. `"0:0"`)
|
|
94
159
|
*/
|
|
95
160
|
export declare function cellKey(row: number, col: number): string;
|
|
96
161
|
/**
|
|
97
|
-
* Parse a cell key back to coordinates
|
|
162
|
+
* Parse a cell key string back to row/col coordinates.
|
|
163
|
+
*
|
|
164
|
+
* @param key - A key in `"row:col"` format (e.g. `"0:0"`)
|
|
165
|
+
* @returns The parsed coordinate
|
|
98
166
|
*/
|
|
99
167
|
export declare function parseKey(key: string): CellCoord;
|
|
100
168
|
/**
|
|
101
|
-
* Convert a column index
|
|
169
|
+
* Convert a 0-based column index to a column letter (A, B, ... Z, AA, AB...).
|
|
170
|
+
*
|
|
171
|
+
* @param col - 0-indexed column number
|
|
172
|
+
* @returns The column letter(s) (e.g. 0 -> "A", 25 -> "Z", 26 -> "AA")
|
|
102
173
|
*/
|
|
103
174
|
export declare function colToLetter(col: number): string;
|
|
104
175
|
/**
|
|
105
|
-
* Convert a column letter (A, B, ... Z, AA, AB...) to 0-based index
|
|
176
|
+
* Convert a column letter (A, B, ... Z, AA, AB...) to a 0-based index.
|
|
177
|
+
*
|
|
178
|
+
* @param letter - Column letter(s) (e.g. "A", "Z", "AA")
|
|
179
|
+
* @returns 0-indexed column number (e.g. "A" -> 0, "Z" -> 25, "AA" -> 26)
|
|
106
180
|
*/
|
|
107
181
|
export declare function letterToCol(letter: string): number;
|
|
108
182
|
/**
|
|
109
|
-
* Convert a cell reference
|
|
110
|
-
* Supports absolute/mixed references:
|
|
183
|
+
* Convert a cell reference string to a CellCoord.
|
|
184
|
+
* Supports absolute/mixed references: `$A$1`, `$A1`, `A$1`.
|
|
185
|
+
*
|
|
186
|
+
* @param ref - Cell reference (e.g. "A1", "$B$3")
|
|
187
|
+
* @returns The 0-indexed coordinate
|
|
188
|
+
* @throws {Error} If the reference format is invalid
|
|
111
189
|
*/
|
|
112
190
|
export declare function refToCoord(ref: string): CellCoord;
|
|
113
191
|
/**
|
|
114
|
-
* Convert a CellCoord to a cell reference like "A1"
|
|
192
|
+
* Convert a CellCoord to a cell reference string like "A1".
|
|
193
|
+
*
|
|
194
|
+
* @param coord - The 0-indexed coordinate
|
|
195
|
+
* @returns Cell reference string (e.g. `{row: 0, col: 0}` -> "A1")
|
|
115
196
|
*/
|
|
116
197
|
export declare function coordToRef(coord: CellCoord): string;
|
|
117
198
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,oCAAoC;IACpC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sCAAsC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC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AAG,SAAS,EAAE,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAY1F;AAWD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAqB7E;AAaD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAG/C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ/C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAOjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAEnD"}
|
|
@@ -2,20 +2,41 @@ import { LitElement } from 'lit';
|
|
|
2
2
|
import { type CellFormat, type GridData, type SelectionRange, type FormulaFunction } from './types.js';
|
|
3
3
|
import './components/y11n-formula-bar.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* `<y11n-spreadsheet>` -- An accessible spreadsheet web component.
|
|
6
6
|
*
|
|
7
|
-
* Implements the WAI-ARIA Grid pattern with
|
|
8
|
-
* keyboard navigation,
|
|
7
|
+
* Implements the WAI-ARIA Grid pattern with:
|
|
8
|
+
* - Roving tabindex and full keyboard navigation (arrows, Tab, Home/End, Ctrl+arrows)
|
|
9
|
+
* - Recursive-descent formula engine (`=SUM(A1:B5)`, `=IF(...)`, etc.)
|
|
10
|
+
* - Copy/cut/paste via the Clipboard API (HTML table + TSV formats)
|
|
11
|
+
* - Undo/redo command history (up to 100 entries)
|
|
12
|
+
* - Virtual rendering for large grids (only visible cells + buffer are in the DOM)
|
|
13
|
+
* - Cell formatting (bold, italic, colors, number formats, etc.)
|
|
14
|
+
*
|
|
15
|
+
* @fires cell-change - When a single cell value is edited
|
|
16
|
+
* @fires selection-change - When the selected range changes
|
|
17
|
+
* @fires data-change - On bulk updates (paste, cut, clear, undo/redo)
|
|
18
|
+
* @fires format-change - When cell formatting is modified
|
|
19
|
+
*
|
|
20
|
+
* @csspart editor - The inline cell editor input element
|
|
9
21
|
*/
|
|
10
22
|
export declare class Y11nSpreadsheet extends LitElement {
|
|
23
|
+
/** Number of rows in the grid. Default: 100 */
|
|
11
24
|
rows: number;
|
|
25
|
+
/** Number of columns in the grid. Default: 26 */
|
|
12
26
|
cols: number;
|
|
27
|
+
/** The sparse grid data map. Set externally or via `setData()`. */
|
|
13
28
|
data: GridData;
|
|
29
|
+
/** When true, all editing is disabled. Default: false */
|
|
14
30
|
readOnly: boolean;
|
|
31
|
+
/** Accessible label for the grid. Default: 'Spreadsheet' */
|
|
32
|
+
gridLabel: string;
|
|
33
|
+
/** Record of custom formula functions to register, keyed by name. */
|
|
15
34
|
functions: Record<string, FormulaFunction>;
|
|
16
35
|
private _isEditing;
|
|
17
36
|
private _editValue;
|
|
18
37
|
private _formulaBarMode;
|
|
38
|
+
/** When true, the next render should reposition the editor cursor (set on edit start / ref mode) */
|
|
39
|
+
private _editorNeedsCursorReset;
|
|
19
40
|
/** Whether arrow keys are currently selecting a cell reference in a formula */
|
|
20
41
|
private _refMode;
|
|
21
42
|
/** Screen reader announcement text for mode changes */
|
|
@@ -30,6 +51,7 @@ export declare class Y11nSpreadsheet extends LitElement {
|
|
|
30
51
|
private _clipboardManager;
|
|
31
52
|
/** Internal data store - we keep a separate mutable copy */
|
|
32
53
|
private _internalData;
|
|
54
|
+
private _lastSyncedDataRef;
|
|
33
55
|
/** Track which cell started editing for commit logic */
|
|
34
56
|
private _editingCellKey;
|
|
35
57
|
private _undoStack;
|
|
@@ -41,25 +63,73 @@ export declare class Y11nSpreadsheet extends LitElement {
|
|
|
41
63
|
/** Start/end positions of the reference text within the formula string */
|
|
42
64
|
private _refInsertStart;
|
|
43
65
|
private _refInsertEnd;
|
|
44
|
-
|
|
66
|
+
/** Whether an async paste operation is currently in progress */
|
|
67
|
+
private _pasteInProgress;
|
|
68
|
+
/** Number of cells to process per animation frame during large pastes */
|
|
69
|
+
private static readonly PASTE_CHUNK_SIZE;
|
|
70
|
+
private static readonly INITIAL_VIEW_ROWS;
|
|
71
|
+
private static readonly INITIAL_VIEW_COLS;
|
|
72
|
+
private static readonly ROW_HEADER_WIDTH;
|
|
45
73
|
willUpdate(changedProps: Map<string, unknown>): void;
|
|
46
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Returns a shallow copy of the current grid data.
|
|
76
|
+
*
|
|
77
|
+
* @returns A new Map containing all cell data
|
|
78
|
+
*/
|
|
47
79
|
getData(): GridData;
|
|
48
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Replaces the entire grid data and resets undo/redo history.
|
|
82
|
+
*
|
|
83
|
+
* @param data - The new sparse grid data map
|
|
84
|
+
*/
|
|
49
85
|
setData(data: GridData): void;
|
|
50
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Register a custom formula function at runtime.
|
|
88
|
+
* Triggers a full recalculation of all formulas.
|
|
89
|
+
*
|
|
90
|
+
* @param name - Function name (will be uppercased for lookup)
|
|
91
|
+
* @param fn - The function implementation
|
|
92
|
+
*/
|
|
51
93
|
registerFunction(name: string, fn: FormulaFunction): void;
|
|
52
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Returns the format for a cell, or undefined if unformatted.
|
|
96
|
+
*
|
|
97
|
+
* @param cellId - Cell key in `"row:col"` format
|
|
98
|
+
* @returns The cell's format, or undefined
|
|
99
|
+
*/
|
|
53
100
|
getCellFormat(cellId: string): CellFormat | undefined;
|
|
54
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Merges format properties into a cell. Creates the cell if it does not exist.
|
|
103
|
+
*
|
|
104
|
+
* @param cellId - Cell key in `"row:col"` format
|
|
105
|
+
* @param format - Format properties to merge
|
|
106
|
+
*/
|
|
55
107
|
setCellFormat(cellId: string, format: CellFormat): void;
|
|
56
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Applies format to all cells in a rectangular range.
|
|
110
|
+
*
|
|
111
|
+
* @param range - The selection range to format
|
|
112
|
+
* @param format - Format properties to apply
|
|
113
|
+
*/
|
|
57
114
|
setRangeFormat(range: SelectionRange, format: CellFormat): void;
|
|
58
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Removes all formatting from a single cell.
|
|
117
|
+
*
|
|
118
|
+
* @param cellId - Cell key in `"row:col"` format
|
|
119
|
+
*/
|
|
59
120
|
clearCellFormat(cellId: string): void;
|
|
60
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Removes all formatting from every cell in a range.
|
|
123
|
+
*
|
|
124
|
+
* @param range - The selection range to clear formatting from
|
|
125
|
+
*/
|
|
61
126
|
clearRangeFormat(range: SelectionRange): void;
|
|
62
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Toggles a boolean format property on the current selection.
|
|
129
|
+
* If all selected cells have the property set, it is removed; otherwise it is applied to all.
|
|
130
|
+
*
|
|
131
|
+
* @param prop - The boolean format property to toggle
|
|
132
|
+
*/
|
|
63
133
|
toggleFormat(prop: 'bold' | 'italic' | 'underline' | 'strikethrough'): void;
|
|
64
134
|
private _applyFormat;
|
|
65
135
|
private _clearFormat;
|
|
@@ -69,6 +139,12 @@ export declare class Y11nSpreadsheet extends LitElement {
|
|
|
69
139
|
private _syncData;
|
|
70
140
|
private _recalcAll;
|
|
71
141
|
private _recalcAffected;
|
|
142
|
+
/** Re-apply number formatting to all cells that have a numberFormat */
|
|
143
|
+
private _reapplyNumberFormats;
|
|
144
|
+
/** Re-apply number formatting only to the given set of cell keys */
|
|
145
|
+
private _applyNumberFormatsToKeys;
|
|
146
|
+
/** Apply number formatting to a single cell using rawValue for robustness */
|
|
147
|
+
private _applyNumberFormatToCell;
|
|
72
148
|
private _getCell;
|
|
73
149
|
private _getCellDisplay;
|
|
74
150
|
private _getCellRaw;
|
|
@@ -117,11 +193,18 @@ export declare class Y11nSpreadsheet extends LitElement {
|
|
|
117
193
|
private _focusActiveCell;
|
|
118
194
|
private _handleGridKeydown;
|
|
119
195
|
private _handleEditorKeydown;
|
|
196
|
+
private _handleSelectAll;
|
|
197
|
+
private _handleCornerKeydown;
|
|
120
198
|
private _handleCellPointerDown;
|
|
121
199
|
private _handleCellDblClick;
|
|
122
200
|
private _handleCopy;
|
|
123
201
|
private _handleCut;
|
|
124
202
|
private _handlePaste;
|
|
203
|
+
/**
|
|
204
|
+
* Apply a command batch progressively in chunks, yielding to the event loop
|
|
205
|
+
* between chunks via requestAnimationFrame to keep the UI responsive.
|
|
206
|
+
*/
|
|
207
|
+
private _applyBatchProgressive;
|
|
125
208
|
private _clearSelectedCells;
|
|
126
209
|
private _handleScroll;
|
|
127
210
|
private _handleEditorInput;
|
|
@@ -137,12 +220,15 @@ export declare class Y11nSpreadsheet extends LitElement {
|
|
|
137
220
|
* We add a buffer of extra rows/cols for smooth scrolling.
|
|
138
221
|
*/
|
|
139
222
|
private _getVisibleRange;
|
|
223
|
+
private _ensureCellVisible;
|
|
140
224
|
private _getCSSVarPx;
|
|
141
225
|
private _getEditorStyle;
|
|
142
226
|
static styles: import("lit").CSSResult;
|
|
143
227
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
228
|
+
private _renderColumnSpacer;
|
|
144
229
|
private _renderHeaderRow;
|
|
145
230
|
private _renderRows;
|
|
231
|
+
private _renderCell;
|
|
146
232
|
private _renderRow;
|
|
147
233
|
private _getAnnouncement;
|
|
148
234
|
protected updated(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"y11n-spreadsheet.d.ts","sourceRoot":"","sources":["../src/y11n-spreadsheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU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11n-spreadsheet",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Accessible spreadsheet web component built with Lit 3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -53,18 +53,17 @@
|
|
|
53
53
|
"lit": "^3.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"
|
|
57
|
-
"@playwright/test": "^1.
|
|
58
|
-
"@storybook/addon-
|
|
59
|
-
"@storybook/
|
|
60
|
-
"@storybook/
|
|
61
|
-
"@storybook/
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"vitest": "^4.0.18"
|
|
56
|
+
"@axe-core/playwright": "^4.14.0",
|
|
57
|
+
"@playwright/test": "^1.65.0",
|
|
58
|
+
"@storybook/addon-a11y": "^10.6.6",
|
|
59
|
+
"@storybook/addon-docs": "^10.6.6",
|
|
60
|
+
"@storybook/web-components": "^10.6.6",
|
|
61
|
+
"@storybook/web-components-vite": "^10.6.6",
|
|
62
|
+
"jsdom": "^31.0.0",
|
|
63
|
+
"lit": "^3.3.3",
|
|
64
|
+
"storybook": "^10.6.6",
|
|
65
|
+
"typescript": "^7.0.2",
|
|
66
|
+
"vite": "^8.3.6",
|
|
67
|
+
"vitest": "^5.1.0"
|
|
69
68
|
}
|
|
70
69
|
}
|