@react-lgpd-consent/mui 0.7.2 → 0.9.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 +38 -5
- package/dist/index.cjs +37 -9
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +37 -9
- package/dist/ui.cjs +37 -9
- package/dist/ui.js +37 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -97,9 +97,9 @@ import { ConsentProvider } from '@react-lgpd-consent/mui'
|
|
|
97
97
|
### Presets ANPD
|
|
98
98
|
|
|
99
99
|
```tsx
|
|
100
|
-
import {
|
|
100
|
+
import { createAnpdCategoriesConfig } from '@react-lgpd-consent/mui'
|
|
101
101
|
|
|
102
|
-
const categories =
|
|
102
|
+
const categories = createAnpdCategoriesConfig({
|
|
103
103
|
include: ['analytics', 'marketing']
|
|
104
104
|
})
|
|
105
105
|
|
|
@@ -151,7 +151,10 @@ function CustomUI() {
|
|
|
151
151
|
<CookieBanner
|
|
152
152
|
blocking={true}
|
|
153
153
|
policyLinkUrl="/privacy"
|
|
154
|
-
|
|
154
|
+
position="bottom"
|
|
155
|
+
anchor="center"
|
|
156
|
+
offset={64}
|
|
157
|
+
SnackbarProps={{ autoHideDuration: null }}
|
|
155
158
|
/>
|
|
156
159
|
|
|
157
160
|
<FloatingPreferencesButton
|
|
@@ -161,6 +164,36 @@ function CustomUI() {
|
|
|
161
164
|
/>
|
|
162
165
|
```
|
|
163
166
|
|
|
167
|
+
### Posicionamento Configurável
|
|
168
|
+
|
|
169
|
+
Use as props `position`, `anchor` e `offset` para evitar colisões com footers fixos, chat widgets e outros elementos flutuantes:
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
<ConsentProvider
|
|
173
|
+
categories={{ enabledCategories: ['analytics'] }}
|
|
174
|
+
cookieBannerProps={{
|
|
175
|
+
position: 'bottom',
|
|
176
|
+
anchor: 'center',
|
|
177
|
+
offset: 72 // ajuste conforme necessário
|
|
178
|
+
}}
|
|
179
|
+
floatingPreferencesButtonProps={{
|
|
180
|
+
position: 'bottom-right',
|
|
181
|
+
offset: 96
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Para bloquear navegação até a decisão, use `blockingMode="hard"` no provider:
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
<ConsentProvider
|
|
190
|
+
categories={{ enabledCategories: ['analytics'] }}
|
|
191
|
+
blocking
|
|
192
|
+
blockingMode="hard"
|
|
193
|
+
blockingStrategy="provider"
|
|
194
|
+
/>
|
|
195
|
+
```
|
|
196
|
+
|
|
164
197
|
## 📚 Documentação
|
|
165
198
|
|
|
166
199
|
- [Documentação Principal](https://lucianoedipo.github.io/react-lgpd-consent/)
|
|
@@ -169,8 +202,8 @@ function CustomUI() {
|
|
|
169
202
|
|
|
170
203
|
## 🔗 Pacotes Relacionados
|
|
171
204
|
|
|
172
|
-
- [`@react-lgpd-consent/core`](../core) - Núcleo sem dependências de UI
|
|
173
|
-
- [`react-lgpd-consent`](../react-lgpd-consent) - Pacote agregador (core + mui)
|
|
205
|
+
- [`@react-lgpd-consent/core`](../core/README.md) - Núcleo sem dependências de UI
|
|
206
|
+
- [`react-lgpd-consent`](../react-lgpd-consent/README.md) - Pacote agregador (core + mui)
|
|
174
207
|
|
|
175
208
|
## 📄 Licença
|
|
176
209
|
|
package/dist/index.cjs
CHANGED
|
@@ -146,7 +146,10 @@ function CookieBanner({
|
|
|
146
146
|
PaperProps,
|
|
147
147
|
texts: textsProp,
|
|
148
148
|
language,
|
|
149
|
-
textVariant
|
|
149
|
+
textVariant,
|
|
150
|
+
position,
|
|
151
|
+
anchor,
|
|
152
|
+
offset
|
|
150
153
|
}) {
|
|
151
154
|
const { consented, acceptAll, rejectAll, openPreferences } = core.useConsent();
|
|
152
155
|
const baseTexts = core.useConsentTexts();
|
|
@@ -243,13 +246,30 @@ function CookieBanner({
|
|
|
243
246
|
)
|
|
244
247
|
] }) });
|
|
245
248
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
249
|
+
const resolvedPosition = position ?? (designTokens?.layout?.position === "top" ? "top" : "bottom");
|
|
250
|
+
const resolvedAnchor = anchor ?? "center";
|
|
251
|
+
const resolvedOffset = offset ?? 0;
|
|
252
|
+
const resolvedWidth = designTokens?.layout?.width?.desktop ?? "100%";
|
|
253
|
+
const resolveHorizontalPosition = (width) => {
|
|
254
|
+
const isFullWidth = width === "100%" || width === "100vw" || width === "100dvw";
|
|
255
|
+
if (isFullWidth) {
|
|
256
|
+
return { left: 0, right: 0 };
|
|
257
|
+
}
|
|
258
|
+
switch (resolvedAnchor) {
|
|
259
|
+
case "left":
|
|
260
|
+
return { left: 0 };
|
|
261
|
+
case "right":
|
|
262
|
+
return { right: 0 };
|
|
263
|
+
default:
|
|
264
|
+
return { left: "50%", transform: "translateX(-50%)" };
|
|
265
|
+
}
|
|
266
|
+
};
|
|
246
267
|
const positionStyle = (theme) => ({
|
|
247
268
|
position: "fixed",
|
|
248
269
|
zIndex: resolveBannerZIndex(theme),
|
|
249
|
-
...
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
270
|
+
...resolvedPosition === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset },
|
|
271
|
+
...resolveHorizontalPosition(resolvedWidth),
|
|
272
|
+
width: resolvedWidth,
|
|
253
273
|
p: 2
|
|
254
274
|
});
|
|
255
275
|
const backdropToken = designTokens?.layout?.backdrop;
|
|
@@ -303,15 +323,19 @@ function CookieBanner({
|
|
|
303
323
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: positionStyle, "data-testid": "lgpd-cookie-banner-wrapper", children: bannerContent })
|
|
304
324
|
] });
|
|
305
325
|
}
|
|
326
|
+
const resolvedAnchorOrigin = {
|
|
327
|
+
vertical: SnackbarProps?.anchorOrigin?.vertical ?? resolvedPosition,
|
|
328
|
+
horizontal: SnackbarProps?.anchorOrigin?.horizontal ?? resolvedAnchor
|
|
329
|
+
};
|
|
330
|
+
const offsetSx = resolvedOffset > 0 ? resolvedAnchorOrigin.vertical === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset } : void 0;
|
|
331
|
+
const snackbarSx = offsetSx && SnackbarProps?.sx ? Array.isArray(SnackbarProps.sx) ? [offsetSx, ...SnackbarProps.sx] : [offsetSx, SnackbarProps.sx] : offsetSx ?? SnackbarProps?.sx;
|
|
306
332
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
307
333
|
Snackbar__default.default,
|
|
308
334
|
{
|
|
309
335
|
open,
|
|
310
|
-
anchorOrigin:
|
|
311
|
-
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
312
|
-
horizontal: "center"
|
|
313
|
-
},
|
|
336
|
+
anchorOrigin: resolvedAnchorOrigin,
|
|
314
337
|
...SnackbarProps,
|
|
338
|
+
sx: snackbarSx,
|
|
315
339
|
children: bannerContent
|
|
316
340
|
}
|
|
317
341
|
);
|
|
@@ -464,6 +488,7 @@ function PreferencesModal({
|
|
|
464
488
|
setTempPreferences(preferences);
|
|
465
489
|
closePreferences();
|
|
466
490
|
};
|
|
491
|
+
const descriptionId = "cookie-pref-description";
|
|
467
492
|
const modalTitleSx = (theme) => ({
|
|
468
493
|
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
469
494
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
@@ -488,11 +513,13 @@ function PreferencesModal({
|
|
|
488
513
|
...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
|
|
489
514
|
"data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
|
|
490
515
|
};
|
|
516
|
+
const ariaDescribedBy = dialogRest["aria-describedby"] ?? descriptionId;
|
|
491
517
|
const mergedDialogProps = {
|
|
492
518
|
open,
|
|
493
519
|
fullWidth: true,
|
|
494
520
|
maxWidth: "sm",
|
|
495
521
|
...dialogRest,
|
|
522
|
+
"aria-describedby": ariaDescribedBy,
|
|
496
523
|
slotProps: {
|
|
497
524
|
...dialogRest?.slotProps,
|
|
498
525
|
root: rootSlotProps
|
|
@@ -504,6 +531,7 @@ function PreferencesModal({
|
|
|
504
531
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
505
532
|
Typography__default.default,
|
|
506
533
|
{
|
|
534
|
+
id: descriptionId,
|
|
507
535
|
variant: "body2",
|
|
508
536
|
sx: (theme) => ({
|
|
509
537
|
mb: 2,
|
package/dist/index.d.cts
CHANGED
|
@@ -637,6 +637,21 @@ interface CookieBannerProps {
|
|
|
637
637
|
* Variação de tom local para resolver `texts.variants`.
|
|
638
638
|
*/
|
|
639
639
|
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
640
|
+
/**
|
|
641
|
+
* Posição vertical do banner (top/bottom).
|
|
642
|
+
* Sobrescreve `designTokens.layout.position` quando definido.
|
|
643
|
+
*/
|
|
644
|
+
position?: 'top' | 'bottom';
|
|
645
|
+
/**
|
|
646
|
+
* Âncora horizontal do banner (left/center/right).
|
|
647
|
+
* Útil para alinhar o snackbar ou banners com largura menor que 100%.
|
|
648
|
+
*/
|
|
649
|
+
anchor?: 'left' | 'center' | 'right';
|
|
650
|
+
/**
|
|
651
|
+
* Offset em px para afastar o banner das bordas da viewport.
|
|
652
|
+
* Exemplo: `offset={64}` empurra o banner 64px para cima quando `position="bottom"`.
|
|
653
|
+
*/
|
|
654
|
+
offset?: number;
|
|
640
655
|
}
|
|
641
656
|
/**
|
|
642
657
|
* Banner principal de consentimento LGPD que solicita decisão do usuário sobre cookies.
|
|
@@ -729,7 +744,7 @@ interface CookieBannerProps {
|
|
|
729
744
|
* @public
|
|
730
745
|
* @since 0.1.0
|
|
731
746
|
*/
|
|
732
|
-
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, texts: textsProp, language, textVariant, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
747
|
+
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, texts: textsProp, language, textVariant, position, anchor, offset, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
733
748
|
|
|
734
749
|
/**
|
|
735
750
|
* Propriedades para customizar o comportamento e aparência do FloatingPreferencesButton.
|
package/dist/index.d.ts
CHANGED
|
@@ -637,6 +637,21 @@ interface CookieBannerProps {
|
|
|
637
637
|
* Variação de tom local para resolver `texts.variants`.
|
|
638
638
|
*/
|
|
639
639
|
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
640
|
+
/**
|
|
641
|
+
* Posição vertical do banner (top/bottom).
|
|
642
|
+
* Sobrescreve `designTokens.layout.position` quando definido.
|
|
643
|
+
*/
|
|
644
|
+
position?: 'top' | 'bottom';
|
|
645
|
+
/**
|
|
646
|
+
* Âncora horizontal do banner (left/center/right).
|
|
647
|
+
* Útil para alinhar o snackbar ou banners com largura menor que 100%.
|
|
648
|
+
*/
|
|
649
|
+
anchor?: 'left' | 'center' | 'right';
|
|
650
|
+
/**
|
|
651
|
+
* Offset em px para afastar o banner das bordas da viewport.
|
|
652
|
+
* Exemplo: `offset={64}` empurra o banner 64px para cima quando `position="bottom"`.
|
|
653
|
+
*/
|
|
654
|
+
offset?: number;
|
|
640
655
|
}
|
|
641
656
|
/**
|
|
642
657
|
* Banner principal de consentimento LGPD que solicita decisão do usuário sobre cookies.
|
|
@@ -729,7 +744,7 @@ interface CookieBannerProps {
|
|
|
729
744
|
* @public
|
|
730
745
|
* @since 0.1.0
|
|
731
746
|
*/
|
|
732
|
-
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, texts: textsProp, language, textVariant, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
747
|
+
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, texts: textsProp, language, textVariant, position, anchor, offset, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
733
748
|
|
|
734
749
|
/**
|
|
735
750
|
* Propriedades para customizar o comportamento e aparência do FloatingPreferencesButton.
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,10 @@ function CookieBanner({
|
|
|
108
108
|
PaperProps,
|
|
109
109
|
texts: textsProp,
|
|
110
110
|
language,
|
|
111
|
-
textVariant
|
|
111
|
+
textVariant,
|
|
112
|
+
position,
|
|
113
|
+
anchor,
|
|
114
|
+
offset
|
|
112
115
|
}) {
|
|
113
116
|
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
114
117
|
const baseTexts = useConsentTexts();
|
|
@@ -205,13 +208,30 @@ function CookieBanner({
|
|
|
205
208
|
)
|
|
206
209
|
] }) });
|
|
207
210
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
211
|
+
const resolvedPosition = position ?? (designTokens?.layout?.position === "top" ? "top" : "bottom");
|
|
212
|
+
const resolvedAnchor = anchor ?? "center";
|
|
213
|
+
const resolvedOffset = offset ?? 0;
|
|
214
|
+
const resolvedWidth = designTokens?.layout?.width?.desktop ?? "100%";
|
|
215
|
+
const resolveHorizontalPosition = (width) => {
|
|
216
|
+
const isFullWidth = width === "100%" || width === "100vw" || width === "100dvw";
|
|
217
|
+
if (isFullWidth) {
|
|
218
|
+
return { left: 0, right: 0 };
|
|
219
|
+
}
|
|
220
|
+
switch (resolvedAnchor) {
|
|
221
|
+
case "left":
|
|
222
|
+
return { left: 0 };
|
|
223
|
+
case "right":
|
|
224
|
+
return { right: 0 };
|
|
225
|
+
default:
|
|
226
|
+
return { left: "50%", transform: "translateX(-50%)" };
|
|
227
|
+
}
|
|
228
|
+
};
|
|
208
229
|
const positionStyle = (theme) => ({
|
|
209
230
|
position: "fixed",
|
|
210
231
|
zIndex: resolveBannerZIndex(theme),
|
|
211
|
-
...
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
232
|
+
...resolvedPosition === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset },
|
|
233
|
+
...resolveHorizontalPosition(resolvedWidth),
|
|
234
|
+
width: resolvedWidth,
|
|
215
235
|
p: 2
|
|
216
236
|
});
|
|
217
237
|
const backdropToken = designTokens?.layout?.backdrop;
|
|
@@ -265,15 +285,19 @@ function CookieBanner({
|
|
|
265
285
|
/* @__PURE__ */ jsx(Box2, { sx: positionStyle, "data-testid": "lgpd-cookie-banner-wrapper", children: bannerContent })
|
|
266
286
|
] });
|
|
267
287
|
}
|
|
288
|
+
const resolvedAnchorOrigin = {
|
|
289
|
+
vertical: SnackbarProps?.anchorOrigin?.vertical ?? resolvedPosition,
|
|
290
|
+
horizontal: SnackbarProps?.anchorOrigin?.horizontal ?? resolvedAnchor
|
|
291
|
+
};
|
|
292
|
+
const offsetSx = resolvedOffset > 0 ? resolvedAnchorOrigin.vertical === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset } : void 0;
|
|
293
|
+
const snackbarSx = offsetSx && SnackbarProps?.sx ? Array.isArray(SnackbarProps.sx) ? [offsetSx, ...SnackbarProps.sx] : [offsetSx, SnackbarProps.sx] : offsetSx ?? SnackbarProps?.sx;
|
|
268
294
|
return /* @__PURE__ */ jsx(
|
|
269
295
|
Snackbar,
|
|
270
296
|
{
|
|
271
297
|
open,
|
|
272
|
-
anchorOrigin:
|
|
273
|
-
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
274
|
-
horizontal: "center"
|
|
275
|
-
},
|
|
298
|
+
anchorOrigin: resolvedAnchorOrigin,
|
|
276
299
|
...SnackbarProps,
|
|
300
|
+
sx: snackbarSx,
|
|
277
301
|
children: bannerContent
|
|
278
302
|
}
|
|
279
303
|
);
|
|
@@ -426,6 +450,7 @@ function PreferencesModal({
|
|
|
426
450
|
setTempPreferences(preferences);
|
|
427
451
|
closePreferences();
|
|
428
452
|
};
|
|
453
|
+
const descriptionId = "cookie-pref-description";
|
|
429
454
|
const modalTitleSx = (theme) => ({
|
|
430
455
|
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
431
456
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
@@ -450,11 +475,13 @@ function PreferencesModal({
|
|
|
450
475
|
...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
|
|
451
476
|
"data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
|
|
452
477
|
};
|
|
478
|
+
const ariaDescribedBy = dialogRest["aria-describedby"] ?? descriptionId;
|
|
453
479
|
const mergedDialogProps = {
|
|
454
480
|
open,
|
|
455
481
|
fullWidth: true,
|
|
456
482
|
maxWidth: "sm",
|
|
457
483
|
...dialogRest,
|
|
484
|
+
"aria-describedby": ariaDescribedBy,
|
|
458
485
|
slotProps: {
|
|
459
486
|
...dialogRest?.slotProps,
|
|
460
487
|
root: rootSlotProps
|
|
@@ -466,6 +493,7 @@ function PreferencesModal({
|
|
|
466
493
|
/* @__PURE__ */ jsx(
|
|
467
494
|
Typography,
|
|
468
495
|
{
|
|
496
|
+
id: descriptionId,
|
|
469
497
|
variant: "body2",
|
|
470
498
|
sx: (theme) => ({
|
|
471
499
|
mb: 2,
|
package/dist/ui.cjs
CHANGED
|
@@ -145,7 +145,10 @@ function CookieBanner({
|
|
|
145
145
|
PaperProps,
|
|
146
146
|
texts: textsProp,
|
|
147
147
|
language,
|
|
148
|
-
textVariant
|
|
148
|
+
textVariant,
|
|
149
|
+
position,
|
|
150
|
+
anchor,
|
|
151
|
+
offset
|
|
149
152
|
}) {
|
|
150
153
|
const { consented, acceptAll, rejectAll, openPreferences } = core.useConsent();
|
|
151
154
|
const baseTexts = core.useConsentTexts();
|
|
@@ -242,13 +245,30 @@ function CookieBanner({
|
|
|
242
245
|
)
|
|
243
246
|
] }) });
|
|
244
247
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
248
|
+
const resolvedPosition = position ?? (designTokens?.layout?.position === "top" ? "top" : "bottom");
|
|
249
|
+
const resolvedAnchor = anchor ?? "center";
|
|
250
|
+
const resolvedOffset = offset ?? 0;
|
|
251
|
+
const resolvedWidth = designTokens?.layout?.width?.desktop ?? "100%";
|
|
252
|
+
const resolveHorizontalPosition = (width) => {
|
|
253
|
+
const isFullWidth = width === "100%" || width === "100vw" || width === "100dvw";
|
|
254
|
+
if (isFullWidth) {
|
|
255
|
+
return { left: 0, right: 0 };
|
|
256
|
+
}
|
|
257
|
+
switch (resolvedAnchor) {
|
|
258
|
+
case "left":
|
|
259
|
+
return { left: 0 };
|
|
260
|
+
case "right":
|
|
261
|
+
return { right: 0 };
|
|
262
|
+
default:
|
|
263
|
+
return { left: "50%", transform: "translateX(-50%)" };
|
|
264
|
+
}
|
|
265
|
+
};
|
|
245
266
|
const positionStyle = (theme) => ({
|
|
246
267
|
position: "fixed",
|
|
247
268
|
zIndex: resolveBannerZIndex(theme),
|
|
248
|
-
...
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
269
|
+
...resolvedPosition === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset },
|
|
270
|
+
...resolveHorizontalPosition(resolvedWidth),
|
|
271
|
+
width: resolvedWidth,
|
|
252
272
|
p: 2
|
|
253
273
|
});
|
|
254
274
|
const backdropToken = designTokens?.layout?.backdrop;
|
|
@@ -302,15 +322,19 @@ function CookieBanner({
|
|
|
302
322
|
/* @__PURE__ */ jsxRuntime.jsx(Box2__default.default, { sx: positionStyle, "data-testid": "lgpd-cookie-banner-wrapper", children: bannerContent })
|
|
303
323
|
] });
|
|
304
324
|
}
|
|
325
|
+
const resolvedAnchorOrigin = {
|
|
326
|
+
vertical: SnackbarProps?.anchorOrigin?.vertical ?? resolvedPosition,
|
|
327
|
+
horizontal: SnackbarProps?.anchorOrigin?.horizontal ?? resolvedAnchor
|
|
328
|
+
};
|
|
329
|
+
const offsetSx = resolvedOffset > 0 ? resolvedAnchorOrigin.vertical === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset } : void 0;
|
|
330
|
+
const snackbarSx = offsetSx && SnackbarProps?.sx ? Array.isArray(SnackbarProps.sx) ? [offsetSx, ...SnackbarProps.sx] : [offsetSx, SnackbarProps.sx] : offsetSx ?? SnackbarProps?.sx;
|
|
305
331
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
306
332
|
Snackbar__default.default,
|
|
307
333
|
{
|
|
308
334
|
open,
|
|
309
|
-
anchorOrigin:
|
|
310
|
-
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
311
|
-
horizontal: "center"
|
|
312
|
-
},
|
|
335
|
+
anchorOrigin: resolvedAnchorOrigin,
|
|
313
336
|
...SnackbarProps,
|
|
337
|
+
sx: snackbarSx,
|
|
314
338
|
children: bannerContent
|
|
315
339
|
}
|
|
316
340
|
);
|
|
@@ -463,6 +487,7 @@ function PreferencesModal({
|
|
|
463
487
|
setTempPreferences(preferences);
|
|
464
488
|
closePreferences();
|
|
465
489
|
};
|
|
490
|
+
const descriptionId = "cookie-pref-description";
|
|
466
491
|
const modalTitleSx = (theme) => ({
|
|
467
492
|
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
468
493
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
@@ -487,11 +512,13 @@ function PreferencesModal({
|
|
|
487
512
|
...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
|
|
488
513
|
"data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
|
|
489
514
|
};
|
|
515
|
+
const ariaDescribedBy = dialogRest["aria-describedby"] ?? descriptionId;
|
|
490
516
|
const mergedDialogProps = {
|
|
491
517
|
open,
|
|
492
518
|
fullWidth: true,
|
|
493
519
|
maxWidth: "sm",
|
|
494
520
|
...dialogRest,
|
|
521
|
+
"aria-describedby": ariaDescribedBy,
|
|
495
522
|
slotProps: {
|
|
496
523
|
...dialogRest?.slotProps,
|
|
497
524
|
root: rootSlotProps
|
|
@@ -503,6 +530,7 @@ function PreferencesModal({
|
|
|
503
530
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
504
531
|
Typography__default.default,
|
|
505
532
|
{
|
|
533
|
+
id: descriptionId,
|
|
506
534
|
variant: "body2",
|
|
507
535
|
sx: (theme) => ({
|
|
508
536
|
mb: 2,
|
package/dist/ui.js
CHANGED
|
@@ -104,7 +104,10 @@ function CookieBanner({
|
|
|
104
104
|
PaperProps,
|
|
105
105
|
texts: textsProp,
|
|
106
106
|
language,
|
|
107
|
-
textVariant
|
|
107
|
+
textVariant,
|
|
108
|
+
position,
|
|
109
|
+
anchor,
|
|
110
|
+
offset
|
|
108
111
|
}) {
|
|
109
112
|
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
110
113
|
const baseTexts = useConsentTexts();
|
|
@@ -201,13 +204,30 @@ function CookieBanner({
|
|
|
201
204
|
)
|
|
202
205
|
] }) });
|
|
203
206
|
const resolveBannerZIndex = (theme) => designTokens?.layout?.zIndex?.banner ?? theme?.zIndex?.snackbar ?? 1400;
|
|
207
|
+
const resolvedPosition = position ?? (designTokens?.layout?.position === "top" ? "top" : "bottom");
|
|
208
|
+
const resolvedAnchor = anchor ?? "center";
|
|
209
|
+
const resolvedOffset = offset ?? 0;
|
|
210
|
+
const resolvedWidth = designTokens?.layout?.width?.desktop ?? "100%";
|
|
211
|
+
const resolveHorizontalPosition = (width) => {
|
|
212
|
+
const isFullWidth = width === "100%" || width === "100vw" || width === "100dvw";
|
|
213
|
+
if (isFullWidth) {
|
|
214
|
+
return { left: 0, right: 0 };
|
|
215
|
+
}
|
|
216
|
+
switch (resolvedAnchor) {
|
|
217
|
+
case "left":
|
|
218
|
+
return { left: 0 };
|
|
219
|
+
case "right":
|
|
220
|
+
return { right: 0 };
|
|
221
|
+
default:
|
|
222
|
+
return { left: "50%", transform: "translateX(-50%)" };
|
|
223
|
+
}
|
|
224
|
+
};
|
|
204
225
|
const positionStyle = (theme) => ({
|
|
205
226
|
position: "fixed",
|
|
206
227
|
zIndex: resolveBannerZIndex(theme),
|
|
207
|
-
...
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
228
|
+
...resolvedPosition === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset },
|
|
229
|
+
...resolveHorizontalPosition(resolvedWidth),
|
|
230
|
+
width: resolvedWidth,
|
|
211
231
|
p: 2
|
|
212
232
|
});
|
|
213
233
|
const backdropToken = designTokens?.layout?.backdrop;
|
|
@@ -261,15 +281,19 @@ function CookieBanner({
|
|
|
261
281
|
/* @__PURE__ */ jsx(Box2, { sx: positionStyle, "data-testid": "lgpd-cookie-banner-wrapper", children: bannerContent })
|
|
262
282
|
] });
|
|
263
283
|
}
|
|
284
|
+
const resolvedAnchorOrigin = {
|
|
285
|
+
vertical: SnackbarProps?.anchorOrigin?.vertical ?? resolvedPosition,
|
|
286
|
+
horizontal: SnackbarProps?.anchorOrigin?.horizontal ?? resolvedAnchor
|
|
287
|
+
};
|
|
288
|
+
const offsetSx = resolvedOffset > 0 ? resolvedAnchorOrigin.vertical === "top" ? { top: resolvedOffset } : { bottom: resolvedOffset } : void 0;
|
|
289
|
+
const snackbarSx = offsetSx && SnackbarProps?.sx ? Array.isArray(SnackbarProps.sx) ? [offsetSx, ...SnackbarProps.sx] : [offsetSx, SnackbarProps.sx] : offsetSx ?? SnackbarProps?.sx;
|
|
264
290
|
return /* @__PURE__ */ jsx(
|
|
265
291
|
Snackbar,
|
|
266
292
|
{
|
|
267
293
|
open,
|
|
268
|
-
anchorOrigin:
|
|
269
|
-
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
270
|
-
horizontal: "center"
|
|
271
|
-
},
|
|
294
|
+
anchorOrigin: resolvedAnchorOrigin,
|
|
272
295
|
...SnackbarProps,
|
|
296
|
+
sx: snackbarSx,
|
|
273
297
|
children: bannerContent
|
|
274
298
|
}
|
|
275
299
|
);
|
|
@@ -422,6 +446,7 @@ function PreferencesModal({
|
|
|
422
446
|
setTempPreferences(preferences);
|
|
423
447
|
closePreferences();
|
|
424
448
|
};
|
|
449
|
+
const descriptionId = "cookie-pref-description";
|
|
425
450
|
const modalTitleSx = (theme) => ({
|
|
426
451
|
fontSize: designTokens?.typography?.fontSize?.modal ?? void 0,
|
|
427
452
|
color: designTokens?.colors?.text ?? theme.palette.text.primary
|
|
@@ -446,11 +471,13 @@ function PreferencesModal({
|
|
|
446
471
|
...modalZIndexToken ? { style: { zIndex: modalZIndexToken } } : {},
|
|
447
472
|
"data-testid": dialogRest?.slotProps?.root?.["data-testid"] ?? "lgpd-preferences-modal-root"
|
|
448
473
|
};
|
|
474
|
+
const ariaDescribedBy = dialogRest["aria-describedby"] ?? descriptionId;
|
|
449
475
|
const mergedDialogProps = {
|
|
450
476
|
open,
|
|
451
477
|
fullWidth: true,
|
|
452
478
|
maxWidth: "sm",
|
|
453
479
|
...dialogRest,
|
|
480
|
+
"aria-describedby": ariaDescribedBy,
|
|
454
481
|
slotProps: {
|
|
455
482
|
...dialogRest?.slotProps,
|
|
456
483
|
root: rootSlotProps
|
|
@@ -462,6 +489,7 @@ function PreferencesModal({
|
|
|
462
489
|
/* @__PURE__ */ jsx(
|
|
463
490
|
Typography,
|
|
464
491
|
{
|
|
492
|
+
id: descriptionId,
|
|
465
493
|
variant: "body2",
|
|
466
494
|
sx: (theme) => ({
|
|
467
495
|
mb: 2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-lgpd-consent/mui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
66
|
+
"@react-lgpd-consent/core": "^0.9.0"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"clean": "rimraf dist",
|