@blocklet/ui-react 2.9.91 → 2.10.1
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,80 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import ReactPlaceholder from "react-placeholder";
|
|
4
|
-
import { Dialog, DialogContent, IconButton } from "@mui/material";
|
|
5
|
-
import CloseOutlinedIcon from "@mui/icons-material/CloseOutlined";
|
|
6
|
-
import EmptySpacesNFT from "./icons/empty-spaces-nft.svg?react";
|
|
7
|
-
function PreviewSpaceNft({ src, alt }) {
|
|
8
|
-
const [showEmptySpaceNFT, setShowEmptySpaceNFT] = useState(false);
|
|
9
|
-
const [open, setOpen] = useState(false);
|
|
10
|
-
const handleOpen = () => setOpen(true);
|
|
11
|
-
const handleClose = () => setOpen(false);
|
|
12
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
|
-
/* @__PURE__ */ jsx(
|
|
14
|
-
ReactPlaceholder,
|
|
15
|
-
{
|
|
16
|
-
ready: showEmptySpaceNFT,
|
|
17
|
-
customPlaceholder: (
|
|
18
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
19
|
-
/* @__PURE__ */ jsx(
|
|
20
|
-
"img",
|
|
21
|
-
{
|
|
22
|
-
style: { cursor: "pointer" },
|
|
23
|
-
alt,
|
|
24
|
-
src,
|
|
25
|
-
width: "58px",
|
|
26
|
-
height: "58px",
|
|
27
|
-
onError: () => setShowEmptySpaceNFT(true),
|
|
28
|
-
onClick: handleOpen
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
),
|
|
32
|
-
children: /* @__PURE__ */ jsx(EmptySpacesNFT, { style: { cursor: "pointer", width: "58px", height: "58px" }, onClick: handleOpen })
|
|
33
|
-
}
|
|
34
|
-
),
|
|
35
|
-
/* @__PURE__ */ jsx(
|
|
36
|
-
Dialog,
|
|
37
|
-
{
|
|
38
|
-
open,
|
|
39
|
-
onClose: handleClose,
|
|
40
|
-
"aria-labelledby": "preview-space-nft-display",
|
|
41
|
-
"aria-describedby": "preview space nft display",
|
|
42
|
-
fullWidth: true,
|
|
43
|
-
maxWidth: "md",
|
|
44
|
-
children: /* @__PURE__ */ jsxs(DialogContent, { style: { padding: "8px 8px", backgroundColor: "rgba(0,0,0,0.8)" }, children: [
|
|
45
|
-
/* @__PURE__ */ jsx(
|
|
46
|
-
IconButton,
|
|
47
|
-
{
|
|
48
|
-
color: "inherit",
|
|
49
|
-
onClick: handleClose,
|
|
50
|
-
"aria-label": "close",
|
|
51
|
-
style: { position: "absolute", top: 8, right: 8, color: "white" },
|
|
52
|
-
children: /* @__PURE__ */ jsx(CloseOutlinedIcon, {})
|
|
53
|
-
}
|
|
54
|
-
),
|
|
55
|
-
showEmptySpaceNFT ? /* @__PURE__ */ jsx(
|
|
56
|
-
EmptySpacesNFT,
|
|
57
|
-
{
|
|
58
|
-
style: {
|
|
59
|
-
width: "100%",
|
|
60
|
-
height: "75vh"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
) : /* @__PURE__ */ jsx(
|
|
64
|
-
"img",
|
|
65
|
-
{
|
|
66
|
-
src,
|
|
67
|
-
alt: "",
|
|
68
|
-
style: {
|
|
69
|
-
width: "100%",
|
|
70
|
-
height: "75vh",
|
|
71
|
-
objectFit: "contain"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
] })
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
] });
|
|
79
|
-
}
|
|
80
|
-
export default PreviewSpaceNft;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useState } from "react";
|
|
3
|
-
import { Box } from "@mui/material";
|
|
4
|
-
import { useAsyncEffect, useCreation } from "ahooks";
|
|
5
|
-
import { getConnectedAccounts, getSourceProvider } from "@arcblock/ux/lib/SessionUser/libs/utils";
|
|
6
|
-
import { LOGIN_PROVIDER } from "@arcblock/ux/lib/Util/constant";
|
|
7
|
-
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
8
|
-
import ThirdPartyItem from "./third-party-item.js";
|
|
9
|
-
export default function ThirdPartyLogin({ user }) {
|
|
10
|
-
const { session } = useContext(SessionContext);
|
|
11
|
-
const [oauthConfigs, setOauthConfigs] = useState({});
|
|
12
|
-
const { getOAuthConfigs } = session.useOAuth();
|
|
13
|
-
useAsyncEffect(async () => {
|
|
14
|
-
const data = await getOAuthConfigs({
|
|
15
|
-
sourceAppPid: user?.sourceAppPid
|
|
16
|
-
});
|
|
17
|
-
setOauthConfigs(data);
|
|
18
|
-
}, [user?.sourceAppPid]);
|
|
19
|
-
const availableProviders = useCreation(() => {
|
|
20
|
-
const oauthList = Object.keys(oauthConfigs).map((x) => {
|
|
21
|
-
return {
|
|
22
|
-
...oauthConfigs[x],
|
|
23
|
-
provider: x
|
|
24
|
-
};
|
|
25
|
-
}).filter((x) => x.enabled);
|
|
26
|
-
return oauthList;
|
|
27
|
-
}, [oauthConfigs]);
|
|
28
|
-
const normalizedAccounts = useCreation(() => {
|
|
29
|
-
const connectedAccounts = getConnectedAccounts(user);
|
|
30
|
-
let removeAuth0 = false;
|
|
31
|
-
let patchProvider = "";
|
|
32
|
-
let sourceProvider = getSourceProvider(user);
|
|
33
|
-
const auth0ConnectedAccount = connectedAccounts.find((x) => x.provider === LOGIN_PROVIDER.AUTH0);
|
|
34
|
-
if (auth0ConnectedAccount) {
|
|
35
|
-
if (auth0ConnectedAccount.id.startsWith("google-oauth2|")) {
|
|
36
|
-
if (!connectedAccounts.some((x) => x.provider === "google")) {
|
|
37
|
-
removeAuth0 = true;
|
|
38
|
-
patchProvider = LOGIN_PROVIDER.GOOGLE;
|
|
39
|
-
if (sourceProvider === LOGIN_PROVIDER.AUTH0) {
|
|
40
|
-
sourceProvider = LOGIN_PROVIDER.GOOGLE;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (auth0ConnectedAccount.id.startsWith("appleid|")) {
|
|
45
|
-
if (!connectedAccounts.some((x) => x.provider === LOGIN_PROVIDER.APPLE)) {
|
|
46
|
-
removeAuth0 = true;
|
|
47
|
-
patchProvider = LOGIN_PROVIDER.APPLE;
|
|
48
|
-
if (sourceProvider === LOGIN_PROVIDER.AUTH0) {
|
|
49
|
-
sourceProvider = LOGIN_PROVIDER.APPLE;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (auth0ConnectedAccount.id.startsWith("github|")) {
|
|
54
|
-
if (!connectedAccounts.some((x) => x.provider === LOGIN_PROVIDER.GITHUB)) {
|
|
55
|
-
removeAuth0 = true;
|
|
56
|
-
patchProvider = LOGIN_PROVIDER.GITHUB;
|
|
57
|
-
if (sourceProvider === LOGIN_PROVIDER.AUTH0) {
|
|
58
|
-
sourceProvider = LOGIN_PROVIDER.GITHUB;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const transformedProviders = availableProviders.map((x) => {
|
|
64
|
-
if (x.provider === LOGIN_PROVIDER.AUTH0 && removeAuth0) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const findConnectedAccount = removeAuth0 && x.provider === patchProvider ? connectedAccounts.find((i) => i.provider === LOGIN_PROVIDER.AUTH0) : connectedAccounts.find((i) => i.provider === x.provider);
|
|
68
|
-
if (findConnectedAccount) {
|
|
69
|
-
return {
|
|
70
|
-
...x,
|
|
71
|
-
provider: x.provider,
|
|
72
|
-
did: findConnectedAccount.did,
|
|
73
|
-
pk: findConnectedAccount.pk,
|
|
74
|
-
userInfo: findConnectedAccount.userInfo,
|
|
75
|
-
_bind: true,
|
|
76
|
-
_rawProvider: findConnectedAccount.provider,
|
|
77
|
-
_mainProvider: x.provider === sourceProvider
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
...x,
|
|
82
|
-
provider: x.provider,
|
|
83
|
-
_rawProvider: x.provider,
|
|
84
|
-
_mainProvider: x.provider === sourceProvider
|
|
85
|
-
};
|
|
86
|
-
}).filter(Boolean).sort((a, b) => {
|
|
87
|
-
if (a?.order !== void 0 && b?.order !== void 0) {
|
|
88
|
-
return a.order - b.order;
|
|
89
|
-
}
|
|
90
|
-
if (a?.order !== void 0) {
|
|
91
|
-
return -1;
|
|
92
|
-
}
|
|
93
|
-
return 1;
|
|
94
|
-
});
|
|
95
|
-
return transformedProviders;
|
|
96
|
-
}, [user?.connectedAccounts, availableProviders]);
|
|
97
|
-
return /* @__PURE__ */ jsx(
|
|
98
|
-
Box,
|
|
99
|
-
{
|
|
100
|
-
sx: {
|
|
101
|
-
gap: 1,
|
|
102
|
-
display: "grid",
|
|
103
|
-
gridTemplateColumns: "1fr min-content"
|
|
104
|
-
},
|
|
105
|
-
children: normalizedAccounts.map((account) => {
|
|
106
|
-
return /* @__PURE__ */ jsx(ThirdPartyItem, { item: account }, account?.provider);
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { OAuthAccount } from '../../../@types';
|
|
3
|
-
export default function ThirdPartyItem({ item, }: {
|
|
4
|
-
item: {
|
|
5
|
-
provider: string;
|
|
6
|
-
did: string;
|
|
7
|
-
pk: string;
|
|
8
|
-
userInfo?: OAuthAccount['userInfo'];
|
|
9
|
-
_bind?: boolean;
|
|
10
|
-
_rawProvider?: string;
|
|
11
|
-
_mainProvider?: boolean;
|
|
12
|
-
};
|
|
13
|
-
}): import("react").JSX.Element;
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Icon } from "@iconify/react";
|
|
3
|
-
import { Box, Tooltip, Typography } from "@mui/material";
|
|
4
|
-
import LinkRoundedIcon from "@iconify-icons/material-symbols/link-rounded";
|
|
5
|
-
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
6
|
-
import Button from "@arcblock/ux/lib/Button";
|
|
7
|
-
import Avatar from "@arcblock/ux/lib/Avatar";
|
|
8
|
-
import { useCreation, useMemoizedFn, useReactive } from "ahooks";
|
|
9
|
-
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
10
|
-
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
11
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
12
|
-
import MailOutlineRoundedIcon from "@iconify-icons/material-symbols/mail-outline-rounded";
|
|
13
|
-
import InfoOutlineRoundedIcon from "@iconify-icons/material-symbols/info-outline-rounded";
|
|
14
|
-
import AppleIcon from "@iconify-icons/logos/apple";
|
|
15
|
-
import GithubIcon from "@iconify-icons/logos/github-icon";
|
|
16
|
-
import GoogleIcon from "@iconify-icons/logos/google-icon";
|
|
17
|
-
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
18
|
-
import { useContext } from "react";
|
|
19
|
-
import pick from "lodash/pick";
|
|
20
|
-
import { getFederatedEnabled, getMaster } from "@arcblock/ux/lib/Util/federated";
|
|
21
|
-
import { LOGIN_PROVIDER, OAUTH_PROVIDER } from "@arcblock/ux/lib/Util/constant";
|
|
22
|
-
import { translations } from "../../libs/locales.js";
|
|
23
|
-
export default function ThirdPartyItem({
|
|
24
|
-
item
|
|
25
|
-
}) {
|
|
26
|
-
const { confirmApi, confirmHolder } = useConfirm();
|
|
27
|
-
const currentState = useReactive({
|
|
28
|
-
loading: false
|
|
29
|
-
});
|
|
30
|
-
const { locale } = useLocaleContext();
|
|
31
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
32
|
-
return translate(translations, key, locale, "en", data);
|
|
33
|
-
});
|
|
34
|
-
const { session } = useContext(SessionContext);
|
|
35
|
-
const { bindOAuth, unbindOAuth, setBaseUrl, baseUrl: oauthBaseUrl } = session.useOAuth();
|
|
36
|
-
const iconMap = {
|
|
37
|
-
// email: MailOutlineRoundedIcon,
|
|
38
|
-
[LOGIN_PROVIDER.AUTH0]: MailOutlineRoundedIcon,
|
|
39
|
-
[LOGIN_PROVIDER.APPLE]: AppleIcon,
|
|
40
|
-
[LOGIN_PROVIDER.GITHUB]: GithubIcon,
|
|
41
|
-
[LOGIN_PROVIDER.GOOGLE]: GoogleIcon
|
|
42
|
-
};
|
|
43
|
-
const icon = useCreation(() => {
|
|
44
|
-
return iconMap[item?.provider];
|
|
45
|
-
}, [item?.provider]);
|
|
46
|
-
const title = useCreation(() => {
|
|
47
|
-
return OAUTH_PROVIDER[item?.provider] || "unknown";
|
|
48
|
-
}, [item?.provider]);
|
|
49
|
-
const toggleBind = useMemoizedFn(async () => {
|
|
50
|
-
try {
|
|
51
|
-
currentState.loading = true;
|
|
52
|
-
await new Promise((resolve, reject) => {
|
|
53
|
-
if (item?._bind) {
|
|
54
|
-
confirmApi.open({
|
|
55
|
-
title: t("thirdPartyLogin.confirmUnbind", { name: title }),
|
|
56
|
-
content: t("thirdPartyLogin.confirmUnbindDescription", { name: title }),
|
|
57
|
-
confirmButtonText: t("common.confirm"),
|
|
58
|
-
cancelButtonText: t("common.cancel"),
|
|
59
|
-
onConfirm(close) {
|
|
60
|
-
unbindOAuth({
|
|
61
|
-
session,
|
|
62
|
-
connectedAccount: {
|
|
63
|
-
...pick(item, ["did", "pk"]),
|
|
64
|
-
showProvider: item.provider,
|
|
65
|
-
provider: item._rawProvider
|
|
66
|
-
}
|
|
67
|
-
}).then(resolve).catch(reject);
|
|
68
|
-
close();
|
|
69
|
-
},
|
|
70
|
-
onCancel: resolve
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
const backupBaseUrl = oauthBaseUrl;
|
|
74
|
-
const blocklet = window?.blocklet;
|
|
75
|
-
let baseUrl = "/";
|
|
76
|
-
const federatedEnabled = getFederatedEnabled(blocklet);
|
|
77
|
-
const master = getMaster(blocklet);
|
|
78
|
-
if (federatedEnabled && master?.appPid && session?.user?.sourceAppPid) {
|
|
79
|
-
baseUrl = master.appUrl;
|
|
80
|
-
}
|
|
81
|
-
setBaseUrl(baseUrl);
|
|
82
|
-
bindOAuth({
|
|
83
|
-
session,
|
|
84
|
-
oauthItem: {
|
|
85
|
-
...item,
|
|
86
|
-
provider: item._rawProvider
|
|
87
|
-
}
|
|
88
|
-
}).then(resolve).catch(reject).finally(() => {
|
|
89
|
-
setBaseUrl(backupBaseUrl);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
} catch (err) {
|
|
94
|
-
console.error(`Failed to ${item?._bind ? "unbind" : "bind"} oauth account`, err);
|
|
95
|
-
} finally {
|
|
96
|
-
currentState.loading = false;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
100
|
-
/* @__PURE__ */ jsxs(
|
|
101
|
-
Box,
|
|
102
|
-
{
|
|
103
|
-
sx: {
|
|
104
|
-
borderRadius: 2,
|
|
105
|
-
border: `1px solid ${colors.strokeBorderBase}`,
|
|
106
|
-
background: colors.backgroundsBgField,
|
|
107
|
-
display: "flex",
|
|
108
|
-
alignItems: "center",
|
|
109
|
-
py: 1,
|
|
110
|
-
px: 1.5,
|
|
111
|
-
gap: 0.75,
|
|
112
|
-
fontSize: "14px",
|
|
113
|
-
lineHeight: 1,
|
|
114
|
-
overflow: "hidden"
|
|
115
|
-
},
|
|
116
|
-
children: [
|
|
117
|
-
/* @__PURE__ */ jsx(Box, { component: Icon, icon, width: "1em", height: "1em", sx: { flexShrink: 0, fontSize: 16 } }),
|
|
118
|
-
/* @__PURE__ */ jsx(
|
|
119
|
-
Box,
|
|
120
|
-
{
|
|
121
|
-
sx: {
|
|
122
|
-
flex: 1
|
|
123
|
-
},
|
|
124
|
-
children: title
|
|
125
|
-
}
|
|
126
|
-
),
|
|
127
|
-
/* @__PURE__ */ jsxs(
|
|
128
|
-
Box,
|
|
129
|
-
{
|
|
130
|
-
sx: {
|
|
131
|
-
display: "flex",
|
|
132
|
-
alignItems: "center",
|
|
133
|
-
gap: 0.5
|
|
134
|
-
},
|
|
135
|
-
children: [
|
|
136
|
-
/* @__PURE__ */ jsx(
|
|
137
|
-
Box,
|
|
138
|
-
{
|
|
139
|
-
sx: {
|
|
140
|
-
flex: 1,
|
|
141
|
-
textOverflow: "ellipsis",
|
|
142
|
-
overflow: "hidden",
|
|
143
|
-
lineHeight: "normal"
|
|
144
|
-
},
|
|
145
|
-
children: item.userInfo?.email || item.did
|
|
146
|
-
}
|
|
147
|
-
),
|
|
148
|
-
item.userInfo?.email ? /* @__PURE__ */ jsx(
|
|
149
|
-
Tooltip,
|
|
150
|
-
{
|
|
151
|
-
title: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
152
|
-
/* @__PURE__ */ jsx(Avatar, { size: 36, variant: "circle", shape: "circle", src: item.userInfo?.picture, did: item.did }),
|
|
153
|
-
/* @__PURE__ */ jsxs(Box, { children: [
|
|
154
|
-
/* @__PURE__ */ jsx(
|
|
155
|
-
Typography,
|
|
156
|
-
{
|
|
157
|
-
sx: {
|
|
158
|
-
whiteSpace: "normal",
|
|
159
|
-
wordBreak: "break-all",
|
|
160
|
-
fontSize: "0.9rem"
|
|
161
|
-
},
|
|
162
|
-
children: item.userInfo?.name
|
|
163
|
-
}
|
|
164
|
-
),
|
|
165
|
-
/* @__PURE__ */ jsx(
|
|
166
|
-
Typography,
|
|
167
|
-
{
|
|
168
|
-
sx: {
|
|
169
|
-
whiteSpace: "normal",
|
|
170
|
-
wordBreak: "break-all",
|
|
171
|
-
fontSize: "0.9rem"
|
|
172
|
-
},
|
|
173
|
-
children: item.userInfo?.email
|
|
174
|
-
}
|
|
175
|
-
)
|
|
176
|
-
] })
|
|
177
|
-
] }) }),
|
|
178
|
-
children: /* @__PURE__ */ jsx(
|
|
179
|
-
Box,
|
|
180
|
-
{
|
|
181
|
-
component: Icon,
|
|
182
|
-
icon: InfoOutlineRoundedIcon,
|
|
183
|
-
color: colors.textSubtitle,
|
|
184
|
-
fontSize: 16,
|
|
185
|
-
sx: { cursor: "pointer", flexShrink: 0 }
|
|
186
|
-
}
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
) : null
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
)
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
),
|
|
196
|
-
/* @__PURE__ */ jsx(Tooltip, { title: item._mainProvider ? t("thirdPartyLogin.mainProviderCantRemove") : "", children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
197
|
-
Button,
|
|
198
|
-
{
|
|
199
|
-
variant: "outlined",
|
|
200
|
-
size: "small",
|
|
201
|
-
sx: {
|
|
202
|
-
color: item?._bind ? colors.red : colors.foregroundsFgBase,
|
|
203
|
-
borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
|
|
204
|
-
backgroundColor: colors.buttonsButtonNeutral,
|
|
205
|
-
"&:hover": {
|
|
206
|
-
borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
|
|
207
|
-
backgroundColor: colors.buttonsButtonNeutralHover
|
|
208
|
-
},
|
|
209
|
-
py: 0.5,
|
|
210
|
-
borderRadius: 2,
|
|
211
|
-
fontWeight: 500,
|
|
212
|
-
whiteSpace: "nowrap"
|
|
213
|
-
},
|
|
214
|
-
fullWidth: true,
|
|
215
|
-
startIcon: currentState.loading ? null : /* @__PURE__ */ jsx(Icon, { icon: LinkRoundedIcon }),
|
|
216
|
-
onClick: toggleBind,
|
|
217
|
-
disabled: item._mainProvider,
|
|
218
|
-
loading: currentState.loading,
|
|
219
|
-
children: item?._bind ? t("thirdPartyLogin.disconnect") : t("thirdPartyLogin.connect")
|
|
220
|
-
}
|
|
221
|
-
) }) }),
|
|
222
|
-
confirmHolder
|
|
223
|
-
] });
|
|
224
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { BoxProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, notLoginContent, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
4
|
-
readonly children: any;
|
|
5
|
-
readonly notLoginContent: any;
|
|
6
|
-
readonly currentTab: string;
|
|
7
|
-
readonly contentProps?: BoxProps;
|
|
8
|
-
readonly disableAutoRedirect?: boolean;
|
|
9
|
-
readonly autoPopupSetting?: boolean;
|
|
10
|
-
readonly hideFooter?: boolean;
|
|
11
|
-
readonly headerProps?: any;
|
|
12
|
-
readonly footerProps?: any;
|
|
13
|
-
readonly userDid?: string;
|
|
14
|
-
readonly stickySidebar?: boolean;
|
|
15
|
-
}): import("react").JSX.Element | null;
|