UNPKG

@cgi-learning-hub/ui

Version:

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

967 lines (966 loc) 25.9 kB
import * as l from "react"; import { P as e } from "./index-B9vkf41S.js"; import { F as P, G as z, H as R } from "./generateUtilityClasses-B_xKAflz.js"; import { jsxs as D, jsx as b } from "react/jsx-runtime"; import { u as $, s as S, c as E } from "./DefaultPropsProvider-BrmlvPWg.js"; import { i as J } from "./integerPropType-BihGt2aU.js"; import { i as ne } from "./isMuiElement-DnSE4qG4.js"; import { m as V } from "./memoTheme-C-PaH-Cy.js"; import { u as k } from "./useSlot-BSkdRaZr.js"; import { c as K, S as re } from "./createSvgIcon-DFIM5PqN.js"; import { B as ae } from "./ButtonBase-C2jRC_V7.js"; import { c as Q } from "./capitalize-BHEX83JQ.js"; const w = /* @__PURE__ */ l.createContext({}); process.env.NODE_ENV !== "production" && (w.displayName = "StepperContext"); function He() { return l.useContext(w); } const B = /* @__PURE__ */ l.createContext({}); process.env.NODE_ENV !== "production" && (B.displayName = "StepContext"); function Ge() { return l.useContext(B); } function se(t) { return z("MuiStep", t); } const qe = P("MuiStep", ["root", "horizontal", "vertical", "alternativeLabel", "completed"]), le = (t) => { const { classes: o, orientation: n, alternativeLabel: r, completed: a } = t; return E({ root: ["root", n, r && "alternativeLabel", a && "completed"] }, se, o); }, ie = S("div", { name: "MuiStep", slot: "Root", overridesResolver: (t, o) => { const { ownerState: n } = t; return [o.root, o[n.orientation], n.alternativeLabel && o.alternativeLabel, n.completed && o.completed]; } })({ variants: [{ props: { orientation: "horizontal" }, style: { paddingLeft: 8, paddingRight: 8 } }, { props: { alternativeLabel: !0 }, style: { flex: 1, position: "relative" } }] }), ce = /* @__PURE__ */ l.forwardRef(function(o, n) { const r = $({ props: o, name: "MuiStep" }), { active: a, children: i, className: d, component: c = "div", completed: u, disabled: m, expanded: p = !1, index: s, last: f, ...x } = r, { activeStep: y, connector: v, alternativeLabel: N, orientation: M, nonLinear: T } = l.useContext(w); let [C = !1, I = !1, h = !1] = [a, u, m]; y === s ? C = a !== void 0 ? a : !0 : !T && y > s ? I = u !== void 0 ? u : !0 : !T && y < s && (h = m !== void 0 ? m : !0); const U = l.useMemo(() => ({ index: s, last: f, expanded: p, icon: s + 1, active: C, completed: I, disabled: h }), [s, f, p, C, I, h]), L = { ...r, active: C, orientation: M, alternativeLabel: N, completed: I, disabled: h, expanded: p, component: c }, O = le(L), j = /* @__PURE__ */ D(ie, { as: c, className: R(O.root, d), ref: n, ownerState: L, ...x, children: [v && N && s !== 0 ? v : null, i] }); return /* @__PURE__ */ b(B.Provider, { value: U, children: v && !N && s !== 0 ? /* @__PURE__ */ D(l.Fragment, { children: [v, j] }) : j }); }); process.env.NODE_ENV !== "production" && (ce.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Sets the step as active. Is passed to child components. */ active: e.bool, /** * Should be `Step` sub-components such as `StepLabel`, `StepContent`. */ children: e.node, /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.string, /** * Mark the step as completed. Is passed to child components. */ completed: e.bool, /** * The component used for the root node. * Either a string to use a HTML element or a component. */ component: e.elementType, /** * If `true`, the step is disabled, will also disable the button if * `StepButton` is a child of `Step`. Is passed to child components. */ disabled: e.bool, /** * Expand the step. * @default false */ expanded: e.bool, /** * The position of the step. * The prop defaults to the value inherited from the parent Stepper component. */ index: J, /** * If `true`, the Step is displayed as rendered last. * The prop defaults to the value inherited from the parent Stepper component. */ last: 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 pe = K(/* @__PURE__ */ b("path", { d: "M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm-2 17l-5-5 1.4-1.4 3.6 3.6 7.6-7.6L19 8l-9 9z" }), "CheckCircle"), de = K(/* @__PURE__ */ b("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }), "Warning"); function ue(t) { return z("MuiStepIcon", t); } const F = P("MuiStepIcon", ["root", "active", "completed", "error", "text"]); var G; const be = (t) => { const { classes: o, active: n, completed: r, error: a } = t; return E({ root: ["root", n && "active", r && "completed", a && "error"], text: ["text"] }, ue, o); }, W = S(re, { name: "MuiStepIcon", slot: "Root" })(V(({ theme: t }) => ({ display: "block", transition: t.transitions.create("color", { duration: t.transitions.duration.shortest }), color: (t.vars || t).palette.text.disabled, [`&.${F.completed}`]: { color: (t.vars || t).palette.primary.main }, [`&.${F.active}`]: { color: (t.vars || t).palette.primary.main }, [`&.${F.error}`]: { color: (t.vars || t).palette.error.main } }))), me = S("text", { name: "MuiStepIcon", slot: "Text" })(V(({ theme: t }) => ({ fill: (t.vars || t).palette.primary.contrastText, fontSize: t.typography.caption.fontSize, fontFamily: t.typography.fontFamily }))), X = /* @__PURE__ */ l.forwardRef(function(o, n) { const r = $({ props: o, name: "MuiStepIcon" }), { active: a = !1, className: i, completed: d = !1, error: c = !1, icon: u, ...m } = r, p = { ...r, active: a, completed: d, error: c }, s = be(p); if (typeof u == "number" || typeof u == "string") { const f = R(i, s.root); return c ? /* @__PURE__ */ b(W, { as: de, className: f, ref: n, ownerState: p, ...m }) : d ? /* @__PURE__ */ b(W, { as: pe, className: f, ref: n, ownerState: p, ...m }) : /* @__PURE__ */ D(W, { className: f, ref: n, ownerState: p, ...m, children: [G || (G = /* @__PURE__ */ b("circle", { cx: "12", cy: "12", r: "12" })), /* @__PURE__ */ b(me, { className: s.text, x: "12", y: "12", textAnchor: "middle", dominantBaseline: "central", ownerState: p, children: u })] }); } return u; }); 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`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Whether this step is active. * @default false */ active: e.bool, /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.string, /** * Mark the step as completed. Is passed to child components. * @default false */ completed: e.bool, /** * If `true`, the step is marked as failed. * @default false */ error: e.bool, /** * The label displayed in the step icon. */ icon: e.node, /** * 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]) }); function fe(t) { return z("MuiStepLabel", t); } const g = P("MuiStepLabel", ["root", "horizontal", "vertical", "label", "active", "completed", "error", "disabled", "iconContainer", "alternativeLabel", "labelContainer"]), ve = (t) => { const { classes: o, orientation: n, active: r, completed: a, error: i, disabled: d, alternativeLabel: c } = t; return E({ root: ["root", n, i && "error", d && "disabled", c && "alternativeLabel"], label: ["label", r && "active", a && "completed", i && "error", d && "disabled", c && "alternativeLabel"], iconContainer: ["iconContainer", r && "active", a && "completed", i && "error", d && "disabled", c && "alternativeLabel"], labelContainer: ["labelContainer", c && "alternativeLabel"] }, fe, o); }, Se = S("span", { name: "MuiStepLabel", slot: "Root", overridesResolver: (t, o) => { const { ownerState: n } = t; return [o.root, o[n.orientation]]; } })({ display: "flex", alignItems: "center", [`&.${g.alternativeLabel}`]: { flexDirection: "column" }, [`&.${g.disabled}`]: { cursor: "default" }, variants: [{ props: { orientation: "vertical" }, style: { textAlign: "left", padding: "8px 0" } }] }), ye = S("span", { name: "MuiStepLabel", slot: "Label" })(V(({ theme: t }) => ({ ...t.typography.body2, display: "block", transition: t.transitions.create("color", { duration: t.transitions.duration.shortest }), [`&.${g.active}`]: { color: (t.vars || t).palette.text.primary, fontWeight: 500 }, [`&.${g.completed}`]: { color: (t.vars || t).palette.text.primary, fontWeight: 500 }, [`&.${g.alternativeLabel}`]: { marginTop: 16 }, [`&.${g.error}`]: { color: (t.vars || t).palette.error.main } }))), Ce = S("span", { name: "MuiStepLabel", slot: "IconContainer" })({ flexShrink: 0, display: "flex", paddingRight: 8, [`&.${g.alternativeLabel}`]: { paddingRight: 0 } }), xe = S("span", { name: "MuiStepLabel", slot: "LabelContainer" })(V(({ theme: t }) => ({ width: "100%", color: (t.vars || t).palette.text.secondary, [`&.${g.alternativeLabel}`]: { textAlign: "center" } }))), A = /* @__PURE__ */ l.forwardRef(function(o, n) { const r = $({ props: o, name: "MuiStepLabel" }), { children: a, className: i, componentsProps: d = {}, error: c = !1, icon: u, optional: m, slots: p = {}, slotProps: s = {}, StepIconComponent: f, StepIconProps: x, ...y } = r, { alternativeLabel: v, orientation: N } = l.useContext(w), { active: M, disabled: T, completed: C, icon: I } = l.useContext(B), h = u || I; let U = f; h && !U && (U = X); const L = { ...r, active: M, alternativeLabel: v, completed: C, disabled: T, error: c, orientation: N }, O = ve(L), j = { slots: p, slotProps: { stepIcon: x, ...d, ...s } }, [Z, ee] = k("root", { elementType: Se, externalForwardedProps: { ...j, ...y }, ownerState: L, ref: n, className: R(O.root, i) }), [te, _] = k("label", { elementType: ye, externalForwardedProps: j, ownerState: L }), [H, oe] = k("stepIcon", { elementType: U, externalForwardedProps: j, ownerState: L }); return /* @__PURE__ */ D(Z, { ...ee, children: [h || H ? /* @__PURE__ */ b(Ce, { className: O.iconContainer, ownerState: L, children: /* @__PURE__ */ b(H, { completed: C, active: M, error: c, icon: h, ...oe }) }) : null, /* @__PURE__ */ D(xe, { className: O.labelContainer, ownerState: L, children: [a ? /* @__PURE__ */ b(te, { ..._, className: R(O.label, _ == null ? void 0 : _.className), children: a }) : null, m] })] }); }); process.env.NODE_ENV !== "production" && (A.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * In most cases will simply be a string containing a title for the label. */ children: e.node, /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.string, /** * The props used for each slot inside. * @default {} * @deprecated use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details. */ componentsProps: e.shape({ label: e.object }), /** * If `true`, the step is marked as failed. * @default false */ error: e.bool, /** * Override the default label of the step icon. */ icon: e.node, /** * The optional node to display. */ optional: e.node, /** * The props used for each slot inside. * @default {} */ slotProps: e.shape({ label: e.oneOfType([e.func, e.object]), root: e.oneOfType([e.func, e.object]), stepIcon: e.oneOfType([e.func, e.object]) }), /** * The components used for each slot inside. * @default {} */ slots: e.shape({ label: e.elementType, root: e.elementType, stepIcon: e.elementType }), /** * The component to render in place of the [`StepIcon`](https://mui.com/material-ui/api/step-icon/). * @deprecated Use `slots.stepIcon` 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. */ StepIconComponent: e.elementType, /** * Props applied to the [`StepIcon`](https://mui.com/material-ui/api/step-icon/) element. * @deprecated Use `slotProps.stepIcon` 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. */ StepIconProps: e.object, /** * 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]) }); A.muiName = "StepLabel"; function Le(t) { return z("MuiStepButton", t); } const q = P("MuiStepButton", ["root", "horizontal", "vertical", "touchRipple"]), he = (t) => { const { classes: o, orientation: n } = t; return E({ root: ["root", n], touchRipple: ["touchRipple"] }, Le, o); }, ge = S(ae, { name: "MuiStepButton", slot: "Root", overridesResolver: (t, o) => { const { ownerState: n } = t; return [{ [`& .${q.touchRipple}`]: o.touchRipple }, o.root, o[n.orientation]]; } })({ width: "100%", padding: "24px 16px", margin: "-24px -16px", boxSizing: "content-box", [`& .${q.touchRipple}`]: { color: "rgba(0, 0, 0, 0.3)" }, variants: [{ props: { orientation: "vertical" }, style: { justifyContent: "flex-start", padding: "8px", margin: "-8px" } }] }), Ne = /* @__PURE__ */ l.forwardRef(function(o, n) { const r = $({ props: o, name: "MuiStepButton" }), { children: a, className: i, icon: d, optional: c, ...u } = r, { disabled: m, active: p } = l.useContext(B), { orientation: s } = l.useContext(w), f = { ...r, orientation: s }, x = he(f), y = { icon: d, optional: c }, v = ne(a, ["StepLabel"]) ? /* @__PURE__ */ l.cloneElement(a, y) : /* @__PURE__ */ b(A, { ...y, children: a }); return /* @__PURE__ */ b(ge, { focusRipple: !0, disabled: m, TouchRippleProps: { className: x.touchRipple }, className: R(x.root, i), ref: n, ownerState: f, "aria-current": p ? "step" : void 0, ...u, children: v }); }); process.env.NODE_ENV !== "production" && (Ne.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Can be a `StepLabel` or a node to place inside `StepLabel` as children. */ children: e.node, /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.string, /** * The icon displayed by the step label. */ icon: e.node, /** * The optional node to display. */ optional: e.node, /** * 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]) }); function Te(t) { return z("MuiStepper", t); } const Je = P("MuiStepper", ["root", "horizontal", "vertical", "nonLinear", "alternativeLabel"]); function Re(t) { return z("MuiStepConnector", t); } P("MuiStepConnector", ["root", "horizontal", "vertical", "alternativeLabel", "active", "completed", "disabled", "line", "lineHorizontal", "lineVertical"]); const we = (t) => { const { classes: o, orientation: n, alternativeLabel: r, active: a, completed: i, disabled: d } = t, c = { root: ["root", n, r && "alternativeLabel", a && "active", i && "completed", d && "disabled"], line: ["line", `line${Q(n)}`] }; return E(c, Re, o); }, Me = S("div", { name: "MuiStepConnector", slot: "Root", overridesResolver: (t, o) => { const { ownerState: n } = t; return [o.root, o[n.orientation], n.alternativeLabel && o.alternativeLabel, n.completed && o.completed]; } })({ flex: "1 1 auto", variants: [{ props: { orientation: "vertical" }, style: { marginLeft: 12 // half icon } }, { props: { alternativeLabel: !0 }, style: { position: "absolute", top: 12, left: "calc(-50% + 20px)", right: "calc(50% + 20px)" } }] }), Ie = S("span", { name: "MuiStepConnector", slot: "Line", overridesResolver: (t, o) => { const { ownerState: n } = t; return [o.line, o[`line${Q(n.orientation)}`]]; } })(V(({ theme: t }) => { const o = t.palette.mode === "light" ? t.palette.grey[400] : t.palette.grey[600]; return { display: "block", borderColor: t.vars ? t.vars.palette.StepConnector.border : o, variants: [{ props: { orientation: "horizontal" }, style: { borderTopStyle: "solid", borderTopWidth: 1 } }, { props: { orientation: "vertical" }, style: { borderLeftStyle: "solid", borderLeftWidth: 1, minHeight: 24 } }] }; })), Y = /* @__PURE__ */ l.forwardRef(function(o, n) { const r = $({ props: o, name: "MuiStepConnector" }), { className: a, ...i } = r, { alternativeLabel: d, orientation: c = "horizontal" } = l.useContext(w), { active: u, disabled: m, completed: p } = l.useContext(B), s = { ...r, alternativeLabel: d, orientation: c, active: u, completed: p, disabled: m }, f = we(s); return /* @__PURE__ */ b(Me, { className: R(f.root, a), ref: n, ownerState: s, ...i, children: /* @__PURE__ */ b(Ie, { className: f.line, ownerState: s }) }); }); 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`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Override or extend the styles applied to the component. */ classes: e.object, /** * @ignore */ className: e.string, /** * 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 Oe = (t) => { const { orientation: o, nonLinear: n, alternativeLabel: r, classes: a } = t; return E({ root: ["root", o, n && "nonLinear", r && "alternativeLabel"] }, Te, a); }, je = S("div", { name: "MuiStepper", slot: "Root", overridesResolver: (t, o) => { const { ownerState: n } = t; return [o.root, o[n.orientation], n.alternativeLabel && o.alternativeLabel, n.nonLinear && o.nonLinear]; } })({ display: "flex", variants: [{ props: { orientation: "horizontal" }, style: { flexDirection: "row", alignItems: "center" } }, { props: { orientation: "vertical" }, style: { flexDirection: "column" } }, { props: { alternativeLabel: !0 }, style: { alignItems: "flex-start" } }] }), Pe = /* @__PURE__ */ b(Y, {}), ze = /* @__PURE__ */ l.forwardRef(function(o, n) { const r = $({ props: o, name: "MuiStepper" }), { activeStep: a = 0, alternativeLabel: i = !1, children: d, className: c, component: u = "div", connector: m = Pe, nonLinear: p = !1, orientation: s = "horizontal", ...f } = r, x = { ...r, nonLinear: p, alternativeLabel: i, orientation: s, component: u }, y = Oe(x), v = l.Children.toArray(d).filter(Boolean), N = v.map((T, C) => /* @__PURE__ */ l.cloneElement(T, { index: C, last: C + 1 === v.length, ...T.props })), M = l.useMemo(() => ({ activeStep: a, alternativeLabel: i, connector: m, nonLinear: p, orientation: s }), [a, i, m, p, s]); return /* @__PURE__ */ b(w.Provider, { value: M, children: /* @__PURE__ */ b(je, { as: u, ownerState: x, className: R(y.root, c), ref: n, ...f, children: N }) }); }); process.env.NODE_ENV !== "production" && (ze.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Set the active step (zero based index). * Set to -1 to disable all the steps. * @default 0 */ activeStep: J, /** * If set to 'true' and orientation is horizontal, * then the step label will be positioned under the icon. * @default false */ alternativeLabel: e.bool, /** * Two or more `<Step />` components. */ 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, /** * An element to be placed between each step. * @default <StepConnector /> */ connector: e.element, /** * If set the `Stepper` will not assist in controlling steps for linear flow. * @default false */ nonLinear: e.bool, /** * The component orientation (layout flow direction). * @default 'horizontal' */ orientation: e.oneOf(["horizontal", "vertical"]), /** * 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 { ce as S, Ne as a, A as b, ze as c, B as d, q as e, Le as f, se as g, g as h, fe as i, Je as j, w as k, Te as l, He as m, qe as s, Ge as u };