@min98/chat-sdk 0.1.0 → 0.1.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/index.js +33 -30
- package/dist/index.mjs +34 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -913,29 +913,32 @@ var ChatWindow = ({
|
|
|
913
913
|
isLoadingMore && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Loader2, { className: "h-4 w-4 animate-spin text-teal-500" }) }),
|
|
914
914
|
messages.map((msg) => {
|
|
915
915
|
const isMe = isAdminMode ? msg.senderId !== msg.userId : msg.senderId === msg.userId;
|
|
916
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex
|
|
917
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
{
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex gap-2.5 ${isMe ? "justify-end" : "justify-start"} items-end`, children: [
|
|
917
|
+
!isMe && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-7 w-7 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center font-bold text-[10px] text-slate-700 dark:text-slate-300 shrink-0 mb-4.5 border border-slate-200/50 dark:border-slate-850", children: isAdminMode ? adminChat.selectedRoom?.user?.image ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: adminChat.selectedRoom.user.image, alt: adminChat.selectedRoom.user.name, className: "h-full w-full object-cover rounded-full" }) : adminChat.selectedRoom?.user?.name.slice(0, 2).toUpperCase() || "KH" : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.MessageSquare, { className: "h-3.5 w-3.5 text-teal-500" }) }),
|
|
918
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col ${isMe ? "items-end" : "items-start"} max-w-[70%]`, children: [
|
|
919
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
920
|
+
"div",
|
|
921
|
+
{
|
|
922
|
+
className: `rounded-2xl px-4 py-2.5 text-xs shadow-sm ${isMe ? "bg-teal-500 text-white rounded-br-none" : "bg-slate-100 dark:bg-slate-850 text-slate-800 dark:text-slate-200 rounded-bl-none"}`,
|
|
923
|
+
children: [
|
|
924
|
+
msg.attachments && msg.attachments.map((att, idx) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mb-2 max-w-full", children: att.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
925
|
+
"img",
|
|
926
|
+
{
|
|
927
|
+
src: att.url,
|
|
928
|
+
alt: att.name,
|
|
929
|
+
className: "max-h-48 rounded-lg cursor-zoom-in object-contain max-w-full",
|
|
930
|
+
onClick: () => window.open(att.url, "_blank")
|
|
931
|
+
}
|
|
932
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2 rounded-lg bg-black/10 px-3 py-2", children: [
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.File, { className: "h-4 w-4 text-sky-500" }),
|
|
934
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: att.url, target: "_blank", rel: "noopener noreferrer", className: "underline line-clamp-1", children: att.name })
|
|
935
|
+
] }) }, idx)),
|
|
936
|
+
msg.content && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "whitespace-pre-wrap break-words", children: msg.content })
|
|
937
|
+
]
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[9px] text-slate-400 mt-1 px-1", children: new Date(msg.createdAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
941
|
+
] })
|
|
939
942
|
] }, msg._id);
|
|
940
943
|
}),
|
|
941
944
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: messagesEndRef })
|
|
@@ -944,7 +947,7 @@ var ChatWindow = ({
|
|
|
944
947
|
),
|
|
945
948
|
attachment && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "relative mx-6 mb-3 p-3 bg-slate-50 dark:bg-slate-950/40 border border-slate-100 dark:border-slate-800 rounded-xl flex items-center justify-between", children: [
|
|
946
949
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
947
|
-
attachment.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: attachment.url, alt: "Preview", className: "h-12 w-12 object-cover rounded-lg border" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-12 w-12 flex items-center justify-center rounded-lg bg-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.
|
|
950
|
+
attachment.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: attachment.url, alt: "Preview", className: "h-12 w-12 object-cover rounded-lg border" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-12 w-12 flex items-center justify-center rounded-lg bg-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.File, { className: "h-6 w-6 text-sky-500" }) }),
|
|
948
951
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-xs font-semibold text-slate-800 dark:text-slate-200 line-clamp-1 max-w-[200px]", children: attachment.name })
|
|
949
952
|
] }),
|
|
950
953
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => setAttachment(null), className: "p-1 hover:text-red-500", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.X, { className: "h-4 w-4" }) })
|
|
@@ -1014,16 +1017,16 @@ var ChatWindow = ({
|
|
|
1014
1017
|
}
|
|
1015
1018
|
)
|
|
1016
1019
|
] }) }),
|
|
1017
|
-
showConfirmModal && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "w-full max-w-[
|
|
1018
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h4", { className: "text-xs font-bold text-slate-800 dark:text-slate-200", children: "
|
|
1019
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-[10px] text-slate-500 mt-
|
|
1020
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex justify-end gap-2 mt-
|
|
1020
|
+
showConfirmModal && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "w-full max-w-[250px] p-4 bg-white dark:bg-slate-900 border dark:border-slate-800 rounded-xl shadow-xl", children: [
|
|
1021
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h4", { className: "text-xs font-bold text-slate-800 dark:text-slate-200", children: "\u0110\xF3ng phi\xEAn h\u1ED7 tr\u1EE3?" }),
|
|
1022
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-[10px] text-slate-500 mt-1.5 leading-relaxed", children: "B\u1EA1n c\xF3 ch\u1EAFc ch\u1EAFn mu\u1ED1n k\u1EBFt th\xFAc cu\u1ED9c tr\xF2 chuy\u1EC7n n\xE0y?" }),
|
|
1023
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex justify-end gap-2 mt-3.5", children: [
|
|
1021
1024
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1022
1025
|
"button",
|
|
1023
1026
|
{
|
|
1024
1027
|
type: "button",
|
|
1025
1028
|
onClick: () => setShowConfirmModal(false),
|
|
1026
|
-
className: "px-
|
|
1029
|
+
className: "px-2.5 py-1.5 text-[10px] font-semibold rounded-lg border text-slate-705 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800",
|
|
1027
1030
|
children: "H\u1EE7y"
|
|
1028
1031
|
}
|
|
1029
1032
|
),
|
|
@@ -1035,7 +1038,7 @@ var ChatWindow = ({
|
|
|
1035
1038
|
setShowConfirmModal(false);
|
|
1036
1039
|
void chat.closeSession();
|
|
1037
1040
|
},
|
|
1038
|
-
className: "px-
|
|
1041
|
+
className: "px-2.5 py-1.5 text-[10px] font-semibold rounded-lg bg-red-500 text-white hover:bg-red-600",
|
|
1039
1042
|
children: "X\xE1c nh\u1EADn"
|
|
1040
1043
|
}
|
|
1041
1044
|
)
|
package/dist/index.mjs
CHANGED
|
@@ -623,7 +623,7 @@ import {
|
|
|
623
623
|
Send,
|
|
624
624
|
Paperclip,
|
|
625
625
|
Loader2,
|
|
626
|
-
|
|
626
|
+
File,
|
|
627
627
|
MessageSquare,
|
|
628
628
|
Sparkles,
|
|
629
629
|
Clock,
|
|
@@ -887,29 +887,32 @@ var ChatWindow = ({
|
|
|
887
887
|
isLoadingMore && /* @__PURE__ */ jsx2("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ jsx2(Loader2, { className: "h-4 w-4 animate-spin text-teal-500" }) }),
|
|
888
888
|
messages.map((msg) => {
|
|
889
889
|
const isMe = isAdminMode ? msg.senderId !== msg.userId : msg.senderId === msg.userId;
|
|
890
|
-
return /* @__PURE__ */ jsxs("div", { className: `flex
|
|
891
|
-
/* @__PURE__ */
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
{
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
890
|
+
return /* @__PURE__ */ jsxs("div", { className: `flex gap-2.5 ${isMe ? "justify-end" : "justify-start"} items-end`, children: [
|
|
891
|
+
!isMe && /* @__PURE__ */ jsx2("div", { className: "h-7 w-7 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center font-bold text-[10px] text-slate-700 dark:text-slate-300 shrink-0 mb-4.5 border border-slate-200/50 dark:border-slate-850", children: isAdminMode ? adminChat.selectedRoom?.user?.image ? /* @__PURE__ */ jsx2("img", { src: adminChat.selectedRoom.user.image, alt: adminChat.selectedRoom.user.name, className: "h-full w-full object-cover rounded-full" }) : adminChat.selectedRoom?.user?.name.slice(0, 2).toUpperCase() || "KH" : /* @__PURE__ */ jsx2(MessageSquare, { className: "h-3.5 w-3.5 text-teal-500" }) }),
|
|
892
|
+
/* @__PURE__ */ jsxs("div", { className: `flex flex-col ${isMe ? "items-end" : "items-start"} max-w-[70%]`, children: [
|
|
893
|
+
/* @__PURE__ */ jsxs(
|
|
894
|
+
"div",
|
|
895
|
+
{
|
|
896
|
+
className: `rounded-2xl px-4 py-2.5 text-xs shadow-sm ${isMe ? "bg-teal-500 text-white rounded-br-none" : "bg-slate-100 dark:bg-slate-850 text-slate-800 dark:text-slate-200 rounded-bl-none"}`,
|
|
897
|
+
children: [
|
|
898
|
+
msg.attachments && msg.attachments.map((att, idx) => /* @__PURE__ */ jsx2("div", { className: "mb-2 max-w-full", children: att.type === "image" ? /* @__PURE__ */ jsx2(
|
|
899
|
+
"img",
|
|
900
|
+
{
|
|
901
|
+
src: att.url,
|
|
902
|
+
alt: att.name,
|
|
903
|
+
className: "max-h-48 rounded-lg cursor-zoom-in object-contain max-w-full",
|
|
904
|
+
onClick: () => window.open(att.url, "_blank")
|
|
905
|
+
}
|
|
906
|
+
) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-lg bg-black/10 px-3 py-2", children: [
|
|
907
|
+
/* @__PURE__ */ jsx2(File, { className: "h-4 w-4 text-sky-500" }),
|
|
908
|
+
/* @__PURE__ */ jsx2("a", { href: att.url, target: "_blank", rel: "noopener noreferrer", className: "underline line-clamp-1", children: att.name })
|
|
909
|
+
] }) }, idx)),
|
|
910
|
+
msg.content && /* @__PURE__ */ jsx2("p", { className: "whitespace-pre-wrap break-words", children: msg.content })
|
|
911
|
+
]
|
|
912
|
+
}
|
|
913
|
+
),
|
|
914
|
+
/* @__PURE__ */ jsx2("span", { className: "text-[9px] text-slate-400 mt-1 px-1", children: new Date(msg.createdAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
915
|
+
] })
|
|
913
916
|
] }, msg._id);
|
|
914
917
|
}),
|
|
915
918
|
/* @__PURE__ */ jsx2("div", { ref: messagesEndRef })
|
|
@@ -918,7 +921,7 @@ var ChatWindow = ({
|
|
|
918
921
|
),
|
|
919
922
|
attachment && /* @__PURE__ */ jsxs("div", { className: "relative mx-6 mb-3 p-3 bg-slate-50 dark:bg-slate-950/40 border border-slate-100 dark:border-slate-800 rounded-xl flex items-center justify-between", children: [
|
|
920
923
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
921
|
-
attachment.type === "image" ? /* @__PURE__ */ jsx2("img", { src: attachment.url, alt: "Preview", className: "h-12 w-12 object-cover rounded-lg border" }) : /* @__PURE__ */ jsx2("div", { className: "h-12 w-12 flex items-center justify-center rounded-lg bg-slate-100", children: /* @__PURE__ */ jsx2(
|
|
924
|
+
attachment.type === "image" ? /* @__PURE__ */ jsx2("img", { src: attachment.url, alt: "Preview", className: "h-12 w-12 object-cover rounded-lg border" }) : /* @__PURE__ */ jsx2("div", { className: "h-12 w-12 flex items-center justify-center rounded-lg bg-slate-100", children: /* @__PURE__ */ jsx2(File, { className: "h-6 w-6 text-sky-500" }) }),
|
|
922
925
|
/* @__PURE__ */ jsx2("span", { className: "text-xs font-semibold text-slate-800 dark:text-slate-200 line-clamp-1 max-w-[200px]", children: attachment.name })
|
|
923
926
|
] }),
|
|
924
927
|
/* @__PURE__ */ jsx2("button", { type: "button", onClick: () => setAttachment(null), className: "p-1 hover:text-red-500", children: /* @__PURE__ */ jsx2(X, { className: "h-4 w-4" }) })
|
|
@@ -988,16 +991,16 @@ var ChatWindow = ({
|
|
|
988
991
|
}
|
|
989
992
|
)
|
|
990
993
|
] }) }),
|
|
991
|
-
showConfirmModal && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[
|
|
992
|
-
/* @__PURE__ */ jsx2("h4", { className: "text-xs font-bold text-slate-800 dark:text-slate-200", children: "
|
|
993
|
-
/* @__PURE__ */ jsx2("p", { className: "text-[10px] text-slate-500 mt-
|
|
994
|
-
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 mt-
|
|
994
|
+
showConfirmModal && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[250px] p-4 bg-white dark:bg-slate-900 border dark:border-slate-800 rounded-xl shadow-xl", children: [
|
|
995
|
+
/* @__PURE__ */ jsx2("h4", { className: "text-xs font-bold text-slate-800 dark:text-slate-200", children: "\u0110\xF3ng phi\xEAn h\u1ED7 tr\u1EE3?" }),
|
|
996
|
+
/* @__PURE__ */ jsx2("p", { className: "text-[10px] text-slate-500 mt-1.5 leading-relaxed", children: "B\u1EA1n c\xF3 ch\u1EAFc ch\u1EAFn mu\u1ED1n k\u1EBFt th\xFAc cu\u1ED9c tr\xF2 chuy\u1EC7n n\xE0y?" }),
|
|
997
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 mt-3.5", children: [
|
|
995
998
|
/* @__PURE__ */ jsx2(
|
|
996
999
|
"button",
|
|
997
1000
|
{
|
|
998
1001
|
type: "button",
|
|
999
1002
|
onClick: () => setShowConfirmModal(false),
|
|
1000
|
-
className: "px-
|
|
1003
|
+
className: "px-2.5 py-1.5 text-[10px] font-semibold rounded-lg border text-slate-705 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800",
|
|
1001
1004
|
children: "H\u1EE7y"
|
|
1002
1005
|
}
|
|
1003
1006
|
),
|
|
@@ -1009,7 +1012,7 @@ var ChatWindow = ({
|
|
|
1009
1012
|
setShowConfirmModal(false);
|
|
1010
1013
|
void chat.closeSession();
|
|
1011
1014
|
},
|
|
1012
|
-
className: "px-
|
|
1015
|
+
className: "px-2.5 py-1.5 text-[10px] font-semibold rounded-lg bg-red-500 text-white hover:bg-red-600",
|
|
1013
1016
|
children: "X\xE1c nh\u1EADn"
|
|
1014
1017
|
}
|
|
1015
1018
|
)
|