@fusioni/client-sdk 1.1.5 → 1.1.8
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 +70 -5
- package/dist/browser.d.ts +3 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/components/ChatWidget.d.ts +2 -2
- package/dist/components/ChatWidget.d.ts.map +1 -1
- package/dist/components/Message.d.ts.map +1 -1
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/fusioni-sdk.umd.js +345 -273
- package/dist/fusioni-sdk.umd.js.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +342 -277
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +341 -276
- package/dist/index.js.map +1 -1
- package/dist/services/SDKClientService.d.ts +6 -3
- package/dist/services/SDKClientService.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,9 +105,11 @@ When including via `<script src="...">`, the SDK exposes a global `Fusioni` obje
|
|
|
105
105
|
position: 'bottom-right',
|
|
106
106
|
primaryColor: '#6366f1'
|
|
107
107
|
});
|
|
108
|
-
// Optional: unmount later
|
|
108
|
+
// Optional: unmount or change language/theme later
|
|
109
109
|
// const result = Fusioni.mount('#my-chat', config);
|
|
110
110
|
// result.unmount();
|
|
111
|
+
// result.setLanguage('el');
|
|
112
|
+
// result.setTheme('auto');
|
|
111
113
|
</script>
|
|
112
114
|
```
|
|
113
115
|
|
|
@@ -115,10 +117,68 @@ When including via `<script src="...">`, the SDK exposes a global `Fusioni` obje
|
|
|
115
117
|
|
|
116
118
|
| Method | Description |
|
|
117
119
|
|--------|-------------|
|
|
118
|
-
| `Fusioni.init(config)` | Mounts the chat widget with default placement (creates `#fusioni-chat-root`). Returns `
|
|
119
|
-
| `Fusioni.mount(container, config)` | Mounts into `container` (CSS selector string or `HTMLElement`). Returns `
|
|
120
|
+
| `Fusioni.init(config)` | Mounts the chat widget with default placement (creates `#fusioni-chat-root`). Returns [`FusioniMountResult`](#changing-language-and-theme-after-init). |
|
|
121
|
+
| `Fusioni.mount(container, config)` | Mounts into `container` (CSS selector string or `HTMLElement`). Returns [`FusioniMountResult`](#changing-language-and-theme-after-init). |
|
|
120
122
|
| `Fusioni.version` | SDK version string. |
|
|
121
123
|
|
|
124
|
+
### Changing language and theme after init
|
|
125
|
+
|
|
126
|
+
`Fusioni.init` and `Fusioni.mount` return the same handle (in TypeScript: `FusioniMountResult`), which includes **`setLanguage`** and **`setTheme`** so you can switch locale or appearance without remounting.
|
|
127
|
+
|
|
128
|
+
| Property / method | Description |
|
|
129
|
+
|-------------------|-------------|
|
|
130
|
+
| `unmount()` | Removes the widget and cleans up the React root. |
|
|
131
|
+
| `setLanguage(language)` | Sets UI language to `'en'` or `'el'`. Invalid values are ignored. |
|
|
132
|
+
| `setTheme(theme)` | Sets appearance to `'light'`, `'dark'`, or `'auto'` (follows system preference). Persists like the in-widget theme control. |
|
|
133
|
+
|
|
134
|
+
**Script example:**
|
|
135
|
+
|
|
136
|
+
```html
|
|
137
|
+
<script src="path/to/fusioni-sdk.umd.js"></script>
|
|
138
|
+
<script>
|
|
139
|
+
const chat = Fusioni.init({
|
|
140
|
+
apiBaseUrl: 'https://your-fusioni-api.com',
|
|
141
|
+
agencyId: 'your-agency-id',
|
|
142
|
+
theme: 'light',
|
|
143
|
+
language: 'en'
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
document.getElementById('locale-el').addEventListener('click', () => {
|
|
147
|
+
chat.setLanguage('el');
|
|
148
|
+
});
|
|
149
|
+
document.getElementById('theme-dark').addEventListener('click', () => {
|
|
150
|
+
chat.setTheme('dark');
|
|
151
|
+
});
|
|
152
|
+
</script>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**React (npm) example:** pass a ref to `ChatWidget` and call the same methods (type: `FusioniChatWidgetHandle`).
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { useRef } from 'react';
|
|
159
|
+
import { ChatWidget, type FusioniChatWidgetHandle, type FusioniSDKConfig } from '@fusioni/client-sdk';
|
|
160
|
+
|
|
161
|
+
function App() {
|
|
162
|
+
const chatRef = useRef<FusioniChatWidgetHandle>(null);
|
|
163
|
+
const config: FusioniSDKConfig = {
|
|
164
|
+
apiBaseUrl: 'https://your-fusioni-api.com',
|
|
165
|
+
agencyId: 'your-agency-id',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<>
|
|
170
|
+
<button type="button" onClick={() => chatRef.current?.setLanguage('el')}>
|
|
171
|
+
Greek
|
|
172
|
+
</button>
|
|
173
|
+
<button type="button" onClick={() => chatRef.current?.setTheme('dark')}>
|
|
174
|
+
Dark mode
|
|
175
|
+
</button>
|
|
176
|
+
<ChatWidget ref={chatRef} config={config} />
|
|
177
|
+
</>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
122
182
|
### Advanced Usage with Event Handlers
|
|
123
183
|
|
|
124
184
|
```tsx
|
|
@@ -187,7 +247,11 @@ export default App;
|
|
|
187
247
|
| `apiBaseUrl` | `string` | **Required** | Base URL of your Fusioni API |
|
|
188
248
|
| `agencyId` | `string` | **Required** | Your agency ID |
|
|
189
249
|
| `accessToken` | `string` | `undefined` | Optional access token for authentication |
|
|
190
|
-
| `theme` | `'light' \| 'dark' \| 'auto'` | `'light'` | UI theme preference |
|
|
250
|
+
| `theme` | `'light' \| 'dark' \| 'auto'` | `'light'` | UI theme preference (can be changed later via [`setTheme`](#changing-language-and-theme-after-init)) |
|
|
251
|
+
| `language` | `'en' \| 'el'` | `'en'` | UI copy language (can be changed later via [`setLanguage`](#changing-language-and-theme-after-init)) |
|
|
252
|
+
| `showThemeToggle` | `boolean` | `true` | Show/hide the theme toggle button in the chat header |
|
|
253
|
+
| `showFullscreenToggle` | `boolean` | `true` | Show/hide the fullscreen toggle button in the chat header |
|
|
254
|
+
| `showLanguageSwitcher` | `boolean` | `true` | Show/hide the language switcher in the chat header |
|
|
191
255
|
| `position` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left'` | `'bottom-right'` | Position of the floating button |
|
|
192
256
|
| `primaryColor` | `string` | `'#6366f1'` | Primary color for the UI |
|
|
193
257
|
| `showConversationList` | `boolean` | `true` | Whether to show the conversation sidebar |
|
|
@@ -195,6 +259,7 @@ export default App;
|
|
|
195
259
|
| `enableFileUpload` | `boolean` | `true` | Enable file upload functionality |
|
|
196
260
|
| `maxFileSize` | `number` | `10` | Maximum file size in MB |
|
|
197
261
|
| `allowedFileTypes` | `string[]` | `['image/*']` | Allowed MIME types for uploads |
|
|
262
|
+
| `buttonVariant` | `'minimal' \| 'glass' \| 'solid'` | `'glass'` | Floating launcher button style |
|
|
198
263
|
|
|
199
264
|
## Event Handlers
|
|
200
265
|
|
|
@@ -386,4 +451,4 @@ For support and questions:
|
|
|
386
451
|
|
|
387
452
|
./fusioni-client-sdk && npm run build && npm link
|
|
388
453
|
|
|
389
|
-
./
|
|
454
|
+
./fusion-client-sdk-example && npm link @fusioni/client-sdk
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { FusioniSDKConfig } from './types';
|
|
1
|
+
import type { FusioniChatWidgetHandle, FusioniSDKConfig } from './types';
|
|
2
2
|
import './styles/index.css';
|
|
3
3
|
export interface FusioniScriptConfig extends FusioniSDKConfig {
|
|
4
4
|
}
|
|
5
5
|
export interface FusioniMountResult {
|
|
6
6
|
unmount: () => void;
|
|
7
|
+
setLanguage: FusioniChatWidgetHandle['setLanguage'];
|
|
8
|
+
setTheme: FusioniChatWidgetHandle['setTheme'];
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Mount the chat widget into a container.
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,oBAAoB,CAAC;AAI5B,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;CAAG;AAEhE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,uBAAuB,CAAC,aAAa,CAAC,CAAC;IACpD,QAAQ,EAAE,uBAAuB,CAAC,UAAU,CAAC,CAAC;CAC/C;AA4BD;;;;;GAKG;AACH,iBAAS,KAAK,CACZ,SAAS,EAAE,MAAM,GAAG,WAAW,EAC/B,MAAM,EAAE,mBAAmB,GAC1B,kBAAkB,CAmBpB;AAED;;;;;GAKG;AACH,iBAAS,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,kBAAkB,CAG7D;AAED,QAAA,MAAM,OAAO;;;;CAIZ,CAAC;AAMF,eAAe,OAAO,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ChatWidgetProps } from '../types';
|
|
2
|
+
import { ChatWidgetProps, FusioniChatWidgetHandle } from '../types';
|
|
3
3
|
import '../styles/index.css';
|
|
4
|
-
export declare const ChatWidget: React.
|
|
4
|
+
export declare const ChatWidget: React.ForwardRefExoticComponent<ChatWidgetProps & React.RefAttributes<FusioniChatWidgetHandle>>;
|
|
5
5
|
//# sourceMappingURL=ChatWidget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkF,MAAM,OAAO,CAAC;AACvG,OAAO,EACL,eAAe,EAEf,uBAAuB,EAGxB,MAAM,UAAU,CAAC;AAmBlB,OAAO,qBAAqB,CAAC;AAE7B,eAAO,MAAM,UAAU,iGAu0BrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../src/components/Message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AA6LtC,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../src/components/Message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AA6LtC,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA0gB1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../src/components/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAQhD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IACjC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC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