@vxe-ui/core 4.4.31 → 4.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/dist/all.esm.js CHANGED
@@ -2,7 +2,7 @@ import { h, reactive, computed, inject, provide, createCommentVNode } from 'vue'
2
2
  import XEUtils from 'xe-utils';
3
3
  import DomZIndex from 'dom-zindex';
4
4
 
5
- const coreVersion = "4.4.31";
5
+ const coreVersion = "4.4.32";
6
6
  const VxeCore = {
7
7
  coreVersion,
8
8
  uiVersion: '',
@@ -402,7 +402,7 @@ function createLog(type, name) {
402
402
  return msg;
403
403
  };
404
404
  }
405
- const version = "4.4.31";
405
+ const version = "4.4.32";
406
406
  const log = {
407
407
  create: createLog,
408
408
  warn: createLog('warn', `v${version}`),
@@ -920,6 +920,194 @@ const scrollbarUtils = {
920
920
  }
921
921
  };
922
922
 
923
+ /**
924
+ * 获取包裹容器的元素
925
+ */
926
+ function getWrapperElement(panelElem) {
927
+ if (!panelElem) {
928
+ return null;
929
+ }
930
+ const bodyEl = document.body;
931
+ const parentEl = panelElem.parentElement;
932
+ return (parentEl === bodyEl ? document.documentElement : parentEl) || null;
933
+ }
934
+ /**
935
+ * 获取插入到指定容器的元素或字符串
936
+ */
937
+ function getAppendSelector(appendTo) {
938
+ const selectElem = appendTo && XEUtils.isFunction(appendTo) ? appendTo({}) : appendTo;
939
+ return selectElem || 'body';
940
+ }
941
+ /**
942
+ * 获取插入到指定容器的元素
943
+ */
944
+ function getAppendElement(appendTo) {
945
+ const selectElem = getAppendSelector(appendTo);
946
+ if (XEUtils.isString(selectElem)) {
947
+ return document.querySelector(selectElem) || document.body;
948
+ }
949
+ return selectElem;
950
+ }
951
+ const popperUtils = {
952
+ /**
953
+ * 更新位置
954
+ */
955
+ updatePlacement(targetElem, panelElem, options) {
956
+ const { defaultTop, defaultLeft, placement, defaultPlacement, appendTo, teleportTo, marginSize, isMinWidth } = Object.assign({
957
+ appendTo: '',
958
+ teleportTo: false,
959
+ marginSize: 18,
960
+ isMinWidth: true
961
+ }, options);
962
+ let panelPlacement = 'bottom';
963
+ let top = '';
964
+ let bottom = '';
965
+ let left = 0;
966
+ let minWidth = '';
967
+ let arrowLeft = '';
968
+ const stys = {};
969
+ if (panelElem && targetElem) {
970
+ const bodyEl = document.body;
971
+ const parentWrapperEl = getWrapperElement(teleportTo ? getAppendElement(appendTo) : panelElem);
972
+ if (parentWrapperEl) {
973
+ const targetWidth = targetElem.offsetWidth;
974
+ const targetHeight = targetElem.offsetHeight;
975
+ const panelWidth = panelElem.offsetWidth;
976
+ const panelHeight = panelElem.offsetHeight;
977
+ const parentWrapperRect = parentWrapperEl.getBoundingClientRect();
978
+ const panelRect = panelElem.getBoundingClientRect();
979
+ const targetRect = targetElem.getBoundingClientRect();
980
+ const visibleHeight = bodyEl.clientHeight;
981
+ const visibleWidth = bodyEl.clientWidth;
982
+ const parentWrapperScrollLeft = parentWrapperEl.scrollLeft;
983
+ const parentWrapperScrollTop = parentWrapperEl.scrollTop;
984
+ const parentWrapperOffsetLeft = parentWrapperRect.left;
985
+ const parentWrapperOffsetTop = parentWrapperRect.top;
986
+ const targetLeft = targetRect.left;
987
+ const targetTop = targetRect.top;
988
+ minWidth = targetElem.offsetWidth;
989
+ if (teleportTo) {
990
+ left = (defaultLeft || (targetLeft - (panelWidth - targetWidth) / 2)) - parentWrapperScrollLeft;
991
+ top = (defaultTop || (targetTop + targetHeight)) - parentWrapperScrollTop;
992
+ if (placement === 'top') {
993
+ panelPlacement = 'top';
994
+ top = targetTop - panelHeight;
995
+ }
996
+ else if (!placement) {
997
+ if (defaultPlacement === 'top') {
998
+ panelPlacement = 'top';
999
+ if (!defaultTop) {
1000
+ top = targetTop - panelHeight;
1001
+ }
1002
+ // 如果上面不够放,则向下
1003
+ if (top < marginSize) {
1004
+ panelPlacement = 'bottom';
1005
+ top = targetTop + targetHeight;
1006
+ }
1007
+ // 如果下面不够放,则向上(优先)
1008
+ if (top + panelHeight + marginSize > visibleHeight) {
1009
+ panelPlacement = 'top';
1010
+ top = targetTop - panelHeight;
1011
+ }
1012
+ }
1013
+ else {
1014
+ // 如果下面不够放,则向上
1015
+ if (top + panelHeight + marginSize > visibleHeight) {
1016
+ panelPlacement = 'top';
1017
+ top = targetTop - panelHeight;
1018
+ }
1019
+ // 如果上面不够放,则向下(优先)
1020
+ if (top < marginSize) {
1021
+ panelPlacement = 'bottom';
1022
+ top = targetTop + targetHeight;
1023
+ }
1024
+ }
1025
+ }
1026
+ // 如果溢出右边
1027
+ if (left + panelWidth + marginSize > visibleWidth) {
1028
+ left -= left + panelWidth + marginSize - visibleWidth;
1029
+ }
1030
+ // 如果溢出左边
1031
+ if (left < marginSize) {
1032
+ left = marginSize;
1033
+ }
1034
+ // 偏移
1035
+ top -= parentWrapperOffsetTop;
1036
+ left -= parentWrapperOffsetLeft;
1037
+ }
1038
+ else {
1039
+ if (placement === 'top') {
1040
+ panelPlacement = 'top';
1041
+ bottom = targetHeight;
1042
+ }
1043
+ else if (!placement) {
1044
+ // 如果下面不够放,则向上
1045
+ top = targetHeight;
1046
+ if (targetTop + targetHeight + panelHeight + marginSize > visibleHeight) {
1047
+ // 如果上面不够放,则向下(优先)
1048
+ if (targetTop - targetHeight - panelHeight > marginSize) {
1049
+ panelPlacement = 'top';
1050
+ top = '';
1051
+ bottom = targetHeight;
1052
+ }
1053
+ }
1054
+ }
1055
+ // 是否超出右侧
1056
+ if (panelRect.left + panelRect.width + marginSize > visibleWidth) {
1057
+ left = -(panelRect.left + panelRect.width + marginSize - visibleWidth);
1058
+ }
1059
+ }
1060
+ if (XEUtils.isNumber(top)) {
1061
+ stys.top = top + 'px';
1062
+ }
1063
+ if (XEUtils.isNumber(bottom)) {
1064
+ stys.bottom = bottom + 'px';
1065
+ }
1066
+ if (XEUtils.isNumber(left)) {
1067
+ stys.left = left + 'px';
1068
+ }
1069
+ if (isMinWidth && XEUtils.isNumber(minWidth)) {
1070
+ stys.minWidth = minWidth + 'px';
1071
+ }
1072
+ // 箭头
1073
+ if (left === targetLeft) {
1074
+ if (targetWidth <= panelWidth) {
1075
+ arrowLeft = targetWidth / 2;
1076
+ }
1077
+ }
1078
+ else if (left < targetLeft) {
1079
+ if (left + panelWidth > targetLeft + targetWidth) {
1080
+ arrowLeft = (targetLeft - left) + targetWidth / 2;
1081
+ }
1082
+ else {
1083
+ arrowLeft = (targetLeft - left) + (panelWidth - (targetLeft - left)) / 2;
1084
+ }
1085
+ }
1086
+ }
1087
+ }
1088
+ return {
1089
+ top: top || 0,
1090
+ bottom: bottom || 0,
1091
+ left: left || 0,
1092
+ arrowLeft: arrowLeft || 0,
1093
+ style: stys,
1094
+ placement: panelPlacement
1095
+ };
1096
+ },
1097
+ /**
1098
+ * 获取包裹容器的元素
1099
+ */
1100
+ getWrapperElement,
1101
+ /**
1102
+ * 获取插入到指定容器的元素或字符串
1103
+ */
1104
+ getAppendSelector,
1105
+ /**
1106
+ * 获取插入到指定容器的元素
1107
+ */
1108
+ getAppendElement
1109
+ };
1110
+
923
1111
  const hooks = new Store();
