@visactor/vtable 0.25.4 → 0.26.0-alpha.0

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.
Files changed (121) hide show
  1. package/cjs/PivotChart.d.ts +9 -0
  2. package/cjs/PivotChart.js +90 -28
  3. package/cjs/PivotChart.js.map +1 -1
  4. package/cjs/PivotTable.d.ts +5 -2
  5. package/cjs/PivotTable.js +186 -152
  6. package/cjs/PivotTable.js.map +1 -1
  7. package/cjs/core/BaseTable.js +1 -1
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +20 -15
  10. package/cjs/dataset/dataset.js +85 -59
  11. package/cjs/dataset/dataset.js.map +1 -1
  12. package/cjs/dataset/statistics-helper.d.ts +13 -2
  13. package/cjs/dataset/statistics-helper.js +22 -27
  14. package/cjs/dataset/statistics-helper.js.map +1 -1
  15. package/cjs/index.d.ts +1 -1
  16. package/cjs/index.js +1 -1
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/layout/chart-helper/get-chart-spec.d.ts +2 -1
  19. package/cjs/layout/chart-helper/get-chart-spec.js +3 -3
  20. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  21. package/cjs/layout/layout-helper.d.ts +12 -0
  22. package/cjs/layout/layout-helper.js +52 -4
  23. package/cjs/layout/layout-helper.js.map +1 -1
  24. package/cjs/layout/pivot-header-layout.d.ts +4 -3
  25. package/cjs/layout/pivot-header-layout.js +36 -46
  26. package/cjs/layout/pivot-header-layout.js.map +1 -1
  27. package/cjs/layout/tree-helper.d.ts +1 -0
  28. package/cjs/layout/tree-helper.js +12 -7
  29. package/cjs/layout/tree-helper.js.map +1 -1
  30. package/cjs/state/cell-move/adjust-header.js +1 -1
  31. package/cjs/state/cell-move/adjust-header.js.map +1 -1
  32. package/cjs/state/resize/update-resize-column.js +1 -1
  33. package/cjs/state/resize/update-resize-column.js.map +1 -1
  34. package/cjs/state/resize/update-resize-row.js +5 -4
  35. package/cjs/state/resize/update-resize-row.js.map +1 -1
  36. package/cjs/themes/ARCO.js +1 -1
  37. package/cjs/themes/BRIGHT.js +1 -1
  38. package/cjs/themes/DARK.js +1 -1
  39. package/cjs/themes/DEFAULT.js +1 -1
  40. package/cjs/themes/SIMPLIFY.js +1 -1
  41. package/cjs/tools/LimitPromiseQueue.js +1 -1
  42. package/cjs/tools/NumberMap.js +1 -1
  43. package/cjs/tools/Rect.js +1 -1
  44. package/cjs/tools/calc.js +1 -1
  45. package/cjs/tools/debounce.js +1 -1
  46. package/cjs/tools/get-data-path/create-dataset.d.ts +9 -1
  47. package/cjs/tools/get-data-path/create-dataset.js +19 -8
  48. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  49. package/cjs/tools/get-data-path/index.js +12 -3
  50. package/cjs/tools/get-data-path/index.js.map +1 -1
  51. package/cjs/ts-types/base-table.d.ts +6 -2
  52. package/cjs/ts-types/base-table.js.map +1 -1
  53. package/cjs/ts-types/common.d.ts +2 -0
  54. package/cjs/ts-types/common.js.map +1 -1
  55. package/cjs/ts-types/menu.d.ts +1 -1
  56. package/cjs/ts-types/menu.js.map +1 -1
  57. package/cjs/ts-types/table-engine.d.ts +1 -0
  58. package/cjs/ts-types/table-engine.js.map +1 -1
  59. package/cjs/vrender.js.map +1 -1
  60. package/dist/vtable.js +882 -546
  61. package/dist/vtable.min.js +2 -2
  62. package/es/PivotChart.d.ts +9 -0
  63. package/es/PivotChart.js +97 -29
  64. package/es/PivotChart.js.map +1 -1
  65. package/es/PivotTable.d.ts +5 -2
  66. package/es/PivotTable.js +188 -148
  67. package/es/PivotTable.js.map +1 -1
  68. package/es/core/BaseTable.js +1 -1
  69. package/es/core/BaseTable.js.map +1 -1
  70. package/es/dataset/dataset.d.ts +20 -15
  71. package/es/dataset/dataset.js +85 -59
  72. package/es/dataset/dataset.js.map +1 -1
  73. package/es/dataset/statistics-helper.d.ts +13 -2
  74. package/es/dataset/statistics-helper.js +22 -27
  75. package/es/dataset/statistics-helper.js.map +1 -1
  76. package/es/index.d.ts +1 -1
  77. package/es/index.js +1 -1
  78. package/es/index.js.map +1 -1
  79. package/es/layout/chart-helper/get-chart-spec.d.ts +2 -1
  80. package/es/layout/chart-helper/get-chart-spec.js +3 -3
  81. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  82. package/es/layout/layout-helper.d.ts +12 -0
  83. package/es/layout/layout-helper.js +50 -0
  84. package/es/layout/layout-helper.js.map +1 -1
  85. package/es/layout/pivot-header-layout.d.ts +4 -3
  86. package/es/layout/pivot-header-layout.js +34 -45
  87. package/es/layout/pivot-header-layout.js.map +1 -1
  88. package/es/layout/tree-helper.d.ts +1 -0
  89. package/es/layout/tree-helper.js +12 -7
  90. package/es/layout/tree-helper.js.map +1 -1
  91. package/es/state/cell-move/adjust-header.js +1 -1
  92. package/es/state/cell-move/adjust-header.js.map +1 -1
  93. package/es/state/resize/update-resize-column.js +1 -1
  94. package/es/state/resize/update-resize-column.js.map +1 -1
  95. package/es/state/resize/update-resize-row.js +5 -4
  96. package/es/state/resize/update-resize-row.js.map +1 -1
  97. package/es/themes/ARCO.js +1 -1
  98. package/es/themes/BRIGHT.js +1 -1
  99. package/es/themes/DARK.js +1 -1
  100. package/es/themes/DEFAULT.js +1 -1
  101. package/es/themes/SIMPLIFY.js +1 -1
  102. package/es/tools/LimitPromiseQueue.js +1 -1
  103. package/es/tools/NumberMap.js +1 -1
  104. package/es/tools/Rect.js +1 -1
  105. package/es/tools/calc.js +1 -1
  106. package/es/tools/debounce.js +1 -1
  107. package/es/tools/get-data-path/create-dataset.d.ts +9 -1
  108. package/es/tools/get-data-path/create-dataset.js +20 -7
  109. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  110. package/es/tools/get-data-path/index.js +15 -2
  111. package/es/tools/get-data-path/index.js.map +1 -1
  112. package/es/ts-types/base-table.d.ts +6 -2
  113. package/es/ts-types/base-table.js.map +1 -1
  114. package/es/ts-types/common.d.ts +2 -0
  115. package/es/ts-types/common.js.map +1 -1
  116. package/es/ts-types/menu.d.ts +1 -1
  117. package/es/ts-types/menu.js.map +1 -1
  118. package/es/ts-types/table-engine.d.ts +1 -0
  119. package/es/ts-types/table-engine.js.map +1 -1
  120. package/es/vrender.js.map +1 -1
  121. package/package.json +5 -5
