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
@@ -1,7 +1,7 @@
1
1
  import XEUtils from 'xe-utils';
2
2
  import { VxeUI } from '../../ui';
3
3
  import { isEnableConf, getClass } from '../../ui/src/utils';
4
- import { getOffsetSize, calcTreeLine, getRowid, createHandleGetRowId, getCellRestHeight } from './util';
4
+ import { getRowid, createHandleGetRowId, getCellRestHeight } from './util';
5
5
  import { updateCellTitle } from '../../ui/src/dom';
6
6
  import { getSlotVNs } from '../../ui/src/vn';
7
7
  const { getI18n, renderer, renderEmptyElement } = VxeUI;
@@ -19,22 +19,38 @@ function renderLine(h, $xeTable, rowid, params, cellHeight) {
19
19
  const tableProps = $xeTable;
20
20
  const tableInternalData = $xeTable;
21
21
  const { column } = params;
22
- const { afterFullData } = tableInternalData;
23
22
  const { treeConfig } = tableProps;
23
+ const cellOpts = $xeTable.computeCellOpts;
24
+ const rowOpts = $xeTable.computeRowOpts;
25
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
24
26
  const treeOpts = $xeTable.computeTreeOpts;
25
27
  const { slots, treeNode } = column;
26
28
  const { fullAllDataRowIdData } = tableInternalData;
27
- if (slots && slots.line) {
28
- return $xeTable.callSlot(slots.line, params, h);
29
- }
30
- const rowRest = fullAllDataRowIdData[rowid];
31
- let rLevel = 0;
32
- let prevRow = null;
33
- if (rowRest) {
34
- rLevel = rowRest.level;
35
- prevRow = rowRest.items[rowRest.treeIndex - 1];
36
- }
37
29
  if (treeConfig && treeNode && (treeOpts.showLine || treeOpts.line)) {
30
+ if (slots && slots.line) {
31
+ return $xeTable.callSlot(slots.line, params, h);
32
+ }
33
+ const rowRest = fullAllDataRowIdData[rowid];
34
+ let rLevel = 0;
35
+ let prevRow = null;
36
+ let parentRow = null;
37
+ let lineHeight = '';
38
+ if (rowRest) {
39
+ rLevel = rowRest.level;
40
+ prevRow = rowRest.items[rowRest.treeIndex - 1];
41
+ parentRow = rowRest.parent;
42
+ }
43
+ if (!rLevel && !treeOpts.showRootLine) {
44
+ return [];
45
+ }
46
+ if (prevRow) {
47
+ const prevRowRest = fullAllDataRowIdData[getRowid($xeTable, prevRow)] || {};
48
+ lineHeight = `${prevRowRest.lineHeight || 0}px`;
49
+ }
50
+ else if (rLevel && parentRow) {
51
+ const parentRowRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)] || {};
52
+ lineHeight = `calc(-1em + ${Math.floor(cellHeight / 2 + getCellRestHeight(parentRowRest, cellOpts, rowOpts, defaultRowHeight) / 2)}px)`;
53
+ }
38
54
  return [
39
55
  h('div', {
40
56
  key: 'tl',
@@ -43,9 +59,9 @@ function renderLine(h, $xeTable, rowid, params, cellHeight) {
43
59
  h('div', {
44
60
  class: 'vxe-tree--line',
45
61
  style: {
46
- height: `${getRowid($xeTable, afterFullData[0]) === rowid ? 1 : calcTreeLine(params, prevRow)}px`,
62
+ height: lineHeight,
47
63
  bottom: `-${Math.floor(cellHeight / 2)}px`,
48
- left: `${(rLevel * treeOpts.indent) + (rLevel ? 2 - getOffsetSize($xeTable) : 0) + 16}px`
64
+ left: `calc(${(rLevel * treeOpts.indent)}px + 1em)`
49
65
  }
50
66
  })
51
67
  ])
@@ -2424,6 +2424,9 @@ function autoCellWidth($xeTable) {
2424
2424
  updateColumnOffsetLeft($xeTable);
2425
2425
  updateHeight($xeTable);
2426
2426
  }
2427
+ /**
2428
+ * 计算自适应行高
2429
+ */
2427
2430
  const calcCellAutoHeight = (rowRest, wrapperEl) => {
2428
2431
  const cellElemList = wrapperEl.querySelectorAll(`.vxe-cell--wrapper[rowid="${rowRest.rowid}"]`);
2429
2432
  let colHeight = rowRest.height;
@@ -2441,14 +2444,20 @@ const calcCellAutoHeight = (rowRest, wrapperEl) => {
2441
2444
  }
2442
2445
  return colHeight;
2443
2446
  };
2447
+ /**
2448
+ * 自适应行高
2449
+ */
2444
2450
  const calcCellHeight = ($xeTable) => {
2451
+ const props = $xeTable;
2445
2452
  const reactData = $xeTable;
2446
2453
  const internalData = $xeTable;
2454
+ const { treeConfig } = props;
2447
2455
  const { tableData, isAllOverflow, scrollYLoad, scrollXLoad } = reactData;
2448
2456
  const { fullAllDataRowIdData } = internalData;
2457
+ const treeOpts = $xeTable.computeTreeOpts;
2449
2458
  const defaultRowHeight = $xeTable.computeDefaultRowHeight;
2450
2459
  const el = $xeTable.$refs.refElem;
2451
- if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
2460
+ if (!isAllOverflow && (scrollYLoad || scrollXLoad || (treeConfig && treeOpts.showLine)) && el) {
2452
2461
  const { handleGetRowId } = createHandleGetRowId($xeTable);
2453
2462
  tableData.forEach(row => {
2454
2463
  const rowid = handleGetRowId(row);
@@ -3286,6 +3295,7 @@ function loadTableData($xeTable, datas, isReset) {
3286
3295
  }
3287
3296
  reactData.isRowLoading = false;
3288
3297
  handleRecalculateStyle($xeTable, false, false, false);
3298
+ updateTreeLineStyle($xeTable);
3289
3299
  // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
3290
3300
  if (!props.showOverflow) {
3291
3301
  setTimeout(() => {
@@ -3299,6 +3309,7 @@ function loadTableData($xeTable, datas, isReset) {
3299
3309
  .then(() => {
3300
3310
  handleRecalculateStyle($xeTable, false, true, true);
3301
3311
  updateRowOffsetTop($xeTable);
3312
+ updateTreeLineStyle($xeTable);
3302
3313
  resolve();
3303
3314
  });
3304
3315
  }
@@ -3308,6 +3319,7 @@ function loadTableData($xeTable, datas, isReset) {
3308
3319
  .then(() => {
3309
3320
  handleRecalculateStyle($xeTable, false, true, true);
3310
3321
  updateRowOffsetTop($xeTable);
3322
+ updateTreeLineStyle($xeTable);
3311
3323
  resolve();
3312
3324
  });
3313
3325
  });
@@ -3790,6 +3802,9 @@ function updateHeight($xeTable) {
3790
3802
  internalData.customHeight = 300;
3791
3803
  }
3792
3804
  }
3805
+ /**
3806
+ * 计算自适应列宽
3807
+ */
3793
3808
  function calcColumnAutoWidth($xeTable, column, wrapperEl) {
3794
3809
  const columnOpts = $xeTable.computeColumnOpts;
3795
3810
  const { autoOptions } = columnOpts;
@@ -3818,6 +3833,9 @@ function calcColumnAutoWidth($xeTable, column, wrapperEl) {
3818
3833
  }
3819
3834
  return colWidth + leftRightPadding;
3820
3835
  }
3836
+ /**
3837
+ * 自适应列宽
3838
+ */
3821
3839
  function calcCellWidth($xeTable) {
3822
3840
  const internalData = $xeTable;
3823
3841
  const autoWidthColumnList = $xeTable.computeAutoWidthColumnList;
@@ -3958,9 +3976,93 @@ function updateRowExpandStyle($xeTable) {
3958
3976
  /**
3959
3977
  * 更新树连接线样式
3960
3978
  */
3961
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3962
3979
  function updateTreeLineStyle($xeTable) {
3963
- // 待优化
3980
+ const props = $xeTable;
3981
+ const reactData = $xeTable;
3982
+ const internalData = $xeTable;
3983
+ const { treeConfig } = props;
3984
+ if (!treeConfig) {
3985
+ return;
3986
+ }
3987
+ const { tableData } = reactData;
3988
+ const { fullAllDataRowIdData, treeExpandedMaps } = internalData;
3989
+ const cellOpts = $xeTable.computeCellOpts;
3990
+ const rowOpts = $xeTable.computeRowOpts;
3991
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
3992
+ const treeOpts = $xeTable.computeTreeOpts;
3993
+ const { transform, mapChildrenField } = treeOpts;
3994
+ const childrenField = treeOpts.children || treeOpts.childrenField;
3995
+ const { handleGetRowId } = createHandleGetRowId($xeTable);
3996
+ const expParentList = [];
3997
+ const handleNodeRow = (row, rIndex, rows) => {
3998
+ const rowid = handleGetRowId(row);
3999
+ const rowRest = fullAllDataRowIdData[rowid] || {};
4000
+ const childList = row[transform ? mapChildrenField : childrenField];
4001
+ const prevRow = rows[rIndex - 1] || null;
4002
+ const nextRow = rows[rIndex + 1] || null;
4003
+ if (childList && childList.length && treeExpandedMaps[rowid]) {
4004
+ expParentList.push({ row, prevRow, nextRow });
4005
+ childList.forEach((childRow, crIndex) => {
4006
+ const childRowid = handleGetRowId(childRow);
4007
+ if (treeExpandedMaps[childRowid]) {
4008
+ handleNodeRow(childRow, crIndex, childList);
4009
+ }
4010
+ });
4011
+ }
4012
+ else {
4013
+ if (nextRow) {
4014
+ const nextRowid = handleGetRowId(nextRow);
4015
+ const nextRowRest = fullAllDataRowIdData[nextRowid] || {};
4016
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
4017
+ const nextCellHeight = getCellRestHeight(nextRowRest, cellOpts, rowOpts, defaultRowHeight);
4018
+ rowRest.oHeight = currCellHeight;
4019
+ rowRest.lineHeight = Math.floor(currCellHeight / 2 + nextCellHeight / 2);
4020
+ }
4021
+ else {
4022
+ rowRest.oHeight = 0;
4023
+ rowRest.lineHeight = 0;
4024
+ }
4025
+ }
4026
+ };
4027
+ tableData.forEach((row, rIndex) => {
4028
+ handleNodeRow(row, rIndex, tableData);
4029
+ });
4030
+ XEUtils.lastArrayEach(expParentList, ({ row, nextRow }) => {
4031
+ const rowid = handleGetRowId(row);
4032
+ const childList = row[transform ? mapChildrenField : childrenField];
4033
+ const rowRest = fullAllDataRowIdData[rowid];
4034
+ if (rowRest) {
4035
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
4036
+ let countOffsetHeight = currCellHeight;
4037
+ let countLineHeight = 0;
4038
+ childList.forEach((childRow) => {
4039
+ const childRowid = handleGetRowId(childRow);
4040
+ const childRowRest = fullAllDataRowIdData[childRowid] || {};
4041
+ const childList = childRow[transform ? mapChildrenField : childrenField];
4042
+ if (treeExpandedMaps[childRowid] && childList && childList.length) {
4043
+ countOffsetHeight += (childRowRest.oHeight || 0);
4044
+ countLineHeight += (childRowRest.oHeight || 0);
4045
+ }
4046
+ else {
4047
+ const cellHeight = getCellRestHeight(childRowRest, cellOpts, rowOpts, defaultRowHeight);
4048
+ childRowRest.oHeight = cellHeight;
4049
+ childRowRest.lineHeight = cellHeight;
4050
+ countOffsetHeight += cellHeight;
4051
+ countLineHeight += cellHeight;
4052
+ }
4053
+ });
4054
+ if (nextRow) {
4055
+ const nextRowid = handleGetRowId(nextRow);
4056
+ const nextRowRest = fullAllDataRowIdData[nextRowid] || {};
4057
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
4058
+ const nextCellHeight = getCellRestHeight(nextRowRest, cellOpts, rowOpts, defaultRowHeight);
4059
+ countOffsetHeight += currCellHeight;
4060
+ countLineHeight += Math.floor(currCellHeight / 2 + nextCellHeight / 2);
4061
+ }
4062
+ rowRest.lineHeight = countLineHeight;
4063
+ rowRest.oHeight = countOffsetHeight;
4064
+ }
4065
+ });
3964
4066
  }
3965
4067
  function handleRowExpandScroll($xeTable) {
3966
4068
  const internalData = $xeTable;
@@ -1511,7 +1511,7 @@ export default {
1511
1511
  const internalData = $xeTable;
1512
1512
  XEUtils.assign(internalData, createInternalData());
1513
1513
  handleKeyField($xeTable);
1514
- const { data, exportConfig, importConfig, treeConfig, showOverflow, highlightCurrentRow, highlightCurrentColumn } = props;
1514
+ const { data, exportConfig, importConfig, treeConfig, highlightCurrentRow, highlightCurrentColumn } = props;
1515
1515
  const { scrollXStore, scrollYStore } = internalData;
1516
1516
  const columnOpts = $xeTable.computeColumnOpts;
1517
1517
  const editOpts = $xeTable.computeEditOpts;
@@ -1545,9 +1545,9 @@ export default {
1545
1545
  if (props.editConfig && editOpts.showStatus && !props.keepSource) {
1546
1546
  warnLog('vxe.error.reqProp', ['keep-source']);
1547
1547
  }
1548
- if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
1549
- warnLog('vxe.error.reqProp', ['show-overflow']);
1550
- }
1548
+ // if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
1549
+ // warnLog('vxe.error.reqProp', ['show-overflow'])
1550
+ // }
1551
1551
  if (treeConfig && !treeOpts.transform && props.stripe) {
1552
1552
  warnLog('vxe.error.noTree', ['stripe']);
1553
1553
  }
@@ -503,67 +503,6 @@ export function getLastChildColumn(column) {
503
503
  }
504
504
  return column;
505
505
  }
506
- const lineOffsetSizes = {
507
- mini: 3,
508
- small: 2,
509
- medium: 1,
510
- large: 0
511
- };
512
- function countTreeExpandSize(prevRow, params) {
513
- let count = 1;
514
- if (!prevRow) {
515
- return count;
516
- }
517
- const { $table } = params;
518
- const reactData = $table;
519
- const { treeExpandedFlag } = reactData;
520
- const internalData = $table;
521
- const { treeExpandedMaps } = internalData;
522
- const treeOpts = $table.computeTreeOpts;
523
- const { transform, mapChildrenField } = treeOpts;
524
- const childrenField = treeOpts.children || treeOpts.childrenField;
525
- const rowChildren = prevRow[transform ? mapChildrenField : childrenField];
526
- if (rowChildren && treeExpandedFlag && treeExpandedMaps[getRowid($table, prevRow)]) {
527
- for (let index = 0; index < rowChildren.length; index++) {
528
- count += countTreeExpandSize(rowChildren[index], params);
529
- }
530
- }
531
- return count;
532
- }
533
- export function getOffsetSize($xeTable) {
534
- const vSize = $xeTable.computeSize;
535
- if (vSize) {
536
- return lineOffsetSizes[vSize] || 0;
537
- }
538
- return 0;
539
- }
540
- export function calcTreeLine(params, prevRow) {
541
- const { $table, row } = params;
542
- const tableProps = $table;
543
- const tableReactData = $table;
544
- const tableInternalData = $table;
545
- const { showOverflow } = tableProps;
546
- const { scrollYLoad } = tableReactData;
547
- const { fullAllDataRowIdData } = tableInternalData;
548
- const rowOpts = $table.computeRowOpts;
549
- const cellOpts = $table.computeCellOpts;
550
- const defaultRowHeight = $table.computeDefaultRowHeight;
551
- const rowid = getRowid($table, row);
552
- const rowRest = fullAllDataRowIdData[rowid];
553
- const currCellHeight = rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight;
554
- let expandSize = 1;
555
- if (prevRow) {
556
- expandSize = countTreeExpandSize(prevRow, params);
557
- }
558
- let cellHeight = currCellHeight;
559
- const vnHeight = rowRest.height;
560
- if (scrollYLoad) {
561
- if (!showOverflow) {
562
- cellHeight = vnHeight || currCellHeight;
563
- }
564
- }
565
- return cellHeight * expandSize - (prevRow ? 1 : (12 - getOffsetSize($table)));
566
- }
567
506
  export function getCellValue(row, column) {
568
507
  return XEUtils.get(row, column.field);
569
508
  }
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
- export const version = "3.19.3";
3
+ export const version = "3.19.4";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
@@ -173,7 +173,8 @@ VxeUI.setConfig({
173
173
  hasChildField: 'hasChild',
174
174
  mapChildrenField: '_X_ROW_CHILD',
175
175
  indent: 20,
176
- showIcon: true
176
+ showIcon: true,
177
+ showRootLine: true
177
178
  },
178
179
  expandConfig: {
179
180
  // trigger: 'default',
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"3.19.3"}`;
3
+ const version = `table v${"3.19.4"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);