@omnigrid/core 0.1.7 → 0.1.9
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 +30 -2
- package/dist/grid.d.ts +28 -1
- package/dist/grid.js +91 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/overlays.d.ts +67 -0
- package/dist/overlays.js +25 -0
- package/dist/types.d.ts +73 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ not re-render on scroll frames. Read them via `getScrollPosition()`.
|
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
interface GridOptions<T> {
|
|
29
|
-
data?: T[];
|
|
29
|
+
data?: T[] | null; // row data; null/omitted means initial loading
|
|
30
30
|
columns: ColumnDef<T>[]; // required
|
|
31
31
|
getRowId?: (row: T, index: number) => RowId; // default: index-based
|
|
32
32
|
rowHeight?: number; // fixed px row height; default 32 (offset math is O(1))
|
|
@@ -39,6 +39,8 @@ interface GridOptions<T> {
|
|
|
39
39
|
getRowClass?: (params: RowRenderParams<T>) => string | undefined;
|
|
40
40
|
rowClassRules?: RowClassRules<T>; // class name → predicate
|
|
41
41
|
plugins?: GridPlugin<T>[]; // plugin instances registered at construction
|
|
42
|
+
loading?: boolean; // active fetch; shows loading even with prior rows
|
|
43
|
+
overlayComponents?: Record<string, OverlayComponent<T>>;
|
|
42
44
|
}
|
|
43
45
|
```
|
|
44
46
|
|
|
@@ -97,7 +99,7 @@ interface GridApi<T> {
|
|
|
97
99
|
getViewportData(): ViewportData<T>; // virtualized window: rows/columns + absolute offsets
|
|
98
100
|
getProcessedData(): T[]; // after all registered data processors
|
|
99
101
|
getRowId(row: T, index: number): RowId;
|
|
100
|
-
setData(data: T[]): void;
|
|
102
|
+
setData(data: T[] | null | undefined): void;
|
|
101
103
|
setViewport(viewport: Partial<ViewportState>): void; // width/height/scrollTop/scrollLeft; scroll-only ⇒ no Store notify
|
|
102
104
|
refresh(): void; // repaint hints (rowClassRules), bumps revision
|
|
103
105
|
subscribe(listener: () => void): () => void;
|
|
@@ -111,12 +113,38 @@ interface GridApi<T> {
|
|
|
111
113
|
readonly slots: SlotManager<T>; // mount headless widgets
|
|
112
114
|
readonly icons: IconRegistry<T>; // declarative SVG icons for plugin UI
|
|
113
115
|
getSlotMounts(slot: SlotName): SlotMount<T>[];
|
|
116
|
+
showOverlay(options: OverlayOptions): void;
|
|
117
|
+
hideOverlay(): void;
|
|
118
|
+
getOverlayState(): OverlayState;
|
|
119
|
+
setLoading(isLoading: boolean, error?: unknown): void;
|
|
114
120
|
getRevision(): number; // monotonic counter for structural changes
|
|
115
121
|
destroy(): void;
|
|
116
122
|
isDestroyed(): boolean;
|
|
117
123
|
}
|
|
118
124
|
```
|
|
119
125
|
|
|
126
|
+
### Overlays
|
|
127
|
+
|
|
128
|
+
Overlays are managed in core state, so state transitions notify subscribers only when the
|
|
129
|
+
overlay changes (scroll position stays ephemeral). Initial `data: null` or omitted data shows
|
|
130
|
+
loading; an explicit empty array shows the no-rows state. Empty processed results with source
|
|
131
|
+
rows show no-matching-rows and leave horizontal column inspection enabled. Report fetch failures
|
|
132
|
+
through `setLoading(false, error)`; a successful `setData` clears the error.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
grid.showOverlay({
|
|
136
|
+
type: "error",
|
|
137
|
+
scope: "bodyOnly", // or "full" to cover the complete grid
|
|
138
|
+
blockScroll: false, // keep horizontal scrolling; body overlays always lock vertical scroll
|
|
139
|
+
message: "Could not load records",
|
|
140
|
+
});
|
|
141
|
+
grid.hideOverlay(); // restores automatic loading / empty-state evaluation
|
|
142
|
+
const overlay = grid.getOverlayState();
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`overlayComponents` accepts framework-specific components through the adapter or core render
|
|
146
|
+
callbacks. Component props include `type`, `message`, `payload`, and the current `state`.
|
|
147
|
+
|
|
120
148
|
`GridEvents<T>`: `stateChange` | `viewportChange` | `dataChange` | `headerClick` | `rowClick` | `rowHover` | `slotsChange`.
|
|
121
149
|
Example: `grid.on("rowClick", (e) => console.log(e.id, e.index, e.data))`.
|
|
122
150
|
|
package/dist/grid.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IconRegistry } from "./icons";
|
|
2
2
|
import { SlotManager } from "./slots";
|
|
3
3
|
import type { DataProcessor, GridApi, GridEvents, GridOptions, GridPlugin, GridState, RowClickEvent, RowHoverEvent, RowId, ScrollPosition, SlotMount, SlotName, ViewportData, ViewportState } from "./types";
|
|
4
|
+
import type { OverlayOptions, OverlayState, OverlayType } from "./overlays";
|
|
4
5
|
export declare class Grid<T> implements GridApi<T> {
|
|
5
6
|
private readonly store;
|
|
6
7
|
private readonly events;
|
|
@@ -13,6 +14,18 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
13
14
|
private processedDataCache;
|
|
14
15
|
private revision;
|
|
15
16
|
private destroyed;
|
|
17
|
+
/**
|
|
18
|
+
* Overlay management state:
|
|
19
|
+
* - `loading`: whether the grid is fetching data (set via setLoading / options.loading)
|
|
20
|
+
* - `overlayState`: the current active overlay (type + payload)
|
|
21
|
+
* - `overlayManual`: whether the overlay was set manually (showOverlay), which
|
|
22
|
+
* disables auto-evaluation until hideOverlay re-enables it.
|
|
23
|
+
*/
|
|
24
|
+
private loading;
|
|
25
|
+
private hasData;
|
|
26
|
+
private loadError;
|
|
27
|
+
private overlayState;
|
|
28
|
+
private overlayManual;
|
|
16
29
|
/**
|
|
17
30
|
* Separate ephemeral scroll position that is NOT stored in the Store.
|
|
18
31
|
*
|
|
@@ -31,7 +44,7 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
31
44
|
getViewportData(): ViewportData<T>;
|
|
32
45
|
getProcessedData(): T[];
|
|
33
46
|
getRowId(row: T, index: number): RowId;
|
|
34
|
-
setData(data: T[]): void;
|
|
47
|
+
setData(data: T[] | null | undefined): void;
|
|
35
48
|
setViewport(viewport: Partial<ViewportState>): void;
|
|
36
49
|
/**
|
|
37
50
|
* Repaints the current viewport: notifies Store subscribers that
|
|
@@ -50,6 +63,20 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
50
63
|
emit<EventName extends keyof GridEvents<T>>(event: EventName, payload: GridEvents<T>[EventName]): void;
|
|
51
64
|
registerPlugin(plugin: GridPlugin<T>): () => void;
|
|
52
65
|
getSlotMounts(slot: SlotName): SlotMount<T>[];
|
|
66
|
+
showOverlay(options: OverlayOptions): void;
|
|
67
|
+
/** @deprecated Use the options-object overload. */
|
|
68
|
+
showOverlay(type: OverlayType, payload?: unknown): void;
|
|
69
|
+
hideOverlay(): void;
|
|
70
|
+
getOverlayState(): OverlayState;
|
|
71
|
+
setLoading(isLoading: boolean, error?: unknown): void;
|
|
72
|
+
/**
|
|
73
|
+
* Re-evaluates the overlay based on the current Data Pipeline state.
|
|
74
|
+
*
|
|
75
|
+
* Skipped when a manual overlay is active (set via `showOverlay`). The
|
|
76
|
+
* Store is only updated when the overlay type actually changes — identical
|
|
77
|
+
* evaluations are a no-op to avoid spurious React re-renders.
|
|
78
|
+
*/
|
|
79
|
+
private recomputeOverlay;
|
|
53
80
|
/** Monotonic counter for structural changes (refresh / data / columns). */
|
|
54
81
|
getRevision(): number;
|
|
55
82
|
destroy(): void;
|
package/dist/grid.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { flattenColumns, getColumnGroups } from "./columns";
|
|
2
2
|
import { EventBus } from "./events";
|
|
3
|
+
import { evaluateAutoOverlay } from "./overlays";
|
|
3
4
|
import { IconRegistry } from "./icons";
|
|
4
5
|
import { SlotManager } from "./slots";
|
|
5
6
|
import { Store } from "./store";
|
|
@@ -13,6 +14,17 @@ export class Grid {
|
|
|
13
14
|
this.processedDataCache = null;
|
|
14
15
|
this.revision = 0;
|
|
15
16
|
this.destroyed = false;
|
|
17
|
+
/**
|
|
18
|
+
* Overlay management state:
|
|
19
|
+
* - `loading`: whether the grid is fetching data (set via setLoading / options.loading)
|
|
20
|
+
* - `overlayState`: the current active overlay (type + payload)
|
|
21
|
+
* - `overlayManual`: whether the overlay was set manually (showOverlay), which
|
|
22
|
+
* disables auto-evaluation until hideOverlay re-enables it.
|
|
23
|
+
*/
|
|
24
|
+
this.loading = false;
|
|
25
|
+
this.hasData = true;
|
|
26
|
+
this.overlayState = { type: null };
|
|
27
|
+
this.overlayManual = false;
|
|
16
28
|
/**
|
|
17
29
|
* Separate ephemeral scroll position that is NOT stored in the Store.
|
|
18
30
|
*
|
|
@@ -29,9 +41,12 @@ export class Grid {
|
|
|
29
41
|
rowHeight: options.rowHeight ?? 32,
|
|
30
42
|
rowOverscan: options.rowOverscan ?? 5,
|
|
31
43
|
columnOverscan: options.columnOverscan ?? 2,
|
|
44
|
+
overlay: { type: null },
|
|
32
45
|
};
|
|
33
46
|
this.store = new Store(state);
|
|
34
47
|
this.resolveRowId = options.getRowId ?? ((_row, index) => index);
|
|
48
|
+
this.loading = options.loading ?? false;
|
|
49
|
+
this.hasData = options.data !== undefined && options.data !== null;
|
|
35
50
|
this.virtualizer = new Virtualizer({
|
|
36
51
|
rowHeight: state.rowHeight,
|
|
37
52
|
rowOverscan: state.rowOverscan,
|
|
@@ -45,6 +60,7 @@ export class Grid {
|
|
|
45
60
|
});
|
|
46
61
|
this.store.subscribe(() => this.events.emit("stateChange", this.store.getState()));
|
|
47
62
|
options.plugins?.forEach((plugin) => this.registerPlugin(plugin));
|
|
63
|
+
this.recomputeOverlay();
|
|
48
64
|
}
|
|
49
65
|
/** Returns the calculated width for a visible column, including off-screen columns. */
|
|
50
66
|
getColumnWidth(columnId) {
|
|
@@ -180,10 +196,14 @@ export class Grid {
|
|
|
180
196
|
}
|
|
181
197
|
setData(data) {
|
|
182
198
|
this.assertActive();
|
|
199
|
+
this.loadError = undefined;
|
|
200
|
+
this.hasData = data !== undefined && data !== null;
|
|
201
|
+
const nextData = data ?? [];
|
|
183
202
|
this.processedDataCache = null;
|
|
184
203
|
this.revision += 1;
|
|
185
|
-
this.store.setState({ data });
|
|
186
|
-
this.events.emit("dataChange",
|
|
204
|
+
this.store.setState({ data: nextData });
|
|
205
|
+
this.events.emit("dataChange", nextData);
|
|
206
|
+
this.recomputeOverlay();
|
|
187
207
|
}
|
|
188
208
|
setViewport(viewport) {
|
|
189
209
|
this.assertActive();
|
|
@@ -245,14 +265,18 @@ export class Grid {
|
|
|
245
265
|
this.processedDataCache = null;
|
|
246
266
|
this.revision += 1;
|
|
247
267
|
this.store.setState({ columns });
|
|
268
|
+
this.recomputeOverlay();
|
|
248
269
|
}
|
|
249
270
|
registerDataProcessor(processor) {
|
|
250
271
|
this.assertActive();
|
|
251
272
|
this.dataProcessors.add(processor);
|
|
252
273
|
this.processedDataCache = null;
|
|
274
|
+
this.recomputeOverlay();
|
|
253
275
|
const unregister = () => {
|
|
254
276
|
this.dataProcessors.delete(processor);
|
|
255
277
|
this.processedDataCache = null;
|
|
278
|
+
if (!this.destroyed)
|
|
279
|
+
this.recomputeOverlay();
|
|
256
280
|
};
|
|
257
281
|
return unregister;
|
|
258
282
|
}
|
|
@@ -294,6 +318,69 @@ export class Grid {
|
|
|
294
318
|
getSlotMounts(slot) {
|
|
295
319
|
return this.slots.getMounts(slot);
|
|
296
320
|
}
|
|
321
|
+
showOverlay(optionsOrType, payload) {
|
|
322
|
+
this.assertActive();
|
|
323
|
+
const options = typeof optionsOrType === "string" ? { type: optionsOrType, payload } : optionsOrType;
|
|
324
|
+
this.overlayManual = true;
|
|
325
|
+
this.overlayState = { ...options };
|
|
326
|
+
this.store.setState({ overlay: { ...this.overlayState } });
|
|
327
|
+
this.events.emit("overlayChange", { ...this.overlayState });
|
|
328
|
+
}
|
|
329
|
+
hideOverlay() {
|
|
330
|
+
this.assertActive();
|
|
331
|
+
this.overlayManual = false;
|
|
332
|
+
this.recomputeOverlay();
|
|
333
|
+
}
|
|
334
|
+
getOverlayState() {
|
|
335
|
+
return { ...this.overlayState };
|
|
336
|
+
}
|
|
337
|
+
setLoading(isLoading, error) {
|
|
338
|
+
this.assertActive();
|
|
339
|
+
const nextError = isLoading ? undefined : error;
|
|
340
|
+
if (this.loading === isLoading && this.loadError === nextError)
|
|
341
|
+
return;
|
|
342
|
+
this.loading = isLoading;
|
|
343
|
+
this.loadError = nextError;
|
|
344
|
+
this.recomputeOverlay();
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Re-evaluates the overlay based on the current Data Pipeline state.
|
|
348
|
+
*
|
|
349
|
+
* Skipped when a manual overlay is active (set via `showOverlay`). The
|
|
350
|
+
* Store is only updated when the overlay type actually changes — identical
|
|
351
|
+
* evaluations are a no-op to avoid spurious React re-renders.
|
|
352
|
+
*/
|
|
353
|
+
recomputeOverlay() {
|
|
354
|
+
if (this.destroyed)
|
|
355
|
+
return;
|
|
356
|
+
if (this.overlayManual)
|
|
357
|
+
return;
|
|
358
|
+
const state = this.store.getState();
|
|
359
|
+
const processedData = this.getProcessedData();
|
|
360
|
+
const type = evaluateAutoOverlay({
|
|
361
|
+
loading: this.loading || !this.hasData,
|
|
362
|
+
error: this.loadError,
|
|
363
|
+
rawData: state.data,
|
|
364
|
+
processedData,
|
|
365
|
+
});
|
|
366
|
+
const next = type
|
|
367
|
+
? {
|
|
368
|
+
type,
|
|
369
|
+
...(type === "error" && this.loadError !== undefined ? { payload: this.loadError } : {}),
|
|
370
|
+
...(type === "noMatchingRows" ? { blockScroll: false } : {}),
|
|
371
|
+
}
|
|
372
|
+
: { type };
|
|
373
|
+
if (next.type !== this.overlayState.type ||
|
|
374
|
+
next.payload !== this.overlayState.payload ||
|
|
375
|
+
next.scope !== this.overlayState.scope ||
|
|
376
|
+
next.blockScroll !== this.overlayState.blockScroll ||
|
|
377
|
+
next.message !== this.overlayState.message ||
|
|
378
|
+
next.component !== this.overlayState.component) {
|
|
379
|
+
this.overlayState = next;
|
|
380
|
+
this.store.setState({ overlay: { ...next } });
|
|
381
|
+
this.events.emit("overlayChange", { ...next });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
297
384
|
/** Monotonic counter for structural changes (refresh / data / columns). */
|
|
298
385
|
getRevision() {
|
|
299
386
|
return this.revision;
|
|
@@ -305,6 +392,8 @@ export class Grid {
|
|
|
305
392
|
this.cleanupPlugins.clear();
|
|
306
393
|
this.dataProcessors.clear();
|
|
307
394
|
this.processedDataCache = null;
|
|
395
|
+
this.overlayState = { type: null };
|
|
396
|
+
this.overlayManual = false;
|
|
308
397
|
this.slots.clear();
|
|
309
398
|
this.store.clear();
|
|
310
399
|
this.events.clear();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { DomPool } from "./dom-pool";
|
|
2
2
|
export { EventBus } from "./events";
|
|
3
|
+
export { evaluateAutoOverlay } from "./overlays";
|
|
3
4
|
export { IconRegistry } from "./icons";
|
|
4
5
|
export type { IconDefinition, IconName } from "./icons";
|
|
5
6
|
export { Grid } from "./grid";
|
|
6
7
|
export { Grid as GridCore } from "./grid";
|
|
7
8
|
export { SlotManager } from "./slots";
|
|
8
9
|
export { Store } from "./store";
|
|
9
|
-
export type {
|
|
10
|
+
export type { OverlayOptions, OverlayScope, OverlayState, OverlayType } from "./overlays";
|
|
11
|
+
export type { BlockConfig, CellAlign, CellRenderParams, CellClassRules, CheckboxControl, CheckboxRenderParams, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, DataProcessor, DomPoolBindings, DomPoolUpdate, GridApi, GridEvents, GridOptions, GridPlugin, GridState, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHost, RowHoverEvent, RowId, RowRenderParams, RowStyle, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, ViewportData, ViewportState, VirtualItem, } from "./types";
|
|
10
12
|
export { getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf } from "./columns";
|
|
11
13
|
export { Virtualizer } from "./virtualizer";
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Core overlay management types and evaluation logic.
|
|
3
|
+
*
|
|
4
|
+
* Overlays communicate transient states to the user: data fetching, empty
|
|
5
|
+
* results, errors, and arbitrary custom content.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported overlay types shown over the grid body viewport.
|
|
9
|
+
*
|
|
10
|
+
* @api
|
|
11
|
+
*/
|
|
12
|
+
export type OverlayType = "loading" | "noRows" | "noMatchingRows" | "error" | "custom";
|
|
13
|
+
/**
|
|
14
|
+
* Portion of the grid covered by an overlay.
|
|
15
|
+
*
|
|
16
|
+
* @api
|
|
17
|
+
*/
|
|
18
|
+
export type OverlayScope = "full" | "bodyOnly";
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for a manually displayed overlay.
|
|
21
|
+
*
|
|
22
|
+
* @api
|
|
23
|
+
*/
|
|
24
|
+
export interface OverlayOptions {
|
|
25
|
+
/** Overlay state to display. */
|
|
26
|
+
type: OverlayType;
|
|
27
|
+
/** Whether the overlay covers the complete grid or only its data body. @default "bodyOnly" */
|
|
28
|
+
scope?: OverlayScope;
|
|
29
|
+
/** Whether horizontal scrolling is also locked. Vertical scrolling is always locked by an active body overlay. */
|
|
30
|
+
blockScroll?: boolean;
|
|
31
|
+
/** Optional text displayed by the default overlay or passed to a custom component. */
|
|
32
|
+
message?: string;
|
|
33
|
+
/** Custom renderer or adapter-specific renderer identifier. */
|
|
34
|
+
component?: unknown;
|
|
35
|
+
/** Optional data passed to a custom overlay or used to derive the default message. */
|
|
36
|
+
payload?: unknown;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Active overlay type, placement, scroll policy, and optional renderer payload.
|
|
40
|
+
*
|
|
41
|
+
* @api
|
|
42
|
+
*/
|
|
43
|
+
export interface OverlayState extends Omit<OverlayOptions, "type"> {
|
|
44
|
+
/** Active overlay type, or null when no overlay is shown. */
|
|
45
|
+
type: OverlayType | null;
|
|
46
|
+
}
|
|
47
|
+
interface EvaluateAutoOverlayParams<T> {
|
|
48
|
+
/** Whether the grid is currently fetching / loading data. */
|
|
49
|
+
loading: boolean;
|
|
50
|
+
/** Error raised by the most recent data load, if any. */
|
|
51
|
+
error?: unknown;
|
|
52
|
+
/** The raw data array held by the grid (before pipeline processors). */
|
|
53
|
+
rawData: T[];
|
|
54
|
+
/** The data array after all pipeline processors (sorting, filtering, pagination). */
|
|
55
|
+
processedData: T[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Evaluates which overlay should be automatically shown based on Data Pipeline state.
|
|
59
|
+
*
|
|
60
|
+
* Priority order is loading, load error, no rows, no matching rows, then no overlay.
|
|
61
|
+
*
|
|
62
|
+
* @param params - The current pipeline state.
|
|
63
|
+
* @returns The overlay type to show, or null when no overlay is needed.
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export declare function evaluateAutoOverlay<T>(params: EvaluateAutoOverlayParams<T>): OverlayType | null;
|
|
67
|
+
export {};
|
package/dist/overlays.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Core overlay management types and evaluation logic.
|
|
3
|
+
*
|
|
4
|
+
* Overlays communicate transient states to the user: data fetching, empty
|
|
5
|
+
* results, errors, and arbitrary custom content.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Evaluates which overlay should be automatically shown based on Data Pipeline state.
|
|
9
|
+
*
|
|
10
|
+
* Priority order is loading, load error, no rows, no matching rows, then no overlay.
|
|
11
|
+
*
|
|
12
|
+
* @param params - The current pipeline state.
|
|
13
|
+
* @returns The overlay type to show, or null when no overlay is needed.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function evaluateAutoOverlay(params) {
|
|
17
|
+
if (params.loading)
|
|
18
|
+
return "loading";
|
|
19
|
+
if (params.error !== undefined)
|
|
20
|
+
return "error";
|
|
21
|
+
if (params.processedData.length === 0) {
|
|
22
|
+
return params.rawData.length === 0 ? "noRows" : "noMatchingRows";
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OverlayOptions, OverlayState, OverlayType } from "./overlays";
|
|
1
2
|
import type { SlotManager } from "./slots";
|
|
2
3
|
import type { IconRegistry } from "./icons";
|
|
3
4
|
export type RowId = string | number;
|
|
@@ -117,8 +118,30 @@ export interface ColumnGroupDef<T> extends BaseColumnDef<T> {
|
|
|
117
118
|
}
|
|
118
119
|
/** Leaf or grouped column definition accepted by the grid. */
|
|
119
120
|
export type ColumnDef<T> = ColumnLeafDef<T> | ColumnGroupDef<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Props supplied to a framework-specific overlay renderer.
|
|
123
|
+
*
|
|
124
|
+
* @api
|
|
125
|
+
*/
|
|
126
|
+
export interface OverlayComponentProps<T> {
|
|
127
|
+
/** The active overlay state. */
|
|
128
|
+
type: OverlayType;
|
|
129
|
+
/** Optional display text override. */
|
|
130
|
+
message?: string;
|
|
131
|
+
/** Custom overlay payload. */
|
|
132
|
+
payload?: unknown;
|
|
133
|
+
/** Latest public grid state. */
|
|
134
|
+
state: GridState<T>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Framework-neutral custom overlay renderer.
|
|
138
|
+
*
|
|
139
|
+
* @api
|
|
140
|
+
*/
|
|
141
|
+
export type OverlayComponent<T> = ((props: OverlayComponentProps<T>) => unknown) | ((payload: unknown, state: GridState<T>) => unknown);
|
|
120
142
|
export interface GridOptions<T> {
|
|
121
|
-
data
|
|
143
|
+
/** Row data; omitted or null means an initial load is pending. */
|
|
144
|
+
data?: T[] | null;
|
|
122
145
|
columns: ColumnDef<T>[];
|
|
123
146
|
getRowId?: (row: T, index: number) => RowId;
|
|
124
147
|
rowHeight?: number;
|
|
@@ -131,6 +154,20 @@ export interface GridOptions<T> {
|
|
|
131
154
|
getRowClass?: (params: RowRenderParams<T>) => string | undefined;
|
|
132
155
|
rowClassRules?: RowClassRules<T>;
|
|
133
156
|
plugins?: GridPlugin<T>[];
|
|
157
|
+
/** Whether data is currently being fetched. Triggers a loading overlay. @default false when data is supplied */
|
|
158
|
+
loading?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Custom overlay renderers keyed by overlay type or renderer identifier.
|
|
161
|
+
* A one-argument function receives `OverlayComponentProps`; the legacy
|
|
162
|
+
* two-argument form receives `(payload, state)`.
|
|
163
|
+
*/
|
|
164
|
+
overlayComponents?: Record<string, unknown>;
|
|
165
|
+
/**
|
|
166
|
+
* Called with the grid API instance when the grid is ready.
|
|
167
|
+
* Use this to programmatically control overlays, sorting, scrolling, etc.
|
|
168
|
+
* @api
|
|
169
|
+
*/
|
|
170
|
+
onGridReady?: (grid: GridApi<T>) => void;
|
|
134
171
|
}
|
|
135
172
|
export interface ViewportState {
|
|
136
173
|
width: number;
|
|
@@ -229,6 +266,8 @@ export interface GridState<T> {
|
|
|
229
266
|
rowHeight: number;
|
|
230
267
|
rowOverscan: number;
|
|
231
268
|
columnOverscan: number;
|
|
269
|
+
/** Active overlay state — updated automatically by the grid's overlay manager. */
|
|
270
|
+
overlay: OverlayState;
|
|
232
271
|
}
|
|
233
272
|
export interface GridEvents<T> {
|
|
234
273
|
stateChange: GridState<T>;
|
|
@@ -248,6 +287,7 @@ export interface GridEvents<T> {
|
|
|
248
287
|
slot: SlotName;
|
|
249
288
|
mounts: SlotMount<T>[];
|
|
250
289
|
};
|
|
290
|
+
overlayChange: OverlayState;
|
|
251
291
|
}
|
|
252
292
|
/** Opaque token for a row node owned by the adapter. */
|
|
253
293
|
export type RowHost<T> = object;
|
|
@@ -397,7 +437,7 @@ export interface GridApi<T> {
|
|
|
397
437
|
getColumnWidth(columnId: string): number | undefined;
|
|
398
438
|
getProcessedData(): T[];
|
|
399
439
|
getRowId(row: T, index: number): RowId;
|
|
400
|
-
setData(data: T[]): void;
|
|
440
|
+
setData(data: T[] | null | undefined): void;
|
|
401
441
|
setViewport(viewport: Partial<ViewportState>): void;
|
|
402
442
|
refresh(): void;
|
|
403
443
|
subscribe(listener: () => void): () => void;
|
|
@@ -413,6 +453,37 @@ export interface GridApi<T> {
|
|
|
413
453
|
readonly slots: SlotManager<T>;
|
|
414
454
|
readonly icons: IconRegistry<T>;
|
|
415
455
|
getSlotMounts(slot: SlotName): SlotMount<T>[];
|
|
456
|
+
/**
|
|
457
|
+
* Shows an overlay using the supplied options.
|
|
458
|
+
*
|
|
459
|
+
* Manual overlays take precedence over automatic states until `hideOverlay`
|
|
460
|
+
* is called. Vertical scrolling is locked for body overlays; `blockScroll`
|
|
461
|
+
* controls whether horizontal scrolling is locked as well.
|
|
462
|
+
* @param options - Overlay type, scope, message, and custom render payload.
|
|
463
|
+
* @api
|
|
464
|
+
*/
|
|
465
|
+
showOverlay(options: OverlayOptions): void;
|
|
466
|
+
/** @deprecated Use the options-object overload. */
|
|
467
|
+
showOverlay(type: OverlayType, payload?: unknown): void;
|
|
468
|
+
/**
|
|
469
|
+
* Hides the current overlay and re-enables automatic overlay evaluation
|
|
470
|
+
* based on the Data Pipeline state.
|
|
471
|
+
* @api
|
|
472
|
+
*/
|
|
473
|
+
hideOverlay(): void;
|
|
474
|
+
/**
|
|
475
|
+
* Returns the current overlay state (a copy).
|
|
476
|
+
* @api
|
|
477
|
+
*/
|
|
478
|
+
getOverlayState(): OverlayState;
|
|
479
|
+
/**
|
|
480
|
+
* Marks the grid as loading or not — triggers automatic overlay
|
|
481
|
+
* re-evaluation. When loading completes with an error, pass it as the
|
|
482
|
+
* second argument to show the automatic error overlay. A subsequent
|
|
483
|
+
* successful `setData` clears the error.
|
|
484
|
+
* @api
|
|
485
|
+
*/
|
|
486
|
+
setLoading(isLoading: boolean, error?: unknown): void;
|
|
416
487
|
/** Monotonic counter for structural changes (refresh / data / columns). */
|
|
417
488
|
getRevision(): number;
|
|
418
489
|
destroy(): void;
|