@xpert-ai/chatkit-web-component 0.0.1

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 ADDED
@@ -0,0 +1,172 @@
1
+ # Xpert Chatkit Web Component
2
+
3
+ A native Web Component for embedding Xpert Chatkit into any web application.
4
+
5
+ ## Features
6
+
7
+ - 🚀 Zero dependencies - pure native Web Component
8
+ - 📦 Lightweight and tree-shakeable
9
+ - 🎨 Style configuration support via JSON schema
10
+ - 🔒 Secure session management
11
+ - ⚡ Loading and error states built-in
12
+ - 🌐 Works with any framework (React, Vue, Angular, vanilla JS)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @xpert-ai/chatkit-web-component
18
+ ```
19
+
20
+ Or use via CDN:
21
+
22
+ ```html
23
+ <script src="https://unpkg.com/@xpert-ai/chatkit-web-component/dist/xpert-chatkit.js"></script>
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Basic Example
29
+
30
+ ```html
31
+ <!DOCTYPE html>
32
+ <html>
33
+ <head>
34
+ <script src="https://unpkg.com/@xpert-ai/chatkit-web-component/dist/xpert-chatkit.js"></script>
35
+ <style>
36
+ xpert-chatkit {
37
+ width: 100%;
38
+ height: 600px;
39
+ }
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <xpert-chatkit
44
+ backend-url="https://your-backend.com"
45
+ chatkit-url="https://chatkit.xpert.ai"
46
+ assistant-id="assistant_123">
47
+ </xpert-chatkit>
48
+ </body>
49
+ </html>
50
+ ```
51
+
52
+ ### With Style Configuration
53
+
54
+ ```html
55
+ <xpert-chatkit
56
+ backend-url="https://your-backend.com"
57
+ chatkit-url="https://chatkit.xpert.ai"
58
+ assistant-id="assistant_123"
59
+ style-config='{"primaryColor": "#007bff", "fontSize": "14px"}'>
60
+ </xpert-chatkit>
61
+ ```
62
+
63
+ ### Programmatic Usage
64
+
65
+ ```javascript
66
+ import '@xpert-ai/chatkit-web-component';
67
+
68
+ // Create element
69
+ const chatkit = document.createElement('xpert-chatkit');
70
+ chatkit.setAttribute('backend-url', 'https://your-backend.com');
71
+ chatkit.setAttribute('chatkit-url', 'https://chatkit.xpert.ai');
72
+ chatkit.setAttribute('assistant-id', 'assistant_123');
73
+
74
+ // Update style config
75
+ chatkit.updateStyleConfig({
76
+ primaryColor: '#007bff',
77
+ fontSize: '14px'
78
+ });
79
+
80
+ document.body.appendChild(chatkit);
81
+ ```
82
+
83
+ ## Attributes
84
+
85
+ | Attribute | Required | Description |
86
+ |-----------|----------|-------------|
87
+ | `backend-url` | Yes | Backend API URL for session creation |
88
+ | `chatkit-url` | Yes | Chatkit iframe URL |
89
+ | `assistant-id` | No | Assistant ID to use |
90
+ | `style-config` | No | JSON string for style configuration |
91
+
92
+ ## Methods
93
+
94
+ ### `updateStyleConfig(config: Record<string, unknown>)`
95
+
96
+ Updates the style configuration. Note: Currently only applied on initial load.
97
+
98
+ ```javascript
99
+ const chatkit = document.querySelector('xpert-chatkit');
100
+ chatkit.updateStyleConfig({
101
+ primaryColor: '#ff0000',
102
+ borderRadius: '8px'
103
+ });
104
+ ```
105
+
106
+ ## Styling
107
+
108
+ The component automatically fills its container. You can control its size with CSS:
109
+
110
+ ```css
111
+ xpert-chatkit {
112
+ width: 100%;
113
+ height: 100vh;
114
+ }
115
+
116
+ /* Or fixed size */
117
+ xpert-chatkit {
118
+ width: 400px;
119
+ height: 600px;
120
+ }
121
+
122
+ /* In a flex/grid container */
123
+ .container {
124
+ display: flex;
125
+ height: 100vh;
126
+ }
127
+
128
+ xpert-chatkit {
129
+ flex: 1;
130
+ }
131
+ ```
132
+
133
+ ## Error Handling
134
+
135
+ The component displays loading and error states automatically:
136
+ - Shows "Creating session..." while fetching client secret
137
+ - Shows error message if session creation fails
138
+ - Logs errors to console with `[xpert-chatkit]` prefix
139
+
140
+ ## Browser Support
141
+
142
+ - Chrome/Edge 54+
143
+ - Firefox 63+
144
+ - Safari 10.1+
145
+ - All modern browsers with Custom Elements v1 support
146
+
147
+ For older browsers, you may need the [Web Components polyfill](https://github.com/webcomponents/polyfills).
148
+
149
+ ## Development
150
+
151
+ ```bash
152
+ # Install dependencies
153
+ npm install
154
+
155
+ # Start development server (recommended)
156
+ npm run serve
157
+
158
+ # Build for production
159
+ npm run build
160
+
161
+ # Watch mode (build on change)
162
+ npm run dev
163
+
164
+ # Type check
165
+ npm run type-check
166
+ ```
167
+
168
+ For detailed development instructions, see [DEVELOPMENT.md](./DEVELOPMENT.md).
169
+
170
+ ## License
171
+
172
+ MIT
@@ -0,0 +1 @@
1
+ export { }