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