{"name":"shared-layout-bg","type":"registry:component","files":[{"path":"shared-layout-bg.tsx","type":"registry:component","target":"components/animated/shared-layout-bg.tsx","content":"\"use client\";\n\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n  type Variants,\n} from \"motion/react\";\nimport {\n  Children,\n  cloneElement,\n  isValidElement,\n  useId,\n  useState,\n  type ReactElement,\n  type ReactNode,\n} from \"react\";\nimport { SPRING_LAYOUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SharedLayoutBgProps {\n  children: ReactNode;\n  className?: string;\n  /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n  pillClassName?: string;\n  /** Horizontal inset of the pill relative to each row (px). Default 20. */\n  inset?: number;\n}\n\nconst variants: Variants = {\n  initial: { opacity: 0, filter: \"blur(6px)\" },\n  animate: { opacity: 1, filter: \"blur(0px)\" },\n  exit: (isActive: boolean) =>\n    !isActive ? { opacity: 0, filter: \"blur(6px)\" } : {},\n};\n\nconst reducedVariants: Variants = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport function SharedLayoutBg({\n  children,\n  className,\n  pillClassName,\n  inset = 20,\n}: SharedLayoutBgProps) {\n  const [activeId, setActiveId] = useState<string | null>(null);\n  const uid = useId();\n  const reduce = useReducedMotion();\n\n  return (\n    // layoutRoot scopes the pill's layout projection to this list, so fixed or\n    // scrolled ancestors can't smear scroll offsets into its movement.\n    <motion.div\n      layoutRoot\n      onMouseLeave={() => setActiveId(null)}\n      className={cn(\"flex w-full flex-col\", className)}\n    >\n      {Children.toArray(children)\n        .filter(isValidElement)\n        .map((child, index) => {\n          const el = child as ReactElement<{ className?: string; onMouseEnter?: () => void; children?: ReactNode }>;\n          const childKey = el.key ? String(el.key) : `item-${index}`;\n          return cloneElement(\n            el,\n            {\n              key: childKey,\n              className: cn(\"relative\", el.props.className),\n              onMouseEnter: () => setActiveId(childKey),\n            },\n            <>\n              <AnimatePresence custom={activeId !== null}>\n                {activeId !== null ? (\n                  <motion.div\n                    variants={reduce ? reducedVariants : variants}\n                    initial=\"initial\"\n                    animate=\"animate\"\n                    exit=\"exit\"\n                    custom={activeId !== null}\n                    className=\"pointer-events-none absolute inset-y-0\"\n                    style={{ left: -inset, right: -inset }}\n                  >\n                    {activeId === childKey ? (\n                      <motion.div\n                        layoutId={`shared-bg-${uid}`}\n                        transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n                        className={cn(\n                          \"pointer-events-none h-full w-full rounded-2xl bg-primary/[0.06]\",\n                          pillClassName,\n                        )}\n                      />\n                    ) : null}\n                  </motion.div>\n                ) : null}\n              </AnimatePresence>\n              <div className=\"relative z-10\">{el.props.children}</div>\n            </>\n          );\n        })}\n    </motion.div>\n  );\n}\n"}],"dependencies":["motion"],"registryDependencies":["https://www.honestui.com/r/ease.json"]}