@react-lgpd-consent/core 0.5.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/index.cjs +342 -34
- package/dist/index.d.cts +196 -6
- package/dist/index.d.ts +196 -6
- package/dist/index.js +339 -35
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -656,6 +656,58 @@ interface ConsentCookieOptions {
|
|
|
656
656
|
secure: boolean;
|
|
657
657
|
/** Caminho do cookie. Padrão: '/' */
|
|
658
658
|
path: string;
|
|
659
|
+
/**
|
|
660
|
+
* Domínio do cookie (ex.: `.example.com` para compartilhar entre subdomínios).
|
|
661
|
+
* Se não definido, o navegador usa o domínio atual.
|
|
662
|
+
* @since 0.5.2
|
|
663
|
+
*/
|
|
664
|
+
domain?: string;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Configuração de versionamento da chave de storage utilizada pelo consentimento.
|
|
668
|
+
* @category Types
|
|
669
|
+
* @since 0.5.2
|
|
670
|
+
* @public
|
|
671
|
+
*
|
|
672
|
+
* @remarks
|
|
673
|
+
* Combine `namespace` e `version` para gerar um nome de cookie único por aplicação
|
|
674
|
+
* e ciclo de consentimento. Ao alterar a `version`, o consentimento anterior é
|
|
675
|
+
* automaticamente considerado inválido, garantindo novo fluxo de consentimento.
|
|
676
|
+
*/
|
|
677
|
+
interface ConsentStorageConfig {
|
|
678
|
+
/**
|
|
679
|
+
* Namespace lógico do consentimento (ex.: nome do produto ou domínio raiz).
|
|
680
|
+
* @defaultValue `'lgpd-consent'`
|
|
681
|
+
*/
|
|
682
|
+
namespace?: string;
|
|
683
|
+
/**
|
|
684
|
+
* Versão do consentimento atual. Incrementar ou alterar o valor força re-consentimento.
|
|
685
|
+
* Use valores sem espaços (ex.: `'2025.10'`, `'marketing-v2'`).
|
|
686
|
+
* @defaultValue `'1'`
|
|
687
|
+
*/
|
|
688
|
+
version?: string;
|
|
689
|
+
/**
|
|
690
|
+
* Domínio compartilhado do cookie (ex.: `.example.com` para múltiplos subdomínios).
|
|
691
|
+
* Se definido, sobrescreve `cookie.domain`.
|
|
692
|
+
*/
|
|
693
|
+
domain?: string;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Payload entregue ao callback `onConsentVersionChange`.
|
|
697
|
+
* @category Types
|
|
698
|
+
* @since 0.5.2
|
|
699
|
+
* @public
|
|
700
|
+
*/
|
|
701
|
+
interface ConsentVersionChangeContext {
|
|
702
|
+
/** Nome da chave anterior utilizada pelo armazenamento de consentimento (cookie). */
|
|
703
|
+
previousKey: string | null;
|
|
704
|
+
/** Nova chave aplicada após a mudança de namespace/versão. */
|
|
705
|
+
nextKey: string;
|
|
706
|
+
/**
|
|
707
|
+
* Helper para gatilhar o reset imediato do estado de consentimento.
|
|
708
|
+
* Útil para cenários onde o consumidor controla estado adicional (ex.: localStorage).
|
|
709
|
+
*/
|
|
710
|
+
resetConsent: () => void;
|
|
659
711
|
}
|
|
660
712
|
/**
|
|
661
713
|
* Tipo alias para valores de espaçamento que suportam eixos x/y.
|
|
@@ -732,7 +784,8 @@ type BackdropConfig = boolean | string | {
|
|
|
732
784
|
*
|
|
733
785
|
* @category Types
|
|
734
786
|
* @since 0.1.3
|
|
735
|
-
* @
|
|
787
|
+
* @remarks
|
|
788
|
+
* **Histórico**: v0.4.1 - Expandido substancialmente com novos tokens
|
|
736
789
|
* @public
|
|
737
790
|
*
|
|
738
791
|
* @example Configuração básica
|
|
@@ -1317,6 +1370,32 @@ interface ConsentProviderProps {
|
|
|
1317
1370
|
* ```
|
|
1318
1371
|
*/
|
|
1319
1372
|
guidanceConfig?: GuidanceConfig;
|
|
1373
|
+
/**
|
|
1374
|
+
* Configuração da chave de armazenamento (cookie/localStorage) do consentimento.
|
|
1375
|
+
* Permite definir namespace, versão e domínio compartilhado.
|
|
1376
|
+
* @since 0.5.2
|
|
1377
|
+
*/
|
|
1378
|
+
storage?: ConsentStorageConfig;
|
|
1379
|
+
/**
|
|
1380
|
+
* Callback disparado quando a chave de armazenamento muda (ex.: bump de versão).
|
|
1381
|
+
* Recebe a chave anterior, a nova chave e um helper `resetConsent`.
|
|
1382
|
+
* @since 0.5.2
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```tsx
|
|
1386
|
+
* <ConsentProvider
|
|
1387
|
+
* storage={{ namespace: 'portal.gov.br', version: '2025-Q4' }}
|
|
1388
|
+
* onConsentVersionChange={({ previousKey, nextKey, resetConsent }) => {
|
|
1389
|
+
* console.info('[consent] versão alterada', { previousKey, nextKey })
|
|
1390
|
+
* analytics.clearUserStorage()
|
|
1391
|
+
* resetConsent()
|
|
1392
|
+
* }}
|
|
1393
|
+
* >
|
|
1394
|
+
* <App />
|
|
1395
|
+
* </ConsentProvider>
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
onConsentVersionChange?: (context: ConsentVersionChangeContext) => void;
|
|
1320
1399
|
/** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
|
|
1321
1400
|
children: React.ReactNode;
|
|
1322
1401
|
}
|
|
@@ -1397,8 +1476,8 @@ interface ConsentContextValue {
|
|
|
1397
1476
|
* @param cat - ID da categoria (predefinida ou customizada)
|
|
1398
1477
|
* @param value - Valor do consentimento para a categoria
|
|
1399
1478
|
*
|
|
1400
|
-
* @
|
|
1401
|
-
* **v0.4.1**: Parâmetro `cat` mudou de `Category` para `string` para suportar
|
|
1479
|
+
* @remarks
|
|
1480
|
+
* **Breaking Change (v0.4.1)**: Parâmetro `cat` mudou de `Category` para `string` para suportar
|
|
1402
1481
|
* categorias customizadas. O uso com strings literais continua funcionando.
|
|
1403
1482
|
*
|
|
1404
1483
|
* @example
|
|
@@ -1577,7 +1656,7 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1577
1656
|
* </ConsentProvider>
|
|
1578
1657
|
* ```
|
|
1579
1658
|
*/
|
|
1580
|
-
declare function ConsentProvider({ initialState, categories, texts: textsProp, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding: _hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
1581
1660
|
declare const defaultTexts: ConsentTexts;
|
|
1582
1661
|
|
|
1583
1662
|
/**
|
|
@@ -2174,6 +2253,7 @@ declare function useCategoryStatus(categoryId: string): {
|
|
|
2174
2253
|
* }
|
|
2175
2254
|
* ```
|
|
2176
2255
|
*
|
|
2256
|
+
*
|
|
2177
2257
|
* @component
|
|
2178
2258
|
* @category Context
|
|
2179
2259
|
* @since 0.1.0
|
|
@@ -2245,6 +2325,24 @@ declare function ConsentGate(props: Readonly<{
|
|
|
2245
2325
|
children: React$1.ReactNode;
|
|
2246
2326
|
}>): react_jsx_runtime.JSX.Element | null;
|
|
2247
2327
|
|
|
2328
|
+
/**
|
|
2329
|
+
* @fileoverview
|
|
2330
|
+
* Utilitários para manipulação do cookie de consentimento.
|
|
2331
|
+
* A estrutura de dados do cookie é um JSON simples para atender aos requisitos da LGPD,
|
|
2332
|
+
* e não implementa o padrão IAB TCF, que é mais complexo.
|
|
2333
|
+
* Veja `src/types/types.ts` para a definição da estrutura `ConsentCookieData`.
|
|
2334
|
+
*/
|
|
2335
|
+
|
|
2336
|
+
/**
|
|
2337
|
+
* Gera o nome da chave de armazenamento (cookie/localStorage) combinando namespace e versão.
|
|
2338
|
+
* @param options.namespace Namespace lógico do consentimento (ex.: domínio raiz).
|
|
2339
|
+
* @param options.version Versão atual do consentimento (ex.: lote de políticas).
|
|
2340
|
+
*/
|
|
2341
|
+
declare function buildConsentStorageKey(options?: {
|
|
2342
|
+
namespace?: string | null;
|
|
2343
|
+
version?: string | null;
|
|
2344
|
+
}): string;
|
|
2345
|
+
|
|
2248
2346
|
/** @module src/utils/scriptLoader */
|
|
2249
2347
|
/**
|
|
2250
2348
|
* @category Utils
|
|
@@ -2265,6 +2363,9 @@ declare function ConsentGate(props: Readonly<{
|
|
|
2265
2363
|
* após o consentimento do usuário. Ela garante que o script só seja inserido na página
|
|
2266
2364
|
* se o consentimento for dado e o contexto estiver disponível.
|
|
2267
2365
|
*
|
|
2366
|
+
* **React 19 StrictMode**: A função é idempotente e mantém um registro global de scripts
|
|
2367
|
+
* em carregamento para evitar duplicações durante double-invoking de efeitos em desenvolvimento.
|
|
2368
|
+
*
|
|
2268
2369
|
* @param {string} id Um identificador único para o elemento `<script>` a ser criado.
|
|
2269
2370
|
* @param {string} src A URL do script externo a ser carregado.
|
|
2270
2371
|
* @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.
|
|
@@ -3225,7 +3326,8 @@ type LanguageTexts = Partial<Omit<ConsentTexts, 'i18n' | 'variants' | 'contexts'
|
|
|
3225
3326
|
*
|
|
3226
3327
|
* @category Types
|
|
3227
3328
|
* @since 0.4.1
|
|
3228
|
-
* @
|
|
3329
|
+
* @remarks
|
|
3330
|
+
* **Histórico**: v0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
3229
3331
|
*
|
|
3230
3332
|
* @example Configuração multilíngue
|
|
3231
3333
|
* ```typescript
|
|
@@ -3606,6 +3708,88 @@ declare const logger: ConsentLogger;
|
|
|
3606
3708
|
*/
|
|
3607
3709
|
declare function setDebugLogging(enabled: boolean, level?: LogLevel): void;
|
|
3608
3710
|
|
|
3711
|
+
/**
|
|
3712
|
+
* @fileoverview
|
|
3713
|
+
* Sistema de diagnóstico de peer dependencies e compatibilidade de versões.
|
|
3714
|
+
* Detecta problemas comuns como múltiplas instâncias de React e versões de MUI fora do range suportado.
|
|
3715
|
+
*
|
|
3716
|
+
* @author Luciano Édipo
|
|
3717
|
+
* @since 0.5.4
|
|
3718
|
+
*/
|
|
3719
|
+
/**
|
|
3720
|
+
* Resultado da verificação de peer dependencies.
|
|
3721
|
+
*
|
|
3722
|
+
* @category Utils
|
|
3723
|
+
* @since 0.5.4
|
|
3724
|
+
*/
|
|
3725
|
+
interface PeerDepsCheckResult {
|
|
3726
|
+
/** Se todas as verificações passaram sem problemas críticos */
|
|
3727
|
+
ok: boolean;
|
|
3728
|
+
/** Lista de avisos detectados */
|
|
3729
|
+
warnings: string[];
|
|
3730
|
+
/** Lista de erros críticos detectados */
|
|
3731
|
+
errors: string[];
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Verifica compatibilidade de peer dependencies (React e MUI).
|
|
3735
|
+
*
|
|
3736
|
+
* @category Utils
|
|
3737
|
+
* @since 0.5.4
|
|
3738
|
+
*
|
|
3739
|
+
* @remarks
|
|
3740
|
+
* Esta função executa verificações em ambiente de desenvolvimento para detectar:
|
|
3741
|
+
* - Múltiplas instâncias de React (causa "Invalid hook call")
|
|
3742
|
+
* - Versões de React fora do range suportado (18-19)
|
|
3743
|
+
* - Versões de MUI fora do range suportado (5-7)
|
|
3744
|
+
*
|
|
3745
|
+
* As mensagens incluem:
|
|
3746
|
+
* - Descrição clara do problema
|
|
3747
|
+
* - Causa raiz provável
|
|
3748
|
+
* - Passos objetivos para resolver
|
|
3749
|
+
* - Links para documentação
|
|
3750
|
+
*
|
|
3751
|
+
* @param options - Opções de configuração
|
|
3752
|
+
* @param options.skipInProduction - Se true, pula verificação em produção (padrão: true)
|
|
3753
|
+
* @param options.logWarnings - Se true, loga avisos no console (padrão: true)
|
|
3754
|
+
*
|
|
3755
|
+
* @returns Resultado da verificação com lista de avisos e erros
|
|
3756
|
+
*
|
|
3757
|
+
* @example
|
|
3758
|
+
* ```typescript
|
|
3759
|
+
* import { checkPeerDeps } from '@react-lgpd-consent/core'
|
|
3760
|
+
*
|
|
3761
|
+
* // Verificar compatibilidade em desenvolvimento
|
|
3762
|
+
* const result = checkPeerDeps()
|
|
3763
|
+
* if (!result.ok) {
|
|
3764
|
+
* console.log('Problemas detectados:', result.errors)
|
|
3765
|
+
* }
|
|
3766
|
+
* ```
|
|
3767
|
+
*/
|
|
3768
|
+
declare function checkPeerDeps(options?: {
|
|
3769
|
+
skipInProduction?: boolean;
|
|
3770
|
+
logWarnings?: boolean;
|
|
3771
|
+
}): PeerDepsCheckResult;
|
|
3772
|
+
/**
|
|
3773
|
+
* Executa verificação de peer dependencies e loga resultados automaticamente.
|
|
3774
|
+
* Versão conveniente de `checkPeerDeps` que sempre loga no console.
|
|
3775
|
+
*
|
|
3776
|
+
* @category Utils
|
|
3777
|
+
* @since 0.5.4
|
|
3778
|
+
*
|
|
3779
|
+
* @remarks
|
|
3780
|
+
* Esta função é chamada automaticamente pelo ConsentProvider em modo development.
|
|
3781
|
+
* Use `checkPeerDeps()` se precisar do resultado programaticamente sem logging.
|
|
3782
|
+
*
|
|
3783
|
+
* @example
|
|
3784
|
+
* ```typescript
|
|
3785
|
+
* import { runPeerDepsCheck } from '@react-lgpd-consent/core'
|
|
3786
|
+
*
|
|
3787
|
+
* // Executar verificação manual (já é automática no Provider)
|
|
3788
|
+
* runPeerDepsCheck()
|
|
3789
|
+
* ```
|
|
3790
|
+
*/
|
|
3791
|
+
declare function runPeerDepsCheck(): void;
|
|
3792
|
+
|
|
3609
3793
|
interface CookieCatalogOverrides {
|
|
3610
3794
|
byCategory?: Record<string, CookieDescriptor[]>;
|
|
3611
3795
|
byIntegration?: Record<string, CookieDescriptor[]>;
|
|
@@ -3666,6 +3850,12 @@ declare function getCookiesInfoForCategory(categoryId: Category, usedIntegration
|
|
|
3666
3850
|
* ```
|
|
3667
3851
|
*/
|
|
3668
3852
|
declare function createProjectPreferences(config?: ProjectCategoriesConfig, defaultValue?: boolean): ConsentPreferences;
|
|
3853
|
+
/**
|
|
3854
|
+
* Garante que a categoria `necessary` permaneça ativa em qualquer estrutura de preferências.
|
|
3855
|
+
* @category Utils
|
|
3856
|
+
* @since 0.5.2
|
|
3857
|
+
*/
|
|
3858
|
+
declare function ensureNecessaryAlwaysOn(preferences: ConsentPreferences): ConsentPreferences;
|
|
3669
3859
|
/**
|
|
3670
3860
|
* Valida um objeto de preferências de consentimento, removendo categorias que não estão permitidas pela configuração do projeto.
|
|
3671
3861
|
* @category Utils
|
|
@@ -3842,4 +4032,4 @@ declare function useDataLayerEvents(): {
|
|
|
3842
4032
|
pushUpdated: typeof pushConsentUpdatedEvent;
|
|
3843
4033
|
};
|
|
3844
4034
|
|
|
3845
|
-
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 ConsentTexts, type ConsentUpdatedEvent, 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 ProjectCategoriesConfig, type SaaSConfig, type ScriptIntegration, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, categorizeDiscoveredCookies, createClarityIntegration, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, resolveTexts, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -656,6 +656,58 @@ interface ConsentCookieOptions {
|
|
|
656
656
|
secure: boolean;
|
|
657
657
|
/** Caminho do cookie. Padrão: '/' */
|
|
658
658
|
path: string;
|
|
659
|
+
/**
|
|
660
|
+
* Domínio do cookie (ex.: `.example.com` para compartilhar entre subdomínios).
|
|
661
|
+
* Se não definido, o navegador usa o domínio atual.
|
|
662
|
+
* @since 0.5.2
|
|
663
|
+
*/
|
|
664
|
+
domain?: string;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Configuração de versionamento da chave de storage utilizada pelo consentimento.
|
|
668
|
+
* @category Types
|
|
669
|
+
* @since 0.5.2
|
|
670
|
+
* @public
|
|
671
|
+
*
|
|
672
|
+
* @remarks
|
|
673
|
+
* Combine `namespace` e `version` para gerar um nome de cookie único por aplicação
|
|
674
|
+
* e ciclo de consentimento. Ao alterar a `version`, o consentimento anterior é
|
|
675
|
+
* automaticamente considerado inválido, garantindo novo fluxo de consentimento.
|
|
676
|
+
*/
|
|
677
|
+
interface ConsentStorageConfig {
|
|
678
|
+
/**
|
|
679
|
+
* Namespace lógico do consentimento (ex.: nome do produto ou domínio raiz).
|
|
680
|
+
* @defaultValue `'lgpd-consent'`
|
|
681
|
+
*/
|
|
682
|
+
namespace?: string;
|
|
683
|
+
/**
|
|
684
|
+
* Versão do consentimento atual. Incrementar ou alterar o valor força re-consentimento.
|
|
685
|
+
* Use valores sem espaços (ex.: `'2025.10'`, `'marketing-v2'`).
|
|
686
|
+
* @defaultValue `'1'`
|
|
687
|
+
*/
|
|
688
|
+
version?: string;
|
|
689
|
+
/**
|
|
690
|
+
* Domínio compartilhado do cookie (ex.: `.example.com` para múltiplos subdomínios).
|
|
691
|
+
* Se definido, sobrescreve `cookie.domain`.
|
|
692
|
+
*/
|
|
693
|
+
domain?: string;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Payload entregue ao callback `onConsentVersionChange`.
|
|
697
|
+
* @category Types
|
|
698
|
+
* @since 0.5.2
|
|
699
|
+
* @public
|
|
700
|
+
*/
|
|
701
|
+
interface ConsentVersionChangeContext {
|
|
702
|
+
/** Nome da chave anterior utilizada pelo armazenamento de consentimento (cookie). */
|
|
703
|
+
previousKey: string | null;
|
|
704
|
+
/** Nova chave aplicada após a mudança de namespace/versão. */
|
|
705
|
+
nextKey: string;
|
|
706
|
+
/**
|
|
707
|
+
* Helper para gatilhar o reset imediato do estado de consentimento.
|
|
708
|
+
* Útil para cenários onde o consumidor controla estado adicional (ex.: localStorage).
|
|
709
|
+
*/
|
|
710
|
+
resetConsent: () => void;
|
|
659
711
|
}
|
|
660
712
|
/**
|
|
661
713
|
* Tipo alias para valores de espaçamento que suportam eixos x/y.
|
|
@@ -732,7 +784,8 @@ type BackdropConfig = boolean | string | {
|
|
|
732
784
|
*
|
|
733
785
|
* @category Types
|
|
734
786
|
* @since 0.1.3
|
|
735
|
-
* @
|
|
787
|
+
* @remarks
|
|
788
|
+
* **Histórico**: v0.4.1 - Expandido substancialmente com novos tokens
|
|
736
789
|
* @public
|
|
737
790
|
*
|
|
738
791
|
* @example Configuração básica
|
|
@@ -1317,6 +1370,32 @@ interface ConsentProviderProps {
|
|
|
1317
1370
|
* ```
|
|
1318
1371
|
*/
|
|
1319
1372
|
guidanceConfig?: GuidanceConfig;
|
|
1373
|
+
/**
|
|
1374
|
+
* Configuração da chave de armazenamento (cookie/localStorage) do consentimento.
|
|
1375
|
+
* Permite definir namespace, versão e domínio compartilhado.
|
|
1376
|
+
* @since 0.5.2
|
|
1377
|
+
*/
|
|
1378
|
+
storage?: ConsentStorageConfig;
|
|
1379
|
+
/**
|
|
1380
|
+
* Callback disparado quando a chave de armazenamento muda (ex.: bump de versão).
|
|
1381
|
+
* Recebe a chave anterior, a nova chave e um helper `resetConsent`.
|
|
1382
|
+
* @since 0.5.2
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```tsx
|
|
1386
|
+
* <ConsentProvider
|
|
1387
|
+
* storage={{ namespace: 'portal.gov.br', version: '2025-Q4' }}
|
|
1388
|
+
* onConsentVersionChange={({ previousKey, nextKey, resetConsent }) => {
|
|
1389
|
+
* console.info('[consent] versão alterada', { previousKey, nextKey })
|
|
1390
|
+
* analytics.clearUserStorage()
|
|
1391
|
+
* resetConsent()
|
|
1392
|
+
* }}
|
|
1393
|
+
* >
|
|
1394
|
+
* <App />
|
|
1395
|
+
* </ConsentProvider>
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
onConsentVersionChange?: (context: ConsentVersionChangeContext) => void;
|
|
1320
1399
|
/** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
|
|
1321
1400
|
children: React.ReactNode;
|
|
1322
1401
|
}
|
|
@@ -1397,8 +1476,8 @@ interface ConsentContextValue {
|
|
|
1397
1476
|
* @param cat - ID da categoria (predefinida ou customizada)
|
|
1398
1477
|
* @param value - Valor do consentimento para a categoria
|
|
1399
1478
|
*
|
|
1400
|
-
* @
|
|
1401
|
-
* **v0.4.1**: Parâmetro `cat` mudou de `Category` para `string` para suportar
|
|
1479
|
+
* @remarks
|
|
1480
|
+
* **Breaking Change (v0.4.1)**: Parâmetro `cat` mudou de `Category` para `string` para suportar
|
|
1402
1481
|
* categorias customizadas. O uso com strings literais continua funcionando.
|
|
1403
1482
|
*
|
|
1404
1483
|
* @example
|
|
@@ -1577,7 +1656,7 @@ type ConsentEvent = ConsentInitializedEvent | ConsentUpdatedEvent;
|
|
|
1577
1656
|
* </ConsentProvider>
|
|
1578
1657
|
* ```
|
|
1579
1658
|
*/
|
|
1580
|
-
declare function ConsentProvider({ initialState, categories, texts: textsProp, designTokens, PreferencesModalComponent, preferencesModalProps, CookieBannerComponent, cookieBannerProps, FloatingPreferencesButtonComponent, floatingPreferencesButtonProps, disableFloatingPreferencesButton, blocking, blockingStrategy, hideBranding: _hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, guidanceConfig, children, disableDiscoveryLog, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
1581
1660
|
declare const defaultTexts: ConsentTexts;
|
|
1582
1661
|
|
|
1583
1662
|
/**
|
|
@@ -2174,6 +2253,7 @@ declare function useCategoryStatus(categoryId: string): {
|
|
|
2174
2253
|
* }
|
|
2175
2254
|
* ```
|
|
2176
2255
|
*
|
|
2256
|
+
*
|
|
2177
2257
|
* @component
|
|
2178
2258
|
* @category Context
|
|
2179
2259
|
* @since 0.1.0
|
|
@@ -2245,6 +2325,24 @@ declare function ConsentGate(props: Readonly<{
|
|
|
2245
2325
|
children: React$1.ReactNode;
|
|
2246
2326
|
}>): react_jsx_runtime.JSX.Element | null;
|
|
2247
2327
|
|
|
2328
|
+
/**
|
|
2329
|
+
* @fileoverview
|
|
2330
|
+
* Utilitários para manipulação do cookie de consentimento.
|
|
2331
|
+
* A estrutura de dados do cookie é um JSON simples para atender aos requisitos da LGPD,
|
|
2332
|
+
* e não implementa o padrão IAB TCF, que é mais complexo.
|
|
2333
|
+
* Veja `src/types/types.ts` para a definição da estrutura `ConsentCookieData`.
|
|
2334
|
+
*/
|
|
2335
|
+
|
|
2336
|
+
/**
|
|
2337
|
+
* Gera o nome da chave de armazenamento (cookie/localStorage) combinando namespace e versão.
|
|
2338
|
+
* @param options.namespace Namespace lógico do consentimento (ex.: domínio raiz).
|
|
2339
|
+
* @param options.version Versão atual do consentimento (ex.: lote de políticas).
|
|
2340
|
+
*/
|
|
2341
|
+
declare function buildConsentStorageKey(options?: {
|
|
2342
|
+
namespace?: string | null;
|
|
2343
|
+
version?: string | null;
|
|
2344
|
+
}): string;
|
|
2345
|
+
|
|
2248
2346
|
/** @module src/utils/scriptLoader */
|
|
2249
2347
|
/**
|
|
2250
2348
|
* @category Utils
|
|
@@ -2265,6 +2363,9 @@ declare function ConsentGate(props: Readonly<{
|
|
|
2265
2363
|
* após o consentimento do usuário. Ela garante que o script só seja inserido na página
|
|
2266
2364
|
* se o consentimento for dado e o contexto estiver disponível.
|
|
2267
2365
|
*
|
|
2366
|
+
* **React 19 StrictMode**: A função é idempotente e mantém um registro global de scripts
|
|
2367
|
+
* em carregamento para evitar duplicações durante double-invoking de efeitos em desenvolvimento.
|
|
2368
|
+
*
|
|
2268
2369
|
* @param {string} id Um identificador único para o elemento `<script>` a ser criado.
|
|
2269
2370
|
* @param {string} src A URL do script externo a ser carregado.
|
|
2270
2371
|
* @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.
|
|
@@ -3225,7 +3326,8 @@ type LanguageTexts = Partial<Omit<ConsentTexts, 'i18n' | 'variants' | 'contexts'
|
|
|
3225
3326
|
*
|
|
3226
3327
|
* @category Types
|
|
3227
3328
|
* @since 0.4.1
|
|
3228
|
-
* @
|
|
3329
|
+
* @remarks
|
|
3330
|
+
* **Histórico**: v0.4.1 - Nova interface com suporte avançado a i18n e contextos
|
|
3229
3331
|
*
|
|
3230
3332
|
* @example Configuração multilíngue
|
|
3231
3333
|
* ```typescript
|
|
@@ -3606,6 +3708,88 @@ declare const logger: ConsentLogger;
|
|
|
3606
3708
|
*/
|
|
3607
3709
|
declare function setDebugLogging(enabled: boolean, level?: LogLevel): void;
|
|
3608
3710
|
|
|
3711
|
+
/**
|
|
3712
|
+
* @fileoverview
|
|
3713
|
+
* Sistema de diagnóstico de peer dependencies e compatibilidade de versões.
|
|
3714
|
+
* Detecta problemas comuns como múltiplas instâncias de React e versões de MUI fora do range suportado.
|
|
3715
|
+
*
|
|
3716
|
+
* @author Luciano Édipo
|
|
3717
|
+
* @since 0.5.4
|
|
3718
|
+
*/
|
|
3719
|
+
/**
|
|
3720
|
+
* Resultado da verificação de peer dependencies.
|
|
3721
|
+
*
|
|
3722
|
+
* @category Utils
|
|
3723
|
+
* @since 0.5.4
|
|
3724
|
+
*/
|
|
3725
|
+
interface PeerDepsCheckResult {
|
|
3726
|
+
/** Se todas as verificações passaram sem problemas críticos */
|
|
3727
|
+
ok: boolean;
|
|
3728
|
+
/** Lista de avisos detectados */
|
|
3729
|
+
warnings: string[];
|
|
3730
|
+
/** Lista de erros críticos detectados */
|
|
3731
|
+
errors: string[];
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Verifica compatibilidade de peer dependencies (React e MUI).
|
|
3735
|
+
*
|
|
3736
|
+
* @category Utils
|
|
3737
|
+
* @since 0.5.4
|
|
3738
|
+
*
|
|
3739
|
+
* @remarks
|
|
3740
|
+
* Esta função executa verificações em ambiente de desenvolvimento para detectar:
|
|
3741
|
+
* - Múltiplas instâncias de React (causa "Invalid hook call")
|
|
3742
|
+
* - Versões de React fora do range suportado (18-19)
|
|
3743
|
+
* - Versões de MUI fora do range suportado (5-7)
|
|
3744
|
+
*
|
|
3745
|
+
* As mensagens incluem:
|
|
3746
|
+
* - Descrição clara do problema
|
|
3747
|
+
* - Causa raiz provável
|
|
3748
|
+
* - Passos objetivos para resolver
|
|
3749
|
+
* - Links para documentação
|
|
3750
|
+
*
|
|
3751
|
+
* @param options - Opções de configuração
|
|
3752
|
+
* @param options.skipInProduction - Se true, pula verificação em produção (padrão: true)
|
|
3753
|
+
* @param options.logWarnings - Se true, loga avisos no console (padrão: true)
|
|
3754
|
+
*
|
|
3755
|
+
* @returns Resultado da verificação com lista de avisos e erros
|
|
3756
|
+
*
|
|
3757
|
+
* @example
|
|
3758
|
+
* ```typescript
|
|
3759
|
+
* import { checkPeerDeps } from '@react-lgpd-consent/core'
|
|
3760
|
+
*
|
|
3761
|
+
* // Verificar compatibilidade em desenvolvimento
|
|
3762
|
+
* const result = checkPeerDeps()
|
|
3763
|
+
* if (!result.ok) {
|
|
3764
|
+
* console.log('Problemas detectados:', result.errors)
|
|
3765
|
+
* }
|
|
3766
|
+
* ```
|
|
3767
|
+
*/
|
|
3768
|
+
declare function checkPeerDeps(options?: {
|
|
3769
|
+
skipInProduction?: boolean;
|
|
3770
|
+
logWarnings?: boolean;
|
|
3771
|
+
}): PeerDepsCheckResult;
|
|
3772
|
+
/**
|
|
3773
|
+
* Executa verificação de peer dependencies e loga resultados automaticamente.
|
|
3774
|
+
* Versão conveniente de `checkPeerDeps` que sempre loga no console.
|
|
3775
|
+
*
|
|
3776
|
+
* @category Utils
|
|
3777
|
+
* @since 0.5.4
|
|
3778
|
+
*
|
|
3779
|
+
* @remarks
|
|
3780
|
+
* Esta função é chamada automaticamente pelo ConsentProvider em modo development.
|
|
3781
|
+
* Use `checkPeerDeps()` se precisar do resultado programaticamente sem logging.
|
|
3782
|
+
*
|
|
3783
|
+
* @example
|
|
3784
|
+
* ```typescript
|
|
3785
|
+
* import { runPeerDepsCheck } from '@react-lgpd-consent/core'
|
|
3786
|
+
*
|
|
3787
|
+
* // Executar verificação manual (já é automática no Provider)
|
|
3788
|
+
* runPeerDepsCheck()
|
|
3789
|
+
* ```
|
|
3790
|
+
*/
|
|
3791
|
+
declare function runPeerDepsCheck(): void;
|
|
3792
|
+
|
|
3609
3793
|
interface CookieCatalogOverrides {
|
|
3610
3794
|
byCategory?: Record<string, CookieDescriptor[]>;
|
|
3611
3795
|
byIntegration?: Record<string, CookieDescriptor[]>;
|
|
@@ -3666,6 +3850,12 @@ declare function getCookiesInfoForCategory(categoryId: Category, usedIntegration
|
|
|
3666
3850
|
* ```
|
|
3667
3851
|
*/
|
|
3668
3852
|
declare function createProjectPreferences(config?: ProjectCategoriesConfig, defaultValue?: boolean): ConsentPreferences;
|
|
3853
|
+
/**
|
|
3854
|
+
* Garante que a categoria `necessary` permaneça ativa em qualquer estrutura de preferências.
|
|
3855
|
+
* @category Utils
|
|
3856
|
+
* @since 0.5.2
|
|
3857
|
+
*/
|
|
3858
|
+
declare function ensureNecessaryAlwaysOn(preferences: ConsentPreferences): ConsentPreferences;
|
|
3669
3859
|
/**
|
|
3670
3860
|
* Valida um objeto de preferências de consentimento, removendo categorias que não estão permitidas pela configuração do projeto.
|
|
3671
3861
|
* @category Utils
|
|
@@ -3842,4 +4032,4 @@ declare function useDataLayerEvents(): {
|
|
|
3842
4032
|
pushUpdated: typeof pushConsentUpdatedEvent;
|
|
3843
4033
|
};
|
|
3844
4034
|
|
|
3845
|
-
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 ConsentTexts, type ConsentUpdatedEvent, 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 ProjectCategoriesConfig, type SaaSConfig, type ScriptIntegration, TEXT_TEMPLATES, type UserWayConfig, type ZendeskConfig, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, categorizeDiscoveredCookies, createClarityIntegration, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, resolveTexts, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
|
|
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 };
|