@iqworksai/consentiq-react 0.1.4 → 0.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/README.md +10 -10
- package/dist/index.d.mts +128 -18
- package/dist/index.d.ts +128 -18
- package/dist/index.js +557 -125
- package/dist/index.mjs +549 -121
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createContext, useContext, useEffect, useState, useCallback, useMemo } from "react";
|
|
3
3
|
|
|
4
4
|
// src/api-client.ts
|
|
5
|
-
var DEFAULT_API_URL = "https://
|
|
5
|
+
var DEFAULT_API_URL = "https://consent.iqworks.ai";
|
|
6
6
|
var ConsentIQApiClient = class {
|
|
7
7
|
constructor(propertyKey, apiUrl, debug = false) {
|
|
8
8
|
this.propertyKey = propertyKey;
|
|
@@ -133,6 +133,10 @@ var DEFAULT_CONSENT = {
|
|
|
133
133
|
social: false
|
|
134
134
|
};
|
|
135
135
|
var CONSENT_STORAGE_KEY = "consentiq_consent";
|
|
136
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "sd", "dv", "yi"]);
|
|
137
|
+
function isRtlLanguage(lang) {
|
|
138
|
+
return RTL_LANGUAGES.has(lang.split("-")[0].toLowerCase());
|
|
139
|
+
}
|
|
136
140
|
function ConsentIQProvider({
|
|
137
141
|
children,
|
|
138
142
|
propertyKey,
|
|
@@ -144,6 +148,7 @@ function ConsentIQProvider({
|
|
|
144
148
|
onClose,
|
|
145
149
|
autoShow = true,
|
|
146
150
|
language: preferredLanguage,
|
|
151
|
+
locale,
|
|
147
152
|
debug = false
|
|
148
153
|
}) {
|
|
149
154
|
const [config, setConfig] = useState(null);
|
|
@@ -155,7 +160,6 @@ function ConsentIQProvider({
|
|
|
155
160
|
const [language, setLanguage] = useState("en");
|
|
156
161
|
const [regulation, setRegulation] = useState(null);
|
|
157
162
|
const [subjectId, setSubjectId] = useState("");
|
|
158
|
-
const [hasExistingConsent, setHasExistingConsent] = useState(false);
|
|
159
163
|
const apiClient = useMemo(
|
|
160
164
|
() => new ConsentIQApiClient(propertyKey, apiUrl, debug),
|
|
161
165
|
[propertyKey, apiUrl, debug]
|
|
@@ -185,7 +189,7 @@ function ConsentIQProvider({
|
|
|
185
189
|
setSubjectId(sid);
|
|
186
190
|
const propertyConfig = await apiClient.getConfig();
|
|
187
191
|
setConfig(propertyConfig);
|
|
188
|
-
const detectedLang = preferredLanguage || detectLanguage(propertyConfig.property.supportedLanguages);
|
|
192
|
+
const detectedLang = preferredLanguage || locale || detectLanguage(propertyConfig.property.supportedLanguages);
|
|
189
193
|
setLanguage(detectedLang);
|
|
190
194
|
const country = detectCountry();
|
|
191
195
|
if (country && propertyConfig.geoRules) {
|
|
@@ -204,14 +208,12 @@ function ConsentIQProvider({
|
|
|
204
208
|
if (existingConsent.marketingConsents) {
|
|
205
209
|
setMarketingConsent(existingConsent.marketingConsents);
|
|
206
210
|
}
|
|
207
|
-
setHasExistingConsent(true);
|
|
208
211
|
saveLocalConsent(existingConsent.cookieConsents);
|
|
209
212
|
foundExistingConsent = true;
|
|
210
213
|
} else {
|
|
211
214
|
const localConsent = loadLocalConsent();
|
|
212
215
|
if (localConsent) {
|
|
213
216
|
setConsent(localConsent);
|
|
214
|
-
setHasExistingConsent(true);
|
|
215
217
|
foundExistingConsent = true;
|
|
216
218
|
}
|
|
217
219
|
}
|
|
@@ -233,6 +235,7 @@ function ConsentIQProvider({
|
|
|
233
235
|
providedSubjectId,
|
|
234
236
|
autoGenerateSubjectId,
|
|
235
237
|
preferredLanguage,
|
|
238
|
+
locale,
|
|
236
239
|
autoShow
|
|
237
240
|
]);
|
|
238
241
|
const submitConsent = useCallback(
|
|
@@ -281,10 +284,10 @@ function ConsentIQProvider({
|
|
|
281
284
|
allAccepted.social = true;
|
|
282
285
|
}
|
|
283
286
|
setConsent(allAccepted);
|
|
284
|
-
await submitConsent(allAccepted, marketingConsent);
|
|
285
287
|
setIsBannerVisible(false);
|
|
286
288
|
setIsPreferenceCenterVisible(false);
|
|
287
289
|
onClose?.();
|
|
290
|
+
void submitConsent(allAccepted, marketingConsent);
|
|
288
291
|
}, [config, marketingConsent, submitConsent, onClose]);
|
|
289
292
|
const rejectAll = useCallback(async () => {
|
|
290
293
|
const allRejected = {
|
|
@@ -296,10 +299,10 @@ function ConsentIQProvider({
|
|
|
296
299
|
social: false
|
|
297
300
|
};
|
|
298
301
|
setConsent(allRejected);
|
|
299
|
-
await submitConsent(allRejected, {});
|
|
300
302
|
setIsBannerVisible(false);
|
|
301
303
|
setIsPreferenceCenterVisible(false);
|
|
302
304
|
onClose?.();
|
|
305
|
+
void submitConsent(allRejected, {});
|
|
303
306
|
}, [submitConsent, onClose]);
|
|
304
307
|
const updateConsent = useCallback(
|
|
305
308
|
async (updates) => {
|
|
@@ -310,7 +313,7 @@ function ConsentIQProvider({
|
|
|
310
313
|
// Always enforce necessary
|
|
311
314
|
};
|
|
312
315
|
setConsent(newConsent);
|
|
313
|
-
|
|
316
|
+
void submitConsent(newConsent, marketingConsent);
|
|
314
317
|
},
|
|
315
318
|
[consent, marketingConsent, submitConsent]
|
|
316
319
|
);
|
|
@@ -318,10 +321,13 @@ function ConsentIQProvider({
|
|
|
318
321
|
async (updates) => {
|
|
319
322
|
const newMarketingConsent = { ...marketingConsent, ...updates };
|
|
320
323
|
setMarketingConsent(newMarketingConsent);
|
|
321
|
-
|
|
324
|
+
void submitConsent(consent, newMarketingConsent);
|
|
322
325
|
},
|
|
323
326
|
[consent, marketingConsent, submitConsent]
|
|
324
327
|
);
|
|
328
|
+
const changeLanguage = useCallback((lang) => {
|
|
329
|
+
setLanguage(lang);
|
|
330
|
+
}, []);
|
|
325
331
|
const showBanner = useCallback(() => {
|
|
326
332
|
setIsBannerVisible(true);
|
|
327
333
|
onOpen?.();
|
|
@@ -342,12 +348,12 @@ function ConsentIQProvider({
|
|
|
342
348
|
const resetConsent = useCallback(() => {
|
|
343
349
|
setConsent(DEFAULT_CONSENT);
|
|
344
350
|
setMarketingConsent({});
|
|
345
|
-
setHasExistingConsent(false);
|
|
346
351
|
if (typeof window !== "undefined") {
|
|
347
352
|
localStorage.removeItem(CONSENT_STORAGE_KEY);
|
|
348
353
|
localStorage.removeItem("consentiq_subject_id");
|
|
349
354
|
}
|
|
350
355
|
}, []);
|
|
356
|
+
const dir = isRtlLanguage(language) ? "rtl" : "ltr";
|
|
351
357
|
const contextValue = useMemo(
|
|
352
358
|
() => ({
|
|
353
359
|
consent,
|
|
@@ -357,6 +363,8 @@ function ConsentIQProvider({
|
|
|
357
363
|
isBannerVisible,
|
|
358
364
|
isPreferenceCenterVisible,
|
|
359
365
|
language,
|
|
366
|
+
changeLanguage,
|
|
367
|
+
dir,
|
|
360
368
|
regulation,
|
|
361
369
|
hasConsent,
|
|
362
370
|
hasMarketingConsent,
|
|
@@ -378,6 +386,8 @@ function ConsentIQProvider({
|
|
|
378
386
|
isBannerVisible,
|
|
379
387
|
isPreferenceCenterVisible,
|
|
380
388
|
language,
|
|
389
|
+
changeLanguage,
|
|
390
|
+
dir,
|
|
381
391
|
regulation,
|
|
382
392
|
hasConsent,
|
|
383
393
|
hasMarketingConsent,
|
|
@@ -413,14 +423,70 @@ function useConsentGate(category) {
|
|
|
413
423
|
};
|
|
414
424
|
}
|
|
415
425
|
|
|
426
|
+
// src/components/LanguageSelector.tsx
|
|
427
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
428
|
+
function languageLabel(code) {
|
|
429
|
+
try {
|
|
430
|
+
const display = new Intl.DisplayNames([code], { type: "language" });
|
|
431
|
+
const name = display.of(code);
|
|
432
|
+
if (name) {
|
|
433
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
434
|
+
}
|
|
435
|
+
} catch {
|
|
436
|
+
}
|
|
437
|
+
return code.toUpperCase();
|
|
438
|
+
}
|
|
439
|
+
function LanguageSelector({ className, style }) {
|
|
440
|
+
const { config, language, changeLanguage, dir } = useConsentIQ();
|
|
441
|
+
const languages = config?.property.supportedLanguages ?? [];
|
|
442
|
+
if (languages.length <= 1) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
const caretSide = dir === "rtl" ? "left" : "right";
|
|
446
|
+
return /* @__PURE__ */ jsx2(
|
|
447
|
+
"select",
|
|
448
|
+
{
|
|
449
|
+
className,
|
|
450
|
+
value: language,
|
|
451
|
+
onChange: (e) => changeLanguage(e.target.value),
|
|
452
|
+
"aria-label": "Language",
|
|
453
|
+
style: {
|
|
454
|
+
appearance: "none",
|
|
455
|
+
WebkitAppearance: "none",
|
|
456
|
+
MozAppearance: "none",
|
|
457
|
+
backgroundColor: "rgba(127, 127, 127, 0.12)",
|
|
458
|
+
backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,
|
|
459
|
+
backgroundRepeat: "no-repeat",
|
|
460
|
+
backgroundPosition: `${caretSide} 0.45rem center`,
|
|
461
|
+
backgroundSize: "0.65rem",
|
|
462
|
+
border: "1px solid rgba(127, 127, 127, 0.3)",
|
|
463
|
+
borderRadius: "0.375rem",
|
|
464
|
+
color: "inherit",
|
|
465
|
+
fontFamily: "inherit",
|
|
466
|
+
fontSize: "0.75rem",
|
|
467
|
+
fontWeight: 500,
|
|
468
|
+
lineHeight: 1.2,
|
|
469
|
+
cursor: "pointer",
|
|
470
|
+
outline: "none",
|
|
471
|
+
paddingBlock: "0.3rem",
|
|
472
|
+
paddingInlineStart: "0.6rem",
|
|
473
|
+
paddingInlineEnd: "1.5rem",
|
|
474
|
+
...style
|
|
475
|
+
},
|
|
476
|
+
children: languages.map((code) => /* @__PURE__ */ jsx2("option", { value: code, style: { color: "#18181b" }, children: languageLabel(code) }, code))
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
|
|
416
481
|
// src/components/CookieBanner.tsx
|
|
417
|
-
import { Fragment, jsx as
|
|
482
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
418
483
|
function CookieBanner({ className, position, theme, style }) {
|
|
419
484
|
const {
|
|
420
485
|
config,
|
|
421
486
|
isBannerVisible,
|
|
422
487
|
isLoading,
|
|
423
488
|
language,
|
|
489
|
+
dir,
|
|
424
490
|
acceptAll,
|
|
425
491
|
rejectAll,
|
|
426
492
|
showPreferenceCenter
|
|
@@ -430,7 +496,8 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
430
496
|
}
|
|
431
497
|
const bannerConfig = config.banner;
|
|
432
498
|
const translations = config.translations[language] || config.translations[config.property.defaultLanguage] || {};
|
|
433
|
-
const
|
|
499
|
+
const requestedPosition = position || bannerConfig.position || "bottom";
|
|
500
|
+
const resolvedPosition = dir === "rtl" ? requestedPosition === "bottom-left" ? "bottom-right" : requestedPosition === "bottom-right" ? "bottom-left" : requestedPosition : requestedPosition;
|
|
434
501
|
const resolvedTheme = theme || bannerConfig.theme || "dark";
|
|
435
502
|
const effectiveTheme = resolvedTheme === "auto" ? typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : resolvedTheme;
|
|
436
503
|
const positionStyles = {
|
|
@@ -449,14 +516,14 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
449
516
|
}
|
|
450
517
|
};
|
|
451
518
|
const themeStyles = {
|
|
452
|
-
backgroundColor: effectiveTheme === "dark" ? "#
|
|
453
|
-
color: effectiveTheme === "dark" ? "#
|
|
519
|
+
backgroundColor: effectiveTheme === "dark" ? "#09090b" : "#ffffff",
|
|
520
|
+
color: effectiveTheme === "dark" ? "#f4f4f5" : "#27272a",
|
|
454
521
|
borderWidth: "1px",
|
|
455
522
|
borderStyle: "solid",
|
|
456
|
-
borderColor: effectiveTheme === "dark" ? "#
|
|
523
|
+
borderColor: effectiveTheme === "dark" ? "#3f3f46" : "#e4e4e7"
|
|
457
524
|
};
|
|
458
525
|
const buttonPrimaryStyle = {
|
|
459
|
-
backgroundColor: bannerConfig.primaryColor || "#
|
|
526
|
+
backgroundColor: bannerConfig.primaryColor || "#ff6a00",
|
|
460
527
|
color: "#ffffff",
|
|
461
528
|
padding: "0.5rem 1rem",
|
|
462
529
|
borderRadius: "0.5rem",
|
|
@@ -466,8 +533,8 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
466
533
|
fontSize: "0.875rem"
|
|
467
534
|
};
|
|
468
535
|
const buttonSecondaryStyle = {
|
|
469
|
-
backgroundColor: effectiveTheme === "dark" ? "#
|
|
470
|
-
color: effectiveTheme === "dark" ? "#
|
|
536
|
+
backgroundColor: effectiveTheme === "dark" ? "#52525b" : "#e4e4e7",
|
|
537
|
+
color: effectiveTheme === "dark" ? "#f4f4f5" : "#27272a",
|
|
471
538
|
padding: "0.5rem 1rem",
|
|
472
539
|
borderRadius: "0.5rem",
|
|
473
540
|
border: "none",
|
|
@@ -478,13 +545,13 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
478
545
|
const buttonLinkStyle = {
|
|
479
546
|
background: "none",
|
|
480
547
|
border: "none",
|
|
481
|
-
color: effectiveTheme === "dark" ? "#
|
|
548
|
+
color: effectiveTheme === "dark" ? "#a1a1aa" : "#71717a",
|
|
482
549
|
cursor: "pointer",
|
|
483
550
|
fontSize: "0.875rem",
|
|
484
551
|
padding: "0.5rem"
|
|
485
552
|
};
|
|
486
553
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
487
|
-
resolvedPosition === "center" && /* @__PURE__ */
|
|
554
|
+
resolvedPosition === "center" && /* @__PURE__ */ jsx3(
|
|
488
555
|
"div",
|
|
489
556
|
{
|
|
490
557
|
style: {
|
|
@@ -511,8 +578,9 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
511
578
|
role: "dialog",
|
|
512
579
|
"aria-label": "Cookie consent",
|
|
513
580
|
"aria-modal": resolvedPosition === "center",
|
|
581
|
+
dir,
|
|
514
582
|
children: [
|
|
515
|
-
bannerConfig.showLogo && bannerConfig.logoUrl && /* @__PURE__ */
|
|
583
|
+
bannerConfig.showLogo && bannerConfig.logoUrl && /* @__PURE__ */ jsx3(
|
|
516
584
|
"img",
|
|
517
585
|
{
|
|
518
586
|
src: bannerConfig.logoUrl,
|
|
@@ -520,7 +588,7 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
520
588
|
style: { height: "1.5rem", marginBottom: "0.75rem" }
|
|
521
589
|
}
|
|
522
590
|
),
|
|
523
|
-
translations.bannerTitle && /* @__PURE__ */
|
|
591
|
+
translations.bannerTitle && /* @__PURE__ */ jsx3(
|
|
524
592
|
"h2",
|
|
525
593
|
{
|
|
526
594
|
style: {
|
|
@@ -532,7 +600,7 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
532
600
|
children: translations.bannerTitle
|
|
533
601
|
}
|
|
534
602
|
),
|
|
535
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ jsx3(
|
|
536
604
|
"p",
|
|
537
605
|
{
|
|
538
606
|
style: {
|
|
@@ -554,7 +622,7 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
554
622
|
alignItems: "center"
|
|
555
623
|
},
|
|
556
624
|
children: [
|
|
557
|
-
/* @__PURE__ */
|
|
625
|
+
/* @__PURE__ */ jsx3(
|
|
558
626
|
"button",
|
|
559
627
|
{
|
|
560
628
|
onClick: acceptAll,
|
|
@@ -563,7 +631,7 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
563
631
|
children: translations.acceptAllText || "Accept All"
|
|
564
632
|
}
|
|
565
633
|
),
|
|
566
|
-
/* @__PURE__ */
|
|
634
|
+
/* @__PURE__ */ jsx3(
|
|
567
635
|
"button",
|
|
568
636
|
{
|
|
569
637
|
onClick: rejectAll,
|
|
@@ -572,7 +640,7 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
572
640
|
children: translations.rejectAllText || "Reject All"
|
|
573
641
|
}
|
|
574
642
|
),
|
|
575
|
-
/* @__PURE__ */
|
|
643
|
+
/* @__PURE__ */ jsx3(
|
|
576
644
|
"button",
|
|
577
645
|
{
|
|
578
646
|
onClick: showPreferenceCenter,
|
|
@@ -580,7 +648,8 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
580
648
|
type: "button",
|
|
581
649
|
children: translations.customizeText || "Customize"
|
|
582
650
|
}
|
|
583
|
-
)
|
|
651
|
+
),
|
|
652
|
+
/* @__PURE__ */ jsx3(LanguageSelector, { style: { marginInlineStart: "auto" } })
|
|
584
653
|
]
|
|
585
654
|
}
|
|
586
655
|
)
|
|
@@ -590,9 +659,91 @@ function CookieBanner({ className, position, theme, style }) {
|
|
|
590
659
|
] });
|
|
591
660
|
}
|
|
592
661
|
|
|
662
|
+
// src/components/ConsentTrigger.tsx
|
|
663
|
+
import { useState as useState2 } from "react";
|
|
664
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
665
|
+
function ConsentTrigger({
|
|
666
|
+
className,
|
|
667
|
+
position = "bottom-left",
|
|
668
|
+
theme,
|
|
669
|
+
style,
|
|
670
|
+
label = "Cookie preferences"
|
|
671
|
+
}) {
|
|
672
|
+
const { config, isLoading, isBannerVisible, isPreferenceCenterVisible, showPreferenceCenter, dir } = useConsentIQ();
|
|
673
|
+
const [hovered, setHovered] = useState2(false);
|
|
674
|
+
if (isLoading || isBannerVisible || isPreferenceCenterVisible) {
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
const bannerConfig = config?.banner;
|
|
678
|
+
const resolvedTheme = theme || bannerConfig?.theme || "dark";
|
|
679
|
+
const effectiveTheme = resolvedTheme === "auto" ? typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : resolvedTheme;
|
|
680
|
+
const accent = bannerConfig?.primaryColor || "#ff6a00";
|
|
681
|
+
const corner = dir === "rtl" ? position === "bottom-right" ? "bottom-left" : "bottom-right" : position;
|
|
682
|
+
const cornerStyles = corner === "bottom-right" ? { right: "1rem" } : { left: "1rem" };
|
|
683
|
+
return /* @__PURE__ */ jsx4(
|
|
684
|
+
"button",
|
|
685
|
+
{
|
|
686
|
+
type: "button",
|
|
687
|
+
className,
|
|
688
|
+
onClick: showPreferenceCenter,
|
|
689
|
+
onMouseEnter: () => setHovered(true),
|
|
690
|
+
onMouseLeave: () => setHovered(false),
|
|
691
|
+
onFocus: () => setHovered(true),
|
|
692
|
+
onBlur: () => setHovered(false),
|
|
693
|
+
"aria-label": label,
|
|
694
|
+
title: label,
|
|
695
|
+
style: {
|
|
696
|
+
position: "fixed",
|
|
697
|
+
bottom: "1rem",
|
|
698
|
+
...cornerStyles,
|
|
699
|
+
zIndex: 9997,
|
|
700
|
+
width: "3rem",
|
|
701
|
+
height: "3rem",
|
|
702
|
+
padding: 0,
|
|
703
|
+
borderRadius: "9999px",
|
|
704
|
+
display: "flex",
|
|
705
|
+
alignItems: "center",
|
|
706
|
+
justifyContent: "center",
|
|
707
|
+
cursor: "pointer",
|
|
708
|
+
backgroundColor: effectiveTheme === "dark" ? "#09090b" : "#ffffff",
|
|
709
|
+
color: accent,
|
|
710
|
+
borderWidth: "1px",
|
|
711
|
+
borderStyle: "solid",
|
|
712
|
+
borderColor: effectiveTheme === "dark" ? "#3f3f46" : "#e4e4e7",
|
|
713
|
+
boxShadow: hovered ? "0 6px 16px -2px rgba(0, 0, 0, 0.2)" : "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
714
|
+
transform: hovered ? "scale(1.05)" : "scale(1)",
|
|
715
|
+
transition: "transform 0.15s ease, box-shadow 0.15s ease",
|
|
716
|
+
...style
|
|
717
|
+
},
|
|
718
|
+
children: /* @__PURE__ */ jsxs2(
|
|
719
|
+
"svg",
|
|
720
|
+
{
|
|
721
|
+
width: "22",
|
|
722
|
+
height: "22",
|
|
723
|
+
viewBox: "0 0 24 24",
|
|
724
|
+
fill: "none",
|
|
725
|
+
stroke: "currentColor",
|
|
726
|
+
strokeWidth: "2",
|
|
727
|
+
strokeLinecap: "round",
|
|
728
|
+
strokeLinejoin: "round",
|
|
729
|
+
"aria-hidden": "true",
|
|
730
|
+
children: [
|
|
731
|
+
/* @__PURE__ */ jsx4("path", { d: "M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5Z" }),
|
|
732
|
+
/* @__PURE__ */ jsx4("path", { d: "M8.5 8.5v.01" }),
|
|
733
|
+
/* @__PURE__ */ jsx4("path", { d: "M16 15.5v.01" }),
|
|
734
|
+
/* @__PURE__ */ jsx4("path", { d: "M12 12v.01" }),
|
|
735
|
+
/* @__PURE__ */ jsx4("path", { d: "M11 17v.01" }),
|
|
736
|
+
/* @__PURE__ */ jsx4("path", { d: "M7 14v.01" })
|
|
737
|
+
]
|
|
738
|
+
}
|
|
739
|
+
)
|
|
740
|
+
}
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
593
744
|
// src/components/PreferenceCenter.tsx
|
|
594
|
-
import { useState as
|
|
595
|
-
import { jsx as
|
|
745
|
+
import { useState as useState3, useEffect as useEffect2 } from "react";
|
|
746
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
596
747
|
function PreferenceCenter({ className, theme, style }) {
|
|
597
748
|
const {
|
|
598
749
|
config,
|
|
@@ -600,10 +751,11 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
600
751
|
isPreferenceCenterVisible,
|
|
601
752
|
isLoading,
|
|
602
753
|
language,
|
|
754
|
+
dir,
|
|
603
755
|
updateConsent,
|
|
604
756
|
hidePreferenceCenter
|
|
605
757
|
} = useConsentIQ();
|
|
606
|
-
const [localConsent, setLocalConsent] =
|
|
758
|
+
const [localConsent, setLocalConsent] = useState3(consent);
|
|
607
759
|
useEffect2(() => {
|
|
608
760
|
setLocalConsent(consent);
|
|
609
761
|
}, [consent]);
|
|
@@ -669,8 +821,8 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
669
821
|
};
|
|
670
822
|
const modalStyle = {
|
|
671
823
|
position: "relative",
|
|
672
|
-
backgroundColor: isDark ? "#
|
|
673
|
-
color: isDark ? "#
|
|
824
|
+
backgroundColor: isDark ? "#09090b" : "#ffffff",
|
|
825
|
+
color: isDark ? "#f4f4f5" : "#27272a",
|
|
674
826
|
borderRadius: "0.75rem",
|
|
675
827
|
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
676
828
|
maxWidth: "600px",
|
|
@@ -684,7 +836,7 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
684
836
|
};
|
|
685
837
|
const headerStyle = {
|
|
686
838
|
padding: "1rem 1.5rem",
|
|
687
|
-
borderBottom: `1px solid ${isDark ? "#
|
|
839
|
+
borderBottom: `1px solid ${isDark ? "#3f3f46" : "#e4e4e7"}`,
|
|
688
840
|
display: "flex",
|
|
689
841
|
justifyContent: "space-between",
|
|
690
842
|
alignItems: "center"
|
|
@@ -696,14 +848,14 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
696
848
|
};
|
|
697
849
|
const footerStyle = {
|
|
698
850
|
padding: "1rem 1.5rem",
|
|
699
|
-
borderTop: `1px solid ${isDark ? "#
|
|
851
|
+
borderTop: `1px solid ${isDark ? "#3f3f46" : "#e4e4e7"}`,
|
|
700
852
|
display: "flex",
|
|
701
853
|
gap: "0.5rem",
|
|
702
854
|
justifyContent: "flex-end"
|
|
703
855
|
};
|
|
704
856
|
const categoryStyle = {
|
|
705
857
|
padding: "1rem",
|
|
706
|
-
backgroundColor: isDark ? "#
|
|
858
|
+
backgroundColor: isDark ? "#18181b" : "#fafafa",
|
|
707
859
|
borderRadius: "0.5rem",
|
|
708
860
|
marginBottom: "0.75rem"
|
|
709
861
|
};
|
|
@@ -713,7 +865,7 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
713
865
|
justifyContent: "space-between"
|
|
714
866
|
};
|
|
715
867
|
const buttonPrimaryStyle = {
|
|
716
|
-
backgroundColor: bannerConfig.primaryColor || "#
|
|
868
|
+
backgroundColor: bannerConfig.primaryColor || "#ff6a00",
|
|
717
869
|
color: "#ffffff",
|
|
718
870
|
padding: "0.5rem 1rem",
|
|
719
871
|
borderRadius: "0.5rem",
|
|
@@ -723,8 +875,8 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
723
875
|
fontSize: "0.875rem"
|
|
724
876
|
};
|
|
725
877
|
const buttonSecondaryStyle = {
|
|
726
|
-
backgroundColor: isDark ? "#
|
|
727
|
-
color: isDark ? "#
|
|
878
|
+
backgroundColor: isDark ? "#52525b" : "#e4e4e7",
|
|
879
|
+
color: isDark ? "#f4f4f5" : "#27272a",
|
|
728
880
|
padding: "0.5rem 1rem",
|
|
729
881
|
borderRadius: "0.5rem",
|
|
730
882
|
border: "none",
|
|
@@ -735,47 +887,59 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
735
887
|
const buttonTextStyle = {
|
|
736
888
|
background: "none",
|
|
737
889
|
border: "none",
|
|
738
|
-
color:
|
|
890
|
+
color: bannerConfig.primaryColor || "#ff6a00",
|
|
739
891
|
cursor: "pointer",
|
|
740
892
|
fontSize: "0.875rem",
|
|
741
|
-
|
|
893
|
+
fontWeight: 500,
|
|
894
|
+
padding: 0,
|
|
895
|
+
textDecoration: "underline",
|
|
896
|
+
textUnderlineOffset: "2px"
|
|
742
897
|
};
|
|
743
|
-
return /* @__PURE__ */
|
|
744
|
-
/* @__PURE__ */
|
|
745
|
-
/* @__PURE__ */
|
|
746
|
-
/* @__PURE__ */
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
898
|
+
return /* @__PURE__ */ jsxs3("div", { style: containerStyle, className, children: [
|
|
899
|
+
/* @__PURE__ */ jsx5("div", { style: backdropStyle, onClick: hidePreferenceCenter }),
|
|
900
|
+
/* @__PURE__ */ jsxs3("div", { style: modalStyle, role: "dialog", "aria-modal": "true", "aria-label": "Cookie preferences", dir, children: [
|
|
901
|
+
/* @__PURE__ */ jsxs3("div", { style: headerStyle, children: [
|
|
902
|
+
/* @__PURE__ */ jsx5("h2", { style: { margin: 0, fontSize: "1.25rem", fontWeight: 600, lineHeight: 1 }, children: "Cookie Preferences" }),
|
|
903
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", gap: "0.875rem" }, children: [
|
|
904
|
+
/* @__PURE__ */ jsx5(LanguageSelector, {}),
|
|
905
|
+
/* @__PURE__ */ jsx5(
|
|
906
|
+
"button",
|
|
907
|
+
{
|
|
908
|
+
onClick: hidePreferenceCenter,
|
|
909
|
+
style: {
|
|
910
|
+
display: "flex",
|
|
911
|
+
alignItems: "center",
|
|
912
|
+
justifyContent: "center",
|
|
913
|
+
width: "1.75rem",
|
|
914
|
+
height: "1.75rem",
|
|
915
|
+
padding: 0,
|
|
916
|
+
background: "none",
|
|
917
|
+
border: "none",
|
|
918
|
+
fontSize: "1.5rem",
|
|
919
|
+
cursor: "pointer",
|
|
920
|
+
color: isDark ? "#a1a1aa" : "#71717a",
|
|
921
|
+
lineHeight: 1
|
|
922
|
+
},
|
|
923
|
+
"aria-label": "Close",
|
|
924
|
+
type: "button",
|
|
925
|
+
children: "\xD7"
|
|
926
|
+
}
|
|
927
|
+
)
|
|
928
|
+
] })
|
|
765
929
|
] }),
|
|
766
|
-
/* @__PURE__ */
|
|
767
|
-
/* @__PURE__ */
|
|
768
|
-
/* @__PURE__ */
|
|
769
|
-
/* @__PURE__ */
|
|
770
|
-
/* @__PURE__ */
|
|
930
|
+
/* @__PURE__ */ jsxs3("div", { style: bodyStyle, children: [
|
|
931
|
+
/* @__PURE__ */ jsx5("p", { style: { marginTop: 0, marginBottom: "1.5rem", opacity: 0.8, fontSize: "0.875rem" }, children: translations.bannerDescription || "Manage your cookie preferences. Some cookies are essential for the site to function properly." }),
|
|
932
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "1rem", marginBottom: "1.5rem" }, children: [
|
|
933
|
+
/* @__PURE__ */ jsx5("button", { onClick: handleAcceptAll, style: buttonTextStyle, type: "button", children: "Enable All" }),
|
|
934
|
+
/* @__PURE__ */ jsx5("button", { onClick: handleRejectAll, style: buttonTextStyle, type: "button", children: "Disable All" })
|
|
771
935
|
] }),
|
|
772
936
|
config.categories.filter((cat) => cat.enabled).map((category) => {
|
|
773
937
|
const categoryTranslation = translations.categories?.[category.code];
|
|
774
938
|
const isEnabled = localConsent[category.code] ?? category.defaultState;
|
|
775
|
-
return /* @__PURE__ */
|
|
776
|
-
/* @__PURE__ */
|
|
777
|
-
/* @__PURE__ */
|
|
778
|
-
/* @__PURE__ */
|
|
939
|
+
return /* @__PURE__ */ jsxs3("div", { style: categoryStyle, children: [
|
|
940
|
+
/* @__PURE__ */ jsxs3("div", { style: toggleContainerStyle, children: [
|
|
941
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "baseline", flexWrap: "wrap" }, children: [
|
|
942
|
+
/* @__PURE__ */ jsx5(
|
|
779
943
|
"h3",
|
|
780
944
|
{
|
|
781
945
|
style: {
|
|
@@ -786,19 +950,19 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
786
950
|
children: categoryTranslation?.title || category.name
|
|
787
951
|
}
|
|
788
952
|
),
|
|
789
|
-
category.isRequired && /* @__PURE__ */
|
|
953
|
+
category.isRequired && /* @__PURE__ */ jsx5(
|
|
790
954
|
"span",
|
|
791
955
|
{
|
|
792
956
|
style: {
|
|
793
957
|
fontSize: "0.75rem",
|
|
794
|
-
color: isDark ? "#
|
|
958
|
+
color: isDark ? "#a1a1aa" : "#71717a",
|
|
795
959
|
marginLeft: "0.5rem"
|
|
796
960
|
},
|
|
797
961
|
children: "(Required)"
|
|
798
962
|
}
|
|
799
963
|
)
|
|
800
964
|
] }),
|
|
801
|
-
/* @__PURE__ */
|
|
965
|
+
/* @__PURE__ */ jsx5(
|
|
802
966
|
Toggle,
|
|
803
967
|
{
|
|
804
968
|
checked: isEnabled,
|
|
@@ -808,7 +972,7 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
808
972
|
}
|
|
809
973
|
)
|
|
810
974
|
] }),
|
|
811
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ jsx5(
|
|
812
976
|
"p",
|
|
813
977
|
{
|
|
814
978
|
style: {
|
|
@@ -822,14 +986,14 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
822
986
|
] }, category.code);
|
|
823
987
|
})
|
|
824
988
|
] }),
|
|
825
|
-
/* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
827
|
-
/* @__PURE__ */
|
|
989
|
+
/* @__PURE__ */ jsxs3("div", { style: footerStyle, children: [
|
|
990
|
+
/* @__PURE__ */ jsx5("button", { onClick: hidePreferenceCenter, style: buttonSecondaryStyle, type: "button", children: "Cancel" }),
|
|
991
|
+
/* @__PURE__ */ jsx5("button", { onClick: handleSave, style: buttonPrimaryStyle, type: "button", children: translations.savePreferencesText || "Save Preferences" })
|
|
828
992
|
] }),
|
|
829
|
-
/* @__PURE__ */
|
|
993
|
+
/* @__PURE__ */ jsx5("div", { style: {
|
|
830
994
|
padding: "0.5rem 1.5rem 0.75rem",
|
|
831
995
|
textAlign: "center"
|
|
832
|
-
}, children: /* @__PURE__ */
|
|
996
|
+
}, children: /* @__PURE__ */ jsxs3(
|
|
833
997
|
"a",
|
|
834
998
|
{
|
|
835
999
|
href: "https://consent.iqworks.ai",
|
|
@@ -840,12 +1004,12 @@ function PreferenceCenter({ className, theme, style }) {
|
|
|
840
1004
|
alignItems: "center",
|
|
841
1005
|
gap: "0.35rem",
|
|
842
1006
|
fontSize: "0.7rem",
|
|
843
|
-
color: isDark ? "#
|
|
1007
|
+
color: isDark ? "#71717a" : "#a1a1aa",
|
|
844
1008
|
textDecoration: "none"
|
|
845
1009
|
},
|
|
846
1010
|
children: [
|
|
847
1011
|
"Powered by",
|
|
848
|
-
/* @__PURE__ */
|
|
1012
|
+
/* @__PURE__ */ jsx5(ConsentIQLogo, { isDark })
|
|
849
1013
|
]
|
|
850
1014
|
}
|
|
851
1015
|
) })
|
|
@@ -862,7 +1026,7 @@ function Toggle({
|
|
|
862
1026
|
position: "relative",
|
|
863
1027
|
width: "44px",
|
|
864
1028
|
height: "24px",
|
|
865
|
-
backgroundColor: checked ? primaryColor || "#
|
|
1029
|
+
backgroundColor: checked ? primaryColor || "#ff6a00" : "#a1a1aa",
|
|
866
1030
|
borderRadius: "12px",
|
|
867
1031
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
868
1032
|
opacity: disabled ? 0.5 : 1,
|
|
@@ -871,15 +1035,15 @@ function Toggle({
|
|
|
871
1035
|
const thumbStyle = {
|
|
872
1036
|
position: "absolute",
|
|
873
1037
|
top: "2px",
|
|
874
|
-
|
|
1038
|
+
insetInlineStart: checked ? "22px" : "2px",
|
|
875
1039
|
width: "20px",
|
|
876
1040
|
height: "20px",
|
|
877
1041
|
backgroundColor: "#ffffff",
|
|
878
1042
|
borderRadius: "50%",
|
|
879
|
-
transition: "
|
|
1043
|
+
transition: "inset-inline-start 0.2s",
|
|
880
1044
|
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.2)"
|
|
881
1045
|
};
|
|
882
|
-
return /* @__PURE__ */
|
|
1046
|
+
return /* @__PURE__ */ jsx5(
|
|
883
1047
|
"button",
|
|
884
1048
|
{
|
|
885
1049
|
type: "button",
|
|
@@ -888,47 +1052,47 @@ function Toggle({
|
|
|
888
1052
|
onClick: disabled ? void 0 : onChange,
|
|
889
1053
|
style: trackStyle,
|
|
890
1054
|
disabled,
|
|
891
|
-
children: /* @__PURE__ */
|
|
1055
|
+
children: /* @__PURE__ */ jsx5("span", { style: thumbStyle })
|
|
892
1056
|
}
|
|
893
1057
|
);
|
|
894
1058
|
}
|
|
895
1059
|
function ConsentIQLogo({ isDark }) {
|
|
896
1060
|
if (isDark) {
|
|
897
|
-
return /* @__PURE__ */
|
|
898
|
-
/* @__PURE__ */
|
|
899
|
-
/* @__PURE__ */
|
|
900
|
-
/* @__PURE__ */
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
/* @__PURE__ */
|
|
903
|
-
/* @__PURE__ */
|
|
904
|
-
/* @__PURE__ */
|
|
905
|
-
/* @__PURE__ */
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
/* @__PURE__ */
|
|
908
|
-
/* @__PURE__ */
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
1061
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "80", height: "14", viewBox: "0 0 487 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
1062
|
+
/* @__PURE__ */ jsx5("path", { d: "M49.3323 11.8633L41.634 7.59045L12.417 24.7048C9.84034 52.4047 19.3957 71.4081 35.7685 82.4129C20.9524 65.4494 18.5009 39.8252 19.664 29.2678L49.3323 11.8633Z", fill: "#FF6503" }),
|
|
1063
|
+
/* @__PURE__ */ jsx5("path", { d: "M58.8505 6.18471L51.0667 2.15857L43.3711 6.59458L50.9943 10.8186L58.8505 6.18471Z", fill: "white" }),
|
|
1064
|
+
/* @__PURE__ */ jsx5("path", { d: "M28.2107 33.8309C24.131 59.3834 31.5211 76.8658 35.7261 82.413C35.7261 82.413 34.4207 77.3773 33.847 74.0981C31.4064 60.1473 32.3708 50.2576 35.1891 37.8571L66.0559 20.1421C65.3617 30.7093 59.5471 53.4338 42.7104 68.3178C50.6824 64.6214 61.1777 58.5798 64.854 51.8087C64.6636 52.2227 66.2567 49.3651 66.0559 49.771C73.3369 35.6413 74.3274 23.7642 74.3767 15.0422L66.8613 10.7477L28.2107 33.8309Z", fill: "#FF6503" }),
|
|
1065
|
+
/* @__PURE__ */ jsx5("path", { d: "M63.7104 54.4578C57.4728 65.6025 33.8945 74.3768 33.8945 74.3768C33.8945 74.3768 34.1088 75.8873 34.643 78.0695C35.1772 80.2517 35.7138 82.3943 35.7138 82.3943C43.4068 78.4438 55.3104 70.2184 63.7104 54.4578Z", fill: "white" }),
|
|
1066
|
+
/* @__PURE__ */ jsx5("path", { d: "M473.855 85V60.5074C472.26 61.7151 470.473 62.6571 468.492 63.3334C466.512 64.0581 464.362 64.4204 462.043 64.4204C457.985 64.4204 454.314 63.3817 451.029 61.3045C447.744 59.2272 445.111 56.4736 443.13 53.0436C441.198 49.5654 440.231 45.7248 440.231 41.5219C440.231 37.319 441.198 33.4784 443.13 30.0002C445.111 26.5219 447.744 23.7683 451.029 21.7393C454.314 19.6621 457.985 18.6234 462.043 18.6234C464.797 18.6234 467.333 19.1065 469.652 20.0727C471.97 21.0389 473.951 22.3674 475.594 24.0582V19.7828H486.463V85H473.855ZM463.492 53.3335C465.618 53.3335 467.55 52.8021 469.289 51.7393C471.028 50.6765 472.405 49.2513 473.42 47.4639C474.483 45.6765 475.014 43.6958 475.014 41.5219C475.014 39.348 474.483 37.3673 473.42 35.5799C472.405 33.7925 471.028 32.3673 469.289 31.3045C467.55 30.2417 465.618 29.7103 463.492 29.7103C461.367 29.7103 459.434 30.2417 457.695 31.3045C455.956 32.3673 454.555 33.7925 453.492 35.5799C452.478 37.3673 451.971 39.348 451.971 41.5219C451.971 43.6958 452.478 45.6765 453.492 47.4639C454.555 49.2513 455.956 50.6765 457.695 51.7393C459.434 52.8021 461.367 53.3335 463.492 53.3335Z", fill: "#FF6503" }),
|
|
1067
|
+
/* @__PURE__ */ jsx5("path", { d: "M420.133 63.2607V19.7826H432.742V63.2607H420.133ZM426.437 13.4782C424.553 13.4782 422.959 12.826 421.655 11.5217C420.35 10.2174 419.698 8.62316 419.698 6.73911C419.698 4.80675 420.35 3.21255 421.655 1.95651C422.959 0.65217 424.553 0 426.437 0C428.37 0 429.964 0.65217 431.22 1.95651C432.524 3.21255 433.176 4.80675 433.176 6.73911C433.176 8.62316 432.524 10.2174 431.22 11.5217C429.964 12.826 428.37 13.4782 426.437 13.4782Z", fill: "#FF6503" }),
|
|
1068
|
+
/* @__PURE__ */ jsx5("path", { d: "M392.451 63.2607V29.7825H384.335V19.7825H392.668V5.28979H404.842V19.7825H413.465V29.7825H405.06V63.2607H392.451Z", fill: "white" }),
|
|
1069
|
+
/* @__PURE__ */ jsx5("path", { d: "M338.059 63.2605V19.7824H349.363V24.565C350.909 22.536 352.817 20.9901 355.088 19.9273C357.358 18.8645 359.798 18.3331 362.406 18.3331C365.498 18.3331 368.373 19.0819 371.03 20.5795C373.735 22.0288 375.909 24.1785 377.551 27.0288C379.242 29.8307 380.087 33.2365 380.087 37.2461V63.2605H367.479V38.9128C367.479 36.4973 366.754 34.3476 365.305 32.4635C363.856 30.5795 361.778 29.6374 359.073 29.6374C356.899 29.6374 354.943 30.3862 353.203 31.8838C351.513 33.3331 350.667 35.6278 350.667 38.7679V63.2605H338.059Z", fill: "white" }),
|
|
1070
|
+
/* @__PURE__ */ jsx5("path", { d: "M310.56 64.7098C305.68 64.7098 301.381 63.6953 297.661 61.6664C293.941 59.6374 291.043 56.8596 288.966 53.333C286.888 49.7582 285.85 45.6761 285.85 41.0867C285.85 36.6906 286.864 32.8017 288.893 29.4201C290.922 25.9901 293.652 23.2848 297.081 21.3041C300.56 19.3235 304.4 18.3331 308.603 18.3331C312.903 18.3331 316.743 19.3235 320.125 21.3041C323.507 23.2365 326.164 25.8935 328.096 29.2751C330.077 32.6568 331.067 36.4973 331.067 40.7968V45.2171H304.545C303.337 45.2171 302.178 45.1447 301.067 44.9997C299.956 44.8548 298.845 44.6857 297.734 44.4925C298.313 47.391 299.738 49.7582 302.009 51.5939C304.328 53.3813 307.275 54.2751 310.85 54.2751C313.603 54.2751 316.067 53.7195 318.241 52.6084C320.463 51.4973 322.275 50.1205 323.676 48.478L326.429 59.7823C324.255 61.4248 321.792 62.6567 319.038 63.4779C316.333 64.2992 313.507 64.7098 310.56 64.7098ZM297.444 36.8838C299.859 36.3524 302.226 36.0867 304.545 36.0867H312.226C313.579 36.0867 314.859 36.135 316.067 36.2316C317.275 36.3283 318.41 36.4973 319.473 36.7389C318.748 34.1302 317.42 32.0771 315.487 30.5795C313.603 29.0819 311.26 28.3331 308.458 28.3331C305.801 28.3331 303.482 29.1061 301.502 30.6519C299.569 32.1495 298.217 34.2268 297.444 36.8838Z", fill: "white" }),
|
|
1071
|
+
/* @__PURE__ */ jsx5("path", { d: "M263.884 64.7098C260.937 64.7098 257.942 64.2267 254.898 63.2605C251.903 62.2944 249.56 60.99 247.869 59.3475L250.985 47.4635C252.386 49.3959 254.318 51.0867 256.782 52.5359C259.294 53.9852 261.879 54.7098 264.536 54.7098C266.323 54.7098 267.603 54.3717 268.376 53.6954C269.198 53.019 269.608 52.1978 269.608 51.2316C269.608 50.1205 269.198 49.3234 268.376 48.8403C267.555 48.3089 266.71 47.8741 265.84 47.536L259.753 45.2171C258.401 44.6857 256.855 43.9611 255.115 43.0432C253.376 42.1253 251.855 40.821 250.55 39.1302C249.294 37.4394 248.666 35.2171 248.666 32.4635C248.666 29.9515 249.294 27.6326 250.55 25.507C251.806 23.3814 253.618 21.6665 255.985 20.3621C258.401 19.0095 261.299 18.3331 264.681 18.3331C267.821 18.3331 270.743 18.8645 273.449 19.9273C276.202 20.9901 278.207 22.1737 279.463 23.478L276.565 34.9273C274.922 32.8017 272.966 31.1833 270.695 30.0722C268.473 28.9128 266.347 28.3331 264.318 28.3331C262.772 28.3331 261.637 28.6471 260.913 29.2751C260.188 29.9031 259.826 30.6278 259.826 31.449C259.826 32.0771 260.067 32.7051 260.55 33.3331C261.082 33.9128 261.951 34.4442 263.159 34.9273L268.811 37.0287C270.454 37.6084 272.193 38.3814 274.028 39.3476C275.913 40.3137 277.507 41.6664 278.811 43.4055C280.115 45.0963 280.768 47.4393 280.768 50.4345C280.768 54.6374 279.198 58.0673 276.057 60.7243C272.966 63.3813 268.908 64.7098 263.884 64.7098Z", fill: "white" }),
|
|
1072
|
+
/* @__PURE__ */ jsx5("path", { d: "M198.861 63.2605V19.7824H210.166V24.565C211.712 22.536 213.62 20.9901 215.89 19.9273C218.161 18.8645 220.6 18.3331 223.209 18.3331C226.301 18.3331 229.175 19.0819 231.832 20.5795C234.538 22.0288 236.711 24.1785 238.354 27.0288C240.045 29.8307 240.89 33.2365 240.89 37.2461V63.2605H228.282V38.9128C228.282 36.4973 227.557 34.3476 226.108 32.4635C224.658 30.5795 222.581 29.6374 219.876 29.6374C217.702 29.6374 215.745 30.3862 214.006 31.8838C212.315 33.3331 211.47 35.6278 211.47 38.7679V63.2605H198.861Z", fill: "white" }),
|
|
1073
|
+
/* @__PURE__ */ jsx5("path", { d: "M167.99 64.7098C163.69 64.7098 159.753 63.6712 156.178 61.5939C152.603 59.5166 149.753 56.7147 147.628 53.1881C145.55 49.6616 144.512 45.7727 144.512 41.5215C144.512 37.222 145.55 33.3331 147.628 29.8548C149.753 26.3283 152.603 23.5264 156.178 21.4491C159.753 19.3718 163.69 18.3331 167.99 18.3331C172.338 18.3331 176.275 19.3718 179.801 21.4491C183.376 23.5264 186.202 26.3283 188.28 29.8548C190.405 33.3331 191.468 37.222 191.468 41.5215C191.468 45.7727 190.405 49.6616 188.28 53.1881C186.202 56.7147 183.376 59.5166 179.801 61.5939C176.275 63.6712 172.338 64.7098 167.99 64.7098ZM167.99 53.4055C170.164 53.4055 172.12 52.8741 173.859 51.8113C175.647 50.7485 177.048 49.3234 178.062 47.536C179.125 45.7002 179.657 43.6954 179.657 41.5215C179.657 39.2993 179.125 37.2944 178.062 35.507C177.048 33.7196 175.647 32.2944 173.859 31.2316C172.12 30.1688 170.164 29.6374 167.99 29.6374C165.816 29.6374 163.835 30.1688 162.048 31.2316C160.309 32.2944 158.908 33.7196 157.845 35.507C156.831 37.2944 156.323 39.2993 156.323 41.5215C156.323 43.6954 156.831 45.7002 157.845 47.536C158.908 49.3234 160.309 50.7485 162.048 51.8113C163.835 52.8741 165.816 53.4055 167.99 53.4055Z", fill: "white" }),
|
|
1074
|
+
/* @__PURE__ */ jsx5("path", { d: "M124.478 64.7098C120.179 64.7098 116.242 63.6712 112.667 61.5939C109.092 59.5166 106.242 56.7147 104.116 53.1881C102.039 49.6616 101 45.7727 101 41.5215C101 37.222 102.039 33.3331 104.116 29.8548C106.242 26.3283 109.092 23.5264 112.667 21.4491C116.242 19.3718 120.179 18.3331 124.478 18.3331C127.473 18.3331 130.299 18.8404 132.956 19.8549C135.662 20.821 138.053 22.2703 140.13 24.2027L136.869 37.0287C135.662 35.0481 134.043 33.3331 132.014 31.8838C130.034 30.3862 127.691 29.6374 124.985 29.6374C122.715 29.6374 120.686 30.1688 118.899 31.2316C117.111 32.2944 115.71 33.7196 114.696 35.507C113.681 37.2944 113.174 39.2993 113.174 41.5215C113.174 43.6954 113.681 45.7002 114.696 47.536C115.71 49.3234 117.111 50.7485 118.899 51.8113C120.686 52.8741 122.715 53.4055 124.985 53.4055C127.691 53.4055 130.034 52.6809 132.014 51.2316C134.043 49.734 135.662 47.9949 136.869 46.0142L140.13 58.8403C138.053 60.7726 135.662 62.2461 132.956 63.2605C130.299 64.2267 127.473 64.7098 124.478 64.7098Z", fill: "white" })
|
|
911
1075
|
] });
|
|
912
1076
|
}
|
|
913
|
-
return /* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
/* @__PURE__ */
|
|
917
|
-
/* @__PURE__ */
|
|
918
|
-
/* @__PURE__ */
|
|
919
|
-
/* @__PURE__ */
|
|
920
|
-
/* @__PURE__ */
|
|
921
|
-
/* @__PURE__ */
|
|
922
|
-
/* @__PURE__ */
|
|
923
|
-
/* @__PURE__ */
|
|
924
|
-
/* @__PURE__ */
|
|
925
|
-
/* @__PURE__ */
|
|
926
|
-
/* @__PURE__ */
|
|
1077
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "80", height: "14", viewBox: "0 0 487 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
1078
|
+
/* @__PURE__ */ jsx5("path", { d: "M48.6448 12.0775L40.9465 7.80469L11.7295 24.9191C9.15284 52.6189 18.7082 71.6223 35.081 82.6271C20.2649 65.6636 17.8134 40.0395 18.9765 29.482L48.6448 12.0775Z", fill: "#FF6503" }),
|
|
1079
|
+
/* @__PURE__ */ jsx5("path", { d: "M58.163 6.39894L50.3792 2.3728L42.6836 6.80882L50.3068 11.0328L58.163 6.39894Z", fill: "#3A3A3A" }),
|
|
1080
|
+
/* @__PURE__ */ jsx5("path", { d: "M27.5232 34.0452C23.4435 59.5977 30.8336 77.08 35.0386 82.6272C35.0386 82.6272 33.7332 77.5916 33.1595 74.3123C30.7189 60.3615 31.6833 50.4718 34.5016 38.0713L65.3684 20.3563C64.6742 30.9236 58.8596 53.6481 42.0229 68.532C49.9949 64.8357 60.4902 58.794 64.1665 52.0229C63.9761 52.437 65.5692 49.5794 65.3684 49.9853C72.6494 35.8555 73.6399 23.9785 73.6892 15.2564L66.1738 10.9619L27.5232 34.0452Z", fill: "#FF6503" }),
|
|
1081
|
+
/* @__PURE__ */ jsx5("path", { d: "M63.0229 54.672C56.7853 65.8167 33.207 74.5911 33.207 74.5911C33.207 74.5911 33.4213 76.1015 33.9555 78.2837C34.4897 80.4659 35.0263 82.6085 35.0263 82.6085C42.7193 78.658 54.6229 70.4326 63.0229 54.672Z", fill: "#3A3A3A" }),
|
|
1082
|
+
/* @__PURE__ */ jsx5("path", { d: "M473.854 85V60.5074C472.259 61.7151 470.472 62.6571 468.491 63.3334C466.511 64.0581 464.361 64.4204 462.042 64.4204C457.984 64.4204 454.313 63.3817 451.028 61.3045C447.743 59.2272 445.11 56.4736 443.129 53.0436C441.197 49.5654 440.23 45.7248 440.23 41.5219C440.23 37.319 441.197 33.4784 443.129 30.0002C445.11 26.5219 447.743 23.7683 451.028 21.7393C454.313 19.6621 457.984 18.6234 462.042 18.6234C464.796 18.6234 467.332 19.1065 469.651 20.0727C471.969 21.0389 473.95 22.3674 475.593 24.0582V19.7828H486.462V85H473.854ZM463.491 53.3335C465.617 53.3335 467.549 52.8021 469.288 51.7393C471.027 50.6765 472.404 49.2513 473.419 47.4639C474.482 45.6765 475.013 43.6958 475.013 41.5219C475.013 39.348 474.482 37.3673 473.419 35.5799C472.404 33.7925 471.027 32.3673 469.288 31.3045C467.549 30.2417 465.617 29.7103 463.491 29.7103C461.366 29.7103 459.433 30.2417 457.694 31.3045C455.955 32.3673 454.554 33.7925 453.491 35.5799C452.477 37.3673 451.97 39.348 451.97 41.5219C451.97 43.6958 452.477 45.6765 453.491 47.4639C454.554 49.2513 455.955 50.6765 457.694 51.7393C459.433 52.8021 461.366 53.3335 463.491 53.3335Z", fill: "#FF6503" }),
|
|
1083
|
+
/* @__PURE__ */ jsx5("path", { d: "M420.132 63.2607V19.7826H432.741V63.2607H420.132ZM426.436 13.4782C424.552 13.4782 422.958 12.826 421.654 11.5217C420.349 10.2174 419.697 8.62316 419.697 6.73911C419.697 4.80675 420.349 3.21255 421.654 1.95651C422.958 0.65217 424.552 0 426.436 0C428.369 0 429.963 0.65217 431.219 1.95651C432.523 3.21255 433.175 4.80675 433.175 6.73911C433.175 8.62316 432.523 10.2174 431.219 11.5217C429.963 12.826 428.369 13.4782 426.436 13.4782Z", fill: "#FF6503" }),
|
|
1084
|
+
/* @__PURE__ */ jsx5("path", { d: "M392.452 63.2607V29.7825H384.336V19.7825H392.669V5.28979H404.843V19.7825H413.466V29.7825H405.061V63.2607H392.452Z", fill: "#3A3A3A" }),
|
|
1085
|
+
/* @__PURE__ */ jsx5("path", { d: "M338.059 63.2605V19.7824H349.363V24.565C350.909 22.536 352.817 20.9901 355.088 19.9273C357.358 18.8645 359.798 18.3331 362.406 18.3331C365.498 18.3331 368.373 19.0819 371.03 20.5795C373.735 22.0288 375.909 24.1785 377.551 27.0288C379.242 29.8307 380.087 33.2365 380.087 37.2461V63.2605H367.479V38.9128C367.479 36.4973 366.754 34.3476 365.305 32.4635C363.856 30.5795 361.778 29.6374 359.073 29.6374C356.899 29.6374 354.943 30.3862 353.203 31.8838C351.513 33.3331 350.667 35.6278 350.667 38.7679V63.2605H338.059Z", fill: "#3A3A3A" }),
|
|
1086
|
+
/* @__PURE__ */ jsx5("path", { d: "M310.56 64.7098C305.68 64.7098 301.381 63.6953 297.661 61.6664C293.941 59.6374 291.043 56.8596 288.966 53.333C286.888 49.7582 285.85 45.6761 285.85 41.0867C285.85 36.6906 286.864 32.8017 288.893 29.4201C290.922 25.9901 293.652 23.2848 297.081 21.3041C300.56 19.3235 304.4 18.3331 308.603 18.3331C312.903 18.3331 316.743 19.3235 320.125 21.3041C323.507 23.2365 326.164 25.8935 328.096 29.2751C330.077 32.6568 331.067 36.4973 331.067 40.7968V45.2171H304.545C303.337 45.2171 302.178 45.1447 301.067 44.9997C299.956 44.8548 298.845 44.6857 297.734 44.4925C298.313 47.391 299.738 49.7582 302.009 51.5939C304.328 53.3813 307.275 54.2751 310.85 54.2751C313.603 54.2751 316.067 53.7195 318.241 52.6084C320.463 51.4973 322.275 50.1205 323.676 48.478L326.429 59.7823C324.255 61.4248 321.792 62.6567 319.038 63.4779C316.333 64.2992 313.507 64.7098 310.56 64.7098ZM297.444 36.8838C299.859 36.3524 302.226 36.0867 304.545 36.0867H312.226C313.579 36.0867 314.859 36.135 316.067 36.2316C317.275 36.3283 318.41 36.4973 319.473 36.7389C318.748 34.1302 317.42 32.0771 315.487 30.5795C313.603 29.0819 311.26 28.3331 308.458 28.3331C305.801 28.3331 303.482 29.1061 301.502 30.6519C299.569 32.1495 298.217 34.2268 297.444 36.8838Z", fill: "#3A3A3A" }),
|
|
1087
|
+
/* @__PURE__ */ jsx5("path", { d: "M263.884 64.7098C260.937 64.7098 257.942 64.2267 254.898 63.2605C251.903 62.2944 249.56 60.99 247.869 59.3475L250.985 47.4635C252.386 49.3959 254.318 51.0867 256.782 52.5359C259.294 53.9852 261.879 54.7098 264.536 54.7098C266.323 54.7098 267.603 54.3717 268.376 53.6954C269.198 53.019 269.608 52.1978 269.608 51.2316C269.608 50.1205 269.198 49.3234 268.376 48.8403C267.555 48.3089 266.71 47.8741 265.84 47.536L259.753 45.2171C258.401 44.6857 256.855 43.9611 255.115 43.0432C253.376 42.1253 251.855 40.821 250.55 39.1302C249.294 37.4394 248.666 35.2171 248.666 32.4635C248.666 29.9515 249.294 27.6326 250.55 25.507C251.806 23.3814 253.618 21.6665 255.985 20.3621C258.401 19.0095 261.299 18.3331 264.681 18.3331C267.821 18.3331 270.743 18.8645 273.449 19.9273C276.202 20.9901 278.207 22.1737 279.463 23.478L276.565 34.9273C274.922 32.8017 272.966 31.1833 270.695 30.0722C268.473 28.9128 266.347 28.3331 264.318 28.3331C262.772 28.3331 261.637 28.6471 260.913 29.2751C260.188 29.9031 259.826 30.6278 259.826 31.449C259.826 32.0771 260.067 32.7051 260.55 33.3331C261.082 33.9128 261.951 34.4442 263.159 34.9273L268.811 37.0287C270.454 37.6084 272.193 38.3814 274.028 39.3476C275.913 40.3137 277.507 41.6664 278.811 43.4055C280.115 45.0963 280.768 47.4393 280.768 50.4345C280.768 54.6374 279.198 58.0673 276.057 60.7243C272.966 63.3813 268.908 64.7098 263.884 64.7098Z", fill: "#3A3A3A" }),
|
|
1088
|
+
/* @__PURE__ */ jsx5("path", { d: "M198.861 63.2605V19.7824H210.166V24.565C211.712 22.536 213.62 20.9901 215.89 19.9273C218.161 18.8645 220.6 18.3331 223.209 18.3331C226.301 18.3331 229.175 19.0819 231.832 20.5795C234.538 22.0288 236.711 24.1785 238.354 27.0288C240.045 29.8307 240.89 33.2365 240.89 37.2461V63.2605H228.282V38.9128C228.282 36.4973 227.557 34.3476 226.108 32.4635C224.658 30.5795 222.581 29.6374 219.876 29.6374C217.702 29.6374 215.745 30.3862 214.006 31.8838C212.315 33.3331 211.47 35.6278 211.47 38.7679V63.2605H198.861Z", fill: "#3A3A3A" }),
|
|
1089
|
+
/* @__PURE__ */ jsx5("path", { d: "M167.99 64.7098C163.69 64.7098 159.753 63.6712 156.178 61.5939C152.603 59.5166 149.753 56.7147 147.628 53.1881C145.55 49.6616 144.512 45.7727 144.512 41.5215C144.512 37.222 145.55 33.3331 147.628 29.8548C149.753 26.3283 152.603 23.5264 156.178 21.4491C159.753 19.3718 163.69 18.3331 167.99 18.3331C172.338 18.3331 176.275 19.3718 179.801 21.4491C183.376 23.5264 186.202 26.3283 188.28 29.8548C190.405 33.3331 191.468 37.222 191.468 41.5215C191.468 45.7727 190.405 49.6616 188.28 53.1881C186.202 56.7147 183.376 59.5166 179.801 61.5939C176.275 63.6712 172.338 64.7098 167.99 64.7098ZM167.99 53.4055C170.164 53.4055 172.12 52.8741 173.859 51.8113C175.647 50.7485 177.048 49.3234 178.062 47.536C179.125 45.7002 179.657 43.6954 179.657 41.5215C179.657 39.2993 179.125 37.2944 178.062 35.507C177.048 33.7196 175.647 32.2944 173.859 31.2316C172.12 30.1688 170.164 29.6374 167.99 29.6374C165.816 29.6374 163.835 30.1688 162.048 31.2316C160.309 32.2944 158.908 33.7196 157.845 35.507C156.831 37.2944 156.323 39.2993 156.323 41.5215C156.323 43.6954 156.831 45.7002 157.845 47.536C158.908 49.3234 160.309 50.7485 162.048 51.8113C163.835 52.8741 165.816 53.4055 167.99 53.4055Z", fill: "#3A3A3A" }),
|
|
1090
|
+
/* @__PURE__ */ jsx5("path", { d: "M124.478 64.7098C120.179 64.7098 116.242 63.6712 112.667 61.5939C109.092 59.5166 106.242 56.7147 104.116 53.1881C102.039 49.6616 101 45.7727 101 41.5215C101 37.222 102.039 33.3331 104.116 29.8548C106.242 26.3283 109.092 23.5264 112.667 21.4491C116.242 19.3718 120.179 18.3331 124.478 18.3331C127.473 18.3331 130.299 18.8404 132.956 19.8549C135.662 20.821 138.053 22.2703 140.13 24.2027L136.869 37.0287C135.662 35.0481 134.043 33.3331 132.014 31.8838C130.034 30.3862 127.691 29.6374 124.985 29.6374C122.715 29.6374 120.686 30.1688 118.899 31.2316C117.111 32.2944 115.71 33.7196 114.696 35.507C113.681 37.2944 113.174 39.2993 113.174 41.5215C113.174 43.6954 113.681 45.7002 114.696 47.536C115.71 49.3234 117.111 50.7485 118.899 51.8113C120.686 52.8741 122.715 53.4055 124.985 53.4055C127.691 53.4055 130.034 52.6809 132.014 51.2316C134.043 49.734 135.662 47.9949 136.869 46.0142L140.13 58.8403C138.053 60.7726 135.662 62.2461 132.956 63.2605C130.299 64.2267 127.473 64.7098 124.478 64.7098Z", fill: "#3A3A3A" })
|
|
927
1091
|
] });
|
|
928
1092
|
}
|
|
929
1093
|
|
|
930
1094
|
// src/components/ConsentGate.tsx
|
|
931
|
-
import { Fragment as Fragment2, jsx as
|
|
1095
|
+
import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
|
|
932
1096
|
function ConsentGate({
|
|
933
1097
|
category,
|
|
934
1098
|
children,
|
|
@@ -937,12 +1101,12 @@ function ConsentGate({
|
|
|
937
1101
|
}) {
|
|
938
1102
|
const { hasConsent, isLoading } = useConsentGate(category);
|
|
939
1103
|
if (isLoading) {
|
|
940
|
-
return /* @__PURE__ */
|
|
1104
|
+
return /* @__PURE__ */ jsx6(Fragment2, { children: loading });
|
|
941
1105
|
}
|
|
942
1106
|
if (hasConsent) {
|
|
943
|
-
return /* @__PURE__ */
|
|
1107
|
+
return /* @__PURE__ */ jsx6(Fragment2, { children });
|
|
944
1108
|
}
|
|
945
|
-
return /* @__PURE__ */
|
|
1109
|
+
return /* @__PURE__ */ jsx6(Fragment2, { children: fallback });
|
|
946
1110
|
}
|
|
947
1111
|
function withConsentGate(Component, category, FallbackComponent) {
|
|
948
1112
|
return function ConsentGatedComponent(props) {
|
|
@@ -951,19 +1115,282 @@ function withConsentGate(Component, category, FallbackComponent) {
|
|
|
951
1115
|
return null;
|
|
952
1116
|
}
|
|
953
1117
|
if (hasConsent) {
|
|
954
|
-
return /* @__PURE__ */
|
|
1118
|
+
return /* @__PURE__ */ jsx6(Component, { ...props });
|
|
955
1119
|
}
|
|
956
1120
|
if (FallbackComponent) {
|
|
957
|
-
return /* @__PURE__ */
|
|
1121
|
+
return /* @__PURE__ */ jsx6(FallbackComponent, { ...props });
|
|
958
1122
|
}
|
|
959
1123
|
return null;
|
|
960
1124
|
};
|
|
961
1125
|
}
|
|
1126
|
+
|
|
1127
|
+
// src/components/MarketingConsentForm.tsx
|
|
1128
|
+
import { forwardRef, useImperativeHandle } from "react";
|
|
1129
|
+
|
|
1130
|
+
// src/hooks/useFormConsent.ts
|
|
1131
|
+
import { useState as useState4, useEffect as useEffect3, useCallback as useCallback2, useRef } from "react";
|
|
1132
|
+
var configCache = /* @__PURE__ */ new Map();
|
|
1133
|
+
var CONFIG_TTL = 6e4;
|
|
1134
|
+
function getCachedConfig(propertyKey) {
|
|
1135
|
+
const entry = configCache.get(propertyKey);
|
|
1136
|
+
if (entry && Date.now() - entry.timestamp < CONFIG_TTL) {
|
|
1137
|
+
return entry.config;
|
|
1138
|
+
}
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1141
|
+
function setCachedConfig(propertyKey, config) {
|
|
1142
|
+
configCache.set(propertyKey, { config, timestamp: Date.now() });
|
|
1143
|
+
}
|
|
1144
|
+
function useFormConsent(options) {
|
|
1145
|
+
const { propertyKey, apiUrl, subjectId, subjectType = "visitor", debug = false } = options;
|
|
1146
|
+
const [config, setConfig] = useState4(() => getCachedConfig(propertyKey));
|
|
1147
|
+
const [consents, setConsents] = useState4({});
|
|
1148
|
+
const [isLoading, setIsLoading] = useState4(!getCachedConfig(propertyKey));
|
|
1149
|
+
const [isSubmitting, setIsSubmitting] = useState4(false);
|
|
1150
|
+
const [error, setError] = useState4(null);
|
|
1151
|
+
const [lastSubmission, setLastSubmission] = useState4(null);
|
|
1152
|
+
const apiClientRef = useRef(null);
|
|
1153
|
+
useEffect3(() => {
|
|
1154
|
+
if (config) return;
|
|
1155
|
+
let cancelled = false;
|
|
1156
|
+
const client = new ConsentIQApiClient(propertyKey, apiUrl, debug);
|
|
1157
|
+
apiClientRef.current = client;
|
|
1158
|
+
client.getConfig().then((cfg) => {
|
|
1159
|
+
if (cancelled) return;
|
|
1160
|
+
setCachedConfig(propertyKey, cfg);
|
|
1161
|
+
setConfig(cfg);
|
|
1162
|
+
setIsLoading(false);
|
|
1163
|
+
}).catch((err) => {
|
|
1164
|
+
if (cancelled) return;
|
|
1165
|
+
setError(err.message || "Failed to load config");
|
|
1166
|
+
setIsLoading(false);
|
|
1167
|
+
});
|
|
1168
|
+
return () => {
|
|
1169
|
+
cancelled = true;
|
|
1170
|
+
};
|
|
1171
|
+
}, [propertyKey, apiUrl, debug]);
|
|
1172
|
+
const privacyNoticeUrl = (() => {
|
|
1173
|
+
if (!config) return null;
|
|
1174
|
+
const currentPath = typeof window !== "undefined" ? window.location.pathname : "/";
|
|
1175
|
+
const sources = config.formConsentSources || [];
|
|
1176
|
+
for (const source of sources) {
|
|
1177
|
+
if (!source.selector) continue;
|
|
1178
|
+
const selectorPath = source.selector.startsWith("/") ? source.selector.split("#")[0] : null;
|
|
1179
|
+
if (selectorPath && currentPath.startsWith(selectorPath)) {
|
|
1180
|
+
const noticeParam = source.privacyNotice.id;
|
|
1181
|
+
return `${config.privacyNoticeUrl}?notice=${noticeParam}`;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
return config.privacyNoticeUrl;
|
|
1185
|
+
})();
|
|
1186
|
+
const channels = config?.marketingChannels || [];
|
|
1187
|
+
const setConsent = useCallback2((channel, value) => {
|
|
1188
|
+
setConsents((prev) => ({ ...prev, [channel]: value }));
|
|
1189
|
+
}, []);
|
|
1190
|
+
const setAllConsents = useCallback2((value) => {
|
|
1191
|
+
if (!config) return;
|
|
1192
|
+
const newConsents = {};
|
|
1193
|
+
for (const ch of config.marketingChannels) {
|
|
1194
|
+
newConsents[ch.code] = value;
|
|
1195
|
+
}
|
|
1196
|
+
setConsents(newConsents);
|
|
1197
|
+
}, [config]);
|
|
1198
|
+
const submit = useCallback2(async () => {
|
|
1199
|
+
if (!subjectId) {
|
|
1200
|
+
setError("subjectId is required");
|
|
1201
|
+
return null;
|
|
1202
|
+
}
|
|
1203
|
+
if (!apiClientRef.current) {
|
|
1204
|
+
setError("API client not initialized");
|
|
1205
|
+
return null;
|
|
1206
|
+
}
|
|
1207
|
+
setIsSubmitting(true);
|
|
1208
|
+
setError(null);
|
|
1209
|
+
try {
|
|
1210
|
+
const result = await apiClientRef.current.submitConsent({
|
|
1211
|
+
subjectId,
|
|
1212
|
+
subjectType,
|
|
1213
|
+
marketingConsents: consents,
|
|
1214
|
+
consentMethod: "form"
|
|
1215
|
+
});
|
|
1216
|
+
const submission = { consentId: result.consentId, proofHash: result.proofHash };
|
|
1217
|
+
setLastSubmission(submission);
|
|
1218
|
+
setIsSubmitting(false);
|
|
1219
|
+
return submission;
|
|
1220
|
+
} catch (err) {
|
|
1221
|
+
const message = err instanceof Error ? err.message : "Failed to submit consent";
|
|
1222
|
+
setError(message);
|
|
1223
|
+
setIsSubmitting(false);
|
|
1224
|
+
return null;
|
|
1225
|
+
}
|
|
1226
|
+
}, [subjectId, subjectType, consents]);
|
|
1227
|
+
return {
|
|
1228
|
+
channels,
|
|
1229
|
+
consents,
|
|
1230
|
+
privacyNoticeUrl,
|
|
1231
|
+
lastSubmission,
|
|
1232
|
+
setConsent,
|
|
1233
|
+
setAllConsents,
|
|
1234
|
+
submit,
|
|
1235
|
+
isLoading,
|
|
1236
|
+
isSubmitting,
|
|
1237
|
+
error
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/components/MarketingConsentForm.tsx
|
|
1242
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1243
|
+
var MarketingConsentForm = forwardRef(
|
|
1244
|
+
function MarketingConsentForm2({
|
|
1245
|
+
propertyKey,
|
|
1246
|
+
apiUrl,
|
|
1247
|
+
subjectId,
|
|
1248
|
+
subjectType,
|
|
1249
|
+
mode = "simple",
|
|
1250
|
+
simpleLabel,
|
|
1251
|
+
channels: channelFilter,
|
|
1252
|
+
onConsentSubmitted,
|
|
1253
|
+
onConsentChange,
|
|
1254
|
+
autoSubmit = false,
|
|
1255
|
+
className,
|
|
1256
|
+
style,
|
|
1257
|
+
showDescriptions = false,
|
|
1258
|
+
showPrivacyLink = true,
|
|
1259
|
+
privacyLinkText = "Privacy Policy",
|
|
1260
|
+
privacyUrl: privacyUrlOverride
|
|
1261
|
+
}, ref) {
|
|
1262
|
+
const resolvedPropertyKey = propertyKey || "";
|
|
1263
|
+
const {
|
|
1264
|
+
channels,
|
|
1265
|
+
consents,
|
|
1266
|
+
privacyNoticeUrl,
|
|
1267
|
+
setConsent,
|
|
1268
|
+
setAllConsents,
|
|
1269
|
+
submit,
|
|
1270
|
+
isLoading,
|
|
1271
|
+
isSubmitting
|
|
1272
|
+
} = useFormConsent({
|
|
1273
|
+
propertyKey: resolvedPropertyKey,
|
|
1274
|
+
apiUrl,
|
|
1275
|
+
subjectId,
|
|
1276
|
+
subjectType
|
|
1277
|
+
});
|
|
1278
|
+
const privacyUrl = privacyUrlOverride || privacyNoticeUrl;
|
|
1279
|
+
const visibleChannels = channelFilter ? channels.filter((ch) => channelFilter.includes(ch.code)) : channels;
|
|
1280
|
+
useImperativeHandle(ref, () => ({
|
|
1281
|
+
submit: async () => {
|
|
1282
|
+
const result = await submit();
|
|
1283
|
+
if (result && onConsentSubmitted) {
|
|
1284
|
+
onConsentSubmitted({ ...result, consents });
|
|
1285
|
+
}
|
|
1286
|
+
return result;
|
|
1287
|
+
},
|
|
1288
|
+
getConsents: () => consents,
|
|
1289
|
+
reset: () => setAllConsents(false)
|
|
1290
|
+
}), [submit, consents, onConsentSubmitted, setAllConsents]);
|
|
1291
|
+
const handleChange = (channel, value) => {
|
|
1292
|
+
setConsent(channel, value);
|
|
1293
|
+
const updated = { ...consents, [channel]: value };
|
|
1294
|
+
onConsentChange?.(updated);
|
|
1295
|
+
if (autoSubmit) {
|
|
1296
|
+
submit().then((result) => {
|
|
1297
|
+
if (result && onConsentSubmitted) {
|
|
1298
|
+
onConsentSubmitted({ ...result, consents: updated });
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
const handleSimpleChange = (checked) => {
|
|
1304
|
+
setAllConsents(checked);
|
|
1305
|
+
const updated = {};
|
|
1306
|
+
for (const ch of visibleChannels) {
|
|
1307
|
+
updated[ch.code] = checked;
|
|
1308
|
+
}
|
|
1309
|
+
onConsentChange?.(updated);
|
|
1310
|
+
if (autoSubmit) {
|
|
1311
|
+
submit().then((result) => {
|
|
1312
|
+
if (result && onConsentSubmitted) {
|
|
1313
|
+
onConsentSubmitted({ ...result, consents: updated });
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
if (isLoading) {
|
|
1319
|
+
return null;
|
|
1320
|
+
}
|
|
1321
|
+
const allChecked = visibleChannels.length > 0 && visibleChannels.every((ch) => consents[ch.code]);
|
|
1322
|
+
return /* @__PURE__ */ jsx7("div", { className, style: { fontSize: "14px", ...style }, children: mode === "simple" ? /* @__PURE__ */ jsxs4("label", { style: { display: "flex", alignItems: "flex-start", gap: "8px", cursor: "pointer" }, children: [
|
|
1323
|
+
/* @__PURE__ */ jsx7(
|
|
1324
|
+
"input",
|
|
1325
|
+
{
|
|
1326
|
+
type: "checkbox",
|
|
1327
|
+
checked: allChecked,
|
|
1328
|
+
onChange: (e) => handleSimpleChange(e.target.checked),
|
|
1329
|
+
disabled: isSubmitting,
|
|
1330
|
+
style: { marginTop: "3px" }
|
|
1331
|
+
}
|
|
1332
|
+
),
|
|
1333
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1334
|
+
simpleLabel || "I agree to receive marketing communications",
|
|
1335
|
+
showPrivacyLink && privacyUrl && /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
1336
|
+
". ",
|
|
1337
|
+
/* @__PURE__ */ jsx7(
|
|
1338
|
+
"a",
|
|
1339
|
+
{
|
|
1340
|
+
href: privacyUrl,
|
|
1341
|
+
target: "_blank",
|
|
1342
|
+
rel: "noopener noreferrer",
|
|
1343
|
+
style: { textDecoration: "underline" },
|
|
1344
|
+
children: privacyLinkText
|
|
1345
|
+
}
|
|
1346
|
+
)
|
|
1347
|
+
] })
|
|
1348
|
+
] })
|
|
1349
|
+
] }) : /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
|
|
1350
|
+
visibleChannels.map((ch) => /* @__PURE__ */ jsxs4(
|
|
1351
|
+
"label",
|
|
1352
|
+
{
|
|
1353
|
+
style: { display: "flex", alignItems: "flex-start", gap: "8px", cursor: "pointer" },
|
|
1354
|
+
children: [
|
|
1355
|
+
/* @__PURE__ */ jsx7(
|
|
1356
|
+
"input",
|
|
1357
|
+
{
|
|
1358
|
+
type: "checkbox",
|
|
1359
|
+
checked: consents[ch.code] === true,
|
|
1360
|
+
onChange: (e) => handleChange(ch.code, e.target.checked),
|
|
1361
|
+
disabled: isSubmitting,
|
|
1362
|
+
style: { marginTop: "3px" }
|
|
1363
|
+
}
|
|
1364
|
+
),
|
|
1365
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1366
|
+
/* @__PURE__ */ jsx7("strong", { children: ch.name }),
|
|
1367
|
+
showDescriptions && ch.description && /* @__PURE__ */ jsx7("span", { style: { display: "block", color: "#666", fontSize: "12px" }, children: ch.description })
|
|
1368
|
+
] })
|
|
1369
|
+
]
|
|
1370
|
+
},
|
|
1371
|
+
ch.code
|
|
1372
|
+
)),
|
|
1373
|
+
showPrivacyLink && privacyUrl && /* @__PURE__ */ jsx7(
|
|
1374
|
+
"a",
|
|
1375
|
+
{
|
|
1376
|
+
href: privacyUrl,
|
|
1377
|
+
target: "_blank",
|
|
1378
|
+
rel: "noopener noreferrer",
|
|
1379
|
+
style: { fontSize: "12px", textDecoration: "underline", color: "#666" },
|
|
1380
|
+
children: privacyLinkText
|
|
1381
|
+
}
|
|
1382
|
+
)
|
|
1383
|
+
] }) });
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
962
1386
|
export {
|
|
963
1387
|
ConsentGate,
|
|
964
1388
|
ConsentIQApiClient,
|
|
965
1389
|
ConsentIQProvider,
|
|
1390
|
+
ConsentTrigger,
|
|
966
1391
|
CookieBanner,
|
|
1392
|
+
LanguageSelector,
|
|
1393
|
+
MarketingConsentForm,
|
|
967
1394
|
PreferenceCenter,
|
|
968
1395
|
detectCountry,
|
|
969
1396
|
detectLanguage,
|
|
@@ -972,5 +1399,6 @@ export {
|
|
|
972
1399
|
useConsent,
|
|
973
1400
|
useConsentGate,
|
|
974
1401
|
useConsentIQ,
|
|
1402
|
+
useFormConsent,
|
|
975
1403
|
withConsentGate
|
|
976
1404
|
};
|