react-lgpd-consent 0.3.1 → 0.3.3
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/CHANGELOG.md +4 -17
- package/README.md +56 -648
- package/dist/{PreferencesModal-J27W5XAJ.js → PreferencesModal-HTTMUZND.js} +1 -1
- package/dist/{chunk-VFAOBR3X.js → chunk-GPLNN3FD.js} +303 -276
- package/dist/index.cjs +326 -290
- package/dist/index.d.cts +1589 -226
- package/dist/index.d.ts +1589 -226
- package/dist/index.js +21 -11
- package/package.json +16 -12
- package/COMPLIANCE.md +0 -107
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>react-lgpd-consent
|
|
3
|
-
<p><strong>
|
|
4
|
-
<p>Conformidade com LGPD, GDPR e CCPA (Partial) • TypeScript First • Zero Config</p>
|
|
2
|
+
<h1>react-lgpd-consent 🍪</h1>
|
|
3
|
+
<p><strong>Uma biblioteca React para gerenciamento de consentimento de cookies em conformidade com a LGPD.</strong></p>
|
|
5
4
|
|
|
6
5
|
<div>
|
|
7
6
|
<a href="https://www.npmjs.com/package/react-lgpd-consent"><img src="https://img.shields.io/npm/v/react-lgpd-consent?style=for-the-badge&logo=npm&color=cb3837&logoColor=white" alt="NPM Version"></a>
|
|
@@ -17,722 +16,131 @@
|
|
|
17
16
|
|
|
18
17
|
<br>
|
|
19
18
|
|
|
20
|
-
> 🎉 **Novidade v0.3.1**: Correções críticas de produção - Compatibilidade total com Material-UI ThemeProvider + API melhorada para controle programático + Sistema de debug avançado
|
|
21
|
-
|
|
22
19
|
<p>
|
|
23
20
|
<a href="#-instalação"><strong>Instalação</strong></a> •
|
|
24
|
-
<a href="#-uso-básico"><strong>
|
|
25
|
-
<a href="#-
|
|
26
|
-
<a href="#-
|
|
27
|
-
<a href="#-conformidade-e-lgpd"><strong>Compliance</strong></a>
|
|
21
|
+
<a href="#-uso-básico"><strong>Uso Básico</strong></a> •
|
|
22
|
+
<a href="#-documentação-completa"><strong>Documentação</strong></a> •
|
|
23
|
+
<a href="#-como-contribuir"><strong>Contribuir</strong></a>
|
|
28
24
|
</p>
|
|
29
25
|
</div>
|
|
30
26
|
|
|
31
27
|
---
|
|
32
28
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
### 🛡️ Correções Críticas Implementadas
|
|
36
|
-
|
|
37
|
-
- **✅ Theme Provider Compatibility**: Resolvido erro "Cannot read properties of undefined (reading 'duration')" com fallbacks automáticos
|
|
38
|
-
- **✅ FloatingPreferencesButton Fixes**: Corrigido "Element type is invalid" + nova prop `disableFloatingPreferencesButton`
|
|
39
|
-
- **✅ API Programática**: Novos `useOpenPreferencesModal()` hook e `openPreferencesModal()` função global
|
|
40
|
-
- **✅ TypeScript Types**: Exports completos de `CustomCookieBannerProps`, `CustomPreferencesModalProps`, etc.
|
|
41
|
-
- **✅ Sistema de Debug**: `setDebugLogging()` para troubleshooting em produção
|
|
42
|
-
|
|
43
|
-
### 🎯 Para Quem Estava Com Problemas
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
// ❌ ANTES v0.3.0 - Erro com ThemeProvider customizado
|
|
47
|
-
<ConsentProvider theme={myCustomTheme}> // Erro: duration undefined
|
|
48
|
-
|
|
49
|
-
// ✅ AGORA v0.3.1 - Funcionamento garantido
|
|
50
|
-
<ConsentProvider
|
|
51
|
-
disableFloatingPreferencesButton={true} // Nova prop!
|
|
52
|
-
theme={myCustomTheme} // Funciona com qualquer tema
|
|
53
|
-
>
|
|
54
|
-
<MyAccessibilityDock />
|
|
55
|
-
</ConsentProvider>
|
|
56
|
-
|
|
57
|
-
// ✅ Controle programático - NOVO!
|
|
58
|
-
const openModal = useOpenPreferencesModal() // Hook React
|
|
59
|
-
openPreferencesModal() // Função global JavaScript
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## 🎯 **Por que escolher react-lgpd-consent?**
|
|
63
|
-
|
|
64
|
-
**A única biblioteca que você precisa para compliance completo de cookies no Brasil.** Desenvolvida seguindo as diretrizes oficiais da ANPD (Autoridade Nacional de Proteção de Dados), com foco em experiência do desenvolvedor e performance.
|
|
65
|
-
|
|
66
|
-
### 🏆 **Diferencial Competitivo**
|
|
67
|
-
|
|
68
|
-
- **🧠 AI-Powered Development**: Sistema inteligente de orientações que guia o desenvolvedor
|
|
69
|
-
- **🎯 Zero False Positives**: UI dinâmica que se adapta às suas necessidades reais
|
|
70
|
-
- **🚀 Performance First**: Bundle otimizado com tree-shaking e lazy loading
|
|
71
|
-
- **🛡️ Enterprise Ready**: Auditoria completa, logs de compliance e versionamento
|
|
72
|
-
|
|
73
|
-
## ✨ Características Principais
|
|
74
|
-
|
|
75
|
-
<table>
|
|
76
|
-
<tr>
|
|
77
|
-
<td width="50%">
|
|
29
|
+
## 🎯 Por que usar `react-lgpd-consent`?
|
|
78
30
|
|
|
79
|
-
|
|
31
|
+
Esta biblioteca oferece uma solução robusta e flexível para gerenciar o consentimento de cookies em aplicações React, com foco total na **Lei Geral de Proteção de Dados (LGPD)** do Brasil.
|
|
80
32
|
|
|
81
|
-
|
|
82
|
-
- **Auditoria Completa**: Logs detalhados para conformidade
|
|
83
|
-
- **Minimização de Dados**: Armazena apenas o essencial
|
|
84
|
-
- **Transparência Total**: Textos e metadados completos
|
|
33
|
+
### Principais Funcionalidades
|
|
85
34
|
|
|
86
|
-
|
|
87
|
-
|
|
35
|
+
| Funcionalidade | Descrição |
|
|
36
|
+
| -------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
37
|
+
| 🇧🇷 **Foco na LGPD** | Implementação baseada nas diretrizes da ANPD, com textos e categorias alinhados à lei brasileira. |
|
|
38
|
+
| 🎨 **UI Automática e Customizável** | Componentes de UI (Banner e Modal) prontos para uso, baseados em Material-UI, e totalmente substituíveis. |
|
|
39
|
+
| ⚙️ **Configuração Consciente** | A prop `categories` força a declaração explícita dos cookies utilizados, seguindo o princípio da minimização. |
|
|
40
|
+
| 🧠 **Guia para Desenvolvedores** | Sistema que exibe avisos e sugestões no console (em ambiente de dev) para garantir a correta implementação. |
|
|
41
|
+
| 🚀 **Integrações Nativas** | Carregamento automático de scripts como Google Analytics e GTM, condicionado ao consentimento do usuário. |
|
|
42
|
+
| 🔒 **Auditoria e Transparência** | O cookie de consentimento armazena metadados como data, origem e versão para fins de auditoria. |
|
|
88
43
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
- **AI-Guided Setup**: Orientações automáticas no console
|
|
92
|
-
- **TypeScript First**: Tipagem completa e autocomplete
|
|
93
|
-
- **Zero Config**: Funciona out-of-the-box
|
|
94
|
-
- **Hot Reload**: Mudanças instantâneas em desenvolvimento
|
|
95
|
-
|
|
96
|
-
</td>
|
|
97
|
-
</tr>
|
|
98
|
-
<tr>
|
|
99
|
-
<td>
|
|
100
|
-
|
|
101
|
-
### 🎨 **UI/UX Inteligente**
|
|
102
|
-
|
|
103
|
-
- **Material-UI Native**: Componentes prontos e customizáveis
|
|
104
|
-
- **Responsive Design**: Funciona em todos os dispositivos
|
|
105
|
-
- **Dark/Light Mode**: Suporte automático a temas
|
|
106
|
-
- **Accessibility First**: WCAG 2.1 AA compliant
|
|
107
|
-
|
|
108
|
-
</td>
|
|
109
|
-
<td>
|
|
110
|
-
|
|
111
|
-
### ⚡ **Performance**
|
|
112
|
-
|
|
113
|
-
- **Tree Shaking**: Bundle otimizado automaticamente
|
|
114
|
-
- **Lazy Loading**: Carregamento sob demanda
|
|
115
|
-
- **SSR/SSG Ready**: Next.js, Gatsby, Remix compatível
|
|
116
|
-
- **< 5KB gzipped**: Impacto mínimo no seu app
|
|
117
|
-
|
|
118
|
-
</td>
|
|
119
|
-
</tr>
|
|
120
|
-
</table>
|
|
121
|
-
|
|
122
|
-
### 🚀 **Integrações Nativas**
|
|
123
|
-
|
|
124
|
-
<div align="center">
|
|
125
|
-
<img src="https://img.shields.io/badge/Google_Analytics-E37400?style=for-the-badge&logo=google-analytics&logoColor=white" alt="Google Analytics">
|
|
126
|
-
<img src="https://img.shields.io/badge/Google_Tag_Manager-4285F4?style=for-the-badge&logo=google-tag-manager&logoColor=white" alt="Google Tag Manager">
|
|
127
|
-
<img src="https://img.shields.io/badge/Facebook_Pixel-1877F2?style=for-the-badge&logo=facebook&logoColor=white" alt="Facebook Pixel">
|
|
128
|
-
<img src="https://img.shields.io/badge/Hotjar-FF3C00?style=for-the-badge&logo=hotjar&logoColor=white" alt="Hotjar">
|
|
129
|
-
<img src="https://img.shields.io/badge/UserWay-6C5CE7?style=for-the-badge&logoColor=white" alt="UserWay">
|
|
130
|
-
</div>
|
|
44
|
+
---
|
|
131
45
|
|
|
132
46
|
## 🚀 Instalação
|
|
133
47
|
|
|
134
|
-
<details>
|
|
135
|
-
<summary><strong>📦 NPM/Yarn/PNPM</strong></summary>
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
# NPM
|
|
139
|
-
npm install react-lgpd-consent
|
|
140
|
-
|
|
141
|
-
# Yarn
|
|
142
|
-
yarn add react-lgpd-consent
|
|
143
|
-
|
|
144
|
-
# PNPM
|
|
145
|
-
pnpm add react-lgpd-consent
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
</details>
|
|
149
|
-
|
|
150
|
-
<details>
|
|
151
|
-
<summary><strong>📋 Dependências Peer</strong></summary>
|
|
152
|
-
|
|
153
|
-
Certifique-se de ter as seguintes dependências instaladas:
|
|
154
|
-
|
|
155
48
|
```bash
|
|
156
|
-
npm install react
|
|
49
|
+
npm install react-lgpd-consent @mui/material @emotion/react @emotion/styled js-cookie
|
|
157
50
|
```
|
|
158
51
|
|
|
159
|
-
**
|
|
160
|
-
|
|
161
|
-
- React: `^18.0.0`
|
|
162
|
-
- Material-UI: `^5.0.0`
|
|
163
|
-
- TypeScript: `^4.5.0` (opcional, mas recomendado)
|
|
52
|
+
**Dependências Peer:**
|
|
164
53
|
|
|
165
|
-
|
|
54
|
+
A biblioteca requer `react`, `react-dom`, `@mui/material` e `js-cookie` como dependências peer.
|
|
166
55
|
|
|
167
|
-
|
|
168
|
-
<summary><strong>🎯 Instalação Completa (Recomendada)</strong></summary>
|
|
169
|
-
|
|
170
|
-
Para uma experiência completa, instale com todas as integrações:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
npm install react-lgpd-consent @mui/material @emotion/react @emotion/styled js-cookie
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
</details>
|
|
56
|
+
---
|
|
177
57
|
|
|
178
58
|
## 📖 Uso Básico
|
|
179
59
|
|
|
180
|
-
|
|
60
|
+
Envolva sua aplicação com o `ConsentProvider` e configure as categorias de cookies que você utiliza.
|
|
181
61
|
|
|
182
62
|
```tsx
|
|
183
|
-
|
|
63
|
+
// Em seu arquivo principal (ex: App.tsx)
|
|
64
|
+
import { ConsentProvider } from 'react-lgpd-consent';
|
|
184
65
|
|
|
185
66
|
function App() {
|
|
186
67
|
return (
|
|
187
68
|
<ConsentProvider
|
|
188
69
|
categories={{
|
|
70
|
+
// É obrigatório especificar as categorias que seu site usa.
|
|
71
|
+
// A categoria 'necessary' é sempre incluída.
|
|
189
72
|
enabledCategories: ['analytics', 'marketing'],
|
|
190
73
|
}}
|
|
191
74
|
>
|
|
192
|
-
{/*
|
|
193
|
-
<
|
|
75
|
+
{/* O banner e o botão de preferências aparecerão automaticamente */}
|
|
76
|
+
<SuaAplicacao />
|
|
194
77
|
</ConsentProvider>
|
|
195
|
-
)
|
|
78
|
+
);
|
|
196
79
|
}
|
|
197
80
|
```
|
|
198
81
|
|
|
199
|
-
###
|
|
82
|
+
### Exemplo com Integração e Textos Customizados
|
|
200
83
|
|
|
201
84
|
```tsx
|
|
202
85
|
import {
|
|
203
86
|
ConsentProvider,
|
|
204
87
|
ConsentScriptLoader,
|
|
205
88
|
createGoogleAnalyticsIntegration,
|
|
206
|
-
|
|
207
|
-
} from 'react-lgpd-consent'
|
|
89
|
+
} from 'react-lgpd-consent';
|
|
208
90
|
|
|
91
|
+
// 1. Crie as integrações que você precisa
|
|
209
92
|
const integrations = [
|
|
210
93
|
createGoogleAnalyticsIntegration({
|
|
211
|
-
measurementId: 'G-XXXXXXXXXX',
|
|
212
|
-
}),
|
|
213
|
-
createGoogleTagManagerIntegration({
|
|
214
|
-
gtmId: 'GTM-XXXXXXX',
|
|
94
|
+
measurementId: 'G-XXXXXXXXXX', // Substitua pelo seu ID
|
|
215
95
|
}),
|
|
216
|
-
]
|
|
96
|
+
];
|
|
217
97
|
|
|
218
98
|
function App() {
|
|
219
99
|
return (
|
|
220
100
|
<ConsentProvider
|
|
221
|
-
categories={{
|
|
222
|
-
enabledCategories: ['analytics', 'marketing', 'functional'],
|
|
223
|
-
}}
|
|
101
|
+
categories={{ enabledCategories: ['analytics'] }}
|
|
224
102
|
texts={{
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
contactInfo: '
|
|
103
|
+
bannerMessage: 'Nós usamos cookies para analisar o tráfego e melhorar a sua experiência.',
|
|
104
|
+
acceptAll: 'Aceitar',
|
|
105
|
+
declineAll: 'Recusar',
|
|
106
|
+
// Para conformidade com a ANPD, preencha os campos abaixo
|
|
107
|
+
controllerInfo: 'Controlado por: Sua Empresa LTDA (CNPJ: XX.XXX.XXX/XXXX-XX)',
|
|
108
|
+
contactInfo: 'Contato do DPO: dpo@suaempresa.com',
|
|
231
109
|
}}
|
|
232
110
|
onConsentGiven={(state) => {
|
|
233
|
-
console.log('
|
|
234
|
-
// Opcional: enviar para seu sistema de auditoria
|
|
235
|
-
}}
|
|
236
|
-
onConsentRevoked={(state) => {
|
|
237
|
-
console.log('❌ Consentimento revogado:', state)
|
|
111
|
+
console.log('O usuário deu o primeiro consentimento!', state.preferences);
|
|
238
112
|
}}
|
|
239
113
|
>
|
|
240
|
-
{/*
|
|
114
|
+
{/* 2. Adicione o loader de scripts para carregá-los após o consentimento */}
|
|
241
115
|
<ConsentScriptLoader integrations={integrations} />
|
|
242
116
|
|
|
243
|
-
|
|
244
|
-
<HomePage />
|
|
117
|
+
<SuaAplicacao />
|
|
245
118
|
</ConsentProvider>
|
|
246
|
-
)
|
|
119
|
+
);
|
|
247
120
|
}
|
|
248
121
|
```
|
|
249
122
|
|
|
250
|
-
### 🎨 **UI Customizada**
|
|
251
|
-
|
|
252
|
-
```tsx
|
|
253
|
-
import { ConsentProvider, useConsent, useCategories } from 'react-lgpd-consent'
|
|
254
|
-
|
|
255
|
-
function CustomCookieBanner() {
|
|
256
|
-
const { acceptAll, acceptSelected, preferences } = useConsent()
|
|
257
|
-
const categories = useCategories()
|
|
258
|
-
|
|
259
|
-
return (
|
|
260
|
-
<div className="custom-banner">
|
|
261
|
-
<h3>🍪 Personalize sua experiência</h3>
|
|
262
|
-
<p>Utilizamos cookies para melhorar sua navegação.</p>
|
|
263
|
-
|
|
264
|
-
{categories.map((category) => (
|
|
265
|
-
<label key={category.id}>
|
|
266
|
-
<input
|
|
267
|
-
type="checkbox"
|
|
268
|
-
checked={preferences[category.id] ?? false}
|
|
269
|
-
disabled={category.essential}
|
|
270
|
-
/>
|
|
271
|
-
{category.name}
|
|
272
|
-
</label>
|
|
273
|
-
))}
|
|
274
|
-
|
|
275
|
-
<button onClick={acceptAll}>Aceitar Todos</button>
|
|
276
|
-
<button onClick={() => acceptSelected(preferences)}>
|
|
277
|
-
Salvar Preferências
|
|
278
|
-
</button>
|
|
279
|
-
</div>
|
|
280
|
-
)
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function App() {
|
|
284
|
-
return (
|
|
285
|
-
<ConsentProvider
|
|
286
|
-
categories={{ enabledCategories: ['analytics'] }}
|
|
287
|
-
CookieBannerComponent={CustomCookieBanner}
|
|
288
|
-
>
|
|
289
|
-
<YourApp />
|
|
290
|
-
</ConsentProvider>
|
|
291
|
-
)
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
## 🔧 API e Funcionalidades
|
|
296
|
-
|
|
297
|
-
### 📊 **Categorias de Cookies Suportadas**
|
|
298
|
-
|
|
299
|
-
<table>
|
|
300
|
-
<tr>
|
|
301
|
-
<th>Categoria</th>
|
|
302
|
-
<th>ID</th>
|
|
303
|
-
<th>Descrição</th>
|
|
304
|
-
<th>Essencial</th>
|
|
305
|
-
</tr>
|
|
306
|
-
<tr>
|
|
307
|
-
<td>🔒 <strong>Necessários</strong></td>
|
|
308
|
-
<td><code>necessary</code></td>
|
|
309
|
-
<td>Cookies essenciais para funcionamento básico</td>
|
|
310
|
-
<td>✅ Sempre ativo</td>
|
|
311
|
-
</tr>
|
|
312
|
-
<tr>
|
|
313
|
-
<td>📈 <strong>Analíticos</strong></td>
|
|
314
|
-
<td><code>analytics</code></td>
|
|
315
|
-
<td>Google Analytics, Adobe Analytics, etc.</td>
|
|
316
|
-
<td>❌ Opcional</td>
|
|
317
|
-
</tr>
|
|
318
|
-
<tr>
|
|
319
|
-
<td>🎯 <strong>Marketing</strong></td>
|
|
320
|
-
<td><code>marketing</code></td>
|
|
321
|
-
<td>Facebook Pixel, Google Ads, remarketing</td>
|
|
322
|
-
<td>❌ Opcional</td>
|
|
323
|
-
</tr>
|
|
324
|
-
<tr>
|
|
325
|
-
<td>⚙️ <strong>Funcionais</strong></td>
|
|
326
|
-
<td><code>functional</code></td>
|
|
327
|
-
<td>Chat, mapas, vídeos incorporados</td>
|
|
328
|
-
<td>❌ Opcional</td>
|
|
329
|
-
</tr>
|
|
330
|
-
<tr>
|
|
331
|
-
<td>👥 <strong>Sociais</strong></td>
|
|
332
|
-
<td><code>social</code></td>
|
|
333
|
-
<td>Botões de compartilhamento, comentários</td>
|
|
334
|
-
<td>❌ Opcional</td>
|
|
335
|
-
</tr>
|
|
336
|
-
<tr>
|
|
337
|
-
<td>🎨 <strong>Personalização</strong></td>
|
|
338
|
-
<td><code>personalization</code></td>
|
|
339
|
-
<td>Preferências, temas, idiomas</td>
|
|
340
|
-
<td>❌ Opcional</td>
|
|
341
|
-
</tr>
|
|
342
|
-
</table>
|
|
343
|
-
|
|
344
|
-
### 🎛️ **Configuração Avançada**
|
|
345
|
-
|
|
346
|
-
<details>
|
|
347
|
-
<summary><strong>ConsentProvider Props</strong></summary>
|
|
348
|
-
|
|
349
|
-
```tsx
|
|
350
|
-
interface ConsentProviderProps {
|
|
351
|
-
// ✨ Configuração de Categorias
|
|
352
|
-
categories: {
|
|
353
|
-
enabledCategories: CategoryId[]
|
|
354
|
-
customCategories?: CustomCategory[]
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// 🎨 Customização de UI
|
|
358
|
-
CookieBannerComponent?: ComponentType<CustomCookieBannerProps>
|
|
359
|
-
PreferencesModalComponent?: ComponentType<CustomPreferencesModalProps>
|
|
360
|
-
FloatingPreferencesButtonComponent?: ComponentType<CustomFloatingPreferencesButtonProps>
|
|
361
|
-
|
|
362
|
-
// 📝 Textos Personalizados
|
|
363
|
-
texts?: {
|
|
364
|
-
controllerInfo?: string
|
|
365
|
-
dataTypes?: string
|
|
366
|
-
userRights?: string
|
|
367
|
-
contactInfo?: string
|
|
368
|
-
// ... mais opções
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// ⚙️ Comportamento
|
|
372
|
-
blocking?: boolean // Banner bloqueante
|
|
373
|
-
disableDeveloperGuidance?: boolean // Desabilitar orientações
|
|
374
|
-
|
|
375
|
-
// 📊 Callbacks de Auditoria
|
|
376
|
-
onConsentGiven?: (state: ConsentState) => void
|
|
377
|
-
onConsentRevoked?: (state: ConsentState) => void
|
|
378
|
-
onPreferencesChanged?: (state: ConsentState) => void
|
|
379
|
-
}
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
</details>
|
|
383
|
-
|
|
384
|
-
### 🪝 **Hooks Disponíveis**
|
|
385
|
-
|
|
386
|
-
<details>
|
|
387
|
-
<summary><strong>useConsent()</strong></summary>
|
|
388
|
-
|
|
389
|
-
```tsx
|
|
390
|
-
const {
|
|
391
|
-
// 📊 Estado
|
|
392
|
-
consented, // boolean: usuário já deu consentimento?
|
|
393
|
-
preferences, // Record<string, boolean>: preferências por categoria
|
|
394
|
-
isHydrated, // boolean: dados carregados do cookie?
|
|
395
|
-
|
|
396
|
-
// 🎬 Ações
|
|
397
|
-
acceptAll, // () => void: aceitar todas as categorias
|
|
398
|
-
rejectAll, // () => void: rejeitar todas (exceto essenciais)
|
|
399
|
-
acceptSelected, // (prefs: Record<string, boolean>) => void
|
|
400
|
-
resetConsent, // () => void: limpar tudo e mostrar banner novamente
|
|
401
|
-
|
|
402
|
-
// 🔄 Controle de UI
|
|
403
|
-
showPreferences, // () => void: abrir modal de preferências
|
|
404
|
-
hidePreferences, // () => void: fechar modal
|
|
405
|
-
} = useConsent()
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
</details>
|
|
409
|
-
|
|
410
|
-
<details>
|
|
411
|
-
<summary><strong>useCategories()</strong></summary>
|
|
412
|
-
|
|
413
|
-
```tsx
|
|
414
|
-
const categories = useCategories() // Category[]
|
|
415
|
-
|
|
416
|
-
// Cada categoria tem:
|
|
417
|
-
interface Category {
|
|
418
|
-
id: string
|
|
419
|
-
name: string
|
|
420
|
-
description: string
|
|
421
|
-
essential: boolean
|
|
422
|
-
examples?: string[]
|
|
423
|
-
}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
</details>
|
|
427
|
-
|
|
428
|
-
<details>
|
|
429
|
-
<summary><strong>useCategoryStatus()</strong></summary>
|
|
430
|
-
|
|
431
|
-
```tsx
|
|
432
|
-
const isAnalyticsEnabled = useCategoryStatus('analytics') // boolean | null
|
|
433
|
-
// null = categoria não configurada
|
|
434
|
-
// true = categoria ativa e consentimento dado
|
|
435
|
-
// false = categoria ativa mas consentimento negado
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
</details>
|
|
439
|
-
|
|
440
|
-
### 🚀 **Integrações e Scripts**
|
|
441
|
-
|
|
442
|
-
<details>
|
|
443
|
-
<summary><strong>ConsentScriptLoader</strong></summary>
|
|
444
|
-
|
|
445
|
-
Carrega scripts automaticamente após o consentimento:
|
|
446
|
-
|
|
447
|
-
```tsx
|
|
448
|
-
import {
|
|
449
|
-
ConsentScriptLoader,
|
|
450
|
-
createGoogleAnalyticsIntegration,
|
|
451
|
-
createGoogleTagManagerIntegration,
|
|
452
|
-
createFacebookPixelIntegration,
|
|
453
|
-
} from 'react-lgpd-consent'
|
|
454
|
-
|
|
455
|
-
const integrations = [
|
|
456
|
-
createGoogleAnalyticsIntegration({
|
|
457
|
-
measurementId: 'G-XXXXXXXXXX',
|
|
458
|
-
anonymizeIP: true,
|
|
459
|
-
cookieFlags: 'SameSite=None; Secure',
|
|
460
|
-
}),
|
|
461
|
-
|
|
462
|
-
createGoogleTagManagerIntegration({
|
|
463
|
-
gtmId: 'GTM-XXXXXXX',
|
|
464
|
-
dataLayerName: 'dataLayer',
|
|
465
|
-
}),
|
|
466
|
-
|
|
467
|
-
createFacebookPixelIntegration({
|
|
468
|
-
pixelId: '1234567890',
|
|
469
|
-
advancedMatching: true,
|
|
470
|
-
}),
|
|
471
|
-
]
|
|
472
|
-
|
|
473
|
-
function App() {
|
|
474
|
-
return (
|
|
475
|
-
<ConsentProvider
|
|
476
|
-
categories={{ enabledCategories: ['analytics', 'marketing'] }}
|
|
477
|
-
>
|
|
478
|
-
<ConsentScriptLoader integrations={integrations} />
|
|
479
|
-
<YourApp />
|
|
480
|
-
</ConsentProvider>
|
|
481
|
-
)
|
|
482
|
-
}
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
</details>
|
|
486
|
-
|
|
487
|
-
<details>
|
|
488
|
-
<summary><strong>ConsentGate - Renderização Condicional</strong></summary>
|
|
489
|
-
|
|
490
|
-
Renderize componentes apenas com consentimento:
|
|
491
|
-
|
|
492
|
-
```tsx
|
|
493
|
-
import { ConsentGate } from 'react-lgpd-consent'
|
|
494
|
-
|
|
495
|
-
// Componente simples
|
|
496
|
-
<ConsentGate category="marketing">
|
|
497
|
-
<FacebookPixel />
|
|
498
|
-
</ConsentGate>
|
|
499
|
-
|
|
500
|
-
// Múltiplas categorias (AND)
|
|
501
|
-
<ConsentGate categories={['analytics', 'marketing']}>
|
|
502
|
-
<AdvancedTracking />
|
|
503
|
-
</ConsentGate>
|
|
504
|
-
|
|
505
|
-
// Fallback quando não consentido
|
|
506
|
-
<ConsentGate category="functional" fallback={<StaticMap />}>
|
|
507
|
-
<InteractiveMap />
|
|
508
|
-
</ConsentGate>
|
|
509
|
-
|
|
510
|
-
// Hook para lógica customizada
|
|
511
|
-
function MyComponent() {
|
|
512
|
-
const canShowAds = useCategoryStatus('marketing')
|
|
513
|
-
|
|
514
|
-
if (canShowAds === null) return <Loading />
|
|
515
|
-
if (!canShowAds) return <AdFreeExperience />
|
|
516
|
-
|
|
517
|
-
return <AdsEnabledExperience />
|
|
518
|
-
}
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
</details>
|
|
522
|
-
|
|
523
|
-
## 🛡️ Conformidade e LGPD
|
|
524
|
-
|
|
525
|
-
<div align="center">
|
|
526
|
-
<img src="https://img.shields.io/badge/Audit-Ready-007ACC?style=for-the-badge&logoColor=white" alt="Audit Ready">
|
|
527
|
-
<img src="https://img.shields.io/badge/Privacy-First-6f42c1?style=for-the-badge&logoColor=white" alt="Privacy First">
|
|
528
|
-
</div>
|
|
529
|
-
|
|
530
|
-
### 📋 **Checklist de Conformidade LGPD**
|
|
531
|
-
|
|
532
|
-
<table>
|
|
533
|
-
<tr>
|
|
534
|
-
<td width="50%">
|
|
535
|
-
|
|
536
|
-
#### ✅ **Princípios Implementados**
|
|
537
|
-
|
|
538
|
-
- **✅ Minimização**: Apenas dados necessários
|
|
539
|
-
- **✅ Transparência**: Textos claros e detalhados
|
|
540
|
-
- **✅ Consentimento Livre**: Não bloqueante por padrão
|
|
541
|
-
- **✅ Finalidade**: Categorias específicas e bem definidas
|
|
542
|
-
- **✅ Adequação**: Conformidade com ANPD
|
|
543
|
-
- **✅ Segurança**: Cookies HTTPOnly quando possível
|
|
544
|
-
|
|
545
|
-
</td>
|
|
546
|
-
<td width="50%">
|
|
547
|
-
|
|
548
|
-
#### 📊 **Auditoria e Logs**
|
|
549
|
-
|
|
550
|
-
- **🕐 Timestamp**: Data/hora do consentimento
|
|
551
|
-
- **📍 Origem**: Banner, modal ou API
|
|
552
|
-
- **🔄 Versionamento**: Controle de mudanças
|
|
553
|
-
- **📝 Metadados**: Configuração do projeto
|
|
554
|
-
- **🔍 Rastreabilidade**: Histórico completo
|
|
555
|
-
- **📋 Exportação**: Logs em formato JSON
|
|
556
|
-
|
|
557
|
-
</td>
|
|
558
|
-
</tr>
|
|
559
|
-
</table>
|
|
560
|
-
|
|
561
|
-
### 🏛️ **Conformidade Regulatória**
|
|
562
|
-
|
|
563
|
-
<details>
|
|
564
|
-
<summary><strong>🇧🇷 LGPD (Lei Geral de Proteção de Dados)</strong></summary>
|
|
565
|
-
|
|
566
|
-
**Artigos implementados:**
|
|
567
|
-
|
|
568
|
-
- **Art. 8º**: Consentimento livre, informado e inequívoco
|
|
569
|
-
- **Art. 9º**: Consentimento específico e destacado
|
|
570
|
-
- **Art. 18º**: Direitos do titular (acesso, correção, eliminação)
|
|
571
|
-
- **Art. 46º**: Tratamento de dados sensíveis
|
|
572
|
-
|
|
573
|
-
**Funcionalidades:**
|
|
574
|
-
|
|
575
|
-
```tsx
|
|
576
|
-
<ConsentProvider
|
|
577
|
-
texts={{
|
|
578
|
-
controllerInfo: 'Controlador: Empresa XYZ (CNPJ: XX.XXX.XXX/XXXX-XX)',
|
|
579
|
-
dataTypes: 'Dados de navegação, IP, cookies funcionais',
|
|
580
|
-
userRights: 'Direito de acesso, correção, eliminação e portabilidade',
|
|
581
|
-
contactInfo: 'DPO: privacy@empresa.com | Tel: (11) 9999-9999',
|
|
582
|
-
legalBasis: 'Consentimento (Art. 7º, I) e Legítimo Interesse (Art. 7º, IX)',
|
|
583
|
-
}}
|
|
584
|
-
/>
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
</details>
|
|
588
|
-
|
|
589
|
-
<details>
|
|
590
|
-
<summary><strong>🇪🇺 GDPR (General Data Protection Regulation)</strong></summary>
|
|
591
|
-
|
|
592
|
-
**Próxima versão (v0.3.0)** incluirá suporte completo ao GDPR:
|
|
593
|
-
|
|
594
|
-
- Consentimento granular por categoria
|
|
595
|
-
- Right to be forgotten (direito ao esquecimento)
|
|
596
|
-
- Data portability (portabilidade de dados)
|
|
597
|
-
- Consent withdrawal (retirada de consentimento)
|
|
598
|
-
|
|
599
|
-
</details>
|
|
600
|
-
|
|
601
|
-
<details>
|
|
602
|
-
<summary><strong>🇺🇸 CCPA (California Consumer Privacy Act)</strong></summary>
|
|
603
|
-
|
|
604
|
-
**Recursos CCPA planejados:**
|
|
605
|
-
|
|
606
|
-
- "Do Not Sell" toggle
|
|
607
|
-
- California resident detection
|
|
608
|
-
- Opt-out mechanisms
|
|
609
|
-
- Consumer rights notices
|
|
610
|
-
|
|
611
|
-
</details>
|
|
612
|
-
|
|
613
|
-
### 🏢 **Para Empresas e Auditoria**
|
|
614
|
-
|
|
615
|
-
<details>
|
|
616
|
-
<summary><strong>📊 Sistema de Auditoria Empresarial</strong></summary>
|
|
617
|
-
|
|
618
|
-
```tsx
|
|
619
|
-
import { ConsentProvider, useConsentAudit } from 'react-lgpd-consent'
|
|
620
|
-
|
|
621
|
-
function AuditDashboard() {
|
|
622
|
-
const auditData = useConsentAudit()
|
|
623
|
-
|
|
624
|
-
return (
|
|
625
|
-
<div>
|
|
626
|
-
<h3>📊 Relatório de Consentimento</h3>
|
|
627
|
-
<p>Total de usuários: {auditData.totalUsers}</p>
|
|
628
|
-
<p>Taxa de aceitação: {auditData.acceptanceRate}%</p>
|
|
629
|
-
<p>Última atualização: {auditData.lastUpdate}</p>
|
|
630
|
-
|
|
631
|
-
<button onClick={() => auditData.exportLogs('csv')}>
|
|
632
|
-
📥 Exportar Logs CSV
|
|
633
|
-
</button>
|
|
634
|
-
</div>
|
|
635
|
-
)
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
// Configuração com callbacks de auditoria
|
|
639
|
-
;<ConsentProvider
|
|
640
|
-
onConsentGiven={(state) => {
|
|
641
|
-
// Enviar para sistema de auditoria interno
|
|
642
|
-
fetch('/api/consent-audit', {
|
|
643
|
-
method: 'POST',
|
|
644
|
-
body: JSON.stringify({
|
|
645
|
-
userId: getCurrentUserId(),
|
|
646
|
-
timestamp: new Date().toISOString(),
|
|
647
|
-
preferences: state.preferences,
|
|
648
|
-
source: state.source,
|
|
649
|
-
version: state.version,
|
|
650
|
-
}),
|
|
651
|
-
})
|
|
652
|
-
}}
|
|
653
|
-
// ... outras props
|
|
654
|
-
/>
|
|
655
|
-
```
|
|
656
|
-
|
|
657
|
-
</details>
|
|
658
|
-
|
|
659
|
-
**💡 Recomendação**: Para implementação empresarial, considere nosso pacote premium `react-lgpd-consent-enterprise` com recursos avançados de auditoria e relatórios.
|
|
660
|
-
|
|
661
123
|
---
|
|
662
124
|
|
|
663
|
-
##
|
|
664
|
-
|
|
665
|
-
<div align="center">
|
|
666
|
-
<img src="https://contrib.rocks/image?repo=lucianoedipo/react-lgpd-consent" alt="Contributors">
|
|
667
|
-
</div>
|
|
668
|
-
|
|
669
|
-
Contribuições são **muito bem-vindas**! Este é um projeto open-source e da comunidade brasileira para a comunidade.
|
|
670
|
-
|
|
671
|
-
### 🚀 **Como Contribuir**
|
|
672
|
-
|
|
673
|
-
1. **🔧 Issues**: Reporte bugs ou sugira melhorias
|
|
674
|
-
2. **💡 Features**: Proponha novas funcionalidades
|
|
675
|
-
3. **📖 Documentação**: Melhore a documentação
|
|
676
|
-
4. **🧪 Testes**: Adicione ou melhore os testes
|
|
677
|
-
5. **🌍 Internacionalização**: Ajude com traduções
|
|
678
|
-
|
|
679
|
-
### 📋 **Roadmap**
|
|
680
|
-
|
|
681
|
-
<details>
|
|
682
|
-
<summary><strong>🗺️ Próximas Versões</strong></summary>
|
|
683
|
-
|
|
684
|
-
#### v0.3.X+ - Compliance Avançado (Em Desenvolvimento)
|
|
125
|
+
## 📚 Documentação Completa
|
|
685
126
|
|
|
686
|
-
|
|
687
|
-
- [ ] Templates setoriais (governo, saúde, educação)
|
|
688
|
-
- [ ] Presets visuais por setor (WCAG AAA)
|
|
689
|
-
- [ ] Modal detalhado de cookies
|
|
127
|
+
Para mais detalhes sobre customização, hooks e funcionalidades, consulte os seguintes guias:
|
|
690
128
|
|
|
691
|
-
|
|
129
|
+
- **[Guia da API (`API.md`)](./API.md)**: Referência completa de todos os componentes, hooks e tipos.
|
|
130
|
+
- **[Guia de Conformidade (`CONFORMIDADE.md`)](./CONFORMIDADE.md)**: Detalhes sobre as funcionalidades de conformidade com a LGPD.
|
|
131
|
+
- **[Guia de Integrações (`INTEGRACOES.md`)](./INTEGRACOES.md)**: Como usar as integrações nativas e criar as suas.
|
|
692
132
|
|
|
693
|
-
|
|
694
|
-
- [ ] Implementação CCPA
|
|
695
|
-
- [ ] Sistema de plugins extensível
|
|
696
|
-
- [ ] API server-side para Next.js
|
|
697
|
-
|
|
698
|
-
#### v0.5.0 - Enterprise Features
|
|
699
|
-
|
|
700
|
-
- [ ] Dashboard de analytics
|
|
701
|
-
- [ ] A/B testing para banners
|
|
702
|
-
- [ ] Integração com CMPs existentes
|
|
703
|
-
- [ ] SDK para mobile (React Native)
|
|
133
|
+
---
|
|
704
134
|
|
|
705
|
-
|
|
135
|
+
## 🤝 Como Contribuir
|
|
706
136
|
|
|
707
|
-
|
|
137
|
+
Contribuições são muito bem-vindas! Este é um projeto open-source para a comunidade brasileira.
|
|
708
138
|
|
|
709
|
-
|
|
710
|
-
|
|
139
|
+
1. **Reporte Bugs ou Sugira Melhorias**: Abra uma [Issue no GitHub](https://github.com/lucianoedipo/react-lgpd-consent/issues).
|
|
140
|
+
2. **Envie um Pull Request**: Siga as instruções no nosso [Guia de Desenvolvimento (`DEVELOPMENT.md`)](./DEVELOPMENT.md).
|
|
711
141
|
|
|
712
142
|
---
|
|
713
143
|
|
|
714
144
|
## 📄 Licença
|
|
715
145
|
|
|
716
|
-
|
|
717
|
-
<p>
|
|
718
|
-
<img src="https://img.shields.io/npm/l/react-lgpd-consent?style=for-the-badge&color=green&logoColor=white" alt="MIT License">
|
|
719
|
-
</p>
|
|
720
|
-
<p>
|
|
721
|
-
Este projeto está licenciado sob a <strong>MIT License</strong>.<br>
|
|
722
|
-
Veja o arquivo <a href="LICENSE"><strong>LICENSE</strong></a> para mais detalhes.
|
|
723
|
-
</p>
|
|
724
|
-
<p>
|
|
725
|
-
<em>Feito com ❤️ por <a href="https://github.com/lucianoedipo">@lucianoedipo</a> e a comunidade brasileira</em>
|
|
726
|
-
</p>
|
|
727
|
-
</div>
|
|
728
|
-
|
|
729
|
-
---
|
|
730
|
-
|
|
731
|
-
<div align="center">
|
|
732
|
-
<h3>⭐ Se este projeto te ajudou, deixe uma estrela!</h3>
|
|
733
|
-
<p>
|
|
734
|
-
<a href="https://github.com/lucianoedipo/react-lgpd-consent/stargazers">
|
|
735
|
-
<img src="https://img.shields.io/github/stars/lucianoedipo/react-lgpd-consent?style=social" alt="Stars">
|
|
736
|
-
</a>
|
|
737
|
-
</p>
|
|
738
|
-
</div>
|
|
146
|
+
Este projeto está licenciado sob a **MIT License**. Veja o arquivo [LICENSE](./LICENSE) para mais detalhes.
|