@1771technologies/lytenyte-pro 1.0.0-beta.10 → 1.0.0-beta.12

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/+types.d.ts CHANGED
@@ -1710,7 +1710,7 @@ export interface ClientRowDataSourceParams<T> {
1710
1710
  */
1711
1711
  readonly rowIdLeaf?: (d: RowLeaf<T>, i: number) => string;
1712
1712
  /**
1713
- * Callback that transforms a column in-filter item before it's applied.
1713
+ * Callback that transforms a set of values for a given column into the in filter items LyteNyte Grid should use.
1714
1714
  */
1715
1715
  readonly transformInFilterItem?: (params: {
1716
1716
  column: Column<T>;
@@ -1746,7 +1746,7 @@ export interface ClientTreeDataSourceParams<T> {
1746
1746
  */
1747
1747
  readonly rowIdLeaf?: (d: RowLeaf<T>, i: number) => string;
1748
1748
  /**
1749
- * Callback that transforms a column in-filter item before it's applied.
1749
+ * Callback that transforms a set of values for a given column into the in filter items LyteNyte Grid should use.
1750
1750
  */
1751
1751
  readonly transformInFilterItem?: (params: {
1752
1752
  column: Column<T>;
@@ -1812,6 +1812,10 @@ export interface RowDataSourceClientPaginated<T> {
1812
1812
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
1813
1813
  */
1814
1814
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
1815
+ /**
1816
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
1817
+ */
1818
+ readonly rowSetCenterData: (newRows: any[]) => void;
1815
1819
  /**
1816
1820
  * Sets the data for rows pinned to the top section.
1817
1821
  */
@@ -1907,6 +1911,10 @@ export interface RowDataSourceClient<T> {
1907
1911
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
1908
1912
  */
1909
1913
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
1914
+ /**
1915
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
1916
+ */
1917
+ readonly rowSetCenterData: (newRows: any[]) => void;
1910
1918
  /**
1911
1919
  * Sets the data for rows pinned to the top section.
1912
1920
  */
@@ -1976,6 +1984,10 @@ export interface RowDataSource<T> {
1976
1984
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
1977
1985
  */
1978
1986
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
1987
+ /**
1988
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
1989
+ */
1990
+ readonly rowSetCenterData: (newRows: any[]) => void;
1979
1991
  /**
1980
1992
  * Sets the data for rows pinned to the top section.
1981
1993
  */
@@ -2051,6 +2063,10 @@ export interface RowDataSourceServer<T> {
2051
2063
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
2052
2064
  */
2053
2065
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
2066
+ /**
2067
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
2068
+ */
2069
+ readonly rowSetCenterData: (newRows: any[]) => void;
2054
2070
  /**
2055
2071
  * Sets the data for rows pinned to the top section.
2056
2072
  */
@@ -2599,6 +2615,10 @@ export interface CellRendererParams<T> {
2599
2615
  * Indicates whether the row is in an indeterminate selection state.
2600
2616
  */
2601
2617
  readonly rowIndeterminate: boolean;
2618
+ /**
2619
+ * The pinning state of a row, used to fix it to the top or bottom of the grid.
2620
+ */
2621
+ readonly rowPin: RowPin;
2602
2622
  }
2603
2623
  /**
2604
2624
  * The parameters the `columnAutosize` method accepts.
@@ -57,6 +57,7 @@ const CellImpl = forwardRef(function Cell({ cell, children, ...props }, forwarde
57
57
  grid: grid,
58
58
  rowIndex: cell.rowIndex,
59
59
  colIndex: cell.colIndex,
60
+ rowPin: cell.rowPin,
60
61
  })
61
62
  : Renderer,
62
63
  }),
@@ -27,6 +27,9 @@ export function makeClientDataSourcePaginated(p) {
27
27
  const data = atom(p.data);
28
28
  const topData = atom(p.topData ?? []);
29
29
  const bottomData = atom(p.bottomData ?? []);
30
+ const dataToSrc$ = atom((g) => {
31
+ return new Map(g(data).map((c, i) => [c, i]));
32
+ });
30
33
  const cache = new Map();
31
34
  const centerNodes = atom((g) => {
32
35
  const nodes = [];
@@ -166,6 +169,13 @@ export function makeClientDataSourcePaginated(p) {
166
169
  };
167
170
  return comparator;
168
171
  });
172
+ const idToNode = atom((g) => {
173
+ const map = new Map();
174
+ traverse(g(tree).root, (node) => {
175
+ map.set(node.id, node);
176
+ });
177
+ return map;
178
+ });
169
179
  const initialized = atom(false);
170
180
  const flat = atom((g) => {
171
181
  if (!g(initialized)) return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
@@ -337,29 +347,31 @@ export function makeClientDataSourcePaginated(p) {
337
347
  };
338
348
  const rowUpdate = (updates) => {
339
349
  const grid = rdsStore.get(grid$);
340
- const t = rdsStore.get(tree);
341
350
  const d = rdsStore.get(data);
342
- for (const [key, data] of updates.entries()) {
343
- const rowIndex = typeof key === "number" ? key : rowToIndex(key);
344
- const row = rowByIndex(rowIndex);
345
- if (!row || !grid) {
346
- console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
351
+ const idMap = rdsStore.get(idToNode);
352
+ const dataToSrc = rdsStore.get(dataToSrc$);
353
+ for (const [key, next] of updates.entries()) {
354
+ const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
355
+ const treeNode = typeof key === "string" ? idMap.get(key) : null;
356
+ if ((!row && !treeNode) || !grid) {
357
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
347
358
  continue;
348
359
  }
349
- if (row.kind === "branch") {
350
- row.data = data;
360
+ if (row?.kind === "branch") {
361
+ row.data = next;
351
362
  } else {
352
- const source = t.idToSourceIndex.get(row.id);
363
+ const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
364
+ const source = dataToSrc.get(data);
353
365
  if (source == null) {
354
- console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
366
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
355
367
  continue;
356
368
  }
357
- d[source] = data;
369
+ d[source] = next;
358
370
  }
359
- grid.state.rowDataStore.rowInvalidateIndex(rowIndex);
360
371
  }
361
372
  rdsStore.set(data, [...d]);
362
373
  rdsStore.set(snapshot, (prev) => prev + 1);
374
+ grid.state.rowDataStore.rowClearCache();
363
375
  };
364
376
  const rowToIndex = (rowId) => {
365
377
  const f = rdsStore.get(flat);
@@ -464,6 +476,11 @@ export function makeClientDataSourcePaginated(p) {
464
476
  const grid = rdsStore.get(grid$);
465
477
  grid?.state.rowDataStore.rowClearCache();
466
478
  },
479
+ rowSetCenterData: (d) => {
480
+ rdsStore.set(data, d);
481
+ const grid = rdsStore.get(grid$);
482
+ grid?.state.rowDataStore.rowClearCache();
483
+ },
467
484
  rowSetTopData: (data) => {
468
485
  rdsStore.set(topData, data);
469
486
  const grid = rdsStore.get(grid$);
@@ -543,12 +560,12 @@ export function useClientRowDataSourcePaginated(p) {
543
560
  const da = dataAtomRef.current;
544
561
  if (p.reflectData) {
545
562
  // Need to queue the microtask since it we cannot update state during render.
546
- if (p.data !== da.center.get()) queueMicrotask(() => da.center.set(p.data));
563
+ if (p.data !== da.center.get()) queueMicrotask(() => ds.current.rowSetCenterData(p.data));
547
564
  if (!equal(p.topData ?? [], da.top.get())) {
548
- queueMicrotask(() => da.top.set(p.topData ?? []));
565
+ queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
549
566
  }
550
567
  if (!equal(p.bottomData ?? [], da.bottom.get()))
551
- queueMicrotask(() => da.bottom.set(p.bottomData ?? []));
568
+ queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
552
569
  }
553
570
  return ds.current;
554
571
  }
@@ -19,6 +19,9 @@ export function makeClientDataSource(p) {
19
19
  const data = atom(p.data);
20
20
  const topData = atom(p.topData ?? []);
21
21
  const bottomData = atom(p.bottomData ?? []);
22
+ const dataToSrc$ = atom((g) => {
23
+ return new Map(g(data).map((c, i) => [c, i]));
24
+ });
22
25
  const cache = new Map();
23
26
  const centerNodes = atom((g) => {
24
27
  const nodes = [];
@@ -230,6 +233,13 @@ export function makeClientDataSource(p) {
230
233
  };
231
234
  return comparator;
232
235
  });
236
+ const idToNode = atom((g) => {
237
+ const map = new Map();
238
+ traverse(g(tree).root, (node) => {
239
+ map.set(node.id, node);
240
+ });
241
+ return map;
242
+ });
233
243
  const tree = atom((g) => (g(columnPivotMode) ? g(pivotTree) : g(normalTree)));
234
244
  const initialized = atom(false);
235
245
  const flatPivot = atom((g) => {
@@ -486,29 +496,31 @@ export function makeClientDataSource(p) {
486
496
  };
487
497
  const rowUpdate = (updates) => {
488
498
  const grid = rdsStore.get(grid$);
489
- const t = rdsStore.get(normalTree);
490
499
  const d = rdsStore.get(data);
491
- for (const [key, data] of updates.entries()) {
492
- const rowIndex = typeof key === "number" ? key : rowToIndex(key);
493
- const row = rowByIndex(rowIndex);
494
- if (!row || !grid) {
495
- console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
500
+ const idMap = rdsStore.get(idToNode);
501
+ const dataToSrc = rdsStore.get(dataToSrc$);
502
+ for (const [key, next] of updates.entries()) {
503
+ const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
504
+ const treeNode = typeof key === "string" ? idMap.get(key) : null;
505
+ if ((!row && !treeNode) || !grid) {
506
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
496
507
  continue;
497
508
  }
498
- if (row.kind === "branch") {
499
- row.data = data;
509
+ if (row?.kind === "branch") {
510
+ row.data = next;
500
511
  } else {
501
- const source = t.idToSourceIndex.get(row.id);
512
+ const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
513
+ const source = dataToSrc.get(data);
502
514
  if (source == null) {
503
- console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
515
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
504
516
  continue;
505
517
  }
506
- d[source] = data;
518
+ d[source] = next;
507
519
  }
508
- grid.state.rowDataStore.rowInvalidateIndex(rowIndex);
509
520
  }
510
521
  rdsStore.set(data, [...d]);
511
522
  rdsStore.set(snapshot, (prev) => prev + 1);
523
+ grid.state.rowDataStore.rowClearCache();
512
524
  };
513
525
  const rowToIndex = (rowId) => {
514
526
  const f = rdsStore.get(flat);
@@ -595,6 +607,11 @@ export function makeClientDataSource(p) {
595
607
  const grid = rdsStore.get(grid$);
596
608
  grid?.state.rowDataStore.rowClearCache();
597
609
  },
610
+ rowSetCenterData: (d) => {
611
+ rdsStore.set(data, d);
612
+ const grid = rdsStore.get(grid$);
613
+ grid?.state.rowDataStore.rowClearCache();
614
+ },
598
615
  rowSetTopData: (data) => {
599
616
  rdsStore.set(topData, data);
600
617
  const grid = rdsStore.get(grid$);
@@ -690,12 +707,12 @@ export function useClientRowDataSource(p) {
690
707
  const da = dataAtomRef.current;
691
708
  if (p.reflectData) {
692
709
  // Need to queue the microtask since it we cannot update state during render.
693
- if (p.data !== da.center.get()) queueMicrotask(() => da.center.set(p.data));
710
+ if (p.data !== da.center.get()) queueMicrotask(() => ds.current.rowSetCenterData(p.data));
694
711
  if (!equal(p.topData ?? [], da.top.get())) {
695
- queueMicrotask(() => da.top.set(p.topData ?? []));
712
+ queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
696
713
  }
697
714
  if (!equal(p.bottomData ?? [], da.bottom.get()))
698
- queueMicrotask(() => da.bottom.set(p.bottomData ?? []));
715
+ queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
699
716
  }
700
717
  return ds.current;
701
718
  }
@@ -17,6 +17,9 @@ export function makeClientTreeDataSource(p) {
17
17
  const data = atom(p.data);
18
18
  const topData = atom(p.topData ?? []);
19
19
  const bottomData = atom(p.bottomData ?? []);
20
+ const dataToSrc$ = atom((g) => {
21
+ return new Map(g(data).map((c, i) => [c, i]));
22
+ });
20
23
  const cache = new Map();
21
24
  const centerNodes = atom((g) => {
22
25
  const nodes = [];
@@ -145,6 +148,13 @@ export function makeClientTreeDataSource(p) {
145
148
  };
146
149
  return comparator;
147
150
  });
151
+ const idToNode = atom((g) => {
152
+ const map = new Map();
153
+ traverse(g(tree).root, (node) => {
154
+ map.set(node.id, node);
155
+ });
156
+ return map;
157
+ });
148
158
  const initialized = atom(false);
149
159
  const flat = atom((g) => {
150
160
  if (!g(initialized)) return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
@@ -308,29 +318,31 @@ export function makeClientTreeDataSource(p) {
308
318
  };
309
319
  const rowUpdate = (updates) => {
310
320
  const grid = rdsStore.get(grid$);
311
- const t = rdsStore.get(tree);
312
321
  const d = rdsStore.get(data);
313
- for (const [key, data] of updates.entries()) {
314
- const rowIndex = typeof key === "number" ? key : rowToIndex(key);
315
- const row = rowByIndex(rowIndex);
316
- if (!row || !grid) {
317
- console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
322
+ const idMap = rdsStore.get(idToNode);
323
+ const dataToSrc = rdsStore.get(dataToSrc$);
324
+ for (const [key, next] of updates.entries()) {
325
+ const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
326
+ const treeNode = typeof key === "string" ? idMap.get(key) : null;
327
+ if ((!row && !treeNode) || !grid) {
328
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
318
329
  continue;
319
330
  }
320
- if (row.kind === "branch") {
321
- row.data = data;
331
+ if (row?.kind === "branch") {
332
+ row.data = next;
322
333
  } else {
323
- const source = t.idToSourceIndex.get(row.id);
334
+ const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
335
+ const source = dataToSrc.get(data);
324
336
  if (source == null) {
325
- console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
337
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
326
338
  continue;
327
339
  }
328
- d[source] = data;
340
+ d[source] = next;
329
341
  }
330
- grid.state.rowDataStore.rowInvalidateIndex(rowIndex);
331
342
  }
332
343
  rdsStore.set(data, [...d]);
333
344
  rdsStore.set(snapshot, (prev) => prev + 1);
345
+ grid.state.rowDataStore.rowClearCache();
334
346
  };
335
347
  const rowToIndex = (rowId) => {
336
348
  const f = rdsStore.get(flat);
@@ -417,6 +429,11 @@ export function makeClientTreeDataSource(p) {
417
429
  const grid = rdsStore.get(grid$);
418
430
  grid?.state.rowDataStore.rowClearCache();
419
431
  },
432
+ rowSetCenterData: (d) => {
433
+ rdsStore.set(data, d);
434
+ const grid = rdsStore.get(grid$);
435
+ grid?.state.rowDataStore.rowClearCache();
436
+ },
420
437
  rowSetTopData: (data) => {
421
438
  rdsStore.set(topData, data);
422
439
  const grid = rdsStore.get(grid$);
@@ -512,12 +529,12 @@ export function useClientTreeDataSource(p) {
512
529
  const da = dataAtomRef.current;
513
530
  if (p.reflectData) {
514
531
  // Need to queue the microtask since it we cannot update state during render.
515
- if (p.data !== da.center.get()) queueMicrotask(() => da.center.set(p.data));
532
+ if (p.data !== da.center.get()) queueMicrotask(() => ds.current.rowSetCenterData(p.data));
516
533
  if (!equal(p.topData ?? [], da.top.get())) {
517
- queueMicrotask(() => da.top.set(p.topData ?? []));
534
+ queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
518
535
  }
519
536
  if (!equal(p.bottomData ?? [], da.bottom.get()))
520
- queueMicrotask(() => da.bottom.set(p.bottomData ?? []));
537
+ queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
521
538
  }
522
539
  return ds.current;
523
540
  }
@@ -664,6 +664,9 @@ export function makeServerDataSource({
664
664
  rowSelect,
665
665
  rowSelectAll,
666
666
  rowSetBotData,
667
+ rowSetCenterData: () => {
668
+ throw new Error("Server side data source does not support full row updates");
669
+ },
667
670
  rowSetTopData,
668
671
  rowToIndex,
669
672
  rowUpdate,
@@ -11,6 +11,7 @@ export const emptyRowDataSource = {
11
11
  rowAdd: () => {},
12
12
  rowDelete: () => {},
13
13
  rowSetBotData: () => {},
14
+ rowSetCenterData: () => {},
14
15
  rowSetTopData: () => {},
15
16
  rowAreAllSelected: () => false,
16
17
  inFilterItems: () => [],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@1771technologies/lytenyte-pro",
3
3
  "description": "Blazingly fast headless React data grid with 100s of features.",
4
- "version": "1.0.0-beta.10",
4
+ "version": "1.0.0-beta.12",
5
5
  "type": "module",
6
6
  "license": "COMMERCIAL",
7
7
  "files": [
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@1771technologies/atom": "^1.0.2",
52
- "@1771technologies/lytenyte-dom-utils": "1.0.0-beta.10",
53
- "@1771technologies/lytenyte-dragon": "1.0.0-beta.10",
54
- "@1771technologies/lytenyte-shared": "1.0.0-beta.10",
55
- "@1771technologies/lytenyte-js-utils": "1.0.0-beta.10",
56
- "@1771technologies/lytenyte-core": "1.0.0-beta.10",
57
- "@1771technologies/lytenyte-react-hooks": "1.0.0-beta.10"
52
+ "@1771technologies/lytenyte-js-utils": "1.0.0-beta.12",
53
+ "@1771technologies/lytenyte-dragon": "1.0.0-beta.12",
54
+ "@1771technologies/lytenyte-shared": "1.0.0-beta.12",
55
+ "@1771technologies/lytenyte-dom-utils": "1.0.0-beta.12",
56
+ "@1771technologies/lytenyte-react-hooks": "1.0.0-beta.12",
57
+ "@1771technologies/lytenyte-core": "1.0.0-beta.12"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^18.0.0 || ^19.0.0",