@mordn/chat-widget 0.3.0 → 0.4.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 +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -57,6 +57,23 @@ interface ChatWidgetConfig {
|
|
|
57
57
|
* Users can click these to quickly start a conversation
|
|
58
58
|
*/
|
|
59
59
|
starterPrompts?: StarterPrompt[];
|
|
60
|
+
/**
|
|
61
|
+
* Called when the user dismisses the widget. The widget renders its own
|
|
62
|
+
* close X inside the header (correctly stacked) when this is provided —
|
|
63
|
+
* works in all layouts (popup, inline, page).
|
|
64
|
+
*
|
|
65
|
+
* In `popup` layout the widget also auto-closes its own panel; in
|
|
66
|
+
* `inline` and `page` layouts the consumer owns the close behaviour
|
|
67
|
+
* (e.g. setting their open state, navigating away).
|
|
68
|
+
*/
|
|
69
|
+
onClose?: () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Custom buttons rendered in the widget header next to the close X.
|
|
72
|
+
* Use this for "expand to full page", "settings", or any consumer-defined
|
|
73
|
+
* action that belongs in the widget's chrome — avoids absolute-positioning
|
|
74
|
+
* overlays from the outside that fight the widget's own z-index.
|
|
75
|
+
*/
|
|
76
|
+
headerActions?: ReactNode;
|
|
60
77
|
}
|
|
61
78
|
interface StarterPrompt {
|
|
62
79
|
/**
|
|
@@ -120,6 +137,7 @@ interface FeatureConfig {
|
|
|
120
137
|
* - full: 100% - fills entire screen
|
|
121
138
|
*/
|
|
122
139
|
type ChatWidgetSize = 'compact' | 'default' | 'large' | 'full';
|
|
140
|
+
|
|
123
141
|
/**
|
|
124
142
|
* Layout shape the widget renders in.
|
|
125
143
|
*
|
|
@@ -193,7 +211,7 @@ interface ChatWidgetProps extends ChatWidgetConfig {
|
|
|
193
211
|
*/
|
|
194
212
|
widgetId?: string;
|
|
195
213
|
}
|
|
196
|
-
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, starterPrompts, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
214
|
+
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, starterPrompts, onClose, headerActions, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
197
215
|
|
|
198
216
|
interface ChatTheme {
|
|
199
217
|
lightPrimary: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,23 @@ interface ChatWidgetConfig {
|
|
|
57
57
|
* Users can click these to quickly start a conversation
|
|
58
58
|
*/
|
|
59
59
|
starterPrompts?: StarterPrompt[];
|
|
60
|
+
/**
|
|
61
|
+
* Called when the user dismisses the widget. The widget renders its own
|
|
62
|
+
* close X inside the header (correctly stacked) when this is provided —
|
|
63
|
+
* works in all layouts (popup, inline, page).
|
|
64
|
+
*
|
|
65
|
+
* In `popup` layout the widget also auto-closes its own panel; in
|
|
66
|
+
* `inline` and `page` layouts the consumer owns the close behaviour
|
|
67
|
+
* (e.g. setting their open state, navigating away).
|
|
68
|
+
*/
|
|
69
|
+
onClose?: () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Custom buttons rendered in the widget header next to the close X.
|
|
72
|
+
* Use this for "expand to full page", "settings", or any consumer-defined
|
|
73
|
+
* action that belongs in the widget's chrome — avoids absolute-positioning
|
|
74
|
+
* overlays from the outside that fight the widget's own z-index.
|
|
75
|
+
*/
|
|
76
|
+
headerActions?: ReactNode;
|
|
60
77
|
}
|
|
61
78
|
interface StarterPrompt {
|
|
62
79
|
/**
|
|
@@ -120,6 +137,7 @@ interface FeatureConfig {
|
|
|
120
137
|
* - full: 100% - fills entire screen
|
|
121
138
|
*/
|
|
122
139
|
type ChatWidgetSize = 'compact' | 'default' | 'large' | 'full';
|
|
140
|
+
|
|
123
141
|
/**
|
|
124
142
|
* Layout shape the widget renders in.
|
|
125
143
|
*
|
|
@@ -193,7 +211,7 @@ interface ChatWidgetProps extends ChatWidgetConfig {
|
|
|
193
211
|
*/
|
|
194
212
|
widgetId?: string;
|
|
195
213
|
}
|
|
196
|
-
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, starterPrompts, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
214
|
+
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, starterPrompts, onClose, headerActions, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
197
215
|
|
|
198
216
|
interface ChatTheme {
|
|
199
217
|
lightPrimary: string;
|
package/dist/index.js
CHANGED
|
@@ -1431,7 +1431,7 @@ function useChatStorageKey() {
|
|
|
1431
1431
|
|
|
1432
1432
|
// src/components/interface.tsx
|
|
1433
1433
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1434
|
-
function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
1434
|
+
function ChatInterface({ id, initialMessages, config, onClose, headerActions } = {}) {
|
|
1435
1435
|
const { storageKeyPrefix } = useChatStorageKey();
|
|
1436
1436
|
const storageKey = (key) => storageKeyPrefix ? `chat-${storageKeyPrefix}-${key}` : `chat-${key}`;
|
|
1437
1437
|
const themeMode = config?.theme?.mode || "light";
|
|
@@ -2102,6 +2102,7 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
2102
2102
|
] }, groupName)) }) })
|
|
2103
2103
|
] })
|
|
2104
2104
|
] }),
|
|
2105
|
+
headerActions,
|
|
2105
2106
|
onClose && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2106
2107
|
"button",
|
|
2107
2108
|
{
|
|
@@ -2215,7 +2216,9 @@ function ChatWidget({
|
|
|
2215
2216
|
theme,
|
|
2216
2217
|
features,
|
|
2217
2218
|
display,
|
|
2218
|
-
starterPrompts
|
|
2219
|
+
starterPrompts,
|
|
2220
|
+
onClose,
|
|
2221
|
+
headerActions
|
|
2219
2222
|
}) {
|
|
2220
2223
|
const layout = display?.layout || "popup";
|
|
2221
2224
|
const showToggleButton = display?.showToggleButton !== false;
|
|
@@ -2297,7 +2300,9 @@ function ChatWidget({
|
|
|
2297
2300
|
{
|
|
2298
2301
|
id: conversationId,
|
|
2299
2302
|
initialMessages,
|
|
2300
|
-
config
|
|
2303
|
+
config,
|
|
2304
|
+
onClose,
|
|
2305
|
+
headerActions
|
|
2301
2306
|
}
|
|
2302
2307
|
)
|
|
2303
2308
|
}
|
|
@@ -2315,7 +2320,9 @@ function ChatWidget({
|
|
|
2315
2320
|
{
|
|
2316
2321
|
id: conversationId,
|
|
2317
2322
|
initialMessages,
|
|
2318
|
-
config
|
|
2323
|
+
config,
|
|
2324
|
+
onClose,
|
|
2325
|
+
headerActions
|
|
2319
2326
|
}
|
|
2320
2327
|
)
|
|
2321
2328
|
}
|
|
@@ -2355,7 +2362,11 @@ function ChatWidget({
|
|
|
2355
2362
|
id: conversationId,
|
|
2356
2363
|
initialMessages,
|
|
2357
2364
|
config,
|
|
2358
|
-
onClose: () =>
|
|
2365
|
+
onClose: () => {
|
|
2366
|
+
setIsOpen(false);
|
|
2367
|
+
onClose?.();
|
|
2368
|
+
},
|
|
2369
|
+
headerActions
|
|
2359
2370
|
}
|
|
2360
2371
|
) })
|
|
2361
2372
|
]
|