@ehfuse/overlay-scrollbar 1.5.9 → 1.5.11
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var pe=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ge=(m,f)=>{for(var S in f)pe(m,S,{get:f[S],enumerable:!0})},Je=(m,f,S,M)=>{if(f&&typeof f=="object"||typeof f=="function")for(let g of Be(f))!Ye.call(m,g)&&g!==S&&pe(m,g,{get:()=>f[g],enumerable:!(M=ze(f,g))||M.enumerable});return m};var Xe=m=>Je(pe({},"__esModule",{value:!0}),m);var rt={};Ge(rt,{OverlayScrollbar:()=>fe,default:()=>fe});module.exports=Xe(rt);var e=require("react");var Ke=["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=(m,f)=>{let S=m.tagName.toLowerCase(),M=["text","password","email","number","search","tel","url","checkbox","radio"];if(S==="input"){let g=m.type;return M.includes(g)}if(["textarea","select","button"].includes(S)||["svg","path","circle","rect","line","polygon","polyline"].includes(S)||m.getAttribute("contenteditable")==="true")return!0;if(f?.excludeSelectors){for(let g of f.excludeSelectors)if(m.matches(g))return!0}return Ze(m,f)},Ze=(m,f)=>{let S=[...Ke,...f?.excludeClasses||[]],M=m,g=0,P=5;for(;M&&g<=P;){if(S.some(E=>M.classList.contains(E)))return!0;if(M.classList.contains("MuiDialogContent-root"))break;M=M.parentElement,g++}return!1};var D=require("react/jsx-runtime"),je={},Ve={},Qe={},et={},tt={},ot=(0,e.forwardRef)(({className:m="",style:f={},containerStyle:S={},contentStyle:M={},children:g,onScroll:P,thumb:E=je,track:R=Ve,arrows:I=Qe,dragScroll:_=et,autoHide:q=tt,showScrollbar:X=!0,detectInnerScroll:Ee=!1},Ce)=>{let He=(0,e.useRef)({});(0,e.useEffect)(()=>{He.current={children:g,onScroll:P,showScrollbar:X,thumb:E,track:R,arrows:I,dragScroll:_,autoHide:q}});let te=(0,e.useRef)(null),n=(0,e.useRef)(null),O=(0,e.useRef)(null),K=(0,e.useRef)(null),De=(0,e.useRef)(null),k=(0,e.useRef)(null),[oe,x]=(0,e.useState)(!1),[N,he]=(0,e.useState)(!1),[ge,be]=(0,e.useState)(!1),[re,ke]=(0,e.useState)({y:0,scrollTop:0}),[U,Le]=(0,e.useState)(0),[Re,ve]=(0,e.useState)(0),[ne,ye]=(0,e.useState)(!1),[W,xe]=(0,e.useState)(!1),[Z,Ie]=(0,e.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[nt,lt]=(0,e.useState)(null),[j,V]=(0,e.useState)(null),[it,Ae]=(0,e.useState)(!1),z=(0,e.useRef)(null),[Te,we]=(0,e.useState)(!1),B=(0,e.useRef)(null),Y=(0,e.useRef)(null),$=(0,e.useRef)(null),T=(0,e.useMemo)(()=>{let t=E.color??"#606060";return{width:E.width??8,minHeight:E.minHeight??50,radius:E.radius??(E.width??8)/2,color:t,opacity:E.opacity??.6,hoverColor:E.hoverColor??t,hoverOpacity:E.hoverOpacity??1}},[E]),a=(0,e.useMemo)(()=>({width:R.width??16,color:R.color??"rgba(128, 128, 128, 0.1)",visible:R.visible??!0,alignment:R.alignment??"center",radius:R.radius??T.radius??4,margin:R.margin??4}),[R,T.radius]),H=(0,e.useMemo)(()=>{let t=I.color??"#808080";return{visible:I.visible??!1,step:I.step??50,color:t,opacity:I.opacity??.6,hoverColor:I.hoverColor??t,hoverOpacity:I.hoverOpacity??1}},[I]),le=(0,e.useMemo)(()=>({enabled:_.enabled??!0,excludeClasses:_.excludeClasses??[],excludeSelectors:_.excludeSelectors??[]}),[_]),c=(0,e.useMemo)(()=>({enabled:q.enabled??!0,delay:q.delay??1500,delayOnWheel:q.delayOnWheel??700}),[q]),h=T.width,Oe=a.width,ie=T.minHeight,L=H.visible,Q=H.step,A=(0,e.useCallback)(()=>{if(!n.current)return;let t=document.activeElement;t&&n.current.contains(t)&&t!==n.current||n.current.focus()},[]);(0,e.useImperativeHandle)(Ce,()=>({getScrollContainer:()=>n.current,scrollTo:t=>{n.current&&n.current.scrollTo(t)},get scrollTop(){return n.current?.scrollTop||0},get scrollHeight(){return n.current?.scrollHeight||0},get clientHeight(){return n.current?.clientHeight||0}}),[]);let d=(0,e.useCallback)(()=>{if(k.current){let o=k.current;if(document.contains(o)&&o.scrollHeight>o.clientHeight+2)return o;k.current=null}if(!n.current)return null;if(O.current&&O.current.scrollHeight>n.current.clientHeight+2)return k.current=n.current,n.current;if(!Ee)return null;let t=n.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let o of t){let r=o;if(r!==n.current&&r.classList.contains("overlay-scrollbar-container"))continue;let l=r.parentElement,i=!1;for(;l&&l!==n.current;){if(l.classList.contains("overlay-scrollbar-container")&&l!==n.current){i=!0;break}l=l.parentElement}if(!i&&r.scrollHeight>r.clientHeight+2)return k.current=r,r}return null},[]),F=(0,e.useCallback)(()=>d()!==null,[d]),b=(0,e.useCallback)(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),Ne=(0,e.useCallback)(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),$e=(0,e.useCallback)(()=>{$.current&&(clearTimeout($.current),$.current=null)},[]),v=(0,e.useCallback)(t=>{c.enabled&&(b(),B.current=setTimeout(()=>{x(!1),B.current=null},t))},[b,c.enabled]),s=(0,e.useCallback)(()=>{let t=d();if(!t){x(!1),ye(!1),b();return}if(ye(!0),!K.current)return;c.enabled||(x(!0),b());let o=t.clientHeight,r=t.scrollHeight,l=t.scrollTop,i=0;if(te.current){let ee=window.getComputedStyle(te.current),Se=parseFloat(ee.paddingTop)||0,Me=parseFloat(ee.paddingBottom)||0;i=Se+Me}let u=L?h*2+a.margin*4:a.margin*2,w=o-u+i,y=o/r,p=Math.max(w*y,ie),J=r-o,C=w-p,de=J>0?l/J*C:0;Le(p),ve(de)},[d,b,L,h,ie,c.enabled]),Pe=(0,e.useCallback)(t=>{t.preventDefault(),t.stopPropagation();let o=d();o&&(he(!0),ke({y:t.clientY,scrollTop:o.scrollTop}),b(),x(!0),A())},[d,b,A]),ce=(0,e.useCallback)(t=>{if(!N)return;let o=d();if(!o)return;let r=o.clientHeight,i=o.scrollHeight-r,u=t.clientY-re.y,w=r-U,y=u/w*i,p=Math.max(0,Math.min(i,re.scrollTop+y));o.scrollTop=p,s()},[N,re,U,s,d]),ae=(0,e.useCallback)(()=>{he(!1),F()&&v(c.delay)},[F,v,c.delay]),Fe=(0,e.useCallback)(t=>{if(!K.current)return;let r=K.current.getBoundingClientRect(),l=t.clientY-r.top,i=d();if(!i)return;let u=i.clientHeight,w=i.scrollHeight,p=l/u*(w-u);i.scrollTop=Math.max(0,Math.min(w-u,p)),s(),x(!0),v(c.delay),A()},[s,v,c.delay,d,A]),_e=(0,e.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!n.current)return;let o=Math.max(0,n.current.scrollTop-Q);n.current.scrollTop=o,s(),x(!0),v(c.delay),A()},[s,v,Q,c.delay,A]),qe=(0,e.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!n.current||!O.current)return;let o=n.current,l=O.current.scrollHeight-o.clientHeight,i=Math.min(l,o.scrollTop+Q);o.scrollTop=i,s(),x(!0),v(c.delay),A()},[s,v,Q,c.delay,A]),Ue=(0,e.useCallback)(t=>{if(!le.enabled)return;let o=t.target;if(me(o,le)||t.button!==0)return;let r=d();r&&(r.scrollHeight<=r.clientHeight||(t.preventDefault(),xe(!0),Ie({x:t.clientX,y:t.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft||0}),b()))},[le,me,d,b]),se=(0,e.useCallback)(t=>{if(!W)return;let o=d();if(!o)return;let r=Z.x-t.clientX,l=Z.y-t.clientY;if(Math.abs(l)<3&&Math.abs(r)<3)return;x(!0);let i=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,Z.scrollTop+l));o.scrollTop=i,s()},[W,Z,d,s]),ue=(0,e.useCallback)(()=>{xe(!1),F()&&v(c.delay)},[F,v,c.delay]);(0,e.useEffect)(()=>{let t=u=>{s(),b(),x(!0);let w=Te?c.delayOnWheel:c.delay;v(w),P&&P(u)},o=()=>{we(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{we(!1)},300),b(),$e(),$.current=setTimeout(()=>{x(!0),$.current=null},50)},r=[],l=d();l&&r.push(l);let i=n.current;return i&&!l&&(r.push(i),i.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(w=>{let y=w;if(y!==i&&y.classList.contains("overlay-scrollbar-container"))return;let p=y.parentElement;for(;p&&p!==i;){if(p.classList.contains("overlay-scrollbar-container")&&p!==i)return;p=p.parentElement}r.push(y)})),r.forEach(u=>{u.addEventListener("scroll",t,{passive:!0}),u.addEventListener("wheel",o,{passive:!0})}),()=>{r.forEach(u=>{u.removeEventListener("scroll",t),u.removeEventListener("wheel",o)}),z.current&&clearTimeout(z.current),$.current&&clearTimeout($.current)}},[d,s,P,b,v,c,Te]),(0,e.useEffect)(()=>{let t=r=>{let l=d();if(!l)return;let{key:i}=r,{scrollTop:u,scrollHeight:w,clientHeight:y}=l,p=w-y,J=50,C=null;switch(i){case"ArrowUp":r.preventDefault(),C=Math.max(0,u-J);break;case"ArrowDown":r.preventDefault(),C=Math.min(p,u+J);break;case"PageUp":r.preventDefault(),C=Math.max(0,u-y);break;case"PageDown":r.preventDefault(),C=Math.min(p,u+y);break;case"Home":r.preventDefault(),C=0;break;case"End":r.preventDefault(),C=p;break;default:return}if(C!==null){let de=C/p,ee=L?h*2+a.margin*4:a.margin*2,We=(y-ee-U)*de;ve(We),l.scrollTop=C,b(),x(!0),v(c.delay)}},o=n.current;if(o)return o.addEventListener("keydown",t),()=>{o.removeEventListener("keydown",t)}},[d,L,h,a.margin,U,b,v,c.delay]),(0,e.useEffect)(()=>{if(W)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",ue),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",ue)}},[W,se,ue]),(0,e.useEffect)(()=>{if(N)return document.addEventListener("mousemove",ce),document.addEventListener("mouseup",ae),()=>{document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",ae)}},[N,ce,ae]),(0,e.useEffect)(()=>{s();let t=setTimeout(()=>{s()},100);return()=>clearTimeout(t)},[s]),(0,e.useLayoutEffect)(()=>{Ae(!0),s(),!c.enabled&&F()&&x(!0)},[F,s,c.enabled]),(0,e.useEffect)(()=>{let t=new ResizeObserver(()=>{s()}),o=[];return n.current&&o.push(n.current),O.current&&o.push(O.current),k.current&&document.contains(k.current)&&o.push(k.current),o.forEach(r=>{t.observe(r)}),()=>t.disconnect()},[s]),(0,e.useEffect)(()=>{if(!n.current)return;let t=new MutationObserver(()=>{k.current=null,s()});return t.observe(n.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>t.disconnect()},[s]);let G=Math.max(Oe,h);return(0,e.useEffect)(()=>{let t="overlay-scrollbar-webkit-hide",o=document.getElementById(t);o&&o.remove();let r=document.createElement("style");return r.id=t,r.textContent=`
|
|
1
|
+
"use strict";var pe=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Xe=(m,f)=>{for(var S in f)pe(m,S,{get:f[S],enumerable:!0})},Ke=(m,f,S,M)=>{if(f&&typeof f=="object"||typeof f=="function")for(let b of Ge(f))!Je.call(m,b)&&b!==S&&pe(m,b,{get:()=>f[b],enumerable:!(M=Ye(f,b))||M.enumerable});return m};var Ze=m=>Ke(pe({},"__esModule",{value:!0}),m);var lt={};Xe(lt,{OverlayScrollbar:()=>fe,default:()=>fe});module.exports=Ze(lt);var e=require("react");var je=["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=(m,f)=>{let S=m.tagName.toLowerCase(),M=["text","password","email","number","search","tel","url","checkbox","radio"];if(S==="input"){let b=m.type;return M.includes(b)}if(["textarea","select","button"].includes(S)||["svg","path","circle","rect","line","polygon","polyline"].includes(S)||m.getAttribute("contenteditable")==="true")return!0;if(f?.excludeSelectors){for(let b of f.excludeSelectors)if(m.matches(b))return!0}return Ve(m,f)},Ve=(m,f)=>{let S=[...je,...f?.excludeClasses||[]],M=m,b=0,I=5;for(;M&&b<=I;){if(S.some(E=>M.classList.contains(E)))return!0;if(M.classList.contains("MuiDialogContent-root"))break;M=M.parentElement,b++}return!1};var D=require("react/jsx-runtime"),Qe={},et={},tt={},rt={},ot={},nt=(0,e.forwardRef)(({className:m="",style:f={},containerStyle:S={},contentStyle:M={},children:b,onScroll:I,thumb:E=Qe,track:R=et,arrows:A=tt,dragScroll:W=rt,autoHide:N=ot,showScrollbar:X=!0,detectInnerScroll:He=!1},De)=>{let ke=(0,e.useRef)({});(0,e.useEffect)(()=>{ke.current={children:b,onScroll:I,showScrollbar:X,thumb:E,track:R,arrows:A,dragScroll:W,autoHide:N}});let te=(0,e.useRef)(null),n=(0,e.useRef)(null),$=(0,e.useRef)(null),K=(0,e.useRef)(null),Le=(0,e.useRef)(null),k=(0,e.useRef)(null),[re,T]=(0,e.useState)(!1),[P,he]=(0,e.useState)(!1),[ge,be]=(0,e.useState)(!1),[oe,Ie]=(0,e.useState)({y:0,scrollTop:0}),[q,Re]=(0,e.useState)(0),[Ae,ve]=(0,e.useState)(0),[ne,ye]=(0,e.useState)(!1),[U,Te]=(0,e.useState)(!1),[Z,Oe]=(0,e.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[it,at]=(0,e.useState)(null),[j,V]=(0,e.useState)(null),[ct,Ne]=(0,e.useState)(!1),z=(0,e.useRef)(null),[xe,we]=(0,e.useState)(!1),B=(0,e.useRef)(null),Y=(0,e.useRef)(null),F=(0,e.useRef)(null),x=(0,e.useMemo)(()=>{let t=E.color??"#606060";return{width:E.width??8,minHeight:E.minHeight??50,radius:E.radius??(E.width??8)/2,color:t,opacity:E.opacity??.6,hoverColor:E.hoverColor??t,hoverOpacity:E.hoverOpacity??1}},[E]),s=(0,e.useMemo)(()=>({width:R.width??16,color:R.color??"rgba(128, 128, 128, 0.1)",visible:R.visible??!0,alignment:R.alignment??"center",radius:R.radius??x.radius??4,margin:R.margin??4}),[R,x.radius]),H=(0,e.useMemo)(()=>{let t=A.color??"#808080";return{visible:A.visible??!1,step:A.step??50,color:t,opacity:A.opacity??.6,hoverColor:A.hoverColor??t,hoverOpacity:A.hoverOpacity??1}},[A]),le=(0,e.useMemo)(()=>({enabled:W.enabled??!0,excludeClasses:W.excludeClasses??[],excludeSelectors:W.excludeSelectors??[]}),[W]),i=(0,e.useMemo)(()=>({enabled:N.enabled??!0,delay:N.delay??1500,delayOnWheel:N.delayOnWheel??700,initialDelay:N.initialDelay??0}),[N]),[Se,$e]=(0,e.useState)(()=>(N.initialDelay??0)>0),h=x.width,Pe=s.width,ie=x.minHeight,L=H.visible,Q=H.step,O=(0,e.useCallback)(()=>{if(!n.current)return;let t=document.activeElement;t&&n.current.contains(t)&&t!==n.current||n.current.focus()},[]);(0,e.useImperativeHandle)(De,()=>({getScrollContainer:()=>n.current,scrollTo:t=>{n.current&&n.current.scrollTo(t)},get scrollTop(){return n.current?.scrollTop||0},get scrollHeight(){return n.current?.scrollHeight||0},get clientHeight(){return n.current?.clientHeight||0}}),[]);let d=(0,e.useCallback)(()=>{if(k.current){let r=k.current;if(document.contains(r)&&r.scrollHeight>r.clientHeight+2)return r;k.current=null}if(!n.current)return null;if($.current&&$.current.scrollHeight>n.current.clientHeight+2)return k.current=n.current,n.current;if(!He)return null;let t=n.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let r of t){let o=r;if(o!==n.current&&o.classList.contains("overlay-scrollbar-container"))continue;let l=o.parentElement,a=!1;for(;l&&l!==n.current;){if(l.classList.contains("overlay-scrollbar-container")&&l!==n.current){a=!0;break}l=l.parentElement}if(!a&&o.scrollHeight>o.clientHeight+2)return k.current=o,o}return null},[]),_=(0,e.useCallback)(()=>d()!==null,[d]),v=(0,e.useCallback)(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),Fe=(0,e.useCallback)(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),Me=(0,e.useCallback)(()=>{F.current&&(clearTimeout(F.current),F.current=null)},[]),g=(0,e.useCallback)(t=>{i.enabled&&(v(),B.current=setTimeout(()=>{T(!1),B.current=null},t))},[v,i.enabled]),u=(0,e.useCallback)(()=>{let t=d();if(!t){T(!1),ye(!1),v();return}if(ye(!0),!K.current)return;i.enabled||(T(!0),v());let r=t.clientHeight,o=t.scrollHeight,l=t.scrollTop,a=0;if(te.current){let ee=window.getComputedStyle(te.current),Ee=parseFloat(ee.paddingTop)||0,Ce=parseFloat(ee.paddingBottom)||0;a=Ee+Ce}let c=L?h*2+s.margin*4:s.margin*2,w=r-c+a,y=r/o,p=Math.max(w*y,ie),J=o-r,C=w-p,de=J>0?l/J*C:0;Re(p),ve(de)},[d,v,L,h,ie,i.enabled]),_e=(0,e.useCallback)(t=>{t.preventDefault(),t.stopPropagation();let r=d();r&&(he(!0),Ie({y:t.clientY,scrollTop:r.scrollTop}),v(),T(!0),O())},[d,v,O]),ae=(0,e.useCallback)(t=>{if(!P)return;let r=d();if(!r)return;let o=r.clientHeight,a=r.scrollHeight-o,c=t.clientY-oe.y,w=o-q,y=c/w*a,p=Math.max(0,Math.min(a,oe.scrollTop+y));r.scrollTop=p,u()},[P,oe,q,u,d]),ce=(0,e.useCallback)(()=>{he(!1),_()&&g(i.delay)},[_,g,i.delay]),We=(0,e.useCallback)(t=>{if(!K.current)return;let o=K.current.getBoundingClientRect(),l=t.clientY-o.top,a=d();if(!a)return;let c=a.clientHeight,w=a.scrollHeight,p=l/c*(w-c);a.scrollTop=Math.max(0,Math.min(w-c,p)),u(),T(!0),g(i.delay),O()},[u,g,i.delay,d,O]),qe=(0,e.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!n.current)return;let r=Math.max(0,n.current.scrollTop-Q);n.current.scrollTop=r,u(),T(!0),g(i.delay),O()},[u,g,Q,i.delay,O]),Ue=(0,e.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!n.current||!$.current)return;let r=n.current,l=$.current.scrollHeight-r.clientHeight,a=Math.min(l,r.scrollTop+Q);r.scrollTop=a,u(),T(!0),g(i.delay),O()},[u,g,Q,i.delay,O]),ze=(0,e.useCallback)(t=>{if(!le.enabled)return;let r=t.target;if(me(r,le)||t.button!==0)return;let o=d();o&&(o.scrollHeight<=o.clientHeight||(t.preventDefault(),Te(!0),Oe({x:t.clientX,y:t.clientY,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft||0}),v()))},[le,me,d,v]),se=(0,e.useCallback)(t=>{if(!U)return;let r=d();if(!r)return;let o=Z.x-t.clientX,l=Z.y-t.clientY;if(Math.abs(l)<3&&Math.abs(o)<3)return;T(!0);let a=Math.max(0,Math.min(r.scrollHeight-r.clientHeight,Z.scrollTop+l));r.scrollTop=a,u()},[U,Z,d,u]),ue=(0,e.useCallback)(()=>{Te(!1),_()&&g(i.delay)},[_,g,i.delay]);(0,e.useEffect)(()=>{let t=c=>{if(u(),Se){I&&I(c);return}v(),T(!0),Me();let w=xe?i.delayOnWheel:i.delay;g(w),I&&I(c)},r=()=>{we(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{we(!1)},300),Me(),F.current=setTimeout(()=>{T(!0),F.current=null,g(i.delayOnWheel)},50)},o=[],l=d();l&&o.push(l);let a=n.current;return a&&!l&&(o.push(a),a.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(w=>{let y=w;if(y!==a&&y.classList.contains("overlay-scrollbar-container"))return;let p=y.parentElement;for(;p&&p!==a;){if(p.classList.contains("overlay-scrollbar-container")&&p!==a)return;p=p.parentElement}o.push(y)})),o.forEach(c=>{c.addEventListener("scroll",t,{passive:!0}),c.addEventListener("wheel",r,{passive:!0})}),()=>{o.forEach(c=>{c.removeEventListener("scroll",t),c.removeEventListener("wheel",r)}),z.current&&clearTimeout(z.current),F.current&&clearTimeout(F.current)}},[d,u,I,v,g,i,xe,Se]),(0,e.useEffect)(()=>{let t=o=>{let l=d();if(!l)return;let{key:a}=o,{scrollTop:c,scrollHeight:w,clientHeight:y}=l,p=w-y,J=50,C=null;switch(a){case"ArrowUp":o.preventDefault(),C=Math.max(0,c-J);break;case"ArrowDown":o.preventDefault(),C=Math.min(p,c+J);break;case"PageUp":o.preventDefault(),C=Math.max(0,c-y);break;case"PageDown":o.preventDefault(),C=Math.min(p,c+y);break;case"Home":o.preventDefault(),C=0;break;case"End":o.preventDefault(),C=p;break;default:return}if(C!==null){let de=C/p,ee=L?h*2+s.margin*4:s.margin*2,Be=(y-ee-q)*de;ve(Be),l.scrollTop=C,v(),T(!0),g(i.delay)}},r=n.current;if(r)return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}},[d,L,h,s.margin,q,v,g,i.delay]),(0,e.useEffect)(()=>{if(U)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",ue),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",ue)}},[U,se,ue]),(0,e.useEffect)(()=>{if(P)return document.addEventListener("mousemove",ae),document.addEventListener("mouseup",ce),()=>{document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",ce)}},[P,ae,ce]),(0,e.useEffect)(()=>{u();let t=setTimeout(()=>{u()},100);return()=>clearTimeout(t)},[u]),(0,e.useLayoutEffect)(()=>{Ne(!0),u(),!i.enabled&&_()&&T(!0)},[_,u,i.enabled]),(0,e.useEffect)(()=>{if(i.initialDelay>0){let t=setTimeout(()=>{$e(!1)},i.initialDelay);return()=>clearTimeout(t)}},[i.initialDelay]),(0,e.useEffect)(()=>{let t=new ResizeObserver(()=>{u()}),r=[];return n.current&&r.push(n.current),$.current&&r.push($.current),k.current&&document.contains(k.current)&&r.push(k.current),r.forEach(o=>{t.observe(o)}),()=>t.disconnect()},[u]),(0,e.useEffect)(()=>{if(!n.current)return;let t=new MutationObserver(()=>{k.current=null,u()});return t.observe(n.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>t.disconnect()},[u]);let G=Math.max(Pe,h);return(0,e.useEffect)(()=>{let t="overlay-scrollbar-webkit-hide",r=document.getElementById(t);r&&r.remove();let o=document.createElement("style");return o.id=t,o.textContent=`
|
|
2
2
|
.overlay-scrollbar-container::-webkit-scrollbar {
|
|
3
3
|
display: none !important;
|
|
4
4
|
width: 0 !important;
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
outline: 2px solid rgba(0, 123, 255, 0.5);
|
|
19
19
|
outline-offset: -2px;
|
|
20
20
|
}
|
|
21
|
-
`,document.head.appendChild(
|
|
21
|
+
`,document.head.appendChild(o),()=>{let l=document.getElementById(t);l&&l.remove()}},[]),(0,D.jsxs)("div",{ref:te,className:`overlay-scrollbar-wrapper ${m}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...f},children:[(0,D.jsx)("div",{ref:n,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:ze,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:U?"none":"auto",...S},children:(0,D.jsx)("div",{ref:$,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...M},children:b})}),X&&ne&&(0,D.jsxs)("div",{ref:K,className:"overlay-scrollbar-track",onMouseEnter:()=>{v(),Y.current=setTimeout(()=>{T(!0),Y.current=null},100)},onMouseLeave:()=>{Fe(),P||g(i.delay)},style:{position:"absolute",top:0,right:0,width:`${G}px`,height:"100%",opacity:re?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[s.visible&&(0,D.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:t=>{t.preventDefault(),t.stopPropagation(),We(t)},style:{position:"absolute",top:L?`${x.width+s.margin*2}px`:`${s.margin}px`,right:s.alignment==="right"?"0px":`${(G-x.width)/2}px`,width:`${x.width}px`,height:L?`calc(100% - ${x.width*2+s.margin*4}px)`:`calc(100% - ${s.margin*2}px)`,backgroundColor:s.color,borderRadius:`${s.radius}px`,cursor:"pointer"}}),(0,D.jsx)("div",{ref:Le,className:"overlay-scrollbar-thumb",onMouseDown:_e,onMouseEnter:()=>be(!0),onMouseLeave:()=>be(!1),style:{position:"absolute",top:`${(L?h+s.margin*2:s.margin)+Ae}px`,right:s.alignment==="right"?"0px":`${(G-h)/2}px`,width:`${h}px`,height:`${Math.max(q,ie)}px`,backgroundColor:ge||P?x.hoverColor:x.color,opacity:ge||P?x.hoverOpacity:x.opacity,borderRadius:`${x.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),X&&ne&&L&&(0,D.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:qe,onMouseEnter:()=>V("up"),onMouseLeave:()=>V(null),style:{position:"absolute",top:`${s.margin}px`,right:s.alignment==="right"?"0px":`${(G-h)/2}px`,width:`${h}px`,height:`${h}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(h*.75,8)}px`,color:j==="up"?H.hoverColor:H.color,userSelect:"none",zIndex:1001,opacity:re?j==="up"?H.hoverOpacity:H.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),X&&ne&&L&&(0,D.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:Ue,onMouseEnter:()=>V("down"),onMouseLeave:()=>V(null),style:{position:"absolute",bottom:`${s.margin}px`,right:s.alignment==="right"?"0px":`${(G-h)/2}px`,width:`${h}px`,height:`${h}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(h*.75,8)}px`,color:j==="down"?H.hoverColor:H.color,userSelect:"none",zIndex:1001,opacity:re?j==="down"?H.hoverOpacity:H.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),fe=nt;
|
|
22
22
|
//# sourceMappingURL=index.js.map
|