vdb-ai-chat 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 +153 -0
- package/dist/chat-widget.js +2 -0
- package/dist/chat-widget.js.LICENSE.txt +29 -0
- package/lib/commonjs/api.js +157 -0
- package/lib/commonjs/api.js.map +1 -0
- package/lib/commonjs/components/ChatHeader.js +111 -0
- package/lib/commonjs/components/ChatHeader.js.map +1 -0
- package/lib/commonjs/components/ChatInput.js +144 -0
- package/lib/commonjs/components/ChatInput.js.map +1 -0
- package/lib/commonjs/components/ChatWidget.js +469 -0
- package/lib/commonjs/components/ChatWidget.js.map +1 -0
- package/lib/commonjs/components/MessageBubble.js +122 -0
- package/lib/commonjs/components/MessageBubble.js.map +1 -0
- package/lib/commonjs/components/ProductsList.js +139 -0
- package/lib/commonjs/components/ProductsList.js.map +1 -0
- package/lib/commonjs/components/SuggestionsRow.js +59 -0
- package/lib/commonjs/components/SuggestionsRow.js.map +1 -0
- package/lib/commonjs/components/utils.js +37 -0
- package/lib/commonjs/components/utils.js.map +1 -0
- package/lib/commonjs/index.js +70 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/index.native.js +70 -0
- package/lib/commonjs/index.native.js.map +1 -0
- package/lib/commonjs/index.web.js +30 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/storage.js +136 -0
- package/lib/commonjs/storage.js.map +1 -0
- package/lib/commonjs/theme.js +29 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/api.js +146 -0
- package/lib/module/api.js.map +1 -0
- package/lib/module/components/ChatHeader.js +105 -0
- package/lib/module/components/ChatHeader.js.map +1 -0
- package/lib/module/components/ChatInput.js +136 -0
- package/lib/module/components/ChatInput.js.map +1 -0
- package/lib/module/components/ChatWidget.js +461 -0
- package/lib/module/components/ChatWidget.js.map +1 -0
- package/lib/module/components/MessageBubble.js +116 -0
- package/lib/module/components/MessageBubble.js.map +1 -0
- package/lib/module/components/ProductsList.js +133 -0
- package/lib/module/components/ProductsList.js.map +1 -0
- package/lib/module/components/SuggestionsRow.js +52 -0
- package/lib/module/components/SuggestionsRow.js.map +1 -0
- package/lib/module/components/utils.js +29 -0
- package/lib/module/components/utils.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.native.js +7 -0
- package/lib/module/index.native.js.map +1 -0
- package/lib/module/index.web.js +23 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/storage.js +129 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/theme.js +22 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/api.d.ts +10 -0
- package/lib/typescript/api.d.ts.map +1 -0
- package/lib/typescript/components/ChatHeader.d.ts +6 -0
- package/lib/typescript/components/ChatHeader.d.ts.map +1 -0
- package/lib/typescript/components/ChatInput.d.ts +15 -0
- package/lib/typescript/components/ChatInput.d.ts.map +1 -0
- package/lib/typescript/components/ChatWidget.d.ts +4 -0
- package/lib/typescript/components/ChatWidget.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble.d.ts +13 -0
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -0
- package/lib/typescript/components/ProductsList.d.ts +9 -0
- package/lib/typescript/components/ProductsList.d.ts.map +1 -0
- package/lib/typescript/components/SuggestionsRow.d.ts +8 -0
- package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -0
- package/lib/typescript/components/utils.d.ts +8 -0
- package/lib/typescript/components/utils.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/index.native.d.ts +6 -0
- package/lib/typescript/index.native.d.ts.map +1 -0
- package/lib/typescript/index.web.d.ts +3 -0
- package/lib/typescript/index.web.d.ts.map +1 -0
- package/lib/typescript/storage.d.ts +28 -0
- package/lib/typescript/storage.d.ts.map +1 -0
- package/lib/typescript/theme.d.ts +4 -0
- package/lib/typescript/theme.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +51 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +90 -0
- package/src/api.ts +200 -0
- package/src/components/ChatHeader.tsx +114 -0
- package/src/components/ChatInput.tsx +163 -0
- package/src/components/ChatWidget.tsx +679 -0
- package/src/components/MessageBubble.tsx +181 -0
- package/src/components/ProductsList.tsx +160 -0
- package/src/components/SuggestionsRow.tsx +73 -0
- package/src/components/utils.ts +43 -0
- package/src/index.native.tsx +6 -0
- package/src/index.ts +7 -0
- package/src/index.web.tsx +33 -0
- package/src/storage.ts +142 -0
- package/src/theme.ts +21 -0
- package/src/types.ts +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# VDB AI Chat
|
|
2
|
+
|
|
3
|
+
A cross-platform AI chat widget that works on **React Native** (iOS/Android) and **Web** (as an embeddable widget).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install vdb-ai-chat
|
|
9
|
+
# or
|
|
10
|
+
yarn add vdb-ai-chat
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### React Native (iOS / Android)
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import { SafeAreaView } from 'react-native';
|
|
20
|
+
import { ChatWidget } from 'vdb-ai-chat';
|
|
21
|
+
|
|
22
|
+
export default function App() {
|
|
23
|
+
return (
|
|
24
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
25
|
+
<ChatWidget
|
|
26
|
+
apiUrl="https://your-api.com/v3/chat"
|
|
27
|
+
theme={{
|
|
28
|
+
primaryColor: '#804195',
|
|
29
|
+
}}
|
|
30
|
+
placeholder="Ask me anything..."
|
|
31
|
+
onClose={() => console.log('Chat closed')}
|
|
32
|
+
/>
|
|
33
|
+
</SafeAreaView>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Web Widget (Embeddable Script)
|
|
39
|
+
|
|
40
|
+
Build the widget bundle:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run build:web
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This creates `dist/chat-widget.js`. Host it on your CDN, then embed:
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<script src="https://your-cdn.com/chat-widget.js"></script>
|
|
50
|
+
<script>
|
|
51
|
+
createChatWidget({
|
|
52
|
+
id: "vdb-chat",
|
|
53
|
+
apiUrl: "https://your-api.com/v3/chat",
|
|
54
|
+
theme: {
|
|
55
|
+
primaryColor: "#804195"
|
|
56
|
+
},
|
|
57
|
+
button: {
|
|
58
|
+
buttonPosition: { bottom: "24px", right: "24px" }
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Props
|
|
65
|
+
|
|
66
|
+
| Prop | Type | Description |
|
|
67
|
+
|------|------|-------------|
|
|
68
|
+
| `apiUrl` | `string` | Required. Your chat API endpoint |
|
|
69
|
+
| `userId` | `string` | Optional. User identifier |
|
|
70
|
+
| `userToken` | `string` | Optional. Auth token |
|
|
71
|
+
| `theme` | `Partial<ChatTheme>` | Optional. Theme customization |
|
|
72
|
+
| `placeholder` | `string` | Optional. Input placeholder text |
|
|
73
|
+
| `onClose` | `() => void` | Optional. Called when chat is closed |
|
|
74
|
+
| `onClearChat` | `() => void` | Optional. Called when chat is cleared |
|
|
75
|
+
|
|
76
|
+
## Theme Customization
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
interface ChatTheme {
|
|
80
|
+
primaryColor: string;
|
|
81
|
+
backgroundColor: string;
|
|
82
|
+
inputColor: string;
|
|
83
|
+
inputBackgroundColor: string;
|
|
84
|
+
inputBorderRadius: number;
|
|
85
|
+
inputTextColor: string;
|
|
86
|
+
userBubbleColor: string;
|
|
87
|
+
userTextColor: string;
|
|
88
|
+
botBubbleColor: string;
|
|
89
|
+
botTextColor: string;
|
|
90
|
+
borderRadius: number;
|
|
91
|
+
fontFamily?: string;
|
|
92
|
+
fontSize: number;
|
|
93
|
+
listContentBackgroundColor?: string;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Install dependencies
|
|
101
|
+
npm install
|
|
102
|
+
|
|
103
|
+
# Start web dev server
|
|
104
|
+
npm run start:web
|
|
105
|
+
|
|
106
|
+
# Build library (for npm)
|
|
107
|
+
npm run build:lib
|
|
108
|
+
|
|
109
|
+
# Build web widget
|
|
110
|
+
npm run build:web
|
|
111
|
+
|
|
112
|
+
# Build everything
|
|
113
|
+
npm run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Local Testing (Before Publishing)
|
|
117
|
+
|
|
118
|
+
To test the package locally in another project:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# In this project
|
|
122
|
+
npm run build:lib
|
|
123
|
+
npm pack
|
|
124
|
+
# Creates vdb-ai-chat-1.0.0.tgz
|
|
125
|
+
|
|
126
|
+
# In your React Native app
|
|
127
|
+
npm install /path/to/vdb-ai-chat-1.0.0.tgz
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Or use `npm link`:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# In this project
|
|
134
|
+
npm run build:lib
|
|
135
|
+
npm link
|
|
136
|
+
|
|
137
|
+
# In your React Native app
|
|
138
|
+
npm link vdb-ai-chat
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Publishing to npm
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Login to npm
|
|
145
|
+
npm login
|
|
146
|
+
|
|
147
|
+
# Publish
|
|
148
|
+
npm publish
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT
|