@react-lgpd-consent/core 0.6.3 → 0.7.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 +346 -2
- package/README.md +62 -1
- package/dist/index.cjs +816 -195
- package/dist/index.d.cts +283 -16
- package/dist/index.d.ts +283 -16
- package/dist/index.js +809 -196
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ declare const GUIDANCE_PRESETS: {
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* @fileoverview
|
|
96
|
-
* Definições de tipos TypeScript para o sistema de consentimento LGPD
|
|
96
|
+
* Definições de tipos TypeScript para o sistema de consentimento LGPD.
|
|
97
97
|
*
|
|
98
98
|
* Este arquivo contém todas as interfaces, tipos e estruturas de dados utilizadas
|
|
99
99
|
* pela biblioteca react-lgpd-consent, incluindo definições de categorias,
|
|
@@ -376,7 +376,7 @@ interface ConsentPreferences {
|
|
|
376
376
|
[key: string]: boolean;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
|
-
* Estrutura do cookie de consentimento em conformidade com LGPD
|
|
379
|
+
* Estrutura do cookie de consentimento em conformidade com LGPD.
|
|
380
380
|
* @category Types
|
|
381
381
|
* @since 0.2.1
|
|
382
382
|
*
|
|
@@ -458,6 +458,44 @@ interface ConsentCookieData {
|
|
|
458
458
|
*/
|
|
459
459
|
projectConfig?: ProjectCategoriesConfig;
|
|
460
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Ações possíveis registradas no log de auditoria de consentimento.
|
|
463
|
+
* @category Types
|
|
464
|
+
* @since 0.7.0
|
|
465
|
+
* @public
|
|
466
|
+
*/
|
|
467
|
+
type ConsentAuditAction = 'init' | 'update' | 'reset';
|
|
468
|
+
/**
|
|
469
|
+
* Entrada de auditoria contendo os dados essenciais para comprovar consentimento.
|
|
470
|
+
* Inclui timestamps, versão configurada e snapshot das preferências.
|
|
471
|
+
* @category Types
|
|
472
|
+
* @since 0.7.0
|
|
473
|
+
* @public
|
|
474
|
+
*/
|
|
475
|
+
interface ConsentAuditEntry {
|
|
476
|
+
/** Ação que originou o registro (inicialização, atualização ou reset). */
|
|
477
|
+
action: ConsentAuditAction;
|
|
478
|
+
/** Chave de armazenamento (cookie/localStorage) aplicada, incluindo namespace/versão. */
|
|
479
|
+
storageKey: string;
|
|
480
|
+
/** Versão lógica de consentimento configurada via `storage.version` (política/termo). */
|
|
481
|
+
consentVersion: string;
|
|
482
|
+
/** Timestamp ISO do registro de auditoria. */
|
|
483
|
+
timestamp: string;
|
|
484
|
+
/** Timestamp ISO da primeira decisão de consentimento. */
|
|
485
|
+
consentDate: string;
|
|
486
|
+
/** Timestamp ISO da última alteração de preferências. */
|
|
487
|
+
lastUpdate: string;
|
|
488
|
+
/** Estado atual de consentimento agregado. */
|
|
489
|
+
consented: boolean;
|
|
490
|
+
/** Preferências por categoria no momento do registro. */
|
|
491
|
+
preferences: ConsentPreferences;
|
|
492
|
+
/** Versão do schema do cookie. */
|
|
493
|
+
version: string;
|
|
494
|
+
/** Origem da decisão (banner, modal, reset, programmatic). */
|
|
495
|
+
source: ConsentEventOrigin;
|
|
496
|
+
/** Snapshot da configuração de categorias utilizada. */
|
|
497
|
+
projectConfig?: ProjectCategoriesConfig;
|
|
498
|
+
}
|
|
461
499
|
/**
|
|
462
500
|
* Estado interno completo do sistema de consentimento.
|
|
463
501
|
* @category Types
|
|
@@ -648,14 +686,22 @@ interface ConsentTexts {
|
|
|
648
686
|
interface ConsentCookieOptions {
|
|
649
687
|
/** Nome do cookie. Padrão: 'cookieConsent' */
|
|
650
688
|
name: string;
|
|
651
|
-
/**
|
|
652
|
-
|
|
689
|
+
/**
|
|
690
|
+
* Tempo de expiração em segundos.
|
|
691
|
+
* @defaultValue 31536000 (365 dias)
|
|
692
|
+
*/
|
|
693
|
+
maxAge?: number;
|
|
694
|
+
/**
|
|
695
|
+
* Tempo de expiração em dias (legado).
|
|
696
|
+
* @deprecated Prefira `maxAge` em segundos.
|
|
697
|
+
*/
|
|
698
|
+
maxAgeDays?: number;
|
|
653
699
|
/** Política SameSite do cookie. */
|
|
654
|
-
sameSite
|
|
655
|
-
/** Se o cookie deve ser seguro (HTTPS). Padrão: true */
|
|
656
|
-
secure
|
|
700
|
+
sameSite?: 'Lax' | 'Strict' | 'None';
|
|
701
|
+
/** Se o cookie deve ser seguro (HTTPS). Padrão: true em HTTPS. */
|
|
702
|
+
secure?: boolean;
|
|
657
703
|
/** Caminho do cookie. Padrão: '/' */
|
|
658
|
-
path
|
|
704
|
+
path?: string;
|
|
659
705
|
/**
|
|
660
706
|
* Domínio do cookie (ex.: `.example.com` para compartilhar entre subdomínios).
|
|
661
707
|
* Se não definido, o navegador usa o domínio atual.
|
|
@@ -1312,6 +1358,26 @@ interface ConsentProviderProps {
|
|
|
1312
1358
|
* ```
|
|
1313
1359
|
*/
|
|
1314
1360
|
onConsentGiven?: (state: ConsentState) => void;
|
|
1361
|
+
/** Callback disparado após hidratação inicial (consentimento existente ou não). */
|
|
1362
|
+
onConsentInit?: (state: ConsentState) => void;
|
|
1363
|
+
/** Callback disparado sempre que o consentimento muda (banner, modal ou programático/reset). */
|
|
1364
|
+
onConsentChange?: (state: ConsentState, context: {
|
|
1365
|
+
origin: ConsentState['source'] | 'reset';
|
|
1366
|
+
}) => void;
|
|
1367
|
+
/**
|
|
1368
|
+
* Callback de auditoria executado sempre que o consentimento é registrado, atualizado ou resetado.
|
|
1369
|
+
* Útil para persistir logs externos (ex.: backend, data lake) com carimbo de tempo e versão do termo.
|
|
1370
|
+
* @since 0.7.0
|
|
1371
|
+
*
|
|
1372
|
+
* @example
|
|
1373
|
+
* ```tsx
|
|
1374
|
+
* <ConsentProvider
|
|
1375
|
+
* storage={{ namespace: 'portal.gov', version: '2025-Q4' }}
|
|
1376
|
+
* onAuditLog={(audit) => api.auditConsent(audit)}
|
|
1377
|
+
* />
|
|
1378
|
+
* ```
|
|
1379
|
+
*/
|
|
1380
|
+
onAuditLog?: (entry: ConsentAuditEntry) => void;
|
|
1315
1381
|
/**
|
|
1316
1382
|
* Callback executado quando usuário modifica preferências.
|
|
1317
1383
|
* Executado após salvar as mudanças.
|
|
@@ -1333,8 +1399,9 @@ interface ConsentProviderProps {
|
|
|
1333
1399
|
* ```tsx
|
|
1334
1400
|
* cookie={{
|
|
1335
1401
|
* name: 'meuAppConsent',
|
|
1336
|
-
*
|
|
1337
|
-
* sameSite: 'Strict'
|
|
1402
|
+
* maxAge: 60 * 60 * 24 * 180, // 180 dias
|
|
1403
|
+
* sameSite: 'Strict',
|
|
1404
|
+
* secure: true,
|
|
1338
1405
|
* }}
|
|
1339
1406
|
* ```
|
|
1340
1407
|
*/
|
|
@@ -1412,6 +1479,8 @@ interface CustomCookieBannerProps {
|
|
|
1412
1479
|
rejectAll: () => void;
|
|
1413
1480
|
openPreferences: () => void;
|
|
1414
1481
|
texts: ConsentTexts;
|
|
1482
|
+
/** Indica se o branding padrão deve ser ocultado. */
|
|
1483
|
+
hideBranding?: boolean;
|
|
1415
1484
|
/**
|
|
1416
1485
|
* Indica se o modo bloqueante está ativo no contexto.
|
|
1417
1486
|
* Esta prop é apenas informativa para banners customizados ajustarem sua UI.
|
|
@@ -1556,6 +1625,8 @@ interface ConsentInitializedEvent {
|
|
|
1556
1625
|
timestamp: string;
|
|
1557
1626
|
/** Estado inicial das categorias de consentimento */
|
|
1558
1627
|
categories: Record<string, boolean>;
|
|
1628
|
+
/** Snapshot das preferências (alias para categories para Consent Mode v2) */
|
|
1629
|
+
preferences?: Record<string, boolean>;
|
|
1559
1630
|
}
|
|
1560
1631
|
/**
|
|
1561
1632
|
* Payload do evento `consent_updated` disparado no dataLayer.
|
|
@@ -1597,6 +1668,8 @@ interface ConsentUpdatedEvent {
|
|
|
1597
1668
|
origin: ConsentEventOrigin;
|
|
1598
1669
|
/** Estado atualizado das categorias de consentimento */
|
|
1599
1670
|
categories: Record<string, boolean>;
|
|
1671
|
+
/** Snapshot das preferências (alias para categories para Consent Mode v2) */
|
|
1672
|
+
preferences?: Record<string, boolean>;
|
|
1600
1673
|
/** Lista de categorias que foram modificadas nesta atualização */
|
|
1601
1674
|
changed_categories: string[];
|
|
1602
1675
|
}
|
|
@@ -1656,7 +1729,7 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1656
1729
|
* </ConsentProvider>
|
|
1657
1730
|
* ```
|
|
1658
1731
|
*/
|
|
1659
|
-
declare function ConsentProvider({ initialState, categories, texts: textsProp, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding: _hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, storage, onConsentVersionChange, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
1732
|
+
declare function ConsentProvider({ initialState, categories, texts: textsProp, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding: _hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, storage, onConsentVersionChange, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, onConsentInit, onConsentChange, onAuditLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
1660
1733
|
declare const defaultTexts: ConsentTexts;
|
|
1661
1734
|
|
|
1662
1735
|
/**
|
|
@@ -2342,6 +2415,23 @@ declare function buildConsentStorageKey(options?: {
|
|
|
2342
2415
|
namespace?: string | null;
|
|
2343
2416
|
version?: string | null;
|
|
2344
2417
|
}): string;
|
|
2418
|
+
/**
|
|
2419
|
+
* Cria um registro de auditoria com carimbo de tempo, versão e snapshot das preferências.
|
|
2420
|
+
* @category Utils
|
|
2421
|
+
* @since 0.7.0
|
|
2422
|
+
*
|
|
2423
|
+
* @param state Estado atual de consentimento.
|
|
2424
|
+
* @param params.storageKey Chave de armazenamento (cookie/localStorage) aplicada.
|
|
2425
|
+
* @param params.action Ação que disparou o registro.
|
|
2426
|
+
* @param params.consentVersion Versão lógica do consentimento (ex.: bump de política/termo).
|
|
2427
|
+
* @param params.origin Origem explícita da decisão (opcional).
|
|
2428
|
+
*/
|
|
2429
|
+
declare function createConsentAuditEntry(state: ConsentState, params: {
|
|
2430
|
+
storageKey: string;
|
|
2431
|
+
action: ConsentAuditAction;
|
|
2432
|
+
consentVersion?: string | null;
|
|
2433
|
+
origin?: ConsentEventOrigin;
|
|
2434
|
+
}): ConsentAuditEntry;
|
|
2345
2435
|
|
|
2346
2436
|
/** @module src/utils/scriptLoader */
|
|
2347
2437
|
/**
|
|
@@ -2352,6 +2442,18 @@ declare function buildConsentStorageKey(options?: {
|
|
|
2352
2442
|
* Fornece funções para carregar scripts de terceiros de forma condicional ao consentimento LGPD,
|
|
2353
2443
|
* garantindo compatibilidade SSR e verificações de permissões por categoria.
|
|
2354
2444
|
*/
|
|
2445
|
+
|
|
2446
|
+
type ConsentSnapshot = {
|
|
2447
|
+
consented: boolean;
|
|
2448
|
+
preferences: ConsentPreferences;
|
|
2449
|
+
isModalOpen?: boolean;
|
|
2450
|
+
};
|
|
2451
|
+
interface LoadScriptOptions {
|
|
2452
|
+
consentSnapshot?: ConsentSnapshot;
|
|
2453
|
+
cookieName?: string;
|
|
2454
|
+
pollIntervalMs?: number;
|
|
2455
|
+
skipConsentCheck?: boolean;
|
|
2456
|
+
}
|
|
2355
2457
|
/**
|
|
2356
2458
|
* @function
|
|
2357
2459
|
* @category Utils
|
|
@@ -2370,6 +2472,8 @@ declare function buildConsentStorageKey(options?: {
|
|
|
2370
2472
|
* @param {string} src A URL do script externo a ser carregado.
|
|
2371
2473
|
* @param {string | null} [category=null] A categoria de consentimento exigida para o script. Suporta tanto categorias predefinidas quanto customizadas. Se o consentimento para esta categoria não for dado, o script não será carregado.
|
|
2372
2474
|
* @param {Record<string, string>} [attrs={}] Atributos adicionais a serem aplicados ao elemento `<script>` (ex: `{ async: 'true' }`).
|
|
2475
|
+
* @param {string | undefined} [nonce] Nonce CSP opcional aplicado ao script.
|
|
2476
|
+
* @param {LoadScriptOptions} [options] Configurações avançadas (consentSnapshot, cookieName, pollIntervalMs, skipConsentCheck).
|
|
2373
2477
|
* @returns {Promise<void>} Uma Promise que resolve quando o script é carregado com sucesso, ou rejeita se o consentimento não for dado ou ocorrer um erro de carregamento.
|
|
2374
2478
|
* @example
|
|
2375
2479
|
* ```ts
|
|
@@ -2379,7 +2483,7 @@ declare function buildConsentStorageKey(options?: {
|
|
|
2379
2483
|
* .catch(error => console.error('Erro ao carregar script:', error))
|
|
2380
2484
|
* ```
|
|
2381
2485
|
*/
|
|
2382
|
-
declare function loadScript(id: string, src: string, category?: string | null, attrs?: Record<string, string
|
|
2486
|
+
declare function loadScript(id: string, src: string, category?: string | null, attrs?: Record<string, string>, nonce?: string, options?: LoadScriptOptions): Promise<void>;
|
|
2383
2487
|
|
|
2384
2488
|
/**
|
|
2385
2489
|
* Utilitários para descoberta e categorização de cookies em tempo de execução (experimental).
|
|
@@ -2437,6 +2541,7 @@ declare function categorizeDiscoveredCookies(discovered?: CookieDescriptor[], re
|
|
|
2437
2541
|
* - URLs possuem valores default atualizados e podem ser sobrescritos via `scriptUrl`
|
|
2438
2542
|
* - SSR-safe: toda execução que toca `window` é protegida
|
|
2439
2543
|
*/
|
|
2544
|
+
|
|
2440
2545
|
/**
|
|
2441
2546
|
* Integração de script de terceiros condicionada a consentimento.
|
|
2442
2547
|
*
|
|
@@ -2481,6 +2586,17 @@ interface ScriptIntegration {
|
|
|
2481
2586
|
init?: () => void;
|
|
2482
2587
|
/** Atributos HTML adicionais para a tag script */
|
|
2483
2588
|
attrs?: Record<string, string>;
|
|
2589
|
+
/** Nonce CSP opcional aplicado à tag script */
|
|
2590
|
+
nonce?: string;
|
|
2591
|
+
/** Prioridade para ordenação na fila do loader (maior = executa primeiro dentro da categoria) */
|
|
2592
|
+
priority?: number;
|
|
2593
|
+
/** Rotina opcional executada antes do carregamento principal (ex.: bootstrap de Consent Mode) */
|
|
2594
|
+
bootstrap?: () => void | Promise<void>;
|
|
2595
|
+
/** Callback disparado quando o consentimento é atualizado */
|
|
2596
|
+
onConsentUpdate?: (consent: {
|
|
2597
|
+
consented: boolean;
|
|
2598
|
+
preferences: ConsentPreferences;
|
|
2599
|
+
}) => void;
|
|
2484
2600
|
/** Lista de cookies que o script pode definir */
|
|
2485
2601
|
cookies?: string[];
|
|
2486
2602
|
/** Informações detalhadas dos cookies (nome, finalidade, duração, fornecedor) */
|
|
@@ -3124,11 +3240,39 @@ declare function suggestCategoryForScript(name: string): string[];
|
|
|
3124
3240
|
* Facilita integração com ferramentas como Google Analytics, Tag Manager, etc.
|
|
3125
3241
|
*/
|
|
3126
3242
|
|
|
3243
|
+
interface RegisteredScript {
|
|
3244
|
+
id: string;
|
|
3245
|
+
category: string;
|
|
3246
|
+
execute: () => void | Promise<void>;
|
|
3247
|
+
priority?: number;
|
|
3248
|
+
allowReload?: boolean;
|
|
3249
|
+
onConsentUpdate?: (consent: {
|
|
3250
|
+
consented: boolean;
|
|
3251
|
+
preferences: ConsentPreferences;
|
|
3252
|
+
}) => void;
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* Registra um script (inline ou externo) na fila controlada por consentimento.
|
|
3256
|
+
*
|
|
3257
|
+
* @remarks
|
|
3258
|
+
* - Scripts `necessary` rodam imediatamente; demais aguardam consentimento da categoria.
|
|
3259
|
+
* - Fluxo de estados: `pending` → `running` → `executed` (respeitando `allowReload` e `onConsentUpdate`).
|
|
3260
|
+
* - A fila é ordenada por categoria, `priority` (maior primeiro) e ordem de registro.
|
|
3261
|
+
* - `allowReload` permite reexecutar scripts quando o usuário muda preferências.
|
|
3262
|
+
* - Use `onConsentUpdate` para reenviar sinais (ex.: Consent Mode) após novas decisões.
|
|
3263
|
+
* - Sempre chame o cleanup retornado em efeitos React para evitar múltiplos registros do mesmo `id`.
|
|
3264
|
+
*
|
|
3265
|
+
* @param def Definição do script a ser registrado.
|
|
3266
|
+
* @returns Função de cleanup para remover o script da fila.
|
|
3267
|
+
*/
|
|
3268
|
+
declare function registerScript(def: RegisteredScript): () => void;
|
|
3127
3269
|
interface ConsentScriptLoaderProps {
|
|
3128
3270
|
/** Lista de integrações de scripts para carregar baseado no consentimento */
|
|
3129
3271
|
integrations: ScriptIntegration[];
|
|
3130
3272
|
/** Se true, força recarregamento se consentimento mudar */
|
|
3131
3273
|
reloadOnChange?: boolean;
|
|
3274
|
+
/** Nonce CSP aplicado às tags <script> geradas automaticamente (sobrescrevível por integração). */
|
|
3275
|
+
nonce?: string;
|
|
3132
3276
|
}
|
|
3133
3277
|
/**
|
|
3134
3278
|
* @component
|
|
@@ -3151,7 +3295,7 @@ interface ConsentScriptLoaderProps {
|
|
|
3151
3295
|
* <ConsentScriptLoader integrations={integrations} />
|
|
3152
3296
|
* ```
|
|
3153
3297
|
*/
|
|
3154
|
-
declare function ConsentScriptLoader({ integrations, reloadOnChange, }: Readonly<ConsentScriptLoaderProps>): null;
|
|
3298
|
+
declare function ConsentScriptLoader({ integrations, reloadOnChange, nonce, }: Readonly<ConsentScriptLoaderProps>): null;
|
|
3155
3299
|
/**
|
|
3156
3300
|
* @hook
|
|
3157
3301
|
* @category Hooks
|
|
@@ -3179,7 +3323,7 @@ declare function ConsentScriptLoader({ integrations, reloadOnChange, }: Readonly
|
|
|
3179
3323
|
* }, [loadScript]);
|
|
3180
3324
|
* ```
|
|
3181
3325
|
*/
|
|
3182
|
-
declare function useConsentScriptLoader(): (integration: ScriptIntegration) => Promise<boolean>;
|
|
3326
|
+
declare function useConsentScriptLoader(): (integration: ScriptIntegration, nonce?: string) => Promise<boolean>;
|
|
3183
3327
|
|
|
3184
3328
|
/**
|
|
3185
3329
|
* @file autoConfigureCategories.ts
|
|
@@ -3287,6 +3431,37 @@ declare function extractCategoriesFromIntegrations(integrations: ScriptIntegrati
|
|
|
3287
3431
|
*/
|
|
3288
3432
|
declare function validateNecessaryClassification(integrations: ScriptIntegration[], enabledCategories: Category[]): string[];
|
|
3289
3433
|
|
|
3434
|
+
/**
|
|
3435
|
+
* Presets de categorias conforme usos típicos da LGPD/ANPD.
|
|
3436
|
+
*
|
|
3437
|
+
* @category Utils
|
|
3438
|
+
* @since 0.6.4
|
|
3439
|
+
*/
|
|
3440
|
+
declare const ANPD_CATEGORY_PRESETS: Record<Category, CategoryDefinition>;
|
|
3441
|
+
type AnpdPresetCategory = keyof typeof ANPD_CATEGORY_PRESETS;
|
|
3442
|
+
interface CreateAnpdCategoriesOptions {
|
|
3443
|
+
/**
|
|
3444
|
+
* Lista de categorias que devem ser habilitadas (além de necessary que é sempre inclusa).
|
|
3445
|
+
* @default ['analytics', 'functional', 'marketing']
|
|
3446
|
+
*/
|
|
3447
|
+
include?: AnpdPresetCategory[];
|
|
3448
|
+
/**
|
|
3449
|
+
* Overrides de descrições por categoria.
|
|
3450
|
+
*/
|
|
3451
|
+
descriptions?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3452
|
+
/**
|
|
3453
|
+
* Overrides de nomes por categoria.
|
|
3454
|
+
*/
|
|
3455
|
+
names?: Partial<Record<AnpdPresetCategory, string>>;
|
|
3456
|
+
}
|
|
3457
|
+
/**
|
|
3458
|
+
* Gera um `ProjectCategoriesConfig` com presets LGPD/ANPD tipados.
|
|
3459
|
+
*
|
|
3460
|
+
* @category Utils
|
|
3461
|
+
* @since 0.6.4
|
|
3462
|
+
*/
|
|
3463
|
+
declare function createAnpdCategoriesConfig(options?: CreateAnpdCategoriesOptions): ProjectCategoriesConfig;
|
|
3464
|
+
|
|
3290
3465
|
/**
|
|
3291
3466
|
* @fileoverview
|
|
3292
3467
|
* Sistema de textos expandido com suporte avançado a internacionalização,
|
|
@@ -3322,7 +3497,7 @@ type LanguageTexts = Partial<Omit<ConsentTexts, 'i18n' | 'variants' | 'contexts'
|
|
|
3322
3497
|
*
|
|
3323
3498
|
* Interface expandida que permite personalização granular de todas as mensagens da biblioteca.
|
|
3324
3499
|
* Suporta múltiplos idiomas, contextos específicos (e-commerce, SaaS, governo), variações
|
|
3325
|
-
* de tom, e compliance completo com LGPD
|
|
3500
|
+
* de tom, e compliance completo com LGPD.
|
|
3326
3501
|
*
|
|
3327
3502
|
* @category Types
|
|
3328
3503
|
* @since 0.4.1
|
|
@@ -3730,6 +3905,98 @@ interface PeerDepsCheckResult {
|
|
|
3730
3905
|
/** Lista de erros críticos detectados */
|
|
3731
3906
|
errors: string[];
|
|
3732
3907
|
}
|
|
3908
|
+
/**
|
|
3909
|
+
* Idiomas suportados para mensagens de diagnóstico de peer dependencies.
|
|
3910
|
+
*
|
|
3911
|
+
* @category Utils
|
|
3912
|
+
* @since 0.7.1
|
|
3913
|
+
*/
|
|
3914
|
+
type PeerDepsLocale = 'pt-BR' | 'en';
|
|
3915
|
+
/**
|
|
3916
|
+
* Estrutura de mensagens de erro e aviso para diagnóstico de peer dependencies.
|
|
3917
|
+
*
|
|
3918
|
+
* @category Utils
|
|
3919
|
+
* @since 0.7.1
|
|
3920
|
+
*/
|
|
3921
|
+
interface PeerDepsMessages {
|
|
3922
|
+
MULTIPLE_REACT_INSTANCES: string;
|
|
3923
|
+
UNSUPPORTED_REACT_VERSION: (version: string) => string;
|
|
3924
|
+
UNSUPPORTED_MUI_VERSION: (version: string) => string;
|
|
3925
|
+
MUI_OUT_OF_RANGE: (version: string) => string;
|
|
3926
|
+
}
|
|
3927
|
+
/**
|
|
3928
|
+
* Define o idioma para mensagens de diagnóstico de peer dependencies.
|
|
3929
|
+
*
|
|
3930
|
+
* @category Utils
|
|
3931
|
+
* @since 0.7.1
|
|
3932
|
+
*
|
|
3933
|
+
* @param locale - Idioma desejado ('pt-BR' ou 'en')
|
|
3934
|
+
*
|
|
3935
|
+
* @example
|
|
3936
|
+
* ```typescript
|
|
3937
|
+
* import { setPeerDepsLocale } from '@react-lgpd-consent/core'
|
|
3938
|
+
*
|
|
3939
|
+
* // Configurar mensagens em inglês
|
|
3940
|
+
* setPeerDepsLocale('en')
|
|
3941
|
+
* ```
|
|
3942
|
+
*/
|
|
3943
|
+
declare function setPeerDepsLocale(locale: PeerDepsLocale): void;
|
|
3944
|
+
/**
|
|
3945
|
+
* Obtém o idioma atual configurado para mensagens de diagnóstico.
|
|
3946
|
+
*
|
|
3947
|
+
* @category Utils
|
|
3948
|
+
* @since 0.7.1
|
|
3949
|
+
*
|
|
3950
|
+
* @returns O idioma atual
|
|
3951
|
+
*
|
|
3952
|
+
* @example
|
|
3953
|
+
* ```typescript
|
|
3954
|
+
* import { getPeerDepsLocale } from '@react-lgpd-consent/core'
|
|
3955
|
+
*
|
|
3956
|
+
* const locale = getPeerDepsLocale() // 'pt-BR' ou 'en'
|
|
3957
|
+
* ```
|
|
3958
|
+
*/
|
|
3959
|
+
declare function getPeerDepsLocale(): PeerDepsLocale;
|
|
3960
|
+
/**
|
|
3961
|
+
* Permite sobrescrever mensagens de diagnóstico com versões customizadas.
|
|
3962
|
+
* Útil para traduzir para outros idiomas ou personalizar o texto.
|
|
3963
|
+
*
|
|
3964
|
+
* @category Utils
|
|
3965
|
+
* @since 0.7.1
|
|
3966
|
+
*
|
|
3967
|
+
* @param messages - Objeto parcial com mensagens a sobrescrever
|
|
3968
|
+
*
|
|
3969
|
+
* @remarks
|
|
3970
|
+
* As mensagens customizadas têm prioridade sobre as mensagens padrão.
|
|
3971
|
+
* Pode fornecer apenas as mensagens que deseja sobrescrever.
|
|
3972
|
+
*
|
|
3973
|
+
* @example
|
|
3974
|
+
* ```typescript
|
|
3975
|
+
* import { setPeerDepsMessages } from '@react-lgpd-consent/core'
|
|
3976
|
+
*
|
|
3977
|
+
* // Customizar mensagens em espanhol
|
|
3978
|
+
* setPeerDepsMessages({
|
|
3979
|
+
* MULTIPLE_REACT_INSTANCES: `ERROR: Múltiples instancias de React detectadas...`,
|
|
3980
|
+
* UNSUPPORTED_REACT_VERSION: (v) => `Versión ${v} no soportada...`,
|
|
3981
|
+
* })
|
|
3982
|
+
* ```
|
|
3983
|
+
*/
|
|
3984
|
+
declare function setPeerDepsMessages(messages: Partial<PeerDepsMessages>): void;
|
|
3985
|
+
/**
|
|
3986
|
+
* Restaura as mensagens padrão, removendo qualquer customização.
|
|
3987
|
+
*
|
|
3988
|
+
* @category Utils
|
|
3989
|
+
* @since 0.7.1
|
|
3990
|
+
*
|
|
3991
|
+
* @example
|
|
3992
|
+
* ```typescript
|
|
3993
|
+
* import { resetPeerDepsMessages } from '@react-lgpd-consent/core'
|
|
3994
|
+
*
|
|
3995
|
+
* // Voltar para mensagens padrão
|
|
3996
|
+
* resetPeerDepsMessages()
|
|
3997
|
+
* ```
|
|
3998
|
+
*/
|
|
3999
|
+
declare function resetPeerDepsMessages(): void;
|
|
3733
4000
|
/**
|
|
3734
4001
|
* Verifica compatibilidade de peer dependencies (React e MUI).
|
|
3735
4002
|
*
|
|
@@ -4032,4 +4299,4 @@ declare function useDataLayerEvents(): {
|
|
|
4032
4299
|
pushUpdated: typeof pushConsentUpdatedEvent;
|
|
4033
4300
|
};
|
|
4034
4301
|
|
|
4035
|
-
export { type AdvancedConsentTexts, COMMON_INTEGRATIONS, type CategoriesContextValue, type Category, type CategoryAutoConfigResult, type CategoryDefinition, type ClarityConfig, type ConsentContextValue, type ConsentCookieData, type ConsentCookieOptions, type ConsentEvent, type ConsentEventOrigin, ConsentGate, type ConsentInitializedEvent, type ConsentPreferences, ConsentProvider, type ConsentProviderProps, ConsentScriptLoader, type ConsentScriptLoaderProps, type ConsentState, type ConsentStorageConfig, type ConsentTexts, type ConsentUpdatedEvent, type ConsentVersionChangeContext, type CookieDescriptor, type CorporateConfig, type CustomCookieBannerProps, type CustomFloatingPreferencesButtonProps, type CustomPreferencesModalProps, DEFAULT_PROJECT_CATEGORIES, DesignProvider, type DesignTokens, type DeveloperGuidance, type ECommerceConfig, EXPANDED_DEFAULT_TEXTS, type FacebookPixelConfig, GUIDANCE_PRESETS, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, type GuidanceConfig, type GuidanceMessage, type GuidanceSeverity, type HotjarConfig, INTEGRATION_TEMPLATES, type IntercomConfig, LogLevel, type MixpanelConfig, type PeerDepsCheckResult, type ProjectCategoriesConfig, type SaaSConfig, type ScriptIntegration, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, buildConsentStorageKey, categorizeDiscoveredCookies, checkPeerDeps, createClarityIntegration, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, ensureNecessaryAlwaysOn, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|
|
4302
|
+
export { ANPD_CATEGORY_PRESETS, type AdvancedConsentTexts, type AnpdPresetCategory, COMMON_INTEGRATIONS, type CategoriesContextValue, type Category, type CategoryAutoConfigResult, type CategoryDefinition, type ClarityConfig, type ConsentAuditAction, type ConsentAuditEntry, type ConsentContextValue, type ConsentCookieData, type ConsentCookieOptions, type ConsentEvent, type ConsentEventOrigin, ConsentGate, type ConsentInitializedEvent, type ConsentPreferences, ConsentProvider, type ConsentProviderProps, ConsentScriptLoader, type ConsentScriptLoaderProps, type ConsentState, type ConsentStorageConfig, type ConsentTexts, type ConsentUpdatedEvent, type ConsentVersionChangeContext, type CookieDescriptor, type CorporateConfig, type CreateAnpdCategoriesOptions, type CustomCookieBannerProps, type CustomFloatingPreferencesButtonProps, type CustomPreferencesModalProps, DEFAULT_PROJECT_CATEGORIES, DesignProvider, type DesignTokens, type DeveloperGuidance, type ECommerceConfig, EXPANDED_DEFAULT_TEXTS, type FacebookPixelConfig, GUIDANCE_PRESETS, type GoogleAnalyticsConfig, type GoogleTagManagerConfig, type GuidanceConfig, type GuidanceMessage, type GuidanceSeverity, type HotjarConfig, INTEGRATION_TEMPLATES, type IntercomConfig, LogLevel, type MixpanelConfig, type PeerDepsCheckResult, type PeerDepsLocale, type PeerDepsMessages, type ProjectCategoriesConfig, type RegisteredScript, type SaaSConfig, type ScriptIntegration, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, buildConsentStorageKey, categorizeDiscoveredCookies, checkPeerDeps, createAnpdCategoriesConfig, createClarityIntegration, createConsentAuditEntry, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, ensureNecessaryAlwaysOn, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, getPeerDepsLocale, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, registerScript, resetPeerDepsMessages, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, setPeerDepsLocale, setPeerDepsMessages, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|