@copilotkit/react-ui 1.9.2-next.2 → 1.9.2-next.4

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # ui
2
2
 
3
+ ## 1.9.2-next.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9169ad7]
8
+ - Updated dependencies [9169ad7]
9
+ - @copilotkit/react-core@1.9.2-next.4
10
+ - @copilotkit/shared@1.9.2-next.4
11
+ - @copilotkit/runtime-client-gql@1.9.2-next.4
12
+
13
+ ## 1.9.2-next.3
14
+
15
+ ### Patch Changes
16
+
17
+ - 35537f1: - fix: memoize nested components to not rerender when content changes
18
+ - Updated dependencies [35537f1]
19
+ - @copilotkit/react-core@1.9.2-next.3
20
+ - @copilotkit/runtime-client-gql@1.9.2-next.3
21
+ - @copilotkit/shared@1.9.2-next.3
22
+
3
23
  ## 1.9.2-next.2
4
24
 
5
25
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-725PPN77.mjs";
3
+ } from "./chunk-XZI6DUGE.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
18
18
  export {
19
19
  CopilotPopup
20
20
  };
21
- //# sourceMappingURL=chunk-6HXS43LW.mjs.map
21
+ //# sourceMappingURL=chunk-GBGU4ZR6.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-725PPN77.mjs";
3
+ } from "./chunk-XZI6DUGE.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
27
27
  export {
28
28
  CopilotSidebar
29
29
  };
30
- //# sourceMappingURL=chunk-6JX4WIAX.mjs.map
30
+ //# sourceMappingURL=chunk-KGKVOUC3.mjs.map
@@ -32,7 +32,7 @@ import {
32
32
  } from "./chunk-MRXNTQOX.mjs";
33
33
 
34
34
  // src/components/chat/Modal.tsx
35
- import React from "react";
35
+ import React, { useMemo } from "react";
36
36
  import { jsx, jsxs } from "react/jsx-runtime";
