@prodigio-io/sdk 2.1.4 → 2.1.5

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.mts CHANGED
@@ -6,6 +6,9 @@ interface ProdigioInitConfig {
6
6
  key: string;
7
7
  badgeToken?: string;
8
8
  baseUrl?: string;
9
+ /** CSS selector for the element the badge should be appended into.
10
+ * e.g. '#careers-footer'. Overrides automatic container detection. */
11
+ badgeContainer?: string;
9
12
  badge?: {
10
13
  position?: 'bottom-right' | 'bottom-left';
11
14
  };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,9 @@ interface ProdigioInitConfig {
6
6
  key: string;
7
7
  badgeToken?: string;
8
8
  baseUrl?: string;
9
+ /** CSS selector for the element the badge should be appended into.
10
+ * e.g. '#careers-footer'. Overrides automatic container detection. */
11
+ badgeContainer?: string;
9
12
  badge?: {
10
13
  position?: 'bottom-right' | 'bottom-left';
11
14
  };
package/dist/index.js CHANGED
@@ -92,7 +92,21 @@ async function verifyBadgeToken(token) {
92
92
  }
93
93
  }
94
94
  var BADGE_ELEMENT_ID = "prodigio-badge-widget";
95
- function injectBadge(_position) {
95
+ function findBadgeContainer(badgeContainer) {
96
+ if (badgeContainer) {
97
+ const el = document.querySelector(badgeContainer);
98
+ if (el) return el;
99
+ }
100
+ const anchor = document.querySelector("[data-prodigio-badge-anchor]");
101
+ if (anchor) return anchor;
102
+ const selectors = ["main", '[role="main"]', "#root", "#__next", "#app"];
103
+ for (const sel of selectors) {
104
+ const el = document.querySelector(sel);
105
+ if (el) return el;
106
+ }
107
+ return document.body;
108
+ }
109
+ function injectBadge(_position, badgeContainer) {
96
110
  if (typeof document === "undefined") return;
97
111
  if (document.getElementById(BADGE_ELEMENT_ID)) return;
98
112
  const wrapper = document.createElement("div");
@@ -134,7 +148,7 @@ function injectBadge(_position) {
134
148
  el.style.boxShadow = "0 2px 8px rgba(0,0,0,0.08)";
135
149
  });
136
150
  wrapper.appendChild(el);
137
- document.body.appendChild(wrapper);
151
+ findBadgeContainer(badgeContainer).appendChild(wrapper);
138
152
  }
139
153
  function removeBadge() {
140
154
  var _a;
@@ -282,7 +296,7 @@ var _Prodigio = class _Prodigio {
282
296
  if (process.env.NODE_ENV !== "production" && !document.querySelector('meta[name="prodigio-badge"]')) {
283
297
  console.warn('[Prodigio] Missing <meta name="prodigio-badge" content="true"> in your page <head>. This is required for compliance detection. See docs.prodigio.io');
284
298
  }
285
- const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig } = config;
299
+ const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig, badgeContainer } = config;
286
300
  const position = (_a = badgeConfig == null ? void 0 : badgeConfig.position) != null ? _a : "bottom-right";
287
301
  const cached = getCachedToken(key);
288
302
  const [initClaims, cachedClaims] = await Promise.all([
@@ -306,7 +320,7 @@ var _Prodigio = class _Prodigio {
306
320
  }
307
321
  if (careersPath) {
308
322
  if (pathMatches(window.location.pathname, careersPath)) {
309
- injectBadge(position);
323
+ injectBadge(position, badgeContainer);
310
324
  } else {
311
325
  removeBadge();
312
326
  }
package/dist/index.mjs CHANGED
@@ -66,7 +66,21 @@ async function verifyBadgeToken(token) {
66
66
  }
67
67
  }
68
68
  var BADGE_ELEMENT_ID = "prodigio-badge-widget";
69
- function injectBadge(_position) {
69
+ function findBadgeContainer(badgeContainer) {
70
+ if (badgeContainer) {
71
+ const el = document.querySelector(badgeContainer);
72
+ if (el) return el;
73
+ }
74
+ const anchor = document.querySelector("[data-prodigio-badge-anchor]");
75
+ if (anchor) return anchor;
76
+ const selectors = ["main", '[role="main"]', "#root", "#__next", "#app"];
77
+ for (const sel of selectors) {
78
+ const el = document.querySelector(sel);
79
+ if (el) return el;
80
+ }
81
+ return document.body;
82
+ }
83
+ function injectBadge(_position, badgeContainer) {
70
84
  if (typeof document === "undefined") return;
71
85
  if (document.getElementById(BADGE_ELEMENT_ID)) return;
72
86
  const wrapper = document.createElement("div");
@@ -108,7 +122,7 @@ function injectBadge(_position) {
108
122
  el.style.boxShadow = "0 2px 8px rgba(0,0,0,0.08)";
109
123
  });
110
124
  wrapper.appendChild(el);
111
- document.body.appendChild(wrapper);
125
+ findBadgeContainer(badgeContainer).appendChild(wrapper);
112
126
  }
113
127
  function removeBadge() {
114
128
  var _a;
@@ -256,7 +270,7 @@ var _Prodigio = class _Prodigio {
256
270
  if (process.env.NODE_ENV !== "production" && !document.querySelector('meta[name="prodigio-badge"]')) {
257
271
  console.warn('[Prodigio] Missing <meta name="prodigio-badge" content="true"> in your page <head>. This is required for compliance detection. See docs.prodigio.io');
258
272
  }
259
- const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig } = config;
273
+ const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig, badgeContainer } = config;
260
274
  const position = (_a = badgeConfig == null ? void 0 : badgeConfig.position) != null ? _a : "bottom-right";
261
275
  const cached = getCachedToken(key);
262
276
  const [initClaims, cachedClaims] = await Promise.all([
@@ -280,7 +294,7 @@ var _Prodigio = class _Prodigio {
280
294
  }
281
295
  if (careersPath) {
282
296
  if (pathMatches(window.location.pathname, careersPath)) {
283
- injectBadge(position);
297
+ injectBadge(position, badgeContainer);
284
298
  } else {
285
299
  removeBadge();
286
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prodigio-io/sdk",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Official JavaScript SDK for the Prodigio hiring API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",