@arcblock/ux 3.0.27 → 3.0.29
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/lib/DIDConnect/auth-apps/auth-apps-info.js +48 -21
- package/lib/RelativeTime/index.js +48 -48
- package/lib/Tag/index.d.ts +2 -2
- package/lib/Theme/theme.d.ts +2 -1
- package/package.json +7 -7
- package/src/DIDConnect/auth-apps/auth-apps-info.tsx +37 -2
- package/src/RelativeTime/index.tsx +4 -2
- package/src/Tag/index.jsx +1 -1
- package/src/Theme/theme.ts +3 -7
@@ -1,12 +1,21 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { Box as
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
2
|
+
import { Box as r, Typography as n } from "@mui/material";
|
3
|
+
import i from "../../Img/index.js";
|
4
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as s } from "../../Util/constant.js";
|
5
|
+
const l = (e) => {
|
6
|
+
if (!e) return "";
|
7
|
+
try {
|
8
|
+
return new URL(e).protocol !== "https:" ? (console.warn("Image URL must use HTTPS protocol:", e), "") : `${s}/proxy?url=${e}`;
|
9
|
+
} catch (t) {
|
10
|
+
return console.warn("Invalid image URL format:", e, t), "";
|
11
|
+
}
|
12
|
+
};
|
13
|
+
function g({
|
14
|
+
requestAppInfo: e,
|
15
|
+
currentAppInfo: t
|
7
16
|
}) {
|
8
|
-
return /* @__PURE__ */
|
9
|
-
|
17
|
+
return /* @__PURE__ */ a(
|
18
|
+
r,
|
10
19
|
{
|
11
20
|
sx: {
|
12
21
|
textAlign: "center",
|
@@ -16,8 +25,8 @@ function c({
|
|
16
25
|
gap: 2
|
17
26
|
},
|
18
27
|
children: [
|
19
|
-
/* @__PURE__ */
|
20
|
-
|
28
|
+
/* @__PURE__ */ a(
|
29
|
+
r,
|
21
30
|
{
|
22
31
|
sx: {
|
23
32
|
display: "flex",
|
@@ -25,9 +34,18 @@ function c({
|
|
25
34
|
justifyContent: "center"
|
26
35
|
},
|
27
36
|
children: [
|
28
|
-
/* @__PURE__ */
|
29
|
-
|
30
|
-
|
37
|
+
/* @__PURE__ */ o(
|
38
|
+
i,
|
39
|
+
{
|
40
|
+
src: t.appLogo,
|
41
|
+
alt: "Server",
|
42
|
+
width: 48,
|
43
|
+
height: 48,
|
44
|
+
fallback: l(t.appLogo)
|
45
|
+
}
|
46
|
+
),
|
47
|
+
/* @__PURE__ */ a(
|
48
|
+
r,
|
31
49
|
{
|
32
50
|
sx: {
|
33
51
|
mx: 2,
|
@@ -42,18 +60,27 @@ function c({
|
|
42
60
|
}
|
43
61
|
},
|
44
62
|
children: [
|
45
|
-
/* @__PURE__ */
|
46
|
-
/* @__PURE__ */
|
47
|
-
/* @__PURE__ */
|
63
|
+
/* @__PURE__ */ o(r, { className: "dot" }),
|
64
|
+
/* @__PURE__ */ o(r, { className: "dot" }),
|
65
|
+
/* @__PURE__ */ o(r, { className: "dot" })
|
48
66
|
]
|
49
67
|
}
|
50
68
|
),
|
51
|
-
/* @__PURE__ */
|
69
|
+
/* @__PURE__ */ o(
|
70
|
+
i,
|
71
|
+
{
|
72
|
+
src: e.appLogo,
|
73
|
+
alt: e.appName,
|
74
|
+
width: 48,
|
75
|
+
height: 48,
|
76
|
+
fallback: l(e.appLogo)
|
77
|
+
}
|
78
|
+
)
|
52
79
|
]
|
53
80
|
}
|
54
81
|
),
|
55
|
-
/* @__PURE__ */
|
56
|
-
|
82
|
+
/* @__PURE__ */ a(
|
83
|
+
n,
|
57
84
|
{
|
58
85
|
sx: {
|
59
86
|
mb: 1,
|
@@ -62,7 +89,7 @@ function c({
|
|
62
89
|
children: [
|
63
90
|
"Authorize",
|
64
91
|
" ",
|
65
|
-
/* @__PURE__ */
|
92
|
+
/* @__PURE__ */ o(r, { component: "span", sx: { color: "primary.main" }, children: e.appName })
|
66
93
|
]
|
67
94
|
}
|
68
95
|
)
|
@@ -71,5 +98,5 @@ function c({
|
|
71
98
|
);
|
72
99
|
}
|
73
100
|
export {
|
74
|
-
|
101
|
+
g as default
|
75
102
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { jsxs as I, jsx as n, Fragment as F } from "react/jsx-runtime";
|
2
2
|
import { Box as a, Tooltip as M } from "@mui/material";
|
3
3
|
import { useEffect as R, useMemo as $ } from "react";
|
4
|
-
import
|
4
|
+
import s from "dayjs";
|
5
5
|
import "dayjs/locale/zh-cn";
|
6
6
|
import k from "dayjs/plugin/utc";
|
7
7
|
import B from "dayjs/plugin/timezone";
|
@@ -10,12 +10,12 @@ import H from "dayjs/plugin/updateLocale";
|
|
10
10
|
import N from "dayjs/plugin/localizedFormat";
|
11
11
|
import { create as Z } from "zustand";
|
12
12
|
import { formatToDatetime as O, setDateTool as q } from "../Util/index.js";
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
s.extend(N);
|
14
|
+
s.extend(k);
|
15
|
+
s.extend(B);
|
16
|
+
s.extend(H);
|
17
|
+
s.extend(E);
|
18
|
+
s.updateLocale("zh-cn", {
|
19
19
|
// copy with https://github.com/iamkun/dayjs/blob/dev/src/locale/zh-cn.js
|
20
20
|
relativeTime: {
|
21
21
|
future: "%s后",
|
@@ -33,7 +33,7 @@ c.updateLocale("zh-cn", {
|
|
33
33
|
yy: "%d 年"
|
34
34
|
}
|
35
35
|
});
|
36
|
-
q(
|
36
|
+
q(s);
|
37
37
|
const j = {
|
38
38
|
en: {
|
39
39
|
utc: "UTC Timezone",
|
@@ -56,33 +56,33 @@ function w({
|
|
56
56
|
locale: o = "en",
|
57
57
|
withoutSuffix: p = !1,
|
58
58
|
from: d = "",
|
59
|
-
to:
|
59
|
+
to: x = "",
|
60
60
|
type: i = "relative",
|
61
61
|
tz: l,
|
62
|
-
relativeRange:
|
63
|
-
format:
|
62
|
+
relativeRange: m,
|
63
|
+
format: g
|
64
64
|
}) {
|
65
|
-
const
|
65
|
+
const C = (/* @__PURE__ */ new Date()).getTimezoneOffset(), T = C > 0 ? "-" : "+", v = Math.abs(C) / 60, L = C === 0, r = A((y) => y.isUtc), U = A((y) => y.setIsUtc);
|
66
66
|
if (R(() => {
|
67
|
-
|
68
|
-
}, [
|
69
|
-
return { innerContent: "-", popContent: "-", isUtc: r, setIsUtc:
|
70
|
-
const
|
71
|
-
let
|
72
|
-
i === "utc" && (
|
73
|
-
const f = O(t, { locale:
|
67
|
+
U(L);
|
68
|
+
}, [L]), !t)
|
69
|
+
return { innerContent: "-", popContent: "-", isUtc: r, setIsUtc: U, sign: T, hoursOffset: v };
|
70
|
+
const h = o === "zh" ? "zh-cn" : "en-us";
|
71
|
+
let c = s(t).locale(h);
|
72
|
+
i === "utc" && (c = s(t).utc().locale(h)), l && (c = c.tz(l));
|
73
|
+
const f = O(t, { locale: h, tz: l, format: g });
|
74
74
|
let e;
|
75
75
|
if (d)
|
76
|
-
e =
|
77
|
-
else if (
|
78
|
-
e =
|
79
|
-
else if (
|
80
|
-
const
|
81
|
-
Math.abs(
|
76
|
+
e = c.from(d, p);
|
77
|
+
else if (x)
|
78
|
+
e = c.to(x, p);
|
79
|
+
else if (m) {
|
80
|
+
const y = c.diff(s());
|
81
|
+
Math.abs(y) > m && (e = f);
|
82
82
|
}
|
83
|
-
e || (e =
|
84
|
-
let
|
85
|
-
return i === "absolute" && (
|
83
|
+
e || (e = c.fromNow(p));
|
84
|
+
let u = e, b = f;
|
85
|
+
return i === "absolute" && (u = f, b = e), i === "utc" && (r ? (u = O(t, { locale: h, tz: l, isUtc: !0, format: g }), b = O(t, { locale: h, tz: l, isUtc: !0, format: g })) : (u = f, b = e)), { innerContent: u, popContent: b, isUtc: r, setIsUtc: U, sign: T, hoursOffset: v, relativeString: e, absoluteString: f };
|
86
86
|
}
|
87
87
|
function z({
|
88
88
|
locale: t,
|
@@ -90,9 +90,9 @@ function z({
|
|
90
90
|
setIsUtc: p,
|
91
91
|
useShortTimezone: d = !0
|
92
92
|
}) {
|
93
|
-
const
|
94
|
-
const i = d ? "shortUTC" : "utc", l = d ? "shortLocal" : "local";
|
95
|
-
return o ? `${
|
93
|
+
const x = $(() => {
|
94
|
+
const i = d ? "shortUTC" : "utc", l = d ? "shortLocal" : "local", m = j[t] || j.en;
|
95
|
+
return o ? `${m[i]}` : `${m[l]}`;
|
96
96
|
}, [t, d, o]);
|
97
97
|
return /* @__PURE__ */ n(
|
98
98
|
a,
|
@@ -108,7 +108,7 @@ function z({
|
|
108
108
|
lineHeight: 1
|
109
109
|
},
|
110
110
|
onClick: () => p(!o),
|
111
|
-
children:
|
111
|
+
children: x
|
112
112
|
}
|
113
113
|
);
|
114
114
|
}
|
@@ -117,29 +117,29 @@ function et({
|
|
117
117
|
locale: o = "en",
|
118
118
|
withoutSuffix: p = !1,
|
119
119
|
from: d = "",
|
120
|
-
to:
|
120
|
+
to: x = "",
|
121
121
|
type: i = "relative",
|
122
122
|
tz: l = void 0,
|
123
|
-
relativeRange:
|
124
|
-
enableTooltip:
|
123
|
+
relativeRange: m = void 0,
|
124
|
+
enableTooltip: g = !0,
|
125
125
|
useShortTimezone: D = !1,
|
126
|
-
disableTimezone:
|
127
|
-
placement:
|
126
|
+
disableTimezone: C = !1,
|
127
|
+
placement: T = "top-end",
|
128
128
|
format: v = "lll",
|
129
|
-
mode:
|
129
|
+
mode: L = "all",
|
130
130
|
...r
|
131
131
|
}) {
|
132
|
-
const { innerContent:
|
132
|
+
const { innerContent: U, popContent: h, isUtc: c, setIsUtc: f, relativeString: e } = w({
|
133
133
|
value: t,
|
134
134
|
locale: o,
|
135
135
|
withoutSuffix: p,
|
136
136
|
from: d,
|
137
|
-
to:
|
137
|
+
to: x,
|
138
138
|
type: i === "all" ? "utc" : i,
|
139
139
|
tz: l,
|
140
|
-
relativeRange:
|
140
|
+
relativeRange: m,
|
141
141
|
format: v
|
142
|
-
}),
|
142
|
+
}), u = /* @__PURE__ */ I(
|
143
143
|
a,
|
144
144
|
{
|
145
145
|
...r,
|
@@ -152,17 +152,17 @@ function et({
|
|
152
152
|
...Array.isArray(r.sx) ? r.sx : [r.sx]
|
153
153
|
],
|
154
154
|
children: [
|
155
|
-
/* @__PURE__ */ n(a, { component: "span", ...r, sx: {}, children:
|
155
|
+
/* @__PURE__ */ n(a, { component: "span", ...r, sx: {}, children: U }),
|
156
156
|
/* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: "·" }),
|
157
157
|
/* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: e }),
|
158
|
-
!
|
158
|
+
!C && /* @__PURE__ */ I(F, { children: [
|
159
159
|
/* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: "·" }),
|
160
|
-
/* @__PURE__ */ n(z, { locale: o, isUtc:
|
160
|
+
/* @__PURE__ */ n(z, { locale: o, isUtc: c, setIsUtc: f, useShortTimezone: D })
|
161
161
|
] })
|
162
162
|
]
|
163
163
|
}
|
164
164
|
);
|
165
|
-
return
|
165
|
+
return L === "daysLeft" ? /* @__PURE__ */ n(M, { title: u, placement: T, enterTouchDelay: 0, children: /* @__PURE__ */ n(a, { component: "span", children: e }) }) : i === "all" && L === "all" ? /* @__PURE__ */ n(M, { title: void 0, placement: T, enterTouchDelay: 0, children: u }) : /* @__PURE__ */ n(M, { title: g ? h : void 0, placement: T, enterTouchDelay: 0, children: /* @__PURE__ */ I(
|
166
166
|
a,
|
167
167
|
{
|
168
168
|
sx: {
|
@@ -171,8 +171,8 @@ function et({
|
|
171
171
|
gap: 1
|
172
172
|
},
|
173
173
|
children: [
|
174
|
-
/* @__PURE__ */ n(a, { component: "span", ...r, children:
|
175
|
-
i === "utc" && !
|
174
|
+
/* @__PURE__ */ n(a, { component: "span", ...r, children: U }),
|
175
|
+
i === "utc" && !C && /* @__PURE__ */ n(z, { locale: o, isUtc: c, setIsUtc: f, useShortTimezone: D })
|
176
176
|
]
|
177
177
|
}
|
178
178
|
) });
|
package/lib/Tag/index.d.ts
CHANGED
@@ -23,9 +23,9 @@ export type TagProps = TypographyProps & TagOwnProps;
|
|
23
23
|
/**
|
24
24
|
* @description
|
25
25
|
* @param {TagProps} props
|
26
|
-
* @return {
|
26
|
+
* @return {JSX.Element}
|
27
27
|
*/
|
28
|
-
declare function Tag({ ...rawProps }: TagProps):
|
28
|
+
declare function Tag({ ...rawProps }: TagProps): JSX.Element;
|
29
29
|
declare namespace Tag {
|
30
30
|
namespace propTypes {
|
31
31
|
let children: PropTypes.Validator<any>;
|
package/lib/Theme/theme.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { PaletteMode } from '@mui/material';
|
2
2
|
import { deepmerge } from '@mui/utils';
|
3
|
+
import { ThemeOptions, Theme } from '@blocklet/theme';
|
3
4
|
/** 是否是 MUI Theme 对象 */
|
4
5
|
export declare function isTheme(obj: any): obj is Theme;
|
5
6
|
/** 是否是 UX Theme 对象 */
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.29",
|
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": "3c3532881441518b47bce00147ba469a03baad78",
|
64
64
|
"dependencies": {
|
65
|
-
"@arcblock/bridge": "3.0.
|
65
|
+
"@arcblock/bridge": "3.0.29",
|
66
66
|
"@arcblock/did": "^1.20.15",
|
67
67
|
"@arcblock/did-motif": "^1.1.14",
|
68
|
-
"@arcblock/icons": "3.0.
|
69
|
-
"@arcblock/nft-display": "3.0.
|
70
|
-
"@arcblock/react-hooks": "3.0.
|
68
|
+
"@arcblock/icons": "3.0.29",
|
69
|
+
"@arcblock/nft-display": "3.0.29",
|
70
|
+
"@arcblock/react-hooks": "3.0.29",
|
71
71
|
"@blocklet/js-sdk": "^1.16.46",
|
72
|
-
"@blocklet/theme": "3.0.
|
72
|
+
"@blocklet/theme": "3.0.29",
|
73
73
|
"@fontsource/roboto": "~5.1.1",
|
74
74
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
75
75
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -1,5 +1,28 @@
|
|
1
1
|
import { Box, Typography } from '@mui/material';
|
2
2
|
import Img from '../../Img';
|
3
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX } from '../../Util/constant';
|
4
|
+
|
5
|
+
const getProxyImageUrl = (url: string) => {
|
6
|
+
if (!url) return '';
|
7
|
+
|
8
|
+
try {
|
9
|
+
// 检查是否是一个有效的URL
|
10
|
+
const urlObj = new URL(url);
|
11
|
+
|
12
|
+
// 检查协议是否是https
|
13
|
+
if (urlObj.protocol !== 'https:') {
|
14
|
+
console.warn('Image URL must use HTTPS protocol:', url);
|
15
|
+
return '';
|
16
|
+
}
|
17
|
+
|
18
|
+
// 返回代理URL
|
19
|
+
return `${BLOCKLET_SERVICE_PATH_PREFIX}/proxy?url=${url}`;
|
20
|
+
} catch (error) {
|
21
|
+
// URL construction failed, indicating invalid URL format
|
22
|
+
console.warn('Invalid image URL format:', url, error);
|
23
|
+
return '';
|
24
|
+
}
|
25
|
+
};
|
3
26
|
|
4
27
|
export type RequestAppInfo = {
|
5
28
|
appLogo: string;
|
@@ -36,7 +59,13 @@ export default function AuthAppsInfo({
|
|
36
59
|
justifyContent: 'center',
|
37
60
|
}}>
|
38
61
|
{/* FIXME: @zhanghan 增加 hover 的效果 */}
|
39
|
-
<Img
|
62
|
+
<Img
|
63
|
+
src={currentAppInfo.appLogo}
|
64
|
+
alt="Server"
|
65
|
+
width={48}
|
66
|
+
height={48}
|
67
|
+
fallback={getProxyImageUrl(currentAppInfo.appLogo)}
|
68
|
+
/>
|
40
69
|
|
41
70
|
<Box
|
42
71
|
sx={{
|
@@ -57,7 +86,13 @@ export default function AuthAppsInfo({
|
|
57
86
|
</Box>
|
58
87
|
|
59
88
|
{/* FIXME: @zhanghan 增加 hover 的效果 */}
|
60
|
-
<Img
|
89
|
+
<Img
|
90
|
+
src={requestAppInfo.appLogo}
|
91
|
+
alt={requestAppInfo.appName}
|
92
|
+
width={48}
|
93
|
+
height={48}
|
94
|
+
fallback={getProxyImageUrl(requestAppInfo.appLogo)}
|
95
|
+
/>
|
61
96
|
</Box>
|
62
97
|
|
63
98
|
<Typography
|
@@ -180,12 +180,14 @@ function UTCChip({
|
|
180
180
|
const text = useMemo(() => {
|
181
181
|
const UTC = useShortTimezone ? 'shortUTC' : 'utc';
|
182
182
|
const LOCAL = useShortTimezone ? 'shortLocal' : 'local';
|
183
|
+
// fallback to en
|
184
|
+
const config = translations[locale] || translations.en;
|
183
185
|
|
184
186
|
if (isUtc) {
|
185
|
-
return `${
|
187
|
+
return `${config[UTC]}`;
|
186
188
|
}
|
187
189
|
|
188
|
-
return `${
|
190
|
+
return `${config[LOCAL]}`;
|
189
191
|
}, [locale, useShortTimezone, isUtc]);
|
190
192
|
|
191
193
|
return (
|
package/src/Tag/index.jsx
CHANGED
package/src/Theme/theme.ts
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
/* eslint-disable no-shadow */
|
2
2
|
// https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
|
3
|
-
import {
|
4
|
-
createTheme as _createTheme,
|
5
|
-
responsiveFontSizes,
|
6
|
-
type ThemeOptions,
|
7
|
-
type PaletteMode,
|
8
|
-
type Theme,
|
9
|
-
} from '@mui/material';
|
3
|
+
import { createTheme as _createTheme, responsiveFontSizes, type PaletteMode } from '@mui/material';
|
10
4
|
import { deepmerge } from '@mui/utils';
|
11
5
|
import webfontloader from 'webfontloader';
|
12
6
|
import {
|
@@ -15,6 +9,8 @@ import {
|
|
15
9
|
DEFAULT_FONTS,
|
16
10
|
getDefaultThemePrefer,
|
17
11
|
getBlockletThemeOptions,
|
12
|
+
type ThemeOptions,
|
13
|
+
type Theme,
|
18
14
|
} from '@blocklet/theme';
|
19
15
|
import { cleanedObj, deepmergeAll } from '../Util';
|
20
16
|
|