@ehfuse/mui-virtual-data-table 1.1.19 → 1.1.20

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/dist/index.js CHANGED
@@ -18,7 +18,7 @@
18
18
  outline: 2px solid rgba(0, 123, 255, 0.5);
19
19
  outline-offset: -2px;
20
20
  }
21
- `,document.head.appendChild(a),()=>{let m=document.getElementById(r);m&&m.remove()}},[]),(0,ee.jsxs)("div",{ref:se,className:`overlay-scrollbar-wrapper ${s}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...f},children:[(0,ee.jsx)("div",{ref:d,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:Te,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:he?"none":"auto",...g},children:(0,ee.jsx)("div",{ref:G,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...y},children:v})}),j&&Se&&(0,ee.jsxs)("div",{ref:ce,className:"overlay-scrollbar-track",onMouseEnter:()=>{t(),Me.current=setTimeout(()=>{k(!0),Me.current=null},100)},onMouseLeave:()=>{o(),F||h(w.delay)},style:{position:"absolute",top:0,right:0,width:`${ae}px`,height:"100%",opacity:X?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[b.visible&&(0,ee.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:r=>{r.preventDefault(),r.stopPropagation(),Re(r)},style:{position:"absolute",top:A?`${N.width+b.margin*2}px`:`${b.margin}px`,right:b.alignment==="right"?"0px":`${(ae-N.width)/2}px`,width:`${N.width}px`,height:A?`calc(100% - ${N.width*2+b.margin*4}px)`:`calc(100% - ${b.margin*2}px)`,backgroundColor:b.color,borderRadius:`${b.radius}px`,cursor:"pointer"}}),(0,ee.jsx)("div",{ref:ue,className:"overlay-scrollbar-thumb",onMouseDown:e,onMouseEnter:()=>we(!0),onMouseLeave:()=>we(!1),style:{position:"absolute",top:`${(A?D+b.margin*2:b.margin)+je}px`,right:b.alignment==="right"?"0px":`${(ae-D)/2}px`,width:`${D}px`,height:`${Math.max(oe,Ee)}px`,backgroundColor:re||F?N.hoverColor:N.color,opacity:re||F?N.hoverOpacity:N.opacity,borderRadius:`${N.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),j&&Se&&A&&(0,ee.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:Q,onMouseEnter:()=>pe("up"),onMouseLeave:()=>pe(null),style:{position:"absolute",top:`${b.margin}px`,right:b.alignment==="right"?"0px":`${(ae-D)/2}px`,width:`${D}px`,height:`${D}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(D*.75,8)}px`,color:ge==="up"?P.hoverColor:P.color,userSelect:"none",zIndex:1001,opacity:X?ge==="up"?P.hoverOpacity:P.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),j&&Se&&A&&(0,ee.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:He,onMouseEnter:()=>pe("down"),onMouseLeave:()=>pe(null),style:{position:"absolute",bottom:`${b.margin}px`,right:b.alignment==="right"?"0px":`${(ae-D)/2}px`,width:`${D}px`,height:`${D}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(D*.75,8)}px`,color:ge==="down"?P.hoverColor:P.color,userSelect:"none",zIndex:1001,opacity:X?ge==="down"?P.hoverOpacity:P.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),Ze=ht;var c=require("react/jsx-runtime"),gt={alignment:"right",margin:0,radius:0},Je=5;function bt({data:s,loading:f=!1,columns:g,onRowClick:y,getRowId:v,selectedRowId:I,selectedRowSx:S,rowHeight:L=50,columnHeight:O=56,striped:Y,rowDivider:K=!0,onSort:j,onLoadMore:U,sortBy:$,sortDirection:_,showPaper:se=!0,paddingX:d="1rem",paddingTop:G=0,paddingBottom:ce=0,rowHoverColor:ue,rowHoverOpacity:V,viewportBuffer:X,overscan:k,scrollbars:F,emptyMessage:te="NO DATA",LoadingComponent:re,showFooter:we,footerHeight:de,footerSx:ne}){let oe=Math.max(L*12,480),qe=Math.max(L*12,480),je=typeof X=="number"?X:X?.top??oe,$e=typeof X=="number"?X:X?.bottom??qe,Se=Math.max(L*8,420),Fe=Math.max(L*10,520),he=typeof k=="number"?k:{main:k?.main??Se,reverse:k?.reverse??Fe},ke=L+(K?1:0),Le=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),[T]=(0,u.useState)(()=>typeof window>"u"?!1:window.localStorage.getItem("vdt-perf-debug")==="1"),x=(0,u.useRef)({wheelEvents:0,wheelInputPx:0,wheelHandlerMs:0,wheelRafFlushes:0,wheelRafMs:0,rangeChangedCalls:0,rangeChangedMs:0,rowContentCalls:0,rowContentMs:0,rowContentMaxMs:0,cellRenderCalls:0,cellRenderMs:0,cellRenderMaxMs:0}),Ne=(0,u.useCallback)(t=>{if(!T)return;let o=x.current;if(!(o.wheelEvents>0||o.rangeChangedCalls>0||o.rowContentCalls>0||o.cellRenderCalls>0))return;let h=o.rowContentCalls>0?o.rowContentMs/o.rowContentCalls:0,l=o.cellRenderCalls>0?o.cellRenderMs/o.cellRenderCalls:0;console.log("[VDT perf]",{reason:t,wheel:{events:o.wheelEvents,inputPx:Math.round(o.wheelInputPx),handlerMs:Number(o.wheelHandlerMs.toFixed(2)),rafFlushes:o.wheelRafFlushes,rafMs:Number(o.wheelRafMs.toFixed(2))},rangeChanged:{calls:o.rangeChangedCalls,totalMs:Number(o.rangeChangedMs.toFixed(2))},rowContent:{calls:o.rowContentCalls,totalMs:Number(o.rowContentMs.toFixed(2)),avgMs:Number(h.toFixed(3)),maxMs:Number(o.rowContentMaxMs.toFixed(3))},cellRender:{calls:o.cellRenderCalls,totalMs:Number(o.cellRenderMs.toFixed(2)),avgMs:Number(l.toFixed(3)),maxMs:Number(o.cellRenderMaxMs.toFixed(3))}}),x.current={wheelEvents:0,wheelInputPx:0,wheelHandlerMs:0,wheelRafFlushes:0,wheelRafMs:0,rangeChangedCalls:0,rangeChangedMs:0,rowContentCalls:0,rowContentMs:0,rowContentMaxMs:0,cellRenderCalls:0,cellRenderMs:0,cellRenderMaxMs:0}},[T]);(0,u.useEffect)(()=>{if(!T||typeof window>"u")return;console.log("[VDT perf] enabled (localStorage vdt-perf-debug=1)");let t=window.setInterval(()=>{Ne("interval")},1500);return()=>{window.clearInterval(t),Ne("cleanup")}},[Ne,T]);let ge=(0,u.useMemo)(()=>(0,u.forwardRef)((t,o)=>{let R=(0,u.useRef)(null),h=(0,u.useRef)(0),l=(0,u.useRef)(null);return(0,u.useEffect)(()=>{let e=R.current;if(!e)return;let B=z=>{let Re=T?performance.now():0;z.preventDefault();let Q=z.deltaY;z.deltaMode===1?Q*=40:z.deltaMode===2&&(Q*=e.clientHeight),T&&(x.current.wheelEvents+=1,x.current.wheelInputPx+=Q),h.current+=Q,l.current===null&&(l.current=requestAnimationFrame(()=>{let He=T?performance.now():0,Te=Math.max(e.clientHeight*.4,160),H=Math.max(-Te,Math.min(Te,h.current));h.current=0,l.current=null,H!==0&&(e.scrollTop+=H),T&&(x.current.wheelRafFlushes+=1,x.current.wheelRafMs+=performance.now()-He)}),T&&(x.current.wheelHandlerMs+=performance.now()-Re))};return e.addEventListener("wheel",B,{passive:!1}),()=>{e.removeEventListener("wheel",B),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),h.current=0}},[]),(0,c.jsx)(Ze,{detectInnerScroll:!0,track:gt,...F,children:(0,c.jsx)(p.TableContainer,{component:p.Box,...t,ref:e=>{R.current=e,typeof o=="function"?o(e):o&&(o.current=e)},sx:{userSelect:"auto",WebkitUserSelect:"auto",position:"relative",width:"100%",height:"100%",overflow:"auto",display:"flex",flexDirection:"column",scrollbarWidth:"none",msOverflowStyle:"none",transform:"translateZ(0)",backfaceVisibility:"hidden",willChange:"scroll-position","&::-webkit-scrollbar":{display:"none"},"& .MuiTable-root":{paddingRight:d,paddingTop:G,paddingBottom:ce}}})})}),[]),pe=(0,u.useMemo)(()=>{if(Y===!0)return"#f5f5f5";if(typeof Y=="string")return Y},[Y]),[Xe,Pe]=(0,u.useState)(f),[be,Ae]=(0,u.useState)(0);(0,u.useEffect)(()=>{f&&Pe(!0)},[f]);let De=(0,u.useCallback)(()=>{Pe(!1)},[]),xe=Xe,Me=f&&s.length>0,Z=(0,u.useRef)(!1),N=(0,u.useRef)(null),b=(0,u.useRef)(!1),P=(0,u.useRef)({x:0,y:0});(0,u.useEffect)(()=>{let t=o=>{let R=o.clientX-P.current.x,h=o.clientY-P.current.y;Math.sqrt(R*R+h*h)>Je&&(b.current=!0)};return document.addEventListener("mousemove",t),()=>{document.removeEventListener("mousemove",t)}},[]),(0,u.useEffect)(()=>{let t=document.querySelector('[data-testid="virtuoso-scroller"]');t&&t.querySelectorAll(".MuiTableSortLabel-root").forEach(R=>{let h=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});R.dispatchEvent(h)})},[$]);let fe=(0,u.useCallback)(t=>{if(!j)return;j(t,$===t&&_==="asc"?"desc":"asc")},[j,$,_]),w=(0,u.useCallback)(t=>{let o=T?performance.now():0;if(!U){T&&(x.current.rangeChangedCalls+=1,x.current.rangeChangedMs+=performance.now()-o);return}if(f&&s.length===0){T&&(x.current.rangeChangedCalls+=1,x.current.rangeChangedMs+=performance.now()-o);return}let R=s.length>=30;if(t>=s.length-1&&R&&!Z.current){Z.current=!0;let l=s.length;U(l,50)}T&&(x.current.rangeChangedCalls+=1,x.current.rangeChangedMs+=performance.now()-o)},[s.length,f,U,T]);(0,u.useEffect)(()=>{f||(Z.current=!1)},[f]),(0,u.useEffect)(()=>{s.length===0&&Ae(t=>t+1)},[s.length]);let D=(0,u.useRef)(s.length);(0,u.useEffect)(()=>{let t=D.current,o=s.length;if(o>t&&t>0){D.current=o;return}N.current&&o>0&&o<=t&&N.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),D.current=o},[s]);let ze=(0,u.useCallback)(()=>{let t={},o=[];if(g.forEach(e=>{e.group?(t[e.group]||(t[e.group]=[]),t[e.group].push(e)):o.push(e)}),!(Object.keys(t).length>0))return(0,c.jsx)(p.TableRow,{children:g.map(e=>(0,c.jsx)(p.TableCell,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable?(0,c.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,c.jsxs)(p.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>fe(String(e.id)),children:[e.text,(0,c.jsx)(p.TableSortLabel,{active:$===e.id,direction:$===e.id?_:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:$===e.id?1:0,transition:"opacity 0.2s ease","& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(180deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(0deg)"}}})]})}):e.text},String(e.id)))});let h=[...o.map(e=>(0,c.jsx)(p.TableCell,{rowSpan:2,align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable&&j?(0,c.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,c.jsxs)(p.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>fe(String(e.id)),children:[e.text,(0,c.jsx)(p.TableSortLabel,{active:$===e.id,direction:$===e.id?_:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:$===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(180deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(0deg)"}}})]})}):e.text},String(e.id))),...Object.entries(t).map(([e,B])=>(0,c.jsx)(p.TableCell,{align:"center",colSpan:B.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e},e))],l=[...Object.values(t).flat().map(e=>(0,c.jsx)(p.TableCell,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable&&j?(0,c.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,c.jsxs)(p.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>fe(String(e.id)),children:[e.text,(0,c.jsx)(p.TableSortLabel,{active:$===e.id,direction:$===e.id?_:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:$===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(0deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(180deg)"}}})]})}):e.text},String(e.id)))];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(p.TableRow,{children:h}),(0,c.jsx)(p.TableRow,{children:l})]})},[g,$,_,fe,j,O]),Ee=(0,u.useCallback)((t,o)=>{let R=T?performance.now():0;if(!o){if(T){x.current.rowContentCalls+=1;let l=performance.now()-R;x.current.rowContentMs+=l,x.current.rowContentMaxMs=Math.max(x.current.rowContentMaxMs,l)}return null}let h=g.map(l=>{let e=T?performance.now():0,B=l.render?l.render(o,t):String(o[l.id]||"");if(T){let z=performance.now()-e;x.current.cellRenderCalls+=1,x.current.cellRenderMs+=z,x.current.cellRenderMaxMs=Math.max(x.current.cellRenderMaxMs,z)}return(0,c.jsx)(p.TableCell,{align:l.align||"left",style:{width:l.width,minWidth:l.width,...l.style,padding:"8px 16px"},children:B},String(l.id))});if(T){x.current.rowContentCalls+=1;let l=performance.now()-R;x.current.rowContentMs+=l,x.current.rowContentMaxMs=Math.max(x.current.rowContentMaxMs,l)}return(0,c.jsx)(c.Fragment,{children:h})},[g,T]),A=we??g.some(t=>typeof t.footer=="function"),Ce=(0,u.useCallback)(()=>A?(0,c.jsx)(p.TableRow,{children:g.map(t=>(0,c.jsx)(p.TableCell,{align:t.align||"left",style:{width:t.width,minWidth:t.width,...t.style,fontWeight:"bold",padding:"16px"},children:t.footer?t.footer(s):null},String(t.id)))}):null,[A,g,s]),E=(0,u.useMemo)(()=>({Scroller:ge,Table:t=>(0,c.jsx)(p.Table,{...t,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px",...A?{height:"100%"}:{}}}),TableHead:(0,u.forwardRef)((t,o)=>(0,c.jsx)(p.TableHead,{...t,ref:o,sx:{userSelect:"none","& tr":{height:O,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:t=>{let{item:o,selected:R,"aria-selected":h,className:l,...e}=t,B=e["data-index"]??0,z=B%2===1,Re=o&&v?v(o,B):B,Q=I!=null&&Re===I,He=Q&&S?typeof S=="function"?S(o,B):S:void 0,Te=String(l??"").split(/\s+/).filter(H=>H!=="Mui-selected"&&H!=="Mui-focusVisible").join(" ");return(0,c.jsx)(p.TableRow,{...e,className:Te||void 0,selected:Q,onMouseDown:H=>{b.current=!1,P.current={x:H.clientX,y:H.clientY}},onClick:H=>{let me=H.clientX-P.current.x,ae=H.clientY-P.current.y;if(Math.sqrt(me*me+ae*ae)>Je||b.current){H.preventDefault(),H.stopPropagation(),b.current=!1;return}o&&y&&y(o,B),b.current=!1},sx:[{userSelect:"none",height:L,backgroundColor:z&&pe?pe:"transparent","& td":{padding:"8px 16px",borderBottom:K?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":y&&!Q?{backgroundColor:H=>{let me=H.palette.mode==="dark",r=ue??"#000000",i=V??.06;if(!ue)return me?`rgba(255, 255, 255, ${i})`:`rgba(0, 0, 0, ${i})`;let a=r.replace("#","").trim();if(a.length!==6)return r;let m=parseInt(a.substring(0,2),16),M=parseInt(a.substring(2,4),16),C=parseInt(a.substring(4,6),16);return`rgba(${m}, ${M}, ${C}, ${i})`}}:void 0,cursor:y?"pointer":void 0},He]})},TableBody:(0,u.forwardRef)((t,o)=>(0,c.jsx)(p.TableBody,{...t,ref:o,sx:A?{height:"100%"}:void 0})),TableFoot:(0,u.forwardRef)((t,o)=>(0,c.jsx)(p.TableFooter,{...t,ref:o,sx:[{position:"sticky",bottom:0,zIndex:2,backgroundColor:R=>R.palette.mode==="dark"?"#1e1e1e":"#ffffff","& tr":{height:de??L},"& td":{padding:"16px",color:"inherit",fontSize:"0.875rem",borderTop:"2px solid rgba(224, 224, 224, 1)",borderBottom:"none"}},...Array.isArray(ne)?ne:ne?[ne]:[]]}))}),[y,v,I,S,L,pe,K,O,ue,V,ge,de,ne,A]),le=(0,c.jsxs)(p.Box,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:t=>t.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"}},children:[(0,c.jsx)(Qe.TableVirtuoso,{ref:N,data:s,totalCount:U?s.length+1:s.length,defaultItemHeight:ke,fixedItemHeight:ke,fixedHeaderContent:ze,fixedFooterContent:A?Ce:void 0,itemContent:Ee,endReached:w,style:{height:"100%"},increaseViewportBy:{top:je,bottom:$e},overscan:he,followOutput:!1,components:E},be),s.length===0&&!f&&(0,c.jsx)(p.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof te=="string"?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(p.Box,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),(0,c.jsx)(p.Typography,{variant:"body1",sx:{color:"text.secondary"},children:te})]}):te}),xe&&(0,c.jsx)(c.Fragment,{children:re?(0,c.jsx)(re,{visible:f,onComplete:De}):(0,c.jsx)(Ke,{visible:f,onComplete:De,size:40,sx:{top:`${g.some(t=>t.group)?O*2:O}px`},background:{show:s.length===0,opacity:.8}})})]});return se?(0,c.jsx)(p.Paper,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:d,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:le}):(0,c.jsx)(p.Box,{className:"grow",style:{padding:0,paddingLeft:d,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:le})}var et=(0,u.memo)(bt);
21
+ `,document.head.appendChild(a),()=>{let m=document.getElementById(r);m&&m.remove()}},[]),(0,ee.jsxs)("div",{ref:se,className:`overlay-scrollbar-wrapper ${s}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...f},children:[(0,ee.jsx)("div",{ref:d,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:Te,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:he?"none":"auto",...g},children:(0,ee.jsx)("div",{ref:G,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...y},children:v})}),j&&Se&&(0,ee.jsxs)("div",{ref:ce,className:"overlay-scrollbar-track",onMouseEnter:()=>{t(),Me.current=setTimeout(()=>{k(!0),Me.current=null},100)},onMouseLeave:()=>{o(),F||h(w.delay)},style:{position:"absolute",top:0,right:0,width:`${ae}px`,height:"100%",opacity:X?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[b.visible&&(0,ee.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:r=>{r.preventDefault(),r.stopPropagation(),Re(r)},style:{position:"absolute",top:A?`${N.width+b.margin*2}px`:`${b.margin}px`,right:b.alignment==="right"?"0px":`${(ae-N.width)/2}px`,width:`${N.width}px`,height:A?`calc(100% - ${N.width*2+b.margin*4}px)`:`calc(100% - ${b.margin*2}px)`,backgroundColor:b.color,borderRadius:`${b.radius}px`,cursor:"pointer"}}),(0,ee.jsx)("div",{ref:ue,className:"overlay-scrollbar-thumb",onMouseDown:e,onMouseEnter:()=>we(!0),onMouseLeave:()=>we(!1),style:{position:"absolute",top:`${(A?D+b.margin*2:b.margin)+je}px`,right:b.alignment==="right"?"0px":`${(ae-D)/2}px`,width:`${D}px`,height:`${Math.max(oe,Ee)}px`,backgroundColor:re||F?N.hoverColor:N.color,opacity:re||F?N.hoverOpacity:N.opacity,borderRadius:`${N.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),j&&Se&&A&&(0,ee.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:Q,onMouseEnter:()=>pe("up"),onMouseLeave:()=>pe(null),style:{position:"absolute",top:`${b.margin}px`,right:b.alignment==="right"?"0px":`${(ae-D)/2}px`,width:`${D}px`,height:`${D}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(D*.75,8)}px`,color:ge==="up"?P.hoverColor:P.color,userSelect:"none",zIndex:1001,opacity:X?ge==="up"?P.hoverOpacity:P.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),j&&Se&&A&&(0,ee.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:He,onMouseEnter:()=>pe("down"),onMouseLeave:()=>pe(null),style:{position:"absolute",bottom:`${b.margin}px`,right:b.alignment==="right"?"0px":`${(ae-D)/2}px`,width:`${D}px`,height:`${D}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(D*.75,8)}px`,color:ge==="down"?P.hoverColor:P.color,userSelect:"none",zIndex:1001,opacity:X?ge==="down"?P.hoverOpacity:P.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),Ze=ht;var c=require("react/jsx-runtime"),gt={alignment:"right",margin:0,radius:0},Je=5;function bt({data:s,loading:f=!1,columns:g,onRowClick:y,getRowId:v,selectedRowId:I,selectedRowSx:S,rowHeight:L=50,columnHeight:O=56,striped:Y,rowDivider:K=!0,onSort:j,onLoadMore:U,sortBy:$,sortDirection:_,showPaper:se=!0,paddingX:d="1rem",paddingTop:G=0,paddingBottom:ce=0,rowHoverColor:ue,rowHoverOpacity:V,viewportBuffer:X,overscan:k,scrollbars:F,emptyMessage:te="NO DATA",LoadingComponent:re,showFooter:we,footerHeight:de,footerSx:ne}){let oe=Math.max(L*12,480),qe=Math.max(L*12,480),je=typeof X=="number"?X:X?.top??oe,$e=typeof X=="number"?X:X?.bottom??qe,Se=Math.max(L*8,420),Fe=Math.max(L*10,520),he=typeof k=="number"?k:{main:k?.main??Se,reverse:k?.reverse??Fe},ke=L+(K?1:0),Le=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),[T]=(0,u.useState)(()=>typeof window>"u"?!1:window.localStorage.getItem("vdt-perf-debug")==="1"),x=(0,u.useRef)({wheelEvents:0,wheelInputPx:0,wheelHandlerMs:0,wheelRafFlushes:0,wheelRafMs:0,rangeChangedCalls:0,rangeChangedMs:0,rowContentCalls:0,rowContentMs:0,rowContentMaxMs:0,cellRenderCalls:0,cellRenderMs:0,cellRenderMaxMs:0}),Ne=(0,u.useCallback)(t=>{if(!T)return;let o=x.current;if(!(o.wheelEvents>0||o.rangeChangedCalls>0||o.rowContentCalls>0||o.cellRenderCalls>0))return;let h=o.rowContentCalls>0?o.rowContentMs/o.rowContentCalls:0,l=o.cellRenderCalls>0?o.cellRenderMs/o.cellRenderCalls:0;console.log("[VDT perf]",{reason:t,wheel:{events:o.wheelEvents,inputPx:Math.round(o.wheelInputPx),handlerMs:Number(o.wheelHandlerMs.toFixed(2)),rafFlushes:o.wheelRafFlushes,rafMs:Number(o.wheelRafMs.toFixed(2))},rangeChanged:{calls:o.rangeChangedCalls,totalMs:Number(o.rangeChangedMs.toFixed(2))},rowContent:{calls:o.rowContentCalls,totalMs:Number(o.rowContentMs.toFixed(2)),avgMs:Number(h.toFixed(3)),maxMs:Number(o.rowContentMaxMs.toFixed(3))},cellRender:{calls:o.cellRenderCalls,totalMs:Number(o.cellRenderMs.toFixed(2)),avgMs:Number(l.toFixed(3)),maxMs:Number(o.cellRenderMaxMs.toFixed(3))}}),x.current={wheelEvents:0,wheelInputPx:0,wheelHandlerMs:0,wheelRafFlushes:0,wheelRafMs:0,rangeChangedCalls:0,rangeChangedMs:0,rowContentCalls:0,rowContentMs:0,rowContentMaxMs:0,cellRenderCalls:0,cellRenderMs:0,cellRenderMaxMs:0}},[T]);(0,u.useEffect)(()=>{if(!T||typeof window>"u")return;console.log("[VDT perf] enabled (localStorage vdt-perf-debug=1)");let t=window.setInterval(()=>{Ne("interval")},1500);return()=>{window.clearInterval(t),Ne("cleanup")}},[Ne,T]);let ge=(0,u.useMemo)(()=>(0,u.forwardRef)((t,o)=>{let R=(0,u.useRef)(null),h=(0,u.useRef)(0),l=(0,u.useRef)(null);return(0,u.useEffect)(()=>{let e=R.current;if(!e)return;let B=z=>{let Re=T?performance.now():0;z.preventDefault();let Q=z.deltaY;z.deltaMode===1?Q*=40:z.deltaMode===2&&(Q*=e.clientHeight),T&&(x.current.wheelEvents+=1,x.current.wheelInputPx+=Q),h.current+=Q,l.current===null&&(l.current=requestAnimationFrame(()=>{let He=T?performance.now():0,Te=Math.max(e.clientHeight*.4,160),H=Math.max(-Te,Math.min(Te,h.current));h.current=0,l.current=null,H!==0&&(e.scrollTop+=H),T&&(x.current.wheelRafFlushes+=1,x.current.wheelRafMs+=performance.now()-He)}),T&&(x.current.wheelHandlerMs+=performance.now()-Re))};return e.addEventListener("wheel",B,{passive:!1}),()=>{e.removeEventListener("wheel",B),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),h.current=0}},[]),(0,c.jsx)(Ze,{detectInnerScroll:!0,track:gt,...F,children:(0,c.jsx)(p.TableContainer,{component:p.Box,...t,ref:e=>{R.current=e,typeof o=="function"?o(e):o&&(o.current=e)},sx:{userSelect:"auto",WebkitUserSelect:"auto",position:"relative",width:"100%",height:"100%",overflow:"auto",display:"flex",flexDirection:"column",scrollbarWidth:"none",msOverflowStyle:"none",transform:"translateZ(0)",backfaceVisibility:"hidden",willChange:"scroll-position","&::-webkit-scrollbar":{display:"none"},"& .MuiTable-root":{paddingRight:d,paddingTop:G,paddingBottom:ce}}})})}),[]),pe=(0,u.useMemo)(()=>{if(Y===!0)return"#f5f5f5";if(typeof Y=="string")return Y},[Y]),[Xe,Pe]=(0,u.useState)(f),[be,Ae]=(0,u.useState)(0);(0,u.useEffect)(()=>{f&&Pe(!0)},[f]);let De=(0,u.useCallback)(()=>{Pe(!1)},[]),xe=Xe,Me=f&&s.length>0,Z=(0,u.useRef)(!1),N=(0,u.useRef)(null),b=(0,u.useRef)(!1),P=(0,u.useRef)({x:0,y:0});(0,u.useEffect)(()=>{let t=o=>{let R=o.clientX-P.current.x,h=o.clientY-P.current.y;Math.sqrt(R*R+h*h)>Je&&(b.current=!0)};return document.addEventListener("mousemove",t),()=>{document.removeEventListener("mousemove",t)}},[]),(0,u.useEffect)(()=>{let t=document.querySelector('[data-testid="virtuoso-scroller"]');t&&t.querySelectorAll(".MuiTableSortLabel-root").forEach(R=>{let h=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});R.dispatchEvent(h)})},[$]);let fe=(0,u.useCallback)(t=>{if(!j)return;j(t,$===t&&_==="asc"?"desc":"asc")},[j,$,_]),w=(0,u.useCallback)(t=>{let o=T?performance.now():0;if(!U){T&&(x.current.rangeChangedCalls+=1,x.current.rangeChangedMs+=performance.now()-o);return}if(f&&s.length===0){T&&(x.current.rangeChangedCalls+=1,x.current.rangeChangedMs+=performance.now()-o);return}let R=s.length>=30;if(t>=s.length-1&&R&&!Z.current){Z.current=!0;let l=s.length;U(l,50)}T&&(x.current.rangeChangedCalls+=1,x.current.rangeChangedMs+=performance.now()-o)},[s.length,f,U,T]);(0,u.useEffect)(()=>{f||(Z.current=!1)},[f]),(0,u.useEffect)(()=>{s.length===0&&Ae(t=>t+1)},[s.length]);let D=(0,u.useRef)(s.length);(0,u.useEffect)(()=>{let t=D.current,o=s.length;if(o>t&&t>0){D.current=o;return}N.current&&o>0&&o<=t&&N.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),D.current=o},[s]);let ze=(0,u.useCallback)(()=>{let t={},o=[];if(g.forEach(e=>{e.group?(t[e.group]||(t[e.group]=[]),t[e.group].push(e)):o.push(e)}),!(Object.keys(t).length>0))return(0,c.jsx)(p.TableRow,{children:g.map(e=>(0,c.jsx)(p.TableCell,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable?(0,c.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,c.jsxs)(p.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>fe(String(e.id)),children:[e.text,(0,c.jsx)(p.TableSortLabel,{active:$===e.id,direction:$===e.id?_:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:$===e.id?1:0,transition:"opacity 0.2s ease","& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(180deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(0deg)"}}})]})}):e.text},String(e.id)))});let h=[...o.map(e=>(0,c.jsx)(p.TableCell,{rowSpan:2,align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable&&j?(0,c.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,c.jsxs)(p.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>fe(String(e.id)),children:[e.text,(0,c.jsx)(p.TableSortLabel,{active:$===e.id,direction:$===e.id?_:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:$===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(180deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(0deg)"}}})]})}):e.text},String(e.id))),...Object.entries(t).map(([e,B])=>(0,c.jsx)(p.TableCell,{align:"center",colSpan:B.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e},e))],l=[...Object.values(t).flat().map(e=>(0,c.jsx)(p.TableCell,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable&&j?(0,c.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,c.jsxs)(p.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>fe(String(e.id)),children:[e.text,(0,c.jsx)(p.TableSortLabel,{active:$===e.id,direction:$===e.id?_:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:$===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(0deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(180deg)"}}})]})}):e.text},String(e.id)))];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(p.TableRow,{children:h}),(0,c.jsx)(p.TableRow,{children:l})]})},[g,$,_,fe,j,O]),Ee=(0,u.useCallback)((t,o)=>{let R=T?performance.now():0;if(!o){if(T){x.current.rowContentCalls+=1;let l=performance.now()-R;x.current.rowContentMs+=l,x.current.rowContentMaxMs=Math.max(x.current.rowContentMaxMs,l)}return null}let h=g.map(l=>{let e=T?performance.now():0,B=l.render?l.render(o,t):String(o[l.id]||"");if(T){let z=performance.now()-e;x.current.cellRenderCalls+=1,x.current.cellRenderMs+=z,x.current.cellRenderMaxMs=Math.max(x.current.cellRenderMaxMs,z)}return(0,c.jsx)(p.TableCell,{align:l.align||"left",style:{width:l.width,minWidth:l.width,...l.style,padding:"8px 16px"},children:B},String(l.id))});if(T){x.current.rowContentCalls+=1;let l=performance.now()-R;x.current.rowContentMs+=l,x.current.rowContentMaxMs=Math.max(x.current.rowContentMaxMs,l)}return(0,c.jsx)(c.Fragment,{children:h})},[g,T]),A=we??g.some(t=>typeof t.footer=="function"),Ce=(0,u.useCallback)(()=>A?(0,c.jsx)(p.TableRow,{children:g.map(t=>(0,c.jsx)(p.TableCell,{align:t.align||"left",style:{width:t.width,minWidth:t.width,...t.style,fontWeight:"bold",padding:"16px"},children:t.footer?t.footer(s):null},String(t.id)))}):null,[A,g,s]),E=(0,u.useMemo)(()=>({Scroller:ge,Table:t=>(0,c.jsx)(p.Table,{...t,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px",...A?{height:"100%"}:{}}}),TableHead:(0,u.forwardRef)((t,o)=>(0,c.jsx)(p.TableHead,{...t,ref:o,sx:{userSelect:"none","& tr":{height:O,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:t=>{let{item:o,selected:R,"aria-selected":h,className:l,...e}=t,B=e["data-index"]??0,z=B%2===1,Re=o&&v?v(o,B):B,Q=I!=null&&Re===I,He=Q&&S?typeof S=="function"?S(o,B):S:void 0,Te=String(l??"").split(/\s+/).filter(H=>H!=="Mui-selected"&&H!=="Mui-focusVisible").join(" ");return(0,c.jsx)(p.TableRow,{...e,className:Te||void 0,selected:Q,onMouseDown:H=>{b.current=!1,P.current={x:H.clientX,y:H.clientY}},onClick:H=>{let me=H.clientX-P.current.x,ae=H.clientY-P.current.y;if(Math.sqrt(me*me+ae*ae)>Je||b.current){H.preventDefault(),H.stopPropagation(),b.current=!1;return}o&&y&&y(o,B),b.current=!1},sx:[{userSelect:"none",height:L,backgroundColor:z&&pe?pe:"transparent","& td":{padding:"8px 16px",borderBottom:K?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":y&&!Q?{backgroundColor:H=>{let me=H.palette.mode==="dark",r=ue??"#000000",i=V??.06;if(!ue)return me?`rgba(255, 255, 255, ${i})`:`rgba(0, 0, 0, ${i})`;let a=r.replace("#","").trim();if(a.length!==6)return r;let m=parseInt(a.substring(0,2),16),M=parseInt(a.substring(2,4),16),C=parseInt(a.substring(4,6),16);return`rgba(${m}, ${M}, ${C}, ${i})`}}:void 0,cursor:y?"pointer":void 0},He]})},TableBody:(0,u.forwardRef)((t,o)=>(0,c.jsx)(p.TableBody,{...t,ref:o,sx:A?{height:"100%"}:void 0})),TableFoot:(0,u.forwardRef)((t,o)=>(0,c.jsx)(p.TableFooter,{...t,ref:o,sx:[{position:"sticky",bottom:0,zIndex:2,backgroundColor:R=>R.palette.mode==="dark"?"#1e1e1e":"#ffffff","& tr":{height:de??L},"& td":{padding:"16px",color:"inherit",fontSize:"0.875rem",borderTop:"1px solid #000000",borderBottom:"none"}},...Array.isArray(ne)?ne:ne?[ne]:[]]}))}),[y,v,I,S,L,pe,K,O,ue,V,ge,de,ne,A]),le=(0,c.jsxs)(p.Box,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:t=>t.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"}},children:[(0,c.jsx)(Qe.TableVirtuoso,{ref:N,data:s,totalCount:U?s.length+1:s.length,defaultItemHeight:ke,fixedItemHeight:ke,fixedHeaderContent:ze,fixedFooterContent:A?Ce:void 0,itemContent:Ee,endReached:w,style:{height:"100%"},increaseViewportBy:{top:je,bottom:$e},overscan:he,followOutput:!1,components:E},be),s.length===0&&!f&&(0,c.jsx)(p.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof te=="string"?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(p.Box,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),(0,c.jsx)(p.Typography,{variant:"body1",sx:{color:"text.secondary"},children:te})]}):te}),xe&&(0,c.jsx)(c.Fragment,{children:re?(0,c.jsx)(re,{visible:f,onComplete:De}):(0,c.jsx)(Ke,{visible:f,onComplete:De,size:40,sx:{top:`${g.some(t=>t.group)?O*2:O}px`},background:{show:s.length===0,opacity:.8}})})]});return se?(0,c.jsx)(p.Paper,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:d,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:le}):(0,c.jsx)(p.Box,{className:"grow",style:{padding:0,paddingLeft:d,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:le})}var et=(0,u.memo)(bt);
22
22
  /**
23
23
  * Virtual Data Table - A high-performance virtual data table component for React
24
24
  *