UNPKG

@cgi-learning-hub/ui

Version:

@cgi-learning-hub/ui is an open-source React component library that implements UI for HUB's features

269 lines (268 loc) 8.24 kB
import * as c from "react"; import { P as t } from "./index-Sy88PpwE.js"; import { F as T, G as k, H as C, n as d } from "./identifier-PWESmBq6.js"; import { u as F, s as L, c as P, r as U } from "./DefaultPropsProvider-DqazQPtr.js"; import { m as E } from "./memoTheme-DAFDflPY.js"; import { a as I } from "./List-CB_cqCSw.js"; import { jsx as x } from "react/jsx-runtime"; import { u as G } from "./useEventCallback-Y2KwRxBw.js"; import { u as j } from "./useForkRef-u29GSuCu.js"; import { B as D } from "./ButtonBase-6TF6t2SP.js"; import { l as $ } from "./listItemTextClasses-B5VhLd9W.js"; import { d as M } from "./dividerClasses-BPJZ8SFy.js"; function se(e) { return k("MuiListItemIcon", e); } const O = T("MuiListItemIcon", ["root", "alignItemsFlexStart"]); function H(e) { return k("MuiMenuItem", e); } const i = T("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divider", "gutters", "selected"]), z = (e, o) => { const { ownerState: s } = e; return [o.root, s.dense && o.dense, s.divider && o.divider, !s.disableGutters && o.gutters]; }, _ = (e) => { const { disabled: o, dense: s, divider: a, disableGutters: l, selected: p, classes: r } = e, n = P({ root: ["root", s && "dense", o && "disabled", !l && "gutters", a && "divider", p && "selected"] }, H, r); return { ...r, ...n }; }, W = L(D, { shouldForwardProp: (e) => U(e) || e === "classes", name: "MuiMenuItem", slot: "Root", overridesResolver: z })(E(({ theme: e }) => ({ ...e.typography.body1, display: "flex", justifyContent: "flex-start", alignItems: "center", position: "relative", textDecoration: "none", minHeight: 48, paddingTop: 6, paddingBottom: 6, boxSizing: "border-box", whiteSpace: "nowrap", "&:hover": { textDecoration: "none", backgroundColor: (e.vars || e).palette.action.hover, // Reset on touch devices, it doesn't add specificity "@media (hover: none)": { backgroundColor: "transparent" } }, [`&.${i.selected}`]: { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : d(e.palette.primary.main, e.palette.action.selectedOpacity), [`&.${i.focusVisible}`]: { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))` : d(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.focusOpacity) } }, [`&.${i.selected}:hover`]: { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))` : d(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.hoverOpacity), // Reset on touch devices, it doesn't add specificity "@media (hover: none)": { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : d(e.palette.primary.main, e.palette.action.selectedOpacity) } }, [`&.${i.focusVisible}`]: { backgroundColor: (e.vars || e).palette.action.focus }, [`&.${i.disabled}`]: { opacity: (e.vars || e).palette.action.disabledOpacity }, [`& + .${M.root}`]: { marginTop: e.spacing(1), marginBottom: e.spacing(1) }, [`& + .${M.inset}`]: { marginLeft: 52 }, [`& .${$.root}`]: { marginTop: 0, marginBottom: 0 }, [`& .${$.inset}`]: { paddingLeft: 36 }, [`& .${O.root}`]: { minWidth: 36 }, variants: [{ props: ({ ownerState: o }) => !o.disableGutters, style: { paddingLeft: 16, paddingRight: 16 } }, { props: ({ ownerState: o }) => o.divider, style: { borderBottom: `1px solid ${(e.vars || e).palette.divider}`, backgroundClip: "padding-box" } }, { props: ({ ownerState: o }) => !o.dense, style: { [e.breakpoints.up("sm")]: { minHeight: "auto" } } }, { props: ({ ownerState: o }) => o.dense, style: { minHeight: 32, // https://m2.material.io/components/menus#specs > Dense paddingTop: 4, paddingBottom: 4, ...e.typography.body2, [`& .${O.root} svg`]: { fontSize: "1.25rem" } } }] }))), q = /* @__PURE__ */ c.forwardRef(function(o, s) { const a = F({ props: o, name: "MuiMenuItem" }), { autoFocus: l = !1, component: p = "li", dense: r = !1, divider: f = !1, disableGutters: n = !1, focusVisibleClassName: N, role: R = "menuitem", tabIndex: b, className: w, ...V } = a, g = c.useContext(I), v = c.useMemo(() => ({ dense: r || g.dense || !1, disableGutters: n }), [g.dense, r, n]), u = c.useRef(null); G(() => { l && (u.current ? u.current.focus() : process.env.NODE_ENV !== "production" && console.error("MUI: Unable to set focus to a MenuItem whose component has not been rendered.")); }, [l]); const B = { ...a, dense: v.dense, divider: f, disableGutters: n }, m = _(a), S = j(u, s); let y; return a.disabled || (y = b !== void 0 ? b : -1), /* @__PURE__ */ x(I.Provider, { value: v, children: /* @__PURE__ */ x(W, { ref: S, role: R, tabIndex: y, component: p, focusVisibleClassName: C(m.focusVisible, N), className: C(m.root, w), ...V, ownerState: B, classes: m }) }); }); process.env.NODE_ENV !== "production" && (q.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * If `true`, the list item is focused during the first mount. * Focus will also be triggered if the value changes from false to true. * @default false */ autoFocus: t.bool, /** * The content of the component. */ children: t.node, /** * Override or extend the styles applied to the component. */ classes: t.object, /** * @ignore */ className: t.string, /** * The component used for the root node. * Either a string to use a HTML element or a component. */ component: t.elementType, /** * If `true`, compact vertical padding designed for keyboard and mouse input is used. * The prop defaults to the value inherited from the parent Menu component. * @default false */ dense: t.bool, /** * @ignore */ disabled: t.bool, /** * If `true`, the left and right padding is removed. * @default false */ disableGutters: t.bool, /** * If `true`, a 1px light border is added to the bottom of the menu item. * @default false */ divider: t.bool, /** * This prop can help identify which element has keyboard focus. * The class name will be applied when the element gains the focus through keyboard interaction. * It's a polyfill for the [CSS :focus-visible selector](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo). * The rationale for using this feature [is explained here](https://github.com/WICG/focus-visible/blob/HEAD/explainer.md). * A [polyfill can be used](https://github.com/WICG/focus-visible) to apply a `focus-visible` class to other components * if needed. */ focusVisibleClassName: t.string, /** * @ignore */ role: t.string, /** * If `true`, the component is selected. * @default false */ selected: t.bool, /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: t.oneOfType([t.arrayOf(t.oneOfType([t.func, t.object, t.bool])), t.func, t.object]), /** * @default 0 */ tabIndex: t.number }); export { q as M, H as a, se as g, O as l, i as m };