@react-lgpd-consent/core 0.7.1 → 0.8.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 +49 -1
- package/README.md +3 -3
- package/dist/index.cjs +689 -427
- package/dist/index.d.cts +1673 -1437
- package/dist/index.d.ts +1673 -1437
- package/dist/index.js +689 -428
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Nível de severidade para mensagens de orientação ao desenvolvedor.
|
|
6
|
+
* @category Types
|
|
7
|
+
* @since 0.4.0
|
|
8
|
+
*/
|
|
4
9
|
type GuidanceSeverity = 'info' | 'warning' | 'error';
|
|
10
|
+
/**
|
|
11
|
+
* Representa uma mensagem de orientação para o desenvolvedor.
|
|
12
|
+
* @category Types
|
|
13
|
+
* @since 0.4.0
|
|
14
|
+
* @example
|
|
15
|
+
* { severity: 'warning', message: 'Configuração ausente', category: 'configuration', actionable: true }
|
|
16
|
+
*/
|
|
5
17
|
interface GuidanceMessage {
|
|
18
|
+
/** Nível de severidade da mensagem */
|
|
6
19
|
severity: GuidanceSeverity;
|
|
20
|
+
/** Texto da mensagem */
|
|
7
21
|
message: string;
|
|
22
|
+
/** Categoria relacionada à mensagem */
|
|
8
23
|
category?: string;
|
|
24
|
+
/** Indica se há ação recomendada */
|
|
9
25
|
actionable?: boolean;
|
|
10
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuração para controle de exibição de mensagens de orientação.
|
|
29
|
+
* @category Types
|
|
30
|
+
* @since 0.4.0
|
|
31
|
+
*/
|
|
11
32
|
interface GuidanceConfig {
|
|
12
33
|
/** Controla se avisos devem ser exibidos */
|
|
13
34
|
showWarnings?: boolean;
|
|
@@ -24,10 +45,19 @@ interface GuidanceConfig {
|
|
|
24
45
|
/** Callback personalizado para processar mensagens */
|
|
25
46
|
messageProcessor?: (messages: GuidanceMessage[]) => void;
|
|
26
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Resultado da análise de configuração LGPD para orientação do desenvolvedor.
|
|
50
|
+
* @category Types
|
|
51
|
+
* @since 0.4.0
|
|
52
|
+
*/
|
|
27
53
|
interface DeveloperGuidance {
|
|
54
|
+
/** Lista de avisos críticos */
|
|
28
55
|
warnings: string[];
|
|
56
|
+
/** Lista de sugestões */
|
|
29
57
|
suggestions: string[];
|
|
58
|
+
/** Mensagens detalhadas de orientação */
|
|
30
59
|
messages: GuidanceMessage[];
|
|
60
|
+
/** Informações das categorias ativas */
|
|
31
61
|
activeCategoriesInfo: {
|
|
32
62
|
id: string;
|
|
33
63
|
name: string;
|
|
@@ -36,21 +66,62 @@ interface DeveloperGuidance {
|
|
|
36
66
|
uiRequired: boolean;
|
|
37
67
|
cookies?: string[];
|
|
38
68
|
}[];
|
|
69
|
+
/** Indica se está usando configuração padrão */
|
|
39
70
|
usingDefaults: boolean;
|
|
71
|
+
/** Score de conformidade LGPD (0-100) com carater orientativo */
|
|
40
72
|
complianceScore?: number;
|
|
41
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Configuração padrão de categorias do projeto.
|
|
76
|
+
* @category Consts
|
|
77
|
+
* @since 0.4.0
|
|
78
|
+
*/
|
|
42
79
|
declare const DEFAULT_PROJECT_CATEGORIES: ProjectCategoriesConfig;
|
|
43
80
|
/**
|
|
44
|
-
* Analisa configuração e integrações implícitas para orientar o
|
|
45
|
-
*
|
|
81
|
+
* Analisa configuração e integrações implícitas para orientar o desenvolvedor.
|
|
82
|
+
* @category Utils
|
|
83
|
+
* @param config Configuração de categorias do projeto
|
|
84
|
+
* @returns Objeto de orientação ao desenvolvedor
|
|
85
|
+
* @remarks
|
|
46
86
|
* Since v0.4.0: inclui customCategories.
|
|
47
87
|
* Since v0.4.1: considera categorias/integrações implícitas e enriquece cookies por categoria.
|
|
88
|
+
* @example
|
|
89
|
+
* const guidance = analyzeDeveloperConfiguration({ enabledCategories: ['analytics', 'marketing'] })
|
|
48
90
|
*/
|
|
49
91
|
declare function analyzeDeveloperConfiguration(config?: ProjectCategoriesConfig): DeveloperGuidance;
|
|
92
|
+
/**
|
|
93
|
+
* Loga orientação ao desenvolvedor no console/browser/servidor.
|
|
94
|
+
* @category Utils
|
|
95
|
+
* @param guidance Objeto de orientação
|
|
96
|
+
* @param disableGuidanceProp Desabilita logs se true
|
|
97
|
+
* @param config Configuração customizada de exibição
|
|
98
|
+
* @remarks
|
|
99
|
+
* Não loga em produção ou se desabilitado.
|
|
100
|
+
* @since 0.4.0
|
|
101
|
+
*/
|
|
50
102
|
declare function logDeveloperGuidance(guidance: DeveloperGuidance, disableGuidanceProp?: boolean, config?: GuidanceConfig): void;
|
|
103
|
+
/**
|
|
104
|
+
* Hook React para análise e logging de orientação LGPD ao desenvolvedor.
|
|
105
|
+
* @category Hooks
|
|
106
|
+
* @param config Configuração de categorias do projeto
|
|
107
|
+
* @param disableGuidanceProp Desabilita logs se true
|
|
108
|
+
* @param guidanceConfig Configuração customizada de exibição
|
|
109
|
+
* @returns Objeto de orientação LGPD
|
|
110
|
+
* @remarks
|
|
111
|
+
* SSR-safe: só loga no client.
|
|
112
|
+
* @since 0.4.0
|
|
113
|
+
* @see analyzeDeveloperConfiguration
|
|
114
|
+
* @see logDeveloperGuidance
|
|
115
|
+
* @example
|
|
116
|
+
* const guidance = useDeveloperGuidance({ enabledCategories: ['analytics'] })
|
|
117
|
+
*/
|
|
51
118
|
declare function useDeveloperGuidance(config?: ProjectCategoriesConfig, disableGuidanceProp?: boolean, guidanceConfig?: GuidanceConfig): DeveloperGuidance;
|
|
52
119
|
/**
|
|
53
|
-
* Presets de configuração para diferentes ambientes
|
|
120
|
+
* Presets de configuração para diferentes ambientes de desenvolvimento/produção.
|
|
121
|
+
* @category Consts
|
|
122
|
+
* @since 0.4.0
|
|
123
|
+
* @example
|
|
124
|
+
* GUIDANCE_PRESETS.development
|
|
54
125
|
*/
|
|
55
126
|
declare const GUIDANCE_PRESETS: {
|
|
56
127
|
/** Configuração completa para desenvolvimento */
|
|
@@ -93,200 +164,470 @@ declare const GUIDANCE_PRESETS: {
|
|
|
93
164
|
|
|
94
165
|
/**
|
|
95
166
|
* @fileoverview
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* Este arquivo contém todas as interfaces, tipos e estruturas de dados utilizadas
|
|
99
|
-
* pela biblioteca react-lgpd-consent, incluindo definições de categorias,
|
|
100
|
-
* estado de consentimento, configurações e textos da interface.
|
|
167
|
+
* Sistema de textos expandido com suporte avançado a internacionalização,
|
|
168
|
+
* contextos específicos e variações de tom.
|
|
101
169
|
*
|
|
102
170
|
* @author Luciano Édipo
|
|
103
|
-
* @since 0.1
|
|
171
|
+
* @since 0.4.1
|
|
104
172
|
*/
|
|
173
|
+
|
|
105
174
|
/**
|
|
106
|
-
*
|
|
107
|
-
* @category Types
|
|
108
|
-
* @since 0.2.0
|
|
109
|
-
*
|
|
110
|
-
* @remarks
|
|
111
|
-
* Use este tipo para identificar as categorias principais de cookies suportadas nativamente pela biblioteca.
|
|
112
|
-
* Cada categoria representa um tipo específico de processamento de dados:
|
|
113
|
-
*
|
|
114
|
-
* - `'necessary'`: Cookies essenciais para funcionamento do site (sempre ativos).
|
|
115
|
-
* - `'analytics'`: Cookies para análise e estatísticas de uso.
|
|
116
|
-
* - `'functional'`: Cookies para funcionalidades extras e preferências do usuário.
|
|
117
|
-
* - `'marketing'`: Cookies para publicidade e marketing direcionado.
|
|
118
|
-
* - `'social'`: Cookies para integração com redes sociais.
|
|
119
|
-
* - `'personalization'`: Cookies para personalização de conteúdo e experiência.
|
|
175
|
+
* Tipo auxiliar para variações de texto.
|
|
120
176
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* const categories: Category[] = ['analytics', 'marketing'];
|
|
124
|
-
* ```
|
|
177
|
+
* Define um subconjunto opcional dos textos principais do banner e modal,
|
|
178
|
+
* permitindo variações de tom (formal, casual, etc.) sem sobrescrever todos os textos.
|
|
125
179
|
*
|
|
126
|
-
* @
|
|
180
|
+
* @category Types
|
|
181
|
+
* @since 0.4.1
|
|
127
182
|
*/
|
|
128
|
-
type
|
|
183
|
+
type TextVariant = Partial<Pick<ConsentTexts, 'bannerMessage' | 'acceptAll' | 'declineAll' | 'modalTitle'>>;
|
|
129
184
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @category Types
|
|
132
|
-
* @since 0.2.0
|
|
133
|
-
*
|
|
134
|
-
* @remarks
|
|
135
|
-
* Esta interface define a estrutura completa de uma categoria de cookies,
|
|
136
|
-
* incluindo metadados e configurações específicas para processamento
|
|
137
|
-
* e exibição na interface do usuário.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* // Categoria padrão da biblioteca
|
|
142
|
-
* const analyticsCategory: CategoryDefinition = {
|
|
143
|
-
* id: 'analytics',
|
|
144
|
-
* name: 'Cookies Analíticos',
|
|
145
|
-
* description: 'Utilizados para análise de uso do site',
|
|
146
|
-
* essential: false,
|
|
147
|
-
* cookies: ['_ga', '_ga_*', '_gid']
|
|
148
|
-
* };
|
|
185
|
+
* Tipo auxiliar para textos de idioma.
|
|
149
186
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* id: 'chat',
|
|
153
|
-
* name: 'Chat de Suporte',
|
|
154
|
-
* description: 'Widget de chat para suporte ao cliente',
|
|
155
|
-
* essential: false
|
|
156
|
-
* };
|
|
157
|
-
* ```
|
|
187
|
+
* Define um subconjunto dos textos principais, excluindo propriedades específicas de internacionalização
|
|
188
|
+
* e contextos, para uso em configurações multilíngues.
|
|
158
189
|
*
|
|
159
|
-
* @
|
|
190
|
+
* @category Types
|
|
191
|
+
* @since 0.4.1
|
|
160
192
|
*/
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Identificador único da categoria.
|
|
164
|
-
* @example 'analytics'
|
|
165
|
-
*/
|
|
166
|
-
id: string;
|
|
167
|
-
/**
|
|
168
|
-
* Nome amigável exibido na interface do usuário.
|
|
169
|
-
* @example 'Cookies Analíticos'
|
|
170
|
-
*/
|
|
171
|
-
name: string;
|
|
172
|
-
/**
|
|
173
|
-
* Descrição detalhada da finalidade da categoria.
|
|
174
|
-
* @example 'Utilizados para análise de uso e comportamento no site'
|
|
175
|
-
*/
|
|
176
|
-
description: string;
|
|
177
|
-
/**
|
|
178
|
-
* Indica se é uma categoria essencial que não pode ser desabilitada pelo usuário.
|
|
179
|
-
* @defaultValue false
|
|
180
|
-
*/
|
|
181
|
-
essential?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Lista de nomes de cookies ou padrões específicos desta categoria.
|
|
184
|
-
* @example ['_ga', '_ga_*', '_gid']
|
|
185
|
-
*/
|
|
186
|
-
cookies?: string[];
|
|
187
|
-
/**
|
|
188
|
-
* Metadados detalhados sobre cookies típicos desta categoria.
|
|
189
|
-
* Não exaustivo; serve para orientar UI e documentação.
|
|
190
|
-
*/
|
|
191
|
-
cookiesInfo?: CookieDescriptor[];
|
|
192
|
-
}
|
|
193
|
+
type LanguageTexts = Partial<Omit<ConsentTexts, 'i18n' | 'variants' | 'contexts'>>;
|
|
193
194
|
/**
|
|
194
|
-
*
|
|
195
|
-
* @category Types
|
|
196
|
-
* @since 0.2.0
|
|
197
|
-
*
|
|
198
|
-
* @remarks
|
|
199
|
-
* Mantém compatibilidade com abordagens comuns no mercado.
|
|
200
|
-
* Fornece informações detalhadas sobre cookies para exibição em interfaces
|
|
201
|
-
* e documentação de compliance.
|
|
195
|
+
* Sistema de textos avançado com suporte a internacionalização e contextos específicos.
|
|
202
196
|
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* name: '_ga',
|
|
207
|
-
* purpose: 'analytics',
|
|
208
|
-
* duration: '2 years',
|
|
209
|
-
* domain: '.example.com',
|
|
210
|
-
* provider: 'Google Analytics'
|
|
211
|
-
* };
|
|
212
|
-
* ```
|
|
197
|
+
* Interface expandida que permite personalização granular de todas as mensagens da biblioteca.
|
|
198
|
+
* Suporta múltiplos idiomas, contextos específicos (e-commerce, SaaS, governo), variações
|
|
199
|
+
* de tom, e compliance completo com LGPD.
|
|
213
200
|
*
|
|
214
|
-
* @public
|
|
215
|
-
*/
|
|
216
|
-
interface CookieDescriptor {
|
|
217
|
-
/**
|
|
218
|
-
* Identificador ou padrão do cookie.
|
|
219
|
-
* @example '_ga'
|
|
220
|
-
*/
|
|
221
|
-
name: string;
|
|
222
|
-
/**
|
|
223
|
-
* Finalidade do cookie (opcional).
|
|
224
|
-
* @example 'analytics'
|
|
225
|
-
*/
|
|
226
|
-
purpose?: string;
|
|
227
|
-
/**
|
|
228
|
-
* Tempo de retenção do cookie (opcional).
|
|
229
|
-
* @example '2 years'
|
|
230
|
-
*/
|
|
231
|
-
duration?: string;
|
|
232
|
-
/**
|
|
233
|
-
* Domínio associado ao cookie (opcional).
|
|
234
|
-
* @example '.example.com'
|
|
235
|
-
*/
|
|
236
|
-
domain?: string;
|
|
237
|
-
/**
|
|
238
|
-
* Provedor ou serviço associado ao cookie (opcional).
|
|
239
|
-
* @example 'Google Analytics'
|
|
240
|
-
*/
|
|
241
|
-
provider?: string;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Configuração de categorias ativas no projeto.
|
|
245
201
|
* @category Types
|
|
246
|
-
* @since 0.
|
|
247
|
-
*
|
|
202
|
+
* @since 0.4.1
|
|
248
203
|
* @remarks
|
|
249
|
-
*
|
|
250
|
-
* e permite extensão com categorias customizadas específicas do projeto.
|
|
251
|
-
*
|
|
252
|
-
* A categoria 'necessary' é sempre incluída automaticamente e não precisa ser
|
|
253
|
-
* especificada em `enabledCategories`.
|
|
204
|
+
* **Histórico**: v0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
254
205
|
*
|
|
255
|
-
* @example
|
|
206
|
+
* @example Configuração multilíngue
|
|
256
207
|
* ```typescript
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
208
|
+
* const multiLangTexts: AdvancedConsentTexts = {
|
|
209
|
+
* // Herda de ConsentTexts básico
|
|
210
|
+
* bannerMessage: 'Utilizamos cookies para melhorar sua experiência.',
|
|
211
|
+
* acceptAll: 'Aceitar todos',
|
|
212
|
+
* declineAll: 'Recusar',
|
|
213
|
+
* preferences: 'Preferências',
|
|
214
|
+
* modalTitle: 'Preferências de Cookies',
|
|
215
|
+
* modalIntro: 'Personalize suas preferências de cookies.',
|
|
216
|
+
* save: 'Salvar',
|
|
217
|
+
* necessaryAlwaysOn: 'Cookies necessários (sempre ativos)',
|
|
262
218
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* customCategories: [
|
|
269
|
-
* {
|
|
270
|
-
* id: 'chat',
|
|
271
|
-
* name: 'Chat de Suporte',
|
|
272
|
-
* description: 'Widget de chat para suporte ao cliente'
|
|
219
|
+
* // Textos expandidos
|
|
220
|
+
* variants: {
|
|
221
|
+
* formal: {
|
|
222
|
+
* bannerMessage: 'Este sítio utiliza cookies para otimizar a experiência de navegação.',
|
|
223
|
+
* acceptAll: 'Concordar com todos os cookies'
|
|
273
224
|
* },
|
|
274
|
-
* {
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* description: 'Experimentos de interface e funcionalidades'
|
|
225
|
+
* casual: {
|
|
226
|
+
* bannerMessage: '🍪 Olá! Usamos cookies para tornar tudo mais gostoso aqui.',
|
|
227
|
+
* acceptAll: 'Aceitar tudo'
|
|
278
228
|
* }
|
|
279
|
-
*
|
|
280
|
-
* };
|
|
281
|
-
* ```
|
|
229
|
+
* },
|
|
282
230
|
*
|
|
283
|
-
*
|
|
231
|
+
* // Internacionalização
|
|
232
|
+
* i18n: {
|
|
233
|
+
* en: {
|
|
234
|
+
* bannerMessage: 'We use cookies to enhance your experience.',
|
|
235
|
+
* acceptAll: 'Accept All',
|
|
236
|
+
* declineAll: 'Decline'
|
|
237
|
+
* },
|
|
238
|
+
* es: {
|
|
239
|
+
* bannerMessage: 'Utilizamos cookies para mejorar su experiencia.',
|
|
240
|
+
* acceptAll: 'Aceptar Todo',
|
|
241
|
+
* declineAll: 'Rechazar'
|
|
242
|
+
* }
|
|
243
|
+
* }
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
284
246
|
*/
|
|
285
|
-
interface
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
247
|
+
interface AdvancedConsentTexts extends ConsentTexts {
|
|
248
|
+
/** Texto para confirmar ação */
|
|
249
|
+
confirm?: string;
|
|
250
|
+
/** Texto para cancelar ação */
|
|
251
|
+
cancel?: string;
|
|
252
|
+
/** Texto de carregamento */
|
|
253
|
+
loading?: string;
|
|
254
|
+
/** Textos específicos para cada categoria de cookie */
|
|
255
|
+
categories?: {
|
|
256
|
+
necessary?: {
|
|
257
|
+
name?: string;
|
|
258
|
+
description?: string;
|
|
259
|
+
examples?: string;
|
|
260
|
+
};
|
|
261
|
+
analytics?: {
|
|
262
|
+
name?: string;
|
|
263
|
+
description?: string;
|
|
264
|
+
examples?: string;
|
|
265
|
+
};
|
|
266
|
+
marketing?: {
|
|
267
|
+
name?: string;
|
|
268
|
+
description?: string;
|
|
269
|
+
examples?: string;
|
|
270
|
+
};
|
|
271
|
+
functional?: {
|
|
272
|
+
name?: string;
|
|
273
|
+
description?: string;
|
|
274
|
+
examples?: string;
|
|
275
|
+
};
|
|
276
|
+
performance?: {
|
|
277
|
+
name?: string;
|
|
278
|
+
description?: string;
|
|
279
|
+
examples?: string;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/** Mensagens de feedback ao usuário */
|
|
283
|
+
feedback?: {
|
|
284
|
+
/** Preferências salvas com sucesso */
|
|
285
|
+
saveSuccess?: string;
|
|
286
|
+
/** Erro ao salvar preferências */
|
|
287
|
+
saveError?: string;
|
|
288
|
+
/** Consentimento atualizado */
|
|
289
|
+
consentUpdated?: string;
|
|
290
|
+
/** Cookies rejeitados */
|
|
291
|
+
cookiesRejected?: string;
|
|
292
|
+
/** Configurações resetadas */
|
|
293
|
+
settingsReset?: string;
|
|
294
|
+
};
|
|
295
|
+
/** Labels ARIA e textos para leitores de tela */
|
|
296
|
+
accessibility?: {
|
|
297
|
+
/** Label do banner para leitores de tela */
|
|
298
|
+
bannerLabel?: string;
|
|
299
|
+
/** Label do modal para leitores de tela */
|
|
300
|
+
modalLabel?: string;
|
|
301
|
+
/** Instrução de navegação por teclado */
|
|
302
|
+
keyboardNavigation?: string;
|
|
303
|
+
/** Estado do toggle de categoria */
|
|
304
|
+
toggleState?: {
|
|
305
|
+
enabled?: string;
|
|
306
|
+
disabled?: string;
|
|
307
|
+
};
|
|
308
|
+
/** Região live para anúncios dinâmicos */
|
|
309
|
+
liveRegion?: string;
|
|
310
|
+
};
|
|
311
|
+
/** Textos otimizados para diferentes contextos */
|
|
312
|
+
contexts?: {
|
|
313
|
+
/** Contexto e-commerce */
|
|
314
|
+
ecommerce?: {
|
|
315
|
+
cartAbandonment?: string;
|
|
316
|
+
personalizedOffers?: string;
|
|
317
|
+
paymentSecurity?: string;
|
|
318
|
+
productRecommendations?: string;
|
|
319
|
+
};
|
|
320
|
+
/** Contexto SaaS */
|
|
321
|
+
saas?: {
|
|
322
|
+
userAnalytics?: string;
|
|
323
|
+
performanceMonitoring?: string;
|
|
324
|
+
featureUsage?: string;
|
|
325
|
+
customerSupport?: string;
|
|
326
|
+
};
|
|
327
|
+
/** Contexto governamental */
|
|
328
|
+
government?: {
|
|
329
|
+
citizenServices?: string;
|
|
330
|
+
dataProtection?: string;
|
|
331
|
+
transparency?: string;
|
|
332
|
+
accessibility?: string;
|
|
333
|
+
};
|
|
334
|
+
/** Contexto educacional */
|
|
335
|
+
education?: {
|
|
336
|
+
studentProgress?: string;
|
|
337
|
+
learningAnalytics?: string;
|
|
338
|
+
accessibility?: string;
|
|
339
|
+
parentalConsent?: string;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
/** Diferentes variações de tom para a mesma mensagem */
|
|
343
|
+
variants?: {
|
|
344
|
+
/** Tom formal/profissional */
|
|
345
|
+
formal?: TextVariant;
|
|
346
|
+
/** Tom casual/amigável */
|
|
347
|
+
casual?: TextVariant;
|
|
348
|
+
/** Tom conciso/direto */
|
|
349
|
+
concise?: TextVariant;
|
|
350
|
+
/** Tom detalhado/explicativo */
|
|
351
|
+
detailed?: TextVariant;
|
|
352
|
+
};
|
|
353
|
+
/** Suporte a múltiplos idiomas */
|
|
354
|
+
i18n?: {
|
|
355
|
+
/** Textos em inglês */
|
|
356
|
+
en?: LanguageTexts;
|
|
357
|
+
/** Textos em espanhol */
|
|
358
|
+
es?: LanguageTexts;
|
|
359
|
+
/** Textos em francês */
|
|
360
|
+
fr?: LanguageTexts;
|
|
361
|
+
/** Textos em alemão */
|
|
362
|
+
de?: LanguageTexts;
|
|
363
|
+
/** Textos em italiano */
|
|
364
|
+
it?: LanguageTexts;
|
|
365
|
+
};
|
|
366
|
+
/** Informações técnicas sobre cookies */
|
|
367
|
+
technical?: {
|
|
368
|
+
/** Explicação sobre cookies de sessão */
|
|
369
|
+
sessionCookies?: string;
|
|
370
|
+
/** Explicação sobre cookies persistentes */
|
|
371
|
+
persistentCookies?: string;
|
|
372
|
+
/** Explicação sobre cookies de terceiros */
|
|
373
|
+
thirdPartyCookies?: string;
|
|
374
|
+
/** Como desabilitar cookies no navegador */
|
|
375
|
+
browserSettings?: string;
|
|
376
|
+
/** Impacto de desabilitar cookies */
|
|
377
|
+
disablingImpact?: string;
|
|
378
|
+
};
|
|
379
|
+
/** Cabeçalhos para tabela de detalhes de cookies */
|
|
380
|
+
cookieDetails?: {
|
|
381
|
+
tableHeaders?: {
|
|
382
|
+
name?: string;
|
|
383
|
+
purpose?: string;
|
|
384
|
+
duration?: string;
|
|
385
|
+
provider?: string;
|
|
386
|
+
type?: string;
|
|
387
|
+
};
|
|
388
|
+
/** Texto quando não há cookies para mostrar */
|
|
389
|
+
noCookies?: string;
|
|
390
|
+
/** Botão para expandir/colapsar detalhes */
|
|
391
|
+
toggleDetails?: {
|
|
392
|
+
expand?: string;
|
|
393
|
+
collapse?: string;
|
|
394
|
+
};
|
|
395
|
+
/** Prefixo exibido antes do ID do script */
|
|
396
|
+
scriptLabelPrefix?: string;
|
|
397
|
+
/** Texto de finalidade para scripts ativos detectados */
|
|
398
|
+
scriptPurpose?: string;
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Textos padrão expandidos para diferentes contextos e idiomas.
|
|
403
|
+
*
|
|
404
|
+
* @category Utils
|
|
405
|
+
* @since 0.4.1
|
|
406
|
+
*/
|
|
407
|
+
declare const EXPANDED_DEFAULT_TEXTS: Partial<AdvancedConsentTexts>;
|
|
408
|
+
/**
|
|
409
|
+
* Utilitário para resolver textos baseado em idioma, contexto e variação.
|
|
410
|
+
*
|
|
411
|
+
* @category Utils
|
|
412
|
+
* @since 0.4.1
|
|
413
|
+
*
|
|
414
|
+
* @param texts - Textos avançados configurados
|
|
415
|
+
* @param options - Opções de resolução
|
|
416
|
+
* @returns Textos resolvidos para o contexto
|
|
417
|
+
*/
|
|
418
|
+
declare function resolveTexts(texts: AdvancedConsentTexts, options?: {
|
|
419
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
420
|
+
context?: 'ecommerce' | 'saas' | 'government' | 'education';
|
|
421
|
+
variant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
422
|
+
}): AdvancedConsentTexts;
|
|
423
|
+
/**
|
|
424
|
+
* Templates pré-configurados para diferentes contextos.
|
|
425
|
+
*
|
|
426
|
+
* @category Utils
|
|
427
|
+
* @since 0.4.1
|
|
428
|
+
*/
|
|
429
|
+
declare const TEXT_TEMPLATES: {
|
|
430
|
+
readonly ecommerce: AdvancedConsentTexts;
|
|
431
|
+
readonly saas: AdvancedConsentTexts;
|
|
432
|
+
readonly government: AdvancedConsentTexts;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @fileoverview
|
|
437
|
+
* Definições de tipos TypeScript para o sistema de consentimento LGPD.
|
|
438
|
+
*
|
|
439
|
+
* Este arquivo contém todas as interfaces, tipos e estruturas de dados utilizadas
|
|
440
|
+
* pela biblioteca react-lgpd-consent, incluindo definições de categorias,
|
|
441
|
+
* estado de consentimento, configurações e textos da interface.
|
|
442
|
+
*
|
|
443
|
+
* @author Luciano Édipo
|
|
444
|
+
* @since 0.1.0
|
|
445
|
+
*/
|
|
446
|
+
/**
|
|
447
|
+
* Tipos de categorias padrão de consentimento para cookies, conforme definido pela ANPD.
|
|
448
|
+
* @category Types
|
|
449
|
+
* @since 0.2.0
|
|
450
|
+
*
|
|
451
|
+
* @remarks
|
|
452
|
+
* Use este tipo para identificar as categorias principais de cookies suportadas nativamente pela biblioteca.
|
|
453
|
+
* Cada categoria representa um tipo específico de processamento de dados:
|
|
454
|
+
*
|
|
455
|
+
* - `'necessary'`: Cookies essenciais para funcionamento do site (sempre ativos).
|
|
456
|
+
* - `'analytics'`: Cookies para análise e estatísticas de uso.
|
|
457
|
+
* - `'functional'`: Cookies para funcionalidades extras e preferências do usuário.
|
|
458
|
+
* - `'marketing'`: Cookies para publicidade e marketing direcionado.
|
|
459
|
+
* - `'social'`: Cookies para integração com redes sociais.
|
|
460
|
+
* - `'personalization'`: Cookies para personalização de conteúdo e experiência.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```typescript
|
|
464
|
+
* const categories: Category[] = ['analytics', 'marketing'];
|
|
465
|
+
* ```
|
|
466
|
+
*
|
|
467
|
+
* @public
|
|
468
|
+
*/
|
|
469
|
+
type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social' | 'personalization';
|
|
470
|
+
/**
|
|
471
|
+
* Definição detalhada de uma categoria de cookie para uso interno.
|
|
472
|
+
* @category Types
|
|
473
|
+
* @since 0.2.0
|
|
474
|
+
*
|
|
475
|
+
* @remarks
|
|
476
|
+
* Esta interface define a estrutura completa de uma categoria de cookies,
|
|
477
|
+
* incluindo metadados e configurações específicas para processamento
|
|
478
|
+
* e exibição na interface do usuário.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```typescript
|
|
482
|
+
* // Categoria padrão da biblioteca
|
|
483
|
+
* const analyticsCategory: CategoryDefinition = {
|
|
484
|
+
* id: 'analytics',
|
|
485
|
+
* name: 'Cookies Analíticos',
|
|
486
|
+
* description: 'Utilizados para análise de uso do site',
|
|
487
|
+
* essential: false,
|
|
488
|
+
* cookies: ['_ga', '_ga_*', '_gid']
|
|
489
|
+
* };
|
|
490
|
+
*
|
|
491
|
+
* // Categoria customizada específica do projeto
|
|
492
|
+
* const chatCategory: CategoryDefinition = {
|
|
493
|
+
* id: 'chat',
|
|
494
|
+
* name: 'Chat de Suporte',
|
|
495
|
+
* description: 'Widget de chat para suporte ao cliente',
|
|
496
|
+
* essential: false
|
|
497
|
+
* };
|
|
498
|
+
* ```
|
|
499
|
+
*
|
|
500
|
+
* @public
|
|
501
|
+
*/
|
|
502
|
+
interface CategoryDefinition {
|
|
503
|
+
/**
|
|
504
|
+
* Identificador único da categoria.
|
|
505
|
+
* @example 'analytics'
|
|
506
|
+
*/
|
|
507
|
+
id: string;
|
|
508
|
+
/**
|
|
509
|
+
* Nome amigável exibido na interface do usuário.
|
|
510
|
+
* @example 'Cookies Analíticos'
|
|
511
|
+
*/
|
|
512
|
+
name: string;
|
|
513
|
+
/**
|
|
514
|
+
* Descrição detalhada da finalidade da categoria.
|
|
515
|
+
* @example 'Utilizados para análise de uso e comportamento no site'
|
|
516
|
+
*/
|
|
517
|
+
description: string;
|
|
518
|
+
/**
|
|
519
|
+
* Indica se é uma categoria essencial que não pode ser desabilitada pelo usuário.
|
|
520
|
+
* @defaultValue false
|
|
521
|
+
*/
|
|
522
|
+
essential?: boolean;
|
|
523
|
+
/**
|
|
524
|
+
* Lista de nomes de cookies ou padrões específicos desta categoria.
|
|
525
|
+
* @example ['_ga', '_ga_*', '_gid']
|
|
526
|
+
*/
|
|
527
|
+
cookies?: string[];
|
|
528
|
+
/**
|
|
529
|
+
* Metadados detalhados sobre cookies típicos desta categoria.
|
|
530
|
+
* Não exaustivo; serve para orientar UI e documentação.
|
|
531
|
+
*/
|
|
532
|
+
cookiesInfo?: CookieDescriptor[];
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Descritor de cookie com metadados úteis para UI/documentação.
|
|
536
|
+
* @category Types
|
|
537
|
+
* @since 0.2.0
|
|
538
|
+
*
|
|
539
|
+
* @remarks
|
|
540
|
+
* Mantém compatibilidade com abordagens comuns no mercado.
|
|
541
|
+
* Fornece informações detalhadas sobre cookies para exibição em interfaces
|
|
542
|
+
* e documentação de compliance.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* const cookieInfo: CookieDescriptor = {
|
|
547
|
+
* name: '_ga',
|
|
548
|
+
* purpose: 'analytics',
|
|
549
|
+
* duration: '2 years',
|
|
550
|
+
* domain: '.example.com',
|
|
551
|
+
* provider: 'Google Analytics'
|
|
552
|
+
* };
|
|
553
|
+
* ```
|
|
554
|
+
*
|
|
555
|
+
* @public
|
|
556
|
+
*/
|
|
557
|
+
interface CookieDescriptor {
|
|
558
|
+
/**
|
|
559
|
+
* Identificador ou padrão do cookie.
|
|
560
|
+
* @example '_ga'
|
|
561
|
+
*/
|
|
562
|
+
name: string;
|
|
563
|
+
/**
|
|
564
|
+
* Finalidade do cookie (opcional).
|
|
565
|
+
* @example 'analytics'
|
|
566
|
+
*/
|
|
567
|
+
purpose?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Tempo de retenção do cookie (opcional).
|
|
570
|
+
* @example '2 years'
|
|
571
|
+
*/
|
|
572
|
+
duration?: string;
|
|
573
|
+
/**
|
|
574
|
+
* Domínio associado ao cookie (opcional).
|
|
575
|
+
* @example '.example.com'
|
|
576
|
+
*/
|
|
577
|
+
domain?: string;
|
|
578
|
+
/**
|
|
579
|
+
* Provedor ou serviço associado ao cookie (opcional).
|
|
580
|
+
* @example 'Google Analytics'
|
|
581
|
+
*/
|
|
582
|
+
provider?: string;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Configuração de categorias ativas no projeto.
|
|
586
|
+
* @category Types
|
|
587
|
+
* @since 0.2.0
|
|
588
|
+
*
|
|
589
|
+
* @remarks
|
|
590
|
+
* Define quais categorias fixas serão usadas (além de 'necessary' que é sempre incluída)
|
|
591
|
+
* e permite extensão com categorias customizadas específicas do projeto.
|
|
592
|
+
*
|
|
593
|
+
* A categoria 'necessary' é sempre incluída automaticamente e não precisa ser
|
|
594
|
+
* especificada em `enabledCategories`.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```typescript
|
|
598
|
+
* // Configuração básica
|
|
599
|
+
* const config: ProjectCategoriesConfig = {
|
|
600
|
+
* enabledCategories: ['analytics', 'marketing']
|
|
601
|
+
* };
|
|
602
|
+
* ```
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* // Configuração com categorias customizadas
|
|
607
|
+
* const config: ProjectCategoriesConfig = {
|
|
608
|
+
* enabledCategories: ['analytics'],
|
|
609
|
+
* customCategories: [
|
|
610
|
+
* {
|
|
611
|
+
* id: 'chat',
|
|
612
|
+
* name: 'Chat de Suporte',
|
|
613
|
+
* description: 'Widget de chat para suporte ao cliente'
|
|
614
|
+
* },
|
|
615
|
+
* {
|
|
616
|
+
* id: 'abTesting',
|
|
617
|
+
* name: 'A/B Testing',
|
|
618
|
+
* description: 'Experimentos de interface e funcionalidades'
|
|
619
|
+
* }
|
|
620
|
+
* ]
|
|
621
|
+
* };
|
|
622
|
+
* ```
|
|
623
|
+
*
|
|
624
|
+
* @public
|
|
625
|
+
*/
|
|
626
|
+
interface ProjectCategoriesConfig {
|
|
627
|
+
/**
|
|
628
|
+
* Categorias padrão que serão ativadas.
|
|
629
|
+
* A categoria 'necessary' é sempre incluída automaticamente.
|
|
630
|
+
* @example ['analytics', 'marketing']
|
|
290
631
|
*/
|
|
291
632
|
enabledCategories?: Category[];
|
|
292
633
|
/**
|
|
@@ -832,6 +1173,19 @@ type BackdropConfig = boolean | string | {
|
|
|
832
1173
|
* @since 0.1.3
|
|
833
1174
|
* @remarks
|
|
834
1175
|
* **Histórico**: v0.4.1 - Expandido substancialmente com novos tokens
|
|
1176
|
+
*
|
|
1177
|
+
* ### Mapa de tokens (top-level)
|
|
1178
|
+
* - `colors`: cores base, semânticas e por componente
|
|
1179
|
+
* - `typography`: fonte, tamanhos, pesos e hierarquia
|
|
1180
|
+
* - `spacing`: espaçamentos, padding/margin e radius
|
|
1181
|
+
* - `layout`: posição, largura, backdrop e z-index
|
|
1182
|
+
* - `effects`: sombras, transições e filtros
|
|
1183
|
+
* - `accessibility`: contraste, motion e foco
|
|
1184
|
+
* - `themes`: overrides para light/dark
|
|
1185
|
+
*
|
|
1186
|
+
* ### Overrides complementares (MUI)
|
|
1187
|
+
* Mesmo com tokens, você pode ajustar detalhes via `sx` e `ThemeProvider`.
|
|
1188
|
+
* Ex.: `cookieBannerProps.PaperProps.sx` e `preferencesModalProps.DialogProps.sx`.
|
|
835
1189
|
* @public
|
|
836
1190
|
*
|
|
837
1191
|
* @example Configuração básica
|
|
@@ -1278,7 +1632,19 @@ interface ConsentProviderProps {
|
|
|
1278
1632
|
* }}
|
|
1279
1633
|
* ```
|
|
1280
1634
|
*/
|
|
1281
|
-
texts?: Partial<
|
|
1635
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
1636
|
+
/**
|
|
1637
|
+
* Idioma ativo para resolver textos via i18n (opcional).
|
|
1638
|
+
* Quando definido, aplica `texts.i18n[language]` nos campos principais.
|
|
1639
|
+
*
|
|
1640
|
+
* @defaultValue 'pt'
|
|
1641
|
+
*/
|
|
1642
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
1643
|
+
/**
|
|
1644
|
+
* Variação de tom aplicada aos textos (opcional).
|
|
1645
|
+
* Utiliza `texts.variants[variant]` como override dos textos principais.
|
|
1646
|
+
*/
|
|
1647
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
1282
1648
|
/**
|
|
1283
1649
|
* Tokens de design para customização visual avançada.
|
|
1284
1650
|
* Oferece controle direto sobre cores, fontes, espaçamento e layout.
|
|
@@ -1327,6 +1693,16 @@ interface ConsentProviderProps {
|
|
|
1327
1693
|
* - `true`: Banner bloqueia interação até decisão (compliance rigorosa)
|
|
1328
1694
|
*/
|
|
1329
1695
|
blocking?: boolean;
|
|
1696
|
+
/**
|
|
1697
|
+
* Intensidade do bloqueio quando `blocking` estiver habilitado.
|
|
1698
|
+
* - 'soft' (padrão): aplica apenas overlay visual (cliques bloqueados).
|
|
1699
|
+
* - 'hard': aplica overlay + torna o conteúdo da aplicação inerte (sem foco/teclado).
|
|
1700
|
+
*
|
|
1701
|
+
* @remarks
|
|
1702
|
+
* O modo `hard` utiliza o atributo `inert` para restringir navegação por teclado
|
|
1703
|
+
* ao banner/modal, atendendo contextos regulatórios mais estritos.
|
|
1704
|
+
*/
|
|
1705
|
+
blockingMode?: 'soft' | 'hard';
|
|
1330
1706
|
/**
|
|
1331
1707
|
* Estratégia de bloqueio quando `blocking` estiver habilitado.
|
|
1332
1708
|
* - 'auto' (padrão):
|
|
@@ -1472,13 +1848,27 @@ interface ConsentProviderProps {
|
|
|
1472
1848
|
* @since 0.3.1
|
|
1473
1849
|
* @public
|
|
1474
1850
|
* Fornece acesso ao estado de consentimento e ações necessárias para o banner.
|
|
1851
|
+
*
|
|
1852
|
+
* @example
|
|
1853
|
+
* ```tsx
|
|
1854
|
+
* function MyBanner({ acceptAll, rejectAll, openPreferences, texts }: CustomCookieBannerProps) {
|
|
1855
|
+
* return (
|
|
1856
|
+
* <div>
|
|
1857
|
+
* <p>{texts.bannerMessage}</p>
|
|
1858
|
+
* <button onClick={acceptAll}>{texts.acceptAll}</button>
|
|
1859
|
+
* <button onClick={rejectAll}>{texts.declineAll}</button>
|
|
1860
|
+
* <button onClick={openPreferences}>{texts.preferences}</button>
|
|
1861
|
+
* </div>
|
|
1862
|
+
* )
|
|
1863
|
+
* }
|
|
1864
|
+
* ```
|
|
1475
1865
|
*/
|
|
1476
1866
|
interface CustomCookieBannerProps {
|
|
1477
1867
|
consented: boolean;
|
|
1478
1868
|
acceptAll: () => void;
|
|
1479
1869
|
rejectAll: () => void;
|
|
1480
1870
|
openPreferences: () => void;
|
|
1481
|
-
texts:
|
|
1871
|
+
texts: AdvancedConsentTexts;
|
|
1482
1872
|
/** Indica se o branding padrão deve ser ocultado. */
|
|
1483
1873
|
hideBranding?: boolean;
|
|
1484
1874
|
/**
|
|
@@ -1497,6 +1887,28 @@ interface CustomCookieBannerProps {
|
|
|
1497
1887
|
* Fornece acesso às preferências atuais do usuário, funções para atualizar e salvar preferências,
|
|
1498
1888
|
* fechar o modal e textos customizados da interface.
|
|
1499
1889
|
*
|
|
1890
|
+
* @example
|
|
1891
|
+
* ```tsx
|
|
1892
|
+
* function MyPreferencesModal({
|
|
1893
|
+
* preferences,
|
|
1894
|
+
* setPreferences,
|
|
1895
|
+
* closePreferences,
|
|
1896
|
+
* isModalOpen,
|
|
1897
|
+
* texts,
|
|
1898
|
+
* }: CustomPreferencesModalProps) {
|
|
1899
|
+
* if (!isModalOpen) return null
|
|
1900
|
+
* return (
|
|
1901
|
+
* <div role="dialog" aria-label={texts.accessibility?.modalLabel}>
|
|
1902
|
+
* <h2>{texts.modalTitle}</h2>
|
|
1903
|
+
* <button onClick={() => setPreferences({ ...preferences, analytics: true })}>
|
|
1904
|
+
* {texts.acceptAll}
|
|
1905
|
+
* </button>
|
|
1906
|
+
* <button onClick={closePreferences}>{texts.close ?? 'Fechar'}</button>
|
|
1907
|
+
* </div>
|
|
1908
|
+
* )
|
|
1909
|
+
* }
|
|
1910
|
+
* ```
|
|
1911
|
+
*
|
|
1500
1912
|
* @property preferences Preferências atuais de consentimento do usuário.
|
|
1501
1913
|
* @property setPreferences Função para atualizar e salvar as preferências.
|
|
1502
1914
|
* @property closePreferences Função para fechar o modal de preferências.
|
|
@@ -1508,7 +1920,7 @@ interface CustomPreferencesModalProps {
|
|
|
1508
1920
|
setPreferences: (preferences: ConsentPreferences) => void;
|
|
1509
1921
|
closePreferences: () => void;
|
|
1510
1922
|
isModalOpen?: boolean;
|
|
1511
|
-
texts:
|
|
1923
|
+
texts: AdvancedConsentTexts;
|
|
1512
1924
|
}
|
|
1513
1925
|
/**
|
|
1514
1926
|
* Props esperadas por um componente customizado de FloatingPreferencesButton.
|
|
@@ -1516,6 +1928,14 @@ interface CustomPreferencesModalProps {
|
|
|
1516
1928
|
* @since 0.3.1
|
|
1517
1929
|
* @public
|
|
1518
1930
|
* Fornece acesso às ações de abertura do modal e ao estado de consentimento.
|
|
1931
|
+
*
|
|
1932
|
+
* @example
|
|
1933
|
+
* ```tsx
|
|
1934
|
+
* function MyFloatingButton({ openPreferences, consented }: CustomFloatingPreferencesButtonProps) {
|
|
1935
|
+
* if (!consented) return null
|
|
1936
|
+
* return <button onClick={openPreferences}>Gerenciar cookies</button>
|
|
1937
|
+
* }
|
|
1938
|
+
* ```
|
|
1519
1939
|
*/
|
|
1520
1940
|
interface CustomFloatingPreferencesButtonProps {
|
|
1521
1941
|
openPreferences: () => void;
|
|
@@ -1602,7 +2022,7 @@ type ConsentEventOrigin = 'banner' | 'modal' | 'reset' | 'programmatic';
|
|
|
1602
2022
|
* @example
|
|
1603
2023
|
* ```typescript
|
|
1604
2024
|
* // Exemplo de evento no dataLayer
|
|
1605
|
-
* window
|
|
2025
|
+
* globalThis.window?.dataLayer?.push({
|
|
1606
2026
|
* event: 'consent_initialized',
|
|
1607
2027
|
* consent_version: '0.4.5',
|
|
1608
2028
|
* timestamp: '2025-10-25T13:52:33.729Z',
|
|
@@ -1640,7 +2060,7 @@ interface ConsentInitializedEvent {
|
|
|
1640
2060
|
* @example
|
|
1641
2061
|
* ```typescript
|
|
1642
2062
|
* // Exemplo de evento no dataLayer após aceitar analytics
|
|
1643
|
-
* window
|
|
2063
|
+
* globalThis.window?.dataLayer?.push({
|
|
1644
2064
|
* event: 'consent_updated',
|
|
1645
2065
|
* consent_version: '0.4.5',
|
|
1646
2066
|
* timestamp: '2025-10-25T13:52:33.729Z',
|
|
@@ -1694,8 +2114,9 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1694
2114
|
*
|
|
1695
2115
|
* @param {Readonly<ConsentProviderProps>} props - As propriedades para configurar o provider.
|
|
1696
2116
|
* @param {ProjectCategoriesConfig} props.categories - **Obrigatório**. Define as categorias de cookies que seu projeto utiliza, em conformidade com o princípio de minimização da LGPD.
|
|
1697
|
-
* @param {Partial<
|
|
2117
|
+
* @param {Partial<AdvancedConsentTexts>} [props.texts] - Objeto para customizar todos os textos exibidos na UI.
|
|
1698
2118
|
* @param {boolean} [props.blocking=false] - Se `true`, exibe um overlay que impede a interação com o site até uma decisão do usuário.
|
|
2119
|
+
* @param {'soft' | 'hard'} [props.blockingMode='soft'] - Intensidade do bloqueio; use `hard` para tornar o conteúdo inerte e restringir navegação por teclado.
|
|
1699
2120
|
* @param {(state: ConsentState) => void} [props.onConsentGiven] - Callback executado na primeira vez que o usuário dá o consentimento.
|
|
1700
2121
|
* @param {(prefs: ConsentPreferences) => void} [props.onPreferencesSaved] - Callback executado sempre que o usuário salva novas preferências.
|
|
1701
2122
|
* @param {boolean} [props.disableDeveloperGuidance=false] - Desativa as mensagens de orientação no console em ambiente de desenvolvimento.
|
|
@@ -1729,8 +2150,8 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1729
2150
|
* </ConsentProvider>
|
|
1730
2151
|
* ```
|
|
1731
2152
|
*/
|
|
1732
|
-
declare function ConsentProvider({ initialState, categories, texts: textsProp, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding: _hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, storage, onConsentVersionChange, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, onConsentInit, onConsentChange, onAuditLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
1733
|
-
declare const defaultTexts:
|
|
2153
|
+
declare function ConsentProvider({ initialState, categories, texts: textsProp, language, textVariant, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingMode, blockingStrategy, hideBranding: _hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, storage, onConsentVersionChange, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, onConsentInit, onConsentChange, onAuditLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
2154
|
+
declare const defaultTexts: AdvancedConsentTexts;
|
|
1734
2155
|
|
|
1735
2156
|
/**
|
|
1736
2157
|
* @fileoverview
|
|
@@ -1873,7 +2294,7 @@ declare const defaultTexts: ConsentTexts;
|
|
|
1873
2294
|
* return (
|
|
1874
2295
|
* <div>
|
|
1875
2296
|
* ❌ Este recurso requer cookies funcionais.
|
|
1876
|
-
* <button onClick={() => window
|
|
2297
|
+
* <button onClick={() => globalThis.window?.openPreferencesModal?.()}>
|
|
1877
2298
|
* Alterar Preferências
|
|
1878
2299
|
* </button>
|
|
1879
2300
|
* </div>
|
|
@@ -2008,13 +2429,13 @@ declare function useConsent(): ConsentContextValue;
|
|
|
2008
2429
|
* }
|
|
2009
2430
|
* ```
|
|
2010
2431
|
*
|
|
2011
|
-
* @see {@link
|
|
2432
|
+
* @see {@link AdvancedConsentTexts} - Interface completa dos textos
|
|
2012
2433
|
* @see {@link ConsentProvider} - Para configurar textos personalizados
|
|
2013
2434
|
*
|
|
2014
2435
|
* @public
|
|
2015
2436
|
* @since 0.1.0
|
|
2016
2437
|
*/
|
|
2017
|
-
declare function useConsentTexts():
|
|
2438
|
+
declare function useConsentTexts(): AdvancedConsentTexts;
|
|
2018
2439
|
/**
|
|
2019
2440
|
* Hook para verificar se a hidratação do estado de consentimento foi concluída.
|
|
2020
2441
|
*
|
|
@@ -2106,7 +2527,7 @@ declare function useConsentTexts(): ConsentTexts;
|
|
|
2106
2527
|
* return (
|
|
2107
2528
|
* <div className="consent-partial">
|
|
2108
2529
|
* <p>Este recurso requer cookies funcionais.</p>
|
|
2109
|
-
* <button onClick={() => window
|
|
2530
|
+
* <button onClick={() => globalThis.window?.openPreferencesModal?.()}>
|
|
2110
2531
|
* Alterar Preferências
|
|
2111
2532
|
* </button>
|
|
2112
2533
|
* </div>
|
|
@@ -2157,1577 +2578,1390 @@ declare function useConsentTexts(): ConsentTexts;
|
|
|
2157
2578
|
* // Uso do hook customizado
|
|
2158
2579
|
* function MyFeature() {
|
|
2159
2580
|
* const { isEnabled, isLoading } = useConsentAwareFeature('analytics');
|
|
2160
|
-
*
|
|
2161
|
-
* if (isLoading) return <Skeleton />;
|
|
2162
|
-
* if (!isEnabled) return <ConsentRequired />;
|
|
2163
|
-
*
|
|
2164
|
-
* return <AnalyticsChart />;
|
|
2165
|
-
* }
|
|
2166
|
-
* ```
|
|
2167
|
-
*
|
|
2168
|
-
* @see {@link ConsentProvider} - Para configuração SSR
|
|
2169
|
-
*
|
|
2170
|
-
* @public
|
|
2171
|
-
* @since 0.1.0
|
|
2172
|
-
*/
|
|
2173
|
-
declare function useConsentHydration(): boolean;
|
|
2174
|
-
/**
|
|
2175
|
-
* @function
|
|
2176
|
-
* @category Hooks
|
|
2177
|
-
* @since 0.3.1
|
|
2178
|
-
* Hook para abrir o modal de preferências programaticamente.
|
|
2179
|
-
*
|
|
2180
|
-
* @returns Função para abrir o modal de preferências.
|
|
2181
|
-
*
|
|
2182
|
-
* @remarks
|
|
2183
|
-
* Este hook retorna uma função que pode ser usada para abrir o modal de preferências
|
|
2184
|
-
* de qualquer lugar dentro do contexto do ConsentProvider. É útil para criar botões
|
|
2185
|
-
* customizados ou trigger o modal baseado em eventos específicos.
|
|
2186
|
-
*
|
|
2187
|
-
* @throws {Error} Se usado fora do ConsentProvider
|
|
2188
|
-
*
|
|
2189
|
-
* @example
|
|
2190
|
-
* ```tsx
|
|
2191
|
-
* function CustomButton() {
|
|
2192
|
-
* const openPreferences = useOpenPreferencesModal();
|
|
2193
|
-
*
|
|
2194
|
-
* return (
|
|
2195
|
-
* <button onClick={openPreferences}>
|
|
2196
|
-
* Configurar Cookies
|
|
2197
|
-
* </button>
|
|
2198
|
-
* );
|
|
2199
|
-
* }
|
|
2200
|
-
* ```
|
|
2201
|
-
*/
|
|
2202
|
-
declare function useOpenPreferencesModal(): () => void;
|
|
2203
|
-
/**
|
|
2204
|
-
* @function
|
|
2205
|
-
* @category Utils
|
|
2206
|
-
* @since 0.3.1
|
|
2207
|
-
* Função global para abrir o modal de preferências de fora do contexto React.
|
|
2208
|
-
*
|
|
2209
|
-
* @remarks
|
|
2210
|
-
* Esta função permite abrir o modal de preferências de código JavaScript puro,
|
|
2211
|
-
* sem precisar estar dentro do contexto React. É útil para integração com
|
|
2212
|
-
* código legado ou bibliotecas de terceiros.
|
|
2213
|
-
*
|
|
2214
|
-
* A função é automaticamente registrada pelo ConsentProvider e limpa quando
|
|
2215
|
-
* o provider é desmontado.
|
|
2216
|
-
*
|
|
2217
|
-
* @example
|
|
2218
|
-
* ```javascript
|
|
2219
|
-
* // Em código JavaScript puro
|
|
2220
|
-
* window.openPreferencesModal?.();
|
|
2221
|
-
*
|
|
2222
|
-
* // Ou importando diretamente
|
|
2223
|
-
* import { openPreferencesModal } from 'react-lgpd-consent';
|
|
2224
|
-
* openPreferencesModal();
|
|
2225
|
-
* ```
|
|
2226
|
-
*/
|
|
2227
|
-
declare function openPreferencesModal(): void;
|
|
2228
|
-
|
|
2229
|
-
/**
|
|
2230
|
-
* @interface CategoriesContextValue
|
|
2231
|
-
* O valor fornecido pelo `CategoriesContext`, contendo informações sobre as categorias de cookies ativas no projeto.
|
|
2232
|
-
*/
|
|
2233
|
-
interface CategoriesContextValue {
|
|
2234
|
-
/** A configuração final das categorias, incluindo padrões aplicados. */
|
|
2235
|
-
config: ProjectCategoriesConfig;
|
|
2236
|
-
/** Análise e orientações para desenvolvedores, incluindo avisos e sugestões. */
|
|
2237
|
-
guidance: DeveloperGuidance;
|
|
2238
|
-
/** Um array de categorias que requerem um toggle na UI de preferências (não essenciais). */
|
|
2239
|
-
toggleableCategories: DeveloperGuidance['activeCategoriesInfo'];
|
|
2240
|
-
/** Um array contendo todas as categorias ativas no projeto (essenciais e não essenciais). */
|
|
2241
|
-
allCategories: DeveloperGuidance['activeCategoriesInfo'];
|
|
2242
|
-
}
|
|
2243
|
-
/**
|
|
2244
|
-
* @hook
|
|
2245
|
-
* @category Hooks
|
|
2246
|
-
* @since 0.2.2
|
|
2247
|
-
* Hook para acessar informações sobre as categorias de cookies ativas no projeto.
|
|
2248
|
-
*
|
|
2249
|
-
* @remarks
|
|
2250
|
-
* Este hook deve ser usado dentro do `ConsentProvider` (que internamente renderiza o `CategoriesProvider`).
|
|
2251
|
-
* Ele é útil para construir componentes de UI customizados que precisam se adaptar dinamicamente às categorias configuradas.
|
|
2252
|
-
*
|
|
2253
|
-
* @returns {CategoriesContextValue} Um objeto contendo a configuração, orientações e listas de categorias.
|
|
2254
|
-
*
|
|
2255
|
-
* @throws {Error} Se usado fora do `CategoriesProvider`.
|
|
2256
|
-
*/
|
|
2257
|
-
declare function useCategories(): CategoriesContextValue;
|
|
2258
|
-
/**
|
|
2259
|
-
* @hook
|
|
2260
|
-
* @category Hooks
|
|
2261
|
-
* @since 0.2.2
|
|
2262
|
-
* Hook de conveniência para verificar o status de uma categoria de cookie específica.
|
|
2263
|
-
*
|
|
2264
|
-
* @param {string} categoryId O ID da categoria a ser verificada (ex: 'analytics', 'necessary').
|
|
2265
|
-
* @returns {object} Um objeto com o status da categoria:
|
|
2266
|
-
* - `isActive`: `true` se a categoria está configurada e ativa no projeto.
|
|
2267
|
-
* - `isEssential`: `true` se a categoria é essencial (não pode ser desativada pelo usuário).
|
|
2268
|
-
* - `needsToggle`: `true` se a categoria requer um controle (switch) na UI de preferências.
|
|
2269
|
-
* - `name`: O nome amigável da categoria.
|
|
2270
|
-
* - `description`: A descrição da categoria.
|
|
2271
|
-
* @example
|
|
2272
|
-
* ```tsx
|
|
2273
|
-
* const analyticsStatus = useCategoryStatus('analytics')
|
|
2274
|
-
* if (analyticsStatus.isActive && analyticsStatus.needsToggle) {
|
|
2275
|
-
* // Renderizar switch para analytics
|
|
2276
|
-
* }
|
|
2277
|
-
* ```
|
|
2278
|
-
*/
|
|
2279
|
-
declare function useCategoryStatus(categoryId: string): {
|
|
2280
|
-
isActive: boolean;
|
|
2281
|
-
isEssential: boolean;
|
|
2282
|
-
needsToggle: boolean;
|
|
2283
|
-
name: string | undefined;
|
|
2284
|
-
description: string | undefined;
|
|
2285
|
-
};
|
|
2286
|
-
|
|
2287
|
-
/**
|
|
2288
|
-
* Provider que envolve a árvore de componentes para fornecer tokens de design via contexto.
|
|
2289
|
-
*
|
|
2290
|
-
* @remarks
|
|
2291
|
-
* Use este provider no topo da aplicação ou seção onde os componentes de consentimento
|
|
2292
|
-
* precisam acessar tokens de design. Permite overrides globais de design sem alterar
|
|
2293
|
-
* os componentes individuais, mantendo tree-shaking e performance.
|
|
2294
|
-
*
|
|
2295
|
-
* @param tokens - Tokens de design opcionais para customização (cores, layouts, etc.)
|
|
2296
|
-
* @param children - Componentes filhos que terão acesso aos tokens via contexto
|
|
2297
|
-
*
|
|
2298
|
-
* @example Uso básico com tokens padrão
|
|
2299
|
-
* ```tsx
|
|
2300
|
-
* import { DesignProvider } from './context/DesignContext';
|
|
2301
|
-
*
|
|
2302
|
-
* function App() {
|
|
2303
|
-
* return (
|
|
2304
|
-
* <DesignProvider>
|
|
2305
|
-
* <CookieBanner />
|
|
2306
|
-
* </DesignProvider>
|
|
2307
|
-
* );
|
|
2308
|
-
* }
|
|
2309
|
-
* ```
|
|
2310
|
-
*
|
|
2311
|
-
* @example Customização de cores
|
|
2312
|
-
* ```tsx
|
|
2313
|
-
* const customTokens = {
|
|
2314
|
-
* colors: {
|
|
2315
|
-
* primary: '#ff0000',
|
|
2316
|
-
* secondary: '#00ff00'
|
|
2317
|
-
* }
|
|
2318
|
-
* };
|
|
2319
|
-
*
|
|
2320
|
-
* function App() {
|
|
2321
|
-
* return (
|
|
2322
|
-
* <DesignProvider tokens={customTokens}>
|
|
2323
|
-
* <PreferencesModal />
|
|
2324
|
-
* </DesignProvider>
|
|
2325
|
-
* );
|
|
2326
|
-
* }
|
|
2327
|
-
* ```
|
|
2328
|
-
*
|
|
2329
|
-
*
|
|
2330
|
-
* @component
|
|
2331
|
-
* @category Context
|
|
2332
|
-
* @since 0.1.0
|
|
2333
|
-
*/
|
|
2334
|
-
declare function DesignProvider({ tokens, children, }: Readonly<{
|
|
2335
|
-
tokens?: DesignTokens;
|
|
2336
|
-
children: React$1.ReactNode;
|
|
2337
|
-
}>): react_jsx_runtime.JSX.Element;
|
|
2338
|
-
/**
|
|
2339
|
-
* Hook para acessar os tokens de design do contexto atual.
|
|
2340
|
-
*
|
|
2341
|
-
* @remarks
|
|
2342
|
-
* Retorna os tokens de design fornecidos pelo DesignProvider mais próximo na árvore de componentes.
|
|
2343
|
-
* Se nenhum provider for encontrado ou tokens não forem definidos, retorna undefined.
|
|
2344
|
-
* Os componentes usam este hook para aplicar estilos consistentes via MUI `sx` ou outros mecanismos.
|
|
2345
|
-
*
|
|
2346
|
-
* @returns Os tokens de design atuais ou undefined se não houver provider ou tokens
|
|
2347
|
-
*
|
|
2348
|
-
* @throws {Error} Se usado fora de um DesignProvider (embora não lance erro, retorna undefined)
|
|
2349
|
-
*
|
|
2350
|
-
* @example Acesso a tokens em componente
|
|
2351
|
-
* ```tsx
|
|
2352
|
-
* import { useDesignTokens } from './context/DesignContext';
|
|
2353
|
-
*
|
|
2354
|
-
* function CustomButton() {
|
|
2355
|
-
* const tokens = useDesignTokens();
|
|
2356
|
-
* const primaryColor = tokens?.colors?.primary || '#default';
|
|
2357
|
-
*
|
|
2358
|
-
* return (
|
|
2359
|
-
* <button style={{ backgroundColor: primaryColor }}>
|
|
2360
|
-
* Botão Customizado
|
|
2361
|
-
* </button>
|
|
2362
|
-
* );
|
|
2363
|
-
* }
|
|
2364
|
-
* ```
|
|
2365
|
-
*
|
|
2366
|
-
* @example Uso defensivo com fallbacks
|
|
2367
|
-
* ```tsx
|
|
2368
|
-
* function ThemedComponent() {
|
|
2369
|
-
* const tokens = useDesignTokens();
|
|
2370
|
-
*
|
|
2371
|
-
* return (
|
|
2372
|
-
* <div style={{
|
|
2373
|
-
* color: tokens?.colors?.text || '#333',
|
|
2374
|
-
* fontSize: tokens?.typography?.fontSize || '16px'
|
|
2375
|
-
* }}>
|
|
2376
|
-
* Conteúdo temático
|
|
2377
|
-
* </div>
|
|
2378
|
-
* );
|
|
2581
|
+
*
|
|
2582
|
+
* if (isLoading) return <Skeleton />;
|
|
2583
|
+
* if (!isEnabled) return <ConsentRequired />;
|
|
2584
|
+
*
|
|
2585
|
+
* return <AnalyticsChart />;
|
|
2379
2586
|
* }
|
|
2380
2587
|
* ```
|
|
2381
2588
|
*
|
|
2382
|
-
* @
|
|
2383
|
-
* @category Hooks
|
|
2384
|
-
* @since 0.1.0
|
|
2385
|
-
*/
|
|
2386
|
-
declare function useDesignTokens(): DesignTokens | undefined;
|
|
2387
|
-
|
|
2388
|
-
/**
|
|
2389
|
-
* ConsentGate - renderiza children apenas se houver consentimento para a categoria.
|
|
2390
|
-
*
|
|
2391
|
-
* @remarks
|
|
2392
|
-
* Não usa React.memo pois o estado de preferências muda dinamicamente
|
|
2393
|
-
* e o componente precisa re-renderizar quando as preferências mudam.
|
|
2394
|
-
* A lógica é leve o suficiente para não justificar memoização.
|
|
2395
|
-
*/
|
|
2396
|
-
declare function ConsentGate(props: Readonly<{
|
|
2397
|
-
category: string;
|
|
2398
|
-
children: React$1.ReactNode;
|
|
2399
|
-
}>): react_jsx_runtime.JSX.Element | null;
|
|
2400
|
-
|
|
2401
|
-
/**
|
|
2402
|
-
* @fileoverview
|
|
2403
|
-
* Utilitários para manipulação do cookie de consentimento.
|
|
2404
|
-
* A estrutura de dados do cookie é um JSON simples para atender aos requisitos da LGPD,
|
|
2405
|
-
* e não implementa o padrão IAB TCF, que é mais complexo.
|
|
2406
|
-
* Veja `src/types/types.ts` para a definição da estrutura `ConsentCookieData`.
|
|
2407
|
-
*/
|
|
2408
|
-
|
|
2409
|
-
/**
|
|
2410
|
-
* Gera o nome da chave de armazenamento (cookie/localStorage) combinando namespace e versão.
|
|
2411
|
-
* @param options.namespace Namespace lógico do consentimento (ex.: domínio raiz).
|
|
2412
|
-
* @param options.version Versão atual do consentimento (ex.: lote de políticas).
|
|
2413
|
-
*/
|
|
2414
|
-
declare function buildConsentStorageKey(options?: {
|
|
2415
|
-
namespace?: string | null;
|
|
2416
|
-
version?: string | null;
|
|
2417
|
-
}): string;
|
|
2418
|
-
/**
|
|
2419
|
-
* Cria um registro de auditoria com carimbo de tempo, versão e snapshot das preferências.
|
|
2420
|
-
* @category Utils
|
|
2421
|
-
* @since 0.7.0
|
|
2589
|
+
* @see {@link ConsentProvider} - Para configuração SSR
|
|
2422
2590
|
*
|
|
2423
|
-
* @
|
|
2424
|
-
* @param params.storageKey Chave de armazenamento (cookie/localStorage) aplicada.
|
|
2425
|
-
* @param params.action Ação que disparou o registro.
|
|
2426
|
-
* @param params.consentVersion Versão lógica do consentimento (ex.: bump de política/termo).
|
|
2427
|
-
* @param params.origin Origem explícita da decisão (opcional).
|
|
2428
|
-
*/
|
|
2429
|
-
declare function createConsentAuditEntry(state: ConsentState, params: {
|
|
2430
|
-
storageKey: string;
|
|
2431
|
-
action: ConsentAuditAction;
|
|
2432
|
-
consentVersion?: string | null;
|
|
2433
|
-
origin?: ConsentEventOrigin;
|
|
2434
|
-
}): ConsentAuditEntry;
|
|
2435
|
-
|
|
2436
|
-
/** @module src/utils/scriptLoader */
|
|
2437
|
-
/**
|
|
2438
|
-
* @category Utils
|
|
2591
|
+
* @public
|
|
2439
2592
|
* @since 0.1.0
|
|
2440
|
-
* Utilitários para carregamento dinâmico e seguro de scripts externos no DOM.
|
|
2441
|
-
*
|
|
2442
|
-
* Fornece funções para carregar scripts de terceiros de forma condicional ao consentimento LGPD,
|
|
2443
|
-
* garantindo compatibilidade SSR e verificações de permissões por categoria.
|
|
2444
2593
|
*/
|
|
2445
|
-
|
|
2446
|
-
type ConsentSnapshot = {
|
|
2447
|
-
consented: boolean;
|
|
2448
|
-
preferences: ConsentPreferences;
|
|
2449
|
-
isModalOpen?: boolean;
|
|
2450
|
-
};
|
|
2451
|
-
interface LoadScriptOptions {
|
|
2452
|
-
consentSnapshot?: ConsentSnapshot;
|
|
2453
|
-
cookieName?: string;
|
|
2454
|
-
pollIntervalMs?: number;
|
|
2455
|
-
skipConsentCheck?: boolean;
|
|
2456
|
-
}
|
|
2594
|
+
declare function useConsentHydration(): boolean;
|
|
2457
2595
|
/**
|
|
2458
2596
|
* @function
|
|
2459
|
-
* @category
|
|
2460
|
-
* @since 0.1
|
|
2461
|
-
*
|
|
2597
|
+
* @category Hooks
|
|
2598
|
+
* @since 0.3.1
|
|
2599
|
+
* Hook para abrir o modal de preferências programaticamente.
|
|
2600
|
+
*
|
|
2601
|
+
* @returns Função para abrir o modal de preferências.
|
|
2462
2602
|
*
|
|
2463
2603
|
* @remarks
|
|
2464
|
-
*
|
|
2465
|
-
*
|
|
2466
|
-
*
|
|
2604
|
+
* Este hook retorna uma função que pode ser usada para abrir o modal de preferências
|
|
2605
|
+
* de qualquer lugar dentro do contexto do ConsentProvider. É útil para criar botões
|
|
2606
|
+
* customizados ou trigger o modal baseado em eventos específicos.
|
|
2467
2607
|
*
|
|
2468
|
-
*
|
|
2469
|
-
* em carregamento para evitar duplicações durante double-invoking de efeitos em desenvolvimento.
|
|
2608
|
+
* @throws {Error} Se usado fora do ConsentProvider
|
|
2470
2609
|
*
|
|
2471
|
-
* @param {string} id Um identificador único para o elemento `<script>` a ser criado.
|
|
2472
|
-
* @param {string} src A URL do script externo a ser carregado.
|
|
2473
|
-
* @param {string | null} [category=null] A categoria de consentimento exigida para o script. Suporta tanto categorias predefinidas quanto customizadas. Se o consentimento para esta categoria não for dado, o script não será carregado.
|
|
2474
|
-
* @param {Record<string, string>} [attrs={}] Atributos adicionais a serem aplicados ao elemento `<script>` (ex: `{ async: 'true' }`).
|
|
2475
|
-
* @param {string | undefined} [nonce] Nonce CSP opcional aplicado ao script.
|
|
2476
|
-
* @param {LoadScriptOptions} [options] Configurações avançadas (consentSnapshot, cookieName, pollIntervalMs, skipConsentCheck).
|
|
2477
|
-
* @returns {Promise<void>} Uma Promise que resolve quando o script é carregado com sucesso, ou rejeita se o consentimento não for dado ou ocorrer um erro de carregamento.
|
|
2478
2610
|
* @example
|
|
2479
|
-
* ```
|
|
2480
|
-
*
|
|
2481
|
-
*
|
|
2482
|
-
*
|
|
2483
|
-
*
|
|
2611
|
+
* ```tsx
|
|
2612
|
+
* function CustomButton() {
|
|
2613
|
+
* const openPreferences = useOpenPreferencesModal();
|
|
2614
|
+
*
|
|
2615
|
+
* return (
|
|
2616
|
+
* <button onClick={openPreferences}>
|
|
2617
|
+
* Configurar Cookies
|
|
2618
|
+
* </button>
|
|
2619
|
+
* );
|
|
2620
|
+
* }
|
|
2484
2621
|
* ```
|
|
2485
2622
|
*/
|
|
2486
|
-
declare function
|
|
2487
|
-
|
|
2623
|
+
declare function useOpenPreferencesModal(): () => void;
|
|
2488
2624
|
/**
|
|
2489
|
-
*
|
|
2490
|
-
*
|
|
2491
|
-
* Fornece funções para detectar cookies presentes no navegador, identificar o cookie de consentimento
|
|
2492
|
-
* e atribuir cookies descobertos a categorias LGPD usando heurísticas baseadas em padrões conhecidos.
|
|
2493
|
-
*
|
|
2625
|
+
* @function
|
|
2494
2626
|
* @category Utils
|
|
2495
|
-
* @since 0.
|
|
2496
|
-
*
|
|
2497
|
-
* Recomenda-se uso em desenvolvimento para inspeção manual e merge com catálogo existente.
|
|
2498
|
-
*/
|
|
2499
|
-
|
|
2500
|
-
/**
|
|
2501
|
-
* Descobre cookies em tempo de execução no navegador (experimental).
|
|
2502
|
-
*
|
|
2503
|
-
* - Lê `document.cookie` com segurança (SSR-safe)
|
|
2504
|
-
* - Retorna lista de cookies detectados (apenas nomes)
|
|
2505
|
-
* - Salva em `globalThis.__LGPD_DISCOVERED_COOKIES__` para inspeção/manual merge
|
|
2627
|
+
* @since 0.3.1
|
|
2628
|
+
* Função global para abrir o modal de preferências de fora do contexto React.
|
|
2506
2629
|
*
|
|
2507
|
-
* @
|
|
2508
|
-
*
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
/**
|
|
2512
|
-
* Tenta detectar o nome do cookie de consentimento pela estrutura JSON armazenada.
|
|
2513
|
-
* Retorna o nome se for encontrado, caso contrário `null`.
|
|
2514
|
-
* @category Utils
|
|
2515
|
-
* @since 0.4.1
|
|
2516
|
-
*/
|
|
2517
|
-
declare function detectConsentCookieName(): string | null;
|
|
2518
|
-
/**
|
|
2519
|
-
* Heurística simples para atribuir cookies descobertos a categorias LGPD (experimental).
|
|
2630
|
+
* @remarks
|
|
2631
|
+
* Esta função permite abrir o modal de preferências de código JavaScript puro,
|
|
2632
|
+
* sem precisar estar dentro do contexto React. É útil para integração com
|
|
2633
|
+
* código legado ou bibliotecas de terceiros.
|
|
2520
2634
|
*
|
|
2521
|
-
*
|
|
2522
|
-
*
|
|
2523
|
-
* - Pode opcionalmente registrar overrides de catálogo por categoria
|
|
2635
|
+
* A função é automaticamente registrada pelo ConsentProvider e limpa quando
|
|
2636
|
+
* o provider é desmontado.
|
|
2524
2637
|
*
|
|
2525
|
-
* @
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2528
|
-
*
|
|
2529
|
-
* @since 0.4.1
|
|
2530
|
-
*/
|
|
2531
|
-
declare function categorizeDiscoveredCookies(discovered?: CookieDescriptor[], registerOverrides?: boolean): Record<Category, CookieDescriptor[]>;
|
|
2532
|
-
|
|
2533
|
-
/**
|
|
2534
|
-
* @fileoverview
|
|
2535
|
-
* Integrações nativas de scripts (GA, GTM, Facebook Pixel, Hotjar, Mixpanel, Clarity, Intercom, Zendesk, UserWay)
|
|
2536
|
-
* com categorias LGPD padrão, cookies típicos e pontos de extensão para URLs.
|
|
2638
|
+
* @example
|
|
2639
|
+
* ```javascript
|
|
2640
|
+
* // Em código JavaScript puro
|
|
2641
|
+
* globalThis.window?.openPreferencesModal?.();
|
|
2537
2642
|
*
|
|
2538
|
-
*
|
|
2539
|
-
*
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2542
|
-
* - SSR-safe: toda execução que toca `window` é protegida
|
|
2643
|
+
* // Ou importando diretamente
|
|
2644
|
+
* import { openPreferencesModal } from 'react-lgpd-consent';
|
|
2645
|
+
* openPreferencesModal();
|
|
2646
|
+
* ```
|
|
2543
2647
|
*/
|
|
2648
|
+
declare function openPreferencesModal(): void;
|
|
2544
2649
|
|
|
2545
2650
|
/**
|
|
2546
|
-
*
|
|
2547
|
-
*
|
|
2548
|
-
* @category Utils
|
|
2549
|
-
* @since 0.2.0
|
|
2550
|
-
*
|
|
2551
|
-
* @remarks
|
|
2552
|
-
* **Breaking Change em v0.4.1**: O campo `category` mudou de `Category` para `string`
|
|
2553
|
-
* para suportar categorias customizadas. Código existente usando strings literais
|
|
2554
|
-
* continua funcionando sem alterações.
|
|
2555
|
-
*
|
|
2556
|
-
* @example
|
|
2557
|
-
* ```typescript
|
|
2558
|
-
* const integration: ScriptIntegration = {
|
|
2559
|
-
* id: 'my-script',
|
|
2560
|
-
* category: 'analytics',
|
|
2561
|
-
* src: 'https://example.com/script.js',
|
|
2562
|
-
* cookies: ['_example'],
|
|
2563
|
-
* init: () => console.log('Script initialized')
|
|
2564
|
-
* }
|
|
2565
|
-
* ```
|
|
2651
|
+
* @interface CategoriesContextValue
|
|
2652
|
+
* O valor fornecido pelo `CategoriesContext`, contendo informações sobre as categorias de cookies ativas no projeto.
|
|
2566
2653
|
*/
|
|
2567
|
-
interface
|
|
2568
|
-
/**
|
|
2569
|
-
|
|
2570
|
-
/**
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
name?: string;
|
|
2577
|
-
/** URL do script a ser carregado */
|
|
2578
|
-
src: string;
|
|
2579
|
-
/** Se o script deve ser carregado de forma assíncrona */
|
|
2580
|
-
async?: boolean;
|
|
2581
|
-
/** Se o script deve ser deferido */
|
|
2582
|
-
defer?: boolean;
|
|
2583
|
-
/** Configuração específica da integração */
|
|
2584
|
-
config?: Record<string, unknown>;
|
|
2585
|
-
/** Função de inicialização executada após carregamento do script */
|
|
2586
|
-
init?: () => void;
|
|
2587
|
-
/** Atributos HTML adicionais para a tag script */
|
|
2588
|
-
attrs?: Record<string, string>;
|
|
2589
|
-
/** Nonce CSP opcional aplicado à tag script */
|
|
2590
|
-
nonce?: string;
|
|
2591
|
-
/** Prioridade para ordenação na fila do loader (maior = executa primeiro dentro da categoria) */
|
|
2592
|
-
priority?: number;
|
|
2593
|
-
/** Rotina opcional executada antes do carregamento principal (ex.: bootstrap de Consent Mode) */
|
|
2594
|
-
bootstrap?: () => void | Promise<void>;
|
|
2595
|
-
/** Callback disparado quando o consentimento é atualizado */
|
|
2596
|
-
onConsentUpdate?: (consent: {
|
|
2597
|
-
consented: boolean;
|
|
2598
|
-
preferences: ConsentPreferences;
|
|
2599
|
-
}) => void;
|
|
2600
|
-
/** Lista de cookies que o script pode definir */
|
|
2601
|
-
cookies?: string[];
|
|
2602
|
-
/** Informações detalhadas dos cookies (nome, finalidade, duração, fornecedor) */
|
|
2603
|
-
cookiesInfo?: Array<{
|
|
2604
|
-
name: string;
|
|
2605
|
-
purpose: string;
|
|
2606
|
-
duration: string;
|
|
2607
|
-
provider: string;
|
|
2608
|
-
}>;
|
|
2654
|
+
interface CategoriesContextValue {
|
|
2655
|
+
/** A configuração final das categorias, incluindo padrões aplicados. */
|
|
2656
|
+
config: ProjectCategoriesConfig;
|
|
2657
|
+
/** Análise e orientações para desenvolvedores, incluindo avisos e sugestões. */
|
|
2658
|
+
guidance: DeveloperGuidance;
|
|
2659
|
+
/** Um array de categorias que requerem um toggle na UI de preferências (não essenciais). */
|
|
2660
|
+
toggleableCategories: DeveloperGuidance['activeCategoriesInfo'];
|
|
2661
|
+
/** Um array contendo todas as categorias ativas no projeto (essenciais e não essenciais). */
|
|
2662
|
+
allCategories: DeveloperGuidance['activeCategoriesInfo'];
|
|
2609
2663
|
}
|
|
2610
2664
|
/**
|
|
2611
|
-
*
|
|
2665
|
+
* @hook
|
|
2666
|
+
* @category Hooks
|
|
2667
|
+
* @since 0.2.2
|
|
2668
|
+
* Hook para acessar informações sobre as categorias de cookies ativas no projeto.
|
|
2612
2669
|
*
|
|
2613
|
-
* @
|
|
2614
|
-
*
|
|
2670
|
+
* @remarks
|
|
2671
|
+
* Este hook deve ser usado dentro do `ConsentProvider` (que internamente renderiza o `CategoriesProvider`).
|
|
2672
|
+
* Ele é útil para construir componentes de UI customizados que precisam se adaptar dinamicamente às categorias configuradas.
|
|
2673
|
+
*
|
|
2674
|
+
* @returns {CategoriesContextValue} Um objeto contendo a configuração, orientações e listas de categorias.
|
|
2675
|
+
*
|
|
2676
|
+
* @throws {Error} Se usado fora do `CategoriesProvider`.
|
|
2677
|
+
*/
|
|
2678
|
+
declare function useCategories(): CategoriesContextValue;
|
|
2679
|
+
/**
|
|
2680
|
+
* @hook
|
|
2681
|
+
* @category Hooks
|
|
2682
|
+
* @since 0.2.2
|
|
2683
|
+
* Hook de conveniência para verificar o status de uma categoria de cookie específica.
|
|
2615
2684
|
*
|
|
2685
|
+
* @param {string} categoryId O ID da categoria a ser verificada (ex: 'analytics', 'necessary').
|
|
2686
|
+
* @returns {object} Um objeto com o status da categoria:
|
|
2687
|
+
* - `isActive`: `true` se a categoria está configurada e ativa no projeto.
|
|
2688
|
+
* - `isEssential`: `true` se a categoria é essencial (não pode ser desativada pelo usuário).
|
|
2689
|
+
* - `needsToggle`: `true` se a categoria requer um controle (switch) na UI de preferências.
|
|
2690
|
+
* - `name`: O nome amigável da categoria.
|
|
2691
|
+
* - `description`: A descrição da categoria.
|
|
2616
2692
|
* @example
|
|
2617
|
-
* ```
|
|
2618
|
-
* const
|
|
2619
|
-
*
|
|
2620
|
-
*
|
|
2693
|
+
* ```tsx
|
|
2694
|
+
* const analyticsStatus = useCategoryStatus('analytics')
|
|
2695
|
+
* if (analyticsStatus.isActive && analyticsStatus.needsToggle) {
|
|
2696
|
+
* // Renderizar switch para analytics
|
|
2621
2697
|
* }
|
|
2622
2698
|
* ```
|
|
2623
2699
|
*/
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2700
|
+
declare function useCategoryStatus(categoryId: string): {
|
|
2701
|
+
isActive: boolean;
|
|
2702
|
+
isEssential: boolean;
|
|
2703
|
+
needsToggle: boolean;
|
|
2704
|
+
name: string | undefined;
|
|
2705
|
+
description: string | undefined;
|
|
2706
|
+
};
|
|
2707
|
+
|
|
2632
2708
|
/**
|
|
2633
|
-
*
|
|
2709
|
+
* Provider que envolve a árvore de componentes para fornecer tokens de design via contexto.
|
|
2634
2710
|
*
|
|
2635
|
-
* @
|
|
2636
|
-
*
|
|
2711
|
+
* @remarks
|
|
2712
|
+
* Use este provider no topo da aplicação ou seção onde os componentes de consentimento
|
|
2713
|
+
* precisam acessar tokens de design. Permite overrides globais de design sem alterar
|
|
2714
|
+
* os componentes individuais, mantendo tree-shaking e performance.
|
|
2637
2715
|
*
|
|
2638
|
-
* @
|
|
2639
|
-
*
|
|
2640
|
-
*
|
|
2641
|
-
*
|
|
2642
|
-
*
|
|
2716
|
+
* @param tokens - Tokens de design opcionais para customização (cores, layouts, etc.)
|
|
2717
|
+
* @param children - Componentes filhos que terão acesso aos tokens via contexto
|
|
2718
|
+
*
|
|
2719
|
+
* @example Uso básico com tokens padrão
|
|
2720
|
+
* ```tsx
|
|
2721
|
+
* import { DesignProvider } from './context/DesignContext';
|
|
2722
|
+
*
|
|
2723
|
+
* function App() {
|
|
2724
|
+
* return (
|
|
2725
|
+
* <DesignProvider>
|
|
2726
|
+
* <CookieBanner />
|
|
2727
|
+
* </DesignProvider>
|
|
2728
|
+
* );
|
|
2643
2729
|
* }
|
|
2644
2730
|
* ```
|
|
2645
|
-
*/
|
|
2646
|
-
interface GoogleTagManagerConfig {
|
|
2647
|
-
/** ID do container GTM (formato: GTM-XXXXXXX) */
|
|
2648
|
-
containerId: string;
|
|
2649
|
-
/** Nome customizado para o dataLayer. Padrão: 'dataLayer' */
|
|
2650
|
-
dataLayerName?: string;
|
|
2651
|
-
/** URL do script GTM. Se omitido usa o padrão oficial. */
|
|
2652
|
-
scriptUrl?: string;
|
|
2653
|
-
}
|
|
2654
|
-
/**
|
|
2655
|
-
* Configuração para integração do UserWay (Acessibilidade).
|
|
2656
2731
|
*
|
|
2657
|
-
* @
|
|
2658
|
-
*
|
|
2732
|
+
* @example Customização de cores
|
|
2733
|
+
* ```tsx
|
|
2734
|
+
* const customTokens = {
|
|
2735
|
+
* colors: {
|
|
2736
|
+
* primary: '#ff0000',
|
|
2737
|
+
* secondary: '#00ff00'
|
|
2738
|
+
* }
|
|
2739
|
+
* };
|
|
2659
2740
|
*
|
|
2660
|
-
*
|
|
2661
|
-
*
|
|
2662
|
-
*
|
|
2663
|
-
*
|
|
2741
|
+
* function App() {
|
|
2742
|
+
* return (
|
|
2743
|
+
* <DesignProvider tokens={customTokens}>
|
|
2744
|
+
* <PreferencesModal />
|
|
2745
|
+
* </DesignProvider>
|
|
2746
|
+
* );
|
|
2664
2747
|
* }
|
|
2665
2748
|
* ```
|
|
2749
|
+
*
|
|
2750
|
+
*
|
|
2751
|
+
* @component
|
|
2752
|
+
* @category Context
|
|
2753
|
+
* @since 0.1.0
|
|
2666
2754
|
*/
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
scriptUrl?: string;
|
|
2672
|
-
}
|
|
2755
|
+
declare function DesignProvider({ tokens, children, }: Readonly<{
|
|
2756
|
+
tokens?: DesignTokens;
|
|
2757
|
+
children: React$1.ReactNode;
|
|
2758
|
+
}>): react_jsx_runtime.JSX.Element;
|
|
2673
2759
|
/**
|
|
2674
|
-
*
|
|
2675
|
-
* Configura o gtag e inicializa o tracking com o measurement ID fornecido.
|
|
2760
|
+
* Hook para acessar os tokens de design do contexto atual.
|
|
2676
2761
|
*
|
|
2677
|
-
* @
|
|
2678
|
-
*
|
|
2679
|
-
*
|
|
2680
|
-
*
|
|
2762
|
+
* @remarks
|
|
2763
|
+
* Retorna os tokens de design fornecidos pelo DesignProvider mais próximo na árvore de componentes.
|
|
2764
|
+
* Se nenhum provider for encontrado ou tokens não forem definidos, retorna undefined.
|
|
2765
|
+
* Os componentes usam este hook para aplicar estilos consistentes via MUI `sx` ou outros mecanismos.
|
|
2681
2766
|
*
|
|
2682
|
-
* @
|
|
2683
|
-
*
|
|
2684
|
-
*
|
|
2685
|
-
*
|
|
2686
|
-
*
|
|
2687
|
-
*
|
|
2767
|
+
* @returns Os tokens de design atuais ou undefined se não houver provider ou tokens
|
|
2768
|
+
*
|
|
2769
|
+
* @throws {Error} Se usado fora de um DesignProvider (embora não lance erro, retorna undefined)
|
|
2770
|
+
*
|
|
2771
|
+
* @example Acesso a tokens em componente
|
|
2772
|
+
* ```tsx
|
|
2773
|
+
* import { useDesignTokens } from './context/DesignContext';
|
|
2774
|
+
*
|
|
2775
|
+
* function CustomButton() {
|
|
2776
|
+
* const tokens = useDesignTokens();
|
|
2777
|
+
* const primaryColor = tokens?.colors?.primary || '#default';
|
|
2778
|
+
*
|
|
2779
|
+
* return (
|
|
2780
|
+
* <button style={{ backgroundColor: primaryColor }}>
|
|
2781
|
+
* Botão Customizado
|
|
2782
|
+
* </button>
|
|
2783
|
+
* );
|
|
2784
|
+
* }
|
|
2785
|
+
* ```
|
|
2786
|
+
*
|
|
2787
|
+
* @example Uso defensivo com fallbacks
|
|
2788
|
+
* ```tsx
|
|
2789
|
+
* function ThemedComponent() {
|
|
2790
|
+
* const tokens = useDesignTokens();
|
|
2791
|
+
*
|
|
2792
|
+
* return (
|
|
2793
|
+
* <div style={{
|
|
2794
|
+
* color: tokens?.colors?.text || '#333',
|
|
2795
|
+
* fontSize: tokens?.typography?.fontSize || '16px'
|
|
2796
|
+
* }}>
|
|
2797
|
+
* Conteúdo temático
|
|
2798
|
+
* </div>
|
|
2799
|
+
* );
|
|
2800
|
+
* }
|
|
2688
2801
|
* ```
|
|
2689
2802
|
*
|
|
2803
|
+
* @hook
|
|
2804
|
+
* @category Hooks
|
|
2805
|
+
* @since 0.1.0
|
|
2806
|
+
*/
|
|
2807
|
+
declare function useDesignTokens(): DesignTokens | undefined;
|
|
2808
|
+
|
|
2809
|
+
/**
|
|
2810
|
+
* ConsentGate - renderiza children apenas se houver consentimento para a categoria.
|
|
2811
|
+
*
|
|
2690
2812
|
* @remarks
|
|
2691
|
-
*
|
|
2692
|
-
* -
|
|
2693
|
-
*
|
|
2813
|
+
* Não usa React.memo pois o estado de preferências muda dinamicamente
|
|
2814
|
+
* e o componente precisa re-renderizar quando as preferências mudam.
|
|
2815
|
+
* A lógica é leve o suficiente para não justificar memoização.
|
|
2694
2816
|
*/
|
|
2695
|
-
declare function
|
|
2817
|
+
declare function ConsentGate(props: Readonly<{
|
|
2818
|
+
category: string;
|
|
2819
|
+
children: React$1.ReactNode;
|
|
2820
|
+
}>): react_jsx_runtime.JSX.Element | null;
|
|
2821
|
+
|
|
2696
2822
|
/**
|
|
2697
|
-
*
|
|
2698
|
-
*
|
|
2823
|
+
* @fileoverview
|
|
2824
|
+
* Utilitários para manipulação do cookie de consentimento.
|
|
2825
|
+
* A estrutura de dados do cookie é um JSON simples para atender aos requisitos da LGPD,
|
|
2826
|
+
* e não implementa o padrão IAB TCF, que é mais complexo.
|
|
2827
|
+
* Veja `src/types/types.ts` para a definição da estrutura `ConsentCookieData`.
|
|
2828
|
+
*/
|
|
2829
|
+
|
|
2830
|
+
/**
|
|
2831
|
+
* Gera o nome da chave de armazenamento (cookie/localStorage) combinando namespace e versão.
|
|
2832
|
+
* @param options.namespace Namespace lógico do consentimento (ex.: domínio raiz).
|
|
2833
|
+
* @param options.version Versão atual do consentimento (ex.: lote de políticas).
|
|
2834
|
+
*/
|
|
2835
|
+
declare function buildConsentStorageKey(options?: {
|
|
2836
|
+
namespace?: string | null;
|
|
2837
|
+
version?: string | null;
|
|
2838
|
+
}): string;
|
|
2839
|
+
/**
|
|
2840
|
+
* Cria um registro de auditoria com carimbo de tempo, versão e snapshot das preferências.
|
|
2841
|
+
* @category Utils
|
|
2842
|
+
* @since 0.7.0
|
|
2699
2843
|
*
|
|
2844
|
+
* @param state Estado atual de consentimento.
|
|
2845
|
+
* @param params.storageKey Chave de armazenamento (cookie/localStorage) aplicada.
|
|
2846
|
+
* @param params.action Ação que disparou o registro.
|
|
2847
|
+
* @param params.consentVersion Versão lógica do consentimento (ex.: bump de política/termo).
|
|
2848
|
+
* @param params.origin Origem explícita da decisão (opcional).
|
|
2849
|
+
*/
|
|
2850
|
+
declare function createConsentAuditEntry(state: ConsentState, params: {
|
|
2851
|
+
storageKey: string;
|
|
2852
|
+
action: ConsentAuditAction;
|
|
2853
|
+
consentVersion?: string | null;
|
|
2854
|
+
origin?: ConsentEventOrigin;
|
|
2855
|
+
}): ConsentAuditEntry;
|
|
2856
|
+
|
|
2857
|
+
/** @module src/utils/scriptLoader */
|
|
2858
|
+
/**
|
|
2700
2859
|
* @category Utils
|
|
2701
|
-
* @
|
|
2702
|
-
*
|
|
2703
|
-
* @since 0.2.0
|
|
2860
|
+
* @since 0.1.0
|
|
2861
|
+
* Utilitários para carregamento dinâmico e seguro de scripts externos no DOM.
|
|
2704
2862
|
*
|
|
2705
|
-
*
|
|
2706
|
-
*
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2863
|
+
* Fornece funções para carregar scripts de terceiros de forma condicional ao consentimento LGPD,
|
|
2864
|
+
* garantindo compatibilidade SSR e verificações de permissões por categoria.
|
|
2865
|
+
*/
|
|
2866
|
+
|
|
2867
|
+
type ConsentSnapshot = {
|
|
2868
|
+
consented: boolean;
|
|
2869
|
+
preferences: ConsentPreferences;
|
|
2870
|
+
isModalOpen?: boolean;
|
|
2871
|
+
};
|
|
2872
|
+
interface LoadScriptOptions {
|
|
2873
|
+
consentSnapshot?: ConsentSnapshot;
|
|
2874
|
+
cookieName?: string;
|
|
2875
|
+
pollIntervalMs?: number;
|
|
2876
|
+
skipConsentCheck?: boolean;
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* @function
|
|
2880
|
+
* @category Utils
|
|
2881
|
+
* @since 0.1.0
|
|
2882
|
+
* Carrega dinamicamente um script externo no DOM.
|
|
2712
2883
|
*
|
|
2713
2884
|
* @remarks
|
|
2714
|
-
*
|
|
2715
|
-
*
|
|
2716
|
-
*
|
|
2717
|
-
*/
|
|
2718
|
-
declare function createGoogleTagManagerIntegration(config: GoogleTagManagerConfig): ScriptIntegration;
|
|
2719
|
-
/**
|
|
2720
|
-
* Cria integração do UserWay (Acessibilidade).
|
|
2721
|
-
* Configura o widget de acessibilidade UserWay.
|
|
2885
|
+
* Esta função é utilizada internamente pela biblioteca para carregar scripts de integração
|
|
2886
|
+
* após o consentimento do usuário. Ela garante que o script só seja inserido na página
|
|
2887
|
+
* se o consentimento for dado e o contexto estiver disponível.
|
|
2722
2888
|
*
|
|
2723
|
-
*
|
|
2724
|
-
*
|
|
2725
|
-
* @returns Integração configurada para o UserWay
|
|
2726
|
-
* @since 0.2.0
|
|
2889
|
+
* **React 19 StrictMode**: A função é idempotente e mantém um registro global de scripts
|
|
2890
|
+
* em carregamento para evitar duplicações durante double-invoking de efeitos em desenvolvimento.
|
|
2727
2891
|
*
|
|
2892
|
+
* @param {string} id Um identificador único para o elemento `<script>` a ser criado.
|
|
2893
|
+
* @param {string} src A URL do script externo a ser carregado.
|
|
2894
|
+
* @param {string | null} [category=null] A categoria de consentimento exigida para o script. Suporta tanto categorias predefinidas quanto customizadas. Se o consentimento para esta categoria não for dado, o script não será carregado.
|
|
2895
|
+
* @param {Record<string, string>} [attrs={}] Atributos adicionais a serem aplicados ao elemento `<script>` (ex: `{ async: 'true' }`).
|
|
2896
|
+
* @param {string | undefined} [nonce] Nonce CSP opcional aplicado ao script.
|
|
2897
|
+
* @param {LoadScriptOptions} [options] Configurações avançadas (consentSnapshot, cookieName, pollIntervalMs, skipConsentCheck).
|
|
2898
|
+
* @returns {Promise<void>} Uma Promise que resolve quando o script é carregado com sucesso, ou rejeita se o consentimento não for dado ou ocorrer um erro de carregamento.
|
|
2728
2899
|
* @example
|
|
2729
|
-
* ```
|
|
2730
|
-
*
|
|
2731
|
-
*
|
|
2732
|
-
*
|
|
2900
|
+
* ```ts
|
|
2901
|
+
* // Carregar um script de analytics após o consentimento
|
|
2902
|
+
* loadScript('my-analytics-script', 'https://example.com/analytics.js', 'analytics')
|
|
2903
|
+
* .then(() => console.log('Script de analytics carregado!'))
|
|
2904
|
+
* .catch(error => console.error('Erro ao carregar script:', error))
|
|
2733
2905
|
* ```
|
|
2734
|
-
*
|
|
2735
|
-
* @remarks
|
|
2736
|
-
* - Define cookies: _userway_*
|
|
2737
|
-
* - Categoria padrão: 'functional'
|
|
2738
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2739
2906
|
*/
|
|
2740
|
-
declare function
|
|
2907
|
+
declare function loadScript(id: string, src: string, category?: string | null, attrs?: Record<string, string>, nonce?: string, options?: LoadScriptOptions): Promise<void>;
|
|
2908
|
+
|
|
2741
2909
|
/**
|
|
2742
|
-
*
|
|
2743
|
-
* Fornece acesso direto às funções de criação de integrações pré-configuradas.
|
|
2910
|
+
* Utilitários para descoberta e categorização de cookies em tempo de execução (experimental).
|
|
2744
2911
|
*
|
|
2745
|
-
*
|
|
2746
|
-
*
|
|
2912
|
+
* Fornece funções para detectar cookies presentes no navegador, identificar o cookie de consentimento
|
|
2913
|
+
* e atribuir cookies descobertos a categorias LGPD usando heurísticas baseadas em padrões conhecidos.
|
|
2747
2914
|
*
|
|
2748
|
-
* @
|
|
2749
|
-
*
|
|
2750
|
-
*
|
|
2751
|
-
*
|
|
2915
|
+
* @category Utils
|
|
2916
|
+
* @since 0.4.1
|
|
2917
|
+
* @remarks Funcionalidades experimentais para auxiliar no mapeamento de cookies em conformidade com LGPD.
|
|
2918
|
+
* Recomenda-se uso em desenvolvimento para inspeção manual e merge com catálogo existente.
|
|
2752
2919
|
*/
|
|
2753
|
-
|
|
2754
|
-
googleAnalytics: typeof createGoogleAnalyticsIntegration;
|
|
2755
|
-
googleTagManager: typeof createGoogleTagManagerIntegration;
|
|
2756
|
-
userway: typeof createUserWayIntegration;
|
|
2757
|
-
};
|
|
2920
|
+
|
|
2758
2921
|
/**
|
|
2759
|
-
*
|
|
2922
|
+
* Descobre cookies em tempo de execução no navegador (experimental).
|
|
2923
|
+
*
|
|
2924
|
+
* - Lê `document.cookie` com segurança (SSR-safe)
|
|
2925
|
+
* - Retorna lista de cookies detectados (apenas nomes)
|
|
2926
|
+
* - Salva em `globalThis.__LGPD_DISCOVERED_COOKIES__` para inspeção/manual merge
|
|
2760
2927
|
*
|
|
2761
2928
|
* @category Utils
|
|
2762
2929
|
* @since 0.4.1
|
|
2763
|
-
*
|
|
2764
|
-
* @example
|
|
2765
|
-
* ```typescript
|
|
2766
|
-
* const config: FacebookPixelConfig = {
|
|
2767
|
-
* pixelId: '1234567890123456',
|
|
2768
|
-
* autoTrack: true,
|
|
2769
|
-
* advancedMatching: { email: 'user@example.com' }
|
|
2770
|
-
* }
|
|
2771
|
-
* ```
|
|
2772
2930
|
*/
|
|
2773
|
-
|
|
2774
|
-
/** ID do pixel do Facebook */
|
|
2775
|
-
pixelId: string;
|
|
2776
|
-
/** Se deve rastrear PageView automaticamente. Padrão: true */
|
|
2777
|
-
autoTrack?: boolean;
|
|
2778
|
-
/** Configuração de correspondência avançada */
|
|
2779
|
-
advancedMatching?: Record<string, unknown>;
|
|
2780
|
-
/** URL do script do Pixel. Se omitido usa o padrão oficial. */
|
|
2781
|
-
scriptUrl?: string;
|
|
2782
|
-
}
|
|
2931
|
+
declare function discoverRuntimeCookies(): CookieDescriptor[];
|
|
2783
2932
|
/**
|
|
2784
|
-
*
|
|
2933
|
+
* Tenta detectar o nome do cookie de consentimento LGPD presente no navegador.
|
|
2934
|
+
*
|
|
2935
|
+
* - Percorre todos os cookies disponíveis em `document.cookie`.
|
|
2936
|
+
* - Decodifica o valor e verifica se corresponde à estrutura JSON esperada de consentimento.
|
|
2937
|
+
* - Retorna o nome do cookie se encontrado, ou `null` se não houver nenhum compatível.
|
|
2785
2938
|
*
|
|
2939
|
+
* @returns Nome do cookie de consentimento ou `null` se não encontrado
|
|
2786
2940
|
* @category Utils
|
|
2787
2941
|
* @since 0.4.1
|
|
2788
|
-
*
|
|
2789
2942
|
* @example
|
|
2790
|
-
* ```
|
|
2791
|
-
* const
|
|
2792
|
-
*
|
|
2793
|
-
*
|
|
2794
|
-
* debug: false
|
|
2943
|
+
* ```ts
|
|
2944
|
+
* const consentCookie = detectConsentCookieName()
|
|
2945
|
+
* if (consentCookie) {
|
|
2946
|
+
* console.log('Cookie de consentimento encontrado:', consentCookie)
|
|
2795
2947
|
* }
|
|
2796
2948
|
* ```
|
|
2949
|
+
* @remarks SSR-safe: retorna `null` se executado fora do browser.
|
|
2797
2950
|
*/
|
|
2798
|
-
|
|
2799
|
-
/** ID do site no Hotjar */
|
|
2800
|
-
siteId: string;
|
|
2801
|
-
/** Versão do script Hotjar. Padrão: 6 */
|
|
2802
|
-
version?: number;
|
|
2803
|
-
/** Ativar modo debug. Padrão: false */
|
|
2804
|
-
debug?: boolean;
|
|
2805
|
-
/** URL do script Hotjar. Se omitido usa o padrão oficial. */
|
|
2806
|
-
scriptUrl?: string;
|
|
2807
|
-
}
|
|
2951
|
+
declare function detectConsentCookieName(): string | null;
|
|
2808
2952
|
/**
|
|
2809
|
-
*
|
|
2953
|
+
* Heurística simples para atribuir cookies descobertos a categorias LGPD (experimental).
|
|
2954
|
+
*
|
|
2955
|
+
* - Usa padrões conhecidos por categoria
|
|
2956
|
+
* - Ignora `cookieConsent` (já tratado como necessary)
|
|
2957
|
+
* - Pode opcionalmente registrar overrides de catálogo por categoria
|
|
2810
2958
|
*
|
|
2959
|
+
* @param discovered Lista de cookies descobertos (opcional: usa global se ausente)
|
|
2960
|
+
* @param registerOverrides Se `true`, registra em `setCookieCatalogOverrides`
|
|
2961
|
+
* @returns Mapa categoria -> descritores atribuídos
|
|
2811
2962
|
* @category Utils
|
|
2812
2963
|
* @since 0.4.1
|
|
2964
|
+
*/
|
|
2965
|
+
declare function categorizeDiscoveredCookies(discovered?: CookieDescriptor[], registerOverrides?: boolean): Record<Category, CookieDescriptor[]>;
|
|
2966
|
+
|
|
2967
|
+
/**
|
|
2968
|
+
* @fileoverview
|
|
2969
|
+
* Integrações nativas de scripts (GA, GTM, Facebook Pixel, Hotjar, Mixpanel, Clarity, Intercom, Zendesk, UserWay)
|
|
2970
|
+
* com categorias LGPD padrão, cookies típicos e pontos de extensão para URLs.
|
|
2813
2971
|
*
|
|
2814
|
-
*
|
|
2815
|
-
*
|
|
2816
|
-
*
|
|
2817
|
-
*
|
|
2818
|
-
*
|
|
2819
|
-
* api_host: 'https://api.mixpanel.com'
|
|
2820
|
-
* }
|
|
2821
|
-
* ```
|
|
2972
|
+
* Princípios:
|
|
2973
|
+
* - Cada integração define uma categoria padrão (mais aderente ao uso no mercado)
|
|
2974
|
+
* - Cada cookie típico aparece em uma única categoria por padrão
|
|
2975
|
+
* - URLs possuem valores default atualizados e podem ser sobrescritos via `scriptUrl`
|
|
2976
|
+
* - SSR-safe: toda execução que toca `window` é protegida
|
|
2822
2977
|
*/
|
|
2823
|
-
|
|
2824
|
-
/** Token do projeto Mixpanel */
|
|
2825
|
-
token: string;
|
|
2826
|
-
/** Configurações adicionais do Mixpanel */
|
|
2827
|
-
config?: Record<string, unknown>;
|
|
2828
|
-
/** Host customizado da API Mixpanel */
|
|
2829
|
-
api_host?: string;
|
|
2830
|
-
/** URL do script Mixpanel. Se omitido usa o padrão oficial. */
|
|
2831
|
-
scriptUrl?: string;
|
|
2832
|
-
}
|
|
2978
|
+
|
|
2833
2979
|
/**
|
|
2834
|
-
*
|
|
2980
|
+
* Integração de script de terceiros condicionada a consentimento.
|
|
2835
2981
|
*
|
|
2836
2982
|
* @category Utils
|
|
2837
|
-
* @since 0.
|
|
2983
|
+
* @since 0.2.0
|
|
2984
|
+
*
|
|
2985
|
+
* @remarks
|
|
2986
|
+
* **Breaking Change em v0.4.1**: O campo `category` mudou de `Category` para `string`
|
|
2987
|
+
* para suportar categorias customizadas. Código existente usando strings literais
|
|
2988
|
+
* continua funcionando sem alterações.
|
|
2838
2989
|
*
|
|
2839
2990
|
* @example
|
|
2840
2991
|
* ```typescript
|
|
2841
|
-
* const
|
|
2842
|
-
*
|
|
2843
|
-
*
|
|
2992
|
+
* const integration: ScriptIntegration = {
|
|
2993
|
+
* id: 'my-script',
|
|
2994
|
+
* category: 'analytics',
|
|
2995
|
+
* src: 'https://example.com/script.js',
|
|
2996
|
+
* cookies: ['_example'],
|
|
2997
|
+
* init: () => console.log('Script initialized')
|
|
2844
2998
|
* }
|
|
2845
2999
|
* ```
|
|
2846
3000
|
*/
|
|
2847
|
-
interface
|
|
2848
|
-
/**
|
|
2849
|
-
|
|
2850
|
-
/**
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
3001
|
+
interface ScriptIntegration {
|
|
3002
|
+
/** Identificador único da integração */
|
|
3003
|
+
id: string;
|
|
3004
|
+
/**
|
|
3005
|
+
* Categoria LGPD à qual o script pertence.
|
|
3006
|
+
* Suporta tanto categorias predefinidas quanto customizadas.
|
|
3007
|
+
*/
|
|
3008
|
+
category: string;
|
|
3009
|
+
/** Nome legível da integração (opcional) */
|
|
3010
|
+
name?: string;
|
|
3011
|
+
/** URL do script a ser carregado */
|
|
3012
|
+
src: string;
|
|
3013
|
+
/** Se o script deve ser carregado de forma assíncrona */
|
|
3014
|
+
async?: boolean;
|
|
3015
|
+
/** Se o script deve ser deferido */
|
|
3016
|
+
defer?: boolean;
|
|
3017
|
+
/** Configuração específica da integração */
|
|
3018
|
+
config?: Record<string, unknown>;
|
|
3019
|
+
/** Função de inicialização executada após carregamento do script */
|
|
3020
|
+
init?: () => void;
|
|
3021
|
+
/** Atributos HTML adicionais para a tag script */
|
|
3022
|
+
attrs?: Record<string, string>;
|
|
3023
|
+
/** Nonce CSP opcional aplicado à tag script */
|
|
3024
|
+
nonce?: string;
|
|
3025
|
+
/** Prioridade para ordenação na fila do loader (maior = executa primeiro dentro da categoria) */
|
|
3026
|
+
priority?: number;
|
|
3027
|
+
/** Rotina opcional executada antes do carregamento principal (ex.: bootstrap de Consent Mode) */
|
|
3028
|
+
bootstrap?: () => void | Promise<void>;
|
|
3029
|
+
/** Callback disparado quando o consentimento é atualizado */
|
|
3030
|
+
onConsentUpdate?: (consent: {
|
|
3031
|
+
consented: boolean;
|
|
3032
|
+
preferences: ConsentPreferences;
|
|
3033
|
+
}) => void;
|
|
3034
|
+
/** Lista de cookies que o script pode definir */
|
|
3035
|
+
cookies?: string[];
|
|
3036
|
+
/** Informações detalhadas dos cookies (nome, finalidade, duração, fornecedor) */
|
|
3037
|
+
cookiesInfo?: Array<{
|
|
3038
|
+
name: string;
|
|
3039
|
+
purpose: string;
|
|
3040
|
+
duration: string;
|
|
3041
|
+
provider: string;
|
|
3042
|
+
}>;
|
|
2854
3043
|
}
|
|
2855
3044
|
/**
|
|
2856
|
-
* Configuração para
|
|
3045
|
+
* Configuração para integrações customizadas com categoria sugerida automaticamente.
|
|
2857
3046
|
*
|
|
2858
3047
|
* @category Utils
|
|
2859
|
-
* @since 0.
|
|
2860
|
-
*
|
|
2861
|
-
* @example
|
|
2862
|
-
* ```typescript
|
|
2863
|
-
* const config: IntercomConfig = {
|
|
2864
|
-
* app_id: 'your-app-id'
|
|
2865
|
-
* }
|
|
2866
|
-
* ```
|
|
3048
|
+
* @since 0.7.2
|
|
2867
3049
|
*/
|
|
2868
|
-
interface
|
|
2869
|
-
/**
|
|
2870
|
-
|
|
2871
|
-
/** URL do script Intercom. Se omitido usa o padrão oficial. */
|
|
2872
|
-
scriptUrl?: string;
|
|
3050
|
+
interface SuggestedIntegrationConfig extends Omit<ScriptIntegration, 'category'> {
|
|
3051
|
+
/** Categoria LGPD customizada (opcional). Se omitida, usa sugestão automática. */
|
|
3052
|
+
category?: string;
|
|
2873
3053
|
}
|
|
2874
3054
|
/**
|
|
2875
|
-
*
|
|
3055
|
+
* Cria integração customizada aplicando categoria sugerida automaticamente.
|
|
3056
|
+
* Permite sobrescrever a categoria quando necessário.
|
|
2876
3057
|
*
|
|
2877
3058
|
* @category Utils
|
|
2878
|
-
* @since 0.
|
|
3059
|
+
* @since 0.7.2
|
|
2879
3060
|
*
|
|
2880
3061
|
* @example
|
|
2881
3062
|
* ```typescript
|
|
2882
|
-
* const
|
|
2883
|
-
*
|
|
2884
|
-
*
|
|
2885
|
-
*
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
/** URL do script Zendesk. Se omitido usa o padrão oficial. */
|
|
2891
|
-
scriptUrl?: string;
|
|
2892
|
-
}
|
|
3063
|
+
* const custom = createSuggestedIntegration({
|
|
3064
|
+
* id: 'custom-chat',
|
|
3065
|
+
* src: 'https://example.com/chat.js'
|
|
3066
|
+
* })
|
|
3067
|
+
* // -> category sugerida: 'functional'
|
|
3068
|
+
* ```
|
|
3069
|
+
*/
|
|
3070
|
+
declare function createSuggestedIntegration(config: SuggestedIntegrationConfig): ScriptIntegration;
|
|
2893
3071
|
/**
|
|
2894
|
-
*
|
|
2895
|
-
* Configura o fbq e inicializa o pixel com tracking automático opcional.
|
|
3072
|
+
* Configuração para integração do Google Analytics (GA4).
|
|
2896
3073
|
*
|
|
2897
3074
|
* @category Utils
|
|
2898
|
-
* @
|
|
2899
|
-
* @returns Integração configurada para o Facebook Pixel
|
|
2900
|
-
* @since 0.4.1
|
|
3075
|
+
* @since 0.2.0
|
|
2901
3076
|
*
|
|
2902
3077
|
* @example
|
|
2903
3078
|
* ```typescript
|
|
2904
|
-
* const
|
|
2905
|
-
*
|
|
2906
|
-
*
|
|
2907
|
-
* }
|
|
3079
|
+
* const config: GoogleAnalyticsConfig = {
|
|
3080
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
3081
|
+
* config: { anonymize_ip: true }
|
|
3082
|
+
* }
|
|
2908
3083
|
* ```
|
|
2909
|
-
*
|
|
2910
|
-
* @remarks
|
|
2911
|
-
* - Define cookies: _fbp, fr
|
|
2912
|
-
* - Categoria padrão: 'marketing'
|
|
2913
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2914
3084
|
*/
|
|
2915
|
-
|
|
3085
|
+
interface GoogleAnalyticsConfig {
|
|
3086
|
+
/** ID de medição do GA4 (formato: G-XXXXXXXXXX) */
|
|
3087
|
+
measurementId: string;
|
|
3088
|
+
/** Configurações adicionais para o gtag */
|
|
3089
|
+
config?: Record<string, unknown>;
|
|
3090
|
+
/** URL do script GA4. Se omitido usa o padrão oficial. */
|
|
3091
|
+
scriptUrl?: string;
|
|
3092
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3093
|
+
category?: string;
|
|
3094
|
+
}
|
|
2916
3095
|
/**
|
|
2917
|
-
*
|
|
2918
|
-
* Configura as configurações do Hotjar e inicializa o tracking de heatmaps e gravações.
|
|
3096
|
+
* Configuração para integração do Google Tag Manager (GTM).
|
|
2919
3097
|
*
|
|
2920
3098
|
* @category Utils
|
|
2921
|
-
* @
|
|
2922
|
-
* @returns Integração configurada para o Hotjar
|
|
2923
|
-
* @since 0.4.1
|
|
3099
|
+
* @since 0.2.0
|
|
2924
3100
|
*
|
|
2925
3101
|
* @example
|
|
2926
3102
|
* ```typescript
|
|
2927
|
-
* const
|
|
2928
|
-
*
|
|
2929
|
-
*
|
|
2930
|
-
* }
|
|
3103
|
+
* const config: GoogleTagManagerConfig = {
|
|
3104
|
+
* containerId: 'GTM-XXXXXXX',
|
|
3105
|
+
* dataLayerName: 'customDataLayer'
|
|
3106
|
+
* }
|
|
2931
3107
|
* ```
|
|
2932
|
-
*
|
|
2933
|
-
* @remarks
|
|
2934
|
-
* - Define cookies: _hjSession_*, _hjSessionUser_*, _hjFirstSeen, _hjIncludedInSessionSample, _hjAbsoluteSessionInProgress
|
|
2935
|
-
* - Categoria padrão: 'analytics'
|
|
2936
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2937
3108
|
*/
|
|
2938
|
-
|
|
3109
|
+
interface GoogleTagManagerConfig {
|
|
3110
|
+
/** ID do container GTM (formato: GTM-XXXXXXX) */
|
|
3111
|
+
containerId: string;
|
|
3112
|
+
/** Nome customizado para o dataLayer. Padrão: 'dataLayer' */
|
|
3113
|
+
dataLayerName?: string;
|
|
3114
|
+
/** URL do script GTM. Se omitido usa o padrão oficial. */
|
|
3115
|
+
scriptUrl?: string;
|
|
3116
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3117
|
+
category?: string;
|
|
3118
|
+
}
|
|
2939
3119
|
/**
|
|
2940
|
-
*
|
|
2941
|
-
* Configura e inicializa o Mixpanel para analytics de eventos.
|
|
3120
|
+
* Configuração para integração do UserWay (Acessibilidade).
|
|
2942
3121
|
*
|
|
2943
3122
|
* @category Utils
|
|
2944
|
-
* @
|
|
2945
|
-
* @returns Integração configurada para o Mixpanel
|
|
2946
|
-
* @since 0.4.1
|
|
3123
|
+
* @since 0.2.0
|
|
2947
3124
|
*
|
|
2948
3125
|
* @example
|
|
2949
3126
|
* ```typescript
|
|
2950
|
-
* const
|
|
2951
|
-
*
|
|
2952
|
-
*
|
|
2953
|
-
* })
|
|
3127
|
+
* const config: UserWayConfig = {
|
|
3128
|
+
* accountId: 'XXXXXXXXXX'
|
|
3129
|
+
* }
|
|
2954
3130
|
* ```
|
|
2955
|
-
*
|
|
2956
|
-
* @remarks
|
|
2957
|
-
* - Define cookies: mp_*
|
|
2958
|
-
* - Categoria padrão: 'analytics'
|
|
2959
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2960
|
-
* - Inclui tratamento de erro na inicialização
|
|
2961
3131
|
*/
|
|
2962
|
-
|
|
3132
|
+
interface UserWayConfig {
|
|
3133
|
+
/** ID da conta UserWay */
|
|
3134
|
+
accountId: string;
|
|
3135
|
+
/** URL do script UserWay. Se omitido usa o padrão oficial. */
|
|
3136
|
+
scriptUrl?: string;
|
|
3137
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3138
|
+
category?: string;
|
|
3139
|
+
}
|
|
2963
3140
|
/**
|
|
2964
|
-
* Cria integração do
|
|
2965
|
-
* Configura o
|
|
3141
|
+
* Cria integração do Google Analytics (GA4).
|
|
3142
|
+
* Configura o gtag e inicializa o tracking com o measurement ID fornecido.
|
|
2966
3143
|
*
|
|
2967
3144
|
* @category Utils
|
|
2968
|
-
* @param config - Configuração do
|
|
2969
|
-
* @returns Integração configurada para o
|
|
2970
|
-
* @since 0.
|
|
3145
|
+
* @param config - Configuração do Google Analytics
|
|
3146
|
+
* @returns Integração configurada para o GA4
|
|
3147
|
+
* @since 0.2.0
|
|
2971
3148
|
*
|
|
2972
3149
|
* @example
|
|
2973
3150
|
* ```typescript
|
|
2974
|
-
* const
|
|
2975
|
-
*
|
|
2976
|
-
*
|
|
3151
|
+
* const ga = createGoogleAnalyticsIntegration({
|
|
3152
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
3153
|
+
* config: { anonymize_ip: true }
|
|
2977
3154
|
* })
|
|
2978
3155
|
* ```
|
|
2979
3156
|
*
|
|
2980
3157
|
* @remarks
|
|
2981
|
-
* - Define cookies:
|
|
3158
|
+
* - Define cookies: _ga, _ga_*, _gid
|
|
2982
3159
|
* - Categoria padrão: 'analytics'
|
|
2983
3160
|
* - SSR-safe: verifica disponibilidade do window
|
|
2984
|
-
* - Configuração de upload opcional
|
|
2985
3161
|
*/
|
|
2986
|
-
declare function
|
|
3162
|
+
declare function createGoogleAnalyticsIntegration(config: GoogleAnalyticsConfig): ScriptIntegration;
|
|
2987
3163
|
/**
|
|
2988
|
-
* Cria integração do
|
|
2989
|
-
* Configura o
|
|
3164
|
+
* Cria integração do Google Tag Manager (GTM).
|
|
3165
|
+
* Configura o dataLayer e inicializa o container GTM.
|
|
2990
3166
|
*
|
|
2991
3167
|
* @category Utils
|
|
2992
|
-
* @param config - Configuração do
|
|
2993
|
-
* @returns Integração configurada para o
|
|
2994
|
-
* @since 0.
|
|
3168
|
+
* @param config - Configuração do Google Tag Manager
|
|
3169
|
+
* @returns Integração configurada para o GTM
|
|
3170
|
+
* @since 0.2.0
|
|
2995
3171
|
*
|
|
2996
3172
|
* @example
|
|
2997
3173
|
* ```typescript
|
|
2998
|
-
* const
|
|
2999
|
-
*
|
|
3174
|
+
* const gtm = createGoogleTagManagerIntegration({
|
|
3175
|
+
* containerId: 'GTM-XXXXXXX',
|
|
3176
|
+
* dataLayerName: 'myDataLayer'
|
|
3000
3177
|
* })
|
|
3001
3178
|
* ```
|
|
3002
3179
|
*
|
|
3003
3180
|
* @remarks
|
|
3004
|
-
* - Define cookies:
|
|
3005
|
-
* - Categoria padrão: '
|
|
3181
|
+
* - Define cookies: _gcl_au
|
|
3182
|
+
* - Categoria padrão: 'analytics'
|
|
3006
3183
|
* - SSR-safe: verifica disponibilidade do window
|
|
3007
|
-
* - Inclui tratamento de erro na inicialização
|
|
3008
3184
|
*/
|
|
3009
|
-
declare function
|
|
3185
|
+
declare function createGoogleTagManagerIntegration(config: GoogleTagManagerConfig): ScriptIntegration;
|
|
3010
3186
|
/**
|
|
3011
|
-
* Cria integração do
|
|
3012
|
-
* Configura o widget de
|
|
3187
|
+
* Cria integração do UserWay (Acessibilidade).
|
|
3188
|
+
* Configura o widget de acessibilidade UserWay.
|
|
3013
3189
|
*
|
|
3014
3190
|
* @category Utils
|
|
3015
|
-
* @param config - Configuração do
|
|
3016
|
-
* @returns Integração configurada para o
|
|
3017
|
-
* @since 0.
|
|
3191
|
+
* @param config - Configuração do UserWay
|
|
3192
|
+
* @returns Integração configurada para o UserWay
|
|
3193
|
+
* @since 0.2.0
|
|
3018
3194
|
*
|
|
3019
3195
|
* @example
|
|
3020
3196
|
* ```typescript
|
|
3021
|
-
* const
|
|
3022
|
-
*
|
|
3197
|
+
* const userway = createUserWayIntegration({
|
|
3198
|
+
* accountId: 'XXXXXXXXXX'
|
|
3023
3199
|
* })
|
|
3024
3200
|
* ```
|
|
3025
3201
|
*
|
|
3026
3202
|
* @remarks
|
|
3027
|
-
* - Define cookies:
|
|
3203
|
+
* - Define cookies: _userway_*
|
|
3028
3204
|
* - Categoria padrão: 'functional'
|
|
3029
3205
|
* - SSR-safe: verifica disponibilidade do window
|
|
3030
|
-
* - Inclui tratamento de erro na identificação
|
|
3031
3206
|
*/
|
|
3032
|
-
declare function
|
|
3207
|
+
declare function createUserWayIntegration(config: UserWayConfig): ScriptIntegration;
|
|
3033
3208
|
/**
|
|
3034
|
-
*
|
|
3035
|
-
*
|
|
3209
|
+
* Funções fábricas para integrações comuns.
|
|
3210
|
+
* Fornece acesso direto às funções de criação de integrações pré-configuradas.
|
|
3036
3211
|
*
|
|
3037
3212
|
* @category Utils
|
|
3038
|
-
* @since 0.
|
|
3213
|
+
* @since 0.2.0
|
|
3039
3214
|
*
|
|
3040
3215
|
* @example
|
|
3041
3216
|
* ```typescript
|
|
3042
|
-
* const
|
|
3043
|
-
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3044
|
-
* facebookPixel: { pixelId: '1234567890123456' }
|
|
3045
|
-
* }
|
|
3217
|
+
* const ga = COMMON_INTEGRATIONS.googleAnalytics({ measurementId: 'G-XXXXXXXXXX' })
|
|
3046
3218
|
* ```
|
|
3047
3219
|
*/
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
/** Configuração do Hotjar */
|
|
3054
|
-
hotjar?: HotjarConfig;
|
|
3055
|
-
/** Configuração do UserWay */
|
|
3056
|
-
userway?: UserWayConfig;
|
|
3057
|
-
}
|
|
3220
|
+
declare const COMMON_INTEGRATIONS: {
|
|
3221
|
+
googleAnalytics: typeof createGoogleAnalyticsIntegration;
|
|
3222
|
+
googleTagManager: typeof createGoogleTagManagerIntegration;
|
|
3223
|
+
userway: typeof createUserWayIntegration;
|
|
3224
|
+
};
|
|
3058
3225
|
/**
|
|
3059
|
-
* Configuração para
|
|
3060
|
-
* Define configurações opcionais para múltiplas integrações otimizadas para SaaS.
|
|
3226
|
+
* Configuração para integração do Facebook Pixel.
|
|
3061
3227
|
*
|
|
3062
3228
|
* @category Utils
|
|
3063
3229
|
* @since 0.4.1
|
|
3064
3230
|
*
|
|
3065
3231
|
* @example
|
|
3066
3232
|
* ```typescript
|
|
3067
|
-
* const config:
|
|
3068
|
-
*
|
|
3069
|
-
*
|
|
3070
|
-
*
|
|
3233
|
+
* const config: FacebookPixelConfig = {
|
|
3234
|
+
* pixelId: '1234567890123456',
|
|
3235
|
+
* autoTrack: true,
|
|
3236
|
+
* advancedMatching: { email: 'user@example.com' }
|
|
3071
3237
|
* }
|
|
3072
3238
|
* ```
|
|
3073
3239
|
*/
|
|
3074
|
-
interface
|
|
3075
|
-
/**
|
|
3076
|
-
|
|
3077
|
-
/**
|
|
3078
|
-
|
|
3079
|
-
/** Configuração
|
|
3080
|
-
|
|
3081
|
-
/**
|
|
3082
|
-
|
|
3240
|
+
interface FacebookPixelConfig {
|
|
3241
|
+
/** ID do pixel do Facebook */
|
|
3242
|
+
pixelId: string;
|
|
3243
|
+
/** Se deve rastrear PageView automaticamente. Padrão: true */
|
|
3244
|
+
autoTrack?: boolean;
|
|
3245
|
+
/** Configuração de correspondência avançada */
|
|
3246
|
+
advancedMatching?: Record<string, unknown>;
|
|
3247
|
+
/** URL do script do Pixel. Se omitido usa o padrão oficial. */
|
|
3248
|
+
scriptUrl?: string;
|
|
3249
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3250
|
+
category?: string;
|
|
3083
3251
|
}
|
|
3084
3252
|
/**
|
|
3085
|
-
* Configuração para
|
|
3086
|
-
* Define configurações opcionais para múltiplas integrações otimizadas para ambientes corporativos.
|
|
3253
|
+
* Configuração para integração do Hotjar.
|
|
3087
3254
|
*
|
|
3088
3255
|
* @category Utils
|
|
3089
3256
|
* @since 0.4.1
|
|
3090
3257
|
*
|
|
3091
3258
|
* @example
|
|
3092
3259
|
* ```typescript
|
|
3093
|
-
* const config:
|
|
3094
|
-
*
|
|
3095
|
-
*
|
|
3096
|
-
*
|
|
3260
|
+
* const config: HotjarConfig = {
|
|
3261
|
+
* siteId: '1234567',
|
|
3262
|
+
* version: 6,
|
|
3263
|
+
* debug: false
|
|
3097
3264
|
* }
|
|
3098
3265
|
* ```
|
|
3099
3266
|
*/
|
|
3100
|
-
interface
|
|
3101
|
-
/**
|
|
3102
|
-
|
|
3103
|
-
/**
|
|
3104
|
-
|
|
3105
|
-
/**
|
|
3106
|
-
|
|
3107
|
-
/**
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
* Combina analytics de conversão, remarketing e acessibilidade.
|
|
3113
|
-
*
|
|
3114
|
-
* @category Utils
|
|
3115
|
-
* @param cfg - Configuração das integrações de e-commerce
|
|
3116
|
-
* @returns Array de integrações configuradas
|
|
3117
|
-
* @since 0.4.1
|
|
3118
|
-
*
|
|
3119
|
-
* @example
|
|
3120
|
-
* ```typescript
|
|
3121
|
-
* const integrations = createECommerceIntegrations({
|
|
3122
|
-
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3123
|
-
* facebookPixel: { pixelId: '1234567890123456' }
|
|
3124
|
-
* })
|
|
3125
|
-
* ```
|
|
3126
|
-
*
|
|
3127
|
-
* @remarks
|
|
3128
|
-
* Combina categorias: analytics, marketing, functional
|
|
3129
|
-
*/
|
|
3130
|
-
declare function createECommerceIntegrations(cfg: ECommerceConfig): ScriptIntegration[];
|
|
3267
|
+
interface HotjarConfig {
|
|
3268
|
+
/** ID do site no Hotjar */
|
|
3269
|
+
siteId: string;
|
|
3270
|
+
/** Versão do script Hotjar. Padrão: 6 */
|
|
3271
|
+
version?: number;
|
|
3272
|
+
/** Ativar modo debug. Padrão: false */
|
|
3273
|
+
debug?: boolean;
|
|
3274
|
+
/** URL do script Hotjar. Se omitido usa o padrão oficial. */
|
|
3275
|
+
scriptUrl?: string;
|
|
3276
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3277
|
+
category?: string;
|
|
3278
|
+
}
|
|
3131
3279
|
/**
|
|
3132
|
-
*
|
|
3133
|
-
* Combina analytics de produto, suporte ao cliente e comportamento do usuário.
|
|
3280
|
+
* Configuração para integração do Mixpanel.
|
|
3134
3281
|
*
|
|
3135
3282
|
* @category Utils
|
|
3136
|
-
* @param cfg - Configuração das integrações de SaaS
|
|
3137
|
-
* @returns Array de integrações configuradas
|
|
3138
3283
|
* @since 0.4.1
|
|
3139
3284
|
*
|
|
3140
3285
|
* @example
|
|
3141
3286
|
* ```typescript
|
|
3142
|
-
* const
|
|
3143
|
-
*
|
|
3144
|
-
*
|
|
3145
|
-
*
|
|
3146
|
-
* }
|
|
3287
|
+
* const config: MixpanelConfig = {
|
|
3288
|
+
* token: 'your-project-token',
|
|
3289
|
+
* config: { debug: true },
|
|
3290
|
+
* api_host: 'https://api.mixpanel.com'
|
|
3291
|
+
* }
|
|
3147
3292
|
* ```
|
|
3148
|
-
*
|
|
3149
|
-
* @remarks
|
|
3150
|
-
* Combina categorias: analytics, functional
|
|
3151
3293
|
*/
|
|
3152
|
-
|
|
3294
|
+
interface MixpanelConfig {
|
|
3295
|
+
/** Token do projeto Mixpanel */
|
|
3296
|
+
token: string;
|
|
3297
|
+
/** Configurações adicionais do Mixpanel */
|
|
3298
|
+
config?: Record<string, unknown>;
|
|
3299
|
+
/** Host customizado da API Mixpanel */
|
|
3300
|
+
api_host?: string;
|
|
3301
|
+
/** URL do script Mixpanel. Se omitido usa o padrão oficial. */
|
|
3302
|
+
scriptUrl?: string;
|
|
3303
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3304
|
+
category?: string;
|
|
3305
|
+
}
|
|
3153
3306
|
/**
|
|
3154
|
-
*
|
|
3155
|
-
* Combina analytics empresariais, compliance e suporte corporativo.
|
|
3307
|
+
* Configuração para integração do Microsoft Clarity.
|
|
3156
3308
|
*
|
|
3157
3309
|
* @category Utils
|
|
3158
|
-
* @param cfg - Configuração das integrações corporativas
|
|
3159
|
-
* @returns Array de integrações configuradas
|
|
3160
3310
|
* @since 0.4.1
|
|
3161
3311
|
*
|
|
3162
3312
|
* @example
|
|
3163
3313
|
* ```typescript
|
|
3164
|
-
* const
|
|
3165
|
-
*
|
|
3166
|
-
*
|
|
3167
|
-
*
|
|
3168
|
-
* })
|
|
3314
|
+
* const config: ClarityConfig = {
|
|
3315
|
+
* projectId: 'abcdefghij',
|
|
3316
|
+
* upload: true
|
|
3317
|
+
* }
|
|
3169
3318
|
* ```
|
|
3170
|
-
*
|
|
3171
|
-
* @remarks
|
|
3172
|
-
* Combina categorias: analytics, functional
|
|
3173
3319
|
*/
|
|
3174
|
-
|
|
3320
|
+
interface ClarityConfig {
|
|
3321
|
+
/** ID do projeto no Microsoft Clarity */
|
|
3322
|
+
projectId: string;
|
|
3323
|
+
/** Configuração de upload de dados. Padrão: indefinido */
|
|
3324
|
+
upload?: boolean;
|
|
3325
|
+
/** URL do script Clarity. Se omitido usa o padrão oficial. */
|
|
3326
|
+
scriptUrl?: string;
|
|
3327
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3328
|
+
category?: string;
|
|
3329
|
+
}
|
|
3175
3330
|
/**
|
|
3176
|
-
*
|
|
3177
|
-
* Define integrações essenciais e opcionais para cada contexto.
|
|
3331
|
+
* Configuração para integração do Intercom.
|
|
3178
3332
|
*
|
|
3179
3333
|
* @category Utils
|
|
3180
3334
|
* @since 0.4.1
|
|
3181
3335
|
*
|
|
3182
3336
|
* @example
|
|
3183
3337
|
* ```typescript
|
|
3184
|
-
* const
|
|
3185
|
-
*
|
|
3186
|
-
*
|
|
3338
|
+
* const config: IntercomConfig = {
|
|
3339
|
+
* app_id: 'your-app-id'
|
|
3340
|
+
* }
|
|
3187
3341
|
* ```
|
|
3188
|
-
*
|
|
3189
|
-
* @remarks
|
|
3190
|
-
* Cada template define:
|
|
3191
|
-
* - essential: integrações obrigatórias/recomendadas
|
|
3192
|
-
* - optional: integrações complementares
|
|
3193
|
-
* - categories: categorias LGPD utilizadas
|
|
3194
3342
|
*/
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
optional: string[];
|
|
3204
|
-
categories: string[];
|
|
3205
|
-
};
|
|
3206
|
-
corporate: {
|
|
3207
|
-
essential: string[];
|
|
3208
|
-
optional: string[];
|
|
3209
|
-
categories: string[];
|
|
3210
|
-
};
|
|
3211
|
-
};
|
|
3343
|
+
interface IntercomConfig {
|
|
3344
|
+
/** ID da aplicação Intercom */
|
|
3345
|
+
app_id: string;
|
|
3346
|
+
/** URL do script Intercom. Se omitido usa o padrão oficial. */
|
|
3347
|
+
scriptUrl?: string;
|
|
3348
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3349
|
+
category?: string;
|
|
3350
|
+
}
|
|
3212
3351
|
/**
|
|
3213
|
-
*
|
|
3214
|
-
* Utiliza heurísticas para classificar scripts desconhecidos.
|
|
3352
|
+
* Configuração para integração do Zendesk Chat.
|
|
3215
3353
|
*
|
|
3216
3354
|
* @category Utils
|
|
3217
|
-
* @param name - Nome ou identificador do script
|
|
3218
|
-
* @returns Array de categorias sugeridas
|
|
3219
3355
|
* @since 0.4.1
|
|
3220
3356
|
*
|
|
3221
3357
|
* @example
|
|
3222
3358
|
* ```typescript
|
|
3223
|
-
*
|
|
3224
|
-
*
|
|
3225
|
-
*
|
|
3226
|
-
* suggestCategoryForScript('unknown-script') // ['analytics']
|
|
3359
|
+
* const config: ZendeskConfig = {
|
|
3360
|
+
* key: 'your-zendesk-key'
|
|
3361
|
+
* }
|
|
3227
3362
|
* ```
|
|
3228
|
-
*
|
|
3229
|
-
* @remarks
|
|
3230
|
-
* Heurísticas aplicadas:
|
|
3231
|
-
* - Scripts de ads/marketing → 'marketing'
|
|
3232
|
-
* - Scripts de analytics/tracking → 'analytics'
|
|
3233
|
-
* - Scripts de chat/suporte → 'functional'
|
|
3234
|
-
* - Padrão para desconhecidos → 'analytics'
|
|
3235
3363
|
*/
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
*/
|
|
3242
|
-
|
|
3243
|
-
interface RegisteredScript {
|
|
3244
|
-
id: string;
|
|
3245
|
-
category: string;
|
|
3246
|
-
execute: () => void | Promise<void>;
|
|
3247
|
-
priority?: number;
|
|
3248
|
-
allowReload?: boolean;
|
|
3249
|
-
onConsentUpdate?: (consent: {
|
|
3250
|
-
consented: boolean;
|
|
3251
|
-
preferences: ConsentPreferences;
|
|
3252
|
-
}) => void;
|
|
3364
|
+
interface ZendeskConfig {
|
|
3365
|
+
/** Chave de identificação do Zendesk */
|
|
3366
|
+
key: string;
|
|
3367
|
+
/** URL do script Zendesk. Se omitido usa o padrão oficial. */
|
|
3368
|
+
scriptUrl?: string;
|
|
3369
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3370
|
+
category?: string;
|
|
3253
3371
|
}
|
|
3254
3372
|
/**
|
|
3255
|
-
*
|
|
3256
|
-
*
|
|
3257
|
-
* @remarks
|
|
3258
|
-
* - Scripts `necessary` rodam imediatamente; demais aguardam consentimento da categoria.
|
|
3259
|
-
* - Fluxo de estados: `pending` → `running` → `executed` (respeitando `allowReload` e `onConsentUpdate`).
|
|
3260
|
-
* - A fila é ordenada por categoria, `priority` (maior primeiro) e ordem de registro.
|
|
3261
|
-
* - `allowReload` permite reexecutar scripts quando o usuário muda preferências.
|
|
3262
|
-
* - Use `onConsentUpdate` para reenviar sinais (ex.: Consent Mode) após novas decisões.
|
|
3263
|
-
* - Sempre chame o cleanup retornado em efeitos React para evitar múltiplos registros do mesmo `id`.
|
|
3373
|
+
* Cria integração do Facebook Pixel.
|
|
3374
|
+
* Configura o fbq e inicializa o pixel com tracking automático opcional.
|
|
3264
3375
|
*
|
|
3265
|
-
* @param def Definição do script a ser registrado.
|
|
3266
|
-
* @returns Função de cleanup para remover o script da fila.
|
|
3267
|
-
*/
|
|
3268
|
-
declare function registerScript(def: RegisteredScript): () => void;
|
|
3269
|
-
interface ConsentScriptLoaderProps {
|
|
3270
|
-
/** Lista de integrações de scripts para carregar baseado no consentimento */
|
|
3271
|
-
integrations: ScriptIntegration[];
|
|
3272
|
-
/** Se true, força recarregamento se consentimento mudar */
|
|
3273
|
-
reloadOnChange?: boolean;
|
|
3274
|
-
/** Nonce CSP aplicado às tags <script> geradas automaticamente (sobrescrevível por integração). */
|
|
3275
|
-
nonce?: string;
|
|
3276
|
-
}
|
|
3277
|
-
/**
|
|
3278
|
-
* @component
|
|
3279
3376
|
* @category Utils
|
|
3280
|
-
* @
|
|
3281
|
-
*
|
|
3282
|
-
*
|
|
3283
|
-
*
|
|
3284
|
-
* @param props As propriedades do componente.
|
|
3285
|
-
* @param {ScriptIntegration[]} props.integrations Um array de objetos de integração de script. Use as factory functions (`createGoogleAnalyticsIntegration`, etc.) para criar.
|
|
3286
|
-
* @param {boolean} [props.reloadOnChange=false] Se `true`, recarrega os scripts se as preferências de consentimento mudarem.
|
|
3377
|
+
* @param config - Configuração do Facebook Pixel
|
|
3378
|
+
* @returns Integração configurada para o Facebook Pixel
|
|
3379
|
+
* @since 0.4.1
|
|
3287
3380
|
*
|
|
3288
3381
|
* @example
|
|
3289
|
-
* ```
|
|
3290
|
-
* const
|
|
3291
|
-
*
|
|
3292
|
-
*
|
|
3293
|
-
*
|
|
3294
|
-
*
|
|
3295
|
-
* <ConsentScriptLoader integrations={integrations} />
|
|
3382
|
+
* ```typescript
|
|
3383
|
+
* const pixel = createFacebookPixelIntegration({
|
|
3384
|
+
* pixelId: '1234567890123456',
|
|
3385
|
+
* autoTrack: true
|
|
3386
|
+
* })
|
|
3296
3387
|
* ```
|
|
3388
|
+
*
|
|
3389
|
+
* @remarks
|
|
3390
|
+
* - Define cookies: _fbp, fr
|
|
3391
|
+
* - Categoria padrão: 'marketing'
|
|
3392
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3297
3393
|
*/
|
|
3298
|
-
declare function
|
|
3394
|
+
declare function createFacebookPixelIntegration(config: FacebookPixelConfig): ScriptIntegration;
|
|
3299
3395
|
/**
|
|
3300
|
-
*
|
|
3301
|
-
*
|
|
3302
|
-
* @since 0.2.0
|
|
3303
|
-
* Hook para carregamento programático de um script baseado no consentimento.
|
|
3396
|
+
* Cria integração do Hotjar.
|
|
3397
|
+
* Configura as configurações do Hotjar e inicializa o tracking de heatmaps e gravações.
|
|
3304
3398
|
*
|
|
3305
|
-
* @
|
|
3306
|
-
*
|
|
3399
|
+
* @category Utils
|
|
3400
|
+
* @param config - Configuração do Hotjar
|
|
3401
|
+
* @returns Integração configurada para o Hotjar
|
|
3402
|
+
* @since 0.4.1
|
|
3307
3403
|
*
|
|
3308
3404
|
* @example
|
|
3309
|
-
* ```
|
|
3310
|
-
* const
|
|
3311
|
-
*
|
|
3312
|
-
*
|
|
3313
|
-
*
|
|
3314
|
-
*
|
|
3315
|
-
*
|
|
3316
|
-
*
|
|
3317
|
-
*
|
|
3318
|
-
*
|
|
3319
|
-
*
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
* myButton.addEventListener('click', handleUserAction);
|
|
3323
|
-
* }, [loadScript]);
|
|
3324
|
-
* ```
|
|
3325
|
-
*/
|
|
3326
|
-
declare function useConsentScriptLoader(): (integration: ScriptIntegration, nonce?: string) => Promise<boolean>;
|
|
3327
|
-
|
|
3328
|
-
/**
|
|
3329
|
-
* @file autoConfigureCategories.ts
|
|
3330
|
-
* @description Sistema inteligente de auto-habilitação de categorias baseado nas integrações utilizadas
|
|
3331
|
-
* @since 0.4.1
|
|
3332
|
-
*/
|
|
3333
|
-
|
|
3334
|
-
/**
|
|
3335
|
-
* @interface CategoryAutoConfigResult
|
|
3336
|
-
* Resultado da análise e auto-configuração de categorias
|
|
3337
|
-
*/
|
|
3338
|
-
interface CategoryAutoConfigResult {
|
|
3339
|
-
/** Configuração original fornecida pelo desenvolvedor */
|
|
3340
|
-
originalConfig: ProjectCategoriesConfig;
|
|
3341
|
-
/** Configuração ajustada automaticamente pela biblioteca */
|
|
3342
|
-
adjustedConfig: ProjectCategoriesConfig;
|
|
3343
|
-
/** Categorias que foram automaticamente habilitadas */
|
|
3344
|
-
autoEnabledCategories: string[];
|
|
3345
|
-
/** Categorias requeridas pelas integrações mas não habilitadas */
|
|
3346
|
-
missingCategories: string[];
|
|
3347
|
-
/** Se algum ajuste foi necessário */
|
|
3348
|
-
wasAdjusted: boolean;
|
|
3349
|
-
/** Integrações que requerem cada categoria */
|
|
3350
|
-
categoryIntegrations: Record<string, string[]>;
|
|
3351
|
-
}
|
|
3405
|
+
* ```typescript
|
|
3406
|
+
* const hotjar = createHotjarIntegration({
|
|
3407
|
+
* siteId: '1234567',
|
|
3408
|
+
* debug: true
|
|
3409
|
+
* })
|
|
3410
|
+
* ```
|
|
3411
|
+
*
|
|
3412
|
+
* @remarks
|
|
3413
|
+
* - Define cookies: _hjSession_*, _hjSessionUser_*, _hjFirstSeen, _hjIncludedInSessionSample, _hjAbsoluteSessionInProgress
|
|
3414
|
+
* - Categoria padrão: 'analytics'
|
|
3415
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3416
|
+
*/
|
|
3417
|
+
declare function createHotjarIntegration(config: HotjarConfig): ScriptIntegration;
|
|
3352
3418
|
/**
|
|
3353
|
-
*
|
|
3419
|
+
* Cria integração do Mixpanel.
|
|
3420
|
+
* Configura e inicializa o Mixpanel para analytics de eventos.
|
|
3421
|
+
*
|
|
3354
3422
|
* @category Utils
|
|
3423
|
+
* @param config - Configuração do Mixpanel
|
|
3424
|
+
* @returns Integração configurada para o Mixpanel
|
|
3355
3425
|
* @since 0.4.1
|
|
3356
|
-
* Analisa as integrações fornecidas e determina quais categorias são necessárias.
|
|
3357
3426
|
*
|
|
3358
|
-
* @
|
|
3359
|
-
*
|
|
3427
|
+
* @example
|
|
3428
|
+
* ```typescript
|
|
3429
|
+
* const mixpanel = createMixpanelIntegration({
|
|
3430
|
+
* token: 'your-project-token',
|
|
3431
|
+
* config: { debug: true }
|
|
3432
|
+
* })
|
|
3433
|
+
* ```
|
|
3434
|
+
*
|
|
3435
|
+
* @remarks
|
|
3436
|
+
* - Define cookies: mp_*
|
|
3437
|
+
* - Categoria padrão: 'analytics'
|
|
3438
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3439
|
+
* - Inclui tratamento de erro na inicialização
|
|
3360
3440
|
*/
|
|
3361
|
-
declare function
|
|
3441
|
+
declare function createMixpanelIntegration(config: MixpanelConfig): ScriptIntegration;
|
|
3362
3442
|
/**
|
|
3363
|
-
*
|
|
3443
|
+
* Cria integração do Microsoft Clarity.
|
|
3444
|
+
* Configura o Microsoft Clarity para heatmaps e analytics de comportamento.
|
|
3445
|
+
*
|
|
3364
3446
|
* @category Utils
|
|
3447
|
+
* @param config - Configuração do Microsoft Clarity
|
|
3448
|
+
* @returns Integração configurada para o Clarity
|
|
3365
3449
|
* @since 0.4.1
|
|
3366
|
-
* Configura automaticamente as categorias necessárias baseado nas integrações utilizadas.
|
|
3367
3450
|
*
|
|
3368
|
-
*
|
|
3369
|
-
*
|
|
3370
|
-
*
|
|
3371
|
-
*
|
|
3372
|
-
*
|
|
3451
|
+
* @example
|
|
3452
|
+
* ```typescript
|
|
3453
|
+
* const clarity = createClarityIntegration({
|
|
3454
|
+
* projectId: 'abcdefghij',
|
|
3455
|
+
* upload: false
|
|
3456
|
+
* })
|
|
3457
|
+
* ```
|
|
3373
3458
|
*
|
|
3374
|
-
* @
|
|
3375
|
-
*
|
|
3376
|
-
*
|
|
3377
|
-
*
|
|
3459
|
+
* @remarks
|
|
3460
|
+
* - Define cookies: _clck, _clsk, CLID, ANONCHK, MR, MUID, SM
|
|
3461
|
+
* - Categoria padrão: 'analytics'
|
|
3462
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3463
|
+
* - Configuração de upload opcional
|
|
3378
3464
|
*/
|
|
3379
|
-
declare function
|
|
3380
|
-
/** Se true, apenas avisa mas não modifica a config (padrão: false - auto-habilita) */
|
|
3381
|
-
warningOnly?: boolean;
|
|
3382
|
-
/** Se true, desabilita logs no console (padrão: false) */
|
|
3383
|
-
silent?: boolean;
|
|
3384
|
-
}): CategoryAutoConfigResult;
|
|
3465
|
+
declare function createClarityIntegration(config: ClarityConfig): ScriptIntegration;
|
|
3385
3466
|
/**
|
|
3386
|
-
*
|
|
3467
|
+
* Cria integração do Intercom.
|
|
3468
|
+
* Configura o widget de chat e suporte do Intercom.
|
|
3469
|
+
*
|
|
3387
3470
|
* @category Utils
|
|
3471
|
+
* @param config - Configuração do Intercom
|
|
3472
|
+
* @returns Integração configurada para o Intercom
|
|
3388
3473
|
* @since 0.4.1
|
|
3389
|
-
* Valida se todas as integrações têm suas categorias habilitadas.
|
|
3390
|
-
* Útil para validação em tempo de execução.
|
|
3391
3474
|
*
|
|
3392
|
-
* @
|
|
3393
|
-
*
|
|
3394
|
-
*
|
|
3475
|
+
* @example
|
|
3476
|
+
* ```typescript
|
|
3477
|
+
* const intercom = createIntercomIntegration({
|
|
3478
|
+
* app_id: 'your-app-id'
|
|
3479
|
+
* })
|
|
3480
|
+
* ```
|
|
3481
|
+
*
|
|
3482
|
+
* @remarks
|
|
3483
|
+
* - Define cookies: intercom-id-*, intercom-session-*
|
|
3484
|
+
* - Categoria padrão: 'functional'
|
|
3485
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3486
|
+
* - Inclui tratamento de erro na inicialização
|
|
3395
3487
|
*/
|
|
3396
|
-
declare function
|
|
3488
|
+
declare function createIntercomIntegration(config: IntercomConfig): ScriptIntegration;
|
|
3397
3489
|
/**
|
|
3398
|
-
*
|
|
3490
|
+
* Cria integração do Zendesk Chat.
|
|
3491
|
+
* Configura o widget de chat e suporte do Zendesk.
|
|
3492
|
+
*
|
|
3399
3493
|
* @category Utils
|
|
3494
|
+
* @param config - Configuração do Zendesk Chat
|
|
3495
|
+
* @returns Integração configurada para o Zendesk Chat
|
|
3400
3496
|
* @since 0.4.1
|
|
3401
|
-
* Extrai categorias únicas de um array de integrações
|
|
3402
3497
|
*
|
|
3403
|
-
* @
|
|
3404
|
-
*
|
|
3498
|
+
* @example
|
|
3499
|
+
* ```typescript
|
|
3500
|
+
* const zendesk = createZendeskChatIntegration({
|
|
3501
|
+
* key: 'your-zendesk-key'
|
|
3502
|
+
* })
|
|
3503
|
+
* ```
|
|
3504
|
+
*
|
|
3505
|
+
* @remarks
|
|
3506
|
+
* - Define cookies: __zlcmid, _zendesk_shared_session
|
|
3507
|
+
* - Categoria padrão: 'functional'
|
|
3508
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3509
|
+
* - Inclui tratamento de erro na identificação
|
|
3405
3510
|
*/
|
|
3406
|
-
declare function
|
|
3511
|
+
declare function createZendeskChatIntegration(config: ZendeskConfig): ScriptIntegration;
|
|
3407
3512
|
/**
|
|
3408
|
-
*
|
|
3513
|
+
* Configuração para conjunto de integrações de e-commerce.
|
|
3514
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para e-commerce.
|
|
3515
|
+
*
|
|
3409
3516
|
* @category Utils
|
|
3410
3517
|
* @since 0.4.1
|
|
3411
|
-
* Valida se integrações estão sendo incorretamente classificadas como "necessary".
|
|
3412
|
-
*
|
|
3413
|
-
* Esta função protege contra violações de GDPR/LGPD identificando scripts que
|
|
3414
|
-
* NUNCA devem ser considerados estritamente necessários.
|
|
3415
|
-
*
|
|
3416
|
-
* @param integrations Array de integrações para validar
|
|
3417
|
-
* @param enabledCategories Categorias habilitadas na configuração
|
|
3418
|
-
* @returns Lista de avisos sobre classificações incorretas
|
|
3419
3518
|
*
|
|
3420
3519
|
* @example
|
|
3421
3520
|
* ```typescript
|
|
3422
|
-
* const
|
|
3423
|
-
*
|
|
3424
|
-
*
|
|
3425
|
-
* ], ['necessary', 'analytics'])
|
|
3426
|
-
*
|
|
3427
|
-
* if (warnings.length > 0) {
|
|
3428
|
-
* console.warn('Scripts incorretamente classificados como necessary:', warnings)
|
|
3521
|
+
* const config: ECommerceConfig = {
|
|
3522
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3523
|
+
* facebookPixel: { pixelId: '1234567890123456' }
|
|
3429
3524
|
* }
|
|
3430
3525
|
* ```
|
|
3431
3526
|
*/
|
|
3432
|
-
|
|
3433
|
-
|
|
3527
|
+
interface ECommerceConfig {
|
|
3528
|
+
/** Configuração do Google Analytics */
|
|
3529
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
3530
|
+
/** Configuração do Facebook Pixel */
|
|
3531
|
+
facebookPixel?: FacebookPixelConfig;
|
|
3532
|
+
/** Configuração do Hotjar */
|
|
3533
|
+
hotjar?: HotjarConfig;
|
|
3534
|
+
/** Configuração do UserWay */
|
|
3535
|
+
userway?: UserWayConfig;
|
|
3536
|
+
}
|
|
3434
3537
|
/**
|
|
3435
|
-
*
|
|
3538
|
+
* Configuração para conjunto de integrações de SaaS.
|
|
3539
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para SaaS.
|
|
3436
3540
|
*
|
|
3437
3541
|
* @category Utils
|
|
3438
|
-
* @since 0.
|
|
3542
|
+
* @since 0.4.1
|
|
3543
|
+
*
|
|
3544
|
+
* @example
|
|
3545
|
+
* ```typescript
|
|
3546
|
+
* const config: SaaSConfig = {
|
|
3547
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3548
|
+
* mixpanel: { token: 'your-token' },
|
|
3549
|
+
* intercom: { app_id: 'your-app-id' }
|
|
3550
|
+
* }
|
|
3551
|
+
* ```
|
|
3439
3552
|
*/
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
/**
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
* Overrides de descrições por categoria.
|
|
3450
|
-
*/
|
|
3451
|
-
descriptions?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3452
|
-
/**
|
|
3453
|
-
* Overrides de nomes por categoria.
|
|
3454
|
-
*/
|
|
3455
|
-
names?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3553
|
+
interface SaaSConfig {
|
|
3554
|
+
/** Configuração do Google Analytics */
|
|
3555
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
3556
|
+
/** Configuração do Mixpanel */
|
|
3557
|
+
mixpanel?: MixpanelConfig;
|
|
3558
|
+
/** Configuração do Intercom */
|
|
3559
|
+
intercom?: IntercomConfig;
|
|
3560
|
+
/** Configuração do Hotjar */
|
|
3561
|
+
hotjar?: HotjarConfig;
|
|
3456
3562
|
}
|
|
3457
3563
|
/**
|
|
3458
|
-
*
|
|
3564
|
+
* Configuração para conjunto de integrações corporativas.
|
|
3565
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para ambientes corporativos.
|
|
3459
3566
|
*
|
|
3460
3567
|
* @category Utils
|
|
3461
|
-
* @since 0.
|
|
3568
|
+
* @since 0.4.1
|
|
3569
|
+
*
|
|
3570
|
+
* @example
|
|
3571
|
+
* ```typescript
|
|
3572
|
+
* const config: CorporateConfig = {
|
|
3573
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3574
|
+
* clarity: { projectId: 'abcdefghij' },
|
|
3575
|
+
* userway: { accountId: 'XXXXXXXXXX' }
|
|
3576
|
+
* }
|
|
3577
|
+
* ```
|
|
3462
3578
|
*/
|
|
3463
|
-
|
|
3464
|
-
|
|
3579
|
+
interface CorporateConfig {
|
|
3580
|
+
/** Configuração do Google Analytics */
|
|
3581
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
3582
|
+
/** Configuração do Microsoft Clarity */
|
|
3583
|
+
clarity?: ClarityConfig;
|
|
3584
|
+
/** Configuração do Zendesk Chat */
|
|
3585
|
+
zendesk?: ZendeskConfig;
|
|
3586
|
+
/** Configuração do UserWay */
|
|
3587
|
+
userway?: UserWayConfig;
|
|
3588
|
+
}
|
|
3465
3589
|
/**
|
|
3466
|
-
*
|
|
3467
|
-
*
|
|
3468
|
-
* contextos específicos e variações de tom.
|
|
3590
|
+
* Cria conjunto de integrações otimizado para e-commerce.
|
|
3591
|
+
* Combina analytics de conversão, remarketing e acessibilidade.
|
|
3469
3592
|
*
|
|
3470
|
-
* @
|
|
3593
|
+
* @category Utils
|
|
3594
|
+
* @param cfg - Configuração das integrações de e-commerce
|
|
3595
|
+
* @returns Array de integrações configuradas
|
|
3471
3596
|
* @since 0.4.1
|
|
3597
|
+
*
|
|
3598
|
+
* @example
|
|
3599
|
+
* ```typescript
|
|
3600
|
+
* const integrations = createECommerceIntegrations({
|
|
3601
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3602
|
+
* facebookPixel: { pixelId: '1234567890123456' }
|
|
3603
|
+
* })
|
|
3604
|
+
* ```
|
|
3605
|
+
*
|
|
3606
|
+
* @remarks
|
|
3607
|
+
* Combina categorias: analytics, marketing, functional
|
|
3472
3608
|
*/
|
|
3473
|
-
|
|
3609
|
+
declare function createECommerceIntegrations(cfg: ECommerceConfig): ScriptIntegration[];
|
|
3474
3610
|
/**
|
|
3475
|
-
*
|
|
3476
|
-
*
|
|
3477
|
-
* Define um subconjunto opcional dos textos principais do banner e modal,
|
|
3478
|
-
* permitindo variações de t es: {
|
|
3479
|
-
bannerMessage: 'Utilizamos cookies para mejorar su experiencia y mostrar contenido personalizado.', (formal, casual, etc.) sem sobrescrever todos os textos.
|
|
3611
|
+
* Cria conjunto de integrações otimizado para SaaS.
|
|
3612
|
+
* Combina analytics de produto, suporte ao cliente e comportamento do usuário.
|
|
3480
3613
|
*
|
|
3481
|
-
* @category
|
|
3614
|
+
* @category Utils
|
|
3615
|
+
* @param cfg - Configuração das integrações de SaaS
|
|
3616
|
+
* @returns Array de integrações configuradas
|
|
3482
3617
|
* @since 0.4.1
|
|
3618
|
+
*
|
|
3619
|
+
* @example
|
|
3620
|
+
* ```typescript
|
|
3621
|
+
* const integrations = createSaaSIntegrations({
|
|
3622
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3623
|
+
* mixpanel: { token: 'your-project-token' },
|
|
3624
|
+
* intercom: { app_id: 'your-app-id' }
|
|
3625
|
+
* })
|
|
3626
|
+
* ```
|
|
3627
|
+
*
|
|
3628
|
+
* @remarks
|
|
3629
|
+
* Combina categorias: analytics, functional
|
|
3483
3630
|
*/
|
|
3484
|
-
|
|
3631
|
+
declare function createSaaSIntegrations(cfg: SaaSConfig): ScriptIntegration[];
|
|
3485
3632
|
/**
|
|
3486
|
-
*
|
|
3487
|
-
*
|
|
3488
|
-
* Define um subconjunto dos textos principais, excluindo propriedades específicas de internacionalização
|
|
3489
|
-
* e contextos, para uso em configurações multilíngues.
|
|
3633
|
+
* Cria conjunto de integrações otimizado para ambientes corporativos.
|
|
3634
|
+
* Combina analytics empresariais, compliance e suporte corporativo.
|
|
3490
3635
|
*
|
|
3491
|
-
* @category
|
|
3636
|
+
* @category Utils
|
|
3637
|
+
* @param cfg - Configuração das integrações corporativas
|
|
3638
|
+
* @returns Array de integrações configuradas
|
|
3492
3639
|
* @since 0.4.1
|
|
3640
|
+
*
|
|
3641
|
+
* @example
|
|
3642
|
+
* ```typescript
|
|
3643
|
+
* const integrations = createCorporateIntegrations({
|
|
3644
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3645
|
+
* clarity: { projectId: 'abcdefghij' },
|
|
3646
|
+
* userway: { accountId: 'XXXXXXXXXX' }
|
|
3647
|
+
* })
|
|
3648
|
+
* ```
|
|
3649
|
+
*
|
|
3650
|
+
* @remarks
|
|
3651
|
+
* Combina categorias: analytics, functional
|
|
3493
3652
|
*/
|
|
3494
|
-
|
|
3653
|
+
declare function createCorporateIntegrations(cfg: CorporateConfig): ScriptIntegration[];
|
|
3495
3654
|
/**
|
|
3496
|
-
*
|
|
3497
|
-
*
|
|
3498
|
-
* Interface expandida que permite personalização granular de todas as mensagens da biblioteca.
|
|
3499
|
-
* Suporta múltiplos idiomas, contextos específicos (e-commerce, SaaS, governo), variações
|
|
3500
|
-
* de tom, e compliance completo com LGPD.
|
|
3655
|
+
* Templates pré-configurados de integrações por tipo de negócio.
|
|
3656
|
+
* Define integrações essenciais e opcionais para cada contexto.
|
|
3501
3657
|
*
|
|
3502
|
-
* @category
|
|
3658
|
+
* @category Utils
|
|
3503
3659
|
* @since 0.4.1
|
|
3504
|
-
* @remarks
|
|
3505
|
-
* **Histórico**: v0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
3506
3660
|
*
|
|
3507
|
-
* @example
|
|
3661
|
+
* @example
|
|
3508
3662
|
* ```typescript
|
|
3509
|
-
* const
|
|
3510
|
-
*
|
|
3511
|
-
*
|
|
3512
|
-
* acceptAll: 'Aceitar todos',
|
|
3513
|
-
* declineAll: 'Recusar',
|
|
3514
|
-
* preferences: 'Preferências',
|
|
3515
|
-
* modalTitle: 'Preferências de Cookies',
|
|
3516
|
-
* modalIntro: 'Personalize suas preferências de cookies.',
|
|
3517
|
-
* save: 'Salvar',
|
|
3518
|
-
* necessaryAlwaysOn: 'Cookies necessários (sempre ativos)',
|
|
3519
|
-
*
|
|
3520
|
-
* // Textos expandidos
|
|
3521
|
-
* variants: {
|
|
3522
|
-
* formal: {
|
|
3523
|
-
* bannerMessage: 'Este sítio utiliza cookies para otimizar a experiência de navegação.',
|
|
3524
|
-
* acceptAll: 'Concordar com todos os cookies'
|
|
3525
|
-
* },
|
|
3526
|
-
* casual: {
|
|
3527
|
-
* bannerMessage: '🍪 Olá! Usamos cookies para tornar tudo mais gostoso aqui.',
|
|
3528
|
-
* acceptAll: 'Aceitar tudo'
|
|
3529
|
-
* }
|
|
3530
|
-
* },
|
|
3531
|
-
*
|
|
3532
|
-
* // Internacionalização
|
|
3533
|
-
* i18n: {
|
|
3534
|
-
* en: {
|
|
3535
|
-
* bannerMessage: 'We use cookies to enhance your experience.',
|
|
3536
|
-
* acceptAll: 'Accept All',
|
|
3537
|
-
* declineAll: 'Decline'
|
|
3538
|
-
* },
|
|
3539
|
-
* es: {
|
|
3540
|
-
* bannerMessage: 'Utilizamos cookies para mejorar su experiencia.',
|
|
3541
|
-
* acceptAll: 'Aceptar Todo',
|
|
3542
|
-
* declineAll: 'Rechazar'
|
|
3543
|
-
* }
|
|
3544
|
-
* }
|
|
3545
|
-
* }
|
|
3663
|
+
* const template = INTEGRATION_TEMPLATES.ecommerce
|
|
3664
|
+
* console.log(template.essential) // ['google-analytics', 'facebook-pixel']
|
|
3665
|
+
* console.log(template.categories) // ['analytics', 'marketing', 'functional']
|
|
3546
3666
|
* ```
|
|
3667
|
+
*
|
|
3668
|
+
* @remarks
|
|
3669
|
+
* Cada template define:
|
|
3670
|
+
* - essential: integrações obrigatórias/recomendadas
|
|
3671
|
+
* - optional: integrações complementares
|
|
3672
|
+
* - categories: categorias LGPD utilizadas
|
|
3547
3673
|
*/
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
/** Texto de carregamento */
|
|
3554
|
-
loading?: string;
|
|
3555
|
-
/** Textos específicos para cada categoria de cookie */
|
|
3556
|
-
categories?: {
|
|
3557
|
-
necessary?: {
|
|
3558
|
-
name?: string;
|
|
3559
|
-
description?: string;
|
|
3560
|
-
examples?: string;
|
|
3561
|
-
};
|
|
3562
|
-
analytics?: {
|
|
3563
|
-
name?: string;
|
|
3564
|
-
description?: string;
|
|
3565
|
-
examples?: string;
|
|
3566
|
-
};
|
|
3567
|
-
marketing?: {
|
|
3568
|
-
name?: string;
|
|
3569
|
-
description?: string;
|
|
3570
|
-
examples?: string;
|
|
3571
|
-
};
|
|
3572
|
-
functional?: {
|
|
3573
|
-
name?: string;
|
|
3574
|
-
description?: string;
|
|
3575
|
-
examples?: string;
|
|
3576
|
-
};
|
|
3577
|
-
performance?: {
|
|
3578
|
-
name?: string;
|
|
3579
|
-
description?: string;
|
|
3580
|
-
examples?: string;
|
|
3581
|
-
};
|
|
3582
|
-
};
|
|
3583
|
-
/** Mensagens de feedback ao usuário */
|
|
3584
|
-
feedback?: {
|
|
3585
|
-
/** Preferências salvas com sucesso */
|
|
3586
|
-
saveSuccess?: string;
|
|
3587
|
-
/** Erro ao salvar preferências */
|
|
3588
|
-
saveError?: string;
|
|
3589
|
-
/** Consentimento atualizado */
|
|
3590
|
-
consentUpdated?: string;
|
|
3591
|
-
/** Cookies rejeitados */
|
|
3592
|
-
cookiesRejected?: string;
|
|
3593
|
-
/** Configurações resetadas */
|
|
3594
|
-
settingsReset?: string;
|
|
3595
|
-
};
|
|
3596
|
-
/** Labels ARIA e textos para leitores de tela */
|
|
3597
|
-
accessibility?: {
|
|
3598
|
-
/** Label do banner para leitores de tela */
|
|
3599
|
-
bannerLabel?: string;
|
|
3600
|
-
/** Label do modal para leitores de tela */
|
|
3601
|
-
modalLabel?: string;
|
|
3602
|
-
/** Instrução de navegação por teclado */
|
|
3603
|
-
keyboardNavigation?: string;
|
|
3604
|
-
/** Estado do toggle de categoria */
|
|
3605
|
-
toggleState?: {
|
|
3606
|
-
enabled?: string;
|
|
3607
|
-
disabled?: string;
|
|
3608
|
-
};
|
|
3609
|
-
/** Região live para anúncios dinâmicos */
|
|
3610
|
-
liveRegion?: string;
|
|
3611
|
-
};
|
|
3612
|
-
/** Textos otimizados para diferentes contextos */
|
|
3613
|
-
contexts?: {
|
|
3614
|
-
/** Contexto e-commerce */
|
|
3615
|
-
ecommerce?: {
|
|
3616
|
-
cartAbandonment?: string;
|
|
3617
|
-
personalizedOffers?: string;
|
|
3618
|
-
paymentSecurity?: string;
|
|
3619
|
-
productRecommendations?: string;
|
|
3620
|
-
};
|
|
3621
|
-
/** Contexto SaaS */
|
|
3622
|
-
saas?: {
|
|
3623
|
-
userAnalytics?: string;
|
|
3624
|
-
performanceMonitoring?: string;
|
|
3625
|
-
featureUsage?: string;
|
|
3626
|
-
customerSupport?: string;
|
|
3627
|
-
};
|
|
3628
|
-
/** Contexto governamental */
|
|
3629
|
-
government?: {
|
|
3630
|
-
citizenServices?: string;
|
|
3631
|
-
dataProtection?: string;
|
|
3632
|
-
transparency?: string;
|
|
3633
|
-
accessibility?: string;
|
|
3634
|
-
};
|
|
3635
|
-
/** Contexto educacional */
|
|
3636
|
-
education?: {
|
|
3637
|
-
studentProgress?: string;
|
|
3638
|
-
learningAnalytics?: string;
|
|
3639
|
-
accessibility?: string;
|
|
3640
|
-
parentalConsent?: string;
|
|
3641
|
-
};
|
|
3642
|
-
};
|
|
3643
|
-
/** Diferentes variações de tom para a mesma mensagem */
|
|
3644
|
-
variants?: {
|
|
3645
|
-
/** Tom formal/profissional */
|
|
3646
|
-
formal?: TextVariant;
|
|
3647
|
-
/** Tom casual/amigável */
|
|
3648
|
-
casual?: TextVariant;
|
|
3649
|
-
/** Tom conciso/direto */
|
|
3650
|
-
concise?: TextVariant;
|
|
3651
|
-
/** Tom detalhado/explicativo */
|
|
3652
|
-
detailed?: TextVariant;
|
|
3653
|
-
};
|
|
3654
|
-
/** Suporte a múltiplos idiomas */
|
|
3655
|
-
i18n?: {
|
|
3656
|
-
/** Textos em inglês */
|
|
3657
|
-
en?: LanguageTexts;
|
|
3658
|
-
/** Textos em espanhol */
|
|
3659
|
-
es?: LanguageTexts;
|
|
3660
|
-
/** Textos em francês */
|
|
3661
|
-
fr?: LanguageTexts;
|
|
3662
|
-
/** Textos em alemão */
|
|
3663
|
-
de?: LanguageTexts;
|
|
3664
|
-
/** Textos em italiano */
|
|
3665
|
-
it?: LanguageTexts;
|
|
3674
|
+
declare const INTEGRATION_TEMPLATES: {
|
|
3675
|
+
ecommerce: {
|
|
3676
|
+
essential: string[];
|
|
3677
|
+
optional: string[];
|
|
3678
|
+
categories: string[];
|
|
3666
3679
|
};
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
/** Explicação sobre cookies persistentes */
|
|
3672
|
-
persistentCookies?: string;
|
|
3673
|
-
/** Explicação sobre cookies de terceiros */
|
|
3674
|
-
thirdPartyCookies?: string;
|
|
3675
|
-
/** Como desabilitar cookies no navegador */
|
|
3676
|
-
browserSettings?: string;
|
|
3677
|
-
/** Impacto de desabilitar cookies */
|
|
3678
|
-
disablingImpact?: string;
|
|
3680
|
+
saas: {
|
|
3681
|
+
essential: string[];
|
|
3682
|
+
optional: string[];
|
|
3683
|
+
categories: string[];
|
|
3679
3684
|
};
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
purpose?: string;
|
|
3685
|
-
duration?: string;
|
|
3686
|
-
provider?: string;
|
|
3687
|
-
type?: string;
|
|
3688
|
-
};
|
|
3689
|
-
/** Texto quando não há cookies para mostrar */
|
|
3690
|
-
noCookies?: string;
|
|
3691
|
-
/** Botão para expandir/colapsar detalhes */
|
|
3692
|
-
toggleDetails?: {
|
|
3693
|
-
expand?: string;
|
|
3694
|
-
collapse?: string;
|
|
3695
|
-
};
|
|
3685
|
+
corporate: {
|
|
3686
|
+
essential: string[];
|
|
3687
|
+
optional: string[];
|
|
3688
|
+
categories: string[];
|
|
3696
3689
|
};
|
|
3690
|
+
};
|
|
3691
|
+
/**
|
|
3692
|
+
* Sugere categorias LGPD apropriadas para um script baseado no nome/tipo.
|
|
3693
|
+
* Utiliza heurísticas para classificar scripts desconhecidos.
|
|
3694
|
+
*
|
|
3695
|
+
* @category Utils
|
|
3696
|
+
* @param name - Nome ou identificador do script
|
|
3697
|
+
* @returns Array de categorias sugeridas
|
|
3698
|
+
* @since 0.4.1
|
|
3699
|
+
*
|
|
3700
|
+
* @example
|
|
3701
|
+
* ```typescript
|
|
3702
|
+
* suggestCategoryForScript('facebook-pixel') // ['marketing']
|
|
3703
|
+
* suggestCategoryForScript('hotjar') // ['analytics']
|
|
3704
|
+
* suggestCategoryForScript('intercom-chat') // ['functional']
|
|
3705
|
+
* suggestCategoryForScript('unknown-script') // ['analytics']
|
|
3706
|
+
* ```
|
|
3707
|
+
*
|
|
3708
|
+
* @remarks
|
|
3709
|
+
* Heurísticas aplicadas:
|
|
3710
|
+
* - Scripts de ads/marketing → 'marketing'
|
|
3711
|
+
* - Scripts de analytics/tracking → 'analytics'
|
|
3712
|
+
* - Scripts de chat/suporte → 'functional'
|
|
3713
|
+
* - Padrão para desconhecidos → 'analytics'
|
|
3714
|
+
*/
|
|
3715
|
+
declare function suggestCategoryForScript(name: string): string[];
|
|
3716
|
+
|
|
3717
|
+
/**
|
|
3718
|
+
* Componente que carrega scripts automaticamente baseado no consentimento.
|
|
3719
|
+
* Facilita integração com ferramentas como Google Analytics, Tag Manager, etc.
|
|
3720
|
+
*/
|
|
3721
|
+
|
|
3722
|
+
interface RegisteredScript {
|
|
3723
|
+
id: string;
|
|
3724
|
+
category: string;
|
|
3725
|
+
execute: () => void | Promise<void>;
|
|
3726
|
+
priority?: number;
|
|
3727
|
+
allowReload?: boolean;
|
|
3728
|
+
onConsentUpdate?: (consent: {
|
|
3729
|
+
consented: boolean;
|
|
3730
|
+
preferences: ConsentPreferences;
|
|
3731
|
+
}) => void;
|
|
3697
3732
|
}
|
|
3698
3733
|
/**
|
|
3699
|
-
*
|
|
3734
|
+
* Registra um script (inline ou externo) na fila controlada por consentimento.
|
|
3735
|
+
*
|
|
3736
|
+
* @remarks
|
|
3737
|
+
* - Scripts `necessary` rodam imediatamente; demais aguardam consentimento da categoria.
|
|
3738
|
+
* - Fluxo de estados: `pending` → `running` → `executed` (respeitando `allowReload` e `onConsentUpdate`).
|
|
3739
|
+
* - A fila é ordenada por categoria, `priority` (maior primeiro) e ordem de registro.
|
|
3740
|
+
* - `allowReload` permite reexecutar scripts quando o usuário muda preferências.
|
|
3741
|
+
* - Use `onConsentUpdate` para reenviar sinais (ex.: Consent Mode) após novas decisões.
|
|
3742
|
+
* - Sempre chame o cleanup retornado em efeitos React para evitar múltiplos registros do mesmo `id`.
|
|
3743
|
+
*
|
|
3744
|
+
* @param def Definição do script a ser registrado.
|
|
3745
|
+
* @returns Função de cleanup para remover o script da fila.
|
|
3746
|
+
*/
|
|
3747
|
+
declare function registerScript(def: RegisteredScript): () => void;
|
|
3748
|
+
/**
|
|
3749
|
+
* Props do ConsentScriptLoader.
|
|
3700
3750
|
*
|
|
3751
|
+
* @category Types
|
|
3752
|
+
* @since 0.2.0
|
|
3753
|
+
*
|
|
3754
|
+
* @example
|
|
3755
|
+
* ```tsx
|
|
3756
|
+
* <ConsentScriptLoader
|
|
3757
|
+
* integrations={[COMMON_INTEGRATIONS.googleTagManager({ containerId: 'GTM-XXXX' })]}
|
|
3758
|
+
* reloadOnChange
|
|
3759
|
+
* />
|
|
3760
|
+
* ```
|
|
3761
|
+
*/
|
|
3762
|
+
interface ConsentScriptLoaderProps {
|
|
3763
|
+
/** Lista de integrações de scripts para carregar baseado no consentimento */
|
|
3764
|
+
integrations: ScriptIntegration[];
|
|
3765
|
+
/** Se true, força recarregamento se consentimento mudar */
|
|
3766
|
+
reloadOnChange?: boolean;
|
|
3767
|
+
/** Nonce CSP aplicado às tags <script> geradas automaticamente (sobrescrevível por integração). */
|
|
3768
|
+
nonce?: string;
|
|
3769
|
+
}
|
|
3770
|
+
/**
|
|
3771
|
+
* @component
|
|
3701
3772
|
* @category Utils
|
|
3773
|
+
* @since 0.2.0
|
|
3774
|
+
* Componente que não renderiza UI, mas gerencia o carregamento de scripts de terceiros
|
|
3775
|
+
* (como Google Analytics) com base nas preferências de consentimento do usuário.
|
|
3776
|
+
*
|
|
3777
|
+
* @param props As propriedades do componente.
|
|
3778
|
+
* @param {ScriptIntegration[]} props.integrations Um array de objetos de integração de script. Use as factory functions (`createGoogleAnalyticsIntegration`, etc.) para criar.
|
|
3779
|
+
* @param {boolean} [props.reloadOnChange=false] Se `true`, recarrega os scripts se as preferências de consentimento mudarem.
|
|
3780
|
+
*
|
|
3781
|
+
* @example
|
|
3782
|
+
* ```tsx
|
|
3783
|
+
* const integrations = [
|
|
3784
|
+
* createGoogleAnalyticsIntegration({ measurementId: 'GA_ID' }),
|
|
3785
|
+
* createFacebookPixelIntegration({ pixelId: 'PIXEL_ID' })
|
|
3786
|
+
* ];
|
|
3787
|
+
*
|
|
3788
|
+
* <ConsentScriptLoader integrations={integrations} />
|
|
3789
|
+
* ```
|
|
3790
|
+
*
|
|
3791
|
+
* @example
|
|
3792
|
+
* ```tsx
|
|
3793
|
+
* <ConsentScriptLoader
|
|
3794
|
+
* integrations={[COMMON_INTEGRATIONS.googleTagManager({ containerId: 'GTM-XXXX' })]}
|
|
3795
|
+
* nonce="csp-nonce"
|
|
3796
|
+
* />
|
|
3797
|
+
* ```
|
|
3798
|
+
*/
|
|
3799
|
+
declare function ConsentScriptLoader({ integrations, reloadOnChange, nonce, }: Readonly<ConsentScriptLoaderProps>): null;
|
|
3800
|
+
/**
|
|
3801
|
+
* @hook
|
|
3802
|
+
* @category Hooks
|
|
3803
|
+
* @since 0.2.0
|
|
3804
|
+
* Hook para carregamento programático de um script baseado no consentimento.
|
|
3805
|
+
*
|
|
3806
|
+
* @returns Uma função assíncrona que recebe um objeto de integração de script e tenta carregá-lo.
|
|
3807
|
+
* Retorna `true` em caso de sucesso e `false` em caso de falha (por falta de consentimento ou erro de rede).
|
|
3808
|
+
*
|
|
3809
|
+
* @example
|
|
3810
|
+
* ```tsx
|
|
3811
|
+
* const loadScript = useConsentScriptLoader();
|
|
3812
|
+
*
|
|
3813
|
+
* useEffect(() => {
|
|
3814
|
+
* const handleUserAction = async () => {
|
|
3815
|
+
* const hotjarIntegration = { id: 'hotjar', category: 'analytics', src: '...' };
|
|
3816
|
+
* const success = await loadScript(hotjarIntegration);
|
|
3817
|
+
* if (success) {
|
|
3818
|
+
* console.log('Hotjar carregado com sucesso!');
|
|
3819
|
+
* }
|
|
3820
|
+
* };
|
|
3821
|
+
*
|
|
3822
|
+
* // Exemplo: carregar script após uma ação específica do usuário
|
|
3823
|
+
* myButton.addEventListener('click', handleUserAction);
|
|
3824
|
+
* }, [loadScript]);
|
|
3825
|
+
* ```
|
|
3826
|
+
*/
|
|
3827
|
+
declare function useConsentScriptLoader(): (integration: ScriptIntegration, nonce?: string) => Promise<boolean>;
|
|
3828
|
+
|
|
3829
|
+
/**
|
|
3830
|
+
* @file autoConfigureCategories.ts
|
|
3831
|
+
* @description Sistema inteligente de auto-habilitação de categorias baseado nas integrações utilizadas
|
|
3702
3832
|
* @since 0.4.1
|
|
3703
3833
|
*/
|
|
3704
|
-
|
|
3834
|
+
|
|
3705
3835
|
/**
|
|
3706
|
-
*
|
|
3836
|
+
* @interface CategoryAutoConfigResult
|
|
3837
|
+
* Resultado da análise e auto-configuração de categorias
|
|
3838
|
+
*/
|
|
3839
|
+
interface CategoryAutoConfigResult {
|
|
3840
|
+
/** Configuração original fornecida pelo desenvolvedor */
|
|
3841
|
+
originalConfig: ProjectCategoriesConfig;
|
|
3842
|
+
/** Configuração ajustada automaticamente pela biblioteca */
|
|
3843
|
+
adjustedConfig: ProjectCategoriesConfig;
|
|
3844
|
+
/** Categorias que foram automaticamente habilitadas */
|
|
3845
|
+
autoEnabledCategories: string[];
|
|
3846
|
+
/** Categorias requeridas pelas integrações mas não habilitadas */
|
|
3847
|
+
missingCategories: string[];
|
|
3848
|
+
/** Se algum ajuste foi necessário */
|
|
3849
|
+
wasAdjusted: boolean;
|
|
3850
|
+
/** Integrações que requerem cada categoria */
|
|
3851
|
+
categoryIntegrations: Record<string, string[]>;
|
|
3852
|
+
}
|
|
3853
|
+
/**
|
|
3854
|
+
* @function
|
|
3855
|
+
* @category Utils
|
|
3856
|
+
* @since 0.4.1
|
|
3857
|
+
* Analisa as integrações fornecidas e determina quais categorias são necessárias.
|
|
3707
3858
|
*
|
|
3859
|
+
* @param integrations Array de integrações de script
|
|
3860
|
+
* @returns Record mapeando categoria para nomes das integrações que a utilizam
|
|
3861
|
+
*/
|
|
3862
|
+
declare function analyzeIntegrationCategories(integrations: ScriptIntegration[]): Record<string, string[]>;
|
|
3863
|
+
/**
|
|
3864
|
+
* @function
|
|
3708
3865
|
* @category Utils
|
|
3709
3866
|
* @since 0.4.1
|
|
3867
|
+
* Configura automaticamente as categorias necessárias baseado nas integrações utilizadas.
|
|
3710
3868
|
*
|
|
3711
|
-
*
|
|
3712
|
-
*
|
|
3713
|
-
*
|
|
3869
|
+
* Esta função implementa o comportamento inteligente da biblioteca:
|
|
3870
|
+
* 1. Detecta categorias requeridas pelas integrações
|
|
3871
|
+
* 2. Auto-habilita categorias em falta (modo padrão)
|
|
3872
|
+
* 3. Ou apenas avisa sobre categorias em falta (modo warning-only)
|
|
3873
|
+
* 4. Loga no console em modo DEV
|
|
3874
|
+
*
|
|
3875
|
+
* @param originalConfig Configuração original do ConsentProvider
|
|
3876
|
+
* @param integrations Array de integrações que serão utilizadas
|
|
3877
|
+
* @param options Opções de comportamento
|
|
3878
|
+
* @returns Resultado da análise e configuração automática
|
|
3714
3879
|
*/
|
|
3715
|
-
declare function
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3880
|
+
declare function autoConfigureCategories(originalConfig: ProjectCategoriesConfig | undefined, integrations: ScriptIntegration[], options?: {
|
|
3881
|
+
/** Se true, apenas avisa mas não modifica a config (padrão: false - auto-habilita) */
|
|
3882
|
+
warningOnly?: boolean;
|
|
3883
|
+
/** Se true, desabilita logs no console (padrão: false) */
|
|
3884
|
+
silent?: boolean;
|
|
3885
|
+
}): CategoryAutoConfigResult;
|
|
3720
3886
|
/**
|
|
3721
|
-
*
|
|
3887
|
+
* @function
|
|
3888
|
+
* @category Utils
|
|
3889
|
+
* @since 0.4.1
|
|
3890
|
+
* Valida se todas as integrações têm suas categorias habilitadas.
|
|
3891
|
+
* Útil para validação em tempo de execução.
|
|
3892
|
+
*
|
|
3893
|
+
* @param integrations Array de integrações
|
|
3894
|
+
* @param enabledCategories Array de categorias habilitadas
|
|
3895
|
+
* @returns true se todas as categorias necessárias estão habilitadas
|
|
3896
|
+
*/
|
|
3897
|
+
declare function validateIntegrationCategories(integrations: ScriptIntegration[], enabledCategories: string[]): boolean;
|
|
3898
|
+
/**
|
|
3899
|
+
* @function
|
|
3900
|
+
* @category Utils
|
|
3901
|
+
* @since 0.4.1
|
|
3902
|
+
* Extrai categorias únicas de um array de integrações
|
|
3722
3903
|
*
|
|
3904
|
+
* @param integrations Array de integrações
|
|
3905
|
+
* @returns Array de categorias únicas
|
|
3906
|
+
*/
|
|
3907
|
+
declare function extractCategoriesFromIntegrations(integrations: ScriptIntegration[]): string[];
|
|
3908
|
+
/**
|
|
3909
|
+
* @function
|
|
3723
3910
|
* @category Utils
|
|
3724
3911
|
* @since 0.4.1
|
|
3912
|
+
* Valida se integrações estão sendo incorretamente classificadas como "necessary".
|
|
3913
|
+
*
|
|
3914
|
+
* Esta função protege contra violações de GDPR/LGPD identificando scripts que
|
|
3915
|
+
* NUNCA devem ser considerados estritamente necessários.
|
|
3916
|
+
*
|
|
3917
|
+
* @param integrations Array de integrações para validar
|
|
3918
|
+
* @param enabledCategories Categorias habilitadas na configuração
|
|
3919
|
+
* @returns Lista de avisos sobre classificações incorretas
|
|
3920
|
+
*
|
|
3921
|
+
* @example
|
|
3922
|
+
* ```typescript
|
|
3923
|
+
* const warnings = validateNecessaryClassification([
|
|
3924
|
+
* createGoogleAnalyticsIntegration({...}), // ❌ NUNCA é necessary
|
|
3925
|
+
* createCustomIntegration({...}) // ✅ Pode ser necessary se apropriado
|
|
3926
|
+
* ], ['necessary', 'analytics'])
|
|
3927
|
+
*
|
|
3928
|
+
* if (warnings.length > 0) {
|
|
3929
|
+
* console.warn('Scripts incorretamente classificados como necessary:', warnings)
|
|
3930
|
+
* }
|
|
3931
|
+
* ```
|
|
3725
3932
|
*/
|
|
3726
|
-
declare
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3933
|
+
declare function validateNecessaryClassification(integrations: ScriptIntegration[], enabledCategories: Category[]): string[];
|
|
3934
|
+
|
|
3935
|
+
/**
|
|
3936
|
+
* Presets de categorias conforme usos típicos da LGPD/ANPD.
|
|
3937
|
+
*
|
|
3938
|
+
* @category Utils
|
|
3939
|
+
* @since 0.6.4
|
|
3940
|
+
*/
|
|
3941
|
+
declare const ANPD_CATEGORY_PRESETS: Record<Category, CategoryDefinition>;
|
|
3942
|
+
type AnpdPresetCategory = keyof typeof ANPD_CATEGORY_PRESETS;
|
|
3943
|
+
interface CreateAnpdCategoriesOptions {
|
|
3944
|
+
/**
|
|
3945
|
+
* Lista de categorias que devem ser habilitadas (além de necessary que é sempre inclusa).
|
|
3946
|
+
* @default ['analytics', 'functional', 'marketing']
|
|
3947
|
+
*/
|
|
3948
|
+
include?: AnpdPresetCategory[];
|
|
3949
|
+
/**
|
|
3950
|
+
* Overrides de descrições por categoria.
|
|
3951
|
+
*/
|
|
3952
|
+
descriptions?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3953
|
+
/**
|
|
3954
|
+
* Overrides de nomes por categoria.
|
|
3955
|
+
*/
|
|
3956
|
+
names?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3957
|
+
}
|
|
3958
|
+
/**
|
|
3959
|
+
* Gera um `ProjectCategoriesConfig` com presets LGPD/ANPD tipados.
|
|
3960
|
+
*
|
|
3961
|
+
* @category Utils
|
|
3962
|
+
* @since 0.6.4
|
|
3963
|
+
*/
|
|
3964
|
+
declare function createAnpdCategoriesConfig(options?: CreateAnpdCategoriesOptions): ProjectCategoriesConfig;
|
|
3731
3965
|
|
|
3732
3966
|
/**
|
|
3733
3967
|
* @enum LogLevel
|
|
@@ -4189,7 +4423,9 @@ declare function getAllProjectCategories(config?: ProjectCategoriesConfig): Cate
|
|
|
4189
4423
|
*/
|
|
4190
4424
|
declare global {
|
|
4191
4425
|
interface Window {
|
|
4192
|
-
dataLayer?: Array<ConsentEvent | Record<string, unknown
|
|
4426
|
+
dataLayer?: Array<ConsentEvent | Record<string, unknown>> | {
|
|
4427
|
+
push?: (...args: unknown[]) => unknown;
|
|
4428
|
+
};
|
|
4193
4429
|
}
|
|
4194
4430
|
}
|
|
4195
4431
|
/**
|
|
@@ -4299,4 +4535,4 @@ declare function useDataLayerEvents(): {
|
|
|
4299
4535
|
pushUpdated: typeof pushConsentUpdatedEvent;
|
|
4300
4536
|
};
|
|
4301
4537
|
|
|
4302
|
-
export { ANPD_CATEGORY_PRESETS, type AdvancedConsentTexts, type AnpdPresetCategory, COMMON_INTEGRATIONS, type CategoriesContextValue, type Category, type CategoryAutoConfigResult, type CategoryDefinition, type ClarityConfig, type ConsentAuditAction, type ConsentAuditEntry, type ConsentContextValue, type ConsentCookieData, type ConsentCookieOptions, type ConsentEvent, type ConsentEventOrigin, ConsentGate, type ConsentInitializedEvent, type ConsentPreferences, ConsentProvider, type ConsentProviderProps, ConsentScriptLoader, type ConsentScriptLoaderProps, type ConsentState, type ConsentStorageConfig, type ConsentTexts, type ConsentUpdatedEvent, type ConsentVersionChangeContext, type CookieDescriptor, type CorporateConfig, type CreateAnpdCategoriesOptions, type CustomCookieBannerProps, type CustomFloatingPreferencesButtonProps, type CustomPreferencesModalProps, DEFAULT_PROJECT_CATEGORIES, DesignProvider, type DesignTokens, type DeveloperGuidance, type ECommerceConfig, EXPANDED_DEFAULT_TEXTS, type FacebookPixelConfig, GUIDANCE_PRESETS, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, type GuidanceConfig, type GuidanceMessage, type GuidanceSeverity, type HotjarConfig, INTEGRATION_TEMPLATES, type IntercomConfig, LogLevel, type MixpanelConfig, type PeerDepsCheckResult, type PeerDepsLocale, type PeerDepsMessages, type ProjectCategoriesConfig, type RegisteredScript, type SaaSConfig, type ScriptIntegration, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, buildConsentStorageKey, categorizeDiscoveredCookies, checkPeerDeps, createAnpdCategoriesConfig, createClarityIntegration, createConsentAuditEntry, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, ensureNecessaryAlwaysOn, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, getPeerDepsLocale, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, registerScript, resetPeerDepsMessages, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, setPeerDepsLocale, setPeerDepsMessages, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|
|
4538
|
+
export { ANPD_CATEGORY_PRESETS, type AdvancedConsentTexts, type AnpdPresetCategory, COMMON_INTEGRATIONS, type CategoriesContextValue, type Category, type CategoryAutoConfigResult, type CategoryDefinition, type ClarityConfig, type ConsentAuditAction, type ConsentAuditEntry, type ConsentContextValue, type ConsentCookieData, type ConsentCookieOptions, type ConsentEvent, type ConsentEventOrigin, ConsentGate, type ConsentInitializedEvent, type ConsentPreferences, ConsentProvider, type ConsentProviderProps, ConsentScriptLoader, type ConsentScriptLoaderProps, type ConsentState, type ConsentStorageConfig, type ConsentTexts, type ConsentUpdatedEvent, type ConsentVersionChangeContext, type CookieDescriptor, type CorporateConfig, type CreateAnpdCategoriesOptions, type CustomCookieBannerProps, type CustomFloatingPreferencesButtonProps, type CustomPreferencesModalProps, DEFAULT_PROJECT_CATEGORIES, DesignProvider, type DesignTokens, type DeveloperGuidance, type ECommerceConfig, EXPANDED_DEFAULT_TEXTS, type FacebookPixelConfig, GUIDANCE_PRESETS, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, type GuidanceConfig, type GuidanceMessage, type GuidanceSeverity, type HotjarConfig, INTEGRATION_TEMPLATES, type IntercomConfig, LogLevel, type MixpanelConfig, type PeerDepsCheckResult, type PeerDepsLocale, type PeerDepsMessages, type ProjectCategoriesConfig, type RegisteredScript, type SaaSConfig, type ScriptIntegration, type SuggestedIntegrationConfig, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, buildConsentStorageKey, categorizeDiscoveredCookies, checkPeerDeps, createAnpdCategoriesConfig, createClarityIntegration, createConsentAuditEntry, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createSuggestedIntegration, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, ensureNecessaryAlwaysOn, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, getPeerDepsLocale, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, registerScript, resetPeerDepsMessages, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, setPeerDepsLocale, setPeerDepsMessages, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|