package/es/PivotTable.js CHANGED
@@ -18,6 +18,8 @@ import { cloneDeep, isValid } from "@visactor/vutils";
18
18
 
19
19
  import { Env } from "./tools/env";
20
20
 
21
+ import { DimensionTree } from "./layout/tree-helper";
22
+
21
23
  import { TABLE_EVENT_TYPE } from "./core/TABLE_EVENT_TYPE";
22
24
 
23
25
  import { EditManeger } from "./edit/edit-manager";
@@ -32,46 +34,54 @@ import { isAllDigits } from "./tools/util";
32
34
 
33
35
  import { cloneDeepSpec } from "./vutil-extension-temp";
34
36
 
37
+ import { parseColKeyRowKeyForPivotTable } from "./layout/layout-helper";
38
+
35
39
  export class PivotTable extends BaseTable {
36
40
  constructor(container, options) {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
38
- "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
41
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
42
+ if ("node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
39
43
  container = container.container ? container.container : null), super(container, options),
40
- options.layout && Object.assign(options, options.layout), this.internalProps.columns = cloneDeep(options.columns),
41
- this.internalProps.rows = cloneDeep(options.rows), this.internalProps.indicators = cloneDeepSpec(options.indicators),
42
- null === (_a = options.indicators) || void 0 === _a || _a.forEach(((indicatorDefine, index) => {
43
- "object" == typeof indicatorDefine && (null == indicatorDefine ? void 0 : indicatorDefine.editor) && (this.internalProps.indicators[index].editor = indicatorDefine.editor);
44
- })), this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_b = options.columns) || void 0 === _b ? void 0 : _b.length) || options.columnTree ? cloneDeep(options.columnTree) : [],
45
- this.internalProps.rowTree = options.indicatorsAsCol || (null === (_c = options.rows) || void 0 === _c ? void 0 : _c.length) || options.rowTree ? cloneDeep(options.rowTree) : [],
46
- this.internalProps.records = options.records, this.pagination = options.pagination,
47
- this.internalProps.columnResizeType = null !== (_d = options.columnResizeType) && void 0 !== _d ? _d : "column",
48
- this.internalProps.rowResizeType = null !== (_e = options.rowResizeType) && void 0 !== _e ? _e : "row",
49
- this.internalProps.dataConfig = cloneDeep(options.dataConfig), options.rowTree || options.columnTree ? this.internalProps.enableDataAnalysis = !1 : this.internalProps.enableDataAnalysis = !0;
50
- const records = this.internalProps.records;
51
- if (this.internalProps.enableDataAnalysis && (options.rows || options.columns)) {
52
- const rowKeys = null !== (_g = null === (_f = options.rows) || void 0 === _f ? void 0 : _f.reduce(((keys, rowObj) => ("string" == typeof rowObj ? keys.push(rowObj) : keys.push(rowObj.dimensionKey),
53
- keys)), [])) && void 0 !== _g ? _g : [], columnKeys = null !== (_j = null === (_h = options.columns) || void 0 === _h ? void 0 : _h.reduce(((keys, columnObj) => ("string" == typeof columnObj ? keys.push(columnObj) : keys.push(columnObj.dimensionKey),
54
- keys)), [])) && void 0 !== _j ? _j : [], indicatorKeys = null !== (_l = null === (_k = options.indicators) || void 0 === _k ? void 0 : _k.reduce(((keys, indicatorObj) => ("string" == typeof indicatorObj ? keys.push(indicatorObj) : keys.push(indicatorObj.indicatorKey),
55
- keys)), [])) && void 0 !== _l ? _l : [];
56
- this.dataset = new Dataset(this.internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_m = options.indicatorsAsCol) || void 0 === _m || _m, options.records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
57
- this.internalProps.layoutMap = new PivotHeaderLayoutMap(this, this.dataset);
58
- } else {
59
- if (!Array.isArray(this.internalProps.columnTree) && !Array.isArray(this.internalProps.rowTree)) return;
60
- this.internalProps.layoutMap = new PivotHeaderLayoutMap(this, null), (null === (_o = null == records ? void 0 : records[0]) || void 0 === _o ? void 0 : _o.constructor) !== Array && (this.flatDataToObjects = new FlatDataToObjects({
61
- rows: this.internalProps.layoutMap.fullRowDimensionKeys,
62
- columns: this.internalProps.layoutMap.colDimensionKeys,
63
- indicators: this.internalProps.layoutMap.indicatorKeys,
64
- indicatorsAsCol: this.internalProps.layoutMap.indicatorsAsCol,
65
- indicatorDimensionKey: this.internalProps.layoutMap.indicatorDimensionKey
66
- }, records));
44
+ this.layoutNodeId = {
45
+ seqId: 0
46
+ }, options) {
47
+ options.layout && Object.assign(options, options.layout), this.internalProps.columns = cloneDeep(options.columns),
48
+ this.internalProps.rows = cloneDeep(options.rows), this.internalProps.indicators = cloneDeepSpec(options.indicators),
49
+ null === (_a = options.indicators) || void 0 === _a || _a.forEach(((indicatorDefine, index) => {
50
+ "object" == typeof indicatorDefine && (null == indicatorDefine ? void 0 : indicatorDefine.editor) && (this.internalProps.indicators[index].editor = indicatorDefine.editor);
51
+ })), this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_b = options.columns) || void 0 === _b ? void 0 : _b.length) || options.columnTree ? cloneDeep(options.columnTree) : [],
52
+ this.internalProps.rowTree = options.indicatorsAsCol || (null === (_c = options.rows) || void 0 === _c ? void 0 : _c.length) || options.rowTree ? cloneDeep(options.rowTree) : [],
53
+ this.internalProps.records = options.records, this.pagination = options.pagination,
54
+ this.internalProps.columnResizeType = null !== (_d = options.columnResizeType) && void 0 !== _d ? _d : "column",
55
+ this.internalProps.rowResizeType = null !== (_e = options.rowResizeType) && void 0 !== _e ? _e : "row",
56
+ this.internalProps.dataConfig = cloneDeep(options.dataConfig);
57
+ const records = this.internalProps.records;
58
+ if (this.internalProps.recordsIsTwoDimensionalArray = !1, (null === (_f = null == records ? void 0 : records[0]) || void 0 === _f ? void 0 : _f.constructor) === Array && (this.internalProps.recordsIsTwoDimensionalArray = !0),
59
+ !1 === (null === (_g = options.customConfig) || void 0 === _g ? void 0 : _g.enableDataAnalysis)) {
60
+ const columnDimensionTree = new DimensionTree(null !== (_h = this.internalProps.columnTree) && void 0 !== _h ? _h : [], this.layoutNodeId), rowDimensionTree = new DimensionTree(null !== (_j = this.internalProps.rowTree) && void 0 !== _j ? _j : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_k = this.options.rowExpandLevel) && void 0 !== _k ? _k : 1 : void 0);
61
+ this.internalProps.layoutMap = new PivotHeaderLayoutMap(this, null, columnDimensionTree, rowDimensionTree),
62
+ !1 === this.internalProps.recordsIsTwoDimensionalArray && (this.flatDataToObjects = new FlatDataToObjects({
63
+ rows: this.internalProps.layoutMap.fullRowDimensionKeys,
64
+ columns: this.internalProps.layoutMap.colDimensionKeys,
65
+ indicators: this.internalProps.layoutMap.indicatorKeys,
66
+ indicatorsAsCol: this.internalProps.layoutMap.indicatorsAsCol,
67
+ indicatorDimensionKey: this.internalProps.layoutMap.indicatorDimensionKey
68
+ }, records));
69
+ } else {
70
+ const keysResults = parseColKeyRowKeyForPivotTable(this, options), {rowKeys: rowKeys, columnKeys: columnKeys, indicatorKeys: indicatorKeys, isNeedResetColumnDimensionTree: isNeedResetColumnDimensionTree, isNeedResetRowDimensionTree: isNeedResetRowDimensionTree} = keysResults;
71
+ let {columnDimensionTree: columnDimensionTree, rowDimensionTree: rowDimensionTree} = keysResults;
72
+ this.dataset = new Dataset(this.internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_l = options.indicatorsAsCol) || void 0 === _l || _l, options.records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
73
+ options.columnTree && !isNeedResetColumnDimensionTree || (columnDimensionTree = new DimensionTree(null !== (_m = this.dataset.colHeaderTree) && void 0 !== _m ? _m : [], this.layoutNodeId)),
74
+ options.rowTree && !isNeedResetRowDimensionTree || (rowDimensionTree = new DimensionTree(null !== (_o = this.dataset.rowHeaderTree) && void 0 !== _o ? _o : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_p = this.options.rowExpandLevel) && void 0 !== _p ? _p : 1 : void 0)),
75
+ this.internalProps.layoutMap = new PivotHeaderLayoutMap(this, this.dataset, columnDimensionTree, rowDimensionTree);
76
+ }
77
+ this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState),
78
+ "node" !== Env.mode && (this.editorManager = new EditManeger(this)), this.refreshHeader(),
79
+ this.stateManager.initCheckedState(records), this.scenegraph.createSceneGraph(),
80
+ options.title && (this.internalProps.title = new Title(options.title, this), this.scenegraph.resize()),
81
+ setTimeout((() => {
82
+ this.fireListeners(TABLE_EVENT_TYPE.INITIALIZED, null);
83
+ }), 0);
67
84
  }
