@react-lgpd-consent/mui 0.5.0
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/LICENSE +21 -0
- package/README.md +138 -0
- package/dist/index.cjs +597 -0
- package/dist/index.d.cts +469 -0
- package/dist/index.d.ts +469 -0
- package/dist/index.js +544 -0
- package/package.json +73 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@react-lgpd-consent/core');
|
|
4
|
+
var Link = require('@mui/material/Link');
|
|
5
|
+
var Typography = require('@mui/material/Typography');
|
|
6
|
+
var React3 = require('react');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var styles = require('@mui/material/styles');
|
|
9
|
+
var Box2 = require('@mui/material/Box');
|
|
10
|
+
var Button = require('@mui/material/Button');
|
|
11
|
+
var Paper = require('@mui/material/Paper');
|
|
12
|
+
var Snackbar = require('@mui/material/Snackbar');
|
|
13
|
+
var Stack = require('@mui/material/Stack');
|
|
14
|
+
var CookieOutlined = require('@mui/icons-material/CookieOutlined');
|
|
15
|
+
var Fab = require('@mui/material/Fab');
|
|
16
|
+
var Tooltip = require('@mui/material/Tooltip');
|
|
17
|
+
var Dialog = require('@mui/material/Dialog');
|
|
18
|
+
var DialogActions = require('@mui/material/DialogActions');
|
|
19
|
+
var DialogContent = require('@mui/material/DialogContent');
|
|
20
|
+
var DialogTitle = require('@mui/material/DialogTitle');
|
|
21
|
+
var FormControlLabel = require('@mui/material/FormControlLabel');
|
|
22
|
+
var FormGroup = require('@mui/material/FormGroup');
|
|
23
|
+
var Switch = require('@mui/material/Switch');
|
|
24
|
+
|
|
25
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
|
+
|
|
27
|
+
function _interopNamespace(e) {
|
|
28
|
+
if (e && e.__esModule) return e;
|
|
29
|
+
var n = Object.create(null);
|
|
30
|
+
if (e) {
|
|
31
|
+
Object.keys(e).forEach(function (k) {
|
|
32
|
+
if (k !== 'default') {
|
|
33
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
34
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return e[k]; }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
n.default = e;
|
|
42
|
+
return Object.freeze(n);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
46
|
+
var Typography__default = /*#__PURE__*/_interopDefault(Typography);
|
|
47
|
+
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
48
|
+
var Box2__default = /*#__PURE__*/_interopDefault(Box2);
|
|
49
|
+
var Button__default = /*#__PURE__*/_interopDefault(Button);
|
|
50
|
+
var Paper__default = /*#__PURE__*/_interopDefault(Paper);
|
|
51
|
+
var Snackbar__default = /*#__PURE__*/_interopDefault(Snackbar);
|
|
52
|
+
var Stack__default = /*#__PURE__*/_interopDefault(Stack);
|
|
53
|
+
var CookieOutlined__default = /*#__PURE__*/_interopDefault(CookieOutlined);
|
|
54
|
+
var Fab__default = /*#__PURE__*/_interopDefault(Fab);
|
|
55
|
+
var Tooltip__default = /*#__PURE__*/_interopDefault(Tooltip);
|
|
56
|
+
var Dialog__default = /*#__PURE__*/_interopDefault(Dialog);
|
|
57
|
+
var DialogActions__default = /*#__PURE__*/_interopDefault(DialogActions);
|
|
58
|
+
var DialogContent__default = /*#__PURE__*/_interopDefault(DialogContent);
|
|
59
|
+
var DialogTitle__default = /*#__PURE__*/_interopDefault(DialogTitle);
|
|
60
|
+
var FormControlLabel__default = /*#__PURE__*/_interopDefault(FormControlLabel);
|
|
61
|
+
var FormGroup__default = /*#__PURE__*/_interopDefault(FormGroup);
|
|
62
|
+
var Switch__default = /*#__PURE__*/_interopDefault(Switch);
|
|
63
|
+
|
|
64
|
+
// @react-lgpd-consent/mui - proxy build
|
|
65
|
+
|
|
66
|
+
var brandingStyles = {
|
|
67
|
+
banner: {
|
|
68
|
+
fontSize: "0.65rem",
|
|
69
|
+
textAlign: "right",
|
|
70
|
+
mt: 1,
|
|
71
|
+
opacity: 0.7,
|
|
72
|
+
fontStyle: "italic",
|
|
73
|
+
width: "100%"
|
|
74
|
+
},
|
|
75
|
+
modal: {
|
|
76
|
+
fontSize: "0.65rem",
|
|
77
|
+
textAlign: "right",
|
|
78
|
+
px: 3,
|
|
79
|
+
pb: 1,
|
|
80
|
+
opacity: 0.7,
|
|
81
|
+
fontStyle: "italic",
|
|
82
|
+
width: "100%"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var linkStyles = {
|
|
86
|
+
textDecoration: "none",
|
|
87
|
+
fontWeight: 500,
|
|
88
|
+
"&:hover": {
|
|
89
|
+
textDecoration: "underline"
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var Branding = React3__namespace.memo(function Branding2({
|
|
93
|
+
variant,
|
|
94
|
+
hidden = false
|
|
95
|
+
}) {
|
|
96
|
+
const texts = core.useConsentTexts();
|
|
97
|
+
const designTokens = core.useDesignTokens();
|
|
98
|
+
if (hidden) return null;
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
100
|
+
Typography__default.default,
|
|
101
|
+
{
|
|
102
|
+
variant: "caption",
|
|
103
|
+
sx: (theme) => ({
|
|
104
|
+
...brandingStyles[variant],
|
|
105
|
+
color: designTokens?.colors?.text ?? theme.palette.text.secondary
|
|
106
|
+
}),
|
|
107
|
+
children: [
|
|
108
|
+
texts.brandingPoweredBy || "fornecido por",
|
|
109
|
+
" ",
|
|
110
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
111
|
+
Link__default.default,
|
|
112
|
+
{
|
|
113
|
+
href: "https://www.ledipo.eti.br",
|
|
114
|
+
target: "_blank",
|
|
115
|
+
rel: "noopener noreferrer",
|
|
116
|
+
sx: (theme) => ({
|
|
117
|
+
...linkStyles,
|
|
118
|
+
color: designTokens?.colors?.primary ?? theme.palette.primary.main
|
|
119
|
+
}),
|
|
120
|
+
children: "L\xC9dipO.eti.br"
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
function CookieBanner({
|
|
128
|
+
policyLinkUrl,
|
|
129
|
+
termsLinkUrl,
|
|
130
|
+
debug,
|
|
131
|
+
blocking = true,
|
|
132
|
+
hideBranding = false,
|
|
133
|
+
SnackbarProps,
|
|
134
|
+
PaperProps
|
|
135
|
+
}) {
|
|
136
|
+
const { consented, acceptAll, rejectAll, openPreferences } = core.useConsent();
|
|
137
|
+
const texts = core.useConsentTexts();
|
|
138
|
+
const isHydrated = core.useConsentHydration();
|
|
139
|
+
const designTokens = core.useDesignTokens();
|
|
140
|
+
const open = debug ? true : isHydrated && !consented;
|
|
141
|
+
core.logger.componentRender("CookieBanner", {
|
|
142
|
+
open,
|
|
143
|
+
consented,
|
|
144
|
+
isHydrated,
|
|
145
|
+
blocking,
|
|
146
|
+
hideBranding
|
|
147
|
+
});
|
|
148
|
+
if (!open) return null;
|
|
149
|
+
const bannerStyle = (theme) => ({
|
|
150
|
+
p: designTokens?.spacing?.padding?.banner ?? 2,
|
|
151
|
+
maxWidth: 720,
|
|
152
|
+
mx: "auto",
|
|
153
|
+
backgroundColor: designTokens?.colors?.background ?? theme.palette.background?.paper,
|
|
154
|
+
color: designTokens?.colors?.text ?? theme.palette.text?.primary,
|
|
155
|
+
borderRadius: designTokens?.spacing?.borderRadius?.banner,
|
|
156
|
+
fontFamily: designTokens?.typography?.fontFamily
|
|
157
|
+
});
|
|
158
|
+
const bannerContent = /* @__PURE__ */ jsxRuntime.jsx(Paper__default.default, { elevation: 3, sx: bannerStyle, ...PaperProps, children: /* @__PURE__ */ jsxRuntime.jsxs(Stack__default.default, { spacing: 1, children: [
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Typography__default.default, { variant: "body2", sx: { fontSize: designTokens?.typography?.fontSize?.banner }, children: [
|
|
160
|
+
texts.bannerMessage,
|
|
161
|
+
" ",
|
|
162
|
+
policyLinkUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
163
|
+
Link__default.default,
|
|
164
|
+
{
|
|
165
|
+
href: policyLinkUrl,
|
|
166
|
+
underline: "hover",
|
|
167
|
+
target: "_blank",
|
|
168
|
+
rel: "noopener noreferrer",
|
|
169
|
+
sx: { color: designTokens?.colors?.primary },
|
|
170
|
+
children: texts.policyLink ?? "Saiba mais"
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Stack__default.default, { direction: { xs: "column", sm: "row" }, spacing: 1, justifyContent: "flex-end", children: [
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
176
|
+
Button__default.default,
|
|
177
|
+
{
|
|
178
|
+
variant: "outlined",
|
|
179
|
+
onClick: () => {
|
|
180
|
+
core.logger.apiUsage("rejectAll", { source: "banner" });
|
|
181
|
+
rejectAll();
|
|
182
|
+
},
|
|
183
|
+
sx: { color: designTokens?.colors?.secondary },
|
|
184
|
+
children: texts.declineAll
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
+
Button__default.default,
|
|
189
|
+
{
|
|
190
|
+
variant: "contained",
|
|
191
|
+
onClick: () => {
|
|
192
|
+
core.logger.apiUsage("acceptAll", { source: "banner" });
|
|
193
|
+
acceptAll();
|
|
194
|
+
},
|
|
195
|
+
sx: { backgroundColor: designTokens?.colors?.primary },
|
|
196
|
+
children: texts.acceptAll
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
200
|
+
Button__default.default,
|
|
201
|
+
{
|
|
202
|
+
variant: "text",
|
|
203
|
+
onClick: () => {
|
|
204
|
+
core.logger.apiUsage("openPreferences", { source: "banner" });
|
|
205
|
+
openPreferences();
|
|
206
|
+
},
|
|
207
|
+
sx: { color: designTokens?.colors?.text },
|
|
208
|
+
children: texts.preferences
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
] }),
|
|
212
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "banner" })
|
|
213
|
+
] }) });
|
|
214
|
+
const positionStyle = {
|
|
215
|
+
position: "fixed",
|
|
216
|
+
zIndex: 1300,
|
|
217
|
+
...designTokens?.layout?.position === "top" ? { top: 0 } : { bottom: 0 },
|
|
218
|
+
left: 0,
|
|
219
|
+
right: 0,
|
|
220
|
+
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
221
|
+
p: 2
|
|
222
|
+
};
|
|
223
|
+
const backdropToken = designTokens?.layout?.backdrop;
|
|
224
|
+
const resolveBackdropColor = (theme) => {
|
|
225
|
+
if (backdropToken === false) return "transparent";
|
|
226
|
+
if (typeof backdropToken === "string") {
|
|
227
|
+
if (backdropToken.toLowerCase() === "auto") {
|
|
228
|
+
const isDark2 = theme?.palette?.mode === "dark";
|
|
229
|
+
return isDark2 ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.4)";
|
|
230
|
+
}
|
|
231
|
+
return backdropToken;
|
|
232
|
+
}
|
|
233
|
+
const isDark = theme?.palette?.mode === "dark";
|
|
234
|
+
return isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.4)";
|
|
235
|
+
};
|
|
236
|
+
const isSafeRoute = (() => {
|
|
237
|
+
try {
|
|
238
|
+
if (typeof window === "undefined") return false;
|
|
239
|
+
const current = new URL(window.location.href);
|
|
240
|
+
const safeUrls = [policyLinkUrl, termsLinkUrl].filter(Boolean);
|
|
241
|
+
return safeUrls.some((u) => {
|
|
242
|
+
try {
|
|
243
|
+
const target = new URL(u, current.origin);
|
|
244
|
+
return target.pathname === current.pathname;
|
|
245
|
+
} catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
} catch {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
})();
|
|
253
|
+
const effectiveBlocking = blocking && !isSafeRoute;
|
|
254
|
+
if (effectiveBlocking) {
|
|
255
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
256
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
+
Box2__default.default,
|
|
258
|
+
{
|
|
259
|
+
sx: (theme) => ({
|
|
260
|
+
position: "fixed",
|
|
261
|
+
top: 0,
|
|
262
|
+
left: 0,
|
|
263
|
+
right: 0,
|
|
264
|
+
bottom: 0,
|
|
265
|
+
backgroundColor: resolveBackdropColor(theme),
|
|
266
|
+
zIndex: 1299
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: positionStyle, children: bannerContent })
|
|
271
|
+
] });
|
|
272
|
+
}
|
|
273
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
274
|
+
Snackbar__default.default,
|
|
275
|
+
{
|
|
276
|
+
open,
|
|
277
|
+
anchorOrigin: {
|
|
278
|
+
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
279
|
+
horizontal: "center"
|
|
280
|
+
},
|
|
281
|
+
...SnackbarProps,
|
|
282
|
+
children: bannerContent
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function useThemeWithFallbacks() {
|
|
287
|
+
const theme = styles.useTheme();
|
|
288
|
+
core.logger.themeCompatibility(theme);
|
|
289
|
+
return {
|
|
290
|
+
palette: {
|
|
291
|
+
primary: {
|
|
292
|
+
main: theme?.palette?.primary?.main || "#1976d2",
|
|
293
|
+
dark: theme?.palette?.primary?.dark || "#1565c0"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
transitions: {
|
|
297
|
+
duration: {
|
|
298
|
+
shortest: theme?.transitions?.duration?.shortest || 150,
|
|
299
|
+
short: theme?.transitions?.duration?.short || 250
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
var FloatingPreferencesButton = React3__namespace.memo(function FloatingPreferencesButton2({
|
|
305
|
+
position = "bottom-right",
|
|
306
|
+
offset = 24,
|
|
307
|
+
icon = /* @__PURE__ */ jsxRuntime.jsx(CookieOutlined__default.default, {}),
|
|
308
|
+
tooltip,
|
|
309
|
+
FabProps,
|
|
310
|
+
hideWhenConsented = false
|
|
311
|
+
}) {
|
|
312
|
+
const { openPreferences, consented } = core.useConsent();
|
|
313
|
+
const texts = core.useConsentTexts();
|
|
314
|
+
const safeTheme = useThemeWithFallbacks();
|
|
315
|
+
const designTokens = core.useDesignTokens();
|
|
316
|
+
const positionStyles = React3__namespace.useMemo(() => {
|
|
317
|
+
const styles = {
|
|
318
|
+
position: "fixed",
|
|
319
|
+
zIndex: 1200
|
|
320
|
+
};
|
|
321
|
+
switch (position) {
|
|
322
|
+
case "bottom-left":
|
|
323
|
+
return { ...styles, bottom: offset, left: offset };
|
|
324
|
+
case "bottom-right":
|
|
325
|
+
return { ...styles, bottom: offset, right: offset };
|
|
326
|
+
case "top-left":
|
|
327
|
+
return { ...styles, top: offset, left: offset };
|
|
328
|
+
case "top-right":
|
|
329
|
+
return { ...styles, top: offset, right: offset };
|
|
330
|
+
default:
|
|
331
|
+
return { ...styles, bottom: offset, right: offset };
|
|
332
|
+
}
|
|
333
|
+
}, [position, offset]);
|
|
334
|
+
core.logger.componentRender("FloatingPreferencesButton", {
|
|
335
|
+
position,
|
|
336
|
+
offset,
|
|
337
|
+
hideWhenConsented,
|
|
338
|
+
consented
|
|
339
|
+
});
|
|
340
|
+
if (hideWhenConsented && consented) {
|
|
341
|
+
core.logger.debug(
|
|
342
|
+
"FloatingPreferencesButton: Hidden due to hideWhenConsented=true and consented=true"
|
|
343
|
+
);
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
const tooltipText = tooltip ?? texts.preferencesButton ?? "Gerenciar Prefer\xEAncias de Cookies";
|
|
347
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tooltip__default.default, { title: tooltipText, placement: "top", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
348
|
+
Fab__default.default,
|
|
349
|
+
{
|
|
350
|
+
size: "medium",
|
|
351
|
+
color: "primary",
|
|
352
|
+
onClick: openPreferences,
|
|
353
|
+
sx: {
|
|
354
|
+
...positionStyles,
|
|
355
|
+
backgroundColor: designTokens?.colors?.primary ?? safeTheme.palette.primary.main,
|
|
356
|
+
"&:hover": {
|
|
357
|
+
backgroundColor: designTokens?.colors?.primary ? designTokens?.colors?.primary : safeTheme.palette.primary.dark
|
|
358
|
+
},
|
|
359
|
+
transition: `all ${safeTheme.transitions.duration.short}ms`
|
|
360
|
+
},
|
|
361
|
+
"aria-label": tooltipText,
|
|
362
|
+
...FabProps,
|
|
363
|
+
children: icon
|
|
364
|
+
}
|
|
365
|
+
) });
|
|
366
|
+
});
|
|
367
|
+
function PreferencesModal({
|
|
368
|
+
DialogProps: DialogProps2,
|
|
369
|
+
hideBranding = false,
|
|
370
|
+
isModalOpen: isModalOpenProp,
|
|
371
|
+
preferences: preferencesProp,
|
|
372
|
+
setPreferences: setPreferencesProp,
|
|
373
|
+
closePreferences: closePreferencesProp
|
|
374
|
+
}) {
|
|
375
|
+
const hookValue = core.useConsent();
|
|
376
|
+
const preferences = preferencesProp ?? hookValue.preferences;
|
|
377
|
+
const setPreferences = setPreferencesProp ?? hookValue.setPreferences;
|
|
378
|
+
const closePreferences = closePreferencesProp ?? hookValue.closePreferences;
|
|
379
|
+
const isModalOpen = isModalOpenProp ?? hookValue.isModalOpen;
|
|
380
|
+
const texts = core.useConsentTexts();
|
|
381
|
+
const designTokens = core.useDesignTokens();
|
|
382
|
+
const { toggleableCategories, allCategories } = core.useCategories();
|
|
383
|
+
const getInitialPreferences = React3__namespace.useCallback(() => {
|
|
384
|
+
const syncedPrefs = { necessary: true };
|
|
385
|
+
toggleableCategories.forEach((category) => {
|
|
386
|
+
syncedPrefs[category.id] = preferences[category.id] ?? false;
|
|
387
|
+
});
|
|
388
|
+
return syncedPrefs;
|
|
389
|
+
}, [preferences, toggleableCategories]);
|
|
390
|
+
const [tempPreferences, setTempPreferences] = React3__namespace.useState(getInitialPreferences);
|
|
391
|
+
const wasOpenRef = React3__namespace.useRef(isModalOpen);
|
|
392
|
+
React3__namespace.useEffect(() => {
|
|
393
|
+
const justOpened = isModalOpen && !wasOpenRef.current;
|
|
394
|
+
wasOpenRef.current = isModalOpen;
|
|
395
|
+
if (justOpened) {
|
|
396
|
+
queueMicrotask(() => {
|
|
397
|
+
setTempPreferences(getInitialPreferences());
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}, [isModalOpen, getInitialPreferences]);
|
|
401
|
+
const open = DialogProps2?.open ?? isModalOpen ?? false;
|
|
402
|
+
const handleSave = () => {
|
|
403
|
+
setPreferences(tempPreferences);
|
|
404
|
+
};
|
|
405
|
+
const handleCancel = () => {
|
|
406
|
+
setTempPreferences(preferences);
|
|
407
|
+
closePreferences();
|
|
408
|
+
};
|
|
409
|
+
const modalTitleSx = (theme) => ({
|
|
410
|
+
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
411
|
+
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
412
|
+
});
|
|
413
|
+
const modalContentSx = (theme) => ({
|
|
414
|
+
p: designTokens?.spacing?.padding?.modal ?? void 0,
|
|
415
|
+
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
416
|
+
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
417
|
+
});
|
|
418
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Dialog__default.default, { "aria-labelledby": "cookie-pref-title", open, onClose: handleCancel, ...DialogProps2, children: [
|
|
419
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle__default.default, { id: "cookie-pref-title", sx: modalTitleSx, children: texts.modalTitle }),
|
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent__default.default, { dividers: true, sx: modalContentSx, children: [
|
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
422
|
+
Typography__default.default,
|
|
423
|
+
{
|
|
424
|
+
variant: "body2",
|
|
425
|
+
sx: (theme) => ({
|
|
426
|
+
mb: 2,
|
|
427
|
+
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
428
|
+
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
429
|
+
}),
|
|
430
|
+
children: texts.modalIntro
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FormGroup__default.default, { children: [
|
|
434
|
+
toggleableCategories.map((category) => {
|
|
435
|
+
const full = allCategories.find((c) => c.id === category.id);
|
|
436
|
+
const namesFromGuidance = full?.cookies ?? [];
|
|
437
|
+
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
438
|
+
const descriptors = core.getCookiesInfoForCategory(category.id, used);
|
|
439
|
+
const enrichedDescriptors = descriptors.map((desc) => {
|
|
440
|
+
if (desc.purpose && desc.duration && desc.provider) {
|
|
441
|
+
return desc;
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
name: desc.name,
|
|
445
|
+
purpose: desc.purpose || "-",
|
|
446
|
+
duration: desc.duration || "-",
|
|
447
|
+
provider: desc.provider || "-"
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
const merged = [
|
|
451
|
+
...enrichedDescriptors,
|
|
452
|
+
...namesFromGuidance.filter((n) => !enrichedDescriptors.find((d) => d.name === n)).map((n) => ({ name: n, purpose: "-", duration: "-", provider: "-" }))
|
|
453
|
+
];
|
|
454
|
+
let mergedFinal = merged;
|
|
455
|
+
try {
|
|
456
|
+
if (merged.length === 0) {
|
|
457
|
+
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
458
|
+
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
459
|
+
name: `(script) ${id}`,
|
|
460
|
+
purpose: "Script de integra\xE7\xE3o ativo",
|
|
461
|
+
duration: "-",
|
|
462
|
+
provider: "-"
|
|
463
|
+
}));
|
|
464
|
+
if (scriptRows.length > 0) mergedFinal = scriptRows;
|
|
465
|
+
}
|
|
466
|
+
} catch {
|
|
467
|
+
}
|
|
468
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Box2__default.default, { sx: { mb: 1 }, children: [
|
|
469
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
470
|
+
FormControlLabel__default.default,
|
|
471
|
+
{
|
|
472
|
+
control: /* @__PURE__ */ jsxRuntime.jsx(
|
|
473
|
+
Switch__default.default,
|
|
474
|
+
{
|
|
475
|
+
checked: tempPreferences[category.id] ?? false,
|
|
476
|
+
onChange: (e) => setTempPreferences((prev) => ({
|
|
477
|
+
...prev,
|
|
478
|
+
[category.id]: e.target.checked
|
|
479
|
+
}))
|
|
480
|
+
}
|
|
481
|
+
),
|
|
482
|
+
label: `${category.name} - ${category.description}`
|
|
483
|
+
}
|
|
484
|
+
),
|
|
485
|
+
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
486
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Ver detalhes" }),
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
488
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
489
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
490
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
491
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
493
|
+
] }) }),
|
|
494
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
495
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.name }),
|
|
496
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.purpose }),
|
|
497
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.duration }),
|
|
498
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.provider })
|
|
499
|
+
] }, d.name + idx)) })
|
|
500
|
+
] }) })
|
|
501
|
+
] })
|
|
502
|
+
] }, category.id);
|
|
503
|
+
}),
|
|
504
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControlLabel__default.default, { control: /* @__PURE__ */ jsxRuntime.jsx(Switch__default.default, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
505
|
+
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
506
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Ver detalhes" }),
|
|
507
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
508
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
509
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
510
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
511
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
512
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
513
|
+
] }) }),
|
|
514
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: (() => {
|
|
515
|
+
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
516
|
+
const necessaryCookies = core.getCookiesInfoForCategory(
|
|
517
|
+
"necessary",
|
|
518
|
+
used
|
|
519
|
+
);
|
|
520
|
+
return necessaryCookies.map((d, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
521
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.name }),
|
|
522
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.purpose || "-" }),
|
|
523
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.duration || "-" }),
|
|
524
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.provider || "-" })
|
|
525
|
+
] }, d.name + idx));
|
|
526
|
+
})() })
|
|
527
|
+
] }) })
|
|
528
|
+
] })
|
|
529
|
+
] })
|
|
530
|
+
] }),
|
|
531
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogActions__default.default, { children: [
|
|
532
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
533
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
534
|
+
] }),
|
|
535
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal" })
|
|
536
|
+
] });
|
|
537
|
+
}
|
|
538
|
+
function ConsentProvider({
|
|
539
|
+
disableDefaultModal = false,
|
|
540
|
+
disableDefaultBanner = false,
|
|
541
|
+
disableDefaultFloatingButton = false,
|
|
542
|
+
PreferencesModalComponent,
|
|
543
|
+
CookieBannerComponent,
|
|
544
|
+
FloatingPreferencesButtonComponent,
|
|
545
|
+
theme,
|
|
546
|
+
hideBranding,
|
|
547
|
+
cookieBannerProps,
|
|
548
|
+
preferencesModalProps,
|
|
549
|
+
floatingPreferencesButtonProps,
|
|
550
|
+
children,
|
|
551
|
+
...coreProps
|
|
552
|
+
}) {
|
|
553
|
+
const modalComponent = disableDefaultModal ? PreferencesModalComponent : PreferencesModalComponent || PreferencesModal;
|
|
554
|
+
const bannerComponent = disableDefaultBanner ? CookieBannerComponent : CookieBannerComponent || CookieBanner;
|
|
555
|
+
const floatingButtonComponent = disableDefaultFloatingButton ? FloatingPreferencesButtonComponent : FloatingPreferencesButtonComponent || FloatingPreferencesButton;
|
|
556
|
+
const mergedCookieBannerProps = {
|
|
557
|
+
...cookieBannerProps,
|
|
558
|
+
hideBranding: cookieBannerProps?.hideBranding ?? hideBranding
|
|
559
|
+
};
|
|
560
|
+
const mergedPreferencesModalProps = {
|
|
561
|
+
...preferencesModalProps,
|
|
562
|
+
hideBranding: preferencesModalProps?.hideBranding ?? hideBranding
|
|
563
|
+
};
|
|
564
|
+
const provider = /* @__PURE__ */ jsxRuntime.jsx(
|
|
565
|
+
core.ConsentProvider,
|
|
566
|
+
{
|
|
567
|
+
...coreProps,
|
|
568
|
+
hideBranding,
|
|
569
|
+
cookieBannerProps: mergedCookieBannerProps,
|
|
570
|
+
preferencesModalProps: mergedPreferencesModalProps,
|
|
571
|
+
floatingPreferencesButtonProps,
|
|
572
|
+
CookieBannerComponent: bannerComponent,
|
|
573
|
+
PreferencesModalComponent: modalComponent,
|
|
574
|
+
FloatingPreferencesButtonComponent: floatingButtonComponent,
|
|
575
|
+
children
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
if (!theme) return provider;
|
|
579
|
+
return /* @__PURE__ */ jsxRuntime.jsx(styles.ThemeProvider, { theme, children: provider });
|
|
580
|
+
}
|
|
581
|
+
ConsentProvider.displayName = "ConsentProvider(MUI)";
|
|
582
|
+
|
|
583
|
+
Object.defineProperty(exports, "ConsentProviderHeadless", {
|
|
584
|
+
enumerable: true,
|
|
585
|
+
get: function () { return core.ConsentProvider; }
|
|
586
|
+
});
|
|
587
|
+
exports.Branding = Branding;
|
|
588
|
+
exports.ConsentProvider = ConsentProvider;
|
|
589
|
+
exports.CookieBanner = CookieBanner;
|
|
590
|
+
exports.FloatingPreferencesButton = FloatingPreferencesButton;
|
|
591
|
+
exports.PreferencesModal = PreferencesModal;
|
|
592
|
+
Object.keys(core).forEach(function (k) {
|
|
593
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
594
|
+
enumerable: true,
|
|
595
|
+
get: function () { return core[k]; }
|
|
596
|
+
});
|
|
597
|
+
});
|