@squeletteapp/widget 0.4.0 → 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.
Files changed (35) hide show
  1. package/dist/changelog-entry.d.ts +43 -0
  2. package/dist/changelog-entry.js +224 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -0
  5. package/package.json +9 -22
  6. package/dist/app-CZ8ztknA.js +0 -40
  7. package/dist/index-Bj_9-5Hl.js +0 -5524
  8. package/dist/types/app/app.d.ts +0 -15
  9. package/dist/types/banner/banner-modal.d.ts +0 -17
  10. package/dist/types/banner/banner.d.ts +0 -17
  11. package/dist/types/banner/element.d.ts +0 -7
  12. package/dist/types/banner/index.d.ts +0 -24
  13. package/dist/types/banner/use-css-animation.d.ts +0 -37
  14. package/dist/types/changelog/changelog.d.ts +0 -15
  15. package/dist/types/changelog/element.d.ts +0 -86
  16. package/dist/types/changelog/index.d.ts +0 -32
  17. package/dist/types/index.d.ts +0 -12
  18. package/dist/types/utils.d.ts +0 -2
  19. package/dist/types/widget/__tests__/widget.test.d.ts +0 -1
  20. package/dist/types/widget/components/widget-shell.d.ts +0 -8
  21. package/dist/types/widget/constants.d.ts +0 -9
  22. package/dist/types/widget/core/custom-element.d.ts +0 -142
  23. package/dist/types/widget/core/global-api.d.ts +0 -97
  24. package/dist/types/widget/core/identity.d.ts +0 -73
  25. package/dist/types/widget/core/panel-dimensions.d.ts +0 -36
  26. package/dist/types/widget/core/positioning.d.ts +0 -63
  27. package/dist/types/widget/core/scroll-lock.d.ts +0 -28
  28. package/dist/types/widget/element.d.ts +0 -90
  29. package/dist/types/widget/events.d.ts +0 -13
  30. package/dist/types/widget/factories.d.ts +0 -41
  31. package/dist/types/widget/styles.d.ts +0 -8
  32. package/dist/types/widget/types.d.ts +0 -79
  33. package/dist/types/widget/utils.d.ts +0 -12
  34. package/dist/widget.es.js +0 -16
  35. package/dist/widget.js +0 -176
