react-lgpd-consent 0.4.0 → 0.4.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 +226 -0
- package/QUICKSTART.en.md +34 -0
- package/QUICKSTART.md +562 -1
- package/README.en.md +25 -0
- package/README.md +37 -0
- package/dist/FloatingPreferencesButton-4AGBXNHH.cjs +11 -0
- package/dist/FloatingPreferencesButton-IY7TFD7D.js +2 -0
- package/dist/PreferencesModal-5KNHWW57.js +2 -0
- package/dist/PreferencesModal-YBCWCVUI.cjs +11 -0
- package/dist/chunk-25XEI2DZ.cjs +193 -0
- package/dist/chunk-FJKRAERJ.cjs +119 -0
- package/dist/chunk-N3QOW4SA.js +178 -0
- package/dist/chunk-ORI4PLVG.cjs +1899 -0
- package/dist/chunk-PJFGQMCI.js +92 -0
- package/dist/chunk-RWT2ORFE.js +1840 -0
- package/dist/index.cjs +872 -1560
- package/dist/index.d.cts +1794 -232
- package/dist/index.d.ts +1794 -232
- package/dist/index.js +707 -65
- package/package.json +73 -39
- package/dist/PreferencesModal-D2SEVH3N.js +0 -6
- package/dist/chunk-B5FNONG3.js +0 -1362
package/dist/chunk-B5FNONG3.js
DELETED
|
@@ -1,1362 +0,0 @@
|
|
|
1
|
-
// src/components/PreferencesModal.tsx
|
|
2
|
-
import Button2 from "@mui/material/Button";
|
|
3
|
-
import Dialog from "@mui/material/Dialog";
|
|
4
|
-
import DialogActions from "@mui/material/DialogActions";
|
|
5
|
-
import DialogContent from "@mui/material/DialogContent";
|
|
6
|
-
import DialogTitle from "@mui/material/DialogTitle";
|
|
7
|
-
import FormControlLabel from "@mui/material/FormControlLabel";
|
|
8
|
-
import FormGroup from "@mui/material/FormGroup";
|
|
9
|
-
import Switch from "@mui/material/Switch";
|
|
10
|
-
import Typography3 from "@mui/material/Typography";
|
|
11
|
-
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
12
|
-
|
|
13
|
-
// src/context/CategoriesContext.tsx
|
|
14
|
-
import * as React2 from "react";
|
|
15
|
-
|
|
16
|
-
// src/utils/developerGuidance.ts
|
|
17
|
-
import React from "react";
|
|
18
|
-
var DEFAULT_PROJECT_CATEGORIES = {
|
|
19
|
-
enabledCategories: ["analytics"]
|
|
20
|
-
};
|
|
21
|
-
function analyzeDeveloperConfiguration(config) {
|
|
22
|
-
const guidance = {
|
|
23
|
-
warnings: [],
|
|
24
|
-
suggestions: [],
|
|
25
|
-
activeCategoriesInfo: [],
|
|
26
|
-
usingDefaults: !config
|
|
27
|
-
};
|
|
28
|
-
const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
|
|
29
|
-
if (!config) {
|
|
30
|
-
guidance.warnings.push(
|
|
31
|
-
'LGPD-CONSENT: Nenhuma configura\xE7\xE3o de categorias especificada. Usando padr\xE3o: necessary + analytics. Para produ\xE7\xE3o, recomenda-se especificar explicitamente as categorias via prop "categories".'
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
guidance.activeCategoriesInfo.push({
|
|
35
|
-
id: "necessary",
|
|
36
|
-
name: "Cookies Necess\xE1rios",
|
|
37
|
-
description: "Essenciais para funcionamento b\xE1sico do site",
|
|
38
|
-
essential: true,
|
|
39
|
-
uiRequired: false
|
|
40
|
-
});
|
|
41
|
-
const enabledCategories = finalConfig.enabledCategories || [];
|
|
42
|
-
const categoryNames = {
|
|
43
|
-
analytics: {
|
|
44
|
-
name: "Cookies Anal\xEDticos",
|
|
45
|
-
description: "Medem uso e performance do site"
|
|
46
|
-
},
|
|
47
|
-
functional: {
|
|
48
|
-
name: "Cookies Funcionais",
|
|
49
|
-
description: "Melhoram experi\xEAncia e funcionalidades"
|
|
50
|
-
},
|
|
51
|
-
marketing: {
|
|
52
|
-
name: "Cookies de Marketing",
|
|
53
|
-
description: "Publicidade direcionada e campanhas"
|
|
54
|
-
},
|
|
55
|
-
social: {
|
|
56
|
-
name: "Cookies de Redes Sociais",
|
|
57
|
-
description: "Integra\xE7\xE3o com plataformas sociais"
|
|
58
|
-
},
|
|
59
|
-
personalization: {
|
|
60
|
-
name: "Cookies de Personaliza\xE7\xE3o",
|
|
61
|
-
description: "Adaptam conte\xFAdo \xE0s prefer\xEAncias do usu\xE1rio"
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
enabledCategories.forEach((categoryId) => {
|
|
65
|
-
const categoryInfo = categoryNames[categoryId];
|
|
66
|
-
if (categoryInfo) {
|
|
67
|
-
guidance.activeCategoriesInfo.push({
|
|
68
|
-
id: categoryId,
|
|
69
|
-
name: categoryInfo.name,
|
|
70
|
-
description: categoryInfo.description,
|
|
71
|
-
essential: false,
|
|
72
|
-
uiRequired: true
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
const custom = finalConfig.customCategories || [];
|
|
77
|
-
custom.forEach((cat) => {
|
|
78
|
-
if (!cat?.id || cat.id === "necessary") return;
|
|
79
|
-
guidance.activeCategoriesInfo.push({
|
|
80
|
-
id: cat.id,
|
|
81
|
-
name: cat.name,
|
|
82
|
-
description: cat.description,
|
|
83
|
-
essential: !!cat.essential,
|
|
84
|
-
uiRequired: !cat.essential
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
const totalToggleable = guidance.activeCategoriesInfo.filter((c) => c.uiRequired).length;
|
|
88
|
-
if (totalToggleable === 0) {
|
|
89
|
-
guidance.suggestions.push(
|
|
90
|
-
'Apenas cookies necess\xE1rios est\xE3o configurados. Para compliance completo LGPD, considere adicionar categorias como "analytics" ou "functional" conforme uso real.'
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
if (totalToggleable > 5) {
|
|
94
|
-
guidance.warnings.push(
|
|
95
|
-
`${totalToggleable} categorias opcionais detectadas. UI com muitas op\xE7\xF5es pode prejudicar experi\xEAncia do usu\xE1rio. Considere agrupar categorias similares.`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return guidance;
|
|
99
|
-
}
|
|
100
|
-
function logDeveloperGuidance(guidance, disableGuidanceProp) {
|
|
101
|
-
const gt = globalThis;
|
|
102
|
-
const nodeEnv = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
|
|
103
|
-
const isProd = nodeEnv === "production" || gt.__LGPD_PRODUCTION__ === true;
|
|
104
|
-
const isDisabled = !!disableGuidanceProp || gt.__LGPD_DISABLE_GUIDANCE__ === true;
|
|
105
|
-
if (isProd || isDisabled) return;
|
|
106
|
-
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
107
|
-
if (guidance.warnings.length > 0) {
|
|
108
|
-
console.group(`${PREFIX} \u26A0\uFE0F Avisos de Configura\xE7\xE3o`);
|
|
109
|
-
guidance.warnings.forEach((msg) => console.warn(`${PREFIX} ${msg}`));
|
|
110
|
-
console.groupEnd();
|
|
111
|
-
}
|
|
112
|
-
if (guidance.suggestions.length > 0) {
|
|
113
|
-
console.group(`${PREFIX} \u{1F4A1} Sugest\xF5es`);
|
|
114
|
-
guidance.suggestions.forEach((msg) => console.info(`${PREFIX} ${msg}`));
|
|
115
|
-
console.groupEnd();
|
|
116
|
-
}
|
|
117
|
-
if (guidance.usingDefaults) {
|
|
118
|
-
console.warn(
|
|
119
|
-
`${PREFIX} \u{1F4CB} Usando configura\xE7\xE3o padr\xE3o. Para personalizar, use a prop "categories" no ConsentProvider.`
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
const rows = guidance.activeCategoriesInfo.map((cat) => ({
|
|
123
|
-
ID: cat.id,
|
|
124
|
-
Nome: cat.name,
|
|
125
|
-
"Toggle UI?": cat.uiRequired ? "\u2705 SIM" : "\u274C N\xC3O (sempre ativo)",
|
|
126
|
-
"Essencial?": cat.essential ? "\u{1F512} SIM" : "\u2699\uFE0F N\xC3O"
|
|
127
|
-
}));
|
|
128
|
-
if (typeof console.table === "function") {
|
|
129
|
-
console.group(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`);
|
|
130
|
-
console.table(rows);
|
|
131
|
-
console.info(`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`);
|
|
132
|
-
console.groupEnd();
|
|
133
|
-
} else {
|
|
134
|
-
console.log(`${PREFIX} \u{1F527} Categorias Ativas (para UI customizada)`, rows);
|
|
135
|
-
console.info(`${PREFIX} \u2139\uFE0F Use estes dados para criar componentes customizados adequados.`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function useDeveloperGuidance(config, disableGuidanceProp) {
|
|
139
|
-
const guidance = React.useMemo(() => {
|
|
140
|
-
return analyzeDeveloperConfiguration(config);
|
|
141
|
-
}, [config]);
|
|
142
|
-
React.useEffect(() => {
|
|
143
|
-
if (!disableGuidanceProp) {
|
|
144
|
-
logDeveloperGuidance(guidance, disableGuidanceProp);
|
|
145
|
-
}
|
|
146
|
-
}, [guidance, disableGuidanceProp]);
|
|
147
|
-
return guidance;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/context/CategoriesContext.tsx
|
|
151
|
-
import { jsx } from "react/jsx-runtime";
|
|
152
|
-
var CategoriesContext = React2.createContext(null);
|
|
153
|
-
function CategoriesProvider({
|
|
154
|
-
children,
|
|
155
|
-
config,
|
|
156
|
-
disableDeveloperGuidance
|
|
157
|
-
}) {
|
|
158
|
-
const contextValue = React2.useMemo(() => {
|
|
159
|
-
const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
|
|
160
|
-
const guidance = analyzeDeveloperConfiguration(config);
|
|
161
|
-
const toggleableCategories = guidance.activeCategoriesInfo.filter((cat) => cat.uiRequired);
|
|
162
|
-
return {
|
|
163
|
-
config: finalConfig,
|
|
164
|
-
guidance,
|
|
165
|
-
toggleableCategories,
|
|
166
|
-
allCategories: guidance.activeCategoriesInfo
|
|
167
|
-
};
|
|
168
|
-
}, [config]);
|
|
169
|
-
React2.useEffect(() => {
|
|
170
|
-
logDeveloperGuidance(contextValue.guidance, disableDeveloperGuidance);
|
|
171
|
-
}, [contextValue.guidance, disableDeveloperGuidance]);
|
|
172
|
-
return /* @__PURE__ */ jsx(CategoriesContext.Provider, { value: contextValue, children });
|
|
173
|
-
}
|
|
174
|
-
function useCategories() {
|
|
175
|
-
const context = React2.useContext(CategoriesContext);
|
|
176
|
-
if (!context) {
|
|
177
|
-
throw new Error(
|
|
178
|
-
"useCategories deve ser usado dentro de CategoriesProvider. Certifique-se de que o ConsentProvider est\xE1 envolvendo seu componente."
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
return context;
|
|
182
|
-
}
|
|
183
|
-
function useCategoryStatus(categoryId) {
|
|
184
|
-
const { allCategories } = useCategories();
|
|
185
|
-
const category = allCategories.find((cat) => cat.id === categoryId);
|
|
186
|
-
return {
|
|
187
|
-
isActive: !!category,
|
|
188
|
-
isEssential: category?.essential || false,
|
|
189
|
-
needsToggle: category?.uiRequired || false,
|
|
190
|
-
name: category?.name,
|
|
191
|
-
description: category?.description
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/context/ConsentContext.tsx
|
|
196
|
-
import * as React4 from "react";
|
|
197
|
-
import { ThemeProvider } from "@mui/material/styles";
|
|
198
|
-
|
|
199
|
-
// src/utils/cookieUtils.ts
|
|
200
|
-
import Cookies from "js-cookie";
|
|
201
|
-
|
|
202
|
-
// src/utils/logger.ts
|
|
203
|
-
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
204
|
-
LogLevel2[LogLevel2["ERROR"] = 0] = "ERROR";
|
|
205
|
-
LogLevel2[LogLevel2["WARN"] = 1] = "WARN";
|
|
206
|
-
LogLevel2[LogLevel2["INFO"] = 2] = "INFO";
|
|
207
|
-
LogLevel2[LogLevel2["DEBUG"] = 3] = "DEBUG";
|
|
208
|
-
return LogLevel2;
|
|
209
|
-
})(LogLevel || {});
|
|
210
|
-
var _ConsentLogger = class _ConsentLogger {
|
|
211
|
-
constructor() {
|
|
212
|
-
this.enabled = _ConsentLogger.IS_DEVELOPMENT;
|
|
213
|
-
this.level = 2 /* INFO */;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Habilita ou desabilita o sistema de logging.
|
|
217
|
-
* @param {boolean} enabled Se `true`, os logs serão exibidos; caso contrário, serão suprimidos.
|
|
218
|
-
*/
|
|
219
|
-
setEnabled(enabled) {
|
|
220
|
-
this.enabled = enabled;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Define o nível mínimo de severidade para os logs.
|
|
224
|
-
* Mensagens com severidade menor que o nível definido não serão exibidas.
|
|
225
|
-
* @param {LogLevel} level O nível mínimo de severidade (ex: `LogLevel.DEBUG` para ver todos os logs).
|
|
226
|
-
*/
|
|
227
|
-
setLevel(level) {
|
|
228
|
-
this.level = level;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Registra uma mensagem de erro.
|
|
232
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
233
|
-
*/
|
|
234
|
-
error(...args) {
|
|
235
|
-
if (this.enabled && this.level >= 0 /* ERROR */) {
|
|
236
|
-
console.error(_ConsentLogger.LOG_PREFIX, "[ERROR]", ...args);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Registra uma mensagem de aviso.
|
|
241
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
242
|
-
*/
|
|
243
|
-
warn(...args) {
|
|
244
|
-
if (this.enabled && this.level >= 1 /* WARN */) {
|
|
245
|
-
console.warn(_ConsentLogger.LOG_PREFIX, "[WARN]", ...args);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Registra uma mensagem informativa.
|
|
250
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
251
|
-
*/
|
|
252
|
-
info(...args) {
|
|
253
|
-
if (this.enabled && this.level >= 2 /* INFO */) {
|
|
254
|
-
console.info(_ConsentLogger.LOG_PREFIX, "[INFO]", ...args);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Registra uma mensagem de depuração.
|
|
259
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
260
|
-
*/
|
|
261
|
-
debug(...args) {
|
|
262
|
-
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
263
|
-
console.debug(_ConsentLogger.LOG_PREFIX, "[DEBUG]", ...args);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Inicia um grupo de logs no console.
|
|
268
|
-
* @param {...unknown[]} args Argumentos para o título do grupo.
|
|
269
|
-
*/
|
|
270
|
-
group(...args) {
|
|
271
|
-
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
272
|
-
console.group(_ConsentLogger.LOG_PREFIX, ...args);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Finaliza o grupo de logs mais recente no console.
|
|
277
|
-
*/
|
|
278
|
-
groupEnd() {
|
|
279
|
-
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
280
|
-
console.groupEnd();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Exibe dados tabulares no console.
|
|
285
|
-
* @param {unknown} tabularData Dados a serem exibidos na tabela.
|
|
286
|
-
* @param {string[]} [properties] Propriedades opcionais para exibir.
|
|
287
|
-
*/
|
|
288
|
-
table(tabularData, properties) {
|
|
289
|
-
if (this.enabled && this.level >= 3 /* DEBUG */) {
|
|
290
|
-
console.table(tabularData, properties);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Registra informações sobre a compatibilidade do tema Material-UI.
|
|
295
|
-
* @param {unknown} themeInfo Objeto potencialmente parcial do tema (inspeção segura).
|
|
296
|
-
*/
|
|
297
|
-
themeCompatibility(themeInfo) {
|
|
298
|
-
const isRecord = (v) => typeof v === "object" && v !== null;
|
|
299
|
-
const theme = isRecord(themeInfo) ? themeInfo : void 0;
|
|
300
|
-
const palette = theme && isRecord(theme["palette"]) ? theme["palette"] : void 0;
|
|
301
|
-
const primary = palette && isRecord(palette["primary"]);
|
|
302
|
-
const transitions = theme && isRecord(theme["transitions"]) ? theme["transitions"] : void 0;
|
|
303
|
-
const duration = transitions && isRecord(transitions["duration"]);
|
|
304
|
-
this.debug("Theme compatibility check:", {
|
|
305
|
-
hasTheme: !!theme,
|
|
306
|
-
hasPalette: !!palette,
|
|
307
|
-
hasPrimary: !!primary,
|
|
308
|
-
hasTransitions: !!transitions,
|
|
309
|
-
hasDuration: !!duration
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Registra mudanças no estado de consentimento.
|
|
314
|
-
* @param {string} action Ação que causou a mudança de estado.
|
|
315
|
-
* @param {{ consented?: boolean; isModalOpen?: boolean; preferences?: Record<string, unknown> }} state Estado atual.
|
|
316
|
-
*/
|
|
317
|
-
consentState(action, state) {
|
|
318
|
-
this.debug(`Consent state change [${action}]:`, {
|
|
319
|
-
consented: state.consented,
|
|
320
|
-
isModalOpen: state.isModalOpen,
|
|
321
|
-
preferencesCount: Object.keys(state.preferences || {}).length
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Registra operações de cookie (leitura, escrita, remoção).
|
|
326
|
-
* @param {'read' | 'write' | 'delete'} operation Tipo de operação.
|
|
327
|
-
* @param {string} cookieName Nome do cookie.
|
|
328
|
-
* @param {unknown} [data] Dados associados, se aplicável.
|
|
329
|
-
*/
|
|
330
|
-
cookieOperation(operation, cookieName, data) {
|
|
331
|
-
this.debug(`Cookie ${operation}:`, {
|
|
332
|
-
name: cookieName,
|
|
333
|
-
hasData: !!data,
|
|
334
|
-
dataSize: data ? JSON.stringify(data).length : 0
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Registra a renderização de um componente.
|
|
339
|
-
* @param {string} componentName Nome do componente.
|
|
340
|
-
* @param {Record<string, unknown>} [props] Propriedades do componente.
|
|
341
|
-
*/
|
|
342
|
-
componentRender(componentName, props) {
|
|
343
|
-
this.debug(`Component render [${componentName}]:`, {
|
|
344
|
-
hasProps: !!props,
|
|
345
|
-
propsKeys: props ? Object.keys(props) : []
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Registra o status de carregamento de scripts de integração.
|
|
350
|
-
* @param {string} scriptName O nome do script.
|
|
351
|
-
* @param {'load' | 'remove'} action A ação realizada (carregar ou remover).
|
|
352
|
-
* @param {boolean} success Se a operação foi bem-sucedida.
|
|
353
|
-
*/
|
|
354
|
-
scriptIntegration(scriptName, action, success) {
|
|
355
|
-
this.info(`Script ${action} [${scriptName}]:`, success ? "SUCCESS" : "FAILED");
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Registra chamadas à API interna da biblioteca.
|
|
359
|
-
* @param {string} method Nome do método da API chamado.
|
|
360
|
-
* @param {unknown} [params] Parâmetros passados para o método.
|
|
361
|
-
*/
|
|
362
|
-
apiUsage(method, params) {
|
|
363
|
-
this.debug(`API call [${method}]:`, params);
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
_ConsentLogger.IS_DEVELOPMENT = typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV === "development";
|
|
367
|
-
_ConsentLogger.LOG_PREFIX = "[react-lgpd-consent]";
|
|
368
|
-
var ConsentLogger = _ConsentLogger;
|
|
369
|
-
var logger = new ConsentLogger();
|
|
370
|
-
function setDebugLogging(enabled, level = 2 /* INFO */) {
|
|
371
|
-
logger.setEnabled(enabled);
|
|
372
|
-
logger.setLevel(level);
|
|
373
|
-
logger.info(`Debug logging ${enabled ? "enabled" : "disabled"} with level ${LogLevel[level]}`);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// src/utils/cookieUtils.ts
|
|
377
|
-
var DEFAULT_COOKIE_OPTS = {
|
|
378
|
-
name: "cookieConsent",
|
|
379
|
-
maxAgeDays: 365,
|
|
380
|
-
sameSite: "Lax",
|
|
381
|
-
secure: typeof window !== "undefined" ? window.location.protocol === "https:" : false,
|
|
382
|
-
path: "/"
|
|
383
|
-
};
|
|
384
|
-
var COOKIE_SCHEMA_VERSION = "1.0";
|
|
385
|
-
function readConsentCookie(name = DEFAULT_COOKIE_OPTS.name) {
|
|
386
|
-
logger.debug("Reading consent cookie", { name });
|
|
387
|
-
if (typeof document === "undefined") {
|
|
388
|
-
logger.debug("Cookie read skipped: server-side environment");
|
|
389
|
-
return null;
|
|
390
|
-
}
|
|
391
|
-
const raw = Cookies.get(name);
|
|
392
|
-
if (!raw) {
|
|
393
|
-
logger.debug("No consent cookie found");
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
try {
|
|
397
|
-
const data = JSON.parse(raw);
|
|
398
|
-
logger.cookieOperation("read", name, data);
|
|
399
|
-
if (!data.version) {
|
|
400
|
-
logger.debug("Migrating legacy cookie format");
|
|
401
|
-
return migrateLegacyCookie(data);
|
|
402
|
-
}
|
|
403
|
-
if (data.version !== COOKIE_SCHEMA_VERSION) {
|
|
404
|
-
logger.warn(`Cookie version mismatch: ${data.version} != ${COOKIE_SCHEMA_VERSION}`);
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
return data;
|
|
408
|
-
} catch (error) {
|
|
409
|
-
logger.error("Error parsing consent cookie", error);
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
function migrateLegacyCookie(legacyData) {
|
|
414
|
-
try {
|
|
415
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
416
|
-
return {
|
|
417
|
-
version: COOKIE_SCHEMA_VERSION,
|
|
418
|
-
consented: Boolean(legacyData.consented) || false,
|
|
419
|
-
preferences: legacyData.preferences && typeof legacyData.preferences === "object" ? legacyData.preferences : { necessary: true },
|
|
420
|
-
consentDate: now,
|
|
421
|
-
lastUpdate: now,
|
|
422
|
-
source: "banner",
|
|
423
|
-
isModalOpen: false
|
|
424
|
-
};
|
|
425
|
-
} catch {
|
|
426
|
-
return null;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
function writeConsentCookie(state, config, opts, source = "banner") {
|
|
430
|
-
if (typeof document === "undefined") {
|
|
431
|
-
logger.debug("Cookie write skipped: server-side environment");
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
435
|
-
const o = { ...DEFAULT_COOKIE_OPTS, ...opts };
|
|
436
|
-
const cookieData = {
|
|
437
|
-
version: COOKIE_SCHEMA_VERSION,
|
|
438
|
-
consented: state.consented,
|
|
439
|
-
preferences: state.preferences,
|
|
440
|
-
consentDate: state.consentDate || now,
|
|
441
|
-
lastUpdate: now,
|
|
442
|
-
source,
|
|
443
|
-
projectConfig: config
|
|
444
|
-
};
|
|
445
|
-
logger.cookieOperation("write", o.name, cookieData);
|
|
446
|
-
Cookies.set(o.name, JSON.stringify(cookieData), {
|
|
447
|
-
expires: o.maxAgeDays,
|
|
448
|
-
sameSite: o.sameSite,
|
|
449
|
-
secure: o.secure,
|
|
450
|
-
path: o.path
|
|
451
|
-
});
|
|
452
|
-
logger.info("Consent cookie saved", {
|
|
453
|
-
consented: cookieData.consented,
|
|
454
|
-
source: cookieData.source,
|
|
455
|
-
preferencesCount: Object.keys(cookieData.preferences).length
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
function removeConsentCookie(opts) {
|
|
459
|
-
if (typeof document === "undefined") {
|
|
460
|
-
logger.debug("Cookie removal skipped: server-side environment");
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
const o = { ...DEFAULT_COOKIE_OPTS, ...opts };
|
|
464
|
-
logger.cookieOperation("delete", o.name);
|
|
465
|
-
Cookies.remove(o.name, { path: o.path });
|
|
466
|
-
logger.info("Consent cookie removed");
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// src/utils/categoryUtils.ts
|
|
470
|
-
function createProjectPreferences(config, defaultValue = false) {
|
|
471
|
-
const preferences = {
|
|
472
|
-
necessary: true
|
|
473
|
-
// Sempre presente e true (essencial)
|
|
474
|
-
};
|
|
475
|
-
const enabledCategories = config?.enabledCategories || [];
|
|
476
|
-
enabledCategories.forEach((category) => {
|
|
477
|
-
if (category !== "necessary") {
|
|
478
|
-
preferences[category] = defaultValue;
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
const custom = config?.customCategories || [];
|
|
482
|
-
custom.forEach((cat) => {
|
|
483
|
-
if (cat.id && cat.id !== "necessary") {
|
|
484
|
-
preferences[cat.id] = defaultValue;
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
return preferences;
|
|
488
|
-
}
|
|
489
|
-
function validateProjectPreferences(preferences, config) {
|
|
490
|
-
const validPreferences = {
|
|
491
|
-
necessary: true
|
|
492
|
-
// Sempre válida
|
|
493
|
-
};
|
|
494
|
-
const enabledCategories = config?.enabledCategories || [];
|
|
495
|
-
enabledCategories.forEach((category) => {
|
|
496
|
-
if (category !== "necessary" && preferences[category] !== void 0) {
|
|
497
|
-
validPreferences[category] = preferences[category];
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
const custom = config?.customCategories || [];
|
|
501
|
-
custom.forEach((cat) => {
|
|
502
|
-
const id = cat.id;
|
|
503
|
-
if (id && id !== "necessary" && preferences[id] !== void 0) {
|
|
504
|
-
validPreferences[id] = preferences[id];
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
return validPreferences;
|
|
508
|
-
}
|
|
509
|
-
function getAllProjectCategories(config) {
|
|
510
|
-
const allCategories = [
|
|
511
|
-
{
|
|
512
|
-
id: "necessary",
|
|
513
|
-
name: "Necess\xE1rios",
|
|
514
|
-
description: "Cookies essenciais para funcionamento b\xE1sico do site",
|
|
515
|
-
essential: true
|
|
516
|
-
}
|
|
517
|
-
];
|
|
518
|
-
const enabledCategories = config?.enabledCategories || [];
|
|
519
|
-
enabledCategories.forEach((category) => {
|
|
520
|
-
if (category !== "necessary") {
|
|
521
|
-
allCategories.push(getDefaultCategoryDefinition(category));
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
const custom = config?.customCategories || [];
|
|
525
|
-
custom.forEach((cat) => {
|
|
526
|
-
if (cat.id && cat.id !== "necessary") {
|
|
527
|
-
allCategories.push({ ...cat, essential: !!cat.essential });
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
return allCategories;
|
|
531
|
-
}
|
|
532
|
-
function getDefaultCategoryDefinition(category) {
|
|
533
|
-
const definitions = {
|
|
534
|
-
necessary: {
|
|
535
|
-
id: "necessary",
|
|
536
|
-
name: "Necess\xE1rios",
|
|
537
|
-
description: "Cookies essenciais para funcionamento b\xE1sico do site",
|
|
538
|
-
essential: true
|
|
539
|
-
},
|
|
540
|
-
analytics: {
|
|
541
|
-
id: "analytics",
|
|
542
|
-
name: "An\xE1lise e Estat\xEDsticas",
|
|
543
|
-
description: "Cookies para an\xE1lise de uso e estat\xEDsticas do site",
|
|
544
|
-
essential: false
|
|
545
|
-
},
|
|
546
|
-
functional: {
|
|
547
|
-
id: "functional",
|
|
548
|
-
name: "Funcionalidades",
|
|
549
|
-
description: "Cookies para funcionalidades extras como prefer\xEAncias e idioma",
|
|
550
|
-
essential: false
|
|
551
|
-
},
|
|
552
|
-
marketing: {
|
|
553
|
-
id: "marketing",
|
|
554
|
-
name: "Marketing e Publicidade",
|
|
555
|
-
description: "Cookies para publicidade direcionada e marketing",
|
|
556
|
-
essential: false
|
|
557
|
-
},
|
|
558
|
-
social: {
|
|
559
|
-
id: "social",
|
|
560
|
-
name: "Redes Sociais",
|
|
561
|
-
description: "Cookies para integra\xE7\xE3o com redes sociais e compartilhamento",
|
|
562
|
-
essential: false
|
|
563
|
-
},
|
|
564
|
-
personalization: {
|
|
565
|
-
id: "personalization",
|
|
566
|
-
name: "Personaliza\xE7\xE3o",
|
|
567
|
-
description: "Cookies para personaliza\xE7\xE3o de conte\xFAdo e experi\xEAncia",
|
|
568
|
-
essential: false
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
return definitions[category];
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// src/context/DesignContext.tsx
|
|
575
|
-
import * as React3 from "react";
|
|
576
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
577
|
-
var DesignContext = React3.createContext(void 0);
|
|
578
|
-
function DesignProvider({
|
|
579
|
-
tokens,
|
|
580
|
-
children
|
|
581
|
-
}) {
|
|
582
|
-
return /* @__PURE__ */ jsx2(DesignContext.Provider, { value: tokens, children });
|
|
583
|
-
}
|
|
584
|
-
function useDesignTokens() {
|
|
585
|
-
return React3.useContext(DesignContext);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// src/components/CookieBanner.tsx
|
|
589
|
-
import Button from "@mui/material/Button";
|
|
590
|
-
import Box from "@mui/material/Box";
|
|
591
|
-
import Paper from "@mui/material/Paper";
|
|
592
|
-
import Snackbar from "@mui/material/Snackbar";
|
|
593
|
-
import Stack from "@mui/material/Stack";
|
|
594
|
-
import Typography2 from "@mui/material/Typography";
|
|
595
|
-
import Link2 from "@mui/material/Link";
|
|
596
|
-
|
|
597
|
-
// src/components/Branding.tsx
|
|
598
|
-
import Link from "@mui/material/Link";
|
|
599
|
-
import Typography from "@mui/material/Typography";
|
|
600
|
-
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
601
|
-
var brandingStyles = {
|
|
602
|
-
banner: {
|
|
603
|
-
fontSize: "0.65rem",
|
|
604
|
-
textAlign: "right",
|
|
605
|
-
mt: 1,
|
|
606
|
-
opacity: 0.7,
|
|
607
|
-
fontStyle: "italic",
|
|
608
|
-
width: "100%"
|
|
609
|
-
},
|
|
610
|
-
modal: {
|
|
611
|
-
fontSize: "0.65rem",
|
|
612
|
-
textAlign: "right",
|
|
613
|
-
px: 3,
|
|
614
|
-
pb: 1,
|
|
615
|
-
opacity: 0.7,
|
|
616
|
-
fontStyle: "italic",
|
|
617
|
-
width: "100%"
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
var linkStyles = {
|
|
621
|
-
textDecoration: "none",
|
|
622
|
-
fontWeight: 500,
|
|
623
|
-
"&:hover": {
|
|
624
|
-
textDecoration: "underline"
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
function Branding({ variant, hidden = false }) {
|
|
628
|
-
const texts = useConsentTexts();
|
|
629
|
-
const designTokens = useDesignTokens();
|
|
630
|
-
if (hidden) return null;
|
|
631
|
-
return /* @__PURE__ */ jsxs(
|
|
632
|
-
Typography,
|
|
633
|
-
{
|
|
634
|
-
variant: "caption",
|
|
635
|
-
sx: (theme) => ({
|
|
636
|
-
...brandingStyles[variant],
|
|
637
|
-
color: designTokens?.colors?.text ?? theme.palette.text.secondary
|
|
638
|
-
}),
|
|
639
|
-
children: [
|
|
640
|
-
texts.brandingPoweredBy || "fornecido por",
|
|
641
|
-
" ",
|
|
642
|
-
/* @__PURE__ */ jsx3(
|
|
643
|
-
Link,
|
|
644
|
-
{
|
|
645
|
-
href: "https://www.ledipo.eti.br",
|
|
646
|
-
target: "_blank",
|
|
647
|
-
rel: "noopener noreferrer",
|
|
648
|
-
sx: (theme) => ({
|
|
649
|
-
...linkStyles,
|
|
650
|
-
color: designTokens?.colors?.primary ?? theme.palette.primary.main
|
|
651
|
-
}),
|
|
652
|
-
children: "L\xC9dipO.eti.br"
|
|
653
|
-
}
|
|
654
|
-
)
|
|
655
|
-
]
|
|
656
|
-
}
|
|
657
|
-
);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
// src/components/CookieBanner.tsx
|
|
661
|
-
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
662
|
-
function CookieBanner({
|
|
663
|
-
policyLinkUrl,
|
|
664
|
-
debug,
|
|
665
|
-
blocking = true,
|
|
666
|
-
hideBranding = false,
|
|
667
|
-
SnackbarProps,
|
|
668
|
-
PaperProps
|
|
669
|
-
}) {
|
|
670
|
-
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
671
|
-
const texts = useConsentTexts();
|
|
672
|
-
const isHydrated = useConsentHydration();
|
|
673
|
-
const designTokens = useDesignTokens();
|
|
674
|
-
const open = debug ? true : isHydrated && !consented;
|
|
675
|
-
logger.componentRender("CookieBanner", {
|
|
676
|
-
open,
|
|
677
|
-
consented,
|
|
678
|
-
isHydrated,
|
|
679
|
-
blocking,
|
|
680
|
-
hideBranding
|
|
681
|
-
});
|
|
682
|
-
if (!open) return null;
|
|
683
|
-
const bannerStyle = {
|
|
684
|
-
p: designTokens?.spacing?.padding?.banner ?? 2,
|
|
685
|
-
maxWidth: 720,
|
|
686
|
-
mx: "auto",
|
|
687
|
-
backgroundColor: designTokens?.colors?.background,
|
|
688
|
-
color: designTokens?.colors?.text,
|
|
689
|
-
borderRadius: designTokens?.spacing?.borderRadius?.banner,
|
|
690
|
-
fontFamily: designTokens?.typography?.fontFamily
|
|
691
|
-
};
|
|
692
|
-
const bannerContent = /* @__PURE__ */ jsx4(Paper, { elevation: 3, sx: bannerStyle, ...PaperProps, children: /* @__PURE__ */ jsxs2(Stack, { spacing: 1, children: [
|
|
693
|
-
/* @__PURE__ */ jsxs2(Typography2, { variant: "body2", sx: { fontSize: designTokens?.typography?.fontSize?.banner }, children: [
|
|
694
|
-
texts.bannerMessage,
|
|
695
|
-
" ",
|
|
696
|
-
policyLinkUrl && /* @__PURE__ */ jsx4(
|
|
697
|
-
Link2,
|
|
698
|
-
{
|
|
699
|
-
href: policyLinkUrl,
|
|
700
|
-
underline: "hover",
|
|
701
|
-
target: "_blank",
|
|
702
|
-
rel: "noopener noreferrer",
|
|
703
|
-
sx: { color: designTokens?.colors?.primary },
|
|
704
|
-
children: texts.policyLink ?? "Saiba mais"
|
|
705
|
-
}
|
|
706
|
-
)
|
|
707
|
-
] }),
|
|
708
|
-
/* @__PURE__ */ jsxs2(Stack, { direction: { xs: "column", sm: "row" }, spacing: 1, justifyContent: "flex-end", children: [
|
|
709
|
-
/* @__PURE__ */ jsx4(
|
|
710
|
-
Button,
|
|
711
|
-
{
|
|
712
|
-
variant: "outlined",
|
|
713
|
-
onClick: () => {
|
|
714
|
-
logger.apiUsage("rejectAll", { source: "banner" });
|
|
715
|
-
rejectAll();
|
|
716
|
-
},
|
|
717
|
-
sx: { color: designTokens?.colors?.secondary },
|
|
718
|
-
children: texts.declineAll
|
|
719
|
-
}
|
|
720
|
-
),
|
|
721
|
-
/* @__PURE__ */ jsx4(
|
|
722
|
-
Button,
|
|
723
|
-
{
|
|
724
|
-
variant: "contained",
|
|
725
|
-
onClick: () => {
|
|
726
|
-
logger.apiUsage("acceptAll", { source: "banner" });
|
|
727
|
-
acceptAll();
|
|
728
|
-
},
|
|
729
|
-
sx: { backgroundColor: designTokens?.colors?.primary },
|
|
730
|
-
children: texts.acceptAll
|
|
731
|
-
}
|
|
732
|
-
),
|
|
733
|
-
/* @__PURE__ */ jsx4(
|
|
734
|
-
Button,
|
|
735
|
-
{
|
|
736
|
-
variant: "text",
|
|
737
|
-
onClick: () => {
|
|
738
|
-
logger.apiUsage("openPreferences", { source: "banner" });
|
|
739
|
-
openPreferences();
|
|
740
|
-
},
|
|
741
|
-
sx: { color: designTokens?.colors?.text },
|
|
742
|
-
children: texts.preferences
|
|
743
|
-
}
|
|
744
|
-
)
|
|
745
|
-
] }),
|
|
746
|
-
!hideBranding && /* @__PURE__ */ jsx4(Branding, { variant: "banner" })
|
|
747
|
-
] }) });
|
|
748
|
-
const positionStyle = {
|
|
749
|
-
position: "fixed",
|
|
750
|
-
zIndex: 1300,
|
|
751
|
-
...designTokens?.layout?.position === "top" ? { top: 0 } : { bottom: 0 },
|
|
752
|
-
left: 0,
|
|
753
|
-
right: 0,
|
|
754
|
-
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
755
|
-
p: 2
|
|
756
|
-
};
|
|
757
|
-
let backdropColor = "rgba(0, 0, 0, 0.4)";
|
|
758
|
-
const backdropToken = designTokens?.layout?.backdrop;
|
|
759
|
-
if (backdropToken === false) {
|
|
760
|
-
backdropColor = "transparent";
|
|
761
|
-
} else if (typeof backdropToken === "string") {
|
|
762
|
-
backdropColor = backdropToken;
|
|
763
|
-
}
|
|
764
|
-
if (blocking) {
|
|
765
|
-
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
766
|
-
/* @__PURE__ */ jsx4(
|
|
767
|
-
Box,
|
|
768
|
-
{
|
|
769
|
-
sx: {
|
|
770
|
-
position: "fixed",
|
|
771
|
-
top: 0,
|
|
772
|
-
left: 0,
|
|
773
|
-
right: 0,
|
|
774
|
-
bottom: 0,
|
|
775
|
-
backgroundColor: backdropColor,
|
|
776
|
-
zIndex: 1299
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
),
|
|
780
|
-
/* @__PURE__ */ jsx4(Box, { sx: positionStyle, children: bannerContent })
|
|
781
|
-
] });
|
|
782
|
-
}
|
|
783
|
-
return /* @__PURE__ */ jsx4(
|
|
784
|
-
Snackbar,
|
|
785
|
-
{
|
|
786
|
-
open,
|
|
787
|
-
anchorOrigin: {
|
|
788
|
-
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
789
|
-
horizontal: "center"
|
|
790
|
-
},
|
|
791
|
-
...SnackbarProps,
|
|
792
|
-
children: bannerContent
|
|
793
|
-
}
|
|
794
|
-
);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
// src/components/FloatingPreferencesButton.tsx
|
|
798
|
-
import CookieOutlined from "@mui/icons-material/CookieOutlined";
|
|
799
|
-
import Fab from "@mui/material/Fab";
|
|
800
|
-
import Tooltip from "@mui/material/Tooltip";
|
|
801
|
-
import { useTheme } from "@mui/material/styles";
|
|
802
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
803
|
-
function useThemeWithFallbacks() {
|
|
804
|
-
const theme = useTheme();
|
|
805
|
-
logger.themeCompatibility(theme);
|
|
806
|
-
return {
|
|
807
|
-
palette: {
|
|
808
|
-
primary: {
|
|
809
|
-
main: theme?.palette?.primary?.main || "#1976d2",
|
|
810
|
-
dark: theme?.palette?.primary?.dark || "#1565c0"
|
|
811
|
-
}
|
|
812
|
-
},
|
|
813
|
-
transitions: {
|
|
814
|
-
duration: {
|
|
815
|
-
shortest: theme?.transitions?.duration?.shortest || 150,
|
|
816
|
-
short: theme?.transitions?.duration?.short || 250
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
function FloatingPreferencesButton({
|
|
822
|
-
position = "bottom-right",
|
|
823
|
-
offset = 24,
|
|
824
|
-
icon = /* @__PURE__ */ jsx5(CookieOutlined, {}),
|
|
825
|
-
tooltip,
|
|
826
|
-
FabProps,
|
|
827
|
-
hideWhenConsented = false
|
|
828
|
-
}) {
|
|
829
|
-
const { openPreferences, consented } = useConsent();
|
|
830
|
-
const texts = useConsentTexts();
|
|
831
|
-
const safeTheme = useThemeWithFallbacks();
|
|
832
|
-
const designTokens = useDesignTokens();
|
|
833
|
-
logger.componentRender("FloatingPreferencesButton", {
|
|
834
|
-
position,
|
|
835
|
-
offset,
|
|
836
|
-
hideWhenConsented,
|
|
837
|
-
consented
|
|
838
|
-
});
|
|
839
|
-
if (hideWhenConsented && consented) {
|
|
840
|
-
logger.debug(
|
|
841
|
-
"FloatingPreferencesButton: Hidden due to hideWhenConsented=true and consented=true"
|
|
842
|
-
);
|
|
843
|
-
return null;
|
|
844
|
-
}
|
|
845
|
-
const tooltipText = tooltip ?? texts.preferencesButton ?? "Gerenciar Prefer\xEAncias de Cookies";
|
|
846
|
-
const getPosition = () => {
|
|
847
|
-
const styles = {
|
|
848
|
-
position: "fixed",
|
|
849
|
-
zIndex: 1200
|
|
850
|
-
};
|
|
851
|
-
switch (position) {
|
|
852
|
-
case "bottom-left":
|
|
853
|
-
return { ...styles, bottom: offset, left: offset };
|
|
854
|
-
case "bottom-right":
|
|
855
|
-
return { ...styles, bottom: offset, right: offset };
|
|
856
|
-
case "top-left":
|
|
857
|
-
return { ...styles, top: offset, left: offset };
|
|
858
|
-
case "top-right":
|
|
859
|
-
return { ...styles, top: offset, right: offset };
|
|
860
|
-
default:
|
|
861
|
-
return { ...styles, bottom: offset, right: offset };
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
return /* @__PURE__ */ jsx5(Tooltip, { title: tooltipText, placement: "top", children: /* @__PURE__ */ jsx5(
|
|
865
|
-
Fab,
|
|
866
|
-
{
|
|
867
|
-
size: "medium",
|
|
868
|
-
color: "primary",
|
|
869
|
-
onClick: openPreferences,
|
|
870
|
-
sx: {
|
|
871
|
-
...getPosition(),
|
|
872
|
-
backgroundColor: designTokens?.colors?.primary ?? safeTheme.palette.primary.main,
|
|
873
|
-
"&:hover": {
|
|
874
|
-
backgroundColor: designTokens?.colors?.primary ? designTokens?.colors?.primary : safeTheme.palette.primary.dark
|
|
875
|
-
},
|
|
876
|
-
transition: `all ${safeTheme.transitions.duration.short}ms`
|
|
877
|
-
},
|
|
878
|
-
"aria-label": tooltipText,
|
|
879
|
-
...FabProps,
|
|
880
|
-
children: icon
|
|
881
|
-
}
|
|
882
|
-
) });
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
// src/context/ConsentContext.tsx
|
|
886
|
-
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
887
|
-
var PreferencesModal = React4.lazy(
|
|
888
|
-
() => import("./PreferencesModal-D2SEVH3N.js").then((m) => ({
|
|
889
|
-
default: m.PreferencesModal
|
|
890
|
-
}))
|
|
891
|
-
);
|
|
892
|
-
function createFullConsentState(consented, preferences, source, projectConfig, isModalOpen = false, existingState) {
|
|
893
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
894
|
-
return {
|
|
895
|
-
version: "1.0",
|
|
896
|
-
consented,
|
|
897
|
-
preferences,
|
|
898
|
-
consentDate: existingState?.consentDate || now,
|
|
899
|
-
lastUpdate: now,
|
|
900
|
-
source,
|
|
901
|
-
projectConfig,
|
|
902
|
-
isModalOpen
|
|
903
|
-
};
|
|
904
|
-
}
|
|
905
|
-
var DEFAULT_TEXTS = {
|
|
906
|
-
// Textos básicos
|
|
907
|
-
bannerMessage: "Utilizamos cookies para melhorar sua experi\xEAncia.",
|
|
908
|
-
acceptAll: "Aceitar todos",
|
|
909
|
-
declineAll: "Recusar",
|
|
910
|
-
preferences: "Prefer\xEAncias",
|
|
911
|
-
policyLink: "Saiba mais",
|
|
912
|
-
modalTitle: "Prefer\xEAncias de Cookies",
|
|
913
|
-
modalIntro: "Ajuste as categorias de cookies. Cookies necess\xE1rios s\xE3o sempre utilizados para funcionalidades b\xE1sicas.",
|
|
914
|
-
save: "Salvar prefer\xEAncias",
|
|
915
|
-
necessaryAlwaysOn: "Cookies necess\xE1rios (sempre ativos)",
|
|
916
|
-
// Textos adicionais para UI customizada
|
|
917
|
-
preferencesButton: "Configurar Cookies",
|
|
918
|
-
preferencesTitle: "Gerenciar Prefer\xEAncias de Cookies",
|
|
919
|
-
preferencesDescription: "Escolha quais tipos de cookies voc\xEA permite que sejam utilizados.",
|
|
920
|
-
close: "Fechar",
|
|
921
|
-
accept: "Aceitar",
|
|
922
|
-
reject: "Rejeitar",
|
|
923
|
-
// Textos ANPD expandidos (opcionais)
|
|
924
|
-
brandingPoweredBy: "fornecido por",
|
|
925
|
-
controllerInfo: void 0,
|
|
926
|
-
// Exibido se definido
|
|
927
|
-
dataTypes: void 0,
|
|
928
|
-
// Exibido se definido
|
|
929
|
-
thirdPartySharing: void 0,
|
|
930
|
-
// Exibido se definido
|
|
931
|
-
userRights: void 0,
|
|
932
|
-
// Exibido se definido
|
|
933
|
-
contactInfo: void 0,
|
|
934
|
-
// Exibido se definido
|
|
935
|
-
retentionPeriod: void 0,
|
|
936
|
-
// Exibido se definido
|
|
937
|
-
lawfulBasis: void 0,
|
|
938
|
-
// Exibido se definido
|
|
939
|
-
transferCountries: void 0
|
|
940
|
-
// Exibido se definido
|
|
941
|
-
};
|
|
942
|
-
function reducer(state, action) {
|
|
943
|
-
logger.consentState(action.type, state);
|
|
944
|
-
switch (action.type) {
|
|
945
|
-
case "ACCEPT_ALL": {
|
|
946
|
-
const prefs = createProjectPreferences(action.config, true);
|
|
947
|
-
const newState = createFullConsentState(true, prefs, "banner", action.config, false, state);
|
|
948
|
-
logger.info("User accepted all cookies", {
|
|
949
|
-
preferences: newState.preferences
|
|
950
|
-
});
|
|
951
|
-
return newState;
|
|
952
|
-
}
|
|
953
|
-
case "REJECT_ALL": {
|
|
954
|
-
const prefs = createProjectPreferences(action.config, false);
|
|
955
|
-
const newState = createFullConsentState(true, prefs, "banner", action.config, false, state);
|
|
956
|
-
logger.info("User rejected all cookies", {
|
|
957
|
-
preferences: newState.preferences
|
|
958
|
-
});
|
|
959
|
-
return newState;
|
|
960
|
-
}
|
|
961
|
-
case "SET_CATEGORY":
|
|
962
|
-
logger.debug("Category preference changed", {
|
|
963
|
-
category: action.category,
|
|
964
|
-
value: action.value
|
|
965
|
-
});
|
|
966
|
-
return {
|
|
967
|
-
...state,
|
|
968
|
-
preferences: {
|
|
969
|
-
...state.preferences,
|
|
970
|
-
[action.category]: action.value
|
|
971
|
-
},
|
|
972
|
-
lastUpdate: (/* @__PURE__ */ new Date()).toISOString()
|
|
973
|
-
};
|
|
974
|
-
case "SET_PREFERENCES":
|
|
975
|
-
logger.info("Preferences saved", { preferences: action.preferences });
|
|
976
|
-
return createFullConsentState(true, action.preferences, "modal", action.config, false, state);
|
|
977
|
-
case "OPEN_MODAL":
|
|
978
|
-
return { ...state, isModalOpen: true };
|
|
979
|
-
case "CLOSE_MODAL":
|
|
980
|
-
return createFullConsentState(true, state.preferences, "modal", action.config, false, state);
|
|
981
|
-
case "RESET": {
|
|
982
|
-
return createFullConsentState(
|
|
983
|
-
false,
|
|
984
|
-
createProjectPreferences(action.config),
|
|
985
|
-
"programmatic",
|
|
986
|
-
action.config,
|
|
987
|
-
false
|
|
988
|
-
);
|
|
989
|
-
}
|
|
990
|
-
case "HYDRATE": {
|
|
991
|
-
const validatedPreferences = validateProjectPreferences(
|
|
992
|
-
action.state.preferences,
|
|
993
|
-
action.config
|
|
994
|
-
);
|
|
995
|
-
return {
|
|
996
|
-
...action.state,
|
|
997
|
-
preferences: validatedPreferences,
|
|
998
|
-
isModalOpen: false
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
default:
|
|
1002
|
-
return state;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
var StateCtx = React4.createContext(null);
|
|
1006
|
-
var ActionsCtx = React4.createContext(null);
|
|
1007
|
-
var TextsCtx = React4.createContext(DEFAULT_TEXTS);
|
|
1008
|
-
var HydrationCtx = React4.createContext(false);
|
|
1009
|
-
function ConsentProvider({
|
|
1010
|
-
initialState,
|
|
1011
|
-
categories,
|
|
1012
|
-
texts: textsProp,
|
|
1013
|
-
theme,
|
|
1014
|
-
designTokens,
|
|
1015
|
-
PreferencesModalComponent,
|
|
1016
|
-
preferencesModalProps = {},
|
|
1017
|
-
CookieBannerComponent,
|
|
1018
|
-
cookieBannerProps = {},
|
|
1019
|
-
FloatingPreferencesButtonComponent,
|
|
1020
|
-
floatingPreferencesButtonProps = {},
|
|
1021
|
-
disableFloatingPreferencesButton = false,
|
|
1022
|
-
blocking = false,
|
|
1023
|
-
blockingStrategy = "auto",
|
|
1024
|
-
hideBranding = false,
|
|
1025
|
-
onConsentGiven,
|
|
1026
|
-
onPreferencesSaved,
|
|
1027
|
-
cookie: cookieOpts,
|
|
1028
|
-
disableDeveloperGuidance,
|
|
1029
|
-
children
|
|
1030
|
-
}) {
|
|
1031
|
-
const texts = React4.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
|
|
1032
|
-
const cookie = React4.useMemo(
|
|
1033
|
-
() => ({ ...DEFAULT_COOKIE_OPTS, ...cookieOpts ?? {} }),
|
|
1034
|
-
[cookieOpts]
|
|
1035
|
-
);
|
|
1036
|
-
const mergedTheme = theme;
|
|
1037
|
-
const finalCategoriesConfig = React4.useMemo(() => {
|
|
1038
|
-
if (categories) return categories;
|
|
1039
|
-
return DEFAULT_PROJECT_CATEGORIES;
|
|
1040
|
-
}, [categories]);
|
|
1041
|
-
useDeveloperGuidance(finalCategoriesConfig, disableDeveloperGuidance);
|
|
1042
|
-
const boot = React4.useMemo(() => {
|
|
1043
|
-
if (initialState) return { ...initialState, isModalOpen: false };
|
|
1044
|
-
return createFullConsentState(
|
|
1045
|
-
false,
|
|
1046
|
-
createProjectPreferences(finalCategoriesConfig),
|
|
1047
|
-
"banner",
|
|
1048
|
-
finalCategoriesConfig,
|
|
1049
|
-
false
|
|
1050
|
-
);
|
|
1051
|
-
}, [initialState, finalCategoriesConfig]);
|
|
1052
|
-
const [state, dispatch] = React4.useReducer(reducer, boot);
|
|
1053
|
-
const [isHydrated, setIsHydrated] = React4.useState(false);
|
|
1054
|
-
React4.useEffect(() => {
|
|
1055
|
-
if (!initialState) {
|
|
1056
|
-
const saved = readConsentCookie(cookie.name);
|
|
1057
|
-
if (saved?.consented) {
|
|
1058
|
-
dispatch({
|
|
1059
|
-
type: "HYDRATE",
|
|
1060
|
-
state: saved,
|
|
1061
|
-
config: finalCategoriesConfig
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
setIsHydrated(true);
|
|
1066
|
-
}, [cookie.name, initialState, finalCategoriesConfig]);
|
|
1067
|
-
React4.useEffect(() => {
|
|
1068
|
-
if (state.consented) writeConsentCookie(state, finalCategoriesConfig, cookie);
|
|
1069
|
-
}, [state, cookie, finalCategoriesConfig]);
|
|
1070
|
-
const prevConsented = React4.useRef(state.consented);
|
|
1071
|
-
React4.useEffect(() => {
|
|
1072
|
-
if (!prevConsented.current && state.consented && onConsentGiven) {
|
|
1073
|
-
setTimeout(() => onConsentGiven(state), 150);
|
|
1074
|
-
}
|
|
1075
|
-
prevConsented.current = state.consented;
|
|
1076
|
-
}, [state, onConsentGiven]);
|
|
1077
|
-
const api = React4.useMemo(() => {
|
|
1078
|
-
const acceptAll = () => dispatch({ type: "ACCEPT_ALL", config: finalCategoriesConfig });
|
|
1079
|
-
const rejectAll = () => dispatch({ type: "REJECT_ALL", config: finalCategoriesConfig });
|
|
1080
|
-
const setPreference = (category, value) => dispatch({ type: "SET_CATEGORY", category, value });
|
|
1081
|
-
const setPreferences = (preferences) => {
|
|
1082
|
-
dispatch({
|
|
1083
|
-
type: "SET_PREFERENCES",
|
|
1084
|
-
preferences,
|
|
1085
|
-
config: finalCategoriesConfig
|
|
1086
|
-
});
|
|
1087
|
-
if (onPreferencesSaved) {
|
|
1088
|
-
setTimeout(() => onPreferencesSaved(preferences), 150);
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
const openPreferences = () => dispatch({ type: "OPEN_MODAL" });
|
|
1092
|
-
const closePreferences = () => dispatch({ type: "CLOSE_MODAL", config: finalCategoriesConfig });
|
|
1093
|
-
const resetConsent = () => {
|
|
1094
|
-
removeConsentCookie(cookie);
|
|
1095
|
-
dispatch({ type: "RESET", config: finalCategoriesConfig });
|
|
1096
|
-
};
|
|
1097
|
-
return {
|
|
1098
|
-
consented: !!state.consented,
|
|
1099
|
-
preferences: state.preferences,
|
|
1100
|
-
isModalOpen: state.isModalOpen,
|
|
1101
|
-
acceptAll,
|
|
1102
|
-
rejectAll,
|
|
1103
|
-
setPreference,
|
|
1104
|
-
setPreferences,
|
|
1105
|
-
openPreferences,
|
|
1106
|
-
closePreferences,
|
|
1107
|
-
resetConsent
|
|
1108
|
-
};
|
|
1109
|
-
}, [state, cookie, finalCategoriesConfig, onPreferencesSaved]);
|
|
1110
|
-
React4.useEffect(() => {
|
|
1111
|
-
_registerGlobalOpenPreferences(api.openPreferences);
|
|
1112
|
-
return () => _unregisterGlobalOpenPreferences();
|
|
1113
|
-
}, [api.openPreferences]);
|
|
1114
|
-
const providerBackdropColor = React4.useMemo(() => {
|
|
1115
|
-
const backdrop = designTokens?.layout?.backdrop;
|
|
1116
|
-
if (backdrop === false) return "transparent";
|
|
1117
|
-
if (typeof backdrop === "string") return backdrop;
|
|
1118
|
-
return "rgba(0, 0, 0, 0.4)";
|
|
1119
|
-
}, [designTokens]);
|
|
1120
|
-
const content = /* @__PURE__ */ jsx6(StateCtx.Provider, { value: state, children: /* @__PURE__ */ jsx6(ActionsCtx.Provider, { value: api, children: /* @__PURE__ */ jsx6(TextsCtx.Provider, { value: texts, children: /* @__PURE__ */ jsx6(HydrationCtx.Provider, { value: isHydrated, children: /* @__PURE__ */ jsx6(DesignProvider, { tokens: designTokens, children: /* @__PURE__ */ jsxs3(
|
|
1121
|
-
CategoriesProvider,
|
|
1122
|
-
{
|
|
1123
|
-
config: finalCategoriesConfig,
|
|
1124
|
-
disableDeveloperGuidance,
|
|
1125
|
-
children: [
|
|
1126
|
-
children,
|
|
1127
|
-
/* @__PURE__ */ jsx6(React4.Suspense, { fallback: null, children: PreferencesModalComponent ? /* @__PURE__ */ jsx6(
|
|
1128
|
-
PreferencesModalComponent,
|
|
1129
|
-
{
|
|
1130
|
-
preferences: api.preferences,
|
|
1131
|
-
setPreferences: api.setPreferences,
|
|
1132
|
-
closePreferences: api.closePreferences,
|
|
1133
|
-
isModalOpen: api.isModalOpen,
|
|
1134
|
-
texts,
|
|
1135
|
-
...preferencesModalProps
|
|
1136
|
-
}
|
|
1137
|
-
) : /* @__PURE__ */ jsx6(PreferencesModal, { hideBranding }) }),
|
|
1138
|
-
blocking && isHydrated && !state.consented && blockingStrategy === "provider" && /* @__PURE__ */ jsx6(
|
|
1139
|
-
"div",
|
|
1140
|
-
{
|
|
1141
|
-
style: {
|
|
1142
|
-
position: "fixed",
|
|
1143
|
-
top: 0,
|
|
1144
|
-
left: 0,
|
|
1145
|
-
right: 0,
|
|
1146
|
-
bottom: 0,
|
|
1147
|
-
backgroundColor: providerBackdropColor,
|
|
1148
|
-
zIndex: 1299
|
|
1149
|
-
},
|
|
1150
|
-
"data-testid": "lgpd-provider-overlay",
|
|
1151
|
-
"aria-hidden": true
|
|
1152
|
-
}
|
|
1153
|
-
),
|
|
1154
|
-
!state.consented && isHydrated && (CookieBannerComponent ? /* @__PURE__ */ jsx6(
|
|
1155
|
-
CookieBannerComponent,
|
|
1156
|
-
{
|
|
1157
|
-
consented: api.consented,
|
|
1158
|
-
acceptAll: api.acceptAll,
|
|
1159
|
-
rejectAll: api.rejectAll,
|
|
1160
|
-
openPreferences: api.openPreferences,
|
|
1161
|
-
texts,
|
|
1162
|
-
blocking,
|
|
1163
|
-
...cookieBannerProps
|
|
1164
|
-
}
|
|
1165
|
-
) : /* @__PURE__ */ jsx6(
|
|
1166
|
-
CookieBanner,
|
|
1167
|
-
{
|
|
1168
|
-
blocking,
|
|
1169
|
-
hideBranding,
|
|
1170
|
-
...cookieBannerProps
|
|
1171
|
-
}
|
|
1172
|
-
)),
|
|
1173
|
-
state.consented && !disableFloatingPreferencesButton && (FloatingPreferencesButtonComponent ? /* @__PURE__ */ jsx6(
|
|
1174
|
-
FloatingPreferencesButtonComponent,
|
|
1175
|
-
{
|
|
1176
|
-
openPreferences: api.openPreferences,
|
|
1177
|
-
consented: api.consented,
|
|
1178
|
-
...floatingPreferencesButtonProps
|
|
1179
|
-
}
|
|
1180
|
-
) : (
|
|
1181
|
-
// Encaminha `floatingPreferencesButtonProps` para o componente padrão
|
|
1182
|
-
/* @__PURE__ */ jsx6(
|
|
1183
|
-
FloatingPreferencesButton,
|
|
1184
|
-
{
|
|
1185
|
-
...floatingPreferencesButtonProps ?? {}
|
|
1186
|
-
}
|
|
1187
|
-
)
|
|
1188
|
-
))
|
|
1189
|
-
]
|
|
1190
|
-
}
|
|
1191
|
-
) }) }) }) }) });
|
|
1192
|
-
if (mergedTheme) {
|
|
1193
|
-
return /* @__PURE__ */ jsx6(ThemeProvider, { theme: mergedTheme, children: content });
|
|
1194
|
-
}
|
|
1195
|
-
return content;
|
|
1196
|
-
}
|
|
1197
|
-
function useConsentStateInternal() {
|
|
1198
|
-
const ctx = React4.useContext(StateCtx);
|
|
1199
|
-
if (!ctx) throw new Error("useConsentState must be used within ConsentProvider");
|
|
1200
|
-
return ctx;
|
|
1201
|
-
}
|
|
1202
|
-
function useConsentActionsInternal() {
|
|
1203
|
-
const ctx = React4.useContext(ActionsCtx);
|
|
1204
|
-
if (!ctx) throw new Error("useConsentActions must be used within ConsentProvider");
|
|
1205
|
-
return ctx;
|
|
1206
|
-
}
|
|
1207
|
-
function useConsentTextsInternal() {
|
|
1208
|
-
const ctx = React4.useContext(TextsCtx);
|
|
1209
|
-
return ctx;
|
|
1210
|
-
}
|
|
1211
|
-
function useConsentHydrationInternal() {
|
|
1212
|
-
return React4.useContext(HydrationCtx);
|
|
1213
|
-
}
|
|
1214
|
-
var defaultTexts = DEFAULT_TEXTS;
|
|
1215
|
-
|
|
1216
|
-
// src/hooks/useConsent.ts
|
|
1217
|
-
function useConsent() {
|
|
1218
|
-
const state = useConsentStateInternal();
|
|
1219
|
-
const actions = useConsentActionsInternal();
|
|
1220
|
-
return {
|
|
1221
|
-
consented: state.consented,
|
|
1222
|
-
preferences: state.preferences,
|
|
1223
|
-
isModalOpen: state.isModalOpen,
|
|
1224
|
-
acceptAll: actions.acceptAll,
|
|
1225
|
-
rejectAll: actions.rejectAll,
|
|
1226
|
-
setPreference: actions.setPreference,
|
|
1227
|
-
setPreferences: actions.setPreferences,
|
|
1228
|
-
openPreferences: actions.openPreferences,
|
|
1229
|
-
closePreferences: actions.closePreferences,
|
|
1230
|
-
resetConsent: actions.resetConsent
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
function useConsentTexts() {
|
|
1234
|
-
return useConsentTextsInternal();
|
|
1235
|
-
}
|
|
1236
|
-
function useConsentHydration() {
|
|
1237
|
-
return useConsentHydrationInternal();
|
|
1238
|
-
}
|
|
1239
|
-
function useOpenPreferencesModal() {
|
|
1240
|
-
const { openPreferences } = useConsent();
|
|
1241
|
-
return openPreferences;
|
|
1242
|
-
}
|
|
1243
|
-
var globalOpenPreferences = null;
|
|
1244
|
-
function openPreferencesModal() {
|
|
1245
|
-
if (globalOpenPreferences) {
|
|
1246
|
-
globalOpenPreferences();
|
|
1247
|
-
} else {
|
|
1248
|
-
logger.warn(
|
|
1249
|
-
"openPreferencesModal: ConsentProvider n\xE3o foi inicializado ou n\xE3o est\xE1 dispon\xEDvel."
|
|
1250
|
-
);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
function _registerGlobalOpenPreferences(openPreferences) {
|
|
1254
|
-
globalOpenPreferences = openPreferences;
|
|
1255
|
-
}
|
|
1256
|
-
function _unregisterGlobalOpenPreferences() {
|
|
1257
|
-
globalOpenPreferences = null;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
// src/components/PreferencesModal.tsx
|
|
1261
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1262
|
-
function PreferencesModal2({
|
|
1263
|
-
DialogProps: DialogProps2,
|
|
1264
|
-
hideBranding = false
|
|
1265
|
-
}) {
|
|
1266
|
-
const { preferences, setPreferences, closePreferences, isModalOpen } = useConsent();
|
|
1267
|
-
const texts = useConsentTexts();
|
|
1268
|
-
const designTokens = useDesignTokens();
|
|
1269
|
-
const { toggleableCategories } = useCategories();
|
|
1270
|
-
const [tempPreferences, setTempPreferences] = useState2(() => {
|
|
1271
|
-
const initialPrefs = { necessary: true };
|
|
1272
|
-
toggleableCategories.forEach((category) => {
|
|
1273
|
-
initialPrefs[category.id] = preferences[category.id] ?? false;
|
|
1274
|
-
});
|
|
1275
|
-
return initialPrefs;
|
|
1276
|
-
});
|
|
1277
|
-
useEffect3(() => {
|
|
1278
|
-
if (isModalOpen) {
|
|
1279
|
-
const syncedPrefs = { necessary: true };
|
|
1280
|
-
toggleableCategories.forEach((category) => {
|
|
1281
|
-
syncedPrefs[category.id] = preferences[category.id] ?? false;
|
|
1282
|
-
});
|
|
1283
|
-
setTempPreferences(syncedPrefs);
|
|
1284
|
-
}
|
|
1285
|
-
}, [isModalOpen, preferences, toggleableCategories]);
|
|
1286
|
-
const open = DialogProps2?.open ?? isModalOpen ?? false;
|
|
1287
|
-
const handleSave = () => {
|
|
1288
|
-
setPreferences(tempPreferences);
|
|
1289
|
-
};
|
|
1290
|
-
const handleCancel = () => {
|
|
1291
|
-
setTempPreferences(preferences);
|
|
1292
|
-
closePreferences();
|
|
1293
|
-
};
|
|
1294
|
-
return /* @__PURE__ */ jsxs4(Dialog, { "aria-labelledby": "cookie-pref-title", open, onClose: handleCancel, ...DialogProps2, children: [
|
|
1295
|
-
/* @__PURE__ */ jsx7(
|
|
1296
|
-
DialogTitle,
|
|
1297
|
-
{
|
|
1298
|
-
id: "cookie-pref-title",
|
|
1299
|
-
sx: { fontSize: designTokens?.typography?.fontSize?.modal ?? void 0 },
|
|
1300
|
-
children: texts.modalTitle
|
|
1301
|
-
}
|
|
1302
|
-
),
|
|
1303
|
-
/* @__PURE__ */ jsxs4(DialogContent, { dividers: true, sx: { p: designTokens?.spacing?.padding?.modal ?? void 0 }, children: [
|
|
1304
|
-
/* @__PURE__ */ jsx7(
|
|
1305
|
-
Typography3,
|
|
1306
|
-
{
|
|
1307
|
-
variant: "body2",
|
|
1308
|
-
sx: { mb: 2, fontSize: designTokens?.typography?.fontSize?.modal ?? void 0 },
|
|
1309
|
-
children: texts.modalIntro
|
|
1310
|
-
}
|
|
1311
|
-
),
|
|
1312
|
-
/* @__PURE__ */ jsxs4(FormGroup, { children: [
|
|
1313
|
-
toggleableCategories.map((category) => /* @__PURE__ */ jsx7(
|
|
1314
|
-
FormControlLabel,
|
|
1315
|
-
{
|
|
1316
|
-
control: /* @__PURE__ */ jsx7(
|
|
1317
|
-
Switch,
|
|
1318
|
-
{
|
|
1319
|
-
checked: tempPreferences[category.id] ?? false,
|
|
1320
|
-
onChange: (e) => setTempPreferences((prev) => ({
|
|
1321
|
-
...prev,
|
|
1322
|
-
[category.id]: e.target.checked
|
|
1323
|
-
}))
|
|
1324
|
-
}
|
|
1325
|
-
),
|
|
1326
|
-
label: `${category.name} - ${category.description}`
|
|
1327
|
-
},
|
|
1328
|
-
category.id
|
|
1329
|
-
)),
|
|
1330
|
-
/* @__PURE__ */ jsx7(FormControlLabel, { control: /* @__PURE__ */ jsx7(Switch, { checked: true, disabled: true }), label: texts.necessaryAlwaysOn })
|
|
1331
|
-
] })
|
|
1332
|
-
] }),
|
|
1333
|
-
/* @__PURE__ */ jsxs4(DialogActions, { children: [
|
|
1334
|
-
/* @__PURE__ */ jsx7(Button2, { variant: "outlined", onClick: handleCancel, children: texts.close }),
|
|
1335
|
-
/* @__PURE__ */ jsx7(Button2, { variant: "contained", onClick: handleSave, children: texts.save })
|
|
1336
|
-
] }),
|
|
1337
|
-
!hideBranding && /* @__PURE__ */ jsx7(Branding, { variant: "modal" })
|
|
1338
|
-
] });
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
export {
|
|
1342
|
-
DEFAULT_PROJECT_CATEGORIES,
|
|
1343
|
-
analyzeDeveloperConfiguration,
|
|
1344
|
-
useCategories,
|
|
1345
|
-
useCategoryStatus,
|
|
1346
|
-
LogLevel,
|
|
1347
|
-
logger,
|
|
1348
|
-
setDebugLogging,
|
|
1349
|
-
createProjectPreferences,
|
|
1350
|
-
validateProjectPreferences,
|
|
1351
|
-
getAllProjectCategories,
|
|
1352
|
-
CookieBanner,
|
|
1353
|
-
FloatingPreferencesButton,
|
|
1354
|
-
ConsentProvider,
|
|
1355
|
-
defaultTexts,
|
|
1356
|
-
useConsent,
|
|
1357
|
-
useConsentTexts,
|
|
1358
|
-
useConsentHydration,
|
|
1359
|
-
useOpenPreferencesModal,
|
|
1360
|
-
openPreferencesModal,
|
|
1361
|
-
PreferencesModal2 as PreferencesModal
|
|
1362
|
-
};
|