@arcblock/ux 3.0.8 → 3.0.10

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.
Files changed (66) hide show
  1. package/lib/Address/did-address.js +47 -49
  2. package/lib/Address/responsive-did-address.js +53 -57
  3. package/lib/Avatar/index.js +16 -16
  4. package/lib/BlockletV2/blocklet.js +64 -64
  5. package/lib/BlockletV2/components/tooltip-icon.js +26 -27
  6. package/lib/CardSelector/index.js +1 -2
  7. package/lib/ClickToCopy/hook.js +10 -11
  8. package/lib/ClickToCopy/index.js +16 -16
  9. package/lib/Config/theme-mode-toggle.js +7 -8
  10. package/lib/DID/index.js +131 -133
  11. package/lib/DIDConnect/app-info-item.js +18 -18
  12. package/lib/DIDConnect/auth-apps/index.js +83 -84
  13. package/lib/DIDConnect/did-connect-container.js +89 -90
  14. package/lib/DIDConnect/did-connect-footer.js +25 -25
  15. package/lib/DIDConnect/landing-page.js +17 -17
  16. package/lib/DIDConnect/powered-by.js +11 -11
  17. package/lib/DIDConnect/request-storage-access-api-dialog.js +36 -37
  18. package/lib/DIDConnect/with-container.js +66 -68
  19. package/lib/Dialog/use-confirm.js +40 -43
  20. package/lib/Earth/index.js +21 -22
  21. package/lib/Footer/index.js +15 -16
  22. package/lib/Header/responsive-header.js +23 -24
  23. package/lib/Layout/dashboard/index.js +63 -72
  24. package/lib/Layout/dashboard/sidebar.js +20 -21
  25. package/lib/Layout/dashboard-legacy/index.js +52 -52
  26. package/lib/Locale/context.js +36 -37
  27. package/lib/Locale/selector.js +40 -42
  28. package/lib/NFTDisplay/index.js +114 -118
  29. package/lib/NFTDisplay/render-svg.js +12 -12
  30. package/lib/NavMenu/nav-menu.js +159 -161
  31. package/lib/NavMenu/sub-container.js +25 -26
  32. package/lib/PageScroller/index.js +28 -32
  33. package/lib/Passport/passport.js +11 -11
  34. package/lib/PhoneInput/country-select.js +38 -38
  35. package/lib/PhoneInput/index.js +65 -66
  36. package/lib/Screenshot/index.js +26 -27
  37. package/lib/SessionBlocklet/index.js +87 -93
  38. package/lib/SessionPermission/index.js +5 -9
  39. package/lib/SessionUser/components/did-space.js +24 -25
  40. package/lib/SessionUser/components/logged-in.js +122 -127
  41. package/lib/SessionUser/components/quick-login-item.js +41 -42
  42. package/lib/SessionUser/components/session-user-item.js +35 -36
  43. package/lib/SessionUser/components/session-user-switch.js +81 -85
  44. package/lib/SessionUser/components/un-login.js +41 -41
  45. package/lib/SessionUser/components/user-info.js +43 -47
  46. package/lib/SessionUser/index.js +1 -1
  47. package/lib/SessionUser/libs/utils.js +24 -30
  48. package/lib/SharedBridge/index.js +35 -35
  49. package/lib/Theme/index.js +16 -16
  50. package/lib/Theme/theme.js +42 -43
  51. package/lib/Toast/index.js +24 -25
  52. package/lib/Typography/index.js +42 -42
  53. package/lib/UserCard/Content/basic.js +91 -93
  54. package/lib/UserCard/Content/shorten-label.js +9 -9
  55. package/lib/UserCard/components.js +15 -15
  56. package/lib/Util/deprecate.js +1 -1
  57. package/lib/Util/federated.js +28 -32
  58. package/lib/Util/iframe.js +9 -10
  59. package/lib/Util/index.js +134 -135
  60. package/lib/Util/security.js +9 -10
  61. package/lib/Util/wallet.js +6 -9
  62. package/lib/VerificationCode/index.js +26 -28
  63. package/lib/hooks/use-blocklet-logo.js +11 -14
  64. package/lib/ux.css +1 -1
  65. package/lib/withTracker/index.js +13 -14
  66. package/package.json +9 -10
