Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

Update import statement for MotionProps type (#891)

ᖇᗩᑎᒎᗩᗰ ᗩ.85353d27eb76
diff --git a/apps/www/public/llms-full.txt b/apps/www/public/llms-full.txt
index 08549f34..d7b30bec 100644
--- a/apps/www/public/llms-full.txt
+++ b/apps/www/public/llms-full.txt
@@ -2547,7 +2547,7 @@ import React, {
useMemo,
useState,
} from "react"
-import { AnimatePresence, motion, MotionProps } from "motion/react"
+import { AnimatePresence, motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
@@ -7612,7 +7612,7 @@ Description: A text animation that scrambles letters before revealing the final
"use client"
import { useEffect, useRef, useState } from "react"
-import { AnimatePresence, motion, MotionProps } from "motion/react"
+import { AnimatePresence, motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
@@ -9240,7 +9240,7 @@ Description: A text component with a moving line shadow.
--- file: magicui/line-shadow-text.tsx ---
"use client"
-import { motion, MotionProps } from "motion/react"
+import { motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
@@ -12801,7 +12801,7 @@ Description: Animated Scroll Progress for your pages
--- file: magicui/scroll-progress.tsx ---
"use client"
-import { motion, MotionProps, useScroll } from "motion/react"
+import { motion, useScroll, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
@@ -13909,7 +13909,7 @@ import {
useRef,
useState,
} from "react"
-import { motion, MotionProps, useInView } from "motion/react"
+import { motion, useInView, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
@@ -14263,7 +14263,12 @@ Description: A text animation component that animates text using a variety of di
"use client"
import { ElementType, memo } from "react"
-import { AnimatePresence, motion, MotionProps, Variants } from "motion/react"
+import {
+ AnimatePresence,
+ motion,
+ Variants,
+ type MotionProps,
+} from "motion/react"
import { cn } from "@/lib/utils"
@@ -15295,7 +15300,7 @@ Description: Characters appearing in typed animation
"use client"
import { useEffect, useMemo, useRef, useState } from "react"
-import { motion, MotionProps, useInView } from "motion/react"
+import { motion, useInView, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
@@ -15988,7 +15993,7 @@ Description: A vertical rotation of words
"use client"
import { useEffect, useState } from "react"
-import { AnimatePresence, motion, MotionProps } from "motion/react"
+import { AnimatePresence, motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/public/r/animated-list.json b/apps/www/public/r/animated-list.json
index 654b22ec..dd301b5e 100644
--- a/apps/www/public/r/animated-list.json
+++ b/apps/www/public/r/animated-list.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/animated-list.tsx",
- "content": "\"use client\"\n\nimport React, {\n ComponentPropsWithoutRef,\n useEffect,\n useMemo,\n useState,\n} from \"react\"\nimport { AnimatePresence, motion, MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport function AnimatedListItem({ children }: { children: React.ReactNode }) {\n const animations: MotionProps = {\n initial: { scale: 0, opacity: 0 },\n animate: { scale: 1, opacity: 1, originY: 0 },\n exit: { scale: 0, opacity: 0 },\n transition: { type: \"spring\", stiffness: 350, damping: 40 },\n }\n\n return (\n <motion.div {...animations} layout className=\"mx-auto w-full\">\n {children}\n </motion.div>\n )\n}\n\nexport interface AnimatedListProps extends ComponentPropsWithoutRef<\"div\"> {\n children: React.ReactNode\n delay?: number\n}\n\nexport const AnimatedList = React.memo(\n ({ children, className, delay = 1000, ...props }: AnimatedListProps) => {\n const [index, setIndex] = useState(0)\n const childrenArray = useMemo(\n () => React.Children.toArray(children),\n [children]\n )\n\n useEffect(() => {\n if (index < childrenArray.length - 1) {\n const timeout = setTimeout(() => {\n setIndex((prevIndex) => (prevIndex + 1) % childrenArray.length)\n }, delay)\n\n return () => clearTimeout(timeout)\n }\n }, [index, delay, childrenArray.length])\n\n const itemsToShow = useMemo(() => {\n const result = childrenArray.slice(0, index + 1).reverse()\n return result\n }, [index, childrenArray])\n\n return (\n <div\n className={cn(`flex flex-col items-center gap-4`, className)}\n {...props}\n >\n <AnimatePresence>\n {itemsToShow.map((item) => (\n <AnimatedListItem key={(item as React.ReactElement).key}>\n {item}\n </AnimatedListItem>\n ))}\n </AnimatePresence>\n </div>\n )\n }\n)\n\nAnimatedList.displayName = \"AnimatedList\"\n",
+ "content": "\"use client\"\n\nimport React, {\n ComponentPropsWithoutRef,\n useEffect,\n useMemo,\n useState,\n} from \"react\"\nimport { AnimatePresence, motion, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport function AnimatedListItem({ children }: { children: React.ReactNode }) {\n const animations: MotionProps = {\n initial: { scale: 0, opacity: 0 },\n animate: { scale: 1, opacity: 1, originY: 0 },\n exit: { scale: 0, opacity: 0 },\n transition: { type: \"spring\", stiffness: 350, damping: 40 },\n }\n\n return (\n <motion.div {...animations} layout className=\"mx-auto w-full\">\n {children}\n </motion.div>\n )\n}\n\nexport interface AnimatedListProps extends ComponentPropsWithoutRef<\"div\"> {\n children: React.ReactNode\n delay?: number\n}\n\nexport const AnimatedList = React.memo(\n ({ children, className, delay = 1000, ...props }: AnimatedListProps) => {\n const [index, setIndex] = useState(0)\n const childrenArray = useMemo(\n () => React.Children.toArray(children),\n [children]\n )\n\n useEffect(() => {\n if (index < childrenArray.length - 1) {\n const timeout = setTimeout(() => {\n setIndex((prevIndex) => (prevIndex + 1) % childrenArray.length)\n }, delay)\n\n return () => clearTimeout(timeout)\n }\n }, [index, delay, childrenArray.length])\n\n const itemsToShow = useMemo(() => {\n const result = childrenArray.slice(0, index + 1).reverse()\n return result\n }, [index, childrenArray])\n\n return (\n <div\n className={cn(`flex flex-col items-center gap-4`, className)}\n {...props}\n >\n <AnimatePresence>\n {itemsToShow.map((item) => (\n <AnimatedListItem key={(item as React.ReactElement).key}>\n {item}\n </AnimatedListItem>\n ))}\n </AnimatePresence>\n </div>\n )\n }\n)\n\nAnimatedList.displayName = \"AnimatedList\"\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/hyper-text.json b/apps/www/public/r/hyper-text.json
index cd0f0e27..7073d51e 100644
--- a/apps/www/public/r/hyper-text.json
+++ b/apps/www/public/r/hyper-text.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/hyper-text.tsx",
- "content": "\"use client\"\n\nimport { useEffect, useRef, useState } from \"react\"\nimport { AnimatePresence, motion, MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype CharacterSet = string[] | readonly string[]\n\ninterface HyperTextProps extends MotionProps {\n /** The text content to be animated */\n children: string\n /** Optional className for styling */\n className?: string\n /** Duration of the animation in milliseconds */\n duration?: number\n /** Delay before animation starts in milliseconds */\n delay?: number\n /** Component to render as - defaults to div */\n as?: React.ElementType\n /** Whether to start animation when element comes into view */\n startOnView?: boolean\n /** Whether to trigger animation on hover */\n animateOnHover?: boolean\n /** Custom character set for scramble effect. Defaults to uppercase alphabet */\n characterSet?: CharacterSet\n}\n\nconst DEFAULT_CHARACTER_SET = Object.freeze(\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\")\n) as readonly string[]\n\nconst getRandomInt = (max: number): number => Math.floor(Math.random() * max)\n\nexport function HyperText({\n children,\n className,\n duration = 800,\n delay = 0,\n as: Component = \"div\",\n startOnView = false,\n animateOnHover = true,\n characterSet = DEFAULT_CHARACTER_SET,\n ...props\n}: HyperTextProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n })\n\n const [displayText, setDisplayText] = useState<string[]>(() =>\n children.split(\"\")\n )\n const [isAnimating, setIsAnimating] = useState(false)\n const iterationCount = useRef(0)\n const elementRef = useRef<HTMLElement>(null)\n\n const handleAnimationTrigger = () => {\n if (animateOnHover && !isAnimating) {\n iterationCount.current = 0\n setIsAnimating(true)\n }\n }\n\n // Handle animation start based on view or delay\n useEffect(() => {\n if (!startOnView) {\n const startTimeout = setTimeout(() => {\n setIsAnimating(true)\n }, delay)\n return () => clearTimeout(startTimeout)\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setTimeout(() => {\n setIsAnimating(true)\n }, delay)\n observer.disconnect()\n }\n },\n { threshold: 0.1, rootMargin: \"-30% 0px -30% 0px\" }\n )\n\n if (elementRef.current) {\n observer.observe(elementRef.current)\n }\n\n return () => observer.disconnect()\n }, [delay, startOnView])\n\n // Handle scramble animation\n useEffect(() => {\n if (!isAnimating) return\n\n const maxIterations = children.length\n const startTime = performance.now()\n let animationFrameId: number\n\n const animate = (currentTime: number) => {\n const elapsed = currentTime - startTime\n const progress = Math.min(elapsed / duration, 1)\n\n iterationCount.current = progress * maxIterations\n\n setDisplayText((currentText) =>\n currentText.map((letter, index) =>\n letter === \" \"\n ? letter\n : index <= iterationCount.current\n ? children[index]\n : characterSet[getRandomInt(characterSet.length)]\n )\n )\n\n if (progress < 1) {\n animationFrameId = requestAnimationFrame(animate)\n } else {\n setIsAnimating(false)\n }\n }\n\n animationFrameId = requestAnimationFrame(animate)\n\n return () => cancelAnimationFrame(animationFrameId)\n }, [children, duration, isAnimating, characterSet])\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"overflow-hidden py-2 text-4xl font-bold\", className)}\n onMouseEnter={handleAnimationTrigger}\n {...props}\n >\n <AnimatePresence>\n {displayText.map((letter, index) => (\n <motion.span\n key={index}\n className={cn(\"font-mono\", letter === \" \" ? \"w-3\" : \"\")}\n >\n {letter.toUpperCase()}\n </motion.span>\n ))}\n </AnimatePresence>\n </MotionComponent>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { useEffect, useRef, useState } from \"react\"\nimport { AnimatePresence, motion, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype CharacterSet = string[] | readonly string[]\n\ninterface HyperTextProps extends MotionProps {\n /** The text content to be animated */\n children: string\n /** Optional className for styling */\n className?: string\n /** Duration of the animation in milliseconds */\n duration?: number\n /** Delay before animation starts in milliseconds */\n delay?: number\n /** Component to render as - defaults to div */\n as?: React.ElementType\n /** Whether to start animation when element comes into view */\n startOnView?: boolean\n /** Whether to trigger animation on hover */\n animateOnHover?: boolean\n /** Custom character set for scramble effect. Defaults to uppercase alphabet */\n characterSet?: CharacterSet\n}\n\nconst DEFAULT_CHARACTER_SET = Object.freeze(\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\")\n) as readonly string[]\n\nconst getRandomInt = (max: number): number => Math.floor(Math.random() * max)\n\nexport function HyperText({\n children,\n className,\n duration = 800,\n delay = 0,\n as: Component = \"div\",\n startOnView = false,\n animateOnHover = true,\n characterSet = DEFAULT_CHARACTER_SET,\n ...props\n}: HyperTextProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n })\n\n const [displayText, setDisplayText] = useState<string[]>(() =>\n children.split(\"\")\n )\n const [isAnimating, setIsAnimating] = useState(false)\n const iterationCount = useRef(0)\n const elementRef = useRef<HTMLElement>(null)\n\n const handleAnimationTrigger = () => {\n if (animateOnHover && !isAnimating) {\n iterationCount.current = 0\n setIsAnimating(true)\n }\n }\n\n // Handle animation start based on view or delay\n useEffect(() => {\n if (!startOnView) {\n const startTimeout = setTimeout(() => {\n setIsAnimating(true)\n }, delay)\n return () => clearTimeout(startTimeout)\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setTimeout(() => {\n setIsAnimating(true)\n }, delay)\n observer.disconnect()\n }\n },\n { threshold: 0.1, rootMargin: \"-30% 0px -30% 0px\" }\n )\n\n if (elementRef.current) {\n observer.observe(elementRef.current)\n }\n\n return () => observer.disconnect()\n }, [delay, startOnView])\n\n // Handle scramble animation\n useEffect(() => {\n if (!isAnimating) return\n\n const maxIterations = children.length\n const startTime = performance.now()\n let animationFrameId: number\n\n const animate = (currentTime: number) => {\n const elapsed = currentTime - startTime\n const progress = Math.min(elapsed / duration, 1)\n\n iterationCount.current = progress * maxIterations\n\n setDisplayText((currentText) =>\n currentText.map((letter, index) =>\n letter === \" \"\n ? letter\n : index <= iterationCount.current\n ? children[index]\n : characterSet[getRandomInt(characterSet.length)]\n )\n )\n\n if (progress < 1) {\n animationFrameId = requestAnimationFrame(animate)\n } else {\n setIsAnimating(false)\n }\n }\n\n animationFrameId = requestAnimationFrame(animate)\n\n return () => cancelAnimationFrame(animationFrameId)\n }, [children, duration, isAnimating, characterSet])\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"overflow-hidden py-2 text-4xl font-bold\", className)}\n onMouseEnter={handleAnimationTrigger}\n {...props}\n >\n <AnimatePresence>\n {displayText.map((letter, index) => (\n <motion.span\n key={index}\n className={cn(\"font-mono\", letter === \" \" ? \"w-3\" : \"\")}\n >\n {letter.toUpperCase()}\n </motion.span>\n ))}\n </AnimatePresence>\n </MotionComponent>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/line-shadow-text.json b/apps/www/public/r/line-shadow-text.json
index 0050dda9..ba404d2b 100644
--- a/apps/www/public/r/line-shadow-text.json
+++ b/apps/www/public/r/line-shadow-text.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/line-shadow-text.tsx",
- "content": "\"use client\"\n\nimport { motion, MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface LineShadowTextProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps>,\n MotionProps {\n shadowColor?: string\n as?: React.ElementType\n}\n\nexport function LineShadowText({\n children,\n shadowColor = \"black\",\n className,\n as: Component = \"span\",\n ...props\n}: LineShadowTextProps) {\n const MotionComponent = motion.create(Component)\n const content = typeof children === \"string\" ? children : null\n\n if (!content) {\n throw new Error(\"LineShadowText only accepts string content\")\n }\n\n return (\n <MotionComponent\n style={{ \"--shadow-color\": shadowColor } as React.CSSProperties}\n className={cn(\n \"relative z-0 inline-flex\",\n \"after:absolute after:top-[0.04em] after:left-[0.04em] after:content-[attr(data-text)]\",\n \"after:bg-[linear-gradient(45deg,transparent_45%,var(--shadow-color)_45%,var(--shadow-color)_55%,transparent_0)]\",\n \"after:-z-10 after:bg-[length:0.06em_0.06em] after:bg-clip-text after:text-transparent\",\n \"after:animate-line-shadow\",\n className\n )}\n data-text={content}\n {...props}\n >\n {content}\n </MotionComponent>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { motion, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface LineShadowTextProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps>,\n MotionProps {\n shadowColor?: string\n as?: React.ElementType\n}\n\nexport function LineShadowText({\n children,\n shadowColor = \"black\",\n className,\n as: Component = \"span\",\n ...props\n}: LineShadowTextProps) {\n const MotionComponent = motion.create(Component)\n const content = typeof children === \"string\" ? children : null\n\n if (!content) {\n throw new Error(\"LineShadowText only accepts string content\")\n }\n\n return (\n <MotionComponent\n style={{ \"--shadow-color\": shadowColor } as React.CSSProperties}\n className={cn(\n \"relative z-0 inline-flex\",\n \"after:absolute after:top-[0.04em] after:left-[0.04em] after:content-[attr(data-text)]\",\n \"after:bg-[linear-gradient(45deg,transparent_45%,var(--shadow-color)_45%,var(--shadow-color)_55%,transparent_0)]\",\n \"after:-z-10 after:bg-[length:0.06em_0.06em] after:bg-clip-text after:text-transparent\",\n \"after:animate-line-shadow\",\n className\n )}\n data-text={content}\n {...props}\n >\n {content}\n </MotionComponent>\n )\n}\n",
"type": "registry:ui"
}
],
diff --git a/apps/www/public/r/scroll-progress.json b/apps/www/public/r/scroll-progress.json
index ec5c12bc..f318b801 100644
--- a/apps/www/public/r/scroll-progress.json
+++ b/apps/www/public/r/scroll-progress.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/scroll-progress.tsx",
- "content": "\"use client\"\n\nimport { motion, MotionProps, useScroll } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface ScrollProgressProps extends Omit<\n React.HTMLAttributes<HTMLElement>,\n keyof MotionProps\n> {\n ref?: React.Ref<HTMLDivElement>\n}\n\nexport function ScrollProgress({\n className,\n ref,\n ...props\n}: ScrollProgressProps) {\n const { scrollYProgress } = useScroll()\n\n return (\n <motion.div\n ref={ref}\n className={cn(\n \"fixed inset-x-0 top-0 z-50 h-px origin-left bg-gradient-to-r from-[#A97CF8] via-[#F38CB8] to-[#FDCC92]\",\n className\n )}\n style={{\n scaleX: scrollYProgress,\n }}\n {...props}\n />\n )\n}\n",
+ "content": "\"use client\"\n\nimport { motion, useScroll, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface ScrollProgressProps extends Omit<\n React.HTMLAttributes<HTMLElement>,\n keyof MotionProps\n> {\n ref?: React.Ref<HTMLDivElement>\n}\n\nexport function ScrollProgress({\n className,\n ref,\n ...props\n}: ScrollProgressProps) {\n const { scrollYProgress } = useScroll()\n\n return (\n <motion.div\n ref={ref}\n className={cn(\n \"fixed inset-x-0 top-0 z-50 h-px origin-left bg-gradient-to-r from-[#A97CF8] via-[#F38CB8] to-[#FDCC92]\",\n className\n )}\n style={{\n scaleX: scrollYProgress,\n }}\n {...props}\n />\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/terminal.json b/apps/www/public/r/terminal.json
index e8eea0bb..d3333b9d 100644
--- a/apps/www/public/r/terminal.json
+++ b/apps/www/public/r/terminal.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/terminal.tsx",
- "content": "\"use client\"\n\nimport {\n Children,\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { motion, MotionProps, useInView } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface SequenceContextValue {\n completeItem: (index: number) => void\n activeIndex: number\n sequenceStarted: boolean\n}\n\nconst SequenceContext = createContext<SequenceContextValue | null>(null)\n\nconst useSequence = () => useContext(SequenceContext)\n\nconst ItemIndexContext = createContext<number | null>(null)\nconst useItemIndex = () => useContext(ItemIndexContext)\n\ninterface AnimatedSpanProps extends MotionProps {\n children: React.ReactNode\n delay?: number\n className?: string\n startOnView?: boolean\n}\n\nexport const AnimatedSpan = ({\n children,\n delay = 0,\n className,\n startOnView = false,\n ...props\n}: AnimatedSpanProps) => {\n const elementRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n const [hasStarted, setHasStarted] = useState(false)\n useEffect(() => {\n if (!sequence || itemIndex === null) return\n if (!sequence.sequenceStarted) return\n if (hasStarted) return\n if (sequence.activeIndex === itemIndex) {\n setHasStarted(true)\n }\n }, [sequence?.activeIndex, sequence?.sequenceStarted, hasStarted, itemIndex])\n\n const shouldAnimate = sequence ? hasStarted : startOnView ? isInView : true\n\n return (\n <motion.div\n ref={elementRef}\n initial={{ opacity: 0, y: -5 }}\n animate={shouldAnimate ? { opacity: 1, y: 0 } : { opacity: 0, y: -5 }}\n transition={{ duration: 0.3, delay: sequence ? 0 : delay / 1000 }}\n className={cn(\"grid text-sm font-normal tracking-tight\", className)}\n onAnimationComplete={() => {\n if (!sequence) return\n if (itemIndex === null) return\n sequence.completeItem(itemIndex)\n }}\n {...props}\n >\n {children}\n </motion.div>\n )\n}\n\ninterface TypingAnimationProps extends MotionProps {\n children: string\n className?: string\n duration?: number\n delay?: number\n as?: React.ElementType\n startOnView?: boolean\n}\n\nexport const TypingAnimation = ({\n children,\n className,\n duration = 60,\n delay = 0,\n as: Component = \"span\",\n startOnView = true,\n ...props\n}: TypingAnimationProps) => {\n if (typeof children !== \"string\") {\n throw new Error(\"TypingAnimation: children must be a string. Received:\")\n }\n\n const MotionComponent = useMemo(\n () =>\n motion.create(Component, {\n forwardMotionProps: true,\n }),\n [Component]\n )\n\n const [displayedText, setDisplayedText] = useState<string>(\"\")\n const [started, setStarted] = useState(false)\n const elementRef = useRef<HTMLElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n\n useEffect(() => {\n if (sequence && itemIndex !== null) {\n if (!sequence.sequenceStarted) return\n if (started) return\n if (sequence.activeIndex === itemIndex) {\n setStarted(true)\n }\n return\n }\n\n if (!startOnView) {\n const startTimeout = setTimeout(() => setStarted(true), delay)\n return () => clearTimeout(startTimeout)\n }\n\n if (!isInView) return\n\n const startTimeout = setTimeout(() => setStarted(true), delay)\n return () => clearTimeout(startTimeout)\n }, [\n delay,\n startOnView,\n isInView,\n started,\n sequence?.activeIndex,\n sequence?.sequenceStarted,\n itemIndex,\n ])\n\n useEffect(() => {\n if (!started) return\n\n let i = 0\n const typingEffect = setInterval(() => {\n if (i < children.length) {\n setDisplayedText(children.substring(0, i + 1))\n i++\n } else {\n clearInterval(typingEffect)\n if (sequence && itemIndex !== null) {\n sequence.completeItem(itemIndex)\n }\n }\n }, duration)\n\n return () => {\n clearInterval(typingEffect)\n }\n }, [children, duration, started])\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"text-sm font-normal tracking-tight\", className)}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n )\n}\n\ninterface TerminalProps {\n children: React.ReactNode\n className?: string\n sequence?: boolean\n startOnView?: boolean\n}\n\nexport const Terminal = ({\n children,\n className,\n sequence = true,\n startOnView = true,\n}: TerminalProps) => {\n const containerRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(containerRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const [activeIndex, setActiveIndex] = useState(0)\n const sequenceHasStarted = sequence ? !startOnView || isInView : false\n\n const contextValue = useMemo<SequenceContextValue | null>(() => {\n if (!sequence) return null\n return {\n completeItem: (index: number) => {\n setActiveIndex((current) => (index === current ? current + 1 : current))\n },\n activeIndex,\n sequenceStarted: sequenceHasStarted,\n }\n }, [sequence, activeIndex, sequenceHasStarted])\n\n const wrappedChildren = useMemo(() => {\n if (!sequence) return children\n const array = Children.toArray(children)\n return array.map((child, index) => (\n <ItemIndexContext.Provider key={index} value={index}>\n {child as React.ReactNode}\n </ItemIndexContext.Provider>\n ))\n }, [children, sequence])\n\n const content = (\n <div\n ref={containerRef}\n className={cn(\n \"border-border bg-background z-0 h-full max-h-[400px] w-full max-w-lg rounded-xl border\",\n className\n )}\n >\n <div className=\"border-border flex flex-col gap-y-2 border-b p-4\">\n <div className=\"flex flex-row gap-x-2\">\n <div className=\"h-2 w-2 rounded-full bg-red-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-yellow-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-green-500\"></div>\n </div>\n </div>\n <pre className=\"p-4\">\n <code className=\"grid gap-y-1 overflow-auto\">{wrappedChildren}</code>\n </pre>\n </div>\n )\n\n if (!sequence) return content\n\n return (\n <SequenceContext.Provider value={contextValue}>\n {content}\n </SequenceContext.Provider>\n )\n}\n",
+ "content": "\"use client\"\n\nimport {\n Children,\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { motion, useInView, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface SequenceContextValue {\n completeItem: (index: number) => void\n activeIndex: number\n sequenceStarted: boolean\n}\n\nconst SequenceContext = createContext<SequenceContextValue | null>(null)\n\nconst useSequence = () => useContext(SequenceContext)\n\nconst ItemIndexContext = createContext<number | null>(null)\nconst useItemIndex = () => useContext(ItemIndexContext)\n\ninterface AnimatedSpanProps extends MotionProps {\n children: React.ReactNode\n delay?: number\n className?: string\n startOnView?: boolean\n}\n\nexport const AnimatedSpan = ({\n children,\n delay = 0,\n className,\n startOnView = false,\n ...props\n}: AnimatedSpanProps) => {\n const elementRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n const [hasStarted, setHasStarted] = useState(false)\n useEffect(() => {\n if (!sequence || itemIndex === null) return\n if (!sequence.sequenceStarted) return\n if (hasStarted) return\n if (sequence.activeIndex === itemIndex) {\n setHasStarted(true)\n }\n }, [sequence?.activeIndex, sequence?.sequenceStarted, hasStarted, itemIndex])\n\n const shouldAnimate = sequence ? hasStarted : startOnView ? isInView : true\n\n return (\n <motion.div\n ref={elementRef}\n initial={{ opacity: 0, y: -5 }}\n animate={shouldAnimate ? { opacity: 1, y: 0 } : { opacity: 0, y: -5 }}\n transition={{ duration: 0.3, delay: sequence ? 0 : delay / 1000 }}\n className={cn(\"grid text-sm font-normal tracking-tight\", className)}\n onAnimationComplete={() => {\n if (!sequence) return\n if (itemIndex === null) return\n sequence.completeItem(itemIndex)\n }}\n {...props}\n >\n {children}\n </motion.div>\n )\n}\n\ninterface TypingAnimationProps extends MotionProps {\n children: string\n className?: string\n duration?: number\n delay?: number\n as?: React.ElementType\n startOnView?: boolean\n}\n\nexport const TypingAnimation = ({\n children,\n className,\n duration = 60,\n delay = 0,\n as: Component = \"span\",\n startOnView = true,\n ...props\n}: TypingAnimationProps) => {\n if (typeof children !== \"string\") {\n throw new Error(\"TypingAnimation: children must be a string. Received:\")\n }\n\n const MotionComponent = useMemo(\n () =>\n motion.create(Component, {\n forwardMotionProps: true,\n }),\n [Component]\n )\n\n const [displayedText, setDisplayedText] = useState<string>(\"\")\n const [started, setStarted] = useState(false)\n const elementRef = useRef<HTMLElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n\n useEffect(() => {\n if (sequence && itemIndex !== null) {\n if (!sequence.sequenceStarted) return\n if (started) return\n if (sequence.activeIndex === itemIndex) {\n setStarted(true)\n }\n return\n }\n\n if (!startOnView) {\n const startTimeout = setTimeout(() => setStarted(true), delay)\n return () => clearTimeout(startTimeout)\n }\n\n if (!isInView) return\n\n const startTimeout = setTimeout(() => setStarted(true), delay)\n return () => clearTimeout(startTimeout)\n }, [\n delay,\n startOnView,\n isInView,\n started,\n sequence?.activeIndex,\n sequence?.sequenceStarted,\n itemIndex,\n ])\n\n useEffect(() => {\n if (!started) return\n\n let i = 0\n const typingEffect = setInterval(() => {\n if (i < children.length) {\n setDisplayedText(children.substring(0, i + 1))\n i++\n } else {\n clearInterval(typingEffect)\n if (sequence && itemIndex !== null) {\n sequence.completeItem(itemIndex)\n }\n }\n }, duration)\n\n return () => {\n clearInterval(typingEffect)\n }\n }, [children, duration, started])\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"text-sm font-normal tracking-tight\", className)}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n )\n}\n\ninterface TerminalProps {\n children: React.ReactNode\n className?: string\n sequence?: boolean\n startOnView?: boolean\n}\n\nexport const Terminal = ({\n children,\n className,\n sequence = true,\n startOnView = true,\n}: TerminalProps) => {\n const containerRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(containerRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const [activeIndex, setActiveIndex] = useState(0)\n const sequenceHasStarted = sequence ? !startOnView || isInView : false\n\n const contextValue = useMemo<SequenceContextValue | null>(() => {\n if (!sequence) return null\n return {\n completeItem: (index: number) => {\n setActiveIndex((current) => (index === current ? current + 1 : current))\n },\n activeIndex,\n sequenceStarted: sequenceHasStarted,\n }\n }, [sequence, activeIndex, sequenceHasStarted])\n\n const wrappedChildren = useMemo(() => {\n if (!sequence) return children\n const array = Children.toArray(children)\n return array.map((child, index) => (\n <ItemIndexContext.Provider key={index} value={index}>\n {child as React.ReactNode}\n </ItemIndexContext.Provider>\n ))\n }, [children, sequence])\n\n const content = (\n <div\n ref={containerRef}\n className={cn(\n \"border-border bg-background z-0 h-full max-h-[400px] w-full max-w-lg rounded-xl border\",\n className\n )}\n >\n <div className=\"border-border flex flex-col gap-y-2 border-b p-4\">\n <div className=\"flex flex-row gap-x-2\">\n <div className=\"h-2 w-2 rounded-full bg-red-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-yellow-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-green-500\"></div>\n </div>\n </div>\n <pre className=\"p-4\">\n <code className=\"grid gap-y-1 overflow-auto\">{wrappedChildren}</code>\n </pre>\n </div>\n )\n\n if (!sequence) return content\n\n return (\n <SequenceContext.Provider value={contextValue}>\n {content}\n </SequenceContext.Provider>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/text-animate.json b/apps/www/public/r/text-animate.json
index 2f3f78d2..5fa91cb8 100644
--- a/apps/www/public/r/text-animate.json
+++ b/apps/www/public/r/text-animate.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/text-animate.tsx",
- "content": "\"use client\"\n\nimport { ElementType, memo } from \"react\"\nimport { AnimatePresence, motion, MotionProps, Variants } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype AnimationType = \"text\" | \"word\" | \"character\" | \"line\"\ntype AnimationVariant =\n | \"fadeIn\"\n | \"blurIn\"\n | \"blurInUp\"\n | \"blurInDown\"\n | \"slideUp\"\n | \"slideDown\"\n | \"slideLeft\"\n | \"slideRight\"\n | \"scaleUp\"\n | \"scaleDown\"\n\ninterface TextAnimateProps extends MotionProps {\n /**\n * The text content to animate\n */\n children: string\n /**\n * The class name to be applied to the component\n */\n className?: string\n /**\n * The class name to be applied to each segment\n */\n segmentClassName?: string\n /**\n * The delay before the animation starts\n */\n delay?: number\n /**\n * The duration of the animation\n */\n duration?: number\n /**\n * Custom motion variants for the animation\n */\n variants?: Variants\n /**\n * The element type to render\n */\n as?: ElementType\n /**\n * How to split the text (\"text\", \"word\", \"character\")\n */\n by?: AnimationType\n /**\n * Whether to start animation when component enters viewport\n */\n startOnView?: boolean\n /**\n * Whether to animate only once\n */\n once?: boolean\n /**\n * The animation preset to use\n */\n animation?: AnimationVariant\n /**\n * Whether to enable accessibility features (default: true)\n */\n accessible?: boolean\n}\n\nconst staggerTimings: Record<AnimationType, number> = {\n text: 0.06,\n word: 0.05,\n character: 0.03,\n line: 0.06,\n}\n\nconst defaultContainerVariants = {\n hidden: { opacity: 1 },\n show: {\n opacity: 1,\n transition: {\n delayChildren: 0,\n staggerChildren: 0.05,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n staggerChildren: 0.05,\n staggerDirection: -1,\n },\n },\n}\n\nconst defaultItemVariants: Variants = {\n hidden: { opacity: 0 },\n show: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n}\n\nconst defaultItemAnimationVariants: Record<\n AnimationVariant,\n { container: Variants; item: Variants }\n> = {\n fadeIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, y: 20 },\n show: {\n opacity: 1,\n y: 0,\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n opacity: 0,\n y: 20,\n transition: { duration: 0.3 },\n },\n },\n },\n blurIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\" },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n transition: { duration: 0.3 },\n },\n },\n },\n blurInUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: 20 },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n y: 20,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n blurInDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: -20 },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n slideUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: 20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n y: -20,\n opacity: 0,\n transition: {\n duration: 0.3,\n },\n },\n },\n },\n slideDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: -20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n y: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideLeft: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: 20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: -20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideRight: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: -20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 0.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 0.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 1.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 1.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n}\n\nconst TextAnimateBase = ({\n children,\n delay = 0,\n duration = 0.3,\n variants,\n className,\n segmentClassName,\n as: Component = \"p\",\n startOnView = true,\n once = false,\n by = \"word\",\n animation = \"fadeIn\",\n accessible = true,\n ...props\n}: TextAnimateProps) => {\n const MotionComponent = motion.create(Component)\n\n let segments: string[] = []\n switch (by) {\n case \"word\":\n segments = children.split(/(\\s+)/)\n break\n case \"character\":\n segments = children.split(\"\")\n break\n case \"line\":\n segments = children.split(\"\\n\")\n break\n case \"text\":\n default:\n segments = [children]\n break\n }\n\n const finalVariants = variants\n ? {\n container: {\n hidden: { opacity: 0 },\n show: {\n opacity: 1,\n transition: {\n opacity: { duration: 0.01, delay },\n delayChildren: delay,\n staggerChildren: duration / segments.length,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n staggerChildren: duration / segments.length,\n staggerDirection: -1,\n },\n },\n },\n item: variants,\n }\n : animation\n ? {\n container: {\n ...defaultItemAnimationVariants[animation].container,\n show: {\n ...defaultItemAnimationVariants[animation].container.show,\n transition: {\n delayChildren: delay,\n staggerChildren: duration / segments.length,\n },\n },\n exit: {\n ...defaultItemAnimationVariants[animation].container.exit,\n transition: {\n staggerChildren: duration / segments.length,\n staggerDirection: -1,\n },\n },\n },\n item: defaultItemAnimationVariants[animation].item,\n }\n : { container: defaultContainerVariants, item: defaultItemVariants }\n\n return (\n <AnimatePresence mode=\"popLayout\">\n <MotionComponent\n variants={finalVariants.container as Variants}\n initial=\"hidden\"\n whileInView={startOnView ? \"show\" : undefined}\n animate={startOnView ? undefined : \"show\"}\n exit=\"exit\"\n className={cn(\"whitespace-pre-wrap\", className)}\n viewport={{ once }}\n aria-label={accessible ? children : undefined}\n {...props}\n >\n {accessible && <span className=\"sr-only\">{children}</span>}\n {segments.map((segment, i) => (\n <motion.span\n key={`${by}-${segment}-${i}`}\n variants={finalVariants.item}\n custom={i * staggerTimings[by]}\n className={cn(\n by === \"line\" ? \"block\" : \"inline-block whitespace-pre\",\n by === \"character\" && \"\",\n segmentClassName\n )}\n aria-hidden={accessible ? true : undefined}\n >\n {segment}\n </motion.span>\n ))}\n </MotionComponent>\n </AnimatePresence>\n )\n}\n\n// Export the memoized version\nexport const TextAnimate = memo(TextAnimateBase)\n",
+ "content": "\"use client\"\n\nimport { ElementType, memo } from \"react\"\nimport {\n AnimatePresence,\n motion,\n Variants,\n type MotionProps,\n} from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype AnimationType = \"text\" | \"word\" | \"character\" | \"line\"\ntype AnimationVariant =\n | \"fadeIn\"\n | \"blurIn\"\n | \"blurInUp\"\n | \"blurInDown\"\n | \"slideUp\"\n | \"slideDown\"\n | \"slideLeft\"\n | \"slideRight\"\n | \"scaleUp\"\n | \"scaleDown\"\n\ninterface TextAnimateProps extends MotionProps {\n /**\n * The text content to animate\n */\n children: string\n /**\n * The class name to be applied to the component\n */\n className?: string\n /**\n * The class name to be applied to each segment\n */\n segmentClassName?: string\n /**\n * The delay before the animation starts\n */\n delay?: number\n /**\n * The duration of the animation\n */\n duration?: number\n /**\n * Custom motion variants for the animation\n */\n variants?: Variants\n /**\n * The element type to render\n */\n as?: ElementType\n /**\n * How to split the text (\"text\", \"word\", \"character\")\n */\n by?: AnimationType\n /**\n * Whether to start animation when component enters viewport\n */\n startOnView?: boolean\n /**\n * Whether to animate only once\n */\n once?: boolean\n /**\n * The animation preset to use\n */\n animation?: AnimationVariant\n /**\n * Whether to enable accessibility features (default: true)\n */\n accessible?: boolean\n}\n\nconst staggerTimings: Record<AnimationType, number> = {\n text: 0.06,\n word: 0.05,\n character: 0.03,\n line: 0.06,\n}\n\nconst defaultContainerVariants = {\n hidden: { opacity: 1 },\n show: {\n opacity: 1,\n transition: {\n delayChildren: 0,\n staggerChildren: 0.05,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n staggerChildren: 0.05,\n staggerDirection: -1,\n },\n },\n}\n\nconst defaultItemVariants: Variants = {\n hidden: { opacity: 0 },\n show: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n}\n\nconst defaultItemAnimationVariants: Record<\n AnimationVariant,\n { container: Variants; item: Variants }\n> = {\n fadeIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, y: 20 },\n show: {\n opacity: 1,\n y: 0,\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n opacity: 0,\n y: 20,\n transition: { duration: 0.3 },\n },\n },\n },\n blurIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\" },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n transition: { duration: 0.3 },\n },\n },\n },\n blurInUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: 20 },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n y: 20,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n blurInDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: -20 },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n slideUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: 20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n y: -20,\n opacity: 0,\n transition: {\n duration: 0.3,\n },\n },\n },\n },\n slideDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: -20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n y: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideLeft: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: 20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: -20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideRight: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: -20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 0.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 0.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 1.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 1.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n}\n\nconst TextAnimateBase = ({\n children,\n delay = 0,\n duration = 0.3,\n variants,\n className,\n segmentClassName,\n as: Component = \"p\",\n startOnView = true,\n once = false,\n by = \"word\",\n animation = \"fadeIn\",\n accessible = true,\n ...props\n}: TextAnimateProps) => {\n const MotionComponent = motion.create(Component)\n\n let segments: string[] = []\n switch (by) {\n case \"word\":\n segments = children.split(/(\\s+)/)\n break\n case \"character\":\n segments = children.split(\"\")\n break\n case \"line\":\n segments = children.split(\"\\n\")\n break\n case \"text\":\n default:\n segments = [children]\n break\n }\n\n const finalVariants = variants\n ? {\n container: {\n hidden: { opacity: 0 },\n show: {\n opacity: 1,\n transition: {\n opacity: { duration: 0.01, delay },\n delayChildren: delay,\n staggerChildren: duration / segments.length,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n staggerChildren: duration / segments.length,\n staggerDirection: -1,\n },\n },\n },\n item: variants,\n }\n : animation\n ? {\n container: {\n ...defaultItemAnimationVariants[animation].container,\n show: {\n ...defaultItemAnimationVariants[animation].container.show,\n transition: {\n delayChildren: delay,\n staggerChildren: duration / segments.length,\n },\n },\n exit: {\n ...defaultItemAnimationVariants[animation].container.exit,\n transition: {\n staggerChildren: duration / segments.length,\n staggerDirection: -1,\n },\n },\n },\n item: defaultItemAnimationVariants[animation].item,\n }\n : { container: defaultContainerVariants, item: defaultItemVariants }\n\n return (\n <AnimatePresence mode=\"popLayout\">\n <MotionComponent\n variants={finalVariants.container as Variants}\n initial=\"hidden\"\n whileInView={startOnView ? \"show\" : undefined}\n animate={startOnView ? undefined : \"show\"}\n exit=\"exit\"\n className={cn(\"whitespace-pre-wrap\", className)}\n viewport={{ once }}\n aria-label={accessible ? children : undefined}\n {...props}\n >\n {accessible && <span className=\"sr-only\">{children}</span>}\n {segments.map((segment, i) => (\n <motion.span\n key={`${by}-${segment}-${i}`}\n variants={finalVariants.item}\n custom={i * staggerTimings[by]}\n className={cn(\n by === \"line\" ? \"block\" : \"inline-block whitespace-pre\",\n by === \"character\" && \"\",\n segmentClassName\n )}\n aria-hidden={accessible ? true : undefined}\n >\n {segment}\n </motion.span>\n ))}\n </MotionComponent>\n </AnimatePresence>\n )\n}\n\n// Export the memoized version\nexport const TextAnimate = memo(TextAnimateBase)\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/typing-animation.json b/apps/www/public/r/typing-animation.json
index 0768cdeb..1c931125 100644
--- a/apps/www/public/r/typing-animation.json
+++ b/apps/www/public/r/typing-animation.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/typing-animation.tsx",
- "content": "\"use client\"\n\nimport { useEffect, useMemo, useRef, useState } from \"react\"\nimport { motion, MotionProps, useInView } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface TypingAnimationProps extends MotionProps {\n children?: string\n words?: string[]\n className?: string\n duration?: number\n typeSpeed?: number\n deleteSpeed?: number\n delay?: number\n pauseDelay?: number\n loop?: boolean\n as?: React.ElementType\n startOnView?: boolean\n showCursor?: boolean\n blinkCursor?: boolean\n cursorStyle?: \"line\" | \"block\" | \"underscore\"\n}\n\nexport function TypingAnimation({\n children,\n words,\n className,\n duration = 100,\n typeSpeed,\n deleteSpeed,\n delay = 0,\n pauseDelay = 1000,\n loop = false,\n as: Component = \"span\",\n startOnView = true,\n showCursor = true,\n blinkCursor = true,\n cursorStyle = \"line\",\n ...props\n}: TypingAnimationProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n })\n\n const [displayedText, setDisplayedText] = useState<string>(\"\")\n const [currentWordIndex, setCurrentWordIndex] = useState(0)\n const [currentCharIndex, setCurrentCharIndex] = useState(0)\n const [phase, setPhase] = useState<\"typing\" | \"pause\" | \"deleting\">(\"typing\")\n const elementRef = useRef<HTMLElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const wordsToAnimate = useMemo(\n () => words || (children ? [children] : []),\n [words, children]\n )\n const hasMultipleWords = wordsToAnimate.length > 1\n\n const typingSpeed = typeSpeed || duration\n const deletingSpeed = deleteSpeed || typingSpeed / 2\n\n const shouldStart = startOnView ? isInView : true\n\n useEffect(() => {\n if (!shouldStart || wordsToAnimate.length === 0) return\n\n const timeoutDelay =\n delay > 0 && displayedText === \"\"\n ? delay\n : phase === \"typing\"\n ? typingSpeed\n : phase === \"deleting\"\n ? deletingSpeed\n : pauseDelay\n\n const timeout = setTimeout(() => {\n const currentWord = wordsToAnimate[currentWordIndex] || \"\"\n const graphemes = Array.from(currentWord)\n\n switch (phase) {\n case \"typing\":\n if (currentCharIndex < graphemes.length) {\n setDisplayedText(graphemes.slice(0, currentCharIndex + 1).join(\"\"))\n setCurrentCharIndex(currentCharIndex + 1)\n } else {\n if (hasMultipleWords || loop) {\n const isLastWord = currentWordIndex === wordsToAnimate.length - 1\n if (!isLastWord || loop) {\n setPhase(\"pause\")\n }\n }\n }\n break\n\n case \"pause\":\n setPhase(\"deleting\")\n break\n\n case \"deleting\":\n if (currentCharIndex > 0) {\n setDisplayedText(graphemes.slice(0, currentCharIndex - 1).join(\"\"))\n setCurrentCharIndex(currentCharIndex - 1)\n } else {\n const nextIndex = (currentWordIndex + 1) % wordsToAnimate.length\n setCurrentWordIndex(nextIndex)\n setPhase(\"typing\")\n }\n break\n }\n }, timeoutDelay)\n\n return () => clearTimeout(timeout)\n }, [\n shouldStart,\n phase,\n currentCharIndex,\n currentWordIndex,\n displayedText,\n wordsToAnimate,\n hasMultipleWords,\n loop,\n typingSpeed,\n deletingSpeed,\n pauseDelay,\n delay,\n ])\n\n const currentWordGraphemes = Array.from(\n wordsToAnimate[currentWordIndex] || \"\"\n )\n const isComplete =\n !loop &&\n currentWordIndex === wordsToAnimate.length - 1 &&\n currentCharIndex >= currentWordGraphemes.length &&\n phase !== \"deleting\"\n\n const shouldShowCursor =\n showCursor &&\n !isComplete &&\n (hasMultipleWords || loop || currentCharIndex < currentWordGraphemes.length)\n\n const getCursorChar = () => {\n switch (cursorStyle) {\n case \"block\":\n return \"▌\"\n case \"underscore\":\n return \"_\"\n case \"line\":\n default:\n return \"|\"\n }\n }\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"leading-[5rem] tracking-[-0.02em]\", className)}\n {...props}\n >\n {displayedText}\n {shouldShowCursor && (\n <span\n className={cn(\"inline-block\", blinkCursor && \"animate-blink-cursor\")}\n >\n {getCursorChar()}\n </span>\n )}\n </MotionComponent>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { useEffect, useMemo, useRef, useState } from \"react\"\nimport { motion, useInView, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface TypingAnimationProps extends MotionProps {\n children?: string\n words?: string[]\n className?: string\n duration?: number\n typeSpeed?: number\n deleteSpeed?: number\n delay?: number\n pauseDelay?: number\n loop?: boolean\n as?: React.ElementType\n startOnView?: boolean\n showCursor?: boolean\n blinkCursor?: boolean\n cursorStyle?: \"line\" | \"block\" | \"underscore\"\n}\n\nexport function TypingAnimation({\n children,\n words,\n className,\n duration = 100,\n typeSpeed,\n deleteSpeed,\n delay = 0,\n pauseDelay = 1000,\n loop = false,\n as: Component = \"span\",\n startOnView = true,\n showCursor = true,\n blinkCursor = true,\n cursorStyle = \"line\",\n ...props\n}: TypingAnimationProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n })\n\n const [displayedText, setDisplayedText] = useState<string>(\"\")\n const [currentWordIndex, setCurrentWordIndex] = useState(0)\n const [currentCharIndex, setCurrentCharIndex] = useState(0)\n const [phase, setPhase] = useState<\"typing\" | \"pause\" | \"deleting\">(\"typing\")\n const elementRef = useRef<HTMLElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const wordsToAnimate = useMemo(\n () => words || (children ? [children] : []),\n [words, children]\n )\n const hasMultipleWords = wordsToAnimate.length > 1\n\n const typingSpeed = typeSpeed || duration\n const deletingSpeed = deleteSpeed || typingSpeed / 2\n\n const shouldStart = startOnView ? isInView : true\n\n useEffect(() => {\n if (!shouldStart || wordsToAnimate.length === 0) return\n\n const timeoutDelay =\n delay > 0 && displayedText === \"\"\n ? delay\n : phase === \"typing\"\n ? typingSpeed\n : phase === \"deleting\"\n ? deletingSpeed\n : pauseDelay\n\n const timeout = setTimeout(() => {\n const currentWord = wordsToAnimate[currentWordIndex] || \"\"\n const graphemes = Array.from(currentWord)\n\n switch (phase) {\n case \"typing\":\n if (currentCharIndex < graphemes.length) {\n setDisplayedText(graphemes.slice(0, currentCharIndex + 1).join(\"\"))\n setCurrentCharIndex(currentCharIndex + 1)\n } else {\n if (hasMultipleWords || loop) {\n const isLastWord = currentWordIndex === wordsToAnimate.length - 1\n if (!isLastWord || loop) {\n setPhase(\"pause\")\n }\n }\n }\n break\n\n case \"pause\":\n setPhase(\"deleting\")\n break\n\n case \"deleting\":\n if (currentCharIndex > 0) {\n setDisplayedText(graphemes.slice(0, currentCharIndex - 1).join(\"\"))\n setCurrentCharIndex(currentCharIndex - 1)\n } else {\n const nextIndex = (currentWordIndex + 1) % wordsToAnimate.length\n setCurrentWordIndex(nextIndex)\n setPhase(\"typing\")\n }\n break\n }\n }, timeoutDelay)\n\n return () => clearTimeout(timeout)\n }, [\n shouldStart,\n phase,\n currentCharIndex,\n currentWordIndex,\n displayedText,\n wordsToAnimate,\n hasMultipleWords,\n loop,\n typingSpeed,\n deletingSpeed,\n pauseDelay,\n delay,\n ])\n\n const currentWordGraphemes = Array.from(\n wordsToAnimate[currentWordIndex] || \"\"\n )\n const isComplete =\n !loop &&\n currentWordIndex === wordsToAnimate.length - 1 &&\n currentCharIndex >= currentWordGraphemes.length &&\n phase !== \"deleting\"\n\n const shouldShowCursor =\n showCursor &&\n !isComplete &&\n (hasMultipleWords || loop || currentCharIndex < currentWordGraphemes.length)\n\n const getCursorChar = () => {\n switch (cursorStyle) {\n case \"block\":\n return \"▌\"\n case \"underscore\":\n return \"_\"\n case \"line\":\n default:\n return \"|\"\n }\n }\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"leading-[5rem] tracking-[-0.02em]\", className)}\n {...props}\n >\n {displayedText}\n {shouldShowCursor && (\n <span\n className={cn(\"inline-block\", blinkCursor && \"animate-blink-cursor\")}\n >\n {getCursorChar()}\n </span>\n )}\n </MotionComponent>\n )\n}\n",
"type": "registry:ui"
}
],
diff --git a/apps/www/public/r/word-rotate.json b/apps/www/public/r/word-rotate.json
index 0e5a9667..ed26d072 100644
--- a/apps/www/public/r/word-rotate.json
+++ b/apps/www/public/r/word-rotate.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/word-rotate.tsx",
- "content": "\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { AnimatePresence, motion, MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface WordRotateProps {\n words: string[]\n duration?: number\n motionProps?: MotionProps\n className?: string\n}\n\nexport function WordRotate({\n words,\n duration = 2500,\n motionProps = {\n initial: { opacity: 0, y: -50 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: 50 },\n transition: { duration: 0.25, ease: \"easeOut\" },\n },\n className,\n}: WordRotateProps) {\n const [index, setIndex] = useState(0)\n\n useEffect(() => {\n const interval = setInterval(() => {\n setIndex((prevIndex) => (prevIndex + 1) % words.length)\n }, duration)\n\n // Clean up interval on unmount\n return () => clearInterval(interval)\n }, [words, duration])\n\n return (\n <div className=\"overflow-hidden py-2\">\n <AnimatePresence mode=\"wait\">\n <motion.h1\n key={words[index]}\n className={cn(className)}\n {...motionProps}\n >\n {words[index]}\n </motion.h1>\n </AnimatePresence>\n </div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { AnimatePresence, motion, type MotionProps } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface WordRotateProps {\n words: string[]\n duration?: number\n motionProps?: MotionProps\n className?: string\n}\n\nexport function WordRotate({\n words,\n duration = 2500,\n motionProps = {\n initial: { opacity: 0, y: -50 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: 50 },\n transition: { duration: 0.25, ease: \"easeOut\" },\n },\n className,\n}: WordRotateProps) {\n const [index, setIndex] = useState(0)\n\n useEffect(() => {\n const interval = setInterval(() => {\n setIndex((prevIndex) => (prevIndex + 1) % words.length)\n }, duration)\n\n // Clean up interval on unmount\n return () => clearInterval(interval)\n }, [words, duration])\n\n return (\n <div className=\"overflow-hidden py-2\">\n <AnimatePresence mode=\"wait\">\n <motion.h1\n key={words[index]}\n className={cn(className)}\n {...motionProps}\n >\n {words[index]}\n </motion.h1>\n </AnimatePresence>\n </div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/registry/magicui/animated-list.tsx b/apps/www/registry/magicui/animated-list.tsx
index 1e29b9f0..1396b65b 100644
--- a/apps/www/registry/magicui/animated-list.tsx
+++ b/apps/www/registry/magicui/animated-list.tsx
@@ -6,7 +6,7 @@ import React, {
useMemo,
useState,
} from "react"
-import { AnimatePresence, motion, MotionProps } from "motion/react"
+import { AnimatePresence, motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/hyper-text.tsx b/apps/www/registry/magicui/hyper-text.tsx
index fec9d6c2..6fbef43e 100644
--- a/apps/www/registry/magicui/hyper-text.tsx
+++ b/apps/www/registry/magicui/hyper-text.tsx
@@ -1,7 +1,7 @@
"use client"
import { useEffect, useRef, useState } from "react"
-import { AnimatePresence, motion, MotionProps } from "motion/react"
+import { AnimatePresence, motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/line-shadow-text.tsx b/apps/www/registry/magicui/line-shadow-text.tsx
index c90f8a63..93b6591b 100644
--- a/apps/www/registry/magicui/line-shadow-text.tsx
+++ b/apps/www/registry/magicui/line-shadow-text.tsx
@@ -1,6 +1,6 @@
"use client"
-import { motion, MotionProps } from "motion/react"
+import { motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/scroll-progress.tsx b/apps/www/registry/magicui/scroll-progress.tsx
index 78f48873..574f5725 100644
--- a/apps/www/registry/magicui/scroll-progress.tsx
+++ b/apps/www/registry/magicui/scroll-progress.tsx
@@ -1,6 +1,6 @@
"use client"
-import { motion, MotionProps, useScroll } from "motion/react"
+import { motion, useScroll, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/terminal.tsx b/apps/www/registry/magicui/terminal.tsx
index 0b0ce7e1..a9f91578 100644
--- a/apps/www/registry/magicui/terminal.tsx
+++ b/apps/www/registry/magicui/terminal.tsx
@@ -9,7 +9,7 @@ import {
useRef,
useState,
} from "react"
-import { motion, MotionProps, useInView } from "motion/react"
+import { motion, useInView, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/text-animate.tsx b/apps/www/registry/magicui/text-animate.tsx
index 62afc2be..77dd7079 100644
--- a/apps/www/registry/magicui/text-animate.tsx
+++ b/apps/www/registry/magicui/text-animate.tsx
@@ -1,7 +1,12 @@
"use client"
import { ElementType, memo } from "react"
-import { AnimatePresence, motion, MotionProps, Variants } from "motion/react"
+import {
+ AnimatePresence,
+ motion,
+ Variants,
+ type MotionProps,
+} from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/typing-animation.tsx b/apps/www/registry/magicui/typing-animation.tsx
index e6ef2cc5..88f16db4 100644
--- a/apps/www/registry/magicui/typing-animation.tsx
+++ b/apps/www/registry/magicui/typing-animation.tsx
@@ -1,7 +1,7 @@
"use client"
import { useEffect, useMemo, useRef, useState } from "react"
-import { motion, MotionProps, useInView } from "motion/react"
+import { motion, useInView, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/word-rotate.tsx b/apps/www/registry/magicui/word-rotate.tsx
index 68aa49c9..ad1866f5 100644
--- a/apps/www/registry/magicui/word-rotate.tsx
+++ b/apps/www/registry/magicui/word-rotate.tsx
@@ -1,7 +1,7 @@
"use client"
import { useEffect, useState } from "react"
-import { AnimatePresence, motion, MotionProps } from "motion/react"
+import { AnimatePresence, motion, type MotionProps } from "motion/react"
import { cn } from "@/lib/utils"