"use client" import * as React from "react" import { editInV0 } from "@/actions/edit-in-v0" import { Loader2 } from "lucide-react" import { useFormStatus } from "react-dom" import { toast } from "sonner" import { cn } from "@/lib/utils" import { Button, ButtonProps } from "@/registry/new-york/ui/button" import { Tooltip, TooltipContent, TooltipTrigger, } from "@/registry/new-york/ui/tooltip" import { Style } from "@/registry/registry-styles" type Size = "default" | "icon" function V0Tooltip({ size, style = "default", children, }: React.PropsWithChildren<{ size: Size; style?: Style["name"] }>) { if (size === "default") { return <>{children} } return ( {style === "new-york" ? ( {children} ) : ( <>{children} )} {style === "new-york" ? ( <>Not available in New York ) : ( <>Open in v0 )} ) } export function V0Button({ name, size = "default", disabled, className, ...props }: { name: string size?: Size } & ButtonProps) { const [url, setUrl] = React.useState("https://ui.shadcn.com") React.useEffect(() => { setUrl(window.location.href) }, []) return (
{ try { const result = await editInV0({ name, url, }) if (result?.error) { throw new Error(result.error) } if (result?.url) { const popupOpened = window.open(result.url, "_blank") if (!popupOpened) { toast.warning("Pop-up window blocked.", { description: "Click the pop-up button in your browser to continue.", duration: 5000, }) } } } catch (error) { if (error instanceof Error) { toast.error(error.message) } } }} >
) } function Form({ disabled, size = "default", className, ...props }: Omit, "name">) { const { pending } = useFormStatus() return ( ) } export function V0Logo({ className, ...props }: React.ComponentProps<"svg">) { return ( ) }