@arcblock/ux 1.17.10 → 1.17.13
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.
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = AnimationWaiter;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _reactLottiePlayer = _interopRequireDefault(require("react-lottie-player"));
|
|
15
|
+
|
|
16
|
+
var _defaultAnimation = _interopRequireDefault(require("./default-animation.json"));
|
|
17
|
+
|
|
18
|
+
const _excluded = ["animationData", "size", "message", "messageDuration", "tips", "tipsDuration", "maybeDuration", "speed", "increaseSpeed"];
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
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
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
27
|
+
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 用于长时间等待的用的动画组件
|
|
32
|
+
* 动画会随着时间的变化而逐步加快播放速度,好适应用户的等待心理
|
|
33
|
+
* @param {Object} animationData lottie json 动画数据
|
|
34
|
+
* @param {Number} size 动画的尺寸,单位px
|
|
35
|
+
* @param {String|Array} message 动画下方的文字;数组情况下会在一定时间切换文案
|
|
36
|
+
* @param {Number} messageDuration 动画下方的文字为数组时,每个文案的持续时间;默认5000ms
|
|
37
|
+
* @param {Array} tips 底部的提示元素
|
|
38
|
+
* @param {Number} tipsDuration 底部提示的切换时间,单位毫秒,默认3000ms
|
|
39
|
+
* @param {Number} speed 动画默认的播放速度
|
|
40
|
+
* @param {Number} maybeDuration 整个动画大概的持续时间,单位毫秒,用于计算增量下的动画速度,默认两分钟(120000ms)
|
|
41
|
+
* @param {Number} increaseSpeed 在 maybeDuration 时间下增加的速度,默认为0(不增加速度)
|
|
42
|
+
* @returns element
|
|
43
|
+
*/
|
|
44
|
+
function AnimationWaiter(_ref) {
|
|
45
|
+
let {
|
|
46
|
+
animationData,
|
|
47
|
+
size,
|
|
48
|
+
message,
|
|
49
|
+
messageDuration,
|
|
50
|
+
tips,
|
|
51
|
+
tipsDuration,
|
|
52
|
+
maybeDuration,
|
|
53
|
+
speed,
|
|
54
|
+
increaseSpeed
|
|
55
|
+
} = _ref,
|
|
56
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
57
|
+
|
|
58
|
+
const [tipsId, setTipsId] = (0, _react.useState)(0);
|
|
59
|
+
const [currentSpeed, setCurrentSpeed] = (0, _react.useState)(speed);
|
|
60
|
+
const [desc, setDesc] = (0, _react.useState)(''); // 动画的开始时间
|
|
61
|
+
|
|
62
|
+
const startTime = (0, _react.useRef)(new Date().getTime()); // 省略号
|
|
63
|
+
|
|
64
|
+
(0, _react.useEffect)(() => {
|
|
65
|
+
if (!message) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let timer1;
|
|
70
|
+
let msgId = 0;
|
|
71
|
+
|
|
72
|
+
if (Array.isArray(message)) {
|
|
73
|
+
setDesc(message[msgId]);
|
|
74
|
+
timer1 = setInterval(() => {
|
|
75
|
+
msgId++;
|
|
76
|
+
|
|
77
|
+
if (msgId >= message.length) {
|
|
78
|
+
msgId = 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setDesc(message[msgId]);
|
|
82
|
+
}, messageDuration);
|
|
83
|
+
} else {
|
|
84
|
+
setDesc(message);
|
|
85
|
+
} // eslint-disable-next-line consistent-return
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
return () => {
|
|
89
|
+
clearInterval(timer1);
|
|
90
|
+
};
|
|
91
|
+
}, [message, messageDuration]); // tips
|
|
92
|
+
|
|
93
|
+
(0, _react.useEffect)(() => {
|
|
94
|
+
if (!tips.length) {
|
|
95
|
+
return () => {};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const timer = setTimeout(() => {
|
|
99
|
+
let nextId = tipsId + 1;
|
|
100
|
+
|
|
101
|
+
if (nextId >= tips.length) {
|
|
102
|
+
nextId = 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setTipsId(nextId);
|
|
106
|
+
}, tipsDuration);
|
|
107
|
+
return () => clearTimeout(timer);
|
|
108
|
+
}, [tips, tipsDuration, tipsId]); // 动画speed
|
|
109
|
+
|
|
110
|
+
(0, _react.useEffect)(() => {
|
|
111
|
+
const timer = setTimeout(() => {
|
|
112
|
+
const diffTime = new Date().getTime() - startTime.current;
|
|
113
|
+
let percentage = diffTime / maybeDuration;
|
|
114
|
+
|
|
115
|
+
if (percentage > 1) {
|
|
116
|
+
percentage = 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const newSpeed = speed + increaseSpeed * percentage;
|
|
120
|
+
setCurrentSpeed(newSpeed);
|
|
121
|
+
}, 1000);
|
|
122
|
+
return () => clearTimeout(timer);
|
|
123
|
+
}, [currentSpeed]);
|
|
124
|
+
return /*#__PURE__*/_react.default.createElement(Container, rest, /*#__PURE__*/_react.default.createElement(_reactLottiePlayer.default, {
|
|
125
|
+
loop: true,
|
|
126
|
+
animationData: animationData || _defaultAnimation.default,
|
|
127
|
+
play: true,
|
|
128
|
+
speed: currentSpeed,
|
|
129
|
+
style: {
|
|
130
|
+
width: size,
|
|
131
|
+
height: size
|
|
132
|
+
}
|
|
133
|
+
}), message && /*#__PURE__*/_react.default.createElement("div", {
|
|
134
|
+
className: "waiter-message"
|
|
135
|
+
}, desc, /*#__PURE__*/_react.default.createElement("span", {
|
|
136
|
+
className: "waiter-loading"
|
|
137
|
+
})), tips.length ? /*#__PURE__*/_react.default.createElement("div", {
|
|
138
|
+
className: "waiter-tips-container"
|
|
139
|
+
}, tips.map((e, index) => {
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
+
className: "waiter-tips-block ".concat(tipsId === index ? 'show-tips' : '') // eslint-disable-next-line react/no-array-index-key
|
|
142
|
+
,
|
|
143
|
+
key: index
|
|
144
|
+
}, e);
|
|
145
|
+
})) : '');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
AnimationWaiter.propTypes = {
|
|
149
|
+
animationData: _propTypes.default.any,
|
|
150
|
+
size: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
151
|
+
message: _propTypes.default.any,
|
|
152
|
+
messageDuration: _propTypes.default.number,
|
|
153
|
+
tips: _propTypes.default.array,
|
|
154
|
+
tipsDuration: _propTypes.default.number,
|
|
155
|
+
speed: _propTypes.default.number,
|
|
156
|
+
maybeDuration: _propTypes.default.number,
|
|
157
|
+
increaseSpeed: _propTypes.default.number
|
|
158
|
+
};
|
|
159
|
+
AnimationWaiter.defaultProps = {
|
|
160
|
+
animationData: null,
|
|
161
|
+
size: '',
|
|
162
|
+
message: '',
|
|
163
|
+
messageDuration: 5000,
|
|
164
|
+
tips: [],
|
|
165
|
+
tipsDuration: 5000,
|
|
166
|
+
speed: 1,
|
|
167
|
+
maybeDuration: 120000,
|
|
168
|
+
increaseSpeed: 0
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const Container = _styledComponents.default.div.withConfig({
|
|
172
|
+
displayName: "AnimationWaiter__Container",
|
|
173
|
+
componentId: "sc-1qcr25l-0"
|
|
174
|
+
})(["display:flex;justify-content:center;align-items:center;flex-direction:column;width:100%;height:100%;.waiter-message{font-weight:700;font-size:18px;line-height:22px;}.waiter-tips-container{position:relative;margin-top:auto;width:100%;.waiter-tips-block{position:absolute;bottom:0;left:0;width:100%;opacity:0;pointer-events:none;z-index:1;transform:translate(-20px,0);transition:all ease 0.4s;&.show-tips{opacity:1;pointer-events:auto;z-index:2;transform:translate(0,0);}}}.waiter-loading::after{display:inline-block;animation:dotty steps(1,end) 2s infinite;content:'';}@keyframes dotty{0%{content:'';}25%{content:'.';}50%{content:'..';}75%{content:'...';}100%{content:'';}}"]);
|
package/lib/index.js
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "Alert", {
|
|
|
21
21
|
return _Alert.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "AnimationWaiter", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _AnimationWaiter.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "Async", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function get() {
|
|
@@ -190,6 +196,8 @@ var _ActivityIndicator = _interopRequireDefault(require("./ActivityIndicator"));
|
|
|
190
196
|
|
|
191
197
|
var _Alert = _interopRequireDefault(require("./Alert"));
|
|
192
198
|
|
|
199
|
+
var _AnimationWaiter = _interopRequireDefault(require("./AnimationWaiter"));
|
|
200
|
+
|
|
193
201
|
var _Async = _interopRequireDefault(require("./Async"));
|
|
194
202
|
|
|
195
203
|
var _Badge = _interopRequireDefault(require("./Badge"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.13",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
"react": ">=16.12.0",
|
|
54
54
|
"react-ga": "^2.7.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "da903274c188ed5dbb9e318b1495af6faa5ce668",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@arcblock/icons": "^1.17.
|
|
59
|
-
"@arcblock/react-hooks": "^1.17.
|
|
58
|
+
"@arcblock/icons": "^1.17.13",
|
|
59
|
+
"@arcblock/react-hooks": "^1.17.13",
|
|
60
60
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
61
61
|
"@fontsource/lato": "^4.5.3",
|
|
62
62
|
"@material-ui/core": "^4.12.3",
|
|
63
63
|
"@material-ui/icons": "4.11.2",
|
|
64
64
|
"@solana/qr-code-styling": "^1.6.0-beta.0",
|
|
65
|
-
"axios": "^0.
|
|
65
|
+
"axios": "^0.21.2",
|
|
66
66
|
"base64-url": "^2.3.3",
|
|
67
67
|
"copy-to-clipboard": "^3.2.0",
|
|
68
68
|
"core-js": "^3.6.4",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"react-cookie-consent": "^6.4.1",
|
|
77
77
|
"react-helmet": "^6.1.0",
|
|
78
78
|
"react-intersection-observer": "^8.31.1",
|
|
79
|
+
"react-lottie-player": "^1.4.2",
|
|
79
80
|
"react-player": "^1.15.2",
|
|
80
81
|
"react-router-dom": "^5.1.2",
|
|
81
82
|
"react-shadow": "^19.0.2",
|