@arcblock/ux 3.1.0 → 3.1.2
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.
@@ -5,7 +5,7 @@ import { RequestAppInfo, CurrentAppInfo } from './auth-apps-info';
|
|
5
5
|
/**
|
6
6
|
* @example app/connect-to-did-space?appPid=zNKp8tdZUanWKnvhwZWvF2hKRutwM9ykLaY8&appDid=zNKp8tdZUanWKnvhwZWvF2hKRutwM9ykLaY8&appName=233&appDescription=456&appUrl=https://bbqaw5mgxc6fnihrwqcejcxvukkdgkk4anwxwk5msvm.did.abtnet.io/zh
|
7
7
|
*/
|
8
|
-
export default function AuthApps({ session, requestAppInfo, currentAppInfo, children, userInfo, hideSwitchConnect, hideAuthorize, hideCancel, notThisText, authorizeText, connectText, cancelText, useAnotherText, slotProps, onConnect, onAuthorize, onSwitchConnect, onCancel, ref, }: {
|
8
|
+
export default function AuthApps({ session, requestAppInfo, currentAppInfo, children, userInfo, hideSwitchConnect, hideAuthorize, hideCancel, hideButton, notThisText, authorizeText, connectText, cancelText, useAnotherText, slotProps, onConnect, onAuthorize, onSwitchConnect, onCancel, ref, }: {
|
9
9
|
session: any;
|
10
10
|
requestAppInfo: RequestAppInfo;
|
11
11
|
currentAppInfo: CurrentAppInfo;
|
@@ -14,6 +14,7 @@ export default function AuthApps({ session, requestAppInfo, currentAppInfo, chil
|
|
14
14
|
hideSwitchConnect?: boolean;
|
15
15
|
hideAuthorize?: boolean;
|
16
16
|
hideCancel?: boolean;
|
17
|
+
hideButton?: boolean;
|
17
18
|
notThisText?: string;
|
18
19
|
authorizeText?: string;
|
19
20
|
connectText?: string;
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import { jsx as e, jsxs as o, Fragment as
|
2
|
-
import { CircularProgress as u, Box as l, Stack as
|
3
|
-
import { useReactive as
|
1
|
+
import { jsx as e, jsxs as o, Fragment as m } from "react/jsx-runtime";
|
2
|
+
import { CircularProgress as u, Box as l, Stack as q, Button as h, Typography as E, Link as G } from "@mui/material";
|
3
|
+
import { useReactive as J, useMemoizedFn as i } from "ahooks";
|
4
4
|
import c from "lodash/noop";
|
5
|
-
import { useImperativeHandle as
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import { translate as
|
11
|
-
import { useLocaleContext as
|
12
|
-
import
|
13
|
-
import { InfoType as
|
14
|
-
import { mergeSx as
|
15
|
-
const
|
5
|
+
import { useImperativeHandle as K } from "react";
|
6
|
+
import O from "../did-connect-container.js";
|
7
|
+
import Q from "./auth-apps-info.js";
|
8
|
+
import V from "../../Center/index.js";
|
9
|
+
import X from "../landing-page.js";
|
10
|
+
import { translate as Y } from "../../Locale/util.js";
|
11
|
+
import { useLocaleContext as Z } from "../../Locale/context.js";
|
12
|
+
import _ from "../../UserCard/index.js";
|
13
|
+
import { InfoType as $, CardType as P } from "../../UserCard/types.js";
|
14
|
+
import { mergeSx as p } from "../../Util/style.js";
|
15
|
+
const ee = {
|
16
16
|
en: {
|
17
17
|
notThis: "Not you?",
|
18
18
|
useAnother: "Use another account",
|
@@ -28,61 +28,62 @@ const P = {
|
|
28
28
|
cancel: "取消"
|
29
29
|
}
|
30
30
|
};
|
31
|
-
function
|
31
|
+
function fe({
|
32
32
|
session: s,
|
33
|
-
requestAppInfo:
|
34
|
-
currentAppInfo:
|
35
|
-
children:
|
36
|
-
userInfo:
|
37
|
-
hideSwitchConnect:
|
38
|
-
hideAuthorize:
|
39
|
-
hideCancel:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
requestAppInfo: f,
|
34
|
+
currentAppInfo: g,
|
35
|
+
children: x = null,
|
36
|
+
userInfo: C = void 0,
|
37
|
+
hideSwitchConnect: v = !1,
|
38
|
+
hideAuthorize: y = !1,
|
39
|
+
hideCancel: z = !1,
|
40
|
+
hideButton: A = !1,
|
41
|
+
notThisText: b = void 0,
|
42
|
+
authorizeText: k = void 0,
|
43
|
+
connectText: T = void 0,
|
44
|
+
cancelText: w = void 0,
|
45
|
+
useAnotherText: D = void 0,
|
45
46
|
slotProps: r = void 0,
|
46
|
-
onConnect:
|
47
|
-
onAuthorize:
|
48
|
-
onSwitchConnect:
|
49
|
-
onCancel:
|
50
|
-
ref:
|
47
|
+
onConnect: I = c,
|
48
|
+
onAuthorize: L = c,
|
49
|
+
onSwitchConnect: S = c,
|
50
|
+
onCancel: W = c,
|
51
|
+
ref: j
|
51
52
|
}) {
|
52
|
-
const n =
|
53
|
+
const n = J({
|
53
54
|
loading: !1
|
54
|
-
}), { locale:
|
55
|
+
}), { locale: B = "en" } = Z() || {}, t = i((H, N = {}) => Y(ee, H, B, "en", N)), a = i(() => {
|
55
56
|
n.loading = !1;
|
56
|
-
}), j = i(() => {
|
57
|
-
n.loading = !0, w?.(a);
|
58
|
-
}), B = i(() => {
|
59
|
-
n.loading = !0, I?.(a);
|
60
57
|
}), F = i(() => {
|
61
|
-
n.loading = !0,
|
58
|
+
n.loading = !0, I?.(a);
|
62
59
|
}), M = i(() => {
|
63
|
-
|
60
|
+
n.loading = !0, S?.(a);
|
61
|
+
}), R = i(() => {
|
62
|
+
n.loading = !0, L?.(a);
|
63
|
+
}), U = i(() => {
|
64
|
+
W?.();
|
64
65
|
});
|
65
|
-
if (
|
66
|
+
if (K(j, () => ({
|
66
67
|
closeLoading: a
|
67
68
|
})), s.loading || !s.initialized)
|
68
|
-
return /* @__PURE__ */ e(
|
69
|
-
const d =
|
70
|
-
return /* @__PURE__ */ e(
|
69
|
+
return /* @__PURE__ */ e(V, { children: /* @__PURE__ */ e(u, {}) });
|
70
|
+
const d = C ?? s?.user;
|
71
|
+
return /* @__PURE__ */ e(X, { did: window.blocklet?.appPid, standalone: !0, children: /* @__PURE__ */ e(
|
71
72
|
l,
|
72
73
|
{
|
73
74
|
...r?.root,
|
74
|
-
sx:
|
75
|
+
sx: p(
|
75
76
|
{
|
76
77
|
width: 420,
|
77
78
|
maxWidth: "100%"
|
78
79
|
},
|
79
80
|
r?.root?.sx
|
80
81
|
),
|
81
|
-
children: /* @__PURE__ */ e(
|
82
|
+
children: /* @__PURE__ */ e(O, { hideCloseButton: !0, ...r?.didConnectContainer, children: /* @__PURE__ */ o(
|
82
83
|
l,
|
83
84
|
{
|
84
85
|
...r?.contentContainer,
|
85
|
-
sx:
|
86
|
+
sx: p(
|
86
87
|
{
|
87
88
|
display: "flex",
|
88
89
|
flexDirection: "column",
|
@@ -101,69 +102,71 @@ function pe({
|
|
101
102
|
r?.contentContainer?.sx
|
102
103
|
),
|
103
104
|
children: [
|
104
|
-
/* @__PURE__ */ e(
|
105
|
-
d ? /* @__PURE__ */ o(
|
106
|
-
/* @__PURE__ */ e(
|
105
|
+
/* @__PURE__ */ e(Q, { requestAppInfo: f, currentAppInfo: g }),
|
106
|
+
d ? /* @__PURE__ */ o(m, { children: [
|
107
|
+
/* @__PURE__ */ e(_, { user: d, showDid: !0, cardType: P.Detailed, infoType: $.Minimal }),
|
107
108
|
/* @__PURE__ */ e(l, {})
|
108
109
|
] }) : null,
|
109
|
-
|
110
|
-
/* @__PURE__ */
|
111
|
-
|
112
|
-
|
113
|
-
sx: {
|
114
|
-
border: "1px solid",
|
115
|
-
borderColor: "divider",
|
116
|
-
borderRadius: 2,
|
117
|
-
overflow: "hidden",
|
118
|
-
my: 1
|
119
|
-
}
|
120
|
-
}
|
121
|
-
),
|
122
|
-
/* @__PURE__ */ o(N, { direction: "row", spacing: 2, children: [
|
123
|
-
y ? null : /* @__PURE__ */ e(
|
124
|
-
h,
|
110
|
+
x,
|
111
|
+
A ? null : /* @__PURE__ */ o(m, { children: [
|
112
|
+
/* @__PURE__ */ e(
|
113
|
+
l,
|
125
114
|
{
|
126
|
-
color: "inherit",
|
127
|
-
variant: "outlined",
|
128
|
-
size: "large",
|
129
|
-
fullWidth: !0,
|
130
|
-
onClick: M,
|
131
115
|
sx: {
|
132
|
-
|
133
|
-
|
134
|
-
|
116
|
+
border: "1px solid",
|
117
|
+
borderColor: "divider",
|
118
|
+
borderRadius: 2,
|
119
|
+
overflow: "hidden",
|
120
|
+
my: 1
|
121
|
+
}
|
135
122
|
}
|
136
123
|
),
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
n.loading
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
124
|
+
/* @__PURE__ */ o(q, { direction: "row", spacing: 2, children: [
|
125
|
+
z ? null : /* @__PURE__ */ e(
|
126
|
+
h,
|
127
|
+
{
|
128
|
+
color: "inherit",
|
129
|
+
variant: "outlined",
|
130
|
+
size: "large",
|
131
|
+
fullWidth: !0,
|
132
|
+
onClick: U,
|
133
|
+
sx: {
|
134
|
+
color: "grey.500"
|
135
|
+
},
|
136
|
+
children: w || t("cancel")
|
137
|
+
}
|
138
|
+
),
|
139
|
+
d && !y ? /* @__PURE__ */ o(
|
140
|
+
h,
|
141
|
+
{
|
142
|
+
variant: "contained",
|
143
|
+
size: "large",
|
144
|
+
fullWidth: !0,
|
145
|
+
onClick: R,
|
146
|
+
disabled: n.loading,
|
147
|
+
children: [
|
148
|
+
n.loading ? /* @__PURE__ */ e(u, { size: 20, sx: { mr: 1 } }) : null,
|
149
|
+
k || t("authorize")
|
150
|
+
]
|
151
|
+
}
|
152
|
+
) : /* @__PURE__ */ o(
|
153
|
+
h,
|
154
|
+
{
|
155
|
+
variant: "contained",
|
156
|
+
size: "large",
|
157
|
+
fullWidth: !0,
|
158
|
+
disabled: n.loading,
|
159
|
+
onClick: F,
|
160
|
+
children: [
|
161
|
+
n.loading ? /* @__PURE__ */ e(u, { size: 20, sx: { mr: 1 } }) : null,
|
162
|
+
T || t("connect")
|
163
|
+
]
|
164
|
+
}
|
165
|
+
)
|
166
|
+
] })
|
164
167
|
] }),
|
165
|
-
|
166
|
-
|
168
|
+
v || !d ? null : /* @__PURE__ */ e(l, { sx: { textAlign: "center" }, children: /* @__PURE__ */ o(
|
169
|
+
E,
|
167
170
|
{
|
168
171
|
variant: "body2",
|
169
172
|
sx: {
|
@@ -173,17 +176,17 @@ function pe({
|
|
173
176
|
gap: 1
|
174
177
|
},
|
175
178
|
children: [
|
176
|
-
|
179
|
+
b || t("notThis"),
|
177
180
|
" ",
|
178
181
|
/* @__PURE__ */ e(
|
179
|
-
|
182
|
+
G,
|
180
183
|
{
|
181
184
|
underline: "hover",
|
182
|
-
onClick:
|
185
|
+
onClick: M,
|
183
186
|
sx: {
|
184
187
|
cursor: "pointer"
|
185
188
|
},
|
186
|
-
children:
|
189
|
+
children: D || t("useAnother")
|
187
190
|
}
|
188
191
|
)
|
189
192
|
]
|
@@ -196,5 +199,5 @@ function pe({
|
|
196
199
|
) });
|
197
200
|
}
|
198
201
|
export {
|
199
|
-
|
202
|
+
fe as default
|
200
203
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.2",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -60,16 +60,16 @@
|
|
60
60
|
"react": "^19.0.0",
|
61
61
|
"react-router-dom": "^6.22.3"
|
62
62
|
},
|
63
|
-
"gitHead": "
|
63
|
+
"gitHead": "0a05fe684c5dcfb2eb5f0e1343aecdd9778bcbb9",
|
64
64
|
"dependencies": {
|
65
|
-
"@arcblock/bridge": "3.1.
|
65
|
+
"@arcblock/bridge": "3.1.2",
|
66
66
|
"@arcblock/did": "^1.21.2",
|
67
67
|
"@arcblock/did-motif": "^1.1.14",
|
68
|
-
"@arcblock/icons": "3.1.
|
69
|
-
"@arcblock/nft-display": "3.1.
|
70
|
-
"@arcblock/react-hooks": "3.1.
|
68
|
+
"@arcblock/icons": "3.1.2",
|
69
|
+
"@arcblock/nft-display": "3.1.2",
|
70
|
+
"@arcblock/react-hooks": "3.1.2",
|
71
71
|
"@blocklet/js-sdk": "^1.16.46",
|
72
|
-
"@blocklet/theme": "3.1.
|
72
|
+
"@blocklet/theme": "3.1.2",
|
73
73
|
"@fontsource/roboto": "~5.1.1",
|
74
74
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
75
75
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -44,6 +44,7 @@ export default function AuthApps({
|
|
44
44
|
hideSwitchConnect = false,
|
45
45
|
hideAuthorize = false,
|
46
46
|
hideCancel = false,
|
47
|
+
hideButton = false,
|
47
48
|
|
48
49
|
notThisText = undefined,
|
49
50
|
authorizeText = undefined,
|
@@ -68,6 +69,7 @@ export default function AuthApps({
|
|
68
69
|
hideSwitchConnect?: boolean;
|
69
70
|
hideAuthorize?: boolean;
|
70
71
|
hideCancel?: boolean;
|
72
|
+
hideButton?: boolean;
|
71
73
|
|
72
74
|
notThisText?: string;
|
73
75
|
authorizeText?: string;
|
@@ -170,52 +172,56 @@ export default function AuthApps({
|
|
170
172
|
|
171
173
|
{children}
|
172
174
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
borderColor: 'divider',
|
177
|
-
borderRadius: 2,
|
178
|
-
overflow: 'hidden',
|
179
|
-
my: 1,
|
180
|
-
}}
|
181
|
-
/>
|
182
|
-
|
183
|
-
<Stack direction="row" spacing={2}>
|
184
|
-
{!hideCancel ? (
|
185
|
-
<Button
|
186
|
-
color="inherit"
|
187
|
-
variant="outlined"
|
188
|
-
size="large"
|
189
|
-
fullWidth
|
190
|
-
onClick={handleCancel}
|
175
|
+
{hideButton ? null : (
|
176
|
+
<>
|
177
|
+
<Box
|
191
178
|
sx={{
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
{
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
179
|
+
border: '1px solid',
|
180
|
+
borderColor: 'divider',
|
181
|
+
borderRadius: 2,
|
182
|
+
overflow: 'hidden',
|
183
|
+
my: 1,
|
184
|
+
}}
|
185
|
+
/>
|
186
|
+
|
187
|
+
<Stack direction="row" spacing={2}>
|
188
|
+
{!hideCancel ? (
|
189
|
+
<Button
|
190
|
+
color="inherit"
|
191
|
+
variant="outlined"
|
192
|
+
size="large"
|
193
|
+
fullWidth
|
194
|
+
onClick={handleCancel}
|
195
|
+
sx={{
|
196
|
+
color: 'grey.500',
|
197
|
+
}}>
|
198
|
+
{cancelText || t('cancel')}
|
199
|
+
</Button>
|
200
|
+
) : null}
|
201
|
+
{user && !hideAuthorize ? (
|
202
|
+
<Button
|
203
|
+
variant="contained"
|
204
|
+
size="large"
|
205
|
+
fullWidth
|
206
|
+
onClick={handleAuthorize}
|
207
|
+
disabled={currentState.loading}>
|
208
|
+
{currentState.loading ? <CircularProgress size={20} sx={{ mr: 1 }} /> : null}
|
209
|
+
{authorizeText || t('authorize')}
|
210
|
+
</Button>
|
211
|
+
) : (
|
212
|
+
<Button
|
213
|
+
variant="contained"
|
214
|
+
size="large"
|
215
|
+
fullWidth
|
216
|
+
disabled={currentState.loading}
|
217
|
+
onClick={handleConnect}>
|
218
|
+
{currentState.loading ? <CircularProgress size={20} sx={{ mr: 1 }} /> : null}
|
219
|
+
{connectText || t('connect')}
|
220
|
+
</Button>
|
221
|
+
)}
|
222
|
+
</Stack>
|
223
|
+
</>
|
224
|
+
)}
|
219
225
|
|
220
226
|
{hideSwitchConnect || !user ? null : (
|
221
227
|
<Box sx={{ textAlign: 'center' }}>
|
@@ -34,7 +34,7 @@ dayjs.updateLocale('zh-cn', {
|
|
34
34
|
yy: '%d 年',
|
35
35
|
},
|
36
36
|
});
|
37
|
-
// FIXME:
|
37
|
+
// FIXME: @zhanghan 此处不能真正的将 relativeTime 设置为支持中文
|
38
38
|
setDateTool(dayjs);
|
39
39
|
|
40
40
|
const translations: Record<Locale, { utc: string; local: string; shortUTC: string; shortLocal: string }> = {
|