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.1 kB
import * as f from "react"; import { P as e } from "./index-B9vkf41S.js"; import { H as B } from "./generateUtilityClasses-B_xKAflz.js"; import { m as M } from "./memoTheme-C-PaH-Cy.js"; import { u as j, s as w, c as k, r as U } from "./DefaultPropsProvider-BrmlvPWg.js"; import { a as R } from "./List-CmJ1jCss.js"; import { b as _, a as x } from "./ListItem-onoPfwb4.js"; import { jsx as O, jsxs as W } from "react/jsx-runtime"; import { u as z } from "./useEventCallback-Y2KwRxBw.js"; import { u as A } from "./useForkRef-u29GSuCu.js"; import { B as H } from "./ButtonBase-C2jRC_V7.js"; import { g as q, l as I } from "./listItemTextClasses-CEbo8A-K.js"; import { u as h } from "./useSlot-BSkdRaZr.js"; import { T as C, t as S } from "./Typography-Cr-aIusw.js"; const J = (o, s) => { const { ownerState: t } = o; return [s.root, t.dense && s.dense, t.alignItems === "flex-start" && s.alignItemsFlexStart, t.divider && s.divider, !t.disableGutters && s.gutters]; }, K = (o) => { const { alignItems: s, classes: t, dense: a, disabled: n, disableGutters: c, divider: i, selected: b } = o, p = k({ root: ["root", a && "dense", !c && "gutters", i && "divider", n && "disabled", s === "flex-start" && "alignItemsFlexStart", b && "selected"] }, _, t); return { ...t, ...p }; }, Q = w(H, { shouldForwardProp: (o) => U(o) || o === "classes", name: "MuiListItemButton", slot: "Root", overridesResolver: J })(M(({ theme: o }) => ({ 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: o.transitions.create("background-color", { duration: o.transitions.duration.shortest }), "&:hover": { textDecoration: "none", backgroundColor: (o.vars || o).palette.action.hover, // Reset on touch devices, it doesn't add specificity "@media (hover: none)": { backgroundColor: "transparent" } }, [`&.${x.selected}`]: { backgroundColor: o.alpha((o.vars || o).palette.primary.main, (o.vars || o).palette.action.selectedOpacity), [`&.${x.focusVisible}`]: { backgroundColor: o.alpha((o.vars || o).palette.primary.main, `${(o.vars || o).palette.action.selectedOpacity} + ${(o.vars || o).palette.action.focusOpacity}`) } }, [`&.${x.selected}:hover`]: { backgroundColor: o.alpha((o.vars || o).palette.primary.main, `${(o.vars || o).palette.action.selectedOpacity} + ${(o.vars || o).palette.action.hoverOpacity}`), // Reset on touch devices, it doesn't add specificity "@media (hover: none)": { backgroundColor: o.alpha((o.vars || o).palette.primary.main, (o.vars || o).palette.action.selectedOpacity) } }, [`&.${x.focusVisible}`]: { backgroundColor: (o.vars || o).palette.action.focus }, [`&.${x.disabled}`]: { opacity: (o.vars || o).palette.action.disabledOpacity }, variants: [{ props: ({ ownerState: s }) => s.divider, style: { borderBottom: `1px solid ${(o.vars || o).palette.divider}`, backgroundClip: "padding-box" } }, { props: { alignItems: "flex-start" }, style: { alignItems: "flex-start" } }, { props: ({ ownerState: s }) => !s.disableGutters, style: { paddingLeft: 16, paddingRight: 16 } }, { props: ({ ownerState: s }) => s.dense, style: { paddingTop: 4, paddingBottom: 4 } }] }))), X = /* @__PURE__ */ f.forwardRef(function(s, t) { const a = j({ props: s, name: "MuiListItemButton" }), { alignItems: n = "center", autoFocus: c = !1, component: i = "div", children: b, dense: u = !1, disableGutters: p = !1, divider: P = !1, focusVisibleClassName: L, selected: N = !1, className: $, ...d } = a, g = f.useContext(R), l = f.useMemo(() => ({ dense: u || g.dense || !1, alignItems: n, disableGutters: p }), [n, g.dense, u, p]), r = f.useRef(null); z(() => { 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: N }, m = K(y), v = A(r, t); return /* @__PURE__ */ O(R.Provider, { value: l, children: /* @__PURE__ */ O(Q, { ref: v, href: d.href || d.to, component: (d.href || d.to) && i === "div" ? "button" : i, focusVisibleClassName: B(m.focusVisible, L), ownerState: y, className: B(m.root, $), ...d, classes: m, children: b }) }); }); process.env.NODE_ENV !== "production" && (X.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: e.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: e.bool, /** * The content of the component if a `ListItemSecondaryAction` is used it must * be the last child. */ children: e.node, /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.string, /** * The component used for the root node. * Either a string to use a HTML element or a component. */ component: e.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: e.bool, /** * If `true`, the component is disabled. * @default false */ disabled: e.bool, /** * If `true`, the left and right padding is removed. * @default false */ disableGutters: e.bool, /** * If `true`, a 1px light border is added to the bottom of the list item. * @default false */ divider: e.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: e.string, /** * @ignore */ href: e.string, /** * Use to apply selected styling. * @default false */ selected: e.bool, /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object]) }); const Y = (o) => { const { classes: s, inset: t, primary: a, secondary: n, dense: c } = o; return k({ root: ["root", t && "inset", c && "dense", a && n && "multiline"], primary: ["primary"], secondary: ["secondary"] }, q, s); }, Z = w("div", { name: "MuiListItemText", slot: "Root", overridesResolver: (o, s) => { const { ownerState: t } = o; return [{ [`& .${I.primary}`]: s.primary }, { [`& .${I.secondary}`]: s.secondary }, s.root, t.inset && s.inset, t.primary && t.secondary && s.multiline, t.dense && s.dense]; } })({ flex: "1 1 auto", minWidth: 0, marginTop: 4, marginBottom: 4, [`.${S.root}:where(& .${I.primary})`]: { display: "block" }, [`.${S.root}:where(& .${I.secondary})`]: { display: "block" }, variants: [{ props: ({ ownerState: o }) => o.primary && o.secondary, style: { marginTop: 6, marginBottom: 6 } }, { props: ({ ownerState: o }) => o.inset, style: { paddingLeft: 56 } }] }), oo = /* @__PURE__ */ f.forwardRef(function(s, t) { const a = j({ props: s, name: "MuiListItemText" }), { children: n, className: c, disableTypography: i = !1, inset: b = !1, primary: u, primaryTypographyProps: p, secondary: P, secondaryTypographyProps: L, slots: N = {}, slotProps: $ = {}, ...d } = a, { dense: g } = f.useContext(R); let l = u ?? n, r = P; const y = { ...a, disableTypography: i, inset: b, primary: !!l, secondary: !!r, dense: g }, m = Y(y), v = { slots: N, slotProps: { primary: p, secondary: L, ...$ } }, [F, V] = h("root", { className: B(m.root, c), elementType: Z, externalForwardedProps: { ...v, ...d }, ownerState: y, ref: t }), [E, T] = h("primary", { className: m.primary, elementType: C, externalForwardedProps: v, ownerState: y }), [D, G] = h("secondary", { className: m.secondary, elementType: C, externalForwardedProps: v, ownerState: y }); return l != null && l.type !== C && !i && (l = /* @__PURE__ */ O(E, { variant: g ? "body2" : "body1", component: T != null && T.variant ? void 0 : "span", ...T, children: l })), r != null && r.type !== C && !i && (r = /* @__PURE__ */ O(D, { variant: "body2", color: "textSecondary", ...G, children: r })), /* @__PURE__ */ W(F, { ...V, children: [l, r] }); }); process.env.NODE_ENV !== "production" && (oo.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: e.node, /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.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: e.bool, /** * If `true`, the children are indented. * This should be used if there is no left avatar or left icon. * @default false */ inset: e.bool, /** * The main content element. */ primary: e.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: e.object, /** * The secondary content element. */ secondary: e.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: e.object, /** * The props used for each slot inside. * @default {} */ slotProps: e.shape({ primary: e.oneOfType([e.func, e.object]), root: e.oneOfType([e.func, e.object]), secondary: e.oneOfType([e.func, e.object]) }), /** * The components used for each slot inside. * @default {} */ slots: e.shape({ primary: e.elementType, root: e.elementType, secondary: e.elementType }), /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object]) }); export { X as L, oo as a };