tomtaw-vxe-table 3.25.20 → 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 (40) hide show
  1. package/es/colgroup/index.d.ts +2 -0
  2. package/es/column/index.d.ts +2 -0
  3. package/es/table/src/body.js +58 -13
  4. package/es/table/src/column.d.ts +2 -0
  5. package/es/table/src/column.js +2 -0
  6. package/es/table/src/columnInfo.js +1 -0
  7. package/es/table/src/group.d.ts +1 -0
  8. package/es/table/src/header.d.ts +3 -1
  9. package/es/table/src/header.js +49 -12
  10. package/es/table/src/methods.js +82 -65
  11. package/es/table/src/table.js +4 -13
  12. package/es/table/src/util.js +4 -2
  13. package/es/ui/index.js +1 -1
  14. package/es/ui/src/log.js +1 -1
  15. package/lib/index.umd.js +205 -113
  16. package/lib/index.umd.min.js +3 -3
  17. package/lib/table/src/body.js +58 -13
  18. package/lib/table/src/column.js +2 -0
  19. package/lib/table/src/columnInfo.js +1 -0
  20. package/lib/table/src/header.js +48 -11
  21. package/lib/table/src/methods.js +82 -65
  22. package/lib/table/src/table.js +4 -13
  23. package/lib/table/src/util.js +4 -2
  24. package/lib/ui/index.js +1 -1
  25. package/lib/ui/src/log.js +1 -1
  26. package/package.json +1 -1
  27. package/packages/table/src/body.ts +42 -13
  28. package/packages/table/src/column.ts +2 -0
  29. package/packages/table/src/columnInfo.ts +1 -0
  30. package/packages/table/src/header.ts +53 -13
  31. package/packages/table/src/methods.ts +102 -65
  32. package/packages/table/src/table.ts +8 -16
  33. package/packages/table/src/util.ts +4 -2
  34. package/types/all.d.ts +21 -1
  35. /package/es/{iconfont.1795759903178.ttf → iconfont.1795761876277.ttf} +0 -0
  36. /package/es/{iconfont.1795759903178.woff → iconfont.1795761876277.woff} +0 -0
  37. /package/es/{iconfont.1795759903178.woff2 → iconfont.1795761876277.woff2} +0 -0
  38. /package/lib/{iconfont.1795759903178.ttf → iconfont.1795761876277.ttf} +0 -0
  39. /package/lib/{iconfont.1795759903178.woff → iconfont.1795761876277.woff} +0 -0
  40. /package/lib/{iconfont.1795759903178.woff2 → iconfont.1795761876277.woff2} +0 -0
