@tantainnovative/ndpr-toolkit 1.0.5 → 1.0.7

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 (263) hide show
  1. package/README.md +88 -14
  2. package/dist/components/breach-notification/BreachNotificationForm.d.ts +18 -0
  3. package/dist/components/breach-notification/BreachNotificationForm.d.ts.map +1 -0
  4. package/dist/components/consent/ConsentBanner.d.ts +30 -0
  5. package/dist/components/consent/ConsentBanner.d.ts.map +1 -0
  6. package/dist/components/consent/ConsentManager.d.ts +51 -0
  7. package/dist/components/consent/ConsentManager.d.ts.map +1 -0
  8. package/dist/components/consent/ConsentSettings.d.ts +15 -0
  9. package/dist/components/consent/ConsentSettings.d.ts.map +1 -0
  10. package/dist/components/consent/unstyled/UnstyledConsentBanner.d.ts +7 -0
  11. package/dist/components/consent/unstyled/UnstyledConsentBanner.d.ts.map +1 -0
  12. package/dist/components/consent/unstyled/UnstyledConsentSettings.d.ts +7 -0
  13. package/dist/components/consent/unstyled/UnstyledConsentSettings.d.ts.map +1 -0
  14. package/dist/components/consent/unstyled/UnstyledConsentToggle.d.ts +8 -0
  15. package/dist/components/consent/unstyled/UnstyledConsentToggle.d.ts.map +1 -0
  16. package/dist/components/consent/unstyled/index.d.ts +4 -0
  17. package/dist/components/consent/unstyled/index.d.ts.map +1 -0
  18. package/dist/components/data-subject-rights/DataSubjectRequestForm.d.ts +14 -0
  19. package/dist/components/data-subject-rights/DataSubjectRequestForm.d.ts.map +1 -0
  20. package/dist/components/docs/DocLayout.d.ts +9 -0
  21. package/dist/components/docs/DocLayout.d.ts.map +1 -0
  22. package/dist/components/docs/index.d.ts +2 -0
  23. package/dist/components/docs/index.d.ts.map +1 -0
  24. package/dist/components/dpia/DPIAQuestionnaire.d.ts +9 -0
  25. package/dist/components/dpia/DPIAQuestionnaire.d.ts.map +1 -0
  26. package/dist/components/privacy-policy/PolicyGenerator.d.ts +12 -0
  27. package/dist/components/privacy-policy/PolicyGenerator.d.ts.map +1 -0
  28. package/dist/components/privacy-policy/data.d.ts +8 -0
  29. package/dist/components/privacy-policy/data.d.ts.map +1 -0
  30. package/dist/components/privacy-policy/shared/CheckboxField.d.ts +13 -0
  31. package/dist/components/privacy-policy/shared/CheckboxField.d.ts.map +1 -0
  32. package/dist/components/privacy-policy/shared/CheckboxGroup.d.ts +13 -0
  33. package/dist/components/privacy-policy/shared/CheckboxGroup.d.ts.map +1 -0
  34. package/dist/components/privacy-policy/shared/FormField.d.ts +13 -0
  35. package/dist/components/privacy-policy/shared/FormField.d.ts.map +1 -0
  36. package/dist/components/privacy-policy/shared/StepIndicator.d.ts +8 -0
  37. package/dist/components/privacy-policy/shared/StepIndicator.d.ts.map +1 -0
  38. package/dist/components/privacy-policy/steps/CustomSectionsStep.d.ts +15 -0
  39. package/dist/components/privacy-policy/steps/CustomSectionsStep.d.ts.map +1 -0
  40. package/dist/components/privacy-policy/steps/DataCollectionStep.d.ts +20 -0
  41. package/dist/components/privacy-policy/steps/DataCollectionStep.d.ts.map +1 -0
  42. package/dist/components/privacy-policy/steps/DataSharingStep.d.ts +34 -0
  43. package/dist/components/privacy-policy/steps/DataSharingStep.d.ts.map +1 -0
  44. package/dist/components/privacy-policy/steps/OrganizationInfoStep.d.ts +17 -0
  45. package/dist/components/privacy-policy/steps/OrganizationInfoStep.d.ts.map +1 -0
  46. package/dist/components/privacy-policy/steps/PolicyPreviewStep.d.ts +30 -0
  47. package/dist/components/privacy-policy/steps/PolicyPreviewStep.d.ts.map +1 -0
  48. package/dist/components/ui/Badge.d.ts +10 -0
  49. package/dist/components/ui/Badge.d.ts.map +1 -0
  50. package/dist/components/ui/Button.d.ts +11 -0
  51. package/dist/components/ui/Button.d.ts.map +1 -0
  52. package/dist/components/ui/Card.d.ts +10 -0
  53. package/dist/components/ui/Card.d.ts.map +1 -0
  54. package/dist/components/ui/Checkbox.d.ts +8 -0
  55. package/dist/components/ui/Checkbox.d.ts.map +1 -0
  56. package/dist/components/ui/FormField.d.ts +11 -0
  57. package/dist/components/ui/FormField.d.ts.map +1 -0
  58. package/dist/components/ui/Input.d.ts +6 -0
  59. package/dist/components/ui/Input.d.ts.map +1 -0
  60. package/dist/components/ui/Select.d.ts +6 -0
  61. package/dist/components/ui/Select.d.ts.map +1 -0
  62. package/dist/components/ui/TextArea.d.ts +6 -0
  63. package/dist/components/ui/TextArea.d.ts.map +1 -0
  64. package/dist/components/ui/dialog.d.ts +18 -0
  65. package/dist/components/ui/dialog.d.ts.map +1 -0
  66. package/dist/components/ui/label.d.ts +5 -0
  67. package/dist/components/ui/label.d.ts.map +1 -0
  68. package/dist/components/ui/switch.d.ts +5 -0
  69. package/dist/components/ui/switch.d.ts.map +1 -0
  70. package/dist/components/ui/tabs.d.ts +8 -0
  71. package/dist/components/ui/tabs.d.ts.map +1 -0
  72. package/dist/contexts/ConsentContext.d.ts +35 -0
  73. package/dist/contexts/ConsentContext.d.ts.map +1 -0
  74. package/dist/contexts/GenericConsentContext.d.ts +11 -0
  75. package/dist/contexts/GenericConsentContext.d.ts.map +1 -0
  76. package/dist/hooks/useConsent.d.ts +12 -0
  77. package/dist/hooks/useConsent.d.ts.map +1 -0
  78. package/dist/hooks/useConsentActions.d.ts +12 -0
  79. package/dist/hooks/useConsentActions.d.ts.map +1 -0
  80. package/dist/hooks/useConsentManager.d.ts +14 -0
  81. package/dist/hooks/useConsentManager.d.ts.map +1 -0
  82. package/dist/hooks/useConsentState.d.ts +10 -0
  83. package/dist/hooks/useConsentState.d.ts.map +1 -0
  84. package/dist/index.d.mts +256 -0
  85. package/dist/index.d.ts +24 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +2 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/index.mjs +2 -0
  90. package/dist/index.mjs.map +1 -0
  91. package/dist/lib/consentService.d.ts +11 -0
  92. package/dist/lib/consentService.d.ts.map +1 -0
  93. package/dist/lib/dpiaQuestions.d.ts +3 -0
  94. package/dist/lib/dpiaQuestions.d.ts.map +1 -0
  95. package/dist/lib/requestService.d.ts +10 -0
  96. package/dist/lib/requestService.d.ts.map +1 -0
  97. package/dist/lib/utils.d.ts +3 -0
  98. package/dist/lib/utils.d.ts.map +1 -0
  99. package/dist/styles.css +38 -0
  100. package/dist/types/consent.d.ts +57 -0
  101. package/dist/types/consent.d.ts.map +1 -0
  102. package/dist/types/index.d.ts +91 -0
  103. package/dist/types/index.d.ts.map +1 -0
  104. package/dist/unstyled.d.mts +22 -0
  105. package/dist/unstyled.d.ts +2 -0
  106. package/dist/unstyled.d.ts.map +1 -0
  107. package/dist/unstyled.js +2 -0
  108. package/dist/unstyled.js.map +1 -0
  109. package/dist/unstyled.mjs +2 -0
  110. package/dist/unstyled.mjs.map +1 -0
  111. package/package.json +33 -5
  112. package/CHANGELOG.md +0 -16
  113. package/CNAME +0 -1
  114. package/CONTRIBUTING.md +0 -87
  115. package/RELEASE-NOTES-v1.0.0.md +0 -140
  116. package/RELEASE-NOTES-v1.0.1.md +0 -69
  117. package/SECURITY.md +0 -21
  118. package/components.json +0 -21
  119. package/eslint.config.mjs +0 -16
  120. package/next-env.d.ts +0 -5
  121. package/next.config.js +0 -15
  122. package/next.config.ts +0 -62
  123. package/packages/ndpr-toolkit/README.md +0 -467
  124. package/packages/ndpr-toolkit/dist/components/breach/BreachNotificationManager.d.ts +0 -62
  125. package/packages/ndpr-toolkit/dist/components/breach/BreachReportForm.d.ts +0 -66
  126. package/packages/ndpr-toolkit/dist/components/breach/BreachRiskAssessment.d.ts +0 -50
  127. package/packages/ndpr-toolkit/dist/components/breach/RegulatoryReportGenerator.d.ts +0 -94
  128. package/packages/ndpr-toolkit/dist/components/consent/ConsentBanner.d.ts +0 -79
  129. package/packages/ndpr-toolkit/dist/components/consent/ConsentManager.d.ts +0 -73
  130. package/packages/ndpr-toolkit/dist/components/consent/ConsentStorage.d.ts +0 -41
  131. package/packages/ndpr-toolkit/dist/components/dpia/DPIAQuestionnaire.d.ts +0 -70
  132. package/packages/ndpr-toolkit/dist/components/dpia/DPIAReport.d.ts +0 -40
  133. package/packages/ndpr-toolkit/dist/components/dpia/StepIndicator.d.ts +0 -64
  134. package/packages/ndpr-toolkit/dist/components/dsr/DSRDashboard.d.ts +0 -58
  135. package/packages/ndpr-toolkit/dist/components/dsr/DSRRequestForm.d.ts +0 -74
  136. package/packages/ndpr-toolkit/dist/components/dsr/DSRTracker.d.ts +0 -56
  137. package/packages/ndpr-toolkit/dist/components/policy/PolicyExporter.d.ts +0 -65
  138. package/packages/ndpr-toolkit/dist/components/policy/PolicyGenerator.d.ts +0 -54
  139. package/packages/ndpr-toolkit/dist/components/policy/PolicyPreview.d.ts +0 -71
  140. package/packages/ndpr-toolkit/dist/hooks/useBreach.d.ts +0 -97
  141. package/packages/ndpr-toolkit/dist/hooks/useConsent.d.ts +0 -63
  142. package/packages/ndpr-toolkit/dist/hooks/useDPIA.d.ts +0 -92
  143. package/packages/ndpr-toolkit/dist/hooks/useDSR.d.ts +0 -72
  144. package/packages/ndpr-toolkit/dist/hooks/usePrivacyPolicy.d.ts +0 -87
  145. package/packages/ndpr-toolkit/dist/index.d.ts +0 -31
  146. package/packages/ndpr-toolkit/dist/index.esm.js +0 -2
  147. package/packages/ndpr-toolkit/dist/index.esm.js.map +0 -1
  148. package/packages/ndpr-toolkit/dist/index.js +0 -2
  149. package/packages/ndpr-toolkit/dist/index.js.map +0 -1
  150. package/packages/ndpr-toolkit/dist/setupTests.d.ts +0 -2
  151. package/packages/ndpr-toolkit/dist/types/breach.d.ts +0 -239
  152. package/packages/ndpr-toolkit/dist/types/consent.d.ts +0 -95
  153. package/packages/ndpr-toolkit/dist/types/dpia.d.ts +0 -196
  154. package/packages/ndpr-toolkit/dist/types/dsr.d.ts +0 -162
  155. package/packages/ndpr-toolkit/dist/types/privacy.d.ts +0 -204
  156. package/packages/ndpr-toolkit/dist/utils/breach.d.ts +0 -14
  157. package/packages/ndpr-toolkit/dist/utils/consent.d.ts +0 -10
  158. package/packages/ndpr-toolkit/dist/utils/dpia.d.ts +0 -12
  159. package/packages/ndpr-toolkit/dist/utils/dsr.d.ts +0 -11
  160. package/packages/ndpr-toolkit/dist/utils/privacy.d.ts +0 -12
  161. package/packages/ndpr-toolkit/package-lock.json +0 -8197
  162. package/packages/ndpr-toolkit/package.json +0 -71
  163. package/packages/ndpr-toolkit/rollup.config.js +0 -34
  164. package/packages/ndpr-toolkit/src/components/breach/BreachNotificationManager.tsx +0 -701
  165. package/packages/ndpr-toolkit/src/components/breach/BreachReportForm.tsx +0 -631
  166. package/packages/ndpr-toolkit/src/components/breach/BreachRiskAssessment.tsx +0 -569
  167. package/packages/ndpr-toolkit/src/components/breach/RegulatoryReportGenerator.tsx +0 -496
  168. package/packages/ndpr-toolkit/src/components/consent/ConsentBanner.tsx +0 -270
  169. package/packages/ndpr-toolkit/src/components/consent/ConsentManager.tsx +0 -217
  170. package/packages/ndpr-toolkit/src/components/consent/ConsentStorage.tsx +0 -206
  171. package/packages/ndpr-toolkit/src/components/dpia/DPIAQuestionnaire.tsx +0 -342
  172. package/packages/ndpr-toolkit/src/components/dpia/DPIAReport.tsx +0 -373
  173. package/packages/ndpr-toolkit/src/components/dpia/StepIndicator.tsx +0 -174
  174. package/packages/ndpr-toolkit/src/components/dsr/DSRDashboard.tsx +0 -717
  175. package/packages/ndpr-toolkit/src/components/dsr/DSRRequestForm.tsx +0 -476
  176. package/packages/ndpr-toolkit/src/components/dsr/DSRTracker.tsx +0 -620
  177. package/packages/ndpr-toolkit/src/components/policy/PolicyExporter.tsx +0 -541
  178. package/packages/ndpr-toolkit/src/components/policy/PolicyGenerator.tsx +0 -454
  179. package/packages/ndpr-toolkit/src/components/policy/PolicyPreview.tsx +0 -333
  180. package/packages/ndpr-toolkit/src/hooks/useBreach.ts +0 -409
  181. package/packages/ndpr-toolkit/src/hooks/useConsent.ts +0 -263
  182. package/packages/ndpr-toolkit/src/hooks/useDPIA.ts +0 -457
  183. package/packages/ndpr-toolkit/src/hooks/useDSR.ts +0 -236
  184. package/packages/ndpr-toolkit/src/hooks/usePrivacyPolicy.ts +0 -428
  185. package/packages/ndpr-toolkit/src/index.ts +0 -44
  186. package/packages/ndpr-toolkit/src/setupTests.ts +0 -5
  187. package/packages/ndpr-toolkit/src/types/breach.ts +0 -283
  188. package/packages/ndpr-toolkit/src/types/consent.ts +0 -111
  189. package/packages/ndpr-toolkit/src/types/dpia.ts +0 -236
  190. package/packages/ndpr-toolkit/src/types/dsr.ts +0 -192
  191. package/packages/ndpr-toolkit/src/types/index.ts +0 -42
  192. package/packages/ndpr-toolkit/src/types/privacy.ts +0 -246
  193. package/packages/ndpr-toolkit/src/utils/breach.ts +0 -122
  194. package/packages/ndpr-toolkit/src/utils/consent.ts +0 -51
  195. package/packages/ndpr-toolkit/src/utils/dpia.ts +0 -104
  196. package/packages/ndpr-toolkit/src/utils/dsr.ts +0 -77
  197. package/packages/ndpr-toolkit/src/utils/privacy.ts +0 -100
  198. package/packages/ndpr-toolkit/tsconfig.json +0 -23
  199. package/postcss.config.mjs +0 -5
  200. package/public/NDPR TOOLKIT.svg +0 -1
  201. package/public/favicon/android-chrome-192x192.png +0 -0
  202. package/public/favicon/android-chrome-512x512.png +0 -0
  203. package/public/favicon/apple-touch-icon.png +0 -0
  204. package/public/favicon/favicon-16x16.png +0 -0
  205. package/public/favicon/favicon-32x32.png +0 -0
  206. package/public/favicon/site.webmanifest +0 -1
  207. package/public/file.svg +0 -1
  208. package/public/globe.svg +0 -1
  209. package/public/ndpr-toolkit-logo.svg +0 -108
  210. package/public/next.svg +0 -1
  211. package/public/vercel.svg +0 -1
  212. package/public/window.svg +0 -1
  213. package/src/app/accessibility.css +0 -70
  214. package/src/app/favicon.ico +0 -0
  215. package/src/app/globals.css +0 -123
  216. package/src/app/layout.tsx +0 -37
  217. package/src/app/ndpr-demos/breach/page.tsx +0 -354
  218. package/src/app/ndpr-demos/consent/page.tsx +0 -366
  219. package/src/app/ndpr-demos/dpia/page.tsx +0 -495
  220. package/src/app/ndpr-demos/dsr/page.tsx +0 -280
  221. package/src/app/ndpr-demos/page.tsx +0 -73
  222. package/src/app/ndpr-demos/policy/page.tsx +0 -771
  223. package/src/app/page.tsx +0 -452
  224. package/src/components/ErrorBoundary.tsx +0 -90
  225. package/src/components/breach-notification/BreachNotificationForm.tsx +0 -479
  226. package/src/components/consent/ConsentBanner.tsx +0 -193
  227. package/src/components/data-subject-rights/DataSubjectRequestForm.tsx +0 -530
  228. package/src/components/dpia/DPIAQuestionnaire.tsx +0 -523
  229. package/src/components/privacy-policy/PolicyGenerator.tsx +0 -1062
  230. package/src/components/privacy-policy/data.ts +0 -98
  231. package/src/components/privacy-policy/shared/CheckboxField.tsx +0 -38
  232. package/src/components/privacy-policy/shared/CheckboxGroup.tsx +0 -85
  233. package/src/components/privacy-policy/shared/FormField.tsx +0 -79
  234. package/src/components/privacy-policy/shared/StepIndicator.tsx +0 -86
  235. package/src/components/privacy-policy/steps/CustomSectionsStep.tsx +0 -361
  236. package/src/components/privacy-policy/steps/DataCollectionStep.tsx +0 -231
  237. package/src/components/privacy-policy/steps/DataSharingStep.tsx +0 -418
  238. package/src/components/privacy-policy/steps/OrganizationInfoStep.tsx +0 -202
  239. package/src/components/privacy-policy/steps/PolicyPreviewStep.tsx +0 -226
  240. package/src/components/ui/Badge.tsx +0 -46
  241. package/src/components/ui/Button.tsx +0 -59
  242. package/src/components/ui/Card.tsx +0 -92
  243. package/src/components/ui/Checkbox.tsx +0 -57
  244. package/src/components/ui/FormField.tsx +0 -50
  245. package/src/components/ui/Input.tsx +0 -38
  246. package/src/components/ui/Loading.tsx +0 -201
  247. package/src/components/ui/Select.tsx +0 -42
  248. package/src/components/ui/TextArea.tsx +0 -38
  249. package/src/components/ui/label.tsx +0 -24
  250. package/src/components/ui/switch.tsx +0 -31
  251. package/src/components/ui/tabs.tsx +0 -66
  252. package/src/hooks/useConsent.ts +0 -70
  253. package/src/hooks/useLoadingState.ts +0 -85
  254. package/src/lib/consentService.ts +0 -144
  255. package/src/lib/dpiaQuestions.ts +0 -188
  256. package/src/lib/requestService.ts +0 -79
  257. package/src/lib/sanitize.ts +0 -108
  258. package/src/lib/storage.ts +0 -222
  259. package/src/lib/utils.ts +0 -6
  260. package/src/types/html-to-docx.d.ts +0 -30
  261. package/src/types/index.ts +0 -77
  262. package/tailwind.config.ts +0 -65
  263. package/tsconfig.json +0 -41
