acud 1.4.61 → 1.4.62-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acud.js +500 -479
- package/dist/acud.js.map +1 -1
- package/es/carousel/carousel.d.ts +2 -0
- package/es/carousel/carousel.js +53 -31
- package/es/carousel/style/index.css +5 -0
- package/es/carousel/style/index.less +5 -0
- package/es/carousel/switch.d.ts +2 -0
- package/es/carousel/switch.js +18 -6
- package/lib/carousel/carousel.d.ts +2 -0
- package/lib/carousel/carousel.js +53 -31
- package/lib/carousel/style/index.css +5 -0
- package/lib/carousel/style/index.less +5 -0
- package/lib/carousel/switch.d.ts +2 -0
- package/lib/carousel/switch.js +21 -6
- package/package.json +1 -1
- package/dist/acud.css +0 -29382
- package/dist/acud.css.map +0 -1
- package/dist/acud.min.css +0 -2
- package/dist/acud.min.css.map +0 -1
- package/dist/acud.min.js +0 -69
- package/dist/acud.min.js.map +0 -1
package/es/carousel/carousel.js
CHANGED
|
@@ -27,7 +27,9 @@ var Carousel = function Carousel(_ref) {
|
|
|
27
27
|
showNumber = _ref$showNumber === void 0 ? 3 : _ref$showNumber,
|
|
28
28
|
_ref$multiShift = _ref.multiShift,
|
|
29
29
|
multiShift = _ref$multiShift === void 0 ? false : _ref$multiShift,
|
|
30
|
-
indicatorStyle = _ref.indicatorStyle
|
|
30
|
+
indicatorStyle = _ref.indicatorStyle,
|
|
31
|
+
_ref$infinite = _ref.infinite,
|
|
32
|
+
infinite = _ref$infinite === void 0 ? true : _ref$infinite;
|
|
31
33
|
var carouselRef = useRef();
|
|
32
34
|
var timer = useRef();
|
|
33
35
|
var _useState = useState(false),
|
|
@@ -55,52 +57,68 @@ var Carousel = function Carousel(_ref) {
|
|
|
55
57
|
var length = Array.isArray(children) ? children.length : undefined;
|
|
56
58
|
var next = useCallback(function () {
|
|
57
59
|
// 向右滑动,最后一帧无缝滑动到第一帧使用的是额外添加的帧,滑动动画结束后,立刻切换到原始帧
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
lastKey: currentKey,
|
|
61
|
-
currentKey: extraCount
|
|
62
|
-
});
|
|
63
|
-
setTimeout(function () {
|
|
64
|
-
// 重置掉自动轮播
|
|
65
|
-
clearTimeout(timer.current);
|
|
66
|
-
var nextKey = extraCount + (multiShift ? extraCount : 1);
|
|
60
|
+
if (infinite) {
|
|
61
|
+
if (currentKey === length + extraCount) {
|
|
67
62
|
setKey({
|
|
68
|
-
lastKey:
|
|
63
|
+
lastKey: currentKey,
|
|
64
|
+
currentKey: extraCount
|
|
65
|
+
});
|
|
66
|
+
setTimeout(function () {
|
|
67
|
+
// 重置掉自动轮播
|
|
68
|
+
clearTimeout(timer.current);
|
|
69
|
+
var nextKey = extraCount + (multiShift ? extraCount : 1);
|
|
70
|
+
setKey({
|
|
71
|
+
lastKey: extraCount,
|
|
72
|
+
currentKey: nextKey > length + extraCount ? length + extraCount : nextKey
|
|
73
|
+
});
|
|
74
|
+
}, 100);
|
|
75
|
+
} else {
|
|
76
|
+
var nextKey = currentKey + (multiShift ? extraCount : 1);
|
|
77
|
+
setKey({
|
|
78
|
+
lastKey: currentKey,
|
|
69
79
|
currentKey: nextKey > length + extraCount ? length + extraCount : nextKey
|
|
70
80
|
});
|
|
71
|
-
}
|
|
81
|
+
}
|
|
72
82
|
} else {
|
|
73
|
-
var
|
|
83
|
+
var _nextKey = currentKey + (multiShift ? extraCount : 1);
|
|
74
84
|
setKey({
|
|
75
85
|
lastKey: currentKey,
|
|
76
|
-
currentKey:
|
|
86
|
+
currentKey: _nextKey > length + extraCount ? length + extraCount : _nextKey
|
|
77
87
|
});
|
|
78
88
|
}
|
|
79
|
-
}, [currentKey, extraCount, length, multiShift]);
|
|
89
|
+
}, [currentKey, extraCount, length, multiShift, infinite]);
|
|
80
90
|
// 向左滑动,第一帧无缝滑动到最后一帧使用的是额外添加的帧,滑动动画结束后,立刻切换到原始帧
|
|
81
91
|
var prev = useCallback(function () {
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
lastKey: currentKey,
|
|
85
|
-
currentKey: length
|
|
86
|
-
});
|
|
87
|
-
setTimeout(function () {
|
|
88
|
-
// 重置掉自动轮播
|
|
89
|
-
clearTimeout(timer.current);
|
|
90
|
-
var nextKey = length - (multiShift ? extraCount : 1);
|
|
92
|
+
if (infinite) {
|
|
93
|
+
if (currentKey === 0) {
|
|
91
94
|
setKey({
|
|
92
|
-
lastKey:
|
|
93
|
-
currentKey:
|
|
95
|
+
lastKey: currentKey,
|
|
96
|
+
currentKey: length
|
|
94
97
|
});
|
|
95
|
-
|
|
98
|
+
setTimeout(function () {
|
|
99
|
+
// 重置掉自动轮播
|
|
100
|
+
clearTimeout(timer.current);
|
|
101
|
+
var nextKey = length - (multiShift ? extraCount : 1);
|
|
102
|
+
setKey({
|
|
103
|
+
lastKey: length,
|
|
104
|
+
currentKey: nextKey < 0 ? 0 : length - (multiShift ? extraCount : 1)
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
var nextKey = currentKey - (multiShift ? extraCount : 1);
|
|
109
|
+
setKey({
|
|
110
|
+
lastKey: currentKey,
|
|
111
|
+
currentKey: nextKey < 0 ? 0 : currentKey - (multiShift ? extraCount : 1)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
96
114
|
} else {
|
|
97
|
-
var
|
|
115
|
+
var _nextKey2 = currentKey - (multiShift ? extraCount : 1);
|
|
98
116
|
setKey({
|
|
99
117
|
lastKey: currentKey,
|
|
100
|
-
currentKey:
|
|
118
|
+
currentKey: _nextKey2 < 0 ? 0 : _nextKey2
|
|
101
119
|
});
|
|
102
120
|
}
|
|
103
|
-
}, [currentKey, extraCount, length, multiShift]);
|
|
121
|
+
}, [currentKey, extraCount, length, multiShift, infinite]);
|
|
104
122
|
// 监听是否hover热区,hover情况下不会自动轮播
|
|
105
123
|
useEffect(function () {
|
|
106
124
|
carouselRef.current.addEventListener('mouseover', function () {
|
|
@@ -152,6 +170,8 @@ var Carousel = function Carousel(_ref) {
|
|
|
152
170
|
return (multi ? cardWidth + 8 : cardWidth) * (idx - currentKey);
|
|
153
171
|
};
|
|
154
172
|
var wrapperClassName = classNames(prefixCls, className, _defineProperty({}, "".concat(prefixCls, "-multi"), multi));
|
|
173
|
+
var isPrevDisabled = !infinite && currentKey === extraCount;
|
|
174
|
+
var isNextDisabled = !infinite && currentKey === length;
|
|
155
175
|
return /*#__PURE__*/React.createElement("div", {
|
|
156
176
|
ref: carouselRef,
|
|
157
177
|
style: style,
|
|
@@ -159,7 +179,9 @@ var Carousel = function Carousel(_ref) {
|
|
|
159
179
|
}, childrenIsArray ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CarouselSwitch, {
|
|
160
180
|
prefixCls: prefixCls,
|
|
161
181
|
next: next,
|
|
162
|
-
prev: prev
|
|
182
|
+
prev: prev,
|
|
183
|
+
isPrevDisabled: isPrevDisabled,
|
|
184
|
+
isNextDisabled: isNextDisabled
|
|
163
185
|
}), !multi && /*#__PURE__*/React.createElement(CarouselIndicator, {
|
|
164
186
|
prefixCls: prefixCls,
|
|
165
187
|
setKey: setKey,
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
.acud-carousel-switch > span {
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
pointer-events: visible;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
.acud-carousel-switch > span.disabled {
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
opacity: 0.5;
|
|
38
43
|
}
|
|
39
44
|
.acud-carousel-switch > span > .acudicon {
|
|
40
45
|
display: block;
|
package/es/carousel/switch.d.ts
CHANGED
package/es/carousel/switch.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import OutlinedRight from "acud-icon/es/icons/OutlinedRight";
|
|
3
3
|
import OutlinedLeft from "acud-icon/es/icons/OutlinedLeft";
|
|
4
4
|
;
|
|
5
5
|
var CarouselSwitch = function CarouselSwitch(_ref) {
|
|
6
6
|
var prefixCls = _ref.prefixCls,
|
|
7
7
|
next = _ref.next,
|
|
8
|
-
prev = _ref.prev
|
|
8
|
+
prev = _ref.prev,
|
|
9
|
+
isPrevDisabled = _ref.isPrevDisabled,
|
|
10
|
+
isNextDisabled = _ref.isNextDisabled;
|
|
11
|
+
var handlePrevClick = useCallback(function () {
|
|
12
|
+
if (!isPrevDisabled) {
|
|
13
|
+
prev();
|
|
14
|
+
}
|
|
15
|
+
}, [isPrevDisabled, prev]);
|
|
16
|
+
var handleNextClick = useCallback(function () {
|
|
17
|
+
if (!isNextDisabled) {
|
|
18
|
+
next();
|
|
19
|
+
}
|
|
20
|
+
}, [isNextDisabled, next]);
|
|
9
21
|
return /*#__PURE__*/React.createElement("div", {
|
|
10
22
|
className: "".concat(prefixCls, "-switch")
|
|
11
23
|
}, /*#__PURE__*/React.createElement("span", {
|
|
12
|
-
className: "".concat(prefixCls, "-switch-left"),
|
|
13
|
-
onClick:
|
|
24
|
+
className: "".concat(prefixCls, "-switch-left ").concat(isPrevDisabled ? 'disabled' : ''),
|
|
25
|
+
onClick: handlePrevClick
|
|
14
26
|
}, /*#__PURE__*/React.createElement(OutlinedLeft, null)), /*#__PURE__*/React.createElement("span", {
|
|
15
|
-
className: "".concat(prefixCls, "-switch-right"),
|
|
16
|
-
onClick:
|
|
27
|
+
className: "".concat(prefixCls, "-switch-right ").concat(isNextDisabled ? 'disabled' : ''),
|
|
28
|
+
onClick: handleNextClick
|
|
17
29
|
}, /*#__PURE__*/React.createElement(OutlinedRight, null)));
|
|
18
30
|
};
|
|
19
31
|
export default CarouselSwitch;
|
package/lib/carousel/carousel.js
CHANGED
|
@@ -37,7 +37,9 @@ var Carousel = function Carousel(_ref) {
|
|
|
37
37
|
showNumber = _ref$showNumber === void 0 ? 3 : _ref$showNumber,
|
|
38
38
|
_ref$multiShift = _ref.multiShift,
|
|
39
39
|
multiShift = _ref$multiShift === void 0 ? false : _ref$multiShift,
|
|
40
|
-
indicatorStyle = _ref.indicatorStyle
|
|
40
|
+
indicatorStyle = _ref.indicatorStyle,
|
|
41
|
+
_ref$infinite = _ref.infinite,
|
|
42
|
+
infinite = _ref$infinite === void 0 ? true : _ref$infinite;
|
|
41
43
|
var carouselRef = (0, _react.useRef)();
|
|
42
44
|
var timer = (0, _react.useRef)();
|
|
43
45
|
var _useState = (0, _react.useState)(false),
|
|
@@ -65,52 +67,68 @@ var Carousel = function Carousel(_ref) {
|
|
|
65
67
|
var length = Array.isArray(children) ? children.length : undefined;
|
|
66
68
|
var next = (0, _react.useCallback)(function () {
|
|
67
69
|
// 向右滑动,最后一帧无缝滑动到第一帧使用的是额外添加的帧,滑动动画结束后,立刻切换到原始帧
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
lastKey: currentKey,
|
|
71
|
-
currentKey: extraCount
|
|
72
|
-
});
|
|
73
|
-
setTimeout(function () {
|
|
74
|
-
// 重置掉自动轮播
|
|
75
|
-
clearTimeout(timer.current);
|
|
76
|
-
var nextKey = extraCount + (multiShift ? extraCount : 1);
|
|
70
|
+
if (infinite) {
|
|
71
|
+
if (currentKey === length + extraCount) {
|
|
77
72
|
setKey({
|
|
78
|
-
lastKey:
|
|
73
|
+
lastKey: currentKey,
|
|
74
|
+
currentKey: extraCount
|
|
75
|
+
});
|
|
76
|
+
setTimeout(function () {
|
|
77
|
+
// 重置掉自动轮播
|
|
78
|
+
clearTimeout(timer.current);
|
|
79
|
+
var nextKey = extraCount + (multiShift ? extraCount : 1);
|
|
80
|
+
setKey({
|
|
81
|
+
lastKey: extraCount,
|
|
82
|
+
currentKey: nextKey > length + extraCount ? length + extraCount : nextKey
|
|
83
|
+
});
|
|
84
|
+
}, 100);
|
|
85
|
+
} else {
|
|
86
|
+
var nextKey = currentKey + (multiShift ? extraCount : 1);
|
|
87
|
+
setKey({
|
|
88
|
+
lastKey: currentKey,
|
|
79
89
|
currentKey: nextKey > length + extraCount ? length + extraCount : nextKey
|
|
80
90
|
});
|
|
81
|
-
}
|
|
91
|
+
}
|
|
82
92
|
} else {
|
|
83
|
-
var
|
|
93
|
+
var _nextKey = currentKey + (multiShift ? extraCount : 1);
|
|
84
94
|
setKey({
|
|
85
95
|
lastKey: currentKey,
|
|
86
|
-
currentKey:
|
|
96
|
+
currentKey: _nextKey > length + extraCount ? length + extraCount : _nextKey
|
|
87
97
|
});
|
|
88
98
|
}
|
|
89
|
-
}, [currentKey, extraCount, length, multiShift]);
|
|
99
|
+
}, [currentKey, extraCount, length, multiShift, infinite]);
|
|
90
100
|
// 向左滑动,第一帧无缝滑动到最后一帧使用的是额外添加的帧,滑动动画结束后,立刻切换到原始帧
|
|
91
101
|
var prev = (0, _react.useCallback)(function () {
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
lastKey: currentKey,
|
|
95
|
-
currentKey: length
|
|
96
|
-
});
|
|
97
|
-
setTimeout(function () {
|
|
98
|
-
// 重置掉自动轮播
|
|
99
|
-
clearTimeout(timer.current);
|
|
100
|
-
var nextKey = length - (multiShift ? extraCount : 1);
|
|
102
|
+
if (infinite) {
|
|
103
|
+
if (currentKey === 0) {
|
|
101
104
|
setKey({
|
|
102
|
-
lastKey:
|
|
103
|
-
currentKey:
|
|
105
|
+
lastKey: currentKey,
|
|
106
|
+
currentKey: length
|
|
104
107
|
});
|
|
105
|
-
|
|
108
|
+
setTimeout(function () {
|
|
109
|
+
// 重置掉自动轮播
|
|
110
|
+
clearTimeout(timer.current);
|
|
111
|
+
var nextKey = length - (multiShift ? extraCount : 1);
|
|
112
|
+
setKey({
|
|
113
|
+
lastKey: length,
|
|
114
|
+
currentKey: nextKey < 0 ? 0 : length - (multiShift ? extraCount : 1)
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
var nextKey = currentKey - (multiShift ? extraCount : 1);
|
|
119
|
+
setKey({
|
|
120
|
+
lastKey: currentKey,
|
|
121
|
+
currentKey: nextKey < 0 ? 0 : currentKey - (multiShift ? extraCount : 1)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
106
124
|
} else {
|
|
107
|
-
var
|
|
125
|
+
var _nextKey2 = currentKey - (multiShift ? extraCount : 1);
|
|
108
126
|
setKey({
|
|
109
127
|
lastKey: currentKey,
|
|
110
|
-
currentKey:
|
|
128
|
+
currentKey: _nextKey2 < 0 ? 0 : _nextKey2
|
|
111
129
|
});
|
|
112
130
|
}
|
|
113
|
-
}, [currentKey, extraCount, length, multiShift]);
|
|
131
|
+
}, [currentKey, extraCount, length, multiShift, infinite]);
|
|
114
132
|
// 监听是否hover热区,hover情况下不会自动轮播
|
|
115
133
|
(0, _react.useEffect)(function () {
|
|
116
134
|
carouselRef.current.addEventListener('mouseover', function () {
|
|
@@ -162,6 +180,8 @@ var Carousel = function Carousel(_ref) {
|
|
|
162
180
|
return (multi ? cardWidth + 8 : cardWidth) * (idx - currentKey);
|
|
163
181
|
};
|
|
164
182
|
var wrapperClassName = (0, _classnames["default"])(prefixCls, className, (0, _defineProperty2["default"])({}, "".concat(prefixCls, "-multi"), multi));
|
|
183
|
+
var isPrevDisabled = !infinite && currentKey === extraCount;
|
|
184
|
+
var isNextDisabled = !infinite && currentKey === length;
|
|
165
185
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
166
186
|
ref: carouselRef,
|
|
167
187
|
style: style,
|
|
@@ -169,7 +189,9 @@ var Carousel = function Carousel(_ref) {
|
|
|
169
189
|
}, childrenIsArray ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_switch["default"], {
|
|
170
190
|
prefixCls: prefixCls,
|
|
171
191
|
next: next,
|
|
172
|
-
prev: prev
|
|
192
|
+
prev: prev,
|
|
193
|
+
isPrevDisabled: isPrevDisabled,
|
|
194
|
+
isNextDisabled: isNextDisabled
|
|
173
195
|
}), !multi && /*#__PURE__*/_react["default"].createElement(_indicator["default"], {
|
|
174
196
|
prefixCls: prefixCls,
|
|
175
197
|
setKey: setKey,
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
.acud-carousel-switch > span {
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
pointer-events: visible;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
.acud-carousel-switch > span.disabled {
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
opacity: 0.5;
|
|
38
43
|
}
|
|
39
44
|
.acud-carousel-switch > span > .acudicon {
|
|
40
45
|
display: block;
|
package/lib/carousel/switch.d.ts
CHANGED
package/lib/carousel/switch.js
CHANGED
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
8
|
-
var _react =
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _OutlinedRight = _interopRequireDefault(require("acud-icon/lib/icons/OutlinedRight"));
|
|
10
11
|
var _OutlinedLeft = _interopRequireDefault(require("acud-icon/lib/icons/OutlinedLeft"));
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
11
14
|
;
|
|
12
15
|
var CarouselSwitch = function CarouselSwitch(_ref) {
|
|
13
16
|
var prefixCls = _ref.prefixCls,
|
|
14
17
|
next = _ref.next,
|
|
15
|
-
prev = _ref.prev
|
|
18
|
+
prev = _ref.prev,
|
|
19
|
+
isPrevDisabled = _ref.isPrevDisabled,
|
|
20
|
+
isNextDisabled = _ref.isNextDisabled;
|
|
21
|
+
var handlePrevClick = (0, _react.useCallback)(function () {
|
|
22
|
+
if (!isPrevDisabled) {
|
|
23
|
+
prev();
|
|
24
|
+
}
|
|
25
|
+
}, [isPrevDisabled, prev]);
|
|
26
|
+
var handleNextClick = (0, _react.useCallback)(function () {
|
|
27
|
+
if (!isNextDisabled) {
|
|
28
|
+
next();
|
|
29
|
+
}
|
|
30
|
+
}, [isNextDisabled, next]);
|
|
16
31
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
17
32
|
className: "".concat(prefixCls, "-switch")
|
|
18
33
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
19
|
-
className: "".concat(prefixCls, "-switch-left"),
|
|
20
|
-
onClick:
|
|
34
|
+
className: "".concat(prefixCls, "-switch-left ").concat(isPrevDisabled ? 'disabled' : ''),
|
|
35
|
+
onClick: handlePrevClick
|
|
21
36
|
}, /*#__PURE__*/_react["default"].createElement(_OutlinedLeft["default"], null)), /*#__PURE__*/_react["default"].createElement("span", {
|
|
22
|
-
className: "".concat(prefixCls, "-switch-right"),
|
|
23
|
-
onClick:
|
|
37
|
+
className: "".concat(prefixCls, "-switch-right ").concat(isNextDisabled ? 'disabled' : ''),
|
|
38
|
+
onClick: handleNextClick
|
|
24
39
|
}, /*#__PURE__*/_react["default"].createElement(_OutlinedRight["default"], null)));
|
|
25
40
|
};
|
|
26
41
|
var _default = exports["default"] = CarouselSwitch;
|