Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typeit-react

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeit-react - npm Package Compare versions

Comparing version 0.1.0-rc to 0.1.0-rc10

4

dist/typeit-react.es.min.js

@@ -5,3 +5,3 @@ /**

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v0.1.0-rc
* Version: v0.1.0-rc10
* License: GPL-2.0

@@ -25,2 +25,2 @@ * URL: https://typeitjs.com

and limitations under the License.
***************************************************************************** */var o=function(){return(o=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};var u={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}},c=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},a=function(n,t){return Object.assign({},n,t)},f=function(n){return Array.isArray(n)},s=function(n,t){return n[2]=a(n[2],t)||t,n},l=function(n,t){return f(n[0])?n.map((function(n){return s(n,t)})):s(n,t)},d=function(n,t,e,r){r=r||!1,e=e||{};var i=!f(n),o=n.length;return(n=i?new Array(n).fill(0):n).map((function(n,u){if(i)return t;var c=[t,n,e];return r&&(0===u&&(c=l(c,{isFirst:!0})),u+1===o&&(c=l(c,{isLast:!0}))),c}))};function h(n){this.insert=function(n,e){t.splice(n,0,e)},this.add=function(n,e,r){return n=f(n)?n:[n,null],r=r||!1,e=e||1,f(n[0])||(n=d(e,n)),t=r?n.concat(t):t.concat(n),this},this.delete=function(n){return t.splice(n,1),this},this.reset=function(){return t=c(t).map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return c(t).filter((function(n){return!n.executed}))};var t=[];n&&this.add(n)}var p=function(n){return Array.from(n)},v=function(n){var t=[];return t.concat.apply(t,n)},m=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},y=function(n){return 3===n.nodeType||"BR"===n.tagName},g=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=p(t.childNodes).map((function(t){return y(t)?t:n(t)}));return i=v(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},b=function(n){return"BODY"===n.tagName},S=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:(!t||b(t.parentNode))&&!e,isHTMLElement:e,content:n}};function T(n){var t,e=m(n);return t=g(e).map((function(n){return n.nodeValue?p(n.nodeValue).map((function(t){return S(t,n)})):S(n)})),v(t)}function N(n,t){return(t=void 0===t||t)?T(n):p(n).map((function(n){return S(n)}))}var w=function(n){return document.createElement(n)},L=function(n,t){var e=w("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},x=function(n){return f(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},M=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))},O=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},D=function(n,t){var e=t.querySelectorAll("*");return[t].concat(p(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},E=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(O(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=D(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(c,e))n=c;else if((o=u.cloneNode()).innerText=t.content,!b(u.parentNode)){for(var a=u.parentNode,f=a.cloneNode(),s=D(f,n);!s&&!b(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=D(f,n);n=s||n}}var l=g(n,e,!0)[r-1],d=l?l.parentNode:n;d.insertBefore(o,d.contains(e)?e:null)}},P=function(n){return n&&n.parentNode.removeChild(n)},C=function(n){return!n.firstChild&&!y(n)},H=function(n){return n.some((function(n){return C(n)}))},A=function(n,t,e){var r,i="string"==typeof n,o=!1,u=-1*n;return i&&(u=(r="END"===n.toUpperCase())?-1:1,o=r?t+u>0:t+u<e.length),{isString:i,numberOfSteps:u,canKeepMoving:o}};function I(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function k(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function z(){}function B(n,t){if(!t)return n&&n.then?n.then(z):Promise.resolve()}function j(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function q(n,t,e){if(!n.s){if(e instanceof R){if(!e.s)return void(e.o=q.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(q.bind(null,n,t),q.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var R=function(){function n(){}return n.prototype.then=function(t,e){var r=new n,i=this.s;if(i){var o=1&i?t:e;if(o){try{q(r,1,o(this.v))}catch(n){q(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?q(r,1,t?t(i):i):e?q(r,1,e(i)):q(r,2,i)}catch(n){q(r,2,n)}},r},n}();function V(n,t){return n&&n.then?n.then(t):t(n)}function U(n,t){var e=this,r=this;t=t||{};var i=function(n,t){return cn.add(n,t),e},o=function(n){n=n||{};var t=a({},tn),e=a(t,n);return[[K,e,{force:!0}],[K,t,{force:!0}]]},c=function(){return W?p(J.value):g(J,an,!0)},s=function(n,t){t=t||1;var e=tn.nextStringDelay;cn.insert(n,[D,e.before]),cn.insert(n+t+1,[D,e.after])},l=function(n){an&&(an.classList.toggle("disabled",n),an.classList.toggle("with-delay",!n))},v=k((function(n,t){return Z.push(setTimeout(n,t)),I()})),y=k((function(n){return j((function(){if($)return B(move(-1*$))}),(function(){cn.reset().delete(0).add([D,n.before],!0),c().forEach((function(n){cn.add([Y,null,{isPhantom:!0}],1,!0)}))}))})),b=k((function(){nn.started=!0;var n=cn.getItems();return V(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return V(function(n,t,e){var r,i,o=-1;return function e(u){try{for(;++o<n.length;)if((u=t(o))&&u.then){if(!((c=u)instanceof R&&1&c.s))return void u.then(e,i||(i=q.bind(null,r=new R,2)));u=u.v}r?q(r,1,u):r=u}catch(n){q(r||(r=new R),2,n)}var c}(),r}(n,(function(t){if(nn.frozen||nn.destroyed)throw"";var e,i,o,u,c=n[t],a=c[2],f=[c,cn,r];return a.freezeCursor&&l(!0),e=tn.speed,i=tn.deleteSpeed,o=tn.lifeLike,u=(i=null!==i?i:e/3)/2,X=o?[M(e,e/2),M(i,u)]:[e,i],j((function(){var n;if(null==a?void 0:a.isFirst)return B((n=tn).beforeString.apply(n,f))}),(function(){var n;return I((n=tn).beforeStep.apply(n,f),(function(){return I(c[0].call(r,c[1],a),(function(){return j((function(){if(!a||!a.isPhantom)return j((function(){var n,t;if(null===(n=c[2])||void 0===n?void 0:n.isLast)return B((t=tn).afterString.apply(t,f))}),(function(){var n;return I((n=tn).afterStep.apply(n,f),(function(){c[2].executed=!0}))}))}),(function(){l(!1)}))}))}))}))})),(function(n){return nn.completed=!0,I(tn.afterComplete(r),(function(){if(tn.loop){var n=tn.loopDelay||tn.nextStringDelay;v((function(){return I(y(n),(function(){b()}))}),n.after)}}))}))}),z),(function(n){return r}))})),D=function(n){return new Promise((function(t){v((function(){return t()}),n||tn.nextStringDelay.total)}))},U=function n(t){var e=c(),r=A(t,$,e);return $+=r.numberOfSteps,new Promise((function(t){v(k((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];(n=o?o.parentNode:n).insertBefore(e,o||null)}}(J,c(),an,$),j((function(){if(r.isString&&r.canKeepMoving)return B(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),X[0])}))},F=function(n){return new Promise((function(t){v((function(){return E(J,n,an,$),t()}),X[0])}))},K=k((function(n){tn=a(tn,n)})),Q=k((function(){W?J.value="":c().forEach((function(n){P(n)}))})),Y=function n(t){return t=!0===t,new Promise((function(e){v(k((function(){var r=!1,i=c();return i.length&&(W?J.value=J.value.slice(0,-1):P(i[$])),function(n){for(var t=p(n.querySelectorAll("*")),e=H(t);t.length&&e;){var r=!1;t.forEach((function(n){C(n)&&(P(n),r=!0)})),r&&(t=p(n.querySelectorAll("*"))),e=H(t)}}(J),j((function(){if(t&&i.length-1>0)return I(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),X[1])}))};this.break=function(){return cn.add([F,w("BR")])},this.delete=function(n,t){var e=o(t);return cn.add(e[0]),cn.add([Y,!n,_],n||1),cn.add(e[1]),this},this.destroy=function(n){n=void 0===n||n,Z.forEach((function(n){clearTimeout(n)})),Z=[],n&&P(an),nn.destroyed=!0},this.empty=function(){return i(Q)},this.exec=function(n,t){var e=o(t);return i([e[0],[n,null],e[1]])},this.is=function(n){return nn[n]},this.move=function(n,t){var e=A(n,$,c()),r=o(t);return cn.add(r[0]),cn.add([U,e.isString?n:Math.sign(n),_],Math.abs(n)),cn.add(r[1]),this},this.freeze=function(){nn.frozen=!0},this.unfreeze=function(){nn.frozen=!1,!nn.frozen&&b()},this.options=function(n){return i([K,n])},this.pause=function(n){return i([D,n||null])},this.type=function(n,t){var e=o(t),r=N(n,tn.html),u=[e[0]].concat(d(r,F,_,!0),[e[1]]);return i(u)},this.getQueue=function(){return cn},this.getOptions=function(){return tn},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),cn.reset(),nn)nn[n]=!1;return this},this.go=function(){return nn.started?this:(function(){if(an){var n="[data-typeit-id='".concat(un,"'] .ti-cursor");L("@keyframes blink-".concat(un," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(un," ").concat(tn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),un),J.appendChild(an)}}(),tn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(J,b.bind(this)),this):(b(),this))};var G,J="string"==typeof(G=n)?document.querySelector(G):G,W=O(J),X=[],Z=[],$=0,_={freezeCursor:!0},nn={started:!1,completed:!1,frozen:!1,destroyed:!1},tn=a(u,t);tn=a(tn,{html:!W&&tn.html,nextStringDelay:x(tn.nextStringDelay),loopDelay:x(tn.loopDelay)});var en,rn,on,un=Math.random().toString().substring(2,9),cn=new h([D,tn.startDelay]);J.setAttribute("data-typeit-id",un),L("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),tn.strings=(on=tn.strings,en=f(on)?on:[on],(rn=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(J))?(J.innerHTML="",tn.startDelete?(T(rn).forEach((function(n){E(J,n,an,$)})),cn.add([Y,!0]),s(1),en):[rn.trim()].concat(en)):en);var an=function(){if(W||!tn.cursor)return null;var n=w("span");return n.innerHTML=m(tn.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="position:absolute;display:inline;margin-left:-.025em;".concat(function(n){var t=["font","lineHeight","color"],e=w("SPAN"),r=window.getComputedStyle(n,null);for(var i in r)t.indexOf(i)>-1&&r[i]&&(e.style[i]=r[i]);return e.style.cssText}(J)),n}();tn.strings.length&&function(){var n=tn.strings;n.forEach((function(t,e){var r=N(t,tn.html);cn.add(d(r,F,_,!0));var i=cn.getItems().length;if(e+1!==n.length){if(tn.breakLines){var o=S(w("BR"));return cn.add([F,o,_]),void s(i)}cn.add(d(r,Y,_)),s(i,t.length)}}))}()}var F=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],K=t,Q=e,Y=r,G=i,J=function(t){var e=Y(!0),r=e[0],i=e[1],u=K(null),c=t.options,a=t.element,f=t.children,s=t.getBeforeInit,l=t.getAfterInit,d=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]])}return e}(t,["options","element","children","getBeforeInit","getAfterInit"]),h=a,p=G((function(){return n=h,F.indexOf(n.toLowerCase())>-1;var n}),[h]);return Q((function(){f&&(c.strings=u.current.innerHTML),i(!1)}),[]),Q((function(){if(!r){var n=new U(u.current,o({},c));return(n=s(n)).go(),n=l(n),function(){n.destroy()}}}),[r]),n("div",{style:{opacity:r?0:1}},p?n(h,o({ref:u},d)):n(h,o({ref:u},d),r&&f))};J.defaultProps={element:"span",options:{},getBeforeInit:function(n){return n},getAfterInit:function(n){return n}};export default J;
***************************************************************************** */var o=function(){return(o=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function u(n){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}var c={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}},a=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},f=function(n,t){return Object.assign({},n,t)},s=function(n){return Array.isArray(n)},l=function(n,t){return n[2]=f(n[2],t)||t,n},d=function(n,t){return s(n[0])?n.map((function(n){return l(n,t)})):l(n,t)},p=function(n,t,e,r){r=r||!1,e=e||{};var i=!s(n),o=n.length;return(n=i?new Array(n).fill(0):n).map((function(n,u){if(i)return t;var c=[t,n,e];return r&&(0===u&&(c=d(c,{isFirst:!0})),u+1===o&&(c=d(c,{isLast:!0}))),c}))};function h(n){this.insert=function(n,e){t.splice(n,0,e)},this.add=function(n,r,i){return n=s(n)?n:[n,null],i=i||!1,r=r||1,s(n[0])||(n=p(r,n)),n=a(n).map((function(n){return n[2]=f(n[2],{id:e}),e++,n})),t=i?n.concat(t):t.concat(n),this},this.delete=function(n){return t.splice(n,1),this},this.reset=function(){return t=t.map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return(t=a(t)).filter((function(n){return!n[2].executed}))},this.setMeta=function(n,e){var r=t.findIndex((function(t){return t[2].id===n}));t[r][2]=f(t[r][2],e)};var t=[],e=0;this.add(n)}var v=function(n){return Array.from(n)},y=function(n){var t=[];return t.concat.apply(t,n)},m=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},g=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=v(t.childNodes).map((function(t){return 3===(e=t).nodeType||"BR"===e.tagName?t:n(t);var e}));return i=y(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},b=function(n){return"BODY"===n.tagName},S=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:(!t||b(t.parentNode))&&!e,isHTMLElement:e,content:n}};function N(n){var t,e=m(n);return t=g(e).map((function(n){return n.nodeValue?v(n.nodeValue).map((function(t){return S(t,n)})):S(n)})),y(t)}function T(n,t){return(t=void 0===t||t)?N(n):v(n).map((function(n){return S(n)}))}var L=function(n){return document.createElement(n)},w=function(n,t){var e=L("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},M=function(n){return s(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},x=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))},O=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},E=function(n,t){var e=t.querySelectorAll("*");return[t].concat(v(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},H=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(O(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=E(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(c,e))n=c;else if((o=u.cloneNode()).innerText=t.content,!b(u.parentNode)){for(var a=u.parentNode,f=a.cloneNode(),s=E(f,n);!s&&!b(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=E(f,n);n=s||n}}var l=g(n,e,!0)[r-1],d=l?l.parentNode:n;d.insertBefore(o,d.contains(e)?e:null)}},D=function(n){var t;return null==n||null===(t=n.parentNode)||void 0===t?void 0:t.removeChild(n)},P=function(n,t,e){var r,i="string"==typeof n,o=!1,u=-1*n;return i&&(u=(r="END"===n.toUpperCase())?-1:1,o=r?t+u>0:t+u<e.length),{isString:i,numberOfSteps:u,canKeepMoving:o}};function C(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function A(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function I(){}function k(n,t){if(!t)return n&&n.then?n.then(I):Promise.resolve()}function B(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function j(n,t,e){if(!n.s){if(e instanceof z){if(!e.s)return void(e.o=j.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(j.bind(null,n,t),j.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var z=function(){function n(){}return n.prototype.then=function(t,e){var r=new n,i=this.s;if(i){var o=1&i?t:e;if(o){try{j(r,1,o(this.v))}catch(n){j(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?j(r,1,t?t(i):i):e?j(r,1,e(i)):j(r,2,i)}catch(n){j(r,2,n)}},r},n}();function q(n,t){return n&&n.then?n.then(t):t(n)}function R(n,t){var e=this,r=this;t=t||{};var i=function(n,t,r){return n=s(n[0])?n:[n],cn.add(n,t),function(n){var t=(n=n||{}).delay;t&&cn.add([V,t])}(r),e},o=function(n){return[[K,n="object"==u(n)?n:{},{force:!0}],[K,tn,{force:!0}]]},a=function(){return W?v(J.value):g(J,an,!0)},l=function(n,t){t=t||1;var e=tn.nextStringDelay;cn.insert(n,[V,e.before]),cn.insert(n+t+1,[V,e.after])},d=A((function(){if(an){var n="[data-typeit-id='".concat(un,"'] .ti-cursor");w("@keyframes blink-".concat(un," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(un," ").concat(tn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),un),J.appendChild(an);var t="loaded"===document.fonts.status;return C(t||document.fonts.ready,(function(n){var t=an.getBoundingClientRect().width/2;an.style.margin="0 -".concat(t+2,"px 0 -").concat(t-2,"px")}),t)}})),y=function(n){an&&(an.classList.toggle("disabled",n),an.classList.toggle("with-delay",!n))},b=A((function(n,t){return Z.push(setTimeout(n,t)),C()})),E=A((function(n){return B((function(){if($)return k(U($))}),(function(){cn.reset().delete(0).add([V,n.before],!0),a().forEach((function(n){cn.add([Y,null,{isPhantom:!0}],1,!0)}))}))})),R=A((function(){nn.started=!0;var n=cn.getItems();return q(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return q(function(n,t,e){var r,i,o=-1;return function e(u){try{for(;++o<n.length;)if((u=t(o))&&u.then){if(!((c=u)instanceof z&&1&c.s))return void u.then(e,i||(i=j.bind(null,r=new z,2)));u=u.v}r?j(r,1,u):r=u}catch(n){j(r||(r=new z),2,n)}var c}(),r}(n,(function(t){if(nn.frozen||nn.destroyed)throw"";var e,i,o,u,c=n[t],a=c[2],f=[c,r];return a.freezeCursor&&y(!0),e=tn.speed,i=tn.deleteSpeed,o=tn.lifeLike,u=(i=null!==i?i:e/3)/2,X=o?[x(e,e/2),x(i,u)]:[e,i],B((function(){var n;if(null==a?void 0:a.isFirst)return k((n=tn).beforeString.apply(n,f))}),(function(){var n;return C((n=tn).beforeStep.apply(n,f),(function(){return C(c[0].call(r,c[1],a),(function(){return B((function(){if(!a||!a.isPhantom)return B((function(){var n,t;if(null===(n=c[2])||void 0===n?void 0:n.isLast)return k((t=tn).afterString.apply(t,f))}),(function(){var n;return C((n=tn).afterStep.apply(n,f),(function(){cn.setMeta(a.id,{executed:!0})}))}))}),(function(){y(!1)}))}))}))}))})),(function(n){return nn.completed=!0,C(tn.afterComplete(r),(function(){if(tn.loop){var n=tn.loopDelay;b((function(){return C(E(n),(function(){R()}))}),n.after)}}))}))}),I),(function(n){return r}))})),V=function(n){return new Promise((function(t){b((function(){return t()}),n||0)}))},U=function n(t){var e=a(),r=P(t,$,e);return $+=r.numberOfSteps,new Promise((function(t){b(A((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];(n=o?o.parentNode:n).insertBefore(e,o||null)}}(J,a(),an,$),B((function(){if(r.isString&&r.canKeepMoving)return k(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),X[0])}))},F=function(n){return new Promise((function(t){b((function(){return H(J,n,an,$),t()}),X[0])}))},K=A((function(n){tn=f(tn,n)})),Q=A((function(){W?J.value="":a().forEach((function(n){D(n)}))})),Y=function n(t){return t=!0===t,new Promise((function(e){b(A((function(){var r=!1,i=a();return i.length&&(W?J.value=J.value.slice(0,-1):D(i[$])),v(J.querySelectorAll("*")).forEach((function(n){if(!n.innerHTML){for(var t=n;1===t.parentNode.childNodes.length&&t.parentNode.childNodes[0].isEqualNode(t);)t=t.parentNode;D(t)}})),B((function(){if(t&&i.length-1>0)return C(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),X[1])}))};this.break=function(n){return i([F,S(L("BR"))],1,n)},this.delete=function(n,t){var e=o(t);return i([e[0]].concat([].concat(Array(Math.abs(n)||1)).fill().map((function(){return[Y,!n,_]})),[e[1]]),1,t)},this.empty=function(){return i(Q,1,arguments)},this.exec=function(n,t){var e=o(t);return i([e[0],[n,null],e[1]],1,t)},this.move=function(n,t){var e=P(n,$,a()),r=o(t),u=e.isString?n:Math.sign(n);return i([r[0]].concat([].concat(Array(Math.abs(n)||1)).fill().map((function(){return[U,u,_]})),[r[1]]),1,t)},this.options=function(n){return i([K,n],1,n)},this.pause=function(n,t){return i([V,n],1,t)},this.type=function(n,t){var e=o(t),r=T(n,tn.html),u=[e[0]].concat(p(r,F,_,!0),[e[1]]);return i(u,1,t)},this.is=function(n){return nn[n]},this.destroy=function(n){n=void 0===n||n,Z.forEach((function(n){clearTimeout(n)})),Z=[],n&&D(an),nn.destroyed=!0},this.freeze=function(){nn.frozen=!0},this.unfreeze=function(){nn.frozen=!1,R()},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),cn.reset(),$=0,nn)nn[n]=!1;return W?J.value="":J.innerHTML="",this},this.go=function(){return nn.started?this:(d(),tn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(J,R.bind(this)),this):(R(),this))},this.getQueue=function(){return cn},this.getOptions=function(){return tn},this.getElement=function(){return J};var G,J="string"==typeof(G=n)?document.querySelector(G):G,W=O(J),X=[],Z=[],$=0,_={freezeCursor:!0},nn={started:!1,completed:!1,frozen:!1,destroyed:!1},tn=f(c,t);tn=f(tn,{html:!W&&tn.html,nextStringDelay:M(tn.nextStringDelay),loopDelay:M(tn.loopDelay)});var en,rn,on,un=Math.random().toString().substring(2,9),cn=new h([V,tn.startDelay]);J.setAttribute("data-typeit-id",un),w("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}[data-typeit-id]"),tn.strings=(on=tn.strings,en=s(on)?on:[on],(rn=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(J))?(J.innerHTML="",tn.startDelete?(N(rn).forEach((function(n){H(J,n,an,$)})),cn.add([Y,!0]),l(1),en):[rn.trim()].concat(en)):en);var an=function(){if(W||!tn.cursor)return null;var n=L("span");return n.innerHTML=m(tn.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="display:inline;".concat(function(n){var t,e=["font","lineHeight","color"],r=L("SPAN"),i=(t=n,window.getComputedStyle(t,null));for(var o in i)e.indexOf(o)>-1&&i[o]&&(r.style[o]=i[o]);return r.style.cssText}(J)),n}();tn.strings.length&&function(){var n=tn.strings;n.forEach((function(t,e){var r=T(t,tn.html);cn.add(p(r,F,_,!0));var i=cn.getItems().length;if(e+1!==n.length){if(tn.breakLines){var o=S(L("BR"));return cn.add([F,o,_]),void l(i)}cn.add(p(r,Y,_)),l(i,t.length)}}))}()}var V=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],U=t,F=e,K=r,Q=i,Y=function(t){var e=K(!0),r=e[0],i=e[1],u=U(null),c=t.options,a=t.element,f=t.children,s=t.getBeforeInit,l=t.getAfterInit,d=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]])}return e}(t,["options","element","children","getBeforeInit","getAfterInit"]),p=a,h=Q((function(){return n=p,V.indexOf(n.toLowerCase())>-1;var n}),[p]);return F((function(){f&&(c.strings=u.current.innerHTML),i(!1)}),[]),F((function(){if(!r){var n=new R(u.current,o({},c));return(n=s(n)).go(),n=l(n),function(){n.destroy()}}}),[r]),n("div",{style:{opacity:r?0:1}},h?n(p,o({ref:u},d)):n(p,o({ref:u},d),r&&f))};Y.defaultProps={element:"span",options:{},getBeforeInit:function(n){return n},getAfterInit:function(n){return n}};export default Y;

