react-lgpd-consent 0.2.5 → 0.3.1

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/dist/index.js CHANGED
@@ -1,188 +1,26 @@
1
1
  import {
2
- Branding,
3
2
  ConsentProvider,
4
3
  DEFAULT_PROJECT_CATEGORIES,
4
+ LogLevel,
5
5
  PreferencesModal,
6
6
  analyzeDeveloperConfiguration,
7
7
  defaultConsentTheme,
8
+ openPreferencesModal,
9
+ setDebugLogging,
8
10
  useCategories,
9
11
  useCategoryStatus,
10
12
  useConsent,
11
13
  useConsentHydration,
12
14
  useConsentTexts,
13
- useCustomCategories
14
- } from "./chunk-4LLZREFO.js";
15
-
16
- // src/components/CookieBanner.tsx
17
- import Button from "@mui/material/Button";
18
- import Box from "@mui/material/Box";
19
- import Paper from "@mui/material/Paper";
20
- import Snackbar from "@mui/material/Snackbar";
21
- import Stack from "@mui/material/Stack";
22
- import Typography from "@mui/material/Typography";
23
- import Link from "@mui/material/Link";
24
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
25
- function CookieBanner({
26
- policyLinkUrl,
27
- debug,
28
- blocking = true,
29
- // Por padrão, bloqueia até decisão
30
- hideBranding = false,
31
- SnackbarProps,
32
- PaperProps
33
- }) {
34
- const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
35
- const texts = useConsentTexts();
36
- const isHydrated = useConsentHydration();
37
- const open = debug ? true : isHydrated && !consented;
38
- if (!open) return null;
39
- const bannerContent = /* @__PURE__ */ jsx(
40
- Paper,
41
- {
42
- elevation: 3,
43
- sx: { p: 2, maxWidth: 720, mx: "auto" },
44
- ...PaperProps,
45
- children: /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
46
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
47
- texts.bannerMessage,
48
- " ",
49
- policyLinkUrl && /* @__PURE__ */ jsx(
50
- Link,
51
- {
52
- href: policyLinkUrl,
53
- underline: "hover",
54
- target: "_blank",
55
- rel: "noopener noreferrer",
56
- children: texts.policyLink ?? "Saiba mais"
57
- }
58
- )
59
- ] }),
60
- /* @__PURE__ */ jsxs(
61
- Stack,
62
- {
63
- direction: { xs: "column", sm: "row" },
64
- spacing: 1,
65
- justifyContent: "flex-end",
66
- children: [
67
- /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: rejectAll, children: texts.declineAll }),
68
- /* @__PURE__ */ jsx(Button, { variant: "contained", onClick: acceptAll, children: texts.acceptAll }),
69
- /* @__PURE__ */ jsx(Button, { variant: "text", onClick: openPreferences, children: texts.preferences })
70
- ]
71
- }
72
- ),
73
- !hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "banner" })
74
- ] })
75
- }
76
- );
77
- if (blocking) {
78
- return /* @__PURE__ */ jsxs(Fragment, { children: [
79
- /* @__PURE__ */ jsx(
80
- Box,
81
- {
82
- sx: {
83
- position: "fixed",
84
- top: 0,
85
- left: 0,
86
- right: 0,
87
- bottom: 0,
88
- backgroundColor: "rgba(0, 0, 0, 0.5)",
89
- zIndex: 1299
90
- // Abaixo do banner mas acima do conteúdo
91
- }
92
- }
93
- ),
94
- /* @__PURE__ */ jsx(
95
- Box,
96
- {
97
- sx: {
98
- position: "fixed",
99
- bottom: 0,
100
- left: 0,
101
- right: 0,
102
- zIndex: 1300,
103
- // Acima do overlay
104
- p: 2
105
- },
106
- children: bannerContent
107
- }
108
- )
109
- ] });
110
- }
111
- return /* @__PURE__ */ jsx(
112
- Snackbar,
113
- {
114
- open,
115
- anchorOrigin: { vertical: "bottom", horizontal: "center" },
116
- ...SnackbarProps,
117
- children: bannerContent
118
- }
119
- );
120
- }
121
-
122
- // src/components/FloatingPreferencesButton.tsx
123
- import CookieOutlined from "@mui/icons-material/CookieOutlined";
124
- import Fab from "@mui/material/Fab";
125
- import Tooltip from "@mui/material/Tooltip";
126
- import { useTheme } from "@mui/material/styles";
127
- import { jsx as jsx2 } from "react/jsx-runtime";
128
- function FloatingPreferencesButton({
129
- position = "bottom-right",
130
- offset = 24,
131
- icon = /* @__PURE__ */ jsx2(CookieOutlined, {}),
132
- tooltip,
133
- FabProps,
134
- hideWhenConsented = false
135
- }) {
136
- const { openPreferences, consented } = useConsent();
137
- const theme = useTheme();
138
- if (hideWhenConsented && consented) {
139
- return null;
140
- }
141
- const tooltipText = tooltip ?? "Gerenciar Prefer\xEAncias de Cookies";
142
- const getPosition = () => {
143
- const styles = {
144
- position: "fixed",
145
- zIndex: 1200
146
- };
147
- switch (position) {
148
- case "bottom-left":
149
- return { ...styles, bottom: offset, left: offset };
150
- case "bottom-right":
151
- return { ...styles, bottom: offset, right: offset };
152
- case "top-left":
153
- return { ...styles, top: offset, left: offset };
154
- case "top-right":
155
- return { ...styles, top: offset, right: offset };
156
- default:
157
- return { ...styles, bottom: offset, right: offset };
158
- }
159
- };
160
- return /* @__PURE__ */ jsx2(Tooltip, { title: tooltipText, placement: "top", children: /* @__PURE__ */ jsx2(
161
- Fab,
162
- {
163
- size: "medium",
164
- color: "primary",
165
- onClick: openPreferences,
166
- sx: {
167
- ...getPosition(),
168
- backgroundColor: theme.palette.primary.main,
169
- "&:hover": {
170
- backgroundColor: theme.palette.primary.dark
171
- }
172
- },
173
- "aria-label": tooltipText,
174
- ...FabProps,
175
- children: icon
176
- }
177
- ) });
178
- }
15
+ useOpenPreferencesModal
16
+ } from "./chunk-VFAOBR3X.js";
179
17
 
