@usecrow/ui 0.1.74 → 0.1.75
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 +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1275,6 +1275,20 @@ function useCrowAPI({ onIdentified, onReset } = {}) {
|
|
|
1275
1275
|
case "close":
|
|
1276
1276
|
window.dispatchEvent(new CustomEvent("crow:close"));
|
|
1277
1277
|
break;
|
|
1278
|
+
case "sendMessage": {
|
|
1279
|
+
const msgText = typeof options === "string" ? options : opts?.text ?? opts?.message;
|
|
1280
|
+
if (!msgText) {
|
|
1281
|
+
console.error("[Crow] sendMessage() requires a text string or { text }");
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
window.dispatchEvent(new CustomEvent("crow:open"));
|
|
1285
|
+
setTimeout(() => {
|
|
1286
|
+
window.dispatchEvent(
|
|
1287
|
+
new CustomEvent("crow:sendMessage", { detail: { text: msgText } })
|
|
1288
|
+
);
|
|
1289
|
+
}, 50);
|
|
1290
|
+
break;
|
|
1291
|
+
}
|
|
1278
1292
|
case "setToolStatus":
|
|
1279
1293
|
if (typeof options !== "string") {
|
|
1280
1294
|
console.error("[Crow] setToolStatus() requires a string");
|
|
@@ -5042,6 +5056,10 @@ function CrowWidget({
|
|
|
5042
5056
|
React3.useEffect(() => {
|
|
5043
5057
|
const handleOpen = () => setIsCollapsed(false);
|
|
5044
5058
|
const handleClose = () => setIsCollapsed(true);
|
|
5059
|
+
const handleSendMessage = (e) => {
|
|
5060
|
+
const text = e.detail?.text;
|
|
5061
|
+
if (text) handleSend(text);
|
|
5062
|
+
};
|
|
5045
5063
|
const handleSetSuggestions = (e) => {
|
|
5046
5064
|
const actions = e.detail;
|
|
5047
5065
|
if (Array.isArray(actions)) {
|
|
@@ -5051,6 +5069,7 @@ function CrowWidget({
|
|
|
5051
5069
|
};
|
|
5052
5070
|
window.addEventListener("crow:open", handleOpen);
|
|
5053
5071
|
window.addEventListener("crow:close", handleClose);
|
|
5072
|
+
window.addEventListener("crow:sendMessage", handleSendMessage);
|
|
5054
5073
|
window.addEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5055
5074
|
const pending = window.__crow_suggested_actions;
|
|
5056
5075
|
if (Array.isArray(pending) && pending.length > 0) {
|
|
@@ -5060,6 +5079,7 @@ function CrowWidget({
|
|
|
5060
5079
|
return () => {
|
|
5061
5080
|
window.removeEventListener("crow:open", handleOpen);
|
|
5062
5081
|
window.removeEventListener("crow:close", handleClose);
|
|
5082
|
+
window.removeEventListener("crow:sendMessage", handleSendMessage);
|
|
5063
5083
|
window.removeEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5064
5084
|
};
|
|
5065
5085
|
}, []);
|
|
@@ -5671,6 +5691,10 @@ function CrowCopilot({
|
|
|
5671
5691
|
React3.useEffect(() => {
|
|
5672
5692
|
const handleOpen = () => setIsCollapsed(false);
|
|
5673
5693
|
const handleClose = () => setIsCollapsed(true);
|
|
5694
|
+
const handleSendMessage = (e) => {
|
|
5695
|
+
const text = e.detail?.text;
|
|
5696
|
+
if (text) handleSend(text);
|
|
5697
|
+
};
|
|
5674
5698
|
const handleSetSuggestions = (e) => {
|
|
5675
5699
|
const actions = e.detail;
|
|
5676
5700
|
if (Array.isArray(actions)) {
|
|
@@ -5680,6 +5704,7 @@ function CrowCopilot({
|
|
|
5680
5704
|
};
|
|
5681
5705
|
window.addEventListener("crow:open", handleOpen);
|
|
5682
5706
|
window.addEventListener("crow:close", handleClose);
|
|
5707
|
+
window.addEventListener("crow:sendMessage", handleSendMessage);
|
|
5683
5708
|
window.addEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5684
5709
|
const pending = window.__crow_suggested_actions;
|
|
5685
5710
|
if (Array.isArray(pending) && pending.length > 0) {
|
|
@@ -5689,6 +5714,7 @@ function CrowCopilot({
|
|
|
5689
5714
|
return () => {
|
|
5690
5715
|
window.removeEventListener("crow:open", handleOpen);
|
|
5691
5716
|
window.removeEventListener("crow:close", handleClose);
|
|
5717
|
+
window.removeEventListener("crow:sendMessage", handleSendMessage);
|
|
5692
5718
|
window.removeEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5693
5719
|
};
|
|
5694
5720
|
}, []);
|