react-lgpd-consent 0.4.1 → 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 +129 -3
- package/QUICKSTART.md +254 -0
- package/README.en.md +6 -0
- package/README.md +7 -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-VOQUCGOA.js → chunk-RWT2ORFE.js} +340 -522
- package/dist/index.cjs +177 -2286
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +10 -98
- package/package.json +47 -41
- package/dist/PreferencesModal-RNRD3JKB.js +0 -6
package/dist/index.d.cts
CHANGED
|
@@ -2083,6 +2083,14 @@ declare function useCategoryStatus(categoryId: string): {
|
|
|
2083
2083
|
description: string | undefined;
|
|
2084
2084
|
};
|
|
2085
2085
|
|
|
2086
|
+
/**
|
|
2087
|
+
* ConsentGate - renderiza children apenas se houver consentimento para a categoria.
|
|
2088
|
+
*
|
|
2089
|
+
* @remarks
|
|
2090
|
+
* Não usa React.memo pois o estado de preferências muda dinamicamente
|
|
2091
|
+
* e o componente precisa re-renderizar quando as preferências mudam.
|
|
2092
|
+
* A lógica é leve o suficiente para não justificar memoização.
|
|
2093
|
+
*/
|
|
2086
2094
|
declare function ConsentGate(props: Readonly<{
|
|
2087
2095
|
category: string;
|
|
2088
2096
|
children: React$1.ReactNode;
|
|
@@ -3640,7 +3648,7 @@ interface FloatingPreferencesButtonProps {
|
|
|
3640
3648
|
/** Offset da borda em pixels. Padrão: 24 */
|
|
3641
3649
|
offset?: number;
|
|
3642
3650
|
/** Ícone customizado. Padrão: CookieOutlined */
|
|
3643
|
-
icon?: React.ReactNode;
|
|
3651
|
+
icon?: React$1.ReactNode;
|
|
3644
3652
|
/** Tooltip customizado exibido ao passar o mouse */
|
|
3645
3653
|
tooltip?: string;
|
|
3646
3654
|
/** Props adicionais para o Fab do MUI */
|
|
@@ -3660,10 +3668,12 @@ interface FloatingPreferencesButtonProps {
|
|
|
3660
3668
|
* Você pode substituí-lo passando seu próprio componente para a prop `FloatingPreferencesButtonComponent`
|
|
3661
3669
|
* no `ConsentProvider`.
|
|
3662
3670
|
*
|
|
3671
|
+
* Componente memoizado para otimizar performance - só re-renderiza quando props mudam.
|
|
3672
|
+
*
|
|
3663
3673
|
* @param {Readonly<FloatingPreferencesButtonProps>} props As propriedades para customizar o botão.
|
|
3664
3674
|
* @returns {JSX.Element | null} O componente do botão flutuante ou `null` se não for necessário exibi-lo.
|
|
3665
3675
|
*/
|
|
3666
|
-
declare
|
|
3676
|
+
declare const FloatingPreferencesButton: React$1.NamedExoticComponent<Readonly<FloatingPreferencesButtonProps>>;
|
|
3667
3677
|
|
|
3668
3678
|
/** @module src/utils/categoryUtils */
|
|
3669
3679
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2083,6 +2083,14 @@ declare function useCategoryStatus(categoryId: string): {
|
|
|
2083
2083
|
description: string | undefined;
|
|
2084
2084
|
};
|
|
2085
2085
|
|
|
2086
|
+
/**
|
|
2087
|
+
* ConsentGate - renderiza children apenas se houver consentimento para a categoria.
|
|
2088
|
+
*
|
|
2089
|
+
* @remarks
|
|
2090
|
+
* Não usa React.memo pois o estado de preferências muda dinamicamente
|
|
2091
|
+
* e o componente precisa re-renderizar quando as preferências mudam.
|
|
2092
|
+
* A lógica é leve o suficiente para não justificar memoização.
|
|
2093
|
+
*/
|
|
2086
2094
|
declare function ConsentGate(props: Readonly<{
|
|
2087
2095
|
category: string;
|
|
2088
2096
|
children: React$1.ReactNode;
|
|
@@ -3640,7 +3648,7 @@ interface FloatingPreferencesButtonProps {
|
|
|
3640
3648
|
/** Offset da borda em pixels. Padrão: 24 */
|
|
3641
3649
|
offset?: number;
|
|
3642
3650
|
/** Ícone customizado. Padrão: CookieOutlined */
|
|
3643
|
-
icon?: React.ReactNode;
|
|
3651
|
+
icon?: React$1.ReactNode;
|
|
3644
3652
|
/** Tooltip customizado exibido ao passar o mouse */
|
|
3645
3653
|
tooltip?: string;
|
|
3646
3654
|
/** Props adicionais para o Fab do MUI */
|
|
@@ -3660,10 +3668,12 @@ interface FloatingPreferencesButtonProps {
|
|
|
3660
3668
|
* Você pode substituí-lo passando seu próprio componente para a prop `FloatingPreferencesButtonComponent`
|
|
3661
3669
|
* no `ConsentProvider`.
|
|
3662
3670
|
*
|
|
3671
|
+
* Componente memoizado para otimizar performance - só re-renderiza quando props mudam.
|
|
3672
|
+
*
|
|
3663
3673
|
* @param {Readonly<FloatingPreferencesButtonProps>} props As propriedades para customizar o botão.
|
|
3664
3674
|
* @returns {JSX.Element | null} O componente do botão flutuante ou `null` se não for necessário exibi-lo.
|
|
3665
3675
|
*/
|
|
3666
|
-
declare
|
|
3676
|
+
declare const FloatingPreferencesButton: React$1.NamedExoticComponent<Readonly<FloatingPreferencesButtonProps>>;
|
|
3667
3677
|
|
|
3668
3678
|
/** @module src/utils/categoryUtils */
|
|
3669
3679
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
PreferencesModal,
|
|
9
|
-
analyzeDeveloperConfiguration,
|
|
10
|
-
categorizeDiscoveredCookies,
|
|
11
|
-
createProjectPreferences,
|
|
12
|
-
defaultTexts,
|
|
13
|
-
detectConsentCookieName,
|
|
14
|
-
discoverRuntimeCookies,
|
|
15
|
-
getAllProjectCategories,
|
|
16
|
-
getCookiesInfoForCategory,
|
|
17
|
-
logDeveloperGuidance,
|
|
18
|
-
logger,
|
|
19
|
-
openPreferencesModal,
|
|
20
|
-
setCookieCatalogOverrides,
|
|
21
|
-
setCookieCategoryOverrides,
|
|
22
|
-
setDebugLogging,
|
|
23
|
-
useCategories,
|
|
24
|
-
useCategoryStatus,
|
|
25
|
-
useConsent,
|
|
26
|
-
useConsentHydration,
|
|
27
|
-
useConsentTexts,
|
|
28
|
-
useDeveloperGuidance,
|
|
29
|
-
useOpenPreferencesModal,
|
|
30
|
-
validateProjectPreferences
|
|
31
|
-
} from "./chunk-VOQUCGOA.js";
|
|
1
|
+
export { FloatingPreferencesButton } from './chunk-PJFGQMCI.js';
|
|
2
|
+
export { PreferencesModal } from './chunk-N3QOW4SA.js';
|
|
3
|
+
import { useConsent, useCategories, logger } from './chunk-RWT2ORFE.js';
|
|
4
|
+
export { ConsentProvider, CookieBanner, DEFAULT_PROJECT_CATEGORIES, GUIDANCE_PRESETS, LogLevel, analyzeDeveloperConfiguration, categorizeDiscoveredCookies, createProjectPreferences, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, getAllProjectCategories, getCookiesInfoForCategory, logDeveloperGuidance, openPreferencesModal, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentTexts, useDeveloperGuidance, useOpenPreferencesModal, validateProjectPreferences } from './chunk-RWT2ORFE.js';
|
|
5
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
import { createTheme } from '@mui/material/styles';
|
|
7
|
+
import * as React from 'react';
|
|
32
8
|
|
|
33
|
-
//
|
|
34
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
9
|
+
// react-lgpd-consent - Tree-shakeable ESM build
|
|
35
10
|
function ConsentGate(props) {
|
|
36
11
|
const { preferences } = useConsent();
|
|
37
12
|
if (!preferences[props.category]) return null;
|
|
@@ -74,9 +49,6 @@ function loadScript(id, src, category = null, attrs = {}) {
|
|
|
74
49
|
checkConsent();
|
|
75
50
|
});
|
|
76
51
|
}
|
|
77
|
-
|
|
78
|
-
// src/utils/theme.ts
|
|
79
|
-
import { createTheme } from "@mui/material/styles";
|
|
80
52
|
function createDefaultConsentTheme() {
|
|
81
53
|
return createTheme({
|
|
82
54
|
palette: {
|
|
@@ -146,9 +118,6 @@ function createDefaultConsentTheme() {
|
|
|
146
118
|
}
|
|
147
119
|
var defaultConsentTheme = () => createDefaultConsentTheme();
|
|
148
120
|
|
|
149
|
-
// src/utils/ConsentScriptLoader.tsx
|
|
150
|
-
import * as React from "react";
|
|
151
|
-
|
|
152
121
|
// src/utils/autoConfigureCategories.ts
|
|
153
122
|
var FORBIDDEN_NECESSARY_SCRIPTS = /* @__PURE__ */ new Set([
|
|
154
123
|
// Analytics & Performance
|
|
@@ -957,62 +926,5 @@ var TEXT_TEMPLATES = {
|
|
|
957
926
|
}
|
|
958
927
|
}
|
|
959
928
|
};
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
ConsentGate,
|
|
963
|
-
ConsentProvider,
|
|
964
|
-
ConsentScriptLoader,
|
|
965
|
-
CookieBanner,
|
|
966
|
-
DEFAULT_PROJECT_CATEGORIES,
|
|
967
|
-
EXPANDED_DEFAULT_TEXTS,
|
|
968
|
-
FloatingPreferencesButton,
|
|
969
|
-
GUIDANCE_PRESETS,
|
|
970
|
-
INTEGRATION_TEMPLATES,
|
|
971
|
-
LogLevel,
|
|
972
|
-
PreferencesModal,
|
|
973
|
-
TEXT_TEMPLATES,
|
|
974
|
-
analyzeDeveloperConfiguration,
|
|
975
|
-
analyzeIntegrationCategories,
|
|
976
|
-
autoConfigureCategories,
|
|
977
|
-
categorizeDiscoveredCookies,
|
|
978
|
-
createClarityIntegration,
|
|
979
|
-
createCorporateIntegrations,
|
|
980
|
-
createDefaultConsentTheme,
|
|
981
|
-
createECommerceIntegrations,
|
|
982
|
-
createFacebookPixelIntegration,
|
|
983
|
-
createGoogleAnalyticsIntegration,
|
|
984
|
-
createGoogleTagManagerIntegration,
|
|
985
|
-
createHotjarIntegration,
|
|
986
|
-
createIntercomIntegration,
|
|
987
|
-
createMixpanelIntegration,
|
|
988
|
-
createProjectPreferences,
|
|
989
|
-
createSaaSIntegrations,
|
|
990
|
-
createUserWayIntegration,
|
|
991
|
-
createZendeskChatIntegration,
|
|
992
|
-
defaultConsentTheme,
|
|
993
|
-
defaultTexts,
|
|
994
|
-
detectConsentCookieName,
|
|
995
|
-
discoverRuntimeCookies,
|
|
996
|
-
extractCategoriesFromIntegrations,
|
|
997
|
-
getAllProjectCategories,
|
|
998
|
-
getCookiesInfoForCategory,
|
|
999
|
-
loadScript,
|
|
1000
|
-
logDeveloperGuidance,
|
|
1001
|
-
openPreferencesModal,
|
|
1002
|
-
resolveTexts,
|
|
1003
|
-
setCookieCatalogOverrides,
|
|
1004
|
-
setCookieCategoryOverrides,
|
|
1005
|
-
setDebugLogging,
|
|
1006
|
-
suggestCategoryForScript,
|
|
1007
|
-
useCategories,
|
|
1008
|
-
useCategoryStatus,
|
|
1009
|
-
useConsent,
|
|
1010
|
-
useConsentHydration,
|
|
1011
|
-
useConsentScriptLoader,
|
|
1012
|
-
useConsentTexts,
|
|
1013
|
-
useDeveloperGuidance,
|
|
1014
|
-
useOpenPreferencesModal,
|
|
1015
|
-
validateIntegrationCategories,
|
|
1016
|
-
validateNecessaryClassification,
|
|
1017
|
-
validateProjectPreferences
|
|
1018
|
-
};
|
|
929
|
+
|
|
930
|
+
export { COMMON_INTEGRATIONS, ConsentGate, ConsentScriptLoader, EXPANDED_DEFAULT_TEXTS, INTEGRATION_TEMPLATES, TEXT_TEMPLATES, analyzeIntegrationCategories, autoConfigureCategories, createClarityIntegration, createCorporateIntegrations, createDefaultConsentTheme, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultConsentTheme, extractCategoriesFromIntegrations, loadScript, resolveTexts, suggestCategoryForScript, useConsentScriptLoader, validateIntegrationCategories, validateNecessaryClassification };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lgpd-consent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Biblioteca de consentimento LGPD, integrações nativas e sistema extensível para React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lgpd",
|
|
@@ -8,19 +8,13 @@
|
|
|
8
8
|
"cookie",
|
|
9
9
|
"consent",
|
|
10
10
|
"react",
|
|
11
|
-
"client-side",
|
|
12
|
-
"spa",
|
|
13
|
-
"material-ui",
|
|
14
|
-
"mui",
|
|
15
11
|
"typescript",
|
|
16
12
|
"js-cookie",
|
|
17
13
|
"consentimento",
|
|
18
14
|
"privacidade",
|
|
19
15
|
"acessibilidade",
|
|
20
16
|
"google-analytics",
|
|
21
|
-
"
|
|
22
|
-
"userway",
|
|
23
|
-
"categorias-extensiveis"
|
|
17
|
+
"userway"
|
|
24
18
|
],
|
|
25
19
|
"publishConfig": {
|
|
26
20
|
"access": "public"
|
|
@@ -41,9 +35,17 @@
|
|
|
41
35
|
"import": "./dist/index.js",
|
|
42
36
|
"require": "./dist/index.cjs"
|
|
43
37
|
},
|
|
38
|
+
"./integrations": {
|
|
39
|
+
"types": "./dist/utils/scriptIntegrations.d.ts",
|
|
40
|
+
"import": "./dist/utils/scriptIntegrations.js",
|
|
41
|
+
"require": "./dist/utils/scriptIntegrations.cjs"
|
|
42
|
+
},
|
|
44
43
|
"./package.json": "./package.json"
|
|
45
44
|
},
|
|
46
|
-
"sideEffects":
|
|
45
|
+
"sideEffects": [
|
|
46
|
+
"dist/chunk-*.js",
|
|
47
|
+
"dist/chunk-*.cjs"
|
|
48
|
+
],
|
|
47
49
|
"files": [
|
|
48
50
|
"dist",
|
|
49
51
|
"README.md",
|
|
@@ -56,7 +58,6 @@
|
|
|
56
58
|
"engines": {
|
|
57
59
|
"node": ">=20.0.0"
|
|
58
60
|
},
|
|
59
|
-
"packageManager": "npm@11.6.0",
|
|
60
61
|
"scripts": {
|
|
61
62
|
"clean": "rimraf node_modules package-lock.json dist docs storybook-static .cache .stryker-tmp",
|
|
62
63
|
"build": "cross-env NODE_ENV=production tsup src/index.ts --format esm,cjs --dts --clean",
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\" \"eslint.config.js\"",
|
|
67
68
|
"type-check": "tsc --noEmit",
|
|
68
69
|
"test": "jest --config jest.config.ts",
|
|
70
|
+
"test:a11y": "jest --config jest.config.ts --testMatch='**/*.a11y.test.tsx'",
|
|
69
71
|
"test:coverage": "jest --config jest.config.ts --coverage",
|
|
70
72
|
"coverage-check": "node scripts/coverage-check.cjs",
|
|
71
73
|
"size-check": "size-limit",
|
|
@@ -96,70 +98,74 @@
|
|
|
96
98
|
}
|
|
97
99
|
},
|
|
98
100
|
"dependencies": {
|
|
99
|
-
"js-cookie": "^3.0.5"
|
|
101
|
+
"js-cookie": "^3.0.5",
|
|
102
|
+
"zod": "^4.1.12"
|
|
100
103
|
},
|
|
101
104
|
"devDependencies": {
|
|
105
|
+
"@axe-core/react": "^4.10.2",
|
|
102
106
|
"@chromatic-com/storybook": "4.1.1",
|
|
103
107
|
"@emotion/react": "11.14.0",
|
|
104
108
|
"@emotion/styled": "11.14.1",
|
|
105
|
-
"@eslint/compat": "1.
|
|
106
|
-
"@mui/icons-material": "7.3.
|
|
107
|
-
"@mui/material": "7.3.
|
|
109
|
+
"@eslint/compat": "1.4.0",
|
|
110
|
+
"@mui/icons-material": "7.3.4",
|
|
111
|
+
"@mui/material": "7.3.4",
|
|
108
112
|
"@size-limit/preset-small-lib": "^11.2.0",
|
|
109
|
-
"@storybook/addon-a11y": "9.1.
|
|
110
|
-
"@storybook/addon-docs": "9.1.
|
|
111
|
-
"@storybook/addon-vitest": "9.1.
|
|
112
|
-
"@storybook/react-vite": "9.1.
|
|
113
|
-
"@stryker-mutator/core": "9.
|
|
114
|
-
"@stryker-mutator/jest-runner": "9.
|
|
113
|
+
"@storybook/addon-a11y": "9.1.10",
|
|
114
|
+
"@storybook/addon-docs": "9.1.10",
|
|
115
|
+
"@storybook/addon-vitest": "9.1.10",
|
|
116
|
+
"@storybook/react-vite": "9.1.10",
|
|
117
|
+
"@stryker-mutator/core": "9.2.0",
|
|
118
|
+
"@stryker-mutator/jest-runner": "9.2.0",
|
|
115
119
|
"@testing-library/dom": "10.4.1",
|
|
116
|
-
"@testing-library/jest-dom": "6.
|
|
120
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
117
121
|
"@testing-library/react": "^16.3.0",
|
|
118
122
|
"@testing-library/user-event": "14.6.1",
|
|
119
123
|
"@types/jest": "30.0.0",
|
|
124
|
+
"@types/jest-axe": "^3.5.9",
|
|
120
125
|
"@types/js-cookie": "3.0.6",
|
|
121
|
-
"@types/node": "24.
|
|
122
|
-
"@types/react": "19.1
|
|
123
|
-
"@types/react-dom": "19.
|
|
124
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
125
|
-
"@typescript-eslint/parser": "8.
|
|
126
|
-
"cross-env": "10.
|
|
127
|
-
"eslint": "9.
|
|
126
|
+
"@types/node": "24.7.0",
|
|
127
|
+
"@types/react": "19.2.1",
|
|
128
|
+
"@types/react-dom": "19.2.0",
|
|
129
|
+
"@typescript-eslint/eslint-plugin": "8.46.0",
|
|
130
|
+
"@typescript-eslint/parser": "8.46.0",
|
|
131
|
+
"cross-env": "10.1.0",
|
|
132
|
+
"eslint": "9.37.0",
|
|
128
133
|
"eslint-config-prettier": "10.1.8",
|
|
129
134
|
"eslint-plugin-jest": "29.0.1",
|
|
130
|
-
"eslint-plugin-react-hooks": "
|
|
131
|
-
"eslint-plugin-storybook": "9.1.
|
|
135
|
+
"eslint-plugin-react-hooks": "6.1.1",
|
|
136
|
+
"eslint-plugin-storybook": "9.1.10",
|
|
132
137
|
"globals": "^16.4.0",
|
|
133
|
-
"jest": "30.
|
|
134
|
-
"jest-
|
|
138
|
+
"jest": "30.2.0",
|
|
139
|
+
"jest-axe": "^10.0.0",
|
|
140
|
+
"jest-environment-jsdom": "30.2.0",
|
|
135
141
|
"prettier": "3.6.2",
|
|
136
|
-
"react": "19.
|
|
137
|
-
"react-dom": "19.
|
|
142
|
+
"react": "19.2.0",
|
|
143
|
+
"react-dom": "19.2.0",
|
|
138
144
|
"rimraf": "6.0.1",
|
|
139
145
|
"size-limit": "^11.2.0",
|
|
140
|
-
"storybook": "9.1.
|
|
146
|
+
"storybook": "9.1.10",
|
|
141
147
|
"ts-jest": "29.4.4",
|
|
142
148
|
"ts-node": "10.9.2",
|
|
143
149
|
"tsup": "8.5.0",
|
|
144
150
|
"typedoc": "0.28.13",
|
|
145
|
-
"typescript": "5.9.
|
|
146
|
-
"typescript-eslint": "8.
|
|
151
|
+
"typescript": "5.9.3",
|
|
152
|
+
"typescript-eslint": "8.46.0"
|
|
147
153
|
},
|
|
148
154
|
"size-limit": [
|
|
149
155
|
{
|
|
150
156
|
"name": "ESM Bundle",
|
|
151
157
|
"path": "dist/index.js",
|
|
152
|
-
"limit": "
|
|
158
|
+
"limit": "34 KB"
|
|
153
159
|
},
|
|
154
160
|
{
|
|
155
161
|
"name": "CJS Bundle",
|
|
156
162
|
"path": "dist/index.cjs",
|
|
157
|
-
"limit": "
|
|
163
|
+
"limit": "120 KB"
|
|
158
164
|
},
|
|
159
165
|
{
|
|
160
166
|
"name": "Types",
|
|
161
167
|
"path": "dist/index.d.ts",
|
|
162
|
-
"limit": "
|
|
168
|
+
"limit": "130 KB"
|
|
163
169
|
},
|
|
164
170
|
{
|
|
165
171
|
"name": "Complete Package Import",
|
|
@@ -168,4 +174,4 @@
|
|
|
168
174
|
"limit": "15 KB"
|
|
169
175
|
}
|
|
170
176
|
]
|
|
171
|
-
}
|
|
177
|
+
}
|