react-lgpd-consent 0.3.0 → 0.3.1
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 +481 -0
- package/README.md +646 -79
- package/dist/{PreferencesModal-XCTM6WJN.js → PreferencesModal-J27W5XAJ.js} +1 -1
- package/dist/{chunk-R3IKVZBC.js → chunk-VFAOBR3X.js} +392 -82
- package/dist/index.cjs +437 -105
- package/dist/index.d.cts +53 -1
- package/dist/index.d.ts +53 -1
- package/dist/index.js +11 -3
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,171 +1,738 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>react-lgpd-consent 🍪 </h1>
|
|
3
|
+
<p><strong>A biblioteca de consentimento de cookies mais completa para React</strong></p>
|
|
4
|
+
<p>Conformidade com LGPD, GDPR e CCPA (Partial) • TypeScript First • Zero Config</p>
|
|
5
|
+
|
|
6
|
+
<div>
|
|
7
|
+
<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>
|
|
8
|
+
<a href="https://www.npmjs.com/package/react-lgpd-consent"><img src="https://img.shields.io/npm/dm/react-lgpd-consent?style=for-the-badge&logo=npm&color=ff6b35&logoColor=white" alt="Downloads"></a>
|
|
9
|
+
<a href="https://github.com/lucianoedipo/react-lgpd-consent/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/react-lgpd-consent?style=for-the-badge&color=green&logoColor=white" alt="License"></a>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div>
|
|
13
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-3178c6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript Ready"></a>
|
|
14
|
+
<a href="https://reactjs.org/"><img src="https://img.shields.io/badge/React-18+-61dafb?style=for-the-badge&logo=react&logoColor=white" alt="React 18+"></a>
|
|
15
|
+
<a href="https://nextjs.org/"><img src="https://img.shields.io/badge/Next.js-Compatible-000000?style=for-the-badge&logo=next.js&logoColor=white" alt="Next.js Compatible"></a>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<br>
|
|
19
|
+
|
|
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
|
+
<p>
|
|
23
|
+
<a href="#-instalação"><strong>Instalação</strong></a> •
|
|
24
|
+
<a href="#-uso-básico"><strong>Começar Agora</strong></a> •
|
|
25
|
+
<a href="#-características-principais"><strong>Funcionalidades</strong></a> •
|
|
26
|
+
<a href="#-api-e-funcionalidades"><strong>Documentação</strong></a> •
|
|
27
|
+
<a href="#-conformidade-e-lgpd"><strong>Compliance</strong></a>
|
|
28
|
+
</p>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🆕 **Novidades v0.3.1 - Production Fixes**
|
|
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
|
|
2
44
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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>
|
|
8
56
|
|
|
9
|
-
|
|
57
|
+
// ✅ Controle programático - NOVO!
|
|
58
|
+
const openModal = useOpenPreferencesModal() // Hook React
|
|
59
|
+
openPreferencesModal() // Função global JavaScript
|
|
60
|
+
```
|
|
10
61
|
|
|
11
|
-
|
|
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
|
|
12
72
|
|
|
13
73
|
## ✨ Características Principais
|
|
14
74
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
75
|
+
<table>
|
|
76
|
+
<tr>
|
|
77
|
+
<td width="50%">
|
|
78
|
+
|
|
79
|
+
### 🇧🇷 **Compliance Brasileiro**
|
|
80
|
+
|
|
81
|
+
- **LGPD/ANPD Oficial**: Implementação baseada nas diretrizes oficiais
|
|
82
|
+
- **Auditoria Completa**: Logs detalhados para conformidade
|
|
83
|
+
- **Minimização de Dados**: Armazena apenas o essencial
|
|
84
|
+
- **Transparência Total**: Textos e metadados completos
|
|
85
|
+
|
|
86
|
+
</td>
|
|
87
|
+
<td width="50%">
|
|
88
|
+
|
|
89
|
+
### 🧠 **Developer Experience**
|
|
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>
|
|
26
131
|
|
|
27
132
|
## 🚀 Instalação
|
|
28
133
|
|
|
134
|
+
<details>
|
|
135
|
+
<summary><strong>📦 NPM/Yarn/PNPM</strong></summary>
|
|
136
|
+
|
|
29
137
|
```bash
|
|
138
|
+
# NPM
|
|
30
139
|
npm install react-lgpd-consent
|
|
140
|
+
|
|
141
|
+
# Yarn
|
|
142
|
+
yarn add react-lgpd-consent
|
|
143
|
+
|
|
144
|
+
# PNPM
|
|
145
|
+
pnpm add react-lgpd-consent
|
|
31
146
|
```
|
|
32
147
|
|
|
33
|
-
|
|
148
|
+
</details>
|
|
149
|
+
|
|
150
|
+
<details>
|
|
151
|
+
<summary><strong>📋 Dependências Peer</strong></summary>
|
|
152
|
+
|
|
153
|
+
Certifique-se de ter as seguintes dependências instaladas:
|
|
34
154
|
|
|
35
155
|
```bash
|
|
36
|
-
npm install react react-dom @mui/material js-cookie
|
|
156
|
+
npm install react react-dom @mui/material @emotion/react @emotion/styled js-cookie
|
|
37
157
|
```
|
|
38
158
|
|
|
159
|
+
**Versões suportadas:**
|
|
160
|
+
|
|
161
|
+
- React: `^18.0.0`
|
|
162
|
+
- Material-UI: `^5.0.0`
|
|
163
|
+
- TypeScript: `^4.5.0` (opcional, mas recomendado)
|
|
164
|
+
|
|
165
|
+
</details>
|
|
166
|
+
|
|
167
|
+
<details>
|
|
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>
|
|
177
|
+
|
|
39
178
|
## 📖 Uso Básico
|
|
40
179
|
|
|
41
|
-
|
|
180
|
+
### 🎯 **Setup em 30 segundos**
|
|
42
181
|
|
|
43
182
|
```tsx
|
|
44
|
-
// Em seu componente principal, como App.tsx
|
|
45
183
|
import { ConsentProvider } from 'react-lgpd-consent'
|
|
46
184
|
|
|
47
185
|
function App() {
|
|
48
186
|
return (
|
|
49
187
|
<ConsentProvider
|
|
50
|
-
// 1. Especifique as categorias que seu site utiliza
|
|
51
188
|
categories={{
|
|
52
189
|
enabledCategories: ['analytics', 'marketing'],
|
|
53
190
|
}}
|
|
54
|
-
|
|
191
|
+
>
|
|
192
|
+
{/* Sua aplicação */}
|
|
193
|
+
<YourApp />
|
|
194
|
+
</ConsentProvider>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 🔥 **Exemplo Completo com Integrações**
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
import {
|
|
203
|
+
ConsentProvider,
|
|
204
|
+
ConsentScriptLoader,
|
|
205
|
+
createGoogleAnalyticsIntegration,
|
|
206
|
+
createGoogleTagManagerIntegration,
|
|
207
|
+
} from 'react-lgpd-consent'
|
|
208
|
+
|
|
209
|
+
const integrations = [
|
|
210
|
+
createGoogleAnalyticsIntegration({
|
|
211
|
+
measurementId: 'G-XXXXXXXXXX',
|
|
212
|
+
}),
|
|
213
|
+
createGoogleTagManagerIntegration({
|
|
214
|
+
gtmId: 'GTM-XXXXXXX',
|
|
215
|
+
}),
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
function App() {
|
|
219
|
+
return (
|
|
220
|
+
<ConsentProvider
|
|
221
|
+
categories={{
|
|
222
|
+
enabledCategories: ['analytics', 'marketing', 'functional'],
|
|
223
|
+
}}
|
|
55
224
|
texts={{
|
|
56
|
-
controllerInfo:
|
|
57
|
-
|
|
225
|
+
controllerInfo:
|
|
226
|
+
'Controlado por: Sua Empresa LTDA (CNPJ: XX.XXX.XXX/XXXX-XX)',
|
|
227
|
+
dataTypes: 'Coletamos dados de navegação, preferências e interações.',
|
|
228
|
+
userRights:
|
|
229
|
+
'Você pode acessar, corrigir ou excluir seus dados a qualquer momento.',
|
|
230
|
+
contactInfo: 'Entre em contato: privacy@suaempresa.com',
|
|
231
|
+
}}
|
|
232
|
+
onConsentGiven={(state) => {
|
|
233
|
+
console.log('✅ Consentimento registrado:', state)
|
|
234
|
+
// Opcional: enviar para seu sistema de auditoria
|
|
235
|
+
}}
|
|
236
|
+
onConsentRevoked={(state) => {
|
|
237
|
+
console.log('❌ Consentimento revogado:', state)
|
|
58
238
|
}}
|
|
59
|
-
// 3. (Opcional) Adicione callbacks para auditoria
|
|
60
|
-
onConsentGiven={(state) => console.log('Consentimento dado:', state)}
|
|
61
239
|
>
|
|
62
|
-
{/*
|
|
63
|
-
<
|
|
64
|
-
<p>Bem-vindo ao meu site.</p>
|
|
240
|
+
{/* Scripts carregados automaticamente após consentimento */}
|
|
241
|
+
<ConsentScriptLoader integrations={integrations} />
|
|
65
242
|
|
|
66
|
-
{/*
|
|
67
|
-
|
|
243
|
+
{/* Sua aplicação */}
|
|
244
|
+
<HomePage />
|
|
68
245
|
</ConsentProvider>
|
|
69
246
|
)
|
|
70
247
|
}
|
|
248
|
+
```
|
|
249
|
+
|
|
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()
|
|
71
258
|
|
|
72
|
-
|
|
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
|
+
}
|
|
73
293
|
```
|
|
74
294
|
|
|
75
295
|
## 🔧 API e Funcionalidades
|
|
76
296
|
|
|
77
|
-
###
|
|
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
|
+
```
|
|
78
381
|
|
|
79
|
-
|
|
382
|
+
</details>
|
|
383
|
+
|
|
384
|
+
### 🪝 **Hooks Disponíveis**
|
|
385
|
+
|
|
386
|
+
<details>
|
|
387
|
+
<summary><strong>useConsent()</strong></summary>
|
|
80
388
|
|
|
81
389
|
```tsx
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
}
|
|
90
424
|
```
|
|
91
425
|
|
|
92
|
-
|
|
426
|
+
</details>
|
|
93
427
|
|
|
94
|
-
|
|
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:
|
|
95
446
|
|
|
96
447
|
```tsx
|
|
97
448
|
import {
|
|
98
|
-
ConsentProvider,
|
|
99
449
|
ConsentScriptLoader,
|
|
100
450
|
createGoogleAnalyticsIntegration,
|
|
451
|
+
createGoogleTagManagerIntegration,
|
|
452
|
+
createFacebookPixelIntegration,
|
|
101
453
|
} from 'react-lgpd-consent'
|
|
102
454
|
|
|
103
455
|
const integrations = [
|
|
104
456
|
createGoogleAnalyticsIntegration({
|
|
105
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,
|
|
106
470
|
}),
|
|
107
471
|
]
|
|
108
472
|
|
|
109
473
|
function App() {
|
|
110
474
|
return (
|
|
111
|
-
<ConsentProvider
|
|
112
|
-
{
|
|
475
|
+
<ConsentProvider
|
|
476
|
+
categories={{ enabledCategories: ['analytics', 'marketing'] }}
|
|
477
|
+
>
|
|
113
478
|
<ConsentScriptLoader integrations={integrations} />
|
|
114
|
-
|
|
115
|
-
{/* ... resto do app */}
|
|
479
|
+
<YourApp />
|
|
116
480
|
</ConsentProvider>
|
|
117
481
|
)
|
|
118
482
|
}
|
|
119
483
|
```
|
|
120
484
|
|
|
121
|
-
|
|
485
|
+
</details>
|
|
486
|
+
|
|
487
|
+
<details>
|
|
488
|
+
<summary><strong>ConsentGate - Renderização Condicional</strong></summary>
|
|
122
489
|
|
|
123
|
-
Renderize componentes
|
|
490
|
+
Renderize componentes apenas com consentimento:
|
|
124
491
|
|
|
125
492
|
```tsx
|
|
126
493
|
import { ConsentGate } from 'react-lgpd-consent'
|
|
127
494
|
|
|
128
|
-
|
|
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
|
+
|
|
129
624
|
return (
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
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>
|
|
134
635
|
)
|
|
135
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
|
+
/>
|
|
136
655
|
```
|
|
137
656
|
|
|
138
|
-
|
|
657
|
+
</details>
|
|
139
658
|
|
|
140
|
-
|
|
659
|
+
**💡 Recomendação**: Para implementação empresarial, considere nosso pacote premium `react-lgpd-consent-enterprise` com recursos avançados de auditoria e relatórios.
|
|
141
660
|
|
|
142
|
-
|
|
143
|
-
- **Controle Simplificado do Modal**: A prop `disableAutomaticModal` foi removida. A visibilidade do modal é controlada internamente.
|
|
144
|
-
- **Remoção de Hooks Internos**: O hook `useConsentComponentProps` foi removido para simplificar a API. Use `useConsent()` e `useConsentTexts()` diretamente.
|
|
661
|
+
---
|
|
145
662
|
|
|
146
|
-
|
|
663
|
+
## 🤝 Contribuições
|
|
147
664
|
|
|
148
|
-
|
|
665
|
+
<div align="center">
|
|
666
|
+
<img src="https://contrib.rocks/image?repo=lucianoedipo/react-lgpd-consent" alt="Contributors">
|
|
667
|
+
</div>
|
|
149
668
|
|
|
150
|
-
-
|
|
151
|
-
- `useCategories()`: Retorna a lista de todas as categorias ativas no projeto.
|
|
152
|
-
- `useCategoryStatus('id')`: Verifica se uma categoria específica está ativa e configurada.
|
|
669
|
+
Contribuições são **muito bem-vindas**! Este é um projeto open-source e da comunidade brasileira para a comunidade.
|
|
153
670
|
|
|
154
|
-
|
|
671
|
+
### 🚀 **Como Contribuir**
|
|
155
672
|
|
|
156
|
-
|
|
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
|
|
157
678
|
|
|
158
|
-
|
|
159
|
-
- **Minimização de Dados**: Apenas as categorias declaradas são gerenciadas e armazenadas no cookie.
|
|
160
|
-
- **Transparência**: O sistema de textos e o cookie de auditoria fornecem informações claras.
|
|
161
|
-
- **Facilidade de Revogação**: O usuário pode alterar suas preferências a qualquer momento.
|
|
679
|
+
### 📋 **Roadmap**
|
|
162
680
|
|
|
163
|
-
|
|
681
|
+
<details>
|
|
682
|
+
<summary><strong>🗺️ Próximas Versões</strong></summary>
|
|
164
683
|
|
|
165
|
-
|
|
684
|
+
#### v0.3.X+ - Compliance Avançado (Em Desenvolvimento)
|
|
685
|
+
|
|
686
|
+
- [x] Sistema completo de logs de auditoria
|
|
687
|
+
- [ ] Templates setoriais (governo, saúde, educação)
|
|
688
|
+
- [ ] Presets visuais por setor (WCAG AAA)
|
|
689
|
+
- [ ] Modal detalhado de cookies
|
|
690
|
+
|
|
691
|
+
#### v0.4.0 - Multi-Regulamentação
|
|
692
|
+
|
|
693
|
+
- [ ] Suporte completo GDPR
|
|
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)
|
|
704
|
+
|
|
705
|
+
</details>
|
|
706
|
+
|
|
707
|
+
### 💬 **Comunidade**
|
|
708
|
+
|
|
709
|
+
- **🐛 Issues**: [GitHub Issues](https://github.com/lucianoedipo/react-lgpd-consent/issues)
|
|
710
|
+
- **💬 Discussões**: [GitHub Discussions](https://github.com/lucianoedipo/react-lgpd-consent/discussions)
|
|
166
711
|
|
|
167
|
-
|
|
712
|
+
---
|
|
168
713
|
|
|
169
714
|
## 📄 Licença
|
|
170
715
|
|
|
171
|
-
|
|
716
|
+
<div align="center">
|
|
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>
|