@squeletteapp/widget 0.1.0 → 0.3.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 (34) hide show
  1. package/README.md +112 -0
  2. package/dist/app-BpPatA6a.js +42 -0
  3. package/dist/index-B0eQqkb_.js +7951 -0
  4. package/dist/types/app/app.d.ts +15 -0
  5. package/dist/types/banner/banner-modal.d.ts +15 -0
  6. package/dist/types/banner/banner.d.ts +14 -0
  7. package/dist/types/banner/element.d.ts +7 -0
  8. package/dist/types/banner/index.d.ts +19 -0
  9. package/dist/types/index.d.ts +10 -0
  10. package/dist/types/utils.d.ts +2 -0
  11. package/dist/types/widget/__tests__/widget.test.d.ts +1 -0
  12. package/dist/types/widget/components/widget-shell.d.ts +8 -0
  13. package/dist/types/widget/constants.d.ts +9 -0
  14. package/dist/types/widget/core/custom-element.d.ts +142 -0
  15. package/dist/types/widget/core/global-api.d.ts +97 -0
  16. package/dist/types/widget/core/identity.d.ts +73 -0
  17. package/dist/types/widget/core/panel-dimensions.d.ts +36 -0
  18. package/dist/types/widget/core/positioning.d.ts +63 -0
  19. package/dist/types/widget/core/scroll-lock.d.ts +28 -0
  20. package/dist/types/widget/element.d.ts +90 -0
  21. package/dist/types/widget/events.d.ts +13 -0
  22. package/dist/types/widget/factories.d.ts +41 -0
  23. package/dist/types/widget/styles.d.ts +8 -0
  24. package/dist/types/widget/types.d.ts +79 -0
  25. package/dist/types/widget/utils.d.ts +12 -0
  26. package/dist/widget.es.js +14 -0
  27. package/dist/widget.js +168 -15
  28. package/package.json +32 -18
  29. package/dist/button-component.d.ts +0 -2
  30. package/dist/button-component.js +0 -158
  31. package/dist/index.d.ts +0 -26
  32. package/dist/index.js +0 -230
  33. package/dist/styles.css +0 -567
  34. package/dist/widget.d.ts +0 -42
@@ -0,0 +1,41 @@
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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,79 @@
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
+ }
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,14 @@
1
+ import { h as a, g as r, S as s, c as d, e as i, b as l, d as g, a as n, f as c, i as W, r as o } from "./index-B0eQqkb_.js";
2
+ export {
3
+ a as SqueletteBanner,
4
+ r as SqueletteBannerElement,
5
+ s as SqueletteWidgetElement,
6
+ d as clearIdentity,
7
+ i as createChangelogWidget,
8
+ l as createFeedbackWidget,
9
+ g as createRoadmapWidget,
10
+ n as createWidget,
11
+ c as ensureGlobalHelper,
12
+ W as identify,
13
+ o as registerSqueletteWidget
14
+ };