@v-c/table 1.1.0-rc.2 → 1.1.1

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.
@@ -27,6 +27,7 @@ export declare function getCellProps<RecordType>(rowInfo: ReturnType<typeof useR
27
27
  fixedInfo: import('../utils/fixUtil').FixedInfo;
28
28
  appendCellNode: any;
29
29
  additionalCellProps: Partial<import('../interface').CellAttributes>;
30
+ hoverRowSpan: number | undefined;
30
31
  };
31
32
  declare const BodyRow: import('vue').DefineComponent<BodyRowProps<any>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<BodyRowProps<any>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
32
33
  export default BodyRow;
@@ -25,22 +25,22 @@ function getCellProps(rowInfo, record, column, colIndex, indent, index, rowKeys
25
25
  onExpand: onTriggerExpand
26
26
  })]);
27
27
  const additionalCellProps = column.onCell?.(record, index) || {};
28
- if (expandedRowOffset) {
28
+ let hoverRowSpan;
29
+ if (expandedRowOffset && expandable.value && colIndex < expandedRowOffset) {
29
30
  const { rowSpan = 1 } = additionalCellProps;
30
- if (expandable.value && rowSpan && colIndex < expandedRowOffset) {
31
- let currentRowSpan = rowSpan;
32
- for (let i = index; i < index + rowSpan; i += 1) {
33
- const keyInRow = rowKeys[i];
34
- if (expandedKeys.has(keyInRow)) currentRowSpan += 1;
35
- }
36
- additionalCellProps.rowSpan = currentRowSpan;
31
+ if (rowSpan) {
32
+ hoverRowSpan = rowSpan;
33
+ let expandedCount = 0;
34
+ for (let i = index; i < index + rowSpan; i += 1) if (expandedKeys.has(rowKeys[i])) expandedCount += 1;
35
+ additionalCellProps.rowSpan = rowSpan + expandedCount;
37
36
  }
38
37
  }
39
38
  return {
40
39
  key,
41
40
  fixedInfo,
42
41
  appendCellNode,
43
- additionalCellProps
42
+ additionalCellProps,
43
+ hoverRowSpan
44
44
  };
45
45
  }
46
46
  var BodyRow = /* @__PURE__ */ defineComponent({
@@ -89,7 +89,7 @@ var BodyRow = /* @__PURE__ */ defineComponent({
89
89
  "style": mergedRowStyle
90
90
  }), _isSlot(_slot = flattenColumns.map((column, colIndex) => {
91
91
  const { render, dataIndex, className: columnClassName } = column;
92
- const { key, fixedInfo, appendCellNode, additionalCellProps } = getCellProps(rowInfo, record, column, colIndex, indent, index, rowKeys, expandedRowInfo?.offset);
92
+ const { key, fixedInfo, appendCellNode, additionalCellProps, hoverRowSpan } = getCellProps(rowInfo, record, column, colIndex, indent, index, rowKeys, expandedRowInfo?.offset);
93
93
  const scope = column.rowScope ? column.rowScope : column.title ? "row" : void 0;
94
94
  const CellComponent = column.rowScope ? scopeCellComponent : BodyCellComponent;
95
95
  return createVNode(Cell, mergeProps({
@@ -109,6 +109,7 @@ var BodyRow = /* @__PURE__ */ defineComponent({
109
109
  "rowType": "body"
110
110
  }, fixedInfo, {
111
111
  "additionalProps": additionalCellProps,
112
+ "hoverRowSpan": hoverRowSpan,
112
113
  "column": column,
113
114
  "appendNode": appendCellNode
114
115
  }), null);
@@ -17,6 +17,7 @@ export interface CellProps<RecordType extends DefaultRecordType> {
17
17
  children?: any;
18
18
  colSpan?: number;
19
19
  rowSpan?: number;
20
+ hoverRowSpan?: number;
20
21
  scope?: ScopeType;
21
22
  ellipsis?: CellEllipsisType;
22
23
  align?: AlignType;
@@ -55,6 +55,7 @@ var Cell = /* @__PURE__ */ defineComponent({
55
55
  "children",
56
56
  "colSpan",
57
57
  "rowSpan",
58
+ "hoverRowSpan",
58
59
  "scope",
59
60
  "ellipsis",
60
61
  "align",
@@ -90,7 +91,7 @@ var Cell = /* @__PURE__ */ defineComponent({
90
91
  return [isFixStart.value && fixedStartShadow ? absScroll - (offsetFixedStartShadow || 0) >= 1 : false, isFixEnd && fixedEndShadow ? scrollWidth - absScroll - (offsetFixedEndShadow || 0) > 1 : false];
91
92
  });
92
93
  return () => {
93
- const { component: Component = "td", ellipsis, scope, prefixCls, className, style, align, record, index, colIndex, renderIndex, dataIndex, render, column, rowType, colSpan, rowSpan, fixStart, fixEnd, fixedStartShadow, fixedEndShadow, zIndex, zIndexReverse, additionalProps = {}, isSticky, appendNode } = props;
94
+ const { component: Component = "td", ellipsis, scope, prefixCls, className, style, align, record, index, colIndex, renderIndex, dataIndex, render, column, rowType, colSpan, rowSpan, hoverRowSpan, fixStart, fixEnd, fixedStartShadow, fixedEndShadow, zIndex, zIndexReverse, additionalProps = {}, isSticky, appendNode } = props;
94
95
  const cellPrefixCls = `${prefixCls}-cell`;
95
96
  const mergedAppendNode = appendNode ?? slots?.appendNode?.();
96
97
  const mergedRenderIndex = renderIndex ?? index ?? 0;
@@ -116,9 +117,10 @@ var Cell = /* @__PURE__ */ defineComponent({
116
117
  }
117
118
  const mergedColSpan = legacyCellProps?.colSpan ?? additionalProps.colSpan ?? colSpan ?? 1;
118
119
  const mergedRowSpan = legacyCellProps?.rowSpan ?? additionalProps.rowSpan ?? rowSpan ?? 1;
119
- const [hovering, onHover] = useHoverState(index, mergedRowSpan, tableContext);
120
+ const mergedHoverRowSpan = hoverRowSpan ?? mergedRowSpan;
121
+ const [hovering, onHover] = useHoverState(index, mergedHoverRowSpan, tableContext);
120
122
  const onMouseEnter = (event) => {
121
- if (record) onHover(index, index + mergedRowSpan - 1);
123
+ if (record) onHover(index, index + mergedHoverRowSpan - 1);
122
124
  (additionalProps.onMouseEnter || additionalProps.onMouseenter)?.(event);
123
125
  };
124
126
  const onMouseLeave = (event) => {
@@ -30,7 +30,7 @@ var VirtualCell = /* @__PURE__ */ defineComponent({
30
30
  const { rowInfo, column, colIndex, indent, index, component, renderIndex, record, style, className, inverse, getHeight } = props;
31
31
  const { render, dataIndex, className: columnClassName, width: colWidth } = column;
32
32
  const columnsOffset = gridContext.columnsOffset || [];
33
- const { key, fixedInfo, appendCellNode, additionalCellProps } = getCellProps(rowInfo, record, column, colIndex, indent, index);
33
+ const { key, fixedInfo, appendCellNode, additionalCellProps, hoverRowSpan } = getCellProps(rowInfo, record, column, colIndex, indent, index);
34
34
  const { style: cellStyle, colSpan = 1, rowSpan = 1 } = additionalCellProps;
35
35
  const concatColWidth = getColumnWidth(colIndex - 1, colSpan, columnsOffset);
36
36
  const marginOffset = colSpan > 1 ? colWidth - concatColWidth : 0;
@@ -69,6 +69,7 @@ var VirtualCell = /* @__PURE__ */ defineComponent({
69
69
  "shouldCellUpdate": column.shouldCellUpdate
70
70
  }, fixedInfo, {
71
71
  "appendNode": appendCellNode,
72
+ "hoverRowSpan": hoverRowSpan,
72
73
  "additionalProps": {
73
74
  ...additionalCellProps,
74
75
  style: mergedStyle,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/table",
3
3
  "type": "module",
4
- "version": "1.1.0-rc.2",
4
+ "version": "1.1.1",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "vue": "^3.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@v-c/resize-observer": "^1.0.8",
23
+ "@v-c/resize-observer": "^1.1.0",
24
24
  "@v-c/util": "^1.0.19",
25
25
  "@v-c/virtual-list": "^1.0.7"
26
26
  },