vxe-table 4.19.5 → 4.19.7

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 (39) hide show
  1. package/dist/all.esm.js +126 -33
  2. package/dist/style.css +1 -1
  3. package/es/style.css +1 -1
  4. package/es/table/src/body.js +11 -11
  5. package/es/table/src/emits.js +1 -0
  6. package/es/table/src/group.js +3 -0
  7. package/es/table/src/table.js +68 -17
  8. package/es/table/src/util.js +27 -8
  9. package/es/ui/index.js +1 -1
  10. package/es/ui/src/log.js +1 -1
  11. package/lib/index.umd.js +68 -40
  12. package/lib/index.umd.min.js +1 -1
  13. package/lib/style.css +1 -1
  14. package/lib/table/src/body.js +11 -11
  15. package/lib/table/src/body.min.js +1 -1
  16. package/lib/table/src/emits.js +1 -1
  17. package/lib/table/src/emits.min.js +1 -1
  18. package/lib/table/src/group.js +3 -0
  19. package/lib/table/src/group.min.js +1 -1
  20. package/lib/table/src/table.js +19 -16
  21. package/lib/table/src/table.min.js +1 -1
  22. package/lib/table/src/util.js +30 -7
  23. package/lib/table/src/util.min.js +1 -1
  24. package/lib/ui/index.js +1 -1
  25. package/lib/ui/index.min.js +1 -1
  26. package/lib/ui/src/log.js +1 -1
  27. package/lib/ui/src/log.min.js +1 -1
  28. package/package.json +2 -2
  29. package/packages/table/src/body.ts +13 -13
  30. package/packages/table/src/emits.ts +1 -0
  31. package/packages/table/src/group.ts +4 -0
  32. package/packages/table/src/table.ts +73 -18
  33. package/packages/table/src/util.ts +26 -8
  34. /package/es/{iconfont.1780200147870.ttf → iconfont.1780638747281.ttf} +0 -0
  35. /package/es/{iconfont.1780200147870.woff → iconfont.1780638747281.woff} +0 -0
  36. /package/es/{iconfont.1780200147870.woff2 → iconfont.1780638747281.woff2} +0 -0
  37. /package/lib/{iconfont.1780200147870.ttf → iconfont.1780638747281.ttf} +0 -0
  38. /package/lib/{iconfont.1780200147870.woff → iconfont.1780638747281.woff} +0 -0
  39. /package/lib/{iconfont.1780200147870.woff2 → iconfont.1780638747281.woff2} +0 -0
@@ -345,21 +345,11 @@ export default defineVxeComponent({
345
345
  class: 'vxe-cell--wrapper vxe-body-cell--wrapper'
346
346
  }, column.renderCell(cellParams)));
347
347
  }
