|
|
import{d as J,s as E,G as d,i as Re,c as q,m as pt,F as ut,t as te,v as vt,P as ht,O as k,E as gt,Q as ae,y as mt,z as xt,U as yt,X as wt}from"./index-bVOhw2NF.js";import{c as St}from"./context-KbjOeZY_.js";import{E as Ct,v as Rt,c as r,d as i,b as S,a as A,e as Tt,u as zt,f as Te,g as j,h as $t}from"./light-Cua7cqmF.js";import{N as Pt}from"./Icon-Ck7Ij_E6.js";import{A as _t}from"./Add-CgLKrdZy.js";import{r as Wt}from"./render-BxFg9-7m.js";import{N as Lt}from"./Close-D6FODkWY.js";import{o as Et}from"./omit-DbnPTcif.js";import{t as At}from"./light-B52QuVq1.js";import{u as ge}from"./use-compitable-DMmt6sIs.js";import{f as re}from"./flatten-7z_8MaI9.js";import{u as Bt}from"./use-merged-state-CzrzZJbg.js";import{x as kt,i as ze}from"./_initCloneObject-K-Y0ueWp.js";import{t as me}from"./toNumber-C7_OyJEx.js";import{c as jt,a as xe,o as Ht}from"./cssr-CS9sbUmO.js";import{g as Y,d as It}from"./index-C-nsH7mf.js";import{r as ye}from"./resolve-slot-Dzko3qih.js";import{V as ne}from"./VResizeObserver-Tzd5ds8d.js";import{c as K}from"./call-f2ri57Kd.js";const Ot=xe(".v-x-scroll",{overflow:"auto",scrollbarWidth:"none"},[xe("&::-webkit-scrollbar",{width:0,height:0})]),Ft=J({name:"XScroll",props:{disabled:Boolean,onScroll:Function},setup(){const e=E(null);function n(l){!(l.currentTarget.offsetWidth<l.currentTarget.scrollWidth)||l.deltaY===0||(l.currentTarget.scrollLeft+=l.deltaY+l.deltaX,l.preventDefault())}const b=Ct();return Ot.mount({id:"vueuc/x-scroll",head:!0,anchorMetaName:jt,ssr:b}),Object.assign({selfRef:e,handleWheel:n},{scrollTo(...l){var x;(x=e.value)===null||x===void 0||x.scrollTo(...l)}})},render(){return d("div",{ref:"selfRef",onScroll:this.onScroll,onWheel:this.disabled?void 0:this.handleWheel,class:"v-x-scroll"},this.$slots)}});var oe=function(){return kt.Date.now()},Mt="Expected a function",Dt=Math.max,Nt=Math.min;function Vt(e,n,b){var u,l,x,v,f,m,h=0,g=!1,_=!1,W=!0;if(typeof e!="function")throw new TypeError(Mt);n=me(n)||0,ze(b)&&(g=!!b.leading,_="maxWait"in b,x=_?Dt(me(b.maxWait)||0,n):x,W="trailing"in b?!!b.trailing:W);function y(c){var R=u,F=l;return u=l=void 0,h=c,v=e.apply(F,R),v}function T(c){return h=c,f=setTimeout(P,n),g?y(c):v}function C(c){var R=c-m,F=c-h,N=n-R;return _?Nt(N,x-F):N}function $(c){var R=c-m,F=c-h;return m===void 0||R>=n||R<0||_&&F>=x}function P(){var c=oe();if($(c))return z(c);f=setTimeout(P,C(c))}function z(c){return f=void 0,W&&u?y(c):(u=l=void 0,v)}function O(){f!==void 0&&clearTimeout(f),h=0,u=m=l=f=void 0}function L(){return f===void 0?v:z(oe())}function p(){var c=oe(),R=$(c);if(u=arguments,l=this,m=c,R){if(f===void 0)return T(m);if(_)return clearTimeout(f),f=setTimeout(P,n),y(m)}return f===void 0&&(f=setTimeout(P,n)),v}return p.cancel=O,p.flush=L,p}var Xt="Expected a function";function ie(e,n,b){var u=!0,l=!0;if(typeof e!="function")throw new TypeError(Xt);return ze(b)&&(u="leading"in b?!!b.leading:u,l="trailing"in b?!!b.trailing:l),Vt(e,n,{leading:u,maxWait:n,trailing:l})}const de=St("n-tabs"),$e={tab:[String,Number,Object,Function],name:{type:[String,Number],required:!0},disabled:Boolean,displayDirective:{type:String,default:"if"},closable:{type:Boolean,default:void 0},tabProps:Object,label:[String,Number,Object,Function]},ua=J({__TAB_PANE__:!0,name:"TabPane",alias:["TabPanel"],props:$e,setup(e){const n=Re(de,null);return n||Rt("tab-pane","`n-tab-pane` must be placed inside `n-tabs`."),{style:n.paneStyleRef,class:n.paneClassRef,mergedClsPrefix:n.mergedClsPrefixRef}},render(){return d("div",{class:[`${this.mergedClsPrefix}-tab-pane`,this.class],style:this.style},this.$slots)}}),Ut=Object.assign({internalLeftPadded:Boolean,internalAddable:Boolean,internalCreatedByPane:Boolean},Et($e,["displayDirective"])),le=J({__TAB__:!0,inheritAttrs:!1,name:"Tab",props:Ut,setup(e){const{mergedClsPrefixRef:n,valueRef:b,typeRef:u,closableRef:l,tabStyleRef:x,addTabStyleRef:v,tabClassRef:f,addTabClassRef:m,tabChangeIdRef:h,onBeforeLeaveRef:g,triggerRef:_,handleAdd:W,activateTab:y,handleClose:T}=Re(de);return{trigger:_,mergedClosable:q(()=>{if(e.internalAddable)return!1;const{closable:C}=e;return C===void box-sizing: border-box; width: 100%; display: flex; flex-direction: column; transition: background-color .3s var(--n-bezier), border-color .3s var(--n-bezier);`,[i("segment-type",[r("tabs-rail",[S("&.transition-disabled",[r("tabs-capsule",` transition: none; `)])])]),i("top",[r("tab-pane",` padding: var(--n-pane-padding-top) var(--n-pane-padding-right) var(--n-pane-padding-bottom) var(--n-pane-padding-left); `)]),i("left",[r("tab-pane",` padding: var(--n-pane-padding-right) var(--n-pane-padding-bottom) var(--n-pane-padding-left) var(--n-pane-padding-top); `)]),i("left, right",` flex-direction: row; `,[r("tabs-bar",` width: 2px; right: 0; transition: top .2s var(--n-bezier), max-height .2s var(--n-bezier), background-color .3s var(--n-bezier); `),r("tabs-tab",` padding: var(--n-tab-padding-vertical); `)]),i("right",` flex-direction: row-reverse; `,[r("tab-pane",` padding: var(--n-pane-padding-left) var(--n-pane-padding-top) var(--n-pane-padding-right) var(--n-pane-padding-bottom); `),r("tabs-bar",` left: 0; `)]),i("bottom",` flex-direction: column-reverse; justify-content: flex-end; `,[r("tab-pane",` padding: var(--n-pane-padding-bottom) var(--n-pane-padding-right) var(--n-pane-padding-top) var(--n-pane-padding-left); `),r("tabs-bar",` top: 0; `)]),r("tabs-rail",` position: relative; padding: 3px; border-radius: var(--n-tab-border-radius); width: 100%; background-color: var(--n-color-segment); transition: background-color .3s var(--n-bezier); display: flex; align-items: center; `,[r("tabs-capsule",` border-radius: var(--n-tab-border-radius); position: absolute; pointer-events: none; background-color: var(--n-tab-color-segment); box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .08); transition: transform 0.3s var(--n-bezier); `),r("tabs-tab-wrapper",` flex-basis: 0; flex-grow: 1; display: flex; align-items: center; justify-content: center; `,[r("tabs-tab",` overflow: hidden; border-radius: var(--n-tab-border-radius); width: 100%; display: flex; align-items: center; justify-content: center; `,[i("active",` font-weight: var(--n-font-weight-strong); color: var(--n-tab-text-color-active); `),S("&:hover",` color: var(--n-tab-text-color-hover); `)])])]),i("flex",[r("tabs-nav",` width: 100%; position: relative; `,[r("tabs-wrapper",` width: 100%; `,[r("tabs-tab",` margin-right: 0; `)])])]),r("tabs-nav",` box-sizing: border-box; line-height: 1.5; display: flex; transition: border-color .3s var(--n-bezier); `,[A("prefix, suffix",` display: flex; align-items: center; `),A("prefix","padding-right: 16px;"),A("suffix","padding-left: 16px;")]),i("top, bottom",[r("tabs-nav-scroll-wrapper",[S("&::before",` top: 0; bottom: 0; left: 0; width: 20px; `),S("&::after",` top: 0; bottom: 0; right: 0; width: 20px; `),i("shadow-start",[S("&::before",` box-shadow: inset 10px 0 8px -8px rgba(0, 0, 0, .12); `)]),i("shadow-end",[S("&::after",` box-shadow: inset -10px 0 8px -8px rgba(0, 0, 0, .12); `)])])]),i("left, right",[r("tabs-nav-scroll-content",` flex-direction: column; `),r("tabs-nav-scroll-wrapper",[S("&::before",` top: 0; left: 0; right: 0; height: 20px; `),S("&::after",` bottom: 0; left: 0; right: 0; height: 20px; `),i("shadow-start",[S("&::before",` box-shadow: inset 0 10px 8px -8px rgba(0, 0, 0, .12); `)]),i("shadow-end",[S("&::after",` box-shadow: inset 0 -10px 8px -8px rgba(0, 0, 0, .12); `)])])]),r("tabs-nav-scroll-wrapper",` flex: 1; position: relative; overflow: hidden; `,[r("tabs-nav-y-scroll",` height: 100%; width: 100%; overflow-y: auto; scrollbar-width: none; `,[S("&::-webkit-scrollbar",` width: 0; height: 0; `)]),S("&::before, &::after",` transition: box-shadow .3s var(--n-bezier); pointer-events: none; content: ""; position: absolute; z-index: 1; `)]),r("tabs-nav-scroll-content",` display: flex; position: relative; min-width: 100%; min-height: 100%; width: fit-content; box-sizing: border-box; `),r("tabs-wrapper",` display: inline-flex; flex-wrap: nowrap; position: relative; `),r("tabs-tab-wrapper",` display: flex; flex-wrap: nowrap; flex-shrink: 0; flex-grow: 0; `),r("tabs-tab",` cursor: pointer; white-space: nowrap; flex-wrap: nowrap; display: inline-flex; align-items: center; color: var(--n-tab-text-color); font-size: var(--n-tab-font-size); background-clip: padding-box; padding: var(--n-tab-padding); transition: box-shadow .3s var(--n-bezier), color .3s var(--n-bezier), background-color .3s var(--n-bezier), border-color .3s var(--n-bezier); `,[i("disabled",{cursor:"not-allowed"}),A("close",` margin-left: 6px; transition: background-color .3s var(--n-bezier), color .3s var(--n-bezier); `),A("label",` display: flex; align-items: center; z-index: 1; `)]),r("tabs-bar",` position: absolute; bottom: 0; height: 2px; border-radius: 1px; background-color: var(--n-bar-color); transition: left .2s var(--n-bezier), max-width .2s var(--n-bezier), opacity .3s var(--n-bezier), background-color .3s var(--n-bezier); `,[S("&.transition-disabled",` transition: none; `),i("disabled",` background-color: var(--n-tab-text-color-disabled) `)]),r("tabs-pane-wrapper",` position: relative; overflow: hidden; transition: max-height .2s var(--n-bezier); `),r("tab-pane",` color: var(--n-pane-text-color); width: 100%; transition: color .3s var(--n-bezier), background-color .3s var(--n-bezier), opacity .2s var(--n-bezier); left: 0; right: 0; top: 0; `,[S("&.next-transition-leave-active, &.prev-transition-leave-active, &.next-transition-enter-active, &.prev-transition-enter-active",` transition: color .3s var(--n-bezier), background-color .3s var(--n-bezier), transform .2s var(--n-bezier), opacity .2s var(--n-bezier); `),S("&.next-transition-leave-active, &.prev-transition-leave-active",` position: absolute; `),S("&.next-transition-enter-from, &.prev-transition-leave-to",` transform: translateX(32px); opacity: 0; `),S("&.next-transition-leave-to, &.prev-transition-enter-from",` transform: translateX(-32px); opacity: 0; `),S("&.next-transition-leave-from, &.next-transition-enter-to, &.prev-transition-leave-from, &.prev-transition-enter-to",` transform: translateX(0); opacity: 1; `)]),r("tabs-tab-pad",` box-sizing: border-box; width: var(--n-tab-gap); flex-grow: 0; flex-shrink: 0; `),i("line-type, bar-type",[r("tabs-tab",` font-weight: var(--n-tab-font-weight); box-sizing: border-box; vertical-align: bottom; `,[S("&:hover",{color:"var(--n-tab-text-color-hover)"}),i("active",` color: var(--n-tab-text-color-active); font-weight: var(--n-tab-font-weight-active); `),i("disabled",{color:"var(--n-tab-text-color-disabled)"})])]),r("tabs-nav",[i("line-type",[i("top",[A("prefix, suffix",` border-bottom: 1px solid var(--n-tab-border-color); `),r("tabs-nav-scroll-content",` border-bottom: 1px solid var(--n-tab-border-color); `),r("tabs-bar",` bottom: -1px; `)]),i("left",[A("prefix, suffix",` border-right: 1px solid var(--n-tab-border-color); `),r("tabs-nav-scroll-content",` border-right: 1px solid var(--n-tab-border-color); `),r("tabs-bar",` right: -1px; `)]),i("right",[A("prefix, suffix",` border-left: 1px solid var(--n-tab-border-color); `),r("tabs-nav-scroll-content",` border-left: 1px solid var(--n-tab-border-color); `),r("tabs-bar",` left: -1px; `)]),i("bottom",[A("prefix, suffix",` border-top: 1px solid var(--n-tab-border-color); `),r("tabs-nav-scroll-content",` border-top: 1px solid var(--n-tab-border-color); `),r("tabs-bar",` top: -1px; `)]),A("prefix, suffix",` transition: border-color .3s var(--n-bezier); `),r("tabs-nav-scroll-content",` transition: border-color .3s var(--n-bezier); `),r("tabs-bar",` border-radius: 0; `)]),i("card-type",[A("prefix, suffix",` transition: border-color .3s var(--n-bezier); border-bottom: 1px solid var(--n-tab-border-color); `),r("tabs-pad",` flex-grow: 1; transition: border-color .3s var(--n-bezier); `),r("tabs-tab-pad",` transition: border-color .3s var(--n-bezier); `),r("tabs-tab",` font-weight: var(--n-tab-font-weight); border: 1px solid var(--n-tab-border-color); background-color: var(--n-tab-color); box-sizing: border-box; position: relative; vertical-align: bottom; display: flex; justify-content: space-between; font-size: var(--n-tab-font-size); color: var(--n-tab-text-color); `,[i("addable",` padding-left: 8px; padding-right: 8px; font-size: 16px; `,[A("height-placeholder",` width: 0; font-size: var(--n-tab-font-size); `),Tt("disabled",[S("&:hover",` color: var(--n-tab-text-color-hover); `)])]),i("closable","padding-right: 8px;"),i("active",` background-color: #0000; font-weight: var(--n-tab-font-weight-active); color: var(--n-tab-text-color-active); `),i("disabled","color: var(--n-tab-text-color-disabled);")]),r("tabs-scroll-padding","border-bottom: 1px solid var(--n-tab-border-color);")]),i("left, right",[r("tabs-wrapper",` flex-direction: column; `,[r("tabs-tab-wrapper",` flex-direction: column; `,[r("tabs-tab-pad",` height: var(--n-tab-gap-vertical); width: 100%; `)])])]),i("top",[i("card-type",[r("tabs-tab",` border-top-left-radius: var(--n-tab-border-radius); border-top-right-radius: var(--n-tab-border-radius); `,[i("active",` border-bottom: 1px solid #0000; `)]),r("tabs-tab-pad",` border-bottom: 1px solid var(--n-tab-border-color); `),r("tabs-pad",` border-bottom: 1px solid var(--n-tab-border-color); `)])]),i("left",[i("card-type",[r("tabs-tab",` border-top-left-radius: var(--n-tab-border-radius); border-bottom-left-radius: var(--n-tab-border-radius); `,[i("active",` border-right: 1px solid #0000; `)]),r("tabs-tab-pad",` border-right: 1px solid var(--n-tab-border-color); `),r("tabs-pad",` border-right: 1px solid var(--n-tab-border-color); `)])]),i("right",[i("card-type",[r("tabs-tab",` border-top-right-radius: var(--n-tab-border-radius); border-bottom-right-radius: var(--n-tab-border-radius); `,[i("active",` border-left: 1px solid #0000; `)]),r("tabs-tab-pad",` border-left: 1px solid var(--n-tab-border-color); `),r("tabs-pad",` border-left: 1px solid var(--n-tab-border-color); `)])]),i("bottom",[i("card-type",[r("tabs-tab",` border-bottom-left-radius: var(--n-tab-border-radius); border-bottom-right-radius: var(--n-tab-border-radius); `,[i("active",` border-top: 1px solid #0000; `)]),r("tabs-tab-pad",` border-top: 1px solid var(--n-tab-border-color); `),r("tabs-pad",` border-top: 1px solid var(--n-tab-border-color); `)])])])]),Yt=Object.assign(Object.assign({},Te.props),{value:[String,Number],defaultValue:[String,Number],trigger:{type:String,default:"click"},type:{type:String,default:"bar"},closable:Boolean,justifyContent:String,size:{type:String,default:"medium"},placement:{type:String,default:"top"},tabStyle:[String,Object],tabClass:String,addTabStyle:[String,Object],addTabClass:String,barWidth:Number,paneClass:String,paneStyle:[String,Object],paneWrapperClass:String,paneWrapperStyle:[String,Object],addable:[Boolean,Object],tabsPadding:{type:Number,default:0},animated:Boolean,onBeforeLeave:Function,onAdd:Function,"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],onClose:[Function,Array],labelSize:String,activeName:[String,Number],onActiveNameChange:[Function,Array]}),va=J({name:"Tabs",props:Yt,setup(e,{slots:n}){var b,u,l,x;const{mergedClsPrefixRef:v,inlineThemeDisabled:f}=zt(e),m=Te("Tabs","-tabs",Gt,At,e,v),h=E(null),g=E(null),_=E(null),W=E(null),y=E(null),T=E(null),C=E(!0),$=E(!0),P=ge(e,["labelSize","size"]),z=ge(e,["activeName","value"]),O=E((u=(b=z.value)!==null&&b!==void 0?b:e.defaultValue)!==null&&u!==void 0?u:n.default?(x=(l=re(n.default())[0])===null||l===void 0?void 0:l.props)===null||x===void 0?void 0:x.name:null),L=Bt(z,O),p={id:0},c=q(()=>{if(!(!e.justifyContent||e.type==="card"))return{display:"flex",justifyContent:e.justifyContent}});te(L,()=>{p.id=0,V(),be()});function R(){var t;const{value:a}=L;return a===null?null:(t=h.value)===null||t===void 0?void 0:t.querySelector(`[data-name="${a}"]`)}function F(t){if(e.type==="card")return;const{value:a}=g;if(!a)return;const o=a.style.opacity==="0";if(t){const s=`${v.value}-tabs-bar--disabled`,{barWidth:w,placement:B}=e;if(t.dataset.disabled==="true"?a.classList.add(s):a.classList.remove(s),["top","bottom"].includes(B)){if(ce(["top","maxHeight","height"]),typeof w=="number"&&t.offsetWidth>=w){const I=Math.floor((t.offsetWidth-w)/2)+t.offsetLeft;a.style.left=`${I}px`,a.style.maxWidth=`${w}px`}else a.style.left=`${t.offsetLeft}px`,a.style.maxWidth=`${t.offsetWidth}px`;a.style.width="8192px",o&&(a.style.transition="none"),a.offsetWidth,o&&(a.style.transition="",a.style.opacity="1")}else{if(ce(["left","maxWidth","width"]),typeof w=="number"&&t.offsetHeight>=w){const I=Math.floor((t.offsetHeight-w)/2)+t.offsetTop;a.style.top=`${I}px`,a.style.maxHeight=`${w}px`}else a.style.top=`${t.offsetTop}px`,a.style.maxHeight=`${t.offsetHeight}px`;a.style.height="8192px",o&&(a.style.transition="none"),a.offsetHeight,o&&(a.style.transition="",a.style.opacity="1")}}}function N(){if(e.type==="card")return;const{value:t}=g;t&&(t.style.opacity="0")}function ce(t){const{value:a}=g;if(a)for(const o of t)a.style[o]=""}function V(){if(e.type==="card")return;const t=R();t?F(t):N()}function be(){var t;const a=(t=y.value)===null||t===void 0?void 0:t.$el;if(!a)return;const o=R();if(!o)return;const{scrollLeft:s,offsetWidth:w}=a,{offsetLeft:B,offsetWidth:I}=o;s>B?a.scrollTo({top:0,left:B,behavior:"smooth"}):B+I>s+w&&a.scrollTo({top:0,left:B+I-w,behavior:"smooth"})}const X=E(null);let Q=0,H=null;function Pe(t){const a=X.value;if(a){Q=t.getBoundingClientRect().height;const o=`${Q}px`,s=()=>{a.style.height=o,a.style.maxHeight=o};H?(s(),H(),H=null):H=s}}function _e(t){const a=X.value;if(a){const o=t.getBoundingClientRect().height,s=()=>{document.body.offsetHeight,a.style.maxHeight=`${o}px`,a.style.height=`${Math.max(Q,o)}px`};H?(H(),H=null,s()):H=s}}function We(){const t=X.value;if(t){t.style.maxHeight="",t.style.height="";const{paneWrapperStyle:a}=e;if(typeof a=="string")t.style.cssText=a;else if(a){const{maxHeight:o,height:s}=a;o!==void 0&&(t.style.maxHeight=o),s!==void 0&&(t.style.height=s)}}}const fe={value:[]},pe=E("next");function Le(t){const a=L.value;let o="next";for(const s of fe.value){if(s===a)break;if(s===t){o="prev";break}}pe.value=o,Ee(t)}function Ee(t){const{onActiveNameChange:a,onUpdateValue:o,"onUpdate:value":s}=e;a&&K(a,t),o&&K(o,t),s&&K(s,t),O.value=t}function Ae(t){const{onClose:a}=e;a&&K(a,t)}function ue(){const{value:t}=g;if(!t)return;const a="transition-disabled";t.class
|