@v-c/table 1.1.0 → 1.1.2
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/Body/BodyRow.d.ts +1 -0
- package/dist/Body/BodyRow.js +11 -10
- package/dist/Cell/index.d.ts +1 -0
- package/dist/Cell/index.js +5 -3
- package/dist/VirtualTable/VirtualCell.js +2 -1
- package/dist/hooks/useFixedInfo.d.ts +1 -1
- package/dist/hooks/useRowInfo.d.ts +1 -1
- package/dist/stickyScrollBar.js +16 -4
- package/dist/sugar/Column.js +0 -9
- package/dist/sugar/ColumnGroup.js +0 -9
- package/package.json +1 -1
package/dist/Body/BodyRow.d.ts
CHANGED
|
@@ -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;
|
package/dist/Body/BodyRow.js
CHANGED
|
@@ -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
|
-
|
|
28
|
+
let hoverRowSpan;
|
|
29
|
+
if (expandedRowOffset && expandable.value && colIndex < expandedRowOffset) {
|
|
29
30
|
const { rowSpan = 1 } = additionalCellProps;
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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);
|
package/dist/Cell/index.d.ts
CHANGED
package/dist/Cell/index.js
CHANGED
|
@@ -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
|
|
120
|
+
const mergedHoverRowSpan = hoverRowSpan ?? mergedRowSpan;
|
|
121
|
+
const [hovering, onHover] = useHoverState(index, mergedHoverRowSpan, tableContext);
|
|
120
122
|
const onMouseEnter = (event) => {
|
|
121
|
-
if (record) onHover(index, index +
|
|
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,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { ColumnType, StickyOffsets } from '../interface';
|
|
3
|
-
export default function useFixedInfo<RecordType>(flattenColumns: Ref<readonly ColumnType<RecordType>[]> | readonly ColumnType<RecordType>[], stickyOffsets: Ref<StickyOffsets> | StickyOffsets):
|
|
3
|
+
export default function useFixedInfo<RecordType>(flattenColumns: Ref<readonly ColumnType<RecordType>[]> | readonly ColumnType<RecordType>[], stickyOffsets: Ref<StickyOffsets> | StickyOffsets): any;
|
|
@@ -8,7 +8,7 @@ export default function useRowInfo<RecordType>(record: Ref<RecordType> | RecordT
|
|
|
8
8
|
rowSupportExpand: import('vue').ComputedRef<boolean>;
|
|
9
9
|
expandable: import('vue').ComputedRef<boolean>;
|
|
10
10
|
rowProps: import('vue').ComputedRef<{
|
|
11
|
-
className:
|
|
11
|
+
className: any;
|
|
12
12
|
onClick: (event: MouseEvent) => void;
|
|
13
13
|
innerHTML?: string | undefined | undefined;
|
|
14
14
|
class?: any;
|
package/dist/stickyScrollBar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useInjectTableContext } from "./context/TableContext.js";
|
|
2
2
|
import { useLayoutState } from "./hooks/useFrame.js";
|
|
3
3
|
import { getOffset } from "./utils/offsetUtil.js";
|
|
4
|
-
import { computed, createVNode, defineComponent, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
4
|
+
import { computed, createVNode, defineComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
5
5
|
import { clsx } from "@v-c/util";
|
|
6
6
|
import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
|
|
7
7
|
import getScrollBarSize from "@v-c/util/dist/getScrollBarSize";
|
|
@@ -33,8 +33,13 @@ var StickyScrollBar = /* @__PURE__ */ defineComponent({
|
|
|
33
33
|
});
|
|
34
34
|
const isActive = ref(false);
|
|
35
35
|
const rafRef = ref(null);
|
|
36
|
-
const bodyScrollWidth =
|
|
37
|
-
const bodyWidth =
|
|
36
|
+
const bodyScrollWidth = ref(0);
|
|
37
|
+
const bodyWidth = ref(0);
|
|
38
|
+
const syncBodySize = () => {
|
|
39
|
+
const bodyNode = props.scrollBodyRef.value;
|
|
40
|
+
bodyScrollWidth.value = bodyNode?.scrollWidth || 0;
|
|
41
|
+
bodyWidth.value = bodyNode?.clientWidth || 0;
|
|
42
|
+
};
|
|
38
43
|
const scrollBarWidth = computed(() => {
|
|
39
44
|
const totalWidth = bodyScrollWidth.value;
|
|
40
45
|
const clientWidth = bodyWidth.value;
|
|
@@ -66,6 +71,7 @@ var StickyScrollBar = /* @__PURE__ */ defineComponent({
|
|
|
66
71
|
const checkScrollBarVisible = () => {
|
|
67
72
|
raf.cancel(rafRef.value);
|
|
68
73
|
rafRef.value = raf(() => {
|
|
74
|
+
syncBodySize();
|
|
69
75
|
if (!props.scrollBodyRef.value || !props.container) return;
|
|
70
76
|
const container = props.container;
|
|
71
77
|
const tableOffsetTop = getOffset(props.scrollBodyRef.value).top;
|
|
@@ -94,7 +100,7 @@ var StickyScrollBar = /* @__PURE__ */ defineComponent({
|
|
|
94
100
|
onMounted(() => {
|
|
95
101
|
document.body.addEventListener(MOUSEUP_EVENT, onMouseUp, false);
|
|
96
102
|
document.body.addEventListener(MOUSEMOVE_EVENT, onMouseMove, false);
|
|
97
|
-
checkScrollBarVisible
|
|
103
|
+
nextTick(checkScrollBarVisible);
|
|
98
104
|
});
|
|
99
105
|
const removeScrollListeners = ref(null);
|
|
100
106
|
onBeforeUnmount(() => {
|
|
@@ -103,6 +109,12 @@ var StickyScrollBar = /* @__PURE__ */ defineComponent({
|
|
|
103
109
|
raf.cancel(rafRef.value);
|
|
104
110
|
removeScrollListeners.value?.();
|
|
105
111
|
});
|
|
112
|
+
watch(() => props.scrollBodyRef.value, () => {
|
|
113
|
+
nextTick(checkScrollBarVisible);
|
|
114
|
+
}, {
|
|
115
|
+
immediate: true,
|
|
116
|
+
flush: "post"
|
|
117
|
+
});
|
|
106
118
|
watch(() => [scrollBarWidth.value, isActive.value], () => {
|
|
107
119
|
checkScrollBarVisible();
|
|
108
120
|
});
|
package/dist/sugar/Column.js
CHANGED