@assistant-ui/react 0.7.6 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/ContentPartRuntime.d.ts.map +1 -1
- package/dist/api/ContentPartRuntime.js +0 -1
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs +0 -1
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts +2 -2
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +23 -6
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.mjs +24 -9
- package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -1
- package/dist/styles/index.css +66 -0
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +30 -0
- package/dist/styles/tailwindcss/thread.css.json +21 -0
- package/dist/ui/assistant-action-bar.d.ts +7 -7
- package/dist/ui/assistant-action-bar.d.ts.map +1 -1
- package/dist/ui/assistant-action-bar.js.map +1 -1
- package/dist/ui/assistant-action-bar.mjs +1 -3
- package/dist/ui/assistant-action-bar.mjs.map +1 -1
- package/dist/ui/assistant-modal.d.ts +3 -3
- package/dist/ui/assistant-modal.d.ts.map +1 -1
- package/dist/ui/assistant-modal.js.map +1 -1
- package/dist/ui/assistant-modal.mjs +1 -3
- package/dist/ui/assistant-modal.mjs.map +1 -1
- package/dist/ui/attachment-ui.d.ts +2 -2
- package/dist/ui/attachment-ui.d.ts.map +1 -1
- package/dist/ui/attachment-ui.js.map +1 -1
- package/dist/ui/attachment-ui.mjs +1 -3
- package/dist/ui/attachment-ui.mjs.map +1 -1
- package/dist/ui/base/index.d.ts +1 -1
- package/dist/ui/base/index.d.ts.map +1 -1
- package/dist/ui/base/index.js.map +1 -1
- package/dist/ui/base/index.mjs +1 -3
- package/dist/ui/base/index.mjs.map +1 -1
- package/dist/ui/base/tooltip-icon-button.d.ts +6 -4
- package/dist/ui/base/tooltip-icon-button.d.ts.map +1 -1
- package/dist/ui/base/tooltip-icon-button.js.map +1 -1
- package/dist/ui/base/tooltip-icon-button.mjs.map +1 -1
- package/dist/ui/branch-picker.d.ts +3 -3
- package/dist/ui/branch-picker.d.ts.map +1 -1
- package/dist/ui/branch-picker.js.map +1 -1
- package/dist/ui/branch-picker.mjs +1 -3
- package/dist/ui/branch-picker.mjs.map +1 -1
- package/dist/ui/composer.d.ts +4 -4
- package/dist/ui/composer.d.ts.map +1 -1
- package/dist/ui/composer.js.map +1 -1
- package/dist/ui/composer.mjs +1 -3
- package/dist/ui/composer.mjs.map +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +6 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +4 -0
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/thread-config.d.ts +13 -0
- package/dist/ui/thread-config.d.ts.map +1 -1
- package/dist/ui/thread-config.js +8 -1
- package/dist/ui/thread-config.js.map +1 -1
- package/dist/ui/thread-config.mjs +8 -1
- package/dist/ui/thread-config.mjs.map +1 -1
- package/dist/ui/thread-list-item.d.ts +24 -0
- package/dist/ui/thread-list-item.d.ts.map +1 -0
- package/dist/ui/thread-list-item.js +107 -0
- package/dist/ui/thread-list-item.js.map +1 -0
- package/dist/ui/thread-list-item.mjs +77 -0
- package/dist/ui/thread-list-item.mjs.map +1 -0
- package/dist/ui/thread-list.d.ts +20 -0
- package/dist/ui/thread-list.d.ts.map +1 -0
- package/dist/ui/thread-list.js +92 -0
- package/dist/ui/thread-list.js.map +1 -0
- package/dist/ui/thread-list.mjs +62 -0
- package/dist/ui/thread-list.mjs.map +1 -0
- package/dist/ui/thread.d.ts +2 -2
- package/dist/ui/thread.d.ts.map +1 -1
- package/dist/ui/thread.js.map +1 -1
- package/dist/ui/thread.mjs +1 -3
- package/dist/ui/thread.mjs.map +1 -1
- package/dist/ui/user-action-bar.d.ts +2 -2
- package/dist/ui/user-action-bar.d.ts.map +1 -1
- package/dist/ui/user-action-bar.js.map +1 -1
- package/dist/ui/user-action-bar.mjs +1 -3
- package/dist/ui/user-action-bar.mjs.map +1 -1
- package/package.json +4 -4
- package/src/api/ContentPartRuntime.ts +0 -1
- package/src/primitives/threadList/ThreadListItems.tsx +3 -3
- package/src/primitives/threadList/ThreadListNew.tsx +45 -0
- package/src/styles/tailwindcss/thread.css +30 -0
- package/src/ui/assistant-action-bar.tsx +7 -10
- package/src/ui/assistant-modal.tsx +3 -6
- package/src/ui/attachment-ui.tsx +2 -5
- package/src/ui/base/index.ts +1 -4
- package/src/ui/base/tooltip-icon-button.tsx +7 -5
- package/src/ui/branch-picker.tsx +3 -6
- package/src/ui/composer.tsx +4 -7
- package/src/ui/index.ts +4 -0
- package/src/ui/thread-config.tsx +29 -7
- package/src/ui/thread-list-item.tsx +99 -0
- package/src/ui/thread-list.tsx +72 -0
- package/src/ui/thread.tsx +2 -5
- package/src/ui/user-action-bar.tsx +2 -5
- package/src/primitives/threadList/ThreadListNew.ts +0 -25
package/package.json
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
"conversational-ui",
|
30
30
|
"conversational-ai"
|
31
31
|
],
|
32
|
-
"version": "0.7.
|
32
|
+
"version": "0.7.8",
|
33
33
|
"license": "MIT",
|
34
34
|
"exports": {
|
35
35
|
".": {
|
@@ -65,7 +65,7 @@
|
|
65
65
|
],
|
66
66
|
"sideEffects": false,
|
67
67
|
"dependencies": {
|
68
|
-
"@ai-sdk/provider": "^1.0.
|
68
|
+
"@ai-sdk/provider": "^1.0.1",
|
69
69
|
"@radix-ui/primitive": "^1.1.0",
|
70
70
|
"@radix-ui/react-avatar": "^1.1.1",
|
71
71
|
"@radix-ui/react-compose-refs": "^1.1.0",
|
@@ -108,7 +108,7 @@
|
|
108
108
|
},
|
109
109
|
"devDependencies": {
|
110
110
|
"@types/json-schema": "^7.0.15",
|
111
|
-
"@types/node": "^22.9.
|
111
|
+
"@types/node": "^22.9.3",
|
112
112
|
"autoprefixer": "^10.4.20",
|
113
113
|
"esbuild-plugin-file-path-extensions": "^2.1.3",
|
114
114
|
"eslint": "^9",
|
@@ -128,7 +128,7 @@
|
|
128
128
|
"access": "public",
|
129
129
|
"provenance": true
|
130
130
|
},
|
131
|
-
"homepage": "https://assistant-ui.com/",
|
131
|
+
"homepage": "https://www.assistant-ui.com/",
|
132
132
|
"repository": {
|
133
133
|
"type": "git",
|
134
134
|
"url": "https://github.com/Yonom/assistant-ui/tree/main/packages/react"
|
@@ -4,7 +4,7 @@ import { ComponentType, FC, memo, useMemo } from "react";
|
|
4
4
|
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider";
|
5
5
|
import { useAssistantRuntime, useThreadList } from "../../context";
|
6
6
|
|
7
|
-
export namespace
|
7
|
+
export namespace ThreadListPrimitiveItems {
|
8
8
|
export type Props = {
|
9
9
|
archived?: boolean | undefined;
|
10
10
|
components: {
|
@@ -16,7 +16,7 @@ export namespace MessagePrimitiveContent {
|
|
16
16
|
type ThreadListItemProps = {
|
17
17
|
partIndex: number;
|
18
18
|
archived: boolean;
|
19
|
-
components:
|
19
|
+
components: ThreadListPrimitiveItems.Props["components"];
|
20
20
|
};
|
21
21
|
|
22
22
|
const ThreadListItemImpl: FC<ThreadListItemProps> = ({
|
@@ -52,7 +52,7 @@ const ThreadListItem = memo(
|
|
52
52
|
prev.components.ThreadListItem === next.components.ThreadListItem,
|
53
53
|
);
|
54
54
|
|
55
|
-
export const ThreadListPrimitiveItems: FC<
|
55
|
+
export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
|
56
56
|
archived = false,
|
57
57
|
components,
|
58
58
|
}) => {
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
} from "../../utils/createActionButton";
|
7
|
+
import { useAssistantRuntime, useThreadList } from "../../context";
|
8
|
+
import { forwardRef } from "react";
|
9
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
10
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
11
|
+
|
12
|
+
const useThreadListNew = () => {
|
13
|
+
const runtime = useAssistantRuntime();
|
14
|
+
return () => {
|
15
|
+
runtime.switchToNewThread();
|
16
|
+
};
|
17
|
+
};
|
18
|
+
|
19
|
+
export namespace ThreadListPrimitiveNew {
|
20
|
+
export type Element = ActionButtonElement;
|
21
|
+
export type Props = ActionButtonProps<typeof useThreadListNew>;
|
22
|
+
}
|
23
|
+
|
24
|
+
export const ThreadListPrimitiveNew = forwardRef<
|
25
|
+
ThreadListPrimitiveNew.Element,
|
26
|
+
ThreadListPrimitiveNew.Props
|
27
|
+
>(({ onClick, disabled, ...props }, forwardedRef) => {
|
28
|
+
const isMain = useThreadList((t) => t.newThread === t.mainThreadId);
|
29
|
+
const callback = useThreadListNew();
|
30
|
+
|
31
|
+
return (
|
32
|
+
<Primitive.button
|
33
|
+
type="button"
|
34
|
+
{...(isMain ? { "data-active": "true" } : null)}
|
35
|
+
{...props}
|
36
|
+
ref={forwardedRef}
|
37
|
+
disabled={disabled || !callback}
|
38
|
+
onClick={composeEventHandlers(onClick, () => {
|
39
|
+
callback?.();
|
40
|
+
})}
|
41
|
+
/>
|
42
|
+
);
|
43
|
+
});
|
44
|
+
|
45
|
+
ThreadListPrimitiveNew.displayName = "ThreadListPrimitive.New";
|
@@ -219,3 +219,33 @@
|
|
219
219
|
.aui-text-running::after {
|
220
220
|
@apply animate-pulse font-sans content-['\25CF'] ltr:ml-1 rtl:mr-1;
|
221
221
|
}
|
222
|
+
|
223
|
+
/* thread-list */
|
224
|
+
|
225
|
+
.aui-thread-list-root {
|
226
|
+
@apply flex flex-col items-stretch gap-1.5;
|
227
|
+
}
|
228
|
+
|
229
|
+
.aui-thread-list-item {
|
230
|
+
@apply data-[active]:bg-aui-muted hover:bg-aui-muted flex items-center gap-2 rounded-lg transition-all;
|
231
|
+
}
|
232
|
+
|
233
|
+
.aui-thread-list-new {
|
234
|
+
@apply data-[active]:bg-aui-muted hover:bg-aui-muted flex items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start;
|
235
|
+
}
|
236
|
+
|
237
|
+
.aui-thread-list-new > .lucide-plus {
|
238
|
+
@apply size-5;
|
239
|
+
}
|
240
|
+
|
241
|
+
.aui-thread-list-item-trigger {
|
242
|
+
@apply flex-grow px-3 py-2 text-start;
|
243
|
+
}
|
244
|
+
|
245
|
+
.aui-thread-list-item-title {
|
246
|
+
@apply text-sm;
|
247
|
+
}
|
248
|
+
|
249
|
+
.aui-thread-list-item-archive {
|
250
|
+
@apply hover:text-aui-primary text-aui-foreground ml-auto mr-3 size-4 p-0;
|
251
|
+
}
|
@@ -11,10 +11,7 @@ import {
|
|
11
11
|
ThumbsUpIcon,
|
12
12
|
} from "lucide-react";
|
13
13
|
import { ActionBarPrimitive, MessagePrimitive } from "../primitives";
|
14
|
-
import {
|
15
|
-
TooltipIconButton,
|
16
|
-
TooltipIconButtonProps,
|
17
|
-
} from "./base/tooltip-icon-button";
|
14
|
+
import { TooltipIconButton } from "./base/tooltip-icon-button";
|
18
15
|
import { withDefaults } from "./utils/withDefaults";
|
19
16
|
import { useThreadConfig } from "./thread-config";
|
20
17
|
import { useThread } from "../context";
|
@@ -91,7 +88,7 @@ AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
|
|
91
88
|
|
92
89
|
namespace AssistantActionBarCopy {
|
93
90
|
export type Element = ActionBarPrimitive.Copy.Element;
|
94
|
-
export type Props = Partial<
|
91
|
+
export type Props = Partial<TooltipIconButton.Props> & {
|
95
92
|
copiedDuration?: number | undefined;
|
96
93
|
};
|
97
94
|
}
|
@@ -141,7 +138,7 @@ const AssistantActionBarSpeechControl: FC = () => {
|
|
141
138
|
|
142
139
|
namespace AssistantActionBarSpeak {
|
143
140
|
export type Element = ActionBarPrimitive.Speak.Element;
|
144
|
-
export type Props = Partial<
|
141
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
145
142
|
}
|
146
143
|
|
147
144
|
const AssistantActionBarSpeak = forwardRef<
|
@@ -168,7 +165,7 @@ AssistantActionBarSpeak.displayName = "AssistantActionBarSpeak";
|
|
168
165
|
|
169
166
|
namespace AssistantActionBarStopSpeaking {
|
170
167
|
export type Element = ActionBarPrimitive.StopSpeaking.Element;
|
171
|
-
export type Props = Partial<
|
168
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
172
169
|
}
|
173
170
|
|
174
171
|
const AssistantActionBarStopSpeaking = forwardRef<
|
@@ -197,7 +194,7 @@ AssistantActionBarStopSpeaking.displayName = "AssistantActionBarStopSpeaking";
|
|
197
194
|
|
198
195
|
namespace AssistantActionBarReload {
|
199
196
|
export type Element = ActionBarPrimitive.Reload.Element;
|
200
|
-
export type Props = Partial<
|
197
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
201
198
|
}
|
202
199
|
|
203
200
|
const AssistantActionBarReload = forwardRef<
|
@@ -223,7 +220,7 @@ AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
|
223
220
|
|
224
221
|
namespace AssistantActionBarFeedbackPositive {
|
225
222
|
export type Element = ActionBarPrimitive.FeedbackPositive.Element;
|
226
|
-
export type Props = Partial<
|
223
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
227
224
|
}
|
228
225
|
|
229
226
|
const AssistantActionBarFeedbackPositive = forwardRef<
|
@@ -256,7 +253,7 @@ AssistantActionBarFeedbackPositive.displayName =
|
|
256
253
|
|
257
254
|
namespace AssistantActionBarFeedbackNegative {
|
258
255
|
export type Element = ActionBarPrimitive.FeedbackNegative.Element;
|
259
|
-
export type Props = Partial<
|
256
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
260
257
|
}
|
261
258
|
|
262
259
|
const AssistantActionBarFeedbackNegative = forwardRef<
|
@@ -6,10 +6,7 @@ import { BotIcon, ChevronDownIcon } from "lucide-react";
|
|
6
6
|
import { AssistantModalPrimitive } from "../primitives";
|
7
7
|
import Thread from "./thread";
|
8
8
|
import { withDefaults } from "./utils/withDefaults";
|
9
|
-
import {
|
10
|
-
TooltipIconButton,
|
11
|
-
TooltipIconButtonProps,
|
12
|
-
} from "./base/tooltip-icon-button";
|
9
|
+
import { TooltipIconButton } from "./base/tooltip-icon-button";
|
13
10
|
import {
|
14
11
|
ThreadConfig,
|
15
12
|
ThreadConfigProvider,
|
@@ -50,7 +47,7 @@ AssistantModalRoot.displayName = "AssistantModalRoot";
|
|
50
47
|
|
51
48
|
namespace AssistantModalTrigger {
|
52
49
|
export type Element = HTMLButtonElement;
|
53
|
-
export type Props = Partial<
|
50
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
54
51
|
}
|
55
52
|
|
56
53
|
const AssistantModalTrigger = forwardRef<
|
@@ -81,7 +78,7 @@ const ModalButtonStyled = withDefaults(TooltipIconButton, {
|
|
81
78
|
|
82
79
|
namespace AssistantModalButton {
|
83
80
|
export type Element = HTMLButtonElement;
|
84
|
-
export type Props = Partial<
|
81
|
+
export type Props = Partial<TooltipIconButton.Props> & {
|
85
82
|
"data-state"?: "open" | "closed";
|
86
83
|
};
|
87
84
|
}
|
package/src/ui/attachment-ui.tsx
CHANGED
@@ -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<
|
169
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
173
170
|
}
|
174
171
|
|
175
172
|
const AttachmentRemove = forwardRef<
|
package/src/ui/base/index.ts
CHANGED
@@ -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
|
8
|
-
|
9
|
-
|
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
|
-
|
16
|
+
TooltipIconButton.Props
|
15
17
|
>(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
16
18
|
return (
|
17
19
|
<Tooltip>
|
package/src/ui/branch-picker.tsx
CHANGED
@@ -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<
|
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<
|
88
|
+
export type Props = Partial<TooltipIconButton.Props>;
|
92
89
|
}
|
93
90
|
|
94
91
|
const BranchPickerNext = forwardRef<
|
package/src/ui/composer.tsx
CHANGED
@@ -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<
|
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<
|
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<
|
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";
|
package/src/ui/thread-config.tsx
CHANGED
@@ -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;
|
@@ -192,14 +205,23 @@ export const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({
|
|
192
205
|
}) => {
|
193
206
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
194
207
|
|
195
|
-
const
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
<>{children}</>
|
208
|
+
const hasConfig = config && Object.keys(config).length > 0;
|
209
|
+
const outerConfig = useThreadConfig();
|
210
|
+
|
211
|
+
if (hasConfig && Object.keys(outerConfig).length > 0) {
|
212
|
+
throw new Error(
|
213
|
+
"You are providing ThreadConfig to several nested components. Please provide all configuration to the same component.",
|
202
214
|
);
|
215
|
+
}
|
216
|
+
|
217
|
+
const configProvider = hasConfig ? (
|
218
|
+
<ThreadConfigContext.Provider value={config}>
|
219
|
+
{children}
|
220
|
+
</ThreadConfigContext.Provider>
|
221
|
+
) : (
|
222
|
+
<>{children}</>
|
223
|
+
);
|
224
|
+
|
203
225
|
if (!config?.runtime) return configProvider;
|
204
226
|
|
205
227
|
if (hasAssistant) {
|
@@ -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<
|
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<
|
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
|
-
);
|