@mordn/chat-widget 0.2.1 → 0.3.0

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.mjs CHANGED
@@ -2197,10 +2197,13 @@ function ChatWidget({
2197
2197
  display,
2198
2198
  starterPrompts
2199
2199
  }) {
2200
+ const layout = display?.layout || "popup";
2200
2201
  const showToggleButton = display?.showToggleButton !== false;
2201
- const resizable = display?.resizable !== false;
2202
+ const resizable = layout === "popup" && display?.resizable !== false;
2202
2203
  const size = display?.size || "default";
2203
- const [isOpen, setIsOpen] = useState5(display?.defaultOpen || false);
2204
+ const [isOpen, setIsOpen] = useState5(
2205
+ layout !== "popup" ? true : display?.defaultOpen || false
2206
+ );
2204
2207
  const [isResizing, setIsResizing] = useState5(false);
2205
2208
  const containerRef = useRef4(null);
2206
2209
  const customStyles = useMemo3(() => {
@@ -2261,6 +2264,43 @@ function ChatWidget({
2261
2264
  starterPrompts
2262
2265
  }), [userId, model, systemPrompt, temperature, theme, features, starterPrompts]);
2263
2266
  const togglePosition = display?.toggleButtonPosition || { bottom: "24px", right: "24px" };
2267
+ const themeClass = theme?.mode === "dark" ? "dark" : "";
2268
+ if (layout === "inline") {
2269
+ return /* @__PURE__ */ jsx21(ChatStorageProvider, { userId, children: /* @__PURE__ */ jsx21(
2270
+ "div",
2271
+ {
2272
+ ref: containerRef,
2273
+ className: `chat-widget-container chat-widget-inline chat-widget-content ${themeClass} ${className || ""}`,
2274
+ style: customStyles,
2275
+ children: /* @__PURE__ */ jsx21(
2276
+ ChatInterface,
2277
+ {
2278
+ id: conversationId,
2279
+ initialMessages,
2280
+ config
2281
+ }
2282
+ )
2283
+ }
2284
+ ) });
2285
+ }
2286
+ if (layout === "page") {
2287
+ return /* @__PURE__ */ jsx21(ChatStorageProvider, { userId, children: /* @__PURE__ */ jsx21(
2288
+ "div",
2289
+ {
2290
+ ref: containerRef,
2291
+ className: `chat-widget-container chat-widget-page chat-widget-content ${themeClass} ${className || ""}`,
2292
+ style: customStyles,
2293
+ children: /* @__PURE__ */ jsx21(
2294
+ ChatInterface,
2295
+ {
2296
+ id: conversationId,
2297
+ initialMessages,
2298
+ config
2299
+ }
2300
+ )
2301
+ }
2302
+ ) });
2303
+ }
2264
2304
  return /* @__PURE__ */ jsxs13(ChatStorageProvider, { userId, children: [
2265
2305
  showToggleButton && !isOpen && /* @__PURE__ */ jsx21(
2266
2306
  "button",
@@ -2276,7 +2316,7 @@ function ChatWidget({
2276
2316
  "div",
2277
2317
  {
2278
2318
  ref: containerRef,
2279
- className: `chat-widget-container chat-widget-popup chat-widget-content ${theme?.mode === "dark" ? "dark" : ""} ${className || ""}`,
2319
+ className: `chat-widget-container chat-widget-popup chat-widget-content ${themeClass} ${className || ""}`,
2280
2320
  "data-size": size,
2281
2321
  "data-resizing": isResizing,
2282
2322
  style: customStyles,