tomtaw-vxe-table 3.25.19 → 3.25.21

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 (43) hide show
  1. package/es/colgroup/index.d.ts +2 -0
  2. package/es/column/index.d.ts +2 -0
  3. package/es/grid/index.d.ts +2 -0
  4. package/es/grid/src/grid.d.ts +1 -0
  5. package/es/table/src/body.js +84 -36
  6. package/es/table/src/column.d.ts +2 -0
  7. package/es/table/src/column.js +2 -0
  8. package/es/table/src/columnInfo.js +1 -0
  9. package/es/table/src/group.d.ts +1 -0
  10. package/es/table/src/header.d.ts +3 -1
  11. package/es/table/src/header.js +49 -12
  12. package/es/table/src/methods.js +142 -79
  13. package/es/table/src/table.js +6 -15
  14. package/es/table/src/util.d.ts +3 -1
  15. package/es/table/src/util.js +30 -14
  16. package/es/ui/index.js +1 -1
  17. package/es/ui/src/log.js +1 -1
  18. package/lib/index.umd.js +315 -164
  19. package/lib/index.umd.min.js +3 -3
  20. package/lib/table/src/body.js +84 -36
  21. package/lib/table/src/column.js +2 -0
  22. package/lib/table/src/columnInfo.js +1 -0
  23. package/lib/table/src/header.js +48 -11
  24. package/lib/table/src/methods.js +147 -86
  25. package/lib/table/src/table.js +6 -15
  26. package/lib/table/src/util.js +30 -14
  27. package/lib/ui/index.js +1 -1
  28. package/lib/ui/src/log.js +1 -1
  29. package/package.json +1 -1
  30. package/packages/table/src/body.ts +71 -35
  31. package/packages/table/src/column.ts +2 -0
  32. package/packages/table/src/columnInfo.ts +1 -0
  33. package/packages/table/src/header.ts +53 -13
  34. package/packages/table/src/methods.ts +176 -79
  35. package/packages/table/src/table.ts +10 -18
  36. package/packages/table/src/util.ts +32 -15
  37. package/types/all.d.ts +23 -1
  38. /package/es/{iconfont.1795571985819.ttf → iconfont.1795761876277.ttf} +0 -0
  39. /package/es/{iconfont.1795571985819.woff → iconfont.1795761876277.woff} +0 -0
  40. /package/es/{iconfont.1795571985819.woff2 → iconfont.1795761876277.woff2} +0 -0
  41. /package/lib/{iconfont.1795571985819.ttf → iconfont.1795761876277.ttf} +0 -0
  42. /package/lib/{iconfont.1795571985819.woff → iconfont.1795761876277.woff} +0 -0
  43. /package/lib/{iconfont.1795571985819.woff2 → iconfont.1795761876277.woff2} +0 -0
@@ -26,6 +26,8 @@ import {
26
26
  createHandleGetRowId,
27
27
  getRefElem,
28
28
  getCellRestHeight,
29
+ getUniformRowHeight,
30
+ maxYHeight,
29
31
  getLastChildColumn,
30
32
  getRowMaxHeight,
31
33
  handleCustomStoreConfig,
@@ -47,9 +49,9 @@ function isTableDestroyed($xeTable) {
47
49
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent, globalEvents, GLOBAL_EVENT_KEYS } = VxeUI;
48
50
  const supportMaxRow = 5e6;
49
51
  const customStorageKey = "VXE_CUSTOM_STORE";
50
- const maxYHeight = 5e6;
51
52
  const maxXWidth = 5e6;
52
53
  const sourceType = "table";
54
+ const filteredRowModels = /* @__PURE__ */ new WeakMap();
53
55
  const customStorageQueues = /* @__PURE__ */ new WeakMap();
54
56
  const pendingExpandOffsetUpdates = /* @__PURE__ */ new WeakMap();
55
57
  const expandHeightCaches = /* @__PURE__ */ new WeakMap();
@@ -747,7 +749,7 @@ function handleVirtualTreeToList($xeTable) {
747
749
  }
748
750
  return internalData.afterFullData;
749
751
  }
