@assistant-ui/react 0.10.42 → 0.10.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/primitives/composer/ComposerAttachments.d.ts +24 -0
- package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +14 -13
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/index.d.ts +1 -0
- package/dist/primitives/composer/index.d.ts.map +1 -1
- package/dist/primitives/composer/index.js +2 -0
- package/dist/primitives/composer/index.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.d.ts +24 -0
- package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +14 -13
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts +24 -0
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js +16 -15
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/index.d.ts +2 -0
- package/dist/primitives/message/index.d.ts.map +1 -1
- package/dist/primitives/message/index.js +4 -0
- package/dist/primitives/message/index.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts +24 -0
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +20 -15
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/index.d.ts +1 -0
- package/dist/primitives/thread/index.d.ts.map +1 -1
- package/dist/primitives/thread/index.js +2 -0
- package/dist/primitives/thread/index.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts +24 -0
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +15 -18
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/index.d.ts +1 -0
- package/dist/primitives/threadList/index.d.ts.map +1 -1
- package/dist/primitives/threadList/index.js +2 -0
- package/dist/primitives/threadList/index.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/composer/ComposerAttachments.tsx +48 -24
- package/src/primitives/composer/index.ts +1 -0
- package/src/primitives/message/MessageAttachments.tsx +48 -24
- package/src/primitives/message/MessageParts.tsx +53 -33
- package/src/primitives/message/index.ts +2 -0
- package/src/primitives/thread/ThreadMessages.tsx +47 -27
- package/src/primitives/thread/index.ts +1 -0
- package/src/primitives/threadList/ThreadListItems.tsx +48 -33
- package/src/primitives/threadList/index.ts +1 -0
@@ -136,35 +136,51 @@ const ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({
|
|
136
136
|
|
137
137
|
return <Component />;
|
138
138
|
};
|
139
|
+
export namespace ThreadPrimitiveMessageByIndex {
|
140
|
+
export type Props = {
|
141
|
+
index: number;
|
142
|
+
components: ThreadPrimitiveMessages.Props["components"];
|
143
|
+
};
|
144
|
+
}
|
139
145
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
146
|
+
/**
|
147
|
+
* Renders a single message at the specified index in the current thread.
|
148
|
+
*
|
149
|
+
* This component provides message context for a specific message in the thread
|
150
|
+
* and renders it using the provided component configuration.
|
151
|
+
*
|
152
|
+
* @example
|
153
|
+
* ```tsx
|
154
|
+
* <ThreadPrimitive.MessageByIndex
|
155
|
+
* index={0}
|
156
|
+
* components={{
|
157
|
+
* UserMessage: MyUserMessage,
|
158
|
+
* AssistantMessage: MyAssistantMessage
|
159
|
+
* }}
|
160
|
+
* />
|
161
|
+
* ```
|
162
|
+
*/
|
163
|
+
export const ThreadPrimitiveMessageByIndex: FC<ThreadPrimitiveMessageByIndex.Props> =
|
164
|
+
memo(
|
165
|
+
({ index, components }) => {
|
166
|
+
const threadRuntime = useThreadRuntime();
|
167
|
+
const runtime = useMemo(
|
168
|
+
() => threadRuntime.getMesssageByIndex(index),
|
169
|
+
[threadRuntime, index],
|
170
|
+
);
|
171
|
+
|
172
|
+
return (
|
173
|
+
<MessageRuntimeProvider runtime={runtime}>
|
174
|
+
<ThreadMessageComponent components={components} />
|
175
|
+
</MessageRuntimeProvider>
|
176
|
+
);
|
177
|
+
},
|
178
|
+
(prev, next) =>
|
179
|
+
prev.index === next.index &&
|
180
|
+
isComponentsSame(prev.components, next.components),
|
159
181
|
);
|
160
|
-
};
|
161
182
|
|
162
|
-
|
163
|
-
ThreadMessageImpl,
|
164
|
-
(prev, next) =>
|
165
|
-
prev.messageIndex === next.messageIndex &&
|
166
|
-
isComponentsSame(prev.components, next.components),
|
167
|
-
);
|
183
|
+
ThreadPrimitiveMessageByIndex.displayName = "ThreadPrimitive.MessageByIndex";
|
168
184
|
|
169
185
|
/**
|
170
186
|
* Renders all messages in the current thread using the provided component configuration.
|
@@ -192,7 +208,11 @@ export const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({
|
|
192
208
|
const messageElements = useMemo(() => {
|
193
209
|
if (messagesLength === 0) return null;
|
194
210
|
return Array.from({ length: messagesLength }, (_, index) => (
|
195
|
-
<
|
211
|
+
<ThreadPrimitiveMessageByIndex
|
212
|
+
key={index}
|
213
|
+
index={index}
|
214
|
+
components={components}
|
215
|
+
/>
|
196
216
|
));
|
197
217
|
}, [messagesLength, components]);
|
198
218
|
|
@@ -3,5 +3,6 @@ export { ThreadPrimitiveEmpty as Empty } from "./ThreadEmpty";
|
|
3
3
|
export { ThreadPrimitiveIf as If } from "./ThreadIf";
|
4
4
|
export { ThreadPrimitiveViewport as Viewport } from "./ThreadViewport";
|
5
5
|
export { ThreadPrimitiveMessages as Messages } from "./ThreadMessages";
|
6
|
+
export { ThreadPrimitiveMessageByIndex as MessageByIndex } from "./ThreadMessages";
|
6
7
|
export { ThreadPrimitiveScrollToBottom as ScrollToBottom } from "./ThreadScrollToBottom";
|
7
8
|
export { ThreadPrimitiveSuggestion as Suggestion } from "./ThreadSuggestion";
|
@@ -13,42 +13,57 @@ export namespace ThreadListPrimitiveItems {
|
|
13
13
|
};
|
14
14
|
}
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
export namespace ThreadListPrimitiveItemByIndex {
|
17
|
+
export type Props = {
|
18
|
+
index: number;
|
19
|
+
archived?: boolean | undefined;
|
20
|
+
components: ThreadListPrimitiveItems.Props["components"];
|
21
|
+
};
|
22
|
+
}
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
/**
|
25
|
+
* Renders a single thread list item at the specified index.
|
26
|
+
*
|
27
|
+
* This component provides direct access to render a specific thread
|
28
|
+
* from the thread list using the provided component configuration.
|
29
|
+
*
|
30
|
+
* @example
|
31
|
+
* ```tsx
|
32
|
+
* <ThreadListPrimitive.ItemByIndex
|
33
|
+
* index={0}
|
34
|
+
* components={{
|
35
|
+
* ThreadListItem: MyThreadListItem
|
36
|
+
* }}
|
37
|
+
* />
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
export const ThreadListPrimitiveItemByIndex: FC<ThreadListPrimitiveItemByIndex.Props> =
|
41
|
+
memo(
|
42
|
+
({ index, archived = false, components }) => {
|
43
|
+
const assistantRuntime = useAssistantRuntime();
|
44
|
+
const runtime = useMemo(
|
45
|
+
() =>
|
46
|
+
archived
|
47
|
+
? assistantRuntime.threads.getArchivedItemByIndex(index)
|
48
|
+
: assistantRuntime.threads.getItemByIndex(index),
|
49
|
+
[assistantRuntime, index, archived],
|
50
|
+
);
|
35
51
|
|
36
|
-
|
52
|
+
const ThreadListItemComponent = components.ThreadListItem;
|
37
53
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
54
|
+
return (
|
55
|
+
<ThreadListItemRuntimeProvider runtime={runtime}>
|
56
|
+
<ThreadListItemComponent />
|
57
|
+
</ThreadListItemRuntimeProvider>
|
58
|
+
);
|
59
|
+
},
|
60
|
+
(prev, next) =>
|
61
|
+
prev.index === next.index &&
|
62
|
+
prev.archived === next.archived &&
|
63
|
+
prev.components.ThreadListItem === next.components.ThreadListItem,
|
42
64
|
);
|
43
|
-
};
|
44
65
|
|
45
|
-
|
46
|
-
ThreadListItemImpl,
|
47
|
-
(prev, next) =>
|
48
|
-
prev.partIndex === next.partIndex &&
|
49
|
-
prev.archived === next.archived &&
|
50
|
-
prev.components.ThreadListItem === next.components.ThreadListItem,
|
51
|
-
);
|
66
|
+
ThreadListPrimitiveItemByIndex.displayName = "ThreadListPrimitive.ItemByIndex";
|
52
67
|
|
53
68
|
export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
|
54
69
|
archived = false,
|
@@ -60,9 +75,9 @@ export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
|
|
60
75
|
|
61
76
|
const listElements = useMemo(() => {
|
62
77
|
return Array.from({ length: contentLength }, (_, index) => (
|
63
|
-
<
|
78
|
+
<ThreadListPrimitiveItemByIndex
|
64
79
|
key={index}
|
65
|
-
|
80
|
+
index={index}
|
66
81
|
archived={archived}
|
67
82
|
components={components}
|
68
83
|
/>
|
@@ -1,3 +1,4 @@
|
|
1
1
|
export { ThreadListPrimitiveNew as New } from "./ThreadListNew";
|
2
2
|
export { ThreadListPrimitiveItems as Items } from "./ThreadListItems";
|
3
|
+
export { ThreadListPrimitiveItemByIndex as ItemByIndex } from "./ThreadListItems";
|
3
4
|
export { ThreadListPrimitiveRoot as Root } from "./ThreadListRoot";
|