@arcblock/ux 3.1.47 → 3.1.49

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/Util/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { lazy as j } from "react";
1
+ import { lazy as T } from "react";
2
2
  import l from "lodash/padStart";
3
- import { colors as w, getDIDMotifInfo as x } from "@arcblock/did-motif";
3
+ import { colors as w, getDIDMotifInfo as j } from "@arcblock/did-motif";
4
4
  import { mergeAllThemeOptions as Ke } from "@blocklet/theme";
5
5
  import I from "lodash/isNil";
6
6
  import E from "lodash/omitBy";
@@ -10,23 +10,23 @@ import O from "color-convert";
10
10
  import a from "dayjs";
11
11
  import "dayjs/locale/zh-cn";
12
12
  import U from "dayjs/plugin/utc";
13
- import F from "dayjs/plugin/timezone";
14
- import A from "dayjs/plugin/relativeTime";
15
- import P from "dayjs/plugin/updateLocale";
16
- import R from "dayjs/plugin/localizedFormat";
13
+ import A from "dayjs/plugin/timezone";
14
+ import F from "dayjs/plugin/relativeTime";
15
+ import R from "dayjs/plugin/updateLocale";
16
+ import P from "dayjs/plugin/localizedFormat";
17
17
  import W from "semver";
18
18
  import { DID_PREFIX as L, BLOCKLET_SERVICE_PATH_PREFIX as C } from "./constant.js";
19
19
  import b from "../package.json.js";
20
20
  import { getFederatedEnabled as M } from "./federated.js";
21
21
  let u = null;
22
- const _ = /^(\d{1,3}\.){3}\d{1,3}(:\d+)?$/, z = /* @__PURE__ */ new Set(["co", "com", "net", "org", "gov", "edu", "ac"]), N = /* @__PURE__ */ new Set(["uk", "au", "cn", "nz", "za", "in", "br", "mx", "fr", "it", "ca"]);
22
+ const _ = /^(\d{1,3}\.){3}\d{1,3}(:\d+)?$/, N = /* @__PURE__ */ new Set(["co", "com", "net", "org", "gov", "edu", "ac"]), z = /* @__PURE__ */ new Set(["uk", "au", "cn", "nz", "za", "in", "br", "mx", "fr", "it", "ca"]);
23
23
  function B(e) {
24
24
  if (!e)
25
25
  return !1;
26
26
  const t = e.split(".");
27
27
  if (t.length < 2) return !1;
28
28
  const o = t[t.length - 2], r = t[t.length - 1];
29
- return z.has(o) && N.has(r);
29
+ return N.has(o) && z.has(r);
30
30
  }
