@visactor/vtable-plugins 1.21.1 → 1.22.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 (117) hide show
  1. package/cjs/add-row-column.js +2 -2
  2. package/cjs/add-row-column.js.map +1 -1
  3. package/cjs/auto-fill/utils/date.js +1 -1
  4. package/cjs/auto-fill/utils/fill.js +1 -1
  5. package/cjs/column-series.js +1 -1
  6. package/cjs/column-series.js.map +1 -1
  7. package/cjs/contextmenu/handle-menu-helper.js +16 -9
  8. package/cjs/contextmenu/handle-menu-helper.js.map +1 -1
  9. package/cjs/contextmenu/menu-manager.js +1 -2
  10. package/cjs/contextmenu/styles.js +2 -1
  11. package/cjs/highlight-header-when-select-cell.js +1 -1
  12. package/cjs/highlight-header-when-select-cell.js.map +1 -1
  13. package/cjs/index.d.ts +1 -0
  14. package/cjs/index.js +4 -4
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/master-detail-plugin/checkbox.d.ts +5 -0
  17. package/cjs/master-detail-plugin/checkbox.js +105 -0
  18. package/cjs/master-detail-plugin/checkbox.js.map +1 -0
  19. package/cjs/master-detail-plugin/config.d.ts +17 -0
  20. package/cjs/master-detail-plugin/config.js +113 -0
  21. package/cjs/master-detail-plugin/config.js.map +1 -0
  22. package/cjs/master-detail-plugin/core.d.ts +50 -0
  23. package/cjs/master-detail-plugin/core.js +310 -0
  24. package/cjs/master-detail-plugin/core.js.map +1 -0
  25. package/cjs/master-detail-plugin/events.d.ts +59 -0
  26. package/cjs/master-detail-plugin/events.js +265 -0
  27. package/cjs/master-detail-plugin/events.js.map +1 -0
  28. package/cjs/master-detail-plugin/index.d.ts +4 -0
  29. package/cjs/master-detail-plugin/index.js +15 -0
  30. package/cjs/master-detail-plugin/index.js.map +1 -0
  31. package/cjs/master-detail-plugin/subtable.d.ts +39 -0
  32. package/cjs/master-detail-plugin/subtable.js +457 -0
  33. package/cjs/master-detail-plugin/subtable.js.map +1 -0
  34. package/cjs/master-detail-plugin/table-api-extensions.d.ts +59 -0
  35. package/cjs/master-detail-plugin/table-api-extensions.js +462 -0
  36. package/cjs/master-detail-plugin/table-api-extensions.js.map +1 -0
  37. package/cjs/master-detail-plugin/types.d.ts +61 -0
  38. package/cjs/master-detail-plugin/types.js +20 -0
  39. package/cjs/master-detail-plugin/types.js.map +1 -0
  40. package/cjs/master-detail-plugin/utils.d.ts +8 -0
  41. package/cjs/master-detail-plugin/utils.js +62 -0
  42. package/cjs/master-detail-plugin/utils.js.map +1 -0
  43. package/cjs/master-detail-plugin.d.ts +1 -0
  44. package/cjs/master-detail-plugin.js +15 -0
  45. package/cjs/master-detail-plugin.js.map +1 -0
  46. package/cjs/paste-add-row-column.js +2 -2
  47. package/cjs/paste-add-row-column.js.map +1 -1
  48. package/cjs/row-series.js +1 -2
  49. package/cjs/table-carousel-animation.js +2 -1
  50. package/cjs/table-export/csv/index.js +1 -1
  51. package/cjs/table-export/util/color.js +2 -1
  52. package/cjs/table-export/util/download.js +1 -1
  53. package/cjs/table-export/util/encode.js +1 -1
  54. package/cjs/table-export/util/indent.js +1 -1
  55. package/cjs/table-export/util/pagination.js +1 -1
  56. package/cjs/table-export/util/promise.js +1 -1
  57. package/cjs/table-export/util/type.js +1 -1
  58. package/dist/vtable-plugins.js +2885 -240
  59. package/dist/vtable-plugins.min.js +3 -3
  60. package/es/add-row-column.js +2 -2
  61. package/es/add-row-column.js.map +1 -1
  62. package/es/auto-fill/utils/date.js +1 -1
  63. package/es/auto-fill/utils/fill.js +1 -1
  64. package/es/column-series.js +1 -1
  65. package/es/column-series.js.map +1 -1
  66. package/es/contextmenu/handle-menu-helper.js +16 -9
  67. package/es/contextmenu/handle-menu-helper.js.map +1 -1
  68. package/es/contextmenu/menu-manager.js +1 -2
  69. package/es/contextmenu/styles.js +2 -1
  70. package/es/highlight-header-when-select-cell.js +1 -1
  71. package/es/highlight-header-when-select-cell.js.map +1 -1
  72. package/es/index.d.ts +1 -0
  73. package/es/index.js +2 -0
  74. package/es/index.js.map +1 -1
  75. package/es/master-detail-plugin/checkbox.d.ts +5 -0
  76. package/es/master-detail-plugin/checkbox.js +94 -0
  77. package/es/master-detail-plugin/checkbox.js.map +1 -0
  78. package/es/master-detail-plugin/config.d.ts +17 -0
  79. package/es/master-detail-plugin/config.js +80 -0
  80. package/es/master-detail-plugin/config.js.map +1 -0
  81. package/es/master-detail-plugin/core.d.ts +50 -0
  82. package/es/master-detail-plugin/core.js +285 -0
  83. package/es/master-detail-plugin/core.js.map +1 -0
  84. package/es/master-detail-plugin/events.d.ts +59 -0
  85. package/es/master-detail-plugin/events.js +232 -0
  86. package/es/master-detail-plugin/events.js.map +1 -0
  87. package/es/master-detail-plugin/index.d.ts +4 -0
  88. package/es/master-detail-plugin/index.js +4 -0
  89. package/es/master-detail-plugin/index.js.map +1 -0
  90. package/es/master-detail-plugin/subtable.d.ts +39 -0
  91. package/es/master-detail-plugin/subtable.js +426 -0
  92. package/es/master-detail-plugin/subtable.js.map +1 -0
  93. package/es/master-detail-plugin/table-api-extensions.d.ts +59 -0
  94. package/es/master-detail-plugin/table-api-extensions.js +445 -0
  95. package/es/master-detail-plugin/table-api-extensions.js.map +1 -0
  96. package/es/master-detail-plugin/types.d.ts +61 -0
  97. package/es/master-detail-plugin/types.js +12 -0
  98. package/es/master-detail-plugin/types.js.map +1 -0
  99. package/es/master-detail-plugin/utils.d.ts +8 -0
  100. package/es/master-detail-plugin/utils.js +52 -0
  101. package/es/master-detail-plugin/utils.js.map +1 -0
  102. package/es/master-detail-plugin.d.ts +1 -0
  103. package/es/master-detail-plugin.js +2 -0
  104. package/es/master-detail-plugin.js.map +1 -0
  105. package/es/paste-add-row-column.js +2 -2
  106. package/es/paste-add-row-column.js.map +1 -1
  107. package/es/row-series.js +1 -2
  108. package/es/table-carousel-animation.js +2 -1
  109. package/es/table-export/csv/index.js +1 -1
  110. package/es/table-export/util/color.js +2 -1
  111. package/es/table-export/util/download.js +1 -1
  112. package/es/table-export/util/encode.js +1 -1
  113. package/es/table-export/util/indent.js +1 -1
  114. package/es/table-export/util/pagination.js +1 -1
  115. package/es/table-export/util/promise.js +1 -1
  116. package/es/table-export/util/type.js +1 -1
  117. package/package.json +6 -6
