@meethive/components 0.0.3 → 0.0.4
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/es/AutoComplete/AutoComplete.js +71 -80
- package/es/BadgeStatus/Badge.js +38 -47
- package/es/CardSelect/CardSelect.js +115 -137
- package/es/CheckButton/CheckButton.js +102 -118
- package/es/ConfigProvider/ConfigProvider.js +44 -68
- package/es/DragModal/DragModal.js +191 -212
- package/es/EditTable/Body.js +158 -189
- package/es/EditTable/CellRender.js +10 -12
- package/es/EditTable/EditTable.js +385 -434
- package/es/EditTable/FormItem.js +140 -169
- package/es/EditTable/Group.js +171 -204
- package/es/EditTable/Header.js +57 -63
- package/es/EditTable/HeaderRender.js +10 -12
- package/es/EditTable/components/ContextMenu/Menu.js +78 -86
- package/es/EditTable/components/Search/Search.js +151 -163
- package/es/EditTable/components/Search/Sort.js +104 -119
- package/es/Ellipsis/Ellipsis.js +144 -148
- package/es/Empty/Empty.js +51 -57
- package/es/FullPage/FullPage.js +20 -19
- package/es/Icon/Icon.js +42 -49
- package/es/LocaleProvider/LocaleProvider.js +32 -38
- package/es/Markdown/Markdown.js +101 -118
- package/es/PermissionButton/PermissionButton.js +118 -118
- package/es/ProLayout/Basic/BasicLayout.js +301 -418
- package/es/ProLayout/Basic/Header.js +91 -111
- package/es/ProLayout/PageContainer/index.js +267 -344
- package/es/ProLayout/SiderMenu/BaseMenu.js +186 -240
- package/es/ProTable/Alert.js +39 -40
- package/es/ProTable/Content.js +84 -97
- package/es/ProTable/Header.js +32 -33
- package/es/ProTable/Pagination.js +56 -55
- package/es/ProTable/ProTable.js +256 -276
- package/es/RadioButton/RadioButton.js +48 -53
- package/es/Scrollbar/Bar.js +65 -76
- package/es/Scrollbar/Scrollbar.js +129 -161
- package/es/Scrollbar/Thumb.js +101 -150
- package/es/Search/Item.js +208 -236
- package/es/Search/Search.js +90 -90
- package/es/Skeleton/Skeleton.js +26 -27
- package/es/Skeleton/components/DashBoardCard.js +26 -27
- package/es/Skeleton/components/DashBoardChart.js +26 -27
- package/es/Skeleton/components/Detail.js +26 -27
- package/es/Skeleton/components/Drawer.js +26 -27
- package/es/Skeleton/components/Item.js +55 -54
- package/es/Skeleton/components/List.js +29 -27
- package/es/Skeleton/components/ListCard.js +28 -28
- package/es/Skeleton/components/ListCardItem.js +20 -20
- package/es/Skeleton/components/ListTable.js +26 -27
- package/es/Skeleton/components/Page.js +27 -26
- package/es/Skeleton/components/Search.js +16 -16
- package/es/Skeleton/components/Tree.js +26 -27
- package/es/TimeFormat/TimeFormat.js +32 -36
- package/es/Title/Title.js +23 -26
- package/es/ValueItem/ValueItem.js +100 -113
- package/es/VirtualTable/VirtualTable.js +235 -271
- package/lib/AutoComplete/AutoComplete.js +71 -80
- package/lib/BadgeStatus/Badge.js +38 -47
- package/lib/CardSelect/CardSelect.js +115 -137
- package/lib/CheckButton/CheckButton.js +102 -118
- package/lib/ConfigProvider/ConfigProvider.js +44 -68
- package/lib/DragModal/DragModal.js +191 -212
- package/lib/EditTable/Body.js +158 -189
- package/lib/EditTable/CellRender.js +10 -12
- package/lib/EditTable/EditTable.js +385 -434
- package/lib/EditTable/FormItem.js +140 -169
- package/lib/EditTable/Group.js +171 -204
- package/lib/EditTable/Header.js +57 -63
- package/lib/EditTable/HeaderRender.js +10 -12
- package/lib/EditTable/components/ContextMenu/Menu.js +78 -86
- package/lib/EditTable/components/Search/Search.js +151 -163
- package/lib/EditTable/components/Search/Sort.js +104 -119
- package/lib/Ellipsis/Ellipsis.js +144 -148
- package/lib/Empty/Empty.js +51 -57
- package/lib/FullPage/FullPage.js +20 -19
- package/lib/Icon/Icon.js +42 -49
- package/lib/LocaleProvider/LocaleProvider.js +32 -38
- package/lib/Markdown/Markdown.js +101 -118
- package/lib/PermissionButton/PermissionButton.js +118 -118
- package/lib/ProLayout/Basic/BasicLayout.js +301 -418
- package/lib/ProLayout/Basic/Header.js +91 -111
- package/lib/ProLayout/PageContainer/index.js +267 -344
- package/lib/ProLayout/SiderMenu/BaseMenu.js +186 -240
- package/lib/ProTable/Alert.js +39 -40
- package/lib/ProTable/Content.js +84 -97
- package/lib/ProTable/Header.js +32 -33
- package/lib/ProTable/Pagination.js +56 -55
- package/lib/ProTable/ProTable.js +256 -276
- package/lib/RadioButton/RadioButton.js +48 -53
- package/lib/Scrollbar/Bar.js +65 -76
- package/lib/Scrollbar/Scrollbar.js +129 -161
- package/lib/Scrollbar/Thumb.js +101 -150
- package/lib/Search/Item.js +208 -236
- package/lib/Search/Search.js +90 -90
- package/lib/Skeleton/Skeleton.js +26 -27
- package/lib/Skeleton/components/DashBoardCard.js +26 -27
- package/lib/Skeleton/components/DashBoardChart.js +26 -27
- package/lib/Skeleton/components/Detail.js +26 -27
- package/lib/Skeleton/components/Drawer.js +26 -27
- package/lib/Skeleton/components/Item.js +55 -54
- package/lib/Skeleton/components/List.js +29 -27
- package/lib/Skeleton/components/ListCard.js +28 -28
- package/lib/Skeleton/components/ListCardItem.js +20 -20
- package/lib/Skeleton/components/ListTable.js +26 -27
- package/lib/Skeleton/components/Page.js +27 -26
- package/lib/Skeleton/components/Search.js +16 -16
- package/lib/Skeleton/components/Tree.js +26 -27
- package/lib/TimeFormat/TimeFormat.js +32 -36
- package/lib/Title/Title.js +23 -26
- package/lib/ValueItem/ValueItem.js +100 -113
- package/lib/VirtualTable/VirtualTable.js +235 -271
- package/package.json +1 -1
package/lib/Scrollbar/Thumb.js
CHANGED
|
@@ -1,150 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
document.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
document.onselectstart
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
scrollbar.wrapElement[bar.value.scroll] =
|
|
104
|
-
(thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) / 100
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const mouseUpDocumentHandler = () => {
|
|
108
|
-
cursorDown = false
|
|
109
|
-
thumbState.value[bar.value.axis] = 0
|
|
110
|
-
document.removeEventListener('mousemove', mouseMoveDocumentHandler)
|
|
111
|
-
document.removeEventListener('mouseup', mouseUpDocumentHandler)
|
|
112
|
-
restoreOnselectstart()
|
|
113
|
-
if (cursorLeave) visible.value = false
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const mouseMoveScrollbarHandler = () => {
|
|
117
|
-
cursorLeave = false
|
|
118
|
-
visible.value = !!props.size
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const mouseLeaveScrollbarHandler = () => {
|
|
122
|
-
cursorLeave = true
|
|
123
|
-
visible.value = cursorDown
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
onBeforeUnmount(() => {
|
|
127
|
-
restoreOnselectstart()
|
|
128
|
-
document.removeEventListener('mouseup', mouseUpDocumentHandler)
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
const restoreOnselectstart = () => {
|
|
132
|
-
if (document.onselectstart !== originalOnSelectStart)
|
|
133
|
-
document.onselectstart = originalOnSelectStart
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mousemove', mouseMoveScrollbarHandler)
|
|
137
|
-
useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mouseleave', mouseLeaveScrollbarHandler)
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
props,
|
|
141
|
-
instance,
|
|
142
|
-
thumb,
|
|
143
|
-
visible,
|
|
144
|
-
hashId,
|
|
145
|
-
thumbStyle,
|
|
146
|
-
clickThumbHandler,
|
|
147
|
-
clickTrackHandler
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
})
|
|
1
|
+
import { defineComponent, computed, inject, onBeforeUnmount, ref, toRef } from 'vue';
|
|
2
|
+
import { useEventListener } from '@vueuse/core';
|
|
3
|
+
import { isClient } from '@meethive/utils';
|
|
4
|
+
import { scrollbarContextKey } from './constants';
|
|
5
|
+
import { BAR_MAP, renderThumbStyle } from './util';
|
|
6
|
+
import { thumbProps } from './thumbProps';
|
|
7
|
+
import useScrollbarStyle from './style';
|
|
8
|
+
export default defineComponent({
|
|
9
|
+
name: 'ScrollbarThumb',
|
|
10
|
+
props: thumbProps,
|
|
11
|
+
setup(props) {
|
|
12
|
+
const scrollbar = inject(scrollbarContextKey);
|
|
13
|
+
if (!scrollbar) throw new Error('can not inject scrollbar context');
|
|
14
|
+
const instance = ref();
|
|
15
|
+
const thumb = ref();
|
|
16
|
+
const thumbState = ref({});
|
|
17
|
+
const visible = ref(false);
|
|
18
|
+
const prefixCls = computed(() => 'j-scrollbar');
|
|
19
|
+
const [wrapSSR, hashId] = useScrollbarStyle(prefixCls);
|
|
20
|
+
let cursorDown = false;
|
|
21
|
+
let cursorLeave = false;
|
|
22
|
+
let originalOnSelectStart = isClient ? document.onselectstart : null;
|
|
23
|
+
const bar = computed(() => BAR_MAP[props.vertical ? 'vertical' : 'horizontal']);
|
|
24
|
+
const thumbStyle = computed(() => renderThumbStyle({
|
|
25
|
+
size: props.size,
|
|
26
|
+
move: props.move,
|
|
27
|
+
bar: bar.value
|
|
28
|
+
}));
|
|
29
|
+
const offsetRatio = computed(() => instance.value?.[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value?.[bar.value.offset]);
|
|
30
|
+
const clickThumbHandler = e => {
|
|
31
|
+
// prevent click event of middle and right button
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
if (e.ctrlKey || [1, 2].includes(e.button)) return;
|
|
34
|
+
window.getSelection()?.removeAllRanges();
|
|
35
|
+
startDrag(e);
|
|
36
|
+
const el = e.currentTarget;
|
|
37
|
+
if (!el) return;
|
|
38
|
+
thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
|
|
39
|
+
};
|
|
40
|
+
const clickTrackHandler = e => {
|
|
41
|
+
if (!thumb.value || !instance.value || !scrollbar.wrapElement) return;
|
|
42
|
+
const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]);
|
|
43
|
+
const thumbHalf = thumb.value[bar.value.offset] / 2;
|
|
44
|
+
const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
45
|
+
scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
|
|
46
|
+
};
|
|
47
|
+
const startDrag = e => {
|
|
48
|
+
e.stopImmediatePropagation();
|
|
49
|
+
cursorDown = true;
|
|
50
|
+
document.addEventListener('mousemove', mouseMoveDocumentHandler);
|
|
51
|
+
document.addEventListener('mouseup', mouseUpDocumentHandler);
|
|
52
|
+
originalOnSelectStart = document.onselectstart;
|
|
53
|
+
document.onselectstart = () => false;
|
|
54
|
+
};
|
|
55
|
+
const mouseMoveDocumentHandler = e => {
|
|
56
|
+
if (!instance.value || !thumb.value) return;
|
|
57
|
+
if (cursorDown === false) return;
|
|
58
|
+
const prevPage = thumbState.value[bar.value.axis];
|
|
59
|
+
if (!prevPage) return;
|
|
60
|
+
const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
|
|
61
|
+
const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
|
|
62
|
+
const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
63
|
+
scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
|
|
64
|
+
};
|
|
65
|
+
const mouseUpDocumentHandler = () => {
|
|
66
|
+
cursorDown = false;
|
|
67
|
+
thumbState.value[bar.value.axis] = 0;
|
|
68
|
+
document.removeEventListener('mousemove', mouseMoveDocumentHandler);
|
|
69
|
+
document.removeEventListener('mouseup', mouseUpDocumentHandler);
|
|
70
|
+
restoreOnselectstart();
|
|
71
|
+
if (cursorLeave) visible.value = false;
|
|
72
|
+
};
|
|
73
|
+
const mouseMoveScrollbarHandler = () => {
|
|
74
|
+
cursorLeave = false;
|
|
75
|
+
visible.value = !!props.size;
|
|
76
|
+
};
|
|
77
|
+
const mouseLeaveScrollbarHandler = () => {
|
|
78
|
+
cursorLeave = true;
|
|
79
|
+
visible.value = cursorDown;
|
|
80
|
+
};
|
|
81
|
+
onBeforeUnmount(() => {
|
|
82
|
+
restoreOnselectstart();
|
|
83
|
+
document.removeEventListener('mouseup', mouseUpDocumentHandler);
|
|
84
|
+
});
|
|
85
|
+
const restoreOnselectstart = () => {
|
|
86
|
+
if (document.onselectstart !== originalOnSelectStart) document.onselectstart = originalOnSelectStart;
|
|
87
|
+
};
|
|
88
|
+
useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mousemove', mouseMoveScrollbarHandler);
|
|
89
|
+
useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mouseleave', mouseLeaveScrollbarHandler);
|
|
90
|
+
return {
|
|
91
|
+
props,
|
|
92
|
+
instance,
|
|
93
|
+
thumb,
|
|
94
|
+
visible,
|
|
95
|
+
hashId,
|
|
96
|
+
thumbStyle,
|
|
97
|
+
clickThumbHandler,
|
|
98
|
+
clickTrackHandler
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|