@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.
- package/dist/+types.d.ts +24 -4
- package/dist/cell-selection/cell-selection-driver.js +3 -2
- package/dist/cell-selection/cell-style-row.d.ts +2 -2
- package/dist/cell-selection/cell-style-row.js +1 -1
- package/dist/cell-selection/get-root-cell.js +3 -83
- package/dist/cell-selection/index.d.ts +0 -1
- package/dist/cell-selection/index.js +0 -1
- package/dist/cell-selection/split-cell-selection-rect.d.ts +8 -1
- package/dist/cell-selection/split-cell-selection-rect.js +13 -4
- package/dist/cell-selection/split-on-pivot.d.ts +3 -0
- package/dist/cell-selection/split-on-pivot.js +50 -0
- package/dist/cells/cell-editor.js +1 -1
- package/dist/cells/cell-spacer.d.ts +3 -0
- package/dist/cells/cell-spacer.js +37 -0
- package/dist/cells/cell.d.ts +1 -3
- package/dist/cells/cell.js +11 -9
- package/dist/column-manager/branch.js +1 -1
- package/dist/column-manager/leaf.js +1 -1
- package/dist/column-manager/move-handle.d.ts +0 -7
- package/dist/column-manager/move-handle.js +23 -6
- package/dist/filter-tree/leaf.js +3 -1
- package/dist/grid-box/+types.d.ts +2 -2
- package/dist/grid-box/item.js +3 -3
- package/dist/grid-box/use-aggregation-box-items.js +1 -2
- package/dist/grid-box/use-column-box-items.d.ts +2 -3
- package/dist/grid-box/use-column-box-items.js +3 -3
- package/dist/grid-box/use-row-group-box-items.d.ts +3 -3
- package/dist/grid-box/use-row-group-box-items.js +41 -5
- package/dist/grid.d.ts +1 -1
- package/dist/header/resize-handler.js +21 -15
- package/dist/license.js +1 -1
- package/dist/row-data-source-client/use-client-data-source-paginated.js +154 -164
- package/dist/row-data-source-client/use-client-data-source.js +144 -177
- package/dist/row-data-source-client/use-client-tree-data-source.js +119 -152
- package/dist/row-data-source-server/use-server-data-source.js +102 -120
- package/dist/rows/row/row.d.ts +1 -1
- package/dist/rows/row/row.js +11 -4
- package/dist/rows/rows-sections.js +1 -1
- package/dist/sort-manager/+types.d.ts +2 -0
- package/dist/sort-manager/hooks/use-sort-row-item.js +6 -6
- package/dist/sort-manager/utils/sort-item-to-sort-model.js +5 -0
- package/dist/sort-manager/utils/sort-model-to-sort-items.js +2 -1
- package/dist/state/+types.d.ts +8 -10
- package/dist/state/api/cell-root.d.ts +5 -0
- package/dist/state/api/cell-root.js +64 -0
- package/dist/state/api/edit-begin.js +5 -9
- package/dist/state/api/edit-is-cell-active.d.ts +1 -1
- package/dist/state/api/edit-is-cell-active.js +2 -7
- package/dist/state/api/focus-cell.js +2 -2
- package/dist/state/helpers/column-layout.d.ts +3 -3
- package/dist/state/helpers/column-layout.js +9 -15
- package/dist/state/helpers/get-full-width-callback.d.ts +1 -1
- package/dist/state/helpers/get-full-width-callback.js +2 -0
- package/dist/state/helpers/get-span-callback.d.ts +1 -1
- package/dist/state/helpers/get-span-callback.js +2 -0
- package/dist/state/helpers/row-layout/row-layout.d.ts +5 -4
- package/dist/state/helpers/row-layout/row-layout.js +112 -346
- package/dist/state/use-lytenyte.js +398 -334
- package/dist/viewport/viewport.js +3 -2
- package/main.css +27 -3
- 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,
|
|
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
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const res = typeof n === "function" ? n(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
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 =
|
|
26
|
+
const centerNodes = computed(() => {
|
|
27
27
|
const nodes = [];
|
|
28
|
-
const d =
|
|
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 =
|
|
44
|
-
return
|
|
43
|
+
const topNodes = computed(() => {
|
|
44
|
+
return topData().map((c, i) => ({ data: c, id: `top-${i}`, kind: "leaf" }));
|
|
45
45
|
});
|
|
46
|
-
const botNodes =
|
|
47
|
-
return
|
|
46
|
+
const botNodes = computed(() => {
|
|
47
|
+
return bottomData().map((c, i) => ({ data: c, id: `bottom-${i}`, kind: "leaf" }));
|
|
48
48
|
});
|
|
49
|
-
const pinnedIdMap =
|
|
50
|
-
const combined = new Map([...
|
|
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 =
|
|
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 =
|
|
63
|
-
const filterModel =
|
|
64
|
-
const filterInModel =
|
|
65
|
-
const rowGroupModel =
|
|
66
|
-
const groupExpansions =
|
|
67
|
-
const aggModel =
|
|
68
|
-
const quickSearch =
|
|
69
|
-
const grid$ =
|
|
70
|
-
const snapshot =
|
|
71
|
-
const tree =
|
|
72
|
-
|
|
73
|
-
const grid =
|
|
74
|
-
const rows =
|
|
75
|
-
const filtered = computeFilteredRows(rows, grid,
|
|
76
|
-
const rowGroups =
|
|
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,
|
|
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(
|
|
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 =
|
|
111
|
-
const model =
|
|
112
|
-
const 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 =
|
|
155
|
+
const idToNode = computed(() => {
|
|
156
156
|
const map = new Map();
|
|
157
|
-
traverse(
|
|
157
|
+
traverse(tree().root, (node) => {
|
|
158
158
|
map.set(node.id, node);
|
|
159
159
|
});
|
|
160
160
|
return map;
|
|
161
161
|
});
|
|
162
|
-
const initialized =
|
|
163
|
-
const flat =
|
|
164
|
-
if (!
|
|
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 =
|
|
170
|
-
const expansions =
|
|
171
|
-
const defaultExpansion =
|
|
172
|
-
let index =
|
|
173
|
-
traverse(
|
|
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 =
|
|
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
|
-
|
|
205
|
+
grid$.set(grid);
|
|
206
206
|
const store = grid.state.rowDataStore;
|
|
207
207
|
// Monitor row count changes
|
|
208
|
-
const rowCount =
|
|
209
|
-
const perPage =
|
|
210
|
-
const currentPage =
|
|
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 =
|
|
215
|
-
const perPage =
|
|
216
|
-
const currentPage =
|
|
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 =
|
|
221
|
-
|
|
222
|
-
|
|
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(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
cleanup.push(effect(() => {
|
|
232
|
+
flatLength();
|
|
233
|
+
page();
|
|
234
|
+
rowsPerPage();
|
|
235
|
+
updateCounts();
|
|
236
236
|
}));
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
241
|
+
const top = topData().length;
|
|
242
|
+
store.rowTopCount.set(top);
|
|
243
|
+
const bottom = bottomData().length;
|
|
245
244
|
store.rowBottomCount.set(bottom);
|
|
246
|
-
cleanup.push(
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
grid.state.
|
|
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 =
|
|
290
|
+
const pinned = peek(pinnedIdMap);
|
|
301
291
|
if (pinned.has(id))
|
|
302
292
|
return pinned.get(id);
|
|
303
|
-
const t =
|
|
293
|
+
const t = peek(flat);
|
|
304
294
|
return t.idMap.get(id) ?? null;
|
|
305
295
|
};
|
|
306
296
|
const rowByIndex = (index) => {
|
|
307
|
-
const top =
|
|
308
|
-
const bot =
|
|
309
|
-
const center =
|
|
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 +
|
|
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 =
|
|
325
|
-
const d =
|
|
326
|
-
const idMap =
|
|
327
|
-
const 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
|
-
|
|
349
|
-
|
|
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 =
|
|
354
|
-
const top =
|
|
355
|
-
const bot =
|
|
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 =
|
|
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:
|
|
386
|
-
pageCount:
|
|
387
|
-
perPage:
|
|
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 =
|
|
385
|
+
const grid = grid$();
|
|
396
386
|
if (!grid)
|
|
397
387
|
return [];
|
|
398
|
-
const data =
|
|
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 =
|
|
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 =
|
|
410
|
+
const f = tree();
|
|
421
411
|
return f.idsAll.isSubsetOf(selected);
|
|
422
412
|
},
|
|
423
413
|
rowAdd: (newRows, place = "end") => {
|
|
424
|
-
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
445
|
+
const grid = peek(grid$);
|
|
456
446
|
grid?.state.rowDataStore.rowClearCache();
|
|
457
447
|
},
|
|
458
448
|
rowSetBotData: (data) => {
|
|
459
|
-
|
|
460
|
-
const grid =
|
|
449
|
+
bottomData.set(data);
|
|
450
|
+
const grid = peek(grid$);
|
|
461
451
|
grid?.state.rowDataStore.rowClearCache();
|
|
462
452
|
},
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const grid =
|
|
453
|
+
rowSetTopData: (data) => {
|
|
454
|
+
topData.set(data);
|
|
455
|
+
const grid = peek(grid$);
|
|
466
456
|
grid?.state.rowDataStore.rowClearCache();
|
|
467
457
|
},
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const 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(...
|
|
466
|
+
d.push(...peek(topData));
|
|
477
467
|
}
|
|
478
468
|
if (section === "center" || section === "flat") {
|
|
479
|
-
d.push(...
|
|
469
|
+
d.push(...peek(data));
|
|
480
470
|
}
|
|
481
471
|
if (section === "bottom" || section === "flat") {
|
|
482
|
-
d.push(...
|
|
472
|
+
d.push(...peek(bottomData));
|
|
483
473
|
}
|
|
484
474
|
return d;
|
|
485
475
|
},
|
|
486
476
|
rowExpand: (expansions) => {
|
|
487
|
-
const 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 =
|
|
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 =
|
|
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 =
|
|
542
|
+
const t = peek(tree);
|
|
553
543
|
grid.state.rowSelectedIds.set(new Set(t.idsAll));
|
|
554
544
|
},
|
|
555
545
|
},
|
|
556
546
|
{
|
|
557
|
-
top:
|
|
558
|
-
center:
|
|
559
|
-
bottom:
|
|
547
|
+
top: makeAtom(topData),
|
|
548
|
+
center: makeAtom(data),
|
|
549
|
+
bottom: makeAtom(bottomData),
|
|
560
550
|
},
|
|
561
551
|
];
|
|
562
552
|
}
|