@@ -0,0 +1,59 @@
1
+ import type * as VTable from '@visactor/vtable';
2
+ import type { Group } from '@visactor/vtable/es/scenegraph/graphic/group';
3
+ import type { ConfigManager } from './config';
4
+ import type { EventManager } from './events';
5
+ export declare class TableAPIExtensions {
6
+ private table;
7
+ private configManager;
8
+ private eventManager;
9
+ private originalUpdateCellContent?;
10
+ private originalUpdateResizeRow?;
11
+ private originalDealHeightMode?;
12
+ private originalUpdatePagination?;
13
+ private originalToggleHierarchyState?;
14
+ private originalUpdateFilterRules?;
15
+ private originalUpdateChartSizeForResizeColWidth?;
16
+ private originalUpdateChartSizeForResizeRowHeight?;
17
+ private originalUpdateRowHeight?;
18
+ private originalGetResizeColAt?;
19
+ private currentMouseX;
20
+ private currentMouseY;
21
+ private mouseEventListener?;
22
+ private isDragging;
23
+ private dragStartIsPluginUnderline;
24
+ private callbacks;
25
+ constructor(table: VTable.ListTable, configManager: ConfigManager, eventManager: EventManager, callbacks: {
26
+ addUnderlineToCell: (cellGroup: Group, originalHeight: number) => void;
27
+ updateOriginalHeightsAfterAdaptive: (expandedRowsInfo: Map<number, {
28
+ baseHeight: number;
29
+ detailHeight: number;
30
+ }>) => void;
31
+ collapseRowToNoRealRecordIndex: (rowIndex: number) => void;
32
+ expandRow: (rowIndex: number) => void;
33
+ restoreExpandedStatesAfter: () => void;
34
+ collapseRow: (rowIndex: number) => void;
35
+ updateSubTablePositions: () => void;
36
+ updateRowHeightForExpand: (rowIndex: number, deltaHeight: number) => void;
37
+ });
38
+ private initMouseTracking;
39
+ extendTableAPI(): void;
40
+ private extendUpdateCellContent;
41
+ private extendUpdateResizeRow;
42
+ private updateResizeColForRow;
43
+ private updateResizeColForAll;
44
+ private extendDealHeightMode;
45
+ private extendUpdatePagination;
46
+ private extendToggleHierarchyState;
47
+ private extendUpdateFilterRules;
48
+ private extendUpdateChartSizeForResizeColWidth;
49
+ private extendUpdateChartSizeForResizeRowHeight;
50
+ private extendGetRowY;
51
+ private extendUpdateRowHeight;
52
+ private extendGetResizeColAt;
53
+ private isMouseInPluginUnderlineArea;
54
+ private protectedShowResizeRow;
55
+ private protectedUpdateResizeRow;
56
+ private getRowsHeightWithOriginalHeight;
57
+ private waitForRenderComplete;
58
+ cleanup(): void;
59
+ }
@@ -0,0 +1,462 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.TableAPIExtensions = void 0;
6
+
7
+ const vtable_1 = require("@visactor/vtable"), utils_1 = require("./utils");
8
+
9
+ class TableAPIExtensions {
10
+ constructor(table, configManager, eventManager, callbacks) {
11
+ this.currentMouseX = 0, this.currentMouseY = 0, this.isDragging = !1, this.dragStartIsPluginUnderline = !1,
12
+ this.table = table, this.configManager = configManager, this.eventManager = eventManager,
13
+ this.callbacks = callbacks, this.initMouseTracking();
14
+ }
15
+ initMouseTracking() {
16
+ this.mouseEventListener = event => {
17
+ try {
18
+ const table = this.table;
19
+ if (table && table.internalProps && table.internalProps.canvas) {
20
+ const rect = table.internalProps.canvas.getBoundingClientRect();
21
+ this.currentMouseX = event.clientX - rect.left, this.currentMouseY = event.clientY - rect.top;
22
+ }
23
+ } catch (error) {}
24
+ "mouseup" === event.type && (this.isDragging = !1, this.dragStartIsPluginUnderline = !1);
25
+ };
26
+ try {
27
+ const table = this.table;
28
+ if (table && table.internalProps && table.internalProps.canvas) {
29
+ const canvas = table.internalProps.canvas;
30
+ canvas.addEventListener("mousemove", this.mouseEventListener), canvas.addEventListener("mousedown", this.mouseEventListener),
31
+ canvas.addEventListener("mouseup", this.mouseEventListener);
32
+ }
33
+ } catch (error) {}
34
+ }
35
+ extendTableAPI() {
36
+ this.extendUpdateCellContent(), this.extendUpdateResizeRow(), this.extendDealHeightMode(),
37
+ this.extendUpdatePagination(), this.extendToggleHierarchyState(), this.extendUpdateFilterRules(),
38
+ this.extendUpdateChartSizeForResizeColWidth(), this.extendUpdateChartSizeForResizeRowHeight(),
39
+ this.extendGetRowY(), this.extendUpdateRowHeight(), this.extendGetResizeColAt();
40
+ }
41
+ extendUpdateCellContent() {
42
+ const table = this.table;
43
+ this.originalUpdateCellContent = table.scenegraph.updateCellContent.bind(table.scenegraph),
44
+ table.scenegraph.updateCellContent = (col, row, forceFastUpdate = !1) => {
45
+ var _a, _b, _c, _d;
46
+ if (this.eventManager.isRowExpanded(row)) {
47
+ const bodyRowIndex = row - this.table.columnHeaderLevelCount, originalHeight = (0,
48
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex), currentHeight = this.table.getRowHeight(row);
49
+ if (originalHeight > 0 && currentHeight !== originalHeight) {
50
+ this.table._setRowHeight(row, originalHeight, !1);
51
+ const oldCellGroup = this.table.scenegraph.getCell(col, row), originalY = null === (_a = null == oldCellGroup ? void 0 : oldCellGroup.attribute) || void 0 === _a ? void 0 : _a.y, result = null === (_b = this.originalUpdateCellContent) || void 0 === _b ? void 0 : _b.call(this, col, row, forceFastUpdate);
52
+ if (this.table._setRowHeight(row, currentHeight, !1), void 0 !== originalY) {
53
+ const newCellGroup = this.table.scenegraph.getCell(col, row);
54
+ newCellGroup && newCellGroup.attribute.y !== originalY && newCellGroup.setAttribute("y", originalY);
55
+ }
56
+ const cellGroup = this.table.scenegraph.getCell(col, row);
57
+ return cellGroup && (row !== this.table.rowCount - 1 && this.callbacks.addUnderlineToCell(cellGroup, originalHeight),
58
+ this.eventManager.handleAfterUpdateCellContentWidth({
59
+ col: col,
60
+ row: row,
61
+ cellHeight: (null === (_c = cellGroup.attribute) || void 0 === _c ? void 0 : _c.height) || 0,
62
+ cellGroup: cellGroup,
63
+ padding: [ 0, 0, 0, 0 ],
64
+ textBaseline: "middle"
65
+ })), result;
66
+ }
67
+ }
68
+ return null === (_d = this.originalUpdateCellContent) || void 0 === _d ? void 0 : _d.call(this, col, row, forceFastUpdate);
69
+ };
70
+ }
71
+ extendUpdateResizeRow() {
72
+ const table = this.table;
73
+ this.originalUpdateResizeRow = table.stateManager.updateResizeRow.bind(table.stateManager),
74
+ table.stateManager.updateResizeRow = (xInTable, yInTable) => {
75
+ const state = table.stateManager;
76
+ xInTable = Math.ceil(xInTable), yInTable = Math.ceil(yInTable);
77
+ let detaY = state.rowResize.isBottomFrozen ? state.rowResize.y - yInTable : yInTable - state.rowResize.y;
78
+ if (Math.abs(detaY) < 1) return;
79
+ const resizeRowIndex = state.rowResize.row, isExpandedRow = this.eventManager.isRowExpanded(resizeRowIndex), originalLimitMinHeight = state.table.internalProps.limitMinHeight;
80
+ let currentRowMinHeight = originalLimitMinHeight;
81
+ if (isExpandedRow) {
82
+ const bodyRowIndex = resizeRowIndex - this.table.columnHeaderLevelCount, originalHeight = (0,
83
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex), detailHeight = this.table.getRowHeight(resizeRowIndex) - originalHeight;
84
+ currentRowMinHeight = this.dragStartIsPluginUnderline ? originalLimitMinHeight + detailHeight : originalHeight + originalLimitMinHeight;
85
+ }
86
+ let afterSize = state.table.getRowHeight(state.rowResize.row) + detaY;
87
+ if (afterSize < currentRowMinHeight && (afterSize = currentRowMinHeight, detaY = afterSize - state.table.getRowHeight(state.rowResize.row)),
88
+ "adaptive" === state.table.heightMode && state.rowResize.row < state.table.rowCount - 1) {
89
+ let bottomRowHeight = state.table.getRowHeight(state.rowResize.row + 1);
90
+ bottomRowHeight -= detaY;
91
+ let nextRowMinHeight = originalLimitMinHeight;
92
+ const nextRowIndex = state.rowResize.row + 1;
93
+ if (this.eventManager.isRowExpanded(nextRowIndex)) {
94
+ const nextBodyRowIndex = nextRowIndex - this.table.columnHeaderLevelCount, nextOriginalHeight = (0,
95
+ utils_1.getOriginalRowHeight)(this.table, nextBodyRowIndex);
96
+ nextRowMinHeight = originalLimitMinHeight + (this.table.getRowHeight(nextRowIndex) - nextOriginalHeight);
97
+ }
98
+ bottomRowHeight - detaY < nextRowMinHeight && (detaY = bottomRowHeight - nextRowMinHeight);
99
+ }
100
+ detaY = Math.ceil(detaY), state.rowResize.row < state.table.columnHeaderLevelCount || state.rowResize.row >= state.table.rowCount - state.table.bottomFrozenRowCount ? this.updateResizeColForRow(detaY, state) : "all" === state.table.internalProps.rowResizeType ? this.updateResizeColForAll(detaY, state) : this.updateResizeColForRow(detaY, state),
101
+ state.rowResize.y = yInTable, state.table.scenegraph.component.updateResizeRow(state.rowResize.row, xInTable, state.rowResize.isBottomFrozen),
102
+ state.table.scenegraph.updateNextFrame();
103
+ };
104
+ }
105
+ updateResizeColForRow(detaY, state) {
106
+ "adaptive" === state.table.heightMode && state.rowResize.row < state.table.rowCount - 1 ? (state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY),
107
+ state.table.scenegraph.updateRowHeight(state.rowResize.row + 1, -detaY), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row),
108
+ state.table.internalProps._heightResizedRowMap.add(state.rowResize.row + 1)) : (state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY),
109
+ state.table.internalProps._heightResizedRowMap.add(state.rowResize.row));
110
+ }
111
+ updateResizeColForAll(detaY, state) {
112
+ for (let row = state.table.frozenRowCount; row < state.table.rowCount - state.table.bottomFrozenRowCount; row++) state.table.scenegraph.updateRowHeight(row, detaY),
113
+ state.table.internalProps._heightResizedRowMap.add(row);
114
+ }
115
+ extendDealHeightMode() {
116
+ const scenegraph = this.table.scenegraph;
117
+ this.originalDealHeightMode = scenegraph.dealHeightMode.bind(scenegraph), scenegraph.dealHeightMode = () => {
118
+ if ("adaptive" !== this.table.heightMode) return this.originalDealHeightMode();
119
+ const expandedRowIndices = this.eventManager.getExpandedRows(), table = this.table, tableAny = table;
120
+ table._clearRowRangeHeightsMap();
121
+ let startRow, totalDrawHeight;
122
+ if ("all" === (tableAny.heightAdaptiveMode || "only-body")) startRow = 0, totalDrawHeight = table.tableNoFrameHeight; else {
123
+ const columnHeaderHeight = table.getRowsHeight(0, table.columnHeaderLevelCount - 1), bottomHeaderHeight = table.isPivotChart() ? table.getBottomFrozenRowsHeight() : 0;
124
+ startRow = table.columnHeaderLevelCount, totalDrawHeight = table.tableNoFrameHeight - columnHeaderHeight - bottomHeaderHeight;
125
+ }
126
+ const endRow = table.isPivotChart() ? table.rowCount - table.bottomFrozenRowCount : table.rowCount;
127
+ if (0 === expandedRowIndices.length) {
128
+ let normalRowsBaseHeight = 0;
129
+ for (let row = startRow; row < endRow; row++) normalRowsBaseHeight += table.getRowHeight(row);
130
+ if (normalRowsBaseHeight > 0) {
131
+ const scaleFactor = totalDrawHeight / normalRowsBaseHeight;
132
+ for (let row = startRow; row < endRow; row++) {
133
+ const baseHeight = table.getRowHeight(row), newHeight = Math.max(Math.round(baseHeight * scaleFactor), 20);
134
+ scenegraph.setRowHeight(row, newHeight);
135
+ }
136
+ }
137
+ return;
138
+ }
139
+ const expandedRowsInfo = new Map;
140
+ let totalExpandedExtraHeight = 0;
141
+ for (const rowIndex of expandedRowIndices) if (rowIndex >= table.columnHeaderLevelCount && rowIndex < endRow) {
142
+ const bodyRowIndex = rowIndex - table.columnHeaderLevelCount, originalHeight = (0,
143
+ utils_1.getOriginalRowHeight)(table, bodyRowIndex), currentRowHeight = table.getRowHeight(rowIndex), detailHeight = currentRowHeight - originalHeight;
144
+ expandedRowsInfo.set(rowIndex, {
145
+ baseHeight: originalHeight > 0 ? originalHeight : currentRowHeight,
146
+ detailHeight: detailHeight
147
+ }), totalExpandedExtraHeight += detailHeight;
148
+ }
149
+ let normalRowsBaseHeight = 0;
150
+ for (let row = startRow; row < endRow; row++) if (expandedRowsInfo.has(row)) {
151
+ const info = expandedRowsInfo.get(row);
152
+ info && (normalRowsBaseHeight += info.baseHeight);
153
+ } else normalRowsBaseHeight += table.getRowHeight(row);
154
+ const scaleFactor = (totalDrawHeight - totalExpandedExtraHeight) / normalRowsBaseHeight;
155
+ for (let row = startRow; row < endRow; row++) {
156
+ let newHeight;
157
+ if (expandedRowsInfo.has(row)) {
158
+ const info = expandedRowsInfo.get(row);
159
+ if (info) {
160
+ const scaledBaseHeight = Math.round(info.baseHeight * scaleFactor);
161
+ newHeight = scaledBaseHeight + info.detailHeight, expandedRowsInfo.set(row, {
162
+ baseHeight: scaledBaseHeight,
163
+ detailHeight: info.detailHeight
164
+ });
165
+ } else newHeight = Math.round(table.getRowHeight(row) * scaleFactor);
166
+ } else {
167
+ const baseHeight = table.getRowHeight(row);
168
+ newHeight = Math.round(baseHeight * scaleFactor);
169
+ }
170
+ scenegraph.setRowHeight(row, newHeight);
171
+ }
172
+ const allRows = [];
173
+ for (let row = startRow; row < endRow; row++) allRows.push(row);
174
+ if (allRows.length > 0) {
175
+ const currentTotalHeight = allRows.reduce(((sum, row) => sum + table.getRowHeight(row)), 0);
176
+ if (Math.abs(currentTotalHeight - totalDrawHeight) > 1) {
177
+ const lastRowIndex = allRows[allRows.length - 1], adjustment = totalDrawHeight - allRows.slice(0, -1).reduce(((sum, row) => sum + table.getRowHeight(row)), 0);
178
+ if (expandedRowsInfo.has(lastRowIndex)) {
179
+ const info = expandedRowsInfo.get(lastRowIndex);
180
+ if (info) {
181
+ const minHeight = info.detailHeight, finalHeight = Math.max(adjustment, minHeight);
182
+ scenegraph.setRowHeight(lastRowIndex, finalHeight), expandedRowsInfo.set(lastRowIndex, {
183
+ baseHeight: finalHeight - info.detailHeight,
184
+ detailHeight: info.detailHeight
185
+ });
186
+ }
187
+ } else scenegraph.setRowHeight(lastRowIndex, adjustment);
188
+ }
189
+ }
190
+ this.callbacks.updateOriginalHeightsAfterAdaptive(expandedRowsInfo), this.callbacks.updateSubTablePositions();
191
+ };
192
+ }
193
+ extendUpdatePagination() {
194
+ const table = this.table;
195
+ this.originalUpdatePagination = table.updatePagination.bind(table), table.updatePagination = pagination => {
196
+ [ ...this.eventManager.getExpandedRows() ].forEach((rowIndex => {
197
+ this.callbacks.collapseRowToNoRealRecordIndex(rowIndex);
198
+ }));
199
+ const result = this.originalUpdatePagination(pagination);
200
+ return this.waitForRenderComplete((() => {
201
+ this.callbacks.restoreExpandedStatesAfter();
202
+ })), result;
203
+ };
204
+ }
205
+ extendToggleHierarchyState() {
206
+ const table = this.table;
207
+ this.originalToggleHierarchyState = table.toggleHierarchyState.bind(table), table.toggleHierarchyState = (col, row, recalculateColWidths = !0) => {
208
+ if (this.table.isHeader(col, row)) {
209
+ [ ...this.eventManager.getExpandedRows() ].forEach((rowIndex => {
210
+ this.callbacks.collapseRowToNoRealRecordIndex(rowIndex);
211
+ }));
212
+ const result = this.originalToggleHierarchyState(col, row, recalculateColWidths);
213
+ return this.waitForRenderComplete((() => {
214
+ this.callbacks.restoreExpandedStatesAfter();
215
+ })), result;
216
+ }
217
+ return this.originalToggleHierarchyState(col, row, recalculateColWidths);
218
+ };
219
+ }
220
+ extendUpdateFilterRules() {
221
+ const table = this.table;
222
+ this.originalUpdateFilterRules = table.updateFilterRules.bind(table), table.updateFilterRules = filterRules => {
223
+ [ ...this.eventManager.getExpandedRows() ].forEach((rowIndex => {
224
+ this.callbacks.collapseRow(rowIndex);
225
+ }));
226
+ return this.originalUpdateFilterRules(filterRules);
227
+ };
228
+ }
229
+ extendUpdateChartSizeForResizeColWidth() {
230
+ const table = this.table;
231
+ this.originalUpdateChartSizeForResizeColWidth = table.scenegraph.updateChartSizeForResizeColWidth.bind(table.scenegraph),
232
+ table.scenegraph.updateChartSizeForResizeColWidth = col => {
233
+ const originalGetRowHeight = table.getRowHeight.bind(table);
234
+ table.getRowHeight = row => {
235
+ if (this.eventManager.isRowExpanded(row)) {
236
+ const bodyRowIndex = row - this.table.columnHeaderLevelCount, originalHeight = (0,
237
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
238
+ return originalHeight > 0 ? originalHeight : originalGetRowHeight(row);
239
+ }
240
+ return originalGetRowHeight(row);
241
+ };
242
+ const result = this.originalUpdateChartSizeForResizeColWidth(col);
243
+ return table.getRowHeight = originalGetRowHeight, result;
244
+ };
245
+ }
246
+ extendUpdateChartSizeForResizeRowHeight() {
247
+ const table = this.table;
248
+ this.originalUpdateChartSizeForResizeRowHeight = table.scenegraph.updateChartSizeForResizeRowHeight.bind(table.scenegraph),
249
+ table.scenegraph.updateChartSizeForResizeRowHeight = col => {
250
+ const originalGetRowHeight = table.getRowHeight.bind(table);
251
+ table.getRowHeight = row => {
252
+ if (this.eventManager.isRowExpanded(row)) {
253
+ const bodyRowIndex = row - this.table.columnHeaderLevelCount, originalHeight = (0,
254
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
255
+ return originalHeight > 0 ? originalHeight : originalGetRowHeight(row);
256
+ }
257
+ return originalGetRowHeight(row);
258
+ };
259
+ const result = this.originalUpdateChartSizeForResizeRowHeight(col);
260
+ return table.getRowHeight = originalGetRowHeight, result;
261
+ };
262
+ }
263
+ extendGetRowY() {
264
+ var _a;
265
+ const scenegraph = this.table.scenegraph;
266
+ if (scenegraph.component) {
267
+ const originalShowResizeRow = scenegraph.component.showResizeRow.bind(scenegraph.component);
268
+ originalShowResizeRow && (scenegraph.component.showResizeRow = (row, x, isRightFrozen) => this.protectedShowResizeRow(originalShowResizeRow, row, x, isRightFrozen));
269
+ const originalUpdateResizeRow = null === (_a = scenegraph.component.updateResizeRow) || void 0 === _a ? void 0 : _a.bind(scenegraph.component);
270
+ originalUpdateResizeRow && (scenegraph.component.updateResizeRow = (row, x, isBottomFrozen) => this.protectedUpdateResizeRow(originalUpdateResizeRow, row, x, isBottomFrozen));
271
+ }
272
+ }
273
+ extendUpdateRowHeight() {
274
+ const scenegraph = this.table.scenegraph;
275
+ this.originalUpdateRowHeight = scenegraph.updateRowHeight.bind(scenegraph), scenegraph.updateRowHeight = (row, detaY, skipTableHeightMap) => {
276
+ if (!this.eventManager.isRowExpanded(row) || !this.isDragging || this.dragStartIsPluginUnderline) return this.originalUpdateRowHeight(row, detaY, skipTableHeightMap);
277
+ detaY = Math.round(detaY), this.callbacks.updateRowHeightForExpand(row, detaY),
278
+ scenegraph.updateContainerHeight(row, detaY);
279
+ };
280
+ }
281
+ extendGetResizeColAt() {
282
+ const scenegraph = this.table.scenegraph;
283
+ this.originalGetResizeColAt = scenegraph.getResizeColAt.bind(scenegraph), scenegraph.getResizeColAt = (abstractX, abstractY, cellGroup) => {
284
+ if (!cellGroup) {
285
+ const cell = this.table.getCellAtRelativePosition(abstractX, abstractY);
286
+ if (cell && cell.row >= 0) {
287
+ if (this.eventManager.isRowExpanded(cell.row)) return {
288
+ col: -1,
289
+ row: -1
290
+ };
291
+ }
292
+ }
293
+ return this.originalGetResizeColAt(abstractX, abstractY, cellGroup);
294
+ };
295
+ }
296
+ isMouseInPluginUnderlineArea(row) {
297
+ var _a, _b, _c, _d;
298
+ try {
299
+ const scrollTop = (null === (_b = null === (_a = this.table.stateManager) || void 0 === _a ? void 0 : _a.scroll) || void 0 === _b ? void 0 : _b.verticalBarPos) || 0, rowY = this.table.getRowsHeight(0, row - 1), rowHeight = this.table.getRowHeight(row), viewportRowBottomY = rowY + rowHeight - scrollTop + ((null === (_d = null === (_c = this.table.theme) || void 0 === _c ? void 0 : _c.frameStyle) || void 0 === _d ? void 0 : _d.shadowBlur) || 0), isNearRowBottom = this.currentMouseY >= viewportRowBottomY - (this.table.internalProps.limitMinHeight - 1) && this.currentMouseY <= viewportRowBottomY + (this.table.internalProps.limitMinHeight - 1), isExpandedRow = this.eventManager.isRowExpanded(row);
300
+ return !(isNearRowBottom && isExpandedRow);
301
+ } catch (error) {
302
+ return !1;
303
+ }
304
+ }
305
+ protectedShowResizeRow(originalMethod, row, x, isRightFrozen) {
306
+ if (this.isDragging || (this.isDragging = !0, this.dragStartIsPluginUnderline = this.isMouseInPluginUnderlineArea(row)),
307
+ this.dragStartIsPluginUnderline) {
308
+ const originalGetRowsHeight = this.table.getRowsHeight.bind(this.table);
309
+ this.table.getRowsHeight = (startRow, endRow) => this.getRowsHeightWithOriginalHeight(startRow, endRow);
310
+ const originalGetRowHeight = this.table.getRowHeight.bind(this.table);
311
+ this.table.getRowHeight = targetRow => {
312
+ if (targetRow === row && this.eventManager.isRowExpanded(targetRow)) {
313
+ const bodyRowIndex = targetRow - this.table.columnHeaderLevelCount, originalHeight = (0,
314
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
315
+ return originalHeight > 0 ? originalHeight : originalGetRowHeight(targetRow);
316
+ }
317
+ return originalGetRowHeight(targetRow);
318
+ };
319
+ try {
320
+ return originalMethod(row, x, isRightFrozen);
321
+ } finally {
322
+ this.table.getRowsHeight = originalGetRowsHeight, this.table.getRowHeight = originalGetRowHeight;
323
+ }
324
+ } else {
325
+ const originalGetRowHeight = this.table.getRowHeight.bind(this.table);
326
+ this.table.getRowHeight = targetRow => {
327
+ if (targetRow === row && this.eventManager.isRowExpanded(targetRow)) {
328
+ const bodyRowIndex = targetRow - this.table.columnHeaderLevelCount, originalHeight = (0,
329
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
330
+ return originalGetRowHeight(targetRow) - originalHeight;
331
+ }
332
+ return originalGetRowHeight(targetRow);
333
+ };
334
+ try {
335
+ return originalMethod(row, x, isRightFrozen);
336
+ } finally {
337
+ this.table.getRowHeight = originalGetRowHeight;
338
+ }
339
+ }
340
+ }
341
+ protectedUpdateResizeRow(originalMethod, row, x, isBottomFrozen) {
342
+ if (this.dragStartIsPluginUnderline) {
343
+ const originalGetRowsHeight = this.table.getRowsHeight.bind(this.table);
344
+ this.table.getRowsHeight = (startRow, endRow) => this.getRowsHeightWithOriginalHeight(startRow, endRow);
345
+ const originalGetRowHeight = this.table.getRowHeight.bind(this.table);
346
+ this.table.getRowHeight = targetRow => {
347
+ if (targetRow === row && this.eventManager.isRowExpanded(targetRow)) {
348
+ const bodyRowIndex = targetRow - this.table.columnHeaderLevelCount, originalHeight = (0,
349
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
350
+ return originalHeight > 0 ? originalHeight : originalGetRowHeight(targetRow);
351
+ }
352
+ return originalGetRowHeight(targetRow);
353
+ };
354
+ try {
355
+ return originalMethod(row, x, isBottomFrozen);
356
+ } finally {
357
+ this.table.getRowsHeight = originalGetRowsHeight, this.table.getRowHeight = originalGetRowHeight;
358
+ }
359
+ } else {
360
+ const originalGetRowHeight = this.table.getRowHeight.bind(this.table);
361
+ this.table.getRowHeight = targetRow => {
362
+ if (targetRow === row && this.eventManager.isRowExpanded(targetRow)) {
363
+ const bodyRowIndex = targetRow - this.table.columnHeaderLevelCount, originalHeight = (0,
364
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
365
+ return originalGetRowHeight(targetRow) - originalHeight;
366
+ }
367
+ return originalGetRowHeight(targetRow);
368
+ };
369
+ try {
370
+ return originalMethod(row, x, isBottomFrozen);
371
+ } finally {
372
+ this.table.getRowHeight = originalGetRowHeight;
373
+ }
374
+ }
375
+ }
376
+ getRowsHeightWithOriginalHeight(startRow, endRow) {
377
+ let totalHeight = 0;
378
+ for (let row = startRow; row <= endRow; row++) {
379
+ if (this.eventManager.isRowExpanded(row) && row === endRow) {
380
+ const bodyRowIndex = row - this.table.columnHeaderLevelCount, originalHeight = (0,
381
+ utils_1.getOriginalRowHeight)(this.table, bodyRowIndex);
382
+ totalHeight += originalHeight > 0 ? originalHeight : this.table.getRowHeight(row);
383
+ } else totalHeight += this.table.getRowHeight(row);
384
+ }
385
+ return totalHeight;
386
+ }
387
+ waitForRenderComplete(callback) {
388
+ const onAfterRender = () => {
389
+ this.table.off(vtable_1.TABLE_EVENT_TYPE.AFTER_RENDER, onAfterRender), callback();
390
+ };
391
+ this.table.on(vtable_1.TABLE_EVENT_TYPE.AFTER_RENDER, onAfterRender);
392
+ }
393
+ cleanup() {
394
+ if (this.mouseEventListener) {
395
+ try {
396
+ const table = this.table;
397
+ if (table && table.internalProps && table.internalProps.canvas) {
398
+ const canvas = table.internalProps.canvas;
399
+ canvas.removeEventListener("mousemove", this.mouseEventListener), canvas.removeEventListener("mousedown", this.mouseEventListener),
400
+ canvas.removeEventListener("mouseup", this.mouseEventListener);
401
+ }
402
+ } catch (error) {}
403
+ this.mouseEventListener = void 0;
404
+ }
405
+ if (this.originalUpdateCellContent && this.table) {
406
+ const table = this.table;
407
+ table.scenegraph && table.scenegraph.updateCellContent && (table.scenegraph.updateCellContent = this.originalUpdateCellContent),
408
+ this.originalUpdateCellContent = void 0;
409
+ }
410
+ if (this.originalUpdateResizeRow && this.table) {
411
+ const table = this.table;
412
+ table.stateManager && table.stateManager.updateResizeRow && (table.stateManager.updateResizeRow = this.originalUpdateResizeRow),
413
+ this.originalUpdateResizeRow = void 0;
414
+ }
415
+ if (this.originalDealHeightMode && this.table) {
416
+ const table = this.table;
417
+ table.scenegraph && table.scenegraph.dealHeightMode && (table.scenegraph.dealHeightMode = this.originalDealHeightMode),
418
+ this.originalDealHeightMode = void 0;
419
+ }
420
+ if (this.originalUpdatePagination && this.table) {
421
+ const table = this.table;
422
+ table.updatePagination && (table.updatePagination = this.originalUpdatePagination),
423
+ this.originalUpdatePagination = void 0;
424
+ }
425
+ if (this.originalToggleHierarchyState && this.table) {
426
+ const table = this.table;
427
+ table.toggleHierarchyState && (table.toggleHierarchyState = this.originalToggleHierarchyState),
428
+ this.originalToggleHierarchyState = void 0;
429
+ }
430
+ if (this.originalUpdateFilterRules && this.table) {
431
+ const table = this.table;
432
+ table.updateFilterRules && (table.updateFilterRules = this.originalUpdateFilterRules),
433
+ this.originalUpdateFilterRules = void 0;
434
+ }
435
+ if (this.originalUpdateChartSizeForResizeColWidth && this.table) {
436
+ const table = this.table;
437
+ table.scenegraph && table.scenegraph.updateChartSizeForResizeColWidth && (table.scenegraph.updateChartSizeForResizeColWidth = this.originalUpdateChartSizeForResizeColWidth),
438
+ this.originalUpdateChartSizeForResizeColWidth = void 0;
439
+ }
440
+ if (this.originalUpdateChartSizeForResizeRowHeight && this.table) {
441
+ const table = this.table;
442
+ table.scenegraph && table.scenegraph.updateChartSizeForResizeRowHeight && (table.scenegraph.updateChartSizeForResizeRowHeight = this.originalUpdateChartSizeForResizeRowHeight),
443
+ this.originalUpdateChartSizeForResizeRowHeight = void 0;
444
+ }
445
+ if (this.originalUpdateRowHeight && this.table) {
446
+ const table = this.table;
447
+ table.scenegraph && table.scenegraph.updateRowHeight && (table.scenegraph.updateRowHeight = this.originalUpdateRowHeight),
448
+ this.originalUpdateRowHeight = void 0;
449
+ }
450
+ if (this.originalGetResizeColAt && this.table) {
451
+ const scenegraph = this.table.scenegraph;
452
+ scenegraph && scenegraph.getResizeColAt && (scenegraph.getResizeColAt = this.originalGetResizeColAt),
453
+ this.originalGetResizeColAt = void 0;
454
+ }
455
+ this.isDragging = !1, this.dragStartIsPluginUnderline = !1, this.currentMouseX = 0,
456
+ this.currentMouseY = 0, this.callbacks = null, this.table = null, this.configManager = null,
457
+ this.eventManager = null;
458
+ }
459
+ }
460
+
461
+ exports.TableAPIExtensions = TableAPIExtensions;
462
+ //# sourceMappingURL=table-api-extensions.js.map