@customerhero/react 1.0.0 → 1.0.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.cjs +15 -6
- package/dist/index.js +15 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1091,10 +1091,12 @@ function AnimatedMessage({
|
|
|
1091
1091
|
}) {
|
|
1092
1092
|
const [visible, setVisible] = (0, import_react7.useState)(!animate);
|
|
1093
1093
|
(0, import_react7.useEffect)(() => {
|
|
1094
|
-
if (animate
|
|
1095
|
-
|
|
1096
|
-
return
|
|
1094
|
+
if (!animate || reduced) {
|
|
1095
|
+
setVisible(true);
|
|
1096
|
+
return;
|
|
1097
1097
|
}
|
|
1098
|
+
const id = requestAnimationFrame(() => setVisible(true));
|
|
1099
|
+
return () => cancelAnimationFrame(id);
|
|
1098
1100
|
}, [animate, reduced]);
|
|
1099
1101
|
const style = {
|
|
1100
1102
|
alignSelf: isUser ? "flex-end" : "flex-start",
|
|
@@ -1470,7 +1472,9 @@ function ChatInput() {
|
|
|
1470
1472
|
}, []);
|
|
1471
1473
|
const updateAttachment = (id, patch) => {
|
|
1472
1474
|
setAttachments(
|
|
1473
|
-
(current) => current.map(
|
|
1475
|
+
(current) => current.map(
|
|
1476
|
+
(a) => a.id === id ? { ...a, ...patch } : a
|
|
1477
|
+
)
|
|
1474
1478
|
);
|
|
1475
1479
|
};
|
|
1476
1480
|
const startUpload = async (blob) => {
|
|
@@ -1506,10 +1510,15 @@ function ChatInput() {
|
|
|
1506
1510
|
return current.filter((a) => a.id !== id);
|
|
1507
1511
|
});
|
|
1508
1512
|
};
|
|
1509
|
-
const readyTokens = attachments.filter(
|
|
1513
|
+
const readyTokens = attachments.filter(
|
|
1514
|
+
(a) => a.status === "ready"
|
|
1515
|
+
).map((a) => a.token);
|
|
1510
1516
|
const handleSend = () => {
|
|
1511
1517
|
if (!value.trim() || isLoading) return;
|
|
1512
|
-
sendMessage(
|
|
1518
|
+
sendMessage(
|
|
1519
|
+
value,
|
|
1520
|
+
readyTokens.length > 0 ? { attachmentTokens: readyTokens } : void 0
|
|
1521
|
+
);
|
|
1513
1522
|
for (const a of attachments) URL.revokeObjectURL(a.previewUrl);
|
|
1514
1523
|
setAttachments([]);
|
|
1515
1524
|
setValue("");
|
package/dist/index.js
CHANGED
|
@@ -1070,10 +1070,12 @@ function AnimatedMessage({
|
|
|
1070
1070
|
}) {
|
|
1071
1071
|
const [visible, setVisible] = useState5(!animate);
|
|
1072
1072
|
useEffect5(() => {
|
|
1073
|
-
if (animate
|
|
1074
|
-
|
|
1075
|
-
return
|
|
1073
|
+
if (!animate || reduced) {
|
|
1074
|
+
setVisible(true);
|
|
1075
|
+
return;
|
|
1076
1076
|
}
|
|
1077
|
+
const id = requestAnimationFrame(() => setVisible(true));
|
|
1078
|
+
return () => cancelAnimationFrame(id);
|
|
1077
1079
|
}, [animate, reduced]);
|
|
1078
1080
|
const style = {
|
|
1079
1081
|
alignSelf: isUser ? "flex-end" : "flex-start",
|
|
@@ -1456,7 +1458,9 @@ function ChatInput() {
|
|
|
1456
1458
|
}, []);
|
|
1457
1459
|
const updateAttachment = (id, patch) => {
|
|
1458
1460
|
setAttachments(
|
|
1459
|
-
(current) => current.map(
|
|
1461
|
+
(current) => current.map(
|
|
1462
|
+
(a) => a.id === id ? { ...a, ...patch } : a
|
|
1463
|
+
)
|
|
1460
1464
|
);
|
|
1461
1465
|
};
|
|
1462
1466
|
const startUpload = async (blob) => {
|
|
@@ -1492,10 +1496,15 @@ function ChatInput() {
|
|
|
1492
1496
|
return current.filter((a) => a.id !== id);
|
|
1493
1497
|
});
|
|
1494
1498
|
};
|
|
1495
|
-
const readyTokens = attachments.filter(
|
|
1499
|
+
const readyTokens = attachments.filter(
|
|
1500
|
+
(a) => a.status === "ready"
|
|
1501
|
+
).map((a) => a.token);
|
|
1496
1502
|
const handleSend = () => {
|
|
1497
1503
|
if (!value.trim() || isLoading) return;
|
|
1498
|
-
sendMessage(
|
|
1504
|
+
sendMessage(
|
|
1505
|
+
value,
|
|
1506
|
+
readyTokens.length > 0 ? { attachmentTokens: readyTokens } : void 0
|
|
1507
|
+
);
|
|
1499
1508
|
for (const a of attachments) URL.revokeObjectURL(a.previewUrl);
|
|
1500
1509
|
setAttachments([]);
|
|
1501
1510
|
setValue("");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@customerhero/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React components for embedding the CustomerHero chat widget.",
|
|
6
6
|
"keywords": [
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"test": "vitest run"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@customerhero/js": "^1.0.
|
|
57
|
+
"@customerhero/js": "^1.0.1",
|
|
58
58
|
"react": ">=18"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@customerhero/js": "^1.0.
|
|
61
|
+
"@customerhero/js": "^1.0.1",
|
|
62
62
|
"@testing-library/react": "^16.1.0",
|
|
63
63
|
"@types/react": "^19.0.0",
|
|
64
64
|
"@types/react-dom": "^19.0.0",
|