@kaifusion/widget 1.0.3 → 1.0.5
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 +58 -9
- package/dist/widget.iife.js +452 -0
- package/package.json +10 -1
- package/src/KaiChatWidget.tsx +78 -34
- package/src/embed.tsx +94 -0
- package/src/index.css +2 -0
- package/dist/KaiChatWidget.d.ts +0 -10
- package/dist/index.d.ts +0 -2
- package/dist/index.es.js +0 -66505
- package/dist/index.es.js.map +0 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ function App() {
|
|
|
49
49
|
title="KAI Assistant" // (Optional) Widget title
|
|
50
50
|
position="right" // (Optional) 'left' or 'right'
|
|
51
51
|
color="#526cfe" // (Optional) Main theme color hex code
|
|
52
|
-
icon={
|
|
52
|
+
icon={"💬"} // (Optional) Custom icon for the toggle button
|
|
53
53
|
/>
|
|
54
54
|
</div>
|
|
55
55
|
);
|
|
@@ -60,11 +60,60 @@ export default App;
|
|
|
60
60
|
|
|
61
61
|
## Props
|
|
62
62
|
|
|
63
|
-
| Prop | Type | Required | Default
|
|
64
|
-
| ------------ | ------------------- | -------- |
|
|
65
|
-
| `targetUrl` | `string` | **Yes** | -
|
|
66
|
-
| `workflowId` | `string` | **Yes** | -
|
|
67
|
-
| `authToken` | `string` | **Yes** | -
|
|
68
|
-
| `title` | `string` | No | `"ChatBot"`
|
|
69
|
-
| `position` | `"left" \| "right"` | No | `"right"`
|
|
70
|
-
| `color` | `string` | No | `"#526cfe"`
|
|
63
|
+
| Prop | Type | Required | Default | Description |
|
|
64
|
+
| ------------ | ------------------- | -------- | --------------- | ---------------------------------------------------------------------------- |
|
|
65
|
+
| `targetUrl` | `string` | **Yes** | - | The address of the KAI Fusion backend API (e.g., `https://api.example.com`). |
|
|
66
|
+
| `workflowId` | `string` | **Yes** | - | Unique identifier (UUID) of the workflow to run. |
|
|
67
|
+
| `authToken` | `string` | **Yes** | - | Bearer token or API Key for API access. |
|
|
68
|
+
| `title` | `string` | No | `"ChatBot"` | Title of the widget window. |
|
|
69
|
+
| `position` | `"left" \| "right"` | No | `"right"` | Position of the widget on the screen (bottom-left or bottom-right). |
|
|
70
|
+
| `color` | `string` | No | `"#526cfe"` | Main theme color of the widget (Hex code). |
|
|
71
|
+
| `icon` | `ReactNode` | No | `MessageSquare` | Custom icon for the toggle button. |
|
|
72
|
+
|
|
73
|
+
## Standalone Usage (HTML / MkDocs)
|
|
74
|
+
|
|
75
|
+
You can also use the widget in non-React projects or static sites (like MkDocs) by including the standalone script.
|
|
76
|
+
|
|
77
|
+
### HTML Integration
|
|
78
|
+
|
|
79
|
+
Add the following script tag to your HTML file:
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<script
|
|
83
|
+
src="/widget.iife.js"
|
|
84
|
+
data-title="KAI Fusion Assistant"
|
|
85
|
+
data-auth-token="your-auth-token"
|
|
86
|
+
data-workflow-id="your-workflow-id"
|
|
87
|
+
data-target-url="http://localhost:8000"
|
|
88
|
+
data-position="right"
|
|
89
|
+
data-color="#526cfe"
|
|
90
|
+
defer
|
|
91
|
+
></script>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### MkDocs Integration
|
|
95
|
+
|
|
96
|
+
For MkDocs, you can inject the script dynamically using JavaScript.
|
|
97
|
+
|
|
98
|
+
1. Create a javascript file (e.g `docs/js/kai-widget.js`) with the following content:
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
102
|
+
const script = document.createElement("script");
|
|
103
|
+
script.src = "/widget.iife.js"; // Adjust URL to your source
|
|
104
|
+
script.dataset.title = "KAI Fusion Assistant";
|
|
105
|
+
script.dataset.authToken = "your-auth-token";
|
|
106
|
+
script.dataset.workflowId = "your-workflow-id";
|
|
107
|
+
script.dataset.targetUrl = "http://localhost:8000";
|
|
108
|
+
script.dataset.position = "right";
|
|
109
|
+
script.dataset.color = "#526cfe";
|
|
110
|
+
document.body.appendChild(script);
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
2. Register the script in your `mkdocs.yml`:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
extra_javascript:
|
|
118
|
+
- js/kai-widget.js
|
|
119
|
+
```
|