@voxket-ai/events-sdk 1.0.0 → 1.0.2
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 +235 -55
- package/dist/api/ApiClient.d.ts +5 -1
- package/dist/components/AttendeePortal.d.ts +2 -0
- package/dist/components/DynamicForm.d.ts +1 -1
- package/dist/components/EventWidgetReact.d.ts +5 -1
- package/dist/events-sdk.js +1608 -22238
- package/dist/events-sdk.umd.cjs +5 -238
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +25 -1
- package/dist/utils/Logger.d.ts +1 -0
- package/dist/utils/formUtils.d.ts +13 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
# @voxket-ai/events-sdk
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Enterprise embeddable event registration, ticketing, and attendee self-service portal SDK for Voxket.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@voxket-ai/events-sdk)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
4
9
|
|
|
5
10
|
## Features
|
|
6
11
|
|
|
7
|
-
- **Multiple Display
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
12
|
+
- **Multiple Display Formats**: Seamlessly embed as an inline `widget`, a floating corner `popup`, or a `fullscreen` modal.
|
|
13
|
+
- **Interactive Corner Snapping**: In popup mode, attendees can slide/drag the collapsed widget to any screen corner (`bottom-right`, `bottom-left`, `top-right`, `top-left`).
|
|
14
|
+
- **Shadow DOM Isolation**: Runs inside an isolated Shadow Root so host CSS styles and framework resets never bleed in or break the widget layout.
|
|
15
|
+
- **Configurable Dark & Light Themes**: Full host-configured dark mode (`bg-black text-white`) and light mode with custom brand primary colors and typography.
|
|
16
|
+
- **Event Callbacks (`onError`, `onRegister`)**: Native typed callbacks to easily display host toast notifications, trigger analytics, or redirect users.
|
|
17
|
+
- **Attendee Self-Service Portal**: Attendees can log in, request OTP/verification codes, update registration fields, upload documents, and purchase add-ons.
|
|
18
|
+
- **Draft Auto-save & Instant Recovery**: Automatically tracks in-progress form inputs and seamlessly recovers drafts via `xref_id` or email.
|
|
19
|
+
- **Configurable Network Timeout**: Built-in 2-minute (`120,000 ms`) timeout across all API operations to handle slow mobile networks cleanly.
|
|
20
|
+
- **Framework Agnostic & React Support**: Usable via vanilla JavaScript (`EventWidgetClient`) or directly as a declarative React component (`EventWidget`).
|
|
14
21
|
|
|
15
22
|
---
|
|
16
23
|
|
|
@@ -32,77 +39,250 @@ pnpm add @voxket-ai/events-sdk
|
|
|
32
39
|
|
|
33
40
|
## Quick Start
|
|
34
41
|
|
|
35
|
-
### 1.
|
|
42
|
+
### 1. React Applications
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
<div id="voxket-widget"></div>
|
|
44
|
+
Import `EventWidget` and pass your `WidgetConfig`:
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
```tsx
|
|
47
|
+
import React from 'react';
|
|
48
|
+
import { EventWidget, type WidgetConfig } from '@voxket-ai/events-sdk';
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
export function RegistrationSection() {
|
|
51
|
+
const config: WidgetConfig = {
|
|
52
|
+
eventSlug: 'fogsi-yuva_2026',
|
|
45
53
|
baseUrl: 'https://api.voxket.com',
|
|
46
54
|
displayMode: 'popup', // 'popup' | 'widget' | 'fullscreen'
|
|
55
|
+
position: 'bottom-right',
|
|
56
|
+
themeMode: 'light', // 'light' | 'dark'
|
|
47
57
|
theme: {
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
primaryColor: '#8b5cf6',
|
|
59
|
+
fontFamily: 'Inter, system-ui, sans-serif'
|
|
60
|
+
},
|
|
61
|
+
// Fired when registration is completed
|
|
62
|
+
onRegister: (data) => {
|
|
63
|
+
console.log('Registered successfully:', data);
|
|
64
|
+
alert(`Registration confirmed! Reference: ${data.payload.xref_id || 'N/A'}`);
|
|
65
|
+
},
|
|
66
|
+
// Fired on validation, submission, or network failure
|
|
67
|
+
onError: (err) => {
|
|
68
|
+
console.error('Widget error:', err);
|
|
69
|
+
alert(`Error [${err.type}]: ${err.message}`);
|
|
50
70
|
}
|
|
51
|
-
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return <EventWidget config={config} />;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### 2. Vanilla JavaScript / HTML
|
|
80
|
+
|
|
81
|
+
Use `EventWidgetClient` to mount and manage the widget programmatically:
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<!DOCTYPE html>
|
|
85
|
+
<html lang="en">
|
|
86
|
+
<head>
|
|
87
|
+
<meta charset="UTF-8" />
|
|
88
|
+
<title>Event Registration</title>
|
|
89
|
+
</head>
|
|
90
|
+
<body>
|
|
91
|
+
<!-- Mount target for inline widget or popup anchor -->
|
|
92
|
+
<div id="voxket-widget-container"></div>
|
|
93
|
+
|
|
94
|
+
<script type="module">
|
|
95
|
+
import { EventWidgetClient } from '@voxket-ai/events-sdk';
|
|
96
|
+
|
|
97
|
+
const client = new EventWidgetClient({
|
|
98
|
+
eventSlug: 'fogsi-yuva_2026',
|
|
99
|
+
baseUrl: 'https://api.voxket.com',
|
|
100
|
+
displayMode: 'popup',
|
|
101
|
+
position: 'bottom-right',
|
|
102
|
+
themeMode: 'dark', // Enable dark mode
|
|
103
|
+
theme: {
|
|
104
|
+
primaryColor: '#6366f1'
|
|
105
|
+
},
|
|
106
|
+
onRegister: (data) => {
|
|
107
|
+
console.log('Registration complete:', data);
|
|
108
|
+
},
|
|
109
|
+
onError: (error) => {
|
|
110
|
+
console.error('Error occurred:', error.message);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Mount to the DOM
|
|
115
|
+
client.mount('voxket-widget-container');
|
|
116
|
+
|
|
117
|
+
// Dynamically update configuration without unmounting
|
|
118
|
+
// client.updateConfig({ position: 'bottom-left' });
|
|
119
|
+
|
|
120
|
+
// Clean up when leaving the page
|
|
121
|
+
// client.unmount();
|
|
122
|
+
</script>
|
|
123
|
+
</body>
|
|
124
|
+
</html>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Configuration Reference (`WidgetConfig`)
|
|
130
|
+
|
|
131
|
+
All available options for the `WidgetConfig` object:
|
|
132
|
+
|
|
133
|
+
| Parameter | Type | Default | Description |
|
|
134
|
+
| :--- | :--- | :--- | :--- |
|
|
135
|
+
| `eventSlug` | `string` | *(Required)* | The unique identifier/slug of the event in Voxket. |
|
|
136
|
+
| `baseUrl` | `string` | *(Required)* | API base URL for Voxket backend endpoints. |
|
|
137
|
+
| `displayMode` | `'popup' \| 'widget' \| 'fullscreen'` | `'widget'` | Layout style: floating popup badge, inline embedded container, or full viewport modal. |
|
|
138
|
+
| `position` | `WidgetPosition` | `'bottom-right'` | Starting corner for popup mode. Options: `'bottom-right'`, `'bottom-left'`, `'top-right'`, `'top-left'`, `'right-bottom'`, `'left-bottom'`, `'right-top'`, `'left-top'`. |
|
|
139
|
+
| `themeMode` | `'light' \| 'dark'` | `'light'` | Controls the base color scheme (clean white/gray or deep black `#000` with high-contrast text). |
|
|
140
|
+
| `theme` | `object` | `{}` | Detailed appearance customization (see below). |
|
|
141
|
+
| `theme.primaryColor` | `string` | `'#2563eb'` | Brand color used for primary buttons, tabs, highlights, and headers. |
|
|
142
|
+
| `theme.fontFamily` | `string` | System font | Custom font family CSS string (e.g. `'Inter, sans-serif'`). |
|
|
143
|
+
| `theme.mode` | `'light' \| 'dark' \| 'blue' \| 'white' \| 'custom'` | `'light'` | Preset theme mode alias. |
|
|
144
|
+
| `width` | `string` | `undefined` | Custom width override (e.g. `'500px'`, `'100%'`). |
|
|
145
|
+
| `height` | `string` | `undefined` | Custom height override (e.g. `'700px'`, `'650px'`). |
|
|
146
|
+
| `timeoutMs` | `number` | `120000` *(2 min)* | Network request timeout in milliseconds before triggering `onError`. |
|
|
147
|
+
| `debug` | `boolean` | `false` | Enables verbose debug logging in the browser console. |
|
|
148
|
+
| `onRegister` | `(data: RegistrationSuccessPayload) => void` | `undefined` | Callback fired when an attendee completes registration successfully. |
|
|
149
|
+
| `onRegistered` | `(data: RegistrationSuccessPayload) => void` | `undefined` | Alias for `onRegister`. |
|
|
150
|
+
| `onError` | `(error: WidgetErrorPayload) => void` | `undefined` | Callback fired on validation, submission, network, or schema load errors. |
|
|
151
|
+
| `onEvent` | `(eventName: string, payload: any) => void` | `undefined` | Optional generic event bus for internal widget lifecycle events. |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Event Callbacks & Toast Notifications
|
|
156
|
+
|
|
157
|
+
The SDK exposes dedicated callback functions so host applications can handle state transitions and show native toast notifications.
|
|
158
|
+
|
|
159
|
+
### 1. `onError`
|
|
52
160
|
|
|
53
|
-
|
|
54
|
-
|
|
161
|
+
Fires whenever an operation fails (form validation failure, network disconnect, timeout, attendee login error, or profile update issue):
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
onError: (err: WidgetErrorPayload) => void;
|
|
55
165
|
```
|
|
56
166
|
|
|
57
|
-
|
|
167
|
+
**Payload Schema:**
|
|
168
|
+
```typescript
|
|
169
|
+
interface WidgetErrorPayload {
|
|
170
|
+
type: 'submit_error' | 'schema_load' | 'login_error' | 'profile_update_error' | 'file_upload_error' | 'network_error' | string;
|
|
171
|
+
message: string;
|
|
172
|
+
error?: any;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
58
175
|
|
|
176
|
+
**Toast Example (React Toastify / Sonner / AntD):**
|
|
59
177
|
```tsx
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
178
|
+
const config: WidgetConfig = {
|
|
179
|
+
// ...
|
|
180
|
+
onError: (err) => {
|
|
181
|
+
// Show toast in your host application
|
|
182
|
+
toast.error(err.message, {
|
|
183
|
+
description: `Error code: ${err.type}`
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
### 2. `onRegister` (or `onRegistered`)
|
|
192
|
+
|
|
193
|
+
Fires when an attendee successfully submits their registration form:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
onRegister: (data: RegistrationSuccessPayload) => void;
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Payload Schema:**
|
|
200
|
+
```typescript
|
|
201
|
+
interface RegistrationSuccessPayload {
|
|
202
|
+
registrationType: string | number; // Selected ticket type
|
|
203
|
+
payload: Record<string, any>; // Form field responses submitted
|
|
204
|
+
response?: any; // Raw backend API response
|
|
205
|
+
paymentUrl?: string | null; // Gateway URL if payment is required
|
|
76
206
|
}
|
|
77
207
|
```
|
|
78
208
|
|
|
209
|
+
**Toast & Redirect Example:**
|
|
210
|
+
```tsx
|
|
211
|
+
const config: WidgetConfig = {
|
|
212
|
+
// ...
|
|
213
|
+
onRegister: (data) => {
|
|
214
|
+
toast.success(`Registration received for ${data.registrationType}!`);
|
|
215
|
+
|
|
216
|
+
if (data.paymentUrl) {
|
|
217
|
+
console.log('Payment gateway URL ready:', data.paymentUrl);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
```
|
|
222
|
+
|
|
79
223
|
---
|
|
80
224
|
|
|
81
|
-
##
|
|
225
|
+
## Draggable Corner Positioning (Popup Mode)
|
|
82
226
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
227
|
+
When `displayMode: 'popup'` is active:
|
|
228
|
+
1. The widget renders as a compact floating badge at the configured `position` (e.g. `bottom-right`).
|
|
229
|
+
2. **Move Handle**: Hovering over the badge reveals a corner drag handle (`Move` icon at the top-left of the badge).
|
|
230
|
+
3. **Corner Snapping**: Clicking and dragging the badge moves it across the screen; releasing snaps it to the nearest corner (`bottom-right`, `bottom-left`, `top-right`, or `top-left`).
|
|
231
|
+
4. Once the popup is opened into full view, positioning is locked to prevent accidental movement during form completion.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Dark Mode Support
|
|
236
|
+
|
|
237
|
+
Theme mode is configured by the host application via `themeMode`:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
const config: WidgetConfig = {
|
|
241
|
+
eventSlug: 'fogsi-yuva_2026',
|
|
242
|
+
baseUrl: 'https://api.voxket.com',
|
|
243
|
+
themeMode: 'dark', // 'dark' | 'light'
|
|
244
|
+
theme: {
|
|
245
|
+
primaryColor: '#8b5cf6'
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- When set to `'dark'`, all views—Ticket Selector, Attendee Portal, Dynamic Form Inputs, Payment Screens, and Error Modals—render in high-contrast deep black (`#000000`) and dark zinc tones with crisp borders.
|
|
251
|
+
- Attendees cannot override the theme from within the widget headers; theme configuration is strictly controlled by your application config.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Client API Methods (`EventWidgetClient`)
|
|
256
|
+
|
|
257
|
+
When using the vanilla JavaScript / non-React API:
|
|
258
|
+
|
|
259
|
+
| Method | Description |
|
|
260
|
+
| :--- | :--- |
|
|
261
|
+
| `mount(container: HTMLElement \| string)` | Mounts the widget into a DOM container element or element ID. |
|
|
262
|
+
| `updateConfig(newConfig: Partial<WidgetConfig>)` | Merges new configuration values into the running widget without remounting. |
|
|
263
|
+
| `setConfig(newConfig: WidgetConfig)` | Replaces the entire widget configuration. |
|
|
264
|
+
| `unmount()` | Cleanly destroys the React root, removes DOM nodes, and releases event listeners. |
|
|
94
265
|
|
|
95
266
|
---
|
|
96
267
|
|
|
97
|
-
##
|
|
268
|
+
## TypeScript Exports
|
|
98
269
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
270
|
+
All primary types are exported directly from the package:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import {
|
|
274
|
+
EventWidget,
|
|
275
|
+
EventWidgetClient,
|
|
276
|
+
type WidgetConfig,
|
|
277
|
+
type WidgetPosition,
|
|
278
|
+
type ThemeMode,
|
|
279
|
+
type RegistrationSuccessPayload,
|
|
280
|
+
type WidgetErrorPayload
|
|
281
|
+
} from '@voxket-ai/events-sdk';
|
|
282
|
+
```
|
|
103
283
|
|
|
104
284
|
---
|
|
105
285
|
|
|
106
286
|
## License
|
|
107
287
|
|
|
108
|
-
|
|
288
|
+
MIT © Voxket
|
package/dist/api/ApiClient.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export declare class ApiClient {
|
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private slug;
|
|
5
5
|
private logger;
|
|
6
|
-
|
|
6
|
+
private timeoutMs;
|
|
7
|
+
constructor(baseUrl: string, slug: string, logger: Logger, timeoutMs?: number);
|
|
7
8
|
private fetchApi;
|
|
8
9
|
getFormSchema(): Promise<any>;
|
|
9
10
|
submitRegistration(payload: any): Promise<any>;
|
|
@@ -21,6 +22,9 @@ export declare class ApiClient {
|
|
|
21
22
|
new_password: string;
|
|
22
23
|
}): Promise<any>;
|
|
23
24
|
portalGetProfile(token: string): Promise<any>;
|
|
25
|
+
uploadFile(file: File, token?: string | null): Promise<any>;
|
|
26
|
+
deleteFile(assetId: string | number, token?: string | null): Promise<any>;
|
|
24
27
|
portalUploadFile(token: string, file: File): Promise<any>;
|
|
28
|
+
portalDeleteFile(token: string, assetId: string | number): Promise<any>;
|
|
25
29
|
portalUpdateProfile(token: string, payload: any): Promise<any>;
|
|
26
30
|
}
|
|
@@ -7,7 +7,9 @@ interface AttendeePortalProps {
|
|
|
7
7
|
storage: StorageHelper;
|
|
8
8
|
logger: Logger;
|
|
9
9
|
primaryColor: string;
|
|
10
|
+
isDark?: boolean;
|
|
10
11
|
onEvent?: (eventName: string, payload: any) => void;
|
|
12
|
+
onError?: (error: any) => void;
|
|
11
13
|
}
|
|
12
14
|
export declare const AttendeePortal: React.FC<AttendeePortalProps>;
|
|
13
15
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const DynamicForm: ({ schema, onSubmit, onBack, theme, displayMode, isExpanded, onToggleExpand, onClose, onChange, initialValues }: any) => React.JSX.Element;
|
|
2
|
+
export declare const DynamicForm: ({ schema, onSubmit, onBack, theme, displayMode, isExpanded, onToggleExpand, onClose, onChange, initialValues, isDark, apiClient, storage, onError, onEvent, }: any) => React.JSX.Element;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type WidgetConfig } from '../types';
|
|
2
|
+
import { type WidgetConfig, type WidgetPosition } from '../types';
|
|
3
|
+
export type Corner = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
4
|
+
export declare function normalizePosition(pos?: WidgetPosition): Corner;
|
|
5
|
+
export declare const getCornerStyle: (corner: Corner) => React.CSSProperties;
|
|
6
|
+
export declare const getCornerClasses: (corner: Corner) => string;
|
|
3
7
|
interface Props {
|
|
4
8
|
config: WidgetConfig;
|
|
5
9
|
}
|