"use client";
import type { ComponentType, PropsWithChildren } from "react";
/**
* The component allowlist passed to ``.
* The agent's JSON spec can reference any of these by name.
*/
export const UnknownComponentFallback = ({
component,
}: {
component: string;
}) => (
unknown component: {component}
);
const Card: ComponentType<
PropsWithChildren<{ title?: string; description?: string }>
> = ({ title, description, children }) => (
{title ?
{title}
: null}
{description ? (
{description}
) : null}
{children ?
{children}
: null}
);
const Button: ComponentType<
PropsWithChildren<{
label?: string;
variant?: "primary" | "secondary";
onClickPrompt?: string;
}>
> = ({ label, variant = "primary", onClickPrompt, children }) => {
const cls =
variant === "primary"
? "bg-primary text-primary-foreground hover:bg-primary/90"
: "bg-secondary text-secondary-foreground hover:bg-secondary/80";
return (
);
};
const Stack: ComponentType<
PropsWithChildren<{ gap?: "sm" | "md" | "lg"; direction?: "row" | "column" }>
> = ({ gap = "md", direction = "column", children }) => {
const gapClass = gap === "sm" ? "gap-2" : gap === "lg" ? "gap-6" : "gap-4";
const dirClass = direction === "row" ? "flex-row" : "flex-col";
return {children}
;
};
const Heading: ComponentType<
PropsWithChildren<{ level?: 1 | 2 | 3; children?: React.ReactNode }>
> = ({ level = 2, children }) => {
const cls =
level === 1
? "text-2xl font-bold"
: level === 2
? "text-lg font-semibold"
: "text-base font-semibold";
const Tag = `h${level}` as keyof React.JSX.IntrinsicElements;
return {children};
};
const Text: ComponentType = ({ children }) => (
{children}
);
const Stat: ComponentType<{ label: string; value: string | number }> = ({
label,
value,
}) => (
{label}
{value}
);
export const componentsAllowlist = {
Card,
Button,
Stack,
Heading,
Text,
Stat,
} as const;