@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.
Files changed (230) hide show
  1. package/LICENSE.md +595 -0
  2. package/README.md +55 -0
  3. package/dist/common/components/consent-manager-provider.cjs +93 -0
  4. package/dist/common/components/consent-manager-provider.d.ts +16 -0
  5. package/dist/common/components/consent-manager-provider.d.ts.map +1 -0
  6. package/dist/common/components/consent-manager-provider.js +59 -0
  7. package/dist/common/context/consent-manager-context.cjs +38 -0
  8. package/dist/common/context/consent-manager-context.d.ts +13 -0
  9. package/dist/common/context/consent-manager-context.d.ts.map +1 -0
  10. package/dist/common/context/consent-manager-context.js +4 -0
  11. package/dist/common/hooks/use-consent-manager.cjs +45 -0
  12. package/dist/common/hooks/use-consent-manager.d.ts +20 -0
  13. package/dist/common/hooks/use-consent-manager.d.ts.map +1 -0
  14. package/dist/common/hooks/use-consent-manager.js +11 -0
  15. package/dist/common/index.cjs +42 -0
  16. package/dist/common/index.d.ts +7 -0
  17. package/dist/common/index.d.ts.map +1 -0
  18. package/dist/common/index.js +9 -0
  19. package/dist/common/store/use-consent-manager.cjs +47 -0
  20. package/dist/common/store/use-consent-manager.d.ts +136 -0
  21. package/dist/common/store/use-consent-manager.d.ts.map +1 -0
  22. package/dist/common/store/use-consent-manager.js +13 -0
  23. package/dist/common/store/use-translations.cjs +58 -0
  24. package/dist/common/store/use-translations.d.ts +29 -0
  25. package/dist/common/store/use-translations.d.ts.map +1 -0
  26. package/dist/common/store/use-translations.js +24 -0
  27. package/dist/common/types/consent-manager.cjs +19 -0
  28. package/dist/common/types/consent-manager.d.ts +82 -0
  29. package/dist/common/types/consent-manager.d.ts.map +1 -0
  30. package/dist/common/types/consent-manager.js +0 -0
  31. package/dist/common/utils/theme.cjs +47 -0
  32. package/dist/common/utils/theme.d.ts +8 -0
  33. package/dist/common/utils/theme.d.ts.map +1 -0
  34. package/dist/common/utils/theme.js +13 -0
  35. package/dist/common/utils/translations.cjs +86 -0
  36. package/dist/common/utils/translations.d.ts +14 -0
  37. package/dist/common/utils/translations.d.ts.map +1 -0
  38. package/dist/common/utils/translations.js +50 -0
  39. package/dist/consent-manager-dialog/__tests__/styles.spec.cjs +218 -0
  40. package/dist/consent-manager-dialog/__tests__/styles.spec.d.ts +2 -0
  41. package/dist/consent-manager-dialog/__tests__/styles.spec.d.ts.map +1 -0
  42. package/dist/consent-manager-dialog/__tests__/styles.spec.js +183 -0
  43. package/dist/consent-manager-dialog/__tests__/utils.cjs +68 -0
  44. package/dist/consent-manager-dialog/__tests__/utils.d.ts +13 -0
  45. package/dist/consent-manager-dialog/__tests__/utils.d.ts.map +1 -0
  46. package/dist/consent-manager-dialog/__tests__/utils.js +34 -0
  47. package/dist/consent-manager-dialog/atoms/dialog-card.cjs +139 -0
  48. package/dist/consent-manager-dialog/atoms/dialog-card.d.ts +90 -0
  49. package/dist/consent-manager-dialog/atoms/dialog-card.d.ts.map +1 -0
  50. package/dist/consent-manager-dialog/atoms/dialog-card.js +94 -0
  51. package/dist/consent-manager-dialog/atoms/overlay.cjs +67 -0
  52. package/dist/consent-manager-dialog/atoms/overlay.d.ts +71 -0
  53. package/dist/consent-manager-dialog/atoms/overlay.d.ts.map +1 -0
  54. package/dist/consent-manager-dialog/atoms/overlay.js +32 -0
  55. package/dist/consent-manager-dialog/consent-manager-dialog.cjs +129 -0
  56. package/dist/consent-manager-dialog/consent-manager-dialog.css +75 -0
  57. package/dist/consent-manager-dialog/consent-manager-dialog.d.ts +44 -0
  58. package/dist/consent-manager-dialog/consent-manager-dialog.d.ts.map +1 -0
  59. package/dist/consent-manager-dialog/consent-manager-dialog.js +95 -0
  60. package/dist/consent-manager-dialog/index.cjs +51 -0
  61. package/dist/consent-manager-dialog/index.d.ts +4 -0
  62. package/dist/consent-manager-dialog/index.d.ts.map +1 -0
  63. package/dist/consent-manager-dialog/index.js +18 -0
  64. package/dist/consent-manager-dialog/theme.cjs +19 -0
  65. package/dist/consent-manager-dialog/theme.d.ts +19 -0
  66. package/dist/consent-manager-dialog/theme.d.ts.map +1 -0
  67. package/dist/consent-manager-dialog/theme.js +0 -0
  68. package/dist/consent-manager-widget/__tests__/styles.spec.cjs +228 -0
  69. package/dist/consent-manager-widget/__tests__/styles.spec.d.ts +2 -0
  70. package/dist/consent-manager-widget/__tests__/styles.spec.d.ts.map +1 -0
  71. package/dist/consent-manager-widget/__tests__/styles.spec.js +193 -0
  72. package/dist/consent-manager-widget/__tests__/utils.cjs +68 -0
  73. package/dist/consent-manager-widget/__tests__/utils.d.ts +13 -0
  74. package/dist/consent-manager-widget/__tests__/utils.d.ts.map +1 -0
  75. package/dist/consent-manager-widget/__tests__/utils.js +34 -0
  76. package/dist/consent-manager-widget/atoms/accordion.cjs +147 -0
  77. package/dist/consent-manager-widget/atoms/accordion.d.ts +57 -0
  78. package/dist/consent-manager-widget/atoms/accordion.d.ts.map +1 -0
  79. package/dist/consent-manager-widget/atoms/accordion.js +98 -0
  80. package/dist/consent-manager-widget/atoms/button.cjs +77 -0
  81. package/dist/consent-manager-widget/atoms/button.d.ts +17 -0
  82. package/dist/consent-manager-widget/atoms/button.d.ts.map +1 -0
  83. package/dist/consent-manager-widget/atoms/button.js +38 -0
  84. package/dist/consent-manager-widget/atoms/footer.cjs +70 -0
  85. package/dist/consent-manager-widget/atoms/footer.d.ts +22 -0
  86. package/dist/consent-manager-widget/atoms/footer.d.ts.map +1 -0
  87. package/dist/consent-manager-widget/atoms/footer.js +34 -0
  88. package/dist/consent-manager-widget/atoms/logo.cjs +101 -0
  89. package/dist/consent-manager-widget/atoms/logo.d.ts +8 -0
  90. package/dist/consent-manager-widget/atoms/logo.d.ts.map +1 -0
  91. package/dist/consent-manager-widget/atoms/logo.js +67 -0
  92. package/dist/consent-manager-widget/atoms/root.cjs +64 -0
  93. package/dist/consent-manager-widget/atoms/root.d.ts +82 -0
  94. package/dist/consent-manager-widget/atoms/root.d.ts.map +1 -0
  95. package/dist/consent-manager-widget/atoms/root.js +29 -0
  96. package/dist/consent-manager-widget/consent-manager-widget.cjs +98 -0
  97. package/dist/consent-manager-widget/consent-manager-widget.css +79 -0
  98. package/dist/consent-manager-widget/consent-manager-widget.d.ts +51 -0
  99. package/dist/consent-manager-widget/consent-manager-widget.d.ts.map +1 -0
  100. package/dist/consent-manager-widget/consent-manager-widget.js +64 -0
  101. package/dist/consent-manager-widget/index.cjs +62 -0
  102. package/dist/consent-manager-widget/index.d.ts +10 -0
  103. package/dist/consent-manager-widget/index.d.ts.map +1 -0
  104. package/dist/consent-manager-widget/index.js +29 -0
  105. package/dist/consent-manager-widget/theme.cjs +19 -0
  106. package/dist/consent-manager-widget/theme.d.ts +48 -0
  107. package/dist/consent-manager-widget/theme.d.ts.map +1 -0
  108. package/dist/consent-manager-widget/theme.js +0 -0
  109. package/dist/consent-manager-widget/types.cjs +19 -0
  110. package/dist/consent-manager-widget/types.d.ts +18 -0
  111. package/dist/consent-manager-widget/types.d.ts.map +1 -0
  112. package/dist/consent-manager-widget/types.js +0 -0
  113. package/dist/cookie-banner/__tests__/styles.spec.cjs +234 -0
  114. package/dist/cookie-banner/__tests__/styles.spec.d.ts +2 -0
  115. package/dist/cookie-banner/__tests__/styles.spec.d.ts.map +1 -0
  116. package/dist/cookie-banner/__tests__/styles.spec.js +199 -0
  117. package/dist/cookie-banner/__tests__/utils.cjs +67 -0
  118. package/dist/cookie-banner/__tests__/utils.d.ts +13 -0
  119. package/dist/cookie-banner/__tests__/utils.d.ts.map +1 -0
  120. package/dist/cookie-banner/__tests__/utils.js +33 -0
  121. package/dist/cookie-banner/atoms/overlay.cjs +71 -0
  122. package/dist/cookie-banner/atoms/overlay.d.ts +46 -0
  123. package/dist/cookie-banner/atoms/overlay.d.ts.map +1 -0
  124. package/dist/cookie-banner/atoms/overlay.js +36 -0
  125. package/dist/cookie-banner/atoms/root.cjs +116 -0
  126. package/dist/cookie-banner/atoms/root.d.ts +79 -0
  127. package/dist/cookie-banner/atoms/root.d.ts.map +1 -0
  128. package/dist/cookie-banner/atoms/root.js +81 -0
  129. package/dist/cookie-banner/components.cjs +160 -0
  130. package/dist/cookie-banner/components.d.ts +136 -0
  131. package/dist/cookie-banner/components.d.ts.map +1 -0
  132. package/dist/cookie-banner/components.js +109 -0
  133. package/dist/cookie-banner/cookie-banner.cjs +99 -0
  134. package/dist/cookie-banner/cookie-banner.css +226 -0
  135. package/dist/cookie-banner/cookie-banner.d.ts +134 -0
  136. package/dist/cookie-banner/cookie-banner.d.ts.map +1 -0
  137. package/dist/cookie-banner/cookie-banner.js +65 -0
  138. package/dist/cookie-banner/error-boundary.cjs +68 -0
  139. package/dist/cookie-banner/error-boundary.d.ts +56 -0
  140. package/dist/cookie-banner/error-boundary.d.ts.map +1 -0
  141. package/dist/cookie-banner/error-boundary.js +34 -0
  142. package/dist/cookie-banner/index.cjs +59 -0
  143. package/dist/cookie-banner/index.d.ts +52 -0
  144. package/dist/cookie-banner/index.d.ts.map +1 -0
  145. package/dist/cookie-banner/index.js +26 -0
  146. package/dist/cookie-banner/theme.cjs +19 -0
  147. package/dist/cookie-banner/theme.d.ts +30 -0
  148. package/dist/cookie-banner/theme.d.ts.map +1 -0
  149. package/dist/cookie-banner/theme.js +0 -0
  150. package/dist/index.cjs +89 -0
  151. package/dist/index.d.ts +11 -0
  152. package/dist/index.d.ts.map +1 -0
  153. package/dist/index.js +8 -0
  154. package/dist/primitives/box.cjs +54 -0
  155. package/dist/primitives/box.d.ts +47 -0
  156. package/dist/primitives/box.d.ts.map +1 -0
  157. package/dist/primitives/box.js +20 -0
  158. package/dist/primitives/button.cjs +93 -0
  159. package/dist/primitives/button.d.ts +207 -0
  160. package/dist/primitives/button.d.ts.map +1 -0
  161. package/dist/primitives/button.js +59 -0
  162. package/dist/primitives/button.types.cjs +19 -0
  163. package/dist/primitives/button.types.d.ts +34 -0
  164. package/dist/primitives/button.types.d.ts.map +1 -0
  165. package/dist/primitives/button.types.js +0 -0
  166. package/dist/theme/context.cjs +44 -0
  167. package/dist/theme/context.d.ts +96 -0
  168. package/dist/theme/context.d.ts.map +1 -0
  169. package/dist/theme/context.js +9 -0
  170. package/dist/theme/index.cjs +39 -0
  171. package/dist/theme/index.d.ts +6 -0
  172. package/dist/theme/index.d.ts.map +1 -0
  173. package/dist/theme/index.js +6 -0
  174. package/dist/theme/style-keys.cjs +39 -0
  175. package/dist/theme/style-keys.d.ts +77 -0
  176. package/dist/theme/style-keys.d.ts.map +1 -0
  177. package/dist/theme/style-keys.js +5 -0
  178. package/dist/theme/use-style.cjs +95 -0
  179. package/dist/theme/use-style.d.ts +32 -0
  180. package/dist/theme/use-style.d.ts.map +1 -0
  181. package/dist/theme/use-style.js +61 -0
  182. package/dist/theme/utils/merge-styles.cjs +62 -0
  183. package/dist/theme/utils/merge-styles.d.ts +3 -0
  184. package/dist/theme/utils/merge-styles.d.ts.map +1 -0
  185. package/dist/theme/utils/merge-styles.js +28 -0
  186. package/dist/ui/components/accordion.cjs +204 -0
  187. package/dist/ui/components/accordion.css +158 -0
  188. package/dist/ui/components/accordion.d.ts +45 -0
  189. package/dist/ui/components/accordion.d.ts.map +1 -0
  190. package/dist/ui/components/accordion.js +164 -0
  191. package/dist/ui/components/button.cjs +185 -0
  192. package/dist/ui/components/button.css +303 -0
  193. package/dist/ui/components/button.d.ts +445 -0
  194. package/dist/ui/components/button.d.ts.map +1 -0
  195. package/dist/ui/components/button.js +149 -0
  196. package/dist/ui/components/card.cjs +80 -0
  197. package/dist/ui/components/card.css +55 -0
  198. package/dist/ui/components/card.d.ts +10 -0
  199. package/dist/ui/components/card.d.ts.map +1 -0
  200. package/dist/ui/components/card.js +41 -0
  201. package/dist/ui/components/icon.cjs +57 -0
  202. package/dist/ui/components/icon.d.ts +8 -0
  203. package/dist/ui/components/icon.d.ts.map +1 -0
  204. package/dist/ui/components/icon.js +23 -0
  205. package/dist/ui/components/logo.cjs +101 -0
  206. package/dist/ui/components/logo.d.ts +8 -0
  207. package/dist/ui/components/logo.d.ts.map +1 -0
  208. package/dist/ui/components/logo.js +67 -0
  209. package/dist/ui/components/switch.cjs +81 -0
  210. package/dist/ui/components/switch.css +135 -0
  211. package/dist/ui/components/switch.d.ts +25 -0
  212. package/dist/ui/components/switch.d.ts.map +1 -0
  213. package/dist/ui/components/switch.js +47 -0
  214. package/dist/ui/libs/cn.cjs +55 -0
  215. package/dist/ui/libs/cn.d.ts +11 -0
  216. package/dist/ui/libs/cn.d.ts.map +1 -0
  217. package/dist/ui/libs/cn.js +6 -0
  218. package/dist/ui/libs/polymorphic.cjs +19 -0
  219. package/dist/ui/libs/polymorphic.d.ts +15 -0
  220. package/dist/ui/libs/polymorphic.d.ts.map +1 -0
  221. package/dist/ui/libs/polymorphic.js +0 -0
  222. package/dist/ui/libs/recursive-clone-children.cjs +49 -0
  223. package/dist/ui/libs/recursive-clone-children.d.ts +14 -0
  224. package/dist/ui/libs/recursive-clone-children.d.ts.map +1 -0
  225. package/dist/ui/libs/recursive-clone-children.js +15 -0
  226. package/dist/ui/theme/context.cjs +6 -0
  227. package/dist/ui/theme/context.d.ts +2 -0
  228. package/dist/ui/theme/context.d.ts.map +1 -0
  229. package/dist/ui/theme/context.js +0 -0
  230. package/package.json +71 -0
