@product7/feedback-sdk 1.1.0 → 1.1.5

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 CHANGED
@@ -9,14 +9,18 @@ A lightweight, customizable JavaScript SDK for collecting user feedback on any w
9
9
 
10
10
  ## Features
11
11
 
12
- - Multiple widget types Button, Tab, and Inline widgets
13
- - Theme supportLight and dark themes with custom CSS properties
14
- - Responsive designWorks on desktop, tablet, and mobile
15
- - Easy integrationSimple JavaScript API, minimal setup
16
- - Lightweight< 25KB minified and gzipped
17
- - TypeScript supportFull type definitions included
18
- - AccessibleWCAG 2.1 compliant
19
- - SecureCSP friendly, no `eval()` usage
12
+ - **Display modes**Side panel or centered modal
13
+ - **Size options**Small, medium, or large widget sizes
14
+ - **Full color customization** Background, text, and primary colors
15
+ - **Custom triggers**Use your own buttons instead of floating widget
16
+ - **Mock mode** Development without backend connection
17
+ - **Multiple positions**7 position options including center
18
+ - **Responsive design** Works on desktop, tablet, and mobile
19
+ - **Easy integration** Simple JavaScript API, minimal setup
20
+ - **Lightweight** — ~12KB gzipped
21
+ - **TypeScript support** — Full type definitions included
22
+ - **Accessible** — WCAG 2.1 compliant
23
+ - **Secure** — CSP friendly, no `eval()` usage
20
24
 
21
25
  ---
22
26
 
@@ -90,22 +94,29 @@ widget.mount();
90
94
 
91
95
  ## Widget Types
92
96
 
93
- **Button Widget**
97
+ **Button Widget with Side Panel**
94
98
 
95
99
  ```javascript
96
- const button = feedback.createWidget('button', {
100
+ const widget = feedback.createWidget('button', {
97
101
  position: 'bottom-right',
102
+ displayMode: 'panel', // Slides in from the side
103
+ size: 'medium',
98
104
  });
99
- button.mount();
105
+ widget.mount();
100
106
  ```
101
107
 
102
- **Tab Widget**
108
+ **Button Widget with Modal**
103
109
 
104
110
  ```javascript
105
- const tab = feedback.createWidget('tab', {
106
- position: 'bottom-left',
111
+ const widget = feedback.createWidget('button', {
112
+ position: 'bottom-right',
113
+ displayMode: 'modal',
114
+ size: 'large',
115
+ backgroundColor: '#ffffff',
116
+ textColor: '#1F2937',
117
+ primaryColor: '#21244A',
107
118
  });
108
- tab.mount();
119
+ widget.mount();
109
120
  ```
110
121
 
111
122
  **Inline Widget**
@@ -119,28 +130,169 @@ inline.mount('#feedback-container');
119
130
 
120
131
  ## Configuration
121
132
 
122
- | Option | Type | Required | Default | Description |
123
- | ----------- | ------- | -------- | -------------- | -------------------------- |
124
- | `workspace` | string | ✅ | - | Your workspace subdomain |
125
- | `boardId` | string | | null | Target board for feedback |
126
- | `apiKey` | string | | null | API key for authentication |
127
- | `theme` | string | ❌ | 'light' | Theme: 'light' or 'dark' |
128
- | `position` | string | ❌ | 'bottom-right' | Widget position |
129
- | `debug` | boolean | ❌ | false | Enable debug logging |
133
+ ### SDK Configuration
134
+
135
+ | Option | Type | Required | Default | Description |
136
+ | ------------- | ------- | -------- | --------- | -------------------------------- |
137
+ | `workspace` | string | | - | Your workspace subdomain |
138
+ | `boardId` | string | ❌ | 'general' | Target board for feedback |
139
+ | `userContext` | object | ❌ | null | User identification data |
140
+ | `mock` | boolean | ❌ | false | Enable mock mode for development |
141
+ | `debug` | boolean | ❌ | false | Enable debug logging |
142
+
143
+ ### Widget Configuration
144
+
145
+ | Option | Type | Default | Description |
146
+ | ----------------- | ------ | -------------- | ---------------------------------------------- |
147
+ | `displayMode` | string | 'panel' | `'panel'` (side slide) or `'modal'` (centered) |
148
+ | `size` | string | 'medium' | `'small'`, `'medium'`, or `'large'` |
149
+ | `position` | string | 'bottom-right' | Button position (see below) |
150
+ | `backgroundColor` | string | '#ffffff' | Panel/modal background color |
151
+ | `textColor` | string | '#1F2937' | Text color |
152
+ | `primaryColor` | string | ''#21244A | Button and accent color |
153
+
154
+ ### Position Options
155
+
156
+ - `bottom-right` (default)
157
+ - `bottom-left`
158
+ - `top-right`
159
+ - `top-left`
160
+ - `bottom-center`
161
+ - `top-center`
162
+ - `center`
163
+
164
+ ### Size Variants
165
+
166
+ | Size | Modal Width | Panel Width |
167
+ | ------ | ----------- | ----------- |
168
+ | small | 360px | 320px |
169
+ | medium | 480px | 420px |
170
+ | large | 600px | 520px |
130
171
 
