@copilotkit/react-ui 1.50.0-beta.0 → 1.50.0-beta.10
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 +97 -0
- package/dist/{chunk-SOB5EIL7.mjs → chunk-4APTIMH3.mjs} +2 -2
- package/dist/{chunk-ODEHR7KI.mjs → chunk-7OURDQZJ.mjs} +2 -2
- package/dist/{chunk-GDSZGYCE.mjs → chunk-B4EBCYMS.mjs} +4 -4
- package/dist/{chunk-3JYVJHL5.mjs → chunk-ETQOY3FA.mjs} +8 -8
- package/dist/{chunk-FFJHOZX6.mjs → chunk-FKJWIQGB.mjs} +9 -9
- package/dist/{chunk-E6WVAOQA.mjs → chunk-HIW7RXCD.mjs} +2 -2
- package/dist/{chunk-CQ2WALZ7.mjs → chunk-I2YM5J5H.mjs} +2 -2
- package/dist/{chunk-G35HUUDA.mjs → chunk-LG6H5CG5.mjs} +5 -5
- package/dist/{chunk-MPF6BJUF.mjs → chunk-NCIAFFQ2.mjs} +4 -2
- package/dist/{chunk-MPF6BJUF.mjs.map → chunk-NCIAFFQ2.mjs.map} +1 -1
- package/dist/{chunk-3YWFGNSM.mjs → chunk-RYUCX3ZK.mjs} +1 -1
- package/dist/chunk-RYUCX3ZK.mjs.map +1 -0
- package/dist/{chunk-HBZW7E5Z.mjs → chunk-SABFRQEH.mjs} +6 -6
- package/dist/chunk-SABFRQEH.mjs.map +1 -0
- package/dist/{chunk-OYRZ4VLU.mjs → chunk-Y4FKRAKJ.mjs} +3 -3
- package/dist/{chunk-OYRZ4VLU.mjs.map → chunk-Y4FKRAKJ.mjs.map} +1 -1
- package/dist/components/chat/Chat.js +4 -2
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +8 -8
- package/dist/components/chat/Header.mjs +5 -5
- package/dist/components/chat/Input.js +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 +2 -0
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -5
- package/dist/components/chat/Modal.js +4 -2
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +17 -17
- package/dist/components/chat/Popup.js +4 -2
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +18 -18
- package/dist/components/chat/Sidebar.js +4 -2
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +18 -18
- package/dist/components/chat/index.js +4 -2
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +21 -21
- package/dist/components/chat/messages/AssistantMessage.mjs +1 -1
- package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.js +2 -0
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
- package/dist/components/chat/messages/RenderMessage.d.ts +1 -1
- package/dist/components/chat/messages/RenderMessage.js +2 -0
- package/dist/components/chat/messages/RenderMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderMessage.mjs +3 -3
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.mjs +5 -5
- package/dist/components/index.js +4 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +25 -25
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.js +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
- package/dist/index.css +1 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -26
- package/dist/v2/index.css +4 -0
- package/dist/v2/index.css.map +1 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +2 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +2 -0
- package/dist/v2/index.mjs.map +1 -0
- package/package.json +22 -22
- package/src/components/chat/Input.tsx +2 -2
- package/src/components/chat/messages/RenderMessage.tsx +2 -0
- package/src/components/chat/messages/UserMessage.tsx +12 -10
- package/src/css/messages.css +1 -0
- package/src/hooks/use-copilot-chat-suggestions.tsx +2 -2
- package/src/v2/index.ts +1 -0
- package/src/v2/styles.css +1 -0
- package/tsup.config.ts +1 -1
- package/dist/chunk-3YWFGNSM.mjs.map +0 -1
- package/dist/chunk-HBZW7E5Z.mjs.map +0 -1
- /package/dist/{chunk-SOB5EIL7.mjs.map → chunk-4APTIMH3.mjs.map} +0 -0
- /package/dist/{chunk-ODEHR7KI.mjs.map → chunk-7OURDQZJ.mjs.map} +0 -0
- /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-B4EBCYMS.mjs.map} +0 -0
- /package/dist/{chunk-3JYVJHL5.mjs.map → chunk-ETQOY3FA.mjs.map} +0 -0
- /package/dist/{chunk-FFJHOZX6.mjs.map → chunk-FKJWIQGB.mjs.map} +0 -0
- /package/dist/{chunk-E6WVAOQA.mjs.map → chunk-HIW7RXCD.mjs.map} +0 -0
- /package/dist/{chunk-CQ2WALZ7.mjs.map → chunk-I2YM5J5H.mjs.map} +0 -0
- /package/dist/{chunk-G35HUUDA.mjs.map → chunk-LG6H5CG5.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2,31 +2,19 @@
|
|
|
2
2
|
import "./chunk-EFZPSZWO.mjs";
|
|
3
3
|
import "./chunk-MMVDU6DF.mjs";
|
|
4
4
|
import "./chunk-SC6JRFAJ.mjs";
|
|
5
|
-
import {
|
|
6
|
-
CopilotSidebar
|
|
7
|
-
} from "./chunk-SOB5EIL7.mjs";
|
|
8
5
|
import "./chunk-WB3YULQ4.mjs";
|
|
9
6
|
import {
|
|
10
7
|
CopilotPopup
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-3JYVJHL5.mjs";
|
|
13
|
-
import "./chunk-C3GSYRC3.mjs";
|
|
14
|
-
import "./chunk-GDSZGYCE.mjs";
|
|
15
|
-
import "./chunk-V7W6IM2V.mjs";
|
|
16
|
-
import {
|
|
17
|
-
CopilotDevConsole
|
|
18
|
-
} from "./chunk-FFJHOZX6.mjs";
|
|
19
|
-
import "./chunk-Q5V6S67N.mjs";
|
|
8
|
+
} from "./chunk-I2YM5J5H.mjs";
|
|
20
9
|
import {
|
|
21
|
-
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-BH6PCAAL.mjs";
|
|
10
|
+
CopilotSidebar
|
|
11
|
+
} from "./chunk-4APTIMH3.mjs";
|
|
12
|
+
import "./chunk-ETQOY3FA.mjs";
|
|
13
|
+
import "./chunk-C3GSYRC3.mjs";
|
|
26
14
|
import "./chunk-UFN2VWSR.mjs";
|
|
27
15
|
import {
|
|
28
16
|
CopilotChat
|
|
29
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LG6H5CG5.mjs";
|
|
30
18
|
import {
|
|
31
19
|
Suggestions
|
|
32
20
|
} from "./chunk-QB3GUN2N.mjs";
|
|
@@ -34,12 +22,11 @@ import {
|
|
|
34
22
|
Suggestion
|
|
35
23
|
} from "./chunk-NGJ32FAP.mjs";
|
|
36
24
|
import "./chunk-PLHTVHUW.mjs";
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-ELGRNEAO.mjs";
|
|
25
|
+
import "./chunk-SABFRQEH.mjs";
|
|
39
26
|
import "./chunk-QIOJXTIQ.mjs";
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-
|
|
42
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-HIW7RXCD.mjs";
|
|
28
|
+
import "./chunk-7OURDQZJ.mjs";
|
|
29
|
+
import "./chunk-NCIAFFQ2.mjs";
|
|
43
30
|
import {
|
|
44
31
|
AssistantMessage
|
|
45
32
|
} from "./chunk-IHFR6PYG.mjs";
|
|
@@ -48,20 +35,33 @@ import {
|
|
|
48
35
|
} from "./chunk-DBKRAOH7.mjs";
|
|
49
36
|
import {
|
|
50
37
|
UserMessage
|
|
51
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-RYUCX3ZK.mjs";
|
|
52
39
|
import {
|
|
53
40
|
Markdown
|
|
54
41
|
} from "./chunk-JZ3RFQQ6.mjs";
|
|
42
|
+
import "./chunk-ELGRNEAO.mjs";
|
|
43
|
+
import "./chunk-IK2BPURM.mjs";
|
|
44
|
+
import "./chunk-B4EBCYMS.mjs";
|
|
55
45
|
import {
|
|
56
46
|
useChatContext
|
|
57
47
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
58
|
-
import "./chunk-
|
|
48
|
+
import "./chunk-V7W6IM2V.mjs";
|
|
49
|
+
import {
|
|
50
|
+
CopilotDevConsole
|
|
51
|
+
} from "./chunk-FKJWIQGB.mjs";
|
|
52
|
+
import "./chunk-KXE2JCUH.mjs";
|
|
53
|
+
import "./chunk-NRA3CFEE.mjs";
|
|
54
|
+
import "./chunk-BH6PCAAL.mjs";
|
|
55
|
+
import {
|
|
56
|
+
shouldShowDevConsole
|
|
57
|
+
} from "./chunk-JY2CSDKN.mjs";
|
|
59
58
|
import "./chunk-XWG3L6QC.mjs";
|
|
59
|
+
import "./chunk-Q5V6S67N.mjs";
|
|
60
60
|
import "./chunk-IU3WTXLQ.mjs";
|
|
61
61
|
import "./chunk-T26KLXLH.mjs";
|
|
62
62
|
import {
|
|
63
63
|
useCopilotChatSuggestions
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-Y4FKRAKJ.mjs";
|
|
65
65
|
import "./chunk-54JAUBUJ.mjs";
|
|
66
66
|
import "./chunk-JGMFJZMG.mjs";
|
|
67
67
|
import "./chunk-O72ZB5V3.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/v2/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.50.0-beta.
|
|
12
|
+
"version": "1.50.0-beta.10",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -21,21 +21,12 @@
|
|
|
21
21
|
"require": "./dist/index.js",
|
|
22
22
|
"types": "./dist/index.d.ts"
|
|
23
23
|
},
|
|
24
|
-
"./styles.css": "./dist/index.css"
|
|
24
|
+
"./styles.css": "./dist/index.css",
|
|
25
|
+
"./v2/styles.css": "./dist/v2/index.css"
|
|
25
26
|
},
|
|
26
27
|
"types": "./dist/index.d.ts",
|
|
27
28
|
"license": "MIT",
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "tsup --clean",
|
|
30
|
-
"dev": "tsup --watch --no-splitting",
|
|
31
|
-
"test": "jest",
|
|
32
|
-
"check-types": "tsc --noEmit",
|
|
33
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
34
|
-
"link:global": "pnpm link --global",
|
|
35
|
-
"unlink:global": "pnpm unlink --global"
|
|
36
|
-
},
|
|
37
29
|
"peerDependencies": {
|
|
38
|
-
"@copilotkitnext/core": "0.0.22",
|
|
39
30
|
"react": "^18 || ^19 || ^19.0.0-rc"
|
|
40
31
|
},
|
|
41
32
|
"devDependencies": {
|
|
@@ -43,27 +34,27 @@
|
|
|
43
34
|
"@types/react": "^19.1.0",
|
|
44
35
|
"@types/react-syntax-highlighter": "^15.5.7",
|
|
45
36
|
"eslint": "^8.56.0",
|
|
46
|
-
"eslint-config-custom": "workspace:*",
|
|
47
37
|
"jest": "^29.6.4",
|
|
48
38
|
"postcss": "^8.4.20",
|
|
49
39
|
"react": "^18.2.0",
|
|
50
|
-
"tailwind-config": "workspace:*",
|
|
51
40
|
"tailwindcss": "^3.3.0",
|
|
52
41
|
"ts-jest": "^29.1.1",
|
|
53
|
-
"tsconfig": "workspace:*",
|
|
54
42
|
"tsup": "^6.7.0",
|
|
55
|
-
"typescript": "^5.2.3"
|
|
43
|
+
"typescript": "^5.2.3",
|
|
44
|
+
"eslint-config-custom": "1.4.6",
|
|
45
|
+
"tsconfig": "1.4.6",
|
|
46
|
+
"tailwind-config": "1.4.6"
|
|
56
47
|
},
|
|
57
48
|
"dependencies": {
|
|
58
|
-
"@copilotkit/react-core": "workspace:*",
|
|
59
|
-
"@copilotkit/runtime-client-gql": "workspace:*",
|
|
60
|
-
"@copilotkit/shared": "workspace:*",
|
|
61
49
|
"@headlessui/react": "^2.2.9",
|
|
62
50
|
"react-markdown": "^10.1.0",
|
|
63
51
|
"react-syntax-highlighter": "^15.6.1",
|
|
64
52
|
"rehype-raw": "^7.0.0",
|
|
65
53
|
"remark-gfm": "^4.0.1",
|
|
66
|
-
"remark-math": "^6.0.0"
|
|
54
|
+
"remark-math": "^6.0.0",
|
|
55
|
+
"@copilotkit/react-core": "1.50.0-beta.10",
|
|
56
|
+
"@copilotkit/shared": "1.50.0-beta.10",
|
|
57
|
+
"@copilotkit/runtime-client-gql": "1.50.0-beta.10"
|
|
67
58
|
},
|
|
68
59
|
"keywords": [
|
|
69
60
|
"copilotkit",
|
|
@@ -76,5 +67,14 @@
|
|
|
76
67
|
"javascript",
|
|
77
68
|
"automation",
|
|
78
69
|
"textarea"
|
|
79
|
-
]
|
|
80
|
-
|
|
70
|
+
],
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "tsup --clean",
|
|
73
|
+
"dev": "tsup --watch --no-splitting",
|
|
74
|
+
"test": "jest",
|
|
75
|
+
"check-types": "tsc --noEmit",
|
|
76
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
77
|
+
"link:global": "pnpm link --global",
|
|
78
|
+
"unlink:global": "pnpm unlink --global"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -11,7 +11,7 @@ const MAX_NEWLINES = 6;
|
|
|
11
11
|
export const Input = ({
|
|
12
12
|
inProgress,
|
|
13
13
|
onSend,
|
|
14
|
-
chatReady =
|
|
14
|
+
chatReady = false,
|
|
15
15
|
onStop,
|
|
16
16
|
onUpload,
|
|
17
17
|
hideStopButton = false,
|
|
@@ -73,7 +73,7 @@ export const Input = ({
|
|
|
73
73
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
74
74
|
const { buttonIcon, buttonAlt } = useMemo(() => {
|
|
75
75
|
if (!chatReady) return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
|
|
76
|
-
return isInProgress && !hideStopButton
|
|
76
|
+
return isInProgress && !hideStopButton && chatReady
|
|
77
77
|
? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" }
|
|
78
78
|
: { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
|
|
79
79
|
}, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
|
|
@@ -11,16 +11,18 @@ const getTextContent = (content: UserMessageContent | undefined): string | undef
|
|
|
11
11
|
return content;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
return (
|
|
15
|
+
content
|
|
16
|
+
.map((part) => {
|
|
17
|
+
if (part.type === "text") {
|
|
18
|
+
return part.text;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
})
|
|
22
|
+
.filter((value): value is string => typeof value === "string" && value.length > 0)
|
|
23
|
+
.join(" ")
|
|
24
|
+
.trim() || undefined
|
|
25
|
+
);
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export const UserMessage = (props: UserMessageProps) => {
|
package/src/css/messages.css
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
* removes it on unmount, ensuring a clean and efficient lifecycle management.
|
|
60
60
|
*/
|
|
61
61
|
import {
|
|
62
|
-
|
|
62
|
+
useCopilotChatSuggestions as useCoreCopilotChatSuggestions,
|
|
63
63
|
type UseCopilotChatSuggestionsConfiguration,
|
|
64
64
|
} from "@copilotkit/react-core";
|
|
65
65
|
|
|
@@ -67,5 +67,5 @@ export function useCopilotChatSuggestions(
|
|
|
67
67
|
config: UseCopilotChatSuggestionsConfiguration,
|
|
68
68
|
dependencies: any[] = [],
|
|
69
69
|
) {
|
|
70
|
-
|
|
70
|
+
useCoreCopilotChatSuggestions(config, dependencies);
|
|
71
71
|
}
|
package/src/v2/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./styles.css";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "@copilotkit/react-core/v2/styles.css";
|
package/tsup.config.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/messages/UserMessage.tsx"],"sourcesContent":["import { UserMessageProps } from \"../props\";\n\ntype UserMessageContent = NonNullable<UserMessageProps[\"message\"]>[\"content\"];\n\nconst getTextContent = (content: UserMessageContent | undefined): string | undefined => {\n if (typeof content === \"undefined\") {\n return undefined;\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (part.type === \"text\") {\n return part.text;\n }\n return undefined;\n })\n .filter((value): value is string => typeof value === \"string\" && value.length > 0)\n .join(\" \")\n .trim() || undefined;\n};\n\nexport const UserMessage = (props: UserMessageProps) => {\n const { message, ImageRenderer } = props;\n const isImageMessage = message && \"image\" in message && Boolean(message.image);\n\n if (isImageMessage) {\n const imageMessage = message!;\n const content = getTextContent(imageMessage?.content);\n\n return (\n <div className=\"copilotKitMessage copilotKitUserMessage\">\n <ImageRenderer image={imageMessage.image!} content={content} />\n </div>\n );\n }\n\n const content = getTextContent(message?.content);\n\n return <div className=\"copilotKitMessage copilotKitUserMessage\">{content}</div>;\n};\n"],"mappings":";AAmCQ;AA/BR,IAAM,iBAAiB,CAAC,YAAgE;AACtF,MAAI,OAAO,YAAY,aAAa;AAClC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,EACT;AAEA,SAAO,QACJ,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,SAAS,QAAQ;AACxB,aAAO,KAAK;AAAA,IACd;AACA,WAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,UAA2B,OAAO,UAAU,YAAY,MAAM,SAAS,CAAC,EAChF,KAAK,GAAG,EACR,KAAK,KAAK;AACf;AAEO,IAAM,cAAc,CAAC,UAA4B;AACtD,QAAM,EAAE,SAAS,cAAc,IAAI;AACnC,QAAM,iBAAiB,WAAW,WAAW,WAAW,QAAQ,QAAQ,KAAK;AAE7E,MAAI,gBAAgB;AAClB,UAAM,eAAe;AACrB,UAAMA,WAAU,eAAe,6CAAc,OAAO;AAEpD,WACE,oBAAC,SAAI,WAAU,2CACb,8BAAC,iBAAc,OAAO,aAAa,OAAQ,SAASA,UAAS,GAC/D;AAAA,EAEJ;AAEA,QAAM,UAAU,eAAe,mCAAS,OAAO;AAE/C,SAAO,oBAAC,SAAI,WAAU,2CAA2C,mBAAQ;AAC3E;","names":["content"]}
|
|
@@ -1 +0,0 @@
|
|
|
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, useCopilotChatInternal } from \"@copilotkit/react-core\";\nimport { PoweredByTag } from \"./PoweredByTag\";\n\nconst MAX_NEWLINES = 6;\n\nexport const Input = ({\n inProgress,\n onSend,\n chatReady = true,\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, buttonAlt } = useMemo(() => {\n if (!chatReady) return { buttonIcon: context.icons.spinnerIcon, buttonAlt: \"Loading\" };\n return isInProgress && !hideStopButton\n ? { buttonIcon: context.icons.stopIcon, buttonAlt: \"Stop\" }\n : { buttonIcon: context.icons.sendIcon, buttonAlt: \"Send\" };\n }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);\n const showPushToTalk =\n pushToTalkConfigured &&\n (pushToTalkState === \"idle\" || pushToTalkState === \"recording\") &&\n !inProgress;\n\n const { interrupt } = useCopilotChatInternal();\n\n const canSend = useMemo(() => {\n return !isInProgress && text.trim().length > 0 && pushToTalkState === \"idle\" && !interrupt;\n }, [interrupt, 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 aria-label={buttonAlt}\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"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|