react-lgpd-consent 0.3.7 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -0
- package/QUICKSTART.en.md +77 -0
- package/QUICKSTART.md +351 -1
- package/README.en.md +20 -0
- package/README.md +31 -0
- package/dist/{PreferencesModal-3KKTKVII.js → PreferencesModal-RNRD3JKB.js} +1 -1
- package/dist/{chunk-TKN3PNIW.js → chunk-VOQUCGOA.js} +916 -226
- package/dist/index.cjs +1712 -261
- package/dist/index.d.cts +1814 -227
- package/dist/index.d.ts +1814 -227
- package/dist/index.js +738 -8
- package/package.json +50 -22
package/dist/index.d.cts
CHANGED
|
@@ -6,6 +6,14 @@ import { PaperProps } from '@mui/material/Paper';
|
|
|
6
6
|
import { SnackbarProps } from '@mui/material/Snackbar';
|
|
7
7
|
import { FabProps } from '@mui/material/Fab';
|
|
8
8
|
|
|
9
|
+
declare global {
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Variável global para rastrear integrações usadas.
|
|
13
|
+
* Usado internamente para logging e análise de performance.
|
|
14
|
+
*/
|
|
15
|
+
var __LGPD_USED_INTEGRATIONS__: string[] | undefined;
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* @interface PreferencesModalProps
|
|
11
19
|
* Propriedades para customizar o componente `PreferencesModal`.
|
|
@@ -34,6 +42,96 @@ interface PreferencesModalProps {
|
|
|
34
42
|
*/
|
|
35
43
|
declare function PreferencesModal({ DialogProps, hideBranding, }: Readonly<PreferencesModalProps>): react_jsx_runtime.JSX.Element;
|
|
36
44
|
|
|
45
|
+
type GuidanceSeverity = 'info' | 'warning' | 'error';
|
|
46
|
+
interface GuidanceMessage {
|
|
47
|
+
severity: GuidanceSeverity;
|
|
48
|
+
message: string;
|
|
49
|
+
category?: string;
|
|
50
|
+
actionable?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface GuidanceConfig {
|
|
53
|
+
/** Controla se avisos devem ser exibidos */
|
|
54
|
+
showWarnings?: boolean;
|
|
55
|
+
/** Controla se sugestões devem ser exibidas */
|
|
56
|
+
showSuggestions?: boolean;
|
|
57
|
+
/** Controla se a tabela de categorias deve ser exibida */
|
|
58
|
+
showCategoriesTable?: boolean;
|
|
59
|
+
/** Controla se as boas práticas devem ser exibidas */
|
|
60
|
+
showBestPractices?: boolean;
|
|
61
|
+
/** Controla se deve exibir score de conformidade */
|
|
62
|
+
showComplianceScore?: boolean;
|
|
63
|
+
/** Filtro de severidade mínima para exibir mensagens */
|
|
64
|
+
minimumSeverity?: GuidanceSeverity;
|
|
65
|
+
/** Callback personalizado para processar mensagens */
|
|
66
|
+
messageProcessor?: (messages: GuidanceMessage[]) => void;
|
|
67
|
+
}
|
|
68
|
+
interface DeveloperGuidance {
|
|
69
|
+
warnings: string[];
|
|
70
|
+
suggestions: string[];
|
|
71
|
+
messages: GuidanceMessage[];
|
|
72
|
+
activeCategoriesInfo: {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
essential: boolean;
|
|
77
|
+
uiRequired: boolean;
|
|
78
|
+
cookies?: string[];
|
|
79
|
+
}[];
|
|
80
|
+
usingDefaults: boolean;
|
|
81
|
+
complianceScore?: number;
|
|
82
|
+
}
|
|
83
|
+
declare const DEFAULT_PROJECT_CATEGORIES: ProjectCategoriesConfig;
|
|
84
|
+
/**
|
|
85
|
+
* Analisa configuração e integrações implícitas para orientar o dev.
|
|
86
|
+
*
|
|
87
|
+
* Since v0.4.0: inclui customCategories.
|
|
88
|
+
* Since v0.4.1: considera categorias/integrações implícitas e enriquece cookies por categoria.
|
|
89
|
+
*/
|
|
90
|
+
declare function analyzeDeveloperConfiguration(config?: ProjectCategoriesConfig): DeveloperGuidance;
|
|
91
|
+
declare function logDeveloperGuidance(guidance: DeveloperGuidance, disableGuidanceProp?: boolean, config?: GuidanceConfig): void;
|
|
92
|
+
declare function useDeveloperGuidance(config?: ProjectCategoriesConfig, disableGuidanceProp?: boolean, guidanceConfig?: GuidanceConfig): DeveloperGuidance;
|
|
93
|
+
/**
|
|
94
|
+
* Presets de configuração para diferentes ambientes
|
|
95
|
+
*/
|
|
96
|
+
declare const GUIDANCE_PRESETS: {
|
|
97
|
+
/** Configuração completa para desenvolvimento */
|
|
98
|
+
readonly development: {
|
|
99
|
+
readonly showWarnings: true;
|
|
100
|
+
readonly showSuggestions: true;
|
|
101
|
+
readonly showCategoriesTable: true;
|
|
102
|
+
readonly showBestPractices: true;
|
|
103
|
+
readonly showComplianceScore: true;
|
|
104
|
+
readonly minimumSeverity: "info";
|
|
105
|
+
};
|
|
106
|
+
/** Configuração silenciosa para produção */
|
|
107
|
+
readonly production: {
|
|
108
|
+
readonly showWarnings: false;
|
|
109
|
+
readonly showSuggestions: false;
|
|
110
|
+
readonly showCategoriesTable: false;
|
|
111
|
+
readonly showBestPractices: false;
|
|
112
|
+
readonly showComplianceScore: false;
|
|
113
|
+
readonly minimumSeverity: "error";
|
|
114
|
+
};
|
|
115
|
+
/** Apenas erros críticos */
|
|
116
|
+
readonly minimal: {
|
|
117
|
+
readonly showWarnings: true;
|
|
118
|
+
readonly showSuggestions: false;
|
|
119
|
+
readonly showCategoriesTable: false;
|
|
120
|
+
readonly showBestPractices: false;
|
|
121
|
+
readonly showComplianceScore: false;
|
|
122
|
+
readonly minimumSeverity: "error";
|
|
123
|
+
};
|
|
124
|
+
/** Focado em conformidade LGPD */
|
|
125
|
+
readonly compliance: {
|
|
126
|
+
readonly showWarnings: true;
|
|
127
|
+
readonly showSuggestions: true;
|
|
128
|
+
readonly showCategoriesTable: true;
|
|
129
|
+
readonly showBestPractices: true;
|
|
130
|
+
readonly showComplianceScore: true;
|
|
131
|
+
readonly minimumSeverity: "warning";
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
37
135
|
/**
|
|
38
136
|
* @fileoverview
|
|
39
137
|
* Definições de tipos TypeScript para o sistema de consentimento LGPD/ANPD.
|
|
@@ -81,6 +179,7 @@ type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social
|
|
|
81
179
|
*
|
|
82
180
|
* @example
|
|
83
181
|
* ```typescript
|
|
182
|
+
* // Categoria padrão da biblioteca
|
|
84
183
|
* const analyticsCategory: CategoryDefinition = {
|
|
85
184
|
* id: 'analytics',
|
|
86
185
|
* name: 'Cookies Analíticos',
|
|
@@ -88,6 +187,14 @@ type Category = 'necessary' | 'analytics' | 'functional' | 'marketing' | 'social
|
|
|
88
187
|
* essential: false,
|
|
89
188
|
* cookies: ['_ga', '_ga_*', '_gid']
|
|
90
189
|
* };
|
|
190
|
+
*
|
|
191
|
+
* // Categoria customizada específica do projeto
|
|
192
|
+
* const chatCategory: CategoryDefinition = {
|
|
193
|
+
* id: 'chat',
|
|
194
|
+
* name: 'Chat de Suporte',
|
|
195
|
+
* description: 'Widget de chat para suporte ao cliente',
|
|
196
|
+
* essential: false
|
|
197
|
+
* };
|
|
91
198
|
* ```
|
|
92
199
|
*
|
|
93
200
|
* @public
|
|
@@ -118,6 +225,61 @@ interface CategoryDefinition {
|
|
|
118
225
|
* @example ['_ga', '_ga_*', '_gid']
|
|
119
226
|
*/
|
|
120
227
|
cookies?: string[];
|
|
228
|
+
/**
|
|
229
|
+
* Metadados detalhados sobre cookies típicos desta categoria.
|
|
230
|
+
* Não exaustivo; serve para orientar UI e documentação.
|
|
231
|
+
*/
|
|
232
|
+
cookiesInfo?: CookieDescriptor[];
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Descritor de cookie com metadados úteis para UI/documentação.
|
|
236
|
+
* @category Types
|
|
237
|
+
* @since 0.2.0
|
|
238
|
+
*
|
|
239
|
+
* @remarks
|
|
240
|
+
* Mantém compatibilidade com abordagens comuns no mercado.
|
|
241
|
+
* Fornece informações detalhadas sobre cookies para exibição em interfaces
|
|
242
|
+
* e documentação de compliance.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const cookieInfo: CookieDescriptor = {
|
|
247
|
+
* name: '_ga',
|
|
248
|
+
* purpose: 'analytics',
|
|
249
|
+
* duration: '2 years',
|
|
250
|
+
* domain: '.example.com',
|
|
251
|
+
* provider: 'Google Analytics'
|
|
252
|
+
* };
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
interface CookieDescriptor {
|
|
258
|
+
/**
|
|
259
|
+
* Identificador ou padrão do cookie.
|
|
260
|
+
* @example '_ga'
|
|
261
|
+
*/
|
|
262
|
+
name: string;
|
|
263
|
+
/**
|
|
264
|
+
* Finalidade do cookie (opcional).
|
|
265
|
+
* @example 'analytics'
|
|
266
|
+
*/
|
|
267
|
+
purpose?: string;
|
|
268
|
+
/**
|
|
269
|
+
* Tempo de retenção do cookie (opcional).
|
|
270
|
+
* @example '2 years'
|
|
271
|
+
*/
|
|
272
|
+
duration?: string;
|
|
273
|
+
/**
|
|
274
|
+
* Domínio associado ao cookie (opcional).
|
|
275
|
+
* @example '.example.com'
|
|
276
|
+
*/
|
|
277
|
+
domain?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Provedor ou serviço associado ao cookie (opcional).
|
|
280
|
+
* @example 'Google Analytics'
|
|
281
|
+
*/
|
|
282
|
+
provider?: string;
|
|
121
283
|
}
|
|
122
284
|
/**
|
|
123
285
|
* Configuração de categorias ativas no projeto.
|
|
@@ -144,11 +306,18 @@ interface CategoryDefinition {
|
|
|
144
306
|
* // Configuração com categorias customizadas
|
|
145
307
|
* const config: ProjectCategoriesConfig = {
|
|
146
308
|
* enabledCategories: ['analytics'],
|
|
147
|
-
* customCategories: [
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
309
|
+
* customCategories: [
|
|
310
|
+
* {
|
|
311
|
+
* id: 'chat',
|
|
312
|
+
* name: 'Chat de Suporte',
|
|
313
|
+
* description: 'Widget de chat para suporte ao cliente'
|
|
314
|
+
* },
|
|
315
|
+
* {
|
|
316
|
+
* id: 'abTesting',
|
|
317
|
+
* name: 'A/B Testing',
|
|
318
|
+
* description: 'Experimentos de interface e funcionalidades'
|
|
319
|
+
* }
|
|
320
|
+
* ]
|
|
152
321
|
* };
|
|
153
322
|
* ```
|
|
154
323
|
*
|
|
@@ -164,6 +333,7 @@ interface ProjectCategoriesConfig {
|
|
|
164
333
|
/**
|
|
165
334
|
* Categorias customizadas específicas do projeto.
|
|
166
335
|
* Permite extensão além das categorias padrão da biblioteca.
|
|
336
|
+
* @example [{ id: 'chat', name: 'Chat de Suporte', description: 'Widget de chat' }]
|
|
167
337
|
*/
|
|
168
338
|
customCategories?: CategoryDefinition[];
|
|
169
339
|
}
|
|
@@ -514,6 +684,7 @@ interface ConsentTexts {
|
|
|
514
684
|
* Opções para configuração do cookie de consentimento.
|
|
515
685
|
* @category Types
|
|
516
686
|
* @since 0.1.0
|
|
687
|
+
* @public
|
|
517
688
|
*/
|
|
518
689
|
interface ConsentCookieOptions {
|
|
519
690
|
/** Nome do cookie. Padrão: 'cookieConsent' */
|
|
@@ -527,53 +698,451 @@ interface ConsentCookieOptions {
|
|
|
527
698
|
/** Caminho do cookie. Padrão: '/' */
|
|
528
699
|
path: string;
|
|
529
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Tipo alias para valores de espaçamento que suportam eixos x/y.
|
|
703
|
+
* @category Types
|
|
704
|
+
* @since 0.1.3
|
|
705
|
+
* @remarks
|
|
706
|
+
* Permite especificar espaçamento como string, número ou objeto com eixos x e y separados.
|
|
707
|
+
* Útil para configurações de padding e margin em design tokens.
|
|
708
|
+
* @example
|
|
709
|
+
* ```typescript
|
|
710
|
+
* const spacing: SpacingValue = { x: 10, y: 20 };
|
|
711
|
+
* ```
|
|
712
|
+
*/
|
|
713
|
+
type SpacingValue = string | number | {
|
|
714
|
+
x?: string | number;
|
|
715
|
+
y?: string | number;
|
|
716
|
+
};
|
|
717
|
+
/**
|
|
718
|
+
* Tipo alias para cores com variações.
|
|
719
|
+
* @category Types
|
|
720
|
+
* @since 0.1.3
|
|
721
|
+
* @remarks
|
|
722
|
+
* Suporta cor simples ou objeto com variações light, main, dark e contrastText.
|
|
723
|
+
* Compatível com sistemas de design que precisam de paletas completas.
|
|
724
|
+
* @example
|
|
725
|
+
* ```typescript
|
|
726
|
+
* const color: ColorVariant = { main: '#1976d2', dark: '#1565c0' };
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
type ColorVariant = string | {
|
|
730
|
+
light?: string;
|
|
731
|
+
main?: string;
|
|
732
|
+
dark?: string;
|
|
733
|
+
contrastText?: string;
|
|
734
|
+
};
|
|
735
|
+
/**
|
|
736
|
+
* Tipo alias para altura com auto.
|
|
737
|
+
* @category Types
|
|
738
|
+
* @since 0.1.3
|
|
739
|
+
* @remarks
|
|
740
|
+
* Permite 'auto' ou qualquer string válida para altura CSS, com type safety.
|
|
741
|
+
* Evita valores inválidos através de interseção com Record<never, never>.
|
|
742
|
+
* @example
|
|
743
|
+
* ```typescript
|
|
744
|
+
* const height: HeightValue = 'auto';
|
|
745
|
+
* const customHeight: HeightValue = '100px';
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
type HeightValue = 'auto' | (string & Record<never, never>);
|
|
749
|
+
/**
|
|
750
|
+
* Tipo alias para configuração de backdrop.
|
|
751
|
+
* @category Types
|
|
752
|
+
* @since 0.1.3
|
|
753
|
+
* @remarks
|
|
754
|
+
* Define configuração do backdrop como booleano simples, string de cor ou objeto detalhado
|
|
755
|
+
* com propriedades como enabled, color, blur e opacity para controle granular.
|
|
756
|
+
* @example
|
|
757
|
+
* ```typescript
|
|
758
|
+
* const backdrop: BackdropConfig = { enabled: true, color: 'rgba(0,0,0,0.5)', blur: '4px' };
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
761
|
+
type BackdropConfig = boolean | string | {
|
|
762
|
+
enabled?: boolean;
|
|
763
|
+
color?: string;
|
|
764
|
+
blur?: string;
|
|
765
|
+
opacity?: number;
|
|
766
|
+
};
|
|
530
767
|
/**
|
|
531
768
|
* Tokens de design para customização visual avançada dos componentes.
|
|
769
|
+
*
|
|
770
|
+
* Sistema robusto de design tokens que permite controle granular sobre todos os aspectos
|
|
771
|
+
* visuais da biblioteca. Suporta responsive design, estados interativos, acessibilidade
|
|
772
|
+
* e temas dark/light.
|
|
773
|
+
*
|
|
532
774
|
* @category Types
|
|
533
775
|
* @since 0.1.3
|
|
534
|
-
*
|
|
776
|
+
* @version 0.4.1 - Expandido substancialmente com novos tokens
|
|
777
|
+
* @public
|
|
778
|
+
*
|
|
779
|
+
* @example Configuração básica
|
|
780
|
+
* ```tsx
|
|
781
|
+
* const tokens: DesignTokens = {
|
|
782
|
+
* colors: {
|
|
783
|
+
* primary: '#1976d2',
|
|
784
|
+
* background: '#ffffff',
|
|
785
|
+
* text: '#333333'
|
|
786
|
+
* }
|
|
787
|
+
* }
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @example Configuração avançada com responsive e estados
|
|
791
|
+
* ```tsx
|
|
792
|
+
* const advancedTokens: DesignTokens = {
|
|
793
|
+
* colors: {
|
|
794
|
+
* primary: { light: '#42a5f5', main: '#1976d2', dark: '#1565c0' },
|
|
795
|
+
* semantic: {
|
|
796
|
+
* error: '#f44336',
|
|
797
|
+
* warning: '#ff9800',
|
|
798
|
+
* success: '#4caf50',
|
|
799
|
+
* info: '#2196f3'
|
|
800
|
+
* }
|
|
801
|
+
* },
|
|
802
|
+
* spacing: {
|
|
803
|
+
* responsive: {
|
|
804
|
+
* mobile: { padding: '12px', margin: '8px' },
|
|
805
|
+
* tablet: { padding: '16px', margin: '12px' },
|
|
806
|
+
* desktop: { padding: '24px', margin: '16px' }
|
|
807
|
+
* }
|
|
808
|
+
* }
|
|
809
|
+
* }
|
|
810
|
+
* ```
|
|
535
811
|
*/
|
|
536
812
|
interface DesignTokens {
|
|
813
|
+
/**
|
|
814
|
+
* Sistema de cores expandido com suporte a variações e semântica
|
|
815
|
+
*/
|
|
537
816
|
colors?: {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
secondary?:
|
|
817
|
+
/** Cor primária da aplicação */
|
|
818
|
+
primary?: ColorVariant;
|
|
819
|
+
/** Cor secundária */
|
|
820
|
+
secondary?: ColorVariant;
|
|
821
|
+
/** Cor de fundo principal */
|
|
822
|
+
background?: string | {
|
|
823
|
+
main?: string;
|
|
824
|
+
paper?: string;
|
|
825
|
+
overlay?: string;
|
|
826
|
+
default?: string;
|
|
827
|
+
};
|
|
828
|
+
/** Cor do texto */
|
|
829
|
+
text?: string | {
|
|
830
|
+
primary?: string;
|
|
831
|
+
secondary?: string;
|
|
832
|
+
disabled?: string;
|
|
833
|
+
};
|
|
834
|
+
/** Cor da borda */
|
|
835
|
+
border?: ColorVariant;
|
|
836
|
+
/** Cores semânticas para estados */
|
|
837
|
+
semantic?: {
|
|
838
|
+
error?: string;
|
|
839
|
+
warning?: string;
|
|
840
|
+
success?: string;
|
|
841
|
+
info?: string;
|
|
842
|
+
};
|
|
843
|
+
/** Cores específicas para componentes */
|
|
844
|
+
components?: {
|
|
845
|
+
banner?: {
|
|
846
|
+
background?: string;
|
|
847
|
+
text?: string;
|
|
848
|
+
border?: string;
|
|
849
|
+
shadow?: string;
|
|
850
|
+
};
|
|
851
|
+
modal?: {
|
|
852
|
+
background?: string;
|
|
853
|
+
text?: string;
|
|
854
|
+
overlay?: string;
|
|
855
|
+
border?: string;
|
|
856
|
+
};
|
|
857
|
+
button?: {
|
|
858
|
+
primary?: {
|
|
859
|
+
background?: string;
|
|
860
|
+
text?: string;
|
|
861
|
+
hover?: string;
|
|
862
|
+
};
|
|
863
|
+
secondary?: {
|
|
864
|
+
background?: string;
|
|
865
|
+
text?: string;
|
|
866
|
+
hover?: string;
|
|
867
|
+
};
|
|
868
|
+
outlined?: {
|
|
869
|
+
border?: string;
|
|
870
|
+
text?: string;
|
|
871
|
+
hover?: string;
|
|
872
|
+
};
|
|
873
|
+
};
|
|
874
|
+
};
|
|
542
875
|
};
|
|
876
|
+
/**
|
|
877
|
+
* Sistema tipográfico completo com hierarquia e responsive
|
|
878
|
+
*/
|
|
543
879
|
typography?: {
|
|
544
|
-
|
|
880
|
+
/** Família de fontes principal */
|
|
881
|
+
fontFamily?: string | {
|
|
882
|
+
primary?: string;
|
|
883
|
+
secondary?: string;
|
|
884
|
+
monospace?: string;
|
|
885
|
+
};
|
|
886
|
+
/** Tamanhos de fonte com hierarchy */
|
|
545
887
|
fontSize?: {
|
|
546
|
-
banner
|
|
547
|
-
|
|
888
|
+
/** Tamanhos para banner */
|
|
889
|
+
banner?: {
|
|
890
|
+
title?: string;
|
|
891
|
+
message?: string;
|
|
892
|
+
button?: string;
|
|
893
|
+
};
|
|
894
|
+
/** Tamanhos para modal */
|
|
895
|
+
modal?: {
|
|
896
|
+
title?: string;
|
|
897
|
+
body?: string;
|
|
898
|
+
button?: string;
|
|
899
|
+
caption?: string;
|
|
900
|
+
};
|
|
901
|
+
/** Scale tipográfica */
|
|
902
|
+
scale?: {
|
|
903
|
+
xs?: string;
|
|
904
|
+
sm?: string;
|
|
905
|
+
base?: string;
|
|
906
|
+
lg?: string;
|
|
907
|
+
xl?: string;
|
|
908
|
+
'2xl'?: string;
|
|
909
|
+
'3xl'?: string;
|
|
910
|
+
};
|
|
911
|
+
/** Tamanhos específicos de cabeçalhos */
|
|
912
|
+
h1?: string;
|
|
913
|
+
h2?: string;
|
|
914
|
+
h3?: string;
|
|
915
|
+
h4?: string;
|
|
916
|
+
h5?: string;
|
|
917
|
+
h6?: string;
|
|
548
918
|
};
|
|
919
|
+
/** Pesos de fonte */
|
|
549
920
|
fontWeight?: {
|
|
921
|
+
light?: number;
|
|
550
922
|
normal?: number;
|
|
923
|
+
medium?: number;
|
|
924
|
+
semibold?: number;
|
|
551
925
|
bold?: number;
|
|
552
926
|
};
|
|
927
|
+
/** Altura de linha */
|
|
928
|
+
lineHeight?: {
|
|
929
|
+
tight?: number;
|
|
930
|
+
normal?: number;
|
|
931
|
+
relaxed?: number;
|
|
932
|
+
loose?: number;
|
|
933
|
+
};
|
|
934
|
+
/** Espaçamento de letras */
|
|
935
|
+
letterSpacing?: {
|
|
936
|
+
tight?: string;
|
|
937
|
+
normal?: string;
|
|
938
|
+
wide?: string;
|
|
939
|
+
};
|
|
553
940
|
};
|
|
941
|
+
/**
|
|
942
|
+
* Sistema de espaçamento e dimensões flexível
|
|
943
|
+
*/
|
|
554
944
|
spacing?: {
|
|
945
|
+
/** Valores diretos de espaçamento */
|
|
946
|
+
xs?: string | number;
|
|
947
|
+
sm?: string | number;
|
|
948
|
+
md?: string | number;
|
|
949
|
+
lg?: string | number;
|
|
950
|
+
xl?: string | number;
|
|
951
|
+
/** Escala de espaçamento base */
|
|
952
|
+
scale?: {
|
|
953
|
+
xs?: string | number;
|
|
954
|
+
sm?: string | number;
|
|
955
|
+
md?: string | number;
|
|
956
|
+
lg?: string | number;
|
|
957
|
+
xl?: string | number;
|
|
958
|
+
'2xl'?: string | number;
|
|
959
|
+
'3xl'?: string | number;
|
|
960
|
+
};
|
|
961
|
+
/** Padding específico por componente */
|
|
555
962
|
padding?: {
|
|
556
|
-
banner?:
|
|
557
|
-
modal?:
|
|
963
|
+
banner?: SpacingValue;
|
|
964
|
+
modal?: SpacingValue;
|
|
965
|
+
button?: SpacingValue;
|
|
966
|
+
};
|
|
967
|
+
/** Margem específica por componente */
|
|
968
|
+
margin?: {
|
|
969
|
+
banner?: SpacingValue;
|
|
970
|
+
modal?: SpacingValue;
|
|
971
|
+
button?: SpacingValue;
|
|
558
972
|
};
|
|
973
|
+
/** Bordas arredondadas */
|
|
559
974
|
borderRadius?: {
|
|
560
975
|
banner?: string | number;
|
|
561
976
|
modal?: string | number;
|
|
977
|
+
button?: string | number;
|
|
978
|
+
/** Scale de border radius */
|
|
979
|
+
scale?: {
|
|
980
|
+
none?: string | number;
|
|
981
|
+
sm?: string | number;
|
|
982
|
+
md?: string | number;
|
|
983
|
+
lg?: string | number;
|
|
984
|
+
xl?: string | number;
|
|
985
|
+
full?: string | number;
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
/** Configurações responsive */
|
|
989
|
+
responsive?: {
|
|
990
|
+
mobile?: {
|
|
991
|
+
padding?: string | number;
|
|
992
|
+
margin?: string | number;
|
|
993
|
+
borderRadius?: string | number;
|
|
994
|
+
};
|
|
995
|
+
tablet?: {
|
|
996
|
+
padding?: string | number;
|
|
997
|
+
margin?: string | number;
|
|
998
|
+
borderRadius?: string | number;
|
|
999
|
+
};
|
|
1000
|
+
desktop?: {
|
|
1001
|
+
padding?: string | number;
|
|
1002
|
+
margin?: string | number;
|
|
1003
|
+
borderRadius?: string | number;
|
|
1004
|
+
};
|
|
562
1005
|
};
|
|
563
1006
|
};
|
|
1007
|
+
/**
|
|
1008
|
+
* Configurações de layout e posicionamento
|
|
1009
|
+
*/
|
|
564
1010
|
layout?: {
|
|
565
|
-
|
|
1011
|
+
/** Posição do banner */
|
|
1012
|
+
position?: 'bottom' | 'top' | 'floating' | 'center';
|
|
1013
|
+
/** Larguras por breakpoint */
|
|
566
1014
|
width?: {
|
|
567
1015
|
mobile?: string;
|
|
1016
|
+
tablet?: string;
|
|
1017
|
+
desktop?: string;
|
|
1018
|
+
max?: string;
|
|
1019
|
+
};
|
|
1020
|
+
/** Alturas específicas */
|
|
1021
|
+
height?: {
|
|
1022
|
+
banner?: HeightValue;
|
|
1023
|
+
modal?: HeightValue;
|
|
1024
|
+
button?: HeightValue;
|
|
1025
|
+
};
|
|
1026
|
+
/** Configuração do backdrop */
|
|
1027
|
+
backdrop?: BackdropConfig;
|
|
1028
|
+
/** Z-index para layering */
|
|
1029
|
+
zIndex?: {
|
|
1030
|
+
banner?: number;
|
|
1031
|
+
modal?: number;
|
|
1032
|
+
backdrop?: number;
|
|
1033
|
+
floatingButton?: number;
|
|
1034
|
+
};
|
|
1035
|
+
/** Breakpoints customizados */
|
|
1036
|
+
breakpoints?: {
|
|
1037
|
+
mobile?: string;
|
|
1038
|
+
tablet?: string;
|
|
568
1039
|
desktop?: string;
|
|
1040
|
+
wide?: string;
|
|
1041
|
+
};
|
|
1042
|
+
/** Border radius para componentes */
|
|
1043
|
+
borderRadius?: string | number | {
|
|
1044
|
+
banner?: string | number;
|
|
1045
|
+
modal?: string | number;
|
|
1046
|
+
button?: string | number;
|
|
1047
|
+
scale?: {
|
|
1048
|
+
none?: string | number;
|
|
1049
|
+
sm?: string | number;
|
|
1050
|
+
md?: string | number;
|
|
1051
|
+
lg?: string | number;
|
|
1052
|
+
xl?: string | number;
|
|
1053
|
+
full?: string | number;
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
/**
|
|
1058
|
+
* Efeitos visuais e interações
|
|
1059
|
+
*/
|
|
1060
|
+
effects?: {
|
|
1061
|
+
/** Sombras */
|
|
1062
|
+
shadow?: {
|
|
1063
|
+
banner?: string;
|
|
1064
|
+
modal?: string;
|
|
1065
|
+
button?: string;
|
|
1066
|
+
/** Scale de sombras */
|
|
1067
|
+
scale?: {
|
|
1068
|
+
none?: string;
|
|
1069
|
+
sm?: string;
|
|
1070
|
+
md?: string;
|
|
1071
|
+
lg?: string;
|
|
1072
|
+
xl?: string;
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1075
|
+
/** Transições e animações */
|
|
1076
|
+
transitions?: {
|
|
1077
|
+
duration?: {
|
|
1078
|
+
fast?: string;
|
|
1079
|
+
normal?: string;
|
|
1080
|
+
slow?: string;
|
|
1081
|
+
};
|
|
1082
|
+
easing?: {
|
|
1083
|
+
linear?: string;
|
|
1084
|
+
easeIn?: string;
|
|
1085
|
+
easeOut?: string;
|
|
1086
|
+
easeInOut?: string;
|
|
1087
|
+
};
|
|
1088
|
+
/** Transições específicas */
|
|
1089
|
+
banner?: {
|
|
1090
|
+
enter?: string;
|
|
1091
|
+
exit?: string;
|
|
1092
|
+
};
|
|
1093
|
+
modal?: {
|
|
1094
|
+
enter?: string;
|
|
1095
|
+
exit?: string;
|
|
1096
|
+
};
|
|
1097
|
+
};
|
|
1098
|
+
/** Blur e filtros */
|
|
1099
|
+
filters?: {
|
|
1100
|
+
backdrop?: string;
|
|
1101
|
+
disabled?: string;
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Configurações de acessibilidade
|
|
1106
|
+
*/
|
|
1107
|
+
accessibility?: {
|
|
1108
|
+
/** Contraste mínimo */
|
|
1109
|
+
contrast?: {
|
|
1110
|
+
normal?: number;
|
|
1111
|
+
enhanced?: number;
|
|
1112
|
+
};
|
|
1113
|
+
/** Configurações para motion */
|
|
1114
|
+
motion?: {
|
|
1115
|
+
respectPreferences?: boolean;
|
|
1116
|
+
reducedMotion?: {
|
|
1117
|
+
duration?: string;
|
|
1118
|
+
easing?: string;
|
|
1119
|
+
};
|
|
1120
|
+
};
|
|
1121
|
+
/** Focus indicators */
|
|
1122
|
+
focus?: {
|
|
1123
|
+
color?: string;
|
|
1124
|
+
width?: string;
|
|
1125
|
+
style?: 'solid' | 'dashed' | 'dotted';
|
|
1126
|
+
offset?: string;
|
|
569
1127
|
};
|
|
570
|
-
|
|
1128
|
+
};
|
|
1129
|
+
/**
|
|
1130
|
+
* Temas e variações
|
|
1131
|
+
*/
|
|
1132
|
+
themes?: {
|
|
1133
|
+
/** Configurações específicas para tema claro */
|
|
1134
|
+
light?: Partial<Omit<DesignTokens, 'themes'>>;
|
|
1135
|
+
/** Configurações específicas para tema escuro */
|
|
1136
|
+
dark?: Partial<Omit<DesignTokens, 'themes'>>;
|
|
1137
|
+
/** Auto-detecção baseada no sistema */
|
|
1138
|
+
auto?: boolean;
|
|
571
1139
|
};
|
|
572
1140
|
}
|
|
573
1141
|
/**
|
|
574
1142
|
* Propriedades do componente ConsentProvider - configuração principal da biblioteca.
|
|
575
1143
|
* @category Types
|
|
576
1144
|
* @since 0.1.0
|
|
1145
|
+
* @public
|
|
577
1146
|
*
|
|
578
1147
|
* @example Uso básico (configuração mínima):
|
|
579
1148
|
* ```tsx
|
|
@@ -647,7 +1216,7 @@ interface ConsentProviderProps {
|
|
|
647
1216
|
* texts={{
|
|
648
1217
|
* controllerInfo: 'Controlado por: Empresa XYZ - CNPJ: 12.345.678/0001-90',
|
|
649
1218
|
* dataTypes: 'Coletamos: endereço IP, preferências de navegação',
|
|
650
|
-
* userRights: 'Você pode solicitar acesso, correção ou exclusão dos dados'
|
|
1219
|
+
* userRights: 'Você pode solicitar acesso, correção ou exclusão dos seus dados'
|
|
651
1220
|
* }}
|
|
652
1221
|
* ```
|
|
653
1222
|
*/
|
|
@@ -782,6 +1351,31 @@ interface ConsentProviderProps {
|
|
|
782
1351
|
* Por padrão, os avisos já são desabilitados em builds de produção.
|
|
783
1352
|
*/
|
|
784
1353
|
disableDeveloperGuidance?: boolean;
|
|
1354
|
+
/**
|
|
1355
|
+
* Desabilita o log automático de descoberta de cookies em modo desenvolvimento.
|
|
1356
|
+
* Mesmo com `disableDeveloperGuidance` ativado, por padrão a descoberta é logada uma vez para ajudar o mapeamento.
|
|
1357
|
+
* Use esta prop para suprimir também esse log experimental.
|
|
1358
|
+
* @since 0.4.1
|
|
1359
|
+
*/
|
|
1360
|
+
disableDiscoveryLog?: boolean;
|
|
1361
|
+
/**
|
|
1362
|
+
* Configuração avançada para o sistema de developer guidance.
|
|
1363
|
+
* Permite controle granular sobre quais tipos de guias são exibidos e como.
|
|
1364
|
+
* @since 0.4.1
|
|
1365
|
+
* @example
|
|
1366
|
+
* ```tsx
|
|
1367
|
+
* // Usar preset de desenvolvimento
|
|
1368
|
+
* guidanceConfig={GUIDANCE_PRESETS.development}
|
|
1369
|
+
*
|
|
1370
|
+
* // Configuração personalizada
|
|
1371
|
+
* guidanceConfig={{
|
|
1372
|
+
* showWarnings: true,
|
|
1373
|
+
* showComplianceScore: true,
|
|
1374
|
+
* minimumSeverity: 'warning'
|
|
1375
|
+
* }}
|
|
1376
|
+
* ```
|
|
1377
|
+
*/
|
|
1378
|
+
guidanceConfig?: GuidanceConfig;
|
|
785
1379
|
/** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
|
|
786
1380
|
children: React.ReactNode;
|
|
787
1381
|
}
|
|
@@ -789,6 +1383,7 @@ interface ConsentProviderProps {
|
|
|
789
1383
|
* Props esperadas por um componente customizado de CookieBanner.
|
|
790
1384
|
* @category Types
|
|
791
1385
|
* @since 0.3.1
|
|
1386
|
+
* @public
|
|
792
1387
|
* Fornece acesso ao estado de consentimento e ações necessárias para o banner.
|
|
793
1388
|
*/
|
|
794
1389
|
interface CustomCookieBannerProps {
|
|
@@ -808,6 +1403,7 @@ interface CustomCookieBannerProps {
|
|
|
808
1403
|
* Props esperadas por um componente customizado de PreferencesModal.
|
|
809
1404
|
* @category Types
|
|
810
1405
|
* @since 0.3.1
|
|
1406
|
+
* @public
|
|
811
1407
|
*
|
|
812
1408
|
* Fornece acesso às preferências atuais do usuário, funções para atualizar e salvar preferências,
|
|
813
1409
|
* fechar o modal e textos customizados da interface.
|
|
@@ -829,6 +1425,7 @@ interface CustomPreferencesModalProps {
|
|
|
829
1425
|
* Props esperadas por um componente customizado de FloatingPreferencesButton.
|
|
830
1426
|
* @category Types
|
|
831
1427
|
* @since 0.3.1
|
|
1428
|
+
* @public
|
|
832
1429
|
* Fornece acesso às ações de abertura do modal e ao estado de consentimento.
|
|
833
1430
|
*/
|
|
834
1431
|
interface CustomFloatingPreferencesButtonProps {
|
|
@@ -839,6 +1436,7 @@ interface CustomFloatingPreferencesButtonProps {
|
|
|
839
1436
|
* Valor do contexto de consentimento, incluindo estado e métodos de manipulação.
|
|
840
1437
|
* @category Types
|
|
841
1438
|
* @since 0.1.0
|
|
1439
|
+
* @public
|
|
842
1440
|
*/
|
|
843
1441
|
interface ConsentContextValue {
|
|
844
1442
|
/** Indica se o usuário consentiu. */
|
|
@@ -851,8 +1449,28 @@ interface ConsentContextValue {
|
|
|
851
1449
|
acceptAll: () => void;
|
|
852
1450
|
/** Rejeita todas as categorias de consentimento. */
|
|
853
1451
|
rejectAll: () => void;
|
|
854
|
-
/**
|
|
855
|
-
|
|
1452
|
+
/**
|
|
1453
|
+
* Define a preferência para uma categoria específica.
|
|
1454
|
+
* Suporta tanto categorias predefinidas quanto customizadas.
|
|
1455
|
+
*
|
|
1456
|
+
* @param cat - ID da categoria (predefinida ou customizada)
|
|
1457
|
+
* @param value - Valor do consentimento para a categoria
|
|
1458
|
+
*
|
|
1459
|
+
* @breakingChange
|
|
1460
|
+
* **v0.4.1**: Parâmetro `cat` mudou de `Category` para `string` para suportar
|
|
1461
|
+
* categorias customizadas. O uso com strings literais continua funcionando.
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```typescript
|
|
1465
|
+
* // ✅ Continua funcionando (categorias predefinidas)
|
|
1466
|
+
* setPreference('analytics', true)
|
|
1467
|
+
* setPreference('marketing', false)
|
|
1468
|
+
*
|
|
1469
|
+
* // ✅ Novo: categorias customizadas
|
|
1470
|
+
* setPreference('custom-tracking', true)
|
|
1471
|
+
* ```
|
|
1472
|
+
*/
|
|
1473
|
+
setPreference: (cat: string, value: boolean) => void;
|
|
856
1474
|
/** Define múltiplas preferências de uma vez e salva. */
|
|
857
1475
|
setPreferences: (preferences: ConsentPreferences) => void;
|
|
858
1476
|
/** Abre o modal de preferências. */
|
|
@@ -910,7 +1528,7 @@ interface ConsentContextValue {
|
|
|
910
1528
|
* </ConsentProvider>
|
|
911
1529
|
* ```
|
|
912
1530
|
*/
|
|
913
|
-
declare function ConsentProvider({ initialState, categories, texts: textsProp, theme, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
1531
|
+
declare function ConsentProvider({ initialState, categories, texts: textsProp, theme, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
914
1532
|
declare const defaultTexts: ConsentTexts;
|
|
915
1533
|
|
|
916
1534
|
/**
|
|
@@ -1353,185 +1971,63 @@ declare function useConsentTexts(): ConsentTexts;
|
|
|
1353
1971
|
*/
|
|
1354
1972
|
declare function useConsentHydration(): boolean;
|
|
1355
1973
|
/**
|
|
1356
|
-
*
|
|
1357
|
-
* @hook
|
|
1974
|
+
* @function
|
|
1358
1975
|
* @category Hooks
|
|
1359
|
-
* @since 0.3.1
|
|
1360
|
-
*
|
|
1361
|
-
* Este hook oferece uma maneira ReactJS-idiomática de abrir o modal de preferências
|
|
1362
|
-
* em qualquer lugar da aplicação. Diferente do botão flutuante padrão, permite
|
|
1363
|
-
* controle total sobre quando e como o modal é acionado.
|
|
1364
|
-
*
|
|
1365
|
-
* ### Casos de Uso Principais
|
|
1366
|
-
* - **Links no footer/header**: "Configurações de Cookies", "Preferências"
|
|
1367
|
-
* - **Botões customizados**: Design próprio para abrir preferências
|
|
1368
|
-
* - **Fluxos condicionais**: Abrir modal baseado em ações do usuário
|
|
1369
|
-
* - **Integração com menus**: Adicionar item de menu para configurações
|
|
1370
|
-
*
|
|
1371
|
-
* ### Vantagens sobre função global
|
|
1372
|
-
* - **Type-safe**: TypeScript com tipagem completa
|
|
1373
|
-
* - **React-friendly**: Integra com ciclo de vida dos componentes
|
|
1374
|
-
* - **Automático**: Sem necessidade de verificar se ConsentProvider existe
|
|
1375
|
-
* - **Testável**: Fácil de mockar em testes unitários
|
|
1376
|
-
*
|
|
1377
|
-
* ### Performance
|
|
1378
|
-
* - Função estável: não causa re-renders quando usada como dependency
|
|
1379
|
-
* - Memoizada internamente para otimização
|
|
1380
|
-
* - Sem overhead: apenas proxy para ação interna do contexto
|
|
1381
|
-
*
|
|
1382
|
-
* @returns Uma função estável que abre o modal de preferências quando chamada
|
|
1383
|
-
*
|
|
1384
|
-
* @throws {Error} Se usado fora do ConsentProvider - verifique se está dentro de `<ConsentProvider>`
|
|
1385
|
-
*
|
|
1386
|
-
* @example Hook básico no footer
|
|
1387
|
-
* ```tsx
|
|
1388
|
-
* function MeuFooter() {
|
|
1389
|
-
* const abrirModal = useOpenPreferencesModal();
|
|
1390
|
-
*
|
|
1391
|
-
* return (
|
|
1392
|
-
* <footer>
|
|
1393
|
-
* <a href="#" onClick={abrirModal}>
|
|
1394
|
-
* Configurações de Cookies
|
|
1395
|
-
* </a>
|
|
1396
|
-
* </footer>
|
|
1397
|
-
* );
|
|
1398
|
-
* }
|
|
1399
|
-
* ```
|
|
1976
|
+
* @since 0.3.1
|
|
1977
|
+
* Hook para abrir o modal de preferências programaticamente.
|
|
1400
1978
|
*
|
|
1401
|
-
* @
|
|
1402
|
-
* ```tsx
|
|
1403
|
-
* import { Settings } from '@mui/icons-material';
|
|
1979
|
+
* @returns Função para abrir o modal de preferências.
|
|
1404
1980
|
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1981
|
+
* @remarks
|
|
1982
|
+
* Este hook retorna uma função que pode ser usada para abrir o modal de preferências
|
|
1983
|
+
* de qualquer lugar dentro do contexto do ConsentProvider. É útil para criar botões
|
|
1984
|
+
* customizados ou trigger o modal baseado em eventos específicos.
|
|
1407
1985
|
*
|
|
1408
|
-
*
|
|
1409
|
-
* <button
|
|
1410
|
-
* onClick={openModal}
|
|
1411
|
-
* className="preferences-btn"
|
|
1412
|
-
* aria-label="Configurar cookies"
|
|
1413
|
-
* >
|
|
1414
|
-
* <Settings /> Cookies
|
|
1415
|
-
* </button>
|
|
1416
|
-
* );
|
|
1417
|
-
* }
|
|
1418
|
-
* ```
|
|
1986
|
+
* @throws {Error} Se usado fora do ConsentProvider
|
|
1419
1987
|
*
|
|
1420
|
-
* @example
|
|
1988
|
+
* @example
|
|
1421
1989
|
* ```tsx
|
|
1422
|
-
* function
|
|
1990
|
+
* function CustomButton() {
|
|
1423
1991
|
* const openPreferences = useOpenPreferencesModal();
|
|
1424
|
-
* const [menuOpen, setMenuOpen] = useState(false);
|
|
1425
1992
|
*
|
|
1426
1993
|
* return (
|
|
1427
|
-
* <
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1430
|
-
* </button>
|
|
1431
|
-
* {menuOpen && (
|
|
1432
|
-
* <ul>
|
|
1433
|
-
* <li><a href="/profile">Meu Perfil</a></li>
|
|
1434
|
-
* <li><a href="/settings">Configurações</a></li>
|
|
1435
|
-
* <li>
|
|
1436
|
-
* <button onClick={openPreferences}>
|
|
1437
|
-
* Preferências de Cookies
|
|
1438
|
-
* </button>
|
|
1439
|
-
* </li>
|
|
1440
|
-
* </ul>
|
|
1441
|
-
* )}
|
|
1442
|
-
* </div>
|
|
1994
|
+
* <button onClick={openPreferences}>
|
|
1995
|
+
* Configurar Cookies
|
|
1996
|
+
* </button>
|
|
1443
1997
|
* );
|
|
1444
1998
|
* }
|
|
1445
1999
|
* ```
|
|
2000
|
+
*/
|
|
2001
|
+
declare function useOpenPreferencesModal(): () => void;
|
|
2002
|
+
/**
|
|
2003
|
+
* @function
|
|
2004
|
+
* @category Utils
|
|
2005
|
+
* @since 0.3.1
|
|
2006
|
+
* Função global para abrir o modal de preferências de fora do contexto React.
|
|
1446
2007
|
*
|
|
1447
|
-
* @
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1451
|
-
* const navigate = useNavigate(); // React Router
|
|
1452
|
-
*
|
|
1453
|
-
* React.useEffect(() => {
|
|
1454
|
-
* // Abre modal automaticamente na página de configurações
|
|
1455
|
-
* openModal();
|
|
1456
|
-
* }, [openModal]);
|
|
1457
|
-
*
|
|
1458
|
-
* const handleModalClose = () => {
|
|
1459
|
-
* // Volta para página anterior quando modal fechar
|
|
1460
|
-
* navigate(-1);
|
|
1461
|
-
* };
|
|
1462
|
-
*
|
|
1463
|
-
* return <div>Configurações de cookies carregando...</div>;
|
|
1464
|
-
* }
|
|
1465
|
-
* ```
|
|
2008
|
+
* @remarks
|
|
2009
|
+
* Esta função permite abrir o modal de preferências de código JavaScript puro,
|
|
2010
|
+
* sem precisar estar dentro do contexto React. É útil para integração com
|
|
2011
|
+
* código legado ou bibliotecas de terceiros.
|
|
1466
2012
|
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
* function SmartCookieButton() {
|
|
1470
|
-
* const { consented } = useConsent();
|
|
1471
|
-
* const openPreferences = useOpenPreferencesModal();
|
|
2013
|
+
* A função é automaticamente registrada pelo ConsentProvider e limpa quando
|
|
2014
|
+
* o provider é desmontado.
|
|
1472
2015
|
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
2016
|
+
* @example
|
|
2017
|
+
* ```javascript
|
|
2018
|
+
* // Em código JavaScript puro
|
|
2019
|
+
* window.openPreferencesModal?.();
|
|
1477
2020
|
*
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
*
|
|
1481
|
-
* className={consented ? 'modify-btn' : 'setup-btn'}
|
|
1482
|
-
* >
|
|
1483
|
-
* {buttonIcon} {buttonText}
|
|
1484
|
-
* </button>
|
|
1485
|
-
* );
|
|
1486
|
-
* }
|
|
2021
|
+
* // Ou importando diretamente
|
|
2022
|
+
* import { openPreferencesModal } from 'react-lgpd-consent';
|
|
2023
|
+
* openPreferencesModal();
|
|
1487
2024
|
* ```
|
|
1488
2025
|
*/
|
|
1489
|
-
declare function useOpenPreferencesModal(): () => void;
|
|
1490
2026
|
declare function openPreferencesModal(): void;
|
|
1491
2027
|
|
|
1492
2028
|
/**
|
|
1493
|
-
* @interface
|
|
1494
|
-
*
|
|
1495
|
-
*/
|
|
1496
|
-
interface DeveloperGuidance {
|
|
1497
|
-
/** Um array de strings, cada uma representando um aviso sobre a configuração. */
|
|
1498
|
-
warnings: string[];
|
|
1499
|
-
/** Um array de strings, cada uma representando uma sugestão para melhorar a conformidade ou UX. */
|
|
1500
|
-
suggestions: string[];
|
|
1501
|
-
/** Um array de objetos, cada um descrevendo uma categoria de cookie ativa e suas propriedades relevantes para a UI. */
|
|
1502
|
-
activeCategoriesInfo: {
|
|
1503
|
-
id: string;
|
|
1504
|
-
name: string;
|
|
1505
|
-
description: string;
|
|
1506
|
-
essential: boolean;
|
|
1507
|
-
uiRequired: boolean;
|
|
1508
|
-
}[];
|
|
1509
|
-
/** Indica se a configuração padrão da biblioteca está sendo utilizada (quando nenhuma configuração explícita é fornecida). */
|
|
1510
|
-
usingDefaults: boolean;
|
|
1511
|
-
}
|
|
1512
|
-
/**
|
|
1513
|
-
* @constant
|
|
1514
|
-
* @category Utils
|
|
1515
|
-
* @since 0.2.2
|
|
1516
|
-
* Configuração padrão de categorias de cookies utilizada quando o desenvolvedor não especifica nenhuma configuração.
|
|
1517
|
-
* Inclui apenas a categoria 'analytics' além da 'necessary' (que é sempre incluída).
|
|
1518
|
-
*/
|
|
1519
|
-
declare const DEFAULT_PROJECT_CATEGORIES: ProjectCategoriesConfig;
|
|
1520
|
-
/**
|
|
1521
|
-
* @function
|
|
1522
|
-
* @category Utils
|
|
1523
|
-
* @since 0.2.2
|
|
1524
|
-
* Analisa a configuração de categorias do projeto e gera um objeto de orientação para o desenvolvedor.
|
|
1525
|
-
* Este objeto contém avisos, sugestões e informações detalhadas sobre as categorias ativas.
|
|
1526
|
-
*
|
|
1527
|
-
* @param {ProjectCategoriesConfig} [config] A configuração de categorias fornecida pelo desenvolvedor. Se não for fornecida, a configuração padrão será utilizada.
|
|
1528
|
-
* @returns {DeveloperGuidance} Um objeto `DeveloperGuidance` com a análise da configuração.
|
|
1529
|
-
*/
|
|
1530
|
-
declare function analyzeDeveloperConfiguration(config?: ProjectCategoriesConfig): DeveloperGuidance;
|
|
1531
|
-
|
|
1532
|
-
/**
|
|
1533
|
-
* @interface CategoriesContextValue
|
|
1534
|
-
* O valor fornecido pelo `CategoriesContext`, contendo informações sobre as categorias de cookies ativas no projeto.
|
|
2029
|
+
* @interface CategoriesContextValue
|
|
2030
|
+
* O valor fornecido pelo `CategoriesContext`, contendo informações sobre as categorias de cookies ativas no projeto.
|
|
1535
2031
|
*/
|
|
1536
2032
|
interface CategoriesContextValue {
|
|
1537
2033
|
/** A configuração final das categorias, incluindo padrões aplicados. */
|
|
@@ -1592,6 +2088,15 @@ declare function ConsentGate(props: Readonly<{
|
|
|
1592
2088
|
children: React$1.ReactNode;
|
|
1593
2089
|
}>): react_jsx_runtime.JSX.Element | null;
|
|
1594
2090
|
|
|
2091
|
+
/** @module src/utils/scriptLoader */
|
|
2092
|
+
/**
|
|
2093
|
+
* @category Utils
|
|
2094
|
+
* @since 0.1.0
|
|
2095
|
+
* Utilitários para carregamento dinâmico e seguro de scripts externos no DOM.
|
|
2096
|
+
*
|
|
2097
|
+
* Fornece funções para carregar scripts de terceiros de forma condicional ao consentimento LGPD,
|
|
2098
|
+
* garantindo compatibilidade SSR e verificações de permissões por categoria.
|
|
2099
|
+
*/
|
|
1595
2100
|
/**
|
|
1596
2101
|
* @function
|
|
1597
2102
|
* @category Utils
|
|
@@ -1605,7 +2110,7 @@ declare function ConsentGate(props: Readonly<{
|
|
|
1605
2110
|
*
|
|
1606
2111
|
* @param {string} id Um identificador único para o elemento `<script>` a ser criado.
|
|
1607
2112
|
* @param {string} src A URL do script externo a ser carregado.
|
|
1608
|
-
* @param {
|
|
2113
|
+
* @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.
|
|
1609
2114
|
* @param {Record<string, string>} [attrs={}] Atributos adicionais a serem aplicados ao elemento `<script>` (ex: `{ async: 'true' }`).
|
|
1610
2115
|
* @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.
|
|
1611
2116
|
* @example
|
|
@@ -1616,11 +2121,64 @@ declare function ConsentGate(props: Readonly<{
|
|
|
1616
2121
|
* .catch(error => console.error('Erro ao carregar script:', error))
|
|
1617
2122
|
* ```
|
|
1618
2123
|
*/
|
|
2124
|
+
declare function loadScript(id: string, src: string, category?: string | null, attrs?: Record<string, string>): Promise<void>;
|
|
2125
|
+
|
|
2126
|
+
/**
|
|
2127
|
+
* Utilitários para descoberta e categorização de cookies em tempo de execução (experimental).
|
|
2128
|
+
*
|
|
2129
|
+
* Fornece funções para detectar cookies presentes no navegador, identificar o cookie de consentimento
|
|
2130
|
+
* e atribuir cookies descobertos a categorias LGPD usando heurísticas baseadas em padrões conhecidos.
|
|
2131
|
+
*
|
|
2132
|
+
* @category Utils
|
|
2133
|
+
* @since 0.4.1
|
|
2134
|
+
* @remarks Funcionalidades experimentais para auxiliar no mapeamento de cookies em conformidade com LGPD.
|
|
2135
|
+
* Recomenda-se uso em desenvolvimento para inspeção manual e merge com catálogo existente.
|
|
2136
|
+
*/
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* Descobre cookies em tempo de execução no navegador (experimental).
|
|
2140
|
+
*
|
|
2141
|
+
* - Lê `document.cookie` com segurança (SSR-safe)
|
|
2142
|
+
* - Retorna lista de cookies detectados (apenas nomes)
|
|
2143
|
+
* - Salva em `globalThis.__LGPD_DISCOVERED_COOKIES__` para inspeção/manual merge
|
|
2144
|
+
*
|
|
2145
|
+
* @category Utils
|
|
2146
|
+
* @since 0.4.1
|
|
2147
|
+
*/
|
|
2148
|
+
declare function discoverRuntimeCookies(): CookieDescriptor[];
|
|
2149
|
+
/**
|
|
2150
|
+
* Tenta detectar o nome do cookie de consentimento pela estrutura JSON armazenada.
|
|
2151
|
+
* Retorna o nome se for encontrado, caso contrário `null`.
|
|
2152
|
+
* @category Utils
|
|
2153
|
+
* @since 0.4.1
|
|
2154
|
+
*/
|
|
2155
|
+
declare function detectConsentCookieName(): string | null;
|
|
2156
|
+
/**
|
|
2157
|
+
* Heurística simples para atribuir cookies descobertos a categorias LGPD (experimental).
|
|
2158
|
+
*
|
|
2159
|
+
* - Usa padrões conhecidos por categoria
|
|
2160
|
+
* - Ignora `cookieConsent` (já tratado como necessary)
|
|
2161
|
+
* - Pode opcionalmente registrar overrides de catálogo por categoria
|
|
2162
|
+
*
|
|
2163
|
+
* @param discovered Lista de cookies descobertos (opcional: usa global se ausente)
|
|
2164
|
+
* @param registerOverrides Se `true`, registra em `setCookieCatalogOverrides`
|
|
2165
|
+
* @returns Mapa categoria -> descritores atribuídos
|
|
2166
|
+
* @category Utils
|
|
2167
|
+
* @since 0.4.1
|
|
2168
|
+
*/
|
|
2169
|
+
declare function categorizeDiscoveredCookies(discovered?: CookieDescriptor[], registerOverrides?: boolean): Record<Category, CookieDescriptor[]>;
|
|
1619
2170
|
|
|
1620
|
-
|
|
2171
|
+
/** @module src/utils/theme */
|
|
2172
|
+
/**
|
|
2173
|
+
* @category Utils
|
|
2174
|
+
* @since 0.1.0
|
|
2175
|
+
* Utilitários para criação e gerenciamento de temas Material-UI para componentes de consentimento LGPD.
|
|
2176
|
+
*
|
|
2177
|
+
* Fornece um tema padrão consistente e acessível, com opções de personalização.
|
|
2178
|
+
*/
|
|
1621
2179
|
|
|
1622
2180
|
/**
|
|
1623
|
-
* @
|
|
2181
|
+
* @function
|
|
1624
2182
|
* @category Utils
|
|
1625
2183
|
* @since 0.1.0
|
|
1626
2184
|
* Tema padrão utilizado pelos componentes de consentimento da biblioteca.
|
|
@@ -1628,6 +2186,16 @@ declare function loadScript(id: string, src: string, category?: Category | null,
|
|
|
1628
2186
|
* Inclui configurações de cores, tipografia e estilos para componentes Material-UI,
|
|
1629
2187
|
* garantindo aparência consistente e acessível conforme guidelines LGPD.
|
|
1630
2188
|
*
|
|
2189
|
+
* @returns {Theme} Instância do tema Material-UI configurado.
|
|
2190
|
+
*
|
|
2191
|
+
* @example
|
|
2192
|
+
* ```typescript
|
|
2193
|
+
* import { createDefaultConsentTheme } from 'react-lgpd-consent'
|
|
2194
|
+
*
|
|
2195
|
+
* const theme = createDefaultConsentTheme()
|
|
2196
|
+
* // Use com ThemeProvider
|
|
2197
|
+
* ```
|
|
2198
|
+
*
|
|
1631
2199
|
* @remarks
|
|
1632
2200
|
* Pode ser sobrescrito via ThemeProvider externo se necessário.
|
|
1633
2201
|
*/
|
|
@@ -1638,99 +2206,225 @@ declare function createDefaultConsentTheme(): Theme;
|
|
|
1638
2206
|
* @deprecated Use `createDefaultConsentTheme()` em vez de importar um tema criado no escopo do módulo.
|
|
1639
2207
|
* Importar um tema já instanciado pode causar side-effects em SSR e conflitos de contexto.
|
|
1640
2208
|
* Esta função retorna uma nova instância do tema quando chamada.
|
|
2209
|
+
*
|
|
2210
|
+
* @returns {Theme} Instância do tema Material-UI configurado.
|
|
2211
|
+
*
|
|
2212
|
+
* @example
|
|
2213
|
+
* ```typescript
|
|
2214
|
+
* import { defaultConsentTheme } from 'react-lgpd-consent'
|
|
2215
|
+
*
|
|
2216
|
+
* const theme = defaultConsentTheme()
|
|
2217
|
+
* // Deprecated, use createDefaultConsentTheme instead
|
|
2218
|
+
* ```
|
|
1641
2219
|
*/
|
|
1642
2220
|
declare const defaultConsentTheme: () => Theme;
|
|
1643
2221
|
|
|
1644
2222
|
/**
|
|
1645
|
-
* @
|
|
1646
|
-
*
|
|
2223
|
+
* @fileoverview
|
|
2224
|
+
* Integrações nativas de scripts (GA, GTM, Facebook Pixel, Hotjar, Mixpanel, Clarity, Intercom, Zendesk, UserWay)
|
|
2225
|
+
* com categorias LGPD padrão, cookies típicos e pontos de extensão para URLs.
|
|
2226
|
+
*
|
|
2227
|
+
* Princípios:
|
|
2228
|
+
* - Cada integração define uma categoria padrão (mais aderente ao uso no mercado)
|
|
2229
|
+
* - Cada cookie típico aparece em uma única categoria por padrão
|
|
2230
|
+
* - URLs possuem valores default atualizados e podem ser sobrescritos via `scriptUrl`
|
|
2231
|
+
* - SSR-safe: toda execução que toca `window` é protegida
|
|
2232
|
+
*/
|
|
2233
|
+
/**
|
|
2234
|
+
* Integração de script de terceiros condicionada a consentimento.
|
|
2235
|
+
*
|
|
2236
|
+
* @category Utils
|
|
2237
|
+
* @since 0.2.0
|
|
1647
2238
|
*
|
|
1648
2239
|
* @remarks
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
2240
|
+
* **Breaking Change em v0.4.1**: O campo `category` mudou de `Category` para `string`
|
|
2241
|
+
* para suportar categorias customizadas. Código existente usando strings literais
|
|
2242
|
+
* continua funcionando sem alterações.
|
|
2243
|
+
*
|
|
2244
|
+
* @example
|
|
2245
|
+
* ```typescript
|
|
2246
|
+
* const integration: ScriptIntegration = {
|
|
2247
|
+
* id: 'my-script',
|
|
2248
|
+
* category: 'analytics',
|
|
2249
|
+
* src: 'https://example.com/script.js',
|
|
2250
|
+
* cookies: ['_example'],
|
|
2251
|
+
* init: () => console.log('Script initialized')
|
|
2252
|
+
* }
|
|
2253
|
+
* ```
|
|
1652
2254
|
*/
|
|
1653
|
-
|
|
1654
2255
|
interface ScriptIntegration {
|
|
1655
|
-
/**
|
|
2256
|
+
/** Identificador único da integração */
|
|
1656
2257
|
id: string;
|
|
1657
|
-
/**
|
|
1658
|
-
|
|
1659
|
-
|
|
2258
|
+
/**
|
|
2259
|
+
* Categoria LGPD à qual o script pertence.
|
|
2260
|
+
* Suporta tanto categorias predefinidas quanto customizadas.
|
|
2261
|
+
*/
|
|
2262
|
+
category: string;
|
|
2263
|
+
/** Nome legível da integração (opcional) */
|
|
2264
|
+
name?: string;
|
|
2265
|
+
/** URL do script a ser carregado */
|
|
1660
2266
|
src: string;
|
|
1661
|
-
/**
|
|
2267
|
+
/** Se o script deve ser carregado de forma assíncrona */
|
|
2268
|
+
async?: boolean;
|
|
2269
|
+
/** Se o script deve ser deferido */
|
|
2270
|
+
defer?: boolean;
|
|
2271
|
+
/** Configuração específica da integração */
|
|
2272
|
+
config?: Record<string, unknown>;
|
|
2273
|
+
/** Função de inicialização executada após carregamento do script */
|
|
1662
2274
|
init?: () => void;
|
|
1663
|
-
/**
|
|
2275
|
+
/** Atributos HTML adicionais para a tag script */
|
|
1664
2276
|
attrs?: Record<string, string>;
|
|
2277
|
+
/** Lista de cookies que o script pode definir */
|
|
2278
|
+
cookies?: string[];
|
|
2279
|
+
/** Informações detalhadas dos cookies (nome, finalidade, duração, fornecedor) */
|
|
2280
|
+
cookiesInfo?: Array<{
|
|
2281
|
+
name: string;
|
|
2282
|
+
purpose: string;
|
|
2283
|
+
duration: string;
|
|
2284
|
+
provider: string;
|
|
2285
|
+
}>;
|
|
1665
2286
|
}
|
|
1666
2287
|
/**
|
|
1667
|
-
*
|
|
1668
|
-
*
|
|
2288
|
+
* Configuração para integração do Google Analytics (GA4).
|
|
2289
|
+
*
|
|
2290
|
+
* @category Utils
|
|
2291
|
+
* @since 0.2.0
|
|
2292
|
+
*
|
|
2293
|
+
* @example
|
|
2294
|
+
* ```typescript
|
|
2295
|
+
* const config: GoogleAnalyticsConfig = {
|
|
2296
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
2297
|
+
* config: { anonymize_ip: true }
|
|
2298
|
+
* }
|
|
2299
|
+
* ```
|
|
1669
2300
|
*/
|
|
1670
2301
|
interface GoogleAnalyticsConfig {
|
|
1671
|
-
/**
|
|
2302
|
+
/** ID de medição do GA4 (formato: G-XXXXXXXXXX) */
|
|
1672
2303
|
measurementId: string;
|
|
1673
|
-
/**
|
|
2304
|
+
/** Configurações adicionais para o gtag */
|
|
1674
2305
|
config?: Record<string, unknown>;
|
|
2306
|
+
/** URL do script GA4. Se omitido usa o padrão oficial. */
|
|
2307
|
+
scriptUrl?: string;
|
|
1675
2308
|
}
|
|
1676
2309
|
/**
|
|
1677
|
-
*
|
|
1678
|
-
*
|
|
2310
|
+
* Configuração para integração do Google Tag Manager (GTM).
|
|
2311
|
+
*
|
|
2312
|
+
* @category Utils
|
|
2313
|
+
* @since 0.2.0
|
|
2314
|
+
*
|
|
2315
|
+
* @example
|
|
2316
|
+
* ```typescript
|
|
2317
|
+
* const config: GoogleTagManagerConfig = {
|
|
2318
|
+
* containerId: 'GTM-XXXXXXX',
|
|
2319
|
+
* dataLayerName: 'customDataLayer'
|
|
2320
|
+
* }
|
|
2321
|
+
* ```
|
|
1679
2322
|
*/
|
|
1680
2323
|
interface GoogleTagManagerConfig {
|
|
1681
|
-
/**
|
|
2324
|
+
/** ID do container GTM (formato: GTM-XXXXXXX) */
|
|
1682
2325
|
containerId: string;
|
|
1683
|
-
/**
|
|
2326
|
+
/** Nome customizado para o dataLayer. Padrão: 'dataLayer' */
|
|
1684
2327
|
dataLayerName?: string;
|
|
2328
|
+
/** URL do script GTM. Se omitido usa o padrão oficial. */
|
|
2329
|
+
scriptUrl?: string;
|
|
1685
2330
|
}
|
|
1686
2331
|
/**
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
2332
|
+
* Configuração para integração do UserWay (Acessibilidade).
|
|
2333
|
+
*
|
|
2334
|
+
* @category Utils
|
|
2335
|
+
* @since 0.2.0
|
|
2336
|
+
*
|
|
2337
|
+
* @example
|
|
2338
|
+
* ```typescript
|
|
2339
|
+
* const config: UserWayConfig = {
|
|
2340
|
+
* accountId: 'XXXXXXXXXX'
|
|
2341
|
+
* }
|
|
2342
|
+
* ```
|
|
1689
2343
|
*/
|
|
1690
2344
|
interface UserWayConfig {
|
|
1691
|
-
/**
|
|
2345
|
+
/** ID da conta UserWay */
|
|
1692
2346
|
accountId: string;
|
|
2347
|
+
/** URL do script UserWay. Se omitido usa o padrão oficial. */
|
|
2348
|
+
scriptUrl?: string;
|
|
1693
2349
|
}
|
|
1694
2350
|
/**
|
|
1695
|
-
*
|
|
2351
|
+
* Cria integração do Google Analytics (GA4).
|
|
2352
|
+
* Configura o gtag e inicializa o tracking com o measurement ID fornecido.
|
|
2353
|
+
*
|
|
1696
2354
|
* @category Utils
|
|
2355
|
+
* @param config - Configuração do Google Analytics
|
|
2356
|
+
* @returns Integração configurada para o GA4
|
|
1697
2357
|
* @since 0.2.0
|
|
1698
|
-
* Cria uma integração para Google Analytics 4 (GA4).
|
|
1699
2358
|
*
|
|
1700
|
-
* @
|
|
1701
|
-
*
|
|
2359
|
+
* @example
|
|
2360
|
+
* ```typescript
|
|
2361
|
+
* const ga = createGoogleAnalyticsIntegration({
|
|
2362
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
2363
|
+
* config: { anonymize_ip: true }
|
|
2364
|
+
* })
|
|
2365
|
+
* ```
|
|
2366
|
+
*
|
|
2367
|
+
* @remarks
|
|
2368
|
+
* - Define cookies: _ga, _ga_*, _gid
|
|
2369
|
+
* - Categoria padrão: 'analytics'
|
|
2370
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
1702
2371
|
*/
|
|
1703
2372
|
declare function createGoogleAnalyticsIntegration(config: GoogleAnalyticsConfig): ScriptIntegration;
|
|
1704
2373
|
/**
|
|
1705
|
-
*
|
|
2374
|
+
* Cria integração do Google Tag Manager (GTM).
|
|
2375
|
+
* Configura o dataLayer e inicializa o container GTM.
|
|
2376
|
+
*
|
|
1706
2377
|
* @category Utils
|
|
2378
|
+
* @param config - Configuração do Google Tag Manager
|
|
2379
|
+
* @returns Integração configurada para o GTM
|
|
1707
2380
|
* @since 0.2.0
|
|
1708
|
-
* Cria uma integração para Google Tag Manager (GTM).
|
|
1709
2381
|
*
|
|
1710
|
-
* @
|
|
1711
|
-
*
|
|
2382
|
+
* @example
|
|
2383
|
+
* ```typescript
|
|
2384
|
+
* const gtm = createGoogleTagManagerIntegration({
|
|
2385
|
+
* containerId: 'GTM-XXXXXXX',
|
|
2386
|
+
* dataLayerName: 'myDataLayer'
|
|
2387
|
+
* })
|
|
2388
|
+
* ```
|
|
2389
|
+
*
|
|
2390
|
+
* @remarks
|
|
2391
|
+
* - Define cookies: _gcl_au
|
|
2392
|
+
* - Categoria padrão: 'analytics'
|
|
2393
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
1712
2394
|
*/
|
|
1713
2395
|
declare function createGoogleTagManagerIntegration(config: GoogleTagManagerConfig): ScriptIntegration;
|
|
1714
2396
|
/**
|
|
1715
|
-
*
|
|
2397
|
+
* Cria integração do UserWay (Acessibilidade).
|
|
2398
|
+
* Configura o widget de acessibilidade UserWay.
|
|
2399
|
+
*
|
|
1716
2400
|
* @category Utils
|
|
2401
|
+
* @param config - Configuração do UserWay
|
|
2402
|
+
* @returns Integração configurada para o UserWay
|
|
1717
2403
|
* @since 0.2.0
|
|
1718
|
-
* Cria uma integração para o widget de acessibilidade UserWay.
|
|
1719
2404
|
*
|
|
1720
|
-
* @
|
|
1721
|
-
*
|
|
2405
|
+
* @example
|
|
2406
|
+
* ```typescript
|
|
2407
|
+
* const userway = createUserWayIntegration({
|
|
2408
|
+
* accountId: 'XXXXXXXXXX'
|
|
2409
|
+
* })
|
|
2410
|
+
* ```
|
|
2411
|
+
*
|
|
2412
|
+
* @remarks
|
|
2413
|
+
* - Define cookies: _userway_*
|
|
2414
|
+
* - Categoria padrão: 'functional'
|
|
2415
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
1722
2416
|
*/
|
|
1723
2417
|
declare function createUserWayIntegration(config: UserWayConfig): ScriptIntegration;
|
|
1724
2418
|
/**
|
|
1725
|
-
*
|
|
2419
|
+
* Funções fábricas para integrações comuns.
|
|
2420
|
+
* Fornece acesso direto às funções de criação de integrações pré-configuradas.
|
|
2421
|
+
*
|
|
1726
2422
|
* @category Utils
|
|
1727
2423
|
* @since 0.2.0
|
|
1728
|
-
* Objeto contendo as factory functions para as integrações pré-configuradas mais comuns.
|
|
1729
2424
|
*
|
|
1730
2425
|
* @example
|
|
1731
|
-
* ```
|
|
1732
|
-
*
|
|
1733
|
-
* const gaIntegration = COMMON_INTEGRATIONS.googleAnalytics({ measurementId: 'G-XYZ' });
|
|
2426
|
+
* ```typescript
|
|
2427
|
+
* const ga = COMMON_INTEGRATIONS.googleAnalytics({ measurementId: 'G-XXXXXXXXXX' })
|
|
1734
2428
|
* ```
|
|
1735
2429
|
*/
|
|
1736
2430
|
declare const COMMON_INTEGRATIONS: {
|
|
@@ -1738,6 +2432,485 @@ declare const COMMON_INTEGRATIONS: {
|
|
|
1738
2432
|
googleTagManager: typeof createGoogleTagManagerIntegration;
|
|
1739
2433
|
userway: typeof createUserWayIntegration;
|
|
1740
2434
|
};
|
|
2435
|
+
/**
|
|
2436
|
+
* Configuração para integração do Facebook Pixel.
|
|
2437
|
+
*
|
|
2438
|
+
* @category Utils
|
|
2439
|
+
* @since 0.4.1
|
|
2440
|
+
*
|
|
2441
|
+
* @example
|
|
2442
|
+
* ```typescript
|
|
2443
|
+
* const config: FacebookPixelConfig = {
|
|
2444
|
+
* pixelId: '1234567890123456',
|
|
2445
|
+
* autoTrack: true,
|
|
2446
|
+
* advancedMatching: { email: 'user@example.com' }
|
|
2447
|
+
* }
|
|
2448
|
+
* ```
|
|
2449
|
+
*/
|
|
2450
|
+
interface FacebookPixelConfig {
|
|
2451
|
+
/** ID do pixel do Facebook */
|
|
2452
|
+
pixelId: string;
|
|
2453
|
+
/** Se deve rastrear PageView automaticamente. Padrão: true */
|
|
2454
|
+
autoTrack?: boolean;
|
|
2455
|
+
/** Configuração de correspondência avançada */
|
|
2456
|
+
advancedMatching?: Record<string, unknown>;
|
|
2457
|
+
/** URL do script do Pixel. Se omitido usa o padrão oficial. */
|
|
2458
|
+
scriptUrl?: string;
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* Configuração para integração do Hotjar.
|
|
2462
|
+
*
|
|
2463
|
+
* @category Utils
|
|
2464
|
+
* @since 0.4.1
|
|
2465
|
+
*
|
|
2466
|
+
* @example
|
|
2467
|
+
* ```typescript
|
|
2468
|
+
* const config: HotjarConfig = {
|
|
2469
|
+
* siteId: '1234567',
|
|
2470
|
+
* version: 6,
|
|
2471
|
+
* debug: false
|
|
2472
|
+
* }
|
|
2473
|
+
* ```
|
|
2474
|
+
*/
|
|
2475
|
+
interface HotjarConfig {
|
|
2476
|
+
/** ID do site no Hotjar */
|
|
2477
|
+
siteId: string;
|
|
2478
|
+
/** Versão do script Hotjar. Padrão: 6 */
|
|
2479
|
+
version?: number;
|
|
2480
|
+
/** Ativar modo debug. Padrão: false */
|
|
2481
|
+
debug?: boolean;
|
|
2482
|
+
/** URL do script Hotjar. Se omitido usa o padrão oficial. */
|
|
2483
|
+
scriptUrl?: string;
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Configuração para integração do Mixpanel.
|
|
2487
|
+
*
|
|
2488
|
+
* @category Utils
|
|
2489
|
+
* @since 0.4.1
|
|
2490
|
+
*
|
|
2491
|
+
* @example
|
|
2492
|
+
* ```typescript
|
|
2493
|
+
* const config: MixpanelConfig = {
|
|
2494
|
+
* token: 'your-project-token',
|
|
2495
|
+
* config: { debug: true },
|
|
2496
|
+
* api_host: 'https://api.mixpanel.com'
|
|
2497
|
+
* }
|
|
2498
|
+
* ```
|
|
2499
|
+
*/
|
|
2500
|
+
interface MixpanelConfig {
|
|
2501
|
+
/** Token do projeto Mixpanel */
|
|
2502
|
+
token: string;
|
|
2503
|
+
/** Configurações adicionais do Mixpanel */
|
|
2504
|
+
config?: Record<string, unknown>;
|
|
2505
|
+
/** Host customizado da API Mixpanel */
|
|
2506
|
+
api_host?: string;
|
|
2507
|
+
/** URL do script Mixpanel. Se omitido usa o padrão oficial. */
|
|
2508
|
+
scriptUrl?: string;
|
|
2509
|
+
}
|
|
2510
|
+
/**
|
|
2511
|
+
* Configuração para integração do Microsoft Clarity.
|
|
2512
|
+
*
|
|
2513
|
+
* @category Utils
|
|
2514
|
+
* @since 0.4.1
|
|
2515
|
+
*
|
|
2516
|
+
* @example
|
|
2517
|
+
* ```typescript
|
|
2518
|
+
* const config: ClarityConfig = {
|
|
2519
|
+
* projectId: 'abcdefghij',
|
|
2520
|
+
* upload: true
|
|
2521
|
+
* }
|
|
2522
|
+
* ```
|
|
2523
|
+
*/
|
|
2524
|
+
interface ClarityConfig {
|
|
2525
|
+
/** ID do projeto no Microsoft Clarity */
|
|
2526
|
+
projectId: string;
|
|
2527
|
+
/** Configuração de upload de dados. Padrão: indefinido */
|
|
2528
|
+
upload?: boolean;
|
|
2529
|
+
/** URL do script Clarity. Se omitido usa o padrão oficial. */
|
|
2530
|
+
scriptUrl?: string;
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Configuração para integração do Intercom.
|
|
2534
|
+
*
|
|
2535
|
+
* @category Utils
|
|
2536
|
+
* @since 0.4.1
|
|
2537
|
+
*
|
|
2538
|
+
* @example
|
|
2539
|
+
* ```typescript
|
|
2540
|
+
* const config: IntercomConfig = {
|
|
2541
|
+
* app_id: 'your-app-id'
|
|
2542
|
+
* }
|
|
2543
|
+
* ```
|
|
2544
|
+
*/
|
|
2545
|
+
interface IntercomConfig {
|
|
2546
|
+
/** ID da aplicação Intercom */
|
|
2547
|
+
app_id: string;
|
|
2548
|
+
/** URL do script Intercom. Se omitido usa o padrão oficial. */
|
|
2549
|
+
scriptUrl?: string;
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Configuração para integração do Zendesk Chat.
|
|
2553
|
+
*
|
|
2554
|
+
* @category Utils
|
|
2555
|
+
* @since 0.4.1
|
|
2556
|
+
*
|
|
2557
|
+
* @example
|
|
2558
|
+
* ```typescript
|
|
2559
|
+
* const config: ZendeskConfig = {
|
|
2560
|
+
* key: 'your-zendesk-key'
|
|
2561
|
+
* }
|
|
2562
|
+
* ```
|
|
2563
|
+
*/
|
|
2564
|
+
interface ZendeskConfig {
|
|
2565
|
+
/** Chave de identificação do Zendesk */
|
|
2566
|
+
key: string;
|
|
2567
|
+
/** URL do script Zendesk. Se omitido usa o padrão oficial. */
|
|
2568
|
+
scriptUrl?: string;
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Cria integração do Facebook Pixel.
|
|
2572
|
+
* Configura o fbq e inicializa o pixel com tracking automático opcional.
|
|
2573
|
+
*
|
|
2574
|
+
* @category Utils
|
|
2575
|
+
* @param config - Configuração do Facebook Pixel
|
|
2576
|
+
* @returns Integração configurada para o Facebook Pixel
|
|
2577
|
+
* @since 0.4.1
|
|
2578
|
+
*
|
|
2579
|
+
* @example
|
|
2580
|
+
* ```typescript
|
|
2581
|
+
* const pixel = createFacebookPixelIntegration({
|
|
2582
|
+
* pixelId: '1234567890123456',
|
|
2583
|
+
* autoTrack: true
|
|
2584
|
+
* })
|
|
2585
|
+
* ```
|
|
2586
|
+
*
|
|
2587
|
+
* @remarks
|
|
2588
|
+
* - Define cookies: _fbp, fr
|
|
2589
|
+
* - Categoria padrão: 'marketing'
|
|
2590
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
2591
|
+
*/
|
|
2592
|
+
declare function createFacebookPixelIntegration(config: FacebookPixelConfig): ScriptIntegration;
|
|
2593
|
+
/**
|
|
2594
|
+
* Cria integração do Hotjar.
|
|
2595
|
+
* Configura as configurações do Hotjar e inicializa o tracking de heatmaps e gravações.
|
|
2596
|
+
*
|
|
2597
|
+
* @category Utils
|
|
2598
|
+
* @param config - Configuração do Hotjar
|
|
2599
|
+
* @returns Integração configurada para o Hotjar
|
|
2600
|
+
* @since 0.4.1
|
|
2601
|
+
*
|
|
2602
|
+
* @example
|
|
2603
|
+
* ```typescript
|
|
2604
|
+
* const hotjar = createHotjarIntegration({
|
|
2605
|
+
* siteId: '1234567',
|
|
2606
|
+
* debug: true
|
|
2607
|
+
* })
|
|
2608
|
+
* ```
|
|
2609
|
+
*
|
|
2610
|
+
* @remarks
|
|
2611
|
+
* - Define cookies: _hjSession_*, _hjSessionUser_*, _hjFirstSeen, _hjIncludedInSessionSample, _hjAbsoluteSessionInProgress
|
|
2612
|
+
* - Categoria padrão: 'analytics'
|
|
2613
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
2614
|
+
*/
|
|
2615
|
+
declare function createHotjarIntegration(config: HotjarConfig): ScriptIntegration;
|
|
2616
|
+
/**
|
|
2617
|
+
* Cria integração do Mixpanel.
|
|
2618
|
+
* Configura e inicializa o Mixpanel para analytics de eventos.
|
|
2619
|
+
*
|
|
2620
|
+
* @category Utils
|
|
2621
|
+
* @param config - Configuração do Mixpanel
|
|
2622
|
+
* @returns Integração configurada para o Mixpanel
|
|
2623
|
+
* @since 0.4.1
|
|
2624
|
+
*
|
|
2625
|
+
* @example
|
|
2626
|
+
* ```typescript
|
|
2627
|
+
* const mixpanel = createMixpanelIntegration({
|
|
2628
|
+
* token: 'your-project-token',
|
|
2629
|
+
* config: { debug: true }
|
|
2630
|
+
* })
|
|
2631
|
+
* ```
|
|
2632
|
+
*
|
|
2633
|
+
* @remarks
|
|
2634
|
+
* - Define cookies: mp_*
|
|
2635
|
+
* - Categoria padrão: 'analytics'
|
|
2636
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
2637
|
+
* - Inclui tratamento de erro na inicialização
|
|
2638
|
+
*/
|
|
2639
|
+
declare function createMixpanelIntegration(config: MixpanelConfig): ScriptIntegration;
|
|
2640
|
+
/**
|
|
2641
|
+
* Cria integração do Microsoft Clarity.
|
|
2642
|
+
* Configura o Microsoft Clarity para heatmaps e analytics de comportamento.
|
|
2643
|
+
*
|
|
2644
|
+
* @category Utils
|
|
2645
|
+
* @param config - Configuração do Microsoft Clarity
|
|
2646
|
+
* @returns Integração configurada para o Clarity
|
|
2647
|
+
* @since 0.4.1
|
|
2648
|
+
*
|
|
2649
|
+
* @example
|
|
2650
|
+
* ```typescript
|
|
2651
|
+
* const clarity = createClarityIntegration({
|
|
2652
|
+
* projectId: 'abcdefghij',
|
|
2653
|
+
* upload: false
|
|
2654
|
+
* })
|
|
2655
|
+
* ```
|
|
2656
|
+
*
|
|
2657
|
+
* @remarks
|
|
2658
|
+
* - Define cookies: _clck, _clsk, CLID, ANONCHK, MR, MUID, SM
|
|
2659
|
+
* - Categoria padrão: 'analytics'
|
|
2660
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
2661
|
+
* - Configuração de upload opcional
|
|
2662
|
+
*/
|
|
2663
|
+
declare function createClarityIntegration(config: ClarityConfig): ScriptIntegration;
|
|
2664
|
+
/**
|
|
2665
|
+
* Cria integração do Intercom.
|
|
2666
|
+
* Configura o widget de chat e suporte do Intercom.
|
|
2667
|
+
*
|
|
2668
|
+
* @category Utils
|
|
2669
|
+
* @param config - Configuração do Intercom
|
|
2670
|
+
* @returns Integração configurada para o Intercom
|
|
2671
|
+
* @since 0.4.1
|
|
2672
|
+
*
|
|
2673
|
+
* @example
|
|
2674
|
+
* ```typescript
|
|
2675
|
+
* const intercom = createIntercomIntegration({
|
|
2676
|
+
* app_id: 'your-app-id'
|
|
2677
|
+
* })
|
|
2678
|
+
* ```
|
|
2679
|
+
*
|
|
2680
|
+
* @remarks
|
|
2681
|
+
* - Define cookies: intercom-id-*, intercom-session-*
|
|
2682
|
+
* - Categoria padrão: 'functional'
|
|
2683
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
2684
|
+
* - Inclui tratamento de erro na inicialização
|
|
2685
|
+
*/
|
|
2686
|
+
declare function createIntercomIntegration(config: IntercomConfig): ScriptIntegration;
|
|
2687
|
+
/**
|
|
2688
|
+
* Cria integração do Zendesk Chat.
|
|
2689
|
+
* Configura o widget de chat e suporte do Zendesk.
|
|
2690
|
+
*
|
|
2691
|
+
* @category Utils
|
|
2692
|
+
* @param config - Configuração do Zendesk Chat
|
|
2693
|
+
* @returns Integração configurada para o Zendesk Chat
|
|
2694
|
+
* @since 0.4.1
|
|
2695
|
+
*
|
|
2696
|
+
* @example
|
|
2697
|
+
* ```typescript
|
|
2698
|
+
* const zendesk = createZendeskChatIntegration({
|
|
2699
|
+
* key: 'your-zendesk-key'
|
|
2700
|
+
* })
|
|
2701
|
+
* ```
|
|
2702
|
+
*
|
|
2703
|
+
* @remarks
|
|
2704
|
+
* - Define cookies: __zlcmid, _zendesk_shared_session
|
|
2705
|
+
* - Categoria padrão: 'functional'
|
|
2706
|
+
* - SSR-safe: verifica disponibilidade do window
|
|
2707
|
+
* - Inclui tratamento de erro na identificação
|
|
2708
|
+
*/
|
|
2709
|
+
declare function createZendeskChatIntegration(config: ZendeskConfig): ScriptIntegration;
|
|
2710
|
+
/**
|
|
2711
|
+
* Configuração para conjunto de integrações de e-commerce.
|
|
2712
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para e-commerce.
|
|
2713
|
+
*
|
|
2714
|
+
* @category Utils
|
|
2715
|
+
* @since 0.4.1
|
|
2716
|
+
*
|
|
2717
|
+
* @example
|
|
2718
|
+
* ```typescript
|
|
2719
|
+
* const config: ECommerceConfig = {
|
|
2720
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
2721
|
+
* facebookPixel: { pixelId: '1234567890123456' }
|
|
2722
|
+
* }
|
|
2723
|
+
* ```
|
|
2724
|
+
*/
|
|
2725
|
+
interface ECommerceConfig {
|
|
2726
|
+
/** Configuração do Google Analytics */
|
|
2727
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
2728
|
+
/** Configuração do Facebook Pixel */
|
|
2729
|
+
facebookPixel?: FacebookPixelConfig;
|
|
2730
|
+
/** Configuração do Hotjar */
|
|
2731
|
+
hotjar?: HotjarConfig;
|
|
2732
|
+
/** Configuração do UserWay */
|
|
2733
|
+
userway?: UserWayConfig;
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2736
|
+
* Configuração para conjunto de integrações de SaaS.
|
|
2737
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para SaaS.
|
|
2738
|
+
*
|
|
2739
|
+
* @category Utils
|
|
2740
|
+
* @since 0.4.1
|
|
2741
|
+
*
|
|
2742
|
+
* @example
|
|
2743
|
+
* ```typescript
|
|
2744
|
+
* const config: SaaSConfig = {
|
|
2745
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
2746
|
+
* mixpanel: { token: 'your-token' },
|
|
2747
|
+
* intercom: { app_id: 'your-app-id' }
|
|
2748
|
+
* }
|
|
2749
|
+
* ```
|
|
2750
|
+
*/
|
|
2751
|
+
interface SaaSConfig {
|
|
2752
|
+
/** Configuração do Google Analytics */
|
|
2753
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
2754
|
+
/** Configuração do Mixpanel */
|
|
2755
|
+
mixpanel?: MixpanelConfig;
|
|
2756
|
+
/** Configuração do Intercom */
|
|
2757
|
+
intercom?: IntercomConfig;
|
|
2758
|
+
/** Configuração do Hotjar */
|
|
2759
|
+
hotjar?: HotjarConfig;
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Configuração para conjunto de integrações corporativas.
|
|
2763
|
+
* Define configurações opcionais para múltiplas integrações otimizadas para ambientes corporativos.
|
|
2764
|
+
*
|
|
2765
|
+
* @category Utils
|
|
2766
|
+
* @since 0.4.1
|
|
2767
|
+
*
|
|
2768
|
+
* @example
|
|
2769
|
+
* ```typescript
|
|
2770
|
+
* const config: CorporateConfig = {
|
|
2771
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
2772
|
+
* clarity: { projectId: 'abcdefghij' },
|
|
2773
|
+
* userway: { accountId: 'XXXXXXXXXX' }
|
|
2774
|
+
* }
|
|
2775
|
+
* ```
|
|
2776
|
+
*/
|
|
2777
|
+
interface CorporateConfig {
|
|
2778
|
+
/** Configuração do Google Analytics */
|
|
2779
|
+
googleAnalytics?: GoogleAnalyticsConfig;
|
|
2780
|
+
/** Configuração do Microsoft Clarity */
|
|
2781
|
+
clarity?: ClarityConfig;
|
|
2782
|
+
/** Configuração do Zendesk Chat */
|
|
2783
|
+
zendesk?: ZendeskConfig;
|
|
2784
|
+
/** Configuração do UserWay */
|
|
2785
|
+
userway?: UserWayConfig;
|
|
2786
|
+
}
|
|
2787
|
+
/**
|
|
2788
|
+
* Cria conjunto de integrações otimizado para e-commerce.
|
|
2789
|
+
* Combina analytics de conversão, remarketing e acessibilidade.
|
|
2790
|
+
*
|
|
2791
|
+
* @category Utils
|
|
2792
|
+
* @param cfg - Configuração das integrações de e-commerce
|
|
2793
|
+
* @returns Array de integrações configuradas
|
|
2794
|
+
* @since 0.4.1
|
|
2795
|
+
*
|
|
2796
|
+
* @example
|
|
2797
|
+
* ```typescript
|
|
2798
|
+
* const integrations = createECommerceIntegrations({
|
|
2799
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
2800
|
+
* facebookPixel: { pixelId: '1234567890123456' }
|
|
2801
|
+
* })
|
|
2802
|
+
* ```
|
|
2803
|
+
*
|
|
2804
|
+
* @remarks
|
|
2805
|
+
* Combina categorias: analytics, marketing, functional
|
|
2806
|
+
*/
|
|
2807
|
+
declare function createECommerceIntegrations(cfg: ECommerceConfig): ScriptIntegration[];
|
|
2808
|
+
/**
|
|
2809
|
+
* Cria conjunto de integrações otimizado para SaaS.
|
|
2810
|
+
* Combina analytics de produto, suporte ao cliente e comportamento do usuário.
|
|
2811
|
+
*
|
|
2812
|
+
* @category Utils
|
|
2813
|
+
* @param cfg - Configuração das integrações de SaaS
|
|
2814
|
+
* @returns Array de integrações configuradas
|
|
2815
|
+
* @since 0.4.1
|
|
2816
|
+
*
|
|
2817
|
+
* @example
|
|
2818
|
+
* ```typescript
|
|
2819
|
+
* const integrations = createSaaSIntegrations({
|
|
2820
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
2821
|
+
* mixpanel: { token: 'your-project-token' },
|
|
2822
|
+
* intercom: { app_id: 'your-app-id' }
|
|
2823
|
+
* })
|
|
2824
|
+
* ```
|
|
2825
|
+
*
|
|
2826
|
+
* @remarks
|
|
2827
|
+
* Combina categorias: analytics, functional
|
|
2828
|
+
*/
|
|
2829
|
+
declare function createSaaSIntegrations(cfg: SaaSConfig): ScriptIntegration[];
|
|
2830
|
+
/**
|
|
2831
|
+
* Cria conjunto de integrações otimizado para ambientes corporativos.
|
|
2832
|
+
* Combina analytics empresariais, compliance e suporte corporativo.
|
|
2833
|
+
*
|
|
2834
|
+
* @category Utils
|
|
2835
|
+
* @param cfg - Configuração das integrações corporativas
|
|
2836
|
+
* @returns Array de integrações configuradas
|
|
2837
|
+
* @since 0.4.1
|
|
2838
|
+
*
|
|
2839
|
+
* @example
|
|
2840
|
+
* ```typescript
|
|
2841
|
+
* const integrations = createCorporateIntegrations({
|
|
2842
|
+
* googleAnalytics: { measurementId: 'G-XXXXXXXXXX' },
|
|
2843
|
+
* clarity: { projectId: 'abcdefghij' },
|
|
2844
|
+
* userway: { accountId: 'XXXXXXXXXX' }
|
|
2845
|
+
* })
|
|
2846
|
+
* ```
|
|
2847
|
+
*
|
|
2848
|
+
* @remarks
|
|
2849
|
+
* Combina categorias: analytics, functional
|
|
2850
|
+
*/
|
|
2851
|
+
declare function createCorporateIntegrations(cfg: CorporateConfig): ScriptIntegration[];
|
|
2852
|
+
/**
|
|
2853
|
+
* Templates pré-configurados de integrações por tipo de negócio.
|
|
2854
|
+
* Define integrações essenciais e opcionais para cada contexto.
|
|
2855
|
+
*
|
|
2856
|
+
* @category Utils
|
|
2857
|
+
* @since 0.4.1
|
|
2858
|
+
*
|
|
2859
|
+
* @example
|
|
2860
|
+
* ```typescript
|
|
2861
|
+
* const template = INTEGRATION_TEMPLATES.ecommerce
|
|
2862
|
+
* console.log(template.essential) // ['google-analytics', 'facebook-pixel']
|
|
2863
|
+
* console.log(template.categories) // ['analytics', 'marketing', 'functional']
|
|
2864
|
+
* ```
|
|
2865
|
+
*
|
|
2866
|
+
* @remarks
|
|
2867
|
+
* Cada template define:
|
|
2868
|
+
* - essential: integrações obrigatórias/recomendadas
|
|
2869
|
+
* - optional: integrações complementares
|
|
2870
|
+
* - categories: categorias LGPD utilizadas
|
|
2871
|
+
*/
|
|
2872
|
+
declare const INTEGRATION_TEMPLATES: {
|
|
2873
|
+
ecommerce: {
|
|
2874
|
+
essential: string[];
|
|
2875
|
+
optional: string[];
|
|
2876
|
+
categories: string[];
|
|
2877
|
+
};
|
|
2878
|
+
saas: {
|
|
2879
|
+
essential: string[];
|
|
2880
|
+
optional: string[];
|
|
2881
|
+
categories: string[];
|
|
2882
|
+
};
|
|
2883
|
+
corporate: {
|
|
2884
|
+
essential: string[];
|
|
2885
|
+
optional: string[];
|
|
2886
|
+
categories: string[];
|
|
2887
|
+
};
|
|
2888
|
+
};
|
|
2889
|
+
/**
|
|
2890
|
+
* Sugere categorias LGPD apropriadas para um script baseado no nome/tipo.
|
|
2891
|
+
* Utiliza heurísticas para classificar scripts desconhecidos.
|
|
2892
|
+
*
|
|
2893
|
+
* @category Utils
|
|
2894
|
+
* @param name - Nome ou identificador do script
|
|
2895
|
+
* @returns Array de categorias sugeridas
|
|
2896
|
+
* @since 0.4.1
|
|
2897
|
+
*
|
|
2898
|
+
* @example
|
|
2899
|
+
* ```typescript
|
|
2900
|
+
* suggestCategoryForScript('facebook-pixel') // ['marketing']
|
|
2901
|
+
* suggestCategoryForScript('hotjar') // ['analytics']
|
|
2902
|
+
* suggestCategoryForScript('intercom-chat') // ['functional']
|
|
2903
|
+
* suggestCategoryForScript('unknown-script') // ['analytics']
|
|
2904
|
+
* ```
|
|
2905
|
+
*
|
|
2906
|
+
* @remarks
|
|
2907
|
+
* Heurísticas aplicadas:
|
|
2908
|
+
* - Scripts de ads/marketing → 'marketing'
|
|
2909
|
+
* - Scripts de analytics/tracking → 'analytics'
|
|
2910
|
+
* - Scripts de chat/suporte → 'functional'
|
|
2911
|
+
* - Padrão para desconhecidos → 'analytics'
|
|
2912
|
+
*/
|
|
2913
|
+
declare function suggestCategoryForScript(name: string): string[];
|
|
1741
2914
|
|
|
1742
2915
|
/**
|
|
1743
2916
|
* Componente que carrega scripts automaticamente baseado no consentimento.
|
|
@@ -1801,6 +2974,378 @@ declare function ConsentScriptLoader({ integrations, reloadOnChange, }: Readonly
|
|
|
1801
2974
|
*/
|
|
1802
2975
|
declare function useConsentScriptLoader(): (integration: ScriptIntegration) => Promise<boolean>;
|
|
1803
2976
|
|
|
2977
|
+
/**
|
|
2978
|
+
* @file autoConfigureCategories.ts
|
|
2979
|
+
* @description Sistema inteligente de auto-habilitação de categorias baseado nas integrações utilizadas
|
|
2980
|
+
* @since 0.4.1
|
|
2981
|
+
*/
|
|
2982
|
+
|
|
2983
|
+
/**
|
|
2984
|
+
* @interface CategoryAutoConfigResult
|
|
2985
|
+
* Resultado da análise e auto-configuração de categorias
|
|
2986
|
+
*/
|
|
2987
|
+
interface CategoryAutoConfigResult {
|
|
2988
|
+
/** Configuração original fornecida pelo desenvolvedor */
|
|
2989
|
+
originalConfig: ProjectCategoriesConfig;
|
|
2990
|
+
/** Configuração ajustada automaticamente pela biblioteca */
|
|
2991
|
+
adjustedConfig: ProjectCategoriesConfig;
|
|
2992
|
+
/** Categorias que foram automaticamente habilitadas */
|
|
2993
|
+
autoEnabledCategories: string[];
|
|
2994
|
+
/** Categorias requeridas pelas integrações mas não habilitadas */
|
|
2995
|
+
missingCategories: string[];
|
|
2996
|
+
/** Se algum ajuste foi necessário */
|
|
2997
|
+
wasAdjusted: boolean;
|
|
2998
|
+
/** Integrações que requerem cada categoria */
|
|
2999
|
+
categoryIntegrations: Record<string, string[]>;
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
* @function
|
|
3003
|
+
* @category Utils
|
|
3004
|
+
* @since 0.4.1
|
|
3005
|
+
* Analisa as integrações fornecidas e determina quais categorias são necessárias.
|
|
3006
|
+
*
|
|
3007
|
+
* @param integrations Array de integrações de script
|
|
3008
|
+
* @returns Record mapeando categoria para nomes das integrações que a utilizam
|
|
3009
|
+
*/
|
|
3010
|
+
declare function analyzeIntegrationCategories(integrations: ScriptIntegration[]): Record<string, string[]>;
|
|
3011
|
+
/**
|
|
3012
|
+
* @function
|
|
3013
|
+
* @category Utils
|
|
3014
|
+
* @since 0.4.1
|
|
3015
|
+
* Configura automaticamente as categorias necessárias baseado nas integrações utilizadas.
|
|
3016
|
+
*
|
|
3017
|
+
* Esta função implementa o comportamento inteligente da biblioteca:
|
|
3018
|
+
* 1. Detecta categorias requeridas pelas integrações
|
|
3019
|
+
* 2. Auto-habilita categorias em falta (modo padrão)
|
|
3020
|
+
* 3. Ou apenas avisa sobre categorias em falta (modo warning-only)
|
|
3021
|
+
* 4. Loga no console em modo DEV
|
|
3022
|
+
*
|
|
3023
|
+
* @param originalConfig Configuração original do ConsentProvider
|
|
3024
|
+
* @param integrations Array de integrações que serão utilizadas
|
|
3025
|
+
* @param options Opções de comportamento
|
|
3026
|
+
* @returns Resultado da análise e configuração automática
|
|
3027
|
+
*/
|
|
3028
|
+
declare function autoConfigureCategories(originalConfig: ProjectCategoriesConfig | undefined, integrations: ScriptIntegration[], options?: {
|
|
3029
|
+
/** Se true, apenas avisa mas não modifica a config (padrão: false - auto-habilita) */
|
|
3030
|
+
warningOnly?: boolean;
|
|
3031
|
+
/** Se true, desabilita logs no console (padrão: false) */
|
|
3032
|
+
silent?: boolean;
|
|
3033
|
+
}): CategoryAutoConfigResult;
|
|
3034
|
+
/**
|
|
3035
|
+
* @function
|
|
3036
|
+
* @category Utils
|
|
3037
|
+
* @since 0.4.1
|
|
3038
|
+
* Valida se todas as integrações têm suas categorias habilitadas.
|
|
3039
|
+
* Útil para validação em tempo de execução.
|
|
3040
|
+
*
|
|
3041
|
+
* @param integrations Array de integrações
|
|
3042
|
+
* @param enabledCategories Array de categorias habilitadas
|
|
3043
|
+
* @returns true se todas as categorias necessárias estão habilitadas
|
|
3044
|
+
*/
|
|
3045
|
+
declare function validateIntegrationCategories(integrations: ScriptIntegration[], enabledCategories: string[]): boolean;
|
|
3046
|
+
/**
|
|
3047
|
+
* @function
|
|
3048
|
+
* @category Utils
|
|
3049
|
+
* @since 0.4.1
|
|
3050
|
+
* Extrai categorias únicas de um array de integrações
|
|
3051
|
+
*
|
|
3052
|
+
* @param integrations Array de integrações
|
|
3053
|
+
* @returns Array de categorias únicas
|
|
3054
|
+
*/
|
|
3055
|
+
declare function extractCategoriesFromIntegrations(integrations: ScriptIntegration[]): string[];
|
|
3056
|
+
/**
|
|
3057
|
+
* @function
|
|
3058
|
+
* @category Utils
|
|
3059
|
+
* @since 0.4.1
|
|
3060
|
+
* Valida se integrações estão sendo incorretamente classificadas como "necessary".
|
|
3061
|
+
*
|
|
3062
|
+
* Esta função protege contra violações de GDPR/LGPD identificando scripts que
|
|
3063
|
+
* NUNCA devem ser considerados estritamente necessários.
|
|
3064
|
+
*
|
|
3065
|
+
* @param integrations Array de integrações para validar
|
|
3066
|
+
* @param enabledCategories Categorias habilitadas na configuração
|
|
3067
|
+
* @returns Lista de avisos sobre classificações incorretas
|
|
3068
|
+
*
|
|
3069
|
+
* @example
|
|
3070
|
+
* ```typescript
|
|
3071
|
+
* const warnings = validateNecessaryClassification([
|
|
3072
|
+
* createGoogleAnalyticsIntegration({...}), // ❌ NUNCA é necessary
|
|
3073
|
+
* createCustomIntegration({...}) // ✅ Pode ser necessary se apropriado
|
|
3074
|
+
* ], ['necessary', 'analytics'])
|
|
3075
|
+
*
|
|
3076
|
+
* if (warnings.length > 0) {
|
|
3077
|
+
* console.warn('Scripts incorretamente classificados como necessary:', warnings)
|
|
3078
|
+
* }
|
|
3079
|
+
* ```
|
|
3080
|
+
*/
|
|
3081
|
+
declare function validateNecessaryClassification(integrations: ScriptIntegration[], enabledCategories: Category[]): string[];
|
|
3082
|
+
|
|
3083
|
+
/**
|
|
3084
|
+
* @fileoverview
|
|
3085
|
+
* Sistema de textos expandido com suporte avançado a internacionalização,
|
|
3086
|
+
* contextos específicos e variações de tom.
|
|
3087
|
+
*
|
|
3088
|
+
* @author Luciano Édipo
|
|
3089
|
+
* @since 0.4.1
|
|
3090
|
+
*/
|
|
3091
|
+
|
|
3092
|
+
/**
|
|
3093
|
+
* Tipo auxiliar para variações de texto.
|
|
3094
|
+
*
|
|
3095
|
+
* Define um subconjunto opcional dos textos principais do banner e modal,
|
|
3096
|
+
* permitindo variações de t es: {
|
|
3097
|
+
bannerMessage: 'Utilizamos cookies para mejorar su experiencia y mostrar contenido personalizado.', (formal, casual, etc.) sem sobrescrever todos os textos.
|
|
3098
|
+
*
|
|
3099
|
+
* @category Types
|
|
3100
|
+
* @since 0.4.1
|
|
3101
|
+
*/
|
|
3102
|
+
type TextVariant = Partial<Pick<ConsentTexts, 'bannerMessage' | 'acceptAll' | 'declineAll' | 'modalTitle'>>;
|
|
3103
|
+
/**
|
|
3104
|
+
* Tipo auxiliar para textos de idioma.
|
|
3105
|
+
*
|
|
3106
|
+
* Define um subconjunto dos textos principais, excluindo propriedades específicas de internacionalização
|
|
3107
|
+
* e contextos, para uso em configurações multilíngues.
|
|
3108
|
+
*
|
|
3109
|
+
* @category Types
|
|
3110
|
+
* @since 0.4.1
|
|
3111
|
+
*/
|
|
3112
|
+
type LanguageTexts = Partial<Omit<ConsentTexts, 'i18n' | 'variants' | 'contexts'>>;
|
|
3113
|
+
/**
|
|
3114
|
+
* Sistema de textos avançado com suporte a internacionalização e contextos específicos.
|
|
3115
|
+
*
|
|
3116
|
+
* Interface expandida que permite personalização granular de todas as mensagens da biblioteca.
|
|
3117
|
+
* Suporta múltiplos idiomas, contextos específicos (e-commerce, SaaS, governo), variações
|
|
3118
|
+
* de tom, e compliance completo com LGPD/ANPD.
|
|
3119
|
+
*
|
|
3120
|
+
* @category Types
|
|
3121
|
+
* @since 0.4.1
|
|
3122
|
+
* @version 0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
3123
|
+
*
|
|
3124
|
+
* @example Configuração multilíngue
|
|
3125
|
+
* ```typescript
|
|
3126
|
+
* const multiLangTexts: AdvancedConsentTexts = {
|
|
3127
|
+
* // Herda de ConsentTexts básico
|
|
3128
|
+
* bannerMessage: 'Utilizamos cookies para melhorar sua experiência.',
|
|
3129
|
+
* acceptAll: 'Aceitar todos',
|
|
3130
|
+
* declineAll: 'Recusar',
|
|
3131
|
+
* preferences: 'Preferências',
|
|
3132
|
+
* modalTitle: 'Preferências de Cookies',
|
|
3133
|
+
* modalIntro: 'Personalize suas preferências de cookies.',
|
|
3134
|
+
* save: 'Salvar',
|
|
3135
|
+
* necessaryAlwaysOn: 'Cookies necessários (sempre ativos)',
|
|
3136
|
+
*
|
|
3137
|
+
* // Textos expandidos
|
|
3138
|
+
* variants: {
|
|
3139
|
+
* formal: {
|
|
3140
|
+
* bannerMessage: 'Este sítio utiliza cookies para otimizar a experiência de navegação.',
|
|
3141
|
+
* acceptAll: 'Concordar com todos os cookies'
|
|
3142
|
+
* },
|
|
3143
|
+
* casual: {
|
|
3144
|
+
* bannerMessage: '🍪 Olá! Usamos cookies para tornar tudo mais gostoso aqui.',
|
|
3145
|
+
* acceptAll: 'Aceitar tudo'
|
|
3146
|
+
* }
|
|
3147
|
+
* },
|
|
3148
|
+
*
|
|
3149
|
+
* // Internacionalização
|
|
3150
|
+
* i18n: {
|
|
3151
|
+
* en: {
|
|
3152
|
+
* bannerMessage: 'We use cookies to enhance your experience.',
|
|
3153
|
+
* acceptAll: 'Accept All',
|
|
3154
|
+
* declineAll: 'Decline'
|
|
3155
|
+
* },
|
|
3156
|
+
* es: {
|
|
3157
|
+
* bannerMessage: 'Utilizamos cookies para mejorar su experiencia.',
|
|
3158
|
+
* acceptAll: 'Aceptar Todo',
|
|
3159
|
+
* declineAll: 'Rechazar'
|
|
3160
|
+
* }
|
|
3161
|
+
* }
|
|
3162
|
+
* }
|
|
3163
|
+
* ```
|
|
3164
|
+
*/
|
|
3165
|
+
interface AdvancedConsentTexts extends ConsentTexts {
|
|
3166
|
+
/** Texto para confirmar ação */
|
|
3167
|
+
confirm?: string;
|
|
3168
|
+
/** Texto para cancelar ação */
|
|
3169
|
+
cancel?: string;
|
|
3170
|
+
/** Texto de carregamento */
|
|
3171
|
+
loading?: string;
|
|
3172
|
+
/** Textos específicos para cada categoria de cookie */
|
|
3173
|
+
categories?: {
|
|
3174
|
+
necessary?: {
|
|
3175
|
+
name?: string;
|
|
3176
|
+
description?: string;
|
|
3177
|
+
examples?: string;
|
|
3178
|
+
};
|
|
3179
|
+
analytics?: {
|
|
3180
|
+
name?: string;
|
|
3181
|
+
description?: string;
|
|
3182
|
+
examples?: string;
|
|
3183
|
+
};
|
|
3184
|
+
marketing?: {
|
|
3185
|
+
name?: string;
|
|
3186
|
+
description?: string;
|
|
3187
|
+
examples?: string;
|
|
3188
|
+
};
|
|
3189
|
+
functional?: {
|
|
3190
|
+
name?: string;
|
|
3191
|
+
description?: string;
|
|
3192
|
+
examples?: string;
|
|
3193
|
+
};
|
|
3194
|
+
performance?: {
|
|
3195
|
+
name?: string;
|
|
3196
|
+
description?: string;
|
|
3197
|
+
examples?: string;
|
|
3198
|
+
};
|
|
3199
|
+
};
|
|
3200
|
+
/** Mensagens de feedback ao usuário */
|
|
3201
|
+
feedback?: {
|
|
3202
|
+
/** Preferências salvas com sucesso */
|
|
3203
|
+
saveSuccess?: string;
|
|
3204
|
+
/** Erro ao salvar preferências */
|
|
3205
|
+
saveError?: string;
|
|
3206
|
+
/** Consentimento atualizado */
|
|
3207
|
+
consentUpdated?: string;
|
|
3208
|
+
/** Cookies rejeitados */
|
|
3209
|
+
cookiesRejected?: string;
|
|
3210
|
+
/** Configurações resetadas */
|
|
3211
|
+
settingsReset?: string;
|
|
3212
|
+
};
|
|
3213
|
+
/** Labels ARIA e textos para leitores de tela */
|
|
3214
|
+
accessibility?: {
|
|
3215
|
+
/** Label do banner para leitores de tela */
|
|
3216
|
+
bannerLabel?: string;
|
|
3217
|
+
/** Label do modal para leitores de tela */
|
|
3218
|
+
modalLabel?: string;
|
|
3219
|
+
/** Instrução de navegação por teclado */
|
|
3220
|
+
keyboardNavigation?: string;
|
|
3221
|
+
/** Estado do toggle de categoria */
|
|
3222
|
+
toggleState?: {
|
|
3223
|
+
enabled?: string;
|
|
3224
|
+
disabled?: string;
|
|
3225
|
+
};
|
|
3226
|
+
/** Região live para anúncios dinâmicos */
|
|
3227
|
+
liveRegion?: string;
|
|
3228
|
+
};
|
|
3229
|
+
/** Textos otimizados para diferentes contextos */
|
|
3230
|
+
contexts?: {
|
|
3231
|
+
/** Contexto e-commerce */
|
|
3232
|
+
ecommerce?: {
|
|
3233
|
+
cartAbandonment?: string;
|
|
3234
|
+
personalizedOffers?: string;
|
|
3235
|
+
paymentSecurity?: string;
|
|
3236
|
+
productRecommendations?: string;
|
|
3237
|
+
};
|
|
3238
|
+
/** Contexto SaaS */
|
|
3239
|
+
saas?: {
|
|
3240
|
+
userAnalytics?: string;
|
|
3241
|
+
performanceMonitoring?: string;
|
|
3242
|
+
featureUsage?: string;
|
|
3243
|
+
customerSupport?: string;
|
|
3244
|
+
};
|
|
3245
|
+
/** Contexto governamental */
|
|
3246
|
+
government?: {
|
|
3247
|
+
citizenServices?: string;
|
|
3248
|
+
dataProtection?: string;
|
|
3249
|
+
transparency?: string;
|
|
3250
|
+
accessibility?: string;
|
|
3251
|
+
};
|
|
3252
|
+
/** Contexto educacional */
|
|
3253
|
+
education?: {
|
|
3254
|
+
studentProgress?: string;
|
|
3255
|
+
learningAnalytics?: string;
|
|
3256
|
+
accessibility?: string;
|
|
3257
|
+
parentalConsent?: string;
|
|
3258
|
+
};
|
|
3259
|
+
};
|
|
3260
|
+
/** Diferentes variações de tom para a mesma mensagem */
|
|
3261
|
+
variants?: {
|
|
3262
|
+
/** Tom formal/profissional */
|
|
3263
|
+
formal?: TextVariant;
|
|
3264
|
+
/** Tom casual/amigável */
|
|
3265
|
+
casual?: TextVariant;
|
|
3266
|
+
/** Tom conciso/direto */
|
|
3267
|
+
concise?: TextVariant;
|
|
3268
|
+
/** Tom detalhado/explicativo */
|
|
3269
|
+
detailed?: TextVariant;
|
|
3270
|
+
};
|
|
3271
|
+
/** Suporte a múltiplos idiomas */
|
|
3272
|
+
i18n?: {
|
|
3273
|
+
/** Textos em inglês */
|
|
3274
|
+
en?: LanguageTexts;
|
|
3275
|
+
/** Textos em espanhol */
|
|
3276
|
+
es?: LanguageTexts;
|
|
3277
|
+
/** Textos em francês */
|
|
3278
|
+
fr?: LanguageTexts;
|
|
3279
|
+
/** Textos em alemão */
|
|
3280
|
+
de?: LanguageTexts;
|
|
3281
|
+
/** Textos em italiano */
|
|
3282
|
+
it?: LanguageTexts;
|
|
3283
|
+
};
|
|
3284
|
+
/** Informações técnicas sobre cookies */
|
|
3285
|
+
technical?: {
|
|
3286
|
+
/** Explicação sobre cookies de sessão */
|
|
3287
|
+
sessionCookies?: string;
|
|
3288
|
+
/** Explicação sobre cookies persistentes */
|
|
3289
|
+
persistentCookies?: string;
|
|
3290
|
+
/** Explicação sobre cookies de terceiros */
|
|
3291
|
+
thirdPartyCookies?: string;
|
|
3292
|
+
/** Como desabilitar cookies no navegador */
|
|
3293
|
+
browserSettings?: string;
|
|
3294
|
+
/** Impacto de desabilitar cookies */
|
|
3295
|
+
disablingImpact?: string;
|
|
3296
|
+
};
|
|
3297
|
+
/** Cabeçalhos para tabela de detalhes de cookies */
|
|
3298
|
+
cookieDetails?: {
|
|
3299
|
+
tableHeaders?: {
|
|
3300
|
+
name?: string;
|
|
3301
|
+
purpose?: string;
|
|
3302
|
+
duration?: string;
|
|
3303
|
+
provider?: string;
|
|
3304
|
+
type?: string;
|
|
3305
|
+
};
|
|
3306
|
+
/** Texto quando não há cookies para mostrar */
|
|
3307
|
+
noCookies?: string;
|
|
3308
|
+
/** Botão para expandir/colapsar detalhes */
|
|
3309
|
+
toggleDetails?: {
|
|
3310
|
+
expand?: string;
|
|
3311
|
+
collapse?: string;
|
|
3312
|
+
};
|
|
3313
|
+
};
|
|
3314
|
+
}
|
|
3315
|
+
/**
|
|
3316
|
+
* Textos padrão expandidos para diferentes contextos e idiomas.
|
|
3317
|
+
*
|
|
3318
|
+
* @category Utils
|
|
3319
|
+
* @since 0.4.1
|
|
3320
|
+
*/
|
|
3321
|
+
declare const EXPANDED_DEFAULT_TEXTS: Partial<AdvancedConsentTexts>;
|
|
3322
|
+
/**
|
|
3323
|
+
* Utilitário para resolver textos baseado em idioma, contexto e variação.
|
|
3324
|
+
*
|
|
3325
|
+
* @category Utils
|
|
3326
|
+
* @since 0.4.1
|
|
3327
|
+
*
|
|
3328
|
+
* @param texts - Textos avançados configurados
|
|
3329
|
+
* @param options - Opções de resolução
|
|
3330
|
+
* @returns Textos resolvidos para o contexto
|
|
3331
|
+
*/
|
|
3332
|
+
declare function resolveTexts(texts: AdvancedConsentTexts, options?: {
|
|
3333
|
+
language?: 'pt' | 'en' | 'es' | 'fr' | 'de' | 'it';
|
|
3334
|
+
context?: 'ecommerce' | 'saas' | 'government' | 'education';
|
|
3335
|
+
variant?: 'formal' | 'casual' | 'concise' | 'detailed';
|
|
3336
|
+
}): ConsentTexts;
|
|
3337
|
+
/**
|
|
3338
|
+
* Templates pré-configurados para diferentes contextos.
|
|
3339
|
+
*
|
|
3340
|
+
* @category Utils
|
|
3341
|
+
* @since 0.4.1
|
|
3342
|
+
*/
|
|
3343
|
+
declare const TEXT_TEMPLATES: {
|
|
3344
|
+
readonly ecommerce: AdvancedConsentTexts;
|
|
3345
|
+
readonly saas: AdvancedConsentTexts;
|
|
3346
|
+
readonly government: AdvancedConsentTexts;
|
|
3347
|
+
};
|
|
3348
|
+
|
|
1804
3349
|
/**
|
|
1805
3350
|
* @enum LogLevel
|
|
1806
3351
|
* @category Utils
|
|
@@ -1840,6 +3385,17 @@ declare enum LogLevel {
|
|
|
1840
3385
|
*/
|
|
1841
3386
|
declare function setDebugLogging(enabled: boolean, level?: LogLevel): void;
|
|
1842
3387
|
|
|
3388
|
+
interface CookieCatalogOverrides {
|
|
3389
|
+
byCategory?: Record<string, CookieDescriptor[]>;
|
|
3390
|
+
byIntegration?: Record<string, CookieDescriptor[]>;
|
|
3391
|
+
}
|
|
3392
|
+
interface CookieCategoryOverrides {
|
|
3393
|
+
[cookieNameOrPattern: string]: Category;
|
|
3394
|
+
}
|
|
3395
|
+
declare function setCookieCatalogOverrides(overrides: CookieCatalogOverrides): void;
|
|
3396
|
+
declare function setCookieCategoryOverrides(map: CookieCategoryOverrides): void;
|
|
3397
|
+
declare function getCookiesInfoForCategory(categoryId: Category, usedIntegrations: string[]): CookieDescriptor[];
|
|
3398
|
+
|
|
1843
3399
|
/**
|
|
1844
3400
|
* Propriedades para customizar o comportamento e aparência do componente CookieBanner.
|
|
1845
3401
|
*
|
|
@@ -1902,6 +3458,11 @@ interface CookieBannerProps {
|
|
|
1902
3458
|
* @example "/privacy-policy" | "https://example.com/cookies"
|
|
1903
3459
|
*/
|
|
1904
3460
|
policyLinkUrl?: string;
|
|
3461
|
+
/**
|
|
3462
|
+
* URL para os termos de uso do site (opcional). Quando fornecida, será considerada uma rota "segura"
|
|
3463
|
+
* para não aplicar bloqueio total (overlay) mesmo em modo bloqueante.
|
|
3464
|
+
*/
|
|
3465
|
+
termsLinkUrl?: string;
|
|
1905
3466
|
/**
|
|
1906
3467
|
* Força exibição do banner em modo de debug, independente do consentimento.
|
|
1907
3468
|
*
|
|
@@ -2063,7 +3624,7 @@ interface CookieBannerProps {
|
|
|
2063
3624
|
* @public
|
|
2064
3625
|
* @since 0.1.0
|
|
2065
3626
|
*/
|
|
2066
|
-
declare function CookieBanner({ policyLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
3627
|
+
declare function CookieBanner({ policyLinkUrl, termsLinkUrl, debug, blocking, hideBranding, SnackbarProps, PaperProps, }: Readonly<CookieBannerProps>): react_jsx_runtime.JSX.Element | null;
|
|
2067
3628
|
|
|
2068
3629
|
/**
|
|
2069
3630
|
* Props para o componente FloatingPreferencesButton.
|
|
@@ -2104,6 +3665,16 @@ interface FloatingPreferencesButtonProps {
|
|
|
2104
3665
|
*/
|
|
2105
3666
|
declare function FloatingPreferencesButton({ position, offset, icon, tooltip, FabProps, hideWhenConsented, }: Readonly<FloatingPreferencesButtonProps>): react_jsx_runtime.JSX.Element | null;
|
|
2106
3667
|
|
|
3668
|
+
/** @module src/utils/categoryUtils */
|
|
3669
|
+
/**
|
|
3670
|
+
* @category Utils
|
|
3671
|
+
* @since 0.2.0
|
|
3672
|
+
* Utilitários para gerenciamento de categorias de consentimento LGPD.
|
|
3673
|
+
*
|
|
3674
|
+
* Fornece funções para criar, validar e recuperar definições de categorias de cookies,
|
|
3675
|
+
* garantindo conformidade com a LGPD e suporte a categorias customizadas.
|
|
3676
|
+
*/
|
|
3677
|
+
|
|
2107
3678
|
/**
|
|
2108
3679
|
* Cria um objeto de preferências de consentimento inicial baseado na configuração de categorias do projeto.
|
|
2109
3680
|
* @category Utils
|
|
@@ -2113,8 +3684,10 @@ declare function FloatingPreferencesButton({ position, offset, icon, tooltip, Fa
|
|
|
2113
3684
|
* @returns Um objeto `ConsentPreferences` com as categorias e seus valores iniciais.
|
|
2114
3685
|
* @remarks
|
|
2115
3686
|
* Esta função é crucial para inicializar o estado de consentimento. Ela garante que apenas as categorias
|
|
2116
|
-
* definidas no `ConsentProvider` sejam incluídas no objeto de preferências
|
|
2117
|
-
* de minimização de dados da LGPD.
|
|
3687
|
+
* definidas no `ConsentProvider` sejam incluídas no objeto de preferências (tanto categorias padrão
|
|
3688
|
+
* em `enabledCategories` quanto `customCategories`), alinhando-se ao princípio de minimização de dados da LGPD.
|
|
3689
|
+
*
|
|
3690
|
+
* Since v0.4.0: inclui categorias de `config.customCategories` na inicialização.
|
|
2118
3691
|
* @example
|
|
2119
3692
|
* ```ts
|
|
2120
3693
|
* // Gera preferências com 'analytics' e 'marketing' desabilitados por padrão
|
|
@@ -2123,6 +3696,15 @@ declare function FloatingPreferencesButton({ position, offset, icon, tooltip, Fa
|
|
|
2123
3696
|
* })
|
|
2124
3697
|
* // Result: { necessary: true, analytics: false, marketing: false }
|
|
2125
3698
|
*
|
|
3699
|
+
* // Inclui categorias customizadas
|
|
3700
|
+
* const initialWithCustom = createProjectPreferences({
|
|
3701
|
+
* enabledCategories: ['analytics'],
|
|
3702
|
+
* customCategories: [
|
|
3703
|
+
* { id: 'abTesting', name: 'AB Testing', description: 'Experimentos de interface' },
|
|
3704
|
+
* ],
|
|
3705
|
+
* })
|
|
3706
|
+
* // Result: { necessary: true, analytics: false, abTesting: false }
|
|
3707
|
+
*
|
|
2126
3708
|
* // Gera preferências com todas as categorias habilitadas
|
|
2127
3709
|
* const allAcceptedPrefs = createProjectPreferences(
|
|
2128
3710
|
* { enabledCategories: ['analytics', 'marketing'] },
|
|
@@ -2143,6 +3725,8 @@ declare function createProjectPreferences(config?: ProjectCategoriesConfig, defa
|
|
|
2143
3725
|
* Garante a integridade dos dados ao carregar o estado de um cookie. Se a configuração do projeto mudou
|
|
2144
3726
|
* (ex: uma categoria foi removida), esta função limpa as preferências obsoletas do estado,
|
|
2145
3727
|
* evitando inconsistências.
|
|
3728
|
+
*
|
|
3729
|
+
* Since v0.4.0: reconhece `config.customCategories` como válidas ao validar.
|
|
2146
3730
|
* @example
|
|
2147
3731
|
* ```ts
|
|
2148
3732
|
* const savedPrefs = { necessary: true, analytics: true, oldCategory: false }
|
|
@@ -2161,7 +3745,10 @@ declare function validateProjectPreferences(preferences: ConsentPreferences, con
|
|
|
2161
3745
|
* @returns Um array de objetos `CategoryDefinition`.
|
|
2162
3746
|
* @remarks
|
|
2163
3747
|
* Útil para construir UIs de preferência customizadas, pois fornece os nomes e descrições
|
|
2164
|
-
* de todas as categorias que devem ser exibidas ao usuário
|
|
3748
|
+
* de todas as categorias que devem ser exibidas ao usuário, incluindo quaisquer `customCategories`
|
|
3749
|
+
* definidas no `ConsentProvider`.
|
|
3750
|
+
*
|
|
3751
|
+
* Since v0.4.0: inclui categorias definidas em `config.customCategories`.
|
|
2165
3752
|
* @example
|
|
2166
3753
|
* ```ts
|
|
2167
3754
|
* const config = { enabledCategories: ['analytics'] }
|
|
@@ -2175,4 +3762,4 @@ declare function validateProjectPreferences(preferences: ConsentPreferences, con
|
|
|
2175
3762
|
*/
|
|
2176
3763
|
declare function getAllProjectCategories(config?: ProjectCategoriesConfig): CategoryDefinition[];
|
|
2177
3764
|
|
|
2178
|
-
export { COMMON_INTEGRATIONS, type CategoriesContextValue, type Category, type CategoryDefinition, type ConsentContextValue, type ConsentCookieData, type ConsentCookieOptions, ConsentGate, type ConsentPreferences, ConsentProvider, type ConsentProviderProps, ConsentScriptLoader, type ConsentScriptLoaderProps, type ConsentState, type ConsentTexts, CookieBanner, type CookieBannerProps, type CustomCookieBannerProps, type CustomFloatingPreferencesButtonProps, type CustomPreferencesModalProps, DEFAULT_PROJECT_CATEGORIES, type DesignTokens, type DeveloperGuidance, FloatingPreferencesButton, type FloatingPreferencesButtonProps, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, LogLevel, PreferencesModal, type PreferencesModalProps, type ProjectCategoriesConfig, type ScriptIntegration, type UserWayConfig, analyzeDeveloperConfiguration, createDefaultConsentTheme, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createProjectPreferences, createUserWayIntegration, defaultConsentTheme, defaultTexts, getAllProjectCategories, loadScript, openPreferencesModal, setDebugLogging, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useOpenPreferencesModal, validateProjectPreferences };
|
|
3765
|
+
export { type AdvancedConsentTexts, COMMON_INTEGRATIONS, type CategoriesContextValue, type Category, type CategoryAutoConfigResult, type CategoryDefinition, type ClarityConfig, type ConsentContextValue, type ConsentCookieData, type ConsentCookieOptions, ConsentGate, type ConsentPreferences, ConsentProvider, type ConsentProviderProps, ConsentScriptLoader, type ConsentScriptLoaderProps, type ConsentState, type ConsentTexts, CookieBanner, type CookieBannerProps, type CookieDescriptor, type CorporateConfig, type CustomCookieBannerProps, type CustomFloatingPreferencesButtonProps, type CustomPreferencesModalProps, DEFAULT_PROJECT_CATEGORIES, type DesignTokens, type DeveloperGuidance, type ECommerceConfig, EXPANDED_DEFAULT_TEXTS, type FacebookPixelConfig, FloatingPreferencesButton, type FloatingPreferencesButtonProps, GUIDANCE_PRESETS, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, type GuidanceConfig, type GuidanceMessage, type GuidanceSeverity, type HotjarConfig, INTEGRATION_TEMPLATES, type IntercomConfig, LogLevel, type MixpanelConfig, PreferencesModal, type PreferencesModalProps, type ProjectCategoriesConfig, type SaaSConfig, type ScriptIntegration, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, categorizeDiscoveredCookies, createClarityIntegration, createCorporateIntegrations, createDefaultConsentTheme, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultConsentTheme, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, loadScript, logDeveloperGuidance, openPreferencesModal, resolveTexts, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|