68
- this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState),
69
- "node" !== Env.mode && (this.editorManager = new EditManeger(this)), this.refreshHeader(),
70
- this.stateManager.initCheckedState(records), this.scenegraph.createSceneGraph(),
71
- options.title && (this.internalProps.title = new Title(options.title, this), this.scenegraph.resize()),
72
- setTimeout((() => {
73
- this.fireListeners(TABLE_EVENT_TYPE.INITIALIZED, null);
74
- }), 0);
75
85
  }
76
86
  static get EVENT_TYPE() {
77
87
  return PIVOT_TABLE_EVENT_TYPE;
@@ -98,10 +108,12 @@ export class PivotTable extends BaseTable {
98
108
  return ifCan;
99
109
  }
100
110
  updateOption(options) {
101
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
111
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
102
112
  const internalProps = this.internalProps;
103
- if (super.updateOption(options), this.internalProps.columns = cloneDeep(options.columns),
104
- this.internalProps.rows = cloneDeep(options.rows), this.internalProps.indicators = (null === (_a = options.indicators) || void 0 === _a ? void 0 : _a.length) ? cloneDeepSpec(options.indicators) : [],
113
+ if (super.updateOption(options), this.layoutNodeId = {
114
+ seqId: 0
115
+ }, this.internalProps.columns = cloneDeep(options.columns), this.internalProps.rows = cloneDeep(options.rows),
116
+ this.internalProps.indicators = (null === (_a = options.indicators) || void 0 === _a ? void 0 : _a.length) ? cloneDeepSpec(options.indicators) : [],
105
117
  null === (_b = options.indicators) || void 0 === _b || _b.forEach(((indicatorDefine, index) => {
106
118
  "object" == typeof indicatorDefine && (null == indicatorDefine ? void 0 : indicatorDefine.editor) && (this.internalProps.indicators[index].editor = indicatorDefine.editor);
107
119
  })), this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_c = options.columns) || void 0 === _c ? void 0 : _c.length) || options.columnTree ? cloneDeep(options.columnTree) : [],
@@ -110,8 +122,7 @@ export class PivotTable extends BaseTable {
110
122
  this.stateManager.updateDrillState(void 0, void 0, !1, !1, -1, -1), this.pagination = options.pagination,
111
123
  internalProps.columnResizeType = null !== (_e = options.columnResizeType) && void 0 !== _e ? _e : "column",
112
124
  internalProps.rowResizeType = null !== (_f = options.rowResizeType) && void 0 !== _f ? _f : "row",
113
- internalProps.dataConfig = cloneDeep(options.dataConfig), options.rowTree || options.columnTree ? internalProps.enableDataAnalysis = !1 : internalProps.enableDataAnalysis = !0,
114
- "tree" === (null == options ? void 0 : options.rowHierarchyType) && "tree" === this.internalProps.layoutMap.rowHierarchyType && this.internalProps.layoutMap.rowExpandLevel === (null == options ? void 0 : options.rowExpandLevel)) {
125
+ internalProps.dataConfig = cloneDeep(options.dataConfig), "tree" === (null == options ? void 0 : options.rowHierarchyType) && "tree" === this.internalProps.layoutMap.rowHierarchyType && this.internalProps.layoutMap.rowExpandLevel === (null == options ? void 0 : options.rowExpandLevel)) {
115
126
  const beforeRowDimensions = this.internalProps.layoutMap.rowDimensionTree.tree.children;
116
127
  null === (_g = this.internalProps.rowTree) || void 0 === _g || _g.forEach(((node, index) => {
117
128
  const beforeRowDimension = beforeRowDimensions.find((item => item.dimensionKey === node.dimensionKey && item.value === node.value));
@@ -119,22 +130,26 @@ export class PivotTable extends BaseTable {
119
130
  }));
120
131
  }
121
132
  const records = this.internalProps.records;
122
- if (this.internalProps.enableDataAnalysis && (options.rows || options.columns)) {
123
- const rowKeys = null === (_h = options.rows) || void 0 === _h ? void 0 : _h.reduce(((keys, rowObj) => ("string" == typeof rowObj ? keys.push(rowObj) : keys.push(rowObj.dimensionKey),
124
- keys)), []), columnKeys = null === (_j = options.columns) || void 0 === _j ? void 0 : _j.reduce(((keys, columnObj) => ("string" == typeof columnObj ? keys.push(columnObj) : keys.push(columnObj.dimensionKey),
125
- keys)), []), indicatorKeys = null === (_k = options.indicators) || void 0 === _k ? void 0 : _k.reduce(((keys, indicatorObj) => ("string" == typeof indicatorObj ? keys.push(indicatorObj) : keys.push(indicatorObj.indicatorKey),
126
- keys)), []);
127
- this.dataset = new Dataset(internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_l = options.indicatorsAsCol) || void 0 === _l || _l, options.records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
128
- internalProps.layoutMap = new PivotHeaderLayoutMap(this, this.dataset);
129
- } else {
130
- if (!Array.isArray(this.internalProps.columnTree) && !Array.isArray(this.internalProps.rowTree)) return this;
131
- internalProps.layoutMap = new PivotHeaderLayoutMap(this, null), (null === (_m = null == records ? void 0 : records[0]) || void 0 === _m ? void 0 : _m.constructor) !== Array && (this.flatDataToObjects = new FlatDataToObjects({
133
+ if (this.internalProps.recordsIsTwoDimensionalArray = !1, (null === (_h = null == records ? void 0 : records[0]) || void 0 === _h ? void 0 : _h.constructor) === Array && (this.internalProps.recordsIsTwoDimensionalArray = !0),
134
+ !1 === (null === (_j = options.customConfig) || void 0 === _j ? void 0 : _j.enableDataAnalysis)) {
135
+ let columnDimensionTree, rowDimensionTree;
136
+ options.columnTree && (columnDimensionTree = new DimensionTree(null !== (_k = this.internalProps.columnTree) && void 0 !== _k ? _k : [], this.layoutNodeId)),
137
+ options.rowTree && (rowDimensionTree = new DimensionTree(null !== (_l = this.internalProps.rowTree) && void 0 !== _l ? _l : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_m = this.options.rowExpandLevel) && void 0 !== _m ? _m : 1 : void 0)),
138
+ internalProps.layoutMap = new PivotHeaderLayoutMap(this, null, columnDimensionTree, rowDimensionTree),
139
+ !1 === this.internalProps.recordsIsTwoDimensionalArray && (this.flatDataToObjects = new FlatDataToObjects({
132
140
  rows: internalProps.layoutMap.fullRowDimensionKeys,
133
141
  columns: internalProps.layoutMap.colDimensionKeys,
134
142
  indicators: internalProps.layoutMap.indicatorKeys,
135
143
  indicatorsAsCol: internalProps.layoutMap.indicatorsAsCol,
136
144
  indicatorDimensionKey: internalProps.layoutMap.indicatorDimensionKey
137
145
  }, records));
146
+ } else {
147
+ const keysResults = parseColKeyRowKeyForPivotTable(this, options), {rowKeys: rowKeys, columnKeys: columnKeys, indicatorKeys: indicatorKeys, isNeedResetColumnDimensionTree: isNeedResetColumnDimensionTree, isNeedResetRowDimensionTree: isNeedResetRowDimensionTree} = keysResults;
148
+ let {columnDimensionTree: columnDimensionTree, rowDimensionTree: rowDimensionTree} = keysResults;
149
+ this.dataset = new Dataset(internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_o = options.indicatorsAsCol) || void 0 === _o || _o, records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
150
+ options.columnTree && !isNeedResetColumnDimensionTree || (columnDimensionTree = new DimensionTree(null !== (_p = this.dataset.colHeaderTree) && void 0 !== _p ? _p : [], this.layoutNodeId)),
151
+ options.rowTree && !isNeedResetRowDimensionTree || (rowDimensionTree = new DimensionTree(null !== (_q = this.dataset.rowHeaderTree) && void 0 !== _q ? _q : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_r = this.options.rowExpandLevel) && void 0 !== _r ? _r : 1 : void 0)),
152
+ internalProps.layoutMap = new PivotHeaderLayoutMap(this, this.dataset, columnDimensionTree, rowDimensionTree);
138
153
  }
139
154
  return this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState),
140
155
  this.refreshHeader(), internalProps.releaseList && (internalProps.releaseList.forEach((releaseObj => {
@@ -198,34 +213,37 @@ export class PivotTable extends BaseTable {
198
213
  }
199
214
  getFieldData(field, col, row) {
200
215
  var _a;
201
- if (this.internalProps.layoutMap.isHeader(col, row)) return;
202
- if (this.dataset) {
203
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
204
- if (cellDimensionPath) {
205
- const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
216
+ if (!this.internalProps.layoutMap.isHeader(col, row)) {
217
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
218
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
219
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
220
+ }
221
+ if (this.dataset) {
222
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
223
+ if (cellDimensionPath) {
224
+ const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
225
+ var _a;
226
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
227
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
228
+ var _a;
229
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
230
+ })), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
231
+ if (aggregator.records && aggregator.records.length >= 1) return aggregator.records[0][field];
232
+ }
233
+ } else if (this.flatDataToObjects) {
234
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
206
235
  var _a;
207
236
  return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
208
237
  })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
209
238
  var _a;
210
239
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
211
- })), aggregator = this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
212
- if (aggregator.records && aggregator.records.length >= 1) return aggregator.records[0][field];
240
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
241
+ if (null == treeNode ? void 0 : treeNode.record) return null == treeNode ? void 0 : treeNode.record[field];
213
242
  }
214
- } else if (this.flatDataToObjects) {
215
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
216
- var _a;
217
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
218
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
219
- var _a;
220
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
221
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
222
- if (null == treeNode ? void 0 : treeNode.record) return null == treeNode ? void 0 : treeNode.record[field];
223
243
  }
224
- const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
225
- return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
226
244
  }
227
245
  getCellValue(col, row, skipCustomMerge) {
228
- var _a, _b;
246
+ var _a, _b, _c, _d, _e, _f, _g;
229
247
  if (!skipCustomMerge) {
230
248
  const customMergeText = this.getCustomMergeValue(col, row);
231
249
  if (customMergeText) return customMergeText;
@@ -242,15 +260,22 @@ export class PivotTable extends BaseTable {
242
260
  const {title: title, fieldFormat: fieldFormat} = this.internalProps.layoutMap.getHeader(col, row);
243
261
  return "function" == typeof fieldFormat ? fieldFormat(title, col, row, this) : title;
244
262
  }
263
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
264
+ const {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row), rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col), dataValue = null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
265
+ if ("function" == typeof fieldFormat) {
266
+ return fieldFormat(dataValue, col, row, this);
267
+ }
268
+ return dataValue;
269
+ }
245
270
  if (this.dataset) {
246
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
271
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = null === (_c = null === (_b = cellDimensionPath.colHeaderPaths) || void 0 === _b ? void 0 : _b.filter((path => !path.virtual))) || void 0 === _c ? void 0 : _c.map((colPath => {
247
272
  var _a;
248
273
  return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
249
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
274
+ })), rowKeys = null === (_e = null === (_d = cellDimensionPath.rowHeaderPaths) || void 0 === _d ? void 0 : _d.filter((path => !path.virtual))) || void 0 === _e ? void 0 : _e.map((rowPath => {
250
275
  var _a;
251
276
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
252
- })), aggregator = this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
253
- return aggregator.formatValue ? aggregator.formatValue(col, row, this) : "";
277
+ })), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)), {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row);
278
+ return aggregator.formatValue ? aggregator.formatValue(col, row, this) : "function" == typeof fieldFormat ? fieldFormat(null == aggregator ? void 0 : aggregator.value(), col, row, this) : null !== (_f = null == aggregator ? void 0 : aggregator.value()) && void 0 !== _f ? _f : "";
254
279
  }
