@qaiddev/thumbs-embed 1.0.15 → 1.0.17

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
@@ -1,5 +1,8 @@
1
1
  # @qaiddev/thumbs-embed
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@qaiddev/thumbs-embed)](https://www.npmjs.com/package/@qaiddev/thumbs-embed)
4
+ [![coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fqaiddev%2Fthumbs-embed%2Fprod%2Fcoverage-badge.json)](https://github.com/qaiddev/thumbs-embed)
5
+
3
6
  A zero-dependency, lightweight feedback embed that adds thumbs up/down buttons to any website. Users can optionally target specific page elements, leave messages, and capture screenshots — all submitted to your API endpoint or the [QAid.dev hosted dashboard](https://qaid.dev).
4
7
 
5
8
  ## Install
package/dist/embed.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import type { FeedbackConfig } from "./types";
2
+ export declare function isHiddenByUser(apiKey?: string): boolean;
3
+ export declare function setHiddenByUser(apiKey?: string, hidden?: boolean): void;
4
+ /**
5
+ * Get or create a visitor ID stored in localStorage
6
+ */
7
+ export declare function getOrCreateVisitorId(): string;
2
8
  /**
3
9
  * QaidFeedback - Standalone feedback collection embed
4
10
  */
@@ -37,6 +37,33 @@ export declare function calculateArrowPosition(bounds: SelectedBounds, modalLeft
37
37
  * Calculate complete modal position based on selected element bounds
38
38
  */
39
39
  export declare function calculateModalPosition(bounds: SelectedBounds, viewportWidth: number, viewportHeight: number, dimensions?: ModalDimensions): ModalPosition;
40
+ export interface TooltipPositionOptions {
41
+ /** Gap in pixels between anchor and tooltip, and from viewport edges */
42
+ gap?: number;
43
+ }
44
+ /**
45
+ * Calculate tooltip position relative to an anchor, clamped to the viewport.
46
+ * Pure function: no DOM access — caller passes measured rects and viewport size.
47
+ *
48
+ * Strategy:
49
+ * - Place below the anchor by default
50
+ * - Flip above if below would overflow vertically
51
+ * - Clamp horizontally to viewport, then vertically to viewport
52
+ */
53
+ export declare function calculateTooltipPosition(anchor: {
54
+ top: number;
55
+ bottom: number;
56
+ left: number;
57
+ }, tooltip: {
58
+ width: number;
59
+ height: number;
60
+ }, viewport: {
61
+ width: number;
62
+ height: number;
63
+ }, options?: TooltipPositionOptions): {
64
+ top: number;
65
+ left: number;
66
+ };
40
67
  /**
41
68
  * Calculate both modal and arrow positions
42
69
  */
@@ -7,6 +7,14 @@ export interface NetworkCapture {
7
7
  errors: NetworkError[];
8
8
  restore: () => void;
9
9
  }
10
+ /**
11
+ * Truncate a body to max size. Callers must guard against null/undefined.
12
+ */
13
+ export declare function truncateBody(body: unknown): string;
14
+ /**
15
+ * Add an error to the buffer, evicting oldest if at capacity
16
+ */
17
+ export declare function addEntry(errors: NetworkError[], entry: NetworkError): void;
10
18
  /**
11
19
  * Intercept fetch() and XMLHttpRequest to capture network errors (4xx/5xx)
12
20
  */