lulichat 1.0.15 → 1.0.16

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 (45) hide show
  1. package/README.md +55 -226
  2. package/dist/index.d.ts +131 -5
  3. package/dist/lulichat-widget-standalone.es.js +1 -1
  4. package/dist/lulichat-widget-standalone.umd.js +1 -1
  5. package/dist/lulichat-widget.es.js +1 -1
  6. package/dist/lulichat-widget.html +153 -0
  7. package/dist/lulichat-widget.js +131 -0
  8. package/dist/lulichat-widget.umd.js +1 -1
  9. package/package.json +91 -89
  10. package/dist/components/Animation.d.ts +0 -15
  11. package/dist/components/ChatWidget.d.ts +0 -7
  12. package/dist/components/LuliChat.d.ts +0 -3
  13. package/dist/components/chatroom/ChatBody.d.ts +0 -3
  14. package/dist/components/chatroom/ChatFooter.d.ts +0 -3
  15. package/dist/components/chatroom/ChatHeader.d.ts +0 -3
  16. package/dist/components/chatroom/ChatInterface.d.ts +0 -2
  17. package/dist/components/chatroom/ChatRating.d.ts +0 -7
  18. package/dist/components/chatroom/CompanyQueues.d.ts +0 -13
  19. package/dist/components/chatroom/Message.d.ts +0 -7
  20. package/dist/components/chatroom/StartChat.d.ts +0 -17
  21. package/dist/components/faq/FAQBody.d.ts +0 -3
  22. package/dist/components/faq/FAQCategories.d.ts +0 -7
  23. package/dist/components/faq/FAQInterface.d.ts +0 -5
  24. package/dist/components/faq/FAQList.d.ts +0 -8
  25. package/dist/components/faq/FAQViewer.d.ts +0 -7
  26. package/dist/components/history/HistoryInterface.d.ts +0 -5
  27. package/dist/components/history/Rate.d.ts +0 -3
  28. package/dist/components/history/TicketList.d.ts +0 -6
  29. package/dist/components/ui/AutoResizeTextArea.d.ts +0 -10
  30. package/dist/components/ui/Button.d.ts +0 -8
  31. package/dist/components/ui/Form.d.ts +0 -33
  32. package/dist/components/ui/Icons.d.ts +0 -25
  33. package/dist/components/ui/Input.d.ts +0 -9
  34. package/dist/components/ui/Tab.d.ts +0 -6
  35. package/dist/constants.d.ts +0 -33
  36. package/dist/hooks/useContext.d.ts +0 -14
  37. package/dist/hooks/useSocket.d.ts +0 -4
  38. package/dist/hooks/useStore.d.ts +0 -50
  39. package/dist/lib/embed.d.ts +0 -45
  40. package/dist/lib/socket.d.ts +0 -18
  41. package/dist/main.d.ts +0 -1
  42. package/dist/types/index.d.ts +0 -188
  43. package/dist/utils/api.d.ts +0 -120
  44. package/dist/utils/index.d.ts +0 -12
  45. package/dist/utils/renderToHTML.d.ts +0 -1
package/README.md CHANGED
@@ -1,33 +1,18 @@
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.
11
-
12
- ## Installation
13
-
14
- To install the LuliChat Support Chat library, run the following command:
7
+ ## 1. React Installation & Usage
15
8
 
9
+ ### Installation
16
10
  ```bash
17
11
  npm install lulichat
18
12
  ```
19
13
 
20
- ## Usage
21
-
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
30
-
14
+ ### Usage
15
+ Import the component and stylesheet:
31
16
  ```tsx
32
17
  import React from "react";
33
18
  import LuliChat from "lulichat";
@@ -35,49 +20,33 @@ import "lulichat/dist/style.css";
35
20
 
36
21
  const App = () => {
37
22
  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>
23
+ <LuliChat
24
+ apiKey="YOUR_API_KEY"
25
+ companyName="LuliChat Demo"
26
+ welcomeMessage="How can we help you today?"
27
+ primaryColor="#4f46e5"
28
+ allowAnonymous={true}
29
+ requireContactInfo={true}
30
+ position="bottom-right"
31
+ />
50
32
  );
51
33
  };
52
34
 
53
35
  export default App;
54
36
  ```
55
37
 
56
- ## Script tag (no React)
57
-
58
- You have two ways to embed the widget:
38
+ ---
59
39
 
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.
40
+ ## 2. Vanilla Script Integration (No React)
62
41
 
63
- ### 1. Externalized build (recommended if you already use React)
42
+ You can load the widget on any website using the unpkg CDN.
64
43
 
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):
44
+ ### Option A: Standalone Bundle (Recommended for non-React websites)
45
+ This bundle includes React, ReactDOM, Socket.io, marked, and DOMPurify internally, making it a zero-dependency drop-in.
66
46
 
