@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
package/llms.txt
CHANGED
|
@@ -382,6 +382,30 @@ const column = ColumnDef.create({ property: "status", headerLabel: "Status", bod
|
|
|
382
382
|
`TrueFalseCellRenderer`, `CheckboxCellRenderer`, … Framework components as cells: `ComponentRendererWrapper` (React,
|
|
383
383
|
Preact, Vue, Svelte, Solid), Angular `RenderWrapperFactory.create(MyComponent, cdr)`.
|
|
384
384
|
- If you must build HTML: `escapeHtml(value)`. Buttons/inputs in a cell: `tabindex="-1"`. → instructions.md 6.1, 6.14
|
|
385
|
+
- **When `render()` runs (since 1.1.120):** once when the row comes into view, and with every repaint that may show
|
|
386
|
+
other data (`repaint()`, `repaintHard()`, `updateCells()`, sorting, filter). **Not** for every scroll step, click or
|
|
387
|
+
arrow key: a row that stays visible keeps its cells. The cleanup function runs once, when the row leaves the view
|
|
388
|
+
(or the cell is built again, or the table is destroyed).
|
|
389
|
+
|
|
390
|
+
**Pictures in cells** – create the `<img>` in the renderer; it is the same element while the row is visible (no
|
|
391
|
+
reload while scrolling or selecting, no cache "URL → element" needed):
|
|
392
|
+
|
|
393
|
+
```ts
|
|
394
|
+
import { AreaIdent, AreaModelIf, CellRendererIf, ColumnDef, RendererCleanupFnType, px200 } from "@guiexpert/table";
|
|
395
|
+
|
|
396
|
+
class PictureRenderer implements CellRendererIf {
|
|
397
|
+
render(cellDiv: HTMLDivElement, _rowIndex: number, _columnIndex: number, _areaIdent: AreaIdent,
|
|
398
|
+
_areaModel: AreaModelIf, url: unknown): RendererCleanupFnType | undefined {
|
|
399
|
+
const img = document.createElement("img");
|
|
400
|
+
img.src = String(url);
|
|
401
|
+
img.alt = "";
|
|
402
|
+
img.loading = "lazy";
|
|
403
|
+
cellDiv.appendChild(img);
|
|
404
|
+
return () => img.removeAttribute("src"); // once, when the row leaves the view: stops a running download
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const picture = ColumnDef.create({ property: "pictureUrl", headerLabel: "Picture", width: px200, bodyRenderer: new PictureRenderer() });
|
|
408
|
+
```
|
|
385
409
|
|
|
386
410
|
### R11 – Editing
|
|
387
411
|
|
|
@@ -638,6 +662,13 @@ Symptom → cause → fix.
|
|
|
638
662
|
- **`Maximum call stack size exceeded`** → `array.push(...rows)` with ~100,000+ rows → a `for` loop (or `appendRows`).
|
|
639
663
|
- **Clicks lost while the table updates** (before 1.1.108) → a render between `mousedown` and `mouseup` → update to
|
|
640
664
|
1.1.108; older: render only when the visible part changed.
|
|
665
|
+
- **After a drag out of the window (Tauri / Electron `startDrag`, HTML5 drag from a cell) the table stays "pressed":
|
|
666
|
+
no hover, selection or column follows the pointer without a button, the next click is ignored** (before 1.1.119) →
|
|
667
|
+
the system took the mouse, no `mouseup` reached the page → update to 1.1.119 (the press ends with the next mouse
|
|
668
|
+
movement without the button, a column drag is cancelled); an app that starts the native drag calls
|
|
669
|
+
`tableApi.releaseMouse()` right before it. Older: `host.dispatchEvent(new MouseEvent("mouseup"))`.
|
|
670
|
+
- **A test that drags with synthetic events stopped working in 1.1.119** → `new MouseEvent("mousemove")` has
|
|
671
|
+
`buttons: 0` = "the button is not held" → pass `buttons: 1` (also for `pointermove` of a row drag / fill handle).
|
|
641
672
|
- **Context menu right after creating the table is ignored** → the first 50 ms are swallowed → normal; Angular: use
|
|
642
673
|
`(contextMenu)` – `(contextmenu)` fires twice (also the native event).
|
|
643
674
|
- **Clicks arrive late in Angular/Vue** → `debounceMouseClickDelay` (150 ms) → `0` for immediate clicks (a double click
|
|
@@ -672,6 +703,10 @@ Symptom → cause → fix.
|
|
|
672
703
|
`ColumnDef.filter = { getValues }`) (R19).
|
|
673
704
|
- **Hiding the filter row (`setFilterRowVisible(false)`) still hides rows** → by design, toggling the filter row only
|
|
674
705
|
toggles the UI; active filters stay → call `tableApi.clearColumnFilters()` if you want to clear them too (R19).
|
|
706
|
+
- **A cell shows an old value after I changed my row object** (since 1.1.120) → rows that stay visible keep their
|
|
707
|
+
cells; scrolling or a click no longer rebuilds them → say that data changed: `updateCells([...])`, `repaint()` or
|
|
708
|
+
`repaintHard()` (R6). Same for a renderer whose look depends on the selection: `getCustomClassesAt()` or `repaint()`
|
|
709
|
+
in `onSelectionChanged`. Old behaviour: `tableOptions.keepCellsOnScroll: false`.
|
|
675
710
|
- **`AsyncBodyAreaModelObjectArray` cannot be imported** → unfinished, not exported → own `AreaModel` (R8, R17).
|
|
676
711
|
- **Invented APIs** – these do NOT exist: `getSelectedRows()`, `onKeyDown`, `api.addRow()`, `api.refresh()`,
|
|
677
712
|
`setData()`, `gridOptions`, `rowData`, `columnDefs` as a table option (it is a model parameter). Use R4–R7.
|
|
@@ -683,6 +718,7 @@ Full answers: instructions.md section 6.26 (https://github.com/guiexperttable/mo
|
|
|
683
718
|
- Rows appended continuously (live log, ticker) and keep the position or follow the end: `tableApi.repaintHard({ py })` – one render pass (since 1.1.107); follow the end with `py: Number.MAX_SAFE_INTEGER`.
|
|
684
719
|
- Clicks lost while the app renders (live tail, `repaint()`/`repaintHard()` between mousedown and mouseup): fixed in 1.1.108 – the table reports `mouseClicked` (and the double click) for the pressed cell itself, once, with the current index of that row object.
|
|
685
720
|
- Rows that keep coming (log, stream, ticker of trades): `tableApi.appendRows(rows, { follow: "auto", maxRows })` (since 1.1.108) – in place, O(k), one render, filter/sort only for new rows, selection/focus stay; freeze = `follow: false`, jump to the end = `repaintHard({ py: Number.MAX_SAFE_INTEGER })`. Own AreaModel: `rowsAppended(count, { removedAtStart })`. Not `addRows()`.
|
|
721
|
+
- Own drag out of the table (native drag in Tauri / Electron, files to the Finder): call `tableApi.releaseMouse()` right before the system takes the mouse – no `mouseup` will come (since 1.1.119; `tableApi.isMouseDown()` tells the state). The table also notices it by itself with the next mouse movement without the button, `pointercancel`, `dragstart` or window blur; a running column resize/move is cancelled (`type: "cancel"`), nothing is dropped, no click.
|
|
686
722
|
- `repaint()` = values changed, same row count; `repaintHard()` = row count or heights changed; `updateCells()` = single cells.
|
|
687
723
|
- Variable row heights: implement `getRowHeight(i)`; `getConstantRowHeight()` only if all rows are equally high. `defaultRowHeights` only applies to models the factory builds or whose `getRowHeight()` returns 0.
|
|
688
724
|
- Save the column layout when the user resizes or moves a column: `onColumnResizeEnd` / `onColumnMoveEnd` (wrappers `columnResizeEnd`, `columnMoveEnd`, since 1.1.110) – once per drag, after the change; read `tableApi.getState(["columns"])` there. Lock a column: `ColumnDef.resizable: false`, `movable: false`. Double click on the column border fits the width (`columnAutoWidth`, `tableApi.autoResizeColumn(column)`).
|
|
@@ -693,6 +729,8 @@ Full answers: instructions.md section 6.26 (https://github.com/guiexperttable/mo
|
|
|
693
729
|
- Cover grid in the full width (since 1.1.117): `tableOptions.coverGridFill: { tileWidth, aspectRatio, extraHeight }` – tiles stretch flush to the edge, a resize takes effect in the same frame; slider: `tableApi.setCoverGridFill({ tileWidth })`. → R21
|
|
694
730
|
- Cover grid warns "the body model has no row objects": fixed in 1.1.116 – its scroll state stores the first visible item (`id`/`uuid` or `getRowId(item, index)`), no warning; a resize or a new tile size keeps that item at the top. Never `getRowId: (_row, rowIndex) => rowIndex` for a cover grid (a row holds other items after a resize).
|
|
695
731
|
- `@guiexpert/demo-table-models` makes the bundle ~600 kB bigger: fixed in 1.1.116 (nothing computed on import, `"sideEffects": false`); an app with only `BookCoverRenderer` ≈ 11 kB minified.
|
|
732
|
+
- Pictures (or inputs, canvases, components) in cells flicker / reload while scrolling or clicking: fixed in 1.1.120 – rows that stay visible keep their cells, `render()` runs once per row in view, the cleanup once when it leaves. Remove caches "URL → element". → R10
|
|
733
|
+
- A changed row object does not show after scrolling (since 1.1.120): call `tableApi.updateCells(...)` / `repaint()` / `repaintHard()` – a visible row keeps its cells. A renderer that must run on every scroll step: `tableOptions.keepCellsOnScroll: false`. → R6, R10
|
|
696
734
|
- Empty table: the host div needs a fixed height and the stylesheet `@guiexpert/table/css/main.css`.
|
|
697
735
|
|
|
698
736
|
## Feature reference
|
|
@@ -728,10 +766,12 @@ What the table can do – one line per feature, details in instructions.md (each
|
|
|
728
766
|
- Spreadsheet mode (since 1.1.99): SpreadsheetFactory.create({ data: unknown[][], rowCount (100), columnCount (26), columnWidth, rowHeight, rowNumbers, locale, functions, tableOptions }) → { tableModel: SpreadsheetTableModel, tableOptions } – column letters (AreaModelSheetHeader), row numbers, sparse AreaModelSheet; preset tableOptions.spreadsheet: true | { editing, clipboard, undo, cellFormulas, fillHandle } (false = off) for any flat table (TableFactory columnLetters: true). FormulaBar(container, api) – address box + formula input. api.getActiveCell(), goToAddress("B2:C5"), insertRows(at, count), deleteRows, insertColumns, deleteColumns (references adjusted, one undo step, source "structure"), getSheetData() (inputs for JSON).
|
|
729
767
|
- Angular signal component (since 1.1.100, Angular 22 and later): TableSignalComponent, selector guiexpert-table-signal, from @guiexpert/angular-table@22.x – inputs (input()) tableModel (TableModelIf | undefined), tableOptions (default new TableOptions()), loading, debounceMouseClickDelay (150, 0 = synchronous); tableApi = model<TableApi | undefined>() → [(tableApi)]="api" with api = signal<TableApi | undefined>(undefined), (tableApiChange), viewChild(TableSignalComponent)?.tableApi(); set when the table is built, switches directly to the new API on a new model/options, undefined after destroy, written from outside = replaced. Outputs (output()): no tableReady (the API comes as the signal tableApi / tableApiChange), mouseClicked, mouseMoved, mouseDragging, mouseDraggingEnded, contextMenu (camelCase – TableComponent's (contextmenu) also receives the native MouseEvent first), scroll, modelChanged, selectionChanged, focusChanged, checkboxChanged, stateChanged, rowDragStart/Move/End, batchEditChanged, detailExpandedChanged, editingChanged, undoStackChanged, columnResizeStart/End, columnMoveStart/End (since 1.1.110) – events of the table (mouse, keyboard, scroll …) are emitted outside the Angular zone (write signals in handlers). effect() instead of ngOnChanges, no RxJS, zoneless (provideZonelessChangeDetection()), SSR: no table on the server. TableComponent (<guiexpert-table>) unchanged for Angular 14 – 22+.
|
|
730
768
|
- Column drag (since 1.1.110): events EventListenerIf.onColumnResizeStart/End (GeColumnResizeEvent: type "start" | "end" | "cancel", source "mouse" | "dblclick", columnIndex, columnDef, property, oldWidth, newWidth) and onColumnMoveStart/End (GeColumnMoveEvent: type, fromIndex, toIndex, columnDef, property, columnOrder, moved) – only user actions, once per drag, the end after the change, start after 4 px, Escape / tableApi.cancelColumnDrag() = "cancel", tableApi.isColumnDragging(); wrappers columnResizeStart/End, columnMoveStart/End. Locks: ColumnDef.resizable: false (no handle, no double click, no auto width), movable: false (fixed place, applyState keeps it); RowNumberColumnDef has both false; a column stays in its area (west/center/east). Double click on the resize handle fits the width (no sorting): tableOptions.columnAutoWidth: { doubleClick (true), maxRows (10,000: all body rows, above only the rendered rows), getWidth(ctx: ColumnAutoWidthContextIf { columnIndex, columnDef, property, source, firstRenderedRow, lastRenderedRow, measureText(text), getDefaultWidth() }) => number | undefined }, limited by minWidth/maxWidth; tableApi.autoResizeColumn(index | property | ColumnDef) → width | undefined.
|
|
769
|
+
- Mouse press without a mouseup (since 1.1.119): tableApi.releaseMouse() ends the press of the table (native drag out of the window, the system took the mouse), tableApi.isMouseDown(): boolean. Automatic: a mousemove anywhere in the document without the pressed button (MouseEvent.buttons), pointercancel, a dragstart that is not prevented, window blur or the next mousedown end a press whose mouseup never arrived – column resize/move cancelled like Escape (onColumnResizeEnd / onColumnMoveEnd type "cancel"), range selection kept, no onMouseClicked, onMouseDraggingEnd once if a drag was reported; row drag, fill handle and formula pointing end on a pointermove with buttons 0. Synthetic drags in tests need `buttons: 1`. No wrapper code (all wrappers pass the TableApi).
|
|
731
770
|
- Column filters, filter menu and column chooser (since 1.1.114): opt-in persistent filter row `tableOptions.filterRow: true | FilterRowOptionsIf` (visible, debounce, placeholder, height, clearButtonVisible, minInputWidthInPx), Excel-style per-column filter menu `tableOptions.columnFilterMenu: true | ColumnFilterMenuOptionsIf` (showCondition, showValues, applyOnChange, maxValues, virtualized unique-value checklist, async `ColumnDef.filter.getValues`), global `tableOptions.columnFilter: ColumnFilterOptionsIf` (`managed: true | false`, `caseSensitive`, `locale`, `maxValues`), `tableOptions.columnFilterTexts: ColumnFilterTextsIf`; per-column `ColumnDef.filter: false | "text" | "number" | "date" | "boolean" | ColumnFilterColumnOptionsIf` (type, valueGetter, caseSensitive, placeholder, getValues) and `ColumnDef.hideable: false`; shorthand syntax in filter row (`>100`, `10..20`, `=x`, `!=x`, `^a`, `z$`, `""`, `2026-01..2026-03`, tri-state boolean); `TableApi`: `setColumnFilter`, `setColumnFilters`, `clearColumnFilters`, `getColumnFilter`, `getColumnFilters`, `isColumnFiltered`, `setFilterRowVisible`, `isFilterRowVisible`, `showColumnFilterMenu`, `hideColumnFilterMenu`, `showColumnChooser`, `hideColumnChooser`; event `EventListenerIf.onFilterChanged(GeFilterEvent: filters, property, source, rowCount, unfilteredRowCount)` (wrappers: `filterChanged`); composes with `externalFilterFunction` (AND) and live `appendRows` (input focus/caret/IME preserved); state part `"filters"` (`TableStateIf.filters`, `filterRowVisible`, `autoRestoreOptions.autoRestoreFilterState`); keyboard `FOCUS_COLUMN_FILTER` (Ctrl/⌘+Shift+F), `OPEN_COLUMN_FILTER_MENU` (Alt+ArrowDown); top-layer popups (`popover="manual"` with fullscreen/Shadow DOM fallback), RTL & fixed columns; DOM-free engine `parseFilterInput`, `formatFilterCondition`, `compileSingleColumnFilter`, `compileColumnFilterPredicate`, `inferColumnFilterType`, `collectDistinctValues`; CSS `ge-table-filter-row*`, `ge-table-filter-menu*`, `ge-table-column-chooser*`, `--ge-table-filter-*`. Showcase `columnfilter`, demo `apps/table-demo/column-filter.html`.
|
|
732
771
|
- Live data / log tail (since 1.1.108): tableApi.appendRows(rows, { follow?: "auto" (default: stays at the end if it was at the end, else the first visible row stays) | true (always the end) | false (freeze), maxRows?: ring buffer – oldest rows removed from the start in blocks of ≥ 1 % }) → AppendRowsResultIf { added, shown, removed, following } | false (tree, row groups, pivot, spreadsheet, cell formulas) – AreaModelObjectArray body only, IN PLACE (pushes to your array, no copy), O(k): externalFilterFunction only for the new rows, sorted column / sort(fn) → merged in (binary search, behind equal rows); selection, focus, Shift+arrow anchor and checked rows stay at their rows (RowIndexShift, SelectionModel/FocusModel.adjustForRowChanges – no onSelectionChanged unless a selected row left the buffer); one render pass, none when only rows below the view came in (cells not rebuilt). Held mouse button: "auto" keeps the rows under the pointer and follows again after release. Own AreaModel: append yourself, then tableApi.rowsAppended(count, { follow, removedAtStart }). Not addRows() (copies all rows, resets filter and sort). Showcase logtail, demo apps/table-demo/log-tail.html, LogTailController + createLogTailModelAndOptions in @guiexpert/demo-table-models.
|
|
733
772
|
- Open a cell, tile navigation, focus frame (since 1.1.115): EventListenerIf.onCellActivated(GeCellActivateEvent: areaIdent "body", rowIndex, columnIndex, value, row, source "keyboard" | "mouse" | "api", originalEvent) – Enter on the focused body cell or a double click, in every table, after the built-in jobs (row checkbox, detail row, tree node, editing.enterKey; double click: editor of an editable cell, tree node), not on handles, empty tiles or under a blocking overlay; the Enter key is not consumed; wrappers cellActivated. Cover grid keyboard: AreaModelIf.getTileLayout?(): TileLayoutIf { getTileCount, getTilesPerRow, getTileAt(index), indexOfTile(item) } (CoverGridBodyModel implements it) → the items are one sequence: ←/→ previous/next with wrap (RTL mirrored), ↑/↓ one row (↓ without a tile below: last item), Home/End and Ctrl/⌘+Home/End first/last item, Page Up/Down; empty tiles never focused (keys and mouse); one render per key; the focus follows the item (sort, filter, resize, new items; filtered out → tile at the same index). DOM-free: navigateTiles(index, action, { count, perRow, pageRows, firstVisible }), tileIndexToCell, cellToTileIndex. tableOptions.focusFrame: "always" (default) | "keyboard" (only while the keyboard is used, default of CoverGridFactory.createCoverGridDefaultOptions) | "never"; FocusModel("none") does not hide the frame. CoverGridFactory.createCoverGridDefaultOptions (alias, the old createCoverGrisDefaultOptions is deprecated). Cover grid fixes: at least one column (was 0 → Infinity rows), no empty extra row, sort()/doSort() sort a copy (the app's items array keeps its order).
|
|
734
773
|
- Cover grid in the full width (since 1.1.117): tableOptions.coverGridFill: true | Partial<CoverGridFillOptionsIf { tileWidth, aspectRatio?, extraHeight? }> → columns = max(1, floor(layout width / tileWidth)), tiles stretched flush (first columns +1 px for the rest), height = round(width × aspectRatio) + extraHeight (without ratio: coverHeight); a resize in the ResizeObserver callback (same frame, one render, no debounce), top item and focused item stay; next to a classic scroll bar the width is corrected in the same layout. TableApi.setCoverGridFill(parts | true | false): boolean (merges, one render, false = no cover grid), getCoverGridFill(). Model: CoverGridBodyModel.setFill/getFill/getTileWidthAt/getTileLeftAt/getTileRowWidth, coverWidth/coverHeight = effective size; DOM-free computeCoverGridFill(width, fill, coverHeight); isCoverGridBodyModel. Other body: one console warning. Also 1.1.117: CoverGridBodyModel.getConstantRowHeight() = coverHeight and getMaxColspan()/getMaxRowspan() = 1 (a resize of 1,000,000 items no longer O(rows)).
|
|
774
|
+
- Cells of visible rows are kept (since 1.1.120): tableOptions.keepCellsOnScroll (default true). A scroll step (scroll bar, wheel, scrollToPixel/scrollToIndex/ensureRowIsVisible/ensureColumnIsVisible) builds only the rows that come into view – rows that stay keep their row element with all cells, only `top` changes; header and footer are not built again by a vertical step; a horizontal step builds the scrollable columns, fixed columns stay. A change of selection, focus or focus frame (click, arrow keys, Shift+arrows, Ctrl/⌘+A, drag selection, tile navigation) builds no cell: selection backgrounds, the focus frame, `aria-selected` and `aria-activedescendant` are drawn on the kept cells (a cell whose getCustomClassesAt/getCustomStyleAt changed is built again). CellRendererIf.render() runs once per row in view (and with repaint(), repaintHard(), updateCells(), sorting, filter, column widths …), its cleanup function once when the row leaves the view, the cell is built again or the table is destroyed; updateCells() calls the cleanup of the replaced content at once. Not kept: a body with col-/rowspans (built completely, as before). `false` = every render pass builds every visible cell (behaviour before 1.1.120). Data changed without a repaint shows when the row is built again, not with the next scroll step (setRows/addRows/removeRows/updateRows mark the rows as outdated). DomServiceIf.insertBefore?(parent, child, before) is optional (the table falls back to the DOM).
|
|
735
775
|
- Custom filtering
|
|
736
776
|
- In-place cell editing
|
|
737
777
|
- User-defined key and mouse events
|