@prodigio-io/sdk 2.1.3 → 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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +26 -7
- package/dist/index.mjs +26 -7
- package/package.json +1 -1
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,19 +92,37 @@ async function verifyBadgeToken(token) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
var BADGE_ELEMENT_ID = "prodigio-badge-widget";
|
|
95
|
-
function
|
|
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;
|
|
112
|
+
const wrapper = document.createElement("div");
|
|
113
|
+
wrapper.id = BADGE_ELEMENT_ID;
|
|
114
|
+
wrapper.style.cssText = `
|
|
115
|
+
width: 100%; display: flex; justify-content: flex-end;
|
|
116
|
+
padding: 16px 20px; box-sizing: border-box;
|
|
117
|
+
`;
|
|
98
118
|
const el = document.createElement("a");
|
|
99
|
-
el.id = BADGE_ELEMENT_ID;
|
|
100
119
|
el.href = "https://prodigio.io";
|
|
101
120
|
el.target = "_blank";
|
|
102
121
|
el.rel = "noopener noreferrer";
|
|
103
122
|
el.setAttribute("data-prodigio-badge", "true");
|
|
104
123
|
el.setAttribute("aria-label", "Hiring powered by Prodigio");
|
|
105
124
|
el.style.cssText = `
|
|
106
|
-
|
|
107
|
-
z-index: 2147483647; display: inline-flex; align-items: center; gap: 7px;
|
|
125
|
+
display: inline-flex; align-items: center; gap: 7px;
|
|
108
126
|
padding: 7px 14px; background: #ffffff; border: 1px solid #e5e5e5;
|
|
109
127
|
border-radius: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
110
128
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
@@ -129,7 +147,8 @@ function injectBadge(_position) {
|
|
|
129
147
|
el.addEventListener("mouseleave", () => {
|
|
130
148
|
el.style.boxShadow = "0 2px 8px rgba(0,0,0,0.08)";
|
|
131
149
|
});
|
|
132
|
-
|
|
150
|
+
wrapper.appendChild(el);
|
|
151
|
+
findBadgeContainer(badgeContainer).appendChild(wrapper);
|
|
133
152
|
}
|
|
134
153
|
function removeBadge() {
|
|
135
154
|
var _a;
|
|
@@ -277,7 +296,7 @@ var _Prodigio = class _Prodigio {
|
|
|
277
296
|
if (process.env.NODE_ENV !== "production" && !document.querySelector('meta[name="prodigio-badge"]')) {
|
|
278
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');
|
|
279
298
|
}
|
|
280
|
-
const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig } = config;
|
|
299
|
+
const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig, badgeContainer } = config;
|
|
281
300
|
const position = (_a = badgeConfig == null ? void 0 : badgeConfig.position) != null ? _a : "bottom-right";
|
|
282
301
|
const cached = getCachedToken(key);
|
|
283
302
|
const [initClaims, cachedClaims] = await Promise.all([
|
|
@@ -301,7 +320,7 @@ var _Prodigio = class _Prodigio {
|
|
|
301
320
|
}
|
|
302
321
|
if (careersPath) {
|
|
303
322
|
if (pathMatches(window.location.pathname, careersPath)) {
|
|
304
|
-
injectBadge(position);
|
|
323
|
+
injectBadge(position, badgeContainer);
|
|
305
324
|
} else {
|
|
306
325
|
removeBadge();
|
|
307
326
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -66,19 +66,37 @@ async function verifyBadgeToken(token) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
var BADGE_ELEMENT_ID = "prodigio-badge-widget";
|
|
69
|
-
function
|
|
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;
|
|
86
|
+
const wrapper = document.createElement("div");
|
|
87
|
+
wrapper.id = BADGE_ELEMENT_ID;
|
|
88
|
+
wrapper.style.cssText = `
|
|
89
|
+
width: 100%; display: flex; justify-content: flex-end;
|
|
90
|
+
padding: 16px 20px; box-sizing: border-box;
|
|
91
|
+
`;
|
|
72
92
|
const el = document.createElement("a");
|
|
73
|
-
el.id = BADGE_ELEMENT_ID;
|
|
74
93
|
el.href = "https://prodigio.io";
|
|
75
94
|
el.target = "_blank";
|
|
76
95
|
el.rel = "noopener noreferrer";
|
|
77
96
|
el.setAttribute("data-prodigio-badge", "true");
|
|
78
97
|
el.setAttribute("aria-label", "Hiring powered by Prodigio");
|
|
79
98
|
el.style.cssText = `
|
|
80
|
-
|
|
81
|
-
z-index: 2147483647; display: inline-flex; align-items: center; gap: 7px;
|
|
99
|
+
display: inline-flex; align-items: center; gap: 7px;
|
|
82
100
|
padding: 7px 14px; background: #ffffff; border: 1px solid #e5e5e5;
|
|
83
101
|
border-radius: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
84
102
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
@@ -103,7 +121,8 @@ function injectBadge(_position) {
|
|
|
103
121
|
el.addEventListener("mouseleave", () => {
|
|
104
122
|
el.style.boxShadow = "0 2px 8px rgba(0,0,0,0.08)";
|
|
105
123
|
});
|
|
106
|
-
|
|
124
|
+
wrapper.appendChild(el);
|
|
125
|
+
findBadgeContainer(badgeContainer).appendChild(wrapper);
|
|
107
126
|
}
|
|
108
127
|
function removeBadge() {
|
|
109
128
|
var _a;
|
|
@@ -251,7 +270,7 @@ var _Prodigio = class _Prodigio {
|
|
|
251
270
|
if (process.env.NODE_ENV !== "production" && !document.querySelector('meta[name="prodigio-badge"]')) {
|
|
252
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');
|
|
253
272
|
}
|
|
254
|
-
const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig } = config;
|
|
273
|
+
const { key, badgeToken, baseUrl = DEFAULT_BASE_URL, badge: badgeConfig, badgeContainer } = config;
|
|
255
274
|
const position = (_a = badgeConfig == null ? void 0 : badgeConfig.position) != null ? _a : "bottom-right";
|
|
256
275
|
const cached = getCachedToken(key);
|
|
257
276
|
const [initClaims, cachedClaims] = await Promise.all([
|
|
@@ -275,7 +294,7 @@ var _Prodigio = class _Prodigio {
|
|
|
275
294
|
}
|
|
276
295
|
if (careersPath) {
|
|
277
296
|
if (pathMatches(window.location.pathname, careersPath)) {
|
|
278
|
-
injectBadge(position);
|
|
297
|
+
injectBadge(position, badgeContainer);
|
|
279
298
|
} else {
|
|
280
299
|
removeBadge();
|
|
281
300
|
}
|