@kanaries/graphic-walker 0.3.14 → 0.3.15
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/assets/viewQuery.worker-03404216.js.map +1 -1
- package/dist/components/dataTable/index.d.ts +2 -2
- package/dist/dataSource/utils.d.ts +1 -1
- package/dist/graphic-walker.es.js +10001 -9898
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +114 -109
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/interfaces.d.ts +11 -0
- package/dist/lib/inferMeta.d.ts +1 -1
- package/dist/lib/viewQuery.d.ts +2 -2
- package/dist/services.d.ts +3 -3
- package/dist/store/visualSpecStore.d.ts +428 -2
- package/dist/utils/dataPrep.d.ts +2 -2
- package/dist/utils/is-plain-object.d.ts +2 -0
- package/dist/utils/save.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/dataTable/index.tsx +154 -74
- package/src/components/dataTable/pagination.tsx +1 -1
- package/src/dataSource/utils.ts +15 -13
- package/src/interfaces.ts +16 -0
- package/src/lib/inferMeta.ts +7 -4
- package/src/lib/viewQuery.ts +2 -2
- package/src/services.ts +3 -3
- package/src/store/visualSpecStore.ts +57 -5
- package/src/utils/dataPrep.ts +21 -28
- package/src/utils/is-plain-object.ts +33 -0
- package/src/utils/save.ts +2 -2
- package/src/visualSettings/index.tsx +1 -4
package/src/utils/dataPrep.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IMutField, IRow } from "../interfaces";
|
|
2
|
+
import { isPlainObject } from "./is-plain-object";
|
|
2
3
|
|
|
3
|
-
function updateRowKeys(data: IRow[], keyEncodeList: {from: string; to: string}[]): IRow[] {
|
|
4
|
+
function updateRowKeys(data: IRow[], keyEncodeList: { from: string[]; to: string }[]): IRow[] {
|
|
4
5
|
return data.map((row) => {
|
|
5
6
|
const newRow: IRow = {};
|
|
6
7
|
for (let k in keyEncodeList) {
|
|
7
8
|
const { from, to } = keyEncodeList[k];
|
|
8
|
-
newRow[to] = row
|
|
9
|
+
newRow[to] = getValueByKeyPath(row, from);
|
|
9
10
|
}
|
|
10
11
|
return newRow;
|
|
11
12
|
});
|
|
@@ -13,9 +14,9 @@ function updateRowKeys(data: IRow[], keyEncodeList: {from: string; to: string}[]
|
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* parse column id(key) to a safe string
|
|
16
|
-
* @param metas
|
|
17
|
+
* @param metas
|
|
17
18
|
*/
|
|
18
|
-
function parseColumnMetas
|
|
19
|
+
function parseColumnMetas(metas: IMutField[]) {
|
|
19
20
|
return metas.map((meta, i) => {
|
|
20
21
|
const safeKey = `gwc_${i}`;
|
|
21
22
|
return {
|
|
@@ -26,42 +27,34 @@ function parseColumnMetas (metas: IMutField[]) {
|
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export function guardDataKeys
|
|
30
|
+
export function guardDataKeys(
|
|
31
|
+
data: IRow[],
|
|
32
|
+
metas: IMutField[]
|
|
33
|
+
): {
|
|
30
34
|
safeData: IRow[];
|
|
31
35
|
safeMetas: IMutField[];
|
|
32
36
|
} {
|
|
33
|
-
const safeMetas = parseColumnMetas(metas)
|
|
37
|
+
const safeMetas = parseColumnMetas(metas);
|
|
34
38
|
const keyEncodeList = safeMetas.map((f, i) => ({
|
|
35
|
-
from: metas[i].fid,
|
|
36
|
-
to: f.fid
|
|
39
|
+
from: metas[i].path ?? [metas[i].fid],
|
|
40
|
+
to: f.fid,
|
|
37
41
|
}));
|
|
38
42
|
const safeData = updateRowKeys(data, keyEncodeList);
|
|
39
43
|
return {
|
|
40
44
|
safeData,
|
|
41
|
-
safeMetas
|
|
42
|
-
}
|
|
45
|
+
safeMetas,
|
|
46
|
+
};
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let flatColKeys: string[] = [];
|
|
49
|
-
for (let key of keys) {
|
|
50
|
-
if (typeof object[key] === 'object') {
|
|
51
|
-
const subKeys = flatNestKeys(object[key]);
|
|
52
|
-
flatColKeys = flatColKeys.concat(subKeys.map(k => `${key}${SPLITOR}${k}`));
|
|
53
|
-
} else {
|
|
54
|
-
flatColKeys.push(key)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return flatColKeys;
|
|
48
|
+
export function flatKeys(obj: Object, prefixKeys: string[] = []): string[][] {
|
|
49
|
+
return Object.keys(obj).flatMap((k) =>
|
|
50
|
+
isPlainObject(obj[k]) ? flatKeys(obj[k], prefixKeys.concat(k)) : [prefixKeys.concat(k)]
|
|
51
|
+
);
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
export function getValueByKeyPath
|
|
61
|
-
const keys = keyPath.split(SPLITOR);
|
|
54
|
+
export function getValueByKeyPath(object: any, keyPath: string[]): any {
|
|
62
55
|
let value = object;
|
|
63
|
-
for (let key of
|
|
56
|
+
for (let key of keyPath) {
|
|
64
57
|
value = value[key];
|
|
65
58
|
}
|
|
66
59
|
return value;
|
|
67
|
-
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
function isObject(o: any) {
|
|
8
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isPlainObject(o: any) {
|
|
12
|
+
var ctor, prot;
|
|
13
|
+
|
|
14
|
+
if (isObject(o) === false) return false;
|
|
15
|
+
|
|
16
|
+
// If has modified constructor
|
|
17
|
+
ctor = o.constructor;
|
|
18
|
+
if (ctor === undefined) return true;
|
|
19
|
+
|
|
20
|
+
// If has modified prototype
|
|
21
|
+
prot = ctor.prototype;
|
|
22
|
+
if (isObject(prot) === false) return false;
|
|
23
|
+
|
|
24
|
+
// If constructor does not have an Object-specific method
|
|
25
|
+
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Most likely a plain Object
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { isPlainObject };
|
package/src/utils/save.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDataSet, IDataSource, IVisSpec } from "../interfaces";
|
|
1
|
+
import { IDataSet, IDataSource, IVisSpec, IVisSpecForExport } from "../interfaces";
|
|
2
2
|
import { VisSpecWithHistory } from "../models/visSpecHistory";
|
|
3
3
|
|
|
4
4
|
export function dumpsGWPureSpec(list: VisSpecWithHistory[]): IVisSpec[] {
|
|
@@ -12,7 +12,7 @@ export function parseGWPureSpec(list: IVisSpec[]): VisSpecWithHistory[] {
|
|
|
12
12
|
export interface IStoInfo {
|
|
13
13
|
datasets: IDataSet[];
|
|
14
14
|
specList: {
|
|
15
|
-
[K in keyof
|
|
15
|
+
[K in keyof IVisSpecForExport]: K extends "config" ? Partial<IVisSpecForExport[K]> : IVisSpecForExport[K];
|
|
16
16
|
}[];
|
|
17
17
|
dataSources: IDataSource[];
|
|
18
18
|
}
|
|
@@ -491,6 +491,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({
|
|
|
491
491
|
commonStore.setShowCodeExportPanel(true);
|
|
492
492
|
},
|
|
493
493
|
},
|
|
494
|
+
...(extra.length === 0 ? [] : ['-', ...extra]),
|
|
494
495
|
'-',
|
|
495
496
|
{
|
|
496
497
|
key: 'kanaries',
|
|
@@ -513,10 +514,6 @@ const VisualSettings: React.FC<IVisualSettings> = ({
|
|
|
513
514
|
|
|
514
515
|
const items = builtInItems.filter((item) => typeof item === 'string' || !exclude.includes(item.key));
|
|
515
516
|
|
|
516
|
-
if (extra.length > 0) {
|
|
517
|
-
items.push('-', ...extra);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
517
|
return items;
|
|
521
518
|
}, [
|
|
522
519
|
vizStore,
|