@blocklet/ui-react 3.2.16 → 3.2.18
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/Dashboard/app-shell/app-badge.d.ts +24 -0
- package/lib/Dashboard/app-shell/app-badge.js +48 -0
- package/lib/Dashboard/app-shell/app-header.d.ts +5 -0
- package/lib/Dashboard/app-shell/app-header.js +64 -0
- package/lib/Dashboard/app-shell/app-info-context.d.ts +38 -0
- package/lib/Dashboard/app-shell/app-info-context.js +69 -0
- package/lib/Dashboard/app-shell/badges/app-badge-default.d.ts +20 -0
- package/lib/Dashboard/app-shell/badges/app-badge-default.js +84 -0
- package/lib/Dashboard/app-shell/badges/app-badge-did.d.ts +5 -0
- package/lib/Dashboard/app-shell/badges/app-badge-did.js +16 -0
- package/lib/Dashboard/app-shell/badges/app-badge-state.d.ts +6 -0
- package/lib/Dashboard/app-shell/badges/app-badge-state.js +34 -0
- package/lib/Dashboard/app-shell/badges/app-badge-switch.d.ts +8 -0
- package/lib/Dashboard/app-shell/badges/app-badge-switch.js +66 -0
- package/lib/Dashboard/app-shell/badges/app-badge-version.d.ts +14 -0
- package/lib/Dashboard/app-shell/badges/app-badge-version.js +50 -0
- package/lib/Dashboard/app-shell/index.d.ts +4 -0
- package/lib/Dashboard/app-shell/index.js +9 -0
- package/lib/Dashboard/index.d.ts +11 -1
- package/lib/Dashboard/index.js +82 -62
- package/lib/Footer/internal-footer.js +11 -11
- package/lib/Footer/links.d.ts +5 -3
- package/lib/Footer/links.js +63 -61
- package/lib/utils.js +28 -28
- package/package.json +12 -6
- package/src/Dashboard/app-shell/app-badge.stories.tsx +64 -0
- package/src/Dashboard/app-shell/app-badge.tsx +94 -0
- package/src/Dashboard/app-shell/app-header.tsx +91 -0
- package/src/Dashboard/app-shell/app-info-context.tsx +157 -0
- package/src/Dashboard/app-shell/badges/app-badge-default.tsx +131 -0
- package/src/Dashboard/app-shell/badges/app-badge-did.tsx +28 -0
- package/src/Dashboard/app-shell/badges/app-badge-state.tsx +40 -0
- package/src/Dashboard/app-shell/badges/app-badge-switch.tsx +72 -0
- package/src/Dashboard/app-shell/badges/app-badge-version.tsx +60 -0
- package/src/Dashboard/app-shell/index.ts +5 -0
- package/src/Dashboard/index.jsx +16 -2
- package/src/Footer/internal-footer.jsx +1 -1
- package/src/Footer/links.jsx +11 -7
- package/src/utils.js +6 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppBadgeDefaultProps } from './badges/app-badge-default';
|
|
2
|
+
import { AppBadgeSwitchProps } from './badges/app-badge-switch';
|
|
3
|
+
import { AppBadgeVersionProps } from './badges/app-badge-version';
|
|
4
|
+
import { AppBadgeStateProps } from './badges/app-badge-state';
|
|
5
|
+
import { AppBadgeDIDProps } from './badges/app-badge-did';
|
|
6
|
+
export declare const formatNumber: (num: unknown, round?: number) => string;
|
|
7
|
+
export declare const formatTime: (value?: string | number | Date, locale?: string) => string;
|
|
8
|
+
export type AppBadgeProps = (AppBadgeDefaultProps & {
|
|
9
|
+
variant?: 'default';
|
|
10
|
+
}) | (AppBadgeDefaultProps & {
|
|
11
|
+
variant: 'number';
|
|
12
|
+
}) | (Omit<AppBadgeDefaultProps, 'value'> & {
|
|
13
|
+
variant: 'time';
|
|
14
|
+
value?: string | number | Date;
|
|
15
|
+
}) | (AppBadgeSwitchProps & {
|
|
16
|
+
variant: 'switch';
|
|
17
|
+
}) | (AppBadgeVersionProps & {
|
|
18
|
+
variant: 'version';
|
|
19
|
+
}) | (AppBadgeStateProps & {
|
|
20
|
+
variant: 'state';
|
|
21
|
+
}) | (AppBadgeDIDProps & {
|
|
22
|
+
variant: 'did';
|
|
23
|
+
});
|
|
24
|
+
export default function AppBadge(props: AppBadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import f from "dayjs";
|
|
3
|
+
import l from "dayjs/plugin/relativeTime";
|
|
4
|
+
import s from "dayjs/plugin/localizedFormat";
|
|
5
|
+
import "dayjs/locale/zh";
|
|
6
|
+
import "dayjs/locale/zh-tw";
|
|
7
|
+
import "dayjs/locale/ja";
|
|
8
|
+
import { useLocaleContext as c } from "@arcblock/ux/lib/Locale/context";
|
|
9
|
+
import { AppBadgeDefault as m } from "./badges/app-badge-default.js";
|
|
10
|
+
import { AppBadgeSwitch as d } from "./badges/app-badge-switch.js";
|
|
11
|
+
import { AppBadgeVersion as p } from "./badges/app-badge-version.js";
|
|
12
|
+
import { AppBadgeState as u } from "./badges/app-badge-state.js";
|
|
13
|
+
import { AppBadgeDID as v } from "./badges/app-badge-did.js";
|
|
14
|
+
f.extend(l);
|
|
15
|
+
f.extend(s);
|
|
16
|
+
const g = (e, i = 0) => {
|
|
17
|
+
if (typeof e != "number") return "";
|
|
18
|
+
const r = Math.abs(e);
|
|
19
|
+
let t, o = "";
|
|
20
|
+
return r >= 1e12 ? (o = "T", t = `${(e / 1e12).toFixed(i)}`) : r >= 1e9 ? (o = "B", t = `${(e / 1e9).toFixed(i)}`) : r >= 1e6 ? (o = "M", t = `${(e / 1e6).toFixed(i)}`) : r >= 1e3 ? (o = "K", t = `${(e / 1e3).toFixed(i)}`) : t = e.toString(), i > 0 && (t = t.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "")), `${t}${o}`;
|
|
21
|
+
}, x = (e, i = "en") => e ? f(e).locale(i).fromNow() : "", B = {
|
|
22
|
+
switch: d,
|
|
23
|
+
version: p,
|
|
24
|
+
state: u,
|
|
25
|
+
did: v
|
|
26
|
+
};
|
|
27
|
+
function V(e) {
|
|
28
|
+
const { locale: i = "en" } = c() || {};
|
|
29
|
+
if (e.variant === "number") {
|
|
30
|
+
const { value: r, round: t = 0, ...o } = e, n = g(Number(r), t);
|
|
31
|
+
return /* @__PURE__ */ a(m, { value: n, ...o });
|
|
32
|
+
}
|
|
33
|
+
if (e.variant === "time") {
|
|
34
|
+
const { value: r, ...t } = e, o = x(r, i);
|
|
35
|
+
return /* @__PURE__ */ a(m, { value: o, ...t });
|
|
36
|
+
}
|
|
37
|
+
if (e.variant) {
|
|
38
|
+
const r = B[e.variant];
|
|
39
|
+
if (r)
|
|
40
|
+
return /* @__PURE__ */ a(r, { ...e });
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ a(m, { ...e });
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
V as default,
|
|
46
|
+
g as formatNumber,
|
|
47
|
+
x as formatTime
|
|
48
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs as s, jsx as e, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as g } from "react";
|
|
3
|
+
import { Box as t, Stack as y, Typography as p, useMediaQuery as v } from "@mui/material";
|
|
4
|
+
import M from "@arcblock/ux/lib/Tabs";
|
|
5
|
+
import B from "./app-badge.js";
|
|
6
|
+
import { useAppInfo as I } from "./app-info-context.js";
|
|
7
|
+
function h() {
|
|
8
|
+
return v((r) => r.breakpoints.down("md"));
|
|
9
|
+
}
|
|
10
|
+
function x({ sx: i = {} }) {
|
|
11
|
+
const r = h();
|
|
12
|
+
return /* @__PURE__ */ e(t, { sx: { mx: r ? -2 : -3, borderBottom: "1px solid", borderColor: "divider", mt: 1.5, mb: 1, ...i } });
|
|
13
|
+
}
|
|
14
|
+
function H({ onTabChange: i = void 0 }) {
|
|
15
|
+
const r = h(), {
|
|
16
|
+
icon: a = void 0,
|
|
17
|
+
name: d = "",
|
|
18
|
+
description: m = void 0,
|
|
19
|
+
actions: n = void 0,
|
|
20
|
+
badges: c = [],
|
|
21
|
+
tabs: l = [],
|
|
22
|
+
currentTab: u = ""
|
|
23
|
+
} = I();
|
|
24
|
+
return d ? /* @__PURE__ */ s(t, { className: "app-header", sx: { mt: 3, mb: 3 }, children: [
|
|
25
|
+
/* @__PURE__ */ s(
|
|
26
|
+
t,
|
|
27
|
+
{
|
|
28
|
+
sx: {
|
|
29
|
+
display: "flex",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
gap: 1
|
|
32
|
+
},
|
|
33
|
+
children: [
|
|
34
|
+
a && /* @__PURE__ */ e(t, { sx: { display: "flex", alignItems: "center", justifyContent: "center" }, children: a }),
|
|
35
|
+
/* @__PURE__ */ s(y, { sx: { flexGrow: 1 }, children: [
|
|
36
|
+
/* @__PURE__ */ e(p, { variant: "h1", sx: { mb: 0.5 }, children: d }),
|
|
37
|
+
m && /* @__PURE__ */ e(
|
|
38
|
+
p,
|
|
39
|
+
{
|
|
40
|
+
variant: "body2",
|
|
41
|
+
color: "text.secondary",
|
|
42
|
+
sx: { lineHeight: 1.6, "& a": { color: "primary.main" }, maxWidth: 980 },
|
|
43
|
+
children: m
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] }),
|
|
47
|
+
!r && n && /* @__PURE__ */ e(t, { sx: { ml: 1 }, children: n })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
c.length > 0 && /* @__PURE__ */ e(t, { sx: { display: "flex", flexWrap: "wrap", gap: 1, alignItems: "center", mt: 2 }, children: c.map(
|
|
52
|
+
(o, b) => g(o) ? o : /* @__PURE__ */ e(B, { ...o }, o.label || b)
|
|
53
|
+
) }),
|
|
54
|
+
r && n && /* @__PURE__ */ e(t, { sx: { mt: r ? 2 : 0 }, children: n }),
|
|
55
|
+
l.length <= 1 && /* @__PURE__ */ e(x, {}),
|
|
56
|
+
l.length > 1 && /* @__PURE__ */ s(f, { children: [
|
|
57
|
+
/* @__PURE__ */ e(M, { tabs: l, current: u, onChange: i, scrollButtons: "auto", sx: { mt: 2.5 } }),
|
|
58
|
+
/* @__PURE__ */ e(x, { sx: { mt: 0 } })
|
|
59
|
+
] })
|
|
60
|
+
] }) : null;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
H as default
|
|
64
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AppBadgeProps } from './app-badge';
|
|
3
|
+
export type NavItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
parent: string;
|
|
6
|
+
title: string;
|
|
7
|
+
link: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface TabConfig {
|
|
11
|
+
value: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
render?: React.ComponentType | React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface AppInfo {
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
name?: React.ReactNode;
|
|
18
|
+
description?: React.ReactNode;
|
|
19
|
+
badges?: Array<AppBadgeProps | React.ReactElement>;
|
|
20
|
+
actions?: React.ReactNode;
|
|
21
|
+
tabs?: TabConfig[];
|
|
22
|
+
currentTab?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AppInfoContextValue extends AppInfo {
|
|
25
|
+
currentTab: string;
|
|
26
|
+
TabComponent: React.ComponentType | React.ReactNode;
|
|
27
|
+
navItem?: NavItem;
|
|
28
|
+
updateAppInfo: (patch: Partial<AppInfo>) => void;
|
|
29
|
+
}
|
|
30
|
+
interface AppInfoProviderProps {
|
|
31
|
+
path?: string;
|
|
32
|
+
currentTab?: string;
|
|
33
|
+
meta?: object;
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
export declare function AppInfoProvider({ path, currentTab, meta, children, }: AppInfoProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function useAppInfo(): AppInfoContextValue;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as h, useState as L, useMemo as T, useEffect as w, useContext as M } from "react";
|
|
3
|
+
import { useCreation as A, useMemoizedFn as O } from "ahooks";
|
|
4
|
+
import { withoutTrailingSlash as P } from "ufo";
|
|
5
|
+
import W from "lodash/isPlainObject";
|
|
6
|
+
import { WELLKNOWN_BLOCKLET_ADMIN_PATH as j } from "@abtnode/constant";
|
|
7
|
+
import { useLocaleContext as E } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
const C = h({
|
|
9
|
+
currentTab: "",
|
|
10
|
+
TabComponent: null,
|
|
11
|
+
navItem: void 0,
|
|
12
|
+
updateAppInfo: () => {
|
|
13
|
+
}
|
|
14
|
+
}), u = (s, a, d = "en") => {
|
|
15
|
+
const o = s?.[a];
|
|
16
|
+
return W(o) ? o[d] || o.en : o;
|
|
17
|
+
};
|
|
18
|
+
function D({
|
|
19
|
+
path: s = window?.location?.pathname || "",
|
|
20
|
+
currentTab: a = "",
|
|
21
|
+
meta: d = void 0,
|
|
22
|
+
children: o = null
|
|
23
|
+
}) {
|
|
24
|
+
const { locale: i = "en" } = E() || {}, I = P(s), f = I.startsWith(j), b = A(() => Object.assign({}, window.blocklet, d), [d]), r = A(() => {
|
|
25
|
+
const n = b.navigation?.filter(
|
|
26
|
+
(e) => Array.isArray(e.section) ? e.section.includes("dashboard") : e.section === "dashboard"
|
|
27
|
+
), t = n?.flatMap((e) => e.items || [])?.find((e) => (u(e, "link", i) || "").startsWith(I));
|
|
28
|
+
if (!t)
|
|
29
|
+
return;
|
|
30
|
+
const l = n.find((e) => e.id === t.parent);
|
|
31
|
+
let p = u(t, "title", i) || "";
|
|
32
|
+
return f || (p = `${u(l, "title", i) || ""} - ${p}`), {
|
|
33
|
+
id: t.id,
|
|
34
|
+
parent: t.parent,
|
|
35
|
+
title: p,
|
|
36
|
+
link: u(t, "link", i) || "",
|
|
37
|
+
description: u(t, "description", i) || ""
|
|
38
|
+
};
|
|
39
|
+
}, [s, f, i, b]), [v, g] = L({}), m = O((n) => {
|
|
40
|
+
g((c) => ({ ...c, ...n }));
|
|
41
|
+
}), k = T(
|
|
42
|
+
() => {
|
|
43
|
+
const { tabs: n = [] } = v, c = n.find((p) => p.value === a);
|
|
44
|
+
let t = a, l = null;
|
|
45
|
+
return !c && n.length > 0 ? (t = n[0].value, l = n[0].render || null) : l = c?.render || null, {
|
|
46
|
+
...v,
|
|
47
|
+
navItem: r,
|
|
48
|
+
currentTab: t,
|
|
49
|
+
TabComponent: l,
|
|
50
|
+
updateAppInfo: m
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
[v, r, a, m]
|
|
55
|
+
);
|
|
56
|
+
return w(() => {
|
|
57
|
+
f || m({
|
|
58
|
+
name: r?.title || "",
|
|
59
|
+
description: r?.description || ""
|
|
60
|
+
});
|
|
61
|
+
}, [r?.title, r?.description, f, m]), /* @__PURE__ */ x(C.Provider, { value: k, children: o });
|
|
62
|
+
}
|
|
63
|
+
function F() {
|
|
64
|
+
return M(C);
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
D as AppInfoProvider,
|
|
68
|
+
F as useAppInfo
|
|
69
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TBox } from '@arcblock/ux/lib/MuiWrap';
|
|
2
|
+
import { BoxProps } from '@mui/material/Box';
|
|
3
|
+
export declare const isExternal: (to?: string) => boolean;
|
|
4
|
+
export declare const isSameOrigin: (to: string) => boolean;
|
|
5
|
+
export declare const StateIcon: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & {
|
|
6
|
+
color: string;
|
|
7
|
+
}, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
8
|
+
export declare const StyledBadge: typeof TBox;
|
|
9
|
+
export interface BadgeContainerProps extends Omit<BoxProps, 'to'> {
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
to?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function BadgeContainer({ loading, children, to, ...rest }: BadgeContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export interface AppBadgeDefaultProps extends BadgeContainerProps {
|
|
15
|
+
icon?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
value?: string | number;
|
|
18
|
+
round?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function AppBadgeDefault({ icon, label, value, loading, ...rest }: AppBadgeDefaultProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsxs as p, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { styled as l, Box as g, Typography as s, Skeleton as c } from "@mui/material";
|
|
3
|
+
import { Icon as f } from "@iconify/react";
|
|
4
|
+
import { Link as u } from "react-router-dom";
|
|
5
|
+
const b = (a = "") => a.startsWith("http:") || a.startsWith("https:"), y = (a) => {
|
|
6
|
+
try {
|
|
7
|
+
return new URL(a).origin === window.location.origin;
|
|
8
|
+
} catch {
|
|
9
|
+
return !1;
|
|
10
|
+
}
|
|
11
|
+
}, S = l("span")(({ theme: a, color: n }) => ({
|
|
12
|
+
position: "relative",
|
|
13
|
+
display: "inline-block",
|
|
14
|
+
width: a.spacing(1),
|
|
15
|
+
height: a.spacing(1),
|
|
16
|
+
borderRadius: "50%",
|
|
17
|
+
backgroundColor: n,
|
|
18
|
+
marginRight: a.spacing(1)
|
|
19
|
+
})), o = l(g)(({ theme: a }) => ({
|
|
20
|
+
position: "relative",
|
|
21
|
+
display: "inline-flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
height: a.spacing(3),
|
|
24
|
+
paddingLeft: a.spacing(1.5),
|
|
25
|
+
paddingRight: a.spacing(1.5),
|
|
26
|
+
border: "1px solid",
|
|
27
|
+
borderColor: a.palette.divider,
|
|
28
|
+
borderRadius: a.shape.borderRadius * 0.5,
|
|
29
|
+
fontSize: 12,
|
|
30
|
+
overflow: "hidden",
|
|
31
|
+
"& .app-badge-label": {
|
|
32
|
+
display: "inline-flex",
|
|
33
|
+
gap: a.spacing(1),
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
lineHeight: a.spacing(3),
|
|
36
|
+
marginLeft: a.spacing(-1.5),
|
|
37
|
+
paddingLeft: a.spacing(1.5),
|
|
38
|
+
marginRight: a.spacing(1),
|
|
39
|
+
fontSize: 12,
|
|
40
|
+
backgroundColor: a.palette.grey[100],
|
|
41
|
+
color: a.palette.text.secondary,
|
|
42
|
+
"&::after": {
|
|
43
|
+
content: '""',
|
|
44
|
+
height: a.spacing(3),
|
|
45
|
+
borderRight: "1px solid",
|
|
46
|
+
borderColor: a.palette.divider,
|
|
47
|
+
backgroundColor: a.palette.grey[100]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"& .app-badge-value": {
|
|
51
|
+
color: a.palette.text.primary,
|
|
52
|
+
fontSize: 12
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
function x({ loading: a = !1, children: n = null, to: r = "", ...e }) {
|
|
56
|
+
const t = /* @__PURE__ */ i(o, { className: "app-badge", component: r ? "a" : "div", href: r, ...e, children: n });
|
|
57
|
+
if (a)
|
|
58
|
+
return /* @__PURE__ */ i(c, { variant: "rounded", children: t });
|
|
59
|
+
if (r) {
|
|
60
|
+
if (b(r)) {
|
|
61
|
+
const d = y(r) ? "_self" : "_blank";
|
|
62
|
+
return /* @__PURE__ */ i(o, { className: "app-badge", component: "a", href: r, target: d, rel: "noreferrer noopener", ...e, children: n });
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ i(o, { className: "app-badge", component: u, to: r, ...e, children: n });
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ i(o, { className: "app-badge", component: "div", ...e, children: n });
|
|
67
|
+
}
|
|
68
|
+
function h({ icon: a = "", label: n = "", value: r = "", loading: e = !1, ...t }) {
|
|
69
|
+
return /* @__PURE__ */ p(x, { loading: e, ...t, children: [
|
|
70
|
+
n && /* @__PURE__ */ p(s, { className: "app-badge-label", children: [
|
|
71
|
+
a && /* @__PURE__ */ i(f, { icon: a }),
|
|
72
|
+
n
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ i(s, { className: "app-badge-value", children: r })
|
|
75
|
+
] });
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
h as AppBadgeDefault,
|
|
79
|
+
x as BadgeContainer,
|
|
80
|
+
S as StateIcon,
|
|
81
|
+
o as StyledBadge,
|
|
82
|
+
b as isExternal,
|
|
83
|
+
y as isSameOrigin
|
|
84
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AppBadgeDefaultProps } from './app-badge-default';
|
|
2
|
+
export interface AppBadgeDIDProps extends Omit<AppBadgeDefaultProps, 'value'> {
|
|
3
|
+
value?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function AppBadgeDID({ value, loading, ...rest }: AppBadgeDIDProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useCreation as p } from "ahooks";
|
|
3
|
+
import { Typography as i } from "@mui/material";
|
|
4
|
+
import { isEthereumDid as m } from "@arcblock/ux/lib/Util";
|
|
5
|
+
import n from "@arcblock/ux/lib/Address";
|
|
6
|
+
import { BadgeContainer as d } from "./app-badge-default.js";
|
|
7
|
+
function b({ value: r = "", loading: o = !1, ...s }) {
|
|
8
|
+
const t = p(() => `DID:${m(r) ? "ETH" : "ABT"}`, [r]);
|
|
9
|
+
return /* @__PURE__ */ a(d, { loading: o, ...s, children: [
|
|
10
|
+
/* @__PURE__ */ e(i, { className: "app-badge-label", children: t }),
|
|
11
|
+
/* @__PURE__ */ e(i, { className: "app-badge-value", children: /* @__PURE__ */ e(n, { inline: !0, size: 14, compact: !0, responsive: !1, children: r }) })
|
|
12
|
+
] });
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
b as AppBadgeDID
|
|
16
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AppBadgeDefaultProps } from './app-badge-default';
|
|
2
|
+
import { BadgeColor } from './app-badge-version';
|
|
3
|
+
export interface AppBadgeStateProps extends AppBadgeDefaultProps {
|
|
4
|
+
color?: BadgeColor;
|
|
5
|
+
}
|
|
6
|
+
export declare function AppBadgeState({ value, color, loading, ...rest }: AppBadgeStateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsxs as l, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { styled as c, useTheme as g, alpha as d, Typography as m } from "@mui/material";
|
|
3
|
+
import { BadgeContainer as h } from "./app-badge-default.js";
|
|
4
|
+
import { getTextColor as i, getBgColor as u } from "./app-badge-version.js";
|
|
5
|
+
const b = c("span")(({ theme: o, color: r }) => ({
|
|
6
|
+
position: "relative",
|
|
7
|
+
display: "inline-block",
|
|
8
|
+
width: o.spacing(1),
|
|
9
|
+
height: o.spacing(1),
|
|
10
|
+
borderRadius: "50%",
|
|
11
|
+
backgroundColor: r,
|
|
12
|
+
marginRight: o.spacing(1)
|
|
13
|
+
}));
|
|
14
|
+
function B({ value: o = "", color: r = "primary", loading: n = !1, ...s }) {
|
|
15
|
+
const t = g(), e = i(t, r), p = u(t, r);
|
|
16
|
+
return /* @__PURE__ */ l(
|
|
17
|
+
h,
|
|
18
|
+
{
|
|
19
|
+
loading: n,
|
|
20
|
+
sx: {
|
|
21
|
+
borderColor: d(e, 0.2),
|
|
22
|
+
bgcolor: p
|
|
23
|
+
},
|
|
24
|
+
...s,
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ a(b, { color: i(t, r) }),
|
|
27
|
+
/* @__PURE__ */ a(m, { className: "app-badge-value", style: { color: e }, children: o })
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
B as AppBadgeState
|
|
34
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppBadgeDefaultProps } from './app-badge-default';
|
|
2
|
+
export interface AppBadgeSwitchProps extends Omit<AppBadgeDefaultProps, 'value' | 'onChange'> {
|
|
3
|
+
value?: unknown;
|
|
4
|
+
trueValue?: unknown;
|
|
5
|
+
falseValue?: unknown;
|
|
6
|
+
onChange?: (checked: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function AppBadgeSwitch({ label, value, trueValue, falseValue, loading, onChange, ...rest }: AppBadgeSwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsxs as l, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme as m, Typography as g, Box as h } from "@mui/material";
|
|
3
|
+
import { useMemoizedFn as f } from "ahooks";
|
|
4
|
+
import { BadgeContainer as u } from "./app-badge-default.js";
|
|
5
|
+
function C({
|
|
6
|
+
label: n = "",
|
|
7
|
+
value: r = void 0,
|
|
8
|
+
trueValue: s = !0,
|
|
9
|
+
falseValue: t = !1,
|
|
10
|
+
loading: a = !1,
|
|
11
|
+
onChange: c = void 0,
|
|
12
|
+
...d
|
|
13
|
+
}) {
|
|
14
|
+
const e = m();
|
|
15
|
+
let o = !1;
|
|
16
|
+
const p = f(() => c?.(!o));
|
|
17
|
+
return r === s ? o = !0 : r === t ? o = !1 : o = !!r, /* @__PURE__ */ l(
|
|
18
|
+
u,
|
|
19
|
+
{
|
|
20
|
+
loading: a,
|
|
21
|
+
sx: {
|
|
22
|
+
cursor: "pointer",
|
|
23
|
+
backgroundColor: o ? "primary.main" : "grey.100",
|
|
24
|
+
borderColor: o ? "primary.main" : "divider",
|
|
25
|
+
transition: "background-color 0.3s ease"
|
|
26
|
+
},
|
|
27
|
+
onClick: p,
|
|
28
|
+
...d,
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ i(
|
|
31
|
+
g,
|
|
32
|
+
{
|
|
33
|
+
sx: {
|
|
34
|
+
fontWeight: 400,
|
|
35
|
+
paddingLeft: o ? 0 : e.spacing(2.5),
|
|
36
|
+
paddingRight: o ? e.spacing(2.5) : 0,
|
|
37
|
+
color: o ? "common.white" : "text.secondary",
|
|
38
|
+
transition: "color 0.3s ease"
|
|
39
|
+
},
|
|
40
|
+
children: n
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ i(
|
|
44
|
+
h,
|
|
45
|
+
{
|
|
46
|
+
sx: {
|
|
47
|
+
width: e.spacing(2.5),
|
|
48
|
+
height: e.spacing(2.5),
|
|
49
|
+
borderRadius: `${e.shape.borderRadius * 0.5}px`,
|
|
50
|
+
backgroundColor: "common.white",
|
|
51
|
+
position: "absolute",
|
|
52
|
+
top: "50%",
|
|
53
|
+
left: o ? `calc(100% - ${e.spacing(3)})` : e.spacing(0.5),
|
|
54
|
+
transform: "translateY(-50%)",
|
|
55
|
+
transition: "left 0.3s ease",
|
|
56
|
+
boxShadow: 1
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
C as AppBadgeSwitch
|
|
66
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
|
+
import { AppBadgeDefaultProps } from './app-badge-default';
|
|
4
|
+
export type ColorKey = 'primary' | 'info' | 'success' | 'error' | 'warning';
|
|
5
|
+
export type BadgeColor = LiteralUnion<ColorKey, string>;
|
|
6
|
+
export declare const colorMap: Record<ColorKey, (theme: Theme) => {
|
|
7
|
+
main: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const getBgColor: (theme: Theme, color: BadgeColor) => string;
|
|
10
|
+
export declare const getTextColor: (theme: Theme, color: BadgeColor) => string;
|
|
11
|
+
export interface AppBadgeVersionProps extends AppBadgeDefaultProps {
|
|
12
|
+
color?: string | ColorKey;
|
|
13
|
+
}
|
|
14
|
+
export declare function AppBadgeVersion({ icon, value, color, loading, ...rest }: AppBadgeVersionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsxs as s, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme as g, alpha as n, Typography as f } from "@mui/material";
|
|
3
|
+
import { Icon as u } from "@iconify/react";
|
|
4
|
+
import { BadgeContainer as d } from "./app-badge-default.js";
|
|
5
|
+
const o = {
|
|
6
|
+
primary: (e) => e.palette.primary,
|
|
7
|
+
info: (e) => e.palette.info,
|
|
8
|
+
success: (e) => e.palette.success,
|
|
9
|
+
error: (e) => e.palette.error,
|
|
10
|
+
warning: (e) => e.palette.warning
|
|
11
|
+
}, h = (e, r) => {
|
|
12
|
+
if (o[r]) {
|
|
13
|
+
const t = o[r](e).main;
|
|
14
|
+
return n(t, 0.1);
|
|
15
|
+
}
|
|
16
|
+
return n(r, 0.1);
|
|
17
|
+
}, x = (e, r) => o[r] ? o[r](e).main : r;
|
|
18
|
+
function T({
|
|
19
|
+
icon: e = "",
|
|
20
|
+
value: r = "",
|
|
21
|
+
color: t = "info",
|
|
22
|
+
loading: p = !1,
|
|
23
|
+
...c
|
|
24
|
+
}) {
|
|
25
|
+
const a = g(), i = x(a, t), l = h(a, t);
|
|
26
|
+
return /* @__PURE__ */ s(
|
|
27
|
+
d,
|
|
28
|
+
{
|
|
29
|
+
loading: p,
|
|
30
|
+
sx: {
|
|
31
|
+
borderColor: n(i, 0.2),
|
|
32
|
+
bgcolor: l
|
|
33
|
+
},
|
|
34
|
+
...c,
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ m(u, { icon: e || "lucide:orbit", style: { marginRight: 6 } }),
|
|
37
|
+
/* @__PURE__ */ s(f, { className: "app-badge-value", style: { color: i }, children: [
|
|
38
|
+
"v ",
|
|
39
|
+
r
|
|
40
|
+
] })
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
T as AppBadgeVersion,
|
|
47
|
+
o as colorMap,
|
|
48
|
+
h as getBgColor,
|
|
49
|
+
x as getTextColor
|
|
50
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as o } from "./app-header.js";
|
|
2
|
+
import { default as f } from "./app-badge.js";
|
|
3
|
+
import { AppInfoProvider as d, useAppInfo as t } from "./app-info-context.js";
|
|
4
|
+
export {
|
|
5
|
+
f as AppBadge,
|
|
6
|
+
o as AppHeader,
|
|
7
|
+
d as AppInfoProvider,
|
|
8
|
+
t as useAppInfo
|
|
9
|
+
};
|
package/lib/Dashboard/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { AppHeader, AppBadge, AppInfoProvider, useAppInfo } from './app-shell';
|
|
1
2
|
import { BlockletMetaProps, SessionManagerProps } from '../types';
|
|
2
3
|
import { default as PropTypes } from 'prop-types';
|
|
3
4
|
export default Dashboard;
|
|
4
5
|
/**
|
|
5
6
|
* 专门用于 (composable) blocklet 的 Dashboard 组件, 解析 blocklet meta 中 section 为 dashboard 的 navigation 数据, 渲染一个 UX Dashboard
|
|
6
7
|
*/
|
|
7
|
-
declare function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessionManagerProps, links, showDomainWarningDialog, ...rest }: {
|
|
8
|
+
declare function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessionManagerProps, links, showDomainWarningDialog, appPath, appTab, onAppTabChange, children, ...rest }: {
|
|
8
9
|
[x: string]: any;
|
|
9
10
|
meta?: {} | undefined;
|
|
10
11
|
fallbackUrl?: any;
|
|
@@ -16,6 +17,10 @@ declare function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddon
|
|
|
16
17
|
} | undefined;
|
|
17
18
|
links?: never[] | undefined;
|
|
18
19
|
showDomainWarningDialog?: boolean | undefined;
|
|
20
|
+
appPath?: undefined;
|
|
21
|
+
appTab?: undefined;
|
|
22
|
+
onAppTabChange?: undefined;
|
|
23
|
+
children?: undefined;
|
|
19
24
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
20
25
|
declare namespace Dashboard {
|
|
21
26
|
namespace propTypes {
|
|
@@ -26,5 +31,10 @@ declare namespace Dashboard {
|
|
|
26
31
|
export { SessionManagerProps as sessionManagerProps };
|
|
27
32
|
export let links: PropTypes.Requireable<NonNullable<any[] | ((...args: any[]) => any) | null | undefined>>;
|
|
28
33
|
export let showDomainWarningDialog: PropTypes.Requireable<boolean>;
|
|
34
|
+
export let appPath: PropTypes.Requireable<string>;
|
|
35
|
+
export let appTab: PropTypes.Requireable<string>;
|
|
36
|
+
export let onAppTabChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
|
+
export let children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
29
38
|
}
|
|
30
39
|
}
|
|
40
|
+
export { AppHeader, AppBadge, AppInfoProvider, useAppInfo };
|