@qaiddev/thumbs-embed 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/dist/index.d.ts +274 -0
- package/dist/qaid.js +703 -0
- package/dist/qaid.js.map +1 -0
- package/dist/qaid.umd.cjs +32 -0
- package/dist/qaid.umd.cjs.map +1 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console message captured during the session
|
|
3
|
+
*/
|
|
4
|
+
export declare interface ConsoleError {
|
|
5
|
+
message: string;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
level: "error" | "warn" | "log";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Element bounds for server-side screenshot fallback
|
|
12
|
+
*/
|
|
13
|
+
declare interface ElementBounds {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Configuration options for the FeedbackEmbed
|
|
22
|
+
*/
|
|
23
|
+
export declare interface FeedbackConfig {
|
|
24
|
+
/** Required: API endpoint URL for submitting feedback */
|
|
25
|
+
endpoint: string;
|
|
26
|
+
/** API key for authenticating with the feedback service */
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
/** CSS selector for user-provided container element. If not provided, creates fixed-position container */
|
|
29
|
+
container?: string;
|
|
30
|
+
/** Custom CSS class to apply to thumb buttons. When provided, default button styles are not applied */
|
|
31
|
+
buttonClass?: string;
|
|
32
|
+
/** Position of the feedback buttons. Default: 'bottom-right'. Ignored if container is provided */
|
|
33
|
+
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
34
|
+
/** Offset from edge in pixels. Default: { x: 16, y: 16 } */
|
|
35
|
+
offset?: {
|
|
36
|
+
x?: number;
|
|
37
|
+
y?: number;
|
|
38
|
+
};
|
|
39
|
+
/** z-index for the embed elements. Default: 50 */
|
|
40
|
+
zIndex?: number;
|
|
41
|
+
/** When true, skip element targeting and go directly to feedback modal. Default: false */
|
|
42
|
+
skipTargeting?: boolean;
|
|
43
|
+
/** Custom colors for feedback types */
|
|
44
|
+
colors?: {
|
|
45
|
+
/** Color for positive feedback. Default: rgb(0, 200, 83) */
|
|
46
|
+
positive?: string;
|
|
47
|
+
/** Color for negative feedback. Default: rgb(255, 0, 0) */
|
|
48
|
+
negative?: string;
|
|
49
|
+
/** Color for selected element marker. Default: #6366f1 */
|
|
50
|
+
marker?: string;
|
|
51
|
+
};
|
|
52
|
+
/** Button size. Default: 'medium' (48px). Small: 36px, Large: 64px */
|
|
53
|
+
buttonSize?: "small" | "medium" | "large";
|
|
54
|
+
/** Custom text labels */
|
|
55
|
+
text?: {
|
|
56
|
+
/** Tooltip text for buttons */
|
|
57
|
+
tooltip?: string;
|
|
58
|
+
/** Banner text during targeting */
|
|
59
|
+
bannerText?: string;
|
|
60
|
+
/** Banner hint text */
|
|
61
|
+
bannerHint?: string;
|
|
62
|
+
/** Modal title */
|
|
63
|
+
modalTitle?: string;
|
|
64
|
+
/** Modal subtitle */
|
|
65
|
+
modalSubtitle?: string;
|
|
66
|
+
/** Textarea placeholder */
|
|
67
|
+
placeholder?: string;
|
|
68
|
+
/** Submit button text */
|
|
69
|
+
submitButton?: string;
|
|
70
|
+
/** Skip button text */
|
|
71
|
+
skipButton?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Modal width in pixels. Default: 400 */
|
|
74
|
+
modalWidth?: number;
|
|
75
|
+
/** Backdrop opacity (0-1). Default: 0.3 */
|
|
76
|
+
backdropOpacity?: number;
|
|
77
|
+
/** Font family for text elements. Default: system-ui, -apple-system, sans-serif */
|
|
78
|
+
fontFamily?: string;
|
|
79
|
+
/** Base font size in pixels. Default: 16 */
|
|
80
|
+
fontSize?: number;
|
|
81
|
+
/** Enable screenshot capture with feedback. Default: false */
|
|
82
|
+
captureScreenshot?: boolean;
|
|
83
|
+
/** When true, buttons are hidden until hovered. Default: false */
|
|
84
|
+
incognito?: boolean;
|
|
85
|
+
/** Custom SVG string for positive feedback button icon */
|
|
86
|
+
positiveIcon?: string;
|
|
87
|
+
/** Custom SVG string for negative feedback button icon */
|
|
88
|
+
negativeIcon?: string;
|
|
89
|
+
/** Screenshot options */
|
|
90
|
+
screenshotOptions?: {
|
|
91
|
+
/** Quality of WebP compression (0-1). Default: 1.0 */
|
|
92
|
+
quality?: number;
|
|
93
|
+
/** Max width of the screenshot. Default: 1280 */
|
|
94
|
+
maxWidth?: number;
|
|
95
|
+
/** Max height of the screenshot. Default: 800 */
|
|
96
|
+
maxHeight?: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Current feedback data being collected
|
|
102
|
+
*/
|
|
103
|
+
export declare interface FeedbackData {
|
|
104
|
+
feedbackType: "up" | "down" | null;
|
|
105
|
+
elementSelector: string | null;
|
|
106
|
+
elementText: string | null;
|
|
107
|
+
consoleErrors: ConsoleError[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* FeedbackEmbed - Standalone feedback collection embed
|
|
112
|
+
*/
|
|
113
|
+
export declare class FeedbackEmbed {
|
|
114
|
+
private config;
|
|
115
|
+
private state;
|
|
116
|
+
private feedbackData;
|
|
117
|
+
private selectedBounds;
|
|
118
|
+
private feedbackId;
|
|
119
|
+
private mousePos;
|
|
120
|
+
private lastHighlighted;
|
|
121
|
+
private isMobile;
|
|
122
|
+
private visitorId;
|
|
123
|
+
private consoleCapture;
|
|
124
|
+
private allowedFeatures;
|
|
125
|
+
private container;
|
|
126
|
+
private isUserProvidedContainer;
|
|
127
|
+
private overlayContainer;
|
|
128
|
+
private captureLayer;
|
|
129
|
+
private crosshairH;
|
|
130
|
+
private crosshairV;
|
|
131
|
+
private scope;
|
|
132
|
+
private marker;
|
|
133
|
+
private modalContainer;
|
|
134
|
+
private backdrop;
|
|
135
|
+
private boundKeyDown;
|
|
136
|
+
private boundMouseMove;
|
|
137
|
+
private boundClick;
|
|
138
|
+
private boundResize;
|
|
139
|
+
constructor(config: FeedbackConfig);
|
|
140
|
+
private init;
|
|
141
|
+
private fetchAllowedFeatures;
|
|
142
|
+
private checkMobile;
|
|
143
|
+
private handleResize;
|
|
144
|
+
private createEmbed;
|
|
145
|
+
private tooltipElement;
|
|
146
|
+
private showTooltip;
|
|
147
|
+
private hideTooltip;
|
|
148
|
+
private handleThumbClick;
|
|
149
|
+
private submitDirectFeedback;
|
|
150
|
+
private startTargeting;
|
|
151
|
+
private createTargetingOverlay;
|
|
152
|
+
private handleKeyDown;
|
|
153
|
+
private handleMouseMove;
|
|
154
|
+
private handleClick;
|
|
155
|
+
private cancelTargeting;
|
|
156
|
+
private removeTargetingOverlay;
|
|
157
|
+
private showSelectedMarker;
|
|
158
|
+
private hideSelectedMarker;
|
|
159
|
+
private submitFeedback;
|
|
160
|
+
private showModal;
|
|
161
|
+
private showBottomSheet;
|
|
162
|
+
private showPositionedModal;
|
|
163
|
+
private getModalContent;
|
|
164
|
+
private setupModalInteractions;
|
|
165
|
+
private submitMessage;
|
|
166
|
+
private closeModal;
|
|
167
|
+
/**
|
|
168
|
+
* Destroy the embed and clean up all resources
|
|
169
|
+
*/
|
|
170
|
+
destroy(): void;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Payload for updating feedback with a message
|
|
175
|
+
*/
|
|
176
|
+
export declare interface FeedbackMessagePayload {
|
|
177
|
+
message: string | null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Payload sent to the feedback API
|
|
182
|
+
*/
|
|
183
|
+
export declare interface FeedbackPayload {
|
|
184
|
+
feedbackType: "up" | "down";
|
|
185
|
+
pageUrl: string;
|
|
186
|
+
/** API key for authenticating with the feedback service */
|
|
187
|
+
apiKey?: string;
|
|
188
|
+
elementSelector: string | null;
|
|
189
|
+
elementText: string | null;
|
|
190
|
+
consoleErrors: ConsoleError[];
|
|
191
|
+
screenWidth: number;
|
|
192
|
+
screenHeight: number;
|
|
193
|
+
clickX: number;
|
|
194
|
+
clickY: number;
|
|
195
|
+
scrollX: number;
|
|
196
|
+
scrollY: number;
|
|
197
|
+
/** Base64-encoded screenshot image (WebP) */
|
|
198
|
+
screenshot: string | null;
|
|
199
|
+
/** Random UUID stored in visitor's localStorage (for anonymous feedback) */
|
|
200
|
+
visitorId: string;
|
|
201
|
+
/** Element bounds for server-side screenshot fallback when client screenshot fails */
|
|
202
|
+
elementBounds?: ElementBounds | null;
|
|
203
|
+
/** User agent string for server-side rendering consistency */
|
|
204
|
+
userAgent?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Response from the feedback API
|
|
209
|
+
*/
|
|
210
|
+
export declare interface FeedbackResponse {
|
|
211
|
+
id: number;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Fully resolved configuration with all defaults applied
|
|
216
|
+
* Used internally by the embed after processing user config
|
|
217
|
+
*/
|
|
218
|
+
export declare interface ResolvedFeedbackConfig {
|
|
219
|
+
endpoint: string;
|
|
220
|
+
apiKey: string;
|
|
221
|
+
container: string;
|
|
222
|
+
buttonClass: string;
|
|
223
|
+
position: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
224
|
+
offset: {
|
|
225
|
+
x: number;
|
|
226
|
+
y: number;
|
|
227
|
+
};
|
|
228
|
+
zIndex: number;
|
|
229
|
+
skipTargeting: boolean;
|
|
230
|
+
colors: {
|
|
231
|
+
positive: string;
|
|
232
|
+
negative: string;
|
|
233
|
+
marker: string;
|
|
234
|
+
};
|
|
235
|
+
buttonSize: "small" | "medium" | "large";
|
|
236
|
+
text: {
|
|
237
|
+
tooltip: string;
|
|
238
|
+
bannerText: string;
|
|
239
|
+
bannerHint: string;
|
|
240
|
+
modalTitle: string;
|
|
241
|
+
modalSubtitle: string;
|
|
242
|
+
placeholder: string;
|
|
243
|
+
submitButton: string;
|
|
244
|
+
skipButton: string;
|
|
245
|
+
};
|
|
246
|
+
modalWidth: number;
|
|
247
|
+
backdropOpacity: number;
|
|
248
|
+
fontFamily: string;
|
|
249
|
+
fontSize: number;
|
|
250
|
+
captureScreenshot: boolean;
|
|
251
|
+
screenshotOptions: {
|
|
252
|
+
quality: number;
|
|
253
|
+
maxWidth: number;
|
|
254
|
+
maxHeight: number;
|
|
255
|
+
};
|
|
256
|
+
incognito: boolean;
|
|
257
|
+
positiveIcon: string;
|
|
258
|
+
negativeIcon: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Bounds of the selected element
|
|
263
|
+
*/
|
|
264
|
+
export declare interface SelectedBounds {
|
|
265
|
+
x: number;
|
|
266
|
+
y: number;
|
|
267
|
+
width: number;
|
|
268
|
+
height: number;
|
|
269
|
+
clickX: number;
|
|
270
|
+
clickY: number;
|
|
271
|
+
visible: boolean;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export { }
|