@adea-ai/ui 0.150.0 → 0.151.2
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/dist/components/composites/inline-citation/inline-citation.d.ts +2 -1
- package/dist/components/composites/inline-citation/inline-citation.d.ts.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.js +36 -3
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.d.ts.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.js +28 -4
- package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
- package/dist/components/conversation/paste-token-editor.d.ts.map +1 -1
- package/dist/components/conversation/paste-token-editor.js +127 -37
- package/dist/components/conversation/paste-token-editor.js.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts +5 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +54 -23
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js +9 -4
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/dialog/dialog.js +1 -1
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts +18 -3
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.js +29 -3
- package/dist/components/ui/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/r/appearance-editor.json +1 -1
- package/dist/r/lib.json +1 -1
- package/dist/r/registry.json +3 -3
- package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +53 -4
- package/dist/r/src/components/conversation/internal/chat-composer-shell.tsx +36 -2
- package/dist/r/src/components/conversation/paste-token-editor.tsx +191 -49
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +76 -28
- package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +11 -2
- package/dist/r/src/components/ui/dialog/dialog.tsx +1 -1
- package/dist/r/src/components/ui/modal-dialog/modal-dialog.tsx +33 -4
- package/dist/r/theming.json +1 -1
- package/package.json +2 -2
- package/registry.json +3 -3
- package/src/components/composites/inline-citation/inline-citation.tsx +53 -4
- package/src/components/conversation/internal/chat-composer-shell.tsx +36 -2
- package/src/components/conversation/paste-token-editor.tsx +191 -49
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +76 -28
- package/src/components/ui/alert-dialog/alert-dialog.tsx +11 -2
- package/src/components/ui/dialog/dialog.tsx +1 -1
- package/src/components/ui/modal-dialog/modal-dialog.tsx +33 -4
|
@@ -17,7 +17,8 @@ import { type Source } from '../sources/source';
|
|
|
17
17
|
*
|
|
18
18
|
* - **Hover or keyboard focus peeks.** The popover opens without taking focus
|
|
19
19
|
* and closes when the pointer or focus leaves. Touch has no hover, so a touch
|
|
20
|
-
* never peeks.
|
|
20
|
+
* never peeks. A keyboard peek's card is inert, so Tab moves on from the badge
|
|
21
|
+
* to the next control on the page instead of into a card that is closing.
|
|
21
22
|
* - **Click, tap, Enter or Space pins.** Focus moves into the popover so its
|
|
22
23
|
* link and Previous/Next are reachable; it stays until Escape, an outside press,
|
|
23
24
|
* or the badge is pressed again, and focus returns to the badge. Pressing a badge
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-citation.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,OAAO,EAML,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAU1B
|
|
1
|
+
{"version":3,"file":"inline-citation.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,OAAO,EAML,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAU1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,0DAA0D;IAC1D,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAID,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,kCAiMxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,CAa7E"}
|
|
@@ -7,7 +7,7 @@ import { boundText, safeSourceUrl, sourceHost, sourceTitle } from "../sources/so
|
|
|
7
7
|
import { citationLabel, citationName, nextCitationMode, wrapIndex } from "./citation.js";
|
|
8
8
|
import { createComponent, insert, memo, template } from "solid-js/web";
|
|
9
9
|
import { ChevronLeft, ChevronRight } from "lucide-solid";
|
|
10
|
-
import { Show, createSignal, onCleanup, splitProps } from "solid-js";
|
|
10
|
+
import { Show, createEffect, createSignal, onCleanup, splitProps } from "solid-js";
|
|
11
11
|
// src/components/composites/inline-citation/inline-citation.tsx
|
|
12
12
|
var _tmpl$ = /*#__PURE__*/ template(`<span aria-hidden=true class="max-w-32 truncate">`);
|
|
13
13
|
var _tmpl$2 = /*#__PURE__*/ template(`<span aria-hidden=true>+`);
|
|
@@ -31,6 +31,18 @@ function InlineCitation(props) {
|
|
|
31
31
|
let content;
|
|
32
32
|
let pressing = false;
|
|
33
33
|
let restoringFocus = false;
|
|
34
|
+
const [keyboardPeek, setKeyboardPeek] = createSignal(false);
|
|
35
|
+
let focusInCard = false;
|
|
36
|
+
let escapeClosedTooltip = false;
|
|
37
|
+
const onWindowKeyDown = (event) => {
|
|
38
|
+
if (event.key !== "Escape") return;
|
|
39
|
+
escapeClosedTooltip = content?.ownerDocument.querySelector("[data-slot=\"tooltip-content\"][data-expanded]") != null;
|
|
40
|
+
};
|
|
41
|
+
createEffect(() => {
|
|
42
|
+
if (mode() !== "pinned" || typeof window === "undefined") return;
|
|
43
|
+
window.addEventListener("keydown", onWindowKeyDown, true);
|
|
44
|
+
onCleanup(() => window.removeEventListener("keydown", onWindowKeyDown, true));
|
|
45
|
+
});
|
|
34
46
|
const count = () => local.sources.length;
|
|
35
47
|
const active = () => local.sources[wrapIndex(position(), count())];
|
|
36
48
|
const clear = () => {
|
|
@@ -38,7 +50,12 @@ function InlineCitation(props) {
|
|
|
38
50
|
timer = void 0;
|
|
39
51
|
};
|
|
40
52
|
onCleanup(clear);
|
|
41
|
-
const dispatch = (event) => setMode((current) =>
|
|
53
|
+
const dispatch = (event) => setMode((current) => {
|
|
54
|
+
const next = nextCitationMode(current, event);
|
|
55
|
+
if (next !== "peek") setKeyboardPeek(false);
|
|
56
|
+
else if (current === "closed") setKeyboardPeek(event === "focus");
|
|
57
|
+
return next;
|
|
58
|
+
});
|
|
42
59
|
const schedule = (event, delay) => {
|
|
43
60
|
clear();
|
|
44
61
|
timer = setTimeout(() => dispatch(event), delay);
|
|
@@ -115,11 +132,27 @@ function InlineCitation(props) {
|
|
|
115
132
|
}
|
|
116
133
|
}), createComponent(PopoverContent, {
|
|
117
134
|
ref: (element) => content = element,
|
|
135
|
+
get inert() {
|
|
136
|
+
return keyboardPeek() || mode() === "closed" || void 0;
|
|
137
|
+
},
|
|
118
138
|
"class": "w-72 max-w-full",
|
|
119
139
|
onOpenAutoFocus: (event) => {
|
|
120
140
|
if (mode() === "peek") event.preventDefault();
|
|
121
141
|
},
|
|
122
|
-
|
|
142
|
+
onFocusIn: () => {
|
|
143
|
+
focusInCard = true;
|
|
144
|
+
},
|
|
145
|
+
onKeyDown: (event) => {
|
|
146
|
+
if (event.key !== "Escape" || escapeClosedTooltip || mode() !== "pinned") return;
|
|
147
|
+
dispatch("dismiss");
|
|
148
|
+
},
|
|
149
|
+
onCloseAutoFocus: (event) => {
|
|
150
|
+
const returnFocus = focusInCard;
|
|
151
|
+
focusInCard = false;
|
|
152
|
+
if (!returnFocus) {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
123
156
|
restoringFocus = true;
|
|
124
157
|
queueMicrotask(() => {
|
|
125
158
|
restoringFocus = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-citation.js","names":["ChevronLeft","ChevronRight","createSignal","onCleanup","Show","splitProps","cn","ActionButton","Button","MessageCitations","Popover","PopoverContent","PopoverTitle","PopoverTrigger","TextLink","SOURCE_SNIPPET_LIMIT","boundText","safeSourceUrl","sourceHost","sourceTitle","Source","citationLabel","citationName","nextCitationMode","wrapIndex","CitationEvent","CitationMode","InlineCitationProps","sources","index","hoverDelay","class","LEAVE_DELAY","InlineCitation","props","local","mode","setMode","position","setPosition","timer","ReturnType","setTimeout","content","HTMLElement","pressing","restoringFocus","count","length","active","clear","undefined","clearTimeout","dispatch","event","current","schedule","delay","onPointerEnter","PointerEvent","pointerType","onPointerLeave","onClick","wasPeeking","queueMicrotask","focus","_$createComponent","when","children","open","onOpenChange","next","placement","gutter","as","variant","size","touchTarget","aria-label","onFocus","FocusEvent","currentTarget","matches","onBlur","_el$","_tmpl$","_$insert","_el$2","_tmpl$2","_el$3","firstChild","ref","element","onOpenAutoFocus","Event","preventDefault","onCloseAutoFocus","source","_el$4","_tmpl$4","_el$5","_tmpl$3","_el$6","_el$7","_el$9","nextSibling","_el$8","_el$0","tooltip","value","CitationDetails","messageCitations","render","numbers","flatMap","number","href","url","host","snippet","withheld","_el$1","_tmpl$5","target","rel","_$memo","_tmpl$8","_tmpl$6","_el$11","_tmpl$7","_$createComponent","_$memo"],"sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from 'lucide-solid'\nimport { createSignal, onCleanup, Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Button } from '../../ui/button'\nimport type { MessageCitations } from '../../ui/message'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { TextLink } from '../../ui/text-link'\nimport {\n SOURCE_SNIPPET_LIMIT,\n boundText,\n safeSourceUrl,\n sourceHost,\n sourceTitle,\n type Source,\n} from '../sources/source'\nimport {\n citationLabel,\n citationName,\n nextCitationMode,\n wrapIndex,\n type CitationEvent,\n type CitationMode,\n} from './citation'\n\n/**\n * InlineCitation.\n *\n * A small badge inside a sentence — \"1\", or a host — that opens the source(s)\n * behind the claim: title, host, address, snippet, and Previous/Next when several\n * sources share one marker. It is an inline element for prose such as\n * `MessageText`: it never breaks across lines, stays on the text baseline, and\n * adds no block of its own. For the list of everything a reply used, reach for\n * `Sources`; the two number sources the same way.\n *\n * ## One popover, two ways to open it\n *\n * A hover card would exclude everyone who is not holding a mouse, so this is a\n * `Popover` that a pointer can also *peek* at:\n *\n * - **Hover or keyboard focus peeks.** The popover opens without taking focus\n * and closes when the pointer or focus leaves. Touch has no hover, so a touch\n * never peeks.\n * - **Click, tap, Enter or Space pins.** Focus moves into the popover so its\n * link and Previous/Next are reachable; it stays until Escape, an outside press,\n * or the badge is pressed again, and focus returns to the badge. Pressing a badge\n * that is only peeking pins it rather than toggling it shut — the transitions\n * are the pure `nextCitationMode`.\n *\n * Kobalte's trigger toggles on every press, so `open` is controlled and its own\n * close request is ignored for the press that we already decided (`pressing`).\n * Without that, hover-then-click, the commonest pointer path, would close the card.\n *\n * ## It makes no claim without sources\n *\n * No sources renders nothing: a marker that points nowhere is not a citation.\n * The address is a link only when `safeSourceUrl` allows it; the host comes from\n * the parsed URL; titles and snippets are clipped, cleaned of direction\n * overrides and rendered as text. The badge's accessible name carries the title\n * and host (the visible label is only a number or a host), so a reader hears\n * what is cited without opening anything.\n */\nexport type InlineCitationProps = {\n /** One source, or several that support the same claim. */\n sources: readonly Source[]\n /**\n * The 1-based number to show, matching the source's position in `Sources`.\n * Omit it to show the host instead; a number is never guessed.\n */\n index?: number\n /** Milliseconds a pointer rests before the peek opens. */\n hoverDelay?: number\n class?: string\n}\n\nconst LEAVE_DELAY = 200\n\nexport function InlineCitation(props: InlineCitationProps) {\n const [local] = splitProps(props, ['sources', 'index', 'hoverDelay', 'class'])\n const [mode, setMode] = createSignal<CitationMode>('closed')\n const [position, setPosition] = createSignal(0)\n let timer: ReturnType<typeof setTimeout> | undefined\n let content: HTMLElement | undefined\n let pressing = false\n // Focus handed back to the badge as the popover closes is not a request to\n // peek again; without this, Escape from a pinned card reopens it as a preview.\n let restoringFocus = false\n\n const count = () => local.sources.length\n const active = () => local.sources[wrapIndex(position(), count())]\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n onCleanup(clear)\n\n const dispatch = (event: CitationEvent) => setMode((current) => nextCitationMode(current, event))\n const schedule = (event: CitationEvent, delay: number) => {\n clear()\n timer = setTimeout(() => dispatch(event), delay)\n }\n\n const onPointerEnter = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('enter', local.hoverDelay ?? 150)\n }\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('leave', LEAVE_DELAY)\n }\n\n const onClick = () => {\n clear()\n const wasPeeking = mode() === 'peek'\n dispatch('press')\n // Kobalte toggles right after this handler; its request is not a dismissal.\n pressing = true\n queueMicrotask(() => {\n pressing = false\n })\n // The peek never took focus; a deliberate press must hand it over.\n if (wasPeeking) queueMicrotask(() => content?.focus())\n }\n\n return (\n <Show when={count() > 0}>\n <Popover\n open={mode() !== 'closed'}\n onOpenChange={(next) => {\n if (!next && !pressing) dispatch('dismiss')\n }}\n placement=\"bottom\"\n gutter={6}\n >\n <PopoverTrigger\n as={Button}\n variant=\"subtle\"\n size=\"2xs\"\n touchTarget=\"comfortable\"\n data-slot=\"inline-citation\"\n aria-label={citationName(local.sources, local.index)}\n class={cn('mx-0.5 align-baseline tabular-nums', local.class)}\n onClick={onClick}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {\n // Mouse focus follows the press; only keyboard focus peeks.\n if (restoringFocus) return\n if (event.currentTarget.matches(':focus-visible')) dispatch('focus')\n }}\n onBlur={() => dispatch('blur')}\n >\n <span aria-hidden=\"true\" class=\"max-w-32 truncate\">\n {citationLabel(local.index, local.sources[0])}\n </span>\n <Show when={count() > 1}>\n <span aria-hidden=\"true\">+{count() - 1}</span>\n </Show>\n </PopoverTrigger>\n <PopoverContent\n ref={(element: HTMLElement) => (content = element)}\n class=\"w-72 max-w-full\"\n onOpenAutoFocus={(event: Event) => {\n if (mode() === 'peek') event.preventDefault()\n }}\n onCloseAutoFocus={() => {\n // The focus move that follows is synchronous; the microtask ends the window.\n restoringFocus = true\n queueMicrotask(() => {\n restoringFocus = false\n })\n }}\n onPointerEnter={(event: PointerEvent) => {\n if (event.pointerType !== 'touch') clear()\n }}\n onPointerLeave={onPointerLeave}\n >\n <Show when={active()}>\n {(source) => (\n <div class=\"flex min-w-0 flex-col gap-1.5 px-2 py-1.5\">\n <Show when={count() > 1}>\n <div class=\"flex items-center justify-between gap-2\">\n <span\n role=\"status\"\n aria-live=\"polite\"\n class=\"text-xs text-muted-foreground tabular-nums\"\n >\n Source {wrapIndex(position(), count()) + 1} of {count()}\n </span>\n <span class=\"flex items-center gap-0.5\">\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Previous source\"\n tooltip=\"Previous source\"\n onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}\n >\n <ChevronLeft />\n </ActionButton>\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Next source\"\n tooltip=\"Next source\"\n onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}\n >\n <ChevronRight />\n </ActionButton>\n </span>\n </div>\n </Show>\n <PopoverTitle class=\"p-0 [overflow-wrap:anywhere]\">\n {sourceTitle(source())}\n </PopoverTitle>\n <CitationDetails source={source()} />\n </div>\n )}\n </Show>\n </PopoverContent>\n </Popover>\n </Show>\n )\n}\n\n/**\n * Citation markers for `MessageText`, from the sources a reply really used.\n *\n * `[^2]` in the text becomes the second source's badge; `[^1,3]` one badge for\n * sources 1 and 3. A number beyond the list leaves the marker as written, and an\n * empty list makes every marker literal, so text can never cite a source the host\n * did not supply.\n *\n * <MessageText text={reply} citations={messageCitations(sources)} />\n */\nexport function messageCitations(sources: readonly Source[]): MessageCitations {\n return {\n count: sources.length,\n render: (numbers) => (\n <InlineCitation\n index={numbers[0]}\n sources={numbers.flatMap((number) => {\n const source = sources[number - 1]\n return source ? [source] : []\n })}\n />\n ),\n }\n}\n\nfunction CitationDetails(props: { source: Source }) {\n const href = () => safeSourceUrl(props.source.url)\n const host = () => sourceHost(props.source.url)\n const snippet = () =>\n props.source.snippet ? boundText(props.source.snippet, SOURCE_SNIPPET_LIMIT) : ''\n const withheld = () => props.source.url !== undefined && props.source.url !== '' && !href()\n\n return (\n <>\n <Show when={host()}>\n <p class=\"m-0 text-xs text-muted-foreground [overflow-wrap:anywhere]\">{host()}</p>\n </Show>\n <Show when={href()}>\n {(url) => (\n <TextLink\n href={url()}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"w-fit max-w-full text-xs [overflow-wrap:anywhere]\"\n >\n {boundText(url(), 96)}\n <span class=\"visually-hidden\"> (opens in a new tab)</span>\n </TextLink>\n )}\n </Show>\n <Show when={withheld()}>\n <p class=\"m-0 text-xs text-muted-foreground\">Address not linked</p>\n </Show>\n <Show when={snippet()}>\n <p class=\"m-0 line-clamp-6 text-xs text-muted-foreground [overflow-wrap:anywhere]\">\n {snippet()}\n </p>\n </Show>\n </>\n )\n}\n"],"mappings":";;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AAC;GAAAhD,WACdiD,QAAGnD,gBACFpD,UAAQ;IAAA,IACPsG,OAAI;KAAA,OAAEC,IAAI;IAAC;IACXM,QAAM;IACNC,KAAG;IAAA,SAAA;IAAA,IAAAxD,WAAA;KAAA,OAAA,CAAAyD,WAGF7G,UAAUqG,IAAI,GAAG,EAAE,CAAC,GAAAS,QAAA,CAAA;IAAA;GAAA,CAAA;EAGxB,CAAA;EAAA5D,gBAEF9D,MAAI;GAAA,IAAC+D,OAAI;IAAA,OAAEqD,SAAS;GAAC;GAAA,IAAApD,WAAA;IAAA,OAAA2D,QAAA;GAAA;EAAA,CAAA;EAAA7D,gBAGrB9D,MAAI;GAAA,IAAC+D,OAAI;IAAA,OAAEoD,QAAQ;GAAC;GAAA,IAAAnD,WAAA;IAAA,IAAA4D,SAAAC,QAAA;IAAA3C,OAAA0C,QAEhBT,OAAO;IAAA,OAAAS;GAAA;EAAA,CAAA;CAAA;AAKlB"}
|
|
1
|
+
{"version":3,"file":"inline-citation.js","names":["ChevronLeft","ChevronRight","createEffect","createSignal","onCleanup","Show","splitProps","cn","ActionButton","Button","MessageCitations","Popover","PopoverContent","PopoverTitle","PopoverTrigger","TextLink","SOURCE_SNIPPET_LIMIT","boundText","safeSourceUrl","sourceHost","sourceTitle","Source","citationLabel","citationName","nextCitationMode","wrapIndex","CitationEvent","CitationMode","InlineCitationProps","sources","index","hoverDelay","class","LEAVE_DELAY","InlineCitation","props","local","mode","setMode","position","setPosition","timer","ReturnType","setTimeout","content","HTMLElement","pressing","restoringFocus","keyboardPeek","setKeyboardPeek","focusInCard","escapeClosedTooltip","onWindowKeyDown","event","KeyboardEvent","key","ownerDocument","querySelector","window","addEventListener","removeEventListener","count","length","active","clear","undefined","clearTimeout","dispatch","current","next","schedule","delay","onPointerEnter","PointerEvent","pointerType","onPointerLeave","onClick","wasPeeking","queueMicrotask","focus","_$createComponent","when","children","open","onOpenChange","placement","gutter","as","variant","size","touchTarget","aria-label","onFocus","FocusEvent","currentTarget","matches","onBlur","_el$","_tmpl$","_$insert","_el$2","_tmpl$2","_el$3","firstChild","ref","element","inert","onOpenAutoFocus","Event","preventDefault","onFocusIn","onKeyDown","onCloseAutoFocus","returnFocus","source","_el$4","_tmpl$4","_el$5","_tmpl$3","_el$6","_el$7","_el$9","nextSibling","_el$8","_el$0","tooltip","value","CitationDetails","messageCitations","render","numbers","flatMap","number","href","url","host","snippet","withheld","_el$1","_tmpl$5","target","rel","_$memo","_tmpl$8","_tmpl$6","_el$11","_tmpl$7","_$createComponent","_$memo"],"sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from 'lucide-solid'\nimport { createEffect, createSignal, onCleanup, Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Button } from '../../ui/button'\nimport type { MessageCitations } from '../../ui/message'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { TextLink } from '../../ui/text-link'\nimport {\n SOURCE_SNIPPET_LIMIT,\n boundText,\n safeSourceUrl,\n sourceHost,\n sourceTitle,\n type Source,\n} from '../sources/source'\nimport {\n citationLabel,\n citationName,\n nextCitationMode,\n wrapIndex,\n type CitationEvent,\n type CitationMode,\n} from './citation'\n\n/**\n * InlineCitation.\n *\n * A small badge inside a sentence — \"1\", or a host — that opens the source(s)\n * behind the claim: title, host, address, snippet, and Previous/Next when several\n * sources share one marker. It is an inline element for prose such as\n * `MessageText`: it never breaks across lines, stays on the text baseline, and\n * adds no block of its own. For the list of everything a reply used, reach for\n * `Sources`; the two number sources the same way.\n *\n * ## One popover, two ways to open it\n *\n * A hover card would exclude everyone who is not holding a mouse, so this is a\n * `Popover` that a pointer can also *peek* at:\n *\n * - **Hover or keyboard focus peeks.** The popover opens without taking focus\n * and closes when the pointer or focus leaves. Touch has no hover, so a touch\n * never peeks. A keyboard peek's card is inert, so Tab moves on from the badge\n * to the next control on the page instead of into a card that is closing.\n * - **Click, tap, Enter or Space pins.** Focus moves into the popover so its\n * link and Previous/Next are reachable; it stays until Escape, an outside press,\n * or the badge is pressed again, and focus returns to the badge. Pressing a badge\n * that is only peeking pins it rather than toggling it shut — the transitions\n * are the pure `nextCitationMode`.\n *\n * Kobalte's trigger toggles on every press, so `open` is controlled and its own\n * close request is ignored for the press that we already decided (`pressing`).\n * Without that, hover-then-click, the commonest pointer path, would close the card.\n *\n * ## It makes no claim without sources\n *\n * No sources renders nothing: a marker that points nowhere is not a citation.\n * The address is a link only when `safeSourceUrl` allows it; the host comes from\n * the parsed URL; titles and snippets are clipped, cleaned of direction\n * overrides and rendered as text. The badge's accessible name carries the title\n * and host (the visible label is only a number or a host), so a reader hears\n * what is cited without opening anything.\n */\nexport type InlineCitationProps = {\n /** One source, or several that support the same claim. */\n sources: readonly Source[]\n /**\n * The 1-based number to show, matching the source's position in `Sources`.\n * Omit it to show the host instead; a number is never guessed.\n */\n index?: number\n /** Milliseconds a pointer rests before the peek opens. */\n hoverDelay?: number\n class?: string\n}\n\nconst LEAVE_DELAY = 200\n\nexport function InlineCitation(props: InlineCitationProps) {\n const [local] = splitProps(props, ['sources', 'index', 'hoverDelay', 'class'])\n const [mode, setMode] = createSignal<CitationMode>('closed')\n const [position, setPosition] = createSignal(0)\n let timer: ReturnType<typeof setTimeout> | undefined\n let content: HTMLElement | undefined\n let pressing = false\n // Focus handed back to the badge as the popover closes is not a request to\n // peek again; without this, Escape from a pinned card reopens it as a preview.\n let restoringFocus = false\n // A keyboard peek is a preview of the badge the reader is already on. Its card\n // sits in a portal at the end of the document, so if it stayed tabbable, Tab\n // from the badge would walk into the card, the card would close behind the\n // focus as the badge blurred, and focus would fall to <body> and be pulled\n // back to the badge: a keyboard trap. The card is inert until Enter or Space\n // pins it, and while it closes. A pointer peek stays interactive.\n const [keyboardPeek, setKeyboardPeek] = createSignal(false)\n // Focus goes back to the badge only when it was in the card. A peek never\n // held focus, and its close (finishing after its exit animation) must not\n // pull the reader back from wherever Tab has taken them since.\n let focusInCard = false\n // Escape closes the innermost layer first: an open Previous/Next tooltip, then\n // the card. Kobalte only lets the top-most layer take Escape, and a tooltip\n // that just closed stays the top layer while it animates out, so a second\n // Escape pressed during that exit used to vanish and leave the card open.\n // Whether a tooltip was open is read before any handler runs (window,\n // capture); an Escape that closed nothing else closes the card itself.\n let escapeClosedTooltip = false\n const onWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n escapeClosedTooltip =\n content?.ownerDocument.querySelector('[data-slot=\"tooltip-content\"][data-expanded]') != null\n }\n createEffect(() => {\n if (mode() !== 'pinned' || typeof window === 'undefined') return\n window.addEventListener('keydown', onWindowKeyDown, true)\n onCleanup(() => window.removeEventListener('keydown', onWindowKeyDown, true))\n })\n\n const count = () => local.sources.length\n const active = () => local.sources[wrapIndex(position(), count())]\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n onCleanup(clear)\n\n const dispatch = (event: CitationEvent) =>\n setMode((current) => {\n const next = nextCitationMode(current, event)\n if (next !== 'peek') setKeyboardPeek(false)\n else if (current === 'closed') setKeyboardPeek(event === 'focus')\n return next\n })\n const schedule = (event: CitationEvent, delay: number) => {\n clear()\n timer = setTimeout(() => dispatch(event), delay)\n }\n\n const onPointerEnter = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('enter', local.hoverDelay ?? 150)\n }\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('leave', LEAVE_DELAY)\n }\n\n const onClick = () => {\n clear()\n const wasPeeking = mode() === 'peek'\n dispatch('press')\n // Kobalte toggles right after this handler; its request is not a dismissal.\n pressing = true\n queueMicrotask(() => {\n pressing = false\n })\n // The peek never took focus; a deliberate press must hand it over.\n if (wasPeeking) queueMicrotask(() => content?.focus())\n }\n\n return (\n <Show when={count() > 0}>\n <Popover\n open={mode() !== 'closed'}\n onOpenChange={(next) => {\n if (!next && !pressing) dispatch('dismiss')\n }}\n placement=\"bottom\"\n gutter={6}\n >\n <PopoverTrigger\n as={Button}\n variant=\"subtle\"\n size=\"2xs\"\n touchTarget=\"comfortable\"\n data-slot=\"inline-citation\"\n aria-label={citationName(local.sources, local.index)}\n class={cn('mx-0.5 align-baseline tabular-nums', local.class)}\n onClick={onClick}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {\n // Mouse focus follows the press; only keyboard focus peeks.\n if (restoringFocus) return\n if (event.currentTarget.matches(':focus-visible')) dispatch('focus')\n }}\n onBlur={() => dispatch('blur')}\n >\n <span aria-hidden=\"true\" class=\"max-w-32 truncate\">\n {citationLabel(local.index, local.sources[0])}\n </span>\n <Show when={count() > 1}>\n <span aria-hidden=\"true\">+{count() - 1}</span>\n </Show>\n </PopoverTrigger>\n <PopoverContent\n ref={(element: HTMLElement) => (content = element)}\n inert={keyboardPeek() || mode() === 'closed' || undefined}\n class=\"w-72 max-w-full\"\n onOpenAutoFocus={(event: Event) => {\n if (mode() === 'peek') event.preventDefault()\n }}\n onFocusIn={() => {\n focusInCard = true\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return\n dispatch('dismiss')\n }}\n onCloseAutoFocus={(event: Event) => {\n const returnFocus = focusInCard\n focusInCard = false\n if (!returnFocus) {\n event.preventDefault()\n return\n }\n // The focus move that follows is synchronous; the microtask ends the window.\n restoringFocus = true\n queueMicrotask(() => {\n restoringFocus = false\n })\n }}\n onPointerEnter={(event: PointerEvent) => {\n if (event.pointerType !== 'touch') clear()\n }}\n onPointerLeave={onPointerLeave}\n >\n <Show when={active()}>\n {(source) => (\n <div class=\"flex min-w-0 flex-col gap-1.5 px-2 py-1.5\">\n <Show when={count() > 1}>\n <div class=\"flex items-center justify-between gap-2\">\n <span\n role=\"status\"\n aria-live=\"polite\"\n class=\"text-xs text-muted-foreground tabular-nums\"\n >\n Source {wrapIndex(position(), count()) + 1} of {count()}\n </span>\n <span class=\"flex items-center gap-0.5\">\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Previous source\"\n tooltip=\"Previous source\"\n onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}\n >\n <ChevronLeft />\n </ActionButton>\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Next source\"\n tooltip=\"Next source\"\n onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}\n >\n <ChevronRight />\n </ActionButton>\n </span>\n </div>\n </Show>\n <PopoverTitle class=\"p-0 [overflow-wrap:anywhere]\">\n {sourceTitle(source())}\n </PopoverTitle>\n <CitationDetails source={source()} />\n </div>\n )}\n </Show>\n </PopoverContent>\n </Popover>\n </Show>\n )\n}\n\n/**\n * Citation markers for `MessageText`, from the sources a reply really used.\n *\n * `[^2]` in the text becomes the second source's badge; `[^1,3]` one badge for\n * sources 1 and 3. A number beyond the list leaves the marker as written, and an\n * empty list makes every marker literal, so text can never cite a source the host\n * did not supply.\n *\n * <MessageText text={reply} citations={messageCitations(sources)} />\n */\nexport function messageCitations(sources: readonly Source[]): MessageCitations {\n return {\n count: sources.length,\n render: (numbers) => (\n <InlineCitation\n index={numbers[0]}\n sources={numbers.flatMap((number) => {\n const source = sources[number - 1]\n return source ? [source] : []\n })}\n />\n ),\n }\n}\n\nfunction CitationDetails(props: { source: Source }) {\n const href = () => safeSourceUrl(props.source.url)\n const host = () => sourceHost(props.source.url)\n const snippet = () =>\n props.source.snippet ? boundText(props.source.snippet, SOURCE_SNIPPET_LIMIT) : ''\n const withheld = () => props.source.url !== undefined && props.source.url !== '' && !href()\n\n return (\n <>\n <Show when={host()}>\n <p class=\"m-0 text-xs text-muted-foreground [overflow-wrap:anywhere]\">{host()}</p>\n </Show>\n <Show when={href()}>\n {(url) => (\n <TextLink\n href={url()}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"w-fit max-w-full text-xs [overflow-wrap:anywhere]\"\n >\n {boundText(url(), 96)}\n <span class=\"visually-hidden\"> (opens in a new tab)</span>\n </TextLink>\n )}\n </Show>\n <Show when={withheld()}>\n <p class=\"m-0 text-xs text-muted-foreground\">Address not linked</p>\n </Show>\n <Show when={snippet()}>\n <p class=\"m-0 line-clamp-6 text-xs text-muted-foreground [overflow-wrap:anywhere]\">\n {snippet()}\n </p>\n </Show>\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4EA,IAAMiC,cAAc;AAEpB,SAAgBC,eAAeC,OAA4B;CACzD,MAAM,CAACC,SAAS9B,WAAW6B,OAAO;EAAC;EAAW;EAAS;EAAc;CAAO,CAAC;CAC7E,MAAM,CAACE,MAAMC,WAAWnC,aAA2B,QAAQ;CAC3D,MAAM,CAACoC,UAAUC,eAAerC,aAAa,CAAC;CAC9C,IAAIsC;CACJ,IAAIG;CACJ,IAAIE,WAAW;CAGf,IAAIC,iBAAiB;CAOrB,MAAM,CAACC,cAAcC,mBAAmB9C,aAAa,KAAK;CAI1D,IAAI+C,cAAc;CAOlB,IAAIC,sBAAsB;CAC1B,MAAMC,mBAAmBC,UAAyB;EAChD,IAAIA,MAAME,QAAQ,UAAU;EAC5BJ,sBACEP,SAASY,cAAcC,cAAc,gDAA8C,KAAK;CAC5F;CACAvD,mBAAmB;EACjB,IAAImC,KAAK,MAAM,YAAY,OAAOqB,WAAW,aAAa;EAC1DA,OAAOC,iBAAiB,WAAWP,iBAAiB,IAAI;EACxDhD,gBAAgBsD,OAAOE,oBAAoB,WAAWR,iBAAiB,IAAI,CAAC;CAC9E,CAAC;CAED,MAAMS,cAAczB,MAAMP,QAAQiC;CAClC,MAAMC,eAAe3B,MAAMP,QAAQJ,UAAUc,SAAS,GAAGsB,MAAM,CAAC;CAChE,MAAMG,cAAc;EAClB,IAAIvB,UAAUwB,KAAAA,GAAWC,aAAazB,KAAK;EAC3CA,QAAQwB,KAAAA;CACV;CACA7D,UAAU4D,KAAK;CAEf,MAAMG,YAAYd,UAChBf,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,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC5B,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,KAAK,sBAAsB,CAAC,KAAK,SAAS,MAAM,IAAI,uBAAuB,GAAG;IAC5E,iBAAiB,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,KAAK,CAAA;IAC5D,QAAQ,EAAE,CAAC,KAAK,EAAE,uBAAuB,GAAG,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1E,WAAW,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,GAAG,CAAC,OAAO,CAAA;CAClE,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"chat-composer-shell.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/internal/chat-composer-shell.tsx"],"names":[],"mappings":"AAOA,OAAO,EAOL,KAAK,QAAQ,EACb,KAAK,GAAG,EACT,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAEV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,kBAAkB,CAAA;AAYzB,6EAA6E;AAC7E,KAAK,4BAA4B,GAAG;IAClC,GAAG,EAAE,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,KAAK,IAAI,CAAA;IACvD,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACvB,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC3B,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5B,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC7B,QAAQ,EAAE,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;IACvC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC3B,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC5B,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,KAAK,sBAAsB,CAAC,KAAK,SAAS,MAAM,IAAI,uBAAuB,GAAG;IAC5E,iBAAiB,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,KAAK,CAAA;IAC5D,QAAQ,EAAE,CAAC,KAAK,EAAE,uBAAuB,GAAG,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1E,WAAW,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,GAAG,CAAC,OAAO,CAAA;CAClE,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,eAmW3F"}
|
|
@@ -3,7 +3,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
|
|
|
3
3
|
import { Spinner } from "../../ui/spinner/spinner.js";
|
|
4
4
|
import { BusySendButton } from "../busy-send-button.js";
|
|
5
5
|
import { createComposerImeGuard } from "../ime-guard.js";
|
|
6
|
-
import { createComponent, insert, memo, mergeProps, template } from "solid-js/web";
|
|
6
|
+
import { createComponent, insert, memo, mergeProps, template, use } from "solid-js/web";
|
|
7
7
|
import { ArrowUp, ChevronsDownUp, ChevronsUpDown, MoreHorizontal } from "lucide-solid";
|
|
8
8
|
import { Show, createEffect, createSignal, on, onCleanup, onMount } from "solid-js";
|
|
9
9
|
// src/components/conversation/internal/chat-composer-shell.tsx
|
|
@@ -39,6 +39,7 @@ function ChatComposerShell(props) {
|
|
|
39
39
|
const [error, setError] = createSignal(null);
|
|
40
40
|
let field;
|
|
41
41
|
let restoreBar;
|
|
42
|
+
let root;
|
|
42
43
|
let focusFrame;
|
|
43
44
|
let focusTarget;
|
|
44
45
|
let selection;
|
|
@@ -54,9 +55,16 @@ function ChatComposerShell(props) {
|
|
|
54
55
|
const requestFocus = (target) => {
|
|
55
56
|
cancelFocus();
|
|
56
57
|
focusTarget = target;
|
|
58
|
+
const requester = document.activeElement;
|
|
57
59
|
focusFrame = requestAnimationFrame(() => {
|
|
58
60
|
focusFrame = void 0;
|
|
59
61
|
if (!active || props.approvalFocus) return;
|
|
62
|
+
const current = document.activeElement;
|
|
63
|
+
if (current && current !== document.body && current !== requester && !root?.contains(current)) {
|
|
64
|
+
focusTarget = void 0;
|
|
65
|
+
if (target === "input") selection = void 0;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
60
68
|
if (target === "bar" && collapsed()) restoreBar?.focus();
|
|
61
69
|
if (target === "input" && !collapsed() && !props.disabled && field) {
|
|
62
70
|
field.focus();
|
|
@@ -65,6 +73,16 @@ function ChatComposerShell(props) {
|
|
|
65
73
|
focusTarget = void 0;
|
|
66
74
|
});
|
|
67
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* A press or key in the input before the deferred expand restore runs is a
|
|
78
|
+
* newer selection owner: the restore must not move its caret back.
|
|
79
|
+
*/
|
|
80
|
+
const yieldInputRestore = () => {
|
|
81
|
+
if (focusTarget !== "input") return;
|
|
82
|
+
cancelFocus();
|
|
83
|
+
focusTarget = void 0;
|
|
84
|
+
selection = void 0;
|
|
85
|
+
};
|
|
68
86
|
const changeCollapsed = (value) => {
|
|
69
87
|
if (!props.collapse || props.approvalFocus) return;
|
|
70
88
|
if (value && field) selection = {
|
|
@@ -133,6 +151,7 @@ function ChatComposerShell(props) {
|
|
|
133
151
|
return first.length > 120 ? `${first.slice(0, 120)}…` : first;
|
|
134
152
|
};
|
|
135
153
|
const handleInputKeyDown = (event) => {
|
|
154
|
+
yieldInputRestore();
|
|
136
155
|
if (event.key === "Escape" && error()) {
|
|
137
156
|
setError(null);
|
|
138
157
|
return;
|
|
@@ -157,6 +176,7 @@ function ChatComposerShell(props) {
|
|
|
157
176
|
};
|
|
158
177
|
return (() => {
|
|
159
178
|
var _el$ = _tmpl$1(), _el$5 = _el$.firstChild;
|
|
179
|
+
use((element) => root = element, _el$);
|
|
160
180
|
insert(_el$, createComponent(Show, {
|
|
161
181
|
get when() {
|
|
162
182
|
return !props.approvalFocus;
|
|
@@ -298,9 +318,13 @@ function ChatComposerShell(props) {
|
|
|
298
318
|
insert(_el$9, () => props.renderInput({
|
|
299
319
|
ref: (element) => {
|
|
300
320
|
field = element;
|
|
301
|
-
if (element)
|
|
302
|
-
|
|
303
|
-
|
|
321
|
+
if (element) {
|
|
322
|
+
element.addEventListener("pointerdown", yieldInputRestore);
|
|
323
|
+
onCleanup(() => {
|
|
324
|
+
element.removeEventListener("pointerdown", yieldInputRestore);
|
|
325
|
+
if (field === element) field = void 0;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
304
328
|
},
|
|
305
329
|
value: () => props.value,
|
|
306
330
|
resetKey: () => props.resetKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-composer-shell.js","names":["ChevronsDownUp","ChevronsUpDown","MoreHorizontal","ArrowUp","Show","createEffect","createSignal","on","onCleanup","onMount","Accessor","JSX","ChatComposerControl","ChatComposerSharedProps","ChatComposerSubmitInput","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","Spinner","BusySendButton","BusySendMode","createComposerImeGuard","ChatComposerInputRenderProps","ref","element","HTMLTextAreaElement","value","resetKey","inputLabel","placeholder","disabled","readOnly","composing","onCompositionStart","onCompositionEnd","onFocus","onBlur","onKeyDown","event","KeyboardEvent","ChatComposerShellProps","createSubmitExtra","input","Extra","onSubmit","Promise","renderInput","props","Element","ChatComposerShell","ime","pending","setPending","error","setError","field","restoreBar","HTMLButtonElement","focusFrame","focusTarget","selection","start","end","direction","generation","active","collapsed","collapse","unavailable","blockedReason","cancelFocus","undefined","cancelAnimationFrame","requestFocus","target","requestAnimationFrame","approvalFocus","focus","setSelectionRange","Math","min","length","changeCollapsed","selectionStart","selectionEnd","selectionDirection","onChange","control","expandAndFocus","controlRef","defer","action","busy","mode","canSend","selected","sendableActions","trim","submit","started","base","text","preview","first","split","find","line","slice","handleInputKeyDown","key","shiftKey","defaultPrevented","claimEnter","metaKey","ctrlKey","handleCompositionStart","handleCompositionEnd","handleBlur","_el$","_tmpl$1","_el$5","firstChild","_$insert","_$createComponent","when","children","knowledge","_el$2","_tmpl$","followUps","_el$3","_tmpl$2","band","_el$4","_tmpl$3","approval","_el$6","_tmpl$4","notices","_el$7","_tmpl$5","_el$8","_tmpl$6","message","_el$14","_tmpl$10","fallback","type","variant","size","aria-label","onClick","_tmpl$11","_el$16","_tmpl$12","_el$9","_tmpl$9","_el$1","_el$10","_el$12","nextSibling","addEventListener","preventDefault","attachments","_el$0","_tmpl$7","menuItems","placement","as","onCloseAutoFocus","_$memo","onSelect","_tmpl$8","leadingActions","trailingActions","label","_$mergeProps","alternateActionHint","onFire","context","_el$13","_tmpl$0","_$createComponent","_$memo","_$mergeProps"],"sources":["../../../../src/components/conversation/internal/chat-composer-shell.tsx"],"sourcesContent":["/*\n * Substantially translated from KiroCrew website/src/components/ChatInput.tsx\n * at 283e136c0f902e965a535a7c9548c57c7504fed0.\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * Licensed under Apache-2.0; see LICENSE and NOTICE.\n */\nimport { ChevronsDownUp, ChevronsUpDown, MoreHorizontal, ArrowUp } from 'lucide-solid'\nimport {\n Show,\n createEffect,\n createSignal,\n on,\n onCleanup,\n onMount,\n type Accessor,\n type JSX,\n} from 'solid-js'\nimport type {\n ChatComposerControl,\n ChatComposerSharedProps,\n ChatComposerSubmitInput,\n} from '../chat-composer'\nimport { Button } from '../../ui/button/button'\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../../ui/dropdown-menu/dropdown-menu'\nimport { Spinner } from '../../ui/spinner/spinner'\nimport { BusySendButton, type BusySendMode } from '../busy-send-button'\nimport { createComposerImeGuard } from '../ime-guard'\n\n/** Private typed seam: public wrappers supply the native or atomic input. */\ntype ChatComposerInputRenderProps = {\n ref: (element: HTMLTextAreaElement | undefined) => void\n value: Accessor<string>\n resetKey: Accessor<unknown>\n inputLabel: Accessor<string>\n placeholder: Accessor<string>\n disabled: Accessor<boolean | undefined>\n readOnly: Accessor<boolean>\n composing: Accessor<boolean>\n onCompositionStart: () => void\n onCompositionEnd: () => void\n onFocus: () => void\n onBlur: () => void\n onKeyDown: (event: KeyboardEvent) => void\n}\n\ntype ChatComposerShellProps<Extra extends object> = ChatComposerSharedProps & {\n createSubmitExtra: (input: ChatComposerSubmitInput) => Extra\n onSubmit: (input: ChatComposerSubmitInput & Extra) => void | Promise<void>\n renderInput: (props: ChatComposerInputRenderProps) => JSX.Element\n}\n\n/**\n * Kiro's composer assembly: context/options, adjacent band, approval/notices,\n * staged content, input/action groups and a context shelf. Reading collapse\n * really unmounts the input and shelf and offers a labeled way back with draft\n * preview. The host retains the only draft, identities, preferences and services.\n *\n * Kobalte owns the options menu. Scoped imperative typing intent replaces the\n * donor global lookup/broadcast so a second composer cannot receive this draft\n * or focus. No animation starts from hidden geometry, no global shortcut, and no\n * runtime/permission/voice/optimizer authority is copied. More specific chips,\n * approval decisions and staged-content semantics are supplied by their owners.\n */\nexport function ChatComposerShell<Extra extends object>(props: ChatComposerShellProps<Extra>) {\n const ime = createComposerImeGuard()\n const [pending, setPending] = createSignal(false)\n const [error, setError] = createSignal<string | null>(null)\n let field: HTMLTextAreaElement | undefined\n let restoreBar: HTMLButtonElement | undefined\n let focusFrame: number | undefined\n let focusTarget: 'input' | 'bar' | undefined\n let selection:\n | { start: number; end: number; direction: 'forward' | 'backward' | 'none' }\n | undefined\n let generation = 0\n let active = true\n let composing = false\n const collapsed = () => props.collapse?.value === true\n const unavailable = () => props.disabled || props.readOnly || !!props.blockedReason\n const cancelFocus = () => {\n if (focusFrame !== undefined) cancelAnimationFrame(focusFrame)\n focusFrame = undefined\n }\n const requestFocus = (target: 'input' | 'bar') => {\n cancelFocus()\n focusTarget = target\n focusFrame = requestAnimationFrame(() => {\n focusFrame = undefined\n if (!active || props.approvalFocus) return\n if (target === 'bar' && collapsed()) restoreBar?.focus()\n if (target === 'input' && !collapsed() && !props.disabled && field) {\n field.focus()\n if (selection)\n field.setSelectionRange(\n Math.min(selection.start, field.value.length),\n Math.min(selection.end, field.value.length),\n selection.direction\n )\n }\n focusTarget = undefined\n })\n }\n const changeCollapsed = (value: boolean) => {\n if (!props.collapse || props.approvalFocus) return\n if (value && field)\n selection = {\n start: field.selectionStart,\n end: field.selectionEnd,\n direction: field.selectionDirection,\n }\n props.collapse.onChange(value)\n requestFocus(value ? 'bar' : 'input')\n }\n const control: ChatComposerControl = {\n focus() {\n if (collapsed() || props.approvalFocus || props.disabled || !field) return false\n field.focus()\n return true\n },\n expandAndFocus() {\n if (props.approvalFocus || props.disabled) return false\n if (collapsed()) changeCollapsed(false)\n else requestFocus('input')\n return true\n },\n }\n onMount(() => props.controlRef?.(control))\n createEffect(\n on(\n () => props.resetKey,\n () => {\n generation += 1\n selection = undefined\n composing = false\n cancelFocus()\n focusTarget = undefined\n setPending(false)\n setError(null)\n ime.onBlur()\n },\n { defer: true }\n )\n )\n onCleanup(() => {\n active = false\n generation += 1\n cancelFocus()\n props.controlRef?.(undefined)\n })\n const action = (): 'send' | BusySendMode => props.busy?.mode ?? 'send'\n const canSend = (selected: 'send' | BusySendMode = action()) =>\n !unavailable() &&\n !pending() &&\n (props.sendableActions?.[selected] ?? props.value.trim().length > 0) &&\n !(selected !== 'send' && props.busy?.unavailable?.[selected])\n const submit = async (selected: 'send' | BusySendMode = action()) => {\n if (!canSend(selected)) return\n const started = generation\n const base: ChatComposerSubmitInput = { text: props.value, action: selected }\n const input = { ...base, ...props.createSubmitExtra(base) }\n setPending(true)\n setError(null)\n try {\n await props.onSubmit(input)\n } catch {\n if (active && started === generation)\n setError('Message not sent. Check your draft and retry when the connection recovers.')\n } finally {\n if (active && started === generation) setPending(false)\n }\n }\n const preview = () => {\n const first =\n props.value\n .split('\\n')\n .find((line) => line.trim().length > 0)\n ?.trim() ?? ''\n return first.length > 120 ? `${first.slice(0, 120)}…` : first\n }\n const handleInputKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && error()) {\n setError(null)\n return\n }\n if (event.key !== 'Enter' || event.shiftKey || event.defaultPrevented) return\n if (ime.claimEnter(event)) {\n const selected =\n props.busy && (event.metaKey || event.ctrlKey)\n ? props.busy.mode === 'steer'\n ? 'queue'\n : 'steer'\n : action()\n void submit(selected)\n }\n }\n const handleCompositionStart = () => {\n composing = true\n ime.onCompositionStart()\n }\n const handleCompositionEnd = () => {\n composing = false\n ime.onCompositionEnd()\n }\n const handleBlur = () => {\n composing = false\n ime.onBlur()\n }\n return (\n <div data-slot=\"chat-composer\" class=\"mx-auto flex w-full max-w-4xl flex-col px-4 pb-1\">\n <Show when={!props.approvalFocus}>\n <Show when={props.knowledge}>\n <div data-slot=\"composer-knowledge\">{props.knowledge}</div>\n </Show>\n <Show when={props.followUps}>\n <div data-slot=\"composer-follow-ups\">{props.followUps}</div>\n </Show>\n </Show>\n <Show when={props.band}>\n <div data-slot=\"composer-band\">{props.band}</div>\n </Show>\n <div aria-hidden=\"true\" class=\"h-1.5 shrink-0\" />\n <Show when={props.approval}>\n <div data-slot=\"composer-approval\">{props.approval}</div>\n </Show>\n <Show when={props.notices}>\n <div data-slot=\"composer-notices\">{props.notices}</div>\n </Show>\n <Show when={props.blockedReason}>\n <p role=\"status\" class=\"text-muted-foreground mb-1 text-xs\">\n {props.blockedReason}\n </p>\n </Show>\n <Show when={error()}>\n {(message) => (\n <p role=\"alert\" class=\"text-foreground mb-1 border-s-2 border-destructive ps-2 text-xs\">\n {message()}\n </p>\n )}\n </Show>\n <Show when={!props.approvalFocus}>\n <Show\n when={!collapsed()}\n fallback={\n <Button\n ref={(element) => {\n restoreBar = element\n onCleanup(() => {\n if (restoreBar === element) restoreBar = undefined\n })\n }}\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n class=\"w-full justify-start\"\n aria-expanded={false}\n aria-label={`Show the message input${preview() ? `: ${preview()}` : ''}`}\n onClick={() => changeCollapsed(false)}\n >\n <ChevronsUpDown />\n <span aria-hidden=\"true\" class=\"shrink-0\">\n Show the message input\n </span>{' '}\n <Show when={preview()}>\n <span aria-hidden=\"true\" class=\"min-w-0 flex-1 truncate\">\n {preview()}\n </span>\n </Show>\n </Button>\n }\n >\n <form\n data-slot=\"composer-input-box\"\n class=\"border-input bg-card flex flex-col overflow-hidden rounded-2xl border transition-colors focus-within:border-ring\"\n onSubmit={(event) => {\n event.preventDefault()\n void submit()\n }}\n >\n <Show when={props.attachments}>\n <div data-slot=\"composer-staged-content\">{props.attachments}</div>\n </Show>\n {props.renderInput({\n ref: (element) => {\n field = element\n if (element)\n onCleanup(() => {\n if (field === element) field = undefined\n })\n },\n value: () => props.value,\n resetKey: () => props.resetKey,\n inputLabel: () => props.inputLabel ?? 'Message',\n placeholder: () => props.placeholder ?? 'Write a message…',\n disabled: () => props.disabled,\n readOnly: () => props.readOnly || pending(),\n composing: () => composing,\n onCompositionStart: handleCompositionStart,\n onCompositionEnd: handleCompositionEnd,\n onFocus: ime.onFocus,\n onBlur: handleBlur,\n onKeyDown: handleInputKeyDown,\n })}\n <div\n data-slot=\"composer-action-row\"\n class=\"flex items-center justify-between gap-2 px-2.5 pb-2 pt-0.5\"\n >\n <div class=\"flex min-w-0 items-center gap-1\">\n <Show when={props.collapse || props.menuItems}>\n <DropdownMenu placement=\"top-start\">\n <DropdownMenuTrigger\n as={Button}\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Message input options\"\n >\n <MoreHorizontal />\n </DropdownMenuTrigger>\n <DropdownMenuContent\n onCloseAutoFocus={(event) => {\n if (focusTarget) event.preventDefault()\n }}\n >\n {props.menuItems}\n <Show when={props.collapse}>\n <DropdownMenuItem onSelect={() => changeCollapsed(true)}>\n <ChevronsDownUp />\n <div class=\"flex min-w-0 flex-col\">\n <span>Collapse the message input</span>\n <span class=\"text-muted-foreground text-xs\">\n Make room to read; keep your draft\n </span>\n </div>\n </DropdownMenuItem>\n </Show>\n </DropdownMenuContent>\n </DropdownMenu>\n </Show>\n {props.leadingActions}\n </div>\n <div class=\"flex shrink-0 items-center gap-1\">\n {props.trailingActions}\n <Show\n when={props.busy}\n fallback={\n <Button\n type=\"submit\"\n size=\"icon-sm\"\n disabled={!canSend()}\n aria-label={pending() ? 'Sending message' : 'Send message'}\n >\n <Show when={pending()} fallback={<ArrowUp />}>\n <Spinner size=\"sm\" label={false} />\n </Show>\n </Button>\n }\n >\n {(busy) => (\n <BusySendButton\n {...busy()}\n alternateActionHint={\n canSend(busy().mode === 'steer' ? 'queue' : 'steer')\n ? 'Ctrl/Cmd+Enter uses the other action'\n : undefined\n }\n disabled={!canSend()}\n onFire={() => {\n void submit()\n }}\n />\n )}\n </Show>\n </div>\n </div>\n </form>\n <Show when={props.context}>\n <div data-slot=\"composer-context\" class=\"flex min-w-0 items-center gap-2 pt-1\">\n {props.context}\n </div>\n </Show>\n </Show>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgBmD,kBAAwCF,OAAsC;CAC5F,MAAMG,MAAM7B,uBAAuB;CACnC,MAAM,CAAC8B,SAASC,cAAchD,aAAa,KAAK;CAChD,MAAM,CAACiD,OAAOC,YAAYlD,aAA4B,IAAI;CAC1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A;OAEJ,CAAA,GAAA,IAAA;OAAA,OAAAvB;MAAA,EAAA,CAAA,GAAAhC,gBAKRzH,MAAI;OAAA,IAAC0H,OAAI;QAAA,OAAE7E,MAAMoI;OAAO;OAAA,IAAAtD,WAAA;QAAA,IAAAuD,SAAAC,QAAA;QAAA3D,OAAA0D,cAEpBrI,MAAMoI,OAAO;QAAA,OAAAC;OAAA;MAAA,CAAA,CAAA;KAAA;IAAA,CAAA;GAAA;EAAA,CAAA,GAAA,IAAA;EAAA,OAAA9D;CAAA,EAAA,CAAA;AAO5B"}
|
|
1
|
+
{"version":3,"file":"chat-composer-shell.js","names":["ChevronsDownUp","ChevronsUpDown","MoreHorizontal","ArrowUp","Show","createEffect","createSignal","on","onCleanup","onMount","Accessor","JSX","ChatComposerControl","ChatComposerSharedProps","ChatComposerSubmitInput","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","Spinner","BusySendButton","BusySendMode","createComposerImeGuard","ChatComposerInputRenderProps","ref","element","HTMLTextAreaElement","value","resetKey","inputLabel","placeholder","disabled","readOnly","composing","onCompositionStart","onCompositionEnd","onFocus","onBlur","onKeyDown","event","KeyboardEvent","ChatComposerShellProps","createSubmitExtra","input","Extra","onSubmit","Promise","renderInput","props","Element","ChatComposerShell","ime","pending","setPending","error","setError","field","restoreBar","HTMLButtonElement","root","HTMLDivElement","focusFrame","focusTarget","selection","start","end","direction","generation","active","collapsed","collapse","unavailable","blockedReason","cancelFocus","undefined","cancelAnimationFrame","requestFocus","target","requester","document","activeElement","requestAnimationFrame","approvalFocus","current","body","contains","focus","setSelectionRange","Math","min","length","yieldInputRestore","changeCollapsed","selectionStart","selectionEnd","selectionDirection","onChange","control","expandAndFocus","controlRef","defer","action","busy","mode","canSend","selected","sendableActions","trim","submit","started","base","text","preview","first","split","find","line","slice","handleInputKeyDown","key","shiftKey","defaultPrevented","claimEnter","metaKey","ctrlKey","handleCompositionStart","handleCompositionEnd","handleBlur","_el$","_tmpl$1","_el$5","firstChild","_$use","_$insert","_$createComponent","when","children","knowledge","_el$2","_tmpl$","followUps","_el$3","_tmpl$2","band","_el$4","_tmpl$3","approval","_el$6","_tmpl$4","notices","_el$7","_tmpl$5","_el$8","_tmpl$6","message","_el$14","_tmpl$10","fallback","type","variant","size","aria-label","onClick","_tmpl$11","_el$16","_tmpl$12","_el$9","_tmpl$9","_el$1","_el$10","_el$12","nextSibling","addEventListener","preventDefault","attachments","_el$0","_tmpl$7","removeEventListener","menuItems","placement","as","onCloseAutoFocus","_$memo","onSelect","_tmpl$8","leadingActions","trailingActions","label","_$mergeProps","alternateActionHint","onFire","context","_el$13","_tmpl$0","_$createComponent","_$memo","_$mergeProps"],"sources":["../../../../src/components/conversation/internal/chat-composer-shell.tsx"],"sourcesContent":["/*\n * Substantially translated from KiroCrew website/src/components/ChatInput.tsx\n * at 283e136c0f902e965a535a7c9548c57c7504fed0.\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * Licensed under Apache-2.0; see LICENSE and NOTICE.\n */\nimport { ChevronsDownUp, ChevronsUpDown, MoreHorizontal, ArrowUp } from 'lucide-solid'\nimport {\n Show,\n createEffect,\n createSignal,\n on,\n onCleanup,\n onMount,\n type Accessor,\n type JSX,\n} from 'solid-js'\nimport type {\n ChatComposerControl,\n ChatComposerSharedProps,\n ChatComposerSubmitInput,\n} from '../chat-composer'\nimport { Button } from '../../ui/button/button'\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../../ui/dropdown-menu/dropdown-menu'\nimport { Spinner } from '../../ui/spinner/spinner'\nimport { BusySendButton, type BusySendMode } from '../busy-send-button'\nimport { createComposerImeGuard } from '../ime-guard'\n\n/** Private typed seam: public wrappers supply the native or atomic input. */\ntype ChatComposerInputRenderProps = {\n ref: (element: HTMLTextAreaElement | undefined) => void\n value: Accessor<string>\n resetKey: Accessor<unknown>\n inputLabel: Accessor<string>\n placeholder: Accessor<string>\n disabled: Accessor<boolean | undefined>\n readOnly: Accessor<boolean>\n composing: Accessor<boolean>\n onCompositionStart: () => void\n onCompositionEnd: () => void\n onFocus: () => void\n onBlur: () => void\n onKeyDown: (event: KeyboardEvent) => void\n}\n\ntype ChatComposerShellProps<Extra extends object> = ChatComposerSharedProps & {\n createSubmitExtra: (input: ChatComposerSubmitInput) => Extra\n onSubmit: (input: ChatComposerSubmitInput & Extra) => void | Promise<void>\n renderInput: (props: ChatComposerInputRenderProps) => JSX.Element\n}\n\n/**\n * Kiro's composer assembly: context/options, adjacent band, approval/notices,\n * staged content, input/action groups and a context shelf. Reading collapse\n * really unmounts the input and shelf and offers a labeled way back with draft\n * preview. The host retains the only draft, identities, preferences and services.\n *\n * Kobalte owns the options menu. Scoped imperative typing intent replaces the\n * donor global lookup/broadcast so a second composer cannot receive this draft\n * or focus. No animation starts from hidden geometry, no global shortcut, and no\n * runtime/permission/voice/optimizer authority is copied. More specific chips,\n * approval decisions and staged-content semantics are supplied by their owners.\n */\nexport function ChatComposerShell<Extra extends object>(props: ChatComposerShellProps<Extra>) {\n const ime = createComposerImeGuard()\n const [pending, setPending] = createSignal(false)\n const [error, setError] = createSignal<string | null>(null)\n let field: HTMLTextAreaElement | undefined\n let restoreBar: HTMLButtonElement | undefined\n let root: HTMLDivElement | undefined\n let focusFrame: number | undefined\n let focusTarget: 'input' | 'bar' | undefined\n let selection:\n | { start: number; end: number; direction: 'forward' | 'backward' | 'none' }\n | undefined\n let generation = 0\n let active = true\n let composing = false\n const collapsed = () => props.collapse?.value === true\n const unavailable = () => props.disabled || props.readOnly || !!props.blockedReason\n const cancelFocus = () => {\n if (focusFrame !== undefined) cancelAnimationFrame(focusFrame)\n focusFrame = undefined\n }\n const requestFocus = (target: 'input' | 'bar') => {\n cancelFocus()\n focusTarget = target\n const requester = document.activeElement\n focusFrame = requestAnimationFrame(() => {\n focusFrame = undefined\n if (!active || props.approvalFocus) return\n // Focus that moved elsewhere since the request (another conversation,\n // say, while a collapse or expand waited for this frame) is a newer\n // owner; taking it back would also drop whatever is being typed there.\n const current = document.activeElement\n if (\n current &&\n current !== document.body &&\n current !== requester &&\n !root?.contains(current)\n ) {\n focusTarget = undefined\n if (target === 'input') selection = undefined\n return\n }\n if (target === 'bar' && collapsed()) restoreBar?.focus()\n if (target === 'input' && !collapsed() && !props.disabled && field) {\n field.focus()\n if (selection)\n field.setSelectionRange(\n Math.min(selection.start, field.value.length),\n Math.min(selection.end, field.value.length),\n selection.direction\n )\n }\n focusTarget = undefined\n })\n }\n /**\n * A press or key in the input before the deferred expand restore runs is a\n * newer selection owner: the restore must not move its caret back.\n */\n const yieldInputRestore = () => {\n if (focusTarget !== 'input') return\n cancelFocus()\n focusTarget = undefined\n selection = undefined\n }\n const changeCollapsed = (value: boolean) => {\n if (!props.collapse || props.approvalFocus) return\n if (value && field)\n selection = {\n start: field.selectionStart,\n end: field.selectionEnd,\n direction: field.selectionDirection,\n }\n props.collapse.onChange(value)\n requestFocus(value ? 'bar' : 'input')\n }\n const control: ChatComposerControl = {\n focus() {\n if (collapsed() || props.approvalFocus || props.disabled || !field) return false\n field.focus()\n return true\n },\n expandAndFocus() {\n if (props.approvalFocus || props.disabled) return false\n if (collapsed()) changeCollapsed(false)\n else requestFocus('input')\n return true\n },\n }\n onMount(() => props.controlRef?.(control))\n createEffect(\n on(\n () => props.resetKey,\n () => {\n generation += 1\n selection = undefined\n composing = false\n cancelFocus()\n focusTarget = undefined\n setPending(false)\n setError(null)\n ime.onBlur()\n },\n { defer: true }\n )\n )\n onCleanup(() => {\n active = false\n generation += 1\n cancelFocus()\n props.controlRef?.(undefined)\n })\n const action = (): 'send' | BusySendMode => props.busy?.mode ?? 'send'\n const canSend = (selected: 'send' | BusySendMode = action()) =>\n !unavailable() &&\n !pending() &&\n (props.sendableActions?.[selected] ?? props.value.trim().length > 0) &&\n !(selected !== 'send' && props.busy?.unavailable?.[selected])\n const submit = async (selected: 'send' | BusySendMode = action()) => {\n if (!canSend(selected)) return\n const started = generation\n const base: ChatComposerSubmitInput = { text: props.value, action: selected }\n const input = { ...base, ...props.createSubmitExtra(base) }\n setPending(true)\n setError(null)\n try {\n await props.onSubmit(input)\n } catch {\n if (active && started === generation)\n setError('Message not sent. Check your draft and retry when the connection recovers.')\n } finally {\n if (active && started === generation) setPending(false)\n }\n }\n const preview = () => {\n const first =\n props.value\n .split('\\n')\n .find((line) => line.trim().length > 0)\n ?.trim() ?? ''\n return first.length > 120 ? `${first.slice(0, 120)}…` : first\n }\n const handleInputKeyDown = (event: KeyboardEvent) => {\n yieldInputRestore()\n if (event.key === 'Escape' && error()) {\n setError(null)\n return\n }\n if (event.key !== 'Enter' || event.shiftKey || event.defaultPrevented) return\n if (ime.claimEnter(event)) {\n const selected =\n props.busy && (event.metaKey || event.ctrlKey)\n ? props.busy.mode === 'steer'\n ? 'queue'\n : 'steer'\n : action()\n void submit(selected)\n }\n }\n const handleCompositionStart = () => {\n composing = true\n ime.onCompositionStart()\n }\n const handleCompositionEnd = () => {\n composing = false\n ime.onCompositionEnd()\n }\n const handleBlur = () => {\n composing = false\n ime.onBlur()\n }\n return (\n <div\n ref={(element) => (root = element)}\n data-slot=\"chat-composer\"\n class=\"mx-auto flex w-full max-w-4xl flex-col px-4 pb-1\"\n >\n <Show when={!props.approvalFocus}>\n <Show when={props.knowledge}>\n <div data-slot=\"composer-knowledge\">{props.knowledge}</div>\n </Show>\n <Show when={props.followUps}>\n <div data-slot=\"composer-follow-ups\">{props.followUps}</div>\n </Show>\n </Show>\n <Show when={props.band}>\n <div data-slot=\"composer-band\">{props.band}</div>\n </Show>\n <div aria-hidden=\"true\" class=\"h-1.5 shrink-0\" />\n <Show when={props.approval}>\n <div data-slot=\"composer-approval\">{props.approval}</div>\n </Show>\n <Show when={props.notices}>\n <div data-slot=\"composer-notices\">{props.notices}</div>\n </Show>\n <Show when={props.blockedReason}>\n <p role=\"status\" class=\"text-muted-foreground mb-1 text-xs\">\n {props.blockedReason}\n </p>\n </Show>\n <Show when={error()}>\n {(message) => (\n <p role=\"alert\" class=\"text-foreground mb-1 border-s-2 border-destructive ps-2 text-xs\">\n {message()}\n </p>\n )}\n </Show>\n <Show when={!props.approvalFocus}>\n <Show\n when={!collapsed()}\n fallback={\n <Button\n ref={(element) => {\n restoreBar = element\n onCleanup(() => {\n if (restoreBar === element) restoreBar = undefined\n })\n }}\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n class=\"w-full justify-start\"\n aria-expanded={false}\n aria-label={`Show the message input${preview() ? `: ${preview()}` : ''}`}\n onClick={() => changeCollapsed(false)}\n >\n <ChevronsUpDown />\n <span aria-hidden=\"true\" class=\"shrink-0\">\n Show the message input\n </span>{' '}\n <Show when={preview()}>\n <span aria-hidden=\"true\" class=\"min-w-0 flex-1 truncate\">\n {preview()}\n </span>\n </Show>\n </Button>\n }\n >\n <form\n data-slot=\"composer-input-box\"\n class=\"border-input bg-card flex flex-col overflow-hidden rounded-2xl border transition-colors focus-within:border-ring\"\n onSubmit={(event) => {\n event.preventDefault()\n void submit()\n }}\n >\n <Show when={props.attachments}>\n <div data-slot=\"composer-staged-content\">{props.attachments}</div>\n </Show>\n {props.renderInput({\n ref: (element) => {\n field = element\n if (element) {\n element.addEventListener('pointerdown', yieldInputRestore)\n onCleanup(() => {\n element.removeEventListener('pointerdown', yieldInputRestore)\n if (field === element) field = undefined\n })\n }\n },\n value: () => props.value,\n resetKey: () => props.resetKey,\n inputLabel: () => props.inputLabel ?? 'Message',\n placeholder: () => props.placeholder ?? 'Write a message…',\n disabled: () => props.disabled,\n readOnly: () => props.readOnly || pending(),\n composing: () => composing,\n onCompositionStart: handleCompositionStart,\n onCompositionEnd: handleCompositionEnd,\n onFocus: ime.onFocus,\n onBlur: handleBlur,\n onKeyDown: handleInputKeyDown,\n })}\n <div\n data-slot=\"composer-action-row\"\n class=\"flex items-center justify-between gap-2 px-2.5 pb-2 pt-0.5\"\n >\n <div class=\"flex min-w-0 items-center gap-1\">\n <Show when={props.collapse || props.menuItems}>\n <DropdownMenu placement=\"top-start\">\n <DropdownMenuTrigger\n as={Button}\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Message input options\"\n >\n <MoreHorizontal />\n </DropdownMenuTrigger>\n <DropdownMenuContent\n onCloseAutoFocus={(event) => {\n if (focusTarget) event.preventDefault()\n }}\n >\n {props.menuItems}\n <Show when={props.collapse}>\n <DropdownMenuItem onSelect={() => changeCollapsed(true)}>\n <ChevronsDownUp />\n <div class=\"flex min-w-0 flex-col\">\n <span>Collapse the message input</span>\n <span class=\"text-muted-foreground text-xs\">\n Make room to read; keep your draft\n </span>\n </div>\n </DropdownMenuItem>\n </Show>\n </DropdownMenuContent>\n </DropdownMenu>\n </Show>\n {props.leadingActions}\n </div>\n <div class=\"flex shrink-0 items-center gap-1\">\n {props.trailingActions}\n <Show\n when={props.busy}\n fallback={\n <Button\n type=\"submit\"\n size=\"icon-sm\"\n disabled={!canSend()}\n aria-label={pending() ? 'Sending message' : 'Send message'}\n >\n <Show when={pending()} fallback={<ArrowUp />}>\n <Spinner size=\"sm\" label={false} />\n </Show>\n </Button>\n }\n >\n {(busy) => (\n <BusySendButton\n {...busy()}\n alternateActionHint={\n canSend(busy().mode === 'steer' ? 'queue' : 'steer')\n ? 'Ctrl/Cmd+Enter uses the other action'\n : undefined\n }\n disabled={!canSend()}\n onFire={() => {\n void submit()\n }}\n />\n )}\n </Show>\n </div>\n </div>\n </form>\n <Show when={props.context}>\n <div data-slot=\"composer-context\" class=\"flex min-w-0 items-center gap-2 pt-1\">\n {props.context}\n </div>\n </Show>\n </Show>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgBmD,kBAAwCF,OAAsC;CAC5F,MAAMG,MAAM7B,uBAAuB;CACnC,MAAM,CAAC8B,SAASC,cAAchD,aAAa,KAAK;CAChD,MAAM,CAACiD,OAAOC,YAAYlD,aAA4B,IAAI;CAC1D,IAAImD;CACJ,IAAIC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Q;aAAA,OAAAvB,gBAAGpI,SAAO,CAAA,CAAA;YAAA;YAAA,IAAAsI,WAAA;aAAA,OAAAF,gBACtCnH,SAAO;cAAC6I,MAAI;cAAM2B,OAAO;aAAK,CAAA;YAAA;WAAA,CAAA;UAAA;SAAA,CAAA;QAAA;QAAAnD,WAKnClC,SAAIgC,gBACHlH,gBAAcwK,WACTtF,MAAI;SAAA,IACRuF,sBAAmB;UAAA,OACjBrF,QAAQF,KAAK,CAAC,CAACC,SAAS,UAAU,UAAU,OAAO,IAC/C,yCACA7B,KAAAA;SAAS;SAAA,IAEf3C,WAAQ;UAAA,OAAE,CAACyE,QAAQ;SAAC;SACpBsF,cAAc;UACZ,OAAY;SACd;QAAC,CAAA,CAAA;OAEJ,CAAA,GAAA,IAAA;OAAA,OAAAxB;MAAA,EAAA,CAAA,GAAAhC,gBAKRnI,MAAI;OAAA,IAACoI,OAAI;QAAA,OAAEvF,MAAM+I;OAAO;OAAA,IAAAvD,WAAA;QAAA,IAAAwD,SAAAC,QAAA;QAAA5D,OAAA2D,cAEpBhJ,MAAM+I,OAAO;QAAA,OAAAC;OAAA;MAAA,CAAA,CAAA;KAAA;IAAA,CAAA;GAAA;EAAA,CAAA,GAAA,IAAA;EAAA,OAAAhE;CAAA,EAAA,CAAA;AAO5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste-token-editor.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/paste-token-editor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAUL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAA;AAIvB,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"paste-token-editor.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/paste-token-editor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAUL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAA;AAIvB,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,CAAA;AAiCpE,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;IAC7B,GAAG,EAAE,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,KAAK,IAAI,CAAA;IACvD,aAAa,EAAE,MAAM,MAAM,CAAA;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IAC1C,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,MAAM,OAAO,CAAA;IACxB,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CAC1C,CAAA;AAsBD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,kCAmtB5D"}
|