@jetlinks-web/components 2.0.2 → 2.0.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.
Files changed (237) hide show
  1. package/es/AMap/Map.js +124 -0
  2. package/es/AMap/index.js +2 -0
  3. package/es/AMap/util.js +56 -0
  4. package/es/BadgeStatus/Badge.js +54 -0
  5. package/es/BadgeStatus/color.js +21 -0
  6. package/es/BadgeStatus/index.js +3 -0
  7. package/es/CardSelect/CardSelect.js +123 -0
  8. package/es/CardSelect/index.js +2 -0
  9. package/es/CheckButton/CheckButton.js +121 -0
  10. package/es/CheckButton/index.js +2 -0
  11. package/es/ConfigProvider/context.js +12 -0
  12. package/es/ConfigProvider/index.js +31 -0
  13. package/es/Echarts/Echarts.js +47 -0
  14. package/es/Echarts/index.js +2 -0
  15. package/es/Ellipsis/Ellipsis.js +189 -0
  16. package/es/Ellipsis/index.js +2 -0
  17. package/es/Empty/Empty.js +56 -0
  18. package/es/Empty/image.js +2 -0
  19. package/es/Empty/index.js +2 -0
  20. package/es/FullPage/FullPage.js +31 -0
  21. package/es/FullPage/index.js +2 -0
  22. package/es/Icon/icon.js +42 -0
  23. package/{src/Icon/index.ts → es/Icon/index.js} +2 -3
  24. package/es/MonacoEditor/Monaco.js +238 -0
  25. package/es/MonacoEditor/index.js +2 -0
  26. package/es/PermissionButton/index.js +117 -0
  27. package/es/ProLayout/Basic/BasicLayout.js +259 -0
  28. package/es/ProLayout/Basic/Header.js +97 -0
  29. package/es/ProLayout/PageContainer/index.js +324 -0
  30. package/es/ProLayout/PageContainer/typings.js +1 -0
  31. package/es/ProLayout/RouteContext.js +22 -0
  32. package/es/ProLayout/SiderMenu/BaseMenu.js +285 -0
  33. package/es/ProLayout/SiderMenu/SiderMenu.js +278 -0
  34. package/es/ProLayout/SiderMenu/index.js +2 -0
  35. package/es/ProLayout/SiderMenu/typings.js +1 -0
  36. package/es/ProLayout/TopHeader/index.js +163 -0
  37. package/es/ProLayout/defaultSettings.js +66 -0
  38. package/{src/ProLayout/index.ts → es/ProLayout/index.js} +4 -6
  39. package/{src → es}/ProLayout/style/default.less +4 -4
  40. package/es/ProLayout/style/index.js +1 -0
  41. package/es/ProLayout/typings.js +1 -0
  42. package/es/ProLayout/util.js +61 -0
  43. package/es/ProTable/index.js +411 -0
  44. package/es/ProTable/proTableTypes.js +11 -0
  45. package/es/ProTable/style/index.css +65 -0
  46. package/es/ProTable/style/index.js +1 -0
  47. package/es/Scrollbar/Bar.js +114 -0
  48. package/es/Scrollbar/Scrollbar.js +212 -0
  49. package/es/Scrollbar/Thumb.js +189 -0
  50. package/es/Scrollbar/constants.js +1 -0
  51. package/es/Scrollbar/index.js +2 -0
  52. package/es/Scrollbar/scrollbarProps.js +100 -0
  53. package/es/Scrollbar/thumbProps.js +10 -0
  54. package/es/Scrollbar/util.js +30 -0
  55. package/es/Search/Advanced/History.js +183 -0
  56. package/es/Search/Advanced/SaveHistory.js +153 -0
  57. package/es/Search/Advanced/index.js +520 -0
  58. package/es/Search/Item.js +497 -0
  59. package/es/Search/Search.js +249 -0
  60. package/es/Search/hooks/index.js +1 -0
  61. package/es/Search/hooks/useSearchItems.js +40 -0
  62. package/es/Search/index.js +4 -0
  63. package/es/Search/setting.js +91 -0
  64. package/es/Search/style/Item.less +33 -0
  65. package/es/Search/style/Search.less +179 -0
  66. package/es/Search/style/index.js +2 -0
  67. package/es/Search/typing.js +1 -0
  68. package/es/Search/util.js +234 -0
  69. package/es/ValueItem/ValueItem.js +233 -0
  70. package/es/ValueItem/index.js +2 -0
  71. package/es/ValueItem/util.js +16 -0
  72. package/es/index.js +24 -0
  73. package/es/style/index.js +3 -0
  74. package/es/style/variable.css +0 -0
  75. package/{src → es}/style/variable.less +0 -2
  76. package/es/style.js +3 -0
  77. package/lib/AMap/Map.js +124 -0
  78. package/lib/AMap/index.js +9 -0
  79. package/lib/AMap/util.js +62 -0
  80. package/lib/BadgeStatus/Badge.js +54 -0
  81. package/lib/BadgeStatus/color.js +27 -0
  82. package/lib/BadgeStatus/index.js +22 -0
  83. package/lib/CardSelect/CardSelect.js +123 -0
  84. package/lib/CardSelect/index.js +9 -0
  85. package/lib/CheckButton/CheckButton.js +121 -0
  86. package/lib/CheckButton/index.js +9 -0
  87. package/lib/ConfigProvider/context.js +19 -0
  88. package/lib/ConfigProvider/index.js +37 -0
  89. package/lib/Echarts/Echarts.js +47 -0
  90. package/lib/Echarts/index.js +9 -0
  91. package/lib/Ellipsis/Ellipsis.js +189 -0
  92. package/lib/Ellipsis/index.js +9 -0
  93. package/lib/Empty/Empty.js +56 -0
  94. package/lib/Empty/image.js +8 -0
  95. package/lib/Empty/index.js +9 -0
  96. package/lib/FullPage/FullPage.js +31 -0
  97. package/lib/FullPage/index.js +9 -0
  98. package/lib/Icon/icon.js +52 -0
  99. package/lib/Icon/index.js +9 -0
  100. package/lib/MonacoEditor/Monaco.js +238 -0
  101. package/lib/MonacoEditor/index.js +9 -0
  102. package/lib/PermissionButton/index.js +124 -0
  103. package/lib/ProLayout/Basic/BasicLayout.js +268 -0
  104. package/lib/ProLayout/Basic/BasicLayout.less +66 -0
  105. package/lib/ProLayout/Basic/Header.js +103 -0
  106. package/lib/ProLayout/Basic/Header.less +8 -0
  107. package/lib/ProLayout/PageContainer/index.js +327 -0
  108. package/lib/ProLayout/PageContainer/index.less +103 -0
  109. package/lib/ProLayout/PageContainer/typings.js +5 -0
  110. package/lib/ProLayout/RouteContext.js +28 -0
  111. package/lib/ProLayout/SiderMenu/BaseMenu.js +290 -0
  112. package/lib/ProLayout/SiderMenu/SiderMenu.js +287 -0
  113. package/lib/ProLayout/SiderMenu/index.js +20 -0
  114. package/lib/ProLayout/SiderMenu/index.less +212 -0
  115. package/lib/ProLayout/SiderMenu/typings.js +5 -0
  116. package/lib/ProLayout/TopHeader/index.js +168 -0
  117. package/lib/ProLayout/TopHeader/index.less +174 -0
  118. package/lib/ProLayout/defaultSettings.js +72 -0
  119. package/lib/ProLayout/index.js +16 -0
  120. package/lib/ProLayout/style/default.less +4 -0
  121. package/lib/ProLayout/style/index.js +3 -0
  122. package/lib/ProLayout/style/style.less +7 -0
  123. package/lib/ProLayout/typings.js +5 -0
  124. package/lib/ProLayout/util.js +72 -0
  125. package/lib/ProTable/index.js +417 -0
  126. package/lib/ProTable/proTableTypes.js +17 -0
  127. package/lib/ProTable/style/index.css +65 -0
  128. package/lib/ProTable/style/index.js +3 -0
  129. package/lib/ProTable/style/index.less +92 -0
  130. package/lib/Scrollbar/Bar.js +114 -0
  131. package/lib/Scrollbar/Scrollbar.js +212 -0
  132. package/lib/Scrollbar/Thumb.js +189 -0
  133. package/lib/Scrollbar/constants.js +7 -0
  134. package/lib/Scrollbar/index.js +9 -0
  135. package/{src/Scrollbar/scrollbar.ts → lib/Scrollbar/scrollbarProps.js} +106 -108
  136. package/lib/Scrollbar/thumbProps.js +16 -0
  137. package/lib/Scrollbar/util.js +37 -0
  138. package/lib/Search/Advanced/History.js +183 -0
  139. package/lib/Search/Advanced/SaveHistory.js +153 -0
  140. package/lib/Search/Advanced/index.js +520 -0
  141. package/lib/Search/Item.js +497 -0
  142. package/lib/Search/Search.js +249 -0
  143. package/lib/Search/hooks/index.js +16 -0
  144. package/lib/Search/hooks/useSearchItems.js +47 -0
  145. package/lib/Search/index.js +16 -0
  146. package/lib/Search/setting.js +97 -0
  147. package/lib/Search/style/Item.less +33 -0
  148. package/lib/Search/style/Search.less +179 -0
  149. package/lib/Search/style/index.js +4 -0
  150. package/lib/Search/typing.js +5 -0
  151. package/lib/Search/util.js +241 -0
  152. package/lib/ValueItem/ValueItem.js +233 -0
  153. package/lib/ValueItem/index.js +9 -0
  154. package/lib/ValueItem/util.js +22 -0
  155. package/lib/index.js +158 -0
  156. package/lib/style/components.less +1 -0
  157. package/lib/style/index.js +4 -0
  158. package/lib/style/variable.css +0 -0
  159. package/lib/style/variable.less +2 -0
  160. package/lib/style.js +5 -0
  161. package/package.json +122 -13
  162. package/index.ts +0 -64
  163. package/src/AMap/Map.vue +0 -110
  164. package/src/AMap/index.ts +0 -1
  165. package/src/AMap/util.ts +0 -56
  166. package/src/BadgeStatus/Badge.vue +0 -41
  167. package/src/BadgeStatus/color.ts +0 -25
  168. package/src/BadgeStatus/index.ts +0 -4
  169. package/src/CardSelect/CardSelect.vue +0 -136
  170. package/src/CardSelect/index.ts +0 -3
  171. package/src/CheckButton/CheckButton.vue +0 -146
  172. package/src/CheckButton/index.md +0 -27
  173. package/src/CheckButton/index.ts +0 -3
  174. package/src/ConfigProvider/context.ts +0 -17
  175. package/src/ConfigProvider/index.tsx +0 -42
  176. package/src/Echarts/Echarts.vue +0 -43
  177. package/src/Echarts/index.ts +0 -3
  178. package/src/Ellipsis/Ellipsis.vue +0 -182
  179. package/src/Ellipsis/index.ts +0 -3
  180. package/src/Empty/Empty.vue +0 -43
  181. package/src/Empty/image.ts +0 -3
  182. package/src/Empty/index.ts +0 -2
  183. package/src/FullPage/FullPage.vue +0 -30
  184. package/src/FullPage/index.ts +0 -3
  185. package/src/Icon/icon.tsx +0 -40
  186. package/src/MonacoEditor/Monaco.vue +0 -242
  187. package/src/MonacoEditor/index.md +0 -26
  188. package/src/MonacoEditor/index.ts +0 -2
  189. package/src/PermissionButton/index.tsx +0 -110
  190. package/src/ProLayout/Basic/BasicLayout.tsx +0 -392
  191. package/src/ProLayout/Basic/Header.tsx +0 -115
  192. package/src/ProLayout/PageContainer/index.tsx +0 -441
  193. package/src/ProLayout/PageContainer/typings.ts +0 -56
  194. package/src/ProLayout/RouteContext.ts +0 -87
  195. package/src/ProLayout/SiderMenu/BaseMenu.tsx +0 -296
  196. package/src/ProLayout/SiderMenu/SiderMenu.tsx +0 -320
  197. package/src/ProLayout/SiderMenu/index.ts +0 -2
  198. package/src/ProLayout/SiderMenu/typings.ts +0 -49
  199. package/src/ProLayout/TopHeader/index.tsx +0 -210
  200. package/src/ProLayout/defaultSettings.ts +0 -106
  201. package/src/ProLayout/style/index.ts +0 -1
  202. package/src/ProLayout/typings.ts +0 -87
  203. package/src/ProLayout/util.ts +0 -64
  204. package/src/ProTable/index.md +0 -53
  205. package/src/ProTable/index.tsx +0 -551
  206. package/src/ProTable/proTableTypes.ts +0 -70
  207. package/src/ProTable/style/index.ts +0 -1
  208. package/src/Scrollbar/Bar.vue +0 -75
  209. package/src/Scrollbar/Scrollbar.vue +0 -260
  210. package/src/Scrollbar/Thumb.vue +0 -163
  211. package/src/Scrollbar/constants.ts +0 -10
  212. package/src/Scrollbar/index.ts +0 -4
  213. package/src/Scrollbar/thumb.ts +0 -16
  214. package/src/Scrollbar/util.ts +0 -38
  215. package/src/Search/Advanced/History.vue +0 -140
  216. package/src/Search/Advanced/SaveHistory.vue +0 -108
  217. package/src/Search/Advanced/index.vue +0 -435
  218. package/src/Search/Item.vue +0 -525
  219. package/src/Search/Search.vue +0 -398
  220. package/src/Search/hooks/index.ts +0 -1
  221. package/src/Search/hooks/useSearchItems.ts +0 -68
  222. package/src/Search/index.md +0 -57
  223. package/src/Search/index.ts +0 -5
  224. package/src/Search/setting.ts +0 -55
  225. package/src/Search/typing.ts +0 -76
  226. package/src/Search/util.ts +0 -263
  227. package/src/ValueItem/ValueItem.vue +0 -192
  228. package/src/ValueItem/index.ts +0 -3
  229. package/src/ValueItem/util.ts +0 -16
  230. package/src/style/index.ts +0 -3
  231. /package/{src → es}/ProLayout/Basic/BasicLayout.less +0 -0
  232. /package/{src → es}/ProLayout/Basic/Header.less +0 -0
  233. /package/{src → es}/ProLayout/PageContainer/index.less +0 -0
  234. /package/{src → es}/ProLayout/SiderMenu/index.less +0 -0
  235. /package/{src → es}/ProLayout/TopHeader/index.less +0 -0
  236. /package/{src → es}/ProLayout/style/style.less +0 -0
  237. /package/{src → es}/ProTable/style/index.less +0 -0
