Skip to content

Commit 5aeb044

Browse files
authored
Merge pull request #2 from kalkson/v1
fix type bundling (v1.0.1)
2 parents 783673c + 683c278 commit 5aeb044

19 files changed

+180
-222
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.1
2+
3+
- fixed types bundling
4+
5+
16
## 1.0.0
27

38
- created initial version

dist/constants.d.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

dist/helpers.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/index.d.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
import { FC } from 'react';
2-
import { AnimatedTextProps } from './types';
1+
import { ElementType, ReactText, FC } from 'react';
2+
export interface AnimationShapeType {
3+
x?: string;
4+
y?: string;
5+
scale?: number;
6+
ease?: string;
7+
}
8+
declare type AnimationType = 'blocks' | 'wave' | 'float' | 'bounce' | 'throw' | 'diagonal' | 'rifle' | 'lights';
9+
interface AnimatedTextProps {
10+
type?: 'chars' | 'words';
11+
children?: ReactText;
12+
interval?: number;
13+
duration?: number;
14+
animation?: AnimationShapeType;
15+
animationType?: AnimationType;
16+
tag?: ElementType;
17+
className?: string;
18+
includeWhiteSpaces?: boolean;
19+
threshold?: number;
20+
rootMargin?: string;
21+
}
22+
export declare const WHITE_SPACE_CODE = " ";
323
declare const AnimatedText: FC<AnimatedTextProps>;
424
export default AnimatedText;

