@blocklet/ui-react 2.9.91 → 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
package/es/blocklets.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { mapRecursive, filterRecursive, isUrl } from './utils.js';
|
|
2
|
-
|
|
3
|
-
export const publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 格式化 theme (目前仅考虑 background)
|
|
7
|
-
*/
|
|
8
|
-
export const formatTheme = (theme) => {
|
|
9
|
-
const formatted = { ...theme };
|
|
10
|
-
const background = theme?.background;
|
|
11
|
-
if (typeof background === 'string') {
|
|
12
|
-
formatted.background = { header: background, footer: background, default: background };
|
|
13
|
-
} else if (background && typeof background === 'object') {
|
|
14
|
-
formatted.background = {
|
|
15
|
-
header: background.header || background.default,
|
|
16
|
-
footer: background.footer || background.default,
|
|
17
|
-
default: background.default,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return formatted;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 获取指定 locale 对应的 navigation 数据, 仅考虑 zh/en
|
|
25
|
-
*/
|
|
26
|
-
export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
27
|
-
if (!navigation?.length) {
|
|
28
|
-
return navigation;
|
|
29
|
-
}
|
|
30
|
-
// eslint-disable-next-line no-shadow
|
|
31
|
-
const getTitle = (title, _locale) => {
|
|
32
|
-
if (typeof title === 'string') {
|
|
33
|
-
return title;
|
|
34
|
-
}
|
|
35
|
-
if (typeof title === 'object') {
|
|
36
|
-
return title[_locale] || title?.en || title?.zh;
|
|
37
|
-
}
|
|
38
|
-
return title;
|
|
39
|
-
};
|
|
40
|
-
// eslint-disable-next-line no-shadow
|
|
41
|
-
const getLink = (link, _locale) => {
|
|
42
|
-
if (typeof link === 'string') {
|
|
43
|
-
// http[s] 开头的 url
|
|
44
|
-
if (isUrl(link)) {
|
|
45
|
-
const url = new URL(link);
|
|
46
|
-
url.searchParams.set('locale', _locale);
|
|
47
|
-
return url.href;
|
|
48
|
-
}
|
|
49
|
-
const url = new URL(link, window.location.origin);
|
|
50
|
-
url.searchParams.set('locale', _locale);
|
|
51
|
-
return url.pathname + url.search;
|
|
52
|
-
}
|
|
53
|
-
if (typeof link === 'object') {
|
|
54
|
-
return link[_locale] || link?.en || link?.zh;
|
|
55
|
-
}
|
|
56
|
-
return link;
|
|
57
|
-
};
|
|
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
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 格式化 navigation
|
|
75
|
-
*
|
|
76
|
-
* - role 统一为数组形式
|
|
77
|
-
*/
|
|
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
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const parseNavigation = (navigation) => {
|
|
95
|
-
if (!navigation?.length) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const formattedNav = formatNavigation(navigation);
|
|
100
|
-
|
|
101
|
-
const sections = {
|
|
102
|
-
header: [],
|
|
103
|
-
footer: [],
|
|
104
|
-
// 对应 footer social media
|
|
105
|
-
social: [],
|
|
106
|
-
// 对应 footer 底部 links
|
|
107
|
-
bottom: [],
|
|
108
|
-
// 对应 dashboard#sidenav 导航
|
|
109
|
-
dashboard: [],
|
|
110
|
-
// session manager menus
|
|
111
|
-
sessionManager: [],
|
|
112
|
-
userCenter: [],
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// 对 navigation 顶层元素按 section 分组
|
|
116
|
-
formattedNav.forEach((item) => {
|
|
117
|
-
// item#section 为空时, 表示只存在于 header
|
|
118
|
-
if (!item.section) {
|
|
119
|
-
sections.header.push(item);
|
|
120
|
-
// item 出现在指定几个 section 中 (array)
|
|
121
|
-
} else if (Array.isArray(item.section)) {
|
|
122
|
-
item.section.forEach((sectionKey) => {
|
|
123
|
-
sections[sectionKey]?.push(item);
|
|
124
|
-
});
|
|
125
|
-
// item 出现在指定的一个 section 中 (string)
|
|
126
|
-
} else if (typeof item.section === 'string') {
|
|
127
|
-
sections[item.section]?.push(item);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
return sections;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 格式化 blocklet info 数据
|
|
136
|
-
*/
|
|
137
|
-
export const formatBlockletInfo = (blockletInfo) => {
|
|
138
|
-
if (!blockletInfo) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
const formatted = { ...blockletInfo };
|
|
142
|
-
// theme
|
|
143
|
-
formatted.theme = formatTheme(formatted.theme);
|
|
144
|
-
// navigation
|
|
145
|
-
formatted.navigation = parseNavigation(filterValidNavItems(formatted.navigation));
|
|
146
|
-
return formatted;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 过滤掉无效结点 (无 link 且子元素为空)
|
|
151
|
-
*/
|
|
152
|
-
export const filterValidNavItems = (navigation = []) => {
|
|
153
|
-
return filterRecursive(navigation, (item, context) => !!item.link || context.filteredChildren?.length, 'items');
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* 根据 role 筛选 nav, 规则:
|
|
158
|
-
* - 如果是枝结点, 必须至少存在一个符合条件的子结点
|
|
159
|
-
* - role 未定义, 符合条件
|
|
160
|
-
* - role 定义且包括当前的 userRole, 符合条件
|
|
161
|
-
*
|
|
162
|
-
* @param {object[]} nav 导航菜单数据
|
|
163
|
-
* @param {string} userRole 当前用户 role
|
|
164
|
-
* @returns 符合 role 权限的导航菜单数据
|
|
165
|
-
*/
|
|
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
|
-
);
|
|
178
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
declare function HeaderAddons({ formattedBlocklet, addons, sessionManagerProps }: {
|
|
2
|
-
formattedBlocklet: any;
|
|
3
|
-
addons: any;
|
|
4
|
-
sessionManagerProps: any;
|
|
5
|
-
}): import("react").DetailedReactHTMLElement<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
-
declare namespace HeaderAddons {
|
|
7
|
-
namespace propTypes {
|
|
8
|
-
export let formattedBlocklet: any;
|
|
9
|
-
export let addons: any;
|
|
10
|
-
export { SessionManagerProps as sessionManagerProps };
|
|
11
|
-
}
|
|
12
|
-
namespace defaultProps {
|
|
13
|
-
let addons_1: null;
|
|
14
|
-
export { addons_1 as addons };
|
|
15
|
-
export namespace sessionManagerProps {
|
|
16
|
-
let showRole: boolean;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export default HeaderAddons;
|
|
21
|
-
import { SessionManagerProps } from '../types';
|
|
@@ -1,83 +0,0 @@
|
|
|
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;
|
|
17
|
-
const authenticated = !!sessionCtx?.session?.user;
|
|
18
|
-
let localizedNav = getLocalizedNavigation(formattedBlocklet?.navigation?.sessionManager, locale) || [];
|
|
19
|
-
localizedNav = filterNavByRole(localizedNav, sessionCtx?.session?.user?.role);
|
|
20
|
-
const renderAddons = () => {
|
|
21
|
-
if (addons && typeof addons !== "function") {
|
|
22
|
-
return Array.isArray(addons) ? addons : [addons];
|
|
23
|
-
}
|
|
24
|
-
let addonsArray = [];
|
|
25
|
-
if (enableLocale && locale) {
|
|
26
|
-
addonsArray.push(/* @__PURE__ */ jsx(LocaleSelector, { showText: false }, "locale-selector"));
|
|
27
|
-
}
|
|
28
|
-
if (enableConnect && sessionCtx) {
|
|
29
|
-
const menu = [];
|
|
30
|
-
if (authenticated) {
|
|
31
|
-
const navList = localizedNav ? localizedNav.slice(0, 5) : [];
|
|
32
|
-
navList.forEach((x) => {
|
|
33
|
-
menu.push({
|
|
34
|
-
label: x.title,
|
|
35
|
-
icon: x.icon ? /* @__PURE__ */ jsx("iconify-icon", { icon: x.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
36
|
-
component: "a",
|
|
37
|
-
href: x.link,
|
|
38
|
-
key: x.link
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
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
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (typeof addons === "function") {
|
|
58
|
-
addonsArray = addons(addonsArray) || [];
|
|
59
|
-
}
|
|
60
|
-
return addonsArray;
|
|
61
|
-
};
|
|
62
|
-
const renderedAddons = renderAddons();
|
|
63
|
-
const addonList = createElement(
|
|
64
|
-
Fragment,
|
|
65
|
-
null,
|
|
66
|
-
...Array.isArray(renderedAddons) ? renderedAddons : [renderedAddons]
|
|
67
|
-
);
|
|
68
|
-
return addonList;
|
|
69
|
-
}
|
|
70
|
-
HeaderAddons.propTypes = {
|
|
71
|
-
formattedBlocklet: PropTypes.object.isRequired,
|
|
72
|
-
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
73
|
-
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
74
|
-
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
75
|
-
addons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
76
|
-
sessionManagerProps: SessionManagerProps
|
|
77
|
-
};
|
|
78
|
-
HeaderAddons.defaultProps = {
|
|
79
|
-
addons: null,
|
|
80
|
-
sessionManagerProps: {
|
|
81
|
-
showRole: true
|
|
82
|
-
}
|
|
83
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
function hasParentOfType(node, type) {
|
|
3
|
-
if (!node)
|
|
4
|
-
return false;
|
|
5
|
-
if (type === node.nodeName)
|
|
6
|
-
return true;
|
|
7
|
-
return hasParentOfType(node.parentNode, type);
|
|
8
|
-
}
|
|
9
|
-
function LinkBlocker({ ...rest }) {
|
|
10
|
-
const handleOnClick = (e) => {
|
|
11
|
-
const isInsideLink = hasParentOfType(e.target, "A");
|
|
12
|
-
if (isInsideLink) {
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
return /* @__PURE__ */ jsx("div", { onClick: handleOnClick, ...rest });
|
|
17
|
-
}
|
|
18
|
-
export default LinkBlocker;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 允许 theme 被覆盖的 ThemeProvider 组件, 默认使用 ux default theme, 可以传入 theme 进行覆盖
|
|
3
|
-
*/
|
|
4
|
-
declare function OverridableThemeProvider({ theme: themeOverrides, children }: {
|
|
5
|
-
theme: any;
|
|
6
|
-
children: any;
|
|
7
|
-
}): import("react").JSX.Element;
|
|
8
|
-
declare namespace OverridableThemeProvider {
|
|
9
|
-
namespace propTypes {
|
|
10
|
-
let children: any;
|
|
11
|
-
let theme: any;
|
|
12
|
-
}
|
|
13
|
-
namespace defaultProps {
|
|
14
|
-
let theme_1: null;
|
|
15
|
-
export { theme_1 as theme };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export default OverridableThemeProvider;
|
|
@@ -1,15 +0,0 @@
|
|
|
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 });
|
|
8
|
-
}
|
|
9
|
-
OverridableThemeProvider.propTypes = {
|
|
10
|
-
children: PropTypes.any.isRequired,
|
|
11
|
-
theme: PropTypes.object
|
|
12
|
-
};
|
|
13
|
-
OverridableThemeProvider.defaultProps = {
|
|
14
|
-
theme: null
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function useWalletHiddenTopbar(): void;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
3
|
-
import bridge from '@arcblock/bridge';
|
|
4
|
-
|
|
5
|
-
// 在 wallet webview 环境中, 隐藏 wallet topbar
|
|
6
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
7
|
-
export const useWalletHiddenTopbar = () => {
|
|
8
|
-
const browser = useBrowser();
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (browser.wallet) {
|
|
11
|
-
bridge.call('arcHideTopBar', '{}');
|
|
12
|
-
}
|
|
13
|
-
}, [browser]);
|
|
14
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface SpaceGateway {
|
|
3
|
-
did: string;
|
|
4
|
-
name: string;
|
|
5
|
-
url: string;
|
|
6
|
-
endpoint: string;
|
|
7
|
-
}
|
|
8
|
-
export interface SettingStorageEndpoint {
|
|
9
|
-
(endpoint: string | undefined): void | Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
interface ConfigUserSpaceContextType {
|
|
12
|
-
loading: boolean;
|
|
13
|
-
spaceGateway: SpaceGateway | undefined;
|
|
14
|
-
deleteSpaceGateway: (spaceGateway: SpaceGateway) => Promise<void>;
|
|
15
|
-
updateSpaceGateway: (updateSpaceGateway: SpaceGateway) => Promise<void>;
|
|
16
|
-
storageEndpoint: string;
|
|
17
|
-
settingStorageEndpoint: SettingStorageEndpoint;
|
|
18
|
-
hasStorageEndpoint: boolean;
|
|
19
|
-
}
|
|
20
|
-
declare const ConfigUserSpaceContext: import("react").Context<ConfigUserSpaceContextType>;
|
|
21
|
-
declare const Consumer: import("react").Consumer<ConfigUserSpaceContextType>;
|
|
22
|
-
declare function ConfigUserSpaceProvider({ children }: {
|
|
23
|
-
children: React.ReactNode;
|
|
24
|
-
}): import("react").JSX.Element;
|
|
25
|
-
declare function useConfigUserSpaceContext(): ConfigUserSpaceContextType;
|
|
26
|
-
export { ConfigUserSpaceContext, ConfigUserSpaceProvider, Consumer as ConfigUserSpaceConsumer, useConfigUserSpaceContext, };
|
|
@@ -1,53 +0,0 @@
|
|
|
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(() => {
|
|
12
|
-
return user?.didSpace?.endpoint;
|
|
13
|
-
}, [user?.didSpace]);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
setSpaceGateway(user?.didSpace);
|
|
16
|
-
}, [user?.didSpace]);
|
|
17
|
-
const deleteSpaceGateway = async () => {
|
|
18
|
-
setSpaceGateway(void 0);
|
|
19
|
-
};
|
|
20
|
-
const settingStorageEndpoint = (endpoint) => {
|
|
21
|
-
};
|
|
22
|
-
const updateSpaceGateway = async (x) => {
|
|
23
|
-
setSpaceGateway(x);
|
|
24
|
-
session.refresh();
|
|
25
|
-
await settingStorageEndpoint(x.endpoint);
|
|
26
|
-
};
|
|
27
|
-
const hasStorageEndpoint = Boolean(storageEndpoint && spaceGateway);
|
|
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
|
-
);
|
|
43
|
-
}
|
|
44
|
-
function useConfigUserSpaceContext() {
|
|
45
|
-
const res = useContext(ConfigUserSpaceContext);
|
|
46
|
-
return res;
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
ConfigUserSpaceContext,
|
|
50
|
-
ConfigUserSpaceProvider,
|
|
51
|
-
Consumer as ConfigUserSpaceConsumer,
|
|
52
|
-
useConfigUserSpaceContext
|
|
53
|
-
};
|
package/es/hooks/use-mobile.d.ts
DELETED
package/es/hooks/use-mobile.js
DELETED
package/es/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { default as Header } from './Header';
|
|
2
|
-
export { default as Footer } from './Footer';
|
|
3
|
-
export { default as Dashboard } from './Dashboard';
|
|
4
|
-
export { default as Icon } from './Icon';
|
|
5
|
-
export { default as ComponentInstaller } from './ComponentInstaller';
|
|
6
|
-
export { default as BlockletStudio } from './BlockletStudio';
|
|
7
|
-
export { default as useComponentInstaller } from './ComponentInstaller/use-component-installed';
|
|
8
|
-
export * from './UserCenter';
|
|
9
|
-
export * from './UserSessions';
|
|
10
|
-
export * from './ComponentManager';
|
package/es/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { default as Header } from "./Header/index.js";
|
|
2
|
-
export { default as Footer } from "./Footer/index.js";
|
|
3
|
-
export { default as Dashboard } from "./Dashboard/index.js";
|
|
4
|
-
export { default as Icon } from "./Icon/index.js";
|
|
5
|
-
export { default as ComponentInstaller } from "./ComponentInstaller/index.js";
|
|
6
|
-
export { default as BlockletStudio } from "./BlockletStudio/index.js";
|
|
7
|
-
export { default as useComponentInstaller } from "./ComponentInstaller/use-component-installed.js";
|
|
8
|
-
export * from "./UserCenter/index.js";
|
|
9
|
-
export * from "./UserSessions/index.js";
|
|
10
|
-
export * from "./ComponentManager/index.js";
|
package/es/libs/client.d.ts
DELETED
package/es/libs/client.js
DELETED
package/es/libs/spaces.d.ts
DELETED
package/es/libs/spaces.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { joinURL } from "ufo";
|
|
2
|
-
export function getSpaceNftDisplayUrlFromEndpoint(endpoint) {
|
|
3
|
-
const prefix = endpoint.replace(/\/api\/space\/.+/, "");
|
|
4
|
-
const strArray = endpoint.replace(/\/$/, "").split("/");
|
|
5
|
-
const spaceDid = strArray.at(-4);
|
|
6
|
-
return joinURL(prefix, `/api/space/nft/display?spaceDid=${spaceDid}`);
|
|
7
|
-
}
|
|
8
|
-
export function getSpaceHomeUrl(endpoint) {
|
|
9
|
-
const baseUrl = endpoint.replace(/\/api\/space\/.+/, "");
|
|
10
|
-
const strArray = endpoint.replace(/\/$/, "").split("/");
|
|
11
|
-
const spaceDid = strArray.at(-4);
|
|
12
|
-
return joinURL(baseUrl, "space", spaceDid);
|
|
13
|
-
}
|
package/es/types.d.ts
DELETED
package/es/types.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
export const BlockletMetaProps = PropTypes.shape({
|
|
5
|
-
appLogo: PropTypes.node,
|
|
6
|
-
appName: PropTypes.string,
|
|
7
|
-
theme: PropTypes.shape({
|
|
8
|
-
background: PropTypes.string,
|
|
9
|
-
}),
|
|
10
|
-
enableConnect: PropTypes.bool,
|
|
11
|
-
enableLocale: PropTypes.bool,
|
|
12
|
-
navigation: PropTypes.arrayOf(
|
|
13
|
-
PropTypes.shape({
|
|
14
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
15
|
-
link: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
16
|
-
icon: PropTypes.string,
|
|
17
|
-
items: PropTypes.arrayOf(
|
|
18
|
-
PropTypes.shape({
|
|
19
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
20
|
-
link: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
21
|
-
})
|
|
22
|
-
),
|
|
23
|
-
})
|
|
24
|
-
),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export const SessionManagerProps = PropTypes.shape({
|
|
28
|
-
showText: PropTypes.bool,
|
|
29
|
-
showRole: PropTypes.bool,
|
|
30
|
-
switchDid: PropTypes.bool,
|
|
31
|
-
switchProfile: PropTypes.bool,
|
|
32
|
-
switchPassport: PropTypes.bool,
|
|
33
|
-
disableLogout: PropTypes.bool,
|
|
34
|
-
onLogin: PropTypes.func,
|
|
35
|
-
onLogout: PropTypes.func,
|
|
36
|
-
onSwitchDid: PropTypes.func,
|
|
37
|
-
onSwitchProfile: PropTypes.func,
|
|
38
|
-
onSwitchPassport: PropTypes.func,
|
|
39
|
-
menu: PropTypes.array,
|
|
40
|
-
menuRender: PropTypes.func,
|
|
41
|
-
dark: PropTypes.bool,
|
|
42
|
-
size: PropTypes.number,
|
|
43
|
-
});
|
package/es/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export function mapRecursive(array: any, fn: any, childrenKey?: string): any;
|
|
2
|
-
export function flatRecursive(array: any, childrenKey?: string): any[];
|
|
3
|
-
export function countRecursive(array: any, childrenKey?: string): number;
|
|
4
|
-
export function filterRecursive(array: any, predicate: any, childrenKey?: string): any;
|
|
5
|
-
export function isUrl(str: any): boolean;
|
|
6
|
-
export function isIconifyString(str: any): boolean;
|
|
7
|
-
export function matchPath(path: any): any;
|
|
8
|
-
export function matchPaths(paths?: any[]): number;
|
package/es/utils.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
2
|
-
return array.map((item) => {
|
|
3
|
-
if (Array.isArray(item[childrenKey])) {
|
|
4
|
-
return fn({
|
|
5
|
-
...item,
|
|
6
|
-
[childrenKey]: mapRecursive(item[childrenKey], fn, childrenKey),
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
return fn(item);
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// 展平有层级结构的 array
|
|
14
|
-
export const flatRecursive = (array, childrenKey = 'children') => {
|
|
15
|
-
const result = [];
|
|
16
|
-
mapRecursive(array, (item) => result.push(item), childrenKey);
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// 对有层级结构的 array 元素计数
|
|
21
|
-
export const countRecursive = (array, childrenKey = 'children') => {
|
|
22
|
-
let counter = 0;
|
|
23
|
-
mapRecursive(array, () => counter++, childrenKey);
|
|
24
|
-
return counter;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// 对有层级结构的 array 进行 filter 处理
|
|
28
|
-
// 因为是 DFS 遍历, 可以借助 context.filteredChildren 在过滤/保留子结的同时保持父子结构 (即使父结点不满足筛选条件)
|
|
29
|
-
export const filterRecursive = (array, predicate, childrenKey = 'children') => {
|
|
30
|
-
return array
|
|
31
|
-
.map((item) => ({ ...item }))
|
|
32
|
-
.filter((item) => {
|
|
33
|
-
const children = item[childrenKey];
|
|
34
|
-
if (Array.isArray(children)) {
|
|
35
|
-
const filtered = filterRecursive(children, predicate, childrenKey);
|
|
36
|
-
item[childrenKey] = filtered?.length ? filtered : undefined;
|
|
37
|
-
}
|
|
38
|
-
const context = { filteredChildren: item[childrenKey], isLeaf: !children?.length };
|
|
39
|
-
return predicate(item, context);
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// "http://", "https://" 2 种情况
|
|
44
|
-
export const isUrl = (str) => {
|
|
45
|
-
return /^https?:\/\//.test(str);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const isIconifyString = (str) => {
|
|
49
|
-
return /^[\w-]+:[\w-]+$/.test(str);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 检测 path 是否匹配当前 location, path 只考虑 "/" 开头的相对路径
|
|
54
|
-
*/
|
|
55
|
-
export const matchPath = (path) => {
|
|
56
|
-
if (!path || !path?.startsWith('/')) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
const ensureTrailingSlash = (str) => (str.endsWith('/') ? str : `${str}/`);
|
|
60
|
-
const pathname = ensureTrailingSlash(window.location.pathname);
|
|
61
|
-
const normalizedPath = ensureTrailingSlash(new URL(path, window.location.origin).pathname);
|
|
62
|
-
return pathname.startsWith(normalizedPath);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 从一组 paths 中, 找到匹配当前 location 的 path, 返回序号
|
|
67
|
-
*/
|
|
68
|
-
export const matchPaths = (paths = []) => {
|
|
69
|
-
const matched = paths.map((item, index) => ({ path: item, index })).filter((item) => matchPath(item.path));
|
|
70
|
-
if (!matched?.length) {
|
|
71
|
-
return -1;
|
|
72
|
-
}
|
|
73
|
-
// 多个 path 都匹配时, 取一个最具体 (最长的) path
|
|
74
|
-
const mostSpecific = matched.slice(1).reduce((prev, cur) => {
|
|
75
|
-
return prev.path.length >= cur.path.length ? prev : cur;
|
|
76
|
-
}, matched[0]);
|
|
77
|
-
return mostSpecific.index;
|
|
78
|
-
};
|