reachat 1.0.5 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("reablocks"), require("@radix-ui/react-slot"), require("framer-motion"), require("react-markdown"), require("remark-gfm"), require("react-syntax-highlighter"), require("mdast-util-find-and-replace"), require("remark-youtube"), require("reakeys"), require("date-fns")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "reablocks", "@radix-ui/react-slot", "framer-motion", "react-markdown", "remark-gfm", "react-syntax-highlighter", "mdast-util-find-and-replace", "remark-youtube", "reakeys", "date-fns"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.reablocks = {}, global.jsxRuntime, global.React, global.reablocks, global.reactSlot, global.framerMotion, global.ReactMarkdown, global.remarkGfm, global.reactSyntaxHighlighter, global.mdastUtilFindAndReplace, global.remarkYoutube, global.reakeys, global.dateFns));
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("reablocks"), require("@radix-ui/react-slot"), require("framer-motion"), require("react-markdown"), require("remark-gfm"), require("react-syntax-highlighter"), require("mdast-util-find-and-replace"), require("remark-youtube"), require("reakeys"), require("date-fns")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "reablocks", "@radix-ui/react-slot", "framer-motion", "react-markdown", "remark-gfm", "react-syntax-highlighter", "mdast-util-find-and-replace", "remark-youtube", "reakeys", "date-fns"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.reachat = {}, global.jsxRuntime, global.React, global.reablocks, global.reactSlot, global.framerMotion, global.ReactMarkdown, global.remarkGfm, global.reactSyntaxHighlighter, global.mdastUtilFindAndReplace, global.remarkYoutube, global.reakeys, global.dateFns));
3
3
  })(this, function(exports2, jsxRuntime, React, reablocks, reactSlot, framerMotion, ReactMarkdown, remarkGfm, reactSyntaxHighlighter, mdastUtilFindAndReplace, remarkYoutube, reakeys, dateFns) {
4
4
  "use strict";
5
5
  function _interopNamespaceDefault(e) {
@@ -225,9 +225,8 @@
225
225
  "msHyphens": "none",
226
226
  "hyphens": "none",
227
227
  "padding": "1em",
228
- "margin": "0.5em 0",
229
- "overflow": "auto",
230
- "borderRadius": "0.3em"
228
+ "margin": "0",
229
+ "overflow": "auto"
231
230
  },
232
231
  'code[class*="language-"]::-moz-selection': {
233
232
  "background": "#1e293b",
@@ -1192,6 +1191,7 @@
1192
1191
  copyClassName,
1193
1192
  copyIcon = /* @__PURE__ */ jsxRuntime.jsx(SvgCopy, {}),
1194
1193
  language,
1194
+ toolbarClassName,
1195
1195
  theme = dark
1196
1196
  }) => {
1197
1197
  const match = language == null ? void 0 : language.match(/language-(\w+)/);
@@ -1204,17 +1204,20 @@
1204
1204
  });
1205
1205
  };
1206
1206
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: reablocks.cn("relative", className), children: [
1207
- copyIcon && /* @__PURE__ */ jsxRuntime.jsx(
1208
- reablocks.Button,
1209
- {
1210
- className: reablocks.cn(copyClassName),
1211
- size: "small",
1212
- variant: "text",
1213
- title: "Copy code",
1214
- onClick: () => handleCopy(children),
1215
- children: copyIcon
1216
- }
1217
- ),
1207
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: reablocks.cn(toolbarClassName), children: [
1208
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: lang }),
1209
+ copyIcon && /* @__PURE__ */ jsxRuntime.jsx(
1210
+ reablocks.Button,
1211
+ {
1212
+ className: reablocks.cn(copyClassName),
1213
+ size: "small",
1214
+ variant: "text",
1215
+ title: "Copy code",
1216
+ onClick: () => handleCopy(children),
1217
+ children: copyIcon
1218
+ }
1219
+ )
1220
+ ] }),
1218
1221
  /* @__PURE__ */ jsxRuntime.jsx(
1219
1222
  reactSyntaxHighlighter.Prism,
1220
1223
  {
@@ -1244,7 +1247,8 @@
1244
1247
  ...props,
1245
1248
  language: className,
1246
1249
  className: reablocks.cn(theme.messages.message.markdown.code, className),
1247
- copyClassName: reablocks.cn(theme.messages.message.markdown.copy)
1250
+ copyClassName: reablocks.cn(theme.messages.message.markdown.copy),
1251
+ toolbarClassName: reablocks.cn(theme.messages.message.markdown.toolbar)
1248
1252
  }
1249
1253
  ),