750
- function updateAfterFullData($xeTable) {
752
+ function updateAfterFullData($xeTable, reason) {
751
753
  const props = $xeTable;
752
754
  const reactData = $xeTable;
753
755
  const internalData = $xeTable;
@@ -765,6 +767,8 @@ function updateAfterFullData($xeTable) {
765
767
  const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple, chronological, isDeep: isSortDeep } = sortOpts;
766
768
  let tableData = [];
767
769
  let tableTree = [];
770
+ const previousFilter = reason === "sort" ? filteredRowModels.get($xeTable) : void 0;
771
+ filteredRowModels.delete($xeTable);
768
772
  if (!allRemoteFilter || !allRemoteSort) {
769
773
  const filterColumns = [];
770
774
  let orderColumns = [];
@@ -827,7 +831,19 @@ function updateAfterFullData($xeTable) {
827
831
  });
828
832
  tableData = tableTree;
829
833
  } else {
830
- tableData = treeConfig ? tableFullTreeData.filter(handleFilter) : tableFullData.filter(handleFilter);
834
+ if (!treeConfig && filterOpts.cacheOnSort === true) {
835
+ const keys = [allFilterMethod, rendererOpts];
836
+ for (const { column, itemList } of filterColumns) {
837
+ keys.push(column, column.field, column.filterMethod, column.filterRender, itemList.length);
838
+ for (const item of itemList) keys.push(item, item.value, item.data);
839
+ }
840
+ const reuse = previousFilter && previousFilter.source === tableFullData && previousFilter.length === tableFullData.length && keys.length === previousFilter.keys.length && keys.every((value, index) => value === previousFilter.keys[index]);
841
+ const rows = reuse ? previousFilter.rows : tableFullData.filter(handleFilter);
842
+ filteredRowModels.set($xeTable, { source: tableFullData, length: tableFullData.length, keys, rows });
843
+ tableData = rows.slice();
844
+ } else {
845
+ tableData = treeConfig ? tableFullTreeData.filter(handleFilter) : tableFullData.filter(handleFilter);
846
+ }
831
847
  tableTree = tableData;
832
848
  }
833
849
  } else {
@@ -952,6 +968,18 @@ function updateAfterFullData($xeTable) {
952
968
  internalData.afterGroupFullData = tableTree;
953
969
  updateAfterDataIndex($xeTable);
954
970
  }
971
+ function syncReusedCurrentRows($xeTable, root, currentRow) {
972
+ const internalData = $xeTable;
973
+ const rowid = $xeTable.computeRowOpts.isCurrent || $xeTable.highlightCurrentRow ? getRowid($xeTable, currentRow) : null;
974
+ const marked = root.querySelectorAll(".row--current[rowid]");
975
+ for (let i = 0; i < marked.length; i++) {
976
+ if (marked[i].getAttribute("rowid") !== rowid) removeClass(marked[i], "row--current");
977
+ }
978
+ if (rowid !== null && internalData.visibleDataRowIdData[rowid]) {
979
+ const matches = root.querySelectorAll(`[rowid="${rowid}"]`);
980
+ for (let i = 0; i < matches.length; i++) addClass(matches[i], "row--current");
981
+ }
982
+ }
955
983
  function updateStyle($xeTable) {
956
984
  const props = $xeTable;
957
985
  const reactData = $xeTable;
@@ -1099,7 +1127,7 @@ function updateStyle($xeTable) {
1099
1127
  if (layout === "header") {
1100
1128
  let renderColumnList = tableColumn;
1101
1129
  const isOptimizeMode = isHeaderRenderOptimize;
1102
- if (isGroup) {
1130
+ if (isGroup && !isOptimizeMode) {
1103
1131
  renderColumnList = visibleColumn;
1104
1132
  } else {
1105
1133
  if (!isOptimizeMode || !isColLoading && (fixedType || !overflowX)) {
@@ -1112,22 +1140,9 @@ function updateStyle($xeTable) {
1112
1140
  }
1113
1141
  }
1114
1142
  const tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
1115
- if (fixedType) {
1116
- if (isGroup) {
1117
- if (wrapperElem) {
1118
- wrapperElem.style.width = scrollXWidth ? `${scrollXWidth}px` : "";
1119
- }
1120
- } else {
1121
- if (isOptimizeMode) {
1122
- if (wrapperElem) {
1123
- wrapperElem.style.width = tWidth ? `${tWidth}px` : "";
1124
- }
1125
- } else {
1126
- if (wrapperElem) {
1127
- wrapperElem.style.width = scrollXWidth ? `${scrollXWidth}px` : "";
1128
- }
1129
- }
1130
- }
1143
+ if (fixedType && wrapperElem) {
1144
+ const width = isOptimizeMode ? tWidth : scrollXWidth;
1145
+ wrapperElem.style.width = width ? `${width}px` : "";
1131
1146
  }
1132
1147
  if (currScrollElem) {
1133
1148
  currScrollElem.style.height = `${tHeaderHeight}px`;
@@ -1379,7 +1394,7 @@ function updateStyleWithDedupe($xeTable) {
1379
1394
  if (layout === "header") {
1380
1395
  let renderColumnList = tableColumn;
1381
1396
  const isOptimizeMode = isHeaderRenderOptimize;
1382
- if (isGroup) {
1397
+ if (isGroup && !isOptimizeMode) {
1383
1398
  renderColumnList = visibleColumn;
1384
1399
  } else {
1385
1400
  if (!isOptimizeMode || !isColLoading && (fixedType || !overflowX)) {
@@ -1392,22 +1407,9 @@ function updateStyleWithDedupe($xeTable) {
1392
1407
  }
1393
1408
  }
1394
1409
  const tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
1395
- if (fixedType) {
1396
- if (isGroup) {
1397
- if (wrapperElem) {
1398
- setLayoutStyle(wrapperElem, "width", scrollXWidth ? `${scrollXWidth}px` : "");
1399
- }
1400
- } else {
1401
- if (isOptimizeMode) {
1402
- if (wrapperElem) {
1403
- setLayoutStyle(wrapperElem, "width", tWidth ? `${tWidth}px` : "");
1404
- }
1405
- } else {
1406
- if (wrapperElem) {
1407
- setLayoutStyle(wrapperElem, "width", scrollXWidth ? `${scrollXWidth}px` : "");
1408
- }
1409
- }
1410
- }
1410
+ if (fixedType && wrapperElem) {
1411
+ const width = isOptimizeMode ? tWidth : scrollXWidth;
1412
+ setLayoutStyle(wrapperElem, "width", width ? `${width}px` : "");
1411
1413
  }
1412
1414
  if (currScrollElem) {
1413
1415
  setLayoutStyle(currScrollElem, "height", `${tHeaderHeight}px`);
@@ -1504,7 +1506,7 @@ function updateStyleWithDedupe($xeTable) {
1504
1506
  }
1505
1507
  return $xeTable.$nextTick();
1506
1508
  }
1507
- function updateScrollXSpaceWithDedupe($xeTable) {
1509
+ function updateScrollXSpaceWithDedupe($xeTable, beforeWindowCommit) {
1508
1510
  const reactData = $xeTable;
1509
1511
  const internalData = $xeTable;
1510
1512
  const { scrollXLoad, overflowX, scrollXWidth } = reactData;
@@ -1580,6 +1582,7 @@ function updateScrollXSpaceWithDedupe($xeTable) {
1580
1582
  if (scrollXSpaceEl) {
1581
1583
  setLayoutStyle(scrollXSpaceEl, "width", `${ySpaceWidth}px`);
1582
1584
  }
1585
+ if (beforeWindowCommit) return;
1583
1586
  calcScrollbar($xeTable);
1584
1587
  if (isScrollXBig && mouseOpts.area) {
1585
1588
  errLog("vxe.error.notProp", ["mouse-config.area"]);
@@ -2110,11 +2113,8 @@ function computeRowHeight($xeTable) {
2110
2113
  function handleVirtualYVisible($xeTable) {
2111
2114
  const reactData = $xeTable;
2112
2115
  const internalData = $xeTable;
2113
- const { isAllOverflow, expandColumn, isScrollYBig, scrollYHeight } = reactData;
2114
- const { elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData;
2115
- const rowOpts = $xeTable.computeRowOpts;
2116
- const cellOpts = $xeTable.computeCellOpts;
2117
- const defaultRowHeight = $xeTable.computeDefaultRowHeight;
2116
+ const { isScrollYBig, scrollYHeight } = reactData;
2117
+ const { elemStore, afterFullData, fullAllDataRowIdData } = internalData;
2118
2118
  const bodyScrollElem = getRefElem(elemStore["main-body-scroll"]);
2119
2119
  if (bodyScrollElem) {
2120
2120
  const clientHeight = bodyScrollElem.clientHeight;
@@ -2126,10 +2126,10 @@ function handleVirtualYVisible($xeTable) {
2126
2126
  const endTop = scrollTop + clientHeight;
2127
2127
  let toVisibleIndex = -1;
2128
2128
  let visibleSize = 0;
2129
- const isCustomCellHeight = isResizeCellHeight || cellOpts.height || rowOpts.height;
2130
- if (!isCustomCellHeight && !expandColumn && isAllOverflow) {
2131
- toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1;
2132
- visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1;
2129
+ const uniformHeight = getUniformRowHeight($xeTable);
2130
+ if (uniformHeight) {
2131
+ toVisibleIndex = Math.max(0, Math.floor(startTop / uniformHeight) - 1);
2132
+ visibleSize = $xeTable.computeCellOpts.height || $xeTable.computeRowOpts.height ? Math.min(afterFullData.length - toVisibleIndex, Math.floor(endTop / uniformHeight) + 2 - toVisibleIndex) : Math.ceil(clientHeight / uniformHeight) + 1;
2133
2133
  } else {
2134
2134
  const { handleGetRowId } = createHandleGetRowId($xeTable);
2135
2135
  let leftIndex = 0;
@@ -2552,7 +2552,7 @@ function handleSortEvent($xeTable, evnt, sortConfs, isUpdate) {
2552
2552
  }
2553
2553
  if (isUpdate) {
2554
2554
  if (!remote) {
2555
- $xeTable.handleTableData(true);
2555
+ $xeTable.handleTableData(true, false, "sort");
2556
2556
  }
2557
2557
  }
2558
2558
  if (evnt) {
@@ -3944,12 +3944,12 @@ function handleLoadDefaults($xeTable) {
3944
3944
  function handleInitDefaults($xeTable) {
3945
3945
  handleDefaultSort($xeTable);
3946
3946
  }
3947
- function getVirtualWindowSlice(source, previous, start, end) {
3947
+ function matchesVirtualWindow(source, previous, start, end) {
3948
3948
  const size = Math.max(0, Math.min(end, source.length) - start);
3949
- if (start >= 0 && end >= 0 && Number.isInteger(start) && Number.isInteger(end) && previous.length === size && previous.every((item, index) => item === source[start + index])) {
3950
- return previous;
3951
- }
3952
- return source.slice(start, end);
3949
+ return start >= 0 && end >= 0 && Number.isInteger(start) && Number.isInteger(end) && previous.length === size && previous.every((item, index) => item === source[start + index]);
3950
+ }
3951
+ function getVirtualWindowSlice(source, previous, start, end) {
3952
+ return matchesVirtualWindow(source, previous, start, end) ? previous : source.slice(start, end);
3953
3953
  }
3954
3954
  function handleTableColumn($xeTable, reuseWindow = false) {
3955
3955
  const reactData = $xeTable;
@@ -3998,7 +3998,7 @@ function loadScrollXData($xeTable) {
3998
3998
  if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
3999
3999
  scrollXStore.startIndex = offsetStartIndex;
4000
4000
  scrollXStore.endIndex = offsetEndIndex;
4001
- $xeTable.updateScrollXData();
4001
+ $xeTable.updateScrollXData(true);
4002
4002
  }
4003
4003
  }
4004
4004
  $xeTable.closeTooltip();
@@ -4166,6 +4166,14 @@ function buildColumnInfo($xeTable) {
4166
4166
  if (props.showCustomHeader && reactData.isGroup && (columnOpts.resizable || props.resizable)) {
4167
4167
  warnLog("vxe.error.notConflictProp", ["show-custom-header & colgroup", "column-config.resizable=false"]);
4168
4168
  }
4169
+ if (reactData.scrollXLoad && !reactData.overflowX && reactData.tableColumn.length < internalData.visibleColumn.length && !$xeTable.computeAutoWidthColumnList.length) {
4170
+ const body = getRefElem(internalData.elemStore["main-body-wrapper"]);
4171
+ if (body && body.clientWidth) {
4172
+ $xeTable.analyColumnWidth();
4173
+ autoCellWidth($xeTable);
4174
+ reactData.overflowX = reactData.scrollXWidth > body.clientWidth;
4175
+ }
4176
+ }
4169
4177
  reactData.isColLoading = false;
4170
4178
  return handleLazyRecalculate($xeTable, false, true, true);
4171
4179
  });
@@ -4307,10 +4315,12 @@ function handleSyncScroll($xeTable, isRollX, isRollY, syncGuard) {
4307
4315
  }
4308
4316
  let xRest = null;
4309
4317
  let yRest = null;
4310
- if (!isAllOverflow) {
4318
+ const { startIndex, endIndex } = internalData.scrollYStore;
4319
+ const measureAfterCommit = !isAllOverflow && !!syncGuard && isRollY && !isRollX && scrollYLoad && !reactData.expandColumn && !autoWidthColumnList.length && matchesVirtualWindow(internalData.afterFullData, reactData.tableData, startIndex, endIndex);
4320
+ if (!isAllOverflow && !measureAfterCommit) {
4311
4321
  measureScrollRowOffsets($xeTable);
4312
4322
  }
4313
- if (syncGuard) syncGuard.markMeasured();
4323
+ if (syncGuard && !measureAfterCommit) syncGuard.markMeasured();
4314
4324
  if (isRollX && scrollXLoad) {
4315
4325
  xRest = $xeTable.updateScrollXData();
4316
4326
  }
@@ -4326,8 +4336,8 @@ function handleSyncScroll($xeTable, isRollX, isRollY, syncGuard) {
4326
4336
  }
4327
4337
  if (!isAllOverflow) {
4328
4338
  measureScrollRowOffsets($xeTable);
4339
+ if (syncGuard) syncGuard.markMeasured();
4329
4340
  }
4330
- if (syncGuard) syncGuard.markMeasured();
4331
4341
  return $xeTable.updateScrollYSpace();
4332
4342
  });
4333
4343
  }
@@ -4547,7 +4557,18 @@ function handleUpdateColResize($xeTable, evnt, params) {
4547
4557
  });
4548
4558
  $xeTable.dispatchEvent("column-resizable-change", params, evnt);
4549
4559
  $xeTable.dispatchEvent("resizable-change", params, evnt);
4550
- setTimeout(() => $xeTable.recalculate(true), 300);
4560
+ const internalData = $xeTable;
4561
+ const reactData = $xeTable;
4562
+ const fixedGeometry = getUniformRowHeight($xeTable) && ($xeTable.computeCellOpts.height || $xeTable.computeRowOpts.height) && !$xeTable.treeConfig && !internalData.xeGanttView && !$xeTable.computeAutoWidthColumnList.length && !reactData.isGroup && !reactData.isRowGroupStatus && !$xeTable.headerRowStyle && !$xeTable.headerCellStyle && !$xeTable.showFooter && $xeTable.showHeaderOverflow && !internalData.visibleColumn.some((column) => column.showHeaderOverflow === false);
4563
+ const root = $xeTable.$refs.refElem;
4564
+ const width = fixedGeometry && root ? root.clientWidth : 0;
4565
+ const height = fixedGeometry && root ? root.clientHeight : 0;
4566
+ setTimeout(() => {
4567
+ if (isTableDestroyed($xeTable)) return;
4568
+ if (!fixedGeometry || !root || root.clientWidth !== width || root.clientHeight !== height) {
4569
+ $xeTable.recalculate(true);
4570
+ }
4571
+ }, 300);
4551
4572
  });
4552
4573
  }
4553
4574
  function handleUpdateRowResize($xeTable, evnt, params) {
@@ -4591,8 +4612,12 @@ function updateRowOffsetTop($xeTable, dirtyIndex = 0) {
4591
4612
  const rowOpts = $xeTable.computeRowOpts;
4592
4613
  const cellOpts = $xeTable.computeCellOpts;
4593
4614
  const defaultRowHeight = $xeTable.computeDefaultRowHeight;
4594
- const { handleGetRowId } = createHandleGetRowId($xeTable);
4595
4615
  const previous = rowOffsetIndexes.get($xeTable);
4616
+ const uniformHeight = cellOpts.height || rowOpts.height ? getUniformRowHeight($xeTable) : 0;
4617
+ if (uniformHeight && previous && previous.uniformHeight === uniformHeight && previous.rows === afterFullData && previous.rowOrder === internalData.afterFullRowMaps && previous.cache === fullAllDataRowIdData && previous.length === afterFullData.length) {
4618
+ return;
4619
+ }
4620
+ const { handleGetRowId } = createHandleGetRowId($xeTable);
4596
4621
  let startIndex = previous && previous.rows === afterFullData && previous.cache === fullAllDataRowIdData ? Math.max(0, Math.min(dirtyIndex, afterFullData.length)) : 0;
4597
4622
  const firstRow = afterFullData[startIndex];
4598
4623
  const firstRest = firstRow ? fullAllDataRowIdData[handleGetRowId(firstRow)] : null;
@@ -4620,6 +4645,7 @@ function updateRowOffsetTop($xeTable, dirtyIndex = 0) {
4620
4645
  cellOpts,
4621
4646
  defaultRowHeight,
4622
4647
  hasExpandColumn: !!expandColumn,
4648
+ uniformHeight,
4623
4649
  heightFlag: reactData.calcCellHeightFlag,
4624
4650
  firstChangedIndex: Infinity,
4625
4651
  resizeFlag: reactData.resizeHeightFlag
@@ -5110,6 +5136,42 @@ const tableMethods = {
5110
5136
  return $xeTable.$nextTick().then(() => loadTableData($xeTable, internalData.tableFullData, true, true));
5111
5137
  });
5112
5138
  },
5139
+ /** 只改变现有行的展示内容。数据模型或尺寸依赖行值时,沿用完整更新。 */
5140
+ refreshRowContent(rows) {
5141
+ const $xeTable = this;
5142
+ const internalData = $xeTable;
5143
+ const reactData = $xeTable;
5144
+ if (!rows.length) return $xeTable.$nextTick();
5145
+ const { fullDataRowIdData, visibleDataRowIdData, tableFullColumn } = internalData;
5146
+ const { handleGetRowId } = createHandleGetRowId($xeTable);
5147
+ let hasVisibleRow = false;
5148
+ let staleRow = false;
5149
+ for (const row of rows) {
5150
+ const id = handleGetRowId(row);
5151
+ const rest = fullDataRowIdData[id];
5152
+ if (rest && rest.row === row) {
5153
+ rest.formatData = void 0;
5154
+ if (visibleDataRowIdData[id] === row) {
5155
+ rest.contentVersion = (rest.contentVersion || 0) + 1;
5156
+ hasVisibleRow = true;
5157
+ }
5158
+ } else {
5159
+ staleRow = true;
5160
+ }
5161
+ }
5162
+ const remoteFilter = $xeTable.computeFilterOpts.remote;
5163
+ const remoteSort = $xeTable.computeSortOpts.remote;
5164
+ if (staleRow || !reactData.isAllOverflow || internalData.isResizeCellHeight || $xeTable.treeConfig || reactData.isRowGroupStatus || reactData.expandColumn || $xeTable.showFooter || $xeTable.spanMethod || internalData.mergeBodyList.length || internalData.xeGanttView || $xeTable.computeAutoWidthColumnList.length || tableFullColumn.some((column) => !remoteSort && column.sortable && column.order || !remoteFilter && column.filters && column.filters.some((item) => item.checked))) {
5165
+ return $xeTable.updateData();
5166
+ }
5167
+ if (hasVisibleRow) {
5168
+ for (const ref of ["refTableBody", "leftBody", "rightBody"]) {
5169
+ const body = $xeTable.$refs[ref];
5170
+ if (body) body.$forceUpdate();
5171
+ }
5172
+ }
5173
+ return $xeTable.$nextTick();
5174
+ },
5113
5175
  /**
5114
5176
  * 手动处理数据,用于手动排序与筛选
5115
5177
  * 对于手动更改了排序、筛选...等条件后需要重新处理数据时可能会用到
@@ -5136,7 +5198,7 @@ const tableMethods = {
5136
5198
  setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 50);
5137
5199
  });
5138
5200
  },
5139
- handleTableData(force, reuseWindow = false) {
5201
+ handleTableData(force, reuseWindow = false, reason) {
5140
5202
  const $xeTable = this;
5141
5203
  const reactData = $xeTable;
5142
5204
  const internalData = $xeTable;
@@ -5145,7 +5207,7 @@ const tableMethods = {
5145
5207
  const $xeGanttView = internalData.xeGanttView;
5146
5208
  let fullList = internalData.afterFullData;
5147
5209
  if (force) {
5148
- updateAfterFullData($xeTable);
5210
+ updateAfterFullData($xeTable, reason);
5149
5211
  fullList = handleVirtualTreeToList($xeTable);
5150
5212
  internalData.mergeHeaderRowMaps = {};
5151
5213
  internalData.mergeHeaderColMaps = {};
@@ -7313,12 +7375,7 @@ const tableMethods = {
7313
7375
  evnt.preventDefault();
7314
7376
  const { fullColumnIdData } = internalData;
7315
7377
  const { column } = params;
7316
- let resizeColumn = column;
7317
- if (column.children && column.children.length) {
7318
- XEUtils.eachTree(column.children, (childColumn) => {
7319
- resizeColumn = childColumn;
7320
- });
7321
- }
7378
+ const resizeColumn = getLastChildColumn(column);
7322
7379
  const colid = resizeColumn.id;
7323
7380
  const colRest = fullColumnIdData[colid];
7324
7381
  const dragBtnElem = evnt.target;
@@ -11347,7 +11404,7 @@ const tableMethods = {
11347
11404
  }
11348
11405
  });
11349
11406
  if (!remote || firstSortColumn && firstSortColumn.remoteSort) {
11350
- $xeTable.handleTableData(true);
11407
+ $xeTable.handleTableData(true, false, "sort");
11351
11408
  }
11352
11409
  return $xeTable.$nextTick().then(() => {
11353
11410
  updateRowOffsetTop($xeTable);
@@ -11382,7 +11439,7 @@ const tableMethods = {
11382
11439
  clearAllSort($xeTable);
11383
11440
  }
11384
11441
  if (!sortOpts.remote) {
11385
- $xeTable.handleTableData(true);
11442
+ $xeTable.handleTableData(true, false, "sort");
11386
11443
  }
11387
11444
  return $xeTable.$nextTick().then(() => {
11388
11445
  updateRowOffsetTop($xeTable);
@@ -11412,7 +11469,7 @@ const tableMethods = {
11412
11469
  });
11413
11470
  }
11414
11471
  if (!sortOpts.remote) {
11415
- $xeTable.handleTableData(true);
11472
+ $xeTable.handleTableData(true, false, "sort");
11416
11473
  }
11417
11474
  if (!multiple) {
11418
11475
  column = sortCols[0];
@@ -12812,12 +12869,14 @@ const tableMethods = {
12812
12869
  fixed: ""
12813
12870
  });
12814
12871
  },
12815
- updateScrollXData() {
12872
+ updateScrollXData(fromScroll = false) {
12816
12873
  const $xeTable = this;
12817
12874
  const reactData = $xeTable;
12818
12875
  const { isAllOverflow } = reactData;
12876
+ const internalData = $xeTable;
12877
+ const deferLayout = fromScroll && isAllOverflow && reactData.overflowX && reactData.scrollXWidth < maxXWidth && !reactData.expandColumn && !internalData.xeGanttView && !$xeTable.computeAutoWidthColumnList.length;
12819
12878
  handleTableColumn($xeTable);
12820
- $xeTable.updateScrollXSpace();
12879
+ $xeTable.updateScrollXSpace(deferLayout);
12821
12880
  return $xeTable.$nextTick().then(() => {
12822
12881
  handleTableColumn($xeTable, true);
12823
12882
  $xeTable.updateScrollXSpace();
@@ -12827,9 +12886,9 @@ const tableMethods = {
12827
12886
  });
12828
12887
  },
12829
12888
  // 更新横向 X 可视渲染上下剩余空间大小
12830
- updateScrollXSpace() {
12889
+ updateScrollXSpace(beforeWindowCommit = false) {
12831
12890
  if (this.computeVirtualXOpts.experimentalSkipUnchangedStyle === true) {
12832
- return updateScrollXSpaceWithDedupe(this);
12891
+ return updateScrollXSpaceWithDedupe(this, beforeWindowCommit);
12833
12892
  }
12834
12893
  const $xeTable = this;
12835
12894
  const reactData = $xeTable;
@@ -12907,6 +12966,7 @@ const tableMethods = {
12907
12966
  if (scrollXSpaceEl) {
12908
12967
  scrollXSpaceEl.style.width = `${ySpaceWidth}px`;
12909
12968
  }
12969
+ if (beforeWindowCommit) return;
12910
12970
  calcScrollbar($xeTable);
12911
12971
  if (isScrollXBig && mouseOpts.area) {
12912
12972
  errLog("vxe.error.notProp", ["mouse-config.area"]);
@@ -12961,13 +13021,13 @@ const tableMethods = {
12961
13021
  let sYHeight = scrollYHeight;
12962
13022
  let isScrollYBig = false;
12963
13023
  if (scrollYLoad) {
12964
- const isCustomCellHeight = isResizeCellHeight || cellOpts.height || rowOpts.height;
12965
- if (!isCustomCellHeight && !expandColumn && isAllOverflow) {
12966
- sYHeight = afterFullData.length * defaultRowHeight;
13024
+ const uniformHeight = getUniformRowHeight($xeTable);
13025
+ if (uniformHeight) {
13026
+ sYHeight = afterFullData.length * uniformHeight;
12967
13027
  if (sYHeight > maxYHeight) {
12968
13028
  isScrollYBig = true;
12969
13029
  }
12970
- ySpaceTop = Math.max(0, startIndex * defaultRowHeight);
13030
+ ySpaceTop = Math.max(0, startIndex * uniformHeight);
12971
13031
  } else {
12972
13032
  const firstRow = afterFullData[startIndex];
12973
13033
  if (firstRow) {
@@ -13042,7 +13102,7 @@ const tableMethods = {
13042
13102
  return;
13043
13103
  }
13044
13104
  const root = $xeTable.$refs.refElem;
13045
- if (stableSpace && fromScroll && root && bodyScrollElem && (cellOpts.height || rowOpts.height) && internalData.customHeight > 0 && !$xeTable.computeAutoWidthColumnList.length && !$xeTable.spanMethod && !internalData.mergeBodyList.length && !internalData.currentRow && !($xeTable.mouseConfig && mouseOpts.selected)) {
13105
+ if (stableSpace && fromScroll && root && bodyScrollElem && (cellOpts.height || rowOpts.height) && internalData.customHeight > 0 && !$xeTable.computeAutoWidthColumnList.length && !$xeTable.spanMethod && !internalData.mergeBodyList.length && !($xeTable.mouseConfig && mouseOpts.selected)) {
13046
13106
  const header = getRefElem(elemStore["main-header-table"]);
13047
13107
  const footer = getRefElem(elemStore["main-footer-table"]);
13048
13108
  const layout = [
@@ -13070,6 +13130,9 @@ const tableMethods = {
13070
13130
  ];
13071
13131
  const previous = scrollYWindowLayouts.get($xeTable);
13072
13132
  if (previous && layout.every((value, index) => value === previous[index])) {
13133
+ if (internalData.currentRow && !$xeTable.rowKey && !rowOpts.useKey) {
13134
+ syncReusedCurrentRows($xeTable, root, internalData.currentRow);
13135
+ }
13073
13136
  reactData.scrollYTop = scrollYTop;
13074
13137
  return;
13075
13138
  }
@@ -1327,31 +1327,22 @@ var table_default = {
1327
1327
  const $xeTable = this;
1328
1328
  const props = $xeTable;
1329
1329
  const reactData = $xeTable;
1330
- const { spanMethod, footerSpanMethod, showHeaderOverflow: allColumnHeaderOverflow } = props;
1331
- const { isGroup, scrollXLoad } = reactData;
1332
- let isOptimizeMode = false;
1333
- if (isGroup) {
1334
- } else {
1335
- if (scrollXLoad && allColumnHeaderOverflow) {
1336
- if (spanMethod || footerSpanMethod) {
1337
- } else {
1338
- isOptimizeMode = true;
1339
- }
1340
- }
1341
- }
1342
- return isOptimizeMode;
1330
+ if (!reactData.scrollXLoad || !props.showHeaderOverflow || props.spanMethod || props.footerSpanMethod) return false;
1331
+ if (!reactData.isGroup) return true;
1332
+ const internalData = $xeTable;
1333
+ return !!(reactData.overflowX && !props.showCustomHeader && !props.headerRowStyle && !props.headerCellStyle && !$xeTable.computeColumnOpts.drag && !$xeTable.computeMouseOpts.area && !(reactData.mergeHeadFlag && internalData.mergeHeaderList.length) && !XEUtils.findTree(reactData.tableGroupColumn, (column) => column.visible && (column.showHeaderOverflow === false || column.width === "auto" || column.minWidth === "auto")));
1343
1334
  },
1344
1335
  computeIsBodyRenderOptimize() {
1345
1336
  const $xeTable = this;
1346
1337
  const props = $xeTable;
1347
1338
  const reactData = $xeTable;
1348
- const { spanMethod, footerSpanMethod } = props;
1339
+ const { spanMethod } = props;
1349
1340
  const { scrollXLoad, scrollYLoad, isAllOverflow, expandColumn } = reactData;
1350
1341
  const bodyMergeCoverFixed = $xeTable.computeBodyMergeCoverFixed;
1351
1342
  const expandOpts = $xeTable.computeExpandOpts;
1352
1343
  let isOptimizeMode = false;
1353
1344
  if (scrollXLoad || scrollYLoad || isAllOverflow) {
1354
- if (expandColumn && expandOpts.mode !== "fixed" || bodyMergeCoverFixed || spanMethod || footerSpanMethod) {
1345
+ if (expandColumn && expandOpts.mode !== "fixed" || bodyMergeCoverFixed || spanMethod) {
1355
1346
  } else {
1356
1347
  isOptimizeMode = true;
1357
1348
  }
@@ -27,7 +27,9 @@ export declare function encodeRowid(rowVal: string | number): string;
27
27
  export declare function getCalcHeight(height: number | 'unset' | undefined | null): number;
28
28
  export declare function handleFieldOrColumn($xeTable: VxeTableConstructor, fieldOrColumn: any): any;
29
29
  export declare function handleRowidOrRow($xeTable: VxeTableConstructor, rowidOrRow: any): any;
30
- export declare function getCellRestHeight(rowRest: VxeTableDefines.RowCacheItem, cellOpts: VxeTablePropTypes.CellConfig, rowOpts: VxeTablePropTypes.RowConfig, defaultRowHeight: number): number;
30
+ export declare function getCellRestHeight(rowRest: Pick<VxeTableDefines.RowCacheItem, 'height' | 'resizeHeight'>, cellOpts: VxeTablePropTypes.CellConfig, rowOpts: VxeTablePropTypes.RowConfig, defaultRowHeight: number): number;
31
+ export declare const maxYHeight = 5000000;
32
+ export declare function getUniformRowHeight($xeTable: VxeTableConstructor): number;
31
33
  export declare function assembleColumn(_vm: any): void;
32
34
  export declare function destroyColumn(_vm: any): void;
33
35
  export declare function getRootColumn($xeTable: VxeTableConstructor & VxeTablePrivateMethods, column: any): any;
@@ -704,6 +704,14 @@ function getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) {
704
704
  }
705
705
  return cellHeight;
706
706
  }
707
+ const maxYHeight = 5e6;
708
+ function getUniformRowHeight($xeTable) {
709
+ const reactData = $xeTable;
710
+ const internalData = $xeTable;
711
+ if (!reactData.isAllOverflow || reactData.expandColumn || internalData.isResizeCellHeight) return 0;
712
+ const height = getCellRestHeight({ height: 0, resizeHeight: 0 }, $xeTable.computeCellOpts, $xeTable.computeRowOpts, $xeTable.computeDefaultRowHeight);
713
+ return Number.isFinite(height) && height > 0 ? height : 0;
714
+ }
707
715
  function assembleColumn(_vm) {
708
716
  const $xeTable = _vm.$xeTable;
709
717
  const reactData = $xeTable;
@@ -852,8 +860,10 @@ function getFirstChildColumn(column) {
852
860
  }
853
861
  function getLastChildColumn(column) {
854
862
  const { children } = column;
855
- if (children && children.length) {
856
- return getFirstChildColumn(XEUtils.last(children));
863
+ if (children) {
864
+ for (let i = children.length - 1; i >= 0; i--) {
865
+ if (children[i].visible !== false) return getLastChildColumn(children[i]);
866
+ }
857
867
  }
858
868
  return column;
859
869
  }
@@ -929,8 +939,8 @@ function createColumn($xeTable, options, renderOptions) {
929
939
  function rowToVisible($xeTable, row) {
930
940
  const reactData = $xeTable;
931
941
  const internalData = $xeTable;
932
- const { scrollYLoad, scrollYTop, isAllOverflow } = reactData;
933
- const { elemStore, afterFullData, fullAllDataRowIdData, isResizeCellHeight } = internalData;
942
+ const { scrollYLoad, scrollYTop, isScrollYBig, scrollYHeight } = reactData;
943
+ const { elemStore, afterFullData, fullAllDataRowIdData } = internalData;
934
944
  const rowOpts = $xeTable.computeRowOpts;
935
945
  const cellOpts = $xeTable.computeCellOpts;
936
946
  const defaultRowHeight = $xeTable.computeDefaultRowHeight;
@@ -952,17 +962,21 @@ function rowToVisible($xeTable, row) {
952
962
  }
953
963
  } else {
954
964
  if (scrollYLoad) {
955
- const isCustomCellHeight = isResizeCellHeight || cellOpts.height || rowOpts.height;
956
- if (!isCustomCellHeight && isAllOverflow) {
957
- return $xeTable.scrollTo(null, ($xeTable.findRowIndexOf(afterFullData, row) - 1) * defaultRowHeight);
958
- }
959
- const rowRest = fullAllDataRowIdData[rowid] || {};
960
- const rHeight = rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight;
961
- const scrollTop = rowRest.oTop;
962
- if (scrollTop < bodyScrollTop) {
963
- return $xeTable.scrollTo(null, scrollTop - leftFixedWidth - 1);
965
+ const rowRest = fullAllDataRowIdData[rowid];
966
+ if (!rowRest) return Promise.resolve();
967
+ const uniformHeight = getUniformRowHeight($xeTable);
968
+ const rHeight = uniformHeight || getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
969
+ const index = rowRest._index;
970
+ if (uniformHeight && afterFullData[index] !== rowRest.row) return Promise.resolve();
971
+ const rowTop = uniformHeight ? index * rHeight : rowRest.oTop;
972
+ const scale = isScrollYBig ? (maxYHeight - bodyHeight) / (scrollYHeight - bodyHeight) : 1;
973
+ let target = rowTop + rHeight - (bodyHeight - rightFixedWidth - 1);
974
+ if (uniformHeight && !cellOpts.height && !rowOpts.height) {
975
+ target = rowTop - rHeight;
976
+ } else if (rowTop < bodyScrollTop / scale) {
977
+ target = rowTop - leftFixedWidth - 1;
964
978
  }
965
- return $xeTable.scrollTo(null, scrollTop + rHeight - (bodyHeight - rightFixedWidth - 1));
979
+ return $xeTable.scrollTo(null, isScrollYBig ? Math.round(target * scale) : target);
966
980
  }
967
981
  }
968
982
  }
@@ -1082,11 +1096,13 @@ export {
1082
1096
  getRowUniqueId,
1083
1097
  getRowid,
1084
1098
  getRowkey,
1099
+ getUniformRowHeight,
1085
1100
  handleCustomStoreConfig,
1086
1101
  handleFieldOrColumn,
1087
1102
  handleRowidOrRow,
1088
1103
  hasDeepKey,
1089
1104
  isColumnInfo,
1105
+ maxYHeight,
1090
1106
  restoreScrollLocation,
1091
1107
  rowToVisible,
1092
1108
  setCellValue,
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from "@vxe-ui/core";
2
2
  import { getFuncText } from "./src/utils";
3
- const version = "3.25.19";
3
+ const version = "3.25.21";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from "@vxe-ui/core";
2
2
  const { log } = VxeUI;
3
- const tableVersion = `table v${"3.25.19"}`;
3
+ const tableVersion = `table v${"3.25.21"}`;
4
4
  function createComponentLog(name) {
5
5
  const uiVersion = VxeUI.uiVersion ? `ui v${VxeUI.uiVersion}` : "";
6
6
  const ganttVersion = VxeUI.ganttVersion ? `gantt v${VxeUI.ganttVersion}` : "";