@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
@@ -43,28 +43,32 @@ var ThreadMessageComponent = ({
|
|
43
43
|
const Component = getComponent(components, role, isEditing);
|
44
44
|
return /* @__PURE__ */ jsx(Component, {});
|
45
45
|
};
|
46
|
-
var
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
};
|
57
|
-
var ThreadMessage = memo(
|
58
|
-
ThreadMessageImpl,
|
59
|
-
(prev, next) => prev.messageIndex === next.messageIndex && isComponentsSame(prev.components, next.components)
|
46
|
+
var ThreadPrimitiveMessageByIndex = memo(
|
47
|
+
({ index, components }) => {
|
48
|
+
const threadRuntime = useThreadRuntime();
|
49
|
+
const runtime = useMemo(
|
50
|
+
() => threadRuntime.getMesssageByIndex(index),
|
51
|
+
[threadRuntime, index]
|
52
|
+
);
|
53
|
+
return /* @__PURE__ */ jsx(MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(ThreadMessageComponent, { components }) });
|
54
|
+
},
|
55
|
+
(prev, next) => prev.index === next.index && isComponentsSame(prev.components, next.components)
|
60
56
|
);
|
57
|
+
ThreadPrimitiveMessageByIndex.displayName = "ThreadPrimitive.MessageByIndex";
|
61
58
|
var ThreadPrimitiveMessagesImpl = ({
|
62
59
|
components
|
63
60
|
}) => {
|
64
61
|
const messagesLength = useThread((t) => t.messages.length);
|
65
62
|
const messageElements = useMemo(() => {
|
66
63
|
if (messagesLength === 0) return null;
|
67
|
-
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ jsx(
|
64
|
+
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ jsx(
|
65
|
+
ThreadPrimitiveMessageByIndex,
|
66
|
+
{
|
67
|
+
index,
|
68
|
+
components
|
69
|
+
},
|
70
|
+
index
|
71
|
+
));
|
68
72
|
}, [messagesLength, components]);
|
69
73
|
return messageElements;
|
70
74
|
};
|
@@ -74,6 +78,7 @@ var ThreadPrimitiveMessages = memo(
|
|
74
78
|
(prev, next) => isComponentsSame(prev.components, next.components)
|
75
79
|
);
|
76
80
|
export {
|
81
|
+
ThreadPrimitiveMessageByIndex,
|
77
82
|
ThreadPrimitiveMessages,
|
78
83
|
ThreadPrimitiveMessagesImpl
|
79
84
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/thread/ThreadMessages.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport { useThread, useThreadRuntime } from \"../../context/react/ThreadContext\";\nimport { MessageRuntimeProvider } from \"../../context/providers/MessageRuntimeProvider\";\nimport { useEditComposer, useMessage } from \"../../context\";\nimport { ThreadMessage as ThreadMessageType } from \"../../types\";\n\nexport namespace ThreadPrimitiveMessages {\n export type Props = {\n /**\n * Component configuration for rendering different types of messages and composers.\n *\n * You can provide either:\n * 1. A single `Message` component that handles all message types\n * 2. Specific components for `UserMessage` and `AssistantMessage` (with optional `SystemMessage`)\n *\n * Optional edit composer components can be provided to customize the editing experience\n * for different message types when users edit their messages.\n */\n components:\n | {\n /** Component used to render all message types */\n Message: ComponentType;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages specifically */\n UserMessage?: ComponentType | undefined;\n /** Component used to render assistant messages specifically */\n AssistantMessage?: ComponentType | undefined;\n /** Component used to render system messages specifically */\n SystemMessage?: ComponentType | undefined;\n }\n | {\n /** Component used to render all message types (fallback) */\n Message?: ComponentType | undefined;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages */\n UserMessage: ComponentType;\n /** Component used to render assistant messages */\n AssistantMessage: ComponentType;\n /** Component used to render system messages */\n SystemMessage?: ComponentType | undefined;\n };\n };\n}\n\nconst isComponentsSame = (\n prev: ThreadPrimitiveMessages.Props[\"components\"],\n next: ThreadPrimitiveMessages.Props[\"components\"],\n) => {\n return (\n prev.Message === next.Message &&\n prev.EditComposer === next.EditComposer &&\n prev.UserEditComposer === next.UserEditComposer &&\n prev.AssistantEditComposer === next.AssistantEditComposer &&\n prev.SystemEditComposer === next.SystemEditComposer &&\n prev.UserMessage === next.UserMessage &&\n prev.AssistantMessage === next.AssistantMessage &&\n prev.SystemMessage === next.SystemMessage\n );\n};\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\n\nconst getComponent = (\n components: ThreadPrimitiveMessages.Props[\"components\"],\n role: ThreadMessageType[\"role\"],\n isEditing: boolean,\n) => {\n switch (role) {\n case \"user\":\n if (isEditing) {\n return (\n components.UserEditComposer ??\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.UserMessage ?? (components.Message as ComponentType);\n }\n case \"assistant\":\n if (isEditing) {\n return (\n components.AssistantEditComposer ??\n components.EditComposer ??\n components.AssistantMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.AssistantMessage ?? (components.Message as ComponentType)\n );\n }\n case \"system\":\n if (isEditing) {\n return (\n components.SystemEditComposer ??\n components.EditComposer ??\n components.SystemMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.SystemMessage ?? DEFAULT_SYSTEM_MESSAGE;\n }\n default:\n const _exhaustiveCheck: never = role;\n throw new Error(`Unknown message role: ${_exhaustiveCheck}`);\n }\n};\n\ntype ThreadMessageComponentProps = {\n components: ThreadPrimitiveMessages.Props[\"components\"];\n};\n\nconst ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({\n components,\n}) => {\n const role = useMessage((m) => m.role);\n const isEditing = useEditComposer((c) => c.isEditing);\n const Component = getComponent(components, role, isEditing);\n\n return <Component />;\n};\n\ntype ThreadMessageProps = {\n messageIndex: number;\n components: ThreadPrimitiveMessages.Props[\"components\"];\n};\n\nconst ThreadMessageImpl: FC<ThreadMessageProps> = ({\n messageIndex,\n components,\n}) => {\n const threadRuntime = useThreadRuntime();\n const runtime = useMemo(\n () => threadRuntime.getMesssageByIndex(messageIndex),\n [threadRuntime, messageIndex],\n );\n\n return (\n <MessageRuntimeProvider runtime={runtime}>\n <ThreadMessageComponent components={components} />\n </MessageRuntimeProvider>\n );\n};\n\nconst ThreadMessage = memo(\n ThreadMessageImpl,\n (prev, next) =>\n prev.messageIndex === next.messageIndex &&\n isComponentsSame(prev.components, next.components),\n);\n\n/**\n * Renders all messages in the current thread using the provided component configuration.\n *\n * This component automatically renders all messages in the thread, providing the appropriate\n * message context for each message. It handles different message types (user, assistant, system)\n * and supports editing mode through the provided edit composer components.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Messages\n * components={{\n * UserMessage: MyUserMessage,\n * AssistantMessage: MyAssistantMessage,\n * EditComposer: MyEditComposer\n * }}\n * />\n * ```\n */\nexport const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({\n components,\n}) => {\n const messagesLength = useThread((t) => t.messages.length);\n\n const messageElements = useMemo(() => {\n if (messagesLength === 0) return null;\n return Array.from({ length: messagesLength }, (_, index) => (\n <ThreadMessage key={index} messageIndex={index} components={components} />\n ));\n }, [messagesLength, components]);\n\n return messageElements;\n};\n\nThreadPrimitiveMessagesImpl.displayName = \"ThreadPrimitive.Messages\";\n\nexport const ThreadPrimitiveMessages = memo(\n ThreadPrimitiveMessagesImpl,\n (prev, next) => isComponentsSame(prev.components, next.components),\n);\n"],"mappings":";;;AAEA,SAAsC,MAAM,eAAe;AAC3D,SAAS,WAAW,wBAAwB;AAC5C,SAAS,8BAA8B;AACvC,SAAS,iBAAiB,kBAAkB;AAmInC;AA5ET,IAAM,mBAAmB,CACvB,MACA,SACG;AACH,SACE,KAAK,YAAY,KAAK,WACtB,KAAK,iBAAiB,KAAK,gBAC3B,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,0BAA0B,KAAK,yBACpC,KAAK,uBAAuB,KAAK,sBACjC,KAAK,gBAAgB,KAAK,eAC1B,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,kBAAkB,KAAK;AAEhC;AAEA,IAAM,yBAAyB,MAAM;AAErC,IAAM,eAAe,CACnB,YACA,MACA,cACG;AACH,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,UAAI,WAAW;AACb,eACE,WAAW,oBACX,WAAW,gBACX,WAAW,eACV,WAAW;AAAA,MAEhB,OAAO;AACL,eAAO,WAAW,eAAgB,WAAW;AAAA,MAC/C;AAAA,IACF,KAAK;AACH,UAAI,WAAW;AACb,eACE,WAAW,yBACX,WAAW,gBACX,WAAW,oBACV,WAAW;AAAA,MAEhB,OAAO;AACL,eACE,WAAW,oBAAqB,WAAW;AAAA,MAE/C;AAAA,IACF,KAAK;AACH,UAAI,WAAW;AACb,eACE,WAAW,sBACX,WAAW,gBACX,WAAW,iBACV,WAAW;AAAA,MAEhB,OAAO;AACL,eAAO,WAAW,iBAAiB;AAAA,MACrC;AAAA,IACF;AACE,YAAM,mBAA0B;AAChC,YAAM,IAAI,MAAM,yBAAyB,gBAAgB,EAAE;AAAA,EAC/D;AACF;AAMA,IAAM,yBAA0D,CAAC;AAAA,EAC/D;AACF,MAAM;AACJ,QAAM,OAAO,WAAW,CAAC,MAAM,EAAE,IAAI;AACrC,QAAM,YAAY,gBAAgB,CAAC,MAAM,EAAE,SAAS;AACpD,QAAM,YAAY,aAAa,YAAY,MAAM,SAAS;AAE1D,SAAO,oBAAC,aAAU;AACpB;AAOA,IAAM,oBAA4C,CAAC;AAAA,EACjD;AAAA,EACA;AACF,MAAM;AACJ,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,UAAU;AAAA,IACd,MAAM,cAAc,mBAAmB,YAAY;AAAA,IACnD,CAAC,eAAe,YAAY;AAAA,EAC9B;AAEA,SACE,oBAAC,0BAAuB,SACtB,8BAAC,0BAAuB,YAAwB,GAClD;AAEJ;AAEA,IAAM,gBAAgB;AAAA,EACpB;AAAA,EACA,CAAC,MAAM,SACL,KAAK,iBAAiB,KAAK,gBAC3B,iBAAiB,KAAK,YAAY,KAAK,UAAU;AACrD;AAoBO,IAAM,8BAAiE,CAAC;AAAA,EAC7E;AACF,MAAM;AACJ,QAAM,iBAAiB,UAAU,CAAC,MAAM,EAAE,SAAS,MAAM;AAEzD,QAAM,kBAAkB,QAAQ,MAAM;AACpC,QAAI,mBAAmB,EAAG,QAAO;AACjC,WAAO,MAAM,KAAK,EAAE,QAAQ,eAAe,GAAG,CAAC,GAAG,UAChD,oBAAC,iBAA0B,cAAc,OAAO,cAA5B,KAAoD,CACzE;AAAA,EACH,GAAG,CAAC,gBAAgB,UAAU,CAAC;AAE/B,SAAO;AACT;AAEA,4BAA4B,cAAc;AAEnC,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA,CAAC,MAAM,SAAS,iBAAiB,KAAK,YAAY,KAAK,UAAU;AACnE;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/primitives/thread/ThreadMessages.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport { useThread, useThreadRuntime } from \"../../context/react/ThreadContext\";\nimport { MessageRuntimeProvider } from \"../../context/providers/MessageRuntimeProvider\";\nimport { useEditComposer, useMessage } from \"../../context\";\nimport { ThreadMessage as ThreadMessageType } from \"../../types\";\n\nexport namespace ThreadPrimitiveMessages {\n export type Props = {\n /**\n * Component configuration for rendering different types of messages and composers.\n *\n * You can provide either:\n * 1. A single `Message` component that handles all message types\n * 2. Specific components for `UserMessage` and `AssistantMessage` (with optional `SystemMessage`)\n *\n * Optional edit composer components can be provided to customize the editing experience\n * for different message types when users edit their messages.\n */\n components:\n | {\n /** Component used to render all message types */\n Message: ComponentType;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages specifically */\n UserMessage?: ComponentType | undefined;\n /** Component used to render assistant messages specifically */\n AssistantMessage?: ComponentType | undefined;\n /** Component used to render system messages specifically */\n SystemMessage?: ComponentType | undefined;\n }\n | {\n /** Component used to render all message types (fallback) */\n Message?: ComponentType | undefined;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages */\n UserMessage: ComponentType;\n /** Component used to render assistant messages */\n AssistantMessage: ComponentType;\n /** Component used to render system messages */\n SystemMessage?: ComponentType | undefined;\n };\n };\n}\n\nconst isComponentsSame = (\n prev: ThreadPrimitiveMessages.Props[\"components\"],\n next: ThreadPrimitiveMessages.Props[\"components\"],\n) => {\n return (\n prev.Message === next.Message &&\n prev.EditComposer === next.EditComposer &&\n prev.UserEditComposer === next.UserEditComposer &&\n prev.AssistantEditComposer === next.AssistantEditComposer &&\n prev.SystemEditComposer === next.SystemEditComposer &&\n prev.UserMessage === next.UserMessage &&\n prev.AssistantMessage === next.AssistantMessage &&\n prev.SystemMessage === next.SystemMessage\n );\n};\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\n\nconst getComponent = (\n components: ThreadPrimitiveMessages.Props[\"components\"],\n role: ThreadMessageType[\"role\"],\n isEditing: boolean,\n) => {\n switch (role) {\n case \"user\":\n if (isEditing) {\n return (\n components.UserEditComposer ??\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.UserMessage ?? (components.Message as ComponentType);\n }\n case \"assistant\":\n if (isEditing) {\n return (\n components.AssistantEditComposer ??\n components.EditComposer ??\n components.AssistantMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.AssistantMessage ?? (components.Message as ComponentType)\n );\n }\n case \"system\":\n if (isEditing) {\n return (\n components.SystemEditComposer ??\n components.EditComposer ??\n components.SystemMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.SystemMessage ?? DEFAULT_SYSTEM_MESSAGE;\n }\n default:\n const _exhaustiveCheck: never = role;\n throw new Error(`Unknown message role: ${_exhaustiveCheck}`);\n }\n};\n\ntype ThreadMessageComponentProps = {\n components: ThreadPrimitiveMessages.Props[\"components\"];\n};\n\nconst ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({\n components,\n}) => {\n const role = useMessage((m) => m.role);\n const isEditing = useEditComposer((c) => c.isEditing);\n const Component = getComponent(components, role, isEditing);\n\n return <Component />;\n};\nexport namespace ThreadPrimitiveMessageByIndex {\n export type Props = {\n index: number;\n components: ThreadPrimitiveMessages.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message at the specified index in the current thread.\n *\n * This component provides message context for a specific message in the thread\n * and renders it using the provided component configuration.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.MessageByIndex\n * index={0}\n * components={{\n * UserMessage: MyUserMessage,\n * AssistantMessage: MyAssistantMessage\n * }}\n * />\n * ```\n */\nexport const ThreadPrimitiveMessageByIndex: FC<ThreadPrimitiveMessageByIndex.Props> =\n memo(\n ({ index, components }) => {\n const threadRuntime = useThreadRuntime();\n const runtime = useMemo(\n () => threadRuntime.getMesssageByIndex(index),\n [threadRuntime, index],\n );\n\n return (\n <MessageRuntimeProvider runtime={runtime}>\n <ThreadMessageComponent components={components} />\n </MessageRuntimeProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n isComponentsSame(prev.components, next.components),\n );\n\nThreadPrimitiveMessageByIndex.displayName = \"ThreadPrimitive.MessageByIndex\";\n\n/**\n * Renders all messages in the current thread using the provided component configuration.\n *\n * This component automatically renders all messages in the thread, providing the appropriate\n * message context for each message. It handles different message types (user, assistant, system)\n * and supports editing mode through the provided edit composer components.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Messages\n * components={{\n * UserMessage: MyUserMessage,\n * AssistantMessage: MyAssistantMessage,\n * EditComposer: MyEditComposer\n * }}\n * />\n * ```\n */\nexport const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({\n components,\n}) => {\n const messagesLength = useThread((t) => t.messages.length);\n\n const messageElements = useMemo(() => {\n if (messagesLength === 0) return null;\n return Array.from({ length: messagesLength }, (_, index) => (\n <ThreadPrimitiveMessageByIndex\n key={index}\n index={index}\n components={components}\n />\n ));\n }, [messagesLength, components]);\n\n return messageElements;\n};\n\nThreadPrimitiveMessagesImpl.displayName = \"ThreadPrimitive.Messages\";\n\nexport const ThreadPrimitiveMessages = memo(\n ThreadPrimitiveMessagesImpl,\n (prev, next) => isComponentsSame(prev.components, next.components),\n);\n"],"mappings":";;;AAEA,SAAsC,MAAM,eAAe;AAC3D,SAAS,WAAW,wBAAwB;AAC5C,SAAS,8BAA8B;AACvC,SAAS,iBAAiB,kBAAkB;AAmInC;AA5ET,IAAM,mBAAmB,CACvB,MACA,SACG;AACH,SACE,KAAK,YAAY,KAAK,WACtB,KAAK,iBAAiB,KAAK,gBAC3B,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,0BAA0B,KAAK,yBACpC,KAAK,uBAAuB,KAAK,sBACjC,KAAK,gBAAgB,KAAK,eAC1B,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,kBAAkB,KAAK;AAEhC;AAEA,IAAM,yBAAyB,MAAM;AAErC,IAAM,eAAe,CACnB,YACA,MACA,cACG;AACH,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,UAAI,WAAW;AACb,eACE,WAAW,oBACX,WAAW,gBACX,WAAW,eACV,WAAW;AAAA,MAEhB,OAAO;AACL,eAAO,WAAW,eAAgB,WAAW;AAAA,MAC/C;AAAA,IACF,KAAK;AACH,UAAI,WAAW;AACb,eACE,WAAW,yBACX,WAAW,gBACX,WAAW,oBACV,WAAW;AAAA,MAEhB,OAAO;AACL,eACE,WAAW,oBAAqB,WAAW;AAAA,MAE/C;AAAA,IACF,KAAK;AACH,UAAI,WAAW;AACb,eACE,WAAW,sBACX,WAAW,gBACX,WAAW,iBACV,WAAW;AAAA,MAEhB,OAAO;AACL,eAAO,WAAW,iBAAiB;AAAA,MACrC;AAAA,IACF;AACE,YAAM,mBAA0B;AAChC,YAAM,IAAI,MAAM,yBAAyB,gBAAgB,EAAE;AAAA,EAC/D;AACF;AAMA,IAAM,yBAA0D,CAAC;AAAA,EAC/D;AACF,MAAM;AACJ,QAAM,OAAO,WAAW,CAAC,MAAM,EAAE,IAAI;AACrC,QAAM,YAAY,gBAAgB,CAAC,MAAM,EAAE,SAAS;AACpD,QAAM,YAAY,aAAa,YAAY,MAAM,SAAS;AAE1D,SAAO,oBAAC,aAAU;AACpB;AAyBO,IAAM,gCACX;AAAA,EACE,CAAC,EAAE,OAAO,WAAW,MAAM;AACzB,UAAM,gBAAgB,iBAAiB;AACvC,UAAM,UAAU;AAAA,MACd,MAAM,cAAc,mBAAmB,KAAK;AAAA,MAC5C,CAAC,eAAe,KAAK;AAAA,IACvB;AAEA,WACE,oBAAC,0BAAuB,SACtB,8BAAC,0BAAuB,YAAwB,GAClD;AAAA,EAEJ;AAAA,EACA,CAAC,MAAM,SACL,KAAK,UAAU,KAAK,SACpB,iBAAiB,KAAK,YAAY,KAAK,UAAU;AACrD;AAEF,8BAA8B,cAAc;AAoBrC,IAAM,8BAAiE,CAAC;AAAA,EAC7E;AACF,MAAM;AACJ,QAAM,iBAAiB,UAAU,CAAC,MAAM,EAAE,SAAS,MAAM;AAEzD,QAAM,kBAAkB,QAAQ,MAAM;AACpC,QAAI,mBAAmB,EAAG,QAAO;AACjC,WAAO,MAAM,KAAK,EAAE,QAAQ,eAAe,GAAG,CAAC,GAAG,UAChD;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA;AAAA;AAAA,MAFK;AAAA,IAGP,CACD;AAAA,EACH,GAAG,CAAC,gBAAgB,UAAU,CAAC;AAE/B,SAAO;AACT;AAEA,4BAA4B,cAAc;AAEnC,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA,CAAC,MAAM,SAAS,iBAAiB,KAAK,YAAY,KAAK,UAAU;AACnE;","names":[]}
|
@@ -3,6 +3,7 @@ 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";
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,oBAAoB,IAAI,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,iBAAiB,IAAI,EAAE,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,uBAAuB,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,uBAAuB,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,6BAA6B,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,yBAAyB,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,oBAAoB,IAAI,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,iBAAiB,IAAI,EAAE,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,uBAAuB,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,uBAAuB,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,6BAA6B,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,6BAA6B,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,yBAAyB,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
@@ -4,11 +4,13 @@ import { ThreadPrimitiveEmpty } from "./ThreadEmpty.js";
|
|
4
4
|
import { ThreadPrimitiveIf } from "./ThreadIf.js";
|
5
5
|
import { ThreadPrimitiveViewport } from "./ThreadViewport.js";
|
6
6
|
import { ThreadPrimitiveMessages } from "./ThreadMessages.js";
|
7
|
+
import { ThreadPrimitiveMessageByIndex } from "./ThreadMessages.js";
|
7
8
|
import { ThreadPrimitiveScrollToBottom } from "./ThreadScrollToBottom.js";
|
8
9
|
import { ThreadPrimitiveSuggestion } from "./ThreadSuggestion.js";
|
9
10
|
export {
|
10
11
|
ThreadPrimitiveEmpty as Empty,
|
11
12
|
ThreadPrimitiveIf as If,
|
13
|
+
ThreadPrimitiveMessageByIndex as MessageByIndex,
|
12
14
|
ThreadPrimitiveMessages as Messages,
|
13
15
|
ThreadPrimitiveRoot as Root,
|
14
16
|
ThreadPrimitiveScrollToBottom as ScrollToBottom,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/thread/index.ts"],"sourcesContent":["export { ThreadPrimitiveRoot as Root } from \"./ThreadRoot\";\nexport { ThreadPrimitiveEmpty as Empty } from \"./ThreadEmpty\";\nexport { ThreadPrimitiveIf as If } from \"./ThreadIf\";\nexport { ThreadPrimitiveViewport as Viewport } from \"./ThreadViewport\";\nexport { ThreadPrimitiveMessages as Messages } from \"./ThreadMessages\";\nexport { ThreadPrimitiveScrollToBottom as ScrollToBottom } from \"./ThreadScrollToBottom\";\nexport { ThreadPrimitiveSuggestion as Suggestion } from \"./ThreadSuggestion\";\n"],"mappings":";AAAA,SAAgC,2BAAY;AAC5C,SAAiC,4BAAa;AAC9C,SAA8B,yBAAU;AACxC,SAAoC,+BAAgB;AACpD,SAAoC,+BAAgB;AACpD,SAA0C,qCAAsB;AAChE,SAAsC,iCAAkB;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/primitives/thread/index.ts"],"sourcesContent":["export { ThreadPrimitiveRoot as Root } from \"./ThreadRoot\";\nexport { ThreadPrimitiveEmpty as Empty } from \"./ThreadEmpty\";\nexport { ThreadPrimitiveIf as If } from \"./ThreadIf\";\nexport { ThreadPrimitiveViewport as Viewport } from \"./ThreadViewport\";\nexport { ThreadPrimitiveMessages as Messages } from \"./ThreadMessages\";\nexport { ThreadPrimitiveMessageByIndex as MessageByIndex } from \"./ThreadMessages\";\nexport { ThreadPrimitiveScrollToBottom as ScrollToBottom } from \"./ThreadScrollToBottom\";\nexport { ThreadPrimitiveSuggestion as Suggestion } from \"./ThreadSuggestion\";\n"],"mappings":";AAAA,SAAgC,2BAAY;AAC5C,SAAiC,4BAAa;AAC9C,SAA8B,yBAAU;AACxC,SAAoC,+BAAgB;AACpD,SAAoC,+BAAgB;AACpD,SAA0C,qCAAsB;AAChE,SAA0C,qCAAsB;AAChE,SAAsC,iCAAkB;","names":[]}
|
@@ -7,5 +7,29 @@ export declare namespace ThreadListPrimitiveItems {
|
|
7
7
|
};
|
8
8
|
};
|
9
9
|
}
|
10
|
+
export declare namespace ThreadListPrimitiveItemByIndex {
|
11
|
+
type Props = {
|
12
|
+
index: number;
|
13
|
+
archived?: boolean | undefined;
|
14
|
+
components: ThreadListPrimitiveItems.Props["components"];
|
15
|
+
};
|
16
|
+
}
|
17
|
+
/**
|
18
|
+
* Renders a single thread list item at the specified index.
|
19
|
+
*
|
20
|
+
* This component provides direct access to render a specific thread
|
21
|
+
* from the thread list using the provided component configuration.
|
22
|
+
*
|
23
|
+
* @example
|
24
|
+
* ```tsx
|
25
|
+
* <ThreadListPrimitive.ItemByIndex
|
26
|
+
* index={0}
|
27
|
+
* components={{
|
28
|
+
* ThreadListItem: MyThreadListItem
|
29
|
+
* }}
|
30
|
+
* />
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
export declare const ThreadListPrimitiveItemByIndex: FC<ThreadListPrimitiveItemByIndex.Props>;
|
10
34
|
export declare const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props>;
|
11
35
|
//# sourceMappingURL=ThreadListItems.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadListItems.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadList/ThreadListItems.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,EAAE,EAAiB,MAAM,OAAO,CAAC;AAIzD,yBAAiB,wBAAwB,CAAC;IACxC,KAAY,KAAK,GAAG;QAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC/B,UAAU,EAAE;YACV,cAAc,EAAE,aAAa,CAAC;SAC/B,CAAC;KACH,CAAC;CACH;
|
1
|
+
{"version":3,"file":"ThreadListItems.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadList/ThreadListItems.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,EAAE,EAAiB,MAAM,OAAO,CAAC;AAIzD,yBAAiB,wBAAwB,CAAC;IACxC,KAAY,KAAK,GAAG;QAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC/B,UAAU,EAAE;YACV,cAAc,EAAE,aAAa,CAAC;SAC/B,CAAC;KACH,CAAC;CACH;AAED,yBAAiB,8BAA8B,CAAC;IAC9C,KAAY,KAAK,GAAG;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC/B,UAAU,EAAE,wBAAwB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;KAC1D,CAAC;CACH;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAAC,8BAA8B,CAAC,KAAK,CAwBjF,CAAC;AAIJ,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAoBvE,CAAC"}
|
@@ -5,23 +5,19 @@ import { memo, useMemo } from "react";
|
|
5
5
|
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider.js";
|
6
6
|
import { useAssistantRuntime, useThreadList } from "../../context/index.js";
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
8
|
-
var
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
return /* @__PURE__ */ jsx(ThreadListItemRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(ThreadListItemComponent, {}) });
|
20
|
-
};
|
21
|
-
var ThreadListItem = memo(
|
22
|
-
ThreadListItemImpl,
|
23
|
-
(prev, next) => prev.partIndex === next.partIndex && prev.archived === next.archived && prev.components.ThreadListItem === next.components.ThreadListItem
|
8
|
+
var ThreadListPrimitiveItemByIndex = memo(
|
9
|
+
({ index, archived = false, components }) => {
|
10
|
+
const assistantRuntime = useAssistantRuntime();
|
11
|
+
const runtime = useMemo(
|
12
|
+
() => archived ? assistantRuntime.threads.getArchivedItemByIndex(index) : assistantRuntime.threads.getItemByIndex(index),
|
13
|
+
[assistantRuntime, index, archived]
|
14
|
+
);
|
15
|
+
const ThreadListItemComponent = components.ThreadListItem;
|
16
|
+
return /* @__PURE__ */ jsx(ThreadListItemRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(ThreadListItemComponent, {}) });
|
17
|
+
},
|
18
|
+
(prev, next) => prev.index === next.index && prev.archived === next.archived && prev.components.ThreadListItem === next.components.ThreadListItem
|
24
19
|
);
|
20
|
+
ThreadListPrimitiveItemByIndex.displayName = "ThreadListPrimitive.ItemByIndex";
|
25
21
|
var ThreadListPrimitiveItems = ({
|
26
22
|
archived = false,
|
27
23
|
components
|
@@ -31,9 +27,9 @@ var ThreadListPrimitiveItems = ({
|
|
31
27
|
);
|
32
28
|
const listElements = useMemo(() => {
|
33
29
|
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ jsx(
|
34
|
-
|
30
|
+
ThreadListPrimitiveItemByIndex,
|
35
31
|
{
|
36
|
-
|
32
|
+
index,
|
37
33
|
archived,
|
38
34
|
components
|
39
35
|
},
|
@@ -44,6 +40,7 @@ var ThreadListPrimitiveItems = ({
|
|
44
40
|
};
|
45
41
|
ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
|
46
42
|
export {
|
43
|
+
ThreadListPrimitiveItemByIndex,
|
47
44
|
ThreadListPrimitiveItems
|
48
45
|
};
|
49
46
|
//# sourceMappingURL=ThreadListItems.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/threadList/ThreadListItems.tsx"],"sourcesContent":["\"use client\";\n\nimport { ComponentType, FC, memo, useMemo } from \"react\";\nimport { ThreadListItemRuntimeProvider } from \"../../context/providers/ThreadListItemRuntimeProvider\";\nimport { useAssistantRuntime, useThreadList } from \"../../context\";\n\nexport namespace ThreadListPrimitiveItems {\n export type Props = {\n archived?: boolean | undefined;\n components: {\n ThreadListItem: ComponentType;\n };\n };\n}\n\
|
1
|
+
{"version":3,"sources":["../../../src/primitives/threadList/ThreadListItems.tsx"],"sourcesContent":["\"use client\";\n\nimport { ComponentType, FC, memo, useMemo } from \"react\";\nimport { ThreadListItemRuntimeProvider } from \"../../context/providers/ThreadListItemRuntimeProvider\";\nimport { useAssistantRuntime, useThreadList } from \"../../context\";\n\nexport namespace ThreadListPrimitiveItems {\n export type Props = {\n archived?: boolean | undefined;\n components: {\n ThreadListItem: ComponentType;\n };\n };\n}\n\nexport namespace ThreadListPrimitiveItemByIndex {\n export type Props = {\n index: number;\n archived?: boolean | undefined;\n components: ThreadListPrimitiveItems.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single thread list item at the specified index.\n *\n * This component provides direct access to render a specific thread\n * from the thread list using the provided component configuration.\n *\n * @example\n * ```tsx\n * <ThreadListPrimitive.ItemByIndex\n * index={0}\n * components={{\n * ThreadListItem: MyThreadListItem\n * }}\n * />\n * ```\n */\nexport const ThreadListPrimitiveItemByIndex: FC<ThreadListPrimitiveItemByIndex.Props> =\n memo(\n ({ index, archived = false, components }) => {\n const assistantRuntime = useAssistantRuntime();\n const runtime = useMemo(\n () =>\n archived\n ? assistantRuntime.threads.getArchivedItemByIndex(index)\n : assistantRuntime.threads.getItemByIndex(index),\n [assistantRuntime, index, archived],\n );\n\n const ThreadListItemComponent = components.ThreadListItem;\n\n return (\n <ThreadListItemRuntimeProvider runtime={runtime}>\n <ThreadListItemComponent />\n </ThreadListItemRuntimeProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.archived === next.archived &&\n prev.components.ThreadListItem === next.components.ThreadListItem,\n );\n\nThreadListPrimitiveItemByIndex.displayName = \"ThreadListPrimitive.ItemByIndex\";\n\nexport const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({\n archived = false,\n components,\n}) => {\n const contentLength = useThreadList((s) =>\n archived ? s.archivedThreads.length : s.threads.length,\n );\n\n const listElements = useMemo(() => {\n return Array.from({ length: contentLength }, (_, index) => (\n <ThreadListPrimitiveItemByIndex\n key={index}\n index={index}\n archived={archived}\n components={components}\n />\n ));\n }, [contentLength, archived, components]);\n\n return listElements;\n};\n\nThreadListPrimitiveItems.displayName = \"ThreadListPrimitive.Items\";\n"],"mappings":";;;AAEA,SAA4B,MAAM,eAAe;AACjD,SAAS,qCAAqC;AAC9C,SAAS,qBAAqB,qBAAqB;AAmDzC;AAhBH,IAAM,iCACX;AAAA,EACE,CAAC,EAAE,OAAO,WAAW,OAAO,WAAW,MAAM;AAC3C,UAAM,mBAAmB,oBAAoB;AAC7C,UAAM,UAAU;AAAA,MACd,MACE,WACI,iBAAiB,QAAQ,uBAAuB,KAAK,IACrD,iBAAiB,QAAQ,eAAe,KAAK;AAAA,MACnD,CAAC,kBAAkB,OAAO,QAAQ;AAAA,IACpC;AAEA,UAAM,0BAA0B,WAAW;AAE3C,WACE,oBAAC,iCAA8B,SAC7B,8BAAC,2BAAwB,GAC3B;AAAA,EAEJ;AAAA,EACA,CAAC,MAAM,SACL,KAAK,UAAU,KAAK,SACpB,KAAK,aAAa,KAAK,YACvB,KAAK,WAAW,mBAAmB,KAAK,WAAW;AACvD;AAEF,+BAA+B,cAAc;AAEtC,IAAM,2BAA+D,CAAC;AAAA,EAC3E,WAAW;AAAA,EACX;AACF,MAAM;AACJ,QAAM,gBAAgB;AAAA,IAAc,CAAC,MACnC,WAAW,EAAE,gBAAgB,SAAS,EAAE,QAAQ;AAAA,EAClD;AAEA,QAAM,eAAe,QAAQ,MAAM;AACjC,WAAO,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG,CAAC,GAAG,UAC/C;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA;AAAA,QACA;AAAA;AAAA,MAHK;AAAA,IAIP,CACD;AAAA,EACH,GAAG,CAAC,eAAe,UAAU,UAAU,CAAC;AAExC,SAAO;AACT;AAEA,yBAAyB,cAAc;","names":[]}
|
@@ -1,4 +1,5 @@
|
|
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";
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,wBAAwB,IAAI,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,uBAAuB,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,wBAAwB,IAAI,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,8BAA8B,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,uBAAuB,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
// src/primitives/threadList/index.ts
|
2
2
|
import { ThreadListPrimitiveNew } from "./ThreadListNew.js";
|
3
3
|
import { ThreadListPrimitiveItems } from "./ThreadListItems.js";
|
4
|
+
import { ThreadListPrimitiveItemByIndex } from "./ThreadListItems.js";
|
4
5
|
import { ThreadListPrimitiveRoot } from "./ThreadListRoot.js";
|
5
6
|
export {
|
7
|
+
ThreadListPrimitiveItemByIndex as ItemByIndex,
|
6
8
|
ThreadListPrimitiveItems as Items,
|
7
9
|
ThreadListPrimitiveNew as New,
|
8
10
|
ThreadListPrimitiveRoot as Root
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/threadList/index.ts"],"sourcesContent":["export { ThreadListPrimitiveNew as New } from \"./ThreadListNew\";\nexport { ThreadListPrimitiveItems as Items } from \"./ThreadListItems\";\nexport { ThreadListPrimitiveRoot as Root } from \"./ThreadListRoot\";\n"],"mappings":";AAAA,SAAmC,8BAAW;AAC9C,SAAqC,gCAAa;AAClD,SAAoC,+BAAY;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/primitives/threadList/index.ts"],"sourcesContent":["export { ThreadListPrimitiveNew as New } from \"./ThreadListNew\";\nexport { ThreadListPrimitiveItems as Items } from \"./ThreadListItems\";\nexport { ThreadListPrimitiveItemByIndex as ItemByIndex } from \"./ThreadListItems\";\nexport { ThreadListPrimitiveRoot as Root } from \"./ThreadListRoot\";\n"],"mappings":";AAAA,SAAmC,8BAAW;AAC9C,SAAqC,gCAAa;AAClD,SAA2C,sCAAmB;AAC9D,SAAoC,+BAAY;","names":[]}
|
package/package.json
CHANGED
@@ -48,31 +48,55 @@ const AttachmentComponent: FC<{
|
|
48
48
|
return <Component />;
|
49
49
|
};
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
export namespace ComposerPrimitiveAttachmentByIndex {
|
52
|
+
export type Props = {
|
53
|
+
index: number;
|
54
|
+
components?: ComposerPrimitiveAttachments.Props["components"];
|
55
|
+
};
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Renders a single attachment at the specified index within the composer.
|
60
|
+
*
|
61
|
+
* This component provides direct access to render a specific attachment
|
62
|
+
* from the composer's attachment list using the provided component configuration.
|
63
|
+
*
|
64
|
+
* @example
|
65
|
+
* ```tsx
|
66
|
+
* <ComposerPrimitive.AttachmentByIndex
|
67
|
+
* index={0}
|
68
|
+
* components={{
|
69
|
+
* Image: MyImageAttachment,
|
70
|
+
* Document: MyDocumentAttachment
|
71
|
+
* }}
|
72
|
+
* />
|
73
|
+
* ```
|
74
|
+
*/
|
75
|
+
export const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =
|
76
|
+
memo(
|
77
|
+
({ index, components }) => {
|
78
|
+
const composerRuntime = useComposerRuntime();
|
79
|
+
const runtime = useMemo(
|
80
|
+
() => composerRuntime.getAttachmentByIndex(index),
|
81
|
+
[composerRuntime, index],
|
82
|
+
);
|
59
83
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
84
|
+
return (
|
85
|
+
<AttachmentRuntimeProvider runtime={runtime}>
|
86
|
+
<AttachmentComponent components={components} />
|
87
|
+
</AttachmentRuntimeProvider>
|
88
|
+
);
|
89
|
+
},
|
90
|
+
(prev, next) =>
|
91
|
+
prev.index === next.index &&
|
92
|
+
prev.components?.Image === next.components?.Image &&
|
93
|
+
prev.components?.Document === next.components?.Document &&
|
94
|
+
prev.components?.File === next.components?.File &&
|
95
|
+
prev.components?.Attachment === next.components?.Attachment,
|
64
96
|
);
|
65
|
-
};
|
66
97
|
|
67
|
-
|
68
|
-
|
69
|
-
(prev, next) =>
|
70
|
-
prev.attachmentIndex === next.attachmentIndex &&
|
71
|
-
prev.components?.Image === next.components?.Image &&
|
72
|
-
prev.components?.Document === next.components?.Document &&
|
73
|
-
prev.components?.File === next.components?.File &&
|
74
|
-
prev.components?.Attachment === next.components?.Attachment,
|
75
|
-
);
|
98
|
+
ComposerPrimitiveAttachmentByIndex.displayName =
|
99
|
+
"ComposerPrimitive.AttachmentByIndex";
|
76
100
|
|
77
101
|
export const ComposerPrimitiveAttachments: FC<
|
78
102
|
ComposerPrimitiveAttachments.Props
|
@@ -81,9 +105,9 @@ export const ComposerPrimitiveAttachments: FC<
|
|
81
105
|
|
82
106
|
const attachmentElements = useMemo(() => {
|
83
107
|
return Array.from({ length: attachmentsCount }, (_, index) => (
|
84
|
-
<
|
108
|
+
<ComposerPrimitiveAttachmentByIndex
|
85
109
|
key={index}
|
86
|
-
|
110
|
+
index={index}
|
87
111
|
components={components}
|
88
112
|
/>
|
89
113
|
));
|
@@ -4,4 +4,5 @@ export { ComposerPrimitiveSend as Send } from "./ComposerSend";
|
|
4
4
|
export { ComposerPrimitiveCancel as Cancel } from "./ComposerCancel";
|
5
5
|
export { ComposerPrimitiveAddAttachment as AddAttachment } from "./ComposerAddAttachment";
|
6
6
|
export { ComposerPrimitiveAttachments as Attachments } from "./ComposerAttachments";
|
7
|
+
export { ComposerPrimitiveAttachmentByIndex as AttachmentByIndex } from "./ComposerAttachments";
|
7
8
|
export { ComposerPrimitiveIf as If } from "./ComposerIf";
|
@@ -46,31 +46,55 @@ const AttachmentComponent: FC<{
|
|
46
46
|
return <Component />;
|
47
47
|
};
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
export namespace MessagePrimitiveAttachmentByIndex {
|
50
|
+
export type Props = {
|
51
|
+
index: number;
|
52
|
+
components?: MessagePrimitiveAttachments.Props["components"];
|
53
|
+
};
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Renders a single attachment at the specified index within the current message.
|
58
|
+
*
|
59
|
+
* This component provides direct access to render a specific attachment
|
60
|
+
* from the message's attachment list using the provided component configuration.
|
61
|
+
*
|
62
|
+
* @example
|
63
|
+
* ```tsx
|
64
|
+
* <MessagePrimitive.AttachmentByIndex
|
65
|
+
* index={0}
|
66
|
+
* components={{
|
67
|
+
* Image: MyImageAttachment,
|
68
|
+
* Document: MyDocumentAttachment
|
69
|
+
* }}
|
70
|
+
* />
|
71
|
+
* ```
|
72
|
+
*/
|
73
|
+
export const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =
|
74
|
+
memo(
|
75
|
+
({ index, components }) => {
|
76
|
+
const messageRuntime = useMessageRuntime();
|
77
|
+
const runtime = useMemo(
|
78
|
+
() => messageRuntime.getAttachmentByIndex(index),
|
79
|
+
[messageRuntime, index],
|
80
|
+
);
|
57
81
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
82
|
+
return (
|
83
|
+
<AttachmentRuntimeProvider runtime={runtime}>
|
84
|
+
<AttachmentComponent components={components} />
|
85
|
+
</AttachmentRuntimeProvider>
|
86
|
+
);
|
87
|
+
},
|
88
|
+
(prev, next) =>
|
89
|
+
prev.index === next.index &&
|
90
|
+
prev.components?.Image === next.components?.Image &&
|
91
|
+
prev.components?.Document === next.components?.Document &&
|
92
|
+
prev.components?.File === next.components?.File &&
|
93
|
+
prev.components?.Attachment === next.components?.Attachment,
|
62
94
|
);
|
63
|
-
};
|
64
95
|
|
65
|
-
|
66
|
-
|
67
|
-
(prev, next) =>
|
68
|
-
prev.attachmentIndex === next.attachmentIndex &&
|
69
|
-
prev.components?.Image === next.components?.Image &&
|
70
|
-
prev.components?.Document === next.components?.Document &&
|
71
|
-
prev.components?.File === next.components?.File &&
|
72
|
-
prev.components?.Attachment === next.components?.Attachment,
|
73
|
-
);
|
96
|
+
MessagePrimitiveAttachmentByIndex.displayName =
|
97
|
+
"MessagePrimitive.AttachmentByIndex";
|
74
98
|
|
75
99
|
export const MessagePrimitiveAttachments: FC<
|
76
100
|
MessagePrimitiveAttachments.Props
|
@@ -82,9 +106,9 @@ export const MessagePrimitiveAttachments: FC<
|
|
82
106
|
|
83
107
|
const attachmentElements = useMemo(() => {
|
84
108
|
return Array.from({ length: attachmentsCount }, (_, index) => (
|
85
|
-
<
|
109
|
+
<MessagePrimitiveAttachmentByIndex
|
86
110
|
key={index}
|
87
|
-
|
111
|
+
index={index}
|
88
112
|
components={components}
|
89
113
|
/>
|
90
114
|
));
|
@@ -279,38 +279,58 @@ const MessagePartComponent: FC<MessagePartComponentProps> = ({
|
|
279
279
|
}
|
280
280
|
};
|
281
281
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
const messageRuntime = useMessageRuntime();
|
289
|
-
const runtime = useMemo(
|
290
|
-
() => messageRuntime.getMessagePartByIndex(partIndex),
|
291
|
-
[messageRuntime, partIndex],
|
292
|
-
);
|
282
|
+
export namespace MessagePrimitivePartByIndex {
|
283
|
+
export type Props = {
|
284
|
+
index: number;
|
285
|
+
components: MessagePrimitiveParts.Props["components"];
|
286
|
+
};
|
287
|
+
}
|
293
288
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
289
|
+
/**
|
290
|
+
* Renders a single message part at the specified index.
|
291
|
+
*
|
292
|
+
* This component provides direct access to render a specific message part
|
293
|
+
* within the current message context, using the provided component configuration.
|
294
|
+
*
|
295
|
+
* @example
|
296
|
+
* ```tsx
|
297
|
+
* <MessagePrimitive.PartByIndex
|
298
|
+
* index={0}
|
299
|
+
* components={{
|
300
|
+
* Text: MyTextComponent,
|
301
|
+
* Image: MyImageComponent
|
302
|
+
* }}
|
303
|
+
* />
|
304
|
+
* ```
|
305
|
+
*/
|
306
|
+
export const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =
|
307
|
+
memo(
|
308
|
+
({ index, components }) => {
|
309
|
+
const messageRuntime = useMessageRuntime();
|
310
|
+
const runtime = useMemo(
|
311
|
+
() => messageRuntime.getMessagePartByIndex(index),
|
312
|
+
[messageRuntime, index],
|
313
|
+
);
|
314
|
+
|
315
|
+
return (
|
316
|
+
<MessagePartRuntimeProvider runtime={runtime}>
|
317
|
+
<MessagePartComponent components={components} />
|
318
|
+
</MessagePartRuntimeProvider>
|
319
|
+
);
|
320
|
+
},
|
321
|
+
(prev, next) =>
|
322
|
+
prev.index === next.index &&
|
323
|
+
prev.components?.Text === next.components?.Text &&
|
324
|
+
prev.components?.Reasoning === next.components?.Reasoning &&
|
325
|
+
prev.components?.Source === next.components?.Source &&
|
326
|
+
prev.components?.Image === next.components?.Image &&
|
327
|
+
prev.components?.File === next.components?.File &&
|
328
|
+
prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&
|
329
|
+
prev.components?.tools === next.components?.tools &&
|
330
|
+
prev.components?.ToolGroup === next.components?.ToolGroup,
|
298
331
|
);
|
299
|
-
};
|
300
332
|
|
301
|
-
|
302
|
-
MessagePartImpl,
|
303
|
-
(prev, next) =>
|
304
|
-
prev.partIndex === next.partIndex &&
|
305
|
-
prev.components?.Text === next.components?.Text &&
|
306
|
-
prev.components?.Reasoning === next.components?.Reasoning &&
|
307
|
-
prev.components?.Source === next.components?.Source &&
|
308
|
-
prev.components?.Image === next.components?.Image &&
|
309
|
-
prev.components?.File === next.components?.File &&
|
310
|
-
prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&
|
311
|
-
prev.components?.tools === next.components?.tools &&
|
312
|
-
prev.components?.ToolGroup === next.components?.ToolGroup,
|
313
|
-
);
|
333
|
+
MessagePrimitivePartByIndex.displayName = "MessagePrimitive.PartByIndex";
|
314
334
|
|
315
335
|
const COMPLETE_STATUS: MessagePartStatus = Object.freeze({
|
316
336
|
type: "complete",
|
@@ -386,9 +406,9 @@ export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
|
|
386
406
|
return messageRanges.map((range) => {
|
387
407
|
if (range.type === "single") {
|
388
408
|
return (
|
389
|
-
<
|
409
|
+
<MessagePrimitivePartByIndex
|
390
410
|
key={range.index}
|
391
|
-
|
411
|
+
index={range.index}
|
392
412
|
components={components}
|
393
413
|
/>
|
394
414
|
);
|
@@ -404,9 +424,9 @@ export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
|
|
404
424
|
{Array.from(
|
405
425
|
{ length: range.endIndex - range.startIndex + 1 },
|
406
426
|
(_, i) => (
|
407
|
-
<
|
427
|
+
<MessagePrimitivePartByIndex
|
408
428
|
key={i}
|
409
|
-
|
429
|
+
index={range.startIndex + i}
|
410
430
|
components={components}
|
411
431
|
/>
|
412
432
|
),
|
@@ -1,8 +1,10 @@
|
|
1
1
|
export { MessagePrimitiveRoot as Root } from "./MessageRoot";
|
2
2
|
export { MessagePrimitiveParts as Parts } from "./MessageParts";
|
3
|
+
export { MessagePrimitivePartByIndex as PartByIndex } from "./MessageParts";
|
3
4
|
export { MessagePrimitiveParts as Content } from "./MessageParts";
|
4
5
|
export { MessagePrimitiveIf as If } from "./MessageIf";
|
5
6
|
export { MessagePrimitiveAttachments as Attachments } from "./MessageAttachments";
|
7
|
+
export { MessagePrimitiveAttachmentByIndex as AttachmentByIndex } from "./MessageAttachments";
|
6
8
|
export { MessagePrimitiveError as Error } from "./MessageError";
|
7
9
|
export {
|
8
10
|
MessagePrimitiveUnstable_PartsGrouped as Unstable_PartsGrouped,
|