@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.d.cts CHANGED
@@ -84,6 +84,8 @@ interface WidgetBubbleConfig {
84
84
  size?: number;
85
85
  /** Icon size inside bubble in pixels */
86
86
  iconSize?: number;
87
+ /** Text label shown next to bubble icon (pill shape when set) */
88
+ label?: string;
87
89
  }
88
90
  interface WidgetShadowsConfig {
89
91
  /** Widget container shadow (CSS box-shadow) */
@@ -318,6 +320,7 @@ declare global {
318
320
  __crow_identity_token_fetcher?: () => Promise<string>;
319
321
  __crow_on_tool_result?: (toolName: string, result: Record<string, unknown>) => void;
320
322
  __crow_tool_renderers?: ToolRenderers;
323
+ __crow_context_label?: string;
321
324
  }
322
325
  }
323
326
 
@@ -394,8 +397,13 @@ interface CrowWidgetProps {
394
397
  * Appended after default styles, allowing overrides.
395
398
  */
396
399
  customCss?: string;
400
+ /**
401
+ * Label shown at the top of the widget indicating what page/context the AI
402
+ * is aware of. Prop takes priority over window.crow('setContextLabel', ...).
403
+ */
404
+ contextLabel?: string;
397
405
  }
398
- declare function CrowWidget({ productId, apiUrl, subdomain, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, language, customCss, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
406
+ declare function CrowWidget({ productId, apiUrl, subdomain, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, language, customCss, contextLabel: contextLabelProp, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
399
407
 
400
408
  interface CrowCopilotProps {
401
409
  /** Product ID for this copilot */
@@ -477,8 +485,13 @@ interface CrowCopilotProps {
477
485
  * responds in that language and the welcome message is translated.
478
486
  */
479
487
  language?: string;
488
+ /**
489
+ * Label shown at the top of the copilot indicating what page/context the AI
490
+ * is aware of. Prop takes priority over window.crow('setContextLabel', ...).
491
+ */
492
+ contextLabel?: string;
480
493
  }
481
- declare function CrowCopilot({ productId, apiUrl, subdomain, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, language, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
494
+ declare function CrowCopilot({ productId, apiUrl, subdomain, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, language, contextLabel: contextLabelProp, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
482
495
 
483
496
  interface CrowProviderProps extends CrowClientConfig {
484
497
  children: React.ReactNode;
@@ -1181,8 +1194,10 @@ interface WidgetHeaderProps {
1181
1194
  hasCustomTransform?: boolean;
1182
1195
  /** Reset position & size to defaults */
1183
1196
  onResetTransform?: () => void;
1197
+ /** Context label displayed below the header row */
1198
+ contextLabel?: string;
1184
1199
  }
1185
- declare function WidgetHeader({ isVerifiedUser, showConversationList, onNewChat, onToggleHistory, showMinimize, onToggleMinimize, onDragPointerDown, isDragging, hasCustomTransform, onResetTransform, }: WidgetHeaderProps): react_jsx_runtime.JSX.Element;
1200
+ declare function WidgetHeader({ isVerifiedUser, showConversationList, onNewChat, onToggleHistory, showMinimize, onToggleMinimize, onDragPointerDown, isDragging, hasCustomTransform, onResetTransform, contextLabel, }: WidgetHeaderProps): react_jsx_runtime.JSX.Element;
1186
1201
 
1187
1202
  /**
1188
1203
  * CopilotToggleButton - Edge toggle button for floating copilot
package/dist/index.d.ts CHANGED
@@ -84,6 +84,8 @@ interface WidgetBubbleConfig {
84
84
  size?: number;
85
85
  /** Icon size inside bubble in pixels */
86
86
  iconSize?: number;
87
+ /** Text label shown next to bubble icon (pill shape when set) */
88
+ label?: string;
87
89
  }
88
90
  interface WidgetShadowsConfig {
89
91
  /** Widget container shadow (CSS box-shadow) */
@@ -318,6 +320,7 @@ declare global {
318
320
  __crow_identity_token_fetcher?: () => Promise<string>;
319
321
  __crow_on_tool_result?: (toolName: string, result: Record<string, unknown>) => void;
320
322
  __crow_tool_renderers?: ToolRenderers;
323
+ __crow_context_label?: string;
321
324
  }
322
325
  }
323
326
 
@@ -394,8 +397,13 @@ interface CrowWidgetProps {
394
397
  * Appended after default styles, allowing overrides.
395
398
  */
396
399
  customCss?: string;
400
+ /**
401
+ * Label shown at the top of the widget indicating what page/context the AI
402
+ * is aware of. Prop takes priority over window.crow('setContextLabel', ...).
403
+ */
404
+ contextLabel?: string;
397
405
  }
398
- declare function CrowWidget({ productId, apiUrl, subdomain, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, language, customCss, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
406
+ declare function CrowWidget({ productId, apiUrl, subdomain, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, language, customCss, contextLabel: contextLabelProp, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
399
407
 
400
408
  interface CrowCopilotProps {
401
409
  /** Product ID for this copilot */
@@ -477,8 +485,13 @@ interface CrowCopilotProps {
477
485
  * responds in that language and the welcome message is translated.
478
486
  */
479
487
  language?: string;
488
+ /**
489
+ * Label shown at the top of the copilot indicating what page/context the AI
490
+ * is aware of. Prop takes priority over window.crow('setContextLabel', ...).
491
+ */
492
+ contextLabel?: string;
480
493
  }
481
- declare function CrowCopilot({ productId, apiUrl, subdomain, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, language, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
494
+ declare function CrowCopilot({ productId, apiUrl, subdomain, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, language, contextLabel: contextLabelProp, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
482
495
 
483
496
  interface CrowProviderProps extends CrowClientConfig {
484
497
  children: React.ReactNode;
@@ -1181,8 +1194,10 @@ interface WidgetHeaderProps {
1181
1194
  hasCustomTransform?: boolean;
1182
1195
  /** Reset position & size to defaults */
1183
1196
  onResetTransform?: () => void;
1197
+ /** Context label displayed below the header row */
1198
+ contextLabel?: string;
1184
1199
  }
1185
- declare function WidgetHeader({ isVerifiedUser, showConversationList, onNewChat, onToggleHistory, showMinimize, onToggleMinimize, onDragPointerDown, isDragging, hasCustomTransform, onResetTransform, }: WidgetHeaderProps): react_jsx_runtime.JSX.Element;
1200
+ declare function WidgetHeader({ isVerifiedUser, showConversationList, onNewChat, onToggleHistory, showMinimize, onToggleMinimize, onDragPointerDown, isDragging, hasCustomTransform, onResetTransform, contextLabel, }: WidgetHeaderProps): react_jsx_runtime.JSX.Element;
1186
1201
 
1187
1202
  /**
1188
1203
  * CopilotToggleButton - Edge toggle button for floating copilot
package/dist/index.js CHANGED
@@ -1237,6 +1237,16 @@ function useCrowAPI({ onIdentified, onReset } = {}) {
1237
1237
  }
1238
1238
  return crowAsk(opts);
1239
1239
  }
1240
+ case "setContextLabel":
1241
+ if (typeof options !== "string") {
1242
+ console.error("[Crow] setContextLabel() requires a string");
1243
+ return;
1244
+ }
1245
+ window.__crow_context_label = options || void 0;
1246
+ window.dispatchEvent(
1247
+ new CustomEvent("crow:setContextLabel", { detail: options })
1248
+ );
1249
+ break;
1240
1250
  case "setSuggestedActions":
1241
1251
  if (!Array.isArray(options)) {
1242
1252
  console.error("[Crow] setSuggestedActions() requires an array of { label, message }");
@@ -1369,7 +1379,8 @@ var DEFAULT_WIDGET_STYLES = {
1369
1379
  // ═══════════════════════════════════════════════════════════
1370
1380
  bubble: {
1371
1381
  size: 48,
1372
- iconSize: 24
1382
+ iconSize: 24,
1383
+ label: ""
1373
1384
  },
1374
1385
  // ═══════════════════════════════════════════════════════════
1375
1386
  // SHADOWS
@@ -2307,14 +2318,20 @@ function ShadowContainer({
2307
2318
  ShadowContainer.displayName = "ShadowContainer";
2308
2319
  function ChatBubble({ isExpanded, onClick }) {
2309
2320
  const { styles } = useWidgetStyleContext();
2310
- return /* @__PURE__ */ jsx(
2321
+ const label = styles.bubble.label;
2322
+ const showLabel = !isExpanded && !!label;
2323
+ return /* @__PURE__ */ jsxs(
2311
2324
  "button",
2312
2325
  {
2313
2326
  onClick,
2314
- 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",
2327
+ 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",
2315
2328
  style: {
2316
- width: styles.bubble.size,
2317
2329
  height: styles.bubble.size,
2330
+ width: showLabel ? "auto" : styles.bubble.size,
2331
+ paddingLeft: showLabel ? styles.bubble.size * 0.3 : 0,
2332
+ paddingRight: showLabel ? styles.bubble.size * 0.4 : 0,
2333
+ gap: showLabel ? 6 : 0,
2334
+ borderRadius: 9999,
2318
2335
  right: styles.position.bubbleRight,
2319
2336
  bottom: styles.position.bubbleBottom,
2320
2337
  background: styles.colors.bubbleBackground,
@@ -2323,7 +2340,15 @@ function ChatBubble({ isExpanded, onClick }) {
2323
2340
  color: styles.colors.bubbleIcon
2324
2341
  },
2325
2342
  "aria-label": isExpanded ? "Close Chat" : "Open Chat",
2326
- children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { size: styles.bubble.iconSize, strokeWidth: 2 }) : /* @__PURE__ */ jsx(MessageCircle, { size: styles.bubble.iconSize, strokeWidth: 2 })
2343
+ children: [
2344
+ isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { size: styles.bubble.iconSize, strokeWidth: 2 }) : /* @__PURE__ */ jsx(MessageCircle, { size: styles.bubble.iconSize, strokeWidth: 2 }),
2345
+ showLabel && /* @__PURE__ */ jsx("span", { style: {
2346
+ fontSize: styles.bubble.iconSize * 0.6,
2347
+ fontWeight: 500,
2348
+ whiteSpace: "nowrap",
2349
+ fontFamily: "system-ui, sans-serif"
2350
+ }, children: label })
2351
+ ]
2327
2352
  }
2328
2353
  );
2329
2354
  }
@@ -2423,7 +2448,8 @@ function WidgetHeader({
2423
2448
  onDragPointerDown,
2424
2449
  isDragging,
2425
2450
  hasCustomTransform,
2426
- onResetTransform
2451
+ onResetTransform,
2452
+ contextLabel
2427
2453
  }) {
2428
2454
  const { agentName, styles } = useWidgetStyleContext();
2429
2455
  return /* @__PURE__ */ jsxs(
@@ -2511,7 +2537,36 @@ function WidgetHeader({
2511
2537
  children: /* @__PURE__ */ jsx(X, { size: 18, className: "crow-text-gray-700" })
2512
2538
  }
2513
2539
  )
2514
- ] })
2540
+ ] }),
2541
+ contextLabel && /* @__PURE__ */ jsxs(
2542
+ "div",
2543
+ {
2544
+ className: "crow-flex crow-items-center crow-gap-1.5 crow-mt-1 crow-text-xs",
2545
+ style: { color: "#6b7280" },
2546
+ children: [
2547
+ /* @__PURE__ */ jsxs(
2548
+ "svg",
2549
+ {
2550
+ xmlns: "http://www.w3.org/2000/svg",
2551
+ width: "12",
2552
+ height: "12",
2553
+ viewBox: "0 0 24 24",
2554
+ fill: "none",
2555
+ stroke: "currentColor",
2556
+ strokeWidth: "2",
2557
+ strokeLinecap: "round",
2558
+ strokeLinejoin: "round",
2559
+ className: "crow-shrink-0",
2560
+ children: [
2561
+ /* @__PURE__ */ jsx("path", { d: "M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z" }),
2562
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "10", r: "3" })
2563
+ ]
2564
+ }
2565
+ ),
2566
+ /* @__PURE__ */ jsx("span", { className: "crow-truncate", children: contextLabel })
2567
+ ]
2568
+ }
2569
+ )
2515
2570
  ]
2516
2571
  }
2517
2572
  );
@@ -4117,7 +4172,8 @@ function CrowWidget({
4117
4172
  context,
4118
4173
  toolRenderers,
4119
4174
  language,
4120
- customCss
4175
+ customCss,
4176
+ contextLabel: contextLabelProp
4121
4177
  }) {
4122
4178
  const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
4123
4179
  const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
@@ -4158,6 +4214,15 @@ function CrowWidget({
4158
4214
  window.addEventListener("crow:setGreeting", handler);
4159
4215
  return () => window.removeEventListener("crow:setGreeting", handler);
4160
4216
  }, []);
4217
+ const [contextLabelFromAPI, setContextLabelFromAPI] = useState(
4218
+ () => window.__crow_context_label
4219
+ );
4220
+ useEffect(() => {
4221
+ const handler = (e) => setContextLabelFromAPI(e.detail || void 0);
4222
+ window.addEventListener("crow:setContextLabel", handler);
4223
+ return () => window.removeEventListener("crow:setContextLabel", handler);
4224
+ }, []);
4225
+ const contextLabel = contextLabelProp ?? contextLabelFromAPI;
4161
4226
  const agentName = agentNameProp ?? agentNameFromAPI;
4162
4227
  const welcomeMessage = greetingOverride ?? welcomeMessageProp ?? welcomeMessageFromAPI;
4163
4228
  const selectedModel = selectedModelFromAPI;
@@ -4648,7 +4713,8 @@ function CrowWidget({
4648
4713
  onDragPointerDown: variant === "floating" ? transform.onDragPointerDown : void 0,
4649
4714
  isDragging: transform.isDragging,
4650
4715
  hasCustomTransform: transform.hasCustomTransform,
4651
- onResetTransform: transform.resetTransform
4716
+ onResetTransform: transform.resetTransform,
4717
+ contextLabel
4652
4718
  }
4653
4719
  ),
4654
4720
  /* @__PURE__ */ jsx(AnimatePresence, { children: showConversationList && isVerifiedUser && /* @__PURE__ */ jsx(
@@ -5040,7 +5106,8 @@ function CrowCopilot({
5040
5106
  toolRenderers,
5041
5107
  getIdentityToken,
5042
5108
  context,
5043
- language
5109
+ language,
5110
+ contextLabel: contextLabelProp
5044
5111
  }) {
5045
5112
  const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
5046
5113
  const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
@@ -5081,6 +5148,15 @@ function CrowCopilot({
5081
5148
  return () => window.removeEventListener("crow:setGreeting", handler);
5082
5149
  }, []);
5083
5150
  const welcomeMessage = greetingOverride ?? welcomeMessageProp ?? welcomeMessageFromAPI;
5151
+ const [contextLabelFromAPI, setContextLabelFromAPI] = useState(
5152
+ () => window.__crow_context_label
5153
+ );
5154
+ useEffect(() => {
5155
+ const handler = (e) => setContextLabelFromAPI(e.detail || void 0);
5156
+ window.addEventListener("crow:setContextLabel", handler);
5157
+ return () => window.removeEventListener("crow:setContextLabel", handler);
5158
+ }, []);
5159
+ const contextLabel = contextLabelProp ?? contextLabelFromAPI;
5084
5160
  const [autoTools, setAutoTools] = useState({});
5085
5161
  const browserUseLoaded = autoTools.browser_use;
5086
5162
  useEffect(() => {
@@ -5895,6 +5971,38 @@ function CrowCopilot({
5895
5971
  ]
5896
5972
  }
5897
5973
  ),
5974
+ contextLabel && /* @__PURE__ */ jsxs(
5975
+ "div",
5976
+ {
5977
+ className: "crow-flex crow-items-center crow-gap-1.5 crow-px-3 crow-py-1.5 crow-border-b crow-text-xs",
5978
+ style: {
5979
+ color: "#6b7280",
5980
+ borderColor: styles.colors.border
5981
+ },
5982
+ children: [
5983
+ /* @__PURE__ */ jsxs(
5984
+ "svg",
5985
+ {
5986
+ xmlns: "http://www.w3.org/2000/svg",
5987
+ width: "12",
5988
+ height: "12",
5989
+ viewBox: "0 0 24 24",
5990
+ fill: "none",
5991
+ stroke: "currentColor",
5992
+ strokeWidth: "2",
5993
+ strokeLinecap: "round",
5994
+ strokeLinejoin: "round",
5995
+ className: "crow-shrink-0",
5996
+ children: [
5997
+ /* @__PURE__ */ jsx("path", { d: "M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z" }),
5998
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "10", r: "3" })
5999
+ ]
6000
+ }
6001
+ ),
6002
+ /* @__PURE__ */ jsx("span", { className: "crow-truncate", children: contextLabel })
6003
+ ]
6004
+ }
6005
+ ),
5898
6006
  /* @__PURE__ */ jsxs(AnimatePresence, { children: [
5899
6007
  showConversationList && isVerifiedUser && /* @__PURE__ */ jsx(
5900
6008
  ConversationList,