"use client"; import { useEffect, useMemo, useState } from "react"; import { buildPrompt } from "../lib/prompt"; import { Doc, Palette, Platform, defaultPlatformOf } from "../lib/tokens"; import { Icon } from "./M3Node"; import { Field, IconBtn, Segmented } from "./ui"; import { t, useLang } from "../lib/i18n"; export function PromptPanel({ doc, widths, palette: p, onDoc, }: { doc: Doc; widths: Record; palette: Palette; onDoc: (patch: Partial) => void; }) { const lang = useLang(); const generated = useMemo(() => buildPrompt(doc, widths, undefined, lang), [doc, widths, lang]); const edited = doc.promptEdit !== undefined; const text = edited ? doc.promptEdit! : generated; const [copied, setCopied] = useState(false); useEffect(() => { if (!copied) return; const t = setTimeout(() => setCopied(false), 1400); return () => clearTimeout(t); }, [copied]); const copy = async () => { try { await navigator.clipboard.writeText(text); setCopied(true); } catch {} }; const projectButton = (icon: string, label: string, onClick: () => void) => ( ); return (
onDoc({ title })} placeholder={t("appName", lang)} p={p} icon="smartphone" /> onDoc({ brief })} placeholder={t("brief", lang)} p={p} icon="lightbulb" multiline rows={3} /> options={[ { key: "android", icon: "android", label: "Android", title: t("targetAndroid", lang) }, { key: "web", icon: "language", label: "Web", title: t("targetWeb", lang) }, ]} value={doc.platform ?? defaultPlatformOf(doc.frames, doc.frame)} onChange={(platform) => onDoc({ platform })} p={p} height={40} />