@@ -1,39 +1,33 @@
1
- const e = (n) => n == null ? void 0 : n.sourceAppPid, p = (n) => {
2
- var t;
3
- return (n == null ? void 0 : n.sourceAppPid) || ((t = window == null ? void 0 : window.blocklet) == null ? void 0 : t.appPid);
4
- };
5
- function A(n) {
6
- return n == null ? void 0 : n.did;
1
+ const d = (t) => t?.sourceAppPid, u = (t) => t?.sourceAppPid || window?.blocklet?.appPid;
2
+ function i(t) {
3
+ return t?.did;
7
4
  }
8
- function d(n) {
9
- var t;
10
- return (n == null ? void 0 : n.connectedAccounts) || ((t = n == null ? void 0 : n.extraConfigs) == null ? void 0 : t.connectedAccounts) || [];
5
+ function o(t) {
6
+ return t?.connectedAccounts || t?.extraConfigs?.connectedAccounts || [];
11
7
  }
12
- function l(n) {
13
- var t;
14
- return (n == null ? void 0 : n.sourceProvider) || ((t = n == null ? void 0 : n.extraConfigs) == null ? void 0 : t.sourceProvider) || "wallet";
8
+ function s(t) {
9
+ return t?.sourceProvider || t?.extraConfigs?.sourceProvider || "wallet";
15
10
  }
16
- function a(n) {
17
- return d(n).map((c) => c.provider);
11
+ function l(t) {
12
+ return o(t).map((c) => c.provider);
18
13
  }
19
- function g(n) {
20
- return d(n).map((o) => o.did);
14
+ function A(t) {
15
+ return o(t).map((e) => e.did);
21
16
  }
22
- function i(n) {
23
- return d(n).find((o) => o.provider === "wallet");
17
+ function r(t) {
18
+ return o(t).find((e) => e.provider === "wallet");
24
19
  }
25
- function f(n) {
26
- const t = i(n);
27
- return t == null ? void 0 : t.did;
20
+ function p(t) {
21
+ return r(t)?.did;
28
22
  }
29
23
  export {
30
- d as getConnectedAccounts,
31
- g as getConnectedDids,
32
- p as getCurrentAppPid,
33
- A as getPermanentDid,
34
- e as getSourceAppPid,
35
- l as getSourceProvider,
36
- a as getSourceProviders,
37
- i as getWallet,
38
- f as getWalletDid
24
+ o as getConnectedAccounts,
25
+ A as getConnectedDids,
26
+ u as getCurrentAppPid,
27
+ i as getPermanentDid,
28
+ d as getSourceAppPid,
29
+ s as getSourceProvider,
30
+ l as getSourceProviders,
31
+ r as getWallet,
32
+ p as getWalletDid
39
33
  };
@@ -1,76 +1,76 @@
1
- import { jsx as g } from "react/jsx-runtime";
1
+ import { jsx as p } from "react/jsx-runtime";
2
2
  import { Box as I } from "@mui/material";
3
3
  import { memo as v, useRef as w, useId as S, useEffect as A, useImperativeHandle as L } from "react";
4
- import { withQuery as b } from "ufo";
5
- import { useReactive as x, useMemoizedFn as y } from "ahooks";
6
- import E from "lodash/noop";
7
- import { mergeSx as R } from "../Util/style.js";
4
+ import { withQuery as R } from "ufo";
5
+ import { useReactive as b, useMemoizedFn as x } from "ahooks";
6
+ import y from "lodash/noop";
7
+ import { mergeSx as E } from "../Util/style.js";
8
8
  import { callIframe as i, getCallbackAction as d } from "../Util/iframe.js";
9
9
  function B({
10
10
  ref: c = void 0,
11
- src: o,
11
+ src: t,
12
12
  onClick: s,
13
- onLoad: u = E,
14
- sx: m = {},
15
- ...f
13
+ onLoad: u = y,
14
+ sx: f = {},
15
+ ...m
16
16
  }) {
17
- const r = w(null), n = `shared-bridge_${S()}`, t = x({
17
+ const o = w(null), a = `shared-bridge_${S()}`, r = b({
18
18
  hasInited: void 0,
19
19
  open: !1,
20
20
  hasStorageAccess: !1,
21
21
  containerEl: null,
22
22
  get origin() {
23
23
  try {
24
- return new URL(o).origin;
24
+ return new URL(t).origin;
25
25
  } catch {
26
- return o;
26
+ return t;
27
27
  }
28
28
  },
29
29
  get host() {
30
30
  try {
31
- return new URL(o).host;
31
+ return new URL(t).host;
32
32
  } catch {
33
- return o;
33
+ return t;
34
34
  }
35
35
  }
36
36
  });
37
37
  A(() => {
38
- async function e(h) {
39
- const { data: a } = h;
40
- if (a.action === d(n, "requestStorageAccess")) {
41
- if (t.open = !1, !a.value) {
42
- s(a);
38
+ async function e(g) {
39
+ const { data: n } = g;
40
+ if (n.action === d(a, "requestStorageAccess")) {
41
+ if (r.open = !1, !n.value) {
42
+ s(n);
43
43
  return;
44
44
  }
45
- const { value: p } = await i(r.current, "getVisitorId");
46
- s({ ...a, visitorId: p });
47
- } else a.action === d(n, "preRequestStorageAccess") && (t.open = !0);
45
+ const { value: h } = await i(o.current, "getVisitorId");
46
+ s({ ...n, visitorId: h });
47
+ } else n.action === d(a, "preRequestStorageAccess") && (r.open = !0);
48
48
  }
49
49
  return window.addEventListener("message", e), () => {
50
50
  window.removeEventListener("message", e);
51
51
  };
52
- }, [s, n, r == null ? void 0 : r.current]);
53
- const l = y(() => {
54
- i(r.current, "hasStorageAccess").then(({ value: e }) => {
55
- t.hasStorageAccess = e, t.hasInited = !0;
52
+ }, [s, a, o?.current]);
53
+ const l = x(() => {
54
+ i(o.current, "hasStorageAccess").then(({ value: e }) => {
55
+ r.hasStorageAccess = e, r.hasInited = !0;
56
56
  }), setTimeout(() => {
57
- t.hasInited === void 0 && (t.hasInited = !1);
57
+ r.hasInited === void 0 && (r.hasInited = !1);
58
58
  }, 1e3), u();
59
59
  });
60
60
  return L(c, () => ({
61
61
  callIframe(e) {
62
- return i(r.current, e);
62
+ return i(o.current, e);
63
63
  }
64
- })), /* @__PURE__ */ g(
64
+ })), /* @__PURE__ */ p(
65
65
  I,
66
66
  {
67
- ...f,
67
+ ...m,
68
68
  component: "iframe",
69
- ref: r,
69
+ ref: o,
70
70
  onLoad: l,
71
- "data-id": n,
72
- src: b(o, { id: n }),
73
- sx: R(
71
+ "data-id": a,
72
+ src: R(t, { id: a }),
73
+ sx: E(
74
74
  {
75
75
  border: 0,
76
76
  position: "absolute",
@@ -81,7 +81,7 @@ function B({
81
81
  cursor: "pointer",
82
82
  backgroundColor: "transparent"
83
83
  },
84
- m
84
+ f
85
85
  )
86
86
  }
87
87
  );
@@ -1,25 +1,25 @@
1
- import { styled as a } from "@mui/material";
1
+ import { styled as s } from "@mui/material";
2
2
  import { useTheme as h } from "@mui/material";
3
- import { collectFontFamilies as c, create as f, createDefaultThemeOptions as T, createTheme as x, isTheme as F, isUxTheme as i, lazyCreateDefaultTheme as n, loadFonts as P } from "./theme.js";
4
- import { ColorSchemeContext as C, default as w, useColorScheme as p } from "./theme-provider.js";
3
+ import { collectFontFamilies as c, create as f, createDefaultThemeOptions as i, createTheme as n, isTheme as T, isUxTheme as x, lazyCreateDefaultTheme as p, loadFonts as F } from "./theme.js";
4
+ import { ColorSchemeContext as y, default as C, useColorScheme as w } from "./theme-provider.js";
5
5
  import { deepmerge as S } from "@mui/utils";
6
- const o = (r) => r.startsWith("$"), l = (r, e) => a(r, {
7
- ...e,
8
- shouldForwardProp: (t) => e != null && e.shouldForwardProp ? e.shouldForwardProp(t) && !o(t) : !o(t)
6
+ const o = (e) => e.startsWith("$"), m = (e, r) => s(e, {
7
+ ...r,
8
+ shouldForwardProp: (t) => r?.shouldForwardProp ? r.shouldForwardProp(t) && !o(t) : !o(t)
9
9
  });
10
10
  export {
11
- C as ColorSchemeContext,
12
- w as ThemeProvider,
11
+ y as ColorSchemeContext,
12
+ C as ThemeProvider,
13
13
  c as collectFontFamilies,
14
14
  f as create,
15
- T as createDefaultThemeOptions,
16
- x as createTheme,
15
+ i as createDefaultThemeOptions,
16
+ n as createTheme,
17
17
  S as deepmerge,
18
- F as isTheme,
19
- i as isUxTheme,
20
- n as lazyCreateDefaultTheme,
21
- P as loadFonts,
22
- l as styled,
23
- p as useColorScheme,
18
+ T as isTheme,
19
+ x as isUxTheme,
20
+ p as lazyCreateDefaultTheme,
21
+ F as loadFonts,
22
+ m as styled,
23
+ w as useColorScheme,
24
24
  h as useTheme
25
25
  };
@@ -1,35 +1,35 @@
1
- import { createTheme as f, responsiveFontSizes as _ } from "@mui/material";
2
- import { deepmerge as d } from "@mui/utils";
3
- import { deepmerge as X } from "@mui/utils";
4
- import b from "webfontloader";
5
- import { DEFAULT_FONTS as C, getDefaultThemePrefer as k, getBlockletThemeOptions as h, BLOCKLET_THEME_DARK as x, BLOCKLET_THEME_LIGHT as A } from "@blocklet/theme";
6
- import { deepmergeAll as E, cleanedObj as m } from "../Util/index.js";
1
+ import { createTheme as p, responsiveFontSizes as O } from "@mui/material";
2
+ import { deepmerge as f } from "@mui/utils";
3
+ import { deepmerge as V } from "@mui/utils";
4
+ import _ from "webfontloader";
5
+ import { DEFAULT_FONTS as b, getDefaultThemePrefer as C, getBlockletThemeOptions as d, BLOCKLET_THEME_DARK as k, BLOCKLET_THEME_LIGHT as x } from "@blocklet/theme";
6
+ import { deepmergeAll as A, cleanedObj as l } from "../Util/index.js";
7
7
  import "@fontsource/roboto/latin-400.css";
8
8
  import "@fontsource/roboto/latin-500.css";
9
9
  import "@fontsource/roboto/latin-700.css";
10
10
  import "@fontsource/roboto/latin-ext-400.css";
11
11
  import "@fontsource/roboto/latin-ext-500.css";
12
12
  import "@fontsource/roboto/latin-ext-700.css";
13
- function D(e) {
13
+ function E(e) {
14
14
  return e && typeof e == "object" && e.palette && typeof e.palette.getContrastText == "function";
15
15
  }
16
- function q(e) {
17
- return D(e) && e.__isUxTheme__ === !0;
16
+ function W(e) {
17
+ return E(e) && e.__isUxTheme__ === !0;
18
18
  }
19
- function u(e, t = /* @__PURE__ */ new Set()) {
19
+ function h(e, t = /* @__PURE__ */ new Set()) {
20
20
  return !e || typeof e != "object" || (typeof e.fontFamily == "string" && e.fontFamily.replace(/"/g, "").split(",").map((o) => o.trim()).filter(Boolean).forEach((o) => t.add(o)), Object.values(e).forEach((o) => {
21
- typeof o == "object" && u(o, t);
21
+ typeof o == "object" && h(o, t);
22
22
  })), t;
23
23
  }
24
- const s = new Set(C.concat("inherit"));
25
- function w(e) {
24
+ const s = new Set(b.concat("inherit"));
25
+ function D(e) {
26
26
  const t = e.filter((r) => !s.has(r));
27
27
  if (t.length === 0)
28
28
  return Promise.resolve(!0);
29
29
  t.forEach((r) => s.add(r));
30
30
  const o = t.length - 1;
31
31
  return t[o] = `${t[o]}&display=swap`, new Promise((r) => {
32
- b.load({
32
+ _.load({
33
33
  google: {
34
34
  families: t
35
35
  },
@@ -41,25 +41,25 @@ function w(e) {
41
41
  });
42
42
  });
43
43
  }
44
- function T(e = "light") {
45
- return e === "dark" ? x : A;
44
+ function u(e = "light") {
45
+ return e === "dark" ? k : x;
46
46
  }
47
- function v(e) {
47
+ function w(e) {
48
48
  let t = null;
49
49
  return () => {
50
50
  if (t) return t;
51
- const o = d(T(e), h(e));
52
- return t = f(o), t;
51
+ const o = f(u(e), d(e));
52
+ return t = p(o), t;
53
53
  };
54
54
  }
55
- const p = ({ palette: e, components: t, overrides: o, ...r }) => ({
55
+ const m = ({ palette: e, components: t, overrides: o, ...r }) => ({
56
56
  palette: e,
57
57
  components: {
58
58
  ...o,
59
59
  ...t
60
60
  },
61
61
  ...r
62
- }), L = {
62
+ }), v = {
63
63
  // @ts-expect-error
64
64
  themeName: "ArcBlock",
65
65
  pageWidth: "md",
@@ -85,26 +85,25 @@ const p = ({ palette: e, components: t, overrides: o, ...r }) => ({
85
85
  danger: "#D0021B",
86
86
  lightGrey: "#BCBCBC"
87
87
  }
88
- }, U = (...e) => {
89
- var l;
90
- const t = k(), o = v(t), r = e.reduce(
91
- (O, c) => d(O, p(typeof c == "function" ? c(o()) : c)),
92
- p(L)
93
- ), n = r.mode || ((l = r.palette) == null ? void 0 : l.mode) || t, i = h(n), F = T(n), { disableBlockletTheme: g } = r, y = E(
88
+ }, L = (...e) => {
89
+ const t = C(), o = w(t), r = e.reduce(
90
+ (B, c) => f(B, m(typeof c == "function" ? c(o()) : c)),
91
+ m(v)
92
+ ), n = r.mode || r.palette?.mode || t, i = d(n), T = u(n), { disableBlockletTheme: F } = r, g = A(
94
93
  [
95
- F,
96
- !g && m(i),
97
- m(r),
94
+ T,
95
+ !F && l(i),
96
+ l(r),
98
97
  // 确保 mode 跟 prefer 一致
99
98
  {
100
99
  mode: n,
101
100
  palette: { mode: n }
102
101
  }
103
102
  ].filter(Boolean)
104
- ), a = f(y);
103
+ ), a = p(g);
105
104
  a.__isUxTheme__ = !0;
106
- const B = u(a.typography);
107
- return w(Array.from(B)), _(a, {
105
+ const y = h(a.typography);
106
+ return D(Array.from(y)), O(a, {
108
107
  breakpoints: ["xs", "sm", "md", "lg"],
109
108
  disableAlign: !1,
110
109
  factor: 3,
@@ -124,15 +123,15 @@ const p = ({ palette: e, components: t, overrides: o, ...r }) => ({
124
123
  "overline"
125
124
  ]
126
125
  });
127
- }, J = U;
126
+ }, q = L;
128
127
  export {
129
- u as collectFontFamilies,
130
- U as create,
131
- T as createDefaultThemeOptions,
132
- J as createTheme,
133
- X as deepmerge,
134
- D as isTheme,
135
- q as isUxTheme,
136
- v as lazyCreateDefaultTheme,
137
- w as loadFonts
128
+ h as collectFontFamilies,
129
+ L as create,
130
+ u as createDefaultThemeOptions,
131
+ q as createTheme,
132
+ V as deepmerge,
133
+ E as isTheme,
134
+ W as isUxTheme,
135
+ w as lazyCreateDefaultTheme,
136
+ D as loadFonts
138
137
  };
@@ -1,22 +1,21 @@
1
- import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
- import { createRef as g } from "react";
3
- import { SnackbarProvider as b, useSnackbar as h } from "notistack";
4
- import { IconButton as S } from "@mui/material";
5
- import { Close as v } from "@mui/icons-material";
1
+ import { jsxs as k, jsx as s } from "react/jsx-runtime";
2
+ import { createRef as d } from "react";
3
+ import { SnackbarProvider as g, useSnackbar as b } from "notistack";
4
+ import { IconButton as h } from "@mui/material";
5
+ import { Close as S } from "@mui/icons-material";
6
6
  import e from "lodash/noop";
7
- let l = e, u = e, f = e, m = e, p = e;
7
+ let a = e, l = e, u = e, f = e, m = e;
8
8
  const t = (o, r) => (i, n = {}) => o(i, {
9
9
  autoHideDuration: 5e3,
10
10
  variant: r,
11
11
  ...n
12
12
  });
13
- function H({ children: o, anchorOrigin: r, ...i }) {
14
- const n = g(), k = (c) => () => {
15
- var a;
16
- (a = n.current) == null || a.closeSnackbar(c);
13
+ function j({ children: o, anchorOrigin: r, ...i }) {
14
+ const n = d(), p = (c) => () => {
15
+ n.current?.closeSnackbar(c);
17
16
  };
18
- return /* @__PURE__ */ d(
19
- b,
17
+ return /* @__PURE__ */ k(
18
+ g,
20
19
  {
21
20
  anchorOrigin: {
22
21
  vertical: "top",
@@ -25,26 +24,26 @@ function H({ children: o, anchorOrigin: r, ...i }) {
25
24
  },
26
25
  ...i,
27
26
  ref: n,
28
- action: (c) => /* @__PURE__ */ s(S, { "aria-label": "close", color: "inherit", onClick: k(c), size: "large", children: /* @__PURE__ */ s(v, { style: { fontSize: 16 } }) }, "close"),
27
+ action: (c) => /* @__PURE__ */ s(h, { "aria-label": "close", color: "inherit", onClick: p(c), size: "large", children: /* @__PURE__ */ s(S, { style: { fontSize: 16 } }) }, "close"),
29
28
  children: [
30
- /* @__PURE__ */ s(w, {}),
29
+ /* @__PURE__ */ s(v, {}),
31
30
  o
32
31
  ]
33
32
  }
34
33
  );
35
34
  }
36
- function w() {
37
- const { enqueueSnackbar: o, closeSnackbar: r } = h();
38
- return l = t(o, "success"), u = t(o, "error"), f = t(o, "warning"), m = t(o, "info"), p = r, null;
35
+ function v() {
36
+ const { enqueueSnackbar: o, closeSnackbar: r } = b();
37
+ return a = t(o, "success"), l = t(o, "error"), u = t(o, "warning"), f = t(o, "info"), m = r, null;
39
38
  }
40
- const P = {
41
- success: (o, r = {}) => l(o, r),
42
- error: (o, r = { autoHideDuration: 15e3 }) => u(o, r),
43
- warning: (o, r = {}) => f(o, r),
44
- info: (o, r = {}) => m(o, r),
45
- close: (o) => p(o)
39
+ const H = {
40
+ success: (o, r = {}) => a(o, r),
41
+ error: (o, r = { autoHideDuration: 15e3 }) => l(o, r),
42
+ warning: (o, r = {}) => u(o, r),
43
+ info: (o, r = {}) => f(o, r),
44
+ close: (o) => m(o)
46
45
  };
47
46
  export {
48
- H as ToastProvider,
49
- P as default
47
+ j as ToastProvider,
48
+ H as default
50
49
  };
@@ -1,82 +1,82 @@
1
- import { jsxs as g, jsx as a } from "react/jsx-runtime";
2
- import { Box as x, Typography as u, Skeleton as y } from "@mui/material";
3
- import { useReactive as v, useSize as c, useCreation as C } from "ahooks";
4
- import b from "lodash/noop";
5
- import { useRef as m, useEffect as w } from "react";
6
- let p = -1;
7
- function T() {
8
- const t = document.createElement("div");
9
- Object.assign(t.style, {
1
+ import { jsxs as g, jsx as n } from "react/jsx-runtime";
2
+ import { Box as x, Typography as d, Skeleton as y } from "@mui/material";
3
+ import { useReactive as h, useSize as z, useCreation as v } from "ahooks";
4
+ import C from "lodash/noop";
5
+ import { useRef as c, useEffect as b } from "react";
6
+ let u = -1;
7
+ function w() {
8
+ const i = document.createElement("div");
9
+ Object.assign(i.style, {
10
10
  fontSize: "1px",
11
11
  visibility: "hidden",
12
12
  position: "absolute"
13
- }), t.textContent = "Test", document.body.appendChild(t);
14
- const f = parseFloat(getComputedStyle(t).fontSize);
15
- return document.body.removeChild(t), f;
13
+ }), i.textContent = "Test", document.body.appendChild(i);
14
+ const r = parseFloat(getComputedStyle(i).fontSize);
15
+ return document.body.removeChild(i), r;
16
16
  }
17
- function M({
18
- children: t = null,
19
- minFontSize: f = 12,
17
+ function E({
18
+ children: i = null,
19
+ minFontSize: r = 12,
20
20
  /* 设置为 auto 时字体会自动收缩,直到达到浏览器最小字体限制 */
21
- fontSize: n = void 0,
22
- sx: s,
23
- onShrink: i = b,
24
- ...r
21
+ fontSize: t = void 0,
22
+ sx: a,
23
+ onShrink: p = C,
24
+ ...l
25
25
  }) {
26
- const d = m(null), z = m(null), e = v({
26
+ const f = c(null), S = c(null), e = h({
27
27
  // @ts-expect-error
28
- fontSize: n,
28
+ fontSize: t,
29
29
  loading: !0
30
- }), o = c(d.current), l = c(z.current);
31
- return w(() => {
30
+ }), o = z(f.current), s = z(S.current);
31
+ return b(() => {
32
32
  if (e.loading)
33
- if (n === "auto") {
33
+ if (t === "auto") {
34
34
  if (o && !e.initialSize) {
35
- const S = getComputedStyle(d.current).fontSize;
36
- e.initialSize = Number(S.replace("px", "")), e.fontSize = e.initialSize;
35
+ const m = getComputedStyle(f.current).fontSize;
36
+ e.initialSize = Number(m.replace("px", "")), e.fontSize = e.initialSize;
37
37
  }
38
- p < 0 && (p = T()), e.fontSize <= p ? (e.loading = !1, i == null || i({ fontSize: e.fontSize, initialSize: e.initialSize })) : l && o && (l.width < o.width && e.fontSize > f ? e.fontSize-- : (e.loading = !1, i == null || i({ fontSize: e.fontSize, initialSize: e.initialSize })));
38
+ u < 0 && (u = w()), e.fontSize <= u ? (e.loading = !1, p?.({ fontSize: e.fontSize, initialSize: e.initialSize })) : s && o && (s.width < o.width && e.fontSize > r ? e.fontSize-- : (e.loading = !1, p?.({ fontSize: e.fontSize, initialSize: e.initialSize })));
39
39
  } else
40
40
  e.loading = !1;
41
- }, [n, o == null ? void 0 : o.width, l == null ? void 0 : l.width]), C(() => n === "auto" ? e.loading : !1, [n, e.loading]) ? /* @__PURE__ */ g(
41
+ }, [t, o?.width, s?.width]), v(() => t === "auto" ? e.loading : !1, [t, e.loading]) ? /* @__PURE__ */ g(
42
42
  x,
43
43
  {
44
- ref: z,
44
+ ref: S,
45
45
  sx: {
46
46
  flex: 1
47
47
  },
48
48
  children: [
49
- /* @__PURE__ */ a(u, { ...r, sx: s, noWrap: !0, children: /* @__PURE__ */ a(y, { variant: "text", sx: { fontSize: "1rem" } }) }),
50
- /* @__PURE__ */ a(
51
- u,
49
+ /* @__PURE__ */ n(d, { ...l, sx: a, noWrap: !0, children: /* @__PURE__ */ n(y, { variant: "text", sx: { fontSize: "1rem" } }) }),
50
+ /* @__PURE__ */ n(
51
+ d,
52
52
  {
53
- ref: d,
54
- ...r,
53
+ ref: f,
54
+ ...l,
55
55
  sx: {
56
- ...s,
56
+ ...a,
57
57
  ...e.fontSize ? { fontSize: `${e.fontSize}px !important` } : {},
58
58
  position: "fixed",
59
59
  top: -1e3,
60
60
  left: -1e3
61
61
  },
62
62
  noWrap: !0,
63
- children: t
63
+ children: i
64
64
  }
65
65
  )
66
66
  ]
67
67
  }
68
- ) : /* @__PURE__ */ a(
69
- u,
68
+ ) : /* @__PURE__ */ n(
69
+ d,
70
70
  {
71
- ...r,
71
+ ...l,
72
72
  sx: {
73
- ...s,
73
+ ...a,
74
74
  ...e.fontSize ? { fontSize: `${e.fontSize}px !important` } : {}
75
75
  },
76
- children: t
76
+ children: i
77
77
  }
78
78
  );
79
79
  }
80
80
  export {
81
- M as default
81
+ E as default
82
82
  };