vxe-table 3.19.3 → 3.19.4

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 (34) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/src/body.js +30 -14
  3. package/es/table/src/methods.js +105 -3
  4. package/es/table/src/table.js +4 -4
  5. package/es/table/src/util.js +0 -61
  6. package/es/ui/index.js +3 -2
  7. package/es/ui/src/log.js +1 -1
  8. package/lib/index.umd.js +158 -104
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/style.css +1 -1
  11. package/lib/table/src/body.js +28 -15
  12. package/lib/table/src/body.min.js +1 -1
  13. package/lib/table/src/methods.js +123 -3
  14. package/lib/table/src/methods.min.js +1 -1
  15. package/lib/table/src/table.js +3 -4
  16. package/lib/table/src/table.min.js +1 -1
  17. package/lib/table/src/util.js +0 -81
  18. package/lib/table/src/util.min.js +1 -1
  19. package/lib/ui/index.js +3 -2
  20. package/lib/ui/index.min.js +1 -1
  21. package/lib/ui/src/log.js +1 -1
  22. package/lib/ui/src/log.min.js +1 -1
  23. package/package.json +2 -2
  24. package/packages/table/src/body.ts +29 -14
  25. package/packages/table/src/methods.ts +109 -3
  26. package/packages/table/src/table.ts +4 -4
  27. package/packages/table/src/util.ts +0 -66
  28. package/packages/ui/index.ts +2 -1
  29. /package/es/{iconfont.1761545705692.ttf → iconfont.1761699967297.ttf} +0 -0
  30. /package/es/{iconfont.1761545705692.woff → iconfont.1761699967297.woff} +0 -0
  31. /package/es/{iconfont.1761545705692.woff2 → iconfont.1761699967297.woff2} +0 -0
  32. /package/lib/{iconfont.1761545705692.ttf → iconfont.1761699967297.ttf} +0 -0
  33. /package/lib/{iconfont.1761545705692.woff → iconfont.1761699967297.woff} +0 -0
  34. /package/lib/{iconfont.1761545705692.woff2 → iconfont.1761699967297.woff2} +0 -0
