reachat 1.3.0 → 1.3.1
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/ChatInput/FileInput.d.ts +26 -0
- package/dist/ChatInput/index.d.ts +2 -0
- package/dist/SessionMessages/SessionMessage/MessageQuestion.d.ts +5 -0
- package/dist/docs.json +139 -16
- package/dist/index.js +87 -66
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +84 -63
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +1 -1
- /package/dist/{ChatInput.d.ts → ChatInput/ChatInput.d.ts} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC, ReactNode, ChangeEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
interface FileInputProps {
|
|
4
|
+
/**
|
|
5
|
+
* Array of allowed file extensions.
|
|
6
|
+
*/
|
|
7
|
+
allowedFiles: string[];
|
|
8
|
+
/**
|
|
9
|
+
* Indicates whether a file upload is in progress.
|
|
10
|
+
*/
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Disables the file input when true.
|
|
14
|
+
*/
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Custom icon for the attach button.
|
|
18
|
+
*/
|
|
19
|
+
attachIcon: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Callback function triggered when a file is selected.
|
|
22
|
+
*/
|
|
23
|
+
onFileUpload: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const FileInput: FC<FileInputProps>;
|
|
26
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { ConversationFile } from '../../types';
|
|
2
3
|
|
|
3
4
|
export interface MessageQuestionProps extends PropsWithChildren {
|
|
4
5
|
/**
|
|
5
6
|
* Question to render.
|
|
6
7
|
*/
|
|
7
8
|
question: string;
|
|
9
|
+
/**
|
|
10
|
+
* Array of sources referenced in the conversation
|
|
11
|
+
*/
|
|
12
|
+
files?: ConversationFile[];
|
|
8
13
|
}
|
|
9
14
|
export declare const MessageQuestion: FC<MessageQuestionProps>;
|
package/dist/docs.json
CHANGED
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
},
|
|
300
300
|
{
|
|
301
301
|
"tags": {},
|
|
302
|
-
"filePath": "src/ChatInput.tsx",
|
|
302
|
+
"filePath": "src/ChatInput/ChatInput.tsx",
|
|
303
303
|
"description": "",
|
|
304
304
|
"displayName": "ChatInput",
|
|
305
305
|
"methods": [],
|
|
@@ -309,12 +309,12 @@
|
|
|
309
309
|
"description": "Default value for the input field.",
|
|
310
310
|
"name": "defaultValue",
|
|
311
311
|
"parent": {
|
|
312
|
-
"fileName": "src/ChatInput.tsx",
|
|
312
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
313
313
|
"name": "ChatInputProps"
|
|
314
314
|
},
|
|
315
315
|
"declarations": [
|
|
316
316
|
{
|
|
317
|
-
"fileName": "src/ChatInput.tsx",
|
|
317
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
318
318
|
"name": "ChatInputProps"
|
|
319
319
|
}
|
|
320
320
|
],
|
|
@@ -328,12 +328,12 @@
|
|
|
328
328
|
"description": "Allowed file types for upload.",
|
|
329
329
|
"name": "allowedFiles",
|
|
330
330
|
"parent": {
|
|
331
|
-
"fileName": "src/ChatInput.tsx",
|
|
331
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
332
332
|
"name": "ChatInputProps"
|
|
333
333
|
},
|
|
334
334
|
"declarations": [
|
|
335
335
|
{
|
|
336
|
-
"fileName": "src/ChatInput.tsx",
|
|
336
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
337
337
|
"name": "ChatInputProps"
|
|
338
338
|
}
|
|
339
339
|
],
|
|
@@ -347,12 +347,12 @@
|
|
|
347
347
|
"description": "Placeholder text for the input field.",
|
|
348
348
|
"name": "placeholder",
|
|
349
349
|
"parent": {
|
|
350
|
-
"fileName": "src/ChatInput.tsx",
|
|
350
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
351
351
|
"name": "ChatInputProps"
|
|
352
352
|
},
|
|
353
353
|
"declarations": [
|
|
354
354
|
{
|
|
355
|
-
"fileName": "src/ChatInput.tsx",
|
|
355
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
356
356
|
"name": "ChatInputProps"
|
|
357
357
|
}
|
|
358
358
|
],
|
|
@@ -368,12 +368,12 @@
|
|
|
368
368
|
"description": "Icon to show for send.",
|
|
369
369
|
"name": "sendIcon",
|
|
370
370
|
"parent": {
|
|
371
|
-
"fileName": "src/ChatInput.tsx",
|
|
371
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
372
372
|
"name": "ChatInputProps"
|
|
373
373
|
},
|
|
374
374
|
"declarations": [
|
|
375
375
|
{
|
|
376
|
-
"fileName": "src/ChatInput.tsx",
|
|
376
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
377
377
|
"name": "ChatInputProps"
|
|
378
378
|
}
|
|
379
379
|
],
|
|
@@ -389,12 +389,12 @@
|
|
|
389
389
|
"description": "Icon to show for send.",
|
|
390
390
|
"name": "stopIcon",
|
|
391
391
|
"parent": {
|
|
392
|
-
"fileName": "src/ChatInput.tsx",
|
|
392
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
393
393
|
"name": "ChatInputProps"
|
|
394
394
|
},
|
|
395
395
|
"declarations": [
|
|
396
396
|
{
|
|
397
|
-
"fileName": "src/ChatInput.tsx",
|
|
397
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
398
398
|
"name": "ChatInputProps"
|
|
399
399
|
}
|
|
400
400
|
],
|
|
@@ -404,18 +404,16 @@
|
|
|
404
404
|
}
|
|
405
405
|
},
|
|
406
406
|
"attachIcon": {
|
|
407
|
-
"defaultValue":
|
|
408
|
-
"value": "<AttachIcon />"
|
|
409
|
-
},
|
|
407
|
+
"defaultValue": null,
|
|
410
408
|
"description": "Icon to show for attach.",
|
|
411
409
|
"name": "attachIcon",
|
|
412
410
|
"parent": {
|
|
413
|
-
"fileName": "src/ChatInput.tsx",
|
|
411
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
414
412
|
"name": "ChatInputProps"
|
|
415
413
|
},
|
|
416
414
|
"declarations": [
|
|
417
415
|
{
|
|
418
|
-
"fileName": "src/ChatInput.tsx",
|
|
416
|
+
"fileName": "src/ChatInput/ChatInput.tsx",
|
|
419
417
|
"name": "ChatInputProps"
|
|
420
418
|
}
|
|
421
419
|
],
|
|
@@ -426,6 +424,112 @@
|
|
|
426
424
|
}
|
|
427
425
|
}
|
|
428
426
|
},
|
|
427
|
+
{
|
|
428
|
+
"tags": {},
|
|
429
|
+
"filePath": "src/ChatInput/FileInput.tsx",
|
|
430
|
+
"description": "",
|
|
431
|
+
"displayName": "FileInput",
|
|
432
|
+
"methods": [],
|
|
433
|
+
"props": {
|
|
434
|
+
"allowedFiles": {
|
|
435
|
+
"defaultValue": null,
|
|
436
|
+
"description": "Array of allowed file extensions.",
|
|
437
|
+
"name": "allowedFiles",
|
|
438
|
+
"parent": {
|
|
439
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
440
|
+
"name": "FileInputProps"
|
|
441
|
+
},
|
|
442
|
+
"declarations": [
|
|
443
|
+
{
|
|
444
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
445
|
+
"name": "FileInputProps"
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
"required": true,
|
|
449
|
+
"type": {
|
|
450
|
+
"name": "string[]"
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
"isLoading": {
|
|
454
|
+
"defaultValue": null,
|
|
455
|
+
"description": "Indicates whether a file upload is in progress.",
|
|
456
|
+
"name": "isLoading",
|
|
457
|
+
"parent": {
|
|
458
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
459
|
+
"name": "FileInputProps"
|
|
460
|
+
},
|
|
461
|
+
"declarations": [
|
|
462
|
+
{
|
|
463
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
464
|
+
"name": "FileInputProps"
|
|
465
|
+
}
|
|
466
|
+
],
|
|
467
|
+
"required": true,
|
|
468
|
+
"type": {
|
|
469
|
+
"name": "boolean"
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
"disabled": {
|
|
473
|
+
"defaultValue": null,
|
|
474
|
+
"description": "Disables the file input when true.",
|
|
475
|
+
"name": "disabled",
|
|
476
|
+
"parent": {
|
|
477
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
478
|
+
"name": "FileInputProps"
|
|
479
|
+
},
|
|
480
|
+
"declarations": [
|
|
481
|
+
{
|
|
482
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
483
|
+
"name": "FileInputProps"
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
"required": true,
|
|
487
|
+
"type": {
|
|
488
|
+
"name": "boolean"
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
"attachIcon": {
|
|
492
|
+
"defaultValue": {
|
|
493
|
+
"value": "<AttachIcon />"
|
|
494
|
+
},
|
|
495
|
+
"description": "Custom icon for the attach button.",
|
|
496
|
+
"name": "attachIcon",
|
|
497
|
+
"parent": {
|
|
498
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
499
|
+
"name": "FileInputProps"
|
|
500
|
+
},
|
|
501
|
+
"declarations": [
|
|
502
|
+
{
|
|
503
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
504
|
+
"name": "FileInputProps"
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
"required": false,
|
|
508
|
+
"type": {
|
|
509
|
+
"name": "ReactNode"
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
"onFileUpload": {
|
|
513
|
+
"defaultValue": null,
|
|
514
|
+
"description": "Callback function triggered when a file is selected.",
|
|
515
|
+
"name": "onFileUpload",
|
|
516
|
+
"parent": {
|
|
517
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
518
|
+
"name": "FileInputProps"
|
|
519
|
+
},
|
|
520
|
+
"declarations": [
|
|
521
|
+
{
|
|
522
|
+
"fileName": "src/ChatInput/FileInput.tsx",
|
|
523
|
+
"name": "FileInputProps"
|
|
524
|
+
}
|
|
525
|
+
],
|
|
526
|
+
"required": true,
|
|
527
|
+
"type": {
|
|
528
|
+
"name": "(event: ChangeEvent<HTMLInputElement>) => void"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
},
|
|
429
533
|
{
|
|
430
534
|
"tags": {},
|
|
431
535
|
"filePath": "src/Markdown/CodeHighlighter.tsx",
|
|
@@ -1324,6 +1428,25 @@
|
|
|
1324
1428
|
"type": {
|
|
1325
1429
|
"name": "string"
|
|
1326
1430
|
}
|
|
1431
|
+
},
|
|
1432
|
+
"files": {
|
|
1433
|
+
"defaultValue": null,
|
|
1434
|
+
"description": "Array of sources referenced in the conversation",
|
|
1435
|
+
"name": "files",
|
|
1436
|
+
"parent": {
|
|
1437
|
+
"fileName": "src/SessionMessages/SessionMessage/MessageQuestion.tsx",
|
|
1438
|
+
"name": "MessageQuestionProps"
|
|
1439
|
+
},
|
|
1440
|
+
"declarations": [
|
|
1441
|
+
{
|
|
1442
|
+
"fileName": "src/SessionMessages/SessionMessage/MessageQuestion.tsx",
|
|
1443
|
+
"name": "MessageQuestionProps"
|
|
1444
|
+
}
|
|
1445
|
+
],
|
|
1446
|
+
"required": false,
|
|
1447
|
+
"type": {
|
|
1448
|
+
"name": "ConversationFile[]"
|
|
1449
|
+
}
|
|
1327
1450
|
}
|
|
1328
1451
|
}
|
|
1329
1452
|
},
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
console.error("vite-plugin-css-injected-by-js", e);
|
|
11
11
|
}
|
|
12
12
|
})();
|
|
13
|
-
import { jsxs,
|
|
13
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
14
14
|
import * as React from "react";
|
|
15
|
-
import { createContext,
|
|
16
|
-
import { cn, Textarea,
|
|
15
|
+
import { createContext, useContext, useRef, forwardRef, useState, useImperativeHandle, useEffect, useMemo, useCallback } from "react";
|
|
16
|
+
import { Button, cn, Textarea, Ellipsis, DateFormat, IconButton, Card, Divider, useInfinityList, useComponentTheme, List, ListItem } from "reablocks";
|
|
17
17
|
import { Slot } from "@radix-ui/react-slot";
|
|
18
18
|
import { motion, AnimatePresence } from "framer-motion";
|
|
19
19
|
import ReactMarkdown from "react-markdown";
|
|
@@ -27,22 +27,57 @@ import remarkMath from "remark-math";
|
|
|
27
27
|
import { isToday, isYesterday, isThisWeek, isThisMonth, isThisYear, format } from "date-fns";
|
|
28
28
|
const SvgSend = (props) => /* @__PURE__ */ React.createElement("svg", { width: 17, height: 17, viewBox: "0 0 17 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("g", { id: "send" }, /* @__PURE__ */ React.createElement("path", { id: "Vector", d: "M14.6111 2.33327C14.5349 2.3339 14.4598 2.35194 14.3917 2.386L2.39168 8.386C2.31456 8.42456 2.24872 8.4824 2.20055 8.55391C2.15238 8.62543 2.12352 8.70818 2.11677 8.79414C2.11002 8.88009 2.12561 8.96634 2.16203 9.04449C2.19845 9.12264 2.25446 9.19005 2.32462 9.24017L4.52514 10.8124L5.47371 13.6581C5.50257 13.7447 5.55457 13.8217 5.62406 13.8808C5.69355 13.9399 5.7779 13.9789 5.86796 13.9935C5.95802 14.0082 6.05036 13.9979 6.13499 13.9638C6.21962 13.9297 6.2933 13.873 6.34806 13.8001L7.05249 12.8606L10.3207 15.2376C10.3843 15.2839 10.4579 15.3146 10.5355 15.3271C10.6132 15.3396 10.6927 15.3336 10.7676 15.3097C10.8425 15.2857 10.9107 15.2444 10.9667 15.1891C11.0226 15.1338 11.0647 15.0661 11.0896 14.9915L15.0896 2.99147C15.1148 2.91597 15.1216 2.83555 15.1094 2.7569C15.0972 2.67825 15.0665 2.60363 15.0197 2.53926C14.9729 2.47488 14.9114 2.42261 14.8403 2.38678C14.7693 2.35096 14.6907 2.33261 14.6111 2.33327ZM13.2478 5.35345L10.3565 14.0266L7.67293 12.0755L13.2478 5.35345ZM10.684 5.35801L4.934 9.87559L3.58113 8.90879L10.684 5.35801ZM11.2784 6.16205L6.56746 11.843C6.56681 11.8437 6.56616 11.8443 6.56551 11.845L6.56355 11.8476C6.55841 11.8538 6.55342 11.8601 6.54858 11.8665C6.54319 11.8733 6.53798 11.8802 6.53295 11.8873L6.12085 12.4361L5.53426 10.6751L11.2784 6.16205Z", fill: "currentColor" })));
|
|
29
29
|
const SvgStop = (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-octagon-x", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m15 9-6 6" }), /* @__PURE__ */ React.createElement("path", { d: "M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z" }), /* @__PURE__ */ React.createElement("path", { d: "m9 9 6 6" }));
|
|
30
|
-
const SvgPaperclip = (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-paperclip", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" }));
|
|
31
30
|
const ChatContext = createContext({
|
|
32
31
|
sessions: [],
|
|
33
32
|
activeSessionId: null
|
|
34
33
|
});
|
|
34
|
+
const SvgPaperclip = (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-paperclip", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" }));
|
|
35
|
+
const FileInput = ({
|
|
36
|
+
allowedFiles,
|
|
37
|
+
onFileUpload,
|
|
38
|
+
isLoading,
|
|
39
|
+
disabled,
|
|
40
|
+
attachIcon = /* @__PURE__ */ jsx(SvgPaperclip, {})
|
|
41
|
+
}) => {
|
|
42
|
+
const { theme } = useContext(ChatContext);
|
|
43
|
+
const fileInputRef = useRef(null);
|
|
44
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
"input",
|
|
47
|
+
{
|
|
48
|
+
type: "file",
|
|
49
|
+
ref: fileInputRef,
|
|
50
|
+
className: "hidden",
|
|
51
|
+
accept: allowedFiles.join(","),
|
|
52
|
+
onChange: onFileUpload
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
Button,
|
|
57
|
+
{
|
|
58
|
+
title: "Upload",
|
|
59
|
+
variant: "text",
|
|
60
|
+
disabled: isLoading || disabled,
|
|
61
|
+
className: cn(theme.input.upload),
|
|
62
|
+
onClick: () => {
|
|
63
|
+
var _a;
|
|
64
|
+
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
65
|
+
},
|
|
66
|
+
children: attachIcon
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] });
|
|
70
|
+
};
|
|
35
71
|
const ChatInput = forwardRef(({
|
|
36
72
|
allowedFiles,
|
|
37
73
|
placeholder,
|
|
38
74
|
defaultValue,
|
|
39
75
|
sendIcon = /* @__PURE__ */ jsx(SvgSend, {}),
|
|
40
76
|
stopIcon = /* @__PURE__ */ jsx(SvgStop, {}),
|
|
41
|
-
attachIcon
|
|
77
|
+
attachIcon
|
|
42
78
|
}, ref) => {
|
|
43
79
|
const { theme, isLoading, disabled, sendMessage, stopMessage, fileUpload } = useContext(ChatContext);
|
|
44
80
|
const [message, setMessage] = useState("");
|
|
45
|
-
const fileInputRef = useRef(null);
|
|
46
81
|
const inputRef = useRef(null);
|
|
47
82
|
useImperativeHandle(ref, () => ({
|
|
48
83
|
focus: () => {
|
|
@@ -86,32 +121,16 @@ const ChatInput = forwardRef(({
|
|
|
86
121
|
}
|
|
87
122
|
),
|
|
88
123
|
/* @__PURE__ */ jsxs("div", { className: cn(theme.input.actions.base), children: [
|
|
89
|
-
(allowedFiles == null ? void 0 : allowedFiles.length) > 0 && /* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
),
|
|
100
|
-
/* @__PURE__ */ jsx(
|
|
101
|
-
Button,
|
|
102
|
-
{
|
|
103
|
-
title: "Upload",
|
|
104
|
-
variant: "text",
|
|
105
|
-
disabled: isLoading || disabled,
|
|
106
|
-
className: cn(theme.input.upload),
|
|
107
|
-
onClick: () => {
|
|
108
|
-
var _a;
|
|
109
|
-
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
110
|
-
},
|
|
111
|
-
children: attachIcon
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
] }),
|
|
124
|
+
(allowedFiles == null ? void 0 : allowedFiles.length) > 0 && /* @__PURE__ */ jsx(
|
|
125
|
+
FileInput,
|
|
126
|
+
{
|
|
127
|
+
allowedFiles,
|
|
128
|
+
onFileUpload: handleFileUpload,
|
|
129
|
+
isLoading,
|
|
130
|
+
disabled,
|
|
131
|
+
attachIcon
|
|
132
|
+
}
|
|
133
|
+
),
|
|
115
134
|
isLoading && /* @__PURE__ */ jsx(
|
|
116
135
|
Button,
|
|
117
136
|
{
|
|
@@ -1300,8 +1319,41 @@ function remarkCve() {
|
|
|
1300
1319
|
];
|
|
1301
1320
|
}
|
|
1302
1321
|
}
|
|
1322
|
+
const SvgFile = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, viewBox: "0 0 16 16", fill: "currentColor", ...props }, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.7036 1.37034C3.04741 1.02653 3.51373 0.833374 3.99996 0.833374H9.33329H9.33331C9.47275 0.833374 9.59885 0.890449 9.68954 0.98251L13.6843 4.97722C13.7763 5.0679 13.8333 5.19398 13.8333 5.33337L13.8333 5.3379V13.3334C13.8333 13.8196 13.6401 14.2859 13.2963 14.6297C12.9525 14.9736 12.4862 15.1667 12 15.1667H3.99996C3.51373 15.1667 3.04741 14.9736 2.7036 14.6297C2.35978 14.2859 2.16663 13.8196 2.16663 13.3334V2.66671C2.16663 2.18048 2.35978 1.71416 2.7036 1.37034ZM3.99996 1.83337H8.83331V5.33337C8.83331 5.60952 9.05717 5.83337 9.33331 5.83337H12.8333V13.3334C12.8333 13.5544 12.7455 13.7663 12.5892 13.9226C12.4329 14.0789 12.221 14.1667 12 14.1667H3.99996C3.77895 14.1667 3.56698 14.0789 3.4107 13.9226C3.25442 13.7663 3.16663 13.5544 3.16663 13.3334V2.66671C3.16663 2.44569 3.25442 2.23373 3.4107 2.07745C3.56698 1.92117 3.77895 1.83337 3.99996 1.83337ZM9.83331 2.5405L12.1262 4.83337H9.83331V2.5405ZM5.33331 8.16663C5.05717 8.16663 4.83331 8.39048 4.83331 8.66663C4.83331 8.94277 5.05717 9.16663 5.33331 9.16663H10.6666C10.9428 9.16663 11.1666 8.94277 11.1666 8.66663C11.1666 8.39048 10.9428 8.16663 10.6666 8.16663H5.33331ZM4.83331 11.3334C4.83331 11.0572 5.05717 10.8334 5.33331 10.8334H10.6666C10.9428 10.8334 11.1666 11.0572 11.1666 11.3334C11.1666 11.6095 10.9428 11.8334 10.6666 11.8334H5.33331C5.05717 11.8334 4.83331 11.6095 4.83331 11.3334ZM5.33331 5.5C5.05717 5.5 4.83331 5.72386 4.83331 6C4.83331 6.27614 5.05717 6.5 5.33331 6.5H6.66665C6.94279 6.5 7.16665 6.27614 7.16665 6C7.16665 5.72386 6.94279 5.5 6.66665 5.5H5.33331Z" }));
|
|
1323
|
+
const MessageFile = ({
|
|
1324
|
+
name,
|
|
1325
|
+
type,
|
|
1326
|
+
url,
|
|
1327
|
+
limit = 100,
|
|
1328
|
+
fileIcon = /* @__PURE__ */ jsx(SvgFile, {})
|
|
1329
|
+
}) => {
|
|
1330
|
+
const { theme } = useContext(ChatContext);
|
|
1331
|
+
const isImage = type == null ? void 0 : type.startsWith("image/");
|
|
1332
|
+
return /* @__PURE__ */ jsxs(
|
|
1333
|
+
"figure",
|
|
1334
|
+
{
|
|
1335
|
+
className: cn(theme.messages.message.files.file.base),
|
|
1336
|
+
onClick: () => {
|
|
1337
|
+
window.open(url, "_blank");
|
|
1338
|
+
},
|
|
1339
|
+
children: [
|
|
1340
|
+
isImage ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("img", { src: url, className: "h-10 w-10" }) }) : /* @__PURE__ */ jsx(Fragment, { children: fileIcon }),
|
|
1341
|
+
name && /* @__PURE__ */ jsx("figcaption", { children: name && /* @__PURE__ */ jsx("span", { className: cn(theme.messages.message.files.file.name), children: /* @__PURE__ */ jsx(Ellipsis, { value: name, limit }) }) })
|
|
1342
|
+
]
|
|
1343
|
+
}
|
|
1344
|
+
);
|
|
1345
|
+
};
|
|
1346
|
+
const MessageFiles = ({ files, children }) => {
|
|
1347
|
+
const { theme } = useContext(ChatContext);
|
|
1348
|
+
const Comp = children ? Slot : MessageFile;
|
|
1349
|
+
if (!files || files.length === 0) {
|
|
1350
|
+
return null;
|
|
1351
|
+
}
|
|
1352
|
+
return files.length > 0 && /* @__PURE__ */ jsx("div", { className: cn(theme.messages.message.files.base), children: files.map((file, index) => /* @__PURE__ */ jsx(Comp, { ...file, children }, index)) });
|
|
1353
|
+
};
|
|
1303
1354
|
const MessageQuestion = ({
|
|
1304
1355
|
question,
|
|
1356
|
+
files,
|
|
1305
1357
|
children
|
|
1306
1358
|
}) => {
|
|
1307
1359
|
const { theme, remarkPlugins } = useContext(ChatContext);
|
|
@@ -1311,6 +1363,7 @@ const MessageQuestion = ({
|
|
|
1311
1363
|
return /* @__PURE__ */ jsxs(Comp, { className: cn(theme.messages.message.question, {
|
|
1312
1364
|
[theme.messages.message.overlay]: isLong && !expanded
|
|
1313
1365
|
}), children: [
|
|
1366
|
+
/* @__PURE__ */ jsx(MessageFiles, { files }),
|
|
1314
1367
|
children || /* @__PURE__ */ jsx(Markdown, { remarkPlugins, children: question }),
|
|
1315
1368
|
isLong && !expanded && /* @__PURE__ */ jsx(
|
|
1316
1369
|
Button,
|
|
@@ -1358,38 +1411,6 @@ const MessageResponse = ({
|
|
|
1358
1411
|
}
|
|
1359
1412
|
);
|
|
1360
1413
|
};
|
|
1361
|
-
const SvgFile = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, viewBox: "0 0 16 16", fill: "currentColor", ...props }, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.7036 1.37034C3.04741 1.02653 3.51373 0.833374 3.99996 0.833374H9.33329H9.33331C9.47275 0.833374 9.59885 0.890449 9.68954 0.98251L13.6843 4.97722C13.7763 5.0679 13.8333 5.19398 13.8333 5.33337L13.8333 5.3379V13.3334C13.8333 13.8196 13.6401 14.2859 13.2963 14.6297C12.9525 14.9736 12.4862 15.1667 12 15.1667H3.99996C3.51373 15.1667 3.04741 14.9736 2.7036 14.6297C2.35978 14.2859 2.16663 13.8196 2.16663 13.3334V2.66671C2.16663 2.18048 2.35978 1.71416 2.7036 1.37034ZM3.99996 1.83337H8.83331V5.33337C8.83331 5.60952 9.05717 5.83337 9.33331 5.83337H12.8333V13.3334C12.8333 13.5544 12.7455 13.7663 12.5892 13.9226C12.4329 14.0789 12.221 14.1667 12 14.1667H3.99996C3.77895 14.1667 3.56698 14.0789 3.4107 13.9226C3.25442 13.7663 3.16663 13.5544 3.16663 13.3334V2.66671C3.16663 2.44569 3.25442 2.23373 3.4107 2.07745C3.56698 1.92117 3.77895 1.83337 3.99996 1.83337ZM9.83331 2.5405L12.1262 4.83337H9.83331V2.5405ZM5.33331 8.16663C5.05717 8.16663 4.83331 8.39048 4.83331 8.66663C4.83331 8.94277 5.05717 9.16663 5.33331 9.16663H10.6666C10.9428 9.16663 11.1666 8.94277 11.1666 8.66663C11.1666 8.39048 10.9428 8.16663 10.6666 8.16663H5.33331ZM4.83331 11.3334C4.83331 11.0572 5.05717 10.8334 5.33331 10.8334H10.6666C10.9428 10.8334 11.1666 11.0572 11.1666 11.3334C11.1666 11.6095 10.9428 11.8334 10.6666 11.8334H5.33331C5.05717 11.8334 4.83331 11.6095 4.83331 11.3334ZM5.33331 5.5C5.05717 5.5 4.83331 5.72386 4.83331 6C4.83331 6.27614 5.05717 6.5 5.33331 6.5H6.66665C6.94279 6.5 7.16665 6.27614 7.16665 6C7.16665 5.72386 6.94279 5.5 6.66665 5.5H5.33331Z" }));
|
|
1362
|
-
const MessageFile = ({
|
|
1363
|
-
name,
|
|
1364
|
-
type,
|
|
1365
|
-
url,
|
|
1366
|
-
limit = 100,
|
|
1367
|
-
fileIcon = /* @__PURE__ */ jsx(SvgFile, {})
|
|
1368
|
-
}) => {
|
|
1369
|
-
const { theme } = useContext(ChatContext);
|
|
1370
|
-
const isImage = type == null ? void 0 : type.startsWith("image/");
|
|
1371
|
-
return /* @__PURE__ */ jsxs(
|
|
1372
|
-
"figure",
|
|
1373
|
-
{
|
|
1374
|
-
className: cn(theme.messages.message.files.file.base),
|
|
1375
|
-
onClick: () => {
|
|
1376
|
-
window.open(url, "_blank");
|
|
1377
|
-
},
|
|
1378
|
-
children: [
|
|
1379
|
-
isImage ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("img", { src: url, className: "h-10 w-10" }) }) : /* @__PURE__ */ jsx(Fragment, { children: fileIcon }),
|
|
1380
|
-
name && /* @__PURE__ */ jsx("figcaption", { children: name && /* @__PURE__ */ jsx("span", { className: cn(theme.messages.message.files.file.name), children: /* @__PURE__ */ jsx(Ellipsis, { value: name, limit }) }) })
|
|
1381
|
-
]
|
|
1382
|
-
}
|
|
1383
|
-
);
|
|
1384
|
-
};
|
|
1385
|
-
const MessageFiles = ({ files, children }) => {
|
|
1386
|
-
const { theme } = useContext(ChatContext);
|
|
1387
|
-
const Comp = children ? Slot : MessageFile;
|
|
1388
|
-
if (!files || files.length === 0) {
|
|
1389
|
-
return null;
|
|
1390
|
-
}
|
|
1391
|
-
return files.length > 0 && /* @__PURE__ */ jsx("div", { className: cn(theme.messages.message.files.base), children: files.map((file, index) => /* @__PURE__ */ jsx(Comp, { ...file, children }, index)) });
|
|
1392
|
-
};
|
|
1393
1414
|
const MessageSource = ({ title, url, image, limit = 50 }) => {
|
|
1394
1415
|
const { theme, isCompact } = useContext(ChatContext);
|
|
1395
1416
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1521,8 +1542,7 @@ const SessionMessage = ({
|
|
|
1521
1542
|
const { theme, isLoading } = useContext(ChatContext);
|
|
1522
1543
|
return /* @__PURE__ */ jsxs(motion.div, { variants: messageVariants, children: [
|
|
1523
1544
|
/* @__PURE__ */ jsx(Card, { className: cn(theme.messages.message.base), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1524
|
-
/* @__PURE__ */ jsx(
|
|
1525
|
-
/* @__PURE__ */ jsx(MessageQuestion, { question: conversation.question }),
|
|
1545
|
+
/* @__PURE__ */ jsx(MessageQuestion, { question: conversation.question, files: conversation.files }),
|
|
1526
1546
|
/* @__PURE__ */ jsx(
|
|
1527
1547
|
MessageResponse,
|
|
1528
1548
|
{
|
|
@@ -2025,6 +2045,7 @@ export {
|
|
|
2025
2045
|
ChatContext,
|
|
2026
2046
|
ChatInput,
|
|
2027
2047
|
CodeHighlighter,
|
|
2048
|
+
FileInput,
|
|
2028
2049
|
Markdown,
|
|
2029
2050
|
MessageActions,
|
|
2030
2051
|
MessageFile,
|