@copilotkit/react-ui 1.9.3-next.2 → 1.9.3-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.
Files changed (47) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +124 -29
  3. package/dist/{chunk-X3LV7OXQ.mjs → chunk-4HUXYD3B.mjs} +6 -3
  4. package/dist/chunk-4HUXYD3B.mjs.map +1 -0
  5. package/dist/{chunk-TSDSBNOS.mjs → chunk-ALIBUJML.mjs} +2 -2
  6. package/dist/{chunk-BP3RN6OE.mjs → chunk-H3EM63WS.mjs} +2 -2
  7. package/dist/{chunk-4RAYX7ZX.mjs → chunk-HKTWKCPS.mjs} +2 -2
  8. package/dist/{chunk-EQUUN7ZM.mjs → chunk-KN2GCKBE.mjs} +3 -3
  9. package/dist/{chunk-YQFVRDNC.mjs → chunk-QIOJXTIQ.mjs} +13 -2
  10. package/dist/chunk-QIOJXTIQ.mjs.map +1 -0
  11. package/dist/components/chat/Chat.js +16 -2
  12. package/dist/components/chat/Chat.js.map +1 -1
  13. package/dist/components/chat/Chat.mjs +3 -3
  14. package/dist/components/chat/Input.js +16 -2
  15. package/dist/components/chat/Input.js.map +1 -1
  16. package/dist/components/chat/Input.mjs +2 -2
  17. package/dist/components/chat/Modal.js +16 -2
  18. package/dist/components/chat/Modal.js.map +1 -1
  19. package/dist/components/chat/Modal.mjs +4 -4
  20. package/dist/components/chat/Popup.js +16 -2
  21. package/dist/components/chat/Popup.js.map +1 -1
  22. package/dist/components/chat/Popup.mjs +5 -5
  23. package/dist/components/chat/Sidebar.js +16 -2
  24. package/dist/components/chat/Sidebar.js.map +1 -1
  25. package/dist/components/chat/Sidebar.mjs +5 -5
  26. package/dist/components/chat/Textarea.d.ts +2 -0
  27. package/dist/components/chat/Textarea.js +12 -1
  28. package/dist/components/chat/Textarea.js.map +1 -1
  29. package/dist/components/chat/Textarea.mjs +1 -1
  30. package/dist/components/chat/index.js +16 -2
  31. package/dist/components/chat/index.js.map +1 -1
  32. package/dist/components/chat/index.mjs +6 -6
  33. package/dist/components/index.js +16 -2
  34. package/dist/components/index.js.map +1 -1
  35. package/dist/components/index.mjs +6 -6
  36. package/dist/index.js +16 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +6 -6
  39. package/package.json +4 -4
  40. package/src/components/chat/Input.tsx +4 -1
  41. package/src/components/chat/Textarea.tsx +17 -1
  42. package/dist/chunk-X3LV7OXQ.mjs.map +0 -1
  43. package/dist/chunk-YQFVRDNC.mjs.map +0 -1
  44. /package/dist/{chunk-TSDSBNOS.mjs.map → chunk-ALIBUJML.mjs.map} +0 -0
  45. /package/dist/{chunk-BP3RN6OE.mjs.map → chunk-H3EM63WS.mjs.map} +0 -0
  46. /package/dist/{chunk-4RAYX7ZX.mjs.map → chunk-HKTWKCPS.mjs.map} +0 -0
  47. /package/dist/{chunk-EQUUN7ZM.mjs.map → chunk-KN2GCKBE.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # ui
2
2
 
3
+ ## 1.9.3-next.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f83bda0]
8
+ - @copilotkit/react-core@1.9.3-next.4
9
+ - @copilotkit/runtime-client-gql@1.9.3-next.4
10
+ - @copilotkit/shared@1.9.3-next.4
11
+
12
+ ## 1.9.3-next.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [1bda332]
17
+ - @copilotkit/shared@1.9.3-next.3
18
+ - @copilotkit/runtime-client-gql@1.9.3-next.3
19
+ - @copilotkit/react-core@1.9.3-next.3
20
+
3
21
  ## 1.9.3-next.2
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -1,46 +1,141 @@
1
- <div align="center">
2
- <a href="https://copilotkit.ai" target="_blank">
3
- <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/banner.png" alt="CopilotKit Logo">
4
- </a>
5
-
6
- <br/>
7
-
8
- <strong>
9
- CopilotKit is the open-source framework for integrating powerful AI Copilots into any application. Easily implement custom AI Chatbots, AI Agents, AI Textareas, and more.
10
- </strong>
11
- </div>
1
+ # CopilotKit - React UI
12
2
 
13
- <br/>
3
+ <img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
14
4
 
15
- <div align="center">
5
+ <br>
6
+ <div align="center" style="display:flex;justify-content:center;gap:16px;height:20px;margin: 0;">
16
7
  <a href="https://www.npmjs.com/package/@copilotkit/react-core" target="_blank">
17
- <img src="https://img.shields.io/npm/v/%40copilotkit%2Freact-core?logo=npm&logoColor=%23FFFFFF&label=Version&color=%236963ff" alt="NPM">
8
+ <img src="https://img.shields.io/npm/v/%40copilotkit%2Freact-ui?logo=npm&logoColor=%23FFFFFF&label=Version&color=%236963ff" alt="NPM">
9
+ </a>
10
+ <a href="https://github.com/copilotkit/copilotkit/blob/main/LICENSE" target="_blank">
11
+ <img src="https://img.shields.io/github/license/copilotkit/copilotkit?color=%236963ff&label=License" alt="MIT">
18
12
  </a>
19
- <img src="https://img.shields.io/github/license/copilotkit/copilotkit?color=%236963ff&label=License" alt="MIT">
20
13
  <a href="https://discord.gg/6dffbvGU3D" target="_blank">
21
14
  <img src="https://img.shields.io/discord/1122926057641742418?logo=discord&logoColor=%23FFFFFF&label=Discord&color=%236963ff" alt="Discord">
22
15
  </a>
23
16
  </div>
24
17
  <br/>
25
-
26
18
  <div align="center">
27
- <a href="https://discord.gg/6dffbvGU3D?ref=github_readme" target="_blank">
28
- <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/btn_discord.png" alt="CopilotKit Discord" height="40px">
29
- </a>
30
- <a href="https://docs.copilotkit.ai?ref=github_readme" target="_blank">
31
- <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/btn_docs.png" alt="CopilotKit GitHub" height="40px">
32
- </a>
33
- <a href="https://cloud.copilotkit.ai?ref=github_readme" target="_blank">
34
- <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/btn_cloud.png" alt="CopilotKit GitHub" height="40px">
19
+ <a href="https://www.producthunt.com/posts/copilotkit" target="_blank">
20
+ <img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=428778&theme=light&period=daily">
35
21
  </a>
36
22
  </div>
37
23
 
38
- <br />
24
+ ## ✨ Why CopilotKit?
39
25
 
40
- <div align="center">
41
- <img src="https://github.com/CopilotKit/CopilotKit/raw/main/assets/animated-banner.gif" alt="CopilotKit Screenshot" style="border-radius: 15px;" />
42
- </div>
26
+ - Minutes to integrate - Get started quickly with our CLI
27
+ - Framework agnostic - Works with React, Next.js, AGUI and more
28
+ - Production-ready UI - Use customizable components or build with headless UI
29
+ - Built-in security - Prompt injection protection
30
+ - Open source - Full transparency and community-driven
31
+
32
+ <img src="https://github.com/user-attachments/assets/6cb425f8-ffcb-49d2-9bbb-87cab5995b78" alt="class-support-ecosystem" style="border-radius: 12px; border: 2px solid #d6d4fa;">
33
+
34
+ ## 🧑‍💻 Real life use cases
35
+
36
+ <span>Deploy deeply-integrated AI assistants & agents that work alongside your users inside your applications.</span>
37
+
38
+ <img src="https://github.com/user-attachments/assets/3b810240-e9f8-43ae-acec-31a58095e223" alt="headless-ui" style="border-radius: 12px; border: 2px solid #d6d4fa;">
39
+
40
+ ## 🖥️ Code Samples
41
+
42
+ <span>Drop in these building blocks and tailor them to your needs.</span>
43
+
44
+ <h3>Build with Headless APIs and Pre-Built Components</h3>
45
+
46
+ ```ts
47
+ // Headless UI with full control
48
+ const { visibleMessages, appendMessage, setMessages, ... } = useCopilotChat();
49
+
50
+ // Pre-built components with deep customization options (CSS + pass custom sub-components)
51
+ <CopilotPopup
52
+ instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
53
+ labels={{ title: "Popup Assistant", initial: "Need any help?" }}
54
+ />
55
+ ```
56
+
57
+ ```ts
58
+ // Frontend actions + generative UI, with full streaming support
59
+ useCopilotAction({
60
+ name: "appendToSpreadsheet",
61
+ description: "Append rows to the current spreadsheet",
62
+ parameters: [
63
+ { name: "rows", type: "object[]", attributes: [{ name: "cells", type: "object[]", attributes: [{ name: "value", type: "string" }] }] }
64
+ ],
65
+ render: ({ status, args }) => <Spreadsheet data={canonicalSpreadsheetData(args.rows)} />,
66
+ handler: ({ rows }) => setSpreadsheet({ ...spreadsheet, rows: [...spreadsheet.rows, ...canonicalSpreadsheetData(rows)] }),
67
+ });
68
+ ```
69
+
70
+ <h3>Integrate In-App CoAgents with LangGraph</h3>
71
+
72
+ ```ts
73
+ // Share state between app and agent
74
+ const { agentState } = useCoAgent({
75
+ name: "basic_agent",
76
+ initialState: { input: "NYC" }
77
+ });
78
+
79
+ // agentic generative UI
80
+ useCoAgentStateRender({
81
+ name: "basic_agent",
82
+ render: ({ state }) => <WeatherDisplay {...state.final_response} />,
83
+ });
84
+
85
+ // Human in the Loop (Approval)
86
+ useCopilotAction({
87
+ name: "email_tool",
88
+ parameters: [
89
+ {
90
+ name: "email_draft",
91
+ type: "string",
92
+ description: "The email content",
93
+ required: true,
94
+ },
95
+ ],
96
+ renderAndWaitForResponse: ({ args, status, respond }) => {
97
+ return (
98
+ <EmailConfirmation
99
+ emailContent={args.email_draft || ""}
100
+ isExecuting={status === "executing"}
101
+ onCancel={() => respond?.({ approved: false })}
102
+ onSend={() =>
103
+ respond?.({
104
+ approved: true,
105
+ metadata: { sentAt: new Date().toISOString() },
106
+ })
107
+ }
108
+ />
109
+ );
110
+ },
111
+ });
112
+ ```
113
+
114
+ ```ts
115
+ // intermediate agent state streaming (supports both LangGraph.js + LangGraph python)
116
+ const modifiedConfig = copilotKitCustomizeConfig(config, {
117
+ emitIntermediateState: [{
118
+ stateKey: "outline",
119
+ tool: "set_outline",
120
+ toolArgument: "outline"
121
+ }],
122
+ });
123
+ const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(messages, modifiedConfig);
124
+ ```
125
+ ## 🏆 Featured Examples
126
+
127
+ <p align="center">
128
+ <a href="https://www.copilotkit.ai/examples/form-filling-copilot">
129
+ <img src="https://github.com/user-attachments/assets/874da84a-67ff-47fa-a6b4-cbc3c65eb704" width="300" style="border-radius: 16px;" />
130
+ </a>
131
+ <a href="https://www.copilotkit.ai/examples/state-machine-copilot">
132
+ <img src="https://github.com/user-attachments/assets/0b5e45b3-2704-4678-82dc-2f3e1c58e2dd" width="300" style="border-radius: 16px;" />
133
+ </a>
134
+ <a href="https://www.copilotkit.ai/examples/chat-with-your-data">
135
+ <img src="https://github.com/user-attachments/assets/0fed66be-a4c2-4093-8eab-75c0b27a62f6" width="300" style="border-radius: 16px;" />
136
+ </a>
137
+ </p>
43
138
 
44
- # Documentation
139
+ ## Documentation
45
140
 
46
141
  To get started with CopilotKit, please check out the [documentation](https://docs.copilotkit.ai).
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-CGEAG65D.mjs";
4
4
  import {
5
5
  Textarea_default
6
- } from "./chunk-YQFVRDNC.mjs";
6
+ } from "./chunk-QIOJXTIQ.mjs";
7
7
  import {
8
8
  useChatContext
9
9
  } from "./chunk-IEMQ2SQW.mjs";
@@ -30,6 +30,7 @@ var Input = ({
30
30
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
31
31
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
32
32
  const textareaRef = useRef(null);
33
+ const [isComposing, setIsComposing] = useState(false);
33
34
  const handleDivClick = (event) => {
34
35
  var _a2;
35
36
  const target = event.target;
@@ -76,8 +77,10 @@ var Input = ({
76
77
  maxRows: MAX_NEWLINES,
77
78
  value: text,
78
79
  onChange: (event) => setText(event.target.value),
80
+ onCompositionStart: () => setIsComposing(true),
81
+ onCompositionEnd: () => setIsComposing(false),
79
82
  onKeyDown: (event) => {
80
- if (event.key === "Enter" && !event.shiftKey) {
83
+ if (event.key === "Enter" && !event.shiftKey && !isComposing) {
81
84
  event.preventDefault();
82
85
  if (canSend) {
83
86
  send();
@@ -117,4 +120,4 @@ var Input = ({
117
120
  export {
118
121
  Input
119
122
  };
120
- //# sourceMappingURL=chunk-X3LV7OXQ.mjs.map
123
+ //# sourceMappingURL=chunk-4HUXYD3B.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Input.tsx"],"sourcesContent":["import React, { useMemo, useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\nimport { usePushToTalk } from \"../../hooks/use-push-to-talk\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { PoweredByTag } from \"./PoweredByTag\";\n\nconst MAX_NEWLINES = 6;\n\nexport const Input = ({\n inProgress,\n onSend,\n isVisible = false,\n onStop,\n onUpload,\n hideStopButton = false,\n}: InputProps) => {\n const context = useChatContext();\n const copilotContext = useCopilotContext();\n\n const showPoweredBy = !copilotContext.copilotApiConfig?.publicApiKey;\n\n const pushToTalkConfigured =\n copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&\n copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [isComposing, setIsComposing] = useState(false);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n\n // If the user clicked a button or inside a button, don't focus the textarea\n if (target.closest(\"button\")) return;\n\n // If the user clicked the textarea, do nothing (it's already focused)\n if (target.tagName === \"TEXTAREA\") return;\n\n // Otherwise, focus the textarea\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n // tylerslaton:\n //\n // This scrolls CopilotKit into view always. Reading the commit history, it was likely\n // added to fix a bug but it is causing issues now.\n //\n // For the future, if we want this behavior again, we will need to find a way to do it without\n // forcing CopilotKit to always be in view. This code causes this because focusing an element\n // in most browsers will scroll that element into view.\n //\n // useEffect(() => {\n // if (isVisible) {\n // textareaRef.current?.focus();\n // }\n // }, [isVisible]);\n\n const { pushToTalkState, setPushToTalkState } = usePushToTalk({\n sendFunction: onSend,\n inProgress,\n });\n\n const isInProgress = inProgress || pushToTalkState === \"transcribing\";\n const buttonIcon =\n isInProgress && !hideStopButton ? context.icons.stopIcon : context.icons.sendIcon;\n const showPushToTalk =\n pushToTalkConfigured &&\n (pushToTalkState === \"idle\" || pushToTalkState === \"recording\") &&\n !inProgress;\n\n const canSend = useMemo(() => {\n const interruptEvent = copilotContext.langGraphInterruptAction?.event;\n const interruptInProgress =\n interruptEvent?.name === \"LangGraphInterruptEvent\" && !interruptEvent?.response;\n\n return (\n !isInProgress && text.trim().length > 0 && pushToTalkState === \"idle\" && !interruptInProgress\n );\n }, [copilotContext.langGraphInterruptAction?.event, isInProgress, text, pushToTalkState]);\n\n const canStop = useMemo(() => {\n return isInProgress && !hideStopButton;\n }, [isInProgress, hideStopButton]);\n\n const sendDisabled = !canSend && !canStop;\n\n return (\n <div className={`copilotKitInputContainer ${showPoweredBy ? \"poweredByContainer\" : \"\"}`}>\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={false}\n maxRows={MAX_NEWLINES}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onCompositionStart={() => setIsComposing(true)}\n onCompositionEnd={() => setIsComposing(false)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey && !isComposing) {\n event.preventDefault();\n if (canSend) {\n send();\n }\n }\n }}\n />\n <div className=\"copilotKitInputControls\">\n {onUpload && (\n <button onClick={onUpload} className=\"copilotKitInputControlButton\">\n {context.icons.uploadIcon}\n </button>\n )}\n\n <div style={{ flexGrow: 1 }} />\n\n {showPushToTalk && (\n <button\n onClick={() =>\n setPushToTalkState(pushToTalkState === \"idle\" ? \"recording\" : \"transcribing\")\n }\n className={\n pushToTalkState === \"recording\"\n ? \"copilotKitInputControlButton copilotKitPushToTalkRecording\"\n : \"copilotKitInputControlButton\"\n }\n >\n {context.icons.pushToTalkIcon}\n </button>\n )}\n <button\n disabled={sendDisabled}\n onClick={isInProgress && !hideStopButton ? onStop : send}\n data-copilotkit-in-progress={inProgress}\n data-test-id={inProgress ? \"copilot-chat-request-in-progress\" : \"copilot-chat-ready\"}\n className=\"copilotKitInputControlButton\"\n >\n {buttonIcon}\n </button>\n </div>\n </div>\n <PoweredByTag showPoweredBy={showPoweredBy} />\n </div>\n );\n};\n"],"mappings":"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","names":["_a"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-EQUUN7ZM.mjs";
3
+ } from "./chunk-KN2GCKBE.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-TSDSBNOS.mjs.map
30
+ //# sourceMappingURL=chunk-ALIBUJML.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-EQUUN7ZM.mjs";
3
+ } from "./chunk-KN2GCKBE.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-BP3RN6OE.mjs.map
21
+ //# sourceMappingURL=chunk-H3EM63WS.mjs.map
@@ -30,7 +30,7 @@ import {
30
30
  } from "./chunk-PLHTVHUW.mjs";
31
31
  import {
32
32
  Input
33
- } from "./chunk-X3LV7OXQ.mjs";
33
+ } from "./chunk-4HUXYD3B.mjs";
34
34
  import {
35
35
  Messages
36
36
  } from "./chunk-B3D7U7TJ.mjs";
@@ -471,4 +471,4 @@ export {
471
471
  WrappedCopilotChat,
472
472
  useCopilotChatLogic
473
473
  };
474
- //# sourceMappingURL=chunk-4RAYX7ZX.mjs.map
474
+ //# sourceMappingURL=chunk-HKTWKCPS.mjs.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-UFN2VWSR.mjs";
10
10
  import {
11
11
  CopilotChat
12
- } from "./chunk-4RAYX7ZX.mjs";
12
+ } from "./chunk-HKTWKCPS.mjs";
13
13
  import {
14
14
  AssistantMessage
15
15
  } from "./chunk-L3GZ7TXC.mjs";
@@ -18,7 +18,7 @@ import {
18
18
  } from "./chunk-HWMFMBJC.mjs";
19
19
  import {
20
20
  Input
21
- } from "./chunk-X3LV7OXQ.mjs";
21
+ } from "./chunk-4HUXYD3B.mjs";
22
22
  import {
23
23
  Messages
24
24
  } from "./chunk-B3D7U7TJ.mjs";
@@ -141,4 +141,4 @@ var CopilotModal = (_a) => {
141
141
  export {
142
142
  CopilotModal
143
143
  };
144
- //# sourceMappingURL=chunk-EQUUN7ZM.mjs.map
144
+ //# sourceMappingURL=chunk-KN2GCKBE.mjs.map
@@ -2,7 +2,16 @@
2
2
  import { useState, useRef, useEffect, forwardRef, useImperativeHandle } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  var AutoResizingTextarea = forwardRef(
5
- ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
5
+ ({
6
+ maxRows = 1,
7
+ placeholder,
8
+ value,
9
+ onChange,
10
+ onKeyDown,
11
+ onCompositionStart,
12
+ onCompositionEnd,
13
+ autoFocus
14
+ }, ref) => {
6
15
  const internalTextareaRef = useRef(null);
7
16
  const [maxHeight, setMaxHeight] = useState(0);
8
17
  useImperativeHandle(ref, () => internalTextareaRef.current);
@@ -34,6 +43,8 @@ var AutoResizingTextarea = forwardRef(
34
43
  value,
35
44
  onChange,
36
45
  onKeyDown,
46
+ onCompositionStart,
47
+ onCompositionEnd,
37
48
  placeholder,
38
49
  style: {
39
50
  overflow: "auto",
@@ -50,4 +61,4 @@ var Textarea_default = AutoResizingTextarea;
50
61
  export {
51
62
  Textarea_default
52
63
  };
53
- //# sourceMappingURL=chunk-YQFVRDNC.mjs.map
64
+ //# sourceMappingURL=chunk-QIOJXTIQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from \"react\";\n\ninterface AutoResizingTextareaProps {\n maxRows?: number;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n onCompositionStart?: () => void;\n onCompositionEnd?: () => void;\n autoFocus?: boolean;\n}\n\nconst AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextareaProps>(\n (\n {\n maxRows = 1,\n placeholder,\n value,\n onChange,\n onKeyDown,\n onCompositionStart,\n onCompositionEnd,\n autoFocus,\n },\n ref,\n ) => {\n const internalTextareaRef = useRef<HTMLTextAreaElement>(null);\n const [maxHeight, setMaxHeight] = useState<number>(0);\n\n useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);\n\n useEffect(() => {\n const calculateMaxHeight = () => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n const singleRowHeight = textarea.scrollHeight;\n setMaxHeight(singleRowHeight * maxRows);\n if (autoFocus) {\n textarea.focus();\n }\n }\n };\n\n calculateMaxHeight();\n }, [maxRows]);\n\n useEffect(() => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;\n }\n }, [value, maxHeight]);\n\n return (\n <textarea\n ref={internalTextareaRef}\n value={value}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n placeholder={placeholder}\n style={{\n overflow: \"auto\",\n resize: \"none\",\n maxHeight: `${maxHeight}px`,\n }}\n rows={1}\n />\n );\n },\n);\n\nexport default AutoResizingTextarea;\n"],"mappings":";AAAA,SAAgB,UAAU,QAAQ,WAAW,YAAY,2BAA2B;AAyD9E;AA5CN,IAAM,uBAAuB;AAAA,EAC3B,CACE;AAAA,IACE,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GACA,QACG;AACH,UAAM,sBAAsB,OAA4B,IAAI;AAC5D,UAAM,CAAC,WAAW,YAAY,IAAI,SAAiB,CAAC;AAEpD,wBAAoB,KAAK,MAAM,oBAAoB,OAA8B;AAEjF,cAAU,MAAM;AACd,YAAM,qBAAqB,MAAM;AAC/B,cAAM,WAAW,oBAAoB;AACrC,YAAI,UAAU;AACZ,mBAAS,MAAM,SAAS;AACxB,gBAAM,kBAAkB,SAAS;AACjC,uBAAa,kBAAkB,OAAO;AACtC,cAAI,WAAW;AACb,qBAAS,MAAM;AAAA,UACjB;AAAA,QACF;AAAA,MACF;AAEA,yBAAmB;AAAA,IACrB,GAAG,CAAC,OAAO,CAAC;AAEZ,cAAU,MAAM;AACd,YAAM,WAAW,oBAAoB;AACrC,UAAI,UAAU;AACZ,iBAAS,MAAM,SAAS;AACxB,iBAAS,MAAM,SAAS,GAAG,KAAK,IAAI,SAAS,cAAc,SAAS;AAAA,MACtE;AAAA,IACF,GAAG,CAAC,OAAO,SAAS,CAAC;AAErB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,WAAW,GAAG;AAAA,QAChB;AAAA,QACA,MAAM;AAAA;AAAA,IACR;AAAA,EAEJ;AACF;AAEA,IAAO,mBAAQ;","names":[]}
@@ -603,7 +603,16 @@ var import_react5 = require("react");
603
603
  var import_react3 = require("react");
604
604
  var import_jsx_runtime4 = require("react/jsx-runtime");
605
605
  var AutoResizingTextarea = (0, import_react3.forwardRef)(
606
- ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
606
+ ({
607
+ maxRows = 1,
608
+ placeholder,
609
+ value,
610
+ onChange,
611
+ onKeyDown,
612
+ onCompositionStart,
613
+ onCompositionEnd,
614
+ autoFocus
615
+ }, ref) => {
607
616
  const internalTextareaRef = (0, import_react3.useRef)(null);
608
617
  const [maxHeight, setMaxHeight] = (0, import_react3.useState)(0);
609
618
  (0, import_react3.useImperativeHandle)(ref, () => internalTextareaRef.current);
@@ -635,6 +644,8 @@ var AutoResizingTextarea = (0, import_react3.forwardRef)(
635
644
  value,
636
645
  onChange,
637
646
  onKeyDown,
647
+ onCompositionStart,
648
+ onCompositionEnd,
638
649
  placeholder,
639
650
  style: {
640
651
  overflow: "auto",
@@ -798,6 +809,7 @@ var Input = ({
798
809
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
799
810
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
800
811
  const textareaRef = (0, import_react5.useRef)(null);
812
+ const [isComposing, setIsComposing] = (0, import_react5.useState)(false);
801
813
  const handleDivClick = (event) => {
802
814
  var _a2;
803
815
  const target = event.target;
@@ -844,8 +856,10 @@ var Input = ({
844
856
  maxRows: MAX_NEWLINES,
845
857
  value: text,
846
858
  onChange: (event) => setText(event.target.value),
859
+ onCompositionStart: () => setIsComposing(true),
860
+ onCompositionEnd: () => setIsComposing(false),
847
861
  onKeyDown: (event) => {
848
- if (event.key === "Enter" && !event.shiftKey) {
862
+ if (event.key === "Enter" && !event.shiftKey && !isComposing) {
849
863
  event.preventDefault();
850
864
  if (canSend) {
851
865
  send();