67
47
  ```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
- ```
74
-
75
- Then include the library UMD bundle. You can pass configuration using `data-*` attributes, or initialize programmatically.
76
-
77
- ```html
78
- <link rel="stylesheet" href="https://unpkg.com/lulichat/dist/style.css" />
79
48
  <script
80
- src="https://unpkg.com/lulichat/dist/lulichat-support.umd.js"
49
+ src="https://unpkg.com/lulichat/dist/lulichat-widget-standalone.umd.js"
81
50
  data-api-key="YOUR_API_KEY"
82
51
  data-company-name="Your Company"
83
52
  data-position="bottom-right"
@@ -87,35 +56,13 @@ Then include the library UMD bundle. You can pass configuration using `data-*` a
87
56
  ></script>
88
57
  ```
89
58
 
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:
108
-
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`:
59
+ ### Option B: Externalized Bundle
60
+ If your page already loads React, ReactDOM, and socket.io-client, use the smaller externalized bundle:
115
61
 
116
62
  ```html
63
+ <link rel="stylesheet" href="https://unpkg.com/lulichat/dist/style.css" />
117
64
  <script
118
- src="https://unpkg.com/lulichat/dist/lulichat-support-standalone.umd.js"
65
+ src="https://unpkg.com/lulichat/dist/lulichat-widget.umd.js"
119
66
  data-api-key="YOUR_API_KEY"
120
67
  data-company-name="Your Company"
121
68
  data-position="bottom-right"
@@ -125,15 +72,16 @@ If you prefer a zero‑dependency drop‑in (larger file size), use the standalo
125
72
  ></script>
126
73
  ```
127
74
 
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).
75
+ ---
129
76
 
130
- ### Isolated iframe mode (optional)
77
+ ## 3. Iframe Embedding Options
131
78
 
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"`:
79
+ ### Option A: Isolated Iframe (Script Tag)
80
+ To isolate the chat DOM and CSS from your parent page styles, enable isolated mode using the `data-isolated` attribute:
133
81
 
134
82
  ```html
135
83
  <script
136
- src="https://unpkg.com/lulichat/dist/lulichat-support.umd.js"
84
+ src="https://unpkg.com/lulichat/dist/lulichat-widget.umd.js"
137
85
  data-api-key="YOUR_API_KEY"
138
86
  data-isolated="iframe"
139
87
  data-iframe-width="360px"
@@ -143,55 +91,12 @@ If you want to isolate the widget’s DOM and CSS from your page, you can mount
143
91
  ></script>
144
92
  ```
145
93
 
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).
189
-
190
- Example:
94
+ ### Option B: Zero-JS Iframe Embedding (Static Frame)
95
+ If you want to embed the chat widget strictly via a standard `<iframe>` without any scripts on the parent page, point the frame to the hosted `lulichat-widget.html`:
191
96
 
192
97
  ```html
193
98
  <iframe
194
- src="/path/to/frame.html?apiKey=YOUR_API_KEY&baseUrl=https://api.example.com&position=bottom-right&primaryColor=%234f46e5"
99
+ src="https://unpkg.com/lulichat/dist/lulichat-widget.html?apiKey=YOUR_API_KEY&position=bottom-right&primaryColor=%234f46e5"
195
100
  width="380"
196
101
  height="600"
197
102
  style="border:0;background:transparent"
@@ -199,111 +104,35 @@ Example:
199
104
  ></iframe>
200
105
  ```
201
106
 
202
- Supported query parameters (same semantics as data-\*):
203
-
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:
107
+ ---
240
108
 
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)
109
+ ## 4. Configuration Options
245
110
 
246
- There is also a convenience alias:
111
+ Set these options via React component props, `data-*` script tag attributes, or URL query parameters:
247
112
 
248
- https://app.lulichat.com/widget/latest/
113
+ | Parameter / Attribute | Description | Default |
114
+ | :--- | :--- | :--- |
115
+ | `apiKey` / `data-api-key` | Your LuliChat public API key (Required) | - |
116
+ | `companyName` / `data-company-name` | Header title of the widget | `LuliChat` |
117
+ | `welcomeMessage` / `data-welcome-message` | Initial greeting message | - |
118
+ | `primaryColor` / `data-primary-color` | Hex theme color code (e.g. `#4f46e5`) | `#4f46e5` |
119
+ | `position` / `data-position` | Widget placement (`bottom-right`, `bottom-left`, `top-right`, `top-left`) | `bottom-right` |
120
+ | `allowAnonymous` / `data-allow-anonymous` | Allow users to chat without entering contact info | `false` |
121
+ | `requireContactInfo` / `data-require-contact-info` | Ask for contact info before initiating a session | `true` |
122
+ | `baseUrl` / `data-base-url` | Base endpoint URL for the chat backend API | `https://api.lulichat.com` |
249
123
 
