@esvndev/es-react-template-chat 0.0.91 → 0.0.92
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 +77 -135
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -135
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72426,141 +72426,83 @@ const ChatLog = (props) => {
|
|
|
72426
72426
|
return (jsxRuntime.jsx("div", { className: "group-image-item image-container", children: jsxRuntime.jsx("img", { style: { maxWidth: "100%", maxHeight: 360 }, src: `${CDN_URL_VIEW}/${it.path.trim()}`, onClick: () => handlePreview(it), alt: "" }) }, index));
|
|
72427
72427
|
}) })), jsxRuntime.jsx("div", { className: "", style: { fontSize: "12px", color: "#476285" }, children: moment(chat.time).format("HH:mm") })] }) }) }));
|
|
72428
72428
|
}, [expandedMessages, handlePreview, mentionItems]);
|
|
72429
|
-
|
|
72430
|
-
|
|
72431
|
-
|
|
72432
|
-
|
|
72433
|
-
|
|
72434
|
-
|
|
72435
|
-
|
|
72436
|
-
|
|
72437
|
-
|
|
72438
|
-
|
|
72439
|
-
|
|
72440
|
-
|
|
72441
|
-
|
|
72442
|
-
|
|
72443
|
-
|
|
72444
|
-
|
|
72445
|
-
|
|
72446
|
-
|
|
72447
|
-
|
|
72448
|
-
|
|
72449
|
-
|
|
72450
|
-
|
|
72451
|
-
|
|
72452
|
-
|
|
72453
|
-
|
|
72454
|
-
|
|
72455
|
-
|
|
72456
|
-
|
|
72457
|
-
|
|
72458
|
-
|
|
72459
|
-
|
|
72460
|
-
|
|
72461
|
-
|
|
72462
|
-
|
|
72463
|
-
|
|
72464
|
-
|
|
72465
|
-
|
|
72466
|
-
|
|
72467
|
-
|
|
72468
|
-
|
|
72469
|
-
|
|
72470
|
-
|
|
72471
|
-
|
|
72472
|
-
|
|
72473
|
-
|
|
72474
|
-
|
|
72475
|
-
|
|
72476
|
-
|
|
72477
|
-
|
|
72478
|
-
|
|
72479
|
-
|
|
72480
|
-
|
|
72481
|
-
|
|
72482
|
-
|
|
72483
|
-
|
|
72484
|
-
|
|
72485
|
-
|
|
72486
|
-
|
|
72487
|
-
|
|
72488
|
-
|
|
72489
|
-
|
|
72490
|
-
|
|
72491
|
-
|
|
72492
|
-
|
|
72493
|
-
|
|
72494
|
-
|
|
72495
|
-
|
|
72496
|
-
|
|
72497
|
-
|
|
72498
|
-
|
|
72499
|
-
|
|
72500
|
-
|
|
72501
|
-
|
|
72502
|
-
|
|
72503
|
-
|
|
72504
|
-
|
|
72505
|
-
|
|
72506
|
-
// <>
|
|
72507
|
-
// <div>
|
|
72508
|
-
// <span style={{ fontWeight: "bold", marginRight: "5px" }}>
|
|
72509
|
-
// {msg?.name}
|
|
72510
|
-
// </span>
|
|
72511
|
-
// <span>được <span style={{ fontWeight: "bold", marginRight: "5px" }}>{chat?.createdBy?.name}</span> xoá khỏi nhóm</span>
|
|
72512
|
-
// </div>
|
|
72513
|
-
// </>
|
|
72514
|
-
// )
|
|
72515
|
-
// }, [dataProfile])
|
|
72516
|
-
// const renderChatNotification = useCallback((chat: any) => {
|
|
72517
|
-
// const parseChatMsg = (msg: string) => {
|
|
72518
|
-
// if (!msg) { return [] }
|
|
72519
|
-
// try {
|
|
72520
|
-
// const parsed = typeof msg === 'string' ? JSON.parse(msg) : msg
|
|
72521
|
-
// return Array.isArray(parsed) ? parsed : [parsed]
|
|
72522
|
-
// } catch (err) {
|
|
72523
|
-
// console.error('JSON parse error:', err)
|
|
72524
|
-
// return []
|
|
72525
|
-
// }
|
|
72526
|
-
// }
|
|
72527
|
-
// const dataParse = parseChatMsg(chat.msg)
|
|
72528
|
-
// // ✅ FIX: Kiểm tra array trước khi dùng slice
|
|
72529
|
-
// if (!Array.isArray(dataParse) || dataParse.length === 0) {
|
|
72530
|
-
// return (
|
|
72531
|
-
// <div>
|
|
72532
|
-
// <span>Đã có thay đổi trong nhóm</span>
|
|
72533
|
-
// </div>
|
|
72534
|
-
// )
|
|
72535
|
-
// }
|
|
72536
|
-
// const displayedItems = dataParse.slice(0, 2)
|
|
72537
|
-
// const extraCount = Math.max(0, dataParse.length - displayedItems.length)
|
|
72538
|
-
// return (
|
|
72539
|
-
// <>
|
|
72540
|
-
// <div>
|
|
72541
|
-
// {displayedItems.map((item: any, index: any) => (
|
|
72542
|
-
// <strong key={index}>
|
|
72543
|
-
// {item.name}
|
|
72544
|
-
// {index < displayedItems.length - 1 && ", "}
|
|
72545
|
-
// </strong>
|
|
72546
|
-
// ))}
|
|
72547
|
-
// {dataParse.length > 3 && (
|
|
72548
|
-
// <strong>
|
|
72549
|
-
// <span style={{ fontWeight: "normal" }}>{" và "}</span>{" "}
|
|
72550
|
-
// {extraCount} người khác
|
|
72551
|
-
// </strong>
|
|
72552
|
-
// )}
|
|
72553
|
-
// {" được "}
|
|
72554
|
-
// {chat?.createdBy?.id === dataProfile?.id ? (
|
|
72555
|
-
// <span>bạn </span>
|
|
72556
|
-
// ) : (
|
|
72557
|
-
// <strong style={{ marginRight: "5px" }}>{chat?.createdByName}</strong>
|
|
72558
|
-
// )}
|
|
72559
|
-
// thêm vào nhóm
|
|
72560
|
-
// </div>
|
|
72561
|
-
// </>
|
|
72562
|
-
// )
|
|
72563
|
-
// }, [dataProfile])
|
|
72429
|
+
const getLinkPreviewData = (urlString) => {
|
|
72430
|
+
try {
|
|
72431
|
+
const hasProtocol = /^https?:\/\//i.test(urlString);
|
|
72432
|
+
const href = hasProtocol ? urlString : `https://${urlString}`;
|
|
72433
|
+
const url = new URL(href);
|
|
72434
|
+
const displayUrl = urlString.length > 80 ? `${urlString.slice(0, 77)}...` : urlString;
|
|
72435
|
+
return {
|
|
72436
|
+
href,
|
|
72437
|
+
displayUrl,
|
|
72438
|
+
host: url.host
|
|
72439
|
+
};
|
|
72440
|
+
}
|
|
72441
|
+
catch (e) {
|
|
72442
|
+
return {
|
|
72443
|
+
href: urlString,
|
|
72444
|
+
displayUrl: urlString,
|
|
72445
|
+
host: ''
|
|
72446
|
+
};
|
|
72447
|
+
}
|
|
72448
|
+
};
|
|
72449
|
+
const renderLinkPreview = (urlString) => {
|
|
72450
|
+
const { href, displayUrl, host } = getLinkPreviewData(urlString);
|
|
72451
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("a", { href: href, target: "_blank", rel: "noreferrer", style: {
|
|
72452
|
+
textDecoration: 'none',
|
|
72453
|
+
color: 'inherit'
|
|
72454
|
+
}, children: jsxRuntime.jsxs("div", { style: {
|
|
72455
|
+
marginTop: 4,
|
|
72456
|
+
marginBottom: 4,
|
|
72457
|
+
padding: '8px 10px',
|
|
72458
|
+
borderRadius: 8,
|
|
72459
|
+
backgroundColor: '#eef5ff',
|
|
72460
|
+
border: '1px solid #d3e2ff',
|
|
72461
|
+
maxWidth: 420
|
|
72462
|
+
}, children: [jsxRuntime.jsx("div", { style: {
|
|
72463
|
+
fontSize: 14,
|
|
72464
|
+
fontWeight: 500,
|
|
72465
|
+
color: '#1d4f91',
|
|
72466
|
+
wordBreak: 'break-word'
|
|
72467
|
+
}, children: displayUrl }), host && (jsxRuntime.jsx("div", { style: {
|
|
72468
|
+
marginTop: 4,
|
|
72469
|
+
fontSize: 12,
|
|
72470
|
+
color: '#6f6b7d'
|
|
72471
|
+
}, children: host }))] }) }) }));
|
|
72472
|
+
};
|
|
72473
|
+
React.useCallback((chat) => {
|
|
72474
|
+
const msg = JSON.parse(chat?.msg);
|
|
72475
|
+
if (chat?.createdById === dataProfile?.id) {
|
|
72476
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: msg?.name }), jsxRuntime.jsx("span", { children: "\u0111\u01B0\u1EE3c b\u1EA1n xo\u00E1 kh\u1ECFi nh\u00F3m" })] }) }));
|
|
72477
|
+
}
|
|
72478
|
+
if (chat?.createdById === msg?.id) {
|
|
72479
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: msg?.name }), jsxRuntime.jsx("span", { children: "\u0111\u00E3 r\u1EDDi kh\u1ECFi nh\u00F3m" })] }) }));
|
|
72480
|
+
}
|
|
72481
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: msg?.name }), jsxRuntime.jsxs("span", { children: ["\u0111\u01B0\u1EE3c ", jsxRuntime.jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: chat?.createdBy?.name }), " xo\u00E1 kh\u1ECFi nh\u00F3m"] })] }) }));
|
|
72482
|
+
}, [dataProfile]);
|
|
72483
|
+
React.useCallback((chat) => {
|
|
72484
|
+
const parseChatMsg = (msg) => {
|
|
72485
|
+
if (!msg) {
|
|
72486
|
+
return [];
|
|
72487
|
+
}
|
|
72488
|
+
try {
|
|
72489
|
+
const parsed = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
72490
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
72491
|
+
}
|
|
72492
|
+
catch (err) {
|
|
72493
|
+
console.error('JSON parse error:', err);
|
|
72494
|
+
return [];
|
|
72495
|
+
}
|
|
72496
|
+
};
|
|
72497
|
+
const dataParse = parseChatMsg(chat.msg);
|
|
72498
|
+
// ✅ FIX: Kiểm tra array trước khi dùng slice
|
|
72499
|
+
if (!Array.isArray(dataParse) || dataParse.length === 0) {
|
|
72500
|
+
return (jsxRuntime.jsx("div", { children: jsxRuntime.jsx("span", { children: "\u0110\u00E3 c\u00F3 thay \u0111\u1ED5i trong nh\u00F3m" }) }));
|
|
72501
|
+
}
|
|
72502
|
+
const displayedItems = dataParse.slice(0, 2);
|
|
72503
|
+
const extraCount = Math.max(0, dataParse.length - displayedItems.length);
|
|
72504
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { children: [displayedItems.map((item, index) => (jsxRuntime.jsxs("strong", { children: [item.name, index < displayedItems.length - 1 && ", "] }, index))), dataParse.length > 3 && (jsxRuntime.jsxs("strong", { children: [jsxRuntime.jsx("span", { style: { fontWeight: "normal" }, children: " và " }), " ", extraCount, " ng\u01B0\u1EDDi kh\u00E1c"] })), " được ", chat?.createdBy?.id === dataProfile?.id ? (jsxRuntime.jsx("span", { children: "b\u1EA1n " })) : (jsxRuntime.jsx("strong", { style: { marginRight: "5px" }, children: chat?.createdByName })), "th\u00EAm v\u00E0o nh\u00F3m"] }) }));
|
|
72505
|
+
}, [dataProfile]);
|
|
72564
72506
|
// const renderChatImage = useCallback((chat: any) => {
|
|
72565
72507
|
// const files = chat.path
|
|
72566
72508
|
// if (!files || !Array.isArray(files) || files.length === 0) {
|