@nexface/chat 0.1.15-alpha.1 → 0.1.15-alpha.3

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.
Files changed (130) hide show
  1. package/dist/assistant-attachments.js +60 -17
  2. package/dist/assistant-components.d.ts +3 -3
  3. package/dist/assistant-components.js +77 -29
  4. package/dist/assistant-runtime.d.ts +1 -1
  5. package/dist/assistant-runtime.js +100 -43
  6. package/dist/attachments.js +36 -15
  7. package/dist/client.js +309 -77
  8. package/dist/config.js +4 -5
  9. package/dist/default-chat.d.ts +1 -1
  10. package/dist/default-chat.js +2102 -728
  11. package/dist/errors.d.ts +1 -0
  12. package/dist/errors.js +69 -18
  13. package/dist/index.js +0 -1
  14. package/dist/messages.js +0 -1
  15. package/dist/page-confirmation.js +3 -4
  16. package/dist/protocol-messages.js +290 -66
  17. package/dist/protocol-response.js +38 -18
  18. package/dist/react.d.ts +1 -1
  19. package/dist/react.js +147 -50
  20. package/dist/shared/errors.d.ts +1 -1
  21. package/dist/shared/errors.js +0 -1
  22. package/dist/shared/runtime-controller.d.ts +1 -0
  23. package/dist/shared/runtime-controller.js +0 -1
  24. package/dist/shared/runtime-execution.js +0 -1
  25. package/dist/shared/schema.js +45 -19
  26. package/dist/storage.js +130 -53
  27. package/dist/styles.css +99 -20
  28. package/dist/tool-result.js +7 -3
  29. package/dist/types.js +0 -1
  30. package/dist/ui/attachment.aui.d.ts +1 -1
  31. package/dist/ui/attachment.aui.js +16 -20
  32. package/dist/ui/avatar.js +0 -1
  33. package/dist/ui/button.js +0 -1
  34. package/dist/ui/code-block.js +2 -3
  35. package/dist/ui/collapsible.js +2 -3
  36. package/dist/ui/composer-voice.js +3 -2
  37. package/dist/ui/dialog.d.ts +1 -1
  38. package/dist/ui/dialog.js +9 -4
  39. package/dist/ui/dropdown-menu.js +2 -3
  40. package/dist/ui/home-demo/action-bar.js +0 -1
  41. package/dist/ui/home-demo/composer.js +7 -4
  42. package/dist/ui/home-demo/greeting.d.ts +1 -1
  43. package/dist/ui/home-demo/greeting.js +1 -2
  44. package/dist/ui/home-demo/messages.d.ts +1 -1
  45. package/dist/ui/home-demo/messages.js +4 -5
  46. package/dist/ui/home-demo/styles.js +0 -1
  47. package/dist/ui/home-demo/suggestions.d.ts +1 -1
  48. package/dist/ui/home-demo/suggestions.js +5 -3
  49. package/dist/ui/home-demo/surfaces.js +3 -2
  50. package/dist/ui/home-demo/thread.d.ts +1 -1
  51. package/dist/ui/home-demo/thread.js +1 -2
  52. package/dist/ui/home-demo/trace-line.d.ts +1 -1
  53. package/dist/ui/home-demo/trace-line.js +2 -3
  54. package/dist/ui/home-demo/trace.d.ts +1 -1
  55. package/dist/ui/home-demo/trace.js +28 -9
  56. package/dist/ui/home-demo/type.js +0 -1
  57. package/dist/ui/input.js +0 -1
  58. package/dist/ui/markdown-text.js +2 -3
  59. package/dist/ui/reasoning.aui.js +2 -3
  60. package/dist/ui/reasoning.d.ts +1 -1
  61. package/dist/ui/reasoning.js +6 -9
  62. package/dist/ui/surface.js +27 -8
  63. package/dist/ui/thread-list.aui.d.ts +2 -2
  64. package/dist/ui/thread-list.aui.js +18 -12
  65. package/dist/ui/tool-group.aui.js +2 -3
  66. package/dist/ui/tooltip-icon-button.js +1 -2
  67. package/dist/ui/tooltip.js +0 -1
  68. package/dist/ui/use-attachment-src.js +1 -2
  69. package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
  70. package/dist/ui/use-copy-to-clipboard.js +1 -2
  71. package/dist/ui/utils.js +9 -3
  72. package/dist/use-next-message.js +7 -4
  73. package/dist/voice/types.js +0 -1
  74. package/dist/voice/use-voice.js +35 -13
  75. package/package.json +8 -4
  76. package/dist/assistant-attachments.js.map +0 -1
  77. package/dist/assistant-components.js.map +0 -1
  78. package/dist/assistant-runtime.js.map +0 -1
  79. package/dist/attachments.js.map +0 -1
  80. package/dist/client.js.map +0 -1
  81. package/dist/config.js.map +0 -1
  82. package/dist/default-chat.js.map +0 -7
  83. package/dist/errors.js.map +0 -1
  84. package/dist/index.js.map +0 -1
  85. package/dist/messages.js.map +0 -1
  86. package/dist/page-confirmation.js.map +0 -1
  87. package/dist/protocol-messages.js.map +0 -1
  88. package/dist/protocol-response.js.map +0 -1
  89. package/dist/react.js.map +0 -1
  90. package/dist/shared/errors.js.map +0 -1
  91. package/dist/shared/runtime-controller.js.map +0 -1
  92. package/dist/shared/runtime-execution.js.map +0 -1
  93. package/dist/shared/schema.js.map +0 -1
  94. package/dist/storage.js.map +0 -1
  95. package/dist/tool-result.js.map +0 -1
  96. package/dist/types.js.map +0 -1
  97. package/dist/ui/attachment.aui.js.map +0 -1
  98. package/dist/ui/avatar.js.map +0 -1
  99. package/dist/ui/button.js.map +0 -1
  100. package/dist/ui/code-block.js.map +0 -1
  101. package/dist/ui/collapsible.js.map +0 -1
  102. package/dist/ui/composer-voice.js.map +0 -1
  103. package/dist/ui/dialog.js.map +0 -1
  104. package/dist/ui/dropdown-menu.js.map +0 -1
  105. package/dist/ui/home-demo/action-bar.js.map +0 -1
  106. package/dist/ui/home-demo/composer.js.map +0 -1
  107. package/dist/ui/home-demo/greeting.js.map +0 -1
  108. package/dist/ui/home-demo/messages.js.map +0 -1
  109. package/dist/ui/home-demo/styles.js.map +0 -1
  110. package/dist/ui/home-demo/suggestions.js.map +0 -1
  111. package/dist/ui/home-demo/surfaces.js.map +0 -1
  112. package/dist/ui/home-demo/thread.js.map +0 -1
  113. package/dist/ui/home-demo/trace-line.js.map +0 -1
  114. package/dist/ui/home-demo/trace.js.map +0 -1
  115. package/dist/ui/home-demo/type.js.map +0 -1
  116. package/dist/ui/input.js.map +0 -1
  117. package/dist/ui/markdown-text.js.map +0 -1
  118. package/dist/ui/reasoning.aui.js.map +0 -1
  119. package/dist/ui/reasoning.js.map +0 -1
  120. package/dist/ui/surface.js.map +0 -1
  121. package/dist/ui/thread-list.aui.js.map +0 -1
  122. package/dist/ui/tool-group.aui.js.map +0 -1
  123. package/dist/ui/tooltip-icon-button.js.map +0 -1
  124. package/dist/ui/tooltip.js.map +0 -1
  125. package/dist/ui/use-attachment-src.js.map +0 -1
  126. package/dist/ui/use-copy-to-clipboard.js.map +0 -1
  127. package/dist/ui/utils.js.map +0 -1
  128. package/dist/use-next-message.js.map +0 -1
  129. package/dist/voice/types.js.map +0 -1
  130. package/dist/voice/use-voice.js.map +0 -1
