@vuu-ui/vuu-data-local 4.0.0-alpha.20 → 4.0.0-alpha.21
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.0-alpha.
|
|
2
|
+
"version": "4.0.0-alpha.21",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"type": "module",
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-data-types": "4.0.0-alpha.
|
|
15
|
-
"@vuu-ui/vuu-table-types": "4.0.0-alpha.
|
|
16
|
-
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.
|
|
17
|
-
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.
|
|
14
|
+
"@vuu-ui/vuu-data-types": "4.0.0-alpha.21",
|
|
15
|
+
"@vuu-ui/vuu-table-types": "4.0.0-alpha.21",
|
|
16
|
+
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.21",
|
|
17
|
+
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.21"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.
|
|
21
|
-
"@vuu-ui/vuu-utils": "4.0.0-alpha.
|
|
20
|
+
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.21",
|
|
21
|
+
"@vuu-ui/vuu-utils": "4.0.0-alpha.21"
|
|
22
22
|
},
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"files": [
|
|
@@ -1,39 +1,17 @@
|
|
|
1
1
|
import { BaseDataSource, KeySet, NULL_RANGE, getParentRow, isSingleValueFilter, lastPathSegment, metadataKeys, missingAncestor, treeToDataSourceRows, uuid } from "@vuu-ui/vuu-utils";
|
|
2
2
|
import { IconProvider } from "./IconProvider.js";
|
|
3
3
|
import { parseFilter } from "@vuu-ui/vuu-filter-parser";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: "Level 2",
|
|
16
|
-
serverDataType: "string"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: "Level 3",
|
|
20
|
-
serverDataType: "string"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: "Level 4",
|
|
24
|
-
serverDataType: "string"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "Level 5",
|
|
28
|
-
serverDataType: "string"
|
|
4
|
+
const treeSchema = (columns)=>({
|
|
5
|
+
columns: columns.map(({ name })=>({
|
|
6
|
+
name,
|
|
7
|
+
serverDataType: "string"
|
|
8
|
+
})),
|
|
9
|
+
key: "",
|
|
10
|
+
table: {
|
|
11
|
+
module: "",
|
|
12
|
+
table: ""
|
|
29
13
|
}
|
|
30
|
-
|
|
31
|
-
key: "",
|
|
32
|
-
table: {
|
|
33
|
-
module: "",
|
|
34
|
-
table: ""
|
|
35
|
-
}
|
|
36
|
-
};
|
|
14
|
+
});
|
|
37
15
|
const { COUNT: COUNT, DEPTH: DEPTH, IDX: IDX, IS_EXPANDED: IS_EXPANDED, IS_LEAF: IS_LEAF, KEY: KEY, SELECTED: SELECTED } = metadataKeys;
|
|
38
16
|
const toClientRow = (row, keys)=>{
|
|
39
17
|
const [rowIndex] = row;
|
|
@@ -61,6 +39,8 @@ class TreeDataSource extends BaseDataSource {
|
|
|
61
39
|
if (!data) throw Error("TreeDataSource constructor called without data");
|
|
62
40
|
this.#iconProvider = new IconProvider();
|
|
63
41
|
[this.columnDescriptors, this.#data] = treeToDataSourceRows(data, this.#iconProvider);
|
|
42
|
+
this.expandedRows = getInitiallyExpandedKeys(data);
|
|
43
|
+
console.table(this.#data);
|
|
64
44
|
if (this.columnDescriptors) {
|
|
65
45
|
const columns = this.columnDescriptors.map((c)=>c.name);
|
|
66
46
|
this._configWithVisualLink = {
|
|
@@ -92,7 +72,7 @@ class TreeDataSource extends BaseDataSource {
|
|
|
92
72
|
groupBy: this._configWithVisualLink.groupBy,
|
|
93
73
|
range: this.range,
|
|
94
74
|
sort: this.sort,
|
|
95
|
-
tableSchema:
|
|
75
|
+
tableSchema: treeSchema(this.columnDescriptors)
|
|
96
76
|
});
|
|
97
77
|
this.clientCallback({
|
|
98
78
|
clientViewportId: this.viewport,
|
|
@@ -306,6 +286,14 @@ class TreeDataSource extends BaseDataSource {
|
|
|
306
286
|
return this.visibleRows[rowIdx];
|
|
307
287
|
}
|
|
308
288
|
}
|
|
289
|
+
const getInitiallyExpandedKeys = (treeSourceNodes, keyBase = "$root", expandedKeys = new Set())=>{
|
|
290
|
+
for (const { childNodes, expanded, label } of treeSourceNodes){
|
|
291
|
+
const key = `${keyBase}|${label}`;
|
|
292
|
+
if (expanded) expandedKeys.add(key);
|
|
293
|
+
if (childNodes) getInitiallyExpandedKeys(childNodes, key, expandedKeys);
|
|
294
|
+
}
|
|
295
|
+
return expandedKeys;
|
|
296
|
+
};
|
|
309
297
|
function getVisibleRows(rows, expandedKeys, filterset) {
|
|
310
298
|
const visibleRows = [];
|
|
311
299
|
const visibleRowIndex = {};
|