react-lgpd-consent 0.3.7 → 0.4.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/CHANGELOG.md +13 -0
- package/QUICKSTART.en.md +43 -0
- package/QUICKSTART.md +43 -0
- package/README.en.md +1 -0
- package/README.md +1 -0
- package/dist/{PreferencesModal-3KKTKVII.js → PreferencesModal-D2SEVH3N.js} +1 -1
- package/dist/{chunk-TKN3PNIW.js → chunk-B5FNONG3.js} +31 -1
- package/dist/index.cjs +30 -0
- package/dist/index.d.cts +43 -8
- package/dist/index.d.ts +43 -8
- package/dist/index.js +1 -1
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ Todas as mudanças notáveis neste projeto serão documentadas neste arquivo.
|
|
|
4
4
|
|
|
5
5
|
O formato é baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.0.0/), e este projeto segue [Semantic Versioning](https://semver.org/lang/pt-BR/).
|
|
6
6
|
|
|
7
|
+
## [0.4.0] - 2025-09-09 — Custom categories
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Support for `customCategories` in `ConsentProvider.categories`.
|
|
11
|
+
- Included in preferences initialization and validation.
|
|
12
|
+
- Shown in the Preferences modal (with name/description).
|
|
13
|
+
- Exposed via developer guidance/context for custom UIs.
|
|
14
|
+
- Quickstart PT/EN sections with `customCategories` examples.
|
|
15
|
+
- Storybook story: WithCustomCategories.
|
|
16
|
+
|
|
17
|
+
### Notes
|
|
18
|
+
- Non-breaking change; existing configurations continue to work.
|
|
19
|
+
|
|
7
20
|
## [0.3.7] - 2025-09-08 - Testes de UI e carregamento de scripts
|
|
8
21
|
|
|
9
22
|
### 🧪 Novos testes e cobertura
|
package/QUICKSTART.en.md
CHANGED
|
@@ -39,6 +39,49 @@ function App() {
|
|
|
39
39
|
export default App
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
## 🧩 Custom categories (customCategories)
|
|
43
|
+
Available since v0.4.0.
|
|
44
|
+
|
|
45
|
+
Add project-specific categories (e.g., support chat, video players, A/B testing):
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<ConsentProvider
|
|
49
|
+
categories={{
|
|
50
|
+
enabledCategories: ['analytics'],
|
|
51
|
+
customCategories: [
|
|
52
|
+
{ id: 'chat', name: 'Support Chat', description: 'Chat widget' },
|
|
53
|
+
{ id: 'video', name: 'Video', description: 'Embedded players' },
|
|
54
|
+
{ id: 'abTesting', name: 'A/B Testing', description: 'Interface experiments' },
|
|
55
|
+
],
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<App />
|
|
59
|
+
</ConsentProvider>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Using custom categories in your code
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { useConsent } from 'react-lgpd-consent'
|
|
66
|
+
|
|
67
|
+
function MyComponent() {
|
|
68
|
+
const { consent } = useConsent()
|
|
69
|
+
|
|
70
|
+
// Check if user consented to specific categories
|
|
71
|
+
const canShowChat = consent?.preferences?.chat === true
|
|
72
|
+
const canLoadVideos = consent?.preferences?.video === true
|
|
73
|
+
const canRunABTests = consent?.preferences?.abTesting === true
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div>
|
|
77
|
+
{canShowChat && <ChatWidget />}
|
|
78
|
+
{canLoadVideos && <VideoPlayer src="..." />}
|
|
79
|
+
{canRunABTests && <ABTestVariant />}
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
42
85
|
## 🧭 Storybook — quick note
|
|
43
86
|
|
|
44
87
|
This repository ships an interactive Storybook playground used for manual testing and visual exploration of components. Quick commands:
|
package/QUICKSTART.md
CHANGED
|
@@ -62,6 +62,49 @@ export default App
|
|
|
62
62
|
|
|
63
63
|
````
|
|
64
64
|
|
|
65
|
+
## 🧩 Categorias customizadas (customCategories)
|
|
66
|
+
Disponível a partir da v0.4.0.
|
|
67
|
+
|
|
68
|
+
Adicione categorias específicas do seu projeto (ex.: chat de suporte, players de vídeo, AB testing):
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<ConsentProvider
|
|
72
|
+
categories={{
|
|
73
|
+
enabledCategories: ['analytics'],
|
|
74
|
+
customCategories: [
|
|
75
|
+
{ id: 'chat', name: 'Chat de Suporte', description: 'Widget de chat' },
|
|
76
|
+
{ id: 'video', name: 'Vídeo', description: 'Players incorporados' },
|
|
77
|
+
{ id: 'abTesting', name: 'A/B Testing', description: 'Experimentos de interface' },
|
|
78
|
+
],
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<App />
|
|
82
|
+
</ConsentProvider>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Usando categorias customizadas no seu código
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { useConsent } from 'react-lgpd-consent'
|
|
89
|
+
|
|
90
|
+
function MyComponent() {
|
|
91
|
+
const { consent } = useConsent()
|
|
92
|
+
|
|
93
|
+
// Verificar se o usuário consentiu com categorias específicas
|
|
94
|
+
const canShowChat = consent?.preferences?.chat === true
|
|
95
|
+
const canLoadVideos = consent?.preferences?.video === true
|
|
96
|
+
const canRunABTests = consent?.preferences?.abTesting === true
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div>
|
|
100
|
+
{canShowChat && <ChatWidget />}
|
|
101
|
+
{canLoadVideos && <VideoPlayer src="..." />}
|
|
102
|
+
{canRunABTests && <ABTestVariant />}
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
65
108
|
## 📋 Tabela Completa de Props do ConsentProvider
|
|
66
109
|
|
|
67
110
|
| Prop | Tipo | Obrigatória | Padrão | Descrição |
|
package/README.en.md
CHANGED
|
@@ -63,6 +63,7 @@ export default function App() {
|
|
|
63
63
|
- For full guides, TypeScript examples, props table and integrations see:
|
|
64
64
|
-
|
|
65
65
|
- **[QUICKSTART.en.md](./QUICKSTART.en.md)** (recommended)
|
|
66
|
+
- New in v0.4.0: `customCategories` support — see the “Custom categories (customCategories)” section in the Quickstart.
|
|
66
67
|
- **[Docs / API](./API.md)**
|
|
67
68
|
- **[LGPD Compliance](./CONFORMIDADE.md)**
|
|
68
69
|
- **[Integrations](./INTEGRACOES.md)**
|
package/README.md
CHANGED
|
@@ -87,6 +87,7 @@ Para mais detalhes sobre customização, hooks e funcionalidades, consulte os se
|
|
|
87
87
|
### 📋 Documentação Principal
|
|
88
88
|
|
|
89
89
|
- **[📚 Guia de Início Rápido (`QUICKSTART.md`)](./QUICKSTART.md)**: Tutorial passo a passo com exemplos práticos, tabela completa de props, debugging e integrações.
|
|
90
|
+
- Novo na v0.4.0: suporte a `customCategories` — veja a seção “Categorias customizadas (customCategories)” no Quickstart.
|
|
90
91
|
- **[Guia da API (`API.md`)](./API.md)**: Referência completa de todos os componentes, hooks e tipos.
|
|
91
92
|
- **[Guia de Conformidade (`CONFORMIDADE.md`)](./CONFORMIDADE.md)**: Detalhes sobre as funcionalidades de conformidade com a LGPD.
|
|
92
93
|
- **[Guia de Integrações (`INTEGRACOES.md`)](./INTEGRACOES.md)**: Como usar as integrações nativas e criar as suas.
|
|
@@ -73,6 +73,17 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
|
+
const custom = finalConfig.customCategories || [];
|
|
77
|
+
custom.forEach((cat) => {
|
|
78
|
+
if (!cat?.id || cat.id === "necessary") return;
|
|
79
|
+
guidance.activeCategoriesInfo.push({
|
|
80
|
+
id: cat.id,
|
|
81
|
+
name: cat.name,
|
|
82
|
+
description: cat.description,
|
|
83
|
+
essential: !!cat.essential,
|
|
84
|
+
uiRequired: !cat.essential
|
|
85
|
+
});
|
|
86
|
+
});
|
|
76
87
|
const totalToggleable = guidance.activeCategoriesInfo.filter((c) => c.uiRequired).length;
|
|
77
88
|
if (totalToggleable === 0) {
|
|
78
89
|
guidance.suggestions.push(
|
|
@@ -467,6 +478,12 @@ function createProjectPreferences(config, defaultValue = false) {
|
|
|
467
478
|
preferences[category] = defaultValue;
|
|
468
479
|
}
|
|
469
480
|
});
|
|
481
|
+
const custom = config?.customCategories || [];
|
|
482
|
+
custom.forEach((cat) => {
|
|
483
|
+
if (cat.id && cat.id !== "necessary") {
|
|
484
|
+
preferences[cat.id] = defaultValue;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
470
487
|
return preferences;
|
|
471
488
|
}
|
|
472
489
|
function validateProjectPreferences(preferences, config) {
|
|
@@ -480,6 +497,13 @@ function validateProjectPreferences(preferences, config) {
|
|
|
480
497
|
validPreferences[category] = preferences[category];
|
|
481
498
|
}
|
|
482
499
|
});
|
|
500
|
+
const custom = config?.customCategories || [];
|
|
501
|
+
custom.forEach((cat) => {
|
|
502
|
+
const id = cat.id;
|
|
503
|
+
if (id && id !== "necessary" && preferences[id] !== void 0) {
|
|
504
|
+
validPreferences[id] = preferences[id];
|
|
505
|
+
}
|
|
506
|
+
});
|
|
483
507
|
return validPreferences;
|
|
484
508
|
}
|
|
485
509
|
function getAllProjectCategories(config) {
|
|
@@ -497,6 +521,12 @@ function getAllProjectCategories(config) {
|
|
|
497
521
|
allCategories.push(getDefaultCategoryDefinition(category));
|
|
498
522
|
}
|
|
499
523
|
});
|
|
524
|
+
const custom = config?.customCategories || [];
|
|
525
|
+
custom.forEach((cat) => {
|
|
526
|
+
if (cat.id && cat.id !== "necessary") {
|
|
527
|
+
allCategories.push({ ...cat, essential: !!cat.essential });
|
|
528
|
+
}
|
|
529
|
+
});
|
|
500
530
|
return allCategories;
|
|
501
531
|
}
|
|
502
532
|
function getDefaultCategoryDefinition(category) {
|
|
@@ -855,7 +885,7 @@ function FloatingPreferencesButton({
|
|
|
855
885
|
// src/context/ConsentContext.tsx
|
|
856
886
|
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
857
887
|
var PreferencesModal = React4.lazy(
|
|
858
|
-
() => import("./PreferencesModal-
|
|
888
|
+
() => import("./PreferencesModal-D2SEVH3N.js").then((m) => ({
|
|
859
889
|
default: m.PreferencesModal
|
|
860
890
|
}))
|
|
861
891
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,17 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
+
const custom = finalConfig.customCategories || [];
|
|
90
|
+
custom.forEach((cat) => {
|
|
91
|
+
if (!cat?.id || cat.id === "necessary") return;
|
|
92
|
+
guidance.activeCategoriesInfo.push({
|
|
93
|
+
id: cat.id,
|
|
94
|
+
name: cat.name,
|
|
95
|
+
description: cat.description,
|
|
96
|
+
essential: !!cat.essential,
|
|
97
|
+
uiRequired: !cat.essential
|
|
98
|
+
});
|
|
99
|
+
});
|
|
89
100
|
const totalToggleable = guidance.activeCategoriesInfo.filter((c) => c.uiRequired).length;
|
|
90
101
|
if (totalToggleable === 0) {
|
|
91
102
|
guidance.suggestions.push(
|
|
@@ -505,6 +516,12 @@ function createProjectPreferences(config, defaultValue = false) {
|
|
|
505
516
|
preferences[category] = defaultValue;
|
|
506
517
|
}
|
|
507
518
|
});
|
|
519
|
+
const custom = config?.customCategories || [];
|
|
520
|
+
custom.forEach((cat) => {
|
|
521
|
+
if (cat.id && cat.id !== "necessary") {
|
|
522
|
+
preferences[cat.id] = defaultValue;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
508
525
|
return preferences;
|
|
509
526
|
}
|
|
510
527
|
function validateProjectPreferences(preferences, config) {
|
|
@@ -518,6 +535,13 @@ function validateProjectPreferences(preferences, config) {
|
|
|
518
535
|
validPreferences[category] = preferences[category];
|
|
519
536
|
}
|
|
520
537
|
});
|
|
538
|
+
const custom = config?.customCategories || [];
|
|
539
|
+
custom.forEach((cat) => {
|
|
540
|
+
const id = cat.id;
|
|
541
|
+
if (id && id !== "necessary" && preferences[id] !== void 0) {
|
|
542
|
+
validPreferences[id] = preferences[id];
|
|
543
|
+
}
|
|
544
|
+
});
|
|
521
545
|
return validPreferences;
|
|
522
546
|
}
|
|
523
547
|
function getAllProjectCategories(config) {
|
|
@@ -535,6 +559,12 @@ function getAllProjectCategories(config) {
|
|
|
535
559
|
allCategories.push(getDefaultCategoryDefinition(category));
|
|
536
560
|
}
|
|
537
561
|
});
|
|
562
|
+
const custom = config?.customCategories || [];
|
|
563
|
+
custom.forEach((cat) => {
|
|
564
|
+
if (cat.id && cat.id !== "necessary") {
|
|
565
|
+
allCategories.push({ ...cat, essential: !!cat.essential });
|
|
566
|
+
}
|
|
567
|
+
});
|
|
538
568
|
return allCategories;
|
|
539
569
|
}
|
|
540
570
|
function getDefaultCategoryDefinition(category) {
|
package/dist/index.d.cts
CHANGED
|
@@ -81,6 +81,7 @@ type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social
|
|
|
81
81
|
*
|
|
82
82
|
* @example
|
|
83
83
|
* ```typescript
|
|
84
|
+
* // Categoria padrão da biblioteca
|
|
84
85
|
* const analyticsCategory: CategoryDefinition = {
|
|
85
86
|
* id: 'analytics',
|
|
86
87
|
* name: 'Cookies Analíticos',
|
|
@@ -88,6 +89,14 @@ type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social
|
|
|
88
89
|
* essential: false,
|
|
89
90
|
* cookies: ['_ga', '_ga_*', '_gid']
|
|
90
91
|
* };
|
|
92
|
+
*
|
|
93
|
+
* // Categoria customizada específica do projeto
|
|
94
|
+
* const chatCategory: CategoryDefinition = {
|
|
95
|
+
* id: 'chat',
|
|
96
|
+
* name: 'Chat de Suporte',
|
|
97
|
+
* description: 'Widget de chat para suporte ao cliente',
|
|
98
|
+
* essential: false
|
|
99
|
+
* };
|
|
91
100
|
* ```
|
|
92
101
|
*
|
|
93
102
|
* @public
|
|
@@ -144,11 +153,18 @@ interface CategoryDefinition {
|
|
|
144
153
|
* // Configuração com categorias customizadas
|
|
145
154
|
* const config: ProjectCategoriesConfig = {
|
|
146
155
|
* enabledCategories: ['analytics'],
|
|
147
|
-
* customCategories: [
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
156
|
+
* customCategories: [
|
|
157
|
+
* {
|
|
158
|
+
* id: 'chat',
|
|
159
|
+
* name: 'Chat de Suporte',
|
|
160
|
+
* description: 'Widget de chat para suporte ao cliente'
|
|
161
|
+
* },
|
|
162
|
+
* {
|
|
163
|
+
* id: 'abTesting',
|
|
164
|
+
* name: 'A/B Testing',
|
|
165
|
+
* description: 'Experimentos de interface e funcionalidades'
|
|
166
|
+
* }
|
|
167
|
+
* ]
|
|
152
168
|
* };
|
|
153
169
|
* ```
|
|
154
170
|
*
|
|
@@ -164,6 +180,7 @@ interface ProjectCategoriesConfig {
|
|
|
164
180
|
/**
|
|
165
181
|
* Categorias customizadas específicas do projeto.
|
|
166
182
|
* Permite extensão além das categorias padrão da biblioteca.
|
|
183
|
+
* @example [{ id: 'chat', name: 'Chat de Suporte', description: 'Widget de chat' }]
|
|
167
184
|
*/
|
|
168
185
|
customCategories?: CategoryDefinition[];
|
|
169
186
|
}
|
|
@@ -1526,6 +1543,8 @@ declare const DEFAULT_PROJECT_CATEGORIES: ProjectCategoriesConfig;
|
|
|
1526
1543
|
*
|
|
1527
1544
|
* @param {ProjectCategoriesConfig} [config] A configuração de categorias fornecida pelo desenvolvedor. Se não for fornecida, a configuração padrão será utilizada.
|
|
1528
1545
|
* @returns {DeveloperGuidance} Um objeto `DeveloperGuidance` com a análise da configuração.
|
|
1546
|
+
*
|
|
1547
|
+
* Since v0.4.0: inclui `customCategories` em `activeCategoriesInfo` (com `uiRequired=false` se `essential=true`).
|
|
1529
1548
|
*/
|
|
1530
1549
|
declare function analyzeDeveloperConfiguration(config?: ProjectCategoriesConfig): DeveloperGuidance;
|
|
1531
1550
|
|
|
@@ -2113,8 +2132,10 @@ declare function FloatingPreferencesButton({ position, offset, icon, tooltip, Fa
|
|
|
2113
2132
|
* @returns Um objeto `ConsentPreferences` com as categorias e seus valores iniciais.
|
|
2114
2133
|
* @remarks
|
|
2115
2134
|
* Esta função é crucial para inicializar o estado de consentimento. Ela garante que apenas as categorias
|
|
2116
|
-
* definidas no `ConsentProvider` sejam incluídas no objeto de preferências
|
|
2117
|
-
* de minimização de dados da LGPD.
|
|
2135
|
+
* definidas no `ConsentProvider` sejam incluídas no objeto de preferências (tanto categorias padrão
|
|
2136
|
+
* em `enabledCategories` quanto `customCategories`), alinhando-se ao princípio de minimização de dados da LGPD.
|
|
2137
|
+
*
|
|
2138
|
+
* Since v0.4.0: inclui categorias de `config.customCategories` na inicialização.
|
|
2118
2139
|
* @example
|
|
2119
2140
|
* ```ts
|
|
2120
2141
|
* // Gera preferências com 'analytics' e 'marketing' desabilitados por padrão
|
|
@@ -2123,6 +2144,15 @@ declare function FloatingPreferencesButton({ position, offset, icon, tooltip, Fa
|
|
|
2123
2144
|
* })
|
|
2124
2145
|
* // Result: { necessary: true, analytics: false, marketing: false }
|
|
2125
2146
|
*
|
|
2147
|
+
* // Inclui categorias customizadas
|
|
2148
|
+
* const initialWithCustom = createProjectPreferences({
|
|
2149
|
+
* enabledCategories: ['analytics'],
|
|
2150
|
+
* customCategories: [
|
|
2151
|
+
* { id: 'abTesting', name: 'AB Testing', description: 'Experimentos de interface' },
|
|
2152
|
+
* ],
|
|
2153
|
+
* })
|
|
2154
|
+
* // Result: { necessary: true, analytics: false, abTesting: false }
|
|
2155
|
+
*
|
|
2126
2156
|
* // Gera preferências com todas as categorias habilitadas
|
|
2127
2157
|
* const allAcceptedPrefs = createProjectPreferences(
|
|
2128
2158
|
* { enabledCategories: ['analytics', 'marketing'] },
|
|
@@ -2143,6 +2173,8 @@ declare function createProjectPreferences(config?: ProjectCategoriesConfig, defa
|
|
|
2143
2173
|
* Garante a integridade dos dados ao carregar o estado de um cookie. Se a configuração do projeto mudou
|
|
2144
2174
|
* (ex: uma categoria foi removida), esta função limpa as preferências obsoletas do estado,
|
|
2145
2175
|
* evitando inconsistências.
|
|
2176
|
+
*
|
|
2177
|
+
* Since v0.4.0: reconhece `config.customCategories` como válidas ao validar.
|
|
2146
2178
|
* @example
|
|
2147
2179
|
* ```ts
|
|
2148
2180
|
* const savedPrefs = { necessary: true, analytics: true, oldCategory: false }
|
|
@@ -2161,7 +2193,10 @@ declare function validateProjectPreferences(preferences: ConsentPreferences, con
|
|
|
2161
2193
|
* @returns Um array de objetos `CategoryDefinition`.
|
|
2162
2194
|
* @remarks
|
|
2163
2195
|
* Útil para construir UIs de preferência customizadas, pois fornece os nomes e descrições
|
|
2164
|
-
* de todas as categorias que devem ser exibidas ao usuário
|
|
2196
|
+
* de todas as categorias que devem ser exibidas ao usuário, incluindo quaisquer `customCategories`
|
|
2197
|
+
* definidas no `ConsentProvider`.
|
|
2198
|
+
*
|
|
2199
|
+
* Since v0.4.0: inclui categorias definidas em `config.customCategories`.
|
|
2165
2200
|
* @example
|
|
2166
2201
|
* ```ts
|
|
2167
2202
|
* const config = { enabledCategories: ['analytics'] }
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,7 @@ type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social
|
|
|
81
81
|
*
|
|
82
82
|
* @example
|
|
83
83
|
* ```typescript
|
|
84
|
+
* // Categoria padrão da biblioteca
|
|
84
85
|
* const analyticsCategory: CategoryDefinition = {
|
|
85
86
|
* id: 'analytics',
|
|
86
87
|
* name: 'Cookies Analíticos',
|
|
@@ -88,6 +89,14 @@ type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social
|
|
|
88
89
|
* essential: false,
|
|
89
90
|
* cookies: ['_ga', '_ga_*', '_gid']
|
|
90
91
|
* };
|
|
92
|
+
*
|
|
93
|
+
* // Categoria customizada específica do projeto
|
|
94
|
+
* const chatCategory: CategoryDefinition = {
|
|
95
|
+
* id: 'chat',
|
|
96
|
+
* name: 'Chat de Suporte',
|
|
97
|
+
* description: 'Widget de chat para suporte ao cliente',
|
|
98
|
+
* essential: false
|
|
99
|
+
* };
|
|
91
100
|
* ```
|
|
92
101
|
*
|
|
93
102
|
* @public
|
|
@@ -144,11 +153,18 @@ interface CategoryDefinition {
|
|
|
144
153
|
* // Configuração com categorias customizadas
|
|
145
154
|
* const config: ProjectCategoriesConfig = {
|
|
146
155
|
* enabledCategories: ['analytics'],
|
|
147
|
-
* customCategories: [
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
156
|
+
* customCategories: [
|
|
157
|
+
* {
|
|
158
|
+
* id: 'chat',
|
|
159
|
+
* name: 'Chat de Suporte',
|
|
160
|
+
* description: 'Widget de chat para suporte ao cliente'
|
|
161
|
+
* },
|
|
162
|
+
* {
|
|
163
|
+
* id: 'abTesting',
|
|
164
|
+
* name: 'A/B Testing',
|
|
165
|
+
* description: 'Experimentos de interface e funcionalidades'
|
|
166
|
+
* }
|
|
167
|
+
* ]
|
|
152
168
|
* };
|
|
153
169
|
* ```
|
|
154
170
|
*
|
|
@@ -164,6 +180,7 @@ interface ProjectCategoriesConfig {
|
|
|
164
180
|
/**
|
|
165
181
|
* Categorias customizadas específicas do projeto.
|
|
166
182
|
* Permite extensão além das categorias padrão da biblioteca.
|
|
183
|
+
* @example [{ id: 'chat', name: 'Chat de Suporte', description: 'Widget de chat' }]
|
|
167
184
|
*/
|
|
168
185
|
customCategories?: CategoryDefinition[];
|
|
169
186
|
}
|
|
@@ -1526,6 +1543,8 @@ declare const DEFAULT_PROJECT_CATEGORIES: ProjectCategoriesConfig;
|
|
|
1526
1543
|
*
|
|
1527
1544
|
* @param {ProjectCategoriesConfig} [config] A configuração de categorias fornecida pelo desenvolvedor. Se não for fornecida, a configuração padrão será utilizada.
|
|
1528
1545
|
* @returns {DeveloperGuidance} Um objeto `DeveloperGuidance` com a análise da configuração.
|
|
1546
|
+
*
|
|
1547
|
+
* Since v0.4.0: inclui `customCategories` em `activeCategoriesInfo` (com `uiRequired=false` se `essential=true`).
|
|
1529
1548
|
*/
|
|
1530
1549
|
declare function analyzeDeveloperConfiguration(config?: ProjectCategoriesConfig): DeveloperGuidance;
|
|
1531
1550
|
|
|
@@ -2113,8 +2132,10 @@ declare function FloatingPreferencesButton({ position, offset, icon, tooltip, Fa
|
|
|
2113
2132
|
* @returns Um objeto `ConsentPreferences` com as categorias e seus valores iniciais.
|
|
2114
2133
|
* @remarks
|
|
2115
2134
|
* Esta função é crucial para inicializar o estado de consentimento. Ela garante que apenas as categorias
|
|
2116
|
-
* definidas no `ConsentProvider` sejam incluídas no objeto de preferências
|
|
2117
|
-
* de minimização de dados da LGPD.
|
|
2135
|
+
* definidas no `ConsentProvider` sejam incluídas no objeto de preferências (tanto categorias padrão
|
|
2136
|
+
* em `enabledCategories` quanto `customCategories`), alinhando-se ao princípio de minimização de dados da LGPD.
|
|
2137
|
+
*
|
|
2138
|
+
* Since v0.4.0: inclui categorias de `config.customCategories` na inicialização.
|
|
2118
2139
|
* @example
|
|
2119
2140
|
* ```ts
|
|
2120
2141
|
* // Gera preferências com 'analytics' e 'marketing' desabilitados por padrão
|
|
@@ -2123,6 +2144,15 @@ declare function FloatingPreferencesButton({ position, offset, icon, tooltip, Fa
|
|
|
2123
2144
|
* })
|
|
2124
2145
|
* // Result: { necessary: true, analytics: false, marketing: false }
|
|
2125
2146
|
*
|
|
2147
|
+
* // Inclui categorias customizadas
|
|
2148
|
+
* const initialWithCustom = createProjectPreferences({
|
|
2149
|
+
* enabledCategories: ['analytics'],
|
|
2150
|
+
* customCategories: [
|
|
2151
|
+
* { id: 'abTesting', name: 'AB Testing', description: 'Experimentos de interface' },
|
|
2152
|
+
* ],
|
|
2153
|
+
* })
|
|
2154
|
+
* // Result: { necessary: true, analytics: false, abTesting: false }
|
|
2155
|
+
*
|
|
2126
2156
|
* // Gera preferências com todas as categorias habilitadas
|
|
2127
2157
|
* const allAcceptedPrefs = createProjectPreferences(
|
|
2128
2158
|
* { enabledCategories: ['analytics', 'marketing'] },
|
|
@@ -2143,6 +2173,8 @@ declare function createProjectPreferences(config?: ProjectCategoriesConfig, defa
|
|
|
2143
2173
|
* Garante a integridade dos dados ao carregar o estado de um cookie. Se a configuração do projeto mudou
|
|
2144
2174
|
* (ex: uma categoria foi removida), esta função limpa as preferências obsoletas do estado,
|
|
2145
2175
|
* evitando inconsistências.
|
|
2176
|
+
*
|
|
2177
|
+
* Since v0.4.0: reconhece `config.customCategories` como válidas ao validar.
|
|
2146
2178
|
* @example
|
|
2147
2179
|
* ```ts
|
|
2148
2180
|
* const savedPrefs = { necessary: true, analytics: true, oldCategory: false }
|
|
@@ -2161,7 +2193,10 @@ declare function validateProjectPreferences(preferences: ConsentPreferences, con
|
|
|
2161
2193
|
* @returns Um array de objetos `CategoryDefinition`.
|
|
2162
2194
|
* @remarks
|
|
2163
2195
|
* Útil para construir UIs de preferência customizadas, pois fornece os nomes e descrições
|
|
2164
|
-
* de todas as categorias que devem ser exibidas ao usuário
|
|
2196
|
+
* de todas as categorias que devem ser exibidas ao usuário, incluindo quaisquer `customCategories`
|
|
2197
|
+
* definidas no `ConsentProvider`.
|
|
2198
|
+
*
|
|
2199
|
+
* Since v0.4.0: inclui categorias definidas em `config.customCategories`.
|
|
2165
2200
|
* @example
|
|
2166
2201
|
* ```ts
|
|
2167
2202
|
* const config = { enabledCategories: ['analytics'] }
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lgpd-consent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Biblioteca de consentimento LGPD, integrações nativas e sistema extensível para React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lgpd",
|
|
@@ -102,42 +102,42 @@
|
|
|
102
102
|
"@eslint/compat": "1.3.2",
|
|
103
103
|
"@mui/icons-material": "7.3.2",
|
|
104
104
|
"@mui/material": "7.3.2",
|
|
105
|
-
"@storybook/addon-a11y": "9.1.
|
|
106
|
-
"@storybook/addon-docs": "9.1.
|
|
107
|
-
"@storybook/addon-vitest": "9.1.
|
|
108
|
-
"@storybook/react-vite": "9.1.
|
|
105
|
+
"@storybook/addon-a11y": "9.1.7",
|
|
106
|
+
"@storybook/addon-docs": "9.1.7",
|
|
107
|
+
"@storybook/addon-vitest": "9.1.7",
|
|
108
|
+
"@storybook/react-vite": "9.1.7",
|
|
109
109
|
"@stryker-mutator/core": "9.1.1",
|
|
110
110
|
"@stryker-mutator/jest-runner": "9.1.1",
|
|
111
111
|
"@testing-library/dom": "10.4.1",
|
|
112
112
|
"@testing-library/jest-dom": "6.8.0",
|
|
113
113
|
"@testing-library/react": "16.3.0",
|
|
114
114
|
"@testing-library/user-event": "14.6.1",
|
|
115
|
-
"@types/jest": "
|
|
115
|
+
"@types/jest": "30.0.0",
|
|
116
116
|
"@types/js-cookie": "3.0.6",
|
|
117
|
-
"@types/node": "24.
|
|
118
|
-
"@types/react": "19.1.
|
|
117
|
+
"@types/node": "24.5.2",
|
|
118
|
+
"@types/react": "19.1.13",
|
|
119
119
|
"@types/react-dom": "19.1.9",
|
|
120
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
121
|
-
"@typescript-eslint/parser": "8.
|
|
120
|
+
"@typescript-eslint/eslint-plugin": "8.44.0",
|
|
121
|
+
"@typescript-eslint/parser": "8.44.0",
|
|
122
122
|
"cross-env": "10.0.0",
|
|
123
|
-
"eslint": "
|
|
123
|
+
"eslint": "9.36.0",
|
|
124
124
|
"eslint-config-prettier": "10.1.8",
|
|
125
125
|
"eslint-plugin-jest": "29.0.1",
|
|
126
126
|
"eslint-plugin-react-hooks": "5.2.0",
|
|
127
|
-
"eslint-plugin-storybook": "9.1.
|
|
128
|
-
"globals": "^
|
|
129
|
-
"jest": "
|
|
130
|
-
"jest-environment-jsdom": "
|
|
127
|
+
"eslint-plugin-storybook": "9.1.7",
|
|
128
|
+
"globals": "^16.4.0",
|
|
129
|
+
"jest": "30.1.3",
|
|
130
|
+
"jest-environment-jsdom": "30.1.2",
|
|
131
131
|
"prettier": "3.6.2",
|
|
132
132
|
"react": "19.1.1",
|
|
133
133
|
"react-dom": "19.1.1",
|
|
134
134
|
"rimraf": "6.0.1",
|
|
135
|
-
"storybook": "9.1.
|
|
136
|
-
"ts-jest": "29.4.
|
|
135
|
+
"storybook": "9.1.7",
|
|
136
|
+
"ts-jest": "29.4.4",
|
|
137
137
|
"ts-node": "10.9.2",
|
|
138
138
|
"tsup": "8.5.0",
|
|
139
|
-
"typedoc": "0.28.
|
|
139
|
+
"typedoc": "0.28.13",
|
|
140
140
|
"typescript": "5.9.2",
|
|
141
|
-
"typescript-eslint": "8.
|
|
141
|
+
"typescript-eslint": "8.44.0"
|
|
142
142
|
}
|
|
143
143
|
}
|