31
31
  function ye() {
32
32
  const { host: e } = window.location;
@@ -51,7 +51,7 @@ function Ie(e) {
51
51
  function be(e = {}) {
52
52
  return new URLSearchParams(e).toString();
53
53
  }
54
- function De(e = 1) {
54
+ function Se(e = 1) {
55
55
  let t = e;
56
56
  typeof t == "number" && (t = { expireInDays: t }), t.path === void 0 && (t.path = "/"), t.expireInDays || (t.expireInDays = 1);
57
57
  const o = {
@@ -64,7 +64,7 @@ function De(e = 1) {
64
64
  };
65
65
  return (typeof window > "u" || t.domain || t.returnDomain === !1) && t.returnDomain === !1 && delete o.domain, o;
66
66
  }
67
- const Se = (e) => e.color ? e.color : e.dark ? e.theme.palette.common.white : e.theme.palette.text.primary, Ve = (e) => e.background ? e.background : e.dark ? e.theme.palette.common.black : e.theme.palette.common.white;
67
+ const De = (e) => e.color ? e.color : e.dark ? e.theme.palette.common.white : e.theme.palette.text.primary, $e = (e) => e.background ? e.background : e.dark ? e.theme.palette.common.black : e.theme.palette.common.white;
68
68
  function ke(e, t, o = []) {
69
69
  const r = Object.assign({}, e), i = t.defaultProps || {};
70
70
  return Object.keys(i).forEach((n) => {
@@ -79,11 +79,11 @@ function ke(e, t, o = []) {
79
79
  typeof r[n] == "string" && r[n].indexOf("::prop::") === 0 && (r[n] = "");
80
80
  }), r;
81
81
  }
82
- function $e(e = 2017) {
82
+ function Ve(e = 2017) {
83
83
  const t = (/* @__PURE__ */ new Date()).getFullYear();
84
84
  return `${t}` == `${e}` ? `© ArcBlock ${t}` : `© ArcBlock ${e} - ${t}`;
85
85
  }
86
- const Te = () => typeof Intl == "object" && typeof Intl.DateTimeFormat == "function" && typeof Intl.DateTimeFormat().resolvedOptions == "function" ? Intl.DateTimeFormat().resolvedOptions().timeZone : "", je = (e) => {
86
+ const xe = () => typeof Intl == "object" && typeof Intl.DateTimeFormat == "function" && typeof Intl.DateTimeFormat().resolvedOptions == "function" ? Intl.DateTimeFormat().resolvedOptions().timeZone : "", Te = (e) => {
87
87
  let t = 0;
88
88
  for (let r = 0; r < e.length; r++)
89
89
  t = e.charCodeAt(r) + ((t << 5) - t);
@@ -93,7 +93,7 @@ const Te = () => typeof Intl == "object" && typeof Intl.DateTimeFormat == "funct
93
93
  o += `00${i.toString(16)}`.substr(-2);
94
94
  }
95
95
  return o;
96
- }, xe = (e) => {
96
+ }, je = (e) => {
97
97
  const t = Math.round(e / 1e3), o = Math.floor(t / 3600), r = Math.floor((t - o * 3600) / 60), i = t % 60;
98
98
  return `${l(o, 2, "0")}:${l(r, 2, "0")}:${l(i, 2, "0")}`;
99
99
  };
@@ -103,8 +103,8 @@ function X(e) {
103
103
  function Ee() {
104
104
  return u;
105
105
  }
106
- const D = (e) => (t, { locale: o, tz: r, isUtc: i } = {}) => {
107
- if (u === null && (a.extend(R), a.extend(U), a.extend(F), a.extend(P), a.extend(A), a.updateLocale("zh-cn", {
106
+ const S = (e) => (t, { locale: o, tz: r, isUtc: i } = {}) => {
107
+ if (u === null && (a.extend(P), a.extend(U), a.extend(A), a.extend(R), a.extend(F), a.updateLocale("zh-cn", {
108
108
  // copy with https://github.com/iamkun/dayjs/blob/dev/src/locale/zh-cn.js
109
109
  relativeTime: {
110
110
  future: "%s后",
@@ -127,7 +127,7 @@ const D = (e) => (t, { locale: o, tz: r, isUtc: i } = {}) => {
127
127
  return r && (n = n.tz(r)), i && (n = n.utc()), typeof o < "u" && (n = n.locale(o)), n.format(e);
128
128
  };
129
129
  function ve(e, { locale: t = "en", tz: o } = {}) {
130
- return D("ll")(e, { locale: t, tz: o });
130
+ return S("ll")(e, { locale: t, tz: o });
131
131
  }
132
132
  function Oe(e, {
133
133
  locale: t = "en",
@@ -135,9 +135,9 @@ function Oe(e, {
135
135
  isUtc: r = !1,
136
136
  format: i = "lll"
137
137
  } = {}) {
138
- return D(i)(e, { locale: t, tz: o, isUtc: r });
138
+ return S(i)(e, { locale: t, tz: o, isUtc: r });
139
139
  }
140
- function K() {
140
+ function J() {
141
141
  const e = window?.ABT_DEV || window.ABT;
142
142
  return e && typeof e.open == "function" ? e : null;
143
143
  }
@@ -150,7 +150,7 @@ function Ue({
150
150
  appInfo: n,
151
151
  memberAppInfo: f
152
152
  }) {
153
- const h = K();
153
+ const h = J();
154
154
  if (h)
155
155
  return h.open({
156
156
  action: t,
@@ -163,7 +163,7 @@ function Ue({
163
163
  ...f
164
164
  }
165
165
  }), { type: "extension" };
166
- const S = {
166
+ const D = {
167
167
  toolbar: "no",
168
168
  location: "no",
169
169
  status: "no",
@@ -173,19 +173,19 @@ function Ue({
173
173
  // iphone 8plus size
174
174
  width: 414,
175
175
  height: 736
176
- }, V = `${e}?action=${t}&locale=${o}&url=${encodeURIComponent(r)}`, c = Object.assign({}, S, i), k = (s) => s.innerWidth || s.document.documentElement.clientWidth || s.document.body.clientWidth;
176
+ }, $ = `${e}?action=${t}&locale=${o}&url=${encodeURIComponent(r)}`, c = Object.assign({}, D, i), k = (s) => s.innerWidth || s.document.documentElement.clientWidth || s.document.body.clientWidth;
177
177
  if (!("left" in c)) {
178
- const s = k(window.top || window), T = window.screenLeft || window.screenX;
179
- c.left = s + T - c.width;
178
+ const s = k(window.top || window), x = window.screenLeft || window.screenX;
179
+ c.left = s + x - c.width;
180
180
  }
181
181
  if (!("top" in c)) {
182
182
  const s = window.screenTop || window.screenY;
183
183
  c.top = s;
184
184
  }
185
- const $ = Object.keys(c).map((s) => `${s}=${c[s]}`).join(",");
186
- return window.open(V, "targetWindow", $), { type: "web" };
185
+ const V = Object.keys(c).map((s) => `${s}=${c[s]}`).join(",");
186
+ return window.open($, "targetWindow", V), { type: "web" };
187
187
  }
188
- const Fe = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", J = (e) => {
188
+ const Ae = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", K = (e) => {
189
189
  const t = e.replace(L, "");
190
190
  return !!/^(0x)?[0-9a-f]{40}$/i.test(t);
191
191
  }, Q = (e, t) => {
@@ -199,15 +199,15 @@ const Fe = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", J = (e) =
199
199
  } catch {
200
200
  return e;
201
201
  }
202
- }, Ae = (e, t = 48) => e && (e.indexOf(C) >= 0 ? Q(e, {
202
+ }, Fe = (e, t = 48) => e && (e.indexOf(C) >= 0 ? Q(e, {
203
203
  imageFilter: "resize",
204
204
  w: t,
205
205
  h: t
206
- }) : e), Pe = (e = 0) => new Promise((t) => {
206
+ }) : e), Re = (e = 0) => new Promise((t) => {
207
207
  setTimeout(() => {
208
208
  t();
209
209
  }, e);
210
- }), Re = (e) => /^https?:\/\//.test(e), p = "vid", g = "__visitor_id", Y = () => m.get(p) || localStorage.getItem(g), y = (e) => {
210
+ }), Pe = (e) => /^https?:\/\//.test(e), p = "vid", g = "__visitor_id", Y = () => m.get(p) || localStorage.getItem(g), y = (e) => {
211
211
  e === null ? m.remove(p, {
212
212
  sameSite: "None",
213
213
  secure: !0
@@ -245,14 +245,14 @@ const Fe = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", J = (e) =
245
245
  e && y(e);
246
246
  }
247
247
  }, Le = (e) => {
248
- if (J(e)) {
248
+ if (K(e)) {
249
249
  const t = Uint8Array.from(
250
250
  e.slice(2).match(/.{1,2}/g).map((o) => parseInt(o, 16))
251
251
  ).slice(0, 8).reduce((o, r) => o + r, 0) % w.length;
252
252
  return w[t];
253
253
  }
254
254
  try {
255
- return x(e)?.color;
255
+ return j(e)?.color;
256
256
  } catch {
257
257
  return null;
258
258
  }
@@ -262,7 +262,7 @@ const Fe = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", J = (e) =
262
262
  return e;
263
263
  let n;
264
264
  return t && (n = e[t]), (!n || typeof n != "string") && (n = e[r]), (!n || typeof n != "string") && (n = i), n;
265
- }, Me = (e) => j(
265
+ }, Me = (e) => T(
266
266
  () => v(
267
267
  async () => {
268
268
  try {
@@ -275,11 +275,11 @@ const Fe = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", J = (e) =
275
275
  { retries: 2 }
276
276
  )
277
277
  ), _e = (e) => E(e, I);
278
- function ze(e, t = 1) {
278
+ function Ne(e, t = 1) {
279
279
  const [o, r, i] = O.hex.rgb(e);
280
280
  return `rgba(${o}, ${r}, ${i}, ${t})`;
281
281
  }
282
- const G = () => window.blocklet?.serverVersion || window.env?.serverVersion || "", H = () => b.version, Z = () => (b.dependencies?.["@blocklet/js-sdk"]).replace(/^[\^~>=<]+/, ""), d = (e, t) => {
282
+ const q = () => window.blocklet?.serverVersion || window.env?.serverVersion || "", G = () => b.version, H = () => (b.dependencies?.["@blocklet/js-sdk"]).replace(/^[\^~>=<]+/, ""), d = (e, t) => {
283
283
  const o = (n) => {
284
284
  const f = n.match(/^(\d+\.\d+\.\d+(?:-[^-]+?-\d{8}))/);
285
285
  return f ? f[1] : n;
@@ -294,44 +294,48 @@ const G = () => window.blocklet?.serverVersion || window.env?.serverVersion || "
294
294
  } catch {
295
295
  return !1;
296
296
  }
297
- }, Ne = () => {
297
+ }, ze = () => {
298
298
  if (process.env.NODE_ENV === "development")
299
299
  return !0;
300
- const e = G(), t = H(), o = Z();
300
+ const e = q(), t = G(), o = H();
301
301
  if (!e || !t || !o)
302
302
  return !1;
303
303
  const r = d(t, "3.1.29"), i = d(e, "1.16.49-beta-20250822-070545-6d3344cc"), n = d(o, "1.16.49-beta-20250822-070545-6d3344cc");
304
304
  return r && i && n;
305
+ }, Be = (e) => {
306
+ const { response: t } = e;
307
+ return t ? `Request failed: ${t.status} ${t.statusText}: ${JSON.stringify(t.data)}` : e.message || "Unknown error occurred";
305
308
  };
306
309
  export {
307
310
  Q as appendParams,
308
311
  _e as cleanedObj,
309
312
  d as compareVersions,
310
313
  Ke as deepmergeAll,
311
- K as detectWalletExtension,
314
+ J as detectWalletExtension,
312
315
  We as ensureVisitorId,
316
+ Be as formatAxiosError,
313
317
  ve as formatToDate,
314
318
  Oe as formatToDatetime,
315
- xe as formatUptime,
316
- Ve as getBackground,
317
- Se as getColor,
318
- De as getCookieOptions,
319
- $e as getCopyright,
319
+ je as formatUptime,
320
+ $e as getBackground,
321
+ De as getColor,
322
+ Se as getCookieOptions,
323
+ Ve as getCopyright,
320
324
  Le as getDIDColor,
321
325
  Ee as getDateTool,
322
- Fe as getFontSize,
323
- Z as getJsSdkVersion,
324
- G as getServerVersion,
325
- Te as getTimezone,
326
+ Ae as getFontSize,
327
+ H as getJsSdkVersion,
328
+ q as getServerVersion,
329
+ xe as getTimezone,
326
330
  Ce as getTranslation,
327
- Ae as getUserAvatar,
328
- H as getUxPackageVersion,
331
+ Fe as getUserAvatar,
332
+ G as getUxPackageVersion,
329
333
  Y as getVisitorId,
330
- ze as hexToRgba,
331
- J as isEthereumDid,
332
- Ne as isSupportFollow,
334
+ Ne as hexToRgba,
335
+ K as isEthereumDid,
336
+ ze as isSupportFollow,
333
337
  B as isTwoSegmentTLD,
334
- Re as isUrl,
338
+ Pe as isUrl,
335
339
  Me as lazyRetry,
336
340
  ke as mergeProps,
337
341
  Ue as openWebWallet,
@@ -339,7 +343,7 @@ export {
339
343
  ye as resolveRootDomain,
340
344
  X as setDateTool,
341
345
  y as setVisitorId,
342
- Pe as sleep,
343
- je as str2color,
346
+ Re as sleep,
347
+ Te as str2color,
344
348
  be as stringifyQuery
345
349
  };
@@ -1,4 +1,4 @@
1
- const e = "3.1.47", s = { "@blocklet/js-sdk": "1.16.52" }, n = {
1
+ const e = "3.1.49", s = { "@blocklet/js-sdk": "1.16.52" }, n = {
2
2
  version: e,
3
3
  dependencies: s
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "3.1.47",
3
+ "version": "3.1.49",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -68,16 +68,16 @@
68
68
  "react": "^19.0.0",
69
69
  "react-router-dom": "^6.22.3"
70
70
  },
71
- "gitHead": "8081935df0b3a38eba2c52f758be63318aa8c3ef",
71
+ "gitHead": "4612b57a1452bd4330755b53d093505a6ae7dea5",
72
72
  "dependencies": {
73
- "@arcblock/bridge": "3.1.47",
73
+ "@arcblock/bridge": "3.1.49",
74
74
  "@arcblock/did": "^1.25.6",
75
75
  "@arcblock/did-motif": "^1.1.14",
76
- "@arcblock/icons": "3.1.47",
77
- "@arcblock/nft-display": "3.1.47",
78
- "@arcblock/react-hooks": "3.1.47",
76
+ "@arcblock/icons": "3.1.49",
77
+ "@arcblock/nft-display": "3.1.49",
78
+ "@arcblock/react-hooks": "3.1.49",
79
79
  "@blocklet/js-sdk": "1.16.52",
80
- "@blocklet/theme": "3.1.47",
80
+ "@blocklet/theme": "3.1.49",
81
81
  "@fontsource/roboto": "~5.1.1",
82
82
  "@fontsource/ubuntu-mono": "^5.2.6",
83
83
  "@iconify-icons/logos": "^1.2.36",
@@ -9,7 +9,7 @@ function SwitchRole({
9
9
  user,
10
10
  switchPassport,
11
11
  }: {
12
- user: UserPublicInfo & { passports: { name: string; title: string; role: string }[] };
12
+ user: UserPublicInfo & { role: string; passports: { name: string; title: string; role: string }[] };
13
13
  switchPassport: () => void;
14
14
  }) {
15
15
  const currentRole = useCreation(
@@ -83,6 +83,7 @@ export interface LocaleProviderProps {
83
83
 
84
84
  export interface LocaleContextType {
85
85
  locale: Locale;
86
+ defaultLocale: Locale;
86
87
  changeLocale: (locale: Locale) => void;
87
88
  t: (key: string, data?: Record<string, any>) => string;
88
89
  languages: { code: string; name: string }[];
@@ -95,7 +96,7 @@ const { Provider, Consumer } = LocaleContext;
95
96
  function LocaleProvider({
96
97
  children,
97
98
  locale = undefined,
98
- fallbackLocale = undefined,
99
+ fallbackLocale = 'en',
99
100
  translations,
100
101
  onLoadingTranslation = undefined,
101
102
  languages = [],
@@ -104,7 +105,8 @@ function LocaleProvider({
104
105
  const langs = getLanguages(languages);
105
106
  // eslint-disable-next-line prefer-const
106
107
  let [currentLocale, setCurrentLocale] = useState<Locale>(locale || getLocale(langs));
107
- const lastCurrentLocale = useRef<string>(fallbackLocale || '');
108
+ const defaultLocale = langs?.[0]?.code ?? fallbackLocale;
109
+ const lastCurrentLocale = useRef<string>(defaultLocale);
108
110
  const [, setForceUpdate] = useState(0);
109
111
 
110
112
  const changeLocale = (newLocale: Locale) => {
@@ -145,7 +147,11 @@ function LocaleProvider({
145
147
  [translations, currentLocale, fallbackLocale]
146
148
  );
147
149
 
148
- return <Provider value={{ locale: currentLocale, changeLocale, t, languages: langs, ...rest }}>{children}</Provider>;
150
+ return (
151
+ <Provider value={{ locale: currentLocale, changeLocale, t, languages: langs, defaultLocale, ...rest }}>
152
+ {children}
153
+ </Provider>
154
+ );
149
155
  }
150
156
 
151
157
  function useLocaleContext() {
@@ -0,0 +1,53 @@
1
+ import { useRef, cloneElement } from 'react';
2
+ import { Button } from '@mui/material';
3
+ import { useMemoizedFn } from 'ahooks';
4
+ import OrgTransferSelector from './selector';
5
+ import { OrgTransferProps } from './type';
6
+ import translations from './locales';
7
+ import { translate } from '../Locale/util';
8
+
9
+ /**
10
+ * org transfer 弹框
11
+ */
12
+ export default function Index({
13
+ org,
14
+ onSuccess,
15
+ resourceId,
16
+ buttonProps,
17
+ buttonText,
18
+ locale = 'en',
19
+ dialogProps,
20
+ children,
21
+ }: OrgTransferProps) {
22
+ const t = useMemoizedFn((key, data = {}) => {
23
+ return translate(translations, key, locale, 'en', data);
24
+ });
25
+ const dialogRef = useRef(null);
26
+
27
+ const handleClick = () => {
28
+ if (dialogRef.current) {
29
+ (dialogRef.current as any).open({ selectedOrg: org });
30
+ }
31
+ };
32
+
33
+ return (
34
+ <>
35
+ {children ? (
36
+ cloneElement(children as React.ReactElement, { ...buttonProps, onClick: handleClick } as any)
37
+ ) : (
38
+ <Button {...buttonProps} onClick={handleClick}>
39
+ {buttonText || t('transferOrg')}
40
+ </Button>
41
+ )}
42
+
43
+ <OrgTransferSelector
44
+ locale={locale}
45
+ org={org}
46
+ ref={dialogRef}
47
+ resourceId={resourceId}
48
+ onSuccess={onSuccess}
49
+ dialogProps={dialogProps}
50
+ />
51
+ </>
52
+ );
53
+ }
@@ -0,0 +1,25 @@
1
+ export default {
2
+ en: {
3
+ transferOrg: 'Transfer to Other Organization',
4
+ cancel: 'Cancel',
5
+ confirm: 'Confirm',
6
+ tranferSuccess: 'Transfer success',
7
+ placeholder: 'Select an organization to transfer',
8
+ loading: 'Loading...',
9
+ noResults: 'No More',
10
+ resourceIdRequired: 'Please select the resource to transfer',
11
+ organizationSameAsCurrent:
12
+ 'The selected organization is the same as the current organization, please select other organizations',
13
+ },
14
+ zh: {
15
+ transferOrg: '转移至其他组织',
16
+ cancel: '取消',
17
+ confirm: '确认',
18
+ tranferSuccess: '转移成功',
19
+ placeholder: '请选择要转移的组织',
20
+ loading: '加载中...',
21
+ noResults: '没有更多了',
22
+ resourceIdRequired: '请选择要转移的资源',
23
+ organizationSameAsCurrent: '选择的组织与当前组织相同,请选择其他组织',
24
+ },
25
+ };