react-lgpd-consent 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -28
- package/dist/PreferencesModal-LWZAP5OT.js +6 -0
- package/dist/chunk-K3EVSUMQ.js +368 -0
- package/dist/index.cjs +283 -223
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +47 -385
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,43 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
ConsentGate: () => ConsentGate,
|
|
34
|
-
ConsentProvider: () => ConsentProvider,
|
|
35
|
-
CookieBanner: () => CookieBanner,
|
|
36
|
-
PreferencesModal: () => PreferencesModal,
|
|
37
|
-
defaultConsentTheme: () => defaultConsentTheme,
|
|
38
|
-
loadConditionalScript: () => loadConditionalScript,
|
|
39
|
-
loadScript: () => loadScript,
|
|
40
|
-
useConsent: () => useConsent,
|
|
41
|
-
useConsentTexts: () => useConsentTexts
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(index_exports);
|
|
44
|
-
|
|
45
|
-
// src/components/CookieBanner.tsx
|
|
46
|
-
var import_Button = __toESM(require("@mui/material/Button"), 1);
|
|
47
|
-
var import_Box = __toESM(require("@mui/material/Box"), 1);
|
|
48
|
-
var import_Link = __toESM(require("@mui/material/Link"), 1);
|
|
49
|
-
var import_Paper = __toESM(require("@mui/material/Paper"), 1);
|
|
50
|
-
var import_Snackbar = __toESM(require("@mui/material/Snackbar"), 1);
|
|
51
|
-
var import_Stack = __toESM(require("@mui/material/Stack"), 1);
|
|
52
|
-
var import_Typography = __toESM(require("@mui/material/Typography"), 1);
|
|
53
|
-
|
|
54
|
-
// src/context/ConsentContext.tsx
|
|
55
|
-
var React = __toESM(require("react"), 1);
|
|
56
|
-
var import_styles2 = require("@mui/material/styles");
|
|
57
|
-
|
|
58
33
|
// src/utils/cookieUtils.ts
|
|
59
|
-
var import_js_cookie = __toESM(require("js-cookie"), 1);
|
|
60
|
-
var DEFAULT_COOKIE_OPTS = {
|
|
61
|
-
name: "cookieConsent",
|
|
62
|
-
maxAgeDays: 365,
|
|
63
|
-
sameSite: "Lax",
|
|
64
|
-
secure: true,
|
|
65
|
-
path: "/"
|
|
66
|
-
};
|
|
67
34
|
function readConsentCookie(name = DEFAULT_COOKIE_OPTS.name) {
|
|
68
35
|
if (typeof document === "undefined") return null;
|
|
69
36
|
const raw = import_js_cookie.default.get(name);
|
|
@@ -89,95 +56,180 @@ function removeConsentCookie(opts) {
|
|
|
89
56
|
const o = { ...DEFAULT_COOKIE_OPTS, ...opts };
|
|
90
57
|
import_js_cookie.default.remove(o.name, { path: o.path });
|
|
91
58
|
}
|
|
59
|
+
var import_js_cookie, DEFAULT_COOKIE_OPTS;
|
|
60
|
+
var init_cookieUtils = __esm({
|
|
61
|
+
"src/utils/cookieUtils.ts"() {
|
|
62
|
+
"use strict";
|
|
63
|
+
import_js_cookie = __toESM(require("js-cookie"), 1);
|
|
64
|
+
DEFAULT_COOKIE_OPTS = {
|
|
65
|
+
name: "cookieConsent",
|
|
66
|
+
maxAgeDays: 365,
|
|
67
|
+
sameSite: "Lax",
|
|
68
|
+
secure: true,
|
|
69
|
+
path: "/"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
92
73
|
|
|
93
74
|
// src/utils/theme.ts
|
|
94
|
-
var import_styles
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
contrastText: "#ffffff"
|
|
106
|
-
},
|
|
107
|
-
background: {
|
|
108
|
-
default: "#fafafa",
|
|
109
|
-
paper: "#ffffff"
|
|
110
|
-
},
|
|
111
|
-
text: {
|
|
112
|
-
primary: "#333333",
|
|
113
|
-
secondary: "#666666"
|
|
114
|
-
},
|
|
115
|
-
action: {
|
|
116
|
-
hover: "rgba(25, 118, 210, 0.04)"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
typography: {
|
|
120
|
-
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
|
121
|
-
body2: {
|
|
122
|
-
fontSize: "0.875rem",
|
|
123
|
-
lineHeight: 1.43
|
|
124
|
-
},
|
|
125
|
-
button: {
|
|
126
|
-
fontWeight: 500,
|
|
127
|
-
textTransform: "none"
|
|
128
|
-
// Manter capitalização original
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
components: {
|
|
132
|
-
MuiButton: {
|
|
133
|
-
styleOverrides: {
|
|
134
|
-
root: {
|
|
135
|
-
borderRadius: 8,
|
|
136
|
-
paddingX: 16,
|
|
137
|
-
paddingY: 8
|
|
75
|
+
var import_styles, defaultConsentTheme;
|
|
76
|
+
var init_theme = __esm({
|
|
77
|
+
"src/utils/theme.ts"() {
|
|
78
|
+
"use strict";
|
|
79
|
+
import_styles = require("@mui/material/styles");
|
|
80
|
+
defaultConsentTheme = (0, import_styles.createTheme)({
|
|
81
|
+
palette: {
|
|
82
|
+
primary: {
|
|
83
|
+
main: "#1976d2",
|
|
84
|
+
// Azul institucional
|
|
85
|
+
contrastText: "#ffffff"
|
|
138
86
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
87
|
+
secondary: {
|
|
88
|
+
main: "#dc004e",
|
|
89
|
+
// Rosa/vermelho para ações importantes
|
|
90
|
+
contrastText: "#ffffff"
|
|
91
|
+
},
|
|
92
|
+
background: {
|
|
93
|
+
default: "#fafafa",
|
|
94
|
+
paper: "#ffffff"
|
|
95
|
+
},
|
|
96
|
+
text: {
|
|
97
|
+
primary: "#333333",
|
|
98
|
+
secondary: "#666666"
|
|
99
|
+
},
|
|
100
|
+
action: {
|
|
101
|
+
hover: "rgba(25, 118, 210, 0.04)"
|
|
144
102
|
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
103
|
+
},
|
|
104
|
+
typography: {
|
|
105
|
+
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
|
106
|
+
body2: {
|
|
107
|
+
fontSize: "0.875rem",
|
|
108
|
+
lineHeight: 1.43
|
|
109
|
+
},
|
|
110
|
+
button: {
|
|
111
|
+
fontWeight: 500,
|
|
112
|
+
textTransform: "none"
|
|
113
|
+
// Manter capitalização original
|
|
151
114
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
115
|
+
},
|
|
116
|
+
components: {
|
|
117
|
+
MuiButton: {
|
|
118
|
+
styleOverrides: {
|
|
119
|
+
root: {
|
|
120
|
+
borderRadius: 8,
|
|
121
|
+
paddingX: 16,
|
|
122
|
+
paddingY: 8
|
|
123
|
+
},
|
|
124
|
+
contained: {
|
|
125
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
126
|
+
"&:hover": {
|
|
127
|
+
boxShadow: "0 4px 8px rgba(0,0,0,0.15)"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
MuiPaper: {
|
|
133
|
+
styleOverrides: {
|
|
134
|
+
root: {
|
|
135
|
+
borderRadius: 12
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
MuiDialog: {
|
|
140
|
+
styleOverrides: {
|
|
141
|
+
paper: {
|
|
142
|
+
borderRadius: 16
|
|
143
|
+
}
|
|
144
|
+
}
|
|
158
145
|
}
|
|
159
146
|
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// src/components/PreferencesModal.tsx
|
|
152
|
+
var PreferencesModal_exports = {};
|
|
153
|
+
__export(PreferencesModal_exports, {
|
|
154
|
+
PreferencesModal: () => PreferencesModal
|
|
155
|
+
});
|
|
156
|
+
function PreferencesModal({
|
|
157
|
+
DialogProps: DialogProps2
|
|
158
|
+
}) {
|
|
159
|
+
const { preferences, setPreference, closePreferences, isModalOpen } = useConsent();
|
|
160
|
+
const texts = useConsentTexts();
|
|
161
|
+
const open = DialogProps2?.open ?? isModalOpen ?? false;
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
163
|
+
import_Dialog.default,
|
|
164
|
+
{
|
|
165
|
+
"aria-labelledby": "cookie-pref-title",
|
|
166
|
+
open,
|
|
167
|
+
onClose: closePreferences,
|
|
168
|
+
...DialogProps2,
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DialogTitle.default, { id: "cookie-pref-title", children: texts.modalTitle }),
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_DialogContent.default, { dividers: true, children: [
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Typography.default, { variant: "body2", sx: { mb: 2 }, children: texts.modalIntro }),
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_FormGroup.default, { children: [
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
175
|
+
import_FormControlLabel.default,
|
|
176
|
+
{
|
|
177
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
import_Switch.default,
|
|
179
|
+
{
|
|
180
|
+
checked: preferences.analytics,
|
|
181
|
+
onChange: (e) => setPreference("analytics", e.target.checked)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
label: "Cookies Anal\xEDticos (medem uso do site)"
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
188
|
+
import_FormControlLabel.default,
|
|
189
|
+
{
|
|
190
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
191
|
+
import_Switch.default,
|
|
192
|
+
{
|
|
193
|
+
checked: preferences.marketing,
|
|
194
|
+
onChange: (e) => setPreference("marketing", e.target.checked)
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
label: "Cookies de Marketing/Publicidade"
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
+
import_FormControlLabel.default,
|
|
202
|
+
{
|
|
203
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Switch.default, { checked: true, disabled: true }),
|
|
204
|
+
label: texts.necessaryAlwaysOn
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] })
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DialogActions.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { variant: "contained", onClick: closePreferences, children: texts.save }) })
|
|
210
|
+
]
|
|
160
211
|
}
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
var import_Button, import_Dialog, import_DialogActions, import_DialogContent, import_DialogTitle, import_FormControlLabel, import_FormGroup, import_Switch, import_Typography, import_jsx_runtime;
|
|
215
|
+
var init_PreferencesModal = __esm({
|
|
216
|
+
"src/components/PreferencesModal.tsx"() {
|
|
217
|
+
"use strict";
|
|
218
|
+
import_Button = __toESM(require("@mui/material/Button"), 1);
|
|
219
|
+
import_Dialog = __toESM(require("@mui/material/Dialog"), 1);
|
|
220
|
+
import_DialogActions = __toESM(require("@mui/material/DialogActions"), 1);
|
|
221
|
+
import_DialogContent = __toESM(require("@mui/material/DialogContent"), 1);
|
|
222
|
+
import_DialogTitle = __toESM(require("@mui/material/DialogTitle"), 1);
|
|
223
|
+
import_FormControlLabel = __toESM(require("@mui/material/FormControlLabel"), 1);
|
|
224
|
+
import_FormGroup = __toESM(require("@mui/material/FormGroup"), 1);
|
|
225
|
+
import_Switch = __toESM(require("@mui/material/Switch"), 1);
|
|
226
|
+
import_Typography = __toESM(require("@mui/material/Typography"), 1);
|
|
227
|
+
init_useConsent();
|
|
228
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
161
229
|
}
|
|
162
230
|
});
|
|
163
231
|
|
|
164
232
|
// src/context/ConsentContext.tsx
|
|
165
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
166
|
-
var DEFAULT_PREFERENCES = {
|
|
167
|
-
analytics: false,
|
|
168
|
-
marketing: false
|
|
169
|
-
};
|
|
170
|
-
var DEFAULT_TEXTS = {
|
|
171
|
-
bannerMessage: "Utilizamos cookies para melhorar sua experi\xEAncia.",
|
|
172
|
-
acceptAll: "Aceitar todos",
|
|
173
|
-
declineAll: "Recusar",
|
|
174
|
-
preferences: "Prefer\xEAncias",
|
|
175
|
-
policyLink: "Saiba mais",
|
|
176
|
-
modalTitle: "Prefer\xEAncias de Cookies",
|
|
177
|
-
modalIntro: "Ajuste as categorias de cookies. Cookies necess\xE1rios s\xE3o sempre utilizados para funcionalidades b\xE1sicas.",
|
|
178
|
-
save: "Salvar prefer\xEAncias",
|
|
179
|
-
necessaryAlwaysOn: "Cookies necess\xE1rios (sempre ativos)"
|
|
180
|
-
};
|
|
181
233
|
function reducer(state, action) {
|
|
182
234
|
switch (action.type) {
|
|
183
235
|
case "ACCEPT_ALL":
|
|
@@ -217,13 +269,13 @@ function reducer(state, action) {
|
|
|
217
269
|
return state;
|
|
218
270
|
}
|
|
219
271
|
}
|
|
220
|
-
var StateCtx = React.createContext(null);
|
|
221
|
-
var ActionsCtx = React.createContext(null);
|
|
222
|
-
var TextsCtx = React.createContext(DEFAULT_TEXTS);
|
|
223
272
|
function ConsentProvider({
|
|
224
273
|
initialState,
|
|
225
274
|
texts: textsProp,
|
|
226
275
|
theme,
|
|
276
|
+
PreferencesModalComponent,
|
|
277
|
+
preferencesModalProps = {},
|
|
278
|
+
disableAutomaticModal = false,
|
|
227
279
|
onConsentGiven,
|
|
228
280
|
onPreferencesSaved,
|
|
229
281
|
cookie: cookieOpts,
|
|
@@ -290,7 +342,10 @@ function ConsentProvider({
|
|
|
290
342
|
resetConsent
|
|
291
343
|
};
|
|
292
344
|
}, [state, cookie]);
|
|
293
|
-
return /* @__PURE__ */ (0,
|
|
345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_styles2.ThemeProvider, { theme: appliedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StateCtx.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActionsCtx.Provider, { value: api, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(TextsCtx.Provider, { value: texts, children: [
|
|
346
|
+
children,
|
|
347
|
+
!disableAutomaticModal && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(React.Suspense, { fallback: null, children: PreferencesModalComponent ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PreferencesModalComponent, { ...preferencesModalProps }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PreferencesModal2, {}) })
|
|
348
|
+
] }) }) }) });
|
|
294
349
|
}
|
|
295
350
|
function useConsentStateInternal() {
|
|
296
351
|
const ctx = React.useContext(StateCtx);
|
|
@@ -308,6 +363,40 @@ function useConsentTextsInternal() {
|
|
|
308
363
|
const ctx = React.useContext(TextsCtx);
|
|
309
364
|
return ctx;
|
|
310
365
|
}
|
|
366
|
+
var React, import_styles2, import_jsx_runtime2, PreferencesModal2, DEFAULT_PREFERENCES, DEFAULT_TEXTS, StateCtx, ActionsCtx, TextsCtx;
|
|
367
|
+
var init_ConsentContext = __esm({
|
|
368
|
+
"src/context/ConsentContext.tsx"() {
|
|
369
|
+
"use strict";
|
|
370
|
+
React = __toESM(require("react"), 1);
|
|
371
|
+
import_styles2 = require("@mui/material/styles");
|
|
372
|
+
init_cookieUtils();
|
|
373
|
+
init_theme();
|
|
374
|
+
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
375
|
+
PreferencesModal2 = React.lazy(
|
|
376
|
+
() => Promise.resolve().then(() => (init_PreferencesModal(), PreferencesModal_exports)).then((m) => ({
|
|
377
|
+
default: m.PreferencesModal
|
|
378
|
+
}))
|
|
379
|
+
);
|
|
380
|
+
DEFAULT_PREFERENCES = {
|
|
381
|
+
analytics: false,
|
|
382
|
+
marketing: false
|
|
383
|
+
};
|
|
384
|
+
DEFAULT_TEXTS = {
|
|
385
|
+
bannerMessage: "Utilizamos cookies para melhorar sua experi\xEAncia.",
|
|
386
|
+
acceptAll: "Aceitar todos",
|
|
387
|
+
declineAll: "Recusar",
|
|
388
|
+
preferences: "Prefer\xEAncias",
|
|
389
|
+
policyLink: "Saiba mais",
|
|
390
|
+
modalTitle: "Prefer\xEAncias de Cookies",
|
|
391
|
+
modalIntro: "Ajuste as categorias de cookies. Cookies necess\xE1rios s\xE3o sempre utilizados para funcionalidades b\xE1sicas.",
|
|
392
|
+
save: "Salvar prefer\xEAncias",
|
|
393
|
+
necessaryAlwaysOn: "Cookies necess\xE1rios (sempre ativos)"
|
|
394
|
+
};
|
|
395
|
+
StateCtx = React.createContext(null);
|
|
396
|
+
ActionsCtx = React.createContext(null);
|
|
397
|
+
TextsCtx = React.createContext(DEFAULT_TEXTS);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
311
400
|
|
|
312
401
|
// src/hooks/useConsent.ts
|
|
313
402
|
function useConsent() {
|
|
@@ -328,9 +417,37 @@ function useConsent() {
|
|
|
328
417
|
function useConsentTexts() {
|
|
329
418
|
return useConsentTextsInternal();
|
|
330
419
|
}
|
|
420
|
+
var init_useConsent = __esm({
|
|
421
|
+
"src/hooks/useConsent.ts"() {
|
|
422
|
+
"use strict";
|
|
423
|
+
init_ConsentContext();
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// src/index.ts
|
|
428
|
+
var index_exports = {};
|
|
429
|
+
__export(index_exports, {
|
|
430
|
+
ConsentGate: () => ConsentGate,
|
|
431
|
+
ConsentProvider: () => ConsentProvider,
|
|
432
|
+
CookieBanner: () => CookieBanner,
|
|
433
|
+
PreferencesModal: () => PreferencesModal,
|
|
434
|
+
defaultConsentTheme: () => defaultConsentTheme,
|
|
435
|
+
loadScript: () => loadScript,
|
|
436
|
+
useConsent: () => useConsent,
|
|
437
|
+
useConsentTexts: () => useConsentTexts
|
|
438
|
+
});
|
|
439
|
+
module.exports = __toCommonJS(index_exports);
|
|
331
440
|
|
|
332
441
|
// src/components/CookieBanner.tsx
|
|
333
|
-
var
|
|
442
|
+
var import_Button2 = __toESM(require("@mui/material/Button"), 1);
|
|
443
|
+
var import_Box = __toESM(require("@mui/material/Box"), 1);
|
|
444
|
+
var import_Link = __toESM(require("@mui/material/Link"), 1);
|
|
445
|
+
var import_Paper = __toESM(require("@mui/material/Paper"), 1);
|
|
446
|
+
var import_Snackbar = __toESM(require("@mui/material/Snackbar"), 1);
|
|
447
|
+
var import_Stack = __toESM(require("@mui/material/Stack"), 1);
|
|
448
|
+
var import_Typography2 = __toESM(require("@mui/material/Typography"), 1);
|
|
449
|
+
init_useConsent();
|
|
450
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
334
451
|
function CookieBanner({
|
|
335
452
|
policyLinkUrl,
|
|
336
453
|
debug,
|
|
@@ -343,17 +460,17 @@ function CookieBanner({
|
|
|
343
460
|
const texts = useConsentTexts();
|
|
344
461
|
const open = debug ? true : !consented;
|
|
345
462
|
if (!open) return null;
|
|
346
|
-
const bannerContent = /* @__PURE__ */ (0,
|
|
463
|
+
const bannerContent = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
347
464
|
import_Paper.default,
|
|
348
465
|
{
|
|
349
466
|
elevation: 3,
|
|
350
467
|
sx: { p: 2, maxWidth: 720, mx: "auto" },
|
|
351
468
|
...PaperProps,
|
|
352
|
-
children: /* @__PURE__ */ (0,
|
|
353
|
-
/* @__PURE__ */ (0,
|
|
469
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_Stack.default, { spacing: 1, children: [
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_Typography2.default, { variant: "body2", children: [
|
|
354
471
|
texts.bannerMessage,
|
|
355
472
|
" ",
|
|
356
|
-
policyLinkUrl && /* @__PURE__ */ (0,
|
|
473
|
+
policyLinkUrl && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
357
474
|
import_Link.default,
|
|
358
475
|
{
|
|
359
476
|
href: policyLinkUrl,
|
|
@@ -364,16 +481,16 @@ function CookieBanner({
|
|
|
364
481
|
}
|
|
365
482
|
)
|
|
366
483
|
] }),
|
|
367
|
-
/* @__PURE__ */ (0,
|
|
484
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
368
485
|
import_Stack.default,
|
|
369
486
|
{
|
|
370
487
|
direction: { xs: "column", sm: "row" },
|
|
371
488
|
spacing: 1,
|
|
372
489
|
justifyContent: "flex-end",
|
|
373
490
|
children: [
|
|
374
|
-
/* @__PURE__ */ (0,
|
|
375
|
-
/* @__PURE__ */ (0,
|
|
376
|
-
/* @__PURE__ */ (0,
|
|
491
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_Button2.default, { variant: "outlined", onClick: rejectAll, children: texts.declineAll }),
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_Button2.default, { variant: "contained", onClick: acceptAll, children: texts.acceptAll }),
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_Button2.default, { variant: "text", onClick: openPreferences, children: texts.preferences })
|
|
377
494
|
]
|
|
378
495
|
}
|
|
379
496
|
)
|
|
@@ -381,8 +498,8 @@ function CookieBanner({
|
|
|
381
498
|
}
|
|
382
499
|
);
|
|
383
500
|
if (blocking) {
|
|
384
|
-
return /* @__PURE__ */ (0,
|
|
385
|
-
/* @__PURE__ */ (0,
|
|
501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
386
503
|
import_Box.default,
|
|
387
504
|
{
|
|
388
505
|
sx: {
|
|
@@ -397,7 +514,7 @@ function CookieBanner({
|
|
|
397
514
|
}
|
|
398
515
|
}
|
|
399
516
|
),
|
|
400
|
-
/* @__PURE__ */ (0,
|
|
517
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
401
518
|
import_Box.default,
|
|
402
519
|
{
|
|
403
520
|
sx: {
|
|
@@ -414,7 +531,7 @@ function CookieBanner({
|
|
|
414
531
|
)
|
|
415
532
|
] });
|
|
416
533
|
}
|
|
417
|
-
return /* @__PURE__ */ (0,
|
|
534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
418
535
|
import_Snackbar.default,
|
|
419
536
|
{
|
|
420
537
|
open,
|
|
@@ -425,77 +542,13 @@ function CookieBanner({
|
|
|
425
542
|
);
|
|
426
543
|
}
|
|
427
544
|
|
|
428
|
-
// src/
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
var import_DialogContent = __toESM(require("@mui/material/DialogContent"), 1);
|
|
433
|
-
var import_DialogTitle = __toESM(require("@mui/material/DialogTitle"), 1);
|
|
434
|
-
var import_FormControlLabel = __toESM(require("@mui/material/FormControlLabel"), 1);
|
|
435
|
-
var import_FormGroup = __toESM(require("@mui/material/FormGroup"), 1);
|
|
436
|
-
var import_Switch = __toESM(require("@mui/material/Switch"), 1);
|
|
437
|
-
var import_Typography2 = __toESM(require("@mui/material/Typography"), 1);
|
|
438
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
439
|
-
function PreferencesModal({
|
|
440
|
-
DialogProps: DialogProps2
|
|
441
|
-
}) {
|
|
442
|
-
const { preferences, setPreference, closePreferences, isModalOpen } = useConsent();
|
|
443
|
-
const texts = useConsentTexts();
|
|
444
|
-
const open = DialogProps2?.open ?? isModalOpen ?? false;
|
|
445
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
446
|
-
import_Dialog.default,
|
|
447
|
-
{
|
|
448
|
-
"aria-labelledby": "cookie-pref-title",
|
|
449
|
-
open,
|
|
450
|
-
onClose: closePreferences,
|
|
451
|
-
...DialogProps2,
|
|
452
|
-
children: [
|
|
453
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_DialogTitle.default, { id: "cookie-pref-title", children: texts.modalTitle }),
|
|
454
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_DialogContent.default, { dividers: true, children: [
|
|
455
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_Typography2.default, { variant: "body2", sx: { mb: 2 }, children: texts.modalIntro }),
|
|
456
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_FormGroup.default, { children: [
|
|
457
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
458
|
-
import_FormControlLabel.default,
|
|
459
|
-
{
|
|
460
|
-
control: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
461
|
-
import_Switch.default,
|
|
462
|
-
{
|
|
463
|
-
checked: preferences.analytics,
|
|
464
|
-
onChange: (e) => setPreference("analytics", e.target.checked)
|
|
465
|
-
}
|
|
466
|
-
),
|
|
467
|
-
label: "Cookies Anal\xEDticos (medem uso do site)"
|
|
468
|
-
}
|
|
469
|
-
),
|
|
470
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
471
|
-
import_FormControlLabel.default,
|
|
472
|
-
{
|
|
473
|
-
control: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
474
|
-
import_Switch.default,
|
|
475
|
-
{
|
|
476
|
-
checked: preferences.marketing,
|
|
477
|
-
onChange: (e) => setPreference("marketing", e.target.checked)
|
|
478
|
-
}
|
|
479
|
-
),
|
|
480
|
-
label: "Cookies de Marketing/Publicidade"
|
|
481
|
-
}
|
|
482
|
-
),
|
|
483
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
484
|
-
import_FormControlLabel.default,
|
|
485
|
-
{
|
|
486
|
-
control: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_Switch.default, { checked: true, disabled: true }),
|
|
487
|
-
label: texts.necessaryAlwaysOn
|
|
488
|
-
}
|
|
489
|
-
)
|
|
490
|
-
] })
|
|
491
|
-
] }),
|
|
492
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_DialogActions.default, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_Button2.default, { variant: "contained", onClick: closePreferences, children: texts.save }) })
|
|
493
|
-
]
|
|
494
|
-
}
|
|
495
|
-
);
|
|
496
|
-
}
|
|
545
|
+
// src/index.ts
|
|
546
|
+
init_PreferencesModal();
|
|
547
|
+
init_ConsentContext();
|
|
548
|
+
init_useConsent();
|
|
497
549
|
|
|
498
550
|
// src/utils/ConsentGate.tsx
|
|
551
|
+
init_useConsent();
|
|
499
552
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
500
553
|
function ConsentGate(props) {
|
|
501
554
|
const { preferences } = useConsent();
|
|
@@ -504,36 +557,44 @@ function ConsentGate(props) {
|
|
|
504
557
|
}
|
|
505
558
|
|
|
506
559
|
// src/utils/scriptLoader.ts
|
|
507
|
-
function loadScript(id, src, attrs = {}) {
|
|
508
|
-
if (typeof document === "undefined") return;
|
|
509
|
-
if (document.getElementById(id)) return;
|
|
510
|
-
const s = document.createElement("script");
|
|
511
|
-
s.id = id;
|
|
512
|
-
s.src = src;
|
|
513
|
-
s.async = true;
|
|
514
|
-
for (const [k, v] of Object.entries(attrs)) s.setAttribute(k, v);
|
|
515
|
-
document.body.appendChild(s);
|
|
516
|
-
}
|
|
517
|
-
function loadConditionalScript(id, src, condition, attrs = {}, maxWaitMs = 5e3) {
|
|
560
|
+
function loadScript(id, src, category = null, attrs = {}) {
|
|
518
561
|
if (typeof document === "undefined") return Promise.resolve();
|
|
519
562
|
if (document.getElementById(id)) return Promise.resolve();
|
|
520
563
|
return new Promise((resolve, reject) => {
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
if (
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
)
|
|
530
|
-
|
|
531
|
-
|
|
564
|
+
const checkConsent = () => {
|
|
565
|
+
const consentCookie = document.cookie.split("; ").find((row) => row.startsWith("cookieConsent="))?.split("=")[1];
|
|
566
|
+
if (!consentCookie) {
|
|
567
|
+
setTimeout(checkConsent, 100);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
try {
|
|
571
|
+
const consent = JSON.parse(decodeURIComponent(consentCookie));
|
|
572
|
+
if (!consent.consented) {
|
|
573
|
+
setTimeout(checkConsent, 100);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (category && !consent.preferences[category]) {
|
|
577
|
+
reject(new Error(`Consent not given for ${category} scripts`));
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const s = document.createElement("script");
|
|
581
|
+
s.id = id;
|
|
582
|
+
s.src = src;
|
|
583
|
+
s.async = true;
|
|
584
|
+
for (const [k, v] of Object.entries(attrs)) s.setAttribute(k, v);
|
|
585
|
+
s.onload = () => resolve();
|
|
586
|
+
s.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
587
|
+
document.body.appendChild(s);
|
|
588
|
+
} catch {
|
|
589
|
+
setTimeout(checkConsent, 100);
|
|
532
590
|
}
|
|
533
591
|
};
|
|
534
|
-
|
|
592
|
+
checkConsent();
|
|
535
593
|
});
|
|
536
594
|
}
|
|
595
|
+
|
|
596
|
+
// src/index.ts
|
|
597
|
+
init_theme();
|
|
537
598
|
// Annotate the CommonJS export names for ESM import in node:
|
|
538
599
|
0 && (module.exports = {
|
|
539
600
|
ConsentGate,
|
|
@@ -541,7 +602,6 @@ function loadConditionalScript(id, src, condition, attrs = {}, maxWaitMs = 5e3)
|
|
|
541
602
|
CookieBanner,
|
|
542
603
|
PreferencesModal,
|
|
543
604
|
defaultConsentTheme,
|
|
544
|
-
loadConditionalScript,
|
|
545
605
|
loadScript,
|
|
546
606
|
useConsent,
|
|
547
607
|
useConsentTexts
|