1250
1254
  table: (props) => /* @__PURE__ */ jsxRuntime.jsx(TableComponent, { ...props, className: reablocks.cn(theme.messages.message.markdown.table) }),
@@ -1344,11 +1348,13 @@
1344
1348
  return files.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: reablocks.cn(theme.messages.message.files.base), children: files.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(Comp, { ...file, children }, index)) });
1345
1349
  };
1346
1350
  const MessageSource = ({ title, url, image, limit = 50 }) => {
1347
- const { theme } = React.useContext(ChatContext);
1351
+ const { theme, isCompact } = React.useContext(ChatContext);
1348
1352
  return /* @__PURE__ */ jsxRuntime.jsxs(
1349
1353
  "figure",
1350
1354
  {
1351
- className: reablocks.cn(theme.messages.message.sources.source.base),
1355
+ className: reablocks.cn(theme.messages.message.sources.source.base, {
1356
+ [theme.messages.message.sources.source.companion]: isCompact
1357
+ }),
1352
1358
  onClick: () => {
1353
1359
  if (url) {
1354
1360
  window.open(url, "_blank");
@@ -1562,69 +1568,95 @@ ${response}`),
1562
1568
  ] });
1563
1569
  };
1564
1570
  const chatTheme = {
1565
- base: "text-white",
1566
- console: "flex w-full gap-5 h-full",
1571
+ base: "dark:text-white text-gray-500",
1572
+ console: "flex w-full gap-10 h-full",
1567
1573
  companion: "w-full h-full overflow-hidden",
1568
1574
  empty: "text-center flex-1",
1569
1575
  sessions: {
1570
1576
  base: "overflow-auto",
1571
- console: "min-w-[150px] w-[30%] max-w-[300px] bg-[#11111F] p-5 rounded-3xl",
1577
+ console: "min-w-[150px] w-[30%] max-w-[300px] dark:bg-[#11111F] bg-[#F2F3F7] p-5 rounded-3xl",
1572
1578
  companion: "w-full h-full",
1573
- group: "text-xs text-gray-400 mt-4 hover:bg-transparent mb-1",
1574
- create: "relative mb-4 rounded-[10px]",
1579
+ group: "text-xs dart:text-gray-400 text-gray-700 mt-4 hover:bg-transparent mb-1",
1580
+ create: "relative mb-4 rounded-[10px] text-white",
1575
1581
  session: {
1576
- base: "my-1 rounded-[10px] p-2 text-typography hover:bg-gray-800/50 border border-transparent hover:border-gray-700/50",
1577
- active: "bg-gray-800/70 border border-gray-700/70 hover:bg-gray-800/50 border-gray-700/50 text-white",
1578
- delete: "[&>svg]:w-4 [&>svg]:h-4 opacity-50"
1582
+ base: [
1583
+ "group my-1 rounded-[10px] p-2 text-gray-500 border border-transparent hover:bg-gray-300 hover:border-gray-400 [&_svg]:text-gray-500",
1584
+ "dark:text-typography dark:text-gray-400 dark:hover:bg-gray-800/50 dark:hover:border-gray-700/50 dark:[&_svg]:text-gray-200"
1585
+ ].join(" "),
1586
+ active: [
1587
+ "border border-gray-300 hover:border-gray-400 text-gray-700 bg-gray-200 hover:bg-gray-300 ",
1588
+ "dark:text-gray-500 dark:bg-gray-800/70 dark:border-gray-700/50 dark:text-white dark:border-gray-700/70 dark:hover:bg-gray-800/50",
1589
+ "[&_button]:!opacity-100"
1590
+ ].join(" "),
1591
+ delete: "[&>svg]:w-4 [&>svg]:h-4 opacity-0 group-hover:!opacity-50"
1579
1592
  }
1580
1593
  },
1581
1594
  messages: {
1582
1595
  base: "",
1583
- console: "flex flex-col flex-1 overflow-hidden",
1596
+ console: "flex flex-col mr-5 flex-1 overflow-hidden",
1584
1597
  companion: "flex w-full h-full",
1585
1598
  back: "self-start p-0 my-2",
1586
1599
  inner: "flex-1 h-full flex flex-col",
1587
- title: "text-2xl font-bold",
1588
- date: "text-sm whitespace-nowrap pt-2",
1589
- content: "mt-2 flex-1 overflow-auto",
1600
+ title: ["text-base font-bold text-gray-500", "dark:text-gray-200"].join(
1601
+ " "
1602
+ ),
1603
+ date: "text-xs whitespace-nowrap pt-2 text-gray-400",
1604
+ content: [
1605
+ "mt-2 flex-1 overflow-auto [&_hr]:bg-gray-200",
1606
+ "dark:[&_hr]:bg-gray-800/60"
1607
+ ].join(" "),
1590
1608
  header: "flex justify-between items-start gap-2",
1591
1609
  showMore: "mb-4",
1592
1610
  message: {
1593
- base: "mt-4 mb-4 flex flex-col p-0 rounded border-none",
1594
- question: "font-semibold text-gray-400 mb-4 px-4 py-3 pb-1 rounded-3xl rounded-br-none text-typography bg-gray-900/60 border border-gray-700/50",
1595
- response: "",
1611
+ base: "mt-4 mb-4 flex flex-col p-0 rounded border-none bg-transparent",
1612
+ question: [
1613
+ "font-semibold mb-4 px-4 py-4 pb-2 rounded-3xl rounded-br-none text-typography border bg-gray-200 border-gray-300 text-gray-900",
1614
+ "dark:bg-gray-900/60 dark:border-gray-700/50 dark:text-gray-100"
1615
+ ].join(" "),
1616
+ response: ["text-gray-900", "dark:text-gray-100"].join(" "),
1596
1617
  cursor: "inline-block w-1 h-4 bg-current",
1597
1618
  files: {
1598
1619
  base: "mb-2 flex flex-wrap gap-3 ",
1599
1620
  file: {
1600
- base: "flex items-center gap-2 border border-gray-700 p-2 rounded cursor-pointer",
1601
- name: "text-sm"
1621
+ base: [
1622
+ "flex items-center gap-2 border border-gray-300 px-3 py-2 rounded-lg cursor-pointer",
1623
+ "dark:border-gray-700"
1624
+ ].join(" "),
1625
+ name: ["text-sm text-gray-500", "dark:text-gray-200"].join(" ")
1602
1626
  }
1603
1627
  },
1604
1628
  sources: {
1605
1629
  base: "my-4 flex flex-wrap gap-3",
1606
1630
  source: {
1607
- base: "flex gap-2 border border-gray-700 p-2 rounded cursor-pointer",
1608
- image: "w-6 h-6 rounded-md",
1631
+ base: [
1632
+ "flex gap-2 border border-gray-200 px-4 py-2 rounded-lg cursor-pointer",
1633
+ "dark:border-gray-700"
1634
+ ].join(" "),
1635
+ companion: "flex-1 px-3 py-1.5",
1636
+ image: "max-w-10 max-h-10 rounded-md w-full h-fit self-center",
1609
1637
  title: "text-md block",
1610
- url: "text-sm text-blue-700 underline"
1638
+ url: "text-sm text-blue-400 underline"
1611
1639
  }
1612
1640
  },
1613
1641
  markdown: {
1614
- copy: "absolute right-0 top-0 [&>svg]:w-4 [&>svg]:h-4 opacity-50",
1642
+ copy: "sticky py-1 [&>svg]:w-4 [&>svg]:h-4 opacity-50",
1615
1643
  p: "mb-2",
1616
- a: "text-blue-700 underline",
1644
+ a: "text-blue-400 underline",
1617
1645
  table: "table-auto w-full m-2",
1618
1646
  th: "px-4 py-2 text-left font-bold border-b border-gray-500",
1619
1647
  td: "px-4 py-2",
1620
- code: "m-2 rounded",
1648
+ code: "m-2 rounded-b relative",
1649
+ toolbar: "text-xs dark:bg-gray-700/50 flex items-center justify-between px-2 py-1 rounded-t sticky top-0 backdrop-blur-md bg-gray-200 ",
1621
1650
  li: "mb-2 ml-6",
1622
1651
  ul: "mb-4 list-disc",
1623
1652
  ol: "mb-4 list-decimal"
1624
1653
  },
1625
1654
  footer: {
1626
- base: "mt-3 flex gap-1.5",
1627
- copy: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white",
1655
+ base: "mt-3 flex gap-1.5 text-gray-400",
1656
+ copy: [
1657
+ "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-200 hover:text-gray-500",
1658
+ "dark:hover:bg-gray-800 dark:hover:text-white"
1659
+ ].join(" "),
1628
1660
  upvote: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white",
1629
1661
  downvote: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white",
1630
1662
  refresh: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white"
@@ -1633,11 +1665,17 @@ ${response}`),
1633
1665
  },
1634
1666
  input: {
1635
1667
  base: "flex mt-4 relative",
1636
- upload: "px-5 py-2 text-white size-10",
1637
- input: "w-full text-typography border border-gray-700/70 rounded-3xl px-3 py-2 pr-16 after:!mx-10 [&>textarea]:w-full [&>textarea]:flex-none",
1668
+ upload: ["px-5 py-2 text-gray-400 size-10", "dark:gray-500"].join(" "),
1669
+ input: [
1670
+ "w-full border rounded-3xl px-3 py-2 pr-16 text-gray-500 border-gray-200 hover:bg-blue-100 hover:border-blue-500 after:hidden after:!mx-10 bg-white [&>textarea]:w-full [&>textarea]:flex-none",
1671
+ "dark:border-gray-700/50 dark:text-gray-200 dark:bg-gray-950 dark:hover:bg-blue-950/40"
1672
+ ].join(" "),
1638
1673
  actions: {
1639
1674
  base: "absolute flex gap-2 items-center right-5 inset-y-1/2 -translate-y-1/2 z-10",
1640
- send: "px-3 py-3 text-white bg-gray-800 hover:bg-primary-hover rounded-full ",
1675
+ send: [
1676
+ "px-3 py-3 hover:bg-primary-hover rounded-full bg-gray-200 hover:bg-gray-300 text-gray-500",
1677
+ "dark:text-white dark:bg-gray-800 hover:dark:bg-gray-700"
1678
+ ].join(" "),
1641
1679
  stop: "px-2 py-2 bg-red-500 text-white rounded-full hover:bg-red-700 "
1642
1680
  }
1643
1681
  }
@@ -1792,7 +1830,7 @@ ${response}`),
1792
1830
  }
1793
1831
  );
1794
1832
  };
1795
- const SvgTrash = (props) => /* @__PURE__ */ React__namespace.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-trash-2", ...props }, /* @__PURE__ */ React__namespace.createElement("path", { d: "M3 6h18" }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" }), /* @__PURE__ */ React__namespace.createElement("line", { x1: 10, x2: 10, y1: 11, y2: 17 }), /* @__PURE__ */ React__namespace.createElement("line", { x1: 14, x2: 14, y1: 11, y2: 17 }));
1833
+ const SvgTrash = (props) => /* @__PURE__ */ React__namespace.createElement("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React__namespace.createElement("g", { id: "Delete" }, /* @__PURE__ */ React__namespace.createElement("path", { id: "Vector", d: "M5.97905 1.16666C5.90859 1.16576 5.83895 1.18189 5.77605 1.21368C5.71316 1.24547 5.65888 1.29199 5.61783 1.34926C5.57677 1.40654 5.55016 1.47288 5.54025 1.54265C5.53034 1.61242 5.53743 1.68355 5.56092 1.75H4.27007C3.7342 1.75 3.2324 2.01817 2.93535 2.46435L2.24492 3.5H2.18738C2.12941 3.49918 2.07185 3.50989 2.01805 3.5315C1.96425 3.55312 1.91529 3.58522 1.874 3.62593C1.83271 3.66663 1.79993 3.71514 1.77755 3.76863C1.75518 3.82211 1.74365 3.87952 1.74365 3.9375C1.74365 3.99548 1.75518 4.05288 1.77755 4.10636C1.79993 4.15985 1.83271 4.20836 1.874 4.24907C1.91529 4.28977 1.96425 4.32187 2.01805 4.34349C2.07185 4.3651 2.12941 4.37582 2.18738 4.375H2.41012C2.44765 4.38067 2.48576 4.38143 2.52348 4.37727L3.24468 11.1084C3.33169 11.9199 4.02367 12.5417 4.83973 12.5417H9.15947C9.97553 12.5417 10.6675 11.9199 10.7545 11.1084L11.4763 4.37727C11.5133 4.38124 11.5506 4.38047 11.5874 4.375H11.8124C11.8704 4.37582 11.9279 4.3651 11.9817 4.34349C12.0355 4.32187 12.0845 4.28977 12.1258 4.24907C12.1671 4.20836 12.1998 4.15985 12.2222 4.10636C12.2446 4.05288 12.2561 3.99548 12.2561 3.9375C12.2561 3.87952 12.2446 3.82211 12.2222 3.76863C12.1998 3.71514 12.1671 3.66663 12.1258 3.62593C12.0845 3.58522 12.0355 3.55312 11.9817 3.5315C11.9279 3.50989 11.8704 3.49918 11.8124 3.5H11.7548L11.0644 2.46435C10.7671 2.01841 10.2654 1.75 9.7297 1.75H8.43885C8.46234 1.68355 8.46943 1.61242 8.45952 1.54265C8.44961 1.47288 8.423 1.40654 8.38194 1.34926C8.34089 1.29199 8.2866 1.24547 8.22371 1.21368C8.16082 1.18189 8.09118 1.16576 8.02072 1.16666H5.97905ZM4.27007 2.625H9.7297C9.97394 2.625 10.2009 2.74639 10.3364 2.9497L10.7033 3.5H3.29651L3.66338 2.9497L3.66395 2.94913C3.79913 2.74608 4.02543 2.625 4.27007 2.625ZM3.40361 4.375H10.5962L9.88465 11.015C9.8445 11.3894 9.53575 11.6667 9.15947 11.6667H4.83973C4.46345 11.6667 4.15527 11.3894 4.11512 11.015L3.40361 4.375Z", fill: "currentColor" })));
1796
1834
  const SvgChat = (props) => /* @__PURE__ */ React__namespace.createElement("svg", { width: 16, height: 17, viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React__namespace.createElement("path", { d: "M8 3C4.55375 3 1.75 5.23753 1.75 7.98828C1.75 9.70653 2.83659 11.2762 4.62109 12.188C4.11184 13.0465 3.62587 13.7378 3.62012 13.7461C3.50687 13.9071 3.49862 14.1196 3.59912 14.2891C3.69012 14.4418 3.8543 14.5342 4.0293 14.5342C4.0483 14.5342 4.06743 14.533 4.08643 14.5308C4.15168 14.5233 5.66214 14.3364 7.50439 12.9604C7.67239 12.9712 7.8385 12.9766 8 12.9766C11.4462 12.9766 14.25 10.739 14.25 7.98828C14.25 5.23753 11.4462 3 8 3ZM8 4C10.8948 4 13.25 5.78903 13.25 7.98828C13.25 10.1875 10.8948 11.9766 8 11.9766C7.8055 11.9766 7.60225 11.968 7.396 11.9497C7.271 11.9382 7.1454 11.9752 7.0459 12.0527C6.3589 12.5855 5.72033 12.9308 5.20508 13.1528C5.38383 12.8648 5.57691 12.5418 5.76416 12.2061C5.83416 12.0813 5.84705 11.9324 5.7998 11.7974C5.75255 11.6624 5.64983 11.5542 5.51758 11.5C3.81033 10.7993 2.75 9.45328 2.75 7.98828C2.75 5.78903 5.10525 4 8 4ZM5.5 7.25C5.08575 7.25 4.75 7.58575 4.75 8C4.75 8.41425 5.08575 8.75 5.5 8.75C5.91425 8.75 6.25 8.41425 6.25 8C6.25 7.58575 5.91425 7.25 5.5 7.25ZM8 7.25C7.58575 7.25 7.25 7.58575 7.25 8C7.25 8.41425 7.58575 8.75 8 8.75C8.41425 8.75 8.75 8.41425 8.75 8C8.75 7.58575 8.41425 7.25 8 7.25ZM10.5 7.25C10.0857 7.25 9.75 7.58575 9.75 8C9.75 8.41425 10.0857 8.75 10.5 8.75C10.9143 8.75 11.25 8.41425 11.25 8C11.25 7.58575 10.9143 7.25 10.5 7.25Z", fill: "currentColor" }));
1797
1835
  const SessionListItem = ({
1798
1836
  children,