lulichat 1.0.15 → 1.0.17

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 (44) hide show
  1. package/README.md +45 -246
  2. package/dist/lulichat-widget-standalone.es.js +2555 -2605
  3. package/dist/lulichat-widget-standalone.umd.js +31 -31
  4. package/dist/lulichat-widget.es.js +793 -843
  5. package/dist/lulichat-widget.umd.js +6 -6
  6. package/dist/style.css +1 -1
  7. package/package.json +90 -89
  8. package/dist/components/Animation.d.ts +0 -15
  9. package/dist/components/ChatWidget.d.ts +0 -7
  10. package/dist/components/LuliChat.d.ts +0 -3
  11. package/dist/components/chatroom/ChatBody.d.ts +0 -3
  12. package/dist/components/chatroom/ChatFooter.d.ts +0 -3
  13. package/dist/components/chatroom/ChatHeader.d.ts +0 -3
  14. package/dist/components/chatroom/ChatInterface.d.ts +0 -2
  15. package/dist/components/chatroom/ChatRating.d.ts +0 -7
  16. package/dist/components/chatroom/CompanyQueues.d.ts +0 -13
  17. package/dist/components/chatroom/Message.d.ts +0 -7
  18. package/dist/components/chatroom/StartChat.d.ts +0 -17
  19. package/dist/components/faq/FAQBody.d.ts +0 -3
  20. package/dist/components/faq/FAQCategories.d.ts +0 -7
  21. package/dist/components/faq/FAQInterface.d.ts +0 -5
  22. package/dist/components/faq/FAQList.d.ts +0 -8
  23. package/dist/components/faq/FAQViewer.d.ts +0 -7
  24. package/dist/components/history/HistoryInterface.d.ts +0 -5
  25. package/dist/components/history/Rate.d.ts +0 -3
  26. package/dist/components/history/TicketList.d.ts +0 -6
  27. package/dist/components/ui/AutoResizeTextArea.d.ts +0 -10
  28. package/dist/components/ui/Button.d.ts +0 -8
  29. package/dist/components/ui/Form.d.ts +0 -33
  30. package/dist/components/ui/Icons.d.ts +0 -25
  31. package/dist/components/ui/Input.d.ts +0 -9
  32. package/dist/components/ui/Tab.d.ts +0 -6
  33. package/dist/constants.d.ts +0 -33
  34. package/dist/hooks/useContext.d.ts +0 -14
  35. package/dist/hooks/useSocket.d.ts +0 -4
  36. package/dist/hooks/useStore.d.ts +0 -50
  37. package/dist/index.d.ts +0 -5
  38. package/dist/lib/embed.d.ts +0 -45
  39. package/dist/lib/socket.d.ts +0 -18
  40. package/dist/main.d.ts +0 -1
  41. package/dist/types/index.d.ts +0 -188
  42. package/dist/utils/api.d.ts +0 -120
  43. package/dist/utils/index.d.ts +0 -12
  44. package/dist/utils/renderToHTML.d.ts +0 -1
package/README.md CHANGED
@@ -1,32 +1,20 @@
1
1
  # LuliChat Support Chat
2
2
 
3
- Lulichat Support Chat is a React library that provides a chat interface for web applications. It includes a chat icon that opens a contact form for users to submit their contact information, and it establishes a socket connection for real-time chat functionality.
3
+ LuliChat Support Chat is a library that provides a real-time live support chat widget for web applications. It can be integrated into React applications or loaded directly via UMD/script tags in standard HTML pages.
4
4
 
5
- ## Features
5
+ ---
6
6
 
7
- - Chat icon positioned at the bottom right corner of the screen.
8
- - Contact information collection form with validation.
9
- - Real-time chat interface using WebSocket.
10
- - Easy integration into any React application.
7
+ ## 1. React Installation & Usage
11
8
 
12
- ## Installation
13
-
14
- To install the LuliChat Support Chat library, run the following command:
9
+ ### Installation
15
10
 
16
11
  ```bash
17
12
  npm install lulichat
18
13
  ```
19
14
 
20
- ## Usage
15
+ ### Usage
21
16
 
22
- To use the Lulichat Support Chat in your application, import the components as follows:
23
-
24
- ```tsx
25
- import LuliChat from "lulichat";
26
- import "lulichat/dist/style.css";
27
- ```
28
-
29
- ### Example
17
+ Import the component and stylesheet:
30
18
 
