@autobest-ui/components 2.3.0 → 2.4.0
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/esm/accordion/Item.js +6 -23
- package/esm/accordion/index.js +8 -36
- package/esm/affix/PortalAffix.js +7 -11
- package/esm/affix/index.js +30 -70
- package/esm/carousel/index.js +45 -141
- package/esm/checkbox/index.js +12 -37
- package/esm/collapse/index.js +11 -49
- package/esm/confirm/index.d.ts +8 -0
- package/esm/confirm/index.js +23 -31
- package/esm/date-picker/DateEnum.js +0 -3
- package/esm/date-picker/calendar/Day.js +62 -78
- package/esm/date-picker/calendar/MonthYear.js +20 -53
- package/esm/date-picker/calendar/grid/index.js +7 -12
- package/esm/date-picker/calendar/index.js +4 -31
- package/esm/date-picker/index.js +11 -51
- package/esm/date-picker/utils.js +6 -11
- package/esm/drawer/Child.js +10 -20
- package/esm/drawer/index.js +22 -71
- package/esm/ellipsis/index.js +9 -17
- package/esm/guide/index.js +25 -63
- package/esm/index.d.ts +1 -1
- package/esm/input-number/ControlArrow.js +0 -2
- package/esm/input-number/constants.js +2 -2
- package/esm/input-number/index.js +26 -106
- package/esm/lazy-image/index.js +10 -55
- package/esm/link-list/index.js +11 -35
- package/esm/loading/index.js +15 -42
- package/esm/loading-container/index.js +3 -6
- package/esm/loading-icon/index.js +0 -2
- package/esm/mask/index.js +6 -9
- package/esm/message/index.d.ts +17 -6
- package/esm/message/index.js +68 -96
- package/esm/message/renderMessage.d.ts +17 -0
- package/esm/message/renderMessage.js +137 -0
- package/esm/message/style/index.css +1 -1
- package/esm/modal/Title.js +5 -12
- package/esm/modal/getPopupLocation.js +5 -7
- package/esm/modal/index.js +44 -125
- package/esm/move/index.js +32 -132
- package/esm/move/range.js +6 -12
- package/esm/move/utils.js +3 -10
- package/esm/popover/index.js +9 -28
- package/esm/portal/index.js +1 -22
- package/esm/script/index.js +19 -59
- package/esm/select/index.js +28 -106
- package/esm/show-more/index.js +40 -103
- package/esm/skeleton/Item.js +1 -3
- package/esm/skeleton/index.js +5 -11
- package/esm/style.css +1 -1
- package/esm/table/body/BodyRow.js +11 -28
- package/esm/table/body/CheckIcon.js +10 -18
- package/esm/table/body/index.js +8 -12
- package/esm/table/header/CheckIcon.js +3 -11
- package/esm/table/header/HeaderCell.js +12 -33
- package/esm/table/header/HeaderRow.js +6 -17
- package/esm/table/index.js +30 -100
- package/esm/tabs/index.js +35 -118
- package/esm/tooltip/index.js +0 -4
- package/esm/trigger/align.js +6 -6
- package/esm/trigger/bottomAlign.js +33 -45
- package/esm/trigger/constants.js +0 -1
- package/esm/trigger/getPopupLocation.js +48 -68
- package/esm/trigger/index.js +52 -187
- package/esm/trigger/leftAlign.js +33 -47
- package/esm/trigger/ref.js +2 -7
- package/esm/trigger/rightAlign.js +33 -45
- package/esm/trigger/topAlign.js +33 -45
- package/esm/trigger/utils.js +28 -45
- package/lib/accordion/Item.js +6 -27
- package/lib/accordion/index.js +8 -41
- package/lib/affix/PortalAffix.js +7 -17
- package/lib/affix/index.js +30 -75
- package/lib/carousel/index.js +45 -146
- package/lib/checkbox/index.js +12 -41
- package/lib/collapse/index.js +11 -53
- package/lib/confirm/index.d.ts +8 -0
- package/lib/confirm/index.js +23 -38
- package/lib/date-picker/DateEnum.js +0 -3
- package/lib/date-picker/calendar/Day.js +62 -87
- package/lib/date-picker/calendar/MonthYear.js +20 -62
- package/lib/date-picker/calendar/grid/index.js +7 -16
- package/lib/date-picker/calendar/index.js +4 -37
- package/lib/date-picker/index.js +9 -58
- package/lib/date-picker/utils.js +6 -26
- package/lib/drawer/Child.js +10 -25
- package/lib/drawer/index.js +22 -78
- package/lib/ellipsis/index.js +9 -23
- package/lib/guide/index.js +25 -71
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -29
- package/lib/input-number/ControlArrow.js +0 -4
- package/lib/input-number/constants.js +2 -2
- package/lib/input-number/index.js +26 -114
- package/lib/lazy-image/index.js +10 -58
- package/lib/link-list/index.js +11 -40
- package/lib/loading/index.js +13 -48
- package/lib/loading-bar/index.js +0 -5
- package/lib/loading-container/index.js +3 -11
- package/lib/loading-icon/index.js +0 -7
- package/lib/mask/index.js +6 -17
- package/lib/message/index.d.ts +17 -6
- package/lib/message/index.js +67 -104
- package/lib/message/renderMessage.d.ts +17 -0
- package/lib/message/renderMessage.js +144 -0
- package/lib/message/style/index.css +1 -1
- package/lib/modal/Affix.js +0 -4
- package/lib/modal/Title.js +5 -15
- package/lib/modal/getPopupLocation.js +5 -9
- package/lib/modal/index.js +44 -135
- package/lib/move/index.js +32 -144
- package/lib/move/range.js +6 -14
- package/lib/move/utils.js +3 -12
- package/lib/popover/index.js +9 -33
- package/lib/portal/index.js +1 -25
- package/lib/script/index.js +19 -61
- package/lib/select/index.js +28 -113
- package/lib/show-more/index.js +40 -110
- package/lib/skeleton/Item.js +1 -8
- package/lib/skeleton/index.js +5 -16
- package/lib/style.css +1 -1
- package/lib/table/body/BodyRow.js +11 -33
- package/lib/table/body/CheckIcon.js +10 -22
- package/lib/table/body/index.js +8 -17
- package/lib/table/header/CheckIcon.js +3 -15
- package/lib/table/header/HeaderCell.js +12 -37
- package/lib/table/header/HeaderRow.js +6 -22
- package/lib/table/index.js +30 -107
- package/lib/tabs/index.js +35 -122
- package/lib/tooltip/index.js +0 -9
- package/lib/trigger/align.js +0 -4
- package/lib/trigger/bottomAlign.js +33 -48
- package/lib/trigger/constants.js +0 -2
- package/lib/trigger/getPopupLocation.js +48 -74
- package/lib/trigger/index.js +52 -198
- package/lib/trigger/leftAlign.js +33 -50
- package/lib/trigger/ref.js +2 -12
- package/lib/trigger/rightAlign.js +33 -48
- package/lib/trigger/topAlign.js +33 -48
- package/lib/trigger/utils.js +28 -53
- package/package.json +7 -3
|
@@ -2,18 +2,14 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
5
|
for (var p in s) {
|
|
7
6
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return __assign.apply(this, arguments);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
import { getOffsetAndSize, getScrollOffset, getStyle, getAvailSize } from '@autobest-ui/utils';
|
|
18
14
|
import { getTranslate, getLocationMethodByPlacement } from './utils';
|
|
19
15
|
import * as alignUtil from './align';
|
|
@@ -21,62 +17,53 @@ import * as alignUtil from './align';
|
|
|
21
17
|
* 获取popup元素接下来的位置信息
|
|
22
18
|
* @returns {*}
|
|
23
19
|
*/
|
|
24
|
-
|
|
25
20
|
export default function getPopupLocation(placement, rootEl, popupEl, initTranslateX, initTranslateY, rootToPopupSpacing, popupLimitSpacing, isTransformHorizontalDirection, hiddenArrow, isInsertNode) {
|
|
26
21
|
// 判断body是否有隐藏, 用于判断按照哪种方式计算元素所在位置
|
|
27
22
|
// 区别可参考getOffset的第二个参数ignoreScroll
|
|
28
23
|
// 主要解决body hidden后,如果还是参考document进行定位,超出窗口后,会被隐藏
|
|
29
24
|
var isBodyHidden = false;
|
|
30
|
-
|
|
31
25
|
try {
|
|
32
26
|
var bodyOverflowValue = getStyle(document.body, 'overflow');
|
|
33
27
|
isBodyHidden = bodyOverflowValue === 'hidden';
|
|
34
28
|
} catch (e) {}
|
|
35
|
-
|
|
36
29
|
var parentNodeInfo = {
|
|
37
30
|
left: 0,
|
|
38
31
|
top: 0
|
|
39
|
-
};
|
|
40
|
-
|
|
32
|
+
};
|
|
33
|
+
// 悬浮框插入到文档流中
|
|
41
34
|
if (isInsertNode) {
|
|
42
|
-
var parentNode = rootEl.parentNode;
|
|
43
|
-
|
|
35
|
+
var parentNode = rootEl.parentNode;
|
|
36
|
+
// 判断父级元素是否定位,否则添加relative
|
|
44
37
|
if (getStyle(parentNode, 'position') === 'static') {
|
|
45
38
|
parentNode.style.position = 'relative';
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
parentNodeInfo = getOffsetAndSize(parentNode);
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
var rootInfo = getOffsetAndSize(rootEl);
|
|
52
|
-
var popInfo = getOffsetAndSize(popupEl);
|
|
43
|
+
var popInfo = getOffsetAndSize(popupEl);
|
|
44
|
+
// 当前元素同级,形成兄弟节点时,需要设置样式隐藏
|
|
53
45
|
// 并获取浏览器可用大小, scroll等信息,
|
|
54
46
|
// 否则有可能会撑出当前UI,导致获取信息错误
|
|
55
|
-
|
|
56
47
|
if (isInsertNode) {
|
|
57
48
|
popupEl.style.display = 'none';
|
|
58
|
-
}
|
|
49
|
+
}
|
|
50
|
+
// 当body hidden时
|
|
59
51
|
// 1. 确定浏览器可用大小(窗口大小)
|
|
60
52
|
// 2. 获取scroll信息,
|
|
61
53
|
// 3. 改定位方式从document换成窗口定位,并智能判断方向,解决UI超出body导致隐藏的问题
|
|
62
|
-
|
|
63
|
-
|
|
64
54
|
var availSize = getAvailSize(isBodyHidden);
|
|
65
55
|
var scrollValueAtHidden = {
|
|
66
56
|
left: 0,
|
|
67
57
|
top: 0
|
|
68
58
|
};
|
|
69
|
-
|
|
70
59
|
if (isBodyHidden) {
|
|
71
60
|
scrollValueAtHidden = getScrollOffset();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
}
|
|
62
|
+
// 获取正确信息后,删除display样式
|
|
75
63
|
if (isInsertNode) {
|
|
76
64
|
popupEl.style.display = '';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
}
|
|
66
|
+
// 获取位置的参数
|
|
80
67
|
var params = {
|
|
81
68
|
rootInfo: rootInfo,
|
|
82
69
|
popInfo: popInfo,
|
|
@@ -86,68 +73,61 @@ export default function getPopupLocation(placement, rootEl, popupEl, initTransla
|
|
|
86
73
|
translateX: initTranslateX,
|
|
87
74
|
translateY: initTranslateY,
|
|
88
75
|
isInsertNode: isInsertNode
|
|
89
|
-
};
|
|
76
|
+
};
|
|
77
|
+
// 分两组:垂直与水平方向。
|
|
90
78
|
// 判断方法名和是否为垂直方向
|
|
91
|
-
|
|
92
79
|
var _a = getLocationMethodByPlacement({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
rootInfo: rootInfo,
|
|
81
|
+
popInfo: popInfo,
|
|
82
|
+
scrollInfo: scrollValueAtHidden,
|
|
83
|
+
placement: placement,
|
|
84
|
+
availSize: availSize,
|
|
85
|
+
rootToPopupSpacing: rootToPopupSpacing
|
|
86
|
+
}),
|
|
87
|
+
methodStr = _a.methodStr,
|
|
88
|
+
isVertical = _a.isVertical;
|
|
89
|
+
// 拼装方法名
|
|
102
90
|
// eslint-disable-next-line import/namespace
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var currentMethod = alignUtil["get".concat(methodStr, "LocationInfo")]; // 执行方法
|
|
106
|
-
|
|
91
|
+
var currentMethod = alignUtil["get".concat(methodStr, "LocationInfo")];
|
|
92
|
+
// 执行方法
|
|
107
93
|
var result = currentMethod(params);
|
|
108
|
-
|
|
109
94
|
if (isVertical) {
|
|
110
95
|
// 获取偏移量
|
|
111
96
|
var _b = getTranslate({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
97
|
+
initTranslate: initTranslateX,
|
|
98
|
+
popupLimitSpacing: popupLimitSpacing,
|
|
99
|
+
currentValue: result.width,
|
|
100
|
+
positionValue: isInsertNode ? parentNodeInfo.left + result.left : result.left,
|
|
101
|
+
scrollValue: scrollValueAtHidden.left,
|
|
102
|
+
availValue: availSize.width
|
|
103
|
+
}),
|
|
104
|
+
translateX = _b.translateValue,
|
|
105
|
+
maxValue_1 = _b.maxValue;
|
|
106
|
+
// 判断是否有偏移
|
|
123
107
|
if (!translateX) {
|
|
124
108
|
return result;
|
|
125
109
|
}
|
|
126
|
-
|
|
127
110
|
var translateResult_1 = currentMethod(__assign(__assign({}, params), {
|
|
128
111
|
translateX: translateX
|
|
129
112
|
}));
|
|
130
113
|
translateResult_1.maxWidth = maxValue_1;
|
|
131
114
|
return translateResult_1;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
115
|
+
}
|
|
116
|
+
// 获取偏移量
|
|
135
117
|
var _c = getTranslate({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
118
|
+
initTranslate: initTranslateY,
|
|
119
|
+
popupLimitSpacing: popupLimitSpacing,
|
|
120
|
+
currentValue: result.height,
|
|
121
|
+
positionValue: isInsertNode ? parentNodeInfo.top + result.top : result.top,
|
|
122
|
+
scrollValue: scrollValueAtHidden.top,
|
|
123
|
+
availValue: availSize.height
|
|
124
|
+
}),
|
|
125
|
+
translateY = _c.translateValue,
|
|
126
|
+
maxValue = _c.maxValue;
|
|
127
|
+
// 判断是否有偏移
|
|
147
128
|
if (!translateY) {
|
|
148
129
|
return result;
|
|
149
130
|
}
|
|
150
|
-
|
|
151
131
|
var translateResult = currentMethod(__assign(__assign({}, params), {
|
|
152
132
|
translateY: translateY
|
|
153
133
|
}));
|