@react-lgpd-consent/mui 0.7.1 → 0.8.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/README.md +13 -2
- package/dist/index.cjs +92 -32
- package/dist/index.d.cts +55 -4
- package/dist/index.d.ts +55 -4
- package/dist/index.js +92 -32
- package/dist/ui.cjs +92 -32
- package/dist/ui.js +92 -32
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useConsentTexts, useDesignTokens, useConsent, logger, useConsentHydration, useCategories, getCookiesInfoForCategory, ConsentProvider as ConsentProvider$1 } from '@react-lgpd-consent/core';
|
|
1
|
+
import { useConsentTexts, resolveTexts, useDesignTokens, useConsent, logger, useConsentHydration, useCategories, getCookiesInfoForCategory, ConsentProvider as ConsentProvider$1 } from '@react-lgpd-consent/core';
|
|
2
2
|
export * from '@react-lgpd-consent/core';
|
|
3
3
|
import * as core from '@react-lgpd-consent/core';
|
|
4
4
|
export { core as headless };
|
|
5
5
|
export { ConsentProvider as ConsentProviderHeadless } from '@react-lgpd-consent/core';
|
|
6
6
|
import Link from '@mui/material/Link';
|
|
7
7
|
import Typography from '@mui/material/Typography';
|
|
8
|
-
import * as
|
|
8
|
+
import * as React4 from 'react';
|
|
9
9
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import { useTheme, ThemeProvider } from '@mui/material/styles';
|
|
11
11
|
import Box2 from '@mui/material/Box';
|
|
@@ -52,11 +52,22 @@ var linkStyles = {
|
|
|
52
52
|
textDecoration: "underline"
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
var Branding =
|
|
55
|
+
var Branding = React4.memo(function Branding2({
|
|
56
56
|
variant,
|
|
57
|
-
hidden = false
|
|
57
|
+
hidden = false,
|
|
58
|
+
texts: textsProp,
|
|
59
|
+
language,
|
|
60
|
+
textVariant
|
|
58
61
|
}) {
|
|
59
|
-
const
|
|
62
|
+
const baseTexts = useConsentTexts();
|
|
63
|
+
const mergedTexts = React4.useMemo(
|
|
64
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
65
|
+
[baseTexts, textsProp]
|
|
66
|
+
);
|
|
67
|
+
const texts = React4.useMemo(
|
|
68
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
69
|
+
[mergedTexts, language, textVariant]
|
|
70
|
+
);
|
|
60
71
|
const designTokens = useDesignTokens();
|
|
61
72
|
if (hidden) return null;
|
|
62
73
|
return /* @__PURE__ */ jsxs(
|
|
@@ -94,10 +105,21 @@ function CookieBanner({
|
|
|
94
105
|
blocking = true,
|
|
95
106
|
hideBranding = false,
|
|
96
107
|
SnackbarProps,
|
|
97
|
-
PaperProps
|
|
108
|
+
PaperProps,
|
|
109
|
+
texts: textsProp,
|
|
110
|
+
language,
|
|
111
|
+
textVariant
|
|
98
112
|
}) {
|
|
99
113
|
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
100
|
-
const
|
|
114
|
+
const baseTexts = useConsentTexts();
|
|
115
|
+
const mergedTexts = React4.useMemo(
|
|
116
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
117
|
+
[baseTexts, textsProp]
|
|
118
|
+
);
|
|
119
|
+
const texts = React4.useMemo(
|
|
120
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
121
|
+
[mergedTexts, language, textVariant]
|
|
122
|
+
);
|
|
101
123
|
const isHydrated = useConsentHydration();
|
|
102
124
|
const designTokens = useDesignTokens();
|
|
103
125
|
const open = debug ? true : isHydrated && !consented;
|
|
@@ -172,7 +194,15 @@ function CookieBanner({
|
|
|
172
194
|
}
|
|
173
195
|
)
|
|
174
196
|
] }),
|
|
175
|
-
!hideBranding && /* @__PURE__ */ jsx(
|
|
197
|
+
!hideBranding && /* @__PURE__ */ jsx(
|
|
198
|
+
Branding,
|
|
199
|
+
{
|
|
200
|
+
variant: "banner",
|
|
201
|
+
texts: textsProp,
|
|
202
|
+
language,
|
|
203
|
+
textVariant
|
|
204
|
+
}
|
|
205
|
+
)
|
|
176
206
|
] }) });
|
|
177
207
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
178
208
|
const positionStyle = (theme) => ({
|
|
@@ -272,13 +302,24 @@ function FloatingPreferencesButtonComponent({
|
|
|
272
302
|
icon = /* @__PURE__ */ jsx(CookieOutlined, {}),
|
|
273
303
|
tooltip,
|
|
274
304
|
FabProps,
|
|
275
|
-
hideWhenConsented = false
|
|
305
|
+
hideWhenConsented = false,
|
|
306
|
+
texts: textsProp,
|
|
307
|
+
language,
|
|
308
|
+
textVariant
|
|
276
309
|
}) {
|
|
277
310
|
const { openPreferences, consented } = useConsent();
|
|
278
|
-
const
|
|
311
|
+
const baseTexts = useConsentTexts();
|
|
312
|
+
const mergedTexts = React4.useMemo(
|
|
313
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
314
|
+
[baseTexts, textsProp]
|
|
315
|
+
);
|
|
316
|
+
const texts = React4.useMemo(
|
|
317
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
318
|
+
[mergedTexts, language, textVariant]
|
|
319
|
+
);
|
|
279
320
|
const safeTheme = useThemeWithFallbacks();
|
|
280
321
|
const designTokens = useDesignTokens();
|
|
281
|
-
const positionStyles =
|
|
322
|
+
const positionStyles = React4.useMemo(() => {
|
|
282
323
|
const styles = {
|
|
283
324
|
position: "fixed",
|
|
284
325
|
zIndex: 1200
|
|
@@ -329,7 +370,7 @@ function FloatingPreferencesButtonComponent({
|
|
|
329
370
|
}
|
|
330
371
|
) });
|
|
331
372
|
}
|
|
332
|
-
var FloatingPreferencesButton =
|
|
373
|
+
var FloatingPreferencesButton = React4.memo(FloatingPreferencesButtonComponent);
|
|
333
374
|
FloatingPreferencesButton.displayName = "FloatingPreferencesButton";
|
|
334
375
|
function PreferencesModal({
|
|
335
376
|
DialogProps: DialogProps2,
|
|
@@ -337,26 +378,37 @@ function PreferencesModal({
|
|
|
337
378
|
isModalOpen: isModalOpenProp,
|
|
338
379
|
preferences: preferencesProp,
|
|
339
380
|
setPreferences: setPreferencesProp,
|
|
340
|
-
closePreferences: closePreferencesProp
|
|
381
|
+
closePreferences: closePreferencesProp,
|
|
382
|
+
texts: textsProp,
|
|
383
|
+
language,
|
|
384
|
+
textVariant
|
|
341
385
|
}) {
|
|
342
386
|
const hookValue = useConsent();
|
|
343
387
|
const preferences = preferencesProp ?? hookValue.preferences;
|
|
344
388
|
const setPreferences = setPreferencesProp ?? hookValue.setPreferences;
|
|
345
389
|
const closePreferences = closePreferencesProp ?? hookValue.closePreferences;
|
|
346
390
|
const isModalOpen = isModalOpenProp ?? hookValue.isModalOpen;
|
|
347
|
-
const
|
|
391
|
+
const baseTexts = useConsentTexts();
|
|
392
|
+
const mergedTexts = React4.useMemo(
|
|
393
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
394
|
+
[baseTexts, textsProp]
|
|
395
|
+
);
|
|
396
|
+
const texts = React4.useMemo(
|
|
397
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
398
|
+
[mergedTexts, language, textVariant]
|
|
399
|
+
);
|
|
348
400
|
const designTokens = useDesignTokens();
|
|
349
401
|
const { toggleableCategories, allCategories } = useCategories();
|
|
350
|
-
const getInitialPreferences =
|
|
402
|
+
const getInitialPreferences = React4.useCallback(() => {
|
|
351
403
|
const syncedPrefs = { necessary: true };
|
|
352
404
|
toggleableCategories.forEach((category) => {
|
|
353
405
|
syncedPrefs[category.id] = preferences[category.id] ?? false;
|
|
354
406
|
});
|
|
355
407
|
return syncedPrefs;
|
|
356
408
|
}, [preferences, toggleableCategories]);
|
|
357
|
-
const [tempPreferences, setTempPreferences] =
|
|
358
|
-
const wasOpenRef =
|
|
359
|
-
|
|
409
|
+
const [tempPreferences, setTempPreferences] = React4.useState(getInitialPreferences);
|
|
410
|
+
const wasOpenRef = React4.useRef(isModalOpen);
|
|
411
|
+
React4.useEffect(() => {
|
|
360
412
|
const justOpened = isModalOpen && !wasOpenRef.current;
|
|
361
413
|
wasOpenRef.current = isModalOpen;
|
|
362
414
|
if (justOpened) {
|
|
@@ -374,6 +426,7 @@ function PreferencesModal({
|
|
|
374
426
|
setTempPreferences(preferences);
|
|
375
427
|
closePreferences();
|
|
376
428
|
};
|
|
429
|
+
const descriptionId = "cookie-pref-description";
|
|
377
430
|
const modalTitleSx = (theme) => ({
|
|
378
431
|
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
379
432
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
@@ -383,7 +436,7 @@ function PreferencesModal({
|
|
|
383
436
|
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
384
437
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
385
438
|
});
|
|
386
|
-
const resolveModalZIndex =
|
|
439
|
+
const resolveModalZIndex = React4.useCallback(
|
|
387
440
|
(theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
|
|
388
441
|
[designTokens?.layout?.zIndex?.modal]
|
|
389
442
|
);
|
|
@@ -398,11 +451,13 @@ function PreferencesModal({
|
|
|
398
451
|
...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
|
|
399
452
|
"data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
|
|
400
453
|
};
|
|
454
|
+
const ariaDescribedBy = dialogRest["aria-describedby"] ?? descriptionId;
|
|
401
455
|
const mergedDialogProps = {
|
|
402
456
|
open,
|
|
403
457
|
fullWidth: true,
|
|
404
458
|
maxWidth: "sm",
|
|
405
459
|
...dialogRest,
|
|
460
|
+
"aria-describedby": ariaDescribedBy,
|
|
406
461
|
slotProps: {
|
|
407
462
|
...dialogRest?.slotProps,
|
|
408
463
|
root: rootSlotProps
|
|
@@ -414,6 +469,7 @@ function PreferencesModal({
|
|
|
414
469
|
/* @__PURE__ */ jsx(
|
|
415
470
|
Typography,
|
|
416
471
|
{
|
|
472
|
+
id: descriptionId,
|
|
417
473
|
variant: "body2",
|
|
418
474
|
sx: (theme) => ({
|
|
419
475
|
mb: 2,
|
|
@@ -429,6 +485,10 @@ function PreferencesModal({
|
|
|
429
485
|
const namesFromGuidance = full?.cookies ?? [];
|
|
430
486
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
431
487
|
const descriptors = getCookiesInfoForCategory(category.id, used);
|
|
488
|
+
const tableHeaders = texts.cookieDetails?.tableHeaders;
|
|
489
|
+
const toggleDetailsText = texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes";
|
|
490
|
+
const scriptLabelPrefix = texts.cookieDetails?.scriptLabelPrefix ?? "(script) ";
|
|
491
|
+
const scriptPurpose = texts.cookieDetails?.scriptPurpose ?? "Script de integra\xE7\xE3o ativo";
|
|
432
492
|
const enrichedDescriptors = descriptors.map((desc) => {
|
|
433
493
|
if (desc.purpose && desc.duration && desc.provider) {
|
|
434
494
|
return desc;
|
|
@@ -449,8 +509,8 @@ function PreferencesModal({
|
|
|
449
509
|
if (merged.length === 0) {
|
|
450
510
|
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
451
511
|
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
452
|
-
name:
|
|
453
|
-
purpose:
|
|
512
|
+
name: `${scriptLabelPrefix}${id}`,
|
|
513
|
+
purpose: scriptPurpose,
|
|
454
514
|
duration: "-",
|
|
455
515
|
provider: "-"
|
|
456
516
|
}));
|
|
@@ -476,13 +536,13 @@ function PreferencesModal({
|
|
|
476
536
|
}
|
|
477
537
|
),
|
|
478
538
|
/* @__PURE__ */ jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
479
|
-
/* @__PURE__ */ jsx("summary", { children:
|
|
539
|
+
/* @__PURE__ */ jsx("summary", { children: toggleDetailsText }),
|
|
480
540
|
/* @__PURE__ */ jsx(Box2, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
481
541
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
482
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
483
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
484
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
485
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
542
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.name ?? "Cookie" }),
|
|
543
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.purpose ?? "Finalidade" }),
|
|
544
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
545
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.provider ?? "Fornecedor" })
|
|
486
546
|
] }) }),
|
|
487
547
|
/* @__PURE__ */ jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
488
548
|
/* @__PURE__ */ jsx("td", { children: d.name }),
|
|
@@ -496,13 +556,13 @@ function PreferencesModal({
|
|
|
496
556
|
}),
|
|
497
557
|
/* @__PURE__ */ jsx(FormControlLabel, { control: /* @__PURE__ */ jsx(Switch, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
498
558
|
/* @__PURE__ */ jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
499
|
-
/* @__PURE__ */ jsx("summary", { children: "Ver detalhes" }),
|
|
559
|
+
/* @__PURE__ */ jsx("summary", { children: texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes" }),
|
|
500
560
|
/* @__PURE__ */ jsx(Box2, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
501
561
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
502
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
503
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
504
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
505
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
562
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.name ?? "Cookie" }),
|
|
563
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.purpose ?? "Finalidade" }),
|
|
564
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
565
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.provider ?? "Fornecedor" })
|
|
506
566
|
] }) }),
|
|
507
567
|
/* @__PURE__ */ jsx("tbody", { children: (() => {
|
|
508
568
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
@@ -525,7 +585,7 @@ function PreferencesModal({
|
|
|
525
585
|
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
526
586
|
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
527
587
|
] }),
|
|
528
|
-
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "modal" })
|
|
588
|
+
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "modal", texts: textsProp, language, textVariant })
|
|
529
589
|
] });
|
|
530
590
|
}
|
|
531
591
|
function ConsentProvider({
|
package/dist/ui.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var Link = require('@mui/material/Link');
|
|
4
4
|
var Typography = require('@mui/material/Typography');
|
|
5
5
|
var core = require('@react-lgpd-consent/core');
|
|
6
|
-
var
|
|
6
|
+
var React4 = require('react');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var styles = require('@mui/material/styles');
|
|
9
9
|
var Box2 = require('@mui/material/Box');
|
|
@@ -44,7 +44,7 @@ function _interopNamespace(e) {
|
|
|
44
44
|
|
|
45
45
|
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
46
46
|
var Typography__default = /*#__PURE__*/_interopDefault(Typography);
|
|
47
|
-
var
|
|
47
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
48
48
|
var Box2__default = /*#__PURE__*/_interopDefault(Box2);
|
|
49
49
|
var Button__default = /*#__PURE__*/_interopDefault(Button);
|
|
50
50
|
var Paper__default = /*#__PURE__*/_interopDefault(Paper);
|
|
@@ -89,11 +89,22 @@ var linkStyles = {
|
|
|
89
89
|
textDecoration: "underline"
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
var Branding =
|
|
92
|
+
var Branding = React4__namespace.memo(function Branding2({
|
|
93
93
|
variant,
|
|
94
|
-
hidden = false
|
|
94
|
+
hidden = false,
|
|
95
|
+
texts: textsProp,
|
|
96
|
+
language,
|
|
97
|
+
textVariant
|
|
95
98
|
}) {
|
|
96
|
-
const
|
|
99
|
+
const baseTexts = core.useConsentTexts();
|
|
100
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
101
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
102
|
+
[baseTexts, textsProp]
|
|
103
|
+
);
|
|
104
|
+
const texts = React4__namespace.useMemo(
|
|
105
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
106
|
+
[mergedTexts, language, textVariant]
|
|
107
|
+
);
|
|
97
108
|
const designTokens = core.useDesignTokens();
|
|
98
109
|
if (hidden) return null;
|
|
99
110
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -131,10 +142,21 @@ function CookieBanner({
|
|
|
131
142
|
blocking = true,
|
|
132
143
|
hideBranding = false,
|
|
133
144
|
SnackbarProps,
|
|
134
|
-
PaperProps
|
|
145
|
+
PaperProps,
|
|
146
|
+
texts: textsProp,
|
|
147
|
+
language,
|
|
148
|
+
textVariant
|
|
135
149
|
}) {
|
|
136
150
|
const { consented, acceptAll, rejectAll, openPreferences } = core.useConsent();
|
|
137
|
-
const
|
|
151
|
+
const baseTexts = core.useConsentTexts();
|
|
152
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
153
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
154
|
+
[baseTexts, textsProp]
|
|
155
|
+
);
|
|
156
|
+
const texts = React4__namespace.useMemo(
|
|
157
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
158
|
+
[mergedTexts, language, textVariant]
|
|
159
|
+
);
|
|
138
160
|
const isHydrated = core.useConsentHydration();
|
|
139
161
|
const designTokens = core.useDesignTokens();
|
|
140
162
|
const open = debug ? true : isHydrated && !consented;
|
|
@@ -209,7 +231,15 @@ function CookieBanner({
|
|
|
209
231
|
}
|
|
210
232
|
)
|
|
211
233
|
] }),
|
|
212
|
-
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(
|
|
234
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(
|
|
235
|
+
Branding,
|
|
236
|
+
{
|
|
237
|
+
variant: "banner",
|
|
238
|
+
texts: textsProp,
|
|
239
|
+
language,
|
|
240
|
+
textVariant
|
|
241
|
+
}
|
|
242
|
+
)
|
|
213
243
|
] }) });
|
|
214
244
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
215
245
|
const positionStyle = (theme) => ({
|
|
@@ -309,13 +339,24 @@ function FloatingPreferencesButtonComponent({
|
|
|
309
339
|
icon = /* @__PURE__ */ jsxRuntime.jsx(CookieOutlined__default.default, {}),
|
|
310
340
|
tooltip,
|
|
311
341
|
FabProps,
|
|
312
|
-
hideWhenConsented = false
|
|
342
|
+
hideWhenConsented = false,
|
|
343
|
+
texts: textsProp,
|
|
344
|
+
language,
|
|
345
|
+
textVariant
|
|
313
346
|
}) {
|
|
314
347
|
const { openPreferences, consented } = core.useConsent();
|
|
315
|
-
const
|
|
348
|
+
const baseTexts = core.useConsentTexts();
|
|
349
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
350
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
351
|
+
[baseTexts, textsProp]
|
|
352
|
+
);
|
|
353
|
+
const texts = React4__namespace.useMemo(
|
|
354
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
355
|
+
[mergedTexts, language, textVariant]
|
|
356
|
+
);
|
|
316
357
|
const safeTheme = useThemeWithFallbacks();
|
|
317
358
|
const designTokens = core.useDesignTokens();
|
|
318
|
-
const positionStyles =
|
|
359
|
+
const positionStyles = React4__namespace.useMemo(() => {
|
|
319
360
|
const styles = {
|
|
320
361
|
position: "fixed",
|
|
321
362
|
zIndex: 1200
|
|
@@ -366,7 +407,7 @@ function FloatingPreferencesButtonComponent({
|
|
|
366
407
|
}
|
|
367
408
|
) });
|
|
368
409
|
}
|
|
369
|
-
var FloatingPreferencesButton =
|
|
410
|
+
var FloatingPreferencesButton = React4__namespace.memo(FloatingPreferencesButtonComponent);
|
|
370
411
|
FloatingPreferencesButton.displayName = "FloatingPreferencesButton";
|
|
371
412
|
function PreferencesModal({
|
|
372
413
|
DialogProps: DialogProps2,
|
|
@@ -374,26 +415,37 @@ function PreferencesModal({
|
|
|
374
415
|
isModalOpen: isModalOpenProp,
|
|
375
416
|
preferences: preferencesProp,
|
|
376
417
|
setPreferences: setPreferencesProp,
|
|
377
|
-
closePreferences: closePreferencesProp
|
|
418
|
+
closePreferences: closePreferencesProp,
|
|
419
|
+
texts: textsProp,
|
|
420
|
+
language,
|
|
421
|
+
textVariant
|
|
378
422
|
}) {
|
|
379
423
|
const hookValue = core.useConsent();
|
|
380
424
|
const preferences = preferencesProp ?? hookValue.preferences;
|
|
381
425
|
const setPreferences = setPreferencesProp ?? hookValue.setPreferences;
|
|
382
426
|
const closePreferences = closePreferencesProp ?? hookValue.closePreferences;
|
|
383
427
|
const isModalOpen = isModalOpenProp ?? hookValue.isModalOpen;
|
|
384
|
-
const
|
|
428
|
+
const baseTexts = core.useConsentTexts();
|
|
429
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
430
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
431
|
+
[baseTexts, textsProp]
|
|
432
|
+
);
|
|
433
|
+
const texts = React4__namespace.useMemo(
|
|
434
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
435
|
+
[mergedTexts, language, textVariant]
|
|
436
|
+
);
|
|
385
437
|
const designTokens = core.useDesignTokens();
|
|
386
438
|
const { toggleableCategories, allCategories } = core.useCategories();
|
|
387
|
-
const getInitialPreferences =
|
|
439
|
+
const getInitialPreferences = React4__namespace.useCallback(() => {
|
|
388
440
|
const syncedPrefs = { necessary: true };
|
|
389
441
|
toggleableCategories.forEach((category) => {
|
|
390
442
|
syncedPrefs[category.id] = preferences[category.id] ?? false;
|
|
391
443
|
});
|
|
392
444
|
return syncedPrefs;
|
|
393
445
|
}, [preferences, toggleableCategories]);
|
|
394
|
-
const [tempPreferences, setTempPreferences] =
|
|
395
|
-
const wasOpenRef =
|
|
396
|
-
|
|
446
|
+
const [tempPreferences, setTempPreferences] = React4__namespace.useState(getInitialPreferences);
|
|
447
|
+
const wasOpenRef = React4__namespace.useRef(isModalOpen);
|
|
448
|
+
React4__namespace.useEffect(() => {
|
|
397
449
|
const justOpened = isModalOpen && !wasOpenRef.current;
|
|
398
450
|
wasOpenRef.current = isModalOpen;
|
|
399
451
|
if (justOpened) {
|
|
@@ -411,6 +463,7 @@ function PreferencesModal({
|
|
|
411
463
|
setTempPreferences(preferences);
|
|
412
464
|
closePreferences();
|
|
413
465
|
};
|
|
466
|
+
const descriptionId = "cookie-pref-description";
|
|
414
467
|
const modalTitleSx = (theme) => ({
|
|
415
468
|
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
416
469
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
@@ -420,7 +473,7 @@ function PreferencesModal({
|
|
|
420
473
|
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
421
474
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
422
475
|
});
|
|
423
|
-
const resolveModalZIndex =
|
|
476
|
+
const resolveModalZIndex = React4__namespace.useCallback(
|
|
424
477
|
(theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
|
|
425
478
|
[designTokens?.layout?.zIndex?.modal]
|
|
426
479
|
);
|
|
@@ -435,11 +488,13 @@ function PreferencesModal({
|
|
|
435
488
|
...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
|
|
436
489
|
"data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
|
|
437
490
|
};
|
|
491
|
+
const ariaDescribedBy = dialogRest["aria-describedby"] ?? descriptionId;
|
|
438
492
|
const mergedDialogProps = {
|
|
439
493
|
open,
|
|
440
494
|
fullWidth: true,
|
|
441
495
|
maxWidth: "sm",
|
|
442
496
|
...dialogRest,
|
|
497
|
+
"aria-describedby": ariaDescribedBy,
|
|
443
498
|
slotProps: {
|
|
444
499
|
...dialogRest?.slotProps,
|
|
445
500
|
root: rootSlotProps
|
|
@@ -451,6 +506,7 @@ function PreferencesModal({
|
|
|
451
506
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
452
507
|
Typography__default.default,
|
|
453
508
|
{
|
|
509
|
+
id: descriptionId,
|
|
454
510
|
variant: "body2",
|
|
455
511
|
sx: (theme) => ({
|
|
456
512
|
mb: 2,
|
|
@@ -466,6 +522,10 @@ function PreferencesModal({
|
|
|
466
522
|
const namesFromGuidance = full?.cookies ?? [];
|
|
467
523
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
468
524
|
const descriptors = core.getCookiesInfoForCategory(category.id, used);
|
|
525
|
+
const tableHeaders = texts.cookieDetails?.tableHeaders;
|
|
526
|
+
const toggleDetailsText = texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes";
|
|
527
|
+
const scriptLabelPrefix = texts.cookieDetails?.scriptLabelPrefix ?? "(script) ";
|
|
528
|
+
const scriptPurpose = texts.cookieDetails?.scriptPurpose ?? "Script de integra\xE7\xE3o ativo";
|
|
469
529
|
const enrichedDescriptors = descriptors.map((desc) => {
|
|
470
530
|
if (desc.purpose && desc.duration && desc.provider) {
|
|
471
531
|
return desc;
|
|
@@ -486,8 +546,8 @@ function PreferencesModal({
|
|
|
486
546
|
if (merged.length === 0) {
|
|
487
547
|
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
488
548
|
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
489
|
-
name:
|
|
490
|
-
purpose:
|
|
549
|
+
name: `${scriptLabelPrefix}${id}`,
|
|
550
|
+
purpose: scriptPurpose,
|
|
491
551
|
duration: "-",
|
|
492
552
|
provider: "-"
|
|
493
553
|
}));
|
|
@@ -513,13 +573,13 @@ function PreferencesModal({
|
|
|
513
573
|
}
|
|
514
574
|
),
|
|
515
575
|
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
516
|
-
/* @__PURE__ */ jsxRuntime.jsx("summary", { children:
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: toggleDetailsText }),
|
|
517
577
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
518
578
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
519
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
520
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
521
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
522
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.name ?? "Cookie" }),
|
|
580
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.purpose ?? "Finalidade" }),
|
|
581
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
582
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.provider ?? "Fornecedor" })
|
|
523
583
|
] }) }),
|
|
524
584
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
525
585
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.name }),
|
|
@@ -533,13 +593,13 @@ function PreferencesModal({
|
|
|
533
593
|
}),
|
|
534
594
|
/* @__PURE__ */ jsxRuntime.jsx(FormControlLabel__default.default, { control: /* @__PURE__ */ jsxRuntime.jsx(Switch__default.default, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
535
595
|
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
536
|
-
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Ver detalhes" }),
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes" }),
|
|
537
597
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
538
598
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
539
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
540
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
541
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
542
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
599
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.name ?? "Cookie" }),
|
|
600
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.purpose ?? "Finalidade" }),
|
|
601
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
602
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.provider ?? "Fornecedor" })
|
|
543
603
|
] }) }),
|
|
544
604
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: (() => {
|
|
545
605
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
@@ -562,7 +622,7 @@ function PreferencesModal({
|
|
|
562
622
|
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
563
623
|
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
564
624
|
] }),
|
|
565
|
-
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal" })
|
|
625
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal", texts: textsProp, language, textVariant })
|
|
566
626
|
] });
|
|
567
627
|
}
|
|
568
628
|
function ConsentProvider({
|