255
280
  if (this.flatDataToObjects) {
256
281
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
@@ -260,13 +285,8 @@ export class PivotTable extends BaseTable {
260
285
  var _a;
261
286
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
262
287
  })), valueNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey), {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row);
263
- return "function" == typeof fieldFormat ? fieldFormat(null == valueNode ? void 0 : valueNode.value, col, row, this) : null !== (_a = null == valueNode ? void 0 : valueNode.value) && void 0 !== _a ? _a : "";
264
- }
265
- const {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row), rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col), dataValue = null === (_b = this.records[rowIndex]) || void 0 === _b ? void 0 : _b[colIndex];
266
- if ("function" == typeof fieldFormat) {
267
- return fieldFormat(dataValue, col, row, this);
288
+ return "function" == typeof fieldFormat ? fieldFormat(null == valueNode ? void 0 : valueNode.value, col, row, this) : null !== (_g = null == valueNode ? void 0 : valueNode.value) && void 0 !== _g ? _g : "";
268
289
  }
269
- return dataValue;
270
290
  }
271
291
  getCellOriginValue(col, row) {
272
292
  var _a;
@@ -275,6 +295,10 @@ export class PivotTable extends BaseTable {
275
295
  const {title: title} = table.internalProps.layoutMap.getHeader(col, row);
276
296
  return "function" == typeof title ? title() : title;
277
297
  }
298
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
299
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
300
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
301
+ }
278
302
  if (this.dataset) {
279
303
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
280
304
  var _a;
@@ -282,7 +306,7 @@ export class PivotTable extends BaseTable {
282
306
  })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
