diff --git a/apps/v4/public/r/styles/new-york-v4/tooltip.json b/apps/v4/public/r/styles/new-york-v4/tooltip.json index 8aee6d9f8c4..3c225769497 100644 --- a/apps/v4/public/r/styles/new-york-v4/tooltip.json +++ b/apps/v4/public/r/styles/new-york-v4/tooltip.json @@ -8,7 +8,7 @@ "files": [ { "path": "registry/new-york-v4/ui/tooltip.tsx", - "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps) {\n return (\n \n )\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps) {\n return (\n \n \n \n )\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps) {\n return \n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps) {\n return (\n \n \n {children}\n \n \n \n )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\n", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps) {\n return (\n \n )\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps) {\n return (\n \n \n \n )\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps) {\n return \n}\n\n//extend props to include hideArrow\ntype TooltipContentProps = React.ComponentProps<\n typeof TooltipPrimitive.Content\n> & {\n hideArrow?: boolean\n}\n\nfunction TooltipContent({\n className,\n children,\n\n //new hideArrow prop with default = false\n hideArrow = false,\n\n //remove default value (we’ll compute it below)\n sideOffset,\n\n ...props\n}: TooltipContentProps) {\n // compute sideOffset based on hideArrow logic\n const sideOffsetValue =\n typeof sideOffset === \"number\"\n ? sideOffset\n : hideArrow\n ? 4 // when hiding arrow, default spacing\n : 0 // default offset when arrow exists\n\n return (\n \n \n {children}\n\n {/*only render arrow if hideArrow is false */}\n {!hideArrow ? (\n \n ) : null}\n \n \n )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\n", "type": "registry:ui" } ] diff --git a/apps/v4/registry/new-york-v4/ui/tooltip.tsx b/apps/v4/registry/new-york-v4/ui/tooltip.tsx index a4e90d4e9af..6798958abe6 100644 --- a/apps/v4/registry/new-york-v4/ui/tooltip.tsx +++ b/apps/v4/registry/new-york-v4/ui/tooltip.tsx @@ -34,17 +34,39 @@ function TooltipTrigger({ return } +//extend props to include hideArrow +type TooltipContentProps = React.ComponentProps< + typeof TooltipPrimitive.Content +> & { + hideArrow?: boolean +} + function TooltipContent({ className, - sideOffset = 0, children, + + //new hideArrow prop with default = false + hideArrow = false, + + //remove default value (we’ll compute it below) + sideOffset, + ...props -}: React.ComponentProps) { +}: TooltipContentProps) { + // compute sideOffset based on hideArrow logic + const sideOffsetValue = + typeof sideOffset === "number" + ? sideOffset + : hideArrow + ? 4 // when hiding arrow, default spacing + : 0 // default offset when arrow exists + return ( {children} - + + {/*only render arrow if hideArrow is false */} + {!hideArrow ? ( + + ) : null} )