@monology-io/chat-widget 1.0.2

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.
Files changed (32) hide show
  1. package/README.md +241 -0
  2. package/dist/index.esm.js +15 -0
  3. package/dist/index.esm.js.map +1 -0
  4. package/dist/index.js +15 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/types/App.test.d.ts +1 -0
  7. package/dist/types/components/Chat.d.ts +17 -0
  8. package/dist/types/components/ChatContainer.d.ts +6 -0
  9. package/dist/types/components/ChatSuggestions.d.ts +14 -0
  10. package/dist/types/components/ColorSelector.d.ts +7 -0
  11. package/dist/types/components/ConversationTitleBadge.d.ts +5 -0
  12. package/dist/types/components/ConversationsHistory.d.ts +7 -0
  13. package/dist/types/components/CustomIcons.d.ts +74 -0
  14. package/dist/types/components/FormRenderer.d.ts +54 -0
  15. package/dist/types/components/Header.d.ts +13 -0
  16. package/dist/types/components/MarkdownRenderer.d.ts +5 -0
  17. package/dist/types/components/MessageLoader.d.ts +2 -0
  18. package/dist/types/components/RenderWidget.d.ts +15 -0
  19. package/dist/types/components/Sidebar.d.ts +4 -0
  20. package/dist/types/components/StatusPopup.d.ts +14 -0
  21. package/dist/types/components/ThemeContext.d.ts +10 -0
  22. package/dist/types/components/ThemeToggle.d.ts +5 -0
  23. package/dist/types/components/UserVerificationPopup.d.ts +23 -0
  24. package/dist/types/components/Widget.d.ts +15 -0
  25. package/dist/types/components/axios.d.ts +3 -0
  26. package/dist/types/components/conversation.service.d.ts +7 -0
  27. package/dist/types/components/reportWebVitals.d.ts +2 -0
  28. package/dist/types/components/setupTests.d.ts +1 -0
  29. package/dist/types/components/token.service.d.ts +2 -0
  30. package/dist/types/components/types.d.ts +4 -0
  31. package/dist/types/index.d.ts +3 -0
  32. package/package.json +60 -0
