@omnigrid/core 0.1.13 → 0.1.15

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 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
@@ -21,6 +21,7 @@ export declare class Grid<T> implements GridApi<T> {
21
21
  * - `overlayManual`: whether the overlay was set manually (showOverlay), which
22
22
  * disables auto-evaluation until hideOverlay re-enables it.
23
23
  */
24
+ private readonly licenseKey;
24
25
  private loading;
25
26
  private hasData;
26
27
  private loadError;
@@ -41,10 +42,24 @@ export declare class Grid<T> implements GridApi<T> {
41
42
  getState(): GridState<T>;
42
43
  /** Returns the current ephemeral scroll position (not part of Store state). */
43
44
  getScrollPosition(): ScrollPosition;
45
+ /**
46
+ * Requests the adapter to update the native scroll position.
47
+ * @param position - Partial scroll coordinates to set.
48
+ * @api
49
+ */
50
+ scrollTo(position: Partial<ScrollPosition>): void;
44
51
  getViewportData(): ViewportData<T>;
45
52
  getProcessedData(): T[];
46
53
  getRowId(row: T, index: number): RowId;
47
54
  setData(data: T[] | null | undefined): void;
55
+ /**
56
+ * Chunk-append API for incremental data loading (infinite scroll, live
57
+ * feeds). Concatenates `rows` onto the existing dataset inside the State
58
+ * Store — the host does not need to re-send the whole array — then emits
59
+ * a single `dataChange` with the combined result. A no-op for empty or
60
+ * missing `rows`.
61
+ */
62
+ appendData(rows: T[] | null | undefined): void;
48
63
  setViewport(viewport: Partial<ViewportState>): void;
49
64
  /**
50
65
  * Repaints the current viewport: notifies Store subscribers that
@@ -78,6 +93,7 @@ export declare class Grid<T> implements GridApi<T> {
78
93
  /** Monotonic counter for structural changes (refresh / data / columns). */
79
94
  getRevision(): number;
80
95
  destroy(): void;
96
+ getLicenseKey(): string | undefined;
81
97
  isDestroyed(): boolean;
82
98
  private assertActive;
83
99
  }
package/dist/grid.js CHANGED
@@ -14,13 +14,6 @@ export class Grid {
14
14
  this.processedDataCache = null;
15
15
  this.revision = 0;
16
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
17
  this.loading = false;
25
18
  this.hasData = true;
26
19
  this.overlayState = { type: null };
@@ -44,6 +37,7 @@ export class Grid {
44
37
  overlay: { type: null },
45
38
  };
46
39
  this.store = new Store(state);
40
+ this.licenseKey = options.licenseKey;
47
41
  this.resolveRowId = options.getRowId ?? ((_row, index) => index);
48
42
  this.loading = options.loading ?? false;
49
43
  this.hasData = options.data !== undefined && options.data !== null;
@@ -93,6 +87,19 @@ export class Grid {
93
87
  getScrollPosition() {
94
88
  return this.scrollPosition;
95
89
  }
90
+ /**
91
+ * Requests the adapter to update the native scroll position.
92
+ * @param position - Partial scroll coordinates to set.
93
+ * @api
94
+ */
95
+ scrollTo(position) {
96
+ this.assertActive();
97
+ const nextPosition = { ...this.scrollPosition, ...position };
98
+ if (nextPosition.scrollTop === this.scrollPosition.scrollTop && nextPosition.scrollLeft === this.scrollPosition.scrollLeft)
99
+ return;
100
+ this.scrollPosition = nextPosition;
101
+ this.events.emit("scrollTo", nextPosition);
102
+ }
96
103
  getViewportData() {
97
104
  const state = this.getState();
98
105
  const processedData = this.getProcessedData();
@@ -208,6 +215,26 @@ export class Grid {
208
215
  this.events.emit("dataChange", nextData);
209
216
  this.recomputeOverlay();
210
217
  }
218
+ /**
219
+ * Chunk-append API for incremental data loading (infinite scroll, live
220
+ * feeds). Concatenates `rows` onto the existing dataset inside the State
221
+ * Store — the host does not need to re-send the whole array — then emits
222
+ * a single `dataChange` with the combined result. A no-op for empty or
223
+ * missing `rows`.
224
+ */
225
+ appendData(rows) {
226
+ this.assertActive();
227
+ if (!rows || rows.length === 0)
228
+ return;
229
+ const currentData = this.store.getState().data;
230
+ const nextData = [...currentData, ...rows];
231
+ this.hasData = true;
232
+ this.processedDataCache = null;
233
+ this.revision += 1;
234
+ this.store.setState({ data: nextData });
235
+ this.events.emit("dataChange", nextData);
236
+ this.recomputeOverlay();
237
+ }
211
238
  setViewport(viewport) {
212
239
  this.assertActive();
213
240
  const state = this.store.getState();
@@ -406,6 +433,9 @@ export class Grid {
406
433
  this.events.clear();
407
434
  this.destroyed = true;
408
435
  }
436
+ getLicenseKey() {
437
+ return this.licenseKey;
438
+ }
409
439
  isDestroyed() {
410
440
  return this.destroyed;
411
441
  }
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,11 +571,27 @@ 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[];
569
583
  getRowId(row: T, index: number): RowId;
570
584
  setData(data: T[] | null | undefined): void;
585
+ /**
586
+ * Chunk-append API for incremental data loading (infinite scroll, live
587
+ * feeds): appends `rows` to the end of the existing dataset without
588
+ * rebuilding it from the host side. Patches the State Store directly and
589
+ * emits a single `dataChange` with the combined array. Empty or missing
590
+ * `rows` is a no-op.
591
+ * @param rows - Chunk of rows appended to the end of the dataset.
592
+ * @api
593
+ */
594
+ appendData(rows: T[] | null | undefined): void;
571
595
  setViewport(viewport: Partial<ViewportState>): void;
572
596
  refresh(): void;
573
597
  subscribe(listener: () => void): () => void;
@@ -583,6 +607,12 @@ export interface GridApi<T> {
583
607
  readonly slots: SlotManager<T>;
584
608
  readonly icons: IconRegistry<T>;
585
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;
586
616
  /**
587
617
  * Shows an overlay using the supplied options.
588
618
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/core",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Framework-agnostic core engine for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",