reachat 2.1.0-alpha.8 → 2.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 +4 -2
- package/dist/AppBar/AppBar.d.ts +1 -1
- package/dist/{CSVFileRenderer-CaWN5iTb.js → CSVFileRenderer-D2mDdCjs.js} +14 -15
- package/dist/CSVFileRenderer-D2mDdCjs.js.map +1 -0
- package/dist/Chat.d.ts +9 -3
- package/dist/ChatBubble/ChatBubble.d.ts +1 -1
- package/dist/ChatContext.d.ts +4 -2
- package/dist/ChatInput/ChatInput.d.ts +23 -13
- package/dist/ChatInput/FileInput.d.ts +1 -1
- package/dist/ChatInput/MentionList.d.ts +32 -0
- package/dist/ChatInput/RichTextInput.d.ts +55 -0
- package/dist/ChatInput/index.d.ts +3 -0
- package/dist/ChatInput/types.d.ts +104 -0
- package/dist/ChatSuggestions/ChatSuggestion.d.ts +9 -0
- package/dist/ChatSuggestions/ChatSuggestions.d.ts +22 -0
- package/dist/ChatSuggestions/index.d.ts +2 -0
- package/dist/{DefaultFileRenderer-C30msYzW.js → DefaultFileRenderer-BLV8PtJk.js} +2 -2
- package/dist/DefaultFileRenderer-BLV8PtJk.js.map +1 -0
- package/dist/ImageFileRenderer-C8tVW3I8.js.map +1 -1
- package/dist/Markdown/Markdown.d.ts +4 -3
- package/dist/Markdown/Table.d.ts +1 -1
- package/dist/Markdown/charts/ChartError.d.ts +21 -0
- package/dist/Markdown/charts/ChartPre.d.ts +6 -0
- package/dist/Markdown/charts/ChartRenderer.d.ts +13 -0
- package/dist/Markdown/charts/chartHelpers.d.ts +40 -0
- package/dist/Markdown/charts/chartHelpers.spec.d.ts +1 -0
- package/dist/Markdown/charts/index.d.ts +7 -0
- package/dist/Markdown/index.d.ts +3 -2
- package/dist/Markdown/plugins/index.d.ts +1 -0
- package/dist/Markdown/plugins/remarkChart.d.ts +59 -0
- package/dist/Markdown/plugins/remarkCve.d.ts +1 -1
- package/dist/MessageStatus/MessageStatus.d.ts +44 -0
- package/dist/MessageStatus/MessageStatusItem.d.ts +9 -0
- package/dist/MessageStatus/StatusIcon.d.ts +17 -0
- package/dist/MessageStatus/index.d.ts +3 -0
- package/dist/PDFFileRenderer-DQdFS2l6.js +9 -0
- package/dist/PDFFileRenderer-DQdFS2l6.js.map +1 -0
- package/dist/SessionMessages/SessionEmpty.d.ts +4 -1
- package/dist/SessionMessages/SessionMessage/MessageFile/renderers/index.d.ts +1 -1
- package/dist/SessionMessages/SessionMessage/MessageFiles.d.ts +1 -1
- package/dist/SessionMessages/SessionMessage/MessageSources.d.ts +1 -1
- package/dist/SessionMessages/SessionMessage/SessionMessage.d.ts +0 -4
- package/dist/SessionMessages/SessionMessage/index.d.ts +2 -2
- package/dist/SessionMessages/SessionMessages.d.ts +3 -7
- package/dist/SessionMessages/index.d.ts +2 -2
- package/dist/SessionsList/index.d.ts +2 -2
- package/dist/docs.json +1037 -183
- package/dist/index-B3dZT-5c.js +4369 -0
- package/dist/index-B3dZT-5c.js.map +1 -0
- package/dist/index.css +2129 -6532
- package/dist/index.d.ts +8 -7
- package/dist/index.js +49 -34
- package/dist/index.umd.cjs +3414 -1318
- package/dist/index.umd.cjs.map +1 -1
- package/dist/stories/Changelog.mdx +1 -1
- package/dist/stories/ChartError.stories.tsx +85 -0
- package/dist/stories/Charts.stories.tsx +371 -0
- package/dist/stories/Chat.stories.tsx +5 -5
- package/dist/stories/ChatBubble.stories.tsx +3 -3
- package/dist/stories/ChatSuggestions.stories.tsx +541 -0
- package/dist/stories/Companion.stories.tsx +6 -6
- package/dist/stories/Console.stories.tsx +164 -24
- package/dist/stories/EnhancedInput.stories.tsx +322 -0
- package/dist/stories/Integration.stories.tsx +2 -2
- package/dist/stories/Intro.mdx +1 -1
- package/dist/stories/MessageStatus.stories.tsx +314 -0
- package/dist/stories/RichTextInput.stories.tsx +198 -0
- package/dist/stories/assets/logo.svg +19 -38
- package/dist/stories/assets/paperclip.svg +1 -4
- package/dist/stories/assets/search.svg +1 -5
- package/dist/stories/assets/sparkles.svg +7 -0
- package/dist/stories/examples.ts +47 -20
- package/dist/theme.d.ts +76 -13
- package/dist/types.d.ts +10 -0
- package/package.json +69 -66
- package/dist/CSVFileRenderer-CaWN5iTb.js.map +0 -1
- package/dist/DefaultFileRenderer-C30msYzW.js.map +0 -1
- package/dist/PDFFileRenderer-BBn2EVrV.js +0 -16
- package/dist/PDFFileRenderer-BBn2EVrV.js.map +0 -1
- package/dist/index-DRRvnZUj.js +0 -2255
- package/dist/index-DRRvnZUj.js.map +0 -1
- package/dist/utils/index.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img width="650" src=".storybook/logo.
|
|
2
|
+
<img width="650" src=".storybook/logo.svg">
|
|
3
3
|
<br />
|
|
4
4
|
Building Blocks for LLM UI
|
|
5
5
|
<br /><br />
|
|
@@ -62,10 +62,12 @@ theme via Tailwind.
|
|
|
62
62
|
- Conversation Pagination
|
|
63
63
|
- Smart/Dynamic Grouping of Sessions
|
|
64
64
|
- Keyboard shortcuts
|
|
65
|
-
- Animations via
|
|
65
|
+
- Animations via Motion.dev
|
|
66
66
|
- Responsive
|
|
67
67
|
- Tailwind for Themeing
|
|
68
68
|
- Customizable via Slots
|
|
69
|
+
- Conversation Charting via Reaviz.dev
|
|
70
|
+
- Mentions and Commands via Tiptap
|
|
69
71
|
|
|
70
72
|
## 📦 Install
|
|
71
73
|
|
package/dist/AppBar/AppBar.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
2
4
|
import { AnimatePresence, motion } from "motion/react";
|
|
5
|
+
import { a as SvgCopy } from "./index-B3dZT-5c.js";
|
|
3
6
|
import { IconButton } from "reablocks";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { useContext, useState, useRef, useEffect } from "react";
|
|
6
|
-
import { C as ChatContext, a as SvgCopy } from "./index-DRRvnZUj.js";
|
|
7
|
-
const SvgDownload = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24px", height: "24px", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M 11 2 C 10.448 2 10 2.448 10 3 L 10 11 L 6.5 11 A 0.5 0.5 0 0 0 6 11.5 A 0.5 0.5 0 0 0 6.1464844 11.853516 A 0.5 0.5 0 0 0 6.1777344 11.882812 L 11.283203 16.697266 L 11.316406 16.728516 A 1 1 0 0 0 12 17 A 1 1 0 0 0 12.683594 16.728516 L 12.697266 16.716797 A 1 1 0 0 0 12.707031 16.705078 L 17.810547 11.892578 A 0.5 0.5 0 0 0 17.839844 11.865234 L 17.847656 11.859375 A 0.5 0.5 0 0 0 17.853516 11.853516 A 0.5 0.5 0 0 0 18 11.5 A 0.5 0.5 0 0 0 17.5 11 L 14 11 L 14 3 C 14 2.448 13.552 2 13 2 L 12 2 L 11 2 z M 3 20 A 1.0001 1.0001 0 1 0 3 22 L 21 22 A 1.0001 1.0001 0 1 0 21 20 L 3 20 z", fill: "currentColor" }));
|
|
8
7
|
const sanitizeSVGCell = (cell) => {
|
|
9
8
|
const trimmed = cell.trim();
|
|
10
9
|
const escaped = trimmed.replace(/"/g, '""');
|
|
@@ -21,8 +20,8 @@ const parseCSV = (csvString) => {
|
|
|
21
20
|
throw new Error("Failed to parse CSV file.");
|
|
22
21
|
}
|
|
23
22
|
};
|
|
23
|
+
const SvgDownload = (props) => /* @__PURE__ */ React.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-cloud-download", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242" }), /* @__PURE__ */ React.createElement("path", { d: "M12 12v9" }), /* @__PURE__ */ React.createElement("path", { d: "m8 17 4 4 4-4" }));
|
|
24
24
|
const CSVFileRenderer = ({ name, url, fileIcon }) => {
|
|
25
|
-
const { theme } = useContext(ChatContext);
|
|
26
25
|
const [isLoading, setIsLoading] = useState(true);
|
|
27
26
|
const [csvData, setCsvData] = useState([]);
|
|
28
27
|
const [error, setError] = useState(null);
|
|
@@ -98,24 +97,24 @@ const CSVFileRenderer = ({ name, url, fileIcon }) => {
|
|
|
98
97
|
]
|
|
99
98
|
}
|
|
100
99
|
);
|
|
101
|
-
return /* @__PURE__ */ jsxs("div", { className:
|
|
102
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
103
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
100
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
101
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center gap-4", children: [
|
|
102
|
+
/* @__PURE__ */ jsxs("div", { className: "csv-icon flex items-center", children: [
|
|
104
103
|
fileIcon,
|
|
105
104
|
name && /* @__PURE__ */ jsx("figcaption", { className: "ml-1", children: name })
|
|
106
105
|
] }),
|
|
107
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
108
|
-
/* @__PURE__ */ jsx(IconButton, { size: "
|
|
109
|
-
/* @__PURE__ */ jsx(IconButton, { size: "
|
|
106
|
+
/* @__PURE__ */ jsxs("div", { className: "csv-icon flex items-center gap-6", children: [
|
|
107
|
+
/* @__PURE__ */ jsx(IconButton, { size: "small", variant: "text", onClick: downloadCSV, children: /* @__PURE__ */ jsx(SvgDownload, {}) }),
|
|
108
|
+
/* @__PURE__ */ jsx(IconButton, { size: "small", variant: "text", onClick: toggleModal, children: /* @__PURE__ */ jsx(SvgCopy, {}) })
|
|
110
109
|
] })
|
|
111
110
|
] }),
|
|
112
111
|
error && /* @__PURE__ */ jsx("div", { className: "error-message", children: error }),
|
|
113
112
|
isLoading && !csvData && /* @__PURE__ */ jsx("div", { className: "text-text-secondary", children: "Loading..." }),
|
|
114
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
113
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-between", children: !error && csvData.length > 0 && renderTable(csvData, 6) }),
|
|
115
114
|
/* @__PURE__ */ jsx(AnimatePresence, { children: isModalOpen && /* @__PURE__ */ jsx(
|
|
116
115
|
motion.div,
|
|
117
116
|
{
|
|
118
|
-
className:
|
|
117
|
+
className: "fixed inset-0 bg-black/70 flex justify-center items-center z-50",
|
|
119
118
|
initial: { opacity: 0 },
|
|
120
119
|
animate: { opacity: 1 },
|
|
121
120
|
exit: { opacity: 0 },
|
|
@@ -124,7 +123,7 @@ const CSVFileRenderer = ({ name, url, fileIcon }) => {
|
|
|
124
123
|
motion.div,
|
|
125
124
|
{
|
|
126
125
|
ref: modalRef,
|
|
127
|
-
className:
|
|
126
|
+
className: "bg-white dark:bg-gray-900 rounded-md w-11/12 h-5/6 overflow-auto",
|
|
128
127
|
initial: { scale: 0.8 },
|
|
129
128
|
animate: { scale: 1 },
|
|
130
129
|
exit: { scale: 0.8 },
|
|
@@ -139,4 +138,4 @@ const CSVFileRenderer = ({ name, url, fileIcon }) => {
|
|
|
139
138
|
export {
|
|
140
139
|
CSVFileRenderer as default
|
|
141
140
|
};
|
|
142
|
-
//# sourceMappingURL=CSVFileRenderer-
|
|
141
|
+
//# sourceMappingURL=CSVFileRenderer-D2mDdCjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CSVFileRenderer-D2mDdCjs.js","sources":["../src/utils/sanitize.ts","../src/utils/parseCSV.ts","../src/assets/download.svg?react","../src/SessionMessages/SessionMessage/MessageFile/renderers/CSVFileRenderer.tsx"],"sourcesContent":["\n/**\n * Sanitizes cell content to prevent CSV injection and other potential vulnerabilities.\n * Based on the documentation of OWASP for CSV Injection\n * https://owasp.org/www-community/attacks/CSV_Injection\n * @param cell The cell content to sanitize.\n * @returns The sanitized cell content.\n */\nexport const sanitizeSVGCell = (cell: string): string => {\n const trimmed = cell.trim();\n // Escape double quotes by doubling them\n const escaped = trimmed.replace(/\"/g, '\"\"');\n // Add single quote prefix only for potentially dangerous content\n const prefix = /^[=+\\-@]/.test(trimmed) ? '\\'' : '';\n // Only wrap in quotes if the content contains special characters\n const needsQuotes = /[\",\\n\\r]/.test(escaped) || prefix;\n\n return needsQuotes ? `\"${prefix}${escaped}\"` : escaped;\n};\n","import { sanitizeSVGCell } from './sanitize';\n\n/**\n * Parses a CSV string from a local file and returns an array of rows.\n * Sanitizes cell data to prevent injection attacks.\n * @param csvString The raw CSV string content to parse.\n * @returns The parsed CSV data as a 2D array of strings.\n */\nexport const parseCSV = (csvString: string): string[][] => {\n try {\n const rows = csvString.split('\\n');\n return rows.map((row) => row.split(',').map((cell) => sanitizeSVGCell(cell)));\n } catch (error) {\n console.error('Error parsing CSV:', error);\n throw new Error('Failed to parse CSV file.');\n }\n};\n","import * as React from \"react\";\nconst SvgDownload = (props) => /* @__PURE__ */ React.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-cloud-download\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { d: \"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242\" }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M12 12v9\" }), /* @__PURE__ */ React.createElement(\"path\", { d: \"m8 17 4 4 4-4\" }));\nexport default SvgDownload;\n","import { FC, useEffect, useState, ReactElement, useRef } from 'react';\nimport { motion, AnimatePresence } from 'motion/react';\nimport { parseCSV } from '@/utils/parseCSV';\nimport DownloadIcon from '@/assets/download.svg?react';\nimport PlaceholderIcon from '@/assets/copy.svg?react';\nimport { IconButton } from 'reablocks';\n\ninterface CSVFileRendererProps {\n /**\n * Name of the file.\n */\n name?: string;\n\n /**\n * URL of the file.\n */\n url: string;\n\n /**\n * Icon to for file type.\n */\n fileIcon?: ReactElement;\n}\n\n/**\n * Renderer for CSV files that fetches and displays a snippet of the file data.\n */\nconst CSVFileRenderer: FC<CSVFileRendererProps> = ({ name, url, fileIcon }) => {\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [csvData, setCsvData] = useState<string[][]>([]);\n const [error, setError] = useState<string | null>(null);\n const [isModalOpen, setIsModalOpen] = useState(false);\n const modalRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const fetchCsvData = async () => {\n try {\n setIsLoading(true);\n const response = await fetch(url);\n const data = parseCSV(await response.text());\n setCsvData(data);\n } catch {\n setError('Failed to load CSV file.');\n } finally {\n setIsLoading(false);\n }\n };\n\n fetchCsvData();\n }, [url]);\n\n const toggleModal = () => {\n setIsModalOpen(prev => !prev);\n };\n\n const handleClickOutside = (event: MouseEvent) => {\n if (modalRef.current && !modalRef.current.contains(event.target as Node)) {\n setIsModalOpen(false);\n }\n };\n\n useEffect(() => {\n if (isModalOpen) {\n document.addEventListener('mousedown', handleClickOutside);\n } else {\n document.removeEventListener('mousedown', handleClickOutside);\n }\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n };\n }, [isModalOpen]);\n\n const downloadCSV = () => {\n if (csvData.length === 0) return;\n\n const csvContent = csvData.map(row => row.join(',')).join('\\n');\n const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.setAttribute('download', `${name || 'data'}`);\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n };\n\n const renderTable = (data: string[][], maxRows?: number) => (\n <motion.table\n layout\n className=\"w-full\"\n transition={{ type: 'spring', stiffness: 100, damping: 20 }}\n >\n <thead className=\"sticky top-0 bg-gray-200 dark:bg-gray-800 z-10\">\n <tr>\n <th className=\"py-4 px-6\">#</th>\n {data[0].map((header, index) => (\n <th key={`header-${index}`} className=\"py-4 px-6\">\n {header}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {data.slice(1, maxRows).map((row, rowIndex) => (\n <tr\n key={`row-${rowIndex}`}\n className=\"border-b border-panel-accent light:border-gray-700 hover:bg-panel-accent hover:light:bg-gray-700/40 transition-colors text-base\"\n >\n <td className=\"py-4 px-6\">{rowIndex + 1}</td>\n {row.map((cell, cellIndex) => (\n <td key={`cell-${rowIndex}-${cellIndex}`} className=\"py-4 px-6\">\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </motion.table>\n );\n\n return (\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex justify-between items-center gap-4\">\n <div className=\"csv-icon flex items-center\">\n {fileIcon}\n {name && <figcaption className=\"ml-1\">{name}</figcaption>}\n </div>\n <div className=\"csv-icon flex items-center gap-6\">\n <IconButton size=\"small\" variant=\"text\" onClick={downloadCSV}>\n <DownloadIcon />\n </IconButton>\n <IconButton size=\"small\" variant=\"text\" onClick={toggleModal}>\n <PlaceholderIcon />\n </IconButton>\n </div>\n </div>\n\n {error && <div className=\"error-message\">{error}</div>}\n\n {isLoading && !csvData && (\n <div className=\"text-text-secondary\">Loading...</div>\n )}\n\n <div className=\"flex justify-between\">\n {!error && csvData.length > 0 && renderTable(csvData, 6)}\n </div>\n\n <AnimatePresence>\n {isModalOpen && (\n <motion.div\n className=\"fixed inset-0 bg-black/70 flex justify-center items-center z-50\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.3 }}\n >\n <motion.div\n ref={modalRef}\n className=\"bg-white dark:bg-gray-900 rounded-md w-11/12 h-5/6 overflow-auto\"\n initial={{ scale: 0.8 }}\n animate={{ scale: 1 }}\n exit={{ scale: 0.8 }}\n transition={{ duration: 0.3 }}\n >\n {!error && csvData.length > 0 && renderTable(csvData)}\n </motion.div>\n </motion.div>\n )}\n </AnimatePresence>\n </div>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{
|
|
3
|
-
import { ChatViewType } from './ChatContext';
|
|
4
|
-
import { ChatTheme } from './theme';
|
|
2
|
+
import { Components } from 'react-markdown';
|
|
5
3
|
import { Session } from './types';
|
|
4
|
+
import { ChatTheme } from './theme';
|
|
5
|
+
import { ChatViewType } from './ChatContext';
|
|
6
|
+
import { Plugin } from 'unified';
|
|
6
7
|
export interface ChatProps extends PropsWithChildren {
|
|
7
8
|
/**
|
|
8
9
|
* The style to apply to the root element.
|
|
@@ -36,6 +37,11 @@ export interface ChatProps extends PropsWithChildren {
|
|
|
36
37
|
* Remark plugins to apply to the request/response.
|
|
37
38
|
*/
|
|
38
39
|
remarkPlugins?: Plugin[];
|
|
40
|
+
/**
|
|
41
|
+
* Custom markdown components to override default rendering.
|
|
42
|
+
* Use this to add support for custom elements like charts.
|
|
43
|
+
*/
|
|
44
|
+
markdownComponents?: Components;
|
|
39
45
|
/**
|
|
40
46
|
* Whether to display a loading state.
|
|
41
47
|
*/
|
|
@@ -24,4 +24,4 @@ export interface ChatBubbleProps {
|
|
|
24
24
|
*/
|
|
25
25
|
className?: string;
|
|
26
26
|
}
|
|
27
|
-
export declare const ChatBubble: import('react').
|
|
27
|
+
export declare const ChatBubble: import('react').NamedExoticComponent<ChatBubbleProps>;
|
package/dist/ChatContext.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChatTheme } from './theme';
|
|
1
|
+
import { Components } from 'react-markdown';
|
|
3
2
|
import { Session } from './types';
|
|
3
|
+
import { ChatTheme } from './theme';
|
|
4
|
+
import { Plugin } from 'unified';
|
|
4
5
|
export type ChatViewType = 'chat' | 'companion' | 'console';
|
|
5
6
|
export interface ChatContextProps {
|
|
6
7
|
sessions: Session[];
|
|
@@ -12,6 +13,7 @@ export interface ChatContextProps {
|
|
|
12
13
|
viewType?: ChatViewType;
|
|
13
14
|
activeSession?: Session | null;
|
|
14
15
|
remarkPlugins?: Plugin[];
|
|
16
|
+
markdownComponents?: Components;
|
|
15
17
|
selectSession?: (sessionId: string) => void;
|
|
16
18
|
deleteSession?: (sessionId: string) => void;
|
|
17
19
|
createSession?: () => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
|
|
2
|
+
import { SuggestionConfig, MentionItem, SlashCommandItem } from './types';
|
|
3
|
+
export interface ChatInputProps {
|
|
3
4
|
/**
|
|
4
5
|
* Default value for the input field.
|
|
5
6
|
*/
|
|
@@ -25,17 +26,27 @@ interface ChatInputProps {
|
|
|
25
26
|
*/
|
|
26
27
|
attachIcon?: ReactElement;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* Configuration for mentions (@user).
|
|
30
|
+
* Provide items or an onSearch function to enable mentions.
|
|
29
31
|
*/
|
|
30
|
-
|
|
32
|
+
mentions?: SuggestionConfig<MentionItem>;
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Configuration for commands (/command).
|
|
35
|
+
* Provide items or an onSearch function to enable commands.
|
|
33
36
|
*/
|
|
34
|
-
|
|
37
|
+
commands?: SuggestionConfig<SlashCommandItem>;
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
39
|
+
* Minimum height for the input (default: 24px)
|
|
37
40
|
*/
|
|
38
|
-
|
|
41
|
+
minHeight?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum height for the input (default: 200px)
|
|
44
|
+
*/
|
|
45
|
+
maxHeight?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to auto-focus the input on mount (default: true)
|
|
48
|
+
*/
|
|
49
|
+
autoFocus?: boolean;
|
|
39
50
|
}
|
|
40
51
|
export interface ChatInputRef {
|
|
41
52
|
/**
|
|
@@ -43,17 +54,16 @@ export interface ChatInputRef {
|
|
|
43
54
|
*/
|
|
44
55
|
focus: () => void;
|
|
45
56
|
/**
|
|
46
|
-
*
|
|
57
|
+
* Get the current input value.
|
|
47
58
|
*/
|
|
48
|
-
|
|
59
|
+
getValue: () => string;
|
|
49
60
|
/**
|
|
50
|
-
* Set the input value
|
|
61
|
+
* Set the input value.
|
|
51
62
|
*/
|
|
52
63
|
setValue: (value: string) => void;
|
|
53
64
|
/**
|
|
54
|
-
*
|
|
65
|
+
* Insert text at the current cursor position.
|
|
55
66
|
*/
|
|
56
|
-
|
|
67
|
+
insertText: (text: string) => void;
|
|
57
68
|
}
|
|
58
69
|
export declare const ChatInput: import('react').ForwardRefExoticComponent<ChatInputProps & import('react').RefAttributes<ChatInputRef>>;
|
|
59
|
-
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SuggestionConfig, SuggestionItem } from './types';
|
|
2
|
+
export interface MentionListRef {
|
|
3
|
+
onKeyDown: (props: {
|
|
4
|
+
event: KeyboardEvent;
|
|
5
|
+
}) => boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface MentionListProps {
|
|
8
|
+
/**
|
|
9
|
+
* List of suggestion items to display
|
|
10
|
+
*/
|
|
11
|
+
items: SuggestionItem[];
|
|
12
|
+
/**
|
|
13
|
+
* Callback to execute the selected suggestion command
|
|
14
|
+
*/
|
|
15
|
+
command: (item: {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The trigger character (e.g., '@' or '/')
|
|
21
|
+
*/
|
|
22
|
+
triggerChar: string;
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for the suggestion popup
|
|
25
|
+
*/
|
|
26
|
+
config: SuggestionConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Current search query text
|
|
29
|
+
*/
|
|
30
|
+
query?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const MentionList: import('react').ForwardRefExoticComponent<MentionListProps & import('react').RefAttributes<MentionListRef>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SuggestionConfig } from './types';
|
|
3
|
+
export interface RichTextInputRef {
|
|
4
|
+
focus: () => void;
|
|
5
|
+
getValue: () => string;
|
|
6
|
+
setValue: (value: string) => void;
|
|
7
|
+
insertText: (text: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface RichTextInputProps {
|
|
10
|
+
/**
|
|
11
|
+
* Current value of the input
|
|
12
|
+
*/
|
|
13
|
+
value?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Placeholder text when empty
|
|
16
|
+
*/
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the input is disabled
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to auto-focus on mount (default: true)
|
|
24
|
+
*/
|
|
25
|
+
autoFocus?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Additional CSS classes
|
|
28
|
+
*/
|
|
29
|
+
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Minimum height in pixels (default: 24)
|
|
32
|
+
*/
|
|
33
|
+
minHeight?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum height in pixels (default: 200)
|
|
36
|
+
*/
|
|
37
|
+
maxHeight?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for @ mentions
|
|
40
|
+
*/
|
|
41
|
+
mentions?: SuggestionConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Configuration for / slash commands
|
|
44
|
+
*/
|
|
45
|
+
commands?: SuggestionConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Callback when user submits (presses Enter)
|
|
48
|
+
*/
|
|
49
|
+
onSubmit?: (value: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Callback when input value changes
|
|
52
|
+
*/
|
|
53
|
+
onChange?: (value: string) => void;
|
|
54
|
+
}
|
|
55
|
+
export declare const RichTextInput: React.ForwardRefExoticComponent<RichTextInputProps & React.RefAttributes<RichTextInputRef>>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Base interface for all suggestion items (mentions, commands, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export interface SuggestionItem {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier for the item
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Display name/label for the item
|
|
12
|
+
*/
|
|
13
|
+
label: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional description for additional context
|
|
16
|
+
*/
|
|
17
|
+
description?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional icon to display next to the item
|
|
20
|
+
*/
|
|
21
|
+
icon?: ReactElement;
|
|
22
|
+
/**
|
|
23
|
+
* Optional metadata for custom use cases
|
|
24
|
+
*/
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for a mention (@) item
|
|
29
|
+
*/
|
|
30
|
+
export interface MentionItem extends SuggestionItem {
|
|
31
|
+
/**
|
|
32
|
+
* The value to insert when mention is selected
|
|
33
|
+
* Defaults to @{label} if not specified
|
|
34
|
+
*/
|
|
35
|
+
value?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for a slash command (/) item
|
|
39
|
+
*/
|
|
40
|
+
export interface SlashCommandItem extends SuggestionItem {
|
|
41
|
+
/**
|
|
42
|
+
* Optional shortcut hint to display
|
|
43
|
+
*/
|
|
44
|
+
shortcut?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether this command inserts text or triggers an action
|
|
47
|
+
*/
|
|
48
|
+
type?: 'insert' | 'action';
|
|
49
|
+
/**
|
|
50
|
+
* The value to insert when command is selected (for 'insert' type)
|
|
51
|
+
*/
|
|
52
|
+
value?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for a suggestion trigger (mentions, commands, or custom)
|
|
56
|
+
*/
|
|
57
|
+
export interface SuggestionConfig<T extends SuggestionItem = SuggestionItem> {
|
|
58
|
+
/**
|
|
59
|
+
* The character that triggers this suggestion (e.g., '@', '/', '#')
|
|
60
|
+
*/
|
|
61
|
+
trigger?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Static list of available items for this trigger
|
|
64
|
+
*/
|
|
65
|
+
items?: T[];
|
|
66
|
+
/**
|
|
67
|
+
* Async function to fetch items dynamically based on query
|
|
68
|
+
*/
|
|
69
|
+
onSearch?: (query: string) => Promise<T[]> | T[];
|
|
70
|
+
/**
|
|
71
|
+
* Callback when an item is selected
|
|
72
|
+
*/
|
|
73
|
+
onSelect?: (item: T, insertText: (text: string) => void) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Maximum items to show in the popup (default: 10)
|
|
76
|
+
*/
|
|
77
|
+
maxResults?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Custom render function for items
|
|
80
|
+
*/
|
|
81
|
+
renderItem?: (item: T, isHighlighted: boolean) => ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Custom render function for empty state
|
|
84
|
+
*/
|
|
85
|
+
renderEmpty?: (query: string) => ReactNode;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for mentions
|
|
89
|
+
* @deprecated Use SuggestionConfig directly with trigger: '@'
|
|
90
|
+
*/
|
|
91
|
+
export type MentionPluginConfig = SuggestionConfig<MentionItem>;
|
|
92
|
+
/**
|
|
93
|
+
* Configuration for slash commands
|
|
94
|
+
* @deprecated Use SuggestionConfig directly with trigger: '/'
|
|
95
|
+
*/
|
|
96
|
+
export type SlashCommandPluginConfig = SuggestionConfig<SlashCommandItem>;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use SuggestionItem instead
|
|
99
|
+
*/
|
|
100
|
+
export type InputPluginItem = SuggestionItem;
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use SuggestionConfig instead
|
|
103
|
+
*/
|
|
104
|
+
export type InputTrigger<T extends SuggestionItem = SuggestionItem> = SuggestionConfig<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Suggestion } from '../types';
|
|
3
|
+
export interface ChatSuggestionProps extends Suggestion {
|
|
4
|
+
/**
|
|
5
|
+
* Callback when the suggestion is clicked.
|
|
6
|
+
*/
|
|
7
|
+
onClick?: (suggestion: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ChatSuggestion: FC<ChatSuggestionProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FC, ReactElement } from 'react';
|
|
2
|
+
import { Suggestion } from '../types';
|
|
3
|
+
export interface ChatSuggestionsProps {
|
|
4
|
+
/**
|
|
5
|
+
* Array of suggestions to display.
|
|
6
|
+
*/
|
|
7
|
+
suggestions: Suggestion[];
|
|
8
|
+
/**
|
|
9
|
+
* Custom class name to apply to the container.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Callback when a suggestion is clicked.
|
|
14
|
+
*/
|
|
15
|
+
onSuggestionClick?: (suggestion: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Custom render function for each suggestion item.
|
|
18
|
+
* Receives the suggestion data and onClick handler.
|
|
19
|
+
*/
|
|
20
|
+
children?: ReactElement;
|
|
21
|
+
}
|
|
22
|
+
export declare const ChatSuggestions: FC<ChatSuggestionsProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { S as SvgFile } from "./index-B3dZT-5c.js";
|
|
2
3
|
import { cn, Ellipsis } from "reablocks";
|
|
3
|
-
import { S as SvgFile } from "./index-DRRvnZUj.js";
|
|
4
4
|
const DefaultFileRenderer = ({
|
|
5
5
|
name,
|
|
6
6
|
limit = 100,
|
|
@@ -12,4 +12,4 @@ const DefaultFileRenderer = ({
|
|
|
12
12
|
export {
|
|
13
13
|
DefaultFileRenderer as default
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=DefaultFileRenderer-
|
|
15
|
+
//# sourceMappingURL=DefaultFileRenderer-BLV8PtJk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultFileRenderer-BLV8PtJk.js","sources":["../src/SessionMessages/SessionMessage/MessageFile/renderers/DefaultFileRenderer.tsx"],"sourcesContent":["import { FC, ReactElement } from 'react';\nimport FileIcon from '@/assets/file.svg?react';\nimport { Ellipsis, cn } from 'reablocks';\n\ninterface DefaultFileRendererProps {\n /**\n * Limit for the name.\n */\n limit?: number;\n\n /**\n * Name of the file.\n */\n name?: string;\n\n /**\n * URL of the file.\n */\n url: string;\n\n /**\n * Icon to for file type.\n */\n fileIcon?: ReactElement;\n}\n\n/**\n * Default renderer for unspecified file types.\n */\nconst DefaultFileRenderer: FC<DefaultFileRendererProps> = ({\n name,\n limit = 100,\n fileIcon = <FileIcon />,\n}) => (\n <figure className=\"flex items-center gap-2\">\n {fileIcon}\n {name && (\n <figcaption className={cn('file-name-class')}>\n <Ellipsis value={name} limit={limit} />\n </figcaption>\n )}\n </figure>\n);\n\nexport default DefaultFileRenderer;\n"],"names":["FileIcon"],"mappings":";;;AA6BA,MAAM,sBAAoD,CAAC;AAAA,EACzD;AAAA,EACA,QAAQ;AAAA,EACR,+BAAYA,SAAA,CAAA,CAAS;AACvB,MACE,qBAAC,UAAA,EAAO,WAAU,2BACf,UAAA;AAAA,EAAA;AAAA,EACA,QACC,oBAAC,cAAA,EAAW,WAAW,GAAG,iBAAiB,GACzC,UAAA,oBAAC,UAAA,EAAS,OAAO,MAAM,MAAA,CAAc,EAAA,CACvC;AAAA,EAAA,CAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageFileRenderer-C8tVW3I8.js","sources":["../src/SessionMessages/SessionMessage/MessageFile/renderers/ImageFileRenderer.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"ImageFileRenderer-C8tVW3I8.js","sources":["../src/SessionMessages/SessionMessage/MessageFile/renderers/ImageFileRenderer.tsx"],"sourcesContent":["import { FC } from 'react';\n\ninterface ImageFileRendererProps {\n /**\n * Name of the file.\n */\n name?: string;\n\n /**\n * URL of the file.\n */\n url: string;\n}\n\n/**\n * Renderer for image files.\n */\nconst ImageFileRenderer: FC<ImageFileRendererProps> = ({ url }) => (\n <img src={url} alt=\"Image\" className=\"size-10\" />\n);\n\nexport default ImageFileRenderer;\n"],"names":[],"mappings":";AAiBA,MAAM,oBAAgD,CAAC,EAAE,IAAA,MACvD,oBAAC,OAAA,EAAI,KAAK,KAAK,KAAI,SAAQ,WAAU,UAAA,CAAU;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { Components } from 'react-markdown';
|
|
2
3
|
import { Plugin } from 'unified';
|
|
3
|
-
import { ChatTheme } from '../theme';
|
|
4
4
|
interface MarkdownWrapperProps extends PropsWithChildren {
|
|
5
5
|
/**
|
|
6
6
|
* Remark plugins to apply to the markdown content.
|
|
@@ -11,9 +11,10 @@ interface MarkdownWrapperProps extends PropsWithChildren {
|
|
|
11
11
|
*/
|
|
12
12
|
rehypePlugins?: Plugin[];
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Custom components to override default markdown rendering.
|
|
15
|
+
* These will be merged with the default components.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
customComponents?: Components;
|
|
17
18
|
}
|
|
18
19
|
export declare const Markdown: FC<MarkdownWrapperProps>;
|
|
19
20
|
export {};
|
package/dist/Markdown/Table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { default as React, FC, PropsWithChildren } from 'react';
|
|
2
2
|
export declare const TableComponent: FC<PropsWithChildren<React.HTMLAttributes<HTMLTableElement>>>;
|
|
3
3
|
export declare const TableHeaderCell: FC<PropsWithChildren<React.HTMLAttributes<HTMLTableHeaderCellElement>>>;
|
|
4
4
|
export declare const TableDataCell: FC<PropsWithChildren<React.HTMLAttributes<HTMLTableDataCellElement>>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface ChartErrorProps {
|
|
3
|
+
/**
|
|
4
|
+
* The visual style variant of the error display.
|
|
5
|
+
* Defaults to 'error'.
|
|
6
|
+
*/
|
|
7
|
+
variant?: 'error' | 'warning';
|
|
8
|
+
/**
|
|
9
|
+
* The heading text displayed at the top of the error.
|
|
10
|
+
*/
|
|
11
|
+
title?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The descriptive message explaining the error or warning.
|
|
14
|
+
*/
|
|
15
|
+
message?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The raw code or data that caused the error, displayed in a code block.
|
|
18
|
+
*/
|
|
19
|
+
code?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const ChartError: FC<ChartErrorProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ChartConfig } from '../plugins/remarkChart';
|
|
3
|
+
export interface ChartRendererProps {
|
|
4
|
+
/**
|
|
5
|
+
* The chart configuration.
|
|
6
|
+
*/
|
|
7
|
+
config: ChartConfig;
|
|
8
|
+
/**
|
|
9
|
+
* The class name to apply to the chart container.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const ChartRenderer: FC<ChartRendererProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ChartConfig } from '../plugins/remarkChart';
|
|
3
|
+
/**
|
|
4
|
+
* Validates that chart data is an array of objects with the required structure.
|
|
5
|
+
* Each item must have a `key` (convertible to string) and `data` (number) property.
|
|
6
|
+
*
|
|
7
|
+
* @param data - The unknown data array to validate
|
|
8
|
+
* @returns An array of validated chart data points with `key` and `data` properties,
|
|
9
|
+
* or `null` if the data is invalid or empty
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateChartData(data: unknown[]): {
|
|
12
|
+
key: string;
|
|
13
|
+
data: number;
|
|
14
|
+
}[] | null;
|
|
15
|
+
/**
|
|
16
|
+
* Parses a JSON string into a validated ChartConfig object.
|
|
17
|
+
* The JSON must contain a `type` and `data` property, where `data` is validated
|
|
18
|
+
* using `validateChartData`.
|
|
19
|
+
*
|
|
20
|
+
* @param value - The JSON string to parse
|
|
21
|
+
* @returns A validated ChartConfig object, or `null` if parsing fails or the config is invalid
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseChartConfig(value: string): ChartConfig | null;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the given className indicates a chart code block.
|
|
26
|
+
* Used to identify markdown code blocks that should be rendered as charts.
|
|
27
|
+
*
|
|
28
|
+
* @param className - The className to check
|
|
29
|
+
* @returns `true` if the className is 'language-chart', `false` otherwise
|
|
30
|
+
*/
|
|
31
|
+
export declare function isChartClassName(className?: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Recursively extracts text content from React children.
|
|
34
|
+
* Handles strings, numbers, arrays, and React elements by traversing
|
|
35
|
+
* their children props.
|
|
36
|
+
*
|
|
37
|
+
* @param children - The React children to extract text from
|
|
38
|
+
* @returns The concatenated text content as a string
|
|
39
|
+
*/
|
|
40
|
+
export declare function getChildText(children: React.ReactNode): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|