zan-layer 1.0.7 → 1.0.8

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.
@@ -1 +1 @@
1
- (function(N,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(N=typeof globalThis<"u"?globalThis:N||self,t(N.ZanLayer={},N.Vue))})(this,function(N,t){"use strict";const Ce=t.defineComponent({name:"Shade",__name:"Shade",props:{visible:{type:[Boolean,String]},opacity:{},index:{type:[Number,Function]},teleport:{},teleportDisabled:{type:Boolean},shadeStyle:{type:[Boolean,null,String,Object,Array]}},emits:["shadeClick"],setup(e,{emit:l}){const o=e,n=l,i=t.computed(()=>[{opacity:o.opacity,position:o.teleportDisabled||o.teleport!="body"?"absolute":"fixed",zIndex:o.index},o.shadeStyle]),s=()=>{n("shadeClick")};return(c,a)=>e.visible?(t.openBlock(),t.createElementBlock("div",{key:0,class:"zan-layer-shade",style:t.normalizeStyle(i.value),onClick:s},null,4)):t.createCommentVNode("",!0)}}),ze=["src"],Ee=t.defineComponent({name:"Iframe",__name:"Iframe",props:{src:{}},setup(e){const l=e,o=t.computed(()=>l.src);return(n,i)=>(t.openBlock(),t.createElementBlock("iframe",{scrolling:"auto",class:"zan-layer-iframe",allowtransparency:"true",frameborder:"0",src:o.value},null,8,ze))}}),_=t.defineComponent({name:"ZanRender",props:{render:{type:Function,required:!0}},setup(e){return()=>e.render()}}),M=function(e){return typeof e=="function"?e():typeof e=="string"?t.h("span",e):e};function te(){const e=[],l="0123456789abcdef";for(let n=0;n<36;n++)e[n]=l.substr(Math.floor(Math.random()*16),1);return e[14]="4",e[19]=l.substr(e[19]&3|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("").replaceAll("-","")}function Se(e,l,o){return e!="drawer"&&e!=4?we(l):ne(o,l)}function we(e){return e==null||e==="auto"?[]:typeof e=="string"?[e]:e[1]&&e[1]==="auto"?e[0]&&e[0]==="auto"?[]:[e[0]]:e[0]&&e[0]==="auto"?e[1]&&e[1]!="auto"?[void 0,e[1]]:[]:[...e]}function ne(e,l="30%"){return l==null&&(l="30%"),l instanceof Array?l:(l==="auto"&&(l="30%"),e==="l"||e==="r"||e==="lt"||e==="lb"||e==="rt"||e==="rb"?[l,"100%"]:e==="t"||e==="b"||e==="tr"||e==="tl"||e==="br"||e==="bl"?["100%",l]:[l,"100%"])}function le(e){return e==null||e===""?"0px":e}function G(e="auto",l,o){e==null&&(e="auto");const n=Array.isArray(l)?l:[],i=le(n[0]),s=le(n[1]),c=["t","r","b","l","lt","tl","lb","bl","rt","tr","rb","br"],a=[];return e==="auto"&&o==4&&(e="r"),typeof e=="string"?c.indexOf(e)>-1?(e==="t"&&(a[0]="0px",a[1]="calc(50% - "+i+"/2)"),e==="l"&&(a[0]="calc(50% - "+s+"/2)",a[1]="0px"),e==="b"&&(a[0]="calc(100% - "+s+")",a[1]="calc(50% - "+i+"/2)"),e==="r"&&(a[0]="calc(50% - "+s+"/2)",a[1]="calc(100% - "+i+")"),(e==="lt"||e==="tl")&&(a[0]="0px",a[1]="0px"),(e==="lb"||e==="bl")&&(a[0]="calc(100% - "+s+")",a[1]="0px"),(e==="rt"||e==="tr")&&(a[0]="0px",a[1]="calc(100% - "+i+")"),(e==="rb"||e==="br")&&(a[0]="calc(100% - "+s+")",a[1]="calc(100% - "+i+")")):e=="auto"?(a[0]="calc(50% - "+s+"/2)",a[1]="calc(50% - "+i+"/2)"):(a[0]=e,a[1]="calc(50% - "+i+"/2)"):e&&e[0]!==void 0&&e[1]!==void 0?(a[0]=e[0],a[1]=e[1]):(a[0]="calc(50% - "+s+"/2)",a[1]="calc(50% - "+i+"/2)"),a}function ve(e){return e==="dialog"||e==0?0:e==="page"||e==1?1:e==="iframe"||e==2?2:e==="loading"||e==3?3:e==="drawer"||e==4?4:e==="photos"||e==5?5:e==="notify"||e==6?6:e==="prompt"||e==7?7:0}function oe(){return{w:"100%",h:"100%"}}function ae(){return{t:"0px",l:"0px"}}function ie(e){var n,i;const l=(n=getComputedStyle(e,null))==null?void 0:n.width,o=(i=getComputedStyle(e,null))==null?void 0:i.height;return[l,o]}const F=[];function A(e,l){let o=0;if(l){const n=F.findIndex(i=>i===void 0);n===-1?(F.push(e),o=F.length-1):(F[n]=e,o=n)}else delete F[F.findIndex(n=>n==e)],o=-1;return o}function se(e,l=!1){const o=["rl"],n="zan-layer-drawer-anim zan-layer-anim";return e==="l"||e==="lt"||e==="lb"?o[0]="lr":e==="r"||e==="rt"||e==="rb"?o[0]="rl":e==="t"||e==="tr"||e==="tl"?o[0]="tb":(e==="b"||e==="br"||e==="bl")&&(o[0]="bt"),l?`${n}-${o[0]}-close`:`${n}-${o[0]}`}async function re(e,l){const o=new Image;return o.src=e,new Promise((i,s)=>{if(o.complete){i(n(o));return}const c=B.load(2,{shadeOpacity:"0"});o.onload=()=>{B.close(c),i(n(o))},o.onerror=()=>{B.close(c),B.msg("图片加载失败"),s(!1)}});function n(i){const s=[i.width,i.height],c=[window.innerWidth-250,window.innerHeight-250];if(s[0]>c[0]||s[1]>c[1]){const a=[s[0]/c[0],s[1]/c[1]];a[0]>a[1]?(s[0]=s[0]/a[0],s[1]=s[1]/a[0]):a[0]<a[1]&&(s[0]=s[0]/a[1],s[1]=s[1]/a[1])}return[s[0]+"px",s[1]+"px"]}}function ce(e,l){const o=document.getElementsByClassName(e);for(let n=0;n<o.length;n++){const i=o[n];if(i.id===l)return i}}function Q(){return window.NotifiyQueen=window.NotifiyQueen||[],window.NotifiyQueen}function de(e){return typeof e!="string"||["lt","lb","rt","rb"].indexOf(e)===-1?"rt":e}function j(){return 15}function ue(e,l){const o=j(),n=parseFloat(l==null?void 0:l[0])||0;return e==="rt"?{left:`calc(100% - ${n+o}px)`}:e==="rb"?{left:`calc(100% - ${n+o}px)`}:e==="lt"?{left:`${o}px`}:{left:`${o}px`}}function me(e,l,o){const n=j();return e==="rb"||e==="lb"?`calc(100% - ${Math.max(n+l+o,o)}px)`:`${Math.max(n+l,n)}px`}function Z(e){const l=de(e),o=Q().filter(i=>i.offset===l);if(o.length===0)return;let n=0;o.forEach(i=>{const s=ce("zan-layer",i.id);if(!s)return;const c=[`${s.offsetWidth}px`,`${s.offsetHeight}px`],a=ue(l,c);s.style.top=me(l,n,s.offsetHeight),s.style.left=a.left,n+=s.offsetHeight+j()})}function Ne(e,l,o){const n=de(e),i=Q();i.some(d=>d.id===o)||i.push({id:o,offset:n});const s=i.filter(d=>d.offset===n),c=ue(n,l);let a=0;return s.slice(0,-1).forEach(d=>{const m=ce("zan-layer",d.id);m&&(a+=m.offsetHeight+j())}),[me(n,a,parseFloat(l==null?void 0:l[1])||0),c.left]}function Ve(e){const l=Q(),o=l.findIndex(i=>i.id===e);if(o===-1)return;const n=l[o].offset;l.splice(o,1),Z(n)}function $e(e){const l="zan-layer-drawer-anim zan-layer-anim";let o="";return e==="lt"||e==="lb"?o="lr":o="rl",`${l}-${o}`}const Le=t.defineComponent({name:"Header",__name:"Header",props:{title:{type:[String,Object,Symbol,Function,Boolean]},titleStyle:{type:[String,Boolean,null,Object,Array]},move:{type:Boolean}},setup(e){const l=e,o=t.computed(()=>[l.move?"cursor: move":"",l.titleStyle]);return(n,i)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-title",style:t.normalizeStyle(o.value)},[t.renderSlot(n.$slots,"default",{},()=>[t.createVNode(_,{render:()=>t.unref(M)(e.title)},null,8,["render"])])],4))}}),Ie=t.defineComponent({name:"Footer",__name:"Footer",props:{footer:{type:[String,Object,Symbol,Function,Boolean]},footerStyle:{type:[String,Boolean,null,Object,Array]}},setup(e){return(l,o)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-footer",style:t.normalizeStyle(e.footerStyle)},[t.renderSlot(l.$slots,"default",{},()=>[t.createVNode(_,{render:()=>t.unref(M)(e.footer)},null,8,["render"])])],4))}}),Fe={class:"zan-layer-setwin"},Oe={class:"zan-tooltip"},Me={class:"zan-tooltip"},Ae=((e,l)=>{const o=e.__vccOpts||e;for(const[n,i]of l)o[n]=i;return o})(t.defineComponent({name:"HeaderBtn",__name:"HeaderBtn",props:{maxmin:{type:Boolean},min:{type:Boolean},max:{type:Boolean},closeBtn:{type:[String,Boolean],default:"1"}},emits:["onMin","onMax","onClose"],setup(e,{emit:l}){const o=e,n=l,i=()=>{n("onMin")},s=()=>{n("onMax")},c=()=>{n("onClose")};return(a,d)=>(t.openBlock(),t.createElementBlock("span",Fe,[o.maxmin&&!o.max?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(["zan-icon-btn",o.min?"zan-icon-full":"zan-icon-min"]),onClick:t.withModifiers(i,["stop"])},[t.createElementVNode("span",Oe,t.toDisplayString(o.min?"还原":"最小化"),1)],2)):t.createCommentVNode("",!0),o.maxmin&&!o.min?(t.openBlock(),t.createElementBlock("i",{key:1,class:t.normalizeClass(["zan-icon-btn",o.max?"zan-icon-restore":"zan-icon-max"]),onClick:t.withModifiers(s,["stop"])},[t.createElementVNode("span",Me,t.toDisplayString(o.max?"还原":"最大化"),1)],2)):t.createCommentVNode("",!0),o.closeBtn?(t.openBlock(),t.createElementBlock("i",{key:2,class:t.normalizeClass(["zan-icon-btn zan-icon-close-btn",`zan-layer-close${e.closeBtn}`]),onClick:t.withModifiers(c,["stop"])},[...d[0]||(d[0]=[t.createElementVNode("span",{class:"zan-tooltip"},"关闭",-1)])],2)):t.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-a2b66c03"]]),He={class:"zan-layer-phimg"},De=["src"],Te={key:0,class:"zan-layer-imgsee"},Pe={key:0,class:"zan-layer-imguide"},_e={key:0,class:"thumb-row"},je=["onClick"],Re=["src"],We={key:1,class:"zan-layer-imgtit"},Xe={key:0},Ye={key:1},qe=t.defineComponent({name:"Photos",__name:"Photos",props:{imgList:{},startIndex:{default:0}},emits:["resetCalculationPohtosArea"],setup(e,{emit:l}){const o=l,n=e,i=t.ref(n.startIndex);t.watch(i,()=>{o("resetCalculationPohtosArea",i.value)});const s=d=>{let y=i.value+d;y<0&&(y=n.imgList.length-1),y>=n.imgList.length&&(y=0),i.value=y},c=t.ref(!1);t.onMounted(()=>{t.nextTick(()=>{setTimeout(()=>{c.value=!0},400)})});const a=t.computed(()=>{let d=!1;return n.imgList.forEach(m=>{m.thumb&&(d=!0)}),d});return(d,m)=>(t.openBlock(),t.createElementBlock("div",He,[t.createElementVNode("img",{src:e.imgList[i.value].src},null,8,De),e.imgList.length>0?(t.openBlock(),t.createElementBlock("div",Te,[e.imgList.length>1?(t.openBlock(),t.createElementBlock("span",Pe,[t.createElementVNode("a",{href:"javascript:;",class:"zan-layer-iconext zan-layer-imgprev",onClick:m[0]||(m[0]=y=>s(-1))},"‹"),t.createElementVNode("a",{href:"javascript:;",class:"zan-layer-iconext zan-layer-imgnext",onClick:m[1]||(m[1]=y=>s(1))},"›")])):t.createCommentVNode("",!0),e.imgList.length>1||e.imgList[i.value].alt?(t.openBlock(),t.createElementBlock("div",{key:1,class:"zan-layer-imgbar",style:t.normalizeStyle({opacity:c.value?1:0})},[a.value?(t.openBlock(),t.createElementBlock("div",_e,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.imgList,(y,r)=>(t.openBlock(),t.createElementBlock("div",{class:"thumb-box",key:"thumb-box"+r,onClick:p=>i.value=r},[t.createElementVNode("img",{src:y.thumb},null,8,Re)],8,je))),128)),t.createElementVNode("div",{class:"thumb-box-border",style:t.normalizeStyle({left:`calc(calc( calc(100% - ${100*e.imgList.length}px) / 2) + ${i.value*100}px)`})},null,4)])):(t.openBlock(),t.createElementBlock("span",We,[e.imgList[i.value].alt?(t.openBlock(),t.createElementBlock("span",Xe,t.toDisplayString(e.imgList[i.value].alt),1)):t.createCommentVNode("",!0),e.imgList.length>1?(t.openBlock(),t.createElementBlock("em",Ye,t.toDisplayString(i.value+1)+" / "+t.toDisplayString(e.imgList.length),1)):t.createCommentVNode("",!0)]))],4)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0)]))}}),Ge={class:"title"},Qe={key:0,class:"content"},Ze=["innerHTML"],Ue=t.defineComponent({name:"Notifiy",__name:"Notifiy",props:{title:{},content:{},isHtmlFragment:{type:Boolean,default:!1},icon:{},iconClass:{},offset:{}},emits:["close"],setup(e,{emit:l}){const o=e,n=l,i=t.shallowRef(null);let s,c=0;const a=()=>{n("close")};function d(y,r){let p=y.className,h=p!=""?" ":"",E=p+h+r;y.className=E}const m=()=>{c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,Z(o.offset)})};return t.onMounted(()=>{t.nextTick(()=>{setTimeout(()=>{var y,r,p,h;(r=(y=i.value)==null?void 0:y.parentElement)!=null&&r.parentElement&&(d((h=(p=i.value)==null?void 0:p.parentElement)==null?void 0:h.parentElement,"zan-layer-notifiy-transition"),m(),i.value&&!s&&(s=new ResizeObserver(()=>{m()}),s.observe(i.value)))},300)})}),t.onUnmounted(()=>{c&&(cancelAnimationFrame(c),c=0),s&&(s.disconnect(),s=void 0)}),(y,r)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-notifiy-wrapper",ref_key:"notifyRef",ref:i},[t.createElementVNode("h2",Ge,[e.icon?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(e.iconClass)},null,2)):t.createCommentVNode("",!0),t.createElementVNode("span",null,t.toDisplayString(e.title),1)]),!e.isHtmlFragment&&e.content?(t.openBlock(),t.createElementBlock("div",Qe,[t.createVNode(_,{render:()=>t.unref(M)(o.content)},null,8,["render"])])):e.isHtmlFragment&&e.content?(t.openBlock(),t.createElementBlock("div",{key:1,class:"content",innerHTML:e.content},null,8,Ze)):t.createCommentVNode("",!0),t.createElementVNode("i",{class:"zan-icon-close",onClick:a},[...r[0]||(r[0]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16"},[t.createElementVNode("path",{d:"M810.666667 273.493333L750.506667 213.333333 512 451.84 273.493333 213.333333 213.333333 273.493333 451.84 512 213.333333 750.506667 273.493333 810.666667 512 572.16 750.506667 810.666667 810.666667 750.506667 572.16 512z",fill:"currentColor"})],-1)])])],512))}}),Ke=["maxlength","placeholder"],Je=["type","placeholder"],et=t.defineComponent({name:"Prompt",__name:"Prompt",props:{promptValue:{},formType:{default:"text"},maxLength:{},placeholder:{default:""}},emits:["update:promptValue"],setup(e,{emit:l}){const o=e,n=t.ref(o.promptValue),i=t.computed(()=>{switch(typeof o.formType){case"string":return o.formType==="textarea";case"number":return o.formType===2;default:return!1}}),s=t.computed(()=>o.formType==1||o.formType=="password");return(c,a)=>i.value?t.withDirectives((t.openBlock(),t.createElementBlock("textarea",{key:0,onInput:a[0]||(a[0]=d=>c.$emit("update:promptValue",n.value)),"onUpdate:modelValue":a[1]||(a[1]=d=>n.value=d),maxlength:o.maxLength,placeholder:o.placeholder,class:"zan-textarea"},null,40,Ke)),[[t.vModelText,n.value]]):t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:1,onInput:a[2]||(a[2]=d=>c.$emit("update:promptValue",n.value)),"onUpdate:modelValue":a[3]||(a[3]=d=>n.value=d),type:s.value?"password":"text",placeholder:o.placeholder,class:"zan-input"},null,40,Je)),[[t.vModelDynamic,n.value]])}});function tt(e){for(;e&&e.parentNode;)if(e=e.parentNode,e&&getComputedStyle(e).position==="relative")return e;return null}const R=e=>{document.querySelectorAll(".zan-layer iframe").forEach(o=>{o.style.pointerEvents=e})},nt=function(e,l,o,n,i){let s,c,a=0,d=0,m=!0;const y=r=>{const p=r.target;return!p||p.closest("button, input, textarea, select, a")?!1:(r.composedPath&&r.composedPath()||r.path||[]).some(E=>E instanceof HTMLElement&&E.classList.contains("zan-layer-title"))};e!=null&&e.addEventListener("mousedown",function(r){if(y(r)&&r.button==0&&e!=null){R("none");const p=getComputedStyle(e);s=r.pageX-e.offsetLeft+parseInt(p["margin-left"]),c=r.pageY-e.offsetTop+parseInt(p["margin-right"]),a=r.clientX,d=r.clientY,document.body.style.userSelect="none",document.body.style.cursor="move";const h=function(z){if(e!=null){(z.clientX-a!=0||z.clientY-d!=0)&&m&&(m=!1,i());let g=z.pageX-s,k=z.pageY-c;const b=document.documentElement.clientWidth,C=document.documentElement.clientHeight;if(!l){let S=b-e.offsetWidth,w=C-e.offsetHeight;if(e.style.position==="absolute"){const v=tt(e);v!=null&&(S=v.clientWidth-e.offsetWidth,w=v.clientHeight-e.offsetHeight)}g<0?g=0:g>S&&(g=S),k<0?k=0:k>w&&(k=w)}e.style.top=k+"px",e.style.left=g+"px",o(e.style.left,e.style.top)}return!1},E=function(){m=!0,document.body.style.userSelect="",document.body.style.cursor="",n(),R("auto"),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",h,{passive:!1}),document.addEventListener("mouseup",E)}return!1})},lt=function(e,l,o,n){let i=0,s=0,c=!0;e!=null&&e.addEventListener("mousedown",function(a){if((a.composedPath&&a.composedPath()||a.path)[0].className==="zan-layer-resize"&&a.button==0&&e!=null){R("none");const m=e.getBoundingClientRect(),y=m.left,r=m.top;i=a.clientX,s=a.clientY,document.body.style.userSelect="none",document.body.style.cursor="se-resize";const p=function(E){var z;if(window.getSelection!=null&&((z=window.getSelection())==null||z.removeAllRanges()),e!=null){const g=E.clientX,k=E.clientY;(g-i!=0||k-s!=0)&&c&&(c=!1,n());let b=g-y,C=k-r;b<260&&(b=260),C<115&&(C=115),e.style.width=b+"px",e.style.height=C+"px",l(e.style.width,e.style.height)}return!1};document.addEventListener("mousemove",p,{passive:!1});const h=function(){c=!0,document.body.style.userSelect="",document.body.style.cursor="",o(),R("auto"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)};document.addEventListener("mouseup",h)}return!1})},ot=Symbol("zIndex");let at=99999;function fe(){return++at}const it=["id"],st={key:1,class:"slot-fragment"},rt=["innerHTML"],ct=["onClick"],dt={key:2,class:"zan-layer-resize"},W=t.defineComponent({name:"ZanLayer",__name:"ZanLayer",props:{modelValue:{type:Boolean,default:!1},type:{default:1},title:{type:[String,Object,Symbol,Function,Boolean],default:"标题"},footer:{type:[String,Object,Symbol,Function,Boolean]},titleStyle:{type:[String,Boolean,null,Object,Array],default:""},footerStyle:{type:[String,Boolean,null,Object,Array]},content:{},isHtmlFragment:{type:Boolean,default:!1},offset:{default:()=>"auto"},area:{default:()=>"auto"},move:{type:Boolean,default:!0},maxmin:{type:Boolean,default:!1},resize:{type:Boolean,default:!1},shade:{type:Boolean,default:!0},shadeClose:{type:Boolean,default:!0},shadeStyle:{type:[Boolean,null,String,Object,Array]},shadeOpacity:{default:"0.1"},layerClasses:{},contentClass:{default:""},zIndex:{},closeBtn:{type:[Boolean,String],default:"1"},btn:{},btnAlign:{default:"r"},anim:{default:0},isOutAnim:{type:Boolean,default:!0},icon:{},imgList:{default:()=>[]},startIndex:{default:0},animDuration:{default:"0.3s"},moveOut:{type:Boolean,default:!1},teleport:{default:"body"},teleportDisabled:{type:Boolean,default:!1},lastPosition:{type:Boolean,default:!0},time:{default:0},load:{default:0},yesText:{default:"确定"},formType:{default:"text"},value:{default:""},maxLength:{},placeholder:{default:"请输入内容"},isMessage:{type:Boolean,default:!1},id:{},isFunction:{type:Boolean,default:!1},appContext:{},success:{type:Function,default:()=>{}},end:{type:Function,default:()=>{}},yes:{},beforeClose:{type:Function,default:()=>!0},close:{type:Function,default:()=>{}},min:{type:Function,default:()=>{}},full:{type:Function,default:()=>{}},revert:{type:Function,default:()=>{}},moveStart:{type:Function,default:()=>{}},moving:{type:Function,default:()=>{}},moveEnd:{type:Function,default:()=>{}},resizeStart:{type:Function,default:()=>{}},resizing:{type:Function,default:()=>{}},resizeEnd:{type:Function,default:()=>{}},internalDestroy:{}},emits:["close","update:modelValue","opened"],setup(e,{expose:l,emit:o}){const n=e,i=o,s=t.useSlots(),c=t.ref(!1),a=t.ref(!1),d=t.ref(n.id||te()),m=t.ref(null),y=t.ref(),r=ve(n.type),p=t.ref(Se(n.type,n.area,n.offset)),h=t.ref(G(n.offset,p.value,r)),E=t.ref(99999),z=t.ref(!1),g=t.ref(p.value[0]),k=t.ref(p.value[1]),b=t.ref(h.value[0]),C=t.ref(h.value[1]),S=t.ref(""),w=t.ref(""),v=t.ref(""),$=t.ref(""),X=t.ref(!1),T=t.ref(n.value);t.watch(()=>n.value,()=>{T.value=n.value});const pe=()=>{E.value=n.zIndex??fe()};t.watch(()=>n.zIndex,()=>{pe()},{immediate:!0});const ye=function(){t.nextTick(async()=>{r==4&&(p.value=ne(n.offset,n.area)),r==5&&(p.value=await re(n.imgList[n.startIndex].src));let u=p.value;(u[0]==null||u[1]==null)&&(u=ie(m.value)),r==6&&(h.value=Ne(n.offset,u,d.value)),q(),be(),Bt()})},kt=function(){a.value&&xe(),c.value&&ge(),S.value="",w.value="",v.value="",$.value=""},he=()=>{v.value=b.value,$.value=C.value,S.value=g.value,w.value=k.value,g.value=oe().w,k.value=oe().h,b.value=ae().t,C.value=ae().l},ge=()=>{c.value?(P(),g.value=S.value,k.value=w.value,n.revert(d.value)):(O(),he(),n.full(d.value)),c.value=!c.value},ke=()=>{let ee=10+190*A(d.value,!0);const Pt=document.documentElement.clientWidth;ee+180>Pt&&(ee=10),S.value=g.value,w.value=k.value,v.value=b.value,$.value=C.value,k.value="51px",g.value="180px",b.value="calc(100% - 51px)",C.value=ee+"px"},xe=async()=>{a.value?(P(),A(d.value,!1),g.value=S.value,k.value=w.value,n.revert(d.value)):(O(),ke(),n.min(d.value)),a.value=!a.value};t.watch(()=>n.modelValue,u=>{z.value!==u&&(z.value=u)},{immediate:!0}),t.watch(()=>z.value,(u,f)=>{if(u!==f&&!(!u&&f===void 0)){if(u){X.value=!1,ye(),pe(),P(),n.isFunction&&ye(),t.nextTick(()=>{n.success(d.value)});return}O(),kt(),f!==void 0&&n.end(d.value)}},{immediate:!0,flush:"post"});const xt=t.computed(()=>[{"zan-layer-dialog":r===0||r===7,"zan-layer-page":r===1,"zan-layer-iframe":r===2,"zan-layer-loading":r===3,"zan-layer-drawer":r===4,"zan-layer-photos":r===5,"zan-layer-notifiy":r===6,"zan-layer-msg":n.isMessage,"zan-layer-hui":n.isMessage&&!n.icon},n.layerClasses]),Bt=function(){n.move&&r!=4&&t.nextTick(()=>{m.value&&(nt(m.value,n.moveOut,(u,f)=>{C.value=u,b.value=f,X.value=!0,a.value||($.value=u,v.value=f),n.moving(d.value,{top:f,left:u})},()=>{const u={left:C.value,top:b.value,isMin:a.value,isMax:c.value},[f,x]=n.moveEnd(d.value,u)||[];x&&f&&(C.value=f,b.value=x)},()=>{n.moveStart(d.value)}),lt(m.value,(u,f)=>{k.value=f,g.value=u,w.value=f,S.value=u,n.resizing(d.value,{width:u,height:f})},()=>{const u={width:g.value,height:k.value},[f,x]=n.resizeEnd(d.value,u)||[];f&&x&&(g.value=f,k.value=x)},()=>{n.resizeStart(d.value)}))})},bt=t.computed(()=>({position:n.teleportDisabled||n.teleport!="body"?"absolute":"fixed",top:b.value,left:C.value,height:k.value,width:g.value,animationDuration:n.animDuration,zIndex:E.value})),Ct=t.computed(()=>[r===3?`zan-layer-loading${n.load}`:"",n.icon?"zan-layer-padding":"",n.contentClass]),Y=()=>{if(typeof n.beforeClose=="function"){const u=n.beforeClose(d.value);(u===void 0||u!=null&&u===!0)&&(n.close(d.value),i("close"),i("update:modelValue",!1),n.internalDestroy&&n.internalDestroy(),a.value&&A(d.value,!a.value))}},zt=(...u)=>{typeof n.yes=="function"?n.yes(...u):Y()},Et=()=>{n.shadeClose&&Y()},Be=t.computed(()=>["zan-icon",`zan-icon-ico${n.icon}`]),St=t.computed(()=>r===4?se(n.offset):r===6?$e(n.offset):`zan-layer-anim-0${n.anim}`),wt=t.computed(()=>r===4?se(n.offset,!0):n.isOutAnim?"zan-layer-anim-close":""),vt=()=>{z.value=!0},Nt=()=>{z.value=!1,r===6&&Ve(d.value)},Vt=t.computed(()=>z.value&&n.shade&&!a.value),$t=t.computed(()=>n.resize&&!c.value&&!a.value),Lt=t.computed(()=>n.title&&r!=3&&r!=5&&r!=6),It=function(u){t.nextTick(async()=>{p.value=await re(n.imgList[u].src),h.value=G(n.offset,p.value,r),g.value=p.value[0],k.value=p.value[1],b.value=h.value[0],C.value=h.value[1],S.value=p.value[0],w.value=p.value[1]})},Ft=function(){n.zIndex||(E.value=fe())},Ot=(u,f)=>((u==null?void 0:u[0])||"")===((f==null?void 0:f[0])||"")&&((u==null?void 0:u[1])||"")===((f==null?void 0:f[1])||""),Mt=()=>{r===6&&Z(n.offset),i("opened")};t.onMounted(()=>{}),t.onUnmounted(()=>{O()});let L,I=0;const P=function(){t.nextTick(()=>{!z.value||!y.value||L||r==6||y.value&&!L&&r!=6&&(L=new ResizeObserver(()=>{m.value&&(I&&cancelAnimationFrame(I),I=requestAnimationFrame(()=>{if(I=0,!m.value)return;const u=G(n.offset,ie(m.value),r);if(Ot(h.value,u)||(h.value=u),X.value&&n.lastPosition)return;const f=n.lastPosition&&v.value||u[0],x=n.lastPosition&&$.value||u[1];b.value!==f&&(b.value=f),C.value!==x&&(C.value=x)}))}),L.observe(y.value))})},O=function(){I&&(cancelAnimationFrame(I),I=0),L&&(L.disconnect(),L=void 0)},q=function(u=!1){b.value=u&&n.lastPosition&&v.value||h.value[0],C.value=u&&n.lastPosition&&$.value||h.value[1]},be=function(){g.value=p.value[0],k.value=p.value[1],S.value=p.value[0],w.value=p.value[1]},At=function(){P(),A(d.value,!1),a.value=!1,c.value=!1,X.value=!1,v.value="",$.value="",q(),be(),n.modelValue||i("update:modelValue",!0)},Ht=async function(){a.value&&(K(),q(!0)),c.value||(await t.nextTick(),O(),he(),c.value=!0)},Dt=async function(){c.value&&(K(),q(!0)),a.value||(await t.nextTick(),O(),ke(),a.value=!0)},K=()=>{P(),A(d.value,!1),a.value=!1,c.value=!1,g.value=S.value,k.value=w.value};return l({reset:At,open:vt,close:Nt,full:Ht,min:Dt,revert:K}),(u,f)=>(t.openBlock(),t.createBlock(t.Teleport,{to:e.teleport,disabled:e.teleportDisabled},[t.createVNode(Ce,{index:E.value,"shade-style":e.shadeStyle,visible:Vt.value,opacity:e.shadeOpacity,teleport:e.teleport,teleportDisabled:e.teleportDisabled,onShadeClick:Et},null,8,["index","shade-style","visible","opacity","teleport","teleportDisabled"]),t.createVNode(t.Transition,{"enter-active-class":St.value,"leave-active-class":wt.value,onAfterEnter:Mt},{default:t.withCtx(()=>[z.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"layerRef",ref:m,class:t.normalizeClass(["zan-layer zan-layer-border",[xt.value,{"zan-layer-min":a.value}]]),id:d.value,style:t.normalizeStyle(bt.value)},[Lt.value?(t.openBlock(),t.createBlock(Le,{key:0,title:e.title,titleStyle:e.titleStyle,move:e.move,onMousedown:Ft},{default:t.withCtx(()=>[t.renderSlot(u.$slots,"title")]),_:3},8,["title","titleStyle","move"])):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"contentRef",ref:y,class:t.normalizeClass(["zan-layer-content",Ct.value]),style:t.normalizeStyle(a.value===!0?"display:none":"")},[t.unref(r)===0||t.unref(r)===1||t.unref(r)===4?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[e.icon?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(Be.value)},null,2)):t.createCommentVNode("",!0),t.unref(s).default?(t.openBlock(),t.createElementBlock("div",st,[t.renderSlot(u.$slots,"default")])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[e.isHtmlFragment?(t.openBlock(),t.createElementBlock("div",{key:0,class:"html-fragment",innerHTML:t.unref(M)(n.content)},null,8,rt)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[n.content?(t.openBlock(),t.createBlock(_,{key:0,render:()=>t.unref(M)(n.content)},null,8,["render"])):t.createCommentVNode("",!0)],64))],64))],64)):t.createCommentVNode("",!0),t.unref(r)===7?(t.openBlock(),t.createBlock(et,{key:1,"prompt-value":T.value,"onUpdate:promptValue":f[0]||(f[0]=x=>T.value=x),formType:n.formType,maxLength:n.maxLength,placeholder:n.placeholder},null,8,["prompt-value","formType","maxLength","placeholder"])):t.createCommentVNode("",!0),t.unref(r)===2?(t.openBlock(),t.createBlock(Ee,{key:2,src:n.content},null,8,["src"])):t.createCommentVNode("",!0),t.unref(r)===5?(t.openBlock(),t.createBlock(qe,{key:3,imgList:n.imgList,startIndex:n.startIndex,onResetCalculationPohtosArea:It},null,8,["imgList","startIndex"])):t.createCommentVNode("",!0),t.unref(r)===6?(t.openBlock(),t.createBlock(Ue,{key:4,onClose:Y,title:n.title,content:n.content,isHtmlFragment:n.isHtmlFragment,icon:n.icon,iconClass:Be.value,offset:n.offset},null,8,["title","content","isHtmlFragment","icon","iconClass","offset"])):t.createCommentVNode("",!0)],6),t.unref(r)!=3&&t.unref(r)!=5&&t.unref(r)!=6?(t.openBlock(),t.createBlock(Ae,{key:1,maxmin:e.maxmin,max:c.value,min:a.value,closeBtn:e.closeBtn,onOnMin:xe,onOnMax:ge,onOnClose:Y},null,8,["maxmin","max","min","closeBtn"])):t.createCommentVNode("",!0),t.createElementVNode("div",{style:t.normalizeStyle(a.value===!0?"display:none":"")},[t.unref(s).footer||n.footer?(t.openBlock(),t.createBlock(Ie,{key:0,footer:n.footer,footerStyle:n.footerStyle},{default:t.withCtx(()=>[t.renderSlot(u.$slots,"footer")]),_:3},8,["footer","footerStyle"])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[(e.btn&&e.btn.length>0||t.unref(r)===0||t.unref(r)===7)&&!e.isMessage?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["zan-layer-btn",[`zan-layer-btn-${e.btnAlign}`]])},[e.btn&&e.btn.length>0?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(e.btn,(x,J)=>(t.openBlock(),t.createElementBlock("a",{key:J,style:t.normalizeStyle(x.style),class:t.normalizeClass([x.class,`zan-layer-btn${J}`,{"zan-layer-btn-disabled":x.disabled}]),onClick:Tt=>!x.disabled&&(t.unref(r)===7?x.callback(d.value,T.value):x.callback(d.value))},t.toDisplayString(x.text),15,ct))),128)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.unref(r)===0||t.unref(r)===7?(t.openBlock(),t.createElementBlock("a",{key:0,class:"zan-layer-btn0",onClick:f[1]||(f[1]=x=>zt(d.value,T.value))},t.toDisplayString(e.yesText),1)):t.createCommentVNode("",!0)],64))],2)):t.createCommentVNode("",!0)],64))],4),$t.value?(t.openBlock(),t.createElementBlock("span",dt)):t.createCommentVNode("",!0)],14,it)):t.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"])],8,["to","disabled"]))}}),V=[],ut=e=>{V.push(e)},U=e=>{V.forEach((l,o)=>{l.modalContainer.id===e&&V.splice(o,1)})},mt=()=>{V.splice(0,V.length)},H=e=>{let l=!1;return V.forEach((o,n)=>{o.modalContainer.id==e&&(l=!0)}),l},D=e=>{let l=null;return V.forEach((o,n)=>{o.modalContainer.id===e&&(l=o)}),l},ft=(e,l)=>(e&&(l=Object.assign(l,e)),l),pt=e=>{const l=document.createElement("div");return l.id=e.id,document.body.appendChild(l),l},yt=e=>typeof e=="function"?t.isVNode(e())?{default:()=>e()}:void 0:t.isVNode(e)?{default:()=>e}:void 0,B={_context:null,open:e=>{const l={};return B.create(e,l)},drawer:e=>{const l={type:"drawer"};return B.create(e,l)},msg:(e,l={},o)=>{const n={type:0,title:!1,content:e,shadeClose:!1,closeBtn:!1,isMessage:!0,shade:!1,btn:void 0,time:2e3};return B.create(l,n,o)},load:(e=0,l={})=>{const o={type:3,load:e,anim:5,isOutAnim:!1,shadeClose:!1,shade:!0,shadeOpacity:"0.3"};return B.create(l,o)},confirm:(e,l={})=>{const o={type:0,content:e,shadeClose:!1};return B.create(l,o)},notify:(e,l)=>{e.type=6;const o={offset:"rt",time:3e3,area:"auto",shade:!1};return B.create(e,o,l)},photos:e=>{typeof e=="string"&&(e={imgList:[{src:e}]});const l={type:5,anim:2,startIndex:0,isOutAnim:!0,shadeClose:!0,shadeOpacity:"0.2"};return B.create(e,l)},prompt:e=>{e.type=7;const l={type:"prompt",shadeClose:!1,shadeOpacity:"0.2"};return B.create(e,l)},create:(e,l,o)=>{var a,d;let n;const i=ft(e,l);i.hasOwnProperty("id")?B.close(i.id):i.id=te();const s=pt(i),c=t.h(W,{...i,isFunction:!0,internalDestroy(){var m,y;n&&clearTimeout(n),(y=(m=c.component)==null?void 0:m.exposed)==null||y.close(),setTimeout(()=>{t.render(null,s),document.body.contains(s)&&document.body.removeChild(s)},500),U(s.id)}},yt(i.content));return c.appContext=i.appContext||B._context,t.render(c,s),(d=(a=c.component)==null?void 0:a.exposed)==null||d.open(),l&&l.time!=null&&l.time!=0&&(n=setTimeout(()=>{var m,y;(y=(m=c.component)==null?void 0:m.exposed)==null||y.close(),o&&o(s.id),setTimeout(()=>{t.render(null,s),document.body.contains(s)&&document.body.removeChild(s)},500),U(s.id)},l.time)),ut({modalContainer:s,modalInstance:c}),s.id},close:e=>{var l,o;if(e!=null&&H(e)){const n=D(e);(o=(l=n.modalInstance.component)==null?void 0:l.exposed)==null||o.close(),setTimeout(()=>{t.render(null,n.modalContainer),document.body.contains(n.modalContainer)&&document.body.removeChild(n.modalContainer)},500)}U(e)},closeAll:()=>{V.forEach(e=>{var l,o;(o=(l=e.modalInstance.component)==null?void 0:l.exposed)==null||o.close(),setTimeout(()=>{t.render(null,e.modalContainer),document.body.contains(e.modalContainer)&&document.body.removeChild(e.modalContainer)},500)}),mt()},reset:e=>{var l,o;e!=null&&H(e)&&((o=(l=D(e).modalInstance.component)==null?void 0:l.exposed)==null||o.reset())},min:e=>{var l,o;e!=null&&H(e)&&((o=(l=D(e).modalInstance.component)==null?void 0:l.exposed)==null||o.min())},full:e=>{var l,o;e!=null&&H(e)&&((o=(l=D(e).modalInstance.component)==null?void 0:l.exposed)==null||o.full())},revert:e=>{var l,o;e!=null&&H(e)&&((o=(l=D(e).modalInstance.component)==null?void 0:l.exposed)==null||o.revert())}},ht=(e,l)=>{B._context=e._context,e.component(W.name,W),e.config.globalProperties.$layer=B,l&&typeof l.zIndex=="number"&&e.provide(ot,t.ref(l.zIndex))},gt={install(e,l){ht(e,l)}};N.ZanLayer=W,N.default=gt,N.layer=B,N.zanLayer=B,Object.defineProperties(N,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(L,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(L=typeof globalThis<"u"?globalThis:L||self,t(L.ZanLayer={},L.Vue))})(this,function(L,t){"use strict";const Oe=t.defineComponent({name:"Shade",__name:"Shade",props:{visible:{type:[Boolean,String]},opacity:{},index:{type:[Number,Function]},teleport:{},teleportDisabled:{type:Boolean},shadeStyle:{type:[Boolean,null,String,Object,Array]}},emits:["shadeClick"],setup(e,{emit:o}){const l=e,n=o,i=t.computed(()=>[{opacity:l.opacity,position:l.teleportDisabled||l.teleport!="body"?"absolute":"fixed",zIndex:l.index},l.shadeStyle]),r=()=>{n("shadeClick")};return(d,a)=>e.visible?(t.openBlock(),t.createElementBlock("div",{key:0,class:"zan-layer-shade",style:t.normalizeStyle(i.value),onClick:r},null,4)):t.createCommentVNode("",!0)}}),Ae=["src"],Me=t.defineComponent({name:"Iframe",__name:"Iframe",props:{src:{}},setup(e){const o=e,l=t.computed(()=>o.src);return(n,i)=>(t.openBlock(),t.createElementBlock("iframe",{scrolling:"auto",class:"zan-layer-iframe",allowtransparency:"true",frameborder:"0",src:l.value},null,8,Ae))}}),Z=t.defineComponent({name:"ZanRender",props:{render:{type:Function,required:!0}},setup(e){return()=>e.render()}}),R=function(e){return typeof e=="function"?e():typeof e=="string"?t.h("span",e):e};function re(){const e=[],o="0123456789abcdef";for(let n=0;n<36;n++)e[n]=o.substr(Math.floor(Math.random()*16),1);return e[14]="4",e[19]=o.substr(e[19]&3|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("").replaceAll("-","")}function T(e){if(!(e==null||e==="")){if(typeof e=="number"&&Number.isFinite(e))return`${e}px`;if(typeof e=="string")return e.trim()||void 0}}function Te(e,o,l){const n=T(o),i=T(l);if(n!==void 0||i!==void 0){const r=se(e),d=Array.isArray(r)?r:typeof r=="string"&&r!=="auto"?[r]:[];return[n??d[0],i??d[1]]}return se(e)}function We(e,o,l){return e!="drawer"&&e!=4?De(o):Pe(l,o)}function se(e){return e==null||e==="auto"?"auto":typeof e=="number"?`${e}px`:typeof e=="string"?e.trim()||"auto":Array.isArray(e)?[T(e[0]),T(e[1])]:"auto"}function De(e){return e==null||e==="auto"?[]:typeof e=="string"?[e]:e[1]&&e[1]==="auto"?e[0]&&e[0]==="auto"?[]:[e[0]]:e[0]&&e[0]==="auto"?e[1]&&e[1]!="auto"?[void 0,e[1]]:[]:[...e]}function Pe(e,o="30%"){return o==null&&(o="30%"),o instanceof Array?o:(o==="auto"&&(o="30%"),e==="l"||e==="r"||e==="lt"||e==="lb"||e==="rt"||e==="rb"?[o,"100%"]:e==="t"||e==="b"||e==="tr"||e==="tl"||e==="br"||e==="bl"?["100%",o]:[o,"100%"])}function ce(e){return e==null||e===""?"0px":e}function j(e,o,l){const n=T(e);if(!n)return l;const i=document.documentElement.clientWidth||window.innerWidth,r=document.documentElement.clientHeight||window.innerHeight,d=o==="width"?i:r,a=n.toLowerCase();if(a.endsWith("px"))return parseFloat(a);if(a.endsWith("%"))return d*parseFloat(a)/100;if(a.endsWith("vw"))return i*parseFloat(a)/100;if(a.endsWith("vh"))return r*parseFloat(a)/100;const c=parseFloat(a);return Number.isFinite(c)?c:l}function ne(e="auto",o,l){e==null&&(e="auto");const n=Array.isArray(o)?o:[],i=ce(n[0]),r=ce(n[1]),d=["t","r","b","l","lt","tl","lb","bl","rt","tr","rb","br"],a=[];return e==="auto"&&l==4&&(e="r"),typeof e=="string"?d.indexOf(e)>-1?(e==="t"&&(a[0]="0px",a[1]="calc(50% - "+i+"/2)"),e==="l"&&(a[0]="calc(50% - "+r+"/2)",a[1]="0px"),e==="b"&&(a[0]="calc(100% - "+r+")",a[1]="calc(50% - "+i+"/2)"),e==="r"&&(a[0]="calc(50% - "+r+"/2)",a[1]="calc(100% - "+i+")"),(e==="lt"||e==="tl")&&(a[0]="0px",a[1]="0px"),(e==="lb"||e==="bl")&&(a[0]="calc(100% - "+r+")",a[1]="0px"),(e==="rt"||e==="tr")&&(a[0]="0px",a[1]="calc(100% - "+i+")"),(e==="rb"||e==="br")&&(a[0]="calc(100% - "+r+")",a[1]="calc(100% - "+i+")")):e=="auto"?(a[0]="calc(50% - "+r+"/2)",a[1]="calc(50% - "+i+"/2)"):(a[0]=e,a[1]="calc(50% - "+i+"/2)"):e&&e[0]!==void 0&&e[1]!==void 0?(a[0]=e[0],a[1]=e[1]):(a[0]="calc(50% - "+r+"/2)",a[1]="calc(50% - "+i+"/2)"),a}function _e(e){return e==="dialog"||e==0?0:e==="page"||e==1?1:e==="iframe"||e==2?2:e==="loading"||e==3?3:e==="drawer"||e==4?4:e==="photos"||e==5?5:e==="notify"||e==6?6:e==="prompt"||e==7?7:0}function ue(){return{w:"100%",h:"100%"}}function de(){return{t:"0px",l:"0px"}}function me(e){var n,i;const o=(n=getComputedStyle(e,null))==null?void 0:n.width,l=(i=getComputedStyle(e,null))==null?void 0:i.height;return[o,l]}const W=[];function X(e,o){let l=0;if(o){const n=W.findIndex(i=>i===void 0);n===-1?(W.push(e),l=W.length-1):(W[n]=e,l=n)}else delete W[W.findIndex(n=>n==e)],l=-1;return l}function fe(e,o=!1){const l=["rl"],n="zan-layer-drawer-anim zan-layer-anim";return e==="l"||e==="lt"||e==="lb"?l[0]="lr":e==="r"||e==="rt"||e==="rb"?l[0]="rl":e==="t"||e==="tr"||e==="tl"?l[0]="tb":(e==="b"||e==="br"||e==="bl")&&(l[0]="bt"),o?`${n}-${l[0]}-close`:`${n}-${l[0]}`}async function pe(e,o){const l=new Image;return l.src=e,new Promise((i,r)=>{if(l.complete){i(n(l));return}const d=C.load(2,{shadeOpacity:"0"});l.onload=()=>{C.close(d),i(n(l))},l.onerror=()=>{C.close(d),C.msg("图片加载失败"),r(!1)}});function n(i){const r=[i.width,i.height],d=[window.innerWidth-250,window.innerHeight-250];if(r[0]>d[0]||r[1]>d[1]){const a=[r[0]/d[0],r[1]/d[1]];a[0]>a[1]?(r[0]=r[0]/a[0],r[1]=r[1]/a[0]):a[0]<a[1]&&(r[0]=r[0]/a[1],r[1]=r[1]/a[1])}return[r[0]+"px",r[1]+"px"]}}function ye(e,o){const l=document.getElementsByClassName(e);for(let n=0;n<l.length;n++){const i=l[n];if(i.id===o)return i}}function oe(){return window.NotifiyQueen=window.NotifiyQueen||[],window.NotifiyQueen}function he(e){return typeof e!="string"||["lt","lb","rt","rb"].indexOf(e)===-1?"rt":e}function U(){return 15}function ge(e,o){const l=U(),n=parseFloat(o==null?void 0:o[0])||0;return e==="rt"?{left:`calc(100% - ${n+l}px)`}:e==="rb"?{left:`calc(100% - ${n+l}px)`}:e==="lt"?{left:`${l}px`}:{left:`${l}px`}}function xe(e,o,l){const n=U();return e==="rb"||e==="lb"?`calc(100% - ${Math.max(n+o+l,l)}px)`:`${Math.max(n+o,n)}px`}function le(e){const o=he(e),l=oe().filter(i=>i.offset===o);if(l.length===0)return;let n=0;l.forEach(i=>{const r=ye("zan-layer",i.id);if(!r)return;const d=[`${r.offsetWidth}px`,`${r.offsetHeight}px`],a=ge(o,d);r.style.top=xe(o,n,r.offsetHeight),r.style.left=a.left,n+=r.offsetHeight+U()})}function Re(e,o,l){const n=he(e),i=oe();i.some(c=>c.id===l)||i.push({id:l,offset:n});const r=i.filter(c=>c.offset===n),d=ge(n,o);let a=0;return r.slice(0,-1).forEach(c=>{const p=ye("zan-layer",c.id);p&&(a+=p.offsetHeight+U())}),[xe(n,a,parseFloat(o==null?void 0:o[1])||0),d.left]}function je(e){const o=oe(),l=o.findIndex(i=>i.id===e);if(l===-1)return;const n=o[l].offset;o.splice(l,1),le(n)}function Xe(e){const o="zan-layer-drawer-anim zan-layer-anim";let l="";return e==="lt"||e==="lb"?l="lr":l="rl",`${o}-${l}`}const Ye=t.defineComponent({name:"Header",__name:"Header",props:{title:{type:[String,Object,Symbol,Function,Boolean]},titleStyle:{type:[String,Boolean,null,Object,Array]},move:{type:Boolean}},setup(e){const o=e,l=t.computed(()=>[o.move?"cursor: move":"",o.titleStyle]);return(n,i)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-title",style:t.normalizeStyle(l.value)},[t.renderSlot(n.$slots,"default",{},()=>[t.createVNode(Z,{render:()=>t.unref(R)(e.title)},null,8,["render"])])],4))}}),qe=t.defineComponent({name:"Footer",__name:"Footer",props:{footer:{type:[String,Object,Symbol,Function,Boolean]},footerStyle:{type:[String,Boolean,null,Object,Array]}},setup(e){return(o,l)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-footer",style:t.normalizeStyle(e.footerStyle)},[t.renderSlot(o.$slots,"default",{},()=>[t.createVNode(Z,{render:()=>t.unref(R)(e.footer)},null,8,["render"])])],4))}}),Ge={class:"zan-layer-setwin"},Qe={class:"zan-tooltip"},Ze={class:"zan-tooltip"},Ue=((e,o)=>{const l=e.__vccOpts||e;for(const[n,i]of o)l[n]=i;return l})(t.defineComponent({name:"HeaderBtn",__name:"HeaderBtn",props:{maxmin:{type:Boolean},min:{type:Boolean},max:{type:Boolean},closeBtn:{type:[String,Boolean],default:"1"}},emits:["onMin","onMax","onClose"],setup(e,{emit:o}){const l=e,n=o,i=()=>{n("onMin")},r=()=>{n("onMax")},d=()=>{n("onClose")};return(a,c)=>(t.openBlock(),t.createElementBlock("span",Ge,[l.maxmin&&!l.max?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(["zan-icon-btn",l.min?"zan-icon-full":"zan-icon-min"]),onClick:t.withModifiers(i,["stop"])},[t.createElementVNode("span",Qe,t.toDisplayString(l.min?"还原":"最小化"),1)],2)):t.createCommentVNode("",!0),l.maxmin&&!l.min?(t.openBlock(),t.createElementBlock("i",{key:1,class:t.normalizeClass(["zan-icon-btn",l.max?"zan-icon-restore":"zan-icon-max"]),onClick:t.withModifiers(r,["stop"])},[t.createElementVNode("span",Ze,t.toDisplayString(l.max?"还原":"最大化"),1)],2)):t.createCommentVNode("",!0),l.closeBtn?(t.openBlock(),t.createElementBlock("i",{key:2,class:t.normalizeClass(["zan-icon-btn zan-icon-close-btn",`zan-layer-close${e.closeBtn}`]),onClick:t.withModifiers(d,["stop"])},[...c[0]||(c[0]=[t.createElementVNode("span",{class:"zan-tooltip"},"关闭",-1)])],2)):t.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-a2b66c03"]]),Ke={class:"zan-layer-phimg"},Je=["src"],et={key:0,class:"zan-layer-imgsee"},tt={key:0,class:"zan-layer-imguide"},nt={key:0,class:"thumb-row"},ot=["onClick"],lt=["src"],at={key:1,class:"zan-layer-imgtit"},it={key:0},rt={key:1},st=t.defineComponent({name:"Photos",__name:"Photos",props:{imgList:{},startIndex:{default:0}},emits:["resetCalculationPohtosArea"],setup(e,{emit:o}){const l=o,n=e,i=t.ref(n.startIndex);t.watch(i,()=>{l("resetCalculationPohtosArea",i.value)});const r=c=>{let f=i.value+c;f<0&&(f=n.imgList.length-1),f>=n.imgList.length&&(f=0),i.value=f},d=t.ref(!1);t.onMounted(()=>{t.nextTick(()=>{setTimeout(()=>{d.value=!0},400)})});const a=t.computed(()=>{let c=!1;return n.imgList.forEach(p=>{p.thumb&&(c=!0)}),c});return(c,p)=>(t.openBlock(),t.createElementBlock("div",Ke,[t.createElementVNode("img",{src:e.imgList[i.value].src},null,8,Je),e.imgList.length>0?(t.openBlock(),t.createElementBlock("div",et,[e.imgList.length>1?(t.openBlock(),t.createElementBlock("span",tt,[t.createElementVNode("a",{href:"javascript:;",class:"zan-layer-iconext zan-layer-imgprev",onClick:p[0]||(p[0]=f=>r(-1))},"‹"),t.createElementVNode("a",{href:"javascript:;",class:"zan-layer-iconext zan-layer-imgnext",onClick:p[1]||(p[1]=f=>r(1))},"›")])):t.createCommentVNode("",!0),e.imgList.length>1||e.imgList[i.value].alt?(t.openBlock(),t.createElementBlock("div",{key:1,class:"zan-layer-imgbar",style:t.normalizeStyle({opacity:d.value?1:0})},[a.value?(t.openBlock(),t.createElementBlock("div",nt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.imgList,(f,s)=>(t.openBlock(),t.createElementBlock("div",{class:"thumb-box",key:"thumb-box"+s,onClick:w=>i.value=s},[t.createElementVNode("img",{src:f.thumb},null,8,lt)],8,ot))),128)),t.createElementVNode("div",{class:"thumb-box-border",style:t.normalizeStyle({left:`calc(calc( calc(100% - ${100*e.imgList.length}px) / 2) + ${i.value*100}px)`})},null,4)])):(t.openBlock(),t.createElementBlock("span",at,[e.imgList[i.value].alt?(t.openBlock(),t.createElementBlock("span",it,t.toDisplayString(e.imgList[i.value].alt),1)):t.createCommentVNode("",!0),e.imgList.length>1?(t.openBlock(),t.createElementBlock("em",rt,t.toDisplayString(i.value+1)+" / "+t.toDisplayString(e.imgList.length),1)):t.createCommentVNode("",!0)]))],4)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0)]))}}),ct={class:"title"},ut={key:0,class:"content"},dt=["innerHTML"],mt=t.defineComponent({name:"Notifiy",__name:"Notifiy",props:{title:{},content:{},isHtmlFragment:{type:Boolean,default:!1},icon:{},iconClass:{},offset:{}},emits:["close"],setup(e,{emit:o}){const l=e,n=o,i=t.shallowRef(null);let r,d=0;const a=()=>{n("close")};function c(f,s){let w=f.className,h=w!=""?" ":"",k=w+h+s;f.className=k}const p=()=>{d&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=0,le(l.offset)})};return t.onMounted(()=>{t.nextTick(()=>{setTimeout(()=>{var f,s,w,h;(s=(f=i.value)==null?void 0:f.parentElement)!=null&&s.parentElement&&(c((h=(w=i.value)==null?void 0:w.parentElement)==null?void 0:h.parentElement,"zan-layer-notifiy-transition"),p(),i.value&&!r&&(r=new ResizeObserver(()=>{p()}),r.observe(i.value)))},300)})}),t.onUnmounted(()=>{d&&(cancelAnimationFrame(d),d=0),r&&(r.disconnect(),r=void 0)}),(f,s)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-notifiy-wrapper",ref_key:"notifyRef",ref:i},[t.createElementVNode("h2",ct,[e.icon?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(e.iconClass)},null,2)):t.createCommentVNode("",!0),t.createElementVNode("span",null,t.toDisplayString(e.title),1)]),!e.isHtmlFragment&&e.content?(t.openBlock(),t.createElementBlock("div",ut,[t.createVNode(Z,{render:()=>t.unref(R)(l.content)},null,8,["render"])])):e.isHtmlFragment&&e.content?(t.openBlock(),t.createElementBlock("div",{key:1,class:"content",innerHTML:e.content},null,8,dt)):t.createCommentVNode("",!0),t.createElementVNode("i",{class:"zan-icon-close",onClick:a},[...s[0]||(s[0]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16"},[t.createElementVNode("path",{d:"M810.666667 273.493333L750.506667 213.333333 512 451.84 273.493333 213.333333 213.333333 273.493333 451.84 512 213.333333 750.506667 273.493333 810.666667 512 572.16 750.506667 810.666667 810.666667 750.506667 572.16 512z",fill:"currentColor"})],-1)])])],512))}}),ft=["maxlength","placeholder"],pt=["type","placeholder"],yt=t.defineComponent({name:"Prompt",__name:"Prompt",props:{promptValue:{},formType:{default:"text"},maxLength:{},placeholder:{default:""}},emits:["update:promptValue"],setup(e,{emit:o}){const l=e,n=t.ref(l.promptValue),i=t.computed(()=>{switch(typeof l.formType){case"string":return l.formType==="textarea";case"number":return l.formType===2;default:return!1}}),r=t.computed(()=>l.formType==1||l.formType=="password");return(d,a)=>i.value?t.withDirectives((t.openBlock(),t.createElementBlock("textarea",{key:0,onInput:a[0]||(a[0]=c=>d.$emit("update:promptValue",n.value)),"onUpdate:modelValue":a[1]||(a[1]=c=>n.value=c),maxlength:l.maxLength,placeholder:l.placeholder,class:"zan-textarea"},null,40,ft)),[[t.vModelText,n.value]]):t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:1,onInput:a[2]||(a[2]=c=>d.$emit("update:promptValue",n.value)),"onUpdate:modelValue":a[3]||(a[3]=c=>n.value=c),type:r.value?"password":"text",placeholder:l.placeholder,class:"zan-input"},null,40,pt)),[[t.vModelDynamic,n.value]])}});function ht(e){for(;e&&e.parentNode;)if(e=e.parentNode,e&&getComputedStyle(e).position==="relative")return e;return null}const K=e=>{document.querySelectorAll(".zan-layer iframe").forEach(l=>{l.style.pointerEvents=e})},gt=function(e,o,l,n,i){let r,d,a=0,c=0,p=!0;const f=s=>{const w=s.target;return!w||w.closest("button, input, textarea, select, a")?!1:(s.composedPath&&s.composedPath()||s.path||[]).some(k=>k instanceof HTMLElement&&k.classList.contains("zan-layer-title"))};e!=null&&e.addEventListener("mousedown",function(s){if(f(s)&&s.button==0&&e!=null){K("none");const w=getComputedStyle(e);r=s.pageX-e.offsetLeft+parseInt(w["margin-left"]),d=s.pageY-e.offsetTop+parseInt(w["margin-right"]),a=s.clientX,c=s.clientY,document.body.style.userSelect="none",document.body.style.cursor="move";const h=function(N){if(e!=null){(N.clientX-a!=0||N.clientY-c!=0)&&p&&(p=!1,i());let z=N.pageX-r,g=N.pageY-d;const v=document.documentElement.clientWidth,E=document.documentElement.clientHeight;if(!o){let x=v-e.offsetWidth,b=E-e.offsetHeight;if(e.style.position==="absolute"){const S=ht(e);S!=null&&(x=S.clientWidth-e.offsetWidth,b=S.clientHeight-e.offsetHeight)}z<0?z=0:z>x&&(z=x),g<0?g=0:g>b&&(g=b)}e.style.top=g+"px",e.style.left=z+"px",l(e.style.left,e.style.top)}return!1},k=function(){p=!0,document.body.style.userSelect="",document.body.style.cursor="",n(),K("auto"),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",h,{passive:!1}),document.addEventListener("mouseup",k)}return!1})},xt=function(e,o,l,n,i){let r=0,d=0,a=!0;e!=null&&e.addEventListener("mousedown",function(c){if((c.composedPath&&c.composedPath()||c.path)[0].className==="zan-layer-resize"&&c.button==0&&e!=null){K("none");const f=typeof i=="function"?i():i,s=e.getBoundingClientRect(),w=s.left,h=s.top;r=c.clientX,d=c.clientY,document.body.style.userSelect="none",document.body.style.cursor="se-resize";const k=function(z){var g;if(window.getSelection!=null&&((g=window.getSelection())==null||g.removeAllRanges()),e!=null){const v=z.clientX,E=z.clientY;(v-r!=0||E-d!=0)&&a&&(a=!1,n());let x=v-w,b=E-h;const S=(f==null?void 0:f.minWidth)??260,F=(f==null?void 0:f.minHeight)??115,V=f==null?void 0:f.maxWidth,H=f==null?void 0:f.maxHeight;x<S&&(x=S),b<F&&(b=F),typeof V=="number"&&Number.isFinite(V)&&x>V&&(x=V),typeof H=="number"&&Number.isFinite(H)&&b>H&&(b=H),e.style.width=x+"px",e.style.height=b+"px",o(e.style.width,e.style.height)}return!1};document.addEventListener("mousemove",k,{passive:!1});const N=function(){a=!0,document.body.style.userSelect="",document.body.style.cursor="",l(),K("auto"),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",N)};document.addEventListener("mouseup",N)}return!1})},kt=Symbol("zIndex");let bt=99999;function ke(){return++bt}const Bt=["id"],Ct={key:1,class:"slot-fragment"},zt=["innerHTML"],vt=["onClick"],wt={key:2,class:"zan-layer-resize"},J=t.defineComponent({name:"ZanLayer",__name:"ZanLayer",props:{modelValue:{type:Boolean,default:!1},type:{default:1},title:{type:[String,Object,Symbol,Function,Boolean],default:"标题"},footer:{type:[String,Object,Symbol,Function,Boolean]},titleStyle:{type:[String,Boolean,null,Object,Array],default:""},footerStyle:{type:[String,Boolean,null,Object,Array]},content:{},isHtmlFragment:{type:Boolean,default:!1},offset:{default:()=>"auto"},area:{default:()=>"auto"},width:{},height:{},minWidth:{},maxWidth:{},minHeight:{},maxHeight:{},move:{type:Boolean,default:!0},maxmin:{type:Boolean,default:!1},resize:{type:Boolean,default:!1},shade:{type:Boolean,default:!0},shadeClose:{type:Boolean,default:!0},shadeStyle:{type:[Boolean,null,String,Object,Array]},shadeOpacity:{default:"0.1"},layerClasses:{},contentClass:{default:""},zIndex:{},closeBtn:{type:[Boolean,String],default:"1"},btn:{},btnAlign:{default:"r"},anim:{default:0},isOutAnim:{type:Boolean,default:!0},icon:{},imgList:{default:()=>[]},startIndex:{default:0},animDuration:{default:"0.3s"},moveOut:{type:Boolean,default:!1},teleport:{default:"body"},teleportDisabled:{type:Boolean,default:!1},lastPosition:{type:Boolean,default:!0},time:{default:0},load:{default:0},yesText:{default:"确定"},formType:{default:"text"},value:{default:""},maxLength:{},placeholder:{default:"请输入内容"},isMessage:{type:Boolean,default:!1},id:{},isFunction:{type:Boolean,default:!1},appContext:{},success:{type:Function,default:()=>{}},end:{type:Function,default:()=>{}},yes:{},beforeClose:{type:Function,default:()=>!0},close:{type:Function,default:()=>{}},min:{type:Function,default:()=>{}},full:{type:Function,default:()=>{}},revert:{type:Function,default:()=>{}},moveStart:{type:Function,default:()=>{}},moving:{type:Function,default:()=>{}},moveEnd:{type:Function,default:()=>{}},resizeStart:{type:Function,default:()=>{}},resizing:{type:Function,default:()=>{}},resizeEnd:{type:Function,default:()=>{}},internalDestroy:{}},emits:["close","update:modelValue","opened"],setup(e,{expose:o,emit:l}){const n=e,i=l,r=t.useSlots(),d=t.ref(!1),a=t.ref(!1),c=t.ref(n.id||re()),p=t.ref(null),f=t.ref(),s=_e(n.type),w=()=>We(n.type,Te(n.area,n.width,n.height),n.offset),h=t.ref(w()),k=t.ref(ne(n.offset,h.value,s)),N=t.ref(99999),z=t.ref(!1),g=t.ref(h.value[0]),v=t.ref(h.value[1]),E=t.ref(k.value[0]),x=t.ref(k.value[1]),b=t.ref(""),S=t.ref(""),F=t.ref(""),V=t.ref(""),H=t.ref(!1),be=(u=!1)=>{const m=j(n.minWidth,"width",u?260:void 0),y=j(n.maxWidth,"width"),B=j(n.minHeight,"height",u?115:void 0),$=j(n.maxHeight,"height");return{minWidth:m,maxWidth:typeof y=="number"&&typeof m=="number"&&y<m?m:y,minHeight:B,maxHeight:typeof $=="number"&&typeof B=="number"&&$<B?B:$}},Be=(u,m,y=!1)=>{var He,Ie;const B=T(u);if(!B)return;const $=be(y),I=m==="width"?$.minWidth:$.minHeight,G=m==="width"?$.maxWidth:$.maxHeight;if(I===void 0&&G===void 0)return B;const en=m==="width"?(He=p.value)==null?void 0:He.offsetWidth:(Ie=p.value)==null?void 0:Ie.offsetHeight,Fe=j(B,m,en);if(Fe===void 0)return B;let Q=Fe;return typeof I=="number"&&(Q=Math.max(Q,I)),typeof G=="number"&&(Q=Math.min(Q,G)),`${Math.round(Q*100)/100}px`},Y=t.ref(n.value);t.watch(()=>n.value,()=>{Y.value=n.value});const Ce=()=>{N.value=n.zIndex??ke()};t.watch(()=>n.zIndex,()=>{Ce()},{immediate:!0});const ze=function(){t.nextTick(async()=>{h.value=w(),s==5&&(h.value=await pe(n.imgList[n.startIndex].src));let u=h.value;(u[0]==null||u[1]==null)&&(u=me(p.value)),s==6&&(k.value=Re(n.offset,u,c.value)),te(),Le(),Ot()})},Ht=function(){a.value&&Se(),d.value&&we(),b.value="",S.value="",F.value="",V.value=""},ve=()=>{F.value=E.value,V.value=x.value,b.value=g.value,S.value=v.value,g.value=ue().w,v.value=ue().h,E.value=de().t,x.value=de().l},we=()=>{d.value?(q(),g.value=b.value,v.value=S.value,n.revert(c.value)):(_(),ve(),n.full(c.value)),d.value=!d.value},Ee=()=>{let I=10+190*X(c.value,!0);const G=document.documentElement.clientWidth;I+180>G&&(I=10),b.value=g.value,S.value=v.value,F.value=E.value,V.value=x.value,v.value="51px",g.value="180px",E.value="calc(100% - 51px)",x.value=I+"px"},Se=async()=>{a.value?(q(),X(c.value,!1),g.value=b.value,v.value=S.value,n.revert(c.value)):(_(),Ee(),n.min(c.value)),a.value=!a.value};t.watch(()=>n.modelValue,u=>{z.value!==u&&(z.value=u)},{immediate:!0}),t.watch(()=>z.value,(u,m)=>{if(u!==m&&!(!u&&m===void 0)){if(u){H.value=!1,ze(),Ce(),q(),n.isFunction&&ze(),t.nextTick(()=>{n.success(c.value)});return}_(),Ht(),m!==void 0&&n.end(c.value)}},{immediate:!0,flush:"post"});const It=t.computed(()=>[{"zan-layer-dialog":s===0||s===7,"zan-layer-page":s===1,"zan-layer-iframe":s===2,"zan-layer-loading":s===3,"zan-layer-drawer":s===4,"zan-layer-photos":s===5,"zan-layer-notifiy":s===6,"zan-layer-msg":n.isMessage,"zan-layer-hui":n.isMessage&&!n.icon},n.layerClasses]),Ot=function(){n.move&&s!=4&&t.nextTick(()=>{p.value&&(gt(p.value,n.moveOut,(u,m)=>{x.value=u,E.value=m,H.value=!0,a.value||(V.value=u,F.value=m),n.moving(c.value,{top:m,left:u})},()=>{const u={left:x.value,top:E.value,isMin:a.value,isMax:d.value},[m,y]=n.moveEnd(c.value,u)||[];y&&m&&(x.value=m,E.value=y)},()=>{n.moveStart(c.value)}),xt(p.value,(u,m)=>{v.value=m,g.value=u,S.value=m,b.value=u,n.resizing(c.value,{width:u,height:m})},()=>{const u={width:g.value,height:v.value},[m,y]=n.resizeEnd(c.value,u)||[];(m||y)&&$e({width:m||void 0,height:y||void 0},{applyCurrent:!0,persistBase:!0})},()=>{n.resizeStart(c.value)},()=>be(!0)))})},At=t.computed(()=>({position:n.teleportDisabled||n.teleport!="body"?"absolute":"fixed",top:E.value,left:x.value,height:v.value,width:g.value,animationDuration:n.animDuration,zIndex:N.value})),Mt=t.computed(()=>[s===3?`zan-layer-loading${n.load}`:"",n.icon?"zan-layer-padding":"",n.contentClass]),ee=()=>{if(typeof n.beforeClose=="function"){const u=n.beforeClose(c.value);(u===void 0||u!=null&&u===!0)&&(n.close(c.value),i("close"),i("update:modelValue",!1),n.internalDestroy&&n.internalDestroy(),a.value&&X(c.value,!a.value))}},Tt=(...u)=>{typeof n.yes=="function"?n.yes(...u):ee()},Wt=()=>{n.shadeClose&&ee()},Ne=t.computed(()=>["zan-icon",`zan-icon-ico${n.icon}`]),Dt=t.computed(()=>s===4?fe(n.offset):s===6?Xe(n.offset):`zan-layer-anim-0${n.anim}`),Pt=t.computed(()=>s===4?fe(n.offset,!0):n.isOutAnim?"zan-layer-anim-close":""),_t=()=>{z.value=!0},Rt=()=>{z.value=!1,s===6&&je(c.value)},jt=t.computed(()=>z.value&&n.shade&&!a.value),Xt=t.computed(()=>n.resize&&!d.value&&!a.value),Yt=t.computed(()=>n.title&&s!=3&&s!=5&&s!=6),qt=function(u){t.nextTick(async()=>{h.value=await pe(n.imgList[u].src),k.value=ne(n.offset,h.value,s),g.value=h.value[0],v.value=h.value[1],E.value=k.value[0],x.value=k.value[1],b.value=h.value[0],S.value=h.value[1]})},Gt=function(){n.zIndex||(N.value=ke())},Qt=(u,m)=>((u==null?void 0:u[0])||"")===((m==null?void 0:m[0])||"")&&((u==null?void 0:u[1])||"")===((m==null?void 0:m[1])||""),Ve=()=>{if(!p.value)return;const u=ne(n.offset,me(p.value),s);if(Qt(k.value,u)||(k.value=u),H.value&&n.lastPosition)return;const m=n.lastPosition&&F.value||u[0],y=n.lastPosition&&V.value||u[1];E.value!==m&&(E.value=m),x.value!==y&&(x.value=y)},$e=(u,m={})=>{const y=u.width!==void 0?Be(u.width,"width"):void 0,B=u.height!==void 0?Be(u.height,"height"):void 0;if(!y&&!B)return;const $=m.applyCurrent??!0,I=m.persistBase??!0;$&&(y&&(g.value=y),B&&(v.value=B)),I&&(y&&(b.value=y),B&&(S.value=B)),z.value&&!d.value&&!a.value&&t.nextTick(()=>{Ve()})},Zt=()=>{s===6&&le(n.offset),i("opened")};t.onMounted(()=>{}),t.onUnmounted(()=>{_()});let A,M=0;const q=function(){t.nextTick(()=>{!z.value||!f.value||A||s==6||f.value&&!A&&s!=6&&(A=new ResizeObserver(()=>{p.value&&(M&&cancelAnimationFrame(M),M=requestAnimationFrame(()=>{M=0,p.value&&Ve()}))}),A.observe(f.value))})},_=function(){M&&(cancelAnimationFrame(M),M=0),A&&(A.disconnect(),A=void 0)},te=function(u=!1){E.value=u&&n.lastPosition&&F.value||k.value[0],x.value=u&&n.lastPosition&&V.value||k.value[1]},Le=function(){g.value=h.value[0],v.value=h.value[1],b.value=h.value[0],S.value=h.value[1]},Ut=function(){q(),X(c.value,!1),a.value=!1,d.value=!1,H.value=!1,F.value="",V.value="",te(),Le(),n.modelValue||i("update:modelValue",!0)},Kt=async function(){a.value&&(ie(),te(!0)),d.value||(await t.nextTick(),_(),ve(),d.value=!0)},Jt=async function(){d.value&&(ie(),te(!0)),a.value||(await t.nextTick(),_(),Ee(),a.value=!0)},ie=()=>{q(),X(c.value,!1),a.value=!1,d.value=!1,g.value=b.value,v.value=S.value};return o({reset:Ut,open:_t,close:Rt,full:Kt,min:Jt,revert:ie,resize:u=>{$e(u,{applyCurrent:!d.value&&!a.value,persistBase:!0})}}),(u,m)=>(t.openBlock(),t.createBlock(t.Teleport,{to:e.teleport,disabled:e.teleportDisabled},[t.createVNode(Oe,{index:N.value,"shade-style":e.shadeStyle,visible:jt.value,opacity:e.shadeOpacity,teleport:e.teleport,teleportDisabled:e.teleportDisabled,onShadeClick:Wt},null,8,["index","shade-style","visible","opacity","teleport","teleportDisabled"]),t.createVNode(t.Transition,{"enter-active-class":Dt.value,"leave-active-class":Pt.value,onAfterEnter:Zt},{default:t.withCtx(()=>[z.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"layerRef",ref:p,class:t.normalizeClass(["zan-layer zan-layer-border",[It.value,{"zan-layer-min":a.value}]]),id:c.value,style:t.normalizeStyle(At.value)},[Yt.value?(t.openBlock(),t.createBlock(Ye,{key:0,title:e.title,titleStyle:e.titleStyle,move:e.move,onMousedown:Gt},{default:t.withCtx(()=>[t.renderSlot(u.$slots,"title")]),_:3},8,["title","titleStyle","move"])):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"contentRef",ref:f,class:t.normalizeClass(["zan-layer-content",Mt.value]),style:t.normalizeStyle(a.value===!0?"display:none":"")},[t.unref(s)===0||t.unref(s)===1||t.unref(s)===4?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[e.icon?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(Ne.value)},null,2)):t.createCommentVNode("",!0),t.unref(r).default?(t.openBlock(),t.createElementBlock("div",Ct,[t.renderSlot(u.$slots,"default")])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[e.isHtmlFragment?(t.openBlock(),t.createElementBlock("div",{key:0,class:"html-fragment",innerHTML:t.unref(R)(n.content)},null,8,zt)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[n.content?(t.openBlock(),t.createBlock(Z,{key:0,render:()=>t.unref(R)(n.content)},null,8,["render"])):t.createCommentVNode("",!0)],64))],64))],64)):t.createCommentVNode("",!0),t.unref(s)===7?(t.openBlock(),t.createBlock(yt,{key:1,"prompt-value":Y.value,"onUpdate:promptValue":m[0]||(m[0]=y=>Y.value=y),formType:n.formType,maxLength:n.maxLength,placeholder:n.placeholder},null,8,["prompt-value","formType","maxLength","placeholder"])):t.createCommentVNode("",!0),t.unref(s)===2?(t.openBlock(),t.createBlock(Me,{key:2,src:n.content},null,8,["src"])):t.createCommentVNode("",!0),t.unref(s)===5?(t.openBlock(),t.createBlock(st,{key:3,imgList:n.imgList,startIndex:n.startIndex,onResetCalculationPohtosArea:qt},null,8,["imgList","startIndex"])):t.createCommentVNode("",!0),t.unref(s)===6?(t.openBlock(),t.createBlock(mt,{key:4,onClose:ee,title:n.title,content:n.content,isHtmlFragment:n.isHtmlFragment,icon:n.icon,iconClass:Ne.value,offset:n.offset},null,8,["title","content","isHtmlFragment","icon","iconClass","offset"])):t.createCommentVNode("",!0)],6),t.unref(s)!=3&&t.unref(s)!=5&&t.unref(s)!=6?(t.openBlock(),t.createBlock(Ue,{key:1,maxmin:e.maxmin,max:d.value,min:a.value,closeBtn:e.closeBtn,onOnMin:Se,onOnMax:we,onOnClose:ee},null,8,["maxmin","max","min","closeBtn"])):t.createCommentVNode("",!0),t.createElementVNode("div",{style:t.normalizeStyle(a.value===!0?"display:none":"")},[t.unref(r).footer||n.footer?(t.openBlock(),t.createBlock(qe,{key:0,footer:n.footer,footerStyle:n.footerStyle},{default:t.withCtx(()=>[t.renderSlot(u.$slots,"footer")]),_:3},8,["footer","footerStyle"])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[(e.btn&&e.btn.length>0||t.unref(s)===0||t.unref(s)===7)&&!e.isMessage?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["zan-layer-btn",[`zan-layer-btn-${e.btnAlign}`]])},[e.btn&&e.btn.length>0?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(e.btn,(y,B)=>(t.openBlock(),t.createElementBlock("a",{key:B,style:t.normalizeStyle(y.style),class:t.normalizeClass([y.class,`zan-layer-btn${B}`,{"zan-layer-btn-disabled":y.disabled}]),onClick:$=>!y.disabled&&(t.unref(s)===7?y.callback(c.value,Y.value):y.callback(c.value))},t.toDisplayString(y.text),15,vt))),128)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.unref(s)===0||t.unref(s)===7?(t.openBlock(),t.createElementBlock("a",{key:0,class:"zan-layer-btn0",onClick:m[1]||(m[1]=y=>Tt(c.value,Y.value))},t.toDisplayString(e.yesText),1)):t.createCommentVNode("",!0)],64))],2)):t.createCommentVNode("",!0)],64))],4),Xt.value?(t.openBlock(),t.createElementBlock("span",wt)):t.createCommentVNode("",!0)],14,Bt)):t.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"])],8,["to","disabled"]))}}),O=[],Et=e=>{O.push(e)},ae=e=>{O.forEach((o,l)=>{o.modalContainer.id===e&&O.splice(l,1)})},St=()=>{O.splice(0,O.length)},D=e=>{let o=!1;return O.forEach((l,n)=>{l.modalContainer.id==e&&(o=!0)}),o},P=e=>{let o=null;return O.forEach((l,n)=>{l.modalContainer.id===e&&(o=l)}),o},Nt=(e,o)=>(e&&(o=Object.assign(o,e)),o),Vt=e=>{const o=document.createElement("div");return o.id=e.id,document.body.appendChild(o),o},$t=e=>typeof e=="function"?t.isVNode(e())?{default:()=>e()}:void 0:t.isVNode(e)?{default:()=>e}:void 0,C={_context:null,open:e=>{const o={};return C.create(e,o)},drawer:e=>{const o={type:"drawer"};return C.create(e,o)},msg:(e,o={},l)=>{const n={type:0,title:!1,content:e,shadeClose:!1,closeBtn:!1,isMessage:!0,shade:!1,btn:void 0,time:2e3};return C.create(o,n,l)},load:(e=0,o={})=>{const l={type:3,load:e,anim:5,isOutAnim:!1,shadeClose:!1,shade:!0,shadeOpacity:"0.3"};return C.create(o,l)},confirm:(e,o={})=>{const l={type:0,content:e,shadeClose:!1};return C.create(o,l)},notify:(e,o)=>{e.type=6;const l={offset:"rt",time:3e3,area:"auto",shade:!1};return C.create(e,l,o)},photos:e=>{typeof e=="string"&&(e={imgList:[{src:e}]});const o={type:5,anim:2,startIndex:0,isOutAnim:!0,shadeClose:!0,shadeOpacity:"0.2"};return C.create(e,o)},prompt:e=>{e.type=7;const o={type:"prompt",shadeClose:!1,shadeOpacity:"0.2"};return C.create(e,o)},create:(e,o,l)=>{var a,c;let n;const i=Nt(e,o);i.hasOwnProperty("id")?C.close(i.id):i.id=re();const r=Vt(i),d=t.h(J,{...i,isFunction:!0,internalDestroy(){var p,f;n&&clearTimeout(n),(f=(p=d.component)==null?void 0:p.exposed)==null||f.close(),setTimeout(()=>{t.render(null,r),document.body.contains(r)&&document.body.removeChild(r)},500),ae(r.id)}},$t(i.content));return d.appContext=i.appContext||C._context,t.render(d,r),(c=(a=d.component)==null?void 0:a.exposed)==null||c.open(),o&&o.time!=null&&o.time!=0&&(n=setTimeout(()=>{var p,f;(f=(p=d.component)==null?void 0:p.exposed)==null||f.close(),l&&l(r.id),setTimeout(()=>{t.render(null,r),document.body.contains(r)&&document.body.removeChild(r)},500),ae(r.id)},o.time)),Et({modalContainer:r,modalInstance:d}),r.id},close:e=>{var o,l;if(e!=null&&D(e)){const n=P(e);(l=(o=n.modalInstance.component)==null?void 0:o.exposed)==null||l.close(),setTimeout(()=>{t.render(null,n.modalContainer),document.body.contains(n.modalContainer)&&document.body.removeChild(n.modalContainer)},500)}ae(e)},closeAll:()=>{O.forEach(e=>{var o,l;(l=(o=e.modalInstance.component)==null?void 0:o.exposed)==null||l.close(),setTimeout(()=>{t.render(null,e.modalContainer),document.body.contains(e.modalContainer)&&document.body.removeChild(e.modalContainer)},500)}),St()},reset:e=>{var o,l;e!=null&&D(e)&&((l=(o=P(e).modalInstance.component)==null?void 0:o.exposed)==null||l.reset())},min:e=>{var o,l;e!=null&&D(e)&&((l=(o=P(e).modalInstance.component)==null?void 0:o.exposed)==null||l.min())},full:e=>{var o,l;e!=null&&D(e)&&((l=(o=P(e).modalInstance.component)==null?void 0:o.exposed)==null||l.full())},revert:e=>{var o,l;e!=null&&D(e)&&((l=(o=P(e).modalInstance.component)==null?void 0:o.exposed)==null||l.revert())},resize:(e,o)=>{var l,n,i;e!=null&&D(e)&&o&&((i=(n=(l=P(e).modalInstance.component)==null?void 0:l.exposed)==null?void 0:n.resize)==null||i.call(n,o))}},Lt=(e,o)=>{C._context=e._context,e.component(J.name,J),e.config.globalProperties.$layer=C,o&&typeof o.zIndex=="number"&&e.provide(kt,t.ref(o.zIndex))},Ft={install(e,o){Lt(e,o)}};L.ZanLayer=J,L.default=Ft,L.layer=C,L.zanLayer=C,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "zan-layer",
3
- "version": "1.0.7",
2
+ "name": "zan-layer",
3
+ "version": "1.0.8",
4
4
  "description": "A powerful layer component for Vue 3",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,12 +21,12 @@
21
21
  },
22
22
  "types": "types/index.d.ts",
23
23
  "style": "lib/index.css",
24
- "scripts": {
25
- "dev": "vite",
26
- "build": "vite build --emptyOutDir && npm run build:types",
27
- "build:types": "vue-tsc --declaration --emitDeclarationOnly --outDir types",
28
- "acceptance:smoke": "node ./scripts/acceptance-smoke.mjs"
29
- },
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "vite build --emptyOutDir && npm run build:types",
27
+ "build:types": "vue-tsc --declaration --emitDeclarationOnly --outDir types",
28
+ "acceptance:smoke": "node ./scripts/acceptance-smoke.mjs"
29
+ },
30
30
  "keywords": [
31
31
  "vue",
32
32
  "vue3",
@@ -1,4 +1,4 @@
1
- import type { ImgListType, PropsContentType, MoveEndFn, ResizeEndFn, LayerProps } from '../types';
1
+ import type { ImgListType, PropsContentType, MoveEndFn, ResizeEndFn, LayerResizeOptions, LayerProps } from '../types';
2
2
  import { StyleValue } from 'vue';
3
3
  import '../styles/index.css';
4
4
  declare var __VLS_30: {}, __VLS_32: {}, __VLS_78: {};
@@ -16,6 +16,7 @@ declare const __VLS_base: import("vue").DefineComponent<LayerProps, {
16
16
  full: () => Promise<void>;
17
17
  min: () => Promise<void>;
18
18
  revert: () => void;
19
+ resize: (size: LayerResizeOptions) => void;
19
20
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
21
  close: (...args: any[]) => void;
21
22
  "update:modelValue": (...args: any[]) => void;
@@ -30,7 +31,7 @@ declare const __VLS_base: import("vue").DefineComponent<LayerProps, {
30
31
  revert: Function;
31
32
  end: Function;
32
33
  move: boolean;
33
- area: string | string[];
34
+ area: import("../types").LayerAreaValue;
34
35
  time: number;
35
36
  title: PropsContentType | boolean;
36
37
  close: Function;
@@ -1,2 +1,12 @@
1
1
  export declare const useMove: (el: HTMLElement, moveOut: boolean, callback: Function, endCallback: Function, startCallback: Function) => void;
2
- export declare const useResize: (el: HTMLElement, callback: Function, endCallback: Function, startCallback: Function) => void;
2
+ export declare const useResize: (el: HTMLElement, callback: Function, endCallback: Function, startCallback: Function, constraints?: {
3
+ minWidth?: number;
4
+ maxWidth?: number;
5
+ minHeight?: number;
6
+ maxHeight?: number;
7
+ } | (() => {
8
+ minWidth?: number;
9
+ maxWidth?: number;
10
+ minHeight?: number;
11
+ maxHeight?: number;
12
+ })) => void;
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { AppContext } from 'vue';
2
2
  import ZanLayer from './component/ZanLayer.vue';
3
- import { LayerProps, InstallOptions } from './types';
3
+ import type { LayerProps, InstallOptions, LayerResizeOptions } from './types';
4
4
  export declare const layer: {
5
5
  _context: AppContext | null;
6
6
  open: (option: LayerProps) => string;
@@ -18,6 +18,7 @@ export declare const layer: {
18
18
  min: (id: any) => void;
19
19
  full: (id: any) => void;
20
20
  revert: (id: any) => void;
21
+ resize: (id: any, options: LayerResizeOptions) => void;
21
22
  };
22
23
  declare const ZanLayerPlugin: {
23
24
  install(app: unknown, options?: InstallOptions): void;
@@ -15,6 +15,8 @@ export type ImgListType = {
15
15
  thumb?: string;
16
16
  };
17
17
  export type PropsContentType = VNodeTypes | (() => VNodeTypes);
18
+ export type LayerSizeValue = number | string;
19
+ export type LayerAreaValue = LayerSizeValue | [LayerSizeValue?, LayerSizeValue?];
18
20
  type OperateEndReturn = void | [string, string] | undefined;
19
21
  interface MoveEndFnOptions {
20
22
  left: string;
@@ -27,6 +29,10 @@ interface ResizeEndFnOptions {
27
29
  width: string;
28
30
  height: string;
29
31
  }
32
+ export interface LayerResizeOptions {
33
+ width?: LayerSizeValue;
34
+ height?: LayerSizeValue;
35
+ }
30
36
  export type ResizeEndFn = (id: string, options: ResizeEndFnOptions) => OperateEndReturn;
31
37
  export interface LayerProps {
32
38
  modelValue?: boolean;
@@ -38,7 +44,13 @@ export interface LayerProps {
38
44
  content?: PropsContentType;
39
45
  isHtmlFragment?: boolean;
40
46
  offset?: string | string[];
41
- area?: string | string[];
47
+ area?: LayerAreaValue;
48
+ width?: LayerSizeValue;
49
+ height?: LayerSizeValue;
50
+ minWidth?: LayerSizeValue;
51
+ maxWidth?: LayerSizeValue;
52
+ minHeight?: LayerSizeValue;
53
+ maxHeight?: LayerSizeValue;
42
54
  move?: boolean;
43
55
  maxmin?: boolean;
44
56
  resize?: boolean;
@@ -1,8 +1,11 @@
1
1
  export declare function nextId(): any;
2
2
  export declare function calculateMinArea(minArea: any): any[];
3
+ export declare function normalizeLayerSizeValue(value: any): string | undefined;
4
+ export declare function resolveLayerAreaInput(area: any, width?: any, height?: any): string | (string | undefined)[];
3
5
  export declare function calculateArea(type: any, area: any, offset: any): any[];
4
6
  export declare function calculateBaseArea(area: any): any[];
5
7
  export declare function calculateDrawerArea(offset: any, drawerArea?: string[] | string): string[];
8
+ export declare function calculateSizeConstraint(value: any, axis: 'width' | 'height', fallback?: number): number | undefined;
6
9
  /**
7
10
  * 计算 offset 属性
8
11
  */