@arcblock/ux 1.17.16 → 1.17.19

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.
@@ -59,39 +59,37 @@ function AnimationWaiter(_ref) {
59
59
 
60
60
  const [tipsId, setTipsId] = (0, _react.useState)(0);
61
61
  const [currentSpeed, setCurrentSpeed] = (0, _react.useState)(speed);
62
- const [desc, setDesc] = (0, _react.useState)(''); // 动画的开始时间
62
+ const [messageId, setMessageId] = (0, _react.useState)(0); // 动画的开始时间
63
63
 
64
64
  const startTime = (0, _react.useRef)(new Date().getTime());
65
+
66
+ if (!Array.isArray(message)) {
67
+ // eslint-disable-next-line no-param-reassign
68
+ message = [message];
69
+ }
70
+
65
71
  (0, _react.useEffect)(() => {
66
72
  if (!message) {
67
73
  return;
68
74
  }
69
75
 
70
- let timer1;
71
- let msgId = 0;
72
-
73
- if (Array.isArray(message)) {
74
- setDesc(message[msgId]);
75
- timer1 = setInterval(() => {
76
- msgId++;
76
+ let msgIndex = 0;
77
+ const timer = setInterval(() => {
78
+ msgIndex++;
77
79
 
78
- if (msgId >= message.length) {
79
- if (messageLoop) {
80
- msgId = 0;
81
- } else {
82
- msgId = message.length - 1;
83
- }
80
+ if (msgIndex >= message.length) {
81
+ if (messageLoop) {
82
+ msgIndex = 0;
83
+ } else {
84
+ msgIndex = message.length - 1;
84
85
  }
86
+ }
85
87
 
86
- setDesc(message[msgId]);
87
- }, messageDuration);
88
- } else {
89
- setDesc(message);
90
- } // eslint-disable-next-line consistent-return
91
-
88
+ setMessageId(msgIndex);
89
+ }, messageDuration); // eslint-disable-next-line consistent-return
92
90
 
93
91
  return () => {
94
- clearInterval(timer1);
92
+ clearInterval(timer);
95
93
  };
96
94
  }, [message, messageDuration]); // tips
97
95
 
@@ -126,6 +124,19 @@ function AnimationWaiter(_ref) {
126
124
  }, 1000);
127
125
  return () => clearTimeout(timer);
128
126
  }, [currentSpeed]);
