@autobest-ui/components 1.2.1 → 1.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/carousel/index.d.ts +13 -21
- package/esm/carousel/index.js +44 -77
- package/esm/carousel/style/index.css +1 -1
- package/esm/carousel/style/index.scss +1 -7
- package/esm/date-picker/calendar/grid/index.css +1 -1
- package/esm/date-picker/calendar/grid/index.js +17 -27
- package/esm/date-picker/calendar/grid/index.scss +4 -0
- package/esm/date-picker/calendar/index.d.ts +4 -0
- package/esm/date-picker/calendar/index.js +1 -1
- package/esm/date-picker/index.d.ts +17 -6
- package/esm/date-picker/index.js +62 -17
- package/esm/date-picker/style/index.css +1 -1
- package/esm/date-picker/style/index.js +0 -2
- package/esm/date-picker/style/index.scss +6 -1
- package/esm/guide/index.d.ts +4 -5
- package/esm/guide/index.js +4 -6
- package/esm/index.d.ts +3 -5
- package/esm/index.js +1 -3
- package/esm/input-number/index.d.ts +30 -17
- package/esm/input-number/index.js +116 -36
- package/esm/loading/index.d.ts +7 -2
- package/esm/loading/index.js +18 -24
- package/esm/loading/style/index.css +1 -1
- package/esm/loading/style/index.scss +0 -10
- package/esm/style.css +7 -23
- package/esm/table/body/BodyRow.d.ts +9 -3
- package/esm/table/body/BodyRow.js +6 -2
- package/esm/table/body/index.d.ts +2 -2
- package/esm/table/body/index.js +8 -7
- package/esm/table/header/HeaderCell.d.ts +2 -2
- package/esm/table/header/HeaderCell.js +15 -7
- package/esm/table/header/HeaderRow.d.ts +2 -2
- package/esm/table/index.d.ts +4 -4
- package/esm/table/index.js +3 -3
- package/esm/table/interface.d.ts +9 -3
- package/esm/table/style/index.css +1 -1
- package/esm/table/style/index.js +0 -2
- package/esm/table/style/index.scss +2 -0
- package/lib/carousel/index.d.ts +13 -21
- package/lib/carousel/index.js +45 -80
- package/lib/carousel/style/index.css +1 -1
- package/lib/carousel/style/index.scss +1 -7
- package/lib/date-picker/calendar/grid/index.css +1 -1
- package/lib/date-picker/calendar/grid/index.js +17 -28
- package/lib/date-picker/calendar/grid/index.scss +4 -0
- package/lib/date-picker/calendar/index.d.ts +4 -0
- package/lib/date-picker/calendar/index.js +1 -1
- package/lib/date-picker/index.d.ts +17 -6
- package/lib/date-picker/index.js +61 -17
- package/lib/date-picker/style/index.css +1 -1
- package/lib/date-picker/style/index.js +0 -2
- package/lib/date-picker/style/index.scss +6 -1
- package/lib/guide/index.d.ts +4 -5
- package/lib/guide/index.js +4 -7
- package/lib/index.d.ts +3 -5
- package/lib/index.js +2 -30
- package/lib/input-number/index.d.ts +30 -17
- package/lib/input-number/index.js +116 -36
- package/lib/loading/index.d.ts +7 -2
- package/lib/loading/index.js +18 -25
- package/lib/loading/style/index.css +1 -1
- package/lib/loading/style/index.scss +0 -10
- package/lib/style.css +7 -23
- package/lib/table/body/BodyRow.d.ts +9 -3
- package/lib/table/body/BodyRow.js +6 -2
- package/lib/table/body/index.d.ts +2 -2
- package/lib/table/body/index.js +8 -7
- package/lib/table/header/HeaderCell.d.ts +2 -2
- package/lib/table/header/HeaderCell.js +15 -8
- package/lib/table/header/HeaderRow.d.ts +2 -2
- package/lib/table/index.d.ts +4 -4
- package/lib/table/index.js +3 -3
- package/lib/table/interface.d.ts +9 -3
- package/lib/table/style/index.css +1 -1
- package/lib/table/style/index.js +0 -2
- package/lib/table/style/index.scss +2 -0
- package/package.json +2 -2
- package/esm/accordion/__stories__/style.css +0 -1
- package/esm/accordion/__stories__/style.scss +0 -59
- package/esm/affix/__stories__/style.css +0 -1
- package/esm/affix/__stories__/style.scss +0 -13
- package/esm/carousel/__stories__/style.css +0 -1
- package/esm/carousel/__stories__/style.scss +0 -41
- package/esm/collapse/__stories__/style.css +0 -1
- package/esm/collapse/__stories__/style.scss +0 -19
- package/esm/guide/__stories__/style.css +0 -1
- package/esm/guide/__stories__/style.scss +0 -14
- package/esm/icon/__stories__/iconNames.d.ts +0 -2
- package/esm/icon/__stories__/iconNames.js +0 -1
- package/esm/icon/__stories__/style.css +0 -1
- package/esm/icon/__stories__/style.scss +0 -40
- package/esm/icon/index.d.ts +0 -43
- package/esm/icon/index.js +0 -94
- package/esm/icon/style/index.css +0 -1
- package/esm/icon/style/index.d.ts +0 -1
- package/esm/icon/style/index.js +0 -5
- package/esm/icon/style/index.scss +0 -7
- package/esm/lazy-image/__stories__/style.css +0 -1
- package/esm/lazy-image/__stories__/style.scss +0 -9
- package/esm/loading-container/__stories__/style.css +0 -1
- package/esm/loading-container/__stories__/style.scss +0 -6
- package/esm/move/__stories__/style.css +0 -1
- package/esm/move/__stories__/style.scss +0 -6
- package/esm/popover/__stories__/style.css +0 -1
- package/esm/popover/__stories__/style.scss +0 -16
- package/esm/select/__stories__/style.css +0 -1
- package/esm/select/__stories__/style.scss +0 -8
- package/esm/skeleton/__stories__/style.css +0 -1
- package/esm/skeleton/__stories__/style.scss +0 -3
- package/esm/table/__stories__/style.css +0 -1
- package/esm/table/__stories__/style.scss +0 -34
- package/esm/tabs/__stories__/style.css +0 -1
- package/esm/tabs/__stories__/style.scss +0 -8
- package/esm/use-config/index.d.ts +0 -5
- package/esm/use-config/index.js +0 -13
- package/esm/use-config/style/index.css +0 -0
- package/esm/use-config/style/index.d.ts +0 -1
- package/esm/use-config/style/index.js +0 -1
- package/esm/use-config/style/index.scss +0 -0
- package/lib/accordion/__stories__/style.css +0 -1
- package/lib/accordion/__stories__/style.scss +0 -59
- package/lib/affix/__stories__/style.css +0 -1
- package/lib/affix/__stories__/style.scss +0 -13
- package/lib/carousel/__stories__/style.css +0 -1
- package/lib/carousel/__stories__/style.scss +0 -41
- package/lib/collapse/__stories__/style.css +0 -1
- package/lib/collapse/__stories__/style.scss +0 -19
- package/lib/guide/__stories__/style.css +0 -1
- package/lib/guide/__stories__/style.scss +0 -14
- package/lib/icon/__stories__/iconNames.d.ts +0 -2
- package/lib/icon/__stories__/iconNames.js +0 -8
- package/lib/icon/__stories__/style.css +0 -1
- package/lib/icon/__stories__/style.scss +0 -40
- package/lib/icon/index.d.ts +0 -43
- package/lib/icon/index.js +0 -111
- package/lib/icon/style/index.css +0 -1
- package/lib/icon/style/index.d.ts +0 -1
- package/lib/icon/style/index.js +0 -7
- package/lib/icon/style/index.scss +0 -7
- package/lib/lazy-image/__stories__/style.css +0 -1
- package/lib/lazy-image/__stories__/style.scss +0 -9
- package/lib/loading-container/__stories__/style.css +0 -1
- package/lib/loading-container/__stories__/style.scss +0 -6
- package/lib/move/__stories__/style.css +0 -1
- package/lib/move/__stories__/style.scss +0 -6
- package/lib/popover/__stories__/style.css +0 -1
- package/lib/popover/__stories__/style.scss +0 -16
- package/lib/select/__stories__/style.css +0 -1
- package/lib/select/__stories__/style.scss +0 -8
- package/lib/skeleton/__stories__/style.css +0 -1
- package/lib/skeleton/__stories__/style.scss +0 -3
- package/lib/table/__stories__/style.css +0 -1
- package/lib/table/__stories__/style.scss +0 -34
- package/lib/tabs/__stories__/style.css +0 -1
- package/lib/tabs/__stories__/style.scss +0 -8
- package/lib/use-config/index.d.ts +0 -5
- package/lib/use-config/index.js +0 -21
- package/lib/use-config/style/index.css +0 -0
- package/lib/use-config/style/index.d.ts +0 -1
- package/lib/use-config/style/index.js +0 -1
- package/lib/use-config/style/index.scss +0 -0
package/lib/carousel/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
@@ -41,14 +41,6 @@ var __extends = void 0 && (void 0).__extends || function () {
|
|
|
41
41
|
};
|
|
42
42
|
}();
|
|
43
43
|
|
|
44
|
-
var CarouselDirection;
|
|
45
|
-
exports.CarouselDirection = CarouselDirection;
|
|
46
|
-
|
|
47
|
-
(function (CarouselDirection) {
|
|
48
|
-
CarouselDirection["vertical"] = "vertical";
|
|
49
|
-
CarouselDirection["horizontal"] = "horizontal";
|
|
50
|
-
})(CarouselDirection || (exports.CarouselDirection = CarouselDirection = {}));
|
|
51
|
-
|
|
52
44
|
var Carousel =
|
|
53
45
|
/** @class */
|
|
54
46
|
function (_super) {
|
|
@@ -58,15 +50,14 @@ function (_super) {
|
|
|
58
50
|
var _this = _super.call(this, props) || this;
|
|
59
51
|
|
|
60
52
|
_this.prefixCls = 'ab-carousel';
|
|
61
|
-
_this.listRef = _react.default.createRef();
|
|
62
|
-
|
|
63
|
-
_this.
|
|
64
|
-
_this.
|
|
65
|
-
_this.
|
|
66
|
-
_this.
|
|
67
|
-
_this.
|
|
68
|
-
_this.
|
|
69
|
-
_this.endSize = 0;
|
|
53
|
+
_this.listRef = _react.default.createRef();
|
|
54
|
+
_this.sliderWidth = 0;
|
|
55
|
+
_this.contentWidth = 0;
|
|
56
|
+
_this.isDirectionLeft = true;
|
|
57
|
+
_this.startX = 0;
|
|
58
|
+
_this.prevX = 0;
|
|
59
|
+
_this.moveX = 0;
|
|
60
|
+
_this.endX = 0;
|
|
70
61
|
_this.autoplayTimer = null;
|
|
71
62
|
_this.fadeEffectTimer = null;
|
|
72
63
|
|
|
@@ -81,20 +72,6 @@ function (_super) {
|
|
|
81
72
|
_this.goTo = function (nextIndex, transition) {
|
|
82
73
|
_this.interceptorChangePage(nextIndex - 1, transition);
|
|
83
74
|
};
|
|
84
|
-
|
|
85
|
-
_this.isHorizontalDirection = function () {
|
|
86
|
-
return _this.props.direction === CarouselDirection.horizontal;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
_this.setElementSizeByDirection = function (element, value) {
|
|
90
|
-
var isHr = _this.isHorizontalDirection();
|
|
91
|
-
|
|
92
|
-
if (isHr) {
|
|
93
|
-
element.style.width = value;
|
|
94
|
-
} else {
|
|
95
|
-
element.style.height = value;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
75
|
/**
|
|
99
76
|
* 获取滚动元素数量
|
|
100
77
|
*/
|
|
@@ -127,14 +104,11 @@ function (_super) {
|
|
|
127
104
|
return;
|
|
128
105
|
}
|
|
129
106
|
|
|
130
|
-
var isHr = _this.isHorizontalDirection();
|
|
131
|
-
|
|
132
107
|
var childCount = _this.getChildCount();
|
|
133
108
|
|
|
134
|
-
|
|
135
|
-
_this.contentSize = isHr ? parentNodeOffset.width : parentNodeOffset.height; // 没有子元素或者获取不到宽度
|
|
109
|
+
_this.contentWidth = (0, _utils.getElementSize)(element.parentNode).width; // 没有子元素或者获取不到宽度
|
|
136
110
|
|
|
137
|
-
if (!childCount || !_this.
|
|
111
|
+
if (!childCount || !_this.contentWidth) {
|
|
138
112
|
return;
|
|
139
113
|
} // 执行一次,控制样式,显示slider
|
|
140
114
|
|
|
@@ -146,18 +120,23 @@ function (_super) {
|
|
|
146
120
|
}
|
|
147
121
|
|
|
148
122
|
var currentPage = _this.state.currentPage;
|
|
149
|
-
var
|
|
150
|
-
|
|
123
|
+
var _a = _this.props,
|
|
124
|
+
slidesPerView = _a.slidesPerView,
|
|
125
|
+
height = _a.height;
|
|
126
|
+
_this.sliderWidth = _this.contentWidth / slidesPerView;
|
|
127
|
+
element.style.width = _this.sliderWidth * childCount + "px";
|
|
151
128
|
|
|
152
|
-
|
|
129
|
+
if (height) {
|
|
130
|
+
element.style.height = height;
|
|
131
|
+
}
|
|
153
132
|
|
|
154
133
|
var childList = Array.from(element.children);
|
|
155
134
|
childList.forEach(function (child) {
|
|
156
|
-
|
|
135
|
+
child.style.width = _this.sliderWidth + "px";
|
|
157
136
|
});
|
|
158
|
-
_this.
|
|
137
|
+
_this.prevX = -currentPage * _this.sliderWidth;
|
|
159
138
|
|
|
160
|
-
_this.setListStyles(element, _this.
|
|
139
|
+
_this.setListStyles(element, _this.prevX);
|
|
161
140
|
|
|
162
141
|
_this.onAutoplay();
|
|
163
142
|
};
|
|
@@ -194,11 +173,11 @@ function (_super) {
|
|
|
194
173
|
nextPage = 0;
|
|
195
174
|
}
|
|
196
175
|
|
|
197
|
-
_this.
|
|
176
|
+
_this.prevX = -nextPage * _this.sliderWidth;
|
|
198
177
|
|
|
199
178
|
_this.onBeforeChange(nextPage);
|
|
200
179
|
|
|
201
|
-
_this.setListStyles(element, _this.
|
|
180
|
+
_this.setListStyles(element, _this.prevX, transition);
|
|
202
181
|
|
|
203
182
|
_this.setState({
|
|
204
183
|
currentPage: nextPage
|
|
@@ -211,12 +190,12 @@ function (_super) {
|
|
|
211
190
|
/**
|
|
212
191
|
* 设置容器元素样式,分别是:透明度渐变与位置偏移
|
|
213
192
|
* @param element
|
|
214
|
-
* @param
|
|
193
|
+
* @param translateX
|
|
215
194
|
* @param transition
|
|
216
195
|
*/
|
|
217
196
|
|
|
218
197
|
|
|
219
|
-
_this.setListStyles = function (element,
|
|
198
|
+
_this.setListStyles = function (element, translateX, transition) {
|
|
220
199
|
element.style.transition = ''; // 当开启渐变时,直接执行渐变,将没有位置偏移动画
|
|
221
200
|
|
|
222
201
|
if (_this.props.fadeEffect) {
|
|
@@ -232,17 +211,7 @@ function (_super) {
|
|
|
232
211
|
element.style.transition = transition || _transition.default.TransformEaseInOut;
|
|
233
212
|
}
|
|
234
213
|
|
|
235
|
-
element.style.transform =
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
_this.getTouchSize = function (event) {
|
|
239
|
-
var isHr = _this.isHorizontalDirection();
|
|
240
|
-
|
|
241
|
-
if (event.touches) {
|
|
242
|
-
return isHr ? event.touches[0].pageX : event.touches[0].pageY;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return isHr ? event.clientX : event.clientY;
|
|
214
|
+
element.style.transform = "translateX(" + translateX + "px)";
|
|
246
215
|
};
|
|
247
216
|
|
|
248
217
|
_this.onBeforeChange = function (currentPage) {
|
|
@@ -279,8 +248,8 @@ function (_super) {
|
|
|
279
248
|
|
|
280
249
|
event.preventDefault();
|
|
281
250
|
clearTimeout(_this.autoplayTimer);
|
|
282
|
-
_this.
|
|
283
|
-
_this.
|
|
251
|
+
_this.endX = 0;
|
|
252
|
+
_this.startX = event.touches ? event.touches[0].pageX : event.clientX;
|
|
284
253
|
|
|
285
254
|
var element = _this.getListDomNode();
|
|
286
255
|
|
|
@@ -302,9 +271,9 @@ function (_super) {
|
|
|
302
271
|
}
|
|
303
272
|
|
|
304
273
|
event.preventDefault();
|
|
305
|
-
_this.
|
|
306
|
-
_this.
|
|
307
|
-
_this.
|
|
274
|
+
_this.endX = event.touches ? event.touches[0].pageX : event.clientX;
|
|
275
|
+
_this.moveX = _this.prevX + _this.endX - _this.startX;
|
|
276
|
+
_this.isDirectionLeft = _this.prevX - _this.startX <= _this.prevX - _this.endX;
|
|
308
277
|
|
|
309
278
|
var element = _this.getListDomNode();
|
|
310
279
|
|
|
@@ -312,7 +281,7 @@ function (_super) {
|
|
|
312
281
|
return;
|
|
313
282
|
}
|
|
314
283
|
|
|
315
|
-
element.style.transform =
|
|
284
|
+
element.style.transform = "translateX(" + _this.moveX + "px)";
|
|
316
285
|
};
|
|
317
286
|
/**
|
|
318
287
|
* 停止滑动,判断用户移动位置,确定用户最终滑动位置
|
|
@@ -339,9 +308,9 @@ function (_super) {
|
|
|
339
308
|
var currentPage = _this.state.currentPage;
|
|
340
309
|
var transition = _transition.default.TransformEaseOut; // 移动的偏移量
|
|
341
310
|
|
|
342
|
-
var
|
|
311
|
+
var translateX = Math.abs(_this.startX - _this.endX); // 判断用户未产生滑动,认为是点击
|
|
343
312
|
|
|
344
|
-
if (_this.
|
|
313
|
+
if (_this.endX === 0 || translateX < sensitivity) {
|
|
345
314
|
if (onClick) {
|
|
346
315
|
onClick(_this.state.currentPage + 1);
|
|
347
316
|
}
|
|
@@ -353,7 +322,7 @@ function (_super) {
|
|
|
353
322
|
|
|
354
323
|
event.preventDefault(); // 移出左边临界点
|
|
355
324
|
|
|
356
|
-
if (_this.
|
|
325
|
+
if (_this.moveX >= 0) {
|
|
357
326
|
_this.interceptorChangePage(0, transition);
|
|
358
327
|
|
|
359
328
|
return;
|
|
@@ -362,21 +331,21 @@ function (_super) {
|
|
|
362
331
|
var childCount = _this.getChildCount(); // 移出右边临界点
|
|
363
332
|
|
|
364
333
|
|
|
365
|
-
var
|
|
366
|
-
var moveX = Math.abs(_this.
|
|
334
|
+
var listWidth = _this.sliderWidth * childCount;
|
|
335
|
+
var moveX = Math.abs(_this.moveX);
|
|
367
336
|
|
|
368
|
-
if (moveX >=
|
|
337
|
+
if (moveX >= listWidth - _this.contentWidth) {
|
|
369
338
|
_this.interceptorChangePage(childCount - slidesPerView, transition);
|
|
370
339
|
|
|
371
340
|
return;
|
|
372
341
|
} // 未达到一页,判断是否超出sensitivity, 超出将加1
|
|
373
342
|
|
|
374
343
|
|
|
375
|
-
var skipOne =
|
|
344
|
+
var skipOne = translateX % _this.sliderWidth >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
|
|
376
345
|
|
|
377
|
-
var skipCount = Math.floor(
|
|
346
|
+
var skipCount = Math.floor(translateX / _this.sliderWidth); // 判断是否向左滑动
|
|
378
347
|
|
|
379
|
-
if (_this.
|
|
348
|
+
if (_this.isDirectionLeft) {
|
|
380
349
|
currentPage = currentPage + skipCount + skipOne;
|
|
381
350
|
} else {
|
|
382
351
|
currentPage -= skipCount + skipOne;
|
|
@@ -419,11 +388,9 @@ function (_super) {
|
|
|
419
388
|
Carousel.prototype.componentDidUpdate = function (prevProps) {
|
|
420
389
|
var _this = this;
|
|
421
390
|
|
|
422
|
-
var
|
|
423
|
-
children = _a.children,
|
|
424
|
-
direction = _a.direction;
|
|
391
|
+
var children = this.props.children;
|
|
425
392
|
|
|
426
|
-
if (_react.default.Children.count(children) !== _react.default.Children.count(prevProps.children)
|
|
393
|
+
if (_react.default.Children.count(children) !== _react.default.Children.count(prevProps.children)) {
|
|
427
394
|
this.init();
|
|
428
395
|
} // 加入 resize 监听
|
|
429
396
|
|
|
@@ -474,9 +441,8 @@ function (_super) {
|
|
|
474
441
|
className = _b.className,
|
|
475
442
|
children = _b.children,
|
|
476
443
|
pagination = _b.pagination;
|
|
477
|
-
var isHr = this.isHorizontalDirection();
|
|
478
444
|
return _react.default.createElement("div", {
|
|
479
|
-
className: (0, _classnames.default)(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a
|
|
445
|
+
className: (0, _classnames.default)(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a))
|
|
480
446
|
}, _react.default.createElement("div", {
|
|
481
447
|
className: cls + "-content"
|
|
482
448
|
}, _react.default.createElement("div", {
|
|
@@ -497,7 +463,6 @@ function (_super) {
|
|
|
497
463
|
|
|
498
464
|
|
|
499
465
|
Carousel.defaultProps = {
|
|
500
|
-
direction: CarouselDirection.horizontal,
|
|
501
466
|
slidesPerView: 1,
|
|
502
467
|
defaultValue: 1,
|
|
503
468
|
className: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-carousel{position:relative
|
|
1
|
+
.ab-carousel{position:relative}.ab-carousel-content{position:relative;display:block;height:100%;width:100%;margin:0;padding:0;overflow:hidden}.ab-carousel-list{user-select:none;position:relative;top:0;left:0;display:block;overflow:hidden}.ab-carousel-slider{outline:0;overflow:hidden;float:left;display:none}.ab-carousel.ab-carousel-init .ab-carousel-slider{display:block}
|
|
@@ -2,7 +2,6 @@ $namespace: ab-carousel;
|
|
|
2
2
|
|
|
3
3
|
.#{$namespace} {
|
|
4
4
|
position: relative;
|
|
5
|
-
height: 100%;
|
|
6
5
|
|
|
7
6
|
&-content {
|
|
8
7
|
position: relative;
|
|
@@ -26,6 +25,7 @@ $namespace: ab-carousel;
|
|
|
26
25
|
&-slider {
|
|
27
26
|
outline: none;
|
|
28
27
|
overflow: hidden;
|
|
28
|
+
float: left;
|
|
29
29
|
display: none;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -34,10 +34,4 @@ $namespace: ab-carousel;
|
|
|
34
34
|
display: block;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
&.#{$namespace}-hr {
|
|
39
|
-
.#{$namespace}-slider {
|
|
40
|
-
float: left;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-dp-cg-content,.ab-dp-cg-head,.ab-dp-cg-title{display:flex;align-items:center}.ab-dp-cg-title{user-select:none;font-size:.14rem;padding-bottom:.08rem}.ab-dp-cg-title>strong{flex:1 1;margin-left:.1rem;cursor:default;color:#4a4a4a}.ab-dp-cg-title>strong.ab-dp-cg-clickable{cursor:pointer}.ab-dp-cg-title>strong.ab-dp-cg-clickable:hover{color:#000}.ab-dp-cg-dis-icon,.ab-dp-cg-icon{align-self:flex-end;margin-left:.08rem}.ab-dp-cg-icon{cursor:pointer}.ab-dp-cg-head{padding-bottom:.05rem}.ab-dp-cg-head>li{display:flex;align-items:center;justify-content:center;cursor:default}.ab-dp-cg-content{flex-wrap:wrap}.ab-dp-cg-content>li{cursor:pointer;display:flex;align-items:center;justify-content:center;color:#000}.ab-dp-cg-content>li:hover{background:#f0f0f0}.ab-dp-cg-content>li.ab-dp-cg-dis{cursor:not-allowed;color:#b0b0b0}.ab-dp-cg-content>li.ab-dp-cg-dis:hover{background:0 0}.ab-dp-cg-content>li.ab-dp-cg-selected,.ab-dp-cg-content>li:active{background:#c7e0f4;border:3px solid #c7e0f4;border-radius:2px;color:#000}.ab-dp-cg-content>li.ab-dp-cg-today{background:#0078d4;color:#fff}
|
|
1
|
+
.ab-dp-cg-content,.ab-dp-cg-head,.ab-dp-cg-title{display:flex;align-items:center}.ab-dp-cg-title{user-select:none;font-size:.14rem;padding-bottom:.08rem}.ab-dp-cg-title>strong{flex:1 1;margin-left:.1rem;cursor:default;color:#4a4a4a}.ab-dp-cg-title>strong.ab-dp-cg-clickable{cursor:pointer}.ab-dp-cg-title>strong.ab-dp-cg-clickable:hover{color:#000}.ab-dp-cg-dis-icon,.ab-dp-cg-icon{align-self:flex-end;margin-left:.08rem}.ab-dp-cg-icon{cursor:pointer}.ab-dp-cg-head{padding-bottom:.05rem}.ab-dp-cg-head>li{display:flex;align-items:center;justify-content:center;cursor:default}.ab-dp-cg-content{flex-wrap:wrap}.ab-dp-cg-content>li{cursor:pointer;display:flex;align-items:center;justify-content:center;color:#000}.ab-dp-cg-content>li:hover{background:#f0f0f0}.ab-dp-cg-content>li.ab-dp-cg-dis{cursor:not-allowed;color:#b0b0b0}.ab-dp-cg-content>li.ab-dp-cg-dis:hover{background:0 0}.ab-dp-cg-content>li.ab-dp-cg-selected,.ab-dp-cg-content>li:active{background:#c7e0f4;border:3px solid #c7e0f4;border-radius:2px;color:#000}.ab-dp-cg-content>li.ab-dp-cg-today{background:#0078d4;color:#fff}.ab-dp-cg-arrow{cursor:pointer}
|
|
@@ -11,37 +11,24 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
|
|
14
|
-
var _icon = _interopRequireDefault(require("../../../icon"));
|
|
15
|
-
|
|
16
|
-
var __assign = void 0 && (void 0).__assign || function () {
|
|
17
|
-
__assign = Object.assign || function (t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
|
|
21
|
-
for (var p in s) {
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return __assign.apply(this, arguments);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
14
|
var cls = 'ab-dp-cg';
|
|
33
15
|
|
|
34
|
-
var
|
|
16
|
+
var renderArrow = function renderArrow(prefixCls, direction, onClick) {
|
|
35
17
|
var enabled = !!onClick;
|
|
36
|
-
return {
|
|
37
|
-
|
|
38
|
-
width: 0.14,
|
|
39
|
-
height: 0.28,
|
|
40
|
-
color: enabled ? '#333' : '#808080',
|
|
41
|
-
transform: direction,
|
|
42
|
-
className: enabled ? cls + "-icon" : cls + "-dis-icon",
|
|
18
|
+
return _react.default.createElement("span", {
|
|
19
|
+
className: prefixCls + "-arrow",
|
|
43
20
|
onClick: onClick
|
|
44
|
-
}
|
|
21
|
+
}, _react.default.createElement("svg", {
|
|
22
|
+
style: direction,
|
|
23
|
+
viewBox: "0 0 1024 1024",
|
|
24
|
+
version: "1.1",
|
|
25
|
+
width: "0.14rem",
|
|
26
|
+
height: "0.28rem",
|
|
27
|
+
fill: enabled ? '#333' : '#808080',
|
|
28
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
29
|
+
}, _react.default.createElement("path", {
|
|
30
|
+
d: "M525.339326 186.172452L801.789086 462.622212c12.496698 12.496698 32.758136 12.496698 45.254834 0 12.497405-12.497405 12.496698-32.758136 0-45.254834l-331.014362-331.014362c-12.496698-12.496698-32.757429-12.497405-45.254834 0l-341.795619 339.143969c-12.496698 12.496698-12.496698 32.758136 0 45.254834 12.496698 12.496698 32.758136 12.496698 45.254834 0l287.10586-284.454209L461.372325 925.726242c0 17.673427 14.32669 32.000117 32.000118 32.000117 17.67272-0.000707 31.99941-14.327398 32.000117-32.000117l-0.032527-739.553083z"
|
|
31
|
+
})));
|
|
45
32
|
};
|
|
46
33
|
|
|
47
34
|
var CalendarGrid = function CalendarGrid(_a) {
|
|
@@ -62,7 +49,9 @@ var CalendarGrid = function CalendarGrid(_a) {
|
|
|
62
49
|
}, _react.default.createElement("strong", {
|
|
63
50
|
className: (0, _classnames.default)((_b = {}, _b[cls + "-clickable"] = !!onClickTitle, _b)),
|
|
64
51
|
onClick: onClickTitle
|
|
65
|
-
}, title),
|
|
52
|
+
}, title), renderArrow(cls, {}, onPrev), renderArrow(cls, {
|
|
53
|
+
transform: 'rotate(180deg)'
|
|
54
|
+
}, onNext)), _react.default.createElement("ul", {
|
|
66
55
|
className: cls + "-head"
|
|
67
56
|
}, headList.map(function (item, index) {
|
|
68
57
|
return _react.default.createElement("li", {
|
|
@@ -12,6 +12,10 @@ export interface CalendarProps extends Omit<DayCalendarProps, omitType>, Omit<Mo
|
|
|
12
12
|
* 选择日期的回调函数
|
|
13
13
|
*/
|
|
14
14
|
onSelect: (date?: Date, name?: ReactText) => void;
|
|
15
|
+
/**
|
|
16
|
+
* 默认日期
|
|
17
|
+
*/
|
|
18
|
+
defaultDate?: Date;
|
|
15
19
|
}
|
|
16
20
|
interface CalendarState {
|
|
17
21
|
selectedDate: Date;
|
|
@@ -87,7 +87,7 @@ function (_super) {
|
|
|
87
87
|
});
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
var nowDate = props.
|
|
90
|
+
var nowDate = props.defaultDate || props.today || new Date();
|
|
91
91
|
_this.state = {
|
|
92
92
|
selectedDate: nowDate,
|
|
93
93
|
navigatedDate: (0, _utils.getMonthStart)(nowDate.getFullYear(), nowDate.getMonth())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactText } from 'react';
|
|
2
2
|
import Calendar, { CalendarProps } from './calendar';
|
|
3
|
-
export interface DatePickerProps extends Partial<CalendarProps
|
|
3
|
+
export interface DatePickerProps extends Partial<Omit<CalendarProps, 'defaultDate'>> {
|
|
4
4
|
/**
|
|
5
5
|
* 组件整体样式
|
|
6
6
|
*/
|
|
@@ -13,6 +13,14 @@ export interface DatePickerProps extends Partial<CalendarProps> {
|
|
|
13
13
|
* 需要显示在input框中的日期格式
|
|
14
14
|
*/
|
|
15
15
|
onFormatDate?: (v: Date, name?: ReactText) => string;
|
|
16
|
+
/**
|
|
17
|
+
* 默认选中的值,用于初始化展示
|
|
18
|
+
*/
|
|
19
|
+
defaultValue?: Date;
|
|
20
|
+
/**
|
|
21
|
+
* 外部控制value
|
|
22
|
+
*/
|
|
23
|
+
value?: Date;
|
|
16
24
|
/**
|
|
17
25
|
* 是否显示input框中的日历图标
|
|
18
26
|
*/
|
|
@@ -29,10 +37,6 @@ export interface DatePickerProps extends Partial<CalendarProps> {
|
|
|
29
37
|
* 是否禁用
|
|
30
38
|
*/
|
|
31
39
|
disabled?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* 默认选中的值,用于初始化展示
|
|
34
|
-
*/
|
|
35
|
-
defaultValue?: Date;
|
|
36
40
|
/**
|
|
37
41
|
* 与onFormatDate正相反,将input框中的字符串转为Date,当onFormatDate有值时,该属性``也需要有值
|
|
38
42
|
*/
|
|
@@ -45,7 +49,9 @@ interface DatePickerState {
|
|
|
45
49
|
declare class DatePicker extends React.Component<DatePickerProps, DatePickerState> {
|
|
46
50
|
prefixCls: string;
|
|
47
51
|
calendarRef: React.RefObject<Calendar>;
|
|
48
|
-
|
|
52
|
+
defaultDate?: Date;
|
|
53
|
+
popoverTriggered: boolean;
|
|
54
|
+
constructor(props: DatePickerProps);
|
|
49
55
|
static defaultProps: {
|
|
50
56
|
onFormatDate: (date: any) => any;
|
|
51
57
|
iconVisible: boolean;
|
|
@@ -53,7 +59,12 @@ declare class DatePicker extends React.Component<DatePickerProps, DatePickerStat
|
|
|
53
59
|
disabled: boolean;
|
|
54
60
|
parseDateFromString: (value: any) => Date;
|
|
55
61
|
};
|
|
62
|
+
static getDerivedStateFromProps(nextProps: DatePickerProps, prevState: DatePickerState): {
|
|
63
|
+
inputValue: string;
|
|
64
|
+
calendarVisible: boolean;
|
|
65
|
+
};
|
|
56
66
|
onCalendarSelect: (date: Date) => void;
|
|
67
|
+
updateDate: () => void;
|
|
57
68
|
onInputFocus: () => void;
|
|
58
69
|
onInputChange: (ev: any) => void;
|
|
59
70
|
onChangeDate: () => void;
|
package/lib/date-picker/index.js
CHANGED
|
@@ -17,8 +17,6 @@ var _calendar = _interopRequireDefault(require("./calendar"));
|
|
|
17
17
|
|
|
18
18
|
var _popover = _interopRequireDefault(require("../popover"));
|
|
19
19
|
|
|
20
|
-
var _icon = _interopRequireDefault(require("../icon"));
|
|
21
|
-
|
|
22
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
21
|
|
|
24
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -76,6 +74,7 @@ function (_super) {
|
|
|
76
74
|
|
|
77
75
|
_this.prefixCls = 'ab-date-picker';
|
|
78
76
|
_this.calendarRef = (0, _react.createRef)();
|
|
77
|
+
_this.popoverTriggered = false;
|
|
79
78
|
|
|
80
79
|
_this.onCalendarSelect = function (date) {
|
|
81
80
|
_this.setState({
|
|
@@ -88,14 +87,35 @@ function (_super) {
|
|
|
88
87
|
}
|
|
89
88
|
};
|
|
90
89
|
|
|
91
|
-
_this.
|
|
92
|
-
if (_this.calendarRef.current
|
|
93
|
-
|
|
90
|
+
_this.updateDate = function () {
|
|
91
|
+
if (!_this.calendarRef.current || !_this.state.inputValue) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var date = _this.props.parseDateFromString(_this.state.inputValue, _this.props.name);
|
|
96
|
+
|
|
97
|
+
if (isNaN(date.getTime())) {
|
|
98
|
+
return;
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
_this.calendarRef.current.updateDate(date);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
_this.onInputFocus = function () {
|
|
105
|
+
_this.updateDate();
|
|
106
|
+
|
|
96
107
|
_this.setState({
|
|
97
108
|
calendarVisible: true
|
|
98
109
|
});
|
|
110
|
+
|
|
111
|
+
if (!_this.popoverTriggered) {
|
|
112
|
+
// 标记触发过popover visible
|
|
113
|
+
_this.popoverTriggered = true;
|
|
114
|
+
|
|
115
|
+
if ('value' in _this.props && _this.props.value) {
|
|
116
|
+
_this.defaultDate = _this.props.value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
99
119
|
};
|
|
100
120
|
|
|
101
121
|
_this.onInputChange = function (ev) {
|
|
@@ -109,13 +129,11 @@ function (_super) {
|
|
|
109
129
|
};
|
|
110
130
|
|
|
111
131
|
_this.onChangeDate = function () {
|
|
112
|
-
if (!_this.props.allowTextInput
|
|
132
|
+
if (!_this.props.allowTextInput) {
|
|
113
133
|
return;
|
|
114
134
|
}
|
|
115
135
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_this.calendarRef.current.updateDate(date);
|
|
136
|
+
_this.updateDate();
|
|
119
137
|
};
|
|
120
138
|
|
|
121
139
|
_this.onPopoverVisibleChange = function (visible) {
|
|
@@ -143,12 +161,14 @@ function (_super) {
|
|
|
143
161
|
return _react.default.createElement(_calendar.default, __assign({}, copyProps, {
|
|
144
162
|
ref: _this.calendarRef,
|
|
145
163
|
onSelect: _this.onCalendarSelect,
|
|
146
|
-
className: copyProps.calendarClassName
|
|
164
|
+
className: copyProps.calendarClassName,
|
|
165
|
+
defaultDate: _this.defaultDate
|
|
147
166
|
}));
|
|
148
167
|
};
|
|
149
168
|
|
|
150
169
|
var defaultValue = props.defaultValue,
|
|
151
170
|
onFormatDate = props.onFormatDate;
|
|
171
|
+
_this.defaultDate = defaultValue;
|
|
152
172
|
_this.state = {
|
|
153
173
|
calendarVisible: false,
|
|
154
174
|
inputValue: defaultValue ? onFormatDate(defaultValue) : ''
|
|
@@ -156,6 +176,25 @@ function (_super) {
|
|
|
156
176
|
return _this;
|
|
157
177
|
}
|
|
158
178
|
|
|
179
|
+
DatePicker.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
180
|
+
if ('value' in nextProps) {
|
|
181
|
+
var onFormatDate = nextProps.onFormatDate,
|
|
182
|
+
value = nextProps.value;
|
|
183
|
+
var currentValue = value ? onFormatDate(value) : '';
|
|
184
|
+
|
|
185
|
+
if (prevState.inputValue === currentValue) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
inputValue: currentValue,
|
|
191
|
+
calendarVisible: false
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return null;
|
|
196
|
+
};
|
|
197
|
+
|
|
159
198
|
DatePicker.prototype.render = function () {
|
|
160
199
|
var cls = this.prefixCls;
|
|
161
200
|
var _a = this.props,
|
|
@@ -182,13 +221,18 @@ function (_super) {
|
|
|
182
221
|
value: inputValue,
|
|
183
222
|
onFocus: this.onInputFocus,
|
|
184
223
|
onChange: this.onInputChange
|
|
185
|
-
}), iconVisible && _react.default.createElement(
|
|
186
|
-
className: cls + "-icon"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
224
|
+
}), iconVisible && _react.default.createElement("span", {
|
|
225
|
+
className: cls + "-icon"
|
|
226
|
+
}, _react.default.createElement("svg", {
|
|
227
|
+
viewBox: "0 0 1024 1024",
|
|
228
|
+
version: "1.1",
|
|
229
|
+
width: "0.16rem",
|
|
230
|
+
height: "0.18rem",
|
|
231
|
+
fill: "currentColor",
|
|
232
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
233
|
+
}, _react.default.createElement("path", {
|
|
234
|
+
d: "M928 128H832V64h-64v64H256V64H192v64H96l-32 32v768l32 32h832l32-32v-768l-32-32zM896 896H128V320h768v576z m0-640H128V192h768v64zM256 512H192v64h64V512z m-64 128h64v64H192v-64z m64 128H192v64h64v-64z m128-256h64v64H384V512z m64 128H384v64h64v-64z m-64 128h64v64H384v-64z m64-384H384v64h64V384z m128 128h64v64H576V512z m64 128H576v64h64v-64z m-64 128h64v64H576v-64z m64-384H576v64h64V384z m128 128h64v64h-64V512z m64 128h-64v64h64v-64z m-64-256h64v64h-64V384z"
|
|
235
|
+
})))));
|
|
192
236
|
};
|
|
193
237
|
|
|
194
238
|
DatePicker.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-date-picker{position:relative}.ab-date-picker-input{outline:0;font-size:.14rem;padding:.04rem;width:1.44rem}.ab-date-picker-icon{position:absolute;right:.05rem;top:50%;transform:translateY(-50%)}
|
|
1
|
+
.ab-date-picker{position:relative}.ab-date-picker-input{outline:0;font-size:.14rem;padding:.04rem;width:1.44rem}.ab-date-picker-input.ab-date-picker-error{background:#fffacd}.ab-date-picker-icon{color:#606060;position:absolute;right:.05rem;top:50%;transform:translateY(-50%)}
|
|
@@ -8,12 +8,17 @@ $namespace: ab-date-picker;
|
|
|
8
8
|
font-size: .14rem;
|
|
9
9
|
padding: .04rem;
|
|
10
10
|
width: 1.44rem;
|
|
11
|
+
|
|
12
|
+
&.#{$namespace}-error {
|
|
13
|
+
background: #fffacd;
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
&-icon {
|
|
18
|
+
color: #606060;
|
|
14
19
|
position: absolute;
|
|
15
20
|
right: 0.05rem;
|
|
16
21
|
top: 50%;
|
|
17
22
|
transform: translateY(-50%);
|
|
18
23
|
}
|
|
19
|
-
}
|
|
24
|
+
}
|
package/lib/guide/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface GuideProps {
|
|
3
|
+
/**
|
|
4
|
+
* 图片路径
|
|
5
|
+
*/
|
|
6
|
+
imgSrc: string;
|
|
3
7
|
/**
|
|
4
8
|
* 是否显示遮罩层
|
|
5
9
|
*/
|
|
@@ -12,10 +16,6 @@ export interface GuideProps {
|
|
|
12
16
|
* 是否显示带箭头的图片,图片默认显示在子元素上方,水平居中
|
|
13
17
|
*/
|
|
14
18
|
loadablePointer?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 图片路径
|
|
17
|
-
*/
|
|
18
|
-
img?: string;
|
|
19
19
|
/**
|
|
20
20
|
* 图片默认显示在子元素上方,水平居中
|
|
21
21
|
*/
|
|
@@ -43,7 +43,6 @@ declare class Guide extends React.Component<GuideProps, GuideStates> {
|
|
|
43
43
|
imgRef: React.RefObject<HTMLImageElement>;
|
|
44
44
|
static defaultProps: {
|
|
45
45
|
loadablePointer: boolean;
|
|
46
|
-
img: string;
|
|
47
46
|
position: string;
|
|
48
47
|
translateX: number;
|
|
49
48
|
translateY: number;
|