@@ -1,260 +0,0 @@
1
- <template>
2
- <div ref="scrollbarRef" class="j-scrollbar">
3
- <div
4
- ref="wrapRef"
5
- :class="wrapKls"
6
- :style="wrapStyle"
7
- @scroll="handleScroll"
8
- >
9
- <component
10
- :is="tag"
11
- :id="id"
12
- ref="resizeRef"
13
- :class="resizeKls"
14
- :role="role"
15
- :aria-label="ariaLabel"
16
- :aria-orientation="ariaOrientation"
17
- >
18
- <slot/>
19
- </component>
20
- </div>
21
- <template v-if="!native">
22
- <bar ref="barRef" :always="always" :min-size="minSize"/>
23
- </template>
24
- </div>
25
- </template>
26
- <script lang="ts" setup>
27
- import {
28
- computed,
29
- nextTick,
30
- onMounted,
31
- onUpdated,
32
- provide,
33
- reactive,
34
- ref,
35
- watch,
36
- } from 'vue'
37
- import { useEventListener, useResizeObserver } from '@vueuse/core'
38
- import { isNumber, isObject } from '@jetlinks-web/utils'
39
- import Bar from './Bar.vue'
40
- import { scrollbarContextKey } from './constants'
41
- import { scrollbarEmits, scrollbarProps, BarInstance } from './scrollbar'
42
- import type { CSSProperties, StyleValue } from 'vue'
43
-
44
- const COMPONENT_NAME = 'JScrollbar'
45
-
46
- defineOptions({
47
- name: COMPONENT_NAME,
48
- })
49
-
50
- const props = defineProps(scrollbarProps)
51
- const emit = defineEmits(scrollbarEmits)
52
-
53
- let stopResizeObserver: (() => void) | undefined = undefined
54
- let stopResizeListener: (() => void) | undefined = undefined
55
-
56
- const scrollbarRef = ref<HTMLDivElement>()
57
- const wrapRef = ref<HTMLDivElement>()
58
- const resizeRef = ref<HTMLElement>()
59
- const barRef = ref<BarInstance>()
60
-
61
- const wrapStyle = computed<StyleValue>(() => {
62
- const style: CSSProperties = {}
63
- if (props.height) style.height = `${props.height}px`
64
- if (props.maxHeight) style.maxHeight = `${props.maxHeight}px`
65
- return [props.wrapStyle, style]
66
- })
67
-
68
- const wrapKls = computed(() => {
69
- return [
70
- 'j-scrollbar__wrap',
71
- 'j-scrollbar__wrap--hidden-default'
72
- ]
73
- })
74
-
75
- const resizeKls = computed(() => {
76
- return ['j-scrollbar__view', props.viewClass]
77
- })
78
-
79
- const handleScroll = () => {
80
- if (wrapRef.value) {
81
- barRef.value?.handleScroll(wrapRef.value)
82
-
83
- emit('scroll', {
84
- scrollTop: wrapRef.value.scrollTop,
85
- scrollLeft: wrapRef.value.scrollLeft,
86
- })
87
- }
88
- }
89
-
90
- function scrollTo(xCord: number, yCord?: number): void
91
- function scrollTo(options: ScrollToOptions): void
92
- function scrollTo(arg1: any, arg2?: number) {
93
- if (isObject(arg1)) {
94
- wrapRef.value!.scrollTo(arg1)
95
- } else if (isNumber(arg1) && isNumber(arg2)) {
96
- wrapRef.value!.scrollTo(arg1, arg2)
97
- }
98
- }
99
-
100
- const setScrollTop = (value: number) => {
101
- if (!isNumber(value)) {
102
- throw new Error('value must be a number');
103
- }
104
- wrapRef.value!.scrollTop = value
105
- }
106
-
107
- const setScrollLeft = (value: number) => {
108
- if (!isNumber(value)) {
109
- throw new Error(`[${COMPONENT_NAME}] value must be a number`);
110
- }
111
- wrapRef.value!.scrollLeft = value
112
- }
113
-
114
- const update = () => {
115
- barRef.value?.update()
116
- }
117
-
118
- watch(
119
- () => props.noresize,
120
- (noResize) => {
121
- if (noResize) {
122
- stopResizeObserver?.()
123
- stopResizeListener?.()
124
- } else {
125
- ;({stop: stopResizeObserver} = useResizeObserver(resizeRef, update))
126
- stopResizeListener = useEventListener('resize', update)
127
- }
128
- },
129
- {immediate: true}
130
- )
131
-
132
- watch(
133
- () => [props.maxHeight, props.height],
134
- () => {
135
- if (!props.native)
136
- nextTick(() => {
137
- update()
138
- if (wrapRef.value) {
139
- barRef.value?.handleScroll(wrapRef.value)
140
- }
141
- })
142
- }
143
- )
144
-
145
- provide(
146
- scrollbarContextKey,
147
- reactive({
148
- scrollbarElement: scrollbarRef,
149
- wrapElement: wrapRef,
150
- })
151
- )
152
-
153
- onMounted(() => {
154
- if (!props.native)
155
- nextTick(() => {
156
- update()
157
- })
158
- })
159
- onUpdated(() => update())
160
-
161
- defineExpose({
162
- /** @description scrollbar wrap ref */
163
- wrapRef,
164
- /** @description update scrollbar state manually */
165
- update,
166
- /** @description scrolls to a particular set of coordinates */
167
- scrollTo,
168
- /** @description set distance to scroll top */
169
- setScrollTop,
170
- /** @description set distance to scroll left */
171
- setScrollLeft,
172
- /** @description handle scroll event */
173
- handleScroll,
174
- })
175
- </script>
176
-
177
- <style lang="less">
178
- @scrollbar-bg-color: #909399;
179
- @scrollbar-hover-bg-color: #909399;
180
- @scrollbar-hover-opacity: 0.5;
181
- @scrollbar-opacity: 0.3;
182
- @transition-duration: 0.3s;
183
-
184
- .j-scrollbar {
185
- overflow: hidden;
186
- position: relative;
187
- height: 100%;
188
-
189
- &__wrap {
190
- overflow: auto;
191
- height: 100%;
192
-
193
- &--hidden-default {
194
- scrollbar-width: none;
195
-
196
- &::-webkit-scrollbar {
197
- display: none;
198
- }
199
- }
200
- }
201
-
202
- &__thumb {
203
- position: relative;
204
- display: block;
205
- width: 0;
206
- height: 0;
207
- cursor: pointer;
208
- border-radius: inherit;
209
- background-color: @scrollbar-bg-color;
210
- transition: @transition-duration background-color;
211
- opacity: @scrollbar-opacity;
212
-
213
- &:hover {
214
- background-color: @scrollbar-hover-bg-color;
215
- opacity: @scrollbar-hover-opacity;
216
- }
217
- }
218
-
219
- &__bar {
220
- position: absolute;
221
- right: 2px;
222
- bottom: 2px;
223
- z-index: 1;
224
- border-radius: 4px;
225
-
226
- &--vertical {
227
- width: 6px;
228
- top: 2px;
229
-
230
- > div {
231
- width: 100%;
232
- }
233
- }
234
-
235
- &--horizontal {
236
- height: 6px;
237
- left: 2px;
238
-
239
- > div {
240
- height: 100%;
241
- }
242
- }
243
- }
244
- }
245
-
246
- .j-scrollbar-fade {
247
- &-enter-active {
248
- transition: opacity 340ms ease-out;
249
- }
250
-
251
- &-leave-active {
252
- transition: opacity 120ms ease-out;
253
- }
254
-
255
- &-enter-from,
256
- &-leave-active {
257
- opacity: 0;
258
- }
259
- }
260
- </style>
@@ -1,163 +0,0 @@
1
- <template>
2
- <transition name="j-scrollbar-fade">
3
- <div
4
- v-show="always || visible"
5
- ref="instance"
6
- :class="['j-scrollbar__bar', props.vertical ? 'is-vertical' : 'is-horizontal']"
7
- @mousedown="clickTrackHandler"
8
- >
9
- <div
10
- ref="thumb"
11
- class="j-scrollbar__thumb"
12
- :style="thumbStyle"
13
- @mousedown="clickThumbHandler"
14
- />
15
- </div>
16
- </transition>
17
- </template>
18
-
19
- <script lang="ts" setup>
20
- import { computed, inject, onBeforeUnmount, ref, toRef } from 'vue'
21
- import { useEventListener } from '@vueuse/core'
22
- import { isClient } from '@jetlinks-web/utils'
23
- import { scrollbarContextKey } from './constants'
24
- import { BAR_MAP, renderThumbStyle } from './util'
25
- import { thumbProps } from './thumb'
26
-
27
- const props = defineProps(thumbProps)
28
-
29
- const scrollbar = inject(scrollbarContextKey)
30
-
31
- if (!scrollbar) throw new Error('can not inject scrollbar context')
32
-
33
- const instance = ref<HTMLDivElement>()
34
- const thumb = ref<HTMLDivElement>()
35
-
36
- const thumbState = ref<Partial<Record<'X' | 'Y', number>>>({})
37
- const visible = ref(false)
38
-
39
- let cursorDown = false
40
- let cursorLeave = false
41
- let originalOnSelectStart:
42
- | ((this: GlobalEventHandlers, ev: Event) => any)
43
- | null = isClient ? document.onselectstart : null
44
-
45
- const bar = computed(() => BAR_MAP[props.vertical ? 'vertical' : 'horizontal'])
46
-
47
- const thumbStyle = computed(() =>
48
- renderThumbStyle({
49
- size: props.size,
50
- move: props.move,
51
- bar: bar.value,
52
- })
53
- )
54
-
55
- const offsetRatio = computed(
56
- () =>
57
- instance.value![bar.value.offset] ** 2 /
58
- scrollbar.wrapElement![bar.value.scrollSize] /
59
- props.ratio /
60
- Thumb.value![bar.value.offset]
61
- )
62
-
63
- const clickThumbHandler = (e: MouseEvent) => {
64
- // prevent click event of middle and right button
65
- e.stopPropagation()
66
- if (e.ctrlKey || [1, 2].includes(e.button)) return
67
-
68
- window.getSelection()?.removeAllRanges()
69
- startDrag(e)
70
-
71
- const el = e.currentTarget as HTMLDivElement
72
- if (!el) return
73
- thumbState.value[bar.value.axis] =
74
- el[bar.value.offset] -
75
- (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction])
76
- }
77
-
78
- const clickTrackHandler = (e: MouseEvent) => {
79
- if (!Thumb.value || !instance.value || !scrollbar.wrapElement) return
80
-
81
- const offset = Math.abs(
82
- (e.target as HTMLElement).getBoundingClientRect()[bar.value.direction] -
83
- e[bar.value.client]
84
- )
85
- const thumbHalf = Thumb.value[bar.value.offset] / 2
86
- const thumbPositionPercentage =
87
- ((offset - thumbHalf) * 100 * offsetRatio.value) /
88
- instance.value[bar.value.offset]
89
-
90
- scrollbar.wrapElement[bar.value.scroll] =
91
- (thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) /
92
- 100
93
- }
94
-
95
- const startDrag = (e: MouseEvent) => {
96
- e.stopImmediatePropagation()
97
- cursorDown = true
98
- document.addEventListener('mousemove', mouseMoveDocumentHandler)
99
- document.addEventListener('mouseup', mouseUpDocumentHandler)
100
- originalOnSelectStart = document.onselectstart
101
- document.onselectstart = () => false
102
- }
103
-
104
- const mouseMoveDocumentHandler = (e: MouseEvent) => {
105
- if (!instance.value || !Thumb.value) return
106
- if (cursorDown === false) return
107
-
108
- const prevPage = thumbState.value[bar.value.axis]
109
- if (!prevPage) return
110
-
111
- const offset =
112
- (instance.value.getBoundingClientRect()[bar.value.direction] -
113
- e[bar.value.client]) *
114
- -1
115
- const thumbClickPosition = Thumb.value[bar.value.offset] - prevPage
116
- const thumbPositionPercentage =
117
- ((offset - thumbClickPosition) * 100 * offsetRatio.value) /
118
- instance.value[bar.value.offset]
119
- scrollbar.wrapElement[bar.value.scroll] =
120
- (thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) /
121
- 100
122
- }
123
-
124
- const mouseUpDocumentHandler = () => {
125
- cursorDown = false
126
- thumbState.value[bar.value.axis] = 0
127
- document.removeEventListener('mousemove', mouseMoveDocumentHandler)
128
- document.removeEventListener('mouseup', mouseUpDocumentHandler)
129
- restoreOnselectstart()
130
- if (cursorLeave) visible.value = false
131
- }
132
-
133
- const mouseMoveScrollbarHandler = () => {
134
- cursorLeave = false
135
- visible.value = !!props.size
136
- }
137
-
138
- const mouseLeaveScrollbarHandler = () => {
139
- cursorLeave = true
140
- visible.value = cursorDown
141
- }
142
-
143
- onBeforeUnmount(() => {
144
- restoreOnselectstart()
145
- document.removeEventListener('mouseup', mouseUpDocumentHandler)
146
- })
147
-
148
- const restoreOnselectstart = () => {
149
- if (document.onselectstart !== originalOnSelectStart)
150
- document.onselectstart = originalOnSelectStart
151
- }
152
-
153
- useEventListener(
154
- toRef(scrollbar, 'scrollbarElement'),
155
- 'mousemove',
156
- mouseMoveScrollbarHandler
157
- )
158
- useEventListener(
159
- toRef(scrollbar, 'scrollbarElement'),
160
- 'mouseleave',
161
- mouseLeaveScrollbarHandler
162
- )
163
- </script>
@@ -1,10 +0,0 @@
1
- import type { InjectionKey } from 'vue'
2
-
3
- export interface ScrollbarContext {
4
- scrollbarElement: HTMLDivElement
5
- wrapElement: HTMLDivElement
6
- }
7
-
8
- export const scrollbarContextKey: InjectionKey<ScrollbarContext> = Symbol(
9
- 'scrollbarContextKey'
10
- )
@@ -1,4 +0,0 @@
1
- import Scrollbar from './Scrollbar.vue'
2
-
3
- export default Scrollbar;
4
-
@@ -1,16 +0,0 @@
1
- import type { ExtractPropTypes } from 'vue'
2
- import type Thumb from './Thumb.vue'
3
-
4
- export const thumbProps = {
5
- vertical: Boolean,
6
- size: String,
7
- move: Number,
8
- ratio: {
9
- type: Number,
10
- required: true,
11
- },
12
- always: Boolean,
13
- }
14
- export type ThumbProps = ExtractPropTypes<typeof thumbProps>
15
-
16
- export type ThumbInstance = InstanceType<typeof Thumb>
@@ -1,38 +0,0 @@
1
- import type { CSSProperties } from 'vue'
2
- import type { ThumbProps } from './thumb'
3
-
4
- export const GAP = 4 // top 2 + bottom 2 of bar instance
5
-
6
- export const BAR_MAP = {
7
- vertical: {
8
- offset: 'offsetHeight',
9
- scroll: 'scrollTop',
10
- scrollSize: 'scrollHeight',
11
- size: 'height',
12
- key: 'vertical',
13
- axis: 'Y',
14
- client: 'clientY',
15
- direction: 'top',
16
- },
17
- horizontal: {
18
- offset: 'offsetWidth',
19
- scroll: 'scrollLeft',
20
- scrollSize: 'scrollWidth',
21
- size: 'width',
22
- key: 'horizontal',
23
- axis: 'X',
24
- client: 'clientX',
25
- direction: 'left',
26
- },
27
- } as const
28
-
29
- export const renderThumbStyle = ({
30
- move,
31
- size,
32
- bar,
33
- }: Pick<ThumbProps, 'move' | 'size'> & {
34
- bar: typeof BAR_MAP[keyof typeof BAR_MAP]
35
- }): CSSProperties => ({
36
- [bar.size]: size,
37
- transform: `translate${bar.axis}(${move}%)`,
38
- })
@@ -1,140 +0,0 @@
1
- <template>
2
- <div class="search-history-warp">
3
- <FormItemRest>
4
- <Button
5
- class="search-history-button"
6
- type="primary"
7
- html-type="submit"
8
- >
9
- 搜索
10
- </Button>
11
- </FormItemRest>
12
- <Popover
13
- placement="bottom"
14
- trigger="click"
15
- overlay-class-name="search-history-list-pop"
16
- :visible="historyVisible"
17
- @visibleChange="visibleChange"
18
- >
19
- <template #content>
20
- <div v-if="!showEmpty" class="search-history-items">
21
- <div
22
- v-for="item in historyList"
23
- :key="item.id"
24
- class="search-history-item"
25
- >
26
- <div
27
- class="history-item--title"
28
- @click="itemClick(item.content)"
29
- >
30
- <Ellipsis style="width: 100%">{{
31
- item.name
32
- }}
33
- </Ellipsis>
34
- </div>
35
- <Popconfirm
36
- title="确认删除吗?"
37
- placement="top"
38
- @confirm="deleteHistory(item)"
39
- >
40
- <span class="delete">
41
- <AIcon type="DeleteOutlined"/>
42
- </span>
43
- </Popconfirm>
44
- </div>
45
- </div>
46
- <div v-else class="search-history-empty">
47
- <Empty/>
48
- </div>
49
- </template>
50
- <div
51
- class="search-history-button-icon"
52
- @click.stop="showHistoryList"
53
- >
54
- <AIcon type="DownOutlined"/>
55
- </div>
56
- </Popover>
57
- </div>
58
- </template>
59
-
60
- <script setup lang="ts" name="SearchHistory">
61
- import type { SearchHistoryList } from '../typing';
62
- import { computed, ref } from 'vue';
63
- import type { PropType } from 'vue';
64
- import { isFunction } from 'lodash-es';
65
- import { AIcon, Empty, Ellipsis } from '../../../';
66
- import { Popconfirm, Button, FormItemRest, Popover, message } from 'ant-design-vue'
67
-
68
- type Emit = {
69
- (event: 'click'): void;
70
- (event: 'itemClick', data: string): void;
71
- };
72
- const emit = defineEmits<Emit>();
73
-
74
- const props = defineProps({
75
- target: {
76
- type: String,
77
- default: '',
78
- required: true,
79
- },
80
- request: {
81
- type: Function as PropType<(target: string) => Promise<any>>,
82
- default: null,
83
- },
84
- deleteRequest: {
85
- type: Function as PropType<(target: string, item: any) => Promise<any>>,
86
- default: null,
87
- },
88
- deleteKey: {
89
- type: String,
90
- default: 'key',
91
- },
92
- });
93
-
94
- const historyList = ref<SearchHistoryList[]>([]);
95
- const historyVisible = ref(false);
96
- const showEmpty = computed(() => {
97
- return historyList.value.length === 0;
98
- });
99
-
100
- const showHistoryList = async () => {
101
- if (props.request) {
102
- const resp = await props.request(props.target);
103
- if (resp.success && resp.result.length) {
104
- historyList.value = resp.result.filter((item) => item.content);
105
- } else {
106
- historyList.value = [];
107
- }
108
- }
109
- };
110
-
111
- const visibleChange = async (v: boolean) => {
112
- historyVisible.value = v;
113
- };
114
-
115
- const click = () => {
116
- emit('click');
117
- };
118
-
119
- const itemClick = (content: string) => {
120
- historyVisible.value = false;
121
- emit('itemClick', content);
122
- };
123
-
124
- const deleteHistory = async (item: any) => {
125
- if (props.deleteRequest && isFunction(props.deleteRequest)) {
126
- const resp = await props.deleteRequest(
127
- props.target,
128
- item[props.deleteKey],
129
- );
130
- historyVisible.value = false;
131
- if (resp.success || resp.status === 200 || resp.code === 200) {
132
- message.success('操作成功');
133
- } else {
134
- message.error('操作失败');
135
- }
136
- }
137
- };
138
- </script>
139
-
140
- <style scoped lang="less"></style>