react-lgpd-consent 0.3.1 → 0.3.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.
- package/CHANGELOG.md +4 -17
- package/README.md +56 -648
- package/dist/{PreferencesModal-J27W5XAJ.js → PreferencesModal-HTTMUZND.js} +1 -1
- package/dist/{chunk-VFAOBR3X.js → chunk-GPLNN3FD.js} +303 -276
- package/dist/index.cjs +326 -290
- package/dist/index.d.cts +1589 -226
- package/dist/index.d.ts +1589 -226
- package/dist/index.js +21 -11
- package/package.json +16 -12
- package/COMPLIANCE.md +0 -107
package/dist/index.cjs
CHANGED
|
@@ -50,7 +50,6 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
50
50
|
description: "Essenciais para funcionamento b\xE1sico do site",
|
|
51
51
|
essential: true,
|
|
52
52
|
uiRequired: false
|
|
53
|
-
// Não precisa de toggle (sempre ativo)
|
|
54
53
|
});
|
|
55
54
|
const enabledCategories = finalConfig.enabledCategories || [];
|
|
56
55
|
const categoryNames = {
|
|
@@ -84,13 +83,10 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
84
83
|
description: categoryInfo.description,
|
|
85
84
|
essential: false,
|
|
86
85
|
uiRequired: true
|
|
87
|
-
// Precisa de toggle na UI
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
});
|
|
91
|
-
const totalToggleable = guidance.activeCategoriesInfo.filter(
|
|
92
|
-
(c) => c.uiRequired
|
|
93
|
-
).length;
|
|
89
|
+
const totalToggleable = guidance.activeCategoriesInfo.filter((c) => c.uiRequired).length;
|
|
94
90
|
if (totalToggleable === 0) {
|
|
95
91
|
guidance.suggestions.push(
|
|
96
92
|
'Apenas cookies necess\xE1rios est\xE3o configurados. Para compliance completo LGPD, considere adicionar categorias como "analytics" ou "functional" conforme uso real.'
|
|
@@ -98,78 +94,66 @@ function analyzeDeveloperConfiguration(config) {
|
|
|
98
94
|
}
|
|
99
95
|
if (totalToggleable > 5) {
|
|
100
96
|
guidance.warnings.push(
|
|
101
|
-
`${totalToggleable} categorias opcionais detectadas. UI com muitas op\xE7\xF5es pode
|
|
102
|
-
'prejudicar experi\xEAncia do usu\xE1rio. Considere agrupar categorias similares.`
|
|
97
|
+
`${totalToggleable} categorias opcionais detectadas. UI com muitas op\xE7\xF5es pode prejudicar experi\xEAncia do usu\xE1rio. Considere agrupar categorias similares.`
|
|
103
98
|
);
|
|
104
99
|
}
|
|
105
100
|
return guidance;
|
|
106
101
|
}
|
|
107
102
|
function logDeveloperGuidance(guidance, disableGuidanceProp) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// 1. NODE_ENV de bundlers (Vite, webpack, etc.)
|
|
113
|
-
typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Flag customizada para desabilitar logs
|
|
114
|
-
typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ === true || // 3. Flag de desenvolvimento desabilitada via window global (legado)
|
|
115
|
-
typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__ === true
|
|
116
|
-
);
|
|
117
|
-
if (isProduction) return;
|
|
103
|
+
const nodeEnv = typeof globalThis.process !== "undefined" ? globalThis.process.env?.NODE_ENV : void 0;
|
|
104
|
+
const isProd = nodeEnv === "production" || globalThis.__LGPD_PRODUCTION__ === true && typeof globalThis !== "undefined";
|
|
105
|
+
const isDisabled = !!disableGuidanceProp || globalThis.__LGPD_DISABLE_GUIDANCE__ === true && typeof globalThis !== "undefined";
|
|
106
|
+
if (isProd || isDisabled) return;
|
|
118
107
|
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
119
108
|
if (guidance.warnings.length > 0) {
|
|
120
109
|
console.group(`${PREFIX} \u26A0\uFE0F Avisos de Configura\xE7\xE3o`);
|
|
121
|
-
guidance.warnings.forEach((
|
|
110
|
+
guidance.warnings.forEach((msg) => console.warn(`${PREFIX} ${msg}`));
|
|
122
111
|
console.groupEnd();
|
|
123
112
|
}
|
|
124
113
|
if (guidance.suggestions.length > 0) {
|
|
125
114
|
console.group(`${PREFIX} \u{1F4A1} Sugest\xF5es`);
|
|
126
|
-
guidance.suggestions.forEach(
|
|
127
|
-
(suggestion) => console.info(`${PREFIX} ${suggestion}`)
|
|
128
|
-
);
|
|
115
|
+
guidance.suggestions.forEach((msg) => console.info(`${PREFIX} ${msg}`));
|
|
129
116
|
console.groupEnd();
|
|
130
117
|
}
|
|
131
118
|
if (guidance.usingDefaults) {
|
|
132
119
|
console.warn(
|
|
133
|
-
// Changed from console.info to console.warn
|
|
134
120
|
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
135
121
|
);
|
|
136
122
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}))
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
123
|
+
const rows = guidance.activeCategoriesInfo.map((cat) => ({
|
|
124
|
+
ID: cat.id,
|
|
125
|
+
Nome: cat.name,
|
|
126
|
+
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
127
|
+
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
128
|
+
}));
|
|
129
|
+
if (typeof console.table === "function") {
|
|
130
|
+
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
131
|
+
console.table(rows);
|
|
132
|
+
console.info(`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`);
|
|
133
|
+
console.groupEnd();
|
|
134
|
+
} else {
|
|
135
|
+
console.log(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`, rows);
|
|
136
|
+
console.info(`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`);
|
|
137
|
+
}
|
|
150
138
|
}
|
|
151
139
|
function useDeveloperGuidance(config, disableGuidanceProp) {
|
|
152
|
-
const guidance =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (disableGuidanceProp === true) {
|
|
159
|
-
return;
|
|
140
|
+
const guidance = import_react.default.useMemo(() => {
|
|
141
|
+
return analyzeDeveloperConfiguration(config);
|
|
142
|
+
}, [config]);
|
|
143
|
+
import_react.default.useEffect(() => {
|
|
144
|
+
if (!disableGuidanceProp) {
|
|
145
|
+
logDeveloperGuidance(guidance, disableGuidanceProp);
|
|
160
146
|
}
|
|
161
|
-
|
|
162
|
-
}, [guidance, stringifiedConfig, disableGuidanceProp]);
|
|
147
|
+
}, [guidance, disableGuidanceProp]);
|
|
163
148
|
return guidance;
|
|
164
149
|
}
|
|
165
|
-
var
|
|
150
|
+
var import_react, DEFAULT_PROJECT_CATEGORIES;
|
|
166
151
|
var init_developerGuidance = __esm({
|
|
167
152
|
"src/utils/developerGuidance.ts"() {
|
|
168
153
|
"use strict";
|
|
169
|
-
|
|
154
|
+
import_react = __toESM(require("react"), 1);
|
|
170
155
|
DEFAULT_PROJECT_CATEGORIES = {
|
|
171
156
|
enabledCategories: ["analytics"]
|
|
172
|
-
// Só analytics além de necessary
|
|
173
157
|
};
|
|
174
158
|
}
|
|
175
159
|
});
|
|
@@ -178,15 +162,12 @@ var init_developerGuidance = __esm({
|
|
|
178
162
|
function CategoriesProvider({
|
|
179
163
|
children,
|
|
180
164
|
config,
|
|
181
|
-
// NOVO: configuração completa
|
|
182
165
|
disableDeveloperGuidance
|
|
183
166
|
}) {
|
|
184
167
|
const contextValue = React2.useMemo(() => {
|
|
185
168
|
const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
|
|
186
169
|
const guidance = analyzeDeveloperConfiguration(config);
|
|
187
|
-
const toggleableCategories = guidance.activeCategoriesInfo.filter(
|
|
188
|
-
(cat) => cat.uiRequired
|
|
189
|
-
);
|
|
170
|
+
const toggleableCategories = guidance.activeCategoriesInfo.filter((cat) => cat.uiRequired);
|
|
190
171
|
return {
|
|
191
172
|
config: finalConfig,
|
|
192
173
|
guidance,
|
|
@@ -226,17 +207,12 @@ var init_CategoriesContext = __esm({
|
|
|
226
207
|
React2 = __toESM(require("react"), 1);
|
|
227
208
|
init_developerGuidance();
|
|
228
209
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
229
|
-
CategoriesContext = React2.createContext(
|
|
230
|
-
null
|
|
231
|
-
);
|
|
210
|
+
CategoriesContext = React2.createContext(null);
|
|
232
211
|
}
|
|
233
212
|
});
|
|
234
213
|
|
|
235
214
|
// src/utils/SafeThemeProvider.tsx
|
|
236
|
-
function SafeThemeProvider({
|
|
237
|
-
theme,
|
|
238
|
-
children
|
|
239
|
-
}) {
|
|
215
|
+
function SafeThemeProvider({ theme, children }) {
|
|
240
216
|
const safeTheme = React3.useMemo(() => createSafeTheme(theme), [theme]);
|
|
241
217
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_styles.ThemeProvider, { theme: safeTheme, children });
|
|
242
218
|
}
|
|
@@ -326,16 +302,12 @@ var init_SafeThemeProvider = __esm({
|
|
|
326
302
|
function setDebugLogging(enabled, level = 2 /* INFO */) {
|
|
327
303
|
logger.setEnabled(enabled);
|
|
328
304
|
logger.setLevel(level);
|
|
329
|
-
logger.info(
|
|
330
|
-
`Debug logging ${enabled ? "enabled" : "disabled"} with level ${LogLevel[level]}`
|
|
331
|
-
);
|
|
305
|
+
logger.info(`Debug logging ${enabled ? "enabled" : "disabled"} with level ${LogLevel[level]}`);
|
|
332
306
|
}
|
|
333
|
-
var
|
|
307
|
+
var LogLevel, _ConsentLogger, ConsentLogger, logger;
|
|
334
308
|
var init_logger = __esm({
|
|
335
309
|
"src/utils/logger.ts"() {
|
|
336
310
|
"use strict";
|
|
337
|
-
IS_DEVELOPMENT = typeof window !== "undefined" && window.__REACT_DEVTOOLS_GLOBAL_HOOK__ || typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV === "development";
|
|
338
|
-
LOG_PREFIX = "[react-lgpd-consent]";
|
|
339
311
|
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
340
312
|
LogLevel2[LogLevel2["ERROR"] = 0] = "ERROR";
|
|
341
313
|
LogLevel2[LogLevel2["WARN"] = 1] = "WARN";
|
|
@@ -343,38 +315,93 @@ var init_logger = __esm({
|
|
|
343
315
|
LogLevel2[LogLevel2["DEBUG"] = 3] = "DEBUG";
|
|
344
316
|
return LogLevel2;
|
|
345
317
|
})(LogLevel || {});
|
|
346
|
-
|
|
318
|
+
_ConsentLogger = class _ConsentLogger {
|
|
347
319
|
constructor() {
|
|
348
|
-
this.enabled = IS_DEVELOPMENT;
|
|
320
|
+
this.enabled = _ConsentLogger.IS_DEVELOPMENT;
|
|
349
321
|
this.level = 2 /* INFO */;
|
|
350
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Habilita ou desabilita o sistema de logging.
|
|
325
|
+
* @param {boolean} enabled Se `true`, os logs serão exibidos; caso contrário, serão suprimidos.
|
|
326
|
+
*/
|
|
351
327
|
setEnabled(enabled) {
|
|
352
328
|
this.enabled = enabled;
|
|
353
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Define o nível mínimo de severidade para os logs.
|
|
332
|
+
* Mensagens com severidade menor que o nível definido não serão exibidas.
|
|
333
|
+
* @param {LogLevel} level O nível mínimo de severidade (ex: `LogLevel.DEBUG` para ver todos os logs).
|
|
334
|
+
*/
|
|
354
335
|
setLevel(level) {
|
|
355
336
|
this.level = level;
|
|
356
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* Registra uma mensagem de erro.
|
|
340
|
+
* @param {...any[]} args Os argumentos a serem logados.
|
|
341
|
+
*/
|
|
357
342
|
error(...args) {
|
|
358
343
|
if (this.enabled && this.level >= 0 /* ERROR */) {
|
|
359
|
-
console.error(LOG_PREFIX, "[ERROR]", ...args);
|
|
344
|
+
console.error(_ConsentLogger.LOG_PREFIX, "[ERROR]", ...args);
|
|
360
345
|
}
|
|
361
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Registra uma mensagem de aviso.
|
|
349
|
+
* @param {...any[]} args Os argumentos a serem logados.
|
|
350
|
+
*/
|
|
362
351
|
warn(...args) {
|
|
363
352
|
if (this.enabled && this.level >= 1 /* WARN */) {
|
|
364
|
-
console.warn(LOG_PREFIX, "[WARN]", ...args);
|
|
353
|
+
console.warn(_ConsentLogger.LOG_PREFIX, "[WARN]", ...args);
|
|
365
354
|
}
|
|
366
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Registra uma mensagem informativa.
|
|
358
|
+
* @param {...any[]} args Os argumentos a serem logados.
|
|
359
|
+
*/
|
|
367
360
|
info(...args) {
|
|
368
361
|
if (this.enabled && this.level >= 2 /* INFO */) {
|
|
369
|
-
console.info(LOG_PREFIX, "[INFO]", ...args);
|
|
362
|
+
console.info(_ConsentLogger.LOG_PREFIX, "[INFO]", ...args);
|
|
370
363
|
}
|
|
371
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Registra uma mensagem de depuração.
|
|
367
|
+
* @param {...any[]} args Os argumentos a serem logados.
|
|
368
|
+
*/
|
|
372
369
|
debug(...args) {
|
|
373
370
|
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
374
|
-
console.debug(LOG_PREFIX, "[DEBUG]", ...args);
|
|
371
|
+
console.debug(_ConsentLogger.LOG_PREFIX, "[DEBUG]", ...args);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Inicia um grupo de logs no console.
|
|
376
|
+
* @param {...any[]} args Os argumentos para o título do grupo.
|
|
377
|
+
*/
|
|
378
|
+
group(...args) {
|
|
379
|
+
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
380
|
+
console.group(_ConsentLogger.LOG_PREFIX, ...args);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Finaliza o grupo de logs mais recente no console.
|
|
385
|
+
*/
|
|
386
|
+
groupEnd() {
|
|
387
|
+
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
388
|
+
console.groupEnd();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Exibe dados tabulares no console.
|
|
393
|
+
* @param {any} tabularData Os dados a serem exibidos na tabela.
|
|
394
|
+
* @param {string[]} [properties] Um array opcional de propriedades para exibir.
|
|
395
|
+
*/
|
|
396
|
+
table(tabularData, properties) {
|
|
397
|
+
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
398
|
+
console.table(tabularData, properties);
|
|
375
399
|
}
|
|
376
400
|
}
|
|
377
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Registra informações sobre a compatibilidade do tema Material-UI.
|
|
403
|
+
* @param {any} themeInfo Objeto com informações do tema.
|
|
404
|
+
*/
|
|
378
405
|
themeCompatibility(themeInfo) {
|
|
379
406
|
this.debug("Theme compatibility check:", {
|
|
380
407
|
hasTheme: !!themeInfo,
|
|
@@ -384,6 +411,11 @@ var init_logger = __esm({
|
|
|
384
411
|
hasDuration: !!themeInfo?.transitions?.duration
|
|
385
412
|
});
|
|
386
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Registra mudanças no estado de consentimento.
|
|
416
|
+
* @param {string} action A ação que causou a mudança de estado.
|
|
417
|
+
* @param {any} state O estado atual do consentimento.
|
|
418
|
+
*/
|
|
387
419
|
consentState(action, state) {
|
|
388
420
|
this.debug(`Consent state change [${action}]:`, {
|
|
389
421
|
consented: state.consented,
|
|
@@ -391,6 +423,12 @@ var init_logger = __esm({
|
|
|
391
423
|
preferencesCount: Object.keys(state.preferences || {}).length
|
|
392
424
|
});
|
|
393
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Registra operações de cookie (leitura, escrita, remoção).
|
|
428
|
+
* @param {'read' | 'write' | 'delete'} operation O tipo de operação de cookie.
|
|
429
|
+
* @param {string} cookieName O nome do cookie.
|
|
430
|
+
* @param {any} [data] Os dados do cookie, se aplicável.
|
|
431
|
+
*/
|
|
394
432
|
cookieOperation(operation, cookieName, data) {
|
|
395
433
|
this.debug(`Cookie ${operation}:`, {
|
|
396
434
|
name: cookieName,
|
|
@@ -398,22 +436,38 @@ var init_logger = __esm({
|
|
|
398
436
|
dataSize: data ? JSON.stringify(data).length : 0
|
|
399
437
|
});
|
|
400
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Registra a renderização de um componente.
|
|
441
|
+
* @param {string} componentName O nome do componente.
|
|
442
|
+
* @param {any} [props] As propriedades do componente.
|
|
443
|
+
*/
|
|
401
444
|
componentRender(componentName, props) {
|
|
402
445
|
this.debug(`Component render [${componentName}]:`, {
|
|
403
446
|
hasProps: !!props,
|
|
404
447
|
propsKeys: props ? Object.keys(props) : []
|
|
405
448
|
});
|
|
406
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* Registra o status de carregamento de scripts de integração.
|
|
452
|
+
* @param {string} scriptName O nome do script.
|
|
453
|
+
* @param {'load' | 'remove'} action A ação realizada (carregar ou remover).
|
|
454
|
+
* @param {boolean} success Se a operação foi bem-sucedida.
|
|
455
|
+
*/
|
|
407
456
|
scriptIntegration(scriptName, action, success) {
|
|
408
|
-
this.info(
|
|
409
|
-
`Script ${action} [${scriptName}]:`,
|
|
410
|
-
success ? "SUCCESS" : "FAILED"
|
|
411
|
-
);
|
|
457
|
+
this.info(`Script ${action} [${scriptName}]:`, success ? "SUCCESS" : "FAILED");
|
|
412
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Registra chamadas à API interna da biblioteca.
|
|
461
|
+
* @param {string} method O nome do método da API chamado.
|
|
462
|
+
* @param {any} [params] Os parâmetros passados para o método.
|
|
463
|
+
*/
|
|
413
464
|
apiUsage(method, params) {
|
|
414
465
|
this.debug(`API call [${method}]:`, params);
|
|
415
466
|
}
|
|
416
467
|
};
|
|
468
|
+
_ConsentLogger.IS_DEVELOPMENT = typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV === "development";
|
|
469
|
+
_ConsentLogger.LOG_PREFIX = "[react-lgpd-consent]";
|
|
470
|
+
ConsentLogger = _ConsentLogger;
|
|
417
471
|
logger = new ConsentLogger();
|
|
418
472
|
}
|
|
419
473
|
});
|
|
@@ -438,9 +492,7 @@ function readConsentCookie(name = DEFAULT_COOKIE_OPTS.name) {
|
|
|
438
492
|
return migrateLegacyCookie(data);
|
|
439
493
|
}
|
|
440
494
|
if (data.version !== COOKIE_SCHEMA_VERSION) {
|
|
441
|
-
logger.warn(
|
|
442
|
-
`Cookie version mismatch: ${data.version} != ${COOKIE_SCHEMA_VERSION}`
|
|
443
|
-
);
|
|
495
|
+
logger.warn(`Cookie version mismatch: ${data.version} != ${COOKIE_SCHEMA_VERSION}`);
|
|
444
496
|
return null;
|
|
445
497
|
}
|
|
446
498
|
return data;
|
|
@@ -457,12 +509,9 @@ function migrateLegacyCookie(legacyData) {
|
|
|
457
509
|
consented: legacyData.consented || false,
|
|
458
510
|
preferences: legacyData.preferences || { necessary: true },
|
|
459
511
|
consentDate: now,
|
|
460
|
-
// Não temos o original, usar data atual
|
|
461
512
|
lastUpdate: now,
|
|
462
513
|
source: "banner",
|
|
463
|
-
// Assumir origem banner
|
|
464
514
|
isModalOpen: false
|
|
465
|
-
// Nunca persistir estado de UI
|
|
466
515
|
};
|
|
467
516
|
} catch {
|
|
468
517
|
return null;
|
|
@@ -480,11 +529,9 @@ function writeConsentCookie(state, config, opts, source = "banner") {
|
|
|
480
529
|
consented: state.consented,
|
|
481
530
|
preferences: state.preferences,
|
|
482
531
|
consentDate: state.consentDate || now,
|
|
483
|
-
// Preservar data original ou usar atual
|
|
484
532
|
lastUpdate: now,
|
|
485
533
|
source,
|
|
486
534
|
projectConfig: config
|
|
487
|
-
// isModalOpen NÃO é persistido (campo de UI apenas)
|
|
488
535
|
};
|
|
489
536
|
logger.cookieOperation("write", o.name, cookieData);
|
|
490
537
|
import_js_cookie.default.set(o.name, JSON.stringify(cookieData), {
|
|
@@ -553,6 +600,64 @@ function validateProjectPreferences(preferences, config) {
|
|
|
553
600
|
});
|
|
554
601
|
return validPreferences;
|
|
555
602
|
}
|
|
603
|
+
function getAllProjectCategories(config) {
|
|
604
|
+
const allCategories = [
|
|
605
|
+
{
|
|
606
|
+
id: "necessary",
|
|
607
|
+
name: "Necess\xE1rios",
|
|
608
|
+
description: "Cookies essenciais para funcionamento b\xE1sico do site",
|
|
609
|
+
essential: true
|
|
610
|
+
}
|
|
611
|
+
];
|
|
612
|
+
const enabledCategories = config?.enabledCategories || [];
|
|
613
|
+
enabledCategories.forEach((category) => {
|
|
614
|
+
if (category !== "necessary") {
|
|
615
|
+
allCategories.push(getDefaultCategoryDefinition(category));
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
return allCategories;
|
|
619
|
+
}
|
|
620
|
+
function getDefaultCategoryDefinition(category) {
|
|
621
|
+
const definitions = {
|
|
622
|
+
necessary: {
|
|
623
|
+
id: "necessary",
|
|
624
|
+
name: "Necess\xE1rios",
|
|
625
|
+
description: "Cookies essenciais para funcionamento b\xE1sico do site",
|
|
626
|
+
essential: true
|
|
627
|
+
},
|
|
628
|
+
analytics: {
|
|
629
|
+
id: "analytics",
|
|
630
|
+
name: "An\xE1lise e Estat\xEDsticas",
|
|
631
|
+
description: "Cookies para an\xE1lise de uso e estat\xEDsticas do site",
|
|
632
|
+
essential: false
|
|
633
|
+
},
|
|
634
|
+
functional: {
|
|
635
|
+
id: "functional",
|
|
636
|
+
name: "Funcionalidades",
|
|
637
|
+
description: "Cookies para funcionalidades extras como prefer\xEAncias e idioma",
|
|
638
|
+
essential: false
|
|
639
|
+
},
|
|
640
|
+
marketing: {
|
|
641
|
+
id: "marketing",
|
|
642
|
+
name: "Marketing e Publicidade",
|
|
643
|
+
description: "Cookies para publicidade direcionada e marketing",
|
|
644
|
+
essential: false
|
|
645
|
+
},
|
|
646
|
+
social: {
|
|
647
|
+
id: "social",
|
|
648
|
+
name: "Redes Sociais",
|
|
649
|
+
description: "Cookies para integra\xE7\xE3o com redes sociais e compartilhamento",
|
|
650
|
+
essential: false
|
|
651
|
+
},
|
|
652
|
+
personalization: {
|
|
653
|
+
id: "personalization",
|
|
654
|
+
name: "Personaliza\xE7\xE3o",
|
|
655
|
+
description: "Cookies para personaliza\xE7\xE3o de conte\xFAdo e experi\xEAncia",
|
|
656
|
+
essential: false
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
return definitions[category];
|
|
660
|
+
}
|
|
556
661
|
var init_categoryUtils = __esm({
|
|
557
662
|
"src/utils/categoryUtils.ts"() {
|
|
558
663
|
"use strict";
|
|
@@ -754,74 +859,59 @@ function CookieBanner({
|
|
|
754
859
|
fontFamily: designTokens?.typography?.fontFamily
|
|
755
860
|
};
|
|
756
861
|
const bannerContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Paper.default, { elevation: 3, sx: bannerStyle, ...PaperProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Stack.default, { spacing: 1, children: [
|
|
757
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
811
|
-
import_Button.default,
|
|
812
|
-
{
|
|
813
|
-
variant: "text",
|
|
814
|
-
onClick: () => {
|
|
815
|
-
logger.apiUsage("openPreferences", { source: "banner" });
|
|
816
|
-
openPreferences();
|
|
817
|
-
},
|
|
818
|
-
sx: { color: designTokens?.colors?.text },
|
|
819
|
-
children: texts.preferences
|
|
820
|
-
}
|
|
821
|
-
)
|
|
822
|
-
]
|
|
823
|
-
}
|
|
824
|
-
),
|
|
862
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Typography2.default, { variant: "body2", sx: { fontSize: designTokens?.typography?.fontSize?.banner }, children: [
|
|
863
|
+
texts.bannerMessage,
|
|
864
|
+
" ",
|
|
865
|
+
policyLinkUrl && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
866
|
+
import_Link2.default,
|
|
867
|
+
{
|
|
868
|
+
href: policyLinkUrl,
|
|
869
|
+
underline: "hover",
|
|
870
|
+
target: "_blank",
|
|
871
|
+
rel: "noopener noreferrer",
|
|
872
|
+
sx: { color: designTokens?.colors?.primary },
|
|
873
|
+
children: texts.policyLink ?? "Saiba mais"
|
|
874
|
+
}
|
|
875
|
+
)
|
|
876
|
+
] }),
|
|
877
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Stack.default, { direction: { xs: "column", sm: "row" }, spacing: 1, justifyContent: "flex-end", children: [
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
879
|
+
import_Button.default,
|
|
880
|
+
{
|
|
881
|
+
variant: "outlined",
|
|
882
|
+
onClick: () => {
|
|
883
|
+
logger.apiUsage("rejectAll", { source: "banner" });
|
|
884
|
+
rejectAll();
|
|
885
|
+
},
|
|
886
|
+
sx: { color: designTokens?.colors?.secondary },
|
|
887
|
+
children: texts.declineAll
|
|
888
|
+
}
|
|
889
|
+
),
|
|
890
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
891
|
+
import_Button.default,
|
|
892
|
+
{
|
|
893
|
+
variant: "contained",
|
|
894
|
+
onClick: () => {
|
|
895
|
+
logger.apiUsage("acceptAll", { source: "banner" });
|
|
896
|
+
acceptAll();
|
|
897
|
+
},
|
|
898
|
+
sx: { backgroundColor: designTokens?.colors?.primary },
|
|
899
|
+
children: texts.acceptAll
|
|
900
|
+
}
|
|
901
|
+
),
|
|
902
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
903
|
+
import_Button.default,
|
|
904
|
+
{
|
|
905
|
+
variant: "text",
|
|
906
|
+
onClick: () => {
|
|
907
|
+
logger.apiUsage("openPreferences", { source: "banner" });
|
|
908
|
+
openPreferences();
|
|
909
|
+
},
|
|
910
|
+
sx: { color: designTokens?.colors?.text },
|
|
911
|
+
children: texts.preferences
|
|
912
|
+
}
|
|
913
|
+
)
|
|
914
|
+
] }),
|
|
825
915
|
!hideBranding && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Branding, { variant: "banner" })
|
|
826
916
|
] }) });
|
|
827
917
|
const positionStyle = {
|
|
@@ -833,6 +923,7 @@ function CookieBanner({
|
|
|
833
923
|
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
834
924
|
p: 2
|
|
835
925
|
};
|
|
926
|
+
const backdropColor = designTokens?.layout?.backdrop === false ? "transparent" : typeof designTokens?.layout?.backdrop === "string" ? designTokens.layout.backdrop : "rgba(0, 0, 0, 0.4)";
|
|
836
927
|
if (blocking) {
|
|
837
928
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
838
929
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -844,7 +935,7 @@ function CookieBanner({
|
|
|
844
935
|
left: 0,
|
|
845
936
|
right: 0,
|
|
846
937
|
bottom: 0,
|
|
847
|
-
backgroundColor:
|
|
938
|
+
backgroundColor: backdropColor,
|
|
848
939
|
zIndex: 1299
|
|
849
940
|
}
|
|
850
941
|
}
|
|
@@ -994,43 +1085,26 @@ function createFullConsentState(consented, preferences, source, projectConfig, i
|
|
|
994
1085
|
};
|
|
995
1086
|
}
|
|
996
1087
|
function reducer(state, action) {
|
|
997
|
-
|
|
998
|
-
action: action.type,
|
|
999
|
-
currentState: state.consented
|
|
1000
|
-
});
|
|
1088
|
+
logger.consentState(action.type, state);
|
|
1001
1089
|
switch (action.type) {
|
|
1002
1090
|
case "ACCEPT_ALL": {
|
|
1003
1091
|
const prefs = createProjectPreferences(action.config, true);
|
|
1004
|
-
const newState = createFullConsentState(
|
|
1005
|
-
|
|
1006
|
-
prefs,
|
|
1007
|
-
"banner",
|
|
1008
|
-
action.config,
|
|
1009
|
-
false,
|
|
1010
|
-
state
|
|
1011
|
-
);
|
|
1012
|
-
log.info("User accepted all cookies", {
|
|
1092
|
+
const newState = createFullConsentState(true, prefs, "banner", action.config, false, state);
|
|
1093
|
+
logger.info("User accepted all cookies", {
|
|
1013
1094
|
preferences: newState.preferences
|
|
1014
1095
|
});
|
|
1015
1096
|
return newState;
|
|
1016
1097
|
}
|
|
1017
1098
|
case "REJECT_ALL": {
|
|
1018
1099
|
const prefs = createProjectPreferences(action.config, false);
|
|
1019
|
-
const newState = createFullConsentState(
|
|
1020
|
-
|
|
1021
|
-
prefs,
|
|
1022
|
-
"banner",
|
|
1023
|
-
action.config,
|
|
1024
|
-
false,
|
|
1025
|
-
state
|
|
1026
|
-
);
|
|
1027
|
-
log.info("User rejected all cookies", {
|
|
1100
|
+
const newState = createFullConsentState(true, prefs, "banner", action.config, false, state);
|
|
1101
|
+
logger.info("User rejected all cookies", {
|
|
1028
1102
|
preferences: newState.preferences
|
|
1029
1103
|
});
|
|
1030
1104
|
return newState;
|
|
1031
1105
|
}
|
|
1032
1106
|
case "SET_CATEGORY":
|
|
1033
|
-
|
|
1107
|
+
logger.debug("Category preference changed", {
|
|
1034
1108
|
category: action.category,
|
|
1035
1109
|
value: action.value
|
|
1036
1110
|
});
|
|
@@ -1043,26 +1117,12 @@ function reducer(state, action) {
|
|
|
1043
1117
|
lastUpdate: (/* @__PURE__ */ new Date()).toISOString()
|
|
1044
1118
|
};
|
|
1045
1119
|
case "SET_PREFERENCES":
|
|
1046
|
-
|
|
1047
|
-
return createFullConsentState(
|
|
1048
|
-
true,
|
|
1049
|
-
action.preferences,
|
|
1050
|
-
"modal",
|
|
1051
|
-
action.config,
|
|
1052
|
-
false,
|
|
1053
|
-
state
|
|
1054
|
-
);
|
|
1120
|
+
logger.info("Preferences saved", { preferences: action.preferences });
|
|
1121
|
+
return createFullConsentState(true, action.preferences, "modal", action.config, false, state);
|
|
1055
1122
|
case "OPEN_MODAL":
|
|
1056
1123
|
return { ...state, isModalOpen: true };
|
|
1057
1124
|
case "CLOSE_MODAL":
|
|
1058
|
-
return createFullConsentState(
|
|
1059
|
-
true,
|
|
1060
|
-
state.preferences,
|
|
1061
|
-
"modal",
|
|
1062
|
-
action.config,
|
|
1063
|
-
false,
|
|
1064
|
-
state
|
|
1065
|
-
);
|
|
1125
|
+
return createFullConsentState(true, state.preferences, "modal", action.config, false, state);
|
|
1066
1126
|
case "RESET": {
|
|
1067
1127
|
return createFullConsentState(
|
|
1068
1128
|
false,
|
|
@@ -1090,12 +1150,9 @@ function reducer(state, action) {
|
|
|
1090
1150
|
function ConsentProvider({
|
|
1091
1151
|
initialState,
|
|
1092
1152
|
categories,
|
|
1093
|
-
// Nova prop para configuração de categorias
|
|
1094
1153
|
texts: textsProp,
|
|
1095
1154
|
theme,
|
|
1096
1155
|
designTokens,
|
|
1097
|
-
scriptIntegrations,
|
|
1098
|
-
// eslint-disable-line no-unused-vars
|
|
1099
1156
|
PreferencesModalComponent,
|
|
1100
1157
|
preferencesModalProps = {},
|
|
1101
1158
|
CookieBannerComponent,
|
|
@@ -1110,18 +1167,12 @@ function ConsentProvider({
|
|
|
1110
1167
|
disableDeveloperGuidance,
|
|
1111
1168
|
children
|
|
1112
1169
|
}) {
|
|
1113
|
-
const texts = React5.useMemo(
|
|
1114
|
-
() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }),
|
|
1115
|
-
[textsProp]
|
|
1116
|
-
);
|
|
1170
|
+
const texts = React5.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
|
|
1117
1171
|
const cookie = React5.useMemo(
|
|
1118
1172
|
() => ({ ...DEFAULT_COOKIE_OPTS, ...cookieOpts ?? {} }),
|
|
1119
1173
|
[cookieOpts]
|
|
1120
1174
|
);
|
|
1121
|
-
const appliedTheme = React5.useMemo(
|
|
1122
|
-
() => theme || defaultConsentTheme,
|
|
1123
|
-
[theme]
|
|
1124
|
-
);
|
|
1175
|
+
const appliedTheme = React5.useMemo(() => theme || defaultConsentTheme, [theme]);
|
|
1125
1176
|
const finalCategoriesConfig = React5.useMemo(() => {
|
|
1126
1177
|
if (categories) return categories;
|
|
1127
1178
|
return DEFAULT_PROJECT_CATEGORIES;
|
|
@@ -1153,8 +1204,7 @@ function ConsentProvider({
|
|
|
1153
1204
|
setIsHydrated(true);
|
|
1154
1205
|
}, [cookie.name, initialState, finalCategoriesConfig]);
|
|
1155
1206
|
React5.useEffect(() => {
|
|
1156
|
-
if (state.consented)
|
|
1157
|
-
writeConsentCookie(state, finalCategoriesConfig, cookie);
|
|
1207
|
+
if (state.consented) writeConsentCookie(state, finalCategoriesConfig, cookie);
|
|
1158
1208
|
}, [state, cookie, finalCategoriesConfig]);
|
|
1159
1209
|
const prevConsented = React5.useRef(state.consented);
|
|
1160
1210
|
React5.useEffect(() => {
|
|
@@ -1243,14 +1293,12 @@ function ConsentProvider({
|
|
|
1243
1293
|
}
|
|
1244
1294
|
function useConsentStateInternal() {
|
|
1245
1295
|
const ctx = React5.useContext(StateCtx);
|
|
1246
|
-
if (!ctx)
|
|
1247
|
-
throw new Error("useConsentState must be used within ConsentProvider");
|
|
1296
|
+
if (!ctx) throw new Error("useConsentState must be used within ConsentProvider");
|
|
1248
1297
|
return ctx;
|
|
1249
1298
|
}
|
|
1250
1299
|
function useConsentActionsInternal() {
|
|
1251
1300
|
const ctx = React5.useContext(ActionsCtx);
|
|
1252
|
-
if (!ctx)
|
|
1253
|
-
throw new Error("useConsentActions must be used within ConsentProvider");
|
|
1301
|
+
if (!ctx) throw new Error("useConsentActions must be used within ConsentProvider");
|
|
1254
1302
|
return ctx;
|
|
1255
1303
|
}
|
|
1256
1304
|
function useConsentTextsInternal() {
|
|
@@ -1260,7 +1308,7 @@ function useConsentTextsInternal() {
|
|
|
1260
1308
|
function useConsentHydrationInternal() {
|
|
1261
1309
|
return React5.useContext(HydrationCtx);
|
|
1262
1310
|
}
|
|
1263
|
-
var React5, import_jsx_runtime7,
|
|
1311
|
+
var React5, import_jsx_runtime7, PreferencesModal, DEFAULT_TEXTS, StateCtx, ActionsCtx, TextsCtx, HydrationCtx, defaultTexts;
|
|
1264
1312
|
var init_ConsentContext = __esm({
|
|
1265
1313
|
"src/context/ConsentContext.tsx"() {
|
|
1266
1314
|
"use strict";
|
|
@@ -1273,21 +1321,10 @@ var init_ConsentContext = __esm({
|
|
|
1273
1321
|
init_DesignContext();
|
|
1274
1322
|
init_developerGuidance();
|
|
1275
1323
|
init_useConsent();
|
|
1324
|
+
init_logger();
|
|
1276
1325
|
init_CookieBanner();
|
|
1277
1326
|
init_FloatingPreferencesButton();
|
|
1278
1327
|
import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1279
|
-
log = {
|
|
1280
|
-
debug: (message, data) => {
|
|
1281
|
-
if (typeof window !== "undefined" && window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
|
1282
|
-
console.debug("[react-lgpd-consent] [DEBUG]", message, data);
|
|
1283
|
-
}
|
|
1284
|
-
},
|
|
1285
|
-
info: (message, data) => {
|
|
1286
|
-
if (typeof window !== "undefined" && window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
|
1287
|
-
console.info("[react-lgpd-consent] [INFO]", message, data);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1291
1328
|
PreferencesModal = React5.lazy(
|
|
1292
1329
|
() => Promise.resolve().then(() => (init_PreferencesModal(), PreferencesModal_exports)).then((m) => ({
|
|
1293
1330
|
default: m.PreferencesModal
|
|
@@ -1334,6 +1371,7 @@ var init_ConsentContext = __esm({
|
|
|
1334
1371
|
ActionsCtx = React5.createContext(null);
|
|
1335
1372
|
TextsCtx = React5.createContext(DEFAULT_TEXTS);
|
|
1336
1373
|
HydrationCtx = React5.createContext(false);
|
|
1374
|
+
defaultTexts = DEFAULT_TEXTS;
|
|
1337
1375
|
}
|
|
1338
1376
|
});
|
|
1339
1377
|
|
|
@@ -1368,7 +1406,7 @@ function openPreferencesModal() {
|
|
|
1368
1406
|
if (globalOpenPreferences) {
|
|
1369
1407
|
globalOpenPreferences();
|
|
1370
1408
|
} else {
|
|
1371
|
-
|
|
1409
|
+
logger.warn(
|
|
1372
1410
|
"openPreferencesModal: ConsentProvider n\xE3o foi inicializado ou n\xE3o est\xE1 dispon\xEDvel."
|
|
1373
1411
|
);
|
|
1374
1412
|
}
|
|
@@ -1384,6 +1422,7 @@ var init_useConsent = __esm({
|
|
|
1384
1422
|
"src/hooks/useConsent.ts"() {
|
|
1385
1423
|
"use strict";
|
|
1386
1424
|
init_ConsentContext();
|
|
1425
|
+
init_logger();
|
|
1387
1426
|
globalOpenPreferences = null;
|
|
1388
1427
|
}
|
|
1389
1428
|
});
|
|
@@ -1400,16 +1439,14 @@ function PreferencesModal2({
|
|
|
1400
1439
|
const { preferences, setPreferences, closePreferences, isModalOpen } = useConsent();
|
|
1401
1440
|
const texts = useConsentTexts();
|
|
1402
1441
|
const { toggleableCategories } = useCategories();
|
|
1403
|
-
const [tempPreferences, setTempPreferences] = (0,
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
);
|
|
1412
|
-
(0, import_react.useEffect)(() => {
|
|
1442
|
+
const [tempPreferences, setTempPreferences] = (0, import_react2.useState)(() => {
|
|
1443
|
+
const initialPrefs = { necessary: true };
|
|
1444
|
+
toggleableCategories.forEach((category) => {
|
|
1445
|
+
initialPrefs[category.id] = preferences[category.id] ?? false;
|
|
1446
|
+
});
|
|
1447
|
+
return initialPrefs;
|
|
1448
|
+
});
|
|
1449
|
+
(0, import_react2.useEffect)(() => {
|
|
1413
1450
|
if (isModalOpen) {
|
|
1414
1451
|
const syncedPrefs = { necessary: true };
|
|
1415
1452
|
toggleableCategories.forEach((category) => {
|
|
@@ -1426,54 +1463,39 @@ function PreferencesModal2({
|
|
|
1426
1463
|
setTempPreferences(preferences);
|
|
1427
1464
|
closePreferences();
|
|
1428
1465
|
};
|
|
1429
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1430
|
-
|
|
1431
|
-
{
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Typography3.default, { variant: "body2", sx: { mb: 2 }, children: texts.modalIntro }),
|
|
1440
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_FormGroup.default, { children: [
|
|
1441
|
-
toggleableCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1442
|
-
import_FormControlLabel.default,
|
|
1443
|
-
{
|
|
1444
|
-
control: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1445
|
-
import_Switch.default,
|
|
1446
|
-
{
|
|
1447
|
-
checked: tempPreferences[category.id] ?? false,
|
|
1448
|
-
onChange: (e) => setTempPreferences((prev) => ({
|
|
1449
|
-
...prev,
|
|
1450
|
-
[category.id]: e.target.checked
|
|
1451
|
-
}))
|
|
1452
|
-
}
|
|
1453
|
-
),
|
|
1454
|
-
label: `${category.name} - ${category.description}`
|
|
1455
|
-
},
|
|
1456
|
-
category.id
|
|
1457
|
-
)),
|
|
1458
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1459
|
-
import_FormControlLabel.default,
|
|
1466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_Dialog.default, { "aria-labelledby": "cookie-pref-title", open, onClose: handleCancel, ...DialogProps2, children: [
|
|
1467
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_DialogTitle.default, { id: "cookie-pref-title", children: texts.modalTitle }),
|
|
1468
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_DialogContent.default, { dividers: true, children: [
|
|
1469
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Typography3.default, { variant: "body2", sx: { mb: 2 }, children: texts.modalIntro }),
|
|
1470
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_FormGroup.default, { children: [
|
|
1471
|
+
toggleableCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1472
|
+
import_FormControlLabel.default,
|
|
1473
|
+
{
|
|
1474
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1475
|
+
import_Switch.default,
|
|
1460
1476
|
{
|
|
1461
|
-
|
|
1462
|
-
|
|
1477
|
+
checked: tempPreferences[category.id] ?? false,
|
|
1478
|
+
onChange: (e) => setTempPreferences((prev) => ({
|
|
1479
|
+
...prev,
|
|
1480
|
+
[category.id]: e.target.checked
|
|
1481
|
+
}))
|
|
1463
1482
|
}
|
|
1464
|
-
)
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1483
|
+
),
|
|
1484
|
+
label: `${category.name} - ${category.description}`
|
|
1485
|
+
},
|
|
1486
|
+
category.id
|
|
1487
|
+
)),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_FormControlLabel.default, { control: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Switch.default, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn })
|
|
1489
|
+
] })
|
|
1490
|
+
] }),
|
|
1491
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_DialogActions.default, { children: [
|
|
1492
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Button2.default, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
1493
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Button2.default, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
1494
|
+
] }),
|
|
1495
|
+
!hideBranding && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Branding, { variant: "modal" })
|
|
1496
|
+
] });
|
|
1475
1497
|
}
|
|
1476
|
-
var import_Button2, import_Dialog, import_DialogActions, import_DialogContent, import_DialogTitle, import_FormControlLabel, import_FormGroup, import_Switch, import_Typography3,
|
|
1498
|
+
var import_Button2, import_Dialog, import_DialogActions, import_DialogContent, import_DialogTitle, import_FormControlLabel, import_FormGroup, import_Switch, import_Typography3, import_react2, import_jsx_runtime8;
|
|
1477
1499
|
var init_PreferencesModal = __esm({
|
|
1478
1500
|
"src/components/PreferencesModal.tsx"() {
|
|
1479
1501
|
"use strict";
|
|
@@ -1486,7 +1508,7 @@ var init_PreferencesModal = __esm({
|
|
|
1486
1508
|
import_FormGroup = __toESM(require("@mui/material/FormGroup"), 1);
|
|
1487
1509
|
import_Switch = __toESM(require("@mui/material/Switch"), 1);
|
|
1488
1510
|
import_Typography3 = __toESM(require("@mui/material/Typography"), 1);
|
|
1489
|
-
|
|
1511
|
+
import_react2 = require("react");
|
|
1490
1512
|
init_CategoriesContext();
|
|
1491
1513
|
init_useConsent();
|
|
1492
1514
|
init_Branding();
|
|
@@ -1501,14 +1523,19 @@ __export(index_exports, {
|
|
|
1501
1523
|
ConsentGate: () => ConsentGate,
|
|
1502
1524
|
ConsentProvider: () => ConsentProvider,
|
|
1503
1525
|
ConsentScriptLoader: () => ConsentScriptLoader,
|
|
1526
|
+
CookieBanner: () => CookieBanner,
|
|
1504
1527
|
DEFAULT_PROJECT_CATEGORIES: () => DEFAULT_PROJECT_CATEGORIES,
|
|
1528
|
+
FloatingPreferencesButton: () => FloatingPreferencesButton,
|
|
1505
1529
|
LogLevel: () => LogLevel,
|
|
1506
1530
|
PreferencesModal: () => PreferencesModal2,
|
|
1507
1531
|
analyzeDeveloperConfiguration: () => analyzeDeveloperConfiguration,
|
|
1508
1532
|
createGoogleAnalyticsIntegration: () => createGoogleAnalyticsIntegration,
|
|
1509
1533
|
createGoogleTagManagerIntegration: () => createGoogleTagManagerIntegration,
|
|
1534
|
+
createProjectPreferences: () => createProjectPreferences,
|
|
1510
1535
|
createUserWayIntegration: () => createUserWayIntegration,
|
|
1511
1536
|
defaultConsentTheme: () => defaultConsentTheme,
|
|
1537
|
+
defaultTexts: () => defaultTexts,
|
|
1538
|
+
getAllProjectCategories: () => getAllProjectCategories,
|
|
1512
1539
|
loadScript: () => loadScript,
|
|
1513
1540
|
openPreferencesModal: () => openPreferencesModal,
|
|
1514
1541
|
setDebugLogging: () => setDebugLogging,
|
|
@@ -1518,7 +1545,8 @@ __export(index_exports, {
|
|
|
1518
1545
|
useConsentHydration: () => useConsentHydration,
|
|
1519
1546
|
useConsentScriptLoader: () => useConsentScriptLoader,
|
|
1520
1547
|
useConsentTexts: () => useConsentTexts,
|
|
1521
|
-
useOpenPreferencesModal: () => useOpenPreferencesModal
|
|
1548
|
+
useOpenPreferencesModal: () => useOpenPreferencesModal,
|
|
1549
|
+
validateProjectPreferences: () => validateProjectPreferences
|
|
1522
1550
|
});
|
|
1523
1551
|
module.exports = __toCommonJS(index_exports);
|
|
1524
1552
|
init_PreferencesModal();
|
|
@@ -1578,6 +1606,7 @@ init_theme();
|
|
|
1578
1606
|
// src/utils/ConsentScriptLoader.tsx
|
|
1579
1607
|
var React6 = __toESM(require("react"), 1);
|
|
1580
1608
|
init_useConsent();
|
|
1609
|
+
init_logger();
|
|
1581
1610
|
function ConsentScriptLoader({
|
|
1582
1611
|
integrations,
|
|
1583
1612
|
reloadOnChange = false
|
|
@@ -1603,7 +1632,7 @@ function ConsentScriptLoader({
|
|
|
1603
1632
|
}
|
|
1604
1633
|
loadedScripts.current.add(integration.id);
|
|
1605
1634
|
} catch (error) {
|
|
1606
|
-
|
|
1635
|
+
logger.error(`\u274C Failed to load script: ${integration.id}`, error);
|
|
1607
1636
|
}
|
|
1608
1637
|
}
|
|
1609
1638
|
});
|
|
@@ -1615,14 +1644,12 @@ function useConsentScriptLoader() {
|
|
|
1615
1644
|
return React6.useCallback(
|
|
1616
1645
|
async (integration) => {
|
|
1617
1646
|
if (!consented) {
|
|
1618
|
-
|
|
1619
|
-
`\u26A0\uFE0F Cannot load script ${integration.id}: No consent given`
|
|
1620
|
-
);
|
|
1647
|
+
logger.warn(`\u26A0\uFE0F Cannot load script ${integration.id}: No consent given`);
|
|
1621
1648
|
return false;
|
|
1622
1649
|
}
|
|
1623
1650
|
const shouldLoad = preferences[integration.category];
|
|
1624
1651
|
if (!shouldLoad) {
|
|
1625
|
-
|
|
1652
|
+
logger.warn(
|
|
1626
1653
|
`\u26A0\uFE0F Cannot load script ${integration.id}: Category '${integration.category}' not consented`
|
|
1627
1654
|
);
|
|
1628
1655
|
return false;
|
|
@@ -1640,7 +1667,7 @@ function useConsentScriptLoader() {
|
|
|
1640
1667
|
}
|
|
1641
1668
|
return true;
|
|
1642
1669
|
} catch (error) {
|
|
1643
|
-
|
|
1670
|
+
logger.error(`\u274C Failed to load script: ${integration.id}`, error);
|
|
1644
1671
|
return false;
|
|
1645
1672
|
}
|
|
1646
1673
|
},
|
|
@@ -1690,8 +1717,7 @@ function createUserWayIntegration(config) {
|
|
|
1690
1717
|
return {
|
|
1691
1718
|
id: "userway",
|
|
1692
1719
|
category: "functional",
|
|
1693
|
-
|
|
1694
|
-
src: `https://cdn.userway.org/widget.js`,
|
|
1720
|
+
src: "https://cdn.userway.org/widget.js",
|
|
1695
1721
|
init: () => {
|
|
1696
1722
|
if (typeof window !== "undefined") {
|
|
1697
1723
|
window.UserWayWidgetApp = window.UserWayWidgetApp || {};
|
|
@@ -1710,20 +1736,29 @@ var COMMON_INTEGRATIONS = {
|
|
|
1710
1736
|
// src/index.ts
|
|
1711
1737
|
init_developerGuidance();
|
|
1712
1738
|
init_logger();
|
|
1739
|
+
init_CookieBanner();
|
|
1740
|
+
init_FloatingPreferencesButton();
|
|
1741
|
+
init_ConsentContext();
|
|
1742
|
+
init_categoryUtils();
|
|
1713
1743
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1714
1744
|
0 && (module.exports = {
|
|
1715
1745
|
COMMON_INTEGRATIONS,
|
|
1716
1746
|
ConsentGate,
|
|
1717
1747
|
ConsentProvider,
|
|
1718
1748
|
ConsentScriptLoader,
|
|
1749
|
+
CookieBanner,
|
|
1719
1750
|
DEFAULT_PROJECT_CATEGORIES,
|
|
1751
|
+
FloatingPreferencesButton,
|
|
1720
1752
|
LogLevel,
|
|
1721
1753
|
PreferencesModal,
|
|
1722
1754
|
analyzeDeveloperConfiguration,
|
|
1723
1755
|
createGoogleAnalyticsIntegration,
|
|
1724
1756
|
createGoogleTagManagerIntegration,
|
|
1757
|
+
createProjectPreferences,
|
|
1725
1758
|
createUserWayIntegration,
|
|
1726
1759
|
defaultConsentTheme,
|
|
1760
|
+
defaultTexts,
|
|
1761
|
+
getAllProjectCategories,
|
|
1727
1762
|
loadScript,
|
|
1728
1763
|
openPreferencesModal,
|
|
1729
1764
|
setDebugLogging,
|
|
@@ -1733,5 +1768,6 @@ init_logger();
|
|
|
1733
1768
|
useConsentHydration,
|
|
1734
1769
|
useConsentScriptLoader,
|
|
1735
1770
|
useConsentTexts,
|
|
1736
|
-
useOpenPreferencesModal
|
|
1771
|
+
useOpenPreferencesModal,
|
|
1772
|
+
validateProjectPreferences
|
|
1737
1773
|
});
|