@copilotkit/react-ui 0.2.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.
Files changed (238) hide show
  1. package/.turbo/turbo-build.log +193 -16
  2. package/CHANGELOG.md +24 -0
  3. package/LICENSE +21 -0
  4. package/dist/chunk-46XC7ODX.mjs +72 -0
  5. package/dist/chunk-46XC7ODX.mjs.map +1 -0
  6. package/dist/chunk-4HK6C362.mjs +106 -0
  7. package/dist/chunk-4HK6C362.mjs.map +1 -0
  8. package/dist/chunk-6LAC5RA2.mjs +28 -0
  9. package/dist/chunk-6LAC5RA2.mjs.map +1 -0
  10. package/dist/chunk-6LRNF2VU.mjs +12 -0
  11. package/dist/chunk-6LRNF2VU.mjs.map +1 -0
  12. package/dist/chunk-7NSRDJ5C.mjs +3 -0
  13. package/dist/chunk-7NSRDJ5C.mjs.map +1 -0
  14. package/dist/chunk-BB6IP63P.mjs +29 -0
  15. package/dist/chunk-BB6IP63P.mjs.map +1 -0
  16. package/dist/chunk-BIPCPNHG.mjs +18 -0
  17. package/dist/chunk-BIPCPNHG.mjs.map +1 -0
  18. package/dist/chunk-BS6RR2DJ.mjs +25 -0
  19. package/dist/chunk-BS6RR2DJ.mjs.map +1 -0
  20. package/dist/chunk-DOMJCSI6.mjs +26 -0
  21. package/dist/chunk-DOMJCSI6.mjs.map +1 -0
  22. package/dist/chunk-E2YBQYWM.mjs +69 -0
  23. package/dist/chunk-E2YBQYWM.mjs.map +1 -0
  24. package/dist/chunk-E5BOIXYO.mjs +45 -0
  25. package/dist/chunk-E5BOIXYO.mjs.map +1 -0
  26. package/dist/chunk-H4VKQGVU.mjs +3 -0
  27. package/dist/chunk-H4VKQGVU.mjs.map +1 -0
  28. package/dist/chunk-I2AB5FK4.mjs +123 -0
  29. package/dist/chunk-I2AB5FK4.mjs.map +1 -0
  30. package/dist/chunk-IU3WTXLQ.mjs +3 -0
  31. package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
  32. package/dist/chunk-KR7MH7XO.mjs +481 -0
  33. package/dist/chunk-KR7MH7XO.mjs.map +1 -0
  34. package/dist/chunk-KXJV37FS.mjs +33 -0
  35. package/dist/chunk-KXJV37FS.mjs.map +1 -0
  36. package/dist/chunk-MC6KTH4X.mjs +12 -0
  37. package/dist/chunk-MC6KTH4X.mjs.map +1 -0
  38. package/dist/chunk-MRXNTQOX.mjs +55 -0
  39. package/dist/chunk-MRXNTQOX.mjs.map +1 -0
  40. package/dist/chunk-N7KB3Z57.mjs +23 -0
  41. package/dist/chunk-N7KB3Z57.mjs.map +1 -0
  42. package/dist/chunk-QEXWZWJL.mjs +75 -0
  43. package/dist/chunk-QEXWZWJL.mjs.map +1 -0
  44. package/dist/chunk-RSONJDLO.mjs +28 -0
  45. package/dist/chunk-RSONJDLO.mjs.map +1 -0
  46. package/dist/chunk-SF56HSZW.mjs +48 -0
  47. package/dist/chunk-SF56HSZW.mjs.map +1 -0
  48. package/dist/chunk-TVTG3V4F.mjs +40 -0
  49. package/dist/chunk-TVTG3V4F.mjs.map +1 -0
  50. package/dist/chunk-U6NJWGTV.mjs +3 -0
  51. package/dist/chunk-U6NJWGTV.mjs.map +1 -0
  52. package/dist/chunk-V6QYUEJR.mjs +47 -0
  53. package/dist/chunk-V6QYUEJR.mjs.map +1 -0
  54. package/dist/chunk-VQNV2DHJ.mjs +142 -0
  55. package/dist/chunk-VQNV2DHJ.mjs.map +1 -0
  56. package/dist/chunk-VSNDSL6W.mjs +74 -0
  57. package/dist/chunk-VSNDSL6W.mjs.map +1 -0
  58. package/dist/chunk-XZFO2YEG.mjs +53 -0
  59. package/dist/chunk-XZFO2YEG.mjs.map +1 -0
  60. package/dist/components/chat-components/chat-list.d.ts +8 -0
  61. package/dist/components/chat-components/chat-list.mjs +13 -0
  62. package/dist/components/chat-components/chat-list.mjs.map +1 -0
  63. package/dist/components/chat-components/chat-message-actions.d.ts +8 -0
  64. package/dist/components/chat-components/chat-message-actions.mjs +8 -0
  65. package/dist/components/chat-components/chat-message-actions.mjs.map +1 -0
  66. package/dist/components/chat-components/chat-message.d.ts +8 -0
  67. package/dist/components/chat-components/chat-message.mjs +11 -0
  68. package/dist/components/chat-components/chat-message.mjs.map +1 -0
  69. package/dist/components/chat-components/chat-panel.d.ts +8 -0
  70. package/dist/components/chat-components/chat-panel.mjs +10 -0
  71. package/dist/components/chat-components/chat-panel.mjs.map +1 -0
  72. package/dist/components/chat-components/chat-scroll-anchor.d.ts +6 -0
  73. package/dist/components/chat-components/chat-scroll-anchor.mjs +5 -0
  74. package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -0
  75. package/dist/components/chat-components/clear-history.d.ts +9 -0
  76. package/dist/components/chat-components/clear-history.mjs +81 -0
  77. package/dist/components/chat-components/clear-history.mjs.map +1 -0
  78. package/dist/components/chat-components/copilot-chat.d.ts +12 -0
  79. package/dist/components/chat-components/copilot-chat.mjs +22 -0
  80. package/dist/components/chat-components/copilot-chat.mjs.map +1 -0
  81. package/dist/components/chat-components/default-empty-screen.d.ts +8 -0
  82. package/dist/components/chat-components/default-empty-screen.mjs +8 -0
  83. package/dist/components/chat-components/default-empty-screen.mjs.map +1 -0
  84. package/dist/components/chat-components/external-link.d.ts +6 -0
  85. package/dist/components/chat-components/external-link.mjs +4 -0
  86. package/dist/components/chat-components/external-link.mjs.map +1 -0
  87. package/dist/components/chat-components/markdown.d.ts +6 -0
  88. package/dist/components/chat-components/markdown.mjs +4 -0
  89. package/dist/components/chat-components/markdown.mjs.map +1 -0
  90. package/dist/components/chat-components/prompt-form.d.ts +9 -0
  91. package/dist/components/chat-components/prompt-form.mjs +9 -0
  92. package/dist/components/chat-components/prompt-form.mjs.map +1 -0
  93. package/dist/components/chat-components/theme-toggle.d.ts +3 -0
  94. package/dist/components/chat-components/theme-toggle.mjs +36 -0
  95. package/dist/components/chat-components/theme-toggle.mjs.map +1 -0
  96. package/dist/components/chat-components/toaster.d.ts +1 -0
  97. package/dist/components/chat-components/toaster.mjs +4 -0
  98. package/dist/components/chat-components/toaster.mjs.map +1 -0
  99. package/dist/components/chat-components/ui/alert-dialog.d.ts +20 -0
  100. package/dist/components/chat-components/ui/alert-dialog.mjs +6 -0
  101. package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -0
  102. package/dist/components/chat-components/ui/badge.d.ts +12 -0
  103. package/dist/components/chat-components/ui/badge.mjs +31 -0
  104. package/dist/components/chat-components/ui/badge.mjs.map +1 -0
  105. package/dist/components/chat-components/ui/button.d.ts +14 -0
  106. package/dist/components/chat-components/ui/button.mjs +5 -0
  107. package/dist/components/chat-components/ui/button.mjs.map +1 -0
  108. package/dist/components/chat-components/ui/codeblock.d.ts +14 -0
  109. package/dist/components/chat-components/ui/codeblock.mjs +8 -0
  110. package/dist/components/chat-components/ui/codeblock.mjs.map +1 -0
  111. package/dist/components/chat-components/ui/dialog.d.ts +18 -0
  112. package/dist/components/chat-components/ui/dialog.mjs +119 -0
  113. package/dist/components/chat-components/ui/dialog.mjs.map +1 -0
  114. package/dist/components/chat-components/ui/dropdown-menu.d.ts +24 -0
  115. package/dist/components/chat-components/ui/dropdown-menu.mjs +84 -0
  116. package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -0
  117. package/dist/components/chat-components/ui/icons.d.ts +33 -0
  118. package/dist/components/chat-components/ui/icons.mjs +5 -0
  119. package/dist/components/chat-components/ui/icons.mjs.map +1 -0
  120. package/dist/components/chat-components/ui/input.d.ts +7 -0
  121. package/dist/components/chat-components/ui/input.mjs +23 -0
  122. package/dist/components/chat-components/ui/input.mjs.map +1 -0
  123. package/dist/components/chat-components/ui/label.d.ts +8 -0
  124. package/dist/components/chat-components/ui/label.mjs +22 -0
  125. package/dist/components/chat-components/ui/label.mjs.map +1 -0
  126. package/dist/components/chat-components/ui/select.d.ts +13 -0
  127. package/dist/components/chat-components/ui/select.mjs +99 -0
  128. package/dist/components/chat-components/ui/select.mjs.map +1 -0
  129. package/dist/components/chat-components/ui/separator.d.ts +6 -0
  130. package/dist/components/chat-components/ui/separator.mjs +5 -0
  131. package/dist/components/chat-components/ui/separator.mjs.map +1 -0
  132. package/dist/components/chat-components/ui/sheet.d.ts +19 -0
  133. package/dist/components/chat-components/ui/sheet.mjs +109 -0
  134. package/dist/components/chat-components/ui/sheet.mjs.map +1 -0
  135. package/dist/components/chat-components/ui/switch.d.ts +6 -0
  136. package/dist/components/chat-components/ui/switch.mjs +27 -0
  137. package/dist/components/chat-components/ui/switch.mjs.map +1 -0
  138. package/dist/components/chat-components/ui/textarea.d.ts +7 -0
  139. package/dist/components/chat-components/ui/textarea.mjs +22 -0
  140. package/dist/components/chat-components/ui/textarea.mjs.map +1 -0
  141. package/dist/components/chat-components/ui/tooltip.d.ts +9 -0
  142. package/dist/components/chat-components/ui/tooltip.mjs +5 -0
  143. package/dist/components/chat-components/ui/tooltip.mjs.map +1 -0
  144. package/dist/components/index.d.ts +9 -0
  145. package/dist/components/index.mjs +26 -0
  146. package/dist/components/index.mjs.map +1 -0
  147. package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +8 -0
  148. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +25 -0
  149. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -0
  150. package/dist/components/sidebar/copilot-sidebar.d.ts +6 -0
  151. package/dist/components/sidebar/copilot-sidebar.mjs +23 -0
  152. package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -0
  153. package/dist/components/sidebar/sidebar-context.d.ts +9 -0
  154. package/dist/components/sidebar/sidebar-context.mjs +4 -0
  155. package/dist/components/sidebar/sidebar-context.mjs.map +1 -0
  156. package/dist/context/index.d.ts +1 -0
  157. package/dist/context/index.mjs +3 -0
  158. package/dist/context/index.mjs.map +1 -0
  159. package/dist/hooks/index.d.ts +1 -0
  160. package/dist/hooks/index.mjs +3 -0
  161. package/dist/hooks/index.mjs.map +1 -0
  162. package/dist/hooks/use-at-bottom.d.ts +3 -0
  163. package/dist/hooks/use-at-bottom.mjs +4 -0
  164. package/dist/hooks/use-at-bottom.mjs.map +1 -0
  165. package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
  166. package/dist/hooks/use-copy-to-clipboard.mjs +4 -0
  167. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
  168. package/dist/hooks/use-enter-submit.d.ts +8 -0
  169. package/dist/hooks/use-enter-submit.mjs +4 -0
  170. package/dist/hooks/use-enter-submit.mjs.map +1 -0
  171. package/dist/index.css +1249 -1
  172. package/dist/index.css.map +1 -0
  173. package/dist/index.d.ts +9 -2
  174. package/dist/index.mjs +29 -0
  175. package/dist/index.mjs.map +1 -0
  176. package/dist/lib/utils.d.ts +8 -0
  177. package/dist/lib/utils.mjs +4 -0
  178. package/dist/lib/utils.mjs.map +1 -0
  179. package/dist/types/index.d.ts +1 -0
  180. package/dist/types/index.mjs +3 -0
  181. package/dist/types/index.mjs.map +1 -0
  182. package/dist/types/types.d.ts +16 -0
  183. package/dist/types/types.mjs +3 -0
  184. package/dist/types/types.mjs.map +1 -0
  185. package/package.json +39 -8
  186. package/src/components/chat-components/chat-list.tsx +32 -0
  187. package/src/components/chat-components/chat-message-actions.tsx +40 -0
  188. package/src/components/chat-components/chat-message.tsx +74 -0
  189. package/src/components/chat-components/chat-panel.tsx +77 -0
  190. package/src/components/chat-components/chat-scroll-anchor.tsx +29 -0
  191. package/src/components/chat-components/clear-history.tsx +73 -0
  192. package/src/components/chat-components/copilot-chat.tsx +56 -0
  193. package/src/components/chat-components/default-empty-screen.tsx +64 -0
  194. package/src/components/chat-components/external-link.tsx +29 -0
  195. package/src/components/chat-components/markdown.tsx +9 -0
  196. package/src/components/chat-components/prompt-form.tsx +91 -0
  197. package/src/components/chat-components/theme-toggle.tsx +31 -0
  198. package/src/components/chat-components/toaster.tsx +3 -0
  199. package/src/components/chat-components/ui/alert-dialog.tsx +150 -0
  200. package/src/components/chat-components/ui/badge.tsx +36 -0
  201. package/src/components/chat-components/ui/button.tsx +57 -0
  202. package/src/components/chat-components/ui/codeblock.tsx +142 -0
  203. package/src/components/chat-components/ui/dialog.tsx +128 -0
  204. package/src/components/chat-components/ui/dropdown-menu.tsx +128 -0
  205. package/src/components/chat-components/ui/icons.tsx +507 -0
  206. package/src/components/chat-components/ui/input.tsx +25 -0
  207. package/src/components/chat-components/ui/label.tsx +26 -0
  208. package/src/components/chat-components/ui/select.tsx +119 -0
  209. package/src/components/chat-components/ui/separator.tsx +31 -0
  210. package/src/components/chat-components/ui/sheet.tsx +122 -0
  211. package/src/components/chat-components/ui/switch.tsx +29 -0
  212. package/src/components/chat-components/ui/textarea.tsx +24 -0
  213. package/src/components/chat-components/ui/tooltip.tsx +30 -0
  214. package/src/components/index.ts +7 -0
  215. package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +77 -0
  216. package/src/components/sidebar/copilot-sidebar.tsx +40 -0
  217. package/src/components/sidebar/sidebar-context.tsx +11 -0
  218. package/src/context/index.ts +1 -0
  219. package/src/hooks/index.ts +1 -0
  220. package/src/hooks/use-at-bottom.tsx +23 -0
  221. package/src/hooks/use-copy-to-clipboard.tsx +33 -0
  222. package/src/hooks/use-enter-submit.tsx +23 -0
  223. package/src/index.tsx +4 -3
  224. package/src/lib/utils.ts +43 -0
  225. package/src/types/index.ts +1 -0
  226. package/src/types/types.ts +18 -0
  227. package/tailwind.config.js +1 -1
  228. package/tsconfig.json +1 -1
  229. package/tsup.config.ts +3 -4
  230. package/dist/Button.d.ts +0 -3
  231. package/dist/Button.js +0 -10
  232. package/dist/Card.d.ts +0 -7
  233. package/dist/Card.js +0 -10
  234. package/dist/chunk-6OZR7L23.js +0 -7
  235. package/dist/chunk-FGO3LSHH.js +0 -7
  236. package/dist/index.js +0 -15
  237. package/src/Button.tsx +0 -16
  238. package/src/Card.tsx +0 -27
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
5
+
6
+ import { cn } from "../../../lib/utils";
7
+
8
+ const Separator = React.forwardRef<
9
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
10
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
11
+ >(
12
+ (
13
+ { className, orientation = "horizontal", decorative = true, ...props },
14
+ ref
15
+ ) => (
16
+ <SeparatorPrimitive.Root
17
+ ref={ref}
18
+ decorative={decorative}
19
+ orientation={orientation}
20
+ className={cn(
21
+ "shrink-0 bg-border",
22
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ )
28
+ );
29
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
30
+
31
+ export { Separator };
@@ -0,0 +1,122 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
5
+
6
+ import { cn } from "../../../lib/utils";
7
+ import { IconClose } from "./icons";
8
+
9
+ const Sheet = SheetPrimitive.Root;
10
+
11
+ const SheetTrigger = SheetPrimitive.Trigger;
12
+
13
+ const SheetClose = SheetPrimitive.Close;
14
+
15
+ const SheetPortal = ({
16
+ className,
17
+ children,
18
+ ...props
19
+ }: SheetPrimitive.DialogPortalProps) => (
20
+ <SheetPrimitive.Portal
21
+ className={cn("fixed inset-0 z-50 flex", className)}
22
+ {...props}
23
+ >
24
+ {children}
25
+ </SheetPrimitive.Portal>
26
+ );
27
+ SheetPortal.displayName = SheetPrimitive.Portal.displayName;
28
+
29
+ const SheetOverlay = React.forwardRef<
30
+ React.ElementRef<typeof SheetPrimitive.Overlay>,
31
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
32
+ >(({ className, children, ...props }, ref) => (
33
+ <SheetPrimitive.Overlay
34
+ className={cn(
35
+ "fixed inset-0 z-50 transition-all duration-100 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in",
36
+ className
37
+ )}
38
+ {...props}
39
+ ref={ref}
40
+ />
41
+ ));
42
+ SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
43
+
44
+ const SheetContent = React.forwardRef<
45
+ React.ElementRef<typeof SheetPrimitive.Content>,
46
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>
47
+ >(({ className, children, ...props }, ref) => (
48
+ <SheetPortal>
49
+ <SheetPrimitive.Content
50
+ ref={ref}
51
+ className={cn(
52
+ "fixed z-50 h-full border-r bg-background p-6 opacity-100 shadow-lg data-[state=closed]:animate-slide-to-left data-[state=open]:animate-slide-from-left",
53
+ className
54
+ )}
55
+ {...props}
56
+ >
57
+ {children}
58
+ <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
59
+ <IconClose />
60
+ <span className="sr-only">Close</span>
61
+ </SheetPrimitive.Close>
62
+ </SheetPrimitive.Content>
63
+ </SheetPortal>
64
+ ));
65
+ SheetContent.displayName = SheetPrimitive.Content.displayName;
66
+
67
+ const SheetHeader = ({
68
+ className,
69
+ ...props
70
+ }: React.HTMLAttributes<HTMLDivElement>) => (
71
+ <div className={cn("flex flex-col space-y-2", className)} {...props} />
72
+ );
73
+ SheetHeader.displayName = "SheetHeader";
74
+
75
+ const SheetFooter = ({
76
+ className,
77
+ ...props
78
+ }: React.HTMLAttributes<HTMLDivElement>) => (
79
+ <div
80
+ className={cn(
81
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
82
+ className
83
+ )}
84
+ {...props}
85
+ />
86
+ );
87
+ SheetFooter.displayName = "SheetFooter";
88
+
89
+ const SheetTitle = React.forwardRef<
90
+ React.ElementRef<typeof SheetPrimitive.Title>,
91
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
92
+ >(({ className, ...props }, ref) => (
93
+ <SheetPrimitive.Title
94
+ ref={ref}
95
+ className={cn("text-lg font-semibold text-foreground", className)}
96
+ {...props}
97
+ />
98
+ ));
99
+ SheetTitle.displayName = SheetPrimitive.Title.displayName;
100
+
101
+ const SheetDescription = React.forwardRef<
102
+ React.ElementRef<typeof SheetPrimitive.Description>,
103
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
104
+ >(({ className, ...props }, ref) => (
105
+ <SheetPrimitive.Description
106
+ ref={ref}
107
+ className={cn("text-sm text-muted-foreground", className)}
108
+ {...props}
109
+ />
110
+ ));
111
+ SheetDescription.displayName = SheetPrimitive.Description.displayName;
112
+
113
+ export {
114
+ Sheet,
115
+ SheetTrigger,
116
+ SheetClose,
117
+ SheetContent,
118
+ SheetHeader,
119
+ SheetFooter,
120
+ SheetTitle,
121
+ SheetDescription,
122
+ };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SwitchPrimitives from "@radix-ui/react-switch";
5
+
6
+ import { cn } from "../../../lib/utils";
7
+
8
+ const Switch = React.forwardRef<
9
+ React.ElementRef<typeof SwitchPrimitives.Root>,
10
+ React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
11
+ >(({ className, ...props }, ref) => (
12
+ <SwitchPrimitives.Root
13
+ className={cn(
14
+ "peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
15
+ className
16
+ )}
17
+ {...props}
18
+ ref={ref}
19
+ >
20
+ <SwitchPrimitives.Thumb
21
+ className={cn(
22
+ "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
23
+ )}
24
+ />
25
+ </SwitchPrimitives.Root>
26
+ ));
27
+ Switch.displayName = SwitchPrimitives.Root.displayName;
28
+
29
+ export { Switch };
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+
3
+ import { cn } from "../../../lib/utils";
4
+
5
+ export interface TextareaProps
6
+ extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
7
+
8
+ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
9
+ ({ className, ...props }, ref) => {
10
+ return (
11
+ <textarea
12
+ className={cn(
13
+ "flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
14
+ className
15
+ )}
16
+ ref={ref}
17
+ {...props}
18
+ />
19
+ );
20
+ }
21
+ );
22
+ Textarea.displayName = "Textarea";
23
+
24
+ export { Textarea };
@@ -0,0 +1,30 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
5
+
6
+ import { cn } from "../../../lib/utils";
7
+
8
+ const TooltipProvider = TooltipPrimitive.Provider;
9
+
10
+ const Tooltip = TooltipPrimitive.Root;
11
+
12
+ const TooltipTrigger = TooltipPrimitive.Trigger;
13
+
14
+ const TooltipContent = React.forwardRef<
15
+ React.ElementRef<typeof TooltipPrimitive.Content>,
16
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
17
+ >(({ className, sideOffset = 4, ...props }, ref) => (
18
+ <TooltipPrimitive.Content
19
+ ref={ref}
20
+ sideOffset={sideOffset}
21
+ className={cn(
22
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 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",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ ));
28
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
29
+
30
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,7 @@
1
+ export { CopilotChat } from "./chat-components/copilot-chat";
2
+ export { Tooltip, TooltipProvider } from "./chat-components/ui/tooltip";
3
+
4
+ export { CopilotSidebarUIProvider } from "./sidebar/copilot-sidebar-ui-provider";
5
+ export { CopilotSidebar } from "./sidebar/copilot-sidebar";
6
+ export { CopilotSidebarContext } from "./sidebar/sidebar-context";
7
+ export type { CopilotSidebarContextType } from "./sidebar/sidebar-context";
@@ -0,0 +1,77 @@
1
+ import React, { ReactNode, useCallback } from "react";
2
+ import { useState } from "react";
3
+ import { CopilotSidebar } from "./copilot-sidebar";
4
+ import { CopilotSidebarContext } from "./sidebar-context";
5
+ import { TooltipProvider } from "../chat-components/ui/tooltip";
6
+
7
+ export interface CopilotSidebarUIProviderProps {
8
+ children: ReactNode;
9
+ }
10
+
11
+ export function CopilotSidebarUIProvider({
12
+ children,
13
+ }: CopilotSidebarUIProviderProps) {
14
+ const [sidebarOpen, setSidebarOpen] = useState(true);
15
+
16
+ const toggleSidebar = useCallback(() => {
17
+ setSidebarOpen((prev) => !prev);
18
+ }, []);
19
+
20
+ return (
21
+ <CopilotSidebarContext.Provider
22
+ value={{ isSidebarOpen: sidebarOpen, toggleSidebar }}
23
+ >
24
+ <>
25
+ <div
26
+ style={{
27
+ height: "100vh",
28
+ width: "100vw",
29
+ position: "relative",
30
+ }}
31
+ >
32
+ <div
33
+ style={{
34
+ overflowY: "auto",
35
+ overflowX: "hidden",
36
+ height: "100%",
37
+ width: sidebarOpen ? "calc(100% - 450px)" : "100%",
38
+ position: "absolute",
39
+ transition: "width 0.5s ease-in-out", // New
40
+ }}
41
+ >
42
+ <main>{children}</main>
43
+ </div>
44
+ <div
45
+ style={{
46
+ overflowY: "auto",
47
+ height: "100%",
48
+ width: "450px",
49
+ position: "absolute",
50
+ right: sidebarOpen ? "0" : "-450px",
51
+ transition: "right 0.5s ease-in-out",
52
+ }}
53
+ >
54
+ <TooltipProvider>
55
+ <CopilotSidebar setSidebarOpen={setSidebarOpen} />
56
+ </TooltipProvider>
57
+ </div>
58
+ {!sidebarOpen && (
59
+ <button
60
+ onClick={toggleSidebar}
61
+ style={{
62
+ position: "absolute",
63
+ top: "5%",
64
+ right: "20px",
65
+ transform: "translateY(-50%)",
66
+ transition: "opacity 0.5s ease-in-out",
67
+ }}
68
+ className="bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg"
69
+ >
70
+ Open Copilot
71
+ </button>
72
+ )}
73
+ </div>
74
+ </>
75
+ </CopilotSidebarContext.Provider>
76
+ );
77
+ }
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import { CopilotChat } from "../chat-components/copilot-chat";
3
+
4
+ export interface SidebarProps {
5
+ setSidebarOpen: (open: boolean) => void;
6
+ }
7
+
8
+ export function CopilotSidebar(props: SidebarProps): JSX.Element {
9
+ return (
10
+ <div
11
+ className="shadow-lg bg-gray-50 flex flex-col border-l-2"
12
+ style={{ width: "100%", height: "100%" }}
13
+ >
14
+ <TopBar {...props} />
15
+ <CopilotChat />
16
+ </div>
17
+ );
18
+ }
19
+
20
+ import { XMarkIcon } from "@heroicons/react/24/outline";
21
+
22
+ function TopBar(props: SidebarProps): JSX.Element {
23
+ return (
24
+ <div className="py-6 flex bg-gray-50 items-center justify-between px-4">
25
+ <h1 className="text-base font-semibold leading-6 text-gray-900">
26
+ Copilot Chat
27
+ </h1>
28
+ <div className="ml-3 flex h-7 items-center">
29
+ <button
30
+ type="button"
31
+ className="rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
32
+ onClick={() => props.setSidebarOpen(false)}
33
+ >
34
+ <span className="sr-only">Close panel</span>
35
+ <XMarkIcon className="h-6 w-6" aria-hidden="true" />
36
+ </button>
37
+ </div>
38
+ </div>
39
+ );
40
+ }
@@ -0,0 +1,11 @@
1
+ import { createContext, ReactNode } from "react";
2
+
3
+ export interface CopilotSidebarContextType {
4
+ isSidebarOpen: boolean;
5
+ toggleSidebar: () => void;
6
+ }
7
+
8
+ export const CopilotSidebarContext = createContext<CopilotSidebarContextType>({
9
+ isSidebarOpen: false,
10
+ toggleSidebar: () => {},
11
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+
3
+ export function useAtBottom(offset = 0) {
4
+ const [isAtBottom, setIsAtBottom] = React.useState(false);
5
+
6
+ React.useEffect(() => {
7
+ const handleScroll = () => {
8
+ setIsAtBottom(
9
+ window.innerHeight + window.scrollY >=
10
+ document.body.offsetHeight - offset
11
+ );
12
+ };
13
+
14
+ window.addEventListener("scroll", handleScroll, { passive: true });
15
+ handleScroll();
16
+
17
+ return () => {
18
+ window.removeEventListener("scroll", handleScroll);
19
+ };
20
+ }, [offset]);
21
+
22
+ return isAtBottom;
23
+ }
@@ -0,0 +1,33 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+
5
+ export interface useCopyToClipboardProps {
6
+ timeout?: number;
7
+ }
8
+
9
+ export function useCopyToClipboard({
10
+ timeout = 2000,
11
+ }: useCopyToClipboardProps) {
12
+ const [isCopied, setIsCopied] = React.useState<Boolean>(false);
13
+
14
+ const copyToClipboard = (value: string) => {
15
+ if (typeof window === "undefined" || !navigator.clipboard?.writeText) {
16
+ return;
17
+ }
18
+
19
+ if (!value) {
20
+ return;
21
+ }
22
+
23
+ navigator.clipboard.writeText(value).then(() => {
24
+ setIsCopied(true);
25
+
26
+ setTimeout(() => {
27
+ setIsCopied(false);
28
+ }, timeout);
29
+ });
30
+ };
31
+
32
+ return { isCopied, copyToClipboard };
33
+ }
@@ -0,0 +1,23 @@
1
+ import { useRef, type RefObject } from "react";
2
+
3
+ export function useEnterSubmit(): {
4
+ formRef: RefObject<HTMLFormElement>;
5
+ onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
6
+ } {
7
+ const formRef = useRef<HTMLFormElement>(null);
8
+
9
+ const handleKeyDown = (
10
+ event: React.KeyboardEvent<HTMLTextAreaElement>
11
+ ): void => {
12
+ if (
13
+ event.key === "Enter" &&
14
+ !event.shiftKey &&
15
+ !event.nativeEvent.isComposing
16
+ ) {
17
+ formRef.current?.requestSubmit();
18
+ event.preventDefault();
19
+ }
20
+ };
21
+
22
+ return { formRef, onKeyDown: handleKeyDown };
23
+ }
package/src/index.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  // styles
2
2
  import "./styles.css";
3
3
 
4
- // components
5
- export * from "./Button";
6
- export * from "./Card";
4
+ export * from "./components";
5
+ export * from "./context";
6
+ export * from "./hooks";
7
+ export * from "./types";
@@ -0,0 +1,43 @@
1
+ import { clsx, type ClassValue } from "clsx";
2
+ import { customAlphabet } from "nanoid";
3
+ import { twMerge } from "tailwind-merge";
4
+
5
+ export function cn(...inputs: ClassValue[]) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+
9
+ export const nanoid = customAlphabet(
10
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
11
+ 7
12
+ ); // 7-character random string
13
+
14
+ export async function fetcher<JSON = any>(
15
+ input: RequestInfo,
16
+ init?: RequestInit
17
+ ): Promise<JSON> {
18
+ const res = await fetch(input, init);
19
+
20
+ if (!res.ok) {
21
+ const json = await res.json();
22
+ if (json.error) {
23
+ const error = new Error(json.error) as Error & {
24
+ status: number;
25
+ };
26
+ error.status = res.status;
27
+ throw error;
28
+ } else {
29
+ throw new Error("An unexpected error occurred");
30
+ }
31
+ }
32
+
33
+ return res.json();
34
+ }
35
+
36
+ export function formatDate(input: string | number | Date): string {
37
+ const date = new Date(input);
38
+ return date.toLocaleDateString("en-US", {
39
+ month: "long",
40
+ day: "numeric",
41
+ year: "numeric",
42
+ });
43
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { type Message } from "ai";
2
+
3
+ export interface Chat extends Record<string, any> {
4
+ id: string;
5
+ title: string;
6
+ createdAt: Date;
7
+ userId: string;
8
+ path: string;
9
+ messages: Message[];
10
+ sharePath?: string;
11
+ }
12
+
13
+ export type ServerActionResult<Result> = Promise<
14
+ | Result
15
+ | {
16
+ error: string;
17
+ }
18
+ >;
@@ -2,6 +2,6 @@ const sharedConfig = require("tailwind-config/tailwind.config.js");
2
2
 
3
3
  module.exports = {
4
4
  // prefix ui lib classes to avoid conflicting with the app
5
- prefix: "ui-",
5
+ // prefix: "ui-",
6
6
  presets: [sharedConfig],
7
7
  };
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "tsconfig/react-library.json",
3
3
  "include": ["."],
4
- "exclude": ["dist", "build", "node_modules"]
4
+ "exclude": ["dist", "build", "node_modules"],
5
5
  }
package/tsup.config.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import { defineConfig, Options } from "tsup";
2
2
 
3
3
  export default defineConfig((options: Options) => ({
4
- treeshake: true,
5
- splitting: true,
6
- entry: ["src/**/*.tsx"],
4
+ entry: ["src/**/*.{ts,tsx}"],
7
5
  format: ["esm"],
8
6
  dts: true,
9
- minify: true,
7
+ minify: false,
10
8
  clean: true,
11
9
  external: ["react"],
10
+ sourcemap: true,
12
11
  ...options,
13
12
  }));
package/dist/Button.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const Button: () => JSX.Element;
2
-
3
- export { Button };
package/dist/Button.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkFGO3LSHH_js = require('./chunk-FGO3LSHH.js');
4
-
5
-
6
-
7
- Object.defineProperty(exports, 'Button', {
8
- enumerable: true,
9
- get: function () { return chunkFGO3LSHH_js.a; }
10
- });
package/dist/Card.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare const Card: ({ title, cta, href, }: {
2
- title: string;
3
- cta: string;
4
- href: string;
5
- }) => JSX.Element;
6
-
7
- export { Card };
package/dist/Card.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk6OZR7L23_js = require('./chunk-6OZR7L23.js');
4
-
5
-
6
-
7
- Object.defineProperty(exports, 'Card', {
8
- enumerable: true,
9
- get: function () { return chunk6OZR7L23_js.a; }
10
- });
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
-
5
- var n=({title:e,cta:t,href:u})=>jsxRuntime.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:u,className:"ui-group ui-mt-4 ui-rounded-lg ui-border ui-border-transparent ui-overflow-hidden ui-bg-origin-border ui-bg-gradient-to-r ui-from-brandred ui-to-brandblue ui-text-[#6b7280]",children:jsxRuntime.jsxs("div",{className:"ui-p-4 ui-bg-zinc-900 ui-h-full",children:[jsxRuntime.jsx("p",{className:"ui-inline-block ui-text-xl ui-text-white",children:e}),jsxRuntime.jsxs("div",{className:"ui-text-xs ui-mt-4 group-hover:ui-underline",children:[t," \u2192"]})]})});
6
-
7
- exports.a = n;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
-
5
- var u=()=>jsxRuntime.jsx("div",{className:"rounded-md ",children:jsxRuntime.jsx("a",{href:"https://turbo.build/repo/docs",children:jsxRuntime.jsxs("div",{className:"ui-flex ui-w-full ui-items-center ui-justify-center ui-rounded-md ui-border ui-border-transparent ui-px-8 ui-py-3 ui-text-base ui-font-medium ui-no-underline ui-bg-white ui-text-black hover:ui-bg-gray-300 md:ui-py-3 md:ui-px-10 md:ui-text-lg md:ui-leading-6",children:["Read the docs",jsxRuntime.jsx("span",{className:"ui-ml-2 ui-bg-gradient-to-r ui-from-brandred ui-to-brandblue ui-bg-clip-text ui-text-transparent",children:"\u2192"})]})})});
6
-
7
- exports.a = u;
package/dist/index.js DELETED
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkFGO3LSHH_js = require('./chunk-FGO3LSHH.js');
4
- var chunk6OZR7L23_js = require('./chunk-6OZR7L23.js');
5
-
6
-
7
-
8
- Object.defineProperty(exports, 'Button', {
9
- enumerable: true,
10
- get: function () { return chunkFGO3LSHH_js.a; }
11
- });
12
- Object.defineProperty(exports, 'Card', {
13
- enumerable: true,
14
- get: function () { return chunk6OZR7L23_js.a; }
15
- });
package/src/Button.tsx DELETED
@@ -1,16 +0,0 @@
1
- import * as React from "react";
2
-
3
- export const Button = () => {
4
- return (
5
- <div className="rounded-md ">
6
- <a href="https://turbo.build/repo/docs">
7
- <div className="ui-flex ui-w-full ui-items-center ui-justify-center ui-rounded-md ui-border ui-border-transparent ui-px-8 ui-py-3 ui-text-base ui-font-medium ui-no-underline ui-bg-white ui-text-black hover:ui-bg-gray-300 md:ui-py-3 md:ui-px-10 md:ui-text-lg md:ui-leading-6">
8
- Read the docs
9
- <span className="ui-ml-2 ui-bg-gradient-to-r ui-from-brandred ui-to-brandblue ui-bg-clip-text ui-text-transparent">
10
-
11
- </span>
12
- </div>
13
- </a>
14
- </div>
15
- );
16
- };