{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "loading-button-dependencies",
  "title": "Loading Button Dependencies",
  "description": "component for the Loading Button Dependencies",
  "dependencies": [
    "@radix-ui/react-slot",
    "class-variance-authority",
    "lucide-react"
  ],
  "files": [
    {
      "path": "app/registry/spectrumui/loading-button-dependencies.tsx",
      "content": "import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"@/lib/utils\";\nimport { Loader2 } from \"lucide-react\";\n\nconst buttonVariants = cva(\n  \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n        destructive:\n          \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n        outline:\n          \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n        secondary:\n          \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n        ghost: \"hover:bg-accent hover:text-accent-foreground\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n      size: {\n        default: \"h-10 px-4 py-2\",\n        sm: \"h-9 rounded-md px-3\",\n        lg: \"h-11 rounded-md px-8\",\n        icon: \"h-10 w-10\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      size: \"default\",\n    },\n  },\n);\n\nexport interface ButtonProps\n  extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n    VariantProps<typeof buttonVariants> {\n  asChild?: boolean;\n  loading?: boolean;\n}\n\nconst LoadingButton = React.forwardRef<HTMLButtonElement, ButtonProps>(\n  (\n    { className, variant, size, asChild = false, loading, children, ...props },\n    ref,\n  ) => {\n    if (asChild) {\n      return (\n        <Slot ref={ref} {...props}>\n          <>\n            {React.Children.map(\n              children as React.ReactElement<{ className?: string; children?: React.ReactNode }>,\n              (child: React.ReactElement<{ className?: string; children?: React.ReactNode }>) => {\n                return React.cloneElement(child, {\n                  className: cn(buttonVariants({ variant, size }), className),\n                  children: (\n                    <>\n                      {loading && (\n                        <Loader2\n                          className={cn(\n                            \"h-4 w-4 animate-spin\",\n                            children && \"mr-2\",\n                          )}\n                        />\n                      )}\n                      {child.props.children}\n                    </>\n                  ),\n                });\n              },\n            )}\n          </>\n        </Slot>\n      );\n    }\n\n    return (\n      <button\n        className={cn(buttonVariants({ variant, size, className }))}\n        disabled={loading}\n        ref={ref}\n        {...props}\n      >\n        <>\n          {loading && (\n            <Loader2\n              className={cn(\"h-4 w-4 animate-spin\", children && \"mr-2\")}\n            />\n          )}\n          {children}\n        </>\n      </button>\n    );\n  },\n);\nLoadingButton.displayName = \"LoadingButton\";\n\nexport { LoadingButton, buttonVariants };\n",
      "type": "registry:component",
      "target": "components/spectrumui/loading-button-dependencies.tsx"
    }
  ],
  "type": "registry:component"
}
