{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "label",
  "type": "registry:ui",
  "title": "Label",
  "description": "Displays an accessible label associated with controls.",
  "author": "Ahdeetai <https://aditya.is-cool.dev>",
  "registryDependencies": [],
  "dependencies": ["motion", "@radix-ui/react-label", "clsx", "tailwind-merge"],
  "files": [
    {
      "type": "registry:ui",
      "path": "components/ui/label.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { motion, useInView, HTMLMotionProps } from 'motion/react';\nimport { cn } from '@/lib/utils';\n\ninterface LabelProps extends Omit<HTMLMotionProps<'label'>, 'direction'> {\n  direction?: 'left' | 'right' | 'top' | 'bottom';\n  disableAnimation?: boolean;\n}\n\nfunction mergeRefs<T>(\n  ...refs: Array<React.Ref<T> | undefined>\n): React.RefCallback<T> {\n  return (value) => {\n    refs.forEach((ref) => {\n      if (!ref) return;\n      if (typeof ref === 'function') ref(value);\n      else (ref as React.MutableRefObject<T | null>).current = value;\n    });\n  };\n}\n\nconst Label = React.forwardRef<HTMLLabelElement, LabelProps>(\n  ({ direction = 'left', disableAnimation, className, ...props }, ref) => {\n    const localRef = React.useRef<HTMLLabelElement>(null);\n    const isInView = useInView(localRef, { once: false, margin: '-50px' });\n\n    const variants = {\n      left: { initial: { x: -20 }, animate: { x: 0 } },\n      right: { initial: { x: 20 }, animate: { x: 0 } },\n      top: { initial: { y: -20 }, animate: { y: 0 } },\n      bottom: { initial: { y: 20 }, animate: { y: 0 } },\n    };\n\n    const baseClasses = cn(\n      'flex items-center gap-2 text-sm leading-none font-medium select-none user-select-none',\n      'peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n      className,\n    );\n\n    if (disableAnimation) {\n      return (\n        <motion.label\n          ref={mergeRefs(ref, localRef)}\n          className={baseClasses}\n          {...props}\n        />\n      );\n    }\n\n    return (\n      <motion.label\n        ref={mergeRefs(ref, localRef)}\n        initial={variants[direction].initial}\n        animate={\n          isInView ? variants[direction].animate : variants[direction].initial\n        }\n        transition={{ duration: 0.4, ease: 'easeOut' }}\n        className={baseClasses}\n        {...props}\n      />\n    );\n  },\n);\n\nLabel.displayName = 'Label';\n\nexport { Label };\n"
    },
    {
      "type": "registry:lib",
      "path": "lib/utils.ts",
      "content": "import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}"
    }
  ]
}
