@usecrow/ui 0.1.70 → 0.1.72

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
@@ -941,6 +941,11 @@ interface UseCopilotStylesResult {
941
941
  name: string;
942
942
  provider: "OpenAI" | "Anthropic";
943
943
  }>;
944
+ /** Initial suggestion buttons from product config */
945
+ initialSuggestions: Array<{
946
+ label: string;
947
+ message: string;
948
+ }>;
944
949
  /** Refetch styles from API */
945
950
  refetch: () => Promise<void>;
946
951
  }
package/dist/index.d.ts CHANGED
@@ -941,6 +941,11 @@ interface UseCopilotStylesResult {
941
941
  name: string;
942
942
  provider: "OpenAI" | "Anthropic";
943
943
  }>;
944
+ /** Initial suggestion buttons from product config */
945
+ initialSuggestions: Array<{
946
+ label: string;
947
+ message: string;
948
+ }>;
944
949
  /** Refetch styles from API */
945
950
  refetch: () => Promise<void>;
946
951
  }
package/dist/index.js CHANGED
@@ -1759,6 +1759,9 @@ function useCopilotStyles({
1759
1759
  const [availableModels, setAvailableModels] = useState(
1760
1760
  styleCache.get(key)?.availableModels || []
1761
1761
  );
1762
+ const [initialSuggestions, setInitialSuggestions] = useState(
1763
+ styleCache.get(key)?.initialSuggestions || []
1764
+ );
1762
1765
  const hasFetchedRef = useRef(false);
1763
1766
  const fetchStyles = async () => {
1764
1767
  if (skip) return;
@@ -1778,6 +1781,7 @@ function useCopilotStyles({
1778
1781
  setToolConsentSettings(config.toolConsentSettings || {});
1779
1782
  setModelSelectionEnabled(config.modelSelectionEnabled || false);
1780
1783
  setAvailableModels(config.availableModels || []);
1784
+ setInitialSuggestions(config.initialSuggestions || []);
1781
1785
  } catch (err) {
1782
1786
  console.error("[CrowCopilot] Failed to fetch styles:", err);
1783
1787
  setError(err instanceof Error ? err : new Error(String(err)));
@@ -1799,6 +1803,7 @@ function useCopilotStyles({
1799
1803
  setSelectedModel(cached.model ?? void 0);
1800
1804
  setModelSelectionEnabled(cached.modelSelectionEnabled || false);
1801
1805
  setAvailableModels(cached.availableModels || []);
1806
+ setInitialSuggestions(cached.initialSuggestions || []);
1802
1807
  setIsLoading(false);
1803
1808
  return;
1804
1809
  }
@@ -1820,6 +1825,7 @@ function useCopilotStyles({
1820
1825
  toolConsentSettings,
1821
1826
  modelSelectionEnabled,
1822
1827
  availableModels,
1828
+ initialSuggestions,
1823
1829
  refetch: fetchStyles
1824
1830
  };
1825
1831
  }
@@ -2406,7 +2412,7 @@ function ShadowContainer({
2406
2412
  document.removeEventListener("keydown", protectFocus, { capture: true });
2407
2413
  };
2408
2414
  }, [shadowRoot]);
2409
- return /* @__PURE__ */ jsx("div", { ref: hostRef, id: hostId, className: hostClassName, children: shadowRoot && createPortal(
2415
+ return /* @__PURE__ */ jsx("div", { ref: hostRef, id: hostId, className: hostClassName, style: { height: "100%" }, children: shadowRoot && createPortal(
2410
2416
  /* @__PURE__ */ jsxs(Fragment, { children: [
2411
2417
  /* @__PURE__ */ jsx("style", { children: styles }),
2412
2418
  children
@@ -5166,15 +5172,30 @@ function CopilotContainer({
5166
5172
  }, [currentWidth]);
5167
5173
  useEffect(() => {
5168
5174
  const className = `crow-copilot-open-${position}`;
5175
+ const marginProp = position === "right" ? "margin-right" : "margin-left";
5176
+ const widthVal = `var(--crow-copilot-width, ${currentWidth}px)`;
5169
5177
  if (isOpen) {
5170
5178
  document.body.classList.add(className);
5179
+ document.body.style.setProperty(marginProp, widthVal, "important");
5180
+ document.body.style.setProperty(
5181
+ "width",
5182
+ `calc(100% - ${widthVal})`,
5183
+ "important"
5184
+ );
5185
+ document.body.style.setProperty("overflow-x", "hidden", "important");
5171
5186
  } else {
5172
5187
  document.body.classList.remove(className);
5188
+ document.body.style.removeProperty(marginProp);
5189
+ document.body.style.removeProperty("width");
5190
+ document.body.style.removeProperty("overflow-x");
5173
5191
  }
5174
5192
  return () => {
5175
5193
  document.body.classList.remove(className);
5194
+ document.body.style.removeProperty(marginProp);
5195
+ document.body.style.removeProperty("width");
5196
+ document.body.style.removeProperty("overflow-x");
5176
5197
  };
5177
- }, [isOpen, position]);
5198
+ }, [isOpen, position, currentWidth]);
5178
5199
  useEffect(() => {
5179
5200
  window.crowCopilot = {
5180
5201
  open: () => setIsOpen(true),
@@ -5330,7 +5351,8 @@ function CrowCopilot({
5330
5351
  selectedModel,
5331
5352
  toolConsentSettings,
5332
5353
  modelSelectionEnabled,
5333
- availableModels: availableModelsFromAPI
5354
+ availableModels: availableModelsFromAPI,
5355
+ initialSuggestions
5334
5356
  } = useCopilotStyles({
5335
5357
  productId,
5336
5358
  apiUrl,
@@ -5512,6 +5534,11 @@ function CrowCopilot({
5512
5534
  window.removeEventListener("crow:setSuggestedActions", handleSetSuggestions);
5513
5535
  };
5514
5536
  }, []);
5537
+ useEffect(() => {
5538
+ if (initialSuggestions.length > 0 && chat.suggestedActions.length === 0) {
5539
+ chat.setSuggestedActions(initialSuggestions);
5540
+ }
5541
+ }, [initialSuggestions]);
5515
5542
  const messagesContainerRef = useRef(null);
5516
5543
  const tabsScrollRef = useRef(null);
5517
5544
  const executeClientToolRef = useRef(null);