@chayns-components/typewriter 5.0.51 → 5.0.53-alpha.0
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/lib/cjs/components/typewriter/Typewriter.js +66 -216
- package/lib/cjs/components/typewriter/Typewriter.js.map +1 -1
- package/lib/cjs/components/typewriter/typewrite-view/TypewriterView.js +55 -0
- package/lib/cjs/components/typewriter/typewrite-view/TypewriterView.js.map +1 -0
- package/lib/cjs/components/typewriter/{Typewriter.styles.js → typewrite-view/TypewriterView.styles.js} +2 -2
- package/lib/cjs/components/typewriter/typewrite-view/TypewriterView.styles.js.map +1 -0
- package/lib/cjs/components/typewriter/{AnimatedTypewriterText.js → typewrite-view/animated-typewriter-text/AnimatedTypewriterText.js} +2 -2
- package/lib/cjs/components/typewriter/typewrite-view/animated-typewriter-text/AnimatedTypewriterText.js.map +1 -0
- package/lib/cjs/hooks/useChunkStreamingSpeed.js +36 -0
- package/lib/cjs/hooks/useChunkStreamingSpeed.js.map +1 -0
- package/lib/cjs/hooks/useTypewriterAnimation.js +185 -0
- package/lib/cjs/hooks/useTypewriterAnimation.js.map +1 -0
- package/lib/cjs/{components/typewriter → utils}/utils.js +7 -24
- package/lib/cjs/utils/utils.js.map +1 -0
- package/lib/esm/components/typewriter/Typewriter.js +69 -219
- package/lib/esm/components/typewriter/Typewriter.js.map +1 -1
- package/lib/esm/components/typewriter/typewrite-view/TypewriterView.js +48 -0
- package/lib/esm/components/typewriter/typewrite-view/TypewriterView.js.map +1 -0
- package/lib/esm/components/typewriter/{Typewriter.styles.js → typewrite-view/TypewriterView.styles.js} +2 -2
- package/lib/esm/components/typewriter/typewrite-view/TypewriterView.styles.js.map +1 -0
- package/lib/esm/components/typewriter/{AnimatedTypewriterText.js → typewrite-view/animated-typewriter-text/AnimatedTypewriterText.js} +1 -1
- package/lib/esm/components/typewriter/typewrite-view/animated-typewriter-text/AnimatedTypewriterText.js.map +1 -0
- package/lib/esm/hooks/useChunkStreamingSpeed.js +30 -0
- package/lib/esm/hooks/useChunkStreamingSpeed.js.map +1 -0
- package/lib/esm/hooks/useTypewriterAnimation.js +178 -0
- package/lib/esm/hooks/useTypewriterAnimation.js.map +1 -0
- package/lib/esm/{components/typewriter → utils}/utils.js +5 -22
- package/lib/esm/utils/utils.js.map +1 -0
- package/lib/types/components/typewriter/typewrite-view/TypewriterView.d.ts +19 -0
- package/lib/types/components/typewriter/{Typewriter.styles.d.ts → typewrite-view/TypewriterView.styles.d.ts} +1 -1
- package/lib/types/hooks/useChunkStreamingSpeed.d.ts +7 -0
- package/lib/types/hooks/useTypewriterAnimation.d.ts +35 -0
- package/lib/types/{components/typewriter → utils}/utils.d.ts +1 -4
- package/package.json +3 -3
- package/lib/cjs/components/typewriter/AnimatedTypewriterText.js.map +0 -1
- package/lib/cjs/components/typewriter/Typewriter.styles.js.map +0 -1
- package/lib/cjs/components/typewriter/utils.js.map +0 -1
- package/lib/esm/components/typewriter/AnimatedTypewriterText.js.map +0 -1
- package/lib/esm/components/typewriter/Typewriter.styles.js.map +0 -1
- package/lib/esm/components/typewriter/utils.js.map +0 -1
- /package/lib/types/components/typewriter/{AnimatedTypewriterText.d.ts → typewrite-view/animated-typewriter-text/AnimatedTypewriterText.d.ts} +0 -0
|
@@ -7,16 +7,14 @@ exports.default = void 0;
|
|
|
7
7
|
var _core = require("@chayns-components/core");
|
|
8
8
|
var _chaynsApi = require("chayns-api");
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactDom = require("react-dom");
|
|
11
10
|
var _server = require("react-dom/server");
|
|
12
11
|
var _cursor = require("../../types/cursor");
|
|
13
12
|
var _speed = require("../../types/speed");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var _utils = require("
|
|
13
|
+
var _TypewriterView = _interopRequireDefault(require("./typewrite-view/TypewriterView"));
|
|
14
|
+
var _useTypewriterAnimation = _interopRequireDefault(require("../../hooks/useTypewriterAnimation"));
|
|
15
|
+
var _utils = require("../../utils/utils");
|
|
17
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
|
|
20
18
|
const Typewriter = ({
|
|
21
19
|
children,
|
|
22
20
|
cursorType = _cursor.CursorType.Default,
|
|
@@ -43,252 +41,104 @@ const Typewriter = ({
|
|
|
43
41
|
shouldCalcAutoSpeed = false,
|
|
44
42
|
autoSpeedBaseFactor = 2000
|
|
45
43
|
}) => {
|
|
46
|
-
var _colorScheme$
|
|
44
|
+
var _colorScheme$designSe3, _colorScheme$designSe4;
|
|
47
45
|
const [currentChildrenIndex, setCurrentChildrenIndex] = (0, _react.useState)(0);
|
|
48
|
-
const [hasRenderedChildrenOnce, setHasRenderedChildrenOnce] = (0, _react.useState)(false);
|
|
49
|
-
const [shouldPreventBlinkingCursor, setShouldPreventBlinkingCursor] = (0, _react.useState)(false);
|
|
50
|
-
const [isResetAnimationActive, setIsResetAnimationActive] = (0, _react.useState)(false);
|
|
51
|
-
const [shouldStopAnimation, setShouldStopAnimation] = (0, _react.useState)(false);
|
|
52
|
-
const autoSpeed = (0, _react.useRef)();
|
|
53
|
-
const autoSteps = (0, _react.useRef)(animationSteps);
|
|
54
46
|
const functions = (0, _chaynsApi.useFunctions)();
|
|
55
47
|
const values = (0, _chaynsApi.useValues)();
|
|
56
48
|
const colorScheme = (0, _core.useColorScheme)();
|
|
57
|
-
useIsomorphicLayoutEffect(() => {
|
|
58
|
-
if (children) {
|
|
59
|
-
setHasRenderedChildrenOnce(false);
|
|
60
|
-
}
|
|
61
|
-
}, [children]);
|
|
62
|
-
(0, _react.useEffect)(() => {
|
|
63
|
-
if (!hasRenderedChildrenOnce) {
|
|
64
|
-
setHasRenderedChildrenOnce(true);
|
|
65
|
-
}
|
|
66
|
-
}, [hasRenderedChildrenOnce]);
|
|
67
49
|
const sortedChildren = (0, _react.useMemo)(() => Array.isArray(children) && shouldSortChildrenRandomly ? (0, _utils.shuffleArray)(children) : children, [children, shouldSortChildrenRandomly]);
|
|
68
50
|
const areMultipleChildrenGiven = Array.isArray(sortedChildren);
|
|
69
51
|
const childrenCount = areMultipleChildrenGiven ? sortedChildren.length : 1;
|
|
70
|
-
const
|
|
71
|
-
var _colorScheme$
|
|
72
|
-
|
|
73
|
-
const currentChildren = sortedChildren[currentChildrenIndex];
|
|
74
|
-
if (currentChildren) {
|
|
75
|
-
var _colorScheme$designSe, _colorScheme$designSe2;
|
|
76
|
-
return /*#__PURE__*/_react.default.isValidElement(currentChildren) ? (0, _server.renderToString)(/*#__PURE__*/_react.default.createElement(_chaynsApi.ChaynsProvider, {
|
|
77
|
-
data: values,
|
|
78
|
-
functions: functions,
|
|
79
|
-
isModule: true
|
|
80
|
-
}, /*#__PURE__*/_react.default.createElement(_core.ColorSchemeProvider, {
|
|
81
|
-
color: colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe = colorScheme.designSettings) === null || _colorScheme$designSe === void 0 ? void 0 : _colorScheme$designSe.color,
|
|
82
|
-
colorMode: colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe2 = colorScheme.designSettings) === null || _colorScheme$designSe2 === void 0 ? void 0 : _colorScheme$designSe2.colorMode,
|
|
83
|
-
style: {
|
|
84
|
-
display: 'inline'
|
|
85
|
-
}
|
|
86
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
87
|
-
className: "notranslate"
|
|
88
|
-
}, currentChildren)))) : currentChildren;
|
|
89
|
-
}
|
|
90
|
-
return '';
|
|
91
|
-
}
|
|
92
|
-
return /*#__PURE__*/_react.default.isValidElement(sortedChildren) ? (0, _server.renderToString)(/*#__PURE__*/_react.default.createElement(_chaynsApi.ChaynsProvider, {
|
|
52
|
+
const renderChildToString = (0, _react.useCallback)(child => {
|
|
53
|
+
var _colorScheme$designSe, _colorScheme$designSe2;
|
|
54
|
+
return /*#__PURE__*/_react.default.isValidElement(child) ? (0, _server.renderToString)(/*#__PURE__*/_react.default.createElement(_chaynsApi.ChaynsProvider, {
|
|
93
55
|
data: values,
|
|
94
56
|
functions: functions,
|
|
95
57
|
isModule: true
|
|
96
58
|
}, /*#__PURE__*/_react.default.createElement(_core.ColorSchemeProvider, {
|
|
97
|
-
color: colorScheme === null || colorScheme === void 0 || (_colorScheme$
|
|
98
|
-
colorMode: colorScheme === null || colorScheme === void 0 || (_colorScheme$
|
|
59
|
+
color: colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe = colorScheme.designSettings) === null || _colorScheme$designSe === void 0 ? void 0 : _colorScheme$designSe.color,
|
|
60
|
+
colorMode: colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe2 = colorScheme.designSettings) === null || _colorScheme$designSe2 === void 0 ? void 0 : _colorScheme$designSe2.colorMode,
|
|
99
61
|
style: {
|
|
100
62
|
display: 'inline'
|
|
101
63
|
}
|
|
102
64
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
103
65
|
className: "notranslate"
|
|
104
|
-
},
|
|
105
|
-
}, [
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
lastLength: charactersCount,
|
|
109
|
-
ema: charactersCount / (autoSpeedBaseFactor / 1000)
|
|
110
|
-
});
|
|
111
|
-
const [shownCharCount, setShownCharCount] = (0, _react.useState)(charactersCount > 0 ? 0 : textContent.length);
|
|
112
|
-
const currentPosition = (0, _react.useRef)(0);
|
|
113
|
-
(0, _react.useEffect)(() => {
|
|
114
|
-
if (shouldUseResetAnimation) {
|
|
115
|
-
chunkIntervalExponentialMovingAverage.current = {
|
|
116
|
-
ema: charactersCount / (autoSpeedBaseFactor / 1000),
|
|
117
|
-
lastLength: charactersCount
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
chunkIntervalExponentialMovingAverage.current = (0, _utils.updateChunkStreamingSpeedEMA)({
|
|
121
|
-
currentLength: charactersCount,
|
|
122
|
-
state: chunkIntervalExponentialMovingAverage.current
|
|
123
|
-
});
|
|
124
|
-
}, [autoSpeedBaseFactor, charactersCount, shouldUseResetAnimation]);
|
|
125
|
-
(0, _react.useEffect)(() => {
|
|
126
|
-
if (!shouldCalcAutoSpeed) {
|
|
127
|
-
autoSpeed.current = undefined;
|
|
128
|
-
autoSteps.current = animationSteps;
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const {
|
|
132
|
-
speed: calculatedAutoSpeed,
|
|
133
|
-
steps
|
|
134
|
-
} = (0, _utils.calculateAutoSpeed)(chunkIntervalExponentialMovingAverage.current.ema);
|
|
135
|
-
autoSpeed.current = calculatedAutoSpeed;
|
|
136
|
-
autoSteps.current = steps;
|
|
137
|
-
}, [animationSteps, charactersCount, shouldCalcAutoSpeed]);
|
|
138
|
-
const isAnimatingText = shownCharCount < textContent.length || shouldForceCursorAnimation || areMultipleChildrenGiven || textContent.length === 0;
|
|
139
|
-
const handleClick = (0, _react.useCallback)(event => {
|
|
140
|
-
event.stopPropagation();
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
setShouldStopAnimation(true);
|
|
143
|
-
}, []);
|
|
144
|
-
const handleSetNextChildrenIndex = (0, _react.useCallback)(() => setCurrentChildrenIndex(() => {
|
|
145
|
-
let newIndex = currentChildrenIndex + 1;
|
|
66
|
+
}, child)))) : child;
|
|
67
|
+
}, [colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe3 = colorScheme.designSettings) === null || _colorScheme$designSe3 === void 0 ? void 0 : _colorScheme$designSe3.color, colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe4 = colorScheme.designSettings) === null || _colorScheme$designSe4 === void 0 ? void 0 : _colorScheme$designSe4.colorMode, functions, values]);
|
|
68
|
+
const handleSetNextChildrenIndex = (0, _react.useCallback)(() => setCurrentChildrenIndex(prevIndex => {
|
|
69
|
+
let newIndex = prevIndex + 1;
|
|
146
70
|
if (newIndex > childrenCount - 1) {
|
|
147
71
|
newIndex = 0;
|
|
148
72
|
}
|
|
149
73
|
return newIndex;
|
|
150
|
-
}), [childrenCount
|
|
151
|
-
(0, _react.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
} else if (isResetAnimationActive) {
|
|
157
|
-
if (typeof onResetAnimationStart === 'function') {
|
|
158
|
-
onResetAnimationStart();
|
|
159
|
-
}
|
|
160
|
-
interval = window.setInterval(() => {
|
|
161
|
-
setShownCharCount(prevState => {
|
|
162
|
-
const nextState = prevState - autoSteps.current;
|
|
163
|
-
currentPosition.current = nextState;
|
|
164
|
-
if (nextState === 0) {
|
|
165
|
-
window.clearInterval(interval);
|
|
166
|
-
if (typeof onResetAnimationEnd === 'function') {
|
|
167
|
-
onResetAnimationEnd();
|
|
168
|
-
}
|
|
169
|
-
if (areMultipleChildrenGiven) {
|
|
170
|
-
setTimeout(() => {
|
|
171
|
-
setIsResetAnimationActive(false);
|
|
172
|
-
handleSetNextChildrenIndex();
|
|
173
|
-
}, nextTextDelay);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return nextState;
|
|
177
|
-
});
|
|
178
|
-
}, resetSpeed);
|
|
179
|
-
} else {
|
|
180
|
-
const startTypingAnimation = () => {
|
|
181
|
-
if (cursorType === _cursor.CursorType.Thin) {
|
|
182
|
-
setShouldPreventBlinkingCursor(true);
|
|
183
|
-
}
|
|
184
|
-
if (typeof onTypingAnimationStart === 'function') {
|
|
185
|
-
onTypingAnimationStart();
|
|
186
|
-
}
|
|
187
|
-
const runTypingInterval = () => {
|
|
188
|
-
setShownCharCount(prevState => {
|
|
189
|
-
let nextState = Math.min(prevState + autoSteps.current, charactersCount);
|
|
190
|
-
if (nextState >= charactersCount && !shouldWaitForContent) {
|
|
191
|
-
window.clearInterval(interval);
|
|
192
|
-
if (cursorType === _cursor.CursorType.Thin) {
|
|
193
|
-
setShouldPreventBlinkingCursor(false);
|
|
194
|
-
}
|
|
195
|
-
if (typeof onTypingAnimationEnd === 'function') {
|
|
196
|
-
onTypingAnimationEnd();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* At this point, the next value for "shownCharCount" is deliberately set to
|
|
201
|
-
* the length of the textContent to correctly display HTML elements
|
|
202
|
-
* after the last letter.
|
|
203
|
-
*/
|
|
204
|
-
nextState = textContent.length;
|
|
205
|
-
if (areMultipleChildrenGiven) {
|
|
206
|
-
setTimeout(() => {
|
|
207
|
-
if (shouldUseResetAnimation) {
|
|
208
|
-
setIsResetAnimationActive(true);
|
|
209
|
-
} else {
|
|
210
|
-
setShownCharCount(0);
|
|
211
|
-
setTimeout(handleSetNextChildrenIndex, nextTextDelay);
|
|
212
|
-
}
|
|
213
|
-
}, resetDelay);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
currentPosition.current = nextState;
|
|
217
|
-
return nextState;
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
interval = window.setInterval(runTypingInterval, autoSpeed.current ?? speed);
|
|
221
|
-
};
|
|
222
|
-
if (startDelay) {
|
|
223
|
-
setTimeout(startTypingAnimation, startDelay);
|
|
224
|
-
} else {
|
|
225
|
-
startTypingAnimation();
|
|
74
|
+
}), [childrenCount]);
|
|
75
|
+
const textContent = (0, _react.useMemo)(() => {
|
|
76
|
+
if (areMultipleChildrenGiven) {
|
|
77
|
+
const currentChildren = sortedChildren[currentChildrenIndex];
|
|
78
|
+
if (currentChildren) {
|
|
79
|
+
return renderChildToString(currentChildren);
|
|
226
80
|
}
|
|
81
|
+
return '';
|
|
227
82
|
}
|
|
228
|
-
return ()
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
83
|
+
return renderChildToString(sortedChildren);
|
|
84
|
+
}, [areMultipleChildrenGiven, currentChildrenIndex, renderChildToString, sortedChildren]);
|
|
85
|
+
const charactersCount = (0, _react.useMemo)(() => (0, _utils.getCharactersCount)(textContent), [textContent]);
|
|
86
|
+
const {
|
|
87
|
+
effectiveShownCharCount,
|
|
88
|
+
hasRenderedChildrenOnce,
|
|
89
|
+
handleClick,
|
|
90
|
+
isAnimatingText,
|
|
91
|
+
isTypingAnimationActive,
|
|
92
|
+
shouldPreventBlinkingCursor
|
|
93
|
+
} = (0, _useTypewriterAnimation.default)({
|
|
94
|
+
autoSpeedBaseFactor,
|
|
95
|
+
charactersCount,
|
|
96
|
+
childrenKey: children,
|
|
97
|
+
childrenCount,
|
|
98
|
+
currentTextLength: textContent.length,
|
|
99
|
+
cursorType,
|
|
100
|
+
nextTextDelay,
|
|
101
|
+
onAdvanceChild: handleSetNextChildrenIndex,
|
|
102
|
+
onFinish,
|
|
103
|
+
onResetAnimationEnd,
|
|
104
|
+
onResetAnimationStart,
|
|
105
|
+
onTypingAnimationEnd,
|
|
106
|
+
onTypingAnimationStart,
|
|
107
|
+
resetDelay,
|
|
108
|
+
resetSpeed,
|
|
109
|
+
shouldCalcAutoSpeed,
|
|
110
|
+
shouldForceCursorAnimation,
|
|
111
|
+
shouldUseResetAnimation,
|
|
112
|
+
shouldWaitForContent,
|
|
113
|
+
speed,
|
|
114
|
+
startDelay
|
|
115
|
+
});
|
|
116
|
+
const shownText = (0, _react.useMemo)(() => (0, _utils.getSubTextFromHTML)(textContent, effectiveShownCharCount) || '​', [effectiveShownCharCount, textContent]);
|
|
238
117
|
const pseudoTextHTML = (0, _react.useMemo)(() => {
|
|
239
118
|
if (pseudoChildren) {
|
|
240
|
-
|
|
241
|
-
const pseudoText = /*#__PURE__*/_react.default.isValidElement(pseudoChildren) ? (0, _server.renderToString)(/*#__PURE__*/_react.default.createElement(_chaynsApi.ChaynsProvider, {
|
|
242
|
-
data: values,
|
|
243
|
-
functions: functions,
|
|
244
|
-
isModule: true
|
|
245
|
-
}, /*#__PURE__*/_react.default.createElement(_core.ColorSchemeProvider, {
|
|
246
|
-
color: colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe7 = colorScheme.designSettings) === null || _colorScheme$designSe7 === void 0 ? void 0 : _colorScheme$designSe7.color,
|
|
247
|
-
colorMode: colorScheme === null || colorScheme === void 0 || (_colorScheme$designSe8 = colorScheme.designSettings) === null || _colorScheme$designSe8 === void 0 ? void 0 : _colorScheme$designSe8.colorMode,
|
|
248
|
-
style: {
|
|
249
|
-
display: 'inline'
|
|
250
|
-
}
|
|
251
|
-
}, pseudoChildren))) : pseudoChildren;
|
|
119
|
+
const pseudoText = renderChildToString(pseudoChildren);
|
|
252
120
|
if (shouldUseAnimationHeight) {
|
|
253
|
-
return (0, _utils.getSubTextFromHTML)(pseudoText,
|
|
121
|
+
return (0, _utils.getSubTextFromHTML)(pseudoText, effectiveShownCharCount);
|
|
254
122
|
}
|
|
255
123
|
return pseudoText;
|
|
256
124
|
}
|
|
257
125
|
if (shouldUseAnimationHeight && textContent) {
|
|
258
|
-
return (0, _utils.getSubTextFromHTML)(textContent,
|
|
126
|
+
return (0, _utils.getSubTextFromHTML)(textContent, effectiveShownCharCount);
|
|
259
127
|
}
|
|
260
128
|
return textContent || '​';
|
|
261
|
-
}, [
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}, isAnimatingText ? /*#__PURE__*/_react.default.createElement(_AnimatedTypewriterText.default, {
|
|
129
|
+
}, [effectiveShownCharCount, pseudoChildren, renderChildToString, shouldUseAnimationHeight, textContent]);
|
|
130
|
+
return /*#__PURE__*/_react.default.createElement(_TypewriterView.default, {
|
|
131
|
+
cursorType: cursorType,
|
|
132
|
+
handleClick: isTypingAnimationActive ? handleClick : undefined,
|
|
133
|
+
hasRenderedChildrenOnce: hasRenderedChildrenOnce,
|
|
134
|
+
isAnimatingText: isAnimatingText,
|
|
135
|
+
pseudoTextHTML: pseudoTextHTML,
|
|
269
136
|
shouldHideCursor: shouldHideCursor,
|
|
137
|
+
shouldPreventBlinkingCursor: shouldPreventBlinkingCursor,
|
|
270
138
|
shouldRemainSingleLine: shouldRemainSingleLine,
|
|
271
139
|
shownText: shownText,
|
|
272
140
|
textStyle: textStyle
|
|
273
|
-
}
|
|
274
|
-
className: "notranslate",
|
|
275
|
-
$shouldRemainSingleLine: shouldRemainSingleLine,
|
|
276
|
-
dangerouslySetInnerHTML: typeof sortedChildren === 'string' ? {
|
|
277
|
-
__html: shownText
|
|
278
|
-
} : undefined,
|
|
279
|
-
style: textStyle
|
|
280
|
-
}, typeof sortedChildren !== 'string' ? sortedChildren : undefined), isAnimatingText && /*#__PURE__*/_react.default.createElement(_Typewriter.StyledTypewriterPseudoText, {
|
|
281
|
-
$isAnimatingText: isAnimatingText,
|
|
282
|
-
$shouldHideCursor: shouldHideCursor,
|
|
283
|
-
dangerouslySetInnerHTML: {
|
|
284
|
-
__html: pseudoTextHTML
|
|
285
|
-
}
|
|
286
|
-
}), !hasRenderedChildrenOnce && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
|
|
287
|
-
style: {
|
|
288
|
-
position: 'absolute',
|
|
289
|
-
visibility: 'hidden'
|
|
290
|
-
}
|
|
291
|
-
}, children), document.body)), [children, cursorType, handleClick, hasRenderedChildrenOnce, isAnimatingText, pseudoTextHTML, shouldHideCursor, shouldPreventBlinkingCursor, shouldRemainSingleLine, shownText, sortedChildren, textStyle]);
|
|
141
|
+
}, sortedChildren);
|
|
292
142
|
};
|
|
293
143
|
Typewriter.displayName = 'Typewriter';
|
|
294
144
|
var _default = exports.default = Typewriter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typewriter.js","names":["_core","require","_chaynsApi","_react","_interopRequireWildcard","_reactDom","_server","_cursor","_speed","_AnimatedTypewriterText","_interopRequireDefault","_Typewriter","_utils","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","Typewriter","children","cursorType","CursorType","Default","nextTextDelay","TypewriterDelay","Medium","onFinish","onResetAnimationEnd","animationSteps","onResetAnimationStart","onTypingAnimationEnd","onTypingAnimationStart","pseudoChildren","resetDelay","shouldForceCursorAnimation","shouldHideCursor","shouldRemainSingleLine","shouldSortChildrenRandomly","shouldUseAnimationHeight","shouldUseResetAnimation","shouldWaitForContent","speed","TypewriterSpeed","resetSpeed","startDelay","None","textStyle","shouldCalcAutoSpeed","autoSpeedBaseFactor","_colorScheme$designSe5","_colorScheme$designSe6","_colorScheme$designSe9","_colorScheme$designSe0","currentChildrenIndex","setCurrentChildrenIndex","useState","hasRenderedChildrenOnce","setHasRenderedChildrenOnce","shouldPreventBlinkingCursor","setShouldPreventBlinkingCursor","isResetAnimationActive","setIsResetAnimationActive","shouldStopAnimation","setShouldStopAnimation","autoSpeed","useRef","autoSteps","functions","useFunctions","values","useValues","colorScheme","useColorScheme","sortedChildren","useMemo","Array","isArray","shuffleArray","areMultipleChildrenGiven","childrenCount","length","textContent","_colorScheme$designSe3","_colorScheme$designSe4","currentChildren","_colorScheme$designSe","_colorScheme$designSe2","React","isValidElement","renderToString","createElement","ChaynsProvider","data","isModule","ColorSchemeProvider","color","designSettings","colorMode","style","display","className","charactersCount","getCharactersCount","chunkIntervalExponentialMovingAverage","lastLength","ema","shownCharCount","setShownCharCount","currentPosition","current","updateChunkStreamingSpeedEMA","currentLength","state","undefined","calculatedAutoSpeed","steps","calculateAutoSpeed","isAnimatingText","handleClick","useCallback","event","stopPropagation","preventDefault","handleSetNextChildrenIndex","newIndex","interval","setInterval","prevState","nextState","clearInterval","setTimeout","startTypingAnimation","Thin","runTypingInterval","Math","min","shownText","getSubTextFromHTML","pseudoTextHTML","_colorScheme$designSe7","_colorScheme$designSe8","pseudoText","StyledTypewriter","$cursorType","onClick","$isAnimatingText","$shouldHideCursor","$shouldPreventBlinkAnimation","StyledTypewriterText","$shouldRemainSingleLine","dangerouslySetInnerHTML","__html","StyledTypewriterPseudoText","createPortal","position","visibility","document","body","displayName","_default","exports"],"sources":["../../../../src/components/typewriter/Typewriter.tsx"],"sourcesContent":["import { ColorSchemeProvider, useColorScheme } from '@chayns-components/core';\nimport { ChaynsProvider, useFunctions, useValues } from 'chayns-api';\nimport React, {\n FC,\n ReactElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { renderToString } from 'react-dom/server';\nimport { CSSPropertiesWithVars } from 'styled-components/dist/types';\nimport { CursorType } from '../../types/cursor';\nimport { TypewriterDelay, TypewriterSpeed } from '../../types/speed';\nimport AnimatedTypewriterText from './AnimatedTypewriterText';\nimport {\n StyledTypewriter,\n StyledTypewriterPseudoText,\n StyledTypewriterText,\n} from './Typewriter.styles';\nimport {\n calculateAutoSpeed,\n ChunkStreamingSpeedState,\n getCharactersCount,\n getSubTextFromHTML,\n shuffleArray,\n updateChunkStreamingSpeedEMA,\n} from './utils';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport type TypewriterProps = {\n /**\n * The number of characters that will be animated per animation cycle.\n */\n animationSteps?: number;\n /**\n * The text to type\n */\n children: ReactElement | ReactElement[] | string | string[];\n /**\n * The type of the cursor. Use the CursorType enum for this prop.\n */\n cursorType?: CursorType;\n /**\n * The delay in milliseconds before the next text is shown.\n * This prop is only used if multiple texts are given.\n */\n nextTextDelay?: TypewriterDelay;\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 * Function that is executed when the reset animation has finished. This function will not be\n * executed if `shouldUseResetAnimation` is not set to `true`.\n */\n onResetAnimationEnd?: VoidFunction;\n /**\n * Function that is executed when the reset animation has started. This function will not be\n * executed if `shouldUseResetAnimation` is not set to `true`.\n */\n onResetAnimationStart?: VoidFunction;\n /**\n * Function that is executed when the typing animation has finished. If multiple texts are given,\n * this function will be executed for each text.\n */\n onTypingAnimationEnd?: VoidFunction;\n /**\n * Function that is executed when the typing animation has started. If multiple texts are given,\n * this function will be executed for each text.\n */\n onTypingAnimationStart?: 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 in milliseconds before the typewriter resets the text.\n * This prop is only used if multiple texts are given.\n */\n resetDelay?: TypewriterDelay;\n /**\n * The reset speed of the animation. Use the TypewriterSpeed enum for this prop.\n */\n resetSpeed?: TypewriterSpeed | number;\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 * Whether the content should remain a single line.\n */\n shouldRemainSingleLine?: 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 * Whether the animation speed should be calculated with the chunk interval.\n */\n shouldCalcAutoSpeed?: boolean;\n /**\n * Sets how long the animation should last when `shouldCalcAutoSpeed` is enabled in milliseconds.\n * When chunks are streamed, this value will only be used for the initial speed and then change to the speed characters are added at\n */\n autoSpeedBaseFactor?: number;\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 delay in milliseconds before the typewriter starts typing.\n */\n startDelay?: TypewriterDelay;\n /**\n * The style of the typewriter text element\n */\n textStyle?: CSSPropertiesWithVars;\n};\n\nconst Typewriter: FC<TypewriterProps> = ({\n children,\n cursorType = CursorType.Default,\n nextTextDelay = TypewriterDelay.Medium,\n onFinish,\n onResetAnimationEnd,\n animationSteps = 1,\n onResetAnimationStart,\n onTypingAnimationEnd,\n onTypingAnimationStart,\n pseudoChildren,\n resetDelay = TypewriterDelay.Medium,\n shouldForceCursorAnimation = false,\n shouldHideCursor = false,\n shouldRemainSingleLine = false,\n shouldSortChildrenRandomly = false,\n shouldUseAnimationHeight = false,\n shouldUseResetAnimation = false,\n shouldWaitForContent,\n speed = TypewriterSpeed.Medium,\n resetSpeed = speed,\n startDelay = TypewriterDelay.None,\n textStyle,\n shouldCalcAutoSpeed = false,\n autoSpeedBaseFactor = 2000,\n}) => {\n const [currentChildrenIndex, setCurrentChildrenIndex] = useState(0);\n const [hasRenderedChildrenOnce, setHasRenderedChildrenOnce] = useState(false);\n const [shouldPreventBlinkingCursor, setShouldPreventBlinkingCursor] = useState(false);\n const [isResetAnimationActive, setIsResetAnimationActive] = useState(false);\n const [shouldStopAnimation, setShouldStopAnimation] = useState(false);\n const autoSpeed = useRef<number>();\n const autoSteps = useRef<number>(animationSteps);\n\n const functions = useFunctions();\n const values = useValues();\n\n const colorScheme = useColorScheme();\n\n useIsomorphicLayoutEffect(() => {\n if (children) {\n setHasRenderedChildrenOnce(false);\n }\n }, [children]);\n\n useEffect(() => {\n if (!hasRenderedChildrenOnce) {\n setHasRenderedChildrenOnce(true);\n }\n }, [hasRenderedChildrenOnce]);\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 <ChaynsProvider data={values} functions={functions} isModule>\n <ColorSchemeProvider\n color={colorScheme?.designSettings?.color}\n colorMode={colorScheme?.designSettings?.colorMode}\n style={{ display: 'inline' }}\n >\n <span className=\"notranslate\">{currentChildren}</span>\n </ColorSchemeProvider>\n </ChaynsProvider>,\n )\n : (currentChildren as string);\n }\n\n return '';\n }\n\n return React.isValidElement(sortedChildren)\n ? renderToString(\n <ChaynsProvider data={values} functions={functions} isModule>\n <ColorSchemeProvider\n color={colorScheme?.designSettings?.color}\n colorMode={colorScheme?.designSettings?.colorMode}\n style={{ display: 'inline' }}\n >\n <span className=\"notranslate\">{sortedChildren}</span>\n </ColorSchemeProvider>\n </ChaynsProvider>,\n )\n : (sortedChildren as string);\n }, [\n areMultipleChildrenGiven,\n colorScheme?.designSettings?.color,\n colorScheme?.designSettings?.colorMode,\n currentChildrenIndex,\n functions,\n sortedChildren,\n values,\n ]);\n\n const charactersCount = useMemo(() => getCharactersCount(textContent), [textContent]);\n const chunkIntervalExponentialMovingAverage = useRef<ChunkStreamingSpeedState>({\n lastLength: charactersCount,\n ema: charactersCount / (autoSpeedBaseFactor / 1000),\n });\n\n const [shownCharCount, setShownCharCount] = useState(\n charactersCount > 0 ? 0 : textContent.length,\n );\n\n const currentPosition = useRef(0);\n\n useEffect(() => {\n if (shouldUseResetAnimation) {\n chunkIntervalExponentialMovingAverage.current = {\n ema: charactersCount / (autoSpeedBaseFactor / 1000),\n lastLength: charactersCount,\n };\n }\n chunkIntervalExponentialMovingAverage.current = updateChunkStreamingSpeedEMA({\n currentLength: charactersCount,\n state: chunkIntervalExponentialMovingAverage.current,\n });\n }, [autoSpeedBaseFactor, charactersCount, shouldUseResetAnimation]);\n\n useEffect(() => {\n if (!shouldCalcAutoSpeed) {\n autoSpeed.current = undefined;\n autoSteps.current = animationSteps;\n return;\n }\n const { speed: calculatedAutoSpeed, steps } = calculateAutoSpeed(\n chunkIntervalExponentialMovingAverage.current.ema,\n );\n\n autoSpeed.current = calculatedAutoSpeed;\n autoSteps.current = steps;\n }, [animationSteps, charactersCount, shouldCalcAutoSpeed]);\n\n const isAnimatingText =\n shownCharCount < textContent.length ||\n shouldForceCursorAnimation ||\n areMultipleChildrenGiven ||\n textContent.length === 0;\n\n const handleClick = useCallback((event: React.MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\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 currentPosition.current = textContent.length;\n } else if (isResetAnimationActive) {\n if (typeof onResetAnimationStart === 'function') {\n onResetAnimationStart();\n }\n\n interval = window.setInterval(() => {\n setShownCharCount((prevState) => {\n const nextState = prevState - autoSteps.current;\n currentPosition.current = nextState;\n\n if (nextState === 0) {\n window.clearInterval(interval);\n\n if (typeof onResetAnimationEnd === 'function') {\n onResetAnimationEnd();\n }\n\n if (areMultipleChildrenGiven) {\n setTimeout(() => {\n setIsResetAnimationActive(false);\n handleSetNextChildrenIndex();\n }, nextTextDelay);\n }\n }\n\n return nextState;\n });\n }, resetSpeed);\n } else {\n const startTypingAnimation = () => {\n if (cursorType === CursorType.Thin) {\n setShouldPreventBlinkingCursor(true);\n }\n\n if (typeof onTypingAnimationStart === 'function') {\n onTypingAnimationStart();\n }\n\n const runTypingInterval = () => {\n setShownCharCount((prevState) => {\n let nextState = Math.min(prevState + autoSteps.current, charactersCount);\n\n if (nextState >= charactersCount && !shouldWaitForContent) {\n window.clearInterval(interval);\n\n if (cursorType === CursorType.Thin) {\n setShouldPreventBlinkingCursor(false);\n }\n\n if (typeof onTypingAnimationEnd === 'function') {\n onTypingAnimationEnd();\n }\n\n /**\n * At this point, the next value for \"shownCharCount\" is deliberately set to\n * the length of the textContent 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, nextTextDelay);\n }\n }, resetDelay);\n }\n }\n\n currentPosition.current = nextState;\n\n return nextState;\n });\n };\n interval = window.setInterval(runTypingInterval, autoSpeed.current ?? speed);\n };\n\n if (startDelay) {\n setTimeout(startTypingAnimation, startDelay);\n } else {\n startTypingAnimation();\n }\n }\n\n return () => {\n window.clearInterval(interval);\n };\n }, [\n areMultipleChildrenGiven,\n autoSteps,\n charactersCount,\n cursorType,\n handleSetNextChildrenIndex,\n isResetAnimationActive,\n nextTextDelay,\n onResetAnimationEnd,\n onResetAnimationStart,\n onTypingAnimationEnd,\n onTypingAnimationStart,\n resetDelay,\n resetSpeed,\n shouldStopAnimation,\n shouldUseResetAnimation,\n shouldWaitForContent,\n speed,\n startDelay,\n textContent.length,\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 <ChaynsProvider data={values} functions={functions} isModule>\n <ColorSchemeProvider\n color={colorScheme?.designSettings?.color}\n colorMode={colorScheme?.designSettings?.colorMode}\n style={{ display: 'inline' }}\n >\n {pseudoChildren}\n </ColorSchemeProvider>\n </ChaynsProvider>,\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 || '​';\n }, [\n colorScheme?.designSettings?.color,\n colorScheme?.designSettings?.colorMode,\n functions,\n pseudoChildren,\n shouldUseAnimationHeight,\n shownCharCount,\n textContent,\n values,\n ]);\n\n return useMemo(\n () => (\n <StyledTypewriter\n $cursorType={cursorType}\n onClick={isAnimatingText ? handleClick : undefined}\n $isAnimatingText={isAnimatingText}\n $shouldHideCursor={shouldHideCursor}\n $shouldPreventBlinkAnimation={shouldPreventBlinkingCursor}\n >\n {isAnimatingText ? (\n <AnimatedTypewriterText\n shouldHideCursor={shouldHideCursor}\n shouldRemainSingleLine={shouldRemainSingleLine}\n shownText={shownText}\n textStyle={textStyle}\n />\n ) : (\n <StyledTypewriterText\n className=\"notranslate\"\n $shouldRemainSingleLine={shouldRemainSingleLine}\n dangerouslySetInnerHTML={\n typeof sortedChildren === 'string' ? { __html: shownText } : undefined\n }\n style={textStyle}\n >\n {typeof sortedChildren !== 'string' ? sortedChildren : undefined}\n </StyledTypewriterText>\n )}\n {isAnimatingText && (\n <StyledTypewriterPseudoText\n $isAnimatingText={isAnimatingText}\n $shouldHideCursor={shouldHideCursor}\n dangerouslySetInnerHTML={{ __html: pseudoTextHTML }}\n />\n )}\n {/*\n The following is needed because some components like the CodeHighlighter will not render correct\n if the element is not rendered on a client before...\n */}\n {!hasRenderedChildrenOnce &&\n createPortal(\n <div style={{ position: 'absolute', visibility: 'hidden' }}>\n {children}\n </div>,\n document.body,\n )}\n </StyledTypewriter>\n ),\n [\n children,\n cursorType,\n handleClick,\n hasRenderedChildrenOnce,\n isAnimatingText,\n pseudoTextHTML,\n shouldHideCursor,\n shouldPre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AW,EACX9D,uBAAuB,EACvB6D,eAAe,EACfqB,cAAc,EACdvG,gBAAgB,EAChBuB,2BAA2B,EAC3BtB,sBAAsB,EACtBoG,SAAS,EACT/D,cAAc,EACd3B,SAAS,CAEjB,CAAC;AACL,CAAC;AAED5B,UAAU,CAAC4I,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnK,OAAA,GAEvBqB,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Typewriter.js","names":["_core","require","_chaynsApi","_react","_interopRequireWildcard","_server","_cursor","_speed","_TypewriterView","_interopRequireDefault","_useTypewriterAnimation","_utils","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Typewriter","children","cursorType","CursorType","Default","nextTextDelay","TypewriterDelay","Medium","onFinish","onResetAnimationEnd","animationSteps","onResetAnimationStart","onTypingAnimationEnd","onTypingAnimationStart","pseudoChildren","resetDelay","shouldForceCursorAnimation","shouldHideCursor","shouldRemainSingleLine","shouldSortChildrenRandomly","shouldUseAnimationHeight","shouldUseResetAnimation","shouldWaitForContent","speed","TypewriterSpeed","resetSpeed","startDelay","None","textStyle","shouldCalcAutoSpeed","autoSpeedBaseFactor","_colorScheme$designSe3","_colorScheme$designSe4","currentChildrenIndex","setCurrentChildrenIndex","useState","functions","useFunctions","values","useValues","colorScheme","useColorScheme","sortedChildren","useMemo","Array","isArray","shuffleArray","areMultipleChildrenGiven","childrenCount","length","renderChildToString","useCallback","child","_colorScheme$designSe","_colorScheme$designSe2","React","isValidElement","renderToString","createElement","ChaynsProvider","data","isModule","ColorSchemeProvider","color","designSettings","colorMode","style","display","className","handleSetNextChildrenIndex","prevIndex","newIndex","textContent","currentChildren","charactersCount","getCharactersCount","effectiveShownCharCount","hasRenderedChildrenOnce","handleClick","isAnimatingText","isTypingAnimationActive","shouldPreventBlinkingCursor","useTypewriterAnimation","childrenKey","currentTextLength","onAdvanceChild","shownText","getSubTextFromHTML","pseudoTextHTML","pseudoText","undefined","displayName","_default","exports"],"sources":["../../../../src/components/typewriter/Typewriter.tsx"],"sourcesContent":["import { ColorSchemeProvider, useColorScheme } from '@chayns-components/core';\nimport { ChaynsProvider, useFunctions, useValues } from 'chayns-api';\nimport React, { FC, ReactElement, useCallback, useMemo, useState } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport { CSSPropertiesWithVars } from 'styled-components/dist/types';\nimport { CursorType } from '../../types/cursor';\nimport { TypewriterDelay, TypewriterSpeed } from '../../types/speed';\nimport TypewriterView from './typewrite-view/TypewriterView';\nimport useTypewriterAnimation from '../../hooks/useTypewriterAnimation';\nimport { getCharactersCount, getSubTextFromHTML, shuffleArray } from '../../utils/utils';\n\nexport type TypewriterProps = {\n /**\n * The number of characters that will be animated per animation cycle.\n */\n animationSteps?: number;\n /**\n * The text to type\n */\n children: ReactElement | ReactElement[] | string | string[];\n /**\n * The type of the cursor. Use the CursorType enum for this prop.\n */\n cursorType?: CursorType;\n /**\n * The delay in milliseconds before the next text is shown.\n * This prop is only used if multiple texts are given.\n */\n nextTextDelay?: TypewriterDelay;\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 * Function that is executed when the reset animation has finished. This function will not be\n * executed if `shouldUseResetAnimation` is not set to `true`.\n */\n onResetAnimationEnd?: VoidFunction;\n /**\n * Function that is executed when the reset animation has started. This function will not be\n * executed if `shouldUseResetAnimation` is not set to `true`.\n */\n onResetAnimationStart?: VoidFunction;\n /**\n * Function that is executed when the typing animation has finished. If multiple texts are given,\n * this function will be executed for each text.\n */\n onTypingAnimationEnd?: VoidFunction;\n /**\n * Function that is executed when the typing animation has started. If multiple texts are given,\n * this function will be executed for each text.\n */\n onTypingAnimationStart?: 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 in milliseconds before the typewriter resets the text.\n * This prop is only used if multiple texts are given.\n */\n resetDelay?: TypewriterDelay;\n /**\n * The reset speed of the animation. Use the TypewriterSpeed enum for this prop.\n */\n resetSpeed?: TypewriterSpeed | number;\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 * Whether the content should remain a single line.\n */\n shouldRemainSingleLine?: 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 * Whether the animation speed should be calculated with the chunk interval.\n */\n shouldCalcAutoSpeed?: boolean;\n /**\n * Sets how long the animation should last when `shouldCalcAutoSpeed` is enabled in milliseconds.\n * When chunks are streamed, this value will only be used for the initial speed and then change to the speed characters are added at\n */\n autoSpeedBaseFactor?: number;\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 delay in milliseconds before the typewriter starts typing.\n */\n startDelay?: TypewriterDelay;\n /**\n * The style of the typewriter text element\n */\n textStyle?: CSSPropertiesWithVars;\n};\n\nconst Typewriter: FC<TypewriterProps> = ({\n children,\n cursorType = CursorType.Default,\n nextTextDelay = TypewriterDelay.Medium,\n onFinish,\n onResetAnimationEnd,\n animationSteps = 1,\n onResetAnimationStart,\n onTypingAnimationEnd,\n onTypingAnimationStart,\n pseudoChildren,\n resetDelay = TypewriterDelay.Medium,\n shouldForceCursorAnimation = false,\n shouldHideCursor = false,\n shouldRemainSingleLine = false,\n shouldSortChildrenRandomly = false,\n shouldUseAnimationHeight = false,\n shouldUseResetAnimation = false,\n shouldWaitForContent,\n speed = TypewriterSpeed.Medium,\n resetSpeed = speed,\n startDelay = TypewriterDelay.None,\n textStyle,\n shouldCalcAutoSpeed = false,\n autoSpeedBaseFactor = 2000,\n}) => {\n const [currentChildrenIndex, setCurrentChildrenIndex] = useState(0);\n\n const functions = useFunctions();\n const values = useValues();\n\n const colorScheme = useColorScheme();\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 renderChildToString = useCallback(\n (child: ReactElement | ReactElement[] | string | string[]) =>\n React.isValidElement(child)\n ? renderToString(\n <ChaynsProvider data={values} functions={functions} isModule>\n <ColorSchemeProvider\n color={colorScheme?.designSettings?.color}\n colorMode={colorScheme?.designSettings?.colorMode}\n style={{ display: 'inline' }}\n >\n <span className=\"notranslate\">{child}</span>\n </ColorSchemeProvider>\n </ChaynsProvider>,\n )\n : (child as string),\n [\n colorScheme?.designSettings?.color,\n colorScheme?.designSettings?.colorMode,\n functions,\n values,\n ],\n );\n\n const handleSetNextChildrenIndex = useCallback(\n () =>\n setCurrentChildrenIndex((prevIndex) => {\n let newIndex = prevIndex + 1;\n\n if (newIndex > childrenCount - 1) {\n newIndex = 0;\n }\n\n return newIndex;\n }),\n [childrenCount],\n );\n\n const textContent = useMemo(() => {\n if (areMultipleChildrenGiven) {\n const currentChildren = sortedChildren[currentChildrenIndex];\n\n if (currentChildren) {\n return renderChildToString(currentChildren);\n }\n\n return '';\n }\n\n return renderChildToString(sortedChildren);\n }, [areMultipleChildrenGiven, currentChildrenIndex, renderChildToString, sortedChildren]);\n\n const charactersCount = useMemo(() => getCharactersCount(textContent), [textContent]);\n\n const {\n effectiveShownCharCount,\n hasRenderedChildrenOnce,\n handleClick,\n isAnimatingText,\n isTypingAnimationActive,\n shouldPreventBlinkingCursor,\n } = useTypewriterAnimation({\n autoSpeedBaseFactor,\n charactersCount,\n childrenKey: children,\n childrenCount,\n currentTextLength: textContent.length,\n cursorType,\n nextTextDelay,\n onAdvanceChild: handleSetNextChildrenIndex,\n onFinish,\n onResetAnimationEnd,\n onResetAnimationStart,\n onTypingAnimationEnd,\n onTypingAnimationStart,\n resetDelay,\n resetSpeed,\n shouldCalcAutoSpeed,\n shouldForceCursorAnimation,\n shouldUseResetAnimation,\n shouldWaitForContent,\n speed,\n startDelay,\n });\n\n const shownText = useMemo(\n () => getSubTextFromHTML(textContent, effectiveShownCharCount) || '​',\n [effectiveShownCharCount, textContent],\n );\n\n const pseudoTextHTML = useMemo(() => {\n if (pseudoChildren) {\n const pseudoText = renderChildToString(pseudoChildren);\n\n if (shouldUseAnimationHeight) {\n return getSubTextFromHTML(pseudoText, effectiveShownCharCount);\n }\n\n return pseudoText;\n }\n\n if (shouldUseAnimationHeight && textContent) {\n return getSubTextFromHTML(textContent, effectiveShownCharCount);\n }\n\n return textContent || '​';\n }, [\n effectiveShownCharCount,\n pseudoChildren,\n renderChildToString,\n shouldUseAnimationHeight,\n textContent,\n ]);\n\n return (\n <TypewriterView\n cursorType={cursorType}\n handleClick={isTypingAnimationActive ? handleClick : undefined}\n hasRenderedChildrenOnce={hasRenderedChildrenOnce}\n isAnimatingText={isAnimatingText}\n pseudoTextHTML={pseudoTextHTML}\n shouldHideCursor={shouldHideCursor}\n shouldPreventBlinkingCursor={shouldPreventBlinkingCursor}\n shouldRemainSingleLine={shouldRemainSingleLine}\n shownText={shownText}\n textStyle={textStyle}\n >\n {sortedChildren}\n </TypewriterView>\n );\n};\n\nTypewriter.displayName = 'Typewriter';\n\nexport default Typewriter;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;A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AAC,QAAA,GAAAC,OAAA,CAAA9G,OAAA,GAEvBiB,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
9
|
+
var _AnimatedTypewriterText = _interopRequireDefault(require("./animated-typewriter-text/AnimatedTypewriterText"));
|
|
10
|
+
var _TypewriterView = require("./TypewriterView.styles");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const TypewriterView = ({
|
|
13
|
+
children,
|
|
14
|
+
cursorType,
|
|
15
|
+
handleClick,
|
|
16
|
+
hasRenderedChildrenOnce,
|
|
17
|
+
isAnimatingText,
|
|
18
|
+
pseudoTextHTML,
|
|
19
|
+
shouldHideCursor,
|
|
20
|
+
shouldPreventBlinkingCursor,
|
|
21
|
+
shouldRemainSingleLine,
|
|
22
|
+
shownText,
|
|
23
|
+
textStyle
|
|
24
|
+
}) => /*#__PURE__*/_react.default.createElement(_TypewriterView.StyledTypewriter, {
|
|
25
|
+
$cursorType: cursorType,
|
|
26
|
+
onClick: handleClick,
|
|
27
|
+
$isAnimatingText: isAnimatingText,
|
|
28
|
+
$shouldHideCursor: shouldHideCursor,
|
|
29
|
+
$shouldPreventBlinkAnimation: shouldPreventBlinkingCursor
|
|
30
|
+
}, isAnimatingText ? /*#__PURE__*/_react.default.createElement(_AnimatedTypewriterText.default, {
|
|
31
|
+
shouldHideCursor: shouldHideCursor,
|
|
32
|
+
shouldRemainSingleLine: shouldRemainSingleLine,
|
|
33
|
+
shownText: shownText,
|
|
34
|
+
textStyle: textStyle
|
|
35
|
+
}) : /*#__PURE__*/_react.default.createElement(_TypewriterView.StyledTypewriterText, {
|
|
36
|
+
className: "notranslate",
|
|
37
|
+
$shouldRemainSingleLine: shouldRemainSingleLine,
|
|
38
|
+
dangerouslySetInnerHTML: typeof children === 'string' ? {
|
|
39
|
+
__html: shownText
|
|
40
|
+
} : undefined,
|
|
41
|
+
style: textStyle
|
|
42
|
+
}, typeof children !== 'string' ? children : undefined), isAnimatingText && /*#__PURE__*/_react.default.createElement(_TypewriterView.StyledTypewriterPseudoText, {
|
|
43
|
+
$isAnimatingText: isAnimatingText,
|
|
44
|
+
$shouldHideCursor: shouldHideCursor,
|
|
45
|
+
dangerouslySetInnerHTML: {
|
|
46
|
+
__html: pseudoTextHTML
|
|
47
|
+
}
|
|
48
|
+
}), !hasRenderedChildrenOnce && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
|
|
49
|
+
style: {
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
visibility: 'hidden'
|
|
52
|
+
}
|
|
53
|
+
}, children), document.body));
|
|
54
|
+
var _default = exports.default = TypewriterView;
|
|
55
|
+
//# sourceMappingURL=TypewriterView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypewriterView.js","names":["_react","_interopRequireDefault","require","_reactDom","_AnimatedTypewriterText","_TypewriterView","e","__esModule","default","TypewriterView","children","cursorType","handleClick","hasRenderedChildrenOnce","isAnimatingText","pseudoTextHTML","shouldHideCursor","shouldPreventBlinkingCursor","shouldRemainSingleLine","shownText","textStyle","createElement","StyledTypewriter","$cursorType","onClick","$isAnimatingText","$shouldHideCursor","$shouldPreventBlinkAnimation","StyledTypewriterText","className","$shouldRemainSingleLine","dangerouslySetInnerHTML","__html","undefined","style","StyledTypewriterPseudoText","createPortal","position","visibility","document","body","_default","exports"],"sources":["../../../../../src/components/typewriter/typewrite-view/TypewriterView.tsx"],"sourcesContent":["import React, { FC, ReactElement } from 'react';\nimport { createPortal } from 'react-dom';\nimport { CSSPropertiesWithVars } from 'styled-components/dist/types';\nimport { CursorType } from '../../../types/cursor';\nimport AnimatedTypewriterText from './animated-typewriter-text/AnimatedTypewriterText';\nimport {\n StyledTypewriter,\n StyledTypewriterPseudoText,\n StyledTypewriterText,\n} from './TypewriterView.styles';\n\nexport type TypewriterContent = ReactElement | string | Array<ReactElement | string>;\n\ntype TypewriterViewProps = {\n children: TypewriterContent;\n cursorType: CursorType;\n handleClick?: (event: React.MouseEvent) => void;\n hasRenderedChildrenOnce: boolean;\n isAnimatingText: boolean;\n pseudoTextHTML: string;\n shouldHideCursor: boolean;\n shouldPreventBlinkingCursor: boolean;\n shouldRemainSingleLine: boolean;\n shownText: string;\n textStyle?: CSSPropertiesWithVars;\n};\n\nconst TypewriterView: FC<TypewriterViewProps> = ({\n children,\n cursorType,\n handleClick,\n hasRenderedChildrenOnce,\n isAnimatingText,\n pseudoTextHTML,\n shouldHideCursor,\n shouldPreventBlinkingCursor,\n shouldRemainSingleLine,\n shownText,\n textStyle,\n}) => (\n <StyledTypewriter\n $cursorType={cursorType}\n onClick={handleClick}\n $isAnimatingText={isAnimatingText}\n $shouldHideCursor={shouldHideCursor}\n $shouldPreventBlinkAnimation={shouldPreventBlinkingCursor}\n >\n {isAnimatingText ? (\n <AnimatedTypewriterText\n shouldHideCursor={shouldHideCursor}\n shouldRemainSingleLine={shouldRemainSingleLine}\n shownText={shownText}\n textStyle={textStyle}\n />\n ) : (\n <StyledTypewriterText\n className=\"notranslate\"\n $shouldRemainSingleLine={shouldRemainSingleLine}\n dangerouslySetInnerHTML={\n typeof children === 'string' ? { __html: shownText } : undefined\n }\n style={textStyle}\n >\n {typeof children !== 'string' ? children : undefined}\n </StyledTypewriterText>\n )}\n {isAnimatingText && (\n <StyledTypewriterPseudoText\n $isAnimatingText={isAnimatingText}\n $shouldHideCursor={shouldHideCursor}\n dangerouslySetInnerHTML={{ __html: pseudoTextHTML }}\n />\n )}\n {/*\n The following is needed because some components like the CodeHighlighter will not render correct\n if the element is not rendered on a client before...\n */}\n {!hasRenderedChildrenOnce &&\n createPortal(\n <div style={{ position: 'absolute', visibility: 'hidden' }}>{children}</div>,\n document.body,\n )}\n </StyledTypewriter>\n);\n\nexport default TypewriterView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,uBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIiC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAkBjC,MAAMG,cAAuC,GAAGA,CAAC;EAC7CC,QAAQ;EACRC,UAAU;EACVC,WAAW;EACXC,uBAAuB;EACvBC,eAAe;EACfC,cAAc;EACdC,gBAAgB;EAChBC,2BAA2B;EAC3BC,sBAAsB;EACtBC,SAAS;EACTC;AACJ,CAAC,kBACGpB,MAAA,CAAAQ,OAAA,CAAAa,aAAA,CAAChB,eAAA,CAAAiB,gBAAgB;EACbC,WAAW,EAAEZ,UAAW;EACxBa,OAAO,EAAEZ,WAAY;EACrBa,gBAAgB,EAAEX,eAAgB;EAClCY,iBAAiB,EAAEV,gBAAiB;EACpCW,4BAA4B,EAAEV;AAA4B,GAEzDH,eAAe,gBACZd,MAAA,CAAAQ,OAAA,CAAAa,aAAA,CAACjB,uBAAA,CAAAI,OAAsB;EACnBQ,gBAAgB,EAAEA,gBAAiB;EACnCE,sBAAsB,EAAEA,sBAAuB;EAC/CC,SAAS,EAAEA,SAAU;EACrBC,SAAS,EAAEA;AAAU,CACxB,CAAC,gBAEFpB,MAAA,CAAAQ,OAAA,CAAAa,aAAA,CAAChB,eAAA,CAAAuB,oBAAoB;EACjBC,SAAS,EAAC,aAAa;EACvBC,uBAAuB,EAAEZ,sBAAuB;EAChDa,uBAAuB,EACnB,OAAOrB,QAAQ,KAAK,QAAQ,GAAG;IAAEsB,MAAM,EAAEb;EAAU,CAAC,GAAGc,SAC1D;EACDC,KAAK,EAAEd;AAAU,GAEhB,OAAOV,QAAQ,KAAK,QAAQ,GAAGA,QAAQ,GAAGuB,SACzB,CACzB,EACAnB,eAAe,iBACZd,MAAA,CAAAQ,OAAA,CAAAa,aAAA,CAAChB,eAAA,CAAA8B,0BAA0B;EACvBV,gBAAgB,EAAEX,eAAgB;EAClCY,iBAAiB,EAAEV,gBAAiB;EACpCe,uBAAuB,EAAE;IAAEC,MAAM,EAAEjB;EAAe;AAAE,CACvD,CACJ,EAKA,CAACF,uBAAuB,iBACrB,IAAAuB,sBAAY,eACRpC,MAAA,CAAAQ,OAAA,CAAAa,aAAA;EAAKa,KAAK,EAAE;IAAEG,QAAQ,EAAE,UAAU;IAAEC,UAAU,EAAE;EAAS;AAAE,GAAE5B,QAAc,CAAC,EAC5E6B,QAAQ,CAACC,IACb,CACU,CACrB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlC,OAAA,GAEaC,cAAc","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.StyledTypewriterText = exports.StyledTypewriterPseudoText = exports.StyledTypewriter = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var _cursor = require("
|
|
8
|
+
var _cursor = require("../../../types/cursor");
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
10
|
const typewriterCursorElement = ({
|
|
11
11
|
$cursorType,
|
|
@@ -101,4 +101,4 @@ const StyledTypewriterText = exports.StyledTypewriterText = _styledComponents.de
|
|
|
101
101
|
width: 100%;
|
|
102
102
|
`}
|
|
103
103
|
`;
|
|
104
|
-
//# sourceMappingURL=
|
|
104
|
+
//# sourceMappingURL=TypewriterView.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypewriterView.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_cursor","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","typewriterCursorElement","$cursorType","$isAnimatingText","$shouldHideCursor","$shouldPreventBlinkAnimation","CursorType","Thin","css","blinkAnimation","theme","text","StyledTypewriter","exports","styled","div","keyframes","StyledTypewriterPseudoText","span","StyledTypewriterText","$shouldRemainSingleLine"],"sources":["../../../../../src/components/typewriter/typewrite-view/TypewriterView.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled, { css, keyframes } from 'styled-components';\nimport { CursorType } from '../../../types/cursor';\nimport type { TypewriterProps } from '../Typewriter';\n\ntype StyledTypewriterProps = WithTheme<{\n $cursorType: TypewriterProps['cursorType'];\n $isAnimatingText: boolean;\n $shouldHideCursor: TypewriterProps['shouldHideCursor'];\n $shouldPreventBlinkAnimation: boolean;\n}>;\n\nconst typewriterCursorElement = ({\n $cursorType,\n $isAnimatingText,\n $shouldHideCursor,\n $shouldPreventBlinkAnimation,\n}: StyledTypewriterProps) => {\n if (!$isAnimatingText || $shouldHideCursor) {\n return '';\n }\n\n if ($cursorType === CursorType.Thin) {\n return css`\n .typewriter-lastWithContent {\n &:after {\n animation: ${$shouldPreventBlinkAnimation ? 'none' : blinkAnimation} 1s steps(2, start) infinite;\n color: inherit;\n content: '|';\n font-size: 25px;\n position: relative;\n line-height: 0;\n vertical-align: baseline;\n }\n `;\n }\n\n return css`\n .typewriter-lastWithContent {\n &:after {\n animation: ${blinkAnimation} 1s steps(2, start) infinite;\n color: ${({ theme }) => (theme as { text: string }).text};\n content: '▋';\n margin-left: 0.25rem;\n opacity: 0.85;\n position: relative;\n vertical-align: baseline;\n }\n }\n `;\n};\n\nexport const StyledTypewriter = styled.div<StyledTypewriterProps>`\n align-items: inherit;\n display: flex;\n position: relative;\n width: 100%;\n ${typewriterCursorElement}\n`;\n\nconst blinkAnimation = keyframes`\n 100% {\n visibility: hidden;\n }\n`;\n\ntype StyledTypewriterPseudoTextProps = WithTheme<{\n $isAnimatingText?: boolean;\n $shouldHideCursor: TypewriterProps['shouldHideCursor'];\n}>;\n\nexport const StyledTypewriterPseudoText = styled.span<StyledTypewriterPseudoTextProps>`\n opacity: 0;\n pointer-events: none;\n user-select: none;\n width: fit-content;\n\n ${({ $isAnimatingText, $shouldHideCursor }) =>\n $isAnimatingText &&\n !$shouldHideCursor &&\n css`\n &:after {\n animation: ${blinkAnimation} 1s steps(2, start) infinite;\n color: inherit;\n content: '|';\n font-size: 25px;\n position: relative;\n line-height: 0;\n vertical-align: baseline;\n }\n `}\n`;\n\ntype StyledTypewriterTextProps = WithTheme<{\n $isAnimatingText?: boolean;\n $shouldRemainSingleLine: boolean;\n}>;\n\nexport const StyledTypewriterText = styled.span<StyledTypewriterTextProps>`\n color: inherit;\n position: ${({ $isAnimatingText }) => ($isAnimatingText ? 'absolute' : 'relative')};\n width: fit-content;\n\n ${({ $isAnimatingText }) =>\n $isAnimatingText &&\n css`\n pointer-events: none;\n `}\n\n ${({ $shouldRemainSingleLine }) =>\n $shouldRemainSingleLine &&\n css`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n width: 100%;\n `}\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAmD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,O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BAAG;AACd;AACA;AACA,6BAA6BC,cAAc;AAC3C,yBAAyB,CAAC;IAAEC;EAAM,CAAC,KAAMA,KAAK,CAAsBC,IAAI;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC;AAEM,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGE,yBAAM,CAACC,GAA0B;AACjE;AACA;AACA;AACA;AACA,MAAMd,uBAAuB;AAC7B,CAAC;AAED,MAAMQ,cAAc,GAAG,IAAAO,2BAAS;AAChC;AACA;AACA;AACA,CAAC;AAOM,MAAMC,0BAA0B,GAAAJ,OAAA,CAAAI,0BAAA,GAAGH,yBAAM,CAACI,IAAqC;AACtF;AACA;AACA;AACA;AACA;AACA,MAAM,CAAC;EAAEf,gBAAgB;EAAEC;AAAkB,CAAC,KACtCD,gBAAgB,IAChB,CAACC,iBAAiB,IAClB,IAAAI,qBAAG;AACX;AACA,6BAA6BC,cAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,CAAC;AAOM,MAAMU,oBAAoB,GAAAN,OAAA,CAAAM,oBAAA,GAAGL,yBAAM,CAACI,IAA+B;AAC1E;AACA,gBAAgB,CAAC;EAAEf;AAAiB,CAAC,KAAMA,gBAAgB,GAAG,UAAU,GAAG,UAAW;AACtF;AACA;AACA,MAAM,CAAC;EAAEA;AAAiB,CAAC,KACnBA,gBAAgB,IAChB,IAAAK,qBAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEY;AAAwB,CAAC,KAC1BA,uBAAuB,IACvB,IAAAZ,qBAAG;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,CAAC","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _TypewriterView = require("../TypewriterView.styles");
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
10
|
const AnimatedTypewriterText = ({
|
|
11
11
|
shouldHideCursor,
|
|
@@ -46,7 +46,7 @@ const AnimatedTypewriterText = ({
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}, [shouldHideCursor]);
|
|
49
|
-
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(
|
|
49
|
+
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_TypewriterView.StyledTypewriterText, {
|
|
50
50
|
ref: ref => updateTypewriterCursor(ref),
|
|
51
51
|
dangerouslySetInnerHTML: {
|
|
52
52
|
__html: shownText
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatedTypewriterText.js","names":["_react","_interopRequireWildcard","require","_TypewriterView","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AnimatedTypewriterText","shouldHideCursor","shownText","shouldRemainSingleLine","textStyle","updateTypewriterCursor","useCallback","ref","traverseNodes","node","_node$textContent","nodeType","Node","TEXT_NODE","textContent","trim","parentElement","childNodes","Array","from","length","result","lastParentWithContent","classList","remove","querySelectorAll","forEach","element","add","useMemo","createElement","StyledTypewriterText","dangerouslySetInnerHTML","__html","$shouldRemainSingleLine","style","$isAnimatingText","_default","exports"],"sources":["../../../../../../src/components/typewriter/typewrite-view/animated-typewriter-text/AnimatedTypewriterText.tsx"],"sourcesContent":["import React, { FC, useCallback, useMemo } from 'react';\nimport { CSSPropertiesWithVars } from 'styled-components/dist/types';\nimport { StyledTypewriterText } from '../TypewriterView.styles';\n\ntype AnimatedTypewriterTextProps = {\n shouldHideCursor: boolean;\n shownText: string;\n textStyle?: CSSPropertiesWithVars;\n shouldRemainSingleLine: boolean;\n};\n\nconst AnimatedTypewriterText: FC<AnimatedTypewriterTextProps> = ({\n shouldHideCursor,\n shownText,\n shouldRemainSingleLine,\n textStyle,\n}) => {\n const updateTypewriterCursor = useCallback(\n (ref: HTMLSpanElement | null) => {\n if (ref && !shouldHideCursor) {\n // Finds the last text node with content.\n const traverseNodes = (node: Node): HTMLElement | null => {\n if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {\n return node.parentElement;\n }\n\n const childNodes = Array.from(node.childNodes);\n for (let i = childNodes.length - 1; i >= 0; i--) {\n const result = traverseNodes(childNodes[i] as Node);\n if (result) {\n return result;\n }\n }\n\n return null;\n };\n\n const lastParentWithContent = traverseNodes(ref);\n\n // Removes lastWithContent class from all elements\n ref.classList.remove('typewriter-lastWithContent');\n ref.querySelectorAll('.lastWithContent').forEach((element) => {\n element.classList.remove('typewriter-lastWithContent');\n });\n\n // Adds lastWithContent class to the last element with content\n if (lastParentWithContent) {\n lastParentWithContent.classList.add('typewriter-lastWithContent');\n } else {\n ref.classList.add('typewriter-lastWithContent');\n }\n }\n },\n [shouldHideCursor],\n );\n\n return useMemo(\n () => (\n <StyledTypewriterText\n ref={(ref) => updateTypewriterCursor(ref)}\n dangerouslySetInnerHTML={{ __html: shownText }}\n $shouldRemainSingleLine={shouldRemainSingleLine}\n style={textStyle}\n $isAnimatingText\n />\n ),\n [shownText, shouldRemainSingleLine, textStyle, updateTypewriterCursor],\n );\n};\n\nexport default AnimatedTypewriterText;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;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