@guiexpert/table 1.1.114 → 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 +10 -0
- package/index.cjs +39 -39
- package/index.d.ts +4 -0
- package/index.js +3129 -2691
- package/lib/table/data/common/event/ge-cell-activate-event.d.ts +65 -0
- package/lib/table/data/options/table-options.d.ts +3 -0
- package/lib/table/data/options/table-options.if.d.ts +16 -0
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +14 -0
- package/lib/table/data/tablemodel/areamodel/cover-grid-body-model.d.ts +37 -3
- package/lib/table/data/tablemodel/areamodel/tile-layout.if.d.ts +55 -0
- package/lib/table/event-adapter.d.ts +3 -0
- package/lib/table/event-listener.if.d.ts +21 -0
- package/lib/table/factory/cover-grid-factory.d.ts +28 -7
- package/lib/table/focus/focus-frame.type.d.ts +16 -0
- package/lib/table/focus/focus-model.d.ts +4 -0
- package/lib/table/focus/focus.type.d.ts +4 -0
- package/lib/table/mouse-handler.d.ts +10 -0
- package/lib/table/render-scope.d.ts +6 -0
- package/lib/table/service/convenience-dom.service.d.ts +1 -1
- 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 +91 -0
- package/lib/table/tile-navigation/tile-navigation.d.ts +81 -0
- package/llms.txt +65 -2
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AreaIdent } from '../../tablemodel/area-ident.type.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What activated a cell: Enter (`"keyboard"`), a double click (`"mouse"`) or
|
|
5
|
+
* `tableApi.triggerAction("ACTIVATE_CELL")` (`"api"`).
|
|
6
|
+
*
|
|
7
|
+
* @category Events
|
|
8
|
+
* @since 1.1.115
|
|
9
|
+
*/
|
|
10
|
+
export type GeCellActivateSource = "keyboard" | "mouse" | "api";
|
|
11
|
+
/**
|
|
12
|
+
* Reported by {@link EventListenerIf.onCellActivated}: the user "opens" a body cell – Enter on the focused cell or a
|
|
13
|
+
* double click. One handler for keyboard and mouse: open the book of a cover grid, the order of a list.
|
|
14
|
+
*
|
|
15
|
+
* It is reported only if the gesture did nothing else: Enter first toggles a row checkbox, a detail row
|
|
16
|
+
* (master/detail) or a tree node and, with Excel-style editing, edits or moves down; a double click first opens the
|
|
17
|
+
* editor of an editable cell or toggles a tree node. Empty tiles of a cover grid report nothing, a double click on a
|
|
18
|
+
* button, link or input inside a cell belongs to that control, and a held Enter key reports once.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const listener = new EventAdapter();
|
|
22
|
+
* listener.onCellActivated = (evt: GeCellActivateEvent) => {
|
|
23
|
+
* console.log(`open row ${evt.rowIndex} by ${evt.source}`, evt.row ?? evt.value);
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* @category Events
|
|
27
|
+
* @since 1.1.115
|
|
28
|
+
*/
|
|
29
|
+
export declare class GeCellActivateEvent<V = any, R = any> {
|
|
30
|
+
/** The area of the cell – always `"body"`. */
|
|
31
|
+
readonly areaIdent: AreaIdent;
|
|
32
|
+
/** Display row index of the cell. */
|
|
33
|
+
readonly rowIndex: number;
|
|
34
|
+
/** Model column index of the cell. */
|
|
35
|
+
readonly columnIndex: number;
|
|
36
|
+
/** The value of the cell (`getValueAt`) – in a cover grid the item of the tile. */
|
|
37
|
+
readonly value: V;
|
|
38
|
+
/**
|
|
39
|
+
* The row (`getRowByIndex`): the row object of a list (the row array of `bodyData` tables); in a tree, row
|
|
40
|
+
* grouping or pivot a `TreeRow` (your object is `row.data`); `undefined` in a cover grid.
|
|
41
|
+
*/
|
|
42
|
+
readonly row: R;
|
|
43
|
+
/** Enter, double click or the API. */
|
|
44
|
+
readonly source: GeCellActivateSource;
|
|
45
|
+
/** The key or mouse event (not for `"api"`). */
|
|
46
|
+
readonly originalEvent?: KeyboardEvent | MouseEvent | undefined;
|
|
47
|
+
constructor(
|
|
48
|
+
/** The area of the cell – always `"body"`. */
|
|
49
|
+
areaIdent: AreaIdent,
|
|
50
|
+
/** Display row index of the cell. */
|
|
51
|
+
rowIndex: number,
|
|
52
|
+
/** Model column index of the cell. */
|
|
53
|
+
columnIndex: number,
|
|
54
|
+
/** The value of the cell (`getValueAt`) – in a cover grid the item of the tile. */
|
|
55
|
+
value: V,
|
|
56
|
+
/**
|
|
57
|
+
* The row (`getRowByIndex`): the row object of a list (the row array of `bodyData` tables); in a tree, row
|
|
58
|
+
* grouping or pivot a `TreeRow` (your object is `row.data`); `undefined` in a cover grid.
|
|
59
|
+
*/
|
|
60
|
+
row: R,
|
|
61
|
+
/** Enter, double click or the API. */
|
|
62
|
+
source: GeCellActivateSource,
|
|
63
|
+
/** The key or mouse event (not for `"api"`). */
|
|
64
|
+
originalEvent?: KeyboardEvent | MouseEvent | undefined);
|
|
65
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableDirection } from '../../rtl/table-direction.type.js';
|
|
2
|
+
import { FocusFrameMode } from '../../focus/focus-frame.type.js';
|
|
2
3
|
import { MasterDetailOptionsIf } from '../../master-detail/master-detail-options.if.js';
|
|
3
4
|
import { DefaultRowHeightsIf } from './default-row-heights.if.js';
|
|
4
5
|
import { TableOptionsIf } from './table-options.if.js';
|
|
@@ -126,6 +127,8 @@ export declare class TableOptions implements TableOptionsIf {
|
|
|
126
127
|
* own value takes the direction of the outer table. @since 1.1.98
|
|
127
128
|
*/
|
|
128
129
|
direction?: TableDirection;
|
|
130
|
+
/** When the focus frame is drawn ({@link TableOptionsIf.focusFrame}). Not set = `"always"`. @since 1.1.115 */
|
|
131
|
+
focusFrame?: FocusFrameMode;
|
|
129
132
|
/** Persistent filter row below the column titles ({@link TableOptionsIf.filterRow}). Not set = off. @since 1.1.114 */
|
|
130
133
|
filterRow?: boolean | Partial<FilterRowOptionsIf>;
|
|
131
134
|
/** Per-column filter menu popup ({@link TableOptionsIf.columnFilterMenu}). Not set = off. @since 1.1.114 */
|
|
@@ -23,6 +23,7 @@ import { AriaTextsIf } from '../../aria/aria-texts.if.js';
|
|
|
23
23
|
import { TableStateIf } from '../../state/table-state.if.js';
|
|
24
24
|
import { OverlayOptionsIf } from './overlay-options.if.js';
|
|
25
25
|
import { TableDirection } from '../../rtl/table-direction.type.js';
|
|
26
|
+
import { FocusFrameMode } from '../../focus/focus-frame.type.js';
|
|
26
27
|
import { ColumnAutoWidthOptionsIf } from '../../column-drag/column-auto-width-options.if.js';
|
|
27
28
|
import { ColumnFilterMenuOptionsIf, ColumnFilterOptionsIf, ColumnFilterTextsIf, FilterRowOptionsIf } from '../../column-filter/column-filter-options.if.js';
|
|
28
29
|
|
|
@@ -523,6 +524,21 @@ export interface TableOptionsIf {
|
|
|
523
524
|
* @see [Live demo: right-to-left](https://gui.expert/showcase/rtl/run/) · Training: [Right-to-left](https://gui.expert/training/theming-dark-mode/#rtl)
|
|
524
525
|
*/
|
|
525
526
|
direction?: TableDirection;
|
|
527
|
+
/**
|
|
528
|
+
* When the frame around the focused cell is drawn: `"always"` (default – after a click and after a key),
|
|
529
|
+
* `"keyboard"` (only while the table is used with the keyboard, like CSS `:focus-visible`; a mouse press hides it)
|
|
530
|
+
* or `"never"`. The focused cell itself is not affected: arrow keys, Enter and `aria-activedescendant` work in all
|
|
531
|
+
* three modes.
|
|
532
|
+
*
|
|
533
|
+
* Use it instead of hiding `.ge-table-focus-border` with CSS. The type of a {@link FocusModel}
|
|
534
|
+
* (`new FocusModel("none")`) does **not** hide the frame.
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), focusFrame: "never" };
|
|
538
|
+
*
|
|
539
|
+
* @since 1.1.115
|
|
540
|
+
*/
|
|
541
|
+
focusFrame?: FocusFrameMode;
|
|
526
542
|
/**
|
|
527
543
|
* The state the table starts with: column layout, sorting, tree, checked and selected rows … – e.g. loaded from
|
|
528
544
|
* your server ({@link TableApi.getState}, {@link EventListenerIf.onStateChanged}). A state stored by
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RowDropTargetIf } from '../../../row-drag/row-drop-target.if.js';
|
|
2
2
|
import { AppendRowsContextIf, AppendRowsModelResultIf } from '../../../live-append/append-rows-options.if.js';
|
|
3
3
|
import { DerivedValuesChangeIf } from './derived-values-change.if.js';
|
|
4
|
+
import { TileLayoutIf } from './tile-layout.if.js';
|
|
4
5
|
import { CellRendererIf } from '../../../renderer/cell-render.if.js';
|
|
5
6
|
import { CheckedType } from '../../common/checked-type.js';
|
|
6
7
|
import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if.js';
|
|
@@ -356,6 +357,19 @@ export interface AreaModelIf {
|
|
|
356
357
|
* @since 1.1.94
|
|
357
358
|
*/
|
|
358
359
|
invalidateDerivedValues?(change?: DerivedValuesChangeIf): void;
|
|
360
|
+
/**
|
|
361
|
+
* Optional (body only): the cells are one sequence of items shown as tiles – the table then navigates from item
|
|
362
|
+
* to item (arrow keys wrap over the end of a row, Home/End = first/last item), never focuses an empty tile and
|
|
363
|
+
* keeps the focus on the same item after sorting, filtering and resizing. See {@link TileLayoutIf};
|
|
364
|
+
* {@link CoverGridBodyModel} implements it. `undefined` (or no method) = a normal table.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* const tiles = tableModel.getBodyModel().getTileLayout?.();
|
|
368
|
+
* if (tiles) console.log(`${tiles.getTileCount()} items, ${tiles.getTilesPerRow()} per row`);
|
|
369
|
+
*
|
|
370
|
+
* @since 1.1.115
|
|
371
|
+
*/
|
|
372
|
+
getTileLayout?(): TileLayoutIf | undefined;
|
|
359
373
|
/**
|
|
360
374
|
* Optional: true for a cell that names its row (a label such as "Nord" or "Total") – the table gives it
|
|
361
375
|
* `role="rowheader"` instead of `gridcell`, so screen readers announce it with the row.
|
|
@@ -6,11 +6,18 @@ import { FilterFunction } from '../../common/filter-function.js';
|
|
|
6
6
|
import { SortItem } from '../../common/sort-item.js';
|
|
7
7
|
import { AreaIdent } from '../area-ident.type.js';
|
|
8
8
|
import { SorterService } from '../../../service/sorter.service.js';
|
|
9
|
+
import { TileLayoutIf } from './tile-layout.if.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Body of a cover grid: `filteredItems[row * columns + column]` is the item of a tile (`getValueAt`), `columns` =
|
|
12
|
-
* `floor(width / coverWidth)
|
|
13
|
-
* Change `coverWidth`/`coverHeight` or the items and call `tableApi.repaintHard()`.
|
|
13
|
+
* `floor(width / coverWidth)` (at least 1). `items` = all items, `filteredItems` = shown items (filter and `sort()`
|
|
14
|
+
* work on it). Change `coverWidth`/`coverHeight` or the items and call `tableApi.repaintHard()`.
|
|
15
|
+
*
|
|
16
|
+
* `filteredItems` is the `items` array itself until the first filter or sort; `sort()` and `doSort()` sort a copy
|
|
17
|
+
* (since 1.1.115 – before, they reordered the array of the app as long as no filter was set).
|
|
18
|
+
*
|
|
19
|
+
* The model is a {@link TileLayoutIf} (since 1.1.115): the keyboard moves from item to item, empty tiles never get
|
|
20
|
+
* the focus and the focus follows the item after sorting, filtering and resizing.
|
|
14
21
|
*
|
|
15
22
|
* @example
|
|
16
23
|
* ```ts
|
|
@@ -23,7 +30,7 @@ import { SorterService } from '../../../service/sorter.service.js';
|
|
|
23
30
|
*
|
|
24
31
|
* @category Area models
|
|
25
32
|
*/
|
|
26
|
-
export declare class CoverGridBodyModel<T> implements AreaModelIf {
|
|
33
|
+
export declare class CoverGridBodyModel<T> implements AreaModelIf, TileLayoutIf {
|
|
27
34
|
items: T[];
|
|
28
35
|
cellRenderer: CellRendererIf;
|
|
29
36
|
coverWidth: number;
|
|
@@ -45,7 +52,29 @@ export declare class CoverGridBodyModel<T> implements AreaModelIf {
|
|
|
45
52
|
* @since 1.1.92
|
|
46
53
|
*/
|
|
47
54
|
getUnfilteredRowCount(): number;
|
|
55
|
+
/**
|
|
56
|
+
* The number of tiles per row: as many as fit into the width – at least 1 (a width smaller than one tile, width 0
|
|
57
|
+
* or a tile width of 0; before 1.1.115 a narrow grid had 0 columns and `Infinity` rows).
|
|
58
|
+
*
|
|
59
|
+
* @returns {number} tiles per row, ≥ 1
|
|
60
|
+
*/
|
|
48
61
|
getColumnCount(): number;
|
|
62
|
+
/**
|
|
63
|
+
* The tiles as one sequence of items – the table uses it for the keyboard navigation and to keep the focus on
|
|
64
|
+
* the same item.
|
|
65
|
+
*
|
|
66
|
+
* @returns {TileLayoutIf} this model
|
|
67
|
+
* @since 1.1.115
|
|
68
|
+
*/
|
|
69
|
+
getTileLayout(): TileLayoutIf;
|
|
70
|
+
/** The number of shown items. @since 1.1.115 */
|
|
71
|
+
getTileCount(): number;
|
|
72
|
+
/** Tiles per row ({@link getColumnCount}). @since 1.1.115 */
|
|
73
|
+
getTilesPerRow(): number;
|
|
74
|
+
/** The shown item at an index, `undefined` outside the items. @since 1.1.115 */
|
|
75
|
+
getTileAt(index: number): T | undefined;
|
|
76
|
+
/** The index of a shown item, `-1` if it is not shown (filtered out, removed). @since 1.1.115 */
|
|
77
|
+
indexOfTile(item: unknown): number;
|
|
49
78
|
getValueAt(rowIndex: number, columnIndex: number): T | undefined;
|
|
50
79
|
getTextValueAt(_rowIndex: number, _columnIndex: number): string;
|
|
51
80
|
getTooltipAt(_rowIndex: number, _columnIndex: number): any;
|
|
@@ -68,6 +97,11 @@ export declare class CoverGridBodyModel<T> implements AreaModelIf {
|
|
|
68
97
|
externalFilterChanged<_T>(predict: FilterFunction<any>): void;
|
|
69
98
|
isFilterable(): boolean;
|
|
70
99
|
doSort(sortItems: SortItem[]): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Sorts the shown items – a copy, the `items` array of the app keeps its order (since 1.1.115).
|
|
102
|
+
*
|
|
103
|
+
* @param compareFn - compares two items
|
|
104
|
+
*/
|
|
71
105
|
sort(compareFn?: (a: any, b: any) => number): void;
|
|
72
106
|
isEditable(_rowIndex: number, _columnIndex: number): boolean;
|
|
73
107
|
setValue(_rowIndex: number, _columnIndex: number, _value: any): boolean;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A body whose cells are **one sequence of items** shown as tiles (a cover grid): item `i` sits in row
|
|
3
|
+
* `floor(i / tilesPerRow)`, column `i % tilesPerRow`; the cells behind the last item are empty.
|
|
4
|
+
*
|
|
5
|
+
* An area model that returns such a layout from {@link AreaModelIf.getTileLayout} gets the keyboard navigation of a
|
|
6
|
+
* tile grid instead of the cell navigation (since 1.1.115):
|
|
7
|
+
*
|
|
8
|
+
* - ← / → move to the previous / next item and wrap over the end of a row; ↑ / ↓ move one row (↓ without an item
|
|
9
|
+
* below: the last item); Home / End go to the first / last item; Page Up / Down move a page.
|
|
10
|
+
* - Empty tiles never get the focus (keyboard and mouse), Enter and double click on them report nothing.
|
|
11
|
+
* - The focus follows the **item**: after sorting, filtering or a different number of tiles per row the same item
|
|
12
|
+
* has the focus (found with {@link indexOfTile}).
|
|
13
|
+
*
|
|
14
|
+
* {@link CoverGridBodyModel} implements it.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* class PhotoBody extends AreaModel implements TileLayoutIf {
|
|
19
|
+
* constructor(private photos: string[], private perRow: number) { super(); }
|
|
20
|
+
* override getRowCount() { return Math.ceil(this.photos.length / this.perRow); }
|
|
21
|
+
* override getValueAt(rowIndex: number, columnIndex: number) { return this.photos[rowIndex * this.perRow + columnIndex]; }
|
|
22
|
+
* getTileLayout() { return this; }
|
|
23
|
+
* getTileCount() { return this.photos.length; }
|
|
24
|
+
* getTilesPerRow() { return this.perRow; }
|
|
25
|
+
* getTileAt(index: number) { return this.photos[index]; }
|
|
26
|
+
* indexOfTile(item: unknown) { return this.photos.indexOf(item as string); }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @category Area models
|
|
31
|
+
* @since 1.1.115
|
|
32
|
+
*/
|
|
33
|
+
export interface TileLayoutIf {
|
|
34
|
+
/** The number of shown items (after the filter). */
|
|
35
|
+
getTileCount(): number;
|
|
36
|
+
/** Tiles per row – at least 1. */
|
|
37
|
+
getTilesPerRow(): number;
|
|
38
|
+
/**
|
|
39
|
+
* The item of a tile: its identity (`===`) is what the focus follows. Return the **same** value for the same item
|
|
40
|
+
* each time (objects of your list, ids) – a model that creates a new object per call never matches, and the table
|
|
41
|
+
* would search with {@link indexOfTile} in every render pass.
|
|
42
|
+
*
|
|
43
|
+
* @param {number} index - index in the shown items
|
|
44
|
+
* @returns {unknown} the item, `undefined` outside the items
|
|
45
|
+
*/
|
|
46
|
+
getTileAt(index: number): unknown;
|
|
47
|
+
/**
|
|
48
|
+
* The index of an item in the shown items. Called only when the focused item is no longer in its cell (after
|
|
49
|
+
* sorting, filtering, a resize) – never while scrolling.
|
|
50
|
+
*
|
|
51
|
+
* @param {unknown} item - an item {@link getTileAt} returned
|
|
52
|
+
* @returns {number} the index, `-1` if the item is not shown (filtered out, removed)
|
|
53
|
+
*/
|
|
54
|
+
indexOfTile(item: unknown): number;
|
|
55
|
+
}
|
|
@@ -13,6 +13,7 @@ import { GeRowDragEvent } from './data/common/event/ge-row-drag-event.js';
|
|
|
13
13
|
import { GeColumnResizeEvent } from './data/common/event/ge-column-resize-event.js';
|
|
14
14
|
import { GeColumnMoveEvent } from './data/common/event/ge-column-move-event.js';
|
|
15
15
|
import { GeFilterEvent } from './data/common/event/ge-filter-event.js';
|
|
16
|
+
import { GeCellActivateEvent } from './data/common/event/ge-cell-activate-event.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Empty implementation of {@link EventListenerIf} – extend it and override only the events you need.
|
|
@@ -62,4 +63,6 @@ export declare class EventAdapter implements EventListenerIf {
|
|
|
62
63
|
onColumnMoveEnd(_evt: GeColumnMoveEvent): void;
|
|
63
64
|
/** @since 1.1.114 */
|
|
64
65
|
onFilterChanged(_evt: GeFilterEvent): void;
|
|
66
|
+
/** @since 1.1.115 */
|
|
67
|
+
onCellActivated(_evt: GeCellActivateEvent): void;
|
|
65
68
|
}
|
|
@@ -4,6 +4,7 @@ import { GeDetailEvent } from './data/common/event/ge-detail-event.js';
|
|
|
4
4
|
import { GeColumnResizeEvent } from './data/common/event/ge-column-resize-event.js';
|
|
5
5
|
import { GeColumnMoveEvent } from './data/common/event/ge-column-move-event.js';
|
|
6
6
|
import { GeFilterEvent } from './data/common/event/ge-filter-event.js';
|
|
7
|
+
import { GeCellActivateEvent } from './data/common/event/ge-cell-activate-event.js';
|
|
7
8
|
import { GeMouseEvent } from './data/common/event/ge-mouse-event.js';
|
|
8
9
|
import { GeModelChangeEvent } from './data/common/event/ge-model-change-event.js';
|
|
9
10
|
import { GeScrollEvent } from './data/common/event/ge-scroll-event.js';
|
|
@@ -157,4 +158,24 @@ export interface EventListenerIf extends EventFocusChangedListenerIf, EventSelec
|
|
|
157
158
|
* @since 1.1.114
|
|
158
159
|
*/
|
|
159
160
|
onFilterChanged?(evt: GeFilterEvent): void;
|
|
161
|
+
/**
|
|
162
|
+
* Optional: the user "opens" a body cell – **Enter** on the focused cell or a **double click** (one handler for
|
|
163
|
+
* both). Typical: open the item of a cover grid (`evt.value`) or the row of a list (`evt.row`).
|
|
164
|
+
*
|
|
165
|
+
* Reported only if the gesture did nothing else: Enter first toggles a row checkbox, a detail row or a tree node
|
|
166
|
+
* and – with Excel-style editing – edits or moves down; a double click first opens the editor of an editable cell
|
|
167
|
+
* or toggles a tree node. Not on resize handles, row drag handles, empty tiles of a cover grid, in an open editor
|
|
168
|
+
* or under a blocking loading overlay. A double click is still reported to {@link onMouseClicked} with
|
|
169
|
+
* `clickCount` 2. See {@link GeCellActivateEvent}.
|
|
170
|
+
*
|
|
171
|
+
* The Enter key is **not** consumed (a dialog or form around the table still gets it, as before 1.1.115): call
|
|
172
|
+
* `evt.originalEvent?.preventDefault()` and `stopPropagation()` in the handler if nothing else should react.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const listener = new EventAdapter();
|
|
176
|
+
* listener.onCellActivated = (evt: GeCellActivateEvent) => console.log("open", evt.row ?? evt.value, evt.source);
|
|
177
|
+
*
|
|
178
|
+
* @since 1.1.115
|
|
179
|
+
*/
|
|
180
|
+
onCellActivated?(evt: GeCellActivateEvent): void;
|
|
160
181
|
}
|
|
@@ -20,7 +20,7 @@ import { TableOptionsIf } from '../data/options/table-options.if.js';
|
|
|
20
20
|
* }
|
|
21
21
|
* };
|
|
22
22
|
* const gridModel = CoverGridFactory.createCoverGridModel(books, renderer, 160, 240);
|
|
23
|
-
* const gridOptions = CoverGridFactory.
|
|
23
|
+
* const gridOptions = CoverGridFactory.createCoverGridDefaultOptions(240, () => "books");
|
|
24
24
|
* const gridApi = new TableScope(host, gridModel, new SimpleDomService(), gridOptions, new EventAdapter())
|
|
25
25
|
* .firstInit()
|
|
26
26
|
* .getApi();
|
|
@@ -52,23 +52,44 @@ export declare class CoverGridFactory {
|
|
|
52
52
|
*/
|
|
53
53
|
static createCoverGridModel<T>(items: T[], cellRenderer: CellRendererIf, coverWidth?: number, coverHeight?: number, width?: number, firstRowPaddingTop?: number): CoverGridTableModel<T>;
|
|
54
54
|
/**
|
|
55
|
-
* Options for a cover grid: no borders and separators, no row or column hover, header and footer height 0,
|
|
56
|
-
* scroll position restored under the key of `getStorageKeyFn` (`localStorage`)
|
|
57
|
-
*
|
|
55
|
+
* Options for a cover grid: no borders and separators, no row or column hover, header and footer height 0, the
|
|
56
|
+
* scroll position restored under the key of `getStorageKeyFn` (`localStorage`), and the focus frame only while the
|
|
57
|
+
* grid is used with the keyboard (`focusFrame: "keyboard"`).
|
|
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`.
|
|
58
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
|
|
69
|
+
* @since 1.1.115
|
|
62
70
|
*
|
|
63
71
|
* @example
|
|
64
72
|
* ```ts
|
|
65
73
|
* let photoFilter = "";
|
|
66
74
|
* const gridOptions: TableOptionsIf = {
|
|
67
|
-
* ...CoverGridFactory.
|
|
68
|
-
* externalFilterFunction: (photo: { name: string }) => photo.name.includes(photoFilter)
|
|
69
|
-
* shortcutActionsDisabled: true
|
|
75
|
+
* ...CoverGridFactory.createCoverGridDefaultOptions(240, () => "photos"),
|
|
76
|
+
* externalFilterFunction: (photo: { name: string }) => photo.name.includes(photoFilter)
|
|
70
77
|
* };
|
|
71
78
|
* ```
|
|
72
79
|
*/
|
|
80
|
+
static createCoverGridDefaultOptions(defaultRowHeight: number, getStorageKeyFn?: () => string): TableOptionsIf;
|
|
81
|
+
/**
|
|
82
|
+
* The same as {@link createCoverGridDefaultOptions} – the old name with a typo, kept for compatibility.
|
|
83
|
+
*
|
|
84
|
+
* @deprecated since 1.1.115: use {@link createCoverGridDefaultOptions}
|
|
85
|
+
* @param defaultRowHeight - the height of a tile (`coverHeight`)
|
|
86
|
+
* @param getStorageKeyFn - storage key of the scroll position (default `"CoverGrid"`)
|
|
87
|
+
* @returns new options – add your own fields with a spread
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const gridOptions: TableOptionsIf = CoverGridFactory.createCoverGrisDefaultOptions(240, () => "photos");
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
73
94
|
static createCoverGrisDefaultOptions(defaultRowHeight: number, getStorageKeyFn?: () => string): TableOptionsIf;
|
|
74
95
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When the frame around the focused cell is drawn ({@link TableOptionsIf.focusFrame}):
|
|
3
|
+
*
|
|
4
|
+
* - `"always"` (default): whenever a cell has the focus – after a click and after a key.
|
|
5
|
+
* - `"keyboard"`: only while the table is used with the keyboard (like CSS `:focus-visible`): a key press or Tab
|
|
6
|
+
* into the table shows it, a mouse press hides it. The default of a cover grid.
|
|
7
|
+
* - `"never"`: no frame. Keyboard users then need another visible focus indicator (WCAG 2.4.7), e.g. drawn by your
|
|
8
|
+
* cell renderer.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), focusFrame: "keyboard" };
|
|
12
|
+
*
|
|
13
|
+
* @category Selection & focus
|
|
14
|
+
* @since 1.1.115
|
|
15
|
+
*/
|
|
16
|
+
export type FocusFrameMode = "always" | "keyboard" | "never";
|
|
@@ -10,6 +10,10 @@ import { RowIndexShift } from '../live-append/row-index-shift.js';
|
|
|
10
10
|
* This class also maintains a list of `EventFocusChangedListenerIf` instances and notifies them
|
|
11
11
|
* whenever there is a change in focus.
|
|
12
12
|
*
|
|
13
|
+
* The type given to the constructor is informational: the table never reads it – `new FocusModel()` (type "none")
|
|
14
|
+
* has a focused cell and a focus frame like `new FocusModel("cell")`. Hide the frame with
|
|
15
|
+
* {@link TableOptionsIf.focusFrame} (since 1.1.115).
|
|
16
|
+
*
|
|
13
17
|
* ## Instance Properties:
|
|
14
18
|
* - `selectionType: FocusType` — Specifies the type of selection that is currently in focus. It could be either a specific cell or the whole row. Defaults to "none".
|
|
15
19
|
* - `rowIndex: number` — Specifies the row index of the cell that is currently in focus.
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* - "cell" : Indicating that cells can have a focus.
|
|
8
8
|
* - "row" : Indicating that entire rows can have a focus.
|
|
9
9
|
*
|
|
10
|
+
* The table does **not** evaluate this type: every focus model has one focused cell (`getFocus()`), and the frame
|
|
11
|
+
* around it is drawn for all three values. To hide the frame use {@link TableOptionsIf.focusFrame}
|
|
12
|
+
* (`"never"`, or `"keyboard"` = only while the table is used with the keyboard) – not `new FocusModel("none")`.
|
|
13
|
+
*
|
|
10
14
|
* Typically, this type is used within the `FocusModel` class,
|
|
11
15
|
* specifically in the `constructor` and in the `setFocus` method,
|
|
12
16
|
* to set `selectionType` property and determine where the focus is set respectively.
|
|
@@ -70,6 +70,16 @@ export declare class MouseHandler {
|
|
|
70
70
|
* because a render replaced the pressed element; `eventTarget` is then the detached pressed element).
|
|
71
71
|
*/
|
|
72
72
|
private handleClick;
|
|
73
|
+
/**
|
|
74
|
+
* After the second click of a double click was reported: an app that renders in its click handler (it marks the
|
|
75
|
+
* clicked cell or tile with `repaint()`) replaces the clicked element – the browser then sends "dblclick" to the
|
|
76
|
+
* detached element and it never reaches the host: no editor, no `onCellActivated`. Then the double click is
|
|
77
|
+
* handled for the clicked cell – once this task is through and only if no native "dblclick" came (since 1.1.115).
|
|
78
|
+
*
|
|
79
|
+
* Call it before the click is reported; the returned function starts the check afterwards.
|
|
80
|
+
*/
|
|
81
|
+
private prepareLostDblClickCheck;
|
|
82
|
+
private checkLostDblClick;
|
|
73
83
|
/** "area:row:column" of a cell given explicitly (same format as {@link getCellKey}). */
|
|
74
84
|
private toCellKey;
|
|
75
85
|
/** Target data of a replaced element: area, row and column come from the pressed cell (current row index). */
|
|
@@ -684,6 +684,12 @@ export declare class RenderScope extends EleScope {
|
|
|
684
684
|
private rowNumberWidth?;
|
|
685
685
|
/** true while the containers are adjusted to a new row number width (no second change in that nested pass). */
|
|
686
686
|
protected adjustingRowNumberWidth: boolean;
|
|
687
|
+
/** The last input in the table was a key – with `focusFrame: "keyboard"` the focus frame is drawn. @since 1.1.115 */
|
|
688
|
+
protected keyboardModality: boolean;
|
|
689
|
+
/** Is the frame of the focused cell drawn now ({@link TableOptionsIf.focusFrame})? @since 1.1.115 */
|
|
690
|
+
protected isFocusFrameVisible(): boolean;
|
|
691
|
+
/** Hook at the start of every render pass (before anything is drawn). @since 1.1.115 */
|
|
692
|
+
protected beforeRenderPass(): void;
|
|
687
693
|
/** Guards {@link adjustRelativeColumnWidthsToScrollBar} against re-entry. */
|
|
688
694
|
private adjustingRelativeWidths;
|
|
689
695
|
/** The width % and weight columns were last computed for (`TableModelIf.setParentWidth`), -1 = unknown. */
|
|
@@ -129,7 +129,7 @@ export declare class ConvenienceDomService {
|
|
|
129
129
|
* `--ge-table-focus-outline-color` resp. `--ge-table-focus-border`). Hidden from screen readers – they get the
|
|
130
130
|
* focus through `aria-activedescendant`.
|
|
131
131
|
*/
|
|
132
|
-
addFocusBorderDivs(parent: HTMLDivElement, geo: GeoData, style: HtmlStyle): HTMLDivElement;
|
|
132
|
+
addFocusBorderDivs(parent: HTMLDivElement, geo: GeoData, style: HtmlStyle, inside?: boolean): HTMLDivElement;
|
|
133
133
|
addVerticalBorder(geo: GeoData, parent: HTMLDivElement, clazz?: string): HTMLDivElement;
|
|
134
134
|
addDiv(parent: HTMLDivElement, geo: GeoData, clazz?: string): HTMLDivElement;
|
|
135
135
|
applyStyleString(div: HTMLDivElement, style: string): void;
|
|
@@ -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
|
/**
|
|
@@ -54,6 +54,8 @@ import { ShortcutActionIdMapping } from './action/shortcut-actionid-mapping.type
|
|
|
54
54
|
import { AppendRowsOptionsIf, AppendRowsResultIf, RowsAppendedOptionsIf } from './live-append/append-rows-options.if.js';
|
|
55
55
|
import { FilterFunction } from './data/common/filter-function.js';
|
|
56
56
|
import { GeFilterEventSource } from './data/common/event/ge-filter-event.js';
|
|
57
|
+
import { GeCellActivateSource } from './data/common/event/ge-cell-activate-event.js';
|
|
58
|
+
import { TileLayoutIf } from './data/tablemodel/areamodel/tile-layout.if.js';
|
|
57
59
|
import { ColumnFilterService } from './column-filter/column-filter-service.js';
|
|
58
60
|
import { ColumnFilterIf, ColumnFiltersMap } from './column-filter/column-filter.if.js';
|
|
59
61
|
import { FilterRowService } from './column-filter/filter-row-service.js';
|
|
@@ -418,6 +420,95 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
418
420
|
private getLastShownColumnIndex;
|
|
419
421
|
/** Home, End, Ctrl+Home, Ctrl+End, Page Up/Down and Enter in the body; `undefined` = not such an action. */
|
|
420
422
|
private onBodyNavigation;
|
|
423
|
+
/**
|
|
424
|
+
* Reports {@link EventListenerIf.onCellActivated} for a body cell ("open": Enter or double click). Nothing for a
|
|
425
|
+
* cell outside the body and for an empty tile of a cover grid.
|
|
426
|
+
*
|
|
427
|
+
* @param {number} rowIndex - display row index
|
|
428
|
+
* @param {number} columnIndex - model column index
|
|
429
|
+
* @param {GeCellActivateSource} source - keyboard, mouse or api
|
|
430
|
+
* @param {KeyboardEvent | MouseEvent} [originalEvent] - the key or mouse event
|
|
431
|
+
* @returns {boolean} true if it was reported
|
|
432
|
+
* @since 1.1.115
|
|
433
|
+
*/
|
|
434
|
+
activateCell(rowIndex: number, columnIndex: number, source: GeCellActivateSource, originalEvent?: KeyboardEvent | MouseEvent): boolean;
|
|
435
|
+
/**
|
|
436
|
+
* The tiles of the body if its cells are one sequence of items ({@link AreaModelIf.getTileLayout}, e.g. a cover
|
|
437
|
+
* grid) – `undefined` for a normal table.
|
|
438
|
+
*
|
|
439
|
+
* @returns {TileLayoutIf | undefined} the layout
|
|
440
|
+
* @since 1.1.115
|
|
441
|
+
*/
|
|
442
|
+
getTileLayout(): TileLayoutIf | undefined;
|
|
443
|
+
/**
|
|
444
|
+
* False for a body cell that must not get the focus: an empty tile behind the last item of a grid of tiles.
|
|
445
|
+
*
|
|
446
|
+
* @param {number} rowIndex - display row index
|
|
447
|
+
* @param {number} columnIndex - model column index
|
|
448
|
+
* @returns {boolean} true for every cell of a normal table
|
|
449
|
+
* @since 1.1.115
|
|
450
|
+
*/
|
|
451
|
+
canFocusBodyCell(rowIndex: number, columnIndex: number): boolean;
|
|
452
|
+
private static readonly tileActions;
|
|
453
|
+
/**
|
|
454
|
+
* Keyboard navigation in a grid of tiles: the items are one sequence ({@link navigateTiles}), empty tiles are never
|
|
455
|
+
* focused. Renders exactly once per key. `undefined` = not a navigation key or not a grid of tiles.
|
|
456
|
+
*/
|
|
457
|
+
private onTileNavigation;
|
|
458
|
+
/**
|
|
459
|
+
* Scrolls a body row into view (pixel-exact: to the top or to the bottom edge).
|
|
460
|
+
*
|
|
461
|
+
* @returns {boolean} true if the table was rendered at the new position – false if the row is visible already
|
|
462
|
+
*/
|
|
463
|
+
private showBodyRow;
|
|
464
|
+
/** The item that has the focus in a grid of tiles and its index when it got it (the focus follows the item). */
|
|
465
|
+
private focusedTile?;
|
|
466
|
+
private syncingTileFocus;
|
|
467
|
+
private tileFocusKnown;
|
|
468
|
+
/** Remembers the item under the focus (called for every focus change). */
|
|
469
|
+
private rememberFocusedTile;
|
|
470
|
+
/**
|
|
471
|
+
* A grid of tiles: the focus follows the **item**. Before a render pass draws the focus, the focused cell is
|
|
472
|
+
* compared with the remembered item (O(1)); only if another item sits there now (sorted, filtered, another number
|
|
473
|
+
* of tiles per row, new items) the item is searched once. An item that is gone hands the focus to the tile at its
|
|
474
|
+
* old index (the last item if there is none; no items: no focus).
|
|
475
|
+
*/
|
|
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;
|
|
503
|
+
/** True if an event comes from a form control, button, link or editable element (inside a cell, the editor …). */
|
|
504
|
+
private static isControlEvent;
|
|
505
|
+
/** A change of the focus frame (focusFrame "keyboard") that the next render pass has to draw. */
|
|
506
|
+
private focusFrameDirty;
|
|
507
|
+
/**
|
|
508
|
+
* The last input in the table was a key (true) or a mouse press (false) – with `focusFrame: "keyboard"` the frame
|
|
509
|
+
* of the focused cell appears resp. disappears with the next render (at once if no other render follows).
|
|
510
|
+
*/
|
|
511
|
+
private setKeyboardModality;
|
|
421
512
|
/** Enter on a body cell: toggles its row checkbox, otherwise expands/collapses its tree row. */
|
|
422
513
|
private activateBodyCell;
|
|
423
514
|
/** Arrow up in the first body row: the focus moves to the lowest header row (same column). */
|