@usecrow/ui 0.1.64 → 0.1.66

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 CHANGED
@@ -1263,6 +1263,16 @@ function useCrowAPI({ onIdentified, onReset } = {}) {
1263
1263
  }
1264
1264
  return client.crowAsk(opts);
1265
1265
  }
1266
+ case "setContextLabel":
1267
+ if (typeof options !== "string") {
1268
+ console.error("[Crow] setContextLabel() requires a string");
1269
+ return;
1270
+ }
1271
+ window.__crow_context_label = options || void 0;
1272
+ window.dispatchEvent(
1273
+ new CustomEvent("crow:setContextLabel", { detail: options })
1274
+ );
1275
+ break;
1266
1276
  case "setSuggestedActions":
1267
1277
  if (!Array.isArray(options)) {
1268
1278
  console.error("[Crow] setSuggestedActions() requires an array of { label, message }");
@@ -1395,7 +1405,8 @@ var DEFAULT_WIDGET_STYLES = {
1395
1405
  // ═══════════════════════════════════════════════════════════
1396
1406
  bubble: {
1397
1407
  size: 48,
1398
- iconSize: 24
1408
+ iconSize: 24,
1409
+ label: ""
1399
1410
  },
1400
1411
  // ═══════════════════════════════════════════════════════════
1401
1412
  // SHADOWS
@@ -2333,14 +2344,20 @@ function ShadowContainer({
2333
2344
  ShadowContainer.displayName = "ShadowContainer";
2334
2345
  function ChatBubble({ isExpanded, onClick }) {
2335
2346
  const { styles } = useWidgetStyleContext();
2336
- return /* @__PURE__ */ jsxRuntime.jsx(
2347
+ const label = styles.bubble.label;
2348
+ const showLabel = !isExpanded && !!label;
2349
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2337
2350
  "button",
2338
2351
  {
2339
2352
  onClick,
2340
- className: "crow-fixed crow-z-[999999] crow-rounded-full crow-flex crow-items-center crow-justify-center crow-shadow-2xl hover:crow-scale-110 crow-transition-all crow-duration-500 crow-border crow-backdrop-blur-md",
2353
+ className: "crow-fixed crow-z-[999999] crow-flex crow-items-center crow-justify-center crow-shadow-2xl hover:crow-scale-110 crow-transition-all crow-duration-500 crow-border crow-backdrop-blur-md",
2341
2354
  style: {
2342
- width: styles.bubble.size,
2343
2355
  height: styles.bubble.size,
2356
+ width: showLabel ? "auto" : styles.bubble.size,
2357
+ paddingLeft: showLabel ? styles.bubble.size * 0.3 : 0,
2358
+ paddingRight: showLabel ? styles.bubble.size * 0.4 : 0,
2359
+ gap: showLabel ? 6 : 0,
2360
+ borderRadius: 9999,
2344
2361
  right: styles.position.bubbleRight,
2345
2362
  bottom: styles.position.bubbleBottom,
2346
2363
  background: styles.colors.bubbleBackground,
@@ -2349,7 +2366,15 @@ function ChatBubble({ isExpanded, onClick }) {
2349
2366
  color: styles.colors.bubbleIcon
2350
2367
  },
2351
2368
  "aria-label": isExpanded ? "Close Chat" : "Open Chat",
2352
- children: isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: styles.bubble.iconSize, strokeWidth: 2 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageCircle, { size: styles.bubble.iconSize, strokeWidth: 2 })
2369
+ children: [
2370
+ isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: styles.bubble.iconSize, strokeWidth: 2 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageCircle, { size: styles.bubble.iconSize, strokeWidth: 2 }),
2371
+ showLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
2372
+ fontSize: styles.bubble.iconSize * 0.6,
2373
+ fontWeight: 500,
2374
+ whiteSpace: "nowrap",
2375
+ fontFamily: "system-ui, sans-serif"
2376
+ }, children: label })
2377
+ ]
2353
2378
  }
2354
2379
  );
2355
2380
  }
@@ -2449,7 +2474,8 @@ function WidgetHeader({
2449
2474
  onDragPointerDown,
2450
2475
  isDragging,
2451
2476
  hasCustomTransform,
2452
- onResetTransform
2477
+ onResetTransform,
2478
+ contextLabel
2453
2479
  }) {
2454
2480
  const { agentName, styles } = useWidgetStyleContext();
2455
2481
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2537,7 +2563,36 @@ function WidgetHeader({
2537
2563
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 18, className: "crow-text-gray-700" })
2538
2564
  }
2539
2565
  )
2540
- ] })
2566
+ ] }),
2567
+ contextLabel && /* @__PURE__ */ jsxRuntime.jsxs(
2568
+ "div",
2569
+ {
2570
+ className: "crow-flex crow-items-center crow-gap-1.5 crow-mt-1 crow-text-xs",
2571
+ style: { color: "#6b7280" },
2572
+ children: [
2573
+ /* @__PURE__ */ jsxRuntime.jsxs(
2574
+ "svg",
2575
+ {
2576
+ xmlns: "http://www.w3.org/2000/svg",
2577
+ width: "12",
2578
+ height: "12",
2579
+ viewBox: "0 0 24 24",
2580
+ fill: "none",
2581
+ stroke: "currentColor",
2582
+ strokeWidth: "2",
2583
+ strokeLinecap: "round",
2584
+ strokeLinejoin: "round",
2585
+ className: "crow-shrink-0",
2586
+ children: [
2587
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z" }),
2588
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "10", r: "3" })
2589
+ ]
2590
+ }
2591
+ ),
2592
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "crow-truncate", children: contextLabel })
2593
+ ]
2594
+ }
2595
+ )
2541
2596
  ]
