react-lgpd-consent 0.2.3 → 0.2.4

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PreferencesModal
3
- } from "./chunk-E763JXNL.js";
3
+ } from "./chunk-UKKWGQN7.js";
4
4
  export {
5
5
  PreferencesModal
6
6
  };
@@ -112,14 +112,15 @@ function analyzeDeveloperConfiguration(config) {
112
112
  }
113
113
  return guidance;
114
114
  }
115
- function logDeveloperGuidance(guidance) {
115
+ function logDeveloperGuidance(guidance, disableGuidanceProp) {
116
116
  try {
117
117
  const isProduction = (
118
118
  // 1. NODE_ENV de bundlers (Vite, webpack, etc.)
119
119
  typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Vite/bundler env vars (apenas em ESM)
120
120
  typeof globalThis !== "undefined" && typeof globalThis.import !== "undefined" && globalThis.import.meta?.env?.PROD === true || // 3. Flag customizada para desabilitar logs
121
- typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ || // 4. Flag de desenvolvimento desabilitada
122
- typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__
121
+ typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ || // 4. Flag de desenvolvimento desabilitada via window global (legado)
122
+ typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__ || // 5. Flag de desenvolvimento desabilitada via prop do ConsentProvider (preferencial)
123
+ disableGuidanceProp
123
124
  );
124
125
  if (isProduction) return;
125
126
  const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
@@ -164,11 +165,12 @@ function logDeveloperGuidance(guidance) {
164
165
  }
165
166
  }
166
167
  }
167
- function useDeveloperGuidance(config) {
168
+ function useDeveloperGuidance(config, disableGuidanceProp) {
168
169
  const guidance = analyzeDeveloperConfiguration(config);
170
+ const stringifiedConfig = React.useMemo(() => JSON.stringify(config), [config]);
169
171
  React.useEffect(() => {
170
- logDeveloperGuidance(guidance);
171
- }, [JSON.stringify(config)]);
172
+ logDeveloperGuidance(guidance, disableGuidanceProp);
173
+ }, [guidance, stringifiedConfig, disableGuidanceProp]);
172
174
  return guidance;
173
175
  }
174
176
 
