|
|
import{d as ge,a0 as Ue,a1 as Ve,s as u,c as d,E as ke,v as Fe,S as Ae,G as b,F as Ne,T as he,m as Ge}from"./index-bVOhw2NF.js";import{y as qe,c as O,b as R,d as Z,a as _,f as we,u as Je,h as Ke}from"./light-Cua7cqmF.js";import{f as Qe}from"./fade-in.cssr-CltBGdAW.js";import{u as Ze}from"./use-rtl-CRyak7TN.js";import{g as en,d as ve}from"./index-C-nsH7mf.js";import{a as $,o as j}from"./delegate-CI_DDEu_.js";import{V as be}from"./VResizeObserver-Tzd5ds8d.js";import{g as nn}from"./get-precise-event-target-DhO46Lpt.js";const me=ge({render(){var l,a;return(a=(l=this.$slots).default)===null||a===void 0?void 0:a.call(l)}});function tn(l){const{left:a,right:s,top:p,bottom:o}=en(l);return`${p} ${s} ${o} ${a}`}const ln=(typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.platform)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)&&!window.MSStream;function on(){return ln}function rn(l){const a={isDeactivated:!1};let s=!1;return Ue(()=>{if(a.isDeactivated=!1,!s){s=!0;return}l()}),Ve(()=>{a.isDeactivated=!0,s||(s=!0)}),a}const an={railInsetHorizontal:"auto 2px 4px 2px",railInsetVertical:"2px 4px 2px auto",railColor:"transparent"};function sn(l){const{scrollbarColor:a,scrollbarColorHover:s,scrollbarHeight:p,scrollbarWidth:o,scrollbarBorderRadius:x}=l;return Object.assign(Object.assign({},an),{height:p,width:o,borderRadius:x,color:a,colorHover:s})}const cn={name:"Scrollbar",common:qe,self:sn},un=O("scrollbar",`
overflow: hidden; position: relative; z-index: auto; height: 100%; width: 100%;`,[R(">",[O("scrollbar-container",` width: 100%; overflow: scroll; height: 100%; min-height: inherit; max-height: inherit; scrollbar-width: none; `,[R("&::-webkit-scrollbar, &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb",` width: 0; height: 0; display: none; `),R(">",[O("scrollbar-content",` box-sizing: border-box; min-width: 100%; `)])])]),R(">, +",[O("scrollbar-rail",` position: absolute; pointer-events: none; user-select: none; background: var(--n-scrollbar-rail-color); -webkit-user-select: none; `,[Z("horizontal",` inset: var(--n-scrollbar-rail-inset-horizontal); height: var(--n-scrollbar-height); `,[R(">",[_("scrollbar",` height: var(--n-scrollbar-height); border-radius: var(--n-scrollbar-border-radius); right: 0; `)])]),Z("vertical",` inset: var(--n-scrollbar-rail-inset-vertical); width: var(--n-scrollbar-width); `,[R(">",[_("scrollbar",` width: var(--n-scrollbar-width); border-radius: var(--n-scrollbar-border-radius); bottom: 0; `)])]),Z("disabled",[R(">",[_("scrollbar","pointer-events: none;")])]),R(">",[_("scrollbar",` z-index: 1; position: absolute; cursor: pointer; pointer-events: all; background-color: var(--n-scrollbar-color); transition: background-color .2s var(--n-scrollbar-bezier); `,[Qe(),R("&:hover","background-color: var(--n-scrollbar-color-hover);")])])])])]),dn=Object.assign(Object.assign({},we.props),{duration:{type:Number,default:0},scrollable:{type:Boolean,default:!0},xScrollable:Boolean,trigger:{type:String,default:"hover"},useUnifiedContainer:Boolean,triggerDisplayManually:Boolean,container:Function,content:Function,containerClass:String,containerStyle:[String,Object],contentClass:[String,Array],contentStyle:[String,Object],horizontalRailStyle:[String,Object],verticalRailStyle:[String,Object],onScroll:Function,onWheel:Function,onResize:Function,internalOnUpdateScrollLeft:Function,internalHoistYRail:Boolean}),fn=ge({name:"Scrollbar",props:dn,inheritAttrs:!1,setup(l){const{mergedClsPrefixRef:a,inlineThemeDisabled:s,mergedRtlRef:p}=Je(l),o=Ze("Scrollbar",p,a),x=u(null),B=u(null),L=u(null),y=u(null),T=u(null),h=u(null),v=u(null),P=u(null),C=u(null),E=u(null),I=u(null),W=u(0),Y=u(0),U=u(!1),V=u(!1);let k=!1,F=!1,m,g,ee=0,ne=0,A=0,te=0;const Se=on(),N=we("Scrollbar","-scrollbar",un,cn,l,a),G=d(()=>{const{value:e}=P,{value:n}=h,{value:t}=E;return e===null||n===null||t===null?0:Math.min(e,t*e/n+ve(N.value.self.width)*1.5)}),Re=d(()=>`${G.value}px`),q=d(()=>{const{value:e}=C,{value:n}=v,{value:t}=I;return e===null||n===null||t===null?0:t*e/n+ve(N.value.self.height)*1.5}),pe=d(()=>`${q.value}px`),xe=d(()=>{const{value:e}=P,{value:n}=W,{value:t}=h,{value:r}=E;if(e===null||t===null||r===null)return 0;{const c=t-e;return c?n/c*(r-G.value):0}}),Be=d(()=>`${xe.value}px`),ye=d(()=>{const{value:e}=C,{value:n}=Y,{value:t}=v,{value:r}=I;if(e===null||t===null||r===null)return 0;{const c=t-e;return c?n/c*(r-q.value):0}}),Te=d(()=>`${ye.value}px`),le=d(()=>{const{value:e}=P,{value:n}=h;return e!==null&&n!==null&&n>e}),oe=d(()=>{const{value:e}=C,{value:n}=v;return e!==null&&n!==null&&n>e}),ze=d(()=>{const{trigger:e}=l;return e==="none"||U.value}),Me=d(()=>{const{trigger:e}=l;return e==="none"||V.value}),z=d(()=>{const{container:e}=l;return e?e():B.value}),Pe=d(()=>{const{content:e}=l;return e?e():L.value}),re=(e,n)=>{if(!l.scrollable)return;if(typeof e=="number"){H(e,n??0,0,!1,"auto");return}const{left:t,top:r,index:c,elSize:f,position:w,behavior:i,el:S,debounce:D=!0}=e;(t!==void 0||r!==void 0)&&H(t??0,r??0,0,!1,i),S!==void 0?H(0,S.offsetTop,S.offsetHeight,D,i):c!==void 0&&f!==void 0?H(0,c*f,f,D,i):w==="bottom"?H(0,Number.MAX_SAFE_INTEGER,0,!1,i):w==="top"&&H(0,0,0,!1,i)},ie=rn(()=>{l.container||re({top:W.value,left:Y.value})}),Ce=()=>{ie.isDeactivated||M()},We=e=>{if(ie.isDeactivated)return;const{onResize:n}=l;n&&n(e),M()},He=(e,n)=>{if(!l.scrollable)return;const{value:t}=z;t&&(typeof e=="object"?t.scrollBy(e):t.scrollBy(e,n||0))};function H(e,n,t,r,c){const{value:f}=z;if(f){if(r){const{scrollTop:w,offsetHeight:i}=f;if(n>w){n+t<=w+i||f.scrollTo({left:e,top:n+t-i,behavior:c});return}}f.scrollTo({left:e,top:n,behavior:c})}}function Xe(){De(),Ee(),M()}function $e(){J()}function J(){Le(),Ye()}function Le(){g!==void 0&&window.clearTimeout(g),g=window.setTimeout(()=>{V.value=!1},l.duration)}function Ye(){m!==void 0&&window.clearTimeout(m),m=window.setTimeout(()=>{U.value=!1},l.duration)}function De(){m!==void 0&&window.clearTimeout(m),U.value=!0}function Ee(){g!==void 0&&window.clearTimeout(g),V.value=!0}function Ie(e){const{onScroll:n}=l;n&&n(e),ae()}function ae(){const{value:e}=z;e&&(W.value=e.scrollTop,Y.value=e.scrollLeft*(o!=null&&o.value?-1:1))}function Oe(){const{value:e}=Pe;e&&(h.value=e.offsetHeight,v.value=e.offsetWidth);const{value:n}=z;n&&(P.value=n.offsetHeight,C.value=n.offsetWidth);const{value:t}=T,{value:r}=y;t&&(I.value=t.offsetWidth),r&&(E.value=r.offsetHeight)}function se(){const{value:e}=z;e&&(W.value=e.scrollTop,Y.value=e.scrollLeft*(o!=null&&o.value?-1:1),P.value=e.offsetHeight,C.value=e.offsetWidth,h.value=e.scrollHeight,v.value=e.scrollWidth);const{value:n}=T,{value:t}=y;n&&(I.value=n.offsetWidth),t&&(E.value=t.offsetHeight)}function M(){l.scrollable&&(l.useUnifiedContainer?se():(Oe(),ae()))}function ce(e){var n;return!(!((n=x.value)===null||n===void 0)&&n.contains(nn(e)))}function _e(e){e.
|