package/dist/ui/dialog.js CHANGED
@@ -23,8 +23,14 @@ function DialogBackgroundGuard() {
23
23
  React.useLayoutEffect(() => {
24
24
  const siblings = Array.from(container?.parentElement?.children ?? []).filter((node) => node instanceof HTMLElement && node !== container);
25
25
  const previous = siblings.map((node) => node.inert);
26
- siblings.forEach((node) => { node.inert = true; });
27
- return () => { siblings.forEach((node, index) => { node.inert = previous[index]; }); };
26
+ siblings.forEach((node) => {
27
+ node.inert = true;
28
+ });
29
+ return () => {
30
+ siblings.forEach((node, index) => {
31
+ node.inert = previous[index];
32
+ });
33
+ };
28
34
  }, [container]);
29
35
  return null;
30
36
  }
@@ -47,5 +53,4 @@ function DialogTitle({ className, ...props }) {
47
53
  function DialogDescription({ className, ...props }) {
48
54
  return (_jsx(DialogPrimitive.Description, { "data-slot": "dialog-description", className: cn("text-sm text-muted-foreground", className), ...props }));
49
55
  }
50
- export { Dialog, DialogContent, DialogDescription, DialogFooter, DialogPortal, DialogTitle, DialogTrigger };
51
- //# sourceMappingURL=dialog.js.map
56
+ export { Dialog, DialogContent, DialogDescription, DialogFooter, DialogPortal, DialogTitle, DialogTrigger, };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { menuContentClass, menuItemClass } from "./home-demo/styles.js";
3
- "use client";
3
+ ("use client");
4
4
  import { usePortalContainer, PortalThemeSync } from "./surface.js";
5
5
  import * as React from "react";
6
6
  import { cn } from "./utils.js";
@@ -9,7 +9,7 @@ function DropdownMenu({ ...props }) {
9
9
  return _jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
10
10
  }
11
11
  const DropdownMenuTrigger = React.forwardRef(function DropdownMenuTrigger({ ...props }, ref) {
12
- return (_jsx(DropdownMenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ref: ref, ...props }));
12
+ return _jsx(DropdownMenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ref: ref, ...props });
13
13
  });