283
307
  var _a;
284
308
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
285
- })), aggregator = this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
309
+ })), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
286
310
  return aggregator.value ? aggregator.value() : void 0;
287
311
  }
288
312
  if (this.flatDataToObjects) {
@@ -295,8 +319,6 @@ export class PivotTable extends BaseTable {
295
319
  })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
296
320
  return null == treeNode ? void 0 : treeNode.value;
297
321
  }
298
- const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
299
- return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
300
322
  }
301
323
  getCellRawValue(col, row) {
302
324
  var _a;
@@ -305,6 +327,10 @@ export class PivotTable extends BaseTable {
305
327
  const {title: title} = table.internalProps.layoutMap.getHeader(col, row);
306
328
  return "function" == typeof title ? title() : title;
307
329
  }
330
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
331
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
332
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
333
+ }
308
334
  if (this.dataset) {
309
335
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
310
336
  var _a;
@@ -312,7 +338,7 @@ export class PivotTable extends BaseTable {
312
338
  })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
313
339
  var _a;
314
340
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
315
- })), aggregator = this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), !1);
341
+ })), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), !1);
316
342
  return aggregator.value ? aggregator.value() : void 0;
317
343
  }
318
344
  if (this.flatDataToObjects) {
@@ -325,60 +351,64 @@ export class PivotTable extends BaseTable {
325
351
  })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
