@1771technologies/lytenyte-pro 1.0.2 → 1.0.3
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 +2 -1
- 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,8 +1,7 @@
|
|
|
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 { equal, get, itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
7
6
|
import { computeFilteredRows } from "./filter/compute-filtered-rows.js";
|
|
8
7
|
import { builtIns } from "./built-ins/built-ins.js";
|
|
@@ -10,17 +9,16 @@ import { createPivotColumns } from "./pivots/create-pivot-columns.js";
|
|
|
10
9
|
import { createAggModel } from "./pivots/create-agg-model.js";
|
|
11
10
|
import { makeClientTree } from "./tree/client-tree.js";
|
|
12
11
|
export function makeClientDataSource(p) {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
return new Map(g(data).map((c, i) => [c, i]));
|
|
12
|
+
const data = signal(p.data);
|
|
13
|
+
const topData = signal(p.topData ?? []);
|
|
14
|
+
const bottomData = signal(p.bottomData ?? []);
|
|
15
|
+
const dataToSrc$ = computed(() => {
|
|
16
|
+
return new Map(data().map((c, i) => [c, i]));
|
|
19
17
|
});
|
|
20
18
|
const cache = new Map();
|
|
21
|
-
const centerNodes =
|
|
19
|
+
const centerNodes = computed(() => {
|
|
22
20
|
const nodes = [];
|
|
23
|
-
const d =
|
|
21
|
+
const d = data();
|
|
24
22
|
for (let i = 0; i < d.length; i++) {
|
|
25
23
|
if (!cache.has(i)) {
|
|
26
24
|
cache.set(i, {
|
|
@@ -35,17 +33,17 @@ export function makeClientDataSource(p) {
|
|
|
35
33
|
}
|
|
36
34
|
return nodes;
|
|
37
35
|
});
|
|
38
|
-
const topNodes =
|
|
39
|
-
return
|
|
36
|
+
const topNodes = computed(() => {
|
|
37
|
+
return topData().map((c, i) => ({ data: c, id: `top-${i}`, kind: "leaf" }));
|
|
40
38
|
});
|
|
41
|
-
const botNodes =
|
|
42
|
-
return
|
|
39
|
+
const botNodes = computed(() => {
|
|
40
|
+
return bottomData().map((c, i) => ({ data: c, id: `bottom-${i}`, kind: "leaf" }));
|
|
43
41
|
});
|
|
44
|
-
const pinnedIdMap =
|
|
45
|
-
const combined = new Map([...
|
|
42
|
+
const pinnedIdMap = computed(() => {
|
|
43
|
+
const combined = new Map([...topNodes(), ...botNodes()].map((c) => [c.id, c]));
|
|
46
44
|
return combined;
|
|
47
45
|
});
|
|
48
|
-
const models =
|
|
46
|
+
const models = signal({
|
|
49
47
|
sort: [],
|
|
50
48
|
filter: {},
|
|
51
49
|
filterIn: {},
|
|
@@ -64,22 +62,22 @@ export function makeClientDataSource(p) {
|
|
|
64
62
|
values: [],
|
|
65
63
|
},
|
|
66
64
|
});
|
|
67
|
-
const sortModel =
|
|
68
|
-
const filterModel =
|
|
69
|
-
const filterInModel =
|
|
70
|
-
const rowGroupModel =
|
|
71
|
-
const groupExpansions =
|
|
72
|
-
const aggModel =
|
|
73
|
-
const quickSearch =
|
|
74
|
-
const columnPivotGroupExpansions =
|
|
75
|
-
const columnPivotMode =
|
|
76
|
-
const columnPivotModel =
|
|
77
|
-
const grid$ =
|
|
78
|
-
const snapshot =
|
|
79
|
-
const pivotTree =
|
|
80
|
-
|
|
81
|
-
const grid =
|
|
82
|
-
const model =
|
|
65
|
+
const sortModel = computed(() => models().sort);
|
|
66
|
+
const filterModel = computed(() => models().filter);
|
|
67
|
+
const filterInModel = computed(() => models().filterIn);
|
|
68
|
+
const rowGroupModel = computed(() => models().group);
|
|
69
|
+
const groupExpansions = computed(() => models().groupExpansions);
|
|
70
|
+
const aggModel = computed(() => models().agg);
|
|
71
|
+
const quickSearch = computed(() => models().quickSearch);
|
|
72
|
+
const columnPivotGroupExpansions = computed(() => models().columnPivotGroupExpansions);
|
|
73
|
+
const columnPivotMode = computed(() => models().pivotMode);
|
|
74
|
+
const columnPivotModel = computed(() => models().pivotModel);
|
|
75
|
+
const grid$ = signal(null);
|
|
76
|
+
const snapshot = signal(0);
|
|
77
|
+
const pivotTree = computed(() => {
|
|
78
|
+
snapshot();
|
|
79
|
+
const grid = grid$();
|
|
80
|
+
const model = columnPivotModel();
|
|
83
81
|
const lookup = new Map(grid.state.columns.get().map((c) => [c.id, c]));
|
|
84
82
|
const activeRows = model.rows.filter((c) => c.active ?? true);
|
|
85
83
|
const rowGroups = activeRows.length
|
|
@@ -93,7 +91,7 @@ export function makeClientDataSource(p) {
|
|
|
93
91
|
};
|
|
94
92
|
})
|
|
95
93
|
: [{ fn: () => null }];
|
|
96
|
-
const filtered = computeFilteredRows(
|
|
94
|
+
const filtered = computeFilteredRows(centerNodes(), grid, model.filters, model.filtersIn, "", "case-sensitive", true);
|
|
97
95
|
const aggModel = createAggModel(model, grid.state.columnPivotColumns.get(), grid.state.columnGroupJoinDelimiter.get());
|
|
98
96
|
const rowAggModel = Object.entries(aggModel).map(([name, agg]) => {
|
|
99
97
|
if (typeof agg.fn === "function") {
|
|
@@ -118,12 +116,12 @@ export function makeClientDataSource(p) {
|
|
|
118
116
|
rowIdLeaf: p.rowIdLeaf,
|
|
119
117
|
});
|
|
120
118
|
});
|
|
121
|
-
const normalTree =
|
|
122
|
-
|
|
123
|
-
const grid =
|
|
124
|
-
const rows =
|
|
125
|
-
const filtered = computeFilteredRows(rows, grid,
|
|
126
|
-
const rowGroups =
|
|
119
|
+
const normalTree = computed(() => {
|
|
120
|
+
snapshot();
|
|
121
|
+
const grid = grid$();
|
|
122
|
+
const rows = centerNodes();
|
|
123
|
+
const filtered = computeFilteredRows(rows, grid, filterModel(), filterInModel(), quickSearch(), grid?.state.quickSearchSensitivity.get() ?? "case-sensitive", false);
|
|
124
|
+
const rowGroups = rowGroupModel()
|
|
127
125
|
.map((c) => {
|
|
128
126
|
if (typeof c === "string")
|
|
129
127
|
return (r) => grid.api.columnField(c, r);
|
|
@@ -134,7 +132,7 @@ export function makeClientDataSource(p) {
|
|
|
134
132
|
return (r) => get(r.data, c.field.path);
|
|
135
133
|
})
|
|
136
134
|
.map((c) => ({ fn: c }));
|
|
137
|
-
const rowAggModel = Object.entries(
|
|
135
|
+
const rowAggModel = Object.entries(aggModel()).map(([name, agg]) => {
|
|
138
136
|
if (typeof agg.fn === "function") {
|
|
139
137
|
const fn = agg.fn;
|
|
140
138
|
return {
|
|
@@ -157,11 +155,11 @@ export function makeClientDataSource(p) {
|
|
|
157
155
|
rowIdLeaf: p.rowIdLeaf,
|
|
158
156
|
});
|
|
159
157
|
});
|
|
160
|
-
const sortComparator =
|
|
161
|
-
const model =
|
|
162
|
-
const grid =
|
|
158
|
+
const sortComparator = computed(() => {
|
|
159
|
+
const model = sortModel();
|
|
160
|
+
const grid = grid$();
|
|
163
161
|
if (!model.length || !grid)
|
|
164
|
-
return () => 0;
|
|
162
|
+
return { fn: () => 0 };
|
|
165
163
|
const comparator = (l, r) => {
|
|
166
164
|
let res = 0;
|
|
167
165
|
for (const sortSpec of model) {
|
|
@@ -200,28 +198,28 @@ export function makeClientDataSource(p) {
|
|
|
200
198
|
}
|
|
201
199
|
return res;
|
|
202
200
|
};
|
|
203
|
-
return comparator;
|
|
201
|
+
return { fn: comparator };
|
|
204
202
|
});
|
|
205
|
-
const idToNode =
|
|
203
|
+
const idToNode = computed(() => {
|
|
206
204
|
const map = new Map();
|
|
207
|
-
traverse(
|
|
205
|
+
traverse(tree().root, (node) => {
|
|
208
206
|
map.set(node.id, node);
|
|
209
207
|
});
|
|
210
208
|
return map;
|
|
211
209
|
});
|
|
212
|
-
const tree =
|
|
213
|
-
const initialized =
|
|
214
|
-
const flatPivot =
|
|
215
|
-
if (!
|
|
210
|
+
const tree = computed(() => (columnPivotMode() ? pivotTree() : normalTree()));
|
|
211
|
+
const initialized = signal(false);
|
|
212
|
+
const flatPivot = computed(() => {
|
|
213
|
+
if (!initialized())
|
|
216
214
|
return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
|
|
217
215
|
const idMap = new Map();
|
|
218
216
|
const idToIndexMap = new Map();
|
|
219
217
|
const flattened = [];
|
|
220
|
-
const comparator =
|
|
221
|
-
const expansions =
|
|
222
|
-
const defaultExpansion =
|
|
218
|
+
const comparator = sortComparator();
|
|
219
|
+
const expansions = columnPivotGroupExpansions();
|
|
220
|
+
const defaultExpansion = grid$()?.state.rowGroupDefaultExpansion.get() ?? false;
|
|
223
221
|
let index = 0;
|
|
224
|
-
traverse(
|
|
222
|
+
traverse(tree().root, (node) => {
|
|
225
223
|
if (node.kind === 1) {
|
|
226
224
|
return;
|
|
227
225
|
}
|
|
@@ -244,20 +242,20 @@ export function makeClientDataSource(p) {
|
|
|
244
242
|
: defaultExpansion);
|
|
245
243
|
return expanded;
|
|
246
244
|
}
|
|
247
|
-
}, comparator);
|
|
245
|
+
}, comparator.fn);
|
|
248
246
|
return { flat: flattened, idMap, idToIndexMap };
|
|
249
247
|
});
|
|
250
|
-
const flatNormal =
|
|
251
|
-
if (!
|
|
248
|
+
const flatNormal = computed(() => {
|
|
249
|
+
if (!initialized())
|
|
252
250
|
return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
|
|
253
251
|
const idMap = new Map();
|
|
254
252
|
const idToIndexMap = new Map();
|
|
255
253
|
const flattened = [];
|
|
256
|
-
const comparator =
|
|
257
|
-
const expansions =
|
|
258
|
-
const defaultExpansion =
|
|
259
|
-
let index =
|
|
260
|
-
traverse(
|
|
254
|
+
const comparator = sortComparator();
|
|
255
|
+
const expansions = groupExpansions();
|
|
256
|
+
const defaultExpansion = grid$()?.state.rowGroupDefaultExpansion.get() ?? false;
|
|
257
|
+
let index = topNodes().length;
|
|
258
|
+
traverse(tree().root, (node) => {
|
|
261
259
|
if (node.kind === 1) {
|
|
262
260
|
node.data.id = node.id;
|
|
263
261
|
flattened.push(node.data);
|
|
@@ -281,37 +279,28 @@ export function makeClientDataSource(p) {
|
|
|
281
279
|
: defaultExpansion);
|
|
282
280
|
return expanded;
|
|
283
281
|
}
|
|
284
|
-
}, comparator);
|
|
282
|
+
}, comparator.fn);
|
|
285
283
|
return { flat: flattened, idMap, idToIndexMap };
|
|
286
284
|
});
|
|
287
|
-
const flat =
|
|
288
|
-
const flatLength =
|
|
285
|
+
const flat = computed(() => (columnPivotMode() ? flatPivot() : flatNormal()));
|
|
286
|
+
const flatLength = computed(() => flat().flat.length);
|
|
289
287
|
const cleanup = [];
|
|
290
288
|
const init = (grid) => {
|
|
291
289
|
while (cleanup.length)
|
|
292
290
|
cleanup.pop()?.();
|
|
293
|
-
|
|
291
|
+
grid$.set(grid);
|
|
294
292
|
const store = grid.state.rowDataStore;
|
|
295
293
|
// Monitor row count changes
|
|
296
|
-
const centerCount =
|
|
294
|
+
const centerCount = flatLength();
|
|
295
|
+
const top = topData().length;
|
|
296
|
+
const bottom = bottomData().length;
|
|
297
297
|
store.rowCenterCount.set(centerCount);
|
|
298
|
-
cleanup.push(rdsStore.sub(flatLength, () => {
|
|
299
|
-
const centerCount = rdsStore.get(flatLength);
|
|
300
|
-
store.rowCenterCount.set(centerCount);
|
|
301
|
-
grid.state.rowDataStore.rowClearCache();
|
|
302
|
-
}));
|
|
303
|
-
const top = rdsStore.get(topData).length;
|
|
304
298
|
store.rowTopCount.set(top);
|
|
305
|
-
cleanup.push(rdsStore.sub(topData, () => {
|
|
306
|
-
const top = rdsStore.get(topData).length;
|
|
307
|
-
store.rowTopCount.set(top);
|
|
308
|
-
grid.state.rowDataStore.rowClearCache();
|
|
309
|
-
}));
|
|
310
|
-
const bottom = rdsStore.get(bottomData).length;
|
|
311
299
|
store.rowBottomCount.set(bottom);
|
|
312
|
-
cleanup.push(
|
|
313
|
-
|
|
314
|
-
store.
|
|
300
|
+
cleanup.push(effect(() => {
|
|
301
|
+
store.rowCenterCount.set(flatLength());
|
|
302
|
+
store.rowTopCount.set(topData().length);
|
|
303
|
+
store.rowBottomCount.set(bottomData().length);
|
|
315
304
|
grid.state.rowDataStore.rowClearCache();
|
|
316
305
|
}));
|
|
317
306
|
const sort = grid.state.sortModel.get();
|
|
@@ -328,19 +317,19 @@ export function makeClientDataSource(p) {
|
|
|
328
317
|
let prevPivotColumnValues = pivotModel.values;
|
|
329
318
|
const updatePivotColumns = (model, ignoreEqualCheck = false) => {
|
|
330
319
|
if (!ignoreEqualCheck &&
|
|
331
|
-
|
|
320
|
+
peek(initialized) &&
|
|
332
321
|
equal(prevPivotColumnModel, model.columns) &&
|
|
333
322
|
equal(prevPivotColumnValues, model.values))
|
|
334
323
|
return;
|
|
335
324
|
const lookup = itemsWithIdToMap(grid.state.columns.get());
|
|
336
|
-
const pivotColumns = createPivotColumns(model, lookup, grid,
|
|
325
|
+
const pivotColumns = createPivotColumns(model, lookup, grid, peek(centerNodes));
|
|
337
326
|
grid.state.columnPivotColumns.set(pivotColumns);
|
|
338
327
|
prevPivotColumnModel = model.columns;
|
|
339
328
|
prevPivotColumnValues = model.values;
|
|
340
329
|
};
|
|
341
330
|
if (pivotMode)
|
|
342
331
|
updatePivotColumns(pivotModel);
|
|
343
|
-
|
|
332
|
+
models.set({
|
|
344
333
|
agg,
|
|
345
334
|
filter,
|
|
346
335
|
filterIn,
|
|
@@ -352,81 +341,59 @@ export function makeClientDataSource(p) {
|
|
|
352
341
|
pivotModel,
|
|
353
342
|
columnPivotGroupExpansions,
|
|
354
343
|
});
|
|
355
|
-
|
|
356
|
-
|
|
344
|
+
initialized.set(true);
|
|
345
|
+
cleanup.push(effect(() => {
|
|
346
|
+
centerNodes();
|
|
357
347
|
updatePivotColumns(grid.state.columnPivotModel.get(), true);
|
|
358
|
-
});
|
|
348
|
+
}));
|
|
359
349
|
// Pivot model monitoring
|
|
360
350
|
cleanup.push(grid.state.columnPivotMode.watch(() => {
|
|
361
351
|
const model = grid.state.columnPivotModel.get();
|
|
362
352
|
updatePivotColumns(model);
|
|
363
|
-
|
|
353
|
+
models.set((prev) => ({ ...prev, pivotMode: grid.state.columnPivotMode.get() }));
|
|
364
354
|
grid.state.rowDataStore.rowClearCache();
|
|
365
355
|
}));
|
|
366
356
|
cleanup.push(grid.state.columnPivotModel.watch(() => {
|
|
367
357
|
const model = grid.state.columnPivotModel.get();
|
|
368
358
|
updatePivotColumns(model);
|
|
369
|
-
|
|
370
|
-
...prev,
|
|
371
|
-
pivotModel: model,
|
|
372
|
-
}));
|
|
359
|
+
models.set((prev) => ({ ...prev, pivotModel: model }));
|
|
373
360
|
grid.state.rowDataStore.rowClearCache();
|
|
374
361
|
}));
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
cleanup.push(grid.state.filterInModel.watch(() => {
|
|
397
|
-
rdsStore.set(models, (prev) => ({ ...prev, filterIn: grid.state.filterInModel.get() }));
|
|
398
|
-
grid.state.rowDataStore.rowClearCache();
|
|
399
|
-
}));
|
|
400
|
-
// Row group model monitoring
|
|
401
|
-
cleanup.push(grid.state.rowGroupModel.watch(() => {
|
|
402
|
-
rdsStore.set(models, (prev) => ({ ...prev, group: grid.state.rowGroupModel.get() }));
|
|
403
|
-
grid.state.rowDataStore.rowClearCache();
|
|
404
|
-
}));
|
|
405
|
-
// Row group expansions monitoring
|
|
406
|
-
cleanup.push(grid.state.rowGroupExpansions.watch(() => {
|
|
407
|
-
rdsStore.set(models, (prev) => ({
|
|
408
|
-
...prev,
|
|
409
|
-
groupExpansions: grid.state.rowGroupExpansions.get(),
|
|
410
|
-
}));
|
|
411
|
-
grid.state.rowDataStore.rowClearCache();
|
|
412
|
-
}));
|
|
413
|
-
// Agg model monitoring
|
|
414
|
-
cleanup.push(grid.state.aggModel.watch(() => {
|
|
415
|
-
rdsStore.set(models, (prev) => ({ ...prev, agg: grid.state.aggModel.get() }));
|
|
362
|
+
cleanup.push(effect(() => {
|
|
363
|
+
models.set({
|
|
364
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
365
|
+
sort: grid.state.sortModel.$(),
|
|
366
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
367
|
+
agg: grid.state.aggModel.$(),
|
|
368
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
369
|
+
filter: grid.state.filterModel.$(),
|
|
370
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
371
|
+
group: grid.state.rowGroupModel.$(),
|
|
372
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
373
|
+
groupExpansions: grid.state.rowGroupExpansions.$(),
|
|
374
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
375
|
+
columnPivotGroupExpansions: grid.state.columnPivotColumnGroupExpansions.$(),
|
|
376
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
377
|
+
filterIn: grid.state.filterInModel.$(),
|
|
378
|
+
// @ts-expect-error The $ is defined, but only internally
|
|
379
|
+
quickSearch: grid.state.quickSearch.$(),
|
|
380
|
+
pivotMode: peek(models).pivotMode,
|
|
381
|
+
pivotModel: peek(models).pivotModel,
|
|
382
|
+
});
|
|
416
383
|
grid.state.rowDataStore.rowClearCache();
|
|
417
384
|
}));
|
|
418
385
|
};
|
|
419
386
|
const rowById = (id) => {
|
|
420
|
-
const pinned =
|
|
387
|
+
const pinned = peek(pinnedIdMap);
|
|
421
388
|
if (pinned.has(id))
|
|
422
389
|
return pinned.get(id);
|
|
423
|
-
const t =
|
|
390
|
+
const t = peek(flat);
|
|
424
391
|
return t.idMap.get(id) ?? null;
|
|
425
392
|
};
|
|
426
393
|
const rowByIndex = (index) => {
|
|
427
|
-
const top =
|
|
428
|
-
const bot =
|
|
429
|
-
const center =
|
|
394
|
+
const top = peek(topNodes);
|
|
395
|
+
const bot = peek(botNodes);
|
|
396
|
+
const center = peek(flat).flat;
|
|
430
397
|
const topOffset = top.length;
|
|
431
398
|
const centerOffset = topOffset + center.length;
|
|
432
399
|
const botOffset = centerOffset + bot.length;
|
|
@@ -439,10 +406,10 @@ export function makeClientDataSource(p) {
|
|
|
439
406
|
return null;
|
|
440
407
|
};
|
|
441
408
|
const rowUpdate = (updates) => {
|
|
442
|
-
const grid =
|
|
443
|
-
const d =
|
|
444
|
-
const idMap =
|
|
445
|
-
const dataToSrc =
|
|
409
|
+
const grid = peek(grid$);
|
|
410
|
+
const d = peek(data);
|
|
411
|
+
const idMap = peek(idToNode);
|
|
412
|
+
const dataToSrc = peek(dataToSrc$);
|
|
446
413
|
for (const [key, next] of updates.entries()) {
|
|
447
414
|
const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
|
|
448
415
|
const treeNode = typeof key === "string" ? idMap.get(key) : null;
|
|
@@ -463,14 +430,14 @@ export function makeClientDataSource(p) {
|
|
|
463
430
|
d[source] = next;
|
|
464
431
|
}
|
|
465
432
|
}
|
|
466
|
-
|
|
467
|
-
|
|
433
|
+
data.set([...d]);
|
|
434
|
+
snapshot.set((prev) => prev + 1);
|
|
468
435
|
grid.state.rowDataStore.rowClearCache();
|
|
469
436
|
};
|
|
470
437
|
const rowToIndex = (rowId) => {
|
|
471
|
-
const f =
|
|
472
|
-
const top =
|
|
473
|
-
const bot =
|
|
438
|
+
const f = peek(flat);
|
|
439
|
+
const top = peek(topNodes);
|
|
440
|
+
const bot = peek(botNodes);
|
|
474
441
|
const topCount = top.length;
|
|
475
442
|
const center = f.flat.length;
|
|
476
443
|
const rowIndex = f.idToIndexMap.get(rowId);
|
|
@@ -487,7 +454,7 @@ export function makeClientDataSource(p) {
|
|
|
487
454
|
return null;
|
|
488
455
|
};
|
|
489
456
|
const rowAllChildIds = (rowId) => {
|
|
490
|
-
const t =
|
|
457
|
+
const t = peek(tree);
|
|
491
458
|
const ids = [];
|
|
492
459
|
const node = t.idToNode.get(rowId);
|
|
493
460
|
if (node?.kind === 2) {
|
|
@@ -505,10 +472,10 @@ export function makeClientDataSource(p) {
|
|
|
505
472
|
rowAllChildIds,
|
|
506
473
|
rowUpdate,
|
|
507
474
|
inFilterItems: (c) => {
|
|
508
|
-
const grid =
|
|
475
|
+
const grid = peek(grid$);
|
|
509
476
|
if (!grid)
|
|
510
477
|
return [];
|
|
511
|
-
const data =
|
|
478
|
+
const data = peek(centerNodes);
|
|
512
479
|
const values = new Set(data.map((row) => {
|
|
513
480
|
const field = grid.api.columnField(c, row);
|
|
514
481
|
return field;
|
|
@@ -519,7 +486,7 @@ export function makeClientDataSource(p) {
|
|
|
519
486
|
return [...values].map((x) => ({ id: `${x}`, label: `${x}`, value: x }));
|
|
520
487
|
},
|
|
521
488
|
rowAdd: (newRows, place = "end") => {
|
|
522
|
-
|
|
489
|
+
data.set((prev) => {
|
|
523
490
|
if (!newRows.length)
|
|
524
491
|
return prev;
|
|
525
492
|
let next;
|
|
@@ -533,7 +500,7 @@ export function makeClientDataSource(p) {
|
|
|
533
500
|
}
|
|
534
501
|
return next;
|
|
535
502
|
});
|
|
536
|
-
const grid =
|
|
503
|
+
const grid = peek(grid$);
|
|
537
504
|
grid?.state.rowDataStore.rowClearCache();
|
|
538
505
|
},
|
|
539
506
|
rowDelete: (rows) => {
|
|
@@ -545,44 +512,44 @@ export function makeClientDataSource(p) {
|
|
|
545
512
|
return rowById(c)?.data;
|
|
546
513
|
})
|
|
547
514
|
.filter((c) => !!c));
|
|
548
|
-
|
|
515
|
+
data.set((prev) => {
|
|
549
516
|
if (!rowData.size)
|
|
550
517
|
return prev;
|
|
551
518
|
return prev.filter((d) => !rowData.has(d));
|
|
552
519
|
});
|
|
553
|
-
const grid =
|
|
520
|
+
const grid = peek(grid$);
|
|
554
521
|
grid?.state.rowDataStore.rowClearCache();
|
|
555
522
|
},
|
|
556
523
|
rowSetBotData: (data) => {
|
|
557
|
-
|
|
558
|
-
const grid =
|
|
524
|
+
bottomData.set(data);
|
|
525
|
+
const grid = peek(grid$);
|
|
559
526
|
grid?.state.rowDataStore.rowClearCache();
|
|
560
527
|
},
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const grid =
|
|
528
|
+
rowSetTopData: (data) => {
|
|
529
|
+
topData.set(data);
|
|
530
|
+
const grid = peek(grid$);
|
|
564
531
|
grid?.state.rowDataStore.rowClearCache();
|
|
565
532
|
},
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const grid =
|
|
533
|
+
rowSetCenterData: (d) => {
|
|
534
|
+
data.set(d);
|
|
535
|
+
const grid = peek(grid$);
|
|
569
536
|
grid?.state.rowDataStore.rowClearCache();
|
|
570
537
|
},
|
|
571
538
|
rowData: (section) => {
|
|
572
539
|
const d = [];
|
|
573
540
|
if (section === "top" || section === "flat") {
|
|
574
|
-
d.push(...
|
|
541
|
+
d.push(...peek(topData));
|
|
575
542
|
}
|
|
576
543
|
if (section === "center" || section === "flat") {
|
|
577
|
-
d.push(...
|
|
544
|
+
d.push(...peek(data));
|
|
578
545
|
}
|
|
579
546
|
if (section === "bottom" || section === "flat") {
|
|
580
|
-
d.push(...
|
|
547
|
+
d.push(...peek(bottomData));
|
|
581
548
|
}
|
|
582
549
|
return d;
|
|
583
550
|
},
|
|
584
551
|
rowExpand: (expansions) => {
|
|
585
|
-
const grid =
|
|
552
|
+
const grid = peek(grid$);
|
|
586
553
|
if (!grid)
|
|
587
554
|
return;
|
|
588
555
|
const mode = grid.state.columnPivotMode.get();
|
|
@@ -593,7 +560,7 @@ export function makeClientDataSource(p) {
|
|
|
593
560
|
},
|
|
594
561
|
rowToIndex,
|
|
595
562
|
rowSelect: (params) => {
|
|
596
|
-
const grid =
|
|
563
|
+
const grid = peek(grid$);
|
|
597
564
|
if (!grid)
|
|
598
565
|
return;
|
|
599
566
|
if (params.mode === "none")
|
|
@@ -644,18 +611,18 @@ export function makeClientDataSource(p) {
|
|
|
644
611
|
}
|
|
645
612
|
},
|
|
646
613
|
rowSelectAll: (params) => {
|
|
647
|
-
const grid =
|
|
614
|
+
const grid = peek(grid$);
|
|
648
615
|
if (!grid)
|
|
649
616
|
return;
|
|
650
617
|
if (params.deselect) {
|
|
651
618
|
grid.state.rowSelectedIds.set(new Set());
|
|
652
619
|
return;
|
|
653
620
|
}
|
|
654
|
-
const t =
|
|
621
|
+
const t = peek(tree);
|
|
655
622
|
grid.state.rowSelectedIds.set(new Set(t.idsAll));
|
|
656
623
|
},
|
|
657
624
|
rowAreAllSelected: (rowId) => {
|
|
658
|
-
const g =
|
|
625
|
+
const g = peek(grid$);
|
|
659
626
|
if (!g)
|
|
660
627
|
return false;
|
|
661
628
|
const selected = g.state.rowSelectedIds.get();
|
|
@@ -666,14 +633,14 @@ export function makeClientDataSource(p) {
|
|
|
666
633
|
const childIds = new Set(rowAllChildIds(rowId));
|
|
667
634
|
return childIds.isSubsetOf(selected);
|
|
668
635
|
}
|
|
669
|
-
const f =
|
|
636
|
+
const f = peek(tree);
|
|
670
637
|
return f.idsAll.isSubsetOf(selected);
|
|
671
638
|
},
|
|
672
639
|
},
|
|
673
640
|
{
|
|
674
|
-
top:
|
|
675
|
-
center:
|
|
676
|
-
bottom:
|
|
641
|
+
top: makeAtom(topData),
|
|
642
|
+
center: makeAtom(data),
|
|
643
|
+
bottom: makeAtom(bottomData),
|
|
677
644
|
},
|
|
678
645
|
];
|
|
679
646
|
}
|