14
14
  function DropdownMenuContent({ children, className, sideOffset = 4, ...props }) {
15
15
  const container = usePortalContainer();
@@ -21,4 +21,3 @@ function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
21
21
  return (_jsx(DropdownMenuPrimitive.Item, { "data-slot": "dropdown-menu-item", "data-inset": inset, "data-variant": variant, className: cn(menuItemClass, "data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[variant=destructive]:text-destructive", className), ...props }));
22
22
  }
23
23
  export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem };
24
- //# sourceMappingURL=dropdown-menu.js.map
@@ -7,4 +7,3 @@ import { actionButtonClass } from "./styles.js";
7
7
  export function AssistantActionBar() {
8
8
  return (_jsx(ActionBarPrimitive.Root, { autohide: "never", className: cn("flex items-center gap-1.5"), children: _jsxs(ActionBarPrimitive.Copy, { "aria-label": "\u590D\u5236\u56DE\u590D", className: cn(actionButtonClass), children: [_jsx(AuiIf, { condition: (s) => s.message.isCopied, children: _jsx(CheckIcon, { className: cn("size-4") }) }), _jsx(AuiIf, { condition: (s) => !s.message.isCopied, children: _jsx(CopyIcon, { className: cn("size-4") }) })] }) }));
9
9
  }
10
- //# sourceMappingURL=action-bar.js.map
@@ -2,11 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ComposerPrimitive, MessagePrimitive } from "@assistant-ui/react";
3
3
  import { cn } from "../utils.js";
4
4
  export function Composer({ children, inputProps, actions, ...props }) {
5
- return (_jsx(ComposerPrimitive.Root, { className: cn("relative w-full"), ...props, children: _jsx(ComposerPrimitive.AttachmentDropzone, { asChild: true, disabled: inputProps.disabled, onDropCapture: (event) => { if (inputProps.disabled)
6
- event.preventDefault(); }, onDragOverCapture: (event) => { if (inputProps.disabled)
7
- event.preventDefault(); }, children: _jsxs("div", { "data-slot": "aui_composer-shell", className: cn("border-foreground/10 bg-muted/30 focus-within:border-foreground/25 data-[dragging=true]:border-foreground/40 rounded-thread flex flex-col border transition-colors data-[dragging=true]:border-dashed"), children: [_jsx("div", { className: cn("has-[.aui-attachment-root]:px-3 has-[.aui-attachment-root]:pt-3"), children: children }), _jsx(ComposerPrimitive.Input, { asChild: true, ...inputProps, children: _jsx("textarea", { "data-composer-input": true, rows: 1, className: cn("placeholder:text-muted-foreground field-sizing-content block max-h-48 w-full resize-none bg-transparent px-4 pt-3 pb-2 text-base leading-6 focus:outline-none") }) }), _jsx("div", { className: cn("flex items-center justify-between gap-2 px-2 pb-2"), children: actions })] }) }) }));
5
+ return (_jsx(ComposerPrimitive.Root, { className: cn("relative w-full"), ...props, children: _jsx(ComposerPrimitive.AttachmentDropzone, { asChild: true, disabled: inputProps.disabled, onDropCapture: (event) => {
6
+ if (inputProps.disabled)
7
+ event.preventDefault();
8
+ }, onDragOverCapture: (event) => {
9
+ if (inputProps.disabled)
10
+ event.preventDefault();
11
+ }, children: _jsxs("div", { "data-slot": "aui_composer-shell", className: cn("border-foreground/10 bg-muted/30 focus-within:border-foreground/25 data-[dragging=true]:border-foreground/40 rounded-thread flex flex-col border transition-colors data-[dragging=true]:border-dashed"), children: [_jsx("div", { className: cn("has-[.aui-attachment-root]:px-3 has-[.aui-attachment-root]:pt-3"), children: children }), _jsx(ComposerPrimitive.Input, { asChild: true, ...inputProps, children: _jsx("textarea", { "data-composer-input": true, rows: 1, className: cn("placeholder:text-muted-foreground field-sizing-content block max-h-48 w-full resize-none bg-transparent px-4 pt-3 pb-2 text-base leading-6 focus:outline-none") }) }), _jsx("div", { className: cn("flex items-center justify-between gap-2 px-2 pb-2"), children: actions })] }) }) }));
8
12
  }
