@ehfuse/overlay-scrollbar 1.6.12 → 1.6.14
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/OverlayScrollbar.d.ts.map +1 -1
- package/dist/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/utils/dragScrollUtils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var De=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var xt=(v,y)=>{for(var E in y)De(v,E,{get:y[E],enumerable:!0})},wt=(v,y,E,C)=>{if(y&&typeof y=="object"||typeof y=="function")for(let T of vt(y))!yt.call(v,T)&&T!==E&&De(v,T,{get:()=>y[T],enumerable:!(C=gt(y,T))||C.enumerable});return v};var Tt=v=>wt(De({},"__esModule",{value:!0}),v);var Rt={};xt(Rt,{OverlayScrollbar:()=>ke,default:()=>ke});module.exports=Tt(Rt);var t=require("react");var Mt=["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"],Le=(v,y)=>{let E=v.tagName.toLowerCase(),C=["text","password","email","number","search","tel","url","checkbox","radio"];if(E==="input"){let T=v.type;return C.includes(T)}if(["textarea","select","button"].includes(E)||["svg","path","circle","rect","line","polygon","polyline"].includes(E)||v.getAttribute("contenteditable")==="true")return!0;if(y?.excludeSelectors){for(let T of y.excludeSelectors)if(v.matches(T))return!0}return St(v,y)},St=(v,y)=>{let E=[...Mt,...y?.excludeClasses||[]],C=v,T=0,z=5;for(;C&&T<=z;){if(E.some(H=>C.classList.contains(H)))return!0;if(C.classList.contains("MuiDialogContent-root"))break;C=C.parentElement,T++}return!1};var S=require("react/jsx-runtime"),Et={},Ct={},Ht={},Dt={},Lt={},kt=(0,t.forwardRef)(({className:v="",style:y={},containerStyle:E={},contentStyle:C={},children:T,onScroll:z,thumb:H=Et,track:k=Ct,arrows:N=Ht,dragScroll:J=Dt,autoHide:_=Lt,showScrollbar:K=!0,detectInnerScroll:qe=!1},Xe)=>{let Ye=(0,t.useRef)({});(0,t.useEffect)(()=>{Ye.current={children:T,onScroll:z,showScrollbar:K,thumb:H,track:k,arrows:N,dragScroll:J,autoHide:_}});let se=(0,t.useRef)(null),c=(0,t.useRef)(null),B=(0,t.useRef)(null),X=(0,t.useRef)(null),Ge=(0,t.useRef)(null),I=(0,t.useRef)(null),[ee,x]=(0,t.useState)(!1),[A,Re]=(0,t.useState)(!1),[Ie,Ae]=(0,t.useState)(!1),[ue,Je]=(0,t.useState)({y:0,scrollTop:0}),[Z,Ke]=(0,t.useState)(0),[Ze,Oe]=(0,t.useState)(0),[Y,We]=(0,t.useState)(!1),[$e,ze]=(0,t.useState)(!1),[O,Ne]=(0,t.useState)(!1),[de,je]=(0,t.useState)({x:0,scrollLeft:0}),[pe,Ve]=(0,t.useState)(0),[me,Qe]=(0,t.useState)(0),[et,he]=(0,t.useState)(!1),[P,fe]=(0,t.useState)(!1),[W,Pe]=(0,t.useState)(!1),[j,tt]=(0,t.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[It,At]=(0,t.useState)(null),[te,oe]=(0,t.useState)(null),[Ot,ot]=(0,t.useState)(!1),[rt,nt]=(0,t.useState)(0),V=(0,t.useRef)(null),[Fe,_e]=(0,t.useState)(!1),Q=(0,t.useRef)(null),U=(0,t.useRef)(null),q=(0,t.useRef)(null),b=(0,t.useMemo)(()=>{let e=H.color??"#606060";return{width:H.width??8,minHeight:H.minHeight??50,radius:H.radius??(H.width??8)/2,color:e,opacity:H.opacity??.6,hoverColor:H.hoverColor??e,hoverOpacity:H.hoverOpacity??1}},[H]),n=(0,t.useMemo)(()=>({width:k.width??16,color:k.color??"rgba(128, 128, 128, 0.1)",visible:k.visible??!0,alignment:k.alignment??"default",radius:k.radius??b.radius??4,margin:k.margin??4,overflowX:k.overflowX??!0,overflowY:k.overflowY??!0}),[k,b.radius]),R=(0,t.useMemo)(()=>{let e=N.color??"#808080";return{visible:N.visible??!1,step:N.step??50,color:e,opacity:N.opacity??.6,hoverColor:N.hoverColor??e,hoverOpacity:N.hoverOpacity??1}},[N]),be=(0,t.useMemo)(()=>({enabled:J.enabled??!0,excludeClasses:J.excludeClasses??[],excludeSelectors:J.excludeSelectors??[]}),[J]),i=(0,t.useMemo)(()=>({enabled:_.enabled??!0,delay:_.delay??1500,delayOnWheel:_.delayOnWheel??700,initialDelay:_.initialDelay??200}),[_]),[G,lt]=(0,t.useState)(()=>(_.initialDelay??200)>0),h=b.width,it=n.width,ge=b.minHeight,$=R.visible,re=R.step,D=(0,t.useCallback)(()=>{if(!c.current)return;let e=document.activeElement;e&&c.current.contains(e)&&e!==c.current||c.current.focus()},[]);(0,t.useImperativeHandle)(Xe,()=>({getScrollContainer:()=>c.current,scrollTo:e=>{c.current&&c.current.scrollTo(e)},get scrollTop(){return c.current?.scrollTop||0},get scrollHeight(){return c.current?.scrollHeight||0},get clientHeight(){return c.current?.clientHeight||0}}),[]);let d=(0,t.useCallback)(()=>{if(I.current){let o=I.current;if(document.contains(o)&&o.scrollHeight>o.clientHeight+2)return o;I.current=null}if(!c.current)return null;if(B.current&&B.current.scrollHeight>c.current.clientHeight+2)return I.current=c.current,c.current;if(!qe)return null;let e=c.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let o of e){let r=o;if(r!==c.current&&r.classList.contains("overlay-scrollbar-container"))continue;let s=r.parentElement,l=!1;for(;s&&s!==c.current;){if(s.classList.contains("overlay-scrollbar-container")&&s!==c.current){l=!0;break}s=s.parentElement}if(!l&&r.scrollHeight>r.clientHeight+2)return I.current=r,r}return null},[]),F=(0,t.useCallback)(()=>d()!==null,[d]),f=(0,t.useCallback)(()=>{Q.current&&(clearTimeout(Q.current),Q.current=null)},[]),ne=(0,t.useCallback)(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),Be=(0,t.useCallback)(()=>{q.current&&(clearTimeout(q.current),q.current=null)},[]),at=(0,t.useCallback)(()=>{ne(),!(A||O||W||P)&&(f(),x(!1))},[f,ne,A,O,W,P]),m=(0,t.useCallback)(e=>{i.enabled&&(f(),Q.current=setTimeout(()=>{x(!1),Q.current=null},e))},[f,i.enabled]),u=(0,t.useCallback)(()=>{let e=d();if(!e){x(!1),We(!1),he(!1),f();return}if(We(!0),!X.current)return;!i.enabled&&!G&&(x(!0),f());let o=e.clientHeight,r=e.scrollHeight,s=e.scrollTop,l=e.clientWidth,a=e.scrollWidth,w=e.scrollLeft,g=0,p=0;if(se.current){let ae=window.getComputedStyle(se.current),ce=parseFloat(ae.paddingTop)||0;p=parseFloat(ae.paddingBottom)||0,g=ce+p,nt(p)}let le=$?h*2+n.margin*4:n.margin*2,L=o-le+g,Se=o/r,ie=Math.max(L*Se,ge),Ee=r-o,Ue=L-ie,Ce=Ee>0?s/Ee*Ue:0;Ke(ie),Oe(Ce);let He=a-l;if(He>0){he(!0);let ae=l/a,ce=Math.max(l*ae,50),ft=l-ce,bt=He>0?w/He*ft:0;Ve(ce),Qe(bt)}else he(!1)},[d,f,$,h,ge,i.enabled,G]),ct=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(Re(!0),Je({y:e.clientY,scrollTop:o.scrollTop}),f(),x(!0),D())},[d,f,D]),ve=(0,t.useCallback)(e=>{if(!A)return;let o=d();if(!o)return;let r=o.clientHeight,l=o.scrollHeight-r,a=e.clientY-ue.y,w=r-Z,g=a/w*l,p=Math.max(0,Math.min(l,ue.scrollTop+g));o.scrollTop=p,u()},[A,ue,Z,u,d]),ye=(0,t.useCallback)(()=>{Re(!1),F()&&m(i.delay)},[F,m,i.delay]),st=(0,t.useCallback)(e=>{if(!X.current)return;let r=X.current.getBoundingClientRect(),s=e.clientY-r.top,l=d();if(!l)return;let a=l.clientHeight,w=l.scrollHeight,p=s/a*(w-a);l.scrollTop=Math.max(0,Math.min(w-a,p)),u(),x(!0),m(i.delay),D()},[u,m,i.delay,d,D]),ut=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!c.current)return;let o=Math.max(0,c.current.scrollTop-re);c.current.scrollTop=o,u(),x(!0),m(i.delay),D()},[u,m,re,i.delay,D]),dt=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!c.current||!B.current)return;let o=c.current,s=B.current.scrollHeight-o.clientHeight,l=Math.min(s,o.scrollTop+re);o.scrollTop=l,u(),x(!0),m(i.delay),D()},[u,m,re,i.delay,D]),pt=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(Ne(!0),je({x:e.clientX,scrollLeft:o.scrollLeft}),f(),x(!0),D())},[d,f,D]),xe=(0,t.useCallback)(e=>{if(!O)return;let o=d();if(!o)return;let r=o.clientWidth,l=o.scrollWidth-r,a=e.clientX-de.x,w=r-pe,g=a/w*l,p=Math.max(0,Math.min(l,de.scrollLeft+g));o.scrollLeft=p,u()},[O,de,pe,u,d]),we=(0,t.useCallback)(()=>{Ne(!1),F()&&m(i.delay)},[F,m,i.delay]),mt=(0,t.useCallback)(e=>{if(!X.current)return;let r=X.current.getBoundingClientRect(),s=e.clientX-r.left,l=d();if(!l)return;let a=l.clientWidth,w=l.scrollWidth,p=s/a*(w-a);l.scrollLeft=Math.max(0,Math.min(w-a,p)),u(),x(!0),m(i.delay),D()},[u,m,i.delay,d,D]),ht=(0,t.useCallback)(e=>{if(!be.enabled)return;let o=e.target;if(Le(o,be)||e.button!==0)return;let r=d();r&&(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth||(e.preventDefault(),fe(!0),tt({x:e.clientX,y:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft||0}),f()))},[be,Le,d,f]),Te=(0,t.useCallback)(e=>{if(!P&&!W)return;let o=d();if(!o)return;let r=j.x-e.clientX,s=j.y-e.clientY;if(Math.abs(s)<5&&Math.abs(r)<5)return;P&&(fe(!1),Pe(!0)),x(!0);let l=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,j.scrollTop+s)),a=Math.max(0,Math.min(o.scrollWidth-o.clientWidth,j.scrollLeft+r));o.scrollTop=l,o.scrollLeft=a,u()},[P,W,j,d,u]),Me=(0,t.useCallback)(()=>{let e=W;fe(!1),Pe(!1),e&&F()&&m(i.delay)},[W,F,m,i.delay]);(0,t.useEffect)(()=>{let e=a=>{if(u(),G){z&&z(a);return}f(),x(!0),Be();let w=Fe?i.delayOnWheel:i.delay;m(w),z&&z(a)},o=()=>{_e(!0),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{_e(!1)},300),Be(),q.current=setTimeout(()=>{x(!0),q.current=null,m(i.delayOnWheel)},50)},r=[],s=d();s&&r.push(s);let l=c.current;return l&&!s&&(r.push(l),l.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(w=>{let g=w;if(g!==l&&g.classList.contains("overlay-scrollbar-container"))return;let p=g.parentElement;for(;p&&p!==l;){if(p.classList.contains("overlay-scrollbar-container")&&p!==l)return;p=p.parentElement}r.push(g)})),r.forEach(a=>{a.addEventListener("scroll",e,{passive:!0}),a.addEventListener("wheel",o,{passive:!0})}),()=>{r.forEach(a=>{a.removeEventListener("scroll",e),a.removeEventListener("wheel",o)}),V.current&&clearTimeout(V.current),q.current&&clearTimeout(q.current)}},[d,u,z,f,m,i,Fe,G]),(0,t.useEffect)(()=>{let e=r=>{let s=d();if(!s)return;let{key:l}=r,{scrollTop:a,scrollHeight:w,clientHeight:g}=s,p=w-g,le=50,L=null;switch(l){case"ArrowUp":r.preventDefault(),L=Math.max(0,a-le);break;case"ArrowDown":r.preventDefault(),L=Math.min(p,a+le);break;case"PageUp":r.preventDefault(),L=Math.max(0,a-g);break;case"PageDown":r.preventDefault(),L=Math.min(p,a+g);break;case"Home":r.preventDefault(),L=0;break;case"End":r.preventDefault(),L=p;break;default:return}if(L!==null){let Se=L/p,ie=$?h*2+n.margin*4:n.margin*2,Ce=(g-ie-Z)*Se;Oe(Ce),s.scrollTop=L,f(),x(!0),m(i.delay)}},o=c.current;if(o)return o.addEventListener("keydown",e),()=>{o.removeEventListener("keydown",e)}},[d,$,h,n.margin,Z,f,m,i.delay]),(0,t.useEffect)(()=>{if(P||W)return document.addEventListener("mousemove",Te),document.addEventListener("mouseup",Me),()=>{document.removeEventListener("mousemove",Te),document.removeEventListener("mouseup",Me)}},[P,W,Te,Me]),(0,t.useEffect)(()=>{if(A)return document.addEventListener("mousemove",ve),document.addEventListener("mouseup",ye),()=>{document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",ye)}},[A,ve,ye]),(0,t.useEffect)(()=>{if(O)return document.addEventListener("mousemove",xe),document.addEventListener("mouseup",we),()=>{document.removeEventListener("mousemove",xe),document.removeEventListener("mouseup",we)}},[O,xe,we]),(0,t.useEffect)(()=>{u();let e=setTimeout(()=>{u()},100);return()=>clearTimeout(e)},[u]),(0,t.useLayoutEffect)(()=>{ot(!0),u(),!i.enabled&&!G&&F()&&x(!0)},[F,u,i.enabled,G]),(0,t.useEffect)(()=>{if(i.initialDelay>0){let e=setTimeout(()=>{lt(!1)},i.initialDelay);return()=>clearTimeout(e)}},[i.initialDelay]),(0,t.useEffect)(()=>{let e=new ResizeObserver(()=>{u()}),o=[];return c.current&&o.push(c.current),B.current&&o.push(B.current),I.current&&document.contains(I.current)&&o.push(I.current),o.forEach(r=>{e.observe(r)}),()=>e.disconnect()},[u]),(0,t.useEffect)(()=>{if(!c.current)return;let e=new MutationObserver(()=>{I.current=null,u()});return e.observe(c.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>e.disconnect()},[u]);let M=Math.max(it,h);return(0,t.useEffect)(()=>{let e="overlay-scrollbar-webkit-hide",o=document.getElementById(e);o&&o.remove();let r=document.createElement("style");return r.id=e,r.textContent=`
|
|
1
|
+
"use strict";var He=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var vt=Object.prototype.hasOwnProperty;var yt=(h,y)=>{for(var E in y)He(h,E,{get:y[E],enumerable:!0})},xt=(h,y,E,T)=>{if(y&&typeof y=="object"||typeof y=="function")for(let C of gt(y))!vt.call(h,C)&&C!==E&&He(h,C,{get:()=>y[C],enumerable:!(T=bt(y,C))||T.enumerable});return h};var wt=h=>xt(He({},"__esModule",{value:!0}),h);var kt={};yt(kt,{OverlayScrollbar:()=>Le,default:()=>Le});module.exports=wt(kt);var t=require("react");var Tt=["editor","textarea","input","select","textfield","form-control","contenteditable","MuiInputBase-input","MuiSelect-select","MuiOutlinedInput-input","MuiFilledInput-input","MuiInput-input","MuiFormControl-root","MuiTextField-root","MuiSelect-root","MuiOutlinedInput-root","MuiFilledInput-root","MuiInput-root","MuiAutocomplete-input","MuiDatePicker-input","MuiSlider-thumb","MuiSlider-rail","MuiSlider-track","MuiSlider-mark","MuiSlider-markLabel","MuiSlider-root","MuiSlider-colorPrimary","MuiSlider-sizeMedium","MuiIconButton-root","MuiButton-root","MuiButtonBase-root","MuiTouchRipple-root","MuiCheckbox-root","MuiRadio-root","MuiSwitch-root","PrivateSwitchBase-root","ant-input","ant-input-affix-wrapper","ant-input-group-addon","ant-input-number","ant-input-number-handler","ant-select","ant-select-selector","ant-select-selection-search","ant-select-dropdown","ant-cascader","ant-cascader-input","ant-picker","ant-picker-input","ant-time-picker","ant-calendar-picker","ant-slider","ant-slider-track","ant-slider-handle","ant-switch","ant-checkbox","ant-checkbox-wrapper","ant-radio","ant-radio-wrapper","ant-rate","ant-upload","ant-upload-drag","ant-form-item","ant-form-item-control","ant-btn","ant-dropdown","ant-dropdown-trigger","ant-menu","ant-menu-item","ant-tooltip","ant-popover","ant-modal","ant-drawer","ant-tree-select","ant-auto-complete","ant-mentions","ant-transfer","ui-input","ui-textarea","ui-select","ui-select-trigger","ui-select-content","ui-select-item","ui-button","ui-checkbox","ui-radio-group","ui-switch","ui-slider","ui-range-slider","ui-calendar","ui-date-picker","ui-combobox","ui-command","ui-command-input","ui-popover","ui-dialog","ui-sheet","ui-dropdown-menu","ui-context-menu","ui-menubar","ui-navigation-menu","ui-form","ui-form-control","ui-form-item","ui-form-field","ui-label","radix-ui","radix-select","radix-dropdown","radix-dialog","radix-popover","radix-accordion","radix-tabs","radix-slider","radix-switch","radix-checkbox","radix-radio","ql-editor","ql-container","ql-toolbar","ql-picker","ql-picker-label","ql-picker-options","ql-formats","ql-snow","ql-bubble","quill","quilleditor","monaco-editor","monaco-editor-background","view-lines","decorationsOverviewRuler","monaco-scrollable-element","CodeMirror","CodeMirror-code","CodeMirror-lines","CodeMirror-scroll","CodeMirror-sizer","cm-editor","cm-focused","cm-content","tox-editor-container","tox-editor-header","tox-edit-area","tox-tinymce","mce-content-body","ck-editor","ck-content","ck-toolbar","ck-editor__editable","ck-widget","slate-editor","slate-content","DraftEditor-root","DraftEditor-editorContainer","public-DraftEditor-content","ehfuse-editor","ehfuse-editor-wrapper","ehfuse-editor-content","ehfuse-toolbar","ehfuse-toolbar-group","ehfuse-cursor","text-editor","rich-text-editor","wysiwyg","ace_editor","ace_content"],me=(h,y)=>{if(h instanceof HTMLElement&&h.isContentEditable||h.closest('[role="textbox"],[role="searchbox"]'))return!0;let E=h.tagName.toLowerCase();if(E==="input"){let T=(h.type||"text").toLowerCase();return!["button","submit","reset","image","hidden"].includes(T)}if(["textarea","select","button"].includes(E)||["svg","path","circle","rect","line","polygon","polyline"].includes(E)||h.getAttribute("contenteditable")==="true")return!0;if(y?.excludeSelectors){for(let T of y.excludeSelectors)if(h.matches(T))return!0}return Mt(h,y)},Mt=(h,y)=>{let E=[...Tt,...y?.excludeClasses||[]],T=h,C=0,$=5;for(;T&&C<=$;){if(E.some(H=>T.classList.contains(H)))return!0;if(T.classList.contains("MuiDialogContent-root"))break;T=T.parentElement,C++}return!1};var S=require("react/jsx-runtime"),St={},Et={},Ct={},Ht={},Lt={},Dt=(0,t.forwardRef)(({className:h="",style:y={},containerStyle:E={},contentStyle:T={},children:C,onScroll:$,thumb:H=St,track:k=Et,arrows:z=Ct,dragScroll:Z=Ht,autoHide:F=Lt,showScrollbar:j=!0,detectInnerScroll:Ue=!1},qe)=>{let Xe=(0,t.useRef)({});(0,t.useEffect)(()=>{Xe.current={children:C,onScroll:$,showScrollbar:j,thumb:H,track:k,arrows:z,dragScroll:Z,autoHide:F}});let he=(0,t.useRef)(null),a=(0,t.useRef)(null),B=(0,t.useRef)(null),q=(0,t.useRef)(null),Ye=(0,t.useRef)(null),I=(0,t.useRef)(null),[ne,x]=(0,t.useState)(!1),[W,De]=(0,t.useState)(!1),[ke,Re]=(0,t.useState)(!1),[fe,Ge]=(0,t.useState)({y:0,scrollTop:0}),[V,Ke]=(0,t.useState)(0),[Ze,Ie]=(0,t.useState)(0),[X,We]=(0,t.useState)(!1),[Ae,Oe]=(0,t.useState)(!1),[A,$e]=(0,t.useState)(!1),[be,je]=(0,t.useState)({x:0,scrollLeft:0}),[ge,Ve]=(0,t.useState)(0),[ve,Je]=(0,t.useState)(0),[Qe,ye]=(0,t.useState)(!1),Y=(0,t.useRef)(!1),[P,ze]=(0,t.useState)(!1),[J,et]=(0,t.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[Rt,It]=(0,t.useState)(null),[le,ie]=(0,t.useState)(null),[Wt,tt]=(0,t.useState)(!1),[ot,rt]=(0,t.useState)(0),Q=(0,t.useRef)(null),[Pe,Ne]=(0,t.useState)(!1),ee=(0,t.useRef)(null),_=(0,t.useRef)(null),U=(0,t.useRef)(null),v=(0,t.useMemo)(()=>{let e=H.color??"#606060";return{width:H.width??8,minHeight:H.minHeight??50,radius:H.radius??(H.width??8)/2,color:e,opacity:H.opacity??.6,hoverColor:H.hoverColor??e,hoverOpacity:H.hoverOpacity??1}},[H]),n=(0,t.useMemo)(()=>({width:k.width??16,color:k.color??"rgba(128, 128, 128, 0.1)",visible:k.visible??!0,alignment:k.alignment??"default",radius:k.radius??v.radius??4,margin:k.margin??4,overflowX:k.overflowX??!0,overflowY:k.overflowY??!0}),[k,v.radius]),R=(0,t.useMemo)(()=>{let e=z.color??"#808080";return{visible:z.visible??!1,step:z.step??50,color:e,opacity:z.opacity??.6,hoverColor:z.hoverColor??e,hoverOpacity:z.hoverOpacity??1}},[z]),te=(0,t.useMemo)(()=>({enabled:Z.enabled??!0,excludeClasses:Z.excludeClasses??[],excludeSelectors:Z.excludeSelectors??[]}),[Z]),i=(0,t.useMemo)(()=>({enabled:F.enabled??!0,delay:F.delay??1500,delayOnWheel:F.delayOnWheel??700,initialDelay:F.initialDelay??200}),[F]),[G,nt]=(0,t.useState)(()=>(F.initialDelay??200)>0),f=v.width,lt=n.width,xe=v.minHeight,O=R.visible,ae=R.step,L=(0,t.useCallback)(()=>{if(!a.current)return;let e=document.activeElement;e&&a.current.contains(e)&&e!==a.current||a.current.focus()},[]);(0,t.useImperativeHandle)(qe,()=>({getScrollContainer:()=>a.current,scrollTo:e=>{a.current&&a.current.scrollTo(e)},get scrollTop(){return a.current?.scrollTop||0},get scrollHeight(){return a.current?.scrollHeight||0},get clientHeight(){return a.current?.clientHeight||0}}),[]);let d=(0,t.useCallback)(()=>{if(I.current){let o=I.current;if(document.contains(o)&&o.scrollHeight>o.clientHeight+2)return o;I.current=null}if(!a.current)return null;if(B.current&&B.current.scrollHeight>a.current.clientHeight+2)return I.current=a.current,a.current;if(!Ue)return null;let e=a.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let o of e){let r=o;if(r!==a.current&&r.classList.contains("overlay-scrollbar-container"))continue;let c=r.parentElement,l=!1;for(;c&&c!==a.current;){if(c.classList.contains("overlay-scrollbar-container")&&c!==a.current){l=!0;break}c=c.parentElement}if(!l&&r.scrollHeight>r.clientHeight+2)return I.current=r,r}return null},[]),N=(0,t.useCallback)(()=>d()!==null,[d]),g=(0,t.useCallback)(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),ce=(0,t.useCallback)(()=>{_.current&&(clearTimeout(_.current),_.current=null)},[]),Fe=(0,t.useCallback)(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),it=(0,t.useCallback)(()=>{ce(),!(W||A||P||Y.current)&&(g(),x(!1))},[g,ce,W,A,P]),m=(0,t.useCallback)(e=>{i.enabled&&(g(),ee.current=setTimeout(()=>{x(!1),ee.current=null},e))},[g,i.enabled]),u=(0,t.useCallback)(()=>{let e=d();if(!e){x(!1),We(!1),ye(!1),g();return}if(We(!0),!q.current)return;!i.enabled&&!G&&(x(!0),g());let o=e.clientHeight,r=e.scrollHeight,c=e.scrollTop,l=e.clientWidth,s=e.scrollWidth,b=e.scrollLeft,w=0,p=0;if(he.current){let de=window.getComputedStyle(he.current),pe=parseFloat(de.paddingTop)||0;p=parseFloat(de.paddingBottom)||0,w=pe+p,rt(p)}let K=O?f*2+n.margin*4:n.margin*2,oe=o-K+w,D=o/r,se=Math.max(oe*D,xe),ue=r-o,Be=oe-se,_e=ue>0?c/ue*Be:0;Ke(se),Ie(_e);let re=s-l;if(re>0){ye(!0);let de=l/s,pe=Math.max(l*de,50),ht=l-pe,ft=re>0?b/re*ht:0;Ve(pe),Je(ft)}else ye(!1)},[d,g,O,f,xe,i.enabled,G]),at=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(De(!0),Ge({y:e.clientY,scrollTop:o.scrollTop}),g(),x(!0),L())},[d,g,L]),we=(0,t.useCallback)(e=>{if(!W)return;let o=d();if(!o)return;let r=o.clientHeight,l=o.scrollHeight-r,s=e.clientY-fe.y,b=r-V,w=s/b*l,p=Math.max(0,Math.min(l,fe.scrollTop+w));o.scrollTop=p,u()},[W,fe,V,u,d]),Te=(0,t.useCallback)(()=>{De(!1),N()&&m(i.delay)},[N,m,i.delay]),ct=(0,t.useCallback)(e=>{if(!q.current)return;let r=q.current.getBoundingClientRect(),c=e.clientY-r.top,l=d();if(!l)return;let s=l.clientHeight,b=l.scrollHeight,p=c/s*(b-s);l.scrollTop=Math.max(0,Math.min(b-s,p)),u(),x(!0),m(i.delay),L()},[u,m,i.delay,d,L]),st=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!a.current)return;let o=Math.max(0,a.current.scrollTop-ae);a.current.scrollTop=o,u(),x(!0),m(i.delay),L()},[u,m,ae,i.delay,L]),ut=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!a.current||!B.current)return;let o=a.current,c=B.current.scrollHeight-o.clientHeight,l=Math.min(c,o.scrollTop+ae);o.scrollTop=l,u(),x(!0),m(i.delay),L()},[u,m,ae,i.delay,L]),dt=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&($e(!0),je({x:e.clientX,scrollLeft:o.scrollLeft}),g(),x(!0),L())},[d,g,L]),Me=(0,t.useCallback)(e=>{if(!A)return;let o=d();if(!o)return;let r=o.clientWidth,l=o.scrollWidth-r,s=e.clientX-be.x,b=r-ge,w=s/b*l,p=Math.max(0,Math.min(l,be.scrollLeft+w));o.scrollLeft=p,u()},[A,be,ge,u,d]),Se=(0,t.useCallback)(()=>{$e(!1),N()&&m(i.delay)},[N,m,i.delay]),pt=(0,t.useCallback)(e=>{if(!q.current)return;let r=q.current.getBoundingClientRect(),c=e.clientX-r.left,l=d();if(!l)return;let s=l.clientWidth,b=l.scrollWidth,p=c/s*(b-s);l.scrollLeft=Math.max(0,Math.min(b-s,p)),u(),x(!0),m(i.delay),L()},[u,m,i.delay,d,L]),mt=(0,t.useCallback)(e=>{if(!te.enabled)return;let o=e.target;if(me(o,te)||e.button!==0)return;let r=d();r&&(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth||(e.preventDefault(),Y.current=!0,et({x:e.clientX,y:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft||0}),g()))},[te,me,d,g]),Ee=(0,t.useCallback)(e=>{if(!Y.current&&!P)return;let o=d();if(!o)return;let r=J.x-e.clientX,c=J.y-e.clientY;if(Math.abs(c)<5&&Math.abs(r)<5)return;Y.current&&(Y.current=!1,ze(!0)),x(!0);let l=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,J.scrollTop+c)),s=Math.max(0,Math.min(o.scrollWidth-o.clientWidth,J.scrollLeft+r));o.scrollTop=l,o.scrollLeft=s,u()},[P,J,d,u]),Ce=(0,t.useCallback)(()=>{let e=P;Y.current=!1,ze(!1),e&&N()&&m(i.delay)},[P,N,m,i.delay]);(0,t.useEffect)(()=>{let e=s=>{if(u(),G){$&&$(s);return}g(),x(!0),Fe();let b=Pe?i.delayOnWheel:i.delay;m(b),$&&$(s)},o=()=>{Ne(!0),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{Ne(!1)},300),Fe(),U.current=setTimeout(()=>{x(!0),U.current=null,m(i.delayOnWheel)},50)},r=[],c=d();c&&r.push(c);let l=a.current;return l&&!c&&(r.push(l),l.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(b=>{let w=b;if(w!==l&&w.classList.contains("overlay-scrollbar-container"))return;let p=w.parentElement;for(;p&&p!==l;){if(p.classList.contains("overlay-scrollbar-container")&&p!==l)return;p=p.parentElement}r.push(w)})),r.forEach(s=>{s.addEventListener("scroll",e,{passive:!0}),s.addEventListener("wheel",o,{passive:!0})}),()=>{r.forEach(s=>{s.removeEventListener("scroll",e),s.removeEventListener("wheel",o)}),Q.current&&clearTimeout(Q.current),U.current&&clearTimeout(U.current)}},[d,u,$,g,m,i,Pe,G]),(0,t.useEffect)(()=>{let e=r=>{let c=r.target;if(r.defaultPrevented||c instanceof Element&&me(c,te))return;let l=d();if(!l)return;let{key:s}=r,{scrollTop:b,scrollHeight:w,clientHeight:p}=l,K=w-p,oe=50,D=null;switch(s){case"ArrowUp":r.preventDefault(),D=Math.max(0,b-oe);break;case"ArrowDown":r.preventDefault(),D=Math.min(K,b+oe);break;case"PageUp":r.preventDefault(),D=Math.max(0,b-p);break;case"PageDown":r.preventDefault(),D=Math.min(K,b+p);break;case"Home":r.preventDefault(),D=0;break;case"End":r.preventDefault(),D=K;break;default:return}if(D!==null){let se=D/K,ue=O?f*2+n.margin*4:n.margin*2,re=(p-ue-V)*se;Ie(re),l.scrollTop=D,g(),x(!0),m(i.delay)}},o=a.current;if(o)return o.addEventListener("keydown",e),()=>{o.removeEventListener("keydown",e)}},[d,O,f,n.margin,V,g,m,i.delay,te]),(0,t.useEffect)(()=>(document.addEventListener("mousemove",Ee),document.addEventListener("mouseup",Ce),()=>{document.removeEventListener("mousemove",Ee),document.removeEventListener("mouseup",Ce)}),[P,Ee,Ce]),(0,t.useEffect)(()=>{if(W)return document.addEventListener("mousemove",we),document.addEventListener("mouseup",Te),()=>{document.removeEventListener("mousemove",we),document.removeEventListener("mouseup",Te)}},[W,we,Te]),(0,t.useEffect)(()=>{if(A)return document.addEventListener("mousemove",Me),document.addEventListener("mouseup",Se),()=>{document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",Se)}},[A,Me,Se]),(0,t.useEffect)(()=>{u();let e=setTimeout(()=>{u()},100);return()=>clearTimeout(e)},[u]),(0,t.useLayoutEffect)(()=>{tt(!0),u(),!i.enabled&&!G&&N()&&x(!0)},[N,u,i.enabled,G]),(0,t.useEffect)(()=>{if(i.initialDelay>0){let e=setTimeout(()=>{nt(!1)},i.initialDelay);return()=>clearTimeout(e)}},[i.initialDelay]),(0,t.useEffect)(()=>{let e=new ResizeObserver(()=>{u()}),o=[];return a.current&&o.push(a.current),B.current&&o.push(B.current),I.current&&document.contains(I.current)&&o.push(I.current),o.forEach(r=>{e.observe(r)}),()=>e.disconnect()},[u]),(0,t.useEffect)(()=>{if(!a.current)return;let e=new MutationObserver(()=>{I.current=null,u()});return e.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>e.disconnect()},[u]);let M=Math.max(lt,f);return(0,t.useEffect)(()=>{let e="overlay-scrollbar-webkit-hide",o=document.getElementById(e);o&&o.remove();let r=document.createElement("style");return r.id=e,r.textContent=`
|
|
2
2
|
/* \uBAA8\uB4E0 \uC2A4\uD06C\uB864\uBC14 \uC228\uAE30\uAE30 */
|
|
3
3
|
.overlay-scrollbar-container {
|
|
4
4
|
scrollbar-width: none !important;
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
.overlay-scrollbar-container .ehfuse-editor-content::-webkit-scrollbar-thumb:hover {
|
|
39
39
|
background: #a1a1a1 !important;
|
|
40
40
|
}
|
|
41
|
-
`,document.head.appendChild(r),()=>{let
|
|
41
|
+
`,document.head.appendChild(r),()=>{let c=document.getElementById(e);c&&c.remove()}},[]),(0,S.jsxs)("div",{ref:he,className:`overlay-scrollbar-wrapper ${h}`,onMouseLeave:it,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",overflow:"hidden",...y},children:[(0,S.jsx)("div",{ref:a,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:mt,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:P?"none":"auto",...E},children:(0,S.jsx)("div",{ref:B,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...T},children:C})}),j&&X&&(n.overflowY??!0)&&(0,S.jsxs)("div",{ref:q,className:"overlay-scrollbar-track",onMouseEnter:()=>{g(),_.current=setTimeout(()=>{x(!0),_.current=null},100)},onMouseLeave:()=>{ce(),W||m(i.delay)},style:{position:"absolute",top:0,right:0,width:`${M}px`,height:"100%",opacity:ne?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[n.visible&&(0,S.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:e=>{e.preventDefault(),e.stopPropagation(),ct(e)},style:{position:"absolute",top:O?`${v.width+n.margin*2}px`:`${n.margin}px`,right:n.alignment==="outside"?"0px":`${(M-v.width)/2}px`,width:`${v.width}px`,height:O?`calc(100% - ${v.width*2+n.margin*4}px)`:`calc(100% - ${n.margin*2}px)`,backgroundColor:n.color,borderRadius:`${n.radius}px`,cursor:"pointer"}}),(0,S.jsx)("div",{ref:Ye,className:"overlay-scrollbar-thumb",onMouseDown:at,onMouseEnter:()=>Re(!0),onMouseLeave:()=>Re(!1),style:{position:"absolute",top:`${(O?f+n.margin*2:n.margin)+Ze}px`,right:n.alignment==="outside"?"0px":`${(M-f)/2}px`,width:`${f}px`,height:`${Math.max(V,xe)}px`,backgroundColor:ke||W?v.hoverColor:v.color,opacity:ke||W?v.hoverOpacity:v.opacity,borderRadius:`${v.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),j&&X&&O&&(0,S.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:st,onMouseEnter:()=>ie("up"),onMouseLeave:()=>ie(null),style:{position:"absolute",top:`${n.margin}px`,right:n.alignment==="outside"?"0px":`${(M-f)/2}px`,width:`${f}px`,height:`${f}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(f*.75,8)}px`,color:le==="up"?R.hoverColor:R.color,userSelect:"none",zIndex:1001,opacity:ne?le==="up"?R.hoverOpacity:R.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),j&&X&&O&&(0,S.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:ut,onMouseEnter:()=>ie("down"),onMouseLeave:()=>ie(null),style:{position:"absolute",bottom:`${n.margin}px`,right:n.alignment==="outside"?"0px":`${(M-f)/2}px`,width:`${f}px`,height:`${f}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(f*.75,8)}px`,color:le==="down"?R.hoverColor:R.color,userSelect:"none",zIndex:1001,opacity:ne?le==="down"?R.hoverOpacity:R.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"}),j&&Qe&&(n.overflowX??!0)&&(0,S.jsxs)("div",{className:"overlay-scrollbar-horizontal-track",onMouseEnter:()=>{g(),_.current=setTimeout(()=>{x(!0),_.current=null},100)},onMouseLeave:()=>{ce(),A||m(i.delay)},style:{position:"absolute",bottom:`${ot}px`,left:0,width:"100%",height:`${M}px`,opacity:ne?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[n.visible&&(0,S.jsx)("div",{className:"overlay-scrollbar-horizontal-track-background",onClick:e=>{e.preventDefault(),e.stopPropagation(),pt(e)},style:{position:"absolute",bottom:n.alignment==="outside"?"0px":`${(M-f)/2}px`,left:`${n.margin}px`,right:X?n.alignment==="outside"?`${M-n.margin}px`:`${M}px`:`${n.margin}px`,height:`${f}px`,backgroundColor:n.color,borderRadius:`${n.radius}px`,cursor:"pointer"}}),(0,S.jsx)("div",{className:"overlay-scrollbar-horizontal-thumb",onMouseDown:dt,onMouseEnter:()=>Oe(!0),onMouseLeave:()=>Oe(!1),style:{position:"absolute",bottom:n.alignment==="outside"?"0px":`${(M-f)/2}px`,left:`${n.margin+ve}px`,right:X?n.alignment==="outside"?`${M-n.margin}px`:`${M}px`:"auto",maxWidth:X?n.alignment==="outside"?`calc(100% - ${n.margin+ve+M-n.margin}px)`:`calc(100% - ${n.margin+ve+M}px)`:"none",width:`${Math.max(ge,50)}px`,height:`${f}px`,backgroundColor:Ae||A?v.hoverColor:v.color,opacity:Ae||A?v.hoverOpacity:v.opacity,borderRadius:`${v.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]})]})}),Le=Dt;
|
|
42
42
|
//# sourceMappingURL=index.js.map
|