{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-animated-group",
  "title": "Animated group",
  "description": "A container component that applies coordinated animations to a group of child elements.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "components/core/animated-group.tsx",
      "content": "'use client';\nimport { ReactNode } from 'react';\nimport { motion, MotionConfig, Variants } from 'motion/react';\nimport { motionElementOf } from './motion-elements';\nimport React from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\nexport type PresetType =\n  | 'fade'\n  | 'slide'\n  | 'scale'\n  | 'blur'\n  | 'blur-slide'\n  | 'zoom'\n  | 'flip'\n  | 'bounce'\n  | 'rotate'\n  | 'swing';\n\nexport type AnimatedGroupProps = {\n  children: ReactNode;\n  className?: string;\n  variants?: {\n    container?: Variants;\n    item?: Variants;\n  };\n  preset?: PresetType;\n  as?: React.ElementType;\n  asChild?: React.ElementType;\n};\n\nconst defaultContainerVariants: Variants = {\n  visible: {\n    transition: {\n      staggerChildren: 0.1,\n    },\n  },\n};\n\nconst defaultItemVariants: Variants = {\n  hidden: { opacity: 0 },\n  visible: { opacity: 1 },\n};\n\nconst presetVariants: Record<PresetType, Variants> = {\n  fade: {},\n  slide: {\n    hidden: { y: 20 },\n    visible: { y: 0 },\n  },\n  scale: {\n    hidden: { scale: 0.8 },\n    visible: { scale: 1 },\n  },\n  blur: {\n    hidden: { filter: 'blur(4px)' },\n    visible: { filter: 'blur(0px)' },\n  },\n  'blur-slide': {\n    hidden: { filter: 'blur(4px)', y: 20 },\n    visible: { filter: 'blur(0px)', y: 0 },\n  },\n  zoom: {\n    hidden: { scale: 0.5 },\n    visible: {\n      scale: 1,\n      transition: { type: 'spring', stiffness: 300, damping: 20 },\n    },\n  },\n  flip: {\n    hidden: { rotateX: -90 },\n    visible: {\n      rotateX: 0,\n      transition: { type: 'spring', stiffness: 300, damping: 20 },\n    },\n  },\n  bounce: {\n    hidden: { y: -50 },\n    visible: {\n      y: 0,\n      transition: { type: 'spring', stiffness: 400, damping: 10 },\n    },\n  },\n  rotate: {\n    hidden: { rotate: -180 },\n    visible: {\n      rotate: 0,\n      transition: { type: 'spring', stiffness: 200, damping: 15 },\n    },\n  },\n  swing: {\n    hidden: { rotate: -10 },\n    visible: {\n      rotate: 0,\n      transition: { type: 'spring', stiffness: 300, damping: 8 },\n    },\n  },\n};\n\nconst addDefaultVariants = (variants: Variants) => ({\n  hidden: { ...defaultItemVariants.hidden, ...variants.hidden },\n  visible: { ...defaultItemVariants.visible, ...variants.visible },\n});\n\nfunction ReducedMotionConfig({ children }: { children: ReactNode }) {\n  const prefersReducedMotion = usePrefersReducedMotion();\n  if (!prefersReducedMotion) {\n    return children;\n  }\n  return <MotionConfig reducedMotion='always'>{children}</MotionConfig>;\n}\n\nfunction AnimatedGroup({\n  children,\n  className,\n  variants,\n  preset,\n  as = 'div',\n  asChild = 'div',\n}: AnimatedGroupProps) {\n  const selectedVariants = {\n    item: addDefaultVariants(preset ? presetVariants[preset] : {}),\n    container: addDefaultVariants(defaultContainerVariants),\n  };\n  const containerVariants = variants?.container || selectedVariants.container;\n  const itemVariants = variants?.item || selectedVariants.item;\n\n  const MotionComponent = motionElementOf(as) as typeof motion.div;\n  const MotionChild = motionElementOf(asChild) as typeof motion.div;\n\n  return (\n    <ReducedMotionConfig>\n      <MotionComponent\n        initial='hidden'\n        animate='visible'\n        variants={containerVariants}\n        className={className}\n      >\n        {React.Children.map(children, (child, index) => (\n          <MotionChild key={index} variants={itemVariants}>\n            {child}\n          </MotionChild>\n        ))}\n      </MotionComponent>\n    </ReducedMotionConfig>\n  );\n}\n\nexport { AnimatedGroup };\n",
      "type": "registry:component",
      "target": "components/core/animated-group.tsx"
    },
    {
      "path": "components/core/motion-elements.ts",
      "content": "import { motion } from 'motion/react';\n\nconst MOTION_ELEMENTS = {\n  a: motion.a,\n  article: motion.article,\n  aside: motion.aside,\n  blockquote: motion.blockquote,\n  button: motion.button,\n  code: motion.code,\n  div: motion.div,\n  em: motion.em,\n  figure: motion.figure,\n  footer: motion.footer,\n  h1: motion.h1,\n  h2: motion.h2,\n  h3: motion.h3,\n  h4: motion.h4,\n  h5: motion.h5,\n  h6: motion.h6,\n  header: motion.header,\n  label: motion.label,\n  li: motion.li,\n  main: motion.main,\n  nav: motion.nav,\n  ol: motion.ol,\n  p: motion.p,\n  pre: motion.pre,\n  section: motion.section,\n  small: motion.small,\n  span: motion.span,\n  strong: motion.strong,\n  ul: motion.ul,\n};\n\ntype MotionElementTag = keyof typeof MOTION_ELEMENTS;\n\nfunction isMotionElementTag(tag: unknown): tag is MotionElementTag {\n  const isString = typeof tag === 'string';\n  return isString && tag in MOTION_ELEMENTS;\n}\n\n/**\n * The motion version of an HTML tag. A lookup such as `motion[tag]` is invisible to the bundler,\n * which drops the tags it never sees and breaks the production build, so every tag is listed here.\n */\nexport function motionElementOf(tag: unknown) {\n  if (isMotionElementTag(tag)) {\n    return MOTION_ELEMENTS[tag];\n  }\n  return MOTION_ELEMENTS.div;\n}\n",
      "type": "registry:component",
      "target": "components/core/motion-elements.ts"
    }
  ],
  "categories": [
    "motion"
  ],
  "type": "registry:component"
}