@copilotkitnext/react 1.52.0-next.5 → 1.52.0-next.7
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/dist/components/WildcardToolCallRender.cjs +13 -13
- package/dist/components/WildcardToolCallRender.cjs.map +1 -1
- package/dist/components/WildcardToolCallRender.mjs +13 -13
- package/dist/components/WildcardToolCallRender.mjs.map +1 -1
- package/dist/components/chat/CopilotChat.cjs.map +1 -1
- package/dist/components/chat/CopilotChat.mjs.map +1 -1
- package/dist/components/chat/CopilotChatAssistantMessage.cjs +36 -28
- package/dist/components/chat/CopilotChatAssistantMessage.cjs.map +1 -1
- package/dist/components/chat/CopilotChatAssistantMessage.mjs +37 -29
- package/dist/components/chat/CopilotChatAssistantMessage.mjs.map +1 -1
- package/dist/components/chat/CopilotChatAudioRecorder.cjs +2 -2
- package/dist/components/chat/CopilotChatAudioRecorder.cjs.map +1 -1
- package/dist/components/chat/CopilotChatAudioRecorder.mjs +2 -2
- package/dist/components/chat/CopilotChatAudioRecorder.mjs.map +1 -1
- package/dist/components/chat/CopilotChatInput.cjs +59 -51
- package/dist/components/chat/CopilotChatInput.cjs.map +1 -1
- package/dist/components/chat/CopilotChatInput.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatInput.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatInput.mjs +59 -51
- package/dist/components/chat/CopilotChatInput.mjs.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.cjs +28 -10
- package/dist/components/chat/CopilotChatMessageView.cjs.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.d.cts +1 -0
- package/dist/components/chat/CopilotChatMessageView.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.d.mts +1 -0
- package/dist/components/chat/CopilotChatMessageView.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.mjs +29 -11
- package/dist/components/chat/CopilotChatMessageView.mjs.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.cjs +24 -20
- package/dist/components/chat/CopilotChatReasoningMessage.cjs.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.mjs +25 -21
- package/dist/components/chat/CopilotChatReasoningMessage.mjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionPill.cjs +6 -5
- package/dist/components/chat/CopilotChatSuggestionPill.cjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionPill.mjs +6 -5
- package/dist/components/chat/CopilotChatSuggestionPill.mjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.cjs +24 -12
- package/dist/components/chat/CopilotChatSuggestionView.cjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.mjs +25 -13
- package/dist/components/chat/CopilotChatSuggestionView.mjs.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.cjs +7 -6
- package/dist/components/chat/CopilotChatToggleButton.cjs.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.mjs +7 -6
- package/dist/components/chat/CopilotChatToggleButton.mjs.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.cjs +29 -24
- package/dist/components/chat/CopilotChatUserMessage.cjs.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.mjs +30 -25
- package/dist/components/chat/CopilotChatUserMessage.mjs.map +1 -1
- package/dist/components/chat/CopilotChatView.cjs +45 -35
- package/dist/components/chat/CopilotChatView.cjs.map +1 -1
- package/dist/components/chat/CopilotChatView.d.cts +1 -1
- package/dist/components/chat/CopilotChatView.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatView.d.mts +1 -1
- package/dist/components/chat/CopilotChatView.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatView.mjs +45 -35
- package/dist/components/chat/CopilotChatView.mjs.map +1 -1
- package/dist/components/chat/CopilotModalHeader.cjs +8 -8
- package/dist/components/chat/CopilotModalHeader.cjs.map +1 -1
- package/dist/components/chat/CopilotModalHeader.d.cts.map +1 -1
- package/dist/components/chat/CopilotModalHeader.d.mts.map +1 -1
- package/dist/components/chat/CopilotModalHeader.mjs +8 -8
- package/dist/components/chat/CopilotModalHeader.mjs.map +1 -1
- package/dist/components/chat/CopilotPopupView.cjs +20 -15
- package/dist/components/chat/CopilotPopupView.cjs.map +1 -1
- package/dist/components/chat/CopilotPopupView.d.cts.map +1 -1
- package/dist/components/chat/CopilotPopupView.d.mts.map +1 -1
- package/dist/components/chat/CopilotPopupView.mjs +20 -15
- package/dist/components/chat/CopilotPopupView.mjs.map +1 -1
- package/dist/components/chat/CopilotSidebarView.cjs +54 -43
- package/dist/components/chat/CopilotSidebarView.cjs.map +1 -1
- package/dist/components/chat/CopilotSidebarView.d.cts.map +1 -1
- package/dist/components/chat/CopilotSidebarView.d.mts.map +1 -1
- package/dist/components/chat/CopilotSidebarView.mjs +55 -44
- package/dist/components/chat/CopilotSidebarView.mjs.map +1 -1
- package/dist/components/ui/button.cjs +42 -42
- package/dist/components/ui/button.cjs.map +1 -1
- package/dist/components/ui/button.mjs +42 -42
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/dropdown-menu.cjs +7 -6
- package/dist/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/components/ui/dropdown-menu.mjs +7 -6
- package/dist/components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/ui/tooltip.cjs +3 -2
- package/dist/components/ui/tooltip.cjs.map +1 -1
- package/dist/components/ui/tooltip.mjs +3 -2
- package/dist/components/ui/tooltip.mjs.map +1 -1
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +2 -1
- package/dist/hooks/index.d.mts +2 -1
- package/dist/hooks/index.mjs +1 -0
- package/dist/hooks/use-component.cjs +18 -5
- package/dist/hooks/use-component.cjs.map +1 -1
- package/dist/hooks/use-component.d.cts +21 -7
- package/dist/hooks/use-component.d.cts.map +1 -1
- package/dist/hooks/use-component.d.mts +21 -7
- package/dist/hooks/use-component.d.mts.map +1 -1
- package/dist/hooks/use-component.mjs +18 -5
- package/dist/hooks/use-component.mjs.map +1 -1
- package/dist/hooks/use-default-render-tool.cjs +2 -2
- package/dist/hooks/use-default-render-tool.cjs.map +1 -1
- package/dist/hooks/use-default-render-tool.d.cts +3 -3
- package/dist/hooks/use-default-render-tool.d.cts.map +1 -1
- package/dist/hooks/use-default-render-tool.d.mts +3 -3
- package/dist/hooks/use-default-render-tool.d.mts.map +1 -1
- package/dist/hooks/use-default-render-tool.mjs +2 -2
- package/dist/hooks/use-default-render-tool.mjs.map +1 -1
- package/dist/hooks/use-interrupt.cjs +171 -0
- package/dist/hooks/use-interrupt.cjs.map +1 -0
- package/dist/hooks/use-interrupt.d.cts +102 -0
- package/dist/hooks/use-interrupt.d.cts.map +1 -0
- package/dist/hooks/use-interrupt.d.mts +102 -0
- package/dist/hooks/use-interrupt.d.mts.map +1 -0
- package/dist/hooks/use-interrupt.mjs +170 -0
- package/dist/hooks/use-interrupt.mjs.map +1 -0
- package/dist/hooks/use-render-tool.cjs +15 -9
- package/dist/hooks/use-render-tool.cjs.map +1 -1
- package/dist/hooks/use-render-tool.d.cts +9 -9
- package/dist/hooks/use-render-tool.d.cts.map +1 -1
- package/dist/hooks/use-render-tool.d.mts +9 -9
- package/dist/hooks/use-render-tool.d.mts.map +1 -1
- package/dist/hooks/use-render-tool.mjs +15 -9
- package/dist/hooks/use-render-tool.mjs.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +2 -1
- package/dist/index.umd.js +625 -342
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/react-core.cjs +13 -0
- package/dist/lib/react-core.cjs.map +1 -1
- package/dist/lib/react-core.d.cts +8 -0
- package/dist/lib/react-core.d.cts.map +1 -1
- package/dist/lib/react-core.d.mts +8 -0
- package/dist/lib/react-core.d.mts.map +1 -1
- package/dist/lib/react-core.mjs +13 -0
- package/dist/lib/react-core.mjs.map +1 -1
- package/dist/lib/utils.cjs +2 -1
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.mjs +3 -2
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/interrupt.d.cts +17 -0
- package/dist/types/interrupt.d.cts.map +1 -0
- package/dist/types/interrupt.d.mts +17 -0
- package/dist/types/interrupt.d.mts.map +1 -0
- package/eslint-rules/README.md +52 -0
- package/eslint-rules/require-cpk-prefix.mjs +375 -0
- package/eslint.config.mjs +17 -0
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatReasoningMessage.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatReasoningMessage.tsx"],"sourcesContent":["import { ReasoningMessage, Message } from \"@ag-ui/core\";\nimport { useState, useEffect, useRef } from \"react\";\nimport { ChevronRight } from \"lucide-react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Streamdown } from \"streamdown\";\nimport { WithSlots, renderSlot } from \"@/lib/slots\";\n\nexport type CopilotChatReasoningMessageProps = WithSlots<\n {\n header: typeof CopilotChatReasoningMessage.Header;\n contentView: typeof CopilotChatReasoningMessage.Content;\n toggle: typeof CopilotChatReasoningMessage.Toggle;\n },\n {\n message: ReasoningMessage;\n messages?: Message[];\n isRunning?: boolean;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\n/**\n * Formats an elapsed duration (in seconds) to a human-readable string.\n */\nfunction formatDuration(seconds: number): string {\n if (seconds < 1) return \"a few seconds\";\n if (seconds < 60) return `${Math.round(seconds)} seconds`;\n const mins = Math.floor(seconds / 60);\n const secs = Math.round(seconds % 60);\n if (secs === 0) return `${mins} minute${mins > 1 ? \"s\" : \"\"}`;\n return `${mins}m ${secs}s`;\n}\n\nexport function CopilotChatReasoningMessage({\n message,\n messages,\n isRunning,\n header,\n contentView,\n toggle,\n children,\n className,\n ...props\n}: CopilotChatReasoningMessageProps) {\n const isLatest = messages?.[messages.length - 1]?.id === message.id;\n const isStreaming = !!(isRunning && isLatest);\n const hasContent = !!(message.content && message.content.length > 0);\n\n // Track elapsed time while streaming\n const startTimeRef = useRef<number | null>(null);\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n if (isStreaming && startTimeRef.current === null) {\n startTimeRef.current = Date.now();\n }\n\n if (!isStreaming && startTimeRef.current !== null) {\n // Final snapshot of elapsed time\n setElapsed((Date.now() - startTimeRef.current) / 1000);\n return;\n }\n\n if (!isStreaming) return;\n\n // Tick every second while streaming\n const timer = setInterval(() => {\n if (startTimeRef.current !== null) {\n setElapsed((Date.now() - startTimeRef.current) / 1000);\n }\n }, 1000);\n return () => clearInterval(timer);\n }, [isStreaming]);\n\n // Default to open while streaming, auto-collapse when streaming ends\n const [isOpen, setIsOpen] = useState(isStreaming);\n\n useEffect(() => {\n if (isStreaming) {\n setIsOpen(true);\n } else {\n // Auto-collapse when reasoning finishes\n setIsOpen(false);\n }\n }, [isStreaming]);\n\n const label = isStreaming\n ? \"Thinking…\"\n : `Thought for ${formatDuration(elapsed)}`;\n\n const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {\n isOpen,\n label,\n hasContent,\n isStreaming,\n onClick: hasContent ? () => setIsOpen((prev) => !prev) : undefined,\n });\n\n const boundContent = renderSlot(\n contentView,\n CopilotChatReasoningMessage.Content,\n {\n isStreaming,\n hasContent,\n children: message.content,\n },\n );\n\n const boundToggle = renderSlot(toggle, CopilotChatReasoningMessage.Toggle, {\n isOpen,\n children: boundContent,\n });\n\n if (children) {\n return (\n
|
|
1
|
+
{"version":3,"file":"CopilotChatReasoningMessage.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatReasoningMessage.tsx"],"sourcesContent":["import { ReasoningMessage, Message } from \"@ag-ui/core\";\nimport { useState, useEffect, useRef } from \"react\";\nimport { ChevronRight } from \"lucide-react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Streamdown } from \"streamdown\";\nimport { WithSlots, renderSlot } from \"@/lib/slots\";\n\nexport type CopilotChatReasoningMessageProps = WithSlots<\n {\n header: typeof CopilotChatReasoningMessage.Header;\n contentView: typeof CopilotChatReasoningMessage.Content;\n toggle: typeof CopilotChatReasoningMessage.Toggle;\n },\n {\n message: ReasoningMessage;\n messages?: Message[];\n isRunning?: boolean;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\n/**\n * Formats an elapsed duration (in seconds) to a human-readable string.\n */\nfunction formatDuration(seconds: number): string {\n if (seconds < 1) return \"a few seconds\";\n if (seconds < 60) return `${Math.round(seconds)} seconds`;\n const mins = Math.floor(seconds / 60);\n const secs = Math.round(seconds % 60);\n if (secs === 0) return `${mins} minute${mins > 1 ? \"s\" : \"\"}`;\n return `${mins}m ${secs}s`;\n}\n\nexport function CopilotChatReasoningMessage({\n message,\n messages,\n isRunning,\n header,\n contentView,\n toggle,\n children,\n className,\n ...props\n}: CopilotChatReasoningMessageProps) {\n const isLatest = messages?.[messages.length - 1]?.id === message.id;\n const isStreaming = !!(isRunning && isLatest);\n const hasContent = !!(message.content && message.content.length > 0);\n\n // Track elapsed time while streaming\n const startTimeRef = useRef<number | null>(null);\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n if (isStreaming && startTimeRef.current === null) {\n startTimeRef.current = Date.now();\n }\n\n if (!isStreaming && startTimeRef.current !== null) {\n // Final snapshot of elapsed time\n setElapsed((Date.now() - startTimeRef.current) / 1000);\n return;\n }\n\n if (!isStreaming) return;\n\n // Tick every second while streaming\n const timer = setInterval(() => {\n if (startTimeRef.current !== null) {\n setElapsed((Date.now() - startTimeRef.current) / 1000);\n }\n }, 1000);\n return () => clearInterval(timer);\n }, [isStreaming]);\n\n // Default to open while streaming, auto-collapse when streaming ends\n const [isOpen, setIsOpen] = useState(isStreaming);\n\n useEffect(() => {\n if (isStreaming) {\n setIsOpen(true);\n } else {\n // Auto-collapse when reasoning finishes\n setIsOpen(false);\n }\n }, [isStreaming]);\n\n const label = isStreaming\n ? \"Thinking…\"\n : `Thought for ${formatDuration(elapsed)}`;\n\n const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {\n isOpen,\n label,\n hasContent,\n isStreaming,\n onClick: hasContent ? () => setIsOpen((prev) => !prev) : undefined,\n });\n\n const boundContent = renderSlot(\n contentView,\n CopilotChatReasoningMessage.Content,\n {\n isStreaming,\n hasContent,\n children: message.content,\n },\n );\n\n const boundToggle = renderSlot(toggle, CopilotChatReasoningMessage.Toggle, {\n isOpen,\n children: boundContent,\n });\n\n if (children) {\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {children({\n header: boundHeader,\n contentView: boundContent,\n toggle: boundToggle,\n message,\n messages,\n isRunning,\n })}\n </div>\n );\n }\n\n return (\n <div\n className={twMerge(\"cpk:my-1\", className)}\n data-message-id={message.id}\n {...props}\n >\n {boundHeader}\n {boundToggle}\n </div>\n );\n}\n\nexport namespace CopilotChatReasoningMessage {\n export const Header: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n isOpen?: boolean;\n label?: string;\n hasContent?: boolean;\n isStreaming?: boolean;\n }\n > = ({\n isOpen,\n label = \"Thoughts\",\n hasContent,\n isStreaming,\n className,\n children: headerChildren,\n ...headerProps\n }) => {\n const isExpandable = !!hasContent;\n\n return (\n <button\n type=\"button\"\n className={twMerge(\n \"cpk:inline-flex cpk:items-center cpk:gap-1 cpk:py-1 cpk:text-sm cpk:text-muted-foreground cpk:transition-colors cpk:select-none\",\n isExpandable\n ? \"cpk:hover:text-foreground cpk:cursor-pointer\"\n : \"cpk:cursor-default\",\n className,\n )}\n aria-expanded={isExpandable ? isOpen : undefined}\n {...headerProps}\n >\n <span className=\"cpk:font-medium\">{label}</span>\n {isStreaming && !hasContent && (\n <span className=\"cpk:inline-flex cpk:items-center cpk:ml-1\">\n <span className=\"cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse\" />\n </span>\n )}\n {headerChildren}\n {isExpandable && (\n <ChevronRight\n className={twMerge(\n \"cpk:size-3.5 cpk:shrink-0 cpk:transition-transform cpk:duration-200\",\n isOpen && \"cpk:rotate-90\",\n )}\n />\n )}\n </button>\n );\n };\n\n export const Content: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n isStreaming?: boolean;\n hasContent?: boolean;\n }\n > = ({\n isStreaming,\n hasContent,\n className,\n children: contentChildren,\n ...contentProps\n }) => {\n // Don't render the content area at all when there's nothing to show\n if (!hasContent && !isStreaming) return null;\n\n return (\n <div\n className={twMerge(\"cpk:pb-2 cpk:pt-1\", className)}\n {...contentProps}\n >\n <div className=\"cpk:text-sm cpk:text-muted-foreground\">\n <Streamdown>\n {typeof contentChildren === \"string\" ? contentChildren : \"\"}\n </Streamdown>\n {isStreaming && hasContent && (\n <span className=\"cpk:inline-flex cpk:items-center cpk:ml-1 cpk:align-middle\">\n <span className=\"cpk:w-2 cpk:h-2 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse-cursor\" />\n </span>\n )}\n </div>\n </div>\n );\n };\n\n export const Toggle: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n isOpen?: boolean;\n }\n > = ({ isOpen, className, children: toggleChildren, ...toggleProps }) => {\n return (\n <div\n className={twMerge(\n \"cpk:grid cpk:transition-[grid-template-rows] cpk:duration-200 cpk:ease-in-out\",\n className,\n )}\n style={{ gridTemplateRows: isOpen ? \"1fr\" : \"0fr\" }}\n {...toggleProps}\n >\n <div className=\"cpk:overflow-hidden\">{toggleChildren}</div>\n </div>\n );\n };\n}\n\nCopilotChatReasoningMessage.Header.displayName =\n \"CopilotChatReasoningMessage.Header\";\nCopilotChatReasoningMessage.Content.displayName =\n \"CopilotChatReasoningMessage.Content\";\nCopilotChatReasoningMessage.Toggle.displayName =\n \"CopilotChatReasoningMessage.Toggle\";\n\nexport default CopilotChatReasoningMessage;\n"],"mappings":";;;;;;;;;;;AAuBA,SAAS,eAAe,SAAyB;AAC/C,KAAI,UAAU,EAAG,QAAO;AACxB,KAAI,UAAU,GAAI,QAAO,GAAG,KAAK,MAAM,QAAQ,CAAC;CAChD,MAAM,OAAO,KAAK,MAAM,UAAU,GAAG;CACrC,MAAM,OAAO,KAAK,MAAM,UAAU,GAAG;AACrC,KAAI,SAAS,EAAG,QAAO,GAAG,KAAK,SAAS,OAAO,IAAI,MAAM;AACzD,QAAO,GAAG,KAAK,IAAI,KAAK;;AAG1B,SAAgB,4BAA4B,EAC1C,SACA,UACA,WACA,QACA,aACA,QACA,UACA,WACA,GAAG,SACgC;CACnC,MAAM,WAAW,WAAW,SAAS,SAAS,IAAI,OAAO,QAAQ;CACjE,MAAM,cAAc,CAAC,EAAE,aAAa;CACpC,MAAM,aAAa,CAAC,EAAE,QAAQ,WAAW,QAAQ,QAAQ,SAAS;CAGlE,MAAM,eAAe,OAAsB,KAAK;CAChD,MAAM,CAAC,SAAS,cAAc,SAAS,EAAE;AAEzC,iBAAgB;AACd,MAAI,eAAe,aAAa,YAAY,KAC1C,cAAa,UAAU,KAAK,KAAK;AAGnC,MAAI,CAAC,eAAe,aAAa,YAAY,MAAM;AAEjD,eAAY,KAAK,KAAK,GAAG,aAAa,WAAW,IAAK;AACtD;;AAGF,MAAI,CAAC,YAAa;EAGlB,MAAM,QAAQ,kBAAkB;AAC9B,OAAI,aAAa,YAAY,KAC3B,aAAY,KAAK,KAAK,GAAG,aAAa,WAAW,IAAK;KAEvD,IAAK;AACR,eAAa,cAAc,MAAM;IAChC,CAAC,YAAY,CAAC;CAGjB,MAAM,CAAC,QAAQ,aAAa,SAAS,YAAY;AAEjD,iBAAgB;AACd,MAAI,YACF,WAAU,KAAK;MAGf,WAAU,MAAM;IAEjB,CAAC,YAAY,CAAC;CAEjB,MAAM,QAAQ,cACV,cACA,eAAe,eAAe,QAAQ;CAE1C,MAAM,cAAc,WAAW,QAAQ,4BAA4B,QAAQ;EACzE;EACA;EACA;EACA;EACA,SAAS,mBAAmB,WAAW,SAAS,CAAC,KAAK,GAAG;EAC1D,CAAC;CAEF,MAAM,eAAe,WACnB,aACA,4BAA4B,SAC5B;EACE;EACA;EACA,UAAU,QAAQ;EACnB,CACF;CAED,MAAM,cAAc,WAAW,QAAQ,4BAA4B,QAAQ;EACzE;EACA,UAAU;EACX,CAAC;AAEF,KAAI,SACF,QACE,oBAAC;EAAI;EAAgB,OAAO,EAAE,SAAS,YAAY;YAChD,SAAS;GACR,QAAQ;GACR,aAAa;GACb,QAAQ;GACR;GACA;GACA;GACD,CAAC;GACE;AAIV,QACE,qBAAC;EACC,WAAW,QAAQ,YAAY,UAAU;EACzC,mBAAiB,QAAQ;EACzB,GAAI;aAEH,aACA;GACG;;;wCAYH,EACH,QACA,QAAQ,YACR,YACA,aACA,WACA,UAAU,gBACV,GAAG,kBACC;EACJ,MAAM,eAAe,CAAC,CAAC;AAEvB,SACE,qBAAC;GACC,MAAK;GACL,WAAW,QACT,mIACA,eACI,iDACA,sBACJ,UACD;GACD,iBAAe,eAAe,SAAS;GACvC,GAAI;;IAEJ,oBAAC;KAAK,WAAU;eAAmB;MAAa;IAC/C,eAAe,CAAC,cACf,oBAAC;KAAK,WAAU;eACd,oBAAC,UAAK,WAAU,mFAAmF;MAC9F;IAER;IACA,gBACC,oBAAC,gBACC,WAAW,QACT,uEACA,UAAU,gBACX,GACD;;IAEG;;yCASR,EACH,aACA,YACA,WACA,UAAU,iBACV,GAAG,mBACC;AAEJ,MAAI,CAAC,cAAc,CAAC,YAAa,QAAO;AAExC,SACE,oBAAC;GACC,WAAW,QAAQ,qBAAqB,UAAU;GAClD,GAAI;aAEJ,qBAAC;IAAI,WAAU;eACb,oBAAC,wBACE,OAAO,oBAAoB,WAAW,kBAAkB,KAC9C,EACZ,eAAe,cACd,oBAAC;KAAK,WAAU;eACd,oBAAC,UAAK,WAAU,sFAAsF;MACjG;KAEL;IACF;;wCAQL,EAAE,QAAQ,WAAW,UAAU,gBAAgB,GAAG,kBAAkB;AACvE,SACE,oBAAC;GACC,WAAW,QACT,iFACA,UACD;GACD,OAAO,EAAE,kBAAkB,SAAS,QAAQ,OAAO;GACnD,GAAI;aAEJ,oBAAC;IAAI,WAAU;cAAuB;KAAqB;IACvD;;;AAKZ,4BAA4B,OAAO,cACjC;AACF,4BAA4B,QAAQ,cAClC;AACF,4BAA4B,OAAO,cACjC;AAEF,0CAAe"}
|
|
@@ -6,12 +6,13 @@ let lucide_react = require("lucide-react");
|
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
|
|
8
8
|
//#region src/components/chat/CopilotChatSuggestionPill.tsx
|
|
9
|
-
const baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground 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:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
10
|
-
const labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
9
|
+
const baseClasses = "group cpk:inline-flex cpk:h-7 cpk:sm:h-8 cpk:items-center cpk:gap-1 cpk:sm:gap-1.5 cpk:rounded-full cpk:border cpk:border-border/60 cpk:bg-background cpk:px-2.5 cpk:sm:px-3 cpk:text-[11px] cpk:sm:text-xs cpk:leading-none cpk:text-foreground cpk:transition-colors cpk:cursor-pointer cpk:hover:bg-accent/60 cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background cpk:disabled:cursor-not-allowed cpk:disabled:text-muted-foreground cpk:disabled:hover:bg-background cpk:disabled:hover:text-muted-foreground cpk:pointer-events-auto";
|
|
10
|
+
const labelClasses = "cpk:whitespace-nowrap cpk:font-medium cpk:leading-none";
|
|
11
11
|
const CopilotChatSuggestionPill = react.default.forwardRef(function CopilotChatSuggestionPill({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
12
12
|
const showIcon = !isLoading && icon;
|
|
13
13
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
14
14
|
ref,
|
|
15
|
+
"data-copilotkit": true,
|
|
15
16
|
"data-slot": "suggestion-pill",
|
|
16
17
|
className: require_utils.cn(baseClasses, className),
|
|
17
18
|
type: type ?? "button",
|
|
@@ -19,13 +20,13 @@ const CopilotChatSuggestionPill = react.default.forwardRef(function CopilotChatS
|
|
|
19
20
|
disabled: isLoading || props.disabled,
|
|
20
21
|
...props,
|
|
21
22
|
children: [isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
22
|
-
className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground",
|
|
23
|
+
className: "cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground",
|
|
23
24
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, {
|
|
24
|
-
className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin",
|
|
25
|
+
className: "cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:animate-spin",
|
|
25
26
|
"aria-hidden": "true"
|
|
26
27
|
})
|
|
27
28
|
}) : showIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28
|
-
className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground",
|
|
29
|
+
className: "cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground",
|
|
29
30
|
children: icon
|
|
30
31
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
31
32
|
className: labelClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatSuggestionPill.cjs","names":["React","cn","Loader2"],"sources":["../../../src/components/chat/CopilotChatSuggestionPill.tsx"],"sourcesContent":["import React from \"react\";\nimport { Loader2 } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CopilotChatSuggestionPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Optional icon to render on the left side when not loading. */\n icon?: React.ReactNode;\n /** Whether the pill should display a loading spinner. */\n isLoading?: boolean;\n}\n\nconst baseClasses =\n \"group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground 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:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto\";\n\nconst labelClasses = \"whitespace-nowrap font-medium leading-none\";\n\nexport const CopilotChatSuggestionPill = React.forwardRef<\n HTMLButtonElement,\n CopilotChatSuggestionPillProps\n>(function CopilotChatSuggestionPill(\n { className, children, icon, isLoading, type, ...props },\n ref,\n) {\n const showIcon = !isLoading && icon;\n\n return (\n <button\n ref={ref}\n data-slot=\"suggestion-pill\"\n className={cn(baseClasses, className)}\n type={type ?? \"button\"}\n aria-busy={isLoading || undefined}\n disabled={isLoading || props.disabled}\n {...props}\n >\n {isLoading ? (\n <span className=\"flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground\">\n <Loader2\n className=\"h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin\"\n aria-hidden=\"true\"\n />\n </span>\n ) : (\n showIcon && (\n <span className=\"flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground\">\n {icon}\n </span>\n )\n )}\n <span className={labelClasses}>{children}</span>\n </button>\n );\n});\n\nCopilotChatSuggestionPill.displayName = \"CopilotChatSuggestionPill\";\n\nexport default CopilotChatSuggestionPill;\n"],"mappings":";;;;;;;;AAWA,MAAM,cACJ;AAEF,MAAM,eAAe;AAErB,MAAa,4BAA4BA,cAAM,WAG7C,SAAS,0BACT,EAAE,WAAW,UAAU,MAAM,WAAW,MAAM,GAAG,SACjD,KACA;CACA,MAAM,WAAW,CAAC,aAAa;AAE/B,QACE,4CAAC;EACM;EACL,aAAU;EACV,WAAWC,iBAAG,aAAa,UAAU;EACrC,MAAM,QAAQ;EACd,aAAW,aAAa;EACxB,UAAU,aAAa,MAAM;EAC7B,GAAI;aAEH,YACC,2CAAC;GAAK,WAAU;aACd,2CAACC;IACC,WAAU;IACV,eAAY;KACZ;IACG,GAEP,YACE,2CAAC;GAAK,WAAU;aACb;IACI,EAGX,2CAAC;GAAK,WAAW;GAAe;IAAgB;GACzC;EAEX;AAEF,0BAA0B,cAAc"}
|
|
1
|
+
{"version":3,"file":"CopilotChatSuggestionPill.cjs","names":["React","cn","Loader2"],"sources":["../../../src/components/chat/CopilotChatSuggestionPill.tsx"],"sourcesContent":["import React from \"react\";\nimport { Loader2 } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CopilotChatSuggestionPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Optional icon to render on the left side when not loading. */\n icon?: React.ReactNode;\n /** Whether the pill should display a loading spinner. */\n isLoading?: boolean;\n}\n\nconst baseClasses =\n \"group cpk:inline-flex cpk:h-7 cpk:sm:h-8 cpk:items-center cpk:gap-1 cpk:sm:gap-1.5 cpk:rounded-full cpk:border cpk:border-border/60 cpk:bg-background cpk:px-2.5 cpk:sm:px-3 cpk:text-[11px] cpk:sm:text-xs cpk:leading-none cpk:text-foreground cpk:transition-colors cpk:cursor-pointer cpk:hover:bg-accent/60 cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background cpk:disabled:cursor-not-allowed cpk:disabled:text-muted-foreground cpk:disabled:hover:bg-background cpk:disabled:hover:text-muted-foreground cpk:pointer-events-auto\";\n\nconst labelClasses = \"cpk:whitespace-nowrap cpk:font-medium cpk:leading-none\";\n\nexport const CopilotChatSuggestionPill = React.forwardRef<\n HTMLButtonElement,\n CopilotChatSuggestionPillProps\n>(function CopilotChatSuggestionPill(\n { className, children, icon, isLoading, type, ...props },\n ref,\n) {\n const showIcon = !isLoading && icon;\n\n return (\n <button\n ref={ref}\n data-copilotkit\n data-slot=\"suggestion-pill\"\n className={cn(baseClasses, className)}\n type={type ?? \"button\"}\n aria-busy={isLoading || undefined}\n disabled={isLoading || props.disabled}\n {...props}\n >\n {isLoading ? (\n <span className=\"cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground\">\n <Loader2\n className=\"cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:animate-spin\"\n aria-hidden=\"true\"\n />\n </span>\n ) : (\n showIcon && (\n <span className=\"cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground\">\n {icon}\n </span>\n )\n )}\n <span className={labelClasses}>{children}</span>\n </button>\n );\n});\n\nCopilotChatSuggestionPill.displayName = \"CopilotChatSuggestionPill\";\n\nexport default CopilotChatSuggestionPill;\n"],"mappings":";;;;;;;;AAWA,MAAM,cACJ;AAEF,MAAM,eAAe;AAErB,MAAa,4BAA4BA,cAAM,WAG7C,SAAS,0BACT,EAAE,WAAW,UAAU,MAAM,WAAW,MAAM,GAAG,SACjD,KACA;CACA,MAAM,WAAW,CAAC,aAAa;AAE/B,QACE,4CAAC;EACM;EACL;EACA,aAAU;EACV,WAAWC,iBAAG,aAAa,UAAU;EACrC,MAAM,QAAQ;EACd,aAAW,aAAa;EACxB,UAAU,aAAa,MAAM;EAC7B,GAAI;aAEH,YACC,2CAAC;GAAK,WAAU;aACd,2CAACC;IACC,WAAU;IACV,eAAY;KACZ;IACG,GAEP,YACE,2CAAC;GAAK,WAAU;aACb;IACI,EAGX,2CAAC;GAAK,WAAW;GAAe;IAAgB;GACzC;EAEX;AAEF,0BAA0B,cAAc"}
|
|
@@ -4,12 +4,13 @@ import { Loader2 } from "lucide-react";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/chat/CopilotChatSuggestionPill.tsx
|
|
7
|
-
const baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground 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:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
8
|
-
const labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
7
|
+
const baseClasses = "group cpk:inline-flex cpk:h-7 cpk:sm:h-8 cpk:items-center cpk:gap-1 cpk:sm:gap-1.5 cpk:rounded-full cpk:border cpk:border-border/60 cpk:bg-background cpk:px-2.5 cpk:sm:px-3 cpk:text-[11px] cpk:sm:text-xs cpk:leading-none cpk:text-foreground cpk:transition-colors cpk:cursor-pointer cpk:hover:bg-accent/60 cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background cpk:disabled:cursor-not-allowed cpk:disabled:text-muted-foreground cpk:disabled:hover:bg-background cpk:disabled:hover:text-muted-foreground cpk:pointer-events-auto";
|
|
8
|
+
const labelClasses = "cpk:whitespace-nowrap cpk:font-medium cpk:leading-none";
|
|
9
9
|
const CopilotChatSuggestionPill = React.forwardRef(function CopilotChatSuggestionPill({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
10
10
|
const showIcon = !isLoading && icon;
|
|
11
11
|
return /* @__PURE__ */ jsxs("button", {
|
|
12
12
|
ref,
|
|
13
|
+
"data-copilotkit": true,
|
|
13
14
|
"data-slot": "suggestion-pill",
|
|
14
15
|
className: cn(baseClasses, className),
|
|
15
16
|
type: type ?? "button",
|
|
@@ -17,13 +18,13 @@ const CopilotChatSuggestionPill = React.forwardRef(function CopilotChatSuggestio
|
|
|
17
18
|
disabled: isLoading || props.disabled,
|
|
18
19
|
...props,
|
|
19
20
|
children: [isLoading ? /* @__PURE__ */ jsx("span", {
|
|
20
|
-
className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground",
|
|
21
|
+
className: "cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground",
|
|
21
22
|
children: /* @__PURE__ */ jsx(Loader2, {
|
|
22
|
-
className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin",
|
|
23
|
+
className: "cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:animate-spin",
|
|
23
24
|
"aria-hidden": "true"
|
|
24
25
|
})
|
|
25
26
|
}) : showIcon && /* @__PURE__ */ jsx("span", {
|
|
26
|
-
className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground",
|
|
27
|
+
className: "cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground",
|
|
27
28
|
children: icon
|
|
28
29
|
}), /* @__PURE__ */ jsx("span", {
|
|
29
30
|
className: labelClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatSuggestionPill.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionPill.tsx"],"sourcesContent":["import React from \"react\";\nimport { Loader2 } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CopilotChatSuggestionPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Optional icon to render on the left side when not loading. */\n icon?: React.ReactNode;\n /** Whether the pill should display a loading spinner. */\n isLoading?: boolean;\n}\n\nconst baseClasses =\n \"group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground 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:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto\";\n\nconst labelClasses = \"whitespace-nowrap font-medium leading-none\";\n\nexport const CopilotChatSuggestionPill = React.forwardRef<\n HTMLButtonElement,\n CopilotChatSuggestionPillProps\n>(function CopilotChatSuggestionPill(\n { className, children, icon, isLoading, type, ...props },\n ref,\n) {\n const showIcon = !isLoading && icon;\n\n return (\n <button\n ref={ref}\n data-slot=\"suggestion-pill\"\n className={cn(baseClasses, className)}\n type={type ?? \"button\"}\n aria-busy={isLoading || undefined}\n disabled={isLoading || props.disabled}\n {...props}\n >\n {isLoading ? (\n <span className=\"flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground\">\n <Loader2\n className=\"h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin\"\n aria-hidden=\"true\"\n />\n </span>\n ) : (\n showIcon && (\n <span className=\"flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground\">\n {icon}\n </span>\n )\n )}\n <span className={labelClasses}>{children}</span>\n </button>\n );\n});\n\nCopilotChatSuggestionPill.displayName = \"CopilotChatSuggestionPill\";\n\nexport default CopilotChatSuggestionPill;\n"],"mappings":";;;;;;AAWA,MAAM,cACJ;AAEF,MAAM,eAAe;AAErB,MAAa,4BAA4B,MAAM,WAG7C,SAAS,0BACT,EAAE,WAAW,UAAU,MAAM,WAAW,MAAM,GAAG,SACjD,KACA;CACA,MAAM,WAAW,CAAC,aAAa;AAE/B,QACE,qBAAC;EACM;EACL,aAAU;EACV,WAAW,GAAG,aAAa,UAAU;EACrC,MAAM,QAAQ;EACd,aAAW,aAAa;EACxB,UAAU,aAAa,MAAM;EAC7B,GAAI;aAEH,YACC,oBAAC;GAAK,WAAU;aACd,oBAAC;IACC,WAAU;IACV,eAAY;KACZ;IACG,GAEP,YACE,oBAAC;GAAK,WAAU;aACb;IACI,EAGX,oBAAC;GAAK,WAAW;GAAe;IAAgB;GACzC;EAEX;AAEF,0BAA0B,cAAc"}
|
|
1
|
+
{"version":3,"file":"CopilotChatSuggestionPill.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionPill.tsx"],"sourcesContent":["import React from \"react\";\nimport { Loader2 } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CopilotChatSuggestionPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Optional icon to render on the left side when not loading. */\n icon?: React.ReactNode;\n /** Whether the pill should display a loading spinner. */\n isLoading?: boolean;\n}\n\nconst baseClasses =\n \"group cpk:inline-flex cpk:h-7 cpk:sm:h-8 cpk:items-center cpk:gap-1 cpk:sm:gap-1.5 cpk:rounded-full cpk:border cpk:border-border/60 cpk:bg-background cpk:px-2.5 cpk:sm:px-3 cpk:text-[11px] cpk:sm:text-xs cpk:leading-none cpk:text-foreground cpk:transition-colors cpk:cursor-pointer cpk:hover:bg-accent/60 cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background cpk:disabled:cursor-not-allowed cpk:disabled:text-muted-foreground cpk:disabled:hover:bg-background cpk:disabled:hover:text-muted-foreground cpk:pointer-events-auto\";\n\nconst labelClasses = \"cpk:whitespace-nowrap cpk:font-medium cpk:leading-none\";\n\nexport const CopilotChatSuggestionPill = React.forwardRef<\n HTMLButtonElement,\n CopilotChatSuggestionPillProps\n>(function CopilotChatSuggestionPill(\n { className, children, icon, isLoading, type, ...props },\n ref,\n) {\n const showIcon = !isLoading && icon;\n\n return (\n <button\n ref={ref}\n data-copilotkit\n data-slot=\"suggestion-pill\"\n className={cn(baseClasses, className)}\n type={type ?? \"button\"}\n aria-busy={isLoading || undefined}\n disabled={isLoading || props.disabled}\n {...props}\n >\n {isLoading ? (\n <span className=\"cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground\">\n <Loader2\n className=\"cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:animate-spin\"\n aria-hidden=\"true\"\n />\n </span>\n ) : (\n showIcon && (\n <span className=\"cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground\">\n {icon}\n </span>\n )\n )}\n <span className={labelClasses}>{children}</span>\n </button>\n );\n});\n\nCopilotChatSuggestionPill.displayName = \"CopilotChatSuggestionPill\";\n\nexport default CopilotChatSuggestionPill;\n"],"mappings":";;;;;;AAWA,MAAM,cACJ;AAEF,MAAM,eAAe;AAErB,MAAa,4BAA4B,MAAM,WAG7C,SAAS,0BACT,EAAE,WAAW,UAAU,MAAM,WAAW,MAAM,GAAG,SACjD,KACA;CACA,MAAM,WAAW,CAAC,aAAa;AAE/B,QACE,qBAAC;EACM;EACL;EACA,aAAU;EACV,WAAW,GAAG,aAAa,UAAU;EACrC,MAAM,QAAQ;EACd,aAAW,aAAa;EACxB,UAAU,aAAa,MAAM;EAC7B,GAAI;aAEH,YACC,oBAAC;GAAK,WAAU;aACd,oBAAC;IACC,WAAU;IACV,eAAY;KACZ;IACG,GAEP,YACE,oBAAC;GAAK,WAAU;aACb;IACI,EAGX,oBAAC;GAAK,WAAW;GAAe;IAAgB;GACzC;EAEX;AAEF,0BAA0B,cAAc"}
|
|
@@ -10,7 +10,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
10
10
|
const DefaultContainer = react.default.forwardRef(function DefaultContainer({ className, ...props }, ref) {
|
|
11
11
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12
12
|
ref,
|
|
13
|
-
|
|
13
|
+
"data-copilotkit": true,
|
|
14
|
+
className: require_utils.cn("cpk:flex cpk:flex-wrap cpk:items-center cpk:gap-1.5 cpk:sm:gap-2 cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:pointer-events-none", className),
|
|
14
15
|
...props
|
|
15
16
|
});
|
|
16
17
|
});
|
|
@@ -35,20 +36,31 @@ const CopilotChatSuggestionView = react.default.forwardRef(function CopilotChatS
|
|
|
35
36
|
return react.default.cloneElement(pill, { key: `${suggestion.title}-${index}` });
|
|
36
37
|
});
|
|
37
38
|
const boundContainer = react.default.cloneElement(ContainerElement, void 0, suggestionElements);
|
|
38
|
-
if (typeof children === "function")
|
|
39
|
-
|
|
40
|
-
suggestion: require_slots.renderSlot(suggestionSlot, require_CopilotChatSuggestionPill.default, {
|
|
39
|
+
if (typeof children === "function") {
|
|
40
|
+
const sampleSuggestion = require_slots.renderSlot(suggestionSlot, require_CopilotChatSuggestionPill.default, {
|
|
41
41
|
children: suggestions[0]?.title ?? "",
|
|
42
42
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
43
43
|
type: "button"
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
46
|
+
"data-copilotkit": true,
|
|
47
|
+
style: { display: "contents" },
|
|
48
|
+
children: children({
|
|
49
|
+
container: boundContainer,
|
|
50
|
+
suggestion: sampleSuggestion,
|
|
51
|
+
suggestions,
|
|
52
|
+
onSelectSuggestion,
|
|
53
|
+
loadingIndexes,
|
|
54
|
+
className,
|
|
55
|
+
...restProps
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
60
|
+
"data-copilotkit": true,
|
|
61
|
+
style: { display: "contents" },
|
|
62
|
+
children: [boundContainer, children]
|
|
63
|
+
});
|
|
52
64
|
return boundContainer;
|
|
53
65
|
});
|
|
54
66
|
CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatSuggestionView.cjs","names":["React","cn","renderSlot","CopilotChatSuggestionPill"],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"sourcesContent":["import React from \"react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport CopilotChatSuggestionPill, {\n CopilotChatSuggestionPillProps,\n} from \"./CopilotChatSuggestionPill\";\n\nconst DefaultContainer = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(function DefaultContainer({ className, ...props }, ref) {\n return (\n <div\n ref={ref}\n className={cn(\n \"flex flex-wrap items-center gap-1.5 sm:gap-2 pl-0 pr-4 sm:px-0 pointer-events-none\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport type CopilotChatSuggestionViewProps = WithSlots<\n {\n container: typeof DefaultContainer;\n suggestion: typeof CopilotChatSuggestionPill;\n },\n {\n suggestions: Suggestion[];\n onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;\n loadingIndexes?: ReadonlyArray<number>;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport const CopilotChatSuggestionView = React.forwardRef<\n HTMLDivElement,\n CopilotChatSuggestionViewProps\n>(function CopilotChatSuggestionView(\n {\n suggestions,\n onSelectSuggestion,\n loadingIndexes,\n container,\n suggestion: suggestionSlot,\n className,\n children,\n ...restProps\n },\n ref,\n) {\n const loadingSet = React.useMemo(() => {\n if (!loadingIndexes || loadingIndexes.length === 0) {\n return new Set<number>();\n }\n return new Set(loadingIndexes);\n }, [loadingIndexes]);\n\n const ContainerElement = renderSlot(container, DefaultContainer, {\n ref,\n className,\n ...restProps,\n });\n\n const suggestionElements = suggestions.map((suggestion, index) => {\n const isLoading = loadingSet.has(index) || suggestion.isLoading === true;\n const pill = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestion.title,\n isLoading,\n type: \"button\",\n onClick: () => onSelectSuggestion?.(suggestion, index),\n });\n\n return React.cloneElement(pill, {\n key: `${suggestion.title}-${index}`,\n });\n });\n\n const boundContainer = React.cloneElement(\n ContainerElement,\n undefined,\n suggestionElements,\n );\n\n if (typeof children === \"function\") {\n const sampleSuggestion = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestions[0]?.title ?? \"\",\n isLoading:\n suggestions.length > 0\n ? loadingSet.has(0) || suggestions[0]?.isLoading === true\n : false,\n type: \"button\",\n });\n\n return (\n
|
|
1
|
+
{"version":3,"file":"CopilotChatSuggestionView.cjs","names":["React","cn","renderSlot","CopilotChatSuggestionPill"],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"sourcesContent":["import React from \"react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport CopilotChatSuggestionPill, {\n CopilotChatSuggestionPillProps,\n} from \"./CopilotChatSuggestionPill\";\n\nconst DefaultContainer = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(function DefaultContainer({ className, ...props }, ref) {\n return (\n <div\n ref={ref}\n data-copilotkit\n className={cn(\n \"cpk:flex cpk:flex-wrap cpk:items-center cpk:gap-1.5 cpk:sm:gap-2 cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:pointer-events-none\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport type CopilotChatSuggestionViewProps = WithSlots<\n {\n container: typeof DefaultContainer;\n suggestion: typeof CopilotChatSuggestionPill;\n },\n {\n suggestions: Suggestion[];\n onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;\n loadingIndexes?: ReadonlyArray<number>;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport const CopilotChatSuggestionView = React.forwardRef<\n HTMLDivElement,\n CopilotChatSuggestionViewProps\n>(function CopilotChatSuggestionView(\n {\n suggestions,\n onSelectSuggestion,\n loadingIndexes,\n container,\n suggestion: suggestionSlot,\n className,\n children,\n ...restProps\n },\n ref,\n) {\n const loadingSet = React.useMemo(() => {\n if (!loadingIndexes || loadingIndexes.length === 0) {\n return new Set<number>();\n }\n return new Set(loadingIndexes);\n }, [loadingIndexes]);\n\n const ContainerElement = renderSlot(container, DefaultContainer, {\n ref,\n className,\n ...restProps,\n });\n\n const suggestionElements = suggestions.map((suggestion, index) => {\n const isLoading = loadingSet.has(index) || suggestion.isLoading === true;\n const pill = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestion.title,\n isLoading,\n type: \"button\",\n onClick: () => onSelectSuggestion?.(suggestion, index),\n });\n\n return React.cloneElement(pill, {\n key: `${suggestion.title}-${index}`,\n });\n });\n\n const boundContainer = React.cloneElement(\n ContainerElement,\n undefined,\n suggestionElements,\n );\n\n if (typeof children === \"function\") {\n const sampleSuggestion = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestions[0]?.title ?? \"\",\n isLoading:\n suggestions.length > 0\n ? loadingSet.has(0) || suggestions[0]?.isLoading === true\n : false,\n type: \"button\",\n });\n\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {children({\n container: boundContainer,\n suggestion: sampleSuggestion,\n suggestions,\n onSelectSuggestion,\n loadingIndexes,\n className,\n ...restProps,\n })}\n </div>\n );\n }\n\n if (children) {\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {boundContainer}\n {children}\n </div>\n );\n }\n\n return boundContainer;\n});\n\nCopilotChatSuggestionView.displayName = \"CopilotChatSuggestionView\";\n\nexport default CopilotChatSuggestionView;\n"],"mappings":";;;;;;;;;AAQA,MAAM,mBAAmBA,cAAM,WAG7B,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;AACxD,QACE,2CAAC;EACM;EACL;EACA,WAAWC,iBACT,0HACA,UACD;EACD,GAAI;GACJ;EAEJ;AAcF,MAAa,4BAA4BD,cAAM,WAG7C,SAAS,0BACT,EACE,aACA,oBACA,gBACA,WACA,YAAY,gBACZ,WACA,UACA,GAAG,aAEL,KACA;CACA,MAAM,aAAaA,cAAM,cAAc;AACrC,MAAI,CAAC,kBAAkB,eAAe,WAAW,EAC/C,wBAAO,IAAI,KAAa;AAE1B,SAAO,IAAI,IAAI,eAAe;IAC7B,CAAC,eAAe,CAAC;CAEpB,MAAM,mBAAmBE,yBAAW,WAAW,kBAAkB;EAC/D;EACA;EACA,GAAG;EACJ,CAAC;CAEF,MAAM,qBAAqB,YAAY,KAAK,YAAY,UAAU;EAChE,MAAM,YAAY,WAAW,IAAI,MAAM,IAAI,WAAW,cAAc;EACpE,MAAM,OAAOA,yBAGX,gBAAgBC,2CAA2B;GAC3C,UAAU,WAAW;GACrB;GACA,MAAM;GACN,eAAe,qBAAqB,YAAY,MAAM;GACvD,CAAC;AAEF,SAAOH,cAAM,aAAa,MAAM,EAC9B,KAAK,GAAG,WAAW,MAAM,GAAG,SAC7B,CAAC;GACF;CAEF,MAAM,iBAAiBA,cAAM,aAC3B,kBACA,QACA,mBACD;AAED,KAAI,OAAO,aAAa,YAAY;EAClC,MAAM,mBAAmBE,yBAGvB,gBAAgBC,2CAA2B;GAC3C,UAAU,YAAY,IAAI,SAAS;GACnC,WACE,YAAY,SAAS,IACjB,WAAW,IAAI,EAAE,IAAI,YAAY,IAAI,cAAc,OACnD;GACN,MAAM;GACP,CAAC;AAEF,SACE,2CAAC;GAAI;GAAgB,OAAO,EAAE,SAAS,YAAY;aAChD,SAAS;IACR,WAAW;IACX,YAAY;IACZ;IACA;IACA;IACA;IACA,GAAG;IACJ,CAAC;IACE;;AAIV,KAAI,SACF,QACE,4CAAC;EAAI;EAAgB,OAAO,EAAE,SAAS,YAAY;aAChD,gBACA;GACG;AAIV,QAAO;EACP;AAEF,0BAA0B,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatSuggestionView.d.cts","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"mappings":";;;;;;cAQM,gBAAA,EAAgB,KAAA,CAAA,yBAAA,CAAA,KAAA,CAAA,cAAA,CAAA,cAAA,IAAA,KAAA,CAAA,aAAA,CAAA,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"CopilotChatSuggestionView.d.cts","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"mappings":";;;;;;cAQM,gBAAA,EAAgB,KAAA,CAAA,yBAAA,CAAA,KAAA,CAAA,cAAA,CAAA,cAAA,IAAA,KAAA,CAAA,aAAA,CAAA,cAAA;AAAA,KAiBV,8BAAA,GAAiC,SAAA;EAEzC,SAAA,SAAkB,gBAAA;EAClB,UAAA,SAAmB,yBAAA;AAAA;EAGnB,WAAA,EAAa,UAAA;EACb,kBAAA,IAAsB,UAAA,EAAY,UAAA,EAAY,KAAA;EAC9C,cAAA,GAAiB,aAAA;AAAA,IACf,KAAA,CAAM,cAAA,CAAe,cAAA;AAAA,cAGd,yBAAA,EAAyB,KAAA,CAAA,yBAAA;;;;;;;;iBANrB,UAAA;0BACS,UAAA,EAAY,UAAA,EAAY,KAAA;qBAC7B,aAAA;EAAA,6CADU,KAAA,CAAO,SAAA;AAAA;eADrB,UAAA;wBACS,UAAA,EAAY,UAAA,EAAY,KAAA;mBAC7B,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatSuggestionView.d.mts","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"mappings":";;;;;;cAQM,gBAAA,EAAgB,KAAA,CAAA,yBAAA,CAAA,KAAA,CAAA,cAAA,CAAA,cAAA,IAAA,KAAA,CAAA,aAAA,CAAA,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"CopilotChatSuggestionView.d.mts","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"mappings":";;;;;;cAQM,gBAAA,EAAgB,KAAA,CAAA,yBAAA,CAAA,KAAA,CAAA,cAAA,CAAA,cAAA,IAAA,KAAA,CAAA,aAAA,CAAA,cAAA;AAAA,KAiBV,8BAAA,GAAiC,SAAA;EAEzC,SAAA,SAAkB,gBAAA;EAClB,UAAA,SAAmB,yBAAA;AAAA;EAGnB,WAAA,EAAa,UAAA;EACb,kBAAA,IAAsB,UAAA,EAAY,UAAA,EAAY,KAAA;EAC9C,cAAA,GAAiB,aAAA;AAAA,IACf,KAAA,CAAM,cAAA,CAAe,cAAA;AAAA,cAGd,yBAAA,EAAyB,KAAA,CAAA,yBAAA;;;;;;;;iBANrB,UAAA;0BACS,UAAA,EAAY,UAAA,EAAY,KAAA;qBAC7B,aAAA;EAAA,6CADU,KAAA,CAAO,SAAA;AAAA;eADrB,UAAA;wBACS,UAAA,EAAY,UAAA,EAAY,KAAA;mBAC7B,aAAA;AAAA"}
|
|
@@ -2,13 +2,14 @@ import { cn } from "../../lib/utils.mjs";
|
|
|
2
2
|
import { renderSlot } from "../../lib/slots.mjs";
|
|
3
3
|
import CopilotChatSuggestionPill from "./CopilotChatSuggestionPill.mjs";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/chat/CopilotChatSuggestionView.tsx
|
|
8
8
|
const DefaultContainer = React.forwardRef(function DefaultContainer({ className, ...props }, ref) {
|
|
9
9
|
return /* @__PURE__ */ jsx("div", {
|
|
10
10
|
ref,
|
|
11
|
-
|
|
11
|
+
"data-copilotkit": true,
|
|
12
|
+
className: cn("cpk:flex cpk:flex-wrap cpk:items-center cpk:gap-1.5 cpk:sm:gap-2 cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:pointer-events-none", className),
|
|
12
13
|
...props
|
|
13
14
|
});
|
|
14
15
|
});
|
|
@@ -33,20 +34,31 @@ const CopilotChatSuggestionView = React.forwardRef(function CopilotChatSuggestio
|
|
|
33
34
|
return React.cloneElement(pill, { key: `${suggestion.title}-${index}` });
|
|
34
35
|
});
|
|
35
36
|
const boundContainer = React.cloneElement(ContainerElement, void 0, suggestionElements);
|
|
36
|
-
if (typeof children === "function")
|
|
37
|
-
|
|
38
|
-
suggestion: renderSlot(suggestionSlot, CopilotChatSuggestionPill, {
|
|
37
|
+
if (typeof children === "function") {
|
|
38
|
+
const sampleSuggestion = renderSlot(suggestionSlot, CopilotChatSuggestionPill, {
|
|
39
39
|
children: suggestions[0]?.title ?? "",
|
|
40
40
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
41
41
|
type: "button"
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ jsx("div", {
|
|
44
|
+
"data-copilotkit": true,
|
|
45
|
+
style: { display: "contents" },
|
|
46
|
+
children: children({
|
|
47
|
+
container: boundContainer,
|
|
48
|
+
suggestion: sampleSuggestion,
|
|
49
|
+
suggestions,
|
|
50
|
+
onSelectSuggestion,
|
|
51
|
+
loadingIndexes,
|
|
52
|
+
className,
|
|
53
|
+
...restProps
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (children) return /* @__PURE__ */ jsxs("div", {
|
|
58
|
+
"data-copilotkit": true,
|
|
59
|
+
style: { display: "contents" },
|
|
60
|
+
children: [boundContainer, children]
|
|
61
|
+
});
|
|
50
62
|
return boundContainer;
|
|
51
63
|
});
|
|
52
64
|
CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatSuggestionView.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"sourcesContent":["import React from \"react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport CopilotChatSuggestionPill, {\n CopilotChatSuggestionPillProps,\n} from \"./CopilotChatSuggestionPill\";\n\nconst DefaultContainer = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(function DefaultContainer({ className, ...props }, ref) {\n return (\n <div\n ref={ref}\n className={cn(\n \"flex flex-wrap items-center gap-1.5 sm:gap-2 pl-0 pr-4 sm:px-0 pointer-events-none\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport type CopilotChatSuggestionViewProps = WithSlots<\n {\n container: typeof DefaultContainer;\n suggestion: typeof CopilotChatSuggestionPill;\n },\n {\n suggestions: Suggestion[];\n onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;\n loadingIndexes?: ReadonlyArray<number>;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport const CopilotChatSuggestionView = React.forwardRef<\n HTMLDivElement,\n CopilotChatSuggestionViewProps\n>(function CopilotChatSuggestionView(\n {\n suggestions,\n onSelectSuggestion,\n loadingIndexes,\n container,\n suggestion: suggestionSlot,\n className,\n children,\n ...restProps\n },\n ref,\n) {\n const loadingSet = React.useMemo(() => {\n if (!loadingIndexes || loadingIndexes.length === 0) {\n return new Set<number>();\n }\n return new Set(loadingIndexes);\n }, [loadingIndexes]);\n\n const ContainerElement = renderSlot(container, DefaultContainer, {\n ref,\n className,\n ...restProps,\n });\n\n const suggestionElements = suggestions.map((suggestion, index) => {\n const isLoading = loadingSet.has(index) || suggestion.isLoading === true;\n const pill = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestion.title,\n isLoading,\n type: \"button\",\n onClick: () => onSelectSuggestion?.(suggestion, index),\n });\n\n return React.cloneElement(pill, {\n key: `${suggestion.title}-${index}`,\n });\n });\n\n const boundContainer = React.cloneElement(\n ContainerElement,\n undefined,\n suggestionElements,\n );\n\n if (typeof children === \"function\") {\n const sampleSuggestion = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestions[0]?.title ?? \"\",\n isLoading:\n suggestions.length > 0\n ? loadingSet.has(0) || suggestions[0]?.isLoading === true\n : false,\n type: \"button\",\n });\n\n return (\n
|
|
1
|
+
{"version":3,"file":"CopilotChatSuggestionView.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatSuggestionView.tsx"],"sourcesContent":["import React from \"react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport CopilotChatSuggestionPill, {\n CopilotChatSuggestionPillProps,\n} from \"./CopilotChatSuggestionPill\";\n\nconst DefaultContainer = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(function DefaultContainer({ className, ...props }, ref) {\n return (\n <div\n ref={ref}\n data-copilotkit\n className={cn(\n \"cpk:flex cpk:flex-wrap cpk:items-center cpk:gap-1.5 cpk:sm:gap-2 cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:pointer-events-none\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport type CopilotChatSuggestionViewProps = WithSlots<\n {\n container: typeof DefaultContainer;\n suggestion: typeof CopilotChatSuggestionPill;\n },\n {\n suggestions: Suggestion[];\n onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;\n loadingIndexes?: ReadonlyArray<number>;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport const CopilotChatSuggestionView = React.forwardRef<\n HTMLDivElement,\n CopilotChatSuggestionViewProps\n>(function CopilotChatSuggestionView(\n {\n suggestions,\n onSelectSuggestion,\n loadingIndexes,\n container,\n suggestion: suggestionSlot,\n className,\n children,\n ...restProps\n },\n ref,\n) {\n const loadingSet = React.useMemo(() => {\n if (!loadingIndexes || loadingIndexes.length === 0) {\n return new Set<number>();\n }\n return new Set(loadingIndexes);\n }, [loadingIndexes]);\n\n const ContainerElement = renderSlot(container, DefaultContainer, {\n ref,\n className,\n ...restProps,\n });\n\n const suggestionElements = suggestions.map((suggestion, index) => {\n const isLoading = loadingSet.has(index) || suggestion.isLoading === true;\n const pill = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestion.title,\n isLoading,\n type: \"button\",\n onClick: () => onSelectSuggestion?.(suggestion, index),\n });\n\n return React.cloneElement(pill, {\n key: `${suggestion.title}-${index}`,\n });\n });\n\n const boundContainer = React.cloneElement(\n ContainerElement,\n undefined,\n suggestionElements,\n );\n\n if (typeof children === \"function\") {\n const sampleSuggestion = renderSlot<\n typeof CopilotChatSuggestionPill,\n CopilotChatSuggestionPillProps\n >(suggestionSlot, CopilotChatSuggestionPill, {\n children: suggestions[0]?.title ?? \"\",\n isLoading:\n suggestions.length > 0\n ? loadingSet.has(0) || suggestions[0]?.isLoading === true\n : false,\n type: \"button\",\n });\n\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {children({\n container: boundContainer,\n suggestion: sampleSuggestion,\n suggestions,\n onSelectSuggestion,\n loadingIndexes,\n className,\n ...restProps,\n })}\n </div>\n );\n }\n\n if (children) {\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {boundContainer}\n {children}\n </div>\n );\n }\n\n return boundContainer;\n});\n\nCopilotChatSuggestionView.displayName = \"CopilotChatSuggestionView\";\n\nexport default CopilotChatSuggestionView;\n"],"mappings":";;;;;;;AAQA,MAAM,mBAAmB,MAAM,WAG7B,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;AACxD,QACE,oBAAC;EACM;EACL;EACA,WAAW,GACT,0HACA,UACD;EACD,GAAI;GACJ;EAEJ;AAcF,MAAa,4BAA4B,MAAM,WAG7C,SAAS,0BACT,EACE,aACA,oBACA,gBACA,WACA,YAAY,gBACZ,WACA,UACA,GAAG,aAEL,KACA;CACA,MAAM,aAAa,MAAM,cAAc;AACrC,MAAI,CAAC,kBAAkB,eAAe,WAAW,EAC/C,wBAAO,IAAI,KAAa;AAE1B,SAAO,IAAI,IAAI,eAAe;IAC7B,CAAC,eAAe,CAAC;CAEpB,MAAM,mBAAmB,WAAW,WAAW,kBAAkB;EAC/D;EACA;EACA,GAAG;EACJ,CAAC;CAEF,MAAM,qBAAqB,YAAY,KAAK,YAAY,UAAU;EAChE,MAAM,YAAY,WAAW,IAAI,MAAM,IAAI,WAAW,cAAc;EACpE,MAAM,OAAO,WAGX,gBAAgB,2BAA2B;GAC3C,UAAU,WAAW;GACrB;GACA,MAAM;GACN,eAAe,qBAAqB,YAAY,MAAM;GACvD,CAAC;AAEF,SAAO,MAAM,aAAa,MAAM,EAC9B,KAAK,GAAG,WAAW,MAAM,GAAG,SAC7B,CAAC;GACF;CAEF,MAAM,iBAAiB,MAAM,aAC3B,kBACA,QACA,mBACD;AAED,KAAI,OAAO,aAAa,YAAY;EAClC,MAAM,mBAAmB,WAGvB,gBAAgB,2BAA2B;GAC3C,UAAU,YAAY,IAAI,SAAS;GACnC,WACE,YAAY,SAAS,IACjB,WAAW,IAAI,EAAE,IAAI,YAAY,IAAI,cAAc,OACnD;GACN,MAAM;GACP,CAAC;AAEF,SACE,oBAAC;GAAI;GAAgB,OAAO,EAAE,SAAS,YAAY;aAChD,SAAS;IACR,WAAW;IACX,YAAY;IACZ;IACA;IACA;IACA;IACA,GAAG;IACJ,CAAC;IACE;;AAIV,KAAI,SACF,QACE,qBAAC;EAAI;EAAgB,OAAO,EAAE,SAAS,YAAY;aAChD,gBACA;GACG;AAIV,QAAO;EACP;AAEF,0BAA0B,cAAc"}
|
|
@@ -9,21 +9,21 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
9
9
|
|
|
10
10
|
//#region src/components/chat/CopilotChatToggleButton.tsx
|
|
11
11
|
const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.MessageCircle, {
|
|
12
|
-
className: require_utils.cn("h-6 w-6", className),
|
|
12
|
+
className: require_utils.cn("cpk:h-6 cpk:w-6", className),
|
|
13
13
|
strokeWidth: 1.75,
|
|
14
14
|
fill: "currentColor",
|
|
15
15
|
...props
|
|
16
16
|
});
|
|
17
17
|
const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
|
|
18
|
-
className: require_utils.cn("h-6 w-6", className),
|
|
18
|
+
className: require_utils.cn("cpk:h-6 cpk:w-6", className),
|
|
19
19
|
strokeWidth: 1.75,
|
|
20
20
|
...props
|
|
21
21
|
});
|
|
22
22
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
23
23
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
24
24
|
const ICON_TRANSITION_STYLE = Object.freeze({ transition: "opacity 120ms ease-out, transform 260ms cubic-bezier(0.22, 1, 0.36, 1)" });
|
|
25
|
-
const ICON_WRAPPER_BASE = "pointer-events-none absolute inset-0 flex items-center justify-center will-change-transform";
|
|
26
|
-
const BUTTON_BASE_CLASSES = require_utils.cn("fixed bottom-6 right-6 z-[1100] flex h-14 w-14 items-center justify-center", "rounded-full border border-primary bg-primary text-primary-foreground", "shadow-sm transition-all duration-200 ease-out", "hover:scale-[1.04] hover:shadow-md", "cursor-pointer", "active:scale-[0.96]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background", "disabled:pointer-events-none disabled:opacity-60");
|
|
25
|
+
const ICON_WRAPPER_BASE = "cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:will-change-transform";
|
|
26
|
+
const BUTTON_BASE_CLASSES = require_utils.cn("cpk:fixed cpk:bottom-6 cpk:right-6 cpk:z-[1100] cpk:flex cpk:h-14 cpk:w-14 cpk:items-center cpk:justify-center", "cpk:rounded-full cpk:border cpk:border-primary cpk:bg-primary cpk:text-primary-foreground", "cpk:shadow-sm cpk:transition-all cpk:duration-200 cpk:ease-out", "cpk:hover:scale-[1.04] cpk:hover:shadow-md", "cpk:cursor-pointer", "cpk:active:scale-[0.96]", "cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-primary/50 cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background", "cpk:disabled:pointer-events-none cpk:disabled:opacity-60");
|
|
27
27
|
const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
28
28
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
29
29
|
const configuration = require_CopilotChatConfigurationProvider.useCopilotChatConfiguration();
|
|
@@ -38,12 +38,12 @@ const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatTog
|
|
|
38
38
|
setModalOpen(!isOpen);
|
|
39
39
|
};
|
|
40
40
|
const renderedOpenIcon = require_slots.renderSlot(openIcon, DefaultOpenIcon, {
|
|
41
|
-
className: "h-6 w-6",
|
|
41
|
+
className: "cpk:h-6 cpk:w-6",
|
|
42
42
|
"aria-hidden": true,
|
|
43
43
|
focusable: false
|
|
44
44
|
});
|
|
45
45
|
const renderedCloseIcon = require_slots.renderSlot(closeIcon, DefaultCloseIcon, {
|
|
46
|
-
className: "h-6 w-6",
|
|
46
|
+
className: "cpk:h-6 cpk:w-6",
|
|
47
47
|
"aria-hidden": true,
|
|
48
48
|
focusable: false
|
|
49
49
|
});
|
|
@@ -72,6 +72,7 @@ const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatTog
|
|
|
72
72
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
73
73
|
ref,
|
|
74
74
|
type: type ?? "button",
|
|
75
|
+
"data-copilotkit": true,
|
|
75
76
|
"data-slot": "chat-toggle-button",
|
|
76
77
|
"data-state": isOpen ? "open" : "closed",
|
|
77
78
|
className: require_utils.cn(BUTTON_BASE_CLASSES, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatToggleButton.cjs","names":["MessageCircle","cn","X","React","useCopilotChatConfiguration","CopilotChatDefaultLabels","renderSlot"],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"sourcesContent":["import React, { useState, MouseEvent } from \"react\";\nimport { MessageCircle, X } from \"lucide-react\";\n\nimport { renderSlot, SlotValue } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport {\n CopilotChatDefaultLabels,\n useCopilotChatConfiguration,\n} from \"@/providers/CopilotChatConfigurationProvider\";\n\nconst DefaultOpenIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => (\n <MessageCircle\n className={cn(\"h-6 w-6\", className)}\n strokeWidth={1.75}\n fill=\"currentColor\"\n {...props}\n />\n);\n\nconst DefaultCloseIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => <X
|
|
1
|
+
{"version":3,"file":"CopilotChatToggleButton.cjs","names":["MessageCircle","cn","X","React","useCopilotChatConfiguration","CopilotChatDefaultLabels","renderSlot"],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"sourcesContent":["import React, { useState, MouseEvent } from \"react\";\nimport { MessageCircle, X } from \"lucide-react\";\n\nimport { renderSlot, SlotValue } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport {\n CopilotChatDefaultLabels,\n useCopilotChatConfiguration,\n} from \"@/providers/CopilotChatConfigurationProvider\";\n\nconst DefaultOpenIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => (\n <MessageCircle\n className={cn(\"cpk:h-6 cpk:w-6\", className)}\n strokeWidth={1.75}\n fill=\"currentColor\"\n {...props}\n />\n);\n\nconst DefaultCloseIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => (\n <X\n className={cn(\"cpk:h-6 cpk:w-6\", className)}\n strokeWidth={1.75}\n {...props}\n />\n);\n\nDefaultOpenIcon.displayName = \"CopilotChatToggleButton.OpenIcon\";\nDefaultCloseIcon.displayName = \"CopilotChatToggleButton.CloseIcon\";\n\nexport interface CopilotChatToggleButtonProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n \"children\"\n> {\n /** Optional slot override for the chat (closed) icon. */\n openIcon?: SlotValue<typeof DefaultOpenIcon>;\n /** Optional slot override for the close icon. */\n closeIcon?: SlotValue<typeof DefaultCloseIcon>;\n}\n\nconst ICON_TRANSITION_STYLE: React.CSSProperties = Object.freeze({\n transition:\n \"opacity 120ms ease-out, transform 260ms cubic-bezier(0.22, 1, 0.36, 1)\",\n});\n\nconst ICON_WRAPPER_BASE =\n \"cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:will-change-transform\";\n\nconst BUTTON_BASE_CLASSES = cn(\n \"cpk:fixed cpk:bottom-6 cpk:right-6 cpk:z-[1100] cpk:flex cpk:h-14 cpk:w-14 cpk:items-center cpk:justify-center\",\n \"cpk:rounded-full cpk:border cpk:border-primary cpk:bg-primary cpk:text-primary-foreground\",\n \"cpk:shadow-sm cpk:transition-all cpk:duration-200 cpk:ease-out\",\n \"cpk:hover:scale-[1.04] cpk:hover:shadow-md\",\n \"cpk:cursor-pointer\",\n \"cpk:active:scale-[0.96]\",\n \"cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-primary/50 cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background\",\n \"cpk:disabled:pointer-events-none cpk:disabled:opacity-60\",\n);\n\nexport const CopilotChatToggleButton = React.forwardRef<\n HTMLButtonElement,\n CopilotChatToggleButtonProps\n>(function CopilotChatToggleButton(\n { openIcon, closeIcon, className, ...buttonProps },\n ref,\n) {\n const { onClick, type, disabled, ...restProps } = buttonProps;\n\n const configuration = useCopilotChatConfiguration();\n const labels = configuration?.labels ?? CopilotChatDefaultLabels;\n\n const [fallbackOpen, setFallbackOpen] = useState(false);\n\n const isOpen = configuration?.isModalOpen ?? fallbackOpen;\n const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n\n if (event.defaultPrevented) {\n return;\n }\n\n const nextOpen = !isOpen;\n setModalOpen(nextOpen);\n };\n\n const renderedOpenIcon = renderSlot(openIcon, DefaultOpenIcon, {\n className: \"cpk:h-6 cpk:w-6\",\n \"aria-hidden\": true,\n focusable: false,\n });\n\n const renderedCloseIcon = renderSlot(closeIcon, DefaultCloseIcon, {\n className: \"cpk:h-6 cpk:w-6\",\n \"aria-hidden\": true,\n focusable: false,\n });\n\n const openIconElement = (\n <span\n aria-hidden=\"true\"\n data-slot=\"chat-toggle-button-open-icon\"\n className={ICON_WRAPPER_BASE}\n style={{\n ...ICON_TRANSITION_STYLE,\n opacity: isOpen ? 0 : 1,\n transform: `scale(${isOpen ? 0.75 : 1}) rotate(${isOpen ? 90 : 0}deg)`,\n }}\n >\n {renderedOpenIcon}\n </span>\n );\n\n const closeIconElement = (\n <span\n aria-hidden=\"true\"\n data-slot=\"chat-toggle-button-close-icon\"\n className={ICON_WRAPPER_BASE}\n style={{\n ...ICON_TRANSITION_STYLE,\n opacity: isOpen ? 1 : 0,\n transform: `scale(${isOpen ? 1 : 0.75}) rotate(${isOpen ? 0 : -90}deg)`,\n }}\n >\n {renderedCloseIcon}\n </span>\n );\n\n return (\n <button\n ref={ref}\n type={type ?? \"button\"}\n data-copilotkit\n data-slot=\"chat-toggle-button\"\n data-state={isOpen ? \"open\" : \"closed\"}\n className={cn(BUTTON_BASE_CLASSES, className)}\n aria-label={\n isOpen ? labels.chatToggleCloseLabel : labels.chatToggleOpenLabel\n }\n aria-pressed={isOpen}\n disabled={disabled}\n onClick={handleClick}\n {...restProps}\n >\n {openIconElement}\n {closeIconElement}\n </button>\n );\n});\nCopilotChatToggleButton.displayName = \"CopilotChatToggleButton\";\nexport default CopilotChatToggleButton;\n\nexport {\n DefaultOpenIcon as CopilotChatToggleButtonOpenIcon,\n DefaultCloseIcon as CopilotChatToggleButtonCloseIcon,\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAM,mBAA4D,EAChE,WACA,GAAG,YAEH,2CAACA;CACC,WAAWC,iBAAG,mBAAmB,UAAU;CAC3C,aAAa;CACb,MAAK;CACL,GAAI;EACJ;AAGJ,MAAM,oBAA6D,EACjE,WACA,GAAG,YAEH,2CAACC;CACC,WAAWD,iBAAG,mBAAmB,UAAU;CAC3C,aAAa;CACb,GAAI;EACJ;AAGJ,gBAAgB,cAAc;AAC9B,iBAAiB,cAAc;AAY/B,MAAM,wBAA6C,OAAO,OAAO,EAC/D,YACE,0EACH,CAAC;AAEF,MAAM,oBACJ;AAEF,MAAM,sBAAsBA,iBAC1B,kHACA,6FACA,kEACA,8CACA,sBACA,2BACA,sKACA,2DACD;AAED,MAAa,0BAA0BE,cAAM,WAG3C,SAAS,wBACT,EAAE,UAAU,WAAW,WAAW,GAAG,eACrC,KACA;CACA,MAAM,EAAE,SAAS,MAAM,UAAU,GAAG,cAAc;CAElD,MAAM,gBAAgBC,sEAA6B;CACnD,MAAM,SAAS,eAAe,UAAUC;CAExC,MAAM,CAAC,cAAc,uCAA4B,MAAM;CAEvD,MAAM,SAAS,eAAe,eAAe;CAC7C,MAAM,eAAe,eAAe,gBAAgB;CAEpD,MAAM,eAAe,UAAyC;AAC5D,MAAI,SACF;AAGF,MAAI,QACF,SAAQ,MAAM;AAGhB,MAAI,MAAM,iBACR;AAIF,eADiB,CAAC,OACI;;CAGxB,MAAM,mBAAmBC,yBAAW,UAAU,iBAAiB;EAC7D,WAAW;EACX,eAAe;EACf,WAAW;EACZ,CAAC;CAEF,MAAM,oBAAoBA,yBAAW,WAAW,kBAAkB;EAChE,WAAW;EACX,eAAe;EACf,WAAW;EACZ,CAAC;CAEF,MAAM,kBACJ,2CAAC;EACC,eAAY;EACZ,aAAU;EACV,WAAW;EACX,OAAO;GACL,GAAG;GACH,SAAS,SAAS,IAAI;GACtB,WAAW,SAAS,SAAS,MAAO,EAAE,WAAW,SAAS,KAAK,EAAE;GAClE;YAEA;GACI;CAGT,MAAM,mBACJ,2CAAC;EACC,eAAY;EACZ,aAAU;EACV,WAAW;EACX,OAAO;GACL,GAAG;GACH,SAAS,SAAS,IAAI;GACtB,WAAW,SAAS,SAAS,IAAI,IAAK,WAAW,SAAS,IAAI,IAAI;GACnE;YAEA;GACI;AAGT,QACE,4CAAC;EACM;EACL,MAAM,QAAQ;EACd;EACA,aAAU;EACV,cAAY,SAAS,SAAS;EAC9B,WAAWL,iBAAG,qBAAqB,UAAU;EAC7C,cACE,SAAS,OAAO,uBAAuB,OAAO;EAEhD,gBAAc;EACJ;EACV,SAAS;EACT,GAAI;aAEH,iBACA;GACM;EAEX;AACF,wBAAwB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatToggleButton.d.cts","names":[],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"mappings":";;;;cAUM,eAAA,EAAiB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,cAYzC,gBAAA,EAAkB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"CopilotChatToggleButton.d.cts","names":[],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"mappings":";;;;cAUM,eAAA,EAAiB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,cAYzC,gBAAA,EAAkB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,UAc/B,4BAAA,SAAqC,IAAA,CACpD,KAAA,CAAM,oBAAA,CAAqB,iBAAA;EAjB5B;EAqBC,QAAA,GAAW,SAAA,QAAiB,eAAA;EA/BiB;EAiC7C,SAAA,GAAY,SAAA,QAAiB,gBAAA;AAAA;AAAA,cAsBlB,uBAAA,EAAuB,KAAA,CAAA,yBAAA,CAAA,4BAAA,GAAA,KAAA,CAAA,aAAA,CAAA,iBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatToggleButton.d.mts","names":[],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"mappings":";;;;cAUM,eAAA,EAAiB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,cAYzC,gBAAA,EAAkB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"CopilotChatToggleButton.d.mts","names":[],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"mappings":";;;;cAUM,eAAA,EAAiB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,cAYzC,gBAAA,EAAkB,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,aAAA;AAAA,UAc/B,4BAAA,SAAqC,IAAA,CACpD,KAAA,CAAM,oBAAA,CAAqB,iBAAA;EAjB5B;EAqBC,QAAA,GAAW,SAAA,QAAiB,eAAA;EA/BiB;EAiC7C,SAAA,GAAY,SAAA,QAAiB,gBAAA;AAAA;AAAA,cAsBlB,uBAAA,EAAuB,KAAA,CAAA,yBAAA,CAAA,4BAAA,GAAA,KAAA,CAAA,aAAA,CAAA,iBAAA"}
|
|
@@ -7,21 +7,21 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
|
|
8
8
|
//#region src/components/chat/CopilotChatToggleButton.tsx
|
|
9
9
|
const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(MessageCircle, {
|
|
10
|
-
className: cn("h-6 w-6", className),
|
|
10
|
+
className: cn("cpk:h-6 cpk:w-6", className),
|
|
11
11
|
strokeWidth: 1.75,
|
|
12
12
|
fill: "currentColor",
|
|
13
13
|
...props
|
|
14
14
|
});
|
|
15
15
|
const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(X, {
|
|
16
|
-
className: cn("h-6 w-6", className),
|
|
16
|
+
className: cn("cpk:h-6 cpk:w-6", className),
|
|
17
17
|
strokeWidth: 1.75,
|
|
18
18
|
...props
|
|
19
19
|
});
|
|
20
20
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
21
21
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
22
22
|
const ICON_TRANSITION_STYLE = Object.freeze({ transition: "opacity 120ms ease-out, transform 260ms cubic-bezier(0.22, 1, 0.36, 1)" });
|
|
23
|
-
const ICON_WRAPPER_BASE = "pointer-events-none absolute inset-0 flex items-center justify-center will-change-transform";
|
|
24
|
-
const BUTTON_BASE_CLASSES = cn("fixed bottom-6 right-6 z-[1100] flex h-14 w-14 items-center justify-center", "rounded-full border border-primary bg-primary text-primary-foreground", "shadow-sm transition-all duration-200 ease-out", "hover:scale-[1.04] hover:shadow-md", "cursor-pointer", "active:scale-[0.96]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background", "disabled:pointer-events-none disabled:opacity-60");
|
|
23
|
+
const ICON_WRAPPER_BASE = "cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:will-change-transform";
|
|
24
|
+
const BUTTON_BASE_CLASSES = cn("cpk:fixed cpk:bottom-6 cpk:right-6 cpk:z-[1100] cpk:flex cpk:h-14 cpk:w-14 cpk:items-center cpk:justify-center", "cpk:rounded-full cpk:border cpk:border-primary cpk:bg-primary cpk:text-primary-foreground", "cpk:shadow-sm cpk:transition-all cpk:duration-200 cpk:ease-out", "cpk:hover:scale-[1.04] cpk:hover:shadow-md", "cpk:cursor-pointer", "cpk:active:scale-[0.96]", "cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-primary/50 cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background", "cpk:disabled:pointer-events-none cpk:disabled:opacity-60");
|
|
25
25
|
const CopilotChatToggleButton = React.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
26
26
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
27
27
|
const configuration = useCopilotChatConfiguration();
|
|
@@ -36,12 +36,12 @@ const CopilotChatToggleButton = React.forwardRef(function CopilotChatToggleButto
|
|
|
36
36
|
setModalOpen(!isOpen);
|
|
37
37
|
};
|
|
38
38
|
const renderedOpenIcon = renderSlot(openIcon, DefaultOpenIcon, {
|
|
39
|
-
className: "h-6 w-6",
|
|
39
|
+
className: "cpk:h-6 cpk:w-6",
|
|
40
40
|
"aria-hidden": true,
|
|
41
41
|
focusable: false
|
|
42
42
|
});
|
|
43
43
|
const renderedCloseIcon = renderSlot(closeIcon, DefaultCloseIcon, {
|
|
44
|
-
className: "h-6 w-6",
|
|
44
|
+
className: "cpk:h-6 cpk:w-6",
|
|
45
45
|
"aria-hidden": true,
|
|
46
46
|
focusable: false
|
|
47
47
|
});
|
|
@@ -70,6 +70,7 @@ const CopilotChatToggleButton = React.forwardRef(function CopilotChatToggleButto
|
|
|
70
70
|
return /* @__PURE__ */ jsxs("button", {
|
|
71
71
|
ref,
|
|
72
72
|
type: type ?? "button",
|
|
73
|
+
"data-copilotkit": true,
|
|
73
74
|
"data-slot": "chat-toggle-button",
|
|
74
75
|
"data-state": isOpen ? "open" : "closed",
|
|
75
76
|
className: cn(BUTTON_BASE_CLASSES, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatToggleButton.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"sourcesContent":["import React, { useState, MouseEvent } from \"react\";\nimport { MessageCircle, X } from \"lucide-react\";\n\nimport { renderSlot, SlotValue } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport {\n CopilotChatDefaultLabels,\n useCopilotChatConfiguration,\n} from \"@/providers/CopilotChatConfigurationProvider\";\n\nconst DefaultOpenIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => (\n <MessageCircle\n className={cn(\"h-6 w-6\", className)}\n strokeWidth={1.75}\n fill=\"currentColor\"\n {...props}\n />\n);\n\nconst DefaultCloseIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => <X
|
|
1
|
+
{"version":3,"file":"CopilotChatToggleButton.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatToggleButton.tsx"],"sourcesContent":["import React, { useState, MouseEvent } from \"react\";\nimport { MessageCircle, X } from \"lucide-react\";\n\nimport { renderSlot, SlotValue } from \"@/lib/slots\";\nimport { cn } from \"@/lib/utils\";\nimport {\n CopilotChatDefaultLabels,\n useCopilotChatConfiguration,\n} from \"@/providers/CopilotChatConfigurationProvider\";\n\nconst DefaultOpenIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => (\n <MessageCircle\n className={cn(\"cpk:h-6 cpk:w-6\", className)}\n strokeWidth={1.75}\n fill=\"currentColor\"\n {...props}\n />\n);\n\nconst DefaultCloseIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({\n className,\n ...props\n}) => (\n <X\n className={cn(\"cpk:h-6 cpk:w-6\", className)}\n strokeWidth={1.75}\n {...props}\n />\n);\n\nDefaultOpenIcon.displayName = \"CopilotChatToggleButton.OpenIcon\";\nDefaultCloseIcon.displayName = \"CopilotChatToggleButton.CloseIcon\";\n\nexport interface CopilotChatToggleButtonProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n \"children\"\n> {\n /** Optional slot override for the chat (closed) icon. */\n openIcon?: SlotValue<typeof DefaultOpenIcon>;\n /** Optional slot override for the close icon. */\n closeIcon?: SlotValue<typeof DefaultCloseIcon>;\n}\n\nconst ICON_TRANSITION_STYLE: React.CSSProperties = Object.freeze({\n transition:\n \"opacity 120ms ease-out, transform 260ms cubic-bezier(0.22, 1, 0.36, 1)\",\n});\n\nconst ICON_WRAPPER_BASE =\n \"cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:will-change-transform\";\n\nconst BUTTON_BASE_CLASSES = cn(\n \"cpk:fixed cpk:bottom-6 cpk:right-6 cpk:z-[1100] cpk:flex cpk:h-14 cpk:w-14 cpk:items-center cpk:justify-center\",\n \"cpk:rounded-full cpk:border cpk:border-primary cpk:bg-primary cpk:text-primary-foreground\",\n \"cpk:shadow-sm cpk:transition-all cpk:duration-200 cpk:ease-out\",\n \"cpk:hover:scale-[1.04] cpk:hover:shadow-md\",\n \"cpk:cursor-pointer\",\n \"cpk:active:scale-[0.96]\",\n \"cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-primary/50 cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background\",\n \"cpk:disabled:pointer-events-none cpk:disabled:opacity-60\",\n);\n\nexport const CopilotChatToggleButton = React.forwardRef<\n HTMLButtonElement,\n CopilotChatToggleButtonProps\n>(function CopilotChatToggleButton(\n { openIcon, closeIcon, className, ...buttonProps },\n ref,\n) {\n const { onClick, type, disabled, ...restProps } = buttonProps;\n\n const configuration = useCopilotChatConfiguration();\n const labels = configuration?.labels ?? CopilotChatDefaultLabels;\n\n const [fallbackOpen, setFallbackOpen] = useState(false);\n\n const isOpen = configuration?.isModalOpen ?? fallbackOpen;\n const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n\n if (event.defaultPrevented) {\n return;\n }\n\n const nextOpen = !isOpen;\n setModalOpen(nextOpen);\n };\n\n const renderedOpenIcon = renderSlot(openIcon, DefaultOpenIcon, {\n className: \"cpk:h-6 cpk:w-6\",\n \"aria-hidden\": true,\n focusable: false,\n });\n\n const renderedCloseIcon = renderSlot(closeIcon, DefaultCloseIcon, {\n className: \"cpk:h-6 cpk:w-6\",\n \"aria-hidden\": true,\n focusable: false,\n });\n\n const openIconElement = (\n <span\n aria-hidden=\"true\"\n data-slot=\"chat-toggle-button-open-icon\"\n className={ICON_WRAPPER_BASE}\n style={{\n ...ICON_TRANSITION_STYLE,\n opacity: isOpen ? 0 : 1,\n transform: `scale(${isOpen ? 0.75 : 1}) rotate(${isOpen ? 90 : 0}deg)`,\n }}\n >\n {renderedOpenIcon}\n </span>\n );\n\n const closeIconElement = (\n <span\n aria-hidden=\"true\"\n data-slot=\"chat-toggle-button-close-icon\"\n className={ICON_WRAPPER_BASE}\n style={{\n ...ICON_TRANSITION_STYLE,\n opacity: isOpen ? 1 : 0,\n transform: `scale(${isOpen ? 1 : 0.75}) rotate(${isOpen ? 0 : -90}deg)`,\n }}\n >\n {renderedCloseIcon}\n </span>\n );\n\n return (\n <button\n ref={ref}\n type={type ?? \"button\"}\n data-copilotkit\n data-slot=\"chat-toggle-button\"\n data-state={isOpen ? \"open\" : \"closed\"}\n className={cn(BUTTON_BASE_CLASSES, className)}\n aria-label={\n isOpen ? labels.chatToggleCloseLabel : labels.chatToggleOpenLabel\n }\n aria-pressed={isOpen}\n disabled={disabled}\n onClick={handleClick}\n {...restProps}\n >\n {openIconElement}\n {closeIconElement}\n </button>\n );\n});\nCopilotChatToggleButton.displayName = \"CopilotChatToggleButton\";\nexport default CopilotChatToggleButton;\n\nexport {\n DefaultOpenIcon as CopilotChatToggleButtonOpenIcon,\n DefaultCloseIcon as CopilotChatToggleButtonCloseIcon,\n};\n"],"mappings":";;;;;;;;AAUA,MAAM,mBAA4D,EAChE,WACA,GAAG,YAEH,oBAAC;CACC,WAAW,GAAG,mBAAmB,UAAU;CAC3C,aAAa;CACb,MAAK;CACL,GAAI;EACJ;AAGJ,MAAM,oBAA6D,EACjE,WACA,GAAG,YAEH,oBAAC;CACC,WAAW,GAAG,mBAAmB,UAAU;CAC3C,aAAa;CACb,GAAI;EACJ;AAGJ,gBAAgB,cAAc;AAC9B,iBAAiB,cAAc;AAY/B,MAAM,wBAA6C,OAAO,OAAO,EAC/D,YACE,0EACH,CAAC;AAEF,MAAM,oBACJ;AAEF,MAAM,sBAAsB,GAC1B,kHACA,6FACA,kEACA,8CACA,sBACA,2BACA,sKACA,2DACD;AAED,MAAa,0BAA0B,MAAM,WAG3C,SAAS,wBACT,EAAE,UAAU,WAAW,WAAW,GAAG,eACrC,KACA;CACA,MAAM,EAAE,SAAS,MAAM,UAAU,GAAG,cAAc;CAElD,MAAM,gBAAgB,6BAA6B;CACnD,MAAM,SAAS,eAAe,UAAU;CAExC,MAAM,CAAC,cAAc,mBAAmB,SAAS,MAAM;CAEvD,MAAM,SAAS,eAAe,eAAe;CAC7C,MAAM,eAAe,eAAe,gBAAgB;CAEpD,MAAM,eAAe,UAAyC;AAC5D,MAAI,SACF;AAGF,MAAI,QACF,SAAQ,MAAM;AAGhB,MAAI,MAAM,iBACR;AAIF,eADiB,CAAC,OACI;;CAGxB,MAAM,mBAAmB,WAAW,UAAU,iBAAiB;EAC7D,WAAW;EACX,eAAe;EACf,WAAW;EACZ,CAAC;CAEF,MAAM,oBAAoB,WAAW,WAAW,kBAAkB;EAChE,WAAW;EACX,eAAe;EACf,WAAW;EACZ,CAAC;CAEF,MAAM,kBACJ,oBAAC;EACC,eAAY;EACZ,aAAU;EACV,WAAW;EACX,OAAO;GACL,GAAG;GACH,SAAS,SAAS,IAAI;GACtB,WAAW,SAAS,SAAS,MAAO,EAAE,WAAW,SAAS,KAAK,EAAE;GAClE;YAEA;GACI;CAGT,MAAM,mBACJ,oBAAC;EACC,eAAY;EACZ,aAAU;EACV,WAAW;EACX,OAAO;GACL,GAAG;GACH,SAAS,SAAS,IAAI;GACtB,WAAW,SAAS,SAAS,IAAI,IAAK,WAAW,SAAS,IAAI,IAAI;GACnE;YAEA;GACI;AAGT,QACE,qBAAC;EACM;EACL,MAAM,QAAQ;EACd;EACA,aAAU;EACV,cAAY,SAAS,SAAS;EAC9B,WAAW,GAAG,qBAAqB,UAAU;EAC7C,cACE,SAAS,OAAO,uBAAuB,OAAO;EAEhD,gBAAc;EACJ;EACV,SAAS;EACT,GAAI;aAEH,iBACA;GACM;EAEX;AACF,wBAAwB,cAAc"}
|