@chayns-components/typewriter 5.0.0-beta.90 → 5.0.0-beta.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,9 @@
1
1
  import { FC, ReactElement } from 'react';
2
+ export declare enum TypewriterResetDelay {
3
+ Slow = 3000,
4
+ Medium = 1500,
5
+ Fast = 750
6
+ }
2
7
  export declare enum TypewriterSpeed {
3
8
  Slow = 40,
4
9
  Medium = 30,
@@ -8,7 +13,14 @@ export type TypewriterProps = {
8
13
  /**
9
14
  * The text to type
10
15
  */
11
- children: ReactElement | string;
16
+ children: ReactElement | ReactElement[] | string | string[];
17
+ /**
18
+ * Waiting time before the typewriter resets the content if multiple texts are given
19
+ */
20
+ resetDelay?: TypewriterResetDelay;
21
+ /**
22
+ * The speed of the animation. Use the TypewriterSpeed enum for this prop.
23
+ */
12
24
  speed?: TypewriterSpeed;
13
25
  };
14
26
  declare const Typewriter: FC<TypewriterProps>;
@@ -3,13 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.TypewriterSpeed = void 0;
6
+ exports.default = exports.TypewriterSpeed = exports.TypewriterResetDelay = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _server = require("react-dom/server");
9
9
  var _Typewriter = require("./Typewriter.styles");
10
10
  var _utils = require("./utils");
11
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ let TypewriterResetDelay;
14
+ exports.TypewriterResetDelay = TypewriterResetDelay;
15
+ (function (TypewriterResetDelay) {
16
+ TypewriterResetDelay[TypewriterResetDelay["Slow"] = 3000] = "Slow";
17
+ TypewriterResetDelay[TypewriterResetDelay["Medium"] = 1500] = "Medium";
18
+ TypewriterResetDelay[TypewriterResetDelay["Fast"] = 750] = "Fast";
19
+ })(TypewriterResetDelay || (exports.TypewriterResetDelay = TypewriterResetDelay = {}));
13
20
  let TypewriterSpeed;
14
21
  exports.TypewriterSpeed = TypewriterSpeed;
15
22
  (function (TypewriterSpeed) {
@@ -20,13 +27,27 @@ exports.TypewriterSpeed = TypewriterSpeed;
20
27
  const Typewriter = _ref => {
21
28
  let {
22
29
  children,
30
+ resetDelay = TypewriterResetDelay.Medium,
23
31
  speed = TypewriterSpeed.Medium
24
32
  } = _ref;
25
- const textContent = /*#__PURE__*/_react.default.isValidElement(children) ? (0, _server.renderToString)(children) : children;
33
+ const [currentChildrenIndex, setCurrentChildrenIndex] = (0, _react.useState)(0);
34
+ const areMultipleChildrenGiven = Array.isArray(children);
35
+ const childrenCount = areMultipleChildrenGiven ? children.length : 1;
36
+ const textContent = (0, _react.useMemo)(() => {
37
+ if (areMultipleChildrenGiven) {
38
+ const currentChildren = children[currentChildrenIndex];
39
+ if (currentChildren) {
40
+ return /*#__PURE__*/_react.default.isValidElement(currentChildren) ? (0, _server.renderToString)(currentChildren) : currentChildren;
41
+ }
42
+ return '';
43
+ }
44
+ return /*#__PURE__*/_react.default.isValidElement(children) ? (0, _server.renderToString)(children) : children;
45
+ }, [areMultipleChildrenGiven, children, currentChildrenIndex]);
26
46
  const charactersCount = (0, _react.useMemo)(() => (0, _utils.getCharactersCount)(textContent), [textContent]);
47
+ const [isResetAnimationActive, setIsResetAnimationActive] = (0, _react.useState)(false);
27
48
  const [shownCharCount, setShownCharCount] = (0, _react.useState)(charactersCount > 0 ? 0 : textContent.length);
28
49
  const [shouldStopAnimation, setShouldStopAnimation] = (0, _react.useState)(false);
29
- const isAnimatingText = shownCharCount !== textContent.length;
50
+ const isAnimatingText = shownCharCount !== textContent.length || areMultipleChildrenGiven;
30
51
  const handleClick = (0, _react.useCallback)(() => {
31
52
  setShouldStopAnimation(true);
32
53
  }, []);
@@ -34,8 +55,29 @@ const Typewriter = _ref => {
34
55
  let interval;
35
56
  if (shouldStopAnimation || charactersCount === 0) {
36
57
  setShownCharCount(textContent.length);
58
+ } else if (isResetAnimationActive) {
59
+ interval = window.setInterval(() => {
60
+ setShownCharCount(prevState => {
61
+ const nextState = prevState - 1;
62
+ if (nextState === 0) {
63
+ window.clearInterval(interval);
64
+ if (areMultipleChildrenGiven) {
65
+ setTimeout(() => {
66
+ setIsResetAnimationActive(false);
67
+ setCurrentChildrenIndex(currentIndex => {
68
+ let newIndex = currentIndex + 1;
69
+ if (newIndex > childrenCount - 1) {
70
+ newIndex = 0;
71
+ }
72
+ return newIndex;
73
+ });
74
+ }, resetDelay);
75
+ }
76
+ }
77
+ return nextState;
78
+ });
79
+ }, speed);
37
80
  } else {
38
- setShownCharCount(0);
39
81
  interval = window.setInterval(() => {
40
82
  setShownCharCount(prevState => {
41
83
  let nextState = prevState + 1;
@@ -48,6 +90,9 @@ const Typewriter = _ref => {
48
90
  * after the last letter.
49
91
  */
50
92
  nextState = textContent.length;
93
+ if (areMultipleChildrenGiven) {
94
+ setTimeout(setIsResetAnimationActive, resetDelay, true);
95
+ }
51
96
  }
52
97
  return nextState;
53
98
  });
@@ -56,7 +101,13 @@ const Typewriter = _ref => {
56
101
  return () => {
57
102
  window.clearInterval(interval);
58
103
  };
59
- }, [shouldStopAnimation, speed, textContent.length, charactersCount]);
104
+ }, [shouldStopAnimation, speed, textContent.length, charactersCount, isResetAnimationActive, areMultipleChildrenGiven, resetDelay, childrenCount]);
105
+ (0, _react.useEffect)(() => {
106
+ if (charactersCount) {
107
+ setIsResetAnimationActive(false);
108
+ setShownCharCount(0);
109
+ }
110
+ }, [charactersCount]);
60
111
  const shownText = (0, _react.useMemo)(() => (0, _utils.getSubTextFromHTML)(textContent, shownCharCount), [shownCharCount, textContent]);
61
112
  return /*#__PURE__*/_react.default.createElement(_Typewriter.StyledTypewriter, {
62
113
  onClick: handleClick
@@ -1 +1 @@
1
- {"version":3,"file":"Typewriter.js","names":["_react","_interopRequireWildcard","require","_server","_Typewriter","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TypewriterSpeed","exports","Typewriter","_ref","children","speed","Medium","textContent","React","isValidElement","renderToString","charactersCount","useMemo","getCharactersCount","shownCharCount","setShownCharCount","useState","length","shouldStopAnimation","setShouldStopAnimation","isAnimatingText","handleClick","useCallback","useEffect","interval","window","setInterval","prevState","nextState","clearInterval","shownText","getSubTextFromHTML","createElement","StyledTypewriter","onClick","StyledTypewriterText","dangerouslySetInnerHTML","__html","StyledTypewriterPseudoText","displayName","_default"],"sources":["../../../src/components/typewriter/Typewriter.tsx"],"sourcesContent":["import React, { FC, ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport {\n StyledTypewriter,\n StyledTypewriterPseudoText,\n StyledTypewriterText,\n} from './Typewriter.styles';\nimport { getCharactersCount, getSubTextFromHTML } from './utils';\n\nexport enum TypewriterSpeed {\n Slow = 40,\n Medium = 30,\n Fast = 20,\n}\n\nexport type TypewriterProps = {\n /**\n * The text to type\n */\n children: ReactElement | string;\n speed?: TypewriterSpeed;\n};\n\nconst Typewriter: FC<TypewriterProps> = ({ children, speed = TypewriterSpeed.Medium }) => {\n const textContent = React.isValidElement(children) ? renderToString(children) : children;\n\n const charactersCount = useMemo(() => getCharactersCount(textContent), [textContent]);\n\n const [shownCharCount, setShownCharCount] = useState(\n charactersCount > 0 ? 0 : textContent.length\n );\n const [shouldStopAnimation, setShouldStopAnimation] = useState(false);\n\n const isAnimatingText = shownCharCount !== textContent.length;\n\n const handleClick = useCallback(() => {\n setShouldStopAnimation(true);\n }, []);\n\n useEffect(() => {\n let interval: number | undefined;\n\n if (shouldStopAnimation || charactersCount === 0) {\n setShownCharCount(textContent.length);\n } else {\n setShownCharCount(0);\n\n interval = window.setInterval(() => {\n setShownCharCount((prevState) => {\n let nextState = prevState + 1;\n\n if (nextState === charactersCount) {\n window.clearInterval(interval);\n\n /**\n * At this point, the next value for \"shownCharCount\" is deliberately set to\n * the length of the textContent in order to correctly display HTML elements\n * after the last letter.\n */\n nextState = textContent.length;\n }\n\n return nextState;\n });\n }, speed);\n }\n\n return () => {\n window.clearInterval(interval);\n };\n }, [shouldStopAnimation, speed, textContent.length, charactersCount]);\n\n const shownText = useMemo(\n () => getSubTextFromHTML(textContent, shownCharCount),\n [shownCharCount, textContent]\n );\n\n return (\n <StyledTypewriter onClick={handleClick}>\n {isAnimatingText ? (\n <StyledTypewriterText\n dangerouslySetInnerHTML={{ __html: shownText }}\n isAnimatingText\n />\n ) : (\n <StyledTypewriterText>{children}</StyledTypewriterText>\n )}\n {isAnimatingText && (\n <StyledTypewriterPseudoText dangerouslySetInnerHTML={{ __html: textContent }} />\n )}\n </StyledTypewriter>\n );\n};\n\nTypewriter.displayName = 'Typewriter';\n\nexport default Typewriter;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA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M,CAACI,aAAa,CAACL,QAAQ,CAAC;;YAE9B;AACxB;AACA;AACA;AACA;YACwBI,SAAS,GAAGrB,WAAW,CAACU,MAAM;UAClC;UAEA,OAAOW,SAAS;QACpB,CAAC,CAAC;MACN,CAAC,EAAEvB,KAAK,CAAC;IACb;IAEA,OAAO,MAAM;MACToB,MAAM,CAACI,aAAa,CAACL,QAAQ,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,CAACN,mBAAmB,EAAEb,KAAK,EAAEE,WAAW,CAACU,MAAM,EAAEN,eAAe,CAAC,CAAC;EAErE,MAAMmB,SAAS,GAAG,IAAAlB,cAAO,EACrB,MAAM,IAAAmB,yBAAkB,EAACxB,WAAW,EAAEO,cAAc,CAAC,EACrD,CAACA,cAAc,EAAEP,WAAW,CAAC,CAChC;EAED,oBACInC,MAAA,CAAAa,OAAA,CAAA+C,aAAA,CAACxD,WAAA,CAAAyD,gBAAgB;IAACC,OAAO,EAAEb;EAAY,GAClCD,eAAe,gBACZhD,MAAA,CAAAa,OAAA,CAAA+C,aAAA,CAACxD,WAAA,CAAA2D,oBAAoB;IACjBC,uBAAuB,EAAE;MAAEC,MAAM,EAAEP;IAAU,CAAE;IAC/CV,eAAe;EAAA,EACjB,gBAEFhD,MAAA,CAAAa,OAAA,CAAA+C,aAAA,CAACxD,WAAA,CAAA2D,oBAAoB,QAAE/B,QAAQ,CAClC,EACAgB,eAAe,iBACZhD,MAAA,CAAAa,OAAA,CAAA+C,aAAA,CAACxD,WAAA,CAAA8D,0BAA0B;IAACF,uBAAuB,EAAE;MAAEC,MAAM,EAAE9B;IAAY;EAAE,EAChF,CACc;AAE3B,CAAC;AAEDL,UAAU,CAACqC,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvBtC,UAAU;AAAAD,OAAA,CAAAhB,OAAA,GAAAuD,QAAA"}
1
+ {"version":3,"file":"Typewriter.js","names":["_react","_interopRequireWildcard","require","_server","_Typewriter","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TypewriterResetDelay","exports","TypewriterSpeed","Typewriter","_ref","children","resetDelay","Medium","speed","currentChildrenIndex","setCurrentChildrenIndex","useState","areMultipleChildrenGiven","Array","isArray","childrenCount","length","textContent","useMemo","currentChildren","React","isValidElement","renderToString","charactersCount","getCharactersCount","isResetAnimationActive","setIsResetAnimationActive","shownCharCount","setShownCharCount","shouldStopAnimation","setShouldStopAnimation","isAnimatingText","handleClick","useCallback","useEffect","interval","window","setInterval","prevState","nextState","clearInterval","setTimeout","currentIndex","newIndex","shownText","getSubTextFromHTML","createElement","StyledTypewriter","onClick","StyledTypewriterText","dangerouslySetInnerHTML","__html","StyledTypewriterPseudoText","displayName","_default"],"sources":["../../../src/components/typewriter/Typewriter.tsx"],"sourcesContent":["import React, { FC, ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport {\n StyledTypewriter,\n StyledTypewriterPseudoText,\n StyledTypewriterText,\n} from './Typewriter.styles';\nimport { getCharactersCount, getSubTextFromHTML } from './utils';\n\nexport enum TypewriterResetDelay {\n Slow = 3000,\n Medium = 1500,\n Fast = 750,\n}\n\nexport enum TypewriterSpeed {\n Slow = 40,\n Medium = 30,\n Fast = 20,\n}\n\nexport type TypewriterProps = {\n /**\n * The text to type\n */\n children: ReactElement | ReactElement[] | string | string[];\n /**\n * Waiting time before the typewriter resets the content if multiple texts are given\n */\n resetDelay?: TypewriterResetDelay;\n /**\n * The speed of the animation. Use the TypewriterSpeed enum for this prop.\n */\n speed?: TypewriterSpeed;\n};\n\nconst Typewriter: FC<TypewriterProps> = ({\n children,\n resetDelay = TypewriterResetDelay.Medium,\n speed = TypewriterSpeed.Medium,\n}) => {\n const [currentChildrenIndex, setCurrentChildrenIndex] = useState(0);\n\n const areMultipleChildrenGiven = Array.isArray(children);\n const childrenCount = areMultipleChildrenGiven ? children.length : 1;\n\n const textContent = useMemo(() => {\n if (areMultipleChildrenGiven) {\n const currentChildren = children[currentChildrenIndex];\n\n if (currentChildren) {\n return React.isValidElement(currentChildren)\n ? renderToString(currentChildren)\n : currentChildren;\n }\n\n return '';\n }\n\n return React.isValidElement(children) ? renderToString(children) : children;\n }, [areMultipleChildrenGiven, children, currentChildrenIndex]);\n\n const charactersCount = useMemo(() => getCharactersCount(textContent), [textContent]);\n\n const [isResetAnimationActive, setIsResetAnimationActive] = useState(false);\n const [shownCharCount, setShownCharCount] = useState(\n charactersCount > 0 ? 0 : textContent.length\n );\n const [shouldStopAnimation, setShouldStopAnimation] = useState(false);\n\n const isAnimatingText = shownCharCount !== textContent.length || areMultipleChildrenGiven;\n\n const handleClick = useCallback(() => {\n setShouldStopAnimation(true);\n }, []);\n\n useEffect(() => {\n let interval: number | undefined;\n\n if (shouldStopAnimation || charactersCount === 0) {\n setShownCharCount(textContent.length);\n } else if (isResetAnimationActive) {\n interval = window.setInterval(() => {\n setShownCharCount((prevState) => {\n const nextState = prevState - 1;\n\n if (nextState === 0) {\n window.clearInterval(interval);\n\n if (areMultipleChildrenGiven) {\n setTimeout(() => {\n setIsResetAnimationActive(false);\n setCurrentChildrenIndex((currentIndex) => {\n let newIndex = currentIndex + 1;\n\n if (newIndex > childrenCount - 1) {\n newIndex = 0;\n }\n\n return newIndex;\n });\n }, resetDelay);\n }\n }\n\n return nextState;\n });\n }, speed);\n } else {\n interval = window.setInterval(() => {\n setShownCharCount((prevState) => {\n let nextState = prevState + 1;\n\n if (nextState === charactersCount) {\n window.clearInterval(interval);\n\n /**\n * At this point, the next value for \"shownCharCount\" is deliberately set to\n * the length of the textContent in order to correctly display HTML elements\n * after the last letter.\n */\n nextState = textContent.length;\n\n if (areMultipleChildrenGiven) {\n setTimeout(setIsResetAnimationActive, resetDelay, true);\n }\n }\n\n return nextState;\n });\n }, speed);\n }\n\n return () => {\n window.clearInterval(interval);\n };\n }, [\n shouldStopAnimation,\n speed,\n textContent.length,\n charactersCount,\n isResetAnimationActive,\n areMultipleChildrenGiven,\n resetDelay,\n childrenCount,\n ]);\n\n useEffect(() => {\n if (charactersCount) {\n setIsResetAnimationActive(false);\n setShownCharCount(0);\n }\n }, [charactersCount]);\n\n const shownText = useMemo(\n () => getSubTextFromHTML(textContent, shownCharCount),\n [shownCharCount, textContent]\n );\n\n return (\n <StyledTypewriter onClick={handleClick}>\n {isAnimatingText ? (\n <StyledTypewriterText\n dangerouslySetInnerHTML={{ __html: shownText }}\n isAnimatingText\n />\n ) : (\n <StyledTypewriterText>{children}</StyledTypewriterText>\n )}\n {isAnimatingText && (\n <StyledTypewriterPseudoText dangerouslySetInnerHTML={{ __html: textContent }} />\n )}\n </StyledTypewriter>\n );\n};\n\nTypewriter.displayName = 'Typewriter';\n\nexport default Typewriter;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAAiE,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GA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AEDd,UAAU,CAACkD,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvBnD,UAAU;AAAAF,OAAA,CAAAhB,OAAA,GAAAqE,QAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/typewriter",
3
- "version": "5.0.0-beta.90",
3
+ "version": "5.0.0-beta.97",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "keywords": [
6
6
  "chayns",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "f0e8c6a4f8faf043c756bb397ba0aa3e6165882d"
66
+ "gitHead": "3dce451561868928db23b56ad9f5f8c465657e71"
67
67
  }