@assistant-ui/react 0.7.7 → 0.7.8

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 (97) hide show
  1. package/dist/primitives/threadList/ThreadListItems.d.ts +2 -2
  2. package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  3. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  4. package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -1
  5. package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
  6. package/dist/primitives/threadList/ThreadListNew.js +23 -6
  7. package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
  8. package/dist/primitives/threadList/ThreadListNew.mjs +24 -9
  9. package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -1
  10. package/dist/styles/index.css +66 -0
  11. package/dist/styles/index.css.map +1 -1
  12. package/dist/styles/tailwindcss/thread.css +30 -0
  13. package/dist/styles/tailwindcss/thread.css.json +21 -0
  14. package/dist/ui/assistant-action-bar.d.ts +7 -7
  15. package/dist/ui/assistant-action-bar.d.ts.map +1 -1
  16. package/dist/ui/assistant-action-bar.js.map +1 -1
  17. package/dist/ui/assistant-action-bar.mjs +1 -3
  18. package/dist/ui/assistant-action-bar.mjs.map +1 -1
  19. package/dist/ui/assistant-modal.d.ts +3 -3
  20. package/dist/ui/assistant-modal.d.ts.map +1 -1
  21. package/dist/ui/assistant-modal.js.map +1 -1
  22. package/dist/ui/assistant-modal.mjs +1 -3
  23. package/dist/ui/assistant-modal.mjs.map +1 -1
  24. package/dist/ui/attachment-ui.d.ts +2 -2
  25. package/dist/ui/attachment-ui.d.ts.map +1 -1
  26. package/dist/ui/attachment-ui.js.map +1 -1
  27. package/dist/ui/attachment-ui.mjs +1 -3
  28. package/dist/ui/attachment-ui.mjs.map +1 -1
  29. package/dist/ui/base/index.d.ts +1 -1
  30. package/dist/ui/base/index.d.ts.map +1 -1
  31. package/dist/ui/base/index.js.map +1 -1
  32. package/dist/ui/base/index.mjs +1 -3
  33. package/dist/ui/base/index.mjs.map +1 -1
  34. package/dist/ui/base/tooltip-icon-button.d.ts +6 -4
  35. package/dist/ui/base/tooltip-icon-button.d.ts.map +1 -1
  36. package/dist/ui/base/tooltip-icon-button.js.map +1 -1
  37. package/dist/ui/base/tooltip-icon-button.mjs.map +1 -1
  38. package/dist/ui/branch-picker.d.ts +3 -3
  39. package/dist/ui/branch-picker.d.ts.map +1 -1
  40. package/dist/ui/branch-picker.js.map +1 -1
  41. package/dist/ui/branch-picker.mjs +1 -3
  42. package/dist/ui/branch-picker.mjs.map +1 -1
  43. package/dist/ui/composer.d.ts +4 -4
  44. package/dist/ui/composer.d.ts.map +1 -1
  45. package/dist/ui/composer.js.map +1 -1
  46. package/dist/ui/composer.mjs +1 -3
  47. package/dist/ui/composer.mjs.map +1 -1
  48. package/dist/ui/index.d.ts +2 -0
  49. package/dist/ui/index.d.ts.map +1 -1
  50. package/dist/ui/index.js +6 -0
  51. package/dist/ui/index.js.map +1 -1
  52. package/dist/ui/index.mjs +4 -0
  53. package/dist/ui/index.mjs.map +1 -1
  54. package/dist/ui/thread-config.d.ts +13 -0
  55. package/dist/ui/thread-config.d.ts.map +1 -1
  56. package/dist/ui/thread-config.js.map +1 -1
  57. package/dist/ui/thread-config.mjs.map +1 -1
  58. package/dist/ui/thread-list-item.d.ts +24 -0
  59. package/dist/ui/thread-list-item.d.ts.map +1 -0
  60. package/dist/ui/thread-list-item.js +107 -0
  61. package/dist/ui/thread-list-item.js.map +1 -0
  62. package/dist/ui/thread-list-item.mjs +77 -0
  63. package/dist/ui/thread-list-item.mjs.map +1 -0
  64. package/dist/ui/thread-list.d.ts +20 -0
  65. package/dist/ui/thread-list.d.ts.map +1 -0
  66. package/dist/ui/thread-list.js +92 -0
  67. package/dist/ui/thread-list.js.map +1 -0
  68. package/dist/ui/thread-list.mjs +62 -0
  69. package/dist/ui/thread-list.mjs.map +1 -0
  70. package/dist/ui/thread.d.ts +2 -2
  71. package/dist/ui/thread.d.ts.map +1 -1
  72. package/dist/ui/thread.js.map +1 -1
  73. package/dist/ui/thread.mjs +1 -3
  74. package/dist/ui/thread.mjs.map +1 -1
  75. package/dist/ui/user-action-bar.d.ts +2 -2
  76. package/dist/ui/user-action-bar.d.ts.map +1 -1
  77. package/dist/ui/user-action-bar.js.map +1 -1
  78. package/dist/ui/user-action-bar.mjs +1 -3
  79. package/dist/ui/user-action-bar.mjs.map +1 -1
  80. package/package.json +5 -5
  81. package/src/primitives/threadList/ThreadListItems.tsx +3 -3
  82. package/src/primitives/threadList/ThreadListNew.tsx +45 -0
  83. package/src/styles/tailwindcss/thread.css +30 -0
  84. package/src/ui/assistant-action-bar.tsx +7 -10
  85. package/src/ui/assistant-modal.tsx +3 -6
  86. package/src/ui/attachment-ui.tsx +2 -5
  87. package/src/ui/base/index.ts +1 -4
  88. package/src/ui/base/tooltip-icon-button.tsx +7 -5
  89. package/src/ui/branch-picker.tsx +3 -6
  90. package/src/ui/composer.tsx +4 -7
  91. package/src/ui/index.ts +4 -0
  92. package/src/ui/thread-config.tsx +13 -0
  93. package/src/ui/thread-list-item.tsx +99 -0
  94. package/src/ui/thread-list.tsx +72 -0
  95. package/src/ui/thread.tsx +2 -5
  96. package/src/ui/user-action-bar.tsx +2 -5
  97. package/src/primitives/threadList/ThreadListNew.ts +0 -25
