@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.
- package/lib/Address/did-address.js +47 -49
- package/lib/Address/responsive-did-address.js +53 -57
- package/lib/Avatar/index.js +16 -16
- package/lib/BlockletV2/blocklet.js +64 -64
- package/lib/BlockletV2/components/tooltip-icon.js +26 -27
- package/lib/CardSelector/index.js +1 -2
- package/lib/ClickToCopy/hook.js +10 -11
- package/lib/ClickToCopy/index.js +16 -16
- package/lib/Config/theme-mode-toggle.js +7 -8
- package/lib/DID/index.js +131 -133
- package/lib/DIDConnect/app-info-item.js +18 -18
- package/lib/DIDConnect/auth-apps/index.js +83 -84
- package/lib/DIDConnect/did-connect-container.js +89 -90
- package/lib/DIDConnect/did-connect-footer.js +25 -25
- package/lib/DIDConnect/landing-page.js +17 -17
- package/lib/DIDConnect/powered-by.js +11 -11
- package/lib/DIDConnect/request-storage-access-api-dialog.js +36 -37
- package/lib/DIDConnect/with-container.js +66 -68
- package/lib/Dialog/use-confirm.js +40 -43
- package/lib/Earth/index.js +21 -22
- package/lib/Footer/index.js +15 -16
- package/lib/Header/responsive-header.js +23 -24
- package/lib/Layout/dashboard/index.js +63 -72
- package/lib/Layout/dashboard/sidebar.js +20 -21
- package/lib/Layout/dashboard-legacy/index.js +52 -52
- package/lib/Locale/context.js +36 -37
- package/lib/Locale/selector.js +40 -42
- package/lib/NFTDisplay/index.js +114 -118
- package/lib/NFTDisplay/render-svg.js +12 -12
- package/lib/NavMenu/nav-menu.js +159 -161
- package/lib/NavMenu/sub-container.js +25 -26
- package/lib/PageScroller/index.js +28 -32
- package/lib/Passport/passport.js +11 -11
- package/lib/PhoneInput/country-select.js +38 -38
- package/lib/PhoneInput/index.js +65 -66
- package/lib/Screenshot/index.js +26 -27
- package/lib/SessionBlocklet/index.js +87 -93
- package/lib/SessionPermission/index.js +5 -9
- package/lib/SessionUser/components/did-space.js +24 -25
- package/lib/SessionUser/components/logged-in.js +122 -127
- package/lib/SessionUser/components/quick-login-item.js +41 -42
- package/lib/SessionUser/components/session-user-item.js +35 -36
- package/lib/SessionUser/components/session-user-switch.js +81 -85
- package/lib/SessionUser/components/un-login.js +41 -41
- package/lib/SessionUser/components/user-info.js +43 -47
- package/lib/SessionUser/index.js +1 -1
- package/lib/SessionUser/libs/utils.js +24 -30
- package/lib/SharedBridge/index.js +35 -35
- package/lib/Theme/index.js +16 -16
- package/lib/Theme/theme.js +42 -43
- package/lib/Toast/index.js +24 -25
- package/lib/Typography/index.js +42 -42
- package/lib/UserCard/Content/basic.js +91 -93
- package/lib/UserCard/Content/shorten-label.js +9 -9
- package/lib/UserCard/components.js +15 -15
- package/lib/Util/deprecate.js +1 -1
- package/lib/Util/federated.js +28 -32
- package/lib/Util/iframe.js +9 -10
- package/lib/Util/index.js +134 -135
- package/lib/Util/security.js +9 -10
- package/lib/Util/wallet.js +6 -9
- package/lib/VerificationCode/index.js +26 -28
- package/lib/hooks/use-blocklet-logo.js +11 -14
- package/lib/ux.css +1 -1
- package/lib/withTracker/index.js +13 -14
- package/package.json +9 -10
@@ -1,39 +1,33 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
return
|
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
|
9
|
-
|
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
|
13
|
-
|
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
|
17
|
-
return
|
11
|
+
function l(t) {
|
12
|
+
return o(t).map((c) => c.provider);
|
18
13
|
}
|
19
|
-
function
|
20
|
-
return
|
14
|
+
function A(t) {
|
15
|
+
return o(t).map((e) => e.did);
|
21
16
|
}
|
22
|
-
function
|
23
|
-
return
|
17
|
+
function r(t) {
|
18
|
+
return o(t).find((e) => e.provider === "wallet");
|
24
19
|
}
|
25
|
-
function
|
26
|
-
|
27
|
-
return t == null ? void 0 : t.did;
|
20
|
+
function p(t) {
|
21
|
+
return r(t)?.did;
|
28
22
|
}
|
29
23
|
export {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
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
|
5
|
-
import { useReactive as
|
6
|
-
import
|
7
|
-
import { mergeSx as
|
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:
|
11
|
+
src: t,
|
12
12
|
onClick: s,
|
13
|
-
onLoad: u =
|
14
|
-
sx:
|
15
|
-
...
|
13
|
+
onLoad: u = y,
|
14
|
+
sx: f = {},
|
15
|
+
...m
|
16
16
|
}) {
|
17
|
-
const
|
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(
|
24
|
+
return new URL(t).origin;
|
25
25
|
} catch {
|
26
|
-
return
|
26
|
+
return t;
|
27
27
|
}
|
28
28
|
},
|
29
29
|
get host() {
|
30
30
|
try {
|
31
|
-
return new URL(
|
31
|
+
return new URL(t).host;
|
32
32
|
} catch {
|
33
|
-
return
|
33
|
+
return t;
|
34
34
|
}
|
35
35
|
}
|
36
36
|
});
|
37
37
|
A(() => {
|
38
|
-
async function e(
|
39
|
-
const { data:
|
40
|
-
if (
|
41
|
-
if (
|
42
|
-
s(
|
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:
|
46
|
-
s({ ...
|
47
|
-
} else
|
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,
|
53
|
-
const l =
|
54
|
-
i(
|
55
|
-
|
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
|
-
|
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(
|
62
|
+
return i(o.current, e);
|
63
63
|
}
|
64
|
-
})), /* @__PURE__ */
|
64
|
+
})), /* @__PURE__ */ p(
|
65
65
|
I,
|
66
66
|
{
|
67
|
-
...
|
67
|
+
...m,
|
68
68
|
component: "iframe",
|
69
|
-
ref:
|
69
|
+
ref: o,
|
70
70
|
onLoad: l,
|
71
|
-
"data-id":
|
72
|
-
src:
|
73
|
-
sx:
|
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
|
-
|
84
|
+
f
|
85
85
|
)
|
86
86
|
}
|
87
87
|
);
|
package/lib/Theme/index.js
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
import { styled as
|
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
|
4
|
-
import { ColorSchemeContext as
|
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 = (
|
7
|
-
...
|
8
|
-
shouldForwardProp: (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
|
-
|
12
|
-
|
11
|
+
y as ColorSchemeContext,
|
12
|
+
C as ThemeProvider,
|
13
13
|
c as collectFontFamilies,
|
14
14
|
f as create,
|
15
|
-
|
16
|
-
|
15
|
+
i as createDefaultThemeOptions,
|
16
|
+
n as createTheme,
|
17
17
|
S as deepmerge,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
};
|
package/lib/Theme/theme.js
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
import { createTheme as
|
2
|
-
import { deepmerge as
|
3
|
-
import { deepmerge as
|
4
|
-
import
|
5
|
-
import { DEFAULT_FONTS as
|
6
|
-
import { deepmergeAll as
|
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
|
13
|
+
function E(e) {
|
14
14
|
return e && typeof e == "object" && e.palette && typeof e.palette.getContrastText == "function";
|
15
15
|
}
|
16
|
-
function
|
17
|
-
return
|
16
|
+
function W(e) {
|
17
|
+
return E(e) && e.__isUxTheme__ === !0;
|
18
18
|
}
|
19
|
-
function
|
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" &&
|
21
|
+
typeof o == "object" && h(o, t);
|
22
22
|
})), t;
|
23
23
|
}
|
24
|
-
const s = new Set(
|
25
|
-
function
|
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
|
-
|
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
|
45
|
-
return e === "dark" ?
|
44
|
+
function u(e = "light") {
|
45
|
+
return e === "dark" ? k : x;
|
46
46
|
}
|
47
|
-
function
|
47
|
+
function w(e) {
|
48
48
|
let t = null;
|
49
49
|
return () => {
|
50
50
|
if (t) return t;
|
51
|
-
const o =
|
52
|
-
return t =
|
51
|
+
const o = f(u(e), d(e));
|
52
|
+
return t = p(o), t;
|
53
53
|
};
|
54
54
|
}
|
55
|
-
const
|
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
|
-
}),
|
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
|
-
},
|
89
|
-
|
90
|
-
|
91
|
-
(
|
92
|
-
|
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
|
-
|
96
|
-
!
|
97
|
-
|
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 =
|
103
|
+
), a = p(g);
|
105
104
|
a.__isUxTheme__ = !0;
|
106
|
-
const
|
107
|
-
return
|
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
|
-
},
|
126
|
+
}, q = L;
|
128
127
|
export {
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
};
|
package/lib/Toast/index.js
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { createRef as
|
3
|
-
import { SnackbarProvider as
|
4
|
-
import { IconButton as
|
5
|
-
import { Close as
|
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
|
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
|
14
|
-
const n =
|
15
|
-
|
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__ */
|
19
|
-
|
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(
|
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(
|
29
|
+
/* @__PURE__ */ s(v, {}),
|
31
30
|
o
|
32
31
|
]
|
33
32
|
}
|
34
33
|
);
|
35
34
|
}
|
36
|
-
function
|
37
|
-
const { enqueueSnackbar: o, closeSnackbar: r } =
|
38
|
-
return
|
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
|
41
|
-
success: (o, r = {}) =>
|
42
|
-
error: (o, r = { autoHideDuration: 15e3 }) =>
|
43
|
-
warning: (o, r = {}) =>
|
44
|
-
info: (o, r = {}) =>
|
45
|
-
close: (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
|
-
|
49
|
-
|
47
|
+
j as ToastProvider,
|
48
|
+
H as default
|
50
49
|
};
|
package/lib/Typography/index.js
CHANGED
@@ -1,82 +1,82 @@
|
|
1
|
-
import { jsxs as g, jsx as
|
2
|
-
import { Box as x, Typography as
|
3
|
-
import { useReactive as
|
4
|
-
import
|
5
|
-
import { useRef as
|
6
|
-
let
|
7
|
-
function
|
8
|
-
const
|
9
|
-
Object.assign(
|
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
|
-
}),
|
14
|
-
const
|
15
|
-
return document.body.removeChild(
|
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
|
18
|
-
children:
|
19
|
-
minFontSize:
|
17
|
+
function E({
|
18
|
+
children: i = null,
|
19
|
+
minFontSize: r = 12,
|
20
20
|
/* 设置为 auto 时字体会自动收缩,直到达到浏览器最小字体限制 */
|
21
|
-
fontSize:
|
22
|
-
sx:
|
23
|
-
onShrink:
|
24
|
-
...
|
21
|
+
fontSize: t = void 0,
|
22
|
+
sx: a,
|
23
|
+
onShrink: p = C,
|
24
|
+
...l
|
25
25
|
}) {
|
26
|
-
const
|
26
|
+
const f = c(null), S = c(null), e = h({
|
27
27
|
// @ts-expect-error
|
28
|
-
fontSize:
|
28
|
+
fontSize: t,
|
29
29
|
loading: !0
|
30
|
-
}), o =
|
31
|
-
return
|
30
|
+
}), o = z(f.current), s = z(S.current);
|
31
|
+
return b(() => {
|
32
32
|
if (e.loading)
|
33
|
-
if (
|
33
|
+
if (t === "auto") {
|
34
34
|
if (o && !e.initialSize) {
|
35
|
-
const
|
36
|
-
e.initialSize = Number(
|
35
|
+
const m = getComputedStyle(f.current).fontSize;
|
36
|
+
e.initialSize = Number(m.replace("px", "")), e.fontSize = e.initialSize;
|
37
37
|
}
|
38
|
-
|
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
|
-
}, [
|
41
|
+
}, [t, o?.width, s?.width]), v(() => t === "auto" ? e.loading : !1, [t, e.loading]) ? /* @__PURE__ */ g(
|
42
42
|
x,
|
43
43
|
{
|
44
|
-
ref:
|
44
|
+
ref: S,
|
45
45
|
sx: {
|
46
46
|
flex: 1
|
47
47
|
},
|
48
48
|
children: [
|
49
|
-
/* @__PURE__ */
|
50
|
-
/* @__PURE__ */
|
51
|
-
|
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:
|
54
|
-
...
|
53
|
+
ref: f,
|
54
|
+
...l,
|
55
55
|
sx: {
|
56
|
-
...
|
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:
|
63
|
+
children: i
|
64
64
|
}
|
65
65
|
)
|
66
66
|
]
|
67
67
|
}
|
68
|
-
) : /* @__PURE__ */
|
69
|
-
|
68
|
+
) : /* @__PURE__ */ n(
|
69
|
+
d,
|
70
70
|
{
|
71
|
-
...
|
71
|
+
...l,
|
72
72
|
sx: {
|
73
|
-
...
|
73
|
+
...a,
|
74
74
|
...e.fontSize ? { fontSize: `${e.fontSize}px !important` } : {}
|
75
75
|
},
|
76
|
-
children:
|
76
|
+
children: i
|
77
77
|
}
|
78
78
|
);
|
79
79
|
}
|
80
80
|
export {
|
81
|
-
|
81
|
+
E as default
|
82
82
|
};
|