@@ -5,3 +5,3 @@ /**

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v0.1.0-rc
* Version: v0.1.0-rc10
* License: GPL-2.0

@@ -25,2 +25,2 @@ * URL: https://typeitjs.com

and limitations under the License.
***************************************************************************** */var t=function(){return(t=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};var e={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}},r=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},i=function(n,t){return Object.assign({},n,t)},o=function(n){return Array.isArray(n)},u=function(n,t){return n[2]=i(n[2],t)||t,n},c=function(n,t){return o(n[0])?n.map((function(n){return u(n,t)})):u(n,t)},a=function(n,t,e,r){r=r||!1,e=e||{};var i=!o(n),u=n.length;return(n=i?new Array(n).fill(0):n).map((function(n,o){if(i)return t;var a=[t,n,e];return r&&(0===o&&(a=c(a,{isFirst:!0})),o+1===u&&(a=c(a,{isLast:!0}))),a}))};function f(n){this.insert=function(n,e){t.splice(n,0,e)},this.add=function(n,e,r){return n=o(n)?n:[n,null],r=r||!1,e=e||1,o(n[0])||(n=a(e,n)),t=r?n.concat(t):t.concat(n),this},this.delete=function(n){return t.splice(n,1),this},this.reset=function(){return t=r(t).map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return r(t).filter((function(n){return!n.executed}))};var t=[];n&&this.add(n)}var s=function(n){return Array.from(n)},l=function(n){var t=[];return t.concat.apply(t,n)},d=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},p=function(n){return 3===n.nodeType||"BR"===n.tagName},h=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=s(t.childNodes).map((function(t){return p(t)?t:n(t)}));return i=l(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},v=function(n){return"BODY"===n.tagName},m=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:(!t||v(t.parentNode))&&!e,isHTMLElement:e,content:n}};function y(n){var t,e=d(n);return t=h(e).map((function(n){return n.nodeValue?s(n.nodeValue).map((function(t){return m(t,n)})):m(n)})),l(t)}function g(n,t){return(t=void 0===t||t)?y(n):s(n).map((function(n){return m(n)}))}var b=function(n){return document.createElement(n)},S=function(n,t){var e=b("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},T=function(n){return o(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},N=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))},w=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},x=function(n,t){var e=t.querySelectorAll("*");return[t].concat(s(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},L=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(w(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=x(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(c,e))n=c;else if((o=u.cloneNode()).innerText=t.content,!v(u.parentNode)){for(var a=u.parentNode,f=a.cloneNode(),s=x(f,n);!s&&!v(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=x(f,n);n=s||n}}var l=h(n,e,!0)[r-1],d=l?l.parentNode:n;d.insertBefore(o,d.contains(e)?e:null)}},M=function(n){return n&&n.parentNode.removeChild(n)},O=function(n){return!n.firstChild&&!p(n)},E=function(n){return n.some((function(n){return O(n)}))},D=function(n,t,e){var r,i="string"==typeof n,o=!1,u=-1*n;return i&&(u=(r="END"===n.toUpperCase())?-1:1,o=r?t+u>0:t+u<e.length),{isString:i,numberOfSteps:u,canKeepMoving:o}};function P(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function C(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function H(){}function A(n,t){if(!t)return n&&n.then?n.then(H):Promise.resolve()}function I(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function k(n,t,e){if(!n.s){if(e instanceof j){if(!e.s)return void(e.o=k.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(k.bind(null,n,t),k.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var j=function(){function n(){}return n.prototype.then=function(t,e){var r=new n,i=this.s;if(i){var o=1&i?t:e;if(o){try{k(r,1,o(this.v))}catch(n){k(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?k(r,1,t?t(i):i):e?k(r,1,e(i)):k(r,2,i)}catch(n){k(r,2,n)}},r},n}();function z(n,t){return n&&n.then?n.then(t):t(n)}function B(n,t){var r=this,u=this;t=t||{};var c=function(n,t){return cn.add(n,t),r},l=function(n){n=n||{};var t=i({},tn),e=i(t,n);return[[K,e,{force:!0}],[K,t,{force:!0}]]},p=function(){return W?s(J.value):h(J,an,!0)},v=function(n,t){t=t||1;var e=tn.nextStringDelay;cn.insert(n,[V,e.before]),cn.insert(n+t+1,[V,e.after])},x=function(n){an&&(an.classList.toggle("disabled",n),an.classList.toggle("with-delay",!n))},B=C((function(n,t){return Z.push(setTimeout(n,t)),P()})),q=C((function(n){return I((function(){if($)return A(move(-1*$))}),(function(){cn.reset().delete(0).add([V,n.before],!0),p().forEach((function(n){cn.add([Y,null,{isPhantom:!0}],1,!0)}))}))})),R=C((function(){nn.started=!0;var n=cn.getItems();return z(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return z(function(n,t,e){var r,i,o=-1;return function e(u){try{for(;++o<n.length;)if((u=t(o))&&u.then){if(!((c=u)instanceof j&&1&c.s))return void u.then(e,i||(i=k.bind(null,r=new j,2)));u=u.v}r?k(r,1,u):r=u}catch(n){k(r||(r=new j),2,n)}var c}(),r}(n,(function(t){if(nn.frozen||nn.destroyed)throw"";var e,r,i,o,c=n[t],a=c[2],f=[c,cn,u];return a.freezeCursor&&x(!0),e=tn.speed,r=tn.deleteSpeed,i=tn.lifeLike,o=(r=null!==r?r:e/3)/2,X=i?[N(e,e/2),N(r,o)]:[e,r],I((function(){var n;if(null==a?void 0:a.isFirst)return A((n=tn).beforeString.apply(n,f))}),(function(){var n;return P((n=tn).beforeStep.apply(n,f),(function(){return P(c[0].call(u,c[1],a),(function(){return I((function(){if(!a||!a.isPhantom)return I((function(){var n,t;if(null===(n=c[2])||void 0===n?void 0:n.isLast)return A((t=tn).afterString.apply(t,f))}),(function(){var n;return P((n=tn).afterStep.apply(n,f),(function(){c[2].executed=!0}))}))}),(function(){x(!1)}))}))}))}))})),(function(n){return nn.completed=!0,P(tn.afterComplete(u),(function(){if(tn.loop){var n=tn.loopDelay||tn.nextStringDelay;B((function(){return P(q(n),(function(){R()}))}),n.after)}}))}))}),H),(function(n){return u}))})),V=function(n){return new Promise((function(t){B((function(){return t()}),n||tn.nextStringDelay.total)}))},U=function n(t){var e=p(),r=D(t,$,e);return $+=r.numberOfSteps,new Promise((function(t){B(C((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];(n=o?o.parentNode:n).insertBefore(e,o||null)}}(J,p(),an,$),I((function(){if(r.isString&&r.canKeepMoving)return A(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),X[0])}))},F=function(n){return new Promise((function(t){B((function(){return L(J,n,an,$),t()}),X[0])}))},K=C((function(n){tn=i(tn,n)})),Q=C((function(){W?J.value="":p().forEach((function(n){M(n)}))})),Y=function n(t){return t=!0===t,new Promise((function(e){B(C((function(){var r=!1,i=p();return i.length&&(W?J.value=J.value.slice(0,-1):M(i[$])),function(n){for(var t=s(n.querySelectorAll("*")),e=E(t);t.length&&e;){var r=!1;t.forEach((function(n){O(n)&&(M(n),r=!0)})),r&&(t=s(n.querySelectorAll("*"))),e=E(t)}}(J),I((function(){if(t&&i.length-1>0)return P(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),X[1])}))};this.break=function(){return cn.add([F,b("BR")])},this.delete=function(n,t){var e=l(t);return cn.add(e[0]),cn.add([Y,!n,_],n||1),cn.add(e[1]),this},this.destroy=function(n){n=void 0===n||n,Z.forEach((function(n){clearTimeout(n)})),Z=[],n&&M(an),nn.destroyed=!0},this.empty=function(){return c(Q)},this.exec=function(n,t){var e=l(t);return c([e[0],[n,null],e[1]])},this.is=function(n){return nn[n]},this.move=function(n,t){var e=D(n,$,p()),r=l(t);return cn.add(r[0]),cn.add([U,e.isString?n:Math.sign(n),_],Math.abs(n)),cn.add(r[1]),this},this.freeze=function(){nn.frozen=!0},this.unfreeze=function(){nn.frozen=!1,!nn.frozen&&R()},this.options=function(n){return c([K,n])},this.pause=function(n){return c([V,n||null])},this.type=function(n,t){var e=l(t),r=g(n,tn.html),i=[e[0]].concat(a(r,F,_,!0),[e[1]]);return c(i)},this.getQueue=function(){return cn},this.getOptions=function(){return tn},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),cn.reset(),nn)nn[n]=!1;return this},this.go=function(){return nn.started?this:(function(){if(an){var n="[data-typeit-id='".concat(un,"'] .ti-cursor");S("@keyframes blink-".concat(un," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(un," ").concat(tn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),un),J.appendChild(an)}}(),tn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(J,R.bind(this)),this):(R(),this))};var G,J="string"==typeof(G=n)?document.querySelector(G):G,W=w(J),X=[],Z=[],$=0,_={freezeCursor:!0},nn={started:!1,completed:!1,frozen:!1,destroyed:!1},tn=i(e,t);tn=i(tn,{html:!W&&tn.html,nextStringDelay:T(tn.nextStringDelay),loopDelay:T(tn.loopDelay)});var en,rn,on,un=Math.random().toString().substring(2,9),cn=new f([V,tn.startDelay]);J.setAttribute("data-typeit-id",un),S("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),tn.strings=(on=tn.strings,en=o(on)?on:[on],(rn=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(J))?(J.innerHTML="",tn.startDelete?(y(rn).forEach((function(n){L(J,n,an,$)})),cn.add([Y,!0]),v(1),en):[rn.trim()].concat(en)):en);var an=function(){if(W||!tn.cursor)return null;var n=b("span");return n.innerHTML=d(tn.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="position:absolute;display:inline;margin-left:-.025em;".concat(function(n){var t=["font","lineHeight","color"],e=b("SPAN"),r=window.getComputedStyle(n,null);for(var i in r)t.indexOf(i)>-1&&r[i]&&(e.style[i]=r[i]);return e.style.cssText}(J)),n}();tn.strings.length&&function(){var n=tn.strings;n.forEach((function(t,e){var r=g(t,tn.html);cn.add(a(r,F,_,!0));var i=cn.getItems().length;if(e+1!==n.length){if(tn.breakLines){var o=m(b("BR"));return cn.add([F,o,_]),void v(i)}cn.add(a(r,Y,_)),v(i,t.length)}}))}()}var q=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],R=n.useRef,V=n.useEffect,U=n.useState,F=n.useMemo,K=function(e){var r=U(!0),i=r[0],o=r[1],u=R(null),c=e.options,a=e.element,f=e.children,s=e.getBeforeInit,l=e.getAfterInit,d=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]])}return e}(e,["options","element","children","getBeforeInit","getAfterInit"]),p=a,h=F((function(){return n=p,q.indexOf(n.toLowerCase())>-1;var n}),[p]);return V((function(){f&&(c.strings=u.current.innerHTML),o(!1)}),[]),V((function(){if(!i){var n=new B(u.current,t({},c));return(n=s(n)).go(),n=l(n),function(){n.destroy()}}}),[i]),n.createElement("div",{style:{opacity:i?0:1}},h?n.createElement(p,t({ref:u},d)):n.createElement(p,t({ref:u},d),i&&f))};return K.defaultProps={element:"span",options:{},getBeforeInit:function(n){return n},getAfterInit:function(n){return n}},K}));
***************************************************************************** */var t=function(){return(t=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}var r={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}},i=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},o=function(n,t){return Object.assign({},n,t)},u=function(n){return Array.isArray(n)},c=function(n,t){return n[2]=o(n[2],t)||t,n},a=function(n,t){return u(n[0])?n.map((function(n){return c(n,t)})):c(n,t)},f=function(n,t,e,r){r=r||!1,e=e||{};var i=!u(n),o=n.length;return(n=i?new Array(n).fill(0):n).map((function(n,u){if(i)return t;var c=[t,n,e];return r&&(0===u&&(c=a(c,{isFirst:!0})),u+1===o&&(c=a(c,{isLast:!0}))),c}))};function s(n){this.insert=function(n,e){t.splice(n,0,e)},this.add=function(n,r,c){return n=u(n)?n:[n,null],c=c||!1,r=r||1,u(n[0])||(n=f(r,n)),n=i(n).map((function(n){return n[2]=o(n[2],{id:e}),e++,n})),t=c?n.concat(t):t.concat(n),this},this.delete=function(n){return t.splice(n,1),this},this.reset=function(){return t=t.map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return(t=i(t)).filter((function(n){return!n[2].executed}))},this.setMeta=function(n,e){var r=t.findIndex((function(t){return t[2].id===n}));t[r][2]=o(t[r][2],e)};var t=[],e=0;this.add(n)}var l=function(n){return Array.from(n)},d=function(n){var t=[];return t.concat.apply(t,n)},p=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},h=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=l(t.childNodes).map((function(t){return 3===(e=t).nodeType||"BR"===e.tagName?t:n(t);var e}));return i=d(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},v=function(n){return"BODY"===n.tagName},y=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:(!t||v(t.parentNode))&&!e,isHTMLElement:e,content:n}};function m(n){var t,e=p(n);return t=h(e).map((function(n){return n.nodeValue?l(n.nodeValue).map((function(t){return y(t,n)})):y(n)})),d(t)}function g(n,t){return(t=void 0===t||t)?m(n):l(n).map((function(n){return y(n)}))}var b=function(n){return document.createElement(n)},S=function(n,t){var e=b("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},N=function(n){return u(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},T=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))},L=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},w=function(n,t){var e=t.querySelectorAll("*");return[t].concat(l(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},x=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(L(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=w(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(c,e))n=c;else if((o=u.cloneNode()).innerText=t.content,!v(u.parentNode)){for(var a=u.parentNode,f=a.cloneNode(),s=w(f,n);!s&&!v(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=w(f,n);n=s||n}}var l=h(n,e,!0)[r-1],d=l?l.parentNode:n;d.insertBefore(o,d.contains(e)?e:null)}},M=function(n){var t;return null==n||null===(t=n.parentNode)||void 0===t?void 0:t.removeChild(n)},E=function(n,t,e){var r,i="string"==typeof n,o=!1,u=-1*n;return i&&(u=(r="END"===n.toUpperCase())?-1:1,o=r?t+u>0:t+u<e.length),{isString:i,numberOfSteps:u,canKeepMoving:o}};function O(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function H(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function D(){}function P(n,t){if(!t)return n&&n.then?n.then(D):Promise.resolve()}function C(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function A(n,t,e){if(!n.s){if(e instanceof I){if(!e.s)return void(e.o=A.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(A.bind(null,n,t),A.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var I=function(){function n(){}return n.prototype.then=function(t,e){var r=new n,i=this.s;if(i){var o=1&i?t:e;if(o){try{A(r,1,o(this.v))}catch(n){A(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?A(r,1,t?t(i):i):e?A(r,1,e(i)):A(r,2,i)}catch(n){A(r,2,n)}},r},n}();function k(n,t){return n&&n.then?n.then(t):t(n)}function j(n,t){var i=this,c=this;t=t||{};var a=function(n,t,e){return n=u(n[0])?n:[n],cn.add(n,t),function(n){var t=(n=n||{}).delay;t&&cn.add([V,t])}(e),i},d=function(n){return[[K,n="object"==e(n)?n:{},{force:!0}],[K,tn,{force:!0}]]},v=function(){return W?l(J.value):h(J,an,!0)},w=function(n,t){t=t||1;var e=tn.nextStringDelay;cn.insert(n,[V,e.before]),cn.insert(n+t+1,[V,e.after])},j=H((function(){if(an){var n="[data-typeit-id='".concat(un,"'] .ti-cursor");S("@keyframes blink-".concat(un," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(un," ").concat(tn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),un),J.appendChild(an);var t="loaded"===document.fonts.status;return O(t||document.fonts.ready,(function(n){var t=an.getBoundingClientRect().width/2;an.style.margin="0 -".concat(t+2,"px 0 -").concat(t-2,"px")}),t)}})),B=function(n){an&&(an.classList.toggle("disabled",n),an.classList.toggle("with-delay",!n))},z=H((function(n,t){return Z.push(setTimeout(n,t)),O()})),q=H((function(n){return C((function(){if($)return P(U($))}),(function(){cn.reset().delete(0).add([V,n.before],!0),v().forEach((function(n){cn.add([Y,null,{isPhantom:!0}],1,!0)}))}))})),R=H((function(){nn.started=!0;var n=cn.getItems();return k(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return k(function(n,t,e){var r,i,o=-1;return function e(u){try{for(;++o<n.length;)if((u=t(o))&&u.then){if(!((c=u)instanceof I&&1&c.s))return void u.then(e,i||(i=A.bind(null,r=new I,2)));u=u.v}r?A(r,1,u):r=u}catch(n){A(r||(r=new I),2,n)}var c}(),r}(n,(function(t){if(nn.frozen||nn.destroyed)throw"";var e,r,i,o,u=n[t],a=u[2],f=[u,c];return a.freezeCursor&&B(!0),e=tn.speed,r=tn.deleteSpeed,i=tn.lifeLike,o=(r=null!==r?r:e/3)/2,X=i?[T(e,e/2),T(r,o)]:[e,r],C((function(){var n;if(null==a?void 0:a.isFirst)return P((n=tn).beforeString.apply(n,f))}),(function(){var n;return O((n=tn).beforeStep.apply(n,f),(function(){return O(u[0].call(c,u[1],a),(function(){return C((function(){if(!a||!a.isPhantom)return C((function(){var n,t;if(null===(n=u[2])||void 0===n?void 0:n.isLast)return P((t=tn).afterString.apply(t,f))}),(function(){var n;return O((n=tn).afterStep.apply(n,f),(function(){cn.setMeta(a.id,{executed:!0})}))}))}),(function(){B(!1)}))}))}))}))})),(function(n){return nn.completed=!0,O(tn.afterComplete(c),(function(){if(tn.loop){var n=tn.loopDelay;z((function(){return O(q(n),(function(){R()}))}),n.after)}}))}))}),D),(function(n){return c}))})),V=function(n){return new Promise((function(t){z((function(){return t()}),n||0)}))},U=function n(t){var e=v(),r=E(t,$,e);return $+=r.numberOfSteps,new Promise((function(t){z(H((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];(n=o?o.parentNode:n).insertBefore(e,o||null)}}(J,v(),an,$),C((function(){if(r.isString&&r.canKeepMoving)return P(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),X[0])}))},F=function(n){return new Promise((function(t){z((function(){return x(J,n,an,$),t()}),X[0])}))},K=H((function(n){tn=o(tn,n)})),Q=H((function(){W?J.value="":v().forEach((function(n){M(n)}))})),Y=function n(t){return t=!0===t,new Promise((function(e){z(H((function(){var r=!1,i=v();return i.length&&(W?J.value=J.value.slice(0,-1):M(i[$])),l(J.querySelectorAll("*")).forEach((function(n){if(!n.innerHTML){for(var t=n;1===t.parentNode.childNodes.length&&t.parentNode.childNodes[0].isEqualNode(t);)t=t.parentNode;M(t)}})),C((function(){if(t&&i.length-1>0)return O(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),X[1])}))};this.break=function(n){return a([F,y(b("BR"))],1,n)},this.delete=function(n,t){var e=d(t);return a([e[0]].concat([].concat(Array(Math.abs(n)||1)).fill().map((function(){return[Y,!n,_]})),[e[1]]),1,t)},this.empty=function(){return a(Q,1,arguments)},this.exec=function(n,t){var e=d(t);return a([e[0],[n,null],e[1]],1,t)},this.move=function(n,t){var e=E(n,$,v()),r=d(t),i=e.isString?n:Math.sign(n);return a([r[0]].concat([].concat(Array(Math.abs(n)||1)).fill().map((function(){return[U,i,_]})),[r[1]]),1,t)},this.options=function(n){return a([K,n],1,n)},this.pause=function(n,t){return a([V,n],1,t)},this.type=function(n,t){var e=d(t),r=g(n,tn.html),i=[e[0]].concat(f(r,F,_,!0),[e[1]]);return a(i,1,t)},this.is=function(n){return nn[n]},this.destroy=function(n){n=void 0===n||n,Z.forEach((function(n){clearTimeout(n)})),Z=[],n&&M(an),nn.destroyed=!0},this.freeze=function(){nn.frozen=!0},this.unfreeze=function(){nn.frozen=!1,R()},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),cn.reset(),$=0,nn)nn[n]=!1;return W?J.value="":J.innerHTML="",this},this.go=function(){return nn.started?this:(j(),tn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(J,R.bind(this)),this):(R(),this))},this.getQueue=function(){return cn},this.getOptions=function(){return tn},this.getElement=function(){return J};var G,J="string"==typeof(G=n)?document.querySelector(G):G,W=L(J),X=[],Z=[],$=0,_={freezeCursor:!0},nn={started:!1,completed:!1,frozen:!1,destroyed:!1},tn=o(r,t);tn=o(tn,{html:!W&&tn.html,nextStringDelay:N(tn.nextStringDelay),loopDelay:N(tn.loopDelay)});var en,rn,on,un=Math.random().toString().substring(2,9),cn=new s([V,tn.startDelay]);J.setAttribute("data-typeit-id",un),S("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}[data-typeit-id]"),tn.strings=(on=tn.strings,en=u(on)?on:[on],(rn=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(J))?(J.innerHTML="",tn.startDelete?(m(rn).forEach((function(n){x(J,n,an,$)})),cn.add([Y,!0]),w(1),en):[rn.trim()].concat(en)):en);var an=function(){if(W||!tn.cursor)return null;var n=b("span");return n.innerHTML=p(tn.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="display:inline;".concat(function(n){var t,e=["font","lineHeight","color"],r=b("SPAN"),i=(t=n,window.getComputedStyle(t,null));for(var o in i)e.indexOf(o)>-1&&i[o]&&(r.style[o]=i[o]);return r.style.cssText}(J)),n}();tn.strings.length&&function(){var n=tn.strings;n.forEach((function(t,e){var r=g(t,tn.html);cn.add(f(r,F,_,!0));var i=cn.getItems().length;if(e+1!==n.length){if(tn.breakLines){var o=y(b("BR"));return cn.add([F,o,_]),void w(i)}cn.add(f(r,Y,_)),w(i,t.length)}}))}()}var B=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],z=n.useRef,q=n.useEffect,R=n.useState,V=n.useMemo,U=function(e){var r=R(!0),i=r[0],o=r[1],u=z(null),c=e.options,a=e.element,f=e.children,s=e.getBeforeInit,l=e.getAfterInit,d=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]])}return e}(e,["options","element","children","getBeforeInit","getAfterInit"]),p=a,h=V((function(){return n=p,B.indexOf(n.toLowerCase())>-1;var n}),[p]);return q((function(){f&&(c.strings=u.current.innerHTML),o(!1)}),[]),q((function(){if(!i){var n=new j(u.current,t({},c));return(n=s(n)).go(),n=l(n),function(){n.destroy()}}}),[i]),n.createElement("div",{style:{opacity:i?0:1}},h?n.createElement(p,t({ref:u},d)):n.createElement(p,t({ref:u},d),i&&f))};return U.defaultProps={element:"span",options:{},getBeforeInit:function(n){return n},getAfterInit:function(n){return n}},U}));
{
"name": "typeit-react",
"version": "0.1.0-rc",
"version": "0.1.0-rc10",
"description": "React component for the most versatile JavaScript animated typing utility on the planet.",

@@ -40,3 +40,3 @@ "homepage": "https://typeitjs.com",

"@types/react": "^16.9.19",
"typeit": "^7.0.0-rc2"
"typeit": "^7.0.0-rc13"
},

@@ -43,0 +43,0 @@ "peerDependencies": {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc