@chayns-components/typewriter 5.0.0-beta.54 → 5.0.0-beta.541

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.
package/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  </h1>
5
5
  <p>A set of beautiful React components for developing your own applications with chayns.</p>
6
6
  <div>
7
- <img src="https://img.shields.io/npm/dm/@chayns-components/typewriter.svg?style=for-the-badge" alt="" />
8
- <img src="https://img.shields.io/npm/v/@chayns-components/typewriter?style=for-the-badge" alt="" />
7
+ <img src="https://img.shields.io/npm/dm/@chayns-components/core.svg?style=for-the-badge" alt="" />
8
+ <img src="https://img.shields.io/npm/v/@chayns-components/core?style=for-the-badge" alt="" />
9
9
  <img src="https://img.shields.io/github/license/TobitSoftware/chayns-components?style=for-the-badge" alt="" />
10
10
  <img src="https://img.shields.io/github/contributors/TobitSoftware/chayns-components?style=for-the-badge" alt="" />
11
11
  </div>
@@ -15,7 +15,7 @@
15
15
 
16
16
  ## Installation
17
17
 
18
- First you need to install the typewriter part of the chayns-components.
18
+ First you need to install the core part of the chayns-components.
19
19
 
20
20
  ```bash
21
21
  # NPM
@@ -31,15 +31,4 @@ yarn add @chayns-components/typewriter
31
31
 
32
32
  ## Usage
33
33
 
34
- You can use the components in your project as in the following example.
35
-
36
- ```typescript jsx
37
- import { Typewriter } from '@chayns-components/typewriter';
38
-
39
- <Typewriter>
40
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt
41
- ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
42
- dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est. Lorem ipsum dolor
43
- sit amet.
44
- </Typewriter>;
45
- ```
34
+ For detailed usage visit the [storybook](https://components.chayns.site/storybook).
@@ -1,9 +1,69 @@
1
- import { FC } from 'react';
1
+ import React, { FC, ReactElement } from 'react';
2
+ export declare enum TypewriterResetDelay {
3
+ Slow = 4000,
4
+ Medium = 2000,
5
+ Fast = 1000
6
+ }
7
+ export declare enum TypewriterSpeed {
8
+ Slow = 35,
9
+ Medium = 25,
10
+ Fast = 15
11
+ }
2
12
  export type TypewriterProps = {
3
13
  /**
4
14
  * The text to type
5
15
  */
6
- children: string;
16
+ children: ReactElement | ReactElement[] | string | string[];
17
+ /**
18
+ * Function that is executed when the typewriter animation has finished. This function will not
19
+ * be executed if multiple texts are used.
20
+ */
21
+ onFinish?: VoidFunction;
22
+ /**
23
+ * Pseudo-element to be rendered invisible during animation to define the size of the element
24
+ * for the typewriter effect. By default, the "children" is used for this purpose.
25
+ */
26
+ pseudoChildren?: ReactElement | string;
27
+ /**
28
+ * Waiting time before the typewriter resets the content if multiple texts are given
29
+ */
30
+ resetDelay?: TypewriterResetDelay;
31
+ /**
32
+ * Specifies whether the cursor should be forced to animate even if no text is currently animated.
33
+ */
34
+ shouldForceCursorAnimation?: boolean;
35
+ /**
36
+ * Specifies whether the cursor should be hidden
37
+ */
38
+ shouldHideCursor?: boolean;
39
+ /**
40
+ * Specifies whether the children should be sorted randomly if there are multiple texts.
41
+ * This makes the typewriter start with a different text each time and also changes them
42
+ * in a random order.
43
+ */
44
+ shouldSortChildrenRandomly?: boolean;
45
+ /**
46
+ * Specifies whether the animation should use its full height or the height of the current
47
+ * chunk.
48
+ */
49
+ shouldUseAnimationHeight?: boolean;
50
+ /**
51
+ * Specifies whether the reset of the text should be animated with a backspace animation for
52
+ * multiple texts.
53
+ */
54
+ shouldUseResetAnimation?: boolean;
55
+ /**
56
+ * Whether the typewriter should wait for new content
57
+ */
58
+ shouldWaitForContent?: boolean;
59
+ /**
60
+ * The speed of the animation. Use the TypewriterSpeed enum for this prop.
61
+ */
62
+ speed?: TypewriterSpeed | number;
63
+ /**
64
+ * The style of the typewriter text element
65
+ */
66
+ textStyle?: React.CSSProperties;
7
67
  };
8
68
  declare const Typewriter: FC<TypewriterProps>;
9
69
  export default Typewriter;
@@ -1,55 +1,183 @@
1
- "use strict";
1
+ import { ColorSchemeProvider } from '@chayns-components/core';
2
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
+ import { renderToString } from 'react-dom/server';
4
+ import { StyledTypewriter, StyledTypewriterPseudoText, StyledTypewriterText } from './Typewriter.styles';
5
+ import { getCharactersCount, getSubTextFromHTML, shuffleArray } from './utils';
2
6
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _Typewriter = require("./Typewriter.styles");
9
- var _utils = require("./utils");
10
- 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); }
11
- 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; }
7
+ // noinspection JSUnusedGlobalSymbols
8
+ export let TypewriterResetDelay = /*#__PURE__*/function (TypewriterResetDelay) {
9
+ TypewriterResetDelay[TypewriterResetDelay["Slow"] = 4000] = "Slow";
10
+ TypewriterResetDelay[TypewriterResetDelay["Medium"] = 2000] = "Medium";
11
+ TypewriterResetDelay[TypewriterResetDelay["Fast"] = 1000] = "Fast";
12
+ return TypewriterResetDelay;
13
+ }({});
14
+
15
+ // noinspection JSUnusedGlobalSymbols
16
+ export let TypewriterSpeed = /*#__PURE__*/function (TypewriterSpeed) {
17
+ TypewriterSpeed[TypewriterSpeed["Slow"] = 35] = "Slow";
18
+ TypewriterSpeed[TypewriterSpeed["Medium"] = 25] = "Medium";
19
+ TypewriterSpeed[TypewriterSpeed["Fast"] = 15] = "Fast";
20
+ return TypewriterSpeed;
21
+ }({});
12
22
  const Typewriter = _ref => {
13
23
  let {
14
- children
24
+ children,
25
+ onFinish,
26
+ pseudoChildren,
27
+ resetDelay = TypewriterResetDelay.Medium,
28
+ shouldForceCursorAnimation = false,
29
+ shouldHideCursor = false,
30
+ shouldSortChildrenRandomly = false,
31
+ shouldUseAnimationHeight = false,
32
+ shouldUseResetAnimation = false,
33
+ shouldWaitForContent,
34
+ speed = TypewriterSpeed.Medium,
35
+ textStyle
15
36
  } = _ref;
16
- const [shownCharCount, setShownCharCount] = (0, _react.useState)(0);
17
- const [shouldStopAnimation, setShouldStopAnimation] = (0, _react.useState)(false);
18
- const isAnimatingText = shownCharCount !== children.length;
19
- const handleClick = (0, _react.useCallback)(() => {
37
+ const [currentChildrenIndex, setCurrentChildrenIndex] = useState(0);
38
+ const [shouldCount, setShouldCount] = useState(true);
39
+ const sortedChildren = useMemo(() => Array.isArray(children) && shouldSortChildrenRandomly ? shuffleArray(children) : children, [children, shouldSortChildrenRandomly]);
40
+ const areMultipleChildrenGiven = Array.isArray(sortedChildren);
41
+ const childrenCount = areMultipleChildrenGiven ? sortedChildren.length : 1;
42
+ const textContent = useMemo(() => {
43
+ if (areMultipleChildrenGiven) {
44
+ const currentChildren = sortedChildren[currentChildrenIndex];
45
+ if (currentChildren) {
46
+ return /*#__PURE__*/React.isValidElement(currentChildren) ? renderToString( /*#__PURE__*/React.createElement(ColorSchemeProvider, {
47
+ color: "#005EB8",
48
+ colorMode: 0
49
+ }, currentChildren)) : currentChildren;
50
+ }
51
+ return '';
52
+ }
53
+ return /*#__PURE__*/React.isValidElement(sortedChildren) ? renderToString( /*#__PURE__*/React.createElement(ColorSchemeProvider, {
54
+ color: "#005EB8",
55
+ colorMode: 0
56
+ }, sortedChildren)) : sortedChildren;
57
+ }, [areMultipleChildrenGiven, currentChildrenIndex, sortedChildren]);
58
+ const charactersCount = useMemo(() => getCharactersCount(textContent), [textContent]);
59
+ const [isResetAnimationActive, setIsResetAnimationActive] = useState(false);
60
+ const [shownCharCount, setShownCharCount] = useState(charactersCount > 0 ? 0 : textContent.length);
61
+ const [shouldStopAnimation, setShouldStopAnimation] = useState(false);
62
+ const [prevChildren, setPrevChildren] = useState(children);
63
+ useEffect(() => {
64
+ if (children !== prevChildren) {
65
+ setShouldCount(true);
66
+ setPrevChildren(children);
67
+ }
68
+ }, [children, prevChildren]);
69
+ const isAnimatingText = shownCharCount < textContent.length || shouldForceCursorAnimation || areMultipleChildrenGiven || textContent.length === 0;
70
+ const handleClick = useCallback(() => {
20
71
  setShouldStopAnimation(true);
21
72
  }, []);
22
- (0, _react.useEffect)(() => {
73
+ const handleSetNextChildrenIndex = useCallback(() => setCurrentChildrenIndex(() => {
74
+ let newIndex = currentChildrenIndex + 1;
75
+ if (newIndex > childrenCount - 1) {
76
+ newIndex = 0;
77
+ }
78
+ return newIndex;
79
+ }), [childrenCount, currentChildrenIndex]);
80
+ useEffect(() => {
23
81
  let interval;
24
- if (shouldStopAnimation) {
25
- setShownCharCount(children.length);
26
- } else {
27
- setShownCharCount(0);
82
+ if (shouldStopAnimation || charactersCount === 0) {
83
+ setShownCharCount(textContent.length);
84
+ } else if (isResetAnimationActive) {
28
85
  interval = window.setInterval(() => {
29
86
  setShownCharCount(prevState => {
30
- const nextState = prevState + 1;
31
- if (nextState === children.length) {
87
+ const nextState = prevState - 1;
88
+ if (nextState === 0) {
32
89
  window.clearInterval(interval);
90
+ if (areMultipleChildrenGiven) {
91
+ setTimeout(() => {
92
+ setIsResetAnimationActive(false);
93
+ handleSetNextChildrenIndex();
94
+ }, resetDelay);
95
+ }
96
+ }
97
+ return nextState;
98
+ });
99
+ }, speed);
100
+ } else {
101
+ interval = window.setInterval(() => {
102
+ setShownCharCount(prevState => {
103
+ let nextState = prevState;
104
+ if (shouldCount) {
105
+ nextState = prevState + 1;
106
+ }
107
+ if (nextState >= charactersCount) {
108
+ if (shouldWaitForContent) {
109
+ setShouldCount(false);
110
+ } else {
111
+ window.clearInterval(interval);
112
+
113
+ /**
114
+ * At this point, the next value for "shownCharCount" is deliberately set to
115
+ * the length of the textContent in order to correctly display HTML elements
116
+ * after the last letter.
117
+ */
118
+ nextState = textContent.length;
119
+ if (areMultipleChildrenGiven) {
120
+ setTimeout(() => {
121
+ if (shouldUseResetAnimation) {
122
+ setIsResetAnimationActive(true);
123
+ } else {
124
+ setShownCharCount(0);
125
+ setTimeout(handleSetNextChildrenIndex, resetDelay / 2);
126
+ }
127
+ }, resetDelay);
128
+ }
129
+ }
33
130
  }
34
131
  return nextState;
35
132
  });
36
- }, 35);
133
+ }, speed);
37
134
  }
38
135
  return () => {
39
136
  window.clearInterval(interval);
40
137
  };
41
- }, [children.length, shouldStopAnimation]);
42
- const shownText = (0, _react.useMemo)(() => (0, _utils.getSubTextFromHTML)(children, shownCharCount), [children, shownCharCount]);
43
- return /*#__PURE__*/_react.default.createElement(_Typewriter.StyledTypewriter, {
138
+ }, [shouldStopAnimation, speed, textContent.length, charactersCount, isResetAnimationActive, areMultipleChildrenGiven, resetDelay, childrenCount, handleSetNextChildrenIndex, shouldUseResetAnimation, shouldCount, shouldWaitForContent]);
139
+ useEffect(() => {
140
+ if (!isAnimatingText && typeof onFinish === 'function') {
141
+ onFinish();
142
+ }
143
+ }, [isAnimatingText, onFinish]);
144
+ const shownText = useMemo(() => getSubTextFromHTML(textContent, shownCharCount), [shownCharCount, textContent]);
145
+ const pseudoTextHTML = useMemo(() => {
146
+ if (pseudoChildren) {
147
+ const pseudoText = /*#__PURE__*/React.isValidElement(pseudoChildren) ? renderToString( /*#__PURE__*/React.createElement(ColorSchemeProvider, {
148
+ color: "#005EB8",
149
+ colorMode: 0
150
+ }, pseudoChildren)) : pseudoChildren;
151
+ if (shouldUseAnimationHeight) {
152
+ return getSubTextFromHTML(pseudoText, shownCharCount);
153
+ }
154
+ return pseudoText;
155
+ }
156
+ if (shouldUseAnimationHeight && textContent) {
157
+ return getSubTextFromHTML(textContent, shownCharCount);
158
+ }
159
+ return textContent || '&#8203;';
160
+ }, [pseudoChildren, shouldUseAnimationHeight, shownCharCount, textContent]);
161
+ return useMemo(() => /*#__PURE__*/React.createElement(StyledTypewriter, {
44
162
  onClick: handleClick
45
- }, /*#__PURE__*/_react.default.createElement(_Typewriter.StyledTypewriterText, {
163
+ }, isAnimatingText && /*#__PURE__*/React.createElement(StyledTypewriterText, {
46
164
  dangerouslySetInnerHTML: {
47
165
  __html: shownText
48
166
  },
49
- isAnimatingText: isAnimatingText
50
- }), isAnimatingText && /*#__PURE__*/_react.default.createElement(_Typewriter.StyledTypewriterPseudoText, null, children));
167
+ $isAnimatingText: true,
168
+ $shouldHideCursor: shouldHideCursor,
169
+ style: textStyle
170
+ }), /*#__PURE__*/React.createElement(StyledTypewriterText, {
171
+ style: isAnimatingText ? {
172
+ visibility: 'hidden',
173
+ position: 'absolute'
174
+ } : textStyle
175
+ }, sortedChildren), isAnimatingText && /*#__PURE__*/React.createElement(StyledTypewriterPseudoText, {
176
+ dangerouslySetInnerHTML: {
177
+ __html: pseudoTextHTML
178
+ }
179
+ })), [handleClick, isAnimatingText, pseudoTextHTML, shouldHideCursor, shownText, sortedChildren, textStyle]);
51
180
  };
52
181
  Typewriter.displayName = 'Typewriter';
53
- var _default = Typewriter;
54
- exports.default = _default;
182
+ export default Typewriter;
55
183
  //# sourceMappingURL=Typewriter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Typewriter.js","names":["Typewriter","children","shownCharCount","setShownCharCount","useState","shouldStopAnimation","setShouldStopAnimation","isAnimatingText","length","handleClick","useCallback","useEffect","interval","window","setInterval","prevState","nextState","clearInterval","shownText","useMemo","getSubTextFromHTML","__html","displayName"],"sources":["../../../src/components/typewriter/Typewriter.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n StyledTypewriter,\n StyledTypewriterPseudoText,\n StyledTypewriterText,\n} from './Typewriter.styles';\nimport { getSubTextFromHTML } from './utils';\n\nexport type TypewriterProps = {\n /**\n * The text to type\n */\n children: string;\n};\n\nconst Typewriter: FC<TypewriterProps> = ({ children }) => {\n const [shownCharCount, setShownCharCount] = useState(0);\n const [shouldStopAnimation, setShouldStopAnimation] = useState(false);\n\n const isAnimatingText = shownCharCount !== children.length;\n\n const handleClick = useCallback(() => {\n setShouldStopAnimation(true);\n }, []);\n\n useEffect(() => {\n let interval: number | undefined;\n\n if (shouldStopAnimation) {\n setShownCharCount(children.length);\n } else {\n setShownCharCount(0);\n\n interval = window.setInterval(() => {\n setShownCharCount((prevState) => {\n const nextState = prevState + 1;\n\n if (nextState === children.length) {\n window.clearInterval(interval);\n }\n\n return nextState;\n });\n }, 35);\n }\n\n return () => {\n window.clearInterval(interval);\n };\n }, [children.length, shouldStopAnimation]);\n\n const shownText = useMemo(\n () => getSubTextFromHTML(children, shownCharCount),\n [children, shownCharCount]\n );\n\n return (\n <StyledTypewriter onClick={handleClick}>\n <StyledTypewriterText\n dangerouslySetInnerHTML={{ __html: shownText }}\n isAnimatingText={isAnimatingText}\n />\n {isAnimatingText && <StyledTypewriterPseudoText>{children}</StyledTypewriterPseudoText>}\n </StyledTypewriter>\n );\n};\n\nTypewriter.displayName = 'Typewriter';\n\nexport default Typewriter;\n"],"mappings":";;;;;;AAAA;AACA;AAKA;AAA6C;AAAA;AAS7C,MAAMA,UAA+B,GAAG,QAAkB;EAAA,IAAjB;IAAEC;EAAS,CAAC;EACjD,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC,CAAC;EACvD,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAG,IAAAF,eAAQ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,WAAW,GAAG,YAAY;AAAC,eAEvBtB,UAAU;AAAA"}
1
+ {"version":3,"file":"Typewriter.js","names":["ColorSchemeProvider","React","useCallback","useEffect","useMemo","useState","renderToString","StyledTypewriter","StyledTypewriterPseudoText","StyledTypewriterText","getCharactersCount","getSubTextFromHTML","shuffleArray","TypewriterResetDelay","TypewriterSpeed","Typewriter","_ref","children","onFinish","pseudoChildren","resetDelay","Medium","shouldForceCursorAnimation","shouldHideCursor","shouldSortChildrenRandomly","shouldUseAnimationHeight","shouldUseResetAnimation","shouldWaitForContent","speed","textStyle","currentChildrenIndex","setCurrentChildrenIndex","shouldCount","setShouldCount","sortedChildren","Array","isArray","areMultipleChildrenGiven","childrenCount","length","textContent","currentChildren","isValidElement","createElement","color","colorMode","charactersCount","isResetAnimationActive","setIsResetAnimationActive","shownCharCount","setShownCharCount","shouldStopAnimation","setShouldStopAnimation","prevChildren","setPrevChildren","isAnimatingText","handleClick","handleSetNextChildrenIndex","newIndex","interval","window","setInterval","prevState","nextState","clearInterval","setTimeout","shownText","pseudoTextHTML","pseudoText","onClick","dangerouslySetInnerHTML","__html","$isAnimatingText","$shouldHideCursor","style","visibility","position","displayName"],"sources":["../../../src/components/typewriter/Typewriter.tsx"],"sourcesContent":["import { ColorSchemeProvider } from '@chayns-components/core';\nimport 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, shuffleArray } from './utils';\n\n// noinspection JSUnusedGlobalSymbols\nexport enum TypewriterResetDelay {\n Slow = 4000,\n Medium = 2000,\n Fast = 1000,\n}\n\n// noinspection JSUnusedGlobalSymbols\nexport enum TypewriterSpeed {\n Slow = 35,\n Medium = 25,\n Fast = 15,\n}\n\nexport type TypewriterProps = {\n /**\n * The text to type\n */\n children: ReactElement | ReactElement[] | string | string[];\n /**\n * Function that is executed when the typewriter animation has finished. This function will not\n * be executed if multiple texts are used.\n */\n onFinish?: VoidFunction;\n /**\n * Pseudo-element to be rendered invisible during animation to define the size of the element\n * for the typewriter effect. By default, the \"children\" is used for this purpose.\n */\n pseudoChildren?: ReactElement | string;\n /**\n * Waiting time before the typewriter resets the content if multiple texts are given\n */\n resetDelay?: TypewriterResetDelay;\n /**\n * Specifies whether the cursor should be forced to animate even if no text is currently animated.\n */\n shouldForceCursorAnimation?: boolean;\n /**\n * Specifies whether the cursor should be hidden\n */\n shouldHideCursor?: boolean;\n /**\n * Specifies whether the children should be sorted randomly if there are multiple texts.\n * This makes the typewriter start with a different text each time and also changes them\n * in a random order.\n */\n shouldSortChildrenRandomly?: boolean;\n /**\n * Specifies whether the animation should use its full height or the height of the current\n * chunk.\n */\n shouldUseAnimationHeight?: boolean;\n /**\n * Specifies whether the reset of the text should be animated with a backspace animation for\n * multiple texts.\n */\n shouldUseResetAnimation?: boolean;\n /**\n * Whether the typewriter should wait for new content\n */\n shouldWaitForContent?: boolean;\n /**\n * The speed of the animation. Use the TypewriterSpeed enum for this prop.\n */\n speed?: TypewriterSpeed | number;\n /**\n * The style of the typewriter text element\n */\n textStyle?: React.CSSProperties;\n};\n\nconst Typewriter: FC<TypewriterProps> = ({\n children,\n onFinish,\n pseudoChildren,\n resetDelay = TypewriterResetDelay.Medium,\n shouldForceCursorAnimation = false,\n shouldHideCursor = false,\n shouldSortChildrenRandomly = false,\n shouldUseAnimationHeight = false,\n shouldUseResetAnimation = false,\n shouldWaitForContent,\n speed = TypewriterSpeed.Medium,\n textStyle,\n}) => {\n const [currentChildrenIndex, setCurrentChildrenIndex] = useState(0);\n const [shouldCount, setShouldCount] = useState(true);\n\n const sortedChildren = useMemo(\n () =>\n Array.isArray(children) && shouldSortChildrenRandomly\n ? shuffleArray<ReactElement | string>(children)\n : children,\n [children, shouldSortChildrenRandomly],\n );\n\n const areMultipleChildrenGiven = Array.isArray(sortedChildren);\n const childrenCount = areMultipleChildrenGiven ? sortedChildren.length : 1;\n\n const textContent = useMemo(() => {\n if (areMultipleChildrenGiven) {\n const currentChildren = sortedChildren[currentChildrenIndex];\n\n if (currentChildren) {\n return React.isValidElement(currentChildren)\n ? renderToString(\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n {currentChildren}\n </ColorSchemeProvider>,\n )\n : (currentChildren as string);\n }\n\n return '';\n }\n\n return React.isValidElement(sortedChildren)\n ? renderToString(\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n {sortedChildren}\n </ColorSchemeProvider>,\n )\n : (sortedChildren as string);\n }, [areMultipleChildrenGiven, currentChildrenIndex, sortedChildren]);\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 const [prevChildren, setPrevChildren] = useState<TypewriterProps['children']>(children);\n\n useEffect(() => {\n if (children !== prevChildren) {\n setShouldCount(true);\n setPrevChildren(children);\n }\n }, [children, prevChildren]);\n\n const isAnimatingText =\n shownCharCount < textContent.length ||\n shouldForceCursorAnimation ||\n areMultipleChildrenGiven ||\n textContent.length === 0;\n\n const handleClick = useCallback(() => {\n setShouldStopAnimation(true);\n }, []);\n\n const handleSetNextChildrenIndex = useCallback(\n () =>\n setCurrentChildrenIndex(() => {\n let newIndex = currentChildrenIndex + 1;\n\n if (newIndex > childrenCount - 1) {\n newIndex = 0;\n }\n\n return newIndex;\n }),\n [childrenCount, currentChildrenIndex],\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 handleSetNextChildrenIndex();\n }, resetDelay);\n }\n }\n\n return nextState;\n });\n }, speed);\n } else {\n interval = window.setInterval(() => {\n setShownCharCount((prevState) => {\n let nextState = prevState;\n\n if (shouldCount) {\n nextState = prevState + 1;\n }\n\n if (nextState >= charactersCount) {\n if (shouldWaitForContent) {\n setShouldCount(false);\n } else {\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(() => {\n if (shouldUseResetAnimation) {\n setIsResetAnimationActive(true);\n } else {\n setShownCharCount(0);\n setTimeout(handleSetNextChildrenIndex, resetDelay / 2);\n }\n }, resetDelay);\n }\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 handleSetNextChildrenIndex,\n shouldUseResetAnimation,\n shouldCount,\n shouldWaitForContent,\n ]);\n\n useEffect(() => {\n if (!isAnimatingText && typeof onFinish === 'function') {\n onFinish();\n }\n }, [isAnimatingText, onFinish]);\n\n const shownText = useMemo(\n () => getSubTextFromHTML(textContent, shownCharCount),\n [shownCharCount, textContent],\n );\n\n const pseudoTextHTML = useMemo(() => {\n if (pseudoChildren) {\n const pseudoText = React.isValidElement(pseudoChildren)\n ? renderToString(\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n {pseudoChildren}\n </ColorSchemeProvider>,\n )\n : (pseudoChildren as string);\n\n if (shouldUseAnimationHeight) {\n return getSubTextFromHTML(pseudoText, shownCharCount);\n }\n\n return pseudoText;\n }\n\n if (shouldUseAnimationHeight && textContent) {\n return getSubTextFromHTML(textContent, shownCharCount);\n }\n\n return textContent || '&#8203;';\n }, [pseudoChildren, shouldUseAnimationHeight, shownCharCount, textContent]);\n\n return useMemo(\n () => (\n <StyledTypewriter onClick={handleClick}>\n {isAnimatingText && (\n <StyledTypewriterText\n dangerouslySetInnerHTML={{ __html: shownText }}\n $isAnimatingText\n $shouldHideCursor={shouldHideCursor}\n style={textStyle}\n />\n )}\n <StyledTypewriterText\n style={\n isAnimatingText ? { visibility: 'hidden', position: 'absolute' } : textStyle\n }\n >\n {sortedChildren}\n </StyledTypewriterText>\n {isAnimatingText && (\n <StyledTypewriterPseudoText\n dangerouslySetInnerHTML={{ __html: pseudoTextHTML }}\n />\n )}\n </StyledTypewriter>\n ),\n [\n handleClick,\n isAnimatingText,\n pseudoTextHTML,\n shouldHideCursor,\n shownText,\n sortedChildren,\n textStyle,\n ],\n );\n};\n\nTypewriter.displayName = 'Typewriter';\n\nexport default Typewriter;\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,yBAAyB;AAC7D,OAAOC,KAAK,IAAsBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC1F,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACIC,gBAAgB,EAChBC,0BAA0B,EAC1BC,oBAAoB,QACjB,qBAAqB;AAC5B,SAASC,kBAAkB,EAAEC,kBAAkB,EAAEC,YAAY,QAAQ,SAAS;;AAE9E;AACA,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;;AAMhC;AACA,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AA+D3B,MAAMC,UAA+B,GAAGC,IAAA,IAalC;EAAA,IAbmC;IACrCC,QAAQ;IACRC,QAAQ;IACRC,cAAc;IACdC,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are const StyledTypewriter: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const StyledTypewriterPseudoText: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const StyledTypewriterText: import("styled-components").StyledComponent<"div", any, {
4
- isAnimatingText: boolean;
5
- } & {
6
- theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
7
- }, never>;
1
+ /// <reference types="react" />
2
+ import type { WithTheme } from '@chayns-components/core';
3
+ export declare const StyledTypewriter: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
4
+ export declare const StyledTypewriterPseudoText: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>;
5
+ type StyledTypewriterTextProps = WithTheme<{
6
+ $isAnimatingText?: boolean;
7
+ $shouldHideCursor?: boolean;
8
+ }>;
9
+ export declare const StyledTypewriterText: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, StyledTypewriterTextProps>>;
10
+ export {};
@@ -1,61 +1,51 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StyledTypewriterText = exports.StyledTypewriterPseudoText = exports.StyledTypewriter = void 0;
7
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
- 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); }
9
- 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; }
10
- const StyledTypewriter = _styledComponents.default.div`
1
+ import styled, { css, keyframes } from 'styled-components';
2
+ export const StyledTypewriter = styled.div`
3
+ align-items: inherit;
4
+ display: flex;
11
5
  position: relative;
6
+ width: 100%;
12
7
  `;
13
- exports.StyledTypewriter = StyledTypewriter;
14
- const blinkAnimation = (0, _styledComponents.keyframes)`
8
+ const blinkAnimation = keyframes`
15
9
  100% {
16
10
  visibility: hidden;
17
11
  }
18
12
  `;
19
- const StyledTypewriterPseudoText = _styledComponents.default.div`
13
+ export const StyledTypewriterPseudoText = styled.span`
20
14
  opacity: 0;
21
15
  pointer-events: none;
22
16
  user-select: none;
23
17
  `;
24
- exports.StyledTypewriterPseudoText = StyledTypewriterPseudoText;
25
- const StyledTypewriterText = _styledComponents.default.div`
26
- color: ${_ref => {
18
+ export const StyledTypewriterText = styled.span`
19
+ color: inherit;
20
+ position: ${_ref => {
27
21
  let {
28
- theme
22
+ $isAnimatingText
29
23
  } = _ref;
30
- return theme.text;
31
- }};
32
- position: ${_ref2 => {
33
- let {
34
- isAnimatingText
35
- } = _ref2;
36
- return isAnimatingText ? 'absolute' : 'relative';
24
+ return $isAnimatingText ? 'absolute' : 'relative';
37
25
  }};
26
+ width: 100%;
38
27
 
