@blocklet/ui-react 2.12.8 → 2.12.10

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.
Files changed (54) hide show
  1. package/lib/@types/index.d.ts +34 -0
  2. package/lib/@types/index.js +16 -0
  3. package/lib/@types/shims.d.ts +1 -0
  4. package/lib/UserCenter/components/config-profile.js +23 -1
  5. package/lib/UserCenter/components/editable-field.d.ts +22 -0
  6. package/lib/UserCenter/components/editable-field.js +159 -0
  7. package/lib/UserCenter/components/nft.d.ts +4 -0
  8. package/lib/UserCenter/components/nft.js +93 -0
  9. package/lib/UserCenter/components/settings.js +32 -15
  10. package/lib/UserCenter/components/status-selector/duration-menu.d.ts +9 -0
  11. package/lib/UserCenter/components/status-selector/duration-menu.js +75 -0
  12. package/lib/UserCenter/components/status-selector/index.d.ts +9 -0
  13. package/lib/UserCenter/components/status-selector/index.js +39 -0
  14. package/lib/UserCenter/components/status-selector/menu-item.d.ts +24 -0
  15. package/lib/UserCenter/components/status-selector/menu-item.js +24 -0
  16. package/lib/UserCenter/components/user-center.js +119 -122
  17. package/lib/UserCenter/components/user-info/clock.d.ts +4 -0
  18. package/lib/UserCenter/components/user-info/clock.js +23 -0
  19. package/lib/UserCenter/components/user-info/link-preview-input.d.ts +5 -0
  20. package/lib/UserCenter/components/user-info/link-preview-input.js +181 -0
  21. package/lib/UserCenter/components/user-info/metadata.d.ts +7 -0
  22. package/lib/UserCenter/components/user-info/metadata.js +458 -0
  23. package/lib/UserCenter/components/user-info/switch-role.js +2 -3
  24. package/lib/UserCenter/components/user-info/user-basic-info.d.ts +2 -0
  25. package/lib/UserCenter/components/user-info/user-basic-info.js +159 -90
  26. package/lib/UserCenter/components/user-info/user-info.js +2 -16
  27. package/lib/UserCenter/components/user-info/user-status.d.ts +8 -0
  28. package/lib/UserCenter/components/user-info/user-status.js +153 -0
  29. package/lib/UserCenter/components/user-info/utils.d.ts +19 -0
  30. package/lib/UserCenter/components/user-info/utils.js +86 -0
  31. package/lib/UserCenter/libs/locales.d.ts +65 -0
  32. package/lib/UserCenter/libs/locales.js +67 -2
  33. package/lib/UserSessions/components/user-sessions.js +48 -14
  34. package/package.json +8 -5
  35. package/src/@types/index.ts +39 -0
  36. package/src/@types/shims.d.ts +1 -0
  37. package/src/UserCenter/components/config-profile.tsx +20 -1
  38. package/src/UserCenter/components/editable-field.tsx +180 -0
  39. package/src/UserCenter/components/nft.tsx +122 -0
  40. package/src/UserCenter/components/settings.tsx +16 -4
  41. package/src/UserCenter/components/status-selector/duration-menu.tsx +87 -0
  42. package/src/UserCenter/components/status-selector/index.tsx +52 -0
  43. package/src/UserCenter/components/status-selector/menu-item.tsx +52 -0
  44. package/src/UserCenter/components/user-center.tsx +104 -103
  45. package/src/UserCenter/components/user-info/clock.tsx +29 -0
  46. package/src/UserCenter/components/user-info/link-preview-input.tsx +227 -0
  47. package/src/UserCenter/components/user-info/metadata.tsx +465 -0
  48. package/src/UserCenter/components/user-info/switch-role.tsx +3 -3
  49. package/src/UserCenter/components/user-info/user-basic-info.tsx +150 -87
  50. package/src/UserCenter/components/user-info/user-info.tsx +6 -16
  51. package/src/UserCenter/components/user-info/user-status.tsx +182 -0
  52. package/src/UserCenter/components/user-info/utils.ts +114 -0
  53. package/src/UserCenter/libs/locales.ts +65 -0
  54. package/src/UserSessions/components/user-sessions.tsx +68 -18