326
352
  return null == treeNode ? void 0 : treeNode.value;
327
353
  }
328
- const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
329
- return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
330
354
  }
331
355
  getCellOriginRecord(col, row) {
332
356
  var _a;
333
- if (this.internalProps.layoutMap.isHeader(col, row)) return;
334
- if (this.dataset) {
335
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
336
- var _a;
337
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
338
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
339
- var _a;
340
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
341
- }));
342
- return this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
343
- }
344
- if (this.flatDataToObjects) {
345
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
346
- var _a;
347
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
348
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
349
- var _a;
350
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
351
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
352
- return null == treeNode ? void 0 : treeNode.record;
357
+ if (!this.internalProps.layoutMap.isHeader(col, row)) {
358
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
359
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
360
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
361
+ }
362
+ if (this.dataset) {
363
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
364
+ var _a;
365
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
366
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
367
+ var _a;
368
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
369
+ }));
370
+ return this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
371
+ }
372
+ if (this.flatDataToObjects) {
373
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
374
+ var _a;
375
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
376
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
377
+ var _a;
378
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
379
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
380
+ return null == treeNode ? void 0 : treeNode.record;
381
+ }
353
382
  }
354
- const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
355
- return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
356
383
  }
357
384
  getCellRawRecord(col, row) {
358
385
  var _a;
359
- if (this.internalProps.layoutMap.isHeader(col, row)) return;
360
- if (this.dataset) {
361
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
362
- var _a;
363
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
364
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
365
- var _a;
366
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
367
- }));
368
- return this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
369
- }
370
- if (this.flatDataToObjects) {
371
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
372
- var _a;
373
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
374
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
375
- var _a;
376
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
377
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
378
- return null == treeNode ? void 0 : treeNode.record;
386
+ if (!this.internalProps.layoutMap.isHeader(col, row)) {
387
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
388
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
389
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
390
+ }
391
+ if (this.dataset) {
392
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
393
+ var _a;
394
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
395
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
396
+ var _a;
397
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
398
+ }));
399
+ return this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
400
+ }
401
+ if (this.flatDataToObjects) {
402
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
403
+ var _a;
404
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
405
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
406
+ var _a;
407
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
408
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
409
+ return null == treeNode ? void 0 : treeNode.record;
410
+ }
379
411
  }
