@arcblock/ux 2.13.30 → 2.13.31

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.
@@ -10,7 +10,7 @@ export interface RelativeTimeProps {
10
10
  tz?: string;
11
11
  relativeRange?: number;
12
12
  enableTooltip?: boolean;
13
- showUTCPrefix?: boolean;
14
- disableUTC?: boolean;
13
+ useShortTimezone?: boolean;
14
+ disableTimezone?: boolean;
15
15
  }
16
- export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, showUTCPrefix, disableUTC, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
16
+ export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, enableTooltip, useShortTimezone, disableTimezone, ...rest }: RelativeTimeProps): import("react/jsx-runtime").JSX.Element;
@@ -36,10 +36,16 @@ dayjs.updateLocale('zh-cn', {
36
36
  setDateTool(dayjs);
37
37
  const translations = {
38
38
  en: {
39
- utc: 'Your Timezone'
39
+ utc: 'UTC Timezone',
40
+ local: 'Local Timezone',
41
+ shortUTC: 'UTC',
42
+ shortLocal: 'Local'
40
43
  },
41
44
  zh: {
42
- utc: '你所在时区'
45
+ utc: 'UTC 时区',
46
+ local: '本地时区',
47
+ shortUTC: 'UTC',
48
+ shortLocal: '本地'
43
49
  }
44
50
  };
45
51
  function useRelativeTime({
@@ -134,17 +140,16 @@ function UTCChip({
134
140
  sign,
135
141
  hoursOffset,
136
142
  setIsUtc,
137
- showUTCPrefix = true
143
+ useShortTimezone = true
138
144
  }) {
139
- const prefix = useMemo(() => {
140
- if (showUTCPrefix) {
141
- if (isUtc) {
142
- return '';
143
- }
144
- return `${translations[locale].utc}: `;
145
+ const text = useMemo(() => {
146
+ const UTC = useShortTimezone ? 'shortUTC' : 'utc';
147
+ const LOCAL = useShortTimezone ? 'shortLocal' : 'local';
148
+ if (isUtc) {
149
+ return `${translations[locale][UTC]}`;
145
150
  }
146
- return '';
147
- }, [locale, showUTCPrefix, isUtc]);
151
+ return `${translations[locale][LOCAL]}`;
152
+ }, [locale, useShortTimezone, isUtc]);
148
153
  return /*#__PURE__*/_jsx(Box, {
149
154
  component: "span",
150
155
  sx: {
@@ -158,7 +163,7 @@ function UTCChip({
158
163
  lineHeight: 1
159
164
  },
160
165
  onClick: () => setIsUtc(r => !r),
161
- children: `${prefix}${isUtc ? 'UTC' : `UTC${sign}${hoursOffset}`}`
166
+ children: text
162
167
  });
163
168
  }
164
169
  export default function RelativeTime({
@@ -171,8 +176,8 @@ export default function RelativeTime({
171
176
  tz,
172
177
  relativeRange,
173
178
  enableTooltip = true,
174
- showUTCPrefix = true,
175
- disableUTC = false,
179
+ useShortTimezone = false,
180
+ disableTimezone = false,
176
181
  ...rest
177
182
  }) {
178
183
  const {
@@ -220,7 +225,7 @@ export default function RelativeTime({
220
225
  color: 'text.secondary'
221
226
  },
222
227
  children: relativeString
223
- }), !disableUTC && /*#__PURE__*/_jsxs(_Fragment, {
228
+ }), !disableTimezone && /*#__PURE__*/_jsxs(_Fragment, {
224
229
  children: [/*#__PURE__*/_jsx(Box, {
225
230
  component: "span",
226
231
  sx: {
@@ -233,7 +238,7 @@ export default function RelativeTime({
233
238
  sign: sign,
234
239
  hoursOffset: hoursOffset,
235
240
  setIsUtc: setIsUtc,
236
- showUTCPrefix: showUTCPrefix
241
+ useShortTimezone: useShortTimezone
237
242
  })]
238
243
  })]
239
244
  })
@@ -251,13 +256,13 @@ export default function RelativeTime({
251
256
  component: "span",
252
257
  ...rest,
253
258
  children: innerContent
254
- }), type === 'utc' && !disableUTC && /*#__PURE__*/_jsx(UTCChip, {
259
+ }), type === 'utc' && !disableTimezone && /*#__PURE__*/_jsx(UTCChip, {
255
260
  locale: locale,
256
261
  isUtc: isUtc,
257
262
  sign: sign,
258
263
  hoursOffset: hoursOffset,
259
264
  setIsUtc: setIsUtc,
260
- showUTCPrefix: showUTCPrefix
265
+ useShortTimezone: useShortTimezone
261
266
  })]
262
267
  })
263
268
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.13.30",
3
+ "version": "2.13.31",
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": "8551352e0bc3feaf46352054993743794ee1f32f",
74
+ "gitHead": "66ef51b4b217d15985838eb2c058ec833c07e1cd",
75
75
  "dependencies": {
76
76
  "@arcblock/did-motif": "^1.1.13",
77
- "@arcblock/icons": "^2.13.30",
78
- "@arcblock/nft-display": "^2.13.30",
79
- "@arcblock/react-hooks": "^2.13.30",
77
+ "@arcblock/icons": "^2.13.31",
78
+ "@arcblock/nft-display": "^2.13.31",
79
+ "@arcblock/react-hooks": "^2.13.31",
80
80
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
81
- "@blocklet/theme": "^2.13.30",
81
+ "@blocklet/theme": "^2.13.31",
82
82
  "@fontsource/roboto": "~5.1.1",
83
83
  "@fontsource/ubuntu-mono": "^5.0.18",
84
84
  "@iconify-icons/logos": "^1.2.36",
@@ -36,12 +36,18 @@ dayjs.updateLocale('zh-cn', {
36
36
  // FIXME: @@ 此处不能真正的将 relativeTime 设置为支持中文
37
37
  setDateTool(dayjs);
38
38
 
39
- const translations: Record<Locale, { utc: string }> = {
39
+ const translations: Record<Locale, { utc: string; local: string; shortUTC: string; shortLocal: string }> = {
40
40
  en: {
41
- utc: 'Your Timezone',
41
+ utc: 'UTC Timezone',
42
+ local: 'Local Timezone',
43
+ shortUTC: 'UTC',
44
+ shortLocal: 'Local',
42
45
  },
43
46
  zh: {
44
- utc: '你所在时区',
47
+ utc: 'UTC 时区',
48
+ local: '本地时区',
49
+ shortUTC: 'UTC',
50
+ shortLocal: '本地',
45
51
  },
46
52
  };
47
53
 
@@ -55,8 +61,8 @@ export interface RelativeTimeProps {
55
61
  tz?: string;
56
62
  relativeRange?: number;
57
63
  enableTooltip?: boolean;
58
- showUTCPrefix?: boolean;
59
- disableUTC?: boolean;
64
+ useShortTimezone?: boolean;
65
+ disableTimezone?: boolean;
60
66
  }
61
67
 
62
68
  function useRelativeTime({
@@ -146,26 +152,25 @@ function UTCChip({
146
152
  sign,
147
153
  hoursOffset,
148
154
  setIsUtc,
149
- showUTCPrefix = true,
155
+ useShortTimezone = true,
150
156
  }: {
151
157
  locale: Locale;
152
158
  isUtc?: boolean;
153
159
  sign: string;
154
160
  hoursOffset: number;
155
161
  setIsUtc: (data: any) => void;
156
- showUTCPrefix?: boolean;
162
+ useShortTimezone?: boolean;
157
163
  }) {
158
- const prefix = useMemo(() => {
159
- if (showUTCPrefix) {
160
- if (isUtc) {
161
- return '';
162
- }
164
+ const text = useMemo(() => {
165
+ const UTC = useShortTimezone ? 'shortUTC' : 'utc';
166
+ const LOCAL = useShortTimezone ? 'shortLocal' : 'local';
163
167
 
164
- return `${translations[locale].utc}: `;
168
+ if (isUtc) {
169
+ return `${translations[locale][UTC]}`;
165
170
  }
166
171
 
167
- return '';
168
- }, [locale, showUTCPrefix, isUtc]);
172
+ return `${translations[locale][LOCAL]}`;
173
+ }, [locale, useShortTimezone, isUtc]);
169
174
 
170
175
  return (
171
176
  <Box
@@ -181,7 +186,7 @@ function UTCChip({
181
186
  lineHeight: 1,
182
187
  }}
183
188
  onClick={() => setIsUtc((r: any) => !r)}>
184
- {`${prefix}${isUtc ? 'UTC' : `UTC${sign}${hoursOffset}`}`}
189
+ {text}
185
190
  </Box>
186
191
  );
187
192
  }
@@ -196,8 +201,8 @@ export default function RelativeTime({
196
201
  tz,
197
202
  relativeRange,
198
203
  enableTooltip = true,
199
- showUTCPrefix = true,
200
- disableUTC = false,
204
+ useShortTimezone = false,
205
+ disableTimezone = false,
201
206
  ...rest
202
207
  }: RelativeTimeProps) {
203
208
  const { innerContent, popContent, isUtc, setIsUtc, sign, hoursOffset, relativeString } = useRelativeTime({
@@ -227,7 +232,7 @@ export default function RelativeTime({
227
232
  {relativeString}
228
233
  </Box>
229
234
 
230
- {!disableUTC && (
235
+ {!disableTimezone && (
231
236
  <>
232
237
  <Box component="span" sx={{ color: 'inherit' }}>
233
238
  ·
@@ -239,7 +244,7 @@ export default function RelativeTime({
239
244
  sign={sign}
240
245
  hoursOffset={hoursOffset}
241
246
  setIsUtc={setIsUtc}
242
- showUTCPrefix={showUTCPrefix}
247
+ useShortTimezone={useShortTimezone}
243
248
  />
244
249
  </>
245
250
  )}
@@ -255,14 +260,14 @@ export default function RelativeTime({
255
260
  {innerContent}
256
261
  </Box>
257
262
 
258
- {type === 'utc' && !disableUTC && (
263
+ {type === 'utc' && !disableTimezone && (
259
264
  <UTCChip
260
265
  locale={locale}
261
266
  isUtc={isUtc}
262
267
  sign={sign}
263
268
  hoursOffset={hoursOffset}
264
269
  setIsUtc={setIsUtc}
265
- showUTCPrefix={showUTCPrefix}
270
+ useShortTimezone={useShortTimezone}
266
271
  />
267
272
  )}
268
273
  </Box>