@trindtech/utils 1.2.0 → 1.3.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.
Files changed (77) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/motion/components/canvas-scrub.d.ts +21 -0
  6. package/dist/motion/components/canvas-scrub.d.ts.map +1 -0
  7. package/dist/motion/components/canvas-scrub.js +80 -0
  8. package/dist/motion/components/canvas-scrub.js.map +1 -0
  9. package/dist/motion/components/count-up.d.ts +15 -0
  10. package/dist/motion/components/count-up.d.ts.map +1 -0
  11. package/dist/motion/components/count-up.js +35 -0
  12. package/dist/motion/components/count-up.js.map +1 -0
  13. package/dist/motion/components/horizontal-scroll.d.ts +11 -0
  14. package/dist/motion/components/horizontal-scroll.d.ts.map +1 -0
  15. package/dist/motion/components/horizontal-scroll.js +46 -0
  16. package/dist/motion/components/horizontal-scroll.js.map +1 -0
  17. package/dist/motion/components/logo-marquee.d.ts +17 -0
  18. package/dist/motion/components/logo-marquee.d.ts.map +1 -0
  19. package/dist/motion/components/logo-marquee.js +21 -0
  20. package/dist/motion/components/logo-marquee.js.map +1 -0
  21. package/dist/motion/components/navbar.d.ts +21 -0
  22. package/dist/motion/components/navbar.d.ts.map +1 -0
  23. package/dist/motion/components/navbar.js +32 -0
  24. package/dist/motion/components/navbar.js.map +1 -0
  25. package/dist/motion/components/parallax-section.d.ts +10 -0
  26. package/dist/motion/components/parallax-section.d.ts.map +1 -0
  27. package/dist/motion/components/parallax-section.js +18 -0
  28. package/dist/motion/components/parallax-section.js.map +1 -0
  29. package/dist/motion/components/reveal-on-scroll.d.ts +15 -0
  30. package/dist/motion/components/reveal-on-scroll.d.ts.map +1 -0
  31. package/dist/motion/components/reveal-on-scroll.js +21 -0
  32. package/dist/motion/components/reveal-on-scroll.js.map +1 -0
  33. package/dist/motion/components/stacked-cards.d.ts +15 -0
  34. package/dist/motion/components/stacked-cards.d.ts.map +1 -0
  35. package/dist/motion/components/stacked-cards.js +53 -0
  36. package/dist/motion/components/stacked-cards.js.map +1 -0
  37. package/dist/motion/components/text-reveal.d.ts +14 -0
  38. package/dist/motion/components/text-reveal.d.ts.map +1 -0
  39. package/dist/motion/components/text-reveal.js +38 -0
  40. package/dist/motion/components/text-reveal.js.map +1 -0
  41. package/dist/motion/components/video-scrub.d.ts +9 -0
  42. package/dist/motion/components/video-scrub.d.ts.map +1 -0
  43. package/dist/motion/components/video-scrub.js +40 -0
  44. package/dist/motion/components/video-scrub.js.map +1 -0
  45. package/dist/motion/index.d.ts +14 -0
  46. package/dist/motion/index.d.ts.map +1 -0
  47. package/dist/motion/index.js +30 -0
  48. package/dist/motion/index.js.map +1 -0
  49. package/dist/motion/providers/motion-provider.d.ts +7 -0
  50. package/dist/motion/providers/motion-provider.d.ts.map +1 -0
  51. package/dist/motion/providers/motion-provider.js +11 -0
  52. package/dist/motion/providers/motion-provider.js.map +1 -0
  53. package/dist/motion/providers/smooth-scroll-provider.d.ts +7 -0
  54. package/dist/motion/providers/smooth-scroll-provider.d.ts.map +1 -0
  55. package/dist/motion/providers/smooth-scroll-provider.js +27 -0
  56. package/dist/motion/providers/smooth-scroll-provider.js.map +1 -0
  57. package/dist/motion/types.d.ts +3 -0
  58. package/dist/motion/types.d.ts.map +1 -0
  59. package/dist/motion/types.js +3 -0
  60. package/dist/motion/types.js.map +1 -0
  61. package/package.json +30 -1
  62. package/src/index.ts +1 -0
  63. package/src/motion/components/canvas-scrub.tsx +110 -0
  64. package/src/motion/components/count-up.tsx +51 -0
  65. package/src/motion/components/horizontal-scroll.tsx +58 -0
  66. package/src/motion/components/logo-marquee.tsx +40 -0
  67. package/src/motion/components/navbar.tsx +151 -0
  68. package/src/motion/components/parallax-section.tsx +32 -0
  69. package/src/motion/components/reveal-on-scroll.tsx +48 -0
  70. package/src/motion/components/stacked-cards.tsx +82 -0
  71. package/src/motion/components/text-reveal.tsx +66 -0
  72. package/src/motion/components/video-scrub.tsx +60 -0
  73. package/src/motion/index.ts +16 -0
  74. package/src/motion/providers/motion-provider.tsx +15 -0
  75. package/src/motion/providers/smooth-scroll-provider.tsx +26 -0
  76. package/src/motion/types.ts +2 -0
  77. package/tsconfig.json +2 -1
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TextReveal = TextReveal;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const gsap_1 = __importDefault(require("gsap"));
11
+ const ScrollTrigger_1 = require("gsap/ScrollTrigger");
12
+ const react_2 = require("@gsap/react");
13
+ gsap_1.default.registerPlugin(ScrollTrigger_1.ScrollTrigger);
14
+ /** Anima headline caractere por caractere ao entrar no viewport */
15
+ function TextReveal({ text, as: Tag = "h2", className, stagger = 0.025, start = "top 88%", }) {
16
+ const ref = (0, react_1.useRef)(null);
17
+ (0, react_2.useGSAP)(() => {
18
+ const chars = ref.current?.querySelectorAll(".trind-char");
19
+ if (!chars?.length)
20
+ return;
21
+ const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
22
+ if (prefersReduced) {
23
+ gsap_1.default.set(chars, { opacity: 1, y: 0 });
24
+ return;
25
+ }
26
+ gsap_1.default.from(chars, {
27
+ opacity: 0,
28
+ y: "110%",
29
+ stagger,
30
+ duration: 0.6,
31
+ ease: "power3.out",
32
+ scrollTrigger: { trigger: ref.current, start },
33
+ });
34
+ return () => ScrollTrigger_1.ScrollTrigger.getAll().forEach((t) => t.kill());
35
+ }, { scope: ref });
36
+ return ((0, jsx_runtime_1.jsx)(Tag, { ref: ref, className: `overflow-hidden ${className ?? ""}`, "aria-label": text, children: text.split("").map((char, i) => ((0, jsx_runtime_1.jsx)("span", { className: "trind-char inline-block", "aria-hidden": "true", children: char === " " ? "\u00A0" : char }, i))) }));
37
+ }
38
+ //# sourceMappingURL=text-reveal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-reveal.js","sourceRoot":"","sources":["../../../src/motion/components/text-reveal.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAqBZ,gCA4CC;;AAhED,iCAA8B;AAC9B,gDAAuB;AACvB,sDAAkD;AAClD,uCAAqC;AAErC,cAAI,CAAC,cAAc,CAAC,6BAAa,CAAC,CAAA;AAclC,mEAAmE;AACnE,SAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,EAAE,EAAE,GAAG,GAAG,IAAI,EACd,SAAS,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,SAAS,GACX;IACN,MAAM,GAAG,GAAG,IAAA,cAAM,EAAc,IAAI,CAAC,CAAA;IAErC,IAAA,eAAO,EAAC,GAAG,EAAE;QACX,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAA;QAC1D,IAAI,CAAC,KAAK,EAAE,MAAM;YAAE,OAAM;QAE1B,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAA;QACpF,IAAI,cAAc,EAAE,CAAC;YACnB,cAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;YACrC,OAAM;QACR,CAAC;QAED,cAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,OAAO,EAAE,CAAC;YACV,CAAC,EAAE,MAAM;YACT,OAAO;YACP,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,YAAY;YAClB,aAAa,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE;SAC/C,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9D,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAElB,OAAO,CACL,uBAAC,GAAG,IACF,GAAG,EAAE,GAA0C,EAC/C,SAAS,EAAE,mBAAmB,SAAS,IAAI,EAAE,EAAE,gBACnC,IAAI,YAEf,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC/B,iCAAc,SAAS,EAAC,yBAAyB,iBAAa,MAAM,YACjE,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IADtB,CAAC,CAEL,CACR,CAAC,GACE,CACP,CAAA;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ src: string;
3
+ scrollHeight?: string;
4
+ fallbackSrc?: string;
5
+ }
6
+ /** Scrub de vídeo mp4 — currentTime controlado pelo scroll */
7
+ export declare function VideoScrub({ src, scrollHeight, fallbackSrc }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=video-scrub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-scrub.d.ts","sourceRoot":"","sources":["../../../src/motion/components/video-scrub.tsx"],"names":[],"mappings":"AAOA,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,EAAE,GAAG,EAAE,YAAsB,EAAE,WAAW,EAAE,EAAE,KAAK,2CA6C7E"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.VideoScrub = VideoScrub;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const gsap_1 = __importDefault(require("gsap"));
11
+ const ScrollTrigger_1 = require("gsap/ScrollTrigger");
12
+ gsap_1.default.registerPlugin(ScrollTrigger_1.ScrollTrigger);
13
+ /** Scrub de vídeo mp4 — currentTime controlado pelo scroll */
14
+ function VideoScrub({ src, scrollHeight = "250vh", fallbackSrc }) {
15
+ const videoRef = (0, react_1.useRef)(null);
16
+ const containerRef = (0, react_1.useRef)(null);
17
+ (0, react_1.useEffect)(() => {
18
+ const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
19
+ if (prefersReduced)
20
+ return;
21
+ const video = videoRef.current;
22
+ const init = () => {
23
+ gsap_1.default.to(video, {
24
+ currentTime: video.duration,
25
+ ease: "none",
26
+ scrollTrigger: {
27
+ trigger: containerRef.current,
28
+ start: "top top",
29
+ end: "bottom bottom",
30
+ scrub: 1,
31
+ invalidateOnRefresh: true,
32
+ },
33
+ });
34
+ };
35
+ video.readyState >= 1 ? init() : video.addEventListener("loadedmetadata", init);
36
+ return () => ScrollTrigger_1.ScrollTrigger.getAll().forEach((t) => t.kill());
37
+ }, []);
38
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, style: { height: scrollHeight }, className: "relative", children: [fallbackSrc && ((0, jsx_runtime_1.jsx)("div", { className: "md:hidden sticky top-0 h-screen w-full", children: (0, jsx_runtime_1.jsx)("img", { src: fallbackSrc, alt: "", className: "h-full w-full object-cover" }) })), (0, jsx_runtime_1.jsx)("video", { ref: videoRef, src: src, muted: true, playsInline: true, preload: "auto", className: "hidden md:block sticky top-0 h-screen w-full object-cover", "aria-hidden": "true" })] }));
39
+ }
40
+ //# sourceMappingURL=video-scrub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-scrub.js","sourceRoot":"","sources":["../../../src/motion/components/video-scrub.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAcZ,gCA6CC;;AA1DD,iCAAyC;AACzC,gDAAuB;AACvB,sDAAkD;AAElD,cAAI,CAAC,cAAc,CAAC,6BAAa,CAAC,CAAA;AAQlC,8DAA8D;AAC9D,SAAgB,UAAU,CAAC,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,EAAE,WAAW,EAAS;IAC5E,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAA;IAC/C,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAA;IAEjD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAA;QACpF,IAAI,cAAc;YAAE,OAAM;QAE1B,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAQ,CAAA;QAC/B,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,cAAI,CAAC,EAAE,CAAC,KAAK,EAAE;gBACb,WAAW,EAAE,KAAK,CAAC,QAAQ;gBAC3B,IAAI,EAAE,MAAM;gBACZ,aAAa,EAAE;oBACb,OAAO,EAAE,YAAY,CAAC,OAAO;oBAC7B,KAAK,EAAE,SAAS;oBAChB,GAAG,EAAE,eAAe;oBACpB,KAAK,EAAE,CAAC;oBACR,mBAAmB,EAAE,IAAI;iBAC1B;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;QAC/E,OAAO,GAAG,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9D,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,iCAAK,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,EAAC,UAAU,aAC1E,WAAW,IAAI,CACd,gCAAK,SAAS,EAAC,wCAAwC,YACrD,gCAAK,GAAG,EAAE,WAAW,EAAE,GAAG,EAAC,EAAE,EAAC,SAAS,EAAC,4BAA4B,GAAG,GACnE,CACP,EACD,kCACE,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,GAAG,EACR,KAAK,QACL,WAAW,QACX,OAAO,EAAC,MAAM,EACd,SAAS,EAAC,2DAA2D,iBACzD,MAAM,GAClB,IACE,CACP,CAAA;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { SmoothScrollProvider } from "./providers/smooth-scroll-provider";
2
+ export { MotionProvider } from "./providers/motion-provider";
3
+ export { RevealOnScroll } from "./components/reveal-on-scroll";
4
+ export { TextReveal } from "./components/text-reveal";
5
+ export { ParallaxSection } from "./components/parallax-section";
6
+ export { HorizontalScroll } from "./components/horizontal-scroll";
7
+ export { StackedCards } from "./components/stacked-cards";
8
+ export { CanvasScrub } from "./components/canvas-scrub";
9
+ export { VideoScrub } from "./components/video-scrub";
10
+ export { CountUp } from "./components/count-up";
11
+ export { LogoMarquee } from "./components/logo-marquee";
12
+ export { Navbar } from "./components/navbar";
13
+ export type { NavLink, NavbarCTA } from "./components/navbar";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Navbar = exports.LogoMarquee = exports.CountUp = exports.VideoScrub = exports.CanvasScrub = exports.StackedCards = exports.HorizontalScroll = exports.ParallaxSection = exports.TextReveal = exports.RevealOnScroll = exports.MotionProvider = exports.SmoothScrollProvider = void 0;
4
+ // Providers
5
+ var smooth_scroll_provider_1 = require("./providers/smooth-scroll-provider");
6
+ Object.defineProperty(exports, "SmoothScrollProvider", { enumerable: true, get: function () { return smooth_scroll_provider_1.SmoothScrollProvider; } });
7
+ var motion_provider_1 = require("./providers/motion-provider");
8
+ Object.defineProperty(exports, "MotionProvider", { enumerable: true, get: function () { return motion_provider_1.MotionProvider; } });
9
+ // Components
10
+ var reveal_on_scroll_1 = require("./components/reveal-on-scroll");
11
+ Object.defineProperty(exports, "RevealOnScroll", { enumerable: true, get: function () { return reveal_on_scroll_1.RevealOnScroll; } });
12
+ var text_reveal_1 = require("./components/text-reveal");
13
+ Object.defineProperty(exports, "TextReveal", { enumerable: true, get: function () { return text_reveal_1.TextReveal; } });
14
+ var parallax_section_1 = require("./components/parallax-section");
15
+ Object.defineProperty(exports, "ParallaxSection", { enumerable: true, get: function () { return parallax_section_1.ParallaxSection; } });
16
+ var horizontal_scroll_1 = require("./components/horizontal-scroll");
17
+ Object.defineProperty(exports, "HorizontalScroll", { enumerable: true, get: function () { return horizontal_scroll_1.HorizontalScroll; } });
18
+ var stacked_cards_1 = require("./components/stacked-cards");
19
+ Object.defineProperty(exports, "StackedCards", { enumerable: true, get: function () { return stacked_cards_1.StackedCards; } });
20
+ var canvas_scrub_1 = require("./components/canvas-scrub");
21
+ Object.defineProperty(exports, "CanvasScrub", { enumerable: true, get: function () { return canvas_scrub_1.CanvasScrub; } });
22
+ var video_scrub_1 = require("./components/video-scrub");
23
+ Object.defineProperty(exports, "VideoScrub", { enumerable: true, get: function () { return video_scrub_1.VideoScrub; } });
24
+ var count_up_1 = require("./components/count-up");
25
+ Object.defineProperty(exports, "CountUp", { enumerable: true, get: function () { return count_up_1.CountUp; } });
26
+ var logo_marquee_1 = require("./components/logo-marquee");
27
+ Object.defineProperty(exports, "LogoMarquee", { enumerable: true, get: function () { return logo_marquee_1.LogoMarquee; } });
28
+ var navbar_1 = require("./components/navbar");
29
+ Object.defineProperty(exports, "Navbar", { enumerable: true, get: function () { return navbar_1.Navbar; } });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":";;;AAAA,YAAY;AACZ,6EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAC7B,+DAA4D;AAAnD,iHAAA,cAAc,OAAA;AAEvB,aAAa;AACb,kEAA8D;AAArD,kHAAA,cAAc,OAAA;AACvB,wDAAqD;AAA5C,yGAAA,UAAU,OAAA;AACnB,kEAA+D;AAAtD,mHAAA,eAAe,OAAA;AACxB,oEAAiE;AAAxD,qHAAA,gBAAgB,OAAA;AACzB,4DAAyD;AAAhD,6GAAA,YAAY,OAAA;AACrB,0DAAuD;AAA9C,2GAAA,WAAW,OAAA;AACpB,wDAAqD;AAA5C,yGAAA,UAAU,OAAA;AACnB,kDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAChB,0DAAuD;AAA9C,2GAAA,WAAW,OAAA;AACpB,8CAA4C;AAAnC,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ children: React.ReactNode;
3
+ }
4
+ /** Wraps app with MotionConfig — respeita prefers-reduced-motion automaticamente */
5
+ export declare function MotionProvider({ children }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=motion-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-provider.d.ts","sourceRoot":"","sources":["../../../src/motion/providers/motion-provider.tsx"],"names":[],"mappings":"AAGA,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAMjD"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.MotionProvider = MotionProvider;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("motion/react");
7
+ /** Wraps app with MotionConfig — respeita prefers-reduced-motion automaticamente */
8
+ function MotionProvider({ children }) {
9
+ return ((0, jsx_runtime_1.jsx)(react_1.MotionConfig, { reducedMotion: "user", children: children }));
10
+ }
11
+ //# sourceMappingURL=motion-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-provider.js","sourceRoot":"","sources":["../../../src/motion/providers/motion-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;AAQZ,wCAMC;;AAbD,wCAA2C;AAM3C,oFAAoF;AACpF,SAAgB,cAAc,CAAC,EAAE,QAAQ,EAAS;IAChD,OAAO,CACL,uBAAC,oBAAY,IAAC,aAAa,EAAC,MAAM,YAC/B,QAAQ,GACI,CAChB,CAAA;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ children: React.ReactNode;
3
+ lerp?: number;
4
+ }
5
+ export declare function SmoothScrollProvider({ children, lerp }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=smooth-scroll-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smooth-scroll-provider.d.ts","sourceRoot":"","sources":["../../../src/motion/providers/smooth-scroll-provider.tsx"],"names":[],"mappings":"AAQA,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,IAAW,EAAE,EAAE,KAAK,2CAYpE"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SmoothScrollProvider = SmoothScrollProvider;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const lenis_1 = __importDefault(require("lenis"));
11
+ const gsap_1 = require("gsap");
12
+ const ScrollTrigger_1 = require("gsap/ScrollTrigger");
13
+ gsap_1.gsap.registerPlugin(ScrollTrigger_1.ScrollTrigger);
14
+ function SmoothScrollProvider({ children, lerp = 0.08 }) {
15
+ (0, react_1.useEffect)(() => {
16
+ const lenis = new lenis_1.default({ lerp, smoothWheel: true });
17
+ lenis.on("scroll", ScrollTrigger_1.ScrollTrigger.update);
18
+ gsap_1.gsap.ticker.add((time) => lenis.raf(time * 1000));
19
+ gsap_1.gsap.ticker.lagSmoothing(0);
20
+ return () => {
21
+ lenis.destroy();
22
+ gsap_1.gsap.ticker.remove((time) => lenis.raf(time * 1000));
23
+ };
24
+ }, [lerp]);
25
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
26
+ }
27
+ //# sourceMappingURL=smooth-scroll-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smooth-scroll-provider.js","sourceRoot":"","sources":["../../../src/motion/providers/smooth-scroll-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAaZ,oDAYC;;AAxBD,iCAAiC;AACjC,kDAAyB;AACzB,+BAA2B;AAC3B,sDAAkD;AAElD,WAAI,CAAC,cAAc,CAAC,6BAAa,CAAC,CAAA;AAOlC,SAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,EAAS;IACnE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,IAAI,eAAK,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QACpD,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,6BAAa,CAAC,MAAM,CAAC,CAAA;QACxC,WAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAA;QACjD,WAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAC3B,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,OAAO,EAAE,CAAA;YACf,WAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAA;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACV,OAAO,2DAAG,QAAQ,GAAI,CAAA;AACxB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type Direction = "up" | "down" | "left" | "right";
2
+ export type ScrollSpeed = "slow" | "normal" | "fast";
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/motion/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AACxD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/motion/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trindtech/utils",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "publishConfig": {
@@ -18,6 +18,35 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "^25.3.3",
21
+ "@types/react": "^19.2.14",
21
22
  "typescript": "^5.9.3"
23
+ },
24
+ "peerDependencies": {
25
+ "@gsap/react": "^2.1.2",
26
+ "gsap": "^3.14.2",
27
+ "lenis": "^1.3.21",
28
+ "motion": "^12.38.0",
29
+ "react": "^18.0.0 || ^19.0.0",
30
+ "react-dom": "^18.0.0 || ^19.0.0"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "gsap": {
34
+ "optional": true
35
+ },
36
+ "@gsap/react": {
37
+ "optional": true
38
+ },
39
+ "motion": {
40
+ "optional": true
41
+ },
42
+ "lenis": {
43
+ "optional": true
44
+ },
45
+ "react": {
46
+ "optional": true
47
+ },
48
+ "react-dom": {
49
+ "optional": true
50
+ }
22
51
  }
