@particle-academy/react-fancy 5.38.0 → 5.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/dist/{index-CazpqSsk.d.cts → Composer.types-CuSPnaOt.d.cts} +1 -4
- package/dist/{index-CazpqSsk.d.ts → Composer.types-CuSPnaOt.d.ts} +1 -4
- package/dist/{chunk-Z4GO6N6N.js → chunk-2JOWGYAJ.js} +322 -408
- package/dist/chunk-2JOWGYAJ.js.map +1 -0
- package/dist/{chunk-RYKPYILS.cjs → chunk-6TZPM43Q.cjs} +325 -408
- package/dist/chunk-6TZPM43Q.cjs.map +1 -0
- package/dist/chunk-BZOU7VJQ.cjs +231 -0
- package/dist/chunk-BZOU7VJQ.cjs.map +1 -0
- package/dist/{chunk-QLL7MWAU.cjs → chunk-FJ2GMQLC.cjs} +116 -26
- package/dist/chunk-FJ2GMQLC.cjs.map +1 -0
- package/dist/chunk-MXAVGOHW.js +229 -0
- package/dist/chunk-MXAVGOHW.js.map +1 -0
- package/dist/{chunk-WUV3XDJH.js → chunk-YLPVTEUH.js} +117 -27
- package/dist/chunk-YLPVTEUH.js.map +1 -0
- package/dist/composer.cjs +4 -3
- package/dist/composer.d.cts +7 -2
- package/dist/composer.d.ts +7 -2
- package/dist/composer.js +2 -1
- package/dist/{index-DXUAAZzE.d.ts → index-BsIBOwaK.d.cts} +46 -1
- package/dist/{index-DXUAAZzE.d.cts → index-S4FC1yFK.d.ts} +46 -1
- package/dist/index.cjs +10 -9
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/prompt-input.cjs +4 -2
- package/dist/prompt-input.d.cts +2 -1
- package/dist/prompt-input.d.ts +2 -1
- package/dist/prompt-input.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-QLL7MWAU.cjs.map +0 -1
- package/dist/chunk-RYKPYILS.cjs.map +0 -1
- package/dist/chunk-WUV3XDJH.js.map +0 -1
- package/dist/chunk-Z4GO6N6N.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/platform.ts","../src/components/PromptInput/PromptInput.tsx"],"names":["useState","useRef","useInlinePaste","useEffect","useMemo","jsxs","cn","jsx","Icon","Fragment","InlinePasteEditor","Tooltip","Button"],"mappings":";;;;;;;;;;;AA2CA,IAAM,0CAA0B,IAAI,GAAA,CAAI,CAAC,OAAA,EAAS,KAAA,EAAO,QAAQ,CAAC,CAAA;AAOlE,IAAM,eAAA,GAAkB,4CAAA;AAGjB,SAAS,eAAe,KAAA,EAA6C;AAC1E,EAAA,IAAI,CAAC,OAAO,OAAO,SAAA;AAEnB,EAAA,MAAM,MAAA,GAAS,MAAM,aAAA,EAAe,QAAA;AACpC,EAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,CAAO,SAAS,CAAA,EAAG;AAInD,IAAA,OAAO,uBAAA,CAAwB,IAAI,MAAA,CAAO,IAAA,GAAO,WAAA,EAAa,IAAI,OAAA,GAAU,SAAA;AAAA,EAC9E;AAEA,EAAA,KAAA,MAAW,SAAS,CAAC,KAAA,CAAM,QAAA,EAAU,KAAA,CAAM,SAAS,CAAA,EAAG;AACrD,IAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,gBAAgB,IAAA,CAAK,KAAK,GAAG,OAAO,OAAA;AAAA,EACvE;AAEA,EAAA,OAAO,SAAA;AACT;AASO,SAAS,iBAAiB,QAAA,EAAuC;AACtE,EAAA,OAAO,QAAA,KAAa,UAAU,QAAA,GAAM,MAAA;AACtC;AAGO,SAAS,oBAAA,GAA6C;AAC3D,EAAA,IAAI,OAAO,SAAA,KAAc,WAAA,EAAa,OAAO,IAAA;AAC7C,EAAA,OAAO,SAAA;AACT;ACqFA,IAAM,qBAAA,GAAgD;AAAA,EACpD,KAAA,EAAO,SAAA;AAAA,EACP,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ;A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AAA,IAAI,CAAA,GAAI,IAAA,EAAM,OAAO,CAAA,EAAG,CAAC,CAAA,EAAA,CAAA;AACzB,EAAA,IAAI,CAAA,GAAI,OAAO,IAAA,EAAM,OAAO,IAAI,CAAA,GAAI,IAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA,CAAA;AACpD,EAAA,OAAO,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA,CAAA;AACxC","file":"chunk-FJ2GMQLC.cjs","sourcesContent":["/**\n * Which modifier key the user actually has.\n *\n * This exists because a keyboard hint is a CLAIM about the reader's hardware.\n * `⌘ + Enter to send` on Windows or Linux names a key that is not on the\n * keyboard, and a reader who cannot act on a hint learns to ignore hints — so\n * the cost is not one wrong glyph, it is the credibility of every hint beside\n * it. (Reported from a real Electron app running on Linux, where the glyph had\n * no font behind it either and rendered as tofu.)\n *\n * Two deliberate choices:\n *\n * 1. **The platform is an ARGUMENT, never a global read.** `detectPlatform`\n * takes the hints; `modifierKeyLabel` takes the verdict. Both branches are\n * therefore reachable from one machine, which is the only way a test can\n * cover the platform you are not sitting at. A function that reads\n * `navigator` internally can only ever be tested on the developer's own OS.\n * 2. **`generic` is the fallback, and that is not arbitrary.** Every Fancy\n * surface that submits on a modifier accepts `metaKey || ctrlKey`, so\n * `Ctrl` is a TRUE label on an Apple keyboard while `⌘` is a FALSE one\n * everywhere else. The honest default is the one that is pressable on all\n * of them.\n */\nexport type FancyPlatform = \"apple\" | \"generic\";\n\n/**\n * The parts of `navigator` the detection reads — nothing more, so a caller can\n * hand it a literal (a test, an Electron main process forwarding `process.platform`,\n * a server with a stored preference).\n */\nexport interface PlatformHints {\n /** `navigator.userAgentData` — the modern, non-spoofed answer where it exists. */\n userAgentData?: { platform?: string } | null;\n /** `navigator.platform` — deprecated, still the most reliable legacy signal. */\n platform?: string | null;\n /** `navigator.userAgent` — last resort. */\n userAgent?: string | null;\n}\n\n/**\n * `userAgentData.platform` is a short enumerated token (\"macOS\", \"Windows\",\n * \"Linux\", \"Android\", \"iOS\"), so it is matched exactly rather than by substring.\n */\nconst APPLE_UA_DATA_PLATFORMS = new Set([\"macos\", \"ios\", \"ipados\"]);\n\n/**\n * Legacy `platform` / `userAgent` are free text. iPadOS reports `MacIntel`, and\n * iOS user agents say \"like Mac OS X\" — both are Apple, so a Mac match is\n * correct for them too.\n */\nconst APPLE_FREE_TEXT = /\\b(mac|macintosh|iphone|ipad|ipod|darwin)/i;\n\n/** Resolve a platform from navigator-shaped hints. Unknown or absent ⇒ `generic`. */\nexport function detectPlatform(hints?: PlatformHints | null): FancyPlatform {\n if (!hints) return \"generic\";\n\n const uaData = hints.userAgentData?.platform;\n if (typeof uaData === \"string\" && uaData.length > 0) {\n // When the browser gives an enumerated answer, TRUST IT and stop. Falling\n // through to the free-text test would let a Windows UA string containing\n // the word \"Mac\" (a font name, a device model) overturn it.\n return APPLE_UA_DATA_PLATFORMS.has(uaData.trim().toLowerCase()) ? \"apple\" : \"generic\";\n }\n\n for (const value of [hints.platform, hints.userAgent]) {\n if (typeof value === \"string\" && APPLE_FREE_TEXT.test(value)) return \"apple\";\n }\n\n return \"generic\";\n}\n\n/**\n * The modifier key to NAME for a platform.\n *\n * `⌘` is emitted for `apple` and nothing else. A test enumerates the platform\n * values and counts that no other one can produce it, because a hint that names\n * the wrong key is worse than no hint.\n */\nexport function modifierKeyLabel(platform: FancyPlatform): \"⌘\" | \"Ctrl\" {\n return platform === \"apple\" ? \"⌘\" : \"Ctrl\";\n}\n\n/** SSR-safe read of the live browser hints. `null` off a browser. */\nexport function browserPlatformHints(): PlatformHints | null {\n if (typeof navigator === \"undefined\") return null;\n return navigator as PlatformHints;\n}\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Tooltip } from \"../Tooltip\";\nimport {\n InlinePasteEditor,\n type InlinePasteEditorHandle,\n} from \"../Composer/InlinePasteEditor\";\nimport { useInlinePaste } from \"../Composer/use-inline-paste\";\nimport type {\n ComposerPasteClassNames,\n ComposerPastePreview,\n} from \"../Composer/Composer.types\";\nimport {\n browserPlatformHints,\n detectPlatform,\n modifierKeyLabel,\n type FancyPlatform,\n} from \"../../utils/platform\";\n\n/**\n * PromptInput — the chat composer every AI app rebuilds. Auto-growing\n * multi-line input with:\n *\n * • slash-command picker (`/` triggers a filtered command palette,\n * ↑/↓ navigate, Enter inserts)\n * • mention picker (`@` triggers, filtered against `mentions`)\n * • drop-to-attach (drag files anywhere on the surface), paste-to-attach\n * (a pasted screenshot becomes an attachment) + chip bar\n * • submit on ⌘/Ctrl+Enter (plain Enter inserts a newline)\n * • live token-budget meter (green → amber → red as headroom drops)\n *\n * Wire it up:\n *\n * <PromptInput\n * budgetTokens={32000}\n * commands={[{ name: \"/rewrite\", hint: \"rewrite the selection\" }]}\n * mentions={[{ id: \"ada\", name: \"Ada\", kind: \"person\" }]}\n * onSubmit={(text, attachments) => sendToAgent(text, attachments)}\n * />\n */\nexport type PromptCmd = { name: string; hint: string };\nexport type PromptMention = {\n id: string;\n name: string;\n kind: \"agent\" | \"file\" | \"person\" | string;\n};\nexport type PromptAttachment = {\n id: string;\n name: string;\n bytes: number;\n /**\n * The file the user actually attached.\n *\n * Optional because an attachment restored from a server has no File — but for\n * anything the user dropped or picked it is always present. Without it a host\n * can render a chip and nothing else: no POST, no FormData, no send-to-model.\n */\n file?: File;\n /** MIME type. Hosts branch on this to decide whether a file can be sent as-is. */\n type?: string;\n};\n\n/**\n * `...rest` reaches the root surface, so a consumer or a bridge can tag the\n * composer with its own `data-*` handle. The component named every prop it\n * used and had no rest spread, which means a `data-handle` put on it was\n * DROPPED — silently, since React discards unknown props and the component\n * still renders perfectly. That is issue #22 all over again, and the contract\n * calls it out: \"Each interactive element has a stable identity. Agents never\n * guess DOM.\"\n */\nexport interface PromptInputProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onSubmit\" | \"className\"> {\n /** Extra classes on the root surface. MERGED, never replaced. */\n className?: string;\n /** Token budget for the meter. */\n budgetTokens: number;\n /** Slash-commands. Names must start with `/`. */\n commands?: PromptCmd[];\n /** @-mentions. */\n mentions?: PromptMention[];\n /** Show the keyboard hint (\"Ctrl + Enter to send\", \"⌘ + Enter\" on a Mac). */\n showHint?: boolean;\n /**\n * Which modifier the hint and the default placeholder NAME. Omit it and the\n * component reads the platform after mount, which is the right answer for an\n * ordinary web app.\n *\n * Pass it when the host knows better than `navigator` does — an Electron\n * renderer forwarding `process.platform`, a remote session where the\n * keyboard is not the one running the browser, or a test that needs the\n * branch it is not sitting on. The pressed keys are unaffected either way:\n * submit is `⌘/Ctrl+Enter` on every platform, so this only decides which\n * true key gets named.\n */\n platform?: FancyPlatform;\n /** Called on ⌘/Ctrl+Enter or send button. */\n onSubmit: (text: string, attachments: PromptAttachment[]) => void;\n /**\n * Placeholder text. Defaults to a hint naming the modifier THIS platform\n * actually has, so leaving it unset is the better option — a hardcoded\n * placeholder is the other place a `⌘` ends up in front of a Windows user.\n */\n placeholder?: string;\n /** Rough estimator: chars-per-token. Defaults to 4. */\n charsPerToken?: number;\n /** Color → CSS chip mapping for mention kinds. */\n mentionColor?: Record<string, string>;\n /** Optional max textarea height in px. Defaults to 280. */\n maxHeight?: number;\n /**\n * Rendered INSIDE the rounded shell, ABOVE the attachments bar and\n * textarea. Use this slot for a drawer of tools/files/prompts/etc. so\n * the drawer and composer share one visual panel. See {@link ChatDrawer}.\n */\n aboveInput?: ReactNode;\n /**\n * Hold a paste of at least this many characters as a pill IN the message,\n * where it was pasted: on a line of its own, its full text put back in place\n * when clicked, and expanded where it sits when sent. Omit it and paste is\n * unchanged. Setting this (or `pasteImages`) swaps the textarea for an inline\n * editor that keeps the `/` and `@` pickers and the send key.\n */\n pasteThreshold?: number;\n /**\n * A pasted image becomes an inline `Pasted image N` pill AND reaches\n * `onSubmit`'s attachments, with its File, in message order; the text marks\n * where it sat as `[Pasted image N]`. Without it a pasted image is an\n * ordinary attachment chip, as before.\n */\n pasteImages?: boolean;\n /** Characters of a held paste shown at EACH end of its hover preview. Default 20. */\n previewChars?: number;\n /** Replace the paste pills' hover popover content. */\n renderPastePreview?: (preview: ComposerPastePreview) => ReactNode;\n /** Restyle the paste pills, their popover and the inline editor. Merged onto the defaults. */\n pasteClassNames?: ComposerPasteClassNames;\n /** `\"icon\"`: an icon-only attach button whose tooltip says what it does. Default `\"label\"`. */\n attachButton?: \"label\" | \"icon\";\n /**\n * `\"icon\"`: a compact icon send button whose tooltip carries the shortcut —\n * replacing the inline `Ctrl + Enter to send` hint. Default `\"label\"`.\n */\n sendButton?: \"label\" | \"icon\";\n /**\n * Tokens already used — the caller's REAL value, e.g. an agent's context\n * usage. The meter shows this plus the estimate for the draft. Without it the\n * meter estimates the draft alone, as before.\n */\n usedTokens?: number;\n /**\n * `\"always\"` (default) — as before. `\"near-limit\"` — hidden until usage passes\n * `meterShowAt`, muted until `meterWarnAt`, warning colour past that.\n * `\"hidden\"` — never shown.\n */\n meter?: \"always\" | \"near-limit\" | \"hidden\";\n /** Fraction of `budgetTokens` at which a `\"near-limit\"` meter appears. Default 0.75. */\n meterShowAt?: number;\n /** Fraction of `budgetTokens` past which a `\"near-limit\"` meter takes the warning colour. Default 0.9. */\n meterWarnAt?: number;\n}\n\nconst DEFAULT_MENTION_COLOR: Record<string, string> = {\n agent: \"#a855f7\",\n file: \"#10b981\",\n person: \"#3b82f6\",\n};\n\nexport function PromptInput({\n budgetTokens,\n commands = [],\n mentions = [],\n showHint = true,\n platform,\n onSubmit,\n placeholder,\n charsPerToken = 4,\n mentionColor,\n maxHeight = 280,\n aboveInput,\n className,\n pasteThreshold,\n pasteImages = false,\n previewChars = 20,\n renderPastePreview,\n pasteClassNames,\n attachButton = \"label\",\n sendButton = \"label\",\n usedTokens,\n meter = \"always\",\n meterShowAt = 0.75,\n meterWarnAt = 0.9,\n ...rest\n}: PromptInputProps) {\n const [text, setText] = useState(\"\");\n /** Inline pills need an editor that can hold them; a textarea cannot. */\n const inline = pasteThreshold !== undefined || pasteImages;\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames: pasteClassNames,\n disabled: false,\n editorRef,\n });\n const [attachments, setAttachments] = useState<PromptAttachment[]>([]);\n const [picker, setPicker] = useState<null | {\n kind: \"cmd\" | \"mention\";\n start: number;\n query: string;\n cursor: number;\n }>(null);\n const taRef = useRef<HTMLTextAreaElement>(null);\n const fileRef = useRef<HTMLInputElement>(null);\n const [dragOver, setDragOver] = useState(false);\n\n const colors = mentionColor ?? DEFAULT_MENTION_COLOR;\n\n /**\n * Resolved AFTER mount, never during render.\n *\n * `navigator` read during render disagrees with the server's HTML and\n * hydration patches it — so the fix for a wrong label would have introduced a\n * hydration mismatch instead. The first paint names `Ctrl`, which is\n * pressable on every platform including a Mac, and an Apple client swaps to\n * `⌘` on the next tick. A prop, when given, wins outright and no detection\n * runs at all.\n */\n const [detected, setDetected] = useState<FancyPlatform>(\"generic\");\n useEffect(() => {\n if (platform) return;\n setDetected(detectPlatform(browserPlatformHints()));\n }, [platform]);\n const modKey = modifierKeyLabel(platform ?? detected);\n\n const resolvedPlaceholder =\n placeholder ??\n `Ask anything. Type / for commands, @ for mentions. ${modKey}+Enter to send.`;\n\n // Estimated from what will actually be SENT — pills expanded — so a held\n // paste counts for its text, not for the few characters of its marker.\n const draftTokens = useMemo(\n () =>\n Math.ceil((inline ? paste.expand(text) : text).length / Math.max(1, charsPerToken)),\n [text, inline, paste, charsPerToken],\n );\n const tokens = (usedTokens ?? 0) + draftTokens;\n const ratio = Math.min(1, tokens / budgetTokens);\n const meterLevel: \"ok\" | \"caution\" | \"warn\" | \"muted\" | null =\n meter === \"hidden\"\n ? null\n : meter === \"near-limit\"\n ? ratio < meterShowAt\n ? null\n : ratio >= meterWarnAt\n ? \"warn\"\n : \"muted\"\n : ratio < 0.6\n ? \"ok\"\n : ratio < 0.85\n ? \"caution\"\n : \"warn\";\n const meterColor =\n meterLevel === \"ok\"\n ? \"#10b981\"\n : meterLevel === \"caution\"\n ? \"#f59e0b\"\n : meterLevel === \"warn\"\n ? \"#ef4444\"\n : \"#a1a1aa\";\n\n const filteredCmds = useMemo(\n () =>\n picker?.kind === \"cmd\"\n ? commands.filter((c) =>\n c.name.slice(1).toLowerCase().startsWith(picker.query.toLowerCase()),\n )\n : [],\n [picker, commands],\n );\n const filteredMentions = useMemo(\n () =>\n picker?.kind === \"mention\"\n ? mentions.filter((m) =>\n m.name.toLowerCase().includes(picker.query.toLowerCase()),\n )\n : [],\n [picker, mentions],\n );\n const items: Array<PromptCmd | PromptMention> =\n picker?.kind === \"cmd\"\n ? filteredCmds\n : picker?.kind === \"mention\"\n ? filteredMentions\n : [];\n\n useEffect(() => {\n const ta = taRef.current;\n if (!ta) return;\n ta.style.height = \"auto\";\n ta.style.height = Math.min(maxHeight, ta.scrollHeight) + \"px\";\n }, [text, maxHeight]);\n\n const updateText = (next: string, caret: number) => {\n setText(next);\n let triggerIdx = -1;\n let triggerKind: \"cmd\" | \"mention\" | null = null;\n for (let i = caret - 1; i >= 0; i--) {\n const ch = next[i];\n if (ch === \"@\") {\n triggerKind = \"mention\";\n triggerIdx = i;\n break;\n }\n if (ch === \"/\" && (i === 0 || /\\s/.test(next[i - 1] ?? \"\"))) {\n triggerKind = \"cmd\";\n triggerIdx = i;\n break;\n }\n if (/\\s/.test(ch)) break;\n }\n if (triggerKind !== null && triggerIdx >= 0) {\n const query = next.slice(triggerIdx + 1, caret);\n setPicker({ kind: triggerKind, start: triggerIdx, query, cursor: 0 });\n } else {\n setPicker(null);\n }\n };\n\n const insertChoice = (i: number) => {\n if (!picker || items.length === 0) return;\n const choice = items[i] ?? items[0];\n const insert =\n picker.kind === \"cmd\"\n ? (choice as PromptCmd).name + \" \"\n : `@${(choice as PromptMention).id} `;\n const before = text.slice(0, picker.start);\n const after = text.slice(picker.start + 1 + picker.query.length);\n const next = before + insert + after;\n setText(next);\n setPicker(null);\n if (inline) {\n // The editor rebuilds from the value and puts the caret back itself.\n editorRef.current?.setValue(next, before.length + insert.length);\n return;\n }\n requestAnimationFrame(() => {\n const ta = taRef.current;\n if (!ta) return;\n ta.focus();\n const pos = before.length + insert.length;\n ta.setSelectionRange(pos, pos);\n });\n };\n\n const submit = () => {\n // A message that is only a paste counts: its marker is in `text`.\n if (!text.trim() && attachments.length === 0) return;\n\n if (inline) {\n // Every pill goes out where it sits; pasted images join the attachments\n // in message order, with their Files, so a host sends them like any other.\n const pastedImages: PromptAttachment[] = paste.imagesIn(text).map((image) => ({\n id: image.id,\n name: image.file.name,\n bytes: image.file.size,\n file: image.file,\n type: image.file.type,\n }));\n onSubmit(paste.expand(text), [...attachments, ...pastedImages]);\n paste.clear();\n } else {\n onSubmit(text, attachments);\n }\n setText(\"\");\n setAttachments([]);\n setPicker(null);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (picker) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setPicker((p) =>\n p ? { ...p, cursor: Math.min(items.length - 1, p.cursor + 1) } : p,\n );\n return;\n }\n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setPicker((p) => (p ? { ...p, cursor: Math.max(0, p.cursor - 1) } : p));\n return;\n }\n if (e.key === \"Enter\" && !e.metaKey && !e.ctrlKey && items.length > 0) {\n e.preventDefault();\n insertChoice(picker.cursor);\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n setPicker(null);\n return;\n }\n }\n if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n submit();\n }\n };\n\n /**\n * Build attachments from a FileList, KEEPING the File.\n *\n * Shared by the drop handler and the picker so the two cannot drift — the\n * picker being a second, subtly different copy of this is exactly how one of\n * them would end up dropping the File again.\n */\n const attach = (list: FileList | File[] | null) => {\n const files = Array.from(list ?? []);\n if (files.length === 0) return;\n\n setAttachments((cur) => [\n ...cur,\n ...files.map((f) => ({\n id: crypto.randomUUID(),\n name: f.name,\n bytes: f.size,\n file: f,\n type: f.type,\n })),\n ]);\n };\n\n const onDrop = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n attach(e.dataTransfer.files);\n };\n\n /**\n * Paste a screenshot, get an attachment.\n *\n * There was no paste handler at all, so a pasted image did nothing — no chip,\n * no error — and a host that had swapped its own paste-capable textarea for\n * this component lost the feature without noticing.\n *\n * Files attach only when the clipboard carries NO plain text. Word, Excel and\n * most editors put a picture of the selection beside the text; attaching that\n * would turn every pasted sentence into a screenshot of the sentence. A pure\n * image paste has nothing for the browser to insert, so the default is\n * prevented only then, and a text paste is never touched.\n */\n const onPaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n const data = e.clipboardData;\n const files = Array.from(data?.files ?? []);\n\n if (files.length === 0 || (data?.getData(\"text/plain\") ?? \"\") !== \"\") return;\n\n e.preventDefault();\n attach(files);\n };\n\n return (\n <div\n // Spread FIRST so an internal handler or data attribute cannot be\n // clobbered from outside, and so a missing one fails loudly here rather\n // than at a consumer's selector. `className` is merged below instead.\n {...rest}\n // The component had no root handle at all, so an agent reading the\n // composer had to guess at classes. The drag state is on it too: a bridge\n // that wants to know whether a drop is in flight should not have to infer\n // it from Tailwind colours.\n data-react-fancy-prompt-input=\"\"\n data-react-fancy-prompt-input-drag={dragOver ? \"over\" : \"idle\"}\n onDragOver={(e) => {\n e.preventDefault();\n setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={onDrop}\n className={cn(\n \"relative rounded-md border bg-white transition dark:bg-zinc-900\",\n dragOver\n ? \"border-violet-400 bg-violet-50/50 dark:border-violet-600 dark:bg-violet-950/30\"\n : \"border-zinc-200 dark:border-zinc-800\",\n className,\n )}\n >\n {aboveInput && (\n <div className=\"border-b border-zinc-200 dark:border-zinc-800\">\n {aboveInput}\n </div>\n )}\n {attachments.length > 0 && (\n <div className=\"flex flex-wrap gap-1.5 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800\">\n {attachments.map((a) => (\n <span\n key={a.id}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-zinc-100 px-2 py-0.5 text-[11px] dark:bg-zinc-800\"\n >\n <Icon name=\"paperclip\" size=\"xs\" className=\"text-zinc-400\" />\n <span className=\"font-mono\">{a.name}</span>\n <span className=\"text-zinc-400\">{fmtSize(a.bytes)}</span>\n <button\n onClick={() =>\n setAttachments((cur) => cur.filter((x) => x.id !== a.id))\n }\n className=\"opacity-50 hover:opacity-100\"\n aria-label=\"Remove attachment\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n )}\n\n <div className=\"relative\">\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={text}\n known={paste.known}\n onChange={(next, caret) => {\n updateText(next, caret);\n paste.prune(next);\n }}\n onSubmit={submit}\n submitKey=\"mod-enter\"\n onKeyDown={onKeyDown}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={resolvedPlaceholder}\n disabled={false}\n maxHeight={maxHeight}\n placeholderClassName=\"left-3 top-2.5 text-[14px] leading-relaxed\"\n className={cn(\n \"block min-h-[5.5rem] px-3 py-2.5 text-[14px] leading-relaxed\",\n pasteClassNames?.input,\n )}\n />\n {paste.portals}\n </>\n ) : (\n <textarea\n ref={taRef}\n value={text}\n onChange={(e) => updateText(e.target.value, e.target.selectionStart)}\n onKeyDown={onKeyDown}\n onPaste={onPaste}\n placeholder={resolvedPlaceholder}\n spellCheck={false}\n className=\"block w-full resize-none bg-transparent px-3 py-2.5 text-[14px] leading-relaxed outline-none placeholder:text-zinc-400\"\n rows={3}\n />\n )}\n\n {picker && items.length > 0 && (\n <div className=\"absolute bottom-full left-2 z-10 mb-1 w-72 overflow-hidden rounded-md border border-zinc-200 bg-white shadow-lg dark:border-zinc-700 dark:bg-zinc-900\">\n <div className=\"border-b border-zinc-100 bg-zinc-50 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950\">\n {picker.kind === \"cmd\" ? \"Commands\" : \"Mention\"} · {items.length}\n </div>\n <ul className=\"max-h-56 overflow-y-auto\">\n {items.map((item, i) => {\n const active = i === picker.cursor;\n if (picker.kind === \"cmd\") {\n const c = item as PromptCmd;\n return (\n <li\n key={c.name}\n onMouseDown={(e) => {\n e.preventDefault();\n insertChoice(i);\n }}\n onMouseEnter={() =>\n setPicker((p) => (p ? { ...p, cursor: i } : p))\n }\n className={`cursor-pointer px-2 py-1.5 text-[12px] ${\n active\n ? \"bg-violet-100 dark:bg-violet-900/30\"\n : \"hover:bg-zinc-50 dark:hover:bg-zinc-800\"\n }`}\n >\n <div className=\"font-mono font-medium text-violet-700 dark:text-violet-300\">\n {c.name}\n </div>\n <div className=\"text-[11px] text-zinc-500\">{c.hint}</div>\n </li>\n );\n }\n const m = item as PromptMention;\n return (\n <li\n key={m.id}\n onMouseDown={(e) => {\n e.preventDefault();\n insertChoice(i);\n }}\n onMouseEnter={() =>\n setPicker((p) => (p ? { ...p, cursor: i } : p))\n }\n className={`flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[12px] ${\n active\n ? \"bg-violet-100 dark:bg-violet-900/30\"\n : \"hover:bg-zinc-50 dark:hover:bg-zinc-800\"\n }`}\n >\n <span\n className=\"h-2 w-2 rounded-full\"\n style={{ backgroundColor: colors[m.kind] ?? \"#71717a\" }}\n />\n <span className=\"font-medium\">{m.name}</span>\n <span className=\"ml-auto text-[10px] uppercase tracking-wider text-zinc-400\">\n {m.kind}\n </span>\n </li>\n );\n })}\n </ul>\n </div>\n )}\n </div>\n\n <div className=\"flex items-center gap-2 border-t border-zinc-200 bg-zinc-50/60 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-900/40\">\n <Tooltip content={attachButton === \"icon\" ? \"Attach files — or drop them here\" : \"Drop files here, or click\"}>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon=\"paperclip\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-attach=\"\"\n // An icon alone has no name; the tooltip is not one a screen reader reads.\n aria-label={attachButton === \"icon\" ? \"Attach files\" : undefined}\n onClick={() => fileRef.current?.click()}\n >\n {attachButton === \"icon\" ? null : \"attach\"}\n </Button>\n </Tooltip>\n {/*\n The button above shipped with a no-op onClick and a tooltip reading\n \"Drop files here, or click\" — an affordance that lied. Drop-only also\n meant keyboard and touch users could not attach at all.\n\n It then shipped with a literal paperclip EMOJI as its icon, which\n needs a COLOUR\n EMOJI FONT — not merely broad coverage — so a lean container renders a\n tofu box where the affordance should be. `icon=\"paperclip\"` draws an\n SVG from the kit's own icon layer, which is the same reason the rest of\n the suite does not hand-roll iconography.\n */}\n <input\n ref={fileRef}\n type=\"file\"\n multiple\n className=\"hidden\"\n onChange={(e) => {\n attach(e.target.files);\n // Let the same file be picked twice in a row.\n e.target.value = \"\";\n }}\n />\n {meterLevel !== null && (\n <div\n data-react-fancy-prompt-input-meter=\"\"\n data-level={meterLevel}\n className=\"ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden\"\n >\n <div className=\"h-1.5 w-24 shrink overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700\">\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${ratio * 100}%`, backgroundColor: meterColor }}\n />\n </div>\n <span className=\"font-mono text-[11px]\" style={{ color: meterColor }}>\n {fmtTokens(tokens)} / {fmtTokens(budgetTokens)}\n </span>\n </div>\n )}\n <div className=\"ml-auto flex shrink-0 items-center gap-2\">\n {/* With an icon send button the shortcut lives in its tooltip instead. */}\n {showHint && sendButton !== \"icon\" && (\n <span\n className=\"hidden text-[10px] text-zinc-500 sm:inline\"\n data-react-fancy-prompt-input-hint={modKey === \"⌘\" ? \"apple\" : \"generic\"}\n >\n <kbd className=\"rounded border border-zinc-300 bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300\">\n {modKey}\n </kbd>{\" \"}\n +{\" \"}\n <kbd className=\"rounded border border-zinc-300 bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300\">\n Enter\n </kbd>{\" \"}\n to send\n </span>\n )}\n {sendButton === \"icon\" ? (\n <Tooltip content={`Send · ${modKey}+Enter`}>\n <Button\n color=\"violet\"\n size=\"sm\"\n icon=\"arrow-up\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-send=\"\"\n aria-label=\"Send\"\n onClick={submit}\n />\n </Tooltip>\n ) : (\n <Button\n color=\"violet\"\n size=\"sm\"\n iconTrailing=\"arrow-right\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-send=\"\"\n onClick={submit}\n >\n send\n </Button>\n )}\n </div>\n </div>\n </div>\n );\n}\n\nfunction fmtTokens(n: number): string {\n if (n < 1000) return `${n}`;\n return `${(n / 1000).toFixed(1)}k`;\n}\n\nfunction fmtSize(b: number): string {\n if (b < 1024) return `${b} B`;\n if (b < 1024 * 1024) return `${(b / 1024).toFixed(0)} KB`;\n return `${(b / 1024 / 1024).toFixed(1)} MB`;\n}\n"]}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { useInlinePaste, withSeparators, endsOf, InlinePasteEditor } from './chunk-2JOWGYAJ.js';
|
|
2
|
+
import { useControllableState } from './chunk-EDYAXGUM.js';
|
|
3
|
+
import { cn } from './chunk-MMW2JGKZ.js';
|
|
4
|
+
import { forwardRef, useRef, useCallback } from 'react';
|
|
5
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var PREVIEW_CHARS = 20;
|
|
8
|
+
var Composer = forwardRef(
|
|
9
|
+
function Composer2({
|
|
10
|
+
value: controlledValue,
|
|
11
|
+
defaultValue = "",
|
|
12
|
+
onChange,
|
|
13
|
+
onSubmit,
|
|
14
|
+
placeholder = "Type a message...",
|
|
15
|
+
actions,
|
|
16
|
+
disabled = false,
|
|
17
|
+
className,
|
|
18
|
+
pasteThreshold,
|
|
19
|
+
pastePlacement = "above",
|
|
20
|
+
pasteImages = false,
|
|
21
|
+
previewChars = PREVIEW_CHARS,
|
|
22
|
+
renderPastePreview,
|
|
23
|
+
classNames,
|
|
24
|
+
heldPastes: controlledHeldPastes,
|
|
25
|
+
onHeldPastesChange,
|
|
26
|
+
heldImages: controlledHeldImages,
|
|
27
|
+
onHeldImagesChange
|
|
28
|
+
}, ref) {
|
|
29
|
+
const inline = pastePlacement === "inline";
|
|
30
|
+
const [value, setValue] = useControllableState(
|
|
31
|
+
controlledValue,
|
|
32
|
+
defaultValue,
|
|
33
|
+
onChange
|
|
34
|
+
);
|
|
35
|
+
const textareaRef = useRef(null);
|
|
36
|
+
const editorRef = useRef(null);
|
|
37
|
+
const paste = useInlinePaste({
|
|
38
|
+
pasteThreshold,
|
|
39
|
+
pasteImages,
|
|
40
|
+
previewChars,
|
|
41
|
+
renderPastePreview,
|
|
42
|
+
classNames,
|
|
43
|
+
disabled,
|
|
44
|
+
heldPastes: controlledHeldPastes,
|
|
45
|
+
onHeldPastesChange,
|
|
46
|
+
heldImages: controlledHeldImages,
|
|
47
|
+
onHeldImagesChange,
|
|
48
|
+
editorRef
|
|
49
|
+
});
|
|
50
|
+
const pills = paste.pills;
|
|
51
|
+
const heldPastes = paste.heldPastes;
|
|
52
|
+
const handlePaste = useCallback(
|
|
53
|
+
(e) => {
|
|
54
|
+
pills.handlePaste(e);
|
|
55
|
+
},
|
|
56
|
+
[pills]
|
|
57
|
+
);
|
|
58
|
+
const handleInlineChange = useCallback(
|
|
59
|
+
(next) => {
|
|
60
|
+
setValue(next);
|
|
61
|
+
paste.prune(next);
|
|
62
|
+
},
|
|
63
|
+
[setValue, paste]
|
|
64
|
+
);
|
|
65
|
+
const composeOutgoing = useCallback(() => {
|
|
66
|
+
if (inline) return paste.expand(value);
|
|
67
|
+
return [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join("\n\n");
|
|
68
|
+
}, [inline, value, heldPastes, paste]);
|
|
69
|
+
const hasContent = value.trim().length > 0 || !inline && heldPastes.length > 0;
|
|
70
|
+
const focusInput = useCallback(() => {
|
|
71
|
+
if (inline) editorRef.current?.focus();
|
|
72
|
+
else textareaRef.current?.focus();
|
|
73
|
+
}, [inline]);
|
|
74
|
+
const handleSubmit = useCallback(() => {
|
|
75
|
+
if (!hasContent || disabled) return;
|
|
76
|
+
const images = inline ? paste.imagesIn(value) : [];
|
|
77
|
+
onSubmit?.(composeOutgoing(), { images });
|
|
78
|
+
setValue("");
|
|
79
|
+
paste.clear();
|
|
80
|
+
focusInput();
|
|
81
|
+
}, [hasContent, disabled, value, inline, paste, onSubmit, composeOutgoing, setValue, focusInput]);
|
|
82
|
+
const handleKeyDown = (e) => {
|
|
83
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
handleSubmit();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const insertPaste = useCallback(
|
|
89
|
+
(held) => {
|
|
90
|
+
const text = pills.expand(held.id);
|
|
91
|
+
if (text === void 0) return;
|
|
92
|
+
setValue((current) => current ? `${current}
|
|
93
|
+
|
|
94
|
+
${text}` : text);
|
|
95
|
+
textareaRef.current?.focus();
|
|
96
|
+
},
|
|
97
|
+
[pills, setValue]
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ jsxs(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
"data-react-fancy-composer": "",
|
|
103
|
+
ref,
|
|
104
|
+
className: cn(
|
|
105
|
+
"rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900",
|
|
106
|
+
disabled && "opacity-50",
|
|
107
|
+
className
|
|
108
|
+
),
|
|
109
|
+
children: [
|
|
110
|
+
!inline && heldPastes.length > 0 && /* @__PURE__ */ jsx(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
"data-react-fancy-composer-paste-pills": "",
|
|
114
|
+
className: "flex flex-wrap gap-1.5 px-3 pt-3",
|
|
115
|
+
children: heldPastes.map((paste2) => (
|
|
116
|
+
// `group` + `group-hover` rather than hover state: the preview is
|
|
117
|
+
// presentation, and a useState for it would be one more thing an
|
|
118
|
+
// agent could desynchronise.
|
|
119
|
+
/* @__PURE__ */ jsxs("span", { className: "group relative inline-flex", children: [
|
|
120
|
+
/* @__PURE__ */ jsx(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
"data-react-fancy-composer-paste-pill": paste2.id,
|
|
125
|
+
onClick: () => insertPaste(paste2),
|
|
126
|
+
disabled,
|
|
127
|
+
"aria-label": `Insert this pasted text, ${withSeparators(paste2.text.length)} characters`,
|
|
128
|
+
"aria-describedby": `${paste2.id}-preview`,
|
|
129
|
+
className: cn(
|
|
130
|
+
"inline-flex items-center gap-1.5 rounded-full border border-zinc-200 bg-zinc-50 py-1 pl-2.5 pr-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700",
|
|
131
|
+
classNames?.pill,
|
|
132
|
+
classNames?.textPill
|
|
133
|
+
),
|
|
134
|
+
children: /* @__PURE__ */ jsxs("span", { children: [
|
|
135
|
+
"Pasted text \xB7 ",
|
|
136
|
+
withSeparators(paste2.text.length),
|
|
137
|
+
" characters"
|
|
138
|
+
] })
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
"data-react-fancy-composer-paste-pill-remove": paste2.id,
|
|
146
|
+
onClick: () => pills.remove(paste2.id),
|
|
147
|
+
disabled,
|
|
148
|
+
"aria-label": "Discard this pasted text",
|
|
149
|
+
className: cn(
|
|
150
|
+
"absolute right-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100",
|
|
151
|
+
classNames?.remove
|
|
152
|
+
),
|
|
153
|
+
children: "\xD7"
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
"span",
|
|
158
|
+
{
|
|
159
|
+
id: `${paste2.id}-preview`,
|
|
160
|
+
"data-react-fancy-composer-paste-pill-preview": paste2.id,
|
|
161
|
+
role: "tooltip",
|
|
162
|
+
className: cn(
|
|
163
|
+
"pointer-events-none absolute bottom-full left-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900",
|
|
164
|
+
classNames?.preview
|
|
165
|
+
),
|
|
166
|
+
children: renderPastePreview?.({ kind: "text", paste: paste2 }) ?? endsOf(paste2.text, previewChars)
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] }, paste2.id)
|
|
170
|
+
))
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
inline ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ jsx(
|
|
175
|
+
InlinePasteEditor,
|
|
176
|
+
{
|
|
177
|
+
ref: editorRef,
|
|
178
|
+
value,
|
|
179
|
+
known: paste.known,
|
|
180
|
+
onChange: handleInlineChange,
|
|
181
|
+
onSubmit: handleSubmit,
|
|
182
|
+
onPaste: paste.decidePaste,
|
|
183
|
+
onHostsChange: paste.onHostsChange,
|
|
184
|
+
placeholder,
|
|
185
|
+
disabled,
|
|
186
|
+
className: classNames?.input
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
paste.portals
|
|
190
|
+
] }) : /* @__PURE__ */ jsx(
|
|
191
|
+
"textarea",
|
|
192
|
+
{
|
|
193
|
+
ref: textareaRef,
|
|
194
|
+
value,
|
|
195
|
+
onChange: (e) => setValue(e.target.value),
|
|
196
|
+
onKeyDown: handleKeyDown,
|
|
197
|
+
onPaste: handlePaste,
|
|
198
|
+
placeholder,
|
|
199
|
+
disabled,
|
|
200
|
+
rows: 3,
|
|
201
|
+
className: cn(
|
|
202
|
+
"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400",
|
|
203
|
+
classNames?.input
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800", children: [
|
|
208
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: actions }),
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
"button",
|
|
211
|
+
{
|
|
212
|
+
type: "button",
|
|
213
|
+
onClick: handleSubmit,
|
|
214
|
+
disabled: disabled || !hasContent,
|
|
215
|
+
className: "rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100",
|
|
216
|
+
children: "Send"
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
] })
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
Composer.displayName = "Composer";
|
|
226
|
+
|
|
227
|
+
export { Composer };
|
|
228
|
+
//# sourceMappingURL=chunk-MXAVGOHW.js.map
|
|
229
|
+
//# sourceMappingURL=chunk-MXAVGOHW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Composer/Composer.tsx"],"names":["Composer","paste"],"mappings":";;;;;;AAUA,IAAM,aAAA,GAAgB,EAAA;AAEf,IAAM,QAAA,GAAW,UAAA;AAAA,EACtB,SAASA,SAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;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AU,2FAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,yBAAA,EAA2B,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,4BAClD,GAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,OAAA,EAAS,YAAA;AAAA,gBACT,QAAA,EAAU,YAAY,CAAC,UAAA;AAAA,gBACvB,SAAA,EAAU,mLAAA;AAAA,gBACX,QAAA,EAAA;AAAA;AAAA;AAED,WAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"chunk-MXAVGOHW.js","sourcesContent":["import { forwardRef, useCallback, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport type { HeldPaste } from \"../../hooks/use-paste-pills\";\nimport { endsOf, withSeparators } from \"./InlinePill\";\nimport { InlinePasteEditor, type InlinePasteEditorHandle } from \"./InlinePasteEditor\";\nimport { useInlinePaste } from \"./use-inline-paste\";\nimport type { ComposerProps } from \"./Composer.types\";\n\n/** Characters of a held paste shown at each end of the hover preview, unless `previewChars` says otherwise. */\nconst PREVIEW_CHARS = 20;\n\nexport const Composer = forwardRef<HTMLDivElement, ComposerProps>(\n function Composer(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSubmit,\n placeholder = \"Type a message...\",\n actions,\n disabled = false,\n className,\n pasteThreshold,\n pastePlacement = \"above\",\n pasteImages = false,\n previewChars = PREVIEW_CHARS,\n renderPastePreview,\n classNames,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n },\n ref,\n ) {\n const inline = pastePlacement === \"inline\";\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n /*\n * The holding logic lives in `usePastePills`, wrapped by `useInlinePaste` for\n * the inline placement — which `PromptInput` shares, so the two components\n * cannot disagree about what a pill means. The rule that must not drift is\n * the one below: a send with pills still closed carries the text.\n */\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n editorRef,\n });\n const pills = paste.pills;\n const heldPastes = paste.heldPastes;\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n // Composable by design, so this reads as a question rather than a handover.\n // Nothing else here wants the paste, so the answer is simply ignored.\n pills.handlePaste(e);\n },\n [pills],\n );\n\n const handleInlineChange = useCallback(\n (next: string) => {\n setValue(next);\n paste.prune(next);\n },\n [setValue, paste],\n );\n\n /** Everything the person believes they are sending, in the order they built it. */\n const composeOutgoing = useCallback(() => {\n if (inline) return paste.expand(value);\n\n return [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join(\"\\n\\n\");\n }, [inline, value, heldPastes, paste]);\n\n const hasContent = value.trim().length > 0 || (!inline && heldPastes.length > 0);\n\n const focusInput = useCallback(() => {\n if (inline) editorRef.current?.focus();\n else textareaRef.current?.focus();\n }, [inline]);\n\n const handleSubmit = useCallback(() => {\n if (!hasContent || disabled) return;\n\n /*\n * THE DANGEROUS STATE, and the reason this feature needed a spec rather than\n * a guess. A pill reads as \"your paste is attached\" — so a send that drops it\n * means asking a question about a document without the document, and nobody\n * can tell: the sender believes it went, the receiver sees a question about\n * nothing.\n *\n * Above the input, held pastes go out in arrival order after what was typed,\n * because people type the question BEFORE pasting the thing it is about.\n * Inline, every pill goes out exactly where it sits.\n */\n const images = inline ? paste.imagesIn(value) : [];\n\n onSubmit?.(composeOutgoing(), { images });\n setValue(\"\");\n paste.clear();\n focusInput();\n }, [hasContent, disabled, value, inline, paste, onSubmit, composeOutgoing, setValue, focusInput]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n };\n\n /** Above the input: click a pill to dump it in, APPENDED to what is already typed. */\n const insertPaste = useCallback(\n (held: HeldPaste) => {\n // `expand` removes it and hands back the text; inserting is this\n // component's job because the hook owns no DOM.\n const text = pills.expand(held.id);\n\n if (text === undefined) return;\n\n setValue((current) => (current ? `${current}\\n\\n${text}` : text));\n textareaRef.current?.focus();\n },\n [pills, setValue],\n );\n\n return (\n <div\n data-react-fancy-composer=\"\"\n ref={ref}\n className={cn(\n \"rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {!inline && heldPastes.length > 0 && (\n <div\n data-react-fancy-composer-paste-pills=\"\"\n className=\"flex flex-wrap gap-1.5 px-3 pt-3\"\n >\n {heldPastes.map((paste) => (\n // `group` + `group-hover` rather than hover state: the preview is\n // presentation, and a useState for it would be one more thing an\n // agent could desynchronise.\n <span key={paste.id} className=\"group relative inline-flex\">\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={paste.id}\n onClick={() => insertPaste(paste)}\n disabled={disabled}\n // No `title`. A native tooltip plus the hover preview below\n // renders TWO tooltips on the same hover, at different delays.\n // The label says what clicking does; the preview says what the\n // text is, and it is linked rather than merely adjacent so a\n // screen reader reaches it too.\n aria-label={`Insert this pasted text, ${withSeparators(paste.text.length)} characters`}\n aria-describedby={`${paste.id}-preview`}\n // `pr-7` leaves room for the absolutely-positioned × that sits\n // over this button's right edge. With a smaller right padding the\n // × lands on top of the label.\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full border border-zinc-200 bg-zinc-50 py-1 pl-2.5 pr-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700\",\n classNames?.pill,\n classNames?.textPill,\n )}\n >\n <span>\n Pasted text · {withSeparators(paste.text.length)} characters\n </span>\n </button>\n\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill-remove={paste.id}\n onClick={() => pills.remove(paste.id)}\n disabled={disabled}\n aria-label=\"Discard this pasted text\"\n className={cn(\n \"absolute right-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100\",\n classNames?.remove,\n )}\n >\n ×\n </button>\n\n <span\n id={`${paste.id}-preview`}\n data-react-fancy-composer-paste-pill-preview={paste.id}\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none absolute bottom-full left-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900\",\n classNames?.preview,\n )}\n >\n {renderPastePreview?.({ kind: \"text\", paste }) ??\n endsOf(paste.text, previewChars)}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={value}\n known={paste.known}\n onChange={handleInlineChange}\n onSubmit={handleSubmit}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={placeholder}\n disabled={disabled}\n className={classNames?.input}\n />\n {paste.portals}\n </>\n ) : (\n <textarea\n ref={textareaRef}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n disabled={disabled}\n rows={3}\n className={cn(\n \"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400\",\n classNames?.input,\n )}\n />\n )}\n <div className=\"flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800\">\n <div className=\"flex items-center gap-1\">{actions}</div>\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={disabled || !hasContent}\n className=\"rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100\"\n >\n Send\n </button>\n </div>\n </div>\n );\n },\n);\n\nComposer.displayName = \"Composer\";\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { useInlinePaste, InlinePasteEditor } from './chunk-2JOWGYAJ.js';
|
|
1
2
|
import { Tooltip } from './chunk-CF5KRDN4.js';
|
|
2
3
|
import { Button } from './chunk-46IPQEUP.js';
|
|
3
4
|
import { Icon } from './chunk-IVRYSSM7.js';
|
|
4
5
|
import { cn } from './chunk-MMW2JGKZ.js';
|
|
5
6
|
import { useState, useRef, useEffect, useMemo } from 'react';
|
|
6
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
7
8
|
|
|
8
9
|
// src/utils/platform.ts
|
|
9
10
|
var APPLE_UA_DATA_PLATFORMS = /* @__PURE__ */ new Set(["macos", "ios", "ipados"]);
|
|
@@ -44,9 +45,31 @@ function PromptInput({
|
|
|
44
45
|
maxHeight = 280,
|
|
45
46
|
aboveInput,
|
|
46
47
|
className,
|
|
48
|
+
pasteThreshold,
|
|
49
|
+
pasteImages = false,
|
|
50
|
+
previewChars = 20,
|
|
51
|
+
renderPastePreview,
|
|
52
|
+
pasteClassNames,
|
|
53
|
+
attachButton = "label",
|
|
54
|
+
sendButton = "label",
|
|
55
|
+
usedTokens,
|
|
56
|
+
meter = "always",
|
|
57
|
+
meterShowAt = 0.75,
|
|
58
|
+
meterWarnAt = 0.9,
|
|
47
59
|
...rest
|
|
48
60
|
}) {
|
|
49
61
|
const [text, setText] = useState("");
|
|
62
|
+
const inline = pasteThreshold !== void 0 || pasteImages;
|
|
63
|
+
const editorRef = useRef(null);
|
|
64
|
+
const paste = useInlinePaste({
|
|
65
|
+
pasteThreshold,
|
|
66
|
+
pasteImages,
|
|
67
|
+
previewChars,
|
|
68
|
+
renderPastePreview,
|
|
69
|
+
classNames: pasteClassNames,
|
|
70
|
+
disabled: false,
|
|
71
|
+
editorRef
|
|
72
|
+
});
|
|
50
73
|
const [attachments, setAttachments] = useState([]);
|
|
51
74
|
const [picker, setPicker] = useState(null);
|
|
52
75
|
const taRef = useRef(null);
|
|
@@ -60,12 +83,14 @@ function PromptInput({
|
|
|
60
83
|
}, [platform]);
|
|
61
84
|
const modKey = modifierKeyLabel(platform ?? detected);
|
|
62
85
|
const resolvedPlaceholder = placeholder ?? `Ask anything. Type / for commands, @ for mentions. ${modKey}+Enter to send.`;
|
|
63
|
-
const
|
|
64
|
-
() => Math.ceil(text.length / Math.max(1, charsPerToken)),
|
|
65
|
-
[text, charsPerToken]
|
|
86
|
+
const draftTokens = useMemo(
|
|
87
|
+
() => Math.ceil((inline ? paste.expand(text) : text).length / Math.max(1, charsPerToken)),
|
|
88
|
+
[text, inline, paste, charsPerToken]
|
|
66
89
|
);
|
|
90
|
+
const tokens = (usedTokens ?? 0) + draftTokens;
|
|
67
91
|
const ratio = Math.min(1, tokens / budgetTokens);
|
|
68
|
-
const
|
|
92
|
+
const meterLevel = meter === "hidden" ? null : meter === "near-limit" ? ratio < meterShowAt ? null : ratio >= meterWarnAt ? "warn" : "muted" : ratio < 0.6 ? "ok" : ratio < 0.85 ? "caution" : "warn";
|
|
93
|
+
const meterColor = meterLevel === "ok" ? "#10b981" : meterLevel === "caution" ? "#f59e0b" : meterLevel === "warn" ? "#ef4444" : "#a1a1aa";
|
|
69
94
|
const filteredCmds = useMemo(
|
|
70
95
|
() => picker?.kind === "cmd" ? commands.filter(
|
|
71
96
|
(c) => c.name.slice(1).toLowerCase().startsWith(picker.query.toLowerCase())
|
|
@@ -119,6 +144,10 @@ function PromptInput({
|
|
|
119
144
|
const next = before + insert + after;
|
|
120
145
|
setText(next);
|
|
121
146
|
setPicker(null);
|
|
147
|
+
if (inline) {
|
|
148
|
+
editorRef.current?.setValue(next, before.length + insert.length);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
122
151
|
requestAnimationFrame(() => {
|
|
123
152
|
const ta = taRef.current;
|
|
124
153
|
if (!ta) return;
|
|
@@ -129,7 +158,19 @@ function PromptInput({
|
|
|
129
158
|
};
|
|
130
159
|
const submit = () => {
|
|
131
160
|
if (!text.trim() && attachments.length === 0) return;
|
|
132
|
-
|
|
161
|
+
if (inline) {
|
|
162
|
+
const pastedImages = paste.imagesIn(text).map((image) => ({
|
|
163
|
+
id: image.id,
|
|
164
|
+
name: image.file.name,
|
|
165
|
+
bytes: image.file.size,
|
|
166
|
+
file: image.file,
|
|
167
|
+
type: image.file.type
|
|
168
|
+
}));
|
|
169
|
+
onSubmit(paste.expand(text), [...attachments, ...pastedImages]);
|
|
170
|
+
paste.clear();
|
|
171
|
+
} else {
|
|
172
|
+
onSubmit(text, attachments);
|
|
173
|
+
}
|
|
133
174
|
setText("");
|
|
134
175
|
setAttachments([]);
|
|
135
176
|
setPicker(null);
|
|
@@ -231,7 +272,34 @@ function PromptInput({
|
|
|
231
272
|
a.id
|
|
232
273
|
)) }),
|
|
233
274
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
234
|
-
/* @__PURE__ */
|
|
275
|
+
inline ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
276
|
+
/* @__PURE__ */ jsx(
|
|
277
|
+
InlinePasteEditor,
|
|
278
|
+
{
|
|
279
|
+
ref: editorRef,
|
|
280
|
+
value: text,
|
|
281
|
+
known: paste.known,
|
|
282
|
+
onChange: (next, caret) => {
|
|
283
|
+
updateText(next, caret);
|
|
284
|
+
paste.prune(next);
|
|
285
|
+
},
|
|
286
|
+
onSubmit: submit,
|
|
287
|
+
submitKey: "mod-enter",
|
|
288
|
+
onKeyDown,
|
|
289
|
+
onPaste: paste.decidePaste,
|
|
290
|
+
onHostsChange: paste.onHostsChange,
|
|
291
|
+
placeholder: resolvedPlaceholder,
|
|
292
|
+
disabled: false,
|
|
293
|
+
maxHeight,
|
|
294
|
+
placeholderClassName: "left-3 top-2.5 text-[14px] leading-relaxed",
|
|
295
|
+
className: cn(
|
|
296
|
+
"block min-h-[5.5rem] px-3 py-2.5 text-[14px] leading-relaxed",
|
|
297
|
+
pasteClassNames?.input
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
paste.portals
|
|
302
|
+
] }) : /* @__PURE__ */ jsx(
|
|
235
303
|
"textarea",
|
|
236
304
|
{
|
|
237
305
|
ref: taRef,
|
|
@@ -300,15 +368,17 @@ function PromptInput({
|
|
|
300
368
|
] })
|
|
301
369
|
] }),
|
|
302
370
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-t border-zinc-200 bg-zinc-50/60 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-900/40", children: [
|
|
303
|
-
/* @__PURE__ */ jsx(Tooltip, { content: "Drop files here, or click", children: /* @__PURE__ */ jsx(
|
|
371
|
+
/* @__PURE__ */ jsx(Tooltip, { content: attachButton === "icon" ? "Attach files \u2014 or drop them here" : "Drop files here, or click", children: /* @__PURE__ */ jsx(
|
|
304
372
|
Button,
|
|
305
373
|
{
|
|
306
374
|
variant: "ghost",
|
|
307
375
|
size: "sm",
|
|
308
376
|
icon: "paperclip",
|
|
309
377
|
className: "shrink-0",
|
|
378
|
+
"data-react-fancy-prompt-input-attach": "",
|
|
379
|
+
"aria-label": attachButton === "icon" ? "Attach files" : void 0,
|
|
310
380
|
onClick: () => fileRef.current?.click(),
|
|
311
|
-
children: "attach"
|
|
381
|
+
children: attachButton === "icon" ? null : "attach"
|
|
312
382
|
}
|
|
313
383
|
) }),
|
|
314
384
|
/* @__PURE__ */ jsx(
|
|
@@ -324,22 +394,30 @@ function PromptInput({
|
|
|
324
394
|
}
|
|
325
395
|
}
|
|
326
396
|
),
|
|
327
|
-
/* @__PURE__ */ jsxs(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
397
|
+
meterLevel !== null && /* @__PURE__ */ jsxs(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
"data-react-fancy-prompt-input-meter": "",
|
|
401
|
+
"data-level": meterLevel,
|
|
402
|
+
className: "ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
403
|
+
children: [
|
|
404
|
+
/* @__PURE__ */ jsx("div", { className: "h-1.5 w-24 shrink overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsx(
|
|
405
|
+
"div",
|
|
406
|
+
{
|
|
407
|
+
className: "h-full rounded-full transition-all",
|
|
408
|
+
style: { width: `${ratio * 100}%`, backgroundColor: meterColor }
|
|
409
|
+
}
|
|
410
|
+
) }),
|
|
411
|
+
/* @__PURE__ */ jsxs("span", { className: "font-mono text-[11px]", style: { color: meterColor }, children: [
|
|
412
|
+
fmtTokens(tokens),
|
|
413
|
+
" / ",
|
|
414
|
+
fmtTokens(budgetTokens)
|
|
415
|
+
] })
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
),
|
|
341
419
|
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
|
|
342
|
-
showHint && /* @__PURE__ */ jsxs(
|
|
420
|
+
showHint && sendButton !== "icon" && /* @__PURE__ */ jsxs(
|
|
343
421
|
"span",
|
|
344
422
|
{
|
|
345
423
|
className: "hidden text-[10px] text-zinc-500 sm:inline",
|
|
@@ -355,13 +433,25 @@ function PromptInput({
|
|
|
355
433
|
]
|
|
356
434
|
}
|
|
357
435
|
),
|
|
358
|
-
/* @__PURE__ */ jsx(
|
|
436
|
+
sendButton === "icon" ? /* @__PURE__ */ jsx(Tooltip, { content: `Send \xB7 ${modKey}+Enter`, children: /* @__PURE__ */ jsx(
|
|
437
|
+
Button,
|
|
438
|
+
{
|
|
439
|
+
color: "violet",
|
|
440
|
+
size: "sm",
|
|
441
|
+
icon: "arrow-up",
|
|
442
|
+
className: "shrink-0",
|
|
443
|
+
"data-react-fancy-prompt-input-send": "",
|
|
444
|
+
"aria-label": "Send",
|
|
445
|
+
onClick: submit
|
|
446
|
+
}
|
|
447
|
+
) }) : /* @__PURE__ */ jsx(
|
|
359
448
|
Button,
|
|
360
449
|
{
|
|
361
450
|
color: "violet",
|
|
362
451
|
size: "sm",
|
|
363
452
|
iconTrailing: "arrow-right",
|
|
364
453
|
className: "shrink-0",
|
|
454
|
+
"data-react-fancy-prompt-input-send": "",
|
|
365
455
|
onClick: submit,
|
|
366
456
|
children: "send"
|
|
367
457
|
}
|
|
@@ -383,5 +473,5 @@ function fmtSize(b) {
|
|
|
383
473
|
}
|
|
384
474
|
|
|
385
475
|
export { PromptInput, browserPlatformHints, detectPlatform, modifierKeyLabel };
|
|
386
|
-
//# sourceMappingURL=chunk-
|
|
387
|
-
//# sourceMappingURL=chunk-
|
|
476
|
+
//# sourceMappingURL=chunk-YLPVTEUH.js.map
|
|
477
|
+
//# sourceMappingURL=chunk-YLPVTEUH.js.map
|