31
19
  ```tsx
32
20
  import React from "react";
@@ -35,49 +23,34 @@ import "lulichat/dist/style.css";
35
23
 
36
24
  const App = () => {
37
25
  return (
38
- <div>
39
- <h1>Welcome to My Application</h1>
40
- <LuliChat
41
- apiKey="LU...."
42
- companyName="LuliChat Demo"
43
- welcomeMessage="How can we help you today?"
44
- primaryColor="#4f46e5"
45
- allowAnonymous={true}
46
- requireContactInfo={true}
47
- position="bottom-right"
48
- />
49
- </div>
26
+ <LuliChat
27
+ apiKey="YOUR_API_KEY"
28
+ companyName="LuliChat Demo"
29
+ welcomeMessage="How can we help you today?"
30
+ primaryColor="#4f46e5"
31
+ allowAnonymous={true}
32
+ requireContactInfo={true}
33
+ position="bottom-right"
34
+ />
50
35
  );
51
36
  };
52
37
 
53
38
  export default App;
54
39
  ```
55
40
 
56
- ## Script tag (no React)
57
-
58
- You have two ways to embed the widget:
59
-
60
- 1. Externalized (smaller) build – you provide React, ReactDOM and socket.io-client (as globals) OR you are on a React page already.
61
- 2. Standalone (larger) build – everything bundled, just one script tag.
41
+ ---
62
42
 
63
- ### 1. Externalized build (recommended if you already use React)
43
+ ## 2. Vanilla Script Integration (No React)
64
44
 
65
- Add React, ReactDOM and socket.io-client globals if they are not already present. If you are not using the standalone bundle, also add marked and DOMPurify (or rely on our graceful fallbacks):
45
+ You can load the widget on any website using the unpkg CDN.
66
46
 
67
- ```html
68
- <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
69
- <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
70
- <script src="https://unpkg.com/socket.io-client@4/dist/socket.io.min.js"></script>
71
- <script src="https://unpkg.com/marked/marked.min.js"></script>
72
- <script src="https://unpkg.com/dompurify/dist/purify.min.js"></script>
73
- ```
47
+ ### Option A: Standalone Bundle (Recommended for non-React websites)
74
48
 
75
- Then include the library UMD bundle. You can pass configuration using `data-*` attributes, or initialize programmatically.
49
+ This bundle includes React, ReactDOM, Socket.io, marked, and DOMPurify internally, making it a zero-dependency drop-in.
76
50
 
77
51
  ```html
78
- <link rel="stylesheet" href="https://unpkg.com/lulichat/dist/style.css" />
79
52
  <script
80
- src="https://unpkg.com/lulichat/dist/lulichat-support.umd.js"
53
+ src="https://unpkg.com/lulichat/dist/lulichat-widget-standalone.umd.js"
81
54
  data-api-key="YOUR_API_KEY"
82
55
  data-company-name="Your Company"
83
56
  data-position="bottom-right"
@@ -87,35 +60,14 @@ Then include the library UMD bundle. You can pass configuration using `data-*` a
87
60
  ></script>
88
61
  ```
89
62
 
90
- Or programmatically:
91
-
92
- ```html
93
- <script src="https://unpkg.com/lulichat/dist/lulichat-support.umd.js"></script>
94
- <script>
95
- window.LuliChatSupport.mount({
96
- apiKey: "YOUR_API_KEY",
97
- baseUrl: "https://api.example.com",
98
- position: "bottom-right",
99
- primaryColor: "#4f46e5",
100
- });
101
- // Later
102
- // window.LuliChatSupport.unmountAll();
103
- // or window.LuliChatSupport.unmount(id)
104
- </script>
105
- ```
106
-
107
- Notes:
63
+ ### Option B: Externalized Bundle
108
64
 
109
- - When using programmatic mount, the stylesheet will be auto‑injected. If your CSS file isn’t next to the script, set a custom URL via `data-style-href` on the script tag.
110
- - If `marked` or `DOMPurify` are not present, the widget will still render. Markdown will fall back to plain text/HTML passthrough and a console warning is logged. For best security and formatting, include both scripts above or use the standalone bundle.
111
-
112
- ### 2. Standalone build (no other scripts needed)
113
-
114
- If you prefer a zero‑dependency drop‑in (larger file size), use the standalone bundle produced as `lulichat-support-standalone.umd.js`:
65
+ If your page already loads React, ReactDOM, and socket.io-client, use the smaller externalized bundle:
115
66
 
116
67
  ```html
68
+ <link rel="stylesheet" href="https://unpkg.com/lulichat/dist/style.css" />
117
69
  <script
118
- src="https://unpkg.com/lulichat/dist/lulichat-support-standalone.umd.js"
70
+ src="https://unpkg.com/lulichat/dist/lulichat-widget.umd.js"
119
71
  data-api-key="YOUR_API_KEY"
120
72
  data-company-name="Your Company"
121
73
  data-position="bottom-right"
@@ -125,185 +77,32 @@ If you prefer a zero‑dependency drop‑in (larger file size), use the standalo
125
77
  ></script>
126
78
  ```
