mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
var Le=Object.defineProperty,ke=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var te=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var se=t=>{throw TypeError(t)};var V=(t,e,s)=>e in t?Le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,R=(t,e)=>{for(var s in e||(e={}))qe.call(e,s)&&V(t,s,e[s]);if(te)for(var s of te(e))De.call(e,s)&&V(t,s,e[s]);return t},ie=(t,e)=>ke(t,ve(e));var y=(t,e,s)=>V(t,typeof e!="symbol"?e+"":e,s),re=(t,e,s)=>e.has(t)||se("Cannot "+s);var c=(t,e,s)=>(re(t,e,"read from private field"),s?s.call(t):e.get(t)),j=(t,e,s)=>e.has(t)?se("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s);var o=(t,e,s)=>(re(t,e,"access private method"),s);var p=(t,e,s)=>new Promise((r,n)=>{var u=h=>{try{l(s.next(h))}catch(f){n(f)}},a=h=>{try{l(s.throw(h))}catch(f){n(f)}},l=h=>h.done?r(h.value):Promise.resolve(h.value).then(u,a);l((s=s.apply(t,e)).next())});import{d as xe,a as Me,m as Re,f as ne}from"./index-DMqaFtX4.js";const ce=t=>Array.isArray(t),fe=t=>ce(t)?t:[t];let $e=function(t){let e=function(d){return fe(d).forEach(b=>{var M;return m.set(Symbol((M=b.char)==null?void 0:M.innerText),n(R({},b)))}),this},s=()=>h().filter(d=>d.typeable),r=function(d,b){let M=[...m.keys()];m.set(M[d],n(b))},n=d=>(d.shouldPauseCursor=function(){return!!(this.typeable||this.cursorable||this.deletable)},d),u=function(){m.forEach(d=>delete d.done)},a=function(){m=new Map,e(t)},l=()=>m,h=()=>Array.from(m.values()),f=d=>m.delete(d),D=()=>{const d=[];for(let[,b]of l())b.done||d.push(b);return d},x=(d=!1)=>d?h():h().filter(b=>!b.done),C=(d,b=!1)=>b?m.delete(d):m.get(d).done=!0,m=new Map;return e(t),{add:e,set:r,wipe:a,done:C,reset:u,destroy:f,getItems:x,getQueue:l,getTypeable:s,getPendingQueueItems:D}};const pe="data-typeit-id",P="ti-cursor",Qe="END",Fe={started:!1,completed:!1,frozen:!1,destroyed:!1},E={breakLines:!0,cursor:{autoPause:!0,autoPauseDelay:500,animation:{frames:[0,0,1].map(t=>({opacity:t})),options:{iterations:1/0,easing:"steps(2, start)",fill:"forwards"}}},cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},He=`[${pe}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`,Q=t=>document.createElement(t),Y=t=>document.createTextNode(t),me=(t,e="")=>{let s=Q("style");s.id=e,s.appendChild(Y(t)),document.head.appendChild(s)},oe=t=>(ce(t)||(t=[t/2,t/2]),t),ue=(t,e)=>Math.abs(Math.random()*(t+e-(t-e))+(t-e));let le=t=>t/2;function Be(t){let{speed:e,deleteSpeed:s,lifeLike:r}=t;return s=s!==null?s:e/3,r?[ue(e,le(e)),ue(s,le(s))]:[e,s]}const ye=t=>Array.from(t);let Z=t=>([...t.childNodes].forEach(e=>{if(e.nodeValue){[...e.nodeValue].forEach(s=>{e.parentNode.insertBefore(Y(s),e)}),e.remove();return}Z(e)}),t);const be=t=>{let e=document.implementation.createHTMLDocument();return e.body.innerHTML=t,Z(e.body)};function ge(t,e=!1,s=!1){let r=t.querySelector(`.${P}`),n=document.createTreeWalker(t,NodeFilter.SHOW_ALL,{acceptNode:l=>{var h,f;if(r&&s){if((h=l.classList)!=null&&h.contains(P))return NodeFilter.FILTER_ACCEPT;if(r.contains(l))return NodeFilter.FILTER_REJECT}return(f=l.classList)!=null&&f.contains(P)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),u,a=[];for(;u=n.nextNode();)u.originalParent||(u.originalParent=u.parentNode),a.push(u);return e?a.reverse():a}function _e(t){return ge(be(t))}function ze(t,e=!0){return e?_e(t):ye(t).map(Y)}const Ue=({index:t,newIndex:e,queueItems:s,cleanUp:r})=>{for(let n=t+1;n<e+1;n++)r(s[n][0])},Te=t=>Number.isInteger(t),ae=({queueItems:t,selector:e,cursorPosition:s,to:r})=>{if(Te(e))return e*-1;let n=new RegExp(Qe,"i").test(r),u=e?[...t].reverse().findIndex(({char:l})=>{let h=l.parentElement,f=h.matches(e);return n&&f?!0:f&&h.firstChild.isSameNode(l)}):-1;u<0&&(u=n?0:t.length-1);let a=n?0:1;return u-s+a},Ve=t=>(t.forEach(clearTimeout),[]),$=(t,e)=>new Array(e).fill(t);let _=t=>new Promise(e=>{requestAnimationFrame(()=>p(void 0,null,function*(){e(yield t())}))}),we=t=>t==null?void 0:t.getAnimations().find(e=>e.id===t.dataset.tiAnimationId),Pe=({cursor:t,frames:e,options:s})=>{let r=t.animate(e,s);return r.pause(),r.id=t.dataset.tiAnimationId,_(()=>{_(()=>{r.play()})}),r},je=({cursor:t,options:e,cursorOptions:s})=>{if(!t||!s)return;let r=we(t),n;r&&(e.delay=r.effect.getComputedTiming().delay,n=r.currentTime,r.cancel());let u=Pe({cursor:t,frames:s.animation.frames,options:e});return n&&(u.currentTime=n),u},he=t=>{var e;return(e=t.func)==null?void 0:e.call(null)},Oe=u=>p(void 0,[u],function*({index:t,queueItems:e,wait:s,cursor:r,cursorOptions:n}){let a=e[t][1],l=[],h=t,f=a,D=()=>f&&!f.delay,x=a.shouldPauseCursor()&&n.autoPause;for(;D();)l.push(f),D()&&h++,f=e[h]?e[h][1]:null;if(l.length)return yield _(()=>p(void 0,null,function*(){for(let d of l)yield he(d)})),h-1;let C=we(r),m;return C&&(m=ie(R({},C.effect.getComputedTiming()),{delay:x?n.autoPauseDelay:0})),yield s(()=>p(void 0,null,function*(){C&&x&&C.cancel(),yield _(()=>{he(a)})}),a.delay),yield je({cursor:r,options:m,cursorOptions:n}),t});const We=(t,e)=>{new IntersectionObserver((r,n)=>{r.forEach(u=>{u.isIntersecting&&(e(),n.unobserve(t))})},{threshold:1}).observe(t)},Je=()=>Math.random().toString().substring(2,9),z=t=>"value"in t;let Xe=t=>z(t)?ye(t.value):ge(t,!0).filter(e=>!(e.childNodes.length>0)),S=t=>typeof t=="function"?t():t,ee=(t,e=document,s=!1)=>e[`querySelector${s?"All":""}`](t),Ge=t=>/body/i.test(t==null?void 0:t.tagName),Ke=(t,e)=>{if(z(t)){t.value=`${t.value}${e.textContent}`;return}e.innerHTML="";let s=Ge(e.originalParent)?t:e.originalParent||t,r=ee("."+P,s)||null;r&&r.parentElement!==s&&(s=r.parentElement),s.insertBefore(e,r)};const Ye=t=>/<(.+)>(.*?)<\/(.+)>/.test(t.outerHTML),I=(t,e)=>Object.assign({},t,e);let Ze=t=>{var e,s,r;if(typeof t=="object"){let n={},{frames:u,options:a}=E.cursor.animation;return n.animation=t.animation||{},n.animation.frames=((e=t.animation)==null?void 0:e.frames)||u,n.animation.options=I(a,((s=t.animation)==null?void 0:s.options)||{}),n.autoPause=(r=t.autoPause)!=null?r:E.cursor.autoPause,n.autoPauseDelay=t.autoPauseDelay||E.cursor.autoPauseDelay,n}return t===!0?E.cursor:t};const et=(t,e)=>{if(!t)return;let s=t.parentNode;(s.childNodes.length>1||s.isSameNode(e)?t:s).remove()},tt=(t,e,s)=>{let r=e[s-1],n=ee(`.${P}`,t);t=(r==null?void 0:r.parentNode)||t,t.insertBefore(n,r||null)};function st(t){return typeof t=="string"?ee(t):t}let it={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"",transform:"translateX(-.125em)"},rt=(t,e)=>{let r=`${`[${pe}='${t}']`} .${P}`,n=getComputedStyle(e),u=Object.entries(it).reduce((a,[l,h])=>`${a} ${l}: var(--ti-cursor-${l}, ${h||n[l]});`,"");me(`${r} { display: inline-block; width: 0; ${u} }`,t)};function nt(t){return t.replace(/<!--(.+?)-->/g,"").trim().split(/<br(?:\s*?)(?:\/)?>/)}let ot=(t,e,s)=>Math.min(Math.max(e+t,0),s.length),ut=(t,e,s)=>new Promise(r=>{let n=()=>p(void 0,null,function*(){yield t(),r()});s.push(setTimeout(n,e||0))});var i,Ce,N,O,Se,W,J,X,F,g,Ee,A,L,Ie,U,Ne,Ae,G,H,k,B,w,v,q,K,T,de;let lt=(de=class{constructor(e,s={}){j(this,i);y(this,"element");y(this,"timeouts");y(this,"cursorPosition");y(this,"predictedCursorPosition");y(this,"statuses",{started:!1,completed:!1,frozen:!1,destroyed:!1,firing:!1});y(this,"opts");y(this,"id");y(this,"queue");y(this,"cursor");y(this,"flushCallback",null);y(this,"unfreeze",()=>{});y(this,"is",function(e){return this.statuses[e]});j(this,U,e=>{var s;this.opts.cursor=Ze((s=e.cursor)!=null?s:E.cursor),this.opts.strings=o(this,i,Ne).call(this,fe(this.opts.strings)),this.opts=I(this.opts,{html:!c(this,i,q)&&this.opts.html,nextStringDelay:oe(this.opts.nextStringDelay),loopDelay:oe(this.opts.loopDelay)})});this.opts=I(E,s),this.element=st(e),this.timeouts=[],this.cursorPosition=0,this.unfreeze=()=>{},this.predictedCursorPosition=null,this.statuses=I({},Fe),this.id=Je(),this.queue=$e([{delay:this.opts.startDelay}]),c(this,U).call(this,s),this.cursor=o(this,i,Ae).call(this),this.element.dataset.typeitId=this.id,me(He),this.opts.strings.length&&o(this,i,Ie).call(this)}go(){return this.statuses.started?this:(o(this,i,X).call(this),this.opts.waitUntilVisible?(We(this.element,o(this,i,N).bind(this)),this):(o(this,i,N).call(this),this))}destroy(e=!0){this.timeouts=Ve(this.timeouts),S(e)&&this.cursor&&o(this,i,B).call(this,this.cursor),this.statuses.destroyed=!0}reset(e){!this.is("destroyed")&&this.destroy(),e?(this.queue.wipe(),e(this)):this.queue.reset(),this.cursorPosition=0;for(let s in this.statuses)this.statuses[s]=!1;return this.element[o(this,i,F).call(this)?"value":"innerHTML"]="",this}type(e,s={}){e=S(e);let{instant:r}=s,n=o(this,i,A).call(this,s),a=ze(e,this.opts.html).map(h=>({func:()=>o(this,i,H).call(this,h),char:h,delay:r||Ye(h)?0:o(this,i,w).call(this),typeable:h.nodeType===Node.TEXT_NODE})),l=[n[0],{func:()=>p(this,null,function*(){return yield this.opts.beforeString(e,this)})},...a,{func:()=>p(this,null,function*(){return yield this.opts.afterString(e,this)})},n[1]];return o(this,i,g).call(this,l,s)}break(e={}){return o(this,i,g).call(this,{func:()=>o(this,i,H).call(this,Q("BR")),typeable:!0},e)}move(e,s={}){e=S(e);let r=o(this,i,A).call(this,s),{instant:n,to:u}=s,a=ae({queueItems:this.queue.getTypeable(),selector:e===null?"":e,to:u,cursorPosition:c(this,i,v)}),l=a<0?-1:1;return this.predictedCursorPosition=c(this,i,v)+a,o(this,i,g).call(this,[r[0],...$({func:()=>o(this,i,O).call(this,l),delay:n?0:o(this,i,w).call(this),cursorable:!0},Math.abs(a)),r[1]],s)}exec(e,s={}){let r=o(this,i,A).call(this,s);return o(this,i,g).call(this,[r[0],{func:()=>e(this)},r[1]],s)}options(e,s={}){return e=S(e),o(this,i,L).call(this,e),o(this,i,g).call(this,{},s)}pause(e,s={}){return o(this,i,g).call(this,{delay:S(e)},s)}delete(e=null,s={}){e=S(e);let r=o(this,i,A).call(this,s),n=e,{instant:u,to:a}=s,l=this.queue.getTypeable(),h=n===null?l.length:Te(n)?n:ae({queueItems:l,selector:n,cursorPosition:c(this,i,v),to:a});return o(this,i,g).call(this,[r[0],...$({func:o(this,i,k).bind(this),delay:u?0:o(this,i,w).call(this,1),deletable:!0},h),r[1]],s)}freeze(){this.statuses.frozen=!0}flush(e=null){return this.flushCallback=e||this.flushCallback,this.statuses.firing?this:(o(this,i,X).call(this),o(this,i,N).call(this,!1).then(()=>{if(this.queue.getPendingQueueItems().length>0)return this.flush();this.flushCallback(),this.flushCallback=null}),this)}getQueue(){return this.queue}getOptions(){return this.opts}updateOptions(e){return o(this,i,L).call(this,e)}getElement(){return this.element}empty(e={}){return o(this,i,g).call(this,{func:o(this,i,Ce).bind(this)},e)}},i=new WeakSet,Ce=function(){return p(this,null,function*(){if(o(this,i,F).call(this)){this.element.value="";return}c(this,i,T).forEach(o(this,i,B).bind(this))})},N=function(e=!0){return p(this,null,function*(){this.statuses.started=!0,this.statuses.firing=!0;let s=r=>{this.queue.done(r,!e)};try{let r=[...this.queue.getQueue()];for(let u=0;u<r.length;u++){let[a,l]=r[u];if(!l.done){if(!l.deletable||l.deletable&&c(this,i,T).length){let h=yield o(this,i,W).call(this,u,r);Ue({index:u,newIndex:h,queueItems:r,cleanUp:s}),u=h}s(a)}}if(!e)return this.statuses.firing=!1,this;if(this.statuses.completed=!0,this.statuses.firing=!1,yield this.opts.afterComplete(this),!this.opts.loop)throw"";let n=this.opts.loopDelay;o(this,i,J).call(this,()=>p(this,null,function*(){yield o(this,i,Se).call(this,n[0]),o(this,i,N).call(this)}),n[1])}catch(r){}return this.statuses.firing=!1,this})},O=function(e){return p(this,null,function*(){this.cursorPosition=ot(e,this.cursorPosition,c(this,i,T)),tt(this.element,c(this,i,T),this.cursorPosition)})},Se=function(e){return p(this,null,function*(){let s=c(this,i,v);s&&(yield o(this,i,O).call(this,{value:s}));let r=c(this,i,T).map(n=>[Symbol(),{func:o(this,i,k).bind(this),delay:o(this,i,w).call(this,1),deletable:!0,shouldPauseCursor:()=>!0}]);for(let n=0;n<r.length;n++)yield o(this,i,W).call(this,n,r);this.queue.reset(),this.queue.set(0,{delay:e})})},W=function(e,s){return Oe({index:e,queueItems:s,wait:o(this,i,J).bind(this),cursor:this.cursor,cursorOptions:this.opts.cursor})},J=function(e,s,r=!1){return p(this,null,function*(){this.statuses.frozen&&(yield new Promise(n=>{this.unfreeze=()=>{this.statuses.frozen=!1,n()}})),r||(yield this.opts.beforeStep(this)),yield ut(e,s,this.timeouts),r||(yield this.opts.afterStep(this))})},X=function(){return p(this,null,function*(){if(!o(this,i,F).call(this)&&this.cursor&&this.element.appendChild(this.cursor),c(this,i,K)){rt(this.id,this.element),this.cursor.dataset.tiAnimationId=this.id;let{animation:e}=this.opts.cursor,{frames:s,options:r}=e;Pe({frames:s,cursor:this.cursor,options:R({duration:this.opts.cursorSpeed},r)})}})},F=function(){return z(this.element)},g=function(e,s){return this.queue.add(e),o(this,i,Ee).call(this,s),this},Ee=function(e={}){let s=e.delay;s&&this.queue.add({delay:s})},A=function(e={}){return[{func:()=>o(this,i,L).call(this,e)},{func:()=>o(this,i,L).call(this,this.opts)}]},L=function(e){return p(this,null,function*(){this.opts=I(this.opts,e)})},Ie=function(){let e=this.opts.strings.filter(s=>!!s);e.forEach((s,r)=>{if(this.type(s),r+1===e.length)return;let n=this.opts.breakLines?[{func:()=>o(this,i,H).call(this,Q("BR")),typeable:!0}]:$({func:o(this,i,k).bind(this),delay:o(this,i,w).call(this,1)},this.queue.getTypeable().length);o(this,i,G).call(this,n)})},U=new WeakMap,Ne=function(e){let s=this.element.innerHTML;return s?(this.element.innerHTML="",this.opts.startDelete?(this.element.innerHTML=s,Z(this.element),o(this,i,G).call(this,$({func:o(this,i,k).bind(this),delay:o(this,i,w).call(this,1),deletable:!0},c(this,i,T).length)),e):nt(s).concat(e)):e},Ae=function(){if(c(this,i,q))return null;let e=Q("span");return e.className=P,c(this,i,K)?(e.innerHTML=be(this.opts.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)},G=function(e){let s=this.opts.nextStringDelay;this.queue.add([{delay:s[0]},...e,{delay:s[1]}])},H=function(e){Ke(this.element,e)},k=function(){c(this,i,T).length&&(c(this,i,q)?this.element.value=this.element.value.slice(0,-1):o(this,i,B).call(this,c(this,i,T)[this.cursorPosition]))},B=function(e){et(e,this.element)},w=function(e=0){return Be(this.opts)[e]},v=function(){var e;return(e=this.predictedCursorPosition)!=null?e:this.cursorPosition},q=function(){return z(this.element)},K=function(){return!!this.opts.cursor&&!c(this,i,q)},T=function(){return Xe(this.element)},de);const at=xe({name:"TypeIt",props:{options:{type:Object,default:()=>({})}},setup(t,{slots:e,expose:s}){function r(a){throw new TypeError(a)}function n(){return navigator.language}const u=Me(null);return Re(()=>{const a=u.value.querySelector(".type-it");if(!a){const h=n()==="zh-CN"?"请确保有且只有一个具有class属性为 'type-it' 的元素":"Please make sure that there is only one element with a Class attribute with 'type-it'";r(h)}const l=new lt(a,t.options).go();s({typeIt:l})}),()=>{var a,l;return ne("div",{ref:u},[(l=(a=e.default)==null?void 0:a.call(e))!=null?l:ne("span",{class:"type-it"},null)])}}}),ft=at;export{ft as T};
|