import * as React from "react";
import Link from "next/link";
import { cn } from "@/lib/utils";
import { InlineCode } from "@/components/ui/code-block";
/**
* Prose primitives for the documentation. Implemented with plain Tailwind classes
* (no typography plugin) so the docs share the exact tokens used by the product.
*/
function textOf(node: React.ReactNode): string {
if (node == null || typeof node === "boolean") return "";
if (typeof node === "string" || typeof node === "number") return String(node);
if (Array.isArray(node)) return node.map(textOf).join("");
if (React.isValidElement<{ children?: React.ReactNode }>(node)) return textOf(node.props.children);
return "";
}
export function headingId(children: React.ReactNode, explicit?: string): string {
if (explicit) return explicit;
return (
textOf(children)
.normalize("NFD")
.replace(/[̀-ͯ]/g, "")
.toLowerCase()
.trim()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "")
.slice(0, 80) || "section"
);
}
function AnchorLink({ id }: { id: string }) {
return (
#
);
}
export function H2({ id, children, className }: { id?: string; children: React.ReactNode; className?: string }) {
const hid = headingId(children, id);
return (
{children}
);
}
export function H3({ id, children, className }: { id?: string; children: React.ReactNode; className?: string }) {
const hid = headingId(children, id);
return (
{children}
);
}
export function H4({ children, className }: { children: React.ReactNode; className?: string }) {
return {children}
;
}
export function P({ children, className }: { children: React.ReactNode; className?: string }) {
return {children}
;
}
export function Lead({ children, className }: { children: React.ReactNode; className?: string }) {
return {children}
;
}
export function Strong({ children }: { children: React.ReactNode }) {
return {children};
}
export function Ul({ children, className }: { children: React.ReactNode; className?: string }) {
return ;
}
export function Ol({ children, className }: { children: React.ReactNode; className?: string }) {
return {children}
;
}
export function Li({ children, className }: { children: React.ReactNode; className?: string }) {
return {children};
}
export function Code({ children }: { children: React.ReactNode }) {
return {children};
}
export function A({ href, children, className }: { href: string; children: React.ReactNode; className?: string }) {
const external = /^https?:\/\//.test(href) || href.startsWith("mailto:");
const cls = cn("font-medium text-accent underline decoration-accent/30 underline-offset-[3px] transition-colors hover:decoration-accent", className);
if (external) {
return (
{children}
);
}
return (
{children}
);
}
export function Kbd({ children }: { children: React.ReactNode }) {
return {children};
}
export function Hr() {
return
;
}
/* ---------------------------------------------------------------------------------------------- */
/* Tables */
/* ---------------------------------------------------------------------------------------------- */
export function Table({ children, className, dense }: { children: React.ReactNode; className?: string; dense?: boolean }) {
return (
);
}
export function THead({ children }: { children: React.ReactNode }) {
return {children};
}
export function TBody({ children }: { children: React.ReactNode }) {
return {children};
}
export function Tr({ children, className }: { children: React.ReactNode; className?: string }) {
return {children}
;
}
export function Th({ children, className }: { children?: React.ReactNode; className?: string }) {
return {children} | ;
}
export function Td({ children, className, mono }: { children?: React.ReactNode; className?: string; mono?: boolean }) {
return {children} | ;
}
/* ---------------------------------------------------------------------------------------------- */
/* Small layout helpers */
/* ---------------------------------------------------------------------------------------------- */
export function Steps({ children }: { children: React.ReactNode }) {
return {children}
;
}
export function Step({ title, children }: { title: React.ReactNode; children?: React.ReactNode }) {
return (
{title}
{children ? {children}
: null}
);
}
export function CardGrid({ children, className }: { children: React.ReactNode; className?: string }) {
return {children}
;
}
export function LinkCard({ href, title, description }: { href: string; title: string; description: string }) {
return (
{title}
→
{description}
);
}