@copilotkit/react-ui 1.3.7 → 1.3.8-fix-memoize-chat-ui-context.0
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/CHANGELOG.md +10 -0
- package/dist/{chunk-7YQICPBC.mjs → chunk-3KBQXU44.mjs} +9 -9
- package/dist/{chunk-XSUSSWDS.mjs → chunk-3XAXY2Z3.mjs} +2 -2
- package/dist/{chunk-6VYMULPK.mjs → chunk-47OPG5FM.mjs} +9 -9
- package/dist/{chunk-RWT7WRG2.mjs → chunk-6BL5C56L.mjs} +2 -2
- package/dist/{chunk-DP5YVGNX.mjs → chunk-6INMITFA.mjs} +2 -2
- package/dist/{chunk-BJPGMY3I.mjs → chunk-CBBFRI3Q.mjs} +19 -8
- package/dist/{chunk-BJPGMY3I.mjs.map → chunk-CBBFRI3Q.mjs.map} +1 -1
- package/dist/{chunk-SHTMRY45.mjs → chunk-CPMIEVKK.mjs} +2 -2
- package/dist/{chunk-BNCTYKEP.mjs → chunk-JTINVYPK.mjs} +2 -2
- package/dist/{chunk-TYYJR3LE.mjs → chunk-KCAVDFB6.mjs} +2 -2
- package/dist/{chunk-YOH25I6N.mjs → chunk-RQNJNK2W.mjs} +2 -2
- package/dist/{chunk-JQOSF44H.mjs → chunk-SWADR6EH.mjs} +2 -2
- package/dist/{chunk-FLV3J3VX.mjs → chunk-VEC45H6Q.mjs} +2 -2
- package/dist/{chunk-WHSD7DBC.mjs → chunk-WYMTXCQU.mjs} +2 -2
- package/dist/{chunk-FO7Z5LAL.mjs → chunk-YAGE7RCE.mjs} +2 -2
- package/dist/{chunk-AAY3WWWC.mjs → chunk-ZABXREBH.mjs} +2 -2
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +2 -2
- package/dist/components/chat/Chat.js +17 -6
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +9 -9
- package/dist/components/chat/ChatContext.js +17 -6
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +1 -1
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +2 -2
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +2 -2
- package/dist/components/chat/Modal.js +17 -6
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +13 -13
- package/dist/components/chat/Popup.js +17 -6
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +14 -14
- package/dist/components/chat/Response.js.map +1 -1
- package/dist/components/chat/Response.mjs +2 -2
- package/dist/components/chat/Sidebar.js +17 -6
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +14 -14
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +2 -2
- package/dist/components/chat/index.js +17 -6
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +15 -15
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +2 -2
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +2 -2
- package/dist/components/chat/messages/RenderResultMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +2 -2
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +2 -2
- package/dist/components/index.js +17 -6
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +15 -15
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/package.json +7 -7
- package/src/components/chat/ChatContext.tsx +21 -8
- /package/dist/{chunk-7YQICPBC.mjs.map → chunk-3KBQXU44.mjs.map} +0 -0
- /package/dist/{chunk-XSUSSWDS.mjs.map → chunk-3XAXY2Z3.mjs.map} +0 -0
- /package/dist/{chunk-6VYMULPK.mjs.map → chunk-47OPG5FM.mjs.map} +0 -0
- /package/dist/{chunk-RWT7WRG2.mjs.map → chunk-6BL5C56L.mjs.map} +0 -0
- /package/dist/{chunk-DP5YVGNX.mjs.map → chunk-6INMITFA.mjs.map} +0 -0
- /package/dist/{chunk-SHTMRY45.mjs.map → chunk-CPMIEVKK.mjs.map} +0 -0
- /package/dist/{chunk-BNCTYKEP.mjs.map → chunk-JTINVYPK.mjs.map} +0 -0
- /package/dist/{chunk-TYYJR3LE.mjs.map → chunk-KCAVDFB6.mjs.map} +0 -0
- /package/dist/{chunk-YOH25I6N.mjs.map → chunk-RQNJNK2W.mjs.map} +0 -0
- /package/dist/{chunk-JQOSF44H.mjs.map → chunk-SWADR6EH.mjs.map} +0 -0
- /package/dist/{chunk-FLV3J3VX.mjs.map → chunk-VEC45H6Q.mjs.map} +0 -0
- /package/dist/{chunk-WHSD7DBC.mjs.map → chunk-WYMTXCQU.mjs.map} +0 -0
- /package/dist/{chunk-FO7Z5LAL.mjs.map → chunk-YAGE7RCE.mjs.map} +0 -0
- /package/dist/{chunk-AAY3WWWC.mjs.map → chunk-ZABXREBH.mjs.map} +0 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-SWADR6EH.mjs";
|
|
4
|
+
import "../../chunk-47OPG5FM.mjs";
|
|
5
|
+
import "../../chunk-YAGE7RCE.mjs";
|
|
6
|
+
import "../../chunk-VEC45H6Q.mjs";
|
|
7
|
+
import "../../chunk-RQNJNK2W.mjs";
|
|
8
|
+
import "../../chunk-3KBQXU44.mjs";
|
|
9
9
|
import "../../chunk-V7W6IM2V.mjs";
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-6BL5C56L.mjs";
|
|
11
|
+
import "../../chunk-ZABXREBH.mjs";
|
|
12
|
+
import "../../chunk-6INMITFA.mjs";
|
|
13
|
+
import "../../chunk-WYMTXCQU.mjs";
|
|
14
14
|
import "../../chunk-KFQYJ5R5.mjs";
|
|
15
15
|
import "../../chunk-RS6UPR5N.mjs";
|
|
16
16
|
import "../../chunk-4FIGRRFS.mjs";
|
|
17
17
|
import "../../chunk-OTPAZXVR.mjs";
|
|
18
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-JTINVYPK.mjs";
|
|
19
19
|
import "../../chunk-YQFVRDNC.mjs";
|
|
20
20
|
import "../../chunk-YQ3D5IQV.mjs";
|
|
21
|
-
import "../../chunk-
|
|
22
|
-
import "../../chunk-
|
|
23
|
-
import "../../chunk-
|
|
21
|
+
import "../../chunk-CPMIEVKK.mjs";
|
|
22
|
+
import "../../chunk-3XAXY2Z3.mjs";
|
|
23
|
+
import "../../chunk-CBBFRI3Q.mjs";
|
|
24
24
|
import "../../chunk-UPTB2MVO.mjs";
|
|
25
25
|
import "../../chunk-FZC7X5PK.mjs";
|
|
26
26
|
import "../../chunk-54JAUBUJ.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/chat/Response.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { useChatContext } from \"./ChatContext\";\nimport { ResponseButtonProps } from \"./props\";\n\nexport const ResponseButton = ({ onClick, inProgress }: ResponseButtonProps) => {\n const context = useChatContext();\n return (\n <button onClick={onClick} className=\"copilotKitResponseButton\">\n <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>\n {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}\n </button>\n );\n};\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/Response.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { useChatContext } from \"./ChatContext\";\nimport { ResponseButtonProps } from \"./props\";\n\nexport const ResponseButton = ({ onClick, inProgress }: ResponseButtonProps) => {\n const context = useChatContext();\n return (\n <button onClick={onClick} className=\"copilotKitResponseButton\">\n <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>\n {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}\n </button>\n );\n};\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.PushToTalkIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AA0LhC;AA5EF,IAAM,cAAc,aAAAA,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ADlHI,IAAAC,sBAAA;AAHG,IAAM,iBAAiB,CAAC,EAAE,SAAS,WAAW,MAA2B;AAC9E,QAAM,UAAU,eAAe;AAC/B,SACE,8CAAC,YAAO,SAAkB,WAAU,4BAClC;AAAA,iDAAC,UAAM,uBAAa,QAAQ,MAAM,WAAW,QAAQ,MAAM,gBAAe;AAAA,IACzE,aAAa,QAAQ,OAAO,iBAAiB,QAAQ,OAAO;AAAA,KAC/D;AAEJ;","names":["React","import_jsx_runtime"]}
|
|
@@ -352,8 +352,8 @@ var ChatContextProvider = ({
|
|
|
352
352
|
open,
|
|
353
353
|
setOpen
|
|
354
354
|
}) => {
|
|
355
|
-
const
|
|
356
|
-
|
|
355
|
+
const memoizedLabels = (0, import_react.useMemo)(
|
|
356
|
+
() => __spreadValues(__spreadValues({}, {
|
|
357
357
|
initial: "",
|
|
358
358
|
title: "CopilotKit",
|
|
359
359
|
placeholder: "Type a message...",
|
|
@@ -361,7 +361,10 @@ var ChatContextProvider = ({
|
|
|
361
361
|
stopGenerating: "Stop generating",
|
|
362
362
|
regenerateResponse: "Regenerate response"
|
|
363
363
|
}), labels),
|
|
364
|
-
|
|
364
|
+
[labels]
|
|
365
|
+
);
|
|
366
|
+
const memoizedIcons = (0, import_react.useMemo)(
|
|
367
|
+
() => __spreadValues(__spreadValues({}, {
|
|
365
368
|
openIcon: OpenIcon,
|
|
366
369
|
closeIcon: CloseIcon,
|
|
367
370
|
headerCloseIcon: HeaderCloseIcon,
|
|
@@ -372,9 +375,17 @@ var ChatContextProvider = ({
|
|
|
372
375
|
regenerateIcon: RegenerateIcon,
|
|
373
376
|
pushToTalkIcon: PushToTalkIcon
|
|
374
377
|
}), icons),
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
+
[icons]
|
|
379
|
+
);
|
|
380
|
+
const context = (0, import_react.useMemo)(
|
|
381
|
+
() => ({
|
|
382
|
+
labels: memoizedLabels,
|
|
383
|
+
icons: memoizedIcons,
|
|
384
|
+
open,
|
|
385
|
+
setOpen
|
|
386
|
+
}),
|
|
387
|
+
[memoizedLabels, memoizedIcons, open, setOpen]
|
|
388
|
+
);
|
|
378
389
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
|
|
379
390
|
};
|
|
380
391
|
|