@@ -39,7 +39,10 @@ export const translations = {
39
39
  required: '必填的',
40
40
  invalid: '无效',
41
41
  setting: '设置',
42
+ save: '保存',
42
43
  profile: '信息',
44
+ nft: 'NFTs',
45
+ noNFT: '暂无 NFT',
43
46
  },
44
47
  toPublic: '公开 “{name}” 页面',
45
48
  currentPassport: '当前使用的通行证',
@@ -96,6 +99,35 @@ export const translations = {
96
99
  title: '通用设置',
97
100
  locale: '偏好语言',
98
101
  },
102
+ userStatus: {
103
+ Online: '在线',
104
+ Meeting: '开会中',
105
+ Community: '通勤中',
106
+ Holiday: '休假',
107
+ OffSick: '病假',
108
+ WorkingRemotely: '远程工作',
109
+ duration: {
110
+ ThirtyMinutes: '30分钟',
111
+ OneHour: '1小时',
112
+ FourHours: '4小时',
113
+ Today: '今天',
114
+ ThisWeek: '本周',
115
+ },
116
+ },
117
+ profile: {
118
+ addLink: '添加连接',
119
+ location: '位置',
120
+ timezone: '时区',
121
+ setStatus: '设置状态',
122
+ localTime: '当地时间:',
123
+ email: '邮箱地址',
124
+ emailInvalid: '邮箱格式不正确',
125
+ phone: '电话号码',
126
+ phoneInvalid: '电话号码格式不正确',
127
+ editProfile: '编辑资料',
128
+ removeStatusAfter: '移除状态',
129
+ justForYou: '仅对您可见',
130
+ },
99
131
  },
100
132
  en: {
101
133
  settings: 'Settings',
@@ -137,7 +169,10 @@ export const translations = {
137
169
  required: 'Required',
138
170
  invalid: 'Invalid',
139
171
  setting: 'Settings',
172
+ save: 'Save',
140
173
  profile: 'Profile',
174
+ nft: 'NFTs',
175
+ noNFT: 'No NFT',
141
176
  },
142
177
  toPublic: 'Public "{name}" page',
143
178
  currentPassport: 'Passport currently in use',
@@ -194,5 +229,35 @@ export const translations = {
194
229
  title: 'Common Settings',
195
230
  locale: 'Preferred language',
196
231
  },
232
+ userStatus: {
233
+ Online: 'Online',
234
+ Meeting: 'In a Meeting',
235
+ Community: 'Commuting',
236
+ Holiday: 'On Holiday',
237
+ OffSick: 'Off Sick',
238
+ WorkingRemotely: 'Working Remotely',
239
+ duration: {
240
+ ThirtyMinutes: '30 minutes',
241
+ OneHour: '1 hour',
242
+ FourHours: '4 hours',
243
+ Today: 'Today',
244
+ ThisWeek: 'This Week',
245
+ },
246
+ },
247
+ profile: {
248
+ addLink: 'Add link',
249
+ location: 'Location',
250
+ timezone: 'Timezone',
251
+ setStatus: 'Set a Status',
252
+ localTime: 'Local Time: ',
253
+ email: 'Email',
254
+ emailInvalid: 'Email is invalid',
255
+ phone: 'Phone',
256
+ phoneInvalid: 'Phone number is invalid',
257
+ editProfile: 'Edit Profile',
258
+ removeStatusAfter: 'Remove status after',
259
+ justForYou: 'Visible to you only',
260
+ maxInputLength: 'Max input length is',
261
+ },
197
262
  },
198
263
  };
@@ -9,6 +9,7 @@ import sortBy from 'lodash/sortBy';
9
9
  import UAParser from 'ua-parser-js';
10
10
  import { getVisitorId } from '@arcblock/ux/lib/Util';
11
11
  import { useConfirm } from '@arcblock/ux/lib/Dialog';
12
+ import { temp as colors } from '@arcblock/ux/lib/Colors';
12
13
  import pAll from 'p-all';
