@tap-payments/os-micro-frontend-shared 0.3.284-test.1794820094 → 0.3.285
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_chunks/{chunk-MEM7VSBN.js → chunk-7EIZDPRX.js} +1 -1
- package/build/_chunks/{chunk-54STY6MC.js → chunk-CKJ63TJ5.js} +1 -1
- package/build/_chunks/chunk-D7SCPBNH.js +1 -0
- package/build/_chunks/chunk-E6SXZOXX.js +2 -0
- package/build/_chunks/{chunk-H2KCDUMN.js → chunk-J5Y23R6K.js} +1 -1
- package/build/_chunks/{chunk-QP4V7L7P.js → chunk-R7AVLGCS.js} +1 -1
- package/build/_chunks/{chunk-ZA7JORR7.js → chunk-VBB5WMVK.js} +1 -1
- package/build/_chunks/{chunk-SVHOBX55.js → chunk-YHRFQZCJ.js} +1 -1
- package/build/_chunks/chunk-Z2ELLNWM.js +1 -0
- package/build/components/ColumnViews/index.js +1 -1
- package/build/components/DateFilter/index.js +1 -1
- package/build/components/ExpandableChip/ExpandableChip.d.ts +4 -0
- package/build/components/ExpandableChip/constants.d.ts +44 -0
- package/build/components/ExpandableChip/hooks/useExpandableChip.d.ts +23 -0
- package/build/components/ExpandableChip/index.d.ts +3 -0
- package/build/components/ExpandableChip/index.js +1 -0
- package/build/components/{LeftPeekRightExpandingChip → ExpandableChip}/style.d.ts +564 -10
- package/build/components/ExpandableChip/type.d.ts +87 -0
- package/build/components/ExpandableChip/utils.d.ts +16 -0
- package/build/components/FilterDropdown/components/MerchantsFilterItem/type.d.ts +0 -4
- package/build/components/FilterDropdown/components/MerchantsFilterItem/utils.d.ts +2 -15
- package/build/components/FilterDropdown/index.js +1 -1
- package/build/components/ListColumnFilter/index.js +1 -1
- package/build/components/ListHeader/index.js +1 -1
- package/build/components/PhoneFilter/index.js +1 -1
- package/build/components/RangeCalender/index.js +1 -1
- package/build/components/StatusFilter/index.js +1 -1
- package/build/components/StatusIcons/index.js +1 -1
- package/build/components/TableCells/index.js +1 -1
- package/build/components/TableReports/index.js +1 -1
- package/build/components/TreeDropdown/TreeDropdown.d.ts +4 -0
- package/build/components/TreeDropdown/TreeNodeItem/SelectionControl.d.ts +8 -0
- package/build/components/TreeDropdown/TreeNodeItem/TreeNodeItem.d.ts +13 -0
- package/build/components/TreeDropdown/TreeNodeItem/index.d.ts +2 -0
- package/build/components/TreeDropdown/TreeNodeItem/style.d.ts +18 -0
- package/build/components/TreeDropdown/TreeNodeList/List.d.ts +6 -0
- package/build/components/TreeDropdown/TreeNodeList/TreeNodeList.d.ts +17 -0
- package/build/components/TreeDropdown/TreeNodeList/style.d.ts +6 -0
- package/build/components/TreeDropdown/context/TreeDropdownProvider.d.ts +15 -0
- package/build/components/TreeDropdown/hooks/useSearch.d.ts +18 -0
- package/build/components/TreeDropdown/hooks/useTreeDropdown.d.ts +12 -0
- package/build/components/TreeDropdown/index.d.ts +4 -0
- package/build/components/TreeDropdown/index.js +1 -0
- package/build/components/TreeDropdown/style.d.ts +13 -0
- package/build/components/TreeDropdown/type.d.ts +96 -0
- package/build/components/TreeDropdown/utils.d.ts +36 -0
- package/build/components/VirtualTables/index.js +1 -1
- package/build/components/WindowServices/index.js +1 -1
- package/build/components/index.d.ts +4 -4
- package/build/components/index.js +1 -1
- package/build/components/modules/JSONViewWindow/index.js +1 -1
- package/build/components/modules/RangeCalender/index.js +1 -1
- package/build/components/modules/VirtualTables/index.js +1 -1
- package/build/components/modules/WindowShell/index.js +1 -1
- package/build/components/modules/index.js +1 -1
- package/build/datetime/components/index.js +1 -1
- package/build/index.js +1 -1
- package/package.json +1 -1
- package/build/_chunks/chunk-2IOTEGXO.js +0 -2
- package/build/_chunks/chunk-VCAGS4JE.js +0 -2
- package/build/_chunks/chunk-VRPTMDSJ.js +0 -1
- package/build/_chunks/chunk-W2HSCMPT.js +0 -1
- package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.d.ts +0 -13
- package/build/components/LeftPeekRightExpandingChip/index.d.ts +0 -2
- package/build/components/LeftPeekRightExpandingChip/index.js +0 -1
- package/build/components/LeftPeekRightExpandingChip/type.d.ts +0 -7
- package/build/components/LeftPeekRightExpandingChip/useLeftPeekRightExpandingChip.d.ts +0 -26
- package/build/components/MultiLevelMenu/MultiLevelMenu.d.ts +0 -10
- package/build/components/MultiLevelMenu/MultiLevelMenuItem.d.ts +0 -6
- package/build/components/MultiLevelMenu/MultiLevelMenuPanel.d.ts +0 -6
- package/build/components/MultiLevelMenu/constants.d.ts +0 -56
- package/build/components/MultiLevelMenu/hooks/useMultiLevelMenuContext.d.ts +0 -24
- package/build/components/MultiLevelMenu/hooks/useMultiLevelMenuSearch.d.ts +0 -11
- package/build/components/MultiLevelMenu/hooks/useMultiLevelMenuSelection.d.ts +0 -25
- package/build/components/MultiLevelMenu/hooks/useSubmenu.d.ts +0 -12
- package/build/components/MultiLevelMenu/icons.d.ts +0 -7
- package/build/components/MultiLevelMenu/index.d.ts +0 -3
- package/build/components/MultiLevelMenu/index.js +0 -1
- package/build/components/MultiLevelMenu/style.d.ts +0 -58
- package/build/components/MultiLevelMenu/type.d.ts +0 -239
- package/build/components/MultiLevelMenu/utils.d.ts +0 -122
- package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.d.ts +0 -36
- package/build/components/RightLeftExpandingCenterChip/index.d.ts +0 -2
- package/build/components/RightLeftExpandingCenterChip/index.js +0 -1
- package/build/components/RightLeftExpandingCenterChip/style.d.ts +0 -3417
- package/build/components/RightLeftExpandingCenterChip/type.d.ts +0 -11
- package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.d.ts +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {p,B,d,r}from'./chunk-6GZFEPN6.js';import {l}from'./chunk-JKW2LY7R.js';import {_b,Bc,Ob}from'./chunk-Z2DUFVI5.js';import {Xe,jm,$e,Kj,Ze,_e}from'./chunk-3M2GZVQW.js';import {memo,useCallback,useState,useId,useReducer,useEffect}from'react';import {useTranslation}from'react-i18next';import {motion,AnimatePresence}from'framer-motion';import Vo from'@mui/material/CircularProgress';import U from'@mui/material/LinearProgress';import Qo from'@mui/material/Popper';import $ from'dayjs';import {styled,Box,alpha,CircularProgress}from'@mui/material';import {jsxs,jsx}from'react/jsx-runtime';import {styled as styled$1}from'@mui/material/styles';var no=styled(motion.div,{shouldForwardProp:o=>!["notificationState","open","loading","ready","failed"].includes(o)})(({theme:o,notificationState:n,open:a,loading:r,ready:p,failed:t})=>({position:"relative",border:`1px solid ${o.palette.divider}`,padding:"0 8px",height:32,borderRadius:"4px",display:"flex",alignItems:"center",overflow:"hidden",fontSize:"11px",fontWeight:500,color:o.palette.text.primary,transition:"width 2s ease-in-out",cursor:"pointer",...(n?.success||n?.failed)&&!r&&!p&&!t&&{"&:after":{content:'""',width:7,height:7,backgroundColor:n?.failed?o.palette.common.red:o.palette.success.dark,borderRadius:"50%",position:"absolute",top:5,border:`1px solid ${o.palette.common.white}`,right:6}},...a&&{border:`1px solid ${o.palette.info.dark}`,boxShadow:o.shadows[7]}})),io=styled(Box)(()=>({position:"relative"})),ao=styled(Box)(({theme:o})=>({background:o.palette.common.white,boxShadow:o.shadows[9],borderRadius:"4px",marginTop:"8px"})),po=styled(Box)(({theme:o})=>({background:o.palette.background.transparent[2],backdropFilter:"blur(2px)",color:o.palette.text.primary,fontSize:"11px",fontWeight:500,height:31,textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",borderBottomLeftRadius:"4px",borderBottomRightRadius:"4px"})),so=styled(Box)(({theme:o})=>({display:"flex",alignItems:"center",gap:"8px",padding:"5.5px 8px",minHeight:48,height:"auto",borderBottom:`1px solid ${o.palette.divider}`,cursor:"pointer","&:hover":{boxShadow:o.shadows[3]}})),lo=styled("img")(()=>({width:16,height:16,objectFit:"contain",flexShrink:0,display:"block"})),co=styled(Box)(()=>({display:"flex",flexDirection:"column",gap:"2px"})),mo=styled(Box)(()=>({display:"flex",alignItems:"center",justifyContent:"space-between",flex:1})),uo=styled(Box)(({theme:o})=>({fontSize:"11px",color:o.palette.text.primary,fontWeight:500,wordBreak:"break-all",paddingInlineEnd:"8px"})),fo=styled(Box)(({theme:o})=>({fontSize:"9px",color:o.palette.text.textSecondary,fontWeight:600})),go=styled(Box)(({theme:o})=>({display:"flex",alignItems:"center",gap:"8px",height:32,padding:"4px 8px",borderBottom:`1px solid ${o.palette.divider}`,cursor:"pointer","&:hover":{boxShadow:o.shadows[3]}})),xo=styled(Box)(({theme:o})=>({fontSize:"11px",color:o.palette.text.primary,fontWeight:400,textTransform:"uppercase"})),T=styled(Box)(({theme:o})=>({borderTop:`2px solid ${o.palette.divider}`})),M=styled(Box)(({theme:o})=>({position:"absolute",bottom:0,right:0,left:0,".MuiLinearProgress-root":{backgroundColor:o.palette.divider,height:2},".MuiLinearProgress-bar":{background:o.palette.background.gradient.shadedBlue},"&.done .MuiLinearProgress-bar":{background:o.palette.success.dark},"&.failed .MuiLinearProgress-bar":{background:o.palette.common.red}})),u=styled(Box)(({theme:o})=>({display:"flex",alignItems:"center",gap:"8px",".MuiCircularProgress-root":{width:"14px !important",height:"14px !important",display:"flex"},".MuiCircularProgress-circle":{strokeWidth:"1.017px",stroke:alpha(o.palette.common.black,.62)}})),I=styled(Box)(()=>({position:"relative"})),P=styled(Box)(({theme:o})=>({position:"absolute",color:o.palette.common.black,fontSize:"7.875px",fontWeight:700,width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center"})),k=styled("img")(()=>({width:14,height:14})),Do=styled(Box)(()=>({display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",padding:"8px"}));var yo=o=>{let n=new Date,a=$(o).isSame(n,"year"),r={sameDay:"DD MMM, YYYY",nextDay:"DD MMM, YYYY",lastDay:"DD MMM, YYYY",sameElse:"DD MMM, YYYY",lastWeek:"DD MMM, YYYY",nextWeek:"DD MMM, YYYY"};return a&&(r={sameDay:"DD MMM",nextDay:"DD MMM",lastDay:"DD MMM",sameElse:"DD MMM",lastWeek:"DD MMM",nextWeek:"DD MMM"}),$(o).calendar(null,r)},Ro=(o,n)=>{let a=new Date().toISOString().split("T")[0],r=n??`file_${a}`,t=/\.(xlx|xlsx|csv|txt|doc|docx|pdf|jpg|png|gif|zip|rar)$/i.exec(o),c=t?t[0]:".csv";return `${r}${c}`};var A={loading:false,success:false,error:null},Wo=(o=A,n)=>{switch(n.type){case "RESET":return A;case "LOADING":return {...o,loading:true};case "SUCCESS":return {...o,success:true};case "ERROR":return {...o,error:n.error};default:return o}},C=({onDownload:o})=>{let n=l(),[{loading:a,error:r,success:p},t]=useReducer(Wo,A),c=useCallback(()=>t({type:"LOADING"}),[]),m=useCallback(()=>t({type:"SUCCESS"}),[]),D=useCallback(l=>t({type:"ERROR",error:l}),[]),h=useCallback(()=>t({type:"RESET"}),[]);useEffect(()=>{(p||r)&&setTimeout(()=>{h();},3e3);},[p,r,h]);let L=useCallback(()=>{o&&(c(),o().then(l=>{m(),Ob(l.url,Ro(l.result_file,l.id));}).catch(l=>{D(l),n.error(l?.response?.data?.error?.message||l?.message||"Failed to download report");}));},[o,c,m,D]);return {loading:a,error:r,success:p,handleDownloadReport:L}};function No({onDownload:o}){let{loading:n,error:a,success:r,handleDownloadReport:p}=C({onDownload:o});return n?jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsx(u,{children:jsxs(I,{children:[jsx(P,{children:"1"}),jsx(CircularProgress,{})]})})}):r?jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsx(u,{children:jsx(k,{src:$e,alt:"done"})})}):a?jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsx(u,{children:jsx(k,{src:Kj,alt:"failed"})})}):jsx(k,{onClick:p,src:Ze,alt:"reports"})}var Y=No;function O(){return jsxs(Do,{children:[jsx(r,{width:"16px",height:"16px",variant:"rectangular"}),jsx(r,{width:"100%",variant:"text"}),jsx(r,{width:"12px",height:"12px",variant:"circular"})]})}function Uo({reports:o,isLoading:n=false,onDownloadReport:a}){let r=useCallback(t=>a?a(t):Promise.reject(new Error("No download report function provided")),[a]),p=o.map(t=>{let c=$(t.created_at).isBefore($().subtract(1,"day")),m=_b(t.result_file);return jsxs(so,{children:[jsx(lo,{src:m,alt:"download"}),jsxs(mo,{children:[jsxs(co,{children:[jsx(uo,{children:t.result_file}),jsx(fo,{children:c?yo(new Date(t.created_at)):$(new Date(t.created_at)).fromNow()})]}),jsx(Y,{onDownload:()=>r(t.id)})]})]},t.id)});return n?jsxs(T,{children:[jsx(O,{}),jsx(O,{})]}):jsx(T,{children:p})}var ho=memo(Uo);function Jo(o){let{progress:n,reportsQueryResult:a,isStatusReady:r,isStatusFailed:p$1,isLoading:t,notificationState:c,onOpenDropdown:m,onRequestReportFile:D,onOpenReportsApp:h,hideOpenReportsApp:L=false,onDownloadReport:l,customContent:Mo}=o,[H,G]=useState(null),{t:w}=useTranslation(),E=!!H,{data:Io,isLoading:Po}=a,ko=useCallback(F=>{t||r||(m?.(),G(F.currentTarget));},[t,r,m]),y=useCallback(()=>{G(null);},[]),Co=useCallback(()=>{t||(y(),D?.());},[t,y,D]),Bo=F=>{F.stopPropagation(),h?.(),y();},Lo=()=>t?jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxs(u,{children:[jsxs(I,{children:[jsx(P,{children:"1"}),jsx(Vo,{})]}),jsx("span",{children:w("preparing")}),jsx(M,{children:jsx(U,{variant:"determinate",value:n})})]})}):r?jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxs(u,{children:[jsx("img",{src:$e,alt:"done"}),jsx("span",{children:w("ready")}),jsx(M,{className:"done",children:jsx(U,{variant:"determinate",value:100})})]})}):p$1?jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxs(u,{children:[jsx("img",{src:Kj,alt:"failed"}),jsx("span",{children:w("failed")}),jsx(M,{className:"failed",children:jsx(U,{variant:"determinate",value:100})})]})}):jsx("img",{src:_e,alt:"reports"});return jsxs(io,{"data-testid":"TableReports_ReportsWrapper",children:[jsx(AnimatePresence,{children:jsx(p,{title:w("reports"),children:jsx(no,{"data-testid":"TableReports_ExportButton",onClick:ko,notificationState:c,open:E,loading:t,ready:r,failed:p$1,sx:{...(t||r||p$1)&&{borderBottom:"none"}},initial:{width:"auto"},transition:{duration:.25},children:Lo()})})}),E&&jsx(B,{onClick:y}),jsx(Qo,{open:E,anchorEl:H,placement:"bottom-end",children:jsxs(ao,{sx:{width:208},children:[Mo?.({closeDropdown:y})??jsxs(go,{onClick:Co,children:[jsx("img",{src:Xe,alt:"download"}),jsx(xo,{children:"csv"})]}),jsx(ho,{reports:Io?.reports??[],isLoading:Po,onDownloadReport:l}),!L&&jsx(po,{onClick:Bo,children:w("openReportsApp")})]})})]})}var bo=memo(Jo);var vo=styled$1(motion.div)(({theme:o})=>({display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",width:54,height:18,backgroundColor:"#1F88D0",borderRadius:"2px",fontSize:"8px",fontWeight:600,color:o.palette.common.white}));function nt({onDownload:o}){let n=Bc(useId(),"download-button"),{loading:a,error:r,success:p,handleDownloadReport:t}=C({onDownload:o}),{t:c}=useTranslation(),m=!a&&!r&&!p;return jsx(vo,{id:n,"data-testid":"DownloadButton",onClick:t,children:jsxs(AnimatePresence,{mode:"wait",initial:false,children:[a&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:{display:"flex",alignItems:"center"},children:jsx(Vo,{size:"10px",sx:{color:"rgba(255, 255, 255, 0.62)"}})},"loading"),!!r&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsx(d,{src:jm,sx:{width:"auto",height:"auto"},alt:"error"})},"error"),m&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:c("download")},"text")]})})}var So=memo(nt);var at=So;var fe=bo;export{C as a,Y as b,at as c,fe as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h as h$1,i,b as b$1,c as c$2,f as f$2,e,d as d$1,j as j$1}from'./chunk-WRJLCKDU.js';import {f,g,h as h$2,i as i$1,b}from'./chunk-KZIIULI3.js';import {d,c as c$1}from'./chunk-ZA7JORR7.js';import {h,c,f as f$1}from'./chunk-ISC5KT5E.js';import {mc,nc}from'./chunk-Z2DUFVI5.js';import'./chunk-3M2GZVQW.js';import {memo,forwardRef,useState,useEffect,useRef}from'react';import {createPortal}from'react-dom';import oo from'@mui/material/Backdrop';import {styled,alpha}from'@mui/material/styles';import v from'@mui/material/Box';import {motion,animate}from'framer-motion';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var H="os-shared-WindowShell",x={root:`${H}-root`,sidebar:`${H}-sidebar`,body:`${H}-body`,panel:`${H}-panel`};var we=styled(v)(()=>({display:"flex",flexDirection:"row",flex:1,minHeight:0,height:"100%",backgroundColor:"transparent"})),xe=styled(v)(()=>({flexShrink:0,overflow:"hidden auto",backgroundColor:"transparent",transition:"none"})),be=styled(v)(({theme:e})=>({flexShrink:0,overflow:"hidden auto",borderLeft:`1px solid ${e.palette.divider}`,backgroundColor:"transparent",transition:"none"})),ye=styled(v)(()=>({display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0})),ze=styled(v,{shouldForwardProp:e=>e!=="$width"})(({$width:e})=>({flexShrink:0,overflow:"hidden",display:"flex",alignItems:"stretch",position:"relative",width:e})),Ne=styled(motion.div)(()=>({flexShrink:0,overflow:"hidden",display:"flex",alignItems:"stretch",position:"relative"})),Ce=styled(motion.div,{shouldForwardProp:e=>e!=="$slotWidth"})(({$slotWidth:e})=>({width:e,minWidth:e,minHeight:"100%",height:"100%",overflow:"hidden"})),Ie=styled(v,{shouldForwardProp:e=>e!=="$visible"&&e!=="$duration"})(({$visible:e=true,$duration:o=h})=>({display:"flex",alignItems:"center",overflow:"hidden",whiteSpace:"nowrap",flexShrink:0,maxWidth:e?160:0,opacity:e?1:0,pointerEvents:e?"auto":"none",transition:o>0?`max-width ${.3*o}s ease-in-out, opacity ${.24*o}s ease-in-out`:"none"})),Te=styled(h$1,{shouldForwardProp:e=>e!=="$width"})(({$width:e})=>({...e!=null?{flex:`0 0 ${e}px`,maxWidth:e}:null})),Pe=styled(i,{shouldForwardProp:e=>e!=="$width"&&e!=="$justifyContent"})(({$width:e,$justifyContent:o="flex-start"})=>({...e!=null?{flex:`0 0 ${e}px`,maxWidth:e,justifyContent:o}:null}));var Ue=220;function ge(e,o,a){return Math.min(Math.max(e,o??0),a??1/0)}function Ae(e,o,a,n){if(Math.abs(e-o)<=1)return;let r=animate(0,1,{duration:a,onUpdate:t=>{n(s=>({...s,width:e+(o-e)*t}));}});return ()=>r.stop()}function G(e,o){if(e===false)return {duration:0,resize:o};let a=typeof e=="object"?e:void 0,n=a?.duration;return {duration:typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):h,resize:a?.resize??o}}function j(e){return e?.children==null||e.expand?.isExpanded===false?false:e.expand?.isExpanded===true}function F(e,o=Ue){let a=Array.isArray(e)?e.flat():[e];for(let n=a.length-1;n>=0;n--){let r=a[n];if(r!=null&&typeof r=="object"&&!Array.isArray(r)&&typeof r.width=="number")return r.width}return o}function Ee(e){let o=e["data-id"]??e.id;return o!=null?{"data-id":o}:{}}function Me({kind:e,slot:o,isOpen:a,fullWidth:n,wrapperWidth:r,animateWrapperWidth:t,animation:s}){let p=e==="sidebar"?xe:be,d=e==="sidebar"?x.sidebar:x.panel,m=o["data-testid"]?`${o["data-testid"]}Wrapper`:e==="sidebar"?"WindowShellSidebarWrapper":"WindowShellPanelWrapper",i=o["data-testid"]??o.id??(e==="sidebar"?"WindowShellSidebar":"WindowShellPanel"),l=Ee(o),u=jsx(p,{id:o.id,className:nc(d,o.className),"data-testid":i,...l,sx:mc({width:n,minWidth:0},o.sx),children:jsx(Ce,{$slotWidth:n,initial:false,animate:{x:a?0:-n},transition:{duration:s.duration},children:o.children})});return t?jsx(Ne,{"data-testid":m,...l,initial:false,animate:{width:r},transition:{duration:s.duration},children:u}):jsx(ze,{"data-testid":m,...l,$width:r,children:u})}Me.displayName="WindowShellSlotColumn";var J=memo(Me);function De({baseWindowWidth:e,sidebar:o,panel:a,content:n,bodyContent:r,sidebarOpen:t,showPanel:s,sidebarFullWidth:p,panelFullWidth:d,sidebarAnimation:m,panelAnimation:i}){let{size:l}=b(),u=i.resize==="window",W=typeof e=="number"?Math.max(0,e-(u?d:0)-(m.resize==="window"&&!t?p:0)):l.width,b$1=u?s?Math.min(d,Math.max(0,l.width-W)):0:s?d:0,y=t?p:0;return jsxs(we,{className:nc(x.root),children:[o?.children?jsx(J,{kind:"sidebar",slot:o,isOpen:t,fullWidth:p,wrapperWidth:y,animateWrapperWidth:true,animation:m}):null,jsx(ye,{id:n?.id?`${n.id}Body`:void 0,className:nc(x.body,n?.className),"data-testid":n?.["data-testid"]?`${n["data-testid"]}Body`:n?.id?`${n.id}Body`:"WindowShellBody",...(n?.["data-id"]??n?.id)!=null?{"data-id":n?.["data-id"]?`${n["data-id"]}Body`:`${n?.id}Body`}:null,sx:n?.sx,children:r}),a?.children?jsx(J,{kind:"panel",slot:a,isOpen:s,fullWidth:d,wrapperWidth:b$1,animateWrapperWidth:!u,animation:i}):null]})}De.displayName="WindowShellSlotsLayout";var Re=memo(De);function $e({sidebarOpen:e,showPanel:o,sidebarResize:a,panelResize:n,sidebarDuration:r,panelDuration:t}){let{size:s,setSize:p,defaultSize:d,minSize:m,maxSize:i}=b(),l=useRef(s);l.current=s;let u=useRef(d.width),W=useRef(e),b$1=useRef(o),y=useRef(d.width);return useEffect(()=>{let C=b$1.current!==o,w=W.current!==e,E=y.current!==d.width;b$1.current=o,W.current=e,y.current=d.width;let S;if(w&&a==="window"?S=r:(C&&n==="window"||E&&!C&&!w)&&(S=t),S==null)return;let h=ge(d.width,m?.width,i?.width);return u.current=h,Ae(l.current.width,h,S,p)},[d.width,o,e,a,n,r,t,m?.width,i?.width,p]),null}$e.displayName="WindowShellAnimator";var Oe=memo($e);function ve({toolbar:e$1,sidebar:o,panel:a,animationDuration:n=h}){let{title:r,titleIcon:t,onClose:s,onMinimize:p,onMaximize:d,startAdornment:m,endAdornment:i,id:l,className:u,"data-testid":W,"data-id":b$2,sx:y}=e$1??{},{isMaximized:C}=b(),w=typeof s=="function"?s:void 0,E=typeof p=="function"?p:void 0,S=typeof d=="function"?d:void 0,h=o?.expand,c=a?.expand,z=j(a),L=h?.isExpanded??true,M=h!=null&&o?.children!=null,D=c!=null&&a?.children!=null&&z,k=M&&D,V=F(a?.sx),_=o!=null?F(o.sx):0,I=Math.max(_,V),T=k&&L?I:void 0,Z=D?I:void 0,X=D;return jsxs(b$1,{id:l??f$1,className:u,"data-testid":W??l??"WindowToolbar","data-id":b$2??l,sx:y,children:[jsxs(Te,{$width:T,children:[w?jsx(c$2,{onClick:w}):null,E?jsx(f$2,{onClick:E}):null,S?jsx(e,{isMaximized:C,onClick:S}):null,M&&h?jsx(d$1,{direction:h.isExpanded??true?"left":"right",active:h.isExpanded??true,onClick:h.onExpand,children:h.label}):null,m]}),jsx(j$1,{title:r,icon:t}),jsxs(Pe,{$width:Z,$justifyContent:i?"space-between":"flex-start",children:[D?jsx(Ie,{$visible:X,$duration:n,children:jsx(d$1,{sx:{flexShrink:0},direction:c?.isExpanded??true?"left":"right",active:z,onClick:c?.onExpand,children:c?.label})}):null,i]})]})}ve.displayName="WindowShellToolbar";var Fe=memo(ve);var Be=forwardRef(function({isOpen:o,className:a,sx:n,toolbar:r,services:t,sidebar:s,panel:p,footer:d$1,content:m,window:i,backdrop:l},u){let W=t?.list??[],b=(t?.isLoading??false)||W.length>0,y=d$1!=null&&(d$1.isVisible??true),C=s?.children,w=F(s?.sx),E=p?.children,S=p!=null?F(p.sx):0,h=m?.children,c$2=s?.expand?.isExpanded??C!=null,z=j(p),L=!!(C||E),[M,D]=useState(w),[k,V]=useState(S);useEffect(()=>{c$2&&D(w),z&&V(S);},[c$2,w,z,S]);let _=r?.onClose??r?.onMinimize??(()=>{}),I=G(s?.animation,"in-place"),T=G(p?.animation,"in-place"),Z=(()=>{let P=i?.defaultSize;if(typeof P?.width!="number")return P;let oe=(I.resize==="window"&&!c$2?M:0)+(T.resize==="window"&&!z?k:0);return oe>0?{...P,width:Math.max(0,P.width-oe)}:P})(),X={height:i?.minSize?.height??i?.defaultSize?.height??c,...i?.minSize?.width!=null?{width:i.minSize.width}:null},Le=l!=null&&(l.isVisible??true)&&o&&!i?.isMinimized,_e=(i?.order??0)+10-1,ee=jsx(oo,{open:true,onClick:_,id:l?.id,className:l?.className,"data-testid":l?.["data-testid"]??l?.id??"WindowShellBackdrop",...(l?.["data-id"]??l?.id)!=null?{"data-id":l?.["data-id"]??l?.id}:null,sx:mc({zIndex:_e,backgroundColor:P=>alpha(P.palette.common.black,.3)},l?.sx)});return jsxs(Fragment,{children:[Le&&(i?.disablePortal?ee:createPortal(ee,document.body)),jsxs(f,{ref:u,isOpen:o,onClose:_,defaultSize:Z,minSize:X,maxSize:i?.maxSize,defaultPosition:i?.defaultPosition,containerRef:i?.containerRef,order:i?.order,isMinimized:i?.isMinimized,isMaximized:i?.isMaximized,id:i?.id,className:nc(x.root,i?.className,a),sx:n,onResize:i?.onResize,onDragStart:i?.onDragStart,onMouseDown:i?.onMouseDown,onClick:i?.onClick,disablePortal:i?.disablePortal,"data-testid":i?.["data-testid"]??i?.id,"data-id":i?.["data-id"]??i?.id,children:[jsx(Oe,{sidebarOpen:c$2,showPanel:z,sidebarWidth:M,panelWidth:k,sidebarResize:I.resize,panelResize:T.resize,sidebarDuration:I.duration,panelDuration:T.duration}),jsx(Fe,{toolbar:r,sidebar:s,panel:p,animationDuration:T.duration}),b?t?.isLoading?jsx(d,{appCode:t?.appCode,id:t?.id,className:t?.className,"data-testid":t?.["data-testid"]??t?.id,"data-id":t?.["data-id"]??t?.id,sx:mc({height:"auto",flexShrink:0},t?.sx)}):jsx(c$1,{services:W,serviceCode:t?.activeCode??"",onOpenService:t?.onOpen,onOpenServiceInNewWindow:t?.onOpenInNewWindow,language:t?.language??"en",openInNewWindowLabel:t?.openInNewWindowLabel??"Open in new window",id:t?.id,className:t?.className,"data-testid":t?.["data-testid"]??t?.id,"data-id":t?.["data-id"]??t?.id,sx:t?.sx}):null,jsx(g,{id:m?.id,className:m?.className,"data-testid":m?.["data-testid"]??m?.id,"data-id":m?.["data-id"]??m?.id,sx:L?void 0:m?.sx,children:L?jsx(Re,{baseWindowWidth:typeof i?.defaultSize?.width=="number"?i.defaultSize.width:void 0,sidebar:s,panel:p,content:m,bodyContent:h,sidebarOpen:c$2,showPanel:z,sidebarFullWidth:M,panelFullWidth:k,sidebarAnimation:I,panelAnimation:T}):h}),y?jsxs(h$2,{id:d$1?.id,className:d$1?.className,"data-testid":d$1?.["data-testid"]??d$1?.id,"data-id":d$1?.["data-id"]??d$1?.id,sx:d$1?.isVisible===true?mc(d$1?.sx??{},{"&:empty, &:has(> :only-child:empty)":{display:"flex"}}):d$1?.sx,children:[d$1?.children,d$1?.actions?jsx(i$1,{children:d$1.actions}):null]}):null]})]})});Be.displayName="WindowShell";var to=memo(Be);export{x as a,to as b};
|
|
1
|
+
import {f,g,h as h$2,i as i$1,b}from'./chunk-KZIIULI3.js';import {d,c as c$1}from'./chunk-VBB5WMVK.js';import {h as h$1,i,b as b$1,c as c$2,f as f$2,e,d as d$1,j as j$1}from'./chunk-WRJLCKDU.js';import {h,c,f as f$1}from'./chunk-ISC5KT5E.js';import {mc,nc}from'./chunk-Z2DUFVI5.js';import'./chunk-3M2GZVQW.js';import {memo,forwardRef,useState,useEffect,useRef}from'react';import {createPortal}from'react-dom';import oo from'@mui/material/Backdrop';import {styled,alpha}from'@mui/material/styles';import v from'@mui/material/Box';import {motion,animate}from'framer-motion';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var H="os-shared-WindowShell",x={root:`${H}-root`,sidebar:`${H}-sidebar`,body:`${H}-body`,panel:`${H}-panel`};var we=styled(v)(()=>({display:"flex",flexDirection:"row",flex:1,minHeight:0,height:"100%",backgroundColor:"transparent"})),xe=styled(v)(()=>({flexShrink:0,overflow:"hidden auto",backgroundColor:"transparent",transition:"none"})),be=styled(v)(({theme:e})=>({flexShrink:0,overflow:"hidden auto",borderLeft:`1px solid ${e.palette.divider}`,backgroundColor:"transparent",transition:"none"})),ye=styled(v)(()=>({display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0})),ze=styled(v,{shouldForwardProp:e=>e!=="$width"})(({$width:e})=>({flexShrink:0,overflow:"hidden",display:"flex",alignItems:"stretch",position:"relative",width:e})),Ne=styled(motion.div)(()=>({flexShrink:0,overflow:"hidden",display:"flex",alignItems:"stretch",position:"relative"})),Ce=styled(motion.div,{shouldForwardProp:e=>e!=="$slotWidth"})(({$slotWidth:e})=>({width:e,minWidth:e,minHeight:"100%",height:"100%",overflow:"hidden"})),Ie=styled(v,{shouldForwardProp:e=>e!=="$visible"&&e!=="$duration"})(({$visible:e=true,$duration:o=h})=>({display:"flex",alignItems:"center",overflow:"hidden",whiteSpace:"nowrap",flexShrink:0,maxWidth:e?160:0,opacity:e?1:0,pointerEvents:e?"auto":"none",transition:o>0?`max-width ${.3*o}s ease-in-out, opacity ${.24*o}s ease-in-out`:"none"})),Te=styled(h$1,{shouldForwardProp:e=>e!=="$width"})(({$width:e})=>({...e!=null?{flex:`0 0 ${e}px`,maxWidth:e}:null})),Pe=styled(i,{shouldForwardProp:e=>e!=="$width"&&e!=="$justifyContent"})(({$width:e,$justifyContent:o="flex-start"})=>({...e!=null?{flex:`0 0 ${e}px`,maxWidth:e,justifyContent:o}:null}));var Ue=220;function ge(e,o,a){return Math.min(Math.max(e,o??0),a??1/0)}function Ae(e,o,a,n){if(Math.abs(e-o)<=1)return;let r=animate(0,1,{duration:a,onUpdate:t=>{n(s=>({...s,width:e+(o-e)*t}));}});return ()=>r.stop()}function G(e,o){if(e===false)return {duration:0,resize:o};let a=typeof e=="object"?e:void 0,n=a?.duration;return {duration:typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):h,resize:a?.resize??o}}function j(e){return e?.children==null||e.expand?.isExpanded===false?false:e.expand?.isExpanded===true}function F(e,o=Ue){let a=Array.isArray(e)?e.flat():[e];for(let n=a.length-1;n>=0;n--){let r=a[n];if(r!=null&&typeof r=="object"&&!Array.isArray(r)&&typeof r.width=="number")return r.width}return o}function Ee(e){let o=e["data-id"]??e.id;return o!=null?{"data-id":o}:{}}function Me({kind:e,slot:o,isOpen:a,fullWidth:n,wrapperWidth:r,animateWrapperWidth:t,animation:s}){let p=e==="sidebar"?xe:be,d=e==="sidebar"?x.sidebar:x.panel,m=o["data-testid"]?`${o["data-testid"]}Wrapper`:e==="sidebar"?"WindowShellSidebarWrapper":"WindowShellPanelWrapper",i=o["data-testid"]??o.id??(e==="sidebar"?"WindowShellSidebar":"WindowShellPanel"),l=Ee(o),u=jsx(p,{id:o.id,className:nc(d,o.className),"data-testid":i,...l,sx:mc({width:n,minWidth:0},o.sx),children:jsx(Ce,{$slotWidth:n,initial:false,animate:{x:a?0:-n},transition:{duration:s.duration},children:o.children})});return t?jsx(Ne,{"data-testid":m,...l,initial:false,animate:{width:r},transition:{duration:s.duration},children:u}):jsx(ze,{"data-testid":m,...l,$width:r,children:u})}Me.displayName="WindowShellSlotColumn";var J=memo(Me);function De({baseWindowWidth:e,sidebar:o,panel:a,content:n,bodyContent:r,sidebarOpen:t,showPanel:s,sidebarFullWidth:p,panelFullWidth:d,sidebarAnimation:m,panelAnimation:i}){let{size:l}=b(),u=i.resize==="window",W=typeof e=="number"?Math.max(0,e-(u?d:0)-(m.resize==="window"&&!t?p:0)):l.width,b$1=u?s?Math.min(d,Math.max(0,l.width-W)):0:s?d:0,y=t?p:0;return jsxs(we,{className:nc(x.root),children:[o?.children?jsx(J,{kind:"sidebar",slot:o,isOpen:t,fullWidth:p,wrapperWidth:y,animateWrapperWidth:true,animation:m}):null,jsx(ye,{id:n?.id?`${n.id}Body`:void 0,className:nc(x.body,n?.className),"data-testid":n?.["data-testid"]?`${n["data-testid"]}Body`:n?.id?`${n.id}Body`:"WindowShellBody",...(n?.["data-id"]??n?.id)!=null?{"data-id":n?.["data-id"]?`${n["data-id"]}Body`:`${n?.id}Body`}:null,sx:n?.sx,children:r}),a?.children?jsx(J,{kind:"panel",slot:a,isOpen:s,fullWidth:d,wrapperWidth:b$1,animateWrapperWidth:!u,animation:i}):null]})}De.displayName="WindowShellSlotsLayout";var Re=memo(De);function $e({sidebarOpen:e,showPanel:o,sidebarResize:a,panelResize:n,sidebarDuration:r,panelDuration:t}){let{size:s,setSize:p,defaultSize:d,minSize:m,maxSize:i}=b(),l=useRef(s);l.current=s;let u=useRef(d.width),W=useRef(e),b$1=useRef(o),y=useRef(d.width);return useEffect(()=>{let C=b$1.current!==o,w=W.current!==e,E=y.current!==d.width;b$1.current=o,W.current=e,y.current=d.width;let S;if(w&&a==="window"?S=r:(C&&n==="window"||E&&!C&&!w)&&(S=t),S==null)return;let h=ge(d.width,m?.width,i?.width);return u.current=h,Ae(l.current.width,h,S,p)},[d.width,o,e,a,n,r,t,m?.width,i?.width,p]),null}$e.displayName="WindowShellAnimator";var Oe=memo($e);function ve({toolbar:e$1,sidebar:o,panel:a,animationDuration:n=h}){let{title:r,titleIcon:t,onClose:s,onMinimize:p,onMaximize:d,startAdornment:m,endAdornment:i,id:l,className:u,"data-testid":W,"data-id":b$2,sx:y}=e$1??{},{isMaximized:C}=b(),w=typeof s=="function"?s:void 0,E=typeof p=="function"?p:void 0,S=typeof d=="function"?d:void 0,h=o?.expand,c=a?.expand,z=j(a),L=h?.isExpanded??true,M=h!=null&&o?.children!=null,D=c!=null&&a?.children!=null&&z,k=M&&D,V=F(a?.sx),_=o!=null?F(o.sx):0,I=Math.max(_,V),T=k&&L?I:void 0,Z=D?I:void 0,X=D;return jsxs(b$1,{id:l??f$1,className:u,"data-testid":W??l??"WindowToolbar","data-id":b$2??l,sx:y,children:[jsxs(Te,{$width:T,children:[w?jsx(c$2,{onClick:w}):null,E?jsx(f$2,{onClick:E}):null,S?jsx(e,{isMaximized:C,onClick:S}):null,M&&h?jsx(d$1,{direction:h.isExpanded??true?"left":"right",active:h.isExpanded??true,onClick:h.onExpand,children:h.label}):null,m]}),jsx(j$1,{title:r,icon:t}),jsxs(Pe,{$width:Z,$justifyContent:i?"space-between":"flex-start",children:[D?jsx(Ie,{$visible:X,$duration:n,children:jsx(d$1,{sx:{flexShrink:0},direction:c?.isExpanded??true?"left":"right",active:z,onClick:c?.onExpand,children:c?.label})}):null,i]})]})}ve.displayName="WindowShellToolbar";var Fe=memo(ve);var Be=forwardRef(function({isOpen:o,className:a,sx:n,toolbar:r,services:t,sidebar:s,panel:p,footer:d$1,content:m,window:i,backdrop:l},u){let W=t?.list??[],b=(t?.isLoading??false)||W.length>0,y=d$1!=null&&(d$1.isVisible??true),C=s?.children,w=F(s?.sx),E=p?.children,S=p!=null?F(p.sx):0,h=m?.children,c$2=s?.expand?.isExpanded??C!=null,z=j(p),L=!!(C||E),[M,D]=useState(w),[k,V]=useState(S);useEffect(()=>{c$2&&D(w),z&&V(S);},[c$2,w,z,S]);let _=r?.onClose??r?.onMinimize??(()=>{}),I=G(s?.animation,"in-place"),T=G(p?.animation,"in-place"),Z=(()=>{let P=i?.defaultSize;if(typeof P?.width!="number")return P;let oe=(I.resize==="window"&&!c$2?M:0)+(T.resize==="window"&&!z?k:0);return oe>0?{...P,width:Math.max(0,P.width-oe)}:P})(),X={height:i?.minSize?.height??i?.defaultSize?.height??c,...i?.minSize?.width!=null?{width:i.minSize.width}:null},Le=l!=null&&(l.isVisible??true)&&o&&!i?.isMinimized,_e=(i?.order??0)+10-1,ee=jsx(oo,{open:true,onClick:_,id:l?.id,className:l?.className,"data-testid":l?.["data-testid"]??l?.id??"WindowShellBackdrop",...(l?.["data-id"]??l?.id)!=null?{"data-id":l?.["data-id"]??l?.id}:null,sx:mc({zIndex:_e,backgroundColor:P=>alpha(P.palette.common.black,.3)},l?.sx)});return jsxs(Fragment,{children:[Le&&(i?.disablePortal?ee:createPortal(ee,document.body)),jsxs(f,{ref:u,isOpen:o,onClose:_,defaultSize:Z,minSize:X,maxSize:i?.maxSize,defaultPosition:i?.defaultPosition,containerRef:i?.containerRef,order:i?.order,isMinimized:i?.isMinimized,isMaximized:i?.isMaximized,id:i?.id,className:nc(x.root,i?.className,a),sx:n,onResize:i?.onResize,onDragStart:i?.onDragStart,onMouseDown:i?.onMouseDown,onClick:i?.onClick,disablePortal:i?.disablePortal,"data-testid":i?.["data-testid"]??i?.id,"data-id":i?.["data-id"]??i?.id,children:[jsx(Oe,{sidebarOpen:c$2,showPanel:z,sidebarWidth:M,panelWidth:k,sidebarResize:I.resize,panelResize:T.resize,sidebarDuration:I.duration,panelDuration:T.duration}),jsx(Fe,{toolbar:r,sidebar:s,panel:p,animationDuration:T.duration}),b?t?.isLoading?jsx(d,{appCode:t?.appCode,id:t?.id,className:t?.className,"data-testid":t?.["data-testid"]??t?.id,"data-id":t?.["data-id"]??t?.id,sx:mc({height:"auto",flexShrink:0},t?.sx)}):jsx(c$1,{services:W,serviceCode:t?.activeCode??"",onOpenService:t?.onOpen,onOpenServiceInNewWindow:t?.onOpenInNewWindow,language:t?.language??"en",openInNewWindowLabel:t?.openInNewWindowLabel??"Open in new window",id:t?.id,className:t?.className,"data-testid":t?.["data-testid"]??t?.id,"data-id":t?.["data-id"]??t?.id,sx:t?.sx}):null,jsx(g,{id:m?.id,className:m?.className,"data-testid":m?.["data-testid"]??m?.id,"data-id":m?.["data-id"]??m?.id,sx:L?void 0:m?.sx,children:L?jsx(Re,{baseWindowWidth:typeof i?.defaultSize?.width=="number"?i.defaultSize.width:void 0,sidebar:s,panel:p,content:m,bodyContent:h,sidebarOpen:c$2,showPanel:z,sidebarFullWidth:M,panelFullWidth:k,sidebarAnimation:I,panelAnimation:T}):h}),y?jsxs(h$2,{id:d$1?.id,className:d$1?.className,"data-testid":d$1?.["data-testid"]??d$1?.id,"data-id":d$1?.["data-id"]??d$1?.id,sx:d$1?.isVisible===true?mc(d$1?.sx??{},{"&:empty, &:has(> :only-child:empty)":{display:"flex"}}):d$1?.sx,children:[d$1?.children,d$1?.actions?jsx(i$1,{children:d$1.actions}):null]}):null]})]})});Be.displayName="WindowShell";var to=memo(Be);export{x as a,to as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {nc}from'./chunk-Z2DUFVI5.js';import {forwardRef,memo,useMemo,useState,useRef,useCallback,useEffect,useLayoutEffect}from'react';import {motion,AnimatePresence,useReducedMotion,useMotionValue,animate}from'framer-motion';import $e from'@mui/material/Box';import {styled}from'@mui/material/styles';import {jsx,jsxs}from'react/jsx-runtime';var B="os-shared-ExpandableChip",x={root:`${B}-root`,mainGroup:`${B}-mainGroup`,main:`${B}-main`,adornment:`${B}-adornment`,item:`${B}-item`,peek:`${B}-peek`},p=24,ee=3,te=6,v=5,se=.2,de=.18,pe=1e3,le="default",j={default:{duration:.25,stagger:.04,ease:"easeOut",closeDelay:120,chipPaddingX:8},stacked:{duration:.18,stagger:0,ease:"easeOut",closeDelay:120,chipPaddingX:6}},ce={duration:0,stagger:0};function Ee(e,t,n){let a=j[e],o=t||{},r={duration:o.duration??a.duration,stagger:o.stagger??a.stagger,ease:o.ease??a.ease,closeDelay:o.closeDelay??a.closeDelay};return t===false||n?{...r,...ce}:r}function ue(e,t){return e===t?true:e.length!==t.length?false:e.every((n,a)=>n===t[a])}function xe(e,t){return e.mainWidth===t.mainWidth&&e.startAdornmentWidth===t.startAdornmentWidth&&e.endAdornmentWidth===t.endAdornmentWidth&&ue(e.startWidths,t.startWidths)&&ue(e.endWidths,t.endWidths)}function Ce(e,t){return Math.max(p,Math.ceil(e+t*2+2))}function he(e){let t=[],n=0;for(let a of e)n+=a+ee,t.push(n);return t}function me(e,t){return e==="stacked"?te*t:0}function We({expandFrom:e,variant:t,measurements:n,startSpan:a,endSpan:o}){let{startWidths:r,endWidths:c,startAdornmentWidth:S,endAdornmentWidth:I}=n;return e==="start"?S+a-me(t,r.length):e==="end"?me(t,c.length)-I-o:0}function be({expandFrom:e,variant:t,measurements:n}){let{mainWidth:a,startWidths:o,endWidths:r,startAdornmentWidth:c,endAdornmentWidth:S}=n,I=p,M=te,b=ee,X=t==="stacked",u=he(o),f=he(r),W=u[u.length-1]??0,D=f[f.length-1]??0,i=We({expandFrom:e,variant:t,measurements:n,startSpan:W,endSpan:D}),s=i-c,y=i+a+S,h=o.map((m,l)=>({closedX:X?-M*(l+1):0,openX:s-u[l],width:m,zIndex:o.length-l})),A=r.map((m,l)=>({closedX:X?a+M*(l+1)-I:a-m,openX:y+b+(f[l]-m-b),width:m,zIndex:r.length-l})),H=Math.min(s-W,0),P=Math.max(y+D,a);return {start:h,end:A,mainShiftX:i,openSpan:{left:H-b,width:P-H+b*2}}}var Oe={mainWidth:p,startWidths:[],endWidths:[],startAdornmentWidth:0,endAdornmentWidth:0};function ge({main:e,startItems:t=[],endItems:n=[],startAdornment:a,endAdornment:o,expandFrom:r,variant:c=le,transition:S,open:I,defaultOpen:M=false,onOpenChange:b}){let X=useReducedMotion()??false,u=useMemo(()=>Ee(c,S,X),[c,S,X]),f=j[c],[W,D]=useState(M),i=I!==void 0,s=i?I:W,y=useRef(null),h=useCallback(()=>{y.current&&clearTimeout(y.current),y.current=null;},[]),A=useCallback(d=>{i||D(d),b?.(d);},[i,b]),H=useCallback(()=>{h(),s||A(true);},[h,s,A]),P=useCallback(()=>{h(),y.current=setTimeout(()=>A(false),u.closeDelay);},[h,u.closeDelay,A]);useEffect(()=>h,[h]);let m=useRef(null),l=useRef([]),F=useRef([]),z=useRef(null),U=useRef(null),[N,J]=useState(Oe),g=useCallback(()=>{let d=(L,k)=>Array.from({length:k},(G,_)=>Ce(L[_]?.offsetWidth??0,f.chipPaddingX)),T={mainWidth:m.current?.offsetWidth??p,startWidths:d(l.current,t.length),endWidths:d(F.current,n.length),startAdornmentWidth:a?z.current?.scrollWidth??0:0,endAdornmentWidth:o?U.current?.scrollWidth??0:0};J(L=>xe(L,T)?L:T);},[f.chipPaddingX,t.length,n.length,a,o]);useLayoutEffect(()=>{g();},[g,e,t,n,a,o]),useEffect(()=>{if(typeof ResizeObserver>"u")return;let d=null,T=new ResizeObserver(()=>{d&&cancelAnimationFrame(d),d=requestAnimationFrame(g);});return [m.current,z.current,U.current,...l.current,...F.current].forEach(k=>k&&T.observe(k)),()=>{d&&cancelAnimationFrame(d),T.disconnect();}},[g,t.length,n.length]);let Q=useMemo(()=>be({expandFrom:r,variant:c,measurements:N}),[r,c,N]),O=useMotionValue(0),$=useMotionValue(0),R=u.duration===0?0:se;return useEffect(()=>{let d=animate(O,s?N.startAdornmentWidth:0,{duration:R,ease:"easeOut"});return ()=>d.stop()},[s,N.startAdornmentWidth,O,R]),useEffect(()=>{let d=animate($,s?N.endAdornmentWidth:0,{duration:R,ease:"easeOut"});return ()=>d.stop()},[s,N.endAdornmentWidth,$,R]),{isOpen:s,motion:u,variant:c,chipPaddingX:f.chipPaddingX,handleOpen:H,handleClose:P,layout:Q,mainRef:m,startContentRefs:l,endContentRefs:F,startAdornmentRef:z,endAdornmentRef:U,startAdornmentWidth:O,endAdornmentWidth:$}}var V=e=>typeof e=="string"&&!e.startsWith("$")&&e!=="sx"&&e!=="theme"&&e!=="ownerState"&&e!=="as";function Y(e){let{base:t,border:n,foreground:a}=e.v2.palette;return {boxSizing:"border-box",height:e.v2.spacing(p),minWidth:e.v2.spacing(p),display:"inline-flex",alignItems:"center",justifyContent:"center",border:`${e.v2.spacing(1)} solid ${n.default}`,borderRadius:e.v2.radius(p/2),backgroundColor:t.white,color:a.primary,...e.v2.typography.textVariants.body.medium.regular,lineHeight:1,whiteSpace:"nowrap"}}var _e=styled($e,{shouldForwardProp:V})(({$isOpen:e})=>({position:"relative",display:"flex",alignItems:"center",overflow:"visible",zIndex:e?pe:void 0})),Se=styled("div")({position:"relative",display:"inline-flex",alignItems:"center",height:p}),Ie=styled(motion.div)({position:"absolute",top:0,bottom:0,background:"transparent"}),Ne=styled(motion.div)({position:"relative",display:"inline-flex",alignItems:"center"}),Xe=styled("div",{shouldForwardProp:V})(({theme:e,$paddingX:t,$fuseStart:n,$fuseEnd:a,$zIndex:o})=>{let r=e.v2.radius(p/2);return {...Y(e),position:"relative",zIndex:o,flex:"0 0 auto",paddingInline:e.v2.spacing(t),overflow:"hidden",borderTopLeftRadius:n?0:r,borderBottomLeftRadius:n?0:r,borderTopRightRadius:a?0:r,borderBottomRightRadius:a?0:r,...n&&{borderLeftColor:"transparent"},...a&&{borderRightColor:"transparent"}}}),ne=styled(motion.span,{shouldForwardProp:V})(({theme:e,$side:t})=>{let n=e.v2.radius(p/2),a=t==="start";return {...Y(e),position:"absolute",top:0,zIndex:1,minWidth:0,justifyContent:"flex-start",overflow:"hidden",willChange:"width",...a?{right:"100%",borderRight:"none",borderRadius:`${n} 0 0 ${n}`}:{left:"100%",borderLeft:"none",borderRadius:`0 ${n} ${n} 0`}}}),ae=styled("span")({display:"inline-flex",alignItems:"center",height:"100%",whiteSpace:"nowrap"}),ie=styled(motion.div,{shouldForwardProp:V})(({theme:e,$side:t})=>({...Y(e),position:"absolute",top:0,zIndex:0,pointerEvents:"none",...t==="start"?{left:0}:{right:0}})),Re=styled(motion.div,{shouldForwardProp:V})(({theme:e,$paddingX:t})=>({...Y(e),position:"absolute",top:0,left:0,justifyContent:"flex-start",paddingInline:e.v2.spacing(t),overflow:"hidden"})),Te=styled("span",{shouldForwardProp:V})(({$isHidden:e})=>({display:"inline-flex",alignItems:"center",flex:"none",whiteSpace:"nowrap",visibility:e?"hidden":"visible"}));var Ve=forwardRef(function({main:t,startItems:n=[],endItems:a=[],startAdornment:o,endAdornment:r,variant:c,expandFrom:S="center",transition:I,open:M,defaultOpen:b,onOpenChange:X,id:u,className:f,sx:W},D){let{isOpen:i,motion:s,variant:y,chipPaddingX:h,handleOpen:A,handleClose:H,layout:P,mainRef:m,startContentRefs:l,endContentRefs:F,startAdornmentRef:z,endAdornmentRef:U,startAdornmentWidth:N,endAdornmentWidth:J}=ge({main:t,startItems:n,endItems:a,startAdornment:o,endAdornment:r,variant:c,expandFrom:S,transition:I,open:M,defaultOpen:b,onOpenChange:X}),g=y==="stacked",Q=Math.max(n.length,a.length)+2,O={duration:s.duration===0?0:de,ease:"easeOut"},$=(R,d,T,L)=>d.map((k,G)=>{let _=T[G];if(!_)return null;let Le=g?{x:_.closedX,width:p,opacity:1}:{x:_.closedX,opacity:0},ve=g?{x:_.openX,width:_.width,opacity:1}:{x:_.openX,opacity:1};return jsx(Re,{className:x.item,"data-side":R,$paddingX:h,initial:false,animate:i?ve:Le,transition:{duration:s.duration===0?0:s.duration+G*s.stagger,ease:s.ease},style:{zIndex:_.zIndex,pointerEvents:i?"auto":"none"},children:jsx(Te,{ref:Me=>{L.current[G]=Me;},$isHidden:g&&!i,children:k})},`${R}-${G}`)});return jsx(_e,{ref:D,id:u,"data-testid":u??"ExpandableChip","data-open":i,className:nc(x.root,f),sx:W,$isOpen:i,onMouseLeave:H,children:jsxs(Se,{children:[i&&jsx(Ie,{onMouseEnter:A,style:{left:P.openSpan.left,width:P.openSpan.width}}),jsxs(Ne,{className:x.mainGroup,initial:false,animate:{x:i?P.mainShiftX:0},transition:{duration:s.duration,ease:s.ease},style:{zIndex:Q},children:[!g&&jsxs(AnimatePresence,{initial:false,children:[n.length>0&&jsx(ie,{className:x.peek,$side:"start",initial:{opacity:0,scale:.95,x:-v+1},animate:i?{opacity:0,scale:.9,x:-v-1}:{opacity:1,scale:1,x:-v},exit:{opacity:0,scale:.95},transition:O},"peek-start"),a.length>0&&jsx(ie,{className:x.peek,$side:"end",initial:{opacity:0,scale:.95,x:v-1},animate:i?{opacity:0,scale:.9,x:v+1}:{opacity:1,scale:1,x:v},exit:{opacity:0,scale:.95},transition:O},"peek-end")]}),o&&jsx(ne,{className:x.adornment,"data-side":"start",$side:"start",initial:false,animate:{opacity:i?1:0},transition:{duration:0},style:{width:N,pointerEvents:i?"auto":"none"},children:jsx(ae,{ref:z,children:o})}),jsx(Xe,{ref:m,className:x.main,$paddingX:h,$fuseStart:i&&!!o,$fuseEnd:i&&!!r,$zIndex:2,onMouseEnter:A,children:t}),r&&jsx(ne,{className:x.adornment,"data-side":"end",$side:"end",initial:false,animate:{opacity:i?1:0},transition:{duration:0},style:{width:J,pointerEvents:i?"auto":"none"},children:jsx(ae,{ref:U,children:r})})]}),$("start",n,P.start,l),$("end",a,P.end,F)]})})}),Fe=memo(Ve);export{x as a,Fe as b};
|