@guiexpert/table 1.1.118 → 1.1.121
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 +8 -0
- package/index.cjs +34 -34
- package/index.js +2833 -2238
- package/lib/table/data/common/event/ge-column-move-event.d.ts +2 -2
- package/lib/table/data/common/event/ge-column-resize-event.d.ts +2 -1
- package/lib/table/data/options/table-options.d.ts +5 -0
- package/lib/table/data/options/table-options.if.d.ts +24 -0
- package/lib/table/event-listener.if.d.ts +5 -1
- package/lib/table/mouse-handler.d.ts +39 -0
- package/lib/table/render-scope.d.ts +112 -0
- package/lib/table/renderer/cell-render.if.d.ts +29 -2
- package/lib/table/renderer/renderer-cleanup-fn.type.d.ts +15 -1
- package/lib/table/service/convenience-dom.service.d.ts +36 -0
- package/lib/table/service/dom-service.if.d.ts +17 -0
- package/lib/table/service/simple-dom-service.d.ts +1 -0
- package/lib/table/table-api.d.ts +38 -0
- package/lib/table/table-scope.d.ts +33 -1
- package/llms.txt +40 -0
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ import { GeColumnDragEventType } from './ge-column-resize-event.js';
|
|
|
22
22
|
* @since 1.1.110
|
|
23
23
|
*/
|
|
24
24
|
export declare class GeColumnMoveEvent {
|
|
25
|
-
/** Phase: `"start"`, `"end"` or `"cancel"` (Escape: the old order is back). */
|
|
25
|
+
/** Phase: `"start"`, `"end"` or `"cancel"` (Escape, or the mouseup never arrived – since 1.1.119: the old order is back). */
|
|
26
26
|
readonly type: GeColumnDragEventType;
|
|
27
27
|
/** Model index of the column when the drag started. */
|
|
28
28
|
readonly fromIndex: number;
|
|
@@ -37,7 +37,7 @@ export declare class GeColumnMoveEvent {
|
|
|
37
37
|
/** The browser event behind it (mouse up; `undefined` for {@link TableApi.cancelColumnDrag}). */
|
|
38
38
|
readonly originalEvent?: Event | undefined;
|
|
39
39
|
constructor(
|
|
40
|
-
/** Phase: `"start"`, `"end"` or `"cancel"` (Escape: the old order is back). */
|
|
40
|
+
/** Phase: `"start"`, `"end"` or `"cancel"` (Escape, or the mouseup never arrived – since 1.1.119: the old order is back). */
|
|
41
41
|
type: GeColumnDragEventType,
|
|
42
42
|
/** Model index of the column when the drag started. */
|
|
43
43
|
fromIndex: number,
|
|
@@ -3,7 +3,8 @@ import { ColumnDefIf } from '../../tablemodel/column/column-def.if.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Phase of a column drag (resize or move): `"start"` (the mouse moved past the drag threshold of 4 px, or a double
|
|
5
5
|
* click on the resize handle), `"end"` (released – also outside of the table) or `"cancel"` (Escape,
|
|
6
|
-
* {@link TableApi.cancelColumnDrag}
|
|
6
|
+
* {@link TableApi.cancelColumnDrag}, or the mouseup never reached the page – a native drag, a system dialog,
|
|
7
|
+
* {@link TableApi.releaseMouse}, since 1.1.119: the old width resp. order is back).
|
|
7
8
|
*
|
|
8
9
|
* @category Column drag
|
|
9
10
|
* @since 1.1.110
|
|
@@ -132,6 +132,11 @@ export declare class TableOptions implements TableOptionsIf {
|
|
|
132
132
|
focusFrame?: FocusFrameMode;
|
|
133
133
|
/** A cover grid fills the whole width ({@link TableOptionsIf.coverGridFill}). Not set = off. @since 1.1.117 */
|
|
134
134
|
coverGridFill?: boolean | Partial<CoverGridFillOptionsIf>;
|
|
135
|
+
/**
|
|
136
|
+
* Rows that stay visible keep their cells when the table scrolls or the selection changes
|
|
137
|
+
* ({@link TableOptionsIf.keepCellsOnScroll}). Not set = `true`. @since 1.1.120
|
|
138
|
+
*/
|
|
139
|
+
keepCellsOnScroll?: boolean;
|
|
135
140
|
/** Persistent filter row below the column titles ({@link TableOptionsIf.filterRow}). Not set = off. @since 1.1.114 */
|
|
136
141
|
filterRow?: boolean | Partial<FilterRowOptionsIf>;
|
|
137
142
|
/** Per-column filter menu popup ({@link TableOptionsIf.columnFilterMenu}). Not set = off. @since 1.1.114 */
|
|
@@ -562,6 +562,30 @@ export interface TableOptionsIf {
|
|
|
562
562
|
* @see [Live demo: cover grid](https://gui.expert/showcase/covergrid/run/)
|
|
563
563
|
*/
|
|
564
564
|
coverGridFill?: boolean | Partial<CoverGridFillOptionsIf>;
|
|
565
|
+
/**
|
|
566
|
+
* Rows that stay visible keep their cells (default `true`, since 1.1.120): a scroll step builds only the rows that
|
|
567
|
+
* come into view – the others keep their row element **with** its cells, only its position changes. The same for a
|
|
568
|
+
* change of selection or focus (a click, an arrow key): only the rows whose selection or focus changed are built.
|
|
569
|
+
* A cell renderer therefore runs **once when its row comes into view** (and with every `repaint()`,
|
|
570
|
+
* `updateCells()`, sorting, filter … as before), its cleanup function once when the row leaves the view or is built
|
|
571
|
+
* again. An `<img>`, `<canvas>`, `<video>`, `<input>` or framework component in a cell is not created again while
|
|
572
|
+
* its row is visible: no reloading images, focus and caret stay.
|
|
573
|
+
*
|
|
574
|
+
* Before 1.1.120 every render pass – also every scroll step – emptied the table and built every visible cell again.
|
|
575
|
+
* Consequence of the new default: data you change **without telling the table** (no `repaint()`, no
|
|
576
|
+
* `updateCells()`) no longer shows up with the next scroll step or click, but when the row is built again.
|
|
577
|
+
* `false` brings back the old behaviour (every pass builds every cell).
|
|
578
|
+
*
|
|
579
|
+
* Horizontal scrolling builds the cells of the scrollable columns as before (the fixed columns stay); a body with
|
|
580
|
+
* col-/rowspans is always built completely.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* // a renderer that must run for every scroll step (rare): switch it off
|
|
584
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), keepCellsOnScroll: false };
|
|
585
|
+
*
|
|
586
|
+
* @since 1.1.120
|
|
587
|
+
*/
|
|
588
|
+
keepCellsOnScroll?: boolean;
|
|
565
589
|
/**
|
|
566
590
|
* The state the table starts with: column layout, sorting, tree, checked and selected rows … – e.g. loaded from
|
|
567
591
|
* your server ({@link TableApi.getState}, {@link EventListenerIf.onStateChanged}). A state stored by
|
|
@@ -46,7 +46,11 @@ export interface EventListenerIf extends EventFocusChangedListenerIf, EventSelec
|
|
|
46
46
|
onContextmenu(evt: GeMouseEvent): void;
|
|
47
47
|
/** The mouse moved over the table (cell under the mouse in `evt`). Called often – keep it cheap. */
|
|
48
48
|
onMouseMoved(evt: GeMouseEvent): void;
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* A drag with the mouse ended (column resize, column move or range selection). Since 1.1.119 also when the mouseup
|
|
51
|
+
* never reached the page (a native drag out of the window, a system dialog, {@link TableApi.releaseMouse}): then
|
|
52
|
+
* with the last position of the drag.
|
|
53
|
+
*/
|
|
50
54
|
onMouseDraggingEnd(evt: GeMouseEvent): void;
|
|
51
55
|
/** The mouse is being dragged; `evt.draggingX` / `evt.draggingY` hold the distance. */
|
|
52
56
|
onMouseDragging(evt: GeMouseEvent): void;
|
|
@@ -47,6 +47,12 @@ export declare class MouseHandler {
|
|
|
47
47
|
private dragGeneration;
|
|
48
48
|
/** The end of the last drag, until its frame ran – a new mousedown handles it at once (see {@link flushDraggingEnd}). */
|
|
49
49
|
private pendingDraggingEnd?;
|
|
50
|
+
/** The button of the press as a bit of `MouseEvent.buttons` (left 1, right 2, middle 4) – see {@link isPressLost}. */
|
|
51
|
+
private pressButtons;
|
|
52
|
+
/** The listeners of the current press at the document and the window (mouseup, lost press) – aborted when it ends. */
|
|
53
|
+
private pressAbort?;
|
|
54
|
+
/** `onMouseDragging` was reported for the current press – only then {@link releaseMouse} reports the end. */
|
|
55
|
+
private dragReported;
|
|
50
56
|
constructor(tableScope: TableScope);
|
|
51
57
|
/**
|
|
52
58
|
* Handles the "contextmenu" event.
|
|
@@ -115,8 +121,38 @@ export declare class MouseHandler {
|
|
|
115
121
|
private isInteractiveCellElement;
|
|
116
122
|
private getArrowColumnIndex;
|
|
117
123
|
private onMouseDown;
|
|
124
|
+
/** True if a mousedown shows that the press of the table is over: the same button again, or its button is not held. */
|
|
125
|
+
private isStalePress;
|
|
126
|
+
/** The bit of `MouseEvent.buttons` for the button of a mousedown (`button` 0 → 1, 1 → 4, 2 → 2, 3 → 8, 4 → 16). */
|
|
127
|
+
private static buttonsOf;
|
|
128
|
+
/**
|
|
129
|
+
* True if the table is pressed but the button of the press is not held any more: the mouseup never reached the
|
|
130
|
+
* page – a native drag out of the window (Tauri, Electron), an HTML5 drag, a system dialog (since 1.1.119).
|
|
131
|
+
*/
|
|
132
|
+
private isPressLost;
|
|
133
|
+
/**
|
|
134
|
+
* Listens at the document and the window while the button is held: for the mouseup outside of the host, and for
|
|
135
|
+
* everything that tells that no mouseup will come ({@link releaseMouse}). {@link endPressListeners} removes them.
|
|
136
|
+
*/
|
|
137
|
+
private listenToPress;
|
|
138
|
+
private endPressListeners;
|
|
118
139
|
/** A mouseup that did not reach the host (released outside the table). */
|
|
119
140
|
private onDocumentMouseUp;
|
|
141
|
+
/**
|
|
142
|
+
* Ends the press without a mouseup ({@link TableApi.releaseMouse}): the table is not pressed any more. Nothing is
|
|
143
|
+
* dropped – a running column resize or move is cancelled like with Escape (old width resp. order, end with type
|
|
144
|
+
* `"cancel"`), a range selection stays as it is, no click is reported. `onMouseDraggingEnd` is called once if
|
|
145
|
+
* `onMouseDragging` was (with the last position of the press). Without a press nothing happens.
|
|
146
|
+
*
|
|
147
|
+
* Called by the table itself as soon as it notices that the button is not held any more: a mouse movement in the
|
|
148
|
+
* document without the button, `pointercancel`, an HTML5 `dragstart` that is not prevented, the window losing the
|
|
149
|
+
* focus, the next mousedown of that button.
|
|
150
|
+
*
|
|
151
|
+
* @param {Event} [originalEvent] - the event that told it (passed on to the column event)
|
|
152
|
+
* @returns {boolean} true if a press was ended
|
|
153
|
+
* @since 1.1.119
|
|
154
|
+
*/
|
|
155
|
+
releaseMouse(originalEvent?: Event): boolean;
|
|
120
156
|
/**
|
|
121
157
|
* Live data (since 1.1.108): a drag in progress (range selection) keeps its start row when rows were removed at the
|
|
122
158
|
* start or inserted.
|
|
@@ -147,6 +183,9 @@ export declare class MouseHandler {
|
|
|
147
183
|
* True while the mouse button is held in the table (a click or a drag in progress) – live data does not jump to
|
|
148
184
|
* the end then (`tableApi.appendRows({ follow: "auto" })`, since 1.1.108).
|
|
149
185
|
*
|
|
186
|
+
* Since 1.1.119 a press also ends without a mouseup, as soon as the table notices that the button is not held any
|
|
187
|
+
* more (see {@link releaseMouse}).
|
|
188
|
+
*
|
|
150
189
|
* @returns {boolean} true between mousedown and mouseup
|
|
151
190
|
*/
|
|
152
191
|
isButtonDown(): boolean;
|
|
@@ -154,6 +154,37 @@ export declare class RenderScope extends EleScope {
|
|
|
154
154
|
* @since 1.1.99
|
|
155
155
|
*/
|
|
156
156
|
tableSheet?: TableSheet;
|
|
157
|
+
/**
|
|
158
|
+
* The next render pass may keep the rows that did not change – set by the passes that only scroll or only change
|
|
159
|
+
* selection and focus ({@link renderKeepingRows}), read and cleared at the start of {@link adjustAfterScrolling}.
|
|
160
|
+
* Every other pass builds every cell, as before 1.1.120.
|
|
161
|
+
*/
|
|
162
|
+
private keepRowsRequested;
|
|
163
|
+
/** A repaint was asked for but did not run yet ({@link invalidateRenderedRows}): the drawn rows may be outdated. */
|
|
164
|
+
private renderedRowsStale;
|
|
165
|
+
/** This pass keeps rows (and header/footer) that did not change. */
|
|
166
|
+
private keepRowsInPass;
|
|
167
|
+
/** The drawn body rows by row index – only while rows are recorded ({@link canRecordBodyRows}). */
|
|
168
|
+
private readonly renderedRows;
|
|
169
|
+
/** The last body pass recorded its rows (otherwise the rows in the DOM are unknown: build all). */
|
|
170
|
+
private renderedRowsRecorded;
|
|
171
|
+
/** Columns and widths of the last pass – another layout builds everything. */
|
|
172
|
+
private renderedLayoutKey;
|
|
173
|
+
/** Header and footer of the last pass: built for this key (horizontal offset, header focus). */
|
|
174
|
+
private renderedFixedAreas;
|
|
175
|
+
private renderPassId;
|
|
176
|
+
private bodyPass?;
|
|
177
|
+
/** The row side whose cells are built now: their cleanup functions and custom classes are recorded in it. */
|
|
178
|
+
private buildingSide?;
|
|
179
|
+
/** The horizontal offset of the center cells in this pass (see adjustColumnsToRowParent). */
|
|
180
|
+
private centerLeftOfPass;
|
|
181
|
+
/**
|
|
182
|
+
* Selection or focus changed since the last render pass ({@link TableScope} sets it in `onSelectionChanged` and
|
|
183
|
+
* `onFocusChanged`) – see {@link BodyPass.checkCustom}.
|
|
184
|
+
*/
|
|
185
|
+
protected selectionOrFocusChanged: boolean;
|
|
186
|
+
/** Focused cell, header focus and focus frame of the last pass (models that change without an event). */
|
|
187
|
+
private renderedFocusKey;
|
|
157
188
|
/** Positions of the body rows (prefix sums of the heights + detail rows), see {@link getBodyRowLayout}. */
|
|
158
189
|
private readonly bodyRowLayout;
|
|
159
190
|
private bodyRowLayoutDirty;
|
|
@@ -375,6 +406,36 @@ export declare class RenderScope extends EleScope {
|
|
|
375
406
|
* @since 1.1.107
|
|
376
407
|
*/
|
|
377
408
|
onViewportScroll(): void;
|
|
409
|
+
/**
|
|
410
|
+
* A render pass for a change that touches **only** the scroll position, the selection, the focus or the focus frame:
|
|
411
|
+
* rows that stay visible and whose selection and focus are the same keep their cells (their renderers do not run,
|
|
412
|
+
* images are not loaded again, an input keeps focus and caret), header and footer are not built again. Everything
|
|
413
|
+
* else – data, columns, sizes, sorting, filter … – must call {@link repaint} or {@link repaintHard}.
|
|
414
|
+
*
|
|
415
|
+
* With `keepCellsOnScroll: false`, a body with col-/rowspans or a repaint that is still due
|
|
416
|
+
* ({@link invalidateRenderedRows}) it builds every cell like {@link repaint}.
|
|
417
|
+
*
|
|
418
|
+
* @since 1.1.120
|
|
419
|
+
*/
|
|
420
|
+
renderKeepingRows(): void;
|
|
421
|
+
/**
|
|
422
|
+
* Marks the drawn rows as outdated: the next render pass builds every cell, also a pass that would keep rows (a
|
|
423
|
+
* scroll step). Called where a repaint is asked for but runs later (the debounced repaint after a mouse click).
|
|
424
|
+
*
|
|
425
|
+
* @since 1.1.120
|
|
426
|
+
*/
|
|
427
|
+
invalidateRenderedRows(): void;
|
|
428
|
+
/** `keepCellsOnScroll` (default true). */
|
|
429
|
+
private isKeepCellsEnabled;
|
|
430
|
+
/**
|
|
431
|
+
* Are the body rows recorded (and may they be kept)? Not with `keepCellsOnScroll: false`, and not with col-/rowspans
|
|
432
|
+
* in the body: span cells lie outside their rows and are positioned by the scroll offset.
|
|
433
|
+
*/
|
|
434
|
+
private canRecordBodyRows;
|
|
435
|
+
/** Columns and widths the rows are built for (all changes of them repaint – this is the safety net). */
|
|
436
|
+
private createLayoutKey;
|
|
437
|
+
/** Header or footer: not built again by a pass that keeps rows if nothing it shows changed. */
|
|
438
|
+
private adjustFixedArea;
|
|
378
439
|
/**
|
|
379
440
|
* Recalculates the column widths of the table (% and weight columns depend on the available width) and repaints.
|
|
380
441
|
*
|
|
@@ -590,6 +651,57 @@ export declare class RenderScope extends EleScope {
|
|
|
590
651
|
* @protected
|
|
591
652
|
*/
|
|
592
653
|
protected adjustArea(areaIdent: AreaIdent, yStart?: number): void;
|
|
654
|
+
/** The loop over the body rows left the viewport at this row: last (fully) visible row, number of displayed rows. */
|
|
655
|
+
private setLastVisibleBodyRow;
|
|
656
|
+
/** What the body pass needs for every row – read once (selection and focus model, the drawn center columns). */
|
|
657
|
+
private createBodyPass;
|
|
658
|
+
/**
|
|
659
|
+
* What a row shows of the selection and the focus in the columns `from … to` – what changes without new data. The
|
|
660
|
+
* same key as when the row was drawn: the row is kept as it is. Another key: selection and focus are drawn again
|
|
661
|
+
* on the kept cells ({@link redecorateRowSide}).
|
|
662
|
+
*/
|
|
663
|
+
private bodyRowStateKey;
|
|
664
|
+
/**
|
|
665
|
+
* What the **cells** of a row show beyond their data and that may change without a pass that builds everything: an
|
|
666
|
+
* open in-cell editor (`getEditRenderer`), the cell that owns the editor above it (`aria-owns`), pending values of a
|
|
667
|
+
* batch edit, a row that is dragged, an open detail row. Another key: the cells are built again.
|
|
668
|
+
*/
|
|
669
|
+
private bodyRowEditorKey;
|
|
670
|
+
/** Custom classes and styles of a cell as one text ('' = none) – see {@link RenderedRowSide.customKeys}. */
|
|
671
|
+
private static customKeyOf;
|
|
672
|
+
/**
|
|
673
|
+
* Draws selection and focus of a kept row side again **without touching its cells** (their content, an `<img>`, an
|
|
674
|
+
* input with its focus stay): the selection backgrounds and the focus frame are replaced – at the places a pass that
|
|
675
|
+
* builds the row puts them –, the cells get their selection class, `aria-selected` and the row its `aria-selected`.
|
|
676
|
+
*
|
|
677
|
+
* @returns {boolean} false if that is not enough and the side must be built: a cell is missing, or the custom
|
|
678
|
+
* classes or styles of a cell (`getCustomClassesAt`, `getCustomStyleAt`) changed – e.g. a model that marks the
|
|
679
|
+
* selected row with a class of its own
|
|
680
|
+
*/
|
|
681
|
+
private redecorateRowSide;
|
|
682
|
+
/**
|
|
683
|
+
* Draws a body row whose sides are recorded: a side that did not change (same height, same position of its cells,
|
|
684
|
+
* same selection and focus) keeps its row div with all cells – only `top` is set. Any other side is built (again)
|
|
685
|
+
* and put behind the row before it, so the order of the row divs stays the order of the rows.
|
|
686
|
+
*/
|
|
687
|
+
private renderRecordedBodyRow;
|
|
688
|
+
private renderRecordedRowSide;
|
|
689
|
+
/** The custom classes and styles of the drawn cells of a kept side are the ones they were built with. */
|
|
690
|
+
private hasSameCustomKeys;
|
|
691
|
+
/**
|
|
692
|
+
* An open in-cell editor (`getEditRenderer`) in a kept row gets the focus back, as it does when its cell is built
|
|
693
|
+
* (a click on another cell or on the scroll bar took it; the grid ignores the arrow keys while the editor is open).
|
|
694
|
+
*/
|
|
695
|
+
private refocusInCellEditor;
|
|
696
|
+
/** Calls the cleanup functions of the cells of a row side – once (the list is emptied first). */
|
|
697
|
+
private runSideCleanups;
|
|
698
|
+
private runRowCleanups;
|
|
699
|
+
/** After the loop of a pass that keeps rows: the rows that were not drawn left the view. */
|
|
700
|
+
private removeRowsOutOfView;
|
|
701
|
+
/** Forgets all recorded rows and calls the cleanup functions of their cells (the areas are emptied by the caller). */
|
|
702
|
+
private dropRenderedRows;
|
|
703
|
+
/** The recorded side of a body row that holds a cell div. */
|
|
704
|
+
private findRenderedSide;
|
|
593
705
|
/** Number of visible persistent filter rows (0 without filter row; overridden in {@link TableScope}). @since 1.1.114 */
|
|
594
706
|
protected getFilterRowCount(): number;
|
|
595
707
|
/**
|
|
@@ -8,7 +8,19 @@ import { RendererCleanupFnType } from './renderer-cleanup-fn.type.js';
|
|
|
8
8
|
* Assign it per column and area (`columnDef.rendererMap.body = …`, or `bodyRenderer` in {@link ColumnDef.create})
|
|
9
9
|
* or return it from {@link AreaModelIf.getCellRenderer}.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* **When it runs** (since 1.1.120): only for visible cells – **once when the row comes into view**, and again with
|
|
12
|
+
* every repaint that may show other data (`repaint()`, `repaintHard()`, `updateCells()`, sorting, filter, new column
|
|
13
|
+
* widths …). Scrolling, a click or an arrow key do **not** call it again for a row that stays visible: the row keeps
|
|
14
|
+
* its cells, so an `<img>`, `<canvas>`, `<input>` or framework component you create here stays the same element (no
|
|
15
|
+
* image is loaded again, focus and caret stay). The cleanup function you return runs once – when the row leaves the
|
|
16
|
+
* view, when the cell is built again, or when the table is destroyed.
|
|
17
|
+
*
|
|
18
|
+
* Consequences: read what the cell shows from `cellValue` / the model **in `render()`** and tell the table when data
|
|
19
|
+
* changed ({@link TableApi.repaint}, {@link TableApi.updateCells}) – it no longer shows up by itself with the next
|
|
20
|
+
* scroll step. A renderer whose look depends on the selection or the focus is not called when they change (the table
|
|
21
|
+
* draws its own selection and focus on the kept cells); use `getCustomClassesAt()` for that – a changed class builds
|
|
22
|
+
* the row again – or call `repaint()` in `onSelectionChanged`. {@link TableOptionsIf.keepCellsOnScroll} `false`
|
|
23
|
+
* brings back the behaviour before 1.1.120 (every render pass builds every visible cell).
|
|
12
24
|
*
|
|
13
25
|
* @example
|
|
14
26
|
* class StatusBadgeRenderer implements CellRendererIf {
|
|
@@ -23,6 +35,20 @@ import { RendererCleanupFnType } from './renderer-cleanup-fn.type.js';
|
|
|
23
35
|
* }
|
|
24
36
|
* columnDefs[9].rendererMap.body = new StatusBadgeRenderer();
|
|
25
37
|
*
|
|
38
|
+
* @example
|
|
39
|
+
* // A picture per row: the <img> is created once while the row is visible – not for every scroll step
|
|
40
|
+
* class PictureRenderer implements CellRendererIf {
|
|
41
|
+
* render(cellDiv: HTMLDivElement, _rowIndex: number, _columnIndex: number, _areaIdent: AreaIdent,
|
|
42
|
+
* _areaModel: AreaModelIf, url: unknown): RendererCleanupFnType | undefined {
|
|
43
|
+
* const img = document.createElement("img");
|
|
44
|
+
* img.src = String(url);
|
|
45
|
+
* img.alt = "";
|
|
46
|
+
* img.loading = "lazy";
|
|
47
|
+
* cellDiv.appendChild(img);
|
|
48
|
+
* return () => img.removeAttribute("src"); // once, when the row leaves the view: stops a running download
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
26
52
|
* @see Training: [Cell renderers](https://gui.expert/training/cell-renderers/),
|
|
27
53
|
* [Framework components as cells](https://gui.expert/training/framework-components/)
|
|
28
54
|
*
|
|
@@ -39,7 +65,8 @@ export interface CellRendererIf {
|
|
|
39
65
|
* @param areaModel - the model of this area (e.g. for `getRowByIndex(rowIndex)`)
|
|
40
66
|
* @param cellValue - the value of the cell (`areaModel.getValueAt(rowIndex, columnIndex)`)
|
|
41
67
|
* @param domService - create and change elements through it (works with Angular's Renderer2, too)
|
|
42
|
-
* @returns optionally a cleanup function
|
|
68
|
+
* @returns optionally a cleanup function – called once when the cell goes away: its row leaves the view, the cell
|
|
69
|
+
* is built again (a repaint, `updateCells()`) or the table is destroyed
|
|
43
70
|
*/
|
|
44
71
|
render(cellDiv: HTMLDivElement, rowIndex: number, columnIndex: number, areaIdent: AreaIdent, areaModel: AreaModelIf, cellValue: any, domService: DomServiceIf): RendererCleanupFnType | undefined;
|
|
45
72
|
}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* A function a {@link CellRendererIf} may return from `render()`: the table calls it **once** when the cell goes away
|
|
3
|
+
* – its row leaves the view (scrolling), the cell is built again (a repaint, `updateCells()`, sorting, filter …) or
|
|
4
|
+
* the table is destroyed. Remove listeners and timers, unmount a framework component, stop a download.
|
|
5
|
+
*
|
|
6
|
+
* Since 1.1.120 it is **not** called for every scroll step: rows that stay visible keep their cells
|
|
7
|
+
* ({@link TableOptionsIf.keepCellsOnScroll}).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const span = document.createElement("span");
|
|
11
|
+
* const timer = setInterval(() => { span.textContent = new Date().toLocaleTimeString(); }, 1000);
|
|
12
|
+
* const cleanup: RendererCleanupFnType = () => clearInterval(timer);
|
|
13
|
+
*
|
|
14
|
+
* @category Renderers & editing
|
|
15
|
+
*/
|
|
2
16
|
export type RendererCleanupFnType = Function;
|
|
@@ -117,6 +117,42 @@ export declare class ConvenienceDomService {
|
|
|
117
117
|
createAreaDivWithClass(clazz: string, parent: HTMLDivElement, areaIdent: AreaIdent, sideIdent: SideIdent): HTMLDivElement;
|
|
118
118
|
createDivWithClass(clazz: string, parent: HTMLDivElement): HTMLDivElement;
|
|
119
119
|
addRowDiv(divScope: DivScope, geo: GeoData, rowIndex: number | undefined, areaIdent: AreaIdent, sideIdent: SideIdent, text?: string): HTMLDivElement;
|
|
120
|
+
/**
|
|
121
|
+
* The row div of a row – a new one or the (emptied) one the row had before – with its classes, position and
|
|
122
|
+
* attributes, but **not** put into the area: {@link addRowDiv} appends it, {@link insertAfter} puts it at its place
|
|
123
|
+
* between rows that are kept (since 1.1.120).
|
|
124
|
+
*
|
|
125
|
+
* @param {DivScope} divScope - the area (its `cache` holds the row divs by row index)
|
|
126
|
+
* @param {GeoData} geo - position and size, `geo.index` = the row index
|
|
127
|
+
* @param {number} rowIndex - the row index
|
|
128
|
+
* @param {AreaIdent} areaIdent - header, body or footer
|
|
129
|
+
* @param {SideIdent} sideIdent - west, center or east
|
|
130
|
+
* @param {string} [text] - a text for debugging
|
|
131
|
+
* @returns {HTMLDivElement} the row div
|
|
132
|
+
* @since 1.1.120
|
|
133
|
+
*/
|
|
134
|
+
prepareRowDiv(divScope: DivScope, geo: GeoData, rowIndex: number | undefined, areaIdent: AreaIdent, sideIdent: SideIdent, text?: string): HTMLDivElement;
|
|
135
|
+
/**
|
|
136
|
+
* Puts a child directly behind another child of the parent (`previous` undefined: at the start). A child that is
|
|
137
|
+
* already there is **not** moved: moving an element in the DOM drops the focus and the caret of an input in it and
|
|
138
|
+
* restarts its CSS transitions.
|
|
139
|
+
*
|
|
140
|
+
* @param {HTMLElement} parent - the parent element
|
|
141
|
+
* @param {HTMLElement} child - the element to place
|
|
142
|
+
* @param {HTMLElement} [previous] - the child it follows
|
|
143
|
+
* @since 1.1.120
|
|
144
|
+
*/
|
|
145
|
+
insertAfter(parent: HTMLElement, child: HTMLElement, previous?: HTMLElement): void;
|
|
146
|
+
/**
|
|
147
|
+
* Puts a child before another child of the parent (`null`: at the end) – with {@link DomServiceIf.insertBefore} if
|
|
148
|
+
* the DOM service has it, otherwise directly.
|
|
149
|
+
*
|
|
150
|
+
* @param {HTMLElement} parent - the parent element
|
|
151
|
+
* @param {HTMLElement} child - the element to insert or to move
|
|
152
|
+
* @param {HTMLElement | null} before - the child it is put in front of
|
|
153
|
+
* @since 1.1.120
|
|
154
|
+
*/
|
|
155
|
+
insertBefore(parent: HTMLElement, child: HTMLElement, before: HTMLElement | null): void;
|
|
120
156
|
addColumnDiv(para: AddColumnDivPara): HTMLDivElement;
|
|
121
157
|
addCheckboxToDiv(parent: HTMLDivElement, checkedType: CheckedType, areaIdent: AreaIdent, rowIndex: number, ariaLabel?: string): HTMLDivElement;
|
|
122
158
|
addLabelDiv(parent: HTMLDivElement, text?: string, firstTreeColumn?: boolean, rowIndex?: number, columnIndex?: number, areaIdent?: AreaIdent): HTMLDivElement;
|
|
@@ -37,4 +37,21 @@ export interface DomServiceIf {
|
|
|
37
37
|
* @since 1.1.91
|
|
38
38
|
*/
|
|
39
39
|
removeAttribute?(ele: HTMLElement, key: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Inserts a child before another child of the parent (`before === null`: at the end). Optional (since 1.1.120): rows
|
|
42
|
+
* that scroll into view above the rows that are kept are inserted before them. Without it the table calls
|
|
43
|
+
* `parent.insertBefore(child, before)` itself.
|
|
44
|
+
*
|
|
45
|
+
* @param {HTMLElement} parent - the parent element
|
|
46
|
+
* @param {HTMLElement} child - the element to insert (or to move)
|
|
47
|
+
* @param {HTMLElement | null} before - the child the new one is put in front of, `null` = append
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* insertBefore(parent: HTMLElement, child: HTMLElement, before: HTMLElement | null): void {
|
|
51
|
+
* parent.insertBefore(child, before);
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* @since 1.1.120
|
|
55
|
+
*/
|
|
56
|
+
insertBefore?(parent: HTMLElement, child: HTMLElement, before: HTMLElement | null): void;
|
|
40
57
|
}
|
|
@@ -11,4 +11,5 @@ export declare class SimpleDomService implements DomServiceIf {
|
|
|
11
11
|
createText(value: string): any;
|
|
12
12
|
setAttribute(ele: HTMLElement, key: string, value: string): void;
|
|
13
13
|
removeAttribute(ele: HTMLElement, key: string): void;
|
|
14
|
+
insertBefore(parent: HTMLElement, child: HTMLElement, before: HTMLElement | null): void;
|
|
14
15
|
}
|
package/lib/table/table-api.d.ts
CHANGED
|
@@ -1175,6 +1175,44 @@ export declare class TableApi {
|
|
|
1175
1175
|
* @since 1.1.110
|
|
1176
1176
|
*/
|
|
1177
1177
|
cancelColumnDrag(): void;
|
|
1178
|
+
/**
|
|
1179
|
+
* Ends the mouse press of the table when its `mouseup` never reaches the page – e.g. because the app hands a drag
|
|
1180
|
+
* over to the operating system (Tauri / Electron `startDrag`: the mouse belongs to the system from then on).
|
|
1181
|
+
*
|
|
1182
|
+
* Nothing is dropped: a running column resize or move is cancelled like with Escape (`onColumnResizeEnd` /
|
|
1183
|
+
* `onColumnMoveEnd` with type `"cancel"`), a range selection stays as it is, no click is reported, and
|
|
1184
|
+
* `onMouseDraggingEnd` is called once if `onMouseDragging` was. Without a press nothing happens.
|
|
1185
|
+
*
|
|
1186
|
+
* The table also notices it by itself – with the next mouse movement without the button, a `pointercancel`, an
|
|
1187
|
+
* HTML5 `dragstart` or when the window loses the focus. Call this method when the app knows the moment: until
|
|
1188
|
+
* then {@link isMouseDown} is `true` and live data does not follow the end ({@link appendRows}).
|
|
1189
|
+
*
|
|
1190
|
+
* @example
|
|
1191
|
+
* // the app drags a file out of the window: the system takes the mouse, no mouseup will come
|
|
1192
|
+
* declare function startNativeDrag(): Promise<void>;
|
|
1193
|
+
*
|
|
1194
|
+
* tableApi.releaseMouse();
|
|
1195
|
+
* await startNativeDrag();
|
|
1196
|
+
*
|
|
1197
|
+
* @since 1.1.119
|
|
1198
|
+
*/
|
|
1199
|
+
releaseMouse(): void;
|
|
1200
|
+
/**
|
|
1201
|
+
* True while a mouse button is held in the table: between `mousedown` and `mouseup` – or {@link releaseMouse},
|
|
1202
|
+
* or the moment the table notices that the button is not held any more. Live data does not jump to the end
|
|
1203
|
+
* meanwhile ({@link appendRows} with `follow: "auto"`).
|
|
1204
|
+
*
|
|
1205
|
+
* A row drag at its handle and the fill handle use pointer events: see {@link isRowDragging} and {@link isFilling}.
|
|
1206
|
+
*
|
|
1207
|
+
* @example
|
|
1208
|
+
* if (!tableApi.isMouseDown()) {
|
|
1209
|
+
* tableApi.setRows(newOrders); // not while the user clicks or drags
|
|
1210
|
+
* }
|
|
1211
|
+
*
|
|
1212
|
+
* @returns {boolean} true while the button is held in the table
|
|
1213
|
+
* @since 1.1.119
|
|
1214
|
+
*/
|
|
1215
|
+
isMouseDown(): boolean;
|
|
1178
1216
|
/**
|
|
1179
1217
|
* Recalculates the dimensions of all wrapper elements in the table.
|
|
1180
1218
|
*
|
|
@@ -142,6 +142,8 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
142
142
|
private mouseStartColumnIndex;
|
|
143
143
|
/** The column resize or move of the current press (prompt 022) – `undefined` without an allowed column action. */
|
|
144
144
|
private columnDrag?;
|
|
145
|
+
/** Counts the presses that ended without a mouseup ({@link mousePressLost}) – a drag frame in progress stops. */
|
|
146
|
+
private pressLostCount;
|
|
145
147
|
private dragFrom;
|
|
146
148
|
private lastDragFrom;
|
|
147
149
|
private lastDragTo;
|
|
@@ -921,6 +923,17 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
921
923
|
* @since 1.1.110
|
|
922
924
|
*/
|
|
923
925
|
cancelColumnDrag(originalEvent?: Event): void;
|
|
926
|
+
/**
|
|
927
|
+
* The press ended without a mouseup ({@link MouseHandler.releaseMouse}, {@link TableApi.releaseMouse}): nothing is
|
|
928
|
+
* dropped. A running column resize or move is cancelled like with Escape (`onColumnResizeEnd` / `onColumnMoveEnd`
|
|
929
|
+
* with type `"cancel"`), the column action of the press is forgotten, then `onMouseDraggingEnd` is reported if a
|
|
930
|
+
* drag was.
|
|
931
|
+
*
|
|
932
|
+
* @param {GeMouseEvent} [draggingEndEvent] - the last position of the drag (only if `onMouseDragging` was reported)
|
|
933
|
+
* @param {Event} [originalEvent] - the event that told that the button is not held any more
|
|
934
|
+
* @since 1.1.119
|
|
935
|
+
*/
|
|
936
|
+
mousePressLost(draggingEndEvent?: GeMouseEvent, originalEvent?: Event): void;
|
|
924
937
|
/** Reports a column drag to the listener (and the subscribers). */
|
|
925
938
|
private emitColumnDragEvent;
|
|
926
939
|
/**
|
|
@@ -1034,13 +1047,32 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
1034
1047
|
* @returns {void}
|
|
1035
1048
|
*/
|
|
1036
1049
|
onMouseClicked(evt: GeMouseEvent, previousEvt: GeMouseEvent | undefined): boolean;
|
|
1037
|
-
|
|
1050
|
+
/** The scheduled repaint keeps the rows that did not change (it was asked for by selection/focus changes only). */
|
|
1051
|
+
private pendingRepaintKeepsRows;
|
|
1052
|
+
/** The same for a repaint that {@link cancelPendingRepaint} took out (the mouse handler holds it until mouseup). */
|
|
1053
|
+
private cancelledRepaintKeepsRows;
|
|
1054
|
+
/**
|
|
1055
|
+
* Repaints a moment later (1 ms): after the events of the current mouse click (a repaint replaces cells – the
|
|
1056
|
+
* browser would send `click`/`dblclick` to a removed element).
|
|
1057
|
+
*
|
|
1058
|
+
* @param {boolean} [keepRows=false] - true: only selection, focus or the focus frame changed – rows whose selection
|
|
1059
|
+
* and focus are the same keep their cells ({@link renderKeepingRows}, since 1.1.120). false: data may have
|
|
1060
|
+
* changed, every cell is built; until then also a scroll step builds every cell.
|
|
1061
|
+
*/
|
|
1062
|
+
debounceRepaint(keepRows?: boolean): void;
|
|
1038
1063
|
/**
|
|
1039
1064
|
* Cancels a repaint scheduled by {@link debounceRepaint}.
|
|
1040
1065
|
*
|
|
1041
1066
|
* @returns true if a repaint was pending
|
|
1042
1067
|
*/
|
|
1043
1068
|
cancelPendingRepaint(): boolean;
|
|
1069
|
+
/**
|
|
1070
|
+
* Schedules the repaint again that {@link cancelPendingRepaint} took out (the mouse handler after `mouseup`) – a
|
|
1071
|
+
* repaint that keeps rows stays one.
|
|
1072
|
+
*
|
|
1073
|
+
* @since 1.1.120
|
|
1074
|
+
*/
|
|
1075
|
+
resumeCancelledRepaint(): void;
|
|
1044
1076
|
publishGeMouseEvent(evt: GeMouseEvent): void;
|
|
1045
1077
|
onFocusChanged(sm: FocusModelIf): void;
|
|
1046
1078
|
/**
|