react-lgpd-consent 0.2.4 → 0.2.5
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/README.md
CHANGED
|
@@ -21,7 +21,6 @@ Por padrão, os avisos são desativados automaticamente em builds de produção
|
|
|
21
21
|
|
|
22
22
|
A forma anterior de desativar os avisos via `window.__LGPD_DISABLE_GUIDANCE__ = true` ainda funciona, mas o uso da prop é a forma **preferencial e mais idiomática** em React.
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
## 📖 Uso Básico - Configuração Consciente (v0.2.2)
|
|
26
25
|
|
|
27
26
|
### 1. Setup Básico (Compliance LGPD Automática)
|
|
@@ -613,13 +612,13 @@ Para controle total, desabilite o modal automático:
|
|
|
613
612
|
|
|
614
613
|
### Components
|
|
615
614
|
|
|
616
|
-
| Componente | Descrição | Props Principais
|
|
617
|
-
| --------------------------- | ------------------------------------------------ |
|
|
615
|
+
| Componente | Descrição | Props Principais |
|
|
616
|
+
| --------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
|
|
618
617
|
| `ConsentProvider` | Provider principal do contexto | `initialState`, `texts`, `theme`, `hideBranding`, `PreferencesModalComponent`, `disableDeveloperGuidance`, callbacks |
|
|
619
|
-
| `CookieBanner` | Banner de consentimento | `policyLinkUrl`, `blocking`, `hideBranding`, `debug`, pass-through MUI props
|
|
620
|
-
| `PreferencesModal` | Modal de preferências (incluído automaticamente) | `DialogProps`, `hideBranding` - **Opcional**
|
|
621
|
-
| `FloatingPreferencesButton` | Botão flutuante para abrir preferências | `position`, `hideWhenConsented`, `tooltip`, `icon`, `FabProps`
|
|
622
|
-
| `ConsentGate` | Renderização condicional por categoria | `category`, `children`
|
|
618
|
+
| `CookieBanner` | Banner de consentimento | `policyLinkUrl`, `blocking`, `hideBranding`, `debug`, pass-through MUI props |
|
|
619
|
+
| `PreferencesModal` | Modal de preferências (incluído automaticamente) | `DialogProps`, `hideBranding` - **Opcional** |
|
|
620
|
+
| `FloatingPreferencesButton` | Botão flutuante para abrir preferências | `position`, `hideWhenConsented`, `tooltip`, `icon`, `FabProps` |
|
|
621
|
+
| `ConsentGate` | Renderização condicional por categoria | `category`, `children` |
|
|
623
622
|
|
|
624
623
|
### Hook `useConsent()`
|
|
625
624
|
|
|
@@ -719,7 +718,7 @@ Este projeto está licenciado sob a Licença MIT - veja o arquivo [LICENSE](LICE
|
|
|
719
718
|
- ✅ **Hooks Avançados**: `useCategories()` e `useCategoryStatus()`
|
|
720
719
|
- ✅ **Validação Automática**: Prevenção de bugs de configuração vs UI
|
|
721
720
|
|
|
722
|
-
### v0.2.
|
|
721
|
+
### v0.2.7 - Compliance Avançado (Próxima Release)
|
|
723
722
|
|
|
724
723
|
**Baseado em feedback de uso real em projetos governamentais:**
|
|
725
724
|
|
|
@@ -113,61 +113,54 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
113
113
|
return guidance;
|
|
114
114
|
}
|
|
115
115
|
function logDeveloperGuidance(guidance, disableGuidanceProp) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
console.
|
|
136
|
-
guidance.suggestions.forEach(
|
|
137
|
-
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
138
|
-
);
|
|
139
|
-
console.groupEnd();
|
|
140
|
-
}
|
|
141
|
-
if (guidance.usingDefaults) {
|
|
142
|
-
console.info(
|
|
143
|
-
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
147
|
-
console.table(
|
|
148
|
-
guidance.activeCategoriesInfo.map((cat) => ({
|
|
149
|
-
ID: cat.id,
|
|
150
|
-
Nome: cat.name,
|
|
151
|
-
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
152
|
-
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
153
|
-
}))
|
|
116
|
+
if (disableGuidanceProp === true) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const isProduction = (
|
|
120
|
+
// 1. NODE_ENV de bundlers (Vite, webpack, etc.)
|
|
121
|
+
typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Flag customizada para desabilitar logs
|
|
122
|
+
typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ === true || // 3. Flag de desenvolvimento desabilitada via window global (legado)
|
|
123
|
+
typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__ === true
|
|
124
|
+
);
|
|
125
|
+
if (isProduction) return;
|
|
126
|
+
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
127
|
+
if (guidance.warnings.length > 0) {
|
|
128
|
+
console.group(`${PREFIX} \u26A0\uFE0F Avisos de Configura\xE7\xE3o`);
|
|
129
|
+
guidance.warnings.forEach((warning) => console.warn(`${PREFIX} ${warning}`));
|
|
130
|
+
console.groupEnd();
|
|
131
|
+
}
|
|
132
|
+
if (guidance.suggestions.length > 0) {
|
|
133
|
+
console.group(`${PREFIX} \u{1F4A1} Sugest\xF5es`);
|
|
134
|
+
guidance.suggestions.forEach(
|
|
135
|
+
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
154
136
|
);
|
|
137
|
+
console.groupEnd();
|
|
138
|
+
}
|
|
139
|
+
if (guidance.usingDefaults) {
|
|
155
140
|
console.info(
|
|
156
|
-
`${PREFIX} \
|
|
141
|
+
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
157
142
|
);
|
|
158
|
-
console.groupEnd();
|
|
159
|
-
} catch (error) {
|
|
160
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
161
|
-
console.warn(
|
|
162
|
-
"[\u{1F36A} LGPD-CONSENT] Sistema de orienta\xE7\xF5es encontrou erro:",
|
|
163
|
-
error
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
143
|
}
|
|
144
|
+
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
145
|
+
console.table(
|
|
146
|
+
guidance.activeCategoriesInfo.map((cat) => ({
|
|
147
|
+
ID: cat.id,
|
|
148
|
+
Nome: cat.name,
|
|
149
|
+
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
150
|
+
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
151
|
+
}))
|
|
152
|
+
);
|
|
153
|
+
console.info(
|
|
154
|
+
`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`
|
|
155
|
+
);
|
|
156
|
+
console.groupEnd();
|
|
167
157
|
}
|
|
168
158
|
function useDeveloperGuidance(config, disableGuidanceProp) {
|
|
169
159
|
const guidance = analyzeDeveloperConfiguration(config);
|
|
170
|
-
const stringifiedConfig = React.useMemo(
|
|
160
|
+
const stringifiedConfig = React.useMemo(
|
|
161
|
+
() => JSON.stringify(config),
|
|
162
|
+
[config]
|
|
163
|
+
);
|
|
171
164
|
React.useEffect(() => {
|
|
172
165
|
logDeveloperGuidance(guidance, disableGuidanceProp);
|
|
173
166
|
}, [guidance, stringifiedConfig, disableGuidanceProp]);
|
|
@@ -391,7 +384,7 @@ var defaultConsentTheme = createTheme({
|
|
|
391
384
|
// src/context/ConsentContext.tsx
|
|
392
385
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
393
386
|
var PreferencesModal = React3.lazy(
|
|
394
|
-
() => import("./PreferencesModal-
|
|
387
|
+
() => import("./PreferencesModal-B6N62JYB.js").then((m) => ({
|
|
395
388
|
default: m.PreferencesModal
|
|
396
389
|
}))
|
|
397
390
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -280,61 +280,54 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
280
280
|
return guidance;
|
|
281
281
|
}
|
|
282
282
|
function logDeveloperGuidance(guidance, disableGuidanceProp) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
console.
|
|
303
|
-
guidance.suggestions.forEach(
|
|
304
|
-
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
305
|
-
);
|
|
306
|
-
console.groupEnd();
|
|
307
|
-
}
|
|
308
|
-
if (guidance.usingDefaults) {
|
|
309
|
-
console.info(
|
|
310
|
-
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
314
|
-
console.table(
|
|
315
|
-
guidance.activeCategoriesInfo.map((cat) => ({
|
|
316
|
-
ID: cat.id,
|
|
317
|
-
Nome: cat.name,
|
|
318
|
-
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
319
|
-
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
320
|
-
}))
|
|
283
|
+
if (disableGuidanceProp === true) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const isProduction = (
|
|
287
|
+
// 1. NODE_ENV de bundlers (Vite, webpack, etc.)
|
|
288
|
+
typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Flag customizada para desabilitar logs
|
|
289
|
+
typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ === true || // 3. Flag de desenvolvimento desabilitada via window global (legado)
|
|
290
|
+
typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__ === true
|
|
291
|
+
);
|
|
292
|
+
if (isProduction) return;
|
|
293
|
+
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
294
|
+
if (guidance.warnings.length > 0) {
|
|
295
|
+
console.group(`${PREFIX} \u26A0\uFE0F Avisos de Configura\xE7\xE3o`);
|
|
296
|
+
guidance.warnings.forEach((warning) => console.warn(`${PREFIX} ${warning}`));
|
|
297
|
+
console.groupEnd();
|
|
298
|
+
}
|
|
299
|
+
if (guidance.suggestions.length > 0) {
|
|
300
|
+
console.group(`${PREFIX} \u{1F4A1} Sugest\xF5es`);
|
|
301
|
+
guidance.suggestions.forEach(
|
|
302
|
+
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
321
303
|
);
|
|
304
|
+
console.groupEnd();
|
|
305
|
+
}
|
|
306
|
+
if (guidance.usingDefaults) {
|
|
322
307
|
console.info(
|
|
323
|
-
`${PREFIX} \
|
|
308
|
+
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
324
309
|
);
|
|
325
|
-
console.groupEnd();
|
|
326
|
-
} catch (error) {
|
|
327
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
328
|
-
console.warn(
|
|
329
|
-
"[\u{1F36A} LGPD-CONSENT] Sistema de orienta\xE7\xF5es encontrou erro:",
|
|
330
|
-
error
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
310
|
}
|
|
311
|
+
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
312
|
+
console.table(
|
|
313
|
+
guidance.activeCategoriesInfo.map((cat) => ({
|
|
314
|
+
ID: cat.id,
|
|
315
|
+
Nome: cat.name,
|
|
316
|
+
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
317
|
+
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
318
|
+
}))
|
|
319
|
+
);
|
|
320
|
+
console.info(
|
|
321
|
+
`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`
|
|
322
|
+
);
|
|
323
|
+
console.groupEnd();
|
|
334
324
|
}
|
|
335
325
|
function useDeveloperGuidance(config, disableGuidanceProp) {
|
|
336
326
|
const guidance = analyzeDeveloperConfiguration(config);
|
|
337
|
-
const stringifiedConfig = React.useMemo(
|
|
327
|
+
const stringifiedConfig = React.useMemo(
|
|
328
|
+
() => JSON.stringify(config),
|
|
329
|
+
[config]
|
|
330
|
+
);
|
|
338
331
|
React.useEffect(() => {
|
|
339
332
|
logDeveloperGuidance(guidance, disableGuidanceProp);
|
|
340
333
|
}, [guidance, stringifiedConfig, disableGuidanceProp]);
|
package/dist/index.js
CHANGED
package/package.json
CHANGED