250
- Use `latest` if you want automatic upgrades; pin a specific `<version>` for stability.
124
+ ---
251
125
 
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
- ```
126
+ ## 5. JavaScript / Programmatic API
264
127
 
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.
128
+ When loaded via a script tag, the widget registers a global `window.LuliChatSupport` object:
266
129
 
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.
130
+ - `window.LuliChatSupport.mount(config, targetSelector?)`: Mounts the widget programmatically.
131
+ - `window.LuliChatSupport.unmount(id)`: Unmounts a specific widget instance by ID.
132
+ - `window.LuliChatSupport.unmountAll()`: Removes all mounted widget instances.
133
+ - `window.LuliChatSupport.mountIframe(config, iframeConfig)`: Programmatically mounts the widget within an isolated iframe.
134
+ - `window.LuliChatSupport.initFromScript()`: Reads properties from the current `<script>` tag and initializes the widget.
305
135
 
306
136
  ## License
307
137
 
308
- This project is licensed under the MIT License. See the LICENSE file for more details.
309
- ```
138
+ This project is licensed under the MIT License.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,131 @@
1
- import { LuliChat } from "./components/LuliChat";
2
- export * from "./types";
3
- import "./styles/main.scss";
4
- export * from "./lib/embed";
5
- export { LuliChat as default };
1
+ import React from 'react';
2
+
3
+ export interface LuliChatConfig {
4
+ apiKey: string;
5
+ baseUrl?: string;
6
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
7
+ primaryColor?: string;
8
+ companyName?: string;
9
+ welcomeMessage?: string;
10
+ requireContactInfo?: boolean;
11
+ allowAnonymous?: boolean;
12
+ }
13
+
14
+ export interface MountResult {
15
+ id: string;
16
+ unmount: () => void;
17
+ container: HTMLElement;
18
+ }
19
+
20
+ export function mount(
21
+ config: LuliChatConfig,
22
+ target?: string | HTMLElement
23
+ ): MountResult;
24
+
25
+ export function unmount(id: string): void;
26
+
27
+ export function unmountAll(): void;
28
+
29
+ export interface IframeOptions {
30
+ width?: string | number;
31
+ height?: string | number;
32
+ autoResize?: boolean;
33
+ minHeight?: string | number;
34
+ maxHeight?: string | number;
35
+ styleHref?: string;
36
+ }
37
+
38
+ export function mountIframe(
39
+ config: LuliChatConfig,
40
+ options?: IframeOptions
41
+ ): MountResult & { iframe: HTMLIFrameElement };
42
+
43
+ export function unmountIframe(id: string): void;
44
+
45
+ export function initFromScript(script?: HTMLScriptElement): any;
46
+
47
+ export interface ContactInfo {
48
+ name?: string;
49
+ email?: string;
50
+ queueId?: string | number;
51
+ queueOptionId?: string | number;
52
+ guestId?: string;
53
+ }
54
+
55
+ export interface Help {
56
+ id: number;
57
+ title: string;
58
+ description: string;
59
+ category: string;
60
+ video: string;
61
+ link: string;
62
+ type: string;
63
+ createdAt: string;
64
+ updatedAt: string;
65
+ }
66
+
67
+ export type Sender = "user" | "human-agent" | "system" | "ai-agent" | "auto-respond";
68
+ export type MessageStatus = "error" | "pending" | "delivered" | "seen" | "played" | "unknown";
69
+
70
+ export interface ChatMessage {
71
+ mediaUrl?: string | null;
72
+ id: string;
73
+ dataJson?: any;
74
+ ack: number;
75
+ read: boolean;
76
+ fromMe: boolean;
77
+ body: string;
78
+ mediaType?: string;
79
+ isDeleted?: boolean;
80
+ createdAt: string | Date;
81
+ quotedMsgId?: number | string | null;
82
+ queueId?: number;
83
+ isEdited?: boolean;
84
+ quotedMsg?: ChatMessage | null;
85
+ status: string;
86
+ sender: Sender;
87
+ }
88
+
89
+ export interface Ticket {
90
+ id: number;
91
+ status: string;
92
+ unreadMessages: null;
93
+ lastMessage: string;
94
+ createdAt: string;
95
+ updatedAt: string;
96
+ companyId: string;
97
+ queueId: string;
98
+ contact: Contact;
99
+ queue: {
100
+ id: number;
101
+ name: string;
102
+ color: string;
103
+ };
104
+ ticketTracking: any;
105
+ tags: any[];
106
+ }
107
+
108
+ export interface Contact {
109
+ id: number;
110
+ name: string;
111
+ number: string;
112
+ email: string;
113
+ chatId: string;
114
+ profilePicUrl: null;
115
+ }
116
+
117
+ export interface Queue {
118
+ id: number;
119
+ name: string;
120
+ color: string;
121
+ greetingMessage: string;
122
+ outOfHoursMessage: string;
123
+ companyId: number;
124
+ createdAt: string;
125
+ updatedAt: string;
126
+ }
127
+
128
+ export type ChatState = "closed" | "contact-form" | "chat" | "loading";
129
+
130
+ declare const LuliChat: React.FC<LuliChatConfig>;
131
+ export default LuliChat;
@@ -12469,7 +12469,7 @@ function Lu(e = document, t, n = 5e3) {
12469
12469
  try {
12470
12470
  if (l) {
12471
12471
  const u = new URL(l, ((s = e.location) == null ? void 0 : s.href) || void 0);
12472
- u.searchParams.has("v") || u.searchParams.set("v", "1.0.15"), l = u.toString();
12472
+ u.searchParams.has("v") || u.searchParams.set("v", "1.0.16"), l = u.toString();
12473
12473
  }
12474
12474
  } catch {
12475
12475
  }