react-lgpd-consent 0.2.5 → 0.3.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/COMPLIANCE.md +73 -287
- package/README.md +87 -667
- package/dist/{PreferencesModal-B6N62JYB.js → PreferencesModal-XCTM6WJN.js} +1 -1
- package/dist/{chunk-4LLZREFO.js → chunk-R3IKVZBC.js} +466 -225
- package/dist/index.cjs +732 -643
- package/dist/index.d.cts +141 -125
- package/dist/index.d.ts +141 -125
- package/dist/index.js +7 -182
- package/package.json +12 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { PaperProps } from '@mui/material/Paper';
|
|
3
|
-
import { SnackbarProps } from '@mui/material/Snackbar';
|
|
4
2
|
import { DialogProps } from '@mui/material/Dialog';
|
|
5
|
-
import { FabProps } from '@mui/material/Fab';
|
|
6
3
|
import * as React$1 from 'react';
|
|
7
4
|
import * as _mui_material_styles from '@mui/material/styles';
|
|
8
5
|
|
|
9
|
-
/**
|
|
10
|
-
* Props para o componente CookieBanner.
|
|
11
|
-
*
|
|
12
|
-
* @property policyLinkUrl URL da política de privacidade (opcional).
|
|
13
|
-
* @property debug Força exibição do banner para QA/debug (opcional).
|
|
14
|
-
* @property blocking Se true, bloqueia interação até decisão do usuário (default: true).
|
|
15
|
-
* @property hideBranding Se true, oculta o branding "fornecido por LÉdipO.eti.br" (opcional).
|
|
16
|
-
* @property SnackbarProps Props adicionais para o componente MUI Snackbar (opcional).
|
|
17
|
-
* @property PaperProps Props adicionais para o componente MUI Paper (opcional).
|
|
18
|
-
*/
|
|
19
|
-
interface CookieBannerProps {
|
|
20
|
-
policyLinkUrl?: string;
|
|
21
|
-
debug?: boolean;
|
|
22
|
-
blocking?: boolean;
|
|
23
|
-
hideBranding?: boolean;
|
|
24
|
-
SnackbarProps?: Partial<SnackbarProps>;
|
|
25
|
-
PaperProps?: Partial<PaperProps>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Banner de consentimento de cookies conforme LGPD.
|
|
29
|
-
*
|
|
30
|
-
* Exibe mensagem informativa, botões de ação e link para política de privacidade.
|
|
31
|
-
* Compatível com modo bloqueante (overlay) e não bloqueante (Snackbar).
|
|
32
|
-
*
|
|
33
|
-
* - Textos em pt-BR, customizáveis via contexto.
|
|
34
|
-
* - Acessível e responsivo.
|
|
35
|
-
* - Branding opcional.
|
|
36
|
-
*
|
|
37
|
-
* @param props Propriedades do banner de consentimento.
|
|
38
|
-
*/
|
|
39
|
-
declare function CookieBanner({ policyLinkUrl, debug, blocking, // Por padrão, bloqueia até decisão
|
|
40
|
-
hideBranding, SnackbarProps, PaperProps, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
41
|
-
|
|
42
6
|
/**
|
|
43
7
|
* Props para o componente PreferencesModal.
|
|
44
8
|
*
|
|
@@ -60,45 +24,6 @@ interface PreferencesModalProps {
|
|
|
60
24
|
*/
|
|
61
25
|
declare function PreferencesModal({ DialogProps, hideBranding, }: Readonly<PreferencesModalProps>): react_jsx_runtime.JSX.Element;
|
|
62
26
|
|
|
63
|
-
/**
|
|
64
|
-
* Props para o componente FloatingPreferencesButton.
|
|
65
|
-
*
|
|
66
|
-
* Permite configurar posição, ícone, tooltip, e comportamento de exibição do botão flutuante
|
|
67
|
-
* para abrir o modal de preferências de cookies LGPD.
|
|
68
|
-
*
|
|
69
|
-
* Todos os campos são opcionais e possuem valores padrão.
|
|
70
|
-
*/
|
|
71
|
-
interface FloatingPreferencesButtonProps {
|
|
72
|
-
/** Posição do botão flutuante. Padrão: 'bottom-right' */
|
|
73
|
-
position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
|
|
74
|
-
/** Offset da borda em pixels. Padrão: 24 */
|
|
75
|
-
offset?: number;
|
|
76
|
-
/** Ícone customizado. Padrão: CookieOutlined */
|
|
77
|
-
icon?: React.ReactNode;
|
|
78
|
-
/** Tooltip customizado exibido ao passar o mouse */
|
|
79
|
-
tooltip?: string;
|
|
80
|
-
/** Props adicionais para o Fab do MUI */
|
|
81
|
-
FabProps?: Partial<FabProps>;
|
|
82
|
-
/** Se deve esconder quando consentimento já foi dado. Padrão: false */
|
|
83
|
-
hideWhenConsented?: boolean;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Botão flutuante para abrir o modal de preferências de cookies.
|
|
87
|
-
*
|
|
88
|
-
* Permite ao usuário acessar rapidamente as configurações de consentimento LGPD.
|
|
89
|
-
* Pode ser posicionado em qualquer canto da tela e customizado via props.
|
|
90
|
-
*
|
|
91
|
-
* @param position Posição do botão na tela. Padrão: 'bottom-right'.
|
|
92
|
-
* @param offset Distância da borda em pixels. Padrão: 24.
|
|
93
|
-
* @param icon Ícone customizado para o botão. Padrão: CookieOutlined.
|
|
94
|
-
* @param tooltip Texto do tooltip exibido ao passar o mouse. Padrão: 'Gerenciar Preferências de Cookies'.
|
|
95
|
-
* @param FabProps Props adicionais para o componente Fab do MUI.
|
|
96
|
-
* @param hideWhenConsented Se verdadeiro, esconde o botão após consentimento. Padrão: false.
|
|
97
|
-
*
|
|
98
|
-
* @returns JSX.Element | null
|
|
99
|
-
*/
|
|
100
|
-
declare function FloatingPreferencesButton({ position, offset, icon, tooltip, FabProps, hideWhenConsented, }: Readonly<FloatingPreferencesButtonProps>): react_jsx_runtime.JSX.Element | null;
|
|
101
|
-
|
|
102
27
|
/**
|
|
103
28
|
* Integrações nativas com scripts de terceiros.
|
|
104
29
|
* Facilita o carregamento automático baseado em consentimento.
|
|
@@ -137,14 +62,24 @@ interface UserWayConfig {
|
|
|
137
62
|
}
|
|
138
63
|
/**
|
|
139
64
|
* Cria integração para Google Analytics 4.
|
|
65
|
+
*
|
|
66
|
+
* @param config Configuração do Google Analytics, contendo o `measurementId`.
|
|
67
|
+
* @returns Um objeto de integração de script para ser usado com `ConsentScriptLoader`.
|
|
140
68
|
*/
|
|
141
69
|
declare function createGoogleAnalyticsIntegration(config: GoogleAnalyticsConfig): ScriptIntegration;
|
|
142
70
|
/**
|
|
143
71
|
* Cria integração para Google Tag Manager.
|
|
72
|
+
*
|
|
73
|
+
* @param config Configuração do GTM, contendo o `containerId`.
|
|
74
|
+
* @returns Um objeto de integração de script.
|
|
144
75
|
*/
|
|
145
76
|
declare function createGoogleTagManagerIntegration(config: GoogleTagManagerConfig): ScriptIntegration;
|
|
146
77
|
/**
|
|
147
|
-
* Cria integração para UserWay (acessibilidade).
|
|
78
|
+
* Cria integração para UserWay (widget de acessibilidade).
|
|
79
|
+
* A categoria padrão foi alterada para 'functional', por ser mais apropriada.
|
|
80
|
+
*
|
|
81
|
+
* @param config Configuração do UserWay, contendo o `accountId`.
|
|
82
|
+
* @returns Um objeto de integração de script.
|
|
148
83
|
*/
|
|
149
84
|
declare function createUserWayIntegration(config: UserWayConfig): ScriptIntegration;
|
|
150
85
|
/**
|
|
@@ -157,14 +92,16 @@ declare const COMMON_INTEGRATIONS: {
|
|
|
157
92
|
};
|
|
158
93
|
|
|
159
94
|
/**
|
|
160
|
-
*
|
|
95
|
+
* Tipos de categorias padrão de consentimento para cookies, conforme definido pela ANPD.
|
|
161
96
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* -
|
|
165
|
-
* -
|
|
166
|
-
* -
|
|
167
|
-
* -
|
|
97
|
+
* @remarks
|
|
98
|
+
* Use este tipo para identificar as categorias principais de cookies suportadas nativamente pela biblioteca.
|
|
99
|
+
* - `'necessary'`: Cookies essenciais para funcionamento do site (sempre ativos).
|
|
100
|
+
* - `'analytics'`: Cookies para análise e estatísticas de uso.
|
|
101
|
+
* - `'functional'`: Cookies para funcionalidades extras e preferências do usuário.
|
|
102
|
+
* - `'marketing'`: Cookies para publicidade e marketing direcionado.
|
|
103
|
+
* - `'social'`: Cookies para integração com redes sociais.
|
|
104
|
+
* - `'personalization'`: Cookies para personalização de conteúdo e experiência.
|
|
168
105
|
*/
|
|
169
106
|
type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social' | 'personalization';
|
|
170
107
|
/**
|
|
@@ -190,8 +127,6 @@ interface CategoryDefinition {
|
|
|
190
127
|
interface ProjectCategoriesConfig {
|
|
191
128
|
/** Categorias padrão que serão ativadas (necessary sempre incluída automaticamente) */
|
|
192
129
|
enabledCategories?: Category[];
|
|
193
|
-
/** Categorias customizadas específicas do projeto */
|
|
194
|
-
customCategories?: CategoryDefinition[];
|
|
195
130
|
}
|
|
196
131
|
/**
|
|
197
132
|
* Preferências de consentimento do usuário.
|
|
@@ -218,6 +153,8 @@ interface ConsentCookieData {
|
|
|
218
153
|
lastUpdate: string;
|
|
219
154
|
/** Origem da decisão de consentimento */
|
|
220
155
|
source: 'banner' | 'modal' | 'programmatic';
|
|
156
|
+
/** Snapshot da configuração de categorias usada para este consentimento */
|
|
157
|
+
projectConfig?: ProjectCategoriesConfig;
|
|
221
158
|
}
|
|
222
159
|
/**
|
|
223
160
|
* Estado interno completo do consentimento (memória + UI).
|
|
@@ -283,6 +220,47 @@ interface ConsentCookieOptions {
|
|
|
283
220
|
/** Caminho do cookie. Padrão: '/' */
|
|
284
221
|
path: string;
|
|
285
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Tokens de design para customização visual avançada dos componentes.
|
|
225
|
+
* Permite um controle mais direto sobre a aparência sem a necessidade de `sx` props complexas.
|
|
226
|
+
*/
|
|
227
|
+
interface DesignTokens {
|
|
228
|
+
colors?: {
|
|
229
|
+
background?: string;
|
|
230
|
+
text?: string;
|
|
231
|
+
primary?: string;
|
|
232
|
+
secondary?: string;
|
|
233
|
+
};
|
|
234
|
+
typography?: {
|
|
235
|
+
fontFamily?: string;
|
|
236
|
+
fontSize?: {
|
|
237
|
+
banner?: string;
|
|
238
|
+
modal?: string;
|
|
239
|
+
};
|
|
240
|
+
fontWeight?: {
|
|
241
|
+
normal?: number;
|
|
242
|
+
bold?: number;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
spacing?: {
|
|
246
|
+
padding?: {
|
|
247
|
+
banner?: string | number;
|
|
248
|
+
modal?: string | number;
|
|
249
|
+
};
|
|
250
|
+
borderRadius?: {
|
|
251
|
+
banner?: string | number;
|
|
252
|
+
modal?: string | number;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
layout?: {
|
|
256
|
+
position?: 'bottom' | 'top' | 'floating';
|
|
257
|
+
width?: {
|
|
258
|
+
mobile?: string;
|
|
259
|
+
desktop?: string;
|
|
260
|
+
};
|
|
261
|
+
backdrop?: boolean;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
286
264
|
/**
|
|
287
265
|
* Propriedades do componente ConsentProvider - configuração principal da biblioteca.
|
|
288
266
|
*
|
|
@@ -300,12 +278,6 @@ interface ConsentCookieOptions {
|
|
|
300
278
|
* <ConsentProvider
|
|
301
279
|
* categories={{
|
|
302
280
|
* enabledCategories: ['analytics', 'functional'],
|
|
303
|
-
* customCategories: [{
|
|
304
|
-
* id: 'governo',
|
|
305
|
-
* name: 'Cookies Governamentais',
|
|
306
|
-
* description: 'Coleta para estatísticas públicas',
|
|
307
|
-
* essential: false
|
|
308
|
-
* }]
|
|
309
281
|
* }}
|
|
310
282
|
* texts={{
|
|
311
283
|
* bannerMessage: 'Utilizamos cookies conforme LGPD...',
|
|
@@ -333,24 +305,16 @@ interface ConsentProviderProps {
|
|
|
333
305
|
initialState?: ConsentState;
|
|
334
306
|
/**
|
|
335
307
|
* Configuração das categorias de cookies utilizadas no projeto.
|
|
336
|
-
* Define quais categorias padrão serão habilitadas
|
|
308
|
+
* Define quais categorias padrão serão habilitadas.
|
|
337
309
|
*
|
|
338
310
|
* @example Apenas analytics:
|
|
339
311
|
* ```tsx
|
|
340
312
|
* categories={{ enabledCategories: ['analytics'] }}
|
|
341
313
|
* ```
|
|
342
314
|
*
|
|
343
|
-
* @example Com categoria
|
|
315
|
+
* @example Com categoria padrão apenas:
|
|
344
316
|
* ```tsx
|
|
345
|
-
* categories={{
|
|
346
|
-
* enabledCategories: ['analytics', 'marketing'],
|
|
347
|
-
* customCategories: [{
|
|
348
|
-
* id: 'pesquisa',
|
|
349
|
-
* name: 'Cookies de Pesquisa',
|
|
350
|
-
* description: 'Coleta feedback e opinião dos usuários',
|
|
351
|
-
* essential: false
|
|
352
|
-
* }]
|
|
353
|
-
* }}
|
|
317
|
+
* categories={{ enabledCategories: ['analytics', 'marketing'] }}
|
|
354
318
|
* ```
|
|
355
319
|
*/
|
|
356
320
|
categories?: ProjectCategoriesConfig;
|
|
@@ -391,10 +355,19 @@ interface ConsentProviderProps {
|
|
|
391
355
|
*/
|
|
392
356
|
theme?: any;
|
|
393
357
|
/**
|
|
394
|
-
*
|
|
395
|
-
*
|
|
358
|
+
* Tokens de design para customização visual avançada.
|
|
359
|
+
* Oferece controle direto sobre cores, fontes, espaçamento e layout.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```tsx
|
|
363
|
+
* designTokens={{
|
|
364
|
+
* colors: { background: '#000', text: '#fff' },
|
|
365
|
+
* typography: { fontFamily: ''Inter', sans-serif' },
|
|
366
|
+
* spacing: { borderRadius: { banner: 0 } }
|
|
367
|
+
* }}
|
|
368
|
+
* ```
|
|
396
369
|
*/
|
|
397
|
-
|
|
370
|
+
designTokens?: DesignTokens;
|
|
398
371
|
/**
|
|
399
372
|
* Integrações nativas de scripts terceiros (Google Analytics, etc.).
|
|
400
373
|
* Scripts são carregados automaticamente baseado no consentimento.
|
|
@@ -411,16 +384,32 @@ interface ConsentProviderProps {
|
|
|
411
384
|
scriptIntegrations?: ScriptIntegration[];
|
|
412
385
|
/**
|
|
413
386
|
* Componente customizado para substituir o modal padrão de preferências.
|
|
414
|
-
* Deve implementar a lógica de consentimento usando
|
|
387
|
+
* Deve implementar a lógica de consentimento usando as props definidas em `CustomPreferencesModalProps`.
|
|
415
388
|
*/
|
|
416
|
-
PreferencesModalComponent?: React.ComponentType<
|
|
389
|
+
PreferencesModalComponent?: React.ComponentType<CustomPreferencesModalProps>;
|
|
417
390
|
/** Props adicionais passadas para o modal customizado. */
|
|
418
391
|
preferencesModalProps?: Record<string, any>;
|
|
419
392
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
393
|
+
* Componente customizado para substituir o banner padrão de cookies.
|
|
394
|
+
* Se não fornecido, o `CookieBanner` padrão será renderizado.
|
|
395
|
+
* Deve implementar a lógica de consentimento usando as props definidas em `CustomCookieBannerProps`.
|
|
396
|
+
*/
|
|
397
|
+
CookieBannerComponent?: React.ComponentType<CustomCookieBannerProps>;
|
|
398
|
+
/** Props adicionais passadas para o banner customizado. */
|
|
399
|
+
cookieBannerProps?: Record<string, any>;
|
|
400
|
+
/**
|
|
401
|
+
* Componente customizado para substituir o botão flutuante de preferências.
|
|
402
|
+
* Se não fornecido, o `FloatingPreferencesButton` padrão será renderizado.
|
|
403
|
+
* Deve implementar a lógica de consentimento usando as props definidas em `CustomFloatingPreferencesButtonProps`.
|
|
422
404
|
*/
|
|
423
|
-
|
|
405
|
+
FloatingPreferencesButtonComponent?: React.ComponentType<CustomFloatingPreferencesButtonProps>;
|
|
406
|
+
/** Props adicionais passadas para o botão flutuante customizado. */
|
|
407
|
+
floatingPreferencesButtonProps?: Record<string, any>;
|
|
408
|
+
/**
|
|
409
|
+
* Desabilita o botão flutuante de preferências.
|
|
410
|
+
* Útil quando o usuário da lib quer ter controle total sobre o acesso às preferências.
|
|
411
|
+
*/
|
|
412
|
+
disableFloatingPreferencesButton?: boolean;
|
|
424
413
|
/**
|
|
425
414
|
* Comportamento do banner de consentimento:
|
|
426
415
|
* - `false` (padrão): Banner não-intrusivo, usuário pode navegar livremente
|
|
@@ -478,6 +467,44 @@ interface ConsentProviderProps {
|
|
|
478
467
|
/** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
|
|
479
468
|
children: React.ReactNode;
|
|
480
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Props esperadas por um componente customizado de CookieBanner.
|
|
472
|
+
* Fornece acesso ao estado de consentimento e ações necessárias para o banner.
|
|
473
|
+
*/
|
|
474
|
+
interface CustomCookieBannerProps {
|
|
475
|
+
consented: boolean;
|
|
476
|
+
acceptAll: () => void;
|
|
477
|
+
rejectAll: () => void;
|
|
478
|
+
openPreferences: () => void;
|
|
479
|
+
texts: ConsentTexts;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Props esperadas por um componente customizado de PreferencesModal.
|
|
483
|
+
*
|
|
484
|
+
* Fornece acesso às preferências atuais do usuário, funções para atualizar e salvar preferências,
|
|
485
|
+
* fechar o modal e textos customizados da interface.
|
|
486
|
+
*
|
|
487
|
+
* @property preferences Preferências atuais de consentimento do usuário.
|
|
488
|
+
* @property setPreferences Função para atualizar e salvar as preferências.
|
|
489
|
+
* @property closePreferences Função para fechar o modal de preferências.
|
|
490
|
+
* @property isModalOpen Indica se o modal está aberto (opcional).
|
|
491
|
+
* @property texts Textos customizados da interface de consentimento.
|
|
492
|
+
*/
|
|
493
|
+
interface CustomPreferencesModalProps {
|
|
494
|
+
preferences: ConsentPreferences;
|
|
495
|
+
setPreferences: (preferences: ConsentPreferences) => void;
|
|
496
|
+
closePreferences: () => void;
|
|
497
|
+
isModalOpen?: boolean;
|
|
498
|
+
texts: ConsentTexts;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Props esperadas por um componente customizado de FloatingPreferencesButton.
|
|
502
|
+
* Fornece acesso às ações de abertura do modal e ao estado de consentimento.
|
|
503
|
+
*/
|
|
504
|
+
interface CustomFloatingPreferencesButtonProps {
|
|
505
|
+
openPreferences: () => void;
|
|
506
|
+
consented: boolean;
|
|
507
|
+
}
|
|
481
508
|
/**
|
|
482
509
|
* Valor do contexto de consentimento, incluindo estado e métodos de manipulação.
|
|
483
510
|
*/
|
|
@@ -519,11 +546,9 @@ interface ConsentContextValue {
|
|
|
519
546
|
* <App />
|
|
520
547
|
* </ConsentProvider>
|
|
521
548
|
*/
|
|
522
|
-
declare function ConsentProvider({ initialState, categories, //
|
|
523
|
-
texts: textsProp, theme,
|
|
524
|
-
|
|
525
|
-
PreferencesModalComponent, preferencesModalProps, disableAutomaticModal, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, // NOVO: desabilita avisos de dev
|
|
526
|
-
children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
549
|
+
declare function ConsentProvider({ initialState, categories, // Nova prop para configuração de categorias
|
|
550
|
+
texts: textsProp, theme, designTokens, scriptIntegrations, // eslint-disable-line no-unused-vars
|
|
551
|
+
PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
527
552
|
|
|
528
553
|
/**
|
|
529
554
|
* Hook principal para acessar e manipular o estado de consentimento de cookies.
|
|
@@ -601,8 +626,6 @@ interface CategoriesContextValue {
|
|
|
601
626
|
toggleableCategories: DeveloperGuidance['activeCategoriesInfo'];
|
|
602
627
|
/** Todas as categorias ativas */
|
|
603
628
|
allCategories: DeveloperGuidance['activeCategoriesInfo'];
|
|
604
|
-
/** LEGACY: Apenas categorias customizadas (backward compatibility) */
|
|
605
|
-
legacyCategories: CategoryDefinition[];
|
|
606
629
|
}
|
|
607
630
|
/**
|
|
608
631
|
* Hook para acessar informações sobre categorias ativas.
|
|
@@ -619,13 +642,6 @@ declare function useCategoryStatus(categoryId: string): {
|
|
|
619
642
|
name: string | undefined;
|
|
620
643
|
description: string | undefined;
|
|
621
644
|
};
|
|
622
|
-
/**
|
|
623
|
-
* LEGACY: Hook para acessar as categorias customizadas.
|
|
624
|
-
* Mantido para backward compatibility.
|
|
625
|
-
*
|
|
626
|
-
* @deprecated Use useCategories() ao invés disso para acesso completo às categorias.
|
|
627
|
-
*/
|
|
628
|
-
declare function useCustomCategories(): CategoryDefinition[];
|
|
629
645
|
|
|
630
646
|
declare function ConsentGate(props: Readonly<{
|
|
631
647
|
category: string;
|
|
@@ -702,4 +718,4 @@ declare function ConsentScriptLoader({ integrations, reloadOnChange, }: Readonly
|
|
|
702
718
|
*/
|
|
703
719
|
declare function useConsentScriptLoader(): (integration: ScriptIntegration) => Promise<boolean>;
|
|
704
720
|
|
|
705
|
-
export { COMMON_INTEGRATIONS, type Category, type CategoryDefinition, type ConsentCookieOptions, ConsentGate, type ConsentPreferences, ConsentProvider, ConsentScriptLoader, type ConsentState, type ConsentTexts,
|
|
721
|
+
export { COMMON_INTEGRATIONS, type Category, type CategoryDefinition, type ConsentCookieOptions, ConsentGate, type ConsentPreferences, ConsentProvider, ConsentScriptLoader, type ConsentState, type ConsentTexts, DEFAULT_PROJECT_CATEGORIES, type DeveloperGuidance, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, PreferencesModal, type ProjectCategoriesConfig, type ScriptIntegration, type UserWayConfig, analyzeDeveloperConfiguration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createUserWayIntegration, defaultConsentTheme, loadScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Branding,
|
|
3
2
|
ConsentProvider,
|
|
4
3
|
DEFAULT_PROJECT_CATEGORIES,
|
|
5
4
|
PreferencesModal,
|
|
@@ -9,180 +8,15 @@ import {
|
|
|
9
8
|
useCategoryStatus,
|
|
10
9
|
useConsent,
|
|
11
10
|
useConsentHydration,
|
|
12
|
-
useConsentTexts
|
|
13
|
-
|
|
14
|
-
} from "./chunk-4LLZREFO.js";
|
|
15
|
-
|
|
16
|
-
// src/components/CookieBanner.tsx
|
|
17
|
-
import Button from "@mui/material/Button";
|
|
18
|
-
import Box from "@mui/material/Box";
|
|
19
|
-
import Paper from "@mui/material/Paper";
|
|
20
|
-
import Snackbar from "@mui/material/Snackbar";
|
|
21
|
-
import Stack from "@mui/material/Stack";
|
|
22
|
-
import Typography from "@mui/material/Typography";
|
|
23
|
-
import Link from "@mui/material/Link";
|
|
24
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
-
function CookieBanner({
|
|
26
|
-
policyLinkUrl,
|
|
27
|
-
debug,
|
|
28
|
-
blocking = true,
|
|
29
|
-
// Por padrão, bloqueia até decisão
|
|
30
|
-
hideBranding = false,
|
|
31
|
-
SnackbarProps,
|
|
32
|
-
PaperProps
|
|
33
|
-
}) {
|
|
34
|
-
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
35
|
-
const texts = useConsentTexts();
|
|
36
|
-
const isHydrated = useConsentHydration();
|
|
37
|
-
const open = debug ? true : isHydrated && !consented;
|
|
38
|
-
if (!open) return null;
|
|
39
|
-
const bannerContent = /* @__PURE__ */ jsx(
|
|
40
|
-
Paper,
|
|
41
|
-
{
|
|
42
|
-
elevation: 3,
|
|
43
|
-
sx: { p: 2, maxWidth: 720, mx: "auto" },
|
|
44
|
-
...PaperProps,
|
|
45
|
-
children: /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
|
|
46
|
-
/* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
|
|
47
|
-
texts.bannerMessage,
|
|
48
|
-
" ",
|
|
49
|
-
policyLinkUrl && /* @__PURE__ */ jsx(
|
|
50
|
-
Link,
|
|
51
|
-
{
|
|
52
|
-
href: policyLinkUrl,
|
|
53
|
-
underline: "hover",
|
|
54
|
-
target: "_blank",
|
|
55
|
-
rel: "noopener noreferrer",
|
|
56
|
-
children: texts.policyLink ?? "Saiba mais"
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
] }),
|
|
60
|
-
/* @__PURE__ */ jsxs(
|
|
61
|
-
Stack,
|
|
62
|
-
{
|
|
63
|
-
direction: { xs: "column", sm: "row" },
|
|
64
|
-
spacing: 1,
|
|
65
|
-
justifyContent: "flex-end",
|
|
66
|
-
children: [
|
|
67
|
-
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: rejectAll, children: texts.declineAll }),
|
|
68
|
-
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: acceptAll, children: texts.acceptAll }),
|
|
69
|
-
/* @__PURE__ */ jsx(Button, { variant: "text", onClick: openPreferences, children: texts.preferences })
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
),
|
|
73
|
-
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "banner" })
|
|
74
|
-
] })
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
if (blocking) {
|
|
78
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
|
-
/* @__PURE__ */ jsx(
|
|
80
|
-
Box,
|
|
81
|
-
{
|
|
82
|
-
sx: {
|
|
83
|
-
position: "fixed",
|
|
84
|
-
top: 0,
|
|
85
|
-
left: 0,
|
|
86
|
-
right: 0,
|
|
87
|
-
bottom: 0,
|
|
88
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
89
|
-
zIndex: 1299
|
|
90
|
-
// Abaixo do banner mas acima do conteúdo
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
),
|
|
94
|
-
/* @__PURE__ */ jsx(
|
|
95
|
-
Box,
|
|
96
|
-
{
|
|
97
|
-
sx: {
|
|
98
|
-
position: "fixed",
|
|
99
|
-
bottom: 0,
|
|
100
|
-
left: 0,
|
|
101
|
-
right: 0,
|
|
102
|
-
zIndex: 1300,
|
|
103
|
-
// Acima do overlay
|
|
104
|
-
p: 2
|
|
105
|
-
},
|
|
106
|
-
children: bannerContent
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
111
|
-
return /* @__PURE__ */ jsx(
|
|
112
|
-
Snackbar,
|
|
113
|
-
{
|
|
114
|
-
open,
|
|
115
|
-
anchorOrigin: { vertical: "bottom", horizontal: "center" },
|
|
116
|
-
...SnackbarProps,
|
|
117
|
-
children: bannerContent
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/components/FloatingPreferencesButton.tsx
|
|
123
|
-
import CookieOutlined from "@mui/icons-material/CookieOutlined";
|
|
124
|
-
import Fab from "@mui/material/Fab";
|
|
125
|
-
import Tooltip from "@mui/material/Tooltip";
|
|
126
|
-
import { useTheme } from "@mui/material/styles";
|
|
127
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
128
|
-
function FloatingPreferencesButton({
|
|
129
|
-
position = "bottom-right",
|
|
130
|
-
offset = 24,
|
|
131
|
-
icon = /* @__PURE__ */ jsx2(CookieOutlined, {}),
|
|
132
|
-
tooltip,
|
|
133
|
-
FabProps,
|
|
134
|
-
hideWhenConsented = false
|
|
135
|
-
}) {
|
|
136
|
-
const { openPreferences, consented } = useConsent();
|
|
137
|
-
const theme = useTheme();
|
|
138
|
-
if (hideWhenConsented && consented) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
const tooltipText = tooltip ?? "Gerenciar Prefer\xEAncias de Cookies";
|
|
142
|
-
const getPosition = () => {
|
|
143
|
-
const styles = {
|
|
144
|
-
position: "fixed",
|
|
145
|
-
zIndex: 1200
|
|
146
|
-
};
|
|
147
|
-
switch (position) {
|
|
148
|
-
case "bottom-left":
|
|
149
|
-
return { ...styles, bottom: offset, left: offset };
|
|
150
|
-
case "bottom-right":
|
|
151
|
-
return { ...styles, bottom: offset, right: offset };
|
|
152
|
-
case "top-left":
|
|
153
|
-
return { ...styles, top: offset, left: offset };
|
|
154
|
-
case "top-right":
|
|
155
|
-
return { ...styles, top: offset, right: offset };
|
|
156
|
-
default:
|
|
157
|
-
return { ...styles, bottom: offset, right: offset };
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
return /* @__PURE__ */ jsx2(Tooltip, { title: tooltipText, placement: "top", children: /* @__PURE__ */ jsx2(
|
|
161
|
-
Fab,
|
|
162
|
-
{
|
|
163
|
-
size: "medium",
|
|
164
|
-
color: "primary",
|
|
165
|
-
onClick: openPreferences,
|
|
166
|
-
sx: {
|
|
167
|
-
...getPosition(),
|
|
168
|
-
backgroundColor: theme.palette.primary.main,
|
|
169
|
-
"&:hover": {
|
|
170
|
-
backgroundColor: theme.palette.primary.dark
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
"aria-label": tooltipText,
|
|
174
|
-
...FabProps,
|
|
175
|
-
children: icon
|
|
176
|
-
}
|
|
177
|
-
) });
|
|
178
|
-
}
|
|
11
|
+
useConsentTexts
|
|
12
|
+
} from "./chunk-R3IKVZBC.js";
|
|
179
13
|
|
|
180
14
|
// src/utils/ConsentGate.tsx
|
|
181
|
-
import { Fragment
|
|
15
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
182
16
|
function ConsentGate(props) {
|
|
183
17
|
const { preferences } = useConsent();
|
|
184
18
|
if (!preferences[props.category]) return null;
|
|
185
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
186
20
|
}
|
|
187
21
|
|
|
188
22
|
// src/utils/scriptLoader.ts
|
|
@@ -248,9 +82,6 @@ function ConsentScriptLoader({
|
|
|
248
82
|
integration.init();
|
|
249
83
|
}
|
|
250
84
|
loadedScripts.current.add(integration.id);
|
|
251
|
-
console.log(
|
|
252
|
-
`\u2705 Script loaded: ${integration.id} (${integration.category})`
|
|
253
|
-
);
|
|
254
85
|
} catch (error) {
|
|
255
86
|
console.error(`\u274C Failed to load script: ${integration.id}`, error);
|
|
256
87
|
}
|
|
@@ -287,9 +118,6 @@ function useConsentScriptLoader() {
|
|
|
287
118
|
if (integration.init) {
|
|
288
119
|
integration.init();
|
|
289
120
|
}
|
|
290
|
-
console.log(
|
|
291
|
-
`\u2705 Script loaded: ${integration.id} (${integration.category})`
|
|
292
|
-
);
|
|
293
121
|
return true;
|
|
294
122
|
} catch (error) {
|
|
295
123
|
console.error(`\u274C Failed to load script: ${integration.id}`, error);
|
|
@@ -341,8 +169,8 @@ function createGoogleTagManagerIntegration(config) {
|
|
|
341
169
|
function createUserWayIntegration(config) {
|
|
342
170
|
return {
|
|
343
171
|
id: "userway",
|
|
344
|
-
category: "
|
|
345
|
-
//
|
|
172
|
+
category: "functional",
|
|
173
|
+
// Categoria mais apropriada para acessibilidade
|
|
346
174
|
src: `https://cdn.userway.org/widget.js`,
|
|
347
175
|
init: () => {
|
|
348
176
|
if (typeof window !== "undefined") {
|
|
@@ -363,9 +191,7 @@ export {
|
|
|
363
191
|
ConsentGate,
|
|
364
192
|
ConsentProvider,
|
|
365
193
|
ConsentScriptLoader,
|
|
366
|
-
CookieBanner,
|
|
367
194
|
DEFAULT_PROJECT_CATEGORIES,
|
|
368
|
-
FloatingPreferencesButton,
|
|
369
195
|
PreferencesModal,
|
|
370
196
|
analyzeDeveloperConfiguration,
|
|
371
197
|
createGoogleAnalyticsIntegration,
|
|
@@ -378,6 +204,5 @@ export {
|
|
|
378
204
|
useConsent,
|
|
379
205
|
useConsentHydration,
|
|
380
206
|
useConsentScriptLoader,
|
|
381
|
-
useConsentTexts
|
|
382
|
-
useCustomCategories
|
|
207
|
+
useConsentTexts
|
|
383
208
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lgpd-consent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Biblioteca completa de consentimento LGPD com 6 categorias ANPD, integrações nativas e sistema extensível para React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lgpd",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"lint": "eslint . --ext .ts,.tsx",
|
|
62
62
|
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\" \"eslint.config.js\"",
|
|
63
63
|
"type-check": "tsc --noEmit",
|
|
64
|
+
"test": "jest",
|
|
64
65
|
"prepublishOnly": "npm run build"
|
|
65
66
|
},
|
|
66
67
|
"repository": {
|
|
@@ -86,9 +87,15 @@
|
|
|
86
87
|
"js-cookie": "^3.0.5"
|
|
87
88
|
},
|
|
88
89
|
"devDependencies": {
|
|
90
|
+
"@emotion/react": "^11.14.0",
|
|
91
|
+
"@emotion/styled": "^11.14.1",
|
|
89
92
|
"@eslint/compat": "^1.3.2",
|
|
90
93
|
"@mui/icons-material": "^7.3.1",
|
|
91
94
|
"@mui/material": "^7.3.1",
|
|
95
|
+
"@testing-library/jest-dom": "^6.6.4",
|
|
96
|
+
"@testing-library/react": "^16.3.0",
|
|
97
|
+
"@testing-library/user-event": "^14.6.1",
|
|
98
|
+
"@types/jest": "^30.0.0",
|
|
92
99
|
"@types/js-cookie": "^3.0.6",
|
|
93
100
|
"@types/react": "^19.1.9",
|
|
94
101
|
"@types/react-dom": "^19.1.7",
|
|
@@ -97,11 +104,15 @@
|
|
|
97
104
|
"cross-env": "^10.0.0",
|
|
98
105
|
"eslint": "^9.33.0",
|
|
99
106
|
"eslint-config-prettier": "^10.1.8",
|
|
107
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
100
108
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
109
|
+
"jest": "^30.0.5",
|
|
110
|
+
"jest-environment-jsdom": "^30.0.5",
|
|
101
111
|
"prettier": "^3.6.2",
|
|
102
112
|
"react": "^19.1.1",
|
|
103
113
|
"react-dom": "^19.1.1",
|
|
104
114
|
"rimraf": "^6.0.1",
|
|
115
|
+
"ts-jest": "^29.4.1",
|
|
105
116
|
"tsup": "^8.5.0",
|
|
106
117
|
"typescript": "^5.9.2",
|
|
107
118
|
"typescript-eslint": "^8.39.1"
|