typeit-react
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -366,8 +366,5 @@ var __defProp = Object.defineProperty; | ||
}; | ||
const _elementIsInput = () => { | ||
return isInput(_element); | ||
}; | ||
const _getPace = (index) => { | ||
return calculatePace(_opts)[index]; | ||
}; | ||
const _elementIsInput = () => isInput(_element); | ||
const _getPace = (index) => calculatePace(_opts)[index]; | ||
const _getAllChars = () => getAllChars(_element); | ||
const _getActionPace = (instant, paceIndex = 0) => { | ||
@@ -385,5 +382,2 @@ return instant ? _getPace(paceIndex) : 0; | ||
}; | ||
const _getAllChars = () => { | ||
return getAllChars(_element); | ||
}; | ||
const _generateTemporaryOptionQueueItems = (newOptions = {}) => { | ||
@@ -414,6 +408,3 @@ return [ | ||
!_elementIsInput() && _element.appendChild(_cursor); | ||
if (!_shouldRenderCursor) { | ||
return; | ||
} | ||
setCursorStyles(_id, _opts, _element); | ||
_shouldRenderCursor && setCursorStyles(_id, _opts, _element); | ||
}; | ||
@@ -672,11 +663,6 @@ const _disableCursorBlink = (shouldDisable) => { | ||
}; | ||
this.getQueue = function() { | ||
return _queue; | ||
}; | ||
this.getOptions = function() { | ||
return _opts; | ||
}; | ||
this.getElement = function() { | ||
return _element; | ||
}; | ||
this.getQueue = () => _queue; | ||
this.getOptions = () => _opts; | ||
this.updateOptions = (options2) => _options(options2); | ||
this.getElement = () => _element; | ||
let _element = selectorToElement(element); | ||
@@ -683,0 +669,0 @@ let _timeouts = []; |
@@ -1,1 +0,1 @@ | ||
var Ge=Object.defineProperty;var V=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var _e=(p,y,g)=>y in p?Ge(p,y,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[y]=g,we=(p,y)=>{for(var g in y||(y={}))ve.call(y,g)&&_e(p,g,y[g]);if(V)for(var g of V(y))Te.call(y,g)&&_e(p,g,y[g]);return p};var Ne=(p,y)=>{var g={};for(var w in p)ve.call(p,w)&&y.indexOf(w)<0&&(g[w]=p[w]);if(p!=null&&V)for(var w of V(p))y.indexOf(w)<0&&Te.call(p,w)&&(g[w]=p[w]);return g};(function(p,y){typeof exports=="object"&&typeof module!="undefined"?module.exports=y(require("react")):typeof define=="function"&&define.amd?define(["react"],y):(p=typeof globalThis!="undefined"?globalThis:p||self,p.TypeIt=y(p.React))})(this,function(p){"use strict";function y(e){if(e&&e.__esModule)return e;var n={__proto__:null,[Symbol.toStringTag]:"Module"};return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}}),n.default=e,Object.freeze(n)}var g=y(p);const w=[null,null,{}];var Ce=e=>e.map(n=>w.map((r,s)=>n[s]?n[s]:r)),B=(e,n)=>Object.assign({},e,n);const Ie=function(e){const n=function(l){return c=c.concat(Ce(l)),this},r=function(l,h){c[l]=h},s=function(){c=c.map(l=>(l[2].executed=!1,l))},i=function(){return c.filter(l=>!l[2].executed)},b=function(l,h){c[l][2]=B(c[l][2],h)};let c=[];return n(e),{add:n,set:r,reset:s,getItems:i,setMeta:b}};var H=e=>Array.from(e),re=e=>{let n=document.implementation.createHTMLDocument();return n.body.innerHTML=e,n.body},Ee=e=>e.nodeType===3||e.tagName==="BR";const P=(e,n=null,r=!1)=>{let s=H(e.childNodes).flatMap(i=>Ee(i)?i:P(i));return n&&(s=s.filter(i=>!n.contains(i))),r?s.reverse():s},Me=e=>P(e).flatMap(r=>r.nodeValue?H(r.nodeValue).map(s=>O(s,r)):O(r)),O=(e,n=null)=>({node:n,content:e});function oe(e){let n=re(e);return Me(n)}function se(e,n=!0){return n?oe(e):H(e).map(r=>O(r))}var Q=e=>document.createElement(e),K=e=>document.createTextNode(e),ie=(e,n="")=>{let r=Q("style");r.id=n,r.appendChild(K(e)),document.head.appendChild(r)},le=e=>Array.isArray(e),Ae=e=>le(e)?e:[e];const ue=e=>Number.isInteger(e),$=(e,n=document,r=!1)=>n[`querySelector${r?"All":""}`](e),ae="data-typeit-id",j="ti-cursor",W="START",Le="END",Pe={started:!1,completed:!1,frozen:!1,destroyed:!1},$e={breakLines:!0,cursor:!0,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:()=>{}},De=(e,n,r=W)=>{let s=new RegExp(Le,"i").test(r),i=$(`.${j}`,n),b=e?$(e,n):n,c=P(b,i,!0),l=c[0],h=c[c.length-1],N=s&&!e?0:P(n,i,!0).findIndex(S=>S.isSameNode(s?l:h));return s&&N--,N+1};var ce=({el:e,move:n,cursorPos:r,to:s})=>ue(n)?n*-1:De(n,e,s)-r,de=e=>(le(e)||(e=[e/2,e/2]),e),fe=(e,n)=>Math.abs(Math.random()*(e+n-(e-n))+(e-n));let pe=e=>e/2;function Re(e){let{speed:n,deleteSpeed:r,lifeLike:s}=e;return r=r!==null?r:n/3,s?[fe(n,pe(n)),fe(r,pe(r))]:[n,r]}var ke=e=>(e.forEach(n=>clearTimeout(n)),[]),xe=()=>Math.random().toString().substring(2,9),Y=e=>"value"in e;const Be=e=>Y(e)?H(e.value):P(e,$(`.${j}`,e),!0);var He=(e,n)=>{new IntersectionObserver((s,i)=>{s.forEach(b=>{b.isIntersecting&&(n(),i.unobserve(e))})},{threshold:1}).observe(e)};const D=e=>typeof e=="function"?e():e;var G=e=>e.tagName==="BODY";const J=(e,n)=>{let r=H($("*",n,!0));return[n].concat(r.reverse()).find(s=>s.cloneNode().isEqualNode(e.cloneNode()))},Oe=(e,n)=>{let r=e.nextSibling;return!r||r.isEqualNode(n)},he=(e,n,r,s)=>{let i=n.content instanceof HTMLElement,b=n.node,c=b==null?void 0:b.parentNode,l=i?n.content:K(n.content);if(Y(e)){e.value=`${e.value}${n.content}`;return}if(!i&&c&&!G(c)){let N=J(c,e);if(N&&Oe(N,r))e=N;else{l=c.cloneNode(),l.appendChild(K(n.content));let S=c.parentNode,M=S.cloneNode();if(!G(S)){let A=J(M,e);for(;!A&&!G(S);){let R=M;R.innerHTML=l.outerHTML,l=R,S=S.parentNode,M=S.cloneNode(),A=J(M,e)}e=A||e}}}let h=P(e,r,!0)[s-1],T=h?h.parentNode:e;T.insertBefore(l,T.contains(r)?r:null)},ze=(e,n,r)=>Math.min(Math.max(n+e,0),r.length);var q=e=>e&&e.remove(),Qe=(e,n)=>{$("*",e,!0).forEach(r=>{if(!r.innerHTML&&r.tagName!=="BR"&&!r.isSameNode(n)){let s=r;for(;s.parentElement.childNodes.length===1;)s=s.parentElement;q(s)}})},je=(e,n,r,s)=>{let i=n[s-1];e=(i==null?void 0:i.parentNode)||e,e.insertBefore(r,i||null)};function qe(e){return typeof e=="string"?$(e):e}const Ue=async(e,n,r)=>new Promise(s=>{const i=async()=>{await e(),s()};r.push(setTimeout(i,n))}),Fe={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"},Ve=(e,n,r)=>{let i=`${`[${ae}='${e}']`} .${j}`,b=getComputedStyle(r),c=Object.entries(Fe).reduce((l,[h,T])=>`${l} ${h}: var(--ti-cursor-${h}, ${T||b[h]});`,"");ie(`@keyframes blink-${e} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${i} { display: inline; letter-spacing: -1em; ${c} animation: blink-${e} ${n.cursorSpeed/1e3}s infinite; } ${i}.with-delay { animation-delay: 500ms; } ${i}.disabled { animation: none; }`,e)};function Ke(e,n={}){const r=async(t,o,a=!1)=>{I.frozen&&await new Promise(d=>{this.unfreeze=()=>{I.frozen=!1,d()}}),a||await u.beforeStep(this),await Ue(t,o,te),a||await u.afterStep(this)},s=()=>Y(m),i=t=>Re(u)[t],b=(t,o=0)=>t?i(o):0,c=(t={})=>{let o=t.delay;o&&E.add([[k,o]])},l=(t,o)=>(E.add(t),c(o),this),h=()=>Be(m),T=(t={})=>[[ee,t],[ee,u]],N=t=>{let o=u.nextStringDelay;E.add([[k,o[0]],...t,[k,o[1]]])},S=()=>{if(s())return;let t=Q("span");return t.className=j,ne?(t.innerHTML=re(u.cursorChar).innerHTML,t):(t.style.visibility="hidden",t)},M=async()=>{!s()&&m.appendChild(L),!!ne&&Ve(Se,u,m)},A=t=>{ne&&(L.classList.toggle("disabled",t),L.classList.toggle("with-delay",!t))},R=()=>{let t=u.strings.filter(o=>!!o);t.forEach((o,a)=>{let d=se(o,u.html);if(E.add([[F,{chars:d},x]]),a+1===t.length)return;const f=u.breakLines?[[F,{chars:[O(Q("BR"))],silent:!0},x]]:[[z,{num:d.length},x]];N(f)})},Z=async t=>{C&&await be({value:C}),E.reset(),E.set(0,[k,t,{}]),await z({num:null})},U=t=>{let o=m.innerHTML;return o?(m.innerHTML="",u.startDelete?(oe(o).forEach(d=>{he(m,d,L,C)}),N([[z,{num:null}]]),t):o.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(t)):t},_=async()=>{I.started=!0;let t=E.getItems();try{for(let a=0;a<t.length;a++){let d=t[a],f=d[2];f.freezeCursor&&A(!0),await d[0].call(this,d[1],f),E.setMeta(a,{executed:!0}),A(!1)}if(I.completed=!0,await u.afterComplete(this),!u.loop)throw"";let o=u.loopDelay;r(async()=>{await Z(o[0]),_()},o[1])}catch{}return this},k=(t=0)=>r(()=>{},t),be=async({value:t,to:o=W,instant:a=!1})=>{let d=ce({el:m,move:t,cursorPos:C,to:o}),f=()=>{C=ze(d<0?-1:1,C,h()),je(m,h(),L,C)};await r(async()=>{for(let v=0;v<Math.abs(d);v++)a?f():await r(f,i(0))},b(a))},F=({chars:t,instant:o,silent:a})=>r(async()=>{const d=f=>he(m,f,L,C);a||await u.beforeString(t,this);for(let f=0;f<t.length;f++)o?d(t[f]):await r(()=>{d(t[f])},i(0));a||await u.afterString(t,this)},b(o),!0),ee=async t=>{u=B(u,t)},Ye=async()=>{if(s()){m.value="";return}h().forEach(t=>{q(t)})},z=async({num:t=null,instant:o=!1,to:a=W})=>{await r(async()=>{let d=ue(t)?t:ce({el:m,move:t,cursorPos:C,to:a});const f=()=>{let v=h();!v.length||(s()?m.value=m.value.slice(0,-1):(q(v[C]),Qe(m,L)))};for(let v=0;v<d;v++)o?f():await r(f,i(1))},b(o,1)),t===null&&h().length-1>0&&await z({num:null})};this.break=function(t){const o=O(Q("BR"));return l([[F,{chars:[o],silent:!0}]],t)},this.delete=function(t=null,o={}){t=D(t);let a=T(o),d=t,{instant:f,to:v}=o;return l([a[0],[z,{num:d,instant:f,to:v},x],a[1]],o)},this.empty=function(t={}){return l([[Ye]],t)},this.exec=function(t,o){let a=T(o);return l([a[0],[t,null],a[1]],o)},this.move=function(t,o={}){t=D(t);let a=T(o),{instant:d,to:f}=o,v={value:t===null?"":t,to:f,instant:d};return l([a[0],[be,v,x],a[1]],o)},this.options=function(t){return t=D(t),l([[ee,t]],t)},this.pause=function(t,o={}){return l([[k,D(t)]],o)},this.type=function(t,o={}){t=D(t);let a=T(o),d=se(t,u.html),{instant:f}=o,v=[a[0],[F,{chars:d,instant:f},x],a[1]];return l(v,o)},this.is=function(t){return I[t]},this.destroy=function(t=!0){te=ke(te),D(t)&&q(L),I.destroyed=!0},this.freeze=function(){I.frozen=!0},this.unfreeze=function(){},this.reset=function(){!this.is("destroyed")&&this.destroy(),E.reset(),C=0;for(let t in I)I[t]=!1;return m[s()?"value":"innerHTML"]="",this},this.go=function(){return I.started?this:(M(),u.waitUntilVisible?(He(m,_.bind(this)),this):(_(),this))},this.getQueue=function(){return E},this.getOptions=function(){return u},this.getElement=function(){return m};let m=qe(e),te=[],C=0,x={freezeCursor:!0},I=B({},Pe),u=B($e,n);u=B(u,{html:!s()&&u.html,nextStringDelay:de(u.nextStringDelay),loopDelay:de(u.loopDelay)});let Se=xe(),E=Ie([[k,u.startDelay]]);m.dataset.typeitId=Se,ie(`[${ae}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`);let ne=u.cursor&&!s(),L=S();u.strings=U(Ae(u.strings)),u.strings.length&&R()}const{useRef:ye,useEffect:X,useState:me}=g,We={as:"span",options:{},getBeforeInit:e=>e,getAfterInit:e=>e},ge=e=>{const n=ye(null),r=ye(null),U=e,{options:s,as:i,children:b,getBeforeInit:c,getAfterInit:l}=U,h=Ne(U,["options","as","children","getBeforeInit","getAfterInit"]),[T,N]=me(!0),[S,M]=me(null),A=i;function R(){const _=Object.assign({},s);b&&n.current&&(_.strings=n.current.innerHTML),M(_)}function Z(){r.current=new Ke(n.current,S),r.current=c(r.current),r.current.go(),r.current=l(r.current)}return X(()=>{R(),N(!1)},[s]),X(()=>{var _;!S||((_=r.current)==null?void 0:_.updateOptions(S))||Z()},[S]),X(()=>()=>{var _;return(_=r.current)==null?void 0:_.destroy()},[]),g.createElement(A,we({ref:n,children:T?b:null,style:{opacity:T?0:1}},h))};return ge.defaultProps=We,ge}); | ||
var Ge=Object.defineProperty;var K=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var _e=(h,y,b)=>y in h?Ge(h,y,{enumerable:!0,configurable:!0,writable:!0,value:b}):h[y]=b,we=(h,y)=>{for(var b in y||(y={}))ve.call(y,b)&&_e(h,b,y[b]);if(K)for(var b of K(y))Te.call(y,b)&&_e(h,b,y[b]);return h};var Ne=(h,y)=>{var b={};for(var w in h)ve.call(h,w)&&y.indexOf(w)<0&&(b[w]=h[w]);if(h!=null&&K)for(var w of K(h))y.indexOf(w)<0&&Te.call(h,w)&&(b[w]=h[w]);return b};(function(h,y){typeof exports=="object"&&typeof module!="undefined"?module.exports=y(require("react")):typeof define=="function"&&define.amd?define(["react"],y):(h=typeof globalThis!="undefined"?globalThis:h||self,h.TypeIt=y(h.React))})(this,function(h){"use strict";function y(e){if(e&&e.__esModule)return e;var n={__proto__:null,[Symbol.toStringTag]:"Module"};return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}}),n.default=e,Object.freeze(n)}var b=y(h);const w=[null,null,{}];var Ce=e=>e.map(n=>w.map((r,s)=>n[s]?n[s]:r)),B=(e,n)=>Object.assign({},e,n);const Ie=function(e){const n=function(c){return a=a.concat(Ce(c)),this},r=function(c,f){a[c]=f},s=function(){a=a.map(c=>(c[2].executed=!1,c))},i=function(){return a.filter(c=>!c[2].executed)},m=function(c,f){a[c][2]=B(a[c][2],f)};let a=[];return n(e),{add:n,set:r,reset:s,getItems:i,setMeta:m}};var O=e=>Array.from(e),re=e=>{let n=document.implementation.createHTMLDocument();return n.body.innerHTML=e,n.body},Ee=e=>e.nodeType===3||e.tagName==="BR";const P=(e,n=null,r=!1)=>{let s=O(e.childNodes).flatMap(i=>Ee(i)?i:P(i));return n&&(s=s.filter(i=>!n.contains(i))),r?s.reverse():s},Me=e=>P(e).flatMap(r=>r.nodeValue?O(r.nodeValue).map(s=>H(s,r)):H(r)),H=(e,n=null)=>({node:n,content:e});function oe(e){let n=re(e);return Me(n)}function se(e,n=!0){return n?oe(e):O(e).map(r=>H(r))}var Q=e=>document.createElement(e),W=e=>document.createTextNode(e),ie=(e,n="")=>{let r=Q("style");r.id=n,r.appendChild(W(e)),document.head.appendChild(r)},le=e=>Array.isArray(e),Ae=e=>le(e)?e:[e];const ue=e=>Number.isInteger(e),$=(e,n=document,r=!1)=>n[`querySelector${r?"All":""}`](e),ae="data-typeit-id",j="ti-cursor",Y="START",Le="END",Pe={started:!1,completed:!1,frozen:!1,destroyed:!1},$e={breakLines:!0,cursor:!0,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:()=>{}},De=(e,n,r=Y)=>{let s=new RegExp(Le,"i").test(r),i=$(`.${j}`,n),m=e?$(e,n):n,a=P(m,i,!0),c=a[0],f=a[a.length-1],N=s&&!e?0:P(n,i,!0).findIndex(S=>S.isSameNode(s?c:f));return s&&N--,N+1};var ce=({el:e,move:n,cursorPos:r,to:s})=>ue(n)?n*-1:De(n,e,s)-r,de=e=>(le(e)||(e=[e/2,e/2]),e),fe=(e,n)=>Math.abs(Math.random()*(e+n-(e-n))+(e-n));let pe=e=>e/2;function Re(e){let{speed:n,deleteSpeed:r,lifeLike:s}=e;return r=r!==null?r:n/3,s?[fe(n,pe(n)),fe(r,pe(r))]:[n,r]}var ke=e=>(e.forEach(n=>clearTimeout(n)),[]),xe=()=>Math.random().toString().substring(2,9),G=e=>"value"in e;const Be=e=>G(e)?O(e.value):P(e,$(`.${j}`,e),!0);var Oe=(e,n)=>{new IntersectionObserver((s,i)=>{s.forEach(m=>{m.isIntersecting&&(n(),i.unobserve(e))})},{threshold:1}).observe(e)};const D=e=>typeof e=="function"?e():e;var J=e=>e.tagName==="BODY";const X=(e,n)=>{let r=O($("*",n,!0));return[n].concat(r.reverse()).find(s=>s.cloneNode().isEqualNode(e.cloneNode()))},He=(e,n)=>{let r=e.nextSibling;return!r||r.isEqualNode(n)},he=(e,n,r,s)=>{let i=n.content instanceof HTMLElement,m=n.node,a=m==null?void 0:m.parentNode,c=i?n.content:W(n.content);if(G(e)){e.value=`${e.value}${n.content}`;return}if(!i&&a&&!J(a)){let N=X(a,e);if(N&&He(N,r))e=N;else{c=a.cloneNode(),c.appendChild(W(n.content));let S=a.parentNode,M=S.cloneNode();if(!J(S)){let A=X(M,e);for(;!A&&!J(S);){let R=M;R.innerHTML=c.outerHTML,c=R,S=S.parentNode,M=S.cloneNode(),A=X(M,e)}e=A||e}}}let f=P(e,r,!0)[s-1],T=f?f.parentNode:e;T.insertBefore(c,T.contains(r)?r:null)},ze=(e,n,r)=>Math.min(Math.max(n+e,0),r.length);var q=e=>e&&e.remove(),Qe=(e,n)=>{$("*",e,!0).forEach(r=>{if(!r.innerHTML&&r.tagName!=="BR"&&!r.isSameNode(n)){let s=r;for(;s.parentElement.childNodes.length===1;)s=s.parentElement;q(s)}})},je=(e,n,r,s)=>{let i=n[s-1];e=(i==null?void 0:i.parentNode)||e,e.insertBefore(r,i||null)};function qe(e){return typeof e=="string"?$(e):e}const Ue=async(e,n,r)=>new Promise(s=>{const i=async()=>{await e(),s()};r.push(setTimeout(i,n))}),Fe={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"},Ve=(e,n,r)=>{let i=`${`[${ae}='${e}']`} .${j}`,m=getComputedStyle(r),a=Object.entries(Fe).reduce((c,[f,T])=>`${c} ${f}: var(--ti-cursor-${f}, ${T||m[f]});`,"");ie(`@keyframes blink-${e} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${i} { display: inline; letter-spacing: -1em; ${a} animation: blink-${e} ${n.cursorSpeed/1e3}s infinite; } ${i}.with-delay { animation-delay: 500ms; } ${i}.disabled { animation: none; }`,e)};function Ke(e,n={}){const r=async(t,o,u=!1)=>{I.frozen&&await new Promise(d=>{this.unfreeze=()=>{I.frozen=!1,d()}}),u||await l.beforeStep(this),await Ue(t,o,te),u||await l.afterStep(this)},s=()=>G(g),i=t=>Re(l)[t],m=()=>Be(g),a=(t,o=0)=>t?i(o):0,c=(t={})=>{let o=t.delay;o&&E.add([[k,o]])},f=(t,o)=>(E.add(t),c(o),this),T=(t={})=>[[V,t],[V,l]],N=t=>{let o=l.nextStringDelay;E.add([[k,o[0]],...t,[k,o[1]]])},S=()=>{if(s())return;let t=Q("span");return t.className=j,ne?(t.innerHTML=re(l.cursorChar).innerHTML,t):(t.style.visibility="hidden",t)},M=async()=>{!s()&&g.appendChild(L),ne&&Ve(Se,l,g)},A=t=>{ne&&(L.classList.toggle("disabled",t),L.classList.toggle("with-delay",!t))},R=()=>{let t=l.strings.filter(o=>!!o);t.forEach((o,u)=>{let d=se(o,l.html);if(E.add([[F,{chars:d},x]]),u+1===t.length)return;const p=l.breakLines?[[F,{chars:[H(Q("BR"))],silent:!0},x]]:[[z,{num:d.length},x]];N(p)})},ee=async t=>{C&&await be({value:C}),E.reset(),E.set(0,[k,t,{}]),await z({num:null})},U=t=>{let o=g.innerHTML;return o?(g.innerHTML="",l.startDelete?(oe(o).forEach(d=>{he(g,d,L,C)}),N([[z,{num:null}]]),t):o.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(t)):t},_=async()=>{I.started=!0;let t=E.getItems();try{for(let u=0;u<t.length;u++){let d=t[u],p=d[2];p.freezeCursor&&A(!0),await d[0].call(this,d[1],p),E.setMeta(u,{executed:!0}),A(!1)}if(I.completed=!0,await l.afterComplete(this),!l.loop)throw"";let o=l.loopDelay;r(async()=>{await ee(o[0]),_()},o[1])}catch{}return this},k=(t=0)=>r(()=>{},t),be=async({value:t,to:o=Y,instant:u=!1})=>{let d=ce({el:g,move:t,cursorPos:C,to:o}),p=()=>{C=ze(d<0?-1:1,C,m()),je(g,m(),L,C)};await r(async()=>{for(let v=0;v<Math.abs(d);v++)u?p():await r(p,i(0))},a(u))},F=({chars:t,instant:o,silent:u})=>r(async()=>{const d=p=>he(g,p,L,C);u||await l.beforeString(t,this);for(let p=0;p<t.length;p++)o?d(t[p]):await r(()=>{d(t[p])},i(0));u||await l.afterString(t,this)},a(o),!0),V=async t=>{l=B(l,t)},Ye=async()=>{if(s()){g.value="";return}m().forEach(t=>{q(t)})},z=async({num:t=null,instant:o=!1,to:u=Y})=>{await r(async()=>{let d=ue(t)?t:ce({el:g,move:t,cursorPos:C,to:u});const p=()=>{let v=m();!v.length||(s()?g.value=g.value.slice(0,-1):(q(v[C]),Qe(g,L)))};for(let v=0;v<d;v++)o?p():await r(p,i(1))},a(o,1)),t===null&&m().length-1>0&&await z({num:null})};this.break=function(t){const o=H(Q("BR"));return f([[F,{chars:[o],silent:!0}]],t)},this.delete=function(t=null,o={}){t=D(t);let u=T(o),d=t,{instant:p,to:v}=o;return f([u[0],[z,{num:d,instant:p,to:v},x],u[1]],o)},this.empty=function(t={}){return f([[Ye]],t)},this.exec=function(t,o){let u=T(o);return f([u[0],[t,null],u[1]],o)},this.move=function(t,o={}){t=D(t);let u=T(o),{instant:d,to:p}=o,v={value:t===null?"":t,to:p,instant:d};return f([u[0],[be,v,x],u[1]],o)},this.options=function(t){return t=D(t),f([[V,t]],t)},this.pause=function(t,o={}){return f([[k,D(t)]],o)},this.type=function(t,o={}){t=D(t);let u=T(o),d=se(t,l.html),{instant:p}=o,v=[u[0],[F,{chars:d,instant:p},x],u[1]];return f(v,o)},this.is=function(t){return I[t]},this.destroy=function(t=!0){te=ke(te),D(t)&&q(L),I.destroyed=!0},this.freeze=function(){I.frozen=!0},this.unfreeze=function(){},this.reset=function(){!this.is("destroyed")&&this.destroy(),E.reset(),C=0;for(let t in I)I[t]=!1;return g[s()?"value":"innerHTML"]="",this},this.go=function(){return I.started?this:(M(),l.waitUntilVisible?(Oe(g,_.bind(this)),this):(_(),this))},this.getQueue=()=>E,this.getOptions=()=>l,this.updateOptions=t=>V(t),this.getElement=()=>g;let g=qe(e),te=[],C=0,x={freezeCursor:!0},I=B({},Pe),l=B($e,n);l=B(l,{html:!s()&&l.html,nextStringDelay:de(l.nextStringDelay),loopDelay:de(l.loopDelay)});let Se=xe(),E=Ie([[k,l.startDelay]]);g.dataset.typeitId=Se,ie(`[${ae}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`);let ne=l.cursor&&!s(),L=S();l.strings=U(Ae(l.strings)),l.strings.length&&R()}const{useRef:ye,useEffect:Z,useState:me}=b,We={as:"span",options:{},getBeforeInit:e=>e,getAfterInit:e=>e},ge=e=>{const n=ye(null),r=ye(null),U=e,{options:s,as:i,children:m,getBeforeInit:a,getAfterInit:c}=U,f=Ne(U,["options","as","children","getBeforeInit","getAfterInit"]),[T,N]=me(!0),[S,M]=me(null),A=i;function R(){const _=Object.assign({},s);m&&n.current&&(_.strings=n.current.innerHTML),M(_)}function ee(){r.current=new Ke(n.current,S),r.current=a(r.current),r.current.go(),r.current=c(r.current)}return Z(()=>{R(),N(!1)},[s]),Z(()=>{var _;!S||((_=r.current)==null?void 0:_.updateOptions(S))||ee()},[S]),Z(()=>()=>{var _;return(_=r.current)==null?void 0:_.destroy()},[]),b.createElement(A,we({ref:n,children:T?m:null,style:{opacity:T?0:1}},f))};return ge.defaultProps=We,ge}); |
{ | ||
"name": "typeit-react", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "React component for the most versatile JavaScript animated typing utility on the planet.", | ||
@@ -50,3 +50,3 @@ "homepage": "https://typeitjs.com", | ||
}, | ||
"gitHead": "6a5a794a1f6b6f8da850d8bfbc5daaa9c76b58a1" | ||
"gitHead": "14d6bd988556c59ad0b88006fdaa576169dfc5d2" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78621
864