@king-one/antdv 1.0.5 → 1.0.7
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/cdn/index.cdn.js.map +1 -0
- package/dist/cdn/index.cdn.mjs.map +1 -0
- package/dist/es/components/form/component/form.mjs.map +1 -0
- package/dist/es/components/form/index.mjs.map +1 -0
- package/dist/es/components/form-item/component/form-item.vue2.mjs.map +1 -0
- package/dist/es/components/scroll-bar/index.mjs.map +1 -0
- package/dist/es/components/scroll-bar/src/scroll-bar.mjs.map +1 -0
- package/dist/es/components/scroll-bar/src/types.mjs.map +1 -0
- package/dist/es/components/utils/install.mjs.map +1 -0
- package/dist/es/components/virtual-list/index.mjs.map +1 -0
- package/dist/es/components/virtual-list/src/types.mjs.map +1 -0
- package/dist/es/components/virtual-list/src/virtual-list.vue2.mjs.map +1 -0
- package/dist/es/hooks/use-namespace/index.mjs.map +1 -0
- package/dist/es/installer.mjs.map +1 -0
- package/dist/lib/components/form/component/form.js.map +1 -0
- package/dist/lib/components/form/index.js.map +1 -0
- package/dist/lib/components/form-item/component/form-item.vue2.js.map +1 -0
- package/dist/lib/components/scroll-bar/index.js.map +1 -0
- package/dist/lib/components/scroll-bar/src/scroll-bar.js.map +1 -0
- package/dist/lib/components/scroll-bar/src/types.js.map +1 -0
- package/dist/lib/components/utils/install.js.map +1 -0
- package/dist/lib/components/virtual-list/index.js.map +1 -0
- package/dist/lib/components/virtual-list/src/types.js.map +1 -0
- package/dist/lib/components/virtual-list/src/virtual-list.vue2.js.map +1 -0
- package/dist/lib/hooks/use-namespace/index.js.map +1 -0
- package/dist/lib/installer.js.map +1 -0
- package/package.json +8 -4
- package/CHANGELOG.md +0 -7
- package/antdv/cdn/index.cdn.js.map +0 -1
- package/antdv/cdn/index.cdn.mjs.map +0 -1
- package/antdv/es/components/form/component/form.mjs.map +0 -1
- package/antdv/es/components/form/index.mjs.map +0 -1
- package/antdv/es/components/form-item/component/form-item.vue2.mjs.map +0 -1
- package/antdv/es/components/scroll-bar/index.mjs.map +0 -1
- package/antdv/es/components/scroll-bar/src/scroll-bar.mjs.map +0 -1
- package/antdv/es/components/scroll-bar/src/types.mjs.map +0 -1
- package/antdv/es/components/utils/install.mjs.map +0 -1
- package/antdv/es/components/virtual-list/index.mjs.map +0 -1
- package/antdv/es/components/virtual-list/src/types.mjs.map +0 -1
- package/antdv/es/components/virtual-list/src/virtual-list.vue2.mjs.map +0 -1
- package/antdv/es/hooks/use-namespace/index.mjs.map +0 -1
- package/antdv/es/installer.mjs.map +0 -1
- package/antdv/lib/components/form/component/form.js.map +0 -1
- package/antdv/lib/components/form/index.js.map +0 -1
- package/antdv/lib/components/form-item/component/form-item.vue2.js.map +0 -1
- package/antdv/lib/components/scroll-bar/index.js.map +0 -1
- package/antdv/lib/components/scroll-bar/src/scroll-bar.js.map +0 -1
- package/antdv/lib/components/scroll-bar/src/types.js.map +0 -1
- package/antdv/lib/components/utils/install.js.map +0 -1
- package/antdv/lib/components/virtual-list/index.js.map +0 -1
- package/antdv/lib/components/virtual-list/src/types.js.map +0 -1
- package/antdv/lib/components/virtual-list/src/virtual-list.vue2.js.map +0 -1
- package/antdv/lib/hooks/use-namespace/index.js.map +0 -1
- package/antdv/lib/installer.js.map +0 -1
- package/antdv/package.json +0 -29
- package/components/base/style/index.ts +0 -8
- package/components/form/component/form.ts +0 -21
- package/components/form/component/form.vue +0 -24
- package/components/form/index.ts +0 -6
- package/components/form-item/component/form-item.vue +0 -106
- package/components/form-item/index.ts +0 -0
- package/components/index.ts +0 -10
- package/components/scroll-bar/index.ts +0 -7
- package/components/scroll-bar/src/scroll-bar.tsx +0 -211
- package/components/scroll-bar/src/types.ts +0 -7
- package/components/scroll-bar/style/index.ts +0 -2
- package/components/utils/install.ts +0 -30
- package/components/virtual-list/index.ts +0 -6
- package/components/virtual-list/src/types.ts +0 -29
- package/components/virtual-list/src/virtual-list.vue +0 -47
- package/hooks/use-namespace/index.ts +0 -93
- package/index.ts +0 -4
- package/installer.ts +0 -19
- /package/{antdv → dist}/cdn/index.cdn.js +0 -0
- /package/{antdv → dist}/cdn/index.cdn.mjs +0 -0
- /package/{antdv → dist}/cdn/index.css +0 -0
- /package/{antdv → dist}/es/components/base/style/index.mjs +0 -0
- /package/{antdv → dist}/es/components/base/style/index.mjs.map +0 -0
- /package/{antdv → dist}/es/components/form/component/form.d.ts +0 -0
- /package/{antdv → dist}/es/components/form/component/form.mjs +0 -0
- /package/{antdv → dist}/es/components/form/component/form.vue.d.ts +0 -0
- /package/{antdv → dist}/es/components/form/component/form.vue.mjs +0 -0
- /package/{antdv → dist}/es/components/form/component/form.vue.mjs.map +0 -0
- /package/{antdv → dist}/es/components/form/component/form.vue2.mjs +0 -0
- /package/{antdv → dist}/es/components/form/component/form.vue2.mjs.map +0 -0
- /package/{antdv → dist}/es/components/form/index.d.ts +0 -0
- /package/{antdv → dist}/es/components/form/index.mjs +0 -0
- /package/{antdv → dist}/es/components/form-item/component/form-item.vue.d.ts +0 -0
- /package/{antdv → dist}/es/components/form-item/component/form-item.vue.mjs +0 -0
- /package/{antdv → dist}/es/components/form-item/component/form-item.vue.mjs.map +0 -0
- /package/{antdv → dist}/es/components/form-item/component/form-item.vue2.mjs +0 -0
- /package/{antdv → dist}/es/components/form-item/index.d.ts +0 -0
- /package/{antdv → dist}/es/components/form-item/index.mjs +0 -0
- /package/{antdv → dist}/es/components/form-item/index.mjs.map +0 -0
- /package/{antdv → dist}/es/components/index.d.ts +0 -0
- /package/{antdv → dist}/es/components/index.mjs +0 -0
- /package/{antdv → dist}/es/components/index.mjs.map +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/index.d.ts +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/index.mjs +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/src/scroll-bar.d.ts +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/src/scroll-bar.mjs +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/src/types.d.ts +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/src/types.mjs +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/style/index.mjs +0 -0
- /package/{antdv → dist}/es/components/scroll-bar/style/index.mjs.map +0 -0
- /package/{antdv → dist}/es/components/utils/install.d.ts +0 -0
- /package/{antdv → dist}/es/components/utils/install.mjs +0 -0
- /package/{antdv → dist}/es/components/virtual-list/index.d.ts +0 -0
- /package/{antdv → dist}/es/components/virtual-list/index.mjs +0 -0
- /package/{antdv → dist}/es/components/virtual-list/src/types.d.ts +0 -0
- /package/{antdv → dist}/es/components/virtual-list/src/types.mjs +0 -0
- /package/{antdv → dist}/es/components/virtual-list/src/virtual-list.vue.d.ts +0 -0
- /package/{antdv → dist}/es/components/virtual-list/src/virtual-list.vue.mjs +0 -0
- /package/{antdv → dist}/es/components/virtual-list/src/virtual-list.vue.mjs.map +0 -0
- /package/{antdv → dist}/es/components/virtual-list/src/virtual-list.vue2.mjs +0 -0
- /package/{antdv → dist}/es/hooks/use-namespace/index.d.ts +0 -0
- /package/{antdv → dist}/es/hooks/use-namespace/index.mjs +0 -0
- /package/{antdv → dist}/es/index.d.ts +0 -0
- /package/{antdv → dist}/es/index.mjs +0 -0
- /package/{antdv → dist}/es/index.mjs.map +0 -0
- /package/{antdv → dist}/es/installer.d.ts +0 -0
- /package/{antdv → dist}/es/installer.mjs +0 -0
- /package/{antdv → dist}/lib/components/base/style/index.js +0 -0
- /package/{antdv → dist}/lib/components/base/style/index.js.map +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.d.ts +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.js +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.vue.d.ts +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.vue.js +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.vue.js.map +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.vue2.js +0 -0
- /package/{antdv → dist}/lib/components/form/component/form.vue2.js.map +0 -0
- /package/{antdv → dist}/lib/components/form/index.d.ts +0 -0
- /package/{antdv → dist}/lib/components/form/index.js +0 -0
- /package/{antdv → dist}/lib/components/form-item/component/form-item.vue.d.ts +0 -0
- /package/{antdv → dist}/lib/components/form-item/component/form-item.vue.js +0 -0
- /package/{antdv → dist}/lib/components/form-item/component/form-item.vue.js.map +0 -0
- /package/{antdv → dist}/lib/components/form-item/component/form-item.vue2.js +0 -0
- /package/{antdv → dist}/lib/components/form-item/index.d.ts +0 -0
- /package/{antdv → dist}/lib/components/form-item/index.js +0 -0
- /package/{antdv → dist}/lib/components/form-item/index.js.map +0 -0
- /package/{antdv → dist}/lib/components/index.d.ts +0 -0
- /package/{antdv → dist}/lib/components/index.js +0 -0
- /package/{antdv → dist}/lib/components/index.js.map +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/index.d.ts +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/index.js +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/src/scroll-bar.d.ts +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/src/scroll-bar.js +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/src/types.d.ts +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/src/types.js +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/style/index.js +0 -0
- /package/{antdv → dist}/lib/components/scroll-bar/style/index.js.map +0 -0
- /package/{antdv → dist}/lib/components/utils/install.d.ts +0 -0
- /package/{antdv → dist}/lib/components/utils/install.js +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/index.d.ts +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/index.js +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/src/types.d.ts +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/src/types.js +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/src/virtual-list.vue.d.ts +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/src/virtual-list.vue.js +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/src/virtual-list.vue.js.map +0 -0
- /package/{antdv → dist}/lib/components/virtual-list/src/virtual-list.vue2.js +0 -0
- /package/{antdv → dist}/lib/hooks/use-namespace/index.d.ts +0 -0
- /package/{antdv → dist}/lib/hooks/use-namespace/index.js +0 -0
- /package/{antdv → dist}/lib/index.d.ts +0 -0
- /package/{antdv → dist}/lib/index.js +0 -0
- /package/{antdv → dist}/lib/index.js.map +0 -0
- /package/{antdv → dist}/lib/installer.d.ts +0 -0
- /package/{antdv → dist}/lib/installer.js +0 -0
- /package/{antdv → dist}/theme-chalk/base.css +0 -0
- /package/{antdv → dist}/theme-chalk/buttons.css +0 -0
- /package/{antdv → dist}/theme-chalk/index.css +0 -0
- /package/{antdv → dist}/theme-chalk/reset.css +0 -0
- /package/{antdv → dist}/theme-chalk/scroll-bar.css +0 -0
- /package/{antdv → dist}/theme-chalk/var.css +0 -0
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { computed, defineComponent, onMounted, ref } from 'vue'
|
|
2
|
-
import { VResizeObserver } from 'vueuc'
|
|
3
|
-
import { off, on } from 'evtd'
|
|
4
|
-
import { defaultNamespace } from '@king-one/antdv/hooks/use-namespace'
|
|
5
|
-
import { scrollbarProps } from './types'
|
|
6
|
-
|
|
7
|
-
export default defineComponent({
|
|
8
|
-
name: 'KScrollbar',
|
|
9
|
-
props: scrollbarProps,
|
|
10
|
-
inheritAttrs: false,
|
|
11
|
-
setup(props) {
|
|
12
|
-
onMounted(() => {
|
|
13
|
-
if (props.container)
|
|
14
|
-
return
|
|
15
|
-
sync()
|
|
16
|
-
})
|
|
17
|
-
const handleContentResize = () => {
|
|
18
|
-
sync()
|
|
19
|
-
}
|
|
20
|
-
const handleContainerResize = () => {
|
|
21
|
-
sync()
|
|
22
|
-
}
|
|
23
|
-
const contentRef = ref<HTMLElement | null>(null)
|
|
24
|
-
const containerRef = ref<HTMLElement | null>(null)
|
|
25
|
-
const yRailRef = ref<HTMLElement | null>(null)
|
|
26
|
-
const contentHeightRef = ref<Nullable<number>>(null)
|
|
27
|
-
const contentWidthRef = ref<Nullable<number>>(null)
|
|
28
|
-
const containerHeightRef = ref<Nullable<number>>(null)
|
|
29
|
-
const containerWidthRef = ref<Nullable<number>>(null)
|
|
30
|
-
const yRailSizeRef = ref<Nullable<number>>(null)
|
|
31
|
-
const mergedContentRef = computed(() => props.content?.() || contentRef.value)
|
|
32
|
-
const mergedContainerRef = computed(() => props.container?.() || containerRef.value)
|
|
33
|
-
const containerScrollTopRef = ref(0)
|
|
34
|
-
const yBarSizeRef = computed(() => {
|
|
35
|
-
const { value: containerHeight } = containerHeightRef
|
|
36
|
-
const { value: contentHeight } = contentHeightRef
|
|
37
|
-
const { value: yRailSize } = yRailSizeRef
|
|
38
|
-
if (containerHeight === null || contentHeight === null || yRailSize === null) {
|
|
39
|
-
return 0
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return Math.min(containerHeight, (yRailSize * containerHeight) / contentHeight + 5 * 1.5)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
const yBarTopRef = computed(() => {
|
|
46
|
-
const { value: containerHeight } = containerHeightRef
|
|
47
|
-
const { value: containerScrollTop } = containerScrollTopRef
|
|
48
|
-
const { value: contentHeight } = contentHeightRef
|
|
49
|
-
const { value: yRailSize } = yRailSizeRef
|
|
50
|
-
if (containerHeight === null || contentHeight === null || yRailSize === null) {
|
|
51
|
-
return 0
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
const heightDiff = contentHeight - containerHeight
|
|
55
|
-
if (!heightDiff)
|
|
56
|
-
return 0
|
|
57
|
-
return (containerScrollTop / heightDiff) * (yRailSize - yBarSizeRef.value)
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
const yBarTopPxRef = computed(() => {
|
|
61
|
-
return `${yBarTopRef.value}px`
|
|
62
|
-
})
|
|
63
|
-
const needYBarRef = computed(() => {
|
|
64
|
-
const { value: containerHeight } = containerHeightRef
|
|
65
|
-
const { value: contentHeight } = contentHeightRef
|
|
66
|
-
return containerHeight !== null && contentHeight !== null && contentHeight > containerHeight
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
const yBarSizePxRef = computed(() => {
|
|
70
|
-
return `${yBarSizeRef.value}px`
|
|
71
|
-
})
|
|
72
|
-
const syncPositionState = () => {
|
|
73
|
-
const { value: content } = mergedContentRef
|
|
74
|
-
if (content) {
|
|
75
|
-
contentHeightRef.value = content.offsetHeight
|
|
76
|
-
contentWidthRef.value = content.offsetWidth
|
|
77
|
-
}
|
|
78
|
-
const { value: container } = mergedContainerRef
|
|
79
|
-
if (container) {
|
|
80
|
-
containerHeightRef.value = container.offsetHeight
|
|
81
|
-
containerWidthRef.value = container.offsetWidth
|
|
82
|
-
}
|
|
83
|
-
const { value: yRailEl } = yRailRef
|
|
84
|
-
if (yRailEl) {
|
|
85
|
-
yRailSizeRef.value = yRailEl.offsetHeight
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
let yBarPressed = false
|
|
89
|
-
let memoYTop: number = 0
|
|
90
|
-
let memoMouseY: number = 0
|
|
91
|
-
let yBarVanishTimerId: number | undefined
|
|
92
|
-
|
|
93
|
-
const handleYScrollMouseMove = (e: MouseEvent) => {
|
|
94
|
-
if (!yBarPressed)
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
if (yBarVanishTimerId !== undefined) {
|
|
98
|
-
window.clearTimeout(yBarVanishTimerId)
|
|
99
|
-
}
|
|
100
|
-
const { value: containerHeight } = containerHeightRef
|
|
101
|
-
const { value: contentHeight } = contentHeightRef
|
|
102
|
-
const { value: yBarSize } = yBarSizeRef
|
|
103
|
-
if (containerHeight === null || contentHeight === null)
|
|
104
|
-
return
|
|
105
|
-
const dY = e.clientY - memoMouseY
|
|
106
|
-
const dScrollTop = (dY * (contentHeight - containerHeight)) / (containerHeight - yBarSize)
|
|
107
|
-
const toScrollTopUpperBound = contentHeight - containerHeight
|
|
108
|
-
let toScrollTop = memoYTop + dScrollTop
|
|
109
|
-
toScrollTop = Math.min(toScrollTopUpperBound, toScrollTop)
|
|
110
|
-
toScrollTop = Math.max(toScrollTop, 0)
|
|
111
|
-
const { value: container } = mergedContainerRef
|
|
112
|
-
if (container) {
|
|
113
|
-
container.scrollTop = toScrollTop
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const handleYScrollMouseUp = (e: MouseEvent) => {
|
|
117
|
-
e.preventDefault()
|
|
118
|
-
e.stopPropagation()
|
|
119
|
-
off('mousemove', window, handleYScrollMouseMove, true)
|
|
120
|
-
off('mouseup', window, handleYScrollMouseUp, true)
|
|
121
|
-
yBarPressed = false
|
|
122
|
-
sync()
|
|
123
|
-
}
|
|
124
|
-
const handleYScrollMouseDown = (e: MouseEvent) => {
|
|
125
|
-
e.preventDefault()
|
|
126
|
-
e.stopPropagation()
|
|
127
|
-
on('mousemove', window, handleYScrollMouseMove, true)
|
|
128
|
-
on('mouseup', window, handleYScrollMouseUp, true)
|
|
129
|
-
memoYTop = containerScrollTopRef.value
|
|
130
|
-
memoMouseY = e.clientY
|
|
131
|
-
yBarPressed = true
|
|
132
|
-
}
|
|
133
|
-
function handleScroll(e: Event): void {
|
|
134
|
-
const { onScroll } = props
|
|
135
|
-
if (onScroll)
|
|
136
|
-
onScroll(e)
|
|
137
|
-
syncScrollState()
|
|
138
|
-
}
|
|
139
|
-
function syncScrollState(): void {
|
|
140
|
-
// only collect scroll state, do not trigger any dom event
|
|
141
|
-
const { value: container } = mergedContainerRef
|
|
142
|
-
if (container) {
|
|
143
|
-
containerScrollTopRef.value = container.scrollTop
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function sync(): void {
|
|
147
|
-
syncPositionState()
|
|
148
|
-
syncScrollState()
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
sync,
|
|
153
|
-
handleContentResize,
|
|
154
|
-
handleContainerResize,
|
|
155
|
-
contentRef,
|
|
156
|
-
yRailRef,
|
|
157
|
-
containerRef,
|
|
158
|
-
contentHeightRef,
|
|
159
|
-
containerHeightRef,
|
|
160
|
-
needYBarRef,
|
|
161
|
-
yBarSizePxRef,
|
|
162
|
-
handleYScrollMouseDown,
|
|
163
|
-
yBarTopPxRef,
|
|
164
|
-
handleScroll
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
render() {
|
|
168
|
-
const { $slots } = this
|
|
169
|
-
const createYBar = () => {
|
|
170
|
-
return (
|
|
171
|
-
<div class={`${defaultNamespace}-scrollbar-rail`} ref="yRailRef">
|
|
172
|
-
{this.needYBarRef && (
|
|
173
|
-
<div
|
|
174
|
-
class={`${defaultNamespace}-scrollbar-rail__scrollbar`}
|
|
175
|
-
style={{
|
|
176
|
-
height: this.yBarSizePxRef,
|
|
177
|
-
top: this.yBarTopPxRef
|
|
178
|
-
}}
|
|
179
|
-
onMousedown={this.handleYScrollMouseDown}
|
|
180
|
-
>
|
|
181
|
-
</div>
|
|
182
|
-
)}
|
|
183
|
-
</div>
|
|
184
|
-
)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const createChildren = () => {
|
|
188
|
-
return (
|
|
189
|
-
<div class={`${defaultNamespace}-scrollbar`} {...this.$attrs}>
|
|
190
|
-
{this.container
|
|
191
|
-
? (
|
|
192
|
-
$slots.default?.()
|
|
193
|
-
)
|
|
194
|
-
: (
|
|
195
|
-
<div class={`${defaultNamespace}-scrollbar-container`} onScroll={this.handleScroll} ref="containerRef">
|
|
196
|
-
<VResizeObserver onResize={this.handleContentResize}>
|
|
197
|
-
<div ref="contentRef" class={`${defaultNamespace}-scrollbar-content`}>
|
|
198
|
-
{$slots.default?.()}
|
|
199
|
-
</div>
|
|
200
|
-
</VResizeObserver>
|
|
201
|
-
</div>
|
|
202
|
-
)}
|
|
203
|
-
|
|
204
|
-
{createYBar()}
|
|
205
|
-
</div>
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
const createBarNode = this.container ? createChildren() : <VResizeObserver onResize={this.handleContainerResize}>{createChildren()}</VResizeObserver>
|
|
209
|
-
return createBarNode
|
|
210
|
-
}
|
|
211
|
-
})
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PropType } from 'vue'
|
|
2
|
-
|
|
3
|
-
export const scrollbarProps = {
|
|
4
|
-
container: Function as PropType<() => HTMLElement | null | undefined>,
|
|
5
|
-
content: Function as PropType<() => HTMLElement | null | undefined>,
|
|
6
|
-
onScroll: Function as PropType<(e: Event) => void>
|
|
7
|
-
} as const
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description:
|
|
3
|
-
* @Version: 2.0
|
|
4
|
-
* @Autor: caohao
|
|
5
|
-
* @Date: 2024-09-17 00:15:40
|
|
6
|
-
* @LastEditors: caohao
|
|
7
|
-
* @LastEditTime: 2024-09-17 00:15:43
|
|
8
|
-
*/
|
|
9
|
-
import type { App, Directive, Plugin } from 'vue'
|
|
10
|
-
|
|
11
|
-
export type SFCWithInstall<T> = T & Plugin
|
|
12
|
-
|
|
13
|
-
const defaultNamePrefix: string = 'K'
|
|
14
|
-
export function withInstall<T>(main: T) {
|
|
15
|
-
(main as SFCWithInstall<T>).install = (app): void => {
|
|
16
|
-
const comp: Record<string, any> = main as Record<string, any>
|
|
17
|
-
app.component(defaultNamePrefix + comp.name, comp)
|
|
18
|
-
}
|
|
19
|
-
return main as SFCWithInstall<T>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// 注册指令
|
|
23
|
-
export function withInstallDirectives<T extends Directive>(main: T, name: string) {
|
|
24
|
-
return {
|
|
25
|
-
install: (app: App): void => {
|
|
26
|
-
app.directive(name, main)
|
|
27
|
-
},
|
|
28
|
-
directive: main
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { VirtualListItemData } from 'vueuc'
|
|
2
|
-
import type { PropType } from 'vue'
|
|
3
|
-
|
|
4
|
-
export const virtualListProps = {
|
|
5
|
-
items: {
|
|
6
|
-
type: Array as PropType<VirtualListItemData[]>,
|
|
7
|
-
default: () => []
|
|
8
|
-
},
|
|
9
|
-
itemSize: {
|
|
10
|
-
type: Number,
|
|
11
|
-
required: true
|
|
12
|
-
},
|
|
13
|
-
itemResizable: Boolean,
|
|
14
|
-
paddingTop: {
|
|
15
|
-
type: [Number, String] as PropType<number | string>,
|
|
16
|
-
default: 0
|
|
17
|
-
},
|
|
18
|
-
paddingBottom: {
|
|
19
|
-
type: [Number, String] as PropType<number | string>,
|
|
20
|
-
default: 0
|
|
21
|
-
},
|
|
22
|
-
keyField: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: 'key'
|
|
25
|
-
},
|
|
26
|
-
onScroll: Function as PropType<() => void>,
|
|
27
|
-
onWheel: Function as PropType<(event: WheelEvent) => void>,
|
|
28
|
-
onResize: Function as PropType<(entry: ResizeObserverEntry) => void>
|
|
29
|
-
} as const
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref } from 'vue'
|
|
3
|
-
import { VVirtualList, type VirtualListInst } from 'vueuc'
|
|
4
|
-
import scrollbar from '../../scroll-bar'
|
|
5
|
-
import { virtualListProps } from './types'
|
|
6
|
-
|
|
7
|
-
const props = defineProps(virtualListProps)
|
|
8
|
-
const virtualListInstRef = ref<VirtualListInst | null>(null)
|
|
9
|
-
const scrollbarInstRef = ref<InstanceType<typeof scrollbar> | null>(null)
|
|
10
|
-
function getScrollContainer(): HTMLElement | null | undefined {
|
|
11
|
-
return virtualListInstRef.value?.listElRef
|
|
12
|
-
}
|
|
13
|
-
function getScrollContent(): HTMLElement | null | undefined {
|
|
14
|
-
return virtualListInstRef.value?.itemsElRef
|
|
15
|
-
}
|
|
16
|
-
const syncScrollbar = () => scrollbarInstRef.value?.sync()
|
|
17
|
-
function handleScroll() {
|
|
18
|
-
props.onScroll?.()
|
|
19
|
-
syncScrollbar()
|
|
20
|
-
}
|
|
21
|
-
function handleResize() {
|
|
22
|
-
syncScrollbar()
|
|
23
|
-
}
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<template>
|
|
27
|
-
<scrollbar ref="scrollbarInstRef" style="max-height: 300px" :container="getScrollContainer" :content="getScrollContent">
|
|
28
|
-
<VVirtualList
|
|
29
|
-
ref="virtualListInstRef"
|
|
30
|
-
:items="items"
|
|
31
|
-
style="height: 100%"
|
|
32
|
-
:item-size="itemSize"
|
|
33
|
-
:item-resizable="itemResizable"
|
|
34
|
-
:show-scrollbar="false"
|
|
35
|
-
:padding-bottom="paddingBottom"
|
|
36
|
-
:padding-top="paddingTop"
|
|
37
|
-
:on-scroll="handleScroll"
|
|
38
|
-
:on-resize="handleResize"
|
|
39
|
-
>
|
|
40
|
-
<template #default="{ item, index }">
|
|
41
|
-
<slot :item="item" :index="index" />
|
|
42
|
-
</template>
|
|
43
|
-
</VVirtualList>
|
|
44
|
-
</scrollbar>
|
|
45
|
-
</template>
|
|
46
|
-
|
|
47
|
-
<style></style>
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { computed, getCurrentInstance, inject, ref, unref } from 'vue'
|
|
2
|
-
|
|
3
|
-
import type { InjectionKey, Ref } from 'vue'
|
|
4
|
-
|
|
5
|
-
export const defaultNamespace = 'king'
|
|
6
|
-
const statePrefix = 'is-'
|
|
7
|
-
|
|
8
|
-
function _bem(namespace: string, block: string, blockSuffix: string, element: string, modifier: string) {
|
|
9
|
-
let cls = `${namespace}-${block}`
|
|
10
|
-
if (blockSuffix) {
|
|
11
|
-
cls += `-${blockSuffix}`
|
|
12
|
-
}
|
|
13
|
-
if (element) {
|
|
14
|
-
cls += `__${element}`
|
|
15
|
-
}
|
|
16
|
-
if (modifier) {
|
|
17
|
-
cls += `--${modifier}`
|
|
18
|
-
}
|
|
19
|
-
return cls
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const namespaceContextKey: InjectionKey<Ref<string | undefined>> = Symbol('namespaceContextKey')
|
|
23
|
-
|
|
24
|
-
export function useGetDerivedNamespace(namespaceOverrides?: Ref<string | undefined>) {
|
|
25
|
-
const derivedNamespace = namespaceOverrides || (getCurrentInstance() ? inject(namespaceContextKey, ref(defaultNamespace)) : ref(defaultNamespace))
|
|
26
|
-
const namespace = computed(() => {
|
|
27
|
-
return unref(derivedNamespace) || defaultNamespace
|
|
28
|
-
})
|
|
29
|
-
return namespace
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function useNamespace(block: string, namespaceOverrides?: Ref<string | undefined>) {
|
|
33
|
-
const namespace = useGetDerivedNamespace(namespaceOverrides)
|
|
34
|
-
const b = (blockSuffix = '') => _bem(namespace.value, block, blockSuffix, '', '')
|
|
35
|
-
const e = (element?: string) => (element ? _bem(namespace.value, block, '', element, '') : '')
|
|
36
|
-
const m = (modifier?: string) => (modifier ? _bem(namespace.value, block, '', '', modifier) : '')
|
|
37
|
-
const be = (blockSuffix?: string, element?: string) => (blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, '') : '')
|
|
38
|
-
const em = (element?: string, modifier?: string) => (element && modifier ? _bem(namespace.value, block, '', element, modifier) : '')
|
|
39
|
-
const bm = (blockSuffix?: string, modifier?: string) => (blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, '', modifier) : '')
|
|
40
|
-
const bem = (blockSuffix?: string, element?: string, modifier?: string) =>
|
|
41
|
-
blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : ''
|
|
42
|
-
const is: {
|
|
43
|
-
(name: string, state: boolean | undefined): string
|
|
44
|
-
(name: string): string
|
|
45
|
-
} = (name: string, ...args: [boolean | undefined] | []) => {
|
|
46
|
-
const state = args.length >= 1 ? args[0]! : true
|
|
47
|
-
return name && state ? `${statePrefix}${name}` : ''
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// for css var
|
|
51
|
-
// --el-xxx: value;
|
|
52
|
-
const cssVar = (object: Record<string, string>) => {
|
|
53
|
-
const styles: Record<string, string> = {}
|
|
54
|
-
for (const key in object) {
|
|
55
|
-
if (object[key]) {
|
|
56
|
-
styles[`--${namespace.value}-${key}`] = object[key]
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return styles
|
|
60
|
-
}
|
|
61
|
-
// with block
|
|
62
|
-
const cssVarBlock = (object: Record<string, string>) => {
|
|
63
|
-
const styles: Record<string, string> = {}
|
|
64
|
-
for (const key in object) {
|
|
65
|
-
if (object[key]) {
|
|
66
|
-
styles[`--${namespace.value}-${block}-${key}`] = object[key]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return styles
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const cssVarName = (name: string) => `--${namespace.value}-${name}`
|
|
73
|
-
const cssVarBlockName = (name: string) => `--${namespace.value}-${block}-${name}`
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
namespace,
|
|
77
|
-
b,
|
|
78
|
-
e,
|
|
79
|
-
m,
|
|
80
|
-
be,
|
|
81
|
-
em,
|
|
82
|
-
bm,
|
|
83
|
-
bem,
|
|
84
|
-
is,
|
|
85
|
-
// css
|
|
86
|
-
cssVar,
|
|
87
|
-
cssVarName,
|
|
88
|
-
cssVarBlock,
|
|
89
|
-
cssVarBlockName
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type UseNamespaceReturn = ReturnType<typeof useNamespace>
|
package/index.ts
DELETED
package/installer.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description:
|
|
3
|
-
* @Version: 2.0
|
|
4
|
-
* @Autor: caohao
|
|
5
|
-
* @Date: 2024-09-16 23:00:22
|
|
6
|
-
* @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
|
|
7
|
-
* @LastEditTime: 2024-10-18 13:49:00
|
|
8
|
-
*/
|
|
9
|
-
import type { App, Plugin } from 'vue'
|
|
10
|
-
import { KForm, KVirtualList } from './components'
|
|
11
|
-
|
|
12
|
-
const component = [KForm, KVirtualList] as Plugin[]
|
|
13
|
-
export function install(app: App): any {
|
|
14
|
-
component.forEach(i => app.use(i))
|
|
15
|
-
}
|
|
16
|
-
const plugin = {
|
|
17
|
-
install
|
|
18
|
-
}
|
|
19
|
-
export default plugin
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|