@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,199 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_vitest__ from "vitest";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__ from "../../index.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
|
|
5
|
+
const ALL_COMPONENTS = [
|
|
6
|
+
{
|
|
7
|
+
testId: 'cookie-banner-root',
|
|
8
|
+
themeKey: 'cookie-banner.root',
|
|
9
|
+
styles: 'custom-root'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
testId: 'cookie-banner-card',
|
|
13
|
+
themeKey: 'cookie-banner.card',
|
|
14
|
+
styles: 'custom-card'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
testId: 'cookie-banner-header',
|
|
18
|
+
themeKey: 'cookie-banner.header.root',
|
|
19
|
+
styles: 'custom-header'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
testId: 'cookie-banner-title',
|
|
23
|
+
themeKey: 'cookie-banner.header.title',
|
|
24
|
+
styles: 'custom-title'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
testId: "cookie-banner-description",
|
|
28
|
+
themeKey: "cookie-banner.header.description",
|
|
29
|
+
styles: "custom-description"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
testId: 'cookie-banner-footer',
|
|
33
|
+
themeKey: 'cookie-banner.footer',
|
|
34
|
+
styles: 'custom-footer'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
testId: 'cookie-banner-footer-sub-group',
|
|
38
|
+
themeKey: 'cookie-banner.footer.sub-group',
|
|
39
|
+
styles: 'custom-footer-sub-group'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
testId: 'cookie-banner-overlay',
|
|
43
|
+
themeKey: 'cookie-banner.overlay',
|
|
44
|
+
styles: 'custom-overlay'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
testId: 'cookie-banner-reject-button',
|
|
48
|
+
themeKey: 'cookie-banner.footer.reject-button',
|
|
49
|
+
styles: 'custom-reject-button'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
testId: 'cookie-banner-customize-button',
|
|
53
|
+
themeKey: 'cookie-banner.footer.customize-button',
|
|
54
|
+
styles: 'custom-customize-button'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
testId: 'cookie-banner-accept-button',
|
|
58
|
+
themeKey: 'cookie-banner.footer.accept-button',
|
|
59
|
+
styles: 'custom-accept-button'
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('Theme prop applies string classnames to all components', async ()=>{
|
|
63
|
+
const test = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.CookieBanner, {
|
|
64
|
+
theme: ALL_COMPONENTS.reduce((acc, { themeKey, styles })=>{
|
|
65
|
+
acc[themeKey] = styles;
|
|
66
|
+
return acc;
|
|
67
|
+
}, {})
|
|
68
|
+
});
|
|
69
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__["default"])({
|
|
70
|
+
component: test,
|
|
71
|
+
testCases: ALL_COMPONENTS.map(({ testId, styles })=>({
|
|
72
|
+
testId,
|
|
73
|
+
styles
|
|
74
|
+
}))
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('Theme prop supports object format with className and style for all components', async ()=>{
|
|
78
|
+
const style = {
|
|
79
|
+
backgroundColor: '#ffffff',
|
|
80
|
+
padding: '20px',
|
|
81
|
+
border: '1px solid #000000'
|
|
82
|
+
};
|
|
83
|
+
const testCases = ALL_COMPONENTS.map(({ testId, themeKey, styles })=>({
|
|
84
|
+
testId,
|
|
85
|
+
themeKey,
|
|
86
|
+
className: styles,
|
|
87
|
+
style
|
|
88
|
+
}));
|
|
89
|
+
const test = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.CookieBanner, {
|
|
90
|
+
theme: testCases.reduce((acc, { themeKey, className, style })=>{
|
|
91
|
+
acc[themeKey] = {
|
|
92
|
+
className,
|
|
93
|
+
style
|
|
94
|
+
};
|
|
95
|
+
return acc;
|
|
96
|
+
}, {})
|
|
97
|
+
});
|
|
98
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__["default"])({
|
|
99
|
+
component: test,
|
|
100
|
+
testCases: testCases.map(({ testId, className, style })=>({
|
|
101
|
+
testId,
|
|
102
|
+
styles: {
|
|
103
|
+
className,
|
|
104
|
+
style
|
|
105
|
+
}
|
|
106
|
+
}))
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('No style prop removes default styles but keeps custom classNames', async ()=>{
|
|
110
|
+
const test = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.CookieBanner, {
|
|
111
|
+
noStyle: true,
|
|
112
|
+
theme: ALL_COMPONENTS.reduce((acc, { themeKey, styles })=>{
|
|
113
|
+
acc[themeKey] = styles;
|
|
114
|
+
return acc;
|
|
115
|
+
}, {})
|
|
116
|
+
});
|
|
117
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__["default"])({
|
|
118
|
+
component: test,
|
|
119
|
+
testCases: ALL_COMPONENTS.map(({ testId, styles })=>({
|
|
120
|
+
testId,
|
|
121
|
+
styles
|
|
122
|
+
})),
|
|
123
|
+
noStyle: true
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('Theme prop handles mixed format (string and object) correctly', async ()=>{
|
|
127
|
+
const mixedTheme = {
|
|
128
|
+
'cookie-banner.root': {
|
|
129
|
+
className: 'custom-root',
|
|
130
|
+
style: {
|
|
131
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
132
|
+
padding: '16px'
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
'cookie-banner.header.title': 'custom-title'
|
|
136
|
+
};
|
|
137
|
+
const test = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.CookieBanner, {
|
|
138
|
+
theme: mixedTheme
|
|
139
|
+
});
|
|
140
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__["default"])({
|
|
141
|
+
component: test,
|
|
142
|
+
testCases: [
|
|
143
|
+
{
|
|
144
|
+
testId: 'cookie-banner-root',
|
|
145
|
+
styles: {
|
|
146
|
+
className: 'custom-root',
|
|
147
|
+
style: {
|
|
148
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
149
|
+
padding: '16px'
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
testId: 'cookie-banner-title',
|
|
155
|
+
styles: 'custom-title'
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('Theme prop handles edge cases gracefully', async ()=>{
|
|
161
|
+
const edgeCaseTheme = {
|
|
162
|
+
'cookie-banner.root': '',
|
|
163
|
+
'cookie-banner.title': '',
|
|
164
|
+
"cookie-banner.description": '',
|
|
165
|
+
'cookie-banner.footer': {
|
|
166
|
+
className: '',
|
|
167
|
+
style: {
|
|
168
|
+
margin: '0',
|
|
169
|
+
padding: '0'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const test = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.CookieBanner, {
|
|
174
|
+
theme: edgeCaseTheme
|
|
175
|
+
});
|
|
176
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__["default"])({
|
|
177
|
+
component: test,
|
|
178
|
+
testCases: [
|
|
179
|
+
{
|
|
180
|
+
testId: 'cookie-banner-root',
|
|
181
|
+
styles: ''
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
testId: 'cookie-banner-title',
|
|
185
|
+
styles: ''
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
testId: 'cookie-banner-footer',
|
|
189
|
+
styles: {
|
|
190
|
+
className: '',
|
|
191
|
+
style: {
|
|
192
|
+
margin: '0',
|
|
193
|
+
padding: '0'
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
default: ()=>utils_rslib_entry_
|
|
30
|
+
});
|
|
31
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
|
+
const external_vitest_namespaceObject = require("vitest");
|
|
33
|
+
const external_vitest_browser_react_namespaceObject = require("vitest-browser-react");
|
|
34
|
+
const external_index_cjs_namespaceObject = require("../../index.cjs");
|
|
35
|
+
async function testComponentStyles({ component, testCases, noStyle = false }) {
|
|
36
|
+
const { getByTestId } = (0, external_vitest_browser_react_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider, {
|
|
37
|
+
children: component
|
|
38
|
+
}));
|
|
39
|
+
for (const { testId, styles } of testCases){
|
|
40
|
+
const element = getByTestId(testId);
|
|
41
|
+
if ('string' == typeof styles || styles?.className) {
|
|
42
|
+
const classNames = 'string' == typeof styles ? styles : styles?.className;
|
|
43
|
+
if (classNames) await external_vitest_namespaceObject.expect.element(element).toHaveClass(classNames, {
|
|
44
|
+
exact: noStyle
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if ('object' == typeof styles && styles?.style) {
|
|
48
|
+
const styleEntries = Object.entries(styles.style).map(([key, value])=>{
|
|
49
|
+
const cssKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
50
|
+
return [
|
|
51
|
+
cssKey,
|
|
52
|
+
value
|
|
53
|
+
];
|
|
54
|
+
});
|
|
55
|
+
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
56
|
+
for (const [property, value] of styleEntries)await external_vitest_namespaceObject.expect.element(element).toHaveStyle({
|
|
57
|
+
[property]: value
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const utils_rslib_entry_ = testComponentStyles;
|
|
63
|
+
var __webpack_export_target__ = exports;
|
|
64
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
65
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
66
|
+
value: true
|
|
67
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ThemeValue } from '../../theme/types/style-types';
|
|
3
|
+
interface ComponentStyles {
|
|
4
|
+
component: ReactNode;
|
|
5
|
+
testCases: {
|
|
6
|
+
testId: string;
|
|
7
|
+
styles: string | ThemeValue;
|
|
8
|
+
}[];
|
|
9
|
+
noStyle?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function testComponentStyles({ component, testCases, noStyle, }: ComponentStyles): Promise<void>;
|
|
12
|
+
export default testComponentStyles;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cookie-banner/__tests__/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,UAAU,eAAe;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;KAC5B,EAAE,CAAC;IACJ,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,iBAAe,mBAAmB,CAAC,EAClC,SAAS,EACT,SAAS,EACT,OAAe,GACf,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCjC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_vitest__ from "vitest";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_vitest_browser_react_6a851916__ from "vitest-browser-react";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__ from "../../index.js";
|
|
5
|
+
async function testComponentStyles({ component, testCases, noStyle = false }) {
|
|
6
|
+
const { getByTestId } = (0, __WEBPACK_EXTERNAL_MODULE_vitest_browser_react_6a851916__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_js_cbfda0f6__.ConsentManagerProvider, {
|
|
7
|
+
children: component
|
|
8
|
+
}));
|
|
9
|
+
for (const { testId, styles } of testCases){
|
|
10
|
+
const element = getByTestId(testId);
|
|
11
|
+
if ('string' == typeof styles || styles?.className) {
|
|
12
|
+
const classNames = 'string' == typeof styles ? styles : styles?.className;
|
|
13
|
+
if (classNames) await __WEBPACK_EXTERNAL_MODULE_vitest__.expect.element(element).toHaveClass(classNames, {
|
|
14
|
+
exact: noStyle
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if ('object' == typeof styles && styles?.style) {
|
|
18
|
+
const styleEntries = Object.entries(styles.style).map(([key, value])=>{
|
|
19
|
+
const cssKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
20
|
+
return [
|
|
21
|
+
cssKey,
|
|
22
|
+
value
|
|
23
|
+
];
|
|
24
|
+
});
|
|
25
|
+
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
26
|
+
for (const [property, value] of styleEntries)await __WEBPACK_EXTERNAL_MODULE_vitest__.expect.element(element).toHaveStyle({
|
|
27
|
+
[property]: value
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const utils_rslib_entry_ = testComponentStyles;
|
|
33
|
+
export { utils_rslib_entry_ as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
CookieBannerOverlay: ()=>CookieBannerOverlay,
|
|
30
|
+
Overlay: ()=>Overlay
|
|
31
|
+
});
|
|
32
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
|
+
const react_namespaceObject = require("motion/react");
|
|
34
|
+
const external_react_namespaceObject = require("react");
|
|
35
|
+
const index_cjs_namespaceObject = require("../../common/index.cjs");
|
|
36
|
+
const external_theme_index_cjs_namespaceObject = require("../../theme/index.cjs");
|
|
37
|
+
const CookieBannerOverlay = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(({ className, style, noStyle, asChild, ...props }, ref)=>{
|
|
38
|
+
const { showPopup } = (0, index_cjs_namespaceObject.useConsentManager)();
|
|
39
|
+
const { disableAnimation, noStyle: contextNoStyle } = (0, external_theme_index_cjs_namespaceObject.useThemeContext)();
|
|
40
|
+
const theme = (0, external_theme_index_cjs_namespaceObject.useStyles)('cookie-banner.overlay', {
|
|
41
|
+
baseClassName: !(contextNoStyle || noStyle) && 'c15t-cookie-banner-overlay',
|
|
42
|
+
noStyle
|
|
43
|
+
});
|
|
44
|
+
return showPopup ? disableAnimation ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
45
|
+
ref: ref,
|
|
46
|
+
...props,
|
|
47
|
+
...theme,
|
|
48
|
+
"data-testid": "cookie-banner-overlay"
|
|
49
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.AnimatePresence, {
|
|
50
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.div, {
|
|
51
|
+
ref: ref,
|
|
52
|
+
...theme,
|
|
53
|
+
initial: {
|
|
54
|
+
opacity: 0
|
|
55
|
+
},
|
|
56
|
+
animate: {
|
|
57
|
+
opacity: 1
|
|
58
|
+
},
|
|
59
|
+
exit: {
|
|
60
|
+
opacity: 0
|
|
61
|
+
},
|
|
62
|
+
"data-testid": "cookie-banner-overlay"
|
|
63
|
+
})
|
|
64
|
+
}) : null;
|
|
65
|
+
});
|
|
66
|
+
const Overlay = CookieBannerOverlay;
|
|
67
|
+
var __webpack_export_target__ = exports;
|
|
68
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
69
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
70
|
+
value: true
|
|
71
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Provides the overlay backdrop component for the CookieBanner.
|
|
4
|
+
*/
|
|
5
|
+
import { type HTMLAttributes } from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Props for the Overlay component.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The overlay provides a semi-transparent backdrop behind the cookie banner content.
|
|
11
|
+
* It can be styled using the CookieBanner theme system or through direct style props.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
interface OverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
/**
|
|
17
|
+
* @remarks
|
|
18
|
+
* When true, the component will not apply any styles.
|
|
19
|
+
*/
|
|
20
|
+
noStyle?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @remarks
|
|
23
|
+
* When true, the component will render its children directly without wrapping them in a DOM element.
|
|
24
|
+
* This enables better composition with other components.
|
|
25
|
+
*/
|
|
26
|
+
asChild?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Overlay component that provides a backdrop for the CookieBanner content.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* This component handles:
|
|
33
|
+
* - Rendering a semi-transparent backdrop
|
|
34
|
+
* - Fade in/out animations (when animations are enabled)
|
|
35
|
+
* - Proper z-indexing for modal behavior
|
|
36
|
+
* - Theme-based styling
|
|
37
|
+
*
|
|
38
|
+
* The overlay visibility is controlled by the `showPopup` state from CookieBanner context,
|
|
39
|
+
* and its animation behavior is controlled by the `disableAnimation` flag.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
declare const CookieBannerOverlay: import("react").ForwardRefExoticComponent<OverlayProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
44
|
+
declare const Overlay: import("react").ForwardRefExoticComponent<OverlayProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
|
+
export { Overlay, CookieBannerOverlay };
|
|
46
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/cookie-banner/atoms/overlay.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,OAAO,CAAC;AAKxD;;;;;;;;GAQG;AACH,UAAU,YAAa,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC5D;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,mBAAmB,yGAgCxB,CAAC;AAEF,QAAA,MAAM,OAAO,yGAAsB,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_motion_react_9decfa63__ from "motion/react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__common_index_js_93bccd67__ from "../../common/index.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__theme_index_js_1910c06e__ from "../../theme/index.js";
|
|
6
|
+
const CookieBannerOverlay = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(({ className, style, noStyle, asChild, ...props }, ref)=>{
|
|
7
|
+
const { showPopup } = (0, __WEBPACK_EXTERNAL_MODULE__common_index_js_93bccd67__.useConsentManager)();
|
|
8
|
+
const { disableAnimation, noStyle: contextNoStyle } = (0, __WEBPACK_EXTERNAL_MODULE__theme_index_js_1910c06e__.useThemeContext)();
|
|
9
|
+
const theme = (0, __WEBPACK_EXTERNAL_MODULE__theme_index_js_1910c06e__.useStyles)('cookie-banner.overlay', {
|
|
10
|
+
baseClassName: !(contextNoStyle || noStyle) && 'c15t-cookie-banner-overlay',
|
|
11
|
+
noStyle
|
|
12
|
+
});
|
|
13
|
+
return showPopup ? disableAnimation ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
14
|
+
ref: ref,
|
|
15
|
+
...props,
|
|
16
|
+
...theme,
|
|
17
|
+
"data-testid": "cookie-banner-overlay"
|
|
18
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_motion_react_9decfa63__.AnimatePresence, {
|
|
19
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_motion_react_9decfa63__.motion.div, {
|
|
20
|
+
ref: ref,
|
|
21
|
+
...theme,
|
|
22
|
+
initial: {
|
|
23
|
+
opacity: 0
|
|
24
|
+
},
|
|
25
|
+
animate: {
|
|
26
|
+
opacity: 1
|
|
27
|
+
},
|
|
28
|
+
exit: {
|
|
29
|
+
opacity: 0
|
|
30
|
+
},
|
|
31
|
+
"data-testid": "cookie-banner-overlay"
|
|
32
|
+
})
|
|
33
|
+
}) : null;
|
|
34
|
+
});
|
|
35
|
+
const Overlay = CookieBannerOverlay;
|
|
36
|
+
export { CookieBannerOverlay, Overlay };
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
Root: ()=>Root,
|
|
31
|
+
CookieBannerRoot: ()=>CookieBannerRoot
|
|
32
|
+
});
|
|
33
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
34
|
+
const react_namespaceObject = require("motion/react");
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const external_react_dom_namespaceObject = require("react-dom");
|
|
37
|
+
const index_cjs_namespaceObject = require("../../theme/index.cjs");
|
|
38
|
+
const external_overlay_cjs_namespaceObject = require("./overlay.cjs");
|
|
39
|
+
const external_common_index_cjs_namespaceObject = require("../../common/index.cjs");
|
|
40
|
+
const theme_cjs_namespaceObject = require("../../common/utils/theme.cjs");
|
|
41
|
+
const CookieBannerRoot = ({ children, className, noStyle, disableAnimation, theme, ...props })=>{
|
|
42
|
+
const consentManager = (0, external_common_index_cjs_namespaceObject.useConsentManager)();
|
|
43
|
+
const contextValue = {
|
|
44
|
+
disableAnimation,
|
|
45
|
+
noStyle,
|
|
46
|
+
theme
|
|
47
|
+
};
|
|
48
|
+
const mergedContextValue = (0, theme_cjs_namespaceObject.createThemeContextValue)(consentManager, contextValue);
|
|
49
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ThemeContext.Provider, {
|
|
50
|
+
value: mergedContextValue,
|
|
51
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CookieBannerRootChildren, {
|
|
52
|
+
disableAnimation: disableAnimation,
|
|
53
|
+
className: className,
|
|
54
|
+
...props,
|
|
55
|
+
children: children
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const CookieBannerRootChildren = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(({ asChild, children, className, style, className: forwardedClassName, disableAnimation, ...props }, ref)=>{
|
|
60
|
+
const { showPopup } = (0, external_common_index_cjs_namespaceObject.useConsentManager)();
|
|
61
|
+
const contentStyle = (0, index_cjs_namespaceObject.useStyles)('cookie-banner.root', {
|
|
62
|
+
baseClassName: [
|
|
63
|
+
'c15t-cookie-banner c15t-cookie-banner-root c15t-cookie-banner-root-bottom-left'
|
|
64
|
+
],
|
|
65
|
+
style,
|
|
66
|
+
className: className || forwardedClassName
|
|
67
|
+
});
|
|
68
|
+
const [isMounted, setIsMounted] = (0, external_react_namespaceObject.useState)(false);
|
|
69
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
70
|
+
setIsMounted(true);
|
|
71
|
+
}, []);
|
|
72
|
+
if (!isMounted) return null;
|
|
73
|
+
return showPopup ? /*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_overlay_cjs_namespaceObject.Overlay, {}),
|
|
76
|
+
disableAnimation ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
77
|
+
ref: ref,
|
|
78
|
+
...props,
|
|
79
|
+
...contentStyle,
|
|
80
|
+
"data-testid": "cookie-banner-root",
|
|
81
|
+
children: children
|
|
82
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.AnimatePresence, {
|
|
83
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.div, {
|
|
84
|
+
ref: ref,
|
|
85
|
+
initial: {
|
|
86
|
+
opacity: 0,
|
|
87
|
+
y: 50
|
|
88
|
+
},
|
|
89
|
+
animate: {
|
|
90
|
+
opacity: 1,
|
|
91
|
+
y: 0
|
|
92
|
+
},
|
|
93
|
+
exit: {
|
|
94
|
+
opacity: 0,
|
|
95
|
+
y: 50
|
|
96
|
+
},
|
|
97
|
+
transition: {
|
|
98
|
+
type: 'spring',
|
|
99
|
+
stiffness: 300,
|
|
100
|
+
damping: 30
|
|
101
|
+
},
|
|
102
|
+
...contentStyle,
|
|
103
|
+
"data-testid": "cookie-banner-root",
|
|
104
|
+
children: children
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}), document.body) : null;
|
|
109
|
+
});
|
|
110
|
+
CookieBannerRootChildren.displayName = 'CookieBannerRootChildren';
|
|
111
|
+
const Root = CookieBannerRoot;
|
|
112
|
+
var __webpack_export_target__ = exports;
|
|
113
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
114
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
115
|
+
value: true
|
|
116
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type FC, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import type { CookieBannerTheme } from '../theme';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the root component of the CookieBanner.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The root component serves as the top-level container and context provider
|
|
8
|
+
* for the cookie banner. It manages the consent state and styling configuration
|
|
9
|
+
* for all child components.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
interface CookieBannerRootProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
/**
|
|
15
|
+
* @remarks
|
|
16
|
+
* React elements to be rendered within the cookie banner.
|
|
17
|
+
* Typically includes Content, Title, Description, and Actions components.
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* @remarks
|
|
22
|
+
* When true, removes all default styling from the banner and its children.
|
|
23
|
+
* Useful when implementing completely custom styles.
|
|
24
|
+
*/
|
|
25
|
+
noStyle?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @remarks
|
|
28
|
+
* Custom styles to be applied to the banner and its child components.
|
|
29
|
+
* These styles are made available through the CookieBanner context.
|
|
30
|
+
*/
|
|
31
|
+
theme?: Partial<CookieBannerTheme>;
|
|
32
|
+
/**
|
|
33
|
+
* @remarks
|
|
34
|
+
* When true, disables the entrance/exit animations.
|
|
35
|
+
* Useful for environments where animations are not desired.
|
|
36
|
+
*/
|
|
37
|
+
disableAnimation?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Root component of the CookieBanner that provides context and styling.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* This component:
|
|
44
|
+
* - Provides the CookieBanner context to all child components
|
|
45
|
+
* - Manages consent state through the consent manager
|
|
46
|
+
* - Handles style distribution to child components
|
|
47
|
+
* - Serves as the main container for the banner
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* Basic usage:
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <CookieBanner.Root>
|
|
53
|
+
* <CookieBanner.Content>
|
|
54
|
+
* {Banner content}
|
|
55
|
+
* </CookieBanner.Content>
|
|
56
|
+
* </CookieBanner.Root>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* With custom styling:
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <CookieBanner.Root
|
|
63
|
+
* styles={{
|
|
64
|
+
* root: "fixed bottom-0 w-full bg-white ",
|
|
65
|
+
* content: "max-w-4xl mx-auto p-4",
|
|
66
|
+
* title: "text-xl font-bold",
|
|
67
|
+
* description: "mt-2 text-gray-600"
|
|
68
|
+
* }}
|
|
69
|
+
* >
|
|
70
|
+
* { Banner content}
|
|
71
|
+
* </CookieBanner.Root>
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
declare const CookieBannerRoot: FC<CookieBannerRootProps>;
|
|
77
|
+
declare const Root: FC<CookieBannerRootProps>;
|
|
78
|
+
export { Root, CookieBannerRoot };
|
|
79
|
+
//# sourceMappingURL=root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/cookie-banner/atoms/root.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEN,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,SAAS,EAId,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;;;GASG;AACH,UAAU,qBAAsB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEnC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,QAAA,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAqC/C,CAAC;AA8JF,QAAA,MAAM,IAAI,2BAAmB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC"}
|