@ehfuse/overlay-scrollbar 1.6.20 → 1.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OverlayScrollbar.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/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Le=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var xt=(h,x)=>{for(var C in x)Le(h,C,{get:x[C],enumerable:!0})},wt=(h,x,C,T)=>{if(x&&typeof x=="object"||typeof x=="function")for(let H of vt(x))!yt.call(h,H)&&H!==C&&Le(h,H,{get:()=>x[H],enumerable:!(T=gt(x,H))||T.enumerable});return h};var Tt=h=>wt(Le({},"__esModule",{value:!0}),h);var Rt={};xt(Rt,{OverlayScrollbar:()=>De,default:()=>De});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"],me=(h,x)=>{if(h instanceof HTMLElement&&h.isContentEditable||h.closest('[role="textbox"],[role="searchbox"]'))return!0;let C=h.tagName.toLowerCase();if(C==="input"){let T=(h.type||"text").toLowerCase();return!["button","submit","reset","image","hidden"].includes(T)}if(["textarea","select","button"].includes(C)||["svg","path","circle","rect","line","polygon","polyline"].includes(C)||h.getAttribute("contenteditable")==="true")return!0;if(x?.excludeSelectors){for(let T of x.excludeSelectors)if(h.matches(T))return!0}return St(h,x)},St=(h,x)=>{let C=[...Mt,...x?.excludeClasses||[]],T=h,H=0,$=5;for(;T&&H<=$;){if(C.some(L=>T.classList.contains(L)))return!0;if(T.classList.contains("MuiDialogContent-root"))break;T=T.parentElement,H++}return!1};var E=require("react/jsx-runtime"),Et={},Ct={},Ht={},Lt={},Dt={},he=24,kt=(0,t.forwardRef)(({className:h="",style:x={},containerStyle:C={},contentStyle:T={},children:H,onScroll:$,thumb:L=Et,track:k=Ct,arrows:z=Ht,dragScroll:Z=Lt,autoHide:B=Dt,showScrollbar:j=!0,showHorizontalScrollbar:ke=!0,detectInnerScroll:Ge=!1},Ke)=>{let Ve=(0,t.useRef)({});(0,t.useEffect)(()=>{Ve.current={children:H,onScroll:$,showScrollbar:j,showHorizontalScrollbar:ke,thumb:L,track:k,arrows:z,dragScroll:Z,autoHide:B}});let fe=(0,t.useRef)(null),i=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(null),Ze=(0,t.useRef)(null),I=(0,t.useRef)(null),[ae,v]=(0,t.useState)(!1),[W,Re]=(0,t.useState)(!1),[Ie,We]=(0,t.useState)(!1),[be,je]=(0,t.useState)({y:0,scrollTop:0}),[ee,Oe]=(0,t.useState)(0),[Je,ge]=(0,t.useState)(0),[X,Ae]=(0,t.useState)(!1),[$e,ze]=(0,t.useState)(!1),[O,Pe]=(0,t.useState)(!1),[ve,Qe]=(0,t.useState)({x:0,scrollLeft:0}),[ye,Ne]=(0,t.useState)(0),[xe,Fe]=(0,t.useState)(0),[et,_e]=(0,t.useState)(!1),Y=(0,t.useRef)(!1),[P,Be]=(0,t.useState)(!1),[te,tt]=(0,t.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[It,Wt]=(0,t.useState)(null),[ce,se]=(0,t.useState)(null),[Ot,ot]=(0,t.useState)(!1),[rt,nt]=(0,t.useState)(0),oe=(0,t.useRef)(null),[Ue,qe]=(0,t.useState)(!1),re=(0,t.useRef)(null),U=(0,t.useRef)(null),q=(0,t.useRef)(null),y=(0,t.useMemo)(()=>{let e=L.color??"#606060";return{width:L.width??8,minHeight:L.minHeight??50,radius:L.radius??(L.width??8)/2,color:e,opacity:L.opacity??.6,hoverColor:L.hoverColor??e,hoverOpacity:L.hoverOpacity??1}},[L]),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??y.radius??4,margin:k.margin??4,overflowX:k.overflowX??!0,overflowY:k.overflowY??!0}),[k,y.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]),ne=(0,t.useMemo)(()=>({enabled:Z.enabled??!0,excludeClasses:Z.excludeClasses??[],excludeSelectors:Z.excludeSelectors??[]}),[Z]),a=(0,t.useMemo)(()=>({enabled:B.enabled??!0,delay:B.delay??1500,delayOnWheel:B.delayOnWheel??700,initialDelay:B.initialDelay??200}),[B]),[G,lt]=(0,t.useState)(()=>(B.initialDelay??200)>0),f=y.width,it=n.width,we=y.minHeight,A=R.visible,ue=R.step,D=(0,t.useCallback)(()=>{if(!i.current)return;let e=document.activeElement;e&&i.current.contains(e)&&e!==i.current||i.current.focus()},[]);(0,t.useImperativeHandle)(Ke,()=>({getScrollContainer:()=>i.current,scrollTo:e=>{i.current&&i.current.scrollTo(e)},get scrollTop(){return i.current?.scrollTop||0},get scrollHeight(){return i.current?.scrollHeight||0},get clientHeight(){return i.current?.clientHeight||0}}),[]);let d=(0,t.useCallback)(()=>{if(I.current){let o=I.current;if(document.contains(o)&&(o.scrollHeight>o.clientHeight+2||o.scrollWidth>o.clientWidth+2))return o;I.current=null}if(!i.current)return null;if(i.current.scrollHeight>i.current.clientHeight+2||i.current.scrollWidth>i.current.clientWidth+2)return I.current=i.current,i.current;if(!Ge)return null;let e=i.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!==i.current&&r.classList.contains("overlay-scrollbar-container"))continue;let c=r.parentElement,l=!1;for(;c&&c!==i.current;){if(c.classList.contains("overlay-scrollbar-container")&&c!==i.current){l=!0;break}c=c.parentElement}if(!l&&(r.scrollHeight>r.clientHeight+2||r.scrollWidth>r.clientWidth+2))return I.current=r,r}return null},[]),N=(0,t.useCallback)(()=>d()!==null,[d]),b=(0,t.useCallback)(()=>{re.current&&(clearTimeout(re.current),re.current=null)},[]),de=(0,t.useCallback)(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),Xe=(0,t.useCallback)(()=>{q.current&&(clearTimeout(q.current),q.current=null)},[]),at=(0,t.useCallback)(()=>{de(),!(W||O||P||Y.current)&&(b(),v(!1))},[b,de,W,O,P]),m=(0,t.useCallback)(e=>{a.enabled&&(b(),re.current=setTimeout(()=>{v(!1),re.current=null},e))},[b,a.enabled]),u=(0,t.useCallback)(()=>{let e=d()??i.current;if(!e){v(!1),Ae(!1),_e(!1),b();return}!a.enabled&&!G&&(v(!0),b());let o=e.clientHeight,r=e.scrollHeight,c=e.scrollTop,l=e.clientWidth,s=e.scrollWidth,g=e.scrollLeft,w=r-o>0,p=s-l>0,K=w||p;Ae(w),_e(p),K||(v(!1),b());let le=0,S=0;if(fe.current){let F=window.getComputedStyle(fe.current),_=parseFloat(F.paddingTop)||0;S=parseFloat(F.paddingBottom)||0,le=_+S,nt(S)}if(w){let F=A?f*2+n.margin*4:n.margin*2,_=o-F+le,pe=o/r,V=Math.max(_*pe,we),Ye=r-o,ft=_-V,bt=Ye>0?c/Ye*ft:0;Oe(V),ge(bt)}else Oe(0),ge(0);let ie=s-l;if(ie>0){let F=l/s,_=Math.max(l*F,50),pe=l-_,V=ie>0?g/ie*pe:0;Ne(_),Fe(V)}else Ne(0),Fe(0)},[d,b,A,f,we,a.enabled,G]),ct=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(Re(!0),je({y:e.clientY,scrollTop:o.scrollTop}),b(),v(!0),D())},[d,b,D]),Te=(0,t.useCallback)(e=>{if(!W)return;let o=d();if(!o)return;let r=o.clientHeight,l=o.scrollHeight-r,s=e.clientY-be.y,g=r-ee,w=s/g*l,p=Math.max(0,Math.min(l,be.scrollTop+w));o.scrollTop=p,u()},[W,be,ee,u,d]),Me=(0,t.useCallback)(()=>{Re(!1),N()&&m(a.delay)},[N,m,a.delay]),st=(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,g=l.scrollHeight,p=c/s*(g-s);l.scrollTop=Math.max(0,Math.min(g-s,p)),u(),v(!0),m(a.delay),D()},[u,m,a.delay,d,D]),ut=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i.current)return;let o=Math.max(0,i.current.scrollTop-ue);i.current.scrollTop=o,u(),v(!0),m(a.delay),D()},[u,m,ue,a.delay,D]),dt=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i.current||!J.current)return;let o=i.current,c=J.current.scrollHeight-o.clientHeight,l=Math.min(c,o.scrollTop+ue);o.scrollTop=l,u(),v(!0),m(a.delay),D()},[u,m,ue,a.delay,D]),pt=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(Pe(!0),Qe({x:e.clientX,scrollLeft:o.scrollLeft}),b(),v(!0),D())},[d,b,D]),Se=(0,t.useCallback)(e=>{if(!O)return;let o=d();if(!o)return;let r=o.clientWidth,l=o.scrollWidth-r,s=e.clientX-ve.x,g=r-ye,w=s/g*l,p=Math.max(0,Math.min(l,ve.scrollLeft+w));o.scrollLeft=p,u()},[O,ve,ye,u,d]),Ee=(0,t.useCallback)(()=>{Pe(!1),N()&&m(a.delay)},[N,m,a.delay]),mt=(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,g=l.scrollWidth,p=c/s*(g-s);l.scrollLeft=Math.max(0,Math.min(g-s,p)),u(),v(!0),m(a.delay),D()},[u,m,a.delay,d,D]),ht=(0,t.useCallback)(e=>{if(!ne.enabled)return;let o=e.target;if(me(o,ne)||e.button!==0)return;let r=d();r&&(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth||(e.preventDefault(),Y.current=!0,tt({x:e.clientX,y:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft||0}),b()))},[ne,me,d,b]),Ce=(0,t.useCallback)(e=>{if(!Y.current&&!P)return;let o=d();if(!o)return;let r=te.x-e.clientX,c=te.y-e.clientY;if(Math.abs(c)<5&&Math.abs(r)<5)return;Y.current&&(Y.current=!1,Be(!0)),v(!0);let l=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,te.scrollTop+c)),s=Math.max(0,Math.min(o.scrollWidth-o.clientWidth,te.scrollLeft+r));o.scrollTop=l,o.scrollLeft=s,u()},[P,te,d,u]),He=(0,t.useCallback)(()=>{let e=P;Y.current=!1,Be(!1),e&&N()&&m(a.delay)},[P,N,m,a.delay]);(0,t.useEffect)(()=>{let e=s=>{if(u(),G){$&&$(s);return}b(),v(!0),Xe();let g=Ue?a.delayOnWheel:a.delay;m(g),$&&$(s)},o=()=>{qe(!0),oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{qe(!1)},300),Xe(),q.current=setTimeout(()=>{v(!0),q.current=null,m(a.delayOnWheel)},50)},r=[],c=d();c&&r.push(c);let l=i.current;return l&&!c&&(r.push(l),l.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(g=>{let w=g;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)}),oe.current&&clearTimeout(oe.current),q.current&&clearTimeout(q.current)}},[d,u,$,b,m,a,Ue,G]),(0,t.useEffect)(()=>{let e=r=>{let c=r.target;if(r.defaultPrevented||c instanceof Element&&me(c,ne))return;let l=d();if(!l)return;let{key:s}=r,{scrollTop:g,scrollHeight:w,clientHeight:p}=l,K=w-p,le=50,S=null;switch(s){case"ArrowUp":r.preventDefault(),S=Math.max(0,g-le);break;case"ArrowDown":r.preventDefault(),S=Math.min(K,g+le);break;case"PageUp":r.preventDefault(),S=Math.max(0,g-p);break;case"PageDown":r.preventDefault(),S=Math.min(K,g+p);break;case"Home":r.preventDefault(),S=0;break;case"End":r.preventDefault(),S=K;break;default:return}if(S!==null){let ie=S/K,F=A?f*2+n.margin*4:n.margin*2,V=(p-F-ee)*ie;ge(V),l.scrollTop=S,b(),v(!0),m(a.delay)}},o=i.current;if(o)return o.addEventListener("keydown",e),()=>{o.removeEventListener("keydown",e)}},[d,A,f,n.margin,ee,b,m,a.delay,ne]),(0,t.useEffect)(()=>(document.addEventListener("mousemove",Ce),document.addEventListener("mouseup",He),()=>{document.removeEventListener("mousemove",Ce),document.removeEventListener("mouseup",He)}),[P,Ce,He]),(0,t.useEffect)(()=>{if(W)return document.addEventListener("mousemove",Te),document.addEventListener("mouseup",Me),()=>{document.removeEventListener("mousemove",Te),document.removeEventListener("mouseup",Me)}},[W,Te,Me]),(0,t.useEffect)(()=>{if(O)return document.addEventListener("mousemove",Se),document.addEventListener("mouseup",Ee),()=>{document.removeEventListener("mousemove",Se),document.removeEventListener("mouseup",Ee)}},[O,Se,Ee]),(0,t.useEffect)(()=>{u();let e=setTimeout(()=>{u()},100);return()=>clearTimeout(e)},[u]),(0,t.useLayoutEffect)(()=>{ot(!0),u(),!a.enabled&&!G&&N()&&v(!0)},[N,u,a.enabled,G]),(0,t.useEffect)(()=>{if(a.initialDelay>0){let e=setTimeout(()=>{lt(!1)},a.initialDelay);return()=>clearTimeout(e)}},[a.initialDelay]),(0,t.useEffect)(()=>{let e=new ResizeObserver(()=>{u()}),o=[];return i.current&&o.push(i.current),J.current&&o.push(J.current),I.current&&document.contains(I.current)&&o.push(I.current),o.forEach(r=>{e.observe(r)}),()=>e.disconnect()},[u]),(0,t.useEffect)(()=>{if(!i.current)return;let e=new MutationObserver(()=>{I.current=null,u()});return e.observe(i.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>e.disconnect()},[u]);let M=Math.max(it,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=`
|
|
1
|
+
"use strict";var He=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var vt=Object.prototype.hasOwnProperty;var yt=(h,x)=>{for(var C in x)He(h,C,{get:x[C],enumerable:!0})},xt=(h,x,C,T)=>{if(x&&typeof x=="object"||typeof x=="function")for(let H of gt(x))!vt.call(h,H)&&H!==C&&He(h,H,{get:()=>x[H],enumerable:!(T=bt(x,H))||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,x)=>{if(h instanceof HTMLElement&&h.isContentEditable||h.closest('[role="textbox"],[role="searchbox"]'))return!0;let C=h.tagName.toLowerCase();if(C==="input"){let T=(h.type||"text").toLowerCase();return!["button","submit","reset","image","hidden"].includes(T)}if(["textarea","select","button"].includes(C)||["svg","path","circle","rect","line","polygon","polyline"].includes(C)||h.getAttribute("contenteditable")==="true")return!0;if(x?.excludeSelectors){for(let T of x.excludeSelectors)if(h.matches(T))return!0}return Mt(h,x)},Mt=(h,x)=>{let C=[...Tt,...x?.excludeClasses||[]],T=h,H=0,$=5;for(;T&&H<=$;){if(C.some(L=>T.classList.contains(L)))return!0;if(T.classList.contains("MuiDialogContent-root"))break;T=T.parentElement,H++}return!1};var E=require("react/jsx-runtime"),St={},Et={},Ct={},Ht={},Lt={},Dt=(0,t.forwardRef)(({className:h="",style:x={},containerStyle:C={},contentStyle:T={},children:H,onScroll:$,thumb:L=St,track:k=Et,arrows:z=Ct,dragScroll:Z=Ht,autoHide:_=Lt,showScrollbar:j=!0,showHorizontalScrollbar:De=!0,detectInnerScroll:Ye=!1},Ge)=>{let Ke=(0,t.useRef)({});(0,t.useEffect)(()=>{Ke.current={children:H,onScroll:$,showScrollbar:j,showHorizontalScrollbar:De,thumb:L,track:k,arrows:z,dragScroll:Z,autoHide:_}});let he=(0,t.useRef)(null),i=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(null),Ve=(0,t.useRef)(null),I=(0,t.useRef)(null),[ae,v]=(0,t.useState)(!1),[W,ke]=(0,t.useState)(!1),[Re,Ie]=(0,t.useState)(!1),[fe,Ze]=(0,t.useState)({y:0,scrollTop:0}),[ee,We]=(0,t.useState)(0),[je,be]=(0,t.useState)(0),[X,Oe]=(0,t.useState)(!1),[Ae,$e]=(0,t.useState)(!1),[O,ze]=(0,t.useState)(!1),[ge,Je]=(0,t.useState)({x:0,scrollLeft:0}),[ve,Pe]=(0,t.useState)(0),[ye,Ne]=(0,t.useState)(0),[Qe,Fe]=(0,t.useState)(!1),Y=(0,t.useRef)(!1),[P,Be]=(0,t.useState)(!1),[te,et]=(0,t.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[Rt,It]=(0,t.useState)(null),[ce,se]=(0,t.useState)(null),[Wt,tt]=(0,t.useState)(!1),[ot,rt]=(0,t.useState)(0),oe=(0,t.useRef)(null),[_e,Ue]=(0,t.useState)(!1),re=(0,t.useRef)(null),U=(0,t.useRef)(null),q=(0,t.useRef)(null),y=(0,t.useMemo)(()=>{let e=L.color??"#606060";return{width:L.width??8,minHeight:L.minHeight??50,radius:L.radius??(L.width??8)/2,color:e,opacity:L.opacity??.6,hoverColor:L.hoverColor??e,hoverOpacity:L.hoverOpacity??1}},[L]),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??y.radius??4,margin:k.margin??4,overflowX:k.overflowX??!0,overflowY:k.overflowY??!0}),[k,y.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]),ne=(0,t.useMemo)(()=>({enabled:Z.enabled??!0,excludeClasses:Z.excludeClasses??[],excludeSelectors:Z.excludeSelectors??[]}),[Z]),a=(0,t.useMemo)(()=>({enabled:_.enabled??!0,delay:_.delay??1500,delayOnWheel:_.delayOnWheel??700,initialDelay:_.initialDelay??200}),[_]),[G,nt]=(0,t.useState)(()=>(_.initialDelay??200)>0),f=y.width,lt=n.width,xe=y.minHeight,A=R.visible,ue=R.step,D=(0,t.useCallback)(()=>{if(!i.current)return;let e=document.activeElement;e&&i.current.contains(e)&&e!==i.current||i.current.focus()},[]);(0,t.useImperativeHandle)(Ge,()=>({getScrollContainer:()=>i.current,scrollTo:e=>{i.current&&i.current.scrollTo(e)},get scrollTop(){return i.current?.scrollTop||0},get scrollHeight(){return i.current?.scrollHeight||0},get clientHeight(){return i.current?.clientHeight||0}}),[]);let d=(0,t.useCallback)(()=>{if(I.current){let o=I.current;if(document.contains(o)&&(o.scrollHeight>o.clientHeight+2||o.scrollWidth>o.clientWidth+2))return o;I.current=null}if(!i.current)return null;if(i.current.scrollHeight>i.current.clientHeight+2||i.current.scrollWidth>i.current.clientWidth+2)return I.current=i.current,i.current;if(!Ye)return null;let e=i.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!==i.current&&r.classList.contains("overlay-scrollbar-container"))continue;let c=r.parentElement,l=!1;for(;c&&c!==i.current;){if(c.classList.contains("overlay-scrollbar-container")&&c!==i.current){l=!0;break}c=c.parentElement}if(!l&&(r.scrollHeight>r.clientHeight+2||r.scrollWidth>r.clientWidth+2))return I.current=r,r}return null},[]),N=(0,t.useCallback)(()=>d()!==null,[d]),b=(0,t.useCallback)(()=>{re.current&&(clearTimeout(re.current),re.current=null)},[]),de=(0,t.useCallback)(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),qe=(0,t.useCallback)(()=>{q.current&&(clearTimeout(q.current),q.current=null)},[]),it=(0,t.useCallback)(()=>{de(),!(W||O||P||Y.current)&&(b(),v(!1))},[b,de,W,O,P]),m=(0,t.useCallback)(e=>{a.enabled&&(b(),re.current=setTimeout(()=>{v(!1),re.current=null},e))},[b,a.enabled]),u=(0,t.useCallback)(()=>{let e=d()??i.current;if(!e){v(!1),Oe(!1),Fe(!1),b();return}!a.enabled&&!G&&(v(!0),b());let o=e.clientHeight,r=e.scrollHeight,c=e.scrollTop,l=e.clientWidth,s=e.scrollWidth,g=e.scrollLeft,w=r-o>0,p=s-l>0,K=w||p;Oe(w),Fe(p),K||(v(!1),b());let le=0,S=0;if(he.current){let F=window.getComputedStyle(he.current),B=parseFloat(F.paddingTop)||0;S=parseFloat(F.paddingBottom)||0,le=B+S,rt(S)}if(w){let F=A?f*2+n.margin*4:n.margin*2,B=o-F+le,pe=o/r,V=Math.max(B*pe,xe),Xe=r-o,ht=B-V,ft=Xe>0?c/Xe*ht:0;We(V),be(ft)}else We(0),be(0);let ie=s-l;if(ie>0){let F=l/s,B=Math.max(l*F,50),pe=l-B,V=ie>0?g/ie*pe:0;Pe(B),Ne(V)}else Pe(0),Ne(0)},[d,b,A,f,xe,a.enabled,G]),at=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(ke(!0),Ze({y:e.clientY,scrollTop:o.scrollTop}),b(),v(!0),D())},[d,b,D]),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,g=r-ee,w=s/g*l,p=Math.max(0,Math.min(l,fe.scrollTop+w));o.scrollTop=p,u()},[W,fe,ee,u,d]),Te=(0,t.useCallback)(()=>{ke(!1),N()&&m(a.delay)},[N,m,a.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,g=l.scrollHeight,p=c/s*(g-s);l.scrollTop=Math.max(0,Math.min(g-s,p)),u(),v(!0),m(a.delay),D()},[u,m,a.delay,d,D]),st=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i.current)return;let o=Math.max(0,i.current.scrollTop-ue);i.current.scrollTop=o,u(),v(!0),m(a.delay),D()},[u,m,ue,a.delay,D]),ut=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i.current||!J.current)return;let o=i.current,c=J.current.scrollHeight-o.clientHeight,l=Math.min(c,o.scrollTop+ue);o.scrollTop=l,u(),v(!0),m(a.delay),D()},[u,m,ue,a.delay,D]),dt=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let o=d();o&&(ze(!0),Je({x:e.clientX,scrollLeft:o.scrollLeft}),b(),v(!0),D())},[d,b,D]),Me=(0,t.useCallback)(e=>{if(!O)return;let o=d();if(!o)return;let r=o.clientWidth,l=o.scrollWidth-r,s=e.clientX-ge.x,g=r-ve,w=s/g*l,p=Math.max(0,Math.min(l,ge.scrollLeft+w));o.scrollLeft=p,u()},[O,ge,ve,u,d]),Se=(0,t.useCallback)(()=>{ze(!1),N()&&m(a.delay)},[N,m,a.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,g=l.scrollWidth,p=c/s*(g-s);l.scrollLeft=Math.max(0,Math.min(g-s,p)),u(),v(!0),m(a.delay),D()},[u,m,a.delay,d,D]),mt=(0,t.useCallback)(e=>{if(!ne.enabled)return;let o=e.target;if(me(o,ne)||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}),b()))},[ne,me,d,b]),Ee=(0,t.useCallback)(e=>{if(!Y.current&&!P)return;let o=d();if(!o)return;let r=te.x-e.clientX,c=te.y-e.clientY;if(Math.abs(c)<5&&Math.abs(r)<5)return;Y.current&&(Y.current=!1,Be(!0)),v(!0);let l=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,te.scrollTop+c)),s=Math.max(0,Math.min(o.scrollWidth-o.clientWidth,te.scrollLeft+r));o.scrollTop=l,o.scrollLeft=s,u()},[P,te,d,u]),Ce=(0,t.useCallback)(()=>{let e=P;Y.current=!1,Be(!1),e&&N()&&m(a.delay)},[P,N,m,a.delay]);(0,t.useEffect)(()=>{let e=s=>{if(u(),G){$&&$(s);return}b(),v(!0),qe();let g=_e?a.delayOnWheel:a.delay;m(g),$&&$(s)},o=()=>{Ue(!0),oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{Ue(!1)},300),qe(),q.current=setTimeout(()=>{v(!0),q.current=null,m(a.delayOnWheel)},50)},r=[],c=d();c&&r.push(c);let l=i.current;return l&&!c&&(r.push(l),l.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(g=>{let w=g;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)}),oe.current&&clearTimeout(oe.current),q.current&&clearTimeout(q.current)}},[d,u,$,b,m,a,_e,G]),(0,t.useEffect)(()=>{let e=r=>{let c=r.target;if(r.defaultPrevented||c instanceof Element&&me(c,ne))return;let l=d();if(!l)return;let{key:s}=r,{scrollTop:g,scrollHeight:w,clientHeight:p}=l,K=w-p,le=50,S=null;switch(s){case"ArrowUp":r.preventDefault(),S=Math.max(0,g-le);break;case"ArrowDown":r.preventDefault(),S=Math.min(K,g+le);break;case"PageUp":r.preventDefault(),S=Math.max(0,g-p);break;case"PageDown":r.preventDefault(),S=Math.min(K,g+p);break;case"Home":r.preventDefault(),S=0;break;case"End":r.preventDefault(),S=K;break;default:return}if(S!==null){let ie=S/K,F=A?f*2+n.margin*4:n.margin*2,V=(p-F-ee)*ie;be(V),l.scrollTop=S,b(),v(!0),m(a.delay)}},o=i.current;if(o)return o.addEventListener("keydown",e),()=>{o.removeEventListener("keydown",e)}},[d,A,f,n.margin,ee,b,m,a.delay,ne]),(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(O)return document.addEventListener("mousemove",Me),document.addEventListener("mouseup",Se),()=>{document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",Se)}},[O,Me,Se]),(0,t.useEffect)(()=>{u();let e=setTimeout(()=>{u()},100);return()=>clearTimeout(e)},[u]),(0,t.useLayoutEffect)(()=>{tt(!0),u(),!a.enabled&&!G&&N()&&v(!0)},[N,u,a.enabled,G]),(0,t.useEffect)(()=>{if(a.initialDelay>0){let e=setTimeout(()=>{nt(!1)},a.initialDelay);return()=>clearTimeout(e)}},[a.initialDelay]),(0,t.useEffect)(()=>{let e=new ResizeObserver(()=>{u()}),o=[];return i.current&&o.push(i.current),J.current&&o.push(J.current),I.current&&document.contains(I.current)&&o.push(I.current),o.forEach(r=>{e.observe(r)}),()=>e.disconnect()},[u]),(0,t.useEffect)(()=>{if(!i.current)return;let e=new MutationObserver(()=>{I.current=null,u()});return e.observe(i.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 c=document.getElementById(e);c&&c.remove()}},[]),(0,E.jsxs)("div",{ref:
|
|
41
|
+
`,document.head.appendChild(r),()=>{let c=document.getElementById(e);c&&c.remove()}},[]),(0,E.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:"visible",...x},children:[(0,E.jsx)("div",{ref:i,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",...C},children:(0,E.jsx)("div",{ref:J,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",boxSizing:"border-box",...T},children:H})}),j&&X&&(n.overflowY??!0)&&(0,E.jsxs)("div",{ref:Q,className:"overlay-scrollbar-track",onMouseEnter:()=>{b(),U.current=setTimeout(()=>{v(!0),U.current=null},100)},onMouseLeave:()=>{de(),W||m(a.delay)},style:{position:"absolute",top:0,right:0,width:`${M}px`,height:"100%",opacity:ae?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[n.visible&&(0,E.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:e=>{e.preventDefault(),e.stopPropagation(),ct(e)},style:{position:"absolute",top:A?`${y.width+n.margin*2}px`:`${n.margin}px`,right:n.alignment==="outside"?"0px":`${(M-y.width)/2}px`,width:`${y.width}px`,height:A?`calc(100% - ${y.width*2+n.margin*4}px)`:`calc(100% - ${n.margin*2}px)`,backgroundColor:n.color,borderRadius:`${n.radius}px`,cursor:"pointer"}}),(0,E.jsx)("div",{ref:Ve,className:"overlay-scrollbar-thumb",onMouseDown:at,onMouseEnter:()=>Ie(!0),onMouseLeave:()=>Ie(!1),style:{position:"absolute",top:`${(A?f+n.margin*2:n.margin)+je}px`,right:n.alignment==="outside"?"0px":`${(M-f)/2}px`,width:`${f}px`,height:`${Math.max(ee,xe)}px`,backgroundColor:Re||W?y.hoverColor:y.color,opacity:Re||W?y.hoverOpacity:y.opacity,borderRadius:`${y.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),j&&X&&A&&(0,E.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:st,onMouseEnter:()=>se("up"),onMouseLeave:()=>se(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:ce==="up"?R.hoverColor:R.color,userSelect:"none",zIndex:1001,opacity:ae?ce==="up"?R.hoverOpacity:R.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),j&&X&&A&&(0,E.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:ut,onMouseEnter:()=>se("down"),onMouseLeave:()=>se(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:ce==="down"?R.hoverColor:R.color,userSelect:"none",zIndex:1001,opacity:ae?ce==="down"?R.hoverOpacity:R.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"}),j&&De&&Qe&&(n.overflowX??!0)&&(0,E.jsxs)("div",{className:"overlay-scrollbar-horizontal-track",onMouseEnter:()=>{b(),U.current=setTimeout(()=>{v(!0),U.current=null},100)},onMouseLeave:()=>{de(),O||m(a.delay)},style:{position:"absolute",bottom:`${ot}px`,left:0,width:"100%",height:`${M}px`,opacity:ae?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[n.visible&&(0,E.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,E.jsx)("div",{className:"overlay-scrollbar-horizontal-thumb",onMouseDown:dt,onMouseEnter:()=>$e(!0),onMouseLeave:()=>$e(!1),style:{position:"absolute",bottom:n.alignment==="outside"?"0px":`${(M-f)/2}px`,left:`${n.margin+ye}px`,right:X?n.alignment==="outside"?`${M-n.margin}px`:`${M}px`:"auto",maxWidth:X?n.alignment==="outside"?`calc(100% - ${n.margin+ye+M-n.margin}px)`:`calc(100% - ${n.margin+ye+M}px)`:"none",width:`${Math.max(ve,50)}px`,height:`${f}px`,backgroundColor:Ae||O?y.hoverColor:y.color,opacity:Ae||O?y.hoverOpacity:y.opacity,borderRadius:`${y.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
|