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.

2 lines
12 KiB

import{m as ne,z as K,y as k,r as V,A as re,O as he,P as D,o as u,h as E,b as T,w as I,i as ie,a as P,Q as Ce,H as de,E as v,c as C,G as O,t as F,l as p,R as ue,T as ce,S as we,M as ve,U as ke,v as U,q as A,s as q,g as j,k as Se,C as l,V as Ie,W as G,I as ee,X as Ee,n as J,Y as te,K as Te,Z as Ve,_ as Be,$ as L,f as Le,L as $e,a0 as Ne,a1 as fe,D as Pe,a2 as Ae}from"./config-provider-5e5578b5.js";import{g as N,h as ze,i as Z,j as me,_ as pe,k as ae,U as W,C as Y,I as _,d as Re,u as De,e as Oe,b as Me,f as Fe,l as Ue,t as He,r as H,m as $,n as se}from"./axios-ea863ce3.js";import{d as Ke,a as qe,E as je,u as Ge}from"./el-overlay-539349b7.js";import{e as Ze,i as We}from"./el-breadcrumb-item-ca27cf79.js";const Ye=ne({...Ke,direction:{type:String,default:"rtl",values:["ltr","rtl","ttb","btt"]},size:{type:[String,Number],default:"30%"},withHeader:{type:Boolean,default:!0},modalFade:{type:Boolean,default:!0}}),_e=qe,Qe=K({name:"ElDrawer",components:{ElOverlay:je,ElFocusTrap:Ze,ElIcon:N,Close:ze},inheritAttrs:!1,props:Ye,emits:_e,setup(e,{slots:t}){Z({scope:"el-drawer",from:"the title slot",replacement:"the header slot",version:"3.0.0",ref:"https://element-plus.org/en-US/component/drawer.html#slots"},k(()=>!!t.title)),Z({scope:"el-drawer",from:"custom-class",replacement:"class",version:"2.3.0",ref:"https://element-plus.org/en-US/component/drawer.html#attributes",type:"Attribute"},k(()=>!!e.customClass));const s=V(),a=V(),d=re("drawer"),{t:r}=he(),f=k(()=>e.direction==="rtl"||e.direction==="ltr"),n=k(()=>me(e.size));return{...Ge(e,s),drawerRef:s,focusStartRef:a,isHorizontal:f,drawerSize:n,ns:d,t:r}}}),Xe=["aria-label","aria-labelledby","aria-describedby"],Je=["id"],xe=["aria-label"],et=["id"];function tt(e,t,s,a,d,r){const f=D("close"),n=D("el-icon"),S=D("el-focus-trap"),m=D("el-overlay");return u(),E(we,{to:"body",disabled:!e.appendToBody},[T(ce,{name:e.ns.b("fade"),onAfterEnter:e.afterEnter,onAfterLeave:e.afterLeave,onBeforeLeave:e.beforeLeave,persisted:""},{default:I(()=>[ie(T(m,{mask:e.modal,"overlay-class":e.modalClass,"z-index":e.zIndex,onClick:e.onModalClick},{default:I(()=>[T(S,{loop:"",trapped:e.visible,"focus-trap-el":e.drawerRef,"focus-start-el":e.focusStartRef,onReleaseRequested:e.onCloseRequested},{default:I(()=>[P("div",Ce({ref:"drawerRef","aria-modal":"true","aria-label":e.title||void 0,"aria-labelledby":e.title?void 0:e.titleId,"aria-describedby":e.bodyId},e.$attrs,{class:[e.ns.b(),e.direction,e.visible&&"open",e.customClass],style:e.isHorizontal?"width: "+e.drawerSize:"height: "+e.drawerSize,role:"dialog",onClick:t[1]||(t[1]=de(()=>{},["stop"]))}),[P("span",{ref:"focusStartRef",class:v(e.ns.e("sr-focus")),tabindex:"-1"},null,2),e.withHeader?(u(),C("header",{key:0,class:v(e.ns.e("header"))},[e.$slots.title?O(e.$slots,"title",{key:1},()=>[p(" DEPRECATED SLOT ")]):O(e.$slots,"header",{key:0,close:e.handleClose,titleId:e.titleId,titleClass:e.ns.e("title")},()=>[e.$slots.title?p("v-if",!0):(u(),C("span",{key:0,id:e.titleId,role:"heading",class:v(e.ns.e("title"))},F(e.title),11,Je))]),e.showClose?(u(),C("button",{key:2,"aria-label":e.t("el.drawer.close"),class:v(e.ns.e("close-btn")),type:"button",onClick:t[0]||(t[0]=(...w)=>e.handleClose&&e.handleClose(...w))},[T(n,{class:v(e.ns.e("close"))},{default:I(()=>[T(f)]),_:1},8,["class"])],10,xe)):p("v-if",!0)],2)):p("v-if",!0),e.rendered?(u(),C("div",{key:1,id:e.bodyId,class:v(e.ns.e("body"))},[O(e.$slots,"default")],10,et)):p("v-if",!0),e.$slots.footer?(u(),C("div",{key:2,class:v(e.ns.e("footer"))},[O(e.$slots,"footer")],2)):p("v-if",!0)],16,Xe)]),_:3},8,["trapped","focus-trap-el","focus-start-el","onReleaseRequested"])]),_:3},8,["mask","overlay-class","z-index","onClick"]),[[ue,e.visible]])]),_:3},8,["name","onAfterEnter","onAfterLeave","onBeforeLeave"])],8,["disabled"])}var at=pe(Qe,[["render",tt],["__file","/home/runner/work/element-plus/element-plus/packages/components/drawer/src/drawer.vue"]]);const kt=ve(at),st=ne({modelValue:{type:[Boolean,String,Number],default:!1},value:{type:[Boolean,String,Number],default:!1},disabled:{type:Boolean,default:!1},width:{type:[String,Number],default:""},inlinePrompt:{type:Boolean,default:!1},activeIcon:{type:ae},inactiveIcon:{type:ae},activeText:{type:String,default:""},inactiveText:{type:String,default:""},activeColor:{type:String,default:""},inactiveColor:{type:String,default:""},borderColor:{type:String,default:""},activeValue:{type:[Boolean,String,Number],default:!0},inactiveValue:{type:[Boolean,String,Number],default:!1},name:{type:String,default:""},validateEvent:{type:Boolean,default:!0},id:String,loading:{type:Boolean,default:!1},beforeChange:{type:ke(Function)},size:{type:String,validator:We},tabindex:{type:[String,Number]}}),ot={[W]:e=>U(e)||A(e)||q(e),[Y]:e=>U(e)||A(e)||q(e),[_]:e=>U(e)||A(e)||q(e)},lt=["onClick"],nt=["id","aria-checked","aria-disabled","name","true-value","false-value","disabled","tabindex","onKeydown"],rt=["aria-hidden"],it=["aria-hidden"],dt=["aria-hidden"],Q="ElSwitch",ut=K({name:Q}),ct=K({...ut,props:st,emits:ot,setup(e,{expose:t,emit:s}){const a=e,d=Ee(),{formItem:r}=Re(),f=De(),n=re("switch");Z({from:'"value"',replacement:'"model-value" or "v-model"',scope:Q,version:"2.3.0",ref:"https://element-plus.org/en-US/component/switch.html#attributes",type:"Attribute"},k(()=>{var o;return!!((o=d.vnode.props)!=null&&o.value)}));const{inputId:S}=Oe(a,{formItemContext:r}),m=Me(k(()=>a.loading)),w=V(a.modelValue!==!1),b=V(),i=V(),g=k(()=>[n.b(),n.m(f.value),n.is("disabled",m.value),n.is("checked",c.value)]),y=k(()=>({width:me(a.width)}));j(()=>a.modelValue,()=>{w.value=!0}),j(()=>a.value,()=>{w.value=!1});const z=k(()=>w.value?a.modelValue:a.value),c=k(()=>z.value===a.activeValue);[a.activeValue,a.inactiveValue].includes(z.value)||(s(W,a.inactiveValue),s(Y,a.inactiveValue),s(_,a.inactiveValue)),j(c,o=>{var h;b.value.checked=o,a.validateEvent&&((h=r==null?void 0:r.validate)==null||h.call(r,"change").catch(ye=>Fe()))});const B=()=>{const o=c.value?a.inactiveValue:a.activeValue;s(W,o),s(Y,o),s(_,o),J(()=>{b.value.checked=c.value})},R=()=>{if(m.value)return;const{beforeChange:o}=a;if(!o){B();return}const h=o();[te(h),U(h)].includes(!0)||He(Q,"beforeChange must return type `Promise<boolean>` or `boolean`"),te(h)?h.then(x=>{x&&B()}).catch(x=>{}):h&&B()},be=k(()=>n.cssVarBlock({...a.activeColor?{"on-color":a.activeColor}:null,...a.inactiveColor?{"off-color":a.inactiveColor}:null,...a.borderColor?{"border-color":a.borderColor}:null})),ge=()=>{var o,h;(h=(o=b.value)==null?void 0:o.focus)==null||h.call(o)};return Se(()=>{b.value.checked=c.value}),t({focus:ge,checked:c}),(o,h)=>(u(),C("div",{class:v(l(g)),style:ee(l(be)),onClick:de(R,["prevent"])},[P("input",{id:l(S),ref_key:"input",ref:b,class:v(l(n).e("input")),type:"checkbox",role:"switch","aria-checked":l(c),"aria-disabled":l(m),name:o.name,"true-value":o.activeValue,"false-value":o.inactiveValue,disabled:l(m),tabindex:o.tabindex,onChange:B,onKeydown:Ie(R,["enter"])},null,42,nt),!o.inlinePrompt&&(o.inactiveIcon||o.inactiveText)?(u(),C("span",{key:0,class:v([l(n).e("label"),l(n).em("label","left"),l(n).is("active",!l(c))])},[o.inactiveIcon?(u(),E(l(N),{key:0},{default:I(()=>[(u(),E(G(o.inactiveIcon)))]),_:1})):p("v-if",!0),!o.inactiveIcon&&o.inactiveText?(u(),C("span",{key:1,"aria-hidden":l(c)},F(o.inactiveText),9,rt)):p("v-if",!0)],2)):p("v-if",!0),P("span",{ref_key:"core",ref:i,class:v(l(n).e("core")),style:ee(l(y))},[o.inlinePrompt?(u(),C("div",{key:0,class:v(l(n).e("inner"))},[o.activeIcon||o.inactiveIcon?(u(),E(l(N),{key:0,class:v(l(n).is("icon"))},{default:I(()=>[(u(),E(G(l(c)?o.activeIcon:o.inactiveIcon)))]),_:1},8,["class"])):o.activeText||o.inactiveText?(u(),C("span",{key:1,class:v(l(n).is("text")),"aria-hidden":!l(c)},F(l(c)?o.activeText:o.inactiveText),11,it)):p("v-if",!0)],2)):p("v-if",!0),P("div",{class:v(l(n).e("action"))},[o.loading?(u(),E(l(N),{key:0,class:v(l(n).is("loading"))},{default:I(()=>[T(l(Ue))]),_:1},8,["class"])):p("v-if",!0)],2)],6),!o.inlinePrompt&&(o.activeIcon||o.activeText)?(u(),C("span",{key:1,class:v([l(n).e("label"),l(n).em("label","right"),l(n).is("active",l(c))])},[o.activeIcon?(u(),E(l(N),{key:0},{default:I(()=>[(u(),E(G(o.activeIcon)))]),_:1})):p("v-if",!0),!o.activeIcon&&o.activeText?(u(),C("span",{key:1,"aria-hidden":!l(c)},F(o.activeText),9,dt)):p("v-if",!0)],2)):p("v-if",!0)],14,lt))}});var vt=pe(ct,[["__file","/home/runner/work/element-plus/element-plus/packages/components/switch/src/switch.vue"]]);const St=ve(vt);function ft(e){let t;const s=V(!1),a=Te({...e,originalPosition:"",originalOverflow:"",visible:!1});function d(i){a.text=i}function r(){const i=a.parent,g=b.ns;if(!i.vLoadingAddClassList){let y=i.getAttribute("loading-number");y=Number.parseInt(y)-1,y?i.setAttribute("loading-number",y.toString()):(H(i,g.bm("parent","relative")),i.removeAttribute("loading-number")),H(i,g.bm("parent","hidden"))}f(),w.unmount()}function f(){var i,g;(g=(i=b.$el)==null?void 0:i.parentNode)==null||g.removeChild(b.$el)}function n(){var i;e.beforeClose&&!e.beforeClose()||(s.value=!0,clearTimeout(t),t=window.setTimeout(S,400),a.visible=!1,(i=e.closed)==null||i.call(e))}function S(){if(!s.value)return;const i=a.parent;s.value=!1,i.vLoadingAddClassList=void 0,r()}const m=K({name:"ElLoading",setup(i,{expose:g}){const{ns:y}=Ve("loading"),z=Be();return g({ns:y,zIndex:z}),()=>{const c=a.spinner||a.svg,B=L("svg",{class:"circular",viewBox:a.svgViewBox?a.svgViewBox:"0 0 50 50",...c?{innerHTML:c}:{}},[L("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none"})]),R=a.text?L("p",{class:y.b("text")},[a.text]):void 0;return L(ce,{name:y.b("fade"),onAfterLeave:S},{default:I(()=>[ie(T("div",{style:{backgroundColor:a.background||""},class:[y.b("mask"),a.customClass,a.fullscreen?"is-fullscreen":""]},[L("div",{class:y.b("spinner")},[B,R])]),[[ue,a.visible]])])})}}}),w=Le(m),b=w.mount(document.createElement("div"));return{...$e(a),setText:d,removeElLoadingChild:f,close:n,handleAfterLeave:S,vm:b,get $el(){return b.$el}}}let M;const mt=function(e={}){if(!Ne)return;const t=pt(e);if(t.fullscreen&&M)return M;const s=ft({...t,closed:()=>{var d;(d=t.closed)==null||d.call(t),t.fullscreen&&(M=void 0)}});bt(t,t.parent,s),oe(t,t.parent,s),t.parent.vLoadingAddClassList=()=>oe(t,t.parent,s);let a=t.parent.getAttribute("loading-number");return a?a=`${Number.parseInt(a)+1}`:a="1",t.parent.setAttribute("loading-number",a),t.parent.appendChild(s.$el),J(()=>s.visible.value=t.visible),t.fullscreen&&(M=s),s},pt=e=>{var t,s,a,d;let r;return A(e.target)?r=(t=document.querySelector(e.target))!=null?t:document.body:r=e.target||document.body,{parent:r===document.body||e.body?document.body:r,background:e.background||"",svg:e.svg||"",svgViewBox:e.svgViewBox||"",spinner:e.spinner||!1,text:e.text||"",fullscreen:r===document.body&&((s=e.fullscreen)!=null?s:!0),lock:(a=e.lock)!=null?a:!1,customClass:e.customClass||"",visible:(d=e.visible)!=null?d:!0,target:r}},bt=async(e,t,s)=>{const{nextZIndex:a}=s.vm.zIndex,d={};if(e.fullscreen)s.originalPosition.value=$(document.body,"position"),s.originalOverflow.value=$(document.body,"overflow"),d.zIndex=a();else if(e.parent===document.body){s.originalPosition.value=$(document.body,"position"),await J();for(const r of["top","left"]){const f=r==="top"?"scrollTop":"scrollLeft";d[r]=`${e.target.getBoundingClientRect()[r]+document.body[f]+document.documentElement[f]-Number.parseInt($(document.body,`margin-${r}`),10)}px`}for(const r of["height","width"])d[r]=`${e.target.getBoundingClientRect()[r]}px`}else s.originalPosition.value=$(t,"position");for(const[r,f]of Object.entries(d))s.$el.style[r]=f},oe=(e,t,s)=>{const a=s.vm.ns;["absolute","fixed","sticky"].includes(s.originalPosition.value)?H(t,a.bm("parent","relative")):se(t,a.bm("parent","relative")),e.fullscreen&&e.lock?se(t,a.bm("parent","hidden")):H(t,a.bm("parent","hidden"))},X=Symbol("ElLoading"),le=(e,t)=>{var s,a,d,r;const f=t.instance,n=i=>fe(t.value)?t.value[i]:void 0,S=i=>{const g=A(i)&&(f==null?void 0:f[i])||i;return g&&V(g)},m=i=>S(n(i)||e.getAttribute(`element-loading-${Ae(i)}`)),w=(s=n("fullscreen"))!=null?s:t.modifiers.fullscreen,b={text:m("text"),svg:m("svg"),svgViewBox:m("svgViewBox"),spinner:m("spinner"),background:m("background"),customClass:m("customClass"),fullscreen:w,target:(a=n("target"))!=null?a:w?void 0:e,body:(d=n("body"))!=null?d:t.modifiers.body,lock:(r=n("lock"))!=null?r:t.modifiers.lock};e[X]={options:b,instance:mt(b)}},gt=(e,t)=>{for(const s of Object.keys(t))Pe(t[s])&&(t[s].value=e[s])},It={mounted(e,t){t.value&&le(e,t)},updated(e,t){const s=e[X];t.oldValue!==t.value&&(t.value&&!t.oldValue?le(e,t):t.value&&t.oldValue?fe(t.value)&&gt(t.value,s.options):s==null||s.instance.close())},unmounted(e){var t;(t=e[X])==null||t.instance.close()}};export{St as E,kt as a,It as v};