@copilotkit/react-ui 1.8.14-next.0 → 1.8.14-next.1

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-FWKHST6I.mjs → chunk-BNTE4N7G.mjs} +2 -2
  3. package/dist/{chunk-TIDV74OE.mjs → chunk-C3GSYRC3.mjs} +2 -4
  4. package/dist/chunk-C3GSYRC3.mjs.map +1 -0
  5. package/dist/{chunk-QEZ3YYLO.mjs → chunk-MG26A5JB.mjs} +2 -2
  6. package/dist/{chunk-JU3HNL5N.mjs → chunk-RMX44BOI.mjs} +2 -2
  7. package/dist/components/chat/Modal.js +8 -10
  8. package/dist/components/chat/Modal.js.map +1 -1
  9. package/dist/components/chat/Modal.mjs +2 -2
  10. package/dist/components/chat/Popup.js +8 -10
  11. package/dist/components/chat/Popup.js.map +1 -1
  12. package/dist/components/chat/Popup.mjs +3 -3
  13. package/dist/components/chat/Sidebar.js +8 -10
  14. package/dist/components/chat/Sidebar.js.map +1 -1
  15. package/dist/components/chat/Sidebar.mjs +3 -3
  16. package/dist/components/chat/Window.js +2 -4
  17. package/dist/components/chat/Window.js.map +1 -1
  18. package/dist/components/chat/Window.mjs +1 -1
  19. package/dist/components/chat/index.js +8 -10
  20. package/dist/components/chat/index.js.map +1 -1
  21. package/dist/components/chat/index.mjs +4 -4
  22. package/dist/components/index.js +8 -10
  23. package/dist/components/index.js.map +1 -1
  24. package/dist/components/index.mjs +4 -4
  25. package/dist/index.js +10 -12
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +4 -4
  28. package/package.json +4 -4
  29. package/src/components/chat/Window.tsx +1 -4
  30. package/dist/chunk-TIDV74OE.mjs.map +0 -1
  31. /package/dist/{chunk-FWKHST6I.mjs.map → chunk-BNTE4N7G.mjs.map} +0 -0
  32. /package/dist/{chunk-QEZ3YYLO.mjs.map → chunk-MG26A5JB.mjs.map} +0 -0
  33. /package/dist/{chunk-JU3HNL5N.mjs.map → chunk-RMX44BOI.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # ui
2
2
 
3
+ ## 1.8.14-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [34a78d8]
8
+ - @copilotkit/shared@1.8.14-next.1
9
+ - @copilotkit/react-core@1.8.14-next.1
10
+ - @copilotkit/runtime-client-gql@1.8.14-next.1
11
+
3
12
  ## 1.8.14-next.0
4
13
 
5
14
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Window
3
- } from "./chunk-TIDV74OE.mjs";
3
+ } from "./chunk-C3GSYRC3.mjs";
4
4
  import {
5
5
  Header
6
6
  } from "./chunk-UH2UFL5W.mjs";
