react-lgpd-consent 0.3.4 → 0.3.6
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/CHANGELOG.md +10 -8
- package/LICENSE +21 -21
- package/QUICKSTART.md +25 -4
- package/README.md +23 -0
- package/dist/{PreferencesModal-XYBFROAB.js → PreferencesModal-KAZMVPBD.js} +1 -1
- package/dist/{chunk-7D2F6JFW.js → chunk-MHCQFGRJ.js} +69 -214
- package/dist/index.cjs +162 -250
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +73 -2
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -211,93 +211,6 @@ var init_CategoriesContext = __esm({
|
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
-
// src/utils/SafeThemeProvider.tsx
|
|
215
|
-
function SafeThemeProvider({ theme, children }) {
|
|
216
|
-
const safeTheme = React3.useMemo(() => createSafeTheme(theme), [theme]);
|
|
217
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_styles.ThemeProvider, { theme: safeTheme, children });
|
|
218
|
-
}
|
|
219
|
-
var React3, import_styles, import_jsx_runtime2, createSafeTheme;
|
|
220
|
-
var init_SafeThemeProvider = __esm({
|
|
221
|
-
"src/utils/SafeThemeProvider.tsx"() {
|
|
222
|
-
"use strict";
|
|
223
|
-
React3 = __toESM(require("react"), 1);
|
|
224
|
-
import_styles = require("@mui/material/styles");
|
|
225
|
-
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
226
|
-
createSafeTheme = (userTheme) => {
|
|
227
|
-
const baseTheme = (0, import_styles.createTheme)({
|
|
228
|
-
palette: {
|
|
229
|
-
primary: {
|
|
230
|
-
main: "#1976d2",
|
|
231
|
-
dark: "#1565c0",
|
|
232
|
-
light: "#42a5f5",
|
|
233
|
-
contrastText: "#ffffff"
|
|
234
|
-
},
|
|
235
|
-
secondary: {
|
|
236
|
-
main: "#dc004e",
|
|
237
|
-
dark: "#9a0036",
|
|
238
|
-
light: "#e33371",
|
|
239
|
-
contrastText: "#ffffff"
|
|
240
|
-
},
|
|
241
|
-
background: {
|
|
242
|
-
default: "#fafafa",
|
|
243
|
-
paper: "#ffffff"
|
|
244
|
-
},
|
|
245
|
-
text: {
|
|
246
|
-
primary: "#333333",
|
|
247
|
-
secondary: "#666666"
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
transitions: {
|
|
251
|
-
duration: {
|
|
252
|
-
shortest: 150,
|
|
253
|
-
shorter: 200,
|
|
254
|
-
short: 250,
|
|
255
|
-
standard: 300,
|
|
256
|
-
complex: 375,
|
|
257
|
-
enteringScreen: 225,
|
|
258
|
-
leavingScreen: 195
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
if (!userTheme) {
|
|
263
|
-
return baseTheme;
|
|
264
|
-
}
|
|
265
|
-
return (0, import_styles.createTheme)({
|
|
266
|
-
...baseTheme,
|
|
267
|
-
...userTheme,
|
|
268
|
-
palette: {
|
|
269
|
-
...baseTheme.palette,
|
|
270
|
-
...userTheme.palette,
|
|
271
|
-
primary: {
|
|
272
|
-
...baseTheme.palette.primary,
|
|
273
|
-
...userTheme.palette?.primary
|
|
274
|
-
},
|
|
275
|
-
secondary: {
|
|
276
|
-
...baseTheme.palette.secondary,
|
|
277
|
-
...userTheme.palette?.secondary
|
|
278
|
-
},
|
|
279
|
-
background: {
|
|
280
|
-
...baseTheme.palette.background,
|
|
281
|
-
...userTheme.palette?.background
|
|
282
|
-
},
|
|
283
|
-
text: {
|
|
284
|
-
...baseTheme.palette.text,
|
|
285
|
-
...userTheme.palette?.text
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
transitions: {
|
|
289
|
-
...baseTheme.transitions,
|
|
290
|
-
...userTheme.transitions,
|
|
291
|
-
duration: {
|
|
292
|
-
...baseTheme.transitions.duration,
|
|
293
|
-
...userTheme.transitions?.duration
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
214
|
// src/utils/logger.ts
|
|
302
215
|
function setDebugLogging(enabled, level = 2 /* INFO */) {
|
|
303
216
|
logger.setEnabled(enabled);
|
|
@@ -664,97 +577,23 @@ var init_categoryUtils = __esm({
|
|
|
664
577
|
}
|
|
665
578
|
});
|
|
666
579
|
|
|
667
|
-
// src/utils/theme.ts
|
|
668
|
-
var import_styles2, defaultConsentTheme;
|
|
669
|
-
var init_theme = __esm({
|
|
670
|
-
"src/utils/theme.ts"() {
|
|
671
|
-
"use strict";
|
|
672
|
-
import_styles2 = require("@mui/material/styles");
|
|
673
|
-
defaultConsentTheme = (0, import_styles2.createTheme)({
|
|
674
|
-
palette: {
|
|
675
|
-
primary: {
|
|
676
|
-
main: "#1976d2",
|
|
677
|
-
contrastText: "#ffffff"
|
|
678
|
-
},
|
|
679
|
-
secondary: {
|
|
680
|
-
main: "#dc004e",
|
|
681
|
-
contrastText: "#ffffff"
|
|
682
|
-
},
|
|
683
|
-
background: {
|
|
684
|
-
default: "#fafafa",
|
|
685
|
-
paper: "#ffffff"
|
|
686
|
-
},
|
|
687
|
-
text: {
|
|
688
|
-
primary: "#333333",
|
|
689
|
-
secondary: "#666666"
|
|
690
|
-
},
|
|
691
|
-
action: {
|
|
692
|
-
hover: "rgba(25, 118, 210, 0.04)"
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
typography: {
|
|
696
|
-
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
|
697
|
-
body2: {
|
|
698
|
-
fontSize: "0.875rem",
|
|
699
|
-
lineHeight: 1.43
|
|
700
|
-
},
|
|
701
|
-
button: {
|
|
702
|
-
fontWeight: 500,
|
|
703
|
-
textTransform: "none"
|
|
704
|
-
}
|
|
705
|
-
},
|
|
706
|
-
components: {
|
|
707
|
-
MuiButton: {
|
|
708
|
-
styleOverrides: {
|
|
709
|
-
root: {
|
|
710
|
-
borderRadius: 8,
|
|
711
|
-
paddingX: 16,
|
|
712
|
-
paddingY: 8
|
|
713
|
-
},
|
|
714
|
-
contained: {
|
|
715
|
-
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
716
|
-
"&:hover": {
|
|
717
|
-
boxShadow: "0 4px 8px rgba(0,0,0,0.15)"
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
MuiPaper: {
|
|
723
|
-
styleOverrides: {
|
|
724
|
-
root: {
|
|
725
|
-
borderRadius: 12
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
},
|
|
729
|
-
MuiDialog: {
|
|
730
|
-
styleOverrides: {
|
|
731
|
-
paper: {
|
|
732
|
-
borderRadius: 16
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
});
|
|
740
|
-
|
|
741
580
|
// src/context/DesignContext.tsx
|
|
742
581
|
function DesignProvider({
|
|
743
582
|
tokens,
|
|
744
583
|
children
|
|
745
584
|
}) {
|
|
746
|
-
return /* @__PURE__ */ (0,
|
|
585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DesignContext.Provider, { value: tokens, children });
|
|
747
586
|
}
|
|
748
587
|
function useDesignTokens() {
|
|
749
|
-
return
|
|
588
|
+
return React3.useContext(DesignContext);
|
|
750
589
|
}
|
|
751
|
-
var
|
|
590
|
+
var React3, import_jsx_runtime2, DesignContext;
|
|
752
591
|
var init_DesignContext = __esm({
|
|
753
592
|
"src/context/DesignContext.tsx"() {
|
|
754
593
|
"use strict";
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
DesignContext =
|
|
594
|
+
React3 = __toESM(require("react"), 1);
|
|
595
|
+
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
596
|
+
DesignContext = React3.createContext(void 0);
|
|
758
597
|
}
|
|
759
598
|
});
|
|
760
599
|
|
|
@@ -763,7 +602,7 @@ function Branding({ variant, hidden = false }) {
|
|
|
763
602
|
const texts = useConsentTexts();
|
|
764
603
|
const designTokens = useDesignTokens();
|
|
765
604
|
if (hidden) return null;
|
|
766
|
-
return /* @__PURE__ */ (0,
|
|
605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
767
606
|
import_Typography.default,
|
|
768
607
|
{
|
|
769
608
|
variant: "caption",
|
|
@@ -774,7 +613,7 @@ function Branding({ variant, hidden = false }) {
|
|
|
774
613
|
children: [
|
|
775
614
|
texts.brandingPoweredBy || "fornecido por",
|
|
776
615
|
" ",
|
|
777
|
-
/* @__PURE__ */ (0,
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
778
617
|
import_Link.default,
|
|
779
618
|
{
|
|
780
619
|
href: "https://www.ledipo.eti.br",
|
|
@@ -791,7 +630,7 @@ function Branding({ variant, hidden = false }) {
|
|
|
791
630
|
}
|
|
792
631
|
);
|
|
793
632
|
}
|
|
794
|
-
var import_Link, import_Typography,
|
|
633
|
+
var import_Link, import_Typography, import_jsx_runtime3, brandingStyles, linkStyles;
|
|
795
634
|
var init_Branding = __esm({
|
|
796
635
|
"src/components/Branding.tsx"() {
|
|
797
636
|
"use strict";
|
|
@@ -799,7 +638,7 @@ var init_Branding = __esm({
|
|
|
799
638
|
init_DesignContext();
|
|
800
639
|
import_Link = __toESM(require("@mui/material/Link"), 1);
|
|
801
640
|
import_Typography = __toESM(require("@mui/material/Typography"), 1);
|
|
802
|
-
|
|
641
|
+
import_jsx_runtime3 = require("react/jsx-runtime");
|
|
803
642
|
brandingStyles = {
|
|
804
643
|
banner: {
|
|
805
644
|
fontSize: "0.65rem",
|
|
@@ -860,11 +699,11 @@ function CookieBanner({
|
|
|
860
699
|
borderRadius: designTokens?.spacing?.borderRadius?.banner,
|
|
861
700
|
fontFamily: designTokens?.typography?.fontFamily
|
|
862
701
|
};
|
|
863
|
-
const bannerContent = /* @__PURE__ */ (0,
|
|
864
|
-
/* @__PURE__ */ (0,
|
|
702
|
+
const bannerContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Paper.default, { elevation: 3, sx: bannerStyle, ...PaperProps, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_Stack.default, { spacing: 1, children: [
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_Typography2.default, { variant: "body2", sx: { fontSize: designTokens?.typography?.fontSize?.banner }, children: [
|
|
865
704
|
texts.bannerMessage,
|
|
866
705
|
" ",
|
|
867
|
-
policyLinkUrl && /* @__PURE__ */ (0,
|
|
706
|
+
policyLinkUrl && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
868
707
|
import_Link2.default,
|
|
869
708
|
{
|
|
870
709
|
href: policyLinkUrl,
|
|
@@ -876,8 +715,8 @@ function CookieBanner({
|
|
|
876
715
|
}
|
|
877
716
|
)
|
|
878
717
|
] }),
|
|
879
|
-
/* @__PURE__ */ (0,
|
|
880
|
-
/* @__PURE__ */ (0,
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_Stack.default, { direction: { xs: "column", sm: "row" }, spacing: 1, justifyContent: "flex-end", children: [
|
|
719
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
881
720
|
import_Button.default,
|
|
882
721
|
{
|
|
883
722
|
variant: "outlined",
|
|
@@ -889,7 +728,7 @@ function CookieBanner({
|
|
|
889
728
|
children: texts.declineAll
|
|
890
729
|
}
|
|
891
730
|
),
|
|
892
|
-
/* @__PURE__ */ (0,
|
|
731
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
893
732
|
import_Button.default,
|
|
894
733
|
{
|
|
895
734
|
variant: "contained",
|
|
@@ -901,7 +740,7 @@ function CookieBanner({
|
|
|
901
740
|
children: texts.acceptAll
|
|
902
741
|
}
|
|
903
742
|
),
|
|
904
|
-
/* @__PURE__ */ (0,
|
|
743
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
905
744
|
import_Button.default,
|
|
906
745
|
{
|
|
907
746
|
variant: "text",
|
|
@@ -914,7 +753,7 @@ function CookieBanner({
|
|
|
914
753
|
}
|
|
915
754
|
)
|
|
916
755
|
] }),
|
|
917
|
-
!hideBranding && /* @__PURE__ */ (0,
|
|
756
|
+
!hideBranding && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Branding, { variant: "banner" })
|
|
918
757
|
] }) });
|
|
919
758
|
const positionStyle = {
|
|
920
759
|
position: "fixed",
|
|
@@ -933,8 +772,8 @@ function CookieBanner({
|
|
|
933
772
|
backdropColor = backdropToken;
|
|
934
773
|
}
|
|
935
774
|
if (blocking) {
|
|
936
|
-
return /* @__PURE__ */ (0,
|
|
937
|
-
/* @__PURE__ */ (0,
|
|
775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
938
777
|
import_Box.default,
|
|
939
778
|
{
|
|
940
779
|
sx: {
|
|
@@ -948,10 +787,10 @@ function CookieBanner({
|
|
|
948
787
|
}
|
|
949
788
|
}
|
|
950
789
|
),
|
|
951
|
-
/* @__PURE__ */ (0,
|
|
790
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Box.default, { sx: positionStyle, children: bannerContent })
|
|
952
791
|
] });
|
|
953
792
|
}
|
|
954
|
-
return /* @__PURE__ */ (0,
|
|
793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
955
794
|
import_Snackbar.default,
|
|
956
795
|
{
|
|
957
796
|
open,
|
|
@@ -964,7 +803,7 @@ function CookieBanner({
|
|
|
964
803
|
}
|
|
965
804
|
);
|
|
966
805
|
}
|
|
967
|
-
var import_Button, import_Box, import_Paper, import_Snackbar, import_Stack, import_Typography2, import_Link2,
|
|
806
|
+
var import_Button, import_Box, import_Paper, import_Snackbar, import_Stack, import_Typography2, import_Link2, import_jsx_runtime4;
|
|
968
807
|
var init_CookieBanner = __esm({
|
|
969
808
|
"src/components/CookieBanner.tsx"() {
|
|
970
809
|
"use strict";
|
|
@@ -979,13 +818,13 @@ var init_CookieBanner = __esm({
|
|
|
979
818
|
init_DesignContext();
|
|
980
819
|
init_Branding();
|
|
981
820
|
init_logger();
|
|
982
|
-
|
|
821
|
+
import_jsx_runtime4 = require("react/jsx-runtime");
|
|
983
822
|
}
|
|
984
823
|
});
|
|
985
824
|
|
|
986
825
|
// src/components/FloatingPreferencesButton.tsx
|
|
987
826
|
function useThemeWithFallbacks() {
|
|
988
|
-
const theme = (0,
|
|
827
|
+
const theme = (0, import_styles.useTheme)();
|
|
989
828
|
logger.themeCompatibility(theme);
|
|
990
829
|
return {
|
|
991
830
|
palette: {
|
|
@@ -1005,7 +844,7 @@ function useThemeWithFallbacks() {
|
|
|
1005
844
|
function FloatingPreferencesButton({
|
|
1006
845
|
position = "bottom-right",
|
|
1007
846
|
offset = 24,
|
|
1008
|
-
icon = /* @__PURE__ */ (0,
|
|
847
|
+
icon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_CookieOutlined.default, {}),
|
|
1009
848
|
tooltip,
|
|
1010
849
|
FabProps,
|
|
1011
850
|
hideWhenConsented = false
|
|
@@ -1045,7 +884,7 @@ function FloatingPreferencesButton({
|
|
|
1045
884
|
return { ...styles, bottom: offset, right: offset };
|
|
1046
885
|
}
|
|
1047
886
|
};
|
|
1048
|
-
return /* @__PURE__ */ (0,
|
|
887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Tooltip.default, { title: tooltipText, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1049
888
|
import_Fab.default,
|
|
1050
889
|
{
|
|
1051
890
|
size: "medium",
|
|
@@ -1065,18 +904,18 @@ function FloatingPreferencesButton({
|
|
|
1065
904
|
}
|
|
1066
905
|
) });
|
|
1067
906
|
}
|
|
1068
|
-
var import_CookieOutlined, import_Fab, import_Tooltip,
|
|
907
|
+
var import_CookieOutlined, import_Fab, import_Tooltip, import_styles, import_jsx_runtime5;
|
|
1069
908
|
var init_FloatingPreferencesButton = __esm({
|
|
1070
909
|
"src/components/FloatingPreferencesButton.tsx"() {
|
|
1071
910
|
"use strict";
|
|
1072
911
|
import_CookieOutlined = __toESM(require("@mui/icons-material/CookieOutlined"), 1);
|
|
1073
912
|
import_Fab = __toESM(require("@mui/material/Fab"), 1);
|
|
1074
913
|
import_Tooltip = __toESM(require("@mui/material/Tooltip"), 1);
|
|
1075
|
-
|
|
914
|
+
import_styles = require("@mui/material/styles");
|
|
1076
915
|
init_DesignContext();
|
|
1077
916
|
init_useConsent();
|
|
1078
917
|
init_logger();
|
|
1079
|
-
|
|
918
|
+
import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1080
919
|
}
|
|
1081
920
|
});
|
|
1082
921
|
|
|
@@ -1179,18 +1018,18 @@ function ConsentProvider({
|
|
|
1179
1018
|
disableDeveloperGuidance,
|
|
1180
1019
|
children
|
|
1181
1020
|
}) {
|
|
1182
|
-
const texts =
|
|
1183
|
-
const cookie =
|
|
1021
|
+
const texts = React4.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
|
|
1022
|
+
const cookie = React4.useMemo(
|
|
1184
1023
|
() => ({ ...DEFAULT_COOKIE_OPTS, ...cookieOpts ?? {} }),
|
|
1185
1024
|
[cookieOpts]
|
|
1186
1025
|
);
|
|
1187
|
-
const
|
|
1188
|
-
const finalCategoriesConfig =
|
|
1026
|
+
const mergedTheme = theme;
|
|
1027
|
+
const finalCategoriesConfig = React4.useMemo(() => {
|
|
1189
1028
|
if (categories) return categories;
|
|
1190
1029
|
return DEFAULT_PROJECT_CATEGORIES;
|
|
1191
1030
|
}, [categories]);
|
|
1192
1031
|
useDeveloperGuidance(finalCategoriesConfig, disableDeveloperGuidance);
|
|
1193
|
-
const boot =
|
|
1032
|
+
const boot = React4.useMemo(() => {
|
|
1194
1033
|
if (initialState) return { ...initialState, isModalOpen: false };
|
|
1195
1034
|
return createFullConsentState(
|
|
1196
1035
|
false,
|
|
@@ -1200,9 +1039,9 @@ function ConsentProvider({
|
|
|
1200
1039
|
false
|
|
1201
1040
|
);
|
|
1202
1041
|
}, [initialState, finalCategoriesConfig]);
|
|
1203
|
-
const [state, dispatch] =
|
|
1204
|
-
const [isHydrated, setIsHydrated] =
|
|
1205
|
-
|
|
1042
|
+
const [state, dispatch] = React4.useReducer(reducer, boot);
|
|
1043
|
+
const [isHydrated, setIsHydrated] = React4.useState(false);
|
|
1044
|
+
React4.useEffect(() => {
|
|
1206
1045
|
if (!initialState) {
|
|
1207
1046
|
const saved = readConsentCookie(cookie.name);
|
|
1208
1047
|
if (saved?.consented) {
|
|
@@ -1215,17 +1054,17 @@ function ConsentProvider({
|
|
|
1215
1054
|
}
|
|
1216
1055
|
setIsHydrated(true);
|
|
1217
1056
|
}, [cookie.name, initialState, finalCategoriesConfig]);
|
|
1218
|
-
|
|
1057
|
+
React4.useEffect(() => {
|
|
1219
1058
|
if (state.consented) writeConsentCookie(state, finalCategoriesConfig, cookie);
|
|
1220
1059
|
}, [state, cookie, finalCategoriesConfig]);
|
|
1221
|
-
const prevConsented =
|
|
1222
|
-
|
|
1060
|
+
const prevConsented = React4.useRef(state.consented);
|
|
1061
|
+
React4.useEffect(() => {
|
|
1223
1062
|
if (!prevConsented.current && state.consented && onConsentGiven) {
|
|
1224
1063
|
setTimeout(() => onConsentGiven(state), 150);
|
|
1225
1064
|
}
|
|
1226
1065
|
prevConsented.current = state.consented;
|
|
1227
1066
|
}, [state, onConsentGiven]);
|
|
1228
|
-
const api =
|
|
1067
|
+
const api = React4.useMemo(() => {
|
|
1229
1068
|
const acceptAll = () => dispatch({ type: "ACCEPT_ALL", config: finalCategoriesConfig });
|
|
1230
1069
|
const rejectAll = () => dispatch({ type: "REJECT_ALL", config: finalCategoriesConfig });
|
|
1231
1070
|
const setPreference = (category, value) => dispatch({ type: "SET_CATEGORY", category, value });
|
|
@@ -1258,24 +1097,24 @@ function ConsentProvider({
|
|
|
1258
1097
|
resetConsent
|
|
1259
1098
|
};
|
|
1260
1099
|
}, [state, cookie, finalCategoriesConfig, onPreferencesSaved]);
|
|
1261
|
-
|
|
1100
|
+
React4.useEffect(() => {
|
|
1262
1101
|
_registerGlobalOpenPreferences(api.openPreferences);
|
|
1263
1102
|
return () => _unregisterGlobalOpenPreferences();
|
|
1264
1103
|
}, [api.openPreferences]);
|
|
1265
|
-
const providerBackdropColor =
|
|
1104
|
+
const providerBackdropColor = React4.useMemo(() => {
|
|
1266
1105
|
const backdrop = designTokens?.layout?.backdrop;
|
|
1267
1106
|
if (backdrop === false) return "transparent";
|
|
1268
1107
|
if (typeof backdrop === "string") return backdrop;
|
|
1269
1108
|
return "rgba(0, 0, 0, 0.4)";
|
|
1270
1109
|
}, [designTokens]);
|
|
1271
|
-
|
|
1110
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StateCtx.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ActionsCtx.Provider, { value: api, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TextsCtx.Provider, { value: texts, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HydrationCtx.Provider, { value: isHydrated, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DesignProvider, { tokens: designTokens, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1272
1111
|
CategoriesProvider,
|
|
1273
1112
|
{
|
|
1274
1113
|
config: finalCategoriesConfig,
|
|
1275
1114
|
disableDeveloperGuidance,
|
|
1276
1115
|
children: [
|
|
1277
1116
|
children,
|
|
1278
|
-
/* @__PURE__ */ (0,
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(React4.Suspense, { fallback: null, children: PreferencesModalComponent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1279
1118
|
PreferencesModalComponent,
|
|
1280
1119
|
{
|
|
1281
1120
|
preferences: api.preferences,
|
|
@@ -1285,8 +1124,8 @@ function ConsentProvider({
|
|
|
1285
1124
|
texts,
|
|
1286
1125
|
...preferencesModalProps
|
|
1287
1126
|
}
|
|
1288
|
-
) : /* @__PURE__ */ (0,
|
|
1289
|
-
blocking && isHydrated && !state.consented && blockingStrategy === "provider" && /* @__PURE__ */ (0,
|
|
1127
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PreferencesModal, { hideBranding }) }),
|
|
1128
|
+
blocking && isHydrated && !state.consented && blockingStrategy === "provider" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1290
1129
|
"div",
|
|
1291
1130
|
{
|
|
1292
1131
|
style: {
|
|
@@ -1302,7 +1141,7 @@ function ConsentProvider({
|
|
|
1302
1141
|
"aria-hidden": true
|
|
1303
1142
|
}
|
|
1304
1143
|
),
|
|
1305
|
-
!state.consented && isHydrated && (CookieBannerComponent ? /* @__PURE__ */ (0,
|
|
1144
|
+
!state.consented && isHydrated && (CookieBannerComponent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1306
1145
|
CookieBannerComponent,
|
|
1307
1146
|
{
|
|
1308
1147
|
consented: api.consented,
|
|
@@ -1313,7 +1152,7 @@ function ConsentProvider({
|
|
|
1313
1152
|
blocking,
|
|
1314
1153
|
...cookieBannerProps
|
|
1315
1154
|
}
|
|
1316
|
-
) : /* @__PURE__ */ (0,
|
|
1155
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1317
1156
|
CookieBanner,
|
|
1318
1157
|
{
|
|
1319
1158
|
blocking,
|
|
@@ -1321,7 +1160,7 @@ function ConsentProvider({
|
|
|
1321
1160
|
...cookieBannerProps
|
|
1322
1161
|
}
|
|
1323
1162
|
)),
|
|
1324
|
-
state.consented && !disableFloatingPreferencesButton && (FloatingPreferencesButtonComponent ? /* @__PURE__ */ (0,
|
|
1163
|
+
state.consented && !disableFloatingPreferencesButton && (FloatingPreferencesButtonComponent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1325
1164
|
FloatingPreferencesButtonComponent,
|
|
1326
1165
|
{
|
|
1327
1166
|
openPreferences: api.openPreferences,
|
|
@@ -1330,38 +1169,41 @@ function ConsentProvider({
|
|
|
1330
1169
|
}
|
|
1331
1170
|
) : (
|
|
1332
1171
|
// Encaminha `floatingPreferencesButtonProps` para o componente padrão
|
|
1333
|
-
/* @__PURE__ */ (0,
|
|
1172
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FloatingPreferencesButton, { ...floatingPreferencesButtonProps })
|
|
1334
1173
|
))
|
|
1335
1174
|
]
|
|
1336
1175
|
}
|
|
1337
|
-
) }) }) }) }) })
|
|
1176
|
+
) }) }) }) }) });
|
|
1177
|
+
if (theme) {
|
|
1178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_styles2.ThemeProvider, { theme: mergedTheme, children: content });
|
|
1179
|
+
}
|
|
1180
|
+
return content;
|
|
1338
1181
|
}
|
|
1339
1182
|
function useConsentStateInternal() {
|
|
1340
|
-
const ctx =
|
|
1183
|
+
const ctx = React4.useContext(StateCtx);
|
|
1341
1184
|
if (!ctx) throw new Error("useConsentState must be used within ConsentProvider");
|
|
1342
1185
|
return ctx;
|
|
1343
1186
|
}
|
|
1344
1187
|
function useConsentActionsInternal() {
|
|
1345
|
-
const ctx =
|
|
1188
|
+
const ctx = React4.useContext(ActionsCtx);
|
|
1346
1189
|
if (!ctx) throw new Error("useConsentActions must be used within ConsentProvider");
|
|
1347
1190
|
return ctx;
|
|
1348
1191
|
}
|
|
1349
1192
|
function useConsentTextsInternal() {
|
|
1350
|
-
const ctx =
|
|
1193
|
+
const ctx = React4.useContext(TextsCtx);
|
|
1351
1194
|
return ctx;
|
|
1352
1195
|
}
|
|
1353
1196
|
function useConsentHydrationInternal() {
|
|
1354
|
-
return
|
|
1197
|
+
return React4.useContext(HydrationCtx);
|
|
1355
1198
|
}
|
|
1356
|
-
var
|
|
1199
|
+
var React4, import_styles2, import_jsx_runtime6, PreferencesModal, DEFAULT_TEXTS, StateCtx, ActionsCtx, TextsCtx, HydrationCtx, defaultTexts;
|
|
1357
1200
|
var init_ConsentContext = __esm({
|
|
1358
1201
|
"src/context/ConsentContext.tsx"() {
|
|
1359
1202
|
"use strict";
|
|
1360
|
-
|
|
1361
|
-
|
|
1203
|
+
React4 = __toESM(require("react"), 1);
|
|
1204
|
+
import_styles2 = require("@mui/material/styles");
|
|
1362
1205
|
init_cookieUtils();
|
|
1363
1206
|
init_categoryUtils();
|
|
1364
|
-
init_theme();
|
|
1365
1207
|
init_CategoriesContext();
|
|
1366
1208
|
init_DesignContext();
|
|
1367
1209
|
init_developerGuidance();
|
|
@@ -1369,8 +1211,8 @@ var init_ConsentContext = __esm({
|
|
|
1369
1211
|
init_logger();
|
|
1370
1212
|
init_CookieBanner();
|
|
1371
1213
|
init_FloatingPreferencesButton();
|
|
1372
|
-
|
|
1373
|
-
PreferencesModal =
|
|
1214
|
+
import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1215
|
+
PreferencesModal = React4.lazy(
|
|
1374
1216
|
() => Promise.resolve().then(() => (init_PreferencesModal(), PreferencesModal_exports)).then((m) => ({
|
|
1375
1217
|
default: m.PreferencesModal
|
|
1376
1218
|
}))
|
|
@@ -1412,10 +1254,10 @@ var init_ConsentContext = __esm({
|
|
|
1412
1254
|
transferCountries: void 0
|
|
1413
1255
|
// Exibido se definido
|
|
1414
1256
|
};
|
|
1415
|
-
StateCtx =
|
|
1416
|
-
ActionsCtx =
|
|
1417
|
-
TextsCtx =
|
|
1418
|
-
HydrationCtx =
|
|
1257
|
+
StateCtx = React4.createContext(null);
|
|
1258
|
+
ActionsCtx = React4.createContext(null);
|
|
1259
|
+
TextsCtx = React4.createContext(DEFAULT_TEXTS);
|
|
1260
|
+
HydrationCtx = React4.createContext(false);
|
|
1419
1261
|
defaultTexts = DEFAULT_TEXTS;
|
|
1420
1262
|
}
|
|
1421
1263
|
});
|
|
@@ -1509,8 +1351,8 @@ function PreferencesModal2({
|
|
|
1509
1351
|
setTempPreferences(preferences);
|
|
1510
1352
|
closePreferences();
|
|
1511
1353
|
};
|
|
1512
|
-
return /* @__PURE__ */ (0,
|
|
1513
|
-
/* @__PURE__ */ (0,
|
|
1354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_Dialog.default, { "aria-labelledby": "cookie-pref-title", open, onClose: handleCancel, ...DialogProps2, children: [
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1514
1356
|
import_DialogTitle.default,
|
|
1515
1357
|
{
|
|
1516
1358
|
id: "cookie-pref-title",
|
|
@@ -1518,8 +1360,8 @@ function PreferencesModal2({
|
|
|
1518
1360
|
children: texts.modalTitle
|
|
1519
1361
|
}
|
|
1520
1362
|
),
|
|
1521
|
-
/* @__PURE__ */ (0,
|
|
1522
|
-
/* @__PURE__ */ (0,
|
|
1363
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_DialogContent.default, { dividers: true, sx: { p: designTokens?.spacing?.padding?.modal ?? void 0 }, children: [
|
|
1364
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1523
1365
|
import_Typography3.default,
|
|
1524
1366
|
{
|
|
1525
1367
|
variant: "body2",
|
|
@@ -1527,11 +1369,11 @@ function PreferencesModal2({
|
|
|
1527
1369
|
children: texts.modalIntro
|
|
1528
1370
|
}
|
|
1529
1371
|
),
|
|
1530
|
-
/* @__PURE__ */ (0,
|
|
1531
|
-
toggleableCategories.map((category) => /* @__PURE__ */ (0,
|
|
1372
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_FormGroup.default, { children: [
|
|
1373
|
+
toggleableCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1532
1374
|
import_FormControlLabel.default,
|
|
1533
1375
|
{
|
|
1534
|
-
control: /* @__PURE__ */ (0,
|
|
1376
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1535
1377
|
import_Switch.default,
|
|
1536
1378
|
{
|
|
1537
1379
|
checked: tempPreferences[category.id] ?? false,
|
|
@@ -1545,17 +1387,17 @@ function PreferencesModal2({
|
|
|
1545
1387
|
},
|
|
1546
1388
|
category.id
|
|
1547
1389
|
)),
|
|
1548
|
-
/* @__PURE__ */ (0,
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_FormControlLabel.default, { control: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Switch.default, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn })
|
|
1549
1391
|
] })
|
|
1550
1392
|
] }),
|
|
1551
|
-
/* @__PURE__ */ (0,
|
|
1552
|
-
/* @__PURE__ */ (0,
|
|
1553
|
-
/* @__PURE__ */ (0,
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_DialogActions.default, { children: [
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Button2.default, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Button2.default, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
1554
1396
|
] }),
|
|
1555
|
-
!hideBranding && /* @__PURE__ */ (0,
|
|
1397
|
+
!hideBranding && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Branding, { variant: "modal" })
|
|
1556
1398
|
] });
|
|
1557
1399
|
}
|
|
1558
|
-
var import_Button2, import_Dialog, import_DialogActions, import_DialogContent, import_DialogTitle, import_FormControlLabel, import_FormGroup, import_Switch, import_Typography3, import_react2,
|
|
1400
|
+
var import_Button2, import_Dialog, import_DialogActions, import_DialogContent, import_DialogTitle, import_FormControlLabel, import_FormGroup, import_Switch, import_Typography3, import_react2, import_jsx_runtime7;
|
|
1559
1401
|
var init_PreferencesModal = __esm({
|
|
1560
1402
|
"src/components/PreferencesModal.tsx"() {
|
|
1561
1403
|
"use strict";
|
|
@@ -1573,7 +1415,7 @@ var init_PreferencesModal = __esm({
|
|
|
1573
1415
|
init_useConsent();
|
|
1574
1416
|
init_DesignContext();
|
|
1575
1417
|
init_Branding();
|
|
1576
|
-
|
|
1418
|
+
import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1577
1419
|
}
|
|
1578
1420
|
});
|
|
1579
1421
|
|
|
@@ -1590,6 +1432,7 @@ __export(index_exports, {
|
|
|
1590
1432
|
LogLevel: () => LogLevel,
|
|
1591
1433
|
PreferencesModal: () => PreferencesModal2,
|
|
1592
1434
|
analyzeDeveloperConfiguration: () => analyzeDeveloperConfiguration,
|
|
1435
|
+
createDefaultConsentTheme: () => createDefaultConsentTheme,
|
|
1593
1436
|
createGoogleAnalyticsIntegration: () => createGoogleAnalyticsIntegration,
|
|
1594
1437
|
createGoogleTagManagerIntegration: () => createGoogleTagManagerIntegration,
|
|
1595
1438
|
createProjectPreferences: () => createProjectPreferences,
|
|
@@ -1617,11 +1460,11 @@ init_CategoriesContext();
|
|
|
1617
1460
|
|
|
1618
1461
|
// src/utils/ConsentGate.tsx
|
|
1619
1462
|
init_useConsent();
|
|
1620
|
-
var
|
|
1463
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1621
1464
|
function ConsentGate(props) {
|
|
1622
1465
|
const { preferences } = useConsent();
|
|
1623
1466
|
if (!preferences[props.category]) return null;
|
|
1624
|
-
return /* @__PURE__ */ (0,
|
|
1467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: props.children });
|
|
1625
1468
|
}
|
|
1626
1469
|
|
|
1627
1470
|
// src/utils/scriptLoader.ts
|
|
@@ -1661,11 +1504,79 @@ function loadScript(id, src, category = null, attrs = {}) {
|
|
|
1661
1504
|
});
|
|
1662
1505
|
}
|
|
1663
1506
|
|
|
1664
|
-
// src/
|
|
1665
|
-
|
|
1507
|
+
// src/utils/theme.ts
|
|
1508
|
+
var import_styles3 = require("@mui/material/styles");
|
|
1509
|
+
function createDefaultConsentTheme() {
|
|
1510
|
+
return (0, import_styles3.createTheme)({
|
|
1511
|
+
palette: {
|
|
1512
|
+
primary: {
|
|
1513
|
+
main: "#1976d2",
|
|
1514
|
+
contrastText: "#ffffff"
|
|
1515
|
+
},
|
|
1516
|
+
secondary: {
|
|
1517
|
+
main: "#dc004e",
|
|
1518
|
+
contrastText: "#ffffff"
|
|
1519
|
+
},
|
|
1520
|
+
background: {
|
|
1521
|
+
default: "#fafafa",
|
|
1522
|
+
paper: "#ffffff"
|
|
1523
|
+
},
|
|
1524
|
+
text: {
|
|
1525
|
+
primary: "#333333",
|
|
1526
|
+
secondary: "#666666"
|
|
1527
|
+
},
|
|
1528
|
+
action: {
|
|
1529
|
+
hover: "rgba(25, 118, 210, 0.04)"
|
|
1530
|
+
}
|
|
1531
|
+
},
|
|
1532
|
+
typography: {
|
|
1533
|
+
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
|
1534
|
+
body2: {
|
|
1535
|
+
fontSize: "0.875rem",
|
|
1536
|
+
lineHeight: 1.43
|
|
1537
|
+
},
|
|
1538
|
+
button: {
|
|
1539
|
+
fontWeight: 500,
|
|
1540
|
+
textTransform: "none"
|
|
1541
|
+
}
|
|
1542
|
+
},
|
|
1543
|
+
components: {
|
|
1544
|
+
MuiButton: {
|
|
1545
|
+
styleOverrides: {
|
|
1546
|
+
root: {
|
|
1547
|
+
borderRadius: 8,
|
|
1548
|
+
paddingX: 16,
|
|
1549
|
+
paddingY: 8
|
|
1550
|
+
},
|
|
1551
|
+
contained: {
|
|
1552
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
1553
|
+
"&:hover": {
|
|
1554
|
+
boxShadow: "0 4px 8px rgba(0,0,0,0.15)"
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
MuiPaper: {
|
|
1560
|
+
styleOverrides: {
|
|
1561
|
+
root: {
|
|
1562
|
+
borderRadius: 12
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
},
|
|
1566
|
+
MuiDialog: {
|
|
1567
|
+
styleOverrides: {
|
|
1568
|
+
paper: {
|
|
1569
|
+
borderRadius: 16
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
var defaultConsentTheme = () => createDefaultConsentTheme();
|
|
1666
1577
|
|
|
1667
1578
|
// src/utils/ConsentScriptLoader.tsx
|
|
1668
|
-
var
|
|
1579
|
+
var React5 = __toESM(require("react"), 1);
|
|
1669
1580
|
init_useConsent();
|
|
1670
1581
|
init_logger();
|
|
1671
1582
|
function ConsentScriptLoader({
|
|
@@ -1673,8 +1584,8 @@ function ConsentScriptLoader({
|
|
|
1673
1584
|
reloadOnChange = false
|
|
1674
1585
|
}) {
|
|
1675
1586
|
const { preferences, consented } = useConsent();
|
|
1676
|
-
const loadedScripts =
|
|
1677
|
-
|
|
1587
|
+
const loadedScripts = React5.useRef(/* @__PURE__ */ new Set());
|
|
1588
|
+
React5.useEffect(() => {
|
|
1678
1589
|
if (!consented) return;
|
|
1679
1590
|
integrations.forEach(async (integration) => {
|
|
1680
1591
|
const shouldLoad = preferences[integration.category];
|
|
@@ -1702,7 +1613,7 @@ function ConsentScriptLoader({
|
|
|
1702
1613
|
}
|
|
1703
1614
|
function useConsentScriptLoader() {
|
|
1704
1615
|
const { preferences, consented } = useConsent();
|
|
1705
|
-
return
|
|
1616
|
+
return React5.useCallback(
|
|
1706
1617
|
async (integration) => {
|
|
1707
1618
|
if (!consented) {
|
|
1708
1619
|
logger.warn(`\u26A0\uFE0F Cannot load script ${integration.id}: No consent given`);
|
|
@@ -1813,6 +1724,7 @@ init_categoryUtils();
|
|
|
1813
1724
|
LogLevel,
|
|
1814
1725
|
PreferencesModal,
|
|
1815
1726
|
analyzeDeveloperConfiguration,
|
|
1727
|
+
createDefaultConsentTheme,
|
|
1816
1728
|
createGoogleAnalyticsIntegration,
|
|
1817
1729
|
createGoogleTagManagerIntegration,
|
|
1818
1730
|
createProjectPreferences,
|