You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
15 KiB
51 lines
15 KiB
import{d as He,aH as Ne,ej as Ve,r as R,f as x,G as Ae,P as Ge,b3 as qe,a8 as z,F as Je,bi as Se,aP as Ke}from"./index-f4658ae7.js";import{k as Qe,c as y,a as Ze,e as ie,f as de,g as le,b as Be}from"./light-0dfdc1ad.js";import{u as en}from"./use-config-816d55a6.js";import{u as nn}from"./use-rtl-889b67fe.js";import{u as tn}from"./use-css-vars-class-3ae3b4b3.js";import{V as Re}from"./VResizeObserver-e3ad0bab.js";function on(n){return n.composedPath()[0]||null}const xe=He({render(){var n,a;return(a=(n=this.$slots).default)===null||a===void 0?void 0:a.call(n)}});function ae(n){return n.composedPath()[0]}const rn={mousemoveoutside:new WeakMap,clickoutside:new WeakMap};function ln(n,a,s){if(n==="mousemoveoutside"){const f=l=>{a.contains(ae(l))||s(l)};return{mousemove:f,touchstart:f}}else if(n==="clickoutside"){let f=!1;const l=g=>{f=!a.contains(ae(g))},h=g=>{f&&(a.contains(ae(g))||s(g))};return{mousedown:l,mouseup:h,touchstart:l,touchend:h}}return{}}function ye(n,a,s){const f=rn[n];let l=f.get(a);l===void 0&&f.set(a,l=new WeakMap);let h=l.get(s);return h===void 0&&l.set(s,h=ln(n,a,s)),h}function an(n,a,s,f){if(n==="mousemoveoutside"||n==="clickoutside"){const l=ye(n,a,s);return Object.keys(l).forEach(h=>{oe(h,document,l[h],f)}),!0}return!1}function sn(n,a,s,f){if(n==="mousemoveoutside"||n==="clickoutside"){const l=ye(n,a,s);return Object.keys(l).forEach(h=>{q(h,document,l[h],f)}),!0}return!1}function cn(){if(typeof window=="undefined")return{on:()=>{},off:()=>{}};const n=new WeakMap,a=new WeakMap;function s(){n.set(this,!0)}function f(){n.set(this,!0),a.set(this,!0)}function l(t,o,c){const u=t[o];return t[o]=function(){return c.apply(t,arguments),u.apply(t,arguments)},t}function h(t,o){t[o]=Event.prototype[o]}const g=new WeakMap,O=Object.getOwnPropertyDescriptor(Event.prototype,"currentTarget");function C(){var t;return(t=g.get(this))!==null&&t!==void 0?t:null}function M(t,o){O!==void 0&&Object.defineProperty(t,"currentTarget",{configurable:!0,enumerable:!0,get:o!=null?o:O.get})}const m={bubble:{},capture:{}},p={};function I(){const t=function(o){const{type:c,eventPhase:u,bubbles:b}=o,P=ae(o);if(u===2)return;const E=u===1?"capture":"bubble";let H=P;const S=[];for(;H===null&&(H=window),S.push(H),H!==window;)H=H.parentNode||null;const W=m.capture[c],k=m.bubble[c];if(l(o,"stopPropagation",s),l(o,"stopImmediatePropagation",f),M(o,C),E==="capture"){if(W===void 0)return;for(let $=S.length-1;$>=0&&!n.has(o);--$){const U=S[$],V=W.get(U);if(V!==void 0){g.set(o,U);for(const X of V){if(a.has(o))break;X(o)}}if($===0&&!b&&k!==void 0){const X=k.get(U);if(X!==void 0)for(const re of X){if(a.has(o))break;re(o)}}}}else if(E==="bubble"){if(k===void 0)return;for(let $=0;$<S.length&&!n.has(o);++$){const U=S[$],V=k.get(U);if(V!==void 0){g.set(o,U);for(const X of V){if(a.has(o))break;X(o)}}}}h(o,"stopPropagation"),h(o,"stopImmediatePropagation"),M(o)};return t.displayName="evtdUnifiedHandler",t}function j(){const t=function(o){const{type:c,eventPhase:u}=o;if(u!==2)return;const b=p[c];b!==void 0&&b.forEach(P=>P(o))};return t.displayName="evtdUnifiedWindowEventHandler",t}const _=I(),F=j();function L(t,o){const c=m[t];return c[o]===void 0&&(c[o]=new Map,window.addEventListener(o,_,t==="capture")),c[o]}function N(t){return p[t]===void 0&&(p[t]=new Set,window.addEventListener(t,F)),p[t]}function J(t,o){let c=t.get(o);return c===void 0&&t.set(o,c=new Set),c}function Z(t,o,c,u){const b=m[o][c];if(b!==void 0){const P=b.get(t);if(P!==void 0&&P.has(u))return!0}return!1}function ee(t,o){const c=p[t];return!!(c!==void 0&&c.has(o))}function ne(t,o,c,u){let b;if(typeof u=="object"&&u.once===!0?b=W=>{T(t,o,b,u),c(W)}:b=c,an(t,o,b,u))return;const E=u===!0||typeof u=="object"&&u.capture===!0?"capture":"bubble",H=L(E,t),S=J(H,o);if(S.has(b)||S.add(b),o===window){const W=N(t);W.has(b)||W.add(b)}}function T(t,o,c,u){if(sn(t,o,c,u))return;const P=u===!0||typeof u=="object"&&u.capture===!0,E=P?"capture":"bubble",H=L(E,t),S=J(H,o);if(o===window&&!Z(o,P?"bubble":"capture",t,c)&&ee(t,c)){const k=p[t];k.delete(c),k.size===0&&(window.removeEventListener(t,F),p[t]=void 0)}S.has(c)&&S.delete(c),S.size===0&&H.delete(o),H.size===0&&(window.removeEventListener(t,_,E==="capture"),m[E][t]=void 0)}return{on:ne,off:T}}const{on:oe,off:q}=cn(),un=(typeof window=="undefined"?!1:/iPad|iPhone|iPod/.test(navigator.platform)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)&&!window.MSStream;function dn(){return un}function fn(n){const a={isDeactivated:!1};let s=!1;return Ne(()=>{if(a.isDeactivated=!1,!s){s=!0;return}n()}),Ve(()=>{a.isDeactivated=!0,s||(s=!0)}),a}const hn=n=>{const{scrollbarColor:a,scrollbarColorHover:s}=n;return{color:a,colorHover:s}},vn={name:"Scrollbar",common:Qe,self:hn},bn=vn,{cubicBezierEaseInOut:Te}=Ze;function wn({name:n="fade-in",enterDuration:a="0.2s",leaveDuration:s="0.2s",enterCubicBezier:f=Te,leaveCubicBezier:l=Te}={}){return[y(`&.${n}-transition-enter-active`,{transition:`all ${a} ${f}!important`}),y(`&.${n}-transition-leave-active`,{transition:`all ${s} ${l}!important`}),y(`&.${n}-transition-enter-from, &.${n}-transition-leave-to`,{opacity:0}),y(`&.${n}-transition-leave-from, &.${n}-transition-enter-to`,{opacity:1})]}const mn=ie("scrollbar",`
|
|
overflow: hidden;
|
|
position: relative;
|
|
z-index: auto;
|
|
height: 100%;
|
|
width: 100%;
|
|
`,[y(">",[ie("scrollbar-container",`
|
|
width: 100%;
|
|
overflow: scroll;
|
|
height: 100%;
|
|
min-height: inherit;
|
|
max-height: inherit;
|
|
scrollbar-width: none;
|
|
`,[y("&::-webkit-scrollbar, &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb",`
|
|
width: 0;
|
|
height: 0;
|
|
display: none;
|
|
`),y(">",[ie("scrollbar-content",`
|
|
box-sizing: border-box;
|
|
min-width: 100%;
|
|
`)])])]),y(">, +",[ie("scrollbar-rail",`
|
|
position: absolute;
|
|
pointer-events: none;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
`,[de("horizontal",`
|
|
left: 2px;
|
|
right: 2px;
|
|
bottom: 4px;
|
|
height: var(--n-scrollbar-height);
|
|
`,[y(">",[le("scrollbar",`
|
|
height: var(--n-scrollbar-height);
|
|
border-radius: var(--n-scrollbar-border-radius);
|
|
right: 0;
|
|
`)])]),de("vertical",`
|
|
right: 4px;
|
|
top: 2px;
|
|
bottom: 2px;
|
|
width: var(--n-scrollbar-width);
|
|
`,[y(">",[le("scrollbar",`
|
|
width: var(--n-scrollbar-width);
|
|
border-radius: var(--n-scrollbar-border-radius);
|
|
bottom: 0;
|
|
`)])]),de("disabled",[y(">",[le("scrollbar",{pointerEvents:"none"})])]),y(">",[le("scrollbar",`
|
|
position: absolute;
|
|
cursor: pointer;
|
|
pointer-events: all;
|
|
background-color: var(--n-scrollbar-color);
|
|
transition: background-color .2s var(--n-scrollbar-bezier);
|
|
`,[wn(),y("&:hover",{backgroundColor:"var(--n-scrollbar-color-hover)"})])])])])]),pn=Object.assign(Object.assign({},Be.props),{size:{type:Number,default:5},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,contentStyle:[String,Object],horizontalRailStyle:[String,Object],verticalRailStyle:[String,Object],onScroll:Function,onWheel:Function,onResize:Function,internalOnUpdateScrollLeft:Function,internalHoistYRail:Boolean}),Pe=He({name:"Scrollbar",props:pn,inheritAttrs:!1,setup(n){const{mergedClsPrefixRef:a,inlineThemeDisabled:s,mergedRtlRef:f}=en(n),l=nn("Scrollbar",f,a),h=R(null),g=R(null),O=R(null),C=R(null),M=R(null),m=R(null),p=R(null),I=R(null),j=R(null),_=R(null),F=R(null),L=R(0),N=R(0),J=R(!1),Z=R(!1);let ee=!1,ne=!1,T,t,o=0,c=0,u=0,b=0;const P=dn(),E=x(()=>{const{value:e}=I,{value:r}=m,{value:i}=_;return e===null||r===null||i===null?0:Math.min(e,i*e/r+n.size*1.5)}),H=x(()=>`${E.value}px`),S=x(()=>{const{value:e}=j,{value:r}=p,{value:i}=F;return e===null||r===null||i===null?0:i*e/r+n.size*1.5}),W=x(()=>`${S.value}px`),k=x(()=>{const{value:e}=I,{value:r}=L,{value:i}=m,{value:d}=_;if(e===null||i===null||d===null)return 0;{const w=i-e;return w?r/w*(d-E.value):0}}),$=x(()=>`${k.value}px`),U=x(()=>{const{value:e}=j,{value:r}=N,{value:i}=p,{value:d}=F;if(e===null||i===null||d===null)return 0;{const w=i-e;return w?r/w*(d-S.value):0}}),V=x(()=>`${U.value}px`),X=x(()=>{const{value:e}=I,{value:r}=m;return e!==null&&r!==null&&r>e}),re=x(()=>{const{value:e}=j,{value:r}=p;return e!==null&&r!==null&&r>e}),Ee=x(()=>{const{trigger:e}=n;return e==="none"||J.value}),ze=x(()=>{const{trigger:e}=n;return e==="none"||Z.value}),A=x(()=>{const{container:e}=n;return e?e():g.value}),Me=x(()=>{const{content:e}=n;return e?e():O.value}),fe=fn(()=>{n.container||he({top:L.value,left:N.value})}),We=()=>{fe.isDeactivated||G()},$e=e=>{if(fe.isDeactivated)return;const{onResize:r}=n;r&&r(e),G()},he=(e,r)=>{if(!n.scrollable)return;if(typeof e=="number"){K(r!=null?r:0,e,0,!1,"auto");return}const{left:i,top:d,index:w,elSize:B,position:D,behavior:v,el:Y,debounce:te=!0}=e;(i!==void 0||d!==void 0)&&K(i!=null?i:0,d!=null?d:0,0,!1,v),Y!==void 0?K(0,Y.offsetTop,Y.offsetHeight,te,v):w!==void 0&&B!==void 0?K(0,w*B,B,te,v):D==="bottom"?K(0,Number.MAX_SAFE_INTEGER,0,!1,v):D==="top"&&K(0,0,0,!1,v)},Ce=(e,r)=>{if(!n.scrollable)return;const{value:i}=A;i&&(typeof e=="object"?i.scrollBy(e):i.scrollBy(e,r||0))};function K(e,r,i,d,w){const{value:B}=A;if(B){if(d){const{scrollTop:D,offsetHeight:v}=B;if(r>D){r+i<=D+v||B.scrollTo({left:e,top:r+i-v,behavior:w});return}}B.scrollTo({left:e,top:r,behavior:w})}}function Le(){Ye(),Oe(),G()}function ke(){se()}function se(){Xe(),De()}function Xe(){t!==void 0&&window.clearTimeout(t),t=window.setTimeout(()=>{Z.value=!1},n.duration)}function De(){T!==void 0&&window.clearTimeout(T),T=window.setTimeout(()=>{J.value=!1},n.duration)}function Ye(){T!==void 0&&window.clearTimeout(T),J.value=!0}function Oe(){t!==void 0&&window.clearTimeout(t),Z.value=!0}function Ie(e){const{onScroll:r}=n;r&&r(e),ve()}function ve(){const{value:e}=A;e&&(L.value=e.scrollTop,N.value=e.scrollLeft*(l!=null&&l.value?-1:1))}function je(){const{value:e}=Me;e&&(m.value=e.offsetHeight,p.value=e.offsetWidth);const{value:r}=A;r&&(I.value=r.offsetHeight,j.value=r.offsetWidth);const{value:i}=M,{value:d}=C;i&&(F.value=i.offsetWidth),d&&(_.value=d.offsetHeight)}function be(){const{value:e}=A;e&&(L.value=e.scrollTop,N.value=e.scrollLeft*(l!=null&&l.value?-1:1),I.value=e.offsetHeight,j.value=e.offsetWidth,m.value=e.scrollHeight,p.value=e.scrollWidth);const{value:r}=M,{value:i}=C;r&&(F.value=r.offsetWidth),i&&(_.value=i.offsetHeight)}function G(){n.scrollable&&(n.useUnifiedContainer?be():(je(),ve()))}function we(e){var r;return!(!((r=h.value)===null||r===void 0)&&r.contains(on(e)))}function Ue(e){e.preventDefault(),e.stopPropagation(),ne=!0,oe("mousemove",window,me,!0),oe("mouseup",window,pe,!0),c=N.value,u=l!=null&&l.value?window.innerWidth-e.clientX:e.clientX}function me(e){if(!ne)return;T!==void 0&&window.clearTimeout(T),t!==void 0&&window.clearTimeout(t);const{value:r}=j,{value:i}=p,{value:d}=S;if(r===null||i===null)return;const B=(l!=null&&l.value?window.innerWidth-e.clientX-u:e.clientX-u)*(i-r)/(r-d),D=i-r;let v=c+B;v=Math.min(D,v),v=Math.max(v,0);const{value:Y}=A;if(Y){Y.scrollLeft=v*(l!=null&&l.value?-1:1);const{internalOnUpdateScrollLeft:te}=n;te&&te(v)}}function pe(e){e.preventDefault(),e.stopPropagation(),q("mousemove",window,me,!0),q("mouseup",window,pe,!0),ne=!1,G(),we(e)&&se()}function _e(e){e.preventDefault(),e.stopPropagation(),ee=!0,oe("mousemove",window,ce,!0),oe("mouseup",window,ue,!0),o=L.value,b=e.clientY}function ce(e){if(!ee)return;T!==void 0&&window.clearTimeout(T),t!==void 0&&window.clearTimeout(t);const{value:r}=I,{value:i}=m,{value:d}=E;if(r===null||i===null)return;const B=(e.clientY-b)*(i-r)/(r-d),D=i-r;let v=o+B;v=Math.min(D,v),v=Math.max(v,0);const{value:Y}=A;Y&&(Y.scrollTop=v)}function ue(e){e.preventDefault(),e.stopPropagation(),q("mousemove",window,ce,!0),q("mouseup",window,ue,!0),ee=!1,G(),we(e)&&se()}Ae(()=>{const{value:e}=re,{value:r}=X,{value:i}=a,{value:d}=M,{value:w}=C;d&&(e?d.classList.remove(`${i}-scrollbar-rail--disabled`):d.classList.add(`${i}-scrollbar-rail--disabled`)),w&&(r?w.classList.remove(`${i}-scrollbar-rail--disabled`):w.classList.add(`${i}-scrollbar-rail--disabled`))}),Ge(()=>{n.container||G()}),qe(()=>{T!==void 0&&window.clearTimeout(T),t!==void 0&&window.clearTimeout(t),q("mousemove",window,ce,!0),q("mouseup",window,ue,!0)});const Fe=Be("Scrollbar","-scrollbar",mn,bn,n,a),ge=x(()=>{const{common:{cubicBezierEaseInOut:e,scrollbarBorderRadius:r,scrollbarHeight:i,scrollbarWidth:d},self:{color:w,colorHover:B}}=Fe.value;return{"--n-scrollbar-bezier":e,"--n-scrollbar-color":w,"--n-scrollbar-color-hover":B,"--n-scrollbar-border-radius":r,"--n-scrollbar-width":d,"--n-scrollbar-height":i}}),Q=s?tn("scrollbar",void 0,ge,n):void 0;return Object.assign(Object.assign({},{scrollTo:he,scrollBy:Ce,sync:G,syncUnifiedContainer:be,handleMouseEnterWrapper:Le,handleMouseLeaveWrapper:ke}),{mergedClsPrefix:a,rtlEnabled:l,containerScrollTop:L,wrapperRef:h,containerRef:g,contentRef:O,yRailRef:C,xRailRef:M,needYBar:X,needXBar:re,yBarSizePx:H,xBarSizePx:W,yBarTopPx:$,xBarLeftPx:V,isShowXBar:Ee,isShowYBar:ze,isIos:P,handleScroll:Ie,handleContentResize:We,handleContainerResize:$e,handleYScrollMouseDown:_e,handleXScrollMouseDown:Ue,cssVars:s?void 0:ge,themeClass:Q==null?void 0:Q.themeClass,onRender:Q==null?void 0:Q.onRender})},render(){var n;const{$slots:a,mergedClsPrefix:s,triggerDisplayManually:f,rtlEnabled:l,internalHoistYRail:h}=this;if(!this.scrollable)return(n=a.default)===null||n===void 0?void 0:n.call(a);const g=this.trigger==="none",O=m=>z("div",{ref:"yRailRef",class:[`${s}-scrollbar-rail`,`${s}-scrollbar-rail--vertical`],"data-scrollbar-rail":!0,style:[m||"",this.verticalRailStyle],"aria-hiddens":!0},z(g?xe:Se,g?null:{name:"fade-in-transition"},{default:()=>this.needYBar&&this.isShowYBar&&!this.isIos?z("div",{class:`${s}-scrollbar-rail__scrollbar`,style:{height:this.yBarSizePx,top:this.yBarTopPx},onMousedown:this.handleYScrollMouseDown}):null})),C=()=>{var m,p;return(m=this.onRender)===null||m===void 0||m.call(this),z("div",Ke(this.$attrs,{role:"none",ref:"wrapperRef",class:[`${s}-scrollbar`,this.themeClass,l&&`${s}-scrollbar--rtl`],style:this.cssVars,onMouseenter:f?void 0:this.handleMouseEnterWrapper,onMouseleave:f?void 0:this.handleMouseLeaveWrapper}),[this.container?(p=a.default)===null||p===void 0?void 0:p.call(a):z("div",{role:"none",ref:"containerRef",class:[`${s}-scrollbar-container`,this.containerClass],style:this.containerStyle,onScroll:this.handleScroll,onWheel:this.onWheel},z(Re,{onResize:this.handleContentResize},{default:()=>z("div",{ref:"contentRef",role:"none",style:[{width:this.xScrollable?"fit-content":null},this.contentStyle],class:[`${s}-scrollbar-content`,this.contentClass]},a)})),h?null:O(void 0),this.xScrollable&&z("div",{ref:"xRailRef",class:[`${s}-scrollbar-rail`,`${s}-scrollbar-rail--horizontal`],style:this.horizontalRailStyle,"data-scrollbar-rail":!0,"aria-hidden":!0},z(g?xe:Se,g?null:{name:"fade-in-transition"},{default:()=>this.needXBar&&this.isShowXBar&&!this.isIos?z("div",{class:`${s}-scrollbar-rail__scrollbar`,style:{width:this.xBarSizePx,right:l?this.xBarLeftPx:void 0,left:l?void 0:this.xBarLeftPx},onMousedown:this.handleXScrollMouseDown}):null}))])},M=this.container?C():z(Re,{onResize:this.handleContainerResize},{default:C});return h?z(Je,null,M,O(this.cssVars)):M}}),yn=Pe,Pn=Pe;export{yn as N,xe as W,Pn as X,oe as a,wn as f,on as g,q as o,bn as s};
|