@@ -139,4 +139,4 @@ var CopilotModal = (_a) => {
139
139
  export {
140
140
  CopilotModal
141
141
  };
142
- //# sourceMappingURL=chunk-FWKHST6I.mjs.map
142
+ //# sourceMappingURL=chunk-BNTE4N7G.mjs.map
@@ -5,6 +5,7 @@ import {
5
5
  // src/components/chat/Window.tsx
6
6
  import React, { useCallback, useEffect } from "react";
7
7
  import { useCopilotContext } from "@copilotkit/react-core";
8
+ import { isMacOS } from "@copilotkit/shared";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
  var Window = ({
10
11
  children,
@@ -110,11 +111,8 @@ var preventScroll = (event) => {
110
111
  event.preventDefault();
111
112
  }
112
113
  };
113
- function isMacOS() {
114
- return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
115
- }
116
114
 
117
115
  export {
118
116
  Window
119
117
  };
120
- //# sourceMappingURL=chunk-TIDV74OE.mjs.map
118
+ //# sourceMappingURL=chunk-C3GSYRC3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Window.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { WindowProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { isMacOS } from \"@copilotkit/shared\";\n\nexport const Window = ({\n children,\n clickOutsideToClose,\n shortcut,\n hitEscapeToClose,\n}: WindowProps) => {\n const windowRef = React.useRef<HTMLDivElement>(null);\n const context = useCopilotContext();\n\n const { open, setOpen } = useChatContext();\n\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (!clickOutsideToClose) {\n return;\n }\n\n const parentElement = windowRef.current?.parentElement;\n\n let className = \"\";\n if (event.target instanceof HTMLElement) {\n className = event.target.className;\n }\n\n if (\n open &&\n parentElement &&\n !parentElement.contains(event.target as any) &&\n // prevent closing the window when clicking on the debug menu\n !className.includes(\"copilotKitDebugMenu\")\n ) {\n setOpen(false);\n }\n },\n [clickOutsideToClose, open, setOpen],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const isInput =\n target.tagName === \"INPUT\" ||\n target.tagName === \"SELECT\" ||\n target.tagName === \"TEXTAREA\" ||\n target.isContentEditable;\n\n const isDescendantOfWrapper = windowRef.current?.contains(target);\n\n if (\n open &&\n event.key === \"Escape\" &&\n (!isInput || isDescendantOfWrapper) &&\n hitEscapeToClose\n ) {\n setOpen(false);\n } else if (\n event.key === shortcut &&\n ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&\n (!isInput || isDescendantOfWrapper)\n ) {\n setOpen(!open);\n }\n },\n [hitEscapeToClose, shortcut, open, setOpen],\n );\n\n const adjustForMobile = useCallback(() => {\n const copilotKitWindow = windowRef.current;\n const vv = window.visualViewport;\n if (!copilotKitWindow || !vv) {\n return;\n }\n\n if (window.innerWidth < 640 && open) {\n copilotKitWindow.style.height = `${vv.height}px`;\n copilotKitWindow.style.left = `${vv.offsetLeft}px`;\n copilotKitWindow.style.top = `${vv.offsetTop}px`;\n\n document.body.style.position = \"fixed\";\n document.body.style.width = \"100%\";\n document.body.style.height = `${window.innerHeight}px`;\n document.body.style.overflow = \"hidden\";\n document.body.style.touchAction = \"none\";\n\n // Prevent scrolling on iOS\n document.body.addEventListener(\"touchmove\", preventScroll, {\n passive: false,\n });\n } else {\n copilotKitWindow.style.height = \"\";\n copilotKitWindow.style.left = \"\";\n copilotKitWindow.style.top = \"\";\n document.body.style.position = \"\";\n document.body.style.height = \"\";\n document.body.style.width = \"\";\n document.body.style.overflow = \"\";\n document.body.style.top = \"\";\n document.body.style.touchAction = \"\";\n\n document.body.removeEventListener(\"touchmove\", preventScroll);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n document.addEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", adjustForMobile);\n adjustForMobile();\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n document.removeEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", adjustForMobile);\n }\n };\n }, [adjustForMobile, handleClickOutside, handleKeyDown]);\n\n return (\n <div className={`copilotKitWindow ${open ? \" open\" : \"\"}`} ref={windowRef}>\n {children}\n </div>\n );\n};\n\nconst preventScroll = (event: TouchEvent): void => {\n let targetElement = event.target as Element;\n\n // Function to check if the target has the parent with a given class\n const hasParentWithClass = (element: Element, className: string): boolean => {\n while (element && element !== document.body) {\n if (element.classList.contains(className)) {\n return true;\n }\n element = element.parentElement!;\n }\n return false;\n };\n\n // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class\n if (!hasParentWithClass(targetElement, \"copilotKitMessages\")) {\n event.preventDefault();\n }\n};\n"],"mappings":";;;;;AAAA,OAAO,SAAS,aAAa,iBAAiB;AAG9C,SAAS,yBAAyB;AAClC,SAAS,eAAe;AA2HpB;AAzHG,IAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmB;AACjB,QAAM,YAAY,MAAM,OAAuB,IAAI;AACnD,QAAM,UAAU,kBAAkB;AAElC,Q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,SAAS,MAAM;AAC3C,UAAI,QAAQ,UAAU,SAAS,SAAS,GAAG;AACzC,eAAO;AAAA,MACT;AACA,gBAAU,QAAQ;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,eAAe,oBAAoB,GAAG;AAC5D,UAAM,eAAe;AAAA,EACvB;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-FWKHST6I.mjs";
3
+ } from "./chunk-BNTE4N7G.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-QEZ3YYLO.mjs.map
21
+ //# sourceMappingURL=chunk-MG26A5JB.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-FWKHST6I.mjs";
3
+ } from "./chunk-BNTE4N7G.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-JU3HNL5N.mjs.map
30
+ //# sourceMappingURL=chunk-RMX44BOI.mjs.map
@@ -396,6 +396,7 @@ var ChatContextProvider = ({
396
396
  // src/components/chat/Window.tsx
397
397
  var import_react2 = __toESM(require("react"));
398
398
  var import_react_core = require("@copilotkit/react-core");
399
+ var import_shared = require("@copilotkit/shared");
399
400
  var import_jsx_runtime3 = require("react/jsx-runtime");
400
401
  var Window = ({
401
402
  children,
@@ -432,7 +433,7 @@ var Window = ({
432
433
  const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
433
434
  if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
434
435
  setOpen(false);
435
- } else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
436
+ } else if (event.key === shortcut && ((0, import_shared.isMacOS)() && event.metaKey || !(0, import_shared.isMacOS)() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
436
437
  setOpen(!open);
437
438
  }
438
439
  },
@@ -501,9 +502,6 @@ var preventScroll = (event) => {
501
502
  event.preventDefault();
502
503
  }
503
504
  };
504
- function isMacOS() {
505
- return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
506
- }
507
505
 
508
506
  // src/components/chat/Button.tsx
509
507
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -732,7 +730,7 @@ var CheckIcon2 = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
732
730
 
733
731
  // src/components/dev-console/console.tsx
734
732
  var import_react5 = require("@headlessui/react");
735
- var import_shared = require("@copilotkit/shared");
733
+ var import_shared2 = require("@copilotkit/shared");
736
734
 
737
735
  // src/components/help-modal/modal.tsx
738
736
  var import_react3 = require("react");
@@ -844,7 +842,7 @@ function CopilotKitHelpModal() {
844
842
  // src/components/dev-console/console.tsx
845
843
  var import_jsx_runtime8 = require("react/jsx-runtime");
846
844
  function CopilotDevConsole() {
847
- const currentVersion = import_shared.COPILOTKIT_VERSION;
845
+ const currentVersion = import_shared2.COPILOTKIT_VERSION;
848
846
  const context = (0, import_react_core3.useCopilotContext)();
849
847
  const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
850
848
  (0, import_react4.useEffect)(() => {
@@ -2490,7 +2488,7 @@ var import_react_core10 = require("@copilotkit/react-core");
2490
2488
 
2491
2489
  // src/components/chat/Suggestion.tsx
2492
2490
  var import_react_core9 = require("@copilotkit/react-core");
2493
- var import_shared2 = require("@copilotkit/shared");
2491
+ var import_shared3 = require("@copilotkit/shared");
2494
2492
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
2495
2493
  var import_jsx_runtime23 = require("react/jsx-runtime");
2496
2494
  function Suggestion({ title, onClick, partial, className }) {
@@ -2514,7 +2512,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
2514
2512
  Object.values(context.actions).map((action) => ({
2515
2513
  name: action.name,
2516
2514
  description: action.description,
2517
- jsonSchema: JSON.stringify((0, import_shared2.actionParametersToJsonSchema)(action.parameters))
2515
+ jsonSchema: JSON.stringify((0, import_shared3.actionParametersToJsonSchema)(action.parameters))
2518
2516
  }))
2519
2517
  );
2520
2518
  const allSuggestions = [];
@@ -2580,7 +2578,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
2580
2578
 
2581
2579
  // src/components/chat/Chat.tsx
2582
2580
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
2583
- var import_shared3 = require("@copilotkit/shared");
2581
+ var import_shared4 = require("@copilotkit/shared");
2584
2582
  var import_react_core11 = require("@copilotkit/react-core");
2585
2583
 
2586
2584
  // src/components/chat/ImageUploadQueue.tsx
@@ -2917,7 +2915,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
2917
2915
  runChatCompletion,
2918
2916
  isLoading
2919
2917
  } = (0, import_react_core10.useCopilotChat)({
2920
- id: (0, import_shared3.randomId)(),
2918
+ id: (0, import_shared4.randomId)(),
2921
2919
  makeSystemMessage
2922
2920
  });
2923
2921
  const [currentSuggestions, setCurrentSuggestions] = (0, import_react13.useState)([]);