@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.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -3
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -120,11 +120,34 @@ interface FeatureConfig {
|
|
|
120
120
|
* - full: 100% - fills entire screen
|
|
121
121
|
*/
|
|
122
122
|
type ChatWidgetSize = 'compact' | 'default' | 'large' | 'full';
|
|
123
|
+
/**
|
|
124
|
+
* Layout shape the widget renders in.
|
|
125
|
+
*
|
|
126
|
+
* - `popup` : floating side panel, opened by a toggle button (default).
|
|
127
|
+
* Best for ambient assistance available across pages.
|
|
128
|
+
* - `inline` : renders in place inside the parent element. No toggle button,
|
|
129
|
+
* no fixed positioning, fills its container. Best for dashboard
|
|
130
|
+
* cards or dedicated chat sections of a page.
|
|
131
|
+
* - `page` : full-viewport layout with a conversation list sidebar on the
|
|
132
|
+
* left and the active chat on the right. Best for a dedicated
|
|
133
|
+
* chat route (e.g. `/chat`).
|
|
134
|
+
*
|
|
135
|
+
* The `popup` value is the historical default and remains backward compatible.
|
|
136
|
+
*/
|
|
137
|
+
type ChatWidgetLayout = 'popup' | 'inline' | 'page';
|
|
123
138
|
interface DisplayConfig {
|
|
139
|
+
/**
|
|
140
|
+
* How the widget renders.
|
|
141
|
+
* Default: `'popup'` (backward compatible).
|
|
142
|
+
*/
|
|
143
|
+
layout?: ChatWidgetLayout;
|
|
124
144
|
/**
|
|
125
145
|
* Preset size for the widget (recommended)
|
|
126
146
|
* Uses clamp() for responsive sizing with min/max bounds
|
|
127
147
|
* Default: 'default'
|
|
148
|
+
*
|
|
149
|
+
* Note: `size` only applies in `popup` layout. `inline` and `page` layouts
|
|
150
|
+
* fill their container regardless.
|
|
128
151
|
*/
|
|
129
152
|
size?: ChatWidgetSize;
|
|
130
153
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -120,11 +120,34 @@ interface FeatureConfig {
|
|
|
120
120
|
* - full: 100% - fills entire screen
|
|
121
121
|
*/
|
|
122
122
|
type ChatWidgetSize = 'compact' | 'default' | 'large' | 'full';
|
|
123
|
+
/**
|
|
124
|
+
* Layout shape the widget renders in.
|
|
125
|
+
*
|
|
126
|
+
* - `popup` : floating side panel, opened by a toggle button (default).
|
|
127
|
+
* Best for ambient assistance available across pages.
|
|
128
|
+
* - `inline` : renders in place inside the parent element. No toggle button,
|
|
129
|
+
* no fixed positioning, fills its container. Best for dashboard
|
|
130
|
+
* cards or dedicated chat sections of a page.
|
|
131
|
+
* - `page` : full-viewport layout with a conversation list sidebar on the
|
|
132
|
+
* left and the active chat on the right. Best for a dedicated
|
|
133
|
+
* chat route (e.g. `/chat`).
|
|
134
|
+
*
|
|
135
|
+
* The `popup` value is the historical default and remains backward compatible.
|
|
136
|
+
*/
|
|
137
|
+
type ChatWidgetLayout = 'popup' | 'inline' | 'page';
|
|
123
138
|
interface DisplayConfig {
|
|
139
|
+
/**
|
|
140
|
+
* How the widget renders.
|
|
141
|
+
* Default: `'popup'` (backward compatible).
|
|
142
|
+
*/
|
|
143
|
+
layout?: ChatWidgetLayout;
|
|
124
144
|
/**
|
|
125
145
|
* Preset size for the widget (recommended)
|
|
126
146
|
* Uses clamp() for responsive sizing with min/max bounds
|
|
127
147
|
* Default: 'default'
|
|
148
|
+
*
|
|
149
|
+
* Note: `size` only applies in `popup` layout. `inline` and `page` layouts
|
|
150
|
+
* fill their container regardless.
|
|
128
151
|
*/
|
|
129
152
|
size?: ChatWidgetSize;
|
|
130
153
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2217,10 +2217,13 @@ function ChatWidget({
|
|
|
2217
2217
|
display,
|
|
2218
2218
|
starterPrompts
|
|
2219
2219
|
}) {
|
|
2220
|
+
const layout = display?.layout || "popup";
|
|
2220
2221
|
const showToggleButton = display?.showToggleButton !== false;
|
|
2221
|
-
const resizable = display?.resizable !== false;
|
|
2222
|
+
const resizable = layout === "popup" && display?.resizable !== false;
|
|
2222
2223
|
const size = display?.size || "default";
|
|
2223
|
-
const [isOpen, setIsOpen] = (0, import_react12.useState)(
|
|
2224
|
+
const [isOpen, setIsOpen] = (0, import_react12.useState)(
|
|
2225
|
+
layout !== "popup" ? true : display?.defaultOpen || false
|
|
2226
|
+
);
|
|
2224
2227
|
const [isResizing, setIsResizing] = (0, import_react12.useState)(false);
|
|
2225
2228
|
const containerRef = (0, import_react12.useRef)(null);
|
|
2226
2229
|
const customStyles = (0, import_react12.useMemo)(() => {
|
|
@@ -2281,6 +2284,43 @@ function ChatWidget({
|
|
|
2281
2284
|
starterPrompts
|
|
2282
2285
|
}), [userId, model, systemPrompt, temperature, theme, features, starterPrompts]);
|
|
2283
2286
|
const togglePosition = display?.toggleButtonPosition || { bottom: "24px", right: "24px" };
|
|
2287
|
+
const themeClass = theme?.mode === "dark" ? "dark" : "";
|
|
2288
|
+
if (layout === "inline") {
|
|
2289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ChatStorageProvider, { userId, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2290
|
+
"div",
|
|
2291
|
+
{
|
|
2292
|
+
ref: containerRef,
|
|
2293
|
+
className: `chat-widget-container chat-widget-inline chat-widget-content ${themeClass} ${className || ""}`,
|
|
2294
|
+
style: customStyles,
|
|
2295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2296
|
+
ChatInterface,
|
|
2297
|
+
{
|
|
2298
|
+
id: conversationId,
|
|
2299
|
+
initialMessages,
|
|
2300
|
+
config
|
|
2301
|
+
}
|
|
2302
|
+
)
|
|
2303
|
+
}
|
|
2304
|
+
) });
|
|
2305
|
+
}
|
|
2306
|
+
if (layout === "page") {
|
|
2307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ChatStorageProvider, { userId, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2308
|
+
"div",
|
|
2309
|
+
{
|
|
2310
|
+
ref: containerRef,
|
|
2311
|
+
className: `chat-widget-container chat-widget-page chat-widget-content ${themeClass} ${className || ""}`,
|
|
2312
|
+
style: customStyles,
|
|
2313
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2314
|
+
ChatInterface,
|
|
2315
|
+
{
|
|
2316
|
+
id: conversationId,
|
|
2317
|
+
initialMessages,
|
|
2318
|
+
config
|
|
2319
|
+
}
|
|
2320
|
+
)
|
|
2321
|
+
}
|
|
2322
|
+
) });
|
|
2323
|
+
}
|
|
2284
2324
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ChatStorageProvider, { userId, children: [
|
|
2285
2325
|
showToggleButton && !isOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2286
2326
|
"button",
|
|
@@ -2296,7 +2336,7 @@ function ChatWidget({
|
|
|
2296
2336
|
"div",
|
|
2297
2337
|
{
|
|
2298
2338
|
ref: containerRef,
|
|
2299
|
-
className: `chat-widget-container chat-widget-popup chat-widget-content ${
|
|
2339
|
+
className: `chat-widget-container chat-widget-popup chat-widget-content ${themeClass} ${className || ""}`,
|
|
2300
2340
|
"data-size": size,
|
|
2301
2341
|
"data-resizing": isResizing,
|
|
2302
2342
|
style: customStyles,
|