@omnigrid/core 0.1.14 → 0.1.16
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 +3 -1
- package/dist/grid.d.ts +18 -0
- package/dist/grid.js +50 -7
- package/dist/types.d.ts +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,8 @@ state, the data pipeline, 2D virtualization, DOM-pool row mapping, slots, and pl
|
|
|
18
18
|
|
|
19
19
|
**Scroll is ephemeral, not state.** `scrollTop`/`scrollLeft` are kept out of the Store:
|
|
20
20
|
scroll-only `setViewport({ scrollTop, scrollLeft })` calls never notify subscribers, so adapters do
|
|
21
|
-
not re-render on scroll frames. Read them via `getScrollPosition()
|
|
21
|
+
not re-render on scroll frames. Read them via `getScrollPosition()`; use `scrollTo()` to request an
|
|
22
|
+
adapter-native scroll adjustment without moving scroll coordinates into the Store.
|
|
22
23
|
|
|
23
24
|
## Key contracts
|
|
24
25
|
|
|
@@ -109,6 +110,7 @@ UI code must never touch core internals directly.
|
|
|
109
110
|
interface GridApi<T> {
|
|
110
111
|
getState(): GridState<T>; // { data, columns, viewport, rowHeight, rowOverscan, columnOverscan }
|
|
111
112
|
getScrollPosition(): ScrollPosition; // ephemeral scrollTop/scrollLeft
|
|
113
|
+
scrollTo(position: Partial<ScrollPosition>): void; // request a native scroll adjustment from the adapter
|
|
112
114
|
getViewportData(): ViewportData<T>; // virtualized window: rows/columns + absolute offsets
|
|
113
115
|
getProcessedData(): T[]; // after all registered data processors
|
|
114
116
|
getRowId(row: T, index: number): RowId;
|
package/dist/grid.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
7
7
|
private readonly events;
|
|
8
8
|
private readonly virtualizer;
|
|
9
9
|
private readonly cleanupPlugins;
|
|
10
|
+
private readonly pluginRegistrations;
|
|
10
11
|
private readonly dataProcessors;
|
|
11
12
|
private readonly resolveRowId;
|
|
12
13
|
readonly slots: SlotManager<T>;
|
|
@@ -21,6 +22,7 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
21
22
|
* - `overlayManual`: whether the overlay was set manually (showOverlay), which
|
|
22
23
|
* disables auto-evaluation until hideOverlay re-enables it.
|
|
23
24
|
*/
|
|
25
|
+
private readonly licenseKey;
|
|
24
26
|
private loading;
|
|
25
27
|
private hasData;
|
|
26
28
|
private loadError;
|
|
@@ -41,6 +43,12 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
41
43
|
getState(): GridState<T>;
|
|
42
44
|
/** Returns the current ephemeral scroll position (not part of Store state). */
|
|
43
45
|
getScrollPosition(): ScrollPosition;
|
|
46
|
+
/**
|
|
47
|
+
* Requests the adapter to update the native scroll position.
|
|
48
|
+
* @param position - Partial scroll coordinates to set.
|
|
49
|
+
* @api
|
|
50
|
+
*/
|
|
51
|
+
scrollTo(position: Partial<ScrollPosition>): void;
|
|
44
52
|
getViewportData(): ViewportData<T>;
|
|
45
53
|
getProcessedData(): T[];
|
|
46
54
|
getRowId(row: T, index: number): RowId;
|
|
@@ -70,6 +78,15 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
70
78
|
on<EventName extends keyof GridEvents<T>>(event: EventName, listener: (payload: GridEvents<T>[EventName]) => void): () => void;
|
|
71
79
|
emit<EventName extends keyof GridEvents<T>>(event: EventName, payload: GridEvents<T>[EventName]): void;
|
|
72
80
|
registerPlugin(plugin: GridPlugin<T>): () => void;
|
|
81
|
+
/**
|
|
82
|
+
* Reconciles the registered plugins with the given list: plugins missing from
|
|
83
|
+
* the list are unregistered (their cleanup restores default behavior), new
|
|
84
|
+
* ones are registered. Plugins already registered are left untouched.
|
|
85
|
+
* When the set actually changes, the vertical scroll position is reset to
|
|
86
|
+
* the top, since the plugin set redefines how rows are sourced.
|
|
87
|
+
* @param plugins - The desired plugin set.
|
|
88
|
+
*/
|
|
89
|
+
setPlugins(plugins: GridPlugin<T>[] | null | undefined): void;
|
|
73
90
|
getSlotMounts(slot: SlotName): SlotMount<T>[];
|
|
74
91
|
showOverlay(options: OverlayOptions): void;
|
|
75
92
|
hideOverlay(): void;
|
|
@@ -86,6 +103,7 @@ export declare class Grid<T> implements GridApi<T> {
|
|
|
86
103
|
/** Monotonic counter for structural changes (refresh / data / columns). */
|
|
87
104
|
getRevision(): number;
|
|
88
105
|
destroy(): void;
|
|
106
|
+
getLicenseKey(): string | undefined;
|
|
89
107
|
isDestroyed(): boolean;
|
|
90
108
|
private assertActive;
|
|
91
109
|
}
|
package/dist/grid.js
CHANGED
|
@@ -9,18 +9,12 @@ export class Grid {
|
|
|
9
9
|
constructor(options) {
|
|
10
10
|
this.events = new EventBus();
|
|
11
11
|
this.cleanupPlugins = new Set();
|
|
12
|
+
this.pluginRegistrations = new Map();
|
|
12
13
|
this.dataProcessors = new Set();
|
|
13
14
|
this.icons = new IconRegistry();
|
|
14
15
|
this.processedDataCache = null;
|
|
15
16
|
this.revision = 0;
|
|
16
17
|
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
18
|
this.loading = false;
|
|
25
19
|
this.hasData = true;
|
|
26
20
|
this.overlayState = { type: null };
|
|
@@ -44,6 +38,7 @@ export class Grid {
|
|
|
44
38
|
overlay: { type: null },
|
|
45
39
|
};
|
|
46
40
|
this.store = new Store(state);
|
|
41
|
+
this.licenseKey = options.licenseKey;
|
|
47
42
|
this.resolveRowId = options.getRowId ?? ((_row, index) => index);
|
|
48
43
|
this.loading = options.loading ?? false;
|
|
49
44
|
this.hasData = options.data !== undefined && options.data !== null;
|
|
@@ -93,6 +88,19 @@ export class Grid {
|
|
|
93
88
|
getScrollPosition() {
|
|
94
89
|
return this.scrollPosition;
|
|
95
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Requests the adapter to update the native scroll position.
|
|
93
|
+
* @param position - Partial scroll coordinates to set.
|
|
94
|
+
* @api
|
|
95
|
+
*/
|
|
96
|
+
scrollTo(position) {
|
|
97
|
+
this.assertActive();
|
|
98
|
+
const nextPosition = { ...this.scrollPosition, ...position };
|
|
99
|
+
if (nextPosition.scrollTop === this.scrollPosition.scrollTop && nextPosition.scrollLeft === this.scrollPosition.scrollLeft)
|
|
100
|
+
return;
|
|
101
|
+
this.scrollPosition = nextPosition;
|
|
102
|
+
this.events.emit("scrollTo", nextPosition);
|
|
103
|
+
}
|
|
96
104
|
getViewportData() {
|
|
97
105
|
const state = this.getState();
|
|
98
106
|
const processedData = this.getProcessedData();
|
|
@@ -334,10 +342,42 @@ export class Grid {
|
|
|
334
342
|
const unregister = () => {
|
|
335
343
|
cleanup?.();
|
|
336
344
|
this.cleanupPlugins.delete(unregister);
|
|
345
|
+
if (this.pluginRegistrations.get(plugin) === unregister)
|
|
346
|
+
this.pluginRegistrations.delete(plugin);
|
|
337
347
|
};
|
|
338
348
|
this.cleanupPlugins.add(unregister);
|
|
349
|
+
this.pluginRegistrations.set(plugin, unregister);
|
|
339
350
|
return unregister;
|
|
340
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Reconciles the registered plugins with the given list: plugins missing from
|
|
354
|
+
* the list are unregistered (their cleanup restores default behavior), new
|
|
355
|
+
* ones are registered. Plugins already registered are left untouched.
|
|
356
|
+
* When the set actually changes, the vertical scroll position is reset to
|
|
357
|
+
* the top, since the plugin set redefines how rows are sourced.
|
|
358
|
+
* @param plugins - The desired plugin set.
|
|
359
|
+
*/
|
|
360
|
+
setPlugins(plugins) {
|
|
361
|
+
this.assertActive();
|
|
362
|
+
const next = plugins ?? [];
|
|
363
|
+
let changed = false;
|
|
364
|
+
Array.from(this.pluginRegistrations.entries()).forEach(([plugin, unregister]) => {
|
|
365
|
+
if (!next.includes(plugin)) {
|
|
366
|
+
unregister();
|
|
367
|
+
changed = true;
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
next.forEach((plugin) => {
|
|
371
|
+
if (!this.pluginRegistrations.has(plugin)) {
|
|
372
|
+
this.registerPlugin(plugin);
|
|
373
|
+
changed = true;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
if (changed) {
|
|
377
|
+
this.scrollTo({ scrollTop: 0 });
|
|
378
|
+
this.refresh();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
341
381
|
getSlotMounts(slot) {
|
|
342
382
|
return this.slots.getMounts(slot);
|
|
343
383
|
}
|
|
@@ -426,6 +466,9 @@ export class Grid {
|
|
|
426
466
|
this.events.clear();
|
|
427
467
|
this.destroyed = true;
|
|
428
468
|
}
|
|
469
|
+
getLicenseKey() {
|
|
470
|
+
return this.licenseKey;
|
|
471
|
+
}
|
|
429
472
|
isDestroyed() {
|
|
430
473
|
return this.destroyed;
|
|
431
474
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -260,6 +260,13 @@ export interface GridOptions<T> {
|
|
|
260
260
|
getRowClass?: (params: RowRenderParams<T>) => string | undefined;
|
|
261
261
|
rowClassRules?: RowClassRules<T>;
|
|
262
262
|
plugins?: GridPlugin<T>[];
|
|
263
|
+
/**
|
|
264
|
+
* License key for Pro plugins. When provided, Pro plugins verify the
|
|
265
|
+
* cryptographic signature and activate full functionality. When missing
|
|
266
|
+
* or invalid, Pro plugins enter demo mode with a non-intrusive watermark.
|
|
267
|
+
* @api
|
|
268
|
+
*/
|
|
269
|
+
licenseKey?: string;
|
|
263
270
|
/** Whether data is currently being fetched. Triggers a loading overlay. @default false when data is supplied */
|
|
264
271
|
loading?: boolean;
|
|
265
272
|
/**
|
|
@@ -378,6 +385,7 @@ export interface GridState<T> {
|
|
|
378
385
|
export interface GridEvents<T> {
|
|
379
386
|
stateChange: GridState<T>;
|
|
380
387
|
viewportChange: ViewportState;
|
|
388
|
+
scrollTo: ScrollPosition;
|
|
381
389
|
dataChange: T[];
|
|
382
390
|
headerClick: {
|
|
383
391
|
columnId: string;
|
|
@@ -470,7 +478,7 @@ export interface GridPlugin<T> {
|
|
|
470
478
|
getRowClass?(params: RowRenderParams<T>): string | undefined;
|
|
471
479
|
getRowStyle?(params: RowRenderParams<T>): RowStyle | undefined;
|
|
472
480
|
}
|
|
473
|
-
export type SlotName = "top" | "bottom" | "left" | "right";
|
|
481
|
+
export type SlotName = "top" | "bottom" | "left" | "right" | "bodyTop" | "bodyBottom";
|
|
474
482
|
export type SlotPosition = "start" | "center" | "end";
|
|
475
483
|
/**
|
|
476
484
|
* Placement of a single UI block that a plugin mounts into a slot.
|
|
@@ -563,6 +571,12 @@ export interface SlotMount<T> {
|
|
|
563
571
|
export interface GridApi<T> {
|
|
564
572
|
getState(): GridState<T>;
|
|
565
573
|
getScrollPosition(): ScrollPosition;
|
|
574
|
+
/**
|
|
575
|
+
* Requests a native scroll position update from the active adapter.
|
|
576
|
+
* @param position - Scroll coordinates to update.
|
|
577
|
+
* @api
|
|
578
|
+
*/
|
|
579
|
+
scrollTo(position: Partial<ScrollPosition>): void;
|
|
566
580
|
getViewportData(): ViewportData<T>;
|
|
567
581
|
getColumnWidth(columnId: string): number | undefined;
|
|
568
582
|
getProcessedData(): T[];
|
|
@@ -593,6 +607,12 @@ export interface GridApi<T> {
|
|
|
593
607
|
readonly slots: SlotManager<T>;
|
|
594
608
|
readonly icons: IconRegistry<T>;
|
|
595
609
|
getSlotMounts(slot: SlotName): SlotMount<T>[];
|
|
610
|
+
/**
|
|
611
|
+
* Returns the `licenseKey` supplied in `GridOptions`. The core never
|
|
612
|
+
* interprets the key; Pro plugins verify it themselves.
|
|
613
|
+
* @api
|
|
614
|
+
*/
|
|
615
|
+
getLicenseKey(): string | undefined;
|
|
596
616
|
/**
|
|
597
617
|
* Shows an overlay using the supplied options.
|
|
598
618
|
*
|