@vxe-ui/core 4.4.42 → 4.5.1
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/all.esm.js +1594 -1389
- package/dist/all.esm.min.js +1 -0
- package/es/index.d.ts +138 -0
- package/es/index.esm.js +138 -125
- package/es/index.js +150 -0
- package/es/src/base-utils.d.ts +2 -0
- package/es/src/base-utils.js +40 -37
- package/es/src/clipboard.d.ts +2 -0
- package/es/src/clipboard.js +48 -45
- package/es/src/commands.d.ts +2 -0
- package/es/src/commands.js +47 -48
- package/es/src/config.d.ts +13 -0
- package/es/src/config.js +21 -23
- package/es/src/configStore.d.ts +2 -0
- package/es/src/configStore.js +8 -5
- package/es/src/core.d.ts +3 -0
- package/es/src/core.js +11 -7
- package/es/src/dataStore.d.ts +2 -0
- package/es/src/dataStore.js +4 -1
- package/es/src/db-utils.d.ts +2 -0
- package/es/src/db-utils.js +234 -0
- package/es/src/dom-utils.d.ts +2 -0
- package/es/src/dom-utils.js +65 -68
- package/es/src/event.d.ts +4 -0
- package/es/src/event.js +133 -147
- package/es/src/formats.d.ts +2 -0
- package/es/src/formats.js +47 -48
- package/es/src/hooks.d.ts +2 -0
- package/es/src/hooks.js +5 -2
- package/es/src/i18n.d.ts +6 -0
- package/es/src/i18n.js +51 -44
- package/es/src/i18nStore.d.ts +5 -0
- package/es/src/i18nStore.js +7 -4
- package/es/src/icon.d.ts +9 -0
- package/es/src/icon.js +28 -22
- package/es/src/iconStore.d.ts +2 -0
- package/es/src/iconStore.js +4 -1
- package/es/src/interceptor.d.ts +2 -0
- package/es/src/interceptor.js +52 -54
- package/es/src/log.d.ts +2 -0
- package/es/src/log.js +14 -11
- package/es/src/menus.d.ts +2 -0
- package/es/src/menus.js +47 -48
- package/es/src/permission.d.ts +3 -0
- package/es/src/permission.js +57 -55
- package/es/src/popper-utils.d.ts +2 -0
- package/es/src/popper-utils.js +159 -179
- package/es/src/renderer.d.ts +5 -0
- package/es/src/renderer.js +37 -42
- package/es/src/resize.d.ts +2 -0
- package/es/src/resize.js +60 -70
- package/es/src/scrollbar-utils.d.ts +2 -0
- package/es/src/scrollbar-utils.js +57 -54
- package/es/src/store.d.ts +13 -0
- package/es/src/store.js +43 -45
- package/es/src/theme.d.ts +3 -0
- package/es/src/theme.js +17 -13
- package/es/src/themeStore.d.ts +4 -0
- package/es/src/themeStore.js +5 -2
- package/es/src/useFns.d.ts +40 -0
- package/es/src/useFns.js +212 -231
- package/es/src/validators.d.ts +2 -0
- package/es/src/validators.js +6 -3
- package/es/src/vm.d.ts +2 -0
- package/es/src/vm.js +9 -6
- package/es/src/z-index.d.ts +2 -0
- package/es/src/z-index.js +29 -26
- package/lib/index.common.js +136 -365
- package/lib/index.js +181 -0
- package/lib/index.umd.js +819 -3343
- package/lib/index.umd.min.js +1 -1
- package/lib/src/base-utils.js +39 -13
- package/lib/src/clipboard.js +50 -23
- package/lib/src/commands.js +46 -27
- package/lib/src/config.js +43 -23
- package/lib/src/configStore.js +24 -7
- package/lib/src/core.js +29 -11
- package/lib/src/dataStore.js +22 -5
- package/lib/src/db-utils.js +263 -0
- package/lib/src/dom-utils.js +40 -20
- package/lib/src/event.js +95 -102
- package/lib/src/formats.js +46 -27
- package/lib/src/hooks.js +33 -7
- package/lib/src/i18n.js +53 -38
- package/lib/src/i18nStore.js +25 -8
- package/lib/src/icon.js +46 -22
- package/lib/src/iconStore.js +22 -5
- package/lib/src/interceptor.js +40 -18
- package/lib/src/log.js +29 -12
- package/lib/src/menus.js +46 -27
- package/lib/src/permission.js +40 -17
- package/lib/src/popper-utils.js +71 -71
- package/lib/src/renderer.js +40 -21
- package/lib/src/resize.js +48 -42
- package/lib/src/scrollbar-utils.js +23 -6
- package/lib/src/store.js +44 -25
- package/lib/src/theme.js +31 -14
- package/lib/src/themeStore.js +24 -7
- package/lib/src/useFns.js +87 -124
- package/lib/src/validators.js +34 -10
- package/lib/src/vm.js +34 -8
- package/lib/src/z-index.js +38 -12
- package/package.json +14 -3
- package/packages/index.ts +171 -168
- package/packages/src/base-utils.ts +42 -43
- package/packages/src/clipboard.ts +56 -56
- package/packages/src/commands.ts +56 -56
- package/packages/src/config.ts +30 -30
- package/packages/src/configStore.ts +8 -8
- package/packages/src/core.ts +11 -11
- package/packages/src/dataStore.ts +3 -4
- package/packages/src/db-utils.ts +267 -0
- package/packages/src/dom-utils.ts +86 -87
- package/packages/src/event.ts +161 -161
- package/packages/src/formats.ts +56 -56
- package/packages/src/hooks.ts +5 -5
- package/packages/src/i18n.ts +63 -63
- package/packages/src/i18nStore.ts +11 -11
- package/packages/src/icon.ts +32 -32
- package/packages/src/iconStore.ts +3 -3
- package/packages/src/interceptor.ts +64 -64
- package/packages/src/log.ts +19 -19
- package/packages/src/menus.ts +56 -56
- package/packages/src/permission.ts +61 -61
- package/packages/src/popper-utils.ts +197 -194
- package/packages/src/renderer.ts +50 -50
- package/packages/src/resize.ts +89 -89
- package/packages/src/scrollbar-utils.ts +58 -58
- package/packages/src/store.ts +47 -47
- package/packages/src/theme.ts +20 -20
- package/packages/src/themeStore.ts +7 -7
- package/packages/src/useFns.ts +270 -275
- package/packages/src/validators.ts +7 -7
- package/packages/src/vm.ts +10 -10
- package/packages/src/z-index.ts +30 -30
- package/types/core/base-utils.d.ts +39 -40
- package/types/core/clipboard.d.ts +22 -22
- package/types/core/commands.d.ts +17 -19
- package/types/core/components.d.ts +5 -5
- package/types/core/db-utils.d.ts +44 -0
- package/types/core/dom-utils.d.ts +36 -37
- package/types/core/formats.d.ts +17 -19
- package/types/core/global-config.d.ts +67 -74
- package/types/core/global-data.d.ts +7 -7
- package/types/core/global-event.d.ts +48 -48
- package/types/core/global-icon.d.ts +10 -10
- package/types/core/global-lang.d.ts +28 -27
- package/types/core/global-resize.d.ts +3 -3
- package/types/core/global-theme.d.ts +1 -1
- package/types/core/hooks.d.ts +12 -14
- package/types/core/index.d.ts +343 -336
- package/types/core/interceptor.d.ts +20 -22
- package/types/core/log.d.ts +8 -8
- package/types/core/menus.d.ts +17 -19
- package/types/core/permission.d.ts +10 -10
- package/types/core/popper-utils.d.ts +44 -44
- package/types/core/renderer.d.ts +14 -14
- package/types/core/scrollbar-utils.d.ts +37 -38
- package/types/core/useFn.d.ts +121 -126
- package/types/core/validators.d.ts +17 -19
- package/types/core/z-index.d.ts +18 -18
- package/types/index.d.ts +13 -13
- package/types/tool/common.d.ts +146 -155
- package/types/tool/index.d.ts +2 -2
- package/types/tool/util.d.ts +4 -4
- package/lib/src/base-utils.min.js +0 -1
- package/lib/src/clipboard.min.js +0 -1
- package/lib/src/commands.min.js +0 -1
- package/lib/src/config.min.js +0 -1
- package/lib/src/configStore.min.js +0 -1
- package/lib/src/core.min.js +0 -1
- package/lib/src/dataStore.min.js +0 -1
- package/lib/src/dom-utils.min.js +0 -1
- package/lib/src/event.min.js +0 -1
- package/lib/src/formats.min.js +0 -1
- package/lib/src/hooks.min.js +0 -1
- package/lib/src/i18n.min.js +0 -1
- package/lib/src/i18nStore.min.js +0 -1
- package/lib/src/icon.min.js +0 -1
- package/lib/src/iconStore.min.js +0 -1
- package/lib/src/interceptor.min.js +0 -1
- package/lib/src/log.min.js +0 -1
- package/lib/src/menus.min.js +0 -1
- package/lib/src/permission.min.js +0 -1
- package/lib/src/popper-utils.min.js +0 -1
- package/lib/src/renderer.min.js +0 -1
- package/lib/src/resize.min.js +0 -1
- package/lib/src/scrollbar-utils.min.js +0 -1
- package/lib/src/store.min.js +0 -1
- package/lib/src/theme.min.js +0 -1
- package/lib/src/themeStore.min.js +0 -1
- package/lib/src/useFns.min.js +0 -1
- package/lib/src/validators.min.js +0 -1
- package/lib/src/vm.min.js +0 -1
- package/lib/src/z-index.min.js +0 -1
|
@@ -1,194 +1,197 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
|
|
3
|
-
import type { VxePopperUtils, VxePopperOptions } from '../../types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 获取包裹容器的元素
|
|
7
|
-
*/
|
|
8
|
-
function getWrapperElement
|
|
9
|
-
if (!panelElem) {
|
|
10
|
-
return null
|
|
11
|
-
}
|
|
12
|
-
const bodyEl = document.body
|
|
13
|
-
const parentEl = panelElem.parentElement
|
|
14
|
-
return (parentEl === bodyEl ? document.documentElement : parentEl) || null
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 获取插入到指定容器的元素或字符串
|
|
19
|
-
|
|
20
|
-
function getAppendSelector
|
|
21
|
-
const selectElem = appendTo && XEUtils.isFunction(appendTo) ? appendTo({}) : appendTo
|
|
22
|
-
return selectElem || 'body'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 获取插入到指定容器的元素
|
|
27
|
-
*/
|
|
28
|
-
function getAppendElement
|
|
29
|
-
const selectElem = getAppendSelector(appendTo)
|
|
30
|
-
if (XEUtils.isString(selectElem)) {
|
|
31
|
-
return document.querySelector<HTMLElement>(selectElem) || document.body
|
|
32
|
-
}
|
|
33
|
-
return selectElem
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const popperUtils: VxePopperUtils = {
|
|
37
|
-
/**
|
|
38
|
-
* 更新位置
|
|
39
|
-
*/
|
|
40
|
-
updatePlacement
|
|
41
|
-
const { defaultTop, defaultLeft, placement, defaultPlacement, appendTo, teleportTo, marginSize, isMinWidth } = Object.assign(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
let
|
|
51
|
-
let
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
if (XEUtils.isNumber(
|
|
150
|
-
stys.
|
|
151
|
-
}
|
|
152
|
-
if (XEUtils.isNumber(
|
|
153
|
-
stys.
|
|
154
|
-
}
|
|
155
|
-
if (
|
|
156
|
-
stys.
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
|
|
3
|
+
import type { VxePopperUtils, VxePopperOptions } from '../../types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取包裹容器的元素
|
|
7
|
+
*/
|
|
8
|
+
function getWrapperElement(panelElem: HTMLElement | null | undefined) {
|
|
9
|
+
if (!panelElem) {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
const bodyEl = document.body
|
|
13
|
+
const parentEl = panelElem.parentElement
|
|
14
|
+
return (parentEl === bodyEl ? document.documentElement : parentEl) || null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取插入到指定容器的元素或字符串
|
|
19
|
+
*/
|
|
20
|
+
function getAppendSelector(appendTo: string | HTMLElement | ((params: any) => string | HTMLElement) | undefined) {
|
|
21
|
+
const selectElem = appendTo && XEUtils.isFunction(appendTo) ? appendTo({}) : appendTo
|
|
22
|
+
return selectElem || 'body'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取插入到指定容器的元素
|
|
27
|
+
*/
|
|
28
|
+
function getAppendElement(appendTo: string | HTMLElement | ((params: any) => string | HTMLElement) | undefined) {
|
|
29
|
+
const selectElem = getAppendSelector(appendTo)
|
|
30
|
+
if (XEUtils.isString(selectElem)) {
|
|
31
|
+
return document.querySelector<HTMLElement>(selectElem) || document.body
|
|
32
|
+
}
|
|
33
|
+
return selectElem
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const popperUtils: VxePopperUtils = {
|
|
37
|
+
/**
|
|
38
|
+
* 更新位置
|
|
39
|
+
*/
|
|
40
|
+
updatePlacement(targetElem: HTMLElement | null | undefined, panelElem: HTMLElement | null | undefined, options: VxePopperOptions) {
|
|
41
|
+
const { defaultTop, defaultLeft, placement, defaultPlacement, appendTo, teleportTo, marginSize, isMinWidth } = Object.assign(
|
|
42
|
+
{
|
|
43
|
+
appendTo: '',
|
|
44
|
+
teleportTo: false,
|
|
45
|
+
marginSize: 12,
|
|
46
|
+
isMinWidth: true
|
|
47
|
+
},
|
|
48
|
+
options
|
|
49
|
+
)
|
|
50
|
+
let panelPlacement: 'top' | 'bottom' = 'bottom'
|
|
51
|
+
let top: number | '' = ''
|
|
52
|
+
let bottom: number | '' = ''
|
|
53
|
+
let left = 0
|
|
54
|
+
let minWidth: number | '' = ''
|
|
55
|
+
let arrowLeft: number | '' = ''
|
|
56
|
+
const stys: Record<string, string> = {}
|
|
57
|
+
if (panelElem && targetElem) {
|
|
58
|
+
const bodyEl = document.body
|
|
59
|
+
const parentWrapperEl = getWrapperElement(teleportTo ? getAppendElement(appendTo) : panelElem)
|
|
60
|
+
if (parentWrapperEl) {
|
|
61
|
+
const targetWidth = targetElem.offsetWidth
|
|
62
|
+
const targetHeight = targetElem.offsetHeight
|
|
63
|
+
const panelWidth = panelElem.offsetWidth
|
|
64
|
+
const panelHeight = panelElem.offsetHeight
|
|
65
|
+
|
|
66
|
+
const parentWrapperRect = parentWrapperEl.getBoundingClientRect()
|
|
67
|
+
const panelRect = panelElem.getBoundingClientRect()
|
|
68
|
+
const targetRect = targetElem.getBoundingClientRect()
|
|
69
|
+
const visibleHeight = bodyEl.clientHeight
|
|
70
|
+
const visibleWidth = bodyEl.clientWidth
|
|
71
|
+
|
|
72
|
+
const parentWrapperScrollLeft = parentWrapperEl.scrollLeft
|
|
73
|
+
const parentWrapperScrollTop = parentWrapperEl.scrollTop
|
|
74
|
+
const parentWrapperOffsetLeft = parentWrapperRect.left
|
|
75
|
+
const parentWrapperOffsetTop = parentWrapperRect.top
|
|
76
|
+
const targetLeft = targetRect.left
|
|
77
|
+
const targetTop = targetRect.top
|
|
78
|
+
|
|
79
|
+
minWidth = targetElem.offsetWidth
|
|
80
|
+
|
|
81
|
+
if (teleportTo) {
|
|
82
|
+
left = (defaultLeft || targetLeft - (panelWidth - targetWidth) / 2) - parentWrapperScrollLeft
|
|
83
|
+
top = (defaultTop || targetTop + targetHeight) - parentWrapperScrollTop
|
|
84
|
+
if (placement === 'top') {
|
|
85
|
+
panelPlacement = 'top'
|
|
86
|
+
top = targetTop - panelHeight
|
|
87
|
+
} else if (!placement) {
|
|
88
|
+
if (defaultPlacement === 'top') {
|
|
89
|
+
panelPlacement = 'top'
|
|
90
|
+
if (!defaultTop) {
|
|
91
|
+
top = targetTop - panelHeight
|
|
92
|
+
}
|
|
93
|
+
// 如果上面不够放,则向下
|
|
94
|
+
if (top < marginSize) {
|
|
95
|
+
panelPlacement = 'bottom'
|
|
96
|
+
top = targetTop + targetHeight
|
|
97
|
+
}
|
|
98
|
+
// 如果下面不够放,则向上(优先)
|
|
99
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
100
|
+
panelPlacement = 'top'
|
|
101
|
+
top = targetTop - panelHeight
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
// 如果下面不够放,则向上
|
|
105
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
106
|
+
panelPlacement = 'top'
|
|
107
|
+
top = targetTop - panelHeight
|
|
108
|
+
}
|
|
109
|
+
// 如果上面不够放,则向下(优先)
|
|
110
|
+
if (top < marginSize) {
|
|
111
|
+
panelPlacement = 'bottom'
|
|
112
|
+
top = targetTop + targetHeight
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// 如果溢出右边
|
|
117
|
+
if (left + panelWidth + marginSize > visibleWidth) {
|
|
118
|
+
left -= left + panelWidth + marginSize - visibleWidth
|
|
119
|
+
}
|
|
120
|
+
// 如果溢出左边
|
|
121
|
+
if (left < marginSize) {
|
|
122
|
+
left = marginSize
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// 偏移
|
|
126
|
+
top -= parentWrapperOffsetTop
|
|
127
|
+
left -= parentWrapperOffsetLeft
|
|
128
|
+
} else {
|
|
129
|
+
if (placement === 'top') {
|
|
130
|
+
panelPlacement = 'top'
|
|
131
|
+
bottom = targetHeight
|
|
132
|
+
} else if (!placement) {
|
|
133
|
+
// 如果下面不够放,则向上
|
|
134
|
+
top = targetHeight
|
|
135
|
+
if (targetTop + targetHeight + panelHeight + marginSize > visibleHeight) {
|
|
136
|
+
// 如果上面不够放,则向下(优先)
|
|
137
|
+
if (targetTop - targetHeight - panelHeight > marginSize) {
|
|
138
|
+
panelPlacement = 'top'
|
|
139
|
+
top = ''
|
|
140
|
+
bottom = targetHeight
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// 是否超出右侧
|
|
145
|
+
if (panelRect.left + panelRect.width + marginSize > visibleWidth) {
|
|
146
|
+
left = -(panelRect.left + panelRect.width + marginSize - visibleWidth)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (XEUtils.isNumber(top)) {
|
|
150
|
+
stys.top = top + 'px'
|
|
151
|
+
}
|
|
152
|
+
if (XEUtils.isNumber(bottom)) {
|
|
153
|
+
stys.bottom = bottom + 'px'
|
|
154
|
+
}
|
|
155
|
+
if (XEUtils.isNumber(left)) {
|
|
156
|
+
stys.left = left + 'px'
|
|
157
|
+
}
|
|
158
|
+
if (isMinWidth && XEUtils.isNumber(minWidth)) {
|
|
159
|
+
stys.minWidth = minWidth + 'px'
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 箭头
|
|
163
|
+
if (left === targetLeft) {
|
|
164
|
+
if (targetWidth <= panelWidth) {
|
|
165
|
+
arrowLeft = targetWidth / 2
|
|
166
|
+
}
|
|
167
|
+
} else if (left < targetLeft) {
|
|
168
|
+
if (left + panelWidth > targetLeft + targetWidth) {
|
|
169
|
+
arrowLeft = targetLeft - left + targetWidth / 2
|
|
170
|
+
} else {
|
|
171
|
+
arrowLeft = targetLeft - left + (panelWidth - (targetLeft - left)) / 2
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
top: top || 0,
|
|
178
|
+
bottom: bottom || 0,
|
|
179
|
+
left: left || 0,
|
|
180
|
+
arrowLeft: arrowLeft || 0,
|
|
181
|
+
style: stys,
|
|
182
|
+
placement: panelPlacement
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* 获取包裹容器的元素
|
|
187
|
+
*/
|
|
188
|
+
getWrapperElement,
|
|
189
|
+
/**
|
|
190
|
+
* 获取插入到指定容器的元素或字符串
|
|
191
|
+
*/
|
|
192
|
+
getAppendSelector,
|
|
193
|
+
/**
|
|
194
|
+
* 获取插入到指定容器的元素
|
|
195
|
+
*/
|
|
196
|
+
getAppendElement
|
|
197
|
+
}
|
package/packages/src/renderer.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { log } from './log'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalRenderer, VxeGlobalRendererOptions } from '../../types'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 内置的组件渲染
|
|
8
|
-
*/
|
|
9
|
-
const renderMap: Record<string, VxeGlobalRendererOptions> = {}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 全局渲染器
|
|
13
|
-
*/
|
|
14
|
-
export const renderer: VxeGlobalRenderer = {
|
|
15
|
-
mixin
|
|
16
|
-
XEUtils.each(opts, (options, name) => {
|
|
17
|
-
renderer.add(name, options)
|
|
18
|
-
})
|
|
19
|
-
return renderer
|
|
20
|
-
},
|
|
21
|
-
get
|
|
22
|
-
return renderMap[name] || null
|
|
23
|
-
},
|
|
24
|
-
add
|
|
25
|
-
if (name && options) {
|
|
26
|
-
const renders: any = renderMap[name]
|
|
27
|
-
if (renders) {
|
|
28
|
-
// 检测是否覆盖
|
|
29
|
-
XEUtils.each(options, (val, key) => {
|
|
30
|
-
if (!XEUtils.eqNull(renders[key]) && renders[key] !== val) {
|
|
31
|
-
log.warn('vxe.error.coverProp', [`Renderer.${name}`, key])
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
Object.assign(renders, options)
|
|
36
|
-
} else {
|
|
37
|
-
renderMap[name] = options
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return renderer
|
|
41
|
-
},
|
|
42
|
-
forEach
|
|
43
|
-
XEUtils.objectEach(renderMap, callback)
|
|
44
|
-
return renderer
|
|
45
|
-
},
|
|
46
|
-
delete
|
|
47
|
-
delete renderMap[name]
|
|
48
|
-
return renderer
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { log } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalRenderer, VxeGlobalRendererOptions } from '../../types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 内置的组件渲染
|
|
8
|
+
*/
|
|
9
|
+
const renderMap: Record<string, VxeGlobalRendererOptions> = {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 全局渲染器
|
|
13
|
+
*/
|
|
14
|
+
export const renderer: VxeGlobalRenderer = {
|
|
15
|
+
mixin(opts) {
|
|
16
|
+
XEUtils.each(opts, (options, name) => {
|
|
17
|
+
renderer.add(name, options)
|
|
18
|
+
})
|
|
19
|
+
return renderer
|
|
20
|
+
},
|
|
21
|
+
get(name: string) {
|
|
22
|
+
return renderMap[name] || null
|
|
23
|
+
},
|
|
24
|
+
add(name, options) {
|
|
25
|
+
if (name && options) {
|
|
26
|
+
const renders: any = renderMap[name]
|
|
27
|
+
if (renders) {
|
|
28
|
+
// 检测是否覆盖
|
|
29
|
+
XEUtils.each(options, (val, key) => {
|
|
30
|
+
if (!XEUtils.eqNull(renders[key]) && renders[key] !== val) {
|
|
31
|
+
log.warn('vxe.error.coverProp', [`Renderer.${name}`, key])
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
Object.assign(renders, options)
|
|
36
|
+
} else {
|
|
37
|
+
renderMap[name] = options
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return renderer
|
|
41
|
+
},
|
|
42
|
+
forEach(callback) {
|
|
43
|
+
XEUtils.objectEach(renderMap, callback)
|
|
44
|
+
return renderer
|
|
45
|
+
},
|
|
46
|
+
delete(name: string) {
|
|
47
|
+
delete renderMap[name]
|
|
48
|
+
return renderer
|
|
49
|
+
}
|
|
50
|
+
}
|