@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.cjs CHANGED
@@ -1786,6 +1786,9 @@ function useCopilotStyles({
1786
1786
  const [availableModels, setAvailableModels] = React3.useState(
1787
1787
  styleCache.get(key)?.availableModels || []
1788
1788
  );
1789
+ const [initialSuggestions, setInitialSuggestions] = React3.useState(
1790
+ styleCache.get(key)?.initialSuggestions || []
1791
+ );
1789
1792
  const hasFetchedRef = React3.useRef(false);
1790
1793
  const fetchStyles = async () => {
1791
1794
  if (skip) return;
@@ -1805,6 +1808,7 @@ function useCopilotStyles({
1805
1808
  setToolConsentSettings(config.toolConsentSettings || {});
1806
1809
  setModelSelectionEnabled(config.modelSelectionEnabled || false);
1807
1810
  setAvailableModels(config.availableModels || []);
1811
+ setInitialSuggestions(config.initialSuggestions || []);
1808
1812
  } catch (err) {
1809
1813
  console.error("[CrowCopilot] Failed to fetch styles:", err);
1810
1814
  setError(err instanceof Error ? err : new Error(String(err)));
@@ -1826,6 +1830,7 @@ function useCopilotStyles({
1826
1830
  setSelectedModel(cached.model ?? void 0);
1827
1831
  setModelSelectionEnabled(cached.modelSelectionEnabled || false);
1828
1832
  setAvailableModels(cached.availableModels || []);
1833
+ setInitialSuggestions(cached.initialSuggestions || []);
1829
1834
  setIsLoading(false);
1830
1835
  return;
1831
1836
  }
@@ -1847,6 +1852,7 @@ function useCopilotStyles({
1847
1852
  toolConsentSettings,
1848
1853
  modelSelectionEnabled,
1849
1854
  availableModels,
1855
+ initialSuggestions,
1850
1856
  refetch: fetchStyles
1851
1857
  };
1852
1858
  }
@@ -2433,7 +2439,7 @@ function ShadowContainer({
2433
2439
  document.removeEventListener("keydown", protectFocus, { capture: true });
2434
2440
  };
2435
2441
  }, [shadowRoot]);
2436
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: hostRef, id: hostId, className: hostClassName, children: shadowRoot && reactDom.createPortal(
2442
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: hostRef, id: hostId, className: hostClassName, style: { height: "100%" }, children: shadowRoot && reactDom.createPortal(
2437
2443
  /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2438
2444
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: styles }),
2439
2445
  children
@@ -5193,15 +5199,30 @@ function CopilotContainer({
5193
5199
  }, [currentWidth]);
5194
5200
  React3.useEffect(() => {
5195
5201
  const className = `crow-copilot-open-${position}`;
5202
+ const marginProp = position === "right" ? "margin-right" : "margin-left";
5203
+ const widthVal = `var(--crow-copilot-width, ${currentWidth}px)`;
5196
5204
  if (isOpen) {
5197
5205
  document.body.classList.add(className);
5206
+ document.body.style.setProperty(marginProp, widthVal, "important");
5207
+ document.body.style.setProperty(
5208
+ "width",
5209
+ `calc(100% - ${widthVal})`,
5210
+ "important"
5211
+ );
5212
+ document.body.style.setProperty("overflow-x", "hidden", "important");
5198
5213
  } else {
5199
5214
  document.body.classList.remove(className);
5215
+ document.body.style.removeProperty(marginProp);
5216
+ document.body.style.removeProperty("width");
5217
+ document.body.style.removeProperty("overflow-x");
5200
5218
  }
5201
5219
  return () => {
5202
5220
  document.body.classList.remove(className);
5221
+ document.body.style.removeProperty(marginProp);
5222
+ document.body.style.removeProperty("width");
5223
+ document.body.style.removeProperty("overflow-x");
5203
5224
  };
5204
- }, [isOpen, position]);
5225
+ }, [isOpen, position, currentWidth]);
5205
5226
  React3.useEffect(() => {
5206
5227
  window.crowCopilot = {
5207
5228
  open: () => setIsOpen(true),
@@ -5357,7 +5378,8 @@ function CrowCopilot({
5357
5378
  selectedModel,
5358
5379
  toolConsentSettings,
5359
5380
  modelSelectionEnabled,
5360
- availableModels: availableModelsFromAPI
5381
+ availableModels: availableModelsFromAPI,
5382
+ initialSuggestions
5361
5383
  } = useCopilotStyles({
5362
5384
  productId,
5363
5385
  apiUrl,
@@ -5539,6 +5561,11 @@ function CrowCopilot({
5539
5561
  window.removeEventListener("crow:setSuggestedActions", handleSetSuggestions);
5540
5562
  };
5541
5563
  }, []);
5564
+ React3.useEffect(() => {
5565
+ if (initialSuggestions.length > 0 && chat.suggestedActions.length === 0) {
5566
+ chat.setSuggestedActions(initialSuggestions);
5567
+ }
5568
+ }, [initialSuggestions]);
5542
5569
  const messagesContainerRef = React3.useRef(null);
5543
5570
  const tabsScrollRef = React3.useRef(null);
5544
5571
  const executeClientToolRef = React3.useRef(null);