UNPKG

@cgi-learning-hub/ui

Version:

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

174 lines (173 loc) 5.21 kB
import * as h from "react"; import { P as e } from "./index-B9vkf41S.js"; import { F as I, G as T, H as A } from "./generateUtilityClasses-B_xKAflz.js"; import { u as C, F as x } from "./useFormControl-CatNKXAi.js"; import { m as N } from "./memoTheme-C-PaH-Cy.js"; import { jsx as l, jsxs as S } from "react/jsx-runtime"; import { u as L, s as O, c as R } from "./DefaultPropsProvider-BrmlvPWg.js"; import { T as w } from "./Typography-Cr-aIusw.js"; import { c as u } from "./capitalize-BHEX83JQ.js"; function z(t) { return T("MuiInputAdornment", t); } const b = I("MuiInputAdornment", ["root", "filled", "standard", "outlined", "positionStart", "positionEnd", "disablePointerEvents", "hiddenLabel", "sizeSmall"]); var y; const F = (t, o) => { const { ownerState: n } = t; return [o.root, o[`position${u(n.position)}`], n.disablePointerEvents === !0 && o.disablePointerEvents, o[n.variant]]; }, j = (t) => { const { classes: o, disablePointerEvents: n, hiddenLabel: i, position: r, size: a, variant: p } = t, d = { root: ["root", n && "disablePointerEvents", r && `position${u(r)}`, p, i && "hiddenLabel", a && `size${u(a)}`] }; return R(d, z, o); }, M = O("div", { name: "MuiInputAdornment", slot: "Root", overridesResolver: F })(N(({ theme: t }) => ({ display: "flex", maxHeight: "2em", alignItems: "center", whiteSpace: "nowrap", color: (t.vars || t).palette.action.active, variants: [{ props: { variant: "filled" }, style: { [`&.${b.positionStart}&:not(.${b.hiddenLabel})`]: { marginTop: 16 } } }, { props: { position: "start" }, style: { marginRight: 8 } }, { props: { position: "end" }, style: { marginLeft: 8 } }, { props: { disablePointerEvents: !0 }, style: { pointerEvents: "none" } }] }))), U = /* @__PURE__ */ h.forwardRef(function(o, n) { const i = L({ props: o, name: "MuiInputAdornment" }), { children: r, className: a, component: p = "div", disablePointerEvents: d = !1, disableTypography: g = !1, position: v, variant: c, ...E } = i, s = C() || {}; let m = c; c && s.variant && process.env.NODE_ENV !== "production" && c === s.variant && console.error("MUI: The `InputAdornment` variant infers the variant prop you do not have to provide one."), s && !m && (m = s.variant); const f = { ...i, hiddenLabel: s.hiddenLabel, size: s.size, disablePointerEvents: d, position: v, variant: m }, P = j(f); return /* @__PURE__ */ l(x.Provider, { value: null, children: /* @__PURE__ */ l(M, { as: p, ownerState: f, className: A(P.root, a), ref: n, ...E, children: typeof r == "string" && !g ? /* @__PURE__ */ l(w, { color: "textSecondary", children: r }) : /* @__PURE__ */ S(h.Fragment, { children: [v === "start" ? ( /* notranslate needed while Google Translate will not fix zero-width space issue */ y || (y = /* @__PURE__ */ l("span", { className: "notranslate", "aria-hidden": !0, children: "​" })) ) : null, r] }) }) }); }); process.env.NODE_ENV !== "production" && (U.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * The content of the component, normally an `IconButton` or string. */ 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, /** * Disable pointer events on the root. * This allows for the content of the adornment to focus the `input` on click. * @default false */ disablePointerEvents: e.bool, /** * If children is a string then disable wrapping in a Typography component. * @default false */ disableTypography: e.bool, /** * The position this adornment should appear relative to the `Input`. */ position: e.oneOf(["end", "start"]).isRequired, /** * 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]), /** * The variant to use. * Note: If you are using the `TextField` component or the `FormControl` component * you do not have to set this manually. */ variant: e.oneOf(["filled", "outlined", "standard"]) }); export { U as I };