@vxe-ui/core 3.4.31 → 3.4.33
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 +3 -0
- package/es/src/base-utils.js +15 -0
- package/es/src/core.js +1 -1
- package/es/src/dom-utils.js +56 -0
- package/es/src/log.js +1 -1
- package/es/src/popper-utils.js +188 -0
- package/lib/index.common.js +13 -0
- package/lib/index.umd.js +269 -2
- package/lib/index.umd.min.js +1 -1
- package/lib/src/base-utils.js +15 -0
- package/lib/src/base-utils.min.js +1 -1
- package/lib/src/core.js +1 -1
- package/lib/src/core.min.js +1 -1
- package/lib/src/dom-utils.js +56 -0
- package/lib/src/dom-utils.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/package.json +1 -1
- package/packages/index.ts +3 -0
- package/packages/src/base-utils.ts +15 -0
- package/packages/src/dom-utils.ts +60 -0
- package/packages/src/popper-utils.ts +194 -0
- package/types/core/base-utils.d.ts +18 -0
- package/types/core/dom-utils.d.ts +28 -0
- package/types/core/index.d.ts +3 -0
- package/types/core/popper-utils.d.ts +44 -0
package/es/index.esm.js
CHANGED
|
@@ -17,6 +17,7 @@ import { permission } from './src/permission';
|
|
|
17
17
|
import { baseUtils } from './src/base-utils';
|
|
18
18
|
import { domUtils } from './src/dom-utils';
|
|
19
19
|
import { scrollbarUtils } from './src/scrollbar-utils';
|
|
20
|
+
import { popperUtils } from './src/popper-utils';
|
|
20
21
|
import { log } from './src/log';
|
|
21
22
|
import { globalMixins } from './src/mixins';
|
|
22
23
|
import { getSlotVNs } from './src/vm';
|
|
@@ -93,6 +94,7 @@ export const VxeUI = Object.assign(VxeCore, {
|
|
|
93
94
|
baseUtils,
|
|
94
95
|
domUtils,
|
|
95
96
|
scrollbarUtils,
|
|
97
|
+
popperUtils,
|
|
96
98
|
globalStore,
|
|
97
99
|
component,
|
|
98
100
|
getComponent,
|
|
@@ -121,6 +123,7 @@ export * from './src/permission';
|
|
|
121
123
|
export * from './src/base-utils';
|
|
122
124
|
export * from './src/dom-utils';
|
|
123
125
|
export * from './src/scrollbar-utils';
|
|
126
|
+
export * from './src/popper-utils';
|
|
124
127
|
export * from './src/dataStore';
|
|
125
128
|
export * from './src/mixins';
|
|
126
129
|
export * from './src/vm';
|
package/es/src/base-utils.js
CHANGED
|
@@ -20,5 +20,20 @@ export const baseUtils = {
|
|
|
20
20
|
*/
|
|
21
21
|
getDefVal(value, defVal) {
|
|
22
22
|
return XEUtils.eqNull(value) ? defVal : value;
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* 判断是否启用
|
|
26
|
+
*/
|
|
27
|
+
isEnabled(conf) {
|
|
28
|
+
return !!(conf && conf.enabled !== false);
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* 用于开关类型的配置项
|
|
32
|
+
* 局部启用规则:conf={}
|
|
33
|
+
* 局部禁用规则:conf={enabled:false}
|
|
34
|
+
* 全局默认启用规则:conf.enabled=true
|
|
35
|
+
*/
|
|
36
|
+
hasEnableConf(conf, opts) {
|
|
37
|
+
return !!(opts && (conf ? opts.enabled !== false : opts.enabled));
|
|
23
38
|
}
|
|
24
39
|
};
|
package/es/src/core.js
CHANGED
package/es/src/dom-utils.js
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils';
|
|
2
|
+
const reClsMap = {};
|
|
3
|
+
function getClsRE(cls) {
|
|
4
|
+
if (!reClsMap[cls]) {
|
|
5
|
+
reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g');
|
|
6
|
+
}
|
|
7
|
+
return reClsMap[cls];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 判断元素是否包含 class
|
|
11
|
+
*/
|
|
12
|
+
function hasClass(elem, cls) {
|
|
13
|
+
if (elem) {
|
|
14
|
+
if (elem.classList) {
|
|
15
|
+
return elem.classList.contains(cls);
|
|
16
|
+
}
|
|
17
|
+
return !!(elem.className && elem.className.match && elem.className.match(getClsRE(cls)));
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 给元素删除 class
|
|
23
|
+
*/
|
|
24
|
+
function removeClass(elem, cls) {
|
|
25
|
+
if (elem && hasClass(elem, cls)) {
|
|
26
|
+
elem.className = elem.className.replace(getClsRE(cls), '');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
2
29
|
export const domUtils = {
|
|
30
|
+
/**
|
|
31
|
+
* 判断是否像素px单位 '100px' | 100
|
|
32
|
+
*/
|
|
33
|
+
isPx(val) {
|
|
34
|
+
return val && /^\d+(\.\d+)?(px)?$/.test(val);
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* 判断是否百分比%单位 '100%'
|
|
38
|
+
*/
|
|
39
|
+
isScale(val) {
|
|
40
|
+
return val && /^\d+(\.\d+)?%$/.test(val);
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* 判断元素是否包含 class
|
|
44
|
+
*/
|
|
45
|
+
hasClass,
|
|
46
|
+
/**
|
|
47
|
+
* 给元素删除 class
|
|
48
|
+
*/
|
|
49
|
+
removeClass,
|
|
50
|
+
/**
|
|
51
|
+
* 给元素增加 class
|
|
52
|
+
*/
|
|
53
|
+
addClass(elem, cls) {
|
|
54
|
+
if (elem && !hasClass(elem, cls)) {
|
|
55
|
+
removeClass(elem, cls);
|
|
56
|
+
elem.className = elem.className + ' ' + cls;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
3
59
|
/**
|
|
4
60
|
* 生成 className
|
|
5
61
|
*/
|
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
|
+
};
|
package/lib/index.common.js
CHANGED
|
@@ -248,6 +248,18 @@ Object.keys(_scrollbarUtils).forEach(function (key) {
|
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
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
|
+
});
|
|
251
263
|
var _log = require("./src/log");
|
|
252
264
|
Object.keys(_log).forEach(function (key) {
|
|
253
265
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -360,6 +372,7 @@ const VxeUI = exports.VxeUI = Object.assign(_core.VxeCore, {
|
|
|
360
372
|
baseUtils: _baseUtils.baseUtils,
|
|
361
373
|
domUtils: _domUtils.domUtils,
|
|
362
374
|
scrollbarUtils: _scrollbarUtils.scrollbarUtils,
|
|
375
|
+
popperUtils: _popperUtils.popperUtils,
|
|
363
376
|
globalStore: _dataStore.globalStore,
|
|
364
377
|
component,
|
|
365
378
|
getComponent,
|
package/lib/index.umd.js
CHANGED
|
@@ -2534,6 +2534,7 @@ __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; },
|
|
@@ -2570,7 +2571,7 @@ if (typeof window !== 'undefined') {
|
|
|
2570
2571
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
|
|
2571
2572
|
var es_array_push = __webpack_require__(4114);
|
|
2572
2573
|
;// ./packages/src/core.ts
|
|
2573
|
-
const coreVersion = "3.4.
|
|
2574
|
+
const coreVersion = "3.4.33";
|
|
2574
2575
|
const VxeCore = {
|
|
2575
2576
|
coreVersion,
|
|
2576
2577
|
uiVersion: '',
|
|
@@ -3223,7 +3224,7 @@ function createLog(type, name) {
|
|
|
3223
3224
|
return msg;
|
|
3224
3225
|
};
|
|
3225
3226
|
}
|
|
3226
|
-
const version = "3.4.
|
|
3227
|
+
const version = "3.4.33";
|
|
3227
3228
|
const log = {
|
|
3228
3229
|
create: createLog,
|
|
3229
3230
|
warn: createLog('warn', `v${version}`),
|
|
@@ -3673,12 +3674,83 @@ const baseUtils = {
|
|
|
3673
3674
|
*/
|
|
3674
3675
|
getDefVal(value, defVal) {
|
|
3675
3676
|
return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().eqNull(value) ? defVal : value;
|
|
3677
|
+
},
|
|
3678
|
+
/**
|
|
3679
|
+
* 判断是否启用
|
|
3680
|
+
*/
|
|
3681
|
+
isEnabled(conf) {
|
|
3682
|
+
return !!(conf && conf.enabled !== false);
|
|
3683
|
+
},
|
|
3684
|
+
/**
|
|
3685
|
+
* 用于开关类型的配置项
|
|
3686
|
+
* 局部启用规则:conf={}
|
|
3687
|
+
* 局部禁用规则:conf={enabled:false}
|
|
3688
|
+
* 全局默认启用规则:conf.enabled=true
|
|
3689
|
+
*/
|
|
3690
|
+
hasEnableConf(conf, opts) {
|
|
3691
|
+
return !!(opts && (conf ? opts.enabled !== false : opts.enabled));
|
|
3676
3692
|
}
|
|
3677
3693
|
};
|
|
3678
3694
|
;// ./packages/src/dom-utils.ts
|
|
3679
3695
|
|
|
3680
3696
|
|
|
3697
|
+
const reClsMap = {};
|
|
3698
|
+
function getClsRE(cls) {
|
|
3699
|
+
if (!reClsMap[cls]) {
|
|
3700
|
+
reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g');
|
|
3701
|
+
}
|
|
3702
|
+
return reClsMap[cls];
|
|
3703
|
+
}
|
|
3704
|
+
/**
|
|
3705
|
+
* 判断元素是否包含 class
|
|
3706
|
+
*/
|
|
3707
|
+
function hasClass(elem, cls) {
|
|
3708
|
+
if (elem) {
|
|
3709
|
+
if (elem.classList) {
|
|
3710
|
+
return elem.classList.contains(cls);
|
|
3711
|
+
}
|
|
3712
|
+
return !!(elem.className && elem.className.match && elem.className.match(getClsRE(cls)));
|
|
3713
|
+
}
|
|
3714
|
+
return false;
|
|
3715
|
+
}
|
|
3716
|
+
/**
|
|
3717
|
+
* 给元素删除 class
|
|
3718
|
+
*/
|
|
3719
|
+
function removeClass(elem, cls) {
|
|
3720
|
+
if (elem && hasClass(elem, cls)) {
|
|
3721
|
+
elem.className = elem.className.replace(getClsRE(cls), '');
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3681
3724
|
const domUtils = {
|
|
3725
|
+
/**
|
|
3726
|
+
* 判断是否像素px单位 '100px' | 100
|
|
3727
|
+
*/
|
|
3728
|
+
isPx(val) {
|
|
3729
|
+
return val && /^\d+(\.\d+)?(px)?$/.test(val);
|
|
3730
|
+
},
|
|
3731
|
+
/**
|
|
3732
|
+
* 判断是否百分比%单位 '100%'
|
|
3733
|
+
*/
|
|
3734
|
+
isScale(val) {
|
|
3735
|
+
return val && /^\d+(\.\d+)?%$/.test(val);
|
|
3736
|
+
},
|
|
3737
|
+
/**
|
|
3738
|
+
* 判断元素是否包含 class
|
|
3739
|
+
*/
|
|
3740
|
+
hasClass,
|
|
3741
|
+
/**
|
|
3742
|
+
* 给元素删除 class
|
|
3743
|
+
*/
|
|
3744
|
+
removeClass,
|
|
3745
|
+
/**
|
|
3746
|
+
* 给元素增加 class
|
|
3747
|
+
*/
|
|
3748
|
+
addClass(elem, cls) {
|
|
3749
|
+
if (elem && !hasClass(elem, cls)) {
|
|
3750
|
+
removeClass(elem, cls);
|
|
3751
|
+
elem.className = elem.className + ' ' + cls;
|
|
3752
|
+
}
|
|
3753
|
+
},
|
|
3682
3754
|
/**
|
|
3683
3755
|
* 生成 className
|
|
3684
3756
|
*/
|
|
@@ -3757,6 +3829,198 @@ const scrollbarUtils = {
|
|
|
3757
3829
|
return thumbOffset / maxThumbOffset * maxScroll;
|
|
3758
3830
|
}
|
|
3759
3831
|
};
|
|
3832
|
+
;// ./packages/src/popper-utils.ts
|
|
3833
|
+
|
|
3834
|
+
/**
|
|
3835
|
+
* 获取包裹容器的元素
|
|
3836
|
+
*/
|
|
3837
|
+
function getWrapperElement(panelElem) {
|
|
3838
|
+
if (!panelElem) {
|
|
3839
|
+
return null;
|
|
3840
|
+
}
|
|
3841
|
+
const bodyEl = document.body;
|
|
3842
|
+
const parentEl = panelElem.parentElement;
|
|
3843
|
+
return (parentEl === bodyEl ? document.documentElement : parentEl) || null;
|
|
3844
|
+
}
|
|
3845
|
+
/**
|
|
3846
|
+
* 获取插入到指定容器的元素或字符串
|
|
3847
|
+
*/
|
|
3848
|
+
function getAppendSelector(appendTo) {
|
|
3849
|
+
const selectElem = appendTo && external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isFunction(appendTo) ? appendTo({}) : appendTo;
|
|
3850
|
+
return selectElem || 'body';
|
|
3851
|
+
}
|
|
3852
|
+
/**
|
|
3853
|
+
* 获取插入到指定容器的元素
|
|
3854
|
+
*/
|
|
3855
|
+
function getAppendElement(appendTo) {
|
|
3856
|
+
const selectElem = getAppendSelector(appendTo);
|
|
3857
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(selectElem)) {
|
|
3858
|
+
return document.querySelector(selectElem) || document.body;
|
|
3859
|
+
}
|
|
3860
|
+
return selectElem;
|
|
3861
|
+
}
|
|
3862
|
+
const popperUtils = {
|
|
3863
|
+
/**
|
|
3864
|
+
* 更新位置
|
|
3865
|
+
*/
|
|
3866
|
+
updatePlacement(targetElem, panelElem, options) {
|
|
3867
|
+
const {
|
|
3868
|
+
defaultTop,
|
|
3869
|
+
defaultLeft,
|
|
3870
|
+
placement,
|
|
3871
|
+
defaultPlacement,
|
|
3872
|
+
appendTo,
|
|
3873
|
+
teleportTo,
|
|
3874
|
+
marginSize,
|
|
3875
|
+
isMinWidth
|
|
3876
|
+
} = Object.assign({
|
|
3877
|
+
appendTo: '',
|
|
3878
|
+
teleportTo: false,
|
|
3879
|
+
marginSize: 18,
|
|
3880
|
+
isMinWidth: true
|
|
3881
|
+
}, options);
|
|
3882
|
+
let panelPlacement = 'bottom';
|
|
3883
|
+
let top = '';
|
|
3884
|
+
let bottom = '';
|
|
3885
|
+
let left = 0;
|
|
3886
|
+
let minWidth = '';
|
|
3887
|
+
let arrowLeft = '';
|
|
3888
|
+
const stys = {};
|
|
3889
|
+
if (panelElem && targetElem) {
|
|
3890
|
+
const bodyEl = document.body;
|
|
3891
|
+
const parentWrapperEl = getWrapperElement(teleportTo ? getAppendElement(appendTo) : panelElem);
|
|
3892
|
+
if (parentWrapperEl) {
|
|
3893
|
+
const targetWidth = targetElem.offsetWidth;
|
|
3894
|
+
const targetHeight = targetElem.offsetHeight;
|
|
3895
|
+
const panelWidth = panelElem.offsetWidth;
|
|
3896
|
+
const panelHeight = panelElem.offsetHeight;
|
|
3897
|
+
const parentWrapperRect = parentWrapperEl.getBoundingClientRect();
|
|
3898
|
+
const panelRect = panelElem.getBoundingClientRect();
|
|
3899
|
+
const targetRect = targetElem.getBoundingClientRect();
|
|
3900
|
+
const visibleHeight = bodyEl.clientHeight;
|
|
3901
|
+
const visibleWidth = bodyEl.clientWidth;
|
|
3902
|
+
const parentWrapperScrollLeft = parentWrapperEl.scrollLeft;
|
|
3903
|
+
const parentWrapperScrollTop = parentWrapperEl.scrollTop;
|
|
3904
|
+
const parentWrapperOffsetLeft = parentWrapperRect.left;
|
|
3905
|
+
const parentWrapperOffsetTop = parentWrapperRect.top;
|
|
3906
|
+
const targetLeft = targetRect.left;
|
|
3907
|
+
const targetTop = targetRect.top;
|
|
3908
|
+
minWidth = targetElem.offsetWidth;
|
|
3909
|
+
if (teleportTo) {
|
|
3910
|
+
left = (defaultLeft || targetLeft - (panelWidth - targetWidth) / 2) - parentWrapperScrollLeft;
|
|
3911
|
+
top = (defaultTop || targetTop + targetHeight) - parentWrapperScrollTop;
|
|
3912
|
+
if (placement === 'top') {
|
|
3913
|
+
panelPlacement = 'top';
|
|
3914
|
+
top = targetTop - panelHeight;
|
|
3915
|
+
} else if (!placement) {
|
|
3916
|
+
if (defaultPlacement === 'top') {
|
|
3917
|
+
panelPlacement = 'top';
|
|
3918
|
+
if (!defaultTop) {
|
|
3919
|
+
top = targetTop - panelHeight;
|
|
3920
|
+
}
|
|
3921
|
+
// 如果上面不够放,则向下
|
|
3922
|
+
if (top < marginSize) {
|
|
3923
|
+
panelPlacement = 'bottom';
|
|
3924
|
+
top = targetTop + targetHeight;
|
|
3925
|
+
}
|
|
3926
|
+
// 如果下面不够放,则向上(优先)
|
|
3927
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
3928
|
+
panelPlacement = 'top';
|
|
3929
|
+
top = targetTop - panelHeight;
|
|
3930
|
+
}
|
|
3931
|
+
} else {
|
|
3932
|
+
// 如果下面不够放,则向上
|
|
3933
|
+
if (top + panelHeight + marginSize > visibleHeight) {
|
|
3934
|
+
panelPlacement = 'top';
|
|
3935
|
+
top = targetTop - panelHeight;
|
|
3936
|
+
}
|
|
3937
|
+
// 如果上面不够放,则向下(优先)
|
|
3938
|
+
if (top < marginSize) {
|
|
3939
|
+
panelPlacement = 'bottom';
|
|
3940
|
+
top = targetTop + targetHeight;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
// 如果溢出右边
|
|
3945
|
+
if (left + panelWidth + marginSize > visibleWidth) {
|
|
3946
|
+
left -= left + panelWidth + marginSize - visibleWidth;
|
|
3947
|
+
}
|
|
3948
|
+
// 如果溢出左边
|
|
3949
|
+
if (left < marginSize) {
|
|
3950
|
+
left = marginSize;
|
|
3951
|
+
}
|
|
3952
|
+
// 偏移
|
|
3953
|
+
top -= parentWrapperOffsetTop;
|
|
3954
|
+
left -= parentWrapperOffsetLeft;
|
|
3955
|
+
} else {
|
|
3956
|
+
if (placement === 'top') {
|
|
3957
|
+
panelPlacement = 'top';
|
|
3958
|
+
bottom = targetHeight;
|
|
3959
|
+
} else if (!placement) {
|
|
3960
|
+
// 如果下面不够放,则向上
|
|
3961
|
+
top = targetHeight;
|
|
3962
|
+
if (targetTop + targetHeight + panelHeight + marginSize > visibleHeight) {
|
|
3963
|
+
// 如果上面不够放,则向下(优先)
|
|
3964
|
+
if (targetTop - targetHeight - panelHeight > marginSize) {
|
|
3965
|
+
panelPlacement = 'top';
|
|
3966
|
+
top = '';
|
|
3967
|
+
bottom = targetHeight;
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
// 是否超出右侧
|
|
3972
|
+
if (panelRect.left + panelRect.width + marginSize > visibleWidth) {
|
|
3973
|
+
left = -(panelRect.left + panelRect.width + marginSize - visibleWidth);
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(top)) {
|
|
3977
|
+
stys.top = top + 'px';
|
|
3978
|
+
}
|
|
3979
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(bottom)) {
|
|
3980
|
+
stys.bottom = bottom + 'px';
|
|
3981
|
+
}
|
|
3982
|
+
if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(left)) {
|
|
3983
|
+
stys.left = left + 'px';
|
|
3984
|
+
}
|
|
3985
|
+
if (isMinWidth && external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(minWidth)) {
|
|
3986
|
+
stys.minWidth = minWidth + 'px';
|
|
3987
|
+
}
|
|
3988
|
+
// 箭头
|
|
3989
|
+
if (left === targetLeft) {
|
|
3990
|
+
if (targetWidth <= panelWidth) {
|
|
3991
|
+
arrowLeft = targetWidth / 2;
|
|
3992
|
+
}
|
|
3993
|
+
} else if (left < targetLeft) {
|
|
3994
|
+
if (left + panelWidth > targetLeft + targetWidth) {
|
|
3995
|
+
arrowLeft = targetLeft - left + targetWidth / 2;
|
|
3996
|
+
} else {
|
|
3997
|
+
arrowLeft = targetLeft - left + (panelWidth - (targetLeft - left)) / 2;
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
return {
|
|
4003
|
+
top: top || 0,
|
|
4004
|
+
bottom: bottom || 0,
|
|
4005
|
+
left: left || 0,
|
|
4006
|
+
arrowLeft: arrowLeft || 0,
|
|
4007
|
+
style: stys,
|
|
4008
|
+
placement: panelPlacement
|
|
4009
|
+
};
|
|
4010
|
+
},
|
|
4011
|
+
/**
|
|
4012
|
+
* 获取包裹容器的元素
|
|
4013
|
+
*/
|
|
4014
|
+
getWrapperElement,
|
|
4015
|
+
/**
|
|
4016
|
+
* 获取插入到指定容器的元素或字符串
|
|
4017
|
+
*/
|
|
4018
|
+
getAppendSelector,
|
|
4019
|
+
/**
|
|
4020
|
+
* 获取插入到指定容器的元素
|
|
4021
|
+
*/
|
|
4022
|
+
getAppendElement
|
|
4023
|
+
};
|
|
3760
4024
|
;// ./packages/src/mixins.ts
|
|
3761
4025
|
|
|
3762
4026
|
|
|
@@ -3817,6 +4081,7 @@ const globalMixins = {
|
|
|
3817
4081
|
|
|
3818
4082
|
|
|
3819
4083
|
|
|
4084
|
+
|
|
3820
4085
|
|
|
3821
4086
|
|
|
3822
4087
|
const installedPlugins = [];
|
|
@@ -3893,6 +4158,7 @@ const VxeUI = Object.assign(VxeCore, {
|
|
|
3893
4158
|
baseUtils: baseUtils,
|
|
3894
4159
|
domUtils: domUtils,
|
|
3895
4160
|
scrollbarUtils: scrollbarUtils,
|
|
4161
|
+
popperUtils: popperUtils,
|
|
3896
4162
|
globalStore: globalStore,
|
|
3897
4163
|
component,
|
|
3898
4164
|
getComponent,
|
|
@@ -3923,6 +4189,7 @@ setTheme();
|
|
|
3923
4189
|
|
|
3924
4190
|
|
|
3925
4191
|
|
|
4192
|
+
|
|
3926
4193
|
|
|
3927
4194
|
|
|
3928
4195
|
/* harmony default export */ var packages_0 = (VxeUI);
|