@react-lgpd-consent/core 0.7.0 → 0.7.2
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 +238 -1
- package/README.md +16 -1
- package/dist/index.cjs +1156 -468
- package/dist/index.d.cts +1346 -1045
- package/dist/index.d.ts +1346 -1045
- package/dist/index.js +1151 -469
- package/package.json +2 -2
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,471 @@ 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
|
-
|
|
124
|
-
* ```
|
|
177
|
+
* Define um subconjunto opcional dos textos principais do banner e modal,
|
|
178
|
+
* permitindo variações de t es: {
|
|
179
|
+
bannerMessage: 'Utilizamos cookies para mejorar su experiencia y mostrar contenido personalizado.', (formal, casual, etc.) sem sobrescrever todos os textos.
|
|
125
180
|
*
|
|
126
|
-
* @
|
|
181
|
+
* @category Types
|
|
182
|
+
* @since 0.4.1
|
|
127
183
|
*/
|
|
128
|
-
type
|
|
184
|
+
type TextVariant = Partial<Pick<ConsentTexts, 'bannerMessage' | 'acceptAll' | 'declineAll' | 'modalTitle'>>;
|
|
129
185
|
/**
|
|
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
|
-
* };
|
|
186
|
+
* Tipo auxiliar para textos de idioma.
|
|
149
187
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* id: 'chat',
|
|
153
|
-
* name: 'Chat de Suporte',
|
|
154
|
-
* description: 'Widget de chat para suporte ao cliente',
|
|
155
|
-
* essential: false
|
|
156
|
-
* };
|
|
157
|
-
* ```
|
|
188
|
+
* Define um subconjunto dos textos principais, excluindo propriedades específicas de internacionalização
|
|
189
|
+
* e contextos, para uso em configurações multilíngues.
|
|
158
190
|
*
|
|
159
|
-
* @
|
|
191
|
+
* @category Types
|
|
192
|
+
* @since 0.4.1
|
|
160
193
|
*/
|
|
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
|
-
}
|
|
194
|
+
type LanguageTexts = Partial<Omit<ConsentTexts, 'i18n' | 'variants' | 'contexts'>>;
|
|
193
195
|
/**
|
|
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.
|
|
196
|
+
* Sistema de textos avançado com suporte a internacionalização e contextos específicos.
|
|
202
197
|
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* name: '_ga',
|
|
207
|
-
* purpose: 'analytics',
|
|
208
|
-
* duration: '2 years',
|
|
209
|
-
* domain: '.example.com',
|
|
210
|
-
* provider: 'Google Analytics'
|
|
211
|
-
* };
|
|
212
|
-
* ```
|
|
198
|
+
* Interface expandida que permite personalização granular de todas as mensagens da biblioteca.
|
|
199
|
+
* Suporta múltiplos idiomas, contextos específicos (e-commerce, SaaS, governo), variações
|
|
200
|
+
* de tom, e compliance completo com LGPD.
|
|
213
201
|
*
|
|
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
202
|
* @category Types
|
|
246
|
-
* @since 0.
|
|
247
|
-
*
|
|
203
|
+
* @since 0.4.1
|
|
248
204
|
* @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`.
|
|
205
|
+
* **Histórico**: v0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
254
206
|
*
|
|
255
|
-
* @example
|
|
207
|
+
* @example Configuração multilíngue
|
|
256
208
|
* ```typescript
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
209
|
+
* const multiLangTexts: AdvancedConsentTexts = {
|
|
210
|
+
* // Herda de ConsentTexts básico
|
|
211
|
+
* bannerMessage: 'Utilizamos cookies para melhorar sua experiência.',
|
|
212
|
+
* acceptAll: 'Aceitar todos',
|
|
213
|
+
* declineAll: 'Recusar',
|
|
214
|
+
* preferences: 'Preferências',
|
|
215
|
+
* modalTitle: 'Preferências de Cookies',
|
|
216
|
+
* modalIntro: 'Personalize suas preferências de cookies.',
|
|
217
|
+
* save: 'Salvar',
|
|
218
|
+
* necessaryAlwaysOn: 'Cookies necessários (sempre ativos)',
|
|
262
219
|
*
|
|
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'
|
|
220
|
+
* // Textos expandidos
|
|
221
|
+
* variants: {
|
|
222
|
+
* formal: {
|
|
223
|
+
* bannerMessage: 'Este sítio utiliza cookies para otimizar a experiência de navegação.',
|
|
224
|
+
* acceptAll: 'Concordar com todos os cookies'
|
|
273
225
|
* },
|
|
274
|
-
* {
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* description: 'Experimentos de interface e funcionalidades'
|
|
226
|
+
* casual: {
|
|
227
|
+
* bannerMessage: '🍪 Olá! Usamos cookies para tornar tudo mais gostoso aqui.',
|
|
228
|
+
* acceptAll: 'Aceitar tudo'
|
|
278
229
|
* }
|
|
279
|
-
*
|
|
280
|
-
* };
|
|
281
|
-
* ```
|
|
230
|
+
* },
|
|
282
231
|
*
|
|
283
|
-
*
|
|
232
|
+
* // Internacionalização
|
|
233
|
+
* i18n: {
|
|
234
|
+
* en: {
|
|
235
|
+
* bannerMessage: 'We use cookies to enhance your experience.',
|
|
236
|
+
* acceptAll: 'Accept All',
|
|
237
|
+
* declineAll: 'Decline'
|
|
238
|
+
* },
|
|
239
|
+
* es: {
|
|
240
|
+
* bannerMessage: 'Utilizamos cookies para mejorar su experiencia.',
|
|
241
|
+
* acceptAll: 'Aceptar Todo',
|
|
242
|
+
* declineAll: 'Rechazar'
|
|
243
|
+
* }
|
|
244
|
+
* }
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
284
247
|
*/
|
|
285
|
-
interface
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
248
|
+
interface AdvancedConsentTexts extends ConsentTexts {
|
|
249
|
+
/** Texto para confirmar ação */
|
|
250
|
+
confirm?: string;
|
|
251
|
+
/** Texto para cancelar ação */
|
|
252
|
+
cancel?: string;
|
|
253
|
+
/** Texto de carregamento */
|
|
254
|
+
loading?: string;
|
|
255
|
+
/** Textos específicos para cada categoria de cookie */
|
|
256
|
+
categories?: {
|
|
257
|
+
necessary?: {
|
|
258
|
+
name?: string;
|
|
259
|
+
description?: string;
|
|
260
|
+
examples?: string;
|
|
261
|
+
};
|
|
262
|
+
analytics?: {
|
|
263
|
+
name?: string;
|
|
264
|
+
description?: string;
|
|
265
|
+
examples?: string;
|
|
266
|
+
};
|
|
267
|
+
marketing?: {
|
|
268
|
+
name?: string;
|
|
269
|
+
description?: string;
|
|
270
|
+
examples?: string;
|
|
271
|
+
};
|
|
272
|
+
functional?: {
|
|
273
|
+
name?: string;
|
|
274
|
+
description?: string;
|
|
275
|
+
examples?: string;
|
|
276
|
+
};
|
|
277
|
+
performance?: {
|
|
278
|
+
name?: string;
|
|
279
|
+
description?: string;
|
|
280
|
+
examples?: string;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
/** Mensagens de feedback ao usuário */
|
|
284
|
+
feedback?: {
|
|
285
|
+
/** Preferências salvas com sucesso */
|
|
286
|
+
saveSuccess?: string;
|
|
287
|
+
/** Erro ao salvar preferências */
|
|
288
|
+
saveError?: string;
|
|
289
|
+
/** Consentimento atualizado */
|
|
290
|
+
consentUpdated?: string;
|
|
291
|
+
/** Cookies rejeitados */
|
|
292
|
+
cookiesRejected?: string;
|
|
293
|
+
/** Configurações resetadas */
|
|
294
|
+
settingsReset?: string;
|
|
295
|
+
};
|
|
296
|
+
/** Labels ARIA e textos para leitores de tela */
|
|
297
|
+
accessibility?: {
|
|
298
|
+
/** Label do banner para leitores de tela */
|
|
299
|
+
bannerLabel?: string;
|
|
300
|
+
/** Label do modal para leitores de tela */
|
|
301
|
+
modalLabel?: string;
|
|
302
|
+
/** Instrução de navegação por teclado */
|
|
303
|
+
keyboardNavigation?: string;
|
|
304
|
+
/** Estado do toggle de categoria */
|
|
305
|
+
toggleState?: {
|
|
306
|
+
enabled?: string;
|
|
307
|
+
disabled?: string;
|
|
308
|
+
};
|
|
309
|
+
/** Região live para anúncios dinâmicos */
|
|
310
|
+
liveRegion?: string;
|
|
311
|
+
};
|
|
312
|
+
/** Textos otimizados para diferentes contextos */
|
|
313
|
+
contexts?: {
|
|
314
|
+
/** Contexto e-commerce */
|
|
315
|
+
ecommerce?: {
|
|
316
|
+
cartAbandonment?: string;
|
|
317
|
+
personalizedOffers?: string;
|
|
318
|
+
paymentSecurity?: string;
|
|
319
|
+
productRecommendations?: string;
|
|
320
|
+
};
|
|
321
|
+
/** Contexto SaaS */
|
|
322
|
+
saas?: {
|
|
323
|
+
userAnalytics?: string;
|
|
324
|
+
performanceMonitoring?: string;
|
|
325
|
+
featureUsage?: string;
|
|
326
|
+
customerSupport?: string;
|
|
327
|
+
};
|
|
328
|
+
/** Contexto governamental */
|
|
329
|
+
government?: {
|
|
330
|
+
citizenServices?: string;
|
|
331
|
+
dataProtection?: string;
|
|
332
|
+
transparency?: string;
|
|
333
|
+
accessibility?: string;
|
|
334
|
+
};
|
|
335
|
+
/** Contexto educacional */
|
|
336
|
+
education?: {
|
|
337
|
+
studentProgress?: string;
|
|
338
|
+
learningAnalytics?: string;
|
|
339
|
+
accessibility?: string;
|
|
340
|
+
parentalConsent?: string;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
/** Diferentes variações de tom para a mesma mensagem */
|
|
344
|
+
variants?: {
|
|
345
|
+
/** Tom formal/profissional */
|
|
346
|
+
formal?: TextVariant;
|
|
347
|
+
/** Tom casual/amigável */
|
|
348
|
+
casual?: TextVariant;
|
|
349
|
+
/** Tom conciso/direto */
|
|
350
|
+
concise?: TextVariant;
|
|
351
|
+
/** Tom detalhado/explicativo */
|
|
352
|
+
detailed?: TextVariant;
|
|
353
|
+
};
|
|
354
|
+
/** Suporte a múltiplos idiomas */
|
|
355
|
+
i18n?: {
|
|
356
|
+
/** Textos em inglês */
|
|
357
|
+
en?: LanguageTexts;
|
|
358
|
+
/** Textos em espanhol */
|
|
359
|
+
es?: LanguageTexts;
|
|
360
|
+
/** Textos em francês */
|
|
361
|
+
fr?: LanguageTexts;
|
|
362
|
+
/** Textos em alemão */
|
|
363
|
+
de?: LanguageTexts;
|
|
364
|
+
/** Textos em italiano */
|
|
365
|
+
it?: LanguageTexts;
|
|
366
|
+
};
|
|
367
|
+
/** Informações técnicas sobre cookies */
|
|
368
|
+
technical?: {
|
|
369
|
+
/** Explicação sobre cookies de sessão */
|
|
370
|
+
sessionCookies?: string;
|
|
371
|
+
/** Explicação sobre cookies persistentes */
|
|
372
|
+
persistentCookies?: string;
|
|
373
|
+
/** Explicação sobre cookies de terceiros */
|
|
374
|
+
thirdPartyCookies?: string;
|
|
375
|
+
/** Como desabilitar cookies no navegador */
|
|
376
|
+
browserSettings?: string;
|
|
377
|
+
/** Impacto de desabilitar cookies */
|
|
378
|
+
disablingImpact?: string;
|
|
379
|
+
};
|
|
380
|
+
/** Cabeçalhos para tabela de detalhes de cookies */
|
|
381
|
+
cookieDetails?: {
|
|
382
|
+
tableHeaders?: {
|
|
383
|
+
name?: string;
|
|
384
|
+
purpose?: string;
|
|
385
|
+
duration?: string;
|
|
386
|
+
provider?: string;
|
|
387
|
+
type?: string;
|
|
388
|
+
};
|
|
389
|
+
/** Texto quando não há cookies para mostrar */
|
|
390
|
+
noCookies?: string;
|
|
391
|
+
/** Botão para expandir/colapsar detalhes */
|
|
392
|
+
toggleDetails?: {
|
|
393
|
+
expand?: string;
|
|
394
|
+
collapse?: string;
|
|
395
|
+
};
|
|
396
|
+
/** Prefixo exibido antes do ID do script */
|
|
397
|
+
scriptLabelPrefix?: string;
|
|
398
|
+
/** Texto de finalidade para scripts ativos detectados */
|
|
399
|
+
scriptPurpose?: string;
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Textos padrão expandidos para diferentes contextos e idiomas.
|
|
404
|
+
*
|
|
405
|
+
* @category Utils
|
|
406
|
+
* @since 0.4.1
|
|
407
|
+
*/
|
|
408
|
+
declare const EXPANDED_DEFAULT_TEXTS: Partial<AdvancedConsentTexts>;
|
|
409
|
+
/**
|
|
410
|
+
* Utilitário para resolver textos baseado em idioma, contexto e variação.
|
|
411
|
+
*
|
|
412
|
+
* @category Utils
|
|
413
|
+
* @since 0.4.1
|
|
414
|
+
*
|
|
415
|
+
* @param texts - Textos avançados configurados
|
|
416
|
+
* @param options - Opções de resolução
|
|
417
|
+
* @returns Textos resolvidos para o contexto
|
|
418
|
+
*/
|
|
419
|
+
declare function resolveTexts(texts: AdvancedConsentTexts, options?: {
|
|
420
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
421
|
+
context?: 'ecommerce' | 'saas' | 'government' | 'education';
|
|
422
|
+
variant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
423
|
+
}): AdvancedConsentTexts;
|
|
424
|
+
/**
|
|
425
|
+
* Templates pré-configurados para diferentes contextos.
|
|
426
|
+
*
|
|
427
|
+
* @category Utils
|
|
428
|
+
* @since 0.4.1
|
|
429
|
+
*/
|
|
430
|
+
declare const TEXT_TEMPLATES: {
|
|
431
|
+
readonly ecommerce: AdvancedConsentTexts;
|
|
432
|
+
readonly saas: AdvancedConsentTexts;
|
|
433
|
+
readonly government: AdvancedConsentTexts;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @fileoverview
|
|
438
|
+
* Definições de tipos TypeScript para o sistema de consentimento LGPD.
|
|
439
|
+
*
|
|
440
|
+
* Este arquivo contém todas as interfaces, tipos e estruturas de dados utilizadas
|
|
441
|
+
* pela biblioteca react-lgpd-consent, incluindo definições de categorias,
|
|
442
|
+
* estado de consentimento, configurações e textos da interface.
|
|
443
|
+
*
|
|
444
|
+
* @author Luciano Édipo
|
|
445
|
+
* @since 0.1.0
|
|
446
|
+
*/
|
|
447
|
+
/**
|
|
448
|
+
* Tipos de categorias padrão de consentimento para cookies, conforme definido pela ANPD.
|
|
449
|
+
* @category Types
|
|
450
|
+
* @since 0.2.0
|
|
451
|
+
*
|
|
452
|
+
* @remarks
|
|
453
|
+
* Use este tipo para identificar as categorias principais de cookies suportadas nativamente pela biblioteca.
|
|
454
|
+
* Cada categoria representa um tipo específico de processamento de dados:
|
|
455
|
+
*
|
|
456
|
+
* - `'necessary'`: Cookies essenciais para funcionamento do site (sempre ativos).
|
|
457
|
+
* - `'analytics'`: Cookies para análise e estatísticas de uso.
|
|
458
|
+
* - `'functional'`: Cookies para funcionalidades extras e preferências do usuário.
|
|
459
|
+
* - `'marketing'`: Cookies para publicidade e marketing direcionado.
|
|
460
|
+
* - `'social'`: Cookies para integração com redes sociais.
|
|
461
|
+
* - `'personalization'`: Cookies para personalização de conteúdo e experiência.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```typescript
|
|
465
|
+
* const categories: Category[] = ['analytics', 'marketing'];
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
*/
|
|
470
|
+
type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social' | 'personalization';
|
|
471
|
+
/**
|
|
472
|
+
* Definição detalhada de uma categoria de cookie para uso interno.
|
|
473
|
+
* @category Types
|
|
474
|
+
* @since 0.2.0
|
|
475
|
+
*
|
|
476
|
+
* @remarks
|
|
477
|
+
* Esta interface define a estrutura completa de uma categoria de cookies,
|
|
478
|
+
* incluindo metadados e configurações específicas para processamento
|
|
479
|
+
* e exibição na interface do usuário.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```typescript
|
|
483
|
+
* // Categoria padrão da biblioteca
|
|
484
|
+
* const analyticsCategory: CategoryDefinition = {
|
|
485
|
+
* id: 'analytics',
|
|
486
|
+
* name: 'Cookies Analíticos',
|
|
487
|
+
* description: 'Utilizados para análise de uso do site',
|
|
488
|
+
* essential: false,
|
|
489
|
+
* cookies: ['_ga', '_ga_*', '_gid']
|
|
490
|
+
* };
|
|
491
|
+
*
|
|
492
|
+
* // Categoria customizada específica do projeto
|
|
493
|
+
* const chatCategory: CategoryDefinition = {
|
|
494
|
+
* id: 'chat',
|
|
495
|
+
* name: 'Chat de Suporte',
|
|
496
|
+
* description: 'Widget de chat para suporte ao cliente',
|
|
497
|
+
* essential: false
|
|
498
|
+
* };
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* @public
|
|
502
|
+
*/
|
|
503
|
+
interface CategoryDefinition {
|
|
504
|
+
/**
|
|
505
|
+
* Identificador único da categoria.
|
|
506
|
+
* @example 'analytics'
|
|
507
|
+
*/
|
|
508
|
+
id: string;
|
|
509
|
+
/**
|
|
510
|
+
* Nome amigável exibido na interface do usuário.
|
|
511
|
+
* @example 'Cookies Analíticos'
|
|
512
|
+
*/
|
|
513
|
+
name: string;
|
|
514
|
+
/**
|
|
515
|
+
* Descrição detalhada da finalidade da categoria.
|
|
516
|
+
* @example 'Utilizados para análise de uso e comportamento no site'
|
|
517
|
+
*/
|
|
518
|
+
description: string;
|
|
519
|
+
/**
|
|
520
|
+
* Indica se é uma categoria essencial que não pode ser desabilitada pelo usuário.
|
|
521
|
+
* @defaultValue false
|
|
522
|
+
*/
|
|
523
|
+
essential?: boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Lista de nomes de cookies ou padrões específicos desta categoria.
|
|
526
|
+
* @example ['_ga', '_ga_*', '_gid']
|
|
527
|
+
*/
|
|
528
|
+
cookies?: string[];
|
|
529
|
+
/**
|
|
530
|
+
* Metadados detalhados sobre cookies típicos desta categoria.
|
|
531
|
+
* Não exaustivo; serve para orientar UI e documentação.
|
|
532
|
+
*/
|
|
533
|
+
cookiesInfo?: CookieDescriptor[];
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Descritor de cookie com metadados úteis para UI/documentação.
|
|
537
|
+
* @category Types
|
|
538
|
+
* @since 0.2.0
|
|
539
|
+
*
|
|
540
|
+
* @remarks
|
|
541
|
+
* Mantém compatibilidade com abordagens comuns no mercado.
|
|
542
|
+
* Fornece informações detalhadas sobre cookies para exibição em interfaces
|
|
543
|
+
* e documentação de compliance.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```typescript
|
|
547
|
+
* const cookieInfo: CookieDescriptor = {
|
|
548
|
+
* name: '_ga',
|
|
549
|
+
* purpose: 'analytics',
|
|
550
|
+
* duration: '2 years',
|
|
551
|
+
* domain: '.example.com',
|
|
552
|
+
* provider: 'Google Analytics'
|
|
553
|
+
* };
|
|
554
|
+
* ```
|
|
555
|
+
*
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
interface CookieDescriptor {
|
|
559
|
+
/**
|
|
560
|
+
* Identificador ou padrão do cookie.
|
|
561
|
+
* @example '_ga'
|
|
562
|
+
*/
|
|
563
|
+
name: string;
|
|
564
|
+
/**
|
|
565
|
+
* Finalidade do cookie (opcional).
|
|
566
|
+
* @example 'analytics'
|
|
567
|
+
*/
|
|
568
|
+
purpose?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Tempo de retenção do cookie (opcional).
|
|
571
|
+
* @example '2 years'
|
|
572
|
+
*/
|
|
573
|
+
duration?: string;
|
|
574
|
+
/**
|
|
575
|
+
* Domínio associado ao cookie (opcional).
|
|
576
|
+
* @example '.example.com'
|
|
577
|
+
*/
|
|
578
|
+
domain?: string;
|
|
579
|
+
/**
|
|
580
|
+
* Provedor ou serviço associado ao cookie (opcional).
|
|
581
|
+
* @example 'Google Analytics'
|
|
582
|
+
*/
|
|
583
|
+
provider?: string;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Configuração de categorias ativas no projeto.
|
|
587
|
+
* @category Types
|
|
588
|
+
* @since 0.2.0
|
|
589
|
+
*
|
|
590
|
+
* @remarks
|
|
591
|
+
* Define quais categorias fixas serão usadas (além de 'necessary' que é sempre incluída)
|
|
592
|
+
* e permite extensão com categorias customizadas específicas do projeto.
|
|
593
|
+
*
|
|
594
|
+
* A categoria 'necessary' é sempre incluída automaticamente e não precisa ser
|
|
595
|
+
* especificada em `enabledCategories`.
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* // Configuração básica
|
|
600
|
+
* const config: ProjectCategoriesConfig = {
|
|
601
|
+
* enabledCategories: ['analytics', 'marketing']
|
|
602
|
+
* };
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```typescript
|
|
607
|
+
* // Configuração com categorias customizadas
|
|
608
|
+
* const config: ProjectCategoriesConfig = {
|
|
609
|
+
* enabledCategories: ['analytics'],
|
|
610
|
+
* customCategories: [
|
|
611
|
+
* {
|
|
612
|
+
* id: 'chat',
|
|
613
|
+
* name: 'Chat de Suporte',
|
|
614
|
+
* description: 'Widget de chat para suporte ao cliente'
|
|
615
|
+
* },
|
|
616
|
+
* {
|
|
617
|
+
* id: 'abTesting',
|
|
618
|
+
* name: 'A/B Testing',
|
|
619
|
+
* description: 'Experimentos de interface e funcionalidades'
|
|
620
|
+
* }
|
|
621
|
+
* ]
|
|
622
|
+
* };
|
|
623
|
+
* ```
|
|
624
|
+
*
|
|
625
|
+
* @public
|
|
626
|
+
*/
|
|
627
|
+
interface ProjectCategoriesConfig {
|
|
628
|
+
/**
|
|
629
|
+
* Categorias padrão que serão ativadas.
|
|
630
|
+
* A categoria 'necessary' é sempre incluída automaticamente.
|
|
631
|
+
* @example ['analytics', 'marketing']
|
|
290
632
|
*/
|
|
291
633
|
enabledCategories?: Category[];
|
|
292
634
|
/**
|
|
@@ -376,7 +718,7 @@ interface ConsentPreferences {
|
|
|
376
718
|
[key: string]: boolean;
|
|
377
719
|
}
|
|
378
720
|
/**
|
|
379
|
-
* Estrutura do cookie de consentimento em conformidade com LGPD
|
|
721
|
+
* Estrutura do cookie de consentimento em conformidade com LGPD.
|
|
380
722
|
* @category Types
|
|
381
723
|
* @since 0.2.1
|
|
382
724
|
*
|
|
@@ -686,14 +1028,22 @@ interface ConsentTexts {
|
|
|
686
1028
|
interface ConsentCookieOptions {
|
|
687
1029
|
/** Nome do cookie. Padrão: 'cookieConsent' */
|
|
688
1030
|
name: string;
|
|
689
|
-
/**
|
|
690
|
-
|
|
1031
|
+
/**
|
|
1032
|
+
* Tempo de expiração em segundos.
|
|
1033
|
+
* @defaultValue 31536000 (365 dias)
|
|
1034
|
+
*/
|
|
1035
|
+
maxAge?: number;
|
|
1036
|
+
/**
|
|
1037
|
+
* Tempo de expiração em dias (legado).
|
|
1038
|
+
* @deprecated Prefira `maxAge` em segundos.
|
|
1039
|
+
*/
|
|
1040
|
+
maxAgeDays?: number;
|
|
691
1041
|
/** Política SameSite do cookie. */
|
|
692
|
-
sameSite
|
|
693
|
-
/** Se o cookie deve ser seguro (HTTPS). Padrão: true */
|
|
694
|
-
secure
|
|
1042
|
+
sameSite?: 'Lax' | 'Strict' | 'None';
|
|
1043
|
+
/** Se o cookie deve ser seguro (HTTPS). Padrão: true em HTTPS. */
|
|
1044
|
+
secure?: boolean;
|
|
695
1045
|
/** Caminho do cookie. Padrão: '/' */
|
|
696
|
-
path
|
|
1046
|
+
path?: string;
|
|
697
1047
|
/**
|
|
698
1048
|
* Domínio do cookie (ex.: `.example.com` para compartilhar entre subdomínios).
|
|
699
1049
|
* Se não definido, o navegador usa o domínio atual.
|
|
@@ -1270,7 +1620,19 @@ interface ConsentProviderProps {
|
|
|
1270
1620
|
* }}
|
|
1271
1621
|
* ```
|
|
1272
1622
|
*/
|
|
1273
|
-
texts?: Partial<
|
|
1623
|
+
texts?: Partial<AdvancedConsentTexts>;
|
|
1624
|
+
/**
|
|
1625
|
+
* Idioma ativo para resolver textos via i18n (opcional).
|
|
1626
|
+
* Quando definido, aplica `texts.i18n[language]` nos campos principais.
|
|
1627
|
+
*
|
|
1628
|
+
* @defaultValue 'pt'
|
|
1629
|
+
*/
|
|
1630
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
1631
|
+
/**
|
|
1632
|
+
* Variação de tom aplicada aos textos (opcional).
|
|
1633
|
+
* Utiliza `texts.variants[variant]` como override dos textos principais.
|
|
1634
|
+
*/
|
|
1635
|
+
textVariant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
1274
1636
|
/**
|
|
1275
1637
|
* Tokens de design para customização visual avançada.
|
|
1276
1638
|
* Oferece controle direto sobre cores, fontes, espaçamento e layout.
|
|
@@ -1391,8 +1753,9 @@ interface ConsentProviderProps {
|
|
|
1391
1753
|
* ```tsx
|
|
1392
1754
|
* cookie={{
|
|
1393
1755
|
* name: 'meuAppConsent',
|
|
1394
|
-
*
|
|
1395
|
-
* sameSite: 'Strict'
|
|
1756
|
+
* maxAge: 60 * 60 * 24 * 180, // 180 dias
|
|
1757
|
+
* sameSite: 'Strict',
|
|
1758
|
+
* secure: true,
|
|
1396
1759
|
* }}
|
|
1397
1760
|
* ```
|
|
1398
1761
|
*/
|
|
@@ -1469,7 +1832,7 @@ interface CustomCookieBannerProps {
|
|
|
1469
1832
|
acceptAll: () => void;
|
|
1470
1833
|
rejectAll: () => void;
|
|
1471
1834
|
openPreferences: () => void;
|
|
1472
|
-
texts:
|
|
1835
|
+
texts: AdvancedConsentTexts;
|
|
1473
1836
|
/** Indica se o branding padrão deve ser ocultado. */
|
|
1474
1837
|
hideBranding?: boolean;
|
|
1475
1838
|
/**
|
|
@@ -1499,7 +1862,7 @@ interface CustomPreferencesModalProps {
|
|
|
1499
1862
|
setPreferences: (preferences: ConsentPreferences) => void;
|
|
1500
1863
|
closePreferences: () => void;
|
|
1501
1864
|
isModalOpen?: boolean;
|
|
1502
|
-
texts:
|
|
1865
|
+
texts: AdvancedConsentTexts;
|
|
1503
1866
|
}
|
|
1504
1867
|
/**
|
|
1505
1868
|
* Props esperadas por um componente customizado de FloatingPreferencesButton.
|
|
@@ -1593,7 +1956,7 @@ type ConsentEventOrigin = 'banner' | 'modal' | 'reset' | 'programmatic';
|
|
|
1593
1956
|
* @example
|
|
1594
1957
|
* ```typescript
|
|
1595
1958
|
* // Exemplo de evento no dataLayer
|
|
1596
|
-
* window
|
|
1959
|
+
* globalThis.window?.dataLayer?.push({
|
|
1597
1960
|
* event: 'consent_initialized',
|
|
1598
1961
|
* consent_version: '0.4.5',
|
|
1599
1962
|
* timestamp: '2025-10-25T13:52:33.729Z',
|
|
@@ -1616,6 +1979,8 @@ interface ConsentInitializedEvent {
|
|
|
1616
1979
|
timestamp: string;
|
|
1617
1980
|
/** Estado inicial das categorias de consentimento */
|
|
1618
1981
|
categories: Record<string, boolean>;
|
|
1982
|
+
/** Snapshot das preferências (alias para categories para Consent Mode v2) */
|
|
1983
|
+
preferences?: Record<string, boolean>;
|
|
1619
1984
|
}
|
|
1620
1985
|
/**
|
|
1621
1986
|
* Payload do evento `consent_updated` disparado no dataLayer.
|
|
@@ -1629,7 +1994,7 @@ interface ConsentInitializedEvent {
|
|
|
1629
1994
|
* @example
|
|
1630
1995
|
* ```typescript
|
|
1631
1996
|
* // Exemplo de evento no dataLayer após aceitar analytics
|
|
1632
|
-
* window
|
|
1997
|
+
* globalThis.window?.dataLayer?.push({
|
|
1633
1998
|
* event: 'consent_updated',
|
|
1634
1999
|
* consent_version: '0.4.5',
|
|
1635
2000
|
* timestamp: '2025-10-25T13:52:33.729Z',
|
|
@@ -1657,6 +2022,8 @@ interface ConsentUpdatedEvent {
|
|
|
1657
2022
|
origin: ConsentEventOrigin;
|
|
1658
2023
|
/** Estado atualizado das categorias de consentimento */
|
|
1659
2024
|
categories: Record<string, boolean>;
|
|
2025
|
+
/** Snapshot das preferências (alias para categories para Consent Mode v2) */
|
|
2026
|
+
preferences?: Record<string, boolean>;
|
|
1660
2027
|
/** Lista de categorias que foram modificadas nesta atualização */
|
|
1661
2028
|
changed_categories: string[];
|
|
1662
2029
|
}
|
|
@@ -1681,7 +2048,7 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1681
2048
|
*
|
|
1682
2049
|
* @param {Readonly<ConsentProviderProps>} props - As propriedades para configurar o provider.
|
|
1683
2050
|
* @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.
|
|
1684
|
-
* @param {Partial<
|
|
2051
|
+
* @param {Partial<AdvancedConsentTexts>} [props.texts] - Objeto para customizar todos os textos exibidos na UI.
|
|
1685
2052
|
* @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.
|
|
1686
2053
|
* @param {(state: ConsentState) => void} [props.onConsentGiven] - Callback executado na primeira vez que o usuário dá o consentimento.
|
|
1687
2054
|
* @param {(prefs: ConsentPreferences) => void} [props.onPreferencesSaved] - Callback executado sempre que o usuário salva novas preferências.
|
|
@@ -1716,8 +2083,8 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1716
2083
|
* </ConsentProvider>
|
|
1717
2084
|
* ```
|
|
1718
2085
|
*/
|
|
1719
|
-
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;
|
|
1720
|
-
declare const defaultTexts:
|
|
2086
|
+
declare function ConsentProvider({ initialState, categories, texts: textsProp, language, textVariant, 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;
|
|
2087
|
+
declare const defaultTexts: AdvancedConsentTexts;
|
|
1721
2088
|
|
|
1722
2089
|
/**
|
|
1723
2090
|
* @fileoverview
|
|
@@ -1860,7 +2227,7 @@ declare const defaultTexts: ConsentTexts;
|
|
|
1860
2227
|
* return (
|
|
1861
2228
|
* <div>
|
|
1862
2229
|
* ❌ Este recurso requer cookies funcionais.
|
|
1863
|
-
* <button onClick={() => window
|
|
2230
|
+
* <button onClick={() => globalThis.window?.openPreferencesModal?.()}>
|
|
1864
2231
|
* Alterar Preferências
|
|
1865
2232
|
* </button>
|
|
1866
2233
|
* </div>
|
|
@@ -1995,13 +2362,13 @@ declare function useConsent(): ConsentContextValue;
|
|
|
1995
2362
|
* }
|
|
1996
2363
|
* ```
|
|
1997
2364
|
*
|
|
1998
|
-
* @see {@link
|
|
2365
|
+
* @see {@link AdvancedConsentTexts} - Interface completa dos textos
|
|
1999
2366
|
* @see {@link ConsentProvider} - Para configurar textos personalizados
|
|
2000
2367
|
*
|
|
2001
2368
|
* @public
|
|
2002
2369
|
* @since 0.1.0
|
|
2003
2370
|
*/
|
|
2004
|
-
declare function useConsentTexts():
|
|
2371
|
+
declare function useConsentTexts(): AdvancedConsentTexts;
|
|
2005
2372
|
/**
|
|
2006
2373
|
* Hook para verificar se a hidratação do estado de consentimento foi concluída.
|
|
2007
2374
|
*
|
|
@@ -2093,7 +2460,7 @@ declare function useConsentTexts(): ConsentTexts;
|
|
|
2093
2460
|
* return (
|
|
2094
2461
|
* <div className="consent-partial">
|
|
2095
2462
|
* <p>Este recurso requer cookies funcionais.</p>
|
|
2096
|
-
* <button onClick={() => window
|
|
2463
|
+
* <button onClick={() => globalThis.window?.openPreferencesModal?.()}>
|
|
2097
2464
|
* Alterar Preferências
|
|
2098
2465
|
* </button>
|
|
2099
2466
|
* </div>
|
|
@@ -2204,7 +2571,7 @@ declare function useOpenPreferencesModal(): () => void;
|
|
|
2204
2571
|
* @example
|
|
2205
2572
|
* ```javascript
|
|
2206
2573
|
* // Em código JavaScript puro
|
|
2207
|
-
* window
|
|
2574
|
+
* globalThis.window?.openPreferencesModal?.();
|
|
2208
2575
|
*
|
|
2209
2576
|
* // Ou importando diretamente
|
|
2210
2577
|
* import { openPreferencesModal } from 'react-lgpd-consent';
|
|
@@ -2429,6 +2796,18 @@ declare function createConsentAuditEntry(state: ConsentState, params: {
|
|
|
2429
2796
|
* Fornece funções para carregar scripts de terceiros de forma condicional ao consentimento LGPD,
|
|
2430
2797
|
* garantindo compatibilidade SSR e verificações de permissões por categoria.
|
|
2431
2798
|
*/
|
|
2799
|
+
|
|
2800
|
+
type ConsentSnapshot = {
|
|
2801
|
+
consented: boolean;
|
|
2802
|
+
preferences: ConsentPreferences;
|
|
2803
|
+
isModalOpen?: boolean;
|
|
2804
|
+
};
|
|
2805
|
+
interface LoadScriptOptions {
|
|
2806
|
+
consentSnapshot?: ConsentSnapshot;
|
|
2807
|
+
cookieName?: string;
|
|
2808
|
+
pollIntervalMs?: number;
|
|
2809
|
+
skipConsentCheck?: boolean;
|
|
2810
|
+
}
|
|
2432
2811
|
/**
|
|
2433
2812
|
* @function
|
|
2434
2813
|
* @category Utils
|
|
@@ -2448,6 +2827,7 @@ declare function createConsentAuditEntry(state: ConsentState, params: {
|
|
|
2448
2827
|
* @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.
|
|
2449
2828
|
* @param {Record<string, string>} [attrs={}] Atributos adicionais a serem aplicados ao elemento `<script>` (ex: `{ async: 'true' }`).
|
|
2450
2829
|
* @param {string | undefined} [nonce] Nonce CSP opcional aplicado ao script.
|
|
2830
|
+
* @param {LoadScriptOptions} [options] Configurações avançadas (consentSnapshot, cookieName, pollIntervalMs, skipConsentCheck).
|
|
2451
2831
|
* @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.
|
|
2452
2832
|
* @example
|
|
2453
2833
|
* ```ts
|
|
@@ -2457,7 +2837,7 @@ declare function createConsentAuditEntry(state: ConsentState, params: {
|
|
|
2457
2837
|
* .catch(error => console.error('Erro ao carregar script:', error))
|
|
2458
2838
|
* ```
|
|
2459
2839
|
*/
|
|
2460
|
-
declare function loadScript(id: string, src: string, category?: string | null, attrs?: Record<string, string>, nonce?: string): Promise<void>;
|
|
2840
|
+
declare function loadScript(id: string, src: string, category?: string | null, attrs?: Record<string, string>, nonce?: string, options?: LoadScriptOptions): Promise<void>;
|
|
2461
2841
|
|
|
2462
2842
|
/**
|
|
2463
2843
|
* Utilitários para descoberta e categorização de cookies em tempo de execução (experimental).
|
|
@@ -2483,10 +2863,23 @@ declare function loadScript(id: string, src: string, category?: string | null, a
|
|
|
2483
2863
|
*/
|
|
2484
2864
|
declare function discoverRuntimeCookies(): CookieDescriptor[];
|
|
2485
2865
|
/**
|
|
2486
|
-
* Tenta detectar o nome do cookie de consentimento
|
|
2487
|
-
*
|
|
2866
|
+
* Tenta detectar o nome do cookie de consentimento LGPD presente no navegador.
|
|
2867
|
+
*
|
|
2868
|
+
* - Percorre todos os cookies disponíveis em `document.cookie`.
|
|
2869
|
+
* - Decodifica o valor e verifica se corresponde à estrutura JSON esperada de consentimento.
|
|
2870
|
+
* - Retorna o nome do cookie se encontrado, ou `null` se não houver nenhum compatível.
|
|
2871
|
+
*
|
|
2872
|
+
* @returns Nome do cookie de consentimento ou `null` se não encontrado
|
|
2488
2873
|
* @category Utils
|
|
2489
2874
|
* @since 0.4.1
|
|
2875
|
+
* @example
|
|
2876
|
+
* ```ts
|
|
2877
|
+
* const consentCookie = detectConsentCookieName()
|
|
2878
|
+
* if (consentCookie) {
|
|
2879
|
+
* console.log('Cookie de consentimento encontrado:', consentCookie)
|
|
2880
|
+
* }
|
|
2881
|
+
* ```
|
|
2882
|
+
* @remarks SSR-safe: retorna `null` se executado fora do browser.
|
|
2490
2883
|
*/
|
|
2491
2884
|
declare function detectConsentCookieName(): string | null;
|
|
2492
2885
|
/**
|
|
@@ -2515,6 +2908,7 @@ declare function categorizeDiscoveredCookies(discovered?: CookieDescriptor[], re
|
|
|
2515
2908
|
* - URLs possuem valores default atualizados e podem ser sobrescritos via `scriptUrl`
|
|
2516
2909
|
* - SSR-safe: toda execução que toca `window` é protegida
|
|
2517
2910
|
*/
|
|
2911
|
+
|
|
2518
2912
|
/**
|
|
2519
2913
|
* Integração de script de terceiros condicionada a consentimento.
|
|
2520
2914
|
*
|
|
@@ -2561,6 +2955,15 @@ interface ScriptIntegration {
|
|
|
2561
2955
|
attrs?: Record<string, string>;
|
|
2562
2956
|
/** Nonce CSP opcional aplicado à tag script */
|
|
2563
2957
|
nonce?: string;
|
|
2958
|
+
/** Prioridade para ordenação na fila do loader (maior = executa primeiro dentro da categoria) */
|
|
2959
|
+
priority?: number;
|
|
2960
|
+
/** Rotina opcional executada antes do carregamento principal (ex.: bootstrap de Consent Mode) */
|
|
2961
|
+
bootstrap?: () => void | Promise<void>;
|
|
2962
|
+
/** Callback disparado quando o consentimento é atualizado */
|
|
2963
|
+
onConsentUpdate?: (consent: {
|
|
2964
|
+
consented: boolean;
|
|
2965
|
+
preferences: ConsentPreferences;
|
|
2966
|
+
}) => void;
|
|
2564
2967
|
/** Lista de cookies que o script pode definir */
|
|
2565
2968
|
cookies?: string[];
|
|
2566
2969
|
/** Informações detalhadas dos cookies (nome, finalidade, duração, fornecedor) */
|
|
@@ -2572,1100 +2975,904 @@ interface ScriptIntegration {
|
|
|
2572
2975
|
}>;
|
|
2573
2976
|
}
|
|
2574
2977
|
/**
|
|
2575
|
-
* Configuração para
|
|
2576
|
-
*
|
|
2577
|
-
* @category Utils
|
|
2578
|
-
* @since 0.2.0
|
|
2579
|
-
*
|
|
2580
|
-
* @example
|
|
2581
|
-
* ```typescript
|
|
2582
|
-
* const config: GoogleAnalyticsConfig = {
|
|
2583
|
-
* measurementId: 'G-XXXXXXXXXX',
|
|
2584
|
-
* config: { anonymize_ip: true }
|
|
2585
|
-
* }
|
|
2586
|
-
* ```
|
|
2587
|
-
*/
|
|
2588
|
-
interface GoogleAnalyticsConfig {
|
|
2589
|
-
/** ID de medição do GA4 (formato: G-XXXXXXXXXX) */
|
|
2590
|
-
measurementId: string;
|
|
2591
|
-
/** Configurações adicionais para o gtag */
|
|
2592
|
-
config?: Record<string, unknown>;
|
|
2593
|
-
/** URL do script GA4. Se omitido usa o padrão oficial. */
|
|
2594
|
-
scriptUrl?: string;
|
|
2595
|
-
}
|
|
2596
|
-
/**
|
|
2597
|
-
* Configuração para integração do Google Tag Manager (GTM).
|
|
2598
|
-
*
|
|
2599
|
-
* @category Utils
|
|
2600
|
-
* @since 0.2.0
|
|
2601
|
-
*
|
|
2602
|
-
* @example
|
|
2603
|
-
* ```typescript
|
|
2604
|
-
* const config: GoogleTagManagerConfig = {
|
|
2605
|
-
* containerId: 'GTM-XXXXXXX',
|
|
2606
|
-
* dataLayerName: 'customDataLayer'
|
|
2607
|
-
* }
|
|
2608
|
-
* ```
|
|
2609
|
-
*/
|
|
2610
|
-
interface GoogleTagManagerConfig {
|
|
2611
|
-
/** ID do container GTM (formato: GTM-XXXXXXX) */
|
|
2612
|
-
containerId: string;
|
|
2613
|
-
/** Nome customizado para o dataLayer. Padrão: 'dataLayer' */
|
|
2614
|
-
dataLayerName?: string;
|
|
2615
|
-
/** URL do script GTM. Se omitido usa o padrão oficial. */
|
|
2616
|
-
scriptUrl?: string;
|
|
2617
|
-
}
|
|
2618
|
-
/**
|
|
2619
|
-
* Configuração para integração do UserWay (Acessibilidade).
|
|
2620
|
-
*
|
|
2621
|
-
* @category Utils
|
|
2622
|
-
* @since 0.2.0
|
|
2623
|
-
*
|
|
2624
|
-
* @example
|
|
2625
|
-
* ```typescript
|
|
2626
|
-
* const config: UserWayConfig = {
|
|
2627
|
-
* accountId: 'XXXXXXXXXX'
|
|
2628
|
-
* }
|
|
2629
|
-
* ```
|
|
2630
|
-
*/
|
|
2631
|
-
interface UserWayConfig {
|
|
2632
|
-
/** ID da conta UserWay */
|
|
2633
|
-
accountId: string;
|
|
2634
|
-
/** URL do script UserWay. Se omitido usa o padrão oficial. */
|
|
2635
|
-
scriptUrl?: string;
|
|
2636
|
-
}
|
|
2637
|
-
/**
|
|
2638
|
-
* Cria integração do Google Analytics (GA4).
|
|
2639
|
-
* Configura o gtag e inicializa o tracking com o measurement ID fornecido.
|
|
2640
|
-
*
|
|
2641
|
-
* @category Utils
|
|
2642
|
-
* @param config - Configuração do Google Analytics
|
|
2643
|
-
* @returns Integração configurada para o GA4
|
|
2644
|
-
* @since 0.2.0
|
|
2645
|
-
*
|
|
2646
|
-
* @example
|
|
2647
|
-
* ```typescript
|
|
2648
|
-
* const ga = createGoogleAnalyticsIntegration({
|
|
2649
|
-
* measurementId: 'G-XXXXXXXXXX',
|
|
2650
|
-
* config: { anonymize_ip: true }
|
|
2651
|
-
* })
|
|
2652
|
-
* ```
|
|
2653
|
-
*
|
|
2654
|
-
* @remarks
|
|
2655
|
-
* - Define cookies: _ga, _ga_*, _gid
|
|
2656
|
-
* - Categoria padrão: 'analytics'
|
|
2657
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2658
|
-
*/
|
|
2659
|
-
declare function createGoogleAnalyticsIntegration(config: GoogleAnalyticsConfig): ScriptIntegration;
|
|
2660
|
-
/**
|
|
2661
|
-
* Cria integração do Google Tag Manager (GTM).
|
|
2662
|
-
* Configura o dataLayer e inicializa o container GTM.
|
|
2663
|
-
*
|
|
2664
|
-
* @category Utils
|
|
2665
|
-
* @param config - Configuração do Google Tag Manager
|
|
2666
|
-
* @returns Integração configurada para o GTM
|
|
2667
|
-
* @since 0.2.0
|
|
2668
|
-
*
|
|
2669
|
-
* @example
|
|
2670
|
-
* ```typescript
|
|
2671
|
-
* const gtm = createGoogleTagManagerIntegration({
|
|
2672
|
-
* containerId: 'GTM-XXXXXXX',
|
|
2673
|
-
* dataLayerName: 'myDataLayer'
|
|
2674
|
-
* })
|
|
2675
|
-
* ```
|
|
2676
|
-
*
|
|
2677
|
-
* @remarks
|
|
2678
|
-
* - Define cookies: _gcl_au
|
|
2679
|
-
* - Categoria padrão: 'analytics'
|
|
2680
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2681
|
-
*/
|
|
2682
|
-
declare function createGoogleTagManagerIntegration(config: GoogleTagManagerConfig): ScriptIntegration;
|
|
2683
|
-
/**
|
|
2684
|
-
* Cria integração do UserWay (Acessibilidade).
|
|
2685
|
-
* Configura o widget de acessibilidade UserWay.
|
|
2686
|
-
*
|
|
2687
|
-
* @category Utils
|
|
2688
|
-
* @param config - Configuração do UserWay
|
|
2689
|
-
* @returns Integração configurada para o UserWay
|
|
2690
|
-
* @since 0.2.0
|
|
2691
|
-
*
|
|
2692
|
-
* @example
|
|
2693
|
-
* ```typescript
|
|
2694
|
-
* const userway = createUserWayIntegration({
|
|
2695
|
-
* accountId: 'XXXXXXXXXX'
|
|
2696
|
-
* })
|
|
2697
|
-
* ```
|
|
2698
|
-
*
|
|
2699
|
-
* @remarks
|
|
2700
|
-
* - Define cookies: _userway_*
|
|
2701
|
-
* - Categoria padrão: 'functional'
|
|
2702
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2703
|
-
*/
|
|
2704
|
-
declare function createUserWayIntegration(config: UserWayConfig): ScriptIntegration;
|
|
2705
|
-
/**
|
|
2706
|
-
* Funções fábricas para integrações comuns.
|
|
2707
|
-
* Fornece acesso direto às funções de criação de integrações pré-configuradas.
|
|
2708
|
-
*
|
|
2709
|
-
* @category Utils
|
|
2710
|
-
* @since 0.2.0
|
|
2711
|
-
*
|
|
2712
|
-
* @example
|
|
2713
|
-
* ```typescript
|
|
2714
|
-
* const ga = COMMON_INTEGRATIONS.googleAnalytics({ measurementId: 'G-XXXXXXXXXX' })
|
|
2715
|
-
* ```
|
|
2716
|
-
*/
|
|
2717
|
-
declare const COMMON_INTEGRATIONS: {
|
|
2718
|
-
googleAnalytics: typeof createGoogleAnalyticsIntegration;
|
|
2719
|
-
googleTagManager: typeof createGoogleTagManagerIntegration;
|
|
2720
|
-
userway: typeof createUserWayIntegration;
|
|
2721
|
-
};
|
|
2722
|
-
/**
|
|
2723
|
-
* Configuração para integração do Facebook Pixel.
|
|
2724
|
-
*
|
|
2725
|
-
* @category Utils
|
|
2726
|
-
* @since 0.4.1
|
|
2727
|
-
*
|
|
2728
|
-
* @example
|
|
2729
|
-
* ```typescript
|
|
2730
|
-
* const config: FacebookPixelConfig = {
|
|
2731
|
-
* pixelId: '1234567890123456',
|
|
2732
|
-
* autoTrack: true,
|
|
2733
|
-
* advancedMatching: { email: 'user@example.com' }
|
|
2734
|
-
* }
|
|
2735
|
-
* ```
|
|
2736
|
-
*/
|
|
2737
|
-
interface FacebookPixelConfig {
|
|
2738
|
-
/** ID do pixel do Facebook */
|
|
2739
|
-
pixelId: string;
|
|
2740
|
-
/** Se deve rastrear PageView automaticamente. Padrão: true */
|
|
2741
|
-
autoTrack?: boolean;
|
|
2742
|
-
/** Configuração de correspondência avançada */
|
|
2743
|
-
advancedMatching?: Record<string, unknown>;
|
|
2744
|
-
/** URL do script do Pixel. Se omitido usa o padrão oficial. */
|
|
2745
|
-
scriptUrl?: string;
|
|
2746
|
-
}
|
|
2747
|
-
/**
|
|
2748
|
-
* Configuração para integração do Hotjar.
|
|
2749
|
-
*
|
|
2750
|
-
* @category Utils
|
|
2751
|
-
* @since 0.4.1
|
|
2752
|
-
*
|
|
2753
|
-
* @example
|
|
2754
|
-
* ```typescript
|
|
2755
|
-
* const config: HotjarConfig = {
|
|
2756
|
-
* siteId: '1234567',
|
|
2757
|
-
* version: 6,
|
|
2758
|
-
* debug: false
|
|
2759
|
-
* }
|
|
2760
|
-
* ```
|
|
2761
|
-
*/
|
|
2762
|
-
interface HotjarConfig {
|
|
2763
|
-
/** ID do site no Hotjar */
|
|
2764
|
-
siteId: string;
|
|
2765
|
-
/** Versão do script Hotjar. Padrão: 6 */
|
|
2766
|
-
version?: number;
|
|
2767
|
-
/** Ativar modo debug. Padrão: false */
|
|
2768
|
-
debug?: boolean;
|
|
2769
|
-
/** URL do script Hotjar. Se omitido usa o padrão oficial. */
|
|
2770
|
-
scriptUrl?: string;
|
|
2771
|
-
}
|
|
2772
|
-
/**
|
|
2773
|
-
* Configuração para integração do Mixpanel.
|
|
2774
|
-
*
|
|
2775
|
-
* @category Utils
|
|
2776
|
-
* @since 0.4.1
|
|
2777
|
-
*
|
|
2778
|
-
* @example
|
|
2779
|
-
* ```typescript
|
|
2780
|
-
* const config: MixpanelConfig = {
|
|
2781
|
-
* token: 'your-project-token',
|
|
2782
|
-
* config: { debug: true },
|
|
2783
|
-
* api_host: 'https://api.mixpanel.com'
|
|
2784
|
-
* }
|
|
2785
|
-
* ```
|
|
2786
|
-
*/
|
|
2787
|
-
interface MixpanelConfig {
|
|
2788
|
-
/** Token do projeto Mixpanel */
|
|
2789
|
-
token: string;
|
|
2790
|
-
/** Configurações adicionais do Mixpanel */
|
|
2791
|
-
config?: Record<string, unknown>;
|
|
2792
|
-
/** Host customizado da API Mixpanel */
|
|
2793
|
-
api_host?: string;
|
|
2794
|
-
/** URL do script Mixpanel. Se omitido usa o padrão oficial. */
|
|
2795
|
-
scriptUrl?: string;
|
|
2796
|
-
}
|
|
2797
|
-
/**
|
|
2798
|
-
* Configuração para integração do Microsoft Clarity.
|
|
2978
|
+
* Configuração para integrações customizadas com categoria sugerida automaticamente.
|
|
2799
2979
|
*
|
|
2800
2980
|
* @category Utils
|
|
2801
|
-
* @since 0.
|
|
2981
|
+
* @since 0.7.2
|
|
2982
|
+
*/
|
|
2983
|
+
interface SuggestedIntegrationConfig extends Omit<ScriptIntegration, 'category'> {
|
|
2984
|
+
/** Categoria LGPD customizada (opcional). Se omitida, usa sugestão automática. */
|
|
2985
|
+
category?: string;
|
|
2986
|
+
}
|
|
2987
|
+
/**
|
|
2988
|
+
* Cria integração customizada aplicando categoria sugerida automaticamente.
|
|
2989
|
+
* Permite sobrescrever a categoria quando necessário.
|
|
2990
|
+
*
|
|
2991
|
+
* @category Utils
|
|
2992
|
+
* @since 0.7.2
|
|
2802
2993
|
*
|
|
2803
2994
|
* @example
|
|
2804
2995
|
* ```typescript
|
|
2805
|
-
* const
|
|
2806
|
-
*
|
|
2807
|
-
*
|
|
2808
|
-
* }
|
|
2996
|
+
* const custom = createSuggestedIntegration({
|
|
2997
|
+
* id: 'custom-chat',
|
|
2998
|
+
* src: 'https://example.com/chat.js'
|
|
2999
|
+
* })
|
|
3000
|
+
* // -> category sugerida: 'functional'
|
|
2809
3001
|
* ```
|
|
2810
3002
|
*/
|
|
2811
|
-
|
|
2812
|
-
/** ID do projeto no Microsoft Clarity */
|
|
2813
|
-
projectId: string;
|
|
2814
|
-
/** Configuração de upload de dados. Padrão: indefinido */
|
|
2815
|
-
upload?: boolean;
|
|
2816
|
-
/** URL do script Clarity. Se omitido usa o padrão oficial. */
|
|
2817
|
-
scriptUrl?: string;
|
|
2818
|
-
}
|
|
3003
|
+
declare function createSuggestedIntegration(config: SuggestedIntegrationConfig): ScriptIntegration;
|
|
2819
3004
|
/**
|
|
2820
|
-
* Configuração para integração do
|
|
3005
|
+
* Configuração para integração do Google Analytics (GA4).
|
|
2821
3006
|
*
|
|
2822
3007
|
* @category Utils
|
|
2823
|
-
* @since 0.
|
|
3008
|
+
* @since 0.2.0
|
|
2824
3009
|
*
|
|
2825
3010
|
* @example
|
|
2826
3011
|
* ```typescript
|
|
2827
|
-
* const config:
|
|
2828
|
-
*
|
|
3012
|
+
* const config: GoogleAnalyticsConfig = {
|
|
3013
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
3014
|
+
* config: { anonymize_ip: true }
|
|
2829
3015
|
* }
|
|
2830
3016
|
* ```
|
|
2831
3017
|
*/
|
|
2832
|
-
interface
|
|
2833
|
-
/** ID
|
|
2834
|
-
|
|
2835
|
-
/**
|
|
3018
|
+
interface GoogleAnalyticsConfig {
|
|
3019
|
+
/** ID de medição do GA4 (formato: G-XXXXXXXXXX) */
|
|
3020
|
+
measurementId: string;
|
|
3021
|
+
/** Configurações adicionais para o gtag */
|
|
3022
|
+
config?: Record<string, unknown>;
|
|
3023
|
+
/** URL do script GA4. Se omitido usa o padrão oficial. */
|
|
2836
3024
|
scriptUrl?: string;
|
|
3025
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3026
|
+
category?: string;
|
|
2837
3027
|
}
|
|
2838
3028
|
/**
|
|
2839
|
-
* Configuração para integração do
|
|
3029
|
+
* Configuração para integração do Google Tag Manager (GTM).
|
|
2840
3030
|
*
|
|
2841
3031
|
* @category Utils
|
|
2842
|
-
* @since 0.
|
|
3032
|
+
* @since 0.2.0
|
|
2843
3033
|
*
|
|
2844
3034
|
* @example
|
|
2845
3035
|
* ```typescript
|
|
2846
|
-
* const config:
|
|
2847
|
-
*
|
|
3036
|
+
* const config: GoogleTagManagerConfig = {
|
|
3037
|
+
* containerId: 'GTM-XXXXXXX',
|
|
3038
|
+
* dataLayerName: 'customDataLayer'
|
|
2848
3039
|
* }
|
|
2849
3040
|
* ```
|
|
2850
3041
|
*/
|
|
2851
|
-
interface
|
|
2852
|
-
/**
|
|
2853
|
-
|
|
2854
|
-
/**
|
|
3042
|
+
interface GoogleTagManagerConfig {
|
|
3043
|
+
/** ID do container GTM (formato: GTM-XXXXXXX) */
|
|
3044
|
+
containerId: string;
|
|
3045
|
+
/** Nome customizado para o dataLayer. Padrão: 'dataLayer' */
|
|
3046
|
+
dataLayerName?: string;
|
|
3047
|
+
/** URL do script GTM. Se omitido usa o padrão oficial. */
|
|
2855
3048
|
scriptUrl?: string;
|
|
3049
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3050
|
+
category?: string;
|
|
2856
3051
|
}
|
|
2857
3052
|
/**
|
|
2858
|
-
*
|
|
2859
|
-
* Configura o fbq e inicializa o pixel com tracking automático opcional.
|
|
3053
|
+
* Configuração para integração do UserWay (Acessibilidade).
|
|
2860
3054
|
*
|
|
2861
3055
|
* @category Utils
|
|
2862
|
-
* @
|
|
2863
|
-
* @returns Integração configurada para o Facebook Pixel
|
|
2864
|
-
* @since 0.4.1
|
|
3056
|
+
* @since 0.2.0
|
|
2865
3057
|
*
|
|
2866
3058
|
* @example
|
|
2867
3059
|
* ```typescript
|
|
2868
|
-
* const
|
|
2869
|
-
*
|
|
2870
|
-
*
|
|
2871
|
-
* })
|
|
3060
|
+
* const config: UserWayConfig = {
|
|
3061
|
+
* accountId: 'XXXXXXXXXX'
|
|
3062
|
+
* }
|
|
2872
3063
|
* ```
|
|
2873
|
-
*
|
|
2874
|
-
* @remarks
|
|
2875
|
-
* - Define cookies: _fbp, fr
|
|
2876
|
-
* - Categoria padrão: 'marketing'
|
|
2877
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2878
3064
|
*/
|
|
2879
|
-
|
|
3065
|
+
interface UserWayConfig {
|
|
3066
|
+
/** ID da conta UserWay */
|
|
3067
|
+
accountId: string;
|
|
3068
|
+
/** URL do script UserWay. Se omitido usa o padrão oficial. */
|
|
3069
|
+
scriptUrl?: string;
|
|
3070
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3071
|
+
category?: string;
|
|
3072
|
+
}
|
|
2880
3073
|
/**
|
|
2881
|
-
* Cria integração do
|
|
2882
|
-
* Configura
|
|
3074
|
+
* Cria integração do Google Analytics (GA4).
|
|
3075
|
+
* Configura o gtag e inicializa o tracking com o measurement ID fornecido.
|
|
2883
3076
|
*
|
|
2884
3077
|
* @category Utils
|
|
2885
|
-
* @param config - Configuração do
|
|
2886
|
-
* @returns Integração configurada para o
|
|
2887
|
-
* @since 0.
|
|
3078
|
+
* @param config - Configuração do Google Analytics
|
|
3079
|
+
* @returns Integração configurada para o GA4
|
|
3080
|
+
* @since 0.2.0
|
|
2888
3081
|
*
|
|
2889
3082
|
* @example
|
|
2890
3083
|
* ```typescript
|
|
2891
|
-
* const
|
|
2892
|
-
*
|
|
2893
|
-
*
|
|
3084
|
+
* const ga = createGoogleAnalyticsIntegration({
|
|
3085
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
3086
|
+
* config: { anonymize_ip: true }
|
|
2894
3087
|
* })
|
|
2895
3088
|
* ```
|
|
2896
3089
|
*
|
|
2897
3090
|
* @remarks
|
|
2898
|
-
* - Define cookies:
|
|
3091
|
+
* - Define cookies: _ga, _ga_*, _gid
|
|
2899
3092
|
* - Categoria padrão: 'analytics'
|
|
2900
3093
|
* - SSR-safe: verifica disponibilidade do window
|
|
2901
3094
|
*/
|
|
2902
|
-
declare function
|
|
3095
|
+
declare function createGoogleAnalyticsIntegration(config: GoogleAnalyticsConfig): ScriptIntegration;
|
|
2903
3096
|
/**
|
|
2904
|
-
* Cria integração do
|
|
2905
|
-
* Configura e inicializa o
|
|
3097
|
+
* Cria integração do Google Tag Manager (GTM).
|
|
3098
|
+
* Configura o dataLayer e inicializa o container GTM.
|
|
2906
3099
|
*
|
|
2907
3100
|
* @category Utils
|
|
2908
|
-
* @param config - Configuração do
|
|
2909
|
-
* @returns Integração configurada para o
|
|
2910
|
-
* @since 0.
|
|
3101
|
+
* @param config - Configuração do Google Tag Manager
|
|
3102
|
+
* @returns Integração configurada para o GTM
|
|
3103
|
+
* @since 0.2.0
|
|
2911
3104
|
*
|
|
2912
3105
|
* @example
|
|
2913
3106
|
* ```typescript
|
|
2914
|
-
* const
|
|
2915
|
-
*
|
|
2916
|
-
*
|
|
3107
|
+
* const gtm = createGoogleTagManagerIntegration({
|
|
3108
|
+
* containerId: 'GTM-XXXXXXX',
|
|
3109
|
+
* dataLayerName: 'myDataLayer'
|
|
2917
3110
|
* })
|
|
2918
3111
|
* ```
|
|
2919
3112
|
*
|
|
2920
3113
|
* @remarks
|
|
2921
|
-
* - Define cookies:
|
|
3114
|
+
* - Define cookies: _gcl_au
|
|
2922
3115
|
* - Categoria padrão: 'analytics'
|
|
2923
3116
|
* - SSR-safe: verifica disponibilidade do window
|
|
2924
|
-
* - Inclui tratamento de erro na inicialização
|
|
2925
3117
|
*/
|
|
2926
|
-
declare function
|
|
3118
|
+
declare function createGoogleTagManagerIntegration(config: GoogleTagManagerConfig): ScriptIntegration;
|
|
2927
3119
|
/**
|
|
2928
|
-
* Cria integração do
|
|
2929
|
-
* Configura o
|
|
3120
|
+
* Cria integração do UserWay (Acessibilidade).
|
|
3121
|
+
* Configura o widget de acessibilidade UserWay.
|
|
2930
3122
|
*
|
|
2931
3123
|
* @category Utils
|
|
2932
|
-
* @param config - Configuração do
|
|
2933
|
-
* @returns Integração configurada para o
|
|
2934
|
-
* @since 0.
|
|
3124
|
+
* @param config - Configuração do UserWay
|
|
3125
|
+
* @returns Integração configurada para o UserWay
|
|
3126
|
+
* @since 0.2.0
|
|
2935
3127
|
*
|
|
2936
3128
|
* @example
|
|
2937
3129
|
* ```typescript
|
|
2938
|
-
* const
|
|
2939
|
-
*
|
|
2940
|
-
* upload: false
|
|
3130
|
+
* const userway = createUserWayIntegration({
|
|
3131
|
+
* accountId: 'XXXXXXXXXX'
|
|
2941
3132
|
* })
|
|
2942
3133
|
* ```
|
|
2943
3134
|
*
|
|
2944
3135
|
* @remarks
|
|
2945
|
-
* - Define cookies:
|
|
2946
|
-
* - Categoria padrão: '
|
|
3136
|
+
* - Define cookies: _userway_*
|
|
3137
|
+
* - Categoria padrão: 'functional'
|
|
2947
3138
|
* - SSR-safe: verifica disponibilidade do window
|
|
2948
|
-
* - Configuração de upload opcional
|
|
2949
3139
|
*/
|
|
2950
|
-
declare function
|
|
3140
|
+
declare function createUserWayIntegration(config: UserWayConfig): ScriptIntegration;
|
|
2951
3141
|
/**
|
|
2952
|
-
*
|
|
2953
|
-
*
|
|
3142
|
+
* Funções fábricas para integrações comuns.
|
|
3143
|
+
* Fornece acesso direto às funções de criação de integrações pré-configuradas.
|
|
2954
3144
|
*
|
|
2955
3145
|
* @category Utils
|
|
2956
|
-
* @
|
|
2957
|
-
* @returns Integração configurada para o Intercom
|
|
2958
|
-
* @since 0.4.1
|
|
3146
|
+
* @since 0.2.0
|
|
2959
3147
|
*
|
|
2960
3148
|
* @example
|
|
2961
3149
|
* ```typescript
|
|
2962
|
-
* const
|
|
2963
|
-
* app_id: 'your-app-id'
|
|
2964
|
-
* })
|
|
3150
|
+
* const ga = COMMON_INTEGRATIONS.googleAnalytics({ measurementId: 'G-XXXXXXXXXX' })
|
|
2965
3151
|
* ```
|
|
2966
|
-
*
|
|
2967
|
-
* @remarks
|
|
2968
|
-
* - Define cookies: intercom-id-*, intercom-session-*
|
|
2969
|
-
* - Categoria padrão: 'functional'
|
|
2970
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2971
|
-
* - Inclui tratamento de erro na inicialização
|
|
2972
3152
|
*/
|
|
2973
|
-
declare
|
|
3153
|
+
declare const COMMON_INTEGRATIONS: {
|
|
3154
|
+
googleAnalytics: typeof createGoogleAnalyticsIntegration;
|
|
3155
|
+
googleTagManager: typeof createGoogleTagManagerIntegration;
|
|
3156
|
+
userway: typeof createUserWayIntegration;
|
|
3157
|
+
};
|
|
2974
3158
|
/**
|
|
2975
|
-
*
|
|
2976
|
-
* Configura o widget de chat e suporte do Zendesk.
|
|
3159
|
+
* Configuração para integração do Facebook Pixel.
|
|
2977
3160
|
*
|
|
2978
3161
|
* @category Utils
|
|
2979
|
-
* @param config - Configuração do Zendesk Chat
|
|
2980
|
-
* @returns Integração configurada para o Zendesk Chat
|
|
2981
3162
|
* @since 0.4.1
|
|
2982
3163
|
*
|
|
2983
3164
|
* @example
|
|
2984
3165
|
* ```typescript
|
|
2985
|
-
* const
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
3166
|
+
* const config: FacebookPixelConfig = {
|
|
3167
|
+
* pixelId: '1234567890123456',
|
|
3168
|
+
* autoTrack: true,
|
|
3169
|
+
* advancedMatching: { email: 'user@example.com' }
|
|
3170
|
+
* }
|
|
2988
3171
|
* ```
|
|
2989
|
-
*
|
|
2990
|
-
* @remarks
|
|
2991
|
-
* - Define cookies: __zlcmid, _zendesk_shared_session
|
|
2992
|
-
* - Categoria padrão: 'functional'
|
|
2993
|
-
* - SSR-safe: verifica disponibilidade do window
|
|
2994
|
-
* - Inclui tratamento de erro na identificação
|
|
2995
3172
|
*/
|
|
2996
|
-
|
|
3173
|
+
interface FacebookPixelConfig {
|
|
3174
|
+
/** ID do pixel do Facebook */
|
|
3175
|
+
pixelId: string;
|
|
3176
|
+
/** Se deve rastrear PageView automaticamente. Padrão: true */
|
|
3177
|
+
autoTrack?: boolean;
|
|
3178
|
+
/** Configuração de correspondência avançada */
|
|
3179
|
+
advancedMatching?: Record<string, unknown>;
|
|
3180
|
+
/** URL do script do Pixel. Se omitido usa o padrão oficial. */
|
|
3181
|
+
scriptUrl?: string;
|
|
3182
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3183
|
+
category?: string;
|
|
3184
|
+
}
|
|
2997
3185
|
/**
|
|
2998
|
-
* Configuração para
|
|
2999
|
-
* Define configurações opcionais para múltiplas integrações otimizadas para e-commerce.
|
|
3186
|
+
* Configuração para integração do Hotjar.
|
|
3000
3187
|
*
|
|
3001
3188
|
* @category Utils
|
|
3002
3189
|
* @since 0.4.1
|
|
3003
3190
|
*
|
|
3004
3191
|
* @example
|
|
3005
3192
|
* ```typescript
|
|
3006
|
-
* const config:
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
3193
|
+
* const config: HotjarConfig = {
|
|
3194
|
+
* siteId: '1234567',
|
|
3195
|
+
* version: 6,
|
|
3196
|
+
* debug: false
|
|
3009
3197
|
* }
|
|
3010
3198
|
* ```
|
|
3011
3199
|
*/
|
|
3012
|
-
interface
|
|
3013
|
-
/**
|
|
3014
|
-
|
|
3015
|
-
/**
|
|
3016
|
-
|
|
3017
|
-
/**
|
|
3018
|
-
|
|
3019
|
-
/**
|
|
3020
|
-
|
|
3200
|
+
interface HotjarConfig {
|
|
3201
|
+
/** ID do site no Hotjar */
|
|
3202
|
+
siteId: string;
|
|
3203
|
+
/** Versão do script Hotjar. Padrão: 6 */
|
|
3204
|
+
version?: number;
|
|
3205
|
+
/** Ativar modo debug. Padrão: false */
|
|
3206
|
+
debug?: boolean;
|
|
3207
|
+
/** URL do script Hotjar. Se omitido usa o padrão oficial. */
|
|
3208
|
+
scriptUrl?: string;
|
|
3209
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3210
|
+
category?: string;
|
|
3021
3211
|
}
|
|
3022
3212
|
/**
|
|
3023
|
-
* Configuração para
|
|
3024
|
-
* Define configurações opcionais para múltiplas integrações otimizadas para SaaS.
|
|
3213
|
+
* Configuração para integração do Mixpanel.
|
|
3025
3214
|
*
|
|
3026
3215
|
* @category Utils
|
|
3027
3216
|
* @since 0.4.1
|
|
3028
3217
|
*
|
|
3029
3218
|
* @example
|
|
3030
3219
|
* ```typescript
|
|
3031
|
-
* const config:
|
|
3032
|
-
*
|
|
3033
|
-
*
|
|
3034
|
-
*
|
|
3220
|
+
* const config: MixpanelConfig = {
|
|
3221
|
+
* token: 'your-project-token',
|
|
3222
|
+
* config: { debug: true },
|
|
3223
|
+
* api_host: 'https://api.mixpanel.com'
|
|
3035
3224
|
* }
|
|
3036
3225
|
* ```
|
|
3037
3226
|
*/
|
|
3038
|
-
interface
|
|
3039
|
-
/**
|
|
3040
|
-
|
|
3041
|
-
/**
|
|
3042
|
-
|
|
3043
|
-
/**
|
|
3044
|
-
|
|
3045
|
-
/**
|
|
3046
|
-
|
|
3227
|
+
interface MixpanelConfig {
|
|
3228
|
+
/** Token do projeto Mixpanel */
|
|
3229
|
+
token: string;
|
|
3230
|
+
/** Configurações adicionais do Mixpanel */
|
|
3231
|
+
config?: Record<string, unknown>;
|
|
3232
|
+
/** Host customizado da API Mixpanel */
|
|
3233
|
+
api_host?: string;
|
|
3234
|
+
/** URL do script Mixpanel. Se omitido usa o padrão oficial. */
|
|
3235
|
+
scriptUrl?: string;
|
|
3236
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3237
|
+
category?: string;
|
|
3047
3238
|
}
|
|
3048
3239
|
/**
|
|
3049
|
-
* Configuração para
|
|
3050
|
-
* Define configurações opcionais para múltiplas integrações otimizadas para ambientes corporativos.
|
|
3240
|
+
* Configuração para integração do Microsoft Clarity.
|
|
3051
3241
|
*
|
|
3052
3242
|
* @category Utils
|
|
3053
3243
|
* @since 0.4.1
|
|
3054
3244
|
*
|
|
3055
3245
|
* @example
|
|
3056
3246
|
* ```typescript
|
|
3057
|
-
* const config:
|
|
3058
|
-
*
|
|
3059
|
-
*
|
|
3060
|
-
* userway: { accountId: 'XXXXXXXXXX' }
|
|
3247
|
+
* const config: ClarityConfig = {
|
|
3248
|
+
* projectId: 'abcdefghij',
|
|
3249
|
+
* upload: true
|
|
3061
3250
|
* }
|
|
3062
3251
|
* ```
|
|
3063
3252
|
*/
|
|
3064
|
-
interface
|
|
3065
|
-
/**
|
|
3066
|
-
|
|
3067
|
-
/** Configuração
|
|
3068
|
-
|
|
3069
|
-
/**
|
|
3070
|
-
|
|
3071
|
-
/**
|
|
3072
|
-
|
|
3253
|
+
interface ClarityConfig {
|
|
3254
|
+
/** ID do projeto no Microsoft Clarity */
|
|
3255
|
+
projectId: string;
|
|
3256
|
+
/** Configuração de upload de dados. Padrão: indefinido */
|
|
3257
|
+
upload?: boolean;
|
|
3258
|
+
/** URL do script Clarity. Se omitido usa o padrão oficial. */
|
|
3259
|
+
scriptUrl?: string;
|
|
3260
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3261
|
+
category?: string;
|
|
3073
3262
|
}
|
|
3074
3263
|
/**
|
|
3075
|
-
*
|
|
3076
|
-
* Combina analytics de conversão, remarketing e acessibilidade.
|
|
3264
|
+
* Configuração para integração do Intercom.
|
|
3077
3265
|
*
|
|
3078
3266
|
* @category Utils
|
|
3079
|
-
* @param cfg - Configuração das integrações de e-commerce
|
|
3080
|
-
* @returns Array de integrações configuradas
|
|
3081
3267
|
* @since 0.4.1
|
|
3082
3268
|
*
|
|
3083
3269
|
* @example
|
|
3084
3270
|
* ```typescript
|
|
3085
|
-
* const
|
|
3086
|
-
*
|
|
3087
|
-
*
|
|
3088
|
-
* })
|
|
3271
|
+
* const config: IntercomConfig = {
|
|
3272
|
+
* app_id: 'your-app-id'
|
|
3273
|
+
* }
|
|
3089
3274
|
* ```
|
|
3090
|
-
*
|
|
3091
|
-
* @remarks
|
|
3092
|
-
* Combina categorias: analytics, marketing, functional
|
|
3093
3275
|
*/
|
|
3094
|
-
|
|
3276
|
+
interface IntercomConfig {
|
|
3277
|
+
/** ID da aplicação Intercom */
|
|
3278
|
+
app_id: string;
|
|
3279
|
+
/** URL do script Intercom. Se omitido usa o padrão oficial. */
|
|
3280
|
+
scriptUrl?: string;
|
|
3281
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3282
|
+
category?: string;
|
|
3283
|
+
}
|
|
3095
3284
|
/**
|
|
3096
|
-
*
|
|
3097
|
-
* Combina analytics de produto, suporte ao cliente e comportamento do usuário.
|
|
3285
|
+
* Configuração para integração do Zendesk Chat.
|
|
3098
3286
|
*
|
|
3099
3287
|
* @category Utils
|
|
3100
|
-
* @param cfg - Configuração das integrações de SaaS
|
|
3101
|
-
* @returns Array de integrações configuradas
|
|
3102
3288
|
* @since 0.4.1
|
|
3103
3289
|
*
|
|
3104
3290
|
* @example
|
|
3105
3291
|
* ```typescript
|
|
3106
|
-
* const
|
|
3107
|
-
*
|
|
3108
|
-
*
|
|
3109
|
-
* intercom: { app_id: 'your-app-id' }
|
|
3110
|
-
* })
|
|
3292
|
+
* const config: ZendeskConfig = {
|
|
3293
|
+
* key: 'your-zendesk-key'
|
|
3294
|
+
* }
|
|
3111
3295
|
* ```
|
|
3112
|
-
*
|
|
3113
|
-
* @remarks
|
|
3114
|
-
* Combina categorias: analytics, functional
|
|
3115
3296
|
*/
|
|
3116
|
-
|
|
3297
|
+
interface ZendeskConfig {
|
|
3298
|
+
/** Chave de identificação do Zendesk */
|
|
3299
|
+
key: string;
|
|
3300
|
+
/** URL do script Zendesk. Se omitido usa o padrão oficial. */
|
|
3301
|
+
scriptUrl?: string;
|
|
3302
|
+
/** Categoria LGPD customizada (opcional). */
|
|
3303
|
+
category?: string;
|
|
3304
|
+
}
|
|
3117
3305
|
/**
|
|
3118
|
-
* Cria
|
|
3119
|
-
*
|
|
3306
|
+
* Cria integração do Facebook Pixel.
|
|
3307
|
+
* Configura o fbq e inicializa o pixel com tracking automático opcional.
|
|
3120
3308
|
*
|
|
3121
3309
|
* @category Utils
|
|
3122
|
-
* @param
|
|
3123
|
-
* @returns
|
|
3310
|
+
* @param config - Configuração do Facebook Pixel
|
|
3311
|
+
* @returns Integração configurada para o Facebook Pixel
|
|
3124
3312
|
* @since 0.4.1
|
|
3125
3313
|
*
|
|
3126
3314
|
* @example
|
|
3127
3315
|
* ```typescript
|
|
3128
|
-
* const
|
|
3129
|
-
*
|
|
3130
|
-
*
|
|
3131
|
-
* userway: { accountId: 'XXXXXXXXXX' }
|
|
3316
|
+
* const pixel = createFacebookPixelIntegration({
|
|
3317
|
+
* pixelId: '1234567890123456',
|
|
3318
|
+
* autoTrack: true
|
|
3132
3319
|
* })
|
|
3133
3320
|
* ```
|
|
3134
3321
|
*
|
|
3135
3322
|
* @remarks
|
|
3136
|
-
*
|
|
3323
|
+
* - Define cookies: _fbp, fr
|
|
3324
|
+
* - Categoria padrão: 'marketing'
|
|
3325
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3137
3326
|
*/
|
|
3138
|
-
declare function
|
|
3327
|
+
declare function createFacebookPixelIntegration(config: FacebookPixelConfig): ScriptIntegration;
|
|
3139
3328
|
/**
|
|
3140
|
-
*
|
|
3141
|
-
*
|
|
3329
|
+
* Cria integração do Hotjar.
|
|
3330
|
+
* Configura as configurações do Hotjar e inicializa o tracking de heatmaps e gravações.
|
|
3142
3331
|
*
|
|
3143
3332
|
* @category Utils
|
|
3333
|
+
* @param config - Configuração do Hotjar
|
|
3334
|
+
* @returns Integração configurada para o Hotjar
|
|
3144
3335
|
* @since 0.4.1
|
|
3145
3336
|
*
|
|
3146
3337
|
* @example
|
|
3147
3338
|
* ```typescript
|
|
3148
|
-
* const
|
|
3149
|
-
*
|
|
3150
|
-
*
|
|
3339
|
+
* const hotjar = createHotjarIntegration({
|
|
3340
|
+
* siteId: '1234567',
|
|
3341
|
+
* debug: true
|
|
3342
|
+
* })
|
|
3151
3343
|
* ```
|
|
3152
3344
|
*
|
|
3153
3345
|
* @remarks
|
|
3154
|
-
*
|
|
3155
|
-
* -
|
|
3156
|
-
* -
|
|
3157
|
-
* - categories: categorias LGPD utilizadas
|
|
3346
|
+
* - Define cookies: _hjSession_*, _hjSessionUser_*, _hjFirstSeen, _hjIncludedInSessionSample, _hjAbsoluteSessionInProgress
|
|
3347
|
+
* - Categoria padrão: 'analytics'
|
|
3348
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3158
3349
|
*/
|
|
3159
|
-
declare
|
|
3160
|
-
ecommerce: {
|
|
3161
|
-
essential: string[];
|
|
3162
|
-
optional: string[];
|
|
3163
|
-
categories: string[];
|
|
3164
|
-
};
|
|
3165
|
-
saas: {
|
|
3166
|
-
essential: string[];
|
|
3167
|
-
optional: string[];
|
|
3168
|
-
categories: string[];
|
|
3169
|
-
};
|
|
3170
|
-
corporate: {
|
|
3171
|
-
essential: string[];
|
|
3172
|
-
optional: string[];
|
|
3173
|
-
categories: string[];
|
|
3174
|
-
};
|
|
3175
|
-
};
|
|
3350
|
+
declare function createHotjarIntegration(config: HotjarConfig): ScriptIntegration;
|
|
3176
3351
|
/**
|
|
3177
|
-
*
|
|
3178
|
-
*
|
|
3352
|
+
* Cria integração do Mixpanel.
|
|
3353
|
+
* Configura e inicializa o Mixpanel para analytics de eventos.
|
|
3179
3354
|
*
|
|
3180
3355
|
* @category Utils
|
|
3181
|
-
* @param
|
|
3182
|
-
* @returns
|
|
3356
|
+
* @param config - Configuração do Mixpanel
|
|
3357
|
+
* @returns Integração configurada para o Mixpanel
|
|
3183
3358
|
* @since 0.4.1
|
|
3184
3359
|
*
|
|
3185
3360
|
* @example
|
|
3186
3361
|
* ```typescript
|
|
3187
|
-
*
|
|
3188
|
-
*
|
|
3189
|
-
*
|
|
3190
|
-
*
|
|
3191
|
-
* ```
|
|
3192
|
-
*
|
|
3193
|
-
* @remarks
|
|
3194
|
-
* Heurísticas aplicadas:
|
|
3195
|
-
* - Scripts de ads/marketing → 'marketing'
|
|
3196
|
-
* - Scripts de analytics/tracking → 'analytics'
|
|
3197
|
-
* - Scripts de chat/suporte → 'functional'
|
|
3198
|
-
* - Padrão para desconhecidos → 'analytics'
|
|
3199
|
-
*/
|
|
3200
|
-
declare function suggestCategoryForScript(name: string): string[];
|
|
3201
|
-
|
|
3202
|
-
/**
|
|
3203
|
-
* Componente que carrega scripts automaticamente baseado no consentimento.
|
|
3204
|
-
* Facilita integração com ferramentas como Google Analytics, Tag Manager, etc.
|
|
3205
|
-
*/
|
|
3206
|
-
|
|
3207
|
-
interface ConsentScriptLoaderProps {
|
|
3208
|
-
/** Lista de integrações de scripts para carregar baseado no consentimento */
|
|
3209
|
-
integrations: ScriptIntegration[];
|
|
3210
|
-
/** Se true, força recarregamento se consentimento mudar */
|
|
3211
|
-
reloadOnChange?: boolean;
|
|
3212
|
-
/** Nonce CSP aplicado às tags <script> geradas automaticamente (sobrescrevível por integração). */
|
|
3213
|
-
nonce?: string;
|
|
3214
|
-
}
|
|
3215
|
-
/**
|
|
3216
|
-
* @component
|
|
3217
|
-
* @category Utils
|
|
3218
|
-
* @since 0.2.0
|
|
3219
|
-
* Componente que não renderiza UI, mas gerencia o carregamento de scripts de terceiros
|
|
3220
|
-
* (como Google Analytics) com base nas preferências de consentimento do usuário.
|
|
3221
|
-
*
|
|
3222
|
-
* @param props As propriedades do componente.
|
|
3223
|
-
* @param {ScriptIntegration[]} props.integrations Um array de objetos de integração de script. Use as factory functions (`createGoogleAnalyticsIntegration`, etc.) para criar.
|
|
3224
|
-
* @param {boolean} [props.reloadOnChange=false] Se `true`, recarrega os scripts se as preferências de consentimento mudarem.
|
|
3225
|
-
*
|
|
3226
|
-
* @example
|
|
3227
|
-
* ```tsx
|
|
3228
|
-
* const integrations = [
|
|
3229
|
-
* createGoogleAnalyticsIntegration({ measurementId: 'GA_ID' }),
|
|
3230
|
-
* createFacebookPixelIntegration({ pixelId: 'PIXEL_ID' })
|
|
3231
|
-
* ];
|
|
3232
|
-
*
|
|
3233
|
-
* <ConsentScriptLoader integrations={integrations} />
|
|
3234
|
-
* ```
|
|
3235
|
-
*/
|
|
3236
|
-
declare function ConsentScriptLoader({ integrations, reloadOnChange, nonce, }: Readonly<ConsentScriptLoaderProps>): null;
|
|
3237
|
-
/**
|
|
3238
|
-
* @hook
|
|
3239
|
-
* @category Hooks
|
|
3240
|
-
* @since 0.2.0
|
|
3241
|
-
* Hook para carregamento programático de um script baseado no consentimento.
|
|
3242
|
-
*
|
|
3243
|
-
* @returns Uma função assíncrona que recebe um objeto de integração de script e tenta carregá-lo.
|
|
3244
|
-
* Retorna `true` em caso de sucesso e `false` em caso de falha (por falta de consentimento ou erro de rede).
|
|
3245
|
-
*
|
|
3246
|
-
* @example
|
|
3247
|
-
* ```tsx
|
|
3248
|
-
* const loadScript = useConsentScriptLoader();
|
|
3249
|
-
*
|
|
3250
|
-
* useEffect(() => {
|
|
3251
|
-
* const handleUserAction = async () => {
|
|
3252
|
-
* const hotjarIntegration = { id: 'hotjar', category: 'analytics', src: '...' };
|
|
3253
|
-
* const success = await loadScript(hotjarIntegration);
|
|
3254
|
-
* if (success) {
|
|
3255
|
-
* console.log('Hotjar carregado com sucesso!');
|
|
3256
|
-
* }
|
|
3257
|
-
* };
|
|
3258
|
-
*
|
|
3259
|
-
* // Exemplo: carregar script após uma ação específica do usuário
|
|
3260
|
-
* myButton.addEventListener('click', handleUserAction);
|
|
3261
|
-
* }, [loadScript]);
|
|
3362
|
+
* const mixpanel = createMixpanelIntegration({
|
|
3363
|
+
* token: 'your-project-token',
|
|
3364
|
+
* config: { debug: true }
|
|
3365
|
+
* })
|
|
3262
3366
|
* ```
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
*
|
|
3268
|
-
*
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
/**
|
|
3273
|
-
* @interface CategoryAutoConfigResult
|
|
3274
|
-
* Resultado da análise e auto-configuração de categorias
|
|
3275
|
-
*/
|
|
3276
|
-
interface CategoryAutoConfigResult {
|
|
3277
|
-
/** Configuração original fornecida pelo desenvolvedor */
|
|
3278
|
-
originalConfig: ProjectCategoriesConfig;
|
|
3279
|
-
/** Configuração ajustada automaticamente pela biblioteca */
|
|
3280
|
-
adjustedConfig: ProjectCategoriesConfig;
|
|
3281
|
-
/** Categorias que foram automaticamente habilitadas */
|
|
3282
|
-
autoEnabledCategories: string[];
|
|
3283
|
-
/** Categorias requeridas pelas integrações mas não habilitadas */
|
|
3284
|
-
missingCategories: string[];
|
|
3285
|
-
/** Se algum ajuste foi necessário */
|
|
3286
|
-
wasAdjusted: boolean;
|
|
3287
|
-
/** Integrações que requerem cada categoria */
|
|
3288
|
-
categoryIntegrations: Record<string, string[]>;
|
|
3289
|
-
}
|
|
3367
|
+
*
|
|
3368
|
+
* @remarks
|
|
3369
|
+
* - Define cookies: mp_*
|
|
3370
|
+
* - Categoria padrão: 'analytics'
|
|
3371
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3372
|
+
* - Inclui tratamento de erro na inicialização
|
|
3373
|
+
*/
|
|
3374
|
+
declare function createMixpanelIntegration(config: MixpanelConfig): ScriptIntegration;
|
|
3290
3375
|
/**
|
|
3291
|
-
*
|
|
3376
|
+
* Cria integração do Microsoft Clarity.
|
|
3377
|
+
* Configura o Microsoft Clarity para heatmaps e analytics de comportamento.
|
|
3378
|
+
*
|
|
3292
3379
|
* @category Utils
|
|
3380
|
+
* @param config - Configuração do Microsoft Clarity
|
|
3381
|
+
* @returns Integração configurada para o Clarity
|
|
3293
3382
|
* @since 0.4.1
|
|
3294
|
-
* Analisa as integrações fornecidas e determina quais categorias são necessárias.
|
|
3295
3383
|
*
|
|
3296
|
-
* @
|
|
3297
|
-
*
|
|
3384
|
+
* @example
|
|
3385
|
+
* ```typescript
|
|
3386
|
+
* const clarity = createClarityIntegration({
|
|
3387
|
+
* projectId: 'abcdefghij',
|
|
3388
|
+
* upload: false
|
|
3389
|
+
* })
|
|
3390
|
+
* ```
|
|
3391
|
+
*
|
|
3392
|
+
* @remarks
|
|
3393
|
+
* - Define cookies: _clck, _clsk, CLID, ANONCHK, MR, MUID, SM
|
|
3394
|
+
* - Categoria padrão: 'analytics'
|
|
3395
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3396
|
+
* - Configuração de upload opcional
|
|
3298
3397
|
*/
|
|
3299
|
-
declare function
|
|
3398
|
+
declare function createClarityIntegration(config: ClarityConfig): ScriptIntegration;
|
|
3300
3399
|
/**
|
|
3301
|
-
*
|
|
3400
|
+
* Cria integração do Intercom.
|
|
3401
|
+
* Configura o widget de chat e suporte do Intercom.
|
|
3402
|
+
*
|
|
3302
3403
|
* @category Utils
|
|
3404
|
+
* @param config - Configuração do Intercom
|
|
3405
|
+
* @returns Integração configurada para o Intercom
|
|
3303
3406
|
* @since 0.4.1
|
|
3304
|
-
* Configura automaticamente as categorias necessárias baseado nas integrações utilizadas.
|
|
3305
3407
|
*
|
|
3306
|
-
*
|
|
3307
|
-
*
|
|
3308
|
-
*
|
|
3309
|
-
*
|
|
3310
|
-
*
|
|
3408
|
+
* @example
|
|
3409
|
+
* ```typescript
|
|
3410
|
+
* const intercom = createIntercomIntegration({
|
|
3411
|
+
* app_id: 'your-app-id'
|
|
3412
|
+
* })
|
|
3413
|
+
* ```
|
|
3311
3414
|
*
|
|
3312
|
-
* @
|
|
3313
|
-
*
|
|
3314
|
-
*
|
|
3315
|
-
*
|
|
3415
|
+
* @remarks
|
|
3416
|
+
* - Define cookies: intercom-id-*, intercom-session-*
|
|
3417
|
+
* - Categoria padrão: 'functional'
|
|
3418
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3419
|
+
* - Inclui tratamento de erro na inicialização
|
|
3316
3420
|
*/
|
|
3317
|
-
declare function
|
|
3318
|
-
/** Se true, apenas avisa mas não modifica a config (padrão: false - auto-habilita) */
|
|
3319
|
-
warningOnly?: boolean;
|
|
3320
|
-
/** Se true, desabilita logs no console (padrão: false) */
|
|
3321
|
-
silent?: boolean;
|
|
3322
|
-
}): CategoryAutoConfigResult;
|
|
3421
|
+
declare function createIntercomIntegration(config: IntercomConfig): ScriptIntegration;
|
|
3323
3422
|
/**
|
|
3324
|
-
*
|
|
3423
|
+
* Cria integração do Zendesk Chat.
|
|
3424
|
+
* Configura o widget de chat e suporte do Zendesk.
|
|
3425
|
+
*
|
|
3325
3426
|
* @category Utils
|
|
3427
|
+
* @param config - Configuração do Zendesk Chat
|
|
3428
|
+
* @returns Integração configurada para o Zendesk Chat
|
|
3326
3429
|
* @since 0.4.1
|
|
3327
|
-
* Valida se todas as integrações têm suas categorias habilitadas.
|
|
3328
|
-
* Útil para validação em tempo de execução.
|
|
3329
3430
|
*
|
|
3330
|
-
* @
|
|
3331
|
-
*
|
|
3332
|
-
*
|
|
3431
|
+
* @example
|
|
3432
|
+
* ```typescript
|
|
3433
|
+
* const zendesk = createZendeskChatIntegration({
|
|
3434
|
+
* key: 'your-zendesk-key'
|
|
3435
|
+
* })
|
|
3436
|
+
* ```
|
|
3437
|
+
*
|
|
3438
|
+
* @remarks
|
|
3439
|
+
* - Define cookies: __zlcmid, _zendesk_shared_session
|
|
3440
|
+
* - Categoria padrão: 'functional'
|
|
3441
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
3442
|
+
* - Inclui tratamento de erro na identificação
|
|
3333
3443
|
*/
|
|
3334
|
-
declare function
|
|
3444
|
+
declare function createZendeskChatIntegration(config: ZendeskConfig): ScriptIntegration;
|
|
3335
3445
|
/**
|
|
3336
|
-
*
|
|
3446
|
+
* Configuração para conjunto de integrações de e-commerce.
|
|
3447
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para e-commerce.
|
|
3448
|
+
*
|
|
3337
3449
|
* @category Utils
|
|
3338
3450
|
* @since 0.4.1
|
|
3339
|
-
* Extrai categorias únicas de um array de integrações
|
|
3340
3451
|
*
|
|
3341
|
-
* @
|
|
3342
|
-
*
|
|
3452
|
+
* @example
|
|
3453
|
+
* ```typescript
|
|
3454
|
+
* const config: ECommerceConfig = {
|
|
3455
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3456
|
+
* facebookPixel: { pixelId: '1234567890123456' }
|
|
3457
|
+
* }
|
|
3458
|
+
* ```
|
|
3343
3459
|
*/
|
|
3344
|
-
|
|
3460
|
+
interface ECommerceConfig {
|
|
3461
|
+
/** Configuração do Google Analytics */
|
|
3462
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
3463
|
+
/** Configuração do Facebook Pixel */
|
|
3464
|
+
facebookPixel?: FacebookPixelConfig;
|
|
3465
|
+
/** Configuração do Hotjar */
|
|
3466
|
+
hotjar?: HotjarConfig;
|
|
3467
|
+
/** Configuração do UserWay */
|
|
3468
|
+
userway?: UserWayConfig;
|
|
3469
|
+
}
|
|
3345
3470
|
/**
|
|
3346
|
-
*
|
|
3471
|
+
* Configuração para conjunto de integrações de SaaS.
|
|
3472
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para SaaS.
|
|
3473
|
+
*
|
|
3347
3474
|
* @category Utils
|
|
3348
3475
|
* @since 0.4.1
|
|
3349
|
-
* Valida se integrações estão sendo incorretamente classificadas como "necessary".
|
|
3350
|
-
*
|
|
3351
|
-
* Esta função protege contra violações de GDPR/LGPD identificando scripts que
|
|
3352
|
-
* NUNCA devem ser considerados estritamente necessários.
|
|
3353
|
-
*
|
|
3354
|
-
* @param integrations Array de integrações para validar
|
|
3355
|
-
* @param enabledCategories Categorias habilitadas na configuração
|
|
3356
|
-
* @returns Lista de avisos sobre classificações incorretas
|
|
3357
3476
|
*
|
|
3358
3477
|
* @example
|
|
3359
3478
|
* ```typescript
|
|
3360
|
-
* const
|
|
3361
|
-
*
|
|
3362
|
-
*
|
|
3363
|
-
*
|
|
3364
|
-
*
|
|
3365
|
-
* if (warnings.length > 0) {
|
|
3366
|
-
* console.warn('Scripts incorretamente classificados como necessary:', warnings)
|
|
3479
|
+
* const config: SaaSConfig = {
|
|
3480
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3481
|
+
* mixpanel: { token: 'your-token' },
|
|
3482
|
+
* intercom: { app_id: 'your-app-id' }
|
|
3367
3483
|
* }
|
|
3368
3484
|
* ```
|
|
3369
3485
|
*/
|
|
3370
|
-
|
|
3371
|
-
|
|
3486
|
+
interface SaaSConfig {
|
|
3487
|
+
/** Configuração do Google Analytics */
|
|
3488
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
3489
|
+
/** Configuração do Mixpanel */
|
|
3490
|
+
mixpanel?: MixpanelConfig;
|
|
3491
|
+
/** Configuração do Intercom */
|
|
3492
|
+
intercom?: IntercomConfig;
|
|
3493
|
+
/** Configuração do Hotjar */
|
|
3494
|
+
hotjar?: HotjarConfig;
|
|
3495
|
+
}
|
|
3372
3496
|
/**
|
|
3373
|
-
*
|
|
3497
|
+
* Configuração para conjunto de integrações corporativas.
|
|
3498
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para ambientes corporativos.
|
|
3374
3499
|
*
|
|
3375
3500
|
* @category Utils
|
|
3376
|
-
* @since 0.
|
|
3501
|
+
* @since 0.4.1
|
|
3502
|
+
*
|
|
3503
|
+
* @example
|
|
3504
|
+
* ```typescript
|
|
3505
|
+
* const config: CorporateConfig = {
|
|
3506
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3507
|
+
* clarity: { projectId: 'abcdefghij' },
|
|
3508
|
+
* userway: { accountId: 'XXXXXXXXXX' }
|
|
3509
|
+
* }
|
|
3510
|
+
* ```
|
|
3377
3511
|
*/
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
/**
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
* Overrides de descrições por categoria.
|
|
3388
|
-
*/
|
|
3389
|
-
descriptions?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3390
|
-
/**
|
|
3391
|
-
* Overrides de nomes por categoria.
|
|
3392
|
-
*/
|
|
3393
|
-
names?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3512
|
+
interface CorporateConfig {
|
|
3513
|
+
/** Configuração do Google Analytics */
|
|
3514
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
3515
|
+
/** Configuração do Microsoft Clarity */
|
|
3516
|
+
clarity?: ClarityConfig;
|
|
3517
|
+
/** Configuração do Zendesk Chat */
|
|
3518
|
+
zendesk?: ZendeskConfig;
|
|
3519
|
+
/** Configuração do UserWay */
|
|
3520
|
+
userway?: UserWayConfig;
|
|
3394
3521
|
}
|
|
3395
3522
|
/**
|
|
3396
|
-
*
|
|
3523
|
+
* Cria conjunto de integrações otimizado para e-commerce.
|
|
3524
|
+
* Combina analytics de conversão, remarketing e acessibilidade.
|
|
3397
3525
|
*
|
|
3398
3526
|
* @category Utils
|
|
3399
|
-
* @
|
|
3527
|
+
* @param cfg - Configuração das integrações de e-commerce
|
|
3528
|
+
* @returns Array de integrações configuradas
|
|
3529
|
+
* @since 0.4.1
|
|
3530
|
+
*
|
|
3531
|
+
* @example
|
|
3532
|
+
* ```typescript
|
|
3533
|
+
* const integrations = createECommerceIntegrations({
|
|
3534
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3535
|
+
* facebookPixel: { pixelId: '1234567890123456' }
|
|
3536
|
+
* })
|
|
3537
|
+
* ```
|
|
3538
|
+
*
|
|
3539
|
+
* @remarks
|
|
3540
|
+
* Combina categorias: analytics, marketing, functional
|
|
3400
3541
|
*/
|
|
3401
|
-
declare function
|
|
3402
|
-
|
|
3542
|
+
declare function createECommerceIntegrations(cfg: ECommerceConfig): ScriptIntegration[];
|
|
3403
3543
|
/**
|
|
3404
|
-
*
|
|
3405
|
-
*
|
|
3406
|
-
* contextos específicos e variações de tom.
|
|
3544
|
+
* Cria conjunto de integrações otimizado para SaaS.
|
|
3545
|
+
* Combina analytics de produto, suporte ao cliente e comportamento do usuário.
|
|
3407
3546
|
*
|
|
3408
|
-
* @
|
|
3547
|
+
* @category Utils
|
|
3548
|
+
* @param cfg - Configuração das integrações de SaaS
|
|
3549
|
+
* @returns Array de integrações configuradas
|
|
3409
3550
|
* @since 0.4.1
|
|
3410
|
-
*/
|
|
3411
|
-
|
|
3412
|
-
/**
|
|
3413
|
-
* Tipo auxiliar para variações de texto.
|
|
3414
3551
|
*
|
|
3415
|
-
*
|
|
3416
|
-
*
|
|
3417
|
-
|
|
3552
|
+
* @example
|
|
3553
|
+
* ```typescript
|
|
3554
|
+
* const integrations = createSaaSIntegrations({
|
|
3555
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3556
|
+
* mixpanel: { token: 'your-project-token' },
|
|
3557
|
+
* intercom: { app_id: 'your-app-id' }
|
|
3558
|
+
* })
|
|
3559
|
+
* ```
|
|
3418
3560
|
*
|
|
3419
|
-
* @
|
|
3420
|
-
*
|
|
3561
|
+
* @remarks
|
|
3562
|
+
* Combina categorias: analytics, functional
|
|
3421
3563
|
*/
|
|
3422
|
-
|
|
3564
|
+
declare function createSaaSIntegrations(cfg: SaaSConfig): ScriptIntegration[];
|
|
3423
3565
|
/**
|
|
3424
|
-
*
|
|
3566
|
+
* Cria conjunto de integrações otimizado para ambientes corporativos.
|
|
3567
|
+
* Combina analytics empresariais, compliance e suporte corporativo.
|
|
3425
3568
|
*
|
|
3426
|
-
*
|
|
3427
|
-
*
|
|
3569
|
+
* @category Utils
|
|
3570
|
+
* @param cfg - Configuração das integrações corporativas
|
|
3571
|
+
* @returns Array de integrações configuradas
|
|
3572
|
+
* @since 0.4.1
|
|
3573
|
+
*
|
|
3574
|
+
* @example
|
|
3575
|
+
* ```typescript
|
|
3576
|
+
* const integrations = createCorporateIntegrations({
|
|
3577
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
3578
|
+
* clarity: { projectId: 'abcdefghij' },
|
|
3579
|
+
* userway: { accountId: 'XXXXXXXXXX' }
|
|
3580
|
+
* })
|
|
3581
|
+
* ```
|
|
3428
3582
|
*
|
|
3429
|
-
* @
|
|
3430
|
-
*
|
|
3583
|
+
* @remarks
|
|
3584
|
+
* Combina categorias: analytics, functional
|
|
3431
3585
|
*/
|
|
3432
|
-
|
|
3586
|
+
declare function createCorporateIntegrations(cfg: CorporateConfig): ScriptIntegration[];
|
|
3433
3587
|
/**
|
|
3434
|
-
*
|
|
3435
|
-
*
|
|
3436
|
-
* Interface expandida que permite personalização granular de todas as mensagens da biblioteca.
|
|
3437
|
-
* Suporta múltiplos idiomas, contextos específicos (e-commerce, SaaS, governo), variações
|
|
3438
|
-
* de tom, e compliance completo com LGPD/ANPD.
|
|
3588
|
+
* Templates pré-configurados de integrações por tipo de negócio.
|
|
3589
|
+
* Define integrações essenciais e opcionais para cada contexto.
|
|
3439
3590
|
*
|
|
3440
|
-
* @category
|
|
3591
|
+
* @category Utils
|
|
3441
3592
|
* @since 0.4.1
|
|
3442
|
-
* @remarks
|
|
3443
|
-
* **Histórico**: v0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
3444
3593
|
*
|
|
3445
|
-
* @example
|
|
3594
|
+
* @example
|
|
3446
3595
|
* ```typescript
|
|
3447
|
-
* const
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
* acceptAll: 'Aceitar todos',
|
|
3451
|
-
* declineAll: 'Recusar',
|
|
3452
|
-
* preferences: 'Preferências',
|
|
3453
|
-
* modalTitle: 'Preferências de Cookies',
|
|
3454
|
-
* modalIntro: 'Personalize suas preferências de cookies.',
|
|
3455
|
-
* save: 'Salvar',
|
|
3456
|
-
* necessaryAlwaysOn: 'Cookies necessários (sempre ativos)',
|
|
3457
|
-
*
|
|
3458
|
-
* // Textos expandidos
|
|
3459
|
-
* variants: {
|
|
3460
|
-
* formal: {
|
|
3461
|
-
* bannerMessage: 'Este sítio utiliza cookies para otimizar a experiência de navegação.',
|
|
3462
|
-
* acceptAll: 'Concordar com todos os cookies'
|
|
3463
|
-
* },
|
|
3464
|
-
* casual: {
|
|
3465
|
-
* bannerMessage: '🍪 Olá! Usamos cookies para tornar tudo mais gostoso aqui.',
|
|
3466
|
-
* acceptAll: 'Aceitar tudo'
|
|
3467
|
-
* }
|
|
3468
|
-
* },
|
|
3469
|
-
*
|
|
3470
|
-
* // Internacionalização
|
|
3471
|
-
* i18n: {
|
|
3472
|
-
* en: {
|
|
3473
|
-
* bannerMessage: 'We use cookies to enhance your experience.',
|
|
3474
|
-
* acceptAll: 'Accept All',
|
|
3475
|
-
* declineAll: 'Decline'
|
|
3476
|
-
* },
|
|
3477
|
-
* es: {
|
|
3478
|
-
* bannerMessage: 'Utilizamos cookies para mejorar su experiencia.',
|
|
3479
|
-
* acceptAll: 'Aceptar Todo',
|
|
3480
|
-
* declineAll: 'Rechazar'
|
|
3481
|
-
* }
|
|
3482
|
-
* }
|
|
3483
|
-
* }
|
|
3596
|
+
* const template = INTEGRATION_TEMPLATES.ecommerce
|
|
3597
|
+
* console.log(template.essential) // ['google-analytics', 'facebook-pixel']
|
|
3598
|
+
* console.log(template.categories) // ['analytics', 'marketing', 'functional']
|
|
3484
3599
|
* ```
|
|
3600
|
+
*
|
|
3601
|
+
* @remarks
|
|
3602
|
+
* Cada template define:
|
|
3603
|
+
* - essential: integrações obrigatórias/recomendadas
|
|
3604
|
+
* - optional: integrações complementares
|
|
3605
|
+
* - categories: categorias LGPD utilizadas
|
|
3485
3606
|
*/
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
/** Texto de carregamento */
|
|
3492
|
-
loading?: string;
|
|
3493
|
-
/** Textos específicos para cada categoria de cookie */
|
|
3494
|
-
categories?: {
|
|
3495
|
-
necessary?: {
|
|
3496
|
-
name?: string;
|
|
3497
|
-
description?: string;
|
|
3498
|
-
examples?: string;
|
|
3499
|
-
};
|
|
3500
|
-
analytics?: {
|
|
3501
|
-
name?: string;
|
|
3502
|
-
description?: string;
|
|
3503
|
-
examples?: string;
|
|
3504
|
-
};
|
|
3505
|
-
marketing?: {
|
|
3506
|
-
name?: string;
|
|
3507
|
-
description?: string;
|
|
3508
|
-
examples?: string;
|
|
3509
|
-
};
|
|
3510
|
-
functional?: {
|
|
3511
|
-
name?: string;
|
|
3512
|
-
description?: string;
|
|
3513
|
-
examples?: string;
|
|
3514
|
-
};
|
|
3515
|
-
performance?: {
|
|
3516
|
-
name?: string;
|
|
3517
|
-
description?: string;
|
|
3518
|
-
examples?: string;
|
|
3519
|
-
};
|
|
3520
|
-
};
|
|
3521
|
-
/** Mensagens de feedback ao usuário */
|
|
3522
|
-
feedback?: {
|
|
3523
|
-
/** Preferências salvas com sucesso */
|
|
3524
|
-
saveSuccess?: string;
|
|
3525
|
-
/** Erro ao salvar preferências */
|
|
3526
|
-
saveError?: string;
|
|
3527
|
-
/** Consentimento atualizado */
|
|
3528
|
-
consentUpdated?: string;
|
|
3529
|
-
/** Cookies rejeitados */
|
|
3530
|
-
cookiesRejected?: string;
|
|
3531
|
-
/** Configurações resetadas */
|
|
3532
|
-
settingsReset?: string;
|
|
3533
|
-
};
|
|
3534
|
-
/** Labels ARIA e textos para leitores de tela */
|
|
3535
|
-
accessibility?: {
|
|
3536
|
-
/** Label do banner para leitores de tela */
|
|
3537
|
-
bannerLabel?: string;
|
|
3538
|
-
/** Label do modal para leitores de tela */
|
|
3539
|
-
modalLabel?: string;
|
|
3540
|
-
/** Instrução de navegação por teclado */
|
|
3541
|
-
keyboardNavigation?: string;
|
|
3542
|
-
/** Estado do toggle de categoria */
|
|
3543
|
-
toggleState?: {
|
|
3544
|
-
enabled?: string;
|
|
3545
|
-
disabled?: string;
|
|
3546
|
-
};
|
|
3547
|
-
/** Região live para anúncios dinâmicos */
|
|
3548
|
-
liveRegion?: string;
|
|
3549
|
-
};
|
|
3550
|
-
/** Textos otimizados para diferentes contextos */
|
|
3551
|
-
contexts?: {
|
|
3552
|
-
/** Contexto e-commerce */
|
|
3553
|
-
ecommerce?: {
|
|
3554
|
-
cartAbandonment?: string;
|
|
3555
|
-
personalizedOffers?: string;
|
|
3556
|
-
paymentSecurity?: string;
|
|
3557
|
-
productRecommendations?: string;
|
|
3558
|
-
};
|
|
3559
|
-
/** Contexto SaaS */
|
|
3560
|
-
saas?: {
|
|
3561
|
-
userAnalytics?: string;
|
|
3562
|
-
performanceMonitoring?: string;
|
|
3563
|
-
featureUsage?: string;
|
|
3564
|
-
customerSupport?: string;
|
|
3565
|
-
};
|
|
3566
|
-
/** Contexto governamental */
|
|
3567
|
-
government?: {
|
|
3568
|
-
citizenServices?: string;
|
|
3569
|
-
dataProtection?: string;
|
|
3570
|
-
transparency?: string;
|
|
3571
|
-
accessibility?: string;
|
|
3572
|
-
};
|
|
3573
|
-
/** Contexto educacional */
|
|
3574
|
-
education?: {
|
|
3575
|
-
studentProgress?: string;
|
|
3576
|
-
learningAnalytics?: string;
|
|
3577
|
-
accessibility?: string;
|
|
3578
|
-
parentalConsent?: string;
|
|
3579
|
-
};
|
|
3580
|
-
};
|
|
3581
|
-
/** Diferentes variações de tom para a mesma mensagem */
|
|
3582
|
-
variants?: {
|
|
3583
|
-
/** Tom formal/profissional */
|
|
3584
|
-
formal?: TextVariant;
|
|
3585
|
-
/** Tom casual/amigável */
|
|
3586
|
-
casual?: TextVariant;
|
|
3587
|
-
/** Tom conciso/direto */
|
|
3588
|
-
concise?: TextVariant;
|
|
3589
|
-
/** Tom detalhado/explicativo */
|
|
3590
|
-
detailed?: TextVariant;
|
|
3591
|
-
};
|
|
3592
|
-
/** Suporte a múltiplos idiomas */
|
|
3593
|
-
i18n?: {
|
|
3594
|
-
/** Textos em inglês */
|
|
3595
|
-
en?: LanguageTexts;
|
|
3596
|
-
/** Textos em espanhol */
|
|
3597
|
-
es?: LanguageTexts;
|
|
3598
|
-
/** Textos em francês */
|
|
3599
|
-
fr?: LanguageTexts;
|
|
3600
|
-
/** Textos em alemão */
|
|
3601
|
-
de?: LanguageTexts;
|
|
3602
|
-
/** Textos em italiano */
|
|
3603
|
-
it?: LanguageTexts;
|
|
3607
|
+
declare const INTEGRATION_TEMPLATES: {
|
|
3608
|
+
ecommerce: {
|
|
3609
|
+
essential: string[];
|
|
3610
|
+
optional: string[];
|
|
3611
|
+
categories: string[];
|
|
3604
3612
|
};
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
/** Explicação sobre cookies persistentes */
|
|
3610
|
-
persistentCookies?: string;
|
|
3611
|
-
/** Explicação sobre cookies de terceiros */
|
|
3612
|
-
thirdPartyCookies?: string;
|
|
3613
|
-
/** Como desabilitar cookies no navegador */
|
|
3614
|
-
browserSettings?: string;
|
|
3615
|
-
/** Impacto de desabilitar cookies */
|
|
3616
|
-
disablingImpact?: string;
|
|
3613
|
+
saas: {
|
|
3614
|
+
essential: string[];
|
|
3615
|
+
optional: string[];
|
|
3616
|
+
categories: string[];
|
|
3617
3617
|
};
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
purpose?: string;
|
|
3623
|
-
duration?: string;
|
|
3624
|
-
provider?: string;
|
|
3625
|
-
type?: string;
|
|
3626
|
-
};
|
|
3627
|
-
/** Texto quando não há cookies para mostrar */
|
|
3628
|
-
noCookies?: string;
|
|
3629
|
-
/** Botão para expandir/colapsar detalhes */
|
|
3630
|
-
toggleDetails?: {
|
|
3631
|
-
expand?: string;
|
|
3632
|
-
collapse?: string;
|
|
3633
|
-
};
|
|
3618
|
+
corporate: {
|
|
3619
|
+
essential: string[];
|
|
3620
|
+
optional: string[];
|
|
3621
|
+
categories: string[];
|
|
3634
3622
|
};
|
|
3623
|
+
};
|
|
3624
|
+
/**
|
|
3625
|
+
* Sugere categorias LGPD apropriadas para um script baseado no nome/tipo.
|
|
3626
|
+
* Utiliza heurísticas para classificar scripts desconhecidos.
|
|
3627
|
+
*
|
|
3628
|
+
* @category Utils
|
|
3629
|
+
* @param name - Nome ou identificador do script
|
|
3630
|
+
* @returns Array de categorias sugeridas
|
|
3631
|
+
* @since 0.4.1
|
|
3632
|
+
*
|
|
3633
|
+
* @example
|
|
3634
|
+
* ```typescript
|
|
3635
|
+
* suggestCategoryForScript('facebook-pixel') // ['marketing']
|
|
3636
|
+
* suggestCategoryForScript('hotjar') // ['analytics']
|
|
3637
|
+
* suggestCategoryForScript('intercom-chat') // ['functional']
|
|
3638
|
+
* suggestCategoryForScript('unknown-script') // ['analytics']
|
|
3639
|
+
* ```
|
|
3640
|
+
*
|
|
3641
|
+
* @remarks
|
|
3642
|
+
* Heurísticas aplicadas:
|
|
3643
|
+
* - Scripts de ads/marketing → 'marketing'
|
|
3644
|
+
* - Scripts de analytics/tracking → 'analytics'
|
|
3645
|
+
* - Scripts de chat/suporte → 'functional'
|
|
3646
|
+
* - Padrão para desconhecidos → 'analytics'
|
|
3647
|
+
*/
|
|
3648
|
+
declare function suggestCategoryForScript(name: string): string[];
|
|
3649
|
+
|
|
3650
|
+
/**
|
|
3651
|
+
* Componente que carrega scripts automaticamente baseado no consentimento.
|
|
3652
|
+
* Facilita integração com ferramentas como Google Analytics, Tag Manager, etc.
|
|
3653
|
+
*/
|
|
3654
|
+
|
|
3655
|
+
interface RegisteredScript {
|
|
3656
|
+
id: string;
|
|
3657
|
+
category: string;
|
|
3658
|
+
execute: () => void | Promise<void>;
|
|
3659
|
+
priority?: number;
|
|
3660
|
+
allowReload?: boolean;
|
|
3661
|
+
onConsentUpdate?: (consent: {
|
|
3662
|
+
consented: boolean;
|
|
3663
|
+
preferences: ConsentPreferences;
|
|
3664
|
+
}) => void;
|
|
3635
3665
|
}
|
|
3636
3666
|
/**
|
|
3637
|
-
*
|
|
3667
|
+
* Registra um script (inline ou externo) na fila controlada por consentimento.
|
|
3638
3668
|
*
|
|
3669
|
+
* @remarks
|
|
3670
|
+
* - Scripts `necessary` rodam imediatamente; demais aguardam consentimento da categoria.
|
|
3671
|
+
* - Fluxo de estados: `pending` → `running` → `executed` (respeitando `allowReload` e `onConsentUpdate`).
|
|
3672
|
+
* - A fila é ordenada por categoria, `priority` (maior primeiro) e ordem de registro.
|
|
3673
|
+
* - `allowReload` permite reexecutar scripts quando o usuário muda preferências.
|
|
3674
|
+
* - Use `onConsentUpdate` para reenviar sinais (ex.: Consent Mode) após novas decisões.
|
|
3675
|
+
* - Sempre chame o cleanup retornado em efeitos React para evitar múltiplos registros do mesmo `id`.
|
|
3676
|
+
*
|
|
3677
|
+
* @param def Definição do script a ser registrado.
|
|
3678
|
+
* @returns Função de cleanup para remover o script da fila.
|
|
3679
|
+
*/
|
|
3680
|
+
declare function registerScript(def: RegisteredScript): () => void;
|
|
3681
|
+
interface ConsentScriptLoaderProps {
|
|
3682
|
+
/** Lista de integrações de scripts para carregar baseado no consentimento */
|
|
3683
|
+
integrations: ScriptIntegration[];
|
|
3684
|
+
/** Se true, força recarregamento se consentimento mudar */
|
|
3685
|
+
reloadOnChange?: boolean;
|
|
3686
|
+
/** Nonce CSP aplicado às tags <script> geradas automaticamente (sobrescrevível por integração). */
|
|
3687
|
+
nonce?: string;
|
|
3688
|
+
}
|
|
3689
|
+
/**
|
|
3690
|
+
* @component
|
|
3639
3691
|
* @category Utils
|
|
3692
|
+
* @since 0.2.0
|
|
3693
|
+
* Componente que não renderiza UI, mas gerencia o carregamento de scripts de terceiros
|
|
3694
|
+
* (como Google Analytics) com base nas preferências de consentimento do usuário.
|
|
3695
|
+
*
|
|
3696
|
+
* @param props As propriedades do componente.
|
|
3697
|
+
* @param {ScriptIntegration[]} props.integrations Um array de objetos de integração de script. Use as factory functions (`createGoogleAnalyticsIntegration`, etc.) para criar.
|
|
3698
|
+
* @param {boolean} [props.reloadOnChange=false] Se `true`, recarrega os scripts se as preferências de consentimento mudarem.
|
|
3699
|
+
*
|
|
3700
|
+
* @example
|
|
3701
|
+
* ```tsx
|
|
3702
|
+
* const integrations = [
|
|
3703
|
+
* createGoogleAnalyticsIntegration({ measurementId: 'GA_ID' }),
|
|
3704
|
+
* createFacebookPixelIntegration({ pixelId: 'PIXEL_ID' })
|
|
3705
|
+
* ];
|
|
3706
|
+
*
|
|
3707
|
+
* <ConsentScriptLoader integrations={integrations} />
|
|
3708
|
+
* ```
|
|
3709
|
+
*/
|
|
3710
|
+
declare function ConsentScriptLoader({ integrations, reloadOnChange, nonce, }: Readonly<ConsentScriptLoaderProps>): null;
|
|
3711
|
+
/**
|
|
3712
|
+
* @hook
|
|
3713
|
+
* @category Hooks
|
|
3714
|
+
* @since 0.2.0
|
|
3715
|
+
* Hook para carregamento programático de um script baseado no consentimento.
|
|
3716
|
+
*
|
|
3717
|
+
* @returns Uma função assíncrona que recebe um objeto de integração de script e tenta carregá-lo.
|
|
3718
|
+
* Retorna `true` em caso de sucesso e `false` em caso de falha (por falta de consentimento ou erro de rede).
|
|
3719
|
+
*
|
|
3720
|
+
* @example
|
|
3721
|
+
* ```tsx
|
|
3722
|
+
* const loadScript = useConsentScriptLoader();
|
|
3723
|
+
*
|
|
3724
|
+
* useEffect(() => {
|
|
3725
|
+
* const handleUserAction = async () => {
|
|
3726
|
+
* const hotjarIntegration = { id: 'hotjar', category: 'analytics', src: '...' };
|
|
3727
|
+
* const success = await loadScript(hotjarIntegration);
|
|
3728
|
+
* if (success) {
|
|
3729
|
+
* console.log('Hotjar carregado com sucesso!');
|
|
3730
|
+
* }
|
|
3731
|
+
* };
|
|
3732
|
+
*
|
|
3733
|
+
* // Exemplo: carregar script após uma ação específica do usuário
|
|
3734
|
+
* myButton.addEventListener('click', handleUserAction);
|
|
3735
|
+
* }, [loadScript]);
|
|
3736
|
+
* ```
|
|
3737
|
+
*/
|
|
3738
|
+
declare function useConsentScriptLoader(): (integration: ScriptIntegration, nonce?: string) => Promise<boolean>;
|
|
3739
|
+
|
|
3740
|
+
/**
|
|
3741
|
+
* @file autoConfigureCategories.ts
|
|
3742
|
+
* @description Sistema inteligente de auto-habilitação de categorias baseado nas integrações utilizadas
|
|
3640
3743
|
* @since 0.4.1
|
|
3641
3744
|
*/
|
|
3642
|
-
|
|
3745
|
+
|
|
3643
3746
|
/**
|
|
3644
|
-
*
|
|
3747
|
+
* @interface CategoryAutoConfigResult
|
|
3748
|
+
* Resultado da análise e auto-configuração de categorias
|
|
3749
|
+
*/
|
|
3750
|
+
interface CategoryAutoConfigResult {
|
|
3751
|
+
/** Configuração original fornecida pelo desenvolvedor */
|
|
3752
|
+
originalConfig: ProjectCategoriesConfig;
|
|
3753
|
+
/** Configuração ajustada automaticamente pela biblioteca */
|
|
3754
|
+
adjustedConfig: ProjectCategoriesConfig;
|
|
3755
|
+
/** Categorias que foram automaticamente habilitadas */
|
|
3756
|
+
autoEnabledCategories: string[];
|
|
3757
|
+
/** Categorias requeridas pelas integrações mas não habilitadas */
|
|
3758
|
+
missingCategories: string[];
|
|
3759
|
+
/** Se algum ajuste foi necessário */
|
|
3760
|
+
wasAdjusted: boolean;
|
|
3761
|
+
/** Integrações que requerem cada categoria */
|
|
3762
|
+
categoryIntegrations: Record<string, string[]>;
|
|
3763
|
+
}
|
|
3764
|
+
/**
|
|
3765
|
+
* @function
|
|
3766
|
+
* @category Utils
|
|
3767
|
+
* @since 0.4.1
|
|
3768
|
+
* Analisa as integrações fornecidas e determina quais categorias são necessárias.
|
|
3645
3769
|
*
|
|
3770
|
+
* @param integrations Array de integrações de script
|
|
3771
|
+
* @returns Record mapeando categoria para nomes das integrações que a utilizam
|
|
3772
|
+
*/
|
|
3773
|
+
declare function analyzeIntegrationCategories(integrations: ScriptIntegration[]): Record<string, string[]>;
|
|
3774
|
+
/**
|
|
3775
|
+
* @function
|
|
3646
3776
|
* @category Utils
|
|
3647
3777
|
* @since 0.4.1
|
|
3778
|
+
* Configura automaticamente as categorias necessárias baseado nas integrações utilizadas.
|
|
3648
3779
|
*
|
|
3649
|
-
*
|
|
3650
|
-
*
|
|
3651
|
-
*
|
|
3780
|
+
* Esta função implementa o comportamento inteligente da biblioteca:
|
|
3781
|
+
* 1. Detecta categorias requeridas pelas integrações
|
|
3782
|
+
* 2. Auto-habilita categorias em falta (modo padrão)
|
|
3783
|
+
* 3. Ou apenas avisa sobre categorias em falta (modo warning-only)
|
|
3784
|
+
* 4. Loga no console em modo DEV
|
|
3785
|
+
*
|
|
3786
|
+
* @param originalConfig Configuração original do ConsentProvider
|
|
3787
|
+
* @param integrations Array de integrações que serão utilizadas
|
|
3788
|
+
* @param options Opções de comportamento
|
|
3789
|
+
* @returns Resultado da análise e configuração automática
|
|
3652
3790
|
*/
|
|
3653
|
-
declare function
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3791
|
+
declare function autoConfigureCategories(originalConfig: ProjectCategoriesConfig | undefined, integrations: ScriptIntegration[], options?: {
|
|
3792
|
+
/** Se true, apenas avisa mas não modifica a config (padrão: false - auto-habilita) */
|
|
3793
|
+
warningOnly?: boolean;
|
|
3794
|
+
/** Se true, desabilita logs no console (padrão: false) */
|
|
3795
|
+
silent?: boolean;
|
|
3796
|
+
}): CategoryAutoConfigResult;
|
|
3658
3797
|
/**
|
|
3659
|
-
*
|
|
3798
|
+
* @function
|
|
3799
|
+
* @category Utils
|
|
3800
|
+
* @since 0.4.1
|
|
3801
|
+
* Valida se todas as integrações têm suas categorias habilitadas.
|
|
3802
|
+
* Útil para validação em tempo de execução.
|
|
3660
3803
|
*
|
|
3804
|
+
* @param integrations Array de integrações
|
|
3805
|
+
* @param enabledCategories Array de categorias habilitadas
|
|
3806
|
+
* @returns true se todas as categorias necessárias estão habilitadas
|
|
3807
|
+
*/
|
|
3808
|
+
declare function validateIntegrationCategories(integrations: ScriptIntegration[], enabledCategories: string[]): boolean;
|
|
3809
|
+
/**
|
|
3810
|
+
* @function
|
|
3661
3811
|
* @category Utils
|
|
3662
3812
|
* @since 0.4.1
|
|
3813
|
+
* Extrai categorias únicas de um array de integrações
|
|
3814
|
+
*
|
|
3815
|
+
* @param integrations Array de integrações
|
|
3816
|
+
* @returns Array de categorias únicas
|
|
3663
3817
|
*/
|
|
3664
|
-
declare
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3818
|
+
declare function extractCategoriesFromIntegrations(integrations: ScriptIntegration[]): string[];
|
|
3819
|
+
/**
|
|
3820
|
+
* @function
|
|
3821
|
+
* @category Utils
|
|
3822
|
+
* @since 0.4.1
|
|
3823
|
+
* Valida se integrações estão sendo incorretamente classificadas como "necessary".
|
|
3824
|
+
*
|
|
3825
|
+
* Esta função protege contra violações de GDPR/LGPD identificando scripts que
|
|
3826
|
+
* NUNCA devem ser considerados estritamente necessários.
|
|
3827
|
+
*
|
|
3828
|
+
* @param integrations Array de integrações para validar
|
|
3829
|
+
* @param enabledCategories Categorias habilitadas na configuração
|
|
3830
|
+
* @returns Lista de avisos sobre classificações incorretas
|
|
3831
|
+
*
|
|
3832
|
+
* @example
|
|
3833
|
+
* ```typescript
|
|
3834
|
+
* const warnings = validateNecessaryClassification([
|
|
3835
|
+
* createGoogleAnalyticsIntegration({...}), // ❌ NUNCA é necessary
|
|
3836
|
+
* createCustomIntegration({...}) // ✅ Pode ser necessary se apropriado
|
|
3837
|
+
* ], ['necessary', 'analytics'])
|
|
3838
|
+
*
|
|
3839
|
+
* if (warnings.length > 0) {
|
|
3840
|
+
* console.warn('Scripts incorretamente classificados como necessary:', warnings)
|
|
3841
|
+
* }
|
|
3842
|
+
* ```
|
|
3843
|
+
*/
|
|
3844
|
+
declare function validateNecessaryClassification(integrations: ScriptIntegration[], enabledCategories: Category[]): string[];
|
|
3845
|
+
|
|
3846
|
+
/**
|
|
3847
|
+
* Presets de categorias conforme usos típicos da LGPD/ANPD.
|
|
3848
|
+
*
|
|
3849
|
+
* @category Utils
|
|
3850
|
+
* @since 0.6.4
|
|
3851
|
+
*/
|
|
3852
|
+
declare const ANPD_CATEGORY_PRESETS: Record<Category, CategoryDefinition>;
|
|
3853
|
+
type AnpdPresetCategory = keyof typeof ANPD_CATEGORY_PRESETS;
|
|
3854
|
+
interface CreateAnpdCategoriesOptions {
|
|
3855
|
+
/**
|
|
3856
|
+
* Lista de categorias que devem ser habilitadas (além de necessary que é sempre inclusa).
|
|
3857
|
+
* @default ['analytics', 'functional', 'marketing']
|
|
3858
|
+
*/
|
|
3859
|
+
include?: AnpdPresetCategory[];
|
|
3860
|
+
/**
|
|
3861
|
+
* Overrides de descrições por categoria.
|
|
3862
|
+
*/
|
|
3863
|
+
descriptions?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3864
|
+
/**
|
|
3865
|
+
* Overrides de nomes por categoria.
|
|
3866
|
+
*/
|
|
3867
|
+
names?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3868
|
+
}
|
|
3869
|
+
/**
|
|
3870
|
+
* Gera um `ProjectCategoriesConfig` com presets LGPD/ANPD tipados.
|
|
3871
|
+
*
|
|
3872
|
+
* @category Utils
|
|
3873
|
+
* @since 0.6.4
|
|
3874
|
+
*/
|
|
3875
|
+
declare function createAnpdCategoriesConfig(options?: CreateAnpdCategoriesOptions): ProjectCategoriesConfig;
|
|
3669
3876
|
|
|
3670
3877
|
/**
|
|
3671
3878
|
* @enum LogLevel
|
|
@@ -3843,6 +4050,98 @@ interface PeerDepsCheckResult {
|
|
|
3843
4050
|
/** Lista de erros críticos detectados */
|
|
3844
4051
|
errors: string[];
|
|
3845
4052
|
}
|
|
4053
|
+
/**
|
|
4054
|
+
* Idiomas suportados para mensagens de diagnóstico de peer dependencies.
|
|
4055
|
+
*
|
|
4056
|
+
* @category Utils
|
|
4057
|
+
* @since 0.7.1
|
|
4058
|
+
*/
|
|
4059
|
+
type PeerDepsLocale = 'pt-BR' | 'en';
|
|
4060
|
+
/**
|
|
4061
|
+
* Estrutura de mensagens de erro e aviso para diagnóstico de peer dependencies.
|
|
4062
|
+
*
|
|
4063
|
+
* @category Utils
|
|
4064
|
+
* @since 0.7.1
|
|
4065
|
+
*/
|
|
4066
|
+
interface PeerDepsMessages {
|
|
4067
|
+
MULTIPLE_REACT_INSTANCES: string;
|
|
4068
|
+
UNSUPPORTED_REACT_VERSION: (version: string) => string;
|
|
4069
|
+
UNSUPPORTED_MUI_VERSION: (version: string) => string;
|
|
4070
|
+
MUI_OUT_OF_RANGE: (version: string) => string;
|
|
4071
|
+
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Define o idioma para mensagens de diagnóstico de peer dependencies.
|
|
4074
|
+
*
|
|
4075
|
+
* @category Utils
|
|
4076
|
+
* @since 0.7.1
|
|
4077
|
+
*
|
|
4078
|
+
* @param locale - Idioma desejado ('pt-BR' ou 'en')
|
|
4079
|
+
*
|
|
4080
|
+
* @example
|
|
4081
|
+
* ```typescript
|
|
4082
|
+
* import { setPeerDepsLocale } from '@react-lgpd-consent/core'
|
|
4083
|
+
*
|
|
4084
|
+
* // Configurar mensagens em inglês
|
|
4085
|
+
* setPeerDepsLocale('en')
|
|
4086
|
+
* ```
|
|
4087
|
+
*/
|
|
4088
|
+
declare function setPeerDepsLocale(locale: PeerDepsLocale): void;
|
|
4089
|
+
/**
|
|
4090
|
+
* Obtém o idioma atual configurado para mensagens de diagnóstico.
|
|
4091
|
+
*
|
|
4092
|
+
* @category Utils
|
|
4093
|
+
* @since 0.7.1
|
|
4094
|
+
*
|
|
4095
|
+
* @returns O idioma atual
|
|
4096
|
+
*
|
|
4097
|
+
* @example
|
|
4098
|
+
* ```typescript
|
|
4099
|
+
* import { getPeerDepsLocale } from '@react-lgpd-consent/core'
|
|
4100
|
+
*
|
|
4101
|
+
* const locale = getPeerDepsLocale() // 'pt-BR' ou 'en'
|
|
4102
|
+
* ```
|
|
4103
|
+
*/
|
|
4104
|
+
declare function getPeerDepsLocale(): PeerDepsLocale;
|
|
4105
|
+
/**
|
|
4106
|
+
* Permite sobrescrever mensagens de diagnóstico com versões customizadas.
|
|
4107
|
+
* Útil para traduzir para outros idiomas ou personalizar o texto.
|
|
4108
|
+
*
|
|
4109
|
+
* @category Utils
|
|
4110
|
+
* @since 0.7.1
|
|
4111
|
+
*
|
|
4112
|
+
* @param messages - Objeto parcial com mensagens a sobrescrever
|
|
4113
|
+
*
|
|
4114
|
+
* @remarks
|
|
4115
|
+
* As mensagens customizadas têm prioridade sobre as mensagens padrão.
|
|
4116
|
+
* Pode fornecer apenas as mensagens que deseja sobrescrever.
|
|
4117
|
+
*
|
|
4118
|
+
* @example
|
|
4119
|
+
* ```typescript
|
|
4120
|
+
* import { setPeerDepsMessages } from '@react-lgpd-consent/core'
|
|
4121
|
+
*
|
|
4122
|
+
* // Customizar mensagens em espanhol
|
|
4123
|
+
* setPeerDepsMessages({
|
|
4124
|
+
* MULTIPLE_REACT_INSTANCES: `ERROR: Múltiples instancias de React detectadas...`,
|
|
4125
|
+
* UNSUPPORTED_REACT_VERSION: (v) => `Versión ${v} no soportada...`,
|
|
4126
|
+
* })
|
|
4127
|
+
* ```
|
|
4128
|
+
*/
|
|
4129
|
+
declare function setPeerDepsMessages(messages: Partial<PeerDepsMessages>): void;
|
|
4130
|
+
/**
|
|
4131
|
+
* Restaura as mensagens padrão, removendo qualquer customização.
|
|
4132
|
+
*
|
|
4133
|
+
* @category Utils
|
|
4134
|
+
* @since 0.7.1
|
|
4135
|
+
*
|
|
4136
|
+
* @example
|
|
4137
|
+
* ```typescript
|
|
4138
|
+
* import { resetPeerDepsMessages } from '@react-lgpd-consent/core'
|
|
4139
|
+
*
|
|
4140
|
+
* // Voltar para mensagens padrão
|
|
4141
|
+
* resetPeerDepsMessages()
|
|
4142
|
+
* ```
|
|
4143
|
+
*/
|
|
4144
|
+
declare function resetPeerDepsMessages(): void;
|
|
3846
4145
|
/**
|
|
3847
4146
|
* Verifica compatibilidade de peer dependencies (React e MUI).
|
|
3848
4147
|
*
|
|
@@ -4035,7 +4334,9 @@ declare function getAllProjectCategories(config?: ProjectCategoriesConfig): Cate
|
|
|
4035
4334
|
*/
|
|
4036
4335
|
declare global {
|
|
4037
4336
|
interface Window {
|
|
4038
|
-
dataLayer?: Array<ConsentEvent | Record<string, unknown
|
|
4337
|
+
dataLayer?: Array<ConsentEvent | Record<string, unknown>> | {
|
|
4338
|
+
push?: (...args: unknown[]) => unknown;
|
|
4339
|
+
};
|
|
4039
4340
|
}
|
|
4040
4341
|
}
|
|
4041
4342
|
/**
|
|
@@ -4145,4 +4446,4 @@ declare function useDataLayerEvents(): {
|
|
|
4145
4446
|
pushUpdated: typeof pushConsentUpdatedEvent;
|
|
4146
4447
|
};
|
|
4147
4448
|
|
|
4148
|
-
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 ProjectCategoriesConfig, 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, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|
|
4449
|
+
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 };
|