react-lgpd-consent 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/INTEGRACOES.md CHANGED
@@ -6,11 +6,9 @@ A biblioteca oferece integrações nativas para as ferramentas mais comuns, elim
6
6
 
7
7
  O componente `ConsentScriptLoader` gerencia o carregamento desses scripts automaticamente, disparando-os apenas quando o usuário concede consentimento para a categoria correspondente.
8
8
 
9
- ## 🎯 Integrações Nativas Disponíveis
10
-
11
- A biblioteca oferece integrações nativas para as ferramentas mais comuns, eliminando a necessidade de código manual para o carregamento condicional de scripts de terceiros.
9
+ > 💡 **Procurando exemplos práticos?** Veja [RECIPES.md](../../RECIPES.md) para receitas passo a passo de Google Consent Mode v2, Next.js App Router e CSP/nonce.
12
10
 
13
- O componente `ConsentScriptLoader` gerencia o carregamento desses scripts automaticamente, disparando-os apenas quando o usuário concede consentimento para a categoria correspondente.
11
+ ## 🎯 Integrações Nativas Disponíveis
14
12
 
15
13
  ### 1. Google Analytics 4 (GA4)
16
14
 
@@ -391,3 +389,89 @@ interface ConsentUpdatedEvent {
391
389
  | Live Chat | `functional` | Funcionalidade de suporte |
392
390
  | YouTube/Vimeo | `social` | Conteúdo de redes sociais |
393
391
 
392
+
393
+ ---
394
+
395
+ ## 🆕 Recursos Avançados v0.7.0
396
+
397
+ ### Monitoramento com Callbacks de Lifecycle
398
+
399
+ Integre sistemas de auditoria monitorando eventos de consentimento:
400
+
401
+ ```tsx
402
+ import { ConsentProvider, ConsentScriptLoader } from 'react-lgpd-consent'
403
+ import { googleAnalytics4Integration } from './integrations'
404
+
405
+ <ConsentProvider
406
+ categories={{ enabledCategories: ['analytics', 'marketing'] }}
407
+ onConsentInit={(state) => {
408
+ // Disparado na inicialização (útil para analytics)
409
+ console.log('Consentimento inicial:', state)
410
+ }}
411
+ onConsentChange={(current, previous) => {
412
+ // Disparado em toda mudança de preferências
413
+ console.log('Mudança:', { current, previous })
414
+
415
+ // Exemplo: disparar evento no dataLayer
416
+ window.dataLayer?.push({
417
+ event: 'consent_preferences_updated',
418
+ consent_analytics: current.preferences.analytics,
419
+ consent_marketing: current.preferences.marketing
420
+ })
421
+ }}
422
+ onAuditLog={(entry) => {
423
+ // Enviar para backend de compliance
424
+ fetch('/api/consent-audit', {
425
+ method: 'POST',
426
+ body: JSON.stringify(entry)
427
+ })
428
+ }}
429
+ >
430
+ <ConsentScriptLoader integrations={[googleAnalytics4Integration]} />
431
+ <YourApp />
432
+ </ConsentProvider>
433
+ ```
434
+
435
+ ### Presets de Categorias ANPD
436
+
437
+ Use configurações pré-validadas pela ANPD:
438
+
439
+ ```tsx
440
+ import { ConsentProvider, createAnpdCategories } from 'react-lgpd-consent'
441
+
442
+ // Preset BÁSICO (necessary + analytics)
443
+ const basicConfig = createAnpdCategories({ include: ['analytics'] })
444
+
445
+ // Preset COMPLETO (todas as 6 categorias)
446
+ const fullConfig = createAnpdCategories({
447
+ include: ['analytics', 'marketing', 'functional', 'social', 'personalization']
448
+ })
449
+
450
+ // Com customizações
451
+ const customConfig = createAnpdCategories({
452
+ include: ['analytics', 'marketing'],
453
+ names: { analytics: 'Análises' },
454
+ descriptions: { marketing: 'Anúncios personalizados' }
455
+ })
456
+
457
+ <ConsentProvider categories={fullConfig}>
458
+ <ConsentScriptLoader integrations={myIntegrations} />
459
+ </ConsentProvider>
460
+ ```
461
+
462
+ **Vantagens dos presets:**
463
+ - ✅ Conformidade com diretrizes ANPD
464
+ - ✅ Nomes e descrições em pt-BR revisadas
465
+ - ✅ Tipagem forte para evitar erros
466
+ - ✅ Reduz código boilerplate em 60%
467
+
468
+ ---
469
+
470
+ ## 📚 Recursos Adicionais
471
+
472
+ - [API.md](./API.md) – Documentação completa da API pública
473
+ - [RECIPES.md](../../RECIPES.md) – Receitas práticas com Next.js, CSP, Google Consent Mode v2
474
+ - [TROUBLESHOOTING.md](../../TROUBLESHOOTING.md) – Solução de problemas comuns
475
+ - [CONFORMIDADE.md](../../CONFORMIDADE.md) – Conformidade LGPD e ANPD
476
+
477
+ **Problemas de integração?** Consulte [TROUBLESHOOTING.md - Seção de Integrations](../../TROUBLESHOOTING.md#integrações-de-terceiros).
package/QUICKSTART.en.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  This quickstart gives everything you need to integrate `react-lgpd-consent` into a React project fast.
4
4
 
5
+ ## 🆕 What's New in v0.7.0
6
+
7
+ - ✅ **Lifecycle Callbacks** - `onConsentInit`, `onConsentChange`, `onAuditLog` for monitoring
8
+ - ✅ **ANPD Presets** - `createAnpdCategories()` for quick LGPD-compliant setup
9
+ - ✅ **Audit Logging** - `createConsentAuditEntry()` for compliance tracking
10
+ - ✅ **Better DX** - Clear error messages when hooks are used incorrectly
11
+
12
+ 📖 **Documentation:** [TROUBLESHOOTING.md](../../TROUBLESHOOTING.md) | [API.md](./API.md)
13
+
14
+ ---
15
+
5
16
  ## 📦 Installation
6
17
 
7
18
  ```bash
package/README.en.md CHANGED
@@ -84,6 +84,46 @@ function Analytics() {
84
84
 
85
85
  ---
86
86
 
87
+ ## 🆕 What's New in v0.7.0
88
+
89
+ ### Lifecycle Callbacks (#68)
90
+
91
+ ```tsx
92
+ <ConsentProvider
93
+ onConsentInit={(state) => console.log('Initialized:', state)}
94
+ onConsentChange={(current, prev) => console.log('Changed:', current)}
95
+ onAuditLog={(entry) => fetch('/api/audit', {
96
+ method: 'POST',
97
+ body: JSON.stringify(entry)
98
+ })}
99
+ >
100
+ ```
101
+
102
+ ### ANPD Category Presets (#70)
103
+
104
+ ```tsx
105
+ import { createAnpdCategories } from 'react-lgpd-consent'
106
+
107
+ const categories = createAnpdCategories({
108
+ include: ['analytics', 'marketing']
109
+ })
110
+ ```
111
+
112
+ ### Consent Audit (#60)
113
+
114
+ ```tsx
115
+ import { createConsentAuditEntry } from 'react-lgpd-consent'
116
+
117
+ const audit = createConsentAuditEntry(state, {
118
+ action: 'update',
119
+ consentVersion: '1'
120
+ })
121
+ ```
122
+
123
+ 📖 **Full documentation:** [API.md](./API.md) | [TROUBLESHOOTING.md](../../TROUBLESHOOTING.md)
124
+
125
+ ---
126
+
87
127
  ## Packages (monorepo)
88
128
 
89
129
  | Package | Description |
@@ -96,11 +136,13 @@ function Analytics() {
96
136
 
97
137
  ## Documentation & Examples
98
138
 
99
- - Quickstart: `QUICKSTART.en.md` (recommended)
100
- - API Reference: `API.md`
101
- - Integrations: `INTEGRACOES.md`
102
- - Storybook: https://lucianoedipo.github.io/react-lgpd-consent/storybook/
103
- - TypeDoc: https://lucianoedipo.github.io/react-lgpd-consent/docs/
139
+ - **[🚀 Quickstart](../../QUICKSTART.en.md)** - Step-by-step tutorial
140
+ - **[📖 Recipes](../../RECIPES.md)** - Practical guide with common use cases (Next.js, CSP, Consent Mode v2)
141
+ - **[⚙️ Workflows](../../WORKFLOWS.md)** - CI/CD workflows documentation
142
+ - **[API Reference](./API.md)** - Complete API reference
143
+ - **[Integrations](./INTEGRACOES.md)** - GA4, GTM, Facebook Pixel
144
+ - **[Storybook](https://lucianoedipo.github.io/react-lgpd-consent/storybook/)** - Interactive components
145
+ - **[TypeDoc](https://lucianoedipo.github.io/react-lgpd-consent/docs/)** - Generated API docs
104
146
 
105
147
  ---
106
148
 
package/README.md CHANGED
@@ -84,6 +84,46 @@ function Analytics() {
84
84
 
85
85
  ---
86
86
 
87
+ ## 🆕 Novidades v0.7.0
88
+
89
+ ### Callbacks de Lifecycle (#68)
90
+
91
+ ```tsx
92
+ <ConsentProvider
93
+ onConsentInit={(state) => console.log('Init:', state)}
94
+ onConsentChange={(current, prev) => console.log('Changed:', current)}
95
+ onAuditLog={(entry) => fetch('/api/audit', {
96
+ method: 'POST',
97
+ body: JSON.stringify(entry)
98
+ })}
99
+ >
100
+ ```
101
+
102
+ ### Presets ANPD (#70)
103
+
104
+ ```tsx
105
+ import { createAnpdCategories } from 'react-lgpd-consent'
106
+
107
+ const categories = createAnpdCategories({
108
+ include: ['analytics', 'marketing']
109
+ })
110
+ ```
111
+
112
+ ### Auditoria (#60)
113
+
114
+ ```tsx
115
+ import { createConsentAuditEntry } from 'react-lgpd-consent'
116
+
117
+ const audit = createConsentAuditEntry(state, {
118
+ action: 'update',
119
+ consentVersion: '1'
120
+ })
121
+ ```
122
+
123
+ 📖 **Documentação completa:** [API.md](./API.md) | [TROUBLESHOOTING.md](../../TROUBLESHOOTING.md)
124
+
125
+ ---
126
+
87
127
  ## Pacotes (monorepo v0.5.x)
88
128
 
89
129
  | Pacote | Descrição |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-lgpd-consent",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Biblioteca de consentimento LGPD, integrações nativas e sistema extensível para React.",
5
5
  "keywords": [
6
6
  "lgpd",
@@ -94,14 +94,14 @@
94
94
  }
95
95
  },
96
96
  "dependencies": {
97
- "@react-lgpd-consent/core": "^0.6.1",
98
- "@react-lgpd-consent/mui": "^0.6.1"
97
+ "@react-lgpd-consent/core": "^0.7.0",
98
+ "@react-lgpd-consent/mui": "^0.7.0"
99
99
  },
100
100
  "size-limit": [
101
101
  {
102
102
  "name": "ESM Bundle",
103
103
  "path": "dist/index.js",
104
- "limit": "70 KB"
104
+ "limit": "80 KB"
105
105
  },
106
106
  {
107
107
  "name": "CJS Bundle",
@@ -133,8 +133,6 @@
133
133
  "test:coverage": "jest --config ../../jest.config.mjs --coverage",
134
134
  "coverage-check": "node ../../scripts/coverage-check.cjs",
135
135
  "size-check": "size-limit",
136
- "mutation": "npx stryker run",
137
- "mutation:tests": "npx stryker run ../../stryker.tests.conf.json",
138
136
  "docs:generate": "node ../../scripts/run-typedoc.mjs",
139
137
  "storybook": "storybook dev -p 6006 --config-dir ../../.storybook",
140
138
  "build-storybook": "storybook build --config-dir ../../.storybook --output-dir ../../storybook-static"