@@ -1,366 +0,0 @@
1
- 'use client';
2
-
3
- import React, { useState, useEffect } from 'react';
4
- import Link from 'next/link';
5
- import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
6
-
7
- import { Switch } from '@/components/ui/switch';
8
- import { Label } from '@/components/ui/label';
9
- import { ConsentBanner, ConsentManager, ConsentStorage } from '@tantainnovative/ndpr-toolkit';
10
- import { ConsentOption, ConsentSettings } from '@tantainnovative/ndpr-toolkit';
11
- import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/Card';
12
- import { Button } from '@/components/ui/Button';
13
-
14
- export default function ConsentDemoPage() {
15
- const [activeTab, setActiveTab] = useState('banner');
16
- const [isClient, setIsClient] = useState(false);
17
- const [showBanner, setShowBanner] = useState(true);
18
- const [consentSettings, setConsentSettings] = useState<ConsentSettings | null>(null);
19
-
20
- // Define consent options
21
- const consentOptions: ConsentOption[] = [
22
- {
23
- id: 'necessary',
24
- label: 'Necessary',
25
- description: 'Essential cookies required for the website to function properly',
26
- required: true
27
- },
28
- {
29
- id: 'analytics',
30
- label: 'Analytics',
31
- description: 'Cookies that help us analyze how you use our website to improve your experience',
32
- required: false
33
- },
34
- {
35
- id: 'marketing',
36
- label: 'Marketing',
37
- description: 'Cookies used to deliver personalized advertisements based on your interests',
38
- required: false
39
- },
40
- {
41
- id: 'preferences',
42
- label: 'Preferences',
43
- description: 'Cookies that remember your preferences and settings on our website',
44
- required: false
45
- }
46
- ];
47
-
48
- // This effect runs only on the client side after hydration
49
- useEffect(() => {
50
- setIsClient(true);
51
- }, []);
52
-
53
- const handleSaveConsent = (settings: ConsentSettings) => {
54
- setConsentSettings(settings);
55
- setShowBanner(false);
56
- console.log('Consent settings saved:', settings);
57
- };
58
-
59
- const handleResetConsent = () => {
60
- setConsentSettings(null);
61
- setShowBanner(true);
62
- };
63
-
64
- const handleLoadConsent = (settings: ConsentSettings | null) => {
65
- if (settings) {
66
- setConsentSettings(settings);
67
- setShowBanner(!settings.hasInteracted);
68
- } else {
69
- // If no settings are found, show the banner
70
- setShowBanner(true);
71
- }
72
- };
73
-
74
- if (!isClient) {
75
- return <div>Loading...</div>;
76
- }
77
-
78
- return (
79
- <div className="container mx-auto py-10">
80
- <div className="mb-6">
81
- <Link href="/ndpr-demos" className="text-blue-600 hover:underline">
82
- ← Back to NDPR Demos
83
- </Link>
84
- </div>
85
-
86
- <h1 className="text-3xl font-bold mb-8">Consent Management Demo</h1>
87
-
88
- <div className="mb-6 flex items-center space-x-4">
89
- <Switch
90
- id="show-banner"
91
- checked={showBanner}
92
- onCheckedChange={setShowBanner}
93
- />
94
- <Label htmlFor="show-banner">Show Consent Banner</Label>
95
-
96
- <Button
97
- variant="outline"
98
- className="ml-4"
99
- onClick={handleResetConsent}
100
- >
101
- Reset Consent
102
- </Button>
103
- </div>
104
-
105
- {showBanner && (
106
- <div className="fixed bottom-0 left-0 right-0 z-50">
107
- <ConsentBanner
108
- options={consentOptions}
109
- onSave={(settings) => {
110
- handleSaveConsent(settings);
111
- }}
112
- show={showBanner}
113
- title="We Value Your Privacy"
114
- description="We use cookies and similar technologies to improve your experience on our website. By clicking 'Accept All', you consent to the use of all cookies. You can customize your preferences by clicking 'Customize'."
115
- position="bottom"
116
- acceptAllButtonText="Accept All"
117
- rejectAllButtonText="Reject All"
118
- customizeButtonText="Customize"
119
- />
120
- </div>
121
- )}
122
-
123
- <Tabs value={activeTab} onValueChange={setActiveTab}>
124
- <TabsList className="mb-6">
125
- <TabsTrigger value="banner">Consent Banner</TabsTrigger>
126
- <TabsTrigger value="manager">Consent Manager</TabsTrigger>
127
- <TabsTrigger value="storage">Consent Storage</TabsTrigger>
128
- </TabsList>
129
-
130
- <TabsContent value="banner" className="mt-6">
131
- <Card>
132
- <CardHeader>
133
- <CardTitle>Consent Banner</CardTitle>
134
- <CardDescription>
135
- The ConsentBanner component displays a banner to collect user consent for cookies and data processing.
136
- </CardDescription>
137
- </CardHeader>
138
- <CardContent>
139
- <div className="p-4 border rounded-md">
140
- <h3 className="text-lg font-semibold mb-4">Banner Preview</h3>
141
- <ConsentBanner
142
- options={consentOptions}
143
- onSave={() => {}}
144
- title="We Value Your Privacy"
145
- description="We use cookies and similar technologies to improve your experience on our website. By clicking 'Accept All', you consent to the use of all cookies. You can customize your preferences by clicking 'Customize'."
146
- position="bottom"
147
- acceptAllButtonText="Accept All"
148
- rejectAllButtonText="Reject All"
149
- customizeButtonText="Customize"
150
- show={true}
151
- />
152
- </div>
153
-
154
- <div className="mt-6">
155
- <h3 className="text-lg font-semibold mb-2">Usage</h3>
156
- <p>
157
- The ConsentBanner component is typically displayed when a user first visits your website
158
- or when they need to update their consent preferences. It provides options to accept all,
159
- reject all, or customize consent settings.
160
- </p>
161
- </div>
162
- </CardContent>
163
- </Card>
164
- </TabsContent>
165
-
166
- <TabsContent value="manager" className="mt-6">
167
- <Card>
168
- <CardHeader>
169
- <CardTitle>Consent Manager</CardTitle>
170
- <CardDescription>
171
- The ConsentManager component allows users to customize their consent preferences.
172
- </CardDescription>
173
- </CardHeader>
174
- <CardContent>
175
- <div className="mb-4 flex flex-wrap gap-3">
176
- <button
177
- onClick={() => {
178
- // Accept all cookies
179
- const allConsents = {} as Record<string, boolean>;
180
- [
181
- { id: 'necessary', required: true },
182
- { id: 'analytics', required: false },
183
- { id: 'marketing', required: false },
184
- { id: 'preferences', required: false },
185
- ].forEach(option => {
186
- allConsents[option.id] = true;
187
- });
188
-
189
- const newSettings: ConsentSettings = {
190
- consents: allConsents,
191
- timestamp: Date.now(),
192
- version: '1.0',
193
- method: 'accept-all',
194
- hasInteracted: true
195
- };
196
-
197
- handleSaveConsent(newSettings);
198
- }}
199
- className="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700"
200
- >
201
- Accept All
202
- </button>
203
- <button
204
- onClick={() => {
205
- // Reject non-essential cookies
206
- const rejectNonEssential = {} as Record<string, boolean>;
207
- [
208
- { id: 'necessary', required: true },
209
- { id: 'analytics', required: false },
210
- { id: 'marketing', required: false },
211
- { id: 'preferences', required: false },
212
- ].forEach(option => {
213
- // Only necessary cookies are enabled
214
- rejectNonEssential[option.id] = option.required;
215
- });
216
-
217
- const newSettings: ConsentSettings = {
218
- consents: rejectNonEssential,
219
- timestamp: Date.now(),
220
- version: '1.0',
221
- method: 'reject-non-essential',
222
- hasInteracted: true
223
- };
224
-
225
- handleSaveConsent(newSettings);
226
- }}
227
- className="px-4 py-2 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded hover:bg-gray-300 dark:hover:bg-gray-600"
228
- >
229
- Reject Non-Essential
230
- </button>
231
- </div>
232
-
233
- <ConsentManager
234
- options={consentOptions}
235
- settings={consentSettings || {
236
- consents: consentOptions.reduce((acc, option) => {
237
- acc[option.id] = option.required || false;
238
- return acc;
239
- }, {} as Record<string, boolean>),
240
- timestamp: Date.now(),
241
- version: '1.0',
242
- method: 'default',
243
- hasInteracted: false
244
- }}
245
- onSave={handleSaveConsent}
246
- title="Manage Consent Preferences"
247
- description="Customize your consent preferences below. Required cookies are necessary for the website to function and cannot be disabled."
248
- saveButtonText="Save Preferences"
249
- />
250
- </CardContent>
251
- </Card>
252
- </TabsContent>
253
-
254
- <TabsContent value="storage" className="mt-6">
255
- <Card>
256
- <CardHeader>
257
- <CardTitle>Consent Storage</CardTitle>
258
- <CardDescription>
259
- The ConsentStorage component handles the storage and retrieval of consent settings.
260
- </CardDescription>
261
- </CardHeader>
262
- <CardContent>
263
- <div className="p-4 border rounded-md">
264
- <h3 className="text-lg font-semibold mb-4">Storage Demo</h3>
265
- <ConsentStorage
266
- settings={consentSettings || {
267
- consents: {},
268
- timestamp: Date.now(),
269
- version: '1.0',
270
- method: 'default',
271
- hasInteracted: false
272
- }}
273
- storageOptions={{
274
- storageKey: "ndpr_demo_consent",
275
- storageType: "localStorage"
276
- }}
277
- onLoad={handleLoadConsent}
278
- onSave={(settings) => {
279
- console.log('Consent settings saved to storage:', settings);
280
- handleSaveConsent(settings);
281
- }}
282
- autoSave={false}
283
- autoLoad={true}
284
- >
285
- {(storage) => (
286
- <div className="space-y-4">
287
- <div className="p-4 bg-gray-100 rounded-md">
288
- <h4 className="font-medium mb-2">Current Consent Settings</h4>
289
- <pre className="text-xs bg-gray-200 p-2 rounded overflow-auto max-h-40">
290
- {JSON.stringify(consentSettings, null, 2) || 'No settings saved'}
291
- </pre>
292
- </div>
293
-
294
- <div className="flex space-x-4">
295
- <Button
296
- variant="outline"
297
- onClick={() => {
298
- if (consentSettings) {
299
- storage.saveSettings(consentSettings);
300
- }
301
- }}
302
- disabled={!consentSettings}
303
- >
304
- Save to Storage
305
- </Button>
306
-
307
- <Button
308
- variant="outline"
309
- onClick={() => {
310
- const loadedSettings = storage.loadSettings();
311
- if (loadedSettings) {
312
- setConsentSettings(loadedSettings);
313
- }
314
- }}
315
- >
316
- Load from Storage
317
- </Button>
318
-
319
- <Button
320
- variant="outline"
321
- onClick={() => {
322
- storage.clearSettings();
323
- setConsentSettings(null);
324
- }}
325
- >
326
- Clear Storage
327
- </Button>
328
- </div>
329
- </div>
330
- )}
331
- </ConsentStorage>
332
- </div>
333
-
334
- <div className="mt-6">
335
- <h3 className="text-lg font-semibold mb-2">Usage</h3>
336
- <p>
337
- The ConsentStorage component is used to persist consent settings across user sessions.
338
- It supports different storage mechanisms including localStorage, sessionStorage, and cookies.
339
- </p>
340
- </div>
341
- </CardContent>
342
- </Card>
343
- </TabsContent>
344
- </Tabs>
345
-
346
- <div className="mt-10 p-4 bg-gray-100 rounded-lg">
347
- <h2 className="text-xl font-semibold mb-2">Implementation Notes</h2>
348
- <p className="mb-4">
349
- This demo showcases the consent management components from the NDPR Toolkit:
350
- </p>
351
- <ul className="list-disc pl-5 space-y-2">
352
- <li><code>ConsentBanner</code>: For displaying a consent notice to users</li>
353
- <li><code>ConsentManager</code>: For allowing users to customize their consent preferences</li>
354
- <li><code>ConsentStorage</code>: For persisting consent settings</li>
355
- </ul>
356
- <p className="mt-4">
357
- For detailed documentation, see the{' '}
358
- <Link href="/docs/components/consent-management" className="text-blue-600 hover:underline">
359
- Consent Management documentation
360
- </Link>
361
- .
362
- </p>
363
- </div>
364
- </div>
365
- );
366
- }