@@ -10,10 +10,7 @@ import {
10
10
  import { CircleXIcon, FileIcon } from "lucide-react";
11
11
  import { withDefaults } from "./utils/withDefaults";
12
12
  import { useThreadConfig } from "./thread-config";
13
- import {
14
- TooltipIconButton,
15
- TooltipIconButtonProps,
16
- } from "./base/tooltip-icon-button";
13
+ import { TooltipIconButton } from "./base/tooltip-icon-button";
17
14
  import { AttachmentPrimitive } from "../primitives";
18
15
  import { useAttachment } from "../context/react/AttachmentContext";
19
16
  import {
@@ -169,7 +166,7 @@ AttachmentUI.displayName = "Attachment";
169
166
 
170
167
  namespace AttachmentRemove {
171
168
  export type Element = HTMLButtonElement;
172
- export type Props = Partial<TooltipIconButtonProps>;
169
+ export type Props = Partial<TooltipIconButton.Props>;
173
170
  }
174
171
 
175
172
  const AttachmentRemove = forwardRef<
@@ -10,9 +10,6 @@ export { Button, buttonVariants, type ButtonProps } from "./button";
10
10
 
11
11
  export { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
12
12
 
13
- export {
14
- TooltipIconButton,
15
- type TooltipIconButtonProps,
16
- } from "./tooltip-icon-button";
13
+ export { TooltipIconButton } from "./tooltip-icon-button";
17
14
 
18
15
  export { CircleStopIcon } from "./CircleStopIcon";
@@ -4,14 +4,16 @@ import { forwardRef } from "react";
4
4
  import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
5
5
  import { Button, ButtonProps } from "./button";
6
6
 
7
- export type TooltipIconButtonProps = ButtonProps & {
8
- tooltip: string;
9
- side?: "top" | "bottom" | "left" | "right";
10
- };
7
+ export namespace TooltipIconButton {
8
+ export type Props = ButtonProps & {
9
+ tooltip: string;
10
+ side?: "top" | "bottom" | "left" | "right";
11
+ };
12
+ }
11
13
 
12
14
  export const TooltipIconButton = forwardRef<
13
15
  HTMLButtonElement,
14
- TooltipIconButtonProps
16
+ TooltipIconButton.Props
15
17
  >(({ children, tooltip, side = "bottom", ...rest }, ref) => {
16
18
  return (
17
19
  <Tooltip>
@@ -3,10 +3,7 @@
3
3
  import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
4
4
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
5
5
 
6
- import {
7
- TooltipIconButton,
8
- TooltipIconButtonProps,
9
- } from "./base/tooltip-icon-button";
6
+ import { TooltipIconButton } from "./base/tooltip-icon-button";
10
7
  import { withDefaults } from "./utils/withDefaults";
11
8
  import { useThreadConfig } from "./thread-config";
12
9
  import { BranchPickerPrimitive } from "../primitives";
@@ -40,7 +37,7 @@ BranchPickerRoot.displayName = "BranchPickerRoot";
40
37
 
41
38
  namespace BranchPickerPrevious {
42
39
  export type Element = BranchPickerPrimitive.Previous.Element;
43
- export type Props = Partial<TooltipIconButtonProps>;
40
+ export type Props = Partial<TooltipIconButton.Props>;
44
41
  }
45
42
 
46
43
  const BranchPickerPrevious = forwardRef<
@@ -88,7 +85,7 @@ BranchPickerState.displayName = "BranchPickerState";
88
85
 
89
86
  namespace BranchPickerNext {
90
87
  export type Element = BranchPickerPrimitive.Next.Element;
91
- export type Props = Partial<TooltipIconButtonProps>;
88
+ export type Props = Partial<TooltipIconButton.Props>;
92
89
  }
93
90
 
94
91
  const BranchPickerNext = forwardRef<
@@ -5,10 +5,7 @@ import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
5
5
  import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
6
6
  import { withDefaults } from "./utils/withDefaults";
7
7
  import { useThreadConfig } from "./thread-config";
8
- import {
9
- TooltipIconButton,
10
- TooltipIconButtonProps,
11
- } from "./base/tooltip-icon-button";
8
+ import { TooltipIconButton } from "./base/tooltip-icon-button";
12
9
  import { CircleStopIcon } from "./base/CircleStopIcon";
13
10
  import { ComposerPrimitive, ThreadPrimitive } from "../primitives";
14
11
  import { useThread } from "../context/react/ThreadContext";
@@ -94,7 +91,7 @@ const ComposerAttachButton = withDefaults(TooltipIconButton, {
94
91
 
95
92
  namespace ComposerAddAttachment {
96
93
  export type Element = HTMLButtonElement;
97
- export type Props = Partial<TooltipIconButtonProps>;
94
+ export type Props = Partial<TooltipIconButton.Props>;
98
95
  }
99
96
 
100
97
  const ComposerAddAttachment = forwardRef<
@@ -152,7 +149,7 @@ const ComposerSendButton = withDefaults(TooltipIconButton, {
152
149
 
153
150
  namespace ComposerSend {
154
151
  export type Element = HTMLButtonElement;
155
- export type Props = Partial<TooltipIconButtonProps>;
152
+ export type Props = Partial<TooltipIconButton.Props>;
156
153
  }
157
154
 
158
155
  const ComposerSend = forwardRef<ComposerSend.Element, ComposerSend.Props>(
@@ -179,7 +176,7 @@ const ComposerCancelButton = withDefaults(TooltipIconButton, {
179
176
 
180
177
  namespace ComposerCancel {
181
178
  export type Element = HTMLButtonElement;
182
- export type Props = Partial<TooltipIconButtonProps>;
179
+ export type Props = Partial<TooltipIconButton.Props>;
183
180
  }
184
181
 
185
182
  const ComposerCancel = forwardRef<ComposerCancel.Element, ComposerCancel.Props>(
package/src/ui/index.ts CHANGED
@@ -35,3 +35,7 @@ export { default as UserActionBar } from "./user-action-bar";
35
35
  export { default as ThreadWelcome } from "./thread-welcome";
36
36
 
37
37
  export { default as ContentPart } from "./content-part";
38
+
39
+ export { default as ThreadList } from "./thread-list";
40
+
41
+ export { default as ThreadListItem } from "./thread-list-item";
@@ -65,6 +65,19 @@ export type StringsConfig = {
65
65
  };
66
66
  };
67
67
  };
68
+ threadList?: {
69
+ new?: {
70
+ label?: string | undefined;
71
+ };
72
+ item?: {
73
+ title?: {
74
+ fallback?: string | undefined;
75
+ };
76
+ archive?: {
77
+ label?: string | undefined;
78
+ };
79
+ };
80
+ };
68
81
  thread?: {
69
82
  scrollToBottom?: {
70
83
  tooltip?: string | undefined;
@@ -0,0 +1,99 @@
1
+ "use client";
2
+
3
+ import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
4
+ import { ArchiveIcon } from "lucide-react";
5
+
6
+ import { withDefaults } from "./utils/withDefaults";
7
+ import { TooltipIconButton } from "./base/tooltip-icon-button";
8
+ import { ThreadListItemPrimitive } from "../primitives";
9
+ import { useThreadConfig } from "./thread-config";
10
+ import classNames from "classnames";
11
+
12
+ const ThreadListItem: FC = () => {
13
+ return (
14
+ <ThreadListItemRoot>
15
+ <ThreadListItemTrigger>
16
+ <ThreadListItemTitle />
17
+ </ThreadListItemTrigger>
18
+ <ThreadListItemArchive />
19
+ </ThreadListItemRoot>
20
+ );
21
+ };
22
+
23
+ const ThreadListItemRoot = withDefaults(ThreadListItemPrimitive.Root, {
24
+ className: "aui-thread-list-item",
25
+ });
26
+
27
+ ThreadListItemRoot.displayName = "ThreadListItemRoot";
28
+
29
+ const ThreadListItemTrigger = withDefaults(ThreadListItemPrimitive.Trigger, {
30
+ className: "aui-thread-list-item-trigger",
31
+ });
32
+
33
+ namespace ThreadListItemPrimitiveTitle {
34
+ export type Element = HTMLParagraphElement;
35
+ export type Props = ComponentPropsWithoutRef<"p">;
36
+ }
37
+
38
+ const ThreadListItemTitle = forwardRef<
39
+ ThreadListItemPrimitiveTitle.Element,
40
+ ThreadListItemPrimitiveTitle.Props
41
+ >(({ className, ...props }, ref) => {
42
+ const {
43
+ strings: {
44
+ threadList: { item: { title: { fallback = "New Chat" } = {} } = {} } = {},
45
+ } = {},
46
+ } = useThreadConfig();
47
+
48
+ return (
49
+ <p
50
+ ref={ref}
51
+ className={classNames("aui-thread-list-item-title", className)}
52
+ {...props}
53
+ >
54
+ <ThreadListItemPrimitive.Title fallback={fallback} />
55
+ </p>
56
+ );
57
+ });
58
+
59
+ ThreadListItemTitle.displayName = "ThreadListItemTitle";
60
+
61
+ const ThreadListItemArchive = withDefaults(
62
+ forwardRef<HTMLButtonElement, TooltipIconButton.Props>(
63
+ ({ className, ...props }, ref) => {
64
+ const {
65
+ strings: {
66
+ threadList: {
67
+ item: { archive: { label = "Archive thread" } = {} } = {},
68
+ } = {},
69
+ } = {},
70
+ } = useThreadConfig();
71
+
72
+ return (
73
+ <ThreadListItemPrimitive.Archive asChild>
74
+ <TooltipIconButton
75
+ {...props}
76
+ ref={ref}
77
+ className={classNames("aui-thread-list-item-archive", className)}
78
+ variant="ghost"
79
+ tooltip={label}
80
+ >
81
+ <ArchiveIcon />
82
+ </TooltipIconButton>
83
+ </ThreadListItemPrimitive.Archive>
84
+ );
85
+ },
86
+ ),
87
+ {},
88
+ );
89
+
90
+ ThreadListItemArchive.displayName = "ThreadListItemArchive";
91
+
92
+ const exports = {
93
+ Root: ThreadListItemRoot,
94
+ Title: ThreadListItemTitle,
95
+ Archive: ThreadListItemArchive,
96
+ };
97
+
98
+ export default Object.assign(ThreadListItem, exports) as typeof ThreadListItem &
99
+ typeof exports;
@@ -0,0 +1,72 @@
1
+ "use client";
2
+
3
+ import { forwardRef, type FC } from "react";
4
+ import { PlusIcon } from "lucide-react";
5
+
6
+ import { withDefaults } from "./utils/withDefaults";
7
+ import { ThreadListPrimitive } from "../primitives";
8
+ import ThreadListItem from "./thread-list-item";
9
+ import { useThreadConfig } from "./thread-config";
10
+ import { Button, ButtonProps } from "./base";
11
+
12
+ const ThreadList: FC = () => {
13
+ return (
14
+ <ThreadListRoot>
15
+ <ThreadListNew />
16
+ <ThreadListItems />
17
+ </ThreadListRoot>
18
+ );
19
+ };
20
+
21
+ const ThreadListRoot = withDefaults("div", {
22
+ className: "aui-root aui-thread-list-root",
23
+ });
24
+ ThreadListRoot.displayName = "ThreadListRoot";
25
+
26
+ const ThreadListNew = forwardRef<
27
+ HTMLButtonElement,
28
+ ThreadListPrimitive.New.Props & ButtonProps
29
+ >((props, ref) => {
30
+ const {
31
+ strings: { threadList: { new: { label = "New Thread" } = {} } = {} } = {},
32
+ } = useThreadConfig();
33
+
34
+ return (
35
+ <ThreadListPrimitive.New asChild>
36
+ <Button
37
+ {...props}
38
+ ref={ref}
39
+ className="aui-thread-list-new"
40
+ variant="ghost"
41
+ >
42
+ <PlusIcon />
43
+ {label}
44
+ </Button>
45
+ </ThreadListPrimitive.New>
46
+ );
47
+ });
48
+ ThreadListNew.displayName = "ThreadListNew";
49
+
50
+ const ThreadListItems: FC<{
51
+ components?: Partial<ThreadListPrimitive.Items.Props["components"]>;
52
+ }> = ({ components }) => {
53
+ return (
54
+ <ThreadListPrimitive.Items
55
+ components={{
56
+ ...components,
57
+ ThreadListItem: components?.ThreadListItem ?? ThreadListItem,
58
+ }}
59
+ />
60
+ );
61
+ };
62
+
63
+ ThreadListItems.displayName = "ThreadListItems";
64
+
65
+ const exports = {
66
+ Root: ThreadListRoot,
67
+ New: ThreadListNew,
68
+ Items: ThreadListItems,
69
+ };
70
+
71
+ export default Object.assign(ThreadList, exports) as typeof ThreadList &
72
+ typeof exports;
package/src/ui/thread.tsx CHANGED
@@ -6,10 +6,7 @@ import { ArrowDownIcon } from "lucide-react";
6
6
  import { withDefaults } from "./utils/withDefaults";
7
7
  import Composer from "./composer";
8
8
  import ThreadWelcome from "./thread-welcome";
9
- import {
10
- TooltipIconButton,
11
- TooltipIconButtonProps,
12
- } from "./base/tooltip-icon-button";
9
+ import { TooltipIconButton } from "./base/tooltip-icon-button";
13
10
  import AssistantMessage from "./assistant-message";
14
11
  import UserMessage from "./user-message";
15
12
  import EditComposer from "./edit-composer";
@@ -133,7 +130,7 @@ const ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
133
130
 
134
131
  namespace ThreadScrollToBottom {
135
132
  export type Element = HTMLButtonElement;
136
- export type Props = Partial<TooltipIconButtonProps>;
133
+ export type Props = Partial<TooltipIconButton.Props>;
137
134
  }
138
135
 
139
136
  const ThreadScrollToBottom = forwardRef<
@@ -3,10 +3,7 @@
3
3
  import { forwardRef, type FC } from "react";
4
4
  import { PencilIcon } from "lucide-react";
5
5
 
6
- import {
7
- TooltipIconButton,
8
- TooltipIconButtonProps,
9
- } from "./base/tooltip-icon-button";
6
+ import { TooltipIconButton } from "./base/tooltip-icon-button";
10
7
  import { withDefaults } from "./utils/withDefaults";
11
8
  import { useThreadConfig } from "./thread-config";
12
9
  import { useThread } from "../context";
@@ -38,7 +35,7 @@ UserActionBarRoot.displayName = "UserActionBarRoot";
38
35
 
39
36
  namespace UserActionBarEdit {
40
37
  export type Element = ActionBarPrimitive.Edit.Element;
41
- export type Props = Partial<TooltipIconButtonProps>;
38
+ export type Props = Partial<TooltipIconButton.Props>;
42
39
  }
43
40
 
44
41
  const UserActionBarEdit = forwardRef<
@@ -1,25 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- ActionButtonElement,
5
- ActionButtonProps,
6
- createActionButton,
7
- } from "../../utils/createActionButton";
8
- import { useAssistantRuntime } from "../../context";
9
-
10
- const useThreadListNew = () => {
11
- const runtime = useAssistantRuntime();
12
- return () => {
13
- runtime.switchToNewThread();
14
- };
15
- };
16
-
17
- export namespace ThreadListPrimitiveNew {
18
- export type Element = ActionButtonElement;
19
- export type Props = ActionButtonProps<typeof useThreadListNew>;
20
- }
21
-
22
- export const ThreadListPrimitiveNew = createActionButton(
23
- "ThreadListPrimitive.New",
24
- useThreadListNew,
25
- );