{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "select",
  "type": "registry:ui",
  "title": "Select",
  "description": "Displays an animated list of options for the user to choose from —smoothly triggered by a button.",
  "author": "Ahdeetai <https://aditya.is-cool.dev>",
  "registryDependencies": [],
  "dependencies": ["motion", "radix-ui", "clsx", "tailwind-merge"],
  "files": [
    {
      "type": "registry:ui",
      "path": "components/ui/select.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { Select as SelectPrimitive } from 'radix-ui';\nimport { cn } from '@/lib/utils';\nimport { ChevronDownIcon, CheckIcon, ChevronUpIcon } from 'lucide-react';\nimport { motion, AnimatePresence, Variants } from 'motion/react';\n\nconst selectVariants: Variants = {\n  hidden: {\n    opacity: 0,\n    y: -10,\n  },\n  visible: {\n    opacity: 1,\n    y: 0,\n    transition: {\n      type: 'spring' as const,\n      stiffness: 260,\n      damping: 15,\n    },\n  },\n  exit: {\n    opacity: 0,\n    y: -10,\n    transition: {\n      duration: 0.2,\n    },\n  },\n};\n\nconst itemVariants: Variants = {\n  hidden: {\n    opacity: 0,\n  },\n  visible: (i: number) => ({\n    opacity: 1,\n    transition: {\n      delay: i * 0.05,\n      duration: 0.2,\n    },\n  }),\n  exit: {\n    opacity: 0,\n    transition: {\n      duration: 0.1,\n    },\n  },\n};\n\nconst useMobile = () => {\n  const [isMobile, setIsMobile] = useState(false);\n\n  useEffect(() => {\n    const checkIfMobile = () => {\n      setIsMobile(\n        window.innerWidth < 768 ||\n          /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(\n            navigator.userAgent,\n          ),\n      );\n    };\n\n    checkIfMobile();\n    window.addEventListener('resize', checkIfMobile);\n\n    return () => {\n      window.removeEventListener('resize', checkIfMobile);\n    };\n  }, []);\n\n  return isMobile;\n};\n\nconst SelectContext = React.createContext<{ animate: boolean }>({\n  animate: true,\n});\n\nfunction Select({\n  animate = true,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Root> & {\n  animate?: boolean;\n}) {\n  return (\n    <SelectContext.Provider value={{ animate }}>\n      <SelectPrimitive.Root data-slot='select' {...props} />\n    </SelectContext.Provider>\n  );\n}\n\nfunction SelectGroup({\n  className,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n  return (\n    <SelectPrimitive.Group\n      data-slot='select-group'\n      className={cn('scroll-my-1 p-1', className)}\n      {...props}\n    />\n  );\n}\n\nfunction SelectValue({\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n  return <SelectPrimitive.Value data-slot='select-value' {...props} />;\n}\n\nfunction SelectTrigger({\n  className,\n  size = 'default',\n  children,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n  size?: 'sm' | 'default';\n}) {\n  const { animate } = React.useContext(SelectContext);\n  const isMobile = useMobile();\n\n  return (\n    <SelectPrimitive.Trigger\n      data-slot='select-trigger'\n      data-size={size}\n      className={cn(\n        \"border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-lg border bg-transparent py-2 pr-2 pl-2.5 text-sm transition-colors select-none focus-visible:ring-3 aria-invalid:ring-3 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-4 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0\",\n        className,\n      )}\n      asChild={animate && !isMobile}\n      {...props}\n    >\n      {animate && !isMobile ? (\n        <motion.button\n          whileHover={{ scale: 1.02 }}\n          whileTap={{ scale: 0.98 }}\n          transition={{ type: 'spring', stiffness: 400, damping: 25 }}\n          style={{ touchAction: 'manipulation' }}\n        >\n          {children}\n          <SelectPrimitive.Icon asChild>\n            <ChevronDownIcon className='text-muted-foreground size-4 pointer-events-none' />\n          </SelectPrimitive.Icon>\n        </motion.button>\n      ) : (\n        <>\n          {children}\n          <SelectPrimitive.Icon asChild>\n            <ChevronDownIcon className='text-muted-foreground size-4 pointer-events-none' />\n          </SelectPrimitive.Icon>\n        </>\n      )}\n    </SelectPrimitive.Trigger>\n  );\n}\n\nfunction SelectContent({\n  className,\n  children,\n  position = 'item-aligned',\n  align = 'center',\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Content>) {\n  const { animate } = React.useContext(SelectContext);\n  const isMobile = useMobile();\n\n  return (\n    <SelectPrimitive.Portal>\n      <SelectPrimitive.Content\n        data-slot='select-content'\n        data-align-trigger={position === 'item-aligned'}\n        className={cn(\n          'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-36 rounded-lg shadow-md ring-1 duration-100 relative z-50 max-h-(--radix-select-content-available-height) origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto data-[align-trigger=true]:animate-none',\n          position === 'popper' &&\n            'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n          className,\n        )}\n        position={position}\n        align={align}\n        asChild={animate && !isMobile}\n        {...props}\n      >\n        {animate && !isMobile ? (\n          <motion.div\n            variants={selectVariants}\n            initial='hidden'\n            animate='visible'\n            exit='exit'\n            style={{\n              transformOrigin: 'var(--radix-select-content-transform-origin)',\n            }}\n          >\n            <SelectScrollUpButton />\n            <SelectPrimitive.Viewport\n              data-position={position}\n              className={cn(\n                'data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)',\n                position === 'popper' && '',\n              )}\n            >\n              {React.Children.map(children, (child, index) => (\n                <motion.div\n                  key={index}\n                  custom={index}\n                  variants={itemVariants}\n                  initial='hidden'\n                  animate='visible'\n                  exit='exit'\n                >\n                  {child}\n                </motion.div>\n              ))}\n            </SelectPrimitive.Viewport>\n            <SelectScrollDownButton />\n          </motion.div>\n        ) : (\n          <>\n            <SelectScrollUpButton />\n            <SelectPrimitive.Viewport\n              data-position={position}\n              className={cn(\n                'data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)',\n                position === 'popper' && '',\n              )}\n            >\n              {children}\n            </SelectPrimitive.Viewport>\n            <SelectScrollDownButton />\n          </>\n        )}\n      </SelectPrimitive.Content>\n    </SelectPrimitive.Portal>\n  );\n}\n\nfunction SelectLabel({\n  className,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Label>) {\n  return (\n    <SelectPrimitive.Label\n      data-slot='select-label'\n      className={cn('text-muted-foreground px-1.5 py-1 text-xs', className)}\n      {...props}\n    />\n  );\n}\n\nfunction SelectItem({\n  className,\n  children,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n  const [isHovered, setIsHovered] = useState(false);\n  const isMobile = useMobile();\n  const { animate } = React.useContext(SelectContext);\n\n  if (!animate || isMobile) {\n    return (\n      <SelectPrimitive.Item\n        data-slot='select-item'\n        className={cn(\n          \"focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0\",\n          className,\n        )}\n        {...props}\n      >\n        <span className='pointer-events-none absolute right-2 flex size-4 items-center justify-center'>\n          <SelectPrimitive.ItemIndicator>\n            <CheckIcon className='pointer-events-none' />\n          </SelectPrimitive.ItemIndicator>\n        </span>\n        <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n      </SelectPrimitive.Item>\n    );\n  }\n\n  return (\n    <SelectPrimitive.Item\n      data-slot='select-item'\n      className={cn(\n        \"not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0\",\n        className,\n      )}\n      onMouseEnter={() => setIsHovered(true)}\n      onMouseLeave={() => setIsHovered(false)}\n      style={{ touchAction: 'manipulation' }}\n      {...props}\n    >\n      <AnimatePresence>\n        {isHovered && (\n          <motion.div\n            layoutId='selectHoverBackground'\n            initial={{ opacity: 0 }}\n            animate={{\n              opacity: 1,\n              transition: {\n                type: 'spring',\n                stiffness: 260,\n                damping: 15,\n              },\n            }}\n            exit={{ opacity: 0 }}\n            className='absolute inset-0 rounded-md bg-accent'\n          />\n        )}\n      </AnimatePresence>\n\n      <span className='pointer-events-none absolute right-2 flex size-4 items-center justify-center z-10'>\n        <SelectPrimitive.ItemIndicator>\n          <motion.div\n            initial={{ scale: 0 }}\n            animate={{ scale: 1 }}\n            transition={{ type: 'spring', stiffness: 400, damping: 25 }}\n          >\n            <CheckIcon className='pointer-events-none' />\n          </motion.div>\n        </SelectPrimitive.ItemIndicator>\n      </span>\n      <SelectPrimitive.ItemText asChild>\n        <motion.span\n          animate={{\n            y: isHovered ? -1 : 0,\n            x: isHovered ? 1 : 0,\n          }}\n          transition={{ type: 'spring', stiffness: 500 }}\n          className='relative z-10'\n        >\n          {children}\n        </motion.span>\n      </SelectPrimitive.ItemText>\n    </SelectPrimitive.Item>\n  );\n}\n\nfunction SelectSeparator({\n  className,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.Separator>) {\n  const { animate } = React.useContext(SelectContext);\n  const isMobile = useMobile();\n\n  return animate && !isMobile ? (\n    <motion.div\n      initial={{ scaleX: 0, opacity: 0 }}\n      animate={{\n        scaleX: 1,\n        opacity: 1,\n        transition: {\n          delay: 0.1,\n          type: 'spring',\n          stiffness: 400,\n          damping: 25,\n        },\n      }}\n    >\n      <SelectPrimitive.Separator\n        data-slot='select-separator'\n        className={cn(\n          'bg-border -mx-1 my-1 h-px pointer-events-none',\n          className,\n        )}\n        {...props}\n      />\n    </motion.div>\n  ) : (\n    <SelectPrimitive.Separator\n      data-slot='select-separator'\n      className={cn('bg-border -mx-1 my-1 h-px pointer-events-none', className)}\n      {...props}\n    />\n  );\n}\n\nfunction SelectScrollUpButton({\n  className,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {\n  return (\n    <SelectPrimitive.ScrollUpButton\n      data-slot='select-scroll-up-button'\n      className={cn(\n        \"bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4\",\n        className,\n      )}\n      {...props}\n    >\n      <ChevronUpIcon />\n    </SelectPrimitive.ScrollUpButton>\n  );\n}\n\nfunction SelectScrollDownButton({\n  className,\n  ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {\n  return (\n    <SelectPrimitive.ScrollDownButton\n      data-slot='select-scroll-down-button'\n      className={cn(\n        \"bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4\",\n        className,\n      )}\n      {...props}\n    >\n      <ChevronDownIcon />\n    </SelectPrimitive.ScrollDownButton>\n  );\n}\n\nexport {\n  Select,\n  SelectContent,\n  SelectGroup,\n  SelectItem,\n  SelectLabel,\n  SelectScrollDownButton,\n  SelectScrollUpButton,\n  SelectSeparator,\n  SelectTrigger,\n  SelectValue,\n};\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}"
    }
  ]
}
