@1771technologies/lytenyte-pro 1.0.2 → 1.0.4

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.
Files changed (61) hide show
  1. package/dist/+types.d.ts +24 -4
  2. package/dist/cell-selection/cell-selection-driver.js +3 -2
  3. package/dist/cell-selection/cell-style-row.d.ts +2 -2
  4. package/dist/cell-selection/cell-style-row.js +1 -1
  5. package/dist/cell-selection/get-root-cell.js +3 -83
  6. package/dist/cell-selection/index.d.ts +0 -1
  7. package/dist/cell-selection/index.js +0 -1
  8. package/dist/cell-selection/split-cell-selection-rect.d.ts +8 -1
  9. package/dist/cell-selection/split-cell-selection-rect.js +13 -4
  10. package/dist/cell-selection/split-on-pivot.d.ts +3 -0
  11. package/dist/cell-selection/split-on-pivot.js +50 -0
  12. package/dist/cells/cell-editor.js +1 -1
  13. package/dist/cells/cell-spacer.d.ts +3 -0
  14. package/dist/cells/cell-spacer.js +37 -0
  15. package/dist/cells/cell.d.ts +1 -3
  16. package/dist/cells/cell.js +11 -9
  17. package/dist/column-manager/branch.js +1 -1
  18. package/dist/column-manager/leaf.js +1 -1
  19. package/dist/column-manager/move-handle.d.ts +0 -7
  20. package/dist/column-manager/move-handle.js +23 -6
  21. package/dist/filter-tree/leaf.js +3 -1
  22. package/dist/grid-box/+types.d.ts +2 -2
  23. package/dist/grid-box/item.js +3 -3
  24. package/dist/grid-box/use-aggregation-box-items.js +1 -2
  25. package/dist/grid-box/use-column-box-items.d.ts +2 -3
  26. package/dist/grid-box/use-column-box-items.js +3 -3
  27. package/dist/grid-box/use-row-group-box-items.d.ts +3 -3
  28. package/dist/grid-box/use-row-group-box-items.js +41 -5
  29. package/dist/grid.d.ts +1 -1
  30. package/dist/header/resize-handler.js +21 -15
  31. package/dist/license.js +1 -1
  32. package/dist/row-data-source-client/use-client-data-source-paginated.js +154 -164
  33. package/dist/row-data-source-client/use-client-data-source.js +144 -177
  34. package/dist/row-data-source-client/use-client-tree-data-source.js +119 -152
  35. package/dist/row-data-source-server/use-server-data-source.js +102 -120
  36. package/dist/rows/row/row.d.ts +1 -1
  37. package/dist/rows/row/row.js +11 -4
  38. package/dist/rows/rows-sections.js +1 -1
  39. package/dist/sort-manager/+types.d.ts +2 -0
  40. package/dist/sort-manager/hooks/use-sort-row-item.js +6 -6
  41. package/dist/sort-manager/utils/sort-item-to-sort-model.js +5 -0
  42. package/dist/sort-manager/utils/sort-model-to-sort-items.js +2 -1
  43. package/dist/state/+types.d.ts +8 -10
  44. package/dist/state/api/cell-root.d.ts +5 -0
  45. package/dist/state/api/cell-root.js +64 -0
  46. package/dist/state/api/edit-begin.js +5 -9
  47. package/dist/state/api/edit-is-cell-active.d.ts +1 -1
  48. package/dist/state/api/edit-is-cell-active.js +2 -7
  49. package/dist/state/api/focus-cell.js +2 -2
  50. package/dist/state/helpers/column-layout.d.ts +3 -3
  51. package/dist/state/helpers/column-layout.js +9 -15
  52. package/dist/state/helpers/get-full-width-callback.d.ts +1 -1
  53. package/dist/state/helpers/get-full-width-callback.js +2 -0
  54. package/dist/state/helpers/get-span-callback.d.ts +1 -1
  55. package/dist/state/helpers/get-span-callback.js +2 -0
  56. package/dist/state/helpers/row-layout/row-layout.d.ts +5 -4
  57. package/dist/state/helpers/row-layout/row-layout.js +112 -346
  58. package/dist/state/use-lytenyte.js +398 -334
  59. package/dist/viewport/viewport.js +3 -2
  60. package/main.css +27 -3
  61. package/package.json +7 -7
