@ehfuse/mui-virtual-data-table 1.1.33 → 1.1.35

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,27 +1,7 @@
1
- import{forwardRef as Ye,useCallback as Me,useMemo as Xe,useRef as z,useEffect as ge,memo as At,useState as ot}from"react";import{Box as be,Table as zt,TableBody as Wt,TableCell as Oe,TableContainer as qt,TableHead as Vt,TableFooter as jt,TableRow as We,TableSortLabel as it,Paper as _t,Typography as Yt,useTheme as Xt}from"@mui/material";import{TableVirtuoso as Kt}from"react-virtuoso";import{jsx as nt}from"react/jsx-runtime";import{useRef as ut,useState as wt,useEffect as Mt}from"react";import{Box as Ct,CircularProgress as Tt}from"@mui/material";var Ae=function(){return Ae=Object.assign||function(d){for(var c,S=1,L=arguments.length;S<L;S++){c=arguments[S];for(var y in c)Object.prototype.hasOwnProperty.call(c,y)&&(d[y]=c[y])}return d},Ae.apply(this,arguments)};function dt(l){var d=l.visible,c=l.onComplete,S=l.fadeoutDuration,L=S===void 0?200:S,y=l.exitDelay,f=y===void 0?0:y,v=l.size,$=v===void 0?40:v,W=l.className,X=l.style,B=l.sx,K=l.indicator,R=l.background,q=R===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:R,ue=ut(void 0),a=ut(null),V=wt(d),de=V[0],Te=V[1],N=q.show,j=N===void 0?!0:N,M=q.color,E=M===void 0?"255, 255, 255":M,oe=q.opacity,ie=oe===void 0?.9:oe;if(Mt(function(){var le=ue.current;if(le===!0&&d===!1&&a.current){var ae=a.current;ae.style.opacity="0",setTimeout(function(){Te(!1),c?.()},L+f)}else d===!0&&(Te(!0),a.current&&(a.current.style.opacity="1"));ue.current=d},[d,c,L,f]),!de)return null;var Se=function(){return typeof K=="string"?nt("img",{src:K,alt:"Loading",style:{width:$,height:$}}):K||nt(Tt,{size:$})},G=function(){return j?E.startsWith("rgba")?{backgroundColor:E}:/^\d+,\s*\d+,\s*\d+$/.test(E)?{backgroundColor:"rgba(".concat(E,", ").concat(ie,")")}:ie!==1?{backgroundColor:E,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:E,opacity:ie,zIndex:-1}}:{backgroundColor:E}:{backgroundColor:"transparent"}};return nt(Ct,{ref:a,className:W,style:Ae({},X),sx:Ae(Ae({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:d?1:0,transition:"opacity ".concat(L,"ms ease-out")},G()),B),children:Se()})}import{Fragment as kt,jsx as pt,jsxs as Lt}from"react/jsx-runtime";var St=`
1
+ import{forwardRef as ce,useCallback as z,useMemo as de,useRef as x,useEffect as k,memo as mt,useState as Ee}from"react";import{Box as E,Table as xt,TableBody as yt,TableCell as j,TableContainer as Ct,TableHead as wt,TableFooter as vt,TableRow as U,TableSortLabel as Ie,Paper as Mt,Typography as Tt,useTheme as St}from"@mui/material";import{TableVirtuoso as Rt}from"react-virtuoso";import{jsx as ke}from"react/jsx-runtime";import{useRef as Ve,useState as dt,useEffect as ut}from"react";import{Box as pt,CircularProgress as ft}from"@mui/material";var J=function(){return J=Object.assign||function(d){for(var c,y=1,T=arguments.length;y<T;y++){c=arguments[y];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(d[f]=c[f])}return d},J.apply(this,arguments)};function We(r){var d=r.visible,c=r.onComplete,y=r.fadeoutDuration,T=y===void 0?200:y,f=r.exitDelay,h=f===void 0?0:f,b=r.size,Y=b===void 0?40:b,W=r.className,K=r.style,S=r.sx,w=r.indicator,p=r.background,C=p===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:p,Z=Ve(void 0),I=Ve(null),Q=dt(d),pe=Q[0],ee=Q[1],te=C.show,R=te===void 0?!0:te,N=C.color,v=N===void 0?"255, 255, 255":N,A=C.opacity,_=A===void 0?.9:A;if(ut(function(){var F=Z.current;if(F===!0&&d===!1&&I.current){var ge=I.current;ge.style.opacity="0",setTimeout(function(){ee(!1),c?.()},T+h)}else d===!0&&(ee(!0),I.current&&(I.current.style.opacity="1"));Z.current=d},[d,c,T,h]),!pe)return null;var fe=function(){return typeof w=="string"?ke("img",{src:w,alt:"Loading",style:{width:Y,height:Y}}):w||ke(ft,{size:Y})},O=function(){return R?v.startsWith("rgba")?{backgroundColor:v}:/^\d+,\s*\d+,\s*\d+$/.test(v)?{backgroundColor:"rgba(".concat(v,", ").concat(_,")")}:_!==1?{backgroundColor:v,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:v,opacity:_,zIndex:-1}}:{backgroundColor:v}:{backgroundColor:"transparent"}};return ke(pt,{ref:I,className:W,style:J({},K),sx:J(J({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:d?1:0,transition:"opacity ".concat(T,"ms ease-out")},O()),S),children:fe()})}import{Fragment as ht,jsx as Ae,jsxs as bt}from"react/jsx-runtime";var gt=`
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 ft({size:l=54}){return Lt(kt,{children:[pt("style",{children:St}),pt("span",{className:"vdt-css-spinner",role:"progressbar","aria-label":"loading",style:{display:"inline-block",width:l,height:l}})]})}import{useRef as Z,useEffect as ce,useState as A,useCallback as H,useMemo as ze,forwardRef as Rt,useImperativeHandle as Dt,useLayoutEffect as Et}from"react";import{jsx as Ie,jsxs as mt}from"react/jsx-runtime";var Ht=["editor","textarea","input","select","textfield","form-control","contenteditable","MuiInputBase-input","MuiSelect-select","MuiOutlinedInput-input","MuiFilledInput-input","MuiInput-input","MuiFormControl-root","MuiTextField-root","MuiSelect-root","MuiOutlinedInput-root","MuiFilledInput-root","MuiInput-root","MuiAutocomplete-input","MuiDatePicker-input","MuiSlider-thumb","MuiSlider-rail","MuiSlider-track","MuiSlider-mark","MuiSlider-markLabel","MuiSlider-root","MuiSlider-colorPrimary","MuiSlider-sizeMedium","MuiIconButton-root","MuiButton-root","MuiButtonBase-root","MuiTouchRipple-root","MuiCheckbox-root","MuiRadio-root","MuiSwitch-root","PrivateSwitchBase-root","ant-input","ant-input-affix-wrapper","ant-input-group-addon","ant-input-number","ant-input-number-handler","ant-select","ant-select-selector","ant-select-selection-search","ant-select-dropdown","ant-cascader","ant-cascader-input","ant-picker","ant-picker-input","ant-time-picker","ant-calendar-picker","ant-slider","ant-slider-track","ant-slider-handle","ant-switch","ant-checkbox","ant-checkbox-wrapper","ant-radio","ant-radio-wrapper","ant-rate","ant-upload","ant-upload-drag","ant-form-item","ant-form-item-control","ant-btn","ant-dropdown","ant-dropdown-trigger","ant-menu","ant-menu-item","ant-tooltip","ant-popover","ant-modal","ant-drawer","ant-tree-select","ant-auto-complete","ant-mentions","ant-transfer","ui-input","ui-textarea","ui-select","ui-select-trigger","ui-select-content","ui-select-item","ui-button","ui-checkbox","ui-radio-group","ui-switch","ui-slider","ui-range-slider","ui-calendar","ui-date-picker","ui-combobox","ui-command","ui-command-input","ui-popover","ui-dialog","ui-sheet","ui-dropdown-menu","ui-context-menu","ui-menubar","ui-navigation-menu","ui-form","ui-form-control","ui-form-item","ui-form-field","ui-label","radix-ui","radix-select","radix-dropdown","radix-dialog","radix-popover","radix-accordion","radix-tabs","radix-slider","radix-switch","radix-checkbox","radix-radio","ql-editor","ql-container","ql-toolbar","ql-picker","ql-picker-label","ql-picker-options","ql-formats","ql-snow","ql-bubble","quill","quilleditor","monaco-editor","monaco-editor-background","view-lines","decorationsOverviewRuler","monaco-scrollable-element","CodeMirror","CodeMirror-code","CodeMirror-lines","CodeMirror-scroll","CodeMirror-sizer","cm-editor","cm-focused","cm-content","tox-editor-container","tox-editor-header","tox-edit-area","tox-tinymce","mce-content-body","ck-editor","ck-content","ck-toolbar","ck-editor__editable","ck-widget","slate-editor","slate-content","DraftEditor-root","DraftEditor-editorContainer","public-DraftEditor-content","ehfuse-editor","ehfuse-editor-wrapper","ehfuse-editor-content","ehfuse-toolbar","ehfuse-toolbar-group","ehfuse-cursor","text-editor","rich-text-editor","wysiwyg","ace_editor","ace_content"],ht=(l,d)=>{let c=l.tagName.toLowerCase(),S=["text","password","email","number","search","tel","url","checkbox","radio"];if(c==="input"){let L=l.type;return S.includes(L)}if(["textarea","select","button"].includes(c)||["svg","path","circle","rect","line","polygon","polyline"].includes(c)||l.getAttribute("contenteditable")==="true")return!0;if(d?.excludeSelectors){for(let L of d.excludeSelectors)if(l.matches(L))return!0}return It(l,d)},It=(l,d)=>{let c=[...Ht,...d?.excludeClasses||[]],S=l,L=0,y=5;for(;S&&L<=y;){if(c.some(f=>S.classList.contains(f)))return!0;if(S.classList.contains("MuiDialogContent-root"))break;S=S.parentElement,L++}return!1},Ot={},$t={},Nt={},Ft={},Pt={},Bt=Rt(({className:l="",style:d={},containerStyle:c={},contentStyle:S={},children:L,onScroll:y,thumb:f=Ot,track:v=$t,arrows:$=Nt,dragScroll:W=Ft,autoHide:X=Pt,showScrollbar:B=!0,detectInnerScroll:K=!1},R)=>{let q=Z({});ce(()=>{q.current={children:L,onScroll:y,showScrollbar:B,thumb:f,track:v,arrows:$,dragScroll:W,autoHide:X}});let ue=Z(null),a=Z(null),V=Z(null),de=Z(null),Te=Z(null),N=Z(null),[j,M]=A(!1),[E,oe]=A(!1),[ie,Se]=A(!1),[G,le]=A({y:0,scrollTop:0}),[ae,xe]=A(0),[lt,J]=A(0),[Q,ke]=A(!1),[se,$e]=A(!1),[Le,Ge]=A({x:0,y:0,scrollTop:0,scrollLeft:0}),[at,st]=A(null),[Re,De]=A(null),[ct,Ee]=A(!1),ee=Z(null),[qe,Ue]=A(!1),h=Z(null),u=Z(null),U=Z(null),I=ze(()=>{let e=f.color??"#606060";return{width:f.width??8,minHeight:f.minHeight??50,radius:f.radius??(f.width??8)/2,color:e,opacity:f.opacity??.6,hoverColor:f.hoverColor??e,hoverOpacity:f.hoverOpacity??1}},[f]),g=ze(()=>({width:v.width??16,color:v.color??"rgba(128, 128, 128, 0.1)",visible:v.visible??!0,alignment:v.alignment??"center",radius:v.radius??I.radius??4,margin:v.margin??4}),[v,I.radius]),_=ze(()=>{let e=$.color??"#808080";return{visible:$.visible??!1,step:$.step??50,color:e,opacity:$.opacity??.6,hoverColor:$.hoverColor??e,hoverOpacity:$.hoverOpacity??1}},[$]),He=ze(()=>({enabled:W.enabled??!0,excludeClasses:W.excludeClasses??[],excludeSelectors:W.excludeSelectors??[]}),[W]),x=ze(()=>({enabled:X.enabled??!0,delay:X.delay??1500,delayOnWheel:X.delayOnWheel??700}),[X]),D=I.width,Ve=g.width,Ne=I.minHeight,te=_.visible,pe=_.step,Y=H(()=>{if(!a.current)return;let e=document.activeElement;e&&a.current.contains(e)&&e!==a.current||a.current.focus()},[]);Dt(R,()=>({getScrollContainer:()=>a.current,scrollTo:e=>{a.current&&a.current.scrollTo(e)},get scrollTop(){return a.current?.scrollTop||0},get scrollHeight(){return a.current?.scrollHeight||0},get clientHeight(){return a.current?.clientHeight||0}}),[]);let w=H(()=>{if(N.current){let t=N.current;if(document.contains(t)&&t.scrollHeight>t.clientHeight+2)return t;N.current=null}if(!a.current)return null;if(V.current&&V.current.scrollHeight>a.current.clientHeight+2)return N.current=a.current,a.current;if(!K)return null;let e=a.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let t of e){let n=t;if(n!==a.current&&n.classList.contains("overlay-scrollbar-container"))continue;let o=n.parentElement,i=!1;for(;o&&o!==a.current;){if(o.classList.contains("overlay-scrollbar-container")&&o!==a.current){i=!0;break}o=o.parentElement}if(!i&&n.scrollHeight>n.clientHeight+2)return N.current=n,n}return null},[]),re=H(()=>w()!==null,[w]),C=H(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),Fe=H(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),ye=H(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),T=H(e=>{x.enabled&&(C(),h.current=setTimeout(()=>{M(!1),h.current=null},e))},[C,x.enabled]),m=H(()=>{let e=w();if(!e){M(!1),ke(!1),C();return}if(ke(!0),!de.current)return;x.enabled||(M(!0),C());let t=e.clientHeight,n=e.scrollHeight,o=e.scrollTop,i=0;if(ue.current){let k=window.getComputedStyle(ue.current),me=parseFloat(k.paddingTop)||0,Be=parseFloat(k.paddingBottom)||0;i=me+Be}let r=te?D*2+g.margin*4:g.margin*2,p=t-r+i,b=t/n,F=Math.max(p*b,Ne),P=n-t,O=p-F,he=P>0?o/P*O:0;xe(F),J(he)},[w,C,te,D,Ne,x.enabled]),Ze=H(e=>{e.preventDefault(),e.stopPropagation();let t=w();t&&(oe(!0),le({y:e.clientY,scrollTop:t.scrollTop}),C(),M(!0),Y())},[w,C,Y]),ve=H(e=>{if(!E)return;let t=w();if(!t)return;let n=t.clientHeight,o=t.scrollHeight-n,i=e.clientY-G.y,r=n-ae,p=i/r*o,b=Math.max(0,Math.min(o,G.scrollTop+p));t.scrollTop=b,m()},[E,G,ae,m,w]),we=H(()=>{oe(!1),re()&&T(x.delay)},[re,T,x.delay]),Je=H(e=>{if(!de.current)return;let t=de.current.getBoundingClientRect(),n=e.clientY-t.top,o=w();if(!o)return;let i=o.clientHeight,r=o.scrollHeight,p=n/i*(r-i);o.scrollTop=Math.max(0,Math.min(r-i,p)),m(),M(!0),T(x.delay),Y()},[m,T,x.delay,w,Y]),Qe=H(e=>{if(e.preventDefault(),e.stopPropagation(),!a.current)return;let t=Math.max(0,a.current.scrollTop-pe);a.current.scrollTop=t,m(),M(!0),T(x.delay),Y()},[m,T,pe,x.delay,Y]),ne=H(e=>{if(e.preventDefault(),e.stopPropagation(),!a.current||!V.current)return;let t=a.current,n=V.current.scrollHeight-t.clientHeight,o=Math.min(n,t.scrollTop+pe);t.scrollTop=o,m(),M(!0),T(x.delay),Y()},[m,T,pe,x.delay,Y]),et=H(e=>{if(!He.enabled)return;let t=e.target;if(ht(t,He)||e.button!==0)return;let n=w();n&&(n.scrollHeight<=n.clientHeight||(e.preventDefault(),$e(!0),Ge({x:e.clientX,y:e.clientY,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft||0}),C()))},[He,ht,w,C]),je=H(e=>{if(!se)return;let t=w();if(!t)return;let n=Le.x-e.clientX,o=Le.y-e.clientY;if(Math.abs(o)<3&&Math.abs(n)<3)return;M(!0);let i=Math.max(0,Math.min(t.scrollHeight-t.clientHeight,Le.scrollTop+o));t.scrollTop=i,m()},[se,Le,w,m]),Pe=H(()=>{$e(!1),re()&&T(x.delay)},[re,T,x.delay]);ce(()=>{let e=r=>{m(),C(),M(!0);let p=qe?x.delayOnWheel:x.delay;T(p),y&&y(r)},t=()=>{Ue(!0),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{Ue(!1)},300),C(),ye(),U.current=setTimeout(()=>{M(!0),U.current=null},50)},n=[],o=w();o&&n.push(o);let i=a.current;return i&&!o&&(n.push(i),i.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(r=>{let p=r;if(p!==i&&p.classList.contains("overlay-scrollbar-container"))return;let b=p.parentElement;for(;b&&b!==i;){if(b.classList.contains("overlay-scrollbar-container")&&b!==i)return;b=b.parentElement}n.push(p)})),n.forEach(r=>{r.addEventListener("scroll",e,{passive:!0}),r.addEventListener("wheel",t,{passive:!0})}),()=>{n.forEach(r=>{r.removeEventListener("scroll",e),r.removeEventListener("wheel",t)}),ee.current&&clearTimeout(ee.current),U.current&&clearTimeout(U.current)}},[w,m,y,C,T,x,qe]),ce(()=>{let e=n=>{let o=w();if(!o)return;let{key:i}=n,{scrollTop:r,scrollHeight:p,clientHeight:b}=o,F=p-b,P=50,O=null;switch(i){case"ArrowUp":n.preventDefault(),O=Math.max(0,r-P);break;case"ArrowDown":n.preventDefault(),O=Math.min(F,r+P);break;case"PageUp":n.preventDefault(),O=Math.max(0,r-b);break;case"PageDown":n.preventDefault(),O=Math.min(F,r+b);break;case"Home":n.preventDefault(),O=0;break;case"End":n.preventDefault(),O=F;break;default:return}if(O!==null){let he=O/F,k=te?D*2+g.margin*4:g.margin*2,me=(b-k-ae)*he;J(me),o.scrollTop=O,C(),M(!0),T(x.delay)}},t=a.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}},[w,te,D,g.margin,ae,C,T,x.delay]),ce(()=>{if(se)return document.addEventListener("mousemove",je),document.addEventListener("mouseup",Pe),()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",Pe)}},[se,je,Pe]),ce(()=>{if(E)return document.addEventListener("mousemove",ve),document.addEventListener("mouseup",we),()=>{document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",we)}},[E,ve,we]),ce(()=>{m();let e=setTimeout(()=>{m()},100);return()=>clearTimeout(e)},[m]),Et(()=>{Ee(!0),m(),!x.enabled&&re()&&M(!0)},[re,m,x.enabled]),ce(()=>{let e=new ResizeObserver(()=>{m()}),t=[];return a.current&&t.push(a.current),V.current&&t.push(V.current),N.current&&document.contains(N.current)&&t.push(N.current),t.forEach(n=>{e.observe(n)}),()=>e.disconnect()},[m]),ce(()=>{if(!a.current)return;let e=new MutationObserver(()=>{N.current=null,m()});return e.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>e.disconnect()},[m]);let fe=Math.max(Ve,D);return ce(()=>{let e="overlay-scrollbar-webkit-hide",t=document.getElementById(e);t&&t.remove();let n=document.createElement("style");return n.id=e,n.textContent=`
5
- .overlay-scrollbar-container::-webkit-scrollbar {
6
- display: none !important;
7
- width: 0 !important;
8
- height: 0 !important;
9
- }
10
- .overlay-scrollbar-container::-webkit-scrollbar-track {
11
- display: none !important;
12
- }
13
- .overlay-scrollbar-container::-webkit-scrollbar-thumb {
14
- display: none !important;
15
- }
16
- .overlay-scrollbar-container:focus {
17
- outline: 2px solid rgba(0, 123, 255, 0.3);
18
- outline-offset: -2px;
19
- }
20
- .overlay-scrollbar-container:focus-visible {
21
- outline: 2px solid rgba(0, 123, 255, 0.5);
22
- outline-offset: -2px;
23
- }
24
- `,document.head.appendChild(n),()=>{let o=document.getElementById(e);o&&o.remove()}},[]),mt("div",{ref:ue,className:`overlay-scrollbar-wrapper ${l}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...d},children:[Ie("div",{ref:a,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:et,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:se?"none":"auto",...c},children:Ie("div",{ref:V,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...S},children:L})}),B&&Q&&mt("div",{ref:de,className:"overlay-scrollbar-track",onMouseEnter:()=>{C(),u.current=setTimeout(()=>{M(!0),u.current=null},100)},onMouseLeave:()=>{Fe(),E||T(x.delay)},style:{position:"absolute",top:0,right:0,width:`${fe}px`,height:"100%",opacity:j?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[g.visible&&Ie("div",{className:"overlay-scrollbar-track-background",onClick:e=>{e.preventDefault(),e.stopPropagation(),Je(e)},style:{position:"absolute",top:te?`${I.width+g.margin*2}px`:`${g.margin}px`,right:g.alignment==="right"?"0px":`${(fe-I.width)/2}px`,width:`${I.width}px`,height:te?`calc(100% - ${I.width*2+g.margin*4}px)`:`calc(100% - ${g.margin*2}px)`,backgroundColor:g.color,borderRadius:`${g.radius}px`,cursor:"pointer"}}),Ie("div",{ref:Te,className:"overlay-scrollbar-thumb",onMouseDown:Ze,onMouseEnter:()=>Se(!0),onMouseLeave:()=>Se(!1),style:{position:"absolute",top:`${(te?D+g.margin*2:g.margin)+lt}px`,right:g.alignment==="right"?"0px":`${(fe-D)/2}px`,width:`${D}px`,height:`${Math.max(ae,Ne)}px`,backgroundColor:ie||E?I.hoverColor:I.color,opacity:ie||E?I.hoverOpacity:I.opacity,borderRadius:`${I.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),B&&Q&&te&&Ie("div",{className:"overlay-scrollbar-up-arrow",onClick:Qe,onMouseEnter:()=>De("up"),onMouseLeave:()=>De(null),style:{position:"absolute",top:`${g.margin}px`,right:g.alignment==="right"?"0px":`${(fe-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:Re==="up"?_.hoverColor:_.color,userSelect:"none",zIndex:1001,opacity:j?Re==="up"?_.hoverOpacity:_.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),B&&Q&&te&&Ie("div",{className:"overlay-scrollbar-down-arrow",onClick:ne,onMouseEnter:()=>De("down"),onMouseLeave:()=>De(null),style:{position:"absolute",bottom:`${g.margin}px`,right:g.alignment==="right"?"0px":`${(fe-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:Re==="down"?_.hoverColor:_.color,userSelect:"none",zIndex:1001,opacity:j?Re==="down"?_.hoverOpacity:_.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),gt=Bt;import{Fragment as Ke,jsx as s,jsxs as Ce}from"react/jsx-runtime";var Gt={alignment:"right",margin:0,radius:0},bt=5,Ut={bg:"#ffffff",border:"#e6e6e3",borderStrong:"#dedddb",headerColor:"#787774",hoverBg:"#f8f8f7"},Zt={bg:"#1e1e1e",border:"#2c333c",borderStrong:"#3b434e",headerColor:"#a3adbb",hoverBg:"#272d36"};function Jt({data:l,loading:d=!1,columns:c,onRowClick:S,getRowId:L,selectedRowId:y,selectedRowSx:f,rowHeight:v=50,columnHeight:$,striped:W,rowDivider:X=!0,onSort:B,onLoadMore:K,sortBy:R,sortDirection:q,showPaper:ue=!0,paddingX:a,paddingTop:V=0,paddingBottom:de=0,rowHoverColor:Te,rowHoverOpacity:N,viewportBuffer:j,overscan:M,scrollbars:E,emptyMessage:oe="NO DATA",LoadingComponent:ie,showFooter:Se,footerHeight:G,footerSx:le,variant:ae="default"}){let xe=ae==="notion",J=Xt().palette.mode==="dark"?Zt:Ut,Q=$??(xe?40:56),ke=a??(xe?"12px":"1rem"),se=Te??(xe?J.hoverBg:void 0),$e=N??(xe?1:void 0),Le=Math.max(v*12,480),Ge=Math.max(v*12,480),at=typeof j=="number"?j:j?.top??Le,st=typeof j=="number"?j:j?.bottom??Ge,Re=Math.max(v*8,420),De=Math.max(v*10,520),ct=typeof M=="number"?M:{main:M?.main??Re,reverse:M?.reverse??De},Ee=v+(X?1:0),ee=!f||typeof f!="function",qe=Xe(()=>!ee||y===null||y===void 0||!f?null:{[`& tbody tr[data-row-id="${String(y).replace(/["\\]/g,"\\$&")}"]`]:f},[ee,y,f]),Ue=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),[h]=ot(()=>typeof window>"u"?!1:window.localStorage.getItem("vdt-perf-debug")==="1"),u=z({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}),U=Me(e=>{if(!h)return;let t=u.current;if(!(t.wheelEvents>0||t.rangeChangedCalls>0||t.rowContentCalls>0||t.cellRenderCalls>0))return;let o=t.rowContentCalls>0?t.rowContentMs/t.rowContentCalls:0,i=t.cellRenderCalls>0?t.cellRenderMs/t.cellRenderCalls:0;console.log("[VDT perf]",{reason:e,wheel:{events:t.wheelEvents,inputPx:Math.round(t.wheelInputPx),handlerMs:Number(t.wheelHandlerMs.toFixed(2)),rafFlushes:t.wheelRafFlushes,rafMs:Number(t.wheelRafMs.toFixed(2))},rangeChanged:{calls:t.rangeChangedCalls,totalMs:Number(t.rangeChangedMs.toFixed(2))},rowContent:{calls:t.rowContentCalls,totalMs:Number(t.rowContentMs.toFixed(2)),avgMs:Number(o.toFixed(3)),maxMs:Number(t.rowContentMaxMs.toFixed(3))},cellRender:{calls:t.cellRenderCalls,totalMs:Number(t.cellRenderMs.toFixed(2)),avgMs:Number(i.toFixed(3)),maxMs:Number(t.cellRenderMaxMs.toFixed(3))}}),u.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}},[h]);ge(()=>{if(!h||typeof window>"u")return;console.log("[VDT perf] enabled (localStorage vdt-perf-debug=1)");let e=window.setInterval(()=>{U("interval")},1500);return()=>{window.clearInterval(e),U("cleanup")}},[U,h]);let I=Xe(()=>Ye((e,t)=>{let n=z(null),o=z(0),i=z(null);return ge(()=>{let r=n.current;if(!r)return;let p=b=>{let F=h?performance.now():0;b.preventDefault();let P=b.deltaY;b.deltaMode===1?P*=40:b.deltaMode===2&&(P*=r.clientHeight),h&&(u.current.wheelEvents+=1,u.current.wheelInputPx+=P),o.current+=P,i.current===null&&(i.current=requestAnimationFrame(()=>{let O=h?performance.now():0,he=Math.max(r.clientHeight*.4,160),k=Math.max(-he,Math.min(he,o.current));o.current=0,i.current=null,k!==0&&(r.scrollTop+=k),h&&(u.current.wheelRafFlushes+=1,u.current.wheelRafMs+=performance.now()-O)}),h&&(u.current.wheelHandlerMs+=performance.now()-F))};return r.addEventListener("wheel",p,{passive:!1}),()=>{r.removeEventListener("wheel",p),i.current!==null&&(cancelAnimationFrame(i.current),i.current=null),o.current=0}},[]),s(gt,{detectInnerScroll:!0,track:Gt,...E,children:s(qt,{component:be,...e,ref:r=>{n.current=r,typeof t=="function"?t(r):t&&(t.current=r)},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:ke,paddingTop:V,paddingBottom:de}}})})}),[]),g=Xe(()=>{if(W===!0)return"#f5f5f5";if(typeof W=="string")return W},[W]),[_,He]=ot(d),[x,D]=ot(0);ge(()=>{d&&He(!0)},[d]);let Ve=Me(()=>{He(!1)},[]),Ne=_,te=d&&l.length>0,pe=z(!1),Y=z(-1),w=z(null),re=z(S);re.current=S;let C=z(L);C.current=L;let Fe=!!S,ye=z(!1),T=z({x:0,y:0});ge(()=>{let e=t=>{let n=t.clientX-T.current.x,o=t.clientY-T.current.y;Math.sqrt(n*n+o*o)>bt&&(ye.current=!0)};return document.addEventListener("mousemove",e),()=>{document.removeEventListener("mousemove",e)}},[]),ge(()=>{let e=document.querySelector('[data-testid="virtuoso-scroller"]');e&&e.querySelectorAll(".MuiTableSortLabel-root").forEach(n=>{let o=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});n.dispatchEvent(o)})},[R]);let m=Me(e=>{if(!B)return;B(e,R===e&&q==="asc"?"desc":"asc")},[B,R,q]),Ze=Me(e=>{let t=h?performance.now():0;if(!K){h&&(u.current.rangeChangedCalls+=1,u.current.rangeChangedMs+=performance.now()-t);return}if(d&&l.length===0){h&&(u.current.rangeChangedCalls+=1,u.current.rangeChangedMs+=performance.now()-t);return}let n=l.length>=30,o=e>=l.length-1,i=Y.current===l.length;if(o&&n&&!pe.current&&!i){pe.current=!0,Y.current=l.length;let r=l.length;K(r,50)}h&&(u.current.rangeChangedCalls+=1,u.current.rangeChangedMs+=performance.now()-t)},[l.length,d,K,h]);ge(()=>{d||(pe.current=!1)},[d]),ge(()=>{l.length===0&&D(e=>e+1)},[l.length]);let ve=z(l.length),we=z(void 0);ge(()=>{let e=ve.current,t=l.length,n=t>0?C.current?C.current(l[0],0):l[0]:void 0,o=we.current;if(t>e&&e>0){ve.current=t,we.current=n;return}let i=t<e||e>0&&n!==o;i&&(Y.current=-1),w.current&&t>0&&i&&w.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),ve.current=t,we.current=n},[l]);let Je=Me(()=>{let e={},t=[];if(c.forEach(r=>{r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(r)):t.push(r)}),!(Object.keys(e).length>0))return s(We,{children:c.map(r=>s(Oe,{align:r.align||"left",style:{width:r.width,minWidth:r.width,...r.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:r.sortable?s("div",{style:{display:"flex",alignItems:"center",justifyContent:r.align==="center"?"center":r.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:Ce(be,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>m(String(r.id)),children:[r.text,s(it,{active:R===r.id,direction:R===r.id?q:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:R===r.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)"}}})]})}):r.text},String(r.id)))});let o=[...t.map(r=>s(Oe,{rowSpan:2,align:r.align||"left",style:{width:r.width,minWidth:r.width,...r.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:r.sortable&&B?s("div",{style:{display:"flex",alignItems:"center",justifyContent:r.align==="center"?"center":r.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:Ce(be,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>m(String(r.id)),children:[r.text,s(it,{active:R===r.id,direction:R===r.id?q:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:R===r.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)"}}})]})}):r.text},String(r.id))),...Object.entries(e).map(([r,p])=>s(Oe,{align:"center",colSpan:p.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:r},r))],i=[...Object.values(e).flat().map(r=>s(Oe,{align:r.align||"left",style:{width:r.width,minWidth:r.width,...r.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:r.sortable&&B?s("div",{style:{display:"flex",alignItems:"center",justifyContent:r.align==="center"?"center":r.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:Ce(be,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>m(String(r.id)),children:[r.text,s(it,{active:R===r.id,direction:R===r.id?q:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:R===r.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)"}}})]})}):r.text},String(r.id)))];return Ce(Ke,{children:[s(We,{children:o}),s(We,{children:i})]})},[c,R,q,m,B,Q]),Qe=Me((e,t)=>{let n=h?performance.now():0;if(!t){if(h){u.current.rowContentCalls+=1;let i=performance.now()-n;u.current.rowContentMs+=i,u.current.rowContentMaxMs=Math.max(u.current.rowContentMaxMs,i)}return null}let o=c.map(i=>{let r=h?performance.now():0,p=i.render?i.render(t,e):String(t[i.id]||"");if(h){let b=performance.now()-r;u.current.cellRenderCalls+=1,u.current.cellRenderMs+=b,u.current.cellRenderMaxMs=Math.max(u.current.cellRenderMaxMs,b)}return s(Oe,{align:i.align||"left",style:{width:i.width,minWidth:i.width,...i.style,padding:"8px 16px"},children:p},String(i.id))});if(h){u.current.rowContentCalls+=1;let i=performance.now()-n;u.current.rowContentMs+=i,u.current.rowContentMaxMs=Math.max(u.current.rowContentMaxMs,i)}return s(Ke,{children:o})},[c,h]),ne=Se??c.some(e=>typeof e.footer=="function"),et=Me(()=>{if(!ne)return null;let e=[];for(let t=0;t<c.length;t+=1){let n=c[t],o=n.footerColSpan&&n.footerColSpan>1?Math.min(n.footerColSpan,c.length-t):1;e.push(s(Oe,{align:n.align||"left",colSpan:o>1?o:void 0,style:{...o>1?{}:{width:n.width,minWidth:n.width},...n.style,fontWeight:"bold",padding:"16px"},children:n.footer?n.footer(l):null},String(n.id))),t+=o-1}return s(We,{children:e})},[ne,c,l]),Pe=Xe(()=>({Scroller:I,Table:e=>s(zt,{...e,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px",...ne?{height:"100%"}:{}}}),TableHead:Ye((e,t)=>s(Vt,{...e,ref:t,sx:{userSelect:"none","& tr":{height:Q,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:e=>{let{item:t,selected:n,"aria-selected":o,className:i,...r}=e,p=r["data-index"]??0,b=p%2===1,F=t&&C.current?C.current(t,p):p,P=!ee&&y!==null&&y!==void 0&&F===y,O=P&&f?typeof f=="function"?f(t,p):f:void 0,he=String(i??"").split(/\s+/).filter(k=>k!=="Mui-selected"&&k!=="Mui-focusVisible").join(" ");return s(We,{...r,"data-row-id":F!=null?String(F):void 0,className:he||void 0,selected:P,onMouseDown:k=>{ye.current=!1,T.current={x:k.clientX,y:k.clientY}},onClick:k=>{let me=k.clientX-T.current.x,Be=k.clientY-T.current.y;if(Math.sqrt(me*me+Be*Be)>bt||ye.current){k.preventDefault(),k.stopPropagation(),ye.current=!1;return}t&&re.current&&re.current(t,p),ye.current=!1},sx:[{userSelect:"none",height:Ee,maxHeight:Ee,boxSizing:"border-box",backgroundColor:b&&g?g:"transparent","& td":{padding:"8px 16px",boxSizing:"border-box",borderBottom:X?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":Fe&&!P?{backgroundColor:k=>{let me=k.palette.mode==="dark",tt=se??"#000000",rt=$e??.06;if(!se)return me?`rgba(255, 255, 255, ${rt})`:`rgba(0, 0, 0, ${rt})`;let _e=tt.replace("#","").trim();if(_e.length!==6)return tt;let xt=parseInt(_e.substring(0,2),16),yt=parseInt(_e.substring(2,4),16),vt=parseInt(_e.substring(4,6),16);return`rgba(${xt}, ${yt}, ${vt}, ${rt})`}}:void 0,cursor:Fe?"pointer":void 0},O]})},TableBody:Ye((e,t)=>{let{children:n,...o}=e;return Ce(Wt,{...o,ref:t,sx:ne?{height:"100%"}:void 0,children:[n,ne&&s("tr",{"aria-hidden":!0,style:{height:"100%"},children:s("td",{colSpan:c.length,style:{padding:0,border:0}})})]})}),TableFoot:Ye((e,t)=>s(jt,{...e,ref:t,sx:[{"& tr":{height:G??v,maxHeight:G??v,boxSizing:"border-box"},"& td":{height:G??v,boxSizing:"border-box",backgroundColor:n=>n.palette.mode==="dark"?"#1e1e1e":"#ffffff",padding:"0 16px",color:"inherit",fontSize:"0.875rem",border:"none",boxShadow:"inset 0 1px 0 0 #000000"}},...Array.isArray(le)?le:le?[le]:[]]}))}),[Fe,ee?null:y,f,v,g,X,Q,se,$e,I,G,le,ne,c]),fe=Ce(be,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:e=>e.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"},...qe??{},...xe?{"& thead tr th":{height:Q,boxSizing:"border-box",padding:"0 14px !important",fontSize:13,fontWeight:"500 !important",color:J.headerColor,backgroundColor:`${J.bg} !important`,borderTop:`1px solid ${J.borderStrong}`,borderBottom:`1px solid ${J.borderStrong}`,borderRight:`1px solid ${J.border}`,"&:last-of-type":{borderRight:"none"}},"& tbody tr td":{padding:"0 14px !important",fontSize:14,borderBottom:`1px solid ${J.border}`}}:{}},children:[s(Kt,{ref:w,data:l,totalCount:K?l.length+1:l.length,defaultItemHeight:Ee,fixedItemHeight:Ee,fixedHeaderContent:Je,fixedFooterContent:ne?et:void 0,itemContent:Qe,endReached:Ze,style:{height:"100%"},increaseViewportBy:{top:at,bottom:st},overscan:ct,followOutput:!1,components:Pe},x),l.length===0&&!d&&s(be,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof oe=="string"?Ce(Ke,{children:[s(be,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),s(Yt,{variant:"body1",sx:{color:"text.secondary"},children:oe})]}):oe}),Ne&&s(Ke,{children:ie?s(ie,{visible:d,onComplete:Ve}):s(dt,{visible:d,onComplete:Ve,size:40,indicator:s(ft,{}),sx:{top:`${c.some(e=>e.group)?Q*2:Q}px`,bottom:`${ne?G??v:0}px`},background:{show:l.length===0,opacity:.8}})})]});return ue?s(_t,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:ke,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:fe}):s(be,{className:"grow",style:{padding:0,paddingLeft:ke,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:fe})}var Qt=At(Jt);export{Qt as VirtualDataTable};
4
+ `;function _e({size:r=54}){return bt(ht,{children:[Ae("style",{children:gt}),Ae("span",{className:"vdt-css-spinner",role:"progressbar","aria-label":"loading",style:{display:"inline-block",width:r,height:r}})]})}import Lt from"@ehfuse/overlay-scrollbar";import{Fragment as ue,jsx as o,jsxs as V}from"react/jsx-runtime";var Dt={alignment:"default",margin:0,radius:0},$e=5,kt={bg:"#ffffff",border:"#e6e6e3",borderStrong:"#dedddb",headerColor:"#787774",hoverBg:"#f8f8f7"},Be="12px",Et={bg:"#1e1e1e",border:"#2c333c",borderStrong:"#3b434e",headerColor:"#a3adbb",hoverBg:"#272d36"};function It({data:r,loading:d=!1,columns:c,onRowClick:y,getRowId:T,selectedRowId:f,selectedRowSx:h,rowHeight:b=50,columnHeight:Y,striped:W,rowDivider:K=!0,onSort:S,onLoadMore:w,sortBy:p,sortDirection:C,showPaper:Z=!0,paddingX:I,paddingTop:Q=0,paddingBottom:pe=0,rowHoverColor:ee,rowHoverOpacity:te,viewportBuffer:R,overscan:N,scrollbars:v,emptyMessage:A="NO DATA",LoadingComponent:_,showFooter:fe,footerHeight:O,footerSx:F,variant:ge="default"}){let P=ge==="notion",H=St().palette.mode==="dark"?Et:kt,$=Y??(P?40:56),ne=I??(P?"12px":"1rem"),he=ee??(P?H.hoverBg:void 0),Ne=te??(P?1:void 0),je=Math.max(b*12,480),Ye=Math.max(b*12,480),Ke=typeof R=="number"?R:R?.top??je,Ge=typeof R=="number"?R:R?.bottom??Ye,Xe=Math.max(b*8,420),qe=Math.max(b*10,520),Je=typeof N=="number"?N:{main:N?.main??Xe,reverse:N?.reverse??qe},re=b+(K?1:0),oe=!h||typeof h!="function",Ue=de(()=>!oe||f===null||f===void 0||!h?null:{[`& tbody tr[data-row-id="${String(f).replace(/["\\]/g,"\\$&")}"]`]:h},[oe,f,h]),Ft=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),[u]=Ee(()=>typeof window>"u"?!1:window.localStorage.getItem("vdt-perf-debug")==="1"),l=x({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}),be=z(n=>{if(!u)return;let t=l.current;if(!(t.wheelEvents>0||t.rangeChangedCalls>0||t.rowContentCalls>0||t.cellRenderCalls>0))return;let s=t.rowContentCalls>0?t.rowContentMs/t.rowContentCalls:0,a=t.cellRenderCalls>0?t.cellRenderMs/t.cellRenderCalls:0;console.log("[VDT perf]",{reason:n,wheel:{events:t.wheelEvents,inputPx:Math.round(t.wheelInputPx),handlerMs:Number(t.wheelHandlerMs.toFixed(2)),rafFlushes:t.wheelRafFlushes,rafMs:Number(t.wheelRafMs.toFixed(2))},rangeChanged:{calls:t.rangeChangedCalls,totalMs:Number(t.rangeChangedMs.toFixed(2))},rowContent:{calls:t.rowContentCalls,totalMs:Number(t.rowContentMs.toFixed(2)),avgMs:Number(s.toFixed(3)),maxMs:Number(t.rowContentMaxMs.toFixed(3))},cellRender:{calls:t.cellRenderCalls,totalMs:Number(t.cellRenderMs.toFixed(2)),avgMs:Number(a.toFixed(3)),maxMs:Number(t.cellRenderMaxMs.toFixed(3))}}),l.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}},[u]);k(()=>{if(!u||typeof window>"u")return;console.log("[VDT perf] enabled (localStorage vdt-perf-debug=1)");let n=window.setInterval(()=>{be("interval")},1500);return()=>{window.clearInterval(n),be("cleanup")}},[be,u]);let Oe=de(()=>ce((n,t)=>{let i=x(null),s=x(0),a=x(null);return k(()=>{let e=i.current;if(!e)return;let m=M=>{let B=u?performance.now():0;M.preventDefault();let D=M.deltaY;M.deltaMode===1?D*=40:M.deltaMode===2&&(D*=e.clientHeight),u&&(l.current.wheelEvents+=1,l.current.wheelInputPx+=D),s.current+=D,a.current===null&&(a.current=requestAnimationFrame(()=>{let Se=u?performance.now():0,ae=Math.max(e.clientHeight*.4,160),g=Math.max(-ae,Math.min(ae,s.current));s.current=0,a.current=null,g!==0&&(e.scrollTop+=g),u&&(l.current.wheelRafFlushes+=1,l.current.wheelRafMs+=performance.now()-Se)}),u&&(l.current.wheelHandlerMs+=performance.now()-B))};return e.addEventListener("wheel",m,{passive:!1}),()=>{e.removeEventListener("wheel",m),a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),s.current=0}},[]),o(Lt,{detectInnerScroll:!0,track:Dt,...v,children:o(Ct,{component:E,...n,ref:e=>{i.current=e,typeof t=="function"?t(e):t&&(t.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:P?0:ne,paddingTop:Q,paddingBottom:pe}}})})}),[]),me=de(()=>{if(W===!0)return"#f5f5f5";if(typeof W=="string")return W},[W]),[Ze,Fe]=Ee(d),[Qe,et]=Ee(0);k(()=>{d&&Fe(!0)},[d]);let Pe=z(()=>{Fe(!1)},[]),tt=Ze,Pt=d&&r.length>0,xe=x(!1),ye=x(-1),Ce=x(null),we=x(y);we.current=y;let G=x(T);G.current=T;let ve=!!y,X=x(!1),q=x({x:0,y:0});k(()=>{let n=t=>{let i=t.clientX-q.current.x,s=t.clientY-q.current.y;Math.sqrt(i*i+s*s)>$e&&(X.current=!0)};return document.addEventListener("mousemove",n),()=>{document.removeEventListener("mousemove",n)}},[]),k(()=>{let n=document.querySelector('[data-testid="virtuoso-scroller"]');n&&n.querySelectorAll(".MuiTableSortLabel-root").forEach(i=>{let s=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});i.dispatchEvent(s)})},[p]);let ie=z(n=>{if(!S)return;S(n,p===n&&C==="asc"?"desc":"asc")},[S,p,C]),nt=z(n=>{let t=u?performance.now():0;if(!w){u&&(l.current.rangeChangedCalls+=1,l.current.rangeChangedMs+=performance.now()-t);return}if(d&&r.length===0){u&&(l.current.rangeChangedCalls+=1,l.current.rangeChangedMs+=performance.now()-t);return}let i=r.length>=30,s=n>=r.length-1,a=ye.current===r.length;if(s&&i&&!xe.current&&!a){xe.current=!0,ye.current=r.length;let e=r.length;w(e,50)}u&&(l.current.rangeChangedCalls+=1,l.current.rangeChangedMs+=performance.now()-t)},[r.length,d,w,u]);k(()=>{d||(xe.current=!1)},[d]),k(()=>{r.length===0&&et(n=>n+1)},[r.length]);let Me=x(r.length),Te=x(void 0);k(()=>{let n=Me.current,t=r.length,i=t>0?G.current?G.current(r[0],0):r[0]:void 0,s=Te.current;if(t>n&&n>0){Me.current=t,Te.current=i;return}let a=t<n||n>0&&i!==s;a&&(ye.current=-1),Ce.current&&t>0&&a&&Ce.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),Me.current=t,Te.current=i},[r]);let rt=z(()=>{let n={},t=[];if(c.forEach(e=>{e.group?(n[e.group]||(n[e.group]=[]),n[e.group].push(e)):t.push(e)}),!(Object.keys(n).length>0))return o(U,{children:c.map(e=>o(j,{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?o("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:V(E,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ie(String(e.id)),children:[e.text,o(Ie,{active:p===e.id,direction:p===e.id?C:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:p===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 s=[...t.map(e=>o(j,{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&&S?o("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:V(E,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ie(String(e.id)),children:[e.text,o(Ie,{active:p===e.id,direction:p===e.id?C:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:p===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(n).map(([e,m])=>o(j,{align:"center",colSpan:m.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e},e))],a=[...Object.values(n).flat().map(e=>o(j,{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&&S?o("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:V(E,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ie(String(e.id)),children:[e.text,o(Ie,{active:p===e.id,direction:p===e.id?C:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:p===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 V(ue,{children:[o(U,{children:s}),o(U,{children:a})]})},[c,p,C,ie,S,$]),ot=z((n,t)=>{let i=u?performance.now():0;if(!t){if(u){l.current.rowContentCalls+=1;let a=performance.now()-i;l.current.rowContentMs+=a,l.current.rowContentMaxMs=Math.max(l.current.rowContentMaxMs,a)}return null}let s=c.map(a=>{let e=u?performance.now():0,m=a.render?a.render(t,n):String(t[a.id]||"");if(u){let M=performance.now()-e;l.current.cellRenderCalls+=1,l.current.cellRenderMs+=M,l.current.cellRenderMaxMs=Math.max(l.current.cellRenderMaxMs,M)}return o(j,{align:a.align||"left",style:{width:a.width,minWidth:a.width,...a.style,padding:"8px 16px"},children:m},String(a.id))});if(u){l.current.rowContentCalls+=1;let a=performance.now()-i;l.current.rowContentMs+=a,l.current.rowContentMaxMs=Math.max(l.current.rowContentMaxMs,a)}return o(ue,{children:s})},[c,u]),L=fe??c.some(n=>typeof n.footer=="function"),it=z(()=>{if(!L)return null;let n=[];for(let t=0;t<c.length;t+=1){let i=c[t],s=i.footerColSpan&&i.footerColSpan>1?Math.min(i.footerColSpan,c.length-t):1;n.push(o(j,{align:i.align||"left",colSpan:s>1?s:void 0,style:{...s>1?{}:{width:i.width,minWidth:i.width},...i.style,fontWeight:"bold",padding:"16px"},children:i.footer?i.footer(r):null},String(i.id))),t+=s-1}return o(U,{children:n})},[L,c,r]),at=de(()=>({Scroller:Oe,Table:n=>o(xt,{...n,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px",...L?{height:"100%"}:{}}}),TableHead:ce((n,t)=>o(wt,{...n,ref:t,sx:{userSelect:"none","& tr":{height:$,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:n=>{let{item:t,selected:i,"aria-selected":s,className:a,...e}=n,m=e["data-index"]??0,M=m%2===1,B=t&&G.current?G.current(t,m):m,D=!oe&&f!==null&&f!==void 0&&B===f,Se=D&&h?typeof h=="function"?h(t,m):h:void 0,ae=String(a??"").split(/\s+/).filter(g=>g!=="Mui-selected"&&g!=="Mui-focusVisible").join(" ");return o(U,{...e,"data-row-id":B!=null?String(B):void 0,className:ae||void 0,selected:D,onMouseDown:g=>{X.current=!1,q.current={x:g.clientX,y:g.clientY}},onClick:g=>{let se=g.clientX-q.current.x,Re=g.clientY-q.current.y;if(Math.sqrt(se*se+Re*Re)>$e||X.current){g.preventDefault(),g.stopPropagation(),X.current=!1;return}t&&we.current&&we.current(t,m),X.current=!1},sx:[{userSelect:"none",height:re,maxHeight:re,boxSizing:"border-box",backgroundColor:M&&me?me:"transparent","& td":{padding:"8px 16px",boxSizing:"border-box",borderBottom:K?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":ve&&!D?{backgroundColor:g=>{let se=g.palette.mode==="dark",Le=he??"#000000",De=Ne??.06;if(!he)return se?`rgba(255, 255, 255, ${De})`:`rgba(0, 0, 0, ${De})`;let le=Le.replace("#","").trim();if(le.length!==6)return Le;let st=parseInt(le.substring(0,2),16),lt=parseInt(le.substring(2,4),16),ct=parseInt(le.substring(4,6),16);return`rgba(${st}, ${lt}, ${ct}, ${De})`}}:void 0,cursor:ve?"pointer":void 0},Se]})},TableBody:ce((n,t)=>{let{children:i,...s}=n;return V(yt,{...s,ref:t,sx:L?{height:"100%"}:void 0,children:[i,L&&o("tr",{"aria-hidden":!0,style:{height:"100%"},children:o("td",{colSpan:c.length,style:{padding:0,border:0}})})]})}),TableFoot:ce((n,t)=>o(vt,{...n,ref:t,sx:[{"& tr":{height:O??b,maxHeight:O??b,boxSizing:"border-box"},"& td":{height:O??b,boxSizing:"border-box",backgroundColor:i=>i.palette.mode==="dark"?"#1e1e1e":"#ffffff",padding:"0 16px",color:"inherit",fontSize:"0.875rem",border:"none",boxShadow:"inset 0 1px 0 0 #000000"}},...Array.isArray(F)?F:F?[F]:[]]}))}),[ve,oe?null:f,h,b,me,K,$,he,Ne,Oe,O,F,L,c]),He=V(E,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:n=>n.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"},...Ue??{},...P?{border:`1px solid ${H.borderStrong}`,borderRadius:"4px",overflow:"hidden","& thead tr th":{height:$,boxSizing:"border-box",padding:"0 14px !important",fontSize:13,fontWeight:"500 !important",color:H.headerColor,backgroundColor:`${H.bg} !important`,borderTop:"none",borderBottom:`1px solid ${H.borderStrong}`,borderRight:`1px solid ${H.border}`,"&:last-of-type":{borderRight:"none"}},"& tbody tr td":{padding:"0 14px !important",fontSize:14,borderBottom:`1px solid ${H.border}`}}:{}},children:[o(Rt,{ref:Ce,data:r,totalCount:w?r.length+1:r.length,defaultItemHeight:re,fixedItemHeight:re,fixedHeaderContent:rt,fixedFooterContent:L?it:void 0,itemContent:ot,endReached:nt,style:{height:"100%"},increaseViewportBy:{top:Ke,bottom:Ge},overscan:Je,followOutput:!1,components:at},Qe),r.length===0&&!d&&o(E,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof A=="string"?V(ue,{children:[o(E,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),o(Tt,{variant:"body1",sx:{color:"text.secondary"},children:A})]}):A}),tt&&o(ue,{children:_?o(_,{visible:d,onComplete:Pe}):o(We,{visible:d,onComplete:Pe,size:40,indicator:o(_e,{}),sx:{top:`${c.some(n=>n.group)?$*2:$}px`,bottom:`${L?O??b:0}px`},background:{show:r.length===0,opacity:.8}})})]}),ze=P?{paddingRight:ne,paddingTop:Be,paddingBottom:Be}:{};return Z?o(Mt,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:ne,...ze,boxSizing:"border-box",height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:He}):o(E,{className:"grow",style:{padding:0,paddingLeft:ne,...ze,boxSizing:"border-box",height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:He})}var Nt=mt(It);export{Nt as VirtualDataTable};
25
5
  /**
26
6
  * Virtual Data Table - A high-performance virtual data table component for React
27
7
  *