@arcblock/ux 2.7.19 → 2.7.21
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/es/BlockletContext/index.js +3 -2
- package/es/SessionManager/translation.js +1 -1
- package/es/SessionManager/user-info.js +33 -38
- package/es/Util/index.js +5 -5
- package/lib/BlockletContext/index.js +3 -2
- package/lib/SessionManager/translation.js +1 -1
- package/lib/SessionManager/user-info.js +33 -38
- package/lib/Util/index.js +5 -5
- package/package.json +4 -4
- package/src/BlockletContext/index.jsx +3 -2
- package/src/SessionManager/translation.js +1 -1
- package/src/SessionManager/user-info.jsx +22 -23
- package/src/Util/index.js +5 -5
@@ -22,7 +22,7 @@ function BlockletProvider({
|
|
22
22
|
const [blockletData, setBlockletData] = useState(null);
|
23
23
|
const getBlockleData = useMemoizedFn(async () => {
|
24
24
|
if (!baseUrl || window.location.href.startsWith(baseUrl)) {
|
25
|
-
|
25
|
+
throw new Error('no blocklet data');
|
26
26
|
}
|
27
27
|
const url = new URL('__blocklet__.js', baseUrl);
|
28
28
|
url.searchParams.set('type', 'json');
|
@@ -36,7 +36,8 @@ function BlockletProvider({
|
|
36
36
|
setBlockletData(data);
|
37
37
|
} catch {
|
38
38
|
// NOTICE: 如果获取指定 blockletData 失败,则使用 window.blocklet
|
39
|
-
|
39
|
+
const data = window.blocklet || window.env;
|
40
|
+
setBlockletData(data);
|
40
41
|
}
|
41
42
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
42
43
|
}, [baseUrl]);
|
@@ -19,7 +19,7 @@ export const translations = {
|
|
19
19
|
from: 'From',
|
20
20
|
addAnotherAccount: 'Add another account',
|
21
21
|
deleteAccountTitle: 'Remove this account ?',
|
22
|
-
deleteAccountContent: 'After delete account, you can add it
|
22
|
+
deleteAccountContent: 'After delete account, you can add it again',
|
23
23
|
confirm: 'Confirm',
|
24
24
|
cancel: 'Cancel',
|
25
25
|
noneMenu: 'Empty menu, maybe you should switch to another role'
|
@@ -32,7 +32,7 @@ export default function UserInfo({
|
|
32
32
|
session
|
33
33
|
});
|
34
34
|
const currentRole = useCreation(() => session.user?.passports?.find(item => item.name === session.user.role), [session?.user?.passports, session?.user?.role]);
|
35
|
-
const userEmail = useCreation(() => session.user?.email
|
35
|
+
const userEmail = useCreation(() => session.user?.email, [session?.user]);
|
36
36
|
const canEdit = useCreation(() => {
|
37
37
|
if (onSwitchProfile instanceof Function) {
|
38
38
|
if (switchProfile && hasBindWallet) {
|
@@ -92,43 +92,38 @@ export default function UserInfo({
|
|
92
92
|
overflow: 'hidden',
|
93
93
|
fontSize: '14px'
|
94
94
|
},
|
95
|
-
children: [/*#__PURE__*/
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
,
|
128
|
-
onDelete: onSwitchPassport,
|
129
|
-
onClick: onSwitchPassport,
|
130
|
-
"data-cy": "sessionManager-switch-passport-trigger"
|
131
|
-
})]
|
95
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
96
|
+
variant: "h5",
|
97
|
+
fontWeight: "bold",
|
98
|
+
sx: {
|
99
|
+
wordBreak: 'break-all',
|
100
|
+
lineHeight: 1
|
101
|
+
},
|
102
|
+
children: session.user.fullName
|
103
|
+
}), /*#__PURE__*/_jsx(Chip, {
|
104
|
+
label: currentRole?.title || session.user?.role.toUpperCase(),
|
105
|
+
size: "small",
|
106
|
+
variant: "outlined",
|
107
|
+
sx: {
|
108
|
+
height: 'auto',
|
109
|
+
marginRight: 0,
|
110
|
+
fontWeight: 'bold',
|
111
|
+
fontSize: '12px',
|
112
|
+
margin: '6px 0 4px 0'
|
113
|
+
},
|
114
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
115
|
+
icon: ShieldCheckIcon,
|
116
|
+
height: "0.8em"
|
117
|
+
}),
|
118
|
+
deleteIcon: /*#__PURE__*/_jsx(Icon, {
|
119
|
+
icon: ExpandMoreIcon,
|
120
|
+
height: "1em"
|
121
|
+
})
|
122
|
+
// HACK: 必须设置 onDelete 函数,deleteIcon 才能显示出来
|
123
|
+
,
|
124
|
+
onDelete: onSwitchPassport,
|
125
|
+
onClick: onSwitchPassport,
|
126
|
+
"data-cy": "sessionManager-switch-passport-trigger"
|
132
127
|
}), session.provider === 'auth0' ? walletDid ? /*#__PURE__*/_jsx(DID, {
|
133
128
|
responsive: false,
|
134
129
|
compact: true,
|
package/es/Util/index.js
CHANGED
@@ -130,7 +130,7 @@ export function setDateTool(tool) {
|
|
130
130
|
export function getDateTool() {
|
131
131
|
return dateTool;
|
132
132
|
}
|
133
|
-
const
|
133
|
+
const createDateFormatter = format => (date, {
|
134
134
|
locale,
|
135
135
|
tz
|
136
136
|
}) => {
|
@@ -157,13 +157,13 @@ const createDateFormater = format => (date, {
|
|
157
157
|
* @param {object} option
|
158
158
|
* @param {string} option.locale, default: en
|
159
159
|
* @param {string} option.tz, default: timzone
|
160
|
-
* @returns
|
160
|
+
* @returns formatted date string
|
161
161
|
*/
|
162
162
|
export function formatToDate(date, {
|
163
163
|
locale,
|
164
164
|
tz
|
165
165
|
} = {}) {
|
166
|
-
return
|
166
|
+
return createDateFormatter('ll')(date, {
|
167
167
|
locale,
|
168
168
|
tz
|
169
169
|
});
|
@@ -176,13 +176,13 @@ export function formatToDate(date, {
|
|
176
176
|
* @param {object} option
|
177
177
|
* @param {string} option.locale, default: en
|
178
178
|
* @param {string} option.tz, default: timzone
|
179
|
-
* @returns
|
179
|
+
* @returns formatted date string
|
180
180
|
*/
|
181
181
|
export function formatToDatetime(date, {
|
182
182
|
locale,
|
183
183
|
tz
|
184
184
|
} = {}) {
|
185
|
-
return
|
185
|
+
return createDateFormatter('lll')(date, {
|
186
186
|
locale,
|
187
187
|
tz
|
188
188
|
});
|
@@ -34,7 +34,7 @@ function BlockletProvider(_ref) {
|
|
34
34
|
const [blockletData, setBlockletData] = (0, _react.useState)(null);
|
35
35
|
const getBlockleData = (0, _ahooks.useMemoizedFn)(async () => {
|
36
36
|
if (!baseUrl || window.location.href.startsWith(baseUrl)) {
|
37
|
-
|
37
|
+
throw new Error('no blocklet data');
|
38
38
|
}
|
39
39
|
const url = new URL('__blocklet__.js', baseUrl);
|
40
40
|
url.searchParams.set('type', 'json');
|
@@ -48,7 +48,8 @@ function BlockletProvider(_ref) {
|
|
48
48
|
setBlockletData(data);
|
49
49
|
} catch (_unused) {
|
50
50
|
// NOTICE: 如果获取指定 blockletData 失败,则使用 window.blocklet
|
51
|
-
|
51
|
+
const data = window.blocklet || window.env;
|
52
|
+
setBlockletData(data);
|
52
53
|
}
|
53
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
54
55
|
}, [baseUrl]);
|
@@ -25,7 +25,7 @@ const translations = {
|
|
25
25
|
from: 'From',
|
26
26
|
addAnotherAccount: 'Add another account',
|
27
27
|
deleteAccountTitle: 'Remove this account ?',
|
28
|
-
deleteAccountContent: 'After delete account, you can add it
|
28
|
+
deleteAccountContent: 'After delete account, you can add it again',
|
29
29
|
confirm: 'Confirm',
|
30
30
|
cancel: 'Cancel',
|
31
31
|
noneMenu: 'Empty menu, maybe you should switch to another role'
|
@@ -47,7 +47,7 @@ function UserInfo(_ref) {
|
|
47
47
|
}, [session === null || session === void 0 ? void 0 : (_session$user3 = session.user) === null || _session$user3 === void 0 ? void 0 : _session$user3.passports, session === null || session === void 0 ? void 0 : (_session$user4 = session.user) === null || _session$user4 === void 0 ? void 0 : _session$user4.role]);
|
48
48
|
const userEmail = (0, _ahooks.useCreation)(() => {
|
49
49
|
var _session$user5;
|
50
|
-
return (
|
50
|
+
return (_session$user5 = session.user) === null || _session$user5 === void 0 ? void 0 : _session$user5.email;
|
51
51
|
}, [session === null || session === void 0 ? void 0 : session.user]);
|
52
52
|
const canEdit = (0, _ahooks.useCreation)(() => {
|
53
53
|
if (onSwitchProfile instanceof Function) {
|
@@ -108,43 +108,38 @@ function UserInfo(_ref) {
|
|
108
108
|
overflow: 'hidden',
|
109
109
|
fontSize: '14px'
|
110
110
|
},
|
111
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
,
|
144
|
-
onDelete: onSwitchPassport,
|
145
|
-
onClick: onSwitchPassport,
|
146
|
-
"data-cy": "sessionManager-switch-passport-trigger"
|
147
|
-
})]
|
111
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
112
|
+
variant: "h5",
|
113
|
+
fontWeight: "bold",
|
114
|
+
sx: {
|
115
|
+
wordBreak: 'break-all',
|
116
|
+
lineHeight: 1
|
117
|
+
},
|
118
|
+
children: session.user.fullName
|
119
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
|
120
|
+
label: (currentRole === null || currentRole === void 0 ? void 0 : currentRole.title) || ((_session$user6 = session.user) === null || _session$user6 === void 0 ? void 0 : _session$user6.role.toUpperCase()),
|
121
|
+
size: "small",
|
122
|
+
variant: "outlined",
|
123
|
+
sx: {
|
124
|
+
height: 'auto',
|
125
|
+
marginRight: 0,
|
126
|
+
fontWeight: 'bold',
|
127
|
+
fontSize: '12px',
|
128
|
+
margin: '6px 0 4px 0'
|
129
|
+
},
|
130
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
131
|
+
icon: _shieldCheck.default,
|
132
|
+
height: "0.8em"
|
133
|
+
}),
|
134
|
+
deleteIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
135
|
+
icon: _expandMore.default,
|
136
|
+
height: "1em"
|
137
|
+
})
|
138
|
+
// HACK: 必须设置 onDelete 函数,deleteIcon 才能显示出来
|
139
|
+
,
|
140
|
+
onDelete: onSwitchPassport,
|
141
|
+
onClick: onSwitchPassport,
|
142
|
+
"data-cy": "sessionManager-switch-passport-trigger"
|
148
143
|
}), session.provider === 'auth0' ? walletDid ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DID.default, {
|
149
144
|
responsive: false,
|
150
145
|
compact: true,
|
package/lib/Util/index.js
CHANGED
@@ -164,7 +164,7 @@ function setDateTool(tool) {
|
|
164
164
|
function getDateTool() {
|
165
165
|
return dateTool;
|
166
166
|
}
|
167
|
-
const
|
167
|
+
const createDateFormatter = format => (date, _ref2) => {
|
168
168
|
let {
|
169
169
|
locale,
|
170
170
|
tz
|
@@ -192,14 +192,14 @@ const createDateFormater = format => (date, _ref2) => {
|
|
192
192
|
* @param {object} option
|
193
193
|
* @param {string} option.locale, default: en
|
194
194
|
* @param {string} option.tz, default: timzone
|
195
|
-
* @returns
|
195
|
+
* @returns formatted date string
|
196
196
|
*/
|
197
197
|
function formatToDate(date) {
|
198
198
|
let {
|
199
199
|
locale,
|
200
200
|
tz
|
201
201
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
202
|
-
return
|
202
|
+
return createDateFormatter('ll')(date, {
|
203
203
|
locale,
|
204
204
|
tz
|
205
205
|
});
|
@@ -212,14 +212,14 @@ function formatToDate(date) {
|
|
212
212
|
* @param {object} option
|
213
213
|
* @param {string} option.locale, default: en
|
214
214
|
* @param {string} option.tz, default: timzone
|
215
|
-
* @returns
|
215
|
+
* @returns formatted date string
|
216
216
|
*/
|
217
217
|
function formatToDatetime(date) {
|
218
218
|
let {
|
219
219
|
locale,
|
220
220
|
tz
|
221
221
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
222
|
-
return
|
222
|
+
return createDateFormatter('lll')(date, {
|
223
223
|
locale,
|
224
224
|
tz
|
225
225
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.7.
|
3
|
+
"version": "2.7.21",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -322,11 +322,11 @@
|
|
322
322
|
"peerDependencies": {
|
323
323
|
"react": ">=18.1.0"
|
324
324
|
},
|
325
|
-
"gitHead": "
|
325
|
+
"gitHead": "e92f763c6f07c8adf341ffc8ffa417adb98c47fa",
|
326
326
|
"dependencies": {
|
327
327
|
"@arcblock/did-motif": "^1.1.13",
|
328
|
-
"@arcblock/icons": "^2.7.
|
329
|
-
"@arcblock/react-hooks": "^2.7.
|
328
|
+
"@arcblock/icons": "^2.7.21",
|
329
|
+
"@arcblock/react-hooks": "^2.7.21",
|
330
330
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
331
331
|
"@emotion/react": "^11.10.4",
|
332
332
|
"@emotion/styled": "^11.10.4",
|
@@ -17,7 +17,7 @@ function BlockletProvider({ children, baseUrl }) {
|
|
17
17
|
const [blockletData, setBlockletData] = useState(null);
|
18
18
|
const getBlockleData = useMemoizedFn(async () => {
|
19
19
|
if (!baseUrl || window.location.href.startsWith(baseUrl)) {
|
20
|
-
|
20
|
+
throw new Error('no blocklet data');
|
21
21
|
}
|
22
22
|
|
23
23
|
const url = new URL('__blocklet__.js', baseUrl);
|
@@ -32,7 +32,8 @@ function BlockletProvider({ children, baseUrl }) {
|
|
32
32
|
setBlockletData(data);
|
33
33
|
} catch {
|
34
34
|
// NOTICE: 如果获取指定 blockletData 失败,则使用 window.blocklet
|
35
|
-
|
35
|
+
const data = window.blocklet || window.env;
|
36
|
+
setBlockletData(data);
|
36
37
|
}
|
37
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
38
39
|
}, [baseUrl]);
|
@@ -19,7 +19,7 @@ export const translations = {
|
|
19
19
|
from: 'From',
|
20
20
|
addAnotherAccount: 'Add another account',
|
21
21
|
deleteAccountTitle: 'Remove this account ?',
|
22
|
-
deleteAccountContent: 'After delete account, you can add it
|
22
|
+
deleteAccountContent: 'After delete account, you can add it again',
|
23
23
|
confirm: 'Confirm',
|
24
24
|
cancel: 'Cancel',
|
25
25
|
noneMenu: 'Empty menu, maybe you should switch to another role',
|
@@ -24,7 +24,7 @@ export default function UserInfo({ session, locale, onSwitchProfile, onSwitchPas
|
|
24
24
|
() => session.user?.passports?.find((item) => item.name === session.user.role),
|
25
25
|
[session?.user?.passports, session?.user?.role]
|
26
26
|
);
|
27
|
-
const userEmail = useCreation(() => session.user?.email
|
27
|
+
const userEmail = useCreation(() => session.user?.email, [session?.user]);
|
28
28
|
|
29
29
|
const canEdit = useCreation(() => {
|
30
30
|
if (onSwitchProfile instanceof Function) {
|
@@ -79,28 +79,27 @@ export default function UserInfo({ session, locale, onSwitchProfile, onSwitchPas
|
|
79
79
|
<DidAvatar variant="circle" did={session.user.did} src={avatar} size={64} shape="circle" />
|
80
80
|
</Box>
|
81
81
|
<Box sx={{ flex: 1, position: 'static', overflow: 'hidden', fontSize: '14px' }}>
|
82
|
-
<
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
</Box>
|
82
|
+
<Typography variant="h5" fontWeight="bold" sx={{ wordBreak: 'break-all', lineHeight: 1 }}>
|
83
|
+
{session.user.fullName}
|
84
|
+
</Typography>
|
85
|
+
<Chip
|
86
|
+
label={currentRole?.title || session.user?.role.toUpperCase()}
|
87
|
+
size="small"
|
88
|
+
variant="outlined"
|
89
|
+
sx={{
|
90
|
+
height: 'auto',
|
91
|
+
marginRight: 0,
|
92
|
+
fontWeight: 'bold',
|
93
|
+
fontSize: '12px',
|
94
|
+
margin: '6px 0 4px 0',
|
95
|
+
}}
|
96
|
+
icon={<Icon icon={ShieldCheckIcon} height="0.8em" />}
|
97
|
+
deleteIcon={<Icon icon={ExpandMoreIcon} height="1em" />}
|
98
|
+
// HACK: 必须设置 onDelete 函数,deleteIcon 才能显示出来
|
99
|
+
onDelete={onSwitchPassport}
|
100
|
+
onClick={onSwitchPassport}
|
101
|
+
data-cy="sessionManager-switch-passport-trigger"
|
102
|
+
/>
|
104
103
|
{/* eslint-disable-next-line no-nested-ternary */}
|
105
104
|
{session.provider === 'auth0' ? (
|
106
105
|
walletDid ? (
|
package/src/Util/index.js
CHANGED
@@ -161,7 +161,7 @@ export function getDateTool() {
|
|
161
161
|
return dateTool;
|
162
162
|
}
|
163
163
|
|
164
|
-
const
|
164
|
+
const createDateFormatter =
|
165
165
|
(format) =>
|
166
166
|
(date, { locale, tz }) => {
|
167
167
|
if (dateTool === null) {
|
@@ -192,10 +192,10 @@ const createDateFormater =
|
|
192
192
|
* @param {object} option
|
193
193
|
* @param {string} option.locale, default: en
|
194
194
|
* @param {string} option.tz, default: timzone
|
195
|
-
* @returns
|
195
|
+
* @returns formatted date string
|
196
196
|
*/
|
197
197
|
export function formatToDate(date, { locale, tz } = {}) {
|
198
|
-
return
|
198
|
+
return createDateFormatter('ll')(date, { locale, tz });
|
199
199
|
}
|
200
200
|
|
201
201
|
/**
|
@@ -205,10 +205,10 @@ export function formatToDate(date, { locale, tz } = {}) {
|
|
205
205
|
* @param {object} option
|
206
206
|
* @param {string} option.locale, default: en
|
207
207
|
* @param {string} option.tz, default: timzone
|
208
|
-
* @returns
|
208
|
+
* @returns formatted date string
|
209
209
|
*/
|
210
210
|
export function formatToDatetime(date, { locale, tz } = {}) {
|
211
|
-
return
|
211
|
+
return createDateFormatter('lll')(date, { locale, tz });
|
212
212
|
}
|
213
213
|
|
214
214
|
export function detectWalletExtension() {
|