@blocklet/ui-react 2.9.90 → 2.10.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.
- package/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.translations = void 0;
|
|
7
|
-
const translations = exports.translations = {
|
|
1
|
+
export const translations = {
|
|
8
2
|
zh: {
|
|
9
3
|
confirm: "\u786E\u8BA4",
|
|
10
4
|
cancel: "\u53D6\u6D88",
|
|
@@ -61,4 +55,4 @@ const translations = exports.translations = {
|
|
|
61
55
|
logoutAllSession: "Logout all sessions",
|
|
62
56
|
logoutAllSessionConfirm: "Are you sure to logout all sessions?"
|
|
63
57
|
}
|
|
64
|
-
};
|
|
58
|
+
};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.batchIp2Region = batchIp2Region;
|
|
7
|
-
exports.ip2Region = ip2Region;
|
|
8
1
|
const RESERVED_IP = "Reserved IP";
|
|
9
2
|
const IP_REGION_CACHE = "ip-region-cache";
|
|
10
3
|
async function getIpRegionFromIpApi(ip) {
|
|
@@ -35,7 +28,7 @@ async function getIpRegionFromIpSb(ip) {
|
|
|
35
28
|
}
|
|
36
29
|
return region;
|
|
37
30
|
}
|
|
38
|
-
async function ip2Region(ip) {
|
|
31
|
+
export async function ip2Region(ip) {
|
|
39
32
|
let region = "";
|
|
40
33
|
let ipRegionCache = {};
|
|
41
34
|
try {
|
|
@@ -75,6 +68,6 @@ async function ip2Region(ip) {
|
|
|
75
68
|
}
|
|
76
69
|
return region;
|
|
77
70
|
}
|
|
78
|
-
async function batchIp2Region(ips) {
|
|
79
|
-
return Promise.all(ips.map(ip => ip2Region(ip)));
|
|
80
|
-
}
|
|
71
|
+
export async function batchIp2Region(ips) {
|
|
72
|
+
return Promise.all(ips.map((ip) => ip2Region(ip)));
|
|
73
|
+
}
|
package/lib/blocklets.js
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { mapRecursive, filterRecursive, isUrl } from './utils.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.publicPath = exports.parseNavigation = exports.getLocalizedNavigation = exports.formatTheme = exports.formatNavigation = exports.formatBlockletInfo = exports.filterValidNavItems = exports.filterNavByRole = void 0;
|
|
7
|
-
var _utils = require("./utils");
|
|
8
|
-
const publicPath = exports.publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
|
|
3
|
+
export const publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
|
|
9
4
|
|
|
10
5
|
/**
|
|
11
6
|
* 格式化 theme (目前仅考虑 background)
|
|
12
7
|
*/
|
|
13
|
-
const formatTheme = theme => {
|
|
14
|
-
const formatted = {
|
|
15
|
-
...theme
|
|
16
|
-
};
|
|
8
|
+
export const formatTheme = (theme) => {
|
|
9
|
+
const formatted = { ...theme };
|
|
17
10
|
const background = theme?.background;
|
|
18
11
|
if (typeof background === 'string') {
|
|
19
|
-
formatted.background = {
|
|
20
|
-
header: background,
|
|
21
|
-
footer: background,
|
|
22
|
-
default: background
|
|
23
|
-
};
|
|
12
|
+
formatted.background = { header: background, footer: background, default: background };
|
|
24
13
|
} else if (background && typeof background === 'object') {
|
|
25
14
|
formatted.background = {
|
|
26
15
|
header: background.header || background.default,
|
|
27
16
|
footer: background.footer || background.default,
|
|
28
|
-
default: background.default
|
|
17
|
+
default: background.default,
|
|
29
18
|
};
|
|
30
19
|
}
|
|
31
20
|
return formatted;
|
|
@@ -34,8 +23,7 @@ const formatTheme = theme => {
|
|
|
34
23
|
/**
|
|
35
24
|
* 获取指定 locale 对应的 navigation 数据, 仅考虑 zh/en
|
|
36
25
|
*/
|
|
37
|
-
|
|
38
|
-
const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
26
|
+
export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
39
27
|
if (!navigation?.length) {
|
|
40
28
|
return navigation;
|
|
41
29
|
}
|
|
@@ -53,7 +41,7 @@ const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
53
41
|
const getLink = (link, _locale) => {
|
|
54
42
|
if (typeof link === 'string') {
|
|
55
43
|
// http[s] 开头的 url
|
|
56
|
-
if (
|
|
44
|
+
if (isUrl(link)) {
|
|
57
45
|
const url = new URL(link);
|
|
58
46
|
url.searchParams.set('locale', _locale);
|
|
59
47
|
return url.href;
|
|
@@ -67,15 +55,19 @@ const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
67
55
|
}
|
|
68
56
|
return link;
|
|
69
57
|
};
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
58
|
+
return mapRecursive(
|
|
59
|
+
navigation,
|
|
60
|
+
(item) => {
|
|
61
|
+
return {
|
|
62
|
+
...item,
|
|
63
|
+
title: getTitle(item.title, locale),
|
|
64
|
+
// 仅对叶结点进行处理
|
|
65
|
+
link: !item.items?.length ? getLink(item.link, locale) : item.link,
|
|
66
|
+
_rawLink: item.link,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
'items'
|
|
70
|
+
);
|
|
79
71
|
};
|
|
80
72
|
|
|
81
73
|
/**
|
|
@@ -83,24 +75,29 @@ const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
83
75
|
*
|
|
84
76
|
* - role 统一为数组形式
|
|
85
77
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
78
|
+
export const formatNavigation = (navigation) => {
|
|
79
|
+
return mapRecursive(
|
|
80
|
+
navigation,
|
|
81
|
+
(item) => {
|
|
82
|
+
if (item.role) {
|
|
83
|
+
return {
|
|
84
|
+
...item,
|
|
85
|
+
role: Array.isArray(item.role) ? item.role : [item.role],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return item;
|
|
89
|
+
},
|
|
90
|
+
'items'
|
|
91
|
+
);
|
|
97
92
|
};
|
|
98
|
-
|
|
99
|
-
const parseNavigation = navigation => {
|
|
93
|
+
|
|
94
|
+
export const parseNavigation = (navigation) => {
|
|
100
95
|
if (!navigation?.length) {
|
|
101
96
|
return null;
|
|
102
97
|
}
|
|
98
|
+
|
|
103
99
|
const formattedNav = formatNavigation(navigation);
|
|
100
|
+
|
|
104
101
|
const sections = {
|
|
105
102
|
header: [],
|
|
106
103
|
footer: [],
|
|
@@ -112,17 +109,17 @@ const parseNavigation = navigation => {
|
|
|
112
109
|
dashboard: [],
|
|
113
110
|
// session manager menus
|
|
114
111
|
sessionManager: [],
|
|
115
|
-
userCenter: []
|
|
112
|
+
userCenter: [],
|
|
116
113
|
};
|
|
117
114
|
|
|
118
115
|
// 对 navigation 顶层元素按 section 分组
|
|
119
|
-
formattedNav.forEach(item => {
|
|
116
|
+
formattedNav.forEach((item) => {
|
|
120
117
|
// item#section 为空时, 表示只存在于 header
|
|
121
118
|
if (!item.section) {
|
|
122
119
|
sections.header.push(item);
|
|
123
120
|
// item 出现在指定几个 section 中 (array)
|
|
124
121
|
} else if (Array.isArray(item.section)) {
|
|
125
|
-
item.section.forEach(sectionKey => {
|
|
122
|
+
item.section.forEach((sectionKey) => {
|
|
126
123
|
sections[sectionKey]?.push(item);
|
|
127
124
|
});
|
|
128
125
|
// item 出现在指定的一个 section 中 (string)
|
|
@@ -130,20 +127,18 @@ const parseNavigation = navigation => {
|
|
|
130
127
|
sections[item.section]?.push(item);
|
|
131
128
|
}
|
|
132
129
|
});
|
|
130
|
+
|
|
133
131
|
return sections;
|
|
134
132
|
};
|
|
135
133
|
|
|
136
134
|
/**
|
|
137
135
|
* 格式化 blocklet info 数据
|
|
138
136
|
*/
|
|
139
|
-
|
|
140
|
-
const formatBlockletInfo = blockletInfo => {
|
|
137
|
+
export const formatBlockletInfo = (blockletInfo) => {
|
|
141
138
|
if (!blockletInfo) {
|
|
142
139
|
return null;
|
|
143
140
|
}
|
|
144
|
-
const formatted = {
|
|
145
|
-
...blockletInfo
|
|
146
|
-
};
|
|
141
|
+
const formatted = { ...blockletInfo };
|
|
147
142
|
// theme
|
|
148
143
|
formatted.theme = formatTheme(formatted.theme);
|
|
149
144
|
// navigation
|
|
@@ -154,9 +149,8 @@ const formatBlockletInfo = blockletInfo => {
|
|
|
154
149
|
/**
|
|
155
150
|
* 过滤掉无效结点 (无 link 且子元素为空)
|
|
156
151
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return (0, _utils.filterRecursive)(navigation, (item, context) => !!item.link || context.filteredChildren?.length, 'items');
|
|
152
|
+
export const filterValidNavItems = (navigation = []) => {
|
|
153
|
+
return filterRecursive(navigation, (item, context) => !!item.link || context.filteredChildren?.length, 'items');
|
|
160
154
|
};
|
|
161
155
|
|
|
162
156
|
/**
|
|
@@ -169,14 +163,16 @@ const filterValidNavItems = (navigation = []) => {
|
|
|
169
163
|
* @param {string} userRole 当前用户 role
|
|
170
164
|
* @returns 符合 role 权限的导航菜单数据
|
|
171
165
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
166
|
+
export const filterNavByRole = (nav, userRole) => {
|
|
167
|
+
return filterRecursive(
|
|
168
|
+
nav,
|
|
169
|
+
(item, context) => {
|
|
170
|
+
const isRoleMatched = !item.role || (userRole && item.role.includes(userRole));
|
|
171
|
+
if (!context.isLeaf) {
|
|
172
|
+
return isRoleMatched && context.filteredChildren?.length;
|
|
173
|
+
}
|
|
174
|
+
return isRoleMatched;
|
|
175
|
+
},
|
|
176
|
+
'items'
|
|
177
|
+
);
|
|
181
178
|
};
|
|
182
|
-
exports.filterNavByRole = filterNavByRole;
|
|
@@ -1,78 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _blocklets = require("../blocklets");
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function HeaderAddons({
|
|
20
|
-
formattedBlocklet,
|
|
21
|
-
addons,
|
|
22
|
-
sessionManagerProps
|
|
23
|
-
}) {
|
|
24
|
-
const sessionCtx = (0, _react.useContext)(_Session.SessionContext);
|
|
25
|
-
const {
|
|
26
|
-
locale
|
|
27
|
-
} = (0, _context.useLocaleContext)() || {};
|
|
28
|
-
const {
|
|
29
|
-
enableConnect = true,
|
|
30
|
-
enableLocale = true
|
|
31
|
-
} = formattedBlocklet;
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "iconify-icon";
|
|
3
|
+
import { useContext, createElement } from "react";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import { Fragment } from "react/jsx-runtime";
|
|
6
|
+
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
7
|
+
import SessionUser from "@arcblock/ux/lib/SessionUser";
|
|
8
|
+
import SessionBlocklet from "@arcblock/ux/lib/SessionBlocklet";
|
|
9
|
+
import LocaleSelector from "@arcblock/ux/lib/Locale/selector";
|
|
10
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
11
|
+
import { SessionManagerProps } from "../types.js";
|
|
12
|
+
import { getLocalizedNavigation, filterNavByRole } from "../blocklets.js";
|
|
13
|
+
export default function HeaderAddons({ formattedBlocklet, addons, sessionManagerProps }) {
|
|
14
|
+
const sessionCtx = useContext(SessionContext);
|
|
15
|
+
const { locale } = useLocaleContext() || {};
|
|
16
|
+
const { enableConnect = true, enableLocale = true } = formattedBlocklet;
|
|
32
17
|
const authenticated = !!sessionCtx?.session?.user;
|
|
33
|
-
let localizedNav =
|
|
34
|
-
localizedNav =
|
|
18
|
+
let localizedNav = getLocalizedNavigation(formattedBlocklet?.navigation?.sessionManager, locale) || [];
|
|
19
|
+
localizedNav = filterNavByRole(localizedNav, sessionCtx?.session?.user?.role);
|
|
35
20
|
const renderAddons = () => {
|
|
36
21
|
if (addons && typeof addons !== "function") {
|
|
37
22
|
return Array.isArray(addons) ? addons : [addons];
|
|
38
23
|
}
|
|
39
24
|
let addonsArray = [];
|
|
40
25
|
if (enableLocale && locale) {
|
|
41
|
-
addonsArray.push(
|
|
42
|
-
showText: false
|
|
43
|
-
}, "locale-selector"));
|
|
26
|
+
addonsArray.push(/* @__PURE__ */ jsx(LocaleSelector, { showText: false }, "locale-selector"));
|
|
44
27
|
}
|
|
45
28
|
if (enableConnect && sessionCtx) {
|
|
46
29
|
const menu = [];
|
|
47
30
|
if (authenticated) {
|
|
48
31
|
const navList = localizedNav ? localizedNav.slice(0, 5) : [];
|
|
49
|
-
navList.forEach(x => {
|
|
32
|
+
navList.forEach((x) => {
|
|
50
33
|
menu.push({
|
|
51
34
|
label: x.title,
|
|
52
|
-
icon: x.icon ? /* @__PURE__ */
|
|
53
|
-
icon: x.icon,
|
|
54
|
-
height: 24,
|
|
55
|
-
style: {
|
|
56
|
-
marginRight: 8
|
|
57
|
-
}
|
|
58
|
-
}) : null,
|
|
35
|
+
icon: x.icon ? /* @__PURE__ */ jsx("iconify-icon", { icon: x.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
59
36
|
component: "a",
|
|
60
37
|
href: x.link,
|
|
61
38
|
key: x.link
|
|
62
39
|
});
|
|
63
40
|
});
|
|
64
41
|
}
|
|
65
|
-
addonsArray.push(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
42
|
+
addonsArray.push(/* @__PURE__ */ jsx(SessionBlocklet, { session: sessionCtx.session, locale }, "session-blocklet"));
|
|
43
|
+
addonsArray.push(
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
SessionUser,
|
|
46
|
+
{
|
|
47
|
+
session: sessionCtx.session,
|
|
48
|
+
locale,
|
|
49
|
+
menu,
|
|
50
|
+
showRole: true,
|
|
51
|
+
...sessionManagerProps
|
|
52
|
+
},
|
|
53
|
+
"session-user"
|
|
54
|
+
)
|
|
55
|
+
);
|
|
76
56
|
}
|
|
77
57
|
if (typeof addons === "function") {
|
|
78
58
|
addonsArray = addons(addonsArray) || [];
|
|
@@ -80,20 +60,24 @@ function HeaderAddons({
|
|
|
80
60
|
return addonsArray;
|
|
81
61
|
};
|
|
82
62
|
const renderedAddons = renderAddons();
|
|
83
|
-
const addonList =
|
|
63
|
+
const addonList = createElement(
|
|
64
|
+
Fragment,
|
|
65
|
+
null,
|
|
66
|
+
...Array.isArray(renderedAddons) ? renderedAddons : [renderedAddons]
|
|
67
|
+
);
|
|
84
68
|
return addonList;
|
|
85
69
|
}
|
|
86
70
|
HeaderAddons.propTypes = {
|
|
87
|
-
formattedBlocklet:
|
|
71
|
+
formattedBlocklet: PropTypes.object.isRequired,
|
|
88
72
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
89
73
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
90
74
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
91
|
-
addons:
|
|
92
|
-
sessionManagerProps:
|
|
75
|
+
addons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
76
|
+
sessionManagerProps: SessionManagerProps
|
|
93
77
|
};
|
|
94
78
|
HeaderAddons.defaultProps = {
|
|
95
79
|
addons: null,
|
|
96
80
|
sessionManagerProps: {
|
|
97
81
|
showRole: true
|
|
98
82
|
}
|
|
99
|
-
};
|
|
83
|
+
};
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
2
|
function hasParentOfType(node, type) {
|
|
9
|
-
if (!node)
|
|
10
|
-
|
|
3
|
+
if (!node)
|
|
4
|
+
return false;
|
|
5
|
+
if (type === node.nodeName)
|
|
6
|
+
return true;
|
|
11
7
|
return hasParentOfType(node.parentNode, type);
|
|
12
8
|
}
|
|
13
|
-
function LinkBlocker({
|
|
14
|
-
|
|
15
|
-
}) {
|
|
16
|
-
const handleOnClick = e => {
|
|
9
|
+
function LinkBlocker({ ...rest }) {
|
|
10
|
+
const handleOnClick = (e) => {
|
|
17
11
|
const isInsideLink = hasParentOfType(e.target, "A");
|
|
18
12
|
if (isInsideLink) {
|
|
19
13
|
e.preventDefault();
|
|
20
14
|
}
|
|
21
15
|
};
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
onClick: handleOnClick,
|
|
24
|
-
...rest
|
|
25
|
-
});
|
|
16
|
+
return /* @__PURE__ */ jsx("div", { onClick: handleOnClick, ...rest });
|
|
26
17
|
}
|
|
27
|
-
|
|
18
|
+
export default LinkBlocker;
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
const defaultTheme = (0, _Theme.createTheme)();
|
|
12
|
-
function OverridableThemeProvider({
|
|
13
|
-
theme: themeOverrides,
|
|
14
|
-
children
|
|
15
|
-
}) {
|
|
16
|
-
const theme = themeOverrides ? (0, _Theme.createTheme)(themeOverrides) : defaultTheme;
|
|
17
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Theme.ThemeProvider, {
|
|
18
|
-
theme,
|
|
19
|
-
children
|
|
20
|
-
});
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { createTheme, ThemeProvider } from "@arcblock/ux/lib/Theme";
|
|
4
|
+
const defaultTheme = createTheme();
|
|
5
|
+
export default function OverridableThemeProvider({ theme: themeOverrides, children }) {
|
|
6
|
+
const theme = themeOverrides ? createTheme(themeOverrides) : defaultTheme;
|
|
7
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme, children });
|
|
21
8
|
}
|
|
22
9
|
OverridableThemeProvider.propTypes = {
|
|
23
|
-
children:
|
|
24
|
-
theme:
|
|
10
|
+
children: PropTypes.any.isRequired,
|
|
11
|
+
theme: PropTypes.object
|
|
25
12
|
};
|
|
26
13
|
OverridableThemeProvider.defaultProps = {
|
|
27
14
|
theme: null
|
|
28
|
-
};
|
|
15
|
+
};
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
3
|
+
import bridge from '@arcblock/bridge';
|
|
2
4
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useWalletHiddenTopbar = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _useBrowser = _interopRequireDefault(require("@arcblock/react-hooks/lib/useBrowser"));
|
|
9
|
-
var _bridge = _interopRequireDefault(require("@arcblock/bridge"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
5
|
// 在 wallet webview 环境中, 隐藏 wallet topbar
|
|
12
6
|
// eslint-disable-next-line import/prefer-default-export
|
|
13
|
-
const useWalletHiddenTopbar = () => {
|
|
14
|
-
const browser = (
|
|
15
|
-
|
|
7
|
+
export const useWalletHiddenTopbar = () => {
|
|
8
|
+
const browser = useBrowser();
|
|
9
|
+
useEffect(() => {
|
|
16
10
|
if (browser.wallet) {
|
|
17
|
-
|
|
11
|
+
bridge.call('arcHideTopBar', '{}');
|
|
18
12
|
}
|
|
19
13
|
}, [browser]);
|
|
20
14
|
};
|
|
21
|
-
exports.useWalletHiddenTopbar = useWalletHiddenTopbar;
|
|
@@ -1,61 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const ConfigUserSpaceContext = exports.ConfigUserSpaceContext = (0, _react.createContext)({});
|
|
13
|
-
const {
|
|
14
|
-
Provider,
|
|
15
|
-
Consumer
|
|
16
|
-
} = ConfigUserSpaceContext;
|
|
17
|
-
exports.ConfigUserSpaceConsumer = Consumer;
|
|
18
|
-
function ConfigUserSpaceProvider({
|
|
19
|
-
children
|
|
20
|
-
}) {
|
|
21
|
-
const [loading] = (0, _react.useState)(false);
|
|
22
|
-
const {
|
|
23
|
-
session
|
|
24
|
-
} = (0, _react.useContext)(_Session.SessionContext);
|
|
25
|
-
const {
|
|
26
|
-
user
|
|
27
|
-
} = session;
|
|
28
|
-
const [spaceGateway, setSpaceGateway] = (0, _react.useState)();
|
|
29
|
-
const storageEndpoint = (0, _react.useMemo)(() => {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, useState, useEffect } from "react";
|
|
3
|
+
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
4
|
+
const ConfigUserSpaceContext = createContext({});
|
|
5
|
+
const { Provider, Consumer } = ConfigUserSpaceContext;
|
|
6
|
+
function ConfigUserSpaceProvider({ children }) {
|
|
7
|
+
const [loading] = useState(false);
|
|
8
|
+
const { session } = useContext(SessionContext);
|
|
9
|
+
const { user } = session;
|
|
10
|
+
const [spaceGateway, setSpaceGateway] = useState();
|
|
11
|
+
const storageEndpoint = useMemo(() => {
|
|
30
12
|
return user?.didSpace?.endpoint;
|
|
31
13
|
}, [user?.didSpace]);
|
|
32
|
-
|
|
14
|
+
useEffect(() => {
|
|
33
15
|
setSpaceGateway(user?.didSpace);
|
|
34
16
|
}, [user?.didSpace]);
|
|
35
17
|
const deleteSpaceGateway = async () => {
|
|
36
18
|
setSpaceGateway(void 0);
|
|
37
19
|
};
|
|
38
|
-
const settingStorageEndpoint = endpoint => {
|
|
39
|
-
|
|
20
|
+
const settingStorageEndpoint = (endpoint) => {
|
|
21
|
+
};
|
|
22
|
+
const updateSpaceGateway = async (x) => {
|
|
40
23
|
setSpaceGateway(x);
|
|
41
24
|
session.refresh();
|
|
42
25
|
await settingStorageEndpoint(x.endpoint);
|
|
43
26
|
};
|
|
44
27
|
const hasStorageEndpoint = Boolean(storageEndpoint && spaceGateway);
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
Provider,
|
|
30
|
+
{
|
|
31
|
+
value: {
|
|
32
|
+
loading,
|
|
33
|
+
spaceGateway,
|
|
34
|
+
deleteSpaceGateway,
|
|
35
|
+
updateSpaceGateway,
|
|
36
|
+
storageEndpoint,
|
|
37
|
+
settingStorageEndpoint,
|
|
38
|
+
hasStorageEndpoint
|
|
39
|
+
},
|
|
40
|
+
children
|
|
41
|
+
}
|
|
42
|
+
);
|
|
57
43
|
}
|
|
58
44
|
function useConfigUserSpaceContext() {
|
|
59
|
-
const res =
|
|
45
|
+
const res = useContext(ConfigUserSpaceContext);
|
|
60
46
|
return res;
|
|
61
|
-
}
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
ConfigUserSpaceContext,
|
|
50
|
+
ConfigUserSpaceProvider,
|
|
51
|
+
Consumer as ConfigUserSpaceConsumer,
|
|
52
|
+
useConfigUserSpaceContext
|
|
53
|
+
};
|
package/lib/hooks/use-mobile.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
module.exports = useMobile;
|
|
7
|
-
var _material = require("@mui/material");
|
|
8
|
-
function useMobile({
|
|
9
|
-
key = "sm"
|
|
10
|
-
}) {
|
|
11
|
-
const theme = (0, _material.useTheme)();
|
|
12
|
-
return (0, _material.useMediaQuery)(theme.breakpoints.down(key));
|
|
13
|
-
}
|
|
1
|
+
import { useTheme, useMediaQuery } from "@mui/material";
|
|
2
|
+
export default function useMobile({ key = "sm" }) {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
return useMediaQuery(theme.breakpoints.down(key));
|
|
5
|
+
}
|