@@ -1,63 +0,0 @@
1
- /**
2
- * Widget Positioning System
3
- *
4
- * Handles advanced positioning logic for the widget.
5
- * This module supports two positioning modes:
6
- *
7
- * 1. **Button-anchored positioning**: Widget appears relative to a trigger button
8
- * - Dynamically calculates optimal placement (top/bottom/left/right)
9
- * - Automatically repositions on scroll/resize
10
- * - Ensures widget stays within viewport bounds
11
- * - Supports collision detection and smart fallback positioning
12
- *
13
- * 2. **Fixed positioning**: Widget appears at a fixed viewport location
14
- * - Supports 9 preset positions (fixed-top-left, fixed-center-center, etc.)
15
- * - Maintains position regardless of page scroll
16
- * - Respects viewport margins and responsive layouts
17
- *
18
- * This module also handles:
19
- * - Click-outside detection to close the widget
20
- * - Overlay blur effects
21
- * - Custom button selector binding
22
- * - Lifecycle cleanup for event listeners
23
- *
24
- * @example
25
- * ```ts
26
- * const cleanup = applyPositioning(element, {
27
- * buttonSelector: '#feedback-button',
28
- * position: 'bottom',
29
- * overlayBlur: true
30
- * });
31
- *
32
- * // Later: cleanup all event listeners
33
- * cleanup();
34
- * ```
35
- */
36
- import type { SqueletteWidgetElement } from "./custom-element";
37
- import type { WidgetPosition } from "../types";
38
- /**
39
- * Widget positioning and binding options.
40
- */
41
- export interface PositioningOptions {
42
- /** CSS selector for the button that triggers the widget */
43
- buttonSelector?: string;
44
- /** Preferred position relative to button or fixed viewport position */
45
- position?: WidgetPosition;
46
- /** Whether to apply blur effect to the overlay backdrop */
47
- overlayBlur?: boolean;
48
- /** Callback when widget open state changes */
49
- onOpenChange?: (open: boolean) => void;
50
- /** Callback when widget iframe finishes loading */
51
- onLoad?: () => void;
52
- }
53
- /**
54
- * Applies positioning and event bindings to a widget element.
55
- *
56
- * This function sets up all the positioning logic, event listeners, and
57
- * custom behaviors needed for the widget.
58
- *
59
- * @param element - The widget element to enhance
60
- * @param options - Positioning and behavior options
61
- * @returns Array of cleanup functions to remove all applied behaviors
62
- */
63
- export declare function applyPositioning(element: SqueletteWidgetElement, options: PositioningOptions): Array<() => void>;
@@ -1,28 +0,0 @@
1
- /**
2
- * Body Scroll Lock Utility
3
- *
4
- * Manages the locking and unlocking of body scroll when the widget panel is open.
5
- * This prevents the underlying page from scrolling while the user interacts with
6
- * the widget overlay.
7
- *
8
- * Key behaviors:
9
- * - Locks body scroll by setting `overflow: hidden`
10
- * - Calculates and compensates for scrollbar width to prevent layout shift
11
- * - Returns a cleanup function to restore original scroll state
12
- * - Preserves original overflow and padding-right values
13
- *
14
- * @example
15
- * ```ts
16
- * const restoreScroll = toggleBodyScroll(true);
17
- * // ... widget is open, body cannot scroll
18
- * restoreScroll(); // restore original scroll behavior
19
- * ```
20
- */
21
- /**
22
- * Toggles body scroll lock and compensates for scrollbar width
23
- * to prevent layout shift.
24
- *
25
- * @param lock - Whether to lock (true) or unlock (false) body scroll
26
- * @returns A cleanup function that restores the original scroll state
27
- */
28
- export declare function toggleBodyScroll(lock: boolean): () => void;
@@ -1,90 +0,0 @@
1
- /**
2
- * Widget Element Module
3
- *
4
- * This is the main entry point for the widget's custom element implementation.
5
- * It has been refactored into smaller, focused modules for better maintainability:
6
- *
7
- * **Module Structure:**
8
- *
9
- * - `core/custom-element.ts` - The `<squelette-widget>` custom element class
10
- * - Handles Shadow DOM, lifecycle methods, attribute observation
11
- * - Manages widget state (open/closed, loading, theme)
12
- * - Coordinates iframe loading and communication
13
- *
14
- * - `core/identity.ts` - User identity management
15
- * - Global identity store for all widget instances
16
- * - `identify()` and `clearIdentity()` functions
17
- * - Event-based identity synchronization
18
- *
19
- * - `core/scroll-lock.ts` - Body scroll management
20
- * - Locks page scroll when widget is open
21
- * - Compensates for scrollbar width to prevent layout shift
22
- *
23
- * - `core/panel-dimensions.ts` - Widget panel dimensions
24
- * - Default dimensions for each view type (feedback, roadmap, changelog)
25
- * - CSS custom property application
26
- *
27
- * - `core/positioning.ts` - Advanced positioning system
28
- * - Button-anchored positioning with collision detection
29
- * - Fixed viewport positioning (9 preset positions)
30
- * - Click-outside-to-close behavior
31
- * - Responsive viewport tracking
32
- *
33
- * - `core/global-api.ts` - Global `window.SqueletteWidget` API
34
- * - Factory functions for creating widgets
35
- * - Convenient JavaScript API layer
36
- * - Version and CDN information
37
- *
38
- * **Usage:**
39
- *
40
- * Declarative (HTML):
41
- * ```html
42
- * <squelette-widget
43
- * project="my-project"
44
- * board="feedback"
45
- * theme="auto"
46
- * locale="en"
47
- * ></squelette-widget>
48
- * ```
49
- *
50
- * Programmatic (JavaScript):
51
- * ```js
52
- * const widget = SqueletteWidget.create({
53
- * project: 'my-project',
54
- * board: 'feedback',
55
- * view: 'feedback'
56
- * });
57
- *
58
- * await widget.open();
59
- * widget.on('submit', (e) => console.log(e.payload));
60
- * ```
61
- *
62
- * Alternative API:
63
- * ```js
64
- * const widget = SqueletteWidget.createFeedbackWidget('my-project', 'feedback', {
65
- * buttonSelector: '#feedback-button',
66
- * position: 'bottom',
67
- * overlayBlur: true
68
- * });
69
- * ```
70
- *
71
- * Identity Management:
72
- * ```js
73
- * SqueletteWidget.identify({
74
- * userId: '123',
75
- * email: 'user@example.com',
76
- * signature: 'hmac-signature',
77
- * name: 'John Doe' // optional
78
- * });
79
- *
80
- * SqueletteWidget.clearIdentity(); // on logout
81
- * ```
82
- */
83
- export { SqueletteWidgetElement, registerSqueletteWidget, } from "./core/custom-element";
84
- export { identify, clearIdentity } from "./core/identity";
85
- export { ensureGlobalHelper, type GlobalSqueletteWidget, } from "./core/global-api";
86
- declare global {
87
- interface HTMLElementTagNameMap {
88
- "squelette-widget": import("./core/custom-element").SqueletteWidgetElement;
89
- }
90
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Lightweight event emitter dedicated to the widget element. It keeps
3
- * allocation pressure low while offering an ergonomic `.on()` API for clients
4
- * embedding the widget and for internal coordination between the shell and the
5
- * custom element lifecycle.
6
- */
7
- import type { WidgetEventListener, WidgetEventName, WidgetEventDetailMap } from './types';
8
- export declare class WidgetEventEmitter {
9
- private listeners;
10
- on<K extends WidgetEventName>(event: K, handler: WidgetEventListener<K>): () => void;
11
- off<K extends WidgetEventName>(event: K, handler: WidgetEventListener<K>): void;
12
- emit<K extends WidgetEventName>(event: K, payload: WidgetEventDetailMap[K]): void;
13
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Widget Factory Functions
3
- *
4
- * Provides convenient factory functions for creating widget instances programmatically.
5
- * These functions are thin wrappers around the global API methods, allowing tree-shakeable
6
- * imports for modern bundlers.
7
- *
8
- * These exports are primarily for the widget-react package and other programmatic
9
- * integrations that prefer direct imports over the global `window.SqueletteWidget` API.
10
- *
11
- * @example
12
- * ```ts
13
- * import { createFeedbackWidget } from '@squeletteapp/widget';
14
- *
15
- * const widget = createFeedbackWidget('my-project', 'feedback', {
16
- * buttonSelector: '#feedback-btn',
17
- * position: 'bottom'
18
- * });
19
- * ```
20
- */
21
- import { type GlobalSqueletteWidget } from "./core/global-api";
22
- /**
23
- * Creates a feedback widget.
24
- * Alias for window.SqueletteWidget.createFeedbackWidget
25
- */
26
- export declare function createFeedbackWidget(...args: Parameters<GlobalSqueletteWidget["createFeedbackWidget"]>): import("./element").SqueletteWidgetElement;
27
- /**
28
- * Creates a roadmap widget.
29
- * Alias for window.SqueletteWidget.createRoadmapWidget
30
- */
31
- export declare function createRoadmapWidget(...args: Parameters<GlobalSqueletteWidget["createRoadmapWidget"]>): import("./element").SqueletteWidgetElement;
32
- /**
33
- * Creates a changelog widget.
34
- * Alias for window.SqueletteWidget.createChangelogWidget
35
- */
36
- export declare function createChangelogWidget(...args: Parameters<GlobalSqueletteWidget["createChangelogWidget"]>): import("./element").SqueletteWidgetElement;
37
- /**
38
- * Creates a widget with the modern API.
39
- * Alias for window.SqueletteWidget.create
40
- */
41
- export declare function createWidget(...args: Parameters<GlobalSqueletteWidget["create"]>): import("./element").SqueletteWidgetElement;
@@ -1,8 +0,0 @@
1
- /**
2
- * Style helpers shared by the widget element. Constructable stylesheets are
3
- * used when available for optimal performance; otherwise, we fall back to a
4
- * simple `<style>` tag appended to the shadow root.
5
- */
6
- export declare const baseStyles = "\n:host {\n position: relative;\n z-index: 2147483000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n color: var(--sq-fg, #0f172a);\n --sq-offset-top: auto;\n --sq-offset-right: 24px;\n --sq-offset-bottom: 24px;\n --sq-offset-left: auto;\n --sq-panel-width: min(420px, 92vw);\n --sq-panel-height: min(420px, 80vh);\n}\n\n.sq-root {\n position: fixed;\n top: var(--sq-offset-top);\n right: var(--sq-offset-right);\n bottom: var(--sq-offset-bottom);\n left: var(--sq-offset-left);\n display: flex;\n align-items: flex-end;\n gap: 12px;\n}\n\n.sq-trigger {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n border: none;\n border-radius: 999px;\n padding: 10px 16px;\n font-size: 14px;\n font-weight: 600;\n background: var(--sq-accent, #6366f1);\n color: #fff;\n cursor: pointer;\n box-shadow: var(--sq-shadow, 0 30px 60px rgba(15, 23, 42, 0.25));\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;\n}\n\n:host([data-launcher-hidden='true']) .sq-trigger {\n display: none;\n}\n\n.sq-trigger:hover {\n transform: translateY(-1px);\n box-shadow: 0 20px 40px rgba(15, 23, 42, 0.28);\n}\n\n.sq-trigger-icon {\n display: inline-flex;\n width: 18px;\n height: 18px;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n background: rgba(255, 255, 255, 0.16);\n font-size: 12px;\n line-height: 1;\n}\n\n.sq-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.2);\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.22s ease;\n z-index: 0;\n}\n\n.sq-overlay[data-state='open'] {\n opacity: 1;\n pointer-events: auto;\n}\n\n:host([data-overlay-blur='off']) .sq-overlay {\n backdrop-filter: none;\n}\n\n.sq-panel {\n position: relative;\n display: flex;\n pointer-events: auto;\n width: var(--sq-panel-width, min(420px, 92vw));\n height: var(--sq-panel-height, min(520px, 80vh));\n max-height: min(80vh, 680px);\n border-radius: var(--sq-radius, 16px);\n overflow: hidden;\n box-shadow: var(--sq-shadow, 0 30px 60px rgba(15, 23, 42, 0.25));\n border: 1px solid var(--sq-border, rgba(15, 23, 42, 0.08));\n background: var(--sq-bg, #ffffff);\n transform: none;\n opacity: 1;\n transition: none;\n z-index: 1;\n}\n\n.sq-panel[data-state='closed'] {\n pointer-events: none;\n display: none;\n}\n\n:host([data-anchor-origin='top']) .sq-panel {\n transform-origin: top center;\n}\n\n:host([data-anchor-origin='bottom']) .sq-panel {\n transform-origin: bottom center;\n}\n\n:host([data-anchor-origin='left']) .sq-panel {\n transform-origin: center left;\n}\n\n:host([data-anchor-origin='right']) .sq-panel {\n transform-origin: center right;\n}\n\n.sq-panel[data-state='open'] {\n opacity: 1;\n transform: translateY(0) scale(1);\n}\n\n@media (max-width: 640px) {\n .sq-root {\n bottom: 16px;\n right: 16px;\n }\n\n .sq-panel {\n width: min(100vw - 24px, 380px);\n max-height: min(85vh, 720px);\n }\n}\n";
7
- export declare function adoptStyles(root: ShadowRoot, cssText: string): void;
8
- export declare function adoptBaseStyles(root: ShadowRoot): void;
@@ -1,79 +0,0 @@
1
- /**
2
- * Shared type definitions for the widget entry-point. These types are used by
3
- * both the custom element class and the shell component so keeping them in a
4
- * dedicated module prevents import cycles while improving discoverability.
5
- */
6
- import type { ComponentType } from "preact";
7
- import type { WidgetFrameProps } from "../app/app";
8
- export type WidgetTheme = "light" | "dark" | "auto";
9
- export type WidgetEventName = "open" | "close" | "submit";
10
- export type WidgetFloatingPosition = "top" | "bottom" | "left" | "right";
11
- export type WidgetFixedPosition = `fixed-${"top" | "center" | "bottom"}-${"left" | "center" | "right"}`;
12
- export type WidgetPosition = WidgetFloatingPosition | WidgetFixedPosition;
13
- export type WidgetView = "feedback" | "roadmap" | "changelog";
14
- export interface WidgetSubmitPayload {
15
- projectId: string;
16
- board?: string | null;
17
- locale: string;
18
- data?: Record<string, unknown>;
19
- }
20
- export interface WidgetIdentityPayload {
21
- userId: string;
22
- email: string;
23
- signature: string;
24
- name?: string;
25
- avatar?: string;
26
- [key: string]: unknown;
27
- }
28
- export interface WidgetEventDetailMap {
29
- open: {
30
- source: "api" | "attribute";
31
- };
32
- close: {
33
- source: "api" | "attribute";
34
- };
35
- submit: {
36
- source: "app";
37
- payload: WidgetSubmitPayload;
38
- };
39
- }
40
- export type WidgetEventListener<K extends WidgetEventName> = (detail: WidgetEventDetailMap[K]) => void;
41
- export interface CreateWidgetOptions {
42
- project: string;
43
- board?: string;
44
- theme?: WidgetTheme;
45
- locale?: string;
46
- token?: string;
47
- signature?: string;
48
- appendTo?: HTMLElement;
49
- attributes?: Record<string, string>;
50
- label?: string;
51
- view?: WidgetView;
52
- apiBase?: string;
53
- }
54
- export interface InternalWidgetConfig {
55
- project: string | null;
56
- board: string | null;
57
- theme: WidgetTheme;
58
- locale: string;
59
- token?: string;
60
- signature?: string;
61
- apiBase: string;
62
- label: string;
63
- view: WidgetView;
64
- }
65
- export interface LazyModule {
66
- WidgetFrame?: ComponentType<WidgetFrameProps>;
67
- default?: ComponentType<WidgetFrameProps>;
68
- stylesText?: string;
69
- }
70
- export interface WidgetShellProps {
71
- open: boolean;
72
- label: string;
73
- iframeSrc: string | null;
74
- FrameComponent: ComponentType<WidgetFrameProps> | null;
75
- ensureFrame: () => void | Promise<void>;
76
- onOpen: () => void;
77
- onClose: () => void;
78
- onFrameLoaded: () => void;
79
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Utility helpers for attribute reflection, locale/theme resolution, and
3
- * building the iframe URL. These functions are intentionally pure to simplify
4
- * unit testing and future extraction into shared packages.
5
- */
6
- import type { WidgetTheme, InternalWidgetConfig, WidgetView } from './types';
7
- export declare function reflectBooleanAttribute(el: HTMLElement, name: string, value: boolean): void;
8
- export declare function resolveLocale(locale?: string | null): string;
9
- export declare function resolveTheme(theme?: string | null): WidgetTheme;
10
- export declare function resolveView(view?: string | null): WidgetView;
11
- export declare function buildIframeSrc(config: InternalWidgetConfig): string | null;
12
- export declare function configureTheme(host: HTMLElement, theme: WidgetTheme): () => void;
package/dist/widget.es.js DELETED
@@ -1,16 +0,0 @@
1
- import { h as a, g as l, k as s, j as g, S as r, c as n, e as d, b as i, d as c, a as o, f as u, i as S, r as q } from "./index-Bj_9-5Hl.js";
2
- export {
3
- a as SqueletteBanner,
4
- l as SqueletteBannerElement,
5
- s as SqueletteChangelog,
6
- g as SqueletteChangelogElement,
7
- r as SqueletteWidgetElement,
8
- n as clearIdentity,
9
- d as createChangelogWidget,
10
- i as createFeedbackWidget,
11
- c as createRoadmapWidget,
12
- o as createWidget,
13
- u as ensureGlobalHelper,
14
- S as identify,
15
- q as registerSqueletteWidget
16
- };