@guiexpert/table 1.1.84 → 1.1.86
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 +21 -0
- package/README.md +7 -1
- package/css/main.css +6 -6
- package/css/table-color-vars.css +6 -6
- package/index.cjs +30 -30
- package/index.js +906 -685
- package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +7 -0
- package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +7 -0
- package/lib/table/data/tablemodel/areamodel/area-model-tree.d.ts +7 -0
- package/lib/table/data/tablemodel/areamodel/area-model.d.ts +13 -4
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +16 -0
- package/lib/table/ele-scope.d.ts +7 -0
- package/lib/table/render-scope.d.ts +41 -0
- package/lib/table/resize-handler.d.ts +6 -0
- package/lib/table/table-api.d.ts +14 -0
- package/lib/table/table-scope.d.ts +27 -0
- package/package.json +14 -3
|
@@ -20,5 +20,12 @@ export declare class AreaModelArrayOfArrays<T> extends AbstractAreaModel<T[][]>
|
|
|
20
20
|
setValue(rowIndex: number, columnIndex: number, value: any): boolean;
|
|
21
21
|
getRowByIndex(rowIndex: number): any;
|
|
22
22
|
getRowHeight(_rowIndex: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* All rows share `defaultRowHeight` – unless a subclass overrides `getRowHeight()`, then row heights may
|
|
25
|
+
* vary and `undefined` is returned.
|
|
26
|
+
*
|
|
27
|
+
* @returns {number | undefined} The constant row height or `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
getConstantRowHeight(): number | undefined;
|
|
23
30
|
changeColumnOrder(sourceColumnIndex: number, targetColumnIndex: number): void;
|
|
24
31
|
}
|
|
@@ -381,6 +381,13 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
381
381
|
* console.log(`The first row has a height of ${rowHeight}px`);
|
|
382
382
|
*/
|
|
383
383
|
getRowHeight(_rowIndex: number): number;
|
|
384
|
+
/**
|
|
385
|
+
* All rows share `defaultRowHeight` – unless a subclass overrides `getRowHeight()`, then row heights may
|
|
386
|
+
* vary and `undefined` is returned.
|
|
387
|
+
*
|
|
388
|
+
* @returns {number | undefined} The constant row height or `undefined`.
|
|
389
|
+
*/
|
|
390
|
+
getConstantRowHeight(): number | undefined;
|
|
384
391
|
/**
|
|
385
392
|
* Returns the row object at the specified index from the filtered rows array.
|
|
386
393
|
* This method overrides the parent class implementation.
|
|
@@ -32,6 +32,13 @@ export declare class AreaModelTree<S> extends AbstractAreaModel<TreeRow<S>> {
|
|
|
32
32
|
getRowCount(): number;
|
|
33
33
|
getValueAt(rowIndex: number, columnIndex: number): any;
|
|
34
34
|
getRowHeight(_rowIndex: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* All rows share `defaultRowHeight` – unless a subclass overrides `getRowHeight()`, then row heights may
|
|
37
|
+
* vary and `undefined` is returned.
|
|
38
|
+
*
|
|
39
|
+
* @returns {number | undefined} The constant row height or `undefined`.
|
|
40
|
+
*/
|
|
41
|
+
getConstantRowHeight(): number | undefined;
|
|
35
42
|
getCustomClassesAt(rowIndex: number, _columnIndex: number): string[];
|
|
36
43
|
getRowByIndex(idx: number): TreeRowIf<S> | undefined;
|
|
37
44
|
getValueByT(t: S, property: string): any;
|
|
@@ -500,10 +500,11 @@ export declare class AreaModel implements AreaModelIf {
|
|
|
500
500
|
/**
|
|
501
501
|
* Returns the Y-coordinate (in pixels) of the top of the row at the specified index.
|
|
502
502
|
* This method is used for scrolling and positioning rows in the viewport.
|
|
503
|
-
* The base implementation
|
|
504
|
-
*
|
|
503
|
+
* The base implementation computes it from `getConstantRowHeight()` (O(1)) or by summing up
|
|
504
|
+
* `getRowHeight()` of all rows above (O(n)) – override it for large models with variable row heights.
|
|
505
|
+
* (Before 1.1.85 the base implementation returned 0.)
|
|
505
506
|
*
|
|
506
|
-
* @param {number}
|
|
507
|
+
* @param {number} rowIndex - The index of the row
|
|
507
508
|
* @returns {number} The Y-coordinate of the top of the row, in pixels
|
|
508
509
|
*
|
|
509
510
|
* @example
|
|
@@ -526,7 +527,15 @@ export declare class AreaModel implements AreaModelIf {
|
|
|
526
527
|
* // return yPos;
|
|
527
528
|
* }
|
|
528
529
|
*/
|
|
529
|
-
getYPosByRowIndex(
|
|
530
|
+
getYPosByRowIndex(rowIndex: number): number;
|
|
531
|
+
/**
|
|
532
|
+
* Returns the row height if all rows have the same height, otherwise `undefined` (default).
|
|
533
|
+
* Override it together with `getRowHeight()` if your rows have a constant height – this makes rendering
|
|
534
|
+
* of very large tables independent of the scroll position.
|
|
535
|
+
*
|
|
536
|
+
* @returns {number | undefined} `undefined` in the base implementation.
|
|
537
|
+
*/
|
|
538
|
+
getConstantRowHeight(): number | undefined;
|
|
530
539
|
/**
|
|
531
540
|
* Initializes the area model.
|
|
532
541
|
* This method is called internally by the TableModel during initialization.
|
|
@@ -565,6 +565,22 @@ export interface AreaModelIf {
|
|
|
565
565
|
* }
|
|
566
566
|
*/
|
|
567
567
|
getRowHeight(rowIndex: number): number;
|
|
568
|
+
/**
|
|
569
|
+
* Returns the row height if **all** rows of this area have the same height, otherwise `undefined`.
|
|
570
|
+
*
|
|
571
|
+
* The renderer uses this value to find the first visible row directly instead of summing up the heights
|
|
572
|
+
* of all rows above it – with millions of rows this keeps scrolling at the end of the table as fast as at
|
|
573
|
+
* the beginning. Only return a number if `getRowHeight(i)` returns exactly this value for every row.
|
|
574
|
+
* If the method is missing or returns `undefined`, the renderer falls back to iterating the row heights.
|
|
575
|
+
*
|
|
576
|
+
* @returns {number | undefined} The constant row height in pixels, or `undefined` if row heights may vary.
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* // Custom area model with 34px rows:
|
|
580
|
+
* getRowHeight(_rowIndex: number): number { return 34; }
|
|
581
|
+
* getConstantRowHeight(): number | undefined { return 34; }
|
|
582
|
+
*/
|
|
583
|
+
getConstantRowHeight?(): number | undefined;
|
|
568
584
|
/**
|
|
569
585
|
* Returns the row object at the specified index.
|
|
570
586
|
* This method provides access to the underlying data structure.
|
package/lib/table/ele-scope.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export declare class EleScope {
|
|
|
13
13
|
readonly tableModel: TableModelIf;
|
|
14
14
|
protected readonly dom: ConvenienceDomService;
|
|
15
15
|
readonly tableOptions: TableOptionsIf;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum height (px) of the scrollable content wrapper. Taller tables are scrolled proportionally
|
|
18
|
+
* (rendering is based on the scroll factor anyway): browsers clamp element heights (Chrome ~33.5 million px)
|
|
19
|
+
* and GPU rasterization loses precision long before (1px borders disappear and text jitters beyond
|
|
20
|
+
* ~16.7 million px). 8 million px keep sub-pixel precision.
|
|
21
|
+
*/
|
|
22
|
+
static maxScrollHeightInPx: number;
|
|
16
23
|
scrollViewport: HTMLDivElement;
|
|
17
24
|
protected contentWrapperDiv: HTMLDivElement;
|
|
18
25
|
protected contentDiv: HTMLDivElement;
|
|
@@ -47,6 +47,17 @@ export declare class RenderScope extends EleScope {
|
|
|
47
47
|
protected colAndRowspanModels: AreaObjectMapType<ColAndRowspanModel>;
|
|
48
48
|
protected draggingTargetColumnIndex: number;
|
|
49
49
|
protected mouseEvent?: GeMouseEvent;
|
|
50
|
+
/** Content pixels scrolled out at the top, i.e. the offset that is actually rendered (see adjustBody). */
|
|
51
|
+
protected contentScrollTop: number;
|
|
52
|
+
/** Exact content position requested by scrollToPixel() for a capped scroll height (see TableScope). */
|
|
53
|
+
protected pendingContentScroll?: {
|
|
54
|
+
scrollTop: number;
|
|
55
|
+
contentTop: number;
|
|
56
|
+
};
|
|
57
|
+
/** Area heights read once at the start of adjustAfterScrolling() (before the DOM is modified). */
|
|
58
|
+
protected areaHeightsOfRenderPass?: {
|
|
59
|
+
[key in AreaIdent]?: number;
|
|
60
|
+
};
|
|
50
61
|
private debounceTimeout?;
|
|
51
62
|
private editorRenderer?;
|
|
52
63
|
private editorRendererColumn?;
|
|
@@ -160,6 +171,31 @@ export declare class RenderScope extends EleScope {
|
|
|
160
171
|
* @protected
|
|
161
172
|
* @return {void}
|
|
162
173
|
*/
|
|
174
|
+
/**
|
|
175
|
+
* Rounds a pixel offset to whole device pixels. The scroll offsets are derived from a scroll factor and are
|
|
176
|
+
* fractional; rows and cells placed at fractional positions render blurry text and 1px borders.
|
|
177
|
+
*
|
|
178
|
+
* @param {number} px - offset in CSS pixels
|
|
179
|
+
* @returns {number} offset snapped to the device pixel grid
|
|
180
|
+
* @protected
|
|
181
|
+
*/
|
|
182
|
+
protected snapToDevicePixel(px: number): number;
|
|
183
|
+
/**
|
|
184
|
+
* True if the table content is taller than {@link EleScope.maxScrollHeightInPx}; then the scroll bar is
|
|
185
|
+
* scaled and scrollTop is no longer a content pixel position.
|
|
186
|
+
*/
|
|
187
|
+
isScrollHeightCapped(): boolean;
|
|
188
|
+
/** Scrollable range of the content in content pixels (content height minus visible body height). */
|
|
189
|
+
protected getContentScrollRangeY(): number;
|
|
190
|
+
/** Scrollable range of the scroll viewport in scroll bar pixels. */
|
|
191
|
+
protected getScrollerRangeY(): number;
|
|
192
|
+
/**
|
|
193
|
+
* Mouse wheel on a capped scroll height: scale the wheel delta, so one wheel step still moves the content
|
|
194
|
+
* by the usual amount of pixels (otherwise it would jump many rows). No-op for normal tables.
|
|
195
|
+
*
|
|
196
|
+
* @param {WheelEvent} evt - the wheel event of the scroll viewport
|
|
197
|
+
*/
|
|
198
|
+
onWheel(evt: WheelEvent): void;
|
|
163
199
|
protected adjustBody(): void;
|
|
164
200
|
/**
|
|
165
201
|
* Returns a number value extracted from the specified attribute of the source element.
|
|
@@ -299,6 +335,11 @@ export declare class RenderScope extends EleScope {
|
|
|
299
335
|
*
|
|
300
336
|
* @return {undefined}
|
|
301
337
|
*/
|
|
338
|
+
/**
|
|
339
|
+
* Cancels a pending debounced rendering and calls all renderer cleanup functions
|
|
340
|
+
* (e.g. unmounts framework components rendered into cells). Used by {@link TableScope.destroy}.
|
|
341
|
+
*/
|
|
342
|
+
protected disposeRendering(): void;
|
|
302
343
|
protected debounce(fn: () => void, delay?: number): void;
|
|
303
344
|
/**
|
|
304
345
|
* Adjusts the dragging column during a mouse move event.
|
|
@@ -8,6 +8,12 @@ import { TableScope } from './table-scope';
|
|
|
8
8
|
export declare class ResizeHandler {
|
|
9
9
|
protected tableScope: TableScope;
|
|
10
10
|
protected debounceDelay: number;
|
|
11
|
+
private readonly resizeObserver;
|
|
12
|
+
private disconnected;
|
|
11
13
|
constructor(tableScope: TableScope, debounceDelay?: number);
|
|
14
|
+
/**
|
|
15
|
+
* Stops observing the host element. Called by {@link TableScope.destroy}.
|
|
16
|
+
*/
|
|
17
|
+
disconnect(): void;
|
|
12
18
|
private handleResize;
|
|
13
19
|
}
|
package/lib/table/table-api.d.ts
CHANGED
|
@@ -718,6 +718,20 @@ export declare class TableApi {
|
|
|
718
718
|
* @returns {void}
|
|
719
719
|
*/
|
|
720
720
|
repaint(): void;
|
|
721
|
+
/**
|
|
722
|
+
* Releases the table: removes all DOM listeners (incl. the window resize listener), stops the
|
|
723
|
+
* resize observer, calls the cleanup functions of all cell renderers and clears the host element.
|
|
724
|
+
* The framework wrappers call it automatically when they are unmounted or receive a new table model.
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* // Plain TS: replace the table with a new model
|
|
728
|
+
* tableApi.destroy();
|
|
729
|
+
* const scope = new TableScope(hostDiv, newModel, new SimpleDomService(), new TableOptions(), new EventAdapter());
|
|
730
|
+
* scope.firstInit();
|
|
731
|
+
*
|
|
732
|
+
* @returns {void}
|
|
733
|
+
*/
|
|
734
|
+
destroy(): void;
|
|
721
735
|
/**
|
|
722
736
|
* Performs a complete repaint of the table by triggering a hard repaint on the underlying table scope.
|
|
723
737
|
*
|
|
@@ -57,6 +57,12 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
57
57
|
readonly copyService: CopyServiceIf;
|
|
58
58
|
readonly excelService: ExcelServiceIf;
|
|
59
59
|
licenseManager: LicenseManager;
|
|
60
|
+
/**
|
|
61
|
+
* Signal for all DOM listeners of this table (host element, scroll viewport, window).
|
|
62
|
+
* {@link destroy} aborts it, which removes every listener at once.
|
|
63
|
+
*/
|
|
64
|
+
readonly listenerAbortController: AbortController;
|
|
65
|
+
private destroyed;
|
|
60
66
|
mouseHandler: MouseHandler;
|
|
61
67
|
inputHandler: InputHandler;
|
|
62
68
|
resizeHandler: ResizeHandler;
|
|
@@ -113,6 +119,27 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
113
119
|
* @returns {TableScope} This instance of the table scope.
|
|
114
120
|
*/
|
|
115
121
|
firstInit(): TableScope;
|
|
122
|
+
/**
|
|
123
|
+
* Releases the table: removes all DOM listeners (host element, scroll viewport, window resize),
|
|
124
|
+
* stops the resize observer, unregisters from the selection and focus model, calls the cleanup
|
|
125
|
+
* functions of all cell renderers and clears the host element.
|
|
126
|
+
*
|
|
127
|
+
* Call it before you create a new `TableScope` for the same host element (e.g. when a framework
|
|
128
|
+
* wrapper receives a new table model) or when the table is removed from the page.
|
|
129
|
+
* Calling it twice is harmless.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* const scope = new TableScope(hostDiv, tableModel, new SimpleDomService(), new TableOptions(), new EventAdapter());
|
|
133
|
+
* scope.firstInit();
|
|
134
|
+
* // later, e.g. when a new model arrives:
|
|
135
|
+
* scope.destroy();
|
|
136
|
+
* new TableScope(hostDiv, newTableModel, new SimpleDomService(), new TableOptions(), new EventAdapter()).firstInit();
|
|
137
|
+
*/
|
|
138
|
+
destroy(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Returns `true` once {@link destroy} has been called.
|
|
141
|
+
*/
|
|
142
|
+
isDestroyed(): boolean;
|
|
116
143
|
/**
|
|
117
144
|
* Creates a GeMouseEvent object based on a MouseEvent.
|
|
118
145
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/table",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.86",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Dr. Marc Kronberg <info@gui.expert> (https://gui.expert)",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/guiexperttable/mono.git",
|
|
9
|
+
"directory": "packages/table"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://gui.expert",
|
|
4
12
|
"private": false,
|
|
5
13
|
"type": "module",
|
|
6
14
|
"main": "./index.js",
|
|
@@ -17,7 +25,9 @@
|
|
|
17
25
|
".": {
|
|
18
26
|
"import": "./index.js",
|
|
19
27
|
"require": "./index.cjs"
|
|
20
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"./css/*": "./css/*",
|
|
30
|
+
"./package.json": "./package.json"
|
|
21
31
|
},
|
|
22
32
|
"dependencies": {
|
|
23
33
|
"tslib": "^2.3.0"
|
|
@@ -35,7 +45,8 @@
|
|
|
35
45
|
"typedoc": "0.25.3",
|
|
36
46
|
"typedoc-plugin-rename-defaults": "^0.7.0",
|
|
37
47
|
"typedoc-plugin-markdown": "3.17.1",
|
|
38
|
-
"typescript": "5.2.2"
|
|
48
|
+
"typescript": "5.2.2",
|
|
49
|
+
"@babel/core": "~7.28.6"
|
|
39
50
|
},
|
|
40
51
|
"scripts": {
|
|
41
52
|
"i": "pnpm i",
|