reachat 1.0.1 → 1.0.2

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.
@@ -28,21 +28,18 @@
28
28
  });
29
29
  const ChatInput = ({
30
30
  allowedFiles,
31
- onSendMessage,
32
31
  placeholder,
33
- onStopMessage,
34
- onFileUpload,
35
32
  defaultValue,
36
33
  sendIcon = /* @__PURE__ */ jsxRuntime.jsx(SvgSend, {}),
37
34
  stopIcon = /* @__PURE__ */ jsxRuntime.jsx(SvgStop, {}),
38
35
  attachIcon = /* @__PURE__ */ jsxRuntime.jsx(SvgPaperclip, {})
39
36
  }) => {
40
- const { theme, isLoading, disabled } = React.useContext(ChatContext);
37
+ const { theme, isLoading, disabled, sendMessage, stopMessage, fileUpload } = React.useContext(ChatContext);
41
38
  const [message, setMessage] = React.useState("");
42
39
  const fileInputRef = React.useRef(null);
43
40
  const handleSendMessage = () => {
44
41
  if (message.trim()) {
45
- onSendMessage == null ? void 0 : onSendMessage(message);
42
+ sendMessage == null ? void 0 : sendMessage(message);
46
43
  setMessage("");
47
44
  }
48
45
  };
@@ -55,8 +52,8 @@
55
52
  const handleFileUpload = (event) => {
56
53
  var _a;
57
54
  const file = (_a = event.target.files) == null ? void 0 : _a[0];
58
- if (file && onFileUpload) {
59
- onFileUpload(file);
55
+ if (file && fileUpload) {
56
+ fileUpload(file);
60
57
  }
61
58
  };
62
59
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: reablocks.cn(theme.input.base), children: [
@@ -104,7 +101,7 @@
104
101
  {
105
102
  title: "Stop",
106
103
  className: reablocks.cn(theme.input.stop),
107
- onClick: onStopMessage,
104
+ onClick: stopMessage,
108
105
  disabled,
109
106
  children: stopIcon
110
107
  }
@@ -1323,6 +1320,7 @@
1323
1320
  fileIcon = /* @__PURE__ */ jsxRuntime.jsx(SvgFile, {})
1324
1321
  }) => {
1325
1322
  const { theme } = React.useContext(ChatContext);
1323
+ const isImage = type == null ? void 0 : type.startsWith("image/");
1326
1324
  return /* @__PURE__ */ jsxRuntime.jsxs(
1327
1325
  "figure",
1328
1326
  {
@@ -1331,8 +1329,8 @@
1331
1329
  window.open(url, "_blank");
1332
1330
  },
1333
1331
  children: [
1334
- fileIcon,
1335
- (name || type) && /* @__PURE__ */ jsxRuntime.jsx("figcaption", { children: name && /* @__PURE__ */ jsxRuntime.jsx("span", { className: reablocks.cn(theme.messages.message.files.file.name), children: /* @__PURE__ */ jsxRuntime.jsx(reablocks.Ellipsis, { value: name, limit }) }) })
1332
+ isImage ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, className: "h-10 w-10" }) }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fileIcon }),
1333
+ name && /* @__PURE__ */ jsxRuntime.jsx("figcaption", { children: name && /* @__PURE__ */ jsxRuntime.jsx("span", { className: reablocks.cn(theme.messages.message.files.file.name), children: /* @__PURE__ */ jsxRuntime.jsx(reablocks.Ellipsis, { value: name, limit }) }) })
1336
1334
  ]
1337
1335
  }
1338
1336
  );
@@ -1645,6 +1643,9 @@ ${response}`),
1645
1643
  sessions,
1646
1644
  onSelectSession,
1647
1645
  onDeleteSession,
1646
+ onSendMessage,
1647
+ onStopMessage,
1648
+ onFileUpload,
1648
1649
  isLoading,
1649
1650
  activeSessionId,
1650
1651
  theme: customTheme = chatTheme,
@@ -1706,7 +1707,10 @@ ${response}`),
1706
1707
  activeSessionId: internalActiveSessionID,
1707
1708
  selectSession: handleSelectSession,
1708
1709
  deleteSession: handleDeleteSession,
1709
- createSession: handleCreateNewSession
1710
+ createSession: handleCreateNewSession,
1711
+ sendMessage: onSendMessage,
1712
+ stopMessage: onStopMessage,
1713
+ fileUpload: onFileUpload
1710
1714
  }),
1711
1715
  [
1712
1716
  isLoading,
@@ -1719,7 +1723,10 @@ ${response}`),
1719
1723
  internalActiveSessionID,
1720
1724
  handleSelectSession,
1721
1725
  handleDeleteSession,
1722
- handleCreateNewSession
1726
+ handleCreateNewSession,
1727
+ onSendMessage,
1728
+ onStopMessage,
1729
+ onFileUpload
1723
1730
  ]
1724
1731
  );
1725
1732
  return /* @__PURE__ */ jsxRuntime.jsx(ChatContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: false, children: /* @__PURE__ */ jsxRuntime.jsx(