@blocklet/ui-react
Version:
Some useful front-end web components that can be used in Blocklets.
64 lines (63 loc) • 2.57 kB
JavaScript
import { jsx as t } from "react/jsx-runtime";
import { Box as d } from "@mui/material";
import { Icon as i } from "@iconify/react";
import { useMemoizedFn as u, useCreation as I } from "ahooks";
import v from "@arcblock/ux/lib/DID";
import h from "@iconify-icons/material-symbols/schedule-outline-rounded";
import x from "@iconify-icons/material-symbols/more-time-rounded";
import l from "@iconify-icons/material-symbols/captive-portal-rounded";
import g from "@iconify-icons/material-symbols/settings-input-antenna-rounded";
import p from "@arcblock/ux/lib/RelativeTime";
import { translate as L } from "@arcblock/ux/lib/Locale/util";
import { useLocaleContext as A } from "@arcblock/ux/lib/Locale/context";
import { LOGIN_PROVIDER_NAME as R } from "@arcblock/ux/lib/Util/constant";
import S from "@arcblock/ux/lib/UserCard/Content/shorten-label";
import { translations as z } from "../../libs/locales.js";
import P from "./user-info-item.js";
function G({
user: o,
isMySelf: a = !1,
...m
}) {
const { locale: r } = A(), n = u((c, s = {}) => L(z, c, r, "en", s)), f = I(() => o?.sourceProvider && R[o.sourceProvider] || n("unknown"), [o?.sourceProvider]), e = [];
return a && (e.push({
icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: h }),
title: n("lastLoginAt"),
content: o?.lastLoginAt ? (
// @ts-ignore
/* @__PURE__ */ t(p, { locale: r, value: o?.lastLoginAt, relativeRange: 3 * 86400 * 1e3 })
) : n("unknown")
}), e.push({
icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: g }),
title: n("lastLoginIp"),
content: o?.lastLoginIp ? /* @__PURE__ */ t(S, { maxLength: 20, children: o?.lastLoginIp }) : n("unknown")
})), e.push({
icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: x }),
title: n("createdAt"),
// @ts-ignore
content: o?.createdAt ? /* @__PURE__ */ t(p, { locale: r, value: o?.createdAt }) : n("unknown")
}), a && (e.push({
icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: l }),
title: n("registerFrom"),
content: f
}), o?.inviter && e.push({
icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: l }),
title: n("invitedBy"),
content: /* @__PURE__ */ t(v, { style: { maxWidth: 260 }, did: o.inviter, showQrcode: !0, copyable: !0, compact: !0, responsive: !0, locale: r })
})), /* @__PURE__ */ t(
d,
{
...m,
sx: {
display: "flex",
flexDirection: "column",
gap: 1.5,
...m?.sx
},
children: e.map((c) => /* @__PURE__ */ t(P, { data: c, sx: { flex: 1 } }, c.title))
}
);
}
export {
G as default
};