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