@c15t/react 0.0.1-rc.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/LICENSE.md +595 -0
- package/README.md +55 -0
- package/dist/common/components/consent-manager-provider.cjs +93 -0
- package/dist/common/components/consent-manager-provider.d.ts +16 -0
- package/dist/common/components/consent-manager-provider.d.ts.map +1 -0
- package/dist/common/components/consent-manager-provider.js +59 -0
- package/dist/common/context/consent-manager-context.cjs +38 -0
- package/dist/common/context/consent-manager-context.d.ts +13 -0
- package/dist/common/context/consent-manager-context.d.ts.map +1 -0
- package/dist/common/context/consent-manager-context.js +4 -0
- package/dist/common/hooks/use-consent-manager.cjs +45 -0
- package/dist/common/hooks/use-consent-manager.d.ts +20 -0
- package/dist/common/hooks/use-consent-manager.d.ts.map +1 -0
- package/dist/common/hooks/use-consent-manager.js +11 -0
- package/dist/common/index.cjs +42 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +9 -0
- package/dist/common/store/use-consent-manager.cjs +47 -0
- package/dist/common/store/use-consent-manager.d.ts +136 -0
- package/dist/common/store/use-consent-manager.d.ts.map +1 -0
- package/dist/common/store/use-consent-manager.js +13 -0
- package/dist/common/store/use-translations.cjs +58 -0
- package/dist/common/store/use-translations.d.ts +29 -0
- package/dist/common/store/use-translations.d.ts.map +1 -0
- package/dist/common/store/use-translations.js +24 -0
- package/dist/common/types/consent-manager.cjs +19 -0
- package/dist/common/types/consent-manager.d.ts +82 -0
- package/dist/common/types/consent-manager.d.ts.map +1 -0
- package/dist/common/types/consent-manager.js +0 -0
- package/dist/common/utils/theme.cjs +47 -0
- package/dist/common/utils/theme.d.ts +8 -0
- package/dist/common/utils/theme.d.ts.map +1 -0
- package/dist/common/utils/theme.js +13 -0
- package/dist/common/utils/translations.cjs +86 -0
- package/dist/common/utils/translations.d.ts +14 -0
- package/dist/common/utils/translations.d.ts.map +1 -0
- package/dist/common/utils/translations.js +50 -0
- package/dist/consent-manager-dialog/__tests__/styles.spec.cjs +218 -0
- package/dist/consent-manager-dialog/__tests__/styles.spec.d.ts +2 -0
- package/dist/consent-manager-dialog/__tests__/styles.spec.d.ts.map +1 -0
- package/dist/consent-manager-dialog/__tests__/styles.spec.js +183 -0
- package/dist/consent-manager-dialog/__tests__/utils.cjs +68 -0
- package/dist/consent-manager-dialog/__tests__/utils.d.ts +13 -0
- package/dist/consent-manager-dialog/__tests__/utils.d.ts.map +1 -0
- package/dist/consent-manager-dialog/__tests__/utils.js +34 -0
- package/dist/consent-manager-dialog/atoms/dialog-card.cjs +139 -0
- package/dist/consent-manager-dialog/atoms/dialog-card.d.ts +90 -0
- package/dist/consent-manager-dialog/atoms/dialog-card.d.ts.map +1 -0
- package/dist/consent-manager-dialog/atoms/dialog-card.js +94 -0
- package/dist/consent-manager-dialog/atoms/overlay.cjs +67 -0
- package/dist/consent-manager-dialog/atoms/overlay.d.ts +71 -0
- package/dist/consent-manager-dialog/atoms/overlay.d.ts.map +1 -0
- package/dist/consent-manager-dialog/atoms/overlay.js +32 -0
- package/dist/consent-manager-dialog/consent-manager-dialog.cjs +129 -0
- package/dist/consent-manager-dialog/consent-manager-dialog.css +75 -0
- package/dist/consent-manager-dialog/consent-manager-dialog.d.ts +44 -0
- package/dist/consent-manager-dialog/consent-manager-dialog.d.ts.map +1 -0
- package/dist/consent-manager-dialog/consent-manager-dialog.js +95 -0
- package/dist/consent-manager-dialog/index.cjs +51 -0
- package/dist/consent-manager-dialog/index.d.ts +4 -0
- package/dist/consent-manager-dialog/index.d.ts.map +1 -0
- package/dist/consent-manager-dialog/index.js +18 -0
- package/dist/consent-manager-dialog/theme.cjs +19 -0
- package/dist/consent-manager-dialog/theme.d.ts +19 -0
- package/dist/consent-manager-dialog/theme.d.ts.map +1 -0
- package/dist/consent-manager-dialog/theme.js +0 -0
- package/dist/consent-manager-widget/__tests__/styles.spec.cjs +228 -0
- package/dist/consent-manager-widget/__tests__/styles.spec.d.ts +2 -0
- package/dist/consent-manager-widget/__tests__/styles.spec.d.ts.map +1 -0
- package/dist/consent-manager-widget/__tests__/styles.spec.js +193 -0
- package/dist/consent-manager-widget/__tests__/utils.cjs +68 -0
- package/dist/consent-manager-widget/__tests__/utils.d.ts +13 -0
- package/dist/consent-manager-widget/__tests__/utils.d.ts.map +1 -0
- package/dist/consent-manager-widget/__tests__/utils.js +34 -0
- package/dist/consent-manager-widget/atoms/accordion.cjs +147 -0
- package/dist/consent-manager-widget/atoms/accordion.d.ts +57 -0
- package/dist/consent-manager-widget/atoms/accordion.d.ts.map +1 -0
- package/dist/consent-manager-widget/atoms/accordion.js +98 -0
- package/dist/consent-manager-widget/atoms/button.cjs +77 -0
- package/dist/consent-manager-widget/atoms/button.d.ts +17 -0
- package/dist/consent-manager-widget/atoms/button.d.ts.map +1 -0
- package/dist/consent-manager-widget/atoms/button.js +38 -0
- package/dist/consent-manager-widget/atoms/footer.cjs +70 -0
- package/dist/consent-manager-widget/atoms/footer.d.ts +22 -0
- package/dist/consent-manager-widget/atoms/footer.d.ts.map +1 -0
- package/dist/consent-manager-widget/atoms/footer.js +34 -0
- package/dist/consent-manager-widget/atoms/logo.cjs +101 -0
- package/dist/consent-manager-widget/atoms/logo.d.ts +8 -0
- package/dist/consent-manager-widget/atoms/logo.d.ts.map +1 -0
- package/dist/consent-manager-widget/atoms/logo.js +67 -0
- package/dist/consent-manager-widget/atoms/root.cjs +64 -0
- package/dist/consent-manager-widget/atoms/root.d.ts +82 -0
- package/dist/consent-manager-widget/atoms/root.d.ts.map +1 -0
- package/dist/consent-manager-widget/atoms/root.js +29 -0
- package/dist/consent-manager-widget/consent-manager-widget.cjs +98 -0
- package/dist/consent-manager-widget/consent-manager-widget.css +79 -0
- package/dist/consent-manager-widget/consent-manager-widget.d.ts +51 -0
- package/dist/consent-manager-widget/consent-manager-widget.d.ts.map +1 -0
- package/dist/consent-manager-widget/consent-manager-widget.js +64 -0
- package/dist/consent-manager-widget/index.cjs +62 -0
- package/dist/consent-manager-widget/index.d.ts +10 -0
- package/dist/consent-manager-widget/index.d.ts.map +1 -0
- package/dist/consent-manager-widget/index.js +29 -0
- package/dist/consent-manager-widget/theme.cjs +19 -0
- package/dist/consent-manager-widget/theme.d.ts +48 -0
- package/dist/consent-manager-widget/theme.d.ts.map +1 -0
- package/dist/consent-manager-widget/theme.js +0 -0
- package/dist/consent-manager-widget/types.cjs +19 -0
- package/dist/consent-manager-widget/types.d.ts +18 -0
- package/dist/consent-manager-widget/types.d.ts.map +1 -0
- package/dist/consent-manager-widget/types.js +0 -0
- package/dist/cookie-banner/__tests__/styles.spec.cjs +234 -0
- package/dist/cookie-banner/__tests__/styles.spec.d.ts +2 -0
- package/dist/cookie-banner/__tests__/styles.spec.d.ts.map +1 -0
- package/dist/cookie-banner/__tests__/styles.spec.js +199 -0
- package/dist/cookie-banner/__tests__/utils.cjs +67 -0
- package/dist/cookie-banner/__tests__/utils.d.ts +13 -0
- package/dist/cookie-banner/__tests__/utils.d.ts.map +1 -0
- package/dist/cookie-banner/__tests__/utils.js +33 -0
- package/dist/cookie-banner/atoms/overlay.cjs +71 -0
- package/dist/cookie-banner/atoms/overlay.d.ts +46 -0
- package/dist/cookie-banner/atoms/overlay.d.ts.map +1 -0
- package/dist/cookie-banner/atoms/overlay.js +36 -0
- package/dist/cookie-banner/atoms/root.cjs +116 -0
- package/dist/cookie-banner/atoms/root.d.ts +79 -0
- package/dist/cookie-banner/atoms/root.d.ts.map +1 -0
- package/dist/cookie-banner/atoms/root.js +81 -0
- package/dist/cookie-banner/components.cjs +160 -0
- package/dist/cookie-banner/components.d.ts +136 -0
- package/dist/cookie-banner/components.d.ts.map +1 -0
- package/dist/cookie-banner/components.js +109 -0
- package/dist/cookie-banner/cookie-banner.cjs +99 -0
- package/dist/cookie-banner/cookie-banner.css +226 -0
- package/dist/cookie-banner/cookie-banner.d.ts +134 -0
- package/dist/cookie-banner/cookie-banner.d.ts.map +1 -0
- package/dist/cookie-banner/cookie-banner.js +65 -0
- package/dist/cookie-banner/error-boundary.cjs +68 -0
- package/dist/cookie-banner/error-boundary.d.ts +56 -0
- package/dist/cookie-banner/error-boundary.d.ts.map +1 -0
- package/dist/cookie-banner/error-boundary.js +34 -0
- package/dist/cookie-banner/index.cjs +59 -0
- package/dist/cookie-banner/index.d.ts +52 -0
- package/dist/cookie-banner/index.d.ts.map +1 -0
- package/dist/cookie-banner/index.js +26 -0
- package/dist/cookie-banner/theme.cjs +19 -0
- package/dist/cookie-banner/theme.d.ts +30 -0
- package/dist/cookie-banner/theme.d.ts.map +1 -0
- package/dist/cookie-banner/theme.js +0 -0
- package/dist/index.cjs +89 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/primitives/box.cjs +54 -0
- package/dist/primitives/box.d.ts +47 -0
- package/dist/primitives/box.d.ts.map +1 -0
- package/dist/primitives/box.js +20 -0
- package/dist/primitives/button.cjs +93 -0
- package/dist/primitives/button.d.ts +207 -0
- package/dist/primitives/button.d.ts.map +1 -0
- package/dist/primitives/button.js +59 -0
- package/dist/primitives/button.types.cjs +19 -0
- package/dist/primitives/button.types.d.ts +34 -0
- package/dist/primitives/button.types.d.ts.map +1 -0
- package/dist/primitives/button.types.js +0 -0
- package/dist/theme/context.cjs +44 -0
- package/dist/theme/context.d.ts +96 -0
- package/dist/theme/context.d.ts.map +1 -0
- package/dist/theme/context.js +9 -0
- package/dist/theme/index.cjs +39 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +6 -0
- package/dist/theme/style-keys.cjs +39 -0
- package/dist/theme/style-keys.d.ts +77 -0
- package/dist/theme/style-keys.d.ts.map +1 -0
- package/dist/theme/style-keys.js +5 -0
- package/dist/theme/use-style.cjs +95 -0
- package/dist/theme/use-style.d.ts +32 -0
- package/dist/theme/use-style.d.ts.map +1 -0
- package/dist/theme/use-style.js +61 -0
- package/dist/theme/utils/merge-styles.cjs +62 -0
- package/dist/theme/utils/merge-styles.d.ts +3 -0
- package/dist/theme/utils/merge-styles.d.ts.map +1 -0
- package/dist/theme/utils/merge-styles.js +28 -0
- package/dist/ui/components/accordion.cjs +204 -0
- package/dist/ui/components/accordion.css +158 -0
- package/dist/ui/components/accordion.d.ts +45 -0
- package/dist/ui/components/accordion.d.ts.map +1 -0
- package/dist/ui/components/accordion.js +164 -0
- package/dist/ui/components/button.cjs +185 -0
- package/dist/ui/components/button.css +303 -0
- package/dist/ui/components/button.d.ts +445 -0
- package/dist/ui/components/button.d.ts.map +1 -0
- package/dist/ui/components/button.js +149 -0
- package/dist/ui/components/card.cjs +80 -0
- package/dist/ui/components/card.css +55 -0
- package/dist/ui/components/card.d.ts +10 -0
- package/dist/ui/components/card.d.ts.map +1 -0
- package/dist/ui/components/card.js +41 -0
- package/dist/ui/components/icon.cjs +57 -0
- package/dist/ui/components/icon.d.ts +8 -0
- package/dist/ui/components/icon.d.ts.map +1 -0
- package/dist/ui/components/icon.js +23 -0
- package/dist/ui/components/logo.cjs +101 -0
- package/dist/ui/components/logo.d.ts +8 -0
- package/dist/ui/components/logo.d.ts.map +1 -0
- package/dist/ui/components/logo.js +67 -0
- package/dist/ui/components/switch.cjs +81 -0
- package/dist/ui/components/switch.css +135 -0
- package/dist/ui/components/switch.d.ts +25 -0
- package/dist/ui/components/switch.d.ts.map +1 -0
- package/dist/ui/components/switch.js +47 -0
- package/dist/ui/libs/cn.cjs +55 -0
- package/dist/ui/libs/cn.d.ts +11 -0
- package/dist/ui/libs/cn.d.ts.map +1 -0
- package/dist/ui/libs/cn.js +6 -0
- package/dist/ui/libs/polymorphic.cjs +19 -0
- package/dist/ui/libs/polymorphic.d.ts +15 -0
- package/dist/ui/libs/polymorphic.d.ts.map +1 -0
- package/dist/ui/libs/polymorphic.js +0 -0
- package/dist/ui/libs/recursive-clone-children.cjs +49 -0
- package/dist/ui/libs/recursive-clone-children.d.ts +14 -0
- package/dist/ui/libs/recursive-clone-children.d.ts.map +1 -0
- package/dist/ui/libs/recursive-clone-children.js +15 -0
- package/dist/ui/theme/context.cjs +6 -0
- package/dist/ui/theme/context.d.ts +2 -0
- package/dist/ui/theme/context.d.ts.map +1 -0
- package/dist/ui/theme/context.js +0 -0
- package/package.json +71 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = function(obj, prop) {
|
|
14
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.r = function(exports1) {
|
|
19
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
20
|
+
value: 'Module'
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
var __webpack_exports__ = {};
|
|
28
|
+
__webpack_require__.r(__webpack_exports__);
|
|
29
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
30
|
+
ConsentManagerProvider: ()=>ConsentManagerProvider
|
|
31
|
+
});
|
|
32
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
|
+
const external_c15t_namespaceObject = require("c15t");
|
|
34
|
+
const external_react_namespaceObject = require("react");
|
|
35
|
+
const consent_manager_context_cjs_namespaceObject = require("../context/consent-manager-context.cjs");
|
|
36
|
+
const translations_cjs_namespaceObject = require("../utils/translations.cjs");
|
|
37
|
+
function ConsentManagerProvider({ children, initialGdprTypes, initialComplianceSettings, namespace = 'KoroflowStore', noStyle = false, translationConfig, trackingBlockerConfig }) {
|
|
38
|
+
const preparedTranslationConfig = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
39
|
+
const mergedConfig = (0, translations_cjs_namespaceObject.mergeTranslationConfigs)(external_c15t_namespaceObject.defaultTranslationConfig, translationConfig);
|
|
40
|
+
const defaultLanguage = (0, translations_cjs_namespaceObject.detectBrowserLanguage)(mergedConfig.translations, mergedConfig.defaultLanguage, mergedConfig.disableAutoLanguageSwitch);
|
|
41
|
+
return {
|
|
42
|
+
...mergedConfig,
|
|
43
|
+
defaultLanguage
|
|
44
|
+
};
|
|
45
|
+
}, [
|
|
46
|
+
translationConfig
|
|
47
|
+
]);
|
|
48
|
+
const store = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
49
|
+
const store = (0, external_c15t_namespaceObject.createConsentManagerStore)(namespace, {
|
|
50
|
+
trackingBlockerConfig
|
|
51
|
+
});
|
|
52
|
+
store.getState().setTranslationConfig(preparedTranslationConfig);
|
|
53
|
+
return store;
|
|
54
|
+
}, [
|
|
55
|
+
namespace,
|
|
56
|
+
preparedTranslationConfig,
|
|
57
|
+
trackingBlockerConfig
|
|
58
|
+
]);
|
|
59
|
+
const [state, setState] = (0, external_react_namespaceObject.useState)(store.getState());
|
|
60
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
61
|
+
const { setGdprTypes, setComplianceSetting, setDetectedCountry } = store.getState();
|
|
62
|
+
if (initialGdprTypes) setGdprTypes(initialGdprTypes);
|
|
63
|
+
if (initialComplianceSettings) for (const [region, settings] of Object.entries(initialComplianceSettings))setComplianceSetting(region, settings);
|
|
64
|
+
const country = document.querySelector('meta[name="user-country"]')?.getAttribute('content') || 'US';
|
|
65
|
+
setDetectedCountry(country);
|
|
66
|
+
const unsubscribe = store.subscribe((newState)=>{
|
|
67
|
+
setState(newState);
|
|
68
|
+
});
|
|
69
|
+
return ()=>{
|
|
70
|
+
unsubscribe();
|
|
71
|
+
};
|
|
72
|
+
}, [
|
|
73
|
+
store,
|
|
74
|
+
initialGdprTypes,
|
|
75
|
+
initialComplianceSettings
|
|
76
|
+
]);
|
|
77
|
+
const contextValue = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
78
|
+
state,
|
|
79
|
+
store
|
|
80
|
+
}), [
|
|
81
|
+
state,
|
|
82
|
+
store
|
|
83
|
+
]);
|
|
84
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(consent_manager_context_cjs_namespaceObject.ConsentStateContext.Provider, {
|
|
85
|
+
value: contextValue,
|
|
86
|
+
children: children
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
var __webpack_export_target__ = exports;
|
|
90
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
91
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
92
|
+
value: true
|
|
93
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConsentManagerProviderProps } from '../types/consent-manager';
|
|
2
|
+
/**
|
|
3
|
+
* Provider component for consent management functionality.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This component initializes and manages the consent management system, including:
|
|
7
|
+
* - Setting up the consent store with initial configuration
|
|
8
|
+
* - Detecting user's region for compliance
|
|
9
|
+
* - Managing consent state updates
|
|
10
|
+
* - Providing access to consent management throughout the app
|
|
11
|
+
* - Injecting default styles (unless noStyle is true)
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare function ConsentManagerProvider({ children, initialGdprTypes, initialComplianceSettings, namespace, noStyle, translationConfig, trackingBlockerConfig, }: ConsentManagerProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=consent-manager-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-manager-provider.d.ts","sourceRoot":"","sources":["../../../src/common/components/consent-manager-provider.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAM5E;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,EACtC,QAAQ,EACR,gBAAgB,EAChB,yBAAyB,EACzB,SAA2B,EAC3B,OAAe,EACf,iBAAiB,EACjB,qBAAqB,GACrB,EAAE,2BAA2B,2CA6E7B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_c15t__ from "c15t";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__ from "../context/consent-manager-context.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_translations_js_c2629c1f__ from "../utils/translations.js";
|
|
7
|
+
function ConsentManagerProvider({ children, initialGdprTypes, initialComplianceSettings, namespace = 'KoroflowStore', noStyle = false, translationConfig, trackingBlockerConfig }) {
|
|
8
|
+
const preparedTranslationConfig = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
9
|
+
const mergedConfig = (0, __WEBPACK_EXTERNAL_MODULE__utils_translations_js_c2629c1f__.mergeTranslationConfigs)(__WEBPACK_EXTERNAL_MODULE_c15t__.defaultTranslationConfig, translationConfig);
|
|
10
|
+
const defaultLanguage = (0, __WEBPACK_EXTERNAL_MODULE__utils_translations_js_c2629c1f__.detectBrowserLanguage)(mergedConfig.translations, mergedConfig.defaultLanguage, mergedConfig.disableAutoLanguageSwitch);
|
|
11
|
+
return {
|
|
12
|
+
...mergedConfig,
|
|
13
|
+
defaultLanguage
|
|
14
|
+
};
|
|
15
|
+
}, [
|
|
16
|
+
translationConfig
|
|
17
|
+
]);
|
|
18
|
+
const store = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
19
|
+
const store = (0, __WEBPACK_EXTERNAL_MODULE_c15t__.createConsentManagerStore)(namespace, {
|
|
20
|
+
trackingBlockerConfig
|
|
21
|
+
});
|
|
22
|
+
store.getState().setTranslationConfig(preparedTranslationConfig);
|
|
23
|
+
return store;
|
|
24
|
+
}, [
|
|
25
|
+
namespace,
|
|
26
|
+
preparedTranslationConfig,
|
|
27
|
+
trackingBlockerConfig
|
|
28
|
+
]);
|
|
29
|
+
const [state, setState] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(store.getState());
|
|
30
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
31
|
+
const { setGdprTypes, setComplianceSetting, setDetectedCountry } = store.getState();
|
|
32
|
+
if (initialGdprTypes) setGdprTypes(initialGdprTypes);
|
|
33
|
+
if (initialComplianceSettings) for (const [region, settings] of Object.entries(initialComplianceSettings))setComplianceSetting(region, settings);
|
|
34
|
+
const country = document.querySelector('meta[name="user-country"]')?.getAttribute('content') || 'US';
|
|
35
|
+
setDetectedCountry(country);
|
|
36
|
+
const unsubscribe = store.subscribe((newState)=>{
|
|
37
|
+
setState(newState);
|
|
38
|
+
});
|
|
39
|
+
return ()=>{
|
|
40
|
+
unsubscribe();
|
|
41
|
+
};
|
|
42
|
+
}, [
|
|
43
|
+
store,
|
|
44
|
+
initialGdprTypes,
|
|
45
|
+
initialComplianceSettings
|
|
46
|
+
]);
|
|
47
|
+
const contextValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
48
|
+
state,
|
|
49
|
+
store
|
|
50
|
+
}), [
|
|
51
|
+
state,
|
|
52
|
+
store
|
|
53
|
+
]);
|
|
54
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__.ConsentStateContext.Provider, {
|
|
55
|
+
value: contextValue,
|
|
56
|
+
children: children
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export { ConsentManagerProvider };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = function(obj, prop) {
|
|
14
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.r = function(exports1) {
|
|
19
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
20
|
+
value: 'Module'
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
var __webpack_exports__ = {};
|
|
28
|
+
__webpack_require__.r(__webpack_exports__);
|
|
29
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
30
|
+
ConsentStateContext: ()=>ConsentStateContext
|
|
31
|
+
});
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const ConsentStateContext = external_react_namespaceObject.createContext(void 0);
|
|
34
|
+
var __webpack_export_target__ = exports;
|
|
35
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
36
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
37
|
+
value: true
|
|
38
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ConsentManagerContextValue } from '../types/consent-manager';
|
|
3
|
+
/**
|
|
4
|
+
* React context for sharing consent management state.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This context provides access to both the current consent state and
|
|
8
|
+
* the methods to modify it throughout the application.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const ConsentStateContext: React.Context<ConsentManagerContextValue | undefined>;
|
|
13
|
+
//# sourceMappingURL=consent-manager-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-manager-context.d.ts","sourceRoot":"","sources":["../../../src/common/context/consent-manager-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAE3E;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,uDAEpB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
useConsentManager: ()=>useConsentManager
|
|
30
|
+
});
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const consent_manager_context_cjs_namespaceObject = require("../context/consent-manager-context.cjs");
|
|
33
|
+
function useConsentManager() {
|
|
34
|
+
const context = (0, external_react_namespaceObject.useContext)(consent_manager_context_cjs_namespaceObject.ConsentStateContext);
|
|
35
|
+
if (void 0 === context) throw new Error('useConsentManager must be used within a ConsentManagerProvider');
|
|
36
|
+
return {
|
|
37
|
+
...context.state,
|
|
38
|
+
...context.store.getState()
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
var __webpack_export_target__ = exports;
|
|
42
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
43
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for accessing and managing consent state.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This hook provides access to the complete consent management API, including:
|
|
6
|
+
* - Current consent state (what consents are given/required)
|
|
7
|
+
* - Methods to update consents
|
|
8
|
+
* - Compliance settings and region detection
|
|
9
|
+
* - State persistence and retrieval
|
|
10
|
+
*
|
|
11
|
+
* The hook must be used within a ConsentManagerProvider component.
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error}
|
|
14
|
+
* Throws if used outside of a ConsentManagerProvider context.
|
|
15
|
+
*
|
|
16
|
+
* @returns Combined state and methods for consent management
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function useConsentManager(): any;
|
|
20
|
+
//# sourceMappingURL=use-consent-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-consent-manager.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-consent-manager.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,QAahC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__ from "../context/consent-manager-context.js";
|
|
3
|
+
function useConsentManager() {
|
|
4
|
+
const context = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__.ConsentStateContext);
|
|
5
|
+
if (void 0 === context) throw new Error('useConsentManager must be used within a ConsentManagerProvider');
|
|
6
|
+
return {
|
|
7
|
+
...context.state,
|
|
8
|
+
...context.store.getState()
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export { useConsentManager };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
consentTypes: ()=>external_c15t_namespaceObject.consentTypes,
|
|
30
|
+
ConsentManagerProvider: ()=>consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,
|
|
31
|
+
useConsentManager: ()=>use_consent_manager_cjs_namespaceObject.useConsentManager,
|
|
32
|
+
useTranslations: ()=>use_translations_cjs_namespaceObject.useTranslations
|
|
33
|
+
});
|
|
34
|
+
const consent_manager_provider_cjs_namespaceObject = require("./components/consent-manager-provider.cjs");
|
|
35
|
+
const use_consent_manager_cjs_namespaceObject = require("./hooks/use-consent-manager.cjs");
|
|
36
|
+
const use_translations_cjs_namespaceObject = require("./store/use-translations.cjs");
|
|
37
|
+
const external_c15t_namespaceObject = require("c15t");
|
|
38
|
+
var __webpack_export_target__ = exports;
|
|
39
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
40
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
41
|
+
value: true
|
|
42
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ConsentManagerProvider } from './components/consent-manager-provider';
|
|
2
|
+
export { useConsentManager } from './hooks/use-consent-manager';
|
|
3
|
+
export type { ConsentManagerProviderProps } from './types/consent-manager';
|
|
4
|
+
export { useTranslations } from './store/use-translations';
|
|
5
|
+
export { consentTypes } from 'c15t';
|
|
6
|
+
export type { CallbackFunction, Callbacks, AllConsentNames, ConsentType, ConsentState, ComplianceRegion, ComplianceSettings, PrivacySettings, HasConsentedProps, } from 'c15t';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,YAAY,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,YAAY,EACX,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,GACjB,MAAM,MAAM,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__components_consent_manager_provider_js_f0dc1a38__ from "./components/consent-manager-provider.js";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_use_consent_manager_js_2b895421__ from "./hooks/use-consent-manager.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__store_use_translations_js_f5c44c99__ from "./store/use-translations.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_c15t__ from "c15t";
|
|
5
|
+
var __webpack_exports__ConsentManagerProvider = __WEBPACK_EXTERNAL_MODULE__components_consent_manager_provider_js_f0dc1a38__.ConsentManagerProvider;
|
|
6
|
+
var __webpack_exports__consentTypes = __WEBPACK_EXTERNAL_MODULE_c15t__.consentTypes;
|
|
7
|
+
var __webpack_exports__useConsentManager = __WEBPACK_EXTERNAL_MODULE__hooks_use_consent_manager_js_2b895421__.useConsentManager;
|
|
8
|
+
var __webpack_exports__useTranslations = __WEBPACK_EXTERNAL_MODULE__store_use_translations_js_f5c44c99__.useTranslations;
|
|
9
|
+
export { __webpack_exports__ConsentManagerProvider as ConsentManagerProvider, __webpack_exports__consentTypes as consentTypes, __webpack_exports__useConsentManager as useConsentManager, __webpack_exports__useTranslations as useTranslations };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = function(obj, prop) {
|
|
14
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.r = function(exports1) {
|
|
19
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
20
|
+
value: 'Module'
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
var __webpack_exports__ = {};
|
|
28
|
+
__webpack_require__.r(__webpack_exports__);
|
|
29
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
30
|
+
useConsentManager: ()=>useConsentManager
|
|
31
|
+
});
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const consent_manager_context_cjs_namespaceObject = require("../context/consent-manager-context.cjs");
|
|
34
|
+
function useConsentManager() {
|
|
35
|
+
const context = (0, external_react_namespaceObject.useContext)(consent_manager_context_cjs_namespaceObject.ConsentStateContext);
|
|
36
|
+
if (void 0 === context) throw new Error('useConsentManager must be used within a ConsentManagerProvider');
|
|
37
|
+
const storeState = context.store.getState();
|
|
38
|
+
return {
|
|
39
|
+
...context.state,
|
|
40
|
+
...storeState
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var __webpack_export_target__ = exports;
|
|
44
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
45
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { PrivacyConsentState, createConsentManagerStore } from 'c15t';
|
|
2
|
+
/**
|
|
3
|
+
* A custom React hook that provides access to the privacy consent state and management methods.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This hook serves as the primary interface for interacting with the consent management system.
|
|
7
|
+
* It provides access to:
|
|
8
|
+
* - Current consent states for different types (analytics, marketing, etc.)
|
|
9
|
+
* - Methods to update and save consent preferences
|
|
10
|
+
* - Compliance settings and region detection
|
|
11
|
+
* - State persistence and retrieval
|
|
12
|
+
*
|
|
13
|
+
* The hook combines both the static state and dynamic methods from the consent manager store,
|
|
14
|
+
* providing a unified API for consent management.
|
|
15
|
+
*
|
|
16
|
+
* Available methods include:
|
|
17
|
+
* - `hasConsent(type: AllConsentNames)`: Check if a specific consent type is granted
|
|
18
|
+
* - `setGdprTypes(types: AllConsentNames[])`: Update allowed GDPR consent types
|
|
19
|
+
* - `saveConsents(type: 'all' | 'custom' | 'necessary')`: Save current consent preferences
|
|
20
|
+
* - `getConsentedTypes()`: Get array of currently consented types
|
|
21
|
+
* - `setComplianceSetting(region, settings)`: Update compliance settings for a region
|
|
22
|
+
*
|
|
23
|
+
* State properties include:
|
|
24
|
+
* - `isConsentRequired`: Whether consent is required in the current region
|
|
25
|
+
* - `detectedCountry`: The detected country code for the user
|
|
26
|
+
* - `complianceSettings`: Region-specific compliance configuration
|
|
27
|
+
* - `consents`: Current state of all consent types
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error}
|
|
30
|
+
* Throws if used outside of a {@link ConsentManagerProvider} context with the message
|
|
31
|
+
* "useConsentManager must be used within a ConsentManagerProvider"
|
|
32
|
+
*
|
|
33
|
+
* @returns {PrivacyConsentState & ReturnType<typeof createConsentManagerStore>["getState"]}
|
|
34
|
+
* Returns a combined object containing:
|
|
35
|
+
* - All properties from {@link PrivacyConsentState}
|
|
36
|
+
* - All methods from the consent manager store
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* Basic consent checking:
|
|
40
|
+
* ```tsx
|
|
41
|
+
* function AnalyticsFeature() {
|
|
42
|
+
* const { hasConsent, isConsentRequired } = useConsentManager();
|
|
43
|
+
*
|
|
44
|
+
* // Check if analytics consent is required and granted
|
|
45
|
+
* if (isConsentRequired && !hasConsent('analytics')) {
|
|
46
|
+
* return <p>Please accept analytics cookies to use this feature.</p>;
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* return <div>Analytics Feature Content</div>;
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* Managing consent preferences with Do Not Track support:
|
|
55
|
+
* ```tsx
|
|
56
|
+
* function ConsentControls() {
|
|
57
|
+
* const {
|
|
58
|
+
* setGdprTypes,
|
|
59
|
+
* saveConsents,
|
|
60
|
+
* getConsentedTypes,
|
|
61
|
+
* honorDoNotTrack
|
|
62
|
+
* } = useConsentManager();
|
|
63
|
+
*
|
|
64
|
+
* const handleAcceptAll = () => {
|
|
65
|
+
* // Set all available consent types
|
|
66
|
+
* setGdprTypes(['necessary', 'functional', 'analytics', 'marketing']);
|
|
67
|
+
* // Save preferences with 'all' type
|
|
68
|
+
* saveConsents('all');
|
|
69
|
+
* };
|
|
70
|
+
*
|
|
71
|
+
* const handleCustomize = () => {
|
|
72
|
+
* // Get current consents and add analytics
|
|
73
|
+
* const currentConsents = getConsentedTypes();
|
|
74
|
+
* setGdprTypes([...currentConsents, 'analytics']);
|
|
75
|
+
* // Save as custom preferences
|
|
76
|
+
* saveConsents('custom');
|
|
77
|
+
* };
|
|
78
|
+
*
|
|
79
|
+
* // Respect Do Not Track setting
|
|
80
|
+
* if (honorDoNotTrack && window.navigator.doNotTrack === "1") {
|
|
81
|
+
* return <p>Respecting Do Not Track preference</p>;
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* return (
|
|
85
|
+
* <div>
|
|
86
|
+
* <button onClick={handleAcceptAll}>Accept All</button>
|
|
87
|
+
* <button onClick={handleCustomize}>Customize</button>
|
|
88
|
+
* </div>
|
|
89
|
+
* );
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* Checking compliance requirements and region-specific settings:
|
|
95
|
+
* ```tsx
|
|
96
|
+
* function CookieBanner() {
|
|
97
|
+
* const {
|
|
98
|
+
* isConsentRequired,
|
|
99
|
+
* detectedCountry,
|
|
100
|
+
* complianceSettings,
|
|
101
|
+
* setComplianceSetting
|
|
102
|
+
* } = useConsentManager();
|
|
103
|
+
*
|
|
104
|
+
* useEffect(() => {
|
|
105
|
+
* // Update settings for a specific region
|
|
106
|
+
* setComplianceSetting('EU', {
|
|
107
|
+
* requireConsent: true,
|
|
108
|
+
* showBanner: true,
|
|
109
|
+
* honorDoNotTrack: true
|
|
110
|
+
* });
|
|
111
|
+
* }, []);
|
|
112
|
+
*
|
|
113
|
+
* if (!isConsentRequired) return null;
|
|
114
|
+
*
|
|
115
|
+
* const settings = complianceSettings[detectedCountry];
|
|
116
|
+
*
|
|
117
|
+
* return (
|
|
118
|
+
* <div>
|
|
119
|
+
* <h2>Cookie Preferences</h2>
|
|
120
|
+
* <p>Your current region: {detectedCountry}</p>
|
|
121
|
+
* {settings.showBanner && (
|
|
122
|
+
* <ConsentControls />
|
|
123
|
+
* )}
|
|
124
|
+
* </div>
|
|
125
|
+
* );
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @see {@link ConsentManagerProvider} For the provider component that makes this hook available
|
|
130
|
+
* @see {@link PrivacyConsentState} For the complete state interface
|
|
131
|
+
* @see {@link AllConsentNames} For available consent type names
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
export declare function useConsentManager(): PrivacyConsentState & ReturnType<typeof createConsentManagerStore>['getState'];
|
|
136
|
+
//# sourceMappingURL=use-consent-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-consent-manager.d.ts","sourceRoot":"","sources":["../../../src/common/store/use-consent-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,MAAM,CAAC;AAI3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoIG;AACH,wBAAgB,iBAAiB,IAAI,mBAAmB,GACvD,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,UAAU,CAAC,CAgBxD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__ from "../context/consent-manager-context.js";
|
|
4
|
+
function useConsentManager() {
|
|
5
|
+
const context = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__.ConsentStateContext);
|
|
6
|
+
if (void 0 === context) throw new Error('useConsentManager must be used within a ConsentManagerProvider');
|
|
7
|
+
const storeState = context.store.getState();
|
|
8
|
+
return {
|
|
9
|
+
...context.state,
|
|
10
|
+
...storeState
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export { useConsentManager };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = function(obj, prop) {
|
|
14
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.r = function(exports1) {
|
|
19
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
20
|
+
value: 'Module'
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
var __webpack_exports__ = {};
|
|
28
|
+
__webpack_require__.r(__webpack_exports__);
|
|
29
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
30
|
+
useTranslations: ()=>useTranslations
|
|
31
|
+
});
|
|
32
|
+
const external_c15t_namespaceObject = require("c15t");
|
|
33
|
+
const external_react_namespaceObject = require("react");
|
|
34
|
+
const external_use_consent_manager_cjs_namespaceObject = require("./use-consent-manager.cjs");
|
|
35
|
+
function useTranslations() {
|
|
36
|
+
const { translationConfig } = (0, external_use_consent_manager_cjs_namespaceObject.useConsentManager)();
|
|
37
|
+
return (0, external_react_namespaceObject.useMemo)(()=>{
|
|
38
|
+
const { translations = {}, defaultLanguage = 'en' } = translationConfig;
|
|
39
|
+
const selectedTranslations = translations[defaultLanguage];
|
|
40
|
+
if (isTranslations(selectedTranslations)) return selectedTranslations;
|
|
41
|
+
const englishTranslations = translations.en;
|
|
42
|
+
if (isTranslations(englishTranslations)) return englishTranslations;
|
|
43
|
+
return external_c15t_namespaceObject.defaultTranslationConfig.translations.en;
|
|
44
|
+
}, [
|
|
45
|
+
translationConfig
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
function isTranslations(value) {
|
|
49
|
+
if (!value || 'object' != typeof value) return false;
|
|
50
|
+
const obj = value;
|
|
51
|
+
const hasRequiredKeys = 'cookieBanner' in obj && 'consentManagerDialog' in obj && 'consentManagerWidget' in obj && 'consentTypes' in obj;
|
|
52
|
+
return hasRequiredKeys;
|
|
53
|
+
}
|
|
54
|
+
var __webpack_export_target__ = exports;
|
|
55
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
56
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|