131
172
  ---
132
173
 
133
- ## Theming
174
+ ## Color Customization
175
+
176
+ Instead of predefined themes, use direct color values for full flexibility:
134
177
 
135
- ```css
136
- :root {
137
- --feedback-primary-color: #10b981;
138
- --feedback-primary-hover: #059669;
139
- --feedback-font-family: 'Inter', sans-serif;
140
- --feedback-border-radius: 8px;
141
- }
178
+ ```javascript
179
+ const widget = feedback.createWidget('button', {
180
+ displayMode: 'modal',
181
+ backgroundColor: '#1a1a2e', // Dark background
182
+ textColor: '#ffffff', // White text
183
+ primaryColor: '#e94560', // Red accent
184
+ });
142
185
  ```
143
186
 
187
+ This approach works better than predefined themes because:
188
+
189
+ - Supports any brand color
190
+ - Works with both light and dark designs
191
+ - No restrictions on color combinations
192
+
193
+ ---
194
+
195
+ ## Custom Triggers
196
+
197
+ Hide the default floating button and trigger from your own UI:
198
+
199
+ ```javascript
200
+ window.FeedbackSDK.onReady((sdk) => {
201
+ const widget = sdk.createWidget('button', {
202
+ displayMode: 'modal',
203
+ size: 'medium',
204
+ });
205
+ widget.mount();
206
+ widget.hide(); // Hide the floating button
207
+
208
+ // Trigger from your own button
209
+ document.getElementById('my-feedback-btn').addEventListener('click', () => {
210
+ widget.openPanel();
211
+ });
212
+ });
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Mock Mode
218
+
219
+ For development without a backend connection:
220
+
221
+ ```javascript
222
+ window.FeedbackSDKConfig = {
223
+ workspace: 'demo',
224
+ mock: true, // No backend required
225
+ userContext: {
226
+ user_id: 'test_user',
227
+ email: 'test@example.com',
228
+ },
229
+ };
230
+ ```
231
+
232
+ Mock mode simulates:
233
+
234
+ - Session initialization
235
+ - Feedback submission (with 500ms delay)
236
+ - Default configuration values
237
+
238
+ ---
239
+
240
+ ## Environments
241
+
242
+ The SDK supports multiple environments for development and production use.
243
+
244
+ ### Production (Default)
245
+
246
+ ```javascript
247
+ const feedback = new FeedbackSDK({
248
+ workspace: 'your-workspace',
249
+ environment: 'production', // Default, can be omitted
250
+ });
251
+ ```
252
+
253
+ **API URLs:**
254
+
255
+ - `https://api.product7.io/api/v1`
256
+ - `https://{workspace}.api.product7.io/api/v1`
257
+
258
+ ### Staging
259
+
260
+ ```javascript
261
+ const feedback = new FeedbackSDK({
262
+ workspace: 'your-workspace',
263
+ environment: 'staging',
264
+ });
265
+ ```
266
+
267
+ **API URLs:**
268
+
269
+ - `https://staging.api.product7.io/api/v1`
270
+ - `https://{workspace}.staging.api.product7.io/api/v1`
271
+
272
+ ### Custom API URL
273
+
274
+ For self-hosted or custom deployments:
275
+
276
+ ```javascript
277
+ const feedback = new FeedbackSDK({
278
+ workspace: 'your-workspace',
279
+ apiUrl: 'https://your-custom-api.com/api/v1',
280
+ });
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Configuration Priority
286
+
287
+ Configuration values merge in this order (later overrides earlier):
288
+
289
+ 1. **Default values** — Built-in SDK defaults
290
+ 2. **Backend config** — Returned from `/widget/init` API
291
+ 3. **SDK config** — `window.FeedbackSDKConfig`
292
+ 4. **Widget options** — Passed to `createWidget()`
293
+
294
+ This allows backend-managed defaults while permitting per-widget customization.
295
+
144
296
  ---
145
297
 
146
298
  ## Events
@@ -184,8 +336,8 @@ npm run size
184
336
 
185
337
  ## Bundle Size
186
338
 
187
- - **Minified**: \~18KB
188
- - **Minified + Gzipped**: \~6KB
339
+ - **Minified**: ~41KB
340
+ - **Minified + Gzipped**: ~12KB
189
341
 
190
342
  ---
191
343
 
package/dist/README.md CHANGED
@@ -9,14 +9,18 @@ A lightweight, customizable JavaScript SDK for collecting user feedback on any w
9
9
 
10
10
  ## Features
11
11
 
12
- - Multiple widget types Button, Tab, and Inline widgets
13
- - Theme supportLight and dark themes with custom CSS properties
14
- - Responsive designWorks on desktop, tablet, and mobile
15
- - Easy integrationSimple JavaScript API, minimal setup
16
- - Lightweight< 25KB minified and gzipped
17
- - TypeScript supportFull type definitions included
18
- - AccessibleWCAG 2.1 compliant
19
- - SecureCSP friendly, no `eval()` usage
12
+ - **Display modes**Side panel or centered modal
13
+ - **Size options**Small, medium, or large widget sizes
14
+ - **Full color customization** Background, text, and primary colors
15
+ - **Custom triggers**Use your own buttons instead of floating widget
16
+ - **Mock mode** Development without backend connection
17
+ - **Multiple positions**7 position options including center
18
+ - **Responsive design** Works on desktop, tablet, and mobile
19
+ - **Easy integration** Simple JavaScript API, minimal setup
20
+ - **Lightweight** — ~12KB gzipped
21
+ - **TypeScript support** — Full type definitions included
22
+ - **Accessible** — WCAG 2.1 compliant
23
+ - **Secure** — CSP friendly, no `eval()` usage
20
24
 
21
25
  ---
22
26
 
@@ -90,22 +94,29 @@ widget.mount();
90
94
 
91
95
  ## Widget Types
92
96
 
93
- **Button Widget**
97
+ **Button Widget with Side Panel**
94
98
 
95
99
  ```javascript