9
13
  export function EditComposer({ children, inputProps, cancelProps, sendProps, ...props }) {
10
14
  return (_jsx(MessagePrimitive.Root, { "data-role": "user", "data-slot": "aui_edit-composer-wrapper", className: cn("mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end"), children: _jsxs(ComposerPrimitive.Root, { className: cn("border-foreground/10 bg-muted/30 focus-within:border-foreground/25 rounded-thread flex w-full max-w-[85%] flex-col border transition-colors"), ...props, children: [_jsx(ComposerPrimitive.Input, { asChild: true, ...inputProps, children: _jsx("textarea", { autoFocus: true, rows: 1, className: cn("field-sizing-content max-h-48 min-h-12 w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-[15px] leading-6 focus:outline-none") }) }), children, _jsxs("div", { className: cn("flex items-center justify-end gap-1.5 px-2.5 pb-2.5"), children: [_jsx(ComposerPrimitive.Cancel, { asChild: true, children: _jsx("button", { type: "button", ...cancelProps, className: cn("text-muted-foreground hover:text-foreground rounded-control h-8 px-3 text-[13px] transition-colors"), children: "\u53D6\u6D88" }) }), _jsx(ComposerPrimitive.Send, { asChild: true, children: _jsx("button", { type: "button", ...sendProps, className: cn("bg-primary text-primary-foreground rounded-control h-8 px-3 text-[13px] font-medium transition-opacity disabled:opacity-40"), children: "\u4FDD\u5B58\u5E76\u91CD\u65B0\u53D1\u9001" }) })] })] }) }));
11
15
  }
12
- //# sourceMappingURL=composer.js.map
@@ -1,4 +1,4 @@
1
- export declare function Greeting({ title, description }: {
1
+ export declare function Greeting({ title, description, }: {
2
2
  title: string;
3
3
  description?: string | undefined;
4
4
  }): import("react").JSX.Element;
@@ -2,7 +2,6 @@ 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
4
  import { typeSection, typeDeck } from "./type.js";
5
- export function Greeting({ title, description }) {
5
+ export function Greeting({ title, description, }) {
6
6
  return (_jsxs("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"), children: [_jsx("p", { className: cn(typeSection), children: title }), description ? _jsx("p", { className: cn(typeDeck), children: description }) : null] }));
7
7
  }
8
- //# sourceMappingURL=greeting.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- export declare function UserMessage({ children, attachments, actions }: {
2
+ export declare function UserMessage({ children, attachments, actions, }: {
3
3
  children: ReactNode;
4
4
  attachments: ReactNode;
5
5
  actions: ReactNode;
@@ -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 } from "@assistant-ui/react";
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,7 +12,6 @@ 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 _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") }) }) });
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
@@ -1,4 +1,3 @@
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
@@ -1,4 +1,4 @@
1
- export declare function Suggestions({ suggestions, disabled, onSend }: {
1
+ export declare function Suggestions({ suggestions, disabled, onSend, }: {
2
2
  suggestions: readonly {
3
3
  label: string;
4
4
  prompt: string;
@@ -4,13 +4,15 @@ 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) => { event.preventDefault(); onSend(suggestion.prompt); }, 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) => {
15
+ event.preventDefault();
16
+ onSend(suggestion.prompt);
17
+ }, className: cn(suggestionChipClass), children: suggestion.label }, suggestion.prompt))) }));
15
18
  }
16
- //# sourceMappingURL=suggestions.js.map
@@ -1,4 +1,5 @@
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 }) { return _jsx("span", { className: cn(active && "shimmer motion-reduce:animate-none", className), ...props }); }
4
- //# sourceMappingURL=surfaces.js.map
3
+ export function ShimmerLabel({ active = true, className, ...props }) {
4
+ return (_jsx("span", { className: cn(active && "shimmer motion-reduce:animate-none", className), ...props }));
5
+ }
@@ -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 }: ThreadProps): import("react").JSX.Element;
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,4 +9,3 @@ 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
@@ -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,6 +33,5 @@ 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
@@ -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 }: ToolCallMessagePartProps & {
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,24 +1,43 @@
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
- "use client";
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" ? "Result unknown" : tool?.toolState === "rejected" ? "Rejected" : tool?.toolState === "cancelled" ? "Stopped" : tool?.toolState === "not_started" ? "Not started" : tool?.toolState === "failed" || isError ? "Failed" : undefined;
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;
16
26
  const live = !label && status?.type === "running";
17
27
  const duration = useToolDuration(live);
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;
28
+ const line = (_jsx(TraceLine, { live: live, label: label ?? (live ? "running" : "ran"), detail: toolName, ...(duration === null ? {} : { meta: formatDuration(duration) }) }));
29
+ 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;
20
30
  if (!showDetails)
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] })] })] });
31
+ return (_jsxs(_Fragment, { children: [line, reason] }));
32
+ 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
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] })] })] }));
23
43
  }
