react-typist
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -1575,2 +1575,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
Backspace.componentName = 'Backspace'; | ||
Backspace.propTypes = { | ||
@@ -1612,2 +1614,4 @@ count: _propTypes2.default.number, | ||
Delay.componentName = 'Delay'; | ||
Delay.propTypes = { | ||
@@ -1645,10 +1649,2 @@ ms: _propTypes2.default.number.isRequired | ||
var _Backspace = __webpack_require__(13); | ||
var _Backspace2 = _interopRequireDefault(_Backspace); | ||
var _Delay = __webpack_require__(14); | ||
var _Delay2 = _interopRequireDefault(_Delay); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -1698,7 +1694,7 @@ | ||
function isBackspaceElement(element) { | ||
return element && element.type === _Backspace2.default; | ||
return element && element.type && element.type.componentName === 'Backspace'; | ||
} | ||
function isDelayElement(element) { | ||
return element && element.type === _Delay2.default; | ||
return element && element.type && element.type.componentName === 'Delay'; | ||
} | ||
@@ -1759,4 +1755,6 @@ | ||
var props = exclude(element.props, ['children']); | ||
var getMilliseconds = new Date().getUTCMilliseconds(); | ||
var randomStamp = getMilliseconds + Math.random() + Math.random(); | ||
// eslint-disable-next-line | ||
props.key = 'Typist-element-' + tag + '-' + (Date.now() + Math.random() + Math.random()); | ||
props.key = 'Typist-element-' + tag + '-' + randomStamp; | ||
return _react2.default.createElement.apply(_react2.default, [tag, props].concat(_toConsumableArray(children))); | ||
@@ -1763,0 +1761,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Typist=t(require("react")):e.Typist=t(e.react)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(1),f=o(c),p=n(2),d=o(p),y=n(7),h=o(y),v=n(9),m=o(v),b=n(10),T=o(b),g=n(11),_=r(g),D=["🔙","⏰"],x=function(e){function t(e){i(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={textLines:[],isDone:!1},n.onTypingDone=function(){n.mounted&&(n.setState({isDone:!0}),n.props.onTypingDone())},n.delayGenerator=function(e,t,r,o){var i=n.props.avgTypingDelay,u=n.props.stdTypingDelay;return n.props.delayGenerator(i,u,{line:e,lineIdx:t,character:r,charIdx:o,defDelayGenerator:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;return _.gaussianRnd(e,t)}})},n.typeLine=function(e,t){if(!n.mounted)return Promise.resolve();var r=e,o=n.props.onLineTyped;return _.isBackspaceElement(e)?(e.props.delay>0&&(n.introducedDelay=e.props.delay),r=String("🔙").repeat(e.props.count)):_.isDelayElement(e)&&(n.introducedDelay=e.props.ms,r="⏰"),new Promise(function(e,i){n.setState({textLines:n.state.textLines.concat([""])},function(){_.eachPromise(r,n.typeCharacter,r,t).then(function(){return o(r,t)}).then(e).catch(i)})})},n.typeCharacter=function(e,t,r,o){if(!n.mounted)return Promise.resolve();var i=n.props.onCharacterTyped;return new Promise(function(u){var a=n.state.textLines.slice();_.sleep(n.introducedDelay).then(function(){n.introducedDelay=null;var s="🔙"===e,l="⏰"===e;if(l)return void u();if(s&&o>0){for(var c=o-1,f=a[c],p=c;p>=0&&(!(f.length>0)||D.includes(f[0]));p--)c=p,f=a[c];a[c]=f.substr(0,f.length-1)}else a[o]+=e;n.setState({textLines:a},function(){var a=n.delayGenerator(r,o,e,t);i(e,t),setTimeout(u,a)})})})},n.mounted=!1,n.linesToType=[],n.introducedDelay=null,e.children&&(n.linesToType=_.extractTextFromElement(e.children)),n}return a(t,e),l(t,[{key:"componentDidMount",value:function(){this.mounted=!0;var e=this.props,t=e.children,n=e.startDelay;t?n>0&&"undefined"!=typeof window?setTimeout(this.typeAllLines.bind(this),n):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(e,t){if(t.textLines.length!==this.state.textLines.length)return!0;for(var n=0;n<t.textLines.length;n++){var r=this.state.textLines[n],o=t.textLines[n];if(r!==o)return!0}return this.state.isDone!==t.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.linesToType;return _.eachPromise(t,this.typeLine).then(function(){return e.onTypingDone()})}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cursor,r=this.state.isDone,o=_.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return f.default.createElement("div",{className:"Typist "+t},o,f.default.createElement(h.default,s({isDone:r},n)))}}]),t}(c.Component);x.propTypes={children:d.default.node,className:d.default.string,avgTypingDelay:d.default.number,stdTypingDelay:d.default.number,startDelay:d.default.number,cursor:d.default.object,onCharacterTyped:d.default.func,onLineTyped:d.default.func,onTypingDone:d.default.func,delayGenerator:d.default.func},x.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:_.gaussianRnd},t.default=x,x.Backspace=m.default,x.Delay=T.default},function(t,n){t.exports=e},function(e,t,n){e.exports=n(3)()},function(e,t,n){"use strict";var r=n(4),o=n(5),i=n(6);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,i,u,a,s){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,u,a,s],f=0;l=new Error(t.replace(/%s/g,function(){return c[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(1),l=r(s),c=n(2),f=r(c);n(8);var p=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._isReRenderingCursor=!1,n.state={shouldRender:n.props.show},n}return u(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){var t=this,n=!this.props.isDone&&e.isDone&&this.props.hideWhenDone;n&&setTimeout(function(){return t.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var e=this.props,t=e.show,n=e.isDone;t&&(n||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var e=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){e.setState({shouldRender:!0},function(){e._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var e=this.props.blink?" Cursor--blinking":"";return l.default.createElement("span",{className:"Cursor"+e},this.props.element)}return null}}]),t}(s.Component);p.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},t.default=p},function(e,t){},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.propTypes={count:a.default.number,delay:a.default.number},s.defaultProps={count:1,delay:0},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.propTypes={ms:a.default.number.isRequired},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){for(var n=12,r=0,o=0;o<n;o++)r+=Math.random();return r-=n/2,Math.round(r*t)+e}function u(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];var i=function(e,n,o){return e.then(function(){return t.apply(void 0,[n,o].concat(r))})};return Array.from(e).reduce(i,Promise.resolve())}function a(e,t){var n={};for(var r in e)t.indexOf(r)===-1&&(n[r]=e[r]);return n}function s(e){return e&&e.type===b.default}function l(e){return e&&e.type===g.default}function c(e){for(var t=e?[e]:[],n=[];t.length>0;){var r=t.pop();if(v.default.isValidElement(r))s(r)||l(r)?n.unshift(r):v.default.Children.forEach(r.props.children,function(e){t.push(e)});else if(Array.isArray(r)){var o=!0,i=!1,u=void 0;try{for(var a,c=r[Symbol.iterator]();!(o=(a=c.next()).done);o=!0){var f=a.value;t.push(f)}}catch(e){i=!0,u=e}finally{try{!o&&c.return&&c.return()}finally{if(i)throw u}}}else n.unshift(r)}return n}function f(e,t){var n=e.type,r=a(e.props,["children"]);return r.key="Typist-element-"+n+"-"+(Date.now()+Math.random()+Math.random()),v.default.createElement.apply(v.default,[n,r].concat(o(t)))}function p(e,t,n){if(n>=t.length)return[null,n];var r=n,o=function(e){var n=p(e,t,r),o=y(n,2),i=o[0],u=o[1];return r=u,i},i=v.default.isValidElement(e)&&!(s(e)||l(e));if(i){var u=v.default.Children.map(e.props.children,o)||[];return[f(e,u),r]}if(Array.isArray(e)){var a=e.map(o);return[a,r]}return[t[r],r+1]}function d(e){var t=e.element,n=e.textLines;if(t)return p(t,n,0)[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0;var y=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.gaussianRnd=i,t.eachPromise=u,t.exclude=a,t.isBackspaceElement=s,t.isDelayElement=l,t.extractTextFromElement=c,t.cloneElement=f,t.cloneElementWithSpecifiedText=d;var h=n(1),v=r(h),m=n(9),b=r(m),T=n(10),g=r(T);t.sleep=function(e){return new Promise(function(t){return null!=e?setTimeout(t,e):t()})}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Typist=t(require("react")):e.Typist=t(e.react)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(1),f=o(c),p=n(2),d=o(p),y=n(7),h=o(y),m=n(9),v=o(m),b=n(10),T=o(b),g=n(11),_=r(g),D=["🔙","⏰"],x=function(e){function t(e){i(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={textLines:[],isDone:!1},n.onTypingDone=function(){n.mounted&&(n.setState({isDone:!0}),n.props.onTypingDone())},n.delayGenerator=function(e,t,r,o){var i=n.props.avgTypingDelay,u=n.props.stdTypingDelay;return n.props.delayGenerator(i,u,{line:e,lineIdx:t,character:r,charIdx:o,defDelayGenerator:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;return _.gaussianRnd(e,t)}})},n.typeLine=function(e,t){if(!n.mounted)return Promise.resolve();var r=e,o=n.props.onLineTyped;return _.isBackspaceElement(e)?(e.props.delay>0&&(n.introducedDelay=e.props.delay),r=String("🔙").repeat(e.props.count)):_.isDelayElement(e)&&(n.introducedDelay=e.props.ms,r="⏰"),new Promise(function(e,i){n.setState({textLines:n.state.textLines.concat([""])},function(){_.eachPromise(r,n.typeCharacter,r,t).then(function(){return o(r,t)}).then(e).catch(i)})})},n.typeCharacter=function(e,t,r,o){if(!n.mounted)return Promise.resolve();var i=n.props.onCharacterTyped;return new Promise(function(u){var a=n.state.textLines.slice();_.sleep(n.introducedDelay).then(function(){n.introducedDelay=null;var s="🔙"===e,l="⏰"===e;if(l)return void u();if(s&&o>0){for(var c=o-1,f=a[c],p=c;p>=0&&(!(f.length>0)||D.includes(f[0]));p--)c=p,f=a[c];a[c]=f.substr(0,f.length-1)}else a[o]+=e;n.setState({textLines:a},function(){var a=n.delayGenerator(r,o,e,t);i(e,t),setTimeout(u,a)})})})},n.mounted=!1,n.linesToType=[],n.introducedDelay=null,e.children&&(n.linesToType=_.extractTextFromElement(e.children)),n}return a(t,e),l(t,[{key:"componentDidMount",value:function(){this.mounted=!0;var e=this.props,t=e.children,n=e.startDelay;t?n>0&&"undefined"!=typeof window?setTimeout(this.typeAllLines.bind(this),n):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(e,t){if(t.textLines.length!==this.state.textLines.length)return!0;for(var n=0;n<t.textLines.length;n++){var r=this.state.textLines[n],o=t.textLines[n];if(r!==o)return!0}return this.state.isDone!==t.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.linesToType;return _.eachPromise(t,this.typeLine).then(function(){return e.onTypingDone()})}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cursor,r=this.state.isDone,o=_.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return f.default.createElement("div",{className:"Typist "+t},o,f.default.createElement(h.default,s({isDone:r},n)))}}]),t}(c.Component);x.propTypes={children:d.default.node,className:d.default.string,avgTypingDelay:d.default.number,stdTypingDelay:d.default.number,startDelay:d.default.number,cursor:d.default.object,onCharacterTyped:d.default.func,onLineTyped:d.default.func,onTypingDone:d.default.func,delayGenerator:d.default.func},x.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:_.gaussianRnd},t.default=x,x.Backspace=v.default,x.Delay=T.default},function(t,n){t.exports=e},function(e,t,n){e.exports=n(3)()},function(e,t,n){"use strict";var r=n(4),o=n(5),i=n(6);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,i,u,a,s){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,u,a,s],f=0;l=new Error(t.replace(/%s/g,function(){return c[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(1),l=r(s),c=n(2),f=r(c);n(8);var p=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._isReRenderingCursor=!1,n.state={shouldRender:n.props.show},n}return u(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){var t=this,n=!this.props.isDone&&e.isDone&&this.props.hideWhenDone;n&&setTimeout(function(){return t.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var e=this.props,t=e.show,n=e.isDone;t&&(n||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var e=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){e.setState({shouldRender:!0},function(){e._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var e=this.props.blink?" Cursor--blinking":"";return l.default.createElement("span",{className:"Cursor"+e},this.props.element)}return null}}]),t}(s.Component);p.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},t.default=p},function(e,t){},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.componentName="Backspace",s.propTypes={count:a.default.number,delay:a.default.number},s.defaultProps={count:1,delay:0},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.componentName="Delay",s.propTypes={ms:a.default.number.isRequired},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){for(var n=12,r=0,o=0;o<n;o++)r+=Math.random();return r-=n/2,Math.round(r*t)+e}function u(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];var i=function(e,n,o){return e.then(function(){return t.apply(void 0,[n,o].concat(r))})};return Array.from(e).reduce(i,Promise.resolve())}function a(e,t){var n={};for(var r in e)t.indexOf(r)===-1&&(n[r]=e[r]);return n}function s(e){return e&&e.type&&"Backspace"===e.type.componentName}function l(e){return e&&e.type&&"Delay"===e.type.componentName}function c(e){for(var t=e?[e]:[],n=[];t.length>0;){var r=t.pop();if(m.default.isValidElement(r))s(r)||l(r)?n.unshift(r):m.default.Children.forEach(r.props.children,function(e){t.push(e)});else if(Array.isArray(r)){var o=!0,i=!1,u=void 0;try{for(var a,c=r[Symbol.iterator]();!(o=(a=c.next()).done);o=!0){var f=a.value;t.push(f)}}catch(e){i=!0,u=e}finally{try{!o&&c.return&&c.return()}finally{if(i)throw u}}}else n.unshift(r)}return n}function f(e,t){var n=e.type,r=a(e.props,["children"]),i=(new Date).getUTCMilliseconds(),u=i+Math.random()+Math.random();return r.key="Typist-element-"+n+"-"+u,m.default.createElement.apply(m.default,[n,r].concat(o(t)))}function p(e,t,n){if(n>=t.length)return[null,n];var r=n,o=function(e){var n=p(e,t,r),o=y(n,2),i=o[0],u=o[1];return r=u,i},i=m.default.isValidElement(e)&&!(s(e)||l(e));if(i){var u=m.default.Children.map(e.props.children,o)||[];return[f(e,u),r]}if(Array.isArray(e)){var a=e.map(o);return[a,r]}return[t[r],r+1]}function d(e){var t=e.element,n=e.textLines;if(t)return p(t,n,0)[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0;var y=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.gaussianRnd=i,t.eachPromise=u,t.exclude=a,t.isBackspaceElement=s,t.isDelayElement=l,t.extractTextFromElement=c,t.cloneElement=f,t.cloneElementWithSpecifiedText=d;var h=n(1),m=r(h);t.sleep=function(e){return new Promise(function(t){return null!=e?setTimeout(t,e):t()})}}])}); |
@@ -1371,2 +1371,4 @@ module.exports = | ||
Backspace.componentName = 'Backspace'; | ||
Backspace.propTypes = { | ||
@@ -1408,2 +1410,4 @@ count: _propTypes2.default.number, | ||
Delay.componentName = 'Delay'; | ||
Delay.propTypes = { | ||
@@ -1441,10 +1445,2 @@ ms: _propTypes2.default.number.isRequired | ||
var _Backspace = __webpack_require__(12); | ||
var _Backspace2 = _interopRequireDefault(_Backspace); | ||
var _Delay = __webpack_require__(13); | ||
var _Delay2 = _interopRequireDefault(_Delay); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -1494,7 +1490,7 @@ | ||
function isBackspaceElement(element) { | ||
return element && element.type === _Backspace2.default; | ||
return element && element.type && element.type.componentName === 'Backspace'; | ||
} | ||
function isDelayElement(element) { | ||
return element && element.type === _Delay2.default; | ||
return element && element.type && element.type.componentName === 'Delay'; | ||
} | ||
@@ -1555,4 +1551,6 @@ | ||
var props = exclude(element.props, ['children']); | ||
var getMilliseconds = new Date().getUTCMilliseconds(); | ||
var randomStamp = getMilliseconds + Math.random() + Math.random(); | ||
// eslint-disable-next-line | ||
props.key = 'Typist-element-' + tag + '-' + (Date.now() + Math.random() + Math.random()); | ||
props.key = 'Typist-element-' + tag + '-' + randomStamp; | ||
return _react2.default.createElement.apply(_react2.default, [tag, props].concat(_toConsumableArray(children))); | ||
@@ -1559,0 +1557,0 @@ } |
{ | ||
"name": "react-typist", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Typing animations with React", | ||
@@ -5,0 +5,0 @@ "main": "dist/Typist.js", |
@@ -1,2 +0,2 @@ | ||
# React Typist | ||
# React Typist [![npm](https://img.shields.io/npm/dm/react-typist.svg)]() [![npm](https://img.shields.io/npm/v/react-typist.svg)]() | ||
React Component for making typing animations. Wrap `Typist` around your text or any | ||
@@ -29,3 +29,3 @@ element tree to animate text inside the tree. Easily stylable and highly | ||
Animate this text. | ||
</Typist>; | ||
</Typist> | ||
); | ||
@@ -32,0 +32,0 @@ } |
@@ -6,2 +6,4 @@ import React from 'react'; | ||
Backspace.componentName = 'Backspace'; | ||
Backspace.propTypes = { | ||
@@ -8,0 +10,0 @@ count: PropTypes.number, |
@@ -6,2 +6,4 @@ import React from 'react'; | ||
Delay.componentName = 'Delay'; | ||
Delay.propTypes = { | ||
@@ -8,0 +10,0 @@ ms: PropTypes.number.isRequired, |
import React from 'react'; | ||
import Backspace from './Backspace'; | ||
import Delay from './Delay'; | ||
@@ -37,7 +35,7 @@ export const sleep = (val) => new Promise((resolve) => ( | ||
export function isBackspaceElement(element) { | ||
return element && element.type === Backspace; | ||
return element && element.type && element.type.componentName === 'Backspace'; | ||
} | ||
export function isDelayElement(element) { | ||
return element && element.type === Delay; | ||
return element && element.type && element.type.componentName === 'Delay'; | ||
} | ||
@@ -77,4 +75,6 @@ | ||
const props = exclude(element.props, ['children']); | ||
const getMilliseconds = new Date().getUTCMilliseconds(); | ||
const randomStamp = getMilliseconds + Math.random() + Math.random(); | ||
// eslint-disable-next-line | ||
props.key = `Typist-element-${tag}-${Date.now() + Math.random() + Math.random()}`; | ||
props.key = `Typist-element-${tag}-${randomStamp}`; | ||
return React.createElement(tag, props, ...children); | ||
@@ -81,0 +81,0 @@ } |
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
152722
3268