zan-layer 1.0.0
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.
- package/README.md +197 -0
- package/lib/index.css +1 -0
- package/lib/zan-layer.js +1150 -0
- package/lib/zan-layer.umd.js +1 -0
- package/package.json +52 -0
- package/types/component/Footer.vue.d.ts +19 -0
- package/types/component/Header.vue.d.ts +20 -0
- package/types/component/HeaderBtn.vue.d.ts +19 -0
- package/types/component/Iframe.vue.d.ts +6 -0
- package/types/component/Notifiy.vue.d.ts +17 -0
- package/types/component/Photos.vue.d.ts +14 -0
- package/types/component/Prompt.vue.d.ts +16 -0
- package/types/component/Render.vue.d.ts +6 -0
- package/types/component/Shade.vue.d.ts +16 -0
- package/types/component/Tips.vue.d.ts +7 -0
- package/types/component/ZanLayer.vue.d.ts +79 -0
- package/types/composable/useDragable.d.ts +2 -0
- package/types/index.d.ts +28 -0
- package/types/tokens/index.d.ts +3 -0
- package/types/types/index.d.ts +99 -0
- package/types/utils/index.d.ts +43 -0
- package/types/utils/render.d.ts +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(w,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(w=typeof globalThis<"u"?globalThis:w||self,t(w.ZanLayer={},w.Vue))})(this,function(w,t){"use strict";const fe=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,a=t.computed(()=>[{opacity:o.opacity,position:o.teleportDisabled||o.teleport!="body"?"absolute":"fixed",zIndex:o.index},o.shadeStyle]),r=()=>{n("shadeClick")};return(m,i)=>e.visible?(t.openBlock(),t.createElementBlock("div",{key:0,class:"zan-layer-shade",style:t.normalizeStyle(a.value),onClick:r},null,4)):t.createCommentVNode("",!0)}}),pe=["src"],ye=t.defineComponent({name:"Iframe",__name:"Iframe",props:{src:{}},setup(e){const l=e,o=t.computed(()=>l.src);return(n,a)=>(t.openBlock(),t.createElementBlock("iframe",{scrolling:"auto",class:"zan-layer-iframe",allowtransparency:"true",frameborder:"0",src:o.value},null,8,pe))}}),_=t.defineComponent({name:"ZanRender",__name:"Render",props:{render:{type:Function}},setup(e){const l=e;return(o,n)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(l.render())))}}),M=function(e){return typeof e=="function"?e():typeof e=="string"?t.h("span",e):e};function q(){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 he(e,l,o){return e!="drawer"||e!=4?ge(l):K(o,l)}function ge(e){return e===void 0||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 K(e,l="30%"){return 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 X(e,l,o){const n=["t","r","b","l","lt","tl","lb","bl","rt","tr","rb","br"],a=[];return e==="auto"&&o==4&&(e="r"),typeof e=="string"?n.indexOf(e)>-1?(e==="t"&&(a[0]="0px",a[1]="calc(50% - "+l[0]+"/2)"),e==="l"&&(a[0]="calc(50% - "+l[1]+"/2)",a[1]="0px"),e==="b"&&(a[0]="calc(100% - "+l[1]+")",a[1]="calc(50% - "+l[0]+"/2)"),e==="r"&&(a[0]="calc(50% - "+l[1]+"/2)",a[1]="calc(100% - "+l[0]+")"),(e==="lt"||e==="tl")&&(a[0]="0px",a[1]="0px"),(e==="lb"||e==="bl")&&(a[0]="calc(100% - "+l[1]+")",a[1]="0px"),(e==="rt"||e==="tr")&&(a[0]="0px",a[1]="calc(100% - "+l[0]+")"),(e==="rb"||e==="br")&&(a[0]="calc(100% - "+l[1]+")",a[1]="calc(100% - "+l[0]+")")):e=="auto"?(a[0]="calc(50% - "+l[1]+"/2)",a[1]="calc(50% - "+l[0]+"/2)"):(a[0]=e,a[1]="calc(50% - "+l[0]+"/2)"):(a[0]=e[0],a[1]=e[1]),a}function xe(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 J(){return{w:"100%",h:"100%"}}function ee(){return{t:"0px",l:"0px"}}function te(e){var n,a;const l=(n=getComputedStyle(e,null))==null?void 0:n.width,o=(a=getComputedStyle(e,null))==null?void 0:a.height;return[l,o]}const $=[];function H(e,l){let o=0;if(l){const n=$.findIndex(a=>a===void 0);n===-1?($.push(e),o=$.length-1):($[n]=e,o=n)}else delete $[$.findIndex(n=>n==e)],o=-1;return o}function ne(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 le(e,l){const o=new Image;return o.src=e,new Promise((a,r)=>{if(o.complete){a(n(o));return}const m=x.load(2,{shadeOpacity:"0"});o.onload=()=>{x.close(m),a(n(o))},o.onerror=()=>{x.close(m),x.msg("图片加载失败"),r(!1)}});function n(a){const r=[a.width,a.height],m=[window.innerWidth-250,window.innerHeight-250];if(r[0]>m[0]||r[1]>m[1]){const i=[r[0]/m[0],r[1]/m[1]];i[0]>i[1]?(r[0]=r[0]/i[0],r[1]=r[1]/i[0]):i[0]<i[1]&&(r[0]=r[0]/i[1],r[1]=r[1]/i[1])}return[r[0]+"px",r[1]+"px"]}}function Y(e,l){const o=document.getElementsByClassName(e);for(let n=0;n<o.length;n++){const a=o[n];if(a.id===l)return a}}function ke(e,l,o){const n=["lt","lb","rt","rb"];let a="0",r="0",i=15;window.NotifiyQueen=window.NotifiyQueen||[];const s=window.NotifiyQueen;(typeof e!="string"||n.indexOf(e)===-1)&&(e="rt");const u=s.filter(c=>{if(c.offset===e)return c});let d=u.length>0?u[u.length-1]:null;if(d)if(d=Y("zan-layer",d.id),e==="rt"||e==="lt")i+=d.offsetHeight+parseFloat(d.style.top);else{const c=parseFloat(d.style.top.split(" - ")[1]);i+=d.offsetHeight+c}else(e==="rb"||e==="lb")&&(i+=parseFloat(l[1]));return e==="rt"?(a=i+"px",r="calc(100% - "+(parseFloat(l[0])+15)+"px)"):e==="rb"?(a="calc(100% - "+i+"px)",r="calc(100% - "+(parseFloat(l[0])+15)+"px)"):e==="lt"?(a=i+"px",r="15px"):e==="lb"&&(a="calc(100% - "+i+"px)",r="15px"),s.push({id:o,offset:e}),[a,r]}function Be(e){const l=Y("zan-layer",e);if(!l)return;const o=15,n=l.offsetHeight;window.NotifiyQueen=window.NotifiyQueen||[];const a=window.NotifiyQueen,r=a.findIndex(d=>d.id===e),m=a[r].offset,i=a.filter(d=>{if(d.offset===m)return d}),s=i.findIndex(d=>d.id===e);i.slice(s+1).forEach(d=>{const c=Y("zan-layer",d.id);if(m==="rt"||m==="lt")c.style.top=parseFloat(c.style.top)-o-n+"px";else{const p=parseFloat(c.style.top.split(" - ")[1])-o-n;c.style.top="calc(100% - "+p+"px)"}}),a.splice(r,1)}function be(e){const l="zan-layer-drawer-anim zan-layer-anim";let o="";return e==="lt"||e==="lb"?o="lr":o="rl",`${l}-${o}`}const Ce=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,a)=>(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))}}),ze=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))}}),Ee={class:"zan-layer-setwin"},Se={class:"zan-tooltip"},we={class:"zan-tooltip"},Ne=((e,l)=>{const o=e.__vccOpts||e;for(const[n,a]of l)o[n]=a;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,a=()=>{n("onMin")},r=()=>{n("onMax")},m=()=>{n("onClose")};return(i,s)=>(t.openBlock(),t.createElementBlock("span",Ee,[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(a,["stop"])},[t.createElementVNode("span",Se,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(r,["stop"])},[t.createElementVNode("span",we,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(m,["stop"])},[...s[0]||(s[0]=[t.createElementVNode("span",{class:"zan-tooltip"},"关闭",-1)])],2)):t.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-8d683fcb"]]),Ve={class:"zan-layer-phimg"},Le=["src"],$e={key:0,class:"zan-layer-imgsee"},ve={key:0,class:"zan-layer-imguide"},Ie={key:0,class:"thumb-row"},Fe=["onClick"],Oe=["src"],Me={key:1,class:"zan-layer-imgtit"},He={key:0},De={key:1},Te=t.defineComponent({name:"Photos",__name:"Photos",props:{imgList:{},startIndex:{default:0}},emits:["resetCalculationPohtosArea"],setup(e,{emit:l}){const o=l,n=e,a=t.ref(n.startIndex);t.watch(a,()=>{o("resetCalculationPohtosArea",a.value)});const r=s=>{let d=a.value+s;d<0&&(d=n.imgList.length-1),d>=n.imgList.length&&(d=0),a.value=d},m=t.ref(!1);t.onMounted(()=>{t.nextTick(()=>{setTimeout(()=>{m.value=!0},400)})});const i=t.computed(()=>{let s=!1;return n.imgList.forEach(u=>{u.thumb&&(s=!0)}),s});return(s,u)=>(t.openBlock(),t.createElementBlock("div",Ve,[t.createElementVNode("img",{src:e.imgList[a.value].src},null,8,Le),e.imgList.length>0?(t.openBlock(),t.createElementBlock("div",$e,[e.imgList.length>1?(t.openBlock(),t.createElementBlock("span",ve,[t.createElementVNode("a",{href:"javascript:;",class:"zan-layer-iconext zan-layer-imgprev",onClick:u[0]||(u[0]=d=>r(-1))},"‹"),t.createElementVNode("a",{href:"javascript:;",class:"zan-layer-iconext zan-layer-imgnext",onClick:u[1]||(u[1]=d=>r(1))},"›")])):t.createCommentVNode("",!0),e.imgList.length>1||e.imgList[a.value].alt?(t.openBlock(),t.createElementBlock("div",{key:1,class:"zan-layer-imgbar",style:t.normalizeStyle({opacity:m.value?1:0})},[i.value?(t.openBlock(),t.createElementBlock("div",Ie,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.imgList,(d,c)=>(t.openBlock(),t.createElementBlock("div",{class:"thumb-box",key:"thumb-box"+c,onClick:p=>a.value=c},[t.createElementVNode("img",{src:d.thumb},null,8,Oe)],8,Fe))),128)),t.createElementVNode("div",{class:"thumb-box-border",style:t.normalizeStyle({left:`calc(calc( calc(100% - ${100*e.imgList.length}px) / 2) + ${a.value*100}px)`})},null,4)])):(t.openBlock(),t.createElementBlock("span",Me,[e.imgList[a.value].alt?(t.openBlock(),t.createElementBlock("span",He,t.toDisplayString(e.imgList[a.value].alt),1)):t.createCommentVNode("",!0),e.imgList.length>1?(t.openBlock(),t.createElementBlock("em",De,t.toDisplayString(a.value+1)+" / "+t.toDisplayString(e.imgList.length),1)):t.createCommentVNode("",!0)]))],4)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0)]))}}),Ae={class:"title"},Pe={key:0,class:"content"},_e=["innerHTML"],je=t.defineComponent({name:"Notifiy",__name:"Notifiy",props:{title:{},content:{},isHtmlFragment:{type:Boolean,default:!1},icon:{},iconClass:{}},emits:["close"],setup(e,{emit:l}){const o=e,n=l,a=t.shallowRef(null),r=()=>{n("close")};function m(i,s){let u=i.className,d=u!=""?" ":"",c=u+d+s;i.className=c}return t.onMounted(()=>{t.nextTick(()=>{setTimeout(()=>{var i,s,u,d;(s=(i=a.value)==null?void 0:i.parentElement)!=null&&s.parentElement&&m((d=(u=a.value)==null?void 0:u.parentElement)==null?void 0:d.parentElement,"zan-layer-notifiy-transition")},300)})}),(i,s)=>(t.openBlock(),t.createElementBlock("div",{class:"zan-layer-notifiy-wrapper",ref_key:"notifyRef",ref:a},[t.createElementVNode("h2",Ae,[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",Pe,[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,_e)):t.createCommentVNode("",!0),t.createElementVNode("i",{class:"zan-icon-close",onClick:r},[...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))}}),Re=["maxlength","placeholder"],We=["type","placeholder"],Xe=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),a=t.computed(()=>{switch(typeof o.formType){case"string":return o.formType==="textarea";case"number":return o.formType===2;default:return!1}}),r=t.computed(()=>o.formType==1||o.formType=="password");return(m,i)=>a.value?t.withDirectives((t.openBlock(),t.createElementBlock("textarea",{key:0,onInput:i[0]||(i[0]=s=>m.$emit("update:promptValue",n.value)),"onUpdate:modelValue":i[1]||(i[1]=s=>n.value=s),maxlength:o.maxLength,placeholder:o.placeholder,class:"zan-textarea"},null,40,Re)),[[t.vModelText,n.value]]):t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:1,onInput:i[2]||(i[2]=s=>m.$emit("update:promptValue",n.value)),"onUpdate:modelValue":i[3]||(i[3]=s=>n.value=s),type:r.value?"password":"text",placeholder:o.placeholder,class:"zan-input"},null,40,We)),[[t.vModelDynamic,n.value]])}});function Ye(e){for(;e&&e.parentNode;)if(e=e.parentNode,e&&getComputedStyle(e).position==="relative")return e;return null}const j=e=>{document.querySelectorAll(".zan-layer iframe").forEach(o=>{o.style.pointerEvents=e})},Qe=function(e,l,o,n,a){let r,m,i=0,s=0,u=!0;e!=null&&e.addEventListener("mousedown",function(d){if((d.composedPath&&d.composedPath()||d.path)[0].className==="zan-layer-title"&&d.button==0&&e!=null){j("none");const p=getComputedStyle(e);r=d.pageX-e.offsetLeft+parseInt(p["margin-left"]),m=d.pageY-e.offsetTop+parseInt(p["margin-right"]),i=d.clientX,s=d.clientY,document.body.style.userSelect="none",document.body.style.cursor="move";const z=function(k){if(e!=null){(k.clientX-i!=0||k.clientY-s!=0)&&u&&(u=!1,a());let y=k.pageX-r,h=k.pageY-m;const b=document.documentElement.clientWidth,C=document.documentElement.clientHeight;if(!l){let E=b-e.offsetWidth,S=C-e.offsetHeight;if(e.style.position==="absolute"){const V=Ye(e);V!=null&&(E=V.clientWidth-e.offsetWidth,S=V.clientHeight-e.offsetHeight)}y<0?y=0:y>E&&(y=E),h<0?h=0:h>S&&(h=S)}e.style.top=h+"px",e.style.left=y+"px",o(e.style.left,e.style.top)}return!1},N=function(){u=!0,document.body.style.userSelect="",document.body.style.cursor="",n(),j("auto"),document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",N)};document.addEventListener("mousemove",z,{passive:!1}),document.addEventListener("mouseup",N)}return!1})},Ge=function(e,l,o,n){let a=0,r=0,m=!0;e!=null&&e.addEventListener("mousedown",function(i){if((i.composedPath&&i.composedPath()||i.path)[0].className==="zan-layer-resize"&&i.button==0&&e!=null){j("none");const u=e.getBoundingClientRect(),d=u.left,c=u.top;a=i.clientX,r=i.clientY,document.body.style.userSelect="none",document.body.style.cursor="se-resize";const p=function(N){var k;if(window.getSelection!=null&&((k=window.getSelection())==null||k.removeAllRanges()),e!=null){const y=N.clientX,h=N.clientY;(y-a!=0||h-r!=0)&&m&&(m=!1,n());let b=y-d,C=h-c;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 z=function(){m=!0,document.body.style.userSelect="",document.body.style.cursor="",o(),j("auto"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",z)};document.addEventListener("mouseup",z)}return!1})},Ze=Symbol("zIndex");let Ue=99999;function oe(){return++Ue}const qe=["id"],Ke={key:1,class:"slot-fragment"},Je=["innerHTML"],et=["onClick"],tt={key:2,class:"zan-layer-resize"},R=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:{},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"],setup(e,{expose:l,emit:o}){const n=e,a=o,r=t.useSlots(),m=t.ref(!1),i=t.ref(!1),s=t.ref(n.id||q()),u=t.ref(null),d=t.ref(),c=xe(n.type),p=t.ref(he(n.type,n.area,n.offset)),z=t.ref(X(n.offset,p.value,c)),N=t.ref(99999),k=t.ref(!1),y=t.ref(p.value[0]),h=t.ref(p.value[1]),b=t.ref(z.value[0]),C=t.ref(z.value[1]),E=t.ref(""),S=t.ref(""),V=t.ref(""),v=t.ref(""),A=t.ref(n.value);t.watch(()=>n.value,()=>{A.value=n.value});const ae=()=>{N.value=n.zIndex??oe()};t.watch(()=>n.zIndex,()=>{ae()},{immediate:!0});const ie=function(){t.nextTick(async()=>{c==4&&(p.value=K(n.offset,n.area)),c==5&&(p.value=await le(n.imgList[n.startIndex].src));let f=p.value;(f[0]==null||f[1]==null)&&(f=te(u.value)),c==6&&(z.value=ke(n.offset,f,s.value)),P(),ue(),dt()})},rt=function(){i.value&&de(),m.value&&re(),E.value="",S.value="",V.value="",v.value=""},se=()=>{V.value=b.value,v.value=C.value,E.value=y.value,S.value=h.value,y.value=J().w,h.value=J().h,b.value=ee().t,C.value=ee().l},re=()=>{m.value?(F(),y.value=E.value,h.value=S.value,n.revert(s.value)):(O(),se(),n.full(s.value)),m.value=!m.value},ce=()=>{let U=10+190*H(s.value,!0);const Vt=document.documentElement.clientWidth;U+180>Vt&&(U=10),E.value=y.value,S.value=h.value,V.value=b.value,v.value=C.value,h.value="51px",y.value="180px",b.value="calc(100% - 51px)",C.value=U+"px"},de=async()=>{i.value?(F(),H(s.value,!1),y.value=E.value,h.value=S.value,n.revert(s.value)):(O(),ce(),n.min(s.value)),i.value=!i.value};t.watch(()=>n.modelValue,()=>{k.value=n.modelValue,k.value?(ie(),ae()):rt()},{deep:!0,immediate:!0}),t.watch(()=>k.value,()=>{k.value&&(n.isFunction&&ie(),t.nextTick(()=>{n.success(s.value)}))},{immediate:!0,flush:"post"}),t.watch(()=>k.value,()=>{k.value||n.end(s.value)});const ct=t.computed(()=>[{"zan-layer-dialog":c===0||c===7,"zan-layer-page":c===1,"zan-layer-iframe":c===2,"zan-layer-loading":c===3,"zan-layer-drawer":c===4,"zan-layer-photos":c===5,"zan-layer-notifiy":c===6,"zan-layer-msg":n.isMessage,"zan-layer-hui":n.isMessage&&!n.icon},n.layerClasses]),dt=function(){n.move&&c!=4&&t.nextTick(()=>{u.value&&(Qe(u.value,n.moveOut,(f,g)=>{C.value=f,b.value=g,i.value||(v.value=f,V.value=g),n.moving(s.value,{top:g,left:f})},()=>{const f={left:C.value,top:b.value,isMin:i.value,isMax:m.value},[g,B]=n.moveEnd(s.value,f)||[];B&&g&&(C.value=g,b.value=B)},()=>{n.moveStart(s.value)}),Ge(u.value,(f,g)=>{h.value=g,y.value=f,S.value=g,E.value=f,n.resizing(s.value,{width:f,height:g})},()=>{const f={width:y.value,height:h.value},[g,B]=n.resizeEnd(s.value,f)||[];g&&B&&(y.value=g,h.value=B)},()=>{n.resizeStart(s.value)}))})},mt=t.computed(()=>({position:n.teleportDisabled||n.teleport!="body"?"absolute":"fixed",top:b.value,left:C.value,height:h.value,width:y.value,animationDuration:n.animDuration,zIndex:N.value})),ut=t.computed(()=>[c===3?`zan-layer-loading${n.load}`:"",n.icon?"zan-layer-padding":""]),W=()=>{if(typeof n.beforeClose=="function"){const f=n.beforeClose(s.value);(f===void 0||f!=null&&f===!0)&&(n.close(s.value),a("close"),a("update:modelValue",!1),n.internalDestroy&&n.internalDestroy(),i.value&&H(s.value,!i.value))}},ft=(...f)=>{typeof n.yes=="function"?n.yes(...f):W()},pt=()=>{n.shadeClose&&W()},me=t.computed(()=>["zan-icon",`zan-icon-ico${n.icon}`]),yt=t.computed(()=>c===4?ne(n.offset):c===6?be(n.offset):`zan-layer-anim-0${n.anim}`),ht=t.computed(()=>c===4?ne(n.offset,!0):n.isOutAnim?"zan-layer-anim-close":""),gt=()=>{k.value=!0},xt=()=>{k.value=!1,c===6&&Be(s.value)},kt=t.computed(()=>k.value&&n.shade&&!i.value),Bt=t.computed(()=>n.resize&&!m.value&&!i.value),bt=t.computed(()=>n.title&&c!=3&&c!=5&&c!=6),Ct=function(f){t.nextTick(async()=>{p.value=await le(n.imgList[f].src),z.value=X(n.offset,p.value,c),y.value=p.value[0],h.value=p.value[1],b.value=z.value[0],C.value=z.value[1],E.value=p.value[0],S.value=p.value[1]})},zt=function(){n.zIndex||(N.value=oe())};t.onMounted(()=>{F()}),t.onUnmounted(()=>{O()}),t.watch(()=>n.modelValue,()=>{n.modelValue?F():O()});let I;const F=function(){t.nextTick(()=>{d.value&&!I&&c!=6&&(I=new ResizeObserver(f=>{u.value&&(z.value=X(n.offset,te(u.value),c),P(!0))}),I.observe(d.value))})},O=function(){I&&d.value&&(I.unobserve(d.value),I=void 0)},P=function(f=!1){b.value=f&&n.lastPosition&&V.value||z.value[0],C.value=f&&n.lastPosition&&v.value||z.value[1]},ue=function(){y.value=p.value[0],h.value=p.value[1],E.value=p.value[0],S.value=p.value[1]},Et=function(){F(),H(s.value,!1),i.value=!1,m.value=!1,V.value="",v.value="",P(),ue(),n.modelValue||a("update:modelValue",!0)},St=async function(){i.value&&(G(),P(!0)),m.value||(await t.nextTick(),O(),se(),m.value=!0)},wt=async function(){m.value&&(G(),P(!0)),i.value||(await t.nextTick(),O(),ce(),i.value=!0)},G=()=>{F(),H(s.value,!1),i.value=!1,m.value=!1,y.value=E.value,h.value=S.value};return l({reset:Et,open:gt,close:xt,full:St,min:wt,revert:G}),(f,g)=>(t.openBlock(),t.createBlock(t.Teleport,{to:e.teleport,disabled:e.teleportDisabled},[t.createVNode(fe,{index:N.value,"shade-style":e.shadeStyle,visible:kt.value,opacity:e.shadeOpacity,teleport:e.teleport,teleportDisabled:e.teleportDisabled,onShadeClick:pt},null,8,["index","shade-style","visible","opacity","teleport","teleportDisabled"]),t.createVNode(t.Transition,{"enter-active-class":yt.value,"leave-active-class":ht.value},{default:t.withCtx(()=>[k.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"layerRef",ref:u,class:t.normalizeClass(["zan-layer zan-layer-border",[ct.value,{"zan-layer-min":i.value}]]),id:s.value,style:t.normalizeStyle(mt.value)},[bt.value?(t.openBlock(),t.createBlock(Ce,{key:0,title:e.title,titleStyle:e.titleStyle,move:e.move,onMousedown:zt},{default:t.withCtx(()=>[t.renderSlot(f.$slots,"title")]),_:3},8,["title","titleStyle","move"])):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"contentRef",ref:d,class:t.normalizeClass(["zan-layer-content",ut.value]),style:t.normalizeStyle(i.value===!0?"display:none":"")},[t.unref(c)===0||t.unref(c)===1||t.unref(c)===4?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[e.icon?(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass(me.value)},null,2)):t.createCommentVNode("",!0),t.unref(r).default?(t.openBlock(),t.createElementBlock("div",Ke,[t.renderSlot(f.$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,Je)):(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(c)===7?(t.openBlock(),t.createBlock(Xe,{key:1,"prompt-value":A.value,"onUpdate:promptValue":g[0]||(g[0]=B=>A.value=B),formType:n.formType,maxLength:n.maxLength,placeholder:n.placeholder},null,8,["prompt-value","formType","maxLength","placeholder"])):t.createCommentVNode("",!0),t.unref(c)===2?(t.openBlock(),t.createBlock(ye,{key:2,src:n.content},null,8,["src"])):t.createCommentVNode("",!0),t.unref(c)===5?(t.openBlock(),t.createBlock(Te,{key:3,imgList:n.imgList,startIndex:n.startIndex,onResetCalculationPohtosArea:Ct},null,8,["imgList","startIndex"])):t.createCommentVNode("",!0),t.unref(c)===6?(t.openBlock(),t.createBlock(je,{key:4,onClose:W,title:n.title,content:n.content,isHtmlFragment:n.isHtmlFragment,icon:n.icon,iconClass:me.value},null,8,["title","content","isHtmlFragment","icon","iconClass"])):t.createCommentVNode("",!0)],6),t.unref(c)!=3&&t.unref(c)!=5&&t.unref(c)!=6?(t.openBlock(),t.createBlock(Ne,{key:1,maxmin:e.maxmin,max:m.value,min:i.value,closeBtn:e.closeBtn,onOnMin:de,onOnMax:re,onOnClose:W},null,8,["maxmin","max","min","closeBtn"])):t.createCommentVNode("",!0),t.createElementVNode("div",{style:t.normalizeStyle(i.value===!0?"display:none":"")},[t.unref(r).footer||n.footer?(t.openBlock(),t.createBlock(ze,{key:0,footer:n.footer,footerStyle:n.footerStyle},{default:t.withCtx(()=>[t.renderSlot(f.$slots,"footer")]),_:3},8,["footer","footerStyle"])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[(e.btn&&e.btn.length>0||t.unref(c)===0||t.unref(c)===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,(B,Z)=>(t.openBlock(),t.createElementBlock("a",{key:Z,style:t.normalizeStyle(B.style),class:t.normalizeClass([B.class,`zan-layer-btn${Z}`,{"zan-layer-btn-disabled":B.disabled}]),onClick:Nt=>!B.disabled&&(t.unref(c)===7?B.callback(s.value,A.value):B.callback(s.value))},t.toDisplayString(B.text),15,et))),128)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.unref(c)===0||t.unref(c)===7?(t.openBlock(),t.createElementBlock("a",{key:0,class:"zan-layer-btn0",onClick:g[1]||(g[1]=B=>ft(s.value,A.value))},t.toDisplayString(e.yesText),1)):t.createCommentVNode("",!0)],64))],2)):t.createCommentVNode("",!0)],64))],4),Bt.value?(t.openBlock(),t.createElementBlock("span",tt)):t.createCommentVNode("",!0)],14,qe)):t.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"])],8,["to","disabled"]))}}),L=[],nt=e=>{L.push(e)},Q=e=>{L.forEach((l,o)=>{l.modalContainer.id===e&&L.splice(o,1)})},lt=()=>{L.splice(0,L.length)},D=e=>{let l=!1;return L.forEach((o,n)=>{o.modalContainer.id==e&&(l=!0)}),l},T=e=>{let l=null;return L.forEach((o,n)=>{o.modalContainer.id===e&&(l=o)}),l},ot=(e,l)=>(e&&(l=Object.assign(l,e)),l),at=e=>{const l=document.createElement("div");return l.id=e.id,document.body.appendChild(l),l},it=e=>typeof e=="function"?t.isVNode(e())?{default:()=>e()}:void 0:t.isVNode(e)?{default:()=>e}:void 0,x={_context:null,open:e=>{const l={};return x.create(e,l)},drawer:e=>{const l={type:"drawer"};return x.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 x.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 x.create(l,o)},confirm:(e,l={})=>{const o={type:0,content:e,shadeClose:!1};return x.create(l,o)},notify:(e,l)=>{e.type=6;const o={offset:"rt",time:3e3,area:"auto",shade:!1};return x.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 x.create(e,l)},prompt:e=>{e.type=7;const l={type:"prompt",shadeClose:!1,shadeOpacity:"0.2"};return x.create(e,l)},create:(e,l,o)=>{var i,s;let n;const a=ot(e,l);a.hasOwnProperty("id")?x.close(a.id):a.id=q();const r=at(a),m=t.h(R,{...a,isFunction:!0,internalDestroy(){var u,d;n&&clearTimeout(n),(d=(u=m.component)==null?void 0:u.exposed)==null||d.close(),setTimeout(()=>{t.render(null,r),document.body.contains(r)&&document.body.removeChild(r)},500),Q(r.id)}},it(a.content));return m.appContext=a.appContext||x._context,t.render(m,r),(s=(i=m.component)==null?void 0:i.exposed)==null||s.open(),l&&l.time!=null&&l.time!=0&&(n=setTimeout(()=>{var u,d;(d=(u=m.component)==null?void 0:u.exposed)==null||d.close(),o&&o(r.id),setTimeout(()=>{t.render(null,r),document.body.contains(r)&&document.body.removeChild(r)},500),Q(r.id)},l.time)),nt({modalContainer:r,modalInstance:m}),r.id},close:e=>{var l,o;if(e!=null&&D(e)){const n=T(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)}Q(e)},closeAll:()=>{L.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)}),lt()},reset:e=>{var l,o;e!=null&&D(e)&&((o=(l=T(e).modalInstance.component)==null?void 0:l.exposed)==null||o.reset())},min:e=>{var l,o;e!=null&&D(e)&&((o=(l=T(e).modalInstance.component)==null?void 0:l.exposed)==null||o.min())},full:e=>{var l,o;e!=null&&D(e)&&((o=(l=T(e).modalInstance.component)==null?void 0:l.exposed)==null||o.full())},revert:e=>{var l,o;e!=null&&D(e)&&((o=(l=T(e).modalInstance.component)==null?void 0:l.exposed)==null||o.revert())}},st={install:(e,l)=>{x._context=e._context,e.component(R.name,R),e.config.globalProperties.$layer=x,l&&typeof l.zIndex=="number"&&e.provide(Ze,t.ref(l.zIndex))}};w.ZanLayer=R,w.default=st,w.layer=x,w.zanLayer=x,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zan-layer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A powerful layer component for Vue 3",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "ZanUI",
|
|
8
|
+
"module": "lib/zan-layer.js",
|
|
9
|
+
"main": "lib/zan-layer.umd.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./types/index.d.ts",
|
|
14
|
+
"default": "./lib/zan-layer.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"./lib/*": "./lib/*",
|
|
18
|
+
"./types/*": [
|
|
19
|
+
"./types/*.d.ts"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"types": "types/index.d.ts",
|
|
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
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"vue",
|
|
32
|
+
"vue3",
|
|
33
|
+
"layer",
|
|
34
|
+
"modal",
|
|
35
|
+
"dialog"
|
|
36
|
+
],
|
|
37
|
+
"files": [
|
|
38
|
+
"lib",
|
|
39
|
+
"types",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"vue": "^3.2.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
47
|
+
"typescript": "^5.0.0",
|
|
48
|
+
"vite": "^5.0.0",
|
|
49
|
+
"vue": "^3.4.0",
|
|
50
|
+
"vue-tsc": "^3.2.4"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PropsContentType } from '../types';
|
|
2
|
+
import { StyleValue } from 'vue';
|
|
3
|
+
export interface FooterProps {
|
|
4
|
+
footer: PropsContentType | boolean;
|
|
5
|
+
footerStyle: string | StyleValue;
|
|
6
|
+
}
|
|
7
|
+
declare var __VLS_1: {};
|
|
8
|
+
type __VLS_Slots = {} & {
|
|
9
|
+
default?: (props: typeof __VLS_1) => any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: import("vue").DefineComponent<FooterProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FooterProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PropsContentType } from '../types';
|
|
2
|
+
import { StyleValue } from 'vue';
|
|
3
|
+
export interface HeaderProps {
|
|
4
|
+
title: PropsContentType | boolean;
|
|
5
|
+
titleStyle: string | StyleValue;
|
|
6
|
+
move: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare var __VLS_1: {};
|
|
9
|
+
type __VLS_Slots = {} & {
|
|
10
|
+
default?: (props: typeof __VLS_1) => any;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_base: import("vue").DefineComponent<HeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<HeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface HeaderBtnProps {
|
|
2
|
+
maxmin?: boolean;
|
|
3
|
+
min?: boolean;
|
|
4
|
+
max?: boolean;
|
|
5
|
+
closeBtn?: string | boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<HeaderBtnProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
onMin: (...args: any[]) => void;
|
|
9
|
+
onMax: (...args: any[]) => void;
|
|
10
|
+
onClose: (...args: any[]) => void;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<HeaderBtnProps> & Readonly<{
|
|
12
|
+
onOnMin?: ((...args: any[]) => any) | undefined;
|
|
13
|
+
onOnMax?: ((...args: any[]) => any) | undefined;
|
|
14
|
+
onOnClose?: ((...args: any[]) => any) | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
closeBtn: string | boolean;
|
|
17
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface IframeProps {
|
|
2
|
+
src?: string;
|
|
3
|
+
}
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<IframeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<IframeProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PropsContentType } from '../types';
|
|
2
|
+
export interface LayNotifyProps {
|
|
3
|
+
title: any;
|
|
4
|
+
content: PropsContentType;
|
|
5
|
+
isHtmlFragment?: boolean;
|
|
6
|
+
icon?: string | number | undefined;
|
|
7
|
+
iconClass: string[];
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<LayNotifyProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
close: (...args: any[]) => void;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<LayNotifyProps> & Readonly<{
|
|
12
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
isHtmlFragment: boolean;
|
|
15
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ImgListType } from '../types';
|
|
2
|
+
export interface LayPhotoProps {
|
|
3
|
+
imgList: ImgListType[];
|
|
4
|
+
startIndex: number;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<LayPhotoProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
+
resetCalculationPohtosArea: (...args: any[]) => void;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<LayPhotoProps> & Readonly<{
|
|
9
|
+
onResetCalculationPohtosArea?: ((...args: any[]) => any) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
startIndex: number;
|
|
12
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface PromptProps {
|
|
2
|
+
promptValue?: string;
|
|
3
|
+
formType?: 0 | 1 | 2 | 'text' | 'password' | 'textarea';
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<PromptProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
"update:promptValue": (...args: any[]) => void;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<PromptProps> & Readonly<{
|
|
10
|
+
"onUpdate:promptValue"?: ((...args: any[]) => any) | undefined;
|
|
11
|
+
}>, {
|
|
12
|
+
formType: 0 | 1 | 2 | "text" | "password" | "textarea";
|
|
13
|
+
placeholder: string;
|
|
14
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
render: () => any;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleValue } from 'vue';
|
|
2
|
+
export interface ShadeProps {
|
|
3
|
+
visible: boolean | string;
|
|
4
|
+
opacity: string;
|
|
5
|
+
index: number | Function;
|
|
6
|
+
teleport: string;
|
|
7
|
+
teleportDisabled: boolean;
|
|
8
|
+
shadeStyle?: StyleValue;
|
|
9
|
+
}
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<ShadeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
shadeClick: (...args: any[]) => void;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<ShadeProps> & Readonly<{
|
|
13
|
+
onShadeClick?: ((...args: any[]) => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
content: string;
|
|
3
|
+
direction: 'top' | 'right' | 'bottom' | 'left';
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ImgListType, PropsContentType, MoveEndFn, ResizeEndFn, LayerProps } from '../types';
|
|
2
|
+
import { StyleValue } from 'vue';
|
|
3
|
+
import '../styles/index.css';
|
|
4
|
+
declare var __VLS_28: {}, __VLS_30: {}, __VLS_76: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
title?: (props: typeof __VLS_28) => any;
|
|
7
|
+
} & {
|
|
8
|
+
default?: (props: typeof __VLS_30) => any;
|
|
9
|
+
} & {
|
|
10
|
+
footer?: (props: typeof __VLS_76) => any;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_base: import("vue").DefineComponent<LayerProps, {
|
|
13
|
+
reset: () => void;
|
|
14
|
+
open: () => void;
|
|
15
|
+
close: () => void;
|
|
16
|
+
full: () => Promise<void>;
|
|
17
|
+
min: () => Promise<void>;
|
|
18
|
+
revert: () => void;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
close: (...args: any[]) => void;
|
|
21
|
+
"update:modelValue": (...args: any[]) => void;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<LayerProps> & Readonly<{
|
|
23
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
25
|
+
}>, {
|
|
26
|
+
teleport: string;
|
|
27
|
+
teleportDisabled: boolean;
|
|
28
|
+
revert: Function;
|
|
29
|
+
end: Function;
|
|
30
|
+
move: boolean;
|
|
31
|
+
area: string | string[];
|
|
32
|
+
time: number;
|
|
33
|
+
title: PropsContentType | boolean;
|
|
34
|
+
close: Function;
|
|
35
|
+
load: number;
|
|
36
|
+
resize: boolean;
|
|
37
|
+
shadeOpacity: string;
|
|
38
|
+
titleStyle: string | false | import("vue").CSSProperties | StyleValue[] | null;
|
|
39
|
+
maxmin: boolean;
|
|
40
|
+
min: Function;
|
|
41
|
+
closeBtn: boolean | string;
|
|
42
|
+
type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | "dialog" | "page" | "iframe" | "loading" | "drawer" | "photos" | "notify" | "prompt";
|
|
43
|
+
imgList: ImgListType[];
|
|
44
|
+
startIndex: number;
|
|
45
|
+
isHtmlFragment: boolean;
|
|
46
|
+
formType: 0 | 1 | 2 | "text" | "password" | "textarea";
|
|
47
|
+
placeholder: string;
|
|
48
|
+
value: string;
|
|
49
|
+
modelValue: boolean;
|
|
50
|
+
offset: string | string[];
|
|
51
|
+
shade: boolean;
|
|
52
|
+
shadeClose: boolean;
|
|
53
|
+
btnAlign: "l" | "c" | "r";
|
|
54
|
+
anim: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
55
|
+
isOutAnim: boolean;
|
|
56
|
+
animDuration: string;
|
|
57
|
+
moveOut: boolean;
|
|
58
|
+
lastPosition: boolean;
|
|
59
|
+
yesText: string;
|
|
60
|
+
isMessage: boolean;
|
|
61
|
+
isFunction: boolean;
|
|
62
|
+
success: Function;
|
|
63
|
+
beforeClose: Function;
|
|
64
|
+
full: Function;
|
|
65
|
+
moveStart: Function;
|
|
66
|
+
moving: Function;
|
|
67
|
+
moveEnd: MoveEndFn;
|
|
68
|
+
resizeStart: Function;
|
|
69
|
+
resizing: Function;
|
|
70
|
+
resizeEnd: ResizeEndFn;
|
|
71
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
72
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
73
|
+
declare const _default: typeof __VLS_export;
|
|
74
|
+
export default _default;
|
|
75
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
76
|
+
new (): {
|
|
77
|
+
$slots: S;
|
|
78
|
+
};
|
|
79
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AppContext, App } from 'vue';
|
|
2
|
+
import ZanLayer from './component/ZanLayer.vue';
|
|
3
|
+
import { LayerProps, InstallOptions } from './types';
|
|
4
|
+
export declare const layer: {
|
|
5
|
+
_context: AppContext | null;
|
|
6
|
+
open: (option: LayerProps) => string;
|
|
7
|
+
drawer: (option: LayerProps) => string;
|
|
8
|
+
msg: (message: string, option?: LayerProps, callback?: Function) => string;
|
|
9
|
+
load: (load?: number, option?: LayerProps) => string;
|
|
10
|
+
confirm: (msg: string, option?: LayerProps) => string;
|
|
11
|
+
notify: (option: LayerProps, callback?: Function) => string;
|
|
12
|
+
photos: (option: string | LayerProps) => string;
|
|
13
|
+
prompt: (option: LayerProps) => string;
|
|
14
|
+
create: (option: LayerProps, defaultOption: LayerProps, callback?: Function) => string;
|
|
15
|
+
close: (id: any) => void;
|
|
16
|
+
closeAll: () => void;
|
|
17
|
+
reset: (id: any) => void;
|
|
18
|
+
min: (id: any) => void;
|
|
19
|
+
full: (id: any) => void;
|
|
20
|
+
revert: (id: any) => void;
|
|
21
|
+
};
|
|
22
|
+
export { ZanLayer, layer as zanLayer };
|
|
23
|
+
declare const _default: {
|
|
24
|
+
install: (app: App, options?: InstallOptions) => void;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
|
27
|
+
export * from './types';
|
|
28
|
+
import './styles/index.css';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { StyleValue, VNodeTypes } from 'vue';
|
|
2
|
+
export type StringObject = Record<string, unknown>;
|
|
3
|
+
export type InstallOptions = StringObject;
|
|
4
|
+
export type BtnType = {
|
|
5
|
+
text: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
style?: string | StyleValue;
|
|
8
|
+
class?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
callback: (id: string, ...args: any) => void;
|
|
11
|
+
};
|
|
12
|
+
export type ImgListType = {
|
|
13
|
+
src: string;
|
|
14
|
+
alt?: string;
|
|
15
|
+
thumb?: string;
|
|
16
|
+
};
|
|
17
|
+
export type PropsContentType = VNodeTypes | (() => VNodeTypes);
|
|
18
|
+
type OperateEndReturn = void | [string, string] | undefined;
|
|
19
|
+
interface MoveEndFnOptions {
|
|
20
|
+
left: string;
|
|
21
|
+
top: string;
|
|
22
|
+
isMax: boolean;
|
|
23
|
+
isMin: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type MoveEndFn = (id: string, options: MoveEndFnOptions) => OperateEndReturn;
|
|
26
|
+
interface ResizeEndFnOptions {
|
|
27
|
+
width: string;
|
|
28
|
+
height: string;
|
|
29
|
+
}
|
|
30
|
+
export type ResizeEndFn = (id: string, options: ResizeEndFnOptions) => OperateEndReturn;
|
|
31
|
+
export interface LayerProps {
|
|
32
|
+
modelValue?: boolean;
|
|
33
|
+
type?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 'dialog' | 'page' | 'iframe' | 'loading' | 'drawer' | 'photos' | 'notify' | 'prompt';
|
|
34
|
+
title?: PropsContentType | boolean;
|
|
35
|
+
footer?: PropsContentType | boolean;
|
|
36
|
+
titleStyle?: string | StyleValue;
|
|
37
|
+
footerStyle?: string | StyleValue;
|
|
38
|
+
content?: PropsContentType;
|
|
39
|
+
isHtmlFragment?: boolean;
|
|
40
|
+
offset?: string | string[];
|
|
41
|
+
area?: string | string[];
|
|
42
|
+
move?: boolean;
|
|
43
|
+
maxmin?: boolean;
|
|
44
|
+
resize?: boolean;
|
|
45
|
+
shade?: boolean;
|
|
46
|
+
shadeClose?: boolean;
|
|
47
|
+
shadeStyle?: StyleValue;
|
|
48
|
+
shadeOpacity?: string;
|
|
49
|
+
layerClasses?: string;
|
|
50
|
+
zIndex?: number;
|
|
51
|
+
closeBtn?: boolean | string;
|
|
52
|
+
btn?: BtnType[];
|
|
53
|
+
btnAlign?: 'l' | 'c' | 'r';
|
|
54
|
+
anim?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
55
|
+
isOutAnim?: boolean;
|
|
56
|
+
icon?: string | number;
|
|
57
|
+
imgList?: ImgListType[];
|
|
58
|
+
startIndex?: number;
|
|
59
|
+
animDuration?: string;
|
|
60
|
+
moveOut?: boolean;
|
|
61
|
+
teleport?: string;
|
|
62
|
+
teleportDisabled?: boolean;
|
|
63
|
+
lastPosition?: boolean;
|
|
64
|
+
time?: number;
|
|
65
|
+
load?: number;
|
|
66
|
+
yesText?: string;
|
|
67
|
+
formType?: 0 | 1 | 2 | 'text' | 'password' | 'textarea';
|
|
68
|
+
value?: string;
|
|
69
|
+
maxLength?: number;
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
isMessage?: boolean;
|
|
72
|
+
id?: string;
|
|
73
|
+
isFunction?: boolean;
|
|
74
|
+
appContext?: any;
|
|
75
|
+
success?: Function;
|
|
76
|
+
end?: Function;
|
|
77
|
+
yes?: Function;
|
|
78
|
+
beforeClose?: Function;
|
|
79
|
+
close?: Function;
|
|
80
|
+
min?: Function;
|
|
81
|
+
full?: Function;
|
|
82
|
+
revert?: Function;
|
|
83
|
+
moveStart?: Function;
|
|
84
|
+
moving?: Function;
|
|
85
|
+
moveEnd?: MoveEndFn;
|
|
86
|
+
resizeStart?: Function;
|
|
87
|
+
resizing?: Function;
|
|
88
|
+
resizeEnd?: ResizeEndFn;
|
|
89
|
+
internalDestroy?: Function;
|
|
90
|
+
}
|
|
91
|
+
export interface ShadeProps {
|
|
92
|
+
visible: boolean | string;
|
|
93
|
+
opacity: string;
|
|
94
|
+
index: number | Function;
|
|
95
|
+
teleport: string;
|
|
96
|
+
teleportDisabled: boolean;
|
|
97
|
+
shadeStyle?: StyleValue;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare function nextId(): any;
|
|
2
|
+
export declare function calculateMinArea(minArea: any): any[];
|
|
3
|
+
export declare function calculateArea(type: any, area: any, offset: any): any[];
|
|
4
|
+
export declare function calculateBaseArea(area: any): any[];
|
|
5
|
+
export declare function calculateDrawerArea(offset: any, drawerArea?: string[] | string): string[];
|
|
6
|
+
/**
|
|
7
|
+
* 计算 offset 属性
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculateOffset(offset: string[] | string, area: string[], type: number): string[];
|
|
10
|
+
/**
|
|
11
|
+
* 转换 number 类型
|
|
12
|
+
*/
|
|
13
|
+
export declare function calculateType(modalType: number | string): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
14
|
+
export declare function maxArea(): {
|
|
15
|
+
w: string;
|
|
16
|
+
h: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function maxOffset(): {
|
|
19
|
+
t: string;
|
|
20
|
+
l: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function minArea(): {
|
|
23
|
+
w: string;
|
|
24
|
+
h: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function minOffset(left: any): {
|
|
27
|
+
t: string;
|
|
28
|
+
l: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function getArea(dom: HTMLDivElement | null): string[];
|
|
31
|
+
export declare function updateMinArrays(id: string, state: Boolean): number;
|
|
32
|
+
/**
|
|
33
|
+
* 根据 offset 返回 anim 动画
|
|
34
|
+
*/
|
|
35
|
+
export declare function getDrawerAnimationClass(offset: any, isClose?: boolean): string;
|
|
36
|
+
/**
|
|
37
|
+
* 计算 image 尺寸, 缩放尺寸
|
|
38
|
+
*/
|
|
39
|
+
export declare function calculatePhotosArea(url: string, options: object): Promise<Array<string>>;
|
|
40
|
+
export declare function calculateNotifOffset(offset: any, area: any, layerId: string): string[];
|
|
41
|
+
export declare function removeNotifiyFromQueen(layerId: string): void;
|
|
42
|
+
export declare function getNotifyAnimationClass(offset: any): string;
|
|
43
|
+
export * from './render';
|