@@ -0,0 +1,29 @@
1
+ import type { Translations } from 'c15t';
2
+ /**
3
+ * Hook for accessing translations in the current language.
4
+ *
5
+ * @remarks
6
+ * This hook provides access to the translations for the currently selected language.
7
+ * It automatically handles language selection based on the translation configuration.
8
+ * Falls back to English if the selected language is not available.
9
+ *
10
+ * @returns The translations for the current language
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * function CookieBanner() {
15
+ * const translations = useTranslations();
16
+ *
17
+ * return (
18
+ * <div>
19
+ * <h2>{translations.cookieBanner.title}</h2>
20
+ * <p>{translations.cookieBanner.description}</p>
21
+ * </div>
22
+ * );
23
+ * }
24
+ * ```
25
+ *
26
+ * @public
27
+ */
28
+ export declare function useTranslations(): Translations;
29
+ //# sourceMappingURL=use-translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-translations.d.ts","sourceRoot":"","sources":["../../../src/common/store/use-translations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAoB9C"}
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+ import * as __WEBPACK_EXTERNAL_MODULE_c15t__ from "c15t";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__use_consent_manager_js_06584a12__ from "./use-consent-manager.js";
5
+ function useTranslations() {
6
+ const { translationConfig } = (0, __WEBPACK_EXTERNAL_MODULE__use_consent_manager_js_06584a12__.useConsentManager)();
7
+ return (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
8
+ const { translations = {}, defaultLanguage = 'en' } = translationConfig;
9
+ const selectedTranslations = translations[defaultLanguage];
10
+ if (isTranslations(selectedTranslations)) return selectedTranslations;
11
+ const englishTranslations = translations.en;
12
+ if (isTranslations(englishTranslations)) return englishTranslations;
13
+ return __WEBPACK_EXTERNAL_MODULE_c15t__.defaultTranslationConfig.translations.en;
14
+ }, [
15
+ translationConfig
16
+ ]);
17
+ }
18
+ function isTranslations(value) {
19
+ if (!value || 'object' != typeof value) return false;
20
+ const obj = value;
21
+ const hasRequiredKeys = 'cookieBanner' in obj && 'consentManagerDialog' in obj && 'consentManagerWidget' in obj && 'consentTypes' in obj;
22
+ return hasRequiredKeys;
23
+ }
24
+ export { useTranslations };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = function(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
+ var __webpack_export_target__ = exports;
16
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
17
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
18
+ value: true
19
+ });
@@ -0,0 +1,82 @@
1
+ import type { AllConsentNames, ComplianceRegion, ComplianceSettings, NamespaceProps, PrivacyConsentState, TrackingBlockerConfig, TranslationConfig, createConsentManagerStore } from 'c15t';
2
+ import type { ReactNode } from 'react';
3
+ /**
4
+ * Configuration options for the ConsentManagerProvider component.
5
+ *
6
+ * @remarks
7
+ * These props allow you to configure the initial state and behavior of the consent manager,
8
+ * including GDPR types, compliance settings, and namespace configuration.
9
+ *
10
+ * @public
11
+ */
12
+ export interface ConsentManagerProviderProps extends NamespaceProps {
13
+ /**
14
+ * @remarks
15
+ * React elements to be rendered within the consent manager context.
16
+ */
17
+ children: ReactNode;
18
+ /**
19
+ * @remarks
20
+ * Array of consent types to be pre-configured for GDPR compliance.
21
+ * These types define what kinds of cookies and tracking are initially allowed.
22
+ */
23
+ initialGdprTypes?: AllConsentNames[];
24
+ /**
25
+ * @remarks
26
+ * Region-specific compliance settings that define how the consent manager
27
+ * should behave in different geographical regions.
28
+ */
29
+ initialComplianceSettings?: Record<ComplianceRegion, ComplianceSettings>;
30
+ /**
31
+ * @remarks
32
+ * Whether to skip injecting default styles
33
+ * @default false
34
+ */
35
+ noStyle?: boolean;
36
+ /**
37
+ * @remarks
38
+ * The configuration allows you to:
39
+ * - Define translations for multiple languages through the translations object
40
+ * - Set a default language via defaultLanguage prop
41
+ * - Control automatic language switching based on browser settings with disableAutoLanguageSwitch
42
+ * - Override specific translation keys while keeping defaults for others
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * <ConsentManagerProvider
47
+ * translationConfig={{
48
+ * translations: {
49
+ * de: {
50
+ * cookieBanner: {
51
+ * title: 'Cookie-Einstellungen',
52
+ * description: 'Wir verwenden Cookies...'
53
+ * }
54
+ * }
55
+ * },
56
+ * defaultLanguage: 'en',
57
+ * disableAutoLanguageSwitch: false
58
+ * }}
59
+ * >
60
+ * {children}
61
+ * </ConsentManagerProvider>
62
+ * ```
63
+ */
64
+ translationConfig?: Partial<TranslationConfig>;
65
+ trackingBlockerConfig?: TrackingBlockerConfig;
66
+ }
67
+ /**
68
+ * Internal context value interface for the consent manager.
69
+ *
70
+ * @remarks
71
+ * Combines both the current state and store instance for complete
72
+ * consent management functionality.
73
+ *
74
+ * @internal
75
+ */
76
+ export interface ConsentManagerContextValue {
77
+ /** Current privacy consent state */
78
+ state: PrivacyConsentState;
79
+ /** Store instance for managing consent state */
80
+ store: ReturnType<typeof createConsentManagerStore>;
81
+ }
82
+ //# sourceMappingURL=consent-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consent-manager.d.ts","sourceRoot":"","sources":["../../../src/common/types/consent-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,WAAW,2BAA4B,SAAQ,cAAc;IAClE;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IAErC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IACzE;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE/C,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,0BAA0B;IAC1C,oCAAoC;IACpC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,gDAAgD;IAChD,KAAK,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;CACpD"}
File without changes
@@ -0,0 +1,47 @@
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
+ createThemeContextValue: ()=>createThemeContextValue
30
+ });
31
+ function createThemeContextValue(consentManager, themeProps) {
32
+ const fn = ()=>({
33
+ ...consentManager,
34
+ ...themeProps
35
+ });
36
+ const result = Object.assign(fn, {
37
+ ...consentManager,
38
+ ...themeProps
39
+ });
40
+ if ('function' != typeof result || !('theme' in result)) throw new Error('Invalid theme context value');
41
+ return result;
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,8 @@
1
+ import type { PrivacyConsentState } from 'c15t';
2
+ import type { ThemeContextValue } from '../../theme';
3
+ interface ThemeContextValueWithConsent extends PrivacyConsentState, ThemeContextValue {
4
+ (): PrivacyConsentState & ThemeContextValue;
5
+ }
6
+ export declare function createThemeContextValue(consentManager: PrivacyConsentState, themeProps: ThemeContextValue): ThemeContextValueWithConsent;
7
+ export {};
8
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/common/utils/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,UAAU,4BACT,SAAQ,mBAAmB,EAC1B,iBAAiB;IAClB,IAAI,mBAAmB,GAAG,iBAAiB,CAAC;CAC5C;AAED,wBAAgB,uBAAuB,CACtC,cAAc,EAAE,mBAAmB,EACnC,UAAU,EAAE,iBAAiB,GAC3B,4BAA4B,CAc9B"}
@@ -0,0 +1,13 @@
1
+ function createThemeContextValue(consentManager, themeProps) {
2
+ const fn = ()=>({
3
+ ...consentManager,
4
+ ...themeProps
5
+ });
6
+ const result = Object.assign(fn, {
7
+ ...consentManager,
8
+ ...themeProps
9
+ });
10
+ if ('function' != typeof result || !('theme' in result)) throw new Error('Invalid theme context value');
11
+ return result;
12
+ }
13
+ export { createThemeContextValue };
@@ -0,0 +1,86 @@
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
+ deepMergeTranslations: ()=>deepMergeTranslations,
31
+ detectBrowserLanguage: ()=>detectBrowserLanguage,
32
+ mergeTranslationConfigs: ()=>mergeTranslationConfigs
33
+ });
34
+ function deepMergeTranslations(base, override) {
35
+ const sections = [
36
+ 'cookieBanner',
37
+ 'consentManagerDialog',
38
+ 'consentManagerWidget',
39
+ 'consentTypes'
40
+ ];
41
+ return sections.reduce((result, section)=>{
42
+ result[section] = {
43
+ ...base[section],
44
+ ...override[section] || {}
45
+ };
46
+ return result;
47
+ }, {});
48
+ }
49
+ function mergeTranslationConfigs(defaultConfig, customConfig) {
50
+ const mergedTranslations = {
51
+ ...defaultConfig.translations
52
+ };
53
+ if (customConfig?.translations) {
54
+ if (customConfig.translations.en) mergedTranslations.en = deepMergeTranslations(defaultConfig.translations.en, customConfig.translations.en);
55
+ for (const [lang, translations] of Object.entries(customConfig.translations))if ('en' !== lang && translations) {
56
+ const baseTranslations = mergedTranslations.en;
57
+ mergedTranslations[lang] = deepMergeTranslations(baseTranslations, translations);
58
+ }
59
+ }
60
+ return {
61
+ ...defaultConfig,
62
+ ...customConfig,
63
+ translations: mergedTranslations
64
+ };
65
+ }
66
+ function detectBrowserLanguage(translations, defaultLanguage, disableAutoSwitch = false) {
67
+ if (disableAutoSwitch) return defaultLanguage || 'en';
68
+ const availableLanguages = Object.keys(translations).map((lang)=>lang.toLowerCase());
69
+ const browserLanguages = 'undefined' != typeof window ? navigator?.languages || [
70
+ navigator?.language || 'en'
71
+ ] : [
72
+ 'en'
73
+ ];
74
+ for (const lang of browserLanguages){
75
+ const normalizedLang = lang.toLowerCase();
76
+ if (availableLanguages.includes(normalizedLang)) return normalizedLang;
77
+ const primaryLang = normalizedLang.split('-')[0];
78
+ if (primaryLang && availableLanguages.includes(primaryLang)) return primaryLang;
79
+ }
80
+ return 'en';
81
+ }
82
+ var __webpack_export_target__ = exports;
83
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
84
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
85
+ value: true
86
+ });
@@ -0,0 +1,14 @@
1
+ import type { TranslationConfig, Translations } from 'c15t';
2
+ /**
3
+ * Deep merges translation objects
4
+ */
5
+ export declare function deepMergeTranslations(base: Translations, override: Partial<Translations>): Translations;
6
+ /**
7
+ * Merges custom translations with defaults
8
+ */
9
+ export declare function mergeTranslationConfigs(defaultConfig: TranslationConfig, customConfig?: Partial<TranslationConfig>): TranslationConfig;
10
+ /**
11
+ * Detects browser language and returns appropriate default language
12
+ */
13
+ export declare function detectBrowserLanguage(translations: Record<string, unknown>, defaultLanguage: string | undefined, disableAutoSwitch?: boolean): string;
14
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/common/utils/translations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAQ5D;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAC7B,YAAY,CAed;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,iBAAiB,EAChC,YAAY,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACvC,iBAAiB,CA+BnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,iBAAiB,UAAQ,GACvB,MAAM,CAgCR"}
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ function deepMergeTranslations(base, override) {
3
+ const sections = [
4
+ 'cookieBanner',
5
+ 'consentManagerDialog',
6
+ 'consentManagerWidget',
7
+ 'consentTypes'
8
+ ];
9
+ return sections.reduce((result, section)=>{
10
+ result[section] = {
11
+ ...base[section],
12
+ ...override[section] || {}
13
+ };
14
+ return result;
15
+ }, {});
16
+ }
17
+ function mergeTranslationConfigs(defaultConfig, customConfig) {
18
+ const mergedTranslations = {
19
+ ...defaultConfig.translations
20
+ };
21
+ if (customConfig?.translations) {
22
+ if (customConfig.translations.en) mergedTranslations.en = deepMergeTranslations(defaultConfig.translations.en, customConfig.translations.en);
23
+ for (const [lang, translations] of Object.entries(customConfig.translations))if ('en' !== lang && translations) {
24
+ const baseTranslations = mergedTranslations.en;
25
+ mergedTranslations[lang] = deepMergeTranslations(baseTranslations, translations);
26
+ }
27
+ }
28
+ return {
29
+ ...defaultConfig,
30
+ ...customConfig,
31
+ translations: mergedTranslations
32
+ };
33
+ }
34
+ function detectBrowserLanguage(translations, defaultLanguage, disableAutoSwitch = false) {
35
+ if (disableAutoSwitch) return defaultLanguage || 'en';
36
+ const availableLanguages = Object.keys(translations).map((lang)=>lang.toLowerCase());
37
+ const browserLanguages = 'undefined' != typeof window ? navigator?.languages || [
38
+ navigator?.language || 'en'
39
+ ] : [
40
+ 'en'
41
+ ];
42
+ for (const lang of browserLanguages){
43
+ const normalizedLang = lang.toLowerCase();
44
+ if (availableLanguages.includes(normalizedLang)) return normalizedLang;
45
+ const primaryLang = normalizedLang.split('-')[0];
46
+ if (primaryLang && availableLanguages.includes(primaryLang)) return primaryLang;
47
+ }
48
+ return 'en';
49
+ }
50
+ export { deepMergeTranslations, detectBrowserLanguage, mergeTranslationConfigs };
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ var __webpack_exports__ = {};
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
+ const external_utils_cjs_namespaceObject = require("./utils.cjs");
34
+ var external_utils_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_utils_cjs_namespaceObject);
35
+ const ALL_COMPONENTS = [
36
+ {
37
+ testId: 'consent-manager-dialog-root',
38
+ themeKey: 'consent-manager-dialog.root',
39
+ styles: 'custom-dialog-root'
40
+ },
41
+ {
42
+ testId: 'consent-manager-dialog-overlay',
43
+ themeKey: 'consent-manager-dialog.overlay',
44
+ styles: 'custom-dialog-overlay'
45
+ },
46
+ {
47
+ testId: 'consent-manager-dialog-header',
48
+ themeKey: 'consent-manager-dialog.header',
49
+ styles: 'custom-dialog-header'
50
+ },
51
+ {
52
+ testId: 'consent-manager-dialog-title',
53
+ themeKey: 'consent-manager-dialog.title',
54
+ styles: 'custom-dialog-title'
55
+ },
56
+ {
57
+ testId: "consent-manager-dialog-description",
58
+ themeKey: "consent-manager-dialog.description",
59
+ styles: "custom-dialog-description"
60
+ },
61
+ {
62
+ testId: 'consent-manager-dialog-content',
63
+ themeKey: 'consent-manager-dialog.content',
64
+ styles: 'custom-dialog-content'
65
+ },
66
+ {
67
+ testId: 'consent-manager-dialog-footer',
68
+ themeKey: 'consent-manager-dialog.footer',
69
+ styles: 'custom-dialog-footer'
70
+ }
71
+ ];
72
+ (0, external_vitest_namespaceObject.test)('Theme prop applies string classnames to all components', async ()=>{
73
+ const test = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerDialog, {
74
+ open: true,
75
+ theme: ALL_COMPONENTS.reduce((acc, { themeKey, styles })=>{
76
+ acc[themeKey] = styles;
77
+ return acc;
78
+ }, {})
79
+ });
80
+ await external_utils_cjs_default()({
81
+ component: test,
82
+ testCases: ALL_COMPONENTS.map(({ testId, styles })=>({
83
+ testId,
84
+ styles
85
+ }))
86
+ });
87
+ });
88
+ (0, external_vitest_namespaceObject.test)('Theme prop supports object format with className and style for all components', async ()=>{
89
+ const style = {
90
+ backgroundColor: '#ffffff',
91
+ padding: '20px',
92
+ border: '1px solid #000000'
93
+ };
94
+ const testCases = ALL_COMPONENTS.map(({ testId, themeKey, styles })=>({
95
+ testId,
96
+ themeKey,
97
+ className: styles,
98
+ style
99
+ }));
100
+ const test = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerDialog, {
101
+ open: true,
102
+ theme: testCases.reduce((acc, { themeKey, className, style })=>{
103
+ acc[themeKey] = {
104
+ className,
105
+ style
106
+ };
107
+ return acc;
108
+ }, {})
109
+ });
110
+ await external_utils_cjs_default()({
111
+ component: test,
112
+ testCases: testCases.map(({ testId, className, style })=>({
113
+ testId,
114
+ styles: {
115
+ className,
116
+ style
117
+ }
118
+ }))
119
+ });
120
+ });
121
+ (0, external_vitest_namespaceObject.test)('No style prop removes default styles but keeps custom classNames', async ()=>{
122
+ const test = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerDialog, {
123
+ noStyle: true,
124
+ open: true,
125
+ theme: ALL_COMPONENTS.reduce((acc, { themeKey, styles })=>{
126
+ acc[themeKey] = styles;
127
+ return acc;
128
+ }, {})
129
+ });
130
+ await external_utils_cjs_default()({
131
+ component: test,
132
+ testCases: ALL_COMPONENTS.map(({ testId, styles })=>({
133
+ testId,
134
+ styles
135
+ })),
136
+ noStyle: true
137
+ });
138
+ });
139
+ (0, external_vitest_namespaceObject.test)('Theme prop handles mixed format (string and object) correctly', async ()=>{
140
+ const mixedTheme = {
141
+ 'consent-manager-dialog.root': {
142
+ className: 'custom-dialog-root',
143
+ style: {
144
+ backgroundColor: 'rgb(255, 255, 255)',
145
+ padding: '16px'
146
+ }
147
+ },
148
+ 'consent-manager-dialog.overlay': 'custom-dialog-overlay'
149
+ };
150
+ const test = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerDialog, {
151
+ theme: mixedTheme,
152
+ open: true
153
+ });
154
+ await external_utils_cjs_default()({
155
+ component: test,
156
+ testCases: [
157
+ {
158
+ testId: 'consent-manager-dialog-root',
159
+ styles: {
160
+ className: 'custom-dialog-root',
161
+ style: {
162
+ backgroundColor: 'rgb(255, 255, 255)',
163
+ padding: '16px'
164
+ }
165
+ }
166
+ },
167
+ {
168
+ testId: 'consent-manager-dialog-overlay',
169
+ styles: 'custom-dialog-overlay'
170
+ }
171
+ ]
172
+ });
173
+ });
174
+ (0, external_vitest_namespaceObject.test)('Theme prop handles edge cases gracefully', async ()=>{
175
+ const edgeCaseTheme = {
176
+ 'consent-manager-dialog.root': '',
177
+ 'consent-manager-dialog.overlay': '',
178
+ 'consent-manager-dialog.content': {
179
+ className: '',
180
+ style: {
181
+ margin: '0',
182
+ padding: '0'
183
+ }
184
+ }
185
+ };
186
+ const test = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerDialog, {
187
+ open: true,
188
+ theme: edgeCaseTheme
189
+ });
190
+ await external_utils_cjs_default()({
191
+ component: test,
192
+ testCases: [
193
+ {
194
+ testId: 'consent-manager-dialog-root',
195
+ styles: ''
196
+ },
197
+ {
198
+ testId: 'consent-manager-dialog-overlay',
199
+ styles: ''
200
+ },
201
+ {
202
+ testId: 'consent-manager-dialog-content',
203
+ styles: {
204
+ className: '',
205
+ style: {
206
+ margin: '0',
207
+ padding: '0'
208
+ }
209
+ }
210
+ }
211
+ ]
212
+ });
213
+ });
214
+ var __webpack_export_target__ = exports;
215
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
216
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
217
+ value: true
218
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=styles.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.spec.d.ts","sourceRoot":"","sources":["../../../src/consent-manager-dialog/__tests__/styles.spec.tsx"],"names":[],"mappings":""}