180
18
  // src/utils/ConsentGate.tsx
181
- import { Fragment as Fragment2, jsx as jsx3 } from "react/jsx-runtime";
19
+ import { Fragment, jsx } from "react/jsx-runtime";
182
20
  function ConsentGate(props) {
183
21
  const { preferences } = useConsent();
184
22
  if (!preferences[props.category]) return null;
185
- return /* @__PURE__ */ jsx3(Fragment2, { children: props.children });
23
+ return /* @__PURE__ */ jsx(Fragment, { children: props.children });
186
24
  }
187
25
 
188
26
  // src/utils/scriptLoader.ts
@@ -248,9 +86,6 @@ function ConsentScriptLoader({
248
86
  integration.init();
249
87
  }
250
88
  loadedScripts.current.add(integration.id);
251
- console.log(
252
- `\u2705 Script loaded: ${integration.id} (${integration.category})`
253
- );
254
89
  } catch (error) {
255
90
  console.error(`\u274C Failed to load script: ${integration.id}`, error);
256
91
  }
@@ -287,9 +122,6 @@ function useConsentScriptLoader() {
287
122
  if (integration.init) {
288
123
  integration.init();
289
124
  }
290
- console.log(
291
- `\u2705 Script loaded: ${integration.id} (${integration.category})`
292
- );
293
125
  return true;
294
126
  } catch (error) {
295
127
  console.error(`\u274C Failed to load script: ${integration.id}`, error);
@@ -341,8 +173,8 @@ function createGoogleTagManagerIntegration(config) {
341
173
  function createUserWayIntegration(config) {
342
174
  return {
343
175
  id: "userway",
344
- category: "marketing",
345
- // ou poderia ser uma categoria 'accessibility'
176
+ category: "functional",
177
+ // Categoria mais apropriada para acessibilidade
346
178
  src: `https://cdn.userway.org/widget.js`,
347
179
  init: () => {
348
180
  if (typeof window !== "undefined") {
@@ -363,9 +195,8 @@ export {
363
195
  ConsentGate,
364
196
  ConsentProvider,
365
197
  ConsentScriptLoader,
366
- CookieBanner,
367
198
  DEFAULT_PROJECT_CATEGORIES,
368
- FloatingPreferencesButton,
199
+ LogLevel,
369
200
  PreferencesModal,
370
201
  analyzeDeveloperConfiguration,
371
202
  createGoogleAnalyticsIntegration,
@@ -373,11 +204,13 @@ export {
373
204
  createUserWayIntegration,
374
205
  defaultConsentTheme,
375
206
  loadScript,
207
+ openPreferencesModal,
208
+ setDebugLogging,
376
209
  useCategories,
377
210
  useCategoryStatus,
378
211
  useConsent,
379
212
  useConsentHydration,
380
213
  useConsentScriptLoader,
381
214
  useConsentTexts,
382
- useCustomCategories
215
+ useOpenPreferencesModal
383
216
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-lgpd-consent",
3
- "version": "0.2.5",
3
+ "version": "0.3.1",
4
4
  "description": "Biblioteca completa de consentimento LGPD com 6 categorias ANPD, integrações nativas e sistema extensível para React.",
5
5
  "keywords": [
6
6
  "lgpd",
@@ -48,12 +48,13 @@
48
48
  "dist",
49
49
  "README.md",
50
50
  "LICENSE",
51
- "COMPLIANCE.md"
51
+ "COMPLIANCE.md",
52
+ "CHANGELOG.md"
52
53
  ],
53
54
  "engines": {
54
55
  "node": ">=18.18"
55
56
  },
56
- "packageManager": "pnpm@9.0.0",
57
+ "packageManager": "pnpm@9.15.9",
57
58
  "scripts": {
58
59
  "clean": "rimraf dist",
59
60
  "build": "cross-env NODE_ENV=production tsup src/index.ts --format esm,cjs --dts --clean",
@@ -61,6 +62,7 @@
61
62
  "lint": "eslint . --ext .ts,.tsx",
62
63
  "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\" \"eslint.config.js\"",
63
64
  "type-check": "tsc --noEmit",
65
+ "test": "jest",
64
66
  "prepublishOnly": "npm run build"
65
67
  },
66
68
  "repository": {
@@ -86,22 +88,32 @@
86
88
  "js-cookie": "^3.0.5"
87
89
  },
88
90
  "devDependencies": {
91
+ "@emotion/react": "^11.14.0",
92
+ "@emotion/styled": "^11.14.1",
89
93
  "@eslint/compat": "^1.3.2",
90
94
  "@mui/icons-material": "^7.3.1",
91
95
  "@mui/material": "^7.3.1",
96
+ "@testing-library/jest-dom": "^6.6.4",
97
+ "@testing-library/react": "^16.3.0",
98
+ "@testing-library/user-event": "^14.6.1",
99
+ "@types/jest": "^30.0.0",
92
100
  "@types/js-cookie": "^3.0.6",
93
- "@types/react": "^19.1.9",
101
+ "@types/react": "^19.1.10",
94
102
  "@types/react-dom": "^19.1.7",
95
103
  "@typescript-eslint/eslint-plugin": "^8.39.1",
96
104
  "@typescript-eslint/parser": "^8.39.1",
97
105
  "cross-env": "^10.0.0",
98
106
  "eslint": "^9.33.0",
99
107
  "eslint-config-prettier": "^10.1.8",
108
+ "eslint-plugin-jest": "^29.0.1",
100
109
  "eslint-plugin-react-hooks": "^5.2.0",
110
+ "jest": "^30.0.5",
111
+ "jest-environment-jsdom": "^30.0.5",
101
112
  "prettier": "^3.6.2",
102
113
  "react": "^19.1.1",
103
114
  "react-dom": "^19.1.1",
104
115
  "rimraf": "^6.0.1",
116
+ "ts-jest": "^29.4.1",
105
117
  "tsup": "^8.5.0",
106
118
  "typescript": "^5.9.2",
107
119
  "typescript-eslint": "^8.39.1"