380
- const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
381
- return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
382
412
  }
383
413
  updateSortRules(sortRules) {
384
414
  this.internalProps.dataConfig.sortRules = sortRules, this.dataset.updateSortRules(sortRules),
@@ -404,18 +434,17 @@ export class PivotTable extends BaseTable {
404
434
  }
405
435
  }
406
436
  _moveHeaderPosition(source, target) {
407
- var _a, _b, _c, _d;
408
437
  const sourceCellRange = this.getCellRange(source.col, source.row), targetCellRange = this.getCellRange(target.col, target.row), moveContext = this.internalProps.layoutMap.moveHeaderPosition(source, target);
409
438
  if (moveContext) {
410
439
  if ("column" === moveContext.moveType) {
411
- if ((null === (_b = null === (_a = this.options.records) || void 0 === _a ? void 0 : _a[0]) || void 0 === _b ? void 0 : _b.constructor) === Array) for (let row = 0; row < this.internalProps.records.length; row++) {
440
+ if (this.internalProps.recordsIsTwoDimensionalArray) for (let row = 0; row < this.internalProps.records.length; row++) {
412
441
  const sourceColumns = this.internalProps.records[row].splice(moveContext.sourceIndex - this.rowHeaderLevelCount, moveContext.sourceSize);
413
442
  sourceColumns.unshift(moveContext.targetIndex - this.rowHeaderLevelCount, 0), Array.prototype.splice.apply(this.internalProps.records[row], sourceColumns);
414
443
  }
415
444
  this.colWidthsMap.exchangeOrder(sourceCellRange.start.col, sourceCellRange.end.col - sourceCellRange.start.col + 1, targetCellRange.start.col, targetCellRange.end.col - targetCellRange.start.col + 1, moveContext.targetIndex),
416
445
  this.setMinMaxLimitWidth();
417
446
  } else if ("row" === moveContext.moveType) {
418
- if ((null === (_d = null === (_c = this.options.records) || void 0 === _c ? void 0 : _c[0]) || void 0 === _d ? void 0 : _d.constructor) === Array) {
447
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
419
448
  const sourceRows = this.internalProps.records.splice(moveContext.sourceIndex - this.columnHeaderLevelCount, moveContext.sourceSize);
420
449
  sourceRows.unshift(moveContext.targetIndex - this.columnHeaderLevelCount, 0), Array.prototype.splice.apply(this.internalProps.records, sourceRows);
421
450
  }
@@ -433,7 +462,7 @@ export class PivotTable extends BaseTable {
433
462
  row: row,
434
463
  hierarchyState: HierarchyState.collapse
435
464
  }); else if (hierarchyState === HierarchyState.collapse) {
436
- const headerPaths = this.internalProps.layoutMap.getCellHeaderPaths(col, row), headerTreeNode = this.internalProps.layoutMap.getHeadNode(headerPaths.rowHeaderPaths.slice(0, headerPaths.rowHeaderPaths.length));
465
+ const headerTreeNode = this.internalProps.layoutMap.getHeadNode(col, row);
437
466
  Array.isArray(headerTreeNode.children) && this._refreshHierarchyState(col, row),
438
467
  this.fireListeners(PIVOT_TABLE_EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE, {
439
468
  col: col,
@@ -484,7 +513,7 @@ export class PivotTable extends BaseTable {
484
513
  return this.internalProps.layoutMap.getLayoutRowTreeCount();
485
514
  }
486
515
  getCellHeaderTreeNodes(col, row) {
487
- return this.internalProps.layoutMap.getCellHeaderPathsWidthTreeNode(col, row);
516
+ return this.internalProps.layoutMap.getCellHeaderPathsWithTreeNode(col, row);
488
517
  }
489
518
  _hasHierarchyTreeHeader() {
490
519
  return "tree" === this.internalProps.layoutMap.rowHierarchyType;
@@ -500,22 +529,28 @@ export class PivotTable extends BaseTable {
500
529
  };
501
530
  }
502
531
  setRecords(records) {
503
- var _a;
532
+ var _a, _b, _c, _d, _e;
504
533
  const oldHoverState = {
505
534
  col: this.stateManager.hover.cellPos.col,
506
535
  row: this.stateManager.hover.cellPos.row
507
536
  };
508
- this.options.records = this.internalProps.records = records;
537
+ this.options.records = this.internalProps.records = records, this.internalProps.recordsIsTwoDimensionalArray = !1,
538
+ (null === (_a = null == records ? void 0 : records[0]) || void 0 === _a ? void 0 : _a.constructor) === Array && (this.internalProps.recordsIsTwoDimensionalArray = !0);
509
539
  const options = this.options, internalProps = this.internalProps;
510
- this.internalProps.enableDataAnalysis && (options.rows || options.columns) ? (this.dataset.setRecords(records),
511
- internalProps.layoutMap = new PivotHeaderLayoutMap(this, this.dataset), this.pivotSortState = [],
512
- options.pivotSortState && this.updatePivotSortState(options.pivotSortState)) : (Array.isArray(this.internalProps.columnTree) || Array.isArray(this.internalProps.rowTree)) && (null === (_a = null == records ? void 0 : records[0]) || void 0 === _a ? void 0 : _a.constructor) !== Array && (this.flatDataToObjects = new FlatDataToObjects({
540
+ if (!1 === (null === (_b = this.options.customConfig) || void 0 === _b ? void 0 : _b.enableDataAnalysis)) !1 === this.internalProps.recordsIsTwoDimensionalArray && (this.flatDataToObjects = new FlatDataToObjects({
513
541
  rows: internalProps.layoutMap.fullRowDimensionKeys,
514
542
  columns: internalProps.layoutMap.colDimensionKeys,
515
543
  indicators: internalProps.layoutMap.indicatorKeys,
516
544
  indicatorsAsCol: internalProps.layoutMap.indicatorsAsCol,
517
545
  indicatorDimensionKey: internalProps.layoutMap.indicatorDimensionKey
518
- }, records)), this.refreshHeader(), this.scenegraph.clearCells(), this.clearCellStyleCache(),
546
+ }, records)); else {
547
+ let columnDimensionTree, rowDimensionTree;
548
+ this.dataset.setRecords(records), columnDimensionTree = options.columnTree ? internalProps.layoutMap.columnDimensionTree : new DimensionTree(null !== (_c = this.dataset.colHeaderTree) && void 0 !== _c ? _c : [], this.layoutNodeId),
549
+ rowDimensionTree = options.rowTree ? internalProps.layoutMap.rowDimensionTree : new DimensionTree(null !== (_d = this.dataset.rowHeaderTree) && void 0 !== _d ? _d : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_e = this.options.rowExpandLevel) && void 0 !== _e ? _e : 1 : void 0),
550
+ internalProps.layoutMap = new PivotHeaderLayoutMap(this, this.dataset, columnDimensionTree, rowDimensionTree),
551
+ this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState);
552
+ }
553
+ this.refreshHeader(), this.scenegraph.clearCells(), this.clearCellStyleCache(),
519
554
  this.scenegraph.createSceneGraph(), this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row),
520
555
  this.internalProps.title && !this.internalProps.title.isReleased && (this._updateSize(),
521
556
  this.internalProps.title.resize(), this.scenegraph.resize()), this.eventManager.updateEventBinder();
@@ -632,7 +667,10 @@ export class PivotTable extends BaseTable {
632
667
  }
633
668
  _changeCellValueToDataSet(col, row, oldValue, newValue) {
634
669
  var _a, _b, _c, _d, _e, _f;
635
- if (this.dataset) {
670
+ if (this.internalProps.recordsIsTwoDimensionalArray) {
671
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
672
+ this.records[rowIndex][colIndex] = newValue;
673
+ } else if (this.dataset) {
636
674
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
637
675
  if (this.isHeader(col, row)) this.internalProps.layoutMap.changeTreeNodeTitle(col, row, newValue),
638
676
  !this.isCornerHeader(col, row) && this.dataset.changeRecordFieldValue((null === (_a = cellDimensionPath.colHeaderPaths) || void 0 === _a ? void 0 : _a.length) ? null !== (_b = cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].indicatorKey) && void 0 !== _b ? _b : cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].dimensionKey : null !== (_c = cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].indicatorKey) && void 0 !== _c ? _c : cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].dimensionKey, oldValue, newValue); else {
@@ -658,9 +696,6 @@ export class PivotTable extends BaseTable {
658
696
  }));
659
697
  this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
660
698
  }
661
- } else {
662
- const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
663
- this.records[rowIndex][colIndex] = newValue;
664
699
  }
