{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "blur-reveal",
  "title": "Blur Reveal",
  "description": "Text that comes into focus from a blur, letter by letter, on mount or when scrolled into view.",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "packages/blur-reveal/blur-reveal.tsx",
      "content": "\"use client\";\r\nimport { useContext, useSyncExternalStore } from \"react\";\r\nimport { MotionConfigContext, AnimatePresence, motion } from \"motion/react\";\r\nimport type React from \"react\";\r\n\r\n/**\r\n * \"user\" (the default) follows a surrounding <MotionConfig reducedMotion>,\r\n * then the visitor's \"reduce motion\" device setting. \"always\" and \"never\"\r\n * force the calm or the full version.\r\n */\r\nexport type ReducedMotion = \"user\" | \"always\" | \"never\";\r\n\r\nconst REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\r\n\r\nfunction subscribeToReducedMotion(onChange: () => void) {\r\n  const query = window.matchMedia(REDUCED_MOTION_QUERY);\r\n  query.addEventListener(\"change\", onChange);\r\n  return () => query.removeEventListener(\"change\", onChange);\r\n}\r\n\r\n// The prop wins, then MotionConfig, then the device setting. The device is\r\n// read as \"no\" while server rendering, so hydration always matches.\r\nfunction useShouldReduceMotion(mode: ReducedMotion = \"user\") {\r\n  const device = useSyncExternalStore(\r\n    subscribeToReducedMotion,\r\n    () => window.matchMedia(REDUCED_MOTION_QUERY).matches,\r\n    () => false,\r\n  );\r\n  const config = useContext(MotionConfigContext).reducedMotion;\r\n  if (mode !== \"user\") return mode === \"always\";\r\n  if (config === \"always\" || config === \"never\") return config === \"always\";\r\n  return device;\r\n}\r\n\r\nexport interface BlurRevealProps\r\n  extends Omit<\r\n    React.HTMLAttributes<HTMLElement>,\r\n    \"children\" | \"style\" | \"onAnimationStart\" | \"onAnimationEnd\" | \"onDrag\" | \"onDragStart\" | \"onDragEnd\"\r\n  > {\r\n  /** The text to reveal. Plain text only: it is split into letters. */\r\n  children: string;\r\n  /** Classes for the text element. */\r\n  className?: string;\r\n  /** Seconds to wait before the first letter appears. */\r\n  delay?: number;\r\n  /** Seconds between one letter starting and the next. @default 0.02 */\r\n  stagger?: number;\r\n  /** Seconds each letter takes to sharpen and rise. @default 0.6 */\r\n  duration?: number;\r\n  /** Show the text. Set to false to blur it back out, and to true again to replay the reveal. */\r\n  trigger?: boolean;\r\n  /** Called when the last letter has finished. */\r\n  onAnimationComplete?: () => void;\r\n  /** Called when the reveal begins. */\r\n  onAnimationStart?: () => void;\r\n  /** The element to render, such as \"h1\" or \"span\". */\r\n  as?: keyof React.JSX.IntrinsicElements;\r\n  /** Inline styles for the text element. */\r\n  style?: React.CSSProperties;\r\n  /** Wait until the text scrolls into view before revealing it. */\r\n  inView?: boolean;\r\n  /**\r\n   * With inView, reveal only the first time. Set to false to replay each time it comes back\r\n   * into view.\r\n   */\r\n  once?: boolean;\r\n  /** Extra space after each letter, as a CSS length or a number of pixels. */\r\n  letterSpacing?: string | number;\r\n  /**\r\n   * \"user\" follows a surrounding MotionConfig, then the visitor's reduce-motion setting.\r\n   * \"always\" and \"never\" force the calm or the full version.\r\n   */\r\n  reducedMotion?: ReducedMotion;\r\n  /** Ref to the text element. */\r\n  ref?: React.Ref<HTMLElement>;\r\n}\r\n\r\nconst BlurReveal = ({\r\n  children,\r\n  className,\r\n  delay = 0,\r\n  stagger: letterStagger = 0.02,\r\n  duration = 0.6,\r\n  trigger = true,\r\n  onAnimationComplete,\r\n  onAnimationStart,\r\n  as = \"p\",\r\n  style,\r\n  inView = false,\r\n  once = true,\r\n  letterSpacing,\r\n  reducedMotion = \"user\",\r\n  ref,\r\n  ...props\r\n}: BlurRevealProps) => {\r\n  const MotionTag = motion[as as keyof typeof motion] as typeof motion.div;\r\n\r\n  // Reduced motion fades the whole line in at once: no blur, no rise, no stagger.\r\n  const reduce = useShouldReduceMotion(reducedMotion);\r\n  const stagger = reduce ? 0 : letterStagger;\r\n  const baseDuration = duration;\r\n\r\n  const containerVariants = {\r\n    hidden: { opacity: 0 },\r\n    visible: {\r\n      opacity: 1,\r\n      transition: {\r\n        staggerChildren: stagger,\r\n        delayChildren: delay,\r\n      },\r\n    },\r\n    exit: {\r\n      transition: {\r\n        staggerChildren: stagger,\r\n        staggerDirection: -1,\r\n      },\r\n    },\r\n  };\r\n\r\n  const itemVariants = reduce\r\n    ? {\r\n        hidden: { opacity: 0 },\r\n        visible: { opacity: 1, transition: { duration: baseDuration } },\r\n        exit: { opacity: 0 },\r\n      }\r\n    : {\r\n        hidden: { opacity: 0, filter: \"blur(12px)\", y: 10 },\r\n        visible: {\r\n          opacity: 1,\r\n          filter: \"blur(0px)\",\r\n          y: 0,\r\n          transition: {\r\n            duration: baseDuration,\r\n          },\r\n        },\r\n        exit: { opacity: 0, filter: \"blur(12px)\", y: 10 },\r\n      };\r\n\r\n  return (\r\n    <AnimatePresence mode=\"popLayout\">\r\n      {trigger && (\r\n        <MotionTag\r\n          {...props}\r\n          ref={ref as React.Ref<HTMLDivElement>}\r\n          initial=\"hidden\"\r\n          whileInView={inView ? \"visible\" : undefined}\r\n          animate={inView ? undefined : \"visible\"}\r\n          exit=\"exit\"\r\n          variants={containerVariants}\r\n          viewport={{ once }}\r\n          className={className}\r\n          onAnimationComplete={onAnimationComplete}\r\n          onAnimationStart={onAnimationStart}\r\n          style={style}\r\n        >\r\n          <span className=\"sr-only\">{children}</span>\r\n          {children &&\r\n            children.split(\" \").map((word, wordIndex, wordsArray) => (\r\n              <span\r\n                key={`word-${wordIndex}`}\r\n                className=\"inline-block whitespace-nowrap\"\r\n                aria-hidden=\"true\"\r\n              >\r\n                {word.split(\"\").map((char, charIndex) => (\r\n                  <motion.span\r\n                    key={`char-${wordIndex}-${charIndex}`}\r\n                    variants={itemVariants}\r\n                    className=\"inline-block\"\r\n                    style={\r\n                      letterSpacing ? { marginRight: letterSpacing } : undefined\r\n                    }\r\n                  >\r\n                    {char}\r\n                  </motion.span>\r\n                ))}\r\n                {wordIndex < wordsArray.length - 1 && (\r\n                  <motion.span\r\n                    key={`space-${wordIndex}`}\r\n                    variants={itemVariants}\r\n                    className=\"inline-block\"\r\n                  >\r\n                    &nbsp;\r\n                  </motion.span>\r\n                )}\r\n              </span>\r\n            ))}\r\n        </MotionTag>\r\n      )}\r\n    </AnimatePresence>\r\n  );\r\n};\r\nexport default BlurReveal;\r\n",
      "type": "registry:component",
      "target": "components/satori-ui/blur-reveal.tsx"
    }
  ],
  "meta": {
    "usage": "<BlurReveal as=\"h1\" className=\"text-4xl font-semibold\">\n  The fog slowly lifts\n</BlurReveal>"
  },
  "type": "registry:component"
}