@omnigrid/core 0.1.23 → 0.1.24
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/dist/grid.d.ts +4 -0
- package/dist/grid.js +41 -1
- package/dist/types.d.ts +16 -0
- package/dist/virtualizer.js +7 -1
- package/package.json +1 -1
package/dist/grid.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
37
37
|
private overlayManual;
|
|
38
38
|
/** Grid-level `wrapText` flag — applied to every column without an explicit one. */
|
|
39
39
|
private wrapTextAll;
|
|
40
|
+
/** Normalized cell flash configuration. `false` when disabled. */
|
|
41
|
+
private cellFlash;
|
|
42
|
+
/** Cells currently flashed: key `${rowId}:${columnId}` → expiry timestamp. */
|
|
43
|
+
private flashedCells;
|
|
40
44
|
/**
|
|
41
45
|
* Separate ephemeral scroll position that is NOT stored in the Store.
|
|
42
46
|
*
|
package/dist/grid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyWrapText, flattenColumns, getColumnGroups, getRowSpans, resolveColSpan } from "./columns";
|
|
1
|
+
import { applyWrapText, flattenColumns, getColumnGroups, getCellValue, getRowSpans, resolveColSpan } from "./columns";
|
|
2
2
|
import { EventBus } from "./events";
|
|
3
3
|
import { applyFilterModel, applyQuickFilter, isActiveCondition } from "./filtering";
|
|
4
4
|
import { PopupManager } from "./ui";
|
|
@@ -26,6 +26,10 @@ export class Grid {
|
|
|
26
26
|
this.hasData = true;
|
|
27
27
|
this.overlayState = { type: null };
|
|
28
28
|
this.overlayManual = false;
|
|
29
|
+
/** Normalized cell flash configuration. `false` when disabled. */
|
|
30
|
+
this.cellFlash = false;
|
|
31
|
+
/** Cells currently flashed: key `${rowId}:${columnId}` → expiry timestamp. */
|
|
32
|
+
this.flashedCells = new Map();
|
|
29
33
|
/**
|
|
30
34
|
* Separate ephemeral scroll position that is NOT stored in the Store.
|
|
31
35
|
*
|
|
@@ -42,6 +46,7 @@ export class Grid {
|
|
|
42
46
|
rowHeight: options.rowHeight ?? 32,
|
|
43
47
|
rowOverscan: options.rowOverscan ?? 5,
|
|
44
48
|
columnOverscan: options.columnOverscan ?? 2,
|
|
49
|
+
flashedCells: new Map(),
|
|
45
50
|
overlay: { type: null },
|
|
46
51
|
quickFilter: options.quickFilter ?? "",
|
|
47
52
|
};
|
|
@@ -51,6 +56,13 @@ export class Grid {
|
|
|
51
56
|
this.loading = options.loading ?? false;
|
|
52
57
|
this.hasData = options.data !== undefined && options.data !== null;
|
|
53
58
|
this.wrapTextAll = options.wrapText;
|
|
59
|
+
const raw = options.cellFlash;
|
|
60
|
+
this.cellFlash =
|
|
61
|
+
raw === true
|
|
62
|
+
? { enabled: true, durationMs: 1000 }
|
|
63
|
+
: typeof raw === "number" && raw > 0
|
|
64
|
+
? { enabled: true, durationMs: raw }
|
|
65
|
+
: false;
|
|
54
66
|
if (options.filterModel)
|
|
55
67
|
this.filterModel = Grid.cloneFilterModel(options.filterModel);
|
|
56
68
|
this.virtualizer = new Virtualizer({
|
|
@@ -632,6 +644,33 @@ export class Grid {
|
|
|
632
644
|
affectedIndexes.add(index);
|
|
633
645
|
}
|
|
634
646
|
}
|
|
647
|
+
// ---------- cell flash on update ----------
|
|
648
|
+
if (this.cellFlash !== false && updated.length > 0) {
|
|
649
|
+
const state = this.store.getState();
|
|
650
|
+
const leafColumns = flattenColumns(state.columns).filter((column) => column.field !== undefined);
|
|
651
|
+
// Lazy cleanup: drop entries older than the flash duration so the map
|
|
652
|
+
// doesn't grow unboundedly and cells can re-flash later.
|
|
653
|
+
const cutoff = Date.now() - this.cellFlash.durationMs;
|
|
654
|
+
for (const [key, ts] of this.flashedCells) {
|
|
655
|
+
if (ts < cutoff) {
|
|
656
|
+
this.flashedCells.delete(key);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const now = Date.now();
|
|
660
|
+
for (const { id, index, data: newRow } of updated) {
|
|
661
|
+
const oldRow = currentData[index];
|
|
662
|
+
if (oldRow === undefined)
|
|
663
|
+
continue;
|
|
664
|
+
for (const column of leafColumns) {
|
|
665
|
+
const oldValue = getCellValue(oldRow, column);
|
|
666
|
+
const newValue = getCellValue(newRow, column);
|
|
667
|
+
if (oldValue !== newValue) {
|
|
668
|
+
this.flashedCells.set(`${id}:${column.id}`, now);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
this.store.setState({ flashedCells: new Map(this.flashedCells) });
|
|
673
|
+
}
|
|
635
674
|
// ---------- adds ----------
|
|
636
675
|
const insertAt = Math.min(Math.max(transaction.addIndex ?? nextData.length, 0), nextData.length);
|
|
637
676
|
if (transaction.add) {
|
|
@@ -888,6 +927,7 @@ export class Grid {
|
|
|
888
927
|
destroy() {
|
|
889
928
|
if (this.destroyed)
|
|
890
929
|
return;
|
|
930
|
+
this.flashedCells.clear();
|
|
891
931
|
this.cleanupPlugins.forEach((cleanup) => cleanup());
|
|
892
932
|
this.cleanupPlugins.clear();
|
|
893
933
|
this.dataProcessors.clear();
|
package/dist/types.d.ts
CHANGED
|
@@ -143,6 +143,10 @@ export interface CellRenderParams<T> {
|
|
|
143
143
|
data: T;
|
|
144
144
|
column: ColumnLeafDef<T>;
|
|
145
145
|
value?: unknown;
|
|
146
|
+
/** Whether the cell was recently updated and is currently flashing. */
|
|
147
|
+
isFlashed?: boolean;
|
|
148
|
+
/** Timestamp (ms) when the flash started; used by adapters to restart CSS animation on re-flash. */
|
|
149
|
+
flashTimestamp?: number;
|
|
146
150
|
}
|
|
147
151
|
export type CellClassRules<T> = Record<string, (params: CellRenderParams<T>) => boolean>;
|
|
148
152
|
/**
|
|
@@ -465,6 +469,16 @@ export interface GridOptions<T> {
|
|
|
465
469
|
/** Columns to render beyond the visible viewport (left + right buffer). @default 2 */
|
|
466
470
|
columnOverscan?: number;
|
|
467
471
|
suppressRowHoverHighlight?: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* Enables automatic cell flashing when data is mutated via
|
|
474
|
+
* `grid.applyTransaction()`. Cells whose values changed are highlighted
|
|
475
|
+
* with a CSS transition that fades out automatically. Pass `true` for the
|
|
476
|
+
* default duration (1000ms), or a number for a custom duration in
|
|
477
|
+
* milliseconds. `false` / `0` / `undefined` disables the feature.
|
|
478
|
+
* @default false
|
|
479
|
+
* @api
|
|
480
|
+
*/
|
|
481
|
+
cellFlash?: boolean | number;
|
|
468
482
|
rowStyle?: RowStyle;
|
|
469
483
|
getRowStyle?: (params: RowRenderParams<T>) => RowStyle | undefined;
|
|
470
484
|
rowClass?: string | ((params: RowRenderParams<T>) => string | undefined);
|
|
@@ -641,6 +655,8 @@ export interface GridState<T> {
|
|
|
641
655
|
rowHeight: number;
|
|
642
656
|
rowOverscan: number;
|
|
643
657
|
columnOverscan: number;
|
|
658
|
+
/** Cells currently flashed, keyed by `${rowId}:${columnId}` → expiry timestamp. */
|
|
659
|
+
flashedCells: Map<string, number>;
|
|
644
660
|
/** Active overlay state — updated automatically by the grid's overlay manager. */
|
|
645
661
|
overlay: OverlayState;
|
|
646
662
|
/**
|
package/dist/virtualizer.js
CHANGED
|
@@ -463,7 +463,13 @@ export class Virtualizer {
|
|
|
463
463
|
getColumnRange(columns, scrollLeft, viewportWidth, offsets) {
|
|
464
464
|
const computed = offsets ?? this.getColumnOffsets(columns, viewportWidth);
|
|
465
465
|
const start = this.findStart(computed, scrollLeft);
|
|
466
|
-
|
|
466
|
+
// When the viewport width is unknown (0 on first paint), we cannot
|
|
467
|
+
// determine how many columns fit. Return all columns so none are
|
|
468
|
+
// missing from the initial render — they will be resized correctly
|
|
469
|
+
// once measureViewport() sets the real width.
|
|
470
|
+
const end = viewportWidth === 0
|
|
471
|
+
? columns.length
|
|
472
|
+
: this.findEnd(computed, scrollLeft + viewportWidth);
|
|
467
473
|
return {
|
|
468
474
|
start: Math.max(0, start - this.options.columnOverscan),
|
|
469
475
|
end: Math.min(columns.length, end + 1 + this.options.columnOverscan),
|