@arcblock/ux 2.5.67 → 2.6.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.
@@ -132,6 +132,11 @@ function SessionManager(_ref) {
132
132
  provider: key
133
133
  });
134
134
  }).filter(item => item.enabled);
135
+ const isFirstLoading = (0, _react.useMemo)(() => {
136
+ // eslint-disable-next-line react/prop-types
137
+ return (session === null || session === void 0 ? void 0 : session.initialized) === false && (session === null || session === void 0 ? void 0 : session.loading) === true;
138
+ // eslint-disable-next-line react/prop-types
139
+ }, [session === null || session === void 0 ? void 0 : session.initialized, session === null || session === void 0 ? void 0 : session.loading]);
135
140
  if (!session.user) {
136
141
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
137
142
  children: [showText ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Button, _objectSpread(_objectSpread({
@@ -147,7 +152,7 @@ function SessionManager(_ref) {
147
152
  "aria-label": "login button"
148
153
  }, rest), {}, {
149
154
  "data-cy": "sessionManager-login",
150
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Account.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
155
+ children: [isFirstLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Account.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
151
156
  style: {
152
157
  lineHeight: '25px'
153
158
  },
@@ -159,7 +164,13 @@ function SessionManager(_ref) {
159
164
  onClick: _onLogin,
160
165
  "data-cy": "sessionManager-login",
161
166
  size: "medium",
162
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Account.default, {
167
+ children: isFirstLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
168
+ style: {
169
+ width: size - 4,
170
+ height: size - 4,
171
+ color: dark ? '#fff' : ''
172
+ }
173
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Account.default, {
163
174
  style: {
164
175
  width: size,
165
176
  height: size,
@@ -184,7 +195,9 @@ function SessionManager(_ref) {
184
195
  setUserOpen(false);
185
196
  }
186
197
  function _onLogin() {
187
- session.login(onLogin);
198
+ if (!isFirstLoading) {
199
+ session.login(onLogin);
200
+ }
188
201
  }
189
202
  function _onLogout() {
190
203
  session.logout(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.5.67",
3
+ "version": "2.6.0",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -47,11 +47,11 @@
47
47
  "peerDependencies": {
48
48
  "react": ">=18.1.0"
49
49
  },
50
- "gitHead": "53a99f5789cb7be993f113c89a4213c04e8a48a6",
50
+ "gitHead": "e6daf0f39a887fc6f13e19b0a3f2d7847f498095",
51
51
  "dependencies": {
52
52
  "@arcblock/did-motif": "^1.1.13",
53
- "@arcblock/icons": "^2.5.67",
54
- "@arcblock/react-hooks": "^2.5.67",
53
+ "@arcblock/icons": "^2.6.0",
54
+ "@arcblock/react-hooks": "^2.6.0",
55
55
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
56
56
  "@emotion/react": "^11.10.4",
57
57
  "@emotion/styled": "^11.10.4",
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable react/jsx-no-bind */
3
3
  import { useMemo, useRef, useState } from 'react';
4
4
  import PropTypes from 'prop-types';
5
- import { IconButton, MenuList, MenuItem, SvgIcon, Button, Chip } from '@mui/material';
5
+ import { IconButton, MenuList, MenuItem, SvgIcon, Button, Chip, CircularProgress } from '@mui/material';
6
6
  import AccountIcon from '@arcblock/icons/lib/Account';
7
7
  import ShieldCheck from 'mdi-material-ui/ShieldCheck';
8
8
  import OpenInIcon from '@arcblock/icons/lib/OpenIn';
@@ -104,6 +104,12 @@ function SessionManager({
104
104
  })
105
105
  .filter((item) => item.enabled);
106
106
 
107
+ const isFirstLoading = useMemo(() => {
108
+ // eslint-disable-next-line react/prop-types
109
+ return session?.initialized === false && session?.loading === true;
110
+ // eslint-disable-next-line react/prop-types
111
+ }, [session?.initialized, session?.loading]);
112
+
107
113
  if (!session.user) {
108
114
  return (
109
115
  <>
@@ -116,12 +122,16 @@ function SessionManager({
116
122
  aria-label="login button"
117
123
  {...rest}
118
124
  data-cy="sessionManager-login">
119
- <AccountIcon />
125
+ {isFirstLoading ? <CircularProgress /> : <AccountIcon />}
120
126
  <span style={{ lineHeight: '25px' }}>{translation.connect}</span>
121
127
  </Button>
122
128
  ) : (
123
129
  <IconButton ref={userAnchorRef} {...rest} onClick={_onLogin} data-cy="sessionManager-login" size="medium">
124
- <AccountIcon style={{ width: size, height: size, color: dark ? '#fff' : '' }} />
130
+ {isFirstLoading ? (
131
+ <CircularProgress style={{ width: size - 4, height: size - 4, color: dark ? '#fff' : '' }} />
132
+ ) : (
133
+ <AccountIcon style={{ width: size, height: size, color: dark ? '#fff' : '' }} />
134
+ )}
125
135
  </IconButton>
126
136
  )}
127
137
 
@@ -142,7 +152,9 @@ function SessionManager({
142
152
  }
143
153
 
144
154
  function _onLogin() {
145
- session.login(onLogin);
155
+ if (!isFirstLoading) {
156
+ session.login(onLogin);
157
+ }
146
158
  }
147
159
  function _onLogout() {
148
160
  session.logout((...args) => {