@vxe-ui/core 3.4.30 → 3.4.32
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/index.esm.js +6 -0
- package/es/src/core.js +1 -1
- package/es/src/log.js +1 -1
- package/es/src/popper-utils.js +188 -0
- package/es/src/scrollbar-utils.js +56 -0
- package/lib/index.common.js +26 -0
- package/lib/index.umd.js +259 -2
- package/lib/index.umd.min.js +1 -1
- package/lib/src/core.js +1 -1
- package/lib/src/core.min.js +1 -1
- package/lib/src/log.js +1 -1
- package/lib/src/log.min.js +1 -1
- package/lib/src/popper-utils.js +198 -0
- package/lib/src/popper-utils.min.js +1 -0
- package/lib/src/scrollbar-utils.js +62 -0
- package/lib/src/scrollbar-utils.min.js +1 -0
- package/package.json +1 -1
- package/packages/index.ts +6 -0
- package/packages/src/popper-utils.ts +194 -0
- package/packages/src/scrollbar-utils.ts +58 -0
- package/types/core/index.d.ts +10 -0
- package/types/core/popper-utils.d.ts +44 -0
- package/types/core/scrollbar-utils.d.ts +38 -0
package/es/index.esm.js
CHANGED
|
@@ -16,6 +16,8 @@ import { clipboard } from './src/clipboard';
|
|
|
16
16
|
import { permission } from './src/permission';
|
|
17
17
|
import { baseUtils } from './src/base-utils';
|
|
18
18
|
import { domUtils } from './src/dom-utils';
|
|
19
|
+
import { scrollbarUtils } from './src/scrollbar-utils';
|
|
20
|
+
import { popperUtils } from './src/popper-utils';
|
|
19
21
|
import { log } from './src/log';
|
|
20
22
|
import { globalMixins } from './src/mixins';
|
|
21
23
|
import { getSlotVNs } from './src/vm';
|
|
@@ -91,6 +93,8 @@ export const VxeUI = Object.assign(VxeCore, {
|
|
|
91
93
|
permission,
|
|
92
94
|
baseUtils,
|
|
93
95
|
domUtils,
|
|
96
|
+
scrollbarUtils,
|
|
97
|
+
popperUtils,
|
|
94
98
|
globalStore,
|
|
95
99
|
component,
|
|
96
100
|
getComponent,
|
|
@@ -118,6 +122,8 @@ export * from './src/clipboard';
|
|
|
118
122
|
export * from './src/permission';
|
|
119
123
|
export * from './src/base-utils';
|
|
120
124
|
export * from './src/dom-utils';
|
|
125
|
+
export * from './src/scrollbar-utils';
|
|
126
|
+
export * from './src/popper-utils';
|
|
121
127
|
export * from './src/dataStore';
|
|
122
128
|
export * from './src/mixins';
|
|
123
129
|
export * from './src/vm';
|
package/es/src/core.js
CHANGED
package/es/src/log.js
CHANGED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils';
|
|
2
|
+
/**
|
|
3
|
+
* 获取包裹容器的元素
|
|
4
|
+
*/
|
|
5
|
+
function getWrapperElement(panelElem) {
|
|
6
|
+
if (!panelElem) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const bodyEl = document.body;
|
|
10
|
+
const parentEl = panelElem.parentElement;
|
|
11
|
+
return (parentEl === bodyEl ? document.documentElement : parentEl) || null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 获取插入到指定容器的元素或字符串
|
|
15
|
+
*/
|
|
16
|
+
function getAppendSelector(appendTo) {
|
|
17
|
+
const selectElem = appendTo && XEUtils.isFunction(appendTo) ? appendTo({}) : appendTo;
|
|
18
|
+
return selectElem || 'body';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 获取插入到指定容器的元素
|
|
22
|
+
*/
|
|
23
|
+
function getAppendElement(appendTo) {
|
|
24
|
+
const selectElem = getAppendSelector(appendTo);
|
|
25
|
+
if (XEUtils.isString(selectElem)) {
|
|
26
|
+
return document.querySelector(selectElem) || document.body;
|
|
27
|
+
}
|
|
28
|
+
return selectElem;
|
|
29
|
+
}
|
|
30
|
+
export const popperUtils = {
|
|
31
|
+
/**
|
|
32
|
+
* 更新位置
|
|
33
|
+
*/
|
|
34
|
+
updatePlacement(targetElem, panelElem, options) {
|
|
35
|
+
const { defaultTop, defaultLeft, placement, defaultPlacement, appendTo, teleportTo, marginSize, isMinWidth } = Object.assign({
|
|
36
|
+
appendTo: '',
|
|
37
|
+
teleportTo: false,
|
|
38
|
+
marginSize: 18,
|
|
39
|
+
isMinWidth: true
|
|
40
|
+
}, options);
|
|
41
|
+
let panelPlacement = 'bottom';
|
|
42
|
+
let top = '';
|
|
43
|
+
let bottom = '';
|
|
44
|
+
let left = 0;
|
|
45
|
+
let minWidth = '';
|
|
46
|
+
let arrowLeft = '';
|
|
47
|
+
const stys = {};
|
|
48
|
+
if (panelElem && targetElem) {
|
|
49
|
+
const bodyEl = document.body;
|
|
50
|
+
const parentWrapperEl = getWrapperElement(teleportTo ? getAppendElement(appendTo) : panelElem);
|
|
51
|
+
if (parentWrapperEl) {
|
|
52
|
+
const targetWidth = targetElem.offsetWidth;
|
|
53
|
+
const targetHeight = targetElem.offsetHeight;
|
|
54
|
+
const panelWidth = panelElem.offsetWidth;
|
|
55
|
+
const panelHeight = panelElem.offsetHeight;
|
|
56
|
+
const parentWrapperRect = parentWrapperEl.getBoundingClientRect();
|
|
57
|
+
const panelRect = panelElem.getBoundingClientRect();
|
|
58
|
+
const targetRect = targetElem.getBoundingClientRect();
|
|
59
|
+
const visibleHeight = bodyEl.clientHeight;
|
|
60
|
+
const visibleWidth = bodyEl.clientWidth;
|
|
61
|
+
const parentWrapperScrollLeft = parentWrapperEl.scrollLeft;
|
|
62
|
+
const parentWrapperScrollTop = parentWrapperEl.scrollTop;
|
|
63
|
+
const parentWrapperOffsetLeft = parentWrapperRect.left;
|
|
64
|
+
const parentWrapperOffsetTop = parentWrapperRect.top;
|
|
65
|
+
const targetLeft = targetRect.left;
|
|
66
|
+
const targetTop = targetRect.top;
|
|
67
|
+
minWidth = targetElem.offsetWidth;
|
|
68
|
+
if (teleportTo) {
|
|
69
|
+
left = (defaultLeft || (targetLeft - (panelWidth - targetWidth) / 2)) - parentWrapperScrollLeft;
|
|
70
|
+
top = (defaultTop || (targetTop + targetHeight)) - parentWrapperScrollTop;
|
|
71
|
+
if (placement === 'top') {
|
|
72
|
+
panelPlacement = 'top';
|
|
73
|
+
top = targetTop - panelHeight;
|
|
74
|
+
}
|
|
75
|
+
else if (!placement) {
|
|
76
|
+
if (defaultPlacement === 'top') {
|
|
77
|
+
panelPlacement = 'top';
|
|
78
|
+
if (!defaultTop) {
|
|
79
|
+
top = targetTop - panelHeight;
|
|
80
|
+
}
|
|
81
|
+
// 如果上面不够放,则向下
|
|
82
|
+
if (top < marginSize) {
|
|
83
|
+
panelPlacement = 'bottom';
|
|
84
|
+
top = targetTop + targetHeight;
|
|
85
|
+
}
|
|
86
|
+
// 如果下面不够放,则向上(优先)
|
|
87
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
88
|
+
panelPlacement = 'top';
|
|
89
|
+
top = targetTop - panelHeight;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// 如果下面不够放,则向上
|
|
94
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
95
|
+
panelPlacement = 'top';
|
|
96
|
+
top = targetTop - panelHeight;
|
|
97
|
+
}
|
|
98
|
+
// 如果上面不够放,则向下(优先)
|
|
99
|
+
if (top < marginSize) {
|
|
100
|
+
panelPlacement = 'bottom';
|
|
101
|
+
top = targetTop + targetHeight;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 如果溢出右边
|
|
106
|
+
if (left + panelWidth + marginSize > visibleWidth) {
|
|
107
|
+
left -= left + panelWidth + marginSize - visibleWidth;
|
|
108
|
+
}
|
|
109
|
+
// 如果溢出左边
|
|
110
|
+
if (left < marginSize) {
|
|
111
|
+
left = marginSize;
|
|
112
|
+
}
|
|
113
|
+
// 偏移
|
|
114
|
+
top -= parentWrapperOffsetTop;
|
|
115
|
+
left -= parentWrapperOffsetLeft;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if (placement === 'top') {
|
|
119
|
+
panelPlacement = 'top';
|
|
120
|
+
bottom = targetHeight;
|
|
121
|
+
}
|
|
122
|
+
else if (!placement) {
|
|
123
|
+
// 如果下面不够放,则向上
|
|
124
|
+
top = targetHeight;
|
|
125
|
+
if (targetTop + targetHeight + panelHeight + marginSize > visibleHeight) {
|
|
126
|
+
// 如果上面不够放,则向下(优先)
|
|
127
|
+
if (targetTop - targetHeight - panelHeight > marginSize) {
|
|
128
|
+
panelPlacement = 'top';
|
|
129
|
+
top = '';
|
|
130
|
+
bottom = targetHeight;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// 是否超出右侧
|
|
135
|
+
if (panelRect.left + panelRect.width + marginSize > visibleWidth) {
|
|
136
|
+
left = -(panelRect.left + panelRect.width + marginSize - visibleWidth);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (XEUtils.isNumber(top)) {
|
|
140
|
+
stys.top = top + 'px';
|
|
141
|
+
}
|
|
142
|
+
if (XEUtils.isNumber(bottom)) {
|
|
143
|
+
stys.bottom = bottom + 'px';
|
|
144
|
+
}
|
|
145
|
+
if (XEUtils.isNumber(left)) {
|
|
146
|
+
stys.left = left + 'px';
|
|
147
|
+
}
|
|
148
|
+
if (isMinWidth && XEUtils.isNumber(minWidth)) {
|
|
149
|
+
stys.minWidth = minWidth + 'px';
|
|
150
|
+
}
|
|
151
|
+
// 箭头
|
|
152
|
+
if (left === targetLeft) {
|
|
153
|
+
if (targetWidth <= panelWidth) {
|
|
154
|
+
arrowLeft = targetWidth / 2;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (left < targetLeft) {
|
|
158
|
+
if (left + panelWidth > targetLeft + targetWidth) {
|
|
159
|
+
arrowLeft = (targetLeft - left) + targetWidth / 2;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
arrowLeft = (targetLeft - left) + (panelWidth - (targetLeft - left)) / 2;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
top: top || 0,
|
|
169
|
+
bottom: bottom || 0,
|
|
170
|
+
left: left || 0,
|
|
171
|
+
arrowLeft: arrowLeft || 0,
|
|
172
|
+
style: stys,
|
|
173
|
+
placement: panelPlacement
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
/**
|
|
177
|
+
* 获取包裹容器的元素
|
|
178
|
+
*/
|
|
179
|
+
getWrapperElement,
|
|
180
|
+
/**
|
|
181
|
+
* 获取插入到指定容器的元素或字符串
|
|
182
|
+
*/
|
|
183
|
+
getAppendSelector,
|
|
184
|
+
/**
|
|
185
|
+
* 获取插入到指定容器的元素
|
|
186
|
+
*/
|
|
187
|
+
getAppendElement
|
|
188
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const scrollbarUtils = {
|
|
2
|
+
/**
|
|
3
|
+
* 计算滚动条滑块的长度
|
|
4
|
+
*/
|
|
5
|
+
getThumbSize(viewportSize, contentSize, trackSize) {
|
|
6
|
+
if (contentSize <= viewportSize) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
const ratio = viewportSize / contentSize;
|
|
10
|
+
const ideal = trackSize * ratio;
|
|
11
|
+
return Math.max(20, Math.min(ideal, trackSize));
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* 计算滚动条滑块的偏移位置
|
|
15
|
+
*/
|
|
16
|
+
getThumbOffsetSize(offsetSize, viewportSize, contentSize, trackSize, thumbSize) {
|
|
17
|
+
const maxScroll = contentSize - viewportSize;
|
|
18
|
+
if (maxScroll <= 0) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
const maxThumbOffset = trackSize - thumbSize;
|
|
22
|
+
if (maxThumbOffset <= 0) {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
const clamped = Math.min(Math.max(offsetSize, 0), maxScroll);
|
|
26
|
+
const ratio = clamped / maxScroll;
|
|
27
|
+
return ratio * maxThumbOffset;
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* 根据点击轨道的位置,计算滑块的偏移位置
|
|
31
|
+
*/
|
|
32
|
+
getScrollFromClick(clickPosition, viewportSize, contentSize, trackSize, thumbSize) {
|
|
33
|
+
const maxThumbOffset = trackSize - thumbSize;
|
|
34
|
+
const maxScroll = contentSize - viewportSize;
|
|
35
|
+
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
let thumbOffset = clickPosition - thumbSize / 2;
|
|
39
|
+
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
|
|
40
|
+
const scrollOffset = (thumbOffset / maxThumbOffset) * maxScroll;
|
|
41
|
+
return scrollOffset;
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
|
|
45
|
+
*/
|
|
46
|
+
getScrollFromDrag(pointerPosition, dragOffset, viewportSize, contentSize, trackSize, thumbSize) {
|
|
47
|
+
const maxScroll = contentSize - viewportSize;
|
|
48
|
+
const maxThumbOffset = trackSize - thumbSize;
|
|
49
|
+
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
let thumbOffset = pointerPosition - dragOffset;
|
|
53
|
+
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
|
|
54
|
+
return (thumbOffset / maxThumbOffset) * maxScroll;
|
|
55
|
+
}
|
|
56
|
+
};
|
package/lib/index.common.js
CHANGED
|
@@ -236,6 +236,30 @@ Object.keys(_domUtils).forEach(function (key) {
|
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
|
+
var _scrollbarUtils = require("./src/scrollbar-utils");
|
|
240
|
+
Object.keys(_scrollbarUtils).forEach(function (key) {
|
|
241
|
+
if (key === "default" || key === "__esModule") return;
|
|
242
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
243
|
+
if (key in exports && exports[key] === _scrollbarUtils[key]) return;
|
|
244
|
+
Object.defineProperty(exports, key, {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function () {
|
|
247
|
+
return _scrollbarUtils[key];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
var _popperUtils = require("./src/popper-utils");
|
|
252
|
+
Object.keys(_popperUtils).forEach(function (key) {
|
|
253
|
+
if (key === "default" || key === "__esModule") return;
|
|
254
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
255
|
+
if (key in exports && exports[key] === _popperUtils[key]) return;
|
|
256
|
+
Object.defineProperty(exports, key, {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function () {
|
|
259
|
+
return _popperUtils[key];
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
});
|
|
239
263
|
var _log = require("./src/log");
|
|
240
264
|
Object.keys(_log).forEach(function (key) {
|
|
241
265
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -347,6 +371,8 @@ const VxeUI = exports.VxeUI = Object.assign(_core.VxeCore, {
|
|
|
347
371
|
permission: _permission.permission,
|
|
348
372
|
baseUtils: _baseUtils.baseUtils,
|
|
349
373
|
domUtils: _domUtils.domUtils,
|
|
374
|
+
scrollbarUtils: _scrollbarUtils.scrollbarUtils,
|
|
375
|
+
popperUtils: _popperUtils.popperUtils,
|
|
350
376
|
globalStore: _dataStore.globalStore,
|
|
351
377
|
component,
|
|
352
378
|
getComponent,
|
package/lib/index.umd.js
CHANGED
|
@@ -2534,10 +2534,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
2534
2534
|
menus: function() { return /* reexport */ menus; },
|
|
2535
2535
|
permission: function() { return /* reexport */ permission; },
|
|
2536
2536
|
permissionMixin: function() { return /* reexport */ permissionMixin; },
|
|
2537
|
+
popperUtils: function() { return /* reexport */ popperUtils; },
|
|
2537
2538
|
renderCustomIcon: function() { return /* reexport */ renderCustomIcon; },
|
|
2538
2539
|
renderEmptyElement: function() { return /* reexport */ renderEmptyElement; },
|
|
2539
2540
|
renderGlobalIcon: function() { return /* reexport */ renderGlobalIcon; },
|
|
2540
2541
|
renderer: function() { return /* reexport */ renderer; },
|
|
2542
|
+
scrollbarUtils: function() { return /* reexport */ scrollbarUtils; },
|
|
2541
2543
|
setConfig: function() { return /* reexport */ setConfig; },
|
|
2542
2544
|
setI18n: function() { return /* reexport */ setI18n; },
|
|
2543
2545
|
setIcon: function() { return /* reexport */ setIcon; },
|
|
@@ -2569,7 +2571,7 @@ if (typeof window !== 'undefined') {
|
|
|
2569
2571
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
|
|
2570
2572
|
var es_array_push = __webpack_require__(4114);
|
|
2571
2573
|
;// ./packages/src/core.ts
|
|
2572
|
-
const coreVersion = "3.4.
|
|
2574
|
+
const coreVersion = "3.4.32";
|
|
2573
2575
|
const VxeCore = {
|
|
2574
2576
|
coreVersion,
|
|
2575
2577
|
uiVersion: '',
|
|
@@ -3222,7 +3224,7 @@ function createLog(type, name) {
|
|
|
3222
3224
|
return msg;
|
|
3223
3225
|
};
|
|
3224
3226
|
}
|
|
3225
|
-
const version = "3.4.
|
|
3227
|
+
const version = "3.4.32";
|
|
3226
3228
|
const log = {
|
|
3227
3229
|
create: createLog,
|
|
3228
3230
|
warn: createLog('warn', `v${version}`),
|
|
@@ -3699,6 +3701,255 @@ const domUtils = {
|
|
|
3699
3701
|
return parts.join(' ');
|
|
3700
3702
|
}
|
|
3701
3703
|
};
|
|
3704
|
+
;// ./packages/src/scrollbar-utils.ts
|
|
3705
|
+
const scrollbarUtils = {
|
|
3706
|
+
/**
|
|
3707
|
+
* 计算滚动条滑块的长度
|
|
3708
|
+
*/
|
|
3709
|
+
getThumbSize(viewportSize, contentSize, trackSize) {
|
|
3710
|
+
if (contentSize <= viewportSize) {
|
|
3711
|
+
return 0;
|
|
3712
|
+
}
|
|
3713
|
+
const ratio = viewportSize / contentSize;
|
|
3714
|
+
const ideal = trackSize * ratio;
|
|
3715
|
+
return Math.max(20, Math.min(ideal, trackSize));
|
|
3716
|
+
},
|
|
3717
|
+
/**
|
|
3718
|
+
* 计算滚动条滑块的偏移位置
|
|
3719
|
+
*/
|
|
3720
|
+
getThumbOffsetSize(offsetSize, viewportSize, contentSize, trackSize, thumbSize) {
|
|
3721
|
+
const maxScroll = contentSize - viewportSize;
|
|
3722
|
+
if (maxScroll <= 0) {
|
|
3723
|
+
return 0;
|
|
3724
|
+
}
|
|
3725
|
+
const maxThumbOffset = trackSize - thumbSize;
|
|
3726
|
+
if (maxThumbOffset <= 0) {
|
|
3727
|
+
return 0;
|
|
3728
|
+
}
|
|
3729
|
+
const clamped = Math.min(Math.max(offsetSize, 0), maxScroll);
|
|
3730
|
+
const ratio = clamped / maxScroll;
|
|
3731
|
+
return ratio * maxThumbOffset;
|
|
3732
|
+
},
|
|
3733
|
+
/**
|
|
3734
|
+
* 根据点击轨道的位置,计算滑块的偏移位置
|
|
3735
|
+
*/
|
|
3736
|
+
getScrollFromClick(clickPosition, viewportSize, contentSize, trackSize, thumbSize) {
|
|
3737
|
+
const maxThumbOffset = trackSize - thumbSize;
|
|
3738
|
+
const maxScroll = contentSize - viewportSize;
|
|
3739
|
+
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
3740
|
+
return 0;
|
|
3741
|
+
}
|
|
3742
|
+
let thumbOffset = clickPosition - thumbSize / 2;
|
|
3743
|
+
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
|
|
3744
|
+
const scrollOffset = thumbOffset / maxThumbOffset * maxScroll;
|
|
3745
|
+
return scrollOffset;
|
|
3746
|
+
},
|
|
3747
|
+
/**
|
|
3748
|
+
* 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
|
|
3749
|
+
*/
|
|
3750
|
+
getScrollFromDrag(pointerPosition, dragOffset, viewportSize, contentSize, trackSize, thumbSize) {
|
|
3751
|
+
const maxScroll = contentSize - viewportSize;
|
|
3752
|
+
const maxThumbOffset = trackSize - thumbSize;
|
|
3753
|
+
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
3754
|
+
return 0;
|
|
3755
|
+
}
|
|
3756
|
+
let thumbOffset = pointerPosition - dragOffset;
|
|
3757
|
+
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset);
|
|
3758
|
+
return thumbOffset / maxThumbOffset * maxScroll;
|
|
3759
|
+
}
|
|
3760
|
+
};
|
|
3761
|
+
;// ./packages/src/popper-utils.ts
|
|
3762
|
+
|
|
3763
|
+
/**
|
|
3764
|
+
* 获取包裹容器的元素
|
|
3765
|
+
*/
|
|
3766
|
+
function getWrapperElement(panelElem) {
|
|
3767
|
+
if (!panelElem) {
|
|
3768
|
+
return null;
|
|
3769
|
+
}
|
|
3770
|
+
const bodyEl = document.body;
|
|
3771
|
+
const parentEl = panelElem.parentElement;
|
|
3772
|
+
return (parentEl === bodyEl ? document.documentElement : parentEl) || null;
|
|
3773
|
+
}
|
|
3774
|
+
/**
|
|
3775
|
+
* 获取插入到指定容器的元素或字符串
|
|
3776
|
+
*/
|
|
3777
|
+
function getAppendSelector(appendTo) {
|
|
3778
|
+
const selectElem = appendTo && external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isFunction(appendTo) ? appendTo({}) : appendTo;
|
|
3779
|
+
return selectElem || 'body';
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* 获取插入到指定容器的元素
|
|
3783
|
+
*/
|
|
3784
|
+
function getAppendElement(appendTo) {
|
|
3785
|
+
const selectElem = getAppendSelector(appendTo);
|
|
3786
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(selectElem)) {
|
|
3787
|
+
return document.querySelector(selectElem) || document.body;
|
|
3788
|
+
}
|
|
3789
|
+
return selectElem;
|
|
3790
|
+
}
|
|
3791
|
+
const popperUtils = {
|
|
3792
|
+
/**
|
|
3793
|
+
* 更新位置
|
|
3794
|
+
*/
|
|
3795
|
+
updatePlacement(targetElem, panelElem, options) {
|
|
3796
|
+
const {
|
|
3797
|
+
defaultTop,
|
|
3798
|
+
defaultLeft,
|
|
3799
|
+
placement,
|
|
3800
|
+
defaultPlacement,
|
|
3801
|
+
appendTo,
|
|
3802
|
+
teleportTo,
|
|
3803
|
+
marginSize,
|
|
3804
|
+
isMinWidth
|
|
3805
|
+
} = Object.assign({
|
|
3806
|
+
appendTo: '',
|
|
3807
|
+
teleportTo: false,
|
|
3808
|
+
marginSize: 18,
|
|
3809
|
+
isMinWidth: true
|
|
3810
|
+
}, options);
|
|
3811
|
+
let panelPlacement = 'bottom';
|
|
3812
|
+
let top = '';
|
|
3813
|
+
let bottom = '';
|
|
3814
|
+
let left = 0;
|
|
3815
|
+
let minWidth = '';
|
|
3816
|
+
let arrowLeft = '';
|
|
3817
|
+
const stys = {};
|
|
3818
|
+
if (panelElem && targetElem) {
|
|
3819
|
+
const bodyEl = document.body;
|
|
3820
|
+
const parentWrapperEl = getWrapperElement(teleportTo ? getAppendElement(appendTo) : panelElem);
|
|
3821
|
+
if (parentWrapperEl) {
|
|
3822
|
+
const targetWidth = targetElem.offsetWidth;
|
|
3823
|
+
const targetHeight = targetElem.offsetHeight;
|
|
3824
|
+
const panelWidth = panelElem.offsetWidth;
|
|
3825
|
+
const panelHeight = panelElem.offsetHeight;
|
|
3826
|
+
const parentWrapperRect = parentWrapperEl.getBoundingClientRect();
|
|
3827
|
+
const panelRect = panelElem.getBoundingClientRect();
|
|
3828
|
+
const targetRect = targetElem.getBoundingClientRect();
|
|
3829
|
+
const visibleHeight = bodyEl.clientHeight;
|
|
3830
|
+
const visibleWidth = bodyEl.clientWidth;
|
|
3831
|
+
const parentWrapperScrollLeft = parentWrapperEl.scrollLeft;
|
|
3832
|
+
const parentWrapperScrollTop = parentWrapperEl.scrollTop;
|
|
3833
|
+
const parentWrapperOffsetLeft = parentWrapperRect.left;
|
|
3834
|
+
const parentWrapperOffsetTop = parentWrapperRect.top;
|
|
3835
|
+
const targetLeft = targetRect.left;
|
|
3836
|
+
const targetTop = targetRect.top;
|
|
3837
|
+
minWidth = targetElem.offsetWidth;
|
|
3838
|
+
if (teleportTo) {
|
|
3839
|
+
left = (defaultLeft || targetLeft - (panelWidth - targetWidth) / 2) - parentWrapperScrollLeft;
|
|
3840
|
+
top = (defaultTop || targetTop + targetHeight) - parentWrapperScrollTop;
|
|
3841
|
+
if (placement === 'top') {
|
|
3842
|
+
panelPlacement = 'top';
|
|
3843
|
+
top = targetTop - panelHeight;
|
|
3844
|
+
} else if (!placement) {
|
|
3845
|
+
if (defaultPlacement === 'top') {
|
|
3846
|
+
panelPlacement = 'top';
|
|
3847
|
+
if (!defaultTop) {
|
|
3848
|
+
top = targetTop - panelHeight;
|
|
3849
|
+
}
|
|
3850
|
+
// 如果上面不够放,则向下
|
|
3851
|
+
if (top < marginSize) {
|
|
3852
|
+
panelPlacement = 'bottom';
|
|
3853
|
+
top = targetTop + targetHeight;
|
|
3854
|
+
}
|
|
3855
|
+
// 如果下面不够放,则向上(优先)
|
|
3856
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
3857
|
+
panelPlacement = 'top';
|
|
3858
|
+
top = targetTop - panelHeight;
|
|
3859
|
+
}
|
|
3860
|
+
} else {
|
|
3861
|
+
// 如果下面不够放,则向上
|
|
3862
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
3863
|
+
panelPlacement = 'top';
|
|
3864
|
+
top = targetTop - panelHeight;
|
|
3865
|
+
}
|
|
3866
|
+
// 如果上面不够放,则向下(优先)
|
|
3867
|
+
if (top < marginSize) {
|
|
3868
|
+
panelPlacement = 'bottom';
|
|
3869
|
+
top = targetTop + targetHeight;
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
// 如果溢出右边
|
|
3874
|
+
if (left + panelWidth + marginSize > visibleWidth) {
|
|
3875
|
+
left -= left + panelWidth + marginSize - visibleWidth;
|
|
3876
|
+
}
|
|
3877
|
+
// 如果溢出左边
|
|
3878
|
+
if (left < marginSize) {
|
|
3879
|
+
left = marginSize;
|
|
3880
|
+
}
|
|
3881
|
+
// 偏移
|
|
3882
|
+
top -= parentWrapperOffsetTop;
|
|
3883
|
+
left -= parentWrapperOffsetLeft;
|
|
3884
|
+
} else {
|
|
3885
|
+
if (placement === 'top') {
|
|
3886
|
+
panelPlacement = 'top';
|
|
3887
|
+
bottom = targetHeight;
|
|
3888
|
+
} else if (!placement) {
|
|
3889
|
+
// 如果下面不够放,则向上
|
|
3890
|
+
top = targetHeight;
|
|
3891
|
+
if (targetTop + targetHeight + panelHeight + marginSize > visibleHeight) {
|
|
3892
|
+
// 如果上面不够放,则向下(优先)
|
|
3893
|
+
if (targetTop - targetHeight - panelHeight > marginSize) {
|
|
3894
|
+
panelPlacement = 'top';
|
|
3895
|
+
top = '';
|
|
3896
|
+
bottom = targetHeight;
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
// 是否超出右侧
|
|
3901
|
+
if (panelRect.left + panelRect.width + marginSize > visibleWidth) {
|
|
3902
|
+
left = -(panelRect.left + panelRect.width + marginSize - visibleWidth);
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(top)) {
|
|
3906
|
+
stys.top = top + 'px';
|
|
3907
|
+
}
|
|
3908
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(bottom)) {
|
|
3909
|
+
stys.bottom = bottom + 'px';
|
|
3910
|
+
}
|
|
3911
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(left)) {
|
|
3912
|
+
stys.left = left + 'px';
|
|
3913
|
+
}
|
|
3914
|
+
if (isMinWidth && external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(minWidth)) {
|
|
3915
|
+
stys.minWidth = minWidth + 'px';
|
|
3916
|
+
}
|
|
3917
|
+
// 箭头
|
|
3918
|
+
if (left === targetLeft) {
|
|
3919
|
+
if (targetWidth <= panelWidth) {
|
|
3920
|
+
arrowLeft = targetWidth / 2;
|
|
3921
|
+
}
|
|
3922
|
+
} else if (left < targetLeft) {
|
|
3923
|
+
if (left + panelWidth > targetLeft + targetWidth) {
|
|
3924
|
+
arrowLeft = targetLeft - left + targetWidth / 2;
|
|
3925
|
+
} else {
|
|
3926
|
+
arrowLeft = targetLeft - left + (panelWidth - (targetLeft - left)) / 2;
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
return {
|
|
3932
|
+
top: top || 0,
|
|
3933
|
+
bottom: bottom || 0,
|
|
3934
|
+
left: left || 0,
|
|
3935
|
+
arrowLeft: arrowLeft || 0,
|
|
3936
|
+
style: stys,
|
|
3937
|
+
placement: panelPlacement
|
|
3938
|
+
};
|
|
3939
|
+
},
|
|
3940
|
+
/**
|
|
3941
|
+
* 获取包裹容器的元素
|
|
3942
|
+
*/
|
|
3943
|
+
getWrapperElement,
|
|
3944
|
+
/**
|
|
3945
|
+
* 获取插入到指定容器的元素或字符串
|
|
3946
|
+
*/
|
|
3947
|
+
getAppendSelector,
|
|
3948
|
+
/**
|
|
3949
|
+
* 获取插入到指定容器的元素
|
|
3950
|
+
*/
|
|
3951
|
+
getAppendElement
|
|
3952
|
+
};
|
|
3702
3953
|
;// ./packages/src/mixins.ts
|
|
3703
3954
|
|
|
3704
3955
|
|
|
@@ -3757,6 +4008,8 @@ const globalMixins = {
|
|
|
3757
4008
|
|
|
3758
4009
|
|
|
3759
4010
|
|
|
4011
|
+
|
|
4012
|
+
|
|
3760
4013
|
|
|
3761
4014
|
|
|
3762
4015
|
|
|
@@ -3833,6 +4086,8 @@ const VxeUI = Object.assign(VxeCore, {
|
|
|
3833
4086
|
permission: permission,
|
|
3834
4087
|
baseUtils: baseUtils,
|
|
3835
4088
|
domUtils: domUtils,
|
|
4089
|
+
scrollbarUtils: scrollbarUtils,
|
|
4090
|
+
popperUtils: popperUtils,
|
|
3836
4091
|
globalStore: globalStore,
|
|
3837
4092
|
component,
|
|
3838
4093
|
getComponent,
|
|
@@ -3861,6 +4116,8 @@ setTheme();
|
|
|
3861
4116
|
|
|
3862
4117
|
|
|
3863
4118
|
|
|
4119
|
+
|
|
4120
|
+
|
|
3864
4121
|
|
|
3865
4122
|
|
|
3866
4123
|
|