@cas0570/chat-widget 0.0.2 → 0.0.4
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 +1 -61
- package/dist/components/ChatBubble.d.ts +8 -0
- package/dist/components/ChatWidget.d.ts +3 -0
- package/dist/components/ChatWindow.d.ts +18 -0
- package/dist/components/Icons.d.ts +26 -0
- package/dist/components/MarkdownRenderer.d.ts +6 -0
- package/dist/components/MessageInput.d.ts +8 -0
- package/dist/components/MessageList.d.ts +9 -0
- package/dist/components/PopoutWindow.d.ts +25 -0
- package/dist/components/ToggleButton.d.ts +9 -0
- package/dist/components/TypingIndicator.d.ts +1 -0
- package/dist/components/__tests__/ChatBubble.test.d.ts +1 -0
- package/dist/components/__tests__/ChatWidget.test.d.ts +1 -0
- package/dist/components/__tests__/ChatWindow.test.d.ts +1 -0
- package/dist/components/__tests__/Icons.test.d.ts +1 -0
- package/dist/components/__tests__/MarkdownRenderer.test.d.ts +1 -0
- package/dist/components/__tests__/MessageInput.test.d.ts +1 -0
- package/dist/components/__tests__/MessageList.test.d.ts +1 -0
- package/dist/components/__tests__/PopoutWindow.test.d.ts +1 -0
- package/dist/components/__tests__/ToggleButton.test.d.ts +1 -0
- package/dist/components/__tests__/TypingIndicator.test.d.ts +1 -0
- package/dist/components/__tests__/index.test.d.ts +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/geoapps-chat-widget.js +1419 -0
- package/dist/geoapps-chat-widget.umd.cjs +598 -0
- package/dist/hooks/__tests__/useChat.test.d.ts +1 -0
- package/dist/hooks/useChat.d.ts +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/main.d.ts +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/utils/__tests__/chatPersistence.test.d.ts +1 -0
- package/dist/utils/chatPersistence.d.ts +44 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +3 -5
- package/dist/geoapps-chat-widget.embed.js +0 -837
- package/dist/style.css +0 -1
package/README.md
CHANGED
|
@@ -29,7 +29,6 @@ npm install @geoapps/chat-widget
|
|
|
29
29
|
|
|
30
30
|
```tsx
|
|
31
31
|
import { ChatWidget } from '@geoapps/chat-widget'
|
|
32
|
-
import '@geoapps/chat-widget/style.css'
|
|
33
32
|
|
|
34
33
|
function App() {
|
|
35
34
|
return (
|
|
@@ -75,7 +74,6 @@ pnpm add @geoapps/chat-widget
|
|
|
75
74
|
|
|
76
75
|
```tsx
|
|
77
76
|
import { ChatWidget } from '@geoapps/chat-widget'
|
|
78
|
-
import '@geoapps/chat-widget/style.css'
|
|
79
77
|
|
|
80
78
|
function App() {
|
|
81
79
|
return (
|
|
@@ -103,7 +101,6 @@ function App() {
|
|
|
103
101
|
|
|
104
102
|
<script setup>
|
|
105
103
|
import { ChatWidget } from '@geoapps/chat-widget'
|
|
106
|
-
import '@geoapps/chat-widget/style.css'
|
|
107
104
|
</script>
|
|
108
105
|
```
|
|
109
106
|
|
|
@@ -113,7 +110,6 @@ import '@geoapps/chat-widget/style.css'
|
|
|
113
110
|
'use client'
|
|
114
111
|
|
|
115
112
|
import dynamic from 'next/dynamic'
|
|
116
|
-
import '@geoapps/chat-widget/style.css'
|
|
117
113
|
|
|
118
114
|
const ChatWidget = dynamic(
|
|
119
115
|
() => import('@geoapps/chat-widget').then(mod => mod.ChatWidget),
|
|
@@ -125,56 +121,6 @@ export default function Page() {
|
|
|
125
121
|
}
|
|
126
122
|
```
|
|
127
123
|
|
|
128
|
-
### Script Tag (CDN)
|
|
129
|
-
|
|
130
|
-
Voor websites zonder build system kun je de embed bundle direct gebruiken via een script tag.
|
|
131
|
-
|
|
132
|
-
#### Methode 1: Data Attributen (eenvoudigste)
|
|
133
|
-
|
|
134
|
-
```html
|
|
135
|
-
<script
|
|
136
|
-
src="https://cdn.example.com/geoapps-chat-widget.embed.js"
|
|
137
|
-
data-api-url="https://api.geoapps.nl/api/v1/chat"
|
|
138
|
-
data-title="GeoApps Help"
|
|
139
|
-
data-subtitle="Vraag me iets over GeoApps"
|
|
140
|
-
data-greeting="Hallo! Hoe kan ik je helpen met GeoApps?"
|
|
141
|
-
data-placeholder="Typ je vraag..."
|
|
142
|
-
data-primary-color="#3b82f6"
|
|
143
|
-
data-position="bottom-right"
|
|
144
|
-
data-default-open="false"
|
|
145
|
-
></script>
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
#### Methode 2: JavaScript API
|
|
149
|
-
|
|
150
|
-
```html
|
|
151
|
-
<script src="https://cdn.example.com/geoapps-chat-widget.embed.js"></script>
|
|
152
|
-
<script>
|
|
153
|
-
GeoAppsChatWidget.embed({
|
|
154
|
-
apiUrl: 'https://api.geoapps.nl/api/v1/chat',
|
|
155
|
-
title: 'GeoApps Help',
|
|
156
|
-
subtitle: 'Vraag me iets over GeoApps',
|
|
157
|
-
greeting: 'Hallo! Hoe kan ik je helpen met GeoApps?',
|
|
158
|
-
placeholder: 'Typ je vraag...',
|
|
159
|
-
primaryColor: '#3b82f6',
|
|
160
|
-
position: 'bottom-right'
|
|
161
|
-
});
|
|
162
|
-
</script>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
#### Beschikbare Data Attributen
|
|
166
|
-
|
|
167
|
-
| Attribuut | Omschrijving |
|
|
168
|
-
| --------- | ------------ |
|
|
169
|
-
| `data-api-url` | **Verplicht.** Chat API endpoint URL |
|
|
170
|
-
| `data-title` | Header titel |
|
|
171
|
-
| `data-subtitle` | Header subtitel |
|
|
172
|
-
| `data-greeting` | Initieel welkomstbericht |
|
|
173
|
-
| `data-placeholder` | Input placeholder tekst |
|
|
174
|
-
| `data-primary-color` | Accent kleur (hex) |
|
|
175
|
-
| `data-position` | `bottom-right`, `bottom-left`, `top-right`, `top-left` |
|
|
176
|
-
| `data-default-open` | `true` of `false` - start open of gesloten |
|
|
177
|
-
|
|
178
124
|
---
|
|
179
125
|
|
|
180
126
|
## API Reference
|
|
@@ -294,7 +240,6 @@ import { ChatWidget, ChatBubble } from '@geoapps/chat-widget'
|
|
|
294
240
|
geoapps-chat-widget/
|
|
295
241
|
├── src/
|
|
296
242
|
│ ├── index.ts # Package exports
|
|
297
|
-
│ ├── embed.ts # IIFE entry for script tag
|
|
298
243
|
│ ├── components/
|
|
299
244
|
│ │ ├── ChatWidget.tsx # Main widget component
|
|
300
245
|
│ │ ├── ChatBubble.tsx # Floating button
|
|
@@ -311,11 +256,6 @@ geoapps-chat-widget/
|
|
|
311
256
|
│ │ └── variables.css # CSS variables
|
|
312
257
|
│ └── types/
|
|
313
258
|
│ └── index.ts # TypeScript types
|
|
314
|
-
├── dist/ # Built files
|
|
315
|
-
│ ├── index.js # ESM bundle
|
|
316
|
-
│ ├── index.cjs # CommonJS bundle
|
|
317
|
-
│ ├── embed.iife.js # Script tag bundle
|
|
318
|
-
│ └── style.css # Styles
|
|
319
259
|
├── package.json
|
|
320
260
|
├── tsconfig.json
|
|
321
261
|
├── vite.config.ts # Build configuration
|
|
@@ -389,7 +329,7 @@ npm publish --access public
|
|
|
389
329
|
| Widget not appearing | Check z-index conflicts |
|
|
390
330
|
| CORS errors | Ensure API allows your domain in CORS_ORIGINS |
|
|
391
331
|
| Messages not sending | Verify apiUrl is correct and API is running |
|
|
392
|
-
| Styles not loading |
|
|
332
|
+
| Styles not loading | CSS is auto-included; check bundler CSS support |
|
|
393
333
|
| SSR errors (Next.js) | Use dynamic import with `ssr: false` |
|
|
394
334
|
|
|
395
335
|
---
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChatWidgetProps } from '../types';
|
|
2
|
+
|
|
3
|
+
export declare function ChatWidget({ apiUrl, tenantId, title, subtitle, placeholder, greeting, primaryColor, position, defaultOpen, defaultSize, headers, onOpen, onClose, onMessageSent, onResponseReceived, }: ChatWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Message, WidgetSize } from '../types';
|
|
2
|
+
|
|
3
|
+
interface ChatWindowProps {
|
|
4
|
+
title: string;
|
|
5
|
+
subtitle: string;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
messages: Message[];
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
onSendMessage: (content: string) => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
onClear: () => void;
|
|
12
|
+
onSizeChange: (size: WidgetSize) => void;
|
|
13
|
+
onPopout: () => void;
|
|
14
|
+
primaryColor: string;
|
|
15
|
+
size: WidgetSize;
|
|
16
|
+
}
|
|
17
|
+
export declare function ChatWindow({ title, subtitle, placeholder, messages, isLoading, onSendMessage, onClose, onClear, onSizeChange, onPopout, primaryColor, size, }: ChatWindowProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WidgetSize } from '../types';
|
|
2
|
+
|
|
3
|
+
interface ResizeIconProps {
|
|
4
|
+
size: WidgetSize;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function ResizeIcon({ size, className }: ResizeIconProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ExpandIcon({ className }: {
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function ContractIcon({ className }: {
|
|
12
|
+
className?: string;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function PopoutIcon({ className }: {
|
|
15
|
+
className?: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function CloseIcon({ className }: {
|
|
18
|
+
className?: string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function TrashIcon({ className }: {
|
|
21
|
+
className?: string;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function ChatIcon({ className }: {
|
|
24
|
+
className?: string;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface MessageInputProps {
|
|
2
|
+
placeholder: string;
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
onSendMessage: (content: string) => void;
|
|
5
|
+
primaryColor: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function MessageInput({ placeholder, isLoading, onSendMessage, primaryColor }: MessageInputProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Message } from '../types';
|
|
2
|
+
|
|
3
|
+
interface MessageListProps {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
primaryColor: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function MessageList({ messages, isLoading, primaryColor }: MessageListProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Message, WidgetSize } from '../types';
|
|
2
|
+
|
|
3
|
+
interface PopoutConfig {
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
tenantId?: string;
|
|
6
|
+
title: string;
|
|
7
|
+
subtitle: string;
|
|
8
|
+
placeholder: string;
|
|
9
|
+
primaryColor: string;
|
|
10
|
+
sessionId?: string | null;
|
|
11
|
+
messages: Message[];
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
interface UsePopoutReturn {
|
|
15
|
+
isPoppedOut: boolean;
|
|
16
|
+
openPopout: () => void;
|
|
17
|
+
closePopout: () => void;
|
|
18
|
+
focusPopout: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook to manage the popout window state
|
|
22
|
+
*/
|
|
23
|
+
export declare function usePopout(config: PopoutConfig, size: WidgetSize, onPopoutClose?: () => void): UsePopoutReturn;
|
|
24
|
+
export declare function ChatWindowStandalone(): null;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface ToggleButtonProps {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClick: () => void;
|
|
4
|
+
primaryColor: string;
|
|
5
|
+
hasUnread?: boolean;
|
|
6
|
+
isPoppedOut?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ToggleButton({ isOpen, onClick, primaryColor, hasUnread, isPoppedOut }: ToggleButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TypingIndicator(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ChatWidget } from './ChatWidget';
|
|
2
|
+
export { ChatWindow } from './ChatWindow';
|
|
3
|
+
export { ChatBubble } from './ChatBubble';
|
|
4
|
+
export { MessageList } from './MessageList';
|
|
5
|
+
export { MessageInput } from './MessageInput';
|
|
6
|
+
export { ToggleButton } from './ToggleButton';
|
|
7
|
+
export { MarkdownRenderer } from './MarkdownRenderer';
|
|
8
|
+
export { usePopout } from './PopoutWindow';
|
|
9
|
+
export { ResizeIcon, ExpandIcon, ContractIcon, PopoutIcon, CloseIcon, TrashIcon, ChatIcon } from './Icons';
|