UNPKG

@useloops/design-system

Version:

The official React based Loops design system

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