vxe-table 4.19.5 → 4.19.6

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/dist/all.esm.js CHANGED
@@ -44,7 +44,7 @@ function eqEmptyValue(cellValue) {
44
44
  return cellValue === '' || XEUtils.eqNull(cellValue);
45
45
  }
46
46
 
47
- const version$1 = "4.19.5";
47
+ const version$1 = "4.19.6";
48
48
  VxeUI.version = version$1;
49
49
  VxeUI.tableVersion = version$1;
50
50
  VxeUI.setConfig({
@@ -556,7 +556,7 @@ const modal = {
556
556
  const defineVxeComponent = defineComponent;
557
557
 
558
558
  const { log } = VxeUI;
559
- const version = `table v${"4.19.5"}`;
559
+ const version = `table v${"4.19.6"}`;
560
560
  const warnLog = log.create('warn', version);
561
561
  const errLog = log.create('error', version);
562
562
 
@@ -1617,17 +1617,54 @@ function getCalcHeight(height) {
1617
1617
  }
1618
1618
  return height || 0;
1619
1619
  }
1620
+ /**
1621
+ * 列宽拖动最大宽度
1622
+ */
1623
+ function getColReMaxWidth(params) {
1624
+ const { $table, column, cell } = params;
1625
+ const internalData = $table.internalData;
1626
+ const { elemStore } = internalData;
1627
+ const { computeColumnOpts, computeResizableOpts } = $table.getComputeMaps();
1628
+ const resizableOpts = computeResizableOpts.value;
1629
+ const columnOpts = computeColumnOpts.value;
1630
+ const { maxWidth: reMaxWidth } = resizableOpts;
1631
+ const colMaxWidth = column.maxWidth || columnOpts.maxWidth;
1632
+ // 如果自定义调整宽度逻辑
1633
+ if (reMaxWidth) {
1634
+ const customMaxWidth = XEUtils.isFunction(reMaxWidth) ? reMaxWidth(params) : reMaxWidth;
1635
+ if (customMaxWidth !== 'auto') {
1636
+ return Math.max(1, XEUtils.toNumber(customMaxWidth));
1637
+ }
1638
+ }
1639
+ const minTitleWidth = XEUtils.floor((XEUtils.toNumber(getComputedStyle(cell).fontSize) || 14) * 1.8);
1640
+ const paddingLeftRight = getPaddingLeftRightSize(cell) + getPaddingLeftRightSize(queryElement(cell, '.vxe-cell'));
1641
+ const mWidth = minTitleWidth + paddingLeftRight;
1642
+ // 如果设置最小宽
1643
+ if (colMaxWidth) {
1644
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
1645
+ if (bodyScrollElem) {
1646
+ if (isScale(colMaxWidth)) {
1647
+ const bodyWidth = bodyScrollElem.clientWidth - 1;
1648
+ const meanWidth = bodyWidth / 100;
1649
+ return Math.max(mWidth, Math.floor(XEUtils.toInteger(colMaxWidth) * meanWidth));
1650
+ }
1651
+ else if (isPx(colMaxWidth)) {
1652
+ return Math.max(mWidth, XEUtils.toInteger(colMaxWidth));
1653
+ }
1654
+ }
1655
+ }
1656
+ return -1;
1657
+ }
1620
1658
  /**
1621
1659
  * 列宽拖动最小宽度
1622
- * @param params
1623
- * @returns
1624
1660
  */
1625
1661
  function getColReMinWidth(params) {
1626
1662
  const { $table, column, cell } = params;
1627
1663
  const tableProps = $table.props;
1628
1664
  const internalData = $table.internalData;
1629
- const { computeResizableOpts } = $table.getComputeMaps();
1665
+ const { computeColumnOpts, computeResizableOpts } = $table.getComputeMaps();
1630
1666
  const resizableOpts = computeResizableOpts.value;
1667
+ const columnOpts = computeColumnOpts.value;
1631
1668
  const { minWidth: reMinWidth } = resizableOpts;
1632
1669
  // 如果自定义调整宽度逻辑
1633
1670
  if (reMinWidth) {
@@ -1638,7 +1675,8 @@ function getColReMinWidth(params) {
1638
1675
  }
1639
1676
  const { elemStore } = internalData;
1640
1677
  const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps;
1641
- const { showHeaderOverflow, minWidth: colMinWidth } = column;
1678
+ const { showHeaderOverflow } = column;
1679
+ const colMinWidth = column.minWidth || columnOpts.minWidth;
1642
1680
  const headOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
1643
1681
  const showEllipsis = headOverflow === 'ellipsis';
1644
1682
  const showTitle = headOverflow === 'title';
@@ -3835,6 +3873,7 @@ const tableEmits = [
3835
3873
  'cell-area-selection-all-end',
3836
3874
  'cell-area-arrows-start',
3837
3875
  'cell-area-arrows-end',
3876
+ 'cell-area-fill-copy',
3838
3877
  'active-cell-change-start',
3839
3878
  'active-cell-change-end'
3840
3879
  ];
@@ -16450,6 +16489,7 @@ var VxeTableComponent = defineVxeComponent({
16450
16489
  if (!xHandleEl) {
16451
16490
  return;
16452
16491
  }
16492
+ const columnOpts = computeColumnOpts.value;
16453
16493
  let tWidth = 0;
16454
16494
  const minCellWidth = 40; // 列宽最少限制 40px
16455
16495
  const bodyWidth = bodyWrapperElem.clientWidth;
@@ -16458,39 +16498,73 @@ var VxeTableComponent = defineVxeComponent({
16458
16498
  const { fit } = props;
16459
16499
  const { columnStore } = reactData;
16460
16500
  const { resizeList, pxMinList, autoMinList, pxList, scaleList, scaleMinList, autoList, remainList } = columnStore;
16501
+ const parseColumnMaxWidth = (column) => {
16502
+ const maxWidth = column.maxWidth || columnOpts.maxWidth;
16503
+ if (maxWidth && maxWidth !== 'auto') {
16504
+ if (isScale(maxWidth)) {
16505
+ return Math.floor(XEUtils.toInteger(maxWidth) * meanWidth);
16506
+ }
16507
+ return XEUtils.toInteger(maxWidth);
16508
+ }
16509
+ return 0;
16510
+ };
16461
16511
  // 最小宽
16462
16512
  pxMinList.forEach((column) => {
16463
- const minWidth = XEUtils.toInteger(column.minWidth);
16464
- tWidth += minWidth;
16465
- column.renderWidth = minWidth;
16513
+ let miWidth = XEUtils.toInteger(column.minWidth);
16514
+ const mxWidth = parseColumnMaxWidth(column);
16515
+ if (mxWidth) {
16516
+ miWidth = Math.min(miWidth, mxWidth);
16517
+ }
16518
+ tWidth += miWidth;
16519
+ column.renderWidth = miWidth;
16466
16520
  });
16467
16521
  // 最小自适应
16468
16522
  autoMinList.forEach((column) => {
16469
- const caWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16523
+ let caWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16524
+ const mxWidth = parseColumnMaxWidth(column);
16525
+ if (mxWidth) {
16526
+ caWidth = Math.min(caWidth, mxWidth);
16527
+ }
16470
16528
  tWidth += caWidth;
16471
16529
  column.renderWidth = caWidth;
16472
16530
  });
16473
16531
  // 最小百分比
16474
16532
  scaleMinList.forEach((column) => {
16475
- const smWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth);
16533
+ let smWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth);
16534
+ const mxWidth = parseColumnMaxWidth(column);
16535
+ if (mxWidth) {
16536
+ smWidth = Math.min(smWidth, mxWidth);
16537
+ }
16476
16538
  tWidth += smWidth;
16477
16539
  column.renderWidth = smWidth;
16478
16540
  });
16479
16541
  // 固定百分比
16480
16542
  scaleList.forEach((column) => {
16481
- const sfWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth);
16543
+ let sfWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth);
16544
+ const mxWidth = parseColumnMaxWidth(column);
16545
+ if (mxWidth) {
16546
+ sfWidth = Math.min(sfWidth, mxWidth);
16547
+ }
16482
16548
  tWidth += sfWidth;
16483
16549
  column.renderWidth = sfWidth;
16484
16550
  });
16485
16551
  // 固定宽
16486
16552
  pxList.forEach((column) => {
16487
- const pWidth = XEUtils.toInteger(column.width);
16553
+ let pWidth = XEUtils.toInteger(column.width);
16554
+ const mxWidth = parseColumnMaxWidth(column);
16555
+ if (mxWidth) {
16556
+ pWidth = Math.min(pWidth, mxWidth);
16557
+ }
16488
16558
  tWidth += pWidth;
16489
16559
  column.renderWidth = pWidth;
16490
16560
  });
16491
16561
  // 自适应宽
16492
16562
  autoList.forEach((column) => {
16493
- const aWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16563
+ let aWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16564
+ const mxWidth = parseColumnMaxWidth(column);
16565
+ if (mxWidth) {
16566
+ aWidth = Math.min(aWidth, mxWidth);
16567
+ }
16494
16568
  tWidth += aWidth;
16495
16569
  column.renderWidth = aWidth;
16496
16570
  });
@@ -16500,11 +16574,12 @@ var VxeTableComponent = defineVxeComponent({
16500
16574
  tWidth += reWidth;
16501
16575
  column.renderWidth = reWidth;
16502
16576
  });
16577
+ const zoomColumnList = scaleMinList.concat(pxMinList).concat(autoMinList).filter(column => !parseColumnMaxWidth(column));
16503
16578
  remainWidth -= tWidth;
16504
- meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoMinList.length + remainList.length)) : 0;
16579
+ meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (zoomColumnList.length + remainList.length)) : 0;
16505
16580
  if (fit) {
16506
16581
  if (remainWidth > 0) {
16507
- scaleMinList.concat(pxMinList).concat(autoMinList).forEach((column) => {
16582
+ zoomColumnList.forEach((column) => {
16508
16583
  tWidth += meanWidth;
16509
16584
  column.renderWidth += meanWidth;
16510
16585
  });
@@ -16523,8 +16598,9 @@ var VxeTableComponent = defineVxeComponent({
16523
16598
  /**
16524
16599
  * 偏移量算法
16525
16600
  * 如果所有列足够放的情况下,从最后动态列开始分配
16601
+ * 排除已设置 max-width
16526
16602
  */
16527
- const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList);
16603
+ const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList).filter(column => !parseColumnMaxWidth(column));
16528
16604
  let dynamicSize = dynamicList.length - 1;
16529
16605
  if (dynamicSize > 0) {
16530
16606
  let i = bodyWidth - tWidth;
@@ -24004,6 +24080,7 @@ var VxeTableComponent = defineVxeComponent({
24004
24080
  const dragBtnOffsetWidth = XEUtils.floor(dragBtnWidth / 2);
24005
24081
  const dragPosLeft = dragBtnRect.x - tableRect.x + dragBtnOffsetWidth;
24006
24082
  const minInterval = getColReMinWidth(cellParams) - dragBtnOffsetWidth; // 列之间的最小间距
24083
+ const maxInterval = getColReMaxWidth(cellParams); // 列之间的最大间距
24007
24084
  const dragMinLeft = isRightFixed ? 0 : (cellRect.x - tableRect.x + dragBtnWidth + minInterval);
24008
24085
  const dragMaxLeft = cellRect.x - tableRect.x + cell.clientWidth - minInterval;
24009
24086
  let fixedLeftRemainWidth = 0;
@@ -24043,6 +24120,10 @@ var VxeTableComponent = defineVxeComponent({
24043
24120
  left = Math.min(left, dragMaxLeft);
24044
24121
  }
24045
24122
  dragLeft = Math.max(left, dragMinLeft);
24123
+ // 最大宽
24124
+ if (maxInterval > 1) {
24125
+ dragLeft = Math.min(dragLeft, maxInterval + dragMinLeft - minInterval);
24126
+ }
24046
24127
  const resizeBarLeft = Math.max(1, dragLeft);
24047
24128
  resizeBarElem.style.left = `${resizeBarLeft}px`;
24048
24129
  resizeBarElem.style.top = `${scrollbarXToTop ? osbHeight : 0}px`;
@@ -24123,6 +24204,7 @@ var VxeTableComponent = defineVxeComponent({
24123
24204
  const cell = dragBtnElem.parentNode;
24124
24205
  const cellParams = Object.assign(params, { cell, $table: $xeTable });
24125
24206
  const colMinWidth = getColReMinWidth(cellParams);
24207
+ const colMaxWidth = getColReMaxWidth(cellParams);
24126
24208
  el.setAttribute('data-calc-col', 'Y');
24127
24209
  let resizeWidth = calcColumnAutoWidth(resizeColumn, el);
24128
24210
  el.removeAttribute('data-calc-col');
@@ -24130,6 +24212,9 @@ var VxeTableComponent = defineVxeComponent({
24130
24212
  resizeWidth = Math.max(resizeWidth, colRest.width);
24131
24213
  }
24132
24214
  resizeWidth = Math.max(colMinWidth, resizeWidth);
24215
+ if (colMaxWidth > 1) {
24216
+ resizeWidth = Math.min(colMaxWidth, resizeWidth);
24217
+ }
24133
24218
  const resizeParams = Object.assign(Object.assign({}, params), { resizeWidth, resizeColumn });
24134
24219
  reactData.isDragResize = false;
24135
24220
  internalData._lastResizeTime = Date.now();