package/lib/index.umd.js CHANGED
@@ -2005,7 +2005,7 @@ function getClass(property, params) {
2005
2005
  ;// CONCATENATED MODULE: ./packages/ui/index.ts
2006
2006
 
2007
2007
 
2008
- const version = "3.19.3";
2008
+ const version = "3.19.4";
2009
2009
  core_.VxeUI.version = version;
2010
2010
  core_.VxeUI.tableVersion = version;
2011
2011
  core_.VxeUI.setConfig({
@@ -2178,7 +2178,8 @@ core_.VxeUI.setConfig({
2178
2178
  hasChildField: 'hasChild',
2179
2179
  mapChildrenField: '_X_ROW_CHILD',
2180
2180
  indent: 20,
2181
- showIcon: true
2181
+ showIcon: true,
2182
+ showRootLine: true
2182
2183
  },
2183
2184
  expandConfig: {
2184
2185
  // trigger: 'default',
@@ -2695,7 +2696,7 @@ function isNodeElement(elem) {
2695
2696
  const {
2696
2697
  log: log_log
2697
2698
  } = core_.VxeUI;
2698
- const log_version = `table v${"3.19.3"}`;
2699
+ const log_version = `table v${"3.19.4"}`;
2699
2700
  const warnLog = log_log.create('warn', log_version);
2700
2701
  const errLog = log_log.create('error', log_version);
2701
2702
  ;// CONCATENATED MODULE: ./packages/table/src/columnInfo.ts
@@ -3477,85 +3478,6 @@ function getLastChildColumn(column) {
3477
3478
  }
3478
3479
  return column;
3479
3480
  }
3480
- const lineOffsetSizes = {
3481
- mini: 3,
3482
- small: 2,
3483
- medium: 1,
3484
- large: 0
3485
- };
3486
- function countTreeExpandSize(prevRow, params) {
3487
- let count = 1;
3488
- if (!prevRow) {
3489
- return count;
3490
- }
3491
- const {
3492
- $table
3493
- } = params;
3494
- const reactData = $table;
3495
- const {
3496
- treeExpandedFlag
3497
- } = reactData;
3498
- const internalData = $table;
3499
- const {
3500
- treeExpandedMaps
3501
- } = internalData;
3502
- const treeOpts = $table.computeTreeOpts;
3503
- const {
3504
- transform,
3505
- mapChildrenField
3506
- } = treeOpts;
3507
- const childrenField = treeOpts.children || treeOpts.childrenField;
3508
- const rowChildren = prevRow[transform ? mapChildrenField : childrenField];
3509
- if (rowChildren && treeExpandedFlag && treeExpandedMaps[getRowid($table, prevRow)]) {
3510
- for (let index = 0; index < rowChildren.length; index++) {
3511
- count += countTreeExpandSize(rowChildren[index], params);
3512
- }
3513
- }
3514
- return count;
3515
- }
3516
- function getOffsetSize($xeTable) {
3517
- const vSize = $xeTable.computeSize;
3518
- if (vSize) {
3519
- return lineOffsetSizes[vSize] || 0;
3520
- }
3521
- return 0;
3522
- }
3523
- function calcTreeLine(params, prevRow) {
3524
- const {
3525
- $table,
3526
- row
3527
- } = params;
3528
- const tableProps = $table;
3529
- const tableReactData = $table;
3530
- const tableInternalData = $table;
3531
- const {
3532
- showOverflow
3533
- } = tableProps;
3534
- const {
3535
- scrollYLoad
3536
- } = tableReactData;
3537
- const {
3538
- fullAllDataRowIdData
3539
- } = tableInternalData;
3540
- const rowOpts = $table.computeRowOpts;
3541
- const cellOpts = $table.computeCellOpts;
3542
- const defaultRowHeight = $table.computeDefaultRowHeight;
3543
- const rowid = getRowid($table, row);
3544
- const rowRest = fullAllDataRowIdData[rowid];
3545
- const currCellHeight = rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight;
3546
- let expandSize = 1;
3547
- if (prevRow) {
3548
- expandSize = countTreeExpandSize(prevRow, params);
3549
- }
3550
- let cellHeight = currCellHeight;
3551
- const vnHeight = rowRest.height;
3552
- if (scrollYLoad) {
3553
- if (!showOverflow) {
3554
- cellHeight = vnHeight || currCellHeight;
3555
- }
3556
- }
3557
- return cellHeight * expandSize - (prevRow ? 1 : 12 - getOffsetSize($table));
3558
- }
3559
3481
  function getCellValue(row, column) {
3560
3482
  return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, column.field);
3561
3483
  }
@@ -8878,6 +8800,9 @@ function autoCellWidth($xeTable) {
8878
8800
  updateColumnOffsetLeft($xeTable);
8879
8801
  updateHeight($xeTable);
8880
8802
  }
8803
+ /**
8804
+ * 计算自适应行高
8805
+ */
8881
8806
  const calcCellAutoHeight = (rowRest, wrapperEl) => {
8882
8807
  const cellElemList = wrapperEl.querySelectorAll(`.vxe-cell--wrapper[rowid="${rowRest.rowid}"]`);
8883
8808
  let colHeight = rowRest.height;
@@ -8895,9 +8820,16 @@ const calcCellAutoHeight = (rowRest, wrapperEl) => {
8895
8820
  }
8896
8821
  return colHeight;
8897
8822
  };
8823
+ /**
8824
+ * 自适应行高
8825
+ */
8898
8826
  const calcCellHeight = $xeTable => {
8827
+ const props = $xeTable;
8899
8828
  const reactData = $xeTable;
8900
8829
  const internalData = $xeTable;
8830
+ const {
8831
+ treeConfig
8832
+ } = props;
8901
8833
  const {
8902
8834
  tableData,
8903
8835
  isAllOverflow,
@@ -8907,9 +8839,10 @@ const calcCellHeight = $xeTable => {
8907
8839
  const {
8908
8840
  fullAllDataRowIdData
8909
8841
  } = internalData;
8842
+ const treeOpts = $xeTable.computeTreeOpts;
8910
8843
  const defaultRowHeight = $xeTable.computeDefaultRowHeight;
8911
8844
  const el = $xeTable.$refs.refElem;
8912
- if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
8845
+ if (!isAllOverflow && (scrollYLoad || scrollXLoad || treeConfig && treeOpts.showLine) && el) {
8913
8846
  const {
8914
8847
  handleGetRowId
8915
8848
  } = createHandleGetRowId($xeTable);
@@ -9833,6 +9766,7 @@ function loadTableData($xeTable, datas, isReset) {
9833
9766
  }
9834
9767
  reactData.isRowLoading = false;
9835
9768
  handleRecalculateStyle($xeTable, false, false, false);
9769
+ updateTreeLineStyle($xeTable);
9836
9770
  // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
9837
9771
  if (!props.showOverflow) {
9838
9772
  setTimeout(() => {
@@ -9845,6 +9779,7 @@ function loadTableData($xeTable, datas, isReset) {
9845
9779
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop).then(() => {
9846
9780
  handleRecalculateStyle($xeTable, false, true, true);
9847
9781
  updateRowOffsetTop($xeTable);
9782
+ updateTreeLineStyle($xeTable);
9848
9783
  resolve();
9849
9784
  });
9850
9785
  } else {
@@ -9852,6 +9787,7 @@ function loadTableData($xeTable, datas, isReset) {
9852
9787
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop).then(() => {
9853
9788
  handleRecalculateStyle($xeTable, false, true, true);
9854
9789
  updateRowOffsetTop($xeTable);
9790
+ updateTreeLineStyle($xeTable);
9855
9791
  resolve();
9856
9792
  });
9857
9793
  });
@@ -10417,6 +10353,9 @@ function updateHeight($xeTable) {
10417
10353
  internalData.customHeight = 300;
10418
10354
  }
10419
10355
  }
10356
+ /**
10357
+ * 计算自适应列宽
10358
+ */
10420
10359
  function calcColumnAutoWidth($xeTable, column, wrapperEl) {
10421
10360
  const columnOpts = $xeTable.computeColumnOpts;
10422
10361
  const {
@@ -10451,6 +10390,9 @@ function calcColumnAutoWidth($xeTable, column, wrapperEl) {
10451
10390
  }
10452
10391
  return colWidth + leftRightPadding;
10453
10392
  }
10393
+ /**
10394
+ * 自适应列宽
10395
+ */
10454
10396
  function calcCellWidth($xeTable) {
10455
10397
  const internalData = $xeTable;
10456
10398
  const autoWidthColumnList = $xeTable.computeAutoWidthColumnList;
@@ -10612,9 +10554,109 @@ function updateRowExpandStyle($xeTable) {
10612
10554
  /**
10613
10555
  * 更新树连接线样式
10614
10556
  */
10615
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
10616
10557
  function updateTreeLineStyle($xeTable) {
10617
- // 待优化
10558
+ const props = $xeTable;
10559
+ const reactData = $xeTable;
10560
+ const internalData = $xeTable;
10561
+ const {
10562
+ treeConfig
10563
+ } = props;
10564
+ if (!treeConfig) {
10565
+ return;
10566
+ }
10567
+ const {
10568
+ tableData
10569
+ } = reactData;
10570
+ const {
10571
+ fullAllDataRowIdData,
10572
+ treeExpandedMaps
10573
+ } = internalData;
10574
+ const cellOpts = $xeTable.computeCellOpts;
10575
+ const rowOpts = $xeTable.computeRowOpts;
10576
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
10577
+ const treeOpts = $xeTable.computeTreeOpts;
10578
+ const {
10579
+ transform,
10580
+ mapChildrenField
10581
+ } = treeOpts;
10582
+ const childrenField = treeOpts.children || treeOpts.childrenField;
10583
+ const {
10584
+ handleGetRowId
10585
+ } = createHandleGetRowId($xeTable);
10586
+ const expParentList = [];
10587
+ const handleNodeRow = (row, rIndex, rows) => {
10588
+ const rowid = handleGetRowId(row);
10589
+ const rowRest = fullAllDataRowIdData[rowid] || {};
10590
+ const childList = row[transform ? mapChildrenField : childrenField];
10591
+ const prevRow = rows[rIndex - 1] || null;
10592
+ const nextRow = rows[rIndex + 1] || null;
10593
+ if (childList && childList.length && treeExpandedMaps[rowid]) {
10594
+ expParentList.push({
10595
+ row,
10596
+ prevRow,
10597
+ nextRow
10598
+ });
10599
+ childList.forEach((childRow, crIndex) => {
10600
+ const childRowid = handleGetRowId(childRow);
10601
+ if (treeExpandedMaps[childRowid]) {
10602
+ handleNodeRow(childRow, crIndex, childList);
10603
+ }
10604
+ });
10605
+ } else {
10606
+ if (nextRow) {
10607
+ const nextRowid = handleGetRowId(nextRow);
10608
+ const nextRowRest = fullAllDataRowIdData[nextRowid] || {};
10609
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
10610
+ const nextCellHeight = getCellRestHeight(nextRowRest, cellOpts, rowOpts, defaultRowHeight);
10611
+ rowRest.oHeight = currCellHeight;
10612
+ rowRest.lineHeight = Math.floor(currCellHeight / 2 + nextCellHeight / 2);
10613
+ } else {
10614
+ rowRest.oHeight = 0;
10615
+ rowRest.lineHeight = 0;
10616
+ }
10617
+ }
10618
+ };
10619
+ tableData.forEach((row, rIndex) => {
10620
+ handleNodeRow(row, rIndex, tableData);
10621
+ });
10622
+ external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().lastArrayEach(expParentList, ({
10623
+ row,
10624
+ nextRow
10625
+ }) => {
10626
+ const rowid = handleGetRowId(row);
10627
+ const childList = row[transform ? mapChildrenField : childrenField];
10628
+ const rowRest = fullAllDataRowIdData[rowid];
10629
+ if (rowRest) {
10630
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
10631
+ let countOffsetHeight = currCellHeight;
10632
+ let countLineHeight = 0;
10633
+ childList.forEach(childRow => {
10634
+ const childRowid = handleGetRowId(childRow);
10635
+ const childRowRest = fullAllDataRowIdData[childRowid] || {};
10636
+ const childList = childRow[transform ? mapChildrenField : childrenField];
10637
+ if (treeExpandedMaps[childRowid] && childList && childList.length) {
10638
+ countOffsetHeight += childRowRest.oHeight || 0;
10639
+ countLineHeight += childRowRest.oHeight || 0;
10640
+ } else {
10641
+ const cellHeight = getCellRestHeight(childRowRest, cellOpts, rowOpts, defaultRowHeight);
10642
+ childRowRest.oHeight = cellHeight;
10643
+ childRowRest.lineHeight = cellHeight;
10644
+ countOffsetHeight += cellHeight;
10645
+ countLineHeight += cellHeight;
10646
+ }
10647
+ });
10648
+ if (nextRow) {
10649
+ const nextRowid = handleGetRowId(nextRow);
10650
+ const nextRowRest = fullAllDataRowIdData[nextRowid] || {};
10651
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
10652
+ const nextCellHeight = getCellRestHeight(nextRowRest, cellOpts, rowOpts, defaultRowHeight);
10653
+ countOffsetHeight += currCellHeight;
10654
+ countLineHeight += Math.floor(currCellHeight / 2 + nextCellHeight / 2);
10655
+ }
10656
+ rowRest.lineHeight = countLineHeight;
10657
+ rowRest.oHeight = countOffsetHeight;
10658
+ }
10659
+ });
10618
10660
  }
10619
10661
  function handleRowExpandScroll($xeTable) {
10620
10662
  const internalData = $xeTable;
@@ -19656,12 +19698,12 @@ function renderLine(h, $xeTable, rowid, params, cellHeight) {
19656
19698
  const {
19657
19699
  column
19658
19700
  } = params;
19659
- const {
19660
- afterFullData
19661
- } = tableInternalData;
19662
19701
  const {
19663
19702
  treeConfig
19664
19703
  } = tableProps;
19704
+ const cellOpts = $xeTable.computeCellOpts;
19705
+ const rowOpts = $xeTable.computeRowOpts;
19706
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
19665
19707
  const treeOpts = $xeTable.computeTreeOpts;
19666
19708
  const {
19667
19709
  slots,
@@ -19670,26 +19712,39 @@ function renderLine(h, $xeTable, rowid, params, cellHeight) {
19670
19712
  const {
19671
19713
  fullAllDataRowIdData
19672
19714
  } = tableInternalData;
19673
- if (slots && slots.line) {
19674
- return $xeTable.callSlot(slots.line, params, h);
19675
- }
19676
- const rowRest = fullAllDataRowIdData[rowid];
19677
- let rLevel = 0;
19678
- let prevRow = null;
19679
- if (rowRest) {
19680
- rLevel = rowRest.level;
19681
- prevRow = rowRest.items[rowRest.treeIndex - 1];
19682
- }
19683
19715
  if (treeConfig && treeNode && (treeOpts.showLine || treeOpts.line)) {
19716
+ if (slots && slots.line) {
19717
+ return $xeTable.callSlot(slots.line, params, h);
19718
+ }
19719
+ const rowRest = fullAllDataRowIdData[rowid];
19720
+ let rLevel = 0;
19721
+ let prevRow = null;
19722
+ let parentRow = null;
19723
+ let lineHeight = '';
19724
+ if (rowRest) {
19725
+ rLevel = rowRest.level;
19726
+ prevRow = rowRest.items[rowRest.treeIndex - 1];
19727
+ parentRow = rowRest.parent;
19728
+ }
19729
+ if (!rLevel && !treeOpts.showRootLine) {
19730
+ return [];
19731
+ }
19732
+ if (prevRow) {
19733
+ const prevRowRest = fullAllDataRowIdData[getRowid($xeTable, prevRow)] || {};
19734
+ lineHeight = `${prevRowRest.lineHeight || 0}px`;
19735
+ } else if (rLevel && parentRow) {
19736
+ const parentRowRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)] || {};
19737
+ lineHeight = `calc(-1em + ${Math.floor(cellHeight / 2 + getCellRestHeight(parentRowRest, cellOpts, rowOpts, defaultRowHeight) / 2)}px)`;
19738
+ }
19684
19739
  return [h('div', {
19685
19740
  key: 'tl',
19686
19741
  class: 'vxe-tree--line-wrapper'
19687
19742
  }, [h('div', {
19688
19743
  class: 'vxe-tree--line',
19689
19744
  style: {
19690
- height: `${getRowid($xeTable, afterFullData[0]) === rowid ? 1 : calcTreeLine(params, prevRow)}px`,
19745
+ height: lineHeight,
19691
19746
  bottom: `-${Math.floor(cellHeight / 2)}px`,
19692
- left: `${rLevel * treeOpts.indent + (rLevel ? 2 - getOffsetSize($xeTable) : 0) + 16}px`
19747
+ left: `calc(${rLevel * treeOpts.indent}px + 1em)`
19693
19748
  }
19694
19749
  })])];
19695
19750
  }
@@ -31737,7 +31792,6 @@ function renderBody(h, $xeTable) {
31737
31792
  exportConfig,
31738
31793
  importConfig,
31739
31794
  treeConfig,
31740
- showOverflow,
31741
31795
  highlightCurrentRow,
31742
31796
  highlightCurrentColumn
31743
31797
  } = props;
@@ -31779,9 +31833,9 @@ function renderBody(h, $xeTable) {
31779
31833
  if (props.editConfig && editOpts.showStatus && !props.keepSource) {
31780
31834
  warnLog('vxe.error.reqProp', ['keep-source']);
31781
31835
  }
31782
- if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
31783
- warnLog('vxe.error.reqProp', ['show-overflow']);
31784
- }
31836
+ // if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
31837
+ // warnLog('vxe.error.reqProp', ['show-overflow'])
31838
+ // }
31785
31839
  if (treeConfig && !treeOpts.transform && props.stripe) {
31786
31840
  warnLog('vxe.error.noTree', ['stripe']);
31787
31841
  }