{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-reveal",
  "title": "Motion Reveal",
  "description": "One wrapper that lets its content arrive when it comes into view, once, as a block or child by child. People who turned motion off see it at once.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://miseui.junsu4621.workers.dev/r/motion.json"
  ],
  "files": [
    {
      "path": "registry/miseui/ui/motion-reveal.tsx",
      "content": "import type * as React from \"react\"\nimport { Children, useRef } from \"react\"\nimport { motion, useInView, useReducedMotion } from \"motion/react\"\nimport { SPRING_DEFAULT } from \"@/registry/miseui/lib/motion\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\n\ntype MotionRevealVariant = \"rise\" | \"fade\" | \"clip\"\ntype MotionRevealEffect = \"stagger\"\ntype MotionRevealTag = \"div\" | \"section\" | \"article\" | \"ul\" | \"ol\" | \"li\" | \"span\"\n\nconst MOTION_TAG = {\n  div: motion.div,\n  section: motion.section,\n  article: motion.article,\n  ul: motion.ul,\n  ol: motion.ol,\n  li: motion.li,\n  span: motion.span,\n} as const\n\n/** Longer than a press: content arriving should be felt, not noticed. */\nconst REVEAL_TRANSITION = { ...SPRING_DEFAULT, duration: 0.6 }\n/** Keeps a block from starting while most of it is still under the fold. */\nconst VIEW_MARGIN = \"0px 0px -10% 0px\"\nconst STAGGER_STEP_S = 0.06\n/** A long list must not keep the last row waiting. */\nconst STAGGER_MAX_S = 0.48\n\nconst STATES = {\n  rise: { hidden: { opacity: 0, y: 16 }, shown: { opacity: 1, y: 0 } },\n  fade: { hidden: { opacity: 0 }, shown: { opacity: 1 } },\n  clip: { hidden: { clipPath: \"inset(0 0 100% 0)\" }, shown: { clipPath: \"inset(0 0 0% 0)\" } },\n} as const\n\nfunction staggerDelay(index: number, count: number, delay = 0) {\n  return delay + index * Math.min(STAGGER_STEP_S, STAGGER_MAX_S / Math.max(1, count))\n}\n\ntype MotionRevealProps = Omit<React.HTMLAttributes<HTMLElement>, \"onAnimationStart\" | \"onDrag\" | \"onDragStart\" | \"onDragEnd\"> & {\n  /** The element to render. A list wraps its staggered children in `li`. */\n  as?: MotionRevealTag\n  /** `rise` up and in, `fade` only opacity, `clip` wiped from the top for images and panels. */\n  variant?: MotionRevealVariant\n  /** `stagger` reveals the direct children one after another instead of the block as one. */\n  effect?: MotionRevealEffect\n  /** Seconds to wait before starting. */\n  delay?: number\n  /** Plays again each time it comes back into view. Off by default: reading something twice should not make you wait twice. */\n  repeat?: boolean\n}\n\nfunction MotionReveal({ as = \"div\", variant = \"rise\", effect, delay = 0, repeat = false, className, children, ...props }: MotionRevealProps) {\n  const reduceMotion = useReducedMotion() ?? false\n  const ref = useRef<HTMLDivElement>(null)\n  const seen = useInView(ref, { once: !repeat, margin: VIEW_MARGIN })\n  const root = { ...props, \"data-slot\": \"motion-reveal\", \"data-variant\": variant, \"data-effect\": effect, className: cn(as === \"span\" && \"inline-block\", className) }\n  // The cast is local: these tags take the same motion props, but a union of them cannot be called as one component.\n  const Tag = MOTION_TAG[as] as typeof motion.div\n  if (reduceMotion) {\n    const Plain = as as \"div\"\n    return (\n      <Plain {...root} data-reduced=\"true\">\n        {children}\n      </Plain>\n    )\n  }\n  const { hidden, shown } = STATES[variant]\n  const state = seen ? shown : hidden\n  if (effect !== \"stagger\") {\n    return (\n      <Tag {...root} ref={ref} initial={hidden} animate={state} transition={{ ...REVEAL_TRANSITION, delay }}>\n        {children}\n      </Tag>\n    )\n  }\n  const pieces = Children.toArray(children)\n  const Piece = as === \"ul\" || as === \"ol\" ? motion.li : motion.div\n  return (\n    // Only the pieces move: the watched root stays put, so its own transform cannot change when it counts as seen.\n    <Tag {...root} ref={ref}>\n      {pieces.map((piece, index) => (\n        <Piece key={index} data-slot=\"motion-reveal-piece\" initial={hidden} animate={state} transition={{ ...REVEAL_TRANSITION, delay: staggerDelay(index, pieces.length, delay) }}>\n          {piece}\n        </Piece>\n      ))}\n    </Tag>\n  )\n}\n\nexport { MotionReveal, staggerDelay, type MotionRevealProps, type MotionRevealVariant, type MotionRevealEffect, type MotionRevealTag }\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "display"
  ],
  "type": "registry:ui"
}