@arcblock/ux 3.0.24 → 3.0.26
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.
@@ -0,0 +1,11 @@
|
|
1
|
+
export interface NftInfo {
|
2
|
+
address: string;
|
3
|
+
data: Record<string, any>;
|
4
|
+
display: Record<string, any>;
|
5
|
+
issuer: string;
|
6
|
+
}
|
7
|
+
export default function NftPreview({ visible, onClose, nft, }: {
|
8
|
+
visible: boolean;
|
9
|
+
onClose: () => void;
|
10
|
+
nft: NftInfo | null;
|
11
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
2
|
+
import n from "@mui/material/Modal";
|
3
|
+
import r from "@emotion/styled";
|
4
|
+
import a, { getNFTData as s } from "./index.js";
|
5
|
+
function f({
|
6
|
+
visible: e,
|
7
|
+
onClose: o,
|
8
|
+
nft: i
|
9
|
+
}) {
|
10
|
+
return !e || !i ? null : /* @__PURE__ */ t(d, { children: /* @__PURE__ */ t(n, { open: e, onClose: o, children: /* @__PURE__ */ t(h, { onClick: o, children: /* @__PURE__ */ t(a, { data: s(i), address: i.address, inset: !0 }) }) }) });
|
11
|
+
}
|
12
|
+
const d = r.div`
|
13
|
+
position: relative;
|
14
|
+
width: 100%;
|
15
|
+
height: 100%;
|
16
|
+
cursor: pointer;
|
17
|
+
|
18
|
+
&:hover {
|
19
|
+
.mask {
|
20
|
+
opacity: 1;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
.mask {
|
25
|
+
position: absolute;
|
26
|
+
top: 0;
|
27
|
+
left: 0;
|
28
|
+
display: flex;
|
29
|
+
align-items: center;
|
30
|
+
justify-content: center;
|
31
|
+
width: 100%;
|
32
|
+
height: 100%;
|
33
|
+
background: rgba(0, 0, 0, 0.6);
|
34
|
+
opacity: 0;
|
35
|
+
transition: opacity 0.2s;
|
36
|
+
}
|
37
|
+
`, h = r.div`
|
38
|
+
display: flex;
|
39
|
+
justify-content: center;
|
40
|
+
align-items: center;
|
41
|
+
height: 100vh;
|
42
|
+
width: 100vw;
|
43
|
+
|
44
|
+
img,
|
45
|
+
object {
|
46
|
+
max-width: 90vw;
|
47
|
+
max-height: 75vh;
|
48
|
+
}
|
49
|
+
|
50
|
+
.nft-display--inset {
|
51
|
+
> .MuiBox-root,
|
52
|
+
.nft-display__loading {
|
53
|
+
width: 75vmin;
|
54
|
+
height: 75vmin;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
`;
|
58
|
+
export {
|
59
|
+
f as default
|
60
|
+
};
|
@@ -15,5 +15,6 @@ export interface RelativeTimeProps {
|
|
15
15
|
placement?: TooltipProps['placement'];
|
16
16
|
sx?: SxProps;
|
17
17
|
format?: string;
|
18
|
+
mode?: 'all' | 'daysLeft';
|
18
19
|
}
|
19
|
-
export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, useShortTimezone, disableTimezone, placement, format, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
|
20
|
+
export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, useShortTimezone, disableTimezone, placement, format, mode, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { jsxs as I, jsx as n, Fragment as F } from "react/jsx-runtime";
|
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 c 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";
|
@@ -9,13 +9,13 @@ import E from "dayjs/plugin/relativeTime";
|
|
9
9
|
import H from "dayjs/plugin/updateLocale";
|
10
10
|
import N from "dayjs/plugin/localizedFormat";
|
11
11
|
import { create as Z } from "zustand";
|
12
|
-
import { formatToDatetime as
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
import { formatToDatetime as O, setDateTool as q } from "../Util/index.js";
|
13
|
+
c.extend(N);
|
14
|
+
c.extend(k);
|
15
|
+
c.extend(B);
|
16
|
+
c.extend(H);
|
17
|
+
c.extend(E);
|
18
|
+
c.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 @@ r.updateLocale("zh-cn", {
|
|
33
33
|
yy: "%d 年"
|
34
34
|
}
|
35
35
|
});
|
36
|
-
q(
|
36
|
+
q(c);
|
37
37
|
const j = {
|
38
38
|
en: {
|
39
39
|
utc: "UTC Timezone",
|
@@ -47,123 +47,123 @@ const j = {
|
|
47
47
|
shortUTC: "UTC",
|
48
48
|
shortLocal: "当前时区"
|
49
49
|
}
|
50
|
-
},
|
50
|
+
}, A = Z((t) => ({
|
51
51
|
isUtc: !1,
|
52
|
-
setIsUtc: (
|
52
|
+
setIsUtc: (o) => t({ isUtc: o })
|
53
53
|
}));
|
54
54
|
function w({
|
55
55
|
value: t,
|
56
|
-
locale:
|
57
|
-
withoutSuffix:
|
58
|
-
from:
|
59
|
-
to:
|
60
|
-
type:
|
61
|
-
tz:
|
62
|
-
relativeRange:
|
63
|
-
format:
|
56
|
+
locale: o = "en",
|
57
|
+
withoutSuffix: p = !1,
|
58
|
+
from: d = "",
|
59
|
+
to: u = "",
|
60
|
+
type: i = "relative",
|
61
|
+
tz: l,
|
62
|
+
relativeRange: y,
|
63
|
+
format: U
|
64
64
|
}) {
|
65
|
-
const
|
65
|
+
const x = (/* @__PURE__ */ new Date()).getTimezoneOffset(), C = x > 0 ? "-" : "+", v = Math.abs(x) / 60, g = x === 0, r = A((L) => L.isUtc), T = A((L) => L.setIsUtc);
|
66
66
|
if (R(() => {
|
67
|
-
T(
|
68
|
-
}, [
|
69
|
-
return { innerContent: "-", popContent: "-", isUtc:
|
70
|
-
const
|
71
|
-
let
|
72
|
-
|
73
|
-
const
|
74
|
-
let
|
75
|
-
if (
|
76
|
-
|
77
|
-
else if (
|
78
|
-
|
79
|
-
else if (
|
80
|
-
const
|
81
|
-
Math.abs(
|
67
|
+
T(g);
|
68
|
+
}, [g]), !t)
|
69
|
+
return { innerContent: "-", popContent: "-", isUtc: r, setIsUtc: T, sign: C, hoursOffset: v };
|
70
|
+
const m = o === "zh" ? "zh-cn" : "en-us";
|
71
|
+
let s = c(t).locale(m);
|
72
|
+
i === "utc" && (s = c(t).utc().locale(m)), l && (s = s.tz(l));
|
73
|
+
const f = O(t, { locale: m, tz: l, format: U });
|
74
|
+
let e;
|
75
|
+
if (d)
|
76
|
+
e = s.from(d, p);
|
77
|
+
else if (u)
|
78
|
+
e = s.to(u, p);
|
79
|
+
else if (y) {
|
80
|
+
const L = s.diff(c());
|
81
|
+
Math.abs(L) > y && (e = f);
|
82
82
|
}
|
83
|
-
|
84
|
-
let
|
85
|
-
return
|
83
|
+
e || (e = s.fromNow(p));
|
84
|
+
let h = e, b = f;
|
85
|
+
return i === "absolute" && (h = f, b = e), i === "utc" && (r ? (h = O(t, { locale: m, tz: l, isUtc: !0, format: U }), b = O(t, { locale: m, tz: l, isUtc: !0, format: U })) : (h = f, b = e)), { innerContent: h, popContent: b, isUtc: r, setIsUtc: T, sign: C, hoursOffset: v, relativeString: e, absoluteString: f };
|
86
86
|
}
|
87
|
-
function
|
87
|
+
function z({
|
88
88
|
locale: t,
|
89
|
-
isUtc:
|
90
|
-
setIsUtc:
|
91
|
-
useShortTimezone:
|
89
|
+
isUtc: o = !1,
|
90
|
+
setIsUtc: p,
|
91
|
+
useShortTimezone: d = !0
|
92
92
|
}) {
|
93
|
-
const
|
94
|
-
const
|
95
|
-
return
|
96
|
-
}, [t,
|
97
|
-
return /* @__PURE__ */
|
98
|
-
|
93
|
+
const u = $(() => {
|
94
|
+
const i = d ? "shortUTC" : "utc", l = d ? "shortLocal" : "local";
|
95
|
+
return o ? `${j[t][i]}` : `${j[t][l]}`;
|
96
|
+
}, [t, d, o]);
|
97
|
+
return /* @__PURE__ */ n(
|
98
|
+
a,
|
99
99
|
{
|
100
100
|
component: "span",
|
101
101
|
sx: {
|
102
102
|
color: "inherit",
|
103
103
|
cursor: "pointer",
|
104
104
|
border: "1px solid",
|
105
|
-
fontSize: "0.8rem",
|
106
105
|
borderColor: "divider",
|
107
106
|
borderRadius: "20px",
|
108
107
|
padding: "4px 8px",
|
109
108
|
lineHeight: 1
|
110
109
|
},
|
111
|
-
onClick: () =>
|
112
|
-
children:
|
110
|
+
onClick: () => p(!o),
|
111
|
+
children: u
|
113
112
|
}
|
114
113
|
);
|
115
114
|
}
|
116
115
|
function et({
|
117
116
|
value: t,
|
118
|
-
locale:
|
119
|
-
withoutSuffix:
|
120
|
-
from:
|
121
|
-
to:
|
122
|
-
type:
|
123
|
-
tz:
|
124
|
-
relativeRange:
|
125
|
-
enableTooltip:
|
126
|
-
useShortTimezone:
|
127
|
-
disableTimezone:
|
128
|
-
placement:
|
117
|
+
locale: o = "en",
|
118
|
+
withoutSuffix: p = !1,
|
119
|
+
from: d = "",
|
120
|
+
to: u = "",
|
121
|
+
type: i = "relative",
|
122
|
+
tz: l = void 0,
|
123
|
+
relativeRange: y = void 0,
|
124
|
+
enableTooltip: U = !0,
|
125
|
+
useShortTimezone: D = !1,
|
126
|
+
disableTimezone: x = !1,
|
127
|
+
placement: C = "top-end",
|
129
128
|
format: v = "lll",
|
130
|
-
|
129
|
+
mode: g = "all",
|
130
|
+
...r
|
131
131
|
}) {
|
132
|
-
const { innerContent:
|
132
|
+
const { innerContent: T, popContent: m, isUtc: s, setIsUtc: f, relativeString: e } = w({
|
133
133
|
value: t,
|
134
|
-
locale:
|
135
|
-
withoutSuffix:
|
136
|
-
from:
|
137
|
-
to:
|
138
|
-
type:
|
139
|
-
tz:
|
140
|
-
relativeRange:
|
134
|
+
locale: o,
|
135
|
+
withoutSuffix: p,
|
136
|
+
from: d,
|
137
|
+
to: u,
|
138
|
+
type: i === "all" ? "utc" : i,
|
139
|
+
tz: l,
|
140
|
+
relativeRange: y,
|
141
141
|
format: v
|
142
|
-
})
|
143
|
-
|
144
|
-
f,
|
142
|
+
}), h = /* @__PURE__ */ I(
|
143
|
+
a,
|
145
144
|
{
|
146
|
-
...
|
145
|
+
...r,
|
147
146
|
sx: [
|
148
147
|
{
|
149
148
|
display: "inline-flex",
|
150
149
|
alignItems: "center",
|
151
150
|
gap: 0.5
|
152
151
|
},
|
153
|
-
...Array.isArray(
|
152
|
+
...Array.isArray(r.sx) ? r.sx : [r.sx]
|
154
153
|
],
|
155
154
|
children: [
|
156
|
-
/* @__PURE__ */
|
157
|
-
/* @__PURE__ */
|
158
|
-
/* @__PURE__ */
|
159
|
-
!
|
160
|
-
/* @__PURE__ */
|
161
|
-
/* @__PURE__ */
|
155
|
+
/* @__PURE__ */ n(a, { component: "span", ...r, sx: {}, children: T }),
|
156
|
+
/* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: "·" }),
|
157
|
+
/* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: e }),
|
158
|
+
!x && /* @__PURE__ */ I(F, { children: [
|
159
|
+
/* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: "·" }),
|
160
|
+
/* @__PURE__ */ n(z, { locale: o, isUtc: s, setIsUtc: f, useShortTimezone: D })
|
162
161
|
] })
|
163
162
|
]
|
164
163
|
}
|
165
|
-
)
|
166
|
-
|
164
|
+
);
|
165
|
+
return g === "daysLeft" ? /* @__PURE__ */ n(M, { title: h, placement: C, enterTouchDelay: 0, children: /* @__PURE__ */ n(a, { component: "span", children: e }) }) : i === "all" && g === "all" ? /* @__PURE__ */ n(M, { title: void 0, placement: C, enterTouchDelay: 0, children: h }) : /* @__PURE__ */ n(M, { title: U ? m : void 0, placement: C, enterTouchDelay: 0, children: /* @__PURE__ */ I(
|
166
|
+
a,
|
167
167
|
{
|
168
168
|
sx: {
|
169
169
|
display: "inline-flex",
|
@@ -171,8 +171,8 @@ function et({
|
|
171
171
|
gap: 1
|
172
172
|
},
|
173
173
|
children: [
|
174
|
-
/* @__PURE__ */
|
175
|
-
|
174
|
+
/* @__PURE__ */ n(a, { component: "span", ...r, children: T }),
|
175
|
+
i === "utc" && !x && /* @__PURE__ */ n(z, { locale: o, isUtc: s, setIsUtc: f, useShortTimezone: D })
|
176
176
|
]
|
177
177
|
}
|
178
178
|
) });
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.26",
|
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": "7bfbe63186facc499363ec4bcc776d1506893576",
|
64
64
|
"dependencies": {
|
65
|
-
"@arcblock/bridge": "3.0.
|
65
|
+
"@arcblock/bridge": "3.0.26",
|
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.26",
|
69
|
+
"@arcblock/nft-display": "3.0.26",
|
70
|
+
"@arcblock/react-hooks": "3.0.26",
|
71
71
|
"@blocklet/js-sdk": "^1.16.46",
|
72
|
-
"@blocklet/theme": "3.0.
|
72
|
+
"@blocklet/theme": "3.0.26",
|
73
73
|
"@fontsource/roboto": "~5.1.1",
|
74
74
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
75
75
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import Modal from '@mui/material/Modal';
|
2
|
+
import styled from '@emotion/styled';
|
3
|
+
import NFTDisplay, { getNFTData } from '.';
|
4
|
+
|
5
|
+
export interface NftInfo {
|
6
|
+
address: string;
|
7
|
+
data: Record<string, any>;
|
8
|
+
display: Record<string, any>;
|
9
|
+
issuer: string;
|
10
|
+
}
|
11
|
+
|
12
|
+
export default function NftPreview({
|
13
|
+
visible,
|
14
|
+
onClose,
|
15
|
+
nft,
|
16
|
+
}: {
|
17
|
+
visible: boolean;
|
18
|
+
onClose: () => void;
|
19
|
+
nft: NftInfo | null;
|
20
|
+
}) {
|
21
|
+
if (!visible || !nft) {
|
22
|
+
return null;
|
23
|
+
}
|
24
|
+
|
25
|
+
return (
|
26
|
+
<NftPreviewRoot>
|
27
|
+
{/* Preview Modal */}
|
28
|
+
<Modal open={visible} onClose={onClose}>
|
29
|
+
<ModalRoot onClick={onClose}>
|
30
|
+
<NFTDisplay data={getNFTData(nft)} address={nft.address} inset />
|
31
|
+
</ModalRoot>
|
32
|
+
</Modal>
|
33
|
+
</NftPreviewRoot>
|
34
|
+
);
|
35
|
+
}
|
36
|
+
|
37
|
+
const NftPreviewRoot = styled.div`
|
38
|
+
position: relative;
|
39
|
+
width: 100%;
|
40
|
+
height: 100%;
|
41
|
+
cursor: pointer;
|
42
|
+
|
43
|
+
&:hover {
|
44
|
+
.mask {
|
45
|
+
opacity: 1;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
.mask {
|
50
|
+
position: absolute;
|
51
|
+
top: 0;
|
52
|
+
left: 0;
|
53
|
+
display: flex;
|
54
|
+
align-items: center;
|
55
|
+
justify-content: center;
|
56
|
+
width: 100%;
|
57
|
+
height: 100%;
|
58
|
+
background: rgba(0, 0, 0, 0.6);
|
59
|
+
opacity: 0;
|
60
|
+
transition: opacity 0.2s;
|
61
|
+
}
|
62
|
+
`;
|
63
|
+
|
64
|
+
const ModalRoot = styled.div`
|
65
|
+
display: flex;
|
66
|
+
justify-content: center;
|
67
|
+
align-items: center;
|
68
|
+
height: 100vh;
|
69
|
+
width: 100vw;
|
70
|
+
|
71
|
+
img,
|
72
|
+
object {
|
73
|
+
max-width: 90vw;
|
74
|
+
max-height: 75vh;
|
75
|
+
}
|
76
|
+
|
77
|
+
.nft-display--inset {
|
78
|
+
> .MuiBox-root,
|
79
|
+
.nft-display__loading {
|
80
|
+
width: 75vmin;
|
81
|
+
height: 75vmin;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
`;
|
@@ -73,6 +73,7 @@ export interface RelativeTimeProps {
|
|
73
73
|
placement?: TooltipProps['placement'];
|
74
74
|
sx?: SxProps;
|
75
75
|
format?: string;
|
76
|
+
mode?: 'all' | 'daysLeft'; // all: 显示所有内容,daysLeft: 只显示剩余天数
|
76
77
|
}
|
77
78
|
|
78
79
|
function useRelativeTime({
|
@@ -194,7 +195,6 @@ function UTCChip({
|
|
194
195
|
color: 'inherit',
|
195
196
|
cursor: 'pointer',
|
196
197
|
border: '1px solid',
|
197
|
-
fontSize: '0.8rem',
|
198
198
|
borderColor: 'divider',
|
199
199
|
borderRadius: '20px',
|
200
200
|
padding: '4px 8px',
|
@@ -220,6 +220,7 @@ export default function RelativeTime({
|
|
220
220
|
disableTimezone = false,
|
221
221
|
placement = 'top-end',
|
222
222
|
format = 'lll',
|
223
|
+
mode = 'all',
|
223
224
|
...rest
|
224
225
|
}: RelativeTimeProps) {
|
225
226
|
const { innerContent, popContent, isUtc, setIsUtc, relativeString } = useRelativeTime({
|
@@ -234,41 +235,54 @@ export default function RelativeTime({
|
|
234
235
|
format,
|
235
236
|
});
|
236
237
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
238
|
+
const allContent = (
|
239
|
+
<Box
|
240
|
+
{...rest}
|
241
|
+
sx={[
|
242
|
+
{
|
243
|
+
display: 'inline-flex',
|
244
|
+
alignItems: 'center',
|
245
|
+
gap: 0.5,
|
246
|
+
},
|
247
|
+
...(Array.isArray(rest.sx) ? rest.sx : [rest.sx]),
|
248
|
+
]}>
|
249
|
+
<Box component="span" {...rest} sx={{}}>
|
250
|
+
{innerContent}
|
251
|
+
</Box>
|
252
|
+
|
253
|
+
<Box component="span" sx={{ color: 'inherit' }}>
|
254
|
+
·
|
255
|
+
</Box>
|
256
|
+
|
257
|
+
<Box component="span" sx={{ color: 'inherit' }}>
|
258
|
+
{relativeString}
|
259
|
+
</Box>
|
253
260
|
|
261
|
+
{!disableTimezone && (
|
262
|
+
<>
|
254
263
|
<Box component="span" sx={{ color: 'inherit' }}>
|
255
264
|
·
|
256
265
|
</Box>
|
257
266
|
|
258
|
-
<
|
259
|
-
|
260
|
-
|
267
|
+
<UTCChip locale={locale} isUtc={isUtc} setIsUtc={setIsUtc} useShortTimezone={useShortTimezone} />
|
268
|
+
</>
|
269
|
+
)}
|
270
|
+
</Box>
|
271
|
+
);
|
261
272
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
273
|
+
// 优先通过 mode 来决定显示什么内容
|
274
|
+
if (mode === 'daysLeft') {
|
275
|
+
return (
|
276
|
+
<Tooltip title={allContent} placement={placement} enterTouchDelay={0}>
|
277
|
+
<Box component="span">{relativeString}</Box>
|
278
|
+
</Tooltip>
|
279
|
+
);
|
280
|
+
}
|
267
281
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
282
|
+
if (type === 'all' && mode === 'all') {
|
283
|
+
return (
|
284
|
+
<Tooltip title={undefined} placement={placement} enterTouchDelay={0}>
|
285
|
+
{allContent}
|
272
286
|
</Tooltip>
|
273
287
|
);
|
274
288
|
}
|