@guiexpert/table 1.1.84 → 1.1.85

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.
@@ -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 returns 0 and should be overridden by
504
- * subclasses that support scrolling.
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} _rowIndex - The index of the row
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(_rowIndex: number): number;
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.
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,14 @@
1
1
  {
2
2
  "name": "@guiexpert/table",
3
- "version": "1.1.84",
3
+ "version": "1.1.85",
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",