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