import * as React from "react" import Image from "next/image" import Link from "next/link" import { cn } from "cn" import { source } from "@/lib/source" import { Callout } from "@/components/callout" import { CodeBlockCommand } from "@/components/code-block-command" import { CodeCollapsibleWrapper } from "@/components/code-collapsible-wrapper" import { CodeTabs } from "@/components/code-tabs" import { ComponentPreview } from "@/components/component-preview" import { ComponentSource } from "@/components/component-source" import { ComponentsList } from "@/components/components-list" import { CopyButton } from "@/components/copy-button" import { DirectoryList } from "@/components/directory-list" import { getIconForLanguageExtension } from "@/components/icons" import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/registry/new-york-v4/ui/accordion" import { Alert, AlertDescription, AlertTitle, } from "@/registry/new-york-v4/ui/alert" import { AspectRatio } from "@/registry/new-york-v4/ui/aspect-ratio" import { Button } from "@/registry/new-york-v4/ui/button" import { Kbd } from "@/registry/new-york-v4/ui/kbd" import { Tabs, TabsContent, TabsList, TabsTrigger, } from "@/registry/new-york-v4/ui/tabs" function getComponentsFolder() { const componentsFolder = source.pageTree.children.find( (page) => page.$id === "components" ) if (componentsFolder?.type !== "folder") { return null } return componentsFolder } // This is only used on /docs/components/ index page, so default to base. function ComponentsListWrapper({ variant }: { variant?: "all" | "new" }) { const componentsFolder = getComponentsFolder() if (!componentsFolder) { return null } return ( ) } function getNodeText(node: React.ReactNode): string { if (typeof node === "string" || typeof node === "number") { return String(node) } if (Array.isArray(node)) { return node.map((child) => getNodeText(child)).join("") } if (React.isValidElement<{ children?: React.ReactNode }>(node)) { return getNodeText(node.props.children) } return "" } function getHeadingId(children: React.ReactNode) { const id = getNodeText(children) .trim() .replace(/\s+/g, "-") .replace(/'/g, "") .replace(/\?/g, "") .toLowerCase() return id || undefined } function HeadingAnchor({ id, children, }: { id?: string children: React.ReactNode }) { if (!id) { return children } return ( {children} ) } export const mdxComponents = { h1: ({ children, id, ...props }: React.ComponentProps<"h1">) => { const headingId = id ?? getHeadingId(children) return (

{children}

) }, h2: ({ children, id, ...props }: React.ComponentProps<"h2">) => { const headingId = id ?? getHeadingId(children) return (

{children}

) }, h3: ({ children, id, ...props }: React.ComponentProps<"h3">) => { const headingId = id ?? getHeadingId(children) return (

{children}

) }, h4: ({ children, id, ...props }: React.ComponentProps<"h4">) => { const headingId = id ?? getHeadingId(children) return (

{children}

) }, h5: ({ children, id, ...props }: React.ComponentProps<"h5">) => { const headingId = id ?? getHeadingId(children) return (
{children}
) }, h6: ({ children, id, ...props }: React.ComponentProps<"h6">) => { const headingId = id ?? getHeadingId(children) return (
{children}
) }, // Typeset tables stay real tables and wrap to fit; wrap them to scroll // wide ones horizontally instead. table: (props: React.ComponentProps<"table">) => (
), pre: ({ className, children, ...props }: React.ComponentProps<"pre">) => { return (
        {children}
      
) }, figcaption: ({ className, children, ...props }: React.ComponentProps<"figcaption">) => { const iconExtension = "data-language" in props && typeof props["data-language"] === "string" ? getIconForLanguageExtension(props["data-language"]) : null return (
{iconExtension} {children}
) }, code: ({ className, __raw__, __src__, __npm__, __yarn__, __pnpm__, __bun__, ...props }: React.ComponentProps<"code"> & { __raw__?: string __src__?: string __npm__?: string __yarn__?: string __pnpm__?: string __bun__?: string }) => { // Inline Code. if (typeof props.children === "string") { return } // npm command. const isNpmCommand = __npm__ && __yarn__ && __pnpm__ && __bun__ if (isNpmCommand) { return ( ) } // Default codeblock. return ( <> {__raw__ && } ) }, Step: (props: React.ComponentProps<"h3">) =>

, Steps: ({ className, ...props }: React.ComponentProps<"div">) => (
h3]:step", className )} {...props} /> ), Image: ({ src, className, width, height, alt, ...props }: React.ComponentProps<"img">) => ( ), Tabs: ({ className, ...props }: React.ComponentProps) => { return }, TabsList: ({ className, ...props }: React.ComponentProps) => ( ), TabsTrigger: ({ className, ...props }: React.ComponentProps) => ( ), TabsContent: ({ className, ...props }: React.ComponentProps) => ( .steps]:mt-6", className )} {...props} /> ), Tab: (props: React.ComponentProps<"div">) =>
, Button: ({ className, ...props }: React.ComponentProps) => (