23
52
  }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./mailer";
2
2
  export * from "./validators";
3
3
  export * from "./s3";
4
+ export * from "./motion";
@@ -0,0 +1,110 @@
1
+ "use client"
2
+ import { useEffect, useRef } from "react"
3
+ import gsap from "gsap"
4
+ import { ScrollTrigger } from "gsap/ScrollTrigger"
5
+
6
+ gsap.registerPlugin(ScrollTrigger)
7
+
8
+ interface Props {
9
+ /** Total de frames na sequência */
10
+ frameCount: number
11
+ /** Função que retorna a URL de cada frame pelo índice */
12
+ getFrameUrl: (index: number) => string
13
+ /** Altura total de scroll para a animação — padrão: "300vh" */
14
+ scrollHeight?: string
15
+ /** Imagem de fallback para mobile e prefers-reduced-motion */
16
+ fallbackSrc?: string
17
+ }
18
+
19
+ /**
20
+ * Scrub de sequência de imagens ao estilo Apple.
21
+ * No mobile e com prefers-reduced-motion, exibe fallbackSrc estático.
22
+ *
23
+ * Convenção de frames: /public/frames/frame-001.webp ... frame-NNN.webp
24
+ * Ferramenta para extrair frames de vídeo: https://frame-extractor.com
25
+ * Recomendado: 60–120 frames, 1280×720, webp, <50kb cada
26
+ */
27
+ export function CanvasScrub({
28
+ frameCount,
29
+ getFrameUrl,
30
+ scrollHeight = "300vh",
31
+ fallbackSrc,
32
+ }: Props) {
33
+ const canvasRef = useRef<HTMLCanvasElement>(null)
34
+ const containerRef = useRef<HTMLDivElement>(null)
35
+ const frameRef = useRef({ frame: 0 })
36
+
37
+ useEffect(() => {
38
+ const isMobile = window.innerWidth < 768
39
+ const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
40
+ if (isMobile || prefersReduced) return
41
+
42
+ const canvas = canvasRef.current!
43
+ const ctx = canvas.getContext("2d")!
44
+ const images: HTMLImageElement[] = []
45
+ let loaded = 0
46
+
47
+ const resize = () => {
48
+ canvas.width = window.innerWidth
49
+ canvas.height = window.innerHeight
50
+ }
51
+ resize()
52
+ window.addEventListener("resize", resize)
53
+
54
+ function draw(index: number) {
55
+ const img = images[Math.min(Math.round(index), frameCount - 1)]
56
+ if (!img?.complete) return
57
+ const scale = Math.max(canvas.width / img.width, canvas.height / img.height)
58
+ const x = (canvas.width - img.width * scale) / 2
59
+ const y = (canvas.height - img.height * scale) / 2
60
+ ctx.clearRect(0, 0, canvas.width, canvas.height)
61
+ ctx.drawImage(img, x, y, img.width * scale, img.height * scale)
62
+ }
63
+
64
+ function start() {
65
+ draw(0)
66
+ gsap.to(frameRef.current, {
67
+ frame: frameCount - 1,
68
+ snap: "frame",
69
+ ease: "none",
70
+ scrollTrigger: {
71
+ trigger: containerRef.current,
72
+ start: "top top",
73
+ end: "bottom bottom",
74
+ scrub: 1,
75
+ invalidateOnRefresh: true,
76
+ onUpdate: () => draw(frameRef.current.frame),
77
+ },
78
+ })
79
+ }
80
+
81
+ for (let i = 0; i < frameCount; i++) {
82
+ const img = new Image()
83
+ img.src = getFrameUrl(i)
84
+ img.onload = () => { if (++loaded === frameCount) start() }
85
+ images.push(img)
86
+ }
87
+
88
+ return () => {
89
+ window.removeEventListener("resize", resize)
90
+ ScrollTrigger.getAll().forEach((t) => t.kill())
91
+ }
92
+ }, [frameCount, getFrameUrl])
93
+
94
+ return (
95
+ <div ref={containerRef} style={{ height: scrollHeight }} className="relative">
96
+ {/* Mobile / reduced-motion fallback */}
97
+ {fallbackSrc && (
98
+ <div className="md:hidden sticky top-0 h-screen w-full">
99
+ <img src={fallbackSrc} alt="" className="h-full w-full object-cover" />
100
+ </div>
101
+ )}
102
+ {/* Desktop canvas */}
103
+ <canvas
104
+ ref={canvasRef}
105
+ className="hidden md:block sticky top-0 h-screen w-full"
106
+ aria-hidden="true"
107
+ />
108
+ </div>
109
+ )
110
+ }
@@ -0,0 +1,51 @@
1
+ "use client"
2
+ import { useEffect, useRef, useState } from "react"
3
+ import { useInView } from "motion/react"
4
+
5
+ interface Props {
6
+ /** Valor final */
7
+ end: number
8
+ /** Duração em ms — padrão: 2000 */
9
+ duration?: number
10
+ prefix?: string
11
+ suffix?: string
12
+ className?: string
13
+ /** Locale para formatação — padrão: "pt-BR" */
14
+ locale?: string
15
+ }
16
+
17
+ /** Contador animado que dispara quando entra no viewport */
18
+ export function CountUp({
19
+ end,
20
+ duration = 2000,
21
+ prefix = "",
22
+ suffix = "",
23
+ className,
24
+ locale = "pt-BR",
25
+ }: Props) {
26
+ const ref = useRef<HTMLSpanElement>(null)
27
+ const isInView = useInView(ref, { once: true, margin: "-10% 0px" })
28
+ const [value, setValue] = useState(0)
29
+
30
+ useEffect(() => {
31
+ if (!isInView) return
32
+ const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
33
+ if (prefersReduced) { setValue(end); return }
34
+
35
+ const start = performance.now()
36
+ const step = (now: number) => {
37
+ const progress = Math.min((now - start) / duration, 1)
38
+ const eased = 1 - Math.pow(1 - progress, 3)
39
+ setValue(Math.floor(eased * end))
40
+ if (progress < 1) requestAnimationFrame(step)
41
+ else setValue(end)
42
+ }
43
+ requestAnimationFrame(step)
44
+ }, [isInView, end, duration])
45
+
46
+ return (
47
+ <span ref={ref} className={className}>
48
+ {prefix}{value.toLocaleString(locale)}{suffix}
49
+ </span>
50
+ )
51
+ }
@@ -0,0 +1,58 @@
1
+ "use client"
2
+ import { useRef } from "react"
3
+ import gsap from "gsap"
4
+ import { ScrollTrigger } from "gsap/ScrollTrigger"
5
+ import { useGSAP } from "@gsap/react"
6
+
7
+ gsap.registerPlugin(ScrollTrigger)
8
+
9
+ interface Props {
10
+ children: React.ReactNode
11
+ className?: string
12
+ }
13
+
14
+ /**
15
+ * Cards scrollam horizontalmente enquanto o usuário scrolla para baixo.
16
+ * Tela fica pinada até o último card passar.
17
+ */
18
+ export function HorizontalScroll({ children, className }: Props) {
19
+ const containerRef = useRef<HTMLDivElement>(null)
20
+ const trackRef = useRef<HTMLDivElement>(null)
21
+
22
+ useGSAP(() => {
23
+ const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
24
+ if (prefersReduced) return
25
+
26
+ const track = trackRef.current!
27
+ const getWidth = () => track.scrollWidth - window.innerWidth
28
+
29
+ const ctx = gsap.context(() => {
30
+ gsap.to(track, {
31
+ x: () => -getWidth(),
32
+ ease: "none",
33
+ scrollTrigger: {
34
+ trigger: containerRef.current,
35
+ start: "top top",
36
+ end: () => `+=${getWidth()}`,
37
+ scrub: 1,
38
+ pin: true,
39
+ anticipatePin: 1,
40
+ invalidateOnRefresh: true,
41
+ },
42
+ })
43
+ })
44
+
45
+ return () => ctx.revert()
46
+ }, { scope: containerRef })
47
+
48
+ return (
49
+ <div ref={containerRef} className={`overflow-hidden ${className ?? ""}`}>
50
+ <div
51
+ ref={trackRef}
52
+ className="flex w-max gap-6 px-4 md:gap-8 md:px-10"
53
+ >
54
+ {children}
55
+ </div>
56
+ </div>
57
+ )
58
+ }
@@ -0,0 +1,40 @@
1
+ "use client"
2
+
3
+ interface Props {
4
+ children: React.ReactNode
5
+ speed?: "slow" | "normal" | "fast"
6
+ direction?: "left" | "right"
7
+ className?: string
8
+ }
9
+
10
+ const speedMap = { slow: "60s", normal: "40s", fast: "20s" }
11
+
12
+ /**
13
+ * Strip infinito de logos/itens com scroll automático.
14
+ * Pausa no hover.
15
+ *
16
+ * Requer no tailwind.config.ts:
17
+ * animation: { marquee: "marquee linear infinite" }
18
+ * keyframes: { marquee: { from: { transform: "translateX(0)" }, to: { transform: "translateX(-50%)" } } }
19
+ */
20
+ export function LogoMarquee({
21
+ children,
22
+ speed = "normal",
23
+ direction = "left",
24
+ className,
25
+ }: Props) {
26
+ return (
27
+ <div className={`overflow-hidden ${className ?? ""}`}>
28
+ <div
29
+ className="flex w-max gap-8 animate-marquee hover:[animation-play-state:paused] md:gap-12"
30
+ style={{
31
+ animationDuration: speedMap[speed],
32
+ animationDirection: direction === "right" ? "reverse" : "normal",
33
+ }}
34
+ >
35
+ {children}
36
+ {children}
37
+ </div>
38
+ </div>
39
+ )
40
+ }