24
- //# sourceMappingURL=trace.js.map
@@ -1,3 +1,2 @@
1
1
  export const typeSection = "font-display text-[1.5rem] leading-snug font-[550] tracking-[-0.01em] text-balance lg:text-[1.75rem]";
2
2
  export const typeDeck = "text-muted-foreground max-w-[40ch] text-[15px] leading-relaxed text-pretty";
3
- //# sourceMappingURL=type.js.map
package/dist/ui/input.js CHANGED
@@ -5,4 +5,3 @@ 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
@@ -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 }) => _jsx(CodeBlock, { title: language || undefined, copyText: code, className: cn("my-3"), children: _jsx("pre", { children: _jsx("code", { children: 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,4 +66,3 @@ const defaultComponents = memoizeMarkdownComponents({
66
66
  CodeHeader: NoCodeHeader,
67
67
  SyntaxHighlighter,
68
68
  });
69
- //# sourceMappingURL=markdown-text.js.map
@@ -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,10 +21,9 @@ 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
@@ -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 };
@@ -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,9 +22,7 @@ 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
26
- ? controlledOpen
27
- : (userOpen ?? (streaming || initialOpen));
25
+ const isOpen = isControlled ? controlledOpen : (userOpen ?? (streaming || initialOpen));
28
26
  const isPreview = streaming === true && isOpen;
29
27
  const prevStreamingRef = useRef(streaming);
30
28
  useLayoutEffect(() => {
@@ -72,7 +70,8 @@ function ReasoningText({ className, children, ...props }) {
72
70
  let pinned = true;
73
71
  let lastScrollTop = scrollEl.scrollTop;
74
72
  let lastScrollHeight = scrollEl.scrollHeight;
75
- const isAtBottom = () => Math.abs(scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight) <= 1 || scrollEl.scrollHeight <= scrollEl.clientHeight;
73
+ const isAtBottom = () => Math.abs(scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight) <= 1 ||
74
+ scrollEl.scrollHeight <= scrollEl.clientHeight;
76
75
  const pin = () => {
77
76
  if (!pinned)
78
77
  return;
@@ -85,8 +84,7 @@ function ReasoningText({ className, children, ...props }) {
85
84
  if (isAtBottom()) {
86
85
  pinned = true;
87
86
  }
88
- else if (scrollEl.scrollTop < lastScrollTop &&
89
- scrollEl.scrollHeight === lastScrollHeight) {
87
+ else if (scrollEl.scrollTop < lastScrollTop && scrollEl.scrollHeight === lastScrollHeight) {
90
88
  pinned = false;
91
89
  }
92
90
  lastScrollTop = scrollEl.scrollTop;
@@ -103,5 +101,4 @@ function ReasoningText({ className, children, ...props }) {
103
101
  }, [isPreview]);
104
102
  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 }) }));
105
103
  }
106
- export { ReasoningRoot, ReasoningContent, ReasoningText, };
107
- //# sourceMappingURL=reasoning.js.map
104
+ export { ReasoningRoot, ReasoningContent, ReasoningText };
@@ -1,22 +1,36 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useLayoutEffect, useRef, useState } from "react";
3
+ import { createContext, useContext, useLayoutEffect, useRef, useState, } from "react";
4
4
  const PortalContext = createContext({ container: null, acquire: () => () => { } });
5
- const tokens = ["background", "foreground", "primary", "primary-foreground", "primary-hover", "muted", "muted-foreground", "border"];
5
+ const tokens = [
6
+ "background",
7
+ "foreground",
8
+ "primary",
9
+ "primary-foreground",
10
+ "primary-hover",
11
+ "muted",
12
+ "muted-foreground",
13
+ "border",
14
+ ];
6
15
  const DialogContainerContext = createContext(null);
7
16
  export function ChatSurface({ children, className, ...props }) {
8
17
  const root = useRef(null);
9
18
  const [dialogContainer, setDialogContainer] = useState(null);
10
19
  const [container, setContainer] = useState(null);
11
20
  const [active, setActive] = useState(0);
12
- const acquire = useRef(() => { setActive((n) => n + 1); return () => setActive((n) => Math.max(0, n - 1)); }).current;
21
+ const acquire = useRef(() => {
22
+ setActive((n) => n + 1);
23
+ return () => setActive((n) => Math.max(0, n - 1));
24
+ }).current;
13
25
  useLayoutEffect(() => {
14
26
  const node = document.createElement("div");
15
27
  node.className = "nexface-ui nexface-chat-portals";
16
28
  node.dataset.nexfaceIgnore = "";
17
29
  document.body.append(node);
18
30
  setContainer(node);
19
- return () => { node.remove(); };
31
+ return () => {
32
+ node.remove();
33
+ };
20
34
  }, []);
21
35
  useLayoutEffect(() => {
22
36
  const element = root.current;
@@ -37,12 +51,18 @@ export function ChatSurface({ children, className, ...props }) {
37
51
  // Observe only theme attributes while a portal is mounted, never page input.
38
52
  const observer = new MutationObserver(sync);
39
53
  for (let node = element; node; node = node.parentElement)
40
- observer.observe(node, { attributes: true, attributeFilter: ["class", "style", "dir", "data-theme"] });
54
+ observer.observe(node, {
55
+ attributes: true,
56
+ attributeFilter: ["class", "style", "dir", "data-theme"],
57
+ });
41
58
  const media = window.matchMedia?.("(prefers-color-scheme: dark)");
42
59
  media?.addEventListener("change", sync);
43
- return () => { observer.disconnect(); media?.removeEventListener("change", sync); };
60
+ return () => {
61
+ observer.disconnect();
62
+ media?.removeEventListener("change", sync);
63
+ };
44
64
  }, [container, active, props.style, className]);
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" })] }) }) });
65
+ 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" })] }) }) }));
46
66
  }
47
67
  export function useDialogContainer() {
48
68
  return useContext(DialogContainerContext);
@@ -55,4 +75,3 @@ export function PortalThemeSync() {
55
75
  useLayoutEffect(acquire, [acquire]);
56
76
  return null;
57
77
  }
58
- //# sourceMappingURL=surface.js.map
@@ -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;
@@ -2,21 +2,21 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  // Official ThreadList composition; Nexface owns the management actions and confirmations.
4
4
  import { useEffect, useRef, useState } from "react";
5
- import { ThreadListItemPrimitive, ThreadListPrimitive, useAui, useAuiState } from "@assistant-ui/react";
5
+ import { ThreadListItemPrimitive, ThreadListPrimitive, useAui, useAuiState, } from "@assistant-ui/react";
6
6
  import { Loader2Icon, MoreHorizontalIcon, PlusIcon, SearchIcon } from "lucide-react";
7
7
  import { Input } from "./input.js";
8
8
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from "./dropdown-menu.js";
9
9
  import { cn } from "./utils.js";
10
10
  export function ThreadListRoot({ className, ...props }) {
11
- return _jsx(ThreadListPrimitive.Root, { "data-slot": "aui_thread-list-root", className: cn("flex flex-col gap-0.5", className), ...props });
11
+ return (_jsx(ThreadListPrimitive.Root, { "data-slot": "aui_thread-list-root", className: cn("flex flex-col gap-0.5", className), ...props }));
12
12
  }
13
13
  export function ThreadListNew(props) {
14
- return _jsx(ThreadListPrimitive.New, { asChild: true, children: _jsxs("button", { type: "button", "data-slot": "aui_thread-list-new", className: cn("border-foreground/10 bg-background hover:border-foreground/25 rounded-control flex h-8 w-full shrink-0 items-center gap-2 border px-2.5 text-[13px] transition-colors"), ...props, children: [_jsx(PlusIcon, { className: cn("size-4 shrink-0") }), "\u65B0\u5EFA\u4F1A\u8BDD"] }) });
14
+ return (_jsx(ThreadListPrimitive.New, { asChild: true, children: _jsxs("button", { type: "button", "data-slot": "aui_thread-list-new", className: cn("border-foreground/10 bg-background hover:border-foreground/25 rounded-control flex h-8 w-full shrink-0 items-center gap-2 border px-2.5 text-[13px] transition-colors"), ...props, children: [_jsx(PlusIcon, { className: cn("size-4 shrink-0") }), "\u65B0\u5EFA\u4F1A\u8BDD"] }) }));
15
15
  }
16
- export function ThreadListSearch({ value, onValueChange }) {
17
- return _jsxs("div", { "data-slot": "aui_thread-list-search", className: cn("relative px-0.5 py-1"), children: [_jsx(SearchIcon, { "data-slot": "aui_thread-list-search-icon", className: cn("text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2") }), _jsx(Input, { type: "search", value: value, onChange: (event) => onValueChange(event.target.value), "aria-label": "\u641C\u7D22\u4F1A\u8BDD", placeholder: "\u641C\u7D22\u4F1A\u8BDD", className: cn("border-foreground/10 bg-background h-8 ps-8 text-[13px] md:text-[13px]") })] });
16
+ export function ThreadListSearch({ value, onValueChange, }) {
17
+ return (_jsxs("div", { "data-slot": "aui_thread-list-search", className: cn("relative px-0.5 py-1"), children: [_jsx(SearchIcon, { "data-slot": "aui_thread-list-search-icon", className: cn("text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2") }), _jsx(Input, { type: "search", value: value, onChange: (event) => onValueChange(event.target.value), "aria-label": "\u641C\u7D22\u4F1A\u8BDD", placeholder: "\u641C\u7D22\u4F1A\u8BDD", className: cn("border-foreground/10 bg-background h-8 ps-8 text-[13px] md:text-[13px]") })] }));
18
18
  }
19
- export function ThreadListItem({ disabled, menu }) {
19
+ export function ThreadListItem({ disabled, menu, }) {
20
20
  const isRunning = useAuiState((s) => s.threadListItem.isRunning);
21
21
  const title = useAuiState((s) => s.threadListItem.title);
22
22
  const [isRenaming, setIsRenaming] = useState(false);
@@ -28,7 +28,10 @@ export function ThreadListItem({ disabled, menu }) {
28
28
  triggerRef.current?.focus();
29
29
  }
30
30
  }, [isRenaming]);
31
- return _jsxs(ThreadListItemPrimitive.Root, { "data-slot": "aui_thread-list-item", className: cn("group data-active:bg-foreground/[0.06] hover:bg-foreground/[0.04] has-data-[state=open]:bg-foreground/[0.04] rounded-control relative flex h-8 shrink-0 items-center transition-colors"), children: [isRenaming ? _jsx(ThreadListItemRename, { onDone: (focus) => { restoreFocus.current = focus; setIsRenaming(false); } }) : _jsxs(ThreadListItemPrimitive.Trigger, { ref: triggerRef, disabled: disabled, "data-slot": "aui_thread-list-item-trigger", className: cn("text-muted-foreground group-data-active:text-foreground hover:text-foreground flex h-full min-w-0 flex-1 items-center px-2 text-left text-[13px] transition-colors outline-none group-hover:pe-8 group-has-focus-visible:pe-8 group-has-data-[state=open]:pe-8 group-data-active:pe-8"), children: [isRunning && _jsx(Loader2Icon, { "aria-hidden": true, className: cn("text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin") }), _jsx("span", { className: cn("min-w-0 flex-1 truncate"), children: _jsx(ThreadListItemPrimitive.Title, { fallback: "\u65B0\u4F1A\u8BDD" }) })] }), _jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": `管理 ${title}`, className: cn("text-muted-foreground hover:text-foreground absolute end-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-sm opacity-0 transition-colors group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100"), children: _jsx(MoreHorizontalIcon, { className: cn("size-3.5") }) }) }), _jsx(DropdownMenuContent, { side: "right", align: "start", sideOffset: 6, children: menu(() => setIsRenaming(true)) })] })] });
31
+ return (_jsxs(ThreadListItemPrimitive.Root, { "data-slot": "aui_thread-list-item", className: cn("group data-active:bg-foreground/[0.06] hover:bg-foreground/[0.04] has-data-[state=open]:bg-foreground/[0.04] rounded-control relative flex h-8 shrink-0 items-center transition-colors"), children: [isRenaming ? (_jsx(ThreadListItemRename, { onDone: (focus) => {
32
+ restoreFocus.current = focus;
33
+ setIsRenaming(false);
34
+ } })) : (_jsxs(ThreadListItemPrimitive.Trigger, { ref: triggerRef, disabled: disabled, "data-slot": "aui_thread-list-item-trigger", className: cn("text-muted-foreground group-data-active:text-foreground hover:text-foreground flex h-full min-w-0 flex-1 items-center px-2 text-left text-[13px] transition-colors outline-none group-hover:pe-8 group-has-focus-visible:pe-8 group-has-data-[state=open]:pe-8 group-data-active:pe-8"), children: [isRunning && (_jsx(Loader2Icon, { "aria-hidden": true, className: cn("text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin") })), _jsx("span", { className: cn("min-w-0 flex-1 truncate"), children: _jsx(ThreadListItemPrimitive.Title, { fallback: "\u65B0\u4F1A\u8BDD" }) })] })), _jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": `管理 ${title}`, className: cn("text-muted-foreground hover:text-foreground absolute end-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-sm opacity-0 transition-colors group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100"), children: _jsx(MoreHorizontalIcon, { className: cn("size-3.5") }) }) }), _jsx(DropdownMenuContent, { side: "right", align: "start", sideOffset: 6, children: menu(() => setIsRenaming(true)) })] })] }));
32
35
  }
33
36
  function ThreadListItemRename({ onDone }) {
34
37
  const aui = useAui();
@@ -36,7 +39,9 @@ function ThreadListItemRename({ onDone }) {
36
39
  const [value, setValue] = useState(title);
37
40
  const inputRef = useRef(null);
38
41
  const settled = useRef(false);
39
- useEffect(() => { inputRef.current?.select(); }, []);
42
+ useEffect(() => {
43
+ inputRef.current?.select();
44
+ }, []);
40
45
  const commit = (focus) => {
41
46
  if (settled.current)
42
47
  return;
@@ -46,13 +51,15 @@ function ThreadListItemRename({ onDone }) {
46
51
  onDone(focus);
47
52
  return;
48
53
  }
49
- void Promise.resolve().then(() => aui.threadListItem.rename(next)).then(() => onDone(focus), () => {
54
+ void Promise.resolve()
55
+ .then(() => aui.threadListItem.rename(next))
56
+ .then(() => onDone(focus), () => {
50
57
  settled.current = false;
51
58
  if (focus)
52
59
  inputRef.current?.focus();
53
60
  });
54
61
  };
55
- return _jsx(Input, { ref: inputRef, autoFocus: true, "data-slot": "aui_thread-list-item-rename", "aria-label": "\u4F1A\u8BDD\u540D\u79F0", maxLength: 80, value: value, className: cn("h-7 min-w-0 flex-1 ps-2 pe-8 text-[13px] md:text-[13px]"), onChange: (event) => setValue(event.target.value), onBlur: () => commit(false), onKeyDown: (event) => {
62
+ return (_jsx(Input, { ref: inputRef, autoFocus: true, "data-slot": "aui_thread-list-item-rename", "aria-label": "\u4F1A\u8BDD\u540D\u79F0", maxLength: 80, value: value, className: cn("h-7 min-w-0 flex-1 ps-2 pe-8 text-[13px] md:text-[13px]"), onChange: (event) => setValue(event.target.value), onBlur: () => commit(false), onKeyDown: (event) => {
56
63
  if (event.nativeEvent.isComposing || event.keyCode === 229)
57
64
  return;
58
65
  if (event.key === "Enter") {
@@ -64,6 +71,5 @@ function ThreadListItemRename({ onDone }) {
64
71
  settled.current = true;
65
72
  onDone(true);
66
73
  }
67
- } });
74
+ } }));
68
75
  }
69
- //# sourceMappingURL=thread-list.aui.js.map
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useCallback, useRef, useState, } from "react";
3
+ import { useCallback, useRef, useState } from "react";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { useScrollLock } from "@assistant-ui/react";
6
- import { Collapsible, CollapsibleContent, } from "./collapsible.js";
6
+ import { Collapsible, CollapsibleContent } from "./collapsible.js";
7
7
  import { cn } from "./utils.js";
8
8
  const ANIMATION_DURATION = 200;
9
9
  const toolGroupVariants = cva("aui-tool-group-root group/tool-group w-full", {
@@ -37,4 +37,3 @@ function ToolGroupContent({ className, children, ...props }) {
37
37
  return (_jsx(CollapsibleContent, { "data-slot": "tool-group-content", className: cn("aui-tool-group-content relative overflow-hidden text-sm outline-none", "group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none", "data-closed:animate-collapsible-up", "data-open:animate-collapsible-down", "data-closed:fill-mode-forwards", "data-closed:pointer-events-none", "[--nxf-tw-duration:var(--animation-duration)]", className), ...props, children: _jsx("div", { className: cn("mt-2 flex flex-col gap-2", "group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1", "group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3", "group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3", "[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]", "[&>*]:motion-reduce:animate-none", "[&>*:nth-child(2)]:[animation-delay:40ms]", "[&>*:nth-child(3)]:[animation-delay:80ms]", "[&>*:nth-child(4)]:[animation-delay:120ms]", "[&>*:nth-child(n+5)]:[animation-delay:160ms]"), children: children }) }));
38
38
  }
39
39
  export { ToolGroupRoot, ToolGroupContent };
40
- //# sourceMappingURL=tool-group.aui.js.map