react-lgpd-consent 0.2.5 → 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/COMPLIANCE.md +73 -287
- package/README.md +540 -553
- package/dist/{PreferencesModal-B6N62JYB.js → PreferencesModal-J27W5XAJ.js} +1 -1
- package/dist/chunk-VFAOBR3X.js +1380 -0
- package/dist/index.cjs +1054 -633
- package/dist/index.d.cts +193 -125
- package/dist/index.d.ts +193 -125
- package/dist/index.js +13 -180
- package/package.json +16 -4
- package/dist/chunk-4LLZREFO.js +0 -829
package/README.md
CHANGED
|
@@ -1,751 +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>
|
|
2
30
|
|
|
3
|
-
|
|
31
|
+
---
|
|
4
32
|
|
|
5
|
-
|
|
33
|
+
## 🆕 **Novidades v0.3.1 - Production Fixes**
|
|
6
34
|
|
|
7
|
-
|
|
8
|
-
- 🎯 **UI Dinâmica**: Componentes se adaptam à configuração do projeto
|
|
9
|
-
- 🛡️ **Compliance por Design**: Previne problemas de conformidade LGPD
|
|
10
|
-
- 🔧 **Hooks Avançados**: `useCategories()` e `useCategoryStatus()` para controle total
|
|
35
|
+
### 🛡️ Correções Críticas Implementadas
|
|
11
36
|
|
|
12
|
-
|
|
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
|
|
13
42
|
|
|
14
|
-
|
|
43
|
+
### 🎯 Para Quem Estava Com Problemas
|
|
15
44
|
|
|
16
45
|
```tsx
|
|
17
|
-
|
|
18
|
-
|
|
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 />
|
|
19
55
|
</ConsentProvider>
|
|
56
|
+
|
|
57
|
+
// ✅ Controle programático - NOVO!
|
|
58
|
+
const openModal = useOpenPreferencesModal() // Hook React
|
|
59
|
+
openPreferencesModal() // Função global JavaScript
|
|
20
60
|
```
|
|
21
61
|
|
|
22
|
-
|
|
62
|
+
## 🎯 **Por que escolher react-lgpd-consent?**
|
|
23
63
|
|
|
24
|
-
|
|
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.
|
|
25
65
|
|
|
26
|
-
###
|
|
66
|
+
### 🏆 **Diferencial Competitivo**
|
|
27
67
|
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
30
72
|
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<ConsentProvider
|
|
34
|
-
// 🛡️ Especificar apenas categorias necessárias (Minimização de Dados LGPD)
|
|
35
|
-
categories={{
|
|
36
|
-
enabledCategories: ['analytics'], // Apenas analytics + necessary
|
|
37
|
-
}}
|
|
73
|
+
## ✨ Características Principais
|
|
38
74
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
controllerInfo: "Controlado por: Empresa XYZ - CNPJ: 00.000.000/0001-00",
|
|
43
|
-
dataTypes: "Coletamos: dados de navegação para análise estatística",
|
|
44
|
-
userRights: "Direitos: acessar, corrigir, excluir dados (dpo@empresa.com)"
|
|
45
|
-
}}
|
|
75
|
+
<table>
|
|
76
|
+
<tr>
|
|
77
|
+
<td width="50%">
|
|
46
78
|
|
|
47
|
-
|
|
48
|
-
onConsentGiven={(state) => console.log('Consentimento registrado:', state)}
|
|
49
|
-
>
|
|
50
|
-
<CookieBanner policyLinkUrl="/politica-de-privacidade" />
|
|
51
|
-
<YourApp />
|
|
52
|
-
</ConsentProvider>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
```eact-lgpd-consent?style=for-the-badge)](https://github.com/lucianoedipo/react-lgpd-consent/blob/main/LICENSE)
|
|
56
|
-
[](https://www.typescriptlang.org/)
|
|
57
|
-
[](https://reactjs.org/)
|
|
58
|
-
[](https://mui.com/)
|
|
59
|
-
[](https://bundlephobia.com/package/react-lgpd-consent)
|
|
60
|
-
[](https://www.npmjs.com/package/react-lgpd-consent)
|
|
79
|
+
### 🇧🇷 **Compliance Brasileiro**
|
|
61
80
|
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
64
85
|
|
|
65
|
-
>
|
|
86
|
+
</td>
|
|
87
|
+
<td width="50%">
|
|
66
88
|
|
|
67
|
-
|
|
89
|
+
### 🧠 **Developer Experience**
|
|
68
90
|
|
|
69
|
-
|
|
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
|
|
70
95
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- ⏰ **Auditoria Completa**: Timestamps e rastreabilidade para prestação de contas
|
|
76
|
-
- ⚡ **Client-Side First**: Arquitetura otimizada para SPA com zero-flash
|
|
77
|
-
- 🎨 **Material-UI Integration**: Componentes prontos e customizáveis com MUI
|
|
78
|
-
- ♿ **Acessibilidade**: Navegação por teclado e leitores de tela nativamente suportados
|
|
79
|
-
- 🌐 **Internacionalização**: Textos totalmente customizáveis (padrão pt-BR)
|
|
80
|
-
- 🚀 **TypeScript**: API completamente tipada para melhor DX
|
|
81
|
-
- 📦 **Zero Config**: Funciona out-of-the-box com configurações sensatas
|
|
82
|
-
- 🎯 **Granular Control**: Controle individual por categoria ativa
|
|
83
|
-
- 🚫 **Banner Bloqueante**: Modo opcional para exigir interação antes de continuar
|
|
84
|
-
- 🎨 **Sistema de Temas**: Temas customizáveis para integração visual perfeita
|
|
85
|
-
- ⚡ **Carregamento Automático**: Scripts só executam após consentimento explícito
|
|
86
|
-
- 🔌 **Modal Automático**: Modal de preferências incluído automaticamente com lazy loading
|
|
87
|
-
- 🎛️ **Botão Flutuante**: Componente opcional para acesso fácil às preferências
|
|
96
|
+
</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>
|
|
88
100
|
|
|
89
|
-
|
|
101
|
+
### 🎨 **UI/UX Inteligente**
|
|
90
102
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
# ou
|
|
96
|
-
pnpm add react-lgpd-consent
|
|
97
|
-
````
|
|
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
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
</td>
|
|
109
|
+
<td>
|
|
100
110
|
|
|
101
|
-
|
|
102
|
-
npm install @mui/material js-cookie
|
|
103
|
-
```
|
|
111
|
+
### ⚡ **Performance**
|
|
104
112
|
|
|
105
|
-
|
|
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
|
|
106
117
|
|
|
107
|
-
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
</table>
|
|
108
121
|
|
|
109
|
-
|
|
122
|
+
### 🚀 **Integrações Nativas**
|
|
110
123
|
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
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>
|
|
117
131
|
|
|
118
|
-
|
|
132
|
+
## 🚀 Instalação
|
|
119
133
|
|
|
120
|
-
|
|
134
|
+
<details>
|
|
135
|
+
<summary><strong>📦 NPM/Yarn/PNPM</strong></summary>
|
|
121
136
|
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
enabledCategories: ['analytics'], // Apenas analytics + necessary
|
|
126
|
-
customCategories: [{
|
|
127
|
-
id: 'governo',
|
|
128
|
-
name: 'Integração Governamental',
|
|
129
|
-
description: 'Cookies para sistemas gov.br',
|
|
130
|
-
essential: false
|
|
131
|
-
}]
|
|
132
|
-
}}
|
|
133
|
-
blocking={true} // Banner bloqueia até decisão explícita
|
|
134
|
-
>
|
|
135
|
-
```
|
|
137
|
+
```bash
|
|
138
|
+
# NPM
|
|
139
|
+
npm install react-lgpd-consent
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
# Yarn
|
|
142
|
+
yarn add react-lgpd-consent
|
|
138
143
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
"version": "1.0",
|
|
142
|
-
"consented": true,
|
|
143
|
-
"preferences": { "necessary": true, "analytics": false, "governo": true },
|
|
144
|
-
"consentDate": "2025-08-12T14:30:00.000Z",
|
|
145
|
-
"lastUpdate": "2025-08-12T14:30:00.000Z",
|
|
146
|
-
"source": "banner"
|
|
147
|
-
}
|
|
144
|
+
# PNPM
|
|
145
|
+
pnpm add react-lgpd-consent
|
|
148
146
|
```
|
|
149
147
|
|
|
150
|
-
>
|
|
148
|
+
</details>
|
|
151
149
|
|
|
152
|
-
|
|
150
|
+
<details>
|
|
151
|
+
<summary><strong>📋 Dependências Peer</strong></summary>
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
Certifique-se de ter as seguintes dependências instaladas:
|
|
155
154
|
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
<ConsentProvider>
|
|
159
|
-
<App />
|
|
160
|
-
</ConsentProvider>
|
|
161
|
-
// Console: "Usando padrão: necessary + analytics. Especificar para produção."
|
|
162
|
-
|
|
163
|
-
// ✅ Configuração explícita - recomendado
|
|
164
|
-
<ConsentProvider
|
|
165
|
-
categories={{
|
|
166
|
-
enabledCategories: ['analytics', 'marketing'],
|
|
167
|
-
customCategories: [...]
|
|
168
|
-
}}
|
|
169
|
-
>
|
|
170
|
-
<App />
|
|
171
|
-
</ConsentProvider>
|
|
155
|
+
```bash
|
|
156
|
+
npm install react react-dom @mui/material @emotion/react @emotion/styled js-cookie
|
|
172
157
|
```
|
|
173
158
|
|
|
174
|
-
**
|
|
159
|
+
**Versões suportadas:**
|
|
175
160
|
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
161
|
+
- React: `^18.0.0`
|
|
162
|
+
- Material-UI: `^5.0.0`
|
|
163
|
+
- TypeScript: `^4.5.0` (opcional, mas recomendado)
|
|
179
164
|
|
|
180
|
-
>
|
|
165
|
+
</details>
|
|
181
166
|
|
|
182
|
-
|
|
167
|
+
<details>
|
|
168
|
+
<summary><strong>🎯 Instalação Completa (Recomendada)</strong></summary>
|
|
183
169
|
|
|
184
|
-
|
|
185
|
-
// LEGACY: ainda suportado, mas deprecated
|
|
186
|
-
const customCategories = [
|
|
187
|
-
{
|
|
188
|
-
id: 'governo',
|
|
189
|
-
name: 'Integração Governo',
|
|
190
|
-
description: 'Cookies para integração com sistemas governamentais.',
|
|
191
|
-
essential: false,
|
|
192
|
-
cookies: ['gov_session', 'cpf_hash']
|
|
193
|
-
}
|
|
194
|
-
]
|
|
170
|
+
Para uma experiência completa, instale com todas as integrações:
|
|
195
171
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
</ConsentProvider>
|
|
172
|
+
```bash
|
|
173
|
+
npm install react-lgpd-consent @mui/material @emotion/react @emotion/styled js-cookie
|
|
199
174
|
```
|
|
200
175
|
|
|
201
|
-
|
|
176
|
+
</details>
|
|
202
177
|
|
|
203
|
-
|
|
178
|
+
## 📖 Uso Básico
|
|
204
179
|
|
|
205
|
-
|
|
206
|
-
import { useCategories, useCategoryStatus } from 'react-lgpd-consent'
|
|
180
|
+
### 🎯 **Setup em 30 segundos**
|
|
207
181
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const { toggleableCategories } = useCategories()
|
|
211
|
-
const { preferences, setPreferences } = useConsent()
|
|
182
|
+
```tsx
|
|
183
|
+
import { ConsentProvider } from 'react-lgpd-consent'
|
|
212
184
|
|
|
185
|
+
function App() {
|
|
213
186
|
return (
|
|
214
|
-
<
|
|
215
|
-
{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
setPreferences({
|
|
223
|
-
...preferences,
|
|
224
|
-
[category.id]: e.target.checked,
|
|
225
|
-
})
|
|
226
|
-
}
|
|
227
|
-
/>
|
|
228
|
-
<strong>{category.name}</strong>
|
|
229
|
-
<p>{category.description}</p>
|
|
230
|
-
</label>
|
|
231
|
-
))}
|
|
232
|
-
</dialog>
|
|
187
|
+
<ConsentProvider
|
|
188
|
+
categories={{
|
|
189
|
+
enabledCategories: ['analytics', 'marketing'],
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
{/* Sua aplicação */}
|
|
193
|
+
<YourApp />
|
|
194
|
+
</ConsentProvider>
|
|
233
195
|
)
|
|
234
196
|
}
|
|
235
|
-
|
|
236
|
-
// ✅ Feature condicional baseada em configuração
|
|
237
|
-
function AnalyticsDashboard() {
|
|
238
|
-
const analytics = useCategoryStatus('analytics')
|
|
239
|
-
|
|
240
|
-
if (!analytics.isActive) {
|
|
241
|
-
return null // Categoria não configurada - não renderiza
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return <div>Dashboard só aparece se analytics estiver configurado!</div>
|
|
245
|
-
}
|
|
246
197
|
```
|
|
247
198
|
|
|
248
|
-
**
|
|
249
|
-
|
|
250
|
-
- ✅ **Zero bugs**: UI sempre consistente com configuração
|
|
251
|
-
- ✅ **Performance**: Não renderiza categorias não utilizadas
|
|
252
|
-
- ✅ **Manutenibilidade**: Mudou configuração? UI atualiza automaticamente
|
|
253
|
-
- ✅ **Orientação**: Console avisa sobre inconsistências
|
|
254
|
-
|
|
255
|
-
### 🚀 Integrações Automáticas
|
|
199
|
+
### 🔥 **Exemplo Completo com Integrações**
|
|
256
200
|
|
|
257
201
|
```tsx
|
|
258
202
|
import {
|
|
203
|
+
ConsentProvider,
|
|
259
204
|
ConsentScriptLoader,
|
|
260
205
|
createGoogleAnalyticsIntegration,
|
|
261
|
-
|
|
206
|
+
createGoogleTagManagerIntegration,
|
|
262
207
|
} from 'react-lgpd-consent'
|
|
263
208
|
|
|
264
209
|
const integrations = [
|
|
265
210
|
createGoogleAnalyticsIntegration({
|
|
266
|
-
measurementId: '
|
|
211
|
+
measurementId: 'G-XXXXXXXXXX',
|
|
267
212
|
}),
|
|
268
|
-
|
|
269
|
-
|
|
213
|
+
createGoogleTagManagerIntegration({
|
|
214
|
+
gtmId: 'GTM-XXXXXXX',
|
|
270
215
|
}),
|
|
271
216
|
]
|
|
272
217
|
|
|
273
218
|
function App() {
|
|
274
219
|
return (
|
|
275
|
-
<ConsentProvider
|
|
276
|
-
{
|
|
220
|
+
<ConsentProvider
|
|
221
|
+
categories={{
|
|
222
|
+
enabledCategories: ['analytics', 'marketing', 'functional'],
|
|
223
|
+
}}
|
|
224
|
+
texts={{
|
|
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)
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
{/* Scripts carregados automaticamente após consentimento */}
|
|
277
241
|
<ConsentScriptLoader integrations={integrations} />
|
|
278
242
|
|
|
279
|
-
|
|
243
|
+
{/* Sua aplicação */}
|
|
244
|
+
<HomePage />
|
|
280
245
|
</ConsentProvider>
|
|
281
246
|
)
|
|
282
247
|
}
|
|
283
248
|
```
|
|
284
249
|
|
|
285
|
-
###
|
|
250
|
+
### 🎨 **UI Customizada**
|
|
286
251
|
|
|
287
252
|
```tsx
|
|
288
|
-
|
|
289
|
-
texts={{
|
|
290
|
-
bannerMessage: 'Utilizamos cookies para melhorar sua experiência.',
|
|
291
|
-
// Textos ANPD opcionais
|
|
292
|
-
controllerInfo: 'Controlado por Empresa LTDA (CNPJ: 00.000.000/0001-00)',
|
|
293
|
-
dataTypes: 'Coletamos dados de navegação, preferências e interações.',
|
|
294
|
-
thirdPartySharing: 'Compartilhamos com: Google Analytics, Facebook Pixel',
|
|
295
|
-
userRights: 'Você tem direito a acesso, correção e exclusão dos dados.',
|
|
296
|
-
contactInfo: 'Contato DPO: dpo@empresa.com.br | (11) 9999-9999',
|
|
297
|
-
retentionPeriod: 'Dados armazenados por até 12 meses.',
|
|
298
|
-
lawfulBasis: 'Base legal: consentimento do titular dos dados.',
|
|
299
|
-
transferCountries: 'Dados podem ser transferidos para: EUA, Irlanda.',
|
|
300
|
-
}}
|
|
301
|
-
>
|
|
302
|
-
{/* Os textos são exibidos condicionalmente apenas se definidos */}
|
|
303
|
-
</ConsentProvider>
|
|
304
|
-
```
|
|
253
|
+
import { ConsentProvider, useConsent, useCategories } from 'react-lgpd-consent'
|
|
305
254
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
import {
|
|
310
|
-
ConsentProvider,
|
|
311
|
-
CookieBanner,
|
|
312
|
-
FloatingPreferencesButton,
|
|
313
|
-
} from 'react-lgpd-consent'
|
|
255
|
+
function CustomCookieBanner() {
|
|
256
|
+
const { acceptAll, acceptSelected, preferences } = useConsent()
|
|
257
|
+
const categories = useCategories()
|
|
314
258
|
|
|
315
|
-
function App() {
|
|
316
259
|
return (
|
|
317
|
-
<
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
<p>Conteúdo do site...</p>
|
|
260
|
+
<div className="custom-banner">
|
|
261
|
+
<h3>🍪 Personalize sua experiência</h3>
|
|
262
|
+
<p>Utilizamos cookies para melhorar sua navegação.</p>
|
|
321
263
|
|
|
322
|
-
|
|
323
|
-
<
|
|
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
|
+
))}
|
|
324
274
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
275
|
+
<button onClick={acceptAll}>Aceitar Todos</button>
|
|
276
|
+
<button onClick={() => acceptSelected(preferences)}>
|
|
277
|
+
Salvar Preferências
|
|
278
|
+
</button>
|
|
279
|
+
</div>
|
|
329
280
|
)
|
|
330
281
|
}
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
## �📖 Uso Básico
|
|
334
|
-
|
|
335
|
-
### 1. Setup do Provider
|
|
336
|
-
|
|
337
|
-
```tsx
|
|
338
|
-
import { ConsentProvider } from 'react-lgpd-consent'
|
|
339
282
|
|
|
340
283
|
function App() {
|
|
341
284
|
return (
|
|
342
|
-
<ConsentProvider
|
|
285
|
+
<ConsentProvider
|
|
286
|
+
categories={{ enabledCategories: ['analytics'] }}
|
|
287
|
+
CookieBannerComponent={CustomCookieBanner}
|
|
288
|
+
>
|
|
343
289
|
<YourApp />
|
|
344
290
|
</ConsentProvider>
|
|
345
291
|
)
|
|
346
292
|
}
|
|
347
293
|
```
|
|
348
294
|
|
|
349
|
-
|
|
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>
|
|
350
348
|
|
|
351
349
|
```tsx
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
<CookieBanner
|
|
359
|
-
policyLinkUrl="/politica-privacidade"
|
|
360
|
-
blocking={true} // Padrão: bloqueia até decisão
|
|
361
|
-
/>
|
|
362
|
-
{/* Modal de preferências incluído automaticamente! */}
|
|
363
|
-
</>
|
|
364
|
-
)
|
|
365
|
-
}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
### 3. Uso do Hook
|
|
350
|
+
interface ConsentProviderProps {
|
|
351
|
+
// ✨ Configuração de Categorias
|
|
352
|
+
categories: {
|
|
353
|
+
enabledCategories: CategoryId[]
|
|
354
|
+
customCategories?: CustomCategory[]
|
|
355
|
+
}
|
|
369
356
|
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
}
|
|
372
370
|
|
|
373
|
-
|
|
374
|
-
|
|
371
|
+
// ⚙️ Comportamento
|
|
372
|
+
blocking?: boolean // Banner bloqueante
|
|
373
|
+
disableDeveloperGuidance?: boolean // Desabilitar orientações
|
|
375
374
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
<button onClick={openPreferences}>Gerenciar Preferências</button>
|
|
381
|
-
</div>
|
|
382
|
-
)
|
|
375
|
+
// 📊 Callbacks de Auditoria
|
|
376
|
+
onConsentGiven?: (state: ConsentState) => void
|
|
377
|
+
onConsentRevoked?: (state: ConsentState) => void
|
|
378
|
+
onPreferencesChanged?: (state: ConsentState) => void
|
|
383
379
|
}
|
|
384
380
|
```
|
|
385
381
|
|
|
386
|
-
>
|
|
382
|
+
</details>
|
|
387
383
|
|
|
388
|
-
|
|
384
|
+
### 🪝 **Hooks Disponíveis**
|
|
389
385
|
|
|
390
|
-
|
|
386
|
+
<details>
|
|
387
|
+
<summary><strong>useConsent()</strong></summary>
|
|
391
388
|
|
|
392
389
|
```tsx
|
|
393
|
-
|
|
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
|
+
```
|
|
394
407
|
|
|
395
|
-
|
|
396
|
-
return (
|
|
397
|
-
<ConsentGate category="analytics">
|
|
398
|
-
<GoogleAnalytics />
|
|
399
|
-
</ConsentGate>
|
|
400
|
-
)
|
|
401
|
-
}
|
|
408
|
+
</details>
|
|
402
409
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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[]
|
|
416
423
|
}
|
|
417
|
-
|
|
424
|
+
```
|
|
418
425
|
|
|
419
|
-
|
|
426
|
+
</details>
|
|
420
427
|
|
|
421
|
-
|
|
428
|
+
<details>
|
|
429
|
+
<summary><strong>useCategoryStatus()</strong></summary>
|
|
422
430
|
|
|
423
431
|
```tsx
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
//
|
|
428
|
-
<CookieBanner blocking={false} />
|
|
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
|
|
429
436
|
```
|
|
430
437
|
|
|
431
|
-
|
|
438
|
+
</details>
|
|
432
439
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
const meuTema = createTheme({
|
|
438
|
-
...defaultConsentTheme,
|
|
439
|
-
palette: {
|
|
440
|
-
...defaultConsentTheme.palette,
|
|
441
|
-
primary: {
|
|
442
|
-
main: '#1976d2', // Sua cor principal
|
|
443
|
-
},
|
|
444
|
-
},
|
|
445
|
-
})
|
|
446
|
-
|
|
447
|
-
<ConsentProvider theme={meuTema}>
|
|
448
|
-
<App />
|
|
449
|
-
</ConsentProvider>
|
|
450
|
-
```
|
|
440
|
+
### 🚀 **Integrações e Scripts**
|
|
441
|
+
|
|
442
|
+
<details>
|
|
443
|
+
<summary><strong>ConsentScriptLoader</strong></summary>
|
|
451
444
|
|
|
452
|
-
|
|
445
|
+
Carrega scripts automaticamente após o consentimento:
|
|
453
446
|
|
|
454
447
|
```tsx
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}}
|
|
462
|
-
>
|
|
463
|
-
```
|
|
448
|
+
import {
|
|
449
|
+
ConsentScriptLoader,
|
|
450
|
+
createGoogleAnalyticsIntegration,
|
|
451
|
+
createGoogleTagManagerIntegration,
|
|
452
|
+
createFacebookPixelIntegration,
|
|
453
|
+
} from 'react-lgpd-consent'
|
|
464
454
|
|
|
465
|
-
|
|
455
|
+
const integrations = [
|
|
456
|
+
createGoogleAnalyticsIntegration({
|
|
457
|
+
measurementId: 'G-XXXXXXXXXX',
|
|
458
|
+
anonymizeIP: true,
|
|
459
|
+
cookieFlags: 'SameSite=None; Secure',
|
|
460
|
+
}),
|
|
466
461
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
maxAgeDays: 180,
|
|
472
|
-
sameSite: 'Strict'
|
|
473
|
-
}}
|
|
474
|
-
>
|
|
475
|
-
```
|
|
462
|
+
createGoogleTagManagerIntegration({
|
|
463
|
+
gtmId: 'GTM-XXXXXXX',
|
|
464
|
+
dataLayerName: 'dataLayer',
|
|
465
|
+
}),
|
|
476
466
|
|
|
477
|
-
|
|
467
|
+
createFacebookPixelIntegration({
|
|
468
|
+
pixelId: '1234567890',
|
|
469
|
+
advancedMatching: true,
|
|
470
|
+
}),
|
|
471
|
+
]
|
|
478
472
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
473
|
+
function App() {
|
|
474
|
+
return (
|
|
475
|
+
<ConsentProvider
|
|
476
|
+
categories={{ enabledCategories: ['analytics', 'marketing'] }}
|
|
477
|
+
>
|
|
478
|
+
<ConsentScriptLoader integrations={integrations} />
|
|
479
|
+
<YourApp />
|
|
480
|
+
</ConsentProvider>
|
|
481
|
+
)
|
|
482
|
+
}
|
|
489
483
|
```
|
|
490
484
|
|
|
491
|
-
|
|
485
|
+
</details>
|
|
492
486
|
|
|
493
|
-
|
|
487
|
+
<details>
|
|
488
|
+
<summary><strong>ConsentGate - Renderização Condicional</strong></summary>
|
|
494
489
|
|
|
495
|
-
|
|
496
|
-
<CookieBanner blocking />
|
|
497
|
-
```
|
|
490
|
+
Renderize componentes apenas com consentimento:
|
|
498
491
|
|
|
499
|
-
|
|
492
|
+
```tsx
|
|
493
|
+
import { ConsentGate } from 'react-lgpd-consent'
|
|
500
494
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
495
|
+
// Componente simples
|
|
496
|
+
<ConsentGate category="marketing">
|
|
497
|
+
<FacebookPixel />
|
|
498
|
+
</ConsentGate>
|
|
504
499
|
|
|
505
|
-
|
|
500
|
+
// Múltiplas categorias (AND)
|
|
501
|
+
<ConsentGate categories={['analytics', 'marketing']}>
|
|
502
|
+
<AdvancedTracking />
|
|
503
|
+
</ConsentGate>
|
|
506
504
|
|
|
507
|
-
|
|
505
|
+
// Fallback quando não consentido
|
|
506
|
+
<ConsentGate category="functional" fallback={<StaticMap />}>
|
|
507
|
+
<InteractiveMap />
|
|
508
|
+
</ConsentGate>
|
|
508
509
|
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
// Hook para lógica customizada
|
|
511
|
+
function MyComponent() {
|
|
512
|
+
const canShowAds = useCategoryStatus('marketing')
|
|
511
513
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
primary: { main: '#2196f3' },
|
|
515
|
-
secondary: { main: '#f50057' },
|
|
516
|
-
},
|
|
517
|
-
})
|
|
514
|
+
if (canShowAds === null) return <Loading />
|
|
515
|
+
if (!canShowAds) return <AdFreeExperience />
|
|
518
516
|
|
|
519
|
-
<
|
|
520
|
-
|
|
521
|
-
</ConsentProvider>
|
|
517
|
+
return <AdsEnabledExperience />
|
|
518
|
+
}
|
|
522
519
|
```
|
|
523
520
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
O tema padrão do react-lgpd-consent está disponível para customização:
|
|
521
|
+
</details>
|
|
527
522
|
|
|
528
|
-
|
|
529
|
-
import { defaultConsentTheme } from 'react-lgpd-consent'
|
|
530
|
-
|
|
531
|
-
const temaCustomizado = createTheme({
|
|
532
|
-
...defaultConsentTheme,
|
|
533
|
-
palette: {
|
|
534
|
-
...defaultConsentTheme.palette,
|
|
535
|
-
primary: { main: '#your-color' },
|
|
536
|
-
},
|
|
537
|
-
})
|
|
538
|
-
```
|
|
523
|
+
## 🛡️ Conformidade e LGPD
|
|
539
524
|
|
|
540
|
-
|
|
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>
|
|
541
529
|
|
|
542
|
-
###
|
|
530
|
+
### 📋 **Checklist de Conformidade LGPD**
|
|
543
531
|
|
|
544
|
-
|
|
532
|
+
<table>
|
|
533
|
+
<tr>
|
|
534
|
+
<td width="50%">
|
|
545
535
|
|
|
546
|
-
|
|
547
|
-
import { loadScript } from 'react-lgpd-consent'
|
|
536
|
+
#### ✅ **Princípios Implementados**
|
|
548
537
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
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
|
|
555
544
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
```
|
|
545
|
+
</td>
|
|
546
|
+
<td width="50%">
|
|
559
547
|
|
|
560
|
-
|
|
548
|
+
#### 📊 **Auditoria e Logs**
|
|
561
549
|
|
|
562
|
-
-
|
|
563
|
-
-
|
|
564
|
-
-
|
|
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
|
|
565
556
|
|
|
566
|
-
|
|
557
|
+
</td>
|
|
558
|
+
</tr>
|
|
559
|
+
</table>
|
|
567
560
|
|
|
568
|
-
###
|
|
561
|
+
### 🏛️ **Conformidade Regulatória**
|
|
569
562
|
|
|
570
|
-
|
|
563
|
+
<details>
|
|
564
|
+
<summary><strong>🇧🇷 LGPD (Lei Geral de Proteção de Dados)</strong></summary>
|
|
571
565
|
|
|
572
|
-
|
|
573
|
-
import { ConsentProvider, useConsent } from 'react-lgpd-consent'
|
|
574
|
-
import MeuModalCustomizado from './MeuModalCustomizado'
|
|
566
|
+
**Artigos implementados:**
|
|
575
567
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
preferencesModalProps={{ variant: 'custom' }}
|
|
581
|
-
>
|
|
582
|
-
<MeuApp />
|
|
583
|
-
</ConsentProvider>
|
|
584
|
-
)
|
|
585
|
-
}
|
|
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
|
|
586
572
|
|
|
587
|
-
|
|
588
|
-
function MeuModalCustomizado({ variant }) {
|
|
589
|
-
const { isModalOpen, closePreferences, setPreference } = useConsent()
|
|
573
|
+
**Funcionalidades:**
|
|
590
574
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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
|
+
/>
|
|
597
585
|
```
|
|
598
586
|
|
|
599
|
-
|
|
587
|
+
</details>
|
|
600
588
|
|
|
601
|
-
|
|
589
|
+
<details>
|
|
590
|
+
<summary><strong>🇪🇺 GDPR (General Data Protection Regulation)</strong></summary>
|
|
602
591
|
|
|
603
|
-
|
|
604
|
-
<ConsentProvider disableAutomaticModal>
|
|
605
|
-
<MeuApp />
|
|
606
|
-
{/* Renderize seus componentes customizados onde quiser */}
|
|
607
|
-
<MeuModalTotalmenteCustomizado />
|
|
608
|
-
</ConsentProvider>
|
|
609
|
-
```
|
|
592
|
+
**Próxima versão (v0.3.0)** incluirá suporte completo ao GDPR:
|
|
610
593
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
| Componente | Descrição | Props Principais |
|
|
616
|
-
| --------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
|
|
617
|
-
| `ConsentProvider` | Provider principal do contexto | `initialState`, `texts`, `theme`, `hideBranding`, `PreferencesModalComponent`, `disableDeveloperGuidance`, callbacks |
|
|
618
|
-
| `CookieBanner` | Banner de consentimento | `policyLinkUrl`, `blocking`, `hideBranding`, `debug`, pass-through MUI props |
|
|
619
|
-
| `PreferencesModal` | Modal de preferências (incluído automaticamente) | `DialogProps`, `hideBranding` - **Opcional** |
|
|
620
|
-
| `FloatingPreferencesButton` | Botão flutuante para abrir preferências | `position`, `hideWhenConsented`, `tooltip`, `icon`, `FabProps` |
|
|
621
|
-
| `ConsentGate` | Renderização condicional por categoria | `category`, `children` |
|
|
622
|
-
|
|
623
|
-
### Hook `useConsent()`
|
|
624
|
-
|
|
625
|
-
```typescript
|
|
626
|
-
interface ConsentContextValue {
|
|
627
|
-
consented: boolean // usuário já consentiu?
|
|
628
|
-
preferences: ConsentPreferences // preferências atuais
|
|
629
|
-
isModalOpen: boolean // estado do modal de preferências
|
|
630
|
-
acceptAll(): void // aceitar todas as categorias
|
|
631
|
-
rejectAll(): void // recusar opcionais
|
|
632
|
-
setPreference(cat: Category, value: boolean): void // definir categoria específica
|
|
633
|
-
openPreferences(): void // abrir modal de preferências
|
|
634
|
-
closePreferences(): void // fechar modal
|
|
635
|
-
resetConsent(): void // resetar tudo
|
|
636
|
-
}
|
|
637
|
-
```
|
|
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)
|
|
638
598
|
|
|
639
|
-
|
|
599
|
+
</details>
|
|
640
600
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
```
|
|
601
|
+
<details>
|
|
602
|
+
<summary><strong>🇺🇸 CCPA (California Consumer Privacy Act)</strong></summary>
|
|
603
|
+
|
|
604
|
+
**Recursos CCPA planejados:**
|
|
646
605
|
|
|
647
|
-
|
|
606
|
+
- "Do Not Sell" toggle
|
|
607
|
+
- California resident detection
|
|
608
|
+
- Opt-out mechanisms
|
|
609
|
+
- Consumer rights notices
|
|
648
610
|
|
|
649
|
-
|
|
650
|
-
- `defaultConsentTheme` - Tema padrão do Material-UI
|
|
651
|
-
- Tipos TypeScript completos exportados## 🌐 SSR / Next.js
|
|
611
|
+
</details>
|
|
652
612
|
|
|
653
|
-
|
|
613
|
+
### 🏢 **Para Empresas e Auditoria**
|
|
614
|
+
|
|
615
|
+
<details>
|
|
616
|
+
<summary><strong>📊 Sistema de Auditoria Empresarial</strong></summary>
|
|
654
617
|
|
|
655
618
|
```tsx
|
|
656
|
-
|
|
657
|
-
|
|
619
|
+
import { ConsentProvider, useConsentAudit } from 'react-lgpd-consent'
|
|
620
|
+
|
|
621
|
+
function AuditDashboard() {
|
|
622
|
+
const auditData = useConsentAudit()
|
|
623
|
+
|
|
658
624
|
return (
|
|
659
|
-
<
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
<
|
|
666
|
-
|
|
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>
|
|
667
635
|
)
|
|
668
636
|
}
|
|
669
|
-
```
|
|
670
|
-
|
|
671
|
-
## ♿ Acessibilidade
|
|
672
637
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
+
```
|
|
680
656
|
|
|
681
|
-
|
|
657
|
+
</details>
|
|
682
658
|
|
|
683
|
-
|
|
659
|
+
**💡 Recomendação**: Para implementação empresarial, considere nosso pacote premium `react-lgpd-consent-enterprise` com recursos avançados de auditoria e relatórios.
|
|
684
660
|
|
|
685
|
-
|
|
686
|
-
- [Next.js com SSR](./examples/nextjs)
|
|
687
|
-
- [Customização avançada](./examples/advanced)
|
|
688
|
-
- [Integração com analytics](./examples/analytics)
|
|
661
|
+
---
|
|
689
662
|
|
|
690
|
-
## 🤝
|
|
663
|
+
## 🤝 Contribuições
|
|
691
664
|
|
|
692
|
-
|
|
665
|
+
<div align="center">
|
|
666
|
+
<img src="https://contrib.rocks/image?repo=lucianoedipo/react-lgpd-consent" alt="Contributors">
|
|
667
|
+
</div>
|
|
693
668
|
|
|
694
|
-
|
|
695
|
-
2. Crie uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
|
|
696
|
-
3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
|
|
697
|
-
4. Push para a branch (`git push origin feature/AmazingFeature`)
|
|
698
|
-
5. Abra um Pull Request
|
|
669
|
+
Contribuições são **muito bem-vindas**! Este é um projeto open-source e da comunidade brasileira para a comunidade.
|
|
699
670
|
|
|
700
|
-
|
|
671
|
+
### 🚀 **Como Contribuir**
|
|
701
672
|
|
|
702
|
-
|
|
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
|
|
703
678
|
|
|
704
|
-
|
|
679
|
+
### 📋 **Roadmap**
|
|
705
680
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
- 💬 [Discussões](https://github.com/lucianoedipo/react-lgpd-consent/discussions)
|
|
681
|
+
<details>
|
|
682
|
+
<summary><strong>🗺️ Próximas Versões</strong></summary>
|
|
709
683
|
|
|
710
|
-
|
|
684
|
+
#### v0.3.X+ - Compliance Avançado (Em Desenvolvimento)
|
|
711
685
|
|
|
712
|
-
|
|
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
|
|
713
690
|
|
|
714
|
-
|
|
691
|
+
#### v0.4.0 - Multi-Regulamentação
|
|
715
692
|
|
|
716
|
-
-
|
|
717
|
-
-
|
|
718
|
-
-
|
|
719
|
-
-
|
|
693
|
+
- [ ] Suporte completo GDPR
|
|
694
|
+
- [ ] Implementação CCPA
|
|
695
|
+
- [ ] Sistema de plugins extensível
|
|
696
|
+
- [ ] API server-side para Next.js
|
|
720
697
|
|
|
721
|
-
|
|
698
|
+
#### v0.5.0 - Enterprise Features
|
|
722
699
|
|
|
723
|
-
|
|
700
|
+
- [ ] Dashboard de analytics
|
|
701
|
+
- [ ] A/B testing para banners
|
|
702
|
+
- [ ] Integração com CMPs existentes
|
|
703
|
+
- [ ] SDK para mobile (React Native)
|
|
724
704
|
|
|
725
|
-
|
|
726
|
-
- 📜 **Templates Setoriais**: Textos pré-configurados (governo, saúde, educação)
|
|
727
|
-
- 🎨 **Presets Visuais**: Identidade visual por setor (acessibilidade WCAG AAA)
|
|
728
|
-
- 📊 **Dashboard para DPOs**: Relatórios automáticos de compliance
|
|
729
|
-
- 🔌 **Mais Integrações**: Microsoft Clarity, Hotjar, Intercom, LinkedIn
|
|
705
|
+
</details>
|
|
730
706
|
|
|
731
|
-
###
|
|
707
|
+
### 💬 **Comunidade**
|
|
732
708
|
|
|
733
|
-
-
|
|
734
|
-
-
|
|
735
|
-
- 🎭 **Temas Avançados**: Design system tokens
|
|
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)
|
|
736
711
|
|
|
737
|
-
|
|
712
|
+
---
|
|
738
713
|
|
|
739
|
-
|
|
740
|
-
- 🔄 **Sync Multi-Domínio**: Consentimento compartilhado
|
|
741
|
-
- 🛡️ **Segurança Empresarial**: Criptografia, audit logs remotos
|
|
714
|
+
## 📄 Licença
|
|
742
715
|
|
|
743
|
-
>
|
|
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>
|
|
744
728
|
|
|
745
729
|
---
|
|
746
730
|
|
|
747
731
|
<div align="center">
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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>
|
|
751
738
|
</div>
|