dist/react-animated-text-content.development.js

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,44 @@ function __rest(s, e) {
5050
function __makeTemplateObject(cooked, raw) {
5151
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
5252
return cooked;
53-
}var PREDEFINED_ANIMATIONS = {
53+
}var splitChildrenToFragments = function (children) {
54+
return children.toString().split(' ');
55+
};
56+
var concatFragments = function (children) {
57+
var _a;
58+
var splittedChildren = splitChildrenToFragments(children);
59+
return (_a = [])
60+
.concat.apply(_a, splittedChildren.map(function (word, index) {
61+
return index !== 0 ? [WHITE_SPACE_CODE, word] : [word];
62+
})).map(function (word) { return (word === ' ' ? WHITE_SPACE_CODE : word); });
63+
};var AnimatedFragment = styled__default["default"].span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n display: inline-block;\n visibility: hidden;\n"], ["\n position: relative;\n display: inline-block;\n visibility: hidden;\n"])));
64+
var StyledWrapper = styled__default["default"].div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n @keyframes fragmentletter-", " {\n 0% {\n opacity: 0;\n visibility: hidden;\n transform: translateX(", ")\n translateY(", ")\n scale(", ");\n }\n 100% {\n oapcity: 1;\n visibility: visible;\n transform: translateX(0) translateY(0) scale(1);\n }\n }\n\n & > span {\n display: inline-block;\n }\n\n & ", " {\n text-decoration: inherit;\n vertical-align: inherit;\n\n animation: ", ";\n\n animation-name: ", ";\n }\n\n ", "\n"], ["\n @keyframes fragmentletter-", " {\n 0% {\n opacity: 0;\n visibility: hidden;\n transform: translateX(", ")\n translateY(", ")\n scale(", ");\n }\n 100% {\n oapcity: 1;\n visibility: visible;\n transform: translateX(0) translateY(0) scale(1);\n }\n }\n\n & > span {\n display: inline-block;\n }\n\n & ", " {\n text-decoration: inherit;\n vertical-align: inherit;\n\n animation: ", ";\n\n animation-name: ", ";\n }\n\n ", "\n"])), function (_a) {
65+
var uid = _a.uid;
66+
return uid;
67+
}, function (_a) {
68+
var x = _a.animation.x;
69+
return x !== null && x !== void 0 ? x : 0;
70+
}, function (_a) {
71+
var y = _a.animation.y;
72+
return y !== null && y !== void 0 ? y : 0;
73+
}, function (_a) {
74+
var scale = _a.animation.scale;
75+
return scale !== null && scale !== void 0 ? scale : 1;
76+
}, AnimatedFragment, function (_a) {
77+
var ease = _a.animation.ease, duration = _a.duration;
78+
return "".concat(duration, "s ").concat(ease !== null && ease !== void 0 ? ease : 'ease-in-out', " forwards;");
79+
}, function (_a) {
80+
var shouldAnimate = _a.shouldAnimate, uid = _a.uid;
81+
return shouldAnimate ? "fragmentletter-".concat(uid) : '';
82+
}, function (_a) {
83+
var _b = _a.count, count = _b === void 0 ? 0 : _b, interval = _a.interval;
84+
var styles = '';
85+
for (var i = 0; i < count; i += 1) {
86+
styles += "".concat(AnimatedFragment, ":nth-of-type(").concat(i + 1, ") {\n animation-delay: ").concat((interval || 0.04) * i, "s;\n }");
87+
}
88+
return styled.css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), styles);
89+
});
90+
var templateObject_1, templateObject_2, templateObject_3;var PREDEFINED_ANIMATIONS = {
5491
blocks: {
5592
y: '60px',
5693
interval: 0.07,
@@ -102,44 +139,8 @@ var DEFAULT_ANIMATION = {
102139
};
103140
var DEFAULT_TAG = 'div';
104141
var DEFAULT_INTESECTION_OBSERVER_ROOT_MARGIN = '20%';
105-
var DEFAULT_THRESHOLD = 0;var splitChildrenToFragments = function (children) {
106-
return children.toString().split(' ');
107-
};
108-
var concatFragments = function (children) {
109-
var _a;
110-
var splittedChildren = splitChildrenToFragments(children);
111-
return (_a = [])
112-
.concat.apply(_a, splittedChildren.map(function (word, index) {
113-
return index !== 0 ? [WHITE_SPACE_CODE, word] : [word];
114-
})).map(function (word) { return (word === ' ' ? WHITE_SPACE_CODE : word); });
115-
};var AnimatedFragment = styled__default["default"].span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n display: inline-block;\n visibility: hidden;\n"], ["\n position: relative;\n display: inline-block;\n visibility: hidden;\n"])));
116-
var StyledWrapper = styled__default["default"].div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n @keyframes fragmentletter-", " {\n 0% {\n opacity: 0;\n visibility: hidden;\n transform: translateX(", ")\n translateY(", ")\n scale(", ");\n }\n 100% {\n oapcity: 1;\n visibility: visible;\n transform: translateX(0) translateY(0) scale(1);\n }\n }\n\n & > span {\n display: inline-block;\n }\n\n & ", " {\n text-decoration: inherit;\n vertical-align: inherit;\n\n animation: ", ";\n\n animation-name: ", ";\n }\n\n ", "\n"], ["\n @keyframes fragmentletter-", " {\n 0% {\n opacity: 0;\n visibility: hidden;\n transform: translateX(", ")\n translateY(", ")\n scale(", ");\n }\n 100% {\n oapcity: 1;\n visibility: visible;\n transform: translateX(0) translateY(0) scale(1);\n }\n }\n\n & > span {\n display: inline-block;\n }\n\n & ", " {\n text-decoration: inherit;\n vertical-align: inherit;\n\n animation: ", ";\n\n animation-name: ", ";\n }\n\n ", "\n"])), function (_a) {
117-
var uid = _a.uid;
118-
return uid;
119-
}, function (_a) {
120-
var x = _a.animation.x;
121-
return x !== null && x !== void 0 ? x : 0;
122-
}, function (_a) {
123-
var y = _a.animation.y;
124-
return y !== null && y !== void 0 ? y : 0;
125-
}, function (_a) {
126-
var scale = _a.animation.scale;
127-
return scale !== null && scale !== void 0 ? scale : 1;
128-
}, AnimatedFragment, function (_a) {
129-
var ease = _a.animation.ease, duration = _a.duration;
130-
return "".concat(duration, "s ").concat(ease !== null && ease !== void 0 ? ease : 'ease-in-out', " forwards;");
131-
}, function (_a) {
132-
var shouldAnimate = _a.shouldAnimate, uid = _a.uid;
133-
return shouldAnimate ? "fragmentletter-".concat(uid) : '';
134-
}, function (_a) {
135-
var _b = _a.count, count = _b === void 0 ? 0 : _b, interval = _a.interval;
136-
var styles = '';
137-
for (var i = 0; i < count; i += 1) {
138-
styles += "".concat(AnimatedFragment, ":nth-of-type(").concat(i + 1, ") {\n animation-delay: ").concat((interval || 0.04) * i, "s;\n }");
139-
}
140-
return styled.css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), styles);
141-
});
142-
var templateObject_1, templateObject_2, templateObject_3;var renderWords = function (arrayToRender, includeWhiteSpaces) {
142+
var DEFAULT_THRESHOLD = 0;
143+
var renderWords = function (arrayToRender, includeWhiteSpaces) {
143144
return arrayToRender.map(function (fragment, index) {
144145
return fragment !== WHITE_SPACE_CODE ? (React__default["default"].createElement(AnimatedFragment, { key: index, dangerouslySetInnerHTML: { __html: fragment } })) : ((includeWhiteSpaces && (React__default["default"].createElement(AnimatedFragment, { key: "".concat(index, "&nbsp;"), dangerouslySetInnerHTML: { __html: '&nbsp;' } }))) ||
145146
WHITE_SPACE_CODE);
@@ -195,4 +196,4 @@ var AnimatedText = function (_a) {
195196
return (React__default["default"].createElement(StyledWrapper, __assign({ as: tag, count: type === 'words' ? arrayToRender.length : 0, interval: interval || ((_c = animationOptions === null || animationOptions === void 0 ? void 0 : animationOptions.interval) !== null && _c !== void 0 ? _c : DEFAULT_INTERVAL), duration: duration || ((_d = animationOptions === null || animationOptions === void 0 ? void 0 : animationOptions.duration) !== null && _d !== void 0 ? _d : DEFAULT_DURATION), ref: wrapperRef, shouldAnimate: shouldAnimate, uid: uid, animation: animationOptions, "data-testid": "animated-text" }, props), type === 'words'
196197
? renderWords(arrayToRender, includeWhiteSpaces)
197198
: renderChars(arrayToRender, interval || ((_e = animationOptions === null || animationOptions === void 0 ? void 0 : animationOptions.interval) !== null && _e !== void 0 ? _e : DEFAULT_INTERVAL), includeWhiteSpaces)));
198-
};exports["default"]=AnimatedText;Object.defineProperty(exports,'__esModule',{value:true});}));//# sourceMappingURL=react-animated-text-content.development.js.map
199+
};exports.WHITE_SPACE_CODE=WHITE_SPACE_CODE;exports["default"]=AnimatedText;Object.defineProperty(exports,'__esModule',{value:true});}));//# sourceMappingURL=react-animated-text-content.development.js.map

0 commit comments

Comments
 (0)