39
- ${_ref3 => {
28
+ ${_ref2 => {
40
29
  let {
41
- isAnimatingText
42
- } = _ref3;
43
- return isAnimatingText && (0, _styledComponents.css)`
30
+ $isAnimatingText,
31
+ $shouldHideCursor
32
+ } = _ref2;
33
+ return $isAnimatingText && !$shouldHideCursor && css`
44
34
  &:after {
45
35
  animation: ${blinkAnimation} 1s steps(5, start) infinite;
46
- color: ${_ref4 => {
36
+ color: ${_ref3 => {
47
37
  let {
48
38
  theme
49
- } = _ref4;
39
+ } = _ref3;
50
40
  return theme.text;
51
41
  }};
52
42
  content: '▋';
53
43
  margin-left: 0.25rem;
54
44
  opacity: 0.85;
45
+ position: absolute;
55
46
  vertical-align: baseline;
56
47
  }
57
48
  `;
58
49
  }}
59
50
  `;
60
- exports.StyledTypewriterText = StyledTypewriterText;
61
51
  //# sourceMappingURL=Typewriter.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Typewriter.styles.js","names":["StyledTypewriter","styled","div","blinkAnimation","keyframes","StyledTypewriterPseudoText","StyledTypewriterText","theme","text","isAnimatingText","css"],"sources":["../../../src/components/typewriter/Typewriter.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled, { css, keyframes } from 'styled-components';\n\nexport const StyledTypewriter = styled.div`\n position: relative;\n`;\n\nconst blinkAnimation = keyframes`\n 100% {\n visibility: hidden;\n }\n`;\n\nexport const StyledTypewriterPseudoText = styled.div`\n opacity: 0;\n pointer-events: none;\n user-select: none;\n`;\n\ntype StyledTypewriterTextProps = WithTheme<{\n isAnimatingText: boolean;\n}>;\n\nexport const StyledTypewriterText = styled.div<StyledTypewriterTextProps>`\n color: ${({ theme }: StyledTypewriterTextProps) => theme.text};\n position: ${({ isAnimatingText }) => (isAnimatingText ? 'absolute' : 'relative')};\n\n ${({ isAnimatingText }) =>\n isAnimatingText &&\n css`\n &:after {\n animation: ${blinkAnimation} 1s steps(5, start) infinite;\n color: ${({ theme }: StyledTypewriterTextProps) => theme.text};\n content: '▋';\n margin-left: 0.25rem;\n opacity: 0.85;\n vertical-align: baseline;\n }\n `}\n`;\n"],"mappings":";;;;;;AACA;AAA2D;AAAA;AAEpD,MAAMA,gBAAgB,GAAGC,yBAAM,CAACC,GAAI;AAC3C;AACA,CAAC;AAAC;AAEF,MAAMC,cAAc,GAAG,IAAAC,2BAAS,CAAC;AACjC;AACA;AACA;AACA,CAAC;AAEM,MAAMC,0BAA0B,GAAGJ,yBAAM,CAACC,GAAI;AACrD;AACA;AACA;AACA,CAAC;AAAC;AAMK,MAAMI,oBAAoB,GAAGL,yBAAM,CAACC,GAA+B;AAC1E,aAAa;EAAA,IAAC;IAAEK;EAAiC,CAAC;EAAA,OAAKA,KAAK,CAACC,IAAI;AAAA,CAAC;AAClE,gBAAgB;EAAA,IAAC;IAAEC;EAAgB,CAAC;EAAA,OAAMA,eAAe,GAAG,UAAU,GAAG,UAAU;AAAA,CAAE;AACrF;AACA,MAAM;EAAA,IAAC;IAAEA;EAAgB,CAAC;EAAA,OAClBA,eAAe,IACf,IAAAC,qBAAG,CAAC;AACZ;AACA,6BAA6BP,cAAe;AAC5C,yBAAyB;IAAA,IAAC;MAAEI;IAAiC,CAAC;IAAA,OAAKA,KAAK,CAACC,IAAI;EAAA,CAAC;AAC9E;AACA;AACA;AACA;AACA;AACA,SAAS;AAAA,CAAC;AACV,CAAC;AAAC"}
1
+ {"version":3,"file":"Typewriter.styles.js","names":["styled","css","keyframes","StyledTypewriter","div","blinkAnimation","StyledTypewriterPseudoText","span","StyledTypewriterText","_ref","$isAnimatingText","_ref2","$shouldHideCursor","_ref3","theme","text"],"sources":["../../../src/components/typewriter/Typewriter.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled, { css, keyframes } from 'styled-components';\n\nexport const StyledTypewriter = styled.div`\n align-items: inherit;\n display: flex;\n position: relative;\n width: 100%;\n`;\n\nconst blinkAnimation = keyframes`\n 100% {\n visibility: hidden;\n }\n`;\n\nexport const StyledTypewriterPseudoText = styled.span`\n opacity: 0;\n pointer-events: none;\n user-select: none;\n`;\n\ntype StyledTypewriterTextProps = WithTheme<{\n $isAnimatingText?: boolean;\n $shouldHideCursor?: boolean;\n}>;\n\nexport const StyledTypewriterText = styled.span<StyledTypewriterTextProps>`\n color: inherit;\n position: ${({ $isAnimatingText }) => ($isAnimatingText ? 'absolute' : 'relative')};\n width: 100%;\n\n ${({ $isAnimatingText, $shouldHideCursor }) =>\n $isAnimatingText &&\n !$shouldHideCursor &&\n css`\n &:after {\n animation: ${blinkAnimation} 1s steps(5, start) infinite;\n color: ${({ theme }: StyledTypewriterTextProps) => theme.text};\n content: '▋';\n margin-left: 0.25rem;\n opacity: 0.85;\n position: absolute;\n vertical-align: baseline;\n }\n `}\n`;\n"],"mappings":"AACA,OAAOA,MAAM,IAAIC,GAAG,EAAEC,SAAS,QAAQ,mBAAmB;AAE1D,OAAO,MAAMC,gBAAgB,GAAGH,MAAM,CAACI,GAAI;AAC3C;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,cAAc,GAAGH,SAAU;AACjC;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMI,0BAA0B,GAAGN,MAAM,CAACO,IAAK;AACtD;AACA;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,oBAAoB,GAAGR,MAAM,CAACO,IAAgC;AAC3E;AACA,gBAAgBE,IAAA;EAAA,IAAC;IAAEC;EAAiB,CAAC,GAAAD,IAAA;EAAA,OAAMC,gBAAgB,GAAG,UAAU,GAAG,UAAU;AAAA,CAAE;AACvF;AACA;AACA,MAAMC,KAAA;EAAA,IAAC;IAAED,gBAAgB;IAAEE;EAAkB,CAAC,GAAAD,KAAA;EAAA,OACtCD,gBAAgB,IAChB,CAACE,iBAAiB,IAClBX,GAAI;AACZ;AACA,6BAA6BI,cAAe;AAC5C,yBAAyBQ,KAAA;IAAA,IAAC;MAAEC;IAAiC,CAAC,GAAAD,KAAA;IAAA,OAAKC,KAAK,CAACC,IAAI;EAAA,CAAC;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AAAA,CAAC;AACV,CAAC"}
@@ -9,3 +9,5 @@
9
9
  * @return string - The text part with the specified length - additionally the HTML elements are added
10
10
  */
11
11
  export declare const getSubTextFromHTML: (html: string, length: number) => string;
12
+ export declare const getCharactersCount: (html: string) => number;
13
+ export declare const shuffleArray: <T>(array: T[]) => T[];
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSubTextFromHTML = void 0;
7
1
  /**
8
2
  * This function extracts a part of the text from an HTML text. The HTML elements themselves are
9
3
  * returned in the result. In addition, the function ensures that the closing tag of the Bold HTML
@@ -14,14 +8,14 @@ exports.getSubTextFromHTML = void 0;
14
8
  *
15
9
  * @return string - The text part with the specified length - additionally the HTML elements are added
16
10
  */
17
- const getSubTextFromHTML = (html, length) => {
11
+ export const getSubTextFromHTML = (html, length) => {
18
12
  const div = document.createElement('div');
19
13
  div.innerHTML = html;
20
14
  let text = '';
21
15
  let currLength = 0;
22
- const traverse = node => {
23
- if (node.nodeType === 3 && typeof node.textContent === 'string') {
24
- const nodeText = node.textContent;
16
+ const traverse = element => {
17
+ if (element.nodeType === 3 && typeof element.textContent === 'string') {
18
+ const nodeText = element.textContent;
25
19
  if (currLength + nodeText.length <= length) {
26
20
  text += nodeText;
27
21
  currLength += nodeText.length;
@@ -29,11 +23,19 @@ const getSubTextFromHTML = (html, length) => {
29
23
  text += nodeText.substring(0, length - currLength);
30
24
  return false;
31
25
  }
32
- } else if (node.nodeType === 1) {
33
- const nodeName = node.nodeName.toLowerCase();
34
- text += `<${nodeName}>`;
35
- for (let i = 0; i < node.childNodes.length; i++) {
36
- const childNode = node.childNodes[i];
26
+ } else if (element.nodeType === 1) {
27
+ const nodeName = element.nodeName.toLowerCase();
28
+ let attributes = '';
29
+
30
+ // @ts-expect-error: Type is correct here
31
+ // eslint-disable-next-line no-restricted-syntax
32
+ for (const attribute of element.attributes) {
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/restrict-template-expressions
34
+ attributes += ` ${attribute.name}="${attribute.value}"`;
35
+ }
36
+ text += `<${nodeName}${attributes}>`;
37
+ for (let i = 0; i < element.childNodes.length; i++) {
38
+ const childNode = element.childNodes[i];
37
39
  if (childNode && !traverse(childNode)) {
38
40
  return false;
39
41
  }
@@ -50,5 +52,30 @@ const getSubTextFromHTML = (html, length) => {
50
52
  }
51
53
  return text;
52
54
  };
53
- exports.getSubTextFromHTML = getSubTextFromHTML;
55
+ export const getCharactersCount = html => {
56
+ const div = document.createElement('div');
57
+ div.innerHTML = html;
58
+ let count = 0;
59
+ const traverse = node => {
60
+ if (node.nodeType === 3 && typeof node.textContent === 'string') {
61
+ count += node.textContent.trim().length;
62
+ } else if (node.nodeType === 1) {
63
+ if (node.nodeName === 'CODE' && node.textContent !== null) {
64
+ count += node.textContent.length;
65
+ return;
66
+ }
67
+ Array.from(node.childNodes).forEach(traverse);
68
+ }
69
+ };
70
+ Array.from(div.childNodes).forEach(traverse);
71
+ return count;
72
+ };
73
+ export const shuffleArray = array => {
74
+ const result = Array.from(array);
75
+ for (let i = result.length - 1; i > 0; i--) {
76
+ const j = Math.floor(Math.random() * (i + 1));
77
+ [result[i], result[j]] = [result[j], result[i]];
78
+ }
79
+ return result;
80
+ };
54
81
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["getSubTextFromHTML","html","length","div","document","createElement","innerHTML","text","currLength","traverse","node","nodeType","textContent","nodeText","substring","nodeName","toLowerCase","i","childNodes","childNode"],"sources":["../../../src/components/typewriter/utils.ts"],"sourcesContent":["/**\n * This function extracts a part of the text from an HTML text. The HTML elements themselves are\n * returned in the result. In addition, the function ensures that the closing tag of the Bold HTML\n * element is also returned for text that is cut off in the middle of a Bold element, for example.\n *\n * @param html - The text from which a part should be taken\n * @param length - The length of the text to be extracted\n *\n * @return string - The text part with the specified length - additionally the HTML elements are added\n */\nexport const getSubTextFromHTML = (html: string, length: number): string => {\n const div = document.createElement('div');\n\n div.innerHTML = html;\n\n let text = '';\n let currLength = 0;\n\n const traverse = (node: Node): boolean => {\n if (node.nodeType === 3 && typeof node.textContent === 'string') {\n const nodeText = node.textContent;\n\n if (currLength + nodeText.length <= length) {\n text += nodeText;\n currLength += nodeText.length;\n } else {\n text += nodeText.substring(0, length - currLength);\n\n return false;\n }\n } else if (node.nodeType === 1) {\n const nodeName = node.nodeName.toLowerCase();\n\n text += `<${nodeName}>`;\n\n for (let i = 0; i < node.childNodes.length; i++) {\n const childNode = node.childNodes[i];\n\n if (childNode && !traverse(childNode)) {\n return false;\n }\n }\n\n text += `</${nodeName}>`;\n }\n\n return true;\n };\n\n for (let i = 0; i < div.childNodes.length; i++) {\n const childNode = div.childNodes[i];\n\n if (childNode && !traverse(childNode)) {\n return text;\n }\n }\n\n return text;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAG,CAACC,IAAY,EAAEC,MAAc,KAAa;EACxE,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAEzCF,GAAG,CAACG,SAAS,GAAGL,IAAI;EAEpB,IAAIM,IAAI,GAAG,EAAE;EACb,IAAIC,UAAU,GAAG,CAAC;EAElB,MAAMC,QAAQ,GAAIC,IAAU,IAAc;IACtC,IAAIA,IAAI,CAACC,QAAQ,KAAK,CAAC,IAAI,OAAOD,IAAI,CAACE,WAAW,KAAK,QAAQ,EAAE;MAC7D,MAAMC,QAAQ,GAAGH,IAAI,CAACE,WAAW;MAEjC,IAAIJ,UAAU,GAAGK,QAAQ,CAACX,MAAM,IAAIA,MAAM,EAAE;QACxCK,IAAI,IAAIM,QAAQ;QAChBL,UAAU,IAAIK,QAAQ,CAACX,MAAM;MACjC,CAAC,MAAM;QACHK,IAAI,IAAIM,QAAQ,CAACC,SAAS,CAAC,CAAC,EAAEZ,MAAM,GAAGM,UAAU,CAAC;QAElD,OAAO,KAAK;MAChB;IACJ,CAAC,MAAM,IAAIE,IAAI,CAACC,QAAQ,KAAK,CAAC,EAAE;MAC5B,MAAMI,QAAQ,GAAGL,IAAI,CAACK,QAAQ,CAACC,WAAW,EAAE;MAE5CT,IAAI,IAAK,IAAGQ,QAAS,GAAE;MAEvB,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,IAAI,CAACQ,UAAU,CAAChB,MAAM,EAAEe,CAAC,EAAE,EAAE;QAC7C,MAAME,SAAS,GAAGT,IAAI,CAACQ,UAAU,CAACD,CAAC,CAAC;QAEpC,IAAIE,SAAS,IAAI,CAACV,QAAQ,CAACU,SAAS,CAAC,EAAE;UACnC,OAAO,KAAK;QAChB;MACJ;MAEAZ,IAAI,IAAK,KAAIQ,QAAS,GAAE;IAC5B;IAEA,OAAO,IAAI;EACf,CAAC;EAED,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGd,GAAG,CAACe,UAAU,CAAChB,MAAM,EAAEe,CAAC,EAAE,EAAE;IAC5C,MAAME,SAAS,GAAGhB,GAAG,CAACe,UAAU,CAACD,CAAC,CAAC;IAEnC,IAAIE,SAAS,IAAI,CAACV,QAAQ,CAACU,SAAS,CAAC,EAAE;MACnC,OAAOZ,IAAI;IACf;EACJ;EAEA,OAAOA,IAAI;AACf,CAAC;AAAC"}
1
+ {"version":3,"file":"utils.js","names":["getSubTextFromHTML","html","length","div","document","createElement","innerHTML","text","currLength","traverse","element","nodeType","textContent","nodeText","substring","nodeName","toLowerCase","attributes","attribute","name","value","i","childNodes","childNode","getCharactersCount","count","node","trim","Array","from","forEach","shuffleArray","array","result","j","Math","floor","random"],"sources":["../../../src/components/typewriter/utils.ts"],"sourcesContent":["/**\n * This function extracts a part of the text from an HTML text. The HTML elements themselves are\n * returned in the result. In addition, the function ensures that the closing tag of the Bold HTML\n * element is also returned for text that is cut off in the middle of a Bold element, for example.\n *\n * @param html - The text from which a part should be taken\n * @param length - The length of the text to be extracted\n *\n * @return string - The text part with the specified length - additionally the HTML elements are added\n */\nexport const getSubTextFromHTML = (html: string, length: number): string => {\n const div = document.createElement('div');\n\n div.innerHTML = html;\n\n let text = '';\n let currLength = 0;\n\n const traverse = (element: Element): boolean => {\n if (element.nodeType === 3 && typeof element.textContent === 'string') {\n const nodeText = element.textContent;\n\n if (currLength + nodeText.length <= length) {\n text += nodeText;\n currLength += nodeText.length;\n } else {\n text += nodeText.substring(0, length - currLength);\n\n return false;\n }\n } else if (element.nodeType === 1) {\n const nodeName = element.nodeName.toLowerCase();\n\n let attributes = '';\n\n // @ts-expect-error: Type is correct here\n // eslint-disable-next-line no-restricted-syntax\n for (const attribute of element.attributes) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/restrict-template-expressions\n attributes += ` ${attribute.name}=\"${attribute.value}\"`;\n }\n\n text += `<${nodeName}${attributes}>`;\n\n for (let i = 0; i < element.childNodes.length; i++) {\n const childNode = element.childNodes[i];\n\n if (childNode && !traverse(childNode as Element)) {\n return false;\n }\n }\n\n text += `</${nodeName}>`;\n }\n\n return true;\n };\n\n for (let i = 0; i < div.childNodes.length; i++) {\n const childNode = div.childNodes[i];\n\n if (childNode && !traverse(childNode as Element)) {\n return text;\n }\n }\n\n return text;\n};\n\nexport const getCharactersCount = (html: string): number => {\n const div = document.createElement('div');\n\n div.innerHTML = html;\n\n let count = 0;\n\n const traverse = (node: Node): void => {\n if (node.nodeType === 3 && typeof node.textContent === 'string') {\n count += node.textContent.trim().length;\n } else if (node.nodeType === 1) {\n if (node.nodeName === 'CODE' && node.textContent !== null) {\n count += node.textContent.length;\n\n return;\n }\n\n Array.from(node.childNodes).forEach(traverse);\n }\n };\n\n Array.from(div.childNodes).forEach(traverse);\n\n return count;\n};\n\nexport const shuffleArray = <T>(array: T[]): T[] => {\n const result = Array.from(array);\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n\n [result[i], result[j]] = [result[j]!, result[i]!];\n }\n\n return result;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,IAAI,CAAC1B,GAAG,CAACmB,UAAU,CAAC,CAACQ,OAAO,CAACrB,QAAQ,CAAC;EAE5C,OAAOgB,KAAK;AAChB,CAAC;AAED,OAAO,MAAMM,YAAY,GAAOC,KAAU,IAAU;EAChD,MAAMC,MAAM,GAAGL,KAAK,CAACC,IAAI,CAACG,KAAK,CAAC;EAEhC,KAAK,IAAIX,CAAC,GAAGY,MAAM,CAAC/B,MAAM,GAAG,CAAC,EAAEmB,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;IACxC,MAAMa,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,IAAIhB,CAAC,GAAG,CAAC,CAAC,CAAC;IAE7C,CAACY,MAAM,CAACZ,CAAC,CAAC,EAAEY,MAAM,CAACC,CAAC,CAAC,CAAC,GAAG,CAACD,MAAM,CAACC,CAAC,CAAC,EAAGD,MAAM,CAACZ,CAAC,CAAC,CAAE;EACrD;EAEA,OAAOY,MAAM;AACjB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default as Typewriter } from './components/typewriter/Typewriter';
1
+ export { default as Typewriter, TypewriterSpeed } from './components/typewriter/Typewriter';
package/lib/index.js CHANGED
@@ -1,14 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Typewriter", {
7
- enumerable: true,
8
- get: function () {
9
- return _Typewriter.default;
10
- }
11
- });
12
- var _Typewriter = _interopRequireDefault(require("./components/typewriter/Typewriter"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ export { default as Typewriter, TypewriterSpeed } from './components/typewriter/Typewriter';
14
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default as Typewriter } from './components/typewriter/Typewriter';\n"],"mappings":";;;;;;;;;;;AAAA;AAA2E"}
1
+ {"version":3,"file":"index.js","names":["default","Typewriter","TypewriterSpeed"],"sources":["../src/index.ts"],"sourcesContent":["export { default as Typewriter, TypewriterSpeed } from './components/typewriter/Typewriter';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,EAAEC,eAAe,QAAQ,oCAAoC"}
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@chayns-components/typewriter",
3
- "version": "5.0.0-beta.54",
3
+ "version": "5.0.0-beta.541",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
+ "sideEffects": false,
6
+ "browserslist": [
7
+ ">0.5%",
8
+ "not dead",
9
+ "not op_mini all",
10
+ "not IE 11"
11
+ ],
5
12
  "keywords": [
6
13
  "chayns",
7
14
  "react",
@@ -33,35 +40,34 @@
33
40
  "url": "https://github.com/TobitSoftware/chayns-components/issues"
34
41
  },
35
42
  "devDependencies": {
36
- "@babel/cli": "^7.20.7",
37
- "@babel/core": "^7.20.12",
38
- "@babel/preset-env": "^7.20.2",
39
- "@babel/preset-react": "^7.18.6",
40
- "@babel/preset-typescript": "^7.18.6",
41
- "@types/react": "^17.0.53",
42
- "@types/react-dom": "^17.0.18",
43
- "@types/styled-components": "^5.1.26",
44
- "@types/uuid": "^9.0.0",
45
- "babel-loader": "^8.3.0",
46
- "lerna": "^6.4.1",
47
- "react": "^17.0.2",
48
- "react-dom": "^17.0.2",
49
- "typescript": "^4.9.5"
43
+ "@babel/cli": "^7.23.9",
44
+ "@babel/core": "^7.23.9",
45
+ "@babel/preset-env": "^7.23.9",
46
+ "@babel/preset-react": "^7.23.3",
47
+ "@babel/preset-typescript": "^7.23.3",
48
+ "@types/react": "^18.2.57",
49
+ "@types/react-dom": "^18.2.19",
50
+ "@types/styled-components": "^5.1.34",
51
+ "@types/uuid": "^9.0.8",
52
+ "babel-loader": "^9.1.3",
53
+ "lerna": "^8.1.2",
54
+ "react": "^18.2.0",
55
+ "react-dom": "^18.2.0",
56
+ "styled-components": "^6.1.8",
57
+ "typescript": "^5.3.3"
50
58
  },
51
59
  "dependencies": {
52
- "@chayns-components/core": "^5.0.0-beta.54",
53
- "@chayns/colors": "^2.0.0",
54
- "clsx": "^1.2.1",
55
- "framer-motion": "^6.5.1",
56
- "styled-components": "^5.3.6",
57
- "uuid": "^9.0.0"
60
+ "@chayns-components/core": "^5.0.0-beta.541"
58
61
  },
59
62
  "peerDependencies": {
63
+ "chayns-api": ">=1.0.50",
64
+ "framer-motion": ">=10.18.0",
60
65
  "react": ">=16.14.0",
61
- "react-dom": ">=16.14.0"
66
+ "react-dom": ">=16.14.0",
67
+ "styled-components": ">=5.3.11"
62
68
  },
63
69
  "publishConfig": {
64
70
  "access": "public"
65
71
  },
66
- "gitHead": "5938050611ab8bd504ef5b610189548d5a62ba7d"
72
+ "gitHead": "26fa52ee4630cf44ac662066594254f69b7ac3bf"
67
73
  }