2542
2597
  }
2543
2598
  );
@@ -4143,7 +4198,8 @@ function CrowWidget({
4143
4198
  context,
4144
4199
  toolRenderers,
4145
4200
  language,
4146
- customCss
4201
+ customCss,
4202
+ contextLabel: contextLabelProp
4147
4203
  }) {
4148
4204
  const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
4149
4205
  const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
@@ -4184,6 +4240,15 @@ function CrowWidget({
4184
4240
  window.addEventListener("crow:setGreeting", handler);
4185
4241
  return () => window.removeEventListener("crow:setGreeting", handler);
4186
4242
  }, []);
4243
+ const [contextLabelFromAPI, setContextLabelFromAPI] = React3.useState(
4244
+ () => window.__crow_context_label
4245
+ );
4246
+ React3.useEffect(() => {
4247
+ const handler = (e) => setContextLabelFromAPI(e.detail || void 0);
4248
+ window.addEventListener("crow:setContextLabel", handler);
4249
+ return () => window.removeEventListener("crow:setContextLabel", handler);
4250
+ }, []);
4251
+ const contextLabel = contextLabelProp ?? contextLabelFromAPI;
4187
4252
  const agentName = agentNameProp ?? agentNameFromAPI;
4188
4253
  const welcomeMessage = greetingOverride ?? welcomeMessageProp ?? welcomeMessageFromAPI;
4189
4254
  const selectedModel = selectedModelFromAPI;
@@ -4674,7 +4739,8 @@ function CrowWidget({
4674
4739
  onDragPointerDown: variant === "floating" ? transform.onDragPointerDown : void 0,
4675
4740
  isDragging: transform.isDragging,
4676
4741
  hasCustomTransform: transform.hasCustomTransform,
4677
- onResetTransform: transform.resetTransform
4742
+ onResetTransform: transform.resetTransform,
4743
+ contextLabel
4678
4744
  }
4679
4745
  ),
4680
4746
  /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: showConversationList && isVerifiedUser && /* @__PURE__ */ jsxRuntime.jsx(
@@ -5066,7 +5132,8 @@ function CrowCopilot({
5066
5132
  toolRenderers,
5067
5133
  getIdentityToken,
5068
5134
  context,
5069
- language
5135
+ language,
5136
+ contextLabel: contextLabelProp
5070
5137
  }) {
5071
5138
  const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
5072
5139
  const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
@@ -5107,6 +5174,15 @@ function CrowCopilot({
5107
5174
  return () => window.removeEventListener("crow:setGreeting", handler);
5108
5175
  }, []);
5109
5176
  const welcomeMessage = greetingOverride ?? welcomeMessageProp ?? welcomeMessageFromAPI;
5177
+ const [contextLabelFromAPI, setContextLabelFromAPI] = React3.useState(
5178
+ () => window.__crow_context_label
5179
+ );
5180
+ React3.useEffect(() => {
5181
+ const handler = (e) => setContextLabelFromAPI(e.detail || void 0);
5182
+ window.addEventListener("crow:setContextLabel", handler);
5183
+ return () => window.removeEventListener("crow:setContextLabel", handler);
5184
+ }, []);
5185
+ const contextLabel = contextLabelProp ?? contextLabelFromAPI;
5110
5186
  const [autoTools, setAutoTools] = React3.useState({});
5111
5187
  const browserUseLoaded = autoTools.browser_use;
5112
5188
  React3.useEffect(() => {
@@ -5921,6 +5997,38 @@ function CrowCopilot({
5921
5997
  ]
5922
5998
  }
5923
5999
  ),
6000
+ contextLabel && /* @__PURE__ */ jsxRuntime.jsxs(
6001
+ "div",
6002
+ {
6003
+ className: "crow-flex crow-items-center crow-gap-1.5 crow-px-3 crow-py-1.5 crow-border-b crow-text-xs",
6004
+ style: {
6005
+ color: "#6b7280",
6006
+ borderColor: styles.colors.border
6007
+ },
6008
+ children: [
6009
+ /* @__PURE__ */ jsxRuntime.jsxs(
6010
+ "svg",
6011
+ {
6012
+ xmlns: "http://www.w3.org/2000/svg",
6013
+ width: "12",
6014
+ height: "12",
6015
+ viewBox: "0 0 24 24",
6016
+ fill: "none",
6017
+ stroke: "currentColor",
6018
+ strokeWidth: "2",
6019
+ strokeLinecap: "round",
6020
+ strokeLinejoin: "round",
6021
+ className: "crow-shrink-0",
6022
+ children: [
6023
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z" }),
6024
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "10", r: "3" })
6025
+ ]
6026
+ }
6027
+ ),
6028
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "crow-truncate", children: contextLabel })
6029
+ ]
6030
+ }
6031
+ ),
5924
6032
  /* @__PURE__ */ jsxRuntime.jsxs(framerMotion.AnimatePresence, { children: [
5925
6033
  showConversationList && isVerifiedUser && /* @__PURE__ */ jsxRuntime.jsx(
5926
6034
  ConversationList,