tomtaw-vxe-table 3.25.19 → 3.25.21

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 (43) hide show
  1. package/es/colgroup/index.d.ts +2 -0
  2. package/es/column/index.d.ts +2 -0
  3. package/es/grid/index.d.ts +2 -0
  4. package/es/grid/src/grid.d.ts +1 -0
  5. package/es/table/src/body.js +84 -36
  6. package/es/table/src/column.d.ts +2 -0
  7. package/es/table/src/column.js +2 -0
  8. package/es/table/src/columnInfo.js +1 -0
  9. package/es/table/src/group.d.ts +1 -0
  10. package/es/table/src/header.d.ts +3 -1
  11. package/es/table/src/header.js +49 -12
  12. package/es/table/src/methods.js +142 -79
  13. package/es/table/src/table.js +6 -15
  14. package/es/table/src/util.d.ts +3 -1
  15. package/es/table/src/util.js +30 -14
  16. package/es/ui/index.js +1 -1
  17. package/es/ui/src/log.js +1 -1
  18. package/lib/index.umd.js +315 -164
  19. package/lib/index.umd.min.js +3 -3
  20. package/lib/table/src/body.js +84 -36
  21. package/lib/table/src/column.js +2 -0
  22. package/lib/table/src/columnInfo.js +1 -0
  23. package/lib/table/src/header.js +48 -11
  24. package/lib/table/src/methods.js +147 -86
  25. package/lib/table/src/table.js +6 -15
  26. package/lib/table/src/util.js +30 -14
  27. package/lib/ui/index.js +1 -1
  28. package/lib/ui/src/log.js +1 -1
  29. package/package.json +1 -1
  30. package/packages/table/src/body.ts +71 -35
  31. package/packages/table/src/column.ts +2 -0
  32. package/packages/table/src/columnInfo.ts +1 -0
  33. package/packages/table/src/header.ts +53 -13
  34. package/packages/table/src/methods.ts +176 -79
  35. package/packages/table/src/table.ts +10 -18
  36. package/packages/table/src/util.ts +32 -15
  37. package/types/all.d.ts +23 -1
  38. /package/es/{iconfont.1795571985819.ttf → iconfont.1795761876277.ttf} +0 -0
  39. /package/es/{iconfont.1795571985819.woff → iconfont.1795761876277.woff} +0 -0
  40. /package/es/{iconfont.1795571985819.woff2 → iconfont.1795761876277.woff2} +0 -0
  41. /package/lib/{iconfont.1795571985819.ttf → iconfont.1795761876277.ttf} +0 -0
  42. /package/lib/{iconfont.1795571985819.woff → iconfont.1795761876277.woff} +0 -0
  43. /package/lib/{iconfont.1795571985819.woff2 → iconfont.1795761876277.woff2} +0 -0
