layui/package/layer/lib/layer-vue.umd.js

4 lines
90 KiB
JavaScript
Raw Normal View History

2022-11-15 01:16:55 +00:00
(function(P,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(P=typeof globalThis!="undefined"?globalThis:P||self,a(P.Layui={},P.Vue))})(this,function(P,a){"use strict";function Y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ae(t,e,n,r,o,c,i){try{var d=t[c](i),p=d.value}catch(A){n(A);return}d.done?e(p):Promise.resolve(p).then(r,o)}function oe(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var c=t.apply(e,n);function i(p){Ae(c,r,o,i,d,"next",p)}function d(p){Ae(c,r,o,i,d,"throw",p)}i(void 0)})}}function te(t){return te=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(t)}var me={exports:{}};(function(t){var e=function(n){var r=Object.prototype,o=r.hasOwnProperty,c,i=typeof Symbol=="function"?Symbol:{},d=i.iterator||"@@iterator",p=i.asyncIterator||"@@asyncIterator",A=i.toStringTag||"@@toStringTag";function y(u,l,s){return Object.defineProperty(u,l,{value:s,enumerable:!0,configurable:!0,writable:!0}),u[l]}try{y({},"")}catch(u){y=function(s,m,v){return s[m]=v}}function h(u,l,s,m){var v=l&&l.prototype instanceof J?l:J,b=Object.create(v.prototype),C=new _(m||[]);return b._invoke=ne(u,s,C),b}n.wrap=h;function f(u,l,s){try{return{type:"normal",arg:u.call(l,s)}}catch(m){return{type:"throw",arg:m}}}var g="suspendedStart",w="suspendedYield",G="executing",U="completed",x={};function J(){}function E(){}function k(){}var O={};y(O,d,function(){return this});var Q=Object.getPrototypeOf,H=Q&&Q(Q(ee([])));H&&H!==r&&o.call(H,d)&&(O=H);var Z=k.prototype=J.prototype=Object.create(O);E.prototype=k,y(Z,"constructor",k),y(k,"constructor",E),E.displayName=y(k,A,"GeneratorFunction");function R(u){["next","throw","return"].forEach(function(l){y(u,l,function(s){return this._invoke(l,s)})})}n.isGeneratorFunction=function(u){var l=typeof u=="function"&&u.constructor;return l?l===E||(l.displayName||l.name)==="GeneratorFunction":!1},n.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,k):(u.__proto__=k,y(u,A,"GeneratorFunction")),u.prototype=Object.create(Z),u},n.awrap=function(u){return{__await:u}};function j(u,l){function s(b,C,I,S){var F=f(u[b],u,C);if(F.type==="throw")S(F.arg);else{var z=F.arg,V=z.value;return V&&te(V)==="object"&&o.call(V,"__await")?l.resolve(V.__await).then(function(W){s("next",W,I,S)},function(W){s("throw",W,I,S)}):l.resolve(V).then(function(W){z.value=W,I(z)},function(W){return s("throw",W,I,S)})}}var m;function v(b,C){function I(){return new l(function(S,F){s(b,C,S,F)})}return m=m?m.then(I,I):I()}this._invoke=v}R(j.prototype),y(j.prototype,p,function(){return this}),n.AsyncIterator=j,n.async=function(u,l,s,m,v){v===void 0&&(v=Promise);var b=new j(h(u,l,s,m),v);return n.isGeneratorFunction(l)?b:b.next().then(function(C){return C.done?C.value:b.next()})};function ne(u,l,s){var m=g;return function(b,C){if(m===G)throw new Error("Generator is already running");if(m===U){if(b==="throw")throw C;return ie()}for(s.method=b,s.arg=C;;){var I=s.delegate;if(I){var S=re(I,s);if(S){if(S===x)continue;return S}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(m===g)throw m=U,s.arg;s.dispatchException(s.arg)}else s.method==="return"&&s.abrupt("return",s.arg);m=G;var F=f(u,l,s);if(F.type==="normal"){if(m=s.done?U:w,F.arg===x)continue;return{value:F.arg,done:s.done}}else F.type==="throw"&&(m=U,s.method="throw",s.arg=F.arg)}}}function re(u,l){var s=u.iterator[l.method];if(s===c){if(l.delegate=null,l.method==="throw"){if(u.iterator.return&&(l.method="return",l.arg=c,re(u,l),l.method==="throw"))return x;l.method="throw",l.arg=new TypeError("The iterator does not provide a 'throw' method")}return x}var m=f(s,u.iterator,l.arg);if(m.type==="throw")return l.method="throw",l.arg=m.arg,l.delegate=null,x;var v=m.arg;if(!v)return l.method="throw",l.arg=new TypeErr
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xt(t){return bt(t)||vt(t)||wt(t)||kt()}function Oe(){for(var t=[],e="0123456789abcdef",n=0;n<36;n++)t[n]=e.substr(Math.floor(Math.random()*16),1);t[14]="4",t[19]=e.substr(t[19]&3|8,1),t[8]=t[13]=t[18]=t[23]="-";var r=t.join("");return r}function Ct(t,e,n){return t!="drawer"?Bt(e):Qe(n,e)}function Bt(t){return t==="auto"?[]:typeof t=="string"?[t]:xt(t)}function Qe(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"30%";return e instanceof Array?e:(e==="auto"&&(e="30%"),t==="l"||t==="r"?[e,"100%"]:t==="t"||t==="b"?["100%",e]:[e,"100%"])}function se(t,e,n){var r=["t","r","b","l","lt","lb","rt","rb"],o=t[0],c=t[1];return t instanceof Array&&n==="drawer"&&(t="r"),r.indexOf(t)>-1&&(o="50%",c="50%"),(r.indexOf(t)!=-1||o.indexOf("%")>-1)&&(o="calc("+o+" - ("+(e==="auto"?"100px":e[1])+"/2 ))"),(r.indexOf(t)!=-1||c.indexOf("%")>-1)&&(c="calc("+c+" - ("+(e==="auto"?"100px":e[0])+"/2 ))"),t==="t"?o="0px":t==="r"?c="calc(100% - "+e[0]+")":t==="b"?o="calc(100% - "+e[1]+")":t==="l"?c="0px":t==="lt"?(o="0px",c="0px"):t==="lb"?(o="calc(100% - "+e[1]+")",c="0px"):t==="rt"?(o="0px",c="calc(100% - "+e[0]+")"):t==="rb"&&(o="calc(100% - "+e[1]+")",c="calc(100% - "+e[0]+")"),[o,c]}function Et(t){return t==="dialog"||t==0?0:t==="page"||t==1?1:t==="iframe"||t==2?2:t==="loading"||t==3?3:t==="drawer"||t==4?4:t==="photos"||t==5?5:t==="notifiy"||t==6?6:0}function Ie(t,e,n,r,o){if(e&&e.indexOf("%")!=-1&&(e="100%"),n&&n.length>0){if(r==0)return t?"calc("+e+" - 137px)":"calc("+e+" - 86px)";if(r==1||r==4||r==2)return t?"calc("+e+" - 102px)":"calc("+e+" - 51px)"}else{if(r==0)return t?o?"":"calc("+e+" - 137px)":o?"":"calc("+e+" - 86px)";if(r==1||r==4||r==2)return t?"calc("+e+" - 51px)":"calc("+e+" - 0px)"}}function De(){return{w:"100%",h:"100%"}}function Le(){return{t:"0px",l:"0px"}}function je(){return{w:"180px",h:"51px"}}function Se(t){return{t:"calc(100% - 51px)",l:t+"px"}}function Ot(t){var e=getComputedStyle(t,null).width,n=getComputedStyle(t,null).height;return[e,n]}var X=[];function Qt(t,e){var n=0;if(e){var r=X.findIndex(function(o){return o===void 0});r===-1?(X.push(t),n=X.length-1):(X[r]=t,n=r)}else delete X[X.findIndex(function(o){return o==t})],n=-1;return n}function Fe(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n="layer-drawer-anim layer-anim",r="rl";return t==="l"?r="lr":t==="r"?r="rl":t==="t"?r="tb":t==="b"&&(r="bt"),e?"".concat(n,"-").concat(r,"-close"):"".concat(n,"-").concat(r)}function He(t,e){return ce.apply(this,arguments)}function ce(){return ce=oe(K.mark(function t(e,n){var r,o;return K.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return o=function(p){var A=[p.width,p.height],y=[window.innerWidth-250,window.innerHeight-250];if(A[0]>y[0]||A[1]>y[1]){var h=[A[0]/y[0],A[1]/y[1]];h[0]>h[1]?(A[0]=A[0]/h[0],A[1]=A[1]/h[0]):h[0]<h[1]&&(A[0]=A[0]/h[1],A[1]=A[1]/h[1])}return[A[0]+"px",A[1]+"px"]},r=new Image,r.src=e,i.abrupt("return",new Promise(function(d,p){if(r.complete){d(o(r));return}var A=L.load(2);r.onload=function(){L.close(A),d(o(r))},r.onerror=function(){L.close(A),L.msg("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"),p(!1)}}));case 4:case"end":return i.stop()}},t)})),ce.apply(this,arguments)}function It(t,e,n){var r=["lt","lb","rt","rb"],o="0",c="0",i=15,d=15;window.NotifiyQueen=window.NotifiyQueen||[];var p=window.NotifiyQueen;(typeof t!="string"||r.indexOf(t)===-1)&&(t="rt");var A=p.filter(function(w){if(w.offset===t)return w}),y=A.length>0?A[A.length-1]:null;if(y){var h,f;if(y=(h=document.getElementById(y.id))===null||h===void 0||(f=h.firstElementChild)===null||f===void 0?void 0:f.firstElementChild,t==="rt"||t==="lt")d+=y.offsetHeight+parseFloat(y.style.top);else{var g=parseFloat(y.style.top.split(" - ")[1]);d+=y.offsetHeight+g}}else(t==="rb"||t==="lb")&&(d+=parseFloat(e[1]));return t==="rt"?(o=d+"px",c="calc(100% - "+(parseFloat(e[0])+i)+"px)"):t==="rb"?(o="calc(100vh - "+d+"px)",c="calc(100% - "+(parseFloat(e[0])+i)+"px)"):t==="lt"?(o=d+"px",c=i+"px"):t==="lb"&&(o="calc(100vh - "+d+"px)",c=i+"px
`)();function Ne(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Pe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ne(Object(n),!0).forEach(function(r){Y(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ne(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var T=[],Gt=function(e){T.push(e)},ue=function(e){T.forEach(function(n,r){n.modalContainer.id===e&&T.splice(r,1)})},Mt=function(){T.splice(0,T.length)},Nt=function(e){var n=!1;return T.forEach(function(r,o){r.modalContainer.id==e&&(n=!0)}),n},Pt=function(e){var n=null;return T.forEach(function(r,o){r.modalContainer.id===e&&(n=r)}),n},Ut=function(e,n){return e&&(n=Object.assign(n,e)),n},Wt=function(e){var n=document.createElement("div");return n.id=e.id,document.body.appendChild(n),n},Yt=function(e){return typeof e=="function"?a.isVNode(e())?{default:function(){return e()}}:void 0:a.isVNode(e)?{default:function(){return e}}:void 0},L={_context:null,open:function(e,n){var r={};return L.create(e,r,n)},drawer:function(e,n){var r={type:"drawer"};return L.create(e,r,n)},msg:function(e,n,r){var o={type:0,title:!1,content:e,closeBtn:!1,shadeClose:!1,isMessage:!0,shade:!1,time:1e3,btn:!1};return L.create(n,o,r)},load:function(e,n,r){var o={type:3,load:e,anim:5,isOutAnim:!1,shadeClose:!1};return L.create(n,o,r)},confirm:function(e,n,r){var o={type:0,content:e,shadeClose:!1};return L.create(n,o,r)},photos:function(e,n){typeof e=="string"&&(e={imgList:[{src:e}]});var r={type:5,anim:2,startIndex:0,isOutAnim:!0,shadeClose:!0,shadeOpacity:"0.7"};return L.create(e,r,n)},notifiy:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;e.type=6;var r={offset:"rt",time:2e3,area:"auto",shade:!1};return L.create(e,r,n)},create:function(e,n,r){var o,c,i,d=Ut(e,n);d.hasOwnProperty("id")?L.close(d.id):d.id=Oe();var p=Wt(d),A=a.h(ae,Pe(Pe({},d),{},{isFunction:!0,destroy:function(){var h,f;clearTimeout(i),(h=A.component)===null||h===void 0||(f=h.exposed)===null||f===void 0||f.close(),setTimeout(function(){a.render(null,p),document.body.contains(p)&&document.body.removeChild(p)},2e3),ue(p.id)}}),Yt(d.content));return A.appContext=d.appContext||L._context,a.render(A,p),(o=A.component)===null||o===void 0||(c=o.exposed)===null||c===void 0||c.open(),n&&n.time!=null&&n.time!=0&&(i=setTimeout(function(){var y,h;(y=A.component)===null||y===void 0||(h=y.exposed)===null||h===void 0||h.close(),r&&r(p.id),setTimeout(function(){a.render(null,p),document.body.contains(p)&&document.body.removeChild(p)},2e3),ue(p.id),d.type===6&&Ze(d.id)},n.time)),Gt({modalContainer:p,modalInstance:A}),p.id},close:function(e){if(e!=null&&Nt(e)){var n,r,o=Pt(e);(n=o.modalInstance.component)===null||n===void 0||(r=n.exposed)===null||r===void 0||r.close(),setTimeout(function(){a.render(null,o.modalContainer),document.body.contains(o.modalContainer)&&document.body.removeChild(o.modalContainer)},2e3)}ue(e)},closeAll:function(){T.forEach(function(e){var n,r;(n=e.modalInstance.component)===null||n===void 0||(r=n.exposed)===null||r===void 0||r.close(),setTimeout(function(){a.render(null,e.modalContainer),document.body.contains(e.modalContainer)&&document.body.removeChild(e.modalContainer)},2e3)}),Mt()},reset:function(e){var n,r;(n=e.modalInstance.component)===null||n===void 0||(r=n.exposed)===null||r===void 0||r.reset()}},Tt=function(e,n){L._context=e._context,e.component(ae.name,ae),e.config.globalProperties.$layer=L,n&&e.provide(Re,n.zIndex)},zt={install:Tt};P.LayLayer=ae,P.default=zt,P.layer=L,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});