@visactor/vtable 0.24.1 → 0.24.2-alpha.1
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/cjs/PivotTable.js +52 -16
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/flatDataToObject.d.ts +8 -3
- package/cjs/dataset/flatDataToObject.js +35 -8
- package/cjs/dataset/flatDataToObject.js.map +1 -1
- package/cjs/edit/edit-manager.js +0 -1
- package/cjs/edit/edit-manager.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/pivot-header-layout.d.ts +1 -0
- package/cjs/layout/pivot-header-layout.js +16 -4
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/state/state.js +1 -1
- package/cjs/themes/component.js +1 -1
- package/cjs/ts-types/pivot-table/dimension/basic-dimension.d.ts +6 -1
- package/cjs/ts-types/pivot-table/dimension/basic-dimension.js.map +1 -1
- package/cjs/ts-types/pivot-table/indicator/basic-indicator.d.ts +3 -0
- package/cjs/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
- package/cjs/ts-types/table-engine.d.ts +3 -0
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +159 -32
- package/dist/vtable.min.js +1 -1
- package/es/PivotTable.js +52 -16
- package/es/PivotTable.js.map +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/flatDataToObject.d.ts +8 -3
- package/es/dataset/flatDataToObject.js +34 -8
- package/es/dataset/flatDataToObject.js.map +1 -1
- package/es/edit/edit-manager.js +0 -1
- package/es/edit/edit-manager.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/pivot-header-layout.d.ts +1 -0
- package/es/layout/pivot-header-layout.js +12 -2
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/state/state.js +1 -1
- package/es/themes/component.js +1 -1
- package/es/ts-types/pivot-table/dimension/basic-dimension.d.ts +6 -1
- package/es/ts-types/pivot-table/dimension/basic-dimension.js.map +1 -1
- package/es/ts-types/pivot-table/indicator/basic-indicator.d.ts +3 -0
- package/es/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
- package/es/ts-types/table-engine.d.ts +3 -0
- package/es/ts-types/table-engine.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +5 -5
|
@@ -8,7 +8,10 @@ export declare class FlatDataToObjects {
|
|
|
8
8
|
};
|
|
9
9
|
records: any[];
|
|
10
10
|
tree: Record<string, Record<string, Record<string, any>>>;
|
|
11
|
-
|
|
11
|
+
beforeChangedTree: Record<string, Record<string, {
|
|
12
|
+
record: any;
|
|
13
|
+
value: string;
|
|
14
|
+
}>>;
|
|
12
15
|
private colFlatKeys;
|
|
13
16
|
private rowFlatKeys;
|
|
14
17
|
stringJoinChar: string;
|
|
@@ -35,7 +38,9 @@ export declare class FlatDataToObjects {
|
|
|
35
38
|
setRecords(records: any[]): void;
|
|
36
39
|
processRecords(): void;
|
|
37
40
|
processRecord(record: any): void;
|
|
38
|
-
getTreeNode(rowKey: string[] | string, colKey: string[] | string, indicator: string,
|
|
39
|
-
changeTreeNodeValue(rowKey: string[]
|
|
41
|
+
getTreeNode(rowKey: string[] | string, colKey: string[] | string, indicator: string, ifChangedValue?: boolean): Record<string, any>;
|
|
42
|
+
changeTreeNodeValue(rowKey: string[], colKey: string[], indicator: string, newValue: any): void;
|
|
43
|
+
_buildRecord(rowKey: string[], colKey: string[], indicator: string, value: any): {};
|
|
40
44
|
addRecords(records: any[]): void;
|
|
45
|
+
changeRecordFieldValue(fieldName: string, value: string | number): void;
|
|
41
46
|
}
|
|
@@ -8,7 +8,7 @@ const vutils_1 = require("@visactor/vutils");
|
|
|
8
8
|
|
|
9
9
|
class FlatDataToObjects {
|
|
10
10
|
constructor(dataConfig, records) {
|
|
11
|
-
if (this.tree = {}, this.
|
|
11
|
+
if (this.tree = {}, this.beforeChangedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
|
|
12
12
|
this.stringJoinChar = String.fromCharCode(0), this.rowsIsTotal = [], this.colsIsTotal = [],
|
|
13
13
|
this.dataConfig = dataConfig, records) {
|
|
14
14
|
this.records = records;
|
|
@@ -53,8 +53,8 @@ class FlatDataToObjects {
|
|
|
53
53
|
}, this.dataConfig.indicatorsAsCol ? colKey.pop() : rowKey.pop()));
|
|
54
54
|
}));
|
|
55
55
|
}
|
|
56
|
-
getTreeNode(rowKey = [], colKey = [], indicator,
|
|
57
|
-
var _a, _b, _c, _d
|
|
56
|
+
getTreeNode(rowKey = [], colKey = [], indicator, ifChangedValue = !0) {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
58
58
|
let flatRowKey, flatColKey;
|
|
59
59
|
if ("string" == typeof rowKey) flatRowKey = rowKey; else {
|
|
60
60
|
let isHasIndicator = !1;
|
|
@@ -68,12 +68,14 @@ class FlatDataToObjects {
|
|
|
68
68
|
key === indicator && (colKey.splice(i, 1), isHasIndicator = !0);
|
|
69
69
|
})), isHasIndicator && colKey.push(indicator), flatColKey = colKey.join(this.stringJoinChar);
|
|
70
70
|
}
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
return ifChangedValue ? null !== (_c = null === (_b = null === (_a = this.tree) || void 0 === _a ? void 0 : _a[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) && void 0 !== _c ? _c : void 0 : (0,
|
|
72
|
+
vutils_1.isValid)(null === (_d = this.beforeChangedTree[flatRowKey]) || void 0 === _d ? void 0 : _d[flatColKey]) ? {
|
|
73
|
+
value: this.beforeChangedTree[flatRowKey][flatColKey].value,
|
|
74
|
+
record: this.beforeChangedTree[flatRowKey][flatColKey].record
|
|
75
|
+
} : void 0;
|
|
75
76
|
}
|
|
76
77
|
changeTreeNodeValue(rowKey = [], colKey = [], indicator, newValue) {
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
77
79
|
let flatRowKey, flatColKey;
|
|
78
80
|
if ("string" == typeof rowKey) flatRowKey = rowKey; else {
|
|
79
81
|
let isHasIndicator = !1;
|
|
@@ -87,7 +89,25 @@ class FlatDataToObjects {
|
|
|
87
89
|
key === indicator && (colKey.splice(i, 1), isHasIndicator = !0);
|
|
88
90
|
})), isHasIndicator && colKey.push(indicator), flatColKey = colKey.join(this.stringJoinChar);
|
|
89
91
|
}
|
|
90
|
-
this.
|
|
92
|
+
const oldValue = null === (_b = null === (_a = this.tree[flatRowKey]) || void 0 === _a ? void 0 : _a[flatColKey]) || void 0 === _b ? void 0 : _b.value, oldRecord = Object.assign({}, null === (_d = null === (_c = this.tree[flatRowKey]) || void 0 === _c ? void 0 : _c[flatColKey]) || void 0 === _d ? void 0 : _d.record);
|
|
93
|
+
(null === (_f = null === (_e = this.tree[flatRowKey]) || void 0 === _e ? void 0 : _e[flatColKey]) || void 0 === _f ? void 0 : _f.record) ? (this.tree[flatRowKey][flatColKey].record[indicator] = newValue,
|
|
94
|
+
this.tree[flatRowKey][flatColKey].value = newValue) : (this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
|
|
95
|
+
this.tree[flatRowKey][flatColKey] = {
|
|
96
|
+
record: this._buildRecord(rowKey, colKey, indicator, newValue),
|
|
97
|
+
value: newValue
|
|
98
|
+
}), (null === (_g = this.beforeChangedTree[flatRowKey]) || void 0 === _g ? void 0 : _g[flatColKey]) || (this.beforeChangedTree[flatRowKey] = {},
|
|
99
|
+
this.beforeChangedTree[flatRowKey][flatColKey] = {
|
|
100
|
+
record: void 0,
|
|
101
|
+
value: void 0
|
|
102
|
+
}, this.beforeChangedTree[flatRowKey][flatColKey].record = oldRecord, this.beforeChangedTree[flatRowKey][flatColKey].value = oldValue);
|
|
103
|
+
}
|
|
104
|
+
_buildRecord(rowKey = [], colKey = [], indicator, value) {
|
|
105
|
+
const record = {}, rowDimensions = this.dataConfig.rows, colDimensions = this.dataConfig.columns;
|
|
106
|
+
return rowDimensions.forEach(((dimension, index) => {
|
|
107
|
+
dimension !== this.dataConfig.indicatorDimensionKey && (record[dimension] = rowKey[index]);
|
|
108
|
+
})), colDimensions.forEach(((dimension, index) => {
|
|
109
|
+
dimension !== this.dataConfig.indicatorDimensionKey && (record[dimension] = colKey[index]);
|
|
110
|
+
})), record[indicator] = value, this.records.push(record), record;
|
|
91
111
|
}
|
|
92
112
|
addRecords(records) {
|
|
93
113
|
for (let i = 0, len = records.length; i < len; i++) {
|
|
@@ -96,6 +116,13 @@ class FlatDataToObjects {
|
|
|
96
116
|
}
|
|
97
117
|
this.records.push(records);
|
|
98
118
|
}
|
|
119
|
+
changeRecordFieldValue(fieldName, value) {
|
|
120
|
+
let isIndicatorName = !1;
|
|
121
|
+
for (let i = 0; i < this.dataConfig.indicators.length; i++) this.dataConfig.indicators[i] === fieldName && (isIndicatorName = !0);
|
|
122
|
+
this.records.forEach((record => {
|
|
123
|
+
isIndicatorName || (record[fieldName] = value);
|
|
124
|
+
})), this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
|
|
125
|
+
}
|
|
99
126
|
}
|
|
100
127
|
|
|
101
128
|
exports.FlatDataToObjects = FlatDataToObjects;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dataset/flatDataToObject.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAc3C,MAAa,iBAAiB;IA4C5B,YACE,UAMC,EACD,OAAe;QAlCjB,SAAI,GAAwD,EAAE,CAAC;QAC/D,gBAAW,GAAwD,EAAE,CAAC;QAC9D,gBAAW,GAAG,EAAE,CAAC;QACjB,gBAAW,GAAG,EAAE,CAAC;QAezB,mBAAc,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAEhC,gBAAW,GAAc,EAAE,CAAC;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C,GAAG,EAAE,CAAC;YAClC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;SACrD;IACH,CAAC;IACD,UAAU,CAAC,OAAc;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAClD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;CACF;AArQD,8CAqQC","file":"flatDataToObject.js","sourcesContent":["import { isValid } from '@visactor/vutils';\nimport { Env } from '../tools/env';\n\n// if (Env.mode === 'node') {\n// // eslint-disable-next-line no-global-assign\n// window = {\n// performance: {\n// now: () => -1,\n// },\n// } as any;\n// }\n/**\n * 针对聚合好的flat数据转为便于查询的行列树对象,每一个显示的指标值都能从一条数据记录中获得\n */\nexport class FlatDataToObjects {\n /**\n * 用户配置\n */\n dataConfig: {\n rows: string[]; //行维度字段数组;\n columns: string[]; //列维度字段数组;\n indicators: string[]; //具体展示指标;\n indicatorsAsCol: boolean;\n indicatorDimensionKey: string | number;\n };\n /**\n * 明细数据\n */\n records: any[];\n /**\n * 树形节点,最后的子节点对应到body部分的每个单元格 树结构: 行-列-单元格\n */\n tree: Record<string, Record<string, Record<string, any>>> = {};\n changedTree: Record<string, Record<string, Record<string, any>>> = {};\n private colFlatKeys = {};\n private rowFlatKeys = {};\n\n // //列表头的每列对应的表头键值\n // colKeys: string[][] = [];\n // //行表头的每行对应的表头键值\n // rowKeys: string[][] = [];\n // /**\n // * 对应dataset中的rowKeys,行表头的每行表头键值,包含小计总计\n // */\n // rowKeysPath: string[][];\n // /**\n // * 对应dataset中的colKeys,列表头的每列表头键值,包含小计总计\n // */\n // colKeysPath: string[][];\n\n stringJoinChar = String.fromCharCode(0);\n //缓存rows对应每个值是否为汇总字段\n private rowsIsTotal: boolean[] = [];\n private colsIsTotal: boolean[] = [];\n private colGrandTotalLabel: string;\n private colSubTotalLabel: string;\n private rowGrandTotalLabel: string;\n private rowSubTotalLabel: string;\n constructor(\n dataConfig: {\n rows: string[]; //行维度字段数组;\n columns: string[]; //列维度字段数组;\n indicators: string[]; //具体展示指标;\n indicatorsAsCol: boolean;\n indicatorDimensionKey: string | number;\n },\n records?: any[]\n ) {\n this.dataConfig = dataConfig;\n // this.allTotal = new SumAggregator(this.dataConfig.indicators[0]);\n\n if (records) {\n //处理数据\n this.records = records;\n const t0 = typeof window !== 'undefined' ? window.performance.now() : 0;\n this.setRecords(records);\n const t1 = typeof window !== 'undefined' ? window.performance.now() : 0;\n console.log('processRecords:', t1 - t0);\n }\n\n // delete this.rowFlatKeys;\n // delete this.colFlatKeys;\n }\n changeDataConfig(dataConfig: {\n rows: string[]; //行维度字段数组;\n columns: string[]; //列维度字段数组;\n indicators: string[]; //具体展示指标;\n indicatorsAsCol: boolean;\n indicatorDimensionKey: string | number;\n }) {\n this.dataConfig = dataConfig;\n }\n setRecords(records: any[]) {\n this.processRecords();\n }\n /**\n * 处理数据,遍历所有条目,过滤和派生字段的处理有待优化TODO\n */\n processRecords() {\n for (let i = 0, len = this.records.length; i < len; i++) {\n const record = this.records[i];\n this.processRecord(record);\n }\n }\n\n /**\n * 处理单条数据\n * @param record\n * @returns\n */\n processRecord(record: any) {\n const colKey: any[] = [];\n const rowKey: any[] = [];\n\n for (let l = 0, len1 = this.dataConfig.rows.length; l < len1; l++) {\n const rowAttr = this.dataConfig.rows[l];\n if (\n // record[rowAttr] !== null &&\n record[rowAttr] !== undefined &&\n rowAttr !== this.dataConfig.indicatorDimensionKey\n ) {\n rowKey.push(record[rowAttr]);\n }\n }\n for (let n = 0, len2 = this.dataConfig.columns.length; n < len2; n++) {\n const colAttr = this.dataConfig.columns[n];\n if (\n // record[colAttr] !== null &&\n record[colAttr] !== undefined &&\n colAttr !== this.dataConfig.indicatorDimensionKey\n ) {\n colKey.push(record[colAttr]);\n }\n }\n\n this.dataConfig.indicators?.forEach((indicatorKey: string | number) => {\n const recordValue: string | number = record[indicatorKey];\n // const indicatorName = this.dataConfig.indicators[indicatorKey];\n if (recordValue !== undefined) {\n if (this.dataConfig.indicatorsAsCol) {\n colKey.push(indicatorKey);\n } else {\n rowKey.push(indicatorKey);\n }\n }\n\n // record[indicatorKey] && (recordValue = record[indicatorKey]);\n\n // this.allTotal.push(record);\n\n const flatRowKey = rowKey.join(this.stringJoinChar);\n const flatColKey = colKey.join(this.stringJoinChar);\n\n if (rowKey.length !== 0) {\n if (!this.rowFlatKeys[flatRowKey]) {\n this.rowFlatKeys[flatRowKey] = 1;\n }\n }\n if (colKey.length !== 0) {\n if (!this.colFlatKeys[flatColKey]) {\n this.colFlatKeys[flatColKey] = 1;\n }\n }\n\n if (colKey.length !== 0 || rowKey.length !== 0) {\n if (!this.tree[flatRowKey]) {\n this.tree[flatRowKey] = {};\n }\n if (recordValue !== undefined) {\n this.tree[flatRowKey][flatColKey] = { value: recordValue, record };\n if (this.dataConfig.indicatorsAsCol) {\n colKey.pop();\n } else {\n rowKey.pop();\n }\n }\n }\n });\n }\n\n getTreeNode(\n rowKey: string[] | string = [],\n colKey: string[] | string = [],\n indicator: string,\n considerChangedValue: boolean = true\n ): Record<string, any> {\n let flatRowKey;\n let flatColKey;\n if (typeof rowKey === 'string') {\n flatRowKey = rowKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n rowKey.map((key, i) => {\n if (key === indicator) {\n rowKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && rowKey.push(indicator);\n flatRowKey = rowKey.join(this.stringJoinChar);\n }\n\n if (typeof colKey === 'string') {\n flatColKey = colKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n colKey.map((key, i) => {\n if (key === indicator) {\n colKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && colKey.push(indicator);\n flatColKey = colKey.join(this.stringJoinChar);\n }\n if (considerChangedValue && isValid(this.changedTree[flatRowKey]?.[flatColKey])) {\n return { value: this.changedTree[flatRowKey][flatColKey], record: this.tree?.[flatRowKey]?.[flatColKey]?.record };\n }\n return this.tree?.[flatRowKey]?.[flatColKey] ?? undefined;\n }\n\n changeTreeNodeValue(\n rowKey: string[] | string = [],\n colKey: string[] | string = [],\n indicator: string,\n newValue: any\n ) {\n let flatRowKey;\n let flatColKey;\n if (typeof rowKey === 'string') {\n flatRowKey = rowKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n rowKey.map((key, i) => {\n if (key === indicator) {\n rowKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && rowKey.push(indicator);\n flatRowKey = rowKey.join(this.stringJoinChar);\n }\n\n if (typeof colKey === 'string') {\n flatColKey = colKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n colKey.map((key, i) => {\n if (key === indicator) {\n colKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && colKey.push(indicator);\n flatColKey = colKey.join(this.stringJoinChar);\n }\n\n if (this.changedTree[flatRowKey]) {\n this.changedTree[flatRowKey][flatColKey] = newValue;\n } else {\n this.changedTree[flatRowKey] = {};\n this.changedTree[flatRowKey][flatColKey] = newValue;\n }\n }\n addRecords(records: any[]) {\n for (let i = 0, len = records.length; i < len; i++) {\n const record = records[i];\n this.processRecord(record);\n }\n this.records.push(records);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/dataset/flatDataToObject.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAc3C,MAAa,iBAAiB;IA4C5B,YACE,UAMC,EACD,OAAe;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M,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,sBAAsB,CAAC,SAAiB,EAAE,KAAsB;QAC9D,IAAI,eAAe,GAAG,KAAK,CAAC;QAE5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;gBAC/C,eAAe,GAAG,IAAI,CAAC;aACxB;SACF;QAED,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC5B,IAAI,eAAe,EAAE;aACpB;iBAAM;gBACL,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;aAC3B;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF;AA5TD,8CA4TC","file":"flatDataToObject.js","sourcesContent":["import { isValid } from '@visactor/vutils';\nimport { Env } from '../tools/env';\n\n// if (Env.mode === 'node') {\n// // eslint-disable-next-line no-global-assign\n// window = {\n// performance: {\n// now: () => -1,\n// },\n// } as any;\n// }\n/**\n * 针对聚合好的flat数据转为便于查询的行列树对象,每一个显示的指标值都能从一条数据记录中获得\n */\nexport class FlatDataToObjects {\n /**\n * 用户配置\n */\n dataConfig: {\n rows: string[]; //行维度字段数组;\n columns: string[]; //列维度字段数组;\n indicators: string[]; //具体展示指标;\n indicatorsAsCol: boolean;\n indicatorDimensionKey: string | number;\n };\n /**\n * 明细数据\n */\n records: any[];\n /**\n * 树形节点,最后的子节点对应到body部分的每个单元格 树结构: 行-列-单元格\n */\n tree: Record<string, Record<string, Record<string, any>>> = {};\n beforeChangedTree: Record<string, Record<string, { record: any; value: string }>> = {};\n private colFlatKeys = {};\n private rowFlatKeys = {};\n\n // //列表头的每列对应的表头键值\n // colKeys: string[][] = [];\n // //行表头的每行对应的表头键值\n // rowKeys: string[][] = [];\n // /**\n // * 对应dataset中的rowKeys,行表头的每行表头键值,包含小计总计\n // */\n // rowKeysPath: string[][];\n // /**\n // * 对应dataset中的colKeys,列表头的每列表头键值,包含小计总计\n // */\n // colKeysPath: string[][];\n\n stringJoinChar = String.fromCharCode(0);\n //缓存rows对应每个值是否为汇总字段\n private rowsIsTotal: boolean[] = [];\n private colsIsTotal: boolean[] = [];\n private colGrandTotalLabel: string;\n private colSubTotalLabel: string;\n private rowGrandTotalLabel: string;\n private rowSubTotalLabel: string;\n constructor(\n dataConfig: {\n rows: string[]; //行维度字段数组;\n columns: string[]; //列维度字段数组;\n indicators: string[]; //具体展示指标;\n indicatorsAsCol: boolean;\n indicatorDimensionKey: string | number;\n },\n records?: any[]\n ) {\n this.dataConfig = dataConfig;\n // this.allTotal = new SumAggregator(this.dataConfig.indicators[0]);\n\n if (records) {\n //处理数据\n this.records = records;\n const t0 = typeof window !== 'undefined' ? window.performance.now() : 0;\n this.setRecords(records);\n const t1 = typeof window !== 'undefined' ? window.performance.now() : 0;\n console.log('processRecords:', t1 - t0);\n }\n\n // delete this.rowFlatKeys;\n // delete this.colFlatKeys;\n }\n changeDataConfig(dataConfig: {\n rows: string[]; //行维度字段数组;\n columns: string[]; //列维度字段数组;\n indicators: string[]; //具体展示指标;\n indicatorsAsCol: boolean;\n indicatorDimensionKey: string | number;\n }) {\n this.dataConfig = dataConfig;\n }\n setRecords(records: any[]) {\n this.processRecords();\n }\n /**\n * 处理数据,遍历所有条目,过滤和派生字段的处理有待优化TODO\n */\n processRecords() {\n for (let i = 0, len = this.records.length; i < len; i++) {\n const record = this.records[i];\n this.processRecord(record);\n }\n }\n\n /**\n * 处理单条数据\n * @param record\n * @returns\n */\n processRecord(record: any) {\n const colKey: any[] = [];\n const rowKey: any[] = [];\n\n for (let l = 0, len1 = this.dataConfig.rows.length; l < len1; l++) {\n const rowAttr = this.dataConfig.rows[l];\n if (\n // record[rowAttr] !== null &&\n record[rowAttr] !== undefined &&\n rowAttr !== this.dataConfig.indicatorDimensionKey\n ) {\n rowKey.push(record[rowAttr]);\n }\n }\n for (let n = 0, len2 = this.dataConfig.columns.length; n < len2; n++) {\n const colAttr = this.dataConfig.columns[n];\n if (\n // record[colAttr] !== null &&\n record[colAttr] !== undefined &&\n colAttr !== this.dataConfig.indicatorDimensionKey\n ) {\n colKey.push(record[colAttr]);\n }\n }\n\n this.dataConfig.indicators?.forEach((indicatorKey: string | number) => {\n const recordValue: string | number = record[indicatorKey];\n // const indicatorName = this.dataConfig.indicators[indicatorKey];\n if (recordValue !== undefined) {\n if (this.dataConfig.indicatorsAsCol) {\n colKey.push(indicatorKey);\n } else {\n rowKey.push(indicatorKey);\n }\n }\n\n // record[indicatorKey] && (recordValue = record[indicatorKey]);\n\n // this.allTotal.push(record);\n\n const flatRowKey = rowKey.join(this.stringJoinChar);\n const flatColKey = colKey.join(this.stringJoinChar);\n\n if (rowKey.length !== 0) {\n if (!this.rowFlatKeys[flatRowKey]) {\n this.rowFlatKeys[flatRowKey] = 1;\n }\n }\n if (colKey.length !== 0) {\n if (!this.colFlatKeys[flatColKey]) {\n this.colFlatKeys[flatColKey] = 1;\n }\n }\n\n if (colKey.length !== 0 || rowKey.length !== 0) {\n if (!this.tree[flatRowKey]) {\n this.tree[flatRowKey] = {};\n }\n if (recordValue !== undefined) {\n this.tree[flatRowKey][flatColKey] = { value: recordValue, record };\n if (this.dataConfig.indicatorsAsCol) {\n colKey.pop();\n } else {\n rowKey.pop();\n }\n }\n }\n });\n }\n\n getTreeNode(\n rowKey: string[] | string = [],\n colKey: string[] | string = [],\n indicator: string,\n ifChangedValue: boolean = true\n ): Record<string, any> {\n let flatRowKey;\n let flatColKey;\n if (typeof rowKey === 'string') {\n flatRowKey = rowKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n rowKey.map((key, i) => {\n if (key === indicator) {\n rowKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && rowKey.push(indicator);\n flatRowKey = rowKey.join(this.stringJoinChar);\n }\n\n if (typeof colKey === 'string') {\n flatColKey = colKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n colKey.map((key, i) => {\n if (key === indicator) {\n colKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && colKey.push(indicator);\n flatColKey = colKey.join(this.stringJoinChar);\n }\n\n if (ifChangedValue) {\n return this.tree?.[flatRowKey]?.[flatColKey] ?? undefined;\n }\n if (isValid(this.beforeChangedTree[flatRowKey]?.[flatColKey])) {\n return {\n value: this.beforeChangedTree[flatRowKey][flatColKey].value,\n record: this.beforeChangedTree[flatRowKey][flatColKey].record\n };\n }\n return undefined;\n }\n\n changeTreeNodeValue(rowKey: string[] = [], colKey: string[] = [], indicator: string, newValue: any) {\n let flatRowKey;\n let flatColKey;\n if (typeof rowKey === 'string') {\n flatRowKey = rowKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n rowKey.map((key, i) => {\n if (key === indicator) {\n rowKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && rowKey.push(indicator);\n flatRowKey = rowKey.join(this.stringJoinChar);\n }\n\n if (typeof colKey === 'string') {\n flatColKey = colKey;\n } else {\n //考虑 指标key有可能在数组中间位置或者前面的可能 将其删除再添加到尾部\n let isHasIndicator = false;\n colKey.map((key, i) => {\n if (key === indicator) {\n colKey.splice(i, 1);\n isHasIndicator = true;\n }\n });\n isHasIndicator && colKey.push(indicator);\n flatColKey = colKey.join(this.stringJoinChar);\n }\n const oldValue = this.tree[flatRowKey]?.[flatColKey]?.value;\n const oldRecord = Object.assign({}, this.tree[flatRowKey]?.[flatColKey]?.record);\n if (this.tree[flatRowKey]?.[flatColKey]?.record) {\n this.tree[flatRowKey][flatColKey].record[indicator] = newValue;\n this.tree[flatRowKey][flatColKey].value = newValue;\n } else {\n if (!this.tree[flatRowKey]) {\n this.tree[flatRowKey] = {};\n }\n // 没有对应数据需要添加进去\n this.tree[flatRowKey][flatColKey] = {\n record: this._buildRecord(rowKey, colKey, indicator, newValue),\n value: newValue\n };\n }\n if (!this.beforeChangedTree[flatRowKey]?.[flatColKey]) {\n this.beforeChangedTree[flatRowKey] = {};\n this.beforeChangedTree[flatRowKey][flatColKey] = { record: undefined, value: undefined };\n this.beforeChangedTree[flatRowKey][flatColKey].record = oldRecord;\n this.beforeChangedTree[flatRowKey][flatColKey].value = oldValue;\n }\n }\n\n _buildRecord(rowKey: string[] = [], colKey: string[] = [], indicator: string, value: any) {\n const record = {};\n const rowDimensions = this.dataConfig.rows;\n const colDimensions = this.dataConfig.columns;\n rowDimensions.forEach((dimension, index) => {\n if (dimension !== this.dataConfig.indicatorDimensionKey) {\n record[dimension] = rowKey[index];\n }\n });\n colDimensions.forEach((dimension, index) => {\n if (dimension !== this.dataConfig.indicatorDimensionKey) {\n record[dimension] = colKey[index];\n }\n });\n record[indicator] = value;\n this.records.push(record);\n return record;\n }\n addRecords(records: any[]) {\n for (let i = 0, len = records.length; i < len; i++) {\n const record = records[i];\n this.processRecord(record);\n }\n this.records.push(records);\n }\n changeRecordFieldValue(fieldName: string, value: string | number) {\n let isIndicatorName = false;\n\n for (let i = 0; i < this.dataConfig.indicators.length; i++) {\n if (this.dataConfig.indicators[i] === fieldName) {\n isIndicatorName = true;\n }\n }\n\n this.records.forEach(record => {\n if (isIndicatorName) {\n } else {\n record[fieldName] = value;\n }\n });\n this.rowFlatKeys = {};\n this.colFlatKeys = {};\n this.tree = {};\n this.processRecords();\n }\n}\n"]}
|
package/cjs/edit/edit-manager.js
CHANGED
|
@@ -32,7 +32,6 @@ class EditManeger {
|
|
|
32
32
|
}
|
|
33
33
|
startEditCell(col, row) {
|
|
34
34
|
var _a, _b, _c, _d, _e;
|
|
35
|
-
if (this.table.isPivotTable() && this.table.isHeader(col, row)) return;
|
|
36
35
|
const editor = this.table.getEditor(col, row);
|
|
37
36
|
if (editor) {
|
|
38
37
|
if (this.table.getCustomRender(col, row) || this.table.getCustomLayout(col, row)) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/edit/edit-manager.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,wCAAoD;AAGpD,MAAa,WAAW;IAKtB,YAAY,KAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,SAAS;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,mCAAgB,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE;;YAChD,IACE,CAAE,IAAI,CAAC,KAAK,CAAC,OAAuC,CAAC,eAAe;gBACnE,IAAI,CAAC,KAAK,CAAC,OAAuC,CAAC,eAAe,KAAK,aAAa,EACrF;gBACA,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;gBAGvB,MAAM,YAAY,GAAG,IAAA,0BAAmB,EAAC,CAAC,CAAC,cAAc,CAAC,CAAC;gBAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CACpD,YAAY,CAAC,WAAW,CAAC,CAAC,EAC1B,YAAY,CAAC,WAAW,CAAC,CAAC,EAC1B,MAAA,YAAY,CAAC,SAAS,0CAAE,UAAU,CACnC,C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ent":["import type { IEditor } from '@visactor/vtable-editors';\nimport { TABLE_EVENT_TYPE } from '../core/TABLE_EVENT_TYPE';\nimport type { BaseTableAPI } from '../ts-types/base-table';\nimport type { ListTableAPI, ListTableConstructorOptions } from '../ts-types';\nimport { getCellEventArgsSet } from '../event/util';\nimport type { SimpleHeaderLayoutMap } from '../layout';\n\nexport class EditManeger {\n table: BaseTableAPI;\n editingEditor: IEditor;\n editCell: { col: number; row: number };\n\n constructor(table: BaseTableAPI) {\n this.table = table;\n this.bindEvent();\n }\n\n bindEvent() {\n const handler = this.table.internalProps.handler;\n this.table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, e => {\n if (\n !(this.table.options as ListTableConstructorOptions).editCellTrigger || //默认为双击\n (this.table.options as ListTableConstructorOptions).editCellTrigger === 'doubleclick'\n ) {\n const { col, row } = e;\n\n //取双击自动列宽逻辑\n const eventArgsSet = getCellEventArgsSet(e.federatedEvent);\n const resizeCol = this.table.scenegraph.getResizeColAt(\n eventArgsSet.abstractPos.x,\n eventArgsSet.abstractPos.y,\n eventArgsSet.eventArgs?.targetCell\n );\n if (this.table._canResizeColumn(resizeCol.col, resizeCol.row) && resizeCol.col >= 0) {\n // 判断同双击自动列宽的时间监听的DBLCLICK_CELL\n // 如果是双击自动列宽 则编辑不开启\n return;\n }\n this.startEditCell(col, row);\n }\n });\n\n this.table.on(TABLE_EVENT_TYPE.CLICK_CELL, e => {\n if ((this.table.options as ListTableConstructorOptions).editCellTrigger === 'click') {\n const { col, row } = e;\n this.startEditCell(col, row);\n }\n });\n\n handler.on(this.table.getElement(), 'wheel', (e: WheelEvent) => {\n this.completeEdit();\n });\n handler.on(this.table.getElement(), 'resize', (e: Event) => {\n if (this.table.autoFillWidth || this.table.autoFillHeight) {\n this.completeEdit();\n }\n });\n }\n\n startEditCell(col: number, row: number) {\n //透视表的表头不允许编辑\n if (this.table.isPivotTable() && this.table.isHeader(col, row)) {\n return;\n }\n const editor = (this.table as ListTableAPI).getEditor(col, row);\n if (editor) {\n //自定义内容单元格不允许编辑\n if (this.table.getCustomRender(col, row) || this.table.getCustomLayout(col, row)) {\n console.warn(\"VTable Warn: cell has config custom render or layout, can't be edited\");\n return;\n }\n if (!this.table.isHeader(col, row)) {\n const range = this.table.getCellRange(col, row);\n const isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row;\n if (isMerge) {\n console.warn(\"VTable Warn: this is merge cell, can't be edited\");\n return;\n }\n }\n if ((this.table.internalProps.layoutMap as SimpleHeaderLayoutMap)?.isAggregation?.(col, row)) {\n console.warn(\"VTable Warn: this is aggregation value, can't be edited\");\n return;\n }\n\n if (!this.editingEditor) {\n this.editCell = { col, row };\n }\n this.editingEditor = editor;\n const dataValue = this.table.getCellOriginValue(col, row);\n const rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row));\n const referencePosition = { rect: { left: rect.left, top: rect.top, width: rect.width, height: rect.height } };\n\n editor.beginEditing && console.warn('VTable Warn: `beginEditing` is deprecated, please use `onStart` instead.');\n editor.beginEditing?.(this.table.getElement(), referencePosition, dataValue);\n\n if (editor.bindSuccessCallback) {\n console.warn('VTable Warn: `bindSuccessCallback` is deprecated, please use `onStart` instead.');\n }\n editor.bindSuccessCallback?.(() => {\n this.completeEdit();\n });\n editor.onStart?.({\n value: dataValue,\n endEdit: () => {\n this.completeEdit();\n },\n referencePosition,\n container: this.table.getElement(),\n col,\n row\n });\n }\n }\n\n /** 如果是事件触发调用该接口 请传入原始事件对象 将判断事件对象是否在编辑器本身上面 来处理是否结束编辑 */\n completeEdit(e?: Event) {\n if (!this.editingEditor) {\n return;\n }\n\n const target = e?.target as HTMLElement | undefined;\n const { editingEditor: editor } = this;\n\n if (target) {\n if (editor.targetIsOnEditor) {\n console.warn('VTable Warn: `targetIsOnEditor` is deprecated, please use `isEditorElement` instead.');\n\n if (editor.targetIsOnEditor(target)) {\n return;\n }\n } else if (!editor.isEditorElement || editor.isEditorElement(target)) {\n return;\n }\n }\n\n if (!this.editingEditor.getValue) {\n console.warn('VTable Warn: `getValue` is not provided, did you forget to implement it?');\n }\n if (!this.editingEditor.validateValue || this.editingEditor.validateValue?.()) {\n const changedValue = this.editingEditor.getValue?.();\n (this.table as ListTableAPI).changeCellValue(this.editCell.col, this.editCell.row, changedValue);\n\n this.editingEditor.exit && console.warn('VTable Warn: `exit` is deprecated, please use `onEnd` instead.');\n this.editingEditor.exit?.();\n this.editingEditor.onEnd?.();\n this.editingEditor = null;\n }\n }\n\n cancelEdit() {\n if (this.editingEditor) {\n // TODO: 添加开发时弃用警告\n this.editingEditor.exit?.();\n this.editingEditor.onEnd?.();\n this.editingEditor = null;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/edit/edit-manager.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,wCAAoD;AAGpD,MAAa,WAAW;IAKtB,YAAY,KAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,SAAS;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,mCAAgB,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE;;YAChD,IACE,CAAE,IAAI,CAAC,KAAK,CAAC,OAAuC,CAAC,eAAe;gBACnE,IAAI,CAAC,KAAK,CAAC,OAAuC,CAAC,eAAe,KAAK,aAAa,EACrF;gBACA,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;gBAGvB,MAAM,YAAY,GAAG,IAAA,0BAAmB,EAAC,CAAC,CAAC,cAAc,CAAC,CAAC;gBAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CACpD,YAAY,CAAC,WAAW,CAAC,CAAC,EAC1B,YAAY,CAAC,WAAW,CAAC,CAAC,EAC1B,MAAA,YAAY,CAAC,SAA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AAO;iBACR;aACF;iBAAM,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;gBACpE,OAAO;aACR;SACF;QAED,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAChC,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;SAC1F;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,KAAI,MAAA,MAAA,IAAI,CAAC,aAAa,EAAC,aAAa,kDAAI,CAAA,EAAE;YAC7E,MAAM,YAAY,GAAG,MAAA,MAAA,IAAI,CAAC,aAAa,EAAC,QAAQ,kDAAI,CAAC;YACpD,IAAI,CAAC,KAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAEjG,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;YAC1G,MAAA,MAAA,IAAI,CAAC,aAAa,EAAC,IAAI,kDAAI,CAAC;YAC5B,MAAA,MAAA,IAAI,CAAC,aAAa,EAAC,KAAK,kDAAI,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC3B;IACH,CAAC;IAED,UAAU;;QACR,IAAI,IAAI,CAAC,aAAa,EAAE;YAEtB,MAAA,MAAA,IAAI,CAAC,aAAa,EAAC,IAAI,kDAAI,CAAC;YAC5B,MAAA,MAAA,IAAI,CAAC,aAAa,EAAC,KAAK,kDAAI,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC3B;IACH,CAAC;CACF;AAlJD,kCAkJC","file":"edit-manager.js","sourcesContent":["import type { IEditor } from '@visactor/vtable-editors';\nimport { TABLE_EVENT_TYPE } from '../core/TABLE_EVENT_TYPE';\nimport type { BaseTableAPI } from '../ts-types/base-table';\nimport type { ListTableAPI, ListTableConstructorOptions } from '../ts-types';\nimport { getCellEventArgsSet } from '../event/util';\nimport type { SimpleHeaderLayoutMap } from '../layout';\n\nexport class EditManeger {\n table: BaseTableAPI;\n editingEditor: IEditor;\n editCell: { col: number; row: number };\n\n constructor(table: BaseTableAPI) {\n this.table = table;\n this.bindEvent();\n }\n\n bindEvent() {\n const handler = this.table.internalProps.handler;\n this.table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, e => {\n if (\n !(this.table.options as ListTableConstructorOptions).editCellTrigger || //默认为双击\n (this.table.options as ListTableConstructorOptions).editCellTrigger === 'doubleclick'\n ) {\n const { col, row } = e;\n\n //取双击自动列宽逻辑\n const eventArgsSet = getCellEventArgsSet(e.federatedEvent);\n const resizeCol = this.table.scenegraph.getResizeColAt(\n eventArgsSet.abstractPos.x,\n eventArgsSet.abstractPos.y,\n eventArgsSet.eventArgs?.targetCell\n );\n if (this.table._canResizeColumn(resizeCol.col, resizeCol.row) && resizeCol.col >= 0) {\n // 判断同双击自动列宽的时间监听的DBLCLICK_CELL\n // 如果是双击自动列宽 则编辑不开启\n return;\n }\n this.startEditCell(col, row);\n }\n });\n\n this.table.on(TABLE_EVENT_TYPE.CLICK_CELL, e => {\n if ((this.table.options as ListTableConstructorOptions).editCellTrigger === 'click') {\n const { col, row } = e;\n this.startEditCell(col, row);\n }\n });\n\n handler.on(this.table.getElement(), 'wheel', (e: WheelEvent) => {\n this.completeEdit();\n });\n handler.on(this.table.getElement(), 'resize', (e: Event) => {\n if (this.table.autoFillWidth || this.table.autoFillHeight) {\n this.completeEdit();\n }\n });\n }\n\n startEditCell(col: number, row: number) {\n const editor = (this.table as ListTableAPI).getEditor(col, row);\n if (editor) {\n //自定义内容单元格不允许编辑\n if (this.table.getCustomRender(col, row) || this.table.getCustomLayout(col, row)) {\n console.warn(\"VTable Warn: cell has config custom render or layout, can't be edited\");\n return;\n }\n if (!this.table.isHeader(col, row)) {\n const range = this.table.getCellRange(col, row);\n const isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row;\n if (isMerge) {\n console.warn(\"VTable Warn: this is merge cell, can't be edited\");\n return;\n }\n }\n if ((this.table.internalProps.layoutMap as SimpleHeaderLayoutMap)?.isAggregation?.(col, row)) {\n console.warn(\"VTable Warn: this is aggregation value, can't be edited\");\n return;\n }\n\n if (!this.editingEditor) {\n this.editCell = { col, row };\n }\n this.editingEditor = editor;\n const dataValue = this.table.getCellOriginValue(col, row);\n const rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row));\n const referencePosition = { rect: { left: rect.left, top: rect.top, width: rect.width, height: rect.height } };\n\n editor.beginEditing && console.warn('VTable Warn: `beginEditing` is deprecated, please use `onStart` instead.');\n editor.beginEditing?.(this.table.getElement(), referencePosition, dataValue);\n\n if (editor.bindSuccessCallback) {\n console.warn('VTable Warn: `bindSuccessCallback` is deprecated, please use `onStart` instead.');\n }\n editor.bindSuccessCallback?.(() => {\n this.completeEdit();\n });\n editor.onStart?.({\n value: dataValue,\n endEdit: () => {\n this.completeEdit();\n },\n referencePosition,\n container: this.table.getElement(),\n col,\n row\n });\n }\n }\n\n /** 如果是事件触发调用该接口 请传入原始事件对象 将判断事件对象是否在编辑器本身上面 来处理是否结束编辑 */\n completeEdit(e?: Event) {\n if (!this.editingEditor) {\n return;\n }\n\n const target = e?.target as HTMLElement | undefined;\n const { editingEditor: editor } = this;\n\n if (target) {\n if (editor.targetIsOnEditor) {\n console.warn('VTable Warn: `targetIsOnEditor` is deprecated, please use `isEditorElement` instead.');\n\n if (editor.targetIsOnEditor(target)) {\n return;\n }\n } else if (!editor.isEditorElement || editor.isEditorElement(target)) {\n return;\n }\n }\n\n if (!this.editingEditor.getValue) {\n console.warn('VTable Warn: `getValue` is not provided, did you forget to implement it?');\n }\n if (!this.editingEditor.validateValue || this.editingEditor.validateValue?.()) {\n const changedValue = this.editingEditor.getValue?.();\n (this.table as ListTableAPI).changeCellValue(this.editCell.col, this.editCell.row, changedValue);\n\n this.editingEditor.exit && console.warn('VTable Warn: `exit` is deprecated, please use `onEnd` instead.');\n this.editingEditor.exit?.();\n this.editingEditor.onEnd?.();\n this.editingEditor = null;\n }\n }\n\n cancelEdit() {\n if (this.editingEditor) {\n // TODO: 添加开发时弃用警告\n this.editingEditor.exit?.();\n this.editingEditor.onEnd?.();\n this.editingEditor = null;\n }\n }\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { renderChart } from './scenegraph/graphic/contributions/chart-render-hel
|
|
|
16
16
|
import { restoreMeasureText, setCustomAlphabetCharSet } from './scenegraph/utils/text-measure';
|
|
17
17
|
export { getDataCellPath } from './tools/get-data-path';
|
|
18
18
|
export * from './render/jsx';
|
|
19
|
-
export declare const version = "0.24.1";
|
|
19
|
+
export declare const version = "0.24.2-alpha.1";
|
|
20
20
|
export { TYPES, core, ListTable, ListTableConstructorOptions, PivotTable, PivotTableConstructorOptions, PivotChartConstructorOptions, PivotChart, IHeaderTreeDefine, IDimension, IIndicator, ITitleDefine, ICornerDefine, ColumnsDefine, ColumnDefine, LinkColumnDefine, ChartColumnDefine, ImageColumnDefine, SparklineColumnDefine, ProgressbarColumnDefine, TextColumnDefine, GroupColumnDefine, TextAlignType, TextBaselineType, themes, data, MousePointerCellEvent, getIcons, clearGlobal, register, DataStatistics, CustomLayout, updateCell, renderChart, graphicUtil, setCustomAlphabetCharSet, restoreMeasureText };
|
|
21
21
|
declare function getIcons(): {
|
|
22
22
|
[key: string]: TYPES.ColumnIconOption;
|
package/cjs/index.js
CHANGED
|
@@ -142,6 +142,6 @@ Object.defineProperty(exports, "getDataCellPath", {
|
|
|
142
142
|
get: function() {
|
|
143
143
|
return get_data_path_1.getDataCellPath;
|
|
144
144
|
}
|
|
145
|
-
}), __exportStar(require("./render/jsx"), exports), exports.version = "0.24.1",
|
|
145
|
+
}), __exportStar(require("./render/jsx"), exports), exports.version = "0.24.2-alpha.1",
|
|
146
146
|
exports.getIcons = getIcons, exports.clearGlobal = clearGlobal, TYPES.AggregationType;
|
|
147
147
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAA4D;AA8F1D,4FA9FO,qBAAW,OA8FP;AA7Fb,IAAA,4BAAkB,GAAE,CAAC;AAErB,kDAAoC;AAqDlC,sBAAK;AApDP,6CAA+B;AAqD7B,oBAAI;AApDN,6CAA+B;AA4E7B,oBAAI;AA3EN,+CAAiC;AACjC,qDAAuC;AA+ErC,4BAAQ;AA9EV,iDAAmC;AAwEjC,wBAAM;AAvER,yEAA2D;AAiFzD,wCAAc;AA3DhB,2CAAwC;AA2BtC,0FA3BO,qBAAS,OA2BP;AA1BX,6CAA0C;AA4BxC,2FA5BO,uBAAU,OA4BP;AA3BZ,6CAA0C;AA8BxC,2FA9BO,uBAAU,OA8BP;AA5BZ,8DAAgD;AAwD9C,oCAAY;AAtDd,wEAAoE;AAuDlE,2FAvDO,wBAAU,OAuDP;AAtDZ,gGAAqF;AAuDnF,4FAvDO,iCAAW,OAuDP;AAtDb,kEAA+F;AAyD7F,mGAzDO,iCAAkB,OAyDP;AADlB,yGAxD2B,uCAAwB,OAwD3B;AAnD1B,uDAAwD;AAA/C,gHAAA,eAAe,OAAA;AACxB,+CAA6B;AAEhB,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAA4D;AA8F1D,4FA9FO,qBAAW,OA8FP;AA7Fb,IAAA,4BAAkB,GAAE,CAAC;AAErB,kDAAoC;AAqDlC,sBAAK;AApDP,6CAA+B;AAqD7B,oBAAI;AApDN,6CAA+B;AA4E7B,oBAAI;AA3EN,+CAAiC;AACjC,qDAAuC;AA+ErC,4BAAQ;AA9EV,iDAAmC;AAwEjC,wBAAM;AAvER,yEAA2D;AAiFzD,wCAAc;AA3DhB,2CAAwC;AA2BtC,0FA3BO,qBAAS,OA2BP;AA1BX,6CAA0C;AA4BxC,2FA5BO,uBAAU,OA4BP;AA3BZ,6CAA0C;AA8BxC,2FA9BO,uBAAU,OA8BP;AA5BZ,8DAAgD;AAwD9C,oCAAY;AAtDd,wEAAoE;AAuDlE,2FAvDO,wBAAU,OAuDP;AAtDZ,gGAAqF;AAuDnF,4FAvDO,iCAAW,OAuDP;AAtDb,kEAA+F;AAyD7F,mGAzDO,iCAAkB,OAyDP;AADlB,yGAxD2B,uCAAwB,OAwD3B;AAnD1B,uDAAwD;AAA/C,gHAAA,eAAe,OAAA;AACxB,+CAA6B;AAEhB,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAqDxC,SAAS,QAAQ;IAGf,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AArBC,4BAAQ;AAuBV,SAAS,WAAW;IAClB,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAGtB,CAAC;AA1BC,kCAAW;AA2Bb,KAAK,CAAC,eAAe,CAAC","file":"index.js","sourcesContent":["/* eslint-disable sort-imports */\nimport { graphicUtil, registerForVrender } from './vrender';\nregisterForVrender();\n\nimport * as TYPES from './ts-types';\nimport * as core from './core';\nimport * as data from './data';\nimport * as icons from './icons';\nimport * as register from './register';\nimport * as themes from './themes';\nimport * as DataStatistics from './dataset/DataStatistics';\nimport type {\n ColumnDefine,\n ColumnsDefine,\n LinkColumnDefine,\n ChartColumnDefine,\n ImageColumnDefine,\n SparklineColumnDefine,\n ProgressbarColumnDefine,\n TextColumnDefine,\n GroupColumnDefine,\n ListTableConstructorOptions,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions,\n IHeaderTreeDefine,\n IDimension,\n IIndicator,\n ITitleDefine,\n ICornerDefine,\n TextAlignType,\n TextBaselineType\n} from './ts-types';\nimport { ListTable } from './ListTable';\nimport { PivotTable } from './PivotTable';\nimport { PivotChart } from './PivotChart';\nimport type { MousePointerCellEvent } from './ts-types/events';\nimport * as CustomLayout from './render/layout';\n\nimport { updateCell } from './scenegraph/group-creater/cell-helper';\nimport { renderChart } from './scenegraph/graphic/contributions/chart-render-helper';\nimport { restoreMeasureText, setCustomAlphabetCharSet } from './scenegraph/utils/text-measure';\n\n// import { container, loadCanvasPicker } from '@src/vrender';\n// loadCanvasPicker(container);\n\nexport { getDataCellPath } from './tools/get-data-path';\nexport * from './render/jsx';\n\nexport const version = \"0.24.2-alpha.1\";\n/**\n * @namespace VTable\n */\nexport {\n /**\n * Types\n * @namespace VTable.TYPES\n */\n TYPES,\n core,\n ListTable,\n ListTableConstructorOptions,\n PivotTable,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions,\n PivotChart,\n IHeaderTreeDefine,\n IDimension,\n IIndicator,\n ITitleDefine,\n ICornerDefine,\n ColumnsDefine,\n ColumnDefine,\n LinkColumnDefine,\n ChartColumnDefine,\n ImageColumnDefine,\n SparklineColumnDefine,\n ProgressbarColumnDefine,\n TextColumnDefine,\n GroupColumnDefine,\n TextAlignType,\n TextBaselineType,\n themes,\n data,\n MousePointerCellEvent,\n getIcons,\n clearGlobal,\n //plugin registers\n register,\n /**\n * 暂不推荐使用\n */\n DataStatistics,\n CustomLayout,\n updateCell,\n renderChart,\n graphicUtil,\n setCustomAlphabetCharSet,\n restoreMeasureText\n};\n\n/** @private */\nfunction getIcons(): {\n [key: string]: TYPES.ColumnIconOption;\n} {\n return icons.get();\n}\n/** 清理内部的全局变量 如注册的icon theme等 以及共享的header column类实例 */\nfunction clearGlobal() {\n register.clearAll();\n // headers.type.clearGlobal();\n // columns.type.clearGlobal();\n}\nTYPES.AggregationType;\n"]}
|
|
@@ -225,4 +225,5 @@ export declare class PivotHeaderLayoutMap implements LayoutMapAPI {
|
|
|
225
225
|
isSeriesNumber(col: number, row: number): boolean;
|
|
226
226
|
getSeriesNumberHeader(col: number, row: number): SeriesNumberColumnData;
|
|
227
227
|
getSeriesNumberBody(col: number, row: number): SeriesNumberColumnData;
|
|
228
|
+
changeTreeNodeTitle(col: number, row: number, value: string): void;
|
|
228
229
|
}
|
|
@@ -1180,16 +1180,18 @@ class PivotHeaderLayoutMap {
|
|
|
1180
1180
|
let isCol = !1;
|
|
1181
1181
|
for (let j = 0; j < colArr.length; j++) {
|
|
1182
1182
|
const dimension = colArr[j];
|
|
1183
|
-
if ((
|
|
1184
|
-
vutils_1.isValid)(highlightDimension.indicatorKey) && dimension.indicatorKey === highlightDimension.indicatorKey
|
|
1183
|
+
if ((0, vutils_1.isValid)(highlightDimension.dimensionKey) && dimension.dimensionKey === highlightDimension.dimensionKey && dimension.value === highlightDimension.value || (0,
|
|
1184
|
+
vutils_1.isValid)(highlightDimension.indicatorKey) && dimension.indicatorKey === highlightDimension.indicatorKey && (dimension.value === highlightDimension.value || !(0,
|
|
1185
|
+
vutils_1.isValid)(highlightDimension.value) || !(0, vutils_1.isValid)(dimension.value))) {
|
|
1185
1186
|
colArr = dimension.children, colDimension = dimension, isCol = !0;
|
|
1186
1187
|
break;
|
|
1187
1188
|
}
|
|
1188
1189
|
}
|
|
1189
1190
|
if (!isCol) for (let k = 0; k < rowArr.length; k++) {
|
|
1190
1191
|
const dimension = rowArr[k];
|
|
1191
|
-
if ((
|
|
1192
|
-
vutils_1.isValid)(highlightDimension.indicatorKey) && dimension.indicatorKey === highlightDimension.indicatorKey
|
|
1192
|
+
if ((0, vutils_1.isValid)(highlightDimension.dimensionKey) && dimension.dimensionKey === highlightDimension.dimensionKey && dimension.value === highlightDimension.value || (0,
|
|
1193
|
+
vutils_1.isValid)(highlightDimension.indicatorKey) && dimension.indicatorKey === highlightDimension.indicatorKey && (dimension.value === highlightDimension.value || !(0,
|
|
1194
|
+
vutils_1.isValid)(highlightDimension.value) || !(0, vutils_1.isValid)(dimension.value))) {
|
|
1193
1195
|
rowArr = dimension.children, rowDimension = dimension;
|
|
1194
1196
|
break;
|
|
1195
1197
|
}
|
|
@@ -1388,6 +1390,16 @@ class PivotHeaderLayoutMap {
|
|
|
1388
1390
|
getSeriesNumberBody(col, row) {
|
|
1389
1391
|
return this.leftRowSeriesNumberColumnCount > 0 && col >= 0 && col < this.leftRowSeriesNumberColumnCount && row >= this.headerLevelCount ? this.leftRowSeriesNumberColumn[col] : this.rightRowSeriesNumberColumnCount > 0 && col >= this.colCount - this.rightRowSeriesNumberColumnCount && row >= this.headerLevelCount ? this.rightRowSeriesNumberColumn[col - (this.colCount - this.rightRowSeriesNumberColumnCount)] : void 0;
|
|
1390
1392
|
}
|
|
1393
|
+
changeTreeNodeTitle(col, row, value) {
|
|
1394
|
+
const headerPaths = this.getCellHeaderPaths(col, row);
|
|
1395
|
+
if (headerPaths.rowHeaderPaths.length > 0) {
|
|
1396
|
+
this.getHeadNode(headerPaths.rowHeaderPaths.slice(0, headerPaths.rowHeaderPaths.length)).value = value;
|
|
1397
|
+
} else if (headerPaths.colHeaderPaths.length > 0) {
|
|
1398
|
+
this.getHeadNode(headerPaths.colHeaderPaths.slice(0, headerPaths.colHeaderPaths.length)).value = value;
|
|
1399
|
+
}
|
|
1400
|
+
const id = this.getCellId(col, row);
|
|
1401
|
+
this._headerObjectMap[id].title = value;
|
|
1402
|
+
}
|
|
1391
1403
|
}
|
|
1392
1404
|
|
|
1393
1405
|
function scaleWholeRangeSize(count, bandwidth, paddingInner, paddingOuter) {
|