@convokit/widget 0.0.1 → 0.0.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 +226 -42
- package/dist/DemoErrorBoundary.d.ts +17 -0
- package/dist/DemoErrorBoundary.d.ts.map +1 -0
- package/dist/FullScreenBackendWidget.d.ts +36 -0
- package/dist/FullScreenBackendWidget.d.ts.map +1 -0
- package/dist/FullScreenWidget.d.ts +34 -0
- package/dist/FullScreenWidget.d.ts.map +1 -0
- package/dist/PopupBackendWidget.d.ts +35 -0
- package/dist/PopupBackendWidget.d.ts.map +1 -0
- package/dist/PopupWidget-CGZOe6ZA.js +5815 -0
- package/dist/PopupWidget.d.ts +33 -0
- package/dist/PopupWidget.d.ts.map +1 -0
- package/dist/components/ChatPopup.d.ts +10 -0
- package/dist/components/ChatPopup.d.ts.map +1 -0
- package/dist/components/ChatPopupConnect.d.ts +10 -0
- package/dist/components/ChatPopupConnect.d.ts.map +1 -0
- package/dist/components/ChatPopupEmbed.d.ts +10 -0
- package/dist/components/ChatPopupEmbed.d.ts.map +1 -0
- package/dist/components/ChatWidget.d.ts +1 -5
- package/dist/components/ChatWidget.d.ts.map +1 -1
- package/dist/components/FullScreenChat.d.ts +12 -0
- package/dist/components/FullScreenChat.d.ts.map +1 -0
- package/dist/components/FullScreenChatConnect.d.ts +12 -0
- package/dist/components/FullScreenChatConnect.d.ts.map +1 -0
- package/dist/components/FullScreenChatEmbed.d.ts +12 -0
- package/dist/components/FullScreenChatEmbed.d.ts.map +1 -0
- package/dist/demo.d.ts +1 -1
- package/dist/demo.d.ts.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +588 -695
- package/dist/next.d.ts +24 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.esm.js +17 -0
- package/dist/types/index.d.ts +125 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/api.d.ts +29 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/dist/utils/markdown.d.ts +3 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/package.json +32 -6
- package/dist/index.umd.js +0 -30
- package/dist/style.css +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
# @convokit/widget
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Chat UI widgets for your website. The public API is intentionally small — **four drop‑in components**:
|
|
4
|
+
|
|
5
|
+
| Component | Layout | Integration | You provide |
|
|
6
|
+
|-----------|--------|--------------|-------------|
|
|
7
|
+
| **PopupWidget** | Bubble (corner) | ConvoKit | `apiKey` (public ConvoKit key) |
|
|
8
|
+
| **FullScreenWidget** | Full page | ConvoKit | `apiKey`, optional `onBack` |
|
|
9
|
+
| **PopupBackendWidget** | Bubble | Your backend | `apiUrl`, `apiKey`, optional `authToken` |
|
|
10
|
+
| **FullScreenBackendWidget** | Full page | Your backend | `apiUrl`, `apiKey`, optional `authToken`, `onBack` |
|
|
11
|
+
|
|
12
|
+
All lower‑level/internal components (`PopupKey`, `FullScreenKey`, `PopupBackend`, `PopupControlled`, etc.) are **not exported** from the package anymore. The four widgets above are what you use in apps.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## What to call and how
|
|
17
|
+
|
|
18
|
+
Use **one import** and **one component** per screen. All of these are from `@convokit/widget`. No separate CSS import needed (styles are in the bundle).
|
|
19
|
+
|
|
20
|
+
| What to call | How (minimal) |
|
|
21
|
+
|--------------|----------------|
|
|
22
|
+
| **PopupWidget** | `<PopupWidget apiKey={key} />` — popup bubble, ConvoKit key. |
|
|
23
|
+
| **FullScreenWidget** | `<FullScreenWidget apiKey={key} onBack={() => router.back()} />` — full-page chat, ConvoKit key. |
|
|
24
|
+
| **PopupBackendWidget** | `<PopupBackendWidget apiUrl="/api/chat" apiKey={myKey} />` — popup, your backend. |
|
|
25
|
+
| **FullScreenBackendWidget** | `<FullScreenBackendWidget apiUrl="/api/chat" apiKey={myKey} onBack={() => router.back()} />` — full-page, your backend. |
|
|
26
|
+
|
|
27
|
+
**Optional props (all wrappers):** `title`, `welcomeMessage`, `widgetId`, `primaryColor`. Popup ones also accept `position`. Backend ones accept `authToken`. Full-screen ones accept `backLabel`. PopupWidget / FullScreenWidget also accept `persistMessages`.
|
|
28
|
+
|
|
29
|
+
**If you need full control** (your own state/API), use the low-level components with a config object:
|
|
30
|
+
|
|
31
|
+
| What to call | How |
|
|
32
|
+
|--------------|-----|
|
|
33
|
+
| **PopupKey** | `<PopupKey config={keyConfig} />` — config: `KeyConfig` (e.g. `{ key, title, position }`). |
|
|
34
|
+
| **FullScreenKey** | `<FullScreenKey config={keyConfig} onBack={fn} backLabel="Back" />` |
|
|
35
|
+
| **PopupBackend** | `<PopupBackend config={backendConfig} />` — config: `BackendConfig` (e.g. `{ apiUrl, apiKey }`). |
|
|
36
|
+
| **FullScreenBackend** | `<FullScreenBackend config={backendConfig} onBack={fn} backLabel="Back" />` |
|
|
37
|
+
| **PopupControlled** | `<PopupControlled config={controlledConfig} />` — you pass `messages`, `onMessagesUpdate`, `onSend`. |
|
|
38
|
+
| **FullScreenControlled** | `<FullScreenControlled config={controlledConfig} onBack={fn} backLabel="Back" />` |
|
|
39
|
+
|
|
40
|
+
**Types you can import:** `KeyConfig`, `BackendConfig`, `ControlledConfig`, `PopupWidgetProps`, `FullScreenWidgetProps`, `PopupBackendWidgetProps`, `FullScreenBackendWidgetProps`, `ChatMessage`, `ChatHistoryItem`, `ChatResponse`, `ThemeOptions`.
|
|
41
|
+
|
|
42
|
+
---
|
|
4
43
|
|
|
5
44
|
## Installation
|
|
6
45
|
|
|
@@ -12,52 +51,207 @@ yarn add @convokit/widget
|
|
|
12
51
|
pnpm add @convokit/widget
|
|
13
52
|
```
|
|
14
53
|
|
|
15
|
-
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Quick start (React / Vite)
|
|
57
|
+
|
|
58
|
+
Add the chat bubble with one import. Styles are included in the bundle.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// Any React entry (e.g. App.tsx)
|
|
62
|
+
import { PopupWidget } from '@convokit/widget';
|
|
63
|
+
|
|
64
|
+
export function App() {
|
|
65
|
+
return (
|
|
66
|
+
<div>
|
|
67
|
+
{/* Your app UI */}
|
|
68
|
+
<PopupWidget apiKey={import.meta.env.VITE_CONVOKIT_KEY ?? ''} />
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- **React (CRA / Vite / plain SPA)**: just import and render the widget anywhere in your tree.
|
|
75
|
+
- Optional props (all wrappers): `title`, `welcomeMessage`, `widgetId`, `primaryColor`.
|
|
76
|
+
- Popup widgets also accept `position`, `persistMessages`. Backend widgets accept `authToken`. Full‑screen widgets accept `onBack` and `backLabel`.
|
|
77
|
+
|
|
78
|
+
If the required props are missing (`apiKey` for key‑based widgets, or `apiUrl`/`apiKey` for backend widgets), the widget renders nothing.
|
|
79
|
+
|
|
80
|
+
### Next.js only: one import, no wrapper (recommended)
|
|
81
|
+
|
|
82
|
+
If you use **Next.js App Router**, use the Next-specific entry so you don’t write `dynamic()` or a wrapper yourself:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
// app/layout.tsx (or any page)
|
|
86
|
+
import { PopupWidgetNext } from '@convokit/widget/next';
|
|
87
|
+
|
|
88
|
+
export default function Layout({ children }) {
|
|
89
|
+
return (
|
|
90
|
+
<html><body>
|
|
91
|
+
{children}
|
|
92
|
+
<PopupWidgetNext />
|
|
93
|
+
</body></html>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- **`PopupWidgetNext`** uses `next/dynamic` with `ssr: false` and reads `process.env.NEXT_PUBLIC_CONVOKIT_KEY` if you don’t pass `apiKey`.
|
|
99
|
+
- Optional: pass `apiKey`, `title`, `welcomeMessage`, `position`, etc. as props.
|
|
100
|
+
- You still need **transpilePackages** (and optionally resolve alias for react) in `next.config.js` if you see duplicate-React errors; see “Next.js App Router (avoid duplicate React)” below.
|
|
101
|
+
|
|
102
|
+
### Next.js App Router (avoid duplicate React)
|
|
16
103
|
|
|
17
|
-
|
|
104
|
+
The widget is client-only (hooks, DOM). In Next.js you must use **one React instance** in the browser. If the widget resolves to a different copy of React than your app, you get errors like `Cannot read properties of undefined (reading 'ReactCurrentDispatcher')`.
|
|
105
|
+
|
|
106
|
+
**Fix 1 — Load the widget only on the client (recommended):** use `next/dynamic` with `ssr: false` so the widget never runs on the server and always uses the client React.
|
|
18
107
|
|
|
19
108
|
```tsx
|
|
20
|
-
|
|
109
|
+
// app/layout.tsx or a client component
|
|
110
|
+
'use client';
|
|
111
|
+
|
|
112
|
+
import dynamic from 'next/dynamic';
|
|
21
113
|
|
|
22
|
-
|
|
114
|
+
const PopupWidget = dynamic(
|
|
115
|
+
() => import('@convokit/widget').then((mod) => mod.PopupWidget),
|
|
116
|
+
{ ssr: false }
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
export default function Layout({ children }) {
|
|
23
120
|
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
121
|
+
<>
|
|
122
|
+
{children}
|
|
123
|
+
<PopupWidget apiKey={process.env.NEXT_PUBLIC_CONVOKIT_KEY ?? ''} />
|
|
124
|
+
</>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Fix 2 — Use the app’s React for the widget:** in `next.config.js`, add `transpilePackages` and (if needed with pnpm) resolve `react` / `react-dom` to a single copy so the widget is bundled with your app’s React.
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
// next.config.js
|
|
133
|
+
/** @type {import('next').NextConfig} */
|
|
134
|
+
const nextConfig = {
|
|
135
|
+
transpilePackages: ['@convokit/widget'],
|
|
136
|
+
webpack: (config) => {
|
|
137
|
+
config.resolve.alias = {
|
|
138
|
+
...config.resolve.alias,
|
|
139
|
+
react: require.resolve('react'),
|
|
140
|
+
'react-dom': require.resolve('react-dom'),
|
|
141
|
+
};
|
|
142
|
+
return config;
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
module.exports = nextConfig;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use **Fix 1** for a quick fix; use **Fix 1 + Fix 2** if you still see duplicate-React issues (e.g. with pnpm).
|
|
149
|
+
|
|
150
|
+
### Other drop-in wrappers (all four)
|
|
151
|
+
|
|
152
|
+
| Wrapper | Use case | Required props |
|
|
153
|
+
|---------|----------|-----------------|
|
|
154
|
+
| **PopupWidget** | Popup with ConvoKit key | `apiKey` |
|
|
155
|
+
| **FullScreenWidget** | Full-page chat with ConvoKit key | `apiKey`, `onBack` (e.g. `() => router.back()`) |
|
|
156
|
+
| **PopupBackendWidget** | Popup talking to your backend | `apiUrl`, `apiKey` |
|
|
157
|
+
| **FullScreenBackendWidget** | Full-page chat talking to your backend | `apiUrl`, `apiKey`, `onBack` |
|
|
158
|
+
|
|
159
|
+
#### React / Vite examples
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
// Full-screen (Key mode)
|
|
163
|
+
import { FullScreenWidget } from '@convokit/widget';
|
|
164
|
+
|
|
165
|
+
export function ChatPage() {
|
|
166
|
+
const apiKey = import.meta.env.VITE_CONVOKIT_KEY ?? '';
|
|
167
|
+
return (
|
|
168
|
+
<FullScreenWidget
|
|
169
|
+
apiKey={apiKey}
|
|
170
|
+
onBack={() => {
|
|
171
|
+
// e.g. navigate(-1) with react-router
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Popup (your backend)
|
|
178
|
+
import { PopupBackendWidget } from '@convokit/widget';
|
|
179
|
+
|
|
180
|
+
export function App() {
|
|
181
|
+
return (
|
|
182
|
+
<>
|
|
183
|
+
{/* your UI */}
|
|
184
|
+
<PopupBackendWidget apiUrl="/api/chat" apiKey={import.meta.env.VITE_BACKEND_KEY ?? ''} />
|
|
185
|
+
</>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Full-screen (your backend)
|
|
190
|
+
import { FullScreenBackendWidget } from '@convokit/widget';
|
|
191
|
+
|
|
192
|
+
export function Support() {
|
|
193
|
+
return (
|
|
194
|
+
<FullScreenBackendWidget
|
|
195
|
+
apiUrl="/api/chat"
|
|
196
|
+
apiKey={import.meta.env.VITE_BACKEND_KEY ?? ''}
|
|
197
|
+
onBack={() => {
|
|
198
|
+
// go back / close
|
|
32
199
|
}}
|
|
33
200
|
/>
|
|
34
201
|
);
|
|
35
202
|
}
|
|
36
203
|
```
|
|
37
204
|
|
|
38
|
-
|
|
205
|
+
#### Next.js (App Router) examples
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
'use client';
|
|
209
|
+
|
|
210
|
+
import dynamic from 'next/dynamic';
|
|
39
211
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
212
|
+
// Popup with ConvoKit key
|
|
213
|
+
const PopupWidget = dynamic(
|
|
214
|
+
() => import('@convokit/widget').then((m) => m.PopupWidget),
|
|
215
|
+
{ ssr: false }
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
// Full-screen (Key mode)
|
|
219
|
+
const FullScreenWidget = dynamic(
|
|
220
|
+
() => import('@convokit/widget').then((m) => m.FullScreenWidget),
|
|
221
|
+
{ ssr: false }
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
225
|
+
const apiKey = process.env.NEXT_PUBLIC_CONVOKIT_KEY ?? '';
|
|
226
|
+
return (
|
|
227
|
+
<html>
|
|
228
|
+
<body>
|
|
229
|
+
{children}
|
|
230
|
+
<PopupWidget apiKey={apiKey} />
|
|
231
|
+
</body>
|
|
232
|
+
</html>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Full-screen page (Key mode)
|
|
237
|
+
export function FullScreenChatPage() {
|
|
238
|
+
const apiKey = process.env.NEXT_PUBLIC_CONVOKIT_KEY ?? '';
|
|
239
|
+
const router = useRouter();
|
|
240
|
+
return (
|
|
241
|
+
<FullScreenWidget apiKey={apiKey} onBack={() => router.back()} />
|
|
242
|
+
);
|
|
243
|
+
}
|
|
48
244
|
```
|
|
49
245
|
|
|
50
|
-
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
---
|
|
51
249
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
| `title` | string | No | `Chat` | Widget header title |
|
|
58
|
-
| `welcomeMessage` | string | No | `Hello! How can I help you?` | Initial greeting message |
|
|
59
|
-
| `placeholder` | string | No | `Type a message...` | Input placeholder text |
|
|
60
|
-
| `position` | string | No | `bottom-right` | Widget position on screen |
|
|
250
|
+
## Advanced configuration
|
|
251
|
+
|
|
252
|
+
Internally, the widgets are built on config types (**KeyConfig**, **BackendConfig**, **ControlledConfig**, **ThemeOptions**). If you need to dive deeper into those (for example, to match server behavior or migrate from the old low‑level API), see `WIDGET_CONFIG_REFERENCE.md` in this repo.
|
|
253
|
+
|
|
254
|
+
---
|
|
61
255
|
|
|
62
256
|
## Development
|
|
63
257
|
|
|
@@ -77,16 +271,6 @@ npm run build
|
|
|
77
271
|
pnpm build
|
|
78
272
|
```
|
|
79
273
|
|
|
80
|
-
## Features
|
|
81
|
-
|
|
82
|
-
- 🎨 Customizable colors and branding
|
|
83
|
-
- 📱 Mobile responsive
|
|
84
|
-
- ⚡ Lightweight and fast
|
|
85
|
-
- 🎯 TypeScript support
|
|
86
|
-
- 🔌 Easy integration
|
|
87
|
-
- 💬 Real-time chat
|
|
88
|
-
- 🤖 AI-powered responses
|
|
89
|
-
|
|
90
274
|
## License
|
|
91
275
|
|
|
92
276
|
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React, Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare class DemoErrorBoundary extends Component<{
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}, {
|
|
6
|
+
error: Error | null;
|
|
7
|
+
}> {
|
|
8
|
+
state: {
|
|
9
|
+
error: Error | null;
|
|
10
|
+
};
|
|
11
|
+
static getDerivedStateFromError(error: Error): {
|
|
12
|
+
error: Error;
|
|
13
|
+
};
|
|
14
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
15
|
+
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=DemoErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DemoErrorBoundary.d.ts","sourceRoot":"","sources":["../src/DemoErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/D,qBAAa,iBAAkB,SAAQ,SAAS,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EAAE;IAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,CAAC;IAChG,KAAK;eAAoB,KAAK,GAAG,IAAI;MAAG;IAExC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;IAI5C,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAIpD,MAAM;CAcP"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal props for the full-screen widget that talks to your backend. No ConvoKit key in the browser.
|
|
5
|
+
*/
|
|
6
|
+
export interface FullScreenBackendWidgetProps {
|
|
7
|
+
/** Your backend chat endpoint URL (e.g. /api/chat). Required. */
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
/** Your API key sent to your backend (e.g. X-API-Key header). Required. */
|
|
10
|
+
apiKey: string;
|
|
11
|
+
/** Called when user taps back (e.g. router.back()). */
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
/** Label for the back button. Default: 'Back'. */
|
|
14
|
+
backLabel?: string;
|
|
15
|
+
/** Optional auth token sent as Authorization: Bearer to your backend. */
|
|
16
|
+
authToken?: string;
|
|
17
|
+
/** Unique id for this instance. Default: 'convokit-widget'. */
|
|
18
|
+
widgetId?: string;
|
|
19
|
+
/** Header title. Default: 'Chat'. */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** First message shown when chat opens. Default: 'How can I help you today?'. */
|
|
22
|
+
welcomeMessage?: string;
|
|
23
|
+
/** Primary color (e.g. '#7c3aed'). */
|
|
24
|
+
primaryColor?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Drop-in full-screen chat widget (Backend mode). Widget talks to your API; you use convokit-server on the server.
|
|
28
|
+
* Use in a client component (e.g. add 'use client' in Next.js).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* import { FullScreenBackendWidget } from '@convokit/widget';
|
|
32
|
+
*
|
|
33
|
+
* <FullScreenBackendWidget apiUrl="/api/chat" apiKey={process.env.NEXT_PUBLIC_MY_API_KEY} onBack={() => router.back()} />
|
|
34
|
+
*/
|
|
35
|
+
export declare const FullScreenBackendWidget: React.FC<FullScreenBackendWidgetProps>;
|
|
36
|
+
//# sourceMappingURL=FullScreenBackendWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FullScreenBackendWidget.d.ts","sourceRoot":"","sources":["../src/FullScreenBackendWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAsB1E,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal props for the full-screen key widget. Pass your public API key; everything else is optional.
|
|
5
|
+
*/
|
|
6
|
+
export interface FullScreenWidgetProps {
|
|
7
|
+
/** ConvoKit public API key (pk_live_... or pk_test_...). From ConvoKit dashboard. Required. */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** Called when user taps back (e.g. router.back()). */
|
|
10
|
+
onBack?: () => void;
|
|
11
|
+
/** Label for the back button. Default: 'Back'. */
|
|
12
|
+
backLabel?: string;
|
|
13
|
+
/** Unique id for this instance. Default: 'convokit-widget'. */
|
|
14
|
+
widgetId?: string;
|
|
15
|
+
/** Header title. Default: 'Support'. */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** First message shown when chat opens. Default: 'Hi! How can we help?'. */
|
|
18
|
+
welcomeMessage?: string;
|
|
19
|
+
/** Restore messages on reload. Default: false. */
|
|
20
|
+
persistMessages?: boolean;
|
|
21
|
+
/** Primary color (e.g. '#7c3aed'). */
|
|
22
|
+
primaryColor?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Drop-in full-screen chat widget (Key mode). One component, minimal props.
|
|
26
|
+
* Use in a client component (e.g. add 'use client' in Next.js).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import { FullScreenWidget } from '@convokit/widget';
|
|
30
|
+
*
|
|
31
|
+
* <FullScreenWidget apiKey={process.env.NEXT_PUBLIC_CONVOKIT_KEY} onBack={() => router.back()} />
|
|
32
|
+
*/
|
|
33
|
+
export declare const FullScreenWidget: React.FC<FullScreenWidgetProps>;
|
|
34
|
+
//# sourceMappingURL=FullScreenWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FullScreenWidget.d.ts","sourceRoot":"","sources":["../src/FullScreenWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,+FAA+F;IAC/F,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqB5D,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BackendConfig } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal props for the popup widget that talks to your backend. No ConvoKit key in the browser.
|
|
6
|
+
*/
|
|
7
|
+
export interface PopupBackendWidgetProps {
|
|
8
|
+
/** Your backend chat endpoint URL (e.g. /api/chat). Required. */
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
/** Your API key sent to your backend (e.g. X-API-Key header). Required. */
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/** Optional auth token sent as Authorization: Bearer to your backend. */
|
|
13
|
+
authToken?: string;
|
|
14
|
+
/** Unique id for this instance. Default: 'convokit-widget'. */
|
|
15
|
+
widgetId?: string;
|
|
16
|
+
/** Header title. Default: 'Chat'. */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** First message shown when chat opens. Default: 'How can I help you today?'. */
|
|
19
|
+
welcomeMessage?: string;
|
|
20
|
+
/** Position of the bubble. Default: 'bottom-right'. */
|
|
21
|
+
position?: BackendConfig['position'];
|
|
22
|
+
/** Primary color (e.g. '#7c3aed'). */
|
|
23
|
+
primaryColor?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Drop-in popup chat widget (Backend mode). Widget talks to your API; you use convokit-server on the server.
|
|
27
|
+
* Use in a client component (e.g. add 'use client' in Next.js).
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* import { PopupBackendWidget } from '@convokit/widget';
|
|
31
|
+
*
|
|
32
|
+
* <PopupBackendWidget apiUrl="/api/chat" apiKey={process.env.NEXT_PUBLIC_MY_API_KEY} />
|
|
33
|
+
*/
|
|
34
|
+
export declare const PopupBackendWidget: React.FC<PopupBackendWidgetProps>;
|
|
35
|
+
//# sourceMappingURL=PopupBackendWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopupBackendWidget.d.ts","sourceRoot":"","sources":["../src/PopupBackendWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACrC,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAQD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAiBhE,CAAC"}
|