@@ -19,6 +19,7 @@ export declare const VxeColgroup: import("vue/types/vue").ExtendedVue<import("vu
19
19
  headerClassName: string | Function;
20
20
  footerClassName: string | Function;
21
21
  formatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Formatter<any>;
22
+ rowScopedSlot: boolean;
22
23
  headerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.HeaderFormatter;
23
24
  footerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.FooterFormatter<any>;
24
25
  padding: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Padding;
@@ -79,6 +80,7 @@ export declare const Colgroup: import("vue/types/vue").ExtendedVue<import("vue")
79
80
  headerClassName: string | Function;
80
81
  footerClassName: string | Function;
81
82
  formatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Formatter<any>;
83
+ rowScopedSlot: boolean;
82
84
  headerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.HeaderFormatter;
83
85
  footerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.FooterFormatter<any>;
84
86
  padding: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Padding;
@@ -19,6 +19,7 @@ export declare const VxeColumn: import("vue/types/vue").ExtendedVue<import("vue"
19
19
  headerClassName: string | Function;
20
20
  footerClassName: string | Function;
21
21
  formatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Formatter<any>;
22
+ rowScopedSlot: boolean;
22
23
  headerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.HeaderFormatter;
23
24
  footerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.FooterFormatter<any>;
24
25
  padding: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Padding;
@@ -79,6 +80,7 @@ export declare const Column: import("vue/types/vue").ExtendedVue<import("vue").d
79
80
  headerClassName: string | Function;
80
81
  footerClassName: string | Function;
81
82
  formatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Formatter<any>;
83
+ rowScopedSlot: boolean;
82
84
  headerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.HeaderFormatter;
83
85
  footerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.FooterFormatter<any>;
84
86
  padding: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Padding;
@@ -1,5 +1,6 @@
1
1
  import XEUtils from "xe-utils";
2
2
  import { VxeUI } from "@vxe-ui/core";
3
+ import { defineVxeComponent } from "../../ui/src/comp";
3
4
  import { isEnableConf, getClass, getDefaultConfig, hasEnableConf } from "../../ui/src/utils";
4
5
  import { getRowid, createHandleGetRowId, getCellRestHeight } from "./util";
5
6
  import { getRowExpandHeight } from "./expand-height";
@@ -8,6 +9,52 @@ import { getSlotVNs } from "../../ui/src/vn";
8
9
  const { getI18n, renderer, renderEmptyElement } = VxeUI;
9
10
  const sourceType = "table";
10
11
  const renderType = "body";
12
+ const cellScopeKeys = [
13
+ "$table",
14
+ "$grid",
15
+ "$gantt",
16
+ "isEdit",
17
+ "seq",
18
+ "rowid",
19
+ "row",
20
+ "rowIndex",
21
+ "$rowIndex",
22
+ "_rowIndex",
23
+ "column",
24
+ "columnIndex",
25
+ "$columnIndex",
26
+ "_columnIndex",
27
+ "fixed",
28
+ "source",
29
+ "type",
30
+ "isHidden",
31
+ "level",
32
+ "visibleData",
33
+ "data",
34
+ "items"
35
+ ];
36
+ const RowScopedCell = defineVxeComponent({
37
+ name: "VxeRowScopedCell",
38
+ props: [...cellScopeKeys, "contentVersion", "rowOrder", "defaultSlot"],
39
+ data() {
40
+ const props = this.$props;
41
+ const scope = {};
42
+ for (const key of cellScopeKeys) {
43
+ Object.defineProperty(scope, key, { enumerable: true, get: () => props[key] });
44
+ }
45
+ return { cellScope: Object.freeze(scope) };
46
+ },
47
+ render(h) {
48
+ void this.contentVersion;
49
+ void this.rowOrder;
50
+ void this.defaultSlot;
51
+ const scope = this.cellScope;
52
+ return h("div", {
53
+ class: "vxe-cell--wrapper vxe-body-cell--wrapper",
54
+ attrs: { rowid: scope.rowid, colid: scope.column.id }
55
+ }, scope.column.renderCell(h, scope));
56
+ }
57
+ });
11
58
  const isVMScrollProcess = ($xeTable) => {
12
59
  const tableProps = $xeTable;
13
60
  const tableReactData = $xeTable;
@@ -330,19 +377,17 @@ function renderTdColumn(h, $xeTable, options, rowRest, seq, rowid, fixedType, is
330
377
  }
331
378
  const clVNs = [];
332
379
  if (!isVNPreEmptyStatus) {
333
- clVNs.push(
334
- h(
335
- "div",
336
- {
337
- attrs: {
338
- colid,
339
- rowid
340
- },
341
- class: "vxe-cell--wrapper vxe-body-cell--wrapper"
342
- },
343
- column.renderCell(h, cellParams)
344
- )
345
- );
380
+ if (column.rowScopedSlot && slots && slots.default && !type && !editRender && !treeNode && !tableReactData.isRowGroupStatus) {
381
+ clVNs.push(h(RowScopedCell, {
382
+ key: rowid,
383
+ props: { ...cellParams, contentVersion: rowRest.contentVersion, rowOrder: tableInternalData.afterFullRowMaps, defaultSlot: slots.default }
384
+ }));
385
+ } else {
386
+ clVNs.push(h("div", {
387
+ class: "vxe-cell--wrapper vxe-body-cell--wrapper",
388
+ attrs: { colid, rowid }
389
+ }, column.renderCell(h, cellParams)));
390
+ }
346
391
  }
347
392
  tdVNs.push(
348
393
  h(
@@ -32,6 +32,7 @@ export declare const columnProps: {
32
32
  headerClassName: (FunctionConstructor | StringConstructor)[];
33
33
  footerClassName: (FunctionConstructor | StringConstructor)[];
34
34
  formatter: PropType<VxeColumnPropTypes.Formatter<any>>;
35
+ rowScopedSlot: BooleanConstructor;
35
36
  headerFormatter: PropType<VxeColumnPropTypes.HeaderFormatter>;
36
37
  footerFormatter: PropType<VxeColumnPropTypes.FooterFormatter>;
37
38
  padding: {
@@ -109,6 +110,7 @@ declare const _default: import("vue/types/vue").ExtendedVue<import("vue").defaul
109
110
  headerClassName: string | Function;
110
111
  footerClassName: string | Function;
111
112
  formatter: VxeColumnPropTypes.Formatter<any>;
113
+ rowScopedSlot: boolean;
112
114
  headerFormatter: VxeColumnPropTypes.HeaderFormatter;
113
115
  footerFormatter: VxeColumnPropTypes.FooterFormatter<any>;
114
116
  padding: VxeColumnPropTypes.Padding;
@@ -51,6 +51,8 @@ const columnProps = {
51
51
  footerClassName: [String, Function],
52
52
  // 格式化显示内容
53
53
  formatter: [Function, Array, String],
54
+ // 只读插槽以独立组件订阅行内容及实际使用的窗口参数。
55
+ rowScopedSlot: Boolean,
54
56
  // 格式化表头显示内容
55
57
  headerFormatter: [Function, Array, String],
56
58
  // 格式化表尾显示内容
@@ -115,6 +115,7 @@ class ColumnInfo {
115
115
  dragSort: colConfs.dragSort,
116
116
  rowResize: colConfs.rowResize,
117
117
  cellType: colConfs.cellType,
118
+ rowScopedSlot: colConfs.rowScopedSlot,
118
119
  cellRender: colConfs.cellRender,
119
120
  editRender,
120
121
  contentRender: colConfs.contentRender,
@@ -18,6 +18,7 @@ declare const _default: import("vue/types/vue").ExtendedVue<import("vue").defaul
18
18
  headerClassName: string | Function;
19
19
  footerClassName: string | Function;
20
20
  formatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Formatter<any>;
21
+ rowScopedSlot: boolean;
21
22
  headerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.HeaderFormatter;
22
23
  footerFormatter: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.FooterFormatter<any>;
23
24
  padding: import("vxe-pc-ui/types/components/column").VxeColumnPropTypes.Padding;
@@ -1,7 +1,9 @@
1
1
  import type { VxeTableDefines } from '../../../types';
2
2
  declare const _default: import("vue/types/vue").ExtendedVue<import("vue").default, {
3
3
  headerColumn: VxeTableDefines.ColumnInfo<any>[][];
4
- }, unknown, unknown, {
4
+ }, unknown, {
5
+ groupedHeaderRows: VxeTableDefines.ColumnInfo<any>[][];
6
+ }, {
5
7
  tableData: any[];
6
8
  tableColumn: VxeTableDefines.ColumnInfo<any>[];
7
9
  tableGroupColumn: VxeTableDefines.ColumnInfo<any>[];
@@ -1,12 +1,35 @@
1
1
  import XEUtils from "xe-utils";
2
2
  import { VxeUI } from "@vxe-ui/core";
3
3
  import { isEnableConf, getClass, getDefaultConfig, hasEnableConf } from "../../ui/src/utils";
4
- import { getCalcHeight, convertHeaderColumnToRows, convertHeaderToGridRows } from "./util";
4
+ import { getCalcHeight, convertHeaderColumnToRows, convertHeaderToGridRows, getLastChildColumn } from "./util";
5
5
  import { getSlotVNs } from "../../ui/src/vn";
6
6
  const { renderer, renderEmptyElement } = VxeUI;
7
7
  const sourceType = "table";
8
8
  const renderType = "header";
9
- function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols) {
9
+ function projectHeaderWindow(leaves, rows, columnCache) {
10
+ var _a;
11
+ const groups = /* @__PURE__ */ new Map();
12
+ const headers = rows.map(() => []);
13
+ for (const leaf of leaves) {
14
+ let column = leaf;
15
+ while (column) {
16
+ const headerRow = headers[column.level - 1];
17
+ if (!headerRow) break;
18
+ const group = groups.get(column);
19
+ if (group) {
20
+ group.span++;
21
+ group.width += leaf.renderWidth;
22
+ group.lastLeaf = leaf;
23
+ } else {
24
+ headerRow.push(column);
25
+ groups.set(column, { span: 1, width: leaf.renderWidth, lastLeaf: leaf });
26
+ }
27
+ column = column.parentId ? (_a = columnCache[column.parentId]) == null ? void 0 : _a.column : void 0;
28
+ }
29
+ }
30
+ return { headers, groups };
31
+ }
32
+ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols, groups) {
10
33
  const props = _vm;
11
34
  const $xeTable = _vm.$parent;
12
35
  const $xeGrid = $xeTable.$xeGrid;
@@ -79,9 +102,11 @@ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, co
79
102
  const thAttrs = {
80
103
  colid
81
104
  };
105
+ const group = groups == null ? void 0 : groups.get(column);
82
106
  let isMergeCell = false;
83
107
  if (!showCustomHeader) {
84
- thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null;
108
+ const colSpan = group ? group.span : column.colSpan;
109
+ thAttrs.colspan = colSpan > 1 ? colSpan : null;
85
110
  thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null;
86
111
  }
87
112
  if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
@@ -139,6 +164,8 @@ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, co
139
164
  tcStyle.minHeight = `${currCellHeight}px`;
140
165
  }
141
166
  if (showCustomHeader) {
167
+ } else if (isColGroup && group) {
168
+ tcStyle.width = `${group.width}px`;
142
169
  } else if (isColGroup && !isLastRow) {
143
170
  let childWidth = 0;
144
171
  XEUtils.eachTree(column.children, (childRow) => {
@@ -212,7 +239,7 @@ function renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, co
212
239
  /**
213
240
  * 列宽拖动
214
241
  */
215
- !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow) ? h("div", {
242
+ !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow) && (!group || !isColGroup || group.lastLeaf === getLastChildColumn(column)) ? h("div", {
216
243
  class: "vxe-cell--col-resizable",
217
244
  on: {
218
245
  mousedown: (evnt) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
@@ -348,13 +375,14 @@ function renderFilterRows(h, _vm, isOptimizeMode, cols) {
348
375
  );
349
376
  });
350
377
  }
351
- function renderHeads(h, _vm, isGroup, isOptimizeMode, headerGroups, renderColumnList) {
378
+ function renderHeads(h, _vm, isGroup, isOptimizeMode, headerGroups, renderColumnList, groups) {
352
379
  const props = _vm;
353
380
  const $xeTable = _vm.$parent;
354
381
  const tableProps = $xeTable;
355
382
  const { fixedType } = props;
356
383
  const { headerRowClassName, headerRowStyle } = tableProps;
357
384
  const floatingFilterOpts = $xeTable.computeFloatingFilterOpts;
385
+ const groupRowStyle = groups ? { height: `${getCalcHeight($xeTable.computeHeaderCellOpts.height) || $xeTable.computeDefaultRowHeight}px` } : void 0;
358
386
  const rowVNs = headerGroups.map((cols, _rowIndex) => {
359
387
  const params = { $table: $xeTable, rowIndex: _rowIndex, _rowIndex, $rowIndex: _rowIndex, fixed: fixedType, type: renderType };
360
388
  return h(
@@ -362,9 +390,9 @@ function renderHeads(h, _vm, isGroup, isOptimizeMode, headerGroups, renderColumn
362
390
  {
363
391
  key: _rowIndex,
364
392
  class: ["vxe-header--row", headerRowClassName ? XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName : ""],
365
- style: headerRowStyle ? XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle : void 0
393
+ style: headerRowStyle ? XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle : groupRowStyle
366
394
  },
367
- renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols)
395
+ renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, _rowIndex, cols, groups)
368
396
  );
369
397
  });
370
398
  if (floatingFilterOpts.enabled) {
@@ -399,6 +427,11 @@ var header_default = {
399
427
  headerColumn
400
428
  };
401
429
  },
430
+ computed: {
431
+ groupedHeaderRows() {
432
+ return convertHeaderColumnToRows(this.tableGroupColumn || []);
433
+ }
434
+ },
402
435
  watch: {
403
436
  tableColumn() {
404
437
  const _vm = this;
@@ -459,7 +492,13 @@ var header_default = {
459
492
  let renderHeaderList = headerColumn;
460
493
  let renderColumnList = tableColumn;
461
494
  const isOptimizeMode = isHeaderRenderOptimize;
462
- if (isGroup) {
495
+ let groups;
496
+ if (isGroup && isOptimizeMode) {
497
+ renderColumnList = fixedType ? fixedColumn : tableColumn;
498
+ const projection = projectHeaderWindow(renderColumnList, headerColumn, fullColumnIdData);
499
+ renderHeaderList = projection.headers;
500
+ groups = projection.groups;
501
+ } else if (isGroup) {
463
502
  renderColumnList = visibleColumn;
464
503
  } else {
465
504
  if (!isOptimizeMode || !isColLoading && (fixedType || !overflowX)) {
@@ -565,7 +604,7 @@ var header_default = {
565
604
  {
566
605
  ref: "refHeaderTHead"
567
606
  },
568
- renderHeads(h, _vm, isGroup, isOptimizeMode, renderHeaderList, renderColumnList)
607
+ renderHeads(h, _vm, isGroup, isOptimizeMode, renderHeaderList, renderColumnList, groups)
569
608
  )
570
609
  ]
571
610
  ),
@@ -610,12 +649,10 @@ var header_default = {
610
649
  const tableProps = $xeTable;
611
650
  const tableReactData = $xeTable;
612
651
  const tableInternalData = $xeTable;
613
- const props = _vm;
614
652
  const { showCustomHeader } = tableProps;
615
653
  const { collectColumn, visibleColumn } = tableInternalData;
616
- const { tableGroupColumn } = props;
617
654
  const { isGroup } = tableReactData;
618
- let spanColumns = isGroup ? convertHeaderColumnToRows(tableGroupColumn) : [];
655
+ let spanColumns = isGroup ? _vm.groupedHeaderRows : [];
619
656
  let visibleColgroups = [];
620
657
  if (showCustomHeader && spanColumns.length > 1) {
621
658
  visibleColgroups = convertHeaderToGridRows(spanColumns);