@omnigrid/core 0.1.36 → 0.1.38
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/dom-pool.js +3 -0
- package/dist/grid.d.ts +18 -2
- package/dist/grid.js +118 -17
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +60 -1
- package/dist/ui.d.ts +84 -7
- package/dist/virtualizer.d.ts +6 -0
- package/dist/virtualizer.js +15 -0
- package/package.json +1 -1
package/dist/dom-pool.js
CHANGED
|
@@ -47,6 +47,7 @@ export class DomPool {
|
|
|
47
47
|
* report describing the update.
|
|
48
48
|
*/
|
|
49
49
|
update(viewport) {
|
|
50
|
+
performance.mark("omnigrid.domPool.update.start");
|
|
50
51
|
this.assertActive();
|
|
51
52
|
const { data, rowRange, rowHeight, rowOffsets, rowHeights, visibleRowRange, rowWidth, skipBind } = viewport;
|
|
52
53
|
if (data !== this.lastData) {
|
|
@@ -206,6 +207,8 @@ export class DomPool {
|
|
|
206
207
|
recycled.push(host);
|
|
207
208
|
}
|
|
208
209
|
this.forceRebind = false;
|
|
210
|
+
performance.mark("omnigrid.domPool.update.end");
|
|
211
|
+
performance.measure("OmniGrid DomPool.update", "omnigrid.domPool.update.start", "omnigrid.domPool.update.end");
|
|
209
212
|
return {
|
|
210
213
|
windowStart: range.start,
|
|
211
214
|
windowEnd: range.end,
|
package/dist/grid.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { OverlayOptions, OverlayState } from "./overlays.js";
|
|
|
4
4
|
import { DataPipeline } from "./pipeline.js";
|
|
5
5
|
import { SlotManager } from "./slots.js";
|
|
6
6
|
import { type StateUpdater } from "./store.js";
|
|
7
|
-
import type { AggregationFunc, ColumnHeaderExtension, ColumnHeaderExtensionPosition, ColumnLeafDef, DataProcessor, DefaultColumnDef, GridApi, GridEvents, GridOptions, GridPlugin, GridState, RowClickEvent, RowHeightUpdateOptions, RowHierarchy, RowHoverEvent, RowId, RowSpanLayout, RowTransaction, ScrollPosition, SlotMount, SlotName, TransactionResult, TreeRowNode, ViewportData, ViewportState } from "./types.js";
|
|
7
|
+
import type { AggregationFunc, ColumnHeaderExtension, ColumnHeaderExtensionPosition, ColumnLeafDef, DataProcessor, DefaultColumnDef, GridApi, GridEvents, GridMetrics, GridOptions, GridPlugin, GridState, RowClickEvent, RowHeightUpdateOptions, RowHierarchy, RowHoverEvent, RowId, RowSpanLayout, RowTransaction, ScrollPosition, GridStateUpdateOptions, SlotMount, SlotName, TransactionResult, TreeRowNode, ViewportData, ViewportState } from "./types.js";
|
|
8
8
|
import type { UIPopupAnchor, UIPopupDescriptor } from "./ui.js";
|
|
9
9
|
export declare class Grid<T> implements GridApi<T> {
|
|
10
10
|
private readonly store;
|
|
@@ -84,9 +84,10 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
84
84
|
* Updates the grid state via partial patch or functional updater.
|
|
85
85
|
* Accessible by plugins to update their contributed state slices.
|
|
86
86
|
* @param updater - Partial state patch or reducer function.
|
|
87
|
+
* @param options - Set `structural` to `false` for presentation-only plugin state.
|
|
87
88
|
* @api
|
|
88
89
|
*/
|
|
89
|
-
setState(updater: StateUpdater<GridState<T
|
|
90
|
+
setState(updater: StateUpdater<GridState<T>>, options?: GridStateUpdateOptions): void;
|
|
90
91
|
/**
|
|
91
92
|
* Registers methods dynamically contributed by plugins.
|
|
92
93
|
* These methods are attached both to `api.methods` and directly to `api`.
|
|
@@ -281,6 +282,14 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
281
282
|
resetRowHeight(rowIndex: number, options?: RowHeightUpdateOptions): number;
|
|
282
283
|
/** Removes all measured row heights (e.g. after `setColumns`). @api */
|
|
283
284
|
resetAllRowHeights(): void;
|
|
285
|
+
/**
|
|
286
|
+
* Updates structural grid metrics at runtime (e.g. the base row height when
|
|
287
|
+
* a theme scales the whole grid). Recomputes the virtualizer geometry and
|
|
288
|
+
* notifies Store subscribers so the host re-renders with the new layout.
|
|
289
|
+
* @param metrics - Metrics to apply; omitted fields are left unchanged.
|
|
290
|
+
* @api
|
|
291
|
+
*/
|
|
292
|
+
setMetrics(metrics: GridMetrics): void;
|
|
284
293
|
/**
|
|
285
294
|
* Returns the absolute vertical offset (px) of the top of a row,
|
|
286
295
|
* accounting for variable heights. Falls back to `index * rowHeight`
|
|
@@ -339,8 +348,15 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
339
348
|
* structural changes.
|
|
340
349
|
*/
|
|
341
350
|
refresh(): void;
|
|
351
|
+
/**
|
|
352
|
+
* Requests an adapter refresh of visible cells without structural rebinding.
|
|
353
|
+
* @param columnIds - Optional column IDs to refresh.
|
|
354
|
+
* @api
|
|
355
|
+
*/
|
|
356
|
+
refreshCells(columnIds?: readonly string[]): void;
|
|
342
357
|
/**
|
|
343
358
|
* Replaces the column definitions and optionally updates shared leaf-column defaults.
|
|
359
|
+
* Width-only changes preserve processed data caches and the structural revision.
|
|
344
360
|
*
|
|
345
361
|
* @param columns - New column definitions.
|
|
346
362
|
* @param defaultColumnDef - Updated defaults; pass `undefined` to clear existing defaults.
|
package/dist/grid.js
CHANGED
|
@@ -9,6 +9,41 @@ import { SlotManager } from "./slots.js";
|
|
|
9
9
|
import { Store } from "./store.js";
|
|
10
10
|
import { PopupManager } from "./ui.js";
|
|
11
11
|
import { Virtualizer } from "./virtualizer.js";
|
|
12
|
+
function haveSameColumnProperties(previous, next, ignoredKeys) {
|
|
13
|
+
const previousProperties = previous;
|
|
14
|
+
const nextProperties = next;
|
|
15
|
+
const previousKeys = Object.keys(previousProperties).filter((key) => !ignoredKeys.includes(key));
|
|
16
|
+
const nextKeys = Object.keys(nextProperties).filter((key) => !ignoredKeys.includes(key));
|
|
17
|
+
return (previousKeys.length === nextKeys.length &&
|
|
18
|
+
previousKeys.every((key) => nextKeys.includes(key) && previousProperties[key] === nextProperties[key]));
|
|
19
|
+
}
|
|
20
|
+
function areColumnDefinitionsEqualExceptSizing(previous, next) {
|
|
21
|
+
if (previous.length !== next.length)
|
|
22
|
+
return false;
|
|
23
|
+
return previous.every((previousColumn, index) => {
|
|
24
|
+
const nextColumn = next[index];
|
|
25
|
+
if (!nextColumn)
|
|
26
|
+
return false;
|
|
27
|
+
if (isColumnGroup(previousColumn)) {
|
|
28
|
+
return (isColumnGroup(nextColumn) &&
|
|
29
|
+
haveSameColumnProperties(previousColumn, nextColumn, ["children"]) &&
|
|
30
|
+
areColumnDefinitionsEqualExceptSizing(previousColumn.children, nextColumn.children));
|
|
31
|
+
}
|
|
32
|
+
return !isColumnGroup(nextColumn) && haveSameColumnProperties(previousColumn, nextColumn, ["width", "flex"]);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function haveColumnSizingChanged(previous, next) {
|
|
36
|
+
return previous.some((previousColumn, index) => {
|
|
37
|
+
const nextColumn = next[index];
|
|
38
|
+
if (!nextColumn)
|
|
39
|
+
return false;
|
|
40
|
+
if (isColumnGroup(previousColumn)) {
|
|
41
|
+
return isColumnGroup(nextColumn) && haveColumnSizingChanged(previousColumn.children, nextColumn.children);
|
|
42
|
+
}
|
|
43
|
+
return (!isColumnGroup(nextColumn) &&
|
|
44
|
+
(previousColumn.width !== nextColumn.width || previousColumn.flex !== nextColumn.flex));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
12
47
|
export class Grid {
|
|
13
48
|
constructor(options) {
|
|
14
49
|
this.events = new EventBus();
|
|
@@ -54,12 +89,14 @@ export class Grid {
|
|
|
54
89
|
this.autoColumnsPending = options.columns === undefined && (options.data?.length ?? 0) === 0;
|
|
55
90
|
this.autoColumnHeaderMode = options.autoColumnHeaderMode;
|
|
56
91
|
this.getColumnHeader = options.getColumnHeader;
|
|
92
|
+
const scale = options.scale ?? 1;
|
|
57
93
|
const state = {
|
|
58
94
|
data: options.data ?? [],
|
|
59
95
|
columns: applyWrapText(applyDefaultColumnDef(options.columns ??
|
|
60
96
|
inferColumns(options.data, options.getColumnHeader, options.autoColumnHeaderMode), options.defaultColumnDef), options.wrapText),
|
|
61
97
|
viewport: { width: 0, height: 0, scrollTop: 0, scrollLeft: 0 },
|
|
62
|
-
rowHeight: options.rowHeight ?? 32,
|
|
98
|
+
rowHeight: options.rowHeight ?? Math.round(32 * scale),
|
|
99
|
+
scale,
|
|
63
100
|
groupBy: [],
|
|
64
101
|
expandedGroups: {},
|
|
65
102
|
groupColumnMode: "single",
|
|
@@ -170,17 +207,21 @@ export class Grid {
|
|
|
170
207
|
* Updates the grid state via partial patch or functional updater.
|
|
171
208
|
* Accessible by plugins to update their contributed state slices.
|
|
172
209
|
* @param updater - Partial state patch or reducer function.
|
|
210
|
+
* @param options - Set `structural` to `false` for presentation-only plugin state.
|
|
173
211
|
* @api
|
|
174
212
|
*/
|
|
175
|
-
setState(updater) {
|
|
213
|
+
setState(updater, options = {}) {
|
|
176
214
|
this.assertActive();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
215
|
+
if (options.structural !== false) {
|
|
216
|
+
this.filteredDataCache = null;
|
|
217
|
+
this.processedDataCache = null;
|
|
218
|
+
this.groupedRowsCache = null;
|
|
219
|
+
this.groupedRowsRevision = -1;
|
|
220
|
+
this.revision += 1;
|
|
221
|
+
}
|
|
182
222
|
this.store.setState(updater);
|
|
183
|
-
|
|
223
|
+
if (options.structural !== false)
|
|
224
|
+
this.recomputeOverlay();
|
|
184
225
|
}
|
|
185
226
|
/**
|
|
186
227
|
* Registers methods dynamically contributed by plugins.
|
|
@@ -489,11 +530,14 @@ export class Grid {
|
|
|
489
530
|
// optimization for DOM Pool operation with large row counts.
|
|
490
531
|
if (this.processedDataCache !== null)
|
|
491
532
|
return this.processedDataCache;
|
|
533
|
+
performance.mark("omnigrid.processedData.start");
|
|
492
534
|
const state = this.getState();
|
|
493
535
|
const filtered = this.getFilteredData();
|
|
494
536
|
const legacyProcessed = [...this.dataProcessors].reduce((data, processor) => processor(data), filtered);
|
|
495
537
|
const result = this.pipeline.process(legacyProcessed, state);
|
|
496
538
|
this.processedDataCache = result;
|
|
539
|
+
performance.mark("omnigrid.processedData.end");
|
|
540
|
+
performance.measure("OmniGrid getProcessedData pipeline", "omnigrid.processedData.start", "omnigrid.processedData.end");
|
|
497
541
|
return result;
|
|
498
542
|
}
|
|
499
543
|
/**
|
|
@@ -887,6 +931,38 @@ export class Grid {
|
|
|
887
931
|
this.revision += 1;
|
|
888
932
|
this.store.setState({}, { force: true });
|
|
889
933
|
}
|
|
934
|
+
/**
|
|
935
|
+
* Updates structural grid metrics at runtime (e.g. the base row height when
|
|
936
|
+
* a theme scales the whole grid). Recomputes the virtualizer geometry and
|
|
937
|
+
* notifies Store subscribers so the host re-renders with the new layout.
|
|
938
|
+
* @param metrics - Metrics to apply; omitted fields are left unchanged.
|
|
939
|
+
* @api
|
|
940
|
+
*/
|
|
941
|
+
setMetrics(metrics) {
|
|
942
|
+
this.assertActive();
|
|
943
|
+
const nextScale = metrics.scale;
|
|
944
|
+
const nextRowHeight = metrics.rowHeight;
|
|
945
|
+
let resolvedScale = nextScale;
|
|
946
|
+
let resolvedRowHeight = nextRowHeight;
|
|
947
|
+
if (nextScale !== undefined && Number.isFinite(nextScale) && nextScale > 0) {
|
|
948
|
+
resolvedScale = nextScale;
|
|
949
|
+
if (nextRowHeight === undefined) {
|
|
950
|
+
resolvedRowHeight = Math.round(32 * nextScale);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
const state = this.getState();
|
|
954
|
+
const scaleChanged = resolvedScale !== undefined && resolvedScale !== state.scale;
|
|
955
|
+
const rowHeightChanged = resolvedRowHeight !== undefined && resolvedRowHeight !== state.rowHeight;
|
|
956
|
+
if (!scaleChanged && !rowHeightChanged)
|
|
957
|
+
return;
|
|
958
|
+
if (scaleChanged || rowHeightChanged) {
|
|
959
|
+
this.virtualizer.setBaseRowHeight(resolvedRowHeight ?? state.rowHeight);
|
|
960
|
+
}
|
|
961
|
+
this.store.setState({
|
|
962
|
+
...(resolvedScale !== undefined ? { scale: resolvedScale } : {}),
|
|
963
|
+
...(resolvedRowHeight !== undefined ? { rowHeight: resolvedRowHeight } : {}),
|
|
964
|
+
});
|
|
965
|
+
}
|
|
890
966
|
/**
|
|
891
967
|
* Returns the absolute vertical offset (px) of the top of a row,
|
|
892
968
|
* accounting for variable heights. Falls back to `index * rowHeight`
|
|
@@ -1190,8 +1266,18 @@ export class Grid {
|
|
|
1190
1266
|
this.revision += 1;
|
|
1191
1267
|
this.store.setState({}, { force: true });
|
|
1192
1268
|
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Requests an adapter refresh of visible cells without structural rebinding.
|
|
1271
|
+
* @param columnIds - Optional column IDs to refresh.
|
|
1272
|
+
* @api
|
|
1273
|
+
*/
|
|
1274
|
+
refreshCells(columnIds) {
|
|
1275
|
+
this.assertActive();
|
|
1276
|
+
this.events.emit("cellsRefresh", { columnIds });
|
|
1277
|
+
}
|
|
1193
1278
|
/**
|
|
1194
1279
|
* Replaces the column definitions and optionally updates shared leaf-column defaults.
|
|
1280
|
+
* Width-only changes preserve processed data caches and the structural revision.
|
|
1195
1281
|
*
|
|
1196
1282
|
* @param columns - New column definitions.
|
|
1197
1283
|
* @param defaultColumnDef - Updated defaults; pass `undefined` to clear existing defaults.
|
|
@@ -1201,13 +1287,19 @@ export class Grid {
|
|
|
1201
1287
|
this.assertActive();
|
|
1202
1288
|
if (arguments.length > 1)
|
|
1203
1289
|
this.defaultColumnDef = defaultColumnDef;
|
|
1204
|
-
this.
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1290
|
+
const nextColumns = applyWrapText(applyDefaultColumnDef(columns, this.defaultColumnDef), this.wrapTextAll);
|
|
1291
|
+
const sizingOnlyChange = arguments.length === 1 &&
|
|
1292
|
+
areColumnDefinitionsEqualExceptSizing(this.store.getState().columns, nextColumns) &&
|
|
1293
|
+
haveColumnSizingChanged(this.store.getState().columns, nextColumns);
|
|
1294
|
+
if (!sizingOnlyChange) {
|
|
1295
|
+
this.filteredDataCache = null;
|
|
1296
|
+
this.processedDataCache = null;
|
|
1297
|
+
this.groupedRowsCache = null;
|
|
1298
|
+
this.groupedRowsRevision = -1;
|
|
1299
|
+
this.revision += 1;
|
|
1300
|
+
}
|
|
1209
1301
|
this.store.setState({
|
|
1210
|
-
columns:
|
|
1302
|
+
columns: nextColumns,
|
|
1211
1303
|
});
|
|
1212
1304
|
this.recomputeOverlay();
|
|
1213
1305
|
}
|
|
@@ -1371,12 +1463,21 @@ export class Grid {
|
|
|
1371
1463
|
if (this.overlayManual)
|
|
1372
1464
|
return;
|
|
1373
1465
|
const state = this.store.getState();
|
|
1374
|
-
const
|
|
1466
|
+
const loading = this.loading || !this.hasData;
|
|
1467
|
+
let processedData;
|
|
1468
|
+
if (!loading && this.loadError === undefined) {
|
|
1469
|
+
if (state.data.length === 0) {
|
|
1470
|
+
processedData = [];
|
|
1471
|
+
}
|
|
1472
|
+
else {
|
|
1473
|
+
processedData = this.getProcessedData();
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1375
1476
|
const type = evaluateAutoOverlay({
|
|
1376
|
-
loading
|
|
1477
|
+
loading,
|
|
1377
1478
|
error: this.loadError,
|
|
1378
1479
|
rawData: state.data,
|
|
1379
|
-
processedData,
|
|
1480
|
+
processedData: processedData ?? [],
|
|
1380
1481
|
});
|
|
1381
1482
|
const next = type
|
|
1382
1483
|
? {
|
package/dist/icons.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SlotNodeContent } from "./types.js";
|
|
2
|
-
export type IconName = "chevron-left" | "chevron-right" | "chevron-up" | "chevron-down" | "chevron-first" | "chevron-last" | "arrow-up" | "arrow-down" | "arrow-up-down" | "filter" | "search";
|
|
2
|
+
export type IconName = "chevron-left" | "chevron-right" | "chevron-up" | "chevron-down" | "chevron-first" | "chevron-last" | "arrow-up" | "arrow-down" | "arrow-up-down" | "filter" | "search" | "calendar";
|
|
3
3
|
export type IconDefinition<T> = SlotNodeContent<T> | (() => SlotNodeContent<T>);
|
|
4
4
|
/** Framework-agnostic registry of declarative SVG slot nodes. */
|
|
5
5
|
export declare class IconRegistry<T> {
|
package/dist/icons.js
CHANGED
|
@@ -30,6 +30,12 @@ const DEFAULT_ICON_PATHS = {
|
|
|
30
30
|
{ tag: "circle", attrs: { cx: "11", cy: "11", r: "8" } },
|
|
31
31
|
{ tag: "path", attrs: { d: "m21 21-4.3-4.3" } },
|
|
32
32
|
],
|
|
33
|
+
"calendar": [
|
|
34
|
+
{ tag: "rect", attrs: { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" } },
|
|
35
|
+
{ tag: "line", attrs: { x1: "16", y1: "2", x2: "16", y2: "6" } },
|
|
36
|
+
{ tag: "line", attrs: { x1: "8", y1: "2", x2: "8", y2: "6" } },
|
|
37
|
+
{ tag: "line", attrs: { x1: "3", y1: "10", x2: "21", y2: "10" } },
|
|
38
|
+
],
|
|
33
39
|
};
|
|
34
40
|
function createSvgIcon(name, paths) {
|
|
35
41
|
return {
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export { DataPipeline, PIPELINE_STAGE_ORDER } from "./pipeline.js";
|
|
|
12
12
|
export type { PipelineProcessor, PipelineStage } from "./pipeline.js";
|
|
13
13
|
export { applyFilterModel, applyQuickFilter, isActiveCondition, isFilterModelActive, matchesColumnFilter, } from "./filtering.js";
|
|
14
14
|
export type { ColumnFilterModel, FilterCondition, FilterModel, FilterOperator } from "./filtering.js";
|
|
15
|
-
export type { UIButtonControl, UICheckboxDescriptor, UIControlBase, UIControlDescriptor, UIGroupControl, UIInputControl, UIPopupAnchor, UIPopupDescriptor, UISelectControl, UISelectOption, UITextBlockControl, UIMultiSelectControl, UIMultiSelectOption, } from "./ui.js";
|
|
15
|
+
export type { UIButtonControl, UICheckboxDescriptor, UIControlBase, UIControlDescriptor, UIGroupControl, UIIconControl, UIInputBase, UIInputControl, UIDateInputControl, UIDateLocaleStrings, UINumberInputControl, UITextInputControl, UIPopupAnchor, UIPopupDescriptor, UIRadioControl, UIRadioOption, UISelectControl, UISeparatorControl, UISelectOption, UITextBlockControl, UIMultiSelectControl, UIMultiSelectOption, } from "./ui.js";
|
|
16
16
|
export type { OverlayOptions, OverlayScope, OverlayState, OverlayType } from "./overlays.js";
|
|
17
|
-
export type { BlockConfig, CellAlign, AggregationFunc, AutoColumnHeaderMode, ColumnHeaderExtension, ColumnHeaderExtensionPosition, CellRenderParams, CellClassRules, CellSpan, CellSpanningParams, CheckboxControl, CheckboxRenderParams, ColSpanDef, ColumnClassRules, ColumnDataType, ColumnDropPosition, DefaultColumnDef, ColumnFilterType, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, ColumnStyle, ColumnStyleParams, DataProcessor, DataRowNode, DomPoolBindings, DomPoolUpdate, DomPoolUpdateOptions, GroupRowNode, GroupRowRenderParams, GroupRowRenderer, CoreGridApi, CoreGridState, GridApi, GridEvents, GridOptions, GridPlugin, GridState, PluginApiExtensions, PluginStateExtensions, ResolvedAggregationFunc, HeaderClassRules, HeaderGroupClassRules, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHeightUpdateOptions, RowHost, RowHoverEvent, RowId, RowHierarchy, RowHierarchyScope, RowGroupContext, RowGroupContextChild, RowNode, RowRenderParams, RowSpanLayout, RowStyle, RowTransaction, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, TransactionResult, TreeRowNode, ViewportData, ViewportState, VirtualItem, } from "./types.js";
|
|
17
|
+
export type { BlockConfig, CellAlign, AggregationFunc, AutoColumnHeaderMode, ColumnHeaderExtension, ColumnHeaderExtensionPosition, CellRenderParams, CellClassRules, CellSpan, CellSpanningParams, CheckboxControl, CheckboxRenderParams, ColSpanDef, ColumnClassRules, ColumnDataType, ColumnDropPosition, DefaultColumnDef, ColumnFilterType, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, ColumnStyle, ColumnStyleParams, DataProcessor, DataRowNode, DomPoolBindings, DomPoolUpdate, DomPoolUpdateOptions, GroupRowNode, GroupRowRenderParams, GroupRowRenderer, CoreGridApi, CoreGridState, GridStateUpdateOptions, GridApi, GridEvents, GridMetrics, GridOptions, GridPlugin, GridState, PluginApiExtensions, PluginStateExtensions, ResolvedAggregationFunc, HeaderClassRules, HeaderGroupClassRules, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHeightUpdateOptions, RowHost, RowHoverEvent, RowId, RowHierarchy, RowHierarchyScope, RowGroupContext, RowGroupContextChild, RowNode, RowRenderParams, RowSpanLayout, RowStyle, RowTransaction, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, TransactionResult, TreeRowNode, ViewportData, ViewportState, VirtualItem, } from "./types.js";
|
|
18
18
|
export { applyDefaultColumnDef, getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf, getCellValue, getCellSpanningParams, resolveColSpan, getRowSpans, inferColumns, } from "./columns.js";
|
|
19
19
|
export { Virtualizer, RowHeightRegistry } from "./virtualizer.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -613,6 +613,31 @@ export interface RowHeightUpdateOptions {
|
|
|
613
613
|
*/
|
|
614
614
|
notify?: boolean;
|
|
615
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Structural grid metrics that can be updated at runtime.
|
|
618
|
+
*
|
|
619
|
+
* These drive both the virtualizer geometry (row height, total scroll height)
|
|
620
|
+
* and the rendered layout, so a single update keeps the scroll math and the
|
|
621
|
+
* DOM in sync — e.g. when a theme scales the whole grid proportionally.
|
|
622
|
+
*
|
|
623
|
+
* @api
|
|
624
|
+
*/
|
|
625
|
+
export interface GridMetrics {
|
|
626
|
+
/**
|
|
627
|
+
* Base row height (px) for fixed-height grids. Scaled/derived values
|
|
628
|
+
* (font size, paddings) live in CSS via `--omnigrid-scale`; this is the
|
|
629
|
+
* single source of truth the virtualizer uses for row geometry.
|
|
630
|
+
*/
|
|
631
|
+
rowHeight?: number;
|
|
632
|
+
/**
|
|
633
|
+
* Theme scale coefficient (1 = 100%). Core stores it and derives
|
|
634
|
+
* `rowHeight = Math.round(baseRowHeight * scale)` so the virtualizer
|
|
635
|
+
* geometry and the CSS tokens stay consistent. Each grid instance owns
|
|
636
|
+
* its own scale — it does not leak to other grids on the page.
|
|
637
|
+
* @default 1
|
|
638
|
+
*/
|
|
639
|
+
scale?: number;
|
|
640
|
+
}
|
|
616
641
|
/**
|
|
617
642
|
* Built-in formatting modes for headers inferred from row fields.
|
|
618
643
|
* @api
|
|
@@ -648,6 +673,14 @@ export interface GridOptions<T> {
|
|
|
648
673
|
/** Returns a stable row ID; defaults to the row's current index. Use a stable ID to preserve row identity when rows are reordered. */
|
|
649
674
|
getRowId?: (row: T, index: number) => RowId;
|
|
650
675
|
rowHeight?: number;
|
|
676
|
+
/**
|
|
677
|
+
* Theme scale coefficient applied to the base row height (`rowHeight =
|
|
678
|
+
* Math.round(baseRowHeight * scale)`). `1` means 100%. Each grid instance
|
|
679
|
+
* owns its own scale — it does not leak to other grids on the page.
|
|
680
|
+
* @default 1
|
|
681
|
+
* @api
|
|
682
|
+
*/
|
|
683
|
+
scale?: number;
|
|
651
684
|
/** Enables automatic text wrapping for all cells. @default false @api */
|
|
652
685
|
wrapText?: boolean;
|
|
653
686
|
/**
|
|
@@ -893,6 +926,8 @@ export interface CoreGridState<T> {
|
|
|
893
926
|
columns: ColumnDef<T>[];
|
|
894
927
|
viewport: ViewportState;
|
|
895
928
|
rowHeight: number;
|
|
929
|
+
/** Theme scale coefficient (1 = 100%). Drives rowHeight geometry. */
|
|
930
|
+
scale: number;
|
|
896
931
|
rowOverscan: number;
|
|
897
932
|
columnOverscan: number;
|
|
898
933
|
/** Cells currently flashed, keyed by `${rowId}:${columnId}` → expiry timestamp. */
|
|
@@ -984,6 +1019,10 @@ export interface GridEvents<T> {
|
|
|
984
1019
|
filterChanged: FilterModel;
|
|
985
1020
|
/** Fired after the global quick filter changed; the payload is the new query string. */
|
|
986
1021
|
quickFilterChanged: string;
|
|
1022
|
+
/** Fired when adapters should refresh rendered cells without rebinding rows. */
|
|
1023
|
+
cellsRefresh: {
|
|
1024
|
+
columnIds?: readonly string[];
|
|
1025
|
+
};
|
|
987
1026
|
/** Fired when a popup is opened, updated (`descriptor`) or closed (`null`). */
|
|
988
1027
|
popupChange: UIPopupDescriptor | null;
|
|
989
1028
|
/** Fired when the user asks for a column's filter menu (e.g. clicks the header filter icon). */
|
|
@@ -992,6 +1031,11 @@ export interface GridEvents<T> {
|
|
|
992
1031
|
anchor: UIPopupAnchor;
|
|
993
1032
|
};
|
|
994
1033
|
}
|
|
1034
|
+
/** Options for updating plugin-contributed grid state. @api */
|
|
1035
|
+
export interface GridStateUpdateOptions {
|
|
1036
|
+
/** Whether the update invalidates data caches and the structural revision. @default true */
|
|
1037
|
+
structural?: boolean;
|
|
1038
|
+
}
|
|
995
1039
|
/** Opaque token for a row node owned by the adapter. */
|
|
996
1040
|
export type RowHost<T> = object;
|
|
997
1041
|
/** Data snapshot for binding a row node in the pool. */
|
|
@@ -1275,9 +1319,10 @@ export interface CoreGridApi<T> {
|
|
|
1275
1319
|
/**
|
|
1276
1320
|
* Updates the grid state via partial patch or reducer.
|
|
1277
1321
|
* @param updater - State slice patch or updater function.
|
|
1322
|
+
* @param options - Set `structural` to `false` for presentation-only plugin state.
|
|
1278
1323
|
* @api
|
|
1279
1324
|
*/
|
|
1280
|
-
setState(updater: StateUpdater<GridState<T
|
|
1325
|
+
setState(updater: StateUpdater<GridState<T>>, options?: GridStateUpdateOptions): void;
|
|
1281
1326
|
/**
|
|
1282
1327
|
* Registers methods dynamically contributed by plugins.
|
|
1283
1328
|
* These methods are attached both to `api.methods` and directly to `api`.
|
|
@@ -1391,6 +1436,14 @@ export interface CoreGridApi<T> {
|
|
|
1391
1436
|
* @api
|
|
1392
1437
|
*/
|
|
1393
1438
|
setRowHeight(rowIndex: number, height: number, options?: RowHeightUpdateOptions): number;
|
|
1439
|
+
/**
|
|
1440
|
+
* Updates structural grid metrics at runtime (e.g. the base row height when
|
|
1441
|
+
* a theme scales the grid). Recomputes the virtualizer geometry and notifies
|
|
1442
|
+
* Store subscribers so the host re-renders with the new layout.
|
|
1443
|
+
* @param metrics - Metrics to apply; omitted fields are left unchanged.
|
|
1444
|
+
* @api
|
|
1445
|
+
*/
|
|
1446
|
+
setMetrics(metrics: GridMetrics): void;
|
|
1394
1447
|
/**
|
|
1395
1448
|
* Removes a measured row height (e.g. when row content collapses back to
|
|
1396
1449
|
* the estimate). Returns the scrollTop correction like `setRowHeight`.
|
|
@@ -1418,6 +1471,12 @@ export interface CoreGridApi<T> {
|
|
|
1418
1471
|
getRowHeight(rowIndex: number): number;
|
|
1419
1472
|
setViewport(viewport: Partial<ViewportState>): void;
|
|
1420
1473
|
refresh(): void;
|
|
1474
|
+
/**
|
|
1475
|
+
* Refreshes rendered cell contents and row presentation without rebinding rows.
|
|
1476
|
+
* @param columnIds - Optional column IDs to refresh; omitted to refresh all visible cells.
|
|
1477
|
+
* @api
|
|
1478
|
+
*/
|
|
1479
|
+
refreshCells(columnIds?: readonly string[]): void;
|
|
1421
1480
|
subscribe(listener: () => void): () => void;
|
|
1422
1481
|
on<EventName extends keyof GridEvents<T>>(event: EventName, listener: (payload: GridEvents<T>[EventName]) => void): () => void;
|
|
1423
1482
|
onAny(listener: (event: string, payload: unknown) => void): () => void;
|
package/dist/ui.d.ts
CHANGED
|
@@ -36,9 +36,8 @@ export interface UIControlBase {
|
|
|
36
36
|
/** Extra CSS class names. */
|
|
37
37
|
className?: string;
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
export interface
|
|
41
|
-
type: "text" | "number" | "date";
|
|
39
|
+
/** Properties shared by all input controls. @api */
|
|
40
|
+
export interface UIInputBase extends UIControlBase {
|
|
42
41
|
/** Current value. */
|
|
43
42
|
value: string;
|
|
44
43
|
/** Placeholder text. */
|
|
@@ -50,6 +49,47 @@ export interface UIInputControl extends UIControlBase {
|
|
|
50
49
|
/** Called when the user presses Enter while the input is focused. */
|
|
51
50
|
onEnter?: () => void;
|
|
52
51
|
}
|
|
52
|
+
/** Single-line text input. @api */
|
|
53
|
+
export interface UITextInputControl extends UIInputBase {
|
|
54
|
+
type: "text";
|
|
55
|
+
/** Maximum number of characters. */
|
|
56
|
+
maxLength?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Numeric input. @api */
|
|
59
|
+
export interface UINumberInputControl extends UIInputBase {
|
|
60
|
+
type: "number";
|
|
61
|
+
/** Minimum allowed value. */
|
|
62
|
+
min?: number;
|
|
63
|
+
/** Maximum allowed value. */
|
|
64
|
+
max?: number;
|
|
65
|
+
/** Step increment. */
|
|
66
|
+
step?: number;
|
|
67
|
+
}
|
|
68
|
+
/** Localized strings for a date input. @api */
|
|
69
|
+
export interface UIDateLocaleStrings {
|
|
70
|
+
/** Month names (12). */
|
|
71
|
+
months?: readonly string[];
|
|
72
|
+
/** Short weekday names (7). */
|
|
73
|
+
weekdaysShort?: readonly string[];
|
|
74
|
+
/** Label for "today". */
|
|
75
|
+
todayLabel?: string;
|
|
76
|
+
/** Label for "clear". */
|
|
77
|
+
clearLabel?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Date input. @api */
|
|
80
|
+
export interface UIDateInputControl extends UIInputBase {
|
|
81
|
+
type: "date";
|
|
82
|
+
/** Minimum selectable date (ISO `YYYY-MM-DD`). */
|
|
83
|
+
minDate?: string;
|
|
84
|
+
/** Maximum selectable date (ISO `YYYY-MM-DD`). */
|
|
85
|
+
maxDate?: string;
|
|
86
|
+
/** Display format. */
|
|
87
|
+
dateFormat?: string;
|
|
88
|
+
/** Per-control locale override. */
|
|
89
|
+
locale?: UIDateLocaleStrings;
|
|
90
|
+
}
|
|
91
|
+
/** Single-line text, number or date input. @api */
|
|
92
|
+
export type UIInputControl = UITextInputControl | UINumberInputControl | UIDateInputControl;
|
|
53
93
|
/** Drop-down select. @api */
|
|
54
94
|
export interface UISelectControl extends UIControlBase {
|
|
55
95
|
type: "select";
|
|
@@ -68,13 +108,36 @@ export interface UICheckboxDescriptor extends UIControlBase {
|
|
|
68
108
|
/** Called with the new checked state. */
|
|
69
109
|
onChange: (checked: boolean) => void;
|
|
70
110
|
}
|
|
111
|
+
/** Radio option. @api */
|
|
112
|
+
export interface UIRadioOption {
|
|
113
|
+
/** Value of the item. */
|
|
114
|
+
value: string;
|
|
115
|
+
/** Human-readable label. */
|
|
116
|
+
label: string;
|
|
117
|
+
}
|
|
118
|
+
/** Radio button group. @api */
|
|
119
|
+
export interface UIRadioControl extends UIControlBase {
|
|
120
|
+
type: "radio";
|
|
121
|
+
/** Layout direction of the options. @default "row" */
|
|
122
|
+
direction?: "row" | "column";
|
|
123
|
+
/** Available options. */
|
|
124
|
+
options: UIRadioOption[];
|
|
125
|
+
/** Currently selected value. */
|
|
126
|
+
value: string;
|
|
127
|
+
/** Called with the newly selected value. */
|
|
128
|
+
onChange: (value: string) => void;
|
|
129
|
+
}
|
|
71
130
|
/** Push button. @api */
|
|
72
131
|
export interface UIButtonControl extends UIControlBase {
|
|
73
132
|
type: "button";
|
|
74
133
|
/** Button caption. */
|
|
75
|
-
text
|
|
134
|
+
text?: string;
|
|
135
|
+
/** Icon name rendered inside the button. */
|
|
136
|
+
icon?: string;
|
|
76
137
|
/** Visual emphasis. @default "secondary" */
|
|
77
|
-
variant?: "primary" | "secondary";
|
|
138
|
+
variant?: "primary" | "secondary" | "ghost";
|
|
139
|
+
/** CSS width; when omitted the button stretches to full parent width. */
|
|
140
|
+
width?: string;
|
|
78
141
|
/** Called when the button is clicked. */
|
|
79
142
|
onClick: () => void;
|
|
80
143
|
}
|
|
@@ -106,13 +169,27 @@ export interface UIMultiSelectControl extends UIControlBase {
|
|
|
106
169
|
/** Container laying out child controls. @api */
|
|
107
170
|
export interface UIGroupControl extends UIControlBase {
|
|
108
171
|
type: "group";
|
|
109
|
-
/** Layout direction. @default "
|
|
172
|
+
/** Layout direction. @default "row" */
|
|
110
173
|
direction?: "row" | "column";
|
|
174
|
+
/** Gap between child controls. @default "var(--omnigrid-control-gap, 8px)" */
|
|
175
|
+
gap?: string;
|
|
111
176
|
/** Nested controls. */
|
|
112
177
|
children: UIControlDescriptor[];
|
|
113
178
|
}
|
|
179
|
+
/** Renders a monochrome icon resolved through the grid's icon registry. @api */
|
|
180
|
+
export interface UIIconControl extends UIControlBase {
|
|
181
|
+
type: "icon";
|
|
182
|
+
/** Icon name resolved through {@link GridApi.icons}. */
|
|
183
|
+
name: string;
|
|
184
|
+
}
|
|
185
|
+
/** Visual separator. @api */
|
|
186
|
+
export interface UISeparatorControl extends UIControlBase {
|
|
187
|
+
type: "separator";
|
|
188
|
+
/** Orientation. @default "horizontal" */
|
|
189
|
+
orientation?: "horizontal" | "vertical";
|
|
190
|
+
}
|
|
114
191
|
/** Any declarative control. @api */
|
|
115
|
-
export type UIControlDescriptor = UIInputControl | UISelectControl | UICheckboxDescriptor | UIButtonControl | UITextBlockControl | UIMultiSelectControl | UIGroupControl;
|
|
192
|
+
export type UIControlDescriptor = UIInputControl | UISelectControl | UICheckboxDescriptor | UIRadioControl | UIButtonControl | UITextBlockControl | UIMultiSelectControl | UIGroupControl | UIIconControl | UISeparatorControl;
|
|
116
193
|
/** Viewport-relative anchor rectangle (CSS pixels) a popup is positioned against. @api */
|
|
117
194
|
export interface UIPopupAnchor {
|
|
118
195
|
x: number;
|
package/dist/virtualizer.d.ts
CHANGED
|
@@ -104,6 +104,12 @@ export declare class Virtualizer<T> {
|
|
|
104
104
|
constructor(options: VirtualizerOptions);
|
|
105
105
|
/** Dynamic height registry backing variable-height mode. @api */
|
|
106
106
|
get rowHeights(): RowHeightRegistry;
|
|
107
|
+
/**
|
|
108
|
+
* Updates the base row height used for fixed-height grids and invalidates
|
|
109
|
+
* the memoized row range (its cache key does not include the row height).
|
|
110
|
+
* @api
|
|
111
|
+
*/
|
|
112
|
+
setBaseRowHeight(height: number): void;
|
|
107
113
|
/** Estimated height used for rows without a measurement. @api */
|
|
108
114
|
get estimatedRowHeight(): number;
|
|
109
115
|
/** Whether any variable-height input exists (resolver counts or measured heights exist). @api */
|
package/dist/virtualizer.js
CHANGED
|
@@ -248,6 +248,21 @@ export class Virtualizer {
|
|
|
248
248
|
get rowHeights() {
|
|
249
249
|
return this.heights;
|
|
250
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Updates the base row height used for fixed-height grids and invalidates
|
|
253
|
+
* the memoized row range (its cache key does not include the row height).
|
|
254
|
+
* @api
|
|
255
|
+
*/
|
|
256
|
+
setBaseRowHeight(height) {
|
|
257
|
+
if (!Number.isFinite(height) || height <= 0)
|
|
258
|
+
return;
|
|
259
|
+
const rounded = Math.round(height);
|
|
260
|
+
if (this.options.rowHeight === rounded)
|
|
261
|
+
return;
|
|
262
|
+
this.options.rowHeight = rounded;
|
|
263
|
+
this.lastScrollTop = null;
|
|
264
|
+
this.lastRowRange = null;
|
|
265
|
+
}
|
|
251
266
|
/** Estimated height used for rows without a measurement. @api */
|
|
252
267
|
get estimatedRowHeight() {
|
|
253
268
|
return this.options.estimatedRowHeight ?? this.options.rowHeight;
|