@@ -389,7 +391,7 @@ var defaultConsentTheme = createTheme({
389
391
  // src/context/ConsentContext.tsx
390
392
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
391
393
  var PreferencesModal = React3.lazy(
392
- () => import("./PreferencesModal-UMNANMVX.js").then((m) => ({
394
+ () => import("./PreferencesModal-SOVV24DU.js").then((m) => ({
393
395
  default: m.PreferencesModal
394
396
  }))
395
397
  );
@@ -522,6 +524,7 @@ function ConsentProvider({
522
524
  customCategories,
523
525
  // LEGACY: compatibilidade
524
526
  scriptIntegrations,
527
+ // eslint-disable-line no-unused-vars
525
528
  PreferencesModalComponent,
526
529
  preferencesModalProps = {},
527
530
  disableAutomaticModal = false,
@@ -529,6 +532,8 @@ function ConsentProvider({
529
532
  onConsentGiven,
530
533
  onPreferencesSaved,
531
534
  cookie: cookieOpts,
535
+ disableDeveloperGuidance,
536
+ // NOVO: desabilita avisos de dev
532
537
  children
533
538
  }) {
534
539
  const texts = React3.useMemo(
@@ -554,7 +559,7 @@ function ConsentProvider({
554
559
  }
555
560
  return void 0;
556
561
  }, [categories, customCategories]);
557
- useDeveloperGuidance(finalCategoriesConfig);
562
+ useDeveloperGuidance(finalCategoriesConfig, disableDeveloperGuidance);
558
563
  const boot = React3.useMemo(() => {
559
564
  if (initialState) return { ...initialState, isModalOpen: false };
560
565
  return createFullConsentState(
package/dist/index.cjs CHANGED
@@ -279,14 +279,15 @@ function analyzeDeveloperConfiguration(config) {
279
279
  }
280
280
  return guidance;
281
281
  }
282
- function logDeveloperGuidance(guidance) {
282
+ function logDeveloperGuidance(guidance, disableGuidanceProp) {
283
283
  try {
284
284
  const isProduction = (
285
285
  // 1. NODE_ENV de bundlers (Vite, webpack, etc.)
286
286
  typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV === "production" || // 2. Vite/bundler env vars (apenas em ESM)
287
287
  typeof globalThis !== "undefined" && typeof globalThis.import !== "undefined" && globalThis.import.meta?.env?.PROD === true || // 3. Flag customizada para desabilitar logs
288
- typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ || // 4. Flag de desenvolvimento desabilitada
289
- typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__
288
+ typeof globalThis !== "undefined" && globalThis.__LGPD_PRODUCTION__ || // 4. Flag de desenvolvimento desabilitada via window global (legado)
289
+ typeof window !== "undefined" && window.__LGPD_DISABLE_GUIDANCE__ || // 5. Flag de desenvolvimento desabilitada via prop do ConsentProvider (preferencial)
290
+ disableGuidanceProp
290
291
  );
291
292
  if (isProduction) return;
292
293
  const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
@@ -331,11 +332,12 @@ function logDeveloperGuidance(guidance) {
331
332
  }
332
333
  }
333
334
  }
334
- function useDeveloperGuidance(config) {
335
+ function useDeveloperGuidance(config, disableGuidanceProp) {
335
336
  const guidance = analyzeDeveloperConfiguration(config);
337
+ const stringifiedConfig = React.useMemo(() => JSON.stringify(config), [config]);
336
338
  React.useEffect(() => {
337
- logDeveloperGuidance(guidance);
338
- }, [JSON.stringify(config)]);
339
+ logDeveloperGuidance(guidance, disableGuidanceProp);
340
+ }, [guidance, stringifiedConfig, disableGuidanceProp]);
339
341
  return guidance;
340
342
  }
341
343
  var React, DEFAULT_PROJECT_CATEGORIES;
@@ -689,6 +691,7 @@ function ConsentProvider({
689
691
  customCategories,
690
692
  // LEGACY: compatibilidade
691
693
  scriptIntegrations,
694
+ // eslint-disable-line no-unused-vars
692
695
  PreferencesModalComponent,
693
696
  preferencesModalProps = {},
694
697
  disableAutomaticModal = false,
@@ -696,6 +699,8 @@ function ConsentProvider({
696
699
  onConsentGiven,
697
700
  onPreferencesSaved,
698
701
  cookie: cookieOpts,
702
+ disableDeveloperGuidance,
703
+ // NOVO: desabilita avisos de dev
699
704
  children
700
705
  }) {
701
706
  const texts = React3.useMemo(
@@ -721,7 +726,7 @@ function ConsentProvider({
721
726
  }
722
727
  return void 0;
723
728
  }, [categories, customCategories]);
724
- useDeveloperGuidance(finalCategoriesConfig);
729
+ useDeveloperGuidance(finalCategoriesConfig, disableDeveloperGuidance);
725
730
  const boot = React3.useMemo(() => {
726
731
  if (initialState) return { ...initialState, isModalOpen: false };
727
732
  return createFullConsentState(
@@ -1240,7 +1245,7 @@ function createGoogleAnalyticsIntegration(config) {
1240
1245
  init: () => {
1241
1246
  if (typeof window !== "undefined") {
1242
1247
  let gtag2 = function(...args) {
1243
- window.dataLayer.push(arguments);
1248
+ window.dataLayer.push(...args);
1244
1249
  };
1245
1250
  var gtag = gtag2;
1246
1251
  window.dataLayer = window.dataLayer || [];
package/dist/index.d.cts CHANGED
@@ -469,6 +469,12 @@ interface ConsentProviderProps {
469
469
  * ```
470
470
  */
471
471
  cookie?: Partial<ConsentCookieOptions>;
472
+ /**
473
+ * Desabilita os avisos e sugestões para desenvolvedores no console.
474
+ * Útil para ambientes de produção ou quando os avisos não são desejados.
475
+ * Por padrão, os avisos já são desabilitados em builds de produção.
476
+ */
477
+ disableDeveloperGuidance?: boolean;
472
478
  /** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
473
479
  children: React.ReactNode;
474
480
  }
@@ -515,7 +521,9 @@ interface ConsentContextValue {
515
521
  */
516
522
  declare function ConsentProvider({ initialState, categories, // NOVO: configuração completa de categorias
517
523
  texts: textsProp, theme, customCategories, // LEGACY: compatibilidade
518
- scriptIntegrations, PreferencesModalComponent, preferencesModalProps, disableAutomaticModal, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
524
+ scriptIntegrations, // eslint-disable-line no-unused-vars
525
+ PreferencesModalComponent, preferencesModalProps, disableAutomaticModal, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, // NOVO: desabilita avisos de dev
526
+ children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
519
527
 
520
528
  /**
521
529
  * Hook principal para acessar e manipular o estado de consentimento de cookies.
package/dist/index.d.ts CHANGED
@@ -469,6 +469,12 @@ interface ConsentProviderProps {
469
469
  * ```
470
470
  */
471
471
  cookie?: Partial<ConsentCookieOptions>;
472
+ /**
473
+ * Desabilita os avisos e sugestões para desenvolvedores no console.
474
+ * Útil para ambientes de produção ou quando os avisos não são desejados.
475
+ * Por padrão, os avisos já são desabilitados em builds de produção.
476
+ */
477
+ disableDeveloperGuidance?: boolean;
472
478
  /** Elementos filhos - toda a aplicação que precisa de contexto de consentimento. */
473
479
  children: React.ReactNode;
474
480
  }
@@ -515,7 +521,9 @@ interface ConsentContextValue {
515
521
  */
516
522
  declare function ConsentProvider({ initialState, categories, // NOVO: configuração completa de categorias
517
523
  texts: textsProp, theme, customCategories, // LEGACY: compatibilidade
518
- scriptIntegrations, PreferencesModalComponent, preferencesModalProps, disableAutomaticModal, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
524
+ scriptIntegrations, // eslint-disable-line no-unused-vars
525
+ PreferencesModalComponent, preferencesModalProps, disableAutomaticModal, hideBranding, onConsentGiven, onPreferencesSaved, cookie: cookieOpts, disableDeveloperGuidance, // NOVO: desabilita avisos de dev
526
+ children, }: Readonly<ConsentProviderProps>): react_jsx_runtime.JSX.Element;
519
527
 
520
528
  /**
521
529
  * Hook principal para acessar e manipular o estado de consentimento de cookies.
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  useConsentHydration,
12
12
  useConsentTexts,
13
13
  useCustomCategories
14
- } from "./chunk-E763JXNL.js";
14
+ } from "./chunk-UKKWGQN7.js";
15
15
 
16
16
  // src/components/CookieBanner.tsx
17
17
  import Button from "@mui/material/Button";
@@ -309,7 +309,7 @@ function createGoogleAnalyticsIntegration(config) {
309
309
  init: () => {
310
310
  if (typeof window !== "undefined") {
311
311
  let gtag2 = function(...args) {
312
- window.dataLayer.push(arguments);
312
+ window.dataLayer.push(...args);
313
313
  };
314
314
  var gtag = gtag2;
315
315
  window.dataLayer = window.dataLayer || [];
package/package.json CHANGED
@@ -1,105 +1,109 @@
1
- {
2
- "name": "react-lgpd-consent",
3
- "version": "0.2.3",
4
- "description": "Biblioteca completa de consentimento LGPD com 6 categorias ANPD, integrações nativas e sistema extensível para React.",
5
- "keywords": [
6
- "lgpd",
7
- "anpd",
8
- "cookie",
9
- "consent",
10
- "react",
11
- "client-side",
12
- "spa",
13
- "material-ui",
14
- "mui",
15
- "typescript",
16
- "js-cookie",
17
- "consentimento",
18
- "privacidade",
19
- "acessibilidade",
20
- "google-analytics",
21
- "tag-manager",
22
- "userway",
23
- "categorias-extensiveis"
24
- ],
25
- "publishConfig": {
26
- "access": "public"
27
- },
28
- "author": {
29
- "name": "Luciano Édipo",
30
- "email": "luciano.psilva@anpd.gov.br",
31
- "url": "https://github.com/lucianoedipo"
32
- },
33
- "license": "MIT",
34
- "type": "module",
35
- "main": "dist/index.cjs",
36
- "module": "dist/index.mjs",
37
- "types": "dist/index.d.ts",
38
- "exports": {
39
- ".": {
40
- "types": "./dist/index.d.ts",
41
- "import": "./dist/index.js",
42
- "require": "./dist/index.cjs"
43
- },
44
- "./package.json": "./package.json"
45
- },
46
- "sideEffects": false,
47
- "files": [
48
- "dist",
49
- "README.md",
50
- "LICENSE",
51
- "COMPLIANCE.md"
52
- ],
53
- "engines": {
54
- "node": ">=18.18"
55
- },
56
- "packageManager": "pnpm@9.0.0",
57
- "scripts": {
58
- "clean": "rimraf dist",
59
- "build": "cross-env NODE_ENV=production tsup src/index.ts --format esm,cjs --dts --clean",
60
- "dev": "cross-env NODE_ENV=development tsup src/index.ts --format esm,cjs --dts --watch",
61
- "lint": "eslint . --ext .ts,.tsx",
62
- "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
63
- "type-check": "tsc --noEmit",
64
- "prepublishOnly": "npm run build"
65
- },
66
- "repository": {
67
- "type": "git",
68
- "url": "git+https://github.com/lucianoedipo/react-lgpd-consent.git"
69
- },
70
- "bugs": {
71
- "url": "https://github.com/lucianoedipo/react-lgpd-consent/issues"
72
- },
73
- "homepage": "https://github.com/lucianoedipo/react-lgpd-consent#readme",
74
- "peerDependencies": {
75
- "@mui/material": "^7.0.0 || ^6.0.0 || ^5.15.0",
76
- "@mui/icons-material": "^7.0.0 || ^6.0.0 || ^5.15.0",
77
- "react": "^18.2.0 || ^19.0.0",
78
- "react-dom": "^18.2.0 || ^19.0.0"
79
- },
80
- "peerDependenciesMeta": {
81
- "@mui/icons-material": {
82
- "optional": true
83
- }
84
- },
85
- "dependencies": {
86
- "js-cookie": "^3.0.5"
87
- },
88
- "devDependencies": {
89
- "@types/js-cookie": "^3.0.6",
90
- "@types/react": "^19.1.9",
91
- "@types/react-dom": "^19.1.7",
92
- "@mui/material": "^7.3.1",
93
- "@mui/icons-material": "^7.3.1",
94
- "react": "^19.1.1",
95
- "react-dom": "^19.1.1",
96
- "cross-env": "^10.0.0",
97
- "eslint": "^9.33.0",
98
- "eslint-config-prettier": "^10.1.8",
99
- "eslint-plugin-react-hooks": "^5.2.0",
100
- "prettier": "^3.6.2",
101
- "rimraf": "^6.0.1",
102
- "tsup": "^8.5.0",
103
- "typescript": "^5.9.2"
104
- }
105
- }
1
+ {
2
+ "name": "react-lgpd-consent",
3
+ "version": "0.2.4",
4
+ "description": "Biblioteca completa de consentimento LGPD com 6 categorias ANPD, integrações nativas e sistema extensível para React.",
5
+ "keywords": [
6
+ "lgpd",
7
+ "anpd",
8
+ "cookie",
9
+ "consent",
10
+ "react",
11
+ "client-side",
12
+ "spa",
13
+ "material-ui",
14
+ "mui",
15
+ "typescript",
16
+ "js-cookie",
17
+ "consentimento",
18
+ "privacidade",
19
+ "acessibilidade",
20
+ "google-analytics",
21
+ "tag-manager",
22
+ "userway",
23
+ "categorias-extensiveis"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "author": {
29
+ "name": "Luciano Édipo",
30
+ "email": "luciano.psilva@anpd.gov.br",
31
+ "url": "https://github.com/lucianoedipo"
32
+ },
33
+ "license": "MIT",
34
+ "type": "module",
35
+ "main": "dist/index.cjs",
36
+ "module": "dist/index.mjs",
37
+ "types": "dist/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.js",
42
+ "require": "./dist/index.cjs"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
46
+ "sideEffects": false,
47
+ "files": [
48
+ "dist",
49
+ "README.md",
50
+ "LICENSE",
51
+ "COMPLIANCE.md"
52
+ ],
53
+ "engines": {
54
+ "node": ">=18.18"
55
+ },
56
+ "packageManager": "pnpm@9.0.0",
57
+ "scripts": {
58
+ "clean": "rimraf dist",
59
+ "build": "cross-env NODE_ENV=production tsup src/index.ts --format esm,cjs --dts --clean",
60
+ "dev": "cross-env NODE_ENV=development tsup src/index.ts --format esm,cjs --dts --watch",
61
+ "lint": "eslint . --ext .ts,.tsx",
62
+ "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\" \"eslint.config.js\"",
63
+ "type-check": "tsc --noEmit",
64
+ "prepublishOnly": "npm run build"
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/lucianoedipo/react-lgpd-consent.git"
69
+ },
70
+ "bugs": {
71
+ "url": "https://github.com/lucianoedipo/react-lgpd-consent/issues"
72
+ },
73
+ "homepage": "https://github.com/lucianoedipo/react-lgpd-consent#readme",
74
+ "peerDependencies": {
75
+ "@mui/icons-material": "^7.0.0 || ^6.0.0 || ^5.15.0",
76
+ "@mui/material": "^7.0.0 || ^6.0.0 || ^5.15.0",
77
+ "react": "^18.2.0 || ^19.0.0",
78
+ "react-dom": "^18.2.0 || ^19.0.0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@mui/icons-material": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "dependencies": {
86
+ "js-cookie": "^3.0.5"
87
+ },
88
+ "devDependencies": {
89
+ "@eslint/compat": "^1.3.2",
90
+ "@mui/icons-material": "^7.3.1",
91
+ "@mui/material": "^7.3.1",
92
+ "@types/js-cookie": "^3.0.6",
93
+ "@types/react": "^19.1.9",
94
+ "@types/react-dom": "^19.1.7",
95
+ "@typescript-eslint/eslint-plugin": "^8.39.1",
96
+ "@typescript-eslint/parser": "^8.39.1",
97
+ "cross-env": "^10.0.0",
98
+ "eslint": "^9.33.0",
99
+ "eslint-config-prettier": "^10.1.8",
100
+ "eslint-plugin-react-hooks": "^5.2.0",
101
+ "prettier": "^3.6.2",
102
+ "react": "^19.1.1",
103
+ "react-dom": "^19.1.1",
104
+ "rimraf": "^6.0.1",
105
+ "tsup": "^8.5.0",
106
+ "typescript": "^5.9.2",
107
+ "typescript-eslint": "^8.39.1"
108
+ }
109
+ }