665
700
  }
666
701
  _hasCustomRenderOrLayout() {
@@ -683,9 +718,7 @@ export class PivotTable extends BaseTable {
683
718
  changeRecordOrder(source, target) {}
684
719
  setTreeNodeChildren(children, records, col, row) {
685
720
  if (this.flatDataToObjects) {
686
- const headerPaths = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
687
- this.internalProps.layoutMap.getHeadNode(headerPaths.rowHeaderPaths.slice(0, headerPaths.rowHeaderPaths.length)).children = children,
688
- this._refreshHierarchyState(col, row, (() => {
721
+ this.internalProps.layoutMap.getHeadNode(col, row).children = children, this._refreshHierarchyState(col, row, (() => {
689
722
  this.flatDataToObjects.changeDataConfig({
690
723
  rows: this.internalProps.layoutMap.fullRowDimensionKeys,
691
724
  columns: this.internalProps.layoutMap.colDimensionKeys,
@@ -694,6 +727,13 @@ export class PivotTable extends BaseTable {
694
727
  indicatorDimensionKey: this.internalProps.layoutMap.indicatorDimensionKey
695
728
  }), this.flatDataToObjects.addRecords(records);
696
729
  }));
730
+ } else {
731
+ this.internalProps.layoutMap.getHeadNode(col, row).children = children, this._refreshHierarchyState(col, row, (() => {
732
+ this.dataset.changeDataConfig({
733
+ rows: this.internalProps.layoutMap.fullRowDimensionKeys,
734
+ columns: this.internalProps.layoutMap.colDimensionKeys
735
+ }), this.dataset.addRecords(records);
736
+ }));
697
737
  }
698
738
  }
699
739
  }