package/README.md ADDED
@@ -0,0 +1,241 @@
1
+ # @monology-io/chat-widget
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@monology-io/chat-widget.svg)](https://www.npmjs.com/package/@monology-io/chat-widget)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Official React/Next.js package for embedding the [Monology](https://monology.io) chat widget into your application. Build intelligent, conversational experiences with ease.
7
+
8
+ ## 🚀 Features
9
+
10
+ - ✅ **React & Next.js Support** - Works seamlessly with both React and Next.js applications
11
+ - ✅ **TypeScript Ready** - Full TypeScript support with type definitions included
12
+ - ✅ **User Identity Tracking** - Pass authenticated user data for personalized experiences
13
+ - ✅ **Customizable** - Control widget behavior, appearance, and interactions
14
+ - ✅ **Lightweight** - Optimized bundle size with minimal dependencies
15
+ - ✅ **SSR Compatible** - Works with Next.js App Router and Pages Router
16
+
17
+ ## 📦 Installation
18
+
19
+ ```bash
20
+ npm install @monology-io/chat-widget
21
+ ```
22
+
23
+ Or using yarn:
24
+
25
+ ```bash
26
+ yarn add @monology-io/chat-widget
27
+ ```
28
+
29
+ Or using pnpm:
30
+
31
+ ```bash
32
+ pnpm add @monology-io/chat-widget
33
+ ```
34
+
35
+ ## 🎯 Quick Start
36
+
37
+ ### Basic React Usage
38
+
39
+ ```jsx
40
+ import { RenderWidget } from "@monology-io/chat-widget";
41
+
42
+ export default function App() {
43
+ return (
44
+ <div className="App">
45
+ <RenderWidget urlId="your-widget-url-id" identity={null} />
46
+ </div>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### Next.js App Router (Recommended)
52
+
53
+ For Next.js 13+ with App Router, use dynamic import with SSR disabled:
54
+
55
+ ```jsx
56
+ "use client";
57
+ import dynamic from "next/dynamic";
58
+
59
+ const RenderWidget = dynamic(
60
+ () => import("@monology-io/chat-widget").then((mod) => mod.RenderWidget),
61
+ { ssr: false },
62
+ );
63
+
64
+ export default function App() {
65
+ return (
66
+ <div className="App">
67
+ <RenderWidget urlId="your-widget-url-id" identity={null} />
68
+ </div>
69
+ );
70
+ }
71
+ ```
72
+
73
+ ### Next.js Pages Router
74
+
75
+ ```jsx
76
+ import { RenderWidget } from "@monology-io/chat-widget";
77
+
78
+ export default function Home() {
79
+ return (
80
+ <div>
81
+ <h1>My App</h1>
82
+ <RenderWidget urlId="your-widget-url-id" identity={null} />
83
+ </div>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ## 📖 Usage Examples
89
+
90
+ ### With User Identity
91
+
92
+ Pass authenticated user information for personalized conversations and tracking:
93
+
94
+ ```jsx
95
+ import { RenderWidget } from "@monology-io/chat-widget";
96
+
97
+ export default function App() {
98
+ return (
99
+ <div className="App">
100
+ <RenderWidget
101
+ urlId="your-widget-url-id"
102
+ identity={{
103
+ id: "user-123",
104
+ firstName: "John",
105
+ lastName: "Doe",
106
+ email: "john.doe@example.com",
107
+ phone: "1234567890",
108
+ company: {
109
+ id: "company-456",
110
+ name: "Acme Inc",
111
+ },
112
+ }}
113
+ />
114
+ </div>
115
+ );
116
+ }
117
+ ```
118
+
119
+ ### Manual Control (Custom Trigger Button)
120
+
121
+ Control when the widget opens and closes with your own UI:
122
+
123
+ ```jsx
124
+ import { RenderWidget } from "@monology-io/chat-widget";
125
+ import { useState } from "react";
126
+
127
+ export default function App() {
128
+ const [isWidgetOpen, setIsWidgetOpen] = useState(false);
129
+
130
+ return (
131
+ <div className="App">
132
+ <button onClick={() => setIsWidgetOpen(true)}>Open Chat Support</button>
133
+
134
+ {isWidgetOpen && (
135
+ <RenderWidget
136
+ urlId="your-widget-url-id"
137
+ onClose={() => setIsWidgetOpen(false)}
138
+ hideLauncherButton={true}
139
+ identity={null}
140
+ />
141
+ )}
142
+ </div>
143
+ );
144
+ }
145
+ ```
146
+
147
+ ### TypeScript Example
148
+
149
+ ```tsx
150
+ import { RenderWidget } from "@monology-io/chat-widget";
151
+ import type { Identity } from "@monology-io/chat-widget";
152
+
153
+ interface Props {
154
+ user: Identity | null;
155
+ }
156
+
157
+ export default function ChatWidget({ user }: Props) {
158
+ return <RenderWidget urlId="your-widget-url-id" identity={user} />;
159
+ }
160
+ ```
161
+
162
+ ## 🔧 API Reference
163
+
164
+ ### `<RenderWidget />` Props
165
+
166
+ | Prop | Type | Required | Default | Description |
167
+ | -------------------- | ------------------ | -------- | ------- | ---------------------------------------------- |
168
+ | `urlId` | `string` | ✅ Yes | - | Your widget URL ID from the Monology dashboard |
169
+ | `identity` | `Identity \| null` | ❌ No | `null` | User identity object for authenticated users |
170
+ | `hideLauncherButton` | `boolean` | ❌ No | `false` | Hide the default launcher button |
171
+ | `onClose` | `() => void` | ❌ No | - | Callback function when widget is closed |
172
+
173
+ ### `Identity` Object
174
+
175
+ ```typescript
176
+ interface Identity {
177
+ id: string; // Unique user identifier
178
+ firstName?: string; // User's first name
179
+ lastName?: string; // User's last name
180
+ email?: string; // User's email address
181
+ phone?: string; // User's phone number
182
+ company?: {
183
+ id: string; // Company identifier
184
+ name: string; // Company name
185
+ };
186
+ }
187
+ ```
188
+
189
+ ## ⚠️ Important CSS Warning
190
+
191
+ **The host site should NOT have CSS directly applied to semantic HTML elements** like `p`, `a`, `ul`, `li`, `h1-h6`, etc.
192
+
193
+ ### Why?
194
+
195
+ Global CSS rules on these elements will conflict with the widget's internal styles and disturb its appearance.
196
+
197
+ ### Solution
198
+
199
+ Use CSS classes or scoped styles instead of element selectors. For example:
200
+
201
+ - ❌ Bad: `p { margin: 0; }`
202
+ - ✅ Good: `.my-paragraph { margin: 0; }`
203
+
204
+ ## 🌟 Best Practices
205
+
206
+ 1. **Load Asynchronously** - Use dynamic imports in Next.js to avoid blocking initial page load
207
+ 2. **Pass User Data When Available** - If users are logged in, pass their identity to enable tracking and skip verification
208
+ 3. **Test on Staging First** - Verify the widget works correctly before deploying to production
209
+ 4. **Handle Errors Gracefully** - Wrap the widget in error boundaries for production apps
210
+ 5. **Optimize Bundle Size** - Use tree-shaking and code splitting to minimize impact
211
+
212
+ ## 📚 Documentation
213
+
214
+ For complete documentation, visit:
215
+
216
+ - [Monology Documentation](https://app.monology.io/docs)
217
+ - [Embedding Guide](https://app.monology.io/docs/widgets/embedding)
218
+ - [Widget Configuration](https://app.monology.io/docs/widgets)
219
+
220
+ ## 🔗 Links
221
+
222
+ - [Website](https://monology.io)
223
+ - [Dashboard](https://app.monology.io)
224
+ - [Documentation](https://app.monology.io/docs)
225
+ - [npm Package](https://www.npmjs.com/package/@monology-io/chat-widget)
226
+
227
+ ## 🆘 Support
228
+
229
+ Need help? We're here for you:
230
+
231
+ - 📧 Email: [contact@monology.io](mailto:contact@monology.io)
232
+ - 💬 Chat: [monology.io](https://monology.io) (use our own widget!)
233
+ - 📖 Docs: [app.monology.io/docs](https://app.monology.io/docs)
234
+
235
+ ## 📝 License
236
+
237
+ MIT © [Monology](https://monology.io)
238
+
239
+ ---
240
+
241
+ Made with ❤️ by the [Monology](https://monology.io) team