127
+
128
+ const getMsgClassName = index => {
129
+ let className = 'message-before';
130
+
131
+ if (messageId === index) {
132
+ className = 'show-message';
133
+ } else if (messageId < index) {
134
+ className = 'message-after';
135
+ }
136
+
137
+ return className;
138
+ };
139
+
129
140
  return /*#__PURE__*/_react.default.createElement(Container, rest, /*#__PURE__*/_react.default.createElement(_reactLottiePlayer.default, {
130
141
  loop: true,
131
142
  animationData: animationData || _defaultAnimation.default,
@@ -137,8 +148,16 @@ function AnimationWaiter(_ref) {
137
148
  }
138
149
  }), message && /*#__PURE__*/_react.default.createElement("div", {
139
150
  className: "waiter-message"
140
- }, desc, /*#__PURE__*/_react.default.createElement("span", {
141
- className: "waiter-loading"
151
+ }, message.map((text, index) => {
152
+ const className = getMsgClassName(index);
153
+ return /*#__PURE__*/_react.default.createElement("div", {
154
+ // eslint-disable-next-line react/no-array-index-key
155
+ key: index
156
+ }, /*#__PURE__*/_react.default.createElement("span", {
157
+ className: "message-block ".concat(className)
158
+ }, text), /*#__PURE__*/_react.default.createElement("span", {
159
+ className: "placeholder-message ".concat(className)
160
+ }, text));
142
161
  })), tips.length ? /*#__PURE__*/_react.default.createElement("div", {
143
162
  className: "waiter-tips-container"
144
163
  }, tips.map((e, index) => {
@@ -178,4 +197,4 @@ AnimationWaiter.defaultProps = {
178
197
  const Container = _styledComponents.default.div.withConfig({
179
198
  displayName: "AnimationWaiter__Container",
180
199
  componentId: "sc-1qcr25l-0"
181
- })(["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:'';}}"]);
200
+ })(["display:flex;justify-content:center;align-items:center;flex-direction:column;width:100%;height:100%;.waiter-message{position:relative;width:100%;font-weight:700;font-size:18px;line-height:22px;text-align:center;overflow:hidden;.message-block{position:absolute;left:0;width:100%;opacity:0;transition:all ease 0.3s;user-select:none;&.message-before{transform:translate(-20px,0);}&.message-after{transform:translate(20px,0);}&.show-message{transform:translate(0,0);opacity:1;user-select:text;z-index:2;}}.placeholder-message{user-select:none;display:none;opacity:0;&.show-message{display:block;}}}.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);}}}"]);
@@ -94,7 +94,7 @@ Header.defaultProps = {
94
94
  const Root = _styledComponents.default.div.withConfig({
95
95
  displayName: "header__Root",
96
96
  componentId: "sc-15qnwg1-0"
97
- })(["position:relative;z-index:", ";font-size:14px;background:", ";.header-container{display:flex;align-items:center;height:64px;padding:8px 16px;}.header-logo{display:inline-flex;justify-content:center;position:relative;height:40px;margin-right:16px;img,svg{width:auto;height:100%;}> a{height:100%;line-height:1;}> a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.header-brand{display:flex;flex-direction:column;flex-shrink:0;margin-right:16px;.header-brand-title{display:flex;align-items:center;h2{font-size:16px;}.header-brand-addon{margin-left:8px;}}.header-brand-desc{color:#9397a1;}}.header-addons{display:flex;align-items:center;}", "{.header-brand{margin-right:12px;.header-brand-title{h2{font-size:14px;}}}}", "{.header-container{height:56px;}.header-menu{display:inline-block;}.header-logo{height:32px;}.header-brand{display:none;}}"], props => props.$theme.zIndex.drawer + 1, props => props.$theme.palette.common.white, props => props.$theme.breakpoints.down('md'), props => props.$theme.breakpoints.down('sm'));
97
+ })(["position:relative;z-index:", ";font-size:14px;background:", ";.header-container{display:flex;align-items:center;height:64px;padding:8px 0;}.header-logo{display:inline-flex;justify-content:center;position:relative;height:40px;margin-right:16px;img,svg{width:auto;height:100%;}> a{height:100%;line-height:1;}> a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.header-brand{display:flex;flex-direction:column;flex-shrink:0;margin-right:16px;.header-brand-title{display:flex;align-items:center;h2{font-size:16px;}.header-brand-addon{margin-left:8px;}}.header-brand-desc{color:#9397a1;}}.header-addons{display:flex;align-items:center;}", "{.header-brand{margin-right:12px;.header-brand-title{h2{font-size:14px;}}}}", "{.header-container{height:56px;}.header-menu{display:inline-block;}.header-logo{height:32px;}.header-brand{display:none;}}"], props => props.$theme.zIndex.drawer + 1, props => props.$theme.palette.common.white, props => props.$theme.breakpoints.down('md'), props => props.$theme.breakpoints.down('sm'));
98
98
 
99
99
  var _default = Header;
100
100
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "1.17.16",
3
+ "version": "1.17.19",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -53,10 +53,10 @@
53
53
  "react": ">=16.12.0",
54
54
  "react-ga": "^2.7.0"
55
55
  },
56
- "gitHead": "acab741ed856df9b4def509821a1ab6217350625",
56
+ "gitHead": "fc295196e19ee7355a7dacab7f85fd9694cd2eb9",
57
57
  "dependencies": {
58
- "@arcblock/icons": "^1.17.16",
59
- "@arcblock/react-hooks": "^1.17.16",
58
+ "@arcblock/icons": "^1.17.19",
59
+ "@arcblock/react-hooks": "^1.17.19",
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",
@@ -34,38 +34,37 @@ export default function AnimationWaiter({
34
34
  }) {
35
35
  const [tipsId, setTipsId] = useState(0);
36
36
  const [currentSpeed, setCurrentSpeed] = useState(speed);
37
- const [desc, setDesc] = useState('');
37
+ const [messageId, setMessageId] = useState(0);
38
38
  // 动画的开始时间
39
39
  const startTime = useRef(new Date().getTime());
40
40
 
41
+ if (!Array.isArray(message)) {
42
+ // eslint-disable-next-line no-param-reassign
43
+ message = [message];
44
+ }
45
+
41
46
  useEffect(() => {
42
47
  if (!message) {
43
48
  return;
44
49
  }
45
50
 
46
- let timer1;
47
- let msgId = 0;
48
-
49
- if (Array.isArray(message)) {
50
- setDesc(message[msgId]);
51
- timer1 = setInterval(() => {
52
- msgId++;
53
- if (msgId >= message.length) {
54
- if (messageLoop) {
55
- msgId = 0;
56
- } else {
57
- msgId = message.length - 1;
58
- }
51
+ let msgIndex = 0;
52
+
53
+ const timer = setInterval(() => {
54
+ msgIndex++;
55
+ if (msgIndex >= message.length) {
56
+ if (messageLoop) {
57
+ msgIndex = 0;
58
+ } else {
59
+ msgIndex = message.length - 1;
59
60
  }
60
- setDesc(message[msgId]);
61
- }, messageDuration);
62
- } else {
63
- setDesc(message);
64
- }
61
+ }
62
+ setMessageId(msgIndex);
63
+ }, messageDuration);
65
64
 
66
65
  // eslint-disable-next-line consistent-return
67
66
  return () => {
68
- clearInterval(timer1);
67
+ clearInterval(timer);
69
68
  };
70
69
  }, [message, messageDuration]);
71
70
 
@@ -106,6 +105,16 @@ export default function AnimationWaiter({
106
105
  return () => clearTimeout(timer);
107
106
  }, [currentSpeed]);
108
107
 
108
+ const getMsgClassName = index => {
109
+ let className = 'message-before';
110
+ if (messageId === index) {
111
+ className = 'show-message';
112
+ } else if (messageId < index) {
113
+ className = 'message-after';
114
+ }
115
+ return className;
116
+ };
117
+
109
118
  return (
110
119
  <Container {...rest}>
111
120
  <Lottie
@@ -120,8 +129,17 @@ export default function AnimationWaiter({
120
129
  />
121
130
  {message && (
122
131
  <div className="waiter-message">
123
- {desc}
124
- <span className="waiter-loading" />
132
+ {message.map((text, index) => {
133
+ const className = getMsgClassName(index);
134
+ return (
135
+ <div
136
+ // eslint-disable-next-line react/no-array-index-key
137
+ key={index}>
138
+ <span className={`message-block ${className}`}>{text}</span>
139
+ <span className={`placeholder-message ${className}`}>{text}</span>
140
+ </div>
141
+ );
142
+ })}
125
143
  </div>
126
144
  )}
127
145
 
@@ -180,9 +198,42 @@ const Container = styled.div`
180
198
  height: 100%;
181
199
 
182
200
  .waiter-message {
201
+ position: relative;
202
+ width: 100%;
183
203
  font-weight: 700;
184
204
  font-size: 18px;
185
205
  line-height: 22px;
206
+ text-align: center;
207
+ overflow: hidden;
208
+ .message-block {
209
+ position: absolute;
210
+ left: 0;
211
+ width: 100%;
212
+ opacity: 0;
213
+ transition: all ease 0.3s;
214
+ user-select: none;
215
+ &.message-before {
216
+ transform: translate(-20px, 0);
217
+ }
218
+ &.message-after {
219
+ transform: translate(20px, 0);
220
+ }
221
+ &.show-message {
222
+ transform: translate(0, 0);
223
+ opacity: 1;
224
+ user-select: text;
225
+ z-index: 2;
226
+ }
227
+ }
228
+
229
+ .placeholder-message {
230
+ user-select: none;
231
+ display: none;
232
+ opacity: 0;
233
+ &.show-message {
234
+ display: block;
235
+ }
236
+ }
186
237
  }
187
238
 
188
239
  .waiter-tips-container {
@@ -207,28 +258,4 @@ const Container = styled.div`
207
258
  }
208
259
  }
209
260
  }
210
-
211
- .waiter-loading::after {
212
- display: inline-block;
213
- animation: dotty steps(1, end) 2s infinite;
214
- content: '';
215
- }
216
-
217
- @keyframes dotty {
218
- 0% {
219
- content: '';
220
- }
221
- 25% {
222
- content: '.';
223
- }
224
- 50% {
225
- content: '..';
226
- }
227
- 75% {
228
- content: '...';
229
- }
230
- 100% {
231
- content: '';
232
- }
233
- }
234
261
  `;
@@ -78,7 +78,7 @@ const Root = styled.div`
78
78
  display: flex;
79
79
  align-items: center;
80
80
  height: 64px;
81
- padding: 8px 16px;
81
+ padding: 8px 0;
82
82
  }
83
83
  .header-logo {
84
84
  display: inline-flex;