{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "link",
  "title": "Link",
  "description": "A link provider that makes every primitive render your router's link, for client-side navigation, with plain anchors as the default.",
  "files": [
    {
      "path": "registry/components/dashboardblocks/link.tsx",
      "content": "'use client'\n\nimport {\n  type ComponentProps,\n  type ComponentType,\n  createContext,\n  createElement,\n  type ReactNode,\n  useContext,\n} from 'react'\n\ntype LinkProps = ComponentProps<'a'> & { href: string }\n\n/** A link that takes anchor props with a string `href`, such as Next.js's `Link`. */\ntype LinkComponent = ComponentType<LinkProps>\n\nconst LinkContext = createContext<LinkComponent | 'a'>('a')\n\nconst NavigateContext = createContext<((href: string) => void) | undefined>(undefined)\n\ninterface LinkProviderProps {\n  children: ReactNode\n  component: LinkComponent\n  /** Opens an in-app href with your router, for links that must not prefetch, such as one a model wrote. Leave out for a full page load. */\n  navigate?: (href: string) => void\n}\n\nfunction LinkProvider({ children, component, navigate }: LinkProviderProps) {\n  return (\n    <LinkContext.Provider value={component}>\n      <NavigateContext.Provider value={navigate}>{children}</NavigateContext.Provider>\n    </LinkContext.Provider>\n  )\n}\n\n/** The router's `navigate` from `LinkProvider`, if it has one. */\nfunction useLinkNavigate() {\n  return useContext(NavigateContext)\n}\n\n/** A primary click with no modifier key, which opens a link in place rather than in a new tab or window. */\nfunction isPlainClick(\n  event: Pick<MouseEvent, 'altKey' | 'button' | 'ctrlKey' | 'metaKey' | 'shiftKey'>,\n) {\n  return (\n    event.button === 0 &&\n    !event.metaKey &&\n    !event.ctrlKey &&\n    !event.shiftKey &&\n    !event.altKey\n  )\n}\n\nfunction Link({ children, href, ...props }: Omit<LinkProps, 'href'> & { href?: string }) {\n  const Component = useContext(LinkContext)\n  if (href === undefined) return <a {...props}>{children}</a>\n  // Not JSX: eslint-plugin-react-hooks reads a component from context as one created during render (static-components), though it's the same one on every render.\n  return createElement(Component, { href, ...props }, children)\n}\n\nexport { isPlainClick, Link, LinkProvider, useLinkNavigate }\n\nexport type { LinkComponent, LinkProps, LinkProviderProps }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/link.tsx"
    }
  ],
  "type": "registry:component"
}
