@visactor/vtable 0.14.1 → 0.14.2-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.
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.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/scenegraph/component/custom.d.ts +1 -0
- package/cjs/scenegraph/component/custom.js +3 -2
- package/cjs/scenegraph/component/custom.js.map +1 -1
- package/cjs/scenegraph/group-creater/column-helper.js +1 -1
- package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/proxy.js +3 -1
- package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +6 -2
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js +3 -2
- package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
- package/cjs/scenegraph/layout/compute-row-height.js +3 -2
- package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
- package/cjs/scenegraph/layout/update-row.js +31 -12
- package/cjs/scenegraph/layout/update-row.js.map +1 -1
- package/cjs/scenegraph/scenegraph.js +1 -1
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/scenegraph/select/update-select-border.js +2 -2
- package/cjs/scenegraph/select/update-select-border.js.map +1 -1
- package/cjs/themes/DARK.js +2 -1
- package/cjs/themes/DEFAULT.js +1 -2
- package/cjs/ts-types/base-table.d.ts +2 -0
- package/cjs/ts-types/base-table.js.map +1 -1
- package/dist/vtable.js +66 -22
- package/dist/vtable.min.js +2 -2
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.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/scenegraph/component/custom.d.ts +1 -0
- package/es/scenegraph/component/custom.js +1 -1
- package/es/scenegraph/component/custom.js.map +1 -1
- package/es/scenegraph/group-creater/column-helper.js +1 -1
- package/es/scenegraph/group-creater/column-helper.js.map +1 -1
- package/es/scenegraph/group-creater/progress/proxy.js +3 -1
- package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +6 -2
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
- package/es/scenegraph/layout/compute-col-width.js +4 -3
- package/es/scenegraph/layout/compute-col-width.js.map +1 -1
- package/es/scenegraph/layout/compute-row-height.js +4 -3
- package/es/scenegraph/layout/compute-row-height.js.map +1 -1
- package/es/scenegraph/layout/update-row.js +32 -11
- package/es/scenegraph/layout/update-row.js.map +1 -1
- package/es/scenegraph/scenegraph.js +1 -1
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/scenegraph/select/update-select-border.js +2 -2
- package/es/scenegraph/select/update-select-border.js.map +1 -1
- package/es/themes/DARK.js +2 -1
- package/es/themes/DEFAULT.js +1 -2
- package/es/ts-types/base-table.d.ts +2 -0
- package/es/ts-types/base-table.js.map +1 -1
- package/package.json +3 -3
|
@@ -4,23 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.updateRow = void 0;
|
|
6
6
|
|
|
7
|
-
const group_1 = require("../graphic/group"), cell_helper_1 = require("../group-creater/cell-helper"), get_cell_merge_1 = require("../utils/get-cell-merge");
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), group_1 = require("../graphic/group"), cell_helper_1 = require("../group-creater/cell-helper"), get_cell_merge_1 = require("../utils/get-cell-merge");
|
|
8
8
|
|
|
9
9
|
function updateRow(removeCells, addCells, updateCells, table) {
|
|
10
|
-
const scene = table.scenegraph, removeRows = deduplication(removeCells.map((cell => cell.row))).sort(((a, b) =>
|
|
10
|
+
const scene = table.scenegraph, removeRows = deduplication(removeCells.map((cell => cell.row))).sort(((a, b) => b - a)), addRows = deduplication(addCells.map((cell => cell.row))).sort(((a, b) => a - b));
|
|
11
11
|
removeRows.forEach((row => {
|
|
12
12
|
removeRow(row, scene);
|
|
13
|
-
})), removeRows.
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
})), removeRows.forEach((row => {
|
|
14
|
+
scene.table.rowHeightsMap.adjustOrder(row + 1, row, scene.table.rowHeightsMap.count() - row - 1),
|
|
15
|
+
scene.table.rowHeightsMap.del(scene.table.rowHeightsMap.count() - 1);
|
|
16
|
+
})), removeRows.length && resetRowNumber(scene), scene.table._clearRowRangeHeightsMap(),
|
|
17
|
+
addRows.forEach((row => {
|
|
18
|
+
addRow(row, scene), scene.table.rowHeightsMap.adjustOrder(row, row + 1, scene.table.rowHeightsMap.count() - row);
|
|
19
|
+
}));
|
|
20
|
+
const newTotalHeight = resetRowNumberAndY(scene);
|
|
21
|
+
if (updateCells.forEach((cell => {
|
|
16
22
|
if (!cell) return;
|
|
17
23
|
const mergeInfo = (0, get_cell_merge_1.getCellMergeInfo)(scene.table, cell.col, cell.row);
|
|
18
24
|
if (mergeInfo) for (let col = mergeInfo.start.col; col <= mergeInfo.end.col; col++) for (let row = mergeInfo.start.row; row <= mergeInfo.end.row; row++) (0,
|
|
19
25
|
cell_helper_1.updateCell)(col, row, scene.table, !1); else (0, cell_helper_1.updateCell)(cell.col, cell.row, scene.table, !1);
|
|
20
|
-
}))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
})), addRows.length) {
|
|
27
|
+
const minRow = Math.min(...addRows);
|
|
28
|
+
scene.proxy.rowUpdatePos = minRow, scene.proxy.rowUpdateDirection = "up", scene.proxy.updateCellGroups(2 * scene.proxy.screenRowCount),
|
|
29
|
+
scene.proxy.progress();
|
|
30
|
+
} else removeRows.length && (scene.proxy.updateCellGroups(2 * scene.proxy.screenRowCount),
|
|
31
|
+
scene.proxy.progress());
|
|
24
32
|
scene.updateContainerHeight(scene.table.frozenRowCount, newTotalHeight - scene.bodyGroup.attribute.height);
|
|
25
33
|
}
|
|
26
34
|
|
|
@@ -30,9 +38,11 @@ function removeRow(row, scene) {
|
|
|
30
38
|
if (!colGroup) continue;
|
|
31
39
|
let cellGroup;
|
|
32
40
|
colGroup.forEachChildren((cell => cell.row === row && (cellGroup = cell, !0))),
|
|
33
|
-
cellGroup && colGroup.removeChild(cellGroup);
|
|
41
|
+
cellGroup && (colGroup.updateColumnHeight(-cellGroup.attribute.height), colGroup.removeChild(cellGroup));
|
|
34
42
|
}
|
|
35
|
-
scene.proxy.rowEnd
|
|
43
|
+
row <= scene.proxy.rowEnd && (scene.proxy.rowEnd--, scene.proxy.currentRow--), scene.proxy.bodyBottomRow--;
|
|
44
|
+
const totalActualBodyRowCount = Math.min(scene.proxy.rowLimit, scene.proxy.bodyBottomRow - scene.proxy.bodyTopRow + 1);
|
|
45
|
+
scene.proxy.totalActualBodyRowCount = totalActualBodyRowCount, scene.proxy.totalRow = scene.proxy.bodyTopRow + totalActualBodyRowCount - 1;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
function addRow(row, scene) {
|
|
@@ -53,7 +63,7 @@ function addRow(row, scene) {
|
|
|
53
63
|
cellBefore !== colGroup.lastChild && colGroup.lastChild && (colGroup.lastChild.row = colGroup.lastChild.row + 1));
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
|
-
scene.proxy.
|
|
66
|
+
scene.proxy.bodyBottomRow++, scene.proxy.totalRow++, scene.proxy.rowEnd++, scene.proxy.currentRow++;
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
function deduplication(array) {
|
|
@@ -69,9 +79,15 @@ function resetRowNumber(scene) {
|
|
|
69
79
|
if (!headerColGroup || !colGroup) continue;
|
|
70
80
|
let rowIndex = null === (_a = headerColGroup.firstChild) || void 0 === _a ? void 0 : _a.row;
|
|
71
81
|
headerColGroup.forEachChildren((cellGroup => {
|
|
82
|
+
const oldRow = cellGroup.row;
|
|
83
|
+
(0, vutils_1.isNumber)(cellGroup.mergeStartRow) && (cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex),
|
|
84
|
+
(0, vutils_1.isNumber)(cellGroup.mergeEndRow) && (cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex),
|
|
72
85
|
cellGroup.row = rowIndex, rowIndex++;
|
|
73
86
|
})), rowIndex = null === (_b = colGroup.firstChild) || void 0 === _b ? void 0 : _b.row,
|
|
74
87
|
colGroup.forEachChildren((cellGroup => {
|
|
88
|
+
const oldRow = cellGroup.row;
|
|
89
|
+
(0, vutils_1.isNumber)(cellGroup.mergeStartRow) && (cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex),
|
|
90
|
+
(0, vutils_1.isNumber)(cellGroup.mergeEndRow) && (cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex),
|
|
75
91
|
cellGroup.row = rowIndex, rowIndex++;
|
|
76
92
|
}));
|
|
77
93
|
}
|
|
@@ -87,6 +103,9 @@ function resetRowNumberAndY(scene) {
|
|
|
87
103
|
let rowIndex = null === (_a = headerColGroup.firstChild) || void 0 === _a ? void 0 : _a.row, y = 0;
|
|
88
104
|
rowIndex = null === (_b = colGroup.firstChild) || void 0 === _b ? void 0 : _b.row;
|
|
89
105
|
y = 0, colGroup.forEachChildren((cellGroup => {
|
|
106
|
+
const oldRow = cellGroup.row;
|
|
107
|
+
(0, vutils_1.isNumber)(cellGroup.mergeStartRow) && (cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex),
|
|
108
|
+
(0, vutils_1.isNumber)(cellGroup.mergeEndRow) && (cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex),
|
|
90
109
|
cellGroup.row = rowIndex, rowIndex++, "cell" === cellGroup.role && (cellGroup.setAttribute("y", y),
|
|
91
110
|
y += cellGroup.attribute.height);
|
|
92
111
|
})), newTotalHeight = y;
|
|
@@ -1 +1 @@
|
|
|
1
|
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CAAC;IAC1B,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE;QACnD,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,cAAc,IAAI,CAAC,QAAQ,EAAE;YAChC,SAAS;SACV;QAED,IAAI,QAAQ,GAAG,MAAC,cAAc,CAAC,UAAoB,0CAAE,GAAG,CAAC;QACzD,IAAI,CAAC,GAAG,CAAC,CAAC;QAUV,QAAQ,GAAG,MAAC,QAAQ,CAAC,UAAoB,0CAAE,GAAG,CAAC;QAC/C,MAAM,QAAQ,GAAG,QAAQ,CAAC;QAC1B,CAAC,GAAG,CAAC,CAAC;QACN,QAAQ,CAAC,eAAe,CAAC,CAAC,SAAgB,EAAE,EAAE;YAC5C,SAAS,CAAC,GAAG,GAAG,QAAQ,CAAC;YACzB,QAAQ,EAAE,CAAC;YACX,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE;gBAC7B,OAAO;aACR;YACD,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/B,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC;QAoBlC,CAAC,CAAC,CAAC;QACH,cAAc,GAAG,CAAC,CAAC;KAOpB;IACD,OAAO,cAAc,CAAC;AACxB,CAAC","file":"update-row.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender';\nimport type { CellAddress } from '../../ts-types';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport { Group } from '../graphic/group';\nimport { updateCell } from '../group-creater/cell-helper';\nimport type { Scenegraph } from '../scenegraph';\nimport { getCellMergeInfo } from '../utils/get-cell-merge';\nimport { isMergeCellGroup } from '../utils/is-merge-cell-group';\nimport { resizeCellGroup } from '../group-creater/column-helper';\n\n/**\n * add and remove rows in scenegraph\n */\nexport function updateRow(\n removeCells: CellAddress[],\n addCells: CellAddress[],\n updateCells: CellAddress[],\n table: BaseTableAPI\n) {\n const scene = table.scenegraph;\n // deduplication\n const removeRows = deduplication(removeCells.map(cell => cell.row)).sort((a, b) => a - b);\n const addRows = deduplication(addCells.map(cell => cell.row)).sort((a, b) => a - b);\n // const updateRows = deduplication(updateCells.map(cell => cell.row)).sort((a, b) => a - b);\n\n // remove cells\n removeRows.forEach(row => {\n removeRow(row, scene);\n });\n\n if (removeRows.length) {\n resetRowNumber(scene);\n }\n\n // add cells\n addRows.forEach(row => {\n addRow(row, scene);\n });\n\n // add cells\n updateCells.forEach(cell => {\n // updateRowAttr(row, scene);\n if (!cell) {\n return;\n }\n const mergeInfo = getCellMergeInfo(scene.table, cell.col, cell.row);\n if (mergeInfo) {\n for (let col = mergeInfo.start.col; col <= mergeInfo.end.col; col++) {\n for (let row = mergeInfo.start.row; row <= mergeInfo.end.row; row++) {\n updateCell(col, row, scene.table, false);\n }\n }\n } else {\n updateCell(cell.col, cell.row, scene.table, false);\n }\n });\n\n // reset attribute y and row number in CellGroup\n const newTotalHeight = resetRowNumberAndY(scene);\n\n if (addRows.length) {\n scene.proxy.rowUpdatePos = scene.proxy.rowStart;\n scene.proxy.rowUpdateDirection = 'up';\n scene.proxy.updateCellGroups(scene.proxy.screenRowCount * 2);\n scene.proxy.progress();\n }\n\n // update table size\n scene.updateContainerHeight(scene.table.frozenRowCount, newTotalHeight - scene.bodyGroup.attribute.height);\n}\n\nfunction removeRow(row: number, scene: Scenegraph) {\n for (let col = 0; col < scene.table.colCount; col++) {\n // const headerColGroup = scene.getColGroup(col, true);\n const colGroup = scene.getColGroup(col, false);\n if (!colGroup) {\n continue;\n }\n // // remove cellGroup in headerColGroup\n // let headerCellGroup;\n // headerColGroup.forEachChildren((cellGroup: Group) => {\n // if (cellGroup.row === row) {\n // headerCellGroup = cellGroup;\n // return true;\n // }\n // return false;\n // });\n // if (headerCellGroup) {\n // headerColGroup.removeChild(headerCellGroup);\n // }\n\n // remove cellGroup in colGroup\n let cellGroup;\n colGroup.forEachChildren((cell: Group) => {\n if (cell.row === row) {\n cellGroup = cell;\n return true;\n }\n return false;\n });\n if (cellGroup) {\n colGroup.removeChild(cellGroup);\n }\n }\n // TODO 需要整体更新proxy的状态\n scene.proxy.rowEnd--;\n scene.proxy.bodyBottomRow--;\n scene.proxy.currentRow--;\n scene.proxy.totalRow--;\n}\n\nfunction addRow(row: number, scene: Scenegraph) {\n for (let col = 0; col < scene.table.colCount; col++) {\n // create cellGroup\n // const cellGroup = updateCell(col, row, scene.table, true);\n const cellGroup = new Group({\n x: 0,\n y: 0,\n width: scene.table.getColWidth(col),\n height: scene.table.getRowHeight(row)\n });\n cellGroup.role = 'cell';\n cellGroup.col = col;\n cellGroup.row = row;\n cellGroup.needUpdate = true;\n\n if (!cellGroup) {\n // TODO: deal with data promise situation\n continue;\n }\n\n // insert cellGroup in colGroup\n const colGroup = scene.getColGroup(col);\n if (!colGroup) {\n continue;\n }\n\n if (colGroup.firstChild && row < (colGroup.firstChild as Group).row) {\n colGroup.insertBefore(cellGroup, colGroup.firstChild);\n (colGroup.firstChild as Group).row = (colGroup.firstChild as Group).row + 1;\n } else if (colGroup.lastChild && row > (colGroup.lastChild as Group).row) {\n colGroup.appendChild(cellGroup);\n } else {\n // let cellBefore: Group;\n // colGroup.forEachChildren((cellGroup: Group) => {\n // if (cellGroup.row === row) {\n // cellBefore = cellGroup;\n // return true;\n // }\n // return false;\n // });\n\n const cellBefore = scene.highPerformanceGetCell(col, row, true);\n if (cellBefore !== cellGroup) {\n colGroup.insertBefore(cellGroup, cellBefore);\n cellBefore && (cellBefore.row = cellBefore.row + 1);\n if (cellBefore !== colGroup.lastChild) {\n colGroup.lastChild && ((colGroup.lastChild as Group).row = (colGroup.lastChild as Group).row + 1);\n }\n }\n }\n\n // // reset row number\n // let rowIndex = (colGroup.firstChild as Group)?.row;\n // colGroup.forEachChildren((cellGroup: Group) => {\n // cellGroup.row = rowIndex;\n // rowIndex++;\n // });\n }\n // TODO 需要整体更新proxy的状态\n scene.proxy.rowEnd++;\n scene.proxy.bodyBottomRow++;\n scene.proxy.currentRow++;\n scene.proxy.totalRow++;\n}\n\n// array deduplication\nfunction deduplication(array: number[]) {\n const result = [];\n for (let i = 0; i < array.length; i++) {\n if (result.indexOf(array[i]) === -1) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\nfunction resetRowNumber(scene: Scenegraph) {\n for (let col = 0; col < scene.table.colCount; col++) {\n const headerColGroup = scene.getColGroup(col, true);\n const colGroup = scene.getColGroup(col, false);\n if (!headerColGroup || !colGroup) {\n continue;\n }\n // reset row number\n let rowIndex = (headerColGroup.firstChild as Group)?.row;\n headerColGroup.forEachChildren((cellGroup: Group) => {\n cellGroup.row = rowIndex;\n rowIndex++;\n });\n rowIndex = (colGroup.firstChild as Group)?.row;\n colGroup.forEachChildren((cellGroup: Group) => {\n cellGroup.row = rowIndex;\n rowIndex++;\n });\n }\n}\n\nfunction resetRowNumberAndY(scene: Scenegraph) {\n const table = scene.table;\n let newTotalHeight = 0;\n for (let col = 0; col < scene.table.colCount; col++) {\n const headerColGroup = scene.getColGroup(col, true);\n const colGroup = scene.getColGroup(col, false);\n if (!headerColGroup || !colGroup) {\n continue;\n }\n // reset row number\n let rowIndex = (headerColGroup.firstChild as Group)?.row;\n let y = 0;\n // headerColGroup.forEachChildren((cellGroup: Group) => {\n // cellGroup.row = rowIndex;\n // rowIndex++;\n // if (cellGroup.role !== 'cell') {\n // return;\n // }\n // cellGroup.setAttribute('y', y);\n // y+= cellGroup.attribute.height;\n // });\n rowIndex = (colGroup.firstChild as Group)?.row;\n const rowStart = rowIndex;\n y = 0;\n colGroup.forEachChildren((cellGroup: Group) => {\n cellGroup.row = rowIndex;\n rowIndex++;\n if (cellGroup.role !== 'cell') {\n return;\n }\n cellGroup.setAttribute('y', y);\n y += cellGroup.attribute.height;\n\n // const { col, row } = cellGroup;\n // const mergeInfo = getCellMergeInfo(table, col, row);\n // if (mergeInfo) {\n // cellGroup.mergeStartCol = mergeInfo.start.col;\n // cellGroup.mergeStartRow = mergeInfo.start.row;\n // cellGroup.mergeEndCol = mergeInfo.end.col;\n // cellGroup.mergeEndRow = mergeInfo.end.row;\n\n // const rangeHeight = table.getRowHeight(row);\n // const rangeWidth = table.getColWidth(col);\n // cellGroup.forEachChildren((child: IGraphic) => {\n // child.setAttributes({\n // dx: 0,\n // dy: 0\n // });\n // });\n // resizeCellGroup(cellGroup, rangeWidth, rangeHeight, mergeInfo, table);\n // }\n });\n newTotalHeight = y;\n\n // const rowCount = rowIndex - rowStart;\n // if (col === 0 && scene.proxy.rowEnd - scene.proxy.rowStart + 1 !== rowCount) {\n // scene.proxy.rowEnd = scene.proxy.rowStart + rowCount - 1;\n // scene.proxy.referenceRow = scene.proxy.rowStart + Math.floor((scene.proxy.rowEnd - scene.proxy.rowStart) / 2);\n // }\n }\n return newTotalHeight;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["scenegraph/layout/update-row.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG5C,4CAAyC;AACzC,8DAA0D;AAE1D,4DAA2D;AAK3D,SAAgB,SAAS,CACvB,WAA0B,EAC1B,QAAuB,EACvB,WAA0B,EAC1B,KAAmB;IAEnB,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;IAE/B,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1F,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,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aACnE;YACD,SAAS,CAAC,GAAG,GAAG,QAAQ,CAAC;YACzB,QAAQ,EAAE,CAAC;YACX,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE;gBAC7B,OAAO;aACR;YACD,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/B,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC;QAoBlC,CAAC,CAAC,CAAC;QACH,cAAc,GAAG,CAAC,CAAC;KAOpB;IACD,OAAO,cAAc,CAAC;AACxB,CAAC","file":"update-row.js","sourcesContent":["import { isNumber } from '@visactor/vutils';\nimport type { CellAddress } from '../../ts-types';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport { Group } from '../graphic/group';\nimport { updateCell } from '../group-creater/cell-helper';\nimport type { Scenegraph } from '../scenegraph';\nimport { getCellMergeInfo } from '../utils/get-cell-merge';\n\n/**\n * add and remove rows in scenegraph\n */\nexport function updateRow(\n removeCells: CellAddress[],\n addCells: CellAddress[],\n updateCells: CellAddress[],\n table: BaseTableAPI\n) {\n const scene = table.scenegraph;\n // deduplication\n const removeRows = deduplication(removeCells.map(cell => cell.row)).sort((a, b) => b - a);\n const addRows = deduplication(addCells.map(cell => cell.row)).sort((a, b) => a - b);\n // const updateRows = deduplication(updateCells.map(cell => cell.row)).sort((a, b) => a - b);\n\n // remove cells\n removeRows.forEach(row => {\n removeRow(row, scene);\n });\n\n removeRows.forEach(row => {\n scene.table.rowHeightsMap.adjustOrder(row + 1, row, scene.table.rowHeightsMap.count() - row - 1);\n scene.table.rowHeightsMap.del(scene.table.rowHeightsMap.count() - 1);\n });\n\n if (removeRows.length) {\n resetRowNumber(scene);\n }\n\n scene.table._clearRowRangeHeightsMap();\n\n // add cells\n addRows.forEach(row => {\n addRow(row, scene);\n scene.table.rowHeightsMap.adjustOrder(row, row + 1, scene.table.rowHeightsMap.count() - row);\n });\n\n // reset attribute y and row number in CellGroup\n const newTotalHeight = resetRowNumberAndY(scene);\n\n // add cells\n updateCells.forEach(cell => {\n // updateRowAttr(row, scene);\n if (!cell) {\n return;\n }\n const mergeInfo = getCellMergeInfo(scene.table, cell.col, cell.row);\n if (mergeInfo) {\n for (let col = mergeInfo.start.col; col <= mergeInfo.end.col; col++) {\n for (let row = mergeInfo.start.row; row <= mergeInfo.end.row; row++) {\n updateCell(col, row, scene.table, false);\n }\n }\n } else {\n updateCell(cell.col, cell.row, scene.table, false);\n }\n });\n if (addRows.length) {\n const minRow = Math.min(...addRows);\n scene.proxy.rowUpdatePos = minRow;\n scene.proxy.rowUpdateDirection = 'up';\n scene.proxy.updateCellGroups(scene.proxy.screenRowCount * 2);\n scene.proxy.progress();\n } else if (removeRows.length) {\n scene.proxy.updateCellGroups(scene.proxy.screenRowCount * 2);\n scene.proxy.progress();\n }\n\n // update table size\n scene.updateContainerHeight(scene.table.frozenRowCount, newTotalHeight - scene.bodyGroup.attribute.height);\n}\n\nfunction removeRow(row: number, scene: Scenegraph) {\n for (let col = 0; col < scene.table.colCount; col++) {\n // const headerColGroup = scene.getColGroup(col, true);\n const colGroup = scene.getColGroup(col, false);\n if (!colGroup) {\n continue;\n }\n // // remove cellGroup in headerColGroup\n // let headerCellGroup;\n // headerColGroup.forEachChildren((cellGroup: Group) => {\n // if (cellGroup.row === row) {\n // headerCellGroup = cellGroup;\n // return true;\n // }\n // return false;\n // });\n // if (headerCellGroup) {\n // headerColGroup.removeChild(headerCellGroup);\n // }\n\n // remove cellGroup in colGroup\n let cellGroup;\n colGroup.forEachChildren((cell: Group) => {\n if (cell.row === row) {\n cellGroup = cell;\n return true;\n }\n return false;\n });\n if (cellGroup) {\n colGroup.updateColumnHeight(-(cellGroup as Group).attribute.height);\n colGroup.removeChild(cellGroup);\n }\n }\n\n // TODO 需要整体更新proxy的状态\n if (row <= scene.proxy.rowEnd) {\n scene.proxy.rowEnd--;\n scene.proxy.currentRow--;\n }\n scene.proxy.bodyBottomRow--;\n // scene.proxy.totalRow--;\n const totalActualBodyRowCount = Math.min(\n scene.proxy.rowLimit,\n scene.proxy.bodyBottomRow - scene.proxy.bodyTopRow + 1\n ); // 渐进加载总row数量\n scene.proxy.totalActualBodyRowCount = totalActualBodyRowCount;\n scene.proxy.totalRow = scene.proxy.bodyTopRow + totalActualBodyRowCount - 1; // 目标渐进完成的row\n}\n\nfunction addRow(row: number, scene: Scenegraph) {\n for (let col = 0; col < scene.table.colCount; col++) {\n // create cellGroup\n // const cellGroup = updateCell(col, row, scene.table, true);\n const cellGroup = new Group({\n x: 0,\n y: 0,\n width: scene.table.getColWidth(col),\n height: scene.table.getRowHeight(row)\n });\n cellGroup.role = 'cell';\n cellGroup.col = col;\n cellGroup.row = row;\n cellGroup.needUpdate = true;\n\n if (!cellGroup) {\n // TODO: deal with data promise situation\n continue;\n }\n\n // insert cellGroup in colGroup\n const colGroup = scene.getColGroup(col);\n if (!colGroup) {\n continue;\n }\n\n if (colGroup.firstChild && row < (colGroup.firstChild as Group).row) {\n colGroup.insertBefore(cellGroup, colGroup.firstChild);\n (colGroup.firstChild as Group).row = (colGroup.firstChild as Group).row + 1;\n } else if (colGroup.lastChild && row > (colGroup.lastChild as Group).row) {\n colGroup.appendChild(cellGroup);\n } else {\n // let cellBefore: Group;\n // colGroup.forEachChildren((cellGroup: Group) => {\n // if (cellGroup.row === row) {\n // cellBefore = cellGroup;\n // return true;\n // }\n // return false;\n // });\n\n const cellBefore = scene.highPerformanceGetCell(col, row, true);\n if (cellBefore !== cellGroup) {\n colGroup.insertBefore(cellGroup, cellBefore);\n cellBefore && (cellBefore.row = cellBefore.row + 1);\n if (cellBefore !== colGroup.lastChild) {\n colGroup.lastChild && ((colGroup.lastChild as Group).row = (colGroup.lastChild as Group).row + 1);\n }\n }\n }\n\n // // reset row number\n // let rowIndex = (colGroup.firstChild as Group)?.row;\n // colGroup.forEachChildren((cellGroup: Group) => {\n // cellGroup.row = rowIndex;\n // rowIndex++;\n // });\n }\n // TODO 需要整体更新proxy的状态\n scene.proxy.bodyBottomRow++;\n scene.proxy.totalRow++;\n scene.proxy.rowEnd++;\n scene.proxy.currentRow++;\n}\n\n// array deduplication\nfunction deduplication(array: number[]) {\n const result = [];\n for (let i = 0; i < array.length; i++) {\n if (result.indexOf(array[i]) === -1) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\nfunction resetRowNumber(scene: Scenegraph) {\n for (let col = 0; col < scene.table.colCount; col++) {\n const headerColGroup = scene.getColGroup(col, true);\n const colGroup = scene.getColGroup(col, false);\n if (!headerColGroup || !colGroup) {\n continue;\n }\n // reset row number\n let rowIndex = (headerColGroup.firstChild as Group)?.row;\n headerColGroup.forEachChildren((cellGroup: Group) => {\n const oldRow = cellGroup.row;\n if (isNumber(cellGroup.mergeStartRow)) {\n cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex;\n }\n if (isNumber(cellGroup.mergeEndRow)) {\n cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex;\n }\n cellGroup.row = rowIndex;\n rowIndex++;\n });\n rowIndex = (colGroup.firstChild as Group)?.row;\n colGroup.forEachChildren((cellGroup: Group) => {\n const oldRow = cellGroup.row;\n if (isNumber(cellGroup.mergeStartRow)) {\n cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex;\n }\n if (isNumber(cellGroup.mergeEndRow)) {\n cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex;\n }\n cellGroup.row = rowIndex;\n rowIndex++;\n });\n }\n}\n\nfunction resetRowNumberAndY(scene: Scenegraph) {\n const table = scene.table;\n let newTotalHeight = 0;\n for (let col = 0; col < scene.table.colCount; col++) {\n const headerColGroup = scene.getColGroup(col, true);\n const colGroup = scene.getColGroup(col, false);\n if (!headerColGroup || !colGroup) {\n continue;\n }\n // reset row number\n let rowIndex = (headerColGroup.firstChild as Group)?.row;\n let y = 0;\n // headerColGroup.forEachChildren((cellGroup: Group) => {\n // cellGroup.row = rowIndex;\n // rowIndex++;\n // if (cellGroup.role !== 'cell') {\n // return;\n // }\n // cellGroup.setAttribute('y', y);\n // y+= cellGroup.attribute.height;\n // });\n rowIndex = (colGroup.firstChild as Group)?.row;\n const rowStart = rowIndex;\n y = 0;\n colGroup.forEachChildren((cellGroup: Group) => {\n const oldRow = cellGroup.row;\n if (isNumber(cellGroup.mergeStartRow)) {\n cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex;\n }\n if (isNumber(cellGroup.mergeEndRow)) {\n cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex;\n }\n cellGroup.row = rowIndex;\n rowIndex++;\n if (cellGroup.role !== 'cell') {\n return;\n }\n cellGroup.setAttribute('y', y);\n y += cellGroup.attribute.height;\n\n // const { col, row } = cellGroup;\n // const mergeInfo = getCellMergeInfo(table, col, row);\n // if (mergeInfo) {\n // cellGroup.mergeStartCol = mergeInfo.start.col;\n // cellGroup.mergeStartRow = mergeInfo.start.row;\n // cellGroup.mergeEndCol = mergeInfo.end.col;\n // cellGroup.mergeEndRow = mergeInfo.end.row;\n\n // const rangeHeight = table.getRowHeight(row);\n // const rangeWidth = table.getColWidth(col);\n // cellGroup.forEachChildren((child: IGraphic) => {\n // child.setAttributes({\n // dx: 0,\n // dy: 0\n // });\n // });\n // resizeCellGroup(cellGroup, rangeWidth, rangeHeight, mergeInfo, table);\n // }\n });\n newTotalHeight = y;\n\n // const rowCount = rowIndex - rowStart;\n // if (col === 0 && scene.proxy.rowEnd - scene.proxy.rowStart + 1 !== rowCount) {\n // scene.proxy.rowEnd = scene.proxy.rowStart + rowCount - 1;\n // scene.proxy.referenceRow = scene.proxy.rowStart + Math.floor((scene.proxy.rowEnd - scene.proxy.rowStart) / 2);\n // }\n }\n return newTotalHeight;\n}\n"]}
|
|
@@ -640,7 +640,7 @@ class Scenegraph {
|
|
|
640
640
|
updateRow(removeCells, addCells, updateCells = []) {
|
|
641
641
|
(0, update_row_1.updateRow)(removeCells, addCells, updateCells, this.table), this.recalculateColWidths(),
|
|
642
642
|
this.recalculateRowHeights(), this.table.stateManeger.checkFrozen(), this.isPivot || this.transpose || this.component.setFrozenColumnShadow(this.table.frozenColCount - 1),
|
|
643
|
-
this.updateNextFrame();
|
|
643
|
+
this.component.updateScrollBar(), this.updateNextFrame();
|
|
644
644
|
}
|
|
645
645
|
getColumnGroupX(col) {
|
|
646
646
|
return col < this.table.rowHeaderLevelCount ? this.table.getColsWidth(0, col - 1) : col < this.table.colCount - this.table.rightFrozenColCount ? this.table.getColsWidth(this.table.rowHeaderLevelCount, col - 1) : col < this.table.colCount ? this.table.getColsWidth(this.table.colCount - this.table.bottomFrozenRowCount, col - 1) : 0;
|