react-lgpd-consent 0.2.2 → 0.2.3
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.
|
@@ -113,33 +113,63 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
113
113
|
return guidance;
|
|
114
114
|
}
|
|
115
115
|
function logDeveloperGuidance(guidance) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
try {
|
|
117
|
+
const isProduction = (
|
|
118
|
+
// 1. NODE_ENV de bundlers (Vite, webpack, etc.)
|
|
119
|
+
typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Vite/bundler env vars (apenas em ESM)
|
|
120
|
+
typeof globalThis !== "undefined" && typeof globalThis.import !== "undefined" && globalThis.import.meta?.env?.PROD === true || // 3. Flag customizada para desabilitar logs
|
|
121
|
+
typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ || // 4. Flag de desenvolvimento desabilitada
|
|
122
|
+
typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__
|
|
123
|
+
);
|
|
124
|
+
if (isProduction) return;
|
|
125
|
+
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
126
|
+
if (guidance.warnings.length > 0) {
|
|
127
|
+
console.group(`${PREFIX} \u26A0\uFE0F Avisos de Configura\xE7\xE3o`);
|
|
128
|
+
guidance.warnings.forEach(
|
|
129
|
+
(warning) => console.warn(`${PREFIX} ${warning}`)
|
|
130
|
+
);
|
|
131
|
+
console.groupEnd();
|
|
132
|
+
}
|
|
133
|
+
if (guidance.suggestions.length > 0) {
|
|
134
|
+
console.group(`${PREFIX} \u{1F4A1} Sugest\xF5es`);
|
|
135
|
+
guidance.suggestions.forEach(
|
|
136
|
+
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
137
|
+
);
|
|
138
|
+
console.groupEnd();
|
|
139
|
+
}
|
|
140
|
+
if (guidance.usingDefaults) {
|
|
141
|
+
console.info(
|
|
142
|
+
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
146
|
+
console.table(
|
|
147
|
+
guidance.activeCategoriesInfo.map((cat) => ({
|
|
148
|
+
ID: cat.id,
|
|
149
|
+
Nome: cat.name,
|
|
150
|
+
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
151
|
+
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
152
|
+
}))
|
|
153
|
+
);
|
|
129
154
|
console.info(
|
|
130
|
-
|
|
155
|
+
`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`
|
|
131
156
|
);
|
|
157
|
+
console.groupEnd();
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
160
|
+
console.warn(
|
|
161
|
+
"[\u{1F36A} LGPD-CONSENT] Sistema de orienta\xE7\xF5es encontrou erro:",
|
|
162
|
+
error
|
|
163
|
+
);
|
|
164
|
+
}
|
|
132
165
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}))
|
|
141
|
-
);
|
|
142
|
-
console.groupEnd();
|
|
166
|
+
}
|
|
167
|
+
function useDeveloperGuidance(config) {
|
|
168
|
+
const guidance = analyzeDeveloperConfiguration(config);
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
logDeveloperGuidance(guidance);
|
|
171
|
+
}, [JSON.stringify(config)]);
|
|
172
|
+
return guidance;
|
|
143
173
|
}
|
|
144
174
|
|
|
145
175
|
// src/context/CategoriesContext.tsx
|
|
@@ -359,7 +389,7 @@ var defaultConsentTheme = createTheme({
|
|
|
359
389
|
// src/context/ConsentContext.tsx
|
|
360
390
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
361
391
|
var PreferencesModal = React3.lazy(
|
|
362
|
-
() => import("./PreferencesModal-
|
|
392
|
+
() => import("./PreferencesModal-UMNANMVX.js").then((m) => ({
|
|
363
393
|
default: m.PreferencesModal
|
|
364
394
|
}))
|
|
365
395
|
);
|
|
@@ -524,6 +554,7 @@ function ConsentProvider({
|
|
|
524
554
|
}
|
|
525
555
|
return void 0;
|
|
526
556
|
}, [categories, customCategories]);
|
|
557
|
+
useDeveloperGuidance(finalCategoriesConfig);
|
|
527
558
|
const boot = React3.useMemo(() => {
|
|
528
559
|
if (initialState) return { ...initialState, isModalOpen: false };
|
|
529
560
|
return createFullConsentState(
|
package/dist/index.cjs
CHANGED
|
@@ -280,33 +280,63 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
280
280
|
return guidance;
|
|
281
281
|
}
|
|
282
282
|
function logDeveloperGuidance(guidance) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
283
|
+
try {
|
|
284
|
+
const isProduction = (
|
|
285
|
+
// 1. NODE_ENV de bundlers (Vite, webpack, etc.)
|
|
286
|
+
typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Vite/bundler env vars (apenas em ESM)
|
|
287
|
+
typeof globalThis !== "undefined" && typeof globalThis.import !== "undefined" && globalThis.import.meta?.env?.PROD === true || // 3. Flag customizada para desabilitar logs
|
|
288
|
+
typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ || // 4. Flag de desenvolvimento desabilitada
|
|
289
|
+
typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__
|
|
290
|
+
);
|
|
291
|
+
if (isProduction) return;
|
|
292
|
+
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
293
|
+
if (guidance.warnings.length > 0) {
|
|
294
|
+
console.group(`${PREFIX} \u26A0\uFE0F Avisos de Configura\xE7\xE3o`);
|
|
295
|
+
guidance.warnings.forEach(
|
|
296
|
+
(warning) => console.warn(`${PREFIX} ${warning}`)
|
|
297
|
+
);
|
|
298
|
+
console.groupEnd();
|
|
299
|
+
}
|
|
300
|
+
if (guidance.suggestions.length > 0) {
|
|
301
|
+
console.group(`${PREFIX} \u{1F4A1} Sugest\xF5es`);
|
|
302
|
+
guidance.suggestions.forEach(
|
|
303
|
+
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
304
|
+
);
|
|
305
|
+
console.groupEnd();
|
|
306
|
+
}
|
|
307
|
+
if (guidance.usingDefaults) {
|
|
308
|
+
console.info(
|
|
309
|
+
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
313
|
+
console.table(
|
|
314
|
+
guidance.activeCategoriesInfo.map((cat) => ({
|
|
315
|
+
ID: cat.id,
|
|
316
|
+
Nome: cat.name,
|
|
317
|
+
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
318
|
+
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
319
|
+
}))
|
|
320
|
+
);
|
|
296
321
|
console.info(
|
|
297
|
-
|
|
322
|
+
`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`
|
|
298
323
|
);
|
|
324
|
+
console.groupEnd();
|
|
325
|
+
} catch (error) {
|
|
326
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
327
|
+
console.warn(
|
|
328
|
+
"[\u{1F36A} LGPD-CONSENT] Sistema de orienta\xE7\xF5es encontrou erro:",
|
|
329
|
+
error
|
|
330
|
+
);
|
|
331
|
+
}
|
|
299
332
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}))
|
|
308
|
-
);
|
|
309
|
-
console.groupEnd();
|
|
333
|
+
}
|
|
334
|
+
function useDeveloperGuidance(config) {
|
|
335
|
+
const guidance = analyzeDeveloperConfiguration(config);
|
|
336
|
+
React.useEffect(() => {
|
|
337
|
+
logDeveloperGuidance(guidance);
|
|
338
|
+
}, [JSON.stringify(config)]);
|
|
339
|
+
return guidance;
|
|
310
340
|
}
|
|
311
341
|
var React, DEFAULT_PROJECT_CATEGORIES;
|
|
312
342
|
var init_developerGuidance = __esm({
|
|
@@ -691,6 +721,7 @@ function ConsentProvider({
|
|
|
691
721
|
}
|
|
692
722
|
return void 0;
|
|
693
723
|
}, [categories, customCategories]);
|
|
724
|
+
useDeveloperGuidance(finalCategoriesConfig);
|
|
694
725
|
const boot = React3.useMemo(() => {
|
|
695
726
|
if (initialState) return { ...initialState, isModalOpen: false };
|
|
696
727
|
return createFullConsentState(
|
|
@@ -793,6 +824,7 @@ var init_ConsentContext = __esm({
|
|
|
793
824
|
init_cookieUtils();
|
|
794
825
|
init_theme();
|
|
795
826
|
init_CategoriesContext();
|
|
827
|
+
init_developerGuidance();
|
|
796
828
|
import_jsx_runtime4 = require("react/jsx-runtime");
|
|
797
829
|
PreferencesModal2 = React3.lazy(
|
|
798
830
|
() => Promise.resolve().then(() => (init_PreferencesModal(), PreferencesModal_exports)).then((m) => ({
|
package/dist/index.d.cts
CHANGED
|
@@ -284,41 +284,192 @@ interface ConsentCookieOptions {
|
|
|
284
284
|
path: string;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
|
-
* Propriedades
|
|
287
|
+
* Propriedades do componente ConsentProvider - configuração principal da biblioteca.
|
|
288
|
+
*
|
|
289
|
+
* @example Uso básico (configuração mínima):
|
|
290
|
+
* ```tsx
|
|
291
|
+
* <ConsentProvider
|
|
292
|
+
* categories={{ enabledCategories: ['analytics'] }}
|
|
293
|
+
* >
|
|
294
|
+
* <App />
|
|
295
|
+
* </ConsentProvider>
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @example Configuração completa com textos ANPD:
|
|
299
|
+
* ```tsx
|
|
300
|
+
* <ConsentProvider
|
|
301
|
+
* categories={{
|
|
302
|
+
* enabledCategories: ['analytics', 'functional'],
|
|
303
|
+
* customCategories: [{
|
|
304
|
+
* id: 'governo',
|
|
305
|
+
* name: 'Cookies Governamentais',
|
|
306
|
+
* description: 'Coleta para estatísticas públicas',
|
|
307
|
+
* essential: false
|
|
308
|
+
* }]
|
|
309
|
+
* }}
|
|
310
|
+
* texts={{
|
|
311
|
+
* bannerMessage: 'Utilizamos cookies conforme LGPD...',
|
|
312
|
+
* controllerInfo: 'Controlado por: Ministério XYZ - CNPJ: 00.000.000/0001-00',
|
|
313
|
+
* dataTypes: 'Coletamos: dados de navegação para análise estatística',
|
|
314
|
+
* userRights: 'Direitos: acessar, corrigir, excluir dados',
|
|
315
|
+
* contactInfo: 'DPO: dpo@ministerio.gov.br'
|
|
316
|
+
* }}
|
|
317
|
+
* onConsentGiven={(state) => console.log('Consentimento:', state)}
|
|
318
|
+
* >
|
|
319
|
+
* <App />
|
|
320
|
+
* </ConsentProvider>
|
|
321
|
+
* ```
|
|
288
322
|
*/
|
|
289
323
|
interface ConsentProviderProps {
|
|
290
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* Estado inicial do consentimento para hidratação SSR.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* // Em Next.js para evitar flash do banner
|
|
330
|
+
* <ConsentProvider initialState={{ consented: true, preferences: {...} }}>
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
291
333
|
initialState?: ConsentState;
|
|
292
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* Configuração das categorias de cookies utilizadas no projeto.
|
|
336
|
+
* Define quais categorias padrão serão habilitadas e categorias customizadas.
|
|
337
|
+
*
|
|
338
|
+
* @example Apenas analytics:
|
|
339
|
+
* ```tsx
|
|
340
|
+
* categories={{ enabledCategories: ['analytics'] }}
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @example Com categoria customizada:
|
|
344
|
+
* ```tsx
|
|
345
|
+
* categories={{
|
|
346
|
+
* enabledCategories: ['analytics', 'marketing'],
|
|
347
|
+
* customCategories: [{
|
|
348
|
+
* id: 'pesquisa',
|
|
349
|
+
* name: 'Cookies de Pesquisa',
|
|
350
|
+
* description: 'Coleta feedback e opinião dos usuários',
|
|
351
|
+
* essential: false
|
|
352
|
+
* }]
|
|
353
|
+
* }}
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
293
356
|
categories?: ProjectCategoriesConfig;
|
|
294
|
-
/**
|
|
357
|
+
/**
|
|
358
|
+
* Textos customizados da interface (banner e modal).
|
|
359
|
+
* Todos os campos são opcionais - valores não fornecidos usam o padrão em português.
|
|
360
|
+
*
|
|
361
|
+
* @example Textos básicos:
|
|
362
|
+
* ```tsx
|
|
363
|
+
* texts={{
|
|
364
|
+
* bannerMessage: 'We use cookies...',
|
|
365
|
+
* acceptAll: 'Accept All',
|
|
366
|
+
* declineAll: 'Reject'
|
|
367
|
+
* }}
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* @example Textos ANPD para compliance:
|
|
371
|
+
* ```tsx
|
|
372
|
+
* texts={{
|
|
373
|
+
* controllerInfo: 'Controlado por: Empresa XYZ - CNPJ: 12.345.678/0001-90',
|
|
374
|
+
* dataTypes: 'Coletamos: endereço IP, preferências de navegação',
|
|
375
|
+
* userRights: 'Você pode solicitar acesso, correção ou exclusão dos dados'
|
|
376
|
+
* }}
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
295
379
|
texts?: Partial<ConsentTexts>;
|
|
296
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* Tema customizado Material-UI aplicado aos componentes.
|
|
382
|
+
* Aceita qualquer objeto que será passado para ThemeProvider.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```tsx
|
|
386
|
+
* theme={{
|
|
387
|
+
* palette: { primary: { main: '#1976d2' } },
|
|
388
|
+
* components: { MuiButton: { styleOverrides: { root: { borderRadius: 8 } } } }
|
|
389
|
+
* }}
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
297
392
|
theme?: any;
|
|
298
393
|
/**
|
|
299
|
-
* @deprecated
|
|
300
|
-
*
|
|
394
|
+
* @deprecated Usar `categories.customCategories` em vez disso.
|
|
395
|
+
* Mantido para compatibilidade com v0.1.x
|
|
301
396
|
*/
|
|
302
397
|
customCategories?: CategoryDefinition[];
|
|
303
|
-
/**
|
|
398
|
+
/**
|
|
399
|
+
* Integrações nativas de scripts terceiros (Google Analytics, etc.).
|
|
400
|
+
* Scripts são carregados automaticamente baseado no consentimento.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* import { createGoogleAnalyticsIntegration } from 'react-lgpd-consent'
|
|
405
|
+
*
|
|
406
|
+
* scriptIntegrations={[
|
|
407
|
+
* createGoogleAnalyticsIntegration('GA_MEASUREMENT_ID')
|
|
408
|
+
* ]}
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
304
411
|
scriptIntegrations?: ScriptIntegration[];
|
|
305
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* Componente customizado para substituir o modal padrão de preferências.
|
|
414
|
+
* Deve implementar a lógica de consentimento usando os hooks da biblioteca.
|
|
415
|
+
*/
|
|
306
416
|
PreferencesModalComponent?: React.ComponentType<any>;
|
|
307
|
-
/** Props adicionais para o modal customizado. */
|
|
417
|
+
/** Props adicionais passadas para o modal customizado. */
|
|
308
418
|
preferencesModalProps?: Record<string, any>;
|
|
309
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Desabilita o modal automático de preferências.
|
|
421
|
+
* Útil quando se quer controle total sobre quando/como exibir as opções.
|
|
422
|
+
*/
|
|
310
423
|
disableAutomaticModal?: boolean;
|
|
311
|
-
/**
|
|
424
|
+
/**
|
|
425
|
+
* Comportamento do banner de consentimento:
|
|
426
|
+
* - `false` (padrão): Banner não-intrusivo, usuário pode navegar livremente
|
|
427
|
+
* - `true`: Banner bloqueia interação até decisão (compliance rigorosa)
|
|
428
|
+
*/
|
|
312
429
|
blocking?: boolean;
|
|
313
|
-
/**
|
|
430
|
+
/** Oculta o branding "fornecido por LÉdipO.eti.br" dos componentes. */
|
|
314
431
|
hideBranding?: boolean;
|
|
315
|
-
/**
|
|
432
|
+
/**
|
|
433
|
+
* Callback executado quando usuário dá consentimento pela primeira vez.
|
|
434
|
+
* Útil para inicializar analytics, registrar evento, etc.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```tsx
|
|
438
|
+
* onConsentGiven={(state) => {
|
|
439
|
+
* console.log('Consentimento registrado:', state)
|
|
440
|
+
* // Inicializar Google Analytics, etc.
|
|
441
|
+
* }}
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
316
444
|
onConsentGiven?: (state: ConsentState) => void;
|
|
317
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* Callback executado quando usuário modifica preferências.
|
|
447
|
+
* Executado após salvar as mudanças.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```tsx
|
|
451
|
+
* onPreferencesSaved={(prefs) => {
|
|
452
|
+
* console.log('Novas preferências:', prefs)
|
|
453
|
+
* // Reconfigurar scripts baseado nas preferências
|
|
454
|
+
* }}
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
318
457
|
onPreferencesSaved?: (prefs: ConsentPreferences) => void;
|
|
319
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* Configurações do cookie de consentimento.
|
|
460
|
+
* Valores não fornecidos usam padrões seguros para LGPD.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```tsx
|
|
464
|
+
* cookie={{
|
|
465
|
+
* name: 'meuAppConsent',
|
|
466
|
+
* maxAgeDays: 180,
|
|
467
|
+
* sameSite: 'Strict'
|
|
468
|
+
* }}
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
320
471
|
cookie?: Partial<ConsentCookieOptions>;
|
|
321
|
-
/** Elementos filhos
|
|
472
|
+
/** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
|
|
322
473
|
children: React.ReactNode;
|
|
323
474
|
}
|
|
324
475
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -284,41 +284,192 @@ interface ConsentCookieOptions {
|
|
|
284
284
|
path: string;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
|
-
* Propriedades
|
|
287
|
+
* Propriedades do componente ConsentProvider - configuração principal da biblioteca.
|
|
288
|
+
*
|
|
289
|
+
* @example Uso básico (configuração mínima):
|
|
290
|
+
* ```tsx
|
|
291
|
+
* <ConsentProvider
|
|
292
|
+
* categories={{ enabledCategories: ['analytics'] }}
|
|
293
|
+
* >
|
|
294
|
+
* <App />
|
|
295
|
+
* </ConsentProvider>
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @example Configuração completa com textos ANPD:
|
|
299
|
+
* ```tsx
|
|
300
|
+
* <ConsentProvider
|
|
301
|
+
* categories={{
|
|
302
|
+
* enabledCategories: ['analytics', 'functional'],
|
|
303
|
+
* customCategories: [{
|
|
304
|
+
* id: 'governo',
|
|
305
|
+
* name: 'Cookies Governamentais',
|
|
306
|
+
* description: 'Coleta para estatísticas públicas',
|
|
307
|
+
* essential: false
|
|
308
|
+
* }]
|
|
309
|
+
* }}
|
|
310
|
+
* texts={{
|
|
311
|
+
* bannerMessage: 'Utilizamos cookies conforme LGPD...',
|
|
312
|
+
* controllerInfo: 'Controlado por: Ministério XYZ - CNPJ: 00.000.000/0001-00',
|
|
313
|
+
* dataTypes: 'Coletamos: dados de navegação para análise estatística',
|
|
314
|
+
* userRights: 'Direitos: acessar, corrigir, excluir dados',
|
|
315
|
+
* contactInfo: 'DPO: dpo@ministerio.gov.br'
|
|
316
|
+
* }}
|
|
317
|
+
* onConsentGiven={(state) => console.log('Consentimento:', state)}
|
|
318
|
+
* >
|
|
319
|
+
* <App />
|
|
320
|
+
* </ConsentProvider>
|
|
321
|
+
* ```
|
|
288
322
|
*/
|
|
289
323
|
interface ConsentProviderProps {
|
|
290
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* Estado inicial do consentimento para hidratação SSR.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* // Em Next.js para evitar flash do banner
|
|
330
|
+
* <ConsentProvider initialState={{ consented: true, preferences: {...} }}>
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
291
333
|
initialState?: ConsentState;
|
|
292
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* Configuração das categorias de cookies utilizadas no projeto.
|
|
336
|
+
* Define quais categorias padrão serão habilitadas e categorias customizadas.
|
|
337
|
+
*
|
|
338
|
+
* @example Apenas analytics:
|
|
339
|
+
* ```tsx
|
|
340
|
+
* categories={{ enabledCategories: ['analytics'] }}
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @example Com categoria customizada:
|
|
344
|
+
* ```tsx
|
|
345
|
+
* categories={{
|
|
346
|
+
* enabledCategories: ['analytics', 'marketing'],
|
|
347
|
+
* customCategories: [{
|
|
348
|
+
* id: 'pesquisa',
|
|
349
|
+
* name: 'Cookies de Pesquisa',
|
|
350
|
+
* description: 'Coleta feedback e opinião dos usuários',
|
|
351
|
+
* essential: false
|
|
352
|
+
* }]
|
|
353
|
+
* }}
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
293
356
|
categories?: ProjectCategoriesConfig;
|
|
294
|
-
/**
|
|
357
|
+
/**
|
|
358
|
+
* Textos customizados da interface (banner e modal).
|
|
359
|
+
* Todos os campos são opcionais - valores não fornecidos usam o padrão em português.
|
|
360
|
+
*
|
|
361
|
+
* @example Textos básicos:
|
|
362
|
+
* ```tsx
|
|
363
|
+
* texts={{
|
|
364
|
+
* bannerMessage: 'We use cookies...',
|
|
365
|
+
* acceptAll: 'Accept All',
|
|
366
|
+
* declineAll: 'Reject'
|
|
367
|
+
* }}
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* @example Textos ANPD para compliance:
|
|
371
|
+
* ```tsx
|
|
372
|
+
* texts={{
|
|
373
|
+
* controllerInfo: 'Controlado por: Empresa XYZ - CNPJ: 12.345.678/0001-90',
|
|
374
|
+
* dataTypes: 'Coletamos: endereço IP, preferências de navegação',
|
|
375
|
+
* userRights: 'Você pode solicitar acesso, correção ou exclusão dos dados'
|
|
376
|
+
* }}
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
295
379
|
texts?: Partial<ConsentTexts>;
|
|
296
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* Tema customizado Material-UI aplicado aos componentes.
|
|
382
|
+
* Aceita qualquer objeto que será passado para ThemeProvider.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```tsx
|
|
386
|
+
* theme={{
|
|
387
|
+
* palette: { primary: { main: '#1976d2' } },
|
|
388
|
+
* components: { MuiButton: { styleOverrides: { root: { borderRadius: 8 } } } }
|
|
389
|
+
* }}
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
297
392
|
theme?: any;
|
|
298
393
|
/**
|
|
299
|
-
* @deprecated
|
|
300
|
-
*
|
|
394
|
+
* @deprecated Usar `categories.customCategories` em vez disso.
|
|
395
|
+
* Mantido para compatibilidade com v0.1.x
|
|
301
396
|
*/
|
|
302
397
|
customCategories?: CategoryDefinition[];
|
|
303
|
-
/**
|
|
398
|
+
/**
|
|
399
|
+
* Integrações nativas de scripts terceiros (Google Analytics, etc.).
|
|
400
|
+
* Scripts são carregados automaticamente baseado no consentimento.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* import { createGoogleAnalyticsIntegration } from 'react-lgpd-consent'
|
|
405
|
+
*
|
|
406
|
+
* scriptIntegrations={[
|
|
407
|
+
* createGoogleAnalyticsIntegration('GA_MEASUREMENT_ID')
|
|
408
|
+
* ]}
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
304
411
|
scriptIntegrations?: ScriptIntegration[];
|
|
305
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* Componente customizado para substituir o modal padrão de preferências.
|
|
414
|
+
* Deve implementar a lógica de consentimento usando os hooks da biblioteca.
|
|
415
|
+
*/
|
|
306
416
|
PreferencesModalComponent?: React.ComponentType<any>;
|
|
307
|
-
/** Props adicionais para o modal customizado. */
|
|
417
|
+
/** Props adicionais passadas para o modal customizado. */
|
|
308
418
|
preferencesModalProps?: Record<string, any>;
|
|
309
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Desabilita o modal automático de preferências.
|
|
421
|
+
* Útil quando se quer controle total sobre quando/como exibir as opções.
|
|
422
|
+
*/
|
|
310
423
|
disableAutomaticModal?: boolean;
|
|
311
|
-
/**
|
|
424
|
+
/**
|
|
425
|
+
* Comportamento do banner de consentimento:
|
|
426
|
+
* - `false` (padrão): Banner não-intrusivo, usuário pode navegar livremente
|
|
427
|
+
* - `true`: Banner bloqueia interação até decisão (compliance rigorosa)
|
|
428
|
+
*/
|
|
312
429
|
blocking?: boolean;
|
|
313
|
-
/**
|
|
430
|
+
/** Oculta o branding "fornecido por LÉdipO.eti.br" dos componentes. */
|
|
314
431
|
hideBranding?: boolean;
|
|
315
|
-
/**
|
|
432
|
+
/**
|
|
433
|
+
* Callback executado quando usuário dá consentimento pela primeira vez.
|
|
434
|
+
* Útil para inicializar analytics, registrar evento, etc.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```tsx
|
|
438
|
+
* onConsentGiven={(state) => {
|
|
439
|
+
* console.log('Consentimento registrado:', state)
|
|
440
|
+
* // Inicializar Google Analytics, etc.
|
|
441
|
+
* }}
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
316
444
|
onConsentGiven?: (state: ConsentState) => void;
|
|
317
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* Callback executado quando usuário modifica preferências.
|
|
447
|
+
* Executado após salvar as mudanças.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```tsx
|
|
451
|
+
* onPreferencesSaved={(prefs) => {
|
|
452
|
+
* console.log('Novas preferências:', prefs)
|
|
453
|
+
* // Reconfigurar scripts baseado nas preferências
|
|
454
|
+
* }}
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
318
457
|
onPreferencesSaved?: (prefs: ConsentPreferences) => void;
|
|
319
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* Configurações do cookie de consentimento.
|
|
460
|
+
* Valores não fornecidos usam padrões seguros para LGPD.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```tsx
|
|
464
|
+
* cookie={{
|
|
465
|
+
* name: 'meuAppConsent',
|
|
466
|
+
* maxAgeDays: 180,
|
|
467
|
+
* sameSite: 'Strict'
|
|
468
|
+
* }}
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
320
471
|
cookie?: Partial<ConsentCookieOptions>;
|
|
321
|
-
/** Elementos filhos
|
|
472
|
+
/** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
|
|
322
473
|
children: React.ReactNode;
|
|
323
474
|
}
|
|
324
475
|
/**
|
package/dist/index.js
CHANGED
package/package.json
CHANGED