127
79
 
128
- No React/socket.io-client tags required. Choose this for non‑React sites wanting the simplest integration. Trade‑off: bigger download (~300kB UMD vs ~61kB + peer scripts).
80
+ ## 3. Configuration Options
129
81
 
130
- ### Isolated iframe mode (optional)
82
+ Set these options via React component props, `data-*` script tag attributes, or URL query parameters:
131
83
 
132
- If you want to isolate the widget’s DOM and CSS from your page, you can mount it inside a fixed-position iframe. Enable it from the script tag via `data-isolated="iframe"`:
84
+ | Parameter / Attribute | Description | Default |
85
+ | :------------------------------------------------- | :------------------------------------------------------------------------ | :------------------------- |
86
+ | `apiKey` / `data-api-key` | Your LuliChat public API key (Required) | - |
87
+ | `companyName` / `data-company-name` | Header title of the widget | `LuliChat` |
88
+ | `welcomeMessage` / `data-welcome-message` | Initial greeting message | - |
89
+ | `primaryColor` / `data-primary-color` | Hex theme color code (e.g. `#4f46e5`) | `#4f46e5` |
90
+ | `position` / `data-position` | Widget placement (`bottom-right`, `bottom-left`, `top-right`, `top-left`) | `bottom-right` |
91
+ | `allowAnonymous` / `data-allow-anonymous` | Allow users to chat without entering contact info | `false` |
92
+ | `requireContactInfo` / `data-require-contact-info` | Ask for contact info before initiating a session | `true` |
93
+ | `baseUrl` / `data-base-url` | Base endpoint URL for the chat backend API | `https://api.lulichat.com` |
133
94
 
134
- ```html
135
- <script
136
- src="https://unpkg.com/lulichat/dist/lulichat-support.umd.js"
137
- data-api-key="YOUR_API_KEY"
138
- data-isolated="iframe"
139
- data-iframe-width="360px"
140
- data-iframe-height="560px"
141
- defer
142
- onload="window.LuliChatSupport && window.LuliChatSupport.initFromScript()"
143
- ></script>
144
- ```
145
-
146
- Options you can set as `data-*` attributes for iframe mode:
147
-
148
- - `data-iframe-width` – width of the iframe (e.g. `360px`)
149
- - `data-iframe-height` – height of the iframe (e.g. `560px`)
150
- - `data-iframe-auto-resize` – when `true`, the iframe will resize to fit its content height
151
- - `data-iframe-min-height` / `data-iframe-max-height` – optional min/max height bounds for auto-resize
152
-
153
- You can also mount the iframe programmatically:
154
-
155
- ```html
156
- <script>
157
- const { mountIframe } = window.LuliChatSupport;
158
- const { id, iframe, unmount } = mountIframe(
159
- {
160
- apiKey: "YOUR_API_KEY",
161
- position: "bottom-right",
162
- primaryColor: "#4f46e5",
163
- },
164
- {
165
- width: "360px",
166
- height: "auto", // optional; if omitted, set autoResize: true to fit content
167
- autoResize: true,
168
- minHeight: 300, // optional
169
- maxHeight: 700, // optional
170
- }
171
- );
172
- // later: unmount()
173
- // or: window.LuliChatSupport.unmountIframe(id)
174
- // or: window.LuliChatSupport.unmountAll()
175
- // You can also set a custom stylesheet URL inside the iframe via styleHref:
176
- // mountIframe(config, { styleHref: 'https://cdn.example.com/lulichat.css' })
177
- }
178
- </script>
179
- ```
180
-
181
- Notes:
182
-
183
- - Stylesheet injection is automatic for both normal and iframe modes. If your `style.css` is not next to the UMD script, set `data-style-href` on the script or pass `styleHref` to `mountIframe`.
184
- - In auto-resize mode, the iframe height tracks the content using `ResizeObserver` (with a polling fallback). Min/max heights are respected if provided.
185
-
186
- ### Zero-JS iframe embedding (static frame)
187
-
188
- If you want to embed the chat without placing any script tags on the parent page (just an `<iframe>`), you can use the provided `frame.html` (or host a copy of it).
95
+ ---
189
96
 
190
- Example:
97
+ ## 4. JavaScript / Programmatic API
191
98
 
192
- ```html
193
- <iframe
194
- src="/path/to/frame.html?apiKey=YOUR_API_KEY&baseUrl=https://api.example.com&position=bottom-right&primaryColor=%234f46e5"
195
- width="380"
196
- height="600"
197
- style="border:0;background:transparent"
198
- loading="lazy"
199
- ></iframe>
200
- ```
201
-
202
- Supported query parameters (same semantics as data-\*):
99
+ When loaded via a script tag, the widget registers a global `window.LuliChatSupport` object:
203
100
 