37
37
  var CopilotModal = (_a) => {
38
38
  var _b = _a, {
@@ -97,8 +97,10 @@ var CopilotModal = (_a) => {
97
97
  onSetOpen == null ? void 0 : onSetOpen(open);
98
98
  setOpenState(open);
99
99
  };
100
+ const memoizedHeader = useMemo(() => /* @__PURE__ */ jsx(Header2, {}), [Header2]);
101
+ const memoizedChildren = useMemo(() => children, [children]);
100
102
  return /* @__PURE__ */ jsxs(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
101
- children,
103
+ memoizedChildren,
102
104
  /* @__PURE__ */ jsxs("div", { className, children: [
103
105
  /* @__PURE__ */ jsx(Button2, {}),
104
106
  /* @__PURE__ */ jsxs(
@@ -108,7 +110,7 @@ var CopilotModal = (_a) => {
108
110
  shortcut,
109
111
  hitEscapeToClose,
110
112
  children: [
111
- /* @__PURE__ */ jsx(Header2, {}),
113
+ memoizedHeader,
112
114
  /* @__PURE__ */ jsx(
113
115
  CopilotChat,
114
116
  __spreadProps(__spreadValues({}, props), {
@@ -139,4 +141,4 @@ var CopilotModal = (_a) => {
139
141
  export {
140
142
  CopilotModal
141
143
  };
142
- //# sourceMappingURL=chunk-725PPN77.mjs.map
144
+ //# sourceMappingURL=chunk-XZI6DUGE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Modal.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { ChatContextProvider } from \"./ChatContext\";\nimport { ButtonProps, HeaderProps, WindowProps } from \"./props\";\nimport { Window as DefaultWindow } from \"./Window\";\nimport { Button as DefaultButton } from \"./Button\";\nimport { Header as DefaultHeader } from \"./Header\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { CopilotChat, CopilotChatProps } from \"./Chat\";\nimport { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\n\nexport interface CopilotModalProps extends CopilotChatProps {\n /**\n * Whether the chat window should be open by default.\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * If the chat window should close when the user clicks outside of it.\n * @default true\n */\n clickOutsideToClose?: boolean;\n\n /**\n * If the chat window should close when the user hits the Escape key.\n * @default true\n */\n hitEscapeToClose?: boolean;\n\n /**\n * The shortcut key to open the chat window.\n * Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.\n * @default '/'\n */\n shortcut?: string;\n\n /**\n * A callback that gets called when the chat window opens or closes.\n */\n onSetOpen?: (open: boolean) => void;\n\n /**\n * A custom Window component to use instead of the default.\n */\n Window?: React.ComponentType<WindowProps>;\n\n /**\n * A custom Button component to use instead of the default.\n */\n Button?: React.ComponentType<ButtonProps>;\n\n /**\n * A custom Header component to use instead of the default.\n */\n Header?: React.ComponentType<HeaderProps>;\n}\n\nexport const CopilotModal = ({\n instructions,\n defaultOpen = false,\n clickOutsideToClose = true,\n hitEscapeToClose = true,\n onSetOpen,\n onSubmitMessage,\n onStopGeneration,\n onReloadMessages,\n shortcut = \"/\",\n icons,\n labels,\n makeSystemMessage,\n onInProgress,\n Window = DefaultWindow,\n Button = DefaultButton,\n Header = DefaultHeader,\n Messages = DefaultMessages,\n Input = DefaultInput,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n onThumbsUp,\n onThumbsDown,\n onCopy,\n onRegenerate,\n markdownTagRenderers,\n className,\n children,\n ...props\n}: CopilotModalProps) => {\n const [openState, setOpenState] = React.useState(defaultOpen);\n\n const setOpen = (open: boolean) => {\n onSetOpen?.(open);\n setOpenState(open);\n };\n\n const memoizedHeader = useMemo(() => <Header />, [Header]);\n const memoizedChildren = useMemo(() => children, [children]);\n\n return (\n <ChatContextProvider icons={icons} labels={labels} open={openState} setOpen={setOpen}>\n {memoizedChildren}\n <div className={className}>\n <Button></Button>\n <Window\n clickOutsideToClose={clickOutsideToClose}\n shortcut={shortcut}\n hitEscapeToClose={hitEscapeToClose}\n >\n {memoizedHeader}\n <CopilotChat\n {...props}\n instructions={instructions}\n onSubmitMessage={onSubmitMessage}\n onStopGeneration={onStopGeneration}\n onReloadMessages={onReloadMessages}\n makeSystemMessage={makeSystemMessage}\n onInProgress={onInProgress}\n Messages={Messages}\n Input={Input}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n onCopy={onCopy}\n onRegenerate={onRegenerate}\n markdownTagRenderers={markdownTagRenderers}\n />\n </Window>\n </div>\n </ChatContextProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,SAAS,eAAe;AAgGQ,cAQ/B,YAR+B;AArChC,IAAM,eAAe,CAAC,OA6BJ;AA7BI,eAC3B;AAAA;AAAA,IACA,cAAc;AAAA,IACd,sBAAsB;AAAA,IACtB,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAAA,UAAS;AAAA,IACT,QAAAC,UAAS;AAAA,IACT,QAAAC,UAAS;AAAA,IACT,UAAAC,YAAW;AAAA,IACX,OAAAC,SAAQ;AAAA,IACR,kBAAAC,oBAAmB;AAAA,IACnB,aAAAC,eAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAtFF,IA2D6B,IA4BxB,kBA5BwB,IA4BxB;AAAA,IA3BH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,WAAW;AAE5D,QAAM,UAAU,CAAC,SAAkB;AACjC,2CAAY;AACZ,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,iBAAiB,QAAQ,MAAM,oBAACJ,SAAA,EAAO,GAAI,CAACA,OAAM,CAAC;AACzD,QAAM,mBAAmB,QAAQ,MAAM,UAAU,CAAC,QAAQ,CAAC;AAE3D,SACE,qBAAC,uBAAoB,OAAc,QAAgB,MAAM,WAAW,SACjE;AAAA;AAAA,IACD,qBAAC,SAAI,WACH;AAAA,0BAACD,SAAA,EAAO;AAAA,MACR;AAAA,QAACD;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,YACD;AAAA,cAAC;AAAA,+CACK,QADL;AAAA,gBAEC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAUG;AAAA,gBACV,OAAOC;AAAA,gBACP,kBAAkBC;AAAA,gBAClB,aAAaC;AAAA,gBACb;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACF;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Window","Button","Header","Messages","Input","AssistantMessage","UserMessage"]}
@@ -3143,8 +3143,10 @@ var CopilotModal = (_a) => {
3143
3143
  onSetOpen == null ? void 0 : onSetOpen(open);
3144
3144
  setOpenState(open);
3145
3145
  };
3146
+ const memoizedHeader = (0, import_react14.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Header2, {}), [Header2]);
3147
+ const memoizedChildren = (0, import_react14.useMemo)(() => children, [children]);
3146
3148
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
3147
- children,
3149
+ memoizedChildren,
3148
3150
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className, children: [
3149
3151
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Button2, {}),
3150
3152
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
@@ -3154,7 +3156,7 @@ var CopilotModal = (_a) => {
3154
3156
  shortcut,
3155
3157
  hitEscapeToClose,
3156
3158
  children: [
3157
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Header2, {}),
3159
+ memoizedHeader,
3158
3160
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3159
3161
  CopilotChat,
3160
3162
  __spreadProps(__spreadValues({}, props), {