textimation 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TheeKia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # textimation
2
+
3
+ Animated Text
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add textimation
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import 'textimation/styles.css';
15
+ import { Button } from 'textimation';
16
+
17
+ function App() {
18
+ return <Button>Click me</Button>;
19
+ }
20
+ ```
21
+
22
+ ## Contributing
23
+
24
+ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for contribution guidelines.
25
+
26
+ ## License
27
+
28
+ MIT
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .textimation-hiddenText{position:absolute;opacity:0;inset:0}.textimation-incorrectChar{opacity:.2}
@@ -0,0 +1,9 @@
1
+ interface AnimatedTextProps {
2
+ text: string;
3
+ animationSpeed?: number;
4
+ className?: string;
5
+ keepCorrectChars?: boolean;
6
+ Comp?: React.ElementType;
7
+ }
8
+ declare function AnimatedText({ text, animationSpeed, className, keepCorrectChars, Comp }: AnimatedTextProps): React.ReactNode;
9
+ export { AnimatedText };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import{useEffect as b,useMemo as x,useRef as c,useState as y}from"react";import{useIntersectionObserver as N}from"usehooks-ts";function R(){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%&*"[Math.floor(Math.random()*69)]}import{jsx as A,jsxs as O}from"react/jsx-runtime";function v({text:e,animationSpeed:r=50,className:u="",keepCorrectChars:n=!1,Comp:M="span"}){let{isIntersecting:h,ref:C}=N({threshold:0}),[l,m]=y("idle"),f=c(e.replace(/\s/g," ").replace(/\S/g," ").split("")),i=c(null),s=c(""),p=c(null),g=x(()=>{return h||l==="animating"},[h,l]);return b(()=>{if(!g)return;if(e===s.current)return;m("animating");let d=s.current,S=Math.max(d.length,e.length),a=Array.from({length:S},(t,o)=>{if(n&&d[o]===e[o])return-1;if(d.length===0&&e[o]===" ")return 1;return Math.max(5,Math.ceil(Math.random()*20))});function T(){if(a.every((t)=>t<0)){if(f.current=e.split(""),i.current)i.current.textContent=e;s.current=e,m("finished");return}for(let t=0;t<a.length;t++){if(a[t]===-1)continue;a[t]--}if(i.current)H(f.current,a,e),i.current.innerHTML=f.current.map((t,o)=>{if(t===e[o])return`<span>${t}</span>`;else return`<span class="textimation-incorrectChar">${t}</span>`}).join("");p.current=setTimeout(T,r)}return T(),()=>{if(m("idle"),s.current=e,p.current)clearTimeout(p.current)}},[e,r,n,g]),O(M,{ref:C,style:{position:"relative"},className:u,children:[l==="idle"&&A("span",{className:"textimation-hiddenText",children:e}),A("span",{ref:i})]})}function H(e,r,u){for(let n=0;n<r.length;n++)switch(r[n]){case-1:break;case 0:e[n]=u[n];break;default:e[n]=R();break}}export{v as AnimatedText};
2
+ // built with love
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "textimation",
3
+ "version": "0.1.1",
4
+ "description": "Animated Text",
5
+ "homepage": "https://github.com/TheeKia/textimation#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/TheeKia/textimation/issues"
8
+ },
9
+ "license": "MIT",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/TheeKia/textimation.git"
16
+ },
17
+ "scripts": {
18
+ "build": "bunup --env.NODE_ENV='production' --minify --no-sourcemap --footer '// built with love'",
19
+ "dev": "bun run --cwd test/ui dev",
20
+ "postinstall": "bun simple-git-hooks",
21
+ "lint": "biome check .",
22
+ "lint:fix": "biome check --write .",
23
+ "release": "bumpp --commit --push --tag",
24
+ "test": "bun test",
25
+ "test:coverage": "bun test --coverage",
26
+ "test:watch": "bun test --watch",
27
+ "type-check": "tsc --noEmit"
28
+ },
29
+ "devDependencies": {
30
+ "@biomejs/biome": "^2.3.7",
31
+ "@types/bun": "^1.3.3",
32
+ "@types/react": "^19.2.6",
33
+ "bumpp": "^10.3.1",
34
+ "bunup": "^0.16.10",
35
+ "react": "^19.2.0",
36
+ "react-dom": "^19.2.0",
37
+ "simple-git-hooks": "^2.13.1",
38
+ "typescript": "^5.9.3"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18.0.0 || ^19.0.0",
42
+ "react-dom": "^18.0.0 || ^19.0.0",
43
+ "typescript": ">=4.5.0",
44
+ "usehooks-ts": "^3.1.1"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "typescript": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "workspaces": [
52
+ "test/**"
53
+ ],
54
+ "type": "module",
55
+ "exports": {
56
+ ".": {
57
+ "import": {
58
+ "types": "./dist/index.d.ts",
59
+ "default": "./dist/index.js"
60
+ }
61
+ },
62
+ "./styles.css": "./dist/index.css",
63
+ "./package.json": "./package.json"
64
+ },
65
+ "module": "./dist/index.js",
66
+ "simple-git-hooks": {
67
+ "pre-commit": "bun run lint && bun run type-check"
68
+ },
69
+ "types": "./dist/index.d.ts",
70
+ "trustedDependencies": [
71
+ "@bunup/dts"
72
+ ]
73
+ }