96
- const button = feedback.createWidget('button', {
100
+ const widget = feedback.createWidget('button', {
97
101
  position: 'bottom-right',
102
+ displayMode: 'panel', // Slides in from the side
103
+ size: 'medium',
98
104
  });
99
- button.mount();
105
+ widget.mount();
100
106
  ```
101
107
 
102
- **Tab Widget**
108
+ **Button Widget with Modal**
103
109
 
104
110
  ```javascript
105
- const tab = feedback.createWidget('tab', {
106
- position: 'bottom-left',
111
+ const widget = feedback.createWidget('button', {
112
+ position: 'bottom-right',
113
+ displayMode: 'modal',
114
+ size: 'large',
115
+ backgroundColor: '#ffffff',
116
+ textColor: '#1F2937',
117
+ primaryColor: '#21244A',
107
118
  });
108
- tab.mount();
119
+ widget.mount();
109
120
  ```
110
121
 
111
122
  **Inline Widget**
@@ -119,28 +130,169 @@ inline.mount('#feedback-container');
119
130
 
120
131
  ## Configuration
121
132
 
122
- | Option | Type | Required | Default | Description |
123
- | ----------- | ------- | -------- | -------------- | -------------------------- |
124
- | `workspace` | string | ✅ | - | Your workspace subdomain |
125
- | `boardId` | string | | null | Target board for feedback |
126
- | `apiKey` | string | | null | API key for authentication |
127
- | `theme` | string | ❌ | 'light' | Theme: 'light' or 'dark' |
128
- | `position` | string | ❌ | 'bottom-right' | Widget position |
129
- | `debug` | boolean | ❌ | false | Enable debug logging |
133
+ ### SDK Configuration
134
+
135
+ | Option | Type | Required | Default | Description |
136
+ | ------------- | ------- | -------- | --------- | -------------------------------- |
137
+ | `workspace` | string | | - | Your workspace subdomain |
138
+ | `boardId` | string | ❌ | 'general' | Target board for feedback |
139
+ | `userContext` | object | ❌ | null | User identification data |
140
+ | `mock` | boolean | ❌ | false | Enable mock mode for development |
141
+ | `debug` | boolean | ❌ | false | Enable debug logging |
142
+
143
+ ### Widget Configuration
144
+
145
+ | Option | Type | Default | Description |
146
+ | ----------------- | ------ | -------------- | ---------------------------------------------- |
147
+ | `displayMode` | string | 'panel' | `'panel'` (side slide) or `'modal'` (centered) |
148
+ | `size` | string | 'medium' | `'small'`, `'medium'`, or `'large'` |
149
+ | `position` | string | 'bottom-right' | Button position (see below) |
150
+ | `backgroundColor` | string | '#ffffff' | Panel/modal background color |
151
+ | `textColor` | string | '#1F2937' | Text color |
152
+ | `primaryColor` | string | ''#21244A | Button and accent color |
153
+
154
+ ### Position Options
155
+
156
+ - `bottom-right` (default)
157
+ - `bottom-left`
158
+ - `top-right`
159
+ - `top-left`
160
+ - `bottom-center`
161
+ - `top-center`
162
+ - `center`
163
+
164
+ ### Size Variants
165
+
166
+ | Size | Modal Width | Panel Width |
167
+ | ------ | ----------- | ----------- |
168
+ | small | 360px | 320px |
169
+ | medium | 480px | 420px |
170
+ | large | 600px | 520px |
130
171
 
131
172
  ---
132
173
 
133
- ## Theming
174
+ ## Color Customization
175
+
176
+ Instead of predefined themes, use direct color values for full flexibility:
134
177
 
135
- ```css
136
- :root {
137
- --feedback-primary-color: #10b981;
138
- --feedback-primary-hover: #059669;
139
- --feedback-font-family: 'Inter', sans-serif;
140
- --feedback-border-radius: 8px;
141
- }
178
+ ```javascript
179
+ const widget = feedback.createWidget('button', {
180
+ displayMode: 'modal',
181
+ backgroundColor: '#1a1a2e', // Dark background
182
+ textColor: '#ffffff', // White text
183
+ primaryColor: '#e94560', // Red accent
184
+ });
142
185
  ```
143
186
 
187
+ This approach works better than predefined themes because:
188
+
189
+ - Supports any brand color
190
+ - Works with both light and dark designs
191
+ - No restrictions on color combinations
192
+
193
+ ---
194
+
195
+ ## Custom Triggers
196
+
197
+ Hide the default floating button and trigger from your own UI:
198
+
199
+ ```javascript
200
+ window.FeedbackSDK.onReady((sdk) => {
201
+ const widget = sdk.createWidget('button', {
202
+ displayMode: 'modal',
203
+ size: 'medium',
204
+ });
205
+ widget.mount();
206
+ widget.hide(); // Hide the floating button
207
+
208
+ // Trigger from your own button
209
+ document.getElementById('my-feedback-btn').addEventListener('click', () => {
210
+ widget.openPanel();
211
+ });
212
+ });
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Mock Mode
218
+
219
+ For development without a backend connection:
220
+
221
+ ```javascript
222
+ window.FeedbackSDKConfig = {
223
+ workspace: 'demo',
224
+ mock: true, // No backend required
225
+ userContext: {
226
+ user_id: 'test_user',
227
+ email: 'test@example.com',
228
+ },
229
+ };
230
+ ```
231
+
232
+ Mock mode simulates:
233
+
234
+ - Session initialization
235
+ - Feedback submission (with 500ms delay)
236
+ - Default configuration values
237
+
238
+ ---
239
+
240
+ ## Environments
241
+
242
+ The SDK supports multiple environments for development and production use.
243
+
244
+ ### Production (Default)
245
+
246
+ ```javascript
247
+ const feedback = new FeedbackSDK({
248
+ workspace: 'your-workspace',
249
+ environment: 'production', // Default, can be omitted
250
+ });
251
+ ```
252
+
253
+ **API URLs:**
254
+
255
+ - `https://api.product7.io/api/v1`
256
+ - `https://{workspace}.api.product7.io/api/v1`
257
+
258
+ ### Staging
259
+
260
+ ```javascript
261
+ const feedback = new FeedbackSDK({
262
+ workspace: 'your-workspace',
263
+ environment: 'staging',
264
+ });
265
+ ```
266
+
267
+ **API URLs:**
268
+
269
+ - `https://staging.api.product7.io/api/v1`
270
+ - `https://{workspace}.staging.api.product7.io/api/v1`
271
+
272
+ ### Custom API URL
273
+
274
+ For self-hosted or custom deployments:
275
+
276
+ ```javascript
277
+ const feedback = new FeedbackSDK({
278
+ workspace: 'your-workspace',
279
+ apiUrl: 'https://your-custom-api.com/api/v1',
280
+ });
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Configuration Priority
286
+
287
+ Configuration values merge in this order (later overrides earlier):
288
+
289
+ 1. **Default values** — Built-in SDK defaults
290
+ 2. **Backend config** — Returned from `/widget/init` API
291
+ 3. **SDK config** — `window.FeedbackSDKConfig`
292
+ 4. **Widget options** — Passed to `createWidget()`
293
+
294
+ This allows backend-managed defaults while permitting per-widget customization.
295
+
144
296
  ---
145
297
 
146
298
  ## Events
@@ -184,8 +336,8 @@ npm run size
184
336
 
185
337
  ## Bundle Size
186
338
 
187
- - **Minified**: \~18KB
188
- - **Minified + Gzipped**: \~6KB
339
+ - **Minified**: ~41KB
340
+ - **Minified + Gzipped**: ~12KB
189
341
 
190
342
  ---
191
343