@@ -33,6 +33,7 @@ __export(body_exports, {
33
33
  module.exports = __toCommonJS(body_exports);
34
34
  var import_xe_utils = __toESM(require("xe-utils"));
35
35
  var import_core = require("@vxe-ui/core");
36
+ var import_comp = require("../../ui/src/comp");
36
37
  var import_utils = require("../../ui/src/utils");
37
38
  var import_util = require("./util");
38
39
  var import_expand_height = require("./expand-height");
@@ -41,6 +42,52 @@ var import_vn = require("../../ui/src/vn");
41
42
  const { getI18n, renderer, renderEmptyElement } = import_core.VxeUI;
42
43
  const sourceType = "table";
43
44
  const renderType = "body";
45
+ const cellScopeKeys = [
46
+ "$table",
47
+ "$grid",
48
+ "$gantt",
49
+ "isEdit",
50
+ "seq",
51
+ "rowid",
52
+ "row",
53
+ "rowIndex",
54
+ "$rowIndex",
55
+ "_rowIndex",
56
+ "column",
57
+ "columnIndex",
58
+ "$columnIndex",
59
+ "_columnIndex",
60
+ "fixed",
61
+ "source",
62
+ "type",
63
+ "isHidden",
64
+ "level",
65
+ "visibleData",
66
+ "data",
67
+ "items"
68
+ ];
69
+ const RowScopedCell = (0, import_comp.defineVxeComponent)({
70
+ name: "VxeRowScopedCell",
71
+ props: [...cellScopeKeys, "contentVersion", "rowOrder", "defaultSlot"],
72
+ data() {
73
+ const props = this.$props;
74
+ const scope = {};
75
+ for (const key of cellScopeKeys) {
76
+ Object.defineProperty(scope, key, { enumerable: true, get: () => props[key] });
77
+ }
78
+ return { cellScope: Object.freeze(scope) };
79
+ },
80
+ render(h) {
81
+ void this.contentVersion;
82
+ void this.rowOrder;
83
+ void this.defaultSlot;
84
+ const scope = this.cellScope;
85
+ return h("div", {
86
+ class: "vxe-cell--wrapper vxe-body-cell--wrapper",
87
+ attrs: { rowid: scope.rowid, colid: scope.column.id }
88
+ }, scope.column.renderCell(h, scope));
89
+ }
90
+ });
44
91
  const isVMScrollProcess = ($xeTable) => {
45
92
  const tableProps = $xeTable;
46
93
  const tableReactData = $xeTable;
@@ -107,7 +154,26 @@ function renderLine(h, $xeTable, rowid, params, cellHeight) {
107
154
  }
108
155
  return [];
109
156
  }
110
- function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
157
+ function getBodyCellOptions($xeTable) {
158
+ return {
159
+ cellOpts: $xeTable.computeCellOpts,
160
+ validOpts: $xeTable.computeValidOpts,
161
+ checkboxOpts: $xeTable.computeCheckboxOpts,
162
+ editOpts: $xeTable.computeEditOpts,
163
+ tooltipOpts: $xeTable.computeTooltipOpts,
164
+ virtualXOpts: $xeTable.computeVirtualXOpts,
165
+ virtualYOpts: $xeTable.computeVirtualYOpts,
166
+ rendererOpts: $xeTable.computeRendererOpts,
167
+ rowOpts: $xeTable.computeRowOpts,
168
+ rowDragOpts: $xeTable.computeRowDragOpts,
169
+ columnOpts: $xeTable.computeColumnOpts,
170
+ mouseOpts: $xeTable.computeMouseOpts,
171
+ areaOpts: $xeTable.computeAreaOpts,
172
+ defaultRowHeight: $xeTable.computeDefaultRowHeight,
173
+ cellOffsetWidth: $xeTable.computeCellOffsetWidth
174
+ };
175
+ }
176
+ function renderTdColumn(h, $xeTable, options, rowRest, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
111
177
  const tableProps = $xeTable;
112
178
  const tableReactData = $xeTable;
113
179
  const tableInternalData = $xeTable;
@@ -116,29 +182,14 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
116
182
  const { columnKey, resizable: allResizable, showOverflow: allShowOverflow, border, height, treeConfig, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig, padding: allPadding } = tableProps;
117
183
  const { tableData, tableColumn, dragRow, overflowX, overflowY, scrollXLoad, scrollYLoad, mergeBodyFlag, calcCellHeightFlag, resizeHeightFlag, resizeWidthFlag, editStore, isAllOverflow, validErrorMaps, currColFlag } = tableReactData;
118
184
  const { fullAllDataRowIdData, fullColumnIdData, mergeBodyCellMaps, visibleColumn, afterFullData, mergeBodyList, scrollXStore, scrollYStore, keepUpdateFieldMaps, currentCol } = tableInternalData;
119
- const cellOpts = $xeTable.computeCellOpts;
120
- const validOpts = $xeTable.computeValidOpts;
121
- const checkboxOpts = $xeTable.computeCheckboxOpts;
122
- const editOpts = $xeTable.computeEditOpts;
123
- const tooltipOpts = $xeTable.computeTooltipOpts;
124
- const virtualXOpts = $xeTable.computeVirtualXOpts;
125
- const virtualYOpts = $xeTable.computeVirtualYOpts;
126
- const rendererOpts = $xeTable.computeRendererOpts;
185
+ const { cellOpts, validOpts, checkboxOpts, editOpts, tooltipOpts, virtualXOpts, virtualYOpts, rendererOpts, rowOpts, rowDragOpts, columnOpts, mouseOpts, areaOpts, defaultRowHeight, cellOffsetWidth } = options;
127
186
  const { isAllColumnDrag, isAllRowDrag } = $xeTable.resizableOpts;
128
- const rowOpts = $xeTable.computeRowOpts;
129
- const rowDragOpts = $xeTable.computeRowDragOpts;
130
- const defaultRowHeight = $xeTable.computeDefaultRowHeight;
131
187
  const customCellHeight = calcCellHeightFlag ? cellOpts.height || rowOpts.height : 0;
132
188
  const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = rowDragOpts;
133
- const columnOpts = $xeTable.computeColumnOpts;
134
- const mouseOpts = $xeTable.computeMouseOpts;
135
- const areaOpts = $xeTable.computeAreaOpts;
136
- const cellOffsetWidth = $xeTable.computeCellOffsetWidth;
137
189
  const { selectCellToRow } = areaOpts;
138
190
  const { field, type, cellRender, editRender, align, showOverflow, className, treeNode, rowResize, padding, verticalAlign, slots } = column;
139
191
  const { verticalAlign: allVerticalAlign, minHeight, maxHeight } = cellOpts;
140
192
  const { actived } = editStore;
141
- const rowRest = fullAllDataRowIdData[rowid] || {};
142
193
  const colid = column.id;
143
194
  const colRest = fullColumnIdData[colid] || {};
144
195
  const renderOpts = editRender || cellRender;
@@ -359,19 +410,17 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
359
410
  }
360
411
  const clVNs = [];
361
412
  if (!isVNPreEmptyStatus) {
362
- clVNs.push(
363
- h(
364
- "div",
365
- {
366
- attrs: {
367
- colid,
368
- rowid
369
- },
370
- class: "vxe-cell--wrapper vxe-body-cell--wrapper"
371
- },
372
- column.renderCell(h, cellParams)
373
- )
374
- );
413
+ if (column.rowScopedSlot && slots && slots.default && !type && !editRender && !treeNode && !tableReactData.isRowGroupStatus) {
414
+ clVNs.push(h(RowScopedCell, {
415
+ key: rowid,
416
+ props: { ...cellParams, contentVersion: rowRest.contentVersion, rowOrder: tableInternalData.afterFullRowMaps, defaultSlot: slots.default }
417
+ }));
418
+ } else {
419
+ clVNs.push(h("div", {
420
+ class: "vxe-cell--wrapper vxe-body-cell--wrapper",
421
+ attrs: { colid, rowid }
422
+ }, column.renderCell(h, cellParams)));
423
+ }
375
424
  }
376
425
  tdVNs.push(
377
426
  h(
@@ -520,12 +569,11 @@ function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
520
569
  const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps;
521
570
  const { hasFixedColumn, treeExpandedFlag, scrollYLoad, isAllOverflow, rowExpandedFlag, expandColumn, selectRadioRow, pendingRowFlag, rowExpandHeightFlag, isRowGroupStatus } = tableReactData;
522
571
  const { fullAllDataRowIdData, fullColumnIdData, treeExpandedMaps, pendingRowMaps, rowExpandedMaps, currentRow } = tableInternalData;
523
- const checkboxOpts = $xeTable.computeCheckboxOpts;
572
+ const options = getBodyCellOptions($xeTable);
573
+ const { checkboxOpts, editOpts, rowOpts, columnOpts } = options;
524
574
  const radioOpts = $xeTable.computeRadioOpts;
525
575
  const treeOpts = $xeTable.computeTreeOpts;
526
- const editOpts = $xeTable.computeEditOpts;
527
- const rowOpts = $xeTable.computeRowOpts;
528
- const columnOpts = $xeTable.computeColumnOpts;
576
+ const currentRowId = currentRow && (rowOpts.isCurrent || tableProps.highlightCurrentRow) ? (0, import_util.getRowid)($xeTable, currentRow) : null;
529
577
  const { transform, seqMode } = treeOpts;
530
578
  const childrenField = treeOpts.children || treeOpts.childrenField;
531
579
  const rows = [];
@@ -606,12 +654,12 @@ function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
606
654
  "row--checked": checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
607
655
  "row--pending": !!pendingRowFlag && !!pendingRowMaps[rowid],
608
656
  "row--group": hasRowGroupAggregate,
609
- "row--current": currentRow && rowid === (0, import_util.getRowid)($xeTable, currentRow)
657
+ "row--current": rowid === currentRowId
610
658
  },
611
659
  rowClassName ? import_xe_utils.default.isFunction(rowClassName) ? rowClassName(params) : rowClassName : ""
612
660
  ];
613
661
  const tdVNs = tableColumn.map((column, $columnIndex) => {
614
- return renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData);
662
+ return renderTdColumn(h, $xeTable, options, rowRest, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData);
615
663
  });
616
664
  rows.push(
617
665
  h(
@@ -86,6 +86,8 @@ const columnProps = {
86
86
  footerClassName: [String, Function],
87
87
  // 格式化显示内容
88
88
  formatter: [Function, Array, String],
89
+ // 只读插槽以独立组件订阅行内容及实际使用的窗口参数。
90
+ rowScopedSlot: Boolean,
89
91
  // 格式化表头显示内容
90
92
  headerFormatter: [Function, Array, String],
91
93
  // 格式化表尾显示内容
@@ -148,6 +148,7 @@ class ColumnInfo {
148
148
  dragSort: colConfs.dragSort,
149
149
  rowResize: colConfs.rowResize,
150
150
  cellType: colConfs.cellType,
151
+ rowScopedSlot: colConfs.rowScopedSlot,
151
152
  cellRender: colConfs.cellRender,
152
153
  editRender,
153
154
  contentRender: colConfs.contentRender,
@@ -39,7 +39,30 @@ var import_vn = require("../../ui/src/vn");
39
39
  const { renderer, renderEmptyElement } = import_core.VxeUI;
40
40
  const sourceType = "table";
41
41
  const renderType = "header";
42
- function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols) {
42
+ function projectHeaderWindow(leaves, rows, columnCache) {
43
+ var _a;
44
+ const groups = /* @__PURE__ */ new Map();
45
+ const headers = rows.map(() => []);
46
+ for (const leaf of leaves) {
47
+ let column = leaf;
48
+ while (column) {
49
+ const headerRow = headers[column.level - 1];
50
+ if (!headerRow) break;
51
+ const group = groups.get(column);
52
+ if (group) {
53
+ group.span++;
54
+ group.width += leaf.renderWidth;
55
+ group.lastLeaf = leaf;
56
+ } else {
57
+ headerRow.push(column);
58
+ groups.set(column, { span: 1, width: leaf.renderWidth, lastLeaf: leaf });
59
+ }
60
+ column = column.parentId ? (_a = columnCache[column.parentId]) == null ? void 0 : _a.column : void 0;
61
+ }
62
+ }
63
+ return { headers, groups };
64
+ }
65
+ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols, groups) {
43
66
  const props = _vm;
44
67
  const $xeTable = _vm.$parent;
45
68
  const $xeGrid = $xeTable.$xeGrid;
@@ -112,9 +135,11 @@ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, co
112
135
  const thAttrs = {
113
136
  colid
114
137
  };
138
+ const group = groups == null ? void 0 : groups.get(column);
115
139
  let isMergeCell = false;
116
140
  if (!showCustomHeader) {
117
- thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null;
141
+ const colSpan = group ? group.span : column.colSpan;
142
+ thAttrs.colspan = colSpan > 1 ? colSpan : null;
118
143
  thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null;
119
144
  }
120
145
  if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
@@ -172,6 +197,8 @@ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, co
172
197
  tcStyle.minHeight = `${currCellHeight}px`;
173
198
  }
174
199
  if (showCustomHeader) {
200
+ } else if (isColGroup && group) {
201
+ tcStyle.width = `${group.width}px`;
175
202
  } else if (isColGroup && !isLastRow) {
176
203
  let childWidth = 0;
177
204
  import_xe_utils.default.eachTree(column.children, (childRow) => {
@@ -245,7 +272,7 @@ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, co
245
272
  /**
246
273
  * 列宽拖动
247
274
  */
248
- !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow) ? h("div", {
275
+ !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow) && (!group || !isColGroup || group.lastLeaf === (0, import_util.getLastChildColumn)(column)) ? h("div", {
249
276
  class: "vxe-cell--col-resizable",
250
277
  on: {
251
278
  mousedown: (evnt) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
@@ -381,13 +408,14 @@ function renderFilterRows(h, _vm, isOptimizeMode, cols) {
381
408
  );
382
409
  });
383
410
  }
384
- function renderHeads(h, _vm, isGroup, isOptimizeMode, headerGroups, renderColumnList) {
411
+ function renderHeads(h, _vm, isGroup, isOptimizeMode, headerGroups, renderColumnList, groups) {
385
412
  const props = _vm;
386
413
  const $xeTable = _vm.$parent;
387
414
  const tableProps = $xeTable;
388
415
  const { fixedType } = props;
389
416
  const { headerRowClassName, headerRowStyle } = tableProps;
390
417
  const floatingFilterOpts = $xeTable.computeFloatingFilterOpts;
418
+ const groupRowStyle = groups ? { height: `${(0, import_util.getCalcHeight)($xeTable.computeHeaderCellOpts.height) || $xeTable.computeDefaultRowHeight}px` } : void 0;
391
419
  const rowVNs = headerGroups.map((cols, _rowIndex) => {
392
420
  const params = { $table: $xeTable, rowIndex: _rowIndex, _rowIndex, $rowIndex: _rowIndex, fixed: fixedType, type: renderType };
393
421
  return h(
@@ -395,9 +423,9 @@ function renderHeads(h, _vm, isGroup, isOptimizeMode, headerGroups, renderColumn
395
423
  {
396
424
  key: _rowIndex,
397
425
  class: ["vxe-header--row", headerRowClassName ? import_xe_utils.default.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName : ""],
398
- style: headerRowStyle ? import_xe_utils.default.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle : void 0
426
+ style: headerRowStyle ? import_xe_utils.default.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle : groupRowStyle
399
427
  },
400
- renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols)
428
+ renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols, groups)
401
429
  );
402
430
  });
403
431
  if (floatingFilterOpts.enabled) {
@@ -432,6 +460,11 @@ var header_default = {
432
460
  headerColumn
433
461
  };
434
462
  },
463
+ computed: {
464
+ groupedHeaderRows() {
465
+ return (0, import_util.convertHeaderColumnToRows)(this.tableGroupColumn || []);
466
+ }
467
+ },
435
468
  watch: {
436
469
  tableColumn() {
437
470
  const _vm = this;
@@ -492,7 +525,13 @@ var header_default = {
492
525
  let renderHeaderList = headerColumn;
493
526
  let renderColumnList = tableColumn;
494
527
  const isOptimizeMode = isHeaderRenderOptimize;
495
- if (isGroup) {
528
+ let groups;
529
+ if (isGroup && isOptimizeMode) {
530
+ renderColumnList = fixedType ? fixedColumn : tableColumn;
531
+ const projection = projectHeaderWindow(renderColumnList, headerColumn, fullColumnIdData);
532
+ renderHeaderList = projection.headers;
533
+ groups = projection.groups;
534
+ } else if (isGroup) {
496
535
  renderColumnList = visibleColumn;
497
536
  } else {
498
537
  if (!isOptimizeMode || !isColLoading && (fixedType || !overflowX)) {
@@ -598,7 +637,7 @@ var header_default = {
598
637
  {
599
638
  ref: "refHeaderTHead"
600
639
  },
601
- renderHeads(h, _vm, isGroup, isOptimizeMode, renderHeaderList, renderColumnList)
640
+ renderHeads(h, _vm, isGroup, isOptimizeMode, renderHeaderList, renderColumnList, groups)
602
641
  )
603
642
  ]
604
643
  ),
@@ -643,12 +682,10 @@ var header_default = {
643
682
  const tableProps = $xeTable;
644
683
  const tableReactData = $xeTable;
645
684
  const tableInternalData = $xeTable;
646
- const props = _vm;
647
685
  const { showCustomHeader } = tableProps;
648
686
  const { collectColumn, visibleColumn } = tableInternalData;
649
- const { tableGroupColumn } = props;
650
687
  const { isGroup } = tableReactData;
651
- let spanColumns = isGroup ? (0, import_util.convertHeaderColumnToRows)(tableGroupColumn) : [];
688
+ let spanColumns = isGroup ? _vm.groupedHeaderRows : [];
652
689
  let visibleColgroups = [];
653
690
  if (showCustomHeader && spanColumns.length > 1) {
654
691
  visibleColgroups = (0, import_util.convertHeaderToGridRows)(spanColumns);