@arcblock/ux 3.0.27 → 3.0.28

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.
@@ -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 c from "dayjs";
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
- c.extend(N);
14
- c.extend(k);
15
- c.extend(B);
16
- c.extend(H);
17
- c.extend(E);
18
- c.updateLocale("zh-cn", {
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(c);
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: u = "",
59
+ to: x = "",
60
60
  type: i = "relative",
61
61
  tz: l,
62
- relativeRange: y,
63
- format: U
62
+ relativeRange: m,
63
+ format: g
64
64
  }) {
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);
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
- 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 });
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 = 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);
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 = 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 };
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 u = $(() => {
94
- const i = d ? "shortUTC" : "utc", l = d ? "shortLocal" : "local";
95
- return o ? `${j[t][i]}` : `${j[t][l]}`;
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: u
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: u = "",
120
+ to: x = "",
121
121
  type: i = "relative",
122
122
  tz: l = void 0,
123
- relativeRange: y = void 0,
124
- enableTooltip: U = !0,
123
+ relativeRange: m = void 0,
124
+ enableTooltip: g = !0,
125
125
  useShortTimezone: D = !1,
126
- disableTimezone: x = !1,
127
- placement: C = "top-end",
126
+ disableTimezone: C = !1,
127
+ placement: T = "top-end",
128
128
  format: v = "lll",
129
- mode: g = "all",
129
+ mode: L = "all",
130
130
  ...r
131
131
  }) {
132
- const { innerContent: T, popContent: m, isUtc: s, setIsUtc: f, relativeString: e } = w({
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: u,
137
+ to: x,
138
138
  type: i === "all" ? "utc" : i,
139
139
  tz: l,
140
- relativeRange: y,
140
+ relativeRange: m,
141
141
  format: v
142
- }), h = /* @__PURE__ */ I(
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: T }),
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
- !x && /* @__PURE__ */ I(F, { children: [
158
+ !C && /* @__PURE__ */ I(F, { children: [
159
159
  /* @__PURE__ */ n(a, { component: "span", sx: { color: "inherit" }, children: "·" }),
160
- /* @__PURE__ */ n(z, { locale: o, isUtc: s, setIsUtc: f, useShortTimezone: D })
160
+ /* @__PURE__ */ n(z, { locale: o, isUtc: c, setIsUtc: f, useShortTimezone: D })
161
161
  ] })
162
162
  ]
163
163
  }
164
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(
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: T }),
175
- i === "utc" && !x && /* @__PURE__ */ n(z, { locale: o, isUtc: s, setIsUtc: f, useShortTimezone: D })
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
  ) });
@@ -23,9 +23,9 @@ export type TagProps = TypographyProps & TagOwnProps;
23
23
  /**
24
24
  * @description
25
25
  * @param {TagProps} props
26
- * @return {import('react').ReactNode}
26
+ * @return {JSX.Element}
27
27
  */
28
- declare function Tag({ ...rawProps }: TagProps): import('react').ReactNode;
28
+ declare function Tag({ ...rawProps }: TagProps): JSX.Element;
29
29
  declare namespace Tag {
30
30
  namespace propTypes {
31
31
  let children: PropTypes.Validator<any>;
@@ -1,5 +1,6 @@
1
- import { ThemeOptions, PaletteMode, Theme } from '@mui/material';
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.27",
3
+ "version": "3.0.28",
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": "b1e137e0c74f4b58af16b1d75a65166b163cf65d",
63
+ "gitHead": "a2d0c2d51c4a6f4fd301e59104fa5811bf4bd4ab",
64
64
  "dependencies": {
65
- "@arcblock/bridge": "3.0.27",
65
+ "@arcblock/bridge": "3.0.28",
66
66
  "@arcblock/did": "^1.20.15",
67
67
  "@arcblock/did-motif": "^1.1.14",
68
- "@arcblock/icons": "3.0.27",
69
- "@arcblock/nft-display": "3.0.27",
70
- "@arcblock/react-hooks": "3.0.27",
68
+ "@arcblock/icons": "3.0.28",
69
+ "@arcblock/nft-display": "3.0.28",
70
+ "@arcblock/react-hooks": "3.0.28",
71
71
  "@blocklet/js-sdk": "^1.16.46",
72
- "@blocklet/theme": "3.0.27",
72
+ "@blocklet/theme": "3.0.28",
73
73
  "@fontsource/roboto": "~5.1.1",
74
74
  "@fontsource/ubuntu-mono": "^5.2.6",
75
75
  "@iconify-icons/logos": "^1.2.36",
@@ -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 `${translations[locale][UTC]}`;
187
+ return `${config[UTC]}`;
186
188
  }
187
189
 
188
- return `${translations[locale][LOCAL]}`;
190
+ return `${config[LOCAL]}`;
189
191
  }, [locale, useShortTimezone, isUtc]);
190
192
 
191
193
  return (
package/src/Tag/index.jsx CHANGED
@@ -44,7 +44,7 @@ const types = {
44
44
  /**
45
45
  * @description
46
46
  * @param {TagProps} props
47
- * @return {import('react').ReactNode}
47
+ * @return {JSX.Element}
48
48
  */
49
49
  function Tag({ ...rawProps }) {
50
50
  const props = Object.assign({}, rawProps);
@@ -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