924
1112
 
925
1113
  function useSize(props) {
@@ -1015,6 +1203,7 @@ const VxeUI = Object.assign(VxeCore, {
1015
1203
  baseUtils,
1016
1204
  domUtils,
1017
1205
  scrollbarUtils,
1206
+ popperUtils,
1018
1207
  globalStore,
1019
1208
  hooks,
1020
1209
  component,
@@ -1027,4 +1216,4 @@ const VxeUI = Object.assign(VxeCore, {
1027
1216
  });
1028
1217
  setTheme();
1029
1218
 
1030
- export { GLOBAL_EVENT_KEYS, VxeCore, VxeUI, baseUtils, checkVersion, clipboard, commands, component, coreVersion, createEvent, VxeUI as default, domUtils, formats, getComponent, getConfig, getI18n, getIcon, getLanguage, getSlotVNs, getTheme, globalEvents, globalResize, globalStore, handleCheckInfo, hasComponent, hasLanguage, hooks, interceptor, log, menus, permission, renderCustomIcon, renderEmptyElement, renderGlobalIcon, renderer, scrollbarUtils, setConfig, setI18n, setIcon, setLanguage, setTheme, use, useFns, usePermission, useSize, validators };
1219
+ export { GLOBAL_EVENT_KEYS, VxeCore, VxeUI, baseUtils, checkVersion, clipboard, commands, component, coreVersion, createEvent, VxeUI as default, domUtils, formats, getComponent, getConfig, getI18n, getIcon, getLanguage, getSlotVNs, getTheme, globalEvents, globalResize, globalStore, handleCheckInfo, hasComponent, hasLanguage, hooks, interceptor, log, menus, permission, popperUtils, renderCustomIcon, renderEmptyElement, renderGlobalIcon, renderer, scrollbarUtils, setConfig, setI18n, setIcon, setLanguage, setTheme, use, useFns, usePermission, useSize, validators };
package/es/index.esm.js CHANGED
@@ -18,6 +18,7 @@ import { permission } from './src/permission';
18
18
  import { baseUtils } from './src/base-utils';
19
19
  import { domUtils } from './src/dom-utils';
20
20
  import { scrollbarUtils } from './src/scrollbar-utils';
21
+ import { popperUtils } from './src/popper-utils';
21
22
  import { log } from './src/log';
22
23
  import { hooks } from './src/hooks';
23
24
  import { useFns } from './src/useFns';
@@ -94,6 +95,7 @@ export const VxeUI = Object.assign(VxeCore, {
94
95
  baseUtils,
95
96
  domUtils,
96
97
  scrollbarUtils,
98
+ popperUtils,
97
99
  globalStore,
98
100
  hooks,
99
101
  component,
@@ -123,6 +125,7 @@ export * from './src/permission';
123
125
  export * from './src/base-utils';
124
126
  export * from './src/dom-utils';
125
127
  export * from './src/scrollbar-utils';
128
+ export * from './src/popper-utils';
126
129
  export * from './src/dataStore';
127
130
  export * from './src/useFns';
128
131
  export * from './src/vm';
package/es/src/core.js CHANGED
@@ -1,4 +1,4 @@
1
- export const coreVersion = "4.4.31";
1
+ export const coreVersion = "4.4.32";
2
2
  export const VxeCore = {
3
3
  coreVersion,
4
4
  uiVersion: '',
package/es/src/log.js CHANGED
@@ -6,7 +6,7 @@ function createLog(type, name) {
6
6
  return msg;
7
7
  };
8
8
  }
9
- const version = "4.4.31";
9
+ const version = "4.4.32";
10
10
  export const log = {
11
11
  create: createLog,
12
12
  warn: createLog('warn', `v${version}`),
@@ -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
+ };
@@ -249,6 +249,18 @@ Object.keys(_scrollbarUtils).forEach(function (key) {
249
249
  }
250
250
  });
251
251
  });
252
+ var _popperUtils = require("./src/popper-utils");
253
+ Object.keys(_popperUtils).forEach(function (key) {
254
+ if (key === "default" || key === "__esModule") return;
255
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
256
+ if (key in exports && exports[key] === _popperUtils[key]) return;
257
+ Object.defineProperty(exports, key, {
258
+ enumerable: true,
259
+ get: function () {
260
+ return _popperUtils[key];
261
+ }
262
+ });
263
+ });
252
264
  var _log = require("./src/log");
253
265
  Object.keys(_log).forEach(function (key) {
254
266
  if (key === "default" || key === "__esModule") return;
@@ -370,6 +382,7 @@ const VxeUI = exports.VxeUI = Object.assign(_core.VxeCore, {
370
382
  baseUtils: _baseUtils.baseUtils,
371
383
  domUtils: _domUtils.domUtils,
372
384
  scrollbarUtils: _scrollbarUtils.scrollbarUtils,
385
+ popperUtils: _popperUtils.popperUtils,
373
386
  globalStore: _dataStore.globalStore,
374
387
  hooks: _hooks.hooks,
375
388
  component,