@arcblock/ux 2.13.29 → 2.13.30
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/RelativeTime/index.d.ts +2 -1
- package/lib/RelativeTime/index.js +30 -21
- package/package.json +6 -6
- package/src/RelativeTime/index.tsx +32 -16
@@ -11,5 +11,6 @@ export interface RelativeTimeProps {
|
|
11
11
|
relativeRange?: number;
|
12
12
|
enableTooltip?: boolean;
|
13
13
|
showUTCPrefix?: boolean;
|
14
|
+
disableUTC?: boolean;
|
14
15
|
}
|
15
|
-
export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, showUTCPrefix, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
|
16
|
+
export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, showUTCPrefix, disableUTC, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import { Box, Tooltip } from '@mui/material';
|
3
|
-
import { useState } from 'react';
|
3
|
+
import { useState, useMemo } from 'react';
|
4
4
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
5
5
|
import dayjs from 'dayjs';
|
6
6
|
import 'dayjs/locale/zh-cn';
|
@@ -136,7 +136,15 @@ function UTCChip({
|
|
136
136
|
setIsUtc,
|
137
137
|
showUTCPrefix = true
|
138
138
|
}) {
|
139
|
-
const prefix =
|
139
|
+
const prefix = useMemo(() => {
|
140
|
+
if (showUTCPrefix) {
|
141
|
+
if (isUtc) {
|
142
|
+
return '';
|
143
|
+
}
|
144
|
+
return `${translations[locale].utc}: `;
|
145
|
+
}
|
146
|
+
return '';
|
147
|
+
}, [locale, showUTCPrefix, isUtc]);
|
140
148
|
return /*#__PURE__*/_jsx(Box, {
|
141
149
|
component: "span",
|
142
150
|
sx: {
|
@@ -164,6 +172,7 @@ export default function RelativeTime({
|
|
164
172
|
relativeRange,
|
165
173
|
enableTooltip = true,
|
166
174
|
showUTCPrefix = true,
|
175
|
+
disableUTC = false,
|
167
176
|
...rest
|
168
177
|
}) {
|
169
178
|
const {
|
@@ -190,10 +199,9 @@ export default function RelativeTime({
|
|
190
199
|
placement: "top-end",
|
191
200
|
enterTouchDelay: 0,
|
192
201
|
children: /*#__PURE__*/_jsxs(Box, {
|
193
|
-
display: "flex",
|
202
|
+
display: "inline-flex",
|
194
203
|
alignItems: "center",
|
195
204
|
gap: 0.5,
|
196
|
-
width: "max-content",
|
197
205
|
...rest,
|
198
206
|
children: [/*#__PURE__*/_jsx(Box, {
|
199
207
|
component: "span",
|
@@ -212,19 +220,21 @@ export default function RelativeTime({
|
|
212
220
|
color: 'text.secondary'
|
213
221
|
},
|
214
222
|
children: relativeString
|
215
|
-
}), /*#__PURE__*/
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
223
|
+
}), !disableUTC && /*#__PURE__*/_jsxs(_Fragment, {
|
224
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
225
|
+
component: "span",
|
226
|
+
sx: {
|
227
|
+
color: 'inherit'
|
228
|
+
},
|
229
|
+
children: "\xB7"
|
230
|
+
}), /*#__PURE__*/_jsx(UTCChip, {
|
231
|
+
locale: locale,
|
232
|
+
isUtc: isUtc,
|
233
|
+
sign: sign,
|
234
|
+
hoursOffset: hoursOffset,
|
235
|
+
setIsUtc: setIsUtc,
|
236
|
+
showUTCPrefix: showUTCPrefix
|
237
|
+
})]
|
228
238
|
})]
|
229
239
|
})
|
230
240
|
});
|
@@ -234,15 +244,14 @@ export default function RelativeTime({
|
|
234
244
|
placement: "top-end",
|
235
245
|
enterTouchDelay: 0,
|
236
246
|
children: /*#__PURE__*/_jsxs(Box, {
|
237
|
-
display: "flex",
|
247
|
+
display: "inline-flex",
|
238
248
|
alignItems: "center",
|
239
249
|
gap: 1,
|
240
|
-
width: "max-content",
|
241
250
|
children: [/*#__PURE__*/_jsx(Box, {
|
242
251
|
component: "span",
|
243
252
|
...rest,
|
244
253
|
children: innerContent
|
245
|
-
}), type === 'utc' && /*#__PURE__*/_jsx(UTCChip, {
|
254
|
+
}), type === 'utc' && !disableUTC && /*#__PURE__*/_jsx(UTCChip, {
|
246
255
|
locale: locale,
|
247
256
|
isUtc: isUtc,
|
248
257
|
sign: sign,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.13.
|
3
|
+
"version": "2.13.30",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -71,14 +71,14 @@
|
|
71
71
|
"react": ">=18.2.0",
|
72
72
|
"react-router-dom": ">=6.22.3"
|
73
73
|
},
|
74
|
-
"gitHead": "
|
74
|
+
"gitHead": "8551352e0bc3feaf46352054993743794ee1f32f",
|
75
75
|
"dependencies": {
|
76
76
|
"@arcblock/did-motif": "^1.1.13",
|
77
|
-
"@arcblock/icons": "^2.13.
|
78
|
-
"@arcblock/nft-display": "^2.13.
|
79
|
-
"@arcblock/react-hooks": "^2.13.
|
77
|
+
"@arcblock/icons": "^2.13.30",
|
78
|
+
"@arcblock/nft-display": "^2.13.30",
|
79
|
+
"@arcblock/react-hooks": "^2.13.30",
|
80
80
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
81
|
-
"@blocklet/theme": "^2.13.
|
81
|
+
"@blocklet/theme": "^2.13.30",
|
82
82
|
"@fontsource/roboto": "~5.1.1",
|
83
83
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
84
84
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Box, Tooltip } from '@mui/material';
|
2
|
-
import { useState } from 'react';
|
2
|
+
import { useState, useMemo } from 'react';
|
3
3
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
4
4
|
import dayjs from 'dayjs';
|
5
5
|
import 'dayjs/locale/zh-cn';
|
@@ -56,6 +56,7 @@ export interface RelativeTimeProps {
|
|
56
56
|
relativeRange?: number;
|
57
57
|
enableTooltip?: boolean;
|
58
58
|
showUTCPrefix?: boolean;
|
59
|
+
disableUTC?: boolean;
|
59
60
|
}
|
60
61
|
|
61
62
|
function useRelativeTime({
|
@@ -154,7 +155,17 @@ function UTCChip({
|
|
154
155
|
setIsUtc: (data: any) => void;
|
155
156
|
showUTCPrefix?: boolean;
|
156
157
|
}) {
|
157
|
-
const prefix =
|
158
|
+
const prefix = useMemo(() => {
|
159
|
+
if (showUTCPrefix) {
|
160
|
+
if (isUtc) {
|
161
|
+
return '';
|
162
|
+
}
|
163
|
+
|
164
|
+
return `${translations[locale].utc}: `;
|
165
|
+
}
|
166
|
+
|
167
|
+
return '';
|
168
|
+
}, [locale, showUTCPrefix, isUtc]);
|
158
169
|
|
159
170
|
return (
|
160
171
|
<Box
|
@@ -186,6 +197,7 @@ export default function RelativeTime({
|
|
186
197
|
relativeRange,
|
187
198
|
enableTooltip = true,
|
188
199
|
showUTCPrefix = true,
|
200
|
+
disableUTC = false,
|
189
201
|
...rest
|
190
202
|
}: RelativeTimeProps) {
|
191
203
|
const { innerContent, popContent, isUtc, setIsUtc, sign, hoursOffset, relativeString } = useRelativeTime({
|
@@ -202,7 +214,7 @@ export default function RelativeTime({
|
|
202
214
|
if (type === 'all') {
|
203
215
|
return (
|
204
216
|
<Tooltip title={undefined} placement="top-end" enterTouchDelay={0}>
|
205
|
-
<Box display="flex" alignItems="center" gap={0.5}
|
217
|
+
<Box display="inline-flex" alignItems="center" gap={0.5} {...rest}>
|
206
218
|
<Box component="span" {...rest} sx={{}}>
|
207
219
|
{innerContent}
|
208
220
|
</Box>
|
@@ -215,18 +227,22 @@ export default function RelativeTime({
|
|
215
227
|
{relativeString}
|
216
228
|
</Box>
|
217
229
|
|
218
|
-
|
219
|
-
|
220
|
-
|
230
|
+
{!disableUTC && (
|
231
|
+
<>
|
232
|
+
<Box component="span" sx={{ color: 'inherit' }}>
|
233
|
+
·
|
234
|
+
</Box>
|
221
235
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
236
|
+
<UTCChip
|
237
|
+
locale={locale}
|
238
|
+
isUtc={isUtc}
|
239
|
+
sign={sign}
|
240
|
+
hoursOffset={hoursOffset}
|
241
|
+
setIsUtc={setIsUtc}
|
242
|
+
showUTCPrefix={showUTCPrefix}
|
243
|
+
/>
|
244
|
+
</>
|
245
|
+
)}
|
230
246
|
</Box>
|
231
247
|
</Tooltip>
|
232
248
|
);
|
@@ -234,12 +250,12 @@ export default function RelativeTime({
|
|
234
250
|
|
235
251
|
return (
|
236
252
|
<Tooltip title={enableTooltip ? popContent : undefined} placement="top-end" enterTouchDelay={0}>
|
237
|
-
<Box display="flex" alignItems="center" gap={1}
|
253
|
+
<Box display="inline-flex" alignItems="center" gap={1}>
|
238
254
|
<Box component="span" {...rest}>
|
239
255
|
{innerContent}
|
240
256
|
</Box>
|
241
257
|
|
242
|
-
{type === 'utc' && (
|
258
|
+
{type === 'utc' && !disableUTC && (
|
243
259
|
<UTCChip
|
244
260
|
locale={locale}
|
245
261
|
isUtc={isUtc}
|