@xiping/react-components 0.0.63 → 0.0.66
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/dist/cjs/components/hyper-text/index.d.ts +22 -0
- package/dist/cjs/components/hyper-text/index.js +1 -0
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
- package/dist/cjs/components/morphing-text/index.d.ts +6 -0
- package/dist/cjs/components/pinch-content/PinchContent.d.ts +2 -0
- package/dist/cjs/components/pinch-content/PinchContent.js +1 -1
- package/dist/cjs/components/shimmer-button/ShimmerButton.d.ts +12 -0
- package/dist/cjs/components/text-animate/TextAnimate.d.ts +52 -0
- package/dist/cjs/components/text-animate/index.d.ts +3 -0
- package/dist/cjs/components/typing-animation/index.d.ts +11 -0
- package/dist/cjs/components/typing-animation/index.js +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-components.css +1 -1
- package/dist/cjs/utils/utils.d.ts +2 -0
- package/dist/cjs/utils/utils.js +1 -0
- package/dist/es/components/hyper-text/index.d.ts +22 -0
- package/dist/es/components/hyper-text/index.js +73 -0
- package/dist/es/components/image-viewer/ImageViewer.js +70 -47
- package/dist/es/components/morphing-text/index.d.ts +6 -0
- package/dist/es/components/pinch-content/PinchContent.d.ts +2 -0
- package/dist/es/components/pinch-content/PinchContent.js +59 -40
- package/dist/es/components/shimmer-button/ShimmerButton.d.ts +12 -0
- package/dist/es/components/text-animate/TextAnimate.d.ts +52 -0
- package/dist/es/components/text-animate/index.d.ts +3 -0
- package/dist/es/components/typing-animation/index.d.ts +11 -0
- package/dist/es/components/typing-animation/index.js +58 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +12 -8
- package/dist/es/react-components.css +1 -1
- package/dist/es/utils/utils.d.ts +2 -0
- package/dist/es/utils/utils.js +8 -0
- package/package.json +30 -26
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("clsx"),t=require("tailwind-merge");function n(...e){return t.twMerge(r(e))}exports.cn=n;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MotionProps } from 'motion/react';
|
|
2
|
+
type CharacterSet = string[] | readonly string[];
|
|
3
|
+
interface HyperTextProps extends MotionProps {
|
|
4
|
+
/** The text content to be animated */
|
|
5
|
+
children: string;
|
|
6
|
+
/** Optional className for styling */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Duration of the animation in milliseconds */
|
|
9
|
+
duration?: number;
|
|
10
|
+
/** Delay before animation starts in milliseconds */
|
|
11
|
+
delay?: number;
|
|
12
|
+
/** Component to render as - defaults to div */
|
|
13
|
+
as?: React.ElementType;
|
|
14
|
+
/** Whether to start animation when element comes into view */
|
|
15
|
+
startOnView?: boolean;
|
|
16
|
+
/** Whether to trigger animation on hover */
|
|
17
|
+
animateOnHover?: boolean;
|
|
18
|
+
/** Custom character set for scramble effect. Defaults to uppercase alphabet */
|
|
19
|
+
characterSet?: CharacterSet;
|
|
20
|
+
}
|
|
21
|
+
export declare function HyperText({ children, className, duration, delay, as: Component, startOnView, animateOnHover, characterSet, ...props }: HyperTextProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default HyperText;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { cn as g } from "../../utils/utils.js";
|
|
3
|
+
import { motion as v, AnimatePresence as H } from "motion/react";
|
|
4
|
+
import { useState as x, useRef as I, useEffect as d } from "react";
|
|
5
|
+
const N = Object.freeze(
|
|
6
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
|
|
7
|
+
), P = (e) => Math.floor(Math.random() * e);
|
|
8
|
+
function L({
|
|
9
|
+
children: e,
|
|
10
|
+
className: A,
|
|
11
|
+
duration: m = 800,
|
|
12
|
+
delay: s = 0,
|
|
13
|
+
as: M = "div",
|
|
14
|
+
startOnView: f = !1,
|
|
15
|
+
animateOnHover: h = !0,
|
|
16
|
+
characterSet: i = N,
|
|
17
|
+
...C
|
|
18
|
+
}) {
|
|
19
|
+
const E = v.create(M, {
|
|
20
|
+
forwardMotionProps: !0
|
|
21
|
+
}), [R, b] = x(
|
|
22
|
+
() => e.split("")
|
|
23
|
+
), [a, o] = x(!1), r = I(0), c = I(null), D = () => {
|
|
24
|
+
h && !a && (r.current = 0, o(!0));
|
|
25
|
+
};
|
|
26
|
+
return d(() => {
|
|
27
|
+
if (!f) {
|
|
28
|
+
const n = setTimeout(() => {
|
|
29
|
+
o(!0);
|
|
30
|
+
}, s);
|
|
31
|
+
return () => clearTimeout(n);
|
|
32
|
+
}
|
|
33
|
+
const t = new IntersectionObserver(
|
|
34
|
+
([n]) => {
|
|
35
|
+
n.isIntersecting && (setTimeout(() => {
|
|
36
|
+
o(!0);
|
|
37
|
+
}, s), t.disconnect());
|
|
38
|
+
},
|
|
39
|
+
{ threshold: 0.1, rootMargin: "-30% 0px -30% 0px" }
|
|
40
|
+
);
|
|
41
|
+
return c.current && t.observe(c.current), () => t.disconnect();
|
|
42
|
+
}, [s, f]), d(() => {
|
|
43
|
+
if (!a) return;
|
|
44
|
+
const t = m / (e.length * 10), n = e.length, l = setInterval(() => {
|
|
45
|
+
r.current < n ? (b(
|
|
46
|
+
(w) => w.map(
|
|
47
|
+
(p, T) => p === " " ? p : T <= r.current ? e[T] : i[P(i.length)]
|
|
48
|
+
)
|
|
49
|
+
), r.current = r.current + 0.1) : (o(!1), clearInterval(l));
|
|
50
|
+
}, t);
|
|
51
|
+
return () => clearInterval(l);
|
|
52
|
+
}, [e, m, a, i]), /* @__PURE__ */ u(
|
|
53
|
+
E,
|
|
54
|
+
{
|
|
55
|
+
ref: c,
|
|
56
|
+
className: g("overflow-hidden py-2 text-4xl font-bold", A),
|
|
57
|
+
onMouseEnter: D,
|
|
58
|
+
...C,
|
|
59
|
+
children: /* @__PURE__ */ u(H, { children: R.map((t, n) => /* @__PURE__ */ u(
|
|
60
|
+
v.span,
|
|
61
|
+
{
|
|
62
|
+
className: g("font-mono", t === " " ? "w-3" : ""),
|
|
63
|
+
children: t.toUpperCase()
|
|
64
|
+
},
|
|
65
|
+
n
|
|
66
|
+
)) })
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
L as HyperText,
|
|
72
|
+
L as default
|
|
73
|
+
};
|
|
@@ -1,76 +1,99 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { Modal as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { Modal as C, ModalContent as k } from "@heroui/modal";
|
|
3
|
+
import { Spinner as z } from "@heroui/spinner";
|
|
4
|
+
import { IoDownloadOutline as j, IoCloseSharp as I } from "react-icons/io5";
|
|
5
|
+
import L from "../pinch-content/PinchContent.js";
|
|
6
|
+
import * as n from "@radix-ui/react-scroll-area";
|
|
7
|
+
import { useState as m } from "react";
|
|
8
|
+
const D = (h) => {
|
|
9
|
+
const { isOpen: p, onClose: b, imgSrc: s, canDownload: u = !1 } = h, r = Array.isArray(s) ? s : [s], [i, g] = m(0), [w, c] = m(!0), d = () => {
|
|
10
|
+
c(!0), b();
|
|
11
|
+
}, x = async () => {
|
|
12
|
+
const o = r[i];
|
|
9
13
|
try {
|
|
10
|
-
const
|
|
11
|
-
|
|
14
|
+
const y = await (await fetch(o)).blob(), f = window.URL.createObjectURL(y), t = document.createElement("a");
|
|
15
|
+
t.href = f, t.download = o.split("/").pop() || "image", document.body.appendChild(t), t.click(), window.URL.revokeObjectURL(f), document.body.removeChild(t);
|
|
12
16
|
} catch (a) {
|
|
13
17
|
console.error("Error downloading image:", a);
|
|
14
18
|
}
|
|
19
|
+
}, N = () => {
|
|
20
|
+
c(!1);
|
|
21
|
+
}, v = () => {
|
|
22
|
+
c(!1);
|
|
15
23
|
};
|
|
16
24
|
return /* @__PURE__ */ e(
|
|
17
|
-
|
|
25
|
+
C,
|
|
18
26
|
{
|
|
19
|
-
isOpen:
|
|
27
|
+
isOpen: p,
|
|
20
28
|
size: "full",
|
|
21
|
-
onClose:
|
|
29
|
+
onClose: d,
|
|
22
30
|
className: "bg-black bg-opacity-70",
|
|
23
31
|
hideCloseButton: !0,
|
|
24
32
|
portalContainer: document.body,
|
|
25
|
-
children: /* @__PURE__ */ e(
|
|
26
|
-
/* @__PURE__ */
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
children: /* @__PURE__ */ e(k, { className: "overflow-hidden", children: /* @__PURE__ */ l("div", { className: "w-screen h-screen relative flex flex-col pt-safe-offset-0", children: [
|
|
34
|
+
/* @__PURE__ */ l("div", { className: "absolute top-2 right-2 flex gap-4 z-10", children: [
|
|
35
|
+
u && /* @__PURE__ */ e(
|
|
36
|
+
j,
|
|
29
37
|
{
|
|
30
38
|
size: 24,
|
|
31
39
|
className: "text-white cursor-pointer",
|
|
32
|
-
onClick:
|
|
40
|
+
onClick: x
|
|
33
41
|
}
|
|
34
42
|
),
|
|
35
43
|
/* @__PURE__ */ e(
|
|
36
|
-
|
|
44
|
+
I,
|
|
37
45
|
{
|
|
38
46
|
size: 24,
|
|
39
47
|
className: "text-white cursor-pointer",
|
|
40
|
-
onClick:
|
|
48
|
+
onClick: d
|
|
41
49
|
}
|
|
42
50
|
)
|
|
43
51
|
] }),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
/* @__PURE__ */ l("div", { className: "flex-1 min-h-0 relative flex items-center justify-center", children: [
|
|
53
|
+
/* @__PURE__ */ e(L, { canRotate: !1, className: "w-full h-full", children: /* @__PURE__ */ e(
|
|
54
|
+
"img",
|
|
55
|
+
{
|
|
56
|
+
draggable: "false",
|
|
57
|
+
src: r[i],
|
|
58
|
+
alt: "",
|
|
59
|
+
className: "w-screen h-full object-contain pointer-events-none",
|
|
60
|
+
onLoad: N,
|
|
61
|
+
onError: v
|
|
62
|
+
}
|
|
63
|
+
) }),
|
|
64
|
+
w && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black bg-opacity-50", children: /* @__PURE__ */ e(z, { color: "white", size: "lg" }) })
|
|
65
|
+
] }),
|
|
66
|
+
r.length > 1 && /* @__PURE__ */ e("div", { className: "h-24 bg-black bg-opacity-50 shrink-0 z-10 pb-safe-offset-0 pl-safe-offset-0 pr-safe-offset-0", children: /* @__PURE__ */ l(n.Root, { className: "h-24 w-screen", type: "auto", children: [
|
|
67
|
+
/* @__PURE__ */ e(n.Viewport, { className: "pppp h-full w-full", children: /* @__PURE__ */ e("div", { className: "flex gap-2 p-2 h-24", children: r.map((o, a) => /* @__PURE__ */ e(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: `h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${a === i ? "border-white" : "border-transparent"}`,
|
|
71
|
+
onClick: () => g(a),
|
|
72
|
+
children: /* @__PURE__ */ e(
|
|
73
|
+
"img",
|
|
74
|
+
{
|
|
75
|
+
src: o,
|
|
76
|
+
alt: "",
|
|
77
|
+
className: "w-full h-full object-contain",
|
|
78
|
+
draggable: "false"
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
o
|
|
83
|
+
)) }) }),
|
|
84
|
+
/* @__PURE__ */ e(
|
|
85
|
+
n.Scrollbar,
|
|
86
|
+
{
|
|
87
|
+
className: "flex select-none touch-none p-0.5 bg-black/50 transition-colors duration-150 ease-out hover:bg-black/80 data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5 data-[orientation=horizontal]:flex-col",
|
|
88
|
+
orientation: "horizontal",
|
|
89
|
+
children: /* @__PURE__ */ e(n.Thumb, { className: "flex-1 bg-white/50 rounded-[10px] relative before:content-[''] before:absolute before:top-1/2 before:left-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:w-full before:h-full before:min-w-[44px] before:min-h-[44px]" })
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] }) })
|
|
70
93
|
] }) })
|
|
71
94
|
}
|
|
72
95
|
);
|
|
73
96
|
};
|
|
74
97
|
export {
|
|
75
|
-
|
|
98
|
+
D as default
|
|
76
99
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export interface PinchContentProps {
|
|
3
|
+
className?: string;
|
|
3
4
|
children?: ReactNode;
|
|
4
5
|
canDrag?: boolean;
|
|
5
6
|
canPinch?: boolean;
|
|
@@ -8,6 +9,7 @@ export interface PinchContentProps {
|
|
|
8
9
|
min: number;
|
|
9
10
|
max: number;
|
|
10
11
|
};
|
|
12
|
+
wheelZoomFactor?: number;
|
|
11
13
|
}
|
|
12
14
|
declare const PinchContent: (props: PinchContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
export default PinchContent;
|
|
@@ -1,61 +1,80 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import { createUseGesture as
|
|
1
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as R, animated as B } from "@react-spring/web";
|
|
3
|
+
import { createUseGesture as C, dragAction as G, pinchAction as N, wheelAction as U } from "@use-gesture/react";
|
|
4
4
|
import { useRef as j } from "react";
|
|
5
|
-
import { useMount as
|
|
6
|
-
|
|
5
|
+
import { useMount as F, useUnmount as W } from "ahooks";
|
|
6
|
+
import k from "clsx";
|
|
7
|
+
const q = C([G, N, U]), o = (i) => i.preventDefault(), Q = (i) => {
|
|
7
8
|
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
className: m,
|
|
10
|
+
children: h,
|
|
11
|
+
canPinch: g = !0,
|
|
12
|
+
canDrag: p = !0,
|
|
13
|
+
canRotate: v = !0,
|
|
14
|
+
scaleBounds: l = { min: 0.3, max: 10 },
|
|
15
|
+
wheelZoomFactor: x = 0.1
|
|
16
|
+
} = i, n = j(null);
|
|
17
|
+
F(() => {
|
|
18
|
+
var t, e, r;
|
|
19
|
+
(t = n.current) == null || t.addEventListener("gesturestart", o), (e = n.current) == null || e.addEventListener("gesturechange", o), (r = n.current) == null || r.addEventListener("gestureend", o);
|
|
20
|
+
}), W(() => {
|
|
21
|
+
var t, e, r;
|
|
22
|
+
(t = n.current) == null || t.removeEventListener("gesturestart", o), (e = n.current) == null || e.removeEventListener("gesturechange", o), (r = n.current) == null || r.removeEventListener("gestureend", o);
|
|
20
23
|
});
|
|
21
|
-
const [
|
|
24
|
+
const [s, d] = R(() => ({
|
|
22
25
|
x: 0,
|
|
23
26
|
y: 0,
|
|
24
27
|
scale: 1,
|
|
25
28
|
rotateZ: 0
|
|
26
29
|
}));
|
|
27
|
-
return
|
|
30
|
+
return q(
|
|
28
31
|
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
onWheel: ({ event: t, delta: [, e] }) => {
|
|
33
|
+
if (!g) return;
|
|
34
|
+
const a = s.scale.get() * (1 - e * x), u = Math.min(
|
|
35
|
+
Math.max(a, l.min),
|
|
36
|
+
l.max
|
|
37
|
+
);
|
|
38
|
+
d.start({ scale: u });
|
|
39
|
+
},
|
|
40
|
+
onDrag: ({ pinching: t, cancel: e, offset: [r, a], ...u }) => {
|
|
41
|
+
if (!p || t) return e();
|
|
42
|
+
d.start({ x: r, y: a });
|
|
34
43
|
},
|
|
35
44
|
onPinch: ({
|
|
36
|
-
origin: [
|
|
37
|
-
first:
|
|
45
|
+
origin: [t, e],
|
|
46
|
+
first: r,
|
|
38
47
|
movement: [a],
|
|
39
|
-
offset: [u,
|
|
40
|
-
memo:
|
|
41
|
-
cancel:
|
|
48
|
+
offset: [u, y],
|
|
49
|
+
memo: c,
|
|
50
|
+
cancel: E
|
|
42
51
|
}) => {
|
|
43
|
-
if (!
|
|
44
|
-
if (
|
|
45
|
-
const { width:
|
|
46
|
-
|
|
52
|
+
if (!g) return E();
|
|
53
|
+
if (r) {
|
|
54
|
+
const { width: S, height: b, x: Z, y: A } = n.current.getBoundingClientRect(), D = t - (Z + S / 2), M = e - (A + b / 2);
|
|
55
|
+
c = [s.x.get(), s.y.get(), D, M];
|
|
47
56
|
}
|
|
48
|
-
const
|
|
49
|
-
return
|
|
57
|
+
const L = c[0] - (a - 1) * c[2], w = c[1] - (a - 1) * c[3], f = { scale: u, rotateZ: 0, x: L, y: w };
|
|
58
|
+
return v && (f.rotateZ = y), d.start(f), c;
|
|
50
59
|
}
|
|
51
60
|
},
|
|
52
61
|
{
|
|
53
|
-
target:
|
|
54
|
-
drag: { from: () => [
|
|
55
|
-
pinch: { scaleBounds:
|
|
62
|
+
target: n,
|
|
63
|
+
drag: { from: () => [s.x.get(), s.y.get()] },
|
|
64
|
+
pinch: { scaleBounds: l, rubberband: !0 },
|
|
65
|
+
wheel: { enabled: !0 }
|
|
66
|
+
}
|
|
67
|
+
), // <div className="flex items-center justify-center h-full w-full">
|
|
68
|
+
/* @__PURE__ */ P(
|
|
69
|
+
B.div,
|
|
70
|
+
{
|
|
71
|
+
className: k("select-none", m),
|
|
72
|
+
ref: n,
|
|
73
|
+
style: s,
|
|
74
|
+
children: h
|
|
56
75
|
}
|
|
57
|
-
)
|
|
76
|
+
);
|
|
58
77
|
};
|
|
59
78
|
export {
|
|
60
|
-
|
|
79
|
+
Q as default
|
|
61
80
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface ShimmerButtonProps extends ComponentPropsWithoutRef<"button"> {
|
|
3
|
+
shimmerColor?: string;
|
|
4
|
+
shimmerSize?: string;
|
|
5
|
+
borderRadius?: string;
|
|
6
|
+
shimmerDuration?: string;
|
|
7
|
+
background?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const ShimmerButton: React.ForwardRefExoticComponent<ShimmerButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export default ShimmerButton;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MotionProps, Variants } from 'motion/react';
|
|
2
|
+
import { ElementType } from 'react';
|
|
3
|
+
type AnimationType = "text" | "word" | "character" | "line";
|
|
4
|
+
type AnimationVariant = "fadeIn" | "blurIn" | "blurInUp" | "blurInDown" | "slideUp" | "slideDown" | "slideLeft" | "slideRight" | "scaleUp" | "scaleDown";
|
|
5
|
+
interface TextAnimateProps extends MotionProps {
|
|
6
|
+
/**
|
|
7
|
+
* The text content to animate
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
/**
|
|
11
|
+
* The class name to be applied to the component
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The class name to be applied to each segment
|
|
16
|
+
*/
|
|
17
|
+
segmentClassName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The delay before the animation starts
|
|
20
|
+
*/
|
|
21
|
+
delay?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The duration of the animation
|
|
24
|
+
*/
|
|
25
|
+
duration?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Custom motion variants for the animation
|
|
28
|
+
*/
|
|
29
|
+
variants?: Variants;
|
|
30
|
+
/**
|
|
31
|
+
* The element type to render
|
|
32
|
+
*/
|
|
33
|
+
as?: ElementType;
|
|
34
|
+
/**
|
|
35
|
+
* How to split the text ("text", "word", "character")
|
|
36
|
+
*/
|
|
37
|
+
by?: AnimationType;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to start animation when component enters viewport
|
|
40
|
+
*/
|
|
41
|
+
startOnView?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to animate only once
|
|
44
|
+
*/
|
|
45
|
+
once?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The animation preset to use
|
|
48
|
+
*/
|
|
49
|
+
animation?: AnimationVariant;
|
|
50
|
+
}
|
|
51
|
+
export declare function TextAnimate({ children, delay, duration, variants, className, segmentClassName, as: Component, startOnView, once, by, animation, ...props }: TextAnimateProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MotionProps } from 'motion/react';
|
|
2
|
+
interface TypingAnimationProps extends MotionProps {
|
|
3
|
+
children: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
duration?: number;
|
|
6
|
+
delay?: number;
|
|
7
|
+
as?: React.ElementType;
|
|
8
|
+
startOnView?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function TypingAnimation({ children, className, duration, delay, as: Component, startOnView, ...props }: TypingAnimationProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default TypingAnimation;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
2
|
+
import { cn as x } from "../../utils/utils.js";
|
|
3
|
+
import { motion as b } from "motion/react";
|
|
4
|
+
import { useState as a, useRef as I, useEffect as u } from "react";
|
|
5
|
+
function R({
|
|
6
|
+
children: r,
|
|
7
|
+
className: l,
|
|
8
|
+
duration: s = 100,
|
|
9
|
+
delay: n = 0,
|
|
10
|
+
as: m = "div",
|
|
11
|
+
startOnView: i = !1,
|
|
12
|
+
...p
|
|
13
|
+
}) {
|
|
14
|
+
const d = b.create(m, {
|
|
15
|
+
forwardMotionProps: !0
|
|
16
|
+
}), [g, v] = a(""), [c, f] = a(!1), o = I(null);
|
|
17
|
+
return u(() => {
|
|
18
|
+
if (!i) {
|
|
19
|
+
const t = setTimeout(() => {
|
|
20
|
+
f(!0);
|
|
21
|
+
}, n);
|
|
22
|
+
return () => clearTimeout(t);
|
|
23
|
+
}
|
|
24
|
+
const e = new IntersectionObserver(
|
|
25
|
+
([t]) => {
|
|
26
|
+
t.isIntersecting && (setTimeout(() => {
|
|
27
|
+
f(!0);
|
|
28
|
+
}, n), e.disconnect());
|
|
29
|
+
},
|
|
30
|
+
{ threshold: 0.1 }
|
|
31
|
+
);
|
|
32
|
+
return o.current && e.observe(o.current), () => e.disconnect();
|
|
33
|
+
}, [n, i]), u(() => {
|
|
34
|
+
if (!c) return;
|
|
35
|
+
let e = 0;
|
|
36
|
+
const t = setInterval(() => {
|
|
37
|
+
e < r.length ? (v(r.substring(0, e + 1)), e++) : clearInterval(t);
|
|
38
|
+
}, s);
|
|
39
|
+
return () => {
|
|
40
|
+
clearInterval(t);
|
|
41
|
+
};
|
|
42
|
+
}, [r, s, c]), /* @__PURE__ */ T(
|
|
43
|
+
d,
|
|
44
|
+
{
|
|
45
|
+
ref: o,
|
|
46
|
+
className: x(
|
|
47
|
+
"text-4xl font-bold leading-[5rem] tracking-[-0.02em]",
|
|
48
|
+
l
|
|
49
|
+
),
|
|
50
|
+
...p,
|
|
51
|
+
children: g
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
R as TypingAnimation,
|
|
57
|
+
R as default
|
|
58
|
+
};
|
package/dist/es/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export * from './components/button/Button';
|
|
|
2
2
|
export * from './components/txt-reader/TxtReader';
|
|
3
3
|
export * from './components/pinch-content';
|
|
4
4
|
export * from './components/image-viewer';
|
|
5
|
+
export * from './components/hyper-text';
|
|
6
|
+
export * from './components/typing-animation';
|
package/dist/es/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import { Button as
|
|
3
|
-
import { TxtReader as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { Button as t } from "./components/button/Button.js";
|
|
3
|
+
import { TxtReader as p } from "./components/txt-reader/TxtReader.js";
|
|
4
|
+
import { HyperText as x } from "./components/hyper-text/index.js";
|
|
5
|
+
import { TypingAnimation as n } from "./components/typing-animation/index.js";
|
|
6
|
+
import { default as d } from "./components/pinch-content/PinchContent.js";
|
|
7
|
+
import { default as T } from "./components/image-viewer/ImageViewer.js";
|
|
6
8
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
t as Button,
|
|
10
|
+
x as HyperText,
|
|
11
|
+
T as ImageViewer,
|
|
12
|
+
d as PinchContent,
|
|
13
|
+
p as TxtReader,
|
|
14
|
+
n as TypingAnimation
|
|
11
15
|
};
|