@ucloud-fe/react-components 1.3.26 → 1.4.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/CHANGELOG.md +19 -0
- package/dist/icon.min.js +1 -1
- package/dist/main.min.js +4 -4
- package/lib/components/AutoComplete/AutoComplete.js +7 -4
- package/lib/components/Badge/Bubble.d.ts +2 -0
- package/lib/components/Box/Box.d.ts +1 -0
- package/lib/components/Calendar/Calendar.d.ts +6 -1
- package/lib/components/Calendar/Calendar.js +12 -4
- package/lib/components/Calendar/Cell.d.ts +8 -0
- package/lib/components/Calendar/Cell.js +55 -0
- package/lib/components/Calendar/HeaderButton.d.ts +8 -0
- package/lib/components/Calendar/HeaderButton.js +75 -0
- package/lib/components/Calendar/HeaderSwitcher.d.ts +2 -1
- package/lib/components/Calendar/Month.js +10 -4
- package/lib/components/Calendar/TwoSide.d.ts +4 -0
- package/lib/components/Calendar/TwoSide.js +155 -0
- package/lib/components/Calendar/index.d.ts +3 -0
- package/lib/components/Calendar/index.js +9 -0
- package/lib/components/Calendar/locale/en_US.js +2 -1
- package/lib/components/Calendar/locale/zh_CN.d.ts +1 -0
- package/lib/components/Calendar/locale/zh_CN.js +3 -2
- package/lib/components/Calendar/style/index.d.ts +13 -0
- package/lib/components/Calendar/style/index.js +29 -7
- package/lib/components/Calendar/utils.d.ts +1 -1
- package/lib/components/Calendar/utils.js +5 -5
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +5 -7
- package/lib/components/DatePicker/Footer.d.ts +5 -2
- package/lib/components/DatePicker/Footer.js +31 -55
- package/lib/components/DatePicker/Month.js +4 -6
- package/lib/components/DatePicker/Range.d.ts +2 -2
- package/lib/components/DatePicker/Range.js +179 -71
- package/lib/components/DatePicker/locale/en_US.js +2 -1
- package/lib/components/DatePicker/locale/zh_CN.d.ts +1 -0
- package/lib/components/DatePicker/locale/zh_CN.js +2 -1
- package/lib/components/DatePicker/style/index.d.ts +24 -5
- package/lib/components/DatePicker/style/index.js +102 -34
- package/lib/components/DatePicker/usePicker.js +90 -31
- package/lib/components/DatePicker/useRangePicker.d.ts +16 -0
- package/lib/components/DatePicker/{RangePicker.js → useRangePicker.js} +44 -80
- package/lib/components/DatePicker/utils.d.ts +1 -1
- package/lib/components/Form/ControllerContext.d.ts +1 -1
- package/lib/components/Input/Input.js +4 -2
- package/lib/components/Input/Search.js +1 -1
- package/lib/components/Input/style/index.d.ts +2 -1
- package/lib/components/Input/style/index.js +6 -4
- package/lib/components/Loading/Loading.d.ts +1 -0
- package/lib/components/NumberInput/NumberInput.d.ts +12 -0
- package/lib/components/NumberInput/NumberInput.js +1 -1
- package/lib/components/Pagination/Options.js +1 -1
- package/lib/components/Popover/Popover.d.ts +17 -13
- package/lib/components/Popover/Popover.js +1 -3
- package/lib/components/Popover/style/index.d.ts +1 -0
- package/lib/components/Popover/style/index.js +1 -1
- package/lib/components/Select/style/index.d.ts +6 -6
- package/lib/components/SvgIcon/SvgIcon.d.ts +1 -0
- package/lib/components/SvgIcon/SvgIcon.js +6 -0
- package/lib/components/SvgIcon/SvgIconWrap.d.ts +1 -0
- package/lib/components/SvgIcon/icons/DoubleArrowLeft.d.ts +3 -0
- package/lib/components/SvgIcon/icons/DoubleArrowLeft.js +27 -0
- package/lib/components/SvgIcon/icons/DoubleArrowRight.d.ts +3 -0
- package/lib/components/SvgIcon/icons/DoubleArrowRight.js +26 -0
- package/lib/components/Switch/style/index.js +2 -2
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/Tabs/style/index.d.ts +1 -1
- package/lib/components/Tag/Group.d.ts +1 -0
- package/lib/components/Tag/Icon.d.ts +1 -0
- package/lib/components/Tag/Tag.d.ts +1 -0
- package/lib/components/Textarea/Textarea.d.ts +1 -0
- package/lib/components/ThemeProvider/ThemeProvider.d.ts +6 -0
- package/lib/components/ThemeProvider/dark.js +6 -249
- package/lib/components/ThemeProvider/designTokens.d.ts +267 -258
- package/lib/components/ThemeProvider/designTokens.js +460 -185
- package/lib/components/ThemeProvider/designTokensDark.d.ts +267 -0
- package/lib/components/ThemeProvider/designTokensDark.js +540 -0
- package/lib/components/ThemeProvider/theme.d.ts +1 -1
- package/lib/components/ThemeProvider/theme.js +3 -3
- package/lib/components/TimePicker/TimePicker.d.ts +1 -1
- package/lib/components/TimePicker/TimePicker.js +11 -13
- package/lib/components/TimePicker/style/index.d.ts +3 -1
- package/lib/components/TimePicker/style/index.js +11 -21
- package/lib/hooks/usePopoverConfig.d.ts +4 -4
- package/lib/libs/dom-align/adjustForViewport.js +55 -0
- package/lib/libs/dom-align/align/align.js +244 -0
- package/lib/libs/dom-align/align/alignElement.js +34 -0
- package/lib/libs/dom-align/align/alignPoint.js +67 -0
- package/lib/libs/dom-align/getAlignOffset.js +38 -0
- package/lib/libs/dom-align/getElFuturePos.js +23 -0
- package/lib/libs/dom-align/getOffsetParent.js +63 -0
- package/lib/libs/dom-align/getRegion.js +38 -0
- package/lib/libs/dom-align/getVisibleRectForElement.js +118 -0
- package/lib/libs/dom-align/index.js +27 -0
- package/lib/libs/dom-align/isAncestorFixed.js +34 -0
- package/lib/libs/dom-align/propertyUtils.js +138 -0
- package/lib/libs/dom-align/utils.js +657 -0
- package/lib/libs/rc-align/index.d.ts +4 -0
- package/lib/libs/rc-align/index.js +15 -3
- package/lib/libs/rc-table/Table.d.ts +5 -0
- package/lib/libs/rc-table/TableCell.d.ts +1 -0
- package/lib/libs/rc-trigger/index.js +14 -0
- package/lib/libs/rc-trigger/src/LazyRenderBox.js +82 -0
- package/lib/libs/rc-trigger/src/Popup.js +383 -0
- package/lib/libs/rc-trigger/src/PopupInner.js +85 -0
- package/lib/libs/rc-trigger/src/index.js +867 -0
- package/lib/libs/rc-trigger/src/mock.js +33 -0
- package/lib/libs/rc-trigger/src/utils.js +48 -0
- package/lib/utils/KeyCode.d.ts +15 -0
- package/lib/{interfaces → utils}/KeyCode.js +0 -0
- package/package.json +4 -6
- package/lib/components/DatePicker/RangePicker.d.ts +0 -17
- package/lib/interfaces/KeyCode.d.ts +0 -15
- package/lib/style/color.js +0 -23
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _newArrowCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/newArrowCheck"));
|
|
11
|
+
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
14
|
+
var _propertyUtils = require("./propertyUtils");
|
|
15
|
+
|
|
16
|
+
var _this = void 0;
|
|
17
|
+
|
|
18
|
+
var RE_NUM = /[-+]?(?:\d*\.|)\d+(?:[eE][-+]?\d+|)/.source;
|
|
19
|
+
var getComputedStyleX; // https://stackoverflow.com/a/3485654/3040605
|
|
20
|
+
|
|
21
|
+
function forceRelayout(elem) {
|
|
22
|
+
var originalStyle = elem.style.display;
|
|
23
|
+
elem.style.display = 'none';
|
|
24
|
+
elem.offsetHeight; // eslint-disable-line
|
|
25
|
+
|
|
26
|
+
elem.style.display = originalStyle;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function css(el, name, v) {
|
|
30
|
+
var value = v;
|
|
31
|
+
|
|
32
|
+
if ((0, _typeof2.default)(name) === 'object') {
|
|
33
|
+
for (var i in name) {
|
|
34
|
+
if (name.hasOwnProperty(i)) {
|
|
35
|
+
css(el, i, name[i]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof value !== 'undefined') {
|
|
43
|
+
if (typeof value === 'number') {
|
|
44
|
+
value = "".concat(value, "px");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
el.style[name] = value;
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return getComputedStyleX(el, name);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getClientPosition(elem) {
|
|
55
|
+
var x;
|
|
56
|
+
var y;
|
|
57
|
+
var doc = elem.ownerDocument;
|
|
58
|
+
var body = doc.body;
|
|
59
|
+
var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
|
|
60
|
+
|
|
61
|
+
var box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
|
|
62
|
+
// 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
|
|
63
|
+
// 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
|
|
64
|
+
|
|
65
|
+
x = Math.floor(box.left);
|
|
66
|
+
y = Math.floor(box.top); // In IE, most of the time, 2 extra pixels are added to the top and left
|
|
67
|
+
// due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
|
|
68
|
+
// IE6 standards mode, this border can be overridden by setting the
|
|
69
|
+
// document element's border to zero -- thus, we cannot rely on the
|
|
70
|
+
// offset always being 2 pixels.
|
|
71
|
+
// In quirks mode, the offset can be determined by querying the body's
|
|
72
|
+
// clientLeft/clientTop, but in standards mode, it is found by querying
|
|
73
|
+
// the document element's clientLeft/clientTop. Since we already called
|
|
74
|
+
// getClientBoundingRect we have already forced a reflow, so it is not
|
|
75
|
+
// too expensive just to query them all.
|
|
76
|
+
// ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
|
|
77
|
+
// 窗口边框标准是设 documentElement ,quirks 时设置 body
|
|
78
|
+
// 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
|
|
79
|
+
// 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
|
|
80
|
+
// 标准 ie 下 docElem.clientTop 就是 border-top
|
|
81
|
+
// ie7 html 即窗口边框改变不了。永远为 2
|
|
82
|
+
// 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
|
|
83
|
+
|
|
84
|
+
x -= docElem.clientLeft || body.clientLeft || 0;
|
|
85
|
+
y -= docElem.clientTop || body.clientTop || 0;
|
|
86
|
+
return {
|
|
87
|
+
left: x,
|
|
88
|
+
top: y
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getScroll(w, top) {
|
|
93
|
+
var ret = w["page".concat(top ? 'Y' : 'X', "Offset")];
|
|
94
|
+
var method = "scroll".concat(top ? 'Top' : 'Left');
|
|
95
|
+
|
|
96
|
+
if (typeof ret !== 'number') {
|
|
97
|
+
var d = w.document; // ie6,7,8 standard mode
|
|
98
|
+
|
|
99
|
+
ret = d.documentElement[method];
|
|
100
|
+
|
|
101
|
+
if (typeof ret !== 'number') {
|
|
102
|
+
// quirks mode
|
|
103
|
+
ret = d.body[method];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getScrollLeft(w) {
|
|
111
|
+
return getScroll(w);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getScrollTop(w) {
|
|
115
|
+
return getScroll(w, true);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getOffset(el) {
|
|
119
|
+
var pos = getClientPosition(el);
|
|
120
|
+
var doc = el.ownerDocument;
|
|
121
|
+
var w = doc.defaultView || doc.parentWindow;
|
|
122
|
+
pos.left += getScrollLeft(w);
|
|
123
|
+
pos.top += getScrollTop(w);
|
|
124
|
+
return pos;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A crude way of determining if an object is a window
|
|
128
|
+
* @member util
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
function isWindow(obj) {
|
|
133
|
+
// must use == for ie8
|
|
134
|
+
|
|
135
|
+
/* eslint eqeqeq:0 */
|
|
136
|
+
return obj !== null && obj !== undefined && obj == obj.window;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function getDocument(node) {
|
|
140
|
+
if (isWindow(node)) {
|
|
141
|
+
return node.document;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (node.nodeType === 9) {
|
|
145
|
+
return node;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return node.ownerDocument;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function _getComputedStyle(elem, name, cs) {
|
|
152
|
+
var computedStyle = cs;
|
|
153
|
+
var val = '';
|
|
154
|
+
var d = getDocument(elem);
|
|
155
|
+
computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null); // https://github.com/kissyteam/kissy/issues/61
|
|
156
|
+
|
|
157
|
+
if (computedStyle) {
|
|
158
|
+
val = computedStyle.getPropertyValue(name) || computedStyle[name];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return val;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var _RE_NUM_NO_PX = new RegExp("^(".concat(RE_NUM, ")(?!px)[a-z%]+$"), 'i');
|
|
165
|
+
|
|
166
|
+
var RE_POS = /^(top|right|bottom|left)$/;
|
|
167
|
+
var CURRENT_STYLE = 'currentStyle';
|
|
168
|
+
var RUNTIME_STYLE = 'runtimeStyle';
|
|
169
|
+
var LEFT = 'left';
|
|
170
|
+
var PX = 'px';
|
|
171
|
+
|
|
172
|
+
function _getComputedStyleIE(elem, name) {
|
|
173
|
+
// currentStyle maybe null
|
|
174
|
+
// http://msdn.microsoft.com/en-us/library/ms535231.aspx
|
|
175
|
+
var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
|
|
176
|
+
// 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
|
|
177
|
+
// 在 ie 下不对,需要直接用 offset 方式
|
|
178
|
+
// borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
|
|
179
|
+
// From the awesome hack by Dean Edwards
|
|
180
|
+
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
181
|
+
// If we're not dealing with a regular pixel number
|
|
182
|
+
// but a number that has a weird ending, we need to convert it to pixels
|
|
183
|
+
// exclude left right for relativity
|
|
184
|
+
|
|
185
|
+
if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
|
|
186
|
+
// Remember the original values
|
|
187
|
+
var style = elem.style;
|
|
188
|
+
var left = style[LEFT];
|
|
189
|
+
var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content
|
|
190
|
+
|
|
191
|
+
elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out
|
|
192
|
+
|
|
193
|
+
style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
|
|
194
|
+
ret = style.pixelLeft + PX; // Revert the changed values
|
|
195
|
+
|
|
196
|
+
style[LEFT] = left;
|
|
197
|
+
elem[RUNTIME_STYLE][LEFT] = rsLeft;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return ret === '' ? 'auto' : ret;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (typeof window !== 'undefined') {
|
|
204
|
+
getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function getOffsetDirection(dir, option) {
|
|
208
|
+
if (dir === 'left') {
|
|
209
|
+
return option.useCssRight ? 'right' : dir;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return option.useCssBottom ? 'bottom' : dir;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function oppositeOffsetDirection(dir) {
|
|
216
|
+
if (dir === 'left') {
|
|
217
|
+
return 'right';
|
|
218
|
+
} else if (dir === 'right') {
|
|
219
|
+
return 'left';
|
|
220
|
+
} else if (dir === 'top') {
|
|
221
|
+
return 'bottom';
|
|
222
|
+
} else if (dir === 'bottom') {
|
|
223
|
+
return 'top';
|
|
224
|
+
}
|
|
225
|
+
} // 设置 elem 相对 elem.ownerDocument 的坐标
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
function setLeftTop(elem, offset, option) {
|
|
229
|
+
// set position first, in-case top/left are set even on static elem
|
|
230
|
+
if (css(elem, 'position') === 'static') {
|
|
231
|
+
elem.style.position = 'relative';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var presetH = -999;
|
|
235
|
+
var presetV = -999;
|
|
236
|
+
var horizontalProperty = getOffsetDirection('left', option);
|
|
237
|
+
var verticalProperty = getOffsetDirection('top', option);
|
|
238
|
+
var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty);
|
|
239
|
+
var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty);
|
|
240
|
+
|
|
241
|
+
if (horizontalProperty !== 'left') {
|
|
242
|
+
presetH = 999;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (verticalProperty !== 'top') {
|
|
246
|
+
presetV = 999;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
var originalTransition = '';
|
|
250
|
+
var originalOffset = getOffset(elem);
|
|
251
|
+
|
|
252
|
+
if ('left' in offset || 'top' in offset) {
|
|
253
|
+
originalTransition = (0, _propertyUtils.getTransitionProperty)(elem) || '';
|
|
254
|
+
(0, _propertyUtils.setTransitionProperty)(elem, 'none');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if ('left' in offset) {
|
|
258
|
+
elem.style[oppositeHorizontalProperty] = '';
|
|
259
|
+
elem.style[horizontalProperty] = "".concat(presetH, "px");
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if ('top' in offset) {
|
|
263
|
+
elem.style[oppositeVerticalProperty] = '';
|
|
264
|
+
elem.style[verticalProperty] = "".concat(presetV, "px");
|
|
265
|
+
} // force relayout
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
forceRelayout(elem);
|
|
269
|
+
var old = getOffset(elem);
|
|
270
|
+
var originalStyle = {};
|
|
271
|
+
|
|
272
|
+
for (var key in offset) {
|
|
273
|
+
if (offset.hasOwnProperty(key)) {
|
|
274
|
+
var dir = getOffsetDirection(key, option);
|
|
275
|
+
var preset = key === 'left' ? presetH : presetV;
|
|
276
|
+
var off = originalOffset[key] - old[key];
|
|
277
|
+
|
|
278
|
+
if (dir === key) {
|
|
279
|
+
originalStyle[dir] = preset + off;
|
|
280
|
+
} else {
|
|
281
|
+
originalStyle[dir] = preset - off;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
css(elem, originalStyle); // force relayout
|
|
287
|
+
|
|
288
|
+
forceRelayout(elem);
|
|
289
|
+
|
|
290
|
+
if ('left' in offset || 'top' in offset) {
|
|
291
|
+
(0, _propertyUtils.setTransitionProperty)(elem, originalTransition);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
var ret = {};
|
|
295
|
+
|
|
296
|
+
for (var _key in offset) {
|
|
297
|
+
if (offset.hasOwnProperty(_key)) {
|
|
298
|
+
var _dir = getOffsetDirection(_key, option);
|
|
299
|
+
|
|
300
|
+
var _off = offset[_key] - originalOffset[_key];
|
|
301
|
+
|
|
302
|
+
if (_key === _dir) {
|
|
303
|
+
ret[_dir] = originalStyle[_dir] + _off;
|
|
304
|
+
} else {
|
|
305
|
+
ret[_dir] = originalStyle[_dir] - _off;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
css(elem, ret);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function setTransform(elem, offset) {
|
|
314
|
+
var originalOffset = getOffset(elem);
|
|
315
|
+
var originalXY = (0, _propertyUtils.getTransformXY)(elem);
|
|
316
|
+
var resultXY = {
|
|
317
|
+
x: originalXY.x,
|
|
318
|
+
y: originalXY.y
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
if ('left' in offset) {
|
|
322
|
+
resultXY.x = originalXY.x + offset.left - originalOffset.left;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if ('top' in offset) {
|
|
326
|
+
resultXY.y = originalXY.y + offset.top - originalOffset.top;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
(0, _propertyUtils.setTransformXY)(elem, resultXY);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function setOffset(elem, offset, option) {
|
|
333
|
+
if (option.ignoreShake) {
|
|
334
|
+
var oriOffset = getOffset(elem);
|
|
335
|
+
var oLeft = oriOffset.left.toFixed(0);
|
|
336
|
+
var oTop = oriOffset.top.toFixed(0);
|
|
337
|
+
var tLeft = offset.left.toFixed(0);
|
|
338
|
+
var tTop = offset.top.toFixed(0);
|
|
339
|
+
|
|
340
|
+
if (oLeft === tLeft && oTop === tTop) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (option.useCssRight || option.useCssBottom) {
|
|
346
|
+
setLeftTop(elem, offset, option);
|
|
347
|
+
} else if (option.useCssTransform && (0, _propertyUtils.getTransformName)() in document.body.style) {
|
|
348
|
+
setTransform(elem, offset, option);
|
|
349
|
+
} else {
|
|
350
|
+
setLeftTop(elem, offset, option);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function each(arr, fn) {
|
|
355
|
+
for (var i = 0; i < arr.length; i++) {
|
|
356
|
+
fn(arr[i]);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function isBorderBoxFn(elem) {
|
|
361
|
+
return getComputedStyleX(elem, 'boxSizing') === 'border-box';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
var BOX_MODELS = ['margin', 'border', 'padding'];
|
|
365
|
+
var CONTENT_INDEX = -1;
|
|
366
|
+
var PADDING_INDEX = 2;
|
|
367
|
+
var BORDER_INDEX = 1;
|
|
368
|
+
var MARGIN_INDEX = 0;
|
|
369
|
+
|
|
370
|
+
function swap(elem, options, callback) {
|
|
371
|
+
var old = {};
|
|
372
|
+
var style = elem.style;
|
|
373
|
+
var name; // Remember the old values, and insert the new ones
|
|
374
|
+
|
|
375
|
+
for (name in options) {
|
|
376
|
+
if (options.hasOwnProperty(name)) {
|
|
377
|
+
old[name] = style[name];
|
|
378
|
+
style[name] = options[name];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
callback.call(elem); // Revert the old values
|
|
383
|
+
|
|
384
|
+
for (name in options) {
|
|
385
|
+
if (options.hasOwnProperty(name)) {
|
|
386
|
+
style[name] = old[name];
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function getPBMWidth(elem, props, which) {
|
|
392
|
+
var value = 0;
|
|
393
|
+
var prop;
|
|
394
|
+
var j;
|
|
395
|
+
var i;
|
|
396
|
+
|
|
397
|
+
for (j = 0; j < props.length; j++) {
|
|
398
|
+
prop = props[j];
|
|
399
|
+
|
|
400
|
+
if (prop) {
|
|
401
|
+
for (i = 0; i < which.length; i++) {
|
|
402
|
+
var cssProp = void 0;
|
|
403
|
+
|
|
404
|
+
if (prop === 'border') {
|
|
405
|
+
cssProp = "".concat(prop).concat(which[i], "Width");
|
|
406
|
+
} else {
|
|
407
|
+
cssProp = prop + which[i];
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return value;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
var domUtils = {
|
|
419
|
+
getParent: function getParent(element) {
|
|
420
|
+
var parent = element;
|
|
421
|
+
|
|
422
|
+
do {
|
|
423
|
+
if (parent.nodeType === 11 && parent.host) {
|
|
424
|
+
parent = parent.host;
|
|
425
|
+
} else {
|
|
426
|
+
parent = parent.parentNode;
|
|
427
|
+
}
|
|
428
|
+
} while (parent && parent.nodeType !== 1 && parent.nodeType !== 9);
|
|
429
|
+
|
|
430
|
+
return parent;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
each(['Width', 'Height'], function (name) {
|
|
434
|
+
var _this2 = this;
|
|
435
|
+
|
|
436
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
437
|
+
|
|
438
|
+
domUtils["doc".concat(name)] = function (refWin) {
|
|
439
|
+
(0, _newArrowCheck2.default)(this, _this2);
|
|
440
|
+
var d = refWin.document;
|
|
441
|
+
return Math.max( // firefox chrome documentElement.scrollHeight< body.scrollHeight
|
|
442
|
+
// ie standard mode : documentElement.scrollHeight> body.scrollHeight
|
|
443
|
+
d.documentElement["scroll".concat(name)], // quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
|
|
444
|
+
d.body["scroll".concat(name)], domUtils["viewport".concat(name)](d));
|
|
445
|
+
}.bind(this);
|
|
446
|
+
|
|
447
|
+
domUtils["viewport".concat(name)] = function (win) {
|
|
448
|
+
(0, _newArrowCheck2.default)(this, _this2);
|
|
449
|
+
// pc browser includes scrollbar in window.innerWidth
|
|
450
|
+
var prop = "client".concat(name);
|
|
451
|
+
var doc = win.document;
|
|
452
|
+
var body = doc.body;
|
|
453
|
+
var documentElement = doc.documentElement;
|
|
454
|
+
var documentElementProp = documentElement[prop]; // 标准模式取 documentElement
|
|
455
|
+
// backcompat 取 body
|
|
456
|
+
|
|
457
|
+
return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
|
|
458
|
+
}.bind(this);
|
|
459
|
+
}.bind(void 0));
|
|
460
|
+
/*
|
|
461
|
+
得到元素的大小信息
|
|
462
|
+
@param elem
|
|
463
|
+
@param name
|
|
464
|
+
@param {String} [extra] 'padding' : (css width) + padding
|
|
465
|
+
'border' : (css width) + padding + border
|
|
466
|
+
'margin' : (css width) + padding + border + margin
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
function getWH(elem, name, ex) {
|
|
470
|
+
var extra = ex;
|
|
471
|
+
|
|
472
|
+
if (isWindow(elem)) {
|
|
473
|
+
return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
|
|
474
|
+
} else if (elem.nodeType === 9) {
|
|
475
|
+
return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
|
|
479
|
+
var borderBoxValue = name === 'width' ? Math.floor(elem.getBoundingClientRect().width) : Math.floor(elem.getBoundingClientRect().height);
|
|
480
|
+
var isBorderBox = isBorderBoxFn(elem);
|
|
481
|
+
var cssBoxValue = 0;
|
|
482
|
+
|
|
483
|
+
if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) {
|
|
484
|
+
borderBoxValue = undefined; // Fall back to computed then un computed css if necessary
|
|
485
|
+
|
|
486
|
+
cssBoxValue = getComputedStyleX(elem, name);
|
|
487
|
+
|
|
488
|
+
if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) {
|
|
489
|
+
cssBoxValue = elem.style[name] || 0;
|
|
490
|
+
} // Normalize '', auto, and prepare for extra
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
cssBoxValue = parseFloat(cssBoxValue) || 0;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (extra === undefined) {
|
|
497
|
+
extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
|
|
501
|
+
var val = borderBoxValue || cssBoxValue;
|
|
502
|
+
|
|
503
|
+
if (extra === CONTENT_INDEX) {
|
|
504
|
+
if (borderBoxValueOrIsBorderBox) {
|
|
505
|
+
return val - getPBMWidth(elem, ['border', 'padding'], which);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return cssBoxValue;
|
|
509
|
+
} else if (borderBoxValueOrIsBorderBox) {
|
|
510
|
+
if (extra === BORDER_INDEX) {
|
|
511
|
+
return val;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which) : getPBMWidth(elem, ['margin'], which));
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
var cssShow = {
|
|
521
|
+
position: 'absolute',
|
|
522
|
+
visibility: 'hidden',
|
|
523
|
+
display: 'block'
|
|
524
|
+
}; // fix #119 : https://github.com/kissyteam/kissy/issues/119
|
|
525
|
+
|
|
526
|
+
function getWHIgnoreDisplay() {
|
|
527
|
+
var _this3 = this;
|
|
528
|
+
|
|
529
|
+
for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
|
|
530
|
+
args[_key2] = arguments[_key2];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
var val;
|
|
534
|
+
var elem = args[0]; // in case elem is window
|
|
535
|
+
// elem.offsetWidth === undefined
|
|
536
|
+
|
|
537
|
+
if (elem.offsetWidth !== 0) {
|
|
538
|
+
val = getWH.apply(undefined, args);
|
|
539
|
+
} else {
|
|
540
|
+
swap(elem, cssShow, function () {
|
|
541
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
542
|
+
val = getWH.apply(undefined, args);
|
|
543
|
+
}.bind(this));
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return val;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
each(['width', 'height'], function (name) {
|
|
550
|
+
var _this4 = this;
|
|
551
|
+
|
|
552
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
553
|
+
var first = name.charAt(0).toUpperCase() + name.slice(1);
|
|
554
|
+
|
|
555
|
+
domUtils["outer".concat(first)] = function (el, includeMargin) {
|
|
556
|
+
(0, _newArrowCheck2.default)(this, _this4);
|
|
557
|
+
return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
|
|
558
|
+
}.bind(this);
|
|
559
|
+
|
|
560
|
+
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
|
|
561
|
+
|
|
562
|
+
domUtils[name] = function (elem, v) {
|
|
563
|
+
(0, _newArrowCheck2.default)(this, _this4);
|
|
564
|
+
var val = v;
|
|
565
|
+
|
|
566
|
+
if (val !== undefined) {
|
|
567
|
+
if (elem) {
|
|
568
|
+
var isBorderBox = isBorderBoxFn(elem);
|
|
569
|
+
|
|
570
|
+
if (isBorderBox) {
|
|
571
|
+
val += getPBMWidth(elem, ['padding', 'border'], which);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return css(elem, name, val);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return undefined;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
|
|
581
|
+
}.bind(this);
|
|
582
|
+
}.bind(void 0));
|
|
583
|
+
|
|
584
|
+
function mix(to, from) {
|
|
585
|
+
for (var i in from) {
|
|
586
|
+
if (from.hasOwnProperty(i)) {
|
|
587
|
+
to[i] = from[i];
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return to;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
var utils = {
|
|
595
|
+
getWindow: function getWindow(node) {
|
|
596
|
+
if (node && node.document && node.setTimeout) {
|
|
597
|
+
return node;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
var doc = node.ownerDocument || node;
|
|
601
|
+
return doc.defaultView || doc.parentWindow;
|
|
602
|
+
},
|
|
603
|
+
getDocument: getDocument,
|
|
604
|
+
offset: function offset(el, value, option) {
|
|
605
|
+
if (typeof value !== 'undefined') {
|
|
606
|
+
setOffset(el, value, option || {});
|
|
607
|
+
} else {
|
|
608
|
+
return getOffset(el);
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
isWindow: isWindow,
|
|
612
|
+
each: each,
|
|
613
|
+
css: css,
|
|
614
|
+
clone: function clone(obj) {
|
|
615
|
+
var i;
|
|
616
|
+
var ret = {};
|
|
617
|
+
|
|
618
|
+
for (i in obj) {
|
|
619
|
+
if (obj.hasOwnProperty(i)) {
|
|
620
|
+
ret[i] = obj[i];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
var overflow = obj.overflow;
|
|
625
|
+
|
|
626
|
+
if (overflow) {
|
|
627
|
+
for (i in obj) {
|
|
628
|
+
if (obj.hasOwnProperty(i)) {
|
|
629
|
+
ret.overflow[i] = obj.overflow[i];
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return ret;
|
|
635
|
+
},
|
|
636
|
+
mix: mix,
|
|
637
|
+
getWindowScrollLeft: function getWindowScrollLeft(w) {
|
|
638
|
+
return getScrollLeft(w);
|
|
639
|
+
},
|
|
640
|
+
getWindowScrollTop: function getWindowScrollTop(w) {
|
|
641
|
+
return getScrollTop(w);
|
|
642
|
+
},
|
|
643
|
+
merge: function merge() {
|
|
644
|
+
var ret = {};
|
|
645
|
+
|
|
646
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
647
|
+
utils.mix(ret, i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
return ret;
|
|
651
|
+
},
|
|
652
|
+
viewportWidth: 0,
|
|
653
|
+
viewportHeight: 0
|
|
654
|
+
};
|
|
655
|
+
mix(utils, domUtils);
|
|
656
|
+
var _default = utils;
|
|
657
|
+
exports.default = _default;
|
|
@@ -24,7 +24,10 @@ declare class Align extends React.Component<any, any, any> {
|
|
|
24
24
|
};
|
|
25
25
|
constructor(props: any);
|
|
26
26
|
constructor(props: any, context: any);
|
|
27
|
+
componentDidMount(): void;
|
|
28
|
+
componentDidUpdate(prevProps: any): void;
|
|
27
29
|
sourceRect: any;
|
|
30
|
+
componentWillUnmount(): void;
|
|
28
31
|
startMonitorWindowResize(): void;
|
|
29
32
|
bufferMonitor: {
|
|
30
33
|
(): void;
|
|
@@ -33,6 +36,7 @@ declare class Align extends React.Component<any, any, any> {
|
|
|
33
36
|
resizeHandler: any;
|
|
34
37
|
stopMonitorWindowResize(): void;
|
|
35
38
|
forceAlign: () => void;
|
|
39
|
+
render(): {} | null | undefined;
|
|
36
40
|
}
|
|
37
41
|
import React from "react";
|
|
38
42
|
import PropTypes from "prop-types";
|