@autobest-ui/components 2.3.0 → 2.5.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 +2 -2
- package/esm/index.js +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 +44 -7
- package/esm/message/index.js +96 -111
- 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 +2 -2
- package/lib/index.js +12 -32
- 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 +44 -7
- package/lib/message/index.js +97 -120
- 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
package/esm/carousel/index.js
CHANGED
|
@@ -9,36 +9,25 @@ var __extends = this && this.__extends || function () {
|
|
|
9
9
|
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
|
|
13
12
|
return _extendStatics(d, b);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
return function (d, b) {
|
|
17
15
|
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
|
-
|
|
19
16
|
_extendStatics(d, b);
|
|
20
|
-
|
|
21
17
|
function __() {
|
|
22
18
|
this.constructor = d;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
26
21
|
};
|
|
27
22
|
}();
|
|
28
|
-
|
|
29
23
|
import React from 'react';
|
|
30
24
|
import classNames from 'classnames';
|
|
31
25
|
import { isTouchScreen, addEventListener, throttleWithRAF, getElementSize } from '@autobest-ui/utils';
|
|
32
26
|
import Transition from './transition';
|
|
33
|
-
|
|
34
|
-
var Carousel =
|
|
35
|
-
/** @class */
|
|
36
|
-
function (_super) {
|
|
27
|
+
var Carousel = /** @class */function (_super) {
|
|
37
28
|
__extends(Carousel, _super);
|
|
38
|
-
|
|
39
29
|
function Carousel(props) {
|
|
40
30
|
var _this = _super.call(this, props) || this;
|
|
41
|
-
|
|
42
31
|
_this.prefixCls = 'ab-carousel';
|
|
43
32
|
_this.listRef = /*#__PURE__*/React.createRef();
|
|
44
33
|
_this.sliderWidth = 0;
|
|
@@ -50,84 +39,65 @@ function (_super) {
|
|
|
50
39
|
_this.endX = 0;
|
|
51
40
|
_this.autoplayTimer = null;
|
|
52
41
|
_this.fadeEffectTimer = null;
|
|
53
|
-
|
|
54
42
|
_this.next = function (transition) {
|
|
55
43
|
_this.interceptorChangePage(_this.state.currentPage + 1, transition);
|
|
56
44
|
};
|
|
57
|
-
|
|
58
45
|
_this.prev = function (transition) {
|
|
59
46
|
_this.interceptorChangePage(_this.state.currentPage - 1, transition);
|
|
60
47
|
};
|
|
61
|
-
|
|
62
48
|
_this.goTo = function (nextIndex, transition) {
|
|
63
49
|
_this.interceptorChangePage(nextIndex - 1, transition);
|
|
64
50
|
};
|
|
65
51
|
/**
|
|
66
52
|
* 获取滚动元素数量
|
|
67
53
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
54
|
_this.getChildCount = function () {
|
|
71
55
|
return React.Children.count(_this.props.children);
|
|
72
56
|
};
|
|
73
57
|
/**
|
|
74
58
|
* 获取滚动容器元素
|
|
75
59
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
60
|
_this.getListDomNode = function () {
|
|
79
61
|
if (_this.listRef && _this.listRef.current) {
|
|
80
62
|
return _this.listRef.current;
|
|
81
63
|
}
|
|
82
|
-
|
|
83
64
|
return null;
|
|
84
65
|
};
|
|
85
66
|
/**
|
|
86
67
|
* 初始化,设置各个元素大小,开启自动滚动
|
|
87
68
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
69
|
_this.init = function () {
|
|
91
70
|
var element = _this.getListDomNode();
|
|
92
|
-
|
|
93
71
|
if (!element) {
|
|
94
72
|
return;
|
|
95
73
|
}
|
|
96
|
-
|
|
97
74
|
var childCount = _this.getChildCount();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
75
|
+
_this.contentWidth = getElementSize(element.parentNode).width;
|
|
76
|
+
// 没有子元素或者获取不到宽度
|
|
101
77
|
if (!childCount || !_this.contentWidth) {
|
|
102
78
|
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
}
|
|
80
|
+
// 执行一次,控制样式,显示slider
|
|
106
81
|
if (!_this.state.initialized) {
|
|
107
82
|
_this.setState({
|
|
108
83
|
initialized: true
|
|
109
84
|
});
|
|
110
85
|
}
|
|
111
|
-
|
|
112
86
|
var currentPage = _this.state.currentPage;
|
|
113
87
|
var _a = _this.props,
|
|
114
|
-
|
|
115
|
-
|
|
88
|
+
slidesPerView = _a.slidesPerView,
|
|
89
|
+
height = _a.height;
|
|
116
90
|
_this.sliderWidth = _this.contentWidth / slidesPerView;
|
|
117
91
|
element.style.width = "".concat(_this.sliderWidth * childCount, "px");
|
|
118
|
-
|
|
119
92
|
if (height) {
|
|
120
93
|
element.style.height = height;
|
|
121
94
|
}
|
|
122
|
-
|
|
123
95
|
var childList = Array.from(element.children);
|
|
124
96
|
childList.forEach(function (child) {
|
|
125
97
|
child.style.width = "".concat(_this.sliderWidth, "px");
|
|
126
98
|
});
|
|
127
99
|
_this.prevX = -currentPage * _this.sliderWidth;
|
|
128
|
-
|
|
129
100
|
_this.setListStyles(element, _this.prevX);
|
|
130
|
-
|
|
131
101
|
_this.onAutoplay();
|
|
132
102
|
};
|
|
133
103
|
/**
|
|
@@ -135,40 +105,28 @@ function (_super) {
|
|
|
135
105
|
* @param nextPage
|
|
136
106
|
* @param transition
|
|
137
107
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
108
|
_this.interceptorChangePage = function (nextPage, transition) {
|
|
141
109
|
// 停止autoplay
|
|
142
110
|
clearTimeout(_this.autoplayTimer);
|
|
143
|
-
|
|
144
111
|
var element = _this.getListDomNode();
|
|
145
|
-
|
|
146
112
|
if (element) {
|
|
147
113
|
var slidesPerView = _this.props.slidesPerView;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
114
|
+
var childCount = _this.getChildCount();
|
|
115
|
+
// 内容未超出容器范围, 将恢复原样
|
|
152
116
|
if (slidesPerView >= childCount) {
|
|
153
117
|
_this.setListStyles(element, 0, transition);
|
|
154
|
-
|
|
155
118
|
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
119
|
+
}
|
|
120
|
+
// 已滑动到最左边
|
|
159
121
|
if (nextPage < 0) {
|
|
160
122
|
nextPage = childCount - slidesPerView;
|
|
161
123
|
} else if (nextPage > childCount - slidesPerView) {
|
|
162
124
|
// 已滑动到最右边
|
|
163
125
|
nextPage = 0;
|
|
164
126
|
}
|
|
165
|
-
|
|
166
127
|
_this.prevX = -nextPage * _this.sliderWidth;
|
|
167
|
-
|
|
168
128
|
_this.onBeforeChange(nextPage);
|
|
169
|
-
|
|
170
129
|
_this.setListStyles(element, _this.prevX, transition);
|
|
171
|
-
|
|
172
130
|
_this.setState({
|
|
173
131
|
currentPage: nextPage
|
|
174
132
|
}, function () {
|
|
@@ -183,11 +141,9 @@ function (_super) {
|
|
|
183
141
|
* @param translateX
|
|
184
142
|
* @param transition
|
|
185
143
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
144
|
_this.setListStyles = function (element, translateX, transition) {
|
|
189
|
-
element.style.transition = '';
|
|
190
|
-
|
|
145
|
+
element.style.transition = '';
|
|
146
|
+
// 当开启渐变时,直接执行渐变,将没有位置偏移动画
|
|
191
147
|
if (_this.props.fadeEffect) {
|
|
192
148
|
clearTimeout(_this.fadeEffectTimer);
|
|
193
149
|
element.style.visibility = 'none';
|
|
@@ -200,27 +156,22 @@ function (_super) {
|
|
|
200
156
|
} else {
|
|
201
157
|
element.style.transition = transition || Transition.TransformEaseInOut;
|
|
202
158
|
}
|
|
203
|
-
|
|
204
159
|
element.style.transform = "translateX(".concat(translateX, "px)");
|
|
205
160
|
};
|
|
206
|
-
|
|
207
161
|
_this.onBeforeChange = function (currentPage) {
|
|
208
162
|
if (typeof _this.props.onBeforeChange === 'function') {
|
|
209
163
|
_this.props.onBeforeChange(currentPage + 1);
|
|
210
164
|
}
|
|
211
165
|
};
|
|
212
|
-
|
|
213
166
|
_this.onAfterChange = function () {
|
|
214
167
|
if (typeof _this.props.onAfterChange === 'function') {
|
|
215
168
|
_this.props.onAfterChange(_this.state.currentPage + 1);
|
|
216
169
|
}
|
|
217
170
|
};
|
|
218
|
-
|
|
219
171
|
_this.onClick = function () {
|
|
220
172
|
if (isTouchScreen()) {
|
|
221
173
|
return;
|
|
222
174
|
}
|
|
223
|
-
|
|
224
175
|
if (_this.props.onClick) {
|
|
225
176
|
_this.props.onClick(_this.state.currentPage + 1);
|
|
226
177
|
}
|
|
@@ -229,178 +180,139 @@ function (_super) {
|
|
|
229
180
|
* 触摸屏触发滑动,缓存触发位置
|
|
230
181
|
* @param event
|
|
231
182
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
183
|
_this.onTouchStart = function (event) {
|
|
235
184
|
if (!_this.props.controllable || _this.props.fadeEffect) {
|
|
236
185
|
return;
|
|
237
186
|
}
|
|
238
|
-
|
|
239
187
|
event.preventDefault();
|
|
240
188
|
clearTimeout(_this.autoplayTimer);
|
|
241
189
|
_this.endX = 0;
|
|
242
190
|
_this.startX = event.touches ? event.touches[0].pageX : event.clientX;
|
|
243
|
-
|
|
244
191
|
var element = _this.getListDomNode();
|
|
245
|
-
|
|
246
192
|
if (!element) {
|
|
247
193
|
return;
|
|
248
194
|
}
|
|
249
|
-
|
|
250
195
|
element.style.transition = 'none';
|
|
251
196
|
};
|
|
252
197
|
/**
|
|
253
198
|
* 触摸屏触发滑动,计算移动位置,并设置元素偏移
|
|
254
199
|
* @param event
|
|
255
200
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
201
|
_this.onTouchMove = function (event) {
|
|
259
202
|
if (!_this.props.controllable || _this.props.fadeEffect) {
|
|
260
203
|
return;
|
|
261
204
|
}
|
|
262
|
-
|
|
263
205
|
event.preventDefault();
|
|
264
206
|
_this.endX = event.touches ? event.touches[0].pageX : event.clientX;
|
|
265
207
|
_this.moveX = _this.prevX + _this.endX - _this.startX;
|
|
266
208
|
_this.isDirectionLeft = _this.prevX - _this.startX <= _this.prevX - _this.endX;
|
|
267
|
-
|
|
268
209
|
var element = _this.getListDomNode();
|
|
269
|
-
|
|
270
210
|
if (!element) {
|
|
271
211
|
return;
|
|
272
212
|
}
|
|
273
|
-
|
|
274
213
|
element.style.transform = "translateX(".concat(_this.moveX, "px)");
|
|
275
214
|
};
|
|
276
215
|
/**
|
|
277
216
|
* 停止滑动,判断用户移动位置,确定用户最终滑动位置
|
|
278
217
|
* @param event
|
|
279
218
|
*/
|
|
280
|
-
|
|
281
|
-
|
|
282
219
|
_this.onTouchEnd = function (event) {
|
|
283
220
|
var _a = _this.props,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
221
|
+
onClick = _a.onClick,
|
|
222
|
+
controllable = _a.controllable,
|
|
223
|
+
fadeEffect = _a.fadeEffect,
|
|
224
|
+
sensitivity = _a.sensitivity,
|
|
225
|
+
slidesPerView = _a.slidesPerView;
|
|
290
226
|
if (!controllable || fadeEffect) {
|
|
291
227
|
if (onClick) {
|
|
292
228
|
onClick(_this.state.currentPage + 1);
|
|
293
229
|
}
|
|
294
|
-
|
|
295
230
|
return;
|
|
296
231
|
}
|
|
297
|
-
|
|
298
232
|
var currentPage = _this.state.currentPage;
|
|
299
|
-
var transition = Transition.TransformEaseOut;
|
|
300
|
-
|
|
301
|
-
var translateX = Math.abs(_this.startX - _this.endX);
|
|
302
|
-
|
|
233
|
+
var transition = Transition.TransformEaseOut;
|
|
234
|
+
// 移动的偏移量
|
|
235
|
+
var translateX = Math.abs(_this.startX - _this.endX);
|
|
236
|
+
// 判断用户未产生滑动,认为是点击
|
|
303
237
|
if (_this.endX === 0 || translateX < sensitivity) {
|
|
304
238
|
if (onClick) {
|
|
305
239
|
onClick(_this.state.currentPage + 1);
|
|
306
240
|
}
|
|
307
|
-
|
|
308
241
|
_this.interceptorChangePage(currentPage, transition);
|
|
309
|
-
|
|
310
242
|
return;
|
|
311
243
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
// 移出左边临界点
|
|
315
246
|
if (_this.moveX >= 0) {
|
|
316
247
|
_this.interceptorChangePage(0, transition);
|
|
317
|
-
|
|
318
248
|
return;
|
|
319
249
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
250
|
+
var childCount = _this.getChildCount();
|
|
251
|
+
// 移出右边临界点
|
|
324
252
|
var listWidth = _this.sliderWidth * childCount;
|
|
325
253
|
var moveX = Math.abs(_this.moveX);
|
|
326
|
-
|
|
327
254
|
if (moveX >= listWidth - _this.contentWidth) {
|
|
328
255
|
_this.interceptorChangePage(childCount - slidesPerView, transition);
|
|
329
|
-
|
|
330
256
|
return;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
257
|
+
}
|
|
258
|
+
// 未达到一页,判断是否超出sensitivity, 超出将加1
|
|
259
|
+
var skipOne = translateX % _this.sliderWidth >= _this.props.sensitivity ? 1 : 0;
|
|
260
|
+
// 滑动的完整页数
|
|
261
|
+
var skipCount = Math.floor(translateX / _this.sliderWidth);
|
|
262
|
+
// 判断是否向左滑动
|
|
338
263
|
if (_this.isDirectionLeft) {
|
|
339
264
|
currentPage = currentPage + skipCount + skipOne;
|
|
340
265
|
} else {
|
|
341
266
|
currentPage -= skipCount + skipOne;
|
|
342
267
|
}
|
|
343
|
-
|
|
344
268
|
_this.interceptorChangePage(currentPage, transition);
|
|
345
269
|
};
|
|
346
|
-
|
|
347
270
|
_this.state = {
|
|
348
271
|
currentPage: props.defaultValue - 1,
|
|
349
272
|
initialized: false
|
|
350
273
|
};
|
|
351
274
|
return _this;
|
|
352
275
|
}
|
|
353
|
-
|
|
354
276
|
Carousel.prototype.componentDidMount = function () {
|
|
355
|
-
var _this = this;
|
|
356
|
-
|
|
357
|
-
|
|
277
|
+
var _this = this;
|
|
278
|
+
// 先执行一遍,解决异步观察延迟问题
|
|
358
279
|
this.init();
|
|
359
280
|
var element = this.getListDomNode();
|
|
360
|
-
|
|
361
281
|
if (element) {
|
|
362
282
|
// 开启异步观察目标元素
|
|
363
283
|
this.intersectionObserver = new IntersectionObserver(function (entries) {
|
|
364
|
-
var item = entries[0];
|
|
365
|
-
|
|
284
|
+
var item = entries[0];
|
|
285
|
+
// 未显示
|
|
366
286
|
if (item.intersectionRatio <= 0 || !item.isIntersecting) {
|
|
367
287
|
clearTimeout(_this.autoplayTimer);
|
|
368
288
|
return;
|
|
369
289
|
}
|
|
370
|
-
|
|
371
290
|
_this.init();
|
|
372
|
-
});
|
|
373
|
-
|
|
291
|
+
});
|
|
292
|
+
// 开启 observing
|
|
374
293
|
this.intersectionObserver.observe(element);
|
|
375
294
|
}
|
|
376
295
|
};
|
|
377
|
-
|
|
378
296
|
Carousel.prototype.componentDidUpdate = function (prevProps) {
|
|
379
297
|
var _this = this;
|
|
380
|
-
|
|
381
298
|
var children = this.props.children;
|
|
382
|
-
|
|
383
299
|
if (React.Children.count(children) !== React.Children.count(prevProps.children)) {
|
|
384
300
|
this.init();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
301
|
+
}
|
|
302
|
+
// 加入 resize 监听
|
|
388
303
|
if (this.props.monitorWindowResize && !this.resizeHandler) {
|
|
389
304
|
this.resizeHandler = addEventListener(window, 'resize', throttleWithRAF(function () {
|
|
390
305
|
return _this.init();
|
|
391
306
|
}));
|
|
392
307
|
}
|
|
393
308
|
};
|
|
394
|
-
|
|
395
309
|
Carousel.prototype.componentWillUnmount = function () {
|
|
396
310
|
clearTimeout(this.autoplayTimer);
|
|
397
311
|
clearTimeout(this.fadeEffectTimer);
|
|
398
|
-
|
|
399
312
|
if (this.resizeHandler) {
|
|
400
313
|
this.resizeHandler.remove();
|
|
401
314
|
this.resizeHandler = null;
|
|
402
315
|
}
|
|
403
|
-
|
|
404
316
|
if (this.intersectionObserver) {
|
|
405
317
|
this.intersectionObserver.disconnect();
|
|
406
318
|
}
|
|
@@ -408,29 +320,23 @@ function (_super) {
|
|
|
408
320
|
/**
|
|
409
321
|
* 开启自动偏移或者渐变,当元素少于2时,将不会开启
|
|
410
322
|
*/
|
|
411
|
-
|
|
412
|
-
|
|
413
323
|
Carousel.prototype.onAutoplay = function () {
|
|
414
324
|
var _this = this;
|
|
415
|
-
|
|
416
325
|
if (!this.props.autoplay || this.getChildCount() <= 1) {
|
|
417
326
|
return;
|
|
418
327
|
}
|
|
419
|
-
|
|
420
328
|
clearTimeout(this.autoplayTimer);
|
|
421
329
|
this.autoplayTimer = setTimeout(function () {
|
|
422
330
|
_this.interceptorChangePage(_this.state.currentPage + 1);
|
|
423
331
|
}, this.props.delay);
|
|
424
332
|
};
|
|
425
|
-
|
|
426
333
|
Carousel.prototype.render = function () {
|
|
427
334
|
var _a;
|
|
428
|
-
|
|
429
335
|
var cls = this.prefixCls;
|
|
430
336
|
var _b = this.props,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
337
|
+
className = _b.className,
|
|
338
|
+
children = _b.children,
|
|
339
|
+
pagination = _b.pagination;
|
|
434
340
|
return /*#__PURE__*/React.createElement("div", {
|
|
435
341
|
className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-init")] = this.state.initialized, _a))
|
|
436
342
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -449,9 +355,8 @@ function (_super) {
|
|
|
449
355
|
className: "".concat(cls, "-slider")
|
|
450
356
|
}, child);
|
|
451
357
|
}))), typeof pagination === 'function' ? pagination(this) : pagination);
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
|
|
358
|
+
};
|
|
359
|
+
// 默认值
|
|
455
360
|
Carousel.defaultProps = {
|
|
456
361
|
slidesPerView: 1,
|
|
457
362
|
defaultValue: 1,
|
|
@@ -465,5 +370,4 @@ function (_super) {
|
|
|
465
370
|
};
|
|
466
371
|
return Carousel;
|
|
467
372
|
}(React.Component);
|
|
468
|
-
|
|
469
373
|
export default Carousel;
|
package/esm/checkbox/index.js
CHANGED
|
@@ -9,63 +9,46 @@ var __extends = this && this.__extends || function () {
|
|
|
9
9
|
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
|
|
13
12
|
return _extendStatics(d, b);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
return function (d, b) {
|
|
17
15
|
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
|
-
|
|
19
16
|
_extendStatics(d, b);
|
|
20
|
-
|
|
21
17
|
function __() {
|
|
22
18
|
this.constructor = d;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
26
21
|
};
|
|
27
22
|
}();
|
|
28
|
-
|
|
29
23
|
import React from 'react';
|
|
30
24
|
import classNames from 'classnames';
|
|
31
25
|
var cls = 'ab-checkbox';
|
|
32
|
-
|
|
33
|
-
var Checkbox =
|
|
34
|
-
/** @class */
|
|
35
|
-
function (_super) {
|
|
26
|
+
var Checkbox = /** @class */function (_super) {
|
|
36
27
|
__extends(Checkbox, _super);
|
|
37
|
-
|
|
38
28
|
function Checkbox(props) {
|
|
39
29
|
var _this = _super.call(this, props) || this;
|
|
40
|
-
|
|
41
30
|
_this.onVisibleChange = function () {
|
|
42
31
|
var _a = _this.props,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
disabled = _a.disabled,
|
|
33
|
+
onChange = _a.onChange,
|
|
34
|
+
name = _a.name;
|
|
47
35
|
if (disabled) {
|
|
48
36
|
return;
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
var visible = !_this.state.visible;
|
|
52
|
-
|
|
53
39
|
if (!('checked' in _this.props)) {
|
|
54
40
|
_this.setState({
|
|
55
41
|
visible: visible
|
|
56
42
|
});
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
onChange(visible, name);
|
|
60
45
|
};
|
|
61
|
-
|
|
62
46
|
_this.renderBox = function () {
|
|
63
47
|
var _a;
|
|
64
|
-
|
|
65
48
|
var _b = _this.props,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
className = _b.className,
|
|
50
|
+
disabled = _b.disabled,
|
|
51
|
+
size = _b.size;
|
|
69
52
|
var visible = _this.state.visible;
|
|
70
53
|
var innerStyle = {
|
|
71
54
|
width: "".concat(size, "px"),
|
|
@@ -89,13 +72,11 @@ function (_super) {
|
|
|
89
72
|
style: iconStyle
|
|
90
73
|
})));
|
|
91
74
|
};
|
|
92
|
-
|
|
93
75
|
_this.state = {
|
|
94
76
|
visible: props.checked || props.defaultChecked
|
|
95
77
|
};
|
|
96
78
|
return _this;
|
|
97
79
|
}
|
|
98
|
-
|
|
99
80
|
Checkbox.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
100
81
|
// 如果父级传了 checked 则更新 state
|
|
101
82
|
if ('checked' in nextProps && nextProps.checked !== prevState.visible) {
|
|
@@ -103,30 +84,25 @@ function (_super) {
|
|
|
103
84
|
visible: nextProps.checked
|
|
104
85
|
};
|
|
105
86
|
}
|
|
106
|
-
|
|
107
87
|
return null;
|
|
108
88
|
};
|
|
109
|
-
|
|
110
89
|
Checkbox.prototype.render = function () {
|
|
111
90
|
var _a;
|
|
112
|
-
|
|
113
91
|
var _b = this.props,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
92
|
+
className = _b.className,
|
|
93
|
+
disabled = _b.disabled,
|
|
94
|
+
children = _b.children,
|
|
95
|
+
reverse = _b.reverse;
|
|
96
|
+
// 只渲染复选框
|
|
119
97
|
if (!children) {
|
|
120
98
|
return this.renderBox();
|
|
121
99
|
}
|
|
122
|
-
|
|
123
100
|
return /*#__PURE__*/React.createElement("label", {
|
|
124
101
|
className: classNames("".concat(cls, "-wrap"), className, (_a = {}, _a["".concat(cls, "-reverse")] = reverse, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
125
102
|
}, this.renderBox(), children ? /*#__PURE__*/React.createElement("span", {
|
|
126
103
|
className: "".concat(cls, "-content")
|
|
127
104
|
}, children) : null);
|
|
128
105
|
};
|
|
129
|
-
|
|
130
106
|
Checkbox.defaultProps = {
|
|
131
107
|
size: 16,
|
|
132
108
|
disabled: false,
|
|
@@ -135,5 +111,4 @@ function (_super) {
|
|
|
135
111
|
};
|
|
136
112
|
return Checkbox;
|
|
137
113
|
}(React.Component);
|
|
138
|
-
|
|
139
114
|
export default Checkbox;
|