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
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.7";
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.7"}`;
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';
@@ -3362,6 +3400,9 @@ var VxeColgroupComponent = defineVxeComponent({
3362
3400
  if (slots.header) {
3363
3401
  columnSlots.header = slots.header;
3364
3402
  }
3403
+ if (slots.title) {
3404
+ columnSlots.title = slots.title;
3405
+ }
3365
3406
  columnConfig.slots = columnSlots;
3366
3407
  columnConfig.children = [];
3367
3408
  watchColumn($xeTable, props, columnConfig);
@@ -3835,6 +3876,7 @@ const tableEmits = [
3835
3876
  'cell-area-selection-all-end',
3836
3877
  'cell-area-arrows-start',
3837
3878
  'cell-area-arrows-end',
3879
+ 'cell-area-fill-copy',
3838
3880
  'active-cell-change-start',
3839
3881
  'active-cell-change-end'
3840
3882
  ];
@@ -4247,21 +4289,11 @@ var TableBodyComponent = defineVxeComponent({
4247
4289
  class: 'vxe-cell--wrapper vxe-body-cell--wrapper'
4248
4290
  }, column.renderCell(cellParams)));
4249
4291
  }
4250
- tdVNs.push(h('div', {
4251
- key: 'tc',
4252
- class: ['vxe-cell', {
4253
- 'c--title': showTitle,
4254
- 'c--tooltip': showTooltip,
4255
- 'c--ellipsis': showEllipsis
4256
- }],
4257
- style: tcStyle,
4258
- title: showTitle ? $xeTable.getCellLabel(row, column) : null
4259
- }, clVNs));
4260
4292
  if (showValidTip && errorValidItem) {
4261
4293
  const errRule = errorValidItem.rule;
4262
4294
  const validSlot = slots ? slots.valid : null;
4263
4295
  const validParams = Object.assign(Object.assign(Object.assign({}, cellParams), errorValidItem), { rule: errorValidItem });
4264
- tdVNs.push(h('div', {
4296
+ clVNs.push(h('div', {
4265
4297
  key: 'tcv',
4266
4298
  class: ['vxe-cell--valid-error-tip', getPropClass(validOpts.className, validParams)],
4267
4299
  style: errRule && errRule.maxWidth
@@ -4283,6 +4315,16 @@ var TableBodyComponent = defineVxeComponent({
4283
4315
  ])
4284
4316
  ]));
4285
4317
  }
4318
+ tdVNs.push(h('div', {
4319
+ key: 'tc',
4320
+ class: ['vxe-cell', {
4321
+ 'c--title': showTitle,
4322
+ 'c--tooltip': showTooltip,
4323
+ 'c--ellipsis': showEllipsis
4324
+ }],
4325
+ style: tcStyle,
4326
+ title: showTitle ? $xeTable.getCellLabel(row, column) : null
4327
+ }, clVNs));
4286
4328
  }
4287
4329
  let showAreaRowStatus = false;
4288
4330
  if (mouseConfig && mouseOpts.area && !_columnIndex && selectCellToRow) {
@@ -16450,6 +16492,7 @@ var VxeTableComponent = defineVxeComponent({
16450
16492
  if (!xHandleEl) {
16451
16493
  return;
16452
16494
  }
16495
+ const columnOpts = computeColumnOpts.value;
16453
16496
  let tWidth = 0;
16454
16497
  const minCellWidth = 40; // 列宽最少限制 40px
16455
16498
  const bodyWidth = bodyWrapperElem.clientWidth;
@@ -16458,39 +16501,73 @@ var VxeTableComponent = defineVxeComponent({
16458
16501
  const { fit } = props;
16459
16502
  const { columnStore } = reactData;
16460
16503
  const { resizeList, pxMinList, autoMinList, pxList, scaleList, scaleMinList, autoList, remainList } = columnStore;
16504
+ const parseColumnMaxWidth = (column) => {
16505
+ const maxWidth = column.maxWidth || columnOpts.maxWidth;
16506
+ if (maxWidth && maxWidth !== 'auto') {
16507
+ if (isScale(maxWidth)) {
16508
+ return Math.floor(XEUtils.toInteger(maxWidth) * meanWidth);
16509
+ }
16510
+ return XEUtils.toInteger(maxWidth);
16511
+ }
16512
+ return 0;
16513
+ };
16461
16514
  // 最小宽
16462
16515
  pxMinList.forEach((column) => {
16463
- const minWidth = XEUtils.toInteger(column.minWidth);
16464
- tWidth += minWidth;
16465
- column.renderWidth = minWidth;
16516
+ let miWidth = XEUtils.toInteger(column.minWidth);
16517
+ const mxWidth = parseColumnMaxWidth(column);
16518
+ if (mxWidth) {
16519
+ miWidth = Math.min(miWidth, mxWidth);
16520
+ }
16521
+ tWidth += miWidth;
16522
+ column.renderWidth = miWidth;
16466
16523
  });
16467
16524
  // 最小自适应
16468
16525
  autoMinList.forEach((column) => {
16469
- const caWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16526
+ let caWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16527
+ const mxWidth = parseColumnMaxWidth(column);
16528
+ if (mxWidth) {
16529
+ caWidth = Math.min(caWidth, mxWidth);
16530
+ }
16470
16531
  tWidth += caWidth;
16471
16532
  column.renderWidth = caWidth;
16472
16533
  });
16473
16534
  // 最小百分比
16474
16535
  scaleMinList.forEach((column) => {
16475
- const smWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth);
16536
+ let smWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth);
16537
+ const mxWidth = parseColumnMaxWidth(column);
16538
+ if (mxWidth) {
16539
+ smWidth = Math.min(smWidth, mxWidth);
16540
+ }
16476
16541
  tWidth += smWidth;
16477
16542
  column.renderWidth = smWidth;
16478
16543
  });
16479
16544
  // 固定百分比
16480
16545
  scaleList.forEach((column) => {
16481
- const sfWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth);
16546
+ let sfWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth);
16547
+ const mxWidth = parseColumnMaxWidth(column);
16548
+ if (mxWidth) {
16549
+ sfWidth = Math.min(sfWidth, mxWidth);
16550
+ }
16482
16551
  tWidth += sfWidth;
16483
16552
  column.renderWidth = sfWidth;
16484
16553
  });
16485
16554
  // 固定宽
16486
16555
  pxList.forEach((column) => {
16487
- const pWidth = XEUtils.toInteger(column.width);
16556
+ let pWidth = XEUtils.toInteger(column.width);
16557
+ const mxWidth = parseColumnMaxWidth(column);
16558
+ if (mxWidth) {
16559
+ pWidth = Math.min(pWidth, mxWidth);
16560
+ }
16488
16561
  tWidth += pWidth;
16489
16562
  column.renderWidth = pWidth;
16490
16563
  });
16491
16564
  // 自适应宽
16492
16565
  autoList.forEach((column) => {
16493
- const aWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16566
+ let aWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth));
16567
+ const mxWidth = parseColumnMaxWidth(column);
16568
+ if (mxWidth) {
16569
+ aWidth = Math.min(aWidth, mxWidth);
16570
+ }
16494
16571
  tWidth += aWidth;
16495
16572
  column.renderWidth = aWidth;
16496
16573
  });
@@ -16500,11 +16577,12 @@ var VxeTableComponent = defineVxeComponent({
16500
16577
  tWidth += reWidth;
16501
16578
  column.renderWidth = reWidth;
16502
16579
  });
16580
+ const zoomColumnList = scaleMinList.concat(pxMinList).concat(autoMinList).filter(column => !parseColumnMaxWidth(column));
16503
16581
  remainWidth -= tWidth;
16504
- meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoMinList.length + remainList.length)) : 0;
16582
+ meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (zoomColumnList.length + remainList.length)) : 0;
16505
16583
  if (fit) {
16506
16584
  if (remainWidth > 0) {
16507
- scaleMinList.concat(pxMinList).concat(autoMinList).forEach((column) => {
16585
+ zoomColumnList.forEach((column) => {
16508
16586
  tWidth += meanWidth;
16509
16587
  column.renderWidth += meanWidth;
16510
16588
  });
@@ -16523,8 +16601,9 @@ var VxeTableComponent = defineVxeComponent({
16523
16601
  /**
16524
16602
  * 偏移量算法
16525
16603
  * 如果所有列足够放的情况下,从最后动态列开始分配
16604
+ * 排除已设置 max-width
16526
16605
  */
16527
- const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList);
16606
+ const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList).filter(column => !parseColumnMaxWidth(column));
16528
16607
  let dynamicSize = dynamicList.length - 1;
16529
16608
  if (dynamicSize > 0) {
16530
16609
  let i = bodyWidth - tWidth;
@@ -17020,7 +17099,7 @@ var VxeTableComponent = defineVxeComponent({
17020
17099
  xScrollbarVisible = 'hidden';
17021
17100
  }
17022
17101
  let yScrollbarVisible = overflowY ? 'visible' : 'hidden';
17023
- if ((scrollbarYConf.visible === 'hidden' || scrollbarYConf.visible === false) || ($xeGanttView && !scrollbarYToLeft)) {
17102
+ if ((scrollbarYConf.visible === 'hidden' || scrollbarYConf.visible === false) || (($xeGantt && $xeGanttView && $xeGantt.reactData.showRightView) && !scrollbarYToLeft)) {
17024
17103
  osbWidth = 0;
17025
17104
  yScrollbarVisible = 'hidden';
17026
17105
  }
@@ -18327,6 +18406,7 @@ var VxeTableComponent = defineVxeComponent({
18327
18406
  updateStyle();
18328
18407
  }).then(() => {
18329
18408
  computeScrollLoad();
18409
+ syncGanttScrollYStatus();
18330
18410
  }).then(() => {
18331
18411
  const virtualYOpts = computeVirtualYOpts.value;
18332
18412
  // 是否启用了虚拟滚动
@@ -18386,6 +18466,7 @@ var VxeTableComponent = defineVxeComponent({
18386
18466
  reactData.isRowLoading = false;
18387
18467
  handleRecalculateStyle(false, false, false);
18388
18468
  updateTreeLineStyle();
18469
+ syncGanttScrollYStatus();
18389
18470
  // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
18390
18471
  if (!props.showOverflow) {
18391
18472
  setTimeout(() => {
@@ -18705,9 +18786,14 @@ var VxeTableComponent = defineVxeComponent({
18705
18786
  reactData.scrollXLoad = scrollXLoad;
18706
18787
  return scrollXLoad;
18707
18788
  };
18789
+ const syncGanttScrollYStatus = () => {
18790
+ const $xeGanttView = internalData.xeGanttView;
18791
+ if ($xeGanttView && $xeGanttView.handleUpdateSYStatus) {
18792
+ $xeGanttView.handleUpdateSYStatus(reactData.scrollYLoad);
18793
+ }
18794
+ };
18708
18795
  const updateScrollYStatus = (fullData) => {
18709
18796
  const { treeConfig } = props;
18710
- const $xeGanttView = internalData.xeGanttView;
18711
18797
  const virtualYOpts = computeVirtualYOpts.value;
18712
18798
  const treeOpts = computeTreeOpts.value;
18713
18799
  const { transform } = treeOpts;
@@ -18715,9 +18801,7 @@ var VxeTableComponent = defineVxeComponent({
18715
18801
  // 如果gt为0,则总是启用
18716
18802
  const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length);
18717
18803
  reactData.scrollYLoad = scrollYLoad;
18718
- if ($xeGanttView && $xeGanttView.handleUpdateSYStatus) {
18719
- $xeGanttView.handleUpdateSYStatus(scrollYLoad);
18720
- }
18804
+ syncGanttScrollYStatus();
18721
18805
  return scrollYLoad;
18722
18806
  };
18723
18807
  /**
@@ -24004,6 +24088,7 @@ var VxeTableComponent = defineVxeComponent({
24004
24088
  const dragBtnOffsetWidth = XEUtils.floor(dragBtnWidth / 2);
24005
24089
  const dragPosLeft = dragBtnRect.x - tableRect.x + dragBtnOffsetWidth;
24006
24090
  const minInterval = getColReMinWidth(cellParams) - dragBtnOffsetWidth; // 列之间的最小间距
24091
+ const maxInterval = getColReMaxWidth(cellParams); // 列之间的最大间距
24007
24092
  const dragMinLeft = isRightFixed ? 0 : (cellRect.x - tableRect.x + dragBtnWidth + minInterval);
24008
24093
  const dragMaxLeft = cellRect.x - tableRect.x + cell.clientWidth - minInterval;
24009
24094
  let fixedLeftRemainWidth = 0;
@@ -24043,6 +24128,10 @@ var VxeTableComponent = defineVxeComponent({
24043
24128
  left = Math.min(left, dragMaxLeft);
24044
24129
  }
24045
24130
  dragLeft = Math.max(left, dragMinLeft);
24131
+ // 最大宽
24132
+ if (maxInterval > 1) {
24133
+ dragLeft = Math.min(dragLeft, maxInterval + dragMinLeft - minInterval);
24134
+ }
24046
24135
  const resizeBarLeft = Math.max(1, dragLeft);
24047
24136
  resizeBarElem.style.left = `${resizeBarLeft}px`;
24048
24137
  resizeBarElem.style.top = `${scrollbarXToTop ? osbHeight : 0}px`;
@@ -24123,6 +24212,7 @@ var VxeTableComponent = defineVxeComponent({
24123
24212
  const cell = dragBtnElem.parentNode;
24124
24213
  const cellParams = Object.assign(params, { cell, $table: $xeTable });
24125
24214
  const colMinWidth = getColReMinWidth(cellParams);
24215
+ const colMaxWidth = getColReMaxWidth(cellParams);
24126
24216
  el.setAttribute('data-calc-col', 'Y');
24127
24217
  let resizeWidth = calcColumnAutoWidth(resizeColumn, el);
24128
24218
  el.removeAttribute('data-calc-col');
@@ -24130,6 +24220,9 @@ var VxeTableComponent = defineVxeComponent({
24130
24220
  resizeWidth = Math.max(resizeWidth, colRest.width);
24131
24221
  }
24132
24222
  resizeWidth = Math.max(colMinWidth, resizeWidth);
24223
+ if (colMaxWidth > 1) {
24224
+ resizeWidth = Math.min(colMaxWidth, resizeWidth);
24225
+ }
24133
24226
  const resizeParams = Object.assign(Object.assign({}, params), { resizeWidth, resizeColumn });
24134
24227
  reactData.isDragResize = false;
24135
24228
  internalData._lastResizeTime = Date.now();