@guiexpert/table 1.1.115 → 1.1.116
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 -0
- package/index.cjs +2 -2
- package/index.js +106 -10
- package/lib/table/factory/cover-grid-factory.d.ts +7 -0
- package/lib/table/state/table-state.if.d.ts +4 -0
- package/lib/table/state/table-state.service.d.ts +10 -0
- package/lib/table/table-scope.d.ts +26 -0
- package/llms.txt +2 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12895,10 +12895,13 @@ const Bc = {
|
|
|
12895
12895
|
return e.filter((s) => s.sortState && s.property).map((s, o) => ({ cd: s, index: o })).sort((s, o) => t(s.cd) - t(o.cd) || s.index - o.index).map(({ cd: s }) => ({ property: s.property, sortState: s.sortState }));
|
|
12896
12896
|
}
|
|
12897
12897
|
computeScroll() {
|
|
12898
|
-
const e = this.scope.scrollViewport, t = { left: this.scope.getViewportScrollLeft(), top: e.scrollTop }, s = this.scope.getFirstVisibleRowIndex();
|
|
12899
|
-
if (
|
|
12900
|
-
const
|
|
12901
|
-
|
|
12898
|
+
const e = this.scope.scrollViewport, t = { left: this.scope.getViewportScrollLeft(), top: e.scrollTop }, s = this.scope.getFirstVisibleRowIndex(), o = this.scope.getTileLayout();
|
|
12899
|
+
if (o) {
|
|
12900
|
+
const i = s > -1 ? this.tileIdAt(o, s * o.getTilesPerRow()) : void 0;
|
|
12901
|
+
i !== void 0 && (t.firstRowId = i);
|
|
12902
|
+
} else if (s > -1 && this.body().getRowCount() > 0) {
|
|
12903
|
+
const i = this.idAt(s, this.warns("scroll"));
|
|
12904
|
+
i !== void 0 && (t.firstRowId = i);
|
|
12902
12905
|
}
|
|
12903
12906
|
return t;
|
|
12904
12907
|
}
|
|
@@ -13118,11 +13121,35 @@ const Bc = {
|
|
|
13118
13121
|
applyScroll(e) {
|
|
13119
13122
|
if (!e || typeof e.top != "number" || typeof e.left != "number" || (this.scope.scrollViewport.scrollTo(al(e.left, this.scope.isRtl()), e.top), this.scope.adjustAfterScrolling(), e.firstRowId === void 0))
|
|
13120
13123
|
return;
|
|
13121
|
-
const t = this.scope.
|
|
13122
|
-
if (t
|
|
13124
|
+
const t = this.scope.getTileLayout();
|
|
13125
|
+
if (t) {
|
|
13126
|
+
this.applyTileScroll(t, e.firstRowId);
|
|
13123
13127
|
return;
|
|
13124
|
-
|
|
13125
|
-
s
|
|
13128
|
+
}
|
|
13129
|
+
const s = this.scope.getFirstVisibleRowIndex();
|
|
13130
|
+
if (s > -1 && this.idAt(s, !1) === e.firstRowId)
|
|
13131
|
+
return;
|
|
13132
|
+
const o = this.rowIndexMap().get(e.firstRowId);
|
|
13133
|
+
o !== void 0 && (this.scope.scrollToIndex(-1, o), this.scope.adjustAfterScrolling());
|
|
13134
|
+
}
|
|
13135
|
+
/**
|
|
13136
|
+
* A grid of tiles: if the stored item is not in the first visible row after restoring the pixels (another number
|
|
13137
|
+
* of tiles per row, new items), scroll to the row of the item. Item gone: the pixel position stays.
|
|
13138
|
+
*/
|
|
13139
|
+
applyTileScroll(e, t) {
|
|
13140
|
+
const s = e.getTilesPerRow(), o = e.getTileCount(), i = this.scope.getFirstVisibleRowIndex();
|
|
13141
|
+
if (i > -1) {
|
|
13142
|
+
for (let r = i * s, l = Math.min(o, (i + 1) * s); r < l; r++)
|
|
13143
|
+
if (this.tileIdAt(e, r) === t) {
|
|
13144
|
+
this.scope.anchorTileScroll(r);
|
|
13145
|
+
return;
|
|
13146
|
+
}
|
|
13147
|
+
}
|
|
13148
|
+
for (let r = 0; r < o; r++)
|
|
13149
|
+
if (this.tileIdAt(e, r) === t) {
|
|
13150
|
+
this.scope.scrollToIndex(-1, Math.floor(r / s)), this.scope.adjustAfterScrolling(), this.scope.anchorTileScroll(r);
|
|
13151
|
+
return;
|
|
13152
|
+
}
|
|
13126
13153
|
}
|
|
13127
13154
|
// ------------------------------------------------------------------ helpers
|
|
13128
13155
|
columnDefs() {
|
|
@@ -13145,6 +13172,14 @@ const Bc = {
|
|
|
13145
13172
|
const e = (t = this.scope.tableOptions.autoRestoreOptions) == null ? void 0 : t.getRowId;
|
|
13146
13173
|
return e && !hl(e) ? e : void 0;
|
|
13147
13174
|
}
|
|
13175
|
+
/**
|
|
13176
|
+
* The id of the item at `index` of a grid of tiles: an own `getRowId(item, index)`, otherwise `id`/`uuid` of the
|
|
13177
|
+
* item. Never warns – an item without id is a normal case of a cover grid (image URLs), the pixels are stored.
|
|
13178
|
+
*/
|
|
13179
|
+
tileIdAt(e, t) {
|
|
13180
|
+
if (!(t < 0 || t >= e.getTileCount()))
|
|
13181
|
+
return this.idOfRow(e.getTileAt(t), t, !1);
|
|
13182
|
+
}
|
|
13148
13183
|
/** The id of the displayed row at `index`. */
|
|
13149
13184
|
idAt(e, t) {
|
|
13150
13185
|
return this.idOfRow(this.body().getRowByIndex(e), e, t);
|
|
@@ -23330,7 +23365,7 @@ const Ie = class Ie extends Dc {
|
|
|
23330
23365
|
* old index (the last item if there is none; no items: no focus).
|
|
23331
23366
|
*/
|
|
23332
23367
|
beforeRenderPass() {
|
|
23333
|
-
if (this.focusFrameDirty && (this.focusFrameDirty = !1, this.cancelPendingRepaint()), !this.tileFocusKnown) {
|
|
23368
|
+
if (this.keepTileScrollAnchor(), this.focusFrameDirty && (this.focusFrameDirty = !1, this.cancelPendingRepaint()), !this.tileFocusKnown) {
|
|
23334
23369
|
this.tileFocusKnown = !0, this.rememberFocusedTile();
|
|
23335
23370
|
return;
|
|
23336
23371
|
}
|
|
@@ -23359,6 +23394,60 @@ const Ie = class Ie extends Dc {
|
|
|
23359
23394
|
}
|
|
23360
23395
|
this.rememberFocusedTile();
|
|
23361
23396
|
}
|
|
23397
|
+
/**
|
|
23398
|
+
* Remembers the top item of a grid of tiles after a render pass (O(1)): the item of the last anchor while it is
|
|
23399
|
+
* still in the top row (several resizes in a row do not drift to the first item of each new row), otherwise the
|
|
23400
|
+
* first item of the top row.
|
|
23401
|
+
*/
|
|
23402
|
+
rememberTileScrollAnchor() {
|
|
23403
|
+
const e = this.getTileLayout(), t = this.renderedBodyRows;
|
|
23404
|
+
if (!e || !t || t.count <= 0) {
|
|
23405
|
+
this.tileScrollAnchor = void 0;
|
|
23406
|
+
return;
|
|
23407
|
+
}
|
|
23408
|
+
const s = Math.max(1, e.getTilesPerRow()), o = e.getTileCount(), i = this.tileScrollAnchor;
|
|
23409
|
+
let r = t.first * s, l;
|
|
23410
|
+
i && Math.floor(i.index / s) === t.first && i.index < o && e.getTileAt(i.index) === i.item ? (r = i.index, l = i.item) : l = r < o ? e.getTileAt(r) : void 0;
|
|
23411
|
+
const a = this.tableModel.getRowHeight("body", t.first);
|
|
23412
|
+
return this.tileScrollAnchor = l === void 0 ? void 0 : { item: l, index: r, perRow: s, rowHeight: a, ratio: a > 0 ? t.offset / a : 0 }, this.tileScrollAnchor;
|
|
23413
|
+
}
|
|
23414
|
+
/**
|
|
23415
|
+
* The scroll state was restored to a grid of tiles: the restored item is the top item from now on (not the first
|
|
23416
|
+
* item of its row), so a later change of the tile size keeps it at the top.
|
|
23417
|
+
*
|
|
23418
|
+
* @internal
|
|
23419
|
+
*/
|
|
23420
|
+
anchorTileScroll(e) {
|
|
23421
|
+
this.tileScrollAnchor = void 0;
|
|
23422
|
+
const t = this.rememberTileScrollAnchor(), s = this.getTileLayout();
|
|
23423
|
+
s && t && Math.floor(e / t.perRow) === Math.floor(t.index / t.perRow) && e < s.getTileCount() && (this.tileScrollAnchor = { ...t, item: s.getTileAt(e), index: e });
|
|
23424
|
+
}
|
|
23425
|
+
/**
|
|
23426
|
+
* A grid of tiles: the scroll position follows the **item** when the geometry changes (since 1.1.116). Another
|
|
23427
|
+
* number of tiles per row (a resize) or another tile height (`coverHeight` + `repaintHard()`) moves the remembered
|
|
23428
|
+
* top item to another row – this pass shows that row at the top again (with the same relative offset), instead of
|
|
23429
|
+
* the old pixels, which would show other items. Only the geometry is followed: new items, a filter or `sort()` keep
|
|
23430
|
+
* their own position (a filter scrolls to the top). The item is searched only if it left its index.
|
|
23431
|
+
*/
|
|
23432
|
+
keepTileScrollAnchor() {
|
|
23433
|
+
const e = this.tileScrollAnchor, t = e ? this.getTileLayout() : void 0;
|
|
23434
|
+
if (!e || !t)
|
|
23435
|
+
return;
|
|
23436
|
+
const s = Math.max(1, t.getTilesPerRow()), o = Math.floor(e.index / e.perRow);
|
|
23437
|
+
if (s === e.perRow && this.tableModel.getRowHeight("body", o) === e.rowHeight)
|
|
23438
|
+
return;
|
|
23439
|
+
const i = t.getTileCount(), r = e.index < i && t.getTileAt(e.index) === e.item ? e.index : t.indexOfTile(e.item);
|
|
23440
|
+
if (r < 0 || r >= i) {
|
|
23441
|
+
this.tileScrollAnchor = void 0;
|
|
23442
|
+
return;
|
|
23443
|
+
}
|
|
23444
|
+
e.index = r;
|
|
23445
|
+
const l = Math.floor(r / s);
|
|
23446
|
+
this.setContentScrollPosition(
|
|
23447
|
+
void 0,
|
|
23448
|
+
this.getBodyRowTop(l) + Math.round(e.ratio * this.tableModel.getRowHeight("body", l))
|
|
23449
|
+
);
|
|
23450
|
+
}
|
|
23362
23451
|
/** True if an event comes from a form control, button, link or editable element (inside a cell, the editor …). */
|
|
23363
23452
|
static isControlEvent(e) {
|
|
23364
23453
|
const t = e.target instanceof Element ? e.target : null;
|
|
@@ -24492,7 +24581,7 @@ const Ie = class Ie extends Dc {
|
|
|
24492
24581
|
}
|
|
24493
24582
|
afterRenderPass() {
|
|
24494
24583
|
var e, t, s, o, i;
|
|
24495
|
-
(e = this.stateService) == null || e.rendered(), (t = this.filterRowService) == null || t.update(), (s = this.fillHandleService) == null || s.update(), (o = this.cellEditorService) == null || o.update(), (i = this.clipboardService) == null || i.update();
|
|
24584
|
+
this.rememberTileScrollAnchor(), (e = this.stateService) == null || e.rendered(), (t = this.filterRowService) == null || t.update(), (s = this.fillHandleService) == null || s.update(), (o = this.cellEditorService) == null || o.update(), (i = this.clipboardService) == null || i.update();
|
|
24496
24585
|
}
|
|
24497
24586
|
onSelectionChanged(e) {
|
|
24498
24587
|
var t, s, o;
|
|
@@ -27702,6 +27791,13 @@ class Vl {
|
|
|
27702
27791
|
* scroll position restored under the key of `getStorageKeyFn` (`localStorage`), and the focus frame only while the
|
|
27703
27792
|
* grid is used with the keyboard (`focusFrame: "keyboard"`).
|
|
27704
27793
|
*
|
|
27794
|
+
* The scroll position follows the **item** (since 1.1.116): the state stores the id of the first item of the first
|
|
27795
|
+
* visible row (`id`/`uuid` of the item or `autoRestoreOptions.getRowId(item, index)`), so a restore with another
|
|
27796
|
+
* width shows the same covers at the top; while the grid lives, a resize or a new tile size keeps the top item at the
|
|
27797
|
+
* top, too. Items without id: only the pixels. Before 1.1.116 every cover grid that stored its scroll position (these
|
|
27798
|
+
* options do) wrote a console warning "the body model has no row objects" – do not set
|
|
27799
|
+
* `getRowId: (_row, rowIndex) => rowIndex`.
|
|
27800
|
+
*
|
|
27705
27801
|
* @param defaultRowHeight - the height of a tile (`coverHeight`)
|
|
27706
27802
|
* @param getStorageKeyFn - storage key of the scroll position (default `"CoverGrid"`)
|
|
27707
27803
|
* @returns new options – add your own fields with a spread
|
|
@@ -56,6 +56,13 @@ export declare class CoverGridFactory {
|
|
|
56
56
|
* scroll position restored under the key of `getStorageKeyFn` (`localStorage`), and the focus frame only while the
|
|
57
57
|
* grid is used with the keyboard (`focusFrame: "keyboard"`).
|
|
58
58
|
*
|
|
59
|
+
* The scroll position follows the **item** (since 1.1.116): the state stores the id of the first item of the first
|
|
60
|
+
* visible row (`id`/`uuid` of the item or `autoRestoreOptions.getRowId(item, index)`), so a restore with another
|
|
61
|
+
* width shows the same covers at the top; while the grid lives, a resize or a new tile size keeps the top item at the
|
|
62
|
+
* top, too. Items without id: only the pixels. Before 1.1.116 every cover grid that stored its scroll position (these
|
|
63
|
+
* options do) wrote a console warning "the body model has no row objects" – do not set
|
|
64
|
+
* `getRowId: (_row, rowIndex) => rowIndex`.
|
|
65
|
+
*
|
|
59
66
|
* @param defaultRowHeight - the height of a tile (`coverHeight`)
|
|
60
67
|
* @param getStorageKeyFn - storage key of the scroll position (default `"CoverGrid"`)
|
|
61
68
|
* @returns new options – add your own fields with a spread
|
|
@@ -129,6 +129,10 @@ export interface TableScrollStateIf {
|
|
|
129
129
|
/**
|
|
130
130
|
* The id of the first visible row. If other rows are at the top after restoring `top` (new data), the table
|
|
131
131
|
* scrolls to this row.
|
|
132
|
+
*
|
|
133
|
+
* A grid of tiles (`AreaModelIf.getTileLayout()`, e.g. a cover grid – since 1.1.116): the id of the first
|
|
134
|
+
* **item** of the first visible row (`id`/`uuid` of the item or an own `getRowId(item, index)`). After a restore
|
|
135
|
+
* with another number of tiles per row the table scrolls to the row of this item. Items without id: not set.
|
|
132
136
|
*/
|
|
133
137
|
firstRowId?: TableStateRowId;
|
|
134
138
|
}
|
|
@@ -140,6 +140,11 @@ export declare class TableStateService {
|
|
|
140
140
|
private applyChecked;
|
|
141
141
|
private applySelection;
|
|
142
142
|
private applyScroll;
|
|
143
|
+
/**
|
|
144
|
+
* A grid of tiles: if the stored item is not in the first visible row after restoring the pixels (another number
|
|
145
|
+
* of tiles per row, new items), scroll to the row of the item. Item gone: the pixel position stays.
|
|
146
|
+
*/
|
|
147
|
+
private applyTileScroll;
|
|
143
148
|
private columnDefs;
|
|
144
149
|
private body;
|
|
145
150
|
private headerGroupModel;
|
|
@@ -147,6 +152,11 @@ export declare class TableStateService {
|
|
|
147
152
|
private warns;
|
|
148
153
|
/** The own `getRowId`, `undefined` for the default of {@link AutoRestoreOptions} (or none). */
|
|
149
154
|
private ownGetRowId;
|
|
155
|
+
/**
|
|
156
|
+
* The id of the item at `index` of a grid of tiles: an own `getRowId(item, index)`, otherwise `id`/`uuid` of the
|
|
157
|
+
* item. Never warns – an item without id is a normal case of a cover grid (image URLs), the pixels are stored.
|
|
158
|
+
*/
|
|
159
|
+
private tileIdAt;
|
|
150
160
|
/** The id of the displayed row at `index`. */
|
|
151
161
|
private idAt;
|
|
152
162
|
/**
|
|
@@ -474,6 +474,32 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
474
474
|
* old index (the last item if there is none; no items: no focus).
|
|
475
475
|
*/
|
|
476
476
|
protected beforeRenderPass(): void;
|
|
477
|
+
/**
|
|
478
|
+
* A grid of tiles: the first item of the top row and where the view stood in that row (0 … 1), remembered after each
|
|
479
|
+
* render pass – the scroll position follows it when the geometry changes (since 1.1.116).
|
|
480
|
+
*/
|
|
481
|
+
private tileScrollAnchor?;
|
|
482
|
+
/**
|
|
483
|
+
* Remembers the top item of a grid of tiles after a render pass (O(1)): the item of the last anchor while it is
|
|
484
|
+
* still in the top row (several resizes in a row do not drift to the first item of each new row), otherwise the
|
|
485
|
+
* first item of the top row.
|
|
486
|
+
*/
|
|
487
|
+
private rememberTileScrollAnchor;
|
|
488
|
+
/**
|
|
489
|
+
* The scroll state was restored to a grid of tiles: the restored item is the top item from now on (not the first
|
|
490
|
+
* item of its row), so a later change of the tile size keeps it at the top.
|
|
491
|
+
*
|
|
492
|
+
* @internal
|
|
493
|
+
*/
|
|
494
|
+
anchorTileScroll(index: number): void;
|
|
495
|
+
/**
|
|
496
|
+
* A grid of tiles: the scroll position follows the **item** when the geometry changes (since 1.1.116). Another
|
|
497
|
+
* number of tiles per row (a resize) or another tile height (`coverHeight` + `repaintHard()`) moves the remembered
|
|
498
|
+
* top item to another row – this pass shows that row at the top again (with the same relative offset), instead of
|
|
499
|
+
* the old pixels, which would show other items. Only the geometry is followed: new items, a filter or `sort()` keep
|
|
500
|
+
* their own position (a filter scrolls to the top). The item is searched only if it left its index.
|
|
501
|
+
*/
|
|
502
|
+
private keepTileScrollAnchor;
|
|
477
503
|
/** True if an event comes from a form control, button, link or editable element (inside a cell, the editor …). */
|
|
478
504
|
private static isControlEvent;
|
|
479
505
|
/** A change of the focus frame (focusFrame "keyboard") that the next render pass has to draw. */
|
package/llms.txt
CHANGED
|
@@ -656,6 +656,8 @@ Full answers: instructions.md section 6.26 (https://github.com/guiexperttable/mo
|
|
|
656
656
|
- Open a row or a cover with Enter or a double click: `listener.onCellActivated = evt => open(evt.row ?? evt.value)` (wrappers `cellActivated`, since 1.1.115) – one handler for keyboard and mouse; only if the gesture did nothing else (checkbox, tree node, detail row, editor); the Enter key is not consumed. → R20
|
|
657
657
|
- Hide the focus frame: `tableOptions.focusFrame: "never"`; only while the keyboard is used: `"keyboard"` (default of a cover grid, since 1.1.115). Not with CSS, not with `new FocusModel("none")`.
|
|
658
658
|
- Cover grid with the keyboard (since 1.1.115): built in – arrows move from item to item (wrap at the end of a row), Home/End first/last item, Enter opens, the focus follows the item after sort/filter/resize. → R20
|
|
659
|
+
- Cover grid warns "the body model has no row objects": fixed in 1.1.116 – its scroll state stores the first visible item (`id`/`uuid` or `getRowId(item, index)`), no warning; a resize or a new tile size keeps that item at the top. Never `getRowId: (_row, rowIndex) => rowIndex` for a cover grid (a row holds other items after a resize).
|
|
660
|
+
- `@guiexpert/demo-table-models` makes the bundle ~600 kB bigger: fixed in 1.1.116 (nothing computed on import, `"sideEffects": false`); an app with only `BookCoverRenderer` ≈ 11 kB minified.
|
|
659
661
|
- Empty table: the host div needs a fixed height and the stylesheet `@guiexpert/table/css/main.css`.
|
|
660
662
|
|
|
661
663
|
## Feature reference
|