@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
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
3
|
-
import { Icon } from "@iconify/react";
|
|
4
|
-
import { Box, Button } from "@mui/material";
|
|
5
|
-
import PropTypes from "prop-types";
|
|
6
|
-
export default function InstallerItem({ optionalComponent, index, installStatus, hasPermission, t }) {
|
|
7
|
-
const handleInstall = () => {
|
|
8
|
-
window.open(optionalComponent?.installUrl, "_blank");
|
|
9
|
-
};
|
|
10
|
-
const handleOpenStore = () => {
|
|
11
|
-
window.open(optionalComponent?.storeUrl, "_blank");
|
|
12
|
-
};
|
|
13
|
-
const handleRefresh = () => {
|
|
14
|
-
window.location.reload();
|
|
15
|
-
};
|
|
16
|
-
const installStatusDone = installStatus === "stopped" || installStatus === "running";
|
|
17
|
-
const size = 60;
|
|
18
|
-
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
19
|
-
index === 0 ? null : /* @__PURE__ */ jsx(Box, { sx: { width: "100%", height: "1px", backgroundColor: colors.gray6 } }),
|
|
20
|
-
/* @__PURE__ */ jsxs(
|
|
21
|
-
Box,
|
|
22
|
-
{
|
|
23
|
-
sx: {
|
|
24
|
-
padding: "20px 24px",
|
|
25
|
-
paddingTop: 0.5,
|
|
26
|
-
marginTop: 2,
|
|
27
|
-
display: "flex",
|
|
28
|
-
flexDirection: "row",
|
|
29
|
-
justifyContent: "start",
|
|
30
|
-
alignItems: "flex-start"
|
|
31
|
-
},
|
|
32
|
-
children: [
|
|
33
|
-
/* @__PURE__ */ jsx(
|
|
34
|
-
"img",
|
|
35
|
-
{
|
|
36
|
-
style: { width: size, height: size, minWidth: size, minHeight: size },
|
|
37
|
-
src: optionalComponent.logoUrl,
|
|
38
|
-
alt: optionalComponent.meta.title
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
/* @__PURE__ */ jsxs(
|
|
42
|
-
Box,
|
|
43
|
-
{
|
|
44
|
-
sx: {
|
|
45
|
-
display: "flex",
|
|
46
|
-
flexDirection: "column",
|
|
47
|
-
justifyContent: "start",
|
|
48
|
-
alignItems: "start",
|
|
49
|
-
marginLeft: 2
|
|
50
|
-
},
|
|
51
|
-
children: [
|
|
52
|
-
/* @__PURE__ */ jsxs(
|
|
53
|
-
Box,
|
|
54
|
-
{
|
|
55
|
-
sx: {
|
|
56
|
-
fontSize: "16px",
|
|
57
|
-
fontWeight: "bold",
|
|
58
|
-
cursor: "pointer",
|
|
59
|
-
".link-icon": {
|
|
60
|
-
opacity: 0
|
|
61
|
-
},
|
|
62
|
-
":hover .link-icon": {
|
|
63
|
-
opacity: 1
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
onClick: () => handleOpenStore(optionalComponent.meta?.did),
|
|
67
|
-
children: [
|
|
68
|
-
optionalComponent.meta.title,
|
|
69
|
-
/* @__PURE__ */ jsxs(
|
|
70
|
-
Box,
|
|
71
|
-
{
|
|
72
|
-
sx: {
|
|
73
|
-
paddingLeft: 1,
|
|
74
|
-
fontSize: "13px",
|
|
75
|
-
fontWeight: "400"
|
|
76
|
-
},
|
|
77
|
-
component: "span",
|
|
78
|
-
children: [
|
|
79
|
-
optionalComponent.meta.version,
|
|
80
|
-
/* @__PURE__ */ jsx(
|
|
81
|
-
Icon,
|
|
82
|
-
{
|
|
83
|
-
className: "link-icon",
|
|
84
|
-
icon: "fluent:open-20-filled",
|
|
85
|
-
style: {
|
|
86
|
-
color: colors.primaryBase,
|
|
87
|
-
fontSize: 16,
|
|
88
|
-
transform: "translate(6px, 3px)",
|
|
89
|
-
transition: "all 0.3s"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
),
|
|
99
|
-
/* @__PURE__ */ jsx(Box, { sx: { marginTop: 0, opacity: 0.7 }, children: optionalComponent.meta.description }),
|
|
100
|
-
/* @__PURE__ */ jsx(Box, { sx: { display: hasPermission ? "flex" : "none", flexDirection: "row", gap: 1 }, children: installStatus ? /* @__PURE__ */ jsx(Box, { sx: { marginTop: 2, opacity: 0.7 }, children: installStatusDone ? /* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleRefresh, children: t("componentInstallerRefresh") }, "refresh") : /* @__PURE__ */ jsx(
|
|
101
|
-
Button,
|
|
102
|
-
{
|
|
103
|
-
disabled: true,
|
|
104
|
-
sx: { color: "#333" },
|
|
105
|
-
startIcon: /* @__PURE__ */ jsx(Icon, { icon: "line-md:loading-loop", style: { color: "#333", fontSize: 16 } }),
|
|
106
|
-
variant: "contained",
|
|
107
|
-
children: installStatus
|
|
108
|
-
},
|
|
109
|
-
"status"
|
|
110
|
-
) }) : /* @__PURE__ */ jsx(
|
|
111
|
-
Button,
|
|
112
|
-
{
|
|
113
|
-
sx: { marginTop: 2 },
|
|
114
|
-
variant: "contained",
|
|
115
|
-
className: "button",
|
|
116
|
-
onClick: () => handleInstall(optionalComponent.meta?.did),
|
|
117
|
-
children: t("componentInstallerInstall")
|
|
118
|
-
},
|
|
119
|
-
"install"
|
|
120
|
-
) }),
|
|
121
|
-
installStatusDone ? /* @__PURE__ */ jsx(Box, { sx: { marginTop: 2, opacity: 0.7 }, children: t("componentInstallerSuccessInstalled") }) : null
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
] });
|
|
129
|
-
}
|
|
130
|
-
InstallerItem.propTypes = {
|
|
131
|
-
t: PropTypes.func.isRequired,
|
|
132
|
-
optionalComponent: PropTypes.object.isRequired,
|
|
133
|
-
index: PropTypes.number.isRequired,
|
|
134
|
-
installStatus: PropTypes.string,
|
|
135
|
-
hasPermission: PropTypes.bool.isRequired
|
|
136
|
-
};
|
|
137
|
-
InstallerItem.defaultProps = {
|
|
138
|
-
installStatus: ""
|
|
139
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export default translations;
|
|
2
|
-
declare namespace translations {
|
|
3
|
-
namespace zh {
|
|
4
|
-
let componentInstallerTitle: string;
|
|
5
|
-
let componentInstallerInstall: string;
|
|
6
|
-
let componentInstallerClose: string;
|
|
7
|
-
let componentInstallerRefresh: string;
|
|
8
|
-
let componentInstallerSuccessInstalled: string;
|
|
9
|
-
let componentInstallerSuggestions: string;
|
|
10
|
-
let componentInstallerNoDefinedInBlockletYML: string;
|
|
11
|
-
}
|
|
12
|
-
namespace en {
|
|
13
|
-
let componentInstallerTitle_1: string;
|
|
14
|
-
export { componentInstallerTitle_1 as componentInstallerTitle };
|
|
15
|
-
let componentInstallerInstall_1: string;
|
|
16
|
-
export { componentInstallerInstall_1 as componentInstallerInstall };
|
|
17
|
-
let componentInstallerClose_1: string;
|
|
18
|
-
export { componentInstallerClose_1 as componentInstallerClose };
|
|
19
|
-
let componentInstallerRefresh_1: string;
|
|
20
|
-
export { componentInstallerRefresh_1 as componentInstallerRefresh };
|
|
21
|
-
let componentInstallerSuccessInstalled_1: string;
|
|
22
|
-
export { componentInstallerSuccessInstalled_1 as componentInstallerSuccessInstalled };
|
|
23
|
-
let componentInstallerSuggestions_1: string;
|
|
24
|
-
export { componentInstallerSuggestions_1 as componentInstallerSuggestions };
|
|
25
|
-
let componentInstallerNoDefinedInBlockletYML_1: string;
|
|
26
|
-
export { componentInstallerNoDefinedInBlockletYML_1 as componentInstallerNoDefinedInBlockletYML };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const translations = {
|
|
2
|
-
zh: {
|
|
3
|
-
componentInstallerTitle: '缺少组件',
|
|
4
|
-
componentInstallerInstall: '安装',
|
|
5
|
-
componentInstallerClose: '关闭',
|
|
6
|
-
componentInstallerRefresh: '重载页面',
|
|
7
|
-
componentInstallerSuccessInstalled: '安装成功,请重载页面查看变化。',
|
|
8
|
-
componentInstallerSuggestions: '请联系系统管理员安装该组件。',
|
|
9
|
-
componentInstallerNoDefinedInBlockletYML: '组件未在 blocklet.yml 中定义',
|
|
10
|
-
},
|
|
11
|
-
en: {
|
|
12
|
-
componentInstallerTitle: 'Missing component',
|
|
13
|
-
componentInstallerInstall: 'Install',
|
|
14
|
-
componentInstallerClose: 'Close',
|
|
15
|
-
componentInstallerRefresh: 'Refresh',
|
|
16
|
-
componentInstallerSuccessInstalled: 'Successfully installed, please refresh the page to see the changes.',
|
|
17
|
-
componentInstallerSuggestions: 'Please contact the system administrator to install the component.',
|
|
18
|
-
componentInstallerNoDefinedInBlockletYML: 'The component is not defined in blocklet.yml',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default translations;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default useComponentInstalled;
|
|
2
|
-
declare function useComponentInstalled({ did, onInstalled, onError }: {
|
|
3
|
-
did: any;
|
|
4
|
-
onInstalled: any;
|
|
5
|
-
onError: any;
|
|
6
|
-
}): {
|
|
7
|
-
optComponents: any;
|
|
8
|
-
installed: any;
|
|
9
|
-
installStatus: {};
|
|
10
|
-
setInstallStatus: import("react").Dispatch<import("react").SetStateAction<{}>>;
|
|
11
|
-
definedInBlockletYML: any;
|
|
12
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { joinURL } from 'ufo';
|
|
4
|
-
|
|
5
|
-
const parseDidToSet = (did) => {
|
|
6
|
-
if (typeof did === 'string') {
|
|
7
|
-
return new Set(did.split(';;'));
|
|
8
|
-
}
|
|
9
|
-
return new Set(did);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function useComponentInstalled({ did, onInstalled, onError }) {
|
|
13
|
-
const didKeys = Array.isArray(did) ? did.join(';;') : did;
|
|
14
|
-
const [installStatus, setInstallStatus] = useState({});
|
|
15
|
-
const onInstalledRef = useRef({ onInstalled, onError });
|
|
16
|
-
onInstalledRef.current = { onInstalled, onError };
|
|
17
|
-
|
|
18
|
-
const { optionalComponents, componentMountPoints } = window.blocklet;
|
|
19
|
-
|
|
20
|
-
const optComponents = useMemo(() => {
|
|
21
|
-
if (!optionalComponents || !optionalComponents.length) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
const didSet = parseDidToSet(didKeys);
|
|
25
|
-
const components = optionalComponents.filter((c) => didSet.has(c.meta.did));
|
|
26
|
-
(components ? onInstalledRef.current.onError : onInstalledRef.current.onInstalled)?.(components);
|
|
27
|
-
return components;
|
|
28
|
-
}, [didKeys, optionalComponents]);
|
|
29
|
-
|
|
30
|
-
const definedInBlockletYML = useMemo(() => {
|
|
31
|
-
if (optComponents.length) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
const didSet = parseDidToSet(didKeys);
|
|
35
|
-
return (componentMountPoints || []).find((item) => didSet.has(item.did));
|
|
36
|
-
}, [optComponents, componentMountPoints, didKeys]);
|
|
37
|
-
|
|
38
|
-
optComponents.forEach((item) => {
|
|
39
|
-
item.storeUrl = joinURL(item.meta.homepage, 'blocklets', item.meta.did);
|
|
40
|
-
item.installUrl = joinURL(
|
|
41
|
-
window.blocklet.appUrl,
|
|
42
|
-
AUTH_SERVICE_PREFIX,
|
|
43
|
-
`/admin/components?install-component=${item.meta.did}`
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const handle = (event) => {
|
|
49
|
-
if (event.origin !== window.blocklet.appUrl) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (event.data?.kind === 'component-installer' && event.data?.blocklet?.children) {
|
|
54
|
-
let hasChild = false;
|
|
55
|
-
const didSet = parseDidToSet(didKeys);
|
|
56
|
-
event.data?.blocklet?.children.forEach((item) => {
|
|
57
|
-
if (didSet.has(item.meta?.did)) {
|
|
58
|
-
hasChild = true;
|
|
59
|
-
setInstallStatus((value) => {
|
|
60
|
-
return {
|
|
61
|
-
...value,
|
|
62
|
-
[item.meta?.did]: item.status || 'waiting',
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
if (!hasChild) {
|
|
68
|
-
setInstallStatus({});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
window.addEventListener('message', handle);
|
|
74
|
-
return () => {
|
|
75
|
-
window.removeEventListener('message', handle);
|
|
76
|
-
};
|
|
77
|
-
}, [didKeys]);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
optComponents,
|
|
81
|
-
installed: !optComponents.length && definedInBlockletYML,
|
|
82
|
-
installStatus,
|
|
83
|
-
setInstallStatus,
|
|
84
|
-
definedInBlockletYML,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default useComponentInstalled;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
export default function AddComponent({ componentDid, resourceType, resourceDid, grantedRoles, autoClose, selectedMeta, storeUrl, onComplete, onClose, render, }: {
|
|
3
|
-
componentDid: string;
|
|
4
|
-
resourceType?: string;
|
|
5
|
-
resourceDid?: string;
|
|
6
|
-
autoClose: boolean;
|
|
7
|
-
selectedMeta?: any;
|
|
8
|
-
storeUrl?: string;
|
|
9
|
-
grantedRoles?: string[];
|
|
10
|
-
onComplete: () => void;
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
render?: ({ onClick, loading }: {
|
|
13
|
-
onClick: () => void;
|
|
14
|
-
loading: boolean;
|
|
15
|
-
}) => ReactElement;
|
|
16
|
-
}): import("react").JSX.Element;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useContext } from "react";
|
|
3
|
-
import Button from "@arcblock/ux/lib/Button";
|
|
4
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
5
|
-
import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
-
import { useMemoizedFn, useReactive } from "ahooks";
|
|
7
|
-
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
8
|
-
import { joinURL, withQuery } from "ufo";
|
|
9
|
-
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
10
|
-
import Toast from "@arcblock/ux/lib/Toast";
|
|
11
|
-
import ResourceDialog from "./resource-dialog.js";
|
|
12
|
-
import { translations } from "../libs/locales.js";
|
|
13
|
-
export default function AddComponent({
|
|
14
|
-
componentDid,
|
|
15
|
-
resourceType,
|
|
16
|
-
resourceDid,
|
|
17
|
-
grantedRoles = ["admin", "owner"],
|
|
18
|
-
autoClose = true,
|
|
19
|
-
selectedMeta,
|
|
20
|
-
storeUrl,
|
|
21
|
-
onComplete,
|
|
22
|
-
onClose,
|
|
23
|
-
render
|
|
24
|
-
}) {
|
|
25
|
-
const { session } = useContext(SessionContext);
|
|
26
|
-
const { locale } = useLocaleContext();
|
|
27
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
28
|
-
return translate(translations, key, locale, "en", data);
|
|
29
|
-
});
|
|
30
|
-
const refIframe = useRef(null);
|
|
31
|
-
const currentState = useReactive({
|
|
32
|
-
loading: false,
|
|
33
|
-
showDialog: false
|
|
34
|
-
});
|
|
35
|
-
const importUrl = withQuery(joinURL(WELLKNOWN_SERVICE_PATH_PREFIX, "embed/resources", componentDid, "add"), {
|
|
36
|
-
resourceDid,
|
|
37
|
-
resourceType,
|
|
38
|
-
mode: "dialog",
|
|
39
|
-
showFromUrl: "false",
|
|
40
|
-
showResourcesSwitch: "false",
|
|
41
|
-
enableRunBackground: "false",
|
|
42
|
-
showCategory: "false"
|
|
43
|
-
});
|
|
44
|
-
const handleClose = useMemoizedFn(() => {
|
|
45
|
-
currentState.showDialog = false;
|
|
46
|
-
onClose?.();
|
|
47
|
-
});
|
|
48
|
-
const handleComplete = useMemoizedFn(() => {
|
|
49
|
-
currentState.showDialog = false;
|
|
50
|
-
onComplete?.();
|
|
51
|
-
});
|
|
52
|
-
const handleOpen = useMemoizedFn(() => {
|
|
53
|
-
if (!session.user) {
|
|
54
|
-
Toast.warning(t("needLogin"));
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (!grantedRoles.includes(session.user?.role)) {
|
|
58
|
-
Toast.warning(t("noPermission"));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
currentState.loading = true;
|
|
62
|
-
currentState.showDialog = true;
|
|
63
|
-
});
|
|
64
|
-
const handleLoad = useMemoizedFn(() => {
|
|
65
|
-
currentState.loading = false;
|
|
66
|
-
if (refIframe.current) {
|
|
67
|
-
refIframe.current?.selectBlocklet(selectedMeta);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
const handleIframeMessage = useMemoizedFn((event) => {
|
|
71
|
-
if (event?.data?.event === "component.installed" && event.data.componentDid === componentDid) {
|
|
72
|
-
if (autoClose || event.data.manual) {
|
|
73
|
-
handleComplete();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (currentState.showDialog) {
|
|
79
|
-
window.addEventListener("message", handleIframeMessage);
|
|
80
|
-
} else {
|
|
81
|
-
window.removeEventListener("message", handleIframeMessage);
|
|
82
|
-
}
|
|
83
|
-
}, [currentState.showDialog]);
|
|
84
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
85
|
-
render ? render({ onClick: handleOpen, loading: currentState.loading }) : /* @__PURE__ */ jsx(
|
|
86
|
-
Button,
|
|
87
|
-
{
|
|
88
|
-
variant: "outlined",
|
|
89
|
-
color: "secondary",
|
|
90
|
-
type: "button",
|
|
91
|
-
className: "submit",
|
|
92
|
-
onClick: handleOpen,
|
|
93
|
-
loading: currentState.loading,
|
|
94
|
-
sx: { mr: 1, ml: 1 },
|
|
95
|
-
children: t("importResource")
|
|
96
|
-
},
|
|
97
|
-
"button"
|
|
98
|
-
),
|
|
99
|
-
currentState.showDialog && /* @__PURE__ */ jsx(
|
|
100
|
-
ResourceDialog,
|
|
101
|
-
{
|
|
102
|
-
ref: refIframe,
|
|
103
|
-
src: importUrl,
|
|
104
|
-
storeUrl,
|
|
105
|
-
open: true,
|
|
106
|
-
componentDid,
|
|
107
|
-
loading: currentState.loading,
|
|
108
|
-
onClose: handleClose,
|
|
109
|
-
onComplete: handleComplete,
|
|
110
|
-
onLoad: handleLoad
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
] });
|
|
114
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
export default function PublishComponent({ componentDid, grantedRoles, onClose, render, }: {
|
|
3
|
-
componentDid: string;
|
|
4
|
-
grantedRoles?: string[];
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
render?: ({ onClick, loading }: {
|
|
7
|
-
onClick: () => void;
|
|
8
|
-
loading: boolean;
|
|
9
|
-
}) => ReactElement;
|
|
10
|
-
}): import("react").JSX.Element;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import Button from "@arcblock/ux/lib/Button";
|
|
4
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
5
|
-
import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
-
import { useMemoizedFn, useReactive } from "ahooks";
|
|
7
|
-
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
8
|
-
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
9
|
-
import Toast from "@arcblock/ux/lib/Toast";
|
|
10
|
-
import ResourceDialog from "./resource-dialog.js";
|
|
11
|
-
import { translations } from "../libs/locales.js";
|
|
12
|
-
export default function PublishComponent({
|
|
13
|
-
componentDid,
|
|
14
|
-
grantedRoles,
|
|
15
|
-
onClose,
|
|
16
|
-
render
|
|
17
|
-
}) {
|
|
18
|
-
const { session } = useContext(SessionContext);
|
|
19
|
-
const { locale } = useLocaleContext();
|
|
20
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
21
|
-
return translate(translations, key, locale, "en", data);
|
|
22
|
-
});
|
|
23
|
-
const currentState = useReactive({
|
|
24
|
-
showDialog: false,
|
|
25
|
-
loading: false
|
|
26
|
-
});
|
|
27
|
-
const exportUrl = `${WELLKNOWN_SERVICE_PATH_PREFIX}/embed/resources/${componentDid}/publish?mode=dialog`;
|
|
28
|
-
const handleClose = useMemoizedFn(() => {
|
|
29
|
-
currentState.showDialog = false;
|
|
30
|
-
onClose?.();
|
|
31
|
-
});
|
|
32
|
-
const handleLoad = useMemoizedFn(() => {
|
|
33
|
-
currentState.loading = false;
|
|
34
|
-
});
|
|
35
|
-
const handleOpen = useMemoizedFn(() => {
|
|
36
|
-
if (!session.user) {
|
|
37
|
-
Toast.warning(t("needLogin"));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (grantedRoles && grantedRoles.length > 0) {
|
|
41
|
-
if (!grantedRoles?.includes(session.user?.role)) {
|
|
42
|
-
Toast.warning(t("noPermission"));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
currentState.loading = true;
|
|
47
|
-
currentState.showDialog = true;
|
|
48
|
-
});
|
|
49
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
-
render ? render({ onClick: handleOpen, loading: currentState.loading }) : /* @__PURE__ */ jsx(
|
|
51
|
-
Button,
|
|
52
|
-
{
|
|
53
|
-
variant: "outlined",
|
|
54
|
-
color: "secondary",
|
|
55
|
-
type: "button",
|
|
56
|
-
className: "submit",
|
|
57
|
-
loading: currentState.loading,
|
|
58
|
-
onClick: handleOpen,
|
|
59
|
-
sx: { mr: 1, ml: 1 },
|
|
60
|
-
children: t("exportResource")
|
|
61
|
-
},
|
|
62
|
-
"button"
|
|
63
|
-
),
|
|
64
|
-
currentState.showDialog && /* @__PURE__ */ jsx(
|
|
65
|
-
ResourceDialog,
|
|
66
|
-
{
|
|
67
|
-
src: exportUrl,
|
|
68
|
-
open: true,
|
|
69
|
-
onClose: handleClose,
|
|
70
|
-
onLoad: handleLoad,
|
|
71
|
-
componentDid,
|
|
72
|
-
loading: currentState.loading
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
] });
|
|
76
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
3
|
-
src: string;
|
|
4
|
-
componentDid: string;
|
|
5
|
-
open?: boolean | undefined;
|
|
6
|
-
loading?: boolean | undefined;
|
|
7
|
-
storeUrl?: string | undefined;
|
|
8
|
-
onLoad?: (() => void) | undefined;
|
|
9
|
-
onClose?: (() => void) | undefined;
|
|
10
|
-
onComplete?: (() => void) | undefined;
|
|
11
|
-
} & import("react").RefAttributes<{
|
|
12
|
-
selectBlocklet: (blockletMeta: any) => void;
|
|
13
|
-
}>>;
|
|
14
|
-
export default _default;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemoizedFn, useMount, useUnmount } from "ahooks";
|
|
3
|
-
import { useRef, forwardRef, useImperativeHandle } from "react";
|
|
4
|
-
function ResourceDialog({
|
|
5
|
-
src,
|
|
6
|
-
open = false,
|
|
7
|
-
componentDid,
|
|
8
|
-
loading = true,
|
|
9
|
-
storeUrl,
|
|
10
|
-
onClose = () => {
|
|
11
|
-
},
|
|
12
|
-
onComplete = () => {
|
|
13
|
-
},
|
|
14
|
-
onLoad = () => {
|
|
15
|
-
}
|
|
16
|
-
}, ref) {
|
|
17
|
-
const iframeRef = useRef(null);
|
|
18
|
-
const listener = useMemoizedFn((event) => {
|
|
19
|
-
if (open) {
|
|
20
|
-
if (event?.data?.event === "resourceDialog.close") {
|
|
21
|
-
onClose();
|
|
22
|
-
}
|
|
23
|
-
if (event?.data?.event === "resourceDialog.complete") {
|
|
24
|
-
onComplete();
|
|
25
|
-
}
|
|
26
|
-
if (event?.data?.event === "resourceDialog.loaded") {
|
|
27
|
-
onLoad();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
useMount(() => {
|
|
32
|
-
window.addEventListener("message", listener);
|
|
33
|
-
});
|
|
34
|
-
useUnmount(() => {
|
|
35
|
-
window.removeEventListener("message", listener);
|
|
36
|
-
});
|
|
37
|
-
useImperativeHandle(ref, () => ({
|
|
38
|
-
selectBlocklet: (blockletMeta) => {
|
|
39
|
-
if (iframeRef.current?.contentWindow) {
|
|
40
|
-
iframeRef.current.contentWindow.postMessage(
|
|
41
|
-
{
|
|
42
|
-
event: "resourceDialog.select",
|
|
43
|
-
data: blockletMeta,
|
|
44
|
-
componentDid,
|
|
45
|
-
storeUrl
|
|
46
|
-
},
|
|
47
|
-
"*"
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
if (!open) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return /* @__PURE__ */ jsx(
|
|
56
|
-
"iframe",
|
|
57
|
-
{
|
|
58
|
-
ref: iframeRef,
|
|
59
|
-
src,
|
|
60
|
-
title: "Resource Dialog",
|
|
61
|
-
style: {
|
|
62
|
-
position: "fixed",
|
|
63
|
-
top: 0,
|
|
64
|
-
left: loading ? "-100vw" : 0,
|
|
65
|
-
width: "100vw",
|
|
66
|
-
height: "100vh",
|
|
67
|
-
zIndex: 9999,
|
|
68
|
-
backgroundColor: "transparent",
|
|
69
|
-
border: "none"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
export default forwardRef(ResourceDialog);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const translations: {
|
|
2
|
-
zh: {
|
|
3
|
-
importResource: string;
|
|
4
|
-
exportResource: string;
|
|
5
|
-
noPermission: string;
|
|
6
|
-
needLogin: string;
|
|
7
|
-
};
|
|
8
|
-
en: {
|
|
9
|
-
importResource: string;
|
|
10
|
-
exportResource: string;
|
|
11
|
-
noPermission: string;
|
|
12
|
-
needLogin: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const translations = {
|
|
2
|
-
zh: {
|
|
3
|
-
importResource: "\u5BFC\u5165",
|
|
4
|
-
exportResource: "\u5BFC\u51FA",
|
|
5
|
-
noPermission: "\u4F60\u6CA1\u6709\u6743\u9650\u6267\u884C\u8BE5\u64CD\u4F5C\uFF0C\u8BF7\u5207\u6362\u7BA1\u7406\u5458\u901A\u884C\u8BC1\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u8FDB\u884C\u5B89\u88C5",
|
|
6
|
-
needLogin: "\u767B\u5F55\u540E\u624D\u53EF\u64CD\u4F5C"
|
|
7
|
-
},
|
|
8
|
-
en: {
|
|
9
|
-
importResource: "Import",
|
|
10
|
-
exportResource: "Export",
|
|
11
|
-
noPermission: "You do not have permission to perform this operation. Please switch your passport as admin or contact the administrator to install the blocklet",
|
|
12
|
-
needLogin: "Please login first"
|
|
13
|
-
}
|
|
14
|
-
};
|