@c15t/react 1.0.5 → 1.1.0
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/components/consent-manager-dialog/__tests__/styles.spec.cjs +1 -239
- package/dist/components/consent-manager-dialog/__tests__/styles.spec.js +1 -211
- package/dist/components/consent-manager-dialog/atoms/dialog-card.cjs +1 -188
- package/dist/components/consent-manager-dialog/atoms/dialog-card.js +1 -108
- package/dist/components/consent-manager-dialog/atoms/overlay.cjs +1 -84
- package/dist/components/consent-manager-dialog/atoms/overlay.d.ts +1 -1
- package/dist/components/consent-manager-dialog/atoms/overlay.d.ts.map +1 -1
- package/dist/components/consent-manager-dialog/atoms/overlay.js +1 -37
- package/dist/components/consent-manager-dialog/consent-manager-dialog.cjs +1 -143
- package/dist/components/consent-manager-dialog/consent-manager-dialog.d.ts +5 -0
- package/dist/components/consent-manager-dialog/consent-manager-dialog.d.ts.map +1 -1
- package/dist/components/consent-manager-dialog/consent-manager-dialog.js +1 -99
- package/dist/components/consent-manager-dialog/consent-manager-dialog.module.cjs +1 -52
- package/dist/components/consent-manager-dialog/consent-manager-dialog.module.js +1 -18
- package/dist/components/consent-manager-dialog/consent-manager-dialog_module.css +1 -217
- package/dist/components/consent-manager-dialog/index.cjs +1 -76
- package/dist/components/consent-manager-dialog/index.js +1 -17
- package/dist/components/consent-manager-dialog/theme.cjs +1 -18
- package/dist/components/consent-manager-widget/__tests__/styles.spec.cjs +1 -249
- package/dist/components/consent-manager-widget/__tests__/styles.spec.js +1 -221
- package/dist/components/consent-manager-widget/atoms/accordion.cjs +1 -195
- package/dist/components/consent-manager-widget/atoms/accordion.js +1 -106
- package/dist/components/consent-manager-widget/atoms/button.cjs +1 -107
- package/dist/components/consent-manager-widget/atoms/button.js +1 -52
- package/dist/components/consent-manager-widget/atoms/footer.cjs +1 -76
- package/dist/components/consent-manager-widget/atoms/footer.js +1 -23
- package/dist/components/consent-manager-widget/atoms/root.cjs +1 -61
- package/dist/components/consent-manager-widget/atoms/root.js +1 -24
- package/dist/components/consent-manager-widget/consent-manager-widget.cjs +1 -84
- package/dist/components/consent-manager-widget/consent-manager-widget.js +1 -50
- package/dist/components/consent-manager-widget/consent-manager-widget.module.cjs +1 -60
- package/dist/components/consent-manager-widget/consent-manager-widget.module.js +1 -26
- package/dist/components/consent-manager-widget/consent-manager-widget_module.css +1 -332
- package/dist/components/consent-manager-widget/index.cjs +1 -126
- package/dist/components/consent-manager-widget/index.js +1 -35
- package/dist/components/consent-manager-widget/theme.cjs +1 -18
- package/dist/components/consent-manager-widget/types.cjs +1 -18
- package/dist/components/cookie-banner/__tests__/cookie-banner.e2e.test.cjs +1 -189
- package/dist/components/cookie-banner/__tests__/cookie-banner.e2e.test.js +1 -183
- package/dist/components/cookie-banner/__tests__/styles.spec.cjs +1 -251
- package/dist/components/cookie-banner/__tests__/styles.spec.js +1 -223
- package/dist/components/cookie-banner/atoms/overlay.cjs +1 -87
- package/dist/components/cookie-banner/atoms/overlay.d.ts.map +1 -1
- package/dist/components/cookie-banner/atoms/overlay.js +1 -40
- package/dist/components/cookie-banner/atoms/root.cjs +1 -129
- package/dist/components/cookie-banner/atoms/root.d.ts.map +1 -1
- package/dist/components/cookie-banner/atoms/root.js +1 -82
- package/dist/components/cookie-banner/components.cjs +1 -216
- package/dist/components/cookie-banner/components.js +1 -121
- package/dist/components/cookie-banner/cookie-banner.cjs +1 -99
- package/dist/components/cookie-banner/cookie-banner.js +1 -65
- package/dist/components/cookie-banner/cookie-banner.module.cjs +1 -55
- package/dist/components/cookie-banner/cookie-banner.module.js +1 -21
- package/dist/components/cookie-banner/cookie-banner_module.css +1 -224
- package/dist/components/cookie-banner/error-boundary.cjs +1 -66
- package/dist/components/cookie-banner/error-boundary.js +1 -32
- package/dist/components/cookie-banner/index.cjs +1 -101
- package/dist/components/cookie-banner/index.js +1 -26
- package/dist/components/cookie-banner/theme.cjs +1 -18
- package/dist/components/shared/libs/polymorphic.cjs +1 -18
- package/dist/components/shared/libs/recursive-clone-children.cjs +1 -49
- package/dist/components/shared/libs/recursive-clone-children.js +1 -15
- package/dist/components/shared/primitives/box.cjs +1 -53
- package/dist/components/shared/primitives/box.js +1 -19
- package/dist/components/shared/primitives/button.cjs +1 -96
- package/dist/components/shared/primitives/button.d.ts +2 -86
- package/dist/components/shared/primitives/button.d.ts.map +1 -1
- package/dist/components/shared/primitives/button.js +1 -62
- package/dist/components/shared/primitives/button.types.cjs +1 -18
- package/dist/components/shared/ui/accordion/accordion.cjs +1 -226
- package/dist/components/shared/ui/accordion/accordion.js +1 -164
- package/dist/components/shared/ui/accordion/accordion.module.cjs +1 -49
- package/dist/components/shared/ui/accordion/accordion.module.js +1 -15
- package/dist/components/shared/ui/accordion/accordion.types.cjs +1 -18
- package/dist/components/shared/ui/accordion/accordion_module.css +1 -216
- package/dist/components/shared/ui/accordion/index.cjs +1 -69
- package/dist/components/shared/ui/accordion/index.js +1 -2
- package/dist/components/shared/ui/button/button.cjs +1 -199
- package/dist/components/shared/ui/button/button.d.ts +36 -182
- package/dist/components/shared/ui/button/button.d.ts.map +1 -1
- package/dist/components/shared/ui/button/button.js +1 -149
- package/dist/components/shared/ui/button/button.module.cjs +1 -65
- package/dist/components/shared/ui/button/button.module.js +1 -31
- package/dist/components/shared/ui/button/button.types.cjs +1 -18
- package/dist/components/shared/ui/button/button.types.d.ts +2 -0
- package/dist/components/shared/ui/button/button.types.d.ts.map +1 -1
- package/dist/components/shared/ui/button/button_module.css +1 -268
- package/dist/components/shared/ui/button/index.cjs +1 -69
- package/dist/components/shared/ui/button/index.js +1 -2
- package/dist/components/shared/ui/icon.cjs +1 -57
- package/dist/components/shared/ui/icon.js +1 -23
- package/dist/components/shared/ui/logo.cjs +1 -90
- package/dist/components/shared/ui/logo.js +1 -53
- package/dist/components/shared/ui/switch/index.cjs +1 -69
- package/dist/components/shared/ui/switch/index.js +1 -2
- package/dist/components/shared/ui/switch/switch.cjs +1 -91
- package/dist/components/shared/ui/switch/switch.js +1 -47
- package/dist/components/shared/ui/switch/switch.module.cjs +1 -45
- package/dist/components/shared/ui/switch/switch.module.js +1 -11
- package/dist/components/shared/ui/switch/switch.types.cjs +1 -18
- package/dist/components/shared/ui/switch/switch_module.css +1 -197
- package/dist/context/consent-manager-context.cjs +1 -37
- package/dist/context/consent-manager-context.js +1 -3
- package/dist/context/theme-context.cjs +1 -47
- package/dist/context/theme-context.js +1 -10
- package/dist/hooks/__tests__/use-consent-manager.test.cjs +1 -76
- package/dist/hooks/__tests__/use-consent-manager.test.js +1 -70
- package/dist/hooks/__tests__/use-styles.test.cjs +1 -76
- package/dist/hooks/__tests__/use-styles.test.js +1 -70
- package/dist/hooks/__tests__/use-theme.test.cjs +1 -86
- package/dist/hooks/__tests__/use-theme.test.js +1 -80
- package/dist/hooks/index.cjs +1 -87
- package/dist/hooks/index.js +1 -20
- package/dist/hooks/use-color-scheme.cjs +1 -66
- package/dist/hooks/use-color-scheme.js +1 -32
- package/dist/hooks/use-consent-manager.cjs +1 -49
- package/dist/hooks/use-consent-manager.js +1 -15
- package/dist/hooks/use-focus-trap.cjs +1 -76
- package/dist/hooks/use-focus-trap.js +1 -42
- package/dist/hooks/use-scroll-lock.cjs +1 -55
- package/dist/hooks/use-scroll-lock.js +1 -21
- package/dist/hooks/use-styles.cjs +1 -94
- package/dist/hooks/use-styles.js +1 -60
- package/dist/hooks/use-theme.cjs +1 -53
- package/dist/hooks/use-theme.js +1 -19
- package/dist/hooks/use-translations.cjs +1 -57
- package/dist/hooks/use-translations.js +1 -23
- package/dist/index.cjs +1 -137
- package/dist/index.js +1 -20
- package/dist/providers/__tests__/provider-basic.test.cjs +1 -127
- package/dist/providers/__tests__/provider-basic.test.js +1 -121
- package/dist/providers/__tests__/provider-context.test.cjs +1 -139
- package/dist/providers/__tests__/provider-context.test.js +1 -133
- package/dist/providers/__tests__/provider-errors.test.cjs +1 -98
- package/dist/providers/__tests__/provider-errors.test.js +1 -92
- package/dist/providers/__tests__/test-helpers.cjs +1 -171
- package/dist/providers/__tests__/test-helpers.js +1 -134
- package/dist/providers/consent-manager-provider.cjs +1 -162
- package/dist/providers/consent-manager-provider.js +1 -128
- package/dist/types/consent-manager.cjs +1 -18
- package/dist/types/theme/index.cjs +1 -69
- package/dist/types/theme/index.js +1 -2
- package/dist/types/theme/style-keys.cjs +1 -18
- package/dist/types/theme/style-types.cjs +1 -18
- package/dist/utils/cn.cjs +1 -49
- package/dist/utils/cn.js +1 -5
- package/dist/utils/merge-styles.cjs +1 -62
- package/dist/utils/merge-styles.js +1 -28
- package/dist/utils/test-helpers.cjs +1 -70
- package/dist/utils/test-helpers.js +1 -33
- package/dist/utils/translations.cjs +1 -89
- package/dist/utils/translations.js +1 -49
- package/package.json +4 -6
|
@@ -1,171 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
setupMocks: ()=>setupMocks,
|
|
28
|
-
TestConsumer: ()=>TestConsumer
|
|
29
|
-
});
|
|
30
|
-
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const external_vitest_namespaceObject = require("vitest");
|
|
32
|
-
const external_index_cjs_namespaceObject = require("../../index.cjs");
|
|
33
|
-
function setupMocks() {
|
|
34
|
-
const mockFetch = external_vitest_namespaceObject.vi.fn();
|
|
35
|
-
window.fetch = mockFetch;
|
|
36
|
-
const mockConfigureConsentManager = external_vitest_namespaceObject.vi.fn();
|
|
37
|
-
const fetchCallMap = new Map();
|
|
38
|
-
(0, external_vitest_namespaceObject.beforeEach)(()=>{
|
|
39
|
-
fetchCallMap.clear();
|
|
40
|
-
});
|
|
41
|
-
external_vitest_namespaceObject.vi.mock('c15t', async ()=>{
|
|
42
|
-
const originalModule = await external_vitest_namespaceObject.vi.importActual('c15t');
|
|
43
|
-
return {
|
|
44
|
-
...originalModule,
|
|
45
|
-
configureConsentManager: (options)=>{
|
|
46
|
-
mockConfigureConsentManager(options);
|
|
47
|
-
const backendURL = options.backendURL || '';
|
|
48
|
-
if ('c15t' === options.mode) return {
|
|
49
|
-
getCallbacks: ()=>options.callbacks,
|
|
50
|
-
showConsentBanner: async ()=>{
|
|
51
|
-
if (!fetchCallMap.has(backendURL)) {
|
|
52
|
-
mockFetch(`${backendURL}/show-consent-banner`, {
|
|
53
|
-
headers: {
|
|
54
|
-
'Content-Type': 'application/json'
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
fetchCallMap.set(backendURL, true);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
ok: true,
|
|
61
|
-
data: {
|
|
62
|
-
showConsentBanner: true
|
|
63
|
-
},
|
|
64
|
-
error: null,
|
|
65
|
-
response: null
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
setConsent: async ()=>({
|
|
69
|
-
ok: true,
|
|
70
|
-
data: {
|
|
71
|
-
success: true
|
|
72
|
-
},
|
|
73
|
-
error: null,
|
|
74
|
-
response: null
|
|
75
|
-
}),
|
|
76
|
-
verifyConsent: async ()=>({
|
|
77
|
-
ok: true,
|
|
78
|
-
data: {
|
|
79
|
-
valid: true
|
|
80
|
-
},
|
|
81
|
-
error: null,
|
|
82
|
-
response: null
|
|
83
|
-
})
|
|
84
|
-
};
|
|
85
|
-
if ('offline' === options.mode) return {
|
|
86
|
-
getCallbacks: ()=>options.callbacks,
|
|
87
|
-
showConsentBanner: async ()=>({
|
|
88
|
-
ok: true,
|
|
89
|
-
data: {
|
|
90
|
-
showConsentBanner: true
|
|
91
|
-
},
|
|
92
|
-
error: null,
|
|
93
|
-
response: null
|
|
94
|
-
}),
|
|
95
|
-
setConsent: async ()=>({
|
|
96
|
-
ok: true,
|
|
97
|
-
data: {
|
|
98
|
-
success: true
|
|
99
|
-
},
|
|
100
|
-
error: null,
|
|
101
|
-
response: null
|
|
102
|
-
}),
|
|
103
|
-
verifyConsent: async ()=>({
|
|
104
|
-
ok: true,
|
|
105
|
-
data: {
|
|
106
|
-
valid: true
|
|
107
|
-
},
|
|
108
|
-
error: null,
|
|
109
|
-
response: null
|
|
110
|
-
})
|
|
111
|
-
};
|
|
112
|
-
if ('custom' === options.mode && 'endpointHandlers' in options) {
|
|
113
|
-
const handlers = options.endpointHandlers;
|
|
114
|
-
return {
|
|
115
|
-
getCallbacks: ()=>options.callbacks,
|
|
116
|
-
showConsentBanner: async ()=>handlers.showConsentBanner({}),
|
|
117
|
-
setConsent: async (data)=>handlers.setConsent(data),
|
|
118
|
-
verifyConsent: async (data)=>handlers.verifyConsent(data)
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
getCallbacks: ()=>options.callbacks,
|
|
123
|
-
showConsentBanner: async ()=>({
|
|
124
|
-
ok: true,
|
|
125
|
-
data: {
|
|
126
|
-
showConsentBanner: true
|
|
127
|
-
},
|
|
128
|
-
error: null,
|
|
129
|
-
response: null
|
|
130
|
-
}),
|
|
131
|
-
setConsent: async ()=>({
|
|
132
|
-
ok: true,
|
|
133
|
-
data: {
|
|
134
|
-
success: true
|
|
135
|
-
},
|
|
136
|
-
error: null,
|
|
137
|
-
response: null
|
|
138
|
-
}),
|
|
139
|
-
verifyConsent: async ()=>({
|
|
140
|
-
ok: true,
|
|
141
|
-
data: {
|
|
142
|
-
valid: true
|
|
143
|
-
},
|
|
144
|
-
error: null,
|
|
145
|
-
response: null
|
|
146
|
-
})
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
});
|
|
151
|
-
return {
|
|
152
|
-
mockFetch,
|
|
153
|
-
mockConfigureConsentManager
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
const TestConsumer = ()=>{
|
|
157
|
-
const consentManager = (0, external_index_cjs_namespaceObject.useConsentManager)();
|
|
158
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
159
|
-
"data-testid": "consumer",
|
|
160
|
-
children: consentManager.showPopup ? 'Show' : 'Hide'
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
exports.TestConsumer = __webpack_exports__.TestConsumer;
|
|
164
|
-
exports.setupMocks = __webpack_exports__.setupMocks;
|
|
165
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
166
|
-
"TestConsumer",
|
|
167
|
-
"setupMocks"
|
|
168
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
169
|
-
Object.defineProperty(exports, '__esModule', {
|
|
170
|
-
value: true
|
|
171
|
-
});
|
|
1
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,n)=>{for(var r in n)__webpack_require__.o(n,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},__webpack_require__.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{setupMocks:()=>setupMocks,TestConsumer:()=>TestConsumer});let jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_index_cjs_namespaceObject=require("../../index.cjs");function setupMocks(){let e=external_vitest_namespaceObject.vi.fn();window.fetch=e;let n=external_vitest_namespaceObject.vi.fn(),r=new Map;return(0,external_vitest_namespaceObject.beforeEach)(()=>{r.clear()}),external_vitest_namespaceObject.vi.mock("c15t",async()=>({...await external_vitest_namespaceObject.vi.importActual("c15t"),configureConsentManager:s=>{n(s);let t=s.backendURL||"";if("c15t"===s.mode)return{getCallbacks:()=>s.callbacks,showConsentBanner:async()=>(r.has(t)||(e(`${t}/show-consent-banner`,{headers:{"Content-Type":"application/json"}}),r.set(t,!0)),{ok:!0,data:{showConsentBanner:!0},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})};if("offline"===s.mode)return{getCallbacks:()=>s.callbacks,showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})};if("custom"===s.mode&&"endpointHandlers"in s){let e=s.endpointHandlers;return{getCallbacks:()=>s.callbacks,showConsentBanner:async()=>e.showConsentBanner({}),setConsent:async n=>e.setConsent(n),verifyConsent:async n=>e.verifyConsent(n)}}return{getCallbacks:()=>s.callbacks,showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})}}})),{mockFetch:e,mockConfigureConsentManager:n}}let TestConsumer=()=>{let e=(0,external_index_cjs_namespaceObject.useConsentManager)();return(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"consumer",children:e.showPopup?"Show":"Hide"})};for(var __webpack_i__ in exports.TestConsumer=__webpack_exports__.TestConsumer,exports.setupMocks=__webpack_exports__.setupMocks,__webpack_exports__)-1===["TestConsumer","setupMocks"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1,134 +1 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_vitest__ from "vitest";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__ from "../../index.js";
|
|
4
|
-
function setupMocks() {
|
|
5
|
-
const mockFetch = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.fn();
|
|
6
|
-
window.fetch = mockFetch;
|
|
7
|
-
const mockConfigureConsentManager = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.fn();
|
|
8
|
-
const fetchCallMap = new Map();
|
|
9
|
-
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.beforeEach)(()=>{
|
|
10
|
-
fetchCallMap.clear();
|
|
11
|
-
});
|
|
12
|
-
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.mock('c15t', async ()=>{
|
|
13
|
-
const originalModule = await __WEBPACK_EXTERNAL_MODULE_vitest__.vi.importActual('c15t');
|
|
14
|
-
return {
|
|
15
|
-
...originalModule,
|
|
16
|
-
configureConsentManager: (options)=>{
|
|
17
|
-
mockConfigureConsentManager(options);
|
|
18
|
-
const backendURL = options.backendURL || '';
|
|
19
|
-
if ('c15t' === options.mode) return {
|
|
20
|
-
getCallbacks: ()=>options.callbacks,
|
|
21
|
-
showConsentBanner: async ()=>{
|
|
22
|
-
if (!fetchCallMap.has(backendURL)) {
|
|
23
|
-
mockFetch(`${backendURL}/show-consent-banner`, {
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type': 'application/json'
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
fetchCallMap.set(backendURL, true);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
ok: true,
|
|
32
|
-
data: {
|
|
33
|
-
showConsentBanner: true
|
|
34
|
-
},
|
|
35
|
-
error: null,
|
|
36
|
-
response: null
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
setConsent: async ()=>({
|
|
40
|
-
ok: true,
|
|
41
|
-
data: {
|
|
42
|
-
success: true
|
|
43
|
-
},
|
|
44
|
-
error: null,
|
|
45
|
-
response: null
|
|
46
|
-
}),
|
|
47
|
-
verifyConsent: async ()=>({
|
|
48
|
-
ok: true,
|
|
49
|
-
data: {
|
|
50
|
-
valid: true
|
|
51
|
-
},
|
|
52
|
-
error: null,
|
|
53
|
-
response: null
|
|
54
|
-
})
|
|
55
|
-
};
|
|
56
|
-
if ('offline' === options.mode) return {
|
|
57
|
-
getCallbacks: ()=>options.callbacks,
|
|
58
|
-
showConsentBanner: async ()=>({
|
|
59
|
-
ok: true,
|
|
60
|
-
data: {
|
|
61
|
-
showConsentBanner: true
|
|
62
|
-
},
|
|
63
|
-
error: null,
|
|
64
|
-
response: null
|
|
65
|
-
}),
|
|
66
|
-
setConsent: async ()=>({
|
|
67
|
-
ok: true,
|
|
68
|
-
data: {
|
|
69
|
-
success: true
|
|
70
|
-
},
|
|
71
|
-
error: null,
|
|
72
|
-
response: null
|
|
73
|
-
}),
|
|
74
|
-
verifyConsent: async ()=>({
|
|
75
|
-
ok: true,
|
|
76
|
-
data: {
|
|
77
|
-
valid: true
|
|
78
|
-
},
|
|
79
|
-
error: null,
|
|
80
|
-
response: null
|
|
81
|
-
})
|
|
82
|
-
};
|
|
83
|
-
if ('custom' === options.mode && 'endpointHandlers' in options) {
|
|
84
|
-
const handlers = options.endpointHandlers;
|
|
85
|
-
return {
|
|
86
|
-
getCallbacks: ()=>options.callbacks,
|
|
87
|
-
showConsentBanner: async ()=>handlers.showConsentBanner({}),
|
|
88
|
-
setConsent: async (data)=>handlers.setConsent(data),
|
|
89
|
-
verifyConsent: async (data)=>handlers.verifyConsent(data)
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
getCallbacks: ()=>options.callbacks,
|
|
94
|
-
showConsentBanner: async ()=>({
|
|
95
|
-
ok: true,
|
|
96
|
-
data: {
|
|
97
|
-
showConsentBanner: true
|
|
98
|
-
},
|
|
99
|
-
error: null,
|
|
100
|
-
response: null
|
|
101
|
-
}),
|
|
102
|
-
setConsent: async ()=>({
|
|
103
|
-
ok: true,
|
|
104
|
-
data: {
|
|
105
|
-
success: true
|
|
106
|
-
},
|
|
107
|
-
error: null,
|
|
108
|
-
response: null
|
|
109
|
-
}),
|
|
110
|
-
verifyConsent: async ()=>({
|
|
111
|
-
ok: true,
|
|
112
|
-
data: {
|
|
113
|
-
valid: true
|
|
114
|
-
},
|
|
115
|
-
error: null,
|
|
116
|
-
response: null
|
|
117
|
-
})
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
return {
|
|
123
|
-
mockFetch,
|
|
124
|
-
mockConfigureConsentManager
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
const TestConsumer = ()=>{
|
|
128
|
-
const consentManager = (0, __WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.useConsentManager)();
|
|
129
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
130
|
-
"data-testid": "consumer",
|
|
131
|
-
children: consentManager.showPopup ? 'Show' : 'Hide'
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
export { TestConsumer, setupMocks };
|
|
1
|
+
import*as n from"react/jsx-runtime";import*as e from"vitest";import*as s from"../../index.js";function o(){let n=e.vi.fn();window.fetch=n;let s=e.vi.fn(),o=new Map;return(0,e.beforeEach)(()=>{o.clear()}),e.vi.mock("c15t",async()=>({...await e.vi.importActual("c15t"),configureConsentManager:e=>{s(e);let r=e.backendURL||"";if("c15t"===e.mode)return{getCallbacks:()=>e.callbacks,showConsentBanner:async()=>(o.has(r)||(n(`${r}/show-consent-banner`,{headers:{"Content-Type":"application/json"}}),o.set(r,!0)),{ok:!0,data:{showConsentBanner:!0},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})};if("offline"===e.mode)return{getCallbacks:()=>e.callbacks,showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})};if("custom"===e.mode&&"endpointHandlers"in e){let n=e.endpointHandlers;return{getCallbacks:()=>e.callbacks,showConsentBanner:async()=>n.showConsentBanner({}),setConsent:async e=>n.setConsent(e),verifyConsent:async e=>n.verifyConsent(e)}}return{getCallbacks:()=>e.callbacks,showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})}}})),{mockFetch:n,mockConfigureConsentManager:s}}let r=()=>{let e=(0,s.useConsentManager)();return(0,n.jsx)("div",{"data-testid":"consumer",children:e.showPopup?"Show":"Hide"})};export{r as TestConsumer,o as setupMocks};
|
|
@@ -1,163 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
var __webpack_require__ = {};
|
|
4
|
-
(()=>{
|
|
5
|
-
__webpack_require__.d = (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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.r = (exports1)=>{
|
|
17
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
-
value: 'Module'
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
-
value: true
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
var __webpack_exports__ = {};
|
|
26
|
-
__webpack_require__.r(__webpack_exports__);
|
|
27
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
-
ConsentManagerProvider: ()=>ConsentManagerProvider
|
|
29
|
-
});
|
|
30
|
-
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const external_c15t_namespaceObject = require("c15t");
|
|
32
|
-
const external_react_namespaceObject = require("react");
|
|
33
|
-
const consent_manager_context_cjs_namespaceObject = require("../context/consent-manager-context.cjs");
|
|
34
|
-
const theme_context_cjs_namespaceObject = require("../context/theme-context.cjs");
|
|
35
|
-
const use_color_scheme_cjs_namespaceObject = require("../hooks/use-color-scheme.cjs");
|
|
36
|
-
const translations_cjs_namespaceObject = require("../utils/translations.cjs");
|
|
37
|
-
function ConsentManagerProvider({ children, options }) {
|
|
38
|
-
const { mode, backendURL, callbacks, store = {}, translations: translationConfig, react = {} } = options;
|
|
39
|
-
const { initialGdprTypes, initialComplianceSettings } = store;
|
|
40
|
-
const { theme, disableAnimation = false, scrollLock = false, trapFocus = true, colorScheme = 'system', noStyle = false } = react;
|
|
41
|
-
const preparedTranslationConfig = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
42
|
-
const mergedConfig = (0, translations_cjs_namespaceObject.mergeTranslationConfigs)(external_c15t_namespaceObject.defaultTranslationConfig, translationConfig);
|
|
43
|
-
const defaultLanguage = (0, translations_cjs_namespaceObject.detectBrowserLanguage)(mergedConfig.translations, mergedConfig.defaultLanguage, mergedConfig.disableAutoLanguageSwitch);
|
|
44
|
-
return {
|
|
45
|
-
...mergedConfig,
|
|
46
|
-
defaultLanguage
|
|
47
|
-
};
|
|
48
|
-
}, [
|
|
49
|
-
translationConfig
|
|
50
|
-
]);
|
|
51
|
-
const isConsentDomain = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
52
|
-
if ('undefined' == typeof window) return false;
|
|
53
|
-
return Boolean(('c15t' === mode || 'offline' === mode) && (backendURL?.includes('c15t.dev') || window.location.hostname.includes('c15t.dev')));
|
|
54
|
-
}, [
|
|
55
|
-
mode,
|
|
56
|
-
backendURL
|
|
57
|
-
]);
|
|
58
|
-
const consentManager = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
59
|
-
if ('offline' === mode) return (0, external_c15t_namespaceObject.configureConsentManager)({
|
|
60
|
-
mode: 'offline',
|
|
61
|
-
callbacks,
|
|
62
|
-
store
|
|
63
|
-
});
|
|
64
|
-
if ('custom' === mode && 'endpointHandlers' in options) return (0, external_c15t_namespaceObject.configureConsentManager)({
|
|
65
|
-
mode: 'custom',
|
|
66
|
-
endpointHandlers: options.endpointHandlers,
|
|
67
|
-
callbacks,
|
|
68
|
-
store
|
|
69
|
-
});
|
|
70
|
-
return (0, external_c15t_namespaceObject.configureConsentManager)({
|
|
71
|
-
mode: 'c15t',
|
|
72
|
-
backendURL: backendURL || '/api/c15t',
|
|
73
|
-
callbacks,
|
|
74
|
-
store
|
|
75
|
-
});
|
|
76
|
-
}, [
|
|
77
|
-
mode,
|
|
78
|
-
backendURL,
|
|
79
|
-
callbacks,
|
|
80
|
-
store,
|
|
81
|
-
options
|
|
82
|
-
]);
|
|
83
|
-
const storeRef = (0, external_react_namespaceObject.useRef)(null);
|
|
84
|
-
const prevBackendURLRef = (0, external_react_namespaceObject.useRef)(backendURL);
|
|
85
|
-
const prevModeRef = (0, external_react_namespaceObject.useRef)(mode);
|
|
86
|
-
const consentStore = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
87
|
-
const storeWithTranslations = {
|
|
88
|
-
...store,
|
|
89
|
-
translationConfig: preparedTranslationConfig,
|
|
90
|
-
isConsentDomain
|
|
91
|
-
};
|
|
92
|
-
const shouldRecreateStore = !storeRef.current || prevBackendURLRef.current !== backendURL || prevModeRef.current !== mode;
|
|
93
|
-
prevBackendURLRef.current = backendURL;
|
|
94
|
-
prevModeRef.current = mode;
|
|
95
|
-
if (shouldRecreateStore) storeRef.current = (0, external_c15t_namespaceObject.createConsentManagerStore)(consentManager, storeWithTranslations);
|
|
96
|
-
return storeRef.current;
|
|
97
|
-
}, [
|
|
98
|
-
consentManager,
|
|
99
|
-
isConsentDomain,
|
|
100
|
-
preparedTranslationConfig,
|
|
101
|
-
store,
|
|
102
|
-
backendURL,
|
|
103
|
-
mode
|
|
104
|
-
]);
|
|
105
|
-
const [state, setState] = (0, external_react_namespaceObject.useState)(()=>{
|
|
106
|
-
if (!consentStore) return {};
|
|
107
|
-
return consentStore.getState();
|
|
108
|
-
});
|
|
109
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
110
|
-
if (!consentStore) return;
|
|
111
|
-
const { setGdprTypes, setComplianceSetting, setDetectedCountry } = consentStore.getState();
|
|
112
|
-
if (initialGdprTypes) setGdprTypes(initialGdprTypes);
|
|
113
|
-
if (initialComplianceSettings) for (const [region, settings] of Object.entries(initialComplianceSettings))setComplianceSetting(region, settings);
|
|
114
|
-
const country = document.querySelector('meta[name="user-country"]')?.getAttribute('content') || 'US';
|
|
115
|
-
setDetectedCountry(country);
|
|
116
|
-
const unsubscribe = consentStore.subscribe(setState);
|
|
117
|
-
return unsubscribe;
|
|
118
|
-
}, [
|
|
119
|
-
consentStore,
|
|
120
|
-
initialGdprTypes,
|
|
121
|
-
initialComplianceSettings
|
|
122
|
-
]);
|
|
123
|
-
const themeContextValue = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
124
|
-
theme,
|
|
125
|
-
noStyle,
|
|
126
|
-
disableAnimation,
|
|
127
|
-
scrollLock,
|
|
128
|
-
trapFocus
|
|
129
|
-
}), [
|
|
130
|
-
theme,
|
|
131
|
-
noStyle,
|
|
132
|
-
disableAnimation,
|
|
133
|
-
scrollLock,
|
|
134
|
-
trapFocus
|
|
135
|
-
]);
|
|
136
|
-
(0, use_color_scheme_cjs_namespaceObject.useColorScheme)(colorScheme);
|
|
137
|
-
const consentContextValue = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
138
|
-
if (!consentStore) throw new Error('Consent store must be initialized before creating context value');
|
|
139
|
-
return {
|
|
140
|
-
state,
|
|
141
|
-
store: consentStore,
|
|
142
|
-
manager: consentManager
|
|
143
|
-
};
|
|
144
|
-
}, [
|
|
145
|
-
state,
|
|
146
|
-
consentStore,
|
|
147
|
-
consentManager
|
|
148
|
-
]);
|
|
149
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(consent_manager_context_cjs_namespaceObject.ConsentStateContext.Provider, {
|
|
150
|
-
value: consentContextValue,
|
|
151
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(theme_context_cjs_namespaceObject.GlobalThemeContext.Provider, {
|
|
152
|
-
value: themeContextValue,
|
|
153
|
-
children: children
|
|
154
|
-
})
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
exports.ConsentManagerProvider = __webpack_exports__.ConsentManagerProvider;
|
|
158
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
159
|
-
"ConsentManagerProvider"
|
|
160
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
161
|
-
Object.defineProperty(exports, '__esModule', {
|
|
162
|
-
value: true
|
|
163
|
-
});
|
|
2
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ConsentManagerProvider:()=>ConsentManagerProvider});let jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_react_namespaceObject=require("react"),consent_manager_context_cjs_namespaceObject=require("../context/consent-manager-context.cjs"),theme_context_cjs_namespaceObject=require("../context/theme-context.cjs"),use_color_scheme_cjs_namespaceObject=require("../hooks/use-color-scheme.cjs"),translations_cjs_namespaceObject=require("../utils/translations.cjs");function ConsentManagerProvider({children:e,options:t}){let{mode:r,backendURL:n,callbacks:a,store:c={},translations:_,react:s={}}=t,{initialGdprTypes:o,initialComplianceSettings:i}=c,{theme:u,disableAnimation:l=!1,scrollLock:m=!1,trapFocus:p=!0,colorScheme:b="system",noStyle:j=!1}=s,d=(0,external_react_namespaceObject.useMemo)(()=>{let e=(0,translations_cjs_namespaceObject.mergeTranslationConfigs)(external_c15t_namespaceObject.defaultTranslationConfig,_),t=(0,translations_cjs_namespaceObject.detectBrowserLanguage)(e.translations,e.defaultLanguage,e.disableAutoLanguageSwitch);return{...e,defaultLanguage:t}},[_]),x=(0,external_react_namespaceObject.useMemo)(()=>"undefined"!=typeof window&&!!(("c15t"===r||"offline"===r)&&(n?.includes("c15t.dev")||window.location.hostname.includes("c15t.dev"))),[r,n]),f=(0,external_react_namespaceObject.useMemo)(()=>"offline"===r?(0,external_c15t_namespaceObject.configureConsentManager)({mode:"offline",callbacks:a,store:c}):"custom"===r&&"endpointHandlers"in t?(0,external_c15t_namespaceObject.configureConsentManager)({mode:"custom",endpointHandlers:t.endpointHandlers,callbacks:a,store:c}):(0,external_c15t_namespaceObject.configureConsentManager)({mode:"c15t",backendURL:n||"/api/c15t",callbacks:a,store:c}),[r,n,a,c,t]),O=(0,external_react_namespaceObject.useRef)(null),g=(0,external_react_namespaceObject.useRef)(n),w=(0,external_react_namespaceObject.useRef)(r),k=(0,external_react_namespaceObject.useMemo)(()=>{let e={...c,translationConfig:d,isConsentDomain:x},t=!O.current||g.current!==n||w.current!==r;return g.current=n,w.current=r,t&&(O.current=(0,external_c15t_namespaceObject.createConsentManagerStore)(f,e)),O.current},[f,x,d,c,n,r]),[v,M]=(0,external_react_namespaceObject.useState)(()=>k?k.getState():{});(0,external_react_namespaceObject.useEffect)(()=>{if(!k)return;let{setGdprTypes:e,setComplianceSetting:t,setDetectedCountry:r}=k.getState();if(o&&e(o),i)for(let[e,r]of Object.entries(i))t(e,r);return r(document.querySelector('meta[name="user-country"]')?.getAttribute("content")||"US"),k.subscribe(M)},[k,o,i]);let C=(0,external_react_namespaceObject.useMemo)(()=>({theme:u,noStyle:j,disableAnimation:l,scrollLock:m,trapFocus:p}),[u,j,l,m,p]);(0,use_color_scheme_cjs_namespaceObject.useColorScheme)(b);let h=(0,external_react_namespaceObject.useMemo)(()=>{if(!k)throw Error("Consent store must be initialized before creating context value");return{state:v,store:k,manager:f}},[v,k,f]);return(0,jsx_runtime_namespaceObject.jsx)(consent_manager_context_cjs_namespaceObject.ConsentStateContext.Provider,{value:h,children:(0,jsx_runtime_namespaceObject.jsx)(theme_context_cjs_namespaceObject.GlobalThemeContext.Provider,{value:C,children:e})})}for(var __webpack_i__ in exports.ConsentManagerProvider=__webpack_exports__.ConsentManagerProvider,__webpack_exports__)-1===["ConsentManagerProvider"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1,129 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import * as
|
|
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__context_theme_context_js_fbb05439__ from "../context/theme-context.js";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_use_color_scheme_js_939e374b__ from "../hooks/use-color-scheme.js";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__utils_translations_js_c2629c1f__ from "../utils/translations.js";
|
|
9
|
-
function ConsentManagerProvider({ children, options }) {
|
|
10
|
-
const { mode, backendURL, callbacks, store = {}, translations: translationConfig, react = {} } = options;
|
|
11
|
-
const { initialGdprTypes, initialComplianceSettings } = store;
|
|
12
|
-
const { theme, disableAnimation = false, scrollLock = false, trapFocus = true, colorScheme = 'system', noStyle = false } = react;
|
|
13
|
-
const preparedTranslationConfig = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
14
|
-
const mergedConfig = (0, __WEBPACK_EXTERNAL_MODULE__utils_translations_js_c2629c1f__.mergeTranslationConfigs)(__WEBPACK_EXTERNAL_MODULE_c15t__.defaultTranslationConfig, translationConfig);
|
|
15
|
-
const defaultLanguage = (0, __WEBPACK_EXTERNAL_MODULE__utils_translations_js_c2629c1f__.detectBrowserLanguage)(mergedConfig.translations, mergedConfig.defaultLanguage, mergedConfig.disableAutoLanguageSwitch);
|
|
16
|
-
return {
|
|
17
|
-
...mergedConfig,
|
|
18
|
-
defaultLanguage
|
|
19
|
-
};
|
|
20
|
-
}, [
|
|
21
|
-
translationConfig
|
|
22
|
-
]);
|
|
23
|
-
const isConsentDomain = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
24
|
-
if ('undefined' == typeof window) return false;
|
|
25
|
-
return Boolean(('c15t' === mode || 'offline' === mode) && (backendURL?.includes('c15t.dev') || window.location.hostname.includes('c15t.dev')));
|
|
26
|
-
}, [
|
|
27
|
-
mode,
|
|
28
|
-
backendURL
|
|
29
|
-
]);
|
|
30
|
-
const consentManager = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
31
|
-
if ('offline' === mode) return (0, __WEBPACK_EXTERNAL_MODULE_c15t__.configureConsentManager)({
|
|
32
|
-
mode: 'offline',
|
|
33
|
-
callbacks,
|
|
34
|
-
store
|
|
35
|
-
});
|
|
36
|
-
if ('custom' === mode && 'endpointHandlers' in options) return (0, __WEBPACK_EXTERNAL_MODULE_c15t__.configureConsentManager)({
|
|
37
|
-
mode: 'custom',
|
|
38
|
-
endpointHandlers: options.endpointHandlers,
|
|
39
|
-
callbacks,
|
|
40
|
-
store
|
|
41
|
-
});
|
|
42
|
-
return (0, __WEBPACK_EXTERNAL_MODULE_c15t__.configureConsentManager)({
|
|
43
|
-
mode: 'c15t',
|
|
44
|
-
backendURL: backendURL || '/api/c15t',
|
|
45
|
-
callbacks,
|
|
46
|
-
store
|
|
47
|
-
});
|
|
48
|
-
}, [
|
|
49
|
-
mode,
|
|
50
|
-
backendURL,
|
|
51
|
-
callbacks,
|
|
52
|
-
store,
|
|
53
|
-
options
|
|
54
|
-
]);
|
|
55
|
-
const storeRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
56
|
-
const prevBackendURLRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(backendURL);
|
|
57
|
-
const prevModeRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(mode);
|
|
58
|
-
const consentStore = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
59
|
-
const storeWithTranslations = {
|
|
60
|
-
...store,
|
|
61
|
-
translationConfig: preparedTranslationConfig,
|
|
62
|
-
isConsentDomain
|
|
63
|
-
};
|
|
64
|
-
const shouldRecreateStore = !storeRef.current || prevBackendURLRef.current !== backendURL || prevModeRef.current !== mode;
|
|
65
|
-
prevBackendURLRef.current = backendURL;
|
|
66
|
-
prevModeRef.current = mode;
|
|
67
|
-
if (shouldRecreateStore) storeRef.current = (0, __WEBPACK_EXTERNAL_MODULE_c15t__.createConsentManagerStore)(consentManager, storeWithTranslations);
|
|
68
|
-
return storeRef.current;
|
|
69
|
-
}, [
|
|
70
|
-
consentManager,
|
|
71
|
-
isConsentDomain,
|
|
72
|
-
preparedTranslationConfig,
|
|
73
|
-
store,
|
|
74
|
-
backendURL,
|
|
75
|
-
mode
|
|
76
|
-
]);
|
|
77
|
-
const [state, setState] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(()=>{
|
|
78
|
-
if (!consentStore) return {};
|
|
79
|
-
return consentStore.getState();
|
|
80
|
-
});
|
|
81
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
82
|
-
if (!consentStore) return;
|
|
83
|
-
const { setGdprTypes, setComplianceSetting, setDetectedCountry } = consentStore.getState();
|
|
84
|
-
if (initialGdprTypes) setGdprTypes(initialGdprTypes);
|
|
85
|
-
if (initialComplianceSettings) for (const [region, settings] of Object.entries(initialComplianceSettings))setComplianceSetting(region, settings);
|
|
86
|
-
const country = document.querySelector('meta[name="user-country"]')?.getAttribute('content') || 'US';
|
|
87
|
-
setDetectedCountry(country);
|
|
88
|
-
const unsubscribe = consentStore.subscribe(setState);
|
|
89
|
-
return unsubscribe;
|
|
90
|
-
}, [
|
|
91
|
-
consentStore,
|
|
92
|
-
initialGdprTypes,
|
|
93
|
-
initialComplianceSettings
|
|
94
|
-
]);
|
|
95
|
-
const themeContextValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
96
|
-
theme,
|
|
97
|
-
noStyle,
|
|
98
|
-
disableAnimation,
|
|
99
|
-
scrollLock,
|
|
100
|
-
trapFocus
|
|
101
|
-
}), [
|
|
102
|
-
theme,
|
|
103
|
-
noStyle,
|
|
104
|
-
disableAnimation,
|
|
105
|
-
scrollLock,
|
|
106
|
-
trapFocus
|
|
107
|
-
]);
|
|
108
|
-
(0, __WEBPACK_EXTERNAL_MODULE__hooks_use_color_scheme_js_939e374b__.useColorScheme)(colorScheme);
|
|
109
|
-
const consentContextValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
110
|
-
if (!consentStore) throw new Error('Consent store must be initialized before creating context value');
|
|
111
|
-
return {
|
|
112
|
-
state,
|
|
113
|
-
store: consentStore,
|
|
114
|
-
manager: consentManager
|
|
115
|
-
};
|
|
116
|
-
}, [
|
|
117
|
-
state,
|
|
118
|
-
consentStore,
|
|
119
|
-
consentManager
|
|
120
|
-
]);
|
|
121
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__context_consent_manager_context_js_ee8f06d2__.ConsentStateContext.Provider, {
|
|
122
|
-
value: consentContextValue,
|
|
123
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__context_theme_context_js_fbb05439__.GlobalThemeContext.Provider, {
|
|
124
|
-
value: themeContextValue,
|
|
125
|
-
children: children
|
|
126
|
-
})
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
export { ConsentManagerProvider };
|
|
2
|
+
import*as e from"react/jsx-runtime";import*as t from"c15t";import*as n from"react";import*as r from"../context/consent-manager-context.js";import*as o from"../context/theme-context.js";import*as s from"../hooks/use-color-scheme.js";import*as a from"../utils/translations.js";function i({children:i,options:u}){let{mode:c,backendURL:l,callbacks:m,store:f={},translations:d,react:g={}}=u,{initialGdprTypes:p,initialComplianceSettings:C}=f,{theme:x,disableAnimation:M=!1,scrollLock:h=!1,trapFocus:b=!0,colorScheme:S="system",noStyle:j=!1}=g,v=(0,n.useMemo)(()=>{let e=(0,a.mergeTranslationConfigs)(t.defaultTranslationConfig,d),n=(0,a.detectBrowserLanguage)(e.translations,e.defaultLanguage,e.disableAutoLanguageSwitch);return{...e,defaultLanguage:n}},[d]),w=(0,n.useMemo)(()=>"undefined"!=typeof window&&!!(("c15t"===c||"offline"===c)&&(l?.includes("c15t.dev")||window.location.hostname.includes("c15t.dev"))),[c,l]),y=(0,n.useMemo)(()=>"offline"===c?(0,t.configureConsentManager)({mode:"offline",callbacks:m,store:f}):"custom"===c&&"endpointHandlers"in u?(0,t.configureConsentManager)({mode:"custom",endpointHandlers:u.endpointHandlers,callbacks:m,store:f}):(0,t.configureConsentManager)({mode:"c15t",backendURL:l||"/api/c15t",callbacks:m,store:f}),[c,l,m,f,u]),L=(0,n.useRef)(null),R=(0,n.useRef)(l),H=(0,n.useRef)(c),P=(0,n.useMemo)(()=>{let e={...f,translationConfig:v,isConsentDomain:w},n=!L.current||R.current!==l||H.current!==c;return R.current=l,H.current=c,n&&(L.current=(0,t.createConsentManagerStore)(y,e)),L.current},[y,w,v,f,l,c]),[T,k]=(0,n.useState)(()=>P?P.getState():{});(0,n.useEffect)(()=>{if(!P)return;let{setGdprTypes:e,setComplianceSetting:t,setDetectedCountry:n}=P.getState();if(p&&e(p),C)for(let[e,n]of Object.entries(C))t(e,n);return n(document.querySelector('meta[name="user-country"]')?.getAttribute("content")||"US"),P.subscribe(k)},[P,p,C]);let A=(0,n.useMemo)(()=>({theme:x,noStyle:j,disableAnimation:M,scrollLock:h,trapFocus:b}),[x,j,M,h,b]);(0,s.useColorScheme)(S);let E=(0,n.useMemo)(()=>{if(!P)throw Error("Consent store must be initialized before creating context value");return{state:T,store:P,manager:y}},[T,P,y]);return(0,e.jsx)(r.ConsentStateContext.Provider,{value:E,children:(0,e.jsx)(o.GlobalThemeContext.Provider,{value:A,children:i})})}export{i as ConsentManagerProvider};
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.r = (exports1)=>{
|
|
5
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
-
value: 'Module'
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
-
value: true
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
})();
|
|
13
|
-
var __webpack_exports__ = {};
|
|
14
|
-
__webpack_require__.r(__webpack_exports__);
|
|
15
|
-
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
16
|
-
Object.defineProperty(exports, '__esModule', {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
1
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};for(var __webpack_i__ in __webpack_require__.r(__webpack_exports__),__webpack_exports__)exports[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|