@mordn/chat-widget 0.2.0 → 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
@@ -2007,26 +2007,21 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
2007
2007
  /* @__PURE__ */ jsx20("div", { className: "p-2.5 border-b", style: {
2008
2008
  borderColor: "var(--chat-border-soft)",
2009
2009
  backgroundColor: "var(--chat-overlay)"
2010
- }, children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
2011
- /* @__PURE__ */ jsx20(SearchIcon, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5", style: {
2012
- color: "hsl(var(--chat-text-muted))"
2013
- }, strokeWidth: 2 }),
2014
- /* @__PURE__ */ jsx20(
2015
- "input",
2016
- {
2017
- type: "text",
2018
- placeholder: "Search",
2019
- value: searchQuery,
2020
- onChange: (e) => setSearchQuery(e.target.value),
2021
- className: "w-full h-7 pl-8 pr-2.5 text-[13px] rounded-lg focus:outline-none transition-all",
2022
- style: {
2023
- backgroundColor: "hsl(var(--chat-surface-deep))",
2024
- border: `1px solid ${"var(--chat-border-medium)"}`,
2025
- color: "hsl(var(--chat-text))"
2026
- }
2010
+ }, children: /* @__PURE__ */ jsx20("div", { className: "relative", children: /* @__PURE__ */ jsx20(
2011
+ "input",
2012
+ {
2013
+ type: "text",
2014
+ placeholder: "Search",
2015
+ value: searchQuery,
2016
+ onChange: (e) => setSearchQuery(e.target.value),
2017
+ className: "w-full h-7 px-2.5 text-[13px] rounded-lg focus:outline-none transition-all",
2018
+ style: {
2019
+ backgroundColor: "hsl(var(--chat-surface-deep))",
2020
+ border: `1px solid ${"var(--chat-border-medium)"}`,
2021
+ color: "hsl(var(--chat-text))"
2027
2022
  }
2028
- )
2029
- ] }) }),
2023
+ }
2024
+ ) }) }),
2030
2025
  /* @__PURE__ */ jsx20("div", { className: "max-h-[300px] overflow-y-auto ai-assistant-scrollbar", children: loadingHistory ? /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsx20("div", { className: "text-[13px]", style: { color: "hsl(var(--chat-text-muted))" }, children: "Loading..." }) }) : conversations.length === 0 ? /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
2031
2026
  /* @__PURE__ */ jsx20("div", { className: "w-12 h-12 rounded-full flex items-center justify-center mb-3", style: {
2032
2027
  backgroundColor: "hsl(var(--chat-surface))"
@@ -2202,10 +2197,13 @@ function ChatWidget({
2202
2197
  display,
2203
2198
  starterPrompts
2204
2199
  }) {
2200
+ const layout = display?.layout || "popup";
2205
2201
  const showToggleButton = display?.showToggleButton !== false;
2206
- const resizable = display?.resizable !== false;
2202
+ const resizable = layout === "popup" && display?.resizable !== false;
2207
2203
  const size = display?.size || "default";
2208
- const [isOpen, setIsOpen] = useState5(display?.defaultOpen || false);
2204
+ const [isOpen, setIsOpen] = useState5(
2205
+ layout !== "popup" ? true : display?.defaultOpen || false
2206
+ );
2209
2207
  const [isResizing, setIsResizing] = useState5(false);
2210
2208
  const containerRef = useRef4(null);
2211
2209
  const customStyles = useMemo3(() => {
@@ -2266,6 +2264,43 @@ function ChatWidget({
2266
2264
  starterPrompts
2267
2265
  }), [userId, model, systemPrompt, temperature, theme, features, starterPrompts]);
2268
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
+ }
2269
2304
  return /* @__PURE__ */ jsxs13(ChatStorageProvider, { userId, children: [
2270
2305
  showToggleButton && !isOpen && /* @__PURE__ */ jsx21(
2271
2306
  "button",
@@ -2281,7 +2316,7 @@ function ChatWidget({
2281
2316
  "div",
2282
2317
  {
2283
2318
  ref: containerRef,
2284
- 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 || ""}`,
2285
2320
  "data-size": size,
2286
2321
  "data-resizing": isResizing,
2287
2322
  style: customStyles,