UNPKG

@prexo/ai-chat-sdk

Version:

AI Chat Component with Persistent History

61 lines (60 loc) 2.06 kB
"use client"; import { jsx } from "react/jsx-runtime"; import { memo } from "react"; import { Button } from "../../components/ui/button.js"; import { motion } from "framer-motion"; function PureSuggestedActions({ append, suggestedActions, sessionId, sessionTTL, history }) { return /* @__PURE__ */ jsx( "div", { "data-testid": "suggested-actions", className: "grid grid-cols-3 gap-2 w-full", children: suggestedActions.map((suggestedAction, index) => /* @__PURE__ */ jsx( motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: 10 }, transition: { delay: 0.3 * index + 1 }, className: "block", children: /* @__PURE__ */ jsx( Button, { variant: "secondary", onClick: async () => { append(suggestedAction.action); if (history) { await history.addMessage( { message: { id: Date.now().toString(), role: "user", content: suggestedAction.action }, sessionId, sessionTTL } ); } }, className: "text-left border rounded-xl px-3 py-2 text-sm gap-1 flex flex-col w-auto h-auto justify-start items-start cursor-pointer ml-auto\n ", style: { minHeight: "24px", wordBreak: "break-word" }, children: /* @__PURE__ */ jsx("span", { className: "suggested-action-label", children: suggestedAction.label }) } ) }, `suggested-action-${suggestedAction.label}-${index}` )) } ); } const SuggestedActions = memo( PureSuggestedActions, (prevProps, nextProps) => prevProps.append === nextProps.append ); export { SuggestedActions };