348
- tdVNs.push(h('div', {
349
- key: 'tc',
350
- class: ['vxe-cell', {
351
- 'c--title': showTitle,
352
- 'c--tooltip': showTooltip,
353
- 'c--ellipsis': showEllipsis
354
- }],
355
- style: tcStyle,
356
- title: showTitle ? $xeTable.getCellLabel(row, column) : null
357
- }, clVNs));
358
348
  if (showValidTip && errorValidItem) {
359
349
  const errRule = errorValidItem.rule;
360
350
  const validSlot = slots ? slots.valid : null;
361
351
  const validParams = Object.assign(Object.assign(Object.assign({}, cellParams), errorValidItem), { rule: errorValidItem });
362
- tdVNs.push(h('div', {
352
+ clVNs.push(h('div', {
363
353
  key: 'tcv',
364
354
  class: ['vxe-cell--valid-error-tip', getPropClass(validOpts.className, validParams)],
365
355
  style: errRule && errRule.maxWidth
@@ -381,6 +371,16 @@ export default defineVxeComponent({
381
371
  ])
382
372
  ]));
383
373
  }
374
+ tdVNs.push(h('div', {
375
+ key: 'tc',
376
+ class: ['vxe-cell', {
377
+ 'c--title': showTitle,
378
+ 'c--tooltip': showTooltip,
379
+ 'c--ellipsis': showEllipsis
380
+ }],
381
+ style: tcStyle,
382
+ title: showTitle ? $xeTable.getCellLabel(row, column) : null
383
+ }, clVNs));
384
384
  }
385
385
  let showAreaRowStatus = false;
386
386
  if (mouseConfig && mouseOpts.area && !_columnIndex && selectCellToRow) {
@@ -106,6 +106,7 @@ export const tableEmits = [
106
106
  'cell-area-selection-all-end',
107
107
  'cell-area-arrows-start',
108
108
  'cell-area-arrows-end',
109
+ 'cell-area-fill-copy',
109
110
  'active-cell-change-start',
110
111
  'active-cell-change-end'
111
112
  ];
@@ -18,6 +18,9 @@ export default defineVxeComponent({
18
18
  if (slots.header) {
19
19
  columnSlots.header = slots.header;
20
20
  }
21
+ if (slots.title) {
22
+ columnSlots.title = slots.title;
23
+ }
21
24
  columnConfig.slots = columnSlots;
22
25
  columnConfig.children = [];
23
26
  watchColumn($xeTable, props, columnConfig);
@@ -4,7 +4,7 @@ import XEUtils from 'xe-utils';
4
4
  import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, wheelScrollTopTo, wheelScrollLeftTo, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey, checkTargetElement, hasEventInputTarget } from '../../ui/src/dom';
5
5
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
6
6
  import { VxeUI } from '../../ui';
7
- import { createReactData, createInternalData, getRowUniqueId, createRowId, clearTableAllStatus, getColumnList, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight, getLastChildColumn } from './util';
7
+ import { createReactData, createInternalData, getRowUniqueId, createRowId, clearTableAllStatus, getColumnList, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, getColReMaxWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight, getLastChildColumn } from './util';
8
8
  import { getSlotVNs } from '../../ui/src/vn';
9
9
  import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from '../../ui/src/anime';
10
10
  import { warnLog, errLog } from '../../ui/src/log';
@@ -1830,6 +1830,7 @@ export default defineVxeComponent({
1830
1830
  if (!xHandleEl) {
1831
1831
  return;
1832
1832
  }
1833
+ const columnOpts = computeColumnOpts.value;
1833
1834
  let tWidth = 0;
1834
1835
  const minCellWidth = 40; // 列宽最少限制 40px
1835
1836
  const bodyWidth = bodyWrapperElem.clientWidth;
@@ -1838,39 +1839,73 @@ export default defineVxeComponent({
1838
1839
  const { fit } = props;
1839
1840
  const { columnStore } = reactData;
1840
1841
  const { resizeList, pxMinList, autoMinList, pxList, scaleList, scaleMinList, autoList, remainList } = columnStore;
1842
+ const parseColumnMaxWidth = (column) => {
1843
+ const maxWidth = column.maxWidth || columnOpts.maxWidth;
1844
+ if (maxWidth && maxWidth !== 'auto') {
1845
+ if (isScale(maxWidth)) {
1846
+ return Math.floor(XEUtils.toInteger(maxWidth) * meanWidth);
1847
+ }
1848
+ return XEUtils.toInteger(maxWidth);
1849
+ }
1850
+ return 0;
1851
+ };
1841
1852
  // 最小宽
1842
1853
  pxMinList.forEach((column) => {
1843
- const minWidth = XEUtils.toInteger(column.minWidth);
1844
- tWidth += minWidth;
1845
- column.renderWidth = minWidth;
1854
+ let miWidth = XEUtils.toInteger(column.minWidth);
1855
+ const mxWidth = parseColumnMaxWidth(column);
1856
+ if (mxWidth) {
1857
+ miWidth = Math.min(miWidth, mxWidth);
1858
+ }
1859
+ tWidth += miWidth;
1860
+ column.renderWidth = miWidth;
1846
1861
  });
1847
1862
  // 最小自适应
1848
1863
  autoMinList.forEach((column) => {
1849
- const caWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
1864
+ let caWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
1865
+ const mxWidth = parseColumnMaxWidth(column);
1866
+ if (mxWidth) {
1867
+ caWidth = Math.min(caWidth, mxWidth);
1868
+ }
1850
1869
  tWidth += caWidth;
1851
1870
  column.renderWidth = caWidth;
1852
1871
  });
1853
1872
  // 最小百分比
1854
1873
  scaleMinList.forEach((column) => {
1855
- const smWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth);
1874
+ let smWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth);
1875
+ const mxWidth = parseColumnMaxWidth(column);
1876
+ if (mxWidth) {
1877
+ smWidth = Math.min(smWidth, mxWidth);
1878
+ }
1856
1879
  tWidth += smWidth;
1857
1880
  column.renderWidth = smWidth;
1858
1881
  });
1859
1882
  // 固定百分比
1860
1883
  scaleList.forEach((column) => {
1861
- const sfWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth);
1884
+ let sfWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth);
1885
+ const mxWidth = parseColumnMaxWidth(column);
1886
+ if (mxWidth) {
1887
+ sfWidth = Math.min(sfWidth, mxWidth);
1888
+ }
1862
1889
  tWidth += sfWidth;
1863
1890
  column.renderWidth = sfWidth;
1864
1891
  });
1865
1892
  // 固定宽
1866
1893
  pxList.forEach((column) => {
1867
- const pWidth = XEUtils.toInteger(column.width);
1894
+ let pWidth = XEUtils.toInteger(column.width);
1895
+ const mxWidth = parseColumnMaxWidth(column);
1896
+ if (mxWidth) {
1897
+ pWidth = Math.min(pWidth, mxWidth);
1898
+ }
1868
1899
  tWidth += pWidth;
1869
1900
  column.renderWidth = pWidth;
1870
1901
  });
1871
1902
  // 自适应宽
1872
1903
  autoList.forEach((column) => {
1873
- const aWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
1904
+ let aWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
1905
+ const mxWidth = parseColumnMaxWidth(column);
1906
+ if (mxWidth) {
1907
+ aWidth = Math.min(aWidth, mxWidth);
1908
+ }
1874
1909
  tWidth += aWidth;
1875
1910
  column.renderWidth = aWidth;
1876
1911
  });
@@ -1880,11 +1915,12 @@ export default defineVxeComponent({
1880
1915
  tWidth += reWidth;
1881
1916
  column.renderWidth = reWidth;
1882
1917
  });
1918
+ const zoomColumnList = scaleMinList.concat(pxMinList).concat(autoMinList).filter(column => !parseColumnMaxWidth(column));
1883
1919
  remainWidth -= tWidth;
1884
- meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoMinList.length + remainList.length)) : 0;
1920
+ meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (zoomColumnList.length + remainList.length)) : 0;
1885
1921
  if (fit) {
1886
1922
  if (remainWidth > 0) {
1887
- scaleMinList.concat(pxMinList).concat(autoMinList).forEach((column) => {
1923
+ zoomColumnList.forEach((column) => {
1888
1924
  tWidth += meanWidth;
1889
1925
  column.renderWidth += meanWidth;
1890
1926
  });
@@ -1903,8 +1939,9 @@ export default defineVxeComponent({
1903
1939
  /**
1904
1940
  * 偏移量算法
1905
1941
  * 如果所有列足够放的情况下,从最后动态列开始分配
1942
+ * 排除已设置 max-width
1906
1943
  */
1907
- const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList);
1944
+ const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList).filter(column => !parseColumnMaxWidth(column));
1908
1945
  let dynamicSize = dynamicList.length - 1;
1909
1946
  if (dynamicSize > 0) {
1910
1947
  let i = bodyWidth - tWidth;
@@ -2400,7 +2437,7 @@ export default defineVxeComponent({
2400
2437
  xScrollbarVisible = 'hidden';
2401
2438
  }
2402
2439
  let yScrollbarVisible = overflowY ? 'visible' : 'hidden';
2403
- if ((scrollbarYConf.visible === 'hidden' || scrollbarYConf.visible === false) || ($xeGanttView && !scrollbarYToLeft)) {
2440
+ if ((scrollbarYConf.visible === 'hidden' || scrollbarYConf.visible === false) || (($xeGantt && $xeGanttView && $xeGantt.reactData.showRightView) && !scrollbarYToLeft)) {
2404
2441
  osbWidth = 0;
2405
2442
  yScrollbarVisible = 'hidden';
2406
2443
  }
@@ -3707,6 +3744,7 @@ export default defineVxeComponent({
3707
3744
  updateStyle();
3708
3745
  }).then(() => {
3709
3746
  computeScrollLoad();
3747
+ syncGanttScrollYStatus();
3710
3748
  }).then(() => {
3711
3749
  const virtualYOpts = computeVirtualYOpts.value;
3712
3750
  // 是否启用了虚拟滚动
@@ -3766,6 +3804,7 @@ export default defineVxeComponent({
3766
3804
  reactData.isRowLoading = false;
3767
3805
  handleRecalculateStyle(false, false, false);
3768
3806
  updateTreeLineStyle();
3807
+ syncGanttScrollYStatus();
3769
3808
  // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
3770
3809
  if (!props.showOverflow) {
3771
3810
  setTimeout(() => {
@@ -4085,9 +4124,14 @@ export default defineVxeComponent({
4085
4124
  reactData.scrollXLoad = scrollXLoad;
4086
4125
  return scrollXLoad;
4087
4126
  };
4127
+ const syncGanttScrollYStatus = () => {
4128
+ const $xeGanttView = internalData.xeGanttView;
4129
+ if ($xeGanttView && $xeGanttView.handleUpdateSYStatus) {
4130
+ $xeGanttView.handleUpdateSYStatus(reactData.scrollYLoad);
4131
+ }
4132
+ };
4088
4133
  const updateScrollYStatus = (fullData) => {
4089
4134
  const { treeConfig } = props;
4090
- const $xeGanttView = internalData.xeGanttView;
4091
4135
  const virtualYOpts = computeVirtualYOpts.value;
4092
4136
  const treeOpts = computeTreeOpts.value;
4093
4137
  const { transform } = treeOpts;
@@ -4095,9 +4139,7 @@ export default defineVxeComponent({
4095
4139
  // 如果gt为0,则总是启用
4096
4140
  const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length);
4097
4141
  reactData.scrollYLoad = scrollYLoad;
4098
- if ($xeGanttView && $xeGanttView.handleUpdateSYStatus) {
4099
- $xeGanttView.handleUpdateSYStatus(scrollYLoad);
4100
- }
4142
+ syncGanttScrollYStatus();
4101
4143
  return scrollYLoad;
4102
4144
  };
4103
4145
  /**
@@ -9398,6 +9440,7 @@ export default defineVxeComponent({
9398
9440
  const dragBtnOffsetWidth = XEUtils.floor(dragBtnWidth / 2);
9399
9441
  const dragPosLeft = dragBtnRect.x - tableRect.x + dragBtnOffsetWidth;
9400
9442
  const minInterval = getColReMinWidth(cellParams) - dragBtnOffsetWidth; // 列之间的最小间距
9443
+ const maxInterval = getColReMaxWidth(cellParams); // 列之间的最大间距
9401
9444
  const dragMinLeft = isRightFixed ? 0 : (cellRect.x - tableRect.x + dragBtnWidth + minInterval);
9402
9445
  const dragMaxLeft = cellRect.x - tableRect.x + cell.clientWidth - minInterval;
9403
9446
  let fixedLeftRemainWidth = 0;
@@ -9437,6 +9480,10 @@ export default defineVxeComponent({
9437
9480
  left = Math.min(left, dragMaxLeft);
9438
9481
  }
9439
9482
  dragLeft = Math.max(left, dragMinLeft);
9483
+ // 最大宽
9484
+ if (maxInterval > 1) {
9485
+ dragLeft = Math.min(dragLeft, maxInterval + dragMinLeft - minInterval);
9486
+ }
9440
9487
  const resizeBarLeft = Math.max(1, dragLeft);
9441
9488
  resizeBarElem.style.left = `${resizeBarLeft}px`;
9442
9489
  resizeBarElem.style.top = `${scrollbarXToTop ? osbHeight : 0}px`;
@@ -9517,6 +9564,7 @@ export default defineVxeComponent({
9517
9564
  const cell = dragBtnElem.parentNode;
9518
9565
  const cellParams = Object.assign(params, { cell, $table: $xeTable });
9519
9566
  const colMinWidth = getColReMinWidth(cellParams);
9567
+ const colMaxWidth = getColReMaxWidth(cellParams);
9520
9568
  el.setAttribute('data-calc-col', 'Y');
9521
9569
  let resizeWidth = calcColumnAutoWidth(resizeColumn, el);
9522
9570
  el.removeAttribute('data-calc-col');
@@ -9524,6 +9572,9 @@ export default defineVxeComponent({
9524
9572
  resizeWidth = Math.max(resizeWidth, colRest.width);
9525
9573
  }
9526
9574
  resizeWidth = Math.max(colMinWidth, resizeWidth);
9575
+ if (colMaxWidth > 1) {
9576
+ resizeWidth = Math.min(colMaxWidth, resizeWidth);
9577
+ }
9527
9578
  const resizeParams = Object.assign(Object.assign({}, params), { resizeWidth, resizeColumn });
9528
9579
  reactData.isDragResize = false;
9529
9580
  internalData._lastResizeTime = Date.now();
@@ -683,14 +683,16 @@ export function getCalcHeight(height) {
683
683
  }
684
684
  /**
685
685
  * 列宽拖动最大宽度
686
- * @param params
687
- * @returns
688
686
  */
689
687
  export function getColReMaxWidth(params) {
690
- const { $table } = params;
691
- const { computeResizableOpts } = $table.getComputeMaps();
688
+ const { $table, column, cell } = params;
689
+ const internalData = $table.internalData;
690
+ const { elemStore } = internalData;
691
+ const { computeColumnOpts, computeResizableOpts } = $table.getComputeMaps();
692
692
  const resizableOpts = computeResizableOpts.value;
693
+ const columnOpts = computeColumnOpts.value;
693
694
  const { maxWidth: reMaxWidth } = resizableOpts;
695
+ const colMaxWidth = column.maxWidth || columnOpts.maxWidth;
694
696
  // 如果自定义调整宽度逻辑
695
697
  if (reMaxWidth) {
696
698
  const customMaxWidth = XEUtils.isFunction(reMaxWidth) ? reMaxWidth(params) : reMaxWidth;
@@ -698,19 +700,35 @@ export function getColReMaxWidth(params) {
698
700
  return Math.max(1, XEUtils.toNumber(customMaxWidth));
699
701
  }
700
702
  }
703
+ const minTitleWidth = XEUtils.floor((XEUtils.toNumber(getComputedStyle(cell).fontSize) || 14) * 1.8);
704
+ const paddingLeftRight = getPaddingLeftRightSize(cell) + getPaddingLeftRightSize(queryElement(cell, '.vxe-cell'));
705
+ const mWidth = minTitleWidth + paddingLeftRight;
706
+ // 如果设置最小宽
707
+ if (colMaxWidth) {
708
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
709
+ if (bodyScrollElem) {
710
+ if (isScale(colMaxWidth)) {
711
+ const bodyWidth = bodyScrollElem.clientWidth - 1;
712
+ const meanWidth = bodyWidth / 100;
713
+ return Math.max(mWidth, Math.floor(XEUtils.toInteger(colMaxWidth) * meanWidth));
714
+ }
715
+ else if (isPx(colMaxWidth)) {
716
+ return Math.max(mWidth, XEUtils.toInteger(colMaxWidth));
717
+ }
718
+ }
719
+ }
701
720
  return -1;
702
721
  }
703
722
  /**
704
723
  * 列宽拖动最小宽度
705
- * @param params
706
- * @returns
707
724
  */
708
725
  export function getColReMinWidth(params) {
709
726
  const { $table, column, cell } = params;
710
727
  const tableProps = $table.props;
711
728
  const internalData = $table.internalData;
712
- const { computeResizableOpts } = $table.getComputeMaps();
729
+ const { computeColumnOpts, computeResizableOpts } = $table.getComputeMaps();
713
730
  const resizableOpts = computeResizableOpts.value;
731
+ const columnOpts = computeColumnOpts.value;
714
732
  const { minWidth: reMinWidth } = resizableOpts;
715
733
  // 如果自定义调整宽度逻辑
716
734
  if (reMinWidth) {
@@ -721,7 +739,8 @@ export function getColReMinWidth(params) {
721
739
  }
722
740
  const { elemStore } = internalData;
723
741
  const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps;
724
- const { showHeaderOverflow, minWidth: colMinWidth } = column;
742
+ const { showHeaderOverflow } = column;
743
+ const colMinWidth = column.minWidth || columnOpts.minWidth;
725
744
  const headOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
726
745
  const showEllipsis = headOverflow === 'ellipsis';
727
746
  const showTitle = headOverflow === 'title';
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 = "4.19.5";
3
+ export const version = "4.19.7";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
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${"4.19.5"}`;
3
+ const version = `table v${"4.19.7"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);