@copilotkit/react-ui 0.9.0-alpha.1 → 0.9.0-alpha.11
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 +105 -105
- package/CHANGELOG.md +90 -0
- package/dist/components/chat-components/chat-list.mjs +488 -12
- package/dist/components/chat-components/chat-list.mjs.map +1 -1
- package/dist/components/chat-components/chat-message-actions.mjs +184 -7
- package/dist/components/chat-components/chat-message-actions.mjs.map +1 -1
- package/dist/components/chat-components/chat-message.mjs +440 -10
- package/dist/components/chat-components/chat-message.mjs.map +1 -1
- package/dist/components/chat-components/chat-panel.mjs +334 -9
- package/dist/components/chat-components/chat-panel.mjs.map +1 -1
- package/dist/components/chat-components/chat-scroll-anchor.mjs +48 -4
- package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -1
- package/dist/components/chat-components/clear-history.mjs +268 -26
- package/dist/components/chat-components/clear-history.mjs.map +1 -1
- package/dist/components/chat-components/copilot-chat.mjs +931 -21
- package/dist/components/chat-components/copilot-chat.mjs.map +1 -1
- package/dist/components/chat-components/default-empty-screen.mjs +206 -7
- package/dist/components/chat-components/default-empty-screen.mjs.map +1 -1
- package/dist/components/chat-components/external-link.mjs +31 -3
- package/dist/components/chat-components/external-link.mjs.map +1 -1
- package/dist/components/chat-components/markdown.mjs +10 -3
- package/dist/components/chat-components/markdown.mjs.map +1 -1
- package/dist/components/chat-components/prompt-form.mjs +246 -8
- package/dist/components/chat-components/prompt-form.mjs.map +1 -1
- package/dist/components/chat-components/theme-toggle.mjs +133 -15
- package/dist/components/chat-components/theme-toggle.mjs.map +1 -1
- package/dist/components/chat-components/toaster.mjs +6 -3
- package/dist/components/chat-components/toaster.mjs.map +1 -1
- package/dist/components/chat-components/ui/alert-dialog.mjs +216 -5
- package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -1
- package/dist/components/chat-components/ui/badge.mjs +49 -7
- package/dist/components/chat-components/ui/badge.mjs.map +1 -1
- package/dist/components/chat-components/ui/button.mjs +88 -4
- package/dist/components/chat-components/ui/button.mjs.map +1 -1
- package/dist/components/chat-components/ui/codeblock.mjs +298 -7
- package/dist/components/chat-components/ui/codeblock.mjs.map +1 -1
- package/dist/components/chat-components/ui/dialog.mjs +94 -26
- package/dist/components/chat-components/ui/dialog.mjs.map +1 -1
- package/dist/components/chat-components/ui/dropdown-menu.mjs +61 -8
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/chat-components/ui/icons.mjs +551 -4
- package/dist/components/chat-components/ui/icons.mjs.map +1 -1
- package/dist/components/chat-components/ui/input.mjs +48 -7
- package/dist/components/chat-components/ui/input.mjs.map +1 -1
- package/dist/components/chat-components/ui/label.mjs +51 -9
- package/dist/components/chat-components/ui/label.mjs.map +1 -1
- package/dist/components/chat-components/ui/select.mjs +113 -27
- package/dist/components/chat-components/ui/select.mjs.map +1 -1
- package/dist/components/chat-components/ui/separator.mjs +67 -4
- package/dist/components/chat-components/ui/separator.mjs.map +1 -1
- package/dist/components/chat-components/ui/sheet.mjs +93 -24
- package/dist/components/chat-components/ui/sheet.mjs.map +1 -1
- package/dist/components/chat-components/ui/switch.mjs +53 -8
- package/dist/components/chat-components/ui/switch.mjs.map +1 -1
- package/dist/components/chat-components/ui/textarea.mjs +48 -7
- package/dist/components/chat-components/ui/textarea.mjs.map +1 -1
- package/dist/components/chat-components/ui/tooltip.mjs +69 -4
- package/dist/components/chat-components/ui/tooltip.mjs.map +1 -1
- package/dist/components/index.mjs +1057 -25
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +1052 -24
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -1
- package/dist/components/sidebar/copilot-sidebar.mjs +974 -22
- package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -1
- package/dist/components/sidebar/sidebar-context.mjs +10 -3
- package/dist/components/sidebar/sidebar-context.mjs.map +1 -1
- package/dist/context/index.mjs +0 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.mjs +0 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-at-bottom.mjs +21 -3
- package/dist/hooks/use-at-bottom.mjs.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +27 -3
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
- package/dist/hooks/use-enter-submit.mjs +16 -3
- package/dist/hooks/use-enter-submit.mjs.map +1 -1
- package/dist/index.mjs +1057 -28
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.mjs +62 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/types.mjs +0 -2
- package/dist/types/types.mjs.map +1 -1
- package/package.json +6 -5
- package/src/components/chat-components/prompt-form.tsx +3 -3
- package/src/components/chat-components/ui/codeblock.tsx +0 -2
- package/dist/chunk-6LAC5RA2.mjs +0 -28
- package/dist/chunk-6LAC5RA2.mjs.map +0 -1
- package/dist/chunk-6LRNF2VU.mjs +0 -12
- package/dist/chunk-6LRNF2VU.mjs.map +0 -1
- package/dist/chunk-6UJWRTL6.mjs +0 -45
- package/dist/chunk-6UJWRTL6.mjs.map +0 -1
- package/dist/chunk-7NSRDJ5C.mjs +0 -3
- package/dist/chunk-7NSRDJ5C.mjs.map +0 -1
- package/dist/chunk-BIPCPNHG.mjs +0 -18
- package/dist/chunk-BIPCPNHG.mjs.map +0 -1
- package/dist/chunk-BS6RR2DJ.mjs +0 -25
- package/dist/chunk-BS6RR2DJ.mjs.map +0 -1
- package/dist/chunk-DOMJCSI6.mjs +0 -26
- package/dist/chunk-DOMJCSI6.mjs.map +0 -1
- package/dist/chunk-G6R4HFOE.mjs +0 -69
- package/dist/chunk-G6R4HFOE.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -3
- package/dist/chunk-H4VKQGVU.mjs.map +0 -1
- package/dist/chunk-I2AB5FK4.mjs +0 -123
- package/dist/chunk-I2AB5FK4.mjs.map +0 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -3
- package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
- package/dist/chunk-JUPNM7ZR.mjs +0 -75
- package/dist/chunk-JUPNM7ZR.mjs.map +0 -1
- package/dist/chunk-KR7MH7XO.mjs +0 -481
- package/dist/chunk-KR7MH7XO.mjs.map +0 -1
- package/dist/chunk-KU35CEEC.mjs +0 -106
- package/dist/chunk-KU35CEEC.mjs.map +0 -1
- package/dist/chunk-KXJV37FS.mjs +0 -33
- package/dist/chunk-KXJV37FS.mjs.map +0 -1
- package/dist/chunk-MC6KTH4X.mjs +0 -12
- package/dist/chunk-MC6KTH4X.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-N7KB3Z57.mjs +0 -23
- package/dist/chunk-N7KB3Z57.mjs.map +0 -1
- package/dist/chunk-OZYTYKC6.mjs +0 -48
- package/dist/chunk-OZYTYKC6.mjs.map +0 -1
- package/dist/chunk-RSONJDLO.mjs +0 -28
- package/dist/chunk-RSONJDLO.mjs.map +0 -1
- package/dist/chunk-RVWZKSLL.mjs +0 -29
- package/dist/chunk-RVWZKSLL.mjs.map +0 -1
- package/dist/chunk-TVTG3V4F.mjs +0 -40
- package/dist/chunk-TVTG3V4F.mjs.map +0 -1
- package/dist/chunk-U6NJWGTV.mjs +0 -3
- package/dist/chunk-U6NJWGTV.mjs.map +0 -1
- package/dist/chunk-UIJXBILJ.mjs +0 -72
- package/dist/chunk-UIJXBILJ.mjs.map +0 -1
- package/dist/chunk-V6QYUEJR.mjs +0 -47
- package/dist/chunk-V6QYUEJR.mjs.map +0 -1
- package/dist/chunk-VQNV2DHJ.mjs +0 -142
- package/dist/chunk-VQNV2DHJ.mjs.map +0 -1
- package/dist/chunk-VSNDSL6W.mjs +0 -74
- package/dist/chunk-VSNDSL6W.mjs.map +0 -1
- package/dist/chunk-XDJJE4RX.mjs +0 -53
- package/dist/chunk-XDJJE4RX.mjs.map +0 -1
- package/dist/components/chat-components/chat-list.d.ts +0 -8
- package/dist/components/chat-components/chat-message-actions.d.ts +0 -8
- package/dist/components/chat-components/chat-message.d.ts +0 -8
- package/dist/components/chat-components/chat-panel.d.ts +0 -8
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +0 -6
- package/dist/components/chat-components/clear-history.d.ts +0 -9
- package/dist/components/chat-components/copilot-chat.d.ts +0 -12
- package/dist/components/chat-components/default-empty-screen.d.ts +0 -8
- package/dist/components/chat-components/external-link.d.ts +0 -6
- package/dist/components/chat-components/markdown.d.ts +0 -6
- package/dist/components/chat-components/prompt-form.d.ts +0 -9
- package/dist/components/chat-components/theme-toggle.d.ts +0 -3
- package/dist/components/chat-components/toaster.d.ts +0 -1
- package/dist/components/chat-components/ui/alert-dialog.d.ts +0 -20
- package/dist/components/chat-components/ui/badge.d.ts +0 -12
- package/dist/components/chat-components/ui/button.d.ts +0 -14
- package/dist/components/chat-components/ui/codeblock.d.ts +0 -14
- package/dist/components/chat-components/ui/dialog.d.ts +0 -18
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +0 -24
- package/dist/components/chat-components/ui/icons.d.ts +0 -33
- package/dist/components/chat-components/ui/input.d.ts +0 -7
- package/dist/components/chat-components/ui/label.d.ts +0 -8
- package/dist/components/chat-components/ui/select.d.ts +0 -13
- package/dist/components/chat-components/ui/separator.d.ts +0 -6
- package/dist/components/chat-components/ui/sheet.d.ts +0 -19
- package/dist/components/chat-components/ui/switch.d.ts +0 -6
- package/dist/components/chat-components/ui/textarea.d.ts +0 -7
- package/dist/components/chat-components/ui/tooltip.d.ts +0 -9
- package/dist/components/index.d.ts +0 -9
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +0 -8
- package/dist/components/sidebar/copilot-sidebar.d.ts +0 -6
- package/dist/components/sidebar/sidebar-context.d.ts +0 -9
- package/dist/context/index.d.ts +0 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/use-at-bottom.d.ts +0 -3
- package/dist/hooks/use-copy-to-clipboard.d.ts +0 -9
- package/dist/hooks/use-enter-submit.d.ts +0 -8
- package/dist/index.d.ts +0 -9
- package/dist/lib/utils.d.ts +0 -8
- package/dist/lib/utils.test.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/types.d.ts +0 -16
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-components/prompt-form.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,WAAW;AACvB,OAAO,sBAAsB;AAQ7B,OAAO,UAAU;AAsCL,SAOE,KAPF;AA9BL,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAgB;AACd,QAAM,EAAE,SAAS,UAAU,IAAI,eAAe;AAC9C,QAAM,WAAiB,aAA4B,IAAI;AAEvD,EAAM,gBAAU,MAAM;AACpB,QAAI,SAAS,SAAS;AACpB,eAAS,QAAQ,MAAM;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC;AAAA,IACC,UAAU,CAAO,MAAM;AACrB,QAAE,eAAe;AACjB,UAAI,EAAC,+BAAO,SAAQ;AAClB;AAAA,MACF;AACA,eAAS,EAAE;AACX,YAAM,SAAS,KAAK;AAAA,IACtB;AAAA,IACA,KAAK;AAAA,IAEL,+BAAC;AAAA,MAAI,WAAU;AAAA,MACb;AAAA,6BAAC;AAAA,UACC;AAAA,gCAAC;AAAA,cAAe,SAAO;AAAA,cACrB,+BAAC;AAAA,gBACC,MAAK;AAAA,gBACL,WAAW;AAAA,kBACT,eAAe,EAAE,MAAM,MAAM,SAAS,UAAU,CAAC;AAAA,kBACjD;AAAA,gBACF;AAAA,gBAEA;AAAA,sCAAC,YAAS;AAAA,kBACV,oBAAC;AAAA,oBAAK,WAAU;AAAA,oBAAU;AAAA,mBAAQ;AAAA;AAAA,eACpC;AAAA,aACF;AAAA,YACA,oBAAC;AAAA,cAAe;AAAA,aAAQ;AAAA;AAAA,SAC1B;AAAA,QACA,oBAAC;AAAA,UACC,KAAK;AAAA,UACL,UAAU;AAAA,UACV;AAAA,UACA,MAAM;AAAA,UACN,OAAO;AAAA,UACP,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAK;AAAA,UACxC,aAAY;AAAA,UACZ,YAAY;AAAA,UACZ,WAAU;AAAA,SACZ;AAAA,QACA,oBAAC;AAAA,UAAI,WAAU;AAAA,UACb,+BAAC;AAAA,YACC;AAAA,kCAAC;AAAA,gBAAe,SAAO;AAAA,gBACrB,+BAAC;AAAA,kBACC,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,UAAU,aAAa,UAAU;AAAA,kBACjC,WAAU;AAAA,kBAEV;AAAA,wCAAC,kBAAe;AAAA,oBAChB,oBAAC;AAAA,sBAAK,WAAU;AAAA,sBAAU;AAAA,qBAAY;AAAA;AAAA,iBACxC;AAAA,eACF;AAAA,cACA,oBAAC;AAAA,gBAAe;AAAA,eAAY;AAAA;AAAA,WAC9B;AAAA,SACF;AAAA;AAAA,KACF;AAAA,GACF;AAEJ","sourcesContent":["import * as React from \"react\";\nimport TextareaAutosize from \"react-textarea-autosize\";\nimport { UseChatHelpers } from \"ai/react\";\n\nimport { useEnterSubmit } from \"../../hooks/use-enter-submit\";\nimport { cn } from \"../../lib/utils\";\nimport { Button, buttonVariants } from \"./ui/button\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./ui/tooltip\";\nimport { IconArrowElbow, IconPlus } from \"./ui/icons\";\nimport Link from \"next/link\";\n\nexport interface PromptProps\n extends Pick<UseChatHelpers, \"input\" | \"setInput\"> {\n onSubmit: (value: string) => Promise<void>;\n isLoading: boolean;\n}\n\nexport function PromptForm({\n onSubmit,\n input,\n setInput,\n isLoading,\n}: PromptProps) {\n const { formRef, onKeyDown } = useEnterSubmit();\n const inputRef = React.useRef<HTMLTextAreaElement>(null);\n\n React.useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n }\n }, []);\n\n return (\n <form\n onSubmit={async (e) => {\n e.preventDefault();\n if (!input?.trim()) {\n return;\n }\n setInput(\"\");\n await onSubmit(input);\n }}\n ref={formRef}\n >\n <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\">\n <Tooltip>\n <TooltipTrigger asChild>\n <Link\n href=\"/\"\n className={cn(\n buttonVariants({ size: \"sm\", variant: \"outline\" }),\n \"absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4\"\n )}\n >\n <IconPlus />\n <span className=\"sr-only\">New Chat</span>\n </Link>\n </TooltipTrigger>\n <TooltipContent>New Chat</TooltipContent>\n </Tooltip>\n <TextareaAutosize\n ref={inputRef}\n tabIndex={0}\n onKeyDown={onKeyDown}\n rows={1}\n value={input}\n onChange={(e) => setInput(e.target.value)}\n placeholder=\"Send a message.\"\n spellCheck={false}\n className=\"min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm\"\n />\n <div className=\"absolute right-0 top-4 sm:right-4\">\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"submit\"\n size=\"icon\"\n disabled={isLoading || input === \"\"}\n className=\" bg-slate-300\"\n >\n <IconArrowElbow />\n <span className=\"sr-only\">Send message</span>\n </Button>\n </TooltipTrigger>\n <TooltipContent>Send message</TooltipContent>\n </Tooltip>\n </div>\n </div>\n </form>\n );\n}\n"]}
|
package/dist/chunk-KXJV37FS.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
// src/components/chat-components/external-link.tsx
|
|
4
|
-
function ExternalLink({
|
|
5
|
-
href,
|
|
6
|
-
children
|
|
7
|
-
}) {
|
|
8
|
-
return /* @__PURE__ */ jsxs("a", {
|
|
9
|
-
href,
|
|
10
|
-
target: "_blank",
|
|
11
|
-
className: "inline-flex flex-1 justify-center gap-1 leading-4 hover:underline",
|
|
12
|
-
children: [
|
|
13
|
-
/* @__PURE__ */ jsx("span", {
|
|
14
|
-
children
|
|
15
|
-
}),
|
|
16
|
-
/* @__PURE__ */ jsx("svg", {
|
|
17
|
-
"aria-hidden": "true",
|
|
18
|
-
height: "7",
|
|
19
|
-
viewBox: "0 0 6 6",
|
|
20
|
-
width: "7",
|
|
21
|
-
className: "opacity-70",
|
|
22
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
23
|
-
d: "M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z",
|
|
24
|
-
fill: "currentColor"
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
]
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { ExternalLink };
|
|
32
|
-
//# sourceMappingURL=out.js.map
|
|
33
|
-
//# sourceMappingURL=chunk-KXJV37FS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-components/external-link.tsx"],"names":[],"mappings":";AAQI,SAKE,KALF;AARG,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AACD,SACE,qBAAC;AAAA,IACC;AAAA,IACA,QAAO;AAAA,IACP,WAAU;AAAA,IAEV;AAAA,0BAAC;AAAA,QAAM;AAAA,OAAS;AAAA,MAChB,oBAAC;AAAA,QACC,eAAY;AAAA,QACZ,QAAO;AAAA,QACP,SAAQ;AAAA,QACR,OAAM;AAAA,QACN,WAAU;AAAA,QAEV,8BAAC;AAAA,UACC,GAAE;AAAA,UACF,MAAK;AAAA,SACN;AAAA,OACH;AAAA;AAAA,GACF;AAEJ","sourcesContent":["export function ExternalLink({\n href,\n children,\n}: {\n href: string;\n children: React.ReactNode;\n}) {\n return (\n <a\n href={href}\n target=\"_blank\"\n className=\"inline-flex flex-1 justify-center gap-1 leading-4 hover:underline\"\n >\n <span>{children}</span>\n <svg\n aria-hidden=\"true\"\n height=\"7\"\n viewBox=\"0 0 6 6\"\n width=\"7\"\n className=\"opacity-70\"\n >\n <path\n d=\"M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z\"\n fill=\"currentColor\"\n ></path>\n </svg>\n </a>\n );\n}\n"]}
|
package/dist/chunk-MC6KTH4X.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
|
|
3
|
-
// src/components/sidebar/sidebar-context.tsx
|
|
4
|
-
var CopilotSidebarContext = createContext({
|
|
5
|
-
isSidebarOpen: false,
|
|
6
|
-
toggleSidebar: () => {
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export { CopilotSidebarContext };
|
|
11
|
-
//# sourceMappingURL=out.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-MC6KTH4X.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/sidebar/sidebar-context.tsx"],"names":[],"mappings":";AAAA,SAAS,qBAAgC;AAOlC,IAAM,wBAAwB,cAAyC;AAAA,EAC5E,eAAe;AAAA,EACf,eAAe,MAAM;AAAA,EAAC;AACxB,CAAC","sourcesContent":["import { createContext, ReactNode } from \"react\";\n\nexport interface CopilotSidebarContextType {\n isSidebarOpen: boolean;\n toggleSidebar: () => void;\n}\n\nexport const CopilotSidebarContext = createContext<CopilotSidebarContextType>({\n isSidebarOpen: false,\n toggleSidebar: () => {},\n});\n"]}
|
package/dist/chunk-MRXNTQOX.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { __async, __objRest, __spreadProps, __spreadValues };
|
|
54
|
-
//# sourceMappingURL=out.js.map
|
|
55
|
-
//# sourceMappingURL=chunk-MRXNTQOX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/dist/chunk-N7KB3Z57.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
// src/hooks/use-at-bottom.tsx
|
|
4
|
-
function useAtBottom(offset = 0) {
|
|
5
|
-
const [isAtBottom, setIsAtBottom] = React.useState(false);
|
|
6
|
-
React.useEffect(() => {
|
|
7
|
-
const handleScroll = () => {
|
|
8
|
-
setIsAtBottom(
|
|
9
|
-
window.innerHeight + window.scrollY >= document.body.offsetHeight - offset
|
|
10
|
-
);
|
|
11
|
-
};
|
|
12
|
-
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
13
|
-
handleScroll();
|
|
14
|
-
return () => {
|
|
15
|
-
window.removeEventListener("scroll", handleScroll);
|
|
16
|
-
};
|
|
17
|
-
}, [offset]);
|
|
18
|
-
return isAtBottom;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { useAtBottom };
|
|
22
|
-
//# sourceMappingURL=out.js.map
|
|
23
|
-
//# sourceMappingURL=chunk-N7KB3Z57.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-at-bottom.tsx"],"names":[],"mappings":";AAAA,YAAY,WAAW;AAEhB,SAAS,YAAY,SAAS,GAAG;AACtC,QAAM,CAAC,YAAY,aAAa,IAAU,eAAS,KAAK;AAExD,EAAM,gBAAU,MAAM;AACpB,UAAM,eAAe,MAAM;AACzB;AAAA,QACE,OAAO,cAAc,OAAO,WAC1B,SAAS,KAAK,eAAe;AAAA,MACjC;AAAA,IACF;AAEA,WAAO,iBAAiB,UAAU,cAAc,EAAE,SAAS,KAAK,CAAC;AACjE,iBAAa;AAEb,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,YAAY;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEX,SAAO;AACT","sourcesContent":["import * as React from \"react\";\n\nexport function useAtBottom(offset = 0) {\n const [isAtBottom, setIsAtBottom] = React.useState(false);\n\n React.useEffect(() => {\n const handleScroll = () => {\n setIsAtBottom(\n window.innerHeight + window.scrollY >=\n document.body.offsetHeight - offset\n );\n };\n\n window.addEventListener(\"scroll\", handleScroll, { passive: true });\n handleScroll();\n\n return () => {\n window.removeEventListener(\"scroll\", handleScroll);\n };\n }, [offset]);\n\n return isAtBottom;\n}\n"]}
|
package/dist/chunk-OZYTYKC6.mjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { CopilotChat } from './chunk-XDJJE4RX.mjs';
|
|
2
|
-
import { __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
-
import { XMarkIcon } from '@heroicons/react/24/outline';
|
|
4
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
function CopilotSidebar(props) {
|
|
7
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
8
|
-
className: "shadow-lg bg-gray-50 flex flex-col border-l-2",
|
|
9
|
-
style: { width: "100%", height: "100%" },
|
|
10
|
-
children: [
|
|
11
|
-
/* @__PURE__ */ jsx(TopBar, __spreadValues({}, props)),
|
|
12
|
-
/* @__PURE__ */ jsx(CopilotChat, {})
|
|
13
|
-
]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
function TopBar(props) {
|
|
17
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
18
|
-
className: "py-6 flex bg-gray-50 items-center justify-between px-4",
|
|
19
|
-
children: [
|
|
20
|
-
/* @__PURE__ */ jsx("h1", {
|
|
21
|
-
className: "text-base font-semibold leading-6 text-gray-900",
|
|
22
|
-
children: "Copilot Chat"
|
|
23
|
-
}),
|
|
24
|
-
/* @__PURE__ */ jsx("div", {
|
|
25
|
-
className: "ml-3 flex h-7 items-center",
|
|
26
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
27
|
-
type: "button",
|
|
28
|
-
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",
|
|
29
|
-
onClick: () => props.setSidebarOpen(false),
|
|
30
|
-
children: [
|
|
31
|
-
/* @__PURE__ */ jsx("span", {
|
|
32
|
-
className: "sr-only",
|
|
33
|
-
children: "Close panel"
|
|
34
|
-
}),
|
|
35
|
-
/* @__PURE__ */ jsx(XMarkIcon, {
|
|
36
|
-
className: "h-6 w-6",
|
|
37
|
-
"aria-hidden": "true"
|
|
38
|
-
})
|
|
39
|
-
]
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
]
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { CopilotSidebar };
|
|
47
|
-
//# sourceMappingURL=out.js.map
|
|
48
|
-
//# sourceMappingURL=chunk-OZYTYKC6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/sidebar/copilot-sidebar.tsx"],"names":[],"mappings":";;;;;;;;AAmBA,SAAS,iBAAiB;AAVtB,SAIE,KAJF;AAFG,SAAS,eAAe,OAAkC;AAC/D,SACE,qBAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO;AAAA,IAEvC;AAAA,0BAAC,2BAAW,MAAO;AAAA,MACnB,oBAAC,eAAY;AAAA;AAAA,GACf;AAEJ;AAIA,SAAS,OAAO,OAAkC;AAChD,SACE,qBAAC;AAAA,IAAI,WAAU;AAAA,IACb;AAAA,0BAAC;AAAA,QAAG,WAAU;AAAA,QAAkD;AAAA,OAEhE;AAAA,MACA,oBAAC;AAAA,QAAI,WAAU;AAAA,QACb,+BAAC;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,SAAS,MAAM,MAAM,eAAe,KAAK;AAAA,UAEzC;AAAA,gCAAC;AAAA,cAAK,WAAU;AAAA,cAAU;AAAA,aAAW;AAAA,YACrC,oBAAC;AAAA,cAAU,WAAU;AAAA,cAAU,eAAY;AAAA,aAAO;AAAA;AAAA,SACpD;AAAA,OACF;AAAA;AAAA,GACF;AAEJ","sourcesContent":["import React from \"react\";\nimport { CopilotChat } from \"../chat-components/copilot-chat\";\n\nexport interface SidebarProps {\n setSidebarOpen: (open: boolean) => void;\n}\n\nexport function CopilotSidebar(props: SidebarProps): JSX.Element {\n return (\n <div\n className=\"shadow-lg bg-gray-50 flex flex-col border-l-2\"\n style={{ width: \"100%\", height: \"100%\" }}\n >\n <TopBar {...props} />\n <CopilotChat />\n </div>\n );\n}\n\nimport { XMarkIcon } from \"@heroicons/react/24/outline\";\n\nfunction TopBar(props: SidebarProps): JSX.Element {\n return (\n <div className=\"py-6 flex bg-gray-50 items-center justify-between px-4\">\n <h1 className=\"text-base font-semibold leading-6 text-gray-900\">\n Copilot Chat\n </h1>\n <div className=\"ml-3 flex h-7 items-center\">\n <button\n type=\"button\"\n 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\"\n onClick={() => props.setSidebarOpen(false)}\n >\n <span className=\"sr-only\">Close panel</span>\n <XMarkIcon className=\"h-6 w-6\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n );\n}\n"]}
|
package/dist/chunk-RSONJDLO.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useAtBottom } from './chunk-N7KB3Z57.mjs';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useInView } from 'react-intersection-observer';
|
|
4
|
-
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
function ChatScrollAnchor({ trackVisibility }) {
|
|
7
|
-
const isAtBottom = useAtBottom();
|
|
8
|
-
const { ref, entry, inView } = useInView({
|
|
9
|
-
trackVisibility,
|
|
10
|
-
delay: 100,
|
|
11
|
-
rootMargin: "0px 0px -150px 0px"
|
|
12
|
-
});
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
if (isAtBottom && trackVisibility && !inView) {
|
|
15
|
-
entry == null ? void 0 : entry.target.scrollIntoView({
|
|
16
|
-
block: "start"
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}, [inView, entry, isAtBottom, trackVisibility]);
|
|
20
|
-
return /* @__PURE__ */ jsx("div", {
|
|
21
|
-
ref,
|
|
22
|
-
className: "h-px w-full"
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { ChatScrollAnchor };
|
|
27
|
-
//# sourceMappingURL=out.js.map
|
|
28
|
-
//# sourceMappingURL=chunk-RSONJDLO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-components/chat-scroll-anchor.tsx"],"names":[],"mappings":";;;;;AAEA,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAwBjB;AA3BT;AAWO,SAAS,iBAAiB,EAAE,gBAAgB,GAA0B;AAC3E,QAAM,aAAa,YAAY;AAC/B,QAAM,EAAE,KAAK,OAAO,OAAO,IAAI,UAAU;AAAA,IACvC;AAAA,IACA,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAED,EAAM,gBAAU,MAAM;AACpB,QAAI,cAAc,mBAAmB,CAAC,QAAQ;AAC5C,qCAAO,OAAO,eAAe;AAAA,QAC3B,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,YAAY,eAAe,CAAC;AAE/C,SAAO,oBAAC;AAAA,IAAI;AAAA,IAAU,WAAU;AAAA,GAAc;AAChD","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { useAtBottom } from \"../../hooks/use-at-bottom\";\n\ninterface ChatScrollAnchorProps {\n trackVisibility?: boolean;\n}\n\nexport function ChatScrollAnchor({ trackVisibility }: ChatScrollAnchorProps) {\n const isAtBottom = useAtBottom();\n const { ref, entry, inView } = useInView({\n trackVisibility,\n delay: 100,\n rootMargin: \"0px 0px -150px 0px\",\n });\n\n React.useEffect(() => {\n if (isAtBottom && trackVisibility && !inView) {\n entry?.target.scrollIntoView({\n block: \"start\",\n });\n }\n }, [inView, entry, isAtBottom, trackVisibility]);\n\n return <div ref={ref} className=\"h-px w-full\" />;\n}\n"]}
|
package/dist/chunk-RVWZKSLL.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Separator } from './chunk-DOMJCSI6.mjs';
|
|
2
|
-
import { ChatMessage } from './chunk-JUPNM7ZR.mjs';
|
|
3
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
function ChatList({ messages }) {
|
|
6
|
-
const displayedMessages = messages.filter(
|
|
7
|
-
(message) => message.role !== "system"
|
|
8
|
-
);
|
|
9
|
-
if (!displayedMessages.length) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return /* @__PURE__ */ jsx("div", {
|
|
13
|
-
className: "relative mx-auto max-w-2xl px-0",
|
|
14
|
-
children: displayedMessages.map((message, index) => /* @__PURE__ */ jsxs("div", {
|
|
15
|
-
children: [
|
|
16
|
-
/* @__PURE__ */ jsx(ChatMessage, {
|
|
17
|
-
message
|
|
18
|
-
}),
|
|
19
|
-
index < displayedMessages.length - 1 && /* @__PURE__ */ jsx(Separator, {
|
|
20
|
-
className: "my-4 md:my-4"
|
|
21
|
-
})
|
|
22
|
-
]
|
|
23
|
-
}, index))
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { ChatList };
|
|
28
|
-
//# sourceMappingURL=out.js.map
|
|
29
|
-
//# sourceMappingURL=chunk-RVWZKSLL.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-components/chat-list.tsx"],"names":[],"mappings":";;;;;;;;AAsBQ,SACE,KADF;AAbD,SAAS,SAAS,EAAE,SAAS,GAAa;AAE/C,QAAM,oBAAoB,SAAS;AAAA,IACjC,CAAC,YAAY,QAAQ,SAAS;AAAA,EAChC;AAEA,MAAI,CAAC,kBAAkB,QAAQ;AAC7B,WAAO;AAAA,EACT;AAEA,SACE,oBAAC;AAAA,IAAI,WAAU;AAAA,IACZ,4BAAkB,IAAI,CAAC,SAAS,UAC/B,qBAAC;AAAA,MACC;AAAA,4BAAC;AAAA,UAAY;AAAA,SAAkB;AAAA,QAC9B,QAAQ,kBAAkB,SAAS,KAClC,oBAAC;AAAA,UAAU,WAAU;AAAA,SAAe;AAAA;AAAA,OAH9B,KAKV,CACD;AAAA,GACH;AAEJ","sourcesContent":["import { type Message } from \"ai\";\n\nimport { Separator } from \"./ui/separator\";\nimport { ChatMessage } from \"./chat-message\";\n\nexport interface ChatList {\n messages: Message[];\n}\n\nexport function ChatList({ messages }: ChatList) {\n // we don't want to display system messages\n const displayedMessages = messages.filter(\n (message) => message.role !== \"system\"\n );\n\n if (!displayedMessages.length) {\n return null;\n }\n\n return (\n <div className=\"relative mx-auto max-w-2xl px-0\">\n {displayedMessages.map((message, index) => (\n <div key={index}>\n <ChatMessage message={message} />\n {index < displayedMessages.length - 1 && (\n <Separator className=\"my-4 md:my-4\" />\n )}\n </div>\n ))}\n </div>\n );\n}\n"]}
|
package/dist/chunk-TVTG3V4F.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
import { customAlphabet } from 'nanoid';
|
|
4
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
|
-
|
|
6
|
-
function cn(...inputs) {
|
|
7
|
-
return twMerge(clsx(inputs));
|
|
8
|
-
}
|
|
9
|
-
var nanoid = customAlphabet(
|
|
10
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
11
|
-
7
|
|
12
|
-
);
|
|
13
|
-
function fetcher(input, init) {
|
|
14
|
-
return __async(this, null, function* () {
|
|
15
|
-
const res = yield fetch(input, init);
|
|
16
|
-
if (!res.ok) {
|
|
17
|
-
const json = yield res.json();
|
|
18
|
-
if (json.error) {
|
|
19
|
-
const error = new Error(json.error);
|
|
20
|
-
error.status = res.status;
|
|
21
|
-
throw error;
|
|
22
|
-
} else {
|
|
23
|
-
throw new Error("An unexpected error occurred");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return res.json();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function formatDate(input) {
|
|
30
|
-
const date = new Date(input);
|
|
31
|
-
return date.toLocaleDateString("en-US", {
|
|
32
|
-
month: "long",
|
|
33
|
-
day: "numeric",
|
|
34
|
-
year: "numeric"
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { cn, fetcher, formatDate, nanoid };
|
|
39
|
-
//# sourceMappingURL=out.js.map
|
|
40
|
-
//# sourceMappingURL=chunk-TVTG3V4F.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/utils.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AACF;AAEA,SAAsB,QACpB,OACA,MACe;AAAA;AACf,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(\n input: RequestInfo,\n init?: RequestInit\n): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n"]}
|
package/dist/chunk-U6NJWGTV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-UIJXBILJ.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { CopilotSidebar } from './chunk-OZYTYKC6.mjs';
|
|
2
|
-
import { TooltipProvider } from './chunk-BS6RR2DJ.mjs';
|
|
3
|
-
import { CopilotSidebarContext } from './chunk-MC6KTH4X.mjs';
|
|
4
|
-
import { useState, useCallback } from 'react';
|
|
5
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
function CopilotSidebarUIProvider({
|
|
8
|
-
children
|
|
9
|
-
}) {
|
|
10
|
-
const [sidebarOpen, setSidebarOpen] = useState(true);
|
|
11
|
-
const toggleSidebar = useCallback(() => {
|
|
12
|
-
setSidebarOpen((prev) => !prev);
|
|
13
|
-
}, []);
|
|
14
|
-
return /* @__PURE__ */ jsx(CopilotSidebarContext.Provider, {
|
|
15
|
-
value: { isSidebarOpen: sidebarOpen, toggleSidebar },
|
|
16
|
-
children: /* @__PURE__ */ jsx(Fragment, {
|
|
17
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
18
|
-
style: {
|
|
19
|
-
height: "100vh",
|
|
20
|
-
width: "100vw",
|
|
21
|
-
position: "relative"
|
|
22
|
-
},
|
|
23
|
-
children: [
|
|
24
|
-
/* @__PURE__ */ jsx("div", {
|
|
25
|
-
style: {
|
|
26
|
-
overflowY: "auto",
|
|
27
|
-
overflowX: "hidden",
|
|
28
|
-
height: "100%",
|
|
29
|
-
width: sidebarOpen ? "calc(100% - 450px)" : "100%",
|
|
30
|
-
position: "absolute",
|
|
31
|
-
transition: "width 0.5s ease-in-out"
|
|
32
|
-
},
|
|
33
|
-
children: /* @__PURE__ */ jsx("main", {
|
|
34
|
-
children
|
|
35
|
-
})
|
|
36
|
-
}),
|
|
37
|
-
/* @__PURE__ */ jsx("div", {
|
|
38
|
-
style: {
|
|
39
|
-
overflowY: "auto",
|
|
40
|
-
height: "100%",
|
|
41
|
-
width: "450px",
|
|
42
|
-
position: "absolute",
|
|
43
|
-
right: sidebarOpen ? "0" : "-450px",
|
|
44
|
-
transition: "right 0.5s ease-in-out"
|
|
45
|
-
},
|
|
46
|
-
children: /* @__PURE__ */ jsx(TooltipProvider, {
|
|
47
|
-
children: /* @__PURE__ */ jsx(CopilotSidebar, {
|
|
48
|
-
setSidebarOpen
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
}),
|
|
52
|
-
!sidebarOpen && /* @__PURE__ */ jsx("button", {
|
|
53
|
-
onClick: toggleSidebar,
|
|
54
|
-
style: {
|
|
55
|
-
position: "absolute",
|
|
56
|
-
top: "5%",
|
|
57
|
-
right: "20px",
|
|
58
|
-
transform: "translateY(-50%)",
|
|
59
|
-
transition: "opacity 0.5s ease-in-out"
|
|
60
|
-
},
|
|
61
|
-
className: "bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg",
|
|
62
|
-
children: "Open Copilot"
|
|
63
|
-
})
|
|
64
|
-
]
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export { CopilotSidebarUIProvider };
|
|
71
|
-
//# sourceMappingURL=out.js.map
|
|
72
|
-
//# sourceMappingURL=chunk-UIJXBILJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/sidebar/copilot-sidebar-ui-provider.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAA2B,mBAAmB;AAC9C,SAAS,gBAAgB;AAsBnB,mBAkBM,KAjBJ,YADF;AAbC,SAAS,yBAAyB;AAAA,EACvC;AACF,GAAkC;AAChC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,IAAI;AAEnD,QAAM,gBAAgB,YAAY,MAAM;AACtC,mBAAe,CAAC,SAAS,CAAC,IAAI;AAAA,EAChC,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,sBAAsB,UAAtB;AAAA,IACC,OAAO,EAAE,eAAe,aAAa,cAAc;AAAA,IAEnD;AAAA,MACE,+BAAC;AAAA,QACC,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA,QAEA;AAAA,8BAAC;AAAA,YACC,OAAO;AAAA,cACL,WAAW;AAAA,cACX,WAAW;AAAA,cACX,QAAQ;AAAA,cACR,OAAO,cAAc,uBAAuB;AAAA,cAC5C,UAAU;AAAA,cACV,YAAY;AAAA,YACd;AAAA,YAEA,8BAAC;AAAA,cAAM;AAAA,aAAS;AAAA,WAClB;AAAA,UACA,oBAAC;AAAA,YACC,OAAO;AAAA,cACL,WAAW;AAAA,cACX,QAAQ;AAAA,cACR,OAAO;AAAA,cACP,UAAU;AAAA,cACV,OAAO,cAAc,MAAM;AAAA,cAC3B,YAAY;AAAA,YACd;AAAA,YAEA,8BAAC;AAAA,cACC,8BAAC;AAAA,gBAAe;AAAA,eAAgC;AAAA,aAClD;AAAA,WACF;AAAA,UACC,CAAC,eACA,oBAAC;AAAA,YACC,SAAS;AAAA,YACT,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK;AAAA,cACL,OAAO;AAAA,cACP,WAAW;AAAA,cACX,YAAY;AAAA,YACd;AAAA,YACA,WAAU;AAAA,YACX;AAAA,WAED;AAAA;AAAA,OAEJ;AAAA,KACF;AAAA,GACF;AAEJ","sourcesContent":["import React, { ReactNode, useCallback } from \"react\";\nimport { useState } from \"react\";\nimport { CopilotSidebar } from \"./copilot-sidebar\";\nimport { CopilotSidebarContext } from \"./sidebar-context\";\nimport { TooltipProvider } from \"../chat-components/ui/tooltip\";\n\nexport interface CopilotSidebarUIProviderProps {\n children: ReactNode;\n}\n\nexport function CopilotSidebarUIProvider({\n children,\n}: CopilotSidebarUIProviderProps) {\n const [sidebarOpen, setSidebarOpen] = useState(true);\n\n const toggleSidebar = useCallback(() => {\n setSidebarOpen((prev) => !prev);\n }, []);\n\n return (\n <CopilotSidebarContext.Provider\n value={{ isSidebarOpen: sidebarOpen, toggleSidebar }}\n >\n <>\n <div\n style={{\n height: \"100vh\",\n width: \"100vw\",\n position: \"relative\",\n }}\n >\n <div\n style={{\n overflowY: \"auto\",\n overflowX: \"hidden\",\n height: \"100%\",\n width: sidebarOpen ? \"calc(100% - 450px)\" : \"100%\",\n position: \"absolute\",\n transition: \"width 0.5s ease-in-out\", // New\n }}\n >\n <main>{children}</main>\n </div>\n <div\n style={{\n overflowY: \"auto\",\n height: \"100%\",\n width: \"450px\",\n position: \"absolute\",\n right: sidebarOpen ? \"0\" : \"-450px\",\n transition: \"right 0.5s ease-in-out\",\n }}\n >\n <TooltipProvider>\n <CopilotSidebar setSidebarOpen={setSidebarOpen} />\n </TooltipProvider>\n </div>\n {!sidebarOpen && (\n <button\n onClick={toggleSidebar}\n style={{\n position: \"absolute\",\n top: \"5%\",\n right: \"20px\",\n transform: \"translateY(-50%)\",\n transition: \"opacity 0.5s ease-in-out\",\n }}\n className=\"bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg\"\n >\n Open Copilot\n </button>\n )}\n </div>\n </>\n </CopilotSidebarContext.Provider>\n );\n}\n"]}
|
package/dist/chunk-V6QYUEJR.mjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { cn } from './chunk-TVTG3V4F.mjs';
|
|
2
|
-
import { __objRest, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
-
import { cva } from 'class-variance-authority';
|
|
6
|
-
import { jsx } from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
var buttonVariants = cva(
|
|
9
|
-
"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",
|
|
10
|
-
{
|
|
11
|
-
variants: {
|
|
12
|
-
variant: {
|
|
13
|
-
default: "bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
|
|
14
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
15
|
-
outline: "border border-input hover:bg-accent hover:text-accent-foreground",
|
|
16
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
17
|
-
ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
|
|
18
|
-
link: "text-primary underline-offset-4 shadow-none hover:underline"
|
|
19
|
-
},
|
|
20
|
-
size: {
|
|
21
|
-
default: "h-8 px-4 py-2",
|
|
22
|
-
sm: "h-8 rounded-md px-3",
|
|
23
|
-
lg: "h-11 rounded-md px-8",
|
|
24
|
-
icon: "h-8 w-8 p-0"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
defaultVariants: {
|
|
28
|
-
variant: "default",
|
|
29
|
-
size: "default"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
var Button = React.forwardRef(
|
|
34
|
-
(_a, ref) => {
|
|
35
|
-
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
36
|
-
const Comp = asChild ? Slot : "button";
|
|
37
|
-
return /* @__PURE__ */ jsx(Comp, __spreadValues({
|
|
38
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
39
|
-
ref
|
|
40
|
-
}, props));
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
Button.displayName = "Button";
|
|
44
|
-
|
|
45
|
-
export { Button, buttonVariants };
|
|
46
|
-
//# sourceMappingURL=out.js.map
|
|
47
|
-
//# sourceMappingURL=chunk-V6QYUEJR.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-components/ui/button.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AA4CjC;AAxCN,IAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SACE;AAAA,QACF,aACE;AAAA,QACF,SACE;AAAA,QACF,WACE;AAAA,QACF,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAQA,IAAM,SAAe;AAAA,EACnB,CAAC,IAAyD,QAAQ;AAAjE,iBAAE,aAAW,SAAS,MAAM,UAAU,MA3CzC,IA2CG,IAAgD,kBAAhD,IAAgD,CAA9C,aAAW,WAAS,QAAM;AAC3B,UAAM,OAAO,UAAU,OAAO;AAC9B,WACE,oBAAC;AAAA,MACC,WAAW,GAAG,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC,CAAC;AAAA,MAC1D;AAAA,OACI,MACN;AAAA,EAEJ;AACF;AACA,OAAO,cAAc","sourcesContent":["import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../../lib/utils\";\n\nconst buttonVariants = cva(\n \"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\",\n {\n variants: {\n variant: {\n default:\n \"bg-primary text-primary-foreground shadow-md hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline:\n \"border border-input hover:bg-accent hover:text-accent-foreground\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"shadow-none hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 shadow-none hover:underline\",\n },\n size: {\n default: \"h-8 px-4 py-2\",\n sm: \"h-8 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-8 w-8 p-0\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n );\n }\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n"]}
|
package/dist/chunk-VQNV2DHJ.mjs
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { Button } from './chunk-V6QYUEJR.mjs';
|
|
2
|
-
import { IconDownload, IconCheck, IconCopy } from './chunk-KR7MH7XO.mjs';
|
|
3
|
-
import { useCopyToClipboard } from './chunk-6LAC5RA2.mjs';
|
|
4
|
-
import { memo } from 'react';
|
|
5
|
-
import { Prism } from 'react-syntax-highlighter';
|
|
6
|
-
import { coldarkDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
7
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
-
|
|
9
|
-
var programmingLanguages = {
|
|
10
|
-
javascript: ".js",
|
|
11
|
-
python: ".py",
|
|
12
|
-
java: ".java",
|
|
13
|
-
c: ".c",
|
|
14
|
-
cpp: ".cpp",
|
|
15
|
-
"c++": ".cpp",
|
|
16
|
-
"c#": ".cs",
|
|
17
|
-
ruby: ".rb",
|
|
18
|
-
php: ".php",
|
|
19
|
-
swift: ".swift",
|
|
20
|
-
"objective-c": ".m",
|
|
21
|
-
kotlin: ".kt",
|
|
22
|
-
typescript: ".ts",
|
|
23
|
-
go: ".go",
|
|
24
|
-
perl: ".pl",
|
|
25
|
-
rust: ".rs",
|
|
26
|
-
scala: ".scala",
|
|
27
|
-
haskell: ".hs",
|
|
28
|
-
lua: ".lua",
|
|
29
|
-
shell: ".sh",
|
|
30
|
-
sql: ".sql",
|
|
31
|
-
html: ".html",
|
|
32
|
-
css: ".css"
|
|
33
|
-
};
|
|
34
|
-
var generateRandomString = (length, lowercase = false) => {
|
|
35
|
-
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
36
|
-
let result = "";
|
|
37
|
-
for (let i = 0; i < length; i++) {
|
|
38
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
39
|
-
}
|
|
40
|
-
return lowercase ? result.toLowerCase() : result;
|
|
41
|
-
};
|
|
42
|
-
var CodeBlock = memo(({ language, value }) => {
|
|
43
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
44
|
-
const downloadAsFile = () => {
|
|
45
|
-
if (typeof window === "undefined") {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const fileExtension = programmingLanguages[language] || ".file";
|
|
49
|
-
const suggestedFileName = `file-${generateRandomString(
|
|
50
|
-
3,
|
|
51
|
-
true
|
|
52
|
-
)}${fileExtension}`;
|
|
53
|
-
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
54
|
-
if (!fileName) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const blob = new Blob([value], { type: "text/plain" });
|
|
58
|
-
const url = URL.createObjectURL(blob);
|
|
59
|
-
const link = document.createElement("a");
|
|
60
|
-
link.download = fileName;
|
|
61
|
-
link.href = url;
|
|
62
|
-
link.style.display = "none";
|
|
63
|
-
document.body.appendChild(link);
|
|
64
|
-
link.click();
|
|
65
|
-
document.body.removeChild(link);
|
|
66
|
-
URL.revokeObjectURL(url);
|
|
67
|
-
};
|
|
68
|
-
const onCopy = () => {
|
|
69
|
-
if (isCopied)
|
|
70
|
-
return;
|
|
71
|
-
copyToClipboard(value);
|
|
72
|
-
};
|
|
73
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
74
|
-
className: "codeblock relative w-full bg-zinc-950 font-sans",
|
|
75
|
-
children: [
|
|
76
|
-
/* @__PURE__ */ jsxs("div", {
|
|
77
|
-
className: "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100",
|
|
78
|
-
children: [
|
|
79
|
-
/* @__PURE__ */ jsx("span", {
|
|
80
|
-
className: "text-xs lowercase",
|
|
81
|
-
children: language
|
|
82
|
-
}),
|
|
83
|
-
/* @__PURE__ */ jsxs("div", {
|
|
84
|
-
className: "flex items-center space-x-1",
|
|
85
|
-
children: [
|
|
86
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
87
|
-
variant: "ghost",
|
|
88
|
-
className: "hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
|
|
89
|
-
onClick: downloadAsFile,
|
|
90
|
-
size: "icon",
|
|
91
|
-
children: [
|
|
92
|
-
/* @__PURE__ */ jsx(IconDownload, {}),
|
|
93
|
-
/* @__PURE__ */ jsx("span", {
|
|
94
|
-
className: "sr-only",
|
|
95
|
-
children: "Download"
|
|
96
|
-
})
|
|
97
|
-
]
|
|
98
|
-
}),
|
|
99
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
100
|
-
variant: "ghost",
|
|
101
|
-
size: "icon",
|
|
102
|
-
className: "text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
|
|
103
|
-
onClick: onCopy,
|
|
104
|
-
children: [
|
|
105
|
-
isCopied ? /* @__PURE__ */ jsx(IconCheck, {}) : /* @__PURE__ */ jsx(IconCopy, {}),
|
|
106
|
-
/* @__PURE__ */ jsx("span", {
|
|
107
|
-
className: "sr-only",
|
|
108
|
-
children: "Copy code"
|
|
109
|
-
})
|
|
110
|
-
]
|
|
111
|
-
})
|
|
112
|
-
]
|
|
113
|
-
})
|
|
114
|
-
]
|
|
115
|
-
}),
|
|
116
|
-
/* @__PURE__ */ jsx(Prism, {
|
|
117
|
-
language,
|
|
118
|
-
style: coldarkDark,
|
|
119
|
-
PreTag: "div",
|
|
120
|
-
showLineNumbers: true,
|
|
121
|
-
customStyle: {
|
|
122
|
-
margin: 0,
|
|
123
|
-
width: "100%",
|
|
124
|
-
background: "transparent",
|
|
125
|
-
padding: "1.5rem 1rem"
|
|
126
|
-
},
|
|
127
|
-
codeTagProps: {
|
|
128
|
-
style: {
|
|
129
|
-
fontSize: "0.9rem",
|
|
130
|
-
fontFamily: "var(--font-mono)"
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
children: value
|
|
134
|
-
})
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
CodeBlock.displayName = "CodeBlock";
|
|
139
|
-
|
|
140
|
-
export { CodeBlock, generateRandomString, programmingLanguages };
|
|
141
|
-
//# sourceMappingURL=out.js.map
|
|
142
|
-
//# sourceMappingURL=chunk-VQNV2DHJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-components/ui/codeblock.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,SAAa,YAAY;AACzB,SAAS,SAAS,yBAAyB;AAC3C,SAAS,mBAAmB;AA0FpB,cAEE,YAFF;AA9FR;AAmBO,IAAM,uBAAoC;AAAA,EAC/C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,GAAG;AAAA,EACH,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAEP;AAEO,IAAM,uBAAuB,CAAC,QAAgB,YAAY,UAAU;AACzE,QAAM,QAAQ;AACd,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,cAAU,MAAM,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM,MAAM,CAAC;AAAA,EACjE;AACA,SAAO,YAAY,OAAO,YAAY,IAAI;AAC5C;AAEA,IAAM,YAAuB,KAAK,CAAC,EAAE,UAAU,MAAM,MAAM;AACzD,QAAM,EAAE,UAAU,gBAAgB,IAAI,mBAAmB,EAAE,SAAS,IAAK,CAAC;AAE1E,QAAM,iBAAiB,MAAM;AAC3B,QAAI,OAAO,WAAW,aAAa;AACjC;AAAA,IACF;AACA,UAAM,gBAAgB,qBAAqB,aAAa;AACxD,UAAM,oBAAoB,QAAQ;AAAA,MAChC;AAAA,MACA;AAAA,IACF,IAAI;AACJ,UAAM,WAAW,OAAO,OAAO,mBAAyB,iBAAiB;AAEzE,QAAI,CAAC,UAAU;AAEb;AAAA,IACF;AAEA,UAAM,OAAO,IAAI,KAAK,CAAC,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AACrD,UAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,UAAM,OAAO,SAAS,cAAc,GAAG;AACvC,SAAK,WAAW;AAChB,SAAK,OAAO;AACZ,SAAK,MAAM,UAAU;AACrB,aAAS,KAAK,YAAY,IAAI;AAC9B,SAAK,MAAM;AACX,aAAS,KAAK,YAAY,IAAI;AAC9B,QAAI,gBAAgB,GAAG;AAAA,EACzB;AAEA,QAAM,SAAS,MAAM;AACnB,QAAI;AAAU;AACd,oBAAgB,KAAK;AAAA,EACvB;AAEA,SACE,qBAAC;AAAA,IAAI,WAAU;AAAA,IACb;AAAA,2BAAC;AAAA,QAAI,WAAU;AAAA,QACb;AAAA,8BAAC;AAAA,YAAK,WAAU;AAAA,YAAqB;AAAA,WAAS;AAAA,UAC9C,qBAAC;AAAA,YAAI,WAAU;AAAA,YACb;AAAA,mCAAC;AAAA,gBACC,SAAQ;AAAA,gBACR,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,MAAK;AAAA,gBAEL;AAAA,sCAAC,gBAAa;AAAA,kBACd,oBAAC;AAAA,oBAAK,WAAU;AAAA,oBAAU;AAAA,mBAAQ;AAAA;AAAA,eACpC;AAAA,cACA,qBAAC;AAAA,gBACC,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,SAAS;AAAA,gBAER;AAAA,6BAAW,oBAAC,aAAU,IAAK,oBAAC,YAAS;AAAA,kBACtC,oBAAC;AAAA,oBAAK,WAAU;AAAA,oBAAU;AAAA,mBAAS;AAAA;AAAA,eACrC;AAAA;AAAA,WACF;AAAA;AAAA,OACF;AAAA,MACA,oBAAC;AAAA,QACC;AAAA,QACA,OAAO;AAAA,QACP,QAAO;AAAA,QACP,iBAAe;AAAA,QACf,aAAa;AAAA,UACX,QAAQ;AAAA,UACR,OAAO;AAAA,UACP,YAAY;AAAA,UACZ,SAAS;AAAA,QACX;AAAA,QACA,cAAc;AAAA,UACZ,OAAO;AAAA,YACL,UAAU;AAAA,YACV,YAAY;AAAA,UACd;AAAA,QACF;AAAA,QAEC;AAAA,OACH;AAAA;AAAA,GACF;AAEJ,CAAC;AACD,UAAU,cAAc","sourcesContent":["\"use client\";\n\nimport { FC, memo } from \"react\";\nimport { Prism as SyntaxHighlighter } from \"react-syntax-highlighter\";\nimport { coldarkDark } from \"react-syntax-highlighter/dist/cjs/styles/prism\";\n\nimport { useCopyToClipboard } from \"../../../hooks/use-copy-to-clipboard\";\nimport { IconCheck, IconCopy, IconDownload } from \"./icons\";\nimport { Button } from \"./button\";\n\ninterface Props {\n language: string;\n value: string;\n}\n\ninterface languageMap {\n [key: string]: string | undefined;\n}\n\nexport const programmingLanguages: languageMap = {\n javascript: \".js\",\n python: \".py\",\n java: \".java\",\n c: \".c\",\n cpp: \".cpp\",\n \"c++\": \".cpp\",\n \"c#\": \".cs\",\n ruby: \".rb\",\n php: \".php\",\n swift: \".swift\",\n \"objective-c\": \".m\",\n kotlin: \".kt\",\n typescript: \".ts\",\n go: \".go\",\n perl: \".pl\",\n rust: \".rs\",\n scala: \".scala\",\n haskell: \".hs\",\n lua: \".lua\",\n shell: \".sh\",\n sql: \".sql\",\n html: \".html\",\n css: \".css\",\n // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component\n};\n\nexport const generateRandomString = (length: number, lowercase = false) => {\n const chars = \"ABCDEFGHJKLMNPQRSTUVWXY3456789\"; // excluding similar looking characters like Z, 2, I, 1, O, 0\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return lowercase ? result.toLowerCase() : result;\n};\n\nconst CodeBlock: FC<Props> = memo(({ language, value }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });\n\n const downloadAsFile = () => {\n if (typeof window === \"undefined\") {\n return;\n }\n const fileExtension = programmingLanguages[language] || \".file\";\n const suggestedFileName = `file-${generateRandomString(\n 3,\n true\n )}${fileExtension}`;\n const fileName = window.prompt(\"Enter file name\" || \"\", suggestedFileName);\n\n if (!fileName) {\n // User pressed cancel on prompt.\n return;\n }\n\n const blob = new Blob([value], { type: \"text/plain\" });\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.download = fileName;\n link.href = url;\n link.style.display = \"none\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n };\n\n const onCopy = () => {\n if (isCopied) return;\n copyToClipboard(value);\n };\n\n return (\n <div className=\"codeblock relative w-full bg-zinc-950 font-sans\">\n <div className=\"flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100\">\n <span className=\"text-xs lowercase\">{language}</span>\n <div className=\"flex items-center space-x-1\">\n <Button\n variant=\"ghost\"\n className=\"hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0\"\n onClick={downloadAsFile}\n size=\"icon\"\n >\n <IconDownload />\n <span className=\"sr-only\">Download</span>\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0\"\n onClick={onCopy}\n >\n {isCopied ? <IconCheck /> : <IconCopy />}\n <span className=\"sr-only\">Copy code</span>\n </Button>\n </div>\n </div>\n <SyntaxHighlighter\n language={language}\n style={coldarkDark}\n PreTag=\"div\"\n showLineNumbers\n customStyle={{\n margin: 0,\n width: \"100%\",\n background: \"transparent\",\n padding: \"1.5rem 1rem\",\n }}\n codeTagProps={{\n style: {\n fontSize: \"0.9rem\",\n fontFamily: \"var(--font-mono)\",\n },\n }}\n >\n {value}\n </SyntaxHighlighter>\n </div>\n );\n});\nCodeBlock.displayName = \"CodeBlock\";\n\nexport { CodeBlock };\n"]}
|