@nexface/chat 0.1.14 → 0.1.15-alpha.1
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/assistant-attachments.js +17 -60
- package/dist/assistant-attachments.js.map +1 -0
- package/dist/assistant-components.d.ts +3 -3
- package/dist/assistant-components.js +29 -77
- package/dist/assistant-components.js.map +1 -0
- package/dist/assistant-runtime.d.ts +1 -1
- package/dist/assistant-runtime.js +43 -100
- package/dist/assistant-runtime.js.map +1 -0
- package/dist/attachments.js +15 -36
- package/dist/attachments.js.map +1 -0
- package/dist/client.js +73 -312
- package/dist/client.js.map +1 -0
- package/dist/config.js +5 -4
- package/dist/config.js.map +1 -0
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +728 -2102
- package/dist/default-chat.js.map +7 -0
- package/dist/errors.js +18 -55
- package/dist/errors.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.js +1 -0
- package/dist/messages.js.map +1 -0
- package/dist/page-confirmation.js +4 -3
- package/dist/page-confirmation.js.map +1 -0
- package/dist/protocol-messages.js +66 -290
- package/dist/protocol-messages.js.map +1 -0
- package/dist/protocol-response.js +18 -38
- package/dist/protocol-response.js.map +1 -0
- package/dist/react.js +50 -146
- package/dist/react.js.map +1 -0
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +1 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/runtime-controller.d.ts +0 -1
- package/dist/shared/runtime-controller.js +1 -0
- package/dist/shared/runtime-controller.js.map +1 -0
- package/dist/shared/runtime-execution.js +1 -0
- package/dist/shared/runtime-execution.js.map +1 -0
- package/dist/shared/schema.js +19 -45
- package/dist/shared/schema.js.map +1 -0
- package/dist/storage.js +53 -130
- package/dist/storage.js.map +1 -0
- package/dist/styles.css +20 -99
- package/dist/tool-result.js +3 -7
- package/dist/tool-result.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/attachment.aui.d.ts +1 -1
- package/dist/ui/attachment.aui.js +20 -16
- package/dist/ui/attachment.aui.js.map +1 -0
- package/dist/ui/avatar.js +1 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/button.js +1 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/code-block.js +3 -2
- package/dist/ui/code-block.js.map +1 -0
- package/dist/ui/collapsible.js +3 -2
- package/dist/ui/collapsible.js.map +1 -0
- package/dist/ui/composer-voice.js +2 -3
- package/dist/ui/composer-voice.js.map +1 -0
- package/dist/ui/dialog.d.ts +1 -1
- package/dist/ui/dialog.js +4 -9
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/dropdown-menu.js +3 -2
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/ui/home-demo/action-bar.js +1 -0
- package/dist/ui/home-demo/action-bar.js.map +1 -0
- package/dist/ui/home-demo/composer.js +4 -7
- package/dist/ui/home-demo/composer.js.map +1 -0
- package/dist/ui/home-demo/greeting.d.ts +1 -1
- package/dist/ui/home-demo/greeting.js +2 -1
- package/dist/ui/home-demo/greeting.js.map +1 -0
- package/dist/ui/home-demo/messages.d.ts +1 -1
- package/dist/ui/home-demo/messages.js +5 -4
- package/dist/ui/home-demo/messages.js.map +1 -0
- package/dist/ui/home-demo/styles.js +1 -0
- package/dist/ui/home-demo/styles.js.map +1 -0
- package/dist/ui/home-demo/suggestions.d.ts +1 -1
- package/dist/ui/home-demo/suggestions.js +3 -5
- package/dist/ui/home-demo/suggestions.js.map +1 -0
- package/dist/ui/home-demo/surfaces.js +2 -3
- package/dist/ui/home-demo/surfaces.js.map +1 -0
- package/dist/ui/home-demo/thread.d.ts +1 -1
- package/dist/ui/home-demo/thread.js +2 -1
- package/dist/ui/home-demo/thread.js.map +1 -0
- package/dist/ui/home-demo/trace-line.d.ts +1 -1
- package/dist/ui/home-demo/trace-line.js +3 -2
- package/dist/ui/home-demo/trace-line.js.map +1 -0
- package/dist/ui/home-demo/trace.d.ts +1 -1
- package/dist/ui/home-demo/trace.js +9 -28
- package/dist/ui/home-demo/trace.js.map +1 -0
- package/dist/ui/home-demo/type.js +1 -0
- package/dist/ui/home-demo/type.js.map +1 -0
- package/dist/ui/input.js +1 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/markdown-text.js +3 -2
- package/dist/ui/markdown-text.js.map +1 -0
- package/dist/ui/reasoning.aui.js +3 -2
- package/dist/ui/reasoning.aui.js.map +1 -0
- package/dist/ui/reasoning.d.ts +1 -1
- package/dist/ui/reasoning.js +9 -6
- package/dist/ui/reasoning.js.map +1 -0
- package/dist/ui/surface.js +8 -27
- package/dist/ui/surface.js.map +1 -0
- package/dist/ui/thread-list.aui.d.ts +2 -2
- package/dist/ui/thread-list.aui.js +12 -18
- package/dist/ui/thread-list.aui.js.map +1 -0
- package/dist/ui/tool-group.aui.js +3 -2
- package/dist/ui/tool-group.aui.js.map +1 -0
- package/dist/ui/tooltip-icon-button.js +2 -1
- package/dist/ui/tooltip-icon-button.js.map +1 -0
- package/dist/ui/tooltip.js +1 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/ui/use-attachment-src.js +2 -1
- package/dist/ui/use-attachment-src.js.map +1 -0
- package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
- package/dist/ui/use-copy-to-clipboard.js +2 -1
- package/dist/ui/use-copy-to-clipboard.js.map +1 -0
- package/dist/ui/utils.js +3 -9
- package/dist/ui/utils.js.map +1 -0
- package/dist/use-next-message.js +4 -7
- package/dist/use-next-message.js.map +1 -0
- package/dist/voice/types.js +1 -0
- package/dist/voice/types.js.map +1 -0
- package/dist/voice/use-voice.js +13 -35
- package/dist/voice/use-voice.js.map +1 -0
- package/package.json +4 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"greeting.js","sourceRoot":"","sources":["../../../src/ui/home-demo/greeting.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAClD,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAuD;IAElG,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kJAAkJ,CAAC,aACpK,YAAG,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,YAC1B,KAAK,GACJ,EACH,WAAW,CAAC,CAAC,CAAC,YAAG,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAG,WAAW,GAAK,CAAC,CAAC,CAAC,IAAI,IAC/D,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport { typeSection, typeDeck } from \"./type.js\";\nexport function Greeting({ title, description }: { title: string; description?: string | undefined }) {\n\n return (\n <div className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto mb-8 flex w-full max-w-(--nxf-thread-max-width) flex-col items-center text-center duration-200\")} >\n <p className={cn(typeSection)}>\n {title}\n </p>\n {description ? <p className={cn(typeDeck)}>{description}</p> : null}\n </div>\n );\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.
|
|
3
3
|
import { cn } from "../utils.js";
|
|
4
|
-
import { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState
|
|
4
|
+
import { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState } from "@assistant-ui/react";
|
|
5
5
|
import { AssistantActionBar } from "./action-bar.js";
|
|
6
|
-
export function UserMessage({ children, attachments, actions
|
|
6
|
+
export function UserMessage({ children, attachments, actions }) {
|
|
7
7
|
return (_jsxs(MessagePrimitive.Root, { "data-role": "user", "data-slot": "aui_user-message-root", className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150"), children: [_jsx("div", { className: cn("w-full has-[.aui-attachment-root]:mb-2"), children: attachments }), _jsxs("div", { className: cn("relative max-w-[80%]"), children: [_jsx("div", { className: cn("peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden"), children: children }), _jsx(ActionBarPrimitive.Root, { hideWhenRunning: true, autohide: "not-last", className: cn("absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden"), children: actions })] })] }));
|
|
8
8
|
}
|
|
9
9
|
export function AssistantMessage({ children }) {
|
|
@@ -12,6 +12,7 @@ export function AssistantMessage({ children }) {
|
|
|
12
12
|
function MessageError() {
|
|
13
13
|
const cancelled = useAuiState((s) => s.message.status?.type === "incomplete" && s.message.status.reason === "cancelled");
|
|
14
14
|
if (cancelled)
|
|
15
|
-
return
|
|
16
|
-
return
|
|
15
|
+
return _jsx("p", { role: "status", className: cn("mt-2 text-[13px] text-muted-foreground"), children: "Stopped" });
|
|
16
|
+
return _jsx(MessagePrimitive.Error, { children: _jsx(ErrorPrimitive.Root, { role: "alert", className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: _jsx(ErrorPrimitive.Message, { className: cn("line-clamp-2") }) }) });
|
|
17
17
|
}
|
|
18
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/ui/home-demo/messages.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,MAA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BAAa,CAAC;IAC5G,OAAO,KAAC,gBAAgB,CAAC,KAAK,cAAC,KAAC,cAAc,CAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,EAAE,CAAC,yEAAyE,CAAC,YAAE,KAAC,cAAc,CAAC,OAAO,IAAC,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,GAAI,GAAsB,GAAyB,CAAC;AACtQ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport type { ReactNode } from \"react\";\nimport { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState } from \"@assistant-ui/react\";\nimport { AssistantActionBar } from \"./action-bar.js\";\nexport function UserMessage({ children, attachments, actions }: { children: ReactNode; attachments: ReactNode; actions: ReactNode }) {\n return (\n <MessagePrimitive.Root\n data-role=\"user\" data-slot=\"aui_user-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150\")}\n >\n <div className={cn(\"w-full has-[.aui-attachment-root]:mb-2\")} >\n {attachments}\n </div>\n <div className={cn(\"relative max-w-[80%]\")} >\n <div className={cn(\"peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden\")} >\n {children}\n </div>\n <ActionBarPrimitive.Root\n hideWhenRunning\n autohide=\"not-last\"\n className={cn(\"absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden\")}\n >\n {actions}\n </ActionBarPrimitive.Root>\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nexport function AssistantMessage({ children }: { children: ReactNode }) {\n return (\n <MessagePrimitive.Root\n data-role=\"assistant\" data-slot=\"aui_assistant-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150\")}\n >\n <div data-slot=\"aui_assistant-message-content\" className={cn(\"text-[15px] leading-relaxed wrap-break-word\")} >\n {children}\n <MessageError />\n </div>\n <div className={cn(\"mt-2 flex items-center gap-1.5 empty:hidden\")} >\n <AssistantActionBar />\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nfunction MessageError() {\n const cancelled = useAuiState((s) => s.message.status?.type === \"incomplete\" && s.message.status.reason === \"cancelled\");\n if (cancelled) return <p role=\"status\" className={cn(\"mt-2 text-[13px] text-muted-foreground\")}>Stopped</p>;\n return <MessagePrimitive.Error><ErrorPrimitive.Root role=\"alert\" className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}><ErrorPrimitive.Message className={cn(\"line-clamp-2\")} /></ErrorPrimitive.Root></MessagePrimitive.Error>;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const actionButtonClass = "text-muted-foreground/70 hover:text-foreground disabled:pointer-events-none disabled:opacity-40 p-1 transition-colors";
|
|
2
2
|
export const menuContentClass = "bg-popover text-popover-foreground border-foreground/10 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out rounded-surface z-50 min-w-28 overflow-hidden border p-1";
|
|
3
3
|
export const menuItemClass = "hover:bg-muted focus:bg-muted flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-[13px] outline-none select-none";
|
|
4
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/ui/home-demo/styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAC5B,uHAAuH,CAAC;AAE1H,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uSAAuS,CAAC;AAE1S,MAAM,CAAC,MAAM,aAAa,GACxB,kIAAkI,CAAC","sourcesContent":["export const actionButtonClass =\n \"text-muted-foreground/70 hover:text-foreground disabled:pointer-events-none disabled:opacity-40 p-1 transition-colors\";\n\nexport const menuContentClass =\n \"bg-popover text-popover-foreground border-foreground/10 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out rounded-surface z-50 min-w-28 overflow-hidden border p-1\";\n\nexport const menuItemClass =\n \"hover:bg-muted focus:bg-muted flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-[13px] outline-none select-none\";\n"]}
|
|
@@ -4,15 +4,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import { ThreadPrimitive, useAuiState } from "@assistant-ui/react";
|
|
5
5
|
import { cn } from "../utils.js";
|
|
6
6
|
const suggestionChipClass = "border-foreground/10 bg-background text-muted-foreground hover:border-foreground/25 hover:text-foreground rounded-control h-8 border px-3 text-[13px] transition-colors";
|
|
7
|
-
export function Suggestions({ suggestions, disabled, onSend
|
|
7
|
+
export function Suggestions({ suggestions, disabled, onSend }) {
|
|
8
8
|
const isComposerEmpty = useAuiState((s) => s.composer.isEmpty);
|
|
9
9
|
const hidden = !isComposerEmpty || disabled;
|
|
10
10
|
return (
|
|
11
11
|
// Typing hides the suggestions without unmounting them: the empty view is
|
|
12
12
|
// centred, so collapsing a block this tall moves the composer out from
|
|
13
13
|
// under the cursor. Disabled buttons also stay out of the tab order in React 18.
|
|
14
|
-
_jsx("div", { "aria-hidden": hidden, className: cn("animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none", hidden && "opacity-0"), children: suggestions.map((suggestion) => (_jsx(ThreadPrimitive.Suggestion, { prompt: suggestion.prompt, send: true, disabled: hidden, onClick: (event) => {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
onSend(suggestion.prompt);
|
|
17
|
-
}, className: cn(suggestionChipClass), children: suggestion.label }, suggestion.prompt))) }));
|
|
14
|
+
_jsx("div", { "aria-hidden": hidden, className: cn("animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none", hidden && "opacity-0"), children: suggestions.map((suggestion) => (_jsx(ThreadPrimitive.Suggestion, { prompt: suggestion.prompt, send: true, disabled: hidden, onClick: (event) => { event.preventDefault(); onSend(suggestion.prompt); }, className: cn(suggestionChipClass), children: suggestion.label }, suggestion.prompt))) }));
|
|
18
15
|
}
|
|
16
|
+
//# sourceMappingURL=suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../../../src/ui/home-demo/suggestions.tsx"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,YAAY,CAAC;;AAEb,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,mBAAmB,GACvB,yKAAyK,CAAC;AAE5K,MAAM,UAAU,WAAW,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAG1D;IACC,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,CAAC,eAAe,IAAI,QAAQ,CAAC;IAE5C,OAAO;IACL,0EAA0E;IAC1E,uEAAuE;IACvE,iFAAiF;IACjF,6BACe,MAAM,EACnB,SAAS,EAAE,EAAE,CACX,sJAAsJ,EACtJ,MAAM,IAAI,WAAW,CACtB,YAEA,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAC/B,KAAC,eAAe,CAAC,UAAU,IAEzB,MAAM,EAAE,UAAU,CAAC,MAAM,EACzB,IAAI,QACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC1E,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,YAEjC,UAAU,CAAC,KAAK,IAPZ,UAAU,CAAC,MAAM,CAQK,CAC9B,CAAC,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\n\"use client\";\n\nimport { ThreadPrimitive, useAuiState } from \"@assistant-ui/react\";\nimport { cn } from \"../utils.js\";\n\nconst suggestionChipClass =\n \"border-foreground/10 bg-background text-muted-foreground hover:border-foreground/25 hover:text-foreground rounded-control h-8 border px-3 text-[13px] transition-colors\";\n\nexport function Suggestions({ suggestions, disabled, onSend }: {\n suggestions: readonly { label: string; prompt: string }[];\n disabled: boolean; onSend(prompt: string): void;\n}) {\n const isComposerEmpty = useAuiState((s) => s.composer.isEmpty);\n const hidden = !isComposerEmpty || disabled;\n\n return (\n // Typing hides the suggestions without unmounting them: the empty view is\n // centred, so collapsing a block this tall moves the composer out from\n // under the cursor. Disabled buttons also stay out of the tab order in React 18.\n <div\n aria-hidden={hidden}\n className={cn(\n \"animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none\",\n hidden && \"opacity-0\",\n )}\n >\n {suggestions.map((suggestion) => (\n <ThreadPrimitive.Suggestion\n key={suggestion.prompt}\n prompt={suggestion.prompt}\n send\n disabled={hidden}\n onClick={(event) => { event.preventDefault(); onSend(suggestion.prompt); }}\n className={cn(suggestionChipClass)}\n >\n {suggestion.label}\n </ThreadPrimitive.Suggestion>\n ))}\n </div>\n );\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../utils.js";
|
|
3
|
-
export function ShimmerLabel({ active = true, className, ...props }) {
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
export function ShimmerLabel({ active = true, className, ...props }) { return _jsx("span", { className: cn(active && "shimmer motion-reduce:animate-none", className), ...props }); }
|
|
4
|
+
//# sourceMappingURL=surfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surfaces.js","sourceRoot":"","sources":["../../../src/ui/home-demo/surfaces.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,MAAM,UAAU,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAiD,IAAI,OAAO,eAAM,SAAS,EAAE,EAAE,CAAC,MAAM,IAAI,oCAAoC,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC,CAAC,CAAC","sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cn } from \"../utils.js\";\nexport function ShimmerLabel({ active = true, className, ...props }: ComponentProps<\"span\"> & { active?: boolean }) { return <span className={cn(active && \"shimmer motion-reduce:animate-none\", className)} {...props} />; }\n"]}
|
|
@@ -9,5 +9,5 @@ type ThreadProps = {
|
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
renderMessage: NonNullable<ComponentProps<typeof ThreadPrimitive.Messages>["children"]>;
|
|
11
11
|
};
|
|
12
|
-
export declare function Thread({ empty: isEmpty, welcome, suggestions, composer, footer, children, renderMessage
|
|
12
|
+
export declare function Thread({ empty: isEmpty, welcome, suggestions, composer, footer, children, renderMessage }: ThreadProps): import("react").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ThreadPrimitive } from "@assistant-ui/react";
|
|
3
3
|
import { cn } from "../utils.js";
|
|
4
|
-
export function Thread({ empty: isEmpty, welcome, suggestions, composer, footer, children, renderMessage
|
|
4
|
+
export function Thread({ empty: isEmpty, welcome, suggestions, composer, footer, children, renderMessage }) {
|
|
5
5
|
return (_jsx(ThreadPrimitive.Root, { className: cn("flex h-full min-h-0 min-w-0 flex-1 flex-col"), style: { ["--nxf-thread-max-width"]: "42rem" }, children: _jsxs(ThreadPrimitive.Viewport, { turnAnchor: "top", "data-slot": "aui_thread-viewport", role: "log", "aria-live": "polite", className: cn(
|
|
6
6
|
// The gutter is reserved whether or not a scrollbar is showing, so the
|
|
7
7
|
// thread and its composer do not shift sideways on the first reply
|
|
@@ -9,3 +9,4 @@ export function Thread({ empty: isEmpty, welcome, suggestions, composer, footer,
|
|
|
9
9
|
// jump appears on Windows and on macOS set to always show them.
|
|
10
10
|
"relative flex flex-1 [scrollbar-gutter:stable_both-edges] flex-col overflow-y-auto px-4 pt-6 md:px-6", isEmpty && "justify-center"), children: [isEmpty ? welcome : null, _jsxs("div", { className: cn("mx-auto mb-12 flex w-full max-w-(--nxf-thread-max-width) flex-col gap-y-6 empty:hidden"), children: [_jsx(ThreadPrimitive.Messages, { children: renderMessage }), children] }), _jsxs(ThreadPrimitive.ViewportFooter, { className: cn("bg-background mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col gap-3 overflow-visible pb-5", !isEmpty && "sticky bottom-0 mt-auto"), children: [footer, composer, isEmpty ? suggestions : null] })] }) }));
|
|
11
11
|
}
|
|
12
|
+
//# sourceMappingURL=thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.js","sourceRoot":"","sources":["../../../src/ui/home-demo/thread.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAOjC,MAAM,UAAU,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAe;IACrH,OAAO,CACL,KAAC,eAAe,CAAC,IAAI,IAAC,SAAS,EAAE,EAAE,CAAC,6CAA6C,CAAC,EAAG,KAAK,EAAE,EAAE,CAAC,wBAAkC,CAAC,EAAE,OAAO,EAAE,YAC3I,MAAC,eAAe,CAAC,QAAQ,IACvB,UAAU,EAAC,KAAK,eAAW,qBAAqB,EAAC,IAAI,EAAC,KAAK,eAAW,QAAQ,EAC9E,SAAS,EAAE,EAAE;YACX,uEAAuE;YACvE,mEAAmE;YACnE,oEAAoE;YACpE,gEAAgE;YAChE,sGAAsG,EACtG,OAAO,IAAI,gBAAgB,CAC5B,aAEA,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAEzB,eAAK,SAAS,EAAE,EAAE,CAAC,wFAAwF,CAAC,aAC1G,KAAC,eAAe,CAAC,QAAQ,cAAE,aAAa,GAA4B,EACnE,QAAQ,IACL,EAEN,MAAC,eAAe,CAAC,cAAc,IAC7B,SAAS,EAAE,EAAE,CACX,uGAAuG,EACvG,CAAC,OAAO,IAAI,yBAAyB,CACtC,aAEA,MAAM,EACN,QAAQ,EACR,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IACE,IACR,GACN,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { ThreadPrimitive } from \"@assistant-ui/react\";\nimport { cn } from \"../utils.js\";\n\ntype ThreadProps = {\n empty: boolean; welcome: ReactNode; suggestions: ReactNode; composer: ReactNode;\n footer: ReactNode; children?: ReactNode;\n renderMessage: NonNullable<ComponentProps<typeof ThreadPrimitive.Messages>[\"children\"]>;\n};\nexport function Thread({ empty: isEmpty, welcome, suggestions, composer, footer, children, renderMessage }: ThreadProps) {\n return (\n <ThreadPrimitive.Root className={cn(\"flex h-full min-h-0 min-w-0 flex-1 flex-col\")} style={{ [\"--nxf-thread-max-width\" as string]: \"42rem\" }}>\n <ThreadPrimitive.Viewport\n turnAnchor=\"top\" data-slot=\"aui_thread-viewport\" role=\"log\" aria-live=\"polite\"\n className={cn(\n // The gutter is reserved whether or not a scrollbar is showing, so the\n // thread and its composer do not shift sideways on the first reply\n // that overflows. Only classic scrollbars take layout space, so the\n // jump appears on Windows and on macOS set to always show them.\n \"relative flex flex-1 [scrollbar-gutter:stable_both-edges] flex-col overflow-y-auto px-4 pt-6 md:px-6\",\n isEmpty && \"justify-center\",\n )}\n >\n {isEmpty ? welcome : null}\n\n <div className={cn(\"mx-auto mb-12 flex w-full max-w-(--nxf-thread-max-width) flex-col gap-y-6 empty:hidden\")} >\n <ThreadPrimitive.Messages>{renderMessage}</ThreadPrimitive.Messages>\n {children}\n </div>\n\n <ThreadPrimitive.ViewportFooter\n className={cn(\n \"bg-background mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col gap-3 overflow-visible pb-5\",\n !isEmpty && \"sticky bottom-0 mt-auto\",\n )}\n >\n {footer}\n {composer}\n {isEmpty ? suggestions : null}\n </ThreadPrimitive.ViewportFooter>\n </ThreadPrimitive.Viewport>\n </ThreadPrimitive.Root>\n );\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* stays a glyph rather than an icon because an icon on a line that cannot open
|
|
5
5
|
* reads as an affordance.
|
|
6
6
|
*/
|
|
7
|
-
export declare function TraceMarker({ live, className }: {
|
|
7
|
+
export declare function TraceMarker({ live, className, }: {
|
|
8
8
|
live: boolean;
|
|
9
9
|
className?: string;
|
|
10
10
|
}): import("react").JSX.Element;
|
|
@@ -9,7 +9,7 @@ import { cn } from "../utils.js";
|
|
|
9
9
|
* stays a glyph rather than an icon because an icon on a line that cannot open
|
|
10
10
|
* reads as an affordance.
|
|
11
11
|
*/
|
|
12
|
-
export function TraceMarker({ live, className }) {
|
|
12
|
+
export function TraceMarker({ live, className, }) {
|
|
13
13
|
return (_jsx("span", { "aria-hidden": true, className: cn("inline-block shrink-0 transition-transform", live ? "text-blue-500" : "text-muted-foreground/50", className), children: ">" }));
|
|
14
14
|
}
|
|
15
15
|
export function useToolDuration(isRunning) {
|
|
@@ -33,5 +33,6 @@ export function formatDuration(ms) {
|
|
|
33
33
|
return `${(ms / 1000).toFixed(1)}s`;
|
|
34
34
|
}
|
|
35
35
|
export function TraceLine({ live, label, detail, meta, }) {
|
|
36
|
-
return (_jsxs("div", { className: cn("my-1 flex items-baseline gap-2 font-mono text-[12px] [font-variant-ligatures:none]"), children: [_jsx(TraceMarker, { live: live }), _jsx("span", { className: cn("text-muted-foreground min-w-0 flex-1 truncate"), children: live ? (_jsxs(ShimmerLabel, { children: [label, detail ? ` ${detail}` : null] })) : (_jsxs(_Fragment, { children: [label, detail ? ` ${detail}` : null] })) }), meta ? _jsx("span", { className: cn("text-muted-foreground/50 shrink-0"), children: meta }) : null] }));
|
|
36
|
+
return (_jsxs("div", { className: cn("my-1 flex items-baseline gap-2 font-mono text-[12px] [font-variant-ligatures:none]"), children: [_jsx(TraceMarker, { live: live }), _jsx("span", { className: cn("text-muted-foreground min-w-0 flex-1 truncate"), children: live ? (_jsxs(ShimmerLabel, { children: [label, detail ? ` ${detail}` : null] })) : (_jsxs(_Fragment, { children: [label, detail ? ` ${detail}` : null] })) }), meta ? (_jsx("span", { className: cn("text-muted-foreground/50 shrink-0"), children: meta })) : null] }));
|
|
37
37
|
}
|
|
38
|
+
//# sourceMappingURL=trace-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-line.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace-line.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,IAAI,EACJ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EAAE,IAAI,GAAI,EAC3B,eAAM,SAAS,EAAE,EAAE,CAAC,+CAA+C,CAAC,YACjE,IAAI,CAAC,CAAC,CAAC,CACN,MAAC,YAAY,eACV,KAAK,EACL,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,IAChB,CAChB,CAAC,CAAC,CAAC,CACF,8BACG,KAAK,EACL,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,GACI,EACN,IAAI,CAAC,CAAC,CAAC,CACN,eAAM,SAAS,EAAE,EAAE,CAAC,mCAAmC,CAAC,YAAG,IAAI,GAAQ,CACxE,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { ShimmerLabel } from \"./surfaces.js\";\nimport { cn } from \"../utils.js\";\n\n/**\n * The mark every trace line carries. A disclosure rotates it and a plain line\n * does not, so the two read as the same grammar rather than two symbols; it\n * stays a glyph rather than an icon because an icon on a line that cannot open\n * reads as an affordance.\n */\nexport function TraceMarker({\n live,\n className,\n}: {\n live: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-block shrink-0 transition-transform\",\n live ? \"text-blue-500\" : \"text-muted-foreground/50\",\n className,\n )}\n >\n {\">\"}\n </span>\n );\n}\n\nexport function useToolDuration(isRunning: boolean): number | null {\n const startTimeRef = useRef<number | null>(null);\n const [duration, setDuration] = useState<number | null>(null);\n\n useEffect(() => {\n if (isRunning && startTimeRef.current === null) {\n startTimeRef.current = Date.now();\n setDuration(null);\n } else if (!isRunning && startTimeRef.current !== null) {\n setDuration(Date.now() - startTimeRef.current);\n startTimeRef.current = null;\n }\n }, [isRunning]);\n\n return duration;\n}\n\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n return `${(ms / 1000).toFixed(1)}s`;\n}\n\nexport function TraceLine({\n live,\n label,\n detail,\n meta,\n}: {\n live: boolean;\n label: string;\n detail?: string;\n meta?: string;\n}) {\n return (\n <div className={cn(\"my-1 flex items-baseline gap-2 font-mono text-[12px] [font-variant-ligatures:none]\")}>\n <TraceMarker live={live} />\n <span className={cn(\"text-muted-foreground min-w-0 flex-1 truncate\")}>\n {live ? (\n <ShimmerLabel>\n {label}\n {detail ? ` ${detail}` : null}\n </ShimmerLabel>\n ) : (\n <>\n {label}\n {detail ? ` ${detail}` : null}\n </>\n )}\n </span>\n {meta ? (\n <span className={cn(\"text-muted-foreground/50 shrink-0\")}>{meta}</span>\n ) : null}\n </div>\n );\n}\n"]}
|
|
@@ -6,7 +6,7 @@ export declare function DisclosureTrigger({ live, label, detail, }: {
|
|
|
6
6
|
label: string;
|
|
7
7
|
detail?: string;
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
|
-
export declare function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation
|
|
9
|
+
export declare function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }: ToolCallMessagePartProps & {
|
|
10
10
|
showDetails: boolean;
|
|
11
11
|
presentation?: UIMessagePart | undefined;
|
|
12
12
|
}): import("react").JSX.Element;
|
|
@@ -1,43 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../utils.js";
|
|
3
3
|
import { Collapsible, CollapsibleContent } from "../collapsible.js";
|
|
4
|
-
|
|
4
|
+
"use client";
|
|
5
5
|
import { ShimmerLabel } from "./surfaces.js";
|
|
6
6
|
import { CollapsibleTrigger } from "../collapsible.js";
|
|
7
|
-
import { TraceLine, TraceMarker, useToolDuration, formatDuration } from "./trace-line.js";
|
|
7
|
+
import { TraceLine, TraceMarker, useToolDuration, formatDuration, } from "./trace-line.js";
|
|
8
8
|
export const disclosureContentClass = "border-foreground/10 ms-[5px] border-s ps-4";
|
|
9
9
|
export function DisclosureTrigger({ live, label, detail, }) {
|
|
10
10
|
return (_jsxs(CollapsibleTrigger, { "data-slot": "tool-group-trigger", className: cn("group/trigger my-1 flex max-w-full items-baseline gap-2 text-left font-mono text-[12px] outline-none [font-variant-ligatures:none] focus-visible:underline"), children: [_jsx(TraceMarker, { live: live, className: cn("group-data-[state=open]/trigger:rotate-90") }), _jsx("span", { className: cn("text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors"), children: live ? (_jsxs(ShimmerLabel, { children: [label, detail ? ` ${detail}` : null] })) : (_jsxs(_Fragment, { children: [label, detail ? ` ${detail}` : null] })) })] }));
|
|
11
11
|
}
|
|
12
|
-
export function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation
|
|
12
|
+
export function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }) {
|
|
13
13
|
const tool = presentation?.type === "tool" ? presentation : undefined;
|
|
14
14
|
const error = tool?.error;
|
|
15
|
-
const label = tool?.toolState === "unknown"
|
|
16
|
-
? "Result unknown"
|
|
17
|
-
: tool?.toolState === "rejected"
|
|
18
|
-
? "Rejected"
|
|
19
|
-
: tool?.toolState === "cancelled"
|
|
20
|
-
? "Stopped"
|
|
21
|
-
: tool?.toolState === "not_started"
|
|
22
|
-
? "Not started"
|
|
23
|
-
: tool?.toolState === "failed" || isError
|
|
24
|
-
? "Failed"
|
|
25
|
-
: undefined;
|
|
15
|
+
const label = tool?.toolState === "unknown" ? "Result unknown" : tool?.toolState === "rejected" ? "Rejected" : tool?.toolState === "cancelled" ? "Stopped" : tool?.toolState === "not_started" ? "Not started" : tool?.toolState === "failed" || isError ? "Failed" : undefined;
|
|
26
16
|
const live = !label && status?.type === "running";
|
|
27
17
|
const duration = useToolDuration(live);
|
|
28
|
-
const line =
|
|
29
|
-
const reason = error && !error.parentErrorId && error.scope === "tool" && error.execution !== "unknown" ?
|
|
18
|
+
const line = _jsx(TraceLine, { live: live, label: label ?? (live ? "running" : "ran"), detail: toolName, ...(duration === null ? {} : { meta: formatDuration(duration) }) });
|
|
19
|
+
const reason = error && !error.parentErrorId && error.scope === "tool" && error.execution !== "unknown" ? _jsx("p", { role: "alert", className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: error.userMessage }) : null;
|
|
30
20
|
if (!showDetails)
|
|
31
|
-
return
|
|
32
|
-
return
|
|
33
|
-
? error.userMessage
|
|
34
|
-
: tool?.toolState === "cancelled"
|
|
35
|
-
? "Stopped"
|
|
36
|
-
: tool?.toolState === "rejected"
|
|
37
|
-
? "Rejected"
|
|
38
|
-
: tool?.toolState === "not_started"
|
|
39
|
-
? "Not started"
|
|
40
|
-
: typeof result === "string"
|
|
41
|
-
? result
|
|
42
|
-
: JSON.stringify(result, null, 2) })) : null] })] })] }));
|
|
21
|
+
return _jsxs(_Fragment, { children: [line, reason] });
|
|
22
|
+
return _jsxs(_Fragment, { children: [line, reason, _jsxs(Collapsible, { children: [_jsx(DisclosureTrigger, { live: false, label: "\u64CD\u4F5C\u660E\u7EC6" }), _jsxs(CollapsibleContent, { className: cn(disclosureContentClass), children: [_jsx("pre", { className: cn("overflow-x-auto text-xs"), "aria-label": "\u64CD\u4F5C\u8F93\u5165", children: argsText || JSON.stringify(args, null, 2) }), result !== undefined ? _jsx("pre", { className: cn("overflow-x-auto text-xs"), "aria-label": "\u64CD\u4F5C\u8F93\u51FA", children: error ? error.userMessage : tool?.toolState === "cancelled" ? "Stopped" : tool?.toolState === "rejected" ? "Rejected" : tool?.toolState === "not_started" ? "Not started" : typeof result === "string" ? result : JSON.stringify(result, null, 2) }) : null] })] })] });
|
|
43
23
|
}
|
|
24
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EA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iBAAiB,IAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,0BAAM,GAAG,EAAA,MAAC,kBAAkB,IAAC,SAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,aAC1I,cAAK,SAAS,EAAE,EAAE,CAAC,yBAAyB,CAAC,gBAAa,0BAAM,YAAE,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,EACjH,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAK,SAAS,EAAE,EAAE,CAAC,yBAAyB,CAAC,gBAAa,0BAAM,YAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,CAAC,CAAC,CAAC,IAAI,IACtU,IAAc,IAAG,CAAC;AACzC,CAAC","sourcesContent":["import type { UIMessagePart } from \"../../messages.js\";\nimport { cn } from \"../utils.js\";\nimport { Collapsible, CollapsibleContent } from \"../collapsible.js\";\n\"use client\";\n\nimport type { ToolCallMessagePartProps } from \"@assistant-ui/react\";\nimport { ShimmerLabel } from \"./surfaces.js\";\nimport { CollapsibleTrigger } from \"../collapsible.js\";\nimport {\n TraceLine,\n TraceMarker,\n useToolDuration,\n formatDuration,\n} from \"./trace-line.js\";\n\nexport const disclosureContentClass =\n \"border-foreground/10 ms-[5px] border-s ps-4\";\n\nexport function DisclosureTrigger({\n live,\n label,\n detail,\n}: {\n live: boolean;\n label: string;\n detail?: string;\n}) {\n return (\n <CollapsibleTrigger data-slot=\"tool-group-trigger\" className={cn(\"group/trigger my-1 flex max-w-full items-baseline gap-2 text-left font-mono text-[12px] outline-none [font-variant-ligatures:none] focus-visible:underline\")}>\n <TraceMarker\n live={live}\n className={cn(\"group-data-[state=open]/trigger:rotate-90\")}\n />\n <span className={cn(\"text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors\")}>\n {live ? (\n <ShimmerLabel>\n {label}\n {detail ? ` ${detail}` : null}\n </ShimmerLabel>\n ) : (\n <>\n {label}\n {detail ? ` ${detail}` : null}\n </>\n )}\n </span>\n </CollapsibleTrigger>\n );\n}\n\nexport function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }: ToolCallMessagePartProps & { showDetails: boolean; presentation?: UIMessagePart | undefined }) {\n const tool = presentation?.type === \"tool\" ? presentation : undefined;\n const error = tool?.error;\n const label = tool?.toolState === \"unknown\" ? \"Result unknown\" : tool?.toolState === \"rejected\" ? \"Rejected\" : tool?.toolState === \"cancelled\" ? \"Stopped\" : tool?.toolState === \"not_started\" ? \"Not started\" : tool?.toolState === \"failed\" || isError ? \"Failed\" : undefined;\n const live = !label && status?.type === \"running\";\n const duration = useToolDuration(live);\n const line = <TraceLine live={live} label={label ?? (live ? \"running\" : \"ran\")} detail={toolName} {...(duration === null ? {} : { meta: formatDuration(duration) })} />;\n const reason = error && !error.parentErrorId && error.scope === \"tool\" && error.execution !== \"unknown\" ? <p role=\"alert\" className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}>{error.userMessage}</p> : null;\n if (!showDetails) return <>{line}{reason}</>;\n return <>{line}{reason}<Collapsible><DisclosureTrigger live={false} label=\"操作明细\" /><CollapsibleContent className={cn(disclosureContentClass)}>\n <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输入\">{argsText || JSON.stringify(args, null, 2)}</pre>\n {result !== undefined ? <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输出\">{error ? error.userMessage : tool?.toolState === \"cancelled\" ? \"Stopped\" : tool?.toolState === \"rejected\" ? \"Rejected\" : tool?.toolState === \"not_started\" ? \"Not started\" : typeof result === \"string\" ? result : JSON.stringify(result, null, 2)}</pre> : null}\n </CollapsibleContent></Collapsible></>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/ui/home-demo/type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GACtB,sGAAsG,CAAC;AAEzG,MAAM,CAAC,MAAM,QAAQ,GACnB,4EAA4E,CAAC","sourcesContent":["export const typeSection =\n \"font-display text-[1.5rem] leading-snug font-[550] tracking-[-0.01em] text-balance lg:text-[1.75rem]\";\n\nexport const typeDeck =\n \"text-muted-foreground max-w-[40ch] text-[15px] leading-relaxed text-pretty\";\n"]}
|
package/dist/ui/input.js
CHANGED
|
@@ -5,3 +5,4 @@ const Input = React.forwardRef(function Input({ className, type, ...props }, ref
|
|
|
5
5
|
return (_jsx("input", { ref: ref, type: type, "data-slot": "input", className: cn("file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 bg-muted/60 focus-visible:bg-background h-9 w-full min-w-0 rounded-lg border border-transparent px-3 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-sm", className), ...props }));
|
|
6
6
|
});
|
|
7
7
|
export { Input };
|
|
8
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/ui/input.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAA4D,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IACzI,OAAO,CACL,gBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,eACA,OAAO,EACjB,SAAS,EAAE,EAAE,CACX,ypBAAypB,EACzpB,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport { cn } from \"./utils.js\";\n\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentPropsWithoutRef<\"input\">>(function Input({ className, type, ...props }, ref) {\n return (\n <input\n ref={ref}\n type={type}\n data-slot=\"input\"\n className={cn(\n \"file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 bg-muted/60 focus-visible:bg-background h-9 w-full min-w-0 rounded-lg border border-transparent px-3 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-sm\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport { Input };\n"]}
|
package/dist/ui/markdown-text.js
CHANGED
|
@@ -35,7 +35,7 @@ function MarkdownTable({ className, children, ...props }) {
|
|
|
35
35
|
};
|
|
36
36
|
return (_jsxs("figure", { className: cn("border-foreground/10 rounded-document my-3 border"), children: [_jsxs("div", { className: cn("border-foreground/10 bg-foreground/[0.025] dark:bg-foreground/[0.04] rounded-t-document flex h-9 items-center justify-between border-b px-3"), children: [_jsx("span", { className: cn("text-muted-foreground font-mono text-[11px] [font-variant-ligatures:none]"), children: "\u8868\u683C" }), _jsx("button", { type: "button", onClick: copy, "aria-label": "\u590D\u5236\u8868\u683C Markdown", className: cn("text-muted-foreground hover:text-foreground rounded-control grid size-6 place-items-center transition-colors"), children: isCopied ? (_jsx(CheckIcon, { className: cn("size-3.5") })) : (_jsx(CopyIcon, { className: cn("size-3.5") })) })] }), _jsx("div", { className: cn("overflow-x-auto"), children: _jsx("table", { ref: ref, className: cn("aui-md-table w-full border-separate border-spacing-0 text-[13px]", className), ...props, children: children }) })] }));
|
|
37
37
|
}
|
|
38
|
-
const SyntaxHighlighter = ({ language, code }) =>
|
|
38
|
+
const SyntaxHighlighter = ({ language, code }) => _jsx(CodeBlock, { title: language || undefined, copyText: code, className: cn("my-3"), children: _jsx("pre", { children: _jsx("code", { children: code }) }) });
|
|
39
39
|
const NoCodeHeader = () => null;
|
|
40
40
|
const defaultComponents = memoizeMarkdownComponents({
|
|
41
41
|
h1: ({ className, ...props }) => (_jsx("h1", { className: cn("aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0", className), ...props })),
|
|
@@ -53,7 +53,7 @@ const defaultComponents = memoizeMarkdownComponents({
|
|
|
53
53
|
table: ({ className, ...props }) => _jsx(MarkdownTable, { className: className, ...props }),
|
|
54
54
|
th: ({ className, ...props }) => (_jsx("th", { className: cn("aui-md-th border-foreground/10 border-b px-3 py-1.5 text-start font-medium [[align=center]]:text-center [[align=right]]:text-right", className), ...props })),
|
|
55
55
|
td: ({ className, ...props }) => (_jsx("td", { className: cn("aui-md-td border-foreground/10 border-b px-3 py-1.5 text-start [[align=center]]:text-center [[align=right]]:text-right", className), ...props })),
|
|
56
|
-
tr: ({ className, ...props }) => _jsx("tr", { className: cn("aui-md-tr m-0 p-0", className), ...props }),
|
|
56
|
+
tr: ({ className, ...props }) => (_jsx("tr", { className: cn("aui-md-tr m-0 p-0", className), ...props })),
|
|
57
57
|
li: ({ className, ...props }) => (_jsx("li", { className: cn("aui-md-li leading-relaxed", className), ...props })),
|
|
58
58
|
strong: ({ className, ...props }) => (_jsx("strong", { className: cn("aui-md-strong font-semibold", className), ...props })),
|
|
59
59
|
sup: ({ className, ...props }) => (_jsx("sup", { className: cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline", className), ...props })),
|
|
@@ -66,3 +66,4 @@ const defaultComponents = memoizeMarkdownComponents({
|
|
|
66
66
|
CodeHeader: NoCodeHeader,
|
|
67
67
|
SyntaxHighlighter,
|
|
68
68
|
});
|
|
69
|
+
//# sourceMappingURL=markdown-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-text.js","sourceRoot":"","sources":["../../src/ui/markdown-text.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAA+B,qBAAqB,EAAE,kCAAkC,IAAI,yBAAyB,EAAE,sBAAsB,GAAG,MAAM,8BAA8B,CAAC;AAC5L,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,MAAM,gBAAgB,GAAO,GAAG,EAAE,CAAC,CACjC,KAAC,qBAAqB,IAAC,aAAa,EAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,QAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,SAAE,CAC5H,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,G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AAC;IACD,UAAU,EAAE,YAAY;IACxB,iBAAiB;CAClB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport { type SyntaxHighlighterProps, MarkdownTextPrimitive, unstable_memoizeMarkdownComponents as memoizeMarkdownComponents, useIsMarkdownCodeBlock, } from \"@assistant-ui/react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport { type FC, type ComponentProps, memo, useRef } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { CodeBlock } from \"./code-block.js\";\nimport { useCopyToClipboard } from \"./use-copy-to-clipboard.js\";\nimport { cn } from \"./utils.js\";\nconst MarkdownTextImpl: FC = () => (\n <MarkdownTextPrimitive remarkPlugins={[remarkGfm]} skipHtml className={cn(\"aui-md\")} components={defaultComponents} defer/>\n);\nexport const MarkdownText = memo(MarkdownTextImpl);\nfunction MarkdownTable({\n className,\n children,\n ...props\n}: ComponentProps<\"table\">) {\n const ref = useRef<HTMLTableElement>(null);\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n\n const copy = () => {\n const table = ref.current;\n if (!table) return;\n\n const rows = [...table.querySelectorAll(\"tr\")].map((row) =>\n [...row.querySelectorAll(\"th, td\")].map((cell) =>\n (cell.textContent ?? \"\")\n .replace(/\\s+/g, \" \")\n .trim()\n // The backslash goes first: escaping the pipe alone would turn a cell's\n // own backslash into the escape for it.\n .replace(/[\\\\|]/g, \"\\\\$&\"),\n ),\n );\n if (rows.length === 0) return;\n\n const width = Math.max(...rows.map((row) => row.length));\n const pad = (row: string[]) =>\n `| ${Array.from({ length: width }, (_, i) => row[i] ?? \"\").join(\" | \")} |`;\n const [header, ...body] = rows;\n copyToClipboard(\n [\n pad(header!),\n `| ${Array.from({ length: width }, () => \"---\").join(\" | \")} |`,\n ...body.map(pad),\n ].join(\"\\n\"),\n );\n };\n\n return (\n <figure className={cn(\"border-foreground/10 rounded-document my-3 border\")}>\n <div className={cn(\"border-foreground/10 bg-foreground/[0.025] dark:bg-foreground/[0.04] rounded-t-document flex h-9 items-center justify-between border-b px-3\")}>\n <span className={cn(\"text-muted-foreground font-mono text-[11px] [font-variant-ligatures:none]\")}>\n 表格\n </span>\n <button\n type=\"button\"\n onClick={copy}\n aria-label=\"复制表格 Markdown\"\n className={cn(\"text-muted-foreground hover:text-foreground rounded-control grid size-6 place-items-center transition-colors\")}\n >\n {isCopied ? (\n <CheckIcon className={cn(\"size-3.5\")} />\n ) : (\n <CopyIcon className={cn(\"size-3.5\")} />\n )}\n </button>\n </div>\n <div className={cn(\"overflow-x-auto\")}>\n <table\n ref={ref}\n className={cn(\n \"aui-md-table w-full border-separate border-spacing-0 text-[13px]\",\n className,\n )}\n {...props}\n >\n {children}\n </table>\n </div>\n </figure>\n );\n}\n\nconst SyntaxHighlighter = ({ language, code }: SyntaxHighlighterProps) => <CodeBlock title={language || undefined} copyText={code} className={cn(\"my-3\")}><pre><code>{code}</code></pre></CodeBlock>;\nconst NoCodeHeader = () => null;\nconst defaultComponents = memoizeMarkdownComponents({\n h1: ({ className, ...props }) => (<h1 className={cn(\"aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0\", className)} {...props}/>),\n h2: ({ className, ...props }) => (<h2 className={cn(\"aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0\", className)} {...props}/>),\n h3: ({ className, ...props }) => (<h3 className={cn(\"aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0\", className)} {...props}/>),\n h4: ({ className, ...props }) => (<h4 className={cn(\"aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0\", className)} {...props}/>),\n h5: ({ className, ...props }) => (<h5 className={cn(\"aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0\", className)} {...props}/>),\n h6: ({ className, ...props }) => (<h6 className={cn(\"aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0\", className)} {...props}/>),\n p: ({ className, ...props }) => (<p className={cn(\"aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0\", className)} {...props}/>),\n a: ({ className, ...props }) => (<a className={cn(\"aui-md-a text-primary hover:text-primary/80 underline underline-offset-2\", className)} {...props}/>),\n blockquote: ({ className, ...props }) => (<blockquote className={cn(\"aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4\", className)} {...props}/>),\n ul: ({ className, ...props }) => (<ul className={cn(\"aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1\", className)} {...props}/>),\n ol: ({ className, ...props }) => (<ol className={cn(\"aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1\", className)} {...props}/>),\n hr: ({ className, ...props }) => (<hr className={cn(\"aui-md-hr border-muted-foreground/20 my-3\", className)} {...props}/>),\n table: ({ className, ...props }) => <MarkdownTable className={className} {...props} />,\n th: ({ className, ...props }) => (<th className={cn(\"aui-md-th border-foreground/10 border-b px-3 py-1.5 text-start font-medium [[align=center]]:text-center [[align=right]]:text-right\", className)} {...props}/>),\n td: ({ className, ...props }) => (<td className={cn(\"aui-md-td border-foreground/10 border-b px-3 py-1.5 text-start [[align=center]]:text-center [[align=right]]:text-right\", className)} {...props}/>),\n tr: ({ className, ...props }) => (<tr className={cn(\"aui-md-tr m-0 p-0\", className)} {...props}/>),\n li: ({ className, ...props }) => (<li className={cn(\"aui-md-li leading-relaxed\", className)} {...props}/>),\n strong: ({ className, ...props }) => (<strong className={cn(\"aui-md-strong font-semibold\", className)} {...props}/>),\n sup: ({ className, ...props }) => (<sup className={cn(\"aui-md-sup [&>a]:text-xs [&>a]:no-underline\", className)} {...props}/>),\n pre: ({ className, ...props }) => (<pre className={cn(\"aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed\", className)} {...props}/>),\n code: function Code({ className, ...props }) {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (<code className={cn(!isCodeBlock &&\n \"aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]\", className)} {...props}/>);\n },\n CodeHeader: NoCodeHeader,\n SyntaxHighlighter,\n});\n"]}
|
package/dist/ui/reasoning.aui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { memo, useCallback, useRef } from "react";
|
|
4
|
-
import { useScrollLock } from "@assistant-ui/react";
|
|
4
|
+
import { useScrollLock, } from "@assistant-ui/react";
|
|
5
5
|
import { MarkdownText } from "./markdown-text.js";
|
|
6
6
|
import { ANIMATION_DURATION, ReasoningRoot as ReasoningRootBase, ReasoningContent, ReasoningText, } from "./reasoning.js";
|
|
7
7
|
/** `ReasoningRoot` with the thread viewport scroll locked during disclosure animations. */
|
|
@@ -21,9 +21,10 @@ function ReasoningRoot({ ref, onAnimationStart, ...props }) {
|
|
|
21
21
|
ref.current = node;
|
|
22
22
|
}
|
|
23
23
|
}, [ref]);
|
|
24
|
-
return _jsx(ReasoningRootBase, { ref: composedRef, onAnimationStart: handleAnimationStart, ...props });
|
|
24
|
+
return (_jsx(ReasoningRootBase, { ref: composedRef, onAnimationStart: handleAnimationStart, ...props }));
|
|
25
25
|
}
|
|
26
26
|
const ReasoningImpl = () => _jsx(MarkdownText, {});
|
|
27
27
|
const Reasoning = memo(ReasoningImpl);
|
|
28
28
|
Reasoning.displayName = "Reasoning";
|
|
29
29
|
export { Reasoning, ReasoningRoot, ReasoningContent, ReasoningText };
|
|
30
|
+
//# sourceMappingURL=reasoning.aui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning.aui.js","sourceRoot":"","sources":["../../src/ui/reasoning.aui.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;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SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC","sourcesContent":["\"use client\";\n\nimport { memo, useCallback, useRef } from \"react\";\nimport {\n useScrollLock,\n type ReasoningMessagePartComponent,\n} from \"@assistant-ui/react\";\nimport { MarkdownText } from \"./markdown-text.js\";\nimport {\n ANIMATION_DURATION,\n ReasoningRoot as ReasoningRootBase,\n ReasoningContent,\n ReasoningText,\n type ReasoningRootProps,\n} from \"./reasoning.js\";\n\nexport type { ReasoningRootProps } from \"./reasoning.js\";\n\n/** `ReasoningRoot` with the thread viewport scroll locked during disclosure animations. */\nfunction ReasoningRoot({\n ref,\n onAnimationStart,\n ...props\n}: ReasoningRootProps) {\n const collapsibleRef = useRef<HTMLDivElement | null>(null);\n const lockScroll = useScrollLock(collapsibleRef, ANIMATION_DURATION);\n\n const handleAnimationStart = useCallback(() => {\n lockScroll();\n onAnimationStart?.();\n }, [lockScroll, onAnimationStart]);\n\n const composedRef = useCallback(\n (node: HTMLDivElement | null) => {\n collapsibleRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as { current: HTMLDivElement | null }).current = node;\n }\n },\n [ref],\n );\n\n return (\n <ReasoningRootBase\n ref={composedRef}\n onAnimationStart={handleAnimationStart}\n {...props}\n />\n );\n}\n\nconst ReasoningImpl: ReasoningMessagePartComponent = () => <MarkdownText />;\n\nconst Reasoning = memo(ReasoningImpl);\nReasoning.displayName = \"Reasoning\";\n\nexport { Reasoning, ReasoningRoot, ReasoningContent, ReasoningText };\n"]}
|
package/dist/ui/reasoning.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ export type ReasoningRootProps = Omit<React.ComponentProps<typeof Collapsible>,
|
|
|
24
24
|
declare const ReasoningRoot: import("react").ForwardRefExoticComponent<Omit<ReasoningRootProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
25
|
declare function ReasoningContent({ className, children, ...props }: React.ComponentProps<typeof CollapsibleContent>): import("react").JSX.Element;
|
|
26
26
|
declare function ReasoningText({ className, children, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
27
|
-
export { ReasoningRoot, ReasoningContent, ReasoningText };
|
|
27
|
+
export { ReasoningRoot, ReasoningContent, ReasoningText, };
|
package/dist/ui/reasoning.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import { Collapsible, CollapsibleContent } from "./collapsible.js";
|
|
5
|
+
import { Collapsible, CollapsibleContent, } from "./collapsible.js";
|
|
6
6
|
import { cn } from "./utils.js";
|
|
7
7
|
export const ANIMATION_DURATION = 200;
|
|
8
8
|
const ReasoningPreviewContext = createContext(false);
|
|
@@ -22,7 +22,9 @@ const ReasoningRoot = forwardRef(function ReasoningRoot({ className, variant, op
|
|
|
22
22
|
const [initialOpen] = useState(defaultOpen);
|
|
23
23
|
const [userOpen, setUserOpen] = useState(null);
|
|
24
24
|
const isControlled = controlledOpen !== undefined;
|
|
25
|
-
const isOpen = isControlled
|
|
25
|
+
const isOpen = isControlled
|
|
26
|
+
? controlledOpen
|
|
27
|
+
: (userOpen ?? (streaming || initialOpen));
|
|
26
28
|
const isPreview = streaming === true && isOpen;
|
|
27
29
|
const prevStreamingRef = useRef(streaming);
|
|
28
30
|
useLayoutEffect(() => {
|
|
@@ -70,8 +72,7 @@ function ReasoningText({ className, children, ...props }) {
|
|
|
70
72
|
let pinned = true;
|
|
71
73
|
let lastScrollTop = scrollEl.scrollTop;
|
|
72
74
|
let lastScrollHeight = scrollEl.scrollHeight;
|
|
73
|
-
const isAtBottom = () => Math.abs(scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight) <= 1 ||
|
|
74
|
-
scrollEl.scrollHeight <= scrollEl.clientHeight;
|
|
75
|
+
const isAtBottom = () => Math.abs(scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight) <= 1 || scrollEl.scrollHeight <= scrollEl.clientHeight;
|
|
75
76
|
const pin = () => {
|
|
76
77
|
if (!pinned)
|
|
77
78
|
return;
|
|
@@ -84,7 +85,8 @@ function ReasoningText({ className, children, ...props }) {
|
|
|
84
85
|
if (isAtBottom()) {
|
|
85
86
|
pinned = true;
|
|
86
87
|
}
|
|
87
|
-
else if (scrollEl.scrollTop < lastScrollTop &&
|
|
88
|
+
else if (scrollEl.scrollTop < lastScrollTop &&
|
|
89
|
+
scrollEl.scrollHeight === lastScrollHeight) {
|
|
88
90
|
pinned = false;
|
|
89
91
|
}
|
|
90
92
|
lastScrollTop = scrollEl.scrollTop;
|
|
@@ -101,4 +103,5 @@ function ReasoningText({ className, children, ...props }) {
|
|
|
101
103
|
}, [isPreview]);
|
|
102
104
|
return (_jsx("div", { ref: scrollRef, "data-slot": "reasoning-text", className: cn("aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty", "transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]", "motion-reduce:animate-none", "group-data-open/collapsible-content:animate-in", "group-data-closed/collapsible-content:animate-out", "group-data-open/collapsible-content:fade-in-0", "group-data-closed/collapsible-content:fade-out-0", "group-data-open/collapsible-content:slide-in-from-top-4", "group-data-closed/collapsible-content:slide-out-to-top-4", "group-data-open/collapsible-content:blur-in-[2px]", "group-data-closed/collapsible-content:blur-out-[2px]", "group-data-open/collapsible-content:animation-duration-(--animation-duration)", "group-data-closed/collapsible-content:animation-duration-(--animation-duration)", className), ...props, children: _jsx("div", { ref: contentRef, className: cn("aui-reasoning-text-content space-y-4"), children: children }) }));
|
|
103
105
|
}
|
|
104
|
-
export { ReasoningRoot, ReasoningContent, ReasoningText };
|
|
106
|
+
export { ReasoningRoot, ReasoningContent, ReasoningText, };
|
|
107
|
+
//# sourceMappingURL=reaso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CAAC;QACN,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;QACzC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjD,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,CACL,cACE,GAAG,EAAE,SAAS,eACJ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACX,qGAAqG,EACrG,iFAAiF,EACjF,4BAA4B,EAC5B,gDAAgD,EAChD,mDAAmD,EACnD,+CAA+C,EAC/C,kDAAkD,EAClD,yDAAyD,EACzD,0DAA0D,EAC1D,mDAAmD,EACnD,sDAAsD,EACtD,+EAA+E,EAC/E,iFAAiF,EACjF,SAAS,CACV,KACG,KAAK,YAET,cAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,sCAAsC,CAAC,YACxE,QAAQ,GACL,GACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,GACd,CAAC","sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n Collapsible,\n CollapsibleContent,\n} from \"./collapsible.js\";\nimport { cn } from \"./utils.js\";\n\nexport const ANIMATION_DURATION = 200;\n\nconst ReasoningPreviewContext = createContext(false);\n\nconst reasoningVariants = cva(\"aui-reasoning-root mb-4 w-full\", {\n variants: {\n variant: {\n outline: \"rounded-lg border px-3 py-2\",\n ghost: \"\",\n muted: \"bg-muted/50 rounded-lg px-3 py-2\",\n },\n },\n defaultVariants: {\n variant: \"outline\",\n },\n});\n\nexport type ReasoningRootProps = Omit<\n React.ComponentProps<typeof Collapsible>,\n \"open\" | \"onOpenChange\"\n> &\n VariantProps<typeof reasoningVariants> & {\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n defaultOpen?: boolean;\n /**\n * Whether the reasoning is currently streaming. While `true` the\n * disclosure is held open with a bottom-pinned live preview; when\n * streaming ends it returns to `defaultOpen`, and the first manual\n * toggle takes over the open/close state permanently. The live preview\n * keeps following the newest tokens while the disclosure is open during\n * streaming, even after a manual toggle, and pauses while the reader is\n * scrolled up.\n */\n streaming?: boolean;\n /** Called right before the disclosure animates, on toggle and on streaming transitions. */\n onAnimationStart?: () => void;\n };\n\nconst ReasoningRoot = forwardRef<HTMLDivElement, ReasoningRootProps>(function ReasoningRoot({\n className,\n variant,\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n defaultOpen = false,\n streaming,\n onAnimationStart,\n children,\n ...props\n}: ReasoningRootProps, ref) {\n const [initialOpen] = useState(defaultOpen);\n const [userOpen, setUserOpen] = useState<boolean | null>(null);\n\n const isControlled = controlledOpen !== undefined;\n const isOpen = isControlled\n ? controlledOpen\n : (userOpen ?? (streaming || initialOpen));\n const isPreview = streaming === true && isOpen;\n\n const prevStreamingRef = useRef(streaming);\n useLayoutEffect(() => {\n if (prevStreamingRef.current === streaming) return;\n prevStreamingRef.current = streaming;\n // A streaming transition only animates the panel when the resting state\n // is collapsed; with `defaultOpen` the disclosure stays open across it.\n if (!isControlled && userOpen === null && !initialOpen) {\n onAnimationStart?.();\n }\n }, [streaming, isControlled, userOpen, initialOpen, onAnimationStart]);\n\n const handleOpenChange = useCallback(\n (open: boolean) => {\n onAnimationStart?.();\n if (!isControlled) {\n setUserOpen(open);\n }\n controlledOnOpenChange?.(open);\n },\n [onAnimationStart, isControlled, controlledOnOpenChange],\n );\n\n return (\n <Collapsible\n data-slot=\"reasoning-root\"\n data-variant={variant}\n open={isOpen}\n onOpenChange={handleOpenChange}\n className={cn(\n \"group/reasoning-root\",\n reasoningVariants({ variant, className }),\n )}\n style={\n {\n \"--nxf-animation-duration\": `${ANIMATION_DURATION}ms`,\n } as React.CSSProperties\n }\n ref={ref}\n {...props}\n >\n <ReasoningPreviewContext.Provider value={isPreview}>\n {children}\n </ReasoningPreviewContext.Provider>\n </Collapsible>\n );\n});\n\nfunction ReasoningFade({\n side = \"bottom\",\n className,\n ...props\n}: React.ComponentProps<\"div\"> & { side?: \"top\" | \"bottom\" }) {\n if (side === \"top\") {\n return (\n <div\n data-slot=\"reasoning-fade\"\n className={cn(\n \"aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8\",\n \"bg-[linear-gradient(to_bottom,var(--color-background),transparent)]\",\n \"group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]\",\n \"fade-in-0 animate-in\",\n \"animation-duration-(--animation-duration)\",\n className,\n )}\n {...props}\n />\n );\n }\n\n return (\n <div\n data-slot=\"reasoning-fade\"\n className={cn(\n \"aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8\",\n \"bg-[linear-gradient(to_top,var(--color-background),transparent)]\",\n \"group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]\",\n \"fade-in-0 animate-in\",\n \"animation-duration-(--animation-duration)\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ReasoningContent({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof CollapsibleContent>) {\n const isPreview = useContext(ReasoningPreviewContext);\n\n return (\n <CollapsibleContent\n data-slot=\"reasoning-content\"\n className={cn(\n \"aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none\",\n \"group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none\",\n \"data-closed:animate-collapsible-up\",\n \"data-open:animate-collapsible-down\",\n \"data-closed:fill-mode-forwards\",\n \"data-closed:pointer-events-none\",\n \"[--tw-duration:var(--animation-duration)]\",\n className,\n )}\n {...props}\n >\n <ReasoningFade side=\"top\" />\n {children}\n {isPreview ? <ReasoningFade /> : null}\n </CollapsibleContent>\n );\n}\n\nfunction ReasoningText({\n className,\n children,\n ...props\n}: React.ComponentProps<\"div\">) {\n const isPreview = useContext(ReasoningPreviewContext);\n const scrollRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!isPreview) return;\n const scrollEl = scrollRef.current;\n const contentEl = contentRef.current;\n if (!scrollEl || !contentEl) return;\n\n let pinned = true;\n let lastScrollTop = scrollEl.scrollTop;\n let lastScrollHeight = scrollEl.scrollHeight;\n const isAtBottom = () =>\n Math.abs(\n scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight,\n ) <= 1 || scrollEl.scrollHeight <= scrollEl.clientHeight;\n\n const pin = () => {\n if (!pinned) return;\n scrollEl.scrollTop = scrollEl.scrollHeight;\n };\n // A pin's own scroll event can arrive after new content grew the scroll\n // height and read as \"not at bottom\"; only an upward move at unchanged\n // scroll height is user intent.\n const onScroll = () => {\n if (isAtBottom()) {\n pinned = true;\n } else if (\n scrollEl.scrollTop < lastScrollTop &&\n scrollEl.scrollHeight === lastScrollHeight\n ) {\n pinned = false;\n }\n lastScrollTop = scrollEl.scrollTop;\n lastScrollHeight = scrollEl.scrollHeight;\n };\n\n pin();\n scrollEl.addEventListener(\"scroll\", onScroll);\n const observer = new ResizeObserver(pin);\n observer.observe(contentEl);\n return () => {\n scrollEl.removeEventListener(\"scroll\", onScroll);\n observer.disconnect();\n };\n }, [isPreview]);\n\n return (\n <div\n ref={scrollRef}\n data-slot=\"reasoning-text\"\n className={cn(\n \"aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty\",\n \"transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]\",\n \"motion-reduce:animate-none\",\n \"group-data-open/collapsible-content:animate-in\",\n \"group-data-closed/collapsible-content:animate-out\",\n \"group-data-open/collapsible-content:fade-in-0\",\n \"group-data-closed/collapsible-content:fade-out-0\",\n \"group-data-open/collapsible-content:slide-in-from-top-4\",\n \"group-data-closed/collapsible-content:slide-out-to-top-4\",\n \"group-data-open/collapsible-content:blur-in-[2px]\",\n \"group-data-closed/collapsible-content:blur-out-[2px]\",\n \"group-data-open/collapsible-content:animation-duration-(--animation-duration)\",\n \"group-data-closed/collapsible-content:animation-duration-(--animation-duration)\",\n className,\n )}\n {...props}\n >\n <div ref={contentRef} className={cn(\"aui-reasoning-text-content space-y-4\")}>\n {children}\n </div>\n </div>\n );\n}\n\nexport {\n ReasoningRoot,\n ReasoningContent,\n ReasoningText,\n};\n"]}
|
package/dist/ui/surface.js
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useLayoutEffect, useRef, useState
|
|
3
|
+
import { createContext, useContext, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
const PortalContext = createContext({ container: null, acquire: () => () => { } });
|
|
5
|
-
const tokens = [
|
|
6
|
-
"background",
|
|
7
|
-
"foreground",
|
|
8
|
-
"primary",
|
|
9
|
-
"primary-foreground",
|
|
10
|
-
"primary-hover",
|
|
11
|
-
"muted",
|
|
12
|
-
"muted-foreground",
|
|
13
|
-
"border",
|
|
14
|
-
];
|
|
5
|
+
const tokens = ["background", "foreground", "primary", "primary-foreground", "primary-hover", "muted", "muted-foreground", "border"];
|
|
15
6
|
const DialogContainerContext = createContext(null);
|
|
16
7
|
export function ChatSurface({ children, className, ...props }) {
|
|
17
8
|
const root = useRef(null);
|
|
18
9
|
const [dialogContainer, setDialogContainer] = useState(null);
|
|
19
10
|
const [container, setContainer] = useState(null);
|
|
20
11
|
const [active, setActive] = useState(0);
|
|
21
|
-
const acquire = useRef(() => {
|
|
22
|
-
setActive((n) => n + 1);
|
|
23
|
-
return () => setActive((n) => Math.max(0, n - 1));
|
|
24
|
-
}).current;
|
|
12
|
+
const acquire = useRef(() => { setActive((n) => n + 1); return () => setActive((n) => Math.max(0, n - 1)); }).current;
|
|
25
13
|
useLayoutEffect(() => {
|
|
26
14
|
const node = document.createElement("div");
|
|
27
15
|
node.className = "nexface-ui nexface-chat-portals";
|
|
28
16
|
node.dataset.nexfaceIgnore = "";
|
|
29
17
|
document.body.append(node);
|
|
30
18
|
setContainer(node);
|
|
31
|
-
return () => {
|
|
32
|
-
node.remove();
|
|
33
|
-
};
|
|
19
|
+
return () => { node.remove(); };
|
|
34
20
|
}, []);
|
|
35
21
|
useLayoutEffect(() => {
|
|
36
22
|
const element = root.current;
|
|
@@ -51,18 +37,12 @@ export function ChatSurface({ children, className, ...props }) {
|
|
|
51
37
|
// Observe only theme attributes while a portal is mounted, never page input.
|
|
52
38
|
const observer = new MutationObserver(sync);
|
|
53
39
|
for (let node = element; node; node = node.parentElement)
|
|
54
|
-
observer.observe(node, {
|
|
55
|
-
attributes: true,
|
|
56
|
-
attributeFilter: ["class", "style", "dir", "data-theme"],
|
|
57
|
-
});
|
|
40
|
+
observer.observe(node, { attributes: true, attributeFilter: ["class", "style", "dir", "data-theme"] });
|
|
58
41
|
const media = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
59
42
|
media?.addEventListener("change", sync);
|
|
60
|
-
return () => {
|
|
61
|
-
observer.disconnect();
|
|
62
|
-
media?.removeEventListener("change", sync);
|
|
63
|
-
};
|
|
43
|
+
return () => { observer.disconnect(); media?.removeEventListener("change", sync); };
|
|
64
44
|
}, [container, active, props.style, className]);
|
|
65
|
-
return
|
|
45
|
+
return _jsx(PortalContext.Provider, { value: { container, acquire }, children: _jsx(DialogContainerContext.Provider, { value: dialogContainer, children: _jsxs("div", { ref: root, className: `nexface-ui ${className ?? ""}`, ...props, children: [children, _jsx("div", { ref: setDialogContainer, className: "nexface-chat__dialogs" })] }) }) });
|
|
66
46
|
}
|
|
67
47
|
export function useDialogContainer() {
|
|
68
48
|
return useContext(DialogContainerContext);
|
|
@@ -75,3 +55,4 @@ export function PortalThemeSync() {
|
|
|
75
55
|
useLayoutEffect(acquire, [acquire]);
|
|
76
56
|
return null;
|
|
77
57
|
}
|
|
58
|
+
//# sourceMappingURL=surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/ui/surface.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAC;AAC1G,MAAM,aAAa,GAAG,aAAa,CAGhC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAClD,MAAM,MAAM,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AACrI,MAAM,sBAAsB,GAAG,aAAa,CAAqB,IAAI,CAAC,CAAC;AACvE,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAyB;IAClF,MAAM,IAAI,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IACpF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IACxE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,OA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kBAAkB,EAAE,SAAS,EAAC,uBAAuB,GAAG,IAAM,GAAkC,GAAyB,CAAC;AAC9U,CAAC;AACD,MAAM,UAAU,kBAAkB;IAChC,OAAO,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAC5C,CAAC;AACD,MAAM,UAAU,kBAAkB;IAChC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AACD,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC9C,eAAe,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["\"use client\";\nimport { createContext, useContext, useLayoutEffect, useRef, useState, type ComponentProps } from \"react\";\nconst PortalContext = createContext<{\n container: HTMLElement | null;\n acquire(): () => void;\n}>({ container: null, acquire: () => () => { } });\nconst tokens = [\"background\", \"foreground\", \"primary\", \"primary-foreground\", \"primary-hover\", \"muted\", \"muted-foreground\", \"border\"];\nconst DialogContainerContext = createContext<HTMLElement | null>(null);\nexport function ChatSurface({ children, className, ...props }: ComponentProps<\"div\">) {\n const root = useRef<HTMLDivElement>(null);\n const [dialogContainer, setDialogContainer] = useState<HTMLDivElement | null>(null);\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const [active, setActive] = useState(0);\n const acquire = useRef(() => { setActive((n) => n + 1); return () => setActive((n) => Math.max(0, n - 1)); }).current;\n useLayoutEffect(() => {\n const node = document.createElement(\"div\");\n node.className = \"nexface-ui nexface-chat-portals\";\n node.dataset.nexfaceIgnore = \"\";\n document.body.append(node);\n setContainer(node);\n return () => { node.remove(); };\n }, []);\n useLayoutEffect(() => {\n const element = root.current;\n if (!element || !container)\n return;\n const sync = () => {\n const style = getComputedStyle(element);\n for (const token of tokens)\n container.style.setProperty(`--nxf-${token}`, style.getPropertyValue(`--nxf-${token}`));\n container.style.font = style.font;\n container.style.direction = style.direction;\n container.style.colorScheme = style.colorScheme;\n container.classList.toggle(\"nexface-dark\", Boolean(element.closest(\".dark, .nexface-dark\")));\n };\n sync();\n if (!active)\n return;\n // Observe only theme attributes while a portal is mounted, never page input.\n const observer = new MutationObserver(sync);\n for (let node: HTMLElement | null = element; node; node = node.parentElement)\n observer.observe(node, { attributes: true, attributeFilter: [\"class\", \"style\", \"dir\", \"data-theme\"] });\n const media = window.matchMedia?.(\"(prefers-color-scheme: dark)\");\n media?.addEventListener(\"change\", sync);\n return () => { observer.disconnect(); media?.removeEventListener(\"change\", sync); };\n }, [container, active, props.style, className]);\n return <PortalContext.Provider value={{ container, acquire }}><DialogContainerContext.Provider value={dialogContainer}><div ref={root} className={`nexface-ui ${className ?? \"\"}`} {...props}>{children}<div ref={setDialogContainer} className=\"nexface-chat__dialogs\" /></div></DialogContainerContext.Provider></PortalContext.Provider>;\n}\nexport function useDialogContainer() {\n return useContext(DialogContainerContext);\n}\nexport function usePortalContainer() {\n return useContext(PortalContext).container;\n}\nexport function PortalThemeSync() {\n const { acquire } = useContext(PortalContext);\n useLayoutEffect(acquire, [acquire]);\n return null;\n}\n"]}
|
|
@@ -2,11 +2,11 @@ import { type ComponentProps, type ReactNode } from "react";
|
|
|
2
2
|
import { ThreadListPrimitive } from "@assistant-ui/react";
|
|
3
3
|
export declare function ThreadListRoot({ className, ...props }: ComponentProps<typeof ThreadListPrimitive.Root>): import("react").JSX.Element;
|
|
4
4
|
export declare function ThreadListNew(props: ComponentProps<"button">): import("react").JSX.Element;
|
|
5
|
-
export declare function ThreadListSearch({ value, onValueChange
|
|
5
|
+
export declare function ThreadListSearch({ value, onValueChange }: {
|
|
6
6
|
value: string;
|
|
7
7
|
onValueChange(value: string): void;
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
|
-
export declare function ThreadListItem({ disabled, menu
|
|
9
|
+
export declare function ThreadListItem({ disabled, menu }: {
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
menu: (beginRename: () => void) => ReactNode;
|
|
12
12
|
}): import("react").JSX.Element;
|