UNPKG

@useloops/design-system

Version:

The official React based Loops design system

2 lines (1 loc) 3.25 kB
"use strict";var e=require("react/jsx-runtime"),t=require("@mui/material"),o=require("merge-sx");require("../../BrandCore/colorRamps.js");var r=require("../../BrandCore/primitiveVariables.js");require("../../BrandCore/semanticColor.js"),require("../../BrandCore/types.js"),require("../../BrandCore/typography.js");var i=require("../../BrandCore/Icon/Icon.js"),s=require("../ButtonBase/Button.variant-helpers.js");require("../ButtonBase/ButtonBase.js");var n=require("../Tooltip/Tooltip.js"),a=require("../Typography/Typography.js");const l=t.styled(t.Button,{shouldForwardProp:e=>!["active","iconHeight"].includes(e)})(({active:e,iconHeight:t=24,theme:o})=>({borderRadius:o.spacing(o.custom.radius.sm),maxWidth:"100%",padding:o.spacing(.5,1),textTransform:"none",width:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",...s.buttonInteraction(o,e),backgroundColor:e?o.custom.palette.surface.sunken:"transparent","& p":{minHeight:t},"&:disabled":{backgroundColor:"inherit","& p":{color:o.custom.palette.text.disabled}}})),c=t.styled(t.Box)(({theme:e})=>({padding:e.spacing(.5,1)})),d=t.styled(t.Box)(({theme:e})=>({alignItems:"center",display:"flex",gap:e.spacing(1),textAlign:"left"})),p=t.styled(t.Stack,{shouldForwardProp:e=>"iconHeight"!==e})(({iconHeight:e=24,theme:t})=>({height:e,width:24,alignItems:"center",color:t.custom.palette.icon.secondary,display:"flex",justifyContent:"center",marginLeft:"auto"}));module.exports=({baseState:s,label:h,active:x,danger:u,divider:m,heading:g,selected:j,disabled:y,closeOnClick:v,hidden:f,onClick:w,startIcon:B,slotProps:b,tooltip:C,children:q})=>{const I=t.useTheme(),k=3*r.base;return f?null:m?e.jsx(t.Box,{sx:{height:32,display:"flex",alignItems:"center"},children:e.jsx(t.Box,{sx:{borderBottom:`1px solid ${I.custom.palette.stroke.default}`,width:"100%"}})}):h?g?e.jsx(c,{children:e.jsx(a,{component:"p",type:"button",variation:"md",sx:{color:I.custom.palette.text.secondary},children:h})}):e.jsx(l,{active:x,disabled:y,onClick:e=>{w&&w(e),v&&s?.close()},iconHeight:k,sx:{[`&.${t.buttonBaseClasses.root} .${t.typographyClasses.root}`]:{minHeight:"initial"}},children:e.jsxs(d,{sx:{width:"100%",justifyContent:"space-between",gap:1},children:[e.jsxs(d,{sx:{flex:"1 1 auto",gap:1,minWidth:0},children:[void 0!==B&&e.jsx(i.default,{name:B,...b?.startIcon}),C?e.jsx(n,{message:h,slotProps:{wrapper:{sx:{minWidth:0,overflow:"hidden",flex:"1 1 auto"}}},children:e.jsx(a,{monospaced:!0,component:"p",sx:o.mergeSx({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},u&&{color:I.custom.palette.text.negative},g&&{color:I.custom.palette.text.secondary}),type:"button",variation:"md",children:h})}):e.jsx(a,{monospaced:!0,component:"p",sx:o.mergeSx({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},u&&{color:I.custom.palette.text.negative},g&&{color:I.custom.palette.text.secondary}),type:"button",variation:"md",children:h})]}),e.jsxs(p,{iconHeight:k,minWidth:k,children:[q?.length&&q.length>0&&e.jsx(t.Grow,{in:!0,children:e.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:e.jsx(i.default,{name:"chevron-right",size:k})})}),j&&e.jsx(t.Grow,{in:!0,children:e.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:e.jsx(i.default,{name:"check",size:k})})})]})]})}):null};