@@ -1,31 +1,31 @@
1
1
  import {} from "../+types.js";
2
2
  import { useRef } from "react";
3
- import { atom, createStore } from "@1771technologies/atom";
4
3
  import { traverse } from "./tree/traverse.js";
5
- import { dateComparator, makeGridAtom, numberComparator, stringComparator, } from "@1771technologies/lytenyte-shared";
4
+ import { computed, dateComparator, effect, makeAtom, numberComparator, peek, signal, stringComparator, } from "@1771technologies/lytenyte-shared";
6
5
  import { clamp, equal, get } from "@1771technologies/lytenyte-js-utils";
7
6
  import { makeClientTree } from "./tree/client-tree.js";
8
7
  import { computeFilteredRows } from "./filter/compute-filtered-rows.js";
9
8
  import { builtIns } from "./built-ins/built-ins.js";
10
9
  export function makeClientDataSourcePaginated(p) {
11
- const rdsStore = createStore();
12
- const pageInternal = atom(0);
13
- const rowsPerPage = atom(p.rowsPerPage ?? 50);
14
- const pageCount = atom((g) => Math.max(Math.ceil(g(flatLength) / g(rowsPerPage)), 1));
15
- const page = atom((g) => clamp(0, g(pageInternal), g(pageCount) - 1), (g, s, n) => {
16
- const res = typeof n === "function" ? n(g(pageInternal)) : n;
17
- s(pageInternal, clamp(0, res, g(pageCount) - 1));
18
- });
19
- const data = atom(p.data);
20
- const topData = atom(p.topData ?? []);
21
- const bottomData = atom(p.bottomData ?? []);
22
- const dataToSrc$ = atom((g) => {
23
- return new Map(g(data).map((c, i) => [c, i]));
10
+ const pageInternal = signal(0);
11
+ const rowsPerPage = signal(p.rowsPerPage ?? 50);
12
+ const pageCount = computed(() => Math.max(Math.ceil(flatLength() / rowsPerPage()), 1));
13
+ const page = computed(() => clamp(0, pageInternal(), pageCount() - 1));
14
+ page.set = (n) => {
15
+ const res = typeof n === "function" ? n(peek(pageInternal)) : n;
16
+ pageInternal.set(clamp(0, res, peek(pageCount) - 1));
17
+ return res;
18
+ };
19
+ const data = signal(p.data);
20
+ const topData = signal(p.topData ?? []);
21
+ const bottomData = signal(p.bottomData ?? []);
22
+ const dataToSrc$ = computed(() => {
23
+ return new Map(data().map((c, i) => [c, i]));
24
24
  });
25
25
  const cache = new Map();
26
- const centerNodes = atom((g) => {
26
+ const centerNodes = computed(() => {
27
27
  const nodes = [];
28
- const d = g(data);
28
+ const d = data();
29
29
  for (let i = 0; i < d.length; i++) {
30
30
  if (!cache.has(i)) {
31
31
  cache.set(i, {
@@ -40,17 +40,17 @@ export function makeClientDataSourcePaginated(p) {
40
40
  }
41
41
  return nodes;
42
42
  });
43
- const topNodes = atom((g) => {
44
- return g(topData).map((c, i) => ({ data: c, id: `top-${i}`, kind: "leaf" }));
43
+ const topNodes = computed(() => {
44
+ return topData().map((c, i) => ({ data: c, id: `top-${i}`, kind: "leaf" }));
45
45
  });
46
- const botNodes = atom((g) => {
47
- return g(bottomData).map((c, i) => ({ data: c, id: `bottom-${i}`, kind: "leaf" }));
46
+ const botNodes = computed(() => {
47
+ return bottomData().map((c, i) => ({ data: c, id: `bottom-${i}`, kind: "leaf" }));
48
48
  });
49
- const pinnedIdMap = atom((g) => {
50
- const combined = new Map([...g(topNodes), ...g(botNodes)].map((c) => [c.id, c]));
49
+ const pinnedIdMap = computed(() => {
50
+ const combined = new Map([...topNodes(), ...botNodes()].map((c) => [c.id, c]));
51
51
  return combined;
52
52
  });
53
- const models = atom({
53
+ const models = signal({
54
54
  sort: [],
55
55
  filter: {},
56
56
  filterIn: {},
@@ -59,24 +59,24 @@ export function makeClientDataSourcePaginated(p) {
59
59
  group: [],
60
60
  groupExpansions: {},
61
61
  });
62
- const sortModel = atom((g) => g(models).sort);
63
- const filterModel = atom((g) => g(models).filter);
64
- const filterInModel = atom((g) => g(models).filterIn);
65
- const rowGroupModel = atom((g) => g(models).group);
66
- const groupExpansions = atom((g) => g(models).groupExpansions);
67
- const aggModel = atom((g) => g(models).agg);
68
- const quickSearch = atom((g) => g(models).quickSearch);
69
- const grid$ = atom(null);
70
- const snapshot = atom(0);
71
- const tree = atom((g) => {
72
- g(snapshot);
73
- const grid = g(grid$);
74
- const rows = g(centerNodes);
75
- const filtered = computeFilteredRows(rows, grid, g(filterModel), g(filterInModel), g(quickSearch), grid?.state.quickSearchSensitivity.get() ?? "case-sensitive", false);
76
- const rowGroups = g(rowGroupModel)
62
+ const sortModel = computed(() => models().sort);
63
+ const filterModel = computed(() => models().filter);
64
+ const filterInModel = computed(() => models().filterIn);
65
+ const rowGroupModel = computed(() => models().group);
66
+ const groupExpansions = computed(() => models().groupExpansions);
67
+ const aggModel = computed(() => models().agg);
68
+ const quickSearch = computed(() => models().quickSearch);
69
+ const grid$ = signal(null);
70
+ const snapshot = signal(0);
71
+ const tree = computed(() => {
72
+ snapshot();
73
+ const grid = grid$();
74
+ const rows = centerNodes();
75
+ const filtered = computeFilteredRows(rows, grid, filterModel(), filterInModel(), quickSearch(), grid?.state.quickSearchSensitivity.get() ?? "case-sensitive", false);
76
+ const rowGroups = rowGroupModel()
77
77
  .map((c) => {
78
78
  if (typeof c === "string")
79
- return (r) => grid.api.columnField(c, { kind: "leaf", data: r.data });
79
+ return (r) => grid.api.columnField(c, r);
80
80
  if (typeof c.field === "string" || typeof c.field === "number")
81
81
  return (r) => r.data[c.field];
82
82
  if (typeof c.field === "function")
@@ -84,7 +84,7 @@ export function makeClientDataSourcePaginated(p) {
84
84
  return (r) => get(r.data, c.field.path);
85
85
  })
86
86
  .map((c) => ({ fn: c }));
87
- const rowAggModel = Object.entries(g(aggModel)).map(([name, agg]) => {
87
+ const rowAggModel = Object.entries(aggModel()).map(([name, agg]) => {
88
88
  if (typeof agg.fn === "function") {
89
89
  const fn = agg.fn;
90
90
  return {
@@ -107,11 +107,11 @@ export function makeClientDataSourcePaginated(p) {
107
107
  rowIdLeaf: p.rowIdLeaf,
108
108
  });
109
109
  });
110
- const sortComparator = atom((g) => {
111
- const model = g(sortModel);
112
- const grid = g(grid$);
110
+ const sortComparator = computed(() => {
111
+ const model = sortModel();
112
+ const grid = grid$();
113
113
  if (!model.length || !grid)
114
- return () => 0;
114
+ return { fn: () => 0 };
115
115
  const comparator = (l, r) => {
116
116
  let res = 0;
117
117
  for (const sortSpec of model) {
@@ -150,27 +150,27 @@ export function makeClientDataSourcePaginated(p) {
150
150
  }
151
151
  return res;
152
152
  };
153
- return comparator;
153
+ return { fn: comparator };
154
154
  });
155
- const idToNode = atom((g) => {
155
+ const idToNode = computed(() => {
156
156
  const map = new Map();
157
- traverse(g(tree).root, (node) => {
157
+ traverse(tree().root, (node) => {
158
158
  map.set(node.id, node);
159
159
  });
160
160
  return map;
161
161
  });
162
- const initialized = atom(false);
163
- const flat = atom((g) => {
164
- if (!g(initialized))
162
+ const initialized = signal(false);
163
+ const flat = computed(() => {
164
+ if (!initialized())
165
165
  return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
166
166
  const idMap = new Map();
167
167
  const idToIndexMap = new Map();
168
168
  const flattened = [];
169
- const comparator = g(sortComparator);
170
- const expansions = g(groupExpansions);
171
- const defaultExpansion = g(grid$)?.state.rowGroupDefaultExpansion.get() ?? false;
172
- let index = g(topNodes).length;
173
- traverse(g(tree).root, (node) => {
169
+ const comparator = sortComparator();
170
+ const expansions = groupExpansions();
171
+ const defaultExpansion = grid$()?.state.rowGroupDefaultExpansion.get() ?? false;
172
+ let index = topNodes().length;
173
+ traverse(tree().root, (node) => {
174
174
  if (node.kind === 1) {
175
175
  node.data.id = node.id;
176
176
  flattened.push(node.data);
@@ -194,32 +194,32 @@ export function makeClientDataSourcePaginated(p) {
194
194
  : defaultExpansion);
195
195
  return expanded;
196
196
  }
197
- }, comparator);
197
+ }, comparator.fn);
198
198
  return { flat: flattened, idMap, idToIndexMap };
199
199
  });
200
- const flatLength = atom((g) => g(flat).flat.length);
200
+ const flatLength = computed(() => flat().flat.length);
201
201
  const cleanup = [];
202
202
  const init = (grid) => {
203
203
  while (cleanup.length)
204
204
  cleanup.pop()?.();
205
- rdsStore.set(grid$, grid);
205
+ grid$.set(grid);
206
206
  const store = grid.state.rowDataStore;
207
207
  // Monitor row count changes
208
- const rowCount = rdsStore.get(flatLength);
209
- const perPage = rdsStore.get(rowsPerPage);
210
- const currentPage = rdsStore.get(pageInternal);
208
+ const rowCount = flatLength();
209
+ const perPage = rowsPerPage();
210
+ const currentPage = pageInternal();
211
211
  const center = clamp(0, rowCount - currentPage * perPage, perPage);
212
212
  store.rowCenterCount.set(center);
213
213
  const updateCounts = () => {
214
- const rowCount = rdsStore.get(flatLength);
215
- const perPage = rdsStore.get(rowsPerPage);
216
- const currentPage = rdsStore.get(pageInternal);
214
+ const rowCount = flatLength();
215
+ const perPage = rowsPerPage();
216
+ const currentPage = pageInternal();
217
217
  const center = clamp(0, rowCount - currentPage * perPage, perPage);
218
218
  // Move to the last page if we are past the boundary
219
219
  if (center === 0 && currentPage !== 0) {
220
- const currentPage = rdsStore.get(pageCount) - 1;
221
- rdsStore.set(page, currentPage);
222
- rdsStore.set(snapshot, (prev) => prev + 1);
220
+ const currentPage = pageCount() - 1;
221
+ page.set(currentPage);
222
+ snapshot.set((prev) => prev + 1);
223
223
  const center = clamp(0, rowCount - currentPage * perPage, perPage);
224
224
  store.rowCenterCount.set(center);
225
225
  grid.state.rowDataStore.rowClearCache();
@@ -228,25 +228,24 @@ export function makeClientDataSourcePaginated(p) {
228
228
  store.rowCenterCount.set(center);
229
229
  grid.state.rowDataStore.rowClearCache();
230
230
  };
231
- cleanup.push(rdsStore.sub(flatLength, updateCounts));
232
- cleanup.push(rdsStore.sub(page, updateCounts));
233
- cleanup.push(rdsStore.sub(rowsPerPage, updateCounts));
234
- cleanup.push(rdsStore.sub(pageInternal, () => {
235
- grid.state.rowDataStore.rowClearCache();
231
+ cleanup.push(effect(() => {
232
+ flatLength();
233
+ page();
234
+ rowsPerPage();
235
+ updateCounts();
236
236
  }));
237
- const top = rdsStore.get(topData).length;
238
- store.rowTopCount.set(top);
239
- cleanup.push(rdsStore.sub(topData, () => {
237
+ cleanup.push(effect(() => {
238
+ pageInternal();
240
239
  grid.state.rowDataStore.rowClearCache();
241
- const top = rdsStore.get(topData).length;
242
- store.rowTopCount.set(top);
243
240
  }));
244
- const bottom = rdsStore.get(bottomData).length;
241
+ const top = topData().length;
242
+ store.rowTopCount.set(top);
243
+ const bottom = bottomData().length;
245
244
  store.rowBottomCount.set(bottom);
246
- cleanup.push(rdsStore.sub(bottomData, () => {
245
+ cleanup.push(effect(() => {
246
+ store.rowTopCount.set(topData().length);
247
+ store.rowBottomCount.set(bottomData().length);
247
248
  grid.state.rowDataStore.rowClearCache();
248
- const bot = rdsStore.get(bottomData).length;
249
- store.rowBottomCount.set(bot);
250
249
  }));
251
250
  const sort = grid.state.sortModel.get();
252
251
  const filter = grid.state.filterModel.get();
@@ -255,65 +254,56 @@ export function makeClientDataSourcePaginated(p) {
255
254
  const groupExpansions = grid.state.rowGroupExpansions.get();
256
255
  const agg = grid.state.aggModel.get();
257
256
  const quickSearch = grid.state.quickSearch.get();
258
- rdsStore.set(models, { agg, filter, filterIn, group, groupExpansions, sort, quickSearch });
259
- rdsStore.set(initialized, true);
260
- // Sort model monitoring
261
- cleanup.push(grid.state.sortModel.watch(() => {
262
- grid.state.rowDataStore.rowClearCache();
263
- rdsStore.set(models, (prev) => ({ ...prev, sort: grid.state.sortModel.get() }));
264
- }));
265
- // Filter model monitoring
266
- cleanup.push(grid.state.filterModel.watch(() => {
267
- rdsStore.set(models, (prev) => ({ ...prev, filter: grid.state.filterModel.get() }));
268
- grid.state.rowDataStore.rowClearCache();
269
- }));
270
- cleanup.push(grid.state.quickSearch.watch(() => {
271
- rdsStore.set(models, (prev) => ({ ...prev, quickSearch: grid.state.quickSearch.get() }));
272
- grid.state.rowDataStore.rowClearCache();
273
- }));
274
- cleanup.push(grid.state.filterInModel.watch(() => {
275
- grid.state.filterInModel.watch(() => {
276
- rdsStore.set(models, (prev) => ({ ...prev, filterIn: grid.state.filterInModel.get() }));
277
- grid.state.rowDataStore.rowClearCache();
257
+ models.set({
258
+ agg,
259
+ filter,
260
+ filterIn,
261
+ group,
262
+ quickSearch,
263
+ groupExpansions,
264
+ sort,
265
+ });
266
+ initialized.set(true);
267
+ cleanup.push(effect(() => {
268
+ models.set({
269
+ // @ts-expect-error The $ is defined, but only internally
270
+ sort: grid.state.sortModel.$(),
271
+ // @ts-expect-error The $ is defined, but only internally
272
+ agg: grid.state.aggModel.$(),
273
+ // @ts-expect-error The $ is defined, but only internally
274
+ filter: grid.state.filterModel.$(),
275
+ // @ts-expect-error The $ is defined, but only internally
276
+ group: grid.state.rowGroupModel.$(),
277
+ // @ts-expect-error The $ is defined, but only internally
278
+ groupExpansions: grid.state.rowGroupExpansions.$(),
279
+ // @ts-expect-error The $ is defined, but only internally
280
+ columnPivotGroupExpansions: grid.state.columnPivotColumnGroupExpansions.$(),
281
+ // @ts-expect-error The $ is defined, but only internally
282
+ filterIn: grid.state.filterInModel.$(),
283
+ // @ts-expect-error The $ is defined, but only internally
284
+ quickSearch: grid.state.quickSearch.$(),
278
285
  });
279
- }));
280
- // Row group model monitoring
281
- cleanup.push(grid.state.rowGroupModel.watch(() => {
282
- rdsStore.set(models, (prev) => ({ ...prev, group: grid.state.rowGroupModel.get() }));
283
- grid.state.rowDataStore.rowClearCache();
284
- }));
285
- // Row group expansions monitoring
286
- cleanup.push(grid.state.rowGroupExpansions.watch(() => {
287
- rdsStore.set(models, (prev) => ({
288
- ...prev,
289
- groupExpansions: grid.state.rowGroupExpansions.get(),
290
- }));
291
- grid.state.rowDataStore.rowClearCache();
292
- }));
293
- // Agg model monitoring
294
- cleanup.push(grid.state.aggModel.watch(() => {
295
- rdsStore.set(models, (prev) => ({ ...prev, agg: grid.state.aggModel.get() }));
296
286
  grid.state.rowDataStore.rowClearCache();
297
287
  }));
298
288
  };
299
289
  const rowById = (id) => {
300
- const pinned = rdsStore.get(pinnedIdMap);
290
+ const pinned = peek(pinnedIdMap);
301
291
  if (pinned.has(id))
302
292
  return pinned.get(id);
303
- const t = rdsStore.get(flat);
293
+ const t = peek(flat);
304
294
  return t.idMap.get(id) ?? null;
305
295
  };
306
296
  const rowByIndex = (index) => {
307
- const top = rdsStore.get(topNodes);
308
- const bot = rdsStore.get(botNodes);
309
- const center = rdsStore.get(flat).flat;
297
+ const top = peek(topNodes);
298
+ const bot = peek(botNodes);
299
+ const center = peek(flat).flat;
310
300
  const topOffset = top.length;
311
301
  const centerOffset = topOffset + center.length;
312
302
  const botOffset = centerOffset + bot.length;
313
303
  if (index < topOffset)
314
304
  return top[index];
315
305
  if (index < centerOffset) {
316
- const pageOffset = index + rdsStore.get(rowsPerPage) * rdsStore.get(pageInternal);
306
+ const pageOffset = index + peek(rowsPerPage) * peek(pageInternal);
317
307
  return center[pageOffset - topOffset];
318
308
  }
319
309
  if (index < botOffset)
@@ -321,10 +311,10 @@ export function makeClientDataSourcePaginated(p) {
321
311
  return null;
322
312
  };
323
313
  const rowUpdate = (updates) => {
324
- const grid = rdsStore.get(grid$);
325
- const d = rdsStore.get(data);
326
- const idMap = rdsStore.get(idToNode);
327
- const dataToSrc = rdsStore.get(dataToSrc$);
314
+ const grid = peek(grid$);
315
+ const d = peek(data);
316
+ const idMap = peek(idToNode);
317
+ const dataToSrc = peek(dataToSrc$);
328
318
  for (const [key, next] of updates.entries()) {
329
319
  const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
330
320
  const treeNode = typeof key === "string" ? idMap.get(key) : null;
@@ -345,14 +335,14 @@ export function makeClientDataSourcePaginated(p) {
345
335
  d[source] = next;
346
336
  }
347
337
  }
348
- rdsStore.set(data, [...d]);
349
- rdsStore.set(snapshot, (prev) => prev + 1);
338
+ data.set([...d]);
339
+ snapshot.set((prev) => prev + 1);
350
340
  grid.state.rowDataStore.rowClearCache();
351
341
  };
352
342
  const rowToIndex = (rowId) => {
353
- const f = rdsStore.get(flat);
354
- const top = rdsStore.get(topNodes);
355
- const bot = rdsStore.get(botNodes);
343
+ const f = peek(flat);
344
+ const top = peek(topNodes);
345
+ const bot = peek(botNodes);
356
346
  const topCount = top.length;
357
347
  const center = f.flat.length;
358
348
  const rowIndex = f.idToIndexMap.get(rowId);
@@ -369,7 +359,7 @@ export function makeClientDataSourcePaginated(p) {
369
359
  return null;
370
360
  };
371
361
  const rowAllChildIds = (rowId) => {
372
- const t = rdsStore.get(tree);
362
+ const t = tree();
373
363
  const ids = [];
374
364
  const node = t.idToNode.get(rowId);
375
365
  if (node?.kind === 2) {
@@ -382,9 +372,9 @@ export function makeClientDataSourcePaginated(p) {
382
372
  return [
383
373
  {
384
374
  page: {
385
- current: makeGridAtom(page, rdsStore),
386
- pageCount: makeGridAtom(pageCount, rdsStore),
387
- perPage: makeGridAtom(rowsPerPage, rdsStore),
375
+ current: makeAtom(page),
376
+ pageCount: makeAtom(pageCount),
377
+ perPage: makeAtom(rowsPerPage),
388
378
  },
389
379
  init,
390
380
  rowById,
@@ -392,10 +382,10 @@ export function makeClientDataSourcePaginated(p) {
392
382
  rowAllChildIds,
393
383
  rowUpdate,
394
384
  inFilterItems: (c) => {
395
- const grid = rdsStore.get(grid$);
385
+ const grid = grid$();
396
386
  if (!grid)
397
387
  return [];
398
- const data = rdsStore.get(centerNodes);
388
+ const data = centerNodes();
399
389
  const values = new Set(data.map((row) => {
400
390
  const field = grid.api.columnField(c, row);
401
391
  return field;
@@ -406,7 +396,7 @@ export function makeClientDataSourcePaginated(p) {
406
396
  return [...values].map((x) => ({ id: `${x}`, label: `${x}`, value: x }));
407
397
  },
408
398
  rowAreAllSelected: (rowId) => {
409
- const g = rdsStore.get(grid$);
399
+ const g = grid$();
410
400
  if (!g)
411
401
  return false;
412
402
  const selected = g.state.rowSelectedIds.get();
@@ -417,11 +407,11 @@ export function makeClientDataSourcePaginated(p) {
417
407
  const childIds = new Set(rowAllChildIds(rowId));
418
408
  return childIds.isSubsetOf(selected);
419
409
  }
420
- const f = rdsStore.get(tree);
410
+ const f = tree();
421
411
  return f.idsAll.isSubsetOf(selected);
422
412
  },
423
413
  rowAdd: (newRows, place = "end") => {
424
- rdsStore.set(data, (prev) => {
414
+ data.set((prev) => {
425
415
  if (!newRows.length)
426
416
  return prev;
427
417
  let next;
@@ -435,7 +425,7 @@ export function makeClientDataSourcePaginated(p) {
435
425
  }
436
426
  return next;
437
427
  });
438
- const grid = rdsStore.get(grid$);
428
+ const grid = peek(grid$);
439
429
  grid?.state.rowDataStore.rowClearCache();
440
430
  },
441
431
  rowDelete: (rows) => {
@@ -447,51 +437,51 @@ export function makeClientDataSourcePaginated(p) {
447
437
  return rowById(c)?.data;
448
438
  })
449
439
  .filter((c) => !!c));
450
- rdsStore.set(data, (prev) => {
440
+ data.set((prev) => {
451
441
  if (!rowData.size)
452
442
  return prev;
453
443
  return prev.filter((d) => !rowData.has(d));
454
444
  });
455
- const grid = rdsStore.get(grid$);
445
+ const grid = peek(grid$);
456
446
  grid?.state.rowDataStore.rowClearCache();
457
447
  },
458
448
  rowSetBotData: (data) => {
459
- rdsStore.set(bottomData, data);
460
- const grid = rdsStore.get(grid$);
449
+ bottomData.set(data);
450
+ const grid = peek(grid$);
461
451
  grid?.state.rowDataStore.rowClearCache();
462
452
  },
463
- rowSetCenterData: (d) => {
464
- rdsStore.set(data, d);
465
- const grid = rdsStore.get(grid$);
453
+ rowSetTopData: (data) => {
454
+ topData.set(data);
455
+ const grid = peek(grid$);
466
456
  grid?.state.rowDataStore.rowClearCache();
467
457
  },
468
- rowSetTopData: (data) => {
469
- rdsStore.set(topData, data);
470
- const grid = rdsStore.get(grid$);
458
+ rowSetCenterData: (d) => {
459
+ data.set(d);
460
+ const grid = grid$();
471
461
  grid?.state.rowDataStore.rowClearCache();
472
462
  },
473
463
  rowData: (section) => {
474
464
  const d = [];
475
465
  if (section === "top" || section === "flat") {
476
- d.push(...rdsStore.get(topData));
466
+ d.push(...peek(topData));
477
467
  }
478
468
  if (section === "center" || section === "flat") {
479
- d.push(...rdsStore.get(data));
469
+ d.push(...peek(data));
480
470
  }
481
471
  if (section === "bottom" || section === "flat") {
482
- d.push(...rdsStore.get(bottomData));
472
+ d.push(...peek(bottomData));
483
473
  }
484
474
  return d;
485
475
  },
486
476
  rowExpand: (expansions) => {
487
- const grid = rdsStore.get(grid$);
477
+ const grid = peek(grid$);
488
478
  if (!grid)
489
479
  return;
490
480
  grid.state.rowGroupExpansions.set((prev) => ({ ...prev, ...expansions }));
491
481
  },
492
482
  rowToIndex,
493
483
  rowSelect: (params) => {
494
- const grid = rdsStore.get(grid$);
484
+ const grid = peek(grid$);
495
485
  if (!grid)
496
486
  return;
497
487
  if (params.mode === "none")
@@ -542,21 +532,21 @@ export function makeClientDataSourcePaginated(p) {
542
532
  }
543
533
  },
544
534
  rowSelectAll: (params) => {
545
- const grid = rdsStore.get(grid$);
535
+ const grid = peek(grid$);
546
536
  if (!grid)
547
537
  return;
548
538
  if (params.deselect) {
549
539
  grid.state.rowSelectedIds.set(new Set());
550
540
  return;
551
541
  }
552
- const t = rdsStore.get(tree);
542
+ const t = peek(tree);
553
543
  grid.state.rowSelectedIds.set(new Set(t.idsAll));
554
544
  },
555
545
  },
556
546
  {
557
- top: makeGridAtom(topData, rdsStore),
558
- center: makeGridAtom(data, rdsStore),
559
- bottom: makeGridAtom(bottomData, rdsStore),
547
+ top: makeAtom(topData),
548
+ center: makeAtom(data),
549
+ bottom: makeAtom(bottomData),
560
550
  },
561
551
  ];
562
552
  }