import { AlertTriangle, Info, Lightbulb, type LucideIcon } from "lucide-react"; import type { ReactNode } from "react"; import { DEFAULT_CALLOUT_KIND, normalizeCalloutKind, type CalloutKind } from "@/shared/editor/schema/callout-model"; import { bidAttribute, type BlockIdentityProps } from "./attrs"; interface CalloutKindMeta { label: string; Icon: LucideIcon; } export const CALLOUT_KIND_META: Record = { info: { label: "Info", Icon: Info }, tip: { label: "Tip", Icon: Lightbulb }, warning: { label: "Warning", Icon: AlertTriangle }, }; export interface CalloutKindContentProps { kind: unknown; } export function getCalloutKindMeta(kind: unknown): CalloutKindMeta { return CALLOUT_KIND_META[normalizeCalloutKind(kind)] ?? CALLOUT_KIND_META[DEFAULT_CALLOUT_KIND]; } export function CalloutKindContent({ kind }: CalloutKindContentProps) { const { Icon, label } = getCalloutKindMeta(kind); return ( <> {label} ); } export interface CalloutPresentationProps extends BlockIdentityProps { kind: unknown; controls?: ReactNode; readOnly?: boolean; children?: ReactNode; } export function CalloutPresentation({ bid, kind, controls, readOnly = false, children }: CalloutPresentationProps) { const normalizedKind = normalizeCalloutKind(kind); return (
{controls ?? (
)}
{children}
); }