@react-lgpd-consent/mui 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +88 -32
- package/dist/index.d.cts +55 -4
- package/dist/index.d.ts +55 -4
- package/dist/index.js +88 -32
- package/dist/ui.cjs +88 -32
- package/dist/ui.js +88 -32
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var core = require('@react-lgpd-consent/core');
|
|
4
4
|
var Link = require('@mui/material/Link');
|
|
5
5
|
var Typography = require('@mui/material/Typography');
|
|
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');
|
|
@@ -45,7 +45,7 @@ function _interopNamespace(e) {
|
|
|
45
45
|
var core__namespace = /*#__PURE__*/_interopNamespace(core);
|
|
46
46
|
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
47
47
|
var Typography__default = /*#__PURE__*/_interopDefault(Typography);
|
|
48
|
-
var
|
|
48
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
49
49
|
var Box2__default = /*#__PURE__*/_interopDefault(Box2);
|
|
50
50
|
var Button__default = /*#__PURE__*/_interopDefault(Button);
|
|
51
51
|
var Paper__default = /*#__PURE__*/_interopDefault(Paper);
|
|
@@ -90,11 +90,22 @@ var linkStyles = {
|
|
|
90
90
|
textDecoration: "underline"
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
var Branding =
|
|
93
|
+
var Branding = React4__namespace.memo(function Branding2({
|
|
94
94
|
variant,
|
|
95
|
-
hidden = false
|
|
95
|
+
hidden = false,
|
|
96
|
+
texts: textsProp,
|
|
97
|
+
language,
|
|
98
|
+
textVariant
|
|
96
99
|
}) {
|
|
97
|
-
const
|
|
100
|
+
const baseTexts = core.useConsentTexts();
|
|
101
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
102
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
103
|
+
[baseTexts, textsProp]
|
|
104
|
+
);
|
|
105
|
+
const texts = React4__namespace.useMemo(
|
|
106
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
107
|
+
[mergedTexts, language, textVariant]
|
|
108
|
+
);
|
|
98
109
|
const designTokens = core.useDesignTokens();
|
|
99
110
|
if (hidden) return null;
|
|
100
111
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -132,10 +143,21 @@ function CookieBanner({
|
|
|
132
143
|
blocking = true,
|
|
133
144
|
hideBranding = false,
|
|
134
145
|
SnackbarProps,
|
|
135
|
-
PaperProps
|
|
146
|
+
PaperProps,
|
|
147
|
+
texts: textsProp,
|
|
148
|
+
language,
|
|
149
|
+
textVariant
|
|
136
150
|
}) {
|
|
137
151
|
const { consented, acceptAll, rejectAll, openPreferences } = core.useConsent();
|
|
138
|
-
const
|
|
152
|
+
const baseTexts = core.useConsentTexts();
|
|
153
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
154
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
155
|
+
[baseTexts, textsProp]
|
|
156
|
+
);
|
|
157
|
+
const texts = React4__namespace.useMemo(
|
|
158
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
159
|
+
[mergedTexts, language, textVariant]
|
|
160
|
+
);
|
|
139
161
|
const isHydrated = core.useConsentHydration();
|
|
140
162
|
const designTokens = core.useDesignTokens();
|
|
141
163
|
const open = debug ? true : isHydrated && !consented;
|
|
@@ -210,7 +232,15 @@ function CookieBanner({
|
|
|
210
232
|
}
|
|
211
233
|
)
|
|
212
234
|
] }),
|
|
213
|
-
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(
|
|
235
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(
|
|
236
|
+
Branding,
|
|
237
|
+
{
|
|
238
|
+
variant: "banner",
|
|
239
|
+
texts: textsProp,
|
|
240
|
+
language,
|
|
241
|
+
textVariant
|
|
242
|
+
}
|
|
243
|
+
)
|
|
214
244
|
] }) });
|
|
215
245
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
216
246
|
const positionStyle = (theme) => ({
|
|
@@ -310,13 +340,24 @@ function FloatingPreferencesButtonComponent({
|
|
|
310
340
|
icon = /* @__PURE__ */ jsxRuntime.jsx(CookieOutlined__default.default, {}),
|
|
311
341
|
tooltip,
|
|
312
342
|
FabProps,
|
|
313
|
-
hideWhenConsented = false
|
|
343
|
+
hideWhenConsented = false,
|
|
344
|
+
texts: textsProp,
|
|
345
|
+
language,
|
|
346
|
+
textVariant
|
|
314
347
|
}) {
|
|
315
348
|
const { openPreferences, consented } = core.useConsent();
|
|
316
|
-
const
|
|
349
|
+
const baseTexts = core.useConsentTexts();
|
|
350
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
351
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
352
|
+
[baseTexts, textsProp]
|
|
353
|
+
);
|
|
354
|
+
const texts = React4__namespace.useMemo(
|
|
355
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
356
|
+
[mergedTexts, language, textVariant]
|
|
357
|
+
);
|
|
317
358
|
const safeTheme = useThemeWithFallbacks();
|
|
318
359
|
const designTokens = core.useDesignTokens();
|
|
319
|
-
const positionStyles =
|
|
360
|
+
const positionStyles = React4__namespace.useMemo(() => {
|
|
320
361
|
const styles = {
|
|
321
362
|
position: "fixed",
|
|
322
363
|
zIndex: 1200
|
|
@@ -367,7 +408,7 @@ function FloatingPreferencesButtonComponent({
|
|
|
367
408
|
}
|
|
368
409
|
) });
|
|
369
410
|
}
|
|
370
|
-
var FloatingPreferencesButton =
|
|
411
|
+
var FloatingPreferencesButton = React4__namespace.memo(FloatingPreferencesButtonComponent);
|
|
371
412
|
FloatingPreferencesButton.displayName = "FloatingPreferencesButton";
|
|
372
413
|
function PreferencesModal({
|
|
373
414
|
DialogProps: DialogProps2,
|
|
@@ -375,26 +416,37 @@ function PreferencesModal({
|
|
|
375
416
|
isModalOpen: isModalOpenProp,
|
|
376
417
|
preferences: preferencesProp,
|
|
377
418
|
setPreferences: setPreferencesProp,
|
|
378
|
-
closePreferences: closePreferencesProp
|
|
419
|
+
closePreferences: closePreferencesProp,
|
|
420
|
+
texts: textsProp,
|
|
421
|
+
language,
|
|
422
|
+
textVariant
|
|
379
423
|
}) {
|
|
380
424
|
const hookValue = core.useConsent();
|
|
381
425
|
const preferences = preferencesProp ?? hookValue.preferences;
|
|
382
426
|
const setPreferences = setPreferencesProp ?? hookValue.setPreferences;
|
|
383
427
|
const closePreferences = closePreferencesProp ?? hookValue.closePreferences;
|
|
384
428
|
const isModalOpen = isModalOpenProp ?? hookValue.isModalOpen;
|
|
385
|
-
const
|
|
429
|
+
const baseTexts = core.useConsentTexts();
|
|
430
|
+
const mergedTexts = React4__namespace.useMemo(
|
|
431
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
432
|
+
[baseTexts, textsProp]
|
|
433
|
+
);
|
|
434
|
+
const texts = React4__namespace.useMemo(
|
|
435
|
+
() => core.resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
436
|
+
[mergedTexts, language, textVariant]
|
|
437
|
+
);
|
|
386
438
|
const designTokens = core.useDesignTokens();
|
|
387
439
|
const { toggleableCategories, allCategories } = core.useCategories();
|
|
388
|
-
const getInitialPreferences =
|
|
440
|
+
const getInitialPreferences = React4__namespace.useCallback(() => {
|
|
389
441
|
const syncedPrefs = { necessary: true };
|
|
390
442
|
toggleableCategories.forEach((category) => {
|
|
391
443
|
syncedPrefs[category.id] = preferences[category.id] ?? false;
|
|
392
444
|
});
|
|
393
445
|
return syncedPrefs;
|
|
394
446
|
}, [preferences, toggleableCategories]);
|
|
395
|
-
const [tempPreferences, setTempPreferences] =
|
|
396
|
-
const wasOpenRef =
|
|
397
|
-
|
|
447
|
+
const [tempPreferences, setTempPreferences] = React4__namespace.useState(getInitialPreferences);
|
|
448
|
+
const wasOpenRef = React4__namespace.useRef(isModalOpen);
|
|
449
|
+
React4__namespace.useEffect(() => {
|
|
398
450
|
const justOpened = isModalOpen && !wasOpenRef.current;
|
|
399
451
|
wasOpenRef.current = isModalOpen;
|
|
400
452
|
if (justOpened) {
|
|
@@ -421,7 +473,7 @@ function PreferencesModal({
|
|
|
421
473
|
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
422
474
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
423
475
|
});
|
|
424
|
-
const resolveModalZIndex =
|
|
476
|
+
const resolveModalZIndex = React4__namespace.useCallback(
|
|
425
477
|
(theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
|
|
426
478
|
[designTokens?.layout?.zIndex?.modal]
|
|
427
479
|
);
|
|
@@ -467,6 +519,10 @@ function PreferencesModal({
|
|
|
467
519
|
const namesFromGuidance = full?.cookies ?? [];
|
|
468
520
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
469
521
|
const descriptors = core.getCookiesInfoForCategory(category.id, used);
|
|
522
|
+
const tableHeaders = texts.cookieDetails?.tableHeaders;
|
|
523
|
+
const toggleDetailsText = texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes";
|
|
524
|
+
const scriptLabelPrefix = texts.cookieDetails?.scriptLabelPrefix ?? "(script) ";
|
|
525
|
+
const scriptPurpose = texts.cookieDetails?.scriptPurpose ?? "Script de integra\xE7\xE3o ativo";
|
|
470
526
|
const enrichedDescriptors = descriptors.map((desc) => {
|
|
471
527
|
if (desc.purpose && desc.duration && desc.provider) {
|
|
472
528
|
return desc;
|
|
@@ -487,8 +543,8 @@ function PreferencesModal({
|
|
|
487
543
|
if (merged.length === 0) {
|
|
488
544
|
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
489
545
|
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
490
|
-
name:
|
|
491
|
-
purpose:
|
|
546
|
+
name: `${scriptLabelPrefix}${id}`,
|
|
547
|
+
purpose: scriptPurpose,
|
|
492
548
|
duration: "-",
|
|
493
549
|
provider: "-"
|
|
494
550
|
}));
|
|
@@ -514,13 +570,13 @@ function PreferencesModal({
|
|
|
514
570
|
}
|
|
515
571
|
),
|
|
516
572
|
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
517
|
-
/* @__PURE__ */ jsxRuntime.jsx("summary", { children:
|
|
573
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: toggleDetailsText }),
|
|
518
574
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
519
575
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
520
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
521
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
522
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
523
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.name ?? "Cookie" }),
|
|
577
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.purpose ?? "Finalidade" }),
|
|
578
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.provider ?? "Fornecedor" })
|
|
524
580
|
] }) }),
|
|
525
581
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
526
582
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.name }),
|
|
@@ -534,13 +590,13 @@ function PreferencesModal({
|
|
|
534
590
|
}),
|
|
535
591
|
/* @__PURE__ */ jsxRuntime.jsx(FormControlLabel__default.default, { control: /* @__PURE__ */ jsxRuntime.jsx(Switch__default.default, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
536
592
|
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
537
|
-
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Ver detalhes" }),
|
|
593
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes" }),
|
|
538
594
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
539
595
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
540
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
541
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
542
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
543
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.name ?? "Cookie" }),
|
|
597
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.purpose ?? "Finalidade" }),
|
|
598
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
599
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.provider ?? "Fornecedor" })
|
|
544
600
|
] }) }),
|
|
545
601
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: (() => {
|
|
546
602
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
@@ -563,7 +619,7 @@ function PreferencesModal({
|
|
|
563
619
|
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
564
620
|
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
565
621
|
] }),
|
|
566
|
-
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal" })
|
|
622
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal", texts: textsProp, language, textVariant })
|
|
567
623
|
] });
|
|
568
624
|
}
|
|
569
625
|
function ConsentProvider({
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConsentProviderProps as ConsentProviderProps$1, ConsentPreferences } from '@react-lgpd-consent/core';
|
|
1
|
+
import { AdvancedConsentTexts, ConsentProviderProps as ConsentProviderProps$1, ConsentPreferences } 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 };
|
|
@@ -49,6 +49,18 @@ interface BrandingProps {
|
|
|
49
49
|
* @defaultValue false
|
|
50
50
|
*/
|
|
51
51
|
hidden?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Textos customizados para o branding.
|
|
54
|
+
*/
|
|
55
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
56
|
+
/**
|
|
57
|
+
* Idioma local para resolver `texts.i18n`.
|
|
58
|
+
*/
|
|
59
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
60
|
+
/**
|
|
61
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
62
|
+
*/
|
|
63
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
52
64
|
}
|
|
53
65
|
/**
|
|
54
66
|
* Componente de branding que exibe crédito "fornecido por LÉdipO.eti.br".
|
|
@@ -611,6 +623,20 @@ interface CookieBannerProps {
|
|
|
611
623
|
* ```
|
|
612
624
|
*/
|
|
613
625
|
PaperProps?: Partial<PaperProps>;
|
|
626
|
+
/**
|
|
627
|
+
* Textos customizados para o banner.
|
|
628
|
+
* Permite sobrescrever textos do contexto e aplicar i18n localmente.
|
|
629
|
+
*/
|
|
630
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
631
|
+
/**
|
|
632
|
+
* Idioma local para resolver `texts.i18n`.
|
|
633
|
+
* Se omitido, usa o idioma do contexto (quando configurado no Provider).
|
|
634
|
+
*/
|
|
635
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
636
|
+
/**
|
|
637
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
638
|
+
*/
|
|
639
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
614
640
|
}
|
|
615
641
|
/**
|
|
616
642
|
* Banner principal de consentimento LGPD que solicita decisão do usuário sobre cookies.
|
|
@@ -703,7 +729,7 @@ interface CookieBannerProps {
|
|
|
703
729
|
* @public
|
|
704
730
|
* @since 0.1.0
|
|
705
731
|
*/
|
|
706
|
-
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
732
|
+
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, texts: textsProp, language, textVariant, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
707
733
|
|
|
708
734
|
/**
|
|
709
735
|
* Propriedades para customizar o comportamento e aparência do FloatingPreferencesButton.
|
|
@@ -848,6 +874,18 @@ interface FloatingPreferencesButtonProps {
|
|
|
848
874
|
* @defaultValue false
|
|
849
875
|
*/
|
|
850
876
|
hideWhenConsented?: boolean;
|
|
877
|
+
/**
|
|
878
|
+
* Textos customizados para o botão flutuante.
|
|
879
|
+
*/
|
|
880
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
881
|
+
/**
|
|
882
|
+
* Idioma local para resolver `texts.i18n`.
|
|
883
|
+
*/
|
|
884
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
885
|
+
/**
|
|
886
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
887
|
+
*/
|
|
888
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
851
889
|
}
|
|
852
890
|
/**
|
|
853
891
|
* Componente interno do botão flutuante de preferências.
|
|
@@ -857,7 +895,7 @@ interface FloatingPreferencesButtonProps {
|
|
|
857
895
|
* @returns {JSX.Element | null} Elemento JSX do botão ou null se oculto.
|
|
858
896
|
* @remarks Memoiza estilos de posição para performance. Usa design tokens defensivamente.
|
|
859
897
|
*/
|
|
860
|
-
declare function FloatingPreferencesButtonComponent({ position, offset, icon, tooltip, FabProps, hideWhenConsented, }: Readonly<FloatingPreferencesButtonProps>): react_jsx_runtime.JSX.Element | null;
|
|
898
|
+
declare function FloatingPreferencesButtonComponent({ position, offset, icon, tooltip, FabProps, hideWhenConsented, texts: textsProp, language, textVariant, }: Readonly<FloatingPreferencesButtonProps>): react_jsx_runtime.JSX.Element | null;
|
|
861
899
|
/**
|
|
862
900
|
* Botão flutuante (FAB) para reabrir o modal de preferências de consentimento LGPD.
|
|
863
901
|
*
|
|
@@ -1096,6 +1134,19 @@ interface PreferencesModalProps {
|
|
|
1096
1134
|
* @defaultValue undefined (usa função do contexto)
|
|
1097
1135
|
*/
|
|
1098
1136
|
closePreferences?: () => void;
|
|
1137
|
+
/**
|
|
1138
|
+
* Textos customizados para o modal.
|
|
1139
|
+
* Permite sobrescrever textos do contexto e aplicar i18n localmente.
|
|
1140
|
+
*/
|
|
1141
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Idioma local para resolver `texts.i18n`.
|
|
1144
|
+
*/
|
|
1145
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
1146
|
+
/**
|
|
1147
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
1148
|
+
*/
|
|
1149
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
1099
1150
|
}
|
|
1100
1151
|
/**
|
|
1101
1152
|
* Modal de preferências de consentimento LGPD que permite ao usuário ajustar suas escolhas.
|
|
@@ -1209,6 +1260,6 @@ interface PreferencesModalProps {
|
|
|
1209
1260
|
* @see {@link PreferencesModalProps} - Interface completa de propriedades
|
|
1210
1261
|
* @see {@link getCookiesInfoForCategory} - Função que retorna informações de cookies
|
|
1211
1262
|
*/
|
|
1212
|
-
declare function PreferencesModal({ DialogProps, hideBranding, isModalOpen: isModalOpenProp, preferences: preferencesProp, setPreferences: setPreferencesProp, closePreferences: closePreferencesProp, }: Readonly<PreferencesModalProps>): react_jsx_runtime.JSX.Element;
|
|
1263
|
+
declare function PreferencesModal({ DialogProps, hideBranding, isModalOpen: isModalOpenProp, preferences: preferencesProp, setPreferences: setPreferencesProp, closePreferences: closePreferencesProp, texts: textsProp, language, textVariant, }: Readonly<PreferencesModalProps>): react_jsx_runtime.JSX.Element;
|
|
1213
1264
|
|
|
1214
1265
|
export { Branding, type BrandingProps, ConsentProvider, type ConsentProviderProps, CookieBanner, type CookieBannerProps, FloatingPreferencesButton, type FloatingPreferencesButtonProps, PreferencesModal, type PreferencesModalProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConsentProviderProps as ConsentProviderProps$1, ConsentPreferences } from '@react-lgpd-consent/core';
|
|
1
|
+
import { AdvancedConsentTexts, ConsentProviderProps as ConsentProviderProps$1, ConsentPreferences } 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 };
|
|
@@ -49,6 +49,18 @@ interface BrandingProps {
|
|
|
49
49
|
* @defaultValue false
|
|
50
50
|
*/
|
|
51
51
|
hidden?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Textos customizados para o branding.
|
|
54
|
+
*/
|
|
55
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
56
|
+
/**
|
|
57
|
+
* Idioma local para resolver `texts.i18n`.
|
|
58
|
+
*/
|
|
59
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
60
|
+
/**
|
|
61
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
62
|
+
*/
|
|
63
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
52
64
|
}
|
|
53
65
|
/**
|
|
54
66
|
* Componente de branding que exibe crédito "fornecido por LÉdipO.eti.br".
|
|
@@ -611,6 +623,20 @@ interface CookieBannerProps {
|
|
|
611
623
|
* ```
|
|
612
624
|
*/
|
|
613
625
|
PaperProps?: Partial<PaperProps>;
|
|
626
|
+
/**
|
|
627
|
+
* Textos customizados para o banner.
|
|
628
|
+
* Permite sobrescrever textos do contexto e aplicar i18n localmente.
|
|
629
|
+
*/
|
|
630
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
631
|
+
/**
|
|
632
|
+
* Idioma local para resolver `texts.i18n`.
|
|
633
|
+
* Se omitido, usa o idioma do contexto (quando configurado no Provider).
|
|
634
|
+
*/
|
|
635
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
636
|
+
/**
|
|
637
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
638
|
+
*/
|
|
639
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
614
640
|
}
|
|
615
641
|
/**
|
|
616
642
|
* Banner principal de consentimento LGPD que solicita decisão do usuário sobre cookies.
|
|
@@ -703,7 +729,7 @@ interface CookieBannerProps {
|
|
|
703
729
|
* @public
|
|
704
730
|
* @since 0.1.0
|
|
705
731
|
*/
|
|
706
|
-
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
732
|
+
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, texts: textsProp, language, textVariant, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
707
733
|
|
|
708
734
|
/**
|
|
709
735
|
* Propriedades para customizar o comportamento e aparência do FloatingPreferencesButton.
|
|
@@ -848,6 +874,18 @@ interface FloatingPreferencesButtonProps {
|
|
|
848
874
|
* @defaultValue false
|
|
849
875
|
*/
|
|
850
876
|
hideWhenConsented?: boolean;
|
|
877
|
+
/**
|
|
878
|
+
* Textos customizados para o botão flutuante.
|
|
879
|
+
*/
|
|
880
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
881
|
+
/**
|
|
882
|
+
* Idioma local para resolver `texts.i18n`.
|
|
883
|
+
*/
|
|
884
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
885
|
+
/**
|
|
886
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
887
|
+
*/
|
|
888
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
851
889
|
}
|
|
852
890
|
/**
|
|
853
891
|
* Componente interno do botão flutuante de preferências.
|
|
@@ -857,7 +895,7 @@ interface FloatingPreferencesButtonProps {
|
|
|
857
895
|
* @returns {JSX.Element | null} Elemento JSX do botão ou null se oculto.
|
|
858
896
|
* @remarks Memoiza estilos de posição para performance. Usa design tokens defensivamente.
|
|
859
897
|
*/
|
|
860
|
-
declare function FloatingPreferencesButtonComponent({ position, offset, icon, tooltip, FabProps, hideWhenConsented, }: Readonly<FloatingPreferencesButtonProps>): react_jsx_runtime.JSX.Element | null;
|
|
898
|
+
declare function FloatingPreferencesButtonComponent({ position, offset, icon, tooltip, FabProps, hideWhenConsented, texts: textsProp, language, textVariant, }: Readonly<FloatingPreferencesButtonProps>): react_jsx_runtime.JSX.Element | null;
|
|
861
899
|
/**
|
|
862
900
|
* Botão flutuante (FAB) para reabrir o modal de preferências de consentimento LGPD.
|
|
863
901
|
*
|
|
@@ -1096,6 +1134,19 @@ interface PreferencesModalProps {
|
|
|
1096
1134
|
* @defaultValue undefined (usa função do contexto)
|
|
1097
1135
|
*/
|
|
1098
1136
|
closePreferences?: () => void;
|
|
1137
|
+
/**
|
|
1138
|
+
* Textos customizados para o modal.
|
|
1139
|
+
* Permite sobrescrever textos do contexto e aplicar i18n localmente.
|
|
1140
|
+
*/
|
|
1141
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Idioma local para resolver `texts.i18n`.
|
|
1144
|
+
*/
|
|
1145
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
1146
|
+
/**
|
|
1147
|
+
* Variação de tom local para resolver `texts.variants`.
|
|
1148
|
+
*/
|
|
1149
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
1099
1150
|
}
|
|
1100
1151
|
/**
|
|
1101
1152
|
* Modal de preferências de consentimento LGPD que permite ao usuário ajustar suas escolhas.
|
|
@@ -1209,6 +1260,6 @@ interface PreferencesModalProps {
|
|
|
1209
1260
|
* @see {@link PreferencesModalProps} - Interface completa de propriedades
|
|
1210
1261
|
* @see {@link getCookiesInfoForCategory} - Função que retorna informações de cookies
|
|
1211
1262
|
*/
|
|
1212
|
-
declare function PreferencesModal({ DialogProps, hideBranding, isModalOpen: isModalOpenProp, preferences: preferencesProp, setPreferences: setPreferencesProp, closePreferences: closePreferencesProp, }: Readonly<PreferencesModalProps>): react_jsx_runtime.JSX.Element;
|
|
1263
|
+
declare function PreferencesModal({ DialogProps, hideBranding, isModalOpen: isModalOpenProp, preferences: preferencesProp, setPreferences: setPreferencesProp, closePreferences: closePreferencesProp, texts: textsProp, language, textVariant, }: Readonly<PreferencesModalProps>): react_jsx_runtime.JSX.Element;
|
|
1213
1264
|
|
|
1214
1265
|
export { Branding, type BrandingProps, ConsentProvider, type ConsentProviderProps, CookieBanner, type CookieBannerProps, FloatingPreferencesButton, type FloatingPreferencesButtonProps, PreferencesModal, type PreferencesModalProps };
|
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) {
|
|
@@ -383,7 +435,7 @@ function PreferencesModal({
|
|
|
383
435
|
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
384
436
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
385
437
|
});
|
|
386
|
-
const resolveModalZIndex =
|
|
438
|
+
const resolveModalZIndex = React4.useCallback(
|
|
387
439
|
(theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
|
|
388
440
|
[designTokens?.layout?.zIndex?.modal]
|
|
389
441
|
);
|
|
@@ -429,6 +481,10 @@ function PreferencesModal({
|
|
|
429
481
|
const namesFromGuidance = full?.cookies ?? [];
|
|
430
482
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
431
483
|
const descriptors = getCookiesInfoForCategory(category.id, used);
|
|
484
|
+
const tableHeaders = texts.cookieDetails?.tableHeaders;
|
|
485
|
+
const toggleDetailsText = texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes";
|
|
486
|
+
const scriptLabelPrefix = texts.cookieDetails?.scriptLabelPrefix ?? "(script) ";
|
|
487
|
+
const scriptPurpose = texts.cookieDetails?.scriptPurpose ?? "Script de integra\xE7\xE3o ativo";
|
|
432
488
|
const enrichedDescriptors = descriptors.map((desc) => {
|
|
433
489
|
if (desc.purpose && desc.duration && desc.provider) {
|
|
434
490
|
return desc;
|
|
@@ -449,8 +505,8 @@ function PreferencesModal({
|
|
|
449
505
|
if (merged.length === 0) {
|
|
450
506
|
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
451
507
|
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
452
|
-
name:
|
|
453
|
-
purpose:
|
|
508
|
+
name: `${scriptLabelPrefix}${id}`,
|
|
509
|
+
purpose: scriptPurpose,
|
|
454
510
|
duration: "-",
|
|
455
511
|
provider: "-"
|
|
456
512
|
}));
|
|
@@ -476,13 +532,13 @@ function PreferencesModal({
|
|
|
476
532
|
}
|
|
477
533
|
),
|
|
478
534
|
/* @__PURE__ */ jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
479
|
-
/* @__PURE__ */ jsx("summary", { children:
|
|
535
|
+
/* @__PURE__ */ jsx("summary", { children: toggleDetailsText }),
|
|
480
536
|
/* @__PURE__ */ jsx(Box2, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
481
537
|
/* @__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" })
|
|
538
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.name ?? "Cookie" }),
|
|
539
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.purpose ?? "Finalidade" }),
|
|
540
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
541
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.provider ?? "Fornecedor" })
|
|
486
542
|
] }) }),
|
|
487
543
|
/* @__PURE__ */ jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
488
544
|
/* @__PURE__ */ jsx("td", { children: d.name }),
|
|
@@ -496,13 +552,13 @@ function PreferencesModal({
|
|
|
496
552
|
}),
|
|
497
553
|
/* @__PURE__ */ jsx(FormControlLabel, { control: /* @__PURE__ */ jsx(Switch, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
498
554
|
/* @__PURE__ */ jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
499
|
-
/* @__PURE__ */ jsx("summary", { children: "Ver detalhes" }),
|
|
555
|
+
/* @__PURE__ */ jsx("summary", { children: texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes" }),
|
|
500
556
|
/* @__PURE__ */ jsx(Box2, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
501
557
|
/* @__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" })
|
|
558
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.name ?? "Cookie" }),
|
|
559
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.purpose ?? "Finalidade" }),
|
|
560
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
561
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.provider ?? "Fornecedor" })
|
|
506
562
|
] }) }),
|
|
507
563
|
/* @__PURE__ */ jsx("tbody", { children: (() => {
|
|
508
564
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
@@ -525,7 +581,7 @@ function PreferencesModal({
|
|
|
525
581
|
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
526
582
|
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
527
583
|
] }),
|
|
528
|
-
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "modal" })
|
|
584
|
+
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "modal", texts: textsProp, language, textVariant })
|
|
529
585
|
] });
|
|
530
586
|
}
|
|
531
587
|
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) {
|
|
@@ -420,7 +472,7 @@ function PreferencesModal({
|
|
|
420
472
|
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
421
473
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
422
474
|
});
|
|
423
|
-
const resolveModalZIndex =
|
|
475
|
+
const resolveModalZIndex = React4__namespace.useCallback(
|
|
424
476
|
(theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
|
|
425
477
|
[designTokens?.layout?.zIndex?.modal]
|
|
426
478
|
);
|
|
@@ -466,6 +518,10 @@ function PreferencesModal({
|
|
|
466
518
|
const namesFromGuidance = full?.cookies ?? [];
|
|
467
519
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
468
520
|
const descriptors = core.getCookiesInfoForCategory(category.id, used);
|
|
521
|
+
const tableHeaders = texts.cookieDetails?.tableHeaders;
|
|
522
|
+
const toggleDetailsText = texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes";
|
|
523
|
+
const scriptLabelPrefix = texts.cookieDetails?.scriptLabelPrefix ?? "(script) ";
|
|
524
|
+
const scriptPurpose = texts.cookieDetails?.scriptPurpose ?? "Script de integra\xE7\xE3o ativo";
|
|
469
525
|
const enrichedDescriptors = descriptors.map((desc) => {
|
|
470
526
|
if (desc.purpose && desc.duration && desc.provider) {
|
|
471
527
|
return desc;
|
|
@@ -486,8 +542,8 @@ function PreferencesModal({
|
|
|
486
542
|
if (merged.length === 0) {
|
|
487
543
|
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
488
544
|
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
489
|
-
name:
|
|
490
|
-
purpose:
|
|
545
|
+
name: `${scriptLabelPrefix}${id}`,
|
|
546
|
+
purpose: scriptPurpose,
|
|
491
547
|
duration: "-",
|
|
492
548
|
provider: "-"
|
|
493
549
|
}));
|
|
@@ -513,13 +569,13 @@ function PreferencesModal({
|
|
|
513
569
|
}
|
|
514
570
|
),
|
|
515
571
|
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
516
|
-
/* @__PURE__ */ jsxRuntime.jsx("summary", { children:
|
|
572
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: toggleDetailsText }),
|
|
517
573
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
518
574
|
/* @__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" })
|
|
575
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.name ?? "Cookie" }),
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.purpose ?? "Finalidade" }),
|
|
577
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
578
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.provider ?? "Fornecedor" })
|
|
523
579
|
] }) }),
|
|
524
580
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
525
581
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: d.name }),
|
|
@@ -533,13 +589,13 @@ function PreferencesModal({
|
|
|
533
589
|
}),
|
|
534
590
|
/* @__PURE__ */ jsxRuntime.jsx(FormControlLabel__default.default, { control: /* @__PURE__ */ jsxRuntime.jsx(Switch__default.default, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
535
591
|
/* @__PURE__ */ jsxRuntime.jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
536
|
-
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Ver detalhes" }),
|
|
592
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes" }),
|
|
537
593
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
538
594
|
/* @__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" })
|
|
595
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.name ?? "Cookie" }),
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.purpose ?? "Finalidade" }),
|
|
597
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
598
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.provider ?? "Fornecedor" })
|
|
543
599
|
] }) }),
|
|
544
600
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: (() => {
|
|
545
601
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
@@ -562,7 +618,7 @@ function PreferencesModal({
|
|
|
562
618
|
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
563
619
|
/* @__PURE__ */ jsxRuntime.jsx(Button__default.default, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
564
620
|
] }),
|
|
565
|
-
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal" })
|
|
621
|
+
!hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "modal", texts: textsProp, language, textVariant })
|
|
566
622
|
] });
|
|
567
623
|
}
|
|
568
624
|
function ConsentProvider({
|
package/dist/ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Link from '@mui/material/Link';
|
|
2
2
|
import Typography from '@mui/material/Typography';
|
|
3
|
-
import { useConsentTexts, useDesignTokens, useConsent, logger, useConsentHydration, useCategories, getCookiesInfoForCategory, ConsentProvider as ConsentProvider$1 } from '@react-lgpd-consent/core';
|
|
4
|
-
import * as
|
|
3
|
+
import { useConsentTexts, resolveTexts, useDesignTokens, useConsent, logger, useConsentHydration, useCategories, getCookiesInfoForCategory, ConsentProvider as ConsentProvider$1 } from '@react-lgpd-consent/core';
|
|
4
|
+
import * as React4 from 'react';
|
|
5
5
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import { useTheme, ThemeProvider } from '@mui/material/styles';
|
|
7
7
|
import Box2 from '@mui/material/Box';
|
|
@@ -48,11 +48,22 @@ var linkStyles = {
|
|
|
48
48
|
textDecoration: "underline"
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var Branding =
|
|
51
|
+
var Branding = React4.memo(function Branding2({
|
|
52
52
|
variant,
|
|
53
|
-
hidden = false
|
|
53
|
+
hidden = false,
|
|
54
|
+
texts: textsProp,
|
|
55
|
+
language,
|
|
56
|
+
textVariant
|
|
54
57
|
}) {
|
|
55
|
-
const
|
|
58
|
+
const baseTexts = useConsentTexts();
|
|
59
|
+
const mergedTexts = React4.useMemo(
|
|
60
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
61
|
+
[baseTexts, textsProp]
|
|
62
|
+
);
|
|
63
|
+
const texts = React4.useMemo(
|
|
64
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
65
|
+
[mergedTexts, language, textVariant]
|
|
66
|
+
);
|
|
56
67
|
const designTokens = useDesignTokens();
|
|
57
68
|
if (hidden) return null;
|
|
58
69
|
return /* @__PURE__ */ jsxs(
|
|
@@ -90,10 +101,21 @@ function CookieBanner({
|
|
|
90
101
|
blocking = true,
|
|
91
102
|
hideBranding = false,
|
|
92
103
|
SnackbarProps,
|
|
93
|
-
PaperProps
|
|
104
|
+
PaperProps,
|
|
105
|
+
texts: textsProp,
|
|
106
|
+
language,
|
|
107
|
+
textVariant
|
|
94
108
|
}) {
|
|
95
109
|
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
96
|
-
const
|
|
110
|
+
const baseTexts = useConsentTexts();
|
|
111
|
+
const mergedTexts = React4.useMemo(
|
|
112
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
113
|
+
[baseTexts, textsProp]
|
|
114
|
+
);
|
|
115
|
+
const texts = React4.useMemo(
|
|
116
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
117
|
+
[mergedTexts, language, textVariant]
|
|
118
|
+
);
|
|
97
119
|
const isHydrated = useConsentHydration();
|
|
98
120
|
const designTokens = useDesignTokens();
|
|
99
121
|
const open = debug ? true : isHydrated && !consented;
|
|
@@ -168,7 +190,15 @@ function CookieBanner({
|
|
|
168
190
|
}
|
|
169
191
|
)
|
|
170
192
|
] }),
|
|
171
|
-
!hideBranding && /* @__PURE__ */ jsx(
|
|
193
|
+
!hideBranding && /* @__PURE__ */ jsx(
|
|
194
|
+
Branding,
|
|
195
|
+
{
|
|
196
|
+
variant: "banner",
|
|
197
|
+
texts: textsProp,
|
|
198
|
+
language,
|
|
199
|
+
textVariant
|
|
200
|
+
}
|
|
201
|
+
)
|
|
172
202
|
] }) });
|
|
173
203
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
174
204
|
const positionStyle = (theme) => ({
|
|
@@ -268,13 +298,24 @@ function FloatingPreferencesButtonComponent({
|
|
|
268
298
|
icon = /* @__PURE__ */ jsx(CookieOutlined, {}),
|
|
269
299
|
tooltip,
|
|
270
300
|
FabProps,
|
|
271
|
-
hideWhenConsented = false
|
|
301
|
+
hideWhenConsented = false,
|
|
302
|
+
texts: textsProp,
|
|
303
|
+
language,
|
|
304
|
+
textVariant
|
|
272
305
|
}) {
|
|
273
306
|
const { openPreferences, consented } = useConsent();
|
|
274
|
-
const
|
|
307
|
+
const baseTexts = useConsentTexts();
|
|
308
|
+
const mergedTexts = React4.useMemo(
|
|
309
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
310
|
+
[baseTexts, textsProp]
|
|
311
|
+
);
|
|
312
|
+
const texts = React4.useMemo(
|
|
313
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
314
|
+
[mergedTexts, language, textVariant]
|
|
315
|
+
);
|
|
275
316
|
const safeTheme = useThemeWithFallbacks();
|
|
276
317
|
const designTokens = useDesignTokens();
|
|
277
|
-
const positionStyles =
|
|
318
|
+
const positionStyles = React4.useMemo(() => {
|
|
278
319
|
const styles = {
|
|
279
320
|
position: "fixed",
|
|
280
321
|
zIndex: 1200
|
|
@@ -325,7 +366,7 @@ function FloatingPreferencesButtonComponent({
|
|
|
325
366
|
}
|
|
326
367
|
) });
|
|
327
368
|
}
|
|
328
|
-
var FloatingPreferencesButton =
|
|
369
|
+
var FloatingPreferencesButton = React4.memo(FloatingPreferencesButtonComponent);
|
|
329
370
|
FloatingPreferencesButton.displayName = "FloatingPreferencesButton";
|
|
330
371
|
function PreferencesModal({
|
|
331
372
|
DialogProps: DialogProps2,
|
|
@@ -333,26 +374,37 @@ function PreferencesModal({
|
|
|
333
374
|
isModalOpen: isModalOpenProp,
|
|
334
375
|
preferences: preferencesProp,
|
|
335
376
|
setPreferences: setPreferencesProp,
|
|
336
|
-
closePreferences: closePreferencesProp
|
|
377
|
+
closePreferences: closePreferencesProp,
|
|
378
|
+
texts: textsProp,
|
|
379
|
+
language,
|
|
380
|
+
textVariant
|
|
337
381
|
}) {
|
|
338
382
|
const hookValue = useConsent();
|
|
339
383
|
const preferences = preferencesProp ?? hookValue.preferences;
|
|
340
384
|
const setPreferences = setPreferencesProp ?? hookValue.setPreferences;
|
|
341
385
|
const closePreferences = closePreferencesProp ?? hookValue.closePreferences;
|
|
342
386
|
const isModalOpen = isModalOpenProp ?? hookValue.isModalOpen;
|
|
343
|
-
const
|
|
387
|
+
const baseTexts = useConsentTexts();
|
|
388
|
+
const mergedTexts = React4.useMemo(
|
|
389
|
+
() => ({ ...baseTexts, ...textsProp ?? {} }),
|
|
390
|
+
[baseTexts, textsProp]
|
|
391
|
+
);
|
|
392
|
+
const texts = React4.useMemo(
|
|
393
|
+
() => resolveTexts(mergedTexts, { language, variant: textVariant }),
|
|
394
|
+
[mergedTexts, language, textVariant]
|
|
395
|
+
);
|
|
344
396
|
const designTokens = useDesignTokens();
|
|
345
397
|
const { toggleableCategories, allCategories } = useCategories();
|
|
346
|
-
const getInitialPreferences =
|
|
398
|
+
const getInitialPreferences = React4.useCallback(() => {
|
|
347
399
|
const syncedPrefs = { necessary: true };
|
|
348
400
|
toggleableCategories.forEach((category) => {
|
|
349
401
|
syncedPrefs[category.id] = preferences[category.id] ?? false;
|
|
350
402
|
});
|
|
351
403
|
return syncedPrefs;
|
|
352
404
|
}, [preferences, toggleableCategories]);
|
|
353
|
-
const [tempPreferences, setTempPreferences] =
|
|
354
|
-
const wasOpenRef =
|
|
355
|
-
|
|
405
|
+
const [tempPreferences, setTempPreferences] = React4.useState(getInitialPreferences);
|
|
406
|
+
const wasOpenRef = React4.useRef(isModalOpen);
|
|
407
|
+
React4.useEffect(() => {
|
|
356
408
|
const justOpened = isModalOpen && !wasOpenRef.current;
|
|
357
409
|
wasOpenRef.current = isModalOpen;
|
|
358
410
|
if (justOpened) {
|
|
@@ -379,7 +431,7 @@ function PreferencesModal({
|
|
|
379
431
|
backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
|
|
380
432
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
381
433
|
});
|
|
382
|
-
const resolveModalZIndex =
|
|
434
|
+
const resolveModalZIndex = React4.useCallback(
|
|
383
435
|
(theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
|
|
384
436
|
[designTokens?.layout?.zIndex?.modal]
|
|
385
437
|
);
|
|
@@ -425,6 +477,10 @@ function PreferencesModal({
|
|
|
425
477
|
const namesFromGuidance = full?.cookies ?? [];
|
|
426
478
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
427
479
|
const descriptors = getCookiesInfoForCategory(category.id, used);
|
|
480
|
+
const tableHeaders = texts.cookieDetails?.tableHeaders;
|
|
481
|
+
const toggleDetailsText = texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes";
|
|
482
|
+
const scriptLabelPrefix = texts.cookieDetails?.scriptLabelPrefix ?? "(script) ";
|
|
483
|
+
const scriptPurpose = texts.cookieDetails?.scriptPurpose ?? "Script de integra\xE7\xE3o ativo";
|
|
428
484
|
const enrichedDescriptors = descriptors.map((desc) => {
|
|
429
485
|
if (desc.purpose && desc.duration && desc.provider) {
|
|
430
486
|
return desc;
|
|
@@ -445,8 +501,8 @@ function PreferencesModal({
|
|
|
445
501
|
if (merged.length === 0) {
|
|
446
502
|
const gmap = globalThis.__LGPD_INTEGRATIONS_MAP__ || {};
|
|
447
503
|
const scriptRows = Object.entries(gmap).filter(([, cat]) => cat === category.id).map(([id]) => ({
|
|
448
|
-
name:
|
|
449
|
-
purpose:
|
|
504
|
+
name: `${scriptLabelPrefix}${id}`,
|
|
505
|
+
purpose: scriptPurpose,
|
|
450
506
|
duration: "-",
|
|
451
507
|
provider: "-"
|
|
452
508
|
}));
|
|
@@ -472,13 +528,13 @@ function PreferencesModal({
|
|
|
472
528
|
}
|
|
473
529
|
),
|
|
474
530
|
/* @__PURE__ */ jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
475
|
-
/* @__PURE__ */ jsx("summary", { children:
|
|
531
|
+
/* @__PURE__ */ jsx("summary", { children: toggleDetailsText }),
|
|
476
532
|
/* @__PURE__ */ jsx(Box2, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
477
533
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
478
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
479
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
480
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
481
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
534
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.name ?? "Cookie" }),
|
|
535
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.purpose ?? "Finalidade" }),
|
|
536
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
537
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: tableHeaders?.provider ?? "Fornecedor" })
|
|
482
538
|
] }) }),
|
|
483
539
|
/* @__PURE__ */ jsx("tbody", { children: mergedFinal.map((d, idx) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
484
540
|
/* @__PURE__ */ jsx("td", { children: d.name }),
|
|
@@ -492,13 +548,13 @@ function PreferencesModal({
|
|
|
492
548
|
}),
|
|
493
549
|
/* @__PURE__ */ jsx(FormControlLabel, { control: /* @__PURE__ */ jsx(Switch, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn }),
|
|
494
550
|
/* @__PURE__ */ jsxs("details", { style: { marginLeft: 48 }, children: [
|
|
495
|
-
/* @__PURE__ */ jsx("summary", { children: "Ver detalhes" }),
|
|
551
|
+
/* @__PURE__ */ jsx("summary", { children: texts.cookieDetails?.toggleDetails?.expand ?? "Ver detalhes" }),
|
|
496
552
|
/* @__PURE__ */ jsx(Box2, { sx: { mt: 1 }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
497
553
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
498
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Cookie" }),
|
|
499
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Finalidade" }),
|
|
500
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Dura\xE7\xE3o" }),
|
|
501
|
-
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: "Fornecedor" })
|
|
554
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.name ?? "Cookie" }),
|
|
555
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.purpose ?? "Finalidade" }),
|
|
556
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.duration ?? "Dura\xE7\xE3o" }),
|
|
557
|
+
/* @__PURE__ */ jsx("th", { style: { textAlign: "left" }, children: texts.cookieDetails?.tableHeaders?.provider ?? "Fornecedor" })
|
|
502
558
|
] }) }),
|
|
503
559
|
/* @__PURE__ */ jsx("tbody", { children: (() => {
|
|
504
560
|
const used = globalThis.__LGPD_USED_INTEGRATIONS__ || [];
|
|
@@ -521,7 +577,7 @@ function PreferencesModal({
|
|
|
521
577
|
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
522
578
|
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
523
579
|
] }),
|
|
524
|
-
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "modal" })
|
|
580
|
+
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "modal", texts: textsProp, language, textVariant })
|
|
525
581
|
] });
|
|
526
582
|
}
|
|
527
583
|
function ConsentProvider({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-lgpd-consent/mui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Componentes Material-UI prontos para gerenciamento de consentimento LGPD",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lgpd",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@react-lgpd-consent/core": "^0.7.
|
|
66
|
+
"@react-lgpd-consent/core": "^0.7.2"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"clean": "rimraf dist",
|