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.
Files changed (102) hide show
  1. package/README.md +153 -0
  2. package/dist/chat-widget.js +2 -0
  3. package/dist/chat-widget.js.LICENSE.txt +29 -0
  4. package/lib/commonjs/api.js +157 -0
  5. package/lib/commonjs/api.js.map +1 -0
  6. package/lib/commonjs/components/ChatHeader.js +111 -0
  7. package/lib/commonjs/components/ChatHeader.js.map +1 -0
  8. package/lib/commonjs/components/ChatInput.js +144 -0
  9. package/lib/commonjs/components/ChatInput.js.map +1 -0
  10. package/lib/commonjs/components/ChatWidget.js +469 -0
  11. package/lib/commonjs/components/ChatWidget.js.map +1 -0
  12. package/lib/commonjs/components/MessageBubble.js +122 -0
  13. package/lib/commonjs/components/MessageBubble.js.map +1 -0
  14. package/lib/commonjs/components/ProductsList.js +139 -0
  15. package/lib/commonjs/components/ProductsList.js.map +1 -0
  16. package/lib/commonjs/components/SuggestionsRow.js +59 -0
  17. package/lib/commonjs/components/SuggestionsRow.js.map +1 -0
  18. package/lib/commonjs/components/utils.js +37 -0
  19. package/lib/commonjs/components/utils.js.map +1 -0
  20. package/lib/commonjs/index.js +70 -0
  21. package/lib/commonjs/index.js.map +1 -0
  22. package/lib/commonjs/index.native.js +70 -0
  23. package/lib/commonjs/index.native.js.map +1 -0
  24. package/lib/commonjs/index.web.js +30 -0
  25. package/lib/commonjs/index.web.js.map +1 -0
  26. package/lib/commonjs/storage.js +136 -0
  27. package/lib/commonjs/storage.js.map +1 -0
  28. package/lib/commonjs/theme.js +29 -0
  29. package/lib/commonjs/theme.js.map +1 -0
  30. package/lib/commonjs/types.js +2 -0
  31. package/lib/commonjs/types.js.map +1 -0
  32. package/lib/module/api.js +146 -0
  33. package/lib/module/api.js.map +1 -0
  34. package/lib/module/components/ChatHeader.js +105 -0
  35. package/lib/module/components/ChatHeader.js.map +1 -0
  36. package/lib/module/components/ChatInput.js +136 -0
  37. package/lib/module/components/ChatInput.js.map +1 -0
  38. package/lib/module/components/ChatWidget.js +461 -0
  39. package/lib/module/components/ChatWidget.js.map +1 -0
  40. package/lib/module/components/MessageBubble.js +116 -0
  41. package/lib/module/components/MessageBubble.js.map +1 -0
  42. package/lib/module/components/ProductsList.js +133 -0
  43. package/lib/module/components/ProductsList.js.map +1 -0
  44. package/lib/module/components/SuggestionsRow.js +52 -0
  45. package/lib/module/components/SuggestionsRow.js.map +1 -0
  46. package/lib/module/components/utils.js +29 -0
  47. package/lib/module/components/utils.js.map +1 -0
  48. package/lib/module/index.js +7 -0
  49. package/lib/module/index.js.map +1 -0
  50. package/lib/module/index.native.js +7 -0
  51. package/lib/module/index.native.js.map +1 -0
  52. package/lib/module/index.web.js +23 -0
  53. package/lib/module/index.web.js.map +1 -0
  54. package/lib/module/storage.js +129 -0
  55. package/lib/module/storage.js.map +1 -0
  56. package/lib/module/theme.js +22 -0
  57. package/lib/module/theme.js.map +1 -0
  58. package/lib/module/types.js +2 -0
  59. package/lib/module/types.js.map +1 -0
  60. package/lib/typescript/api.d.ts +10 -0
  61. package/lib/typescript/api.d.ts.map +1 -0
  62. package/lib/typescript/components/ChatHeader.d.ts +6 -0
  63. package/lib/typescript/components/ChatHeader.d.ts.map +1 -0
  64. package/lib/typescript/components/ChatInput.d.ts +15 -0
  65. package/lib/typescript/components/ChatInput.d.ts.map +1 -0
  66. package/lib/typescript/components/ChatWidget.d.ts +4 -0
  67. package/lib/typescript/components/ChatWidget.d.ts.map +1 -0
  68. package/lib/typescript/components/MessageBubble.d.ts +13 -0
  69. package/lib/typescript/components/MessageBubble.d.ts.map +1 -0
  70. package/lib/typescript/components/ProductsList.d.ts +9 -0
  71. package/lib/typescript/components/ProductsList.d.ts.map +1 -0
  72. package/lib/typescript/components/SuggestionsRow.d.ts +8 -0
  73. package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -0
  74. package/lib/typescript/components/utils.d.ts +8 -0
  75. package/lib/typescript/components/utils.d.ts.map +1 -0
  76. package/lib/typescript/index.d.ts +6 -0
  77. package/lib/typescript/index.d.ts.map +1 -0
  78. package/lib/typescript/index.native.d.ts +6 -0
  79. package/lib/typescript/index.native.d.ts.map +1 -0
  80. package/lib/typescript/index.web.d.ts +3 -0
  81. package/lib/typescript/index.web.d.ts.map +1 -0
  82. package/lib/typescript/storage.d.ts +28 -0
  83. package/lib/typescript/storage.d.ts.map +1 -0
  84. package/lib/typescript/theme.d.ts +4 -0
  85. package/lib/typescript/theme.d.ts.map +1 -0
  86. package/lib/typescript/types.d.ts +51 -0
  87. package/lib/typescript/types.d.ts.map +1 -0
  88. package/package.json +90 -0
  89. package/src/api.ts +200 -0
  90. package/src/components/ChatHeader.tsx +114 -0
  91. package/src/components/ChatInput.tsx +163 -0
  92. package/src/components/ChatWidget.tsx +679 -0
  93. package/src/components/MessageBubble.tsx +181 -0
  94. package/src/components/ProductsList.tsx +160 -0
  95. package/src/components/SuggestionsRow.tsx +73 -0
  96. package/src/components/utils.ts +43 -0
  97. package/src/index.native.tsx +6 -0
  98. package/src/index.ts +7 -0
  99. package/src/index.web.tsx +33 -0
  100. package/src/storage.ts +142 -0
  101. package/src/theme.ts +21 -0
  102. 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