@copilotkit/react-ui 0.15.0-alpha.0 → 0.15.0-alpha.2
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/.turbo/turbo-build.log +196 -209
- package/CHANGELOG.md +27 -1
- package/dist/chunk-3M4HWSE7.mjs +61 -0
- package/dist/chunk-3M4HWSE7.mjs.map +1 -0
- package/dist/chunk-47SYBLI2.mjs +110 -0
- package/dist/chunk-47SYBLI2.mjs.map +1 -0
- package/dist/chunk-5O2MCJZ2.mjs +21 -0
- package/dist/chunk-5O2MCJZ2.mjs.map +1 -0
- package/dist/chunk-7YXG7D47.mjs +191 -0
- package/dist/chunk-7YXG7D47.mjs.map +1 -0
- package/dist/chunk-CKJXXQ2W.mjs +26 -0
- package/dist/chunk-CKJXXQ2W.mjs.map +1 -0
- package/dist/{chunk-6LAZQHEB.mjs → chunk-DPRH4HX3.mjs} +18 -43
- package/dist/chunk-DPRH4HX3.mjs.map +1 -0
- package/dist/chunk-GWGHQNRI.mjs +54 -0
- package/dist/chunk-GWGHQNRI.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +3 -0
- package/dist/chunk-KBGIPFXA.mjs +14 -0
- package/dist/chunk-KBGIPFXA.mjs.map +1 -0
- package/dist/chunk-NNVWLSYK.mjs +72 -0
- package/dist/chunk-NNVWLSYK.mjs.map +1 -0
- package/dist/chunk-NYLOXKYT.mjs +51 -0
- package/dist/chunk-NYLOXKYT.mjs.map +1 -0
- package/dist/chunk-OF66AL5Z.mjs +56 -0
- package/dist/chunk-OF66AL5Z.mjs.map +1 -0
- package/dist/chunk-P4GBO6MW.mjs +3 -0
- package/dist/chunk-UWPFPWAW.mjs +14 -0
- package/dist/chunk-UWPFPWAW.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +3 -0
- package/dist/chunk-WM6BS77F.mjs +53 -0
- package/dist/chunk-WM6BS77F.mjs.map +1 -0
- package/dist/chunk-Z34F3WLK.mjs +14 -0
- package/dist/chunk-Z34F3WLK.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +6 -0
- package/dist/components/chat/Button.js +38 -0
- package/dist/components/chat/Button.js.map +1 -0
- package/dist/components/chat/Button.mjs +6 -0
- package/dist/components/chat/Chat.d.ts +96 -0
- package/dist/components/chat/Chat.js +800 -0
- package/dist/components/chat/Chat.js.map +1 -0
- package/dist/components/chat/Chat.mjs +16 -0
- package/dist/components/chat/ChatContext.d.ts +105 -0
- package/dist/components/chat/ChatContext.js +220 -0
- package/dist/components/chat/ChatContext.js.map +1 -0
- package/dist/components/chat/ChatContext.mjs +5 -0
- package/dist/components/chat/CodeBlock.js +221 -0
- package/dist/components/chat/CodeBlock.js.map +1 -0
- package/dist/components/chat/CodeBlock.mjs +6 -0
- package/dist/components/chat/Header.d.ts +6 -0
- package/dist/components/chat/Header.js +31 -0
- package/dist/components/chat/Header.js.map +1 -0
- package/dist/components/chat/Header.mjs +6 -0
- package/dist/components/chat/Icons.d.ts +15 -0
- package/dist/components/chat/Icons.js +233 -0
- package/dist/components/chat/Icons.js.map +1 -0
- package/dist/components/chat/Icons.mjs +4 -0
- package/dist/components/chat/Input.d.ts +6 -0
- package/dist/components/chat/Input.js +111 -0
- package/dist/components/chat/Input.js.map +1 -0
- package/dist/components/chat/Input.mjs +7 -0
- package/dist/components/chat/Markdown.d.ts +6 -0
- package/dist/components/chat/Markdown.js +269 -0
- package/dist/components/chat/Markdown.js.map +1 -0
- package/dist/components/chat/Markdown.mjs +7 -0
- package/dist/components/chat/Messages.d.ts +6 -0
- package/dist/components/chat/Messages.js +331 -0
- package/dist/components/chat/Messages.js.map +1 -0
- package/dist/components/chat/Messages.mjs +9 -0
- package/dist/components/chat/Popup.d.ts +10 -0
- package/dist/components/chat/Popup.js +806 -0
- package/dist/components/chat/Popup.js.map +1 -0
- package/dist/components/chat/Popup.mjs +17 -0
- package/dist/components/chat/Response.d.ts +6 -0
- package/dist/components/chat/Response.js +31 -0
- package/dist/components/chat/Response.js.map +1 -0
- package/dist/components/chat/Response.mjs +6 -0
- package/dist/components/chat/Sidebar.d.ts +13 -0
- package/dist/components/chat/Sidebar.js +817 -0
- package/dist/components/chat/Sidebar.js.map +1 -0
- package/dist/components/chat/Sidebar.mjs +17 -0
- package/dist/components/chat/Textarea.d.ts +13 -0
- package/dist/components/chat/Textarea.js +55 -0
- package/dist/components/chat/Textarea.js.map +1 -0
- package/dist/components/chat/Textarea.mjs +4 -0
- package/dist/components/chat/Window.d.ts +6 -0
- package/dist/components/chat/Window.js +116 -0
- package/dist/components/chat/Window.js.map +1 -0
- package/dist/components/chat/Window.mjs +4 -0
- package/dist/components/chat/index.d.ts +8 -0
- package/dist/components/chat/index.js +824 -0
- package/dist/components/chat/index.js.map +1 -0
- package/dist/components/chat/index.mjs +20 -0
- package/dist/components/chat/props.d.ts +33 -0
- package/dist/components/chat/props.js +4 -0
- package/dist/components/chat/props.mjs +3 -0
- package/dist/components/index.d.ts +6 -7
- package/dist/components/index.js +824 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +17 -22
- package/dist/context/index.js +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-copy-to-clipboard.js +47 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/index.css +565 -917
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +824 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +18 -23
- package/dist/lib/utils.js +64 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +38 -2
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +10 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.js +4 -0
- package/dist/types/types.js.map +1 -0
- package/package.json +8 -7
- package/src/components/chat/Button.tsx +23 -0
- package/src/components/chat/Chat.tsx +186 -0
- package/src/components/chat/ChatContext.tsx +176 -0
- package/src/components/{chat-components/ui/codeblock.tsx → chat/CodeBlock.tsx} +21 -33
- package/src/components/chat/Header.tsx +15 -0
- package/src/components/chat/Icons.tsx +179 -0
- package/src/components/chat/Input.tsx +51 -0
- package/src/components/chat/Markdown.tsx +68 -0
- package/src/components/chat/Messages.tsx +113 -0
- package/src/components/chat/Popup.tsx +9 -0
- package/src/components/chat/Response.tsx +12 -0
- package/src/components/chat/Sidebar.tsx +28 -0
- package/src/components/chat/Textarea.tsx +61 -0
- package/src/components/chat/Window.tsx +141 -0
- package/src/components/chat/index.tsx +3 -0
- package/src/components/chat/props.ts +36 -0
- package/src/components/index.ts +1 -7
- package/src/css/animations.css +35 -0
- package/src/css/button.css +54 -0
- package/src/css/colors.css +61 -0
- package/src/css/header.css +43 -0
- package/src/css/input.css +79 -0
- package/src/css/markdown.css +123 -0
- package/src/css/messages.css +57 -0
- package/src/css/popup.css +22 -0
- package/src/css/response.css +29 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/window.css +58 -0
- package/src/styles.css +12 -0
- package/src/types/types.ts +1 -1
- package/tsup.config.ts +1 -2
- package/dist/chunk-2KAF7NKC.mjs +0 -484
- package/dist/chunk-2KAF7NKC.mjs.map +0 -1
- package/dist/chunk-5KEDV5VC.mjs +0 -27
- package/dist/chunk-5KEDV5VC.mjs.map +0 -1
- package/dist/chunk-6LAZQHEB.mjs.map +0 -1
- package/dist/chunk-CF3BK4OX.mjs +0 -53
- package/dist/chunk-CF3BK4OX.mjs.map +0 -1
- package/dist/chunk-CNQX2VY3.mjs +0 -66
- package/dist/chunk-CNQX2VY3.mjs.map +0 -1
- package/dist/chunk-GCOPYGHH.mjs +0 -27
- package/dist/chunk-GCOPYGHH.mjs.map +0 -1
- package/dist/chunk-IJLMKBSZ.mjs +0 -25
- package/dist/chunk-IJLMKBSZ.mjs.map +0 -1
- package/dist/chunk-INCNMGJ7.mjs +0 -72
- package/dist/chunk-INCNMGJ7.mjs.map +0 -1
- package/dist/chunk-M3CZWJI3.mjs +0 -44
- package/dist/chunk-M3CZWJI3.mjs.map +0 -1
- package/dist/chunk-MC6KTH4X.mjs +0 -12
- package/dist/chunk-MC6KTH4X.mjs.map +0 -1
- package/dist/chunk-NMT7XT2R.mjs +0 -39
- package/dist/chunk-NMT7XT2R.mjs.map +0 -1
- package/dist/chunk-OHWEJUCS.mjs +0 -18
- package/dist/chunk-OHWEJUCS.mjs.map +0 -1
- package/dist/chunk-OOBQC5H6.mjs +0 -34
- package/dist/chunk-OOBQC5H6.mjs.map +0 -1
- package/dist/chunk-Q6YO7LDK.mjs +0 -40
- package/dist/chunk-Q6YO7LDK.mjs.map +0 -1
- package/dist/chunk-RPTRCFSO.mjs +0 -42
- package/dist/chunk-RPTRCFSO.mjs.map +0 -1
- package/dist/chunk-SEH5PQVW.mjs +0 -52
- package/dist/chunk-SEH5PQVW.mjs.map +0 -1
- package/dist/chunk-SHOTWRKC.mjs +0 -18
- package/dist/chunk-SHOTWRKC.mjs.map +0 -1
- package/dist/chunk-SRBUGQTM.mjs +0 -109
- package/dist/chunk-SRBUGQTM.mjs.map +0 -1
- package/dist/chunk-TEYIQHMK.mjs +0 -12
- package/dist/chunk-TEYIQHMK.mjs.map +0 -1
- package/dist/chunk-U6NJWGTV.mjs +0 -3
- package/dist/chunk-VGX2W5ZB.mjs +0 -28
- package/dist/chunk-VGX2W5ZB.mjs.map +0 -1
- package/dist/chunk-WLTEQ2FW.mjs +0 -80
- package/dist/chunk-WLTEQ2FW.mjs.map +0 -1
- package/dist/chunk-ZYC5YVDO.mjs +0 -21
- package/dist/chunk-ZYC5YVDO.mjs.map +0 -1
- package/dist/components/chat-components/chat-list.d.ts +0 -8
- package/dist/components/chat-components/chat-list.mjs +0 -13
- package/dist/components/chat-components/chat-message-actions.d.ts +0 -8
- package/dist/components/chat-components/chat-message-actions.mjs +0 -8
- package/dist/components/chat-components/chat-message.d.ts +0 -8
- package/dist/components/chat-components/chat-message.mjs +0 -11
- package/dist/components/chat-components/chat-panel.d.ts +0 -8
- package/dist/components/chat-components/chat-panel.mjs +0 -10
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +0 -6
- package/dist/components/chat-components/chat-scroll-anchor.mjs +0 -5
- package/dist/components/chat-components/clear-history.d.ts +0 -9
- package/dist/components/chat-components/clear-history.mjs +0 -56
- package/dist/components/chat-components/clear-history.mjs.map +0 -1
- package/dist/components/chat-components/copilot-chat.d.ts +0 -12
- package/dist/components/chat-components/copilot-chat.mjs +0 -22
- package/dist/components/chat-components/default-empty-screen.d.ts +0 -8
- package/dist/components/chat-components/default-empty-screen.mjs +0 -8
- package/dist/components/chat-components/external-link.d.ts +0 -6
- package/dist/components/chat-components/external-link.mjs +0 -4
- package/dist/components/chat-components/markdown.d.ts +0 -6
- package/dist/components/chat-components/markdown.mjs +0 -4
- package/dist/components/chat-components/prompt-form.d.ts +0 -9
- package/dist/components/chat-components/prompt-form.mjs +0 -9
- package/dist/components/chat-components/theme-toggle.d.ts +0 -3
- package/dist/components/chat-components/theme-toggle.mjs +0 -32
- package/dist/components/chat-components/theme-toggle.mjs.map +0 -1
- package/dist/components/chat-components/toaster.d.ts +0 -1
- package/dist/components/chat-components/toaster.mjs +0 -4
- package/dist/components/chat-components/toaster.mjs.map +0 -1
- package/dist/components/chat-components/ui/alert-dialog.d.ts +0 -20
- package/dist/components/chat-components/ui/alert-dialog.mjs +0 -6
- package/dist/components/chat-components/ui/badge.d.ts +0 -12
- package/dist/components/chat-components/ui/badge.mjs +0 -29
- package/dist/components/chat-components/ui/badge.mjs.map +0 -1
- package/dist/components/chat-components/ui/button.d.ts +0 -14
- package/dist/components/chat-components/ui/button.mjs +0 -5
- package/dist/components/chat-components/ui/codeblock.mjs +0 -8
- package/dist/components/chat-components/ui/dialog.d.ts +0 -18
- package/dist/components/chat-components/ui/dialog.mjs +0 -94
- package/dist/components/chat-components/ui/dialog.mjs.map +0 -1
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +0 -24
- package/dist/components/chat-components/ui/dropdown-menu.mjs +0 -87
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +0 -1
- package/dist/components/chat-components/ui/icons.d.ts +0 -33
- package/dist/components/chat-components/ui/icons.mjs +0 -5
- package/dist/components/chat-components/ui/input.d.ts +0 -7
- package/dist/components/chat-components/ui/input.mjs +0 -26
- package/dist/components/chat-components/ui/input.mjs.map +0 -1
- package/dist/components/chat-components/ui/label.d.ts +0 -8
- package/dist/components/chat-components/ui/label.mjs +0 -19
- package/dist/components/chat-components/ui/label.mjs.map +0 -1
- package/dist/components/chat-components/ui/select.d.ts +0 -13
- package/dist/components/chat-components/ui/select.mjs +0 -101
- package/dist/components/chat-components/ui/select.mjs.map +0 -1
- package/dist/components/chat-components/ui/separator.d.ts +0 -6
- package/dist/components/chat-components/ui/separator.mjs +0 -5
- package/dist/components/chat-components/ui/sheet.d.ts +0 -19
- package/dist/components/chat-components/ui/sheet.mjs +0 -93
- package/dist/components/chat-components/ui/sheet.mjs.map +0 -1
- package/dist/components/chat-components/ui/switch.d.ts +0 -6
- package/dist/components/chat-components/ui/switch.mjs +0 -33
- package/dist/components/chat-components/ui/switch.mjs.map +0 -1
- package/dist/components/chat-components/ui/textarea.d.ts +0 -7
- package/dist/components/chat-components/ui/textarea.mjs +0 -25
- package/dist/components/chat-components/ui/textarea.mjs.map +0 -1
- package/dist/components/chat-components/ui/tooltip.d.ts +0 -9
- package/dist/components/chat-components/ui/tooltip.mjs +0 -5
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +0 -9
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +0 -25
- package/dist/components/sidebar/copilot-sidebar.d.ts +0 -7
- package/dist/components/sidebar/copilot-sidebar.mjs +0 -23
- package/dist/components/sidebar/sidebar-context.d.ts +0 -9
- package/dist/components/sidebar/sidebar-context.mjs +0 -4
- package/dist/hooks/use-at-bottom.d.ts +0 -3
- package/dist/hooks/use-at-bottom.mjs +0 -4
- package/dist/hooks/use-enter-submit.d.ts +0 -8
- package/dist/hooks/use-enter-submit.mjs +0 -4
- package/src/components/chat-components/chat-list.tsx +0 -28
- package/src/components/chat-components/chat-message-actions.tsx +0 -36
- package/src/components/chat-components/chat-message.tsx +0 -70
- package/src/components/chat-components/chat-panel.tsx +0 -64
- package/src/components/chat-components/chat-scroll-anchor.tsx +0 -29
- package/src/components/chat-components/clear-history.tsx +0 -72
- package/src/components/chat-components/copilot-chat.tsx +0 -57
- package/src/components/chat-components/default-empty-screen.tsx +0 -57
- package/src/components/chat-components/external-link.tsx +0 -17
- package/src/components/chat-components/markdown.tsx +0 -8
- package/src/components/chat-components/prompt-form.tsx +0 -85
- package/src/components/chat-components/theme-toggle.tsx +0 -31
- package/src/components/chat-components/toaster.tsx +0 -3
- package/src/components/chat-components/ui/alert-dialog.tsx +0 -126
- package/src/components/chat-components/ui/badge.tsx +0 -33
- package/src/components/chat-components/ui/button.tsx +0 -49
- package/src/components/chat-components/ui/dialog.tsx +0 -106
- package/src/components/chat-components/ui/dropdown-menu.tsx +0 -117
- package/src/components/chat-components/ui/icons.tsx +0 -484
- package/src/components/chat-components/ui/input.tsx +0 -24
- package/src/components/chat-components/ui/label.tsx +0 -21
- package/src/components/chat-components/ui/select.tsx +0 -119
- package/src/components/chat-components/ui/separator.tsx +0 -26
- package/src/components/chat-components/ui/sheet.tsx +0 -106
- package/src/components/chat-components/ui/switch.tsx +0 -29
- package/src/components/chat-components/ui/textarea.tsx +0 -23
- package/src/components/chat-components/ui/tooltip.tsx +0 -30
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +0 -77
- package/src/components/sidebar/copilot-sidebar.tsx +0 -39
- package/src/components/sidebar/sidebar-context.tsx +0 -11
- package/src/hooks/use-at-bottom.tsx +0 -20
- package/src/hooks/use-enter-submit.tsx +0 -17
- /package/dist/{chunk-U6NJWGTV.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
- /package/dist/{components/chat-components/chat-list.mjs.map → chunk-P4GBO6MW.mjs.map} +0 -0
- /package/dist/{components/chat-components/chat-message-actions.mjs.map → chunk-WB3YULQ4.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-message.mjs.map → chat/Button.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-panel.mjs.map → chat/Chat.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-scroll-anchor.mjs.map → chat/ChatContext.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/codeblock.d.ts → chat/CodeBlock.d.ts} +0 -0
- /package/dist/components/{chat-components/copilot-chat.mjs.map → chat/CodeBlock.mjs.map} +0 -0
- /package/dist/components/{chat-components/default-empty-screen.mjs.map → chat/Header.mjs.map} +0 -0
- /package/dist/components/{chat-components/external-link.mjs.map → chat/Icons.mjs.map} +0 -0
- /package/dist/components/{chat-components/markdown.mjs.map → chat/Input.mjs.map} +0 -0
- /package/dist/components/{chat-components/prompt-form.mjs.map → chat/Markdown.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/alert-dialog.mjs.map → chat/Messages.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/button.mjs.map → chat/Popup.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/codeblock.mjs.map → chat/Response.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/icons.mjs.map → chat/Sidebar.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/separator.mjs.map → chat/Textarea.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/tooltip.mjs.map → chat/Window.mjs.map} +0 -0
- /package/dist/components/{sidebar/copilot-sidebar-ui-provider.mjs.map → chat/index.mjs.map} +0 -0
- /package/dist/components/{sidebar/copilot-sidebar.mjs.map → chat/props.js.map} +0 -0
- /package/dist/components/{sidebar/sidebar-context.mjs.map → chat/props.mjs.map} +0 -0
- /package/dist/{hooks/use-at-bottom.mjs.map → context/index.js.map} +0 -0
- /package/dist/hooks/{use-enter-submit.mjs.map → index.js.map} +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type UseChatHelpers } from "@copilotkit/react-core";
|
|
2
|
-
|
|
3
|
-
import { Button } from "./ui/button";
|
|
4
|
-
import { PromptForm } from "./prompt-form";
|
|
5
|
-
import { IconRefresh, IconStop } from "./ui/icons";
|
|
6
|
-
import { nanoid } from "nanoid";
|
|
7
|
-
|
|
8
|
-
export interface ChatPanelProps
|
|
9
|
-
extends Pick<
|
|
10
|
-
UseChatHelpers,
|
|
11
|
-
"append" | "isLoading" | "reload" | "messages" | "stop" | "input" | "setInput"
|
|
12
|
-
> {
|
|
13
|
-
id?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function ChatPanel({
|
|
17
|
-
id,
|
|
18
|
-
isLoading,
|
|
19
|
-
stop,
|
|
20
|
-
append,
|
|
21
|
-
reload,
|
|
22
|
-
input,
|
|
23
|
-
setInput,
|
|
24
|
-
messages,
|
|
25
|
-
}: ChatPanelProps) {
|
|
26
|
-
return (
|
|
27
|
-
<div
|
|
28
|
-
className="inset-x-0 bottom-0 bg-gradient-to-b from-muted/10 from-10% to-muted/30 to-50% mt-4 mb-8"
|
|
29
|
-
style={{ width: "100%", overflow: "hidden", boxSizing: "border-box" }}
|
|
30
|
-
>
|
|
31
|
-
<div className="mx-auto sm:max-w-2xl sm:px-4">
|
|
32
|
-
<div className="flex h-10 items-center justify-center mb-4">
|
|
33
|
-
{isLoading ? (
|
|
34
|
-
<Button variant="outline" onClick={() => stop()} className="bg-background">
|
|
35
|
-
<IconStop className="mr-2" />
|
|
36
|
-
Stop generating
|
|
37
|
-
</Button>
|
|
38
|
-
) : (
|
|
39
|
-
messages?.length > 0 && (
|
|
40
|
-
<Button variant="outline" onClick={() => reload()} className="bg-background">
|
|
41
|
-
<IconRefresh className="mr-2" />
|
|
42
|
-
Regenerate response
|
|
43
|
-
</Button>
|
|
44
|
-
)
|
|
45
|
-
)}
|
|
46
|
-
</div>
|
|
47
|
-
<div className="space-y-4 border-2 bg-background px-4 py-2 shadow-lg sm:rounded-xl md:py-4">
|
|
48
|
-
<PromptForm
|
|
49
|
-
onSubmit={async (value) => {
|
|
50
|
-
await append({
|
|
51
|
-
id: id || nanoid(),
|
|
52
|
-
content: value,
|
|
53
|
-
role: "user",
|
|
54
|
-
});
|
|
55
|
-
}}
|
|
56
|
-
input={input}
|
|
57
|
-
setInput={setInput}
|
|
58
|
-
isLoading={isLoading}
|
|
59
|
-
/>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { useInView } from "react-intersection-observer";
|
|
5
|
-
|
|
6
|
-
import { useAtBottom } from "../../hooks/use-at-bottom";
|
|
7
|
-
|
|
8
|
-
interface ChatScrollAnchorProps {
|
|
9
|
-
trackVisibility?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function ChatScrollAnchor({ trackVisibility }: ChatScrollAnchorProps) {
|
|
13
|
-
const isAtBottom = useAtBottom();
|
|
14
|
-
const { ref, entry, inView } = useInView({
|
|
15
|
-
trackVisibility,
|
|
16
|
-
delay: 100,
|
|
17
|
-
rootMargin: "0px 0px -150px 0px",
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
if (isAtBottom && trackVisibility && !inView) {
|
|
22
|
-
entry?.target.scrollIntoView({
|
|
23
|
-
block: "start",
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}, [inView, entry, isAtBottom, trackVisibility]);
|
|
27
|
-
|
|
28
|
-
return <div ref={ref} className="h-px w-full" />;
|
|
29
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { useRouter } from "next/navigation";
|
|
5
|
-
import { toast } from "react-hot-toast";
|
|
6
|
-
|
|
7
|
-
import { ServerActionResult } from "../../types/types";
|
|
8
|
-
import { Button } from "./ui/button";
|
|
9
|
-
import {
|
|
10
|
-
AlertDialog,
|
|
11
|
-
AlertDialogAction,
|
|
12
|
-
AlertDialogCancel,
|
|
13
|
-
AlertDialogContent,
|
|
14
|
-
AlertDialogDescription,
|
|
15
|
-
AlertDialogFooter,
|
|
16
|
-
AlertDialogHeader,
|
|
17
|
-
AlertDialogTitle,
|
|
18
|
-
AlertDialogTrigger,
|
|
19
|
-
} from "./ui/alert-dialog";
|
|
20
|
-
import { IconSpinner } from "./ui/icons";
|
|
21
|
-
|
|
22
|
-
interface ClearHistoryProps {
|
|
23
|
-
clearChats: () => ServerActionResult<void>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function ClearHistory({ clearChats }: ClearHistoryProps) {
|
|
27
|
-
const [open, setOpen] = React.useState(false);
|
|
28
|
-
const [isPending, startTransition] = React.useTransition();
|
|
29
|
-
const router = useRouter();
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<AlertDialog open={open} onOpenChange={setOpen}>
|
|
33
|
-
<AlertDialogTrigger asChild>
|
|
34
|
-
<Button variant="ghost" disabled={isPending}>
|
|
35
|
-
{isPending && <IconSpinner className="mr-2" />}
|
|
36
|
-
Clear history
|
|
37
|
-
</Button>
|
|
38
|
-
</AlertDialogTrigger>
|
|
39
|
-
<AlertDialogContent>
|
|
40
|
-
<AlertDialogHeader>
|
|
41
|
-
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
|
42
|
-
<AlertDialogDescription>
|
|
43
|
-
This will permanently delete your chat history and remove your data from our servers.
|
|
44
|
-
</AlertDialogDescription>
|
|
45
|
-
</AlertDialogHeader>
|
|
46
|
-
<AlertDialogFooter>
|
|
47
|
-
<AlertDialogCancel disabled={isPending}>Cancel</AlertDialogCancel>
|
|
48
|
-
<AlertDialogAction
|
|
49
|
-
disabled={isPending}
|
|
50
|
-
onClick={(event: any) => {
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
startTransition(async () => {
|
|
53
|
-
const result = await clearChats();
|
|
54
|
-
|
|
55
|
-
if (result && "error" in result) {
|
|
56
|
-
toast.error(result.error);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
setOpen(false);
|
|
61
|
-
router.push("/");
|
|
62
|
-
});
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
{isPending && <IconSpinner className="mr-2 animate-spin" />}
|
|
66
|
-
Delete
|
|
67
|
-
</AlertDialogAction>
|
|
68
|
-
</AlertDialogFooter>
|
|
69
|
-
</AlertDialogContent>
|
|
70
|
-
</AlertDialog>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
|
|
5
|
-
import { ChatList } from "./chat-list";
|
|
6
|
-
import { ChatPanel } from "./chat-panel";
|
|
7
|
-
import { DefaultEmptyScreen, EmptyScreenProps } from "./default-empty-screen";
|
|
8
|
-
import { ChatScrollAnchor } from "./chat-scroll-anchor";
|
|
9
|
-
import { UseCopilotChatOptions } from "@copilotkit/react-core";
|
|
10
|
-
import { useCopilotChat } from "@copilotkit/react-core";
|
|
11
|
-
|
|
12
|
-
interface ChatComponentInjectionsProps {
|
|
13
|
-
EmptyScreen?: React.FC<EmptyScreenProps>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface CopilotChatProps extends UseCopilotChatOptions, ChatComponentInjectionsProps {}
|
|
17
|
-
|
|
18
|
-
export function CopilotChat({
|
|
19
|
-
id,
|
|
20
|
-
initialMessages,
|
|
21
|
-
makeSystemMessage,
|
|
22
|
-
EmptyScreen = DefaultEmptyScreen,
|
|
23
|
-
}: CopilotChatProps) {
|
|
24
|
-
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({
|
|
25
|
-
id,
|
|
26
|
-
initialMessages,
|
|
27
|
-
makeSystemMessage,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="w-full h-full flex flex-col overflow-hidden box-border items-start">
|
|
32
|
-
<div className="pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow">
|
|
33
|
-
{visibleMessages.length ? (
|
|
34
|
-
<div className="pl-0 pr-6">
|
|
35
|
-
<ChatList messages={visibleMessages} />
|
|
36
|
-
<ChatScrollAnchor trackVisibility={isLoading} />
|
|
37
|
-
</div>
|
|
38
|
-
) : (
|
|
39
|
-
<EmptyScreen setInput={setInput} />
|
|
40
|
-
)}
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<div className="flex-shrink-0 w-full">
|
|
44
|
-
<ChatPanel
|
|
45
|
-
id={id}
|
|
46
|
-
isLoading={isLoading}
|
|
47
|
-
stop={stop}
|
|
48
|
-
append={append}
|
|
49
|
-
reload={reload}
|
|
50
|
-
messages={visibleMessages}
|
|
51
|
-
input={input}
|
|
52
|
-
setInput={setInput}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
import { Button } from "./ui/button";
|
|
5
|
-
import { ExternalLink } from "./external-link";
|
|
6
|
-
import { IconArrowRight } from "./ui/icons";
|
|
7
|
-
|
|
8
|
-
const exampleMessages = [
|
|
9
|
-
{
|
|
10
|
-
heading: "Explain technical concepts",
|
|
11
|
-
message: `What is a "serverless function"?`,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
heading: "Summarize an article",
|
|
15
|
-
message: "Summarize the following article for a 2nd grader: \n",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
heading: "Draft an email",
|
|
19
|
-
message: `Draft an email to my boss about the following: \n`,
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
export interface EmptyScreenProps {
|
|
24
|
-
setInput: React.Dispatch<React.SetStateAction<string>>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = (props) => {
|
|
28
|
-
return (
|
|
29
|
-
<div className="mx-auto max-w-2xl px-4">
|
|
30
|
-
<div className="rounded-lg border bg-background p-8">
|
|
31
|
-
<h1 className="mb-2 text-lg font-semibold">Welcome to CopilotKit! 👋</h1>
|
|
32
|
-
<p className="mb-2 leading-normal text-muted-foreground">
|
|
33
|
-
This is a Copilot built with{" "}
|
|
34
|
-
<ExternalLink href="https://recursively.ai">recursively.ai's</ExternalLink>{" "}
|
|
35
|
-
<ExternalLink href="https://github.com/RecursivelyAI/CopilotKit">CopilotKit</ExternalLink>{" "}
|
|
36
|
-
.
|
|
37
|
-
</p>
|
|
38
|
-
<p className="leading-normal text-muted-foreground">
|
|
39
|
-
You can start a conversation here or try the following examples:
|
|
40
|
-
</p>
|
|
41
|
-
<div className="mt-4 flex flex-col items-start space-y-2">
|
|
42
|
-
{exampleMessages.map((message, index) => (
|
|
43
|
-
<Button
|
|
44
|
-
key={index}
|
|
45
|
-
variant="link"
|
|
46
|
-
className="h-auto p-0 text-base"
|
|
47
|
-
onClick={() => props.setInput(message.message)}
|
|
48
|
-
>
|
|
49
|
-
<IconArrowRight className="mr-2 text-muted-foreground" />
|
|
50
|
-
{message.heading}
|
|
51
|
-
</Button>
|
|
52
|
-
))}
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function ExternalLink({ href, children }: { href: string; children: React.ReactNode }) {
|
|
2
|
-
return (
|
|
3
|
-
<a
|
|
4
|
-
href={href}
|
|
5
|
-
target="_blank"
|
|
6
|
-
className="inline-flex flex-1 justify-center gap-1 leading-4 hover:underline"
|
|
7
|
-
>
|
|
8
|
-
<span>{children}</span>
|
|
9
|
-
<svg aria-hidden="true" height="7" viewBox="0 0 6 6" width="7" className="opacity-70">
|
|
10
|
-
<path
|
|
11
|
-
d="M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z"
|
|
12
|
-
fill="currentColor"
|
|
13
|
-
></path>
|
|
14
|
-
</svg>
|
|
15
|
-
</a>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FC, memo } from "react";
|
|
2
|
-
import ReactMarkdown, { Options } from "react-markdown";
|
|
3
|
-
|
|
4
|
-
export const MemoizedReactMarkdown: FC<Options> = memo(
|
|
5
|
-
ReactMarkdown,
|
|
6
|
-
(prevProps, nextProps) =>
|
|
7
|
-
prevProps.children === nextProps.children && prevProps.className === nextProps.className,
|
|
8
|
-
);
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import TextareaAutosize from "react-textarea-autosize";
|
|
3
|
-
import { UseChatHelpers } from "@copilotkit/react-core";
|
|
4
|
-
|
|
5
|
-
import { useEnterSubmit } from "../../hooks/use-enter-submit";
|
|
6
|
-
import { cn } from "../../lib/utils";
|
|
7
|
-
import { Button, buttonVariants } from "./ui/button";
|
|
8
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
|
9
|
-
import { IconArrowElbow, IconPlus } from "./ui/icons";
|
|
10
|
-
// import Link from "next/link";
|
|
11
|
-
|
|
12
|
-
export interface PromptProps extends Pick<UseChatHelpers, "input" | "setInput"> {
|
|
13
|
-
onSubmit: (value: string) => Promise<void>;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function PromptForm({ onSubmit, input, setInput, isLoading }: PromptProps) {
|
|
18
|
-
const { formRef, onKeyDown } = useEnterSubmit();
|
|
19
|
-
const inputRef = React.useRef<HTMLTextAreaElement>(null);
|
|
20
|
-
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
if (inputRef.current) {
|
|
23
|
-
inputRef.current.focus();
|
|
24
|
-
}
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<form
|
|
29
|
-
onSubmit={async (e) => {
|
|
30
|
-
e.preventDefault();
|
|
31
|
-
if (!input?.trim()) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
setInput("");
|
|
35
|
-
await onSubmit(input);
|
|
36
|
-
}}
|
|
37
|
-
ref={formRef}
|
|
38
|
-
>
|
|
39
|
-
<div className="relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md border sm:px-12">
|
|
40
|
-
<Tooltip>
|
|
41
|
-
<TooltipTrigger asChild>
|
|
42
|
-
{/* <Link
|
|
43
|
-
href="/"
|
|
44
|
-
className={cn(
|
|
45
|
-
buttonVariants({ size: "sm", variant: "outline" }),
|
|
46
|
-
"absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4"
|
|
47
|
-
)}
|
|
48
|
-
>
|
|
49
|
-
<IconPlus />
|
|
50
|
-
<span className="sr-only">New Chat</span>
|
|
51
|
-
</Link> */}
|
|
52
|
-
</TooltipTrigger>
|
|
53
|
-
<TooltipContent>New Chat</TooltipContent>
|
|
54
|
-
</Tooltip>
|
|
55
|
-
<TextareaAutosize
|
|
56
|
-
ref={inputRef}
|
|
57
|
-
tabIndex={0}
|
|
58
|
-
onKeyDown={onKeyDown}
|
|
59
|
-
rows={1}
|
|
60
|
-
value={input}
|
|
61
|
-
onChange={(e) => setInput(e.target.value)}
|
|
62
|
-
placeholder="Send a message."
|
|
63
|
-
spellCheck={false}
|
|
64
|
-
className="min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"
|
|
65
|
-
/>
|
|
66
|
-
<div className="absolute right-0 top-4 sm:right-4">
|
|
67
|
-
<Tooltip>
|
|
68
|
-
<TooltipTrigger asChild>
|
|
69
|
-
<Button
|
|
70
|
-
type="submit"
|
|
71
|
-
size="icon"
|
|
72
|
-
disabled={isLoading || input === ""}
|
|
73
|
-
className=" bg-slate-300"
|
|
74
|
-
>
|
|
75
|
-
<IconArrowElbow />
|
|
76
|
-
<span className="sr-only">Send message</span>
|
|
77
|
-
</Button>
|
|
78
|
-
</TooltipTrigger>
|
|
79
|
-
<TooltipContent>Send message</TooltipContent>
|
|
80
|
-
</Tooltip>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
</form>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { useTheme } from "next-themes";
|
|
5
|
-
|
|
6
|
-
import { Button } from "./ui/button";
|
|
7
|
-
import { IconMoon, IconSun } from "./ui/icons";
|
|
8
|
-
|
|
9
|
-
export function ThemeToggle() {
|
|
10
|
-
const { setTheme, theme } = useTheme();
|
|
11
|
-
const [_, startTransition] = React.useTransition();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Button
|
|
15
|
-
variant="ghost"
|
|
16
|
-
size="icon"
|
|
17
|
-
onClick={() => {
|
|
18
|
-
startTransition(() => {
|
|
19
|
-
setTheme(theme === "light" ? "dark" : "light");
|
|
20
|
-
});
|
|
21
|
-
}}
|
|
22
|
-
>
|
|
23
|
-
{!theme ? null : theme === "dark" ? (
|
|
24
|
-
<IconMoon className="transition-all" />
|
|
25
|
-
) : (
|
|
26
|
-
<IconSun className="transition-all" />
|
|
27
|
-
)}
|
|
28
|
-
<span className="sr-only">Toggle theme</span>
|
|
29
|
-
</Button>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
5
|
-
|
|
6
|
-
import { cn } from "../../../lib/utils";
|
|
7
|
-
import { buttonVariants } from "./button";
|
|
8
|
-
|
|
9
|
-
const AlertDialog = AlertDialogPrimitive.Root;
|
|
10
|
-
|
|
11
|
-
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
12
|
-
|
|
13
|
-
const AlertDialogPortal = ({
|
|
14
|
-
className,
|
|
15
|
-
children,
|
|
16
|
-
...props
|
|
17
|
-
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
|
|
18
|
-
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
|
|
19
|
-
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
|
|
20
|
-
{children}
|
|
21
|
-
</div>
|
|
22
|
-
</AlertDialogPrimitive.Portal>
|
|
23
|
-
);
|
|
24
|
-
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName;
|
|
25
|
-
|
|
26
|
-
const AlertDialogOverlay = React.forwardRef<
|
|
27
|
-
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
28
|
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
29
|
-
>(({ className, children, ...props }, ref) => (
|
|
30
|
-
<AlertDialogPrimitive.Overlay
|
|
31
|
-
className={cn(
|
|
32
|
-
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in",
|
|
33
|
-
className,
|
|
34
|
-
)}
|
|
35
|
-
{...props}
|
|
36
|
-
ref={ref}
|
|
37
|
-
/>
|
|
38
|
-
));
|
|
39
|
-
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
40
|
-
|
|
41
|
-
const AlertDialogContent = React.forwardRef<
|
|
42
|
-
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
43
|
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
44
|
-
>(({ className, ...props }, ref) => (
|
|
45
|
-
<AlertDialogPortal>
|
|
46
|
-
<AlertDialogOverlay />
|
|
47
|
-
<AlertDialogPrimitive.Content
|
|
48
|
-
ref={ref}
|
|
49
|
-
className={cn(
|
|
50
|
-
"fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full",
|
|
51
|
-
className,
|
|
52
|
-
)}
|
|
53
|
-
{...props}
|
|
54
|
-
/>
|
|
55
|
-
</AlertDialogPortal>
|
|
56
|
-
));
|
|
57
|
-
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
58
|
-
|
|
59
|
-
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
-
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
|
61
|
-
);
|
|
62
|
-
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
63
|
-
|
|
64
|
-
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
65
|
-
<div
|
|
66
|
-
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
|
|
67
|
-
{...props}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
71
|
-
|
|
72
|
-
const AlertDialogTitle = React.forwardRef<
|
|
73
|
-
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
74
|
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
75
|
-
>(({ className, ...props }, ref) => (
|
|
76
|
-
<AlertDialogPrimitive.Title
|
|
77
|
-
ref={ref}
|
|
78
|
-
className={cn("text-lg font-semibold", className)}
|
|
79
|
-
{...props}
|
|
80
|
-
/>
|
|
81
|
-
));
|
|
82
|
-
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
83
|
-
|
|
84
|
-
const AlertDialogDescription = React.forwardRef<
|
|
85
|
-
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
86
|
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
87
|
-
>(({ className, ...props }, ref) => (
|
|
88
|
-
<AlertDialogPrimitive.Description
|
|
89
|
-
ref={ref}
|
|
90
|
-
className={cn("text-sm text-muted-foreground", className)}
|
|
91
|
-
{...props}
|
|
92
|
-
/>
|
|
93
|
-
));
|
|
94
|
-
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
95
|
-
|
|
96
|
-
const AlertDialogAction = React.forwardRef<
|
|
97
|
-
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
98
|
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
99
|
-
>(({ className, ...props }, ref) => (
|
|
100
|
-
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
|
101
|
-
));
|
|
102
|
-
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
103
|
-
|
|
104
|
-
const AlertDialogCancel = React.forwardRef<
|
|
105
|
-
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
106
|
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
107
|
-
>(({ className, ...props }, ref) => (
|
|
108
|
-
<AlertDialogPrimitive.Cancel
|
|
109
|
-
ref={ref}
|
|
110
|
-
className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)}
|
|
111
|
-
{...props}
|
|
112
|
-
/>
|
|
113
|
-
));
|
|
114
|
-
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
115
|
-
|
|
116
|
-
export {
|
|
117
|
-
AlertDialog,
|
|
118
|
-
AlertDialogTrigger,
|
|
119
|
-
AlertDialogContent,
|
|
120
|
-
AlertDialogHeader,
|
|
121
|
-
AlertDialogFooter,
|
|
122
|
-
AlertDialogTitle,
|
|
123
|
-
AlertDialogDescription,
|
|
124
|
-
AlertDialogAction,
|
|
125
|
-
AlertDialogCancel,
|
|
126
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
-
|
|
4
|
-
import { cn } from "../../../lib/utils";
|
|
5
|
-
|
|
6
|
-
const badgeVariants = cva(
|
|
7
|
-
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8
|
-
{
|
|
9
|
-
variants: {
|
|
10
|
-
variant: {
|
|
11
|
-
default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
|
12
|
-
secondary:
|
|
13
|
-
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
14
|
-
destructive:
|
|
15
|
-
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
16
|
-
outline: "text-foreground",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
defaultVariants: {
|
|
20
|
-
variant: "default",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export interface BadgeProps
|
|
26
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
27
|
-
VariantProps<typeof badgeVariants> {}
|
|
28
|
-
|
|
29
|
-
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
30
|
-
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { Badge, badgeVariants };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
-
|
|
5
|
-
import { cn } from "../../../lib/utils";
|
|
6
|
-
|
|
7
|
-
const buttonVariants = cva(
|
|
8
|
-
"inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
9
|
-
{
|
|
10
|
-
variants: {
|
|
11
|
-
variant: {
|
|
12
|
-
default: "bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
|
|
13
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
14
|
-
outline: "border border-input hover:bg-accent hover:text-accent-foreground",
|
|
15
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
16
|
-
ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
|
|
17
|
-
link: "text-primary underline-offset-4 shadow-none hover:underline",
|
|
18
|
-
},
|
|
19
|
-
size: {
|
|
20
|
-
default: "h-8 px-4 py-2",
|
|
21
|
-
sm: "h-8 rounded-md px-3",
|
|
22
|
-
lg: "h-11 rounded-md px-8",
|
|
23
|
-
icon: "h-8 w-8 p-0",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
defaultVariants: {
|
|
27
|
-
variant: "default",
|
|
28
|
-
size: "default",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
export interface ButtonProps
|
|
34
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
35
|
-
VariantProps<typeof buttonVariants> {
|
|
36
|
-
asChild?: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
40
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
41
|
-
const Comp = asChild ? Slot : "button";
|
|
42
|
-
return (
|
|
43
|
-
<Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
Button.displayName = "Button";
|
|
48
|
-
|
|
49
|
-
export { Button, buttonVariants };
|