@copilotkit/react-ui 0.3.0 → 0.4.0
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 +192 -13
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/chunk-46XC7ODX.mjs +72 -0
- package/dist/chunk-46XC7ODX.mjs.map +1 -0
- package/dist/chunk-4HK6C362.mjs +106 -0
- package/dist/chunk-4HK6C362.mjs.map +1 -0
- package/dist/chunk-6LAC5RA2.mjs +28 -0
- package/dist/chunk-6LAC5RA2.mjs.map +1 -0
- package/dist/chunk-6LRNF2VU.mjs +12 -0
- package/dist/chunk-6LRNF2VU.mjs.map +1 -0
- package/dist/chunk-7NSRDJ5C.mjs +3 -0
- package/dist/chunk-7NSRDJ5C.mjs.map +1 -0
- package/dist/chunk-BB6IP63P.mjs +29 -0
- package/dist/chunk-BB6IP63P.mjs.map +1 -0
- package/dist/chunk-BIPCPNHG.mjs +18 -0
- package/dist/chunk-BIPCPNHG.mjs.map +1 -0
- package/dist/chunk-BS6RR2DJ.mjs +25 -0
- package/dist/chunk-BS6RR2DJ.mjs.map +1 -0
- package/dist/chunk-DOMJCSI6.mjs +26 -0
- package/dist/chunk-DOMJCSI6.mjs.map +1 -0
- package/dist/chunk-E2YBQYWM.mjs +69 -0
- package/dist/chunk-E2YBQYWM.mjs.map +1 -0
- package/dist/chunk-E5BOIXYO.mjs +45 -0
- package/dist/chunk-E5BOIXYO.mjs.map +1 -0
- package/dist/chunk-H4VKQGVU.mjs +3 -0
- package/dist/chunk-H4VKQGVU.mjs.map +1 -0
- package/dist/chunk-I2AB5FK4.mjs +123 -0
- package/dist/chunk-I2AB5FK4.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +3 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-KR7MH7XO.mjs +481 -0
- package/dist/chunk-KR7MH7XO.mjs.map +1 -0
- package/dist/chunk-KXJV37FS.mjs +33 -0
- package/dist/chunk-KXJV37FS.mjs.map +1 -0
- package/dist/chunk-MC6KTH4X.mjs +12 -0
- package/dist/chunk-MC6KTH4X.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +55 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-N7KB3Z57.mjs +23 -0
- package/dist/chunk-N7KB3Z57.mjs.map +1 -0
- package/dist/chunk-QEXWZWJL.mjs +75 -0
- package/dist/chunk-QEXWZWJL.mjs.map +1 -0
- package/dist/chunk-RSONJDLO.mjs +28 -0
- package/dist/chunk-RSONJDLO.mjs.map +1 -0
- package/dist/chunk-SF56HSZW.mjs +48 -0
- package/dist/chunk-SF56HSZW.mjs.map +1 -0
- package/dist/chunk-TVTG3V4F.mjs +40 -0
- package/dist/chunk-TVTG3V4F.mjs.map +1 -0
- package/dist/chunk-U6NJWGTV.mjs +3 -0
- package/dist/chunk-U6NJWGTV.mjs.map +1 -0
- package/dist/chunk-V6QYUEJR.mjs +47 -0
- package/dist/chunk-V6QYUEJR.mjs.map +1 -0
- package/dist/chunk-VQNV2DHJ.mjs +142 -0
- package/dist/chunk-VQNV2DHJ.mjs.map +1 -0
- package/dist/chunk-VSNDSL6W.mjs +74 -0
- package/dist/chunk-VSNDSL6W.mjs.map +1 -0
- package/dist/chunk-XZFO2YEG.mjs +53 -0
- package/dist/chunk-XZFO2YEG.mjs.map +1 -0
- package/dist/components/chat-components/chat-list.d.ts +8 -0
- package/dist/components/chat-components/chat-list.mjs +13 -0
- package/dist/components/chat-components/chat-list.mjs.map +1 -0
- package/dist/components/chat-components/chat-message-actions.d.ts +8 -0
- package/dist/components/chat-components/chat-message-actions.mjs +8 -0
- package/dist/components/chat-components/chat-message-actions.mjs.map +1 -0
- package/dist/components/chat-components/chat-message.d.ts +8 -0
- package/dist/components/chat-components/chat-message.mjs +11 -0
- package/dist/components/chat-components/chat-message.mjs.map +1 -0
- package/dist/components/chat-components/chat-panel.d.ts +8 -0
- package/dist/components/chat-components/chat-panel.mjs +10 -0
- package/dist/components/chat-components/chat-panel.mjs.map +1 -0
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +6 -0
- package/dist/components/chat-components/chat-scroll-anchor.mjs +5 -0
- package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -0
- package/dist/components/chat-components/clear-history.d.ts +9 -0
- package/dist/components/chat-components/clear-history.mjs +81 -0
- package/dist/components/chat-components/clear-history.mjs.map +1 -0
- package/dist/components/chat-components/copilot-chat.d.ts +12 -0
- package/dist/components/chat-components/copilot-chat.mjs +22 -0
- package/dist/components/chat-components/copilot-chat.mjs.map +1 -0
- package/dist/components/chat-components/default-empty-screen.d.ts +8 -0
- package/dist/components/chat-components/default-empty-screen.mjs +8 -0
- package/dist/components/chat-components/default-empty-screen.mjs.map +1 -0
- package/dist/components/chat-components/external-link.d.ts +6 -0
- package/dist/components/chat-components/external-link.mjs +4 -0
- package/dist/components/chat-components/external-link.mjs.map +1 -0
- package/dist/components/chat-components/markdown.d.ts +6 -0
- package/dist/components/chat-components/markdown.mjs +4 -0
- package/dist/components/chat-components/markdown.mjs.map +1 -0
- package/dist/components/chat-components/prompt-form.d.ts +9 -0
- package/dist/components/chat-components/prompt-form.mjs +9 -0
- package/dist/components/chat-components/prompt-form.mjs.map +1 -0
- package/dist/components/chat-components/theme-toggle.d.ts +3 -0
- package/dist/components/chat-components/theme-toggle.mjs +36 -0
- package/dist/components/chat-components/theme-toggle.mjs.map +1 -0
- package/dist/components/chat-components/toaster.d.ts +1 -0
- package/dist/components/chat-components/toaster.mjs +4 -0
- package/dist/components/chat-components/toaster.mjs.map +1 -0
- package/dist/components/chat-components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/chat-components/ui/alert-dialog.mjs +6 -0
- package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -0
- package/dist/components/chat-components/ui/badge.d.ts +12 -0
- package/dist/components/chat-components/ui/badge.mjs +31 -0
- package/dist/components/chat-components/ui/badge.mjs.map +1 -0
- package/dist/components/chat-components/ui/button.d.ts +14 -0
- package/dist/components/chat-components/ui/button.mjs +5 -0
- package/dist/components/chat-components/ui/button.mjs.map +1 -0
- package/dist/components/chat-components/ui/codeblock.d.ts +14 -0
- package/dist/components/chat-components/ui/codeblock.mjs +8 -0
- package/dist/components/chat-components/ui/codeblock.mjs.map +1 -0
- package/dist/components/chat-components/ui/dialog.d.ts +18 -0
- package/dist/components/chat-components/ui/dialog.mjs +119 -0
- package/dist/components/chat-components/ui/dialog.mjs.map +1 -0
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +24 -0
- package/dist/components/chat-components/ui/dropdown-menu.mjs +84 -0
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -0
- package/dist/components/chat-components/ui/icons.d.ts +33 -0
- package/dist/components/chat-components/ui/icons.mjs +5 -0
- package/dist/components/chat-components/ui/icons.mjs.map +1 -0
- package/dist/components/chat-components/ui/input.d.ts +7 -0
- package/dist/components/chat-components/ui/input.mjs +23 -0
- package/dist/components/chat-components/ui/input.mjs.map +1 -0
- package/dist/components/chat-components/ui/label.d.ts +8 -0
- package/dist/components/chat-components/ui/label.mjs +22 -0
- package/dist/components/chat-components/ui/label.mjs.map +1 -0
- package/dist/components/chat-components/ui/select.d.ts +13 -0
- package/dist/components/chat-components/ui/select.mjs +99 -0
- package/dist/components/chat-components/ui/select.mjs.map +1 -0
- package/dist/components/chat-components/ui/separator.d.ts +6 -0
- package/dist/components/chat-components/ui/separator.mjs +5 -0
- package/dist/components/chat-components/ui/separator.mjs.map +1 -0
- package/dist/components/chat-components/ui/sheet.d.ts +19 -0
- package/dist/components/chat-components/ui/sheet.mjs +109 -0
- package/dist/components/chat-components/ui/sheet.mjs.map +1 -0
- package/dist/components/chat-components/ui/switch.d.ts +6 -0
- package/dist/components/chat-components/ui/switch.mjs +27 -0
- package/dist/components/chat-components/ui/switch.mjs.map +1 -0
- package/dist/components/chat-components/ui/textarea.d.ts +7 -0
- package/dist/components/chat-components/ui/textarea.mjs +22 -0
- package/dist/components/chat-components/ui/textarea.mjs.map +1 -0
- package/dist/components/chat-components/ui/tooltip.d.ts +9 -0
- package/dist/components/chat-components/ui/tooltip.mjs +5 -0
- package/dist/components/chat-components/ui/tooltip.mjs.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.mjs +26 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +8 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +25 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -0
- package/dist/components/sidebar/copilot-sidebar.d.ts +6 -0
- package/dist/components/sidebar/copilot-sidebar.mjs +23 -0
- package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -0
- package/dist/components/sidebar/sidebar-context.d.ts +9 -0
- package/dist/components/sidebar/sidebar-context.mjs +4 -0
- package/dist/components/sidebar/sidebar-context.mjs.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.mjs +3 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-at-bottom.d.ts +3 -0
- package/dist/hooks/use-at-bottom.mjs +4 -0
- package/dist/hooks/use-at-bottom.mjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-to-clipboard.mjs +4 -0
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/hooks/use-enter-submit.d.ts +8 -0
- package/dist/hooks/use-enter-submit.mjs +4 -0
- package/dist/hooks/use-enter-submit.mjs.map +1 -0
- package/dist/index.css +1249 -1
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +9 -36
- package/dist/index.mjs +29 -26
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.mjs +4 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/types.d.ts +16 -0
- package/dist/types/types.mjs +3 -0
- package/dist/types/types.mjs.map +1 -0
- package/package.json +8 -8
- package/src/components/chat-components/chat-list.tsx +8 -8
- package/src/components/chat-components/chat-message-actions.tsx +14 -14
- package/src/components/chat-components/chat-message.tsx +26 -26
- package/src/components/chat-components/chat-panel.tsx +18 -18
- package/src/components/chat-components/chat-scroll-anchor.tsx +12 -12
- package/src/components/chat-components/clear-history.tsx +22 -22
- package/src/components/chat-components/copilot-chat.tsx +45 -50
- package/src/components/chat-components/default-empty-screen.tsx +24 -22
- package/src/components/chat-components/external-link.tsx +4 -4
- package/src/components/chat-components/markdown.tsx +3 -3
- package/src/components/chat-components/prompt-form.tsx +27 -27
- package/src/components/chat-components/theme-toggle.tsx +11 -11
- package/src/components/chat-components/toaster.tsx +2 -2
- package/src/components/chat-components/ui/alert-dialog.tsx +35 -35
- package/src/components/chat-components/ui/badge.tsx +14 -14
- package/src/components/chat-components/ui/button.tsx +26 -26
- package/src/components/chat-components/ui/codeblock.tsx +70 -70
- package/src/components/chat-components/ui/dialog.tsx +29 -29
- package/src/components/chat-components/ui/dropdown-menu.tsx +35 -35
- package/src/components/chat-components/ui/icons.tsx +96 -96
- package/src/components/chat-components/ui/input.tsx +7 -7
- package/src/components/chat-components/ui/label.tsx +10 -10
- package/src/components/chat-components/ui/select.tsx +30 -30
- package/src/components/chat-components/ui/separator.tsx +10 -10
- package/src/components/chat-components/ui/sheet.tsx +31 -31
- package/src/components/chat-components/ui/switch.tsx +9 -9
- package/src/components/chat-components/ui/textarea.tsx +7 -7
- package/src/components/chat-components/ui/tooltip.tsx +11 -11
- package/src/components/index.ts +6 -6
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +34 -31
- package/src/components/sidebar/copilot-sidebar.tsx +9 -9
- package/src/components/sidebar/sidebar-context.tsx +5 -5
- package/src/context/index.ts +1 -1
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-at-bottom.tsx +10 -10
- package/src/hooks/use-copy-to-clipboard.tsx +14 -14
- package/src/hooks/use-enter-submit.tsx +9 -9
- package/src/index.tsx +4 -4
- package/src/lib/utils.ts +20 -20
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +10 -10
- package/tsup.config.ts +3 -4
- package/dist/index.js +0 -53
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { cva, type VariantProps } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
3
|
|
|
4
|
-
import { cn } from
|
|
4
|
+
import { cn } from "../../../lib/utils";
|
|
5
5
|
|
|
6
6
|
const badgeVariants = cva(
|
|
7
|
-
|
|
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
8
|
{
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|
|
11
11
|
default:
|
|
12
|
-
|
|
12
|
+
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
|
13
13
|
secondary:
|
|
14
|
-
|
|
14
|
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
15
15
|
destructive:
|
|
16
|
-
|
|
17
|
-
outline:
|
|
18
|
-
}
|
|
16
|
+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
17
|
+
outline: "text-foreground",
|
|
18
|
+
},
|
|
19
19
|
},
|
|
20
20
|
defaultVariants: {
|
|
21
|
-
variant:
|
|
22
|
-
}
|
|
21
|
+
variant: "default",
|
|
22
|
+
},
|
|
23
23
|
}
|
|
24
|
-
)
|
|
24
|
+
);
|
|
25
25
|
|
|
26
26
|
export interface BadgeProps
|
|
27
27
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
@@ -30,7 +30,7 @@ export interface BadgeProps
|
|
|
30
30
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
31
31
|
return (
|
|
32
32
|
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
33
|
-
)
|
|
33
|
+
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export { Badge, badgeVariants }
|
|
36
|
+
export { Badge, badgeVariants };
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { Slot } from
|
|
3
|
-
import { cva, type VariantProps } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
4
|
|
|
5
|
-
import { cn } from
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
6
|
|
|
7
7
|
const buttonVariants = cva(
|
|
8
|
-
|
|
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
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
12
12
|
default:
|
|
13
|
-
|
|
13
|
+
"bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
|
|
14
14
|
destructive:
|
|
15
|
-
|
|
15
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
16
16
|
outline:
|
|
17
|
-
|
|
17
|
+
"border border-input hover:bg-accent hover:text-accent-foreground",
|
|
18
18
|
secondary:
|
|
19
|
-
|
|
20
|
-
ghost:
|
|
21
|
-
link:
|
|
19
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
20
|
+
ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
link: "text-primary underline-offset-4 shadow-none hover:underline",
|
|
22
22
|
},
|
|
23
23
|
size: {
|
|
24
|
-
default:
|
|
25
|
-
sm:
|
|
26
|
-
lg:
|
|
27
|
-
icon:
|
|
28
|
-
}
|
|
24
|
+
default: "h-8 px-4 py-2",
|
|
25
|
+
sm: "h-8 rounded-md px-3",
|
|
26
|
+
lg: "h-11 rounded-md px-8",
|
|
27
|
+
icon: "h-8 w-8 p-0",
|
|
28
|
+
},
|
|
29
29
|
},
|
|
30
30
|
defaultVariants: {
|
|
31
|
-
variant:
|
|
32
|
-
size:
|
|
33
|
-
}
|
|
31
|
+
variant: "default",
|
|
32
|
+
size: "default",
|
|
33
|
+
},
|
|
34
34
|
}
|
|
35
|
-
)
|
|
35
|
+
);
|
|
36
36
|
|
|
37
37
|
export interface ButtonProps
|
|
38
38
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
39
39
|
VariantProps<typeof buttonVariants> {
|
|
40
|
-
asChild?: boolean
|
|
40
|
+
asChild?: boolean;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
44
44
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
45
|
-
const Comp = asChild ? Slot :
|
|
45
|
+
const Comp = asChild ? Slot : "button";
|
|
46
46
|
return (
|
|
47
47
|
<Comp
|
|
48
48
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
49
49
|
ref={ref}
|
|
50
50
|
{...props}
|
|
51
51
|
/>
|
|
52
|
-
)
|
|
52
|
+
);
|
|
53
53
|
}
|
|
54
|
-
)
|
|
55
|
-
Button.displayName =
|
|
54
|
+
);
|
|
55
|
+
Button.displayName = "Button";
|
|
56
56
|
|
|
57
|
-
export { Button, buttonVariants }
|
|
57
|
+
export { Button, buttonVariants };
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import { FC, memo } from
|
|
4
|
-
import { Prism as SyntaxHighlighter } from
|
|
5
|
-
import { coldarkDark } from
|
|
3
|
+
import { FC, memo } from "react";
|
|
4
|
+
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
5
|
+
import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
|
6
6
|
|
|
7
|
-
import { useCopyToClipboard } from
|
|
8
|
-
import { IconCheck, IconCopy, IconDownload } from
|
|
9
|
-
import { Button } from
|
|
7
|
+
import { useCopyToClipboard } from "../../../hooks/use-copy-to-clipboard";
|
|
8
|
+
import { IconCheck, IconCopy, IconDownload } from "./icons";
|
|
9
|
+
import { Button } from "./button";
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
|
-
language: string
|
|
13
|
-
value: string
|
|
12
|
+
language: string;
|
|
13
|
+
value: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
interface languageMap {
|
|
17
|
-
[key: string]: string | undefined
|
|
17
|
+
[key: string]: string | undefined;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const programmingLanguages: languageMap = {
|
|
21
|
-
javascript:
|
|
22
|
-
python:
|
|
23
|
-
java:
|
|
24
|
-
c:
|
|
25
|
-
cpp:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
ruby:
|
|
29
|
-
php:
|
|
30
|
-
swift:
|
|
31
|
-
|
|
32
|
-
kotlin:
|
|
33
|
-
typescript:
|
|
34
|
-
go:
|
|
35
|
-
perl:
|
|
36
|
-
rust:
|
|
37
|
-
scala:
|
|
38
|
-
haskell:
|
|
39
|
-
lua:
|
|
40
|
-
shell:
|
|
41
|
-
sql:
|
|
42
|
-
html:
|
|
43
|
-
css:
|
|
21
|
+
javascript: ".js",
|
|
22
|
+
python: ".py",
|
|
23
|
+
java: ".java",
|
|
24
|
+
c: ".c",
|
|
25
|
+
cpp: ".cpp",
|
|
26
|
+
"c++": ".cpp",
|
|
27
|
+
"c#": ".cs",
|
|
28
|
+
ruby: ".rb",
|
|
29
|
+
php: ".php",
|
|
30
|
+
swift: ".swift",
|
|
31
|
+
"objective-c": ".m",
|
|
32
|
+
kotlin: ".kt",
|
|
33
|
+
typescript: ".ts",
|
|
34
|
+
go: ".go",
|
|
35
|
+
perl: ".pl",
|
|
36
|
+
rust: ".rs",
|
|
37
|
+
scala: ".scala",
|
|
38
|
+
haskell: ".hs",
|
|
39
|
+
lua: ".lua",
|
|
40
|
+
shell: ".sh",
|
|
41
|
+
sql: ".sql",
|
|
42
|
+
html: ".html",
|
|
43
|
+
css: ".css",
|
|
44
44
|
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
45
|
-
}
|
|
45
|
+
};
|
|
46
46
|
|
|
47
47
|
export const generateRandomString = (length: number, lowercase = false) => {
|
|
48
|
-
const chars =
|
|
49
|
-
let result =
|
|
48
|
+
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789"; // excluding similar looking characters like Z, 2, I, 1, O, 0
|
|
49
|
+
let result = "";
|
|
50
50
|
for (let i = 0; i < length; i++) {
|
|
51
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length))
|
|
51
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
52
52
|
}
|
|
53
|
-
return lowercase ? result.toLowerCase() : result
|
|
54
|
-
}
|
|
53
|
+
return lowercase ? result.toLowerCase() : result;
|
|
54
|
+
};
|
|
55
55
|
|
|
56
56
|
const CodeBlock: FC<Props> = memo(({ language, value }) => {
|
|
57
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 })
|
|
57
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
|
|
58
58
|
|
|
59
59
|
const downloadAsFile = () => {
|
|
60
|
-
if (typeof window ===
|
|
61
|
-
return
|
|
60
|
+
if (typeof window === "undefined") {
|
|
61
|
+
return;
|
|
62
62
|
}
|
|
63
|
-
const fileExtension = programmingLanguages[language] ||
|
|
63
|
+
const fileExtension = programmingLanguages[language] || ".file";
|
|
64
64
|
const suggestedFileName = `file-${generateRandomString(
|
|
65
65
|
3,
|
|
66
66
|
true
|
|
67
|
-
)}${fileExtension}
|
|
68
|
-
const fileName = window.prompt(
|
|
67
|
+
)}${fileExtension}`;
|
|
68
|
+
const fileName = window.prompt("Enter file name" || "", suggestedFileName);
|
|
69
69
|
|
|
70
70
|
if (!fileName) {
|
|
71
71
|
// User pressed cancel on prompt.
|
|
72
|
-
return
|
|
72
|
+
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const blob = new Blob([value], { type:
|
|
76
|
-
const url = URL.createObjectURL(blob)
|
|
77
|
-
const link = document.createElement(
|
|
78
|
-
link.download = fileName
|
|
79
|
-
link.href = url
|
|
80
|
-
link.style.display =
|
|
81
|
-
document.body.appendChild(link)
|
|
82
|
-
link.click()
|
|
83
|
-
document.body.removeChild(link)
|
|
84
|
-
URL.revokeObjectURL(url)
|
|
85
|
-
}
|
|
75
|
+
const blob = new Blob([value], { type: "text/plain" });
|
|
76
|
+
const url = URL.createObjectURL(blob);
|
|
77
|
+
const link = document.createElement("a");
|
|
78
|
+
link.download = fileName;
|
|
79
|
+
link.href = url;
|
|
80
|
+
link.style.display = "none";
|
|
81
|
+
document.body.appendChild(link);
|
|
82
|
+
link.click();
|
|
83
|
+
document.body.removeChild(link);
|
|
84
|
+
URL.revokeObjectURL(url);
|
|
85
|
+
};
|
|
86
86
|
|
|
87
87
|
const onCopy = () => {
|
|
88
|
-
if (isCopied) return
|
|
89
|
-
copyToClipboard(value)
|
|
90
|
-
}
|
|
88
|
+
if (isCopied) return;
|
|
89
|
+
copyToClipboard(value);
|
|
90
|
+
};
|
|
91
91
|
|
|
92
92
|
return (
|
|
93
93
|
<div className="codeblock relative w-full bg-zinc-950 font-sans">
|
|
@@ -121,22 +121,22 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
|
|
|
121
121
|
showLineNumbers
|
|
122
122
|
customStyle={{
|
|
123
123
|
margin: 0,
|
|
124
|
-
width:
|
|
125
|
-
background:
|
|
126
|
-
padding:
|
|
124
|
+
width: "100%",
|
|
125
|
+
background: "transparent",
|
|
126
|
+
padding: "1.5rem 1rem",
|
|
127
127
|
}}
|
|
128
128
|
codeTagProps={{
|
|
129
129
|
style: {
|
|
130
|
-
fontSize:
|
|
131
|
-
fontFamily:
|
|
132
|
-
}
|
|
130
|
+
fontSize: "0.9rem",
|
|
131
|
+
fontFamily: "var(--font-mono)",
|
|
132
|
+
},
|
|
133
133
|
}}
|
|
134
134
|
>
|
|
135
135
|
{value}
|
|
136
136
|
</SyntaxHighlighter>
|
|
137
137
|
</div>
|
|
138
|
-
)
|
|
139
|
-
})
|
|
140
|
-
CodeBlock.displayName =
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
CodeBlock.displayName = "CodeBlock";
|
|
141
141
|
|
|
142
|
-
export { CodeBlock }
|
|
142
|
+
export { CodeBlock };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as DialogPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { IconClose } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
|
+
import { IconClose } from "./icons";
|
|
8
8
|
|
|
9
|
-
const Dialog = DialogPrimitive.Root
|
|
9
|
+
const Dialog = DialogPrimitive.Root;
|
|
10
10
|
|
|
11
|
-
const DialogTrigger = DialogPrimitive.Trigger
|
|
11
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
12
12
|
|
|
13
13
|
const DialogPortal = ({
|
|
14
14
|
className,
|
|
@@ -20,8 +20,8 @@ const DialogPortal = ({
|
|
|
20
20
|
{children}
|
|
21
21
|
</div>
|
|
22
22
|
</DialogPrimitive.Portal>
|
|
23
|
-
)
|
|
24
|
-
DialogPortal.displayName = DialogPrimitive.Portal.displayName
|
|
23
|
+
);
|
|
24
|
+
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
25
25
|
|
|
26
26
|
const DialogOverlay = React.forwardRef<
|
|
27
27
|
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
@@ -30,13 +30,13 @@ const DialogOverlay = React.forwardRef<
|
|
|
30
30
|
<DialogPrimitive.Overlay
|
|
31
31
|
ref={ref}
|
|
32
32
|
className={cn(
|
|
33
|
-
|
|
33
|
+
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-all duration-100 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in",
|
|
34
34
|
className
|
|
35
35
|
)}
|
|
36
36
|
{...props}
|
|
37
37
|
/>
|
|
38
|
-
))
|
|
39
|
-
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
|
38
|
+
));
|
|
39
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
40
40
|
|
|
41
41
|
const DialogContent = React.forwardRef<
|
|
42
42
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
@@ -47,7 +47,7 @@ const DialogContent = React.forwardRef<
|
|
|
47
47
|
<DialogPrimitive.Content
|
|
48
48
|
ref={ref}
|
|
49
49
|
className={cn(
|
|
50
|
-
|
|
50
|
+
"fixed z-50 grid w-full gap-4 rounded-b-lg border bg-background p-6 shadow-sm animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:max-w-lg sm:rounded-lg sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0",
|
|
51
51
|
className
|
|
52
52
|
)}
|
|
53
53
|
{...props}
|
|
@@ -59,8 +59,8 @@ const DialogContent = React.forwardRef<
|
|
|
59
59
|
</DialogPrimitive.Close>
|
|
60
60
|
</DialogPrimitive.Content>
|
|
61
61
|
</DialogPortal>
|
|
62
|
-
))
|
|
63
|
-
DialogContent.displayName = DialogPrimitive.Content.displayName
|
|
62
|
+
));
|
|
63
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
64
64
|
|
|
65
65
|
const DialogHeader = ({
|
|
66
66
|
className,
|
|
@@ -68,13 +68,13 @@ const DialogHeader = ({
|
|
|
68
68
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
69
69
|
<div
|
|
70
70
|
className={cn(
|
|
71
|
-
|
|
71
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
72
72
|
className
|
|
73
73
|
)}
|
|
74
74
|
{...props}
|
|
75
75
|
/>
|
|
76
|
-
)
|
|
77
|
-
DialogHeader.displayName =
|
|
76
|
+
);
|
|
77
|
+
DialogHeader.displayName = "DialogHeader";
|
|
78
78
|
|
|
79
79
|
const DialogFooter = ({
|
|
80
80
|
className,
|
|
@@ -82,13 +82,13 @@ const DialogFooter = ({
|
|
|
82
82
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
83
83
|
<div
|
|
84
84
|
className={cn(
|
|
85
|
-
|
|
85
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
86
86
|
className
|
|
87
87
|
)}
|
|
88
88
|
{...props}
|
|
89
89
|
/>
|
|
90
|
-
)
|
|
91
|
-
DialogFooter.displayName =
|
|
90
|
+
);
|
|
91
|
+
DialogFooter.displayName = "DialogFooter";
|
|
92
92
|
|
|
93
93
|
const DialogTitle = React.forwardRef<
|
|
94
94
|
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
@@ -97,13 +97,13 @@ const DialogTitle = React.forwardRef<
|
|
|
97
97
|
<DialogPrimitive.Title
|
|
98
98
|
ref={ref}
|
|
99
99
|
className={cn(
|
|
100
|
-
|
|
100
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
101
101
|
className
|
|
102
102
|
)}
|
|
103
103
|
{...props}
|
|
104
104
|
/>
|
|
105
|
-
))
|
|
106
|
-
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
|
105
|
+
));
|
|
106
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
107
107
|
|
|
108
108
|
const DialogDescription = React.forwardRef<
|
|
109
109
|
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
@@ -111,11 +111,11 @@ const DialogDescription = React.forwardRef<
|
|
|
111
111
|
>(({ className, ...props }, ref) => (
|
|
112
112
|
<DialogPrimitive.Description
|
|
113
113
|
ref={ref}
|
|
114
|
-
className={cn(
|
|
114
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
115
115
|
{...props}
|
|
116
116
|
/>
|
|
117
|
-
))
|
|
118
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
|
117
|
+
));
|
|
118
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
119
119
|
|
|
120
120
|
export {
|
|
121
121
|
Dialog,
|
|
@@ -124,5 +124,5 @@ export {
|
|
|
124
124
|
DialogHeader,
|
|
125
125
|
DialogFooter,
|
|
126
126
|
DialogTitle,
|
|
127
|
-
DialogDescription
|
|
128
|
-
}
|
|
127
|
+
DialogDescription,
|
|
128
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as DropdownMenuPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
7
|
|
|
8
|
-
const DropdownMenu = DropdownMenuPrimitive.Root
|
|
8
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
9
9
|
|
|
10
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
|
10
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
11
11
|
|
|
12
|
-
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
|
12
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
13
13
|
|
|
14
|
-
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
|
14
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
15
15
|
|
|
16
|
-
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
|
16
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
17
17
|
|
|
18
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
|
18
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
19
19
|
|
|
20
20
|
const DropdownMenuSubContent = React.forwardRef<
|
|
21
21
|
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
@@ -24,14 +24,14 @@ const DropdownMenuSubContent = React.forwardRef<
|
|
|
24
24
|
<DropdownMenuPrimitive.SubContent
|
|
25
25
|
ref={ref}
|
|
26
26
|
className={cn(
|
|
27
|
-
|
|
27
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",
|
|
28
28
|
className
|
|
29
29
|
)}
|
|
30
30
|
{...props}
|
|
31
31
|
/>
|
|
32
|
-
))
|
|
32
|
+
));
|
|
33
33
|
DropdownMenuSubContent.displayName =
|
|
34
|
-
DropdownMenuPrimitive.SubContent.displayName
|
|
34
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
35
35
|
|
|
36
36
|
const DropdownMenuContent = React.forwardRef<
|
|
37
37
|
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
@@ -42,50 +42,50 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
42
42
|
ref={ref}
|
|
43
43
|
sideOffset={sideOffset}
|
|
44
44
|
className={cn(
|
|
45
|
-
|
|
45
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow animate-in data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
46
46
|
className
|
|
47
47
|
)}
|
|
48
48
|
{...props}
|
|
49
49
|
/>
|
|
50
50
|
</DropdownMenuPrimitive.Portal>
|
|
51
|
-
))
|
|
52
|
-
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
|
51
|
+
));
|
|
52
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
53
53
|
|
|
54
54
|
const DropdownMenuItem = React.forwardRef<
|
|
55
55
|
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
56
56
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
57
|
-
inset?: boolean
|
|
57
|
+
inset?: boolean;
|
|
58
58
|
}
|
|
59
59
|
>(({ className, inset, ...props }, ref) => (
|
|
60
60
|
<DropdownMenuPrimitive.Item
|
|
61
61
|
ref={ref}
|
|
62
62
|
className={cn(
|
|
63
|
-
|
|
64
|
-
inset &&
|
|
63
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
64
|
+
inset && "pl-8",
|
|
65
65
|
className
|
|
66
66
|
)}
|
|
67
67
|
{...props}
|
|
68
68
|
/>
|
|
69
|
-
))
|
|
70
|
-
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
|
69
|
+
));
|
|
70
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
71
71
|
|
|
72
72
|
const DropdownMenuLabel = React.forwardRef<
|
|
73
73
|
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
74
74
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
75
|
-
inset?: boolean
|
|
75
|
+
inset?: boolean;
|
|
76
76
|
}
|
|
77
77
|
>(({ className, inset, ...props }, ref) => (
|
|
78
78
|
<DropdownMenuPrimitive.Label
|
|
79
79
|
ref={ref}
|
|
80
80
|
className={cn(
|
|
81
|
-
|
|
82
|
-
inset &&
|
|
81
|
+
"px-2 py-1.5 text-sm font-semibold",
|
|
82
|
+
inset && "pl-8",
|
|
83
83
|
className
|
|
84
84
|
)}
|
|
85
85
|
{...props}
|
|
86
86
|
/>
|
|
87
|
-
))
|
|
88
|
-
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
|
87
|
+
));
|
|
88
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
89
89
|
|
|
90
90
|
const DropdownMenuSeparator = React.forwardRef<
|
|
91
91
|
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
@@ -93,11 +93,11 @@ const DropdownMenuSeparator = React.forwardRef<
|
|
|
93
93
|
>(({ className, ...props }, ref) => (
|
|
94
94
|
<DropdownMenuPrimitive.Separator
|
|
95
95
|
ref={ref}
|
|
96
|
-
className={cn(
|
|
96
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
97
97
|
{...props}
|
|
98
98
|
/>
|
|
99
|
-
))
|
|
100
|
-
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
|
99
|
+
));
|
|
100
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
101
101
|
|
|
102
102
|
const DropdownMenuShortcut = ({
|
|
103
103
|
className,
|
|
@@ -105,12 +105,12 @@ const DropdownMenuShortcut = ({
|
|
|
105
105
|
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
106
106
|
return (
|
|
107
107
|
<span
|
|
108
|
-
className={cn(
|
|
108
|
+
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
|
109
109
|
{...props}
|
|
110
110
|
/>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
DropdownMenuShortcut.displayName =
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
114
114
|
|
|
115
115
|
export {
|
|
116
116
|
DropdownMenu,
|
|
@@ -124,5 +124,5 @@ export {
|
|
|
124
124
|
DropdownMenuPortal,
|
|
125
125
|
DropdownMenuSub,
|
|
126
126
|
DropdownMenuSubContent,
|
|
127
|
-
DropdownMenuRadioGroup
|
|
128
|
-
}
|
|
127
|
+
DropdownMenuRadioGroup,
|
|
128
|
+
};
|