@ehfuse/mui-virtual-data-table 1.3.0 → 1.3.1

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.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- import{forwardRef as De,useCallback as P,useMemo as G,useRef as b,useEffect as N,memo as rn,useState as Ee}from"react";import{Box as R,Table as on,TableBody as xt,TableCell as J,TableContainer as an,TableHead as sn,TableFooter as ln,TableRow as pe,TableSortLabel as Ue,Paper as dn,Typography as cn,useTheme as un}from"@mui/material";import{TableVirtuoso as pn}from"react-virtuoso";import{jsx as Je}from"react/jsx-runtime";import{useRef as ht,useState as Jt,useEffect as Ut}from"react";import{Box as Zt,CircularProgress as Qt}from"@mui/material";var ue=function(){return ue=Object.assign||function(u){for(var l,k=1,y=arguments.length;k<y;k++){l=arguments[k];for(var x in l)Object.prototype.hasOwnProperty.call(l,x)&&(u[x]=l[x])}return u},ue.apply(this,arguments)};function bt(a){var u=a.visible,l=a.onComplete,k=a.fadeoutDuration,y=k===void 0?200:k,x=a.exitDelay,ge=x===void 0?0:x,he=a.size,te=he===void 0?40:he,U=a.className,ne=a.style,z=a.sx,B=a.indicator,m=a.background,L=m===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:m,be=ht(void 0),$=ht(null),me=Jt(u),He=me[0],ye=me[1],xe=L.show,F=xe===void 0?!0:xe,V=L.color,O=V===void 0?"255, 255, 255":V,I=L.opacity,C=I===void 0?.9:I;if(Ut(function(){var _=be.current;if(_===!0&&u===!1&&$.current){var Y=$.current;Y.style.opacity="0",setTimeout(function(){ye(!1),l?.()},y+ge)}else u===!0&&(ye(!0),$.current&&($.current.style.opacity="1"));be.current=u},[u,l,y,ge]),!He)return null;var Ce=function(){return typeof B=="string"?Je("img",{src:B,alt:"Loading",style:{width:te,height:te}}):B||Je(Qt,{size:te})},Pe=function(){return F?O.startsWith("rgba")?{backgroundColor:O}:/^\d+,\s*\d+,\s*\d+$/.test(O)?{backgroundColor:"rgba(".concat(O,", ").concat(C,")")}:C!==1?{backgroundColor:O,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:O,opacity:C,zIndex:-1}}:{backgroundColor:O}:{backgroundColor:"transparent"}};return Je(Zt,{ref:$,className:U,style:ue({},ne),sx:ue(ue({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:u?1:0,transition:"opacity ".concat(y,"ms ease-out")},Pe()),z),children:Ce()})}import{Fragment as tn,jsx as mt,jsxs as nn}from"react/jsx-runtime";var en=`
1
+ import{forwardRef as De,useCallback as P,useMemo as G,useRef as b,useEffect as N,memo as rn,useState as Ee}from"react";import{Box as R,Table as on,TableBody as xt,TableCell as J,TableContainer as an,TableHead as sn,TableFooter as ln,TableRow as pe,TableSortLabel as Ue,Paper as dn,Typography as cn,useTheme as un}from"@mui/material";import{TableVirtuoso as pn}from"react-virtuoso";import{jsx as Je}from"react/jsx-runtime";import{useRef as ht,useState as Jt,useEffect as Ut}from"react";import{Box as Zt,CircularProgress as Qt}from"@mui/material";var ue=function(){return ue=Object.assign||function(u){for(var l,k=1,y=arguments.length;k<y;k++){l=arguments[k];for(var x in l)Object.prototype.hasOwnProperty.call(l,x)&&(u[x]=l[x])}return u},ue.apply(this,arguments)};function bt(a){var u=a.visible,l=a.onComplete,k=a.fadeoutDuration,y=k===void 0?200:k,x=a.exitDelay,ge=x===void 0?0:x,he=a.size,te=he===void 0?40:he,U=a.className,ne=a.style,z=a.sx,B=a.indicator,m=a.background,L=m===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:m,be=ht(void 0),$=ht(null),me=Jt(u),He=me[0],ye=me[1],xe=L.show,F=xe===void 0?!0:xe,V=L.color,I=V===void 0?"255, 255, 255":V,O=L.opacity,C=O===void 0?.9:O;if(Ut(function(){var _=be.current;if(_===!0&&u===!1&&$.current){var Y=$.current;Y.style.opacity="0",setTimeout(function(){ye(!1),l?.()},y+ge)}else u===!0&&(ye(!0),$.current&&($.current.style.opacity="1"));be.current=u},[u,l,y,ge]),!He)return null;var Ce=function(){return typeof B=="string"?Je("img",{src:B,alt:"Loading",style:{width:te,height:te}}):B||Je(Qt,{size:te})},Pe=function(){return F?I.startsWith("rgba")?{backgroundColor:I}:/^\d+,\s*\d+,\s*\d+$/.test(I)?{backgroundColor:"rgba(".concat(I,", ").concat(C,")")}:C!==1?{backgroundColor:I,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:I,opacity:C,zIndex:-1}}:{backgroundColor:I}:{backgroundColor:"transparent"}};return Je(Zt,{ref:$,className:U,style:ue({},ne),sx:ue(ue({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:u?1:0,transition:"opacity ".concat(y,"ms ease-out")},Pe()),z),children:Ce()})}import{Fragment as tn,jsx as mt,jsxs as nn}from"react/jsx-runtime";var en=`
2
2
  .vdt-css-spinner{box-sizing:border-box;border-radius:50%;border:4px solid rgba(28,64,125,0.14);border-top-color:#1c407d;animation:vdt-css-spinner-spin .75s linear infinite}
3
3
  @keyframes vdt-css-spinner-spin{to{transform:rotate(360deg)}}
4
- `;function yt({size:a=54}){return nn(tn,{children:[mt("style",{children:en}),mt("span",{className:"vdt-css-spinner",role:"progressbar","aria-label":"loading",style:{display:"inline-block",width:a,height:a}})]})}import fn from"@ehfuse/overlay-scrollbar";import{Fragment as fe,jsx as o,jsxs as A}from"react/jsx-runtime";var gn={alignment:"default",margin:0,radius:0},Ze=5,hn={bg:"#ffffff",border:"#e6e6e3",borderStrong:"#dedddb",headerColor:"#787774",hoverBg:"#f8f8f7",emptyColor:"#9b9a97",selectedBg:"#dbeafe",selectedBar:"#3b82f6"},Ct="12px",bn={bg:"#1e1e1e",border:"#2c333c",borderStrong:"#3b434e",headerColor:"#a3adbb",hoverBg:"#272d36",emptyColor:"#7d8590",selectedBg:"rgba(59, 130, 246, 0.22)",selectedBar:"#60a5fa"};function mn({data:a,loading:u=!1,columns:l,onRowClick:k,getRowId:y,selectedRowId:x,selectedRowSx:ge,rowHeight:he,columnHeight:te,striped:U,rowDivider:ne=!0,onSort:z,onLoadMore:B,sortBy:m,sortDirection:L,showPaper:be=!0,paddingX:$,paddingTop:me=0,paddingBottom:He=0,rowHoverColor:ye,rowHoverOpacity:xe,viewportBuffer:F,overscan:V,scrollbars:O,emptyMessage:I="NO DATA",autoHeight:C=!1,LoadingComponent:Ce,showFooter:Pe,footerHeight:_,footerSx:Y,variant:wt="default",framed:re=!0,rowHeightMode:vt="fixed",tableLayout:we="fixed",renderFullWidthRow:Ae,fullWidthRowSx:oe,onRowContextMenu:Qe,pinnedRows:ae,pinnedRowsMaxHeight:Be,pinnedRowsSx:ie,resetScrollOnDataChange:et=!0,rowKeyFromId:Tt=!1,onEndReached:tt,colorMode:Mt}){let c=wt==="notion",Oe=un(),p=(Mt??Oe.palette.mode)==="dark"?bn:hn,nt=(ae?.length??0)>0,j=te??(c?40:56),D=he??(c?48:50),ve=re?$??(c?"12px":"1rem"):0,Ie=vt==="auto",Ne=ye??(c?p.hoverBg:void 0),rt=xe??(c?1:void 0),St=Math.max(D*12,480),Rt=Math.max(D*12,480),kt=typeof F=="number"?F:F?.top??St,Lt=typeof F=="number"?F:F?.bottom??Rt,Dt=Math.max(D*8,420),Et=Math.max(D*10,520),Ht=typeof V=="number"?V:{main:V?.main??Dt,reverse:V?.reverse??Et},se=D+(ne?1:0),Pt=G(()=>c?{backgroundColor:p.selectedBg,"& > td:first-of-type":{boxShadow:`inset 3px 0 0 ${p.selectedBar}`},"& > td[data-vdt-pinned]":{backgroundColor:p.selectedBg}}:void 0,[c,p]),E=ge??Pt,Te=!E||typeof E!="function",At=G(()=>!Te||x===null||x===void 0||!E?null:{[`& tbody tr[data-row-id="${String(x).replace(/["\\]/g,"\\$&")}"]`]:E},[Te,x,E]),xn=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),[g]=Ee(()=>typeof window>"u"?!1:window.localStorage.getItem("vdt-perf-debug")==="1"),d=b({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}),ze=P(t=>{if(!g)return;let e=d.current;if(!(e.wheelEvents>0||e.rangeChangedCalls>0||e.rowContentCalls>0||e.cellRenderCalls>0))return;let s=e.rowContentCalls>0?e.rowContentMs/e.rowContentCalls:0,f=e.cellRenderCalls>0?e.cellRenderMs/e.cellRenderCalls:0;console.log("[VDT perf]",{reason:t,wheel:{events:e.wheelEvents,inputPx:Math.round(e.wheelInputPx),handlerMs:Number(e.wheelHandlerMs.toFixed(2)),rafFlushes:e.wheelRafFlushes,rafMs:Number(e.wheelRafMs.toFixed(2))},rangeChanged:{calls:e.rangeChangedCalls,totalMs:Number(e.rangeChangedMs.toFixed(2))},rowContent:{calls:e.rowContentCalls,totalMs:Number(e.rowContentMs.toFixed(2)),avgMs:Number(s.toFixed(3)),maxMs:Number(e.rowContentMaxMs.toFixed(3))},cellRender:{calls:e.cellRenderCalls,totalMs:Number(e.cellRenderMs.toFixed(2)),avgMs:Number(f.toFixed(3)),maxMs:Number(e.cellRenderMaxMs.toFixed(3))}}),d.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}},[g]);N(()=>{if(!g||typeof window>"u")return;console.log("[VDT perf] enabled (localStorage vdt-perf-debug=1)");let t=window.setInterval(()=>{ze("interval")},1500);return()=>{window.clearInterval(t),ze("cleanup")}},[ze,g]);let ot=G(()=>De((t,e)=>{let r=b(null),s=b(0),f=b(null);return N(()=>{let n=r.current;if(!n)return;let i=w=>{let T=g?performance.now():0;if(w.shiftKey||Math.abs(w.deltaX)>Math.abs(w.deltaY))return;let v=w.target?.closest?.("[data-vdt-inner-scroll]");if(v&&n.contains(v)&&(w.deltaY<0?v.scrollTop>0:v.scrollTop+v.clientHeight<v.scrollHeight-1))return;w.preventDefault();let W=w.deltaY;w.deltaMode===1?W*=40:w.deltaMode===2&&(W*=n.clientHeight),g&&(d.current.wheelEvents+=1,d.current.wheelInputPx+=W),s.current+=W,f.current===null&&(f.current=requestAnimationFrame(()=>{let Q=g?performance.now():0,h=Math.max(n.clientHeight*.4,160),M=Math.max(-h,Math.min(h,s.current));s.current=0,f.current=null,M!==0&&(n.scrollTop+=M),g&&(d.current.wheelRafFlushes+=1,d.current.wheelRafMs+=performance.now()-Q)}),g&&(d.current.wheelHandlerMs+=performance.now()-T))};return n.addEventListener("wheel",i,{passive:!1}),()=>{n.removeEventListener("wheel",i),f.current!==null&&(cancelAnimationFrame(f.current),f.current=null),s.current=0}},[]),o(fn,{detectInnerScroll:!0,track:gn,...O,children:o(an,{component:R,...t,ref:n=>{r.current=n,typeof e=="function"?e(n):e&&(e.current=n)},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:c?0:ve,paddingTop:me,paddingBottom:He}}})})}),[]),Fe=G(()=>{if(U===!0)return"#f5f5f5";if(typeof U=="string")return U},[U]),[Bt,at]=Ee(u),[Ot,It]=Ee(0);N(()=>{u&&at(!0)},[u]);let it=P(()=>{at(!1)},[]),Nt=Bt,Cn=u&&a.length>0,We=b(!1),$e=b(-1),Ve=b(null),_e=b(null),[zt,Ft]=Ee(!1),Me=P(()=>{let t=_e.current;t&&Ft(t.scrollHeight>t.clientHeight+1)},[]);N(()=>{let t=_e.current;if(!t||typeof ResizeObserver>"u")return;let e=new ResizeObserver(()=>Me());return e.observe(t),()=>e.disconnect()},[Me,C]);let Ye=b(k);Ye.current=k;let le=b(y);le.current=y;let je=b(Qe);je.current=Qe;let st=b(tt);st.current=tt;let lt=b(null),Se=G(()=>{let t=new Map,e=0;return l.forEach(r=>{r.pinned==="left"&&(t.set(String(r.id),e),e+=typeof r.width=="number"?r.width:0)}),t},[l]),Xe=G(()=>{if(l.some(t=>typeof t.minWidth=="number"))return l.reduce((t,e)=>t+(typeof e.width=="number"?e.width:typeof e.minWidth=="number"?e.minWidth:0),0)},[l]),Z=P((t,e)=>{let r=Se.get(String(t.id));return r===void 0?{}:{position:"sticky",left:r,zIndex:e?3:1}},[Se]),Re=!!k,de=b(!1),X=b({x:0,y:0});N(()=>{let t=e=>{let r=e.clientX-X.current.x,s=e.clientY-X.current.y;Math.sqrt(r*r+s*s)>Ze&&(de.current=!0)};return document.addEventListener("mousemove",t),()=>{document.removeEventListener("mousemove",t)}},[]),N(()=>{let t=document.querySelector('[data-testid="virtuoso-scroller"]');t&&t.querySelectorAll(".MuiTableSortLabel-root").forEach(r=>{let s=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});r.dispatchEvent(s)})},[m]);let ke=P(t=>{if(!z)return;z(t,m===t&&L==="asc"?"desc":"asc")},[z,m,L]),Wt=P(t=>{let e=g?performance.now():0;if(st.current?.(),!B){g&&(d.current.rangeChangedCalls+=1,d.current.rangeChangedMs+=performance.now()-e);return}if(u&&a.length===0){g&&(d.current.rangeChangedCalls+=1,d.current.rangeChangedMs+=performance.now()-e);return}let r=a.length>=30,s=t>=a.length-1,f=$e.current===a.length;if(s&&r&&!We.current&&!f){We.current=!0,$e.current=a.length;let n=a.length;B(n,50)}g&&(d.current.rangeChangedCalls+=1,d.current.rangeChangedMs+=performance.now()-e)},[a.length,u,B,g]);N(()=>{u||(We.current=!1)},[u]),N(()=>{a.length===0&&It(t=>t+1)},[a.length]);let dt=b(et);dt.current=et;let Ke=b(a.length),qe=b(void 0);N(()=>{let t=Ke.current,e=a.length,r=e>0?le.current?le.current(a[0],0):a[0]:void 0,s=qe.current;if(e>t&&t>0){Ke.current=e,qe.current=r;return}let f=e<t||t>0&&r!==s;f&&($e.current=-1),Ve.current&&e>0&&f&&dt.current&&Ve.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),Ke.current=e,qe.current=r},[a]);let ct=P(()=>{let t={},e=[];if(l.forEach(n=>{n.group?(t[n.group]||(t[n.group]=[]),t[n.group].push(n)):e.push(n)}),!(Object.keys(t).length>0))return o(pe,{children:l.map(n=>o(J,{align:n.align||"left",...n.headerProps,style:{width:n.width,minWidth:n.width??n.minWidth,...n.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px",...Z(n,!0),...n.headerProps?.style},children:n.sortable?o("div",{style:{display:"flex",alignItems:"center",justifyContent:n.align==="center"?"center":n.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:A(R,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(n.id)),children:[n.text,o(Ue,{active:m===n.id,direction:m===n.id?L:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:m===n.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)"}}})]})}):n.text},String(n.id)))});let s=[...e.map(n=>o(J,{rowSpan:2,align:n.align||"left",...n.headerProps,style:{width:n.width,minWidth:n.width,...n.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px",...Z(n,!0),...n.headerProps?.style},children:n.sortable&&z?o("div",{style:{display:"flex",alignItems:"center",justifyContent:n.align==="center"?"center":n.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:A(R,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(n.id)),children:[n.text,o(Ue,{active:m===n.id,direction:m===n.id?L:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:m===n.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)"}}})]})}):n.text},String(n.id))),...Object.entries(t).map(([n,i])=>o(J,{align:"center",colSpan:i.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:n},n))],f=[...Object.values(t).flat().map(n=>o(J,{align:n.align||"left",...n.headerProps,style:{width:n.width,minWidth:n.width,...n.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px",...Z(n,!0),...n.headerProps?.style},children:n.sortable&&z?o("div",{style:{display:"flex",alignItems:"center",justifyContent:n.align==="center"?"center":n.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:A(R,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(n.id)),children:[n.text,o(Ue,{active:m===n.id,direction:m===n.id?L:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:m===n.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)"}}})]})}):n.text},String(n.id)))];return A(fe,{children:[o(pe,{children:s}),o(pe,{children:f})]})},[l,m,L,ke,z,j,Z]),Le=P((t,e)=>{let r=g?performance.now():0;if(!e){if(g){d.current.rowContentCalls+=1;let i=performance.now()-r;d.current.rowContentMs+=i,d.current.rowContentMaxMs=Math.max(d.current.rowContentMaxMs,i)}return null}let s=Ae?Ae(e,t):null;if(s!=null)return o(J,{colSpan:l.length,"data-vdt-pad":"",sx:[{padding:c?"0 14px":"8px 16px"},...Array.isArray(oe)?oe:oe?[oe]:[]],children:s});let f=0,n=l.map((i,w)=>{if(f>0)return f-=1,null;let T=i.colSpan?Math.max(1,Math.min(i.colSpan(e,t),l.length-w)):1;f=T-1;let v=g?performance.now():0,W=i.render?i.render(e,t):String(e[i.id]||"");if(g){let S=performance.now()-v;d.current.cellRenderCalls+=1,d.current.cellRenderMs+=S,d.current.cellRenderMaxMs=Math.max(d.current.cellRenderMaxMs,S)}let Q=Se.has(String(i.id)),h=i.cellPadding!==void 0,M=i.rowSpan?i.rowSpan(e,t):1;if(M<=0)return null;let K=i.onCellClick;return o(J,{align:i.align||"left",rowSpan:M>1?M:void 0,colSpan:T>1?T:void 0,"data-vdt-pad":h?"":void 0,"data-vdt-pinned":Q?"":void 0,"data-vdt-cell-click":K?"":void 0,onClick:K?S=>{let ee=S.clientX-X.current.x,q=S.clientY-X.current.y;S.stopPropagation(),!(Math.sqrt(ee*ee+q*q)>Ze)&&K(e,t,S)}:void 0,style:{...T>1?{}:{width:i.width,minWidth:i.width??i.minWidth},...i.primary?{fontSize:15}:{},...i.style,...i.cellStyle?i.cellStyle(e,t):{},padding:h?i.cellPadding:"8px 16px",...Z(i,!1)},children:W},String(i.id))});if(g){d.current.rowContentCalls+=1;let i=performance.now()-r;d.current.rowContentMs+=i,d.current.rowContentMaxMs=Math.max(d.current.rowContentMaxMs,i)}return o(fe,{children:n})},[l,g,Ae,oe,c,Se,Z]),ut=P(()=>{let t=ct();if(!ae||ae.length===0)return t;let e=lt.current;return A(fe,{children:[t,o("tr",{"data-vdt-pinned-area":"",children:o("td",{colSpan:l.length,style:{padding:0,border:0},children:o(R,{"data-vdt-inner-scroll":"",sx:[{maxHeight:Be,overflowY:Be?"auto":"visible",overflowX:"hidden",scrollbarWidth:"thin",borderBottom:`1px solid ${c?p.borderStrong:"rgba(224, 224, 224, 1)"}`,"& tbody tr:last-of-type > td":{borderBottom:"none"}},...Array.isArray(ie)?ie:ie?[ie]:[]],children:A("table",{style:{width:"100%",tableLayout:we,borderCollapse:"separate",borderSpacing:0},children:[o("colgroup",{children:l.map(r=>o("col",{style:{width:r.width,minWidth:r.width??r.minWidth}},String(r.id)))}),o(xt,{children:ae.map((r,s)=>e?o(e,{item:r,"data-index":s,"data-vdt-pinned-row":"",children:Le(s,r)},y?String(y(r,s)):`p${s}`):null)})]})})})})]})},[ct,ae,Be,ie,l,Le,we,y,c,p]),H=Pe??l.some(t=>typeof t.footer=="function"),pt=P(()=>{if(!H)return null;let t=[];for(let e=0;e<l.length;e+=1){let r=l[e],s=r.footerColSpan&&r.footerColSpan>1?Math.min(r.footerColSpan,l.length-e):1;t.push(o(J,{align:r.align||"left",colSpan:s>1?s:void 0,style:{...s>1?{}:{width:r.width,minWidth:r.width},...r.style,fontWeight:"bold",padding:c?"0 14px":"16px"},children:r.footer?r.footer(a):null},String(r.id))),e+=s-1}return o(pe,{children:t})},[H,l,a,c]),Ge=G(()=>({Scroller:ot,Table:t=>o(on,{...t,sx:{borderCollapse:"separate",tableLayout:we,...Xe?{minWidth:Xe}:{},marginRight:re?"16px":0,...H?{height:"100%"}:{}}}),TableHead:De((t,e)=>o(sn,{...t,ref:e,sx:{userSelect:"none","& > tr":{height:j,"& > th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:t=>{let{item:e,selected:r,"aria-selected":s,className:f,...n}=t,i=n["data-index"]??0,w=i%2===1,T=e&&le.current?le.current(e,i):i,v=!Te&&x!==null&&x!==void 0&&T===x,W=v&&E?typeof E=="function"?E(e,i):E:void 0,Q=String(f??"").split(/\s+/).filter(h=>h!=="Mui-selected"&&h!=="Mui-focusVisible").join(" ");return o(pe,{...n,"data-row-id":T!=null?String(T):void 0,className:Q||void 0,selected:v,onMouseDown:h=>{de.current=!1,X.current={x:h.clientX,y:h.clientY}},onContextMenu:h=>{e&&je.current&&je.current(e,i,h)},onClick:h=>{let M=h.clientX-X.current.x,K=h.clientY-X.current.y;if(Math.sqrt(M*M+K*K)>Ze||de.current){h.preventDefault(),h.stopPropagation(),de.current=!1;return}e&&Ye.current&&Ye.current(e,i),de.current=!1},sx:[{userSelect:"none",...Ie?{"& > td":{height:se}}:{height:se,maxHeight:se},boxSizing:"border-box",backgroundColor:w&&Fe?Fe:"transparent","& td:not([data-vdt-pad])":{padding:"8px 16px"},"& td":{boxSizing:"border-box",borderBottom:ne?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":Re&&!v?{backgroundColor:h=>{let M=h.palette.mode==="dark",S=Ne??"#000000",ee=rt??.06;if(!Ne)return M?`rgba(255, 255, 255, ${ee})`:`rgba(0, 0, 0, ${ee})`;let q=S.replace("#","").trim();if(q.length!==6)return S;let Kt=parseInt(q.substring(0,2),16),qt=parseInt(q.substring(2,4),16),Gt=parseInt(q.substring(4,6),16);return`rgba(${Kt}, ${qt}, ${Gt}, ${ee})`}}:void 0,cursor:Re?"pointer":void 0},W]})},TableBody:De((t,e)=>{let{children:r,...s}=t;return A(xt,{...s,ref:e,sx:H?{height:"100%"}:void 0,children:[r,H&&o("tr",{"aria-hidden":!0,style:{height:"100%"},children:o("td",{colSpan:l.length,style:{padding:0,border:0}})})]})}),TableFoot:De((t,e)=>o(ln,{...t,ref:e,sx:[{"& tr":{height:_??D,maxHeight:_??D,boxSizing:"border-box"},"& td":{height:_??D,boxSizing:"border-box",backgroundColor:r=>r.palette.mode==="dark"?"#1e1e1e":"#ffffff",padding:"0 16px",color:"inherit",fontSize:"0.875rem",border:"none",boxShadow:`inset 0 1px 0 0 ${c?p.borderStrong:"#000000"}`}},...Array.isArray(Y)?Y:Y?[Y]:[]]}))}),[Re,Te?null:x,E,D,Fe,ne,j,Ne,rt,ot,_,Y,H,c,p,l,we,re,Ie,Xe]);lt.current=Ge.TableRow;let $t=Ge,ce=Ge,Vt=ce.Table,_t=ce.TableHead,Yt=ce.TableBody,jt=ce.TableRow,Xt=ce.TableFoot,ft=A(R,{sx:{position:"relative",height:C?"auto":"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:t=>c?`${p.bg} !important`:t.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"},...At??{},"& tbody td[data-vdt-pinned]":{backgroundColor:c?p.bg:Oe.palette.background.paper},"& tbody td[data-vdt-cell-click]":{cursor:"pointer"},"& tbody td[data-vdt-cell-click]:hover":{backgroundColor:c?p.hoverBg:Oe.palette.mode==="dark"?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.04)"},...c&&Re?{"& tbody tr:hover td[data-vdt-pinned]":{backgroundColor:p.hoverBg}}:{},...c?{...re?{border:`1px solid ${p.borderStrong}`,borderRadius:"4px"}:{"& table":{backgroundColor:p.bg}},overflow:"hidden","& thead tr th":{height:j,boxSizing:"border-box",padding:"0 14px !important",fontSize:13,fontWeight:"500 !important",color:p.headerColor,backgroundColor:`${p.bg} !important`,borderTop:"none",borderBottom:`1px solid ${p.borderStrong}`,borderRight:`1px solid ${p.border}`,"&:last-of-type":{borderRight:"none"}},"& tbody tr td:not([data-vdt-pad])":{padding:"0 14px !important"},"& tbody tr td":{fontSize:14,borderBottom:`1px solid ${p.border}`},...a.length>0&&(C||zt||H)?{[`& tbody tr[data-index="${a.length-1}"]:not([data-vdt-pinned-row]) td`]:{borderBottom:"none"}}:{}}:{}},children:[C?o(R,{sx:{overflowX:"auto",width:"100%"},children:A(Vt,{children:[o(_t,{children:ut()}),o(Yt,{children:a.map((t,e)=>o(jt,{item:t,"data-index":e,children:Le(e,t)},y?String(y(t,e)):e))}),H?o(Xt,{children:pt()}):null]})}):o(pn,{ref:Ve,data:a,totalCount:B?a.length+1:a.length,defaultItemHeight:se,fixedItemHeight:Ie?void 0:se,fixedHeaderContent:ut,fixedFooterContent:H?pt:void 0,itemContent:Le,computeItemKey:Tt&&y?(t,e)=>e?y(e,t):`vdt-${t}`:void 0,endReached:Wt,scrollerRef:t=>{_e.current=t instanceof HTMLElement?t:null,Me()},totalListHeightChanged:Me,style:{height:"100%"},increaseViewportBy:{top:kt,bottom:Lt},overscan:Ht,followOutput:!1,components:$t},Ot),a.length===0&&!u&&!nt&&c&&typeof I=="string"&&o(R,{sx:{position:C?"static":"absolute",top:j,left:0,right:0,py:6,textAlign:"center",fontSize:14,color:p.emptyColor},children:I}),a.length===0&&!u&&!nt&&!(c&&typeof I=="string")&&o(R,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof I=="string"?A(fe,{children:[o(R,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),o(cn,{variant:"body1",sx:{color:"text.secondary"},children:I})]}):I}),Nt&&o(fe,{children:Ce?o(Ce,{visible:u,onComplete:it}):o(bt,{visible:u,onComplete:it,size:40,indicator:o(yt,{}),sx:{top:`${l.some(t=>t.group)?j*2:j}px`,bottom:`${H?_??D:0}px`},background:{show:a.length===0,opacity:.8}})})]}),gt=c&&re?{paddingRight:ve,paddingTop:Ct,paddingBottom:Ct}:{};return be?o(dn,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:ve,...gt,boxSizing:"border-box",height:C?"auto":"100%",minHeight:0,flex:C?"none":1,display:"flex",flexDirection:"column"},children:ft}):o(R,{className:"grow",style:{padding:0,paddingLeft:ve,...gt,boxSizing:"border-box",height:C?"auto":"100%",minHeight:0,flex:C?"none":1,display:"flex",flexDirection:"column"},children:ft})}var yn=rn(mn);export{yn as VirtualDataTable};
4
+ `;function yt({size:a=54}){return nn(tn,{children:[mt("style",{children:en}),mt("span",{className:"vdt-css-spinner",role:"progressbar","aria-label":"loading",style:{display:"inline-block",width:a,height:a}})]})}import fn from"@ehfuse/overlay-scrollbar";import{Fragment as fe,jsx as o,jsxs as A}from"react/jsx-runtime";var gn={alignment:"default",margin:0,radius:0},Ze=5,hn={bg:"#ffffff",border:"#e6e6e3",borderStrong:"#dedddb",headerColor:"#787774",hoverBg:"#f8f8f7",emptyColor:"#9b9a97",selectedBg:"#dbeafe",selectedBar:"#3b82f6"},Ct="12px",bn={bg:"#1e1e1e",border:"#2c333c",borderStrong:"#3b434e",headerColor:"#a3adbb",hoverBg:"#272d36",emptyColor:"#7d8590",selectedBg:"rgba(59, 130, 246, 0.22)",selectedBar:"#60a5fa"};function mn({data:a,loading:u=!1,columns:l,onRowClick:k,getRowId:y,selectedRowId:x,selectedRowSx:ge,rowHeight:he,columnHeight:te,striped:U,rowDivider:ne=!0,onSort:z,onLoadMore:B,sortBy:m,sortDirection:L,showPaper:be=!0,paddingX:$,paddingTop:me=0,paddingBottom:He=0,rowHoverColor:ye,rowHoverOpacity:xe,viewportBuffer:F,overscan:V,scrollbars:I,emptyMessage:O="NO DATA",autoHeight:C=!1,LoadingComponent:Ce,showFooter:Pe,footerHeight:_,footerSx:Y,variant:wt="default",framed:re=!0,rowHeightMode:vt="fixed",tableLayout:we="fixed",renderFullWidthRow:Ae,fullWidthRowSx:oe,onRowContextMenu:Qe,pinnedRows:ae,pinnedRowsMaxHeight:Be,pinnedRowsSx:ie,resetScrollOnDataChange:et=!0,rowKeyFromId:Tt=!1,onEndReached:tt,colorMode:Mt}){let c=wt==="notion",Ie=un(),p=(Mt??Ie.palette.mode)==="dark"?bn:hn,nt=(ae?.length??0)>0,j=te??(c?40:56),D=he??(c?48:50),ve=re?$??(c?"12px":"1rem"):0,Oe=vt==="auto",Ne=ye??(c?p.hoverBg:void 0),rt=xe??(c?1:void 0),St=Math.max(D*12,480),Rt=Math.max(D*12,480),kt=typeof F=="number"?F:F?.top??St,Lt=typeof F=="number"?F:F?.bottom??Rt,Dt=Math.max(D*8,420),Et=Math.max(D*10,520),Ht=typeof V=="number"?V:{main:V?.main??Dt,reverse:V?.reverse??Et},se=D+(ne?1:0),Pt=G(()=>c?{backgroundColor:p.selectedBg,"& > td:first-of-type":{boxShadow:`inset 3px 0 0 ${p.selectedBar}`},"& > td[data-vdt-pinned]":{backgroundColor:p.selectedBg}}:void 0,[c,p]),E=ge??Pt,Te=!E||typeof E!="function",At=G(()=>!Te||x===null||x===void 0||!E?null:{[`& tbody tr[data-row-id="${String(x).replace(/["\\]/g,"\\$&")}"]`]:E},[Te,x,E]),xn=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),[g]=Ee(()=>typeof window>"u"?!1:window.localStorage.getItem("vdt-perf-debug")==="1"),d=b({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}),ze=P(t=>{if(!g)return;let e=d.current;if(!(e.wheelEvents>0||e.rangeChangedCalls>0||e.rowContentCalls>0||e.cellRenderCalls>0))return;let s=e.rowContentCalls>0?e.rowContentMs/e.rowContentCalls:0,f=e.cellRenderCalls>0?e.cellRenderMs/e.cellRenderCalls:0;console.log("[VDT perf]",{reason:t,wheel:{events:e.wheelEvents,inputPx:Math.round(e.wheelInputPx),handlerMs:Number(e.wheelHandlerMs.toFixed(2)),rafFlushes:e.wheelRafFlushes,rafMs:Number(e.wheelRafMs.toFixed(2))},rangeChanged:{calls:e.rangeChangedCalls,totalMs:Number(e.rangeChangedMs.toFixed(2))},rowContent:{calls:e.rowContentCalls,totalMs:Number(e.rowContentMs.toFixed(2)),avgMs:Number(s.toFixed(3)),maxMs:Number(e.rowContentMaxMs.toFixed(3))},cellRender:{calls:e.cellRenderCalls,totalMs:Number(e.cellRenderMs.toFixed(2)),avgMs:Number(f.toFixed(3)),maxMs:Number(e.cellRenderMaxMs.toFixed(3))}}),d.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}},[g]);N(()=>{if(!g||typeof window>"u")return;console.log("[VDT perf] enabled (localStorage vdt-perf-debug=1)");let t=window.setInterval(()=>{ze("interval")},1500);return()=>{window.clearInterval(t),ze("cleanup")}},[ze,g]);let ot=G(()=>De((t,e)=>{let r=b(null),s=b(0),f=b(null);return N(()=>{let n=r.current;if(!n)return;let i=w=>{let T=g?performance.now():0;if(w.shiftKey||Math.abs(w.deltaX)>Math.abs(w.deltaY))return;let v=w.target?.closest?.("[data-vdt-inner-scroll]");if(v&&n.contains(v)&&(w.deltaY<0?v.scrollTop>0:v.scrollTop+v.clientHeight<v.scrollHeight-1))return;w.preventDefault();let W=w.deltaY;w.deltaMode===1?W*=40:w.deltaMode===2&&(W*=n.clientHeight),g&&(d.current.wheelEvents+=1,d.current.wheelInputPx+=W),s.current+=W,f.current===null&&(f.current=requestAnimationFrame(()=>{let Q=g?performance.now():0,h=Math.max(n.clientHeight*.4,160),M=Math.max(-h,Math.min(h,s.current));s.current=0,f.current=null,M!==0&&(n.scrollTop+=M),g&&(d.current.wheelRafFlushes+=1,d.current.wheelRafMs+=performance.now()-Q)}),g&&(d.current.wheelHandlerMs+=performance.now()-T))};return n.addEventListener("wheel",i,{passive:!1}),()=>{n.removeEventListener("wheel",i),f.current!==null&&(cancelAnimationFrame(f.current),f.current=null),s.current=0}},[]),o(fn,{detectInnerScroll:!0,track:gn,...I,children:o(an,{component:R,...t,ref:n=>{r.current=n,typeof e=="function"?e(n):e&&(e.current=n)},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:c?0:ve,paddingTop:me,paddingBottom:He}}})})}),[]),Fe=G(()=>{if(U===!0)return"#f5f5f5";if(typeof U=="string")return U},[U]),[Bt,at]=Ee(u),[It,Ot]=Ee(0);N(()=>{u&&at(!0)},[u]);let it=P(()=>{at(!1)},[]),Nt=Bt,Cn=u&&a.length>0,We=b(!1),$e=b(-1),Ve=b(null),_e=b(null),[zt,Ft]=Ee(!1),Me=P(()=>{let t=_e.current;t&&Ft(t.scrollHeight>t.clientHeight+1)},[]);N(()=>{let t=_e.current;if(!t||typeof ResizeObserver>"u")return;let e=new ResizeObserver(()=>Me());return e.observe(t),()=>e.disconnect()},[Me,C]);let Ye=b(k);Ye.current=k;let le=b(y);le.current=y;let je=b(Qe);je.current=Qe;let st=b(tt);st.current=tt;let lt=b(null),Se=G(()=>{let t=new Map,e=0;return l.forEach(r=>{r.pinned==="left"&&(t.set(String(r.id),e),e+=typeof r.width=="number"?r.width:0)}),t},[l]),Ke=G(()=>{if(l.some(t=>typeof t.minWidth=="number"))return l.reduce((t,e)=>t+(typeof e.width=="number"?e.width:typeof e.minWidth=="number"?e.minWidth:0),0)},[l]),Z=P((t,e)=>{let r=Se.get(String(t.id));return r===void 0?{}:{position:"sticky",left:r,zIndex:e?3:1}},[Se]),Re=!!k,de=b(!1),K=b({x:0,y:0});N(()=>{let t=e=>{let r=e.clientX-K.current.x,s=e.clientY-K.current.y;Math.sqrt(r*r+s*s)>Ze&&(de.current=!0)};return document.addEventListener("mousemove",t),()=>{document.removeEventListener("mousemove",t)}},[]),N(()=>{let t=document.querySelector('[data-testid="virtuoso-scroller"]');t&&t.querySelectorAll(".MuiTableSortLabel-root").forEach(r=>{let s=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});r.dispatchEvent(s)})},[m]);let ke=P(t=>{if(!z)return;z(t,m===t&&L==="asc"?"desc":"asc")},[z,m,L]),Wt=P(t=>{let e=g?performance.now():0;if(st.current?.(),!B){g&&(d.current.rangeChangedCalls+=1,d.current.rangeChangedMs+=performance.now()-e);return}if(u&&a.length===0){g&&(d.current.rangeChangedCalls+=1,d.current.rangeChangedMs+=performance.now()-e);return}let r=a.length>=30,s=t>=a.length-1,f=$e.current===a.length;if(s&&r&&!We.current&&!f){We.current=!0,$e.current=a.length;let n=a.length;B(n,50)}g&&(d.current.rangeChangedCalls+=1,d.current.rangeChangedMs+=performance.now()-e)},[a.length,u,B,g]);N(()=>{u||(We.current=!1)},[u]),N(()=>{a.length===0&&Ot(t=>t+1)},[a.length]);let dt=b(et);dt.current=et;let Xe=b(a.length),qe=b(void 0);N(()=>{let t=Xe.current,e=a.length,r=e>0?le.current?le.current(a[0],0):a[0]:void 0,s=qe.current;if(e>t&&t>0){Xe.current=e,qe.current=r;return}let f=e<t||t>0&&r!==s;f&&($e.current=-1),Ve.current&&e>0&&f&&dt.current&&Ve.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),Xe.current=e,qe.current=r},[a]);let ct=P(()=>{let t={},e=[];if(l.forEach(n=>{n.group?(t[n.group]||(t[n.group]=[]),t[n.group].push(n)):e.push(n)}),!(Object.keys(t).length>0))return o(pe,{children:l.map(n=>o(J,{align:n.align||"left",...n.headerProps,style:{width:n.width,minWidth:n.width??n.minWidth,...n.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px",...Z(n,!0),...n.headerProps?.style},children:n.sortable?o("div",{style:{display:"flex",alignItems:"center",justifyContent:n.align==="center"?"center":n.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:A(R,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(n.id)),children:[n.text,o(Ue,{active:m===n.id,direction:m===n.id?L:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:m===n.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)"}}})]})}):n.text},String(n.id)))});let s=[...e.map(n=>o(J,{rowSpan:2,align:n.align||"left",...n.headerProps,style:{width:n.width,minWidth:n.width,...n.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px",...Z(n,!0),...n.headerProps?.style},children:n.sortable&&z?o("div",{style:{display:"flex",alignItems:"center",justifyContent:n.align==="center"?"center":n.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:A(R,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(n.id)),children:[n.text,o(Ue,{active:m===n.id,direction:m===n.id?L:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:m===n.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)"}}})]})}):n.text},String(n.id))),...Object.entries(t).map(([n,i])=>o(J,{align:"center",colSpan:i.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:n},n))],f=[...Object.values(t).flat().map(n=>o(J,{align:n.align||"left",...n.headerProps,style:{width:n.width,minWidth:n.width,...n.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px",...Z(n,!0),...n.headerProps?.style},children:n.sortable&&z?o("div",{style:{display:"flex",alignItems:"center",justifyContent:n.align==="center"?"center":n.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:A(R,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(n.id)),children:[n.text,o(Ue,{active:m===n.id,direction:m===n.id?L:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:m===n.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)"}}})]})}):n.text},String(n.id)))];return A(fe,{children:[o(pe,{children:s}),o(pe,{children:f})]})},[l,m,L,ke,z,j,Z]),Le=P((t,e)=>{let r=g?performance.now():0;if(!e){if(g){d.current.rowContentCalls+=1;let i=performance.now()-r;d.current.rowContentMs+=i,d.current.rowContentMaxMs=Math.max(d.current.rowContentMaxMs,i)}return null}let s=Ae?Ae(e,t):null;if(s!=null)return o(J,{colSpan:l.length,"data-vdt-pad":"",sx:[{padding:c?"0 14px":"8px 16px"},...Array.isArray(oe)?oe:oe?[oe]:[]],children:s});let f=0,n=l.map((i,w)=>{if(f>0)return f-=1,null;let T=i.colSpan?Math.max(1,Math.min(i.colSpan(e,t),l.length-w)):1;f=T-1;let v=g?performance.now():0,W=i.render?i.render(e,t):String(e[i.id]||"");if(g){let S=performance.now()-v;d.current.cellRenderCalls+=1,d.current.cellRenderMs+=S,d.current.cellRenderMaxMs=Math.max(d.current.cellRenderMaxMs,S)}let Q=Se.has(String(i.id)),h=i.cellPadding!==void 0,M=i.rowSpan?i.rowSpan(e,t):1;if(M<=0)return null;let X=i.onCellClick;return o(J,{align:i.align||"left",rowSpan:M>1?M:void 0,colSpan:T>1?T:void 0,"data-vdt-pad":h?"":void 0,"data-vdt-pinned":Q?"":void 0,"data-vdt-cell-click":X?"":void 0,onClick:X?S=>{let ee=S.clientX-K.current.x,q=S.clientY-K.current.y;S.stopPropagation(),!(Math.sqrt(ee*ee+q*q)>Ze)&&X(e,t,S)}:void 0,style:{...T>1?{}:{width:i.width,minWidth:i.width??i.minWidth},...i.primary?{fontSize:15}:{},...i.style,...i.cellStyle?i.cellStyle(e,t):{},padding:h?i.cellPadding:"8px 16px",...Z(i,!1)},children:W},String(i.id))});if(g){d.current.rowContentCalls+=1;let i=performance.now()-r;d.current.rowContentMs+=i,d.current.rowContentMaxMs=Math.max(d.current.rowContentMaxMs,i)}return o(fe,{children:n})},[l,g,Ae,oe,c,Se,Z]),ut=P(()=>{let t=ct();if(!ae||ae.length===0)return t;let e=lt.current;return A(fe,{children:[t,o("tr",{"data-vdt-pinned-area":"",children:o("td",{colSpan:l.length,style:{padding:0,border:0},children:o(R,{"data-vdt-inner-scroll":"",sx:[{maxHeight:Be,overflowY:Be?"auto":"visible",overflowX:"hidden",scrollbarWidth:"thin",borderBottom:`1px solid ${c?p.borderStrong:"rgba(224, 224, 224, 1)"}`,"& tbody tr:last-of-type > td":{borderBottom:"none"}},...Array.isArray(ie)?ie:ie?[ie]:[]],children:A("table",{style:{width:"100%",tableLayout:we,borderCollapse:"separate",borderSpacing:0},children:[o("colgroup",{children:l.map(r=>o("col",{style:{width:r.width,minWidth:r.width??r.minWidth}},String(r.id)))}),o(xt,{children:ae.map((r,s)=>e?o(e,{item:r,"data-index":s,"data-vdt-pinned-row":"",children:Le(s,r)},y?String(y(r,s)):`p${s}`):null)})]})})})})]})},[ct,ae,Be,ie,l,Le,we,y,c,p]),H=Pe??l.some(t=>typeof t.footer=="function"),pt=P(()=>{if(!H)return null;let t=[];for(let e=0;e<l.length;e+=1){let r=l[e],s=r.footerColSpan&&r.footerColSpan>1?Math.min(r.footerColSpan,l.length-e):1;t.push(o(J,{align:r.align||"left",colSpan:s>1?s:void 0,style:{...s>1?{}:{width:r.width,minWidth:r.width},...r.style,fontWeight:"bold",padding:c?"0 14px":"16px"},children:r.footer?r.footer(a):null},String(r.id))),e+=s-1}return o(pe,{children:t})},[H,l,a,c]),Ge=G(()=>({Scroller:ot,Table:t=>o(on,{...t,sx:{borderCollapse:"separate",tableLayout:we,...Ke?{minWidth:Ke}:{},marginRight:re?"16px":0,...H?{height:"100%"}:{}}}),TableHead:De((t,e)=>o(sn,{...t,ref:e,sx:{userSelect:"none","& > tr":{height:j,"& > th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:t=>{let{item:e,selected:r,"aria-selected":s,className:f,...n}=t,i=n["data-index"]??0,w=i%2===1,T=e&&le.current?le.current(e,i):i,v=!Te&&x!==null&&x!==void 0&&T===x,W=v&&E?typeof E=="function"?E(e,i):E:void 0,Q=String(f??"").split(/\s+/).filter(h=>h!=="Mui-selected"&&h!=="Mui-focusVisible").join(" ");return o(pe,{...n,"data-row-id":T!=null?String(T):void 0,className:Q||void 0,selected:v,onMouseDown:h=>{de.current=!1,K.current={x:h.clientX,y:h.clientY}},onContextMenu:h=>{e&&je.current&&je.current(e,i,h)},onClick:h=>{let M=h.clientX-K.current.x,X=h.clientY-K.current.y;if(Math.sqrt(M*M+X*X)>Ze||de.current){h.preventDefault(),h.stopPropagation(),de.current=!1;return}e&&Ye.current&&Ye.current(e,i),de.current=!1},sx:[{userSelect:"none",...Oe?{"& > td":{height:se}}:{height:se,maxHeight:se},boxSizing:"border-box",backgroundColor:w&&Fe?Fe:"transparent","& td:not([data-vdt-pad])":{padding:"8px 16px"},"& td":{boxSizing:"border-box",borderBottom:ne?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":Re&&!v?{backgroundColor:h=>{let M=h.palette.mode==="dark",S=Ne??"#000000",ee=rt??.06;if(!Ne)return M?`rgba(255, 255, 255, ${ee})`:`rgba(0, 0, 0, ${ee})`;let q=S.replace("#","").trim();if(q.length!==6)return S;let Xt=parseInt(q.substring(0,2),16),qt=parseInt(q.substring(2,4),16),Gt=parseInt(q.substring(4,6),16);return`rgba(${Xt}, ${qt}, ${Gt}, ${ee})`}}:void 0,cursor:Re?"pointer":void 0},W]})},TableBody:De((t,e)=>{let{children:r,...s}=t;return A(xt,{...s,ref:e,sx:H?{height:"100%"}:void 0,children:[r,H&&o("tr",{"aria-hidden":!0,style:{height:"100%"},children:o("td",{colSpan:l.length,style:{padding:0,border:0}})})]})}),TableFoot:De((t,e)=>o(ln,{...t,ref:e,sx:[{"& tr":{height:_??D,maxHeight:_??D,boxSizing:"border-box"},"& td":{height:_??D,boxSizing:"border-box",backgroundColor:r=>r.palette.mode==="dark"?"#1e1e1e":"#ffffff",padding:"0 16px",color:"inherit",fontSize:"0.875rem",border:"none",boxShadow:`inset 0 1px 0 0 ${c?p.borderStrong:"#000000"}`}},...Array.isArray(Y)?Y:Y?[Y]:[]]}))}),[Re,Te?null:x,E,D,Fe,ne,j,Ne,rt,ot,_,Y,H,c,p,l,we,re,Oe,Ke]);lt.current=Ge.TableRow;let $t=Ge,ce=Ge,Vt=ce.Table,_t=ce.TableHead,Yt=ce.TableBody,jt=ce.TableRow,Kt=ce.TableFoot,ft=A(R,{sx:{position:"relative",height:C?"auto":"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:t=>c?`${p.bg} !important`:t.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"},...At??{},"& tbody td[data-vdt-pinned]":{backgroundColor:c?p.bg:Ie.palette.background.paper},"& tbody td[data-vdt-cell-click]":{cursor:"pointer"},"& tbody td[data-vdt-cell-click]:hover":{backgroundColor:c?p.hoverBg:Ie.palette.mode==="dark"?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.04)"},...c&&Re?{"& tbody tr:hover td[data-vdt-pinned]":{backgroundColor:p.hoverBg}}:{},...c?{...re?{border:`1px solid ${p.borderStrong}`,borderRadius:"4px"}:{"& table":{backgroundColor:p.bg}},overflow:"hidden","& thead tr th":{height:j,boxSizing:"border-box",padding:"0 14px !important",fontSize:13,fontWeight:"500 !important",color:p.headerColor,backgroundColor:`${p.bg} !important`,borderTop:"none",borderBottom:`1px solid ${p.borderStrong}`,borderRight:`1px solid ${p.border}`,"&:last-of-type":{borderRight:"none"}},"& tbody tr td:not([data-vdt-pad])":{padding:"0 14px !important"},"& tbody tr td":{fontSize:14,borderBottom:`1px solid ${p.border}`},...a.length>0&&(C||zt||H)?{[`& tbody tr[data-index="${a.length-1}"]:not([data-vdt-pinned-row]) td`]:{borderBottom:"none"}}:{}}:{}},children:[C?o(R,{sx:{overflowX:"auto",width:"100%"},children:A(Vt,{children:[o(_t,{children:ut()}),o(Yt,{children:a.map((t,e)=>o(jt,{item:t,"data-index":e,children:Le(e,t)},y?String(y(t,e)):e))}),H?o(Kt,{children:pt()}):null]})}):o(pn,{ref:Ve,data:a,totalCount:B?a.length+1:a.length,defaultItemHeight:se,fixedItemHeight:Oe?void 0:se,fixedHeaderContent:ut,fixedFooterContent:H?pt:void 0,itemContent:Le,...Tt&&y?{computeItemKey:(t,e)=>e?y(e,t):`vdt-${t}`}:{},endReached:Wt,scrollerRef:t=>{_e.current=t instanceof HTMLElement?t:null,Me()},totalListHeightChanged:Me,style:{height:"100%"},increaseViewportBy:{top:kt,bottom:Lt},overscan:Ht,followOutput:!1,components:$t},It),a.length===0&&!u&&!nt&&c&&typeof O=="string"&&o(R,{sx:{position:C?"static":"absolute",top:j,left:0,right:0,py:6,textAlign:"center",fontSize:14,color:p.emptyColor},children:O}),a.length===0&&!u&&!nt&&!(c&&typeof O=="string")&&o(R,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof O=="string"?A(fe,{children:[o(R,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),o(cn,{variant:"body1",sx:{color:"text.secondary"},children:O})]}):O}),Nt&&o(fe,{children:Ce?o(Ce,{visible:u,onComplete:it}):o(bt,{visible:u,onComplete:it,size:40,indicator:o(yt,{}),sx:{top:`${l.some(t=>t.group)?j*2:j}px`,bottom:`${H?_??D:0}px`},background:{show:a.length===0,opacity:.8}})})]}),gt=c&&re?{paddingRight:ve,paddingTop:Ct,paddingBottom:Ct}:{};return be?o(dn,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:ve,...gt,boxSizing:"border-box",height:C?"auto":"100%",minHeight:0,flex:C?"none":1,display:"flex",flexDirection:"column"},children:ft}):o(R,{className:"grow",style:{padding:0,paddingLeft:ve,...gt,boxSizing:"border-box",height:C?"auto":"100%",minHeight:0,flex:C?"none":1,display:"flex",flexDirection:"column"},children:ft})}var yn=rn(mn);export{yn as VirtualDataTable};
5
5
  /**
6
6
  * Virtual Data Table - A high-performance virtual data table component for React
7
7
  *