@v-c/table 1.1.1 → 1.1.3
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/MeasureRow.js +15 -15
- package/dist/Cell/index.js +1 -1
- package/dist/stickyScrollBar.js +16 -4
- package/package.json +1 -1
package/dist/Body/MeasureRow.js
CHANGED
|
@@ -8,6 +8,21 @@ import isVisible from "@v-c/util/dist/Dom/isVisible";
|
|
|
8
8
|
function _isSlot(s) {
|
|
9
9
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
10
|
}
|
|
11
|
+
function cloneTitle(title) {
|
|
12
|
+
if (Array.isArray(title)) return title.map((node) => cloneTitle(node));
|
|
13
|
+
if (isVNode(title)) {
|
|
14
|
+
const cloned = cloneVNode(title, { ref: void 0 });
|
|
15
|
+
let children = cloned.children;
|
|
16
|
+
if (cloned.children?.default && typeof cloned.children.default === "function") {
|
|
17
|
+
children = filterEmpty(cloned.children?.default?.());
|
|
18
|
+
if (Array.isArray(children)) children = children.map((child) => cloneTitle(child));
|
|
19
|
+
else if (isVNode(children)) children = cloneTitle(children);
|
|
20
|
+
cloned.children.default = () => children;
|
|
21
|
+
} else if (Array.isArray(children)) cloned.children = children.map((child) => cloneTitle(child));
|
|
22
|
+
return cloned;
|
|
23
|
+
}
|
|
24
|
+
return title;
|
|
25
|
+
}
|
|
11
26
|
var MeasureRow = /* @__PURE__ */ defineComponent({
|
|
12
27
|
name: "TableMeasureRow",
|
|
13
28
|
props: [
|
|
@@ -21,21 +36,6 @@ var MeasureRow = /* @__PURE__ */ defineComponent({
|
|
|
21
36
|
const { measureRowRender } = useInjectTableContext();
|
|
22
37
|
return () => {
|
|
23
38
|
let _slot;
|
|
24
|
-
const cloneTitle = (title) => {
|
|
25
|
-
if (Array.isArray(title)) return title.map((node) => cloneTitle(node));
|
|
26
|
-
if (isVNode(title)) {
|
|
27
|
-
const cloned = cloneVNode(title, { ref: void 0 });
|
|
28
|
-
let children = cloned.children;
|
|
29
|
-
if (cloned.children?.default && typeof cloned.children.default === "function") {
|
|
30
|
-
children = filterEmpty(cloned.children?.default?.());
|
|
31
|
-
if (Array.isArray(children)) children = children.map((child) => cloneTitle(child));
|
|
32
|
-
else if (isVNode(children)) children = cloneTitle(children);
|
|
33
|
-
cloned.children.default = () => children;
|
|
34
|
-
} else if (Array.isArray(children)) cloned.children = children.map((child) => cloneTitle(child));
|
|
35
|
-
return cloned;
|
|
36
|
-
}
|
|
37
|
-
return title;
|
|
38
|
-
};
|
|
39
39
|
const measureRow = createVNode("tr", {
|
|
40
40
|
"aria-hidden": "true",
|
|
41
41
|
"class": `${props.prefixCls}-measure-row`,
|
package/dist/Cell/index.js
CHANGED
|
@@ -85,9 +85,9 @@ var Cell = /* @__PURE__ */ defineComponent({
|
|
|
85
85
|
return typeof props.fixEnd === "number" && !tableContext.allColumnsFixedLeft;
|
|
86
86
|
});
|
|
87
87
|
const shadowInfo = computed(() => {
|
|
88
|
+
if (!isFixStart.value && !isFixEnd.value) return [false, false];
|
|
88
89
|
const { fixedEndShadow, offsetFixedStartShadow, offsetFixedEndShadow, fixedStartShadow } = props;
|
|
89
90
|
const [absScroll = 0, scrollWidth = 0] = tableContext.scrollInfo || [];
|
|
90
|
-
if (!isFixStart.value && !isFixEnd.value) return [false, false];
|
|
91
91
|
return [isFixStart.value && fixedStartShadow ? absScroll - (offsetFixedStartShadow || 0) >= 1 : false, isFixEnd && fixedEndShadow ? scrollWidth - absScroll - (offsetFixedEndShadow || 0) > 1 : false];
|
|
92
92
|
});
|
|
93
93
|
return () => {
|
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
|
});
|