@firstlovecenter/ai-chat 0.9.3 → 0.9.4

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/ui/index.js CHANGED
@@ -6,6 +6,8 @@ import Link from 'next/link';
6
6
  import { PanelLeftClose, Plus, Pencil, Trash2, Menu, Sparkles, Loader2, ChevronDown, Check, ArrowUp, Copy, RotateCcw, ChevronUp } from 'lucide-react';
7
7
  import { DropdownMenu as DropdownMenu$1 } from 'radix-ui';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
+ import ReactMarkdown from 'react-markdown';
10
+ import remarkGfm from 'remark-gfm';
9
11
  import * as RechartsPrimitive from 'recharts';
10
12
  import { PieChart, Pie, Cell, Label, BarChart, CartesianGrid, XAxis, YAxis, Bar, LineChart, Line } from 'recharts';
11
13
  import { useChat } from '@ai-sdk/react';
@@ -488,22 +490,54 @@ function isBlockEmpty(b) {
488
490
  if (b.kind === "table") return !Array.isArray(b.rows) || b.rows.length === 0;
489
491
  return false;
490
492
  }
493
+ var PROSE_MD_COMPONENTS = {
494
+ p: ({ children }) => /* @__PURE__ */ jsx("p", { className: "mb-2 last:mb-0", children }),
495
+ ul: ({ children }) => /* @__PURE__ */ jsx("ul", { className: "my-1 list-disc pl-6", children }),
496
+ ol: ({ children }) => /* @__PURE__ */ jsx("ol", { className: "my-1 list-decimal pl-6", children }),
497
+ li: ({ children }) => /* @__PURE__ */ jsx("li", { className: "leading-6", children }),
498
+ strong: ({ children }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", children }),
499
+ em: ({ children }) => /* @__PURE__ */ jsx("em", { className: "italic", children }),
500
+ code: ({ children }) => /* @__PURE__ */ jsx("code", { className: "rounded bg-muted px-1 py-0.5 font-mono text-[0.85em]", children }),
501
+ a: ({ children, href }) => /* @__PURE__ */ jsx(
502
+ "a",
503
+ {
504
+ href,
505
+ target: "_blank",
506
+ rel: "noreferrer noopener",
507
+ className: "underline underline-offset-2",
508
+ children
509
+ }
510
+ )
511
+ };
512
+ var INLINE_MD_COMPONENTS = {
513
+ ...PROSE_MD_COMPONENTS,
514
+ p: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children })
515
+ };
516
+ function ProseMarkdown({ children }) {
517
+ return /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: PROSE_MD_COMPONENTS, children });
518
+ }
519
+ function InlineMarkdown({ children }) {
520
+ return /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: INLINE_MD_COMPONENTS, children });
521
+ }
491
522
  function AnswerBlocks({ blocks }) {
492
523
  const visible = blocks.filter((b) => !isBlockEmpty(b));
493
524
  return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: visible.map((b, i) => /* @__PURE__ */ jsx(BlockView, { block: b }, i)) });
494
525
  }
495
526
  function BlockView({ block }) {
496
527
  if (block.kind === "paragraph_brief") {
497
- return /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap text-sm leading-6 text-foreground", children: block.prose || /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
498
- block.key_facts.join(". "),
499
- "\u2026"
500
- ] }) });
528
+ if (!block.prose) {
529
+ return /* @__PURE__ */ jsxs("p", { className: "text-sm leading-6 text-muted-foreground", children: [
530
+ block.key_facts.join(". "),
531
+ "\u2026"
532
+ ] });
533
+ }
534
+ return /* @__PURE__ */ jsx("div", { className: "text-sm leading-6 text-foreground", children: /* @__PURE__ */ jsx(ProseMarkdown, { children: block.prose }) });
501
535
  }
502
536
  if (block.kind === "list") {
503
537
  const Tag = block.style === "numbered" ? "ol" : "ul";
504
538
  return /* @__PURE__ */ jsxs("div", { children: [
505
539
  block.title && /* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: block.title }),
506
- /* @__PURE__ */ jsx(Tag, { className: block.style === "numbered" ? "list-decimal pl-6" : "list-disc pl-6", children: block.items.map((it, i) => /* @__PURE__ */ jsx("li", { className: "text-sm leading-6", children: it }, i)) })
540
+ /* @__PURE__ */ jsx(Tag, { className: block.style === "numbered" ? "list-decimal pl-6" : "list-disc pl-6", children: block.items.map((it, i) => /* @__PURE__ */ jsx("li", { className: "text-sm leading-6", children: /* @__PURE__ */ jsx(InlineMarkdown, { children: it }) }, i)) })
507
541
  ] });
508
542
  }
509
543
  if (block.kind === "chart") {
@@ -520,7 +554,7 @@ function BlockView({ block }) {
520
554
  }
521
555
  if (block.kind === "callout") {
522
556
  const cls = block.tone === "warn" ? "border-amber-300 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 text-amber-900 dark:text-amber-100" : block.tone === "success" ? "border-emerald-300 dark:border-emerald-800 bg-emerald-50 dark:bg-emerald-950/30 text-emerald-900 dark:text-emerald-100" : "border-sky-300 bg-sky-50 text-sky-900";
523
- return /* @__PURE__ */ jsx("div", { className: `rounded border p-3 text-sm ${cls}`, children: block.text });
557
+ return /* @__PURE__ */ jsx("div", { className: `rounded border p-3 text-sm leading-6 ${cls}`, children: /* @__PURE__ */ jsx(ProseMarkdown, { children: block.text }) });
524
558
  }
525
559
  return null;
526
560
  }