UNPKG

@cgi-learning-hub/ui

Version:

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

442 lines (441 loc) 13.5 kB
import * as f from "react"; import { P as o } from "./index-Sy88PpwE.js"; import { H as R, n as C } from "./identifier-PWESmBq6.js"; import { m as U } from "./memoTheme-DAFDflPY.js"; import { u as w, s as k, c as F, r as _ } from "./DefaultPropsProvider-DqazQPtr.js"; import { a as S } from "./List-CB_cqCSw.js"; import { b as W, a as x } from "./ListItem-DAZQEir2.js"; import { jsx as $, jsxs as z } from "react/jsx-runtime"; import { u as A } from "./useEventCallback-Y2KwRxBw.js"; import { u as H } from "./useForkRef-u29GSuCu.js"; import { B as q } from "./ButtonBase-6TF6t2SP.js"; import { g as J, l as I } from "./listItemTextClasses-B5VhLd9W.js"; import { u as B } from "./useSlot-BzdKwDQ5.js"; import { T as O, t as j } from "./Typography-Dy8r_tT2.js"; const K = (e, t) => { const { ownerState: s } = e; return [t.root, s.dense && t.dense, s.alignItems === "flex-start" && t.alignItemsFlexStart, s.divider && t.divider, !s.disableGutters && t.gutters]; }, Q = (e) => { const { alignItems: t, classes: s, dense: a, disabled: n, disableGutters: c, divider: i, selected: b } = e, p = F({ root: ["root", a && "dense", !c && "gutters", i && "divider", n && "disabled", t === "flex-start" && "alignItemsFlexStart", b && "selected"] }, W, s); return { ...s, ...p }; }, X = k(q, { shouldForwardProp: (e) => _(e) || e === "classes", name: "MuiListItemButton", slot: "Root", overridesResolver: K })(U(({ theme: e }) => ({ display: "flex", flexGrow: 1, justifyContent: "flex-start", alignItems: "center", position: "relative", textDecoration: "none", minWidth: 0, boxSizing: "border-box", textAlign: "left", paddingTop: 8, paddingBottom: 8, transition: e.transitions.create("background-color", { duration: e.transitions.duration.shortest }), "&:hover": { textDecoration: "none", backgroundColor: (e.vars || e).palette.action.hover, // Reset on touch devices, it doesn't add specificity "@media (hover: none)": { backgroundColor: "transparent" } }, [`&.${x.selected}`]: { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : C(e.palette.primary.main, e.palette.action.selectedOpacity), [`&.${x.focusVisible}`]: { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))` : C(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.focusOpacity) } }, [`&.${x.selected}:hover`]: { backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))` : C(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})` : C(e.palette.primary.main, e.palette.action.selectedOpacity) } }, [`&.${x.focusVisible}`]: { backgroundColor: (e.vars || e).palette.action.focus }, [`&.${x.disabled}`]: { opacity: (e.vars || e).palette.action.disabledOpacity }, variants: [{ props: ({ ownerState: t }) => t.divider, style: { borderBottom: `1px solid ${(e.vars || e).palette.divider}`, backgroundClip: "padding-box" } }, { props: { alignItems: "flex-start" }, style: { alignItems: "flex-start" } }, { props: ({ ownerState: t }) => !t.disableGutters, style: { paddingLeft: 16, paddingRight: 16 } }, { props: ({ ownerState: t }) => t.dense, style: { paddingTop: 4, paddingBottom: 4 } }] }))), Y = /* @__PURE__ */ f.forwardRef(function(t, s) { const a = w({ props: t, name: "MuiListItemButton" }), { alignItems: n = "center", autoFocus: c = !1, component: i = "div", children: b, dense: u = !1, disableGutters: p = !1, divider: P = !1, focusVisibleClassName: h, selected: L = !1, className: N, ...d } = a, g = f.useContext(S), l = f.useMemo(() => ({ dense: u || g.dense || !1, alignItems: n, disableGutters: p }), [n, g.dense, u, p]), r = f.useRef(null); A(() => { c && (r.current ? r.current.focus() : process.env.NODE_ENV !== "production" && console.error("MUI: Unable to set focus to a ListItemButton whose component has not been rendered.")); }, [c]); const y = { ...a, alignItems: n, dense: l.dense, disableGutters: p, divider: P, selected: L }, m = Q(y), v = H(r, s); return /* @__PURE__ */ $(S.Provider, { value: l, children: /* @__PURE__ */ $(X, { ref: v, href: d.href || d.to, component: (d.href || d.to) && i === "div" ? "button" : i, focusVisibleClassName: R(m.focusVisible, h), ownerState: y, className: R(m.root, N), ...d, classes: m, children: b }) }); }); process.env.NODE_ENV !== "production" && (Y.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Defines the `align-items` style property. * @default 'center' */ alignItems: o.oneOf(["center", "flex-start"]), /** * 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: o.bool, /** * The content of the component if a `ListItemSecondaryAction` is used it must * be the last child. */ children: o.node, /** * Override or extend the styles applied to the component. */ classes: o.object, /** * @ignore */ className: o.string, /** * The component used for the root node. * Either a string to use a HTML element or a component. */ component: o.elementType, /** * If `true`, compact vertical padding designed for keyboard and mouse input is used. * The prop defaults to the value inherited from the parent List component. * @default false */ dense: o.bool, /** * If `true`, the component is disabled. * @default false */ disabled: o.bool, /** * If `true`, the left and right padding is removed. * @default false */ disableGutters: o.bool, /** * If `true`, a 1px light border is added to the bottom of the list item. * @default false */ divider: o.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: o.string, /** * @ignore */ href: o.string, /** * Use to apply selected styling. * @default false */ selected: o.bool, /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: o.oneOfType([o.arrayOf(o.oneOfType([o.func, o.object, o.bool])), o.func, o.object]) }); const Z = (e) => { const { classes: t, inset: s, primary: a, secondary: n, dense: c } = e; return F({ root: ["root", s && "inset", c && "dense", a && n && "multiline"], primary: ["primary"], secondary: ["secondary"] }, J, t); }, ee = k("div", { name: "MuiListItemText", slot: "Root", overridesResolver: (e, t) => { const { ownerState: s } = e; return [{ [`& .${I.primary}`]: t.primary }, { [`& .${I.secondary}`]: t.secondary }, t.root, s.inset && t.inset, s.primary && s.secondary && t.multiline, s.dense && t.dense]; } })({ flex: "1 1 auto", minWidth: 0, marginTop: 4, marginBottom: 4, [`.${j.root}:where(& .${I.primary})`]: { display: "block" }, [`.${j.root}:where(& .${I.secondary})`]: { display: "block" }, variants: [{ props: ({ ownerState: e }) => e.primary && e.secondary, style: { marginTop: 6, marginBottom: 6 } }, { props: ({ ownerState: e }) => e.inset, style: { paddingLeft: 56 } }] }), oe = /* @__PURE__ */ f.forwardRef(function(t, s) { const a = w({ props: t, name: "MuiListItemText" }), { children: n, className: c, disableTypography: i = !1, inset: b = !1, primary: u, primaryTypographyProps: p, secondary: P, secondaryTypographyProps: h, slots: L = {}, slotProps: N = {}, ...d } = a, { dense: g } = f.useContext(S); let l = u ?? n, r = P; const y = { ...a, disableTypography: i, inset: b, primary: !!l, secondary: !!r, dense: g }, m = Z(y), v = { slots: L, slotProps: { primary: p, secondary: h, ...N } }, [V, E] = B("root", { className: R(m.root, c), elementType: ee, externalForwardedProps: { ...v, ...d }, ownerState: y, ref: s }), [D, T] = B("primary", { className: m.primary, elementType: O, externalForwardedProps: v, ownerState: y }), [G, M] = B("secondary", { className: m.secondary, elementType: O, externalForwardedProps: v, ownerState: y }); return l != null && l.type !== O && !i && (l = /* @__PURE__ */ $(D, { variant: g ? "body2" : "body1", component: T != null && T.variant ? void 0 : "span", ...T, children: l })), r != null && r.type !== O && !i && (r = /* @__PURE__ */ $(G, { variant: "body2", color: "textSecondary", ...M, children: r })), /* @__PURE__ */ z(V, { ...E, children: [l, r] }); }); process.env.NODE_ENV !== "production" && (oe.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Alias for the `primary` prop. */ children: o.node, /** * Override or extend the styles applied to the component. */ classes: o.object, /** * @ignore */ className: o.string, /** * If `true`, the children won't be wrapped by a Typography component. * This can be useful to render an alternative Typography variant by wrapping * the `children` (or `primary`) text, and optional `secondary` text * with the Typography component. * @default false */ disableTypography: o.bool, /** * If `true`, the children are indented. * This should be used if there is no left avatar or left icon. * @default false */ inset: o.bool, /** * The main content element. */ primary: o.node, /** * These props will be forwarded to the primary typography component * (as long as disableTypography is not `true`). * @deprecated Use `slotProps.primary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. */ primaryTypographyProps: o.object, /** * The secondary content element. */ secondary: o.node, /** * These props will be forwarded to the secondary typography component * (as long as disableTypography is not `true`). * @deprecated Use `slotProps.secondary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. */ secondaryTypographyProps: o.object, /** * The props used for each slot inside. * @default {} */ slotProps: o.shape({ primary: o.oneOfType([o.func, o.object]), root: o.oneOfType([o.func, o.object]), secondary: o.oneOfType([o.func, o.object]) }), /** * The components used for each slot inside. * @default {} */ slots: o.shape({ primary: o.elementType, root: o.elementType, secondary: o.elementType }), /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: o.oneOfType([o.arrayOf(o.oneOfType([o.func, o.object, o.bool])), o.func, o.object]) }); export { Y as L, oe as a };