@guiexpert/table 1.1.91 → 1.1.92
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 +5 -1
- package/css/main.css +79 -0
- package/css/table-classes.css +63 -0
- package/css/table-color-vars.css +16 -0
- package/index.cjs +58 -34
- package/index.d.ts +11 -0
- package/index.js +2425 -1243
- package/lib/table/aria/live-announcer.d.ts +9 -0
- package/lib/table/crud/crud-table-model-factory.d.ts +8 -0
- package/lib/table/data/common/event/ge-state-change-event.d.ts +30 -0
- package/lib/table/data/options/auto-restore-options.d.ts +14 -2
- package/lib/table/data/options/auto-restore-options.if.d.ts +94 -52
- package/lib/table/data/options/default-row-id.d.ts +4 -0
- package/lib/table/data/options/overlay-options.d.ts +30 -0
- package/lib/table/data/options/overlay-options.if.d.ts +79 -0
- package/lib/table/data/options/table-options.d.ts +3 -0
- package/lib/table/data/options/table-options.if.d.ts +35 -0
- package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +7 -0
- package/lib/table/data/tablemodel/areamodel/area-model-cell-groups.d.ts +31 -0
- package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +13 -0
- package/lib/table/data/tablemodel/areamodel/area-model-tree.d.ts +9 -0
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +19 -0
- package/lib/table/data/tablemodel/areamodel/cover-grid-body-model.d.ts +7 -0
- package/lib/table/data/tablemodel/cellgroup/cell-group.d.ts +2 -0
- package/lib/table/data/tablemodel/cellgroup/cell-group.if.d.ts +6 -0
- package/lib/table/data/tablemodel/column/column-visibility.d.ts +5 -0
- package/lib/table/ele-scope.d.ts +17 -0
- package/lib/table/event-adapter.d.ts +3 -0
- package/lib/table/event-listener.if.d.ts +8 -0
- package/lib/table/mouse-handler.d.ts +2 -0
- package/lib/table/overlay/calc-overlay-kind.d.ts +31 -0
- package/lib/table/overlay/ge-overlay-kind.type.d.ts +17 -0
- package/lib/table/overlay/table-overlay.d.ts +108 -0
- package/lib/table/render-scope.d.ts +26 -2
- package/lib/table/service/convenience-dom.service.d.ts +1 -1
- package/lib/table/state/state-storage.if.d.ts +39 -0
- package/lib/table/state/table-state-migration.d.ts +36 -0
- package/lib/table/state/table-state-part.d.ts +13 -0
- package/lib/table/state/table-state.if.d.ts +181 -0
- package/lib/table/state/table-state.service.d.ts +158 -0
- package/lib/table/table-api.d.ts +154 -0
- package/lib/table/table-scope.d.ts +78 -31
- package/package.json +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
import { TableStateIf, TableStatePart } from './table-state.if.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Collects and applies the {@link TableStateIf} of one table, stores it ({@link AutoRestoreOptionsIf}) and reports
|
|
6
|
+
* changes ({@link EventListenerIf.onStateChanged}). One instance per {@link TableScope} (`tableScope.stateService`);
|
|
7
|
+
* use the methods of {@link TableApi} instead.
|
|
8
|
+
*
|
|
9
|
+
* Changes are only marked ({@link markDirty}); after {@link TableOptionsIf.stateChangedDebounceDelay} the dirty
|
|
10
|
+
* parts are computed once, compared with the last reported state, stored with ONE storage write and reported with
|
|
11
|
+
* ONE event – no storage access per scroll frame.
|
|
12
|
+
*
|
|
13
|
+
* @category Internals
|
|
14
|
+
* @since 1.1.92
|
|
15
|
+
*/
|
|
16
|
+
export declare class TableStateService {
|
|
17
|
+
private readonly scope;
|
|
18
|
+
/** Suffix of the storage key: `<key>tableState`. */
|
|
19
|
+
static readonly STORAGE_SUFFIX = "tableState";
|
|
20
|
+
/** Parts that need a pass over all rows: no baseline at the start, computed only when they are used. */
|
|
21
|
+
private static readonly EXPENSIVE;
|
|
22
|
+
/** The restore of the first `firstInit()` is running (or has not finished). */
|
|
23
|
+
private restoring;
|
|
24
|
+
private started;
|
|
25
|
+
private destroyed;
|
|
26
|
+
private readonly dirty;
|
|
27
|
+
private timer?;
|
|
28
|
+
/** JSON per part of the last reported (or restored) state. */
|
|
29
|
+
private readonly lastReported;
|
|
30
|
+
/** The last reported state – a flush recomputes only the dirty parts. */
|
|
31
|
+
private reported;
|
|
32
|
+
/** The scroll position of the last reported state (a number compare – no string prefixes). */
|
|
33
|
+
private reportedScroll?;
|
|
34
|
+
/** The last stored JSON (no second write for the same state). */
|
|
35
|
+
private lastPersisted?;
|
|
36
|
+
/** The keys before 1.1.92 are removed with the first save of this table. */
|
|
37
|
+
private legacyRemoved;
|
|
38
|
+
/** Properties of the sorted columns, primary key first (the header shows only the sort states). */
|
|
39
|
+
private sortPriority;
|
|
40
|
+
/** The widths of the column definitions before anything was restored (a width is stored only if it changed). */
|
|
41
|
+
private readonly initialWidths;
|
|
42
|
+
/** The state right after the table was built – {@link resetState}. */
|
|
43
|
+
private defaultState?;
|
|
44
|
+
/** The state applied at the start: stored state over `initialState`. */
|
|
45
|
+
private startState;
|
|
46
|
+
private custom;
|
|
47
|
+
private warnedNoRowObject;
|
|
48
|
+
private warnedNoId;
|
|
49
|
+
constructor(scope: TableScope);
|
|
50
|
+
/**
|
|
51
|
+
* First `firstInit()` only, before `tableModel.init()`: reads the start state and applies the header groups
|
|
52
|
+
* (they decide which column definitions exist).
|
|
53
|
+
*/
|
|
54
|
+
initBeforeModel(): void;
|
|
55
|
+
/** After `tableModel.init()`: remembers the defaults, applies the column layout. */
|
|
56
|
+
initAfterModel(): void;
|
|
57
|
+
/** After the external filter: tree, sorting, checked rows, selection. */
|
|
58
|
+
initAfterFilter(): void;
|
|
59
|
+
/** After the layout (scroll height known): scroll position; the restore is finished. */
|
|
60
|
+
initAfterLayout(): void;
|
|
61
|
+
/**
|
|
62
|
+
* The current state (all parts, or the given ones). Parts that do not apply to the table are left out (e.g. `tree`
|
|
63
|
+
* without a tree, `columns` without column definitions).
|
|
64
|
+
*
|
|
65
|
+
* @param {TableStatePart[]} [parts] - the parts to read, default: all
|
|
66
|
+
* @returns {TableStateIf} the state
|
|
67
|
+
*/
|
|
68
|
+
getState(parts?: readonly TableStatePart[]): TableStateIf;
|
|
69
|
+
/**
|
|
70
|
+
* Applies the parts of a state (only the parts it contains, optionally only the given ones) and repaints.
|
|
71
|
+
* Reports the change with `onStateChanged` and stores it.
|
|
72
|
+
*
|
|
73
|
+
* @param {Partial<TableStateIf>} state - the state
|
|
74
|
+
* @param {TableStatePart[]} [parts] - only these parts
|
|
75
|
+
*/
|
|
76
|
+
applyState(state: Partial<TableStateIf>, parts?: readonly TableStatePart[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Back to the state right after the table was built (the code's column layout, sort icons, header groups, without
|
|
79
|
+
* the restored state; tree, checked rows and selection when they are stored or were given as `initialState`),
|
|
80
|
+
* scrolled to the top, custom data removed – and removes the stored state.
|
|
81
|
+
*/
|
|
82
|
+
resetState(): void;
|
|
83
|
+
/** Sets the part `custom` (data of the application). */
|
|
84
|
+
setCustomState(custom: unknown): void;
|
|
85
|
+
/** The column was sorted by a header click / `sortByColumn` – it becomes the primary sort key. */
|
|
86
|
+
sortedByColumn(property: string | undefined): void;
|
|
87
|
+
/**
|
|
88
|
+
* Marks a part as changed. After {@link TableOptionsIf.stateChangedDebounceDelay} the state is stored and
|
|
89
|
+
* reported – only if it really changed. No effect before the table is built.
|
|
90
|
+
*
|
|
91
|
+
* @param {TableStatePart} part - the changed part
|
|
92
|
+
*/
|
|
93
|
+
markDirty(part: TableStatePart): void;
|
|
94
|
+
/** Called after each render pass: marks the scroll position as changed if it changed. */
|
|
95
|
+
rendered(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Stores and reports the dirty parts now (normally called by the timer of {@link markDirty}).
|
|
98
|
+
*/
|
|
99
|
+
flush(): void;
|
|
100
|
+
/** Stops the timer and stores / reports a pending change (called by `TableScope.destroy()`). */
|
|
101
|
+
destroy(): void;
|
|
102
|
+
private storageKey;
|
|
103
|
+
private storage;
|
|
104
|
+
/** The parts switched on in {@link AutoRestoreOptionsIf}. */
|
|
105
|
+
private persistedParts;
|
|
106
|
+
private warnWithoutStorageKey;
|
|
107
|
+
/** The stored state (or the one of the keys before 1.1.92) over `tableOptions.initialState`. */
|
|
108
|
+
private readStartState;
|
|
109
|
+
private persist;
|
|
110
|
+
private rememberAsReported;
|
|
111
|
+
private partJson;
|
|
112
|
+
private computePart;
|
|
113
|
+
private computeColumns;
|
|
114
|
+
private computeSort;
|
|
115
|
+
private computeScroll;
|
|
116
|
+
private computeTree;
|
|
117
|
+
private computeChecked;
|
|
118
|
+
private computeSelection;
|
|
119
|
+
/**
|
|
120
|
+
* A cell range → ids and properties. A range to the last row / column (`MAX_SAFE_INTEGER`) has no `toRowId` /
|
|
121
|
+
* `toProperty` ("to the end"); a range over all rows / columns has neither.
|
|
122
|
+
*/
|
|
123
|
+
private toStateRange;
|
|
124
|
+
/** @returns true if a group changed */
|
|
125
|
+
private applyHeaderGroups;
|
|
126
|
+
/**
|
|
127
|
+
* Order, visibility and widths of the columns.
|
|
128
|
+
*
|
|
129
|
+
* @param {TableColumnStateIf[]} columns - the stored columns
|
|
130
|
+
* @param {boolean} resetMissingWidths - columns without width get the width of the code back (applyState)
|
|
131
|
+
* @returns true if the widths must be recalculated (a `%` or weight width came back)
|
|
132
|
+
*/
|
|
133
|
+
private applyColumns;
|
|
134
|
+
private applyTree;
|
|
135
|
+
private applySort;
|
|
136
|
+
private applyChecked;
|
|
137
|
+
private applySelection;
|
|
138
|
+
private applyScroll;
|
|
139
|
+
private columnDefs;
|
|
140
|
+
private body;
|
|
141
|
+
private headerGroupModel;
|
|
142
|
+
/** Warn about rows without id only for parts that are stored (a `getState()` for an own use stays quiet). */
|
|
143
|
+
private warns;
|
|
144
|
+
/** The own `getRowId`, `undefined` for the default of {@link AutoRestoreOptions} (or none). */
|
|
145
|
+
private ownGetRowId;
|
|
146
|
+
/** The id of the displayed row at `index`. */
|
|
147
|
+
private idAt;
|
|
148
|
+
/**
|
|
149
|
+
* The id of a row (tree rows: of `row.data`): an own `getRowId`, otherwise the property `id` or `uuid`. Rows
|
|
150
|
+
* without id are not stored – the JSON fallback of the default `getRowId` would write whole rows (personal data)
|
|
151
|
+
* into the storage. Rows without an object get an id only from an own `getRowId` that declares the second
|
|
152
|
+
* parameter (`(_row, rowIndex) => rowIndex`).
|
|
153
|
+
*/
|
|
154
|
+
private idOfRow;
|
|
155
|
+
/** id → displayed row index (one pass over the displayed rows). */
|
|
156
|
+
private rowIndexMap;
|
|
157
|
+
private walkTree;
|
|
158
|
+
}
|
package/lib/table/table-api.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GeOverlayKind } from './overlay/ge-overlay-kind.type.js';
|
|
2
|
+
import { TableStateIf, TableStatePart } from './state/table-state.if.js';
|
|
1
3
|
import { SortState } from './data/common/sort-state.type.js';
|
|
2
4
|
import { TableScope } from './table-scope.js';
|
|
3
5
|
import { ColumnDefIf } from './data/tablemodel/column/column-def.if.js';
|
|
@@ -36,6 +38,7 @@ import { AreaModelIf } from './data/tablemodel/areamodel/area-model.if.js';
|
|
|
36
38
|
* | redraw | {@link repaint} (same row count), {@link repaintHard} (row count or heights changed) |
|
|
37
39
|
* | columns | {@link autoResizeColumns}, {@link setColumnWidth}, {@link recalcColumnWidths} |
|
|
38
40
|
* | tree | {@link expandAll}, {@link collapseAll}, {@link setRowExpanded} |
|
|
41
|
+
* | state | {@link getState}, {@link applyState}, {@link resetState} (with {@link TableOptionsIf.autoRestoreOptions}) |
|
|
39
42
|
* | lifecycle | {@link destroy} |
|
|
40
43
|
*
|
|
41
44
|
* @example
|
|
@@ -605,6 +608,157 @@ export declare class TableApi {
|
|
|
605
608
|
* @see Training: [Accessible tables: keyboard and screen readers](https://gui.expert/training/accessibility/)
|
|
606
609
|
*/
|
|
607
610
|
announce(text: string): void;
|
|
611
|
+
/**
|
|
612
|
+
* Shows "Loading…" with a CSS spinner over the body – e.g. while a server answers. The header and footer stay
|
|
613
|
+
* readable; rows already shown stay visible under a semi-transparent layer. By default mouse and editing on the
|
|
614
|
+
* body are blocked until {@link hideOverlay} ({@link OverlayOptionsIf.blockInteractionWhileLoading}).
|
|
615
|
+
* Screen readers: the host gets `aria-busy="true"`, the text is announced.
|
|
616
|
+
*
|
|
617
|
+
* Texts, delay and own content: {@link TableOptionsIf.overlayOptions}. Framework wrappers have a `loading` prop
|
|
618
|
+
* that calls this method (no re-creation of the table).
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* tableApi.showLoadingOverlay();
|
|
622
|
+
* fetch("/api/orders")
|
|
623
|
+
* .then(response => response.json())
|
|
624
|
+
* .then((orders: object[]) => {
|
|
625
|
+
* tableApi.setRows(orders);
|
|
626
|
+
* tableApi.repaintHard();
|
|
627
|
+
* })
|
|
628
|
+
* .finally(() => tableApi.hideOverlay()); // 0 rows? "No rows to show" appears by itself
|
|
629
|
+
*
|
|
630
|
+
* @param {string} [text] - text for this overlay only, e.g. `"Saving…"`; default {@link OverlayOptionsIf.loadingText}
|
|
631
|
+
* @since 1.1.92
|
|
632
|
+
* @see Training: [Live data](https://gui.expert/training/live-data/)
|
|
633
|
+
*/
|
|
634
|
+
showLoadingOverlay(text?: string): void;
|
|
635
|
+
/**
|
|
636
|
+
* Shows the "no rows" overlay, also over rows – e.g. when the server says "no permission". An empty body shows
|
|
637
|
+
* "No rows to show" anyway ({@link OverlayOptionsIf.autoNoRows}); this method is for other cases.
|
|
638
|
+
* Ends with {@link hideOverlay}.
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* tableApi.showNoRowsOverlay("You may not see these orders");
|
|
642
|
+
*
|
|
643
|
+
* @param {string} [text] - text for this overlay only; default {@link OverlayOptionsIf.noRowsText}
|
|
644
|
+
* @since 1.1.92
|
|
645
|
+
*/
|
|
646
|
+
showNoRowsOverlay(text?: string): void;
|
|
647
|
+
/**
|
|
648
|
+
* Ends the overlay shown by {@link showLoadingOverlay} or {@link showNoRowsOverlay}.
|
|
649
|
+
* "No rows to show" / "No matching rows" are not ended: they show the state of the body and stay as long as it
|
|
650
|
+
* is empty (switch them off with `overlayOptions: { autoNoRows: false }`).
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* tableApi.showLoadingOverlay("Saving…");
|
|
654
|
+
* save(order).finally(() => tableApi.hideOverlay());
|
|
655
|
+
*
|
|
656
|
+
* @since 1.1.92
|
|
657
|
+
*/
|
|
658
|
+
hideOverlay(): void;
|
|
659
|
+
/**
|
|
660
|
+
* The overlay shown now: `"none"`, `"loading"`, `"noRows"` or `"noMatches"`. During
|
|
661
|
+
* {@link OverlayOptionsIf.loadingDelayInMs} the loading overlay is requested but not shown yet – the automatic
|
|
662
|
+
* overlay stays meanwhile (e.g. `"noRows"` of an empty table), so a fast answer causes no flicker.
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* if (tableApi.getOverlayState() === "noMatches") {
|
|
666
|
+
* resetFilterButton.hidden = false;
|
|
667
|
+
* }
|
|
668
|
+
*
|
|
669
|
+
* @returns {GeOverlayKind} the shown overlay
|
|
670
|
+
* @since 1.1.92
|
|
671
|
+
*/
|
|
672
|
+
getOverlayState(): GeOverlayKind;
|
|
673
|
+
/**
|
|
674
|
+
* The state of the table as plain JSON: column layout (order, widths, visibility), sorting, scroll position,
|
|
675
|
+
* expanded tree nodes, checked and selected rows, header groups and your own data ({@link setCustomState}).
|
|
676
|
+
* Columns are identified by property and rows by id ({@link AutoRestoreOptionsIf.getRowId}), never by index.
|
|
677
|
+
* Parts that do not apply to this table are left out (e.g. `tree` for a flat table).
|
|
678
|
+
*
|
|
679
|
+
* Store it wherever you like and give it back with {@link applyState} or {@link TableOptionsIf.initialState};
|
|
680
|
+
* {@link TableOptionsIf.autoRestoreOptions} does this for you in `localStorage`.
|
|
681
|
+
*
|
|
682
|
+
* @param {TableStatePart[]} [parts] - only these parts, default: all
|
|
683
|
+
* @returns {TableStateIf} the state
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* const state = tableApi.getState(); // { version: 1, columns: [...], sort: [...], ... }
|
|
687
|
+
* await fetch("/api/prefs/orders", { method: "PUT", body: JSON.stringify(state) });
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* const layout = tableApi.getState(["columns", "sort"]); // only the layout, no scroll position or selection
|
|
691
|
+
*
|
|
692
|
+
* @see Training: [Remember the state](https://gui.expert/training/persist-state/)
|
|
693
|
+
* @since 1.1.92
|
|
694
|
+
*/
|
|
695
|
+
getState(parts?: TableStatePart[]): TableStateIf;
|
|
696
|
+
/**
|
|
697
|
+
* Applies a state from {@link getState} (or one written by hand) and repaints. Only the parts contained in the
|
|
698
|
+
* state are applied (optionally only the given ones); the others stay as they are – pass a part empty to reset it,
|
|
699
|
+
* e.g. `sort: []` (clears the sort icons; the rows keep their current order). Unknown columns and rows are ignored. The change is stored ({@link TableOptionsIf.autoRestoreOptions})
|
|
700
|
+
* and reported ({@link EventListenerIf.onStateChanged}).
|
|
701
|
+
*
|
|
702
|
+
* @param {Partial<TableStateIf>} state - the state
|
|
703
|
+
* @param {TableStatePart[]} [parts] - only these parts, default: all parts of the state
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* // two saved views of the same table
|
|
707
|
+
* const views: Record<string, TableStateIf> = {};
|
|
708
|
+
* views["compact"] = tableApi.getState(["columns"]);
|
|
709
|
+
* tableApi.applyState(views["compact"]);
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* tableApi.applyState({ sort: [{ property: "total", sortState: "desc" }] });
|
|
713
|
+
*
|
|
714
|
+
* @since 1.1.92
|
|
715
|
+
*/
|
|
716
|
+
applyState(state: Partial<TableStateIf>, parts?: TableStatePart[]): void;
|
|
717
|
+
/**
|
|
718
|
+
* Back to the state of the code: column layout, sort icons and header groups as they were right after the table was
|
|
719
|
+
* built (before a stored state was applied) – tree, checked and selected rows too when they are remembered
|
|
720
|
+
* ({@link TableOptionsIf.autoRestoreOptions}) or given as {@link TableOptionsIf.initialState} –, scrolled to the top,
|
|
721
|
+
* custom data removed. Deletes the stored state. The rows keep their current order (a table has no "unsorted" order
|
|
722
|
+
* to go back to); only the sort icons of the code come back.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* document.querySelector("#reset-layout")!.addEventListener("click", () => tableApi.resetState());
|
|
726
|
+
*
|
|
727
|
+
* @since 1.1.92
|
|
728
|
+
*/
|
|
729
|
+
resetState(): void;
|
|
730
|
+
/**
|
|
731
|
+
* Stores data of your application with the table state (part `custom`), e.g. the text of a filter field. It is
|
|
732
|
+
* reported with {@link EventListenerIf.onStateChanged}, stored with `autoRestoreCustomState` and returned by
|
|
733
|
+
* {@link getState} – also after a reload, so you can restore your filter in `tableReady`. Must be JSON.
|
|
734
|
+
*
|
|
735
|
+
* @param {unknown} custom - your data (JSON)
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* filterInput.addEventListener("input", () => {
|
|
739
|
+
* tableApi.setCustomState({ filter: filterInput.value });
|
|
740
|
+
* tableApi.externalFilterChanged();
|
|
741
|
+
* });
|
|
742
|
+
* // after a reload (tableReady):
|
|
743
|
+
* const custom = tableApi.getState(["custom"]).custom as { filter?: string } | undefined;
|
|
744
|
+
* filterInput.value = custom?.filter ?? "";
|
|
745
|
+
*
|
|
746
|
+
* @since 1.1.92
|
|
747
|
+
*/
|
|
748
|
+
setCustomState(custom: unknown): void;
|
|
749
|
+
/**
|
|
750
|
+
* Collapses or expands a header group ({@link CellGroupIf} with `toggle: true`) – like a click on its toggle.
|
|
751
|
+
*
|
|
752
|
+
* @param {string} id - {@link CellGroupIf.id}, otherwise the path of the labels, e.g. `"Customer"` or `"2026/Q1"`
|
|
753
|
+
* @param {boolean} collapsed - true = collapse
|
|
754
|
+
* @returns {boolean} false if the header has no such group
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* tableApi.setHeaderGroupCollapsed("Customer", true);
|
|
758
|
+
*
|
|
759
|
+
* @since 1.1.92
|
|
760
|
+
*/
|
|
761
|
+
setHeaderGroupCollapsed(id: string, collapsed?: boolean): boolean;
|
|
608
762
|
/**
|
|
609
763
|
* The header cell that has the keyboard focus. Arrow up in the first body row moves the focus into the header
|
|
610
764
|
* (Enter sorts or opens/closes a header group there); arrow down leaves it. The {@link FocusModelIf} holds
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TableOverlayChange } from './overlay/table-overlay.js';
|
|
2
|
+
import { GeOverlayKind } from './overlay/ge-overlay-kind.type.js';
|
|
1
3
|
import { TableModelIf } from './data/tablemodel/table-model.if.js';
|
|
2
4
|
import { AreaIdent } from './data/tablemodel/area-ident.type.js';
|
|
3
5
|
import { GeMouseEvent } from './data/common/event/ge-mouse-event.js';
|
|
@@ -10,6 +12,9 @@ import { SortState } from './data/common/sort-state.type.js';
|
|
|
10
12
|
import { StoreStateCollapsedExpandService } from './service/store-state-collapsed-expand.service.js';
|
|
11
13
|
import { StoreStateSortingService } from './service/store-state-sorting.service.js';
|
|
12
14
|
import { RenderScope } from './render-scope.js';
|
|
15
|
+
import { SortItem } from './data/common/sort-item.js';
|
|
16
|
+
import { TableStateService } from './state/table-state.service.js';
|
|
17
|
+
import { GeStateChangeEvent } from './data/common/event/ge-state-change-event.js';
|
|
13
18
|
import { InputHandler } from './input-handler.js';
|
|
14
19
|
import { SelectionService } from './selection/selection-service.js';
|
|
15
20
|
import { GeKeyEvent } from './data/common/event/ge-key-event.js';
|
|
@@ -72,8 +77,16 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
72
77
|
inputHandler: InputHandler;
|
|
73
78
|
resizeHandler: ResizeHandler;
|
|
74
79
|
shortcutService: ShortcutService;
|
|
80
|
+
/** @deprecated since 1.1.92 – always `undefined`; the state is kept by {@link stateService}. */
|
|
75
81
|
storeStateCollapsedExpandService?: StoreStateCollapsedExpandService;
|
|
82
|
+
/** @deprecated since 1.1.92 – always `undefined`; the state is kept by {@link stateService}. */
|
|
76
83
|
storeSortingService?: StoreStateSortingService;
|
|
84
|
+
/**
|
|
85
|
+
* Collects, applies, stores and reports the state of this table (column layout, sorting, scroll, tree, checked
|
|
86
|
+
* and selected rows …). Use {@link TableApi.getState} / {@link TableApi.applyState}.
|
|
87
|
+
* @since 1.1.92
|
|
88
|
+
*/
|
|
89
|
+
readonly stateService: TableStateService;
|
|
77
90
|
protected selectionService: SelectionService;
|
|
78
91
|
protected keyEvent?: GeKeyEvent;
|
|
79
92
|
private api;
|
|
@@ -83,8 +96,12 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
83
96
|
* @since 1.1.91
|
|
84
97
|
*/
|
|
85
98
|
readonly liveAnnouncer: LiveAnnouncer;
|
|
99
|
+
/** Keyboard actions ignored while a blocking loading overlay is shown ({@link OverlayOptionsIf.blockInteractionWhileLoading}). */
|
|
100
|
+
static actionsBlockedWhileLoading: ActionId[];
|
|
86
101
|
/** Delay of the "42 rows" announcement after a filter change (typing in a filter field: one announcement). */
|
|
87
102
|
static filterAnnouncementDelayInMs: number;
|
|
103
|
+
/** The text announced when the loading overlay appeared (dropped if loading ends before it is spoken). */
|
|
104
|
+
private lastLoadingAnnouncement?;
|
|
88
105
|
/** firstInit() has finished: announcements are made from now on (not for the initial filter). */
|
|
89
106
|
private initialized;
|
|
90
107
|
private mouseStartAction;
|
|
@@ -135,6 +152,38 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
135
152
|
* @since 1.1.91
|
|
136
153
|
*/
|
|
137
154
|
announce(text: string, delayInMs?: number): void;
|
|
155
|
+
/**
|
|
156
|
+
* Shows the loading overlay over the body (see {@link TableApi.showLoadingOverlay}).
|
|
157
|
+
*
|
|
158
|
+
* @param {string} [text] - text for this overlay, default {@link OverlayOptionsIf.loadingText}
|
|
159
|
+
* @since 1.1.92
|
|
160
|
+
*/
|
|
161
|
+
showLoadingOverlay(text?: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Shows the "no rows" overlay (see {@link TableApi.showNoRowsOverlay}).
|
|
164
|
+
*
|
|
165
|
+
* @param {string} [text] - text for this overlay, default {@link OverlayOptionsIf.noRowsText}
|
|
166
|
+
* @since 1.1.92
|
|
167
|
+
*/
|
|
168
|
+
showNoRowsOverlay(text?: string): void;
|
|
169
|
+
/**
|
|
170
|
+
* Ends an overlay shown by the API (see {@link TableApi.hideOverlay}).
|
|
171
|
+
*
|
|
172
|
+
* @since 1.1.92
|
|
173
|
+
*/
|
|
174
|
+
hideOverlay(): void;
|
|
175
|
+
/**
|
|
176
|
+
* The overlay shown now (see {@link TableApi.getOverlayState}).
|
|
177
|
+
*
|
|
178
|
+
* @since 1.1.92
|
|
179
|
+
*/
|
|
180
|
+
getOverlayState(): GeOverlayKind;
|
|
181
|
+
/**
|
|
182
|
+
* Screen readers: `aria-busy` while loading, the loading text is spoken; "no rows" is spoken when it appears
|
|
183
|
+
* after the start (not for the initially empty table). "No matching rows" is not spoken: the filter
|
|
184
|
+
* announcement ({@link AriaTextsIf.filtered}) already says it.
|
|
185
|
+
*/
|
|
186
|
+
protected onOverlayChanged(change: TableOverlayChange): void;
|
|
138
187
|
/** "12 cells copied" – the selected cells of the shown columns (without a selection: the focused cell). */
|
|
139
188
|
announceCopied(_text?: string): void;
|
|
140
189
|
/** The number of cells a copy takes: selected cells of shown columns (like CopyService), otherwise 1 (focus). */
|
|
@@ -280,8 +329,6 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
280
329
|
* @returns {boolean} false if the body is no tree or the state was already set
|
|
281
330
|
*/
|
|
282
331
|
setTreeRowExpanded(row: TreeRowIf<any>, expanded: boolean): boolean;
|
|
283
|
-
/** Remembers the expanded/collapsed state of a row (autoRestoreOptions.getRowId). */
|
|
284
|
-
private storeTreeRowState;
|
|
285
332
|
/**
|
|
286
333
|
* Toggles the checkbox state of a specific row in a table.
|
|
287
334
|
*
|
|
@@ -309,6 +356,12 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
309
356
|
cancelPendingRepaint(): boolean;
|
|
310
357
|
publishGeMouseEvent(evt: GeMouseEvent): void;
|
|
311
358
|
onFocusChanged(sm: FocusModelIf): void;
|
|
359
|
+
/**
|
|
360
|
+
* Reports a changed state to the event listener (called by {@link TableStateService}).
|
|
361
|
+
* @since 1.1.92
|
|
362
|
+
*/
|
|
363
|
+
stateChanged(evt: GeStateChangeEvent): void;
|
|
364
|
+
protected afterRenderPass(): void;
|
|
312
365
|
onSelectionChanged(sm: SelectionModelIf): void;
|
|
313
366
|
private selectionEventsHeld;
|
|
314
367
|
private heldSelectionModel?;
|
|
@@ -387,6 +440,21 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
387
440
|
*/
|
|
388
441
|
setSelectionModel(sm: SelectionModel, rerender?: boolean): void;
|
|
389
442
|
toggleHeaderGroup(mouseTargetData: MouseTargetData): void;
|
|
443
|
+
/**
|
|
444
|
+
* Collapses or expands a header group by its id ({@link TableApi.setHeaderGroupCollapsed}).
|
|
445
|
+
*
|
|
446
|
+
* @param {string} id - {@link CellGroupIf.id} or the path of the labels, e.g. `"Customer"`
|
|
447
|
+
* @param {boolean} collapsed - true = collapse
|
|
448
|
+
* @returns {boolean} false if the header has no such group
|
|
449
|
+
* @since 1.1.92
|
|
450
|
+
*/
|
|
451
|
+
setHeaderGroupCollapsed(id: string, collapsed: boolean): boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Rebuilds the layout after a header group was collapsed or expanded (other columns are shown) and marks the
|
|
454
|
+
* state as changed.
|
|
455
|
+
* @since 1.1.92
|
|
456
|
+
*/
|
|
457
|
+
headerGroupsChanged(): void;
|
|
390
458
|
/**
|
|
391
459
|
* Retrieves the selection model.
|
|
392
460
|
* @returns {SelectionModelIf | undefined} The selection model if available, otherwise undefined.
|
|
@@ -426,35 +494,6 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
426
494
|
* @return {void}
|
|
427
495
|
*/
|
|
428
496
|
private clearSelectionModel;
|
|
429
|
-
/**
|
|
430
|
-
* Restores the scroll position of the table if auto restore options are enabled.
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* @returns {void}
|
|
434
|
-
*/
|
|
435
|
-
private autoRestoreScrollPosition;
|
|
436
|
-
/**
|
|
437
|
-
* Automatically restores the sorting state of the table.
|
|
438
|
-
*
|
|
439
|
-
* @private
|
|
440
|
-
* @function autoRestoreSortingState
|
|
441
|
-
* @memberof ClassName
|
|
442
|
-
*
|
|
443
|
-
* @description
|
|
444
|
-
* This method checks if the autoRestoreSortingState option is enabled in the tableOptions.
|
|
445
|
-
* If enabled, it uses the storeSortingService to retrieve the sort items array.
|
|
446
|
-
* If there are sort items present, it applies them to the table's body model using the doSort method.
|
|
447
|
-
*
|
|
448
|
-
* @returns {void}
|
|
449
|
-
*/
|
|
450
|
-
private autoRestoreSortingState;
|
|
451
|
-
/**
|
|
452
|
-
* Restores the collapsed/expanded state of the rows in the table based on the autoRestoreOptions
|
|
453
|
-
* specified in the tableOptions. This method is private and should not be called directly.
|
|
454
|
-
*
|
|
455
|
-
* @private
|
|
456
|
-
*/
|
|
457
|
-
private autoRestoreCollapsedExpandedState;
|
|
458
497
|
/**
|
|
459
498
|
* Calculates a width per column that fits the widest text of header, body and footer.
|
|
460
499
|
*
|
|
@@ -492,6 +531,14 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
492
531
|
recalcWrappers(): void;
|
|
493
532
|
reSort(): void;
|
|
494
533
|
sort(compareFn: (a: any, b: any) => number): void;
|
|
534
|
+
/**
|
|
535
|
+
* Sorts the body by the given items (first = primary key) and sets the header icons – used to apply a stored
|
|
536
|
+
* state. Does not repaint.
|
|
537
|
+
*
|
|
538
|
+
* @param {SortItem[]} sortItems - column index and sort state per sorted column; `[]` only clears the icons
|
|
539
|
+
* @since 1.1.92
|
|
540
|
+
*/
|
|
541
|
+
applySortItems(sortItems: SortItem[]): void;
|
|
495
542
|
/**
|
|
496
543
|
* Sorts the (freshly filtered) body rows again, so a filter keeps the current order:
|
|
497
544
|
* the last `sort(compareFn)` call, otherwise the columns with a `sortState` (header icons).
|