@squeletteapp/widget 3.0.1 → 3.1.1

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.
@@ -1,13 +1,14 @@
1
- import { Widget, Position } from '@squeletteapp/widget-builder';
2
- type ContentTheme = 'light' | 'dark';
1
+ import { Widget, Position } from "@squeletteapp/widget-builder";
2
+ type ContentTheme = "light" | "dark";
3
3
  export type ThemedWidget = Widget & {
4
4
  setTheme(theme: ContentTheme): void;
5
5
  };
6
- type ChangelogBannerOptions = {
6
+ export type ChangelogBannerOptions = {
7
7
  base?: string;
8
8
  contentTheme?: ContentTheme;
9
9
  slug: string;
10
10
  debug?: boolean;
11
+ position?: Position;
11
12
  };
12
13
  type WidgetStore = {
13
14
  getState: () => Record<string, ThemedWidget>;
@@ -1,10 +1,10 @@
1
- import { createWidget } from '@squeletteapp/widget-builder';
1
+ import { createWidget } from "@squeletteapp/widget-builder";
2
2
  // ============================================================================
3
3
  // Constants
4
4
  // ============================================================================
5
5
  const CACHE_DURATION_MS = 5 * 60 * 1000; // 5 minutes
6
- const STORAGE_KEY = 'squelette_banner_last_ticket';
7
- const DEFAULT_BASE = 'https://www.squelette.app';
6
+ const STORAGE_KEY = "squelette_banner_last_ticket";
7
+ const DEFAULT_BASE = "https://www.squelette.app";
8
8
  // ============================================================================
9
9
  // Cache Utilities
10
10
  // ============================================================================
@@ -13,8 +13,8 @@ function getEnableCache(debug) {
13
13
  if (debug === true)
14
14
  return false;
15
15
  try {
16
- const userPreference = localStorage.getItem('squelette-enable-cache');
17
- if (userPreference === 'false')
16
+ const userPreference = localStorage.getItem("squelette-enable-cache");
17
+ if (userPreference === "false")
18
18
  return false;
19
19
  return true;
20
20
  }
@@ -54,7 +54,7 @@ async function fetchLastChangelogTicket(base, slug, debug) {
54
54
  return ticket;
55
55
  }
56
56
  catch (e) {
57
- console.error('[SqueletteBanner] Error fetching changelog ticket:', e);
57
+ console.error("[SqueletteBanner] Error fetching changelog ticket:", e);
58
58
  return null;
59
59
  }
60
60
  }
@@ -77,7 +77,7 @@ function withTheme(widget) {
77
77
  ...widget,
78
78
  setTheme(theme) {
79
79
  const message = {
80
- type: 'THEME_UPDATE',
80
+ type: "THEME_UPDATE",
81
81
  payload: { theme },
82
82
  };
83
83
  widget.sendMessage(message);
@@ -119,11 +119,11 @@ export function createChangelogStore() {
119
119
  // Widget Creators
120
120
  // ============================================================================
121
121
  export function createChangelogEntryWidget(ticketId, options = {}) {
122
- const { base = DEFAULT_BASE, contentTheme = 'light', slug = 'squelette' } = options;
122
+ const { base = DEFAULT_BASE, contentTheme = "light", slug = "squelette" } = options;
123
123
  const widget = createWidget({
124
- elementName: 'sq-changelog-entry-widget',
124
+ elementName: "sq-changelog-entry-widget",
125
125
  source: `${base}/widget/${contentTheme}/${slug}/changelog/${ticketId}`,
126
- position: 'center',
126
+ position: "center",
127
127
  overlay: true,
128
128
  });
129
129
  return withTheme(widget);
@@ -136,7 +136,7 @@ export function createChangelogEntryWidget(ticketId, options = {}) {
136
136
  * - Returns null if nothing to show
137
137
  */
138
138
  export async function createChangelogBannerWidget(store, options) {
139
- const { base = DEFAULT_BASE, contentTheme = 'light', slug, debug = false } = options;
139
+ const { base = DEFAULT_BASE, contentTheme = "light", slug, debug = false, position = "s", } = options;
140
140
  // Fetch the latest ticket
141
141
  const ticket = await fetchLastChangelogTicket(base, slug, debug);
142
142
  if (!ticket) {
@@ -151,9 +151,9 @@ export async function createChangelogBannerWidget(store, options) {
151
151
  // Preload the entry widget for when user clicks the banner
152
152
  store.mount(ticketId, createChangelogEntryWidget(ticketId, { base, contentTheme, slug }));
153
153
  const widget = createWidget({
154
- elementName: 'sq-changelog-banner-widget',
154
+ elementName: "sq-changelog-banner-widget",
155
155
  source: `${base}/widget/${contentTheme}/${slug}/changelog/${ticketId}/banner`,
156
- position: 's',
156
+ position,
157
157
  overlay: false,
158
158
  fitToContent: true,
159
159
  style: {
@@ -162,11 +162,11 @@ export async function createChangelogBannerWidget(store, options) {
162
162
  },
163
163
  onMessage: (type, message, actions) => {
164
164
  // Iframe signals it's ready to be shown
165
- if (type === 'OPEN_WIDGET') {
165
+ if (type === "OPEN_WIDGET") {
166
166
  widget.open();
167
167
  }
168
168
  // User clicked on the banner content
169
- if (type === 'OPEN_CHANGELOG_ENTRY') {
169
+ if (type === "OPEN_CHANGELOG_ENTRY") {
170
170
  const id = message.payload.ticketId;
171
171
  actions.close();
172
172
  store.open(id);
@@ -184,21 +184,21 @@ export async function createChangelogBannerWidget(store, options) {
184
184
  return withTheme(widget);
185
185
  }
186
186
  export function createChangelogEntriesListDropdownWidget(anchor, store, options = {}) {
187
- const { base = DEFAULT_BASE, contentTheme = 'light', slug = 'squelette', position = 'nw' } = options;
187
+ const { base = DEFAULT_BASE, contentTheme = "light", slug = "squelette", position = "nw", } = options;
188
188
  const widget = createWidget({
189
- elementName: 'sq-changelog-entries-list-dropdown-widget',
189
+ elementName: "sq-changelog-entries-list-dropdown-widget",
190
190
  source: `${base}/widget/${contentTheme}/${slug}/changelog/list`,
191
191
  position,
192
192
  anchor,
193
193
  fitToContent: true,
194
194
  onMessage: (type, message, actions) => {
195
- if (type === 'PRELOAD_CHANGELOG_ENTRIES') {
195
+ if (type === "PRELOAD_CHANGELOG_ENTRIES") {
196
196
  const ids = message.payload.ids;
197
197
  for (const id of ids) {
198
198
  store.mount(id, createChangelogEntryWidget(id, { base, contentTheme, slug }));
199
199
  }
200
200
  }
201
- if (type === 'OPEN_CHANGELOG_ENTRY') {
201
+ if (type === "OPEN_CHANGELOG_ENTRY") {
202
202
  const ticketId = message.payload.ticketId;
203
203
  actions.close();
204
204
  store.open(ticketId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squeletteapp/widget",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "Embeddable Squelette widget",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",