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