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