@react-lgpd-consent/mui 0.6.1 → 0.7.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 CHANGED
@@ -70,6 +70,40 @@ function App() {
70
70
  }
71
71
  ```
72
72
 
73
+ ## 🆕 Novidades v0.7.0
74
+
75
+ ### Callbacks de Lifecycle
76
+
77
+ Monitore eventos para auditoria:
78
+
79
+ ```tsx
80
+ import { ConsentProvider } from '@react-lgpd-consent/mui'
81
+
82
+ <ConsentProvider
83
+ onConsentInit={(state) => console.log('Inicializado:', state)}
84
+ onConsentChange={(current, prev) => console.log('Mudou:', current)}
85
+ onAuditLog={(entry) => {
86
+ fetch('/api/audit', { method: 'POST', body: JSON.stringify(entry) })
87
+ }}
88
+ >
89
+ ```
90
+
91
+ ### Presets ANPD
92
+
93
+ ```tsx
94
+ import { createAnpdCategories } from '@react-lgpd-consent/mui'
95
+
96
+ const categories = createAnpdCategories({
97
+ include: ['analytics', 'marketing']
98
+ })
99
+
100
+ <ConsentProvider categories={categories}>
101
+ ```
102
+
103
+ 📖 **Documentação completa:** [API.md](../react-lgpd-consent/API.md) | [TROUBLESHOOTING.md](../../TROUBLESHOOTING.md)
104
+
105
+ ---
106
+
73
107
  ### Uso Headless (Avançado)
74
108
 
75
109
  Se você quiser controle total sobre a UI:
package/dist/index.cjs CHANGED
@@ -211,15 +211,16 @@ function CookieBanner({
211
211
  ] }),
212
212
  !hideBranding && /* @__PURE__ */ jsxRuntime.jsx(Branding, { variant: "banner" })
213
213
  ] }) });
214
- const positionStyle = {
214
+ const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
215
+ const positionStyle = (theme) => ({
215
216
  position: "fixed",
216
- zIndex: 1300,
217
+ zIndex: resolveBannerZIndex(theme),
217
218
  ...designTokens?.layout?.position === "top" ? { top: 0 } : { bottom: 0 },
218
219
  left: 0,
219
220
  right: 0,
220
221
  width: designTokens?.layout?.width?.desktop ?? "100%",
221
222
  p: 2
222
- };
223
+ });
223
224
  const backdropToken = designTokens?.layout?.backdrop;
224
225
  const resolveBackdropColor = (theme) => {
225
226
  if (backdropToken === false) return "transparent";
@@ -235,8 +236,8 @@ function CookieBanner({
235
236
  };
236
237
  const isSafeRoute = (() => {
237
238
  try {
238
- if (typeof window === "undefined") return false;
239
- const current = new URL(window.location.href);
239
+ if (globalThis?.window === void 0) return false;
240
+ const current = new URL(globalThis.window.location.href);
240
241
  const safeUrls = [policyLinkUrl, termsLinkUrl].filter(Boolean);
241
242
  return safeUrls.some((u) => {
242
243
  try {
@@ -263,12 +264,12 @@ function CookieBanner({
263
264
  right: 0,
264
265
  bottom: 0,
265
266
  backgroundColor: resolveBackdropColor(theme),
266
- zIndex: 1299
267
+ zIndex: designTokens?.layout?.zIndex?.backdrop ?? (resolveBannerZIndex(theme) ? resolveBannerZIndex(theme) - 1 : 1299)
267
268
  }),
268
269
  "data-testid": "lgpd-cookie-banner-overlay"
269
270
  }
270
271
  ),
271
- /* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: positionStyle, children: bannerContent })
272
+ /* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: positionStyle, "data-testid": "lgpd-cookie-banner-wrapper", children: bannerContent })
272
273
  ] });
273
274
  }
274
275
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -401,7 +402,8 @@ function PreferencesModal({
401
402
  });
402
403
  }
403
404
  }, [isModalOpen, getInitialPreferences]);
404
- const open = DialogProps2?.open ?? isModalOpen ?? false;
405
+ const { open: dialogOpenProp, ...dialogRest } = DialogProps2 ?? {};
406
+ const open = dialogOpenProp ?? isModalOpen ?? false;
405
407
  const handleSave = () => {
406
408
  setPreferences(tempPreferences);
407
409
  };
@@ -418,7 +420,32 @@ function PreferencesModal({
418
420
  backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
419
421
  color: designTokens?.colors?.text ?? theme.palette.text.primary
420
422
  });
421
- return /* @__PURE__ */ jsxRuntime.jsxs(Dialog__default.default, { "aria-labelledby": "cookie-pref-title", open, onClose: handleCancel, ...DialogProps2, children: [
423
+ const resolveModalZIndex = React3__namespace.useCallback(
424
+ (theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
425
+ [designTokens?.layout?.zIndex?.modal]
426
+ );
427
+ const modalZIndexToken = designTokens?.layout?.zIndex?.modal;
428
+ const rootSx = [
429
+ DialogProps2?.slotProps?.root && DialogProps2.slotProps.root.sx,
430
+ (theme) => ({ zIndex: resolveModalZIndex(theme) })
431
+ ].filter(Boolean);
432
+ const rootSlotProps = {
433
+ ...dialogRest?.slotProps?.root,
434
+ sx: rootSx,
435
+ ...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
436
+ "data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
437
+ };
438
+ const mergedDialogProps = {
439
+ open,
440
+ fullWidth: true,
441
+ maxWidth: "sm",
442
+ ...dialogRest,
443
+ slotProps: {
444
+ ...dialogRest?.slotProps,
445
+ root: rootSlotProps
446
+ }
447
+ };
448
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog__default.default, { "aria-labelledby": "cookie-pref-title", onClose: handleCancel, ...mergedDialogProps, children: [
422
449
  /* @__PURE__ */ jsxRuntime.jsx(DialogTitle__default.default, { id: "cookie-pref-title", sx: modalTitleSx, children: texts.modalTitle }),
423
450
  /* @__PURE__ */ jsxRuntime.jsxs(DialogContent__default.default, { dividers: true, sx: modalContentSx, children: [
424
451
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -452,7 +479,7 @@ function PreferencesModal({
452
479
  });
453
480
  const merged = [
454
481
  ...enrichedDescriptors,
455
- ...namesFromGuidance.filter((n) => !enrichedDescriptors.find((d) => d.name === n)).map((n) => ({ name: n, purpose: "-", duration: "-", provider: "-" }))
482
+ ...namesFromGuidance.filter((n) => !enrichedDescriptors.some((d) => d.name === n)).map((n) => ({ name: n, purpose: "-", duration: "-", provider: "-" }))
456
483
  ];
457
484
  let mergedFinal = merged;
458
485
  try {
package/dist/index.d.cts CHANGED
@@ -468,7 +468,7 @@ interface ConsentProviderProps extends ConsentProviderProps$1 {
468
468
  * @see {@link FloatingPreferencesButton} Para o botão flutuante usado por padrão
469
469
  * @see {@link https://mui.com/material-ui/customization/theming/ | MUI Theming Guide} Para customização de tema
470
470
  */
471
- declare function ConsentProvider({ disableDefaultModal, disableDefaultBanner, disableDefaultFloatingButton, PreferencesModalComponent, CookieBannerComponent, FloatingPreferencesButtonComponent, theme, hideBranding, cookieBannerProps, preferencesModalProps, floatingPreferencesButtonProps, children, ...coreProps }: ConsentProviderProps): react_jsx_runtime.JSX.Element;
471
+ declare function ConsentProvider({ disableDefaultModal, disableDefaultBanner, disableDefaultFloatingButton, PreferencesModalComponent, CookieBannerComponent, FloatingPreferencesButtonComponent, theme, hideBranding, cookieBannerProps, preferencesModalProps, floatingPreferencesButtonProps, children, ...coreProps }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
472
472
  declare namespace ConsentProvider {
473
473
  var displayName: string;
474
474
  }
package/dist/index.d.ts CHANGED
@@ -468,7 +468,7 @@ interface ConsentProviderProps extends ConsentProviderProps$1 {
468
468
  * @see {@link FloatingPreferencesButton} Para o botão flutuante usado por padrão
469
469
  * @see {@link https://mui.com/material-ui/customization/theming/ | MUI Theming Guide} Para customização de tema
470
470
  */
471
- declare function ConsentProvider({ disableDefaultModal, disableDefaultBanner, disableDefaultFloatingButton, PreferencesModalComponent, CookieBannerComponent, FloatingPreferencesButtonComponent, theme, hideBranding, cookieBannerProps, preferencesModalProps, floatingPreferencesButtonProps, children, ...coreProps }: ConsentProviderProps): react_jsx_runtime.JSX.Element;
471
+ declare function ConsentProvider({ disableDefaultModal, disableDefaultBanner, disableDefaultFloatingButton, PreferencesModalComponent, CookieBannerComponent, FloatingPreferencesButtonComponent, theme, hideBranding, cookieBannerProps, preferencesModalProps, floatingPreferencesButtonProps, children, ...coreProps }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
472
472
  declare namespace ConsentProvider {
473
473
  var displayName: string;
474
474
  }
package/dist/index.js CHANGED
@@ -172,15 +172,16 @@ function CookieBanner({
172
172
  ] }),
173
173
  !hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "banner" })
174
174
  ] }) });
175
- const positionStyle = {
175
+ const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
176
+ const positionStyle = (theme) => ({
176
177
  position: "fixed",
177
- zIndex: 1300,
178
+ zIndex: resolveBannerZIndex(theme),
178
179
  ...designTokens?.layout?.position === "top" ? { top: 0 } : { bottom: 0 },
179
180
  left: 0,
180
181
  right: 0,
181
182
  width: designTokens?.layout?.width?.desktop ?? "100%",
182
183
  p: 2
183
- };
184
+ });
184
185
  const backdropToken = designTokens?.layout?.backdrop;
185
186
  const resolveBackdropColor = (theme) => {
186
187
  if (backdropToken === false) return "transparent";
@@ -196,8 +197,8 @@ function CookieBanner({
196
197
  };
197
198
  const isSafeRoute = (() => {
198
199
  try {
199
- if (typeof window === "undefined") return false;
200
- const current = new URL(window.location.href);
200
+ if (globalThis?.window === void 0) return false;
201
+ const current = new URL(globalThis.window.location.href);
201
202
  const safeUrls = [policyLinkUrl, termsLinkUrl].filter(Boolean);
202
203
  return safeUrls.some((u) => {
203
204
  try {
@@ -224,12 +225,12 @@ function CookieBanner({
224
225
  right: 0,
225
226
  bottom: 0,
226
227
  backgroundColor: resolveBackdropColor(theme),
227
- zIndex: 1299
228
+ zIndex: designTokens?.layout?.zIndex?.backdrop ?? (resolveBannerZIndex(theme) ? resolveBannerZIndex(theme) - 1 : 1299)
228
229
  }),
229
230
  "data-testid": "lgpd-cookie-banner-overlay"
230
231
  }
231
232
  ),
232
- /* @__PURE__ */ jsx(Box2, { sx: positionStyle, children: bannerContent })
233
+ /* @__PURE__ */ jsx(Box2, { sx: positionStyle, "data-testid": "lgpd-cookie-banner-wrapper", children: bannerContent })
233
234
  ] });
234
235
  }
235
236
  return /* @__PURE__ */ jsx(
@@ -362,7 +363,8 @@ function PreferencesModal({
362
363
  });
363
364
  }
364
365
  }, [isModalOpen, getInitialPreferences]);
365
- const open = DialogProps2?.open ?? isModalOpen ?? false;
366
+ const { open: dialogOpenProp, ...dialogRest } = DialogProps2 ?? {};
367
+ const open = dialogOpenProp ?? isModalOpen ?? false;
366
368
  const handleSave = () => {
367
369
  setPreferences(tempPreferences);
368
370
  };
@@ -379,7 +381,32 @@ function PreferencesModal({
379
381
  backgroundColor: designTokens?.colors?.background ?? theme.palette.background.paper,
380
382
  color: designTokens?.colors?.text ?? theme.palette.text.primary
381
383
  });
382
- return /* @__PURE__ */ jsxs(Dialog, { "aria-labelledby": "cookie-pref-title", open, onClose: handleCancel, ...DialogProps2, children: [
384
+ const resolveModalZIndex = React3.useCallback(
385
+ (theme) => designTokens?.layout?.zIndex?.modal ?? (theme?.zIndex?.modal ?? 1300) + 10,
386
+ [designTokens?.layout?.zIndex?.modal]
387
+ );
388
+ const modalZIndexToken = designTokens?.layout?.zIndex?.modal;
389
+ const rootSx = [
390
+ DialogProps2?.slotProps?.root && DialogProps2.slotProps.root.sx,
391
+ (theme) => ({ zIndex: resolveModalZIndex(theme) })
392
+ ].filter(Boolean);
393
+ const rootSlotProps = {
394
+ ...dialogRest?.slotProps?.root,
395
+ sx: rootSx,
396
+ ...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
397
+ "data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
398
+ };
399
+ const mergedDialogProps = {
400
+ open,
401
+ fullWidth: true,
402
+ maxWidth: "sm",
403
+ ...dialogRest,
404
+ slotProps: {
405
+ ...dialogRest?.slotProps,
406
+ root: rootSlotProps
407
+ }
408
+ };
409
+ return /* @__PURE__ */ jsxs(Dialog, { "aria-labelledby": "cookie-pref-title", onClose: handleCancel, ...mergedDialogProps, children: [
383
410
  /* @__PURE__ */ jsx(DialogTitle, { id: "cookie-pref-title", sx: modalTitleSx, children: texts.modalTitle }),
384
411
  /* @__PURE__ */ jsxs(DialogContent, { dividers: true, sx: modalContentSx, children: [
385
412
  /* @__PURE__ */ jsx(
@@ -413,7 +440,7 @@ function PreferencesModal({
413
440
  });
414
441
  const merged = [
415
442
  ...enrichedDescriptors,
416
- ...namesFromGuidance.filter((n) => !enrichedDescriptors.find((d) => d.name === n)).map((n) => ({ name: n, purpose: "-", duration: "-", provider: "-" }))
443
+ ...namesFromGuidance.filter((n) => !enrichedDescriptors.some((d) => d.name === n)).map((n) => ({ name: n, purpose: "-", duration: "-", provider: "-" }))
417
444
  ];
418
445
  let mergedFinal = merged;
419
446
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-lgpd-consent/mui",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Componentes Material-UI prontos para gerenciamento de consentimento LGPD/ANPD",
5
5
  "keywords": [
6
6
  "lgpd",
@@ -58,7 +58,7 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "@react-lgpd-consent/core": "^0.6.1"
61
+ "@react-lgpd-consent/core": "^0.7.0"
62
62
  },
63
63
  "scripts": {
64
64
  "clean": "rimraf dist",