UNPKG

@rws-aoa/react-library

Version:

RWS AOA Design System

81 lines (80 loc) 3.36 kB
import { jsx as g, jsxs as M } from "react/jsx-runtime"; import { c as T } from "../../../../chunks/compiler-runtime.hDcrsMwn.js"; import { Typography as j, Avatar as w, MenuItem as C, Link as I, Popper as U, Box as W } from "@mui/material"; import { Link as $ } from "@tanstack/react-router"; import { l as B } from "../../../../chunks/lodash.CA_K01A9.js"; import { useState as E } from "react"; import { FontNormalSxProps as L } from "../../../../_constants.js"; function J(n) { const e = T.c(24), [_, k] = E(null), [s, y] = E(!1); let m; e[0] === Symbol.for("react.memo_cache_sentinel") ? (m = function(t) { y(!0), k(t.currentTarget); }, e[0] = m) : m = e[0]; const R = m; let c; e[1] === Symbol.for("react.memo_cache_sentinel") ? (c = function() { y(!1), k(null); }, e[1] = c) : c = e[1]; const A = c; let p; e[2] === Symbol.for("react.memo_cache_sentinel") ? (p = { flexGrow: 0, minWidth: "fit-content" }, e[2] = p) : p = e[2]; let r; e[3] !== n.username ? (r = n.username && /* @__PURE__ */ g(j, { component: "span", sx: B.merge({ marginRight: "16px" }, L), children: n.username }), e[3] = n.username, e[4] = r) : r = e[4]; const S = s ? "usermenu" : void 0, v = s ? "true" : void 0; let f, u; e[5] === Symbol.for("react.memo_cache_sentinel") ? (f = (o) => R(o), u = () => A(), e[5] = f, e[6] = u) : (f = e[5], u = e[6]); let d, x; e[7] === Symbol.for("react.memo_cache_sentinel") ? (d = { padding: 0, ":hover": { backgroundColor: "transparent" } }, x = /* @__PURE__ */ g(w, {}), e[7] = d, e[8] = x) : (d = e[7], x = e[8]); let h; e[9] === Symbol.for("react.memo_cache_sentinel") ? (h = { backgroundColor: "var(--color-bg-light)", padding: "4px 0", borderRadius: "6px", marginTop: "8px", minWidth: "120px", color: "var(--color-text)", boxShadow: ` rgb(255 255 255) 0 0 0 0, rgb(0 0 0 / 5%) 0 0 0 1px, rgb(0 0 0 / 10%) 0 10px 15px -3px, rgb(0 0 0 / 5%) 0 4px 6px -2px ` }, e[9] = h) : h = e[9]; let l; if (e[10] !== n.settings) { let o; e[12] === Symbol.for("react.memo_cache_sentinel") ? (o = (t, O) => /* @__PURE__ */ g(C, { component: t.to ? $ : I, disableRipple: !0, divider: t.divider ?? !1, onClick: (P) => { P.stopPropagation(), t.onClick && t.onClick(), y(!1); }, sx: { ...L }, to: t.to, children: t.label }, O), e[12] = o) : o = e[12], l = n.settings.map(o), e[10] = n.settings, e[11] = l; } else l = e[11]; let a; e[13] !== _ || e[14] !== s || e[15] !== l ? (a = /* @__PURE__ */ g(U, { anchorEl: _, id: "usermenu", open: s, placement: "bottom-end", sx: h, children: l }), e[13] = _, e[14] = s, e[15] = l, e[16] = a) : a = e[16]; let i; e[17] !== a || e[18] !== S || e[19] !== v ? (i = /* @__PURE__ */ M(C, { "aria-controls": S, "aria-expanded": v, "aria-haspopup": "true", "aria-label": "User menu", onMouseEnter: f, onMouseLeave: u, sx: d, children: [ x, a ] }), e[17] = a, e[18] = S, e[19] = v, e[20] = i) : i = e[20]; let b; return e[21] !== i || e[22] !== r ? (b = /* @__PURE__ */ M(W, { alignItems: "center", display: "flex", role: "menu", sx: p, children: [ r, i ] }), e[21] = i, e[22] = r, e[23] = b) : b = e[23], b; } export { J as AoaUserMenu }; //# sourceMappingURL=UserMenu.js.map