@mordn/chat-widget 0.1.0 → 0.1.3
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/README.md +260 -103
- package/dist/api/index.d.mts +2 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +2 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +2 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/cli/init.js +430 -0
- package/dist/db/index.d.mts +4 -277
- package/dist/db/index.d.ts +4 -277
- package/dist/db/index.js +2 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +2 -1
- package/dist/db/index.mjs.map +1 -1
- package/dist/index-uiN6exzS.d.mts +278 -0
- package/dist/index-uiN6exzS.d.ts +278 -0
- package/dist/index.d.mts +64 -5
- package/dist/index.d.ts +64 -5
- package/dist/index.js +311 -236
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -186
- package/dist/index.mjs.map +1 -1
- package/dist/schema/index.d.mts +2 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +63 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/index.mjs +35 -0
- package/dist/schema/index.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +14 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
2
|
import * as React from 'react';
|
|
3
|
+
import { ReactNode, HTMLAttributes } from 'react';
|
|
4
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
5
|
import { VariantProps } from 'class-variance-authority';
|
|
5
6
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
6
7
|
|
|
@@ -51,6 +52,21 @@ interface ChatWidgetConfig {
|
|
|
51
52
|
* Initial messages (if starting with pre-filled messages)
|
|
52
53
|
*/
|
|
53
54
|
initialMessages?: any[];
|
|
55
|
+
/**
|
|
56
|
+
* Starter prompts shown when chat is empty
|
|
57
|
+
* Users can click these to quickly start a conversation
|
|
58
|
+
*/
|
|
59
|
+
starterPrompts?: StarterPrompt[];
|
|
60
|
+
}
|
|
61
|
+
interface StarterPrompt {
|
|
62
|
+
/**
|
|
63
|
+
* The main text of the prompt (also used as the message when clicked)
|
|
64
|
+
*/
|
|
65
|
+
title: string;
|
|
66
|
+
/**
|
|
67
|
+
* Optional subtitle for additional context
|
|
68
|
+
*/
|
|
69
|
+
subtitle?: string;
|
|
54
70
|
}
|
|
55
71
|
interface ThemeConfig {
|
|
56
72
|
/**
|
|
@@ -80,12 +96,36 @@ interface FeatureConfig {
|
|
|
80
96
|
*/
|
|
81
97
|
webSearch?: boolean;
|
|
82
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Size presets for the chat widget
|
|
101
|
+
* Each preset uses clamp() for responsive sizing:
|
|
102
|
+
* - compact: clamp(300px, 24vw, 400px) - sidebars, minimal footprint
|
|
103
|
+
* - default: clamp(320px, 28vw, 500px) - balanced for most use cases
|
|
104
|
+
* - large: clamp(400px, 35vw, 700px) - content-heavy conversations
|
|
105
|
+
* - full: 100% - fills entire screen
|
|
106
|
+
*/
|
|
107
|
+
type ChatWidgetSize = 'compact' | 'default' | 'large' | 'full';
|
|
83
108
|
interface DisplayConfig {
|
|
84
109
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
110
|
+
* Preset size for the widget (recommended)
|
|
111
|
+
* Uses clamp() for responsive sizing with min/max bounds
|
|
112
|
+
* Default: 'default'
|
|
113
|
+
*/
|
|
114
|
+
size?: ChatWidgetSize;
|
|
115
|
+
/**
|
|
116
|
+
* Custom width override (any CSS value)
|
|
117
|
+
* Examples:
|
|
118
|
+
* - '400px' (fixed)
|
|
119
|
+
* - '30vw' (viewport-relative)
|
|
120
|
+
* - 'clamp(300px, 25vw, 500px)' (responsive with bounds)
|
|
121
|
+
* Overrides the size preset if provided
|
|
87
122
|
*/
|
|
88
123
|
width?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Enable drag-to-resize functionality
|
|
126
|
+
* Default: true
|
|
127
|
+
*/
|
|
128
|
+
resizable?: boolean;
|
|
89
129
|
/**
|
|
90
130
|
* Initial state (open or closed)
|
|
91
131
|
* Default: false
|
|
@@ -115,7 +155,7 @@ interface ChatWidgetProps extends ChatWidgetConfig {
|
|
|
115
155
|
*/
|
|
116
156
|
widgetId?: string;
|
|
117
157
|
}
|
|
118
|
-
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
158
|
+
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, starterPrompts, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
119
159
|
|
|
120
160
|
interface ChatTheme {
|
|
121
161
|
lightPrimary: string;
|
|
@@ -164,6 +204,15 @@ declare function useChatTheme(): {
|
|
|
164
204
|
updateThemeMode: (mode: ThemeMode) => void;
|
|
165
205
|
};
|
|
166
206
|
|
|
207
|
+
interface ChatStorageContextValue {
|
|
208
|
+
storageKeyPrefix: string;
|
|
209
|
+
}
|
|
210
|
+
declare function ChatStorageProvider({ children, userId, }: {
|
|
211
|
+
children: ReactNode;
|
|
212
|
+
userId?: string;
|
|
213
|
+
}): react_jsx_runtime.JSX.Element;
|
|
214
|
+
declare function useChatStorageKey(): ChatStorageContextValue;
|
|
215
|
+
|
|
167
216
|
declare const buttonVariants: (props?: ({
|
|
168
217
|
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
169
218
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
@@ -184,4 +233,14 @@ declare function DialogHeader({ className, ...props }: React.ComponentProps<"div
|
|
|
184
233
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
185
234
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
186
235
|
|
|
187
|
-
|
|
236
|
+
type StarterMessagesProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
|
|
237
|
+
prompts: StarterPrompt[];
|
|
238
|
+
onPromptSelect: (prompt: StarterPrompt) => void;
|
|
239
|
+
};
|
|
240
|
+
declare function StarterMessages({ className, prompts, onPromptSelect, ...props }: StarterMessagesProps): react_jsx_runtime.JSX.Element | null;
|
|
241
|
+
type StarterMessageItemProps = HTMLAttributes<HTMLButtonElement> & {
|
|
242
|
+
prompt: StarterPrompt;
|
|
243
|
+
};
|
|
244
|
+
declare function StarterMessageItem({ className, prompt, onClick, ...props }: StarterMessageItemProps): react_jsx_runtime.JSX.Element;
|
|
245
|
+
|
|
246
|
+
export { Button, ChatStorageProvider, type ChatTheme, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type ChatWidgetSize, type ConversationStarter, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, type DisplayConfig, type FeatureConfig, Input, StarterMessageItem, StarterMessages, type StarterPrompt, type ThemeConfig, type ThemeMode, ChatWidget as default, fontOptions, useChatStorageKey, useChatTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
2
|
import * as React from 'react';
|
|
3
|
+
import { ReactNode, HTMLAttributes } from 'react';
|
|
4
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
5
|
import { VariantProps } from 'class-variance-authority';
|
|
5
6
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
6
7
|
|
|
@@ -51,6 +52,21 @@ interface ChatWidgetConfig {
|
|
|
51
52
|
* Initial messages (if starting with pre-filled messages)
|
|
52
53
|
*/
|
|
53
54
|
initialMessages?: any[];
|
|
55
|
+
/**
|
|
56
|
+
* Starter prompts shown when chat is empty
|
|
57
|
+
* Users can click these to quickly start a conversation
|
|
58
|
+
*/
|
|
59
|
+
starterPrompts?: StarterPrompt[];
|
|
60
|
+
}
|
|
61
|
+
interface StarterPrompt {
|
|
62
|
+
/**
|
|
63
|
+
* The main text of the prompt (also used as the message when clicked)
|
|
64
|
+
*/
|
|
65
|
+
title: string;
|
|
66
|
+
/**
|
|
67
|
+
* Optional subtitle for additional context
|
|
68
|
+
*/
|
|
69
|
+
subtitle?: string;
|
|
54
70
|
}
|
|
55
71
|
interface ThemeConfig {
|
|
56
72
|
/**
|
|
@@ -80,12 +96,36 @@ interface FeatureConfig {
|
|
|
80
96
|
*/
|
|
81
97
|
webSearch?: boolean;
|
|
82
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Size presets for the chat widget
|
|
101
|
+
* Each preset uses clamp() for responsive sizing:
|
|
102
|
+
* - compact: clamp(300px, 24vw, 400px) - sidebars, minimal footprint
|
|
103
|
+
* - default: clamp(320px, 28vw, 500px) - balanced for most use cases
|
|
104
|
+
* - large: clamp(400px, 35vw, 700px) - content-heavy conversations
|
|
105
|
+
* - full: 100% - fills entire screen
|
|
106
|
+
*/
|
|
107
|
+
type ChatWidgetSize = 'compact' | 'default' | 'large' | 'full';
|
|
83
108
|
interface DisplayConfig {
|
|
84
109
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
110
|
+
* Preset size for the widget (recommended)
|
|
111
|
+
* Uses clamp() for responsive sizing with min/max bounds
|
|
112
|
+
* Default: 'default'
|
|
113
|
+
*/
|
|
114
|
+
size?: ChatWidgetSize;
|
|
115
|
+
/**
|
|
116
|
+
* Custom width override (any CSS value)
|
|
117
|
+
* Examples:
|
|
118
|
+
* - '400px' (fixed)
|
|
119
|
+
* - '30vw' (viewport-relative)
|
|
120
|
+
* - 'clamp(300px, 25vw, 500px)' (responsive with bounds)
|
|
121
|
+
* Overrides the size preset if provided
|
|
87
122
|
*/
|
|
88
123
|
width?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Enable drag-to-resize functionality
|
|
126
|
+
* Default: true
|
|
127
|
+
*/
|
|
128
|
+
resizable?: boolean;
|
|
89
129
|
/**
|
|
90
130
|
* Initial state (open or closed)
|
|
91
131
|
* Default: false
|
|
@@ -115,7 +155,7 @@ interface ChatWidgetProps extends ChatWidgetConfig {
|
|
|
115
155
|
*/
|
|
116
156
|
widgetId?: string;
|
|
117
157
|
}
|
|
118
|
-
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
158
|
+
declare function ChatWidget({ userId, conversationId, initialMessages, className, model, systemPrompt, temperature, theme, features, display, starterPrompts, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
119
159
|
|
|
120
160
|
interface ChatTheme {
|
|
121
161
|
lightPrimary: string;
|
|
@@ -164,6 +204,15 @@ declare function useChatTheme(): {
|
|
|
164
204
|
updateThemeMode: (mode: ThemeMode) => void;
|
|
165
205
|
};
|
|
166
206
|
|
|
207
|
+
interface ChatStorageContextValue {
|
|
208
|
+
storageKeyPrefix: string;
|
|
209
|
+
}
|
|
210
|
+
declare function ChatStorageProvider({ children, userId, }: {
|
|
211
|
+
children: ReactNode;
|
|
212
|
+
userId?: string;
|
|
213
|
+
}): react_jsx_runtime.JSX.Element;
|
|
214
|
+
declare function useChatStorageKey(): ChatStorageContextValue;
|
|
215
|
+
|
|
167
216
|
declare const buttonVariants: (props?: ({
|
|
168
217
|
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
169
218
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
@@ -184,4 +233,14 @@ declare function DialogHeader({ className, ...props }: React.ComponentProps<"div
|
|
|
184
233
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
185
234
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
186
235
|
|
|
187
|
-
|
|
236
|
+
type StarterMessagesProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
|
|
237
|
+
prompts: StarterPrompt[];
|
|
238
|
+
onPromptSelect: (prompt: StarterPrompt) => void;
|
|
239
|
+
};
|
|
240
|
+
declare function StarterMessages({ className, prompts, onPromptSelect, ...props }: StarterMessagesProps): react_jsx_runtime.JSX.Element | null;
|
|
241
|
+
type StarterMessageItemProps = HTMLAttributes<HTMLButtonElement> & {
|
|
242
|
+
prompt: StarterPrompt;
|
|
243
|
+
};
|
|
244
|
+
declare function StarterMessageItem({ className, prompt, onClick, ...props }: StarterMessageItemProps): react_jsx_runtime.JSX.Element;
|
|
245
|
+
|
|
246
|
+
export { Button, ChatStorageProvider, type ChatTheme, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type ChatWidgetSize, type ConversationStarter, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, type DisplayConfig, type FeatureConfig, Input, StarterMessageItem, StarterMessages, type StarterPrompt, type ThemeConfig, type ThemeMode, ChatWidget as default, fontOptions, useChatStorageKey, useChatTheme };
|