204
- | Param | Description |
205
- | ------------------ | ---------------------------------------------------------- | ----------- | --------- | -------- |
206
- | apiKey | Required API key |
207
- | baseUrl | API base override |
208
- | position | bottom-right | bottom-left | top-right | top-left |
209
- | primaryColor | Hex/CSS color |
210
- | companyName | Display name |
211
- | welcomeMessage | Initial auto-response message |
212
- | requireContactInfo | `true` or `false` |
213
- | allowAnonymous | `true` or `false` |
214
- | configUrl | URL returning JSON config to merge (query params override) |
215
-
216
- Config JSON shape (example returned by `configUrl`):
217
-
218
- ```json
219
- {
220
- "apiKey": "YOUR_API_KEY",
221
- "companyName": "My Company",
222
- "welcomeMessage": "Hello! How can we help?",
223
- "primaryColor": "#4f46e5",
224
- "requireContactInfo": true,
225
- "allowAnonymous": false
226
- }
227
- ```
228
-
229
- Precedence: query parameters override fields returned by `configUrl`.
230
-
231
- To host your own: copy `frame.html` and ensure the path to the standalone bundle script is correct (or swap to externalized bundle + peer scripts). The frame loads, then waits for `window.LuliChatSupport` and mounts internally; styles are auto-injected.
232
-
233
- ## Hosted widget (production)
234
-
235
- We recommend hosting a small, versioned bundle set under:
236
-
237
- https://app.lulichat.com/widget/<version>/
238
-
239
- Each version folder contains:
240
-
241
- - `lulichat-widget.js` – loader clients include in their pages
242
- - `lulichat-widget.html` – the frame loaded by the loader
243
- - `dist/style.css` – stylesheet
244
- - `lulichat-widget-standalone.umd.js` – the standalone bundle (copied/renamed from the build)
245
-
246
- There is also a convenience alias:
247
-
248
- https://app.lulichat.com/widget/latest/
249
-
250
- Use `latest` if you want automatic upgrades; pin a specific `<version>` for stability.
251
-
252
- ### Client usage (loader)
253
-
254
- ```html
255
- <script
256
- src="https://app.lulichat.com/widget/latest/lulichat-widget.js"
257
- data-api-key="YOUR_API_KEY"
258
- data-base-url="https://api.lulichat.com"
259
- data-position="bottom-right"
260
- data-primary-color="#4f46e5"
261
- defer
262
- ></script>
263
- ```
264
-
265
- The loader computes its base URL from its own `src` and injects an iframe pointing to `.../lulichat-widget.html` with your `data-*` passed as query params. It also auto-resizes the iframe based on messages from the frame.
266
-
267
- #
268
-
269
- ### Passing options via data attributes
270
-
271
- Supported attributes (all optional except api-key):
272
-
273
- | Attribute | Purpose |
274
- | ------------------ | ------------------------------------------------------- |
275
- | data-api-key | Your public API key for auth/identification |
276
- | data-company-name | Display name in header |
277
- | data-position | one of: bottom-right, bottom-left, top-right, top-left |
278
- | data-primary-color | Hex or CSS color used as primary accent |
279
- | data-container | CSS selector for a custom mount node (defaults to body) |
280
- | data-style-href | Optional absolute URL to the CSS file if not colocated |
281
-
282
- Programmatic mount accepts the same properties plus `baseUrl` and feature flags like `allowAnonymous`.
283
-
284
- ```
285
-
286
- ## API
287
-
288
- ### Global Embed API
289
-
290
- `window.LuliChatSupport.mount(options)` – mounts the widget, returns an id.
291
-
292
- `window.LuliChatSupport.unmount(id)` – unmounts a specific instance.
293
-
294
- `window.LuliChatSupport.unmountAll()` – removes all mounted instances.
295
-
296
- `window.LuliChatSupport.initFromScript()` – reads the current script tag's `data-*` attributes and auto‑mounts.
297
-
298
- ### React Usage
299
-
300
- Import the default export `LuliChat` for React integration; styling is in `dist/style.css`.
301
-
302
- ## Contributing
303
-
304
- Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
101
+ - `window.LuliChatSupport.mount(config, targetSelector?)`: Mounts the widget programmatically.
102
+ - `window.LuliChatSupport.unmount(id)`: Unmounts a specific widget instance by ID.
103
+ - `window.LuliChatSupport.unmountAll()`: Removes all mounted widget instances.
104
+ - `window.LuliChatSupport.initFromScript()`: Reads properties from the current `<script>` tag and initializes the widget.
305
105
 
306
106
  ## License
307
107
 
308
- This project is licensed under the MIT License. See the LICENSE file for more details.
309
- ```
108
+ This project is licensed under the MIT License.