@buni.ai/chatbot-react 1.0.0
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 +273 -0
- package/dist/components.d.ts +24 -0
- package/dist/hooks.d.ts +33 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +232 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +240 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# @buni.ai/chatbot-react
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40buni.ai%2Fchatbot-react)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
React adapter for BuniAI Chat Widget - provides React hooks and components for seamless chatbot integration.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- ⚛️ **React Native** - Built specifically for React applications
|
|
11
|
+
- 🪝 **Hooks API** - Modern React hooks for state management
|
|
12
|
+
- 🧩 **Components** - Pre-built React components ready to use
|
|
13
|
+
- 📦 **TypeScript Ready** - Full type definitions included
|
|
14
|
+
- 🎯 **Context Provider** - Easy widget sharing across components
|
|
15
|
+
- 🔄 **Reactive State** - Automatic UI updates with widget state changes
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @buni.ai/chatbot-react
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Using the Hook
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import React from 'react';
|
|
29
|
+
import { useBuniChat, BuniChatWidget } from '@buni.ai/chatbot-react';
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
const { isOpen, toggle, setCustomerData } = useBuniChat({
|
|
33
|
+
token: 'your-embed-token',
|
|
34
|
+
config: {
|
|
35
|
+
theme: 'default',
|
|
36
|
+
position: 'bottom-right'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const handleCustomerLogin = () => {
|
|
41
|
+
setCustomerData({
|
|
42
|
+
name: 'John Doe',
|
|
43
|
+
email: 'john@example.com',
|
|
44
|
+
userId: 'user123'
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
<h1>My App</h1>
|
|
51
|
+
<button onClick={toggle}>
|
|
52
|
+
{isOpen ? 'Close Chat' : 'Open Chat'}
|
|
53
|
+
</button>
|
|
54
|
+
<button onClick={handleCustomerLogin}>
|
|
55
|
+
Set Customer Data
|
|
56
|
+
</button>
|
|
57
|
+
<BuniChatWidget />
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Using the Provider
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import React from 'react';
|
|
67
|
+
import { BuniChatProvider, BuniChatWidget, BuniChatButton } from '@buni.ai/chatbot-react';
|
|
68
|
+
|
|
69
|
+
function App() {
|
|
70
|
+
return (
|
|
71
|
+
<BuniChatProvider
|
|
72
|
+
options={{
|
|
73
|
+
token: 'your-embed-token',
|
|
74
|
+
config: {
|
|
75
|
+
theme: 'default',
|
|
76
|
+
position: 'bottom-right'
|
|
77
|
+
}
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<MyAppContent />
|
|
81
|
+
</BuniChatProvider>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function MyAppContent() {
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<h1>My App</h1>
|
|
89
|
+
<BuniChatButton>Chat with Support</BuniChatButton>
|
|
90
|
+
<BuniChatWidget />
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Components
|
|
97
|
+
|
|
98
|
+
### BuniChatWidget
|
|
99
|
+
|
|
100
|
+
The main widget component that renders the chat interface.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<BuniChatWidget
|
|
104
|
+
className="custom-widget"
|
|
105
|
+
style={{ zIndex: 1000 }}
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### BuniChatButton
|
|
110
|
+
|
|
111
|
+
A button to trigger the chat widget.
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<BuniChatButton
|
|
115
|
+
onClick={() => console.log('Chat opened')}
|
|
116
|
+
className="chat-trigger"
|
|
117
|
+
showUnreadCount={true}
|
|
118
|
+
>
|
|
119
|
+
Need Help?
|
|
120
|
+
</BuniChatButton>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### BuniChatFloatingButton
|
|
124
|
+
|
|
125
|
+
A pre-styled floating action button for the chat widget.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<BuniChatFloatingButton
|
|
129
|
+
position="bottom-right"
|
|
130
|
+
size="medium"
|
|
131
|
+
theme="default"
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Hooks
|
|
136
|
+
|
|
137
|
+
### useBuniChat
|
|
138
|
+
|
|
139
|
+
Main hook for widget interaction.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
const {
|
|
143
|
+
// State
|
|
144
|
+
isOpen,
|
|
145
|
+
isLoaded,
|
|
146
|
+
isMinimized,
|
|
147
|
+
unreadCount,
|
|
148
|
+
isReady,
|
|
149
|
+
|
|
150
|
+
// Actions
|
|
151
|
+
show,
|
|
152
|
+
hide,
|
|
153
|
+
toggle,
|
|
154
|
+
minimize,
|
|
155
|
+
maximize,
|
|
156
|
+
setCustomerData,
|
|
157
|
+
setSessionVariables,
|
|
158
|
+
sendMessage,
|
|
159
|
+
|
|
160
|
+
// Widget instance
|
|
161
|
+
widget
|
|
162
|
+
} = useBuniChat(options);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### useWidgetEvents
|
|
166
|
+
|
|
167
|
+
Hook for event handling.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
const { on, off } = useWidgetEvents();
|
|
171
|
+
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
const handleNewMessage = (data) => {
|
|
174
|
+
console.log('New message:', data.message);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
on('new_message', handleNewMessage);
|
|
178
|
+
|
|
179
|
+
return () => off('new_message', handleNewMessage);
|
|
180
|
+
}, [on, off]);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### useCustomerData
|
|
184
|
+
|
|
185
|
+
Hook for customer data management.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
const { customerData, setCustomerData, getCustomerData } = useCustomerData();
|
|
189
|
+
|
|
190
|
+
const handleLogin = () => {
|
|
191
|
+
setCustomerData({
|
|
192
|
+
name: 'John Doe',
|
|
193
|
+
email: 'john@example.com'
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Advanced Usage
|
|
199
|
+
|
|
200
|
+
### Custom Event Handling
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
function ChatEventHandler() {
|
|
204
|
+
const { widget } = useBuniChat();
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (widget) {
|
|
208
|
+
const handleTyping = (data) => {
|
|
209
|
+
console.log('Typing indicator:', data.isBot);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
widget.on('typing_start', handleTyping);
|
|
213
|
+
widget.on('typing_stop', handleTyping);
|
|
214
|
+
|
|
215
|
+
return () => {
|
|
216
|
+
widget.off('typing_start', handleTyping);
|
|
217
|
+
widget.off('typing_stop', handleTyping);
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}, [widget]);
|
|
221
|
+
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Conditional Rendering
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
function ConditionalChat() {
|
|
230
|
+
const { isReady, isOpen } = useBuniChat({
|
|
231
|
+
token: 'your-token'
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
if (!isReady) {
|
|
235
|
+
return <div>Loading chat...</div>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<div>
|
|
240
|
+
{isOpen && <div>Chat is open!</div>}
|
|
241
|
+
<BuniChatWidget />
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## TypeScript Support
|
|
248
|
+
|
|
249
|
+
Full TypeScript support with comprehensive type definitions:
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import {
|
|
253
|
+
BuniChatConfig,
|
|
254
|
+
BuniChatOptions,
|
|
255
|
+
CustomerData,
|
|
256
|
+
SessionVariables
|
|
257
|
+
} from '@buni.ai/chatbot-react';
|
|
258
|
+
|
|
259
|
+
const config: BuniChatConfig = {
|
|
260
|
+
theme: 'dark',
|
|
261
|
+
position: 'bottom-left',
|
|
262
|
+
primaryColor: '#007bff'
|
|
263
|
+
};
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Requirements
|
|
267
|
+
|
|
268
|
+
- React >= 16.8.0
|
|
269
|
+
- React DOM >= 16.8.0
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT © BuniAI Team
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { BuniChatConfig } from '@buni.ai/chatbot-core';
|
|
3
|
+
interface BuniChatWidgetProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
config?: BuniChatConfig;
|
|
7
|
+
}
|
|
8
|
+
export declare const BuniChatWidget: React.FC<BuniChatWidgetProps>;
|
|
9
|
+
interface BuniChatButtonProps {
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
showUnreadCount?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const BuniChatButton: React.FC<BuniChatButtonProps>;
|
|
18
|
+
interface BuniChatFloatingButtonProps extends Omit<BuniChatButtonProps, 'children'> {
|
|
19
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
20
|
+
size?: 'small' | 'medium' | 'large';
|
|
21
|
+
theme?: 'default' | 'minimal' | 'colorful';
|
|
22
|
+
}
|
|
23
|
+
export declare const BuniChatFloatingButton: React.FC<BuniChatFloatingButtonProps>;
|
|
24
|
+
export {};
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { BuniChatWidget, BuniChatOptions, CustomerData, SessionVariables } from '@buni.ai/chatbot-core';
|
|
3
|
+
interface BuniChatProviderProps {
|
|
4
|
+
options: BuniChatOptions;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const BuniChatProvider: React.FC<BuniChatProviderProps>;
|
|
8
|
+
export declare function useBuniChat(options?: BuniChatOptions): {
|
|
9
|
+
isReady: boolean;
|
|
10
|
+
show: () => void;
|
|
11
|
+
hide: () => void;
|
|
12
|
+
toggle: () => void;
|
|
13
|
+
minimize: () => void;
|
|
14
|
+
maximize: () => void;
|
|
15
|
+
setCustomerData: (data: CustomerData) => void;
|
|
16
|
+
setSessionVariables: (variables: SessionVariables) => void;
|
|
17
|
+
sendMessage: (message: string) => void;
|
|
18
|
+
widget: BuniChatWidget;
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
isLoaded: boolean;
|
|
21
|
+
isMinimized: boolean;
|
|
22
|
+
unreadCount: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function useWidgetEvents(): {
|
|
25
|
+
on: (event: string, callback: Function) => void;
|
|
26
|
+
off: (event: string, callback?: Function) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare function useCustomerData(): {
|
|
29
|
+
customerData: CustomerData | null;
|
|
30
|
+
setCustomerData: (data: CustomerData) => void;
|
|
31
|
+
getCustomerData: () => CustomerData | null;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useState, useEffect, useContext, useCallback } from 'react';
|
|
3
|
+
import { BuniChatWidget as BuniChatWidget$1 } from '@buni.ai/chatbot-core';
|
|
4
|
+
|
|
5
|
+
const BuniChatContext = createContext(null);
|
|
6
|
+
const BuniChatProvider = ({ options, children }) => {
|
|
7
|
+
const [widget] = useState(() => new BuniChatWidget$1());
|
|
8
|
+
const [state, setState] = useState({
|
|
9
|
+
isOpen: false,
|
|
10
|
+
isLoaded: false,
|
|
11
|
+
isMinimized: false,
|
|
12
|
+
unreadCount: 0
|
|
13
|
+
});
|
|
14
|
+
const [isReady, setIsReady] = useState(false);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const initWidget = async () => {
|
|
17
|
+
try {
|
|
18
|
+
await widget.initialize(options);
|
|
19
|
+
setIsReady(true);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Failed to initialize BuniChat widget:', error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
initWidget();
|
|
26
|
+
// Set up event listeners
|
|
27
|
+
const handleStateChange = () => {
|
|
28
|
+
setState(widget.getState());
|
|
29
|
+
};
|
|
30
|
+
widget.on('ready', handleStateChange);
|
|
31
|
+
widget.on('visibility_changed', handleStateChange);
|
|
32
|
+
widget.on('minimized', handleStateChange);
|
|
33
|
+
widget.on('maximized', handleStateChange);
|
|
34
|
+
widget.on('new_message', handleStateChange);
|
|
35
|
+
return () => {
|
|
36
|
+
widget.destroy();
|
|
37
|
+
};
|
|
38
|
+
}, [widget, options]);
|
|
39
|
+
return (jsx(BuniChatContext.Provider, { value: { widget, state, isReady }, children: children }));
|
|
40
|
+
};
|
|
41
|
+
// Main hook for using BuniChat
|
|
42
|
+
function useBuniChat(options) {
|
|
43
|
+
const context = useContext(BuniChatContext);
|
|
44
|
+
const [widget] = useState(() => new BuniChatWidget$1());
|
|
45
|
+
const [state, setState] = useState({
|
|
46
|
+
isOpen: false,
|
|
47
|
+
isLoaded: false,
|
|
48
|
+
isMinimized: false,
|
|
49
|
+
unreadCount: 0
|
|
50
|
+
});
|
|
51
|
+
const [isReady, setIsReady] = useState(false);
|
|
52
|
+
// Use context widget if available, otherwise use standalone
|
|
53
|
+
const activeWidget = (context === null || context === void 0 ? void 0 : context.widget) || widget;
|
|
54
|
+
const activeState = (context === null || context === void 0 ? void 0 : context.state) || state;
|
|
55
|
+
const activeIsReady = (context === null || context === void 0 ? void 0 : context.isReady) || isReady;
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (options && !context) {
|
|
58
|
+
// Initialize standalone widget
|
|
59
|
+
const initWidget = async () => {
|
|
60
|
+
try {
|
|
61
|
+
await activeWidget.initialize(options);
|
|
62
|
+
setIsReady(true);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error('Failed to initialize BuniChat widget:', error);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
initWidget();
|
|
69
|
+
const handleStateChange = () => {
|
|
70
|
+
setState(activeWidget.getState());
|
|
71
|
+
};
|
|
72
|
+
activeWidget.on('ready', handleStateChange);
|
|
73
|
+
activeWidget.on('visibility_changed', handleStateChange);
|
|
74
|
+
activeWidget.on('minimized', handleStateChange);
|
|
75
|
+
activeWidget.on('maximized', handleStateChange);
|
|
76
|
+
activeWidget.on('new_message', handleStateChange);
|
|
77
|
+
return () => {
|
|
78
|
+
activeWidget.destroy();
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}, [options, context, activeWidget]);
|
|
82
|
+
const show = useCallback(() => {
|
|
83
|
+
activeWidget.show();
|
|
84
|
+
}, [activeWidget]);
|
|
85
|
+
const hide = useCallback(() => {
|
|
86
|
+
activeWidget.hide();
|
|
87
|
+
}, [activeWidget]);
|
|
88
|
+
const toggle = useCallback(() => {
|
|
89
|
+
activeWidget.toggle();
|
|
90
|
+
}, [activeWidget]);
|
|
91
|
+
const minimize = useCallback(() => {
|
|
92
|
+
activeWidget.minimize();
|
|
93
|
+
}, [activeWidget]);
|
|
94
|
+
const maximize = useCallback(() => {
|
|
95
|
+
activeWidget.maximize();
|
|
96
|
+
}, [activeWidget]);
|
|
97
|
+
const setCustomerData = useCallback((data) => {
|
|
98
|
+
activeWidget.setCustomerData(data);
|
|
99
|
+
}, [activeWidget]);
|
|
100
|
+
const setSessionVariables = useCallback((variables) => {
|
|
101
|
+
activeWidget.setSessionVariables(variables);
|
|
102
|
+
}, [activeWidget]);
|
|
103
|
+
const sendMessage = useCallback((message) => {
|
|
104
|
+
activeWidget.sendMessage(message);
|
|
105
|
+
}, [activeWidget]);
|
|
106
|
+
return {
|
|
107
|
+
// State
|
|
108
|
+
...activeState,
|
|
109
|
+
isReady: activeIsReady,
|
|
110
|
+
// Actions
|
|
111
|
+
show,
|
|
112
|
+
hide,
|
|
113
|
+
toggle,
|
|
114
|
+
minimize,
|
|
115
|
+
maximize,
|
|
116
|
+
setCustomerData,
|
|
117
|
+
setSessionVariables,
|
|
118
|
+
sendMessage,
|
|
119
|
+
// Direct widget access
|
|
120
|
+
widget: activeWidget
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
// Hook for widget events
|
|
124
|
+
function useWidgetEvents() {
|
|
125
|
+
const { widget } = useBuniChat();
|
|
126
|
+
const on = useCallback((event, callback) => {
|
|
127
|
+
widget === null || widget === void 0 ? void 0 : widget.on(event, callback);
|
|
128
|
+
}, [widget]);
|
|
129
|
+
const off = useCallback((event, callback) => {
|
|
130
|
+
widget === null || widget === void 0 ? void 0 : widget.off(event, callback);
|
|
131
|
+
}, [widget]);
|
|
132
|
+
return { on, off };
|
|
133
|
+
}
|
|
134
|
+
// Hook for customer data management
|
|
135
|
+
function useCustomerData() {
|
|
136
|
+
const { widget } = useBuniChat();
|
|
137
|
+
const [customerData, setCustomerDataState] = useState(null);
|
|
138
|
+
const setCustomerData = useCallback((data) => {
|
|
139
|
+
widget === null || widget === void 0 ? void 0 : widget.setCustomerData(data);
|
|
140
|
+
setCustomerDataState(data);
|
|
141
|
+
}, [widget]);
|
|
142
|
+
const getCustomerData = useCallback(() => {
|
|
143
|
+
return (widget === null || widget === void 0 ? void 0 : widget.getCustomerData()) || null;
|
|
144
|
+
}, [widget]);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (widget) {
|
|
147
|
+
const handleCustomerDataUpdate = (event) => {
|
|
148
|
+
setCustomerDataState(event.data);
|
|
149
|
+
};
|
|
150
|
+
widget.on('customer_data_updated', handleCustomerDataUpdate);
|
|
151
|
+
return () => {
|
|
152
|
+
widget.off('customer_data_updated', handleCustomerDataUpdate);
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}, [widget]);
|
|
156
|
+
return {
|
|
157
|
+
customerData,
|
|
158
|
+
setCustomerData,
|
|
159
|
+
getCustomerData
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const BuniChatWidget = ({ className, style, config }) => {
|
|
164
|
+
const { isReady, isOpen } = useBuniChat();
|
|
165
|
+
if (!isReady) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return (jsx("div", { className: `buni-chat-widget ${className || ''}`, style: style, "data-widget-open": isOpen, id: "buni-chat-widget-container" }));
|
|
169
|
+
};
|
|
170
|
+
const BuniChatButton = ({ onClick, children, className, style, disabled = false, showUnreadCount = true }) => {
|
|
171
|
+
const { toggle, unreadCount } = useBuniChat();
|
|
172
|
+
const handleClick = () => {
|
|
173
|
+
if (onClick) {
|
|
174
|
+
onClick();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
toggle();
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
return (jsxs("button", { className: `buni-chat-button ${className || ''}`, style: style, onClick: handleClick, disabled: disabled, "aria-label": "Open chat widget", children: [children || 'Chat with us', showUnreadCount && unreadCount > 0 && (jsx("span", { className: "buni-chat-unread-badge", "aria-label": `${unreadCount} unread messages`, children: unreadCount }))] }));
|
|
181
|
+
};
|
|
182
|
+
const BuniChatFloatingButton = ({ position = 'bottom-right', size = 'medium', theme = 'default', className, style, ...props }) => {
|
|
183
|
+
const baseStyles = {
|
|
184
|
+
position: 'fixed',
|
|
185
|
+
zIndex: 1000,
|
|
186
|
+
borderRadius: '50%',
|
|
187
|
+
border: 'none',
|
|
188
|
+
cursor: 'pointer',
|
|
189
|
+
transition: 'all 0.3s ease',
|
|
190
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
191
|
+
...style,
|
|
192
|
+
};
|
|
193
|
+
// Position styles
|
|
194
|
+
const positionStyles = {
|
|
195
|
+
'bottom-right': { bottom: '20px', right: '20px' },
|
|
196
|
+
'bottom-left': { bottom: '20px', left: '20px' },
|
|
197
|
+
'top-right': { top: '20px', right: '20px' },
|
|
198
|
+
'top-left': { top: '20px', left: '20px' },
|
|
199
|
+
};
|
|
200
|
+
// Size styles
|
|
201
|
+
const sizeStyles = {
|
|
202
|
+
small: { width: '48px', height: '48px', fontSize: '14px' },
|
|
203
|
+
medium: { width: '60px', height: '60px', fontSize: '16px' },
|
|
204
|
+
large: { width: '72px', height: '72px', fontSize: '18px' },
|
|
205
|
+
};
|
|
206
|
+
// Theme styles
|
|
207
|
+
const themeStyles = {
|
|
208
|
+
default: {
|
|
209
|
+
backgroundColor: '#007bff',
|
|
210
|
+
color: 'white',
|
|
211
|
+
},
|
|
212
|
+
minimal: {
|
|
213
|
+
backgroundColor: '#f8f9fa',
|
|
214
|
+
color: '#333',
|
|
215
|
+
border: '1px solid #dee2e6',
|
|
216
|
+
},
|
|
217
|
+
colorful: {
|
|
218
|
+
background: 'linear-gradient(45deg, #007bff, #28a745)',
|
|
219
|
+
color: 'white',
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
const combinedStyles = {
|
|
223
|
+
...baseStyles,
|
|
224
|
+
...positionStyles[position],
|
|
225
|
+
...sizeStyles[size],
|
|
226
|
+
...themeStyles[theme],
|
|
227
|
+
};
|
|
228
|
+
return (jsx(BuniChatButton, { className: `buni-chat-floating-button buni-chat-floating-button--${position} buni-chat-floating-button--${size} buni-chat-floating-button--${theme} ${className || ''}`, style: combinedStyles, ...props, children: "\uD83D\uDCAC" }));
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { BuniChatButton, BuniChatFloatingButton, BuniChatProvider, BuniChatWidget, useBuniChat, useCustomerData, useWidgetEvents };
|
|
232
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/hooks.tsx","../src/components.tsx"],"sourcesContent":["// @buni.ai/chatbot-react - React hooks and components\n\nimport React, { \n createContext, \n useContext, \n useEffect, \n useState, \n useCallback,\n ReactNode \n} from 'react';\nimport { \n BuniChatWidget, \n BuniChatOptions, \n BuniChatState, \n CustomerData, \n SessionVariables,\n BuniChatConfig\n} from '@buni.ai/chatbot-core';\n\n// Context for providing widget instance\ninterface BuniChatContextType {\n widget: BuniChatWidget | null;\n state: BuniChatState;\n isReady: boolean;\n}\n\nconst BuniChatContext = createContext<BuniChatContextType | null>(null);\n\n// Provider component\ninterface BuniChatProviderProps {\n options: BuniChatOptions;\n children: ReactNode;\n}\n\nexport const BuniChatProvider: React.FC<BuniChatProviderProps> = ({ \n options, \n children \n}) => {\n const [widget] = useState(() => new BuniChatWidget());\n const [state, setState] = useState<BuniChatState>({\n isOpen: false,\n isLoaded: false,\n isMinimized: false,\n unreadCount: 0\n });\n const [isReady, setIsReady] = useState(false);\n\n useEffect(() => {\n const initWidget = async () => {\n try {\n await widget.initialize(options);\n setIsReady(true);\n } catch (error) {\n console.error('Failed to initialize BuniChat widget:', error);\n }\n };\n\n initWidget();\n\n // Set up event listeners\n const handleStateChange = () => {\n setState(widget.getState());\n };\n\n widget.on('ready', handleStateChange);\n widget.on('visibility_changed', handleStateChange);\n widget.on('minimized', handleStateChange);\n widget.on('maximized', handleStateChange);\n widget.on('new_message', handleStateChange);\n\n return () => {\n widget.destroy();\n };\n }, [widget, options]);\n\n return (\n <BuniChatContext.Provider value={{ widget, state, isReady }}>\n {children}\n </BuniChatContext.Provider>\n );\n};\n\n// Main hook for using BuniChat\nexport function useBuniChat(options?: BuniChatOptions) {\n const context = useContext(BuniChatContext);\n const [widget] = useState(() => new BuniChatWidget());\n const [state, setState] = useState<BuniChatState>({\n isOpen: false,\n isLoaded: false,\n isMinimized: false,\n unreadCount: 0\n });\n const [isReady, setIsReady] = useState(false);\n\n // Use context widget if available, otherwise use standalone\n const activeWidget = context?.widget || widget;\n const activeState = context?.state || state;\n const activeIsReady = context?.isReady || isReady;\n\n useEffect(() => {\n if (options && !context) {\n // Initialize standalone widget\n const initWidget = async () => {\n try {\n await activeWidget.initialize(options);\n setIsReady(true);\n } catch (error) {\n console.error('Failed to initialize BuniChat widget:', error);\n }\n };\n\n initWidget();\n\n const handleStateChange = () => {\n setState(activeWidget.getState());\n };\n\n activeWidget.on('ready', handleStateChange);\n activeWidget.on('visibility_changed', handleStateChange);\n activeWidget.on('minimized', handleStateChange);\n activeWidget.on('maximized', handleStateChange);\n activeWidget.on('new_message', handleStateChange);\n\n return () => {\n activeWidget.destroy();\n };\n }\n }, [options, context, activeWidget]);\n\n const show = useCallback(() => {\n activeWidget.show();\n }, [activeWidget]);\n\n const hide = useCallback(() => {\n activeWidget.hide();\n }, [activeWidget]);\n\n const toggle = useCallback(() => {\n activeWidget.toggle();\n }, [activeWidget]);\n\n const minimize = useCallback(() => {\n activeWidget.minimize();\n }, [activeWidget]);\n\n const maximize = useCallback(() => {\n activeWidget.maximize();\n }, [activeWidget]);\n\n const setCustomerData = useCallback((data: CustomerData) => {\n activeWidget.setCustomerData(data);\n }, [activeWidget]);\n\n const setSessionVariables = useCallback((variables: SessionVariables) => {\n activeWidget.setSessionVariables(variables);\n }, [activeWidget]);\n\n const sendMessage = useCallback((message: string) => {\n activeWidget.sendMessage(message);\n }, [activeWidget]);\n\n return {\n // State\n ...activeState,\n isReady: activeIsReady,\n \n // Actions\n show,\n hide,\n toggle,\n minimize,\n maximize,\n setCustomerData,\n setSessionVariables,\n sendMessage,\n \n // Direct widget access\n widget: activeWidget\n };\n}\n\n// Hook for widget events\nexport function useWidgetEvents() {\n const { widget } = useBuniChat();\n \n const on = useCallback((event: string, callback: Function) => {\n widget?.on(event, callback);\n }, [widget]);\n \n const off = useCallback((event: string, callback?: Function) => {\n widget?.off(event, callback);\n }, [widget]);\n \n return { on, off };\n}\n\n// Hook for customer data management\nexport function useCustomerData() {\n const { widget } = useBuniChat();\n const [customerData, setCustomerDataState] = useState<CustomerData | null>(null);\n \n const setCustomerData = useCallback((data: CustomerData) => {\n widget?.setCustomerData(data);\n setCustomerDataState(data);\n }, [widget]);\n \n const getCustomerData = useCallback(() => {\n return widget?.getCustomerData() || null;\n }, [widget]);\n \n useEffect(() => {\n if (widget) {\n const handleCustomerDataUpdate = (event: { data: CustomerData }) => {\n setCustomerDataState(event.data);\n };\n \n widget.on('customer_data_updated', handleCustomerDataUpdate);\n \n return () => {\n widget.off('customer_data_updated', handleCustomerDataUpdate);\n };\n }\n }, [widget]);\n \n return {\n customerData,\n setCustomerData,\n getCustomerData\n };\n}\n","// Components for @buni.ai/chatbot-react\n\nimport React, { ReactNode } from 'react';\nimport { useBuniChat } from './hooks';\nimport { BuniChatConfig } from '@buni.ai/chatbot-core';\n\n// Widget component\ninterface BuniChatWidgetProps {\n className?: string;\n style?: React.CSSProperties;\n config?: BuniChatConfig;\n}\n\nexport const BuniChatWidget: React.FC<BuniChatWidgetProps> = ({ \n className,\n style,\n config \n}) => {\n const { isReady, isOpen } = useBuniChat();\n \n if (!isReady) {\n return null;\n }\n \n return (\n <div \n className={`buni-chat-widget ${className || ''}`}\n style={style}\n data-widget-open={isOpen}\n id=\"buni-chat-widget-container\"\n >\n {/* Widget will be rendered here by the core widget */}\n </div>\n );\n};\n\n// Chat button component\ninterface BuniChatButtonProps {\n onClick?: () => void;\n children?: ReactNode;\n className?: string;\n style?: React.CSSProperties;\n disabled?: boolean;\n showUnreadCount?: boolean;\n}\n\nexport const BuniChatButton: React.FC<BuniChatButtonProps> = ({\n onClick,\n children,\n className,\n style,\n disabled = false,\n showUnreadCount = true\n}) => {\n const { toggle, unreadCount } = useBuniChat();\n \n const handleClick = () => {\n if (onClick) {\n onClick();\n } else {\n toggle();\n }\n };\n \n return (\n <button\n className={`buni-chat-button ${className || ''}`}\n style={style}\n onClick={handleClick}\n disabled={disabled}\n aria-label=\"Open chat widget\"\n >\n {children || 'Chat with us'}\n {showUnreadCount && unreadCount > 0 && (\n <span className=\"buni-chat-unread-badge\" aria-label={`${unreadCount} unread messages`}>\n {unreadCount}\n </span>\n )}\n </button>\n );\n};\n\n// Floating chat button with default styling\ninterface BuniChatFloatingButtonProps extends Omit<BuniChatButtonProps, 'children'> {\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n size?: 'small' | 'medium' | 'large';\n theme?: 'default' | 'minimal' | 'colorful';\n}\n\nexport const BuniChatFloatingButton: React.FC<BuniChatFloatingButtonProps> = ({\n position = 'bottom-right',\n size = 'medium',\n theme = 'default',\n className,\n style,\n ...props\n}) => {\n const baseStyles: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n borderRadius: '50%',\n border: 'none',\n cursor: 'pointer',\n transition: 'all 0.3s ease',\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n ...style,\n };\n\n // Position styles\n const positionStyles: Record<string, React.CSSProperties> = {\n 'bottom-right': { bottom: '20px', right: '20px' },\n 'bottom-left': { bottom: '20px', left: '20px' },\n 'top-right': { top: '20px', right: '20px' },\n 'top-left': { top: '20px', left: '20px' },\n };\n\n // Size styles\n const sizeStyles: Record<string, React.CSSProperties> = {\n small: { width: '48px', height: '48px', fontSize: '14px' },\n medium: { width: '60px', height: '60px', fontSize: '16px' },\n large: { width: '72px', height: '72px', fontSize: '18px' },\n };\n\n // Theme styles\n const themeStyles: Record<string, React.CSSProperties> = {\n default: { \n backgroundColor: '#007bff', \n color: 'white',\n },\n minimal: { \n backgroundColor: '#f8f9fa', \n color: '#333',\n border: '1px solid #dee2e6',\n },\n colorful: { \n background: 'linear-gradient(45deg, #007bff, #28a745)',\n color: 'white',\n },\n };\n\n const combinedStyles = {\n ...baseStyles,\n ...positionStyles[position],\n ...sizeStyles[size],\n ...themeStyles[theme],\n };\n\n return (\n <BuniChatButton\n className={`buni-chat-floating-button buni-chat-floating-button--${position} buni-chat-floating-button--${size} buni-chat-floating-button--${theme} ${className || ''}`}\n style={combinedStyles}\n {...props}\n >\n 💬\n </BuniChatButton>\n );\n};\n"],"names":["BuniChatWidget","_jsx","_jsxs"],"mappings":";;;;AA0BA,MAAM,eAAe,GAAG,aAAa,CAA6B,IAAI,CAAC,CAAC;AAQ3D,MAAA,gBAAgB,GAAoC,CAAC,EAChE,OAAO,EACP,QAAQ,EACT,KAAI;AACH,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAIA,gBAAc,EAAE,CAAC,CAAC;AACtD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB;AAChD,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,WAAW,EAAE,CAAC;AACf,KAAA,CAAC,CAAC;IACH,MAAM,CAA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AAe,EAAE,SAAS;AAC1B,YAAA,KAAK,EAAE,OAAO;AACf,SAAA;AACD,QAAA,OAAO,EAAE;AACP,YAAA,eAAe,EAAE,SAAS;AAC1B,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,MAAM,EAAE,mBAAmB;AAC5B,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,UAAU,EAAE,0CAA0C;AACtD,YAAA,KAAK,EAAE,OAAO;AACf,SAAA;KACF,CAAC;AAEF,IAAA,MAAM,cAAc,GAAG;AACrB,QAAA,GAAG,UAAU;QACb,GAAG,cAAc,CAAC,QAAQ,CAAC;QAC3B,GAAG,UAAU,CAAC,IAAI,CAAC;QACnB,GAAG,WAAW,CAAC,KAAK,CAAC;KACtB,CAAC;IAEF,QACEA,GAAC,CAAA,cAAc,EACb,EAAA,SAAS,EAAE,CAAwD,qDAAA,EAAA,QAAQ,CAA+B,4BAAA,EAAA,IAAI,CAA+B,4BAAA,EAAA,KAAK,IAAI,SAAS,IAAI,EAAE,CAAA,CAAE,EACvK,KAAK,EAAE,cAAc,EACjB,GAAA,KAAK,EAGM,QAAA,EAAA,cAAA,EAAA,CAAA,EACjB;AACJ;;;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var chatbotCore = require('@buni.ai/chatbot-core');
|
|
6
|
+
|
|
7
|
+
const BuniChatContext = react.createContext(null);
|
|
8
|
+
const BuniChatProvider = ({ options, children }) => {
|
|
9
|
+
const [widget] = react.useState(() => new chatbotCore.BuniChatWidget());
|
|
10
|
+
const [state, setState] = react.useState({
|
|
11
|
+
isOpen: false,
|
|
12
|
+
isLoaded: false,
|
|
13
|
+
isMinimized: false,
|
|
14
|
+
unreadCount: 0
|
|
15
|
+
});
|
|
16
|
+
const [isReady, setIsReady] = react.useState(false);
|
|
17
|
+
react.useEffect(() => {
|
|
18
|
+
const initWidget = async () => {
|
|
19
|
+
try {
|
|
20
|
+
await widget.initialize(options);
|
|
21
|
+
setIsReady(true);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('Failed to initialize BuniChat widget:', error);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
initWidget();
|
|
28
|
+
// Set up event listeners
|
|
29
|
+
const handleStateChange = () => {
|
|
30
|
+
setState(widget.getState());
|
|
31
|
+
};
|
|
32
|
+
widget.on('ready', handleStateChange);
|
|
33
|
+
widget.on('visibility_changed', handleStateChange);
|
|
34
|
+
widget.on('minimized', handleStateChange);
|
|
35
|
+
widget.on('maximized', handleStateChange);
|
|
36
|
+
widget.on('new_message', handleStateChange);
|
|
37
|
+
return () => {
|
|
38
|
+
widget.destroy();
|
|
39
|
+
};
|
|
40
|
+
}, [widget, options]);
|
|
41
|
+
return (jsxRuntime.jsx(BuniChatContext.Provider, { value: { widget, state, isReady }, children: children }));
|
|
42
|
+
};
|
|
43
|
+
// Main hook for using BuniChat
|
|
44
|
+
function useBuniChat(options) {
|
|
45
|
+
const context = react.useContext(BuniChatContext);
|
|
46
|
+
const [widget] = react.useState(() => new chatbotCore.BuniChatWidget());
|
|
47
|
+
const [state, setState] = react.useState({
|
|
48
|
+
isOpen: false,
|
|
49
|
+
isLoaded: false,
|
|
50
|
+
isMinimized: false,
|
|
51
|
+
unreadCount: 0
|
|
52
|
+
});
|
|
53
|
+
const [isReady, setIsReady] = react.useState(false);
|
|
54
|
+
// Use context widget if available, otherwise use standalone
|
|
55
|
+
const activeWidget = (context === null || context === void 0 ? void 0 : context.widget) || widget;
|
|
56
|
+
const activeState = (context === null || context === void 0 ? void 0 : context.state) || state;
|
|
57
|
+
const activeIsReady = (context === null || context === void 0 ? void 0 : context.isReady) || isReady;
|
|
58
|
+
react.useEffect(() => {
|
|
59
|
+
if (options && !context) {
|
|
60
|
+
// Initialize standalone widget
|
|
61
|
+
const initWidget = async () => {
|
|
62
|
+
try {
|
|
63
|
+
await activeWidget.initialize(options);
|
|
64
|
+
setIsReady(true);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error('Failed to initialize BuniChat widget:', error);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
initWidget();
|
|
71
|
+
const handleStateChange = () => {
|
|
72
|
+
setState(activeWidget.getState());
|
|
73
|
+
};
|
|
74
|
+
activeWidget.on('ready', handleStateChange);
|
|
75
|
+
activeWidget.on('visibility_changed', handleStateChange);
|
|
76
|
+
activeWidget.on('minimized', handleStateChange);
|
|
77
|
+
activeWidget.on('maximized', handleStateChange);
|
|
78
|
+
activeWidget.on('new_message', handleStateChange);
|
|
79
|
+
return () => {
|
|
80
|
+
activeWidget.destroy();
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}, [options, context, activeWidget]);
|
|
84
|
+
const show = react.useCallback(() => {
|
|
85
|
+
activeWidget.show();
|
|
86
|
+
}, [activeWidget]);
|
|
87
|
+
const hide = react.useCallback(() => {
|
|
88
|
+
activeWidget.hide();
|
|
89
|
+
}, [activeWidget]);
|
|
90
|
+
const toggle = react.useCallback(() => {
|
|
91
|
+
activeWidget.toggle();
|
|
92
|
+
}, [activeWidget]);
|
|
93
|
+
const minimize = react.useCallback(() => {
|
|
94
|
+
activeWidget.minimize();
|
|
95
|
+
}, [activeWidget]);
|
|
96
|
+
const maximize = react.useCallback(() => {
|
|
97
|
+
activeWidget.maximize();
|
|
98
|
+
}, [activeWidget]);
|
|
99
|
+
const setCustomerData = react.useCallback((data) => {
|
|
100
|
+
activeWidget.setCustomerData(data);
|
|
101
|
+
}, [activeWidget]);
|
|
102
|
+
const setSessionVariables = react.useCallback((variables) => {
|
|
103
|
+
activeWidget.setSessionVariables(variables);
|
|
104
|
+
}, [activeWidget]);
|
|
105
|
+
const sendMessage = react.useCallback((message) => {
|
|
106
|
+
activeWidget.sendMessage(message);
|
|
107
|
+
}, [activeWidget]);
|
|
108
|
+
return {
|
|
109
|
+
// State
|
|
110
|
+
...activeState,
|
|
111
|
+
isReady: activeIsReady,
|
|
112
|
+
// Actions
|
|
113
|
+
show,
|
|
114
|
+
hide,
|
|
115
|
+
toggle,
|
|
116
|
+
minimize,
|
|
117
|
+
maximize,
|
|
118
|
+
setCustomerData,
|
|
119
|
+
setSessionVariables,
|
|
120
|
+
sendMessage,
|
|
121
|
+
// Direct widget access
|
|
122
|
+
widget: activeWidget
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// Hook for widget events
|
|
126
|
+
function useWidgetEvents() {
|
|
127
|
+
const { widget } = useBuniChat();
|
|
128
|
+
const on = react.useCallback((event, callback) => {
|
|
129
|
+
widget === null || widget === void 0 ? void 0 : widget.on(event, callback);
|
|
130
|
+
}, [widget]);
|
|
131
|
+
const off = react.useCallback((event, callback) => {
|
|
132
|
+
widget === null || widget === void 0 ? void 0 : widget.off(event, callback);
|
|
133
|
+
}, [widget]);
|
|
134
|
+
return { on, off };
|
|
135
|
+
}
|
|
136
|
+
// Hook for customer data management
|
|
137
|
+
function useCustomerData() {
|
|
138
|
+
const { widget } = useBuniChat();
|
|
139
|
+
const [customerData, setCustomerDataState] = react.useState(null);
|
|
140
|
+
const setCustomerData = react.useCallback((data) => {
|
|
141
|
+
widget === null || widget === void 0 ? void 0 : widget.setCustomerData(data);
|
|
142
|
+
setCustomerDataState(data);
|
|
143
|
+
}, [widget]);
|
|
144
|
+
const getCustomerData = react.useCallback(() => {
|
|
145
|
+
return (widget === null || widget === void 0 ? void 0 : widget.getCustomerData()) || null;
|
|
146
|
+
}, [widget]);
|
|
147
|
+
react.useEffect(() => {
|
|
148
|
+
if (widget) {
|
|
149
|
+
const handleCustomerDataUpdate = (event) => {
|
|
150
|
+
setCustomerDataState(event.data);
|
|
151
|
+
};
|
|
152
|
+
widget.on('customer_data_updated', handleCustomerDataUpdate);
|
|
153
|
+
return () => {
|
|
154
|
+
widget.off('customer_data_updated', handleCustomerDataUpdate);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}, [widget]);
|
|
158
|
+
return {
|
|
159
|
+
customerData,
|
|
160
|
+
setCustomerData,
|
|
161
|
+
getCustomerData
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const BuniChatWidget = ({ className, style, config }) => {
|
|
166
|
+
const { isReady, isOpen } = useBuniChat();
|
|
167
|
+
if (!isReady) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return (jsxRuntime.jsx("div", { className: `buni-chat-widget ${className || ''}`, style: style, "data-widget-open": isOpen, id: "buni-chat-widget-container" }));
|
|
171
|
+
};
|
|
172
|
+
const BuniChatButton = ({ onClick, children, className, style, disabled = false, showUnreadCount = true }) => {
|
|
173
|
+
const { toggle, unreadCount } = useBuniChat();
|
|
174
|
+
const handleClick = () => {
|
|
175
|
+
if (onClick) {
|
|
176
|
+
onClick();
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
toggle();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
return (jsxRuntime.jsxs("button", { className: `buni-chat-button ${className || ''}`, style: style, onClick: handleClick, disabled: disabled, "aria-label": "Open chat widget", children: [children || 'Chat with us', showUnreadCount && unreadCount > 0 && (jsxRuntime.jsx("span", { className: "buni-chat-unread-badge", "aria-label": `${unreadCount} unread messages`, children: unreadCount }))] }));
|
|
183
|
+
};
|
|
184
|
+
const BuniChatFloatingButton = ({ position = 'bottom-right', size = 'medium', theme = 'default', className, style, ...props }) => {
|
|
185
|
+
const baseStyles = {
|
|
186
|
+
position: 'fixed',
|
|
187
|
+
zIndex: 1000,
|
|
188
|
+
borderRadius: '50%',
|
|
189
|
+
border: 'none',
|
|
190
|
+
cursor: 'pointer',
|
|
191
|
+
transition: 'all 0.3s ease',
|
|
192
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
193
|
+
...style,
|
|
194
|
+
};
|
|
195
|
+
// Position styles
|
|
196
|
+
const positionStyles = {
|
|
197
|
+
'bottom-right': { bottom: '20px', right: '20px' },
|
|
198
|
+
'bottom-left': { bottom: '20px', left: '20px' },
|
|
199
|
+
'top-right': { top: '20px', right: '20px' },
|
|
200
|
+
'top-left': { top: '20px', left: '20px' },
|
|
201
|
+
};
|
|
202
|
+
// Size styles
|
|
203
|
+
const sizeStyles = {
|
|
204
|
+
small: { width: '48px', height: '48px', fontSize: '14px' },
|
|
205
|
+
medium: { width: '60px', height: '60px', fontSize: '16px' },
|
|
206
|
+
large: { width: '72px', height: '72px', fontSize: '18px' },
|
|
207
|
+
};
|
|
208
|
+
// Theme styles
|
|
209
|
+
const themeStyles = {
|
|
210
|
+
default: {
|
|
211
|
+
backgroundColor: '#007bff',
|
|
212
|
+
color: 'white',
|
|
213
|
+
},
|
|
214
|
+
minimal: {
|
|
215
|
+
backgroundColor: '#f8f9fa',
|
|
216
|
+
color: '#333',
|
|
217
|
+
border: '1px solid #dee2e6',
|
|
218
|
+
},
|
|
219
|
+
colorful: {
|
|
220
|
+
background: 'linear-gradient(45deg, #007bff, #28a745)',
|
|
221
|
+
color: 'white',
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
const combinedStyles = {
|
|
225
|
+
...baseStyles,
|
|
226
|
+
...positionStyles[position],
|
|
227
|
+
...sizeStyles[size],
|
|
228
|
+
...themeStyles[theme],
|
|
229
|
+
};
|
|
230
|
+
return (jsxRuntime.jsx(BuniChatButton, { className: `buni-chat-floating-button buni-chat-floating-button--${position} buni-chat-floating-button--${size} buni-chat-floating-button--${theme} ${className || ''}`, style: combinedStyles, ...props, children: "\uD83D\uDCAC" }));
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
exports.BuniChatButton = BuniChatButton;
|
|
234
|
+
exports.BuniChatFloatingButton = BuniChatFloatingButton;
|
|
235
|
+
exports.BuniChatProvider = BuniChatProvider;
|
|
236
|
+
exports.BuniChatWidget = BuniChatWidget;
|
|
237
|
+
exports.useBuniChat = useBuniChat;
|
|
238
|
+
exports.useCustomerData = useCustomerData;
|
|
239
|
+
exports.useWidgetEvents = useWidgetEvents;
|
|
240
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/hooks.tsx","../src/components.tsx"],"sourcesContent":["// @buni.ai/chatbot-react - React hooks and components\n\nimport React, { \n createContext, \n useContext, \n useEffect, \n useState, \n useCallback,\n ReactNode \n} from 'react';\nimport { \n BuniChatWidget, \n BuniChatOptions, \n BuniChatState, \n CustomerData, \n SessionVariables,\n BuniChatConfig\n} from '@buni.ai/chatbot-core';\n\n// Context for providing widget instance\ninterface BuniChatContextType {\n widget: BuniChatWidget | null;\n state: BuniChatState;\n isReady: boolean;\n}\n\nconst BuniChatContext = createContext<BuniChatContextType | null>(null);\n\n// Provider component\ninterface BuniChatProviderProps {\n options: BuniChatOptions;\n children: ReactNode;\n}\n\nexport const BuniChatProvider: React.FC<BuniChatProviderProps> = ({ \n options, \n children \n}) => {\n const [widget] = useState(() => new BuniChatWidget());\n const [state, setState] = useState<BuniChatState>({\n isOpen: false,\n isLoaded: false,\n isMinimized: false,\n unreadCount: 0\n });\n const [isReady, setIsReady] = useState(false);\n\n useEffect(() => {\n const initWidget = async () => {\n try {\n await widget.initialize(options);\n setIsReady(true);\n } catch (error) {\n console.error('Failed to initialize BuniChat widget:', error);\n }\n };\n\n initWidget();\n\n // Set up event listeners\n const handleStateChange = () => {\n setState(widget.getState());\n };\n\n widget.on('ready', handleStateChange);\n widget.on('visibility_changed', handleStateChange);\n widget.on('minimized', handleStateChange);\n widget.on('maximized', handleStateChange);\n widget.on('new_message', handleStateChange);\n\n return () => {\n widget.destroy();\n };\n }, [widget, options]);\n\n return (\n <BuniChatContext.Provider value={{ widget, state, isReady }}>\n {children}\n </BuniChatContext.Provider>\n );\n};\n\n// Main hook for using BuniChat\nexport function useBuniChat(options?: BuniChatOptions) {\n const context = useContext(BuniChatContext);\n const [widget] = useState(() => new BuniChatWidget());\n const [state, setState] = useState<BuniChatState>({\n isOpen: false,\n isLoaded: false,\n isMinimized: false,\n unreadCount: 0\n });\n const [isReady, setIsReady] = useState(false);\n\n // Use context widget if available, otherwise use standalone\n const activeWidget = context?.widget || widget;\n const activeState = context?.state || state;\n const activeIsReady = context?.isReady || isReady;\n\n useEffect(() => {\n if (options && !context) {\n // Initialize standalone widget\n const initWidget = async () => {\n try {\n await activeWidget.initialize(options);\n setIsReady(true);\n } catch (error) {\n console.error('Failed to initialize BuniChat widget:', error);\n }\n };\n\n initWidget();\n\n const handleStateChange = () => {\n setState(activeWidget.getState());\n };\n\n activeWidget.on('ready', handleStateChange);\n activeWidget.on('visibility_changed', handleStateChange);\n activeWidget.on('minimized', handleStateChange);\n activeWidget.on('maximized', handleStateChange);\n activeWidget.on('new_message', handleStateChange);\n\n return () => {\n activeWidget.destroy();\n };\n }\n }, [options, context, activeWidget]);\n\n const show = useCallback(() => {\n activeWidget.show();\n }, [activeWidget]);\n\n const hide = useCallback(() => {\n activeWidget.hide();\n }, [activeWidget]);\n\n const toggle = useCallback(() => {\n activeWidget.toggle();\n }, [activeWidget]);\n\n const minimize = useCallback(() => {\n activeWidget.minimize();\n }, [activeWidget]);\n\n const maximize = useCallback(() => {\n activeWidget.maximize();\n }, [activeWidget]);\n\n const setCustomerData = useCallback((data: CustomerData) => {\n activeWidget.setCustomerData(data);\n }, [activeWidget]);\n\n const setSessionVariables = useCallback((variables: SessionVariables) => {\n activeWidget.setSessionVariables(variables);\n }, [activeWidget]);\n\n const sendMessage = useCallback((message: string) => {\n activeWidget.sendMessage(message);\n }, [activeWidget]);\n\n return {\n // State\n ...activeState,\n isReady: activeIsReady,\n \n // Actions\n show,\n hide,\n toggle,\n minimize,\n maximize,\n setCustomerData,\n setSessionVariables,\n sendMessage,\n \n // Direct widget access\n widget: activeWidget\n };\n}\n\n// Hook for widget events\nexport function useWidgetEvents() {\n const { widget } = useBuniChat();\n \n const on = useCallback((event: string, callback: Function) => {\n widget?.on(event, callback);\n }, [widget]);\n \n const off = useCallback((event: string, callback?: Function) => {\n widget?.off(event, callback);\n }, [widget]);\n \n return { on, off };\n}\n\n// Hook for customer data management\nexport function useCustomerData() {\n const { widget } = useBuniChat();\n const [customerData, setCustomerDataState] = useState<CustomerData | null>(null);\n \n const setCustomerData = useCallback((data: CustomerData) => {\n widget?.setCustomerData(data);\n setCustomerDataState(data);\n }, [widget]);\n \n const getCustomerData = useCallback(() => {\n return widget?.getCustomerData() || null;\n }, [widget]);\n \n useEffect(() => {\n if (widget) {\n const handleCustomerDataUpdate = (event: { data: CustomerData }) => {\n setCustomerDataState(event.data);\n };\n \n widget.on('customer_data_updated', handleCustomerDataUpdate);\n \n return () => {\n widget.off('customer_data_updated', handleCustomerDataUpdate);\n };\n }\n }, [widget]);\n \n return {\n customerData,\n setCustomerData,\n getCustomerData\n };\n}\n","// Components for @buni.ai/chatbot-react\n\nimport React, { ReactNode } from 'react';\nimport { useBuniChat } from './hooks';\nimport { BuniChatConfig } from '@buni.ai/chatbot-core';\n\n// Widget component\ninterface BuniChatWidgetProps {\n className?: string;\n style?: React.CSSProperties;\n config?: BuniChatConfig;\n}\n\nexport const BuniChatWidget: React.FC<BuniChatWidgetProps> = ({ \n className,\n style,\n config \n}) => {\n const { isReady, isOpen } = useBuniChat();\n \n if (!isReady) {\n return null;\n }\n \n return (\n <div \n className={`buni-chat-widget ${className || ''}`}\n style={style}\n data-widget-open={isOpen}\n id=\"buni-chat-widget-container\"\n >\n {/* Widget will be rendered here by the core widget */}\n </div>\n );\n};\n\n// Chat button component\ninterface BuniChatButtonProps {\n onClick?: () => void;\n children?: ReactNode;\n className?: string;\n style?: React.CSSProperties;\n disabled?: boolean;\n showUnreadCount?: boolean;\n}\n\nexport const BuniChatButton: React.FC<BuniChatButtonProps> = ({\n onClick,\n children,\n className,\n style,\n disabled = false,\n showUnreadCount = true\n}) => {\n const { toggle, unreadCount } = useBuniChat();\n \n const handleClick = () => {\n if (onClick) {\n onClick();\n } else {\n toggle();\n }\n };\n \n return (\n <button\n className={`buni-chat-button ${className || ''}`}\n style={style}\n onClick={handleClick}\n disabled={disabled}\n aria-label=\"Open chat widget\"\n >\n {children || 'Chat with us'}\n {showUnreadCount && unreadCount > 0 && (\n <span className=\"buni-chat-unread-badge\" aria-label={`${unreadCount} unread messages`}>\n {unreadCount}\n </span>\n )}\n </button>\n );\n};\n\n// Floating chat button with default styling\ninterface BuniChatFloatingButtonProps extends Omit<BuniChatButtonProps, 'children'> {\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n size?: 'small' | 'medium' | 'large';\n theme?: 'default' | 'minimal' | 'colorful';\n}\n\nexport const BuniChatFloatingButton: React.FC<BuniChatFloatingButtonProps> = ({\n position = 'bottom-right',\n size = 'medium',\n theme = 'default',\n className,\n style,\n ...props\n}) => {\n const baseStyles: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n borderRadius: '50%',\n border: 'none',\n cursor: 'pointer',\n transition: 'all 0.3s ease',\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n ...style,\n };\n\n // Position styles\n const positionStyles: Record<string, React.CSSProperties> = {\n 'bottom-right': { bottom: '20px', right: '20px' },\n 'bottom-left': { bottom: '20px', left: '20px' },\n 'top-right': { top: '20px', right: '20px' },\n 'top-left': { top: '20px', left: '20px' },\n };\n\n // Size styles\n const sizeStyles: Record<string, React.CSSProperties> = {\n small: { width: '48px', height: '48px', fontSize: '14px' },\n medium: { width: '60px', height: '60px', fontSize: '16px' },\n large: { width: '72px', height: '72px', fontSize: '18px' },\n };\n\n // Theme styles\n const themeStyles: Record<string, React.CSSProperties> = {\n default: { \n backgroundColor: '#007bff', \n color: 'white',\n },\n minimal: { \n backgroundColor: '#f8f9fa', \n color: '#333',\n border: '1px solid #dee2e6',\n },\n colorful: { \n background: 'linear-gradient(45deg, #007bff, #28a745)',\n color: 'white',\n },\n };\n\n const combinedStyles = {\n ...baseStyles,\n ...positionStyles[position],\n ...sizeStyles[size],\n ...themeStyles[theme],\n };\n\n return (\n <BuniChatButton\n className={`buni-chat-floating-button buni-chat-floating-button--${position} buni-chat-floating-button--${size} buni-chat-floating-button--${theme} ${className || ''}`}\n style={combinedStyles}\n {...props}\n >\n 💬\n </BuniChatButton>\n );\n};\n"],"names":["createContext","useState","BuniChatWidget","useEffect","_jsx","useContext","useCallback","_jsxs"],"mappings":";;;;;;AA0BA,MAAM,eAAe,GAAGA,mBAAa,CAA6B,IAAI,CAAC,CAAC;AAQ3D,MAAA,gBAAgB,GAAoC,CAAC,EAChE,OAAO,EACP,QAAQ,EACT,KAAI;AACH,IAAA,MAAM,CAAC,MAAM,CAAC,GAAGC,cAAQ,CAAC,MAAM,IAAIC,0BAAc,EAAE,CAAC,CAAC;AACtD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGD,cAAQ,CAAgB;AAChD,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,WAAW,EAAE,CAAC;AACf,KAAA,CAAC,CAAC;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,CAAC;IAE9CE,eAAS,CAAC,MAAK;AACb,QAAA,MAAM,UAAU,GAAG,YAAW;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBACjC,UAAU,CAAC,IAAI,CAAC,CAAC;aAClB;YAAC,OAAO,KAAK,EAAE;AACd,gBAAA,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;aAC/D;AACH,SAAC,CAAC;AAEF,QAAA,UAAU,EAAE,CAAC;;QAGb,MAAM,iBAAiB,GAAG,MAAK;AAC7B,YAAA,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9B,SAAC,CAAC;AAEF,Q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QACEA,cAAC,CAAA,cAAc,EACb,EAAA,SAAS,EAAE,CAAwD,qDAAA,EAAA,QAAQ,CAA+B,4BAAA,EAAA,IAAI,CAA+B,4BAAA,EAAA,KAAK,IAAI,SAAS,IAAI,EAAE,CAAA,CAAE,EACvK,KAAK,EAAE,cAAc,EACjB,GAAA,KAAK,EAGM,QAAA,EAAA,cAAA,EAAA,CAAA,EACjB;AACJ;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@buni.ai/chatbot-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React components and hooks for BuniAI chat widget",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.cjs.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rollup -c",
|
|
21
|
+
"dev": "rollup -c -w",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
24
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"react",
|
|
28
|
+
"chat",
|
|
29
|
+
"widget",
|
|
30
|
+
"buni",
|
|
31
|
+
"ai",
|
|
32
|
+
"customer-support"
|
|
33
|
+
],
|
|
34
|
+
"author": "BuniAI",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">=16.8.0",
|
|
38
|
+
"react-dom": ">=16.8.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@buni.ai/chatbot-core": "^1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
45
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
46
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
47
|
+
"@types/react": "^18.0.0",
|
|
48
|
+
"@types/react-dom": "^18.0.0",
|
|
49
|
+
"react": "^18.0.0",
|
|
50
|
+
"react-dom": "^18.0.0",
|
|
51
|
+
"rollup": "^3.20.0",
|
|
52
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
53
|
+
"tslib": "^2.5.0",
|
|
54
|
+
"typescript": "^5.0.0"
|
|
55
|
+
}
|
|
56
|
+
}
|