reachat 1.0.6 → 1.1.0
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/README.md +2 -1
- package/dist/Chat.d.ts +7 -4
- package/dist/ChatContext.d.ts +2 -0
- package/dist/Markdown/CodeHighlighter.d.ts +4 -0
- package/dist/Markdown/themes/dark.d.ts +0 -1
- package/dist/docs.json +22 -3
- package/dist/index.js +33 -26
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +33 -26
- package/dist/index.umd.cjs.map +1 -1
- package/dist/theme.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -146,9 +146,9 @@
|
|
|
146
146
|
};
|
|
147
147
|
const SvgBack = (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-chevron-left", ...props }, /* @__PURE__ */ React__namespace.createElement("path", { d: "m15 18-6-6 6-6" }));
|
|
148
148
|
const SessionMessagePanel = ({ children }) => {
|
|
149
|
-
const { activeSessionId, theme, isCompact, selectSession } = React.useContext(ChatContext);
|
|
150
|
-
const isVisible = isCompact && activeSessionId;
|
|
151
|
-
return
|
|
149
|
+
const { activeSessionId, theme, isCompact, selectSession, viewType } = React.useContext(ChatContext);
|
|
150
|
+
const isVisible = isCompact && activeSessionId || viewType === "chat" || !isCompact;
|
|
151
|
+
return isVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
152
152
|
framerMotion.motion.div,
|
|
153
153
|
{
|
|
154
154
|
initial: { translateX: "200%" },
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
[theme.messages.console]: !isCompact
|
|
168
168
|
}),
|
|
169
169
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: reablocks.cn(theme.messages.inner), children: [
|
|
170
|
-
isCompact && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
170
|
+
isCompact && viewType !== "chat" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
171
171
|
reablocks.Button,
|
|
172
172
|
{
|
|
173
173
|
variant: "text",
|
|
@@ -225,9 +225,8 @@
|
|
|
225
225
|
"msHyphens": "none",
|
|
226
226
|
"hyphens": "none",
|
|
227
227
|
"padding": "1em",
|
|
228
|
-
"margin": "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
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
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) }),
|
|
@@ -1521,7 +1525,7 @@ ${response}`),
|
|
|
1521
1525
|
}
|
|
1522
1526
|
}, [activeSession, isAnimating]);
|
|
1523
1527
|
function handleShowMore() {
|
|
1524
|
-
showNext(
|
|
1528
|
+
showNext(limit);
|
|
1525
1529
|
requestAnimationFrame(() => contentRef.current.scrollTop = 0);
|
|
1526
1530
|
}
|
|
1527
1531
|
const reversedConvos = React.useMemo(
|
|
@@ -1530,7 +1534,7 @@ ${response}`),
|
|
|
1530
1534
|
);
|
|
1531
1535
|
const { data, hasMore, showNext } = reablocks.useInfinityList({
|
|
1532
1536
|
items: reversedConvos,
|
|
1533
|
-
limit
|
|
1537
|
+
size: limit
|
|
1534
1538
|
});
|
|
1535
1539
|
const reReversedConvo = React.useMemo(() => [...data].reverse(), [data]);
|
|
1536
1540
|
const convosToRender = limit ? reReversedConvo : activeSession == null ? void 0 : activeSession.conversations;
|
|
@@ -1555,7 +1559,7 @@ ${response}`),
|
|
|
1555
1559
|
initial: "hidden",
|
|
1556
1560
|
animate: "visible",
|
|
1557
1561
|
onAnimationComplete: () => {
|
|
1558
|
-
setIsAnimating(false);
|
|
1562
|
+
requestAnimationFrame(() => setIsAnimating(false));
|
|
1559
1563
|
},
|
|
1560
1564
|
children: children(convosToRender)
|
|
1561
1565
|
},
|
|
@@ -1565,7 +1569,7 @@ ${response}`),
|
|
|
1565
1569
|
};
|
|
1566
1570
|
const chatTheme = {
|
|
1567
1571
|
base: "dark:text-white text-gray-500",
|
|
1568
|
-
console: "flex w-full gap-
|
|
1572
|
+
console: "flex w-full gap-4 h-full",
|
|
1569
1573
|
companion: "w-full h-full overflow-hidden",
|
|
1570
1574
|
empty: "text-center flex-1",
|
|
1571
1575
|
sessions: {
|
|
@@ -1589,7 +1593,7 @@ ${response}`),
|
|
|
1589
1593
|
},
|
|
1590
1594
|
messages: {
|
|
1591
1595
|
base: "",
|
|
1592
|
-
console: "flex flex-col
|
|
1596
|
+
console: "flex flex-col mx-5 flex-1 overflow-hidden",
|
|
1593
1597
|
companion: "flex w-full h-full",
|
|
1594
1598
|
back: "self-start p-0 my-2",
|
|
1595
1599
|
inner: "flex-1 h-full flex flex-col",
|
|
@@ -1635,13 +1639,14 @@ ${response}`),
|
|
|
1635
1639
|
}
|
|
1636
1640
|
},
|
|
1637
1641
|
markdown: {
|
|
1638
|
-
copy: "
|
|
1642
|
+
copy: "sticky py-1 [&>svg]:w-4 [&>svg]:h-4 opacity-50",
|
|
1639
1643
|
p: "mb-2",
|
|
1640
1644
|
a: "text-blue-400 underline",
|
|
1641
1645
|
table: "table-auto w-full m-2",
|
|
1642
1646
|
th: "px-4 py-2 text-left font-bold border-b border-gray-500",
|
|
1643
1647
|
td: "px-4 py-2",
|
|
1644
|
-
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 ",
|
|
1645
1650
|
li: "mb-2 ml-6",
|
|
1646
1651
|
ul: "mb-4 list-disc",
|
|
1647
1652
|
ol: "mb-4 list-decimal"
|
|
@@ -1762,6 +1767,7 @@ ${response}`),
|
|
|
1762
1767
|
disabled,
|
|
1763
1768
|
isLoading,
|
|
1764
1769
|
isCompact,
|
|
1770
|
+
viewType,
|
|
1765
1771
|
activeSessionId: internalActiveSessionID,
|
|
1766
1772
|
selectSession: handleSelectSession,
|
|
1767
1773
|
deleteSession: handleDeleteSession,
|
|
@@ -1773,6 +1779,7 @@ ${response}`),
|
|
|
1773
1779
|
[
|
|
1774
1780
|
isLoading,
|
|
1775
1781
|
isCompact,
|
|
1782
|
+
viewType,
|
|
1776
1783
|
disabled,
|
|
1777
1784
|
theme,
|
|
1778
1785
|
remarkPlugins,
|