@arcblock/ux 2.13.68 → 2.13.70
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 +11 -5
- package/lib/Theme/theme-provider.js +1 -2
- package/lib/Util/index.d.ts +2 -1
- package/lib/Util/index.js +3 -2
- package/package.json +6 -6
- package/src/RelativeTime/index.tsx +8 -3
- package/src/Theme/theme-provider.tsx +7 -2
- package/src/Util/index.ts +7 -2
@@ -14,5 +14,6 @@ export interface RelativeTimeProps {
|
|
14
14
|
useShortTimezone?: boolean;
|
15
15
|
disableTimezone?: boolean;
|
16
16
|
placement?: TooltipProps['placement'];
|
17
|
+
format?: string;
|
17
18
|
}
|
18
|
-
export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, useShortTimezone, disableTimezone, placement, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
|
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;
|
@@ -63,7 +63,8 @@ function useRelativeTime({
|
|
63
63
|
to = '',
|
64
64
|
type = 'relative',
|
65
65
|
tz,
|
66
|
-
relativeRange
|
66
|
+
relativeRange,
|
67
|
+
format
|
67
68
|
}) {
|
68
69
|
const date = new Date();
|
69
70
|
const timeZoneOffset = date.getTimezoneOffset();
|
@@ -96,7 +97,8 @@ function useRelativeTime({
|
|
96
97
|
}
|
97
98
|
const absoluteString = formatToDatetime(value, {
|
98
99
|
locale: localeOption,
|
99
|
-
tz
|
100
|
+
tz,
|
101
|
+
format
|
100
102
|
});
|
101
103
|
let relativeString;
|
102
104
|
if (from) {
|
@@ -123,12 +125,14 @@ function useRelativeTime({
|
|
123
125
|
innerContent = formatToDatetime(value, {
|
124
126
|
locale: localeOption,
|
125
127
|
tz,
|
126
|
-
isUtc: true
|
128
|
+
isUtc: true,
|
129
|
+
format
|
127
130
|
});
|
128
131
|
popContent = formatToDatetime(value, {
|
129
132
|
locale: localeOption,
|
130
133
|
tz,
|
131
|
-
isUtc: true
|
134
|
+
isUtc: true,
|
135
|
+
format
|
132
136
|
});
|
133
137
|
} else {
|
134
138
|
innerContent = absoluteString;
|
@@ -189,6 +193,7 @@ export default function RelativeTime({
|
|
189
193
|
useShortTimezone = false,
|
190
194
|
disableTimezone = false,
|
191
195
|
placement = 'top-end',
|
196
|
+
format = 'lll',
|
192
197
|
...rest
|
193
198
|
}) {
|
194
199
|
const {
|
@@ -205,7 +210,8 @@ export default function RelativeTime({
|
|
205
210
|
to,
|
206
211
|
type: type === 'all' ? 'utc' : type,
|
207
212
|
tz,
|
208
|
-
relativeRange
|
213
|
+
relativeRange,
|
214
|
+
format
|
209
215
|
});
|
210
216
|
if (type === 'all') {
|
211
217
|
return /*#__PURE__*/_jsx(Tooltip, {
|
@@ -2,8 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState, useRef } from 'react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
4
|
import { GlobalStyles } from '@mui/material';
|
5
|
-
import { ThemeProvider as MuiThemeProvider, useTheme } from '@mui/material/styles';
|
6
|
-
import StyledEngineProvider from '@mui/material/StyledEngineProvider';
|
5
|
+
import { ThemeProvider as MuiThemeProvider, useTheme, StyledEngineProvider } from '@mui/material/styles';
|
7
6
|
import CssBaseline from '@mui/material/CssBaseline';
|
8
7
|
import set from 'lodash/set';
|
9
8
|
import { BLOCKLET_THEME_PREFER_KEY, getDefaultThemePrefer, isValidThemeMode } from '@blocklet/theme';
|
package/lib/Util/index.d.ts
CHANGED
@@ -48,10 +48,11 @@ export declare function formatToDate(date: string | number | Date, { locale, tz
|
|
48
48
|
* Ensure that the setDateTool() function is called first to set the time tool library.
|
49
49
|
* @returns formatted date string
|
50
50
|
*/
|
51
|
-
export declare function formatToDatetime(date: string | number | Date, { locale, tz, isUtc }?: {
|
51
|
+
export declare function formatToDatetime(date: string | number | Date, { locale, tz, isUtc, format, }?: {
|
52
52
|
locale?: Locale;
|
53
53
|
tz?: string;
|
54
54
|
isUtc?: boolean;
|
55
|
+
format?: string;
|
55
56
|
}): any;
|
56
57
|
export declare function detectWalletExtension(): any;
|
57
58
|
export declare function openWebWallet({ webWalletUrl, action, locale, url, windowFeatures, appInfo, memberAppInfo, }: {
|
package/lib/Util/index.js
CHANGED
@@ -234,9 +234,10 @@ export function formatToDate(date, {
|
|
234
234
|
export function formatToDatetime(date, {
|
235
235
|
locale = 'en',
|
236
236
|
tz,
|
237
|
-
isUtc = false
|
237
|
+
isUtc = false,
|
238
|
+
format = 'lll'
|
238
239
|
} = {}) {
|
239
|
-
return createDateFormatter(
|
240
|
+
return createDateFormatter(format)(date, {
|
240
241
|
locale,
|
241
242
|
tz,
|
242
243
|
isUtc
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.13.
|
3
|
+
"version": "2.13.70",
|
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": "b38a83a2c7d9a22e90bab369d8f61340db2abbd0",
|
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.70",
|
78
|
+
"@arcblock/nft-display": "^2.13.70",
|
79
|
+
"@arcblock/react-hooks": "^2.13.70",
|
80
80
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
81
|
-
"@blocklet/theme": "^2.13.
|
81
|
+
"@blocklet/theme": "^2.13.70",
|
82
82
|
"@fontsource/roboto": "~5.1.1",
|
83
83
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
84
84
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -71,6 +71,7 @@ export interface RelativeTimeProps {
|
|
71
71
|
useShortTimezone?: boolean;
|
72
72
|
disableTimezone?: boolean;
|
73
73
|
placement?: TooltipProps['placement'];
|
74
|
+
format?: string;
|
74
75
|
}
|
75
76
|
|
76
77
|
function useRelativeTime({
|
@@ -82,6 +83,7 @@ function useRelativeTime({
|
|
82
83
|
type = 'relative',
|
83
84
|
tz,
|
84
85
|
relativeRange,
|
86
|
+
format,
|
85
87
|
}: {
|
86
88
|
value: string | number;
|
87
89
|
locale?: Locale;
|
@@ -91,6 +93,7 @@ function useRelativeTime({
|
|
91
93
|
type?: 'relative' | 'absolute' | 'utc';
|
92
94
|
tz?: string;
|
93
95
|
relativeRange?: number;
|
96
|
+
format?: string;
|
94
97
|
}) {
|
95
98
|
const date = new Date();
|
96
99
|
const timeZoneOffset = date.getTimezoneOffset();
|
@@ -121,7 +124,7 @@ function useRelativeTime({
|
|
121
124
|
datetime = datetime.tz(tz);
|
122
125
|
}
|
123
126
|
|
124
|
-
const absoluteString = formatToDatetime(value, { locale: localeOption, tz });
|
127
|
+
const absoluteString = formatToDatetime(value, { locale: localeOption, tz, format });
|
125
128
|
|
126
129
|
let relativeString;
|
127
130
|
|
@@ -150,8 +153,8 @@ function useRelativeTime({
|
|
150
153
|
|
151
154
|
if (type === 'utc') {
|
152
155
|
if (isUtc) {
|
153
|
-
innerContent = formatToDatetime(value, { locale: localeOption, tz, isUtc: true });
|
154
|
-
popContent = formatToDatetime(value, { locale: localeOption, tz, isUtc: true });
|
156
|
+
innerContent = formatToDatetime(value, { locale: localeOption, tz, isUtc: true, format });
|
157
|
+
popContent = formatToDatetime(value, { locale: localeOption, tz, isUtc: true, format });
|
155
158
|
} else {
|
156
159
|
innerContent = absoluteString;
|
157
160
|
popContent = relativeString;
|
@@ -215,6 +218,7 @@ export default function RelativeTime({
|
|
215
218
|
useShortTimezone = false,
|
216
219
|
disableTimezone = false,
|
217
220
|
placement = 'top-end',
|
221
|
+
format = 'lll',
|
218
222
|
...rest
|
219
223
|
}: RelativeTimeProps) {
|
220
224
|
const { innerContent, popContent, isUtc, setIsUtc, relativeString } = useRelativeTime({
|
@@ -226,6 +230,7 @@ export default function RelativeTime({
|
|
226
230
|
type: type === 'all' ? 'utc' : type,
|
227
231
|
tz,
|
228
232
|
relativeRange,
|
233
|
+
format,
|
229
234
|
});
|
230
235
|
|
231
236
|
if (type === 'all') {
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState, useRef } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import { GlobalStyles, PaletteMode } from '@mui/material';
|
4
|
-
import {
|
5
|
-
|
4
|
+
import {
|
5
|
+
ThemeProvider as MuiThemeProvider,
|
6
|
+
Theme,
|
7
|
+
ThemeOptions,
|
8
|
+
useTheme,
|
9
|
+
StyledEngineProvider,
|
10
|
+
} from '@mui/material/styles';
|
6
11
|
import CssBaseline from '@mui/material/CssBaseline';
|
7
12
|
import set from 'lodash/set';
|
8
13
|
import { BLOCKLET_THEME_PREFER_KEY, getDefaultThemePrefer, isValidThemeMode } from '@blocklet/theme';
|
package/src/Util/index.ts
CHANGED
@@ -291,9 +291,14 @@ export function formatToDate(
|
|
291
291
|
*/
|
292
292
|
export function formatToDatetime(
|
293
293
|
date: string | number | Date,
|
294
|
-
{
|
294
|
+
{
|
295
|
+
locale = 'en',
|
296
|
+
tz,
|
297
|
+
isUtc = false,
|
298
|
+
format = 'lll',
|
299
|
+
}: { locale?: Locale; tz?: string; isUtc?: boolean; format?: string } = {}
|
295
300
|
) {
|
296
|
-
return createDateFormatter(
|
301
|
+
return createDateFormatter(format)(date, { locale, tz, isUtc });
|
297
302
|
}
|
298
303
|
|
299
304
|
export function detectWalletExtension() {
|