13
14
  import PQueue from 'p-queue';
14
15
  import { Box, Button, CircularProgress, Tooltip, Typography, useMediaQuery } from '@mui/material';
@@ -34,7 +35,7 @@ const parseUa = (ua: string) => {
34
35
 
35
36
  const queue = new PQueue({ concurrency: 1 });
36
37
 
37
- const UserSessionIp = memo(({ userSession }: { userSession: any }) => {
38
+ const UserSessionIp = memo(({ userSession, isMobile = false }: { userSession: any; isMobile: boolean }) => {
38
39
  const currentState = useReactive({
39
40
  loading: true,
40
41
  ipRegion: '',
@@ -53,7 +54,7 @@ const UserSessionIp = memo(({ userSession }: { userSession: any }) => {
53
54
  }, [currentState, userSession.lastLoginIp]);
54
55
 
55
56
  return (
56
- <Box>
57
+ <Box {...(isMobile && { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 1 })}>
57
58
  {currentState.ipRegion ? (
58
59
  <>
59
60
  <Typography variant="body2">{currentState.ipRegion}</Typography>
@@ -199,7 +200,11 @@ export default function UserSessions({
199
200
  customBodyRenderLite: (rawIndex: number) => {
200
201
  const x = safeData[rawIndex];
201
202
  const result = parseUa(x.ua);
202
- return <Box>{[result.os?.name, result.os?.version].filter(Boolean).join('/') || t('unknown')}</Box>;
203
+ return (
204
+ <Box sx={isMobile ? { textAlign: 'right' } : {}}>
205
+ {[result.os?.name, result.os?.version].filter(Boolean).join('/') || t('unknown')}
206
+ </Box>
207
+ );
203
208
  },
204
209
  },
205
210
  },
@@ -210,7 +215,11 @@ export default function UserSessions({
210
215
  customBodyRenderLite: (rawIndex: number) => {
211
216
  const x = safeData[rawIndex];
212
217
  const result = parseUa(x.ua);
213
- return <Box>{[result.browser?.name, result.browser?.version].filter(Boolean).join('/') || t('unknown')}</Box>;
218
+ return (
219
+ <Box sx={isMobile ? { textAlign: 'right' } : {}}>
220
+ {[result.browser?.name, result.browser?.version].filter(Boolean).join('/') || t('unknown')}
221
+ </Box>
222
+ );
214
223
  },
215
224
  },
216
225
  },
@@ -220,7 +229,7 @@ export default function UserSessions({
220
229
  options: {
221
230
  customBodyRenderLite: (rawIndex: number) => {
222
231
  const x = safeData[rawIndex];
223
- return <Box>{x.extra?.walletOS || t('unknown')}</Box>;
232
+ return <Box sx={isMobile ? { textAlign: 'right' } : {}}>{x.extra?.walletOS || t('unknown')}</Box>;
224
233
  },
225
234
  },
226
235
  },
@@ -231,7 +240,7 @@ export default function UserSessions({
231
240
  customBodyRenderLite: (rawIndex: number) => {
232
241
  const x = safeData[rawIndex];
233
242
  return (
234
- <Box sx={{ minWidth: 150, maxWidth: 250 }}>
243
+ <Box sx={{ minWidth: 150, maxWidth: 250, ...(isMobile && { textAlign: 'right' }) }}>
235
244
  <UserSessionInfo sessionUser={x.user} user={user} />
236
245
  </Box>
237
246
  );
@@ -244,10 +253,14 @@ export default function UserSessions({
244
253
  options: {
245
254
  customBodyRenderLite: (rawIndex: number) => {
246
255
  const x = safeData[rawIndex];
247
- return x.createdAt ? (
248
- <RelativeTime value={x.createdAt} relativeRange={3 * 86400 * 1000} locale={locale} />
249
- ) : (
250
- t('unknown')
256
+ return (
257
+ <Box sx={isMobile ? { textAlign: 'right' } : {}}>
258
+ {x.createdAt ? (
259
+ <RelativeTime value={x.createdAt} relativeRange={3 * 86400 * 1000} locale={locale} />
260
+ ) : (
261
+ t('unknown')
262
+ )}
263
+ </Box>
251
264
  );
252
265
  },
253
266
  },
@@ -258,10 +271,14 @@ export default function UserSessions({
258
271
  options: {
259
272
  customBodyRenderLite: (rawIndex: number) => {
260
273
  const x = safeData[rawIndex];
261
- return x.status === 'expired' ? (
262
- t('expired')
263
- ) : (
264
- <RelativeTime value={x.updatedAt} relativeRange={3 * 86400 * 1000} locale={locale} />
274
+ return (
275
+ <Box sx={isMobile ? { textAlign: 'right' } : {}}>
276
+ {x.status === 'expired' ? (
277
+ t('expired')
278
+ ) : (
279
+ <RelativeTime value={x.updatedAt} relativeRange={3 * 86400 * 1000} locale={locale} />
280
+ )}
281
+ </Box>
265
282
  );
266
283
  },
267
284
  },
@@ -272,7 +289,7 @@ export default function UserSessions({
272
289
  options: {
273
290
  customBodyRenderLite: (rawIndex: number) => {
274
291
  const x = safeData[rawIndex];
275
- return <UserSessionIp userSession={x} />;
292
+ return <UserSessionIp userSession={x} isMobile={isMobile} />;
276
293
  },
277
294
  },
278
295
  },
@@ -283,11 +300,12 @@ export default function UserSessions({
283
300
  customBodyRenderLite: (rawIndex: number) => {
284
301
  const x = safeData[rawIndex];
285
302
  return (
286
- <Box>
303
+ <Box sx={isMobile ? { textAlign: 'right' } : {}}>
287
304
  <Button
288
305
  sx={{
289
306
  whiteSpace: 'nowrap',
290
- fontSize: '12px',
307
+ fontSize: '12px !important',
308
+ lineHeight: '1.25',
291
309
  px: 1,
292
310
  }}
293
311
  disabled={currentVisitorId === x.visitorId}
@@ -310,14 +328,45 @@ export default function UserSessions({
310
328
  ].filter(Boolean);
311
329
  return (
312
330
  <Box
331
+ className="pc-user-sessions"
313
332
  sx={{
314
- maxWidth: isMobile ? 'unset' : isLg ? 'calc(100vw - 300px)' : '920px',
333
+ maxWidth: isMobile ? 'unset' : isLg ? 'calc(100vw - 300px)' : '100%',
334
+ ...(isMobile && {
335
+ '.pc-user-sessions-table > div:nth-child(2)': {
336
+ border: `1px solid ${colors.dividerColor}`,
337
+ borderRadius: '8px',
338
+ },
339
+ }),
315
340
  '.MuiTableCell-head': {
316
341
  whiteSpace: 'nowrap',
317
342
  fontWeight: 'bold',
318
343
  },
344
+ '.MuiTableRow-root': {
345
+ border: 'unset',
346
+ '&:nth-child(even)': {
347
+ backgroundColor: '#F9FAFB',
348
+ '&:hover': {
349
+ backgroundColor: '#F9FAFB !important',
350
+ },
351
+ },
352
+ },
353
+ '.MuiTableRow-hover': {
354
+ '&:hover': {
355
+ backgroundColor: 'inherit !important',
356
+ },
357
+ },
319
358
  '.MuiTableCell-root': {
320
359
  paddingRight: '8px',
360
+ paddingLeft: '8px',
361
+ ...(isMobile && {
362
+ padding: '8px !important',
363
+ '&:first-child': {
364
+ paddingTop: '20px!important',
365
+ },
366
+ '&:last-child': {
367
+ paddingBottom: '20px!important',
368
+ },
369
+ }),
321
370
  },
322
371
  }}>
323
372
  {confirmHolder}
@@ -330,6 +379,7 @@ export default function UserSessions({
330
379
  customButtons={customButtons}
331
380
  options={tableOptions}
332
381
  loading={pageState.loading}
382
+ className="pc-user-sessions-table"
333
383
  />
334
384
  </Box>
335
385
  );