@blocklet/ui-react 2.9.77 → 2.9.78
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/es/UserCenter/components/third-party-login/index.js +4 -5
- package/es/UserCenter/components/third-party-login/third-party-item.js +93 -96
- package/es/UserCenter/components/user-center.d.ts +2 -1
- package/es/UserCenter/components/user-center.js +4 -0
- package/lib/UserCenter/components/third-party-login/index.js +3 -4
- package/lib/UserCenter/components/third-party-login/third-party-item.js +99 -95
- package/lib/UserCenter/components/user-center.d.ts +2 -1
- package/lib/UserCenter/components/user-center.js +4 -0
- package/package.json +6 -6
- package/src/UserCenter/components/third-party-login/index.tsx +5 -6
- package/src/UserCenter/components/third-party-login/third-party-item.tsx +87 -88
- package/src/UserCenter/components/user-center.tsx +5 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Box } from "@mui/material";
|
|
4
4
|
import { useAsyncEffect, useCreation } from "ahooks";
|
|
5
5
|
import { getConnectedAccounts, getSourceProvider } from "@arcblock/ux/lib/SessionUser/libs/utils";
|
|
6
6
|
import { LOGIN_PROVIDER } from "@arcblock/ux/lib/Util/constant";
|
|
@@ -95,13 +95,12 @@ export default function ThirdPartyLogin({ user }) {
|
|
|
95
95
|
return transformedProviders;
|
|
96
96
|
}, [user?.connectedAccounts, availableProviders]);
|
|
97
97
|
return /* @__PURE__ */ jsx(
|
|
98
|
-
|
|
98
|
+
Box,
|
|
99
99
|
{
|
|
100
|
-
dense: true,
|
|
101
100
|
sx: {
|
|
102
101
|
gap: 1,
|
|
103
|
-
display: "
|
|
104
|
-
|
|
102
|
+
display: "grid",
|
|
103
|
+
gridTemplateColumns: "1fr min-content"
|
|
105
104
|
},
|
|
106
105
|
children: normalizedAccounts.map((account) => {
|
|
107
106
|
return /* @__PURE__ */ jsx(ThirdPartyItem, { item: account }, account?.provider);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Icon } from "@iconify/react";
|
|
3
|
-
import { Box,
|
|
3
|
+
import { Box, Tooltip, Typography } from "@mui/material";
|
|
4
4
|
import LinkRoundedIcon from "@iconify-icons/material-symbols/link-rounded";
|
|
5
5
|
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
6
6
|
import Button from "@arcblock/ux/lib/Button";
|
|
@@ -98,130 +98,127 @@ export default function ThirdPartyItem({
|
|
|
98
98
|
});
|
|
99
99
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
100
100
|
/* @__PURE__ */ jsxs(
|
|
101
|
-
|
|
101
|
+
Box,
|
|
102
102
|
{
|
|
103
|
-
disablePadding: true,
|
|
104
103
|
sx: {
|
|
104
|
+
borderRadius: 2,
|
|
105
|
+
border: `1px solid ${colors.strokeBorderBase}`,
|
|
106
|
+
background: colors.backgroundsBgField,
|
|
105
107
|
display: "flex",
|
|
106
108
|
alignItems: "center",
|
|
107
|
-
|
|
109
|
+
py: 1,
|
|
110
|
+
px: 1.5,
|
|
111
|
+
gap: 0.75,
|
|
112
|
+
fontSize: "14px",
|
|
113
|
+
lineHeight: 1,
|
|
114
|
+
overflow: "hidden"
|
|
108
115
|
},
|
|
109
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
|
+
),
|
|
110
127
|
/* @__PURE__ */ jsxs(
|
|
111
128
|
Box,
|
|
112
129
|
{
|
|
113
130
|
sx: {
|
|
114
|
-
flex: 1,
|
|
115
|
-
borderRadius: 2,
|
|
116
|
-
border: `1px solid ${colors.strokeBorderBase}`,
|
|
117
|
-
background: colors.backgroundsBgField,
|
|
118
131
|
display: "flex",
|
|
119
132
|
alignItems: "center",
|
|
120
|
-
|
|
121
|
-
px: 1.5,
|
|
122
|
-
gap: 0.75,
|
|
123
|
-
fontSize: "14px",
|
|
124
|
-
lineHeight: 1
|
|
133
|
+
gap: 0.5
|
|
125
134
|
},
|
|
126
135
|
children: [
|
|
127
|
-
/* @__PURE__ */ jsx(Icon, { icon, fontSize: 16, width: "1em", height: "1em" }),
|
|
128
136
|
/* @__PURE__ */ jsx(
|
|
129
137
|
Box,
|
|
130
138
|
{
|
|
131
139
|
sx: {
|
|
132
|
-
display: "flex",
|
|
133
|
-
alignItems: "center",
|
|
134
|
-
justifyContent: "space-between",
|
|
135
140
|
flex: 1,
|
|
136
|
-
|
|
141
|
+
textOverflow: "ellipsis",
|
|
142
|
+
overflow: "hidden",
|
|
143
|
+
lineHeight: "normal"
|
|
137
144
|
},
|
|
138
|
-
children:
|
|
145
|
+
children: item.userInfo?.email || item.did
|
|
139
146
|
}
|
|
140
147
|
),
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
|
|
148
|
+
item.userInfo?.email ? /* @__PURE__ */ jsx(
|
|
149
|
+
Tooltip,
|
|
143
150
|
{
|
|
144
|
-
sx: {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
children: /* @__PURE__ */ jsx(
|
|
182
|
-
Icon,
|
|
183
|
-
{
|
|
184
|
-
icon: InfoOutlineRoundedIcon,
|
|
185
|
-
color: colors.textSubtitle,
|
|
186
|
-
fontSize: 16,
|
|
187
|
-
style: { cursor: "pointer" }
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
}
|
|
191
|
-
) : null
|
|
192
|
-
]
|
|
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
|
+
)
|
|
193
188
|
}
|
|
194
|
-
)
|
|
189
|
+
) : null
|
|
195
190
|
]
|
|
196
191
|
}
|
|
197
|
-
)
|
|
198
|
-
/* @__PURE__ */ jsx(Tooltip, { title: item._mainProvider ? t("thirdPartyLogin.mainProviderCantRemove") : "", children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
199
|
-
Button,
|
|
200
|
-
{
|
|
201
|
-
variant: "outlined",
|
|
202
|
-
size: "small",
|
|
203
|
-
sx: {
|
|
204
|
-
color: item?._bind ? colors.red : colors.foregroundsFgBase,
|
|
205
|
-
borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
|
|
206
|
-
backgroundColor: colors.buttonsButtonNeutral,
|
|
207
|
-
"&:hover": {
|
|
208
|
-
borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
|
|
209
|
-
backgroundColor: colors.buttonsButtonNeutralHover
|
|
210
|
-
},
|
|
211
|
-
py: 0.5,
|
|
212
|
-
borderRadius: 2,
|
|
213
|
-
fontWeight: 500
|
|
214
|
-
},
|
|
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
|
-
) }) })
|
|
192
|
+
)
|
|
222
193
|
]
|
|
223
194
|
}
|
|
224
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
|
+
) }) }),
|
|
225
222
|
confirmHolder
|
|
226
223
|
] });
|
|
227
224
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
3
|
+
export default function UserCenter({ children, notLoginContent, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
4
4
|
readonly children: any;
|
|
5
|
+
readonly notLoginContent: any;
|
|
5
6
|
readonly currentTab: string;
|
|
6
7
|
readonly contentProps?: BoxProps;
|
|
7
8
|
readonly disableAutoRedirect?: boolean;
|
|
@@ -24,6 +24,7 @@ import Settings from "./settings.js";
|
|
|
24
24
|
import { client } from "../../libs/client.js";
|
|
25
25
|
export default function UserCenter({
|
|
26
26
|
children,
|
|
27
|
+
notLoginContent = null,
|
|
27
28
|
currentTab,
|
|
28
29
|
contentProps = {},
|
|
29
30
|
disableAutoRedirect = false,
|
|
@@ -186,6 +187,9 @@ export default function UserCenter({
|
|
|
186
187
|
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(ErrorFallback, { error: formatError }) });
|
|
187
188
|
}
|
|
188
189
|
if (!currentDid && !userState.data) {
|
|
190
|
+
if (notLoginContent) {
|
|
191
|
+
return notLoginContent;
|
|
192
|
+
}
|
|
189
193
|
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(
|
|
190
194
|
Box,
|
|
191
195
|
{
|
|
@@ -107,12 +107,11 @@ function ThirdPartyLogin({
|
|
|
107
107
|
});
|
|
108
108
|
return transformedProviders;
|
|
109
109
|
}, [user?.connectedAccounts, availableProviders]);
|
|
110
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.
|
|
111
|
-
dense: true,
|
|
110
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
112
111
|
sx: {
|
|
113
112
|
gap: 1,
|
|
114
|
-
display: "
|
|
115
|
-
|
|
113
|
+
display: "grid",
|
|
114
|
+
gridTemplateColumns: "1fr min-content"
|
|
116
115
|
},
|
|
117
116
|
children: normalizedAccounts.map(account => {
|
|
118
117
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_thirdPartyItem.default, {
|
|
@@ -120,118 +120,122 @@ function ThirdPartyItem({
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
123
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.
|
|
124
|
-
disablePadding: true,
|
|
123
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
125
124
|
sx: {
|
|
125
|
+
borderRadius: 2,
|
|
126
|
+
border: `1px solid ${_Colors.temp.strokeBorderBase}`,
|
|
127
|
+
background: _Colors.temp.backgroundsBgField,
|
|
126
128
|
display: "flex",
|
|
127
129
|
alignItems: "center",
|
|
128
|
-
|
|
130
|
+
py: 1,
|
|
131
|
+
px: 1.5,
|
|
132
|
+
gap: 0.75,
|
|
133
|
+
fontSize: "14px",
|
|
134
|
+
lineHeight: 1,
|
|
135
|
+
overflow: "hidden"
|
|
129
136
|
},
|
|
130
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.
|
|
137
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
138
|
+
component: _react.Icon,
|
|
139
|
+
icon,
|
|
140
|
+
width: "1em",
|
|
141
|
+
height: "1em",
|
|
142
|
+
sx: {
|
|
143
|
+
flexShrink: 0,
|
|
144
|
+
fontSize: 16
|
|
145
|
+
}
|
|
146
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
147
|
+
sx: {
|
|
148
|
+
flex: 1
|
|
149
|
+
},
|
|
150
|
+
children: title
|
|
151
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
131
152
|
sx: {
|
|
132
|
-
flex: 1,
|
|
133
|
-
borderRadius: 2,
|
|
134
|
-
border: `1px solid ${_Colors.temp.strokeBorderBase}`,
|
|
135
|
-
background: _Colors.temp.backgroundsBgField,
|
|
136
153
|
display: "flex",
|
|
137
154
|
alignItems: "center",
|
|
138
|
-
|
|
139
|
-
px: 1.5,
|
|
140
|
-
gap: 0.75,
|
|
141
|
-
fontSize: "14px",
|
|
142
|
-
lineHeight: 1
|
|
155
|
+
gap: 0.5
|
|
143
156
|
},
|
|
144
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
145
|
-
icon,
|
|
146
|
-
fontSize: 16,
|
|
147
|
-
width: "1em",
|
|
148
|
-
height: "1em"
|
|
149
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
157
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
150
158
|
sx: {
|
|
151
|
-
display: "flex",
|
|
152
|
-
alignItems: "center",
|
|
153
|
-
justifyContent: "space-between",
|
|
154
159
|
flex: 1,
|
|
155
|
-
|
|
160
|
+
textOverflow: "ellipsis",
|
|
161
|
+
overflow: "hidden",
|
|
162
|
+
lineHeight: "normal"
|
|
156
163
|
},
|
|
157
|
-
children:
|
|
158
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
children: /* @__PURE__ */(0, _jsxRuntime.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
children:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
sx: {
|
|
188
|
-
whiteSpace: "normal",
|
|
189
|
-
wordBreak: "break-all",
|
|
190
|
-
fontSize: "0.9rem"
|
|
191
|
-
},
|
|
192
|
-
children: item.userInfo?.email
|
|
193
|
-
})]
|
|
164
|
+
children: item.userInfo?.email || item.did
|
|
165
|
+
}), item.userInfo?.email ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
166
|
+
title: /* @__PURE__ */(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
167
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
168
|
+
sx: {
|
|
169
|
+
display: "flex",
|
|
170
|
+
alignItems: "center",
|
|
171
|
+
gap: 1
|
|
172
|
+
},
|
|
173
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
174
|
+
size: 36,
|
|
175
|
+
variant: "circle",
|
|
176
|
+
shape: "circle",
|
|
177
|
+
src: item.userInfo?.picture,
|
|
178
|
+
did: item.did
|
|
179
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
180
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
181
|
+
sx: {
|
|
182
|
+
whiteSpace: "normal",
|
|
183
|
+
wordBreak: "break-all",
|
|
184
|
+
fontSize: "0.9rem"
|
|
185
|
+
},
|
|
186
|
+
children: item.userInfo?.name
|
|
187
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
188
|
+
sx: {
|
|
189
|
+
whiteSpace: "normal",
|
|
190
|
+
wordBreak: "break-all",
|
|
191
|
+
fontSize: "0.9rem"
|
|
192
|
+
},
|
|
193
|
+
children: item.userInfo?.email
|
|
194
194
|
})]
|
|
195
|
-
})
|
|
196
|
-
}),
|
|
197
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
|
|
198
|
-
icon: _infoOutlineRounded.default,
|
|
199
|
-
color: _Colors.temp.textSubtitle,
|
|
200
|
-
fontSize: 16,
|
|
201
|
-
style: {
|
|
202
|
-
cursor: "pointer"
|
|
203
|
-
}
|
|
195
|
+
})]
|
|
204
196
|
})
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
variant: "outlined",
|
|
212
|
-
size: "small",
|
|
197
|
+
}),
|
|
198
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
199
|
+
component: _react.Icon,
|
|
200
|
+
icon: _infoOutlineRounded.default,
|
|
201
|
+
color: _Colors.temp.textSubtitle,
|
|
202
|
+
fontSize: 16,
|
|
213
203
|
sx: {
|
|
214
|
-
|
|
204
|
+
cursor: "pointer",
|
|
205
|
+
flexShrink: 0
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
}) : null]
|
|
209
|
+
})]
|
|
210
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
211
|
+
title: item._mainProvider ? t("thirdPartyLogin.mainProviderCantRemove") : "",
|
|
212
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
213
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_Button.default, {
|
|
214
|
+
variant: "outlined",
|
|
215
|
+
size: "small",
|
|
216
|
+
sx: {
|
|
217
|
+
color: item?._bind ? _Colors.temp.red : _Colors.temp.foregroundsFgBase,
|
|
218
|
+
borderColor: item?._bind ? _Colors.temp.red : _Colors.temp.strokeBorderBase,
|
|
219
|
+
backgroundColor: _Colors.temp.buttonsButtonNeutral,
|
|
220
|
+
"&:hover": {
|
|
215
221
|
borderColor: item?._bind ? _Colors.temp.red : _Colors.temp.strokeBorderBase,
|
|
216
|
-
backgroundColor: _Colors.temp.
|
|
217
|
-
"&:hover": {
|
|
218
|
-
borderColor: item?._bind ? _Colors.temp.red : _Colors.temp.strokeBorderBase,
|
|
219
|
-
backgroundColor: _Colors.temp.buttonsButtonNeutralHover
|
|
220
|
-
},
|
|
221
|
-
py: 0.5,
|
|
222
|
-
borderRadius: 2,
|
|
223
|
-
fontWeight: 500
|
|
222
|
+
backgroundColor: _Colors.temp.buttonsButtonNeutralHover
|
|
224
223
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
py: 0.5,
|
|
225
|
+
borderRadius: 2,
|
|
226
|
+
fontWeight: 500,
|
|
227
|
+
whiteSpace: "nowrap"
|
|
228
|
+
},
|
|
229
|
+
fullWidth: true,
|
|
230
|
+
startIcon: currentState.loading ? null : /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
|
|
231
|
+
icon: _linkRounded.default
|
|
232
|
+
}),
|
|
233
|
+
onClick: toggleBind,
|
|
234
|
+
disabled: item._mainProvider,
|
|
235
|
+
loading: currentState.loading,
|
|
236
|
+
children: item?._bind ? t("thirdPartyLogin.disconnect") : t("thirdPartyLogin.connect")
|
|
233
237
|
})
|
|
234
|
-
})
|
|
238
|
+
})
|
|
235
239
|
}), confirmHolder]
|
|
236
240
|
});
|
|
237
241
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
3
|
+
export default function UserCenter({ children, notLoginContent, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
4
4
|
readonly children: any;
|
|
5
|
+
readonly notLoginContent: any;
|
|
5
6
|
readonly currentTab: string;
|
|
6
7
|
readonly contentProps?: BoxProps;
|
|
7
8
|
readonly disableAutoRedirect?: boolean;
|
|
@@ -31,6 +31,7 @@ var _client = require("../../libs/client");
|
|
|
31
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
32
|
function UserCenter({
|
|
33
33
|
children,
|
|
34
|
+
notLoginContent = null,
|
|
34
35
|
currentTab,
|
|
35
36
|
contentProps = {},
|
|
36
37
|
disableAutoRedirect = false,
|
|
@@ -203,6 +204,9 @@ function UserCenter({
|
|
|
203
204
|
});
|
|
204
205
|
}
|
|
205
206
|
if (!currentDid && !userState.data) {
|
|
207
|
+
if (notLoginContent) {
|
|
208
|
+
return notLoginContent;
|
|
209
|
+
}
|
|
206
210
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
207
211
|
sx: {
|
|
208
212
|
width: "100%"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.78",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@arcblock/bridge": "^2.9.
|
|
66
|
-
"@arcblock/did-connect": "^2.9.
|
|
67
|
-
"@arcblock/react-hooks": "^2.9.
|
|
68
|
-
"@arcblock/ux": "^2.9.
|
|
65
|
+
"@arcblock/bridge": "^2.9.78",
|
|
66
|
+
"@arcblock/did-connect": "^2.9.78",
|
|
67
|
+
"@arcblock/react-hooks": "^2.9.78",
|
|
68
|
+
"@arcblock/ux": "^2.9.78",
|
|
69
69
|
"@blocklet/js-sdk": "^1.16.26",
|
|
70
70
|
"@emotion/react": "^11.10.4",
|
|
71
71
|
"@emotion/styled": "^11.10.4",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"jest": "^28.1.3",
|
|
110
110
|
"unbuild": "^2.0.0"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "db9dafbc8bc35be7884e7152d4aff169cbcbfa90"
|
|
113
113
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
3
|
import { useAsyncEffect, useCreation } from 'ahooks';
|
|
4
4
|
import { getConnectedAccounts, getSourceProvider } from '@arcblock/ux/lib/SessionUser/libs/utils';
|
|
5
5
|
import { LOGIN_PROVIDER } from '@arcblock/ux/lib/Util/constant';
|
|
@@ -118,16 +118,15 @@ export default function ThirdPartyLogin({ user }: { user: User }) {
|
|
|
118
118
|
}, [user?.connectedAccounts, availableProviders]);
|
|
119
119
|
|
|
120
120
|
return (
|
|
121
|
-
<
|
|
122
|
-
dense
|
|
121
|
+
<Box
|
|
123
122
|
sx={{
|
|
124
123
|
gap: 1,
|
|
125
|
-
display: '
|
|
126
|
-
|
|
124
|
+
display: 'grid',
|
|
125
|
+
gridTemplateColumns: '1fr min-content',
|
|
127
126
|
}}>
|
|
128
127
|
{normalizedAccounts.map((account) => {
|
|
129
128
|
return <ThirdPartyItem key={account?.provider} item={account as OAuthAccount} />;
|
|
130
129
|
})}
|
|
131
|
-
</
|
|
130
|
+
</Box>
|
|
132
131
|
);
|
|
133
132
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Icon } from '@iconify/react';
|
|
2
|
-
import { Box,
|
|
2
|
+
import { Box, Tooltip, Typography } from '@mui/material';
|
|
3
3
|
import LinkRoundedIcon from '@iconify-icons/material-symbols/link-rounded';
|
|
4
4
|
import { temp as colors } from '@arcblock/ux/lib/Colors';
|
|
5
5
|
import Button from '@arcblock/ux/lib/Button';
|
|
@@ -120,72 +120,69 @@ export default function ThirdPartyItem({
|
|
|
120
120
|
|
|
121
121
|
return (
|
|
122
122
|
<>
|
|
123
|
-
<
|
|
124
|
-
disablePadding
|
|
123
|
+
<Box
|
|
125
124
|
sx={{
|
|
125
|
+
borderRadius: 2,
|
|
126
|
+
border: `1px solid ${colors.strokeBorderBase}`,
|
|
127
|
+
background: colors.backgroundsBgField,
|
|
126
128
|
display: 'flex',
|
|
127
129
|
alignItems: 'center',
|
|
128
|
-
|
|
130
|
+
py: 1,
|
|
131
|
+
px: 1.5,
|
|
132
|
+
gap: 0.75,
|
|
133
|
+
fontSize: '14px',
|
|
134
|
+
lineHeight: 1,
|
|
135
|
+
overflow: 'hidden',
|
|
129
136
|
}}>
|
|
137
|
+
<Box component={Icon} icon={icon} width="1em" height="1em" sx={{ flexShrink: 0, fontSize: 16 }} />
|
|
130
138
|
<Box
|
|
131
139
|
sx={{
|
|
132
140
|
flex: 1,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
}}>
|
|
142
|
+
{title}
|
|
143
|
+
</Box>
|
|
144
|
+
<Box
|
|
145
|
+
sx={{
|
|
136
146
|
display: 'flex',
|
|
137
147
|
alignItems: 'center',
|
|
138
|
-
|
|
139
|
-
px: 1.5,
|
|
140
|
-
gap: 0.75,
|
|
141
|
-
fontSize: '14px',
|
|
142
|
-
lineHeight: 1,
|
|
148
|
+
gap: 0.5,
|
|
143
149
|
}}>
|
|
144
|
-
<Icon icon={icon} fontSize={16} width="1em" height="1em" />
|
|
145
150
|
<Box
|
|
146
151
|
sx={{
|
|
147
|
-
display: 'flex',
|
|
148
|
-
alignItems: 'center',
|
|
149
|
-
justifyContent: 'space-between',
|
|
150
152
|
flex: 1,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
</Box>
|
|
155
|
-
<Box
|
|
156
|
-
sx={{
|
|
157
|
-
display: 'flex',
|
|
158
|
-
alignItems: 'center',
|
|
159
|
-
gap: 0.5,
|
|
153
|
+
textOverflow: 'ellipsis',
|
|
154
|
+
overflow: 'hidden',
|
|
155
|
+
lineHeight: 'normal',
|
|
160
156
|
}}>
|
|
161
157
|
{item.userInfo?.email || item.did}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
</
|
|
158
|
+
</Box>
|
|
159
|
+
{item.userInfo?.email ? (
|
|
160
|
+
<Tooltip
|
|
161
|
+
title={
|
|
162
|
+
<>
|
|
163
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
164
|
+
<Avatar size={36} variant="circle" shape="circle" src={item.userInfo?.picture} did={item.did} />
|
|
165
|
+
<Box>
|
|
166
|
+
<Typography
|
|
167
|
+
sx={{
|
|
168
|
+
whiteSpace: 'normal',
|
|
169
|
+
wordBreak: 'break-all',
|
|
170
|
+
fontSize: '0.9rem',
|
|
171
|
+
}}>
|
|
172
|
+
{item.userInfo?.name}
|
|
173
|
+
</Typography>
|
|
174
|
+
<Typography
|
|
175
|
+
sx={{
|
|
176
|
+
whiteSpace: 'normal',
|
|
177
|
+
wordBreak: 'break-all',
|
|
178
|
+
fontSize: '0.9rem',
|
|
179
|
+
}}>
|
|
180
|
+
{item.userInfo?.email}
|
|
181
|
+
</Typography>
|
|
186
182
|
</Box>
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
</Box>
|
|
184
|
+
{/* 暂不显示 oauth 账户的 did */}
|
|
185
|
+
{/* <Box
|
|
189
186
|
component={DID}
|
|
190
187
|
did={item.did}
|
|
191
188
|
sx={{
|
|
@@ -194,45 +191,47 @@ export default function ThirdPartyItem({
|
|
|
194
191
|
},
|
|
195
192
|
}}
|
|
196
193
|
/> */}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
</>
|
|
195
|
+
}>
|
|
196
|
+
<Box
|
|
197
|
+
component={Icon}
|
|
198
|
+
icon={InfoOutlineRoundedIcon}
|
|
199
|
+
color={colors.textSubtitle}
|
|
200
|
+
fontSize={16}
|
|
201
|
+
sx={{ cursor: 'pointer', flexShrink: 0 }}
|
|
202
|
+
/>
|
|
203
|
+
</Tooltip>
|
|
204
|
+
) : null}
|
|
208
205
|
</Box>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
</Box>
|
|
207
|
+
<Tooltip title={item._mainProvider ? t('thirdPartyLogin.mainProviderCantRemove') : ''}>
|
|
208
|
+
{/* HACK: 结合下面的 button disable 使用,必须增加这一层 */}
|
|
209
|
+
<Box>
|
|
210
|
+
<Button
|
|
211
|
+
variant="outlined"
|
|
212
|
+
size="small"
|
|
213
|
+
sx={{
|
|
214
|
+
color: item?._bind ? colors.red : colors.foregroundsFgBase,
|
|
215
|
+
borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
|
|
216
|
+
backgroundColor: colors.buttonsButtonNeutral,
|
|
217
|
+
'&:hover': {
|
|
217
218
|
borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
|
|
218
|
-
backgroundColor: colors.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
</Tooltip>
|
|
235
|
-
</ListItem>
|
|
219
|
+
backgroundColor: colors.buttonsButtonNeutralHover,
|
|
220
|
+
},
|
|
221
|
+
py: 0.5,
|
|
222
|
+
borderRadius: 2,
|
|
223
|
+
fontWeight: 500,
|
|
224
|
+
whiteSpace: 'nowrap',
|
|
225
|
+
}}
|
|
226
|
+
fullWidth
|
|
227
|
+
startIcon={currentState.loading ? null : <Icon icon={LinkRoundedIcon} />}
|
|
228
|
+
onClick={toggleBind}
|
|
229
|
+
disabled={item._mainProvider}
|
|
230
|
+
loading={currentState.loading}>
|
|
231
|
+
{item?._bind ? t('thirdPartyLogin.disconnect') : t('thirdPartyLogin.connect')}
|
|
232
|
+
</Button>
|
|
233
|
+
</Box>
|
|
234
|
+
</Tooltip>
|
|
236
235
|
{confirmHolder}
|
|
237
236
|
</>
|
|
238
237
|
);
|
|
@@ -31,6 +31,7 @@ import { client } from '../../libs/client';
|
|
|
31
31
|
|
|
32
32
|
export default function UserCenter({
|
|
33
33
|
children,
|
|
34
|
+
notLoginContent = null,
|
|
34
35
|
currentTab,
|
|
35
36
|
contentProps = {},
|
|
36
37
|
disableAutoRedirect = false,
|
|
@@ -42,6 +43,7 @@ export default function UserCenter({
|
|
|
42
43
|
stickySidebar = false,
|
|
43
44
|
}: {
|
|
44
45
|
readonly children: any;
|
|
46
|
+
readonly notLoginContent: any;
|
|
45
47
|
readonly currentTab: string;
|
|
46
48
|
readonly contentProps?: BoxProps;
|
|
47
49
|
readonly disableAutoRedirect?: boolean;
|
|
@@ -229,6 +231,9 @@ export default function UserCenter({
|
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
if (!currentDid && !userState.data) {
|
|
234
|
+
if (notLoginContent) {
|
|
235
|
+
return notLoginContent;
|
|
236
|
+
}
|
|
232
237
|
return (
|
|
233
238
|
<Box sx={{ width: '100%' }}>
|
|
234
239
|
<Box
|