@ehfuse/mui-virtual-data-table 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{forwardRef as Ze,useCallback as me,useMemo as Qe,useRef as q,useEffect as Ne,memo as Lt,useState as lt}from"react";import{Box as he,Table as Dt,TableBody as Et,TableCell as je,TableContainer as Ht,TableHead as Rt,TableRow as Ve,TableSortLabel as et,Paper as It,Typography as $t}from"@mui/material";import{TableVirtuoso as Ot}from"react-virtuoso";import{jsx as Je}from"react/jsx-runtime";import{useRef as tt,useState as pt,useEffect as ft}from"react";import{Box as mt,CircularProgress as ht}from"@mui/material";var Pe=function(){return Pe=Object.assign||function(p){for(var h,v=1,D=arguments.length;v<D;v++){h=arguments[v];for(var k in h)Object.prototype.hasOwnProperty.call(h,k)&&(p[k]=h[k])}return p},Pe.apply(this,arguments)};function rt(s){var p=s.visible,h=s.onComplete,v=s.fadeoutDuration,D=v===void 0?200:v,k=s.exitDelay,T=k===void 0?0:k,B=s.size,L=B===void 0?40:B,N=s.className,x=s.style,j=s.sx,Z=s.indicator,Q=s.background,ge=Q===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:Q,ee=tt(void 0),a=tt(null),z=pt(p),te=z[0],re=z[1],$=ge.show,oe=$===void 0?!0:$,S=ge.color,E=S===void 0?"255, 255, 255":S,ne=ge.opacity,ie=ne===void 0?.9:ne;if(ft(function(){var Le=ee.current;if(Le===!0&&p===!1&&a.current){var ae=a.current;ae.style.opacity="0",setTimeout(function(){re(!1),h?.()},D+T)}else p===!0&&(re(!0),a.current&&(a.current.style.opacity="1"));ee.current=p},[p,h,D,T]),!te)return null;var we=function(){return typeof Z=="string"?Je("img",{src:Z,alt:"Loading",style:{width:L,height:L}}):Z||Je(ht,{size:L})},le=function(){return oe?E.startsWith("rgba")?{backgroundColor:E}:/^\d+,\s*\d+,\s*\d+$/.test(E)?{backgroundColor:"rgba(".concat(E,", ").concat(ie,")")}:ie!==1?{backgroundColor:E,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:E,opacity:ie,zIndex:-1}}:{backgroundColor:E}:{backgroundColor:"transparent"}};return Je(mt,{ref:a,className:N,style:Pe({},x),sx:Pe(Pe({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:p?1:0,transition:"opacity ".concat(D,"ms ease-out")},le()),j),children:we()})}import{useRef as U,useEffect as J,useState as A,useCallback as R,useMemo as Be,forwardRef as gt,useImperativeHandle as bt,useLayoutEffect as yt}from"react";import{jsx as Ce,jsxs as nt}from"react/jsx-runtime";var vt=["editor","textarea","input","select","textfield","form-control","contenteditable","MuiInputBase-input","MuiSelect-select","MuiOutlinedInput-input","MuiFilledInput-input","MuiInput-input","MuiFormControl-root","MuiTextField-root","MuiSelect-root","MuiOutlinedInput-root","MuiFilledInput-root","MuiInput-root","MuiAutocomplete-input","MuiDatePicker-input","MuiSlider-thumb","MuiSlider-rail","MuiSlider-track","MuiSlider-mark","MuiSlider-markLabel","MuiSlider-root","MuiSlider-colorPrimary","MuiSlider-sizeMedium","MuiIconButton-root","MuiButton-root","MuiButtonBase-root","MuiTouchRipple-root","MuiCheckbox-root","MuiRadio-root","MuiSwitch-root","PrivateSwitchBase-root","ant-input","ant-input-affix-wrapper","ant-input-group-addon","ant-input-number","ant-input-number-handler","ant-select","ant-select-selector","ant-select-selection-search","ant-select-dropdown","ant-cascader","ant-cascader-input","ant-picker","ant-picker-input","ant-time-picker","ant-calendar-picker","ant-slider","ant-slider-track","ant-slider-handle","ant-switch","ant-checkbox","ant-checkbox-wrapper","ant-radio","ant-radio-wrapper","ant-rate","ant-upload","ant-upload-drag","ant-form-item","ant-form-item-control","ant-btn","ant-dropdown","ant-dropdown-trigger","ant-menu","ant-menu-item","ant-tooltip","ant-popover","ant-modal","ant-drawer","ant-tree-select","ant-auto-complete","ant-mentions","ant-transfer","ui-input","ui-textarea","ui-select","ui-select-trigger","ui-select-content","ui-select-item","ui-button","ui-checkbox","ui-radio-group","ui-switch","ui-slider","ui-range-slider","ui-calendar","ui-date-picker","ui-combobox","ui-command","ui-command-input","ui-popover","ui-dialog","ui-sheet","ui-dropdown-menu","ui-context-menu","ui-menubar","ui-navigation-menu","ui-form","ui-form-control","ui-form-item","ui-form-field","ui-label","radix-ui","radix-select","radix-dropdown","radix-dialog","radix-popover","radix-accordion","radix-tabs","radix-slider","radix-switch","radix-checkbox","radix-radio","ql-editor","ql-container","ql-toolbar","ql-picker","ql-picker-label","ql-picker-options","ql-formats","ql-snow","ql-bubble","quill","quilleditor","monaco-editor","monaco-editor-background","view-lines","decorationsOverviewRuler","monaco-scrollable-element","CodeMirror","CodeMirror-code","CodeMirror-lines","CodeMirror-scroll","CodeMirror-sizer","cm-editor","cm-focused","cm-content","tox-editor-container","tox-editor-header","tox-edit-area","tox-tinymce","mce-content-body","ck-editor","ck-content","ck-toolbar","ck-editor__editable","ck-widget","slate-editor","slate-content","DraftEditor-root","DraftEditor-editorContainer","public-DraftEditor-content","ehfuse-editor","ehfuse-editor-wrapper","ehfuse-editor-content","ehfuse-toolbar","ehfuse-toolbar-group","ehfuse-cursor","text-editor","rich-text-editor","wysiwyg","ace_editor","ace_content"],ot=(s,p)=>{let h=s.tagName.toLowerCase(),v=["text","password","email","number","search","tel","url","checkbox","radio"];if(h==="input"){let D=s.type;return v.includes(D)}if(["textarea","select","button"].includes(h)||["svg","path","circle","rect","line","polygon","polyline"].includes(h)||s.getAttribute("contenteditable")==="true")return!0;if(p?.excludeSelectors){for(let D of p.excludeSelectors)if(s.matches(D))return!0}return xt(s,p)},xt=(s,p)=>{let h=[...vt,...p?.excludeClasses||[]],v=s,D=0,k=5;for(;v&&D<=k;){if(h.some(T=>v.classList.contains(T)))return!0;if(v.classList.contains("MuiDialogContent-root"))break;v=v.parentElement,D++}return!1},wt={},Mt={},Tt={},St={},Ct={},kt=gt(({className:s="",style:p={},containerStyle:h={},contentStyle:v={},children:D,onScroll:k,thumb:T=wt,track:B=Mt,arrows:L=Tt,dragScroll:N=St,autoHide:x=Ct,showScrollbar:j=!0,detectInnerScroll:Z=!1},Q)=>{let ge=U({});J(()=>{ge.current={children:D,onScroll:k,showScrollbar:j,thumb:T,track:B,arrows:L,dragScroll:N,autoHide:x}});let ee=U(null),a=U(null),z=U(null),te=U(null),re=U(null),$=U(null),[oe,S]=A(!1),[E,ne]=A(!1),[ie,we]=A(!1),[le,Le]=A({y:0,scrollTop:0}),[ae,De]=A(0),[_e,Y]=A(0),[X,Ee]=A(!1),[se,He]=A(!1),[K,Me]=A({x:0,y:0,scrollTop:0,scrollLeft:0}),[ze,at]=A(null),[Te,ce]=A(null),[Ae,Se]=A(!1),be=U(null),[Ye,qe]=A(!1),ye=U(null),ue=U(null),r=U(null),n=Be(()=>{let t=T.color??"#606060";return{width:T.width??8,minHeight:T.minHeight??50,radius:T.radius??(T.width??8)/2,color:t,opacity:T.opacity??.6,hoverColor:T.hoverColor??t,hoverOpacity:T.hoverOpacity??1}},[T]),l=Be(()=>({width:B.width??16,color:B.color??"rgba(128, 128, 128, 0.1)",visible:B.visible??!0,alignment:B.alignment??"center",radius:B.radius??n.radius??4,margin:B.margin??4}),[B,n.radius]),m=Be(()=>{let t=L.color??"#808080";return{visible:L.visible??!1,step:L.step??50,color:t,opacity:L.opacity??.6,hoverColor:L.hoverColor??t,hoverOpacity:L.hoverOpacity??1}},[L]),W=Be(()=>({enabled:N.enabled??!0,excludeClasses:N.excludeClasses??[],excludeSelectors:N.excludeSelectors??[]}),[N]),e=Be(()=>({enabled:x.enabled??!0,delay:x.delay??1500,delayOnWheel:x.delayOnWheel??700}),[x]),g=n.width,Re=l.width,de=n.minHeight,V=m.visible,pe=m.step,H=R(()=>{if(!a.current)return;let t=document.activeElement;t&&a.current.contains(t)&&t!==a.current||a.current.focus()},[]);bt(Q,()=>({getScrollContainer:()=>a.current,scrollTo:t=>{a.current&&a.current.scrollTo(t)},get scrollTop(){return a.current?.scrollTop||0},get scrollHeight(){return a.current?.scrollHeight||0},get clientHeight(){return a.current?.clientHeight||0}}),[]);let f=R(()=>{if($.current){let o=$.current;if(document.contains(o)&&o.scrollHeight>o.clientHeight+2)return o;$.current=null}if(!a.current)return null;if(z.current&&z.current.scrollHeight>a.current.clientHeight+2)return $.current=a.current,a.current;if(!Z)return null;let t=a.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let o of t){let i=o;if(i!==a.current&&i.classList.contains("overlay-scrollbar-container"))continue;let c=i.parentElement,y=!1;for(;c&&c!==a.current;){if(c.classList.contains("overlay-scrollbar-container")&&c!==a.current){y=!0;break}c=c.parentElement}if(!y&&i.scrollHeight>i.clientHeight+2)return $.current=i,i}return null},[]),I=R(()=>f()!==null,[f]),b=R(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null)},[]),ve=R(()=>{ue.current&&(clearTimeout(ue.current),ue.current=null)},[]),fe=R(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),w=R(t=>{e.enabled&&(b(),ye.current=setTimeout(()=>{S(!1),ye.current=null},t))},[b,e.enabled]),u=R(()=>{let t=f();if(!t){S(!1),Ee(!1),b();return}if(Ee(!0),!te.current)return;e.enabled||(S(!0),b());let o=t.clientHeight,i=t.scrollHeight,c=t.scrollTop,y=0;if(ee.current){let We=window.getComputedStyle(ee.current),Ke=parseFloat(We.paddingTop)||0,dt=parseFloat(We.paddingBottom)||0;y=Ke+dt}let M=V?g*2+l.margin*4:l.margin*2,O=o-M+y,P=o/i,xe=Math.max(O*P,de),Oe=i-o,G=O-xe,Xe=Oe>0?c/Oe*G:0;De(xe),Y(Xe)},[f,b,V,g,de,e.enabled]),Ie=R(t=>{t.preventDefault(),t.stopPropagation();let o=f();o&&(ne(!0),Le({y:t.clientY,scrollTop:o.scrollTop}),b(),S(!0),H())},[f,b,H]),C=R(t=>{if(!E)return;let o=f();if(!o)return;let i=o.clientHeight,c=o.scrollHeight-i,y=t.clientY-le.y,M=i-ae,O=y/M*c,P=Math.max(0,Math.min(c,le.scrollTop+O));o.scrollTop=P,u()},[E,le,ae,u,f]),F=R(()=>{ne(!1),I()&&w(e.delay)},[I,w,e.delay]),_=R(t=>{if(!te.current)return;let o=te.current.getBoundingClientRect(),i=t.clientY-o.top,c=f();if(!c)return;let y=c.clientHeight,M=c.scrollHeight,O=i/y*(M-y);c.scrollTop=Math.max(0,Math.min(M-y,O)),u(),S(!0),w(e.delay),H()},[u,w,e.delay,f,H]),st=R(t=>{if(t.preventDefault(),t.stopPropagation(),!a.current)return;let o=Math.max(0,a.current.scrollTop-pe);a.current.scrollTop=o,u(),S(!0),w(e.delay),H()},[u,w,pe,e.delay,H]),ct=R(t=>{if(t.preventDefault(),t.stopPropagation(),!a.current||!z.current)return;let o=a.current,i=z.current.scrollHeight-o.clientHeight,c=Math.min(i,o.scrollTop+pe);o.scrollTop=c,u(),S(!0),w(e.delay),H()},[u,w,pe,e.delay,H]),ut=R(t=>{if(!W.enabled)return;let o=t.target;if(ot(o,W)||t.button!==0)return;let i=f();i&&(i.scrollHeight<=i.clientHeight||(t.preventDefault(),He(!0),Me({x:t.clientX,y:t.clientY,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft||0}),b()))},[W,ot,f,b]),Ge=R(t=>{if(!se)return;let o=f();if(!o)return;let i=K.x-t.clientX,c=K.y-t.clientY;if(Math.abs(c)<3&&Math.abs(i)<3)return;S(!0);let y=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,K.scrollTop+c));o.scrollTop=y,u()},[se,K,f,u]),Ue=R(()=>{He(!1),I()&&w(e.delay)},[I,w,e.delay]);J(()=>{let t=M=>{u(),b(),S(!0);let O=Ye?e.delayOnWheel:e.delay;w(O),k&&k(M)},o=()=>{qe(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>{qe(!1)},300),b(),fe(),r.current=setTimeout(()=>{S(!0),r.current=null},50)},i=[],c=f();c&&i.push(c);let y=a.current;return y&&!c&&(i.push(y),y.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(M=>{let O=M;if(O!==y&&O.classList.contains("overlay-scrollbar-container"))return;let P=O.parentElement;for(;P&&P!==y;){if(P.classList.contains("overlay-scrollbar-container")&&P!==y)return;P=P.parentElement}i.push(O)})),i.forEach(M=>{M.addEventListener("scroll",t,{passive:!0}),M.addEventListener("wheel",o,{passive:!0})}),()=>{i.forEach(M=>{M.removeEventListener("scroll",t),M.removeEventListener("wheel",o)}),be.current&&clearTimeout(be.current),r.current&&clearTimeout(r.current)}},[f,u,k,b,w,e,Ye]),J(()=>{let t=i=>{let c=f();if(!c)return;let{key:y}=i,{scrollTop:M,scrollHeight:O,clientHeight:P}=c,xe=O-P,Oe=50,G=null;switch(y){case"ArrowUp":i.preventDefault(),G=Math.max(0,M-Oe);break;case"ArrowDown":i.preventDefault(),G=Math.min(xe,M+Oe);break;case"PageUp":i.preventDefault(),G=Math.max(0,M-P);break;case"PageDown":i.preventDefault(),G=Math.min(xe,M+P);break;case"Home":i.preventDefault(),G=0;break;case"End":i.preventDefault(),G=xe;break;default:return}if(G!==null){let Xe=G/xe,We=V?g*2+l.margin*4:l.margin*2,Ke=(P-We-ae)*Xe;Y(Ke),c.scrollTop=G,b(),S(!0),w(e.delay)}},o=a.current;if(o)return o.addEventListener("keydown",t),()=>{o.removeEventListener("keydown",t)}},[f,V,g,l.margin,ae,b,w,e.delay]),J(()=>{if(se)return document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",Ue),()=>{document.removeEventListener("mousemove",Ge),document.removeEventListener("mouseup",Ue)}},[se,Ge,Ue]),J(()=>{if(E)return document.addEventListener("mousemove",C),document.addEventListener("mouseup",F),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",F)}},[E,C,F]),J(()=>{u();let t=setTimeout(()=>{u()},100);return()=>clearTimeout(t)},[u]),yt(()=>{Se(!0),u(),!e.enabled&&I()&&S(!0)},[I,u,e.enabled]),J(()=>{let t=new ResizeObserver(()=>{u()}),o=[];return a.current&&o.push(a.current),z.current&&o.push(z.current),$.current&&document.contains($.current)&&o.push($.current),o.forEach(i=>{t.observe(i)}),()=>t.disconnect()},[u]),J(()=>{if(!a.current)return;let t=new MutationObserver(()=>{$.current=null,u()});return t.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>t.disconnect()},[u]);let $e=Math.max(Re,g);return J(()=>{let t="overlay-scrollbar-webkit-hide",o=document.getElementById(t);o&&o.remove();let i=document.createElement("style");return i.id=t,i.textContent=`
|
|
1
|
+
import{forwardRef as Qe,useCallback as fe,useMemo as et,useRef as Y,useEffect as He,memo as Lt,useState as at}from"react";import{Box as me,Table as Dt,TableBody as Et,TableCell as Ye,TableContainer as Ht,TableHead as Rt,TableRow as _e,TableSortLabel as tt,Paper as It,Typography as $t}from"@mui/material";import{TableVirtuoso as Ot}from"react-virtuoso";import{jsx as Ze}from"react/jsx-runtime";import{useRef as rt,useState as pt,useEffect as ft}from"react";import{Box as mt,CircularProgress as ht}from"@mui/material";var ze=function(){return ze=Object.assign||function(p){for(var g,v=1,L=arguments.length;v<L;v++){g=arguments[v];for(var C in g)Object.prototype.hasOwnProperty.call(g,C)&&(p[C]=g[C])}return p},ze.apply(this,arguments)};function ot(l){var p=l.visible,g=l.onComplete,v=l.fadeoutDuration,L=v===void 0?200:v,C=l.exitDelay,M=C===void 0?0:C,P=l.size,k=P===void 0?40:P,N=l.className,x=l.style,j=l.sx,ee=l.indicator,te=l.background,he=te===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:te,re=rt(void 0),a=rt(null),z=pt(p),oe=z[0],ne=z[1],I=he.show,ie=I===void 0?!0:I,T=he.color,E=T===void 0?"255, 255, 255":T,le=he.opacity,ae=le===void 0?.9:le;if(ft(function(){var Ie=re.current;if(Ie===!0&&p===!1&&a.current){var ce=a.current;ce.style.opacity="0",setTimeout(function(){ne(!1),g?.()},L+M)}else p===!0&&(ne(!0),a.current&&(a.current.style.opacity="1"));re.current=p},[p,g,L,M]),!oe)return null;var Te=function(){return typeof ee=="string"?Ze("img",{src:ee,alt:"Loading",style:{width:k,height:k}}):ee||Ze(ht,{size:k})},se=function(){return ie?E.startsWith("rgba")?{backgroundColor:E}:/^\d+,\s*\d+,\s*\d+$/.test(E)?{backgroundColor:"rgba(".concat(E,", ").concat(ae,")")}:ae!==1?{backgroundColor:E,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:E,opacity:ae,zIndex:-1}}:{backgroundColor:E}:{backgroundColor:"transparent"}};return Ze(mt,{ref:a,className:N,style:ze({},x),sx:ze(ze({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:p?1:0,transition:"opacity ".concat(L,"ms ease-out")},se()),j),children:Te()})}import{useRef as G,useEffect as Q,useState as A,useCallback as H,useMemo as Ae,forwardRef as gt,useImperativeHandle as bt,useLayoutEffect as yt}from"react";import{jsx as Ee,jsxs as it}from"react/jsx-runtime";var vt=["editor","textarea","input","select","textfield","form-control","contenteditable","MuiInputBase-input","MuiSelect-select","MuiOutlinedInput-input","MuiFilledInput-input","MuiInput-input","MuiFormControl-root","MuiTextField-root","MuiSelect-root","MuiOutlinedInput-root","MuiFilledInput-root","MuiInput-root","MuiAutocomplete-input","MuiDatePicker-input","MuiSlider-thumb","MuiSlider-rail","MuiSlider-track","MuiSlider-mark","MuiSlider-markLabel","MuiSlider-root","MuiSlider-colorPrimary","MuiSlider-sizeMedium","MuiIconButton-root","MuiButton-root","MuiButtonBase-root","MuiTouchRipple-root","MuiCheckbox-root","MuiRadio-root","MuiSwitch-root","PrivateSwitchBase-root","ant-input","ant-input-affix-wrapper","ant-input-group-addon","ant-input-number","ant-input-number-handler","ant-select","ant-select-selector","ant-select-selection-search","ant-select-dropdown","ant-cascader","ant-cascader-input","ant-picker","ant-picker-input","ant-time-picker","ant-calendar-picker","ant-slider","ant-slider-track","ant-slider-handle","ant-switch","ant-checkbox","ant-checkbox-wrapper","ant-radio","ant-radio-wrapper","ant-rate","ant-upload","ant-upload-drag","ant-form-item","ant-form-item-control","ant-btn","ant-dropdown","ant-dropdown-trigger","ant-menu","ant-menu-item","ant-tooltip","ant-popover","ant-modal","ant-drawer","ant-tree-select","ant-auto-complete","ant-mentions","ant-transfer","ui-input","ui-textarea","ui-select","ui-select-trigger","ui-select-content","ui-select-item","ui-button","ui-checkbox","ui-radio-group","ui-switch","ui-slider","ui-range-slider","ui-calendar","ui-date-picker","ui-combobox","ui-command","ui-command-input","ui-popover","ui-dialog","ui-sheet","ui-dropdown-menu","ui-context-menu","ui-menubar","ui-navigation-menu","ui-form","ui-form-control","ui-form-item","ui-form-field","ui-label","radix-ui","radix-select","radix-dropdown","radix-dialog","radix-popover","radix-accordion","radix-tabs","radix-slider","radix-switch","radix-checkbox","radix-radio","ql-editor","ql-container","ql-toolbar","ql-picker","ql-picker-label","ql-picker-options","ql-formats","ql-snow","ql-bubble","quill","quilleditor","monaco-editor","monaco-editor-background","view-lines","decorationsOverviewRuler","monaco-scrollable-element","CodeMirror","CodeMirror-code","CodeMirror-lines","CodeMirror-scroll","CodeMirror-sizer","cm-editor","cm-focused","cm-content","tox-editor-container","tox-editor-header","tox-edit-area","tox-tinymce","mce-content-body","ck-editor","ck-content","ck-toolbar","ck-editor__editable","ck-widget","slate-editor","slate-content","DraftEditor-root","DraftEditor-editorContainer","public-DraftEditor-content","ehfuse-editor","ehfuse-editor-wrapper","ehfuse-editor-content","ehfuse-toolbar","ehfuse-toolbar-group","ehfuse-cursor","text-editor","rich-text-editor","wysiwyg","ace_editor","ace_content"],nt=(l,p)=>{let g=l.tagName.toLowerCase(),v=["text","password","email","number","search","tel","url","checkbox","radio"];if(g==="input"){let L=l.type;return v.includes(L)}if(["textarea","select","button"].includes(g)||["svg","path","circle","rect","line","polygon","polyline"].includes(g)||l.getAttribute("contenteditable")==="true")return!0;if(p?.excludeSelectors){for(let L of p.excludeSelectors)if(l.matches(L))return!0}return xt(l,p)},xt=(l,p)=>{let g=[...vt,...p?.excludeClasses||[]],v=l,L=0,C=5;for(;v&&L<=C;){if(g.some(M=>v.classList.contains(M)))return!0;if(v.classList.contains("MuiDialogContent-root"))break;v=v.parentElement,L++}return!1},wt={},Mt={},Tt={},St={},Ct={},kt=gt(({className:l="",style:p={},containerStyle:g={},contentStyle:v={},children:L,onScroll:C,thumb:M=wt,track:P=Mt,arrows:k=Tt,dragScroll:N=St,autoHide:x=Ct,showScrollbar:j=!0,detectInnerScroll:ee=!1},te)=>{let he=G({});Q(()=>{he.current={children:L,onScroll:C,showScrollbar:j,thumb:M,track:P,arrows:k,dragScroll:N,autoHide:x}});let re=G(null),a=G(null),z=G(null),oe=G(null),ne=G(null),I=G(null),[ie,T]=A(!1),[E,le]=A(!1),[ae,Te]=A(!1),[se,Ie]=A({y:0,scrollTop:0}),[ce,$e]=A(0),[Oe,q]=A(0),[U,Pe]=A(!1),[ue,Be]=A(!1),[K,Se]=A({x:0,y:0,scrollTop:0,scrollLeft:0}),[qe,st]=A(null),[Ce,de]=A(null),[We,ke]=A(!1),ge=G(null),[Le,Ve]=A(!1),be=G(null),ye=G(null),X=G(null),o=Ae(()=>{let t=M.color??"#606060";return{width:M.width??8,minHeight:M.minHeight??50,radius:M.radius??(M.width??8)/2,color:t,opacity:M.opacity??.6,hoverColor:M.hoverColor??t,hoverOpacity:M.hoverOpacity??1}},[M]),r=Ae(()=>({width:P.width??16,color:P.color??"rgba(128, 128, 128, 0.1)",visible:P.visible??!0,alignment:P.alignment??"center",radius:P.radius??o.radius??4,margin:P.margin??4}),[P,o.radius]),c=Ae(()=>{let t=k.color??"#808080";return{visible:k.visible??!1,step:k.step??50,color:t,opacity:k.opacity??.6,hoverColor:k.hoverColor??t,hoverOpacity:k.hoverOpacity??1}},[k]),D=Ae(()=>({enabled:N.enabled??!0,excludeClasses:N.excludeClasses??[],excludeSelectors:N.excludeSelectors??[]}),[N]),u=Ae(()=>({enabled:x.enabled??!0,delay:x.delay??1500,delayOnWheel:x.delayOnWheel??700}),[x]),e=o.width,J=r.width,ve=o.minHeight,B=c.visible,De=c.step,W=H(()=>{if(!a.current)return;let t=document.activeElement;t&&a.current.contains(t)&&t!==a.current||a.current.focus()},[]);bt(te,()=>({getScrollContainer:()=>a.current,scrollTo:t=>{a.current&&a.current.scrollTo(t)},get scrollTop(){return a.current?.scrollTop||0},get scrollHeight(){return a.current?.scrollHeight||0},get clientHeight(){return a.current?.clientHeight||0}}),[]);let f=H(()=>{if(I.current){let n=I.current;if(document.contains(n)&&n.scrollHeight>n.clientHeight+2)return n;I.current=null}if(!a.current)return null;if(z.current&&z.current.scrollHeight>a.current.clientHeight+2)return I.current=a.current,a.current;if(!ee)return null;let t=a.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let n of t){let i=n;if(i!==a.current&&i.classList.contains("overlay-scrollbar-container"))continue;let s=i.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&&i.scrollHeight>i.clientHeight+2)return I.current=i,i}return null},[]),R=H(()=>f()!==null,[f]),h=H(()=>{be.current&&(clearTimeout(be.current),be.current=null)},[]),pe=H(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null)},[]),xe=H(()=>{X.current&&(clearTimeout(X.current),X.current=null)},[]),b=H(t=>{u.enabled&&(h(),be.current=setTimeout(()=>{T(!1),be.current=null},t))},[h,u.enabled]),m=H(()=>{let t=f();if(!t){T(!1),Pe(!1),h();return}if(Pe(!0),!oe.current)return;u.enabled||(T(!0),h());let n=t.clientHeight,i=t.scrollHeight,s=t.scrollTop,y=0;if(re.current){let Fe=window.getComputedStyle(re.current),Je=parseFloat(Fe.paddingTop)||0,dt=parseFloat(Fe.paddingBottom)||0;y=Je+dt}let w=B?e*2+r.margin*4:r.margin*2,$=n-w+y,O=n/i,Me=Math.max($*O,ve),je=i-n,_=$-Me,Ke=je>0?s/je*_:0;$e(Me),q(Ke)},[f,h,B,e,ve,u.enabled]),V=H(t=>{t.preventDefault(),t.stopPropagation();let n=f();n&&(le(!0),Ie({y:t.clientY,scrollTop:n.scrollTop}),h(),T(!0),W())},[f,h,W]),we=H(t=>{if(!E)return;let n=f();if(!n)return;let i=n.clientHeight,s=n.scrollHeight-i,y=t.clientY-se.y,w=i-ce,$=y/w*s,O=Math.max(0,Math.min(s,se.scrollTop+$));n.scrollTop=O,m()},[E,se,ce,m,f]),S=H(()=>{le(!1),R()&&b(u.delay)},[R,b,u.delay]),Z=H(t=>{if(!oe.current)return;let n=oe.current.getBoundingClientRect(),i=t.clientY-n.top,s=f();if(!s)return;let y=s.clientHeight,w=s.scrollHeight,$=i/y*(w-y);s.scrollTop=Math.max(0,Math.min(w-y,$)),m(),T(!0),b(u.delay),W()},[m,b,u.delay,f,W]),F=H(t=>{if(t.preventDefault(),t.stopPropagation(),!a.current)return;let n=Math.max(0,a.current.scrollTop-De);a.current.scrollTop=n,m(),T(!0),b(u.delay),W()},[m,b,De,u.delay,W]),ct=H(t=>{if(t.preventDefault(),t.stopPropagation(),!a.current||!z.current)return;let n=a.current,i=z.current.scrollHeight-n.clientHeight,s=Math.min(i,n.scrollTop+De);n.scrollTop=s,m(),T(!0),b(u.delay),W()},[m,b,De,u.delay,W]),ut=H(t=>{if(!D.enabled)return;let n=t.target;if(nt(n,D)||t.button!==0)return;let i=f();i&&(i.scrollHeight<=i.clientHeight||(t.preventDefault(),Be(!0),Se({x:t.clientX,y:t.clientY,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft||0}),h()))},[D,nt,f,h]),Ue=H(t=>{if(!ue)return;let n=f();if(!n)return;let i=K.x-t.clientX,s=K.y-t.clientY;if(Math.abs(s)<3&&Math.abs(i)<3)return;T(!0);let y=Math.max(0,Math.min(n.scrollHeight-n.clientHeight,K.scrollTop+s));n.scrollTop=y,m()},[ue,K,f,m]),Xe=H(()=>{Be(!1),R()&&b(u.delay)},[R,b,u.delay]);Q(()=>{let t=w=>{m(),h(),T(!0);let $=Le?u.delayOnWheel:u.delay;b($),C&&C(w)},n=()=>{Ve(!0),ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{Ve(!1)},300),h(),xe(),X.current=setTimeout(()=>{T(!0),X.current=null},50)},i=[],s=f();s&&i.push(s);let y=a.current;return y&&!s&&(i.push(y),y.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(w=>{let $=w;if($!==y&&$.classList.contains("overlay-scrollbar-container"))return;let O=$.parentElement;for(;O&&O!==y;){if(O.classList.contains("overlay-scrollbar-container")&&O!==y)return;O=O.parentElement}i.push($)})),i.forEach(w=>{w.addEventListener("scroll",t,{passive:!0}),w.addEventListener("wheel",n,{passive:!0})}),()=>{i.forEach(w=>{w.removeEventListener("scroll",t),w.removeEventListener("wheel",n)}),ge.current&&clearTimeout(ge.current),X.current&&clearTimeout(X.current)}},[f,m,C,h,b,u,Le]),Q(()=>{let t=i=>{let s=f();if(!s)return;let{key:y}=i,{scrollTop:w,scrollHeight:$,clientHeight:O}=s,Me=$-O,je=50,_=null;switch(y){case"ArrowUp":i.preventDefault(),_=Math.max(0,w-je);break;case"ArrowDown":i.preventDefault(),_=Math.min(Me,w+je);break;case"PageUp":i.preventDefault(),_=Math.max(0,w-O);break;case"PageDown":i.preventDefault(),_=Math.min(Me,w+O);break;case"Home":i.preventDefault(),_=0;break;case"End":i.preventDefault(),_=Me;break;default:return}if(_!==null){let Ke=_/Me,Fe=B?e*2+r.margin*4:r.margin*2,Je=(O-Fe-ce)*Ke;q(Je),s.scrollTop=_,h(),T(!0),b(u.delay)}},n=a.current;if(n)return n.addEventListener("keydown",t),()=>{n.removeEventListener("keydown",t)}},[f,B,e,r.margin,ce,h,b,u.delay]),Q(()=>{if(ue)return document.addEventListener("mousemove",Ue),document.addEventListener("mouseup",Xe),()=>{document.removeEventListener("mousemove",Ue),document.removeEventListener("mouseup",Xe)}},[ue,Ue,Xe]),Q(()=>{if(E)return document.addEventListener("mousemove",we),document.addEventListener("mouseup",S),()=>{document.removeEventListener("mousemove",we),document.removeEventListener("mouseup",S)}},[E,we,S]),Q(()=>{m();let t=setTimeout(()=>{m()},100);return()=>clearTimeout(t)},[m]),yt(()=>{ke(!0),m(),!u.enabled&&R()&&T(!0)},[R,m,u.enabled]),Q(()=>{let t=new ResizeObserver(()=>{m()}),n=[];return a.current&&n.push(a.current),z.current&&n.push(z.current),I.current&&document.contains(I.current)&&n.push(I.current),n.forEach(i=>{t.observe(i)}),()=>t.disconnect()},[m]),Q(()=>{if(!a.current)return;let t=new MutationObserver(()=>{I.current=null,m()});return t.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>t.disconnect()},[m]);let Ne=Math.max(J,e);return Q(()=>{let t="overlay-scrollbar-webkit-hide",n=document.getElementById(t);n&&n.remove();let i=document.createElement("style");return i.id=t,i.textContent=`
|
|
2
2
|
.overlay-scrollbar-container::-webkit-scrollbar {
|
|
3
3
|
display: none !important;
|
|
4
4
|
width: 0 !important;
|
|
@@ -18,7 +18,7 @@ import{forwardRef as Ze,useCallback as me,useMemo as Qe,useRef as q,useEffect as
|
|
|
18
18
|
outline: 2px solid rgba(0, 123, 255, 0.5);
|
|
19
19
|
outline-offset: -2px;
|
|
20
20
|
}
|
|
21
|
-
`,document.head.appendChild(i),()=>{let c=document.getElementById(t);c&&c.remove()}},[]),nt("div",{ref:ee,className:`overlay-scrollbar-wrapper ${s}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...p},children:[Ce("div",{ref:a,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:ut,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:se?"none":"auto",...h},children:Ce("div",{ref:z,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...v},children:D})}),j&&X&&nt("div",{ref:te,className:"overlay-scrollbar-track",onMouseEnter:()=>{b(),ue.current=setTimeout(()=>{S(!0),ue.current=null},100)},onMouseLeave:()=>{ve(),E||w(e.delay)},style:{position:"absolute",top:0,right:0,width:`${$e}px`,height:"100%",opacity:oe?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[l.visible&&Ce("div",{className:"overlay-scrollbar-track-background",onClick:t=>{t.preventDefault(),t.stopPropagation(),_(t)},style:{position:"absolute",top:V?`${n.width+l.margin*2}px`:`${l.margin}px`,right:l.alignment==="right"?"0px":`${($e-n.width)/2}px`,width:`${n.width}px`,height:V?`calc(100% - ${n.width*2+l.margin*4}px)`:`calc(100% - ${l.margin*2}px)`,backgroundColor:l.color,borderRadius:`${l.radius}px`,cursor:"pointer"}}),Ce("div",{ref:re,className:"overlay-scrollbar-thumb",onMouseDown:Ie,onMouseEnter:()=>we(!0),onMouseLeave:()=>we(!1),style:{position:"absolute",top:`${(V?g+l.margin*2:l.margin)+_e}px`,right:l.alignment==="right"?"0px":`${($e-g)/2}px`,width:`${g}px`,height:`${Math.max(ae,de)}px`,backgroundColor:ie||E?n.hoverColor:n.color,opacity:ie||E?n.hoverOpacity:n.opacity,borderRadius:`${n.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),j&&X&&V&&Ce("div",{className:"overlay-scrollbar-up-arrow",onClick:st,onMouseEnter:()=>ce("up"),onMouseLeave:()=>ce(null),style:{position:"absolute",top:`${l.margin}px`,right:l.alignment==="right"?"0px":`${($e-g)/2}px`,width:`${g}px`,height:`${g}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(g*.75,8)}px`,color:Te==="up"?m.hoverColor:m.color,userSelect:"none",zIndex:1001,opacity:oe?Te==="up"?m.hoverOpacity:m.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),j&&X&&V&&Ce("div",{className:"overlay-scrollbar-down-arrow",onClick:ct,onMouseEnter:()=>ce("down"),onMouseLeave:()=>ce(null),style:{position:"absolute",bottom:`${l.margin}px`,right:l.alignment==="right"?"0px":`${($e-g)/2}px`,width:`${g}px`,height:`${g}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(g*.75,8)}px`,color:Te==="down"?m.hoverColor:m.color,userSelect:"none",zIndex:1001,opacity:oe?Te==="down"?m.hoverOpacity:m.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),it=kt;import{Fragment as Fe,jsx as d,jsxs as ke}from"react/jsx-runtime";var Pt={alignment:"right",margin:0,radius:0};function Bt({data:s,loading:p=!1,columns:h,onRowClick:v,rowHeight:D=50,columnHeight:k=56,striped:T,rowDivider:B=!0,onSort:L,onLoadMore:N,sortBy:x,sortDirection:j,showPaper:Z=!0,paddingX:Q="1rem",paddingTop:ge=0,paddingBottom:ee=0,rowHoverColor:a,rowHoverOpacity:z,scrollbars:te,emptyMessage:re="NO DATA",LoadingComponent:$}){let oe=Qe(()=>Ze((r,n)=>{let l=q(null);return d(it,{detectInnerScroll:!0,track:Pt,...te,children:d(Ht,{component:he,...r,ref:m=>{l.current=m,typeof n=="function"?n(m):n&&(n.current=m)},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:Q,paddingTop:ge,paddingBottom:ee}}})})}),[]),S=Qe(()=>{if(T===!0)return"#f5f5f5";if(typeof T=="string")return T},[T]),[E,ne]=lt(p),[ie,we]=lt(0);Ne(()=>{p&&ne(!0)},[p]);let le=me(()=>{ne(!1)},[]),Le=E,ae=p&&s.length>0,De=q(!1),_e=q(null),Y=q(null),X=q(!1),Ee=q({x:0,y:0,scrollTop:0}),se=q(!1),He=q(0),K=q(0),Me=q(!1),ze=q({x:0,y:0}),at=q(null),Te=me(r=>{},[]),ce=me(r=>{if(!se.current||!Y.current)return;let n=r.clientY-Ee.current.y;if(!X.current&&Math.abs(n)>5&&(X.current=!0,Y.current&&(Y.current.style.userSelect="none")),X.current){let m=n*2;K.current+=-m;let W=Y.current,e=Math.max(0,He.current+K.current);W.scrollTop=e,Ee.current.y=r.clientY,r.preventDefault()}},[]),Ae=me(()=>{if(se.current=!1,X.current&&Y.current){let r=Math.max(0,He.current+K.current),n=()=>{Y.current&&(Y.current.scrollTop=r)};n(),setTimeout(n,1),setTimeout(n,5),setTimeout(n,10)}X.current=!1,K.current=0,Y.current&&(Y.current.style.userSelect="auto")},[]);Ne(()=>{let r=document.querySelector('[data-testid="virtuoso-scroller"]');r&&r.querySelectorAll(".MuiTableSortLabel-root").forEach(l=>{let m=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});l.dispatchEvent(m)})},[x]);let Se=me(r=>{if(!L)return;L(r,x===r&&j==="asc"?"desc":"asc")},[L,x,j]),be=me(r=>{if(!N||p&&s.length===0)return;let n=Date.now(),l=window.lastRangeChangeTime||0;if(n-l<100)return;window.lastRangeChangeTime=n;let m=Math.max(10,Math.floor(s.length*.1)),W=r.endIndex>=s.length-m,e=s.length>=30;if(W&&e&&N&&!De.current){De.current=!0;let g=s.length;N(g,50)}},[s.length,p,N]);Ne(()=>{p||(De.current=!1)},[p]),Ne(()=>{s.length===0&&we(r=>r+1)},[s.length]),Ne(()=>(document.addEventListener("mousemove",ce),document.addEventListener("mouseup",Ae),()=>{document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",Ae)}),[ce,Ae]);let Ye=me(()=>{let r={},n=[];if(h.forEach(e=>{e.group?(r[e.group]||(r[e.group]=[]),r[e.group].push(e)):n.push(e)}),!(Object.keys(r).length>0))return d(Ve,{children:h.map(e=>d(je,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable?d("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:ke(he,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>Se(String(e.id)),children:[e.text,d(et,{active:x===e.id,direction:x===e.id?j:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:x===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 m=[...n.map(e=>d(je,{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&&L?d("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:ke(he,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>Se(String(e.id)),children:[e.text,d(et,{active:x===e.id,direction:x===e.id?j:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:x===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,g])=>d(je,{align:"center",colSpan:g.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e},e))],W=[...Object.values(r).flat().map(e=>d(je,{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&&L?d("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:ke(he,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>Se(String(e.id)),children:[e.text,d(et,{active:x===e.id,direction:x===e.id?j:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:x===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 ke(Fe,{children:[d(Ve,{children:m}),d(Ve,{children:W})]})},[h,x,j,Se,L,k]),qe=me((r,n)=>n?d(Fe,{children:h.map(l=>d(je,{align:l.align||"left",style:{width:l.width,minWidth:l.width,...l.style,padding:"8px 16px"},children:l.render?l.render(n,r):String(n[l.id]||"")},String(l.id)))}):(console.log("rowContent - \uC544\uC774\uD15C \uC5C6\uC74C, \uC778\uB371\uC2A4:",r),null),[h]),ye=Qe(()=>({Scroller:oe,Table:r=>d(Dt,{...r,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px"}}),TableHead:Ze((r,n)=>d(Rt,{...r,ref:n,sx:{userSelect:"none","& tr":{height:k,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:r=>{let{item:n,...l}=r,m=l["data-index"]??0,W=m%2===1;return d(Ve,{...l,onMouseDown:e=>{Me.current=!1,ze.current={x:e.clientX,y:e.clientY}},onMouseMove:e=>{let g=Math.abs(e.clientX-ze.current.x),Re=Math.abs(e.clientY-ze.current.y),de=5;(g>de||Re>de)&&(Me.current=!0)},onClick:()=>{!Me.current&&!X.current&&n&&v&&v(n,m),Me.current=!1},sx:{userSelect:"none",height:D,backgroundColor:W&&S?S:"transparent","& td":{padding:"8px 16px",borderBottom:B?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":v?{backgroundColor:e=>{let g=e.palette.mode==="dark",de=a??"#000000",V=z??.06,pe=de.replace("#",""),H=parseInt(pe.substring(0,2),16)/255,f=parseInt(pe.substring(2,4),16)/255,I=parseInt(pe.substring(4,6),16)/255;if(g){let b=Math.max(H,f,I),ve=Math.min(H,f,I),fe=0,w=0,u=(b+ve)/2;if(b!==ve){let C=b-ve;switch(w=u>.5?C/(2-b-ve):C/(b+ve),b){case H:fe=((f-I)/C+(f<I?6:0))/6;break;case f:fe=((I-H)/C+2)/6;break;case I:fe=((H-f)/C+4)/6;break}}u=1-u;let Ie=(C,F,_)=>(_<0&&(_+=1),_>1&&(_-=1),_<1/6?C+(F-C)*6*_:_<1/2?F:_<2/3?C+(F-C)*(2/3-_)*6:C);if(w===0)H=f=I=u;else{let C=u<.5?u*(1+w):u+w-u*w,F=2*u-C;H=Ie(F,C,fe+1/3),f=Ie(F,C,fe),I=Ie(F,C,fe-1/3)}}return`rgba(${Math.round(H*255)}, ${Math.round(f*255)}, ${Math.round(I*255)}, ${V})`},transition:"background-color 0.2s ease"}:{}}})},TableBody:Ze((r,n)=>d(Et,{...r,ref:n}))}),[v,D,Te,S,B,k,a,z,oe]),ue=ke(he,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:r=>r.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"}},children:[d(Ot,{ref:_e,data:s,totalCount:N?s.length+1:s.length,fixedHeaderContent:Ye,itemContent:qe,rangeChanged:be,components:ye,style:{height:"100%"},increaseViewportBy:{top:100,bottom:300},overscan:5,followOutput:!1},ie),s.length===0&&!p&&d(he,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof re=="string"?ke(Fe,{children:[d(he,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),d($t,{variant:"body1",sx:{color:"text.secondary"},children:re})]}):re}),Le&&d(Fe,{children:$?d($,{visible:p,onComplete:le}):d(rt,{visible:p,onComplete:le,size:40,sx:{top:`${h.some(r=>r.group)?k*2:k}px`},background:{show:s.length===0,opacity:.8}})})]});return Z?d(It,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:Q,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:ue}):d(he,{className:"grow",style:{padding:0,paddingLeft:Q,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:ue})}var Nt=Lt(Bt);export{Nt as VirtualDataTable};
|
|
21
|
+
`,document.head.appendChild(i),()=>{let s=document.getElementById(t);s&&s.remove()}},[]),it("div",{ref:re,className:`overlay-scrollbar-wrapper ${l}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...p},children:[Ee("div",{ref:a,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:ut,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:ue?"none":"auto",...g},children:Ee("div",{ref:z,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...v},children:L})}),j&&U&&it("div",{ref:oe,className:"overlay-scrollbar-track",onMouseEnter:()=>{h(),ye.current=setTimeout(()=>{T(!0),ye.current=null},100)},onMouseLeave:()=>{pe(),E||b(u.delay)},style:{position:"absolute",top:0,right:0,width:`${Ne}px`,height:"100%",opacity:ie?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[r.visible&&Ee("div",{className:"overlay-scrollbar-track-background",onClick:t=>{t.preventDefault(),t.stopPropagation(),Z(t)},style:{position:"absolute",top:B?`${o.width+r.margin*2}px`:`${r.margin}px`,right:r.alignment==="right"?"0px":`${(Ne-o.width)/2}px`,width:`${o.width}px`,height:B?`calc(100% - ${o.width*2+r.margin*4}px)`:`calc(100% - ${r.margin*2}px)`,backgroundColor:r.color,borderRadius:`${r.radius}px`,cursor:"pointer"}}),Ee("div",{ref:ne,className:"overlay-scrollbar-thumb",onMouseDown:V,onMouseEnter:()=>Te(!0),onMouseLeave:()=>Te(!1),style:{position:"absolute",top:`${(B?e+r.margin*2:r.margin)+Oe}px`,right:r.alignment==="right"?"0px":`${(Ne-e)/2}px`,width:`${e}px`,height:`${Math.max(ce,ve)}px`,backgroundColor:ae||E?o.hoverColor:o.color,opacity:ae||E?o.hoverOpacity:o.opacity,borderRadius:`${o.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),j&&U&&B&&Ee("div",{className:"overlay-scrollbar-up-arrow",onClick:F,onMouseEnter:()=>de("up"),onMouseLeave:()=>de(null),style:{position:"absolute",top:`${r.margin}px`,right:r.alignment==="right"?"0px":`${(Ne-e)/2}px`,width:`${e}px`,height:`${e}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(e*.75,8)}px`,color:Ce==="up"?c.hoverColor:c.color,userSelect:"none",zIndex:1001,opacity:ie?Ce==="up"?c.hoverOpacity:c.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),j&&U&&B&&Ee("div",{className:"overlay-scrollbar-down-arrow",onClick:ct,onMouseEnter:()=>de("down"),onMouseLeave:()=>de(null),style:{position:"absolute",bottom:`${r.margin}px`,right:r.alignment==="right"?"0px":`${(Ne-e)/2}px`,width:`${e}px`,height:`${e}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(e*.75,8)}px`,color:Ce==="down"?c.hoverColor:c.color,userSelect:"none",zIndex:1001,opacity:ie?Ce==="down"?c.hoverOpacity:c.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),lt=kt;import{Fragment as Ge,jsx as d,jsxs as Re}from"react/jsx-runtime";var Pt={alignment:"right",margin:0,radius:0};function Bt({data:l,loading:p=!1,columns:g,onRowClick:v,rowHeight:L=50,columnHeight:C=56,striped:M,rowDivider:P=!0,onSort:k,onLoadMore:N,sortBy:x,sortDirection:j,showPaper:ee=!0,paddingX:te="1rem",paddingTop:he=0,paddingBottom:re=0,rowHoverColor:a,rowHoverOpacity:z,scrollbars:oe,emptyMessage:ne="NO DATA",LoadingComponent:I}){let ie=et(()=>Qe((o,r)=>{let c=Y(null);return d(lt,{detectInnerScroll:!0,track:Pt,...oe,children:d(Ht,{component:me,...o,ref:D=>{c.current=D,typeof r=="function"?r(D):r&&(r.current=D)},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:te,paddingTop:he,paddingBottom:re}}})})}),[]),T=et(()=>{if(M===!0)return"#f5f5f5";if(typeof M=="string")return M},[M]),[E,le]=at(p),[ae,Te]=at(0);He(()=>{p&&le(!0)},[p]);let se=fe(()=>{le(!1)},[]),Ie=E,ce=p&&l.length>0,$e=Y(!1),Oe=Y(null),q=Y(null),U=Y(!1),Pe=Y({x:0,y:0,scrollTop:0}),ue=Y(!1),Be=Y(0),K=Y(0),Se=Y(!1),qe=Y({x:0,y:0}),st=Y(null),Ce=fe(o=>{},[]),de=fe(o=>{if(!ue.current||!q.current)return;let r=o.clientY-Pe.current.y;if(!U.current&&Math.abs(r)>5&&(U.current=!0,q.current&&(q.current.style.userSelect="none")),U.current){let D=r*2;K.current+=-D;let u=q.current,e=Math.max(0,Be.current+K.current);u.scrollTop=e,Pe.current.y=o.clientY,o.preventDefault()}},[]),We=fe(()=>{if(ue.current=!1,U.current&&q.current){let o=Math.max(0,Be.current+K.current),r=()=>{q.current&&(q.current.scrollTop=o)};r(),setTimeout(r,1),setTimeout(r,5),setTimeout(r,10)}U.current=!1,K.current=0,q.current&&(q.current.style.userSelect="auto")},[]);He(()=>{let o=document.querySelector('[data-testid="virtuoso-scroller"]');o&&o.querySelectorAll(".MuiTableSortLabel-root").forEach(c=>{let D=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});c.dispatchEvent(D)})},[x]);let ke=fe(o=>{if(!k)return;k(o,x===o&&j==="asc"?"desc":"asc")},[k,x,j]),ge=fe(o=>{if(!N||p&&l.length===0)return;let r=Date.now(),c=window.lastRangeChangeTime||0;if(r-c<100)return;window.lastRangeChangeTime=r;let D=Math.max(10,Math.floor(l.length*.1)),u=o.endIndex>=l.length-D,e=l.length>=30;if(u&&e&&N&&!$e.current){$e.current=!0;let J=l.length;N(J,50)}},[l.length,p,N]);He(()=>{p||($e.current=!1)},[p]),He(()=>{l.length===0&&Te(o=>o+1)},[l.length]);let Le=Y(l.length);He(()=>{let o=Le.current,r=l.length;if(r>o&&o>0){Le.current=r;return}Oe.current&&r>0&&r<=o&&Oe.current.scrollToIndex({index:0,align:"start",behavior:"auto"}),Le.current=r},[l]),He(()=>(document.addEventListener("mousemove",de),document.addEventListener("mouseup",We),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",We)}),[de,We]);let Ve=fe(()=>{let o={},r=[];if(g.forEach(e=>{e.group?(o[e.group]||(o[e.group]=[]),o[e.group].push(e)):r.push(e)}),!(Object.keys(o).length>0))return d(_e,{children:g.map(e=>d(Ye,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable?d("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:Re(me,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(e.id)),children:[e.text,d(tt,{active:x===e.id,direction:x===e.id?j:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:x===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 D=[...r.map(e=>d(Ye,{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&&k?d("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:Re(me,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(e.id)),children:[e.text,d(tt,{active:x===e.id,direction:x===e.id?j:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:x===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,J])=>d(Ye,{align:"center",colSpan:J.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e},e))],u=[...Object.values(o).flat().map(e=>d(Ye,{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&&k?d("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:Re(me,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>ke(String(e.id)),children:[e.text,d(tt,{active:x===e.id,direction:x===e.id?j:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:x===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(0deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(180deg)"}}})]})}):e.text},String(e.id)))];return Re(Ge,{children:[d(_e,{children:D}),d(_e,{children:u})]})},[g,x,j,ke,k,C]),be=fe((o,r)=>r?d(Ge,{children:g.map(c=>d(Ye,{align:c.align||"left",style:{width:c.width,minWidth:c.width,...c.style,padding:"8px 16px"},children:c.render?c.render(r,o):String(r[c.id]||"")},String(c.id)))}):(console.log("rowContent - \uC544\uC774\uD15C \uC5C6\uC74C, \uC778\uB371\uC2A4:",o),null),[g]),ye=et(()=>({Scroller:ie,Table:o=>d(Dt,{...o,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px"}}),TableHead:Qe((o,r)=>d(Rt,{...o,ref:r,sx:{userSelect:"none","& tr":{height:C,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:o=>{let{item:r,...c}=o,D=c["data-index"]??0,u=D%2===1;return d(_e,{...c,onMouseDown:e=>{Se.current=!1,qe.current={x:e.clientX,y:e.clientY}},onMouseMove:e=>{let J=Math.abs(e.clientX-qe.current.x),ve=Math.abs(e.clientY-qe.current.y),B=5;(J>B||ve>B)&&(Se.current=!0)},onClick:()=>{!Se.current&&!U.current&&r&&v&&v(r,D),Se.current=!1},sx:{userSelect:"none",height:L,backgroundColor:u&&T?T:"transparent","& td":{padding:"8px 16px",borderBottom:P?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":v?{backgroundColor:e=>{let J=e.palette.mode==="dark",B=a??"#000000",De=z??.06,W=B.replace("#",""),f=parseInt(W.substring(0,2),16)/255,R=parseInt(W.substring(2,4),16)/255,h=parseInt(W.substring(4,6),16)/255;if(J){let pe=Math.max(f,R,h),xe=Math.min(f,R,h),b=0,m=0,V=(pe+xe)/2;if(pe!==xe){let S=pe-xe;switch(m=V>.5?S/(2-pe-xe):S/(pe+xe),pe){case f:b=((R-h)/S+(R<h?6:0))/6;break;case R:b=((h-f)/S+2)/6;break;case h:b=((f-R)/S+4)/6;break}}V=1-V;let we=(S,Z,F)=>(F<0&&(F+=1),F>1&&(F-=1),F<1/6?S+(Z-S)*6*F:F<1/2?Z:F<2/3?S+(Z-S)*(2/3-F)*6:S);if(m===0)f=R=h=V;else{let S=V<.5?V*(1+m):V+m-V*m,Z=2*V-S;f=we(Z,S,b+1/3),R=we(Z,S,b),h=we(Z,S,b-1/3)}}return`rgba(${Math.round(f*255)}, ${Math.round(R*255)}, ${Math.round(h*255)}, ${De})`},transition:"background-color 0.2s ease"}:{}}})},TableBody:Qe((o,r)=>d(Et,{...o,ref:r}))}),[v,L,Ce,T,P,C,a,z,ie]),X=Re(me,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:o=>o.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"}},children:[d(Ot,{ref:Oe,data:l,totalCount:N?l.length+1:l.length,fixedHeaderContent:Ve,itemContent:be,rangeChanged:ge,components:ye,style:{height:"100%"},increaseViewportBy:{top:100,bottom:300},overscan:5,followOutput:!1},ae),l.length===0&&!p&&d(me,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof ne=="string"?Re(Ge,{children:[d(me,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),d($t,{variant:"body1",sx:{color:"text.secondary"},children:ne})]}):ne}),Ie&&d(Ge,{children:I?d(I,{visible:p,onComplete:se}):d(ot,{visible:p,onComplete:se,size:40,sx:{top:`${g.some(o=>o.group)?C*2:C}px`},background:{show:l.length===0,opacity:.8}})})]});return ee?d(It,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:te,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:X}):d(me,{className:"grow",style:{padding:0,paddingLeft:te,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:X})}var Nt=Lt(Bt);export{Nt as VirtualDataTable};
|
|
22
22
|
/**
|
|
23
23
|
* Virtual Data Table - A high-performance virtual data table component for React
|
|
24
24
|
*
|