@redacto.io/consent-sdk-react 9.1.0 → 9.2.0-beta.1

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 (64) hide show
  1. package/.turbo/turbo-build.log +10 -9
  2. package/CHANGELOG.md +12 -0
  3. package/dist/index.js +2 -4
  4. package/dist/index.mjs +2 -4
  5. package/dist/privacy-center.d.mts +56 -2
  6. package/dist/privacy-center.d.ts +56 -2
  7. package/dist/privacy-center.js +4840 -1874
  8. package/dist/privacy-center.mjs +5124 -2158
  9. package/package.json +1 -1
  10. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +2 -4
  11. package/src/RedactoNoticeConsent/api/types.ts +1 -0
  12. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +3 -1
  13. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +3 -0
  14. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +26 -0
  15. package/src/RedactoPrivacyCenter/api/actions.ts +66 -0
  16. package/src/RedactoPrivacyCenter/api/client.ts +79 -0
  17. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +19 -13
  18. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +25 -0
  19. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +39 -30
  20. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +2 -0
  21. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +10 -3
  22. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +21 -6
  23. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +222 -0
  24. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +12 -0
  25. package/src/RedactoPrivacyCenter/components/Form.tsx +843 -162
  26. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +492 -0
  27. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +284 -71
  28. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +6 -1
  29. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +56 -0
  30. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +203 -0
  31. package/src/RedactoPrivacyCenter/components/types.ts +26 -2
  32. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +2 -2
  33. package/src/RedactoPrivacyCenter/lib/api.ts +95 -1
  34. package/src/RedactoPrivacyCenter/lib/constants.ts +17 -0
  35. package/src/RedactoPrivacyCenter/lib/types.ts +115 -0
  36. package/src/RedactoPrivacyCenter/locales/as/translation.json +40 -1
  37. package/src/RedactoPrivacyCenter/locales/bho/translation.json +40 -1
  38. package/src/RedactoPrivacyCenter/locales/bn/translation.json +40 -1
  39. package/src/RedactoPrivacyCenter/locales/brx/translation.json +40 -1
  40. package/src/RedactoPrivacyCenter/locales/doi/translation.json +40 -1
  41. package/src/RedactoPrivacyCenter/locales/en/translation.json +46 -1
  42. package/src/RedactoPrivacyCenter/locales/gom/translation.json +40 -1
  43. package/src/RedactoPrivacyCenter/locales/gu/translation.json +40 -1
  44. package/src/RedactoPrivacyCenter/locales/hi/translation.json +40 -1
  45. package/src/RedactoPrivacyCenter/locales/kn/translation.json +40 -1
  46. package/src/RedactoPrivacyCenter/locales/ks/translation.json +40 -1
  47. package/src/RedactoPrivacyCenter/locales/mai/translation.json +40 -1
  48. package/src/RedactoPrivacyCenter/locales/ml/translation.json +40 -1
  49. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +40 -1
  50. package/src/RedactoPrivacyCenter/locales/mr/translation.json +40 -1
  51. package/src/RedactoPrivacyCenter/locales/ne/translation.json +40 -1
  52. package/src/RedactoPrivacyCenter/locales/or/translation.json +40 -1
  53. package/src/RedactoPrivacyCenter/locales/pa/translation.json +40 -1
  54. package/src/RedactoPrivacyCenter/locales/sa/translation.json +40 -1
  55. package/src/RedactoPrivacyCenter/locales/sat/translation.json +40 -1
  56. package/src/RedactoPrivacyCenter/locales/sd/translation.json +40 -1
  57. package/src/RedactoPrivacyCenter/locales/ta/translation.json +40 -1
  58. package/src/RedactoPrivacyCenter/locales/te/translation.json +40 -1
  59. package/src/RedactoPrivacyCenter/locales/ur/translation.json +40 -1
  60. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +301 -0
  61. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +3 -1
  62. package/tests/Form.test.tsx +1170 -0
  63. package/tests/ProductSelectionSection.test.tsx +293 -0
  64. package/tests/RequestSubmit.test.tsx +295 -0
@@ -0,0 +1,222 @@
1
+ import { type CSSProperties, useEffect } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { PCEmpty } from '../../ui/PCEmpty';
4
+ import { pcStyles } from '../../styles/pcStyles';
5
+ import type { FormProductGroup } from '../../lib/types';
6
+ import { buildGroupPurposes } from '../groupHelpers';
7
+
8
+ const getVar = (varName: string): string => `var(${varName})`;
9
+
10
+ /**
11
+ * Compute the unique selection key for a product group.
12
+ *
13
+ * Direct (own-data) groups key on `product_uuid`. Nominated groups append
14
+ * the nominator UUID so two chips on the same product — one direct and one
15
+ * via a nominator — register as distinct selections.
16
+ */
17
+ export const productGroupKey = (group: FormProductGroup): string =>
18
+ group.nominator
19
+ ? `${group.product_uuid}:${group.nominator.uuid}`
20
+ : group.product_uuid;
21
+
22
+ export type ProductSelectionSectionProps = Readonly<{
23
+ directGroups: FormProductGroup[];
24
+ nominatedGroups: FormProductGroup[];
25
+ selectedProductKey: string | null;
26
+ onSelect: (key: string | null, group: FormProductGroup | null) => void;
27
+ /** Optional human label of the request type, e.g. "access". Folded into
28
+ * the instruction header when supplied. */
29
+ requestTypeLabel?: string;
30
+ isTranslating?: boolean;
31
+ }>;
32
+
33
+ type ChipProps = Readonly<{
34
+ group: FormProductGroup;
35
+ isSelected: boolean;
36
+ isLocked: boolean;
37
+ onSelect: (key: string | null, group: FormProductGroup | null) => void;
38
+ nominationSuffix?: string;
39
+ activePurposesLabel: string;
40
+ }>;
41
+
42
+ const productSelectHeaderStyle: CSSProperties = {
43
+ paddingLeft: pcStyles.pxMd.paddingLeft,
44
+ paddingRight: pcStyles.pxMd.paddingRight,
45
+ marginBottom: pcStyles.mbMd.marginBottom,
46
+ };
47
+
48
+ const ProductChip = ({
49
+ group,
50
+ isSelected,
51
+ isLocked,
52
+ onSelect,
53
+ nominationSuffix,
54
+ activePurposesLabel,
55
+ }: ChipProps) => {
56
+ const key = productGroupKey(group);
57
+
58
+ return (
59
+ <button
60
+ type="button"
61
+ role="option"
62
+ aria-selected={isSelected}
63
+ disabled={isLocked}
64
+ title={group.product_name}
65
+ className={`pc-product-select-chip ${isSelected ? 'pc-product-select-chip--selected' : ''}`}
66
+ data-testid={`product-chip-${key}`}
67
+ onClick={() => {
68
+ if (isLocked) {
69
+ return;
70
+ }
71
+ if (isSelected) {
72
+ onSelect(null, null);
73
+ } else {
74
+ onSelect(key, group);
75
+ }
76
+ }}
77
+ >
78
+ <span className="pc-product-select-chip-inner">
79
+ <span className="pc-product-select-chip-label">{group.product_name}</span>
80
+ {nominationSuffix && (
81
+ <span className="pc-product-select-chip-suffix">{nominationSuffix}</span>
82
+ )}
83
+ <span className="pc-product-select-chip-meta">{activePurposesLabel}</span>
84
+ </span>
85
+ </button>
86
+ );
87
+ };
88
+
89
+ const SkeletonChip = () => (
90
+ <div
91
+ className="pc-product-select-chip pc-product-select-chip--skeleton"
92
+ aria-hidden="true"
93
+ >
94
+ <div
95
+ style={{
96
+ height: '0.875rem',
97
+ width: '6rem',
98
+ animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
99
+ borderRadius: pcStyles.borderRadiusMd,
100
+ backgroundColor: getVar('--pc-bg-tertiary'),
101
+ }}
102
+ />
103
+ </div>
104
+ );
105
+
106
+ export function ProductSelectionSection({
107
+ directGroups,
108
+ nominatedGroups,
109
+ selectedProductKey,
110
+ onSelect,
111
+ requestTypeLabel,
112
+ isTranslating = false,
113
+ }: ProductSelectionSectionProps) {
114
+ const { t } = useTranslation();
115
+
116
+ const totalGroups = directGroups.length + nominatedGroups.length;
117
+ const isSingleGroup = totalGroups === 1;
118
+ const singleGroup = isSingleGroup
119
+ ? (directGroups[0] ?? nominatedGroups[0] ?? null)
120
+ : null;
121
+
122
+ // Auto-select the only group when present. This drives the parent's
123
+ // selection state without requiring a click — per spec, single-group
124
+ // step is pre-selected and rendered read-only.
125
+ useEffect(() => {
126
+ if (!singleGroup) {
127
+ return;
128
+ }
129
+ const key = productGroupKey(singleGroup);
130
+ if (selectedProductKey !== key) {
131
+ onSelect(key, singleGroup);
132
+ }
133
+ }, [singleGroup, selectedProductKey, onSelect]);
134
+
135
+ if (isTranslating) {
136
+ return (
137
+ <div className="pc-product-select-section">
138
+ <div
139
+ className="pc-product-select-chips"
140
+ data-testid="product-selection-chips"
141
+ role="listbox"
142
+ aria-label={t('selectProductsForRequestGeneric')}
143
+ >
144
+ {[0, 1, 2].map((i) => (
145
+ <SkeletonChip key={i} />
146
+ ))}
147
+ </div>
148
+ </div>
149
+ );
150
+ }
151
+
152
+ if (totalGroups === 0) {
153
+ return (
154
+ <PCEmpty
155
+ title={t('noProductsAvailable')}
156
+ description={t('noProductsAvailableDescription')}
157
+ />
158
+ );
159
+ }
160
+
161
+ const headerText = requestTypeLabel
162
+ ? t('selectProductsForRequest', { requestType: requestTypeLabel })
163
+ : t('selectProductsForRequestGeneric');
164
+
165
+ return (
166
+ <div className="pc-product-select-section">
167
+ <div style={productSelectHeaderStyle} className="pc-product-select-header">
168
+ <p
169
+ style={{
170
+ margin: 0,
171
+ fontSize: pcStyles.textXs.fontSize,
172
+ color: getVar('--pc-text-secondary'),
173
+ }}
174
+ >
175
+ {headerText}
176
+ </p>
177
+ </div>
178
+
179
+ <div
180
+ className="pc-product-select-chips"
181
+ data-testid="product-selection-chips"
182
+ role="listbox"
183
+ aria-label={headerText}
184
+ >
185
+ {directGroups.map((group) => {
186
+ const key = productGroupKey(group);
187
+ const activeCount = buildGroupPurposes(group).length;
188
+ return (
189
+ <ProductChip
190
+ key={key}
191
+ group={group}
192
+ isSelected={selectedProductKey === key || isSingleGroup}
193
+ isLocked={isSingleGroup}
194
+ onSelect={onSelect}
195
+ activePurposesLabel={t('activePurposes', { count: activeCount })}
196
+ />
197
+ );
198
+ })}
199
+
200
+ {nominatedGroups.map((group) => {
201
+ const key = productGroupKey(group);
202
+ const activeCount = buildGroupPurposes(group).length;
203
+ const nominatorLabel =
204
+ group.nominator?.name ?? group.nominator?.email ?? '';
205
+ return (
206
+ <ProductChip
207
+ key={key}
208
+ group={group}
209
+ isSelected={selectedProductKey === key || isSingleGroup}
210
+ isLocked={isSingleGroup}
211
+ onSelect={onSelect}
212
+ nominationSuffix={t('nominationChipSuffix', {
213
+ nominator: nominatorLabel,
214
+ })}
215
+ activePurposesLabel={t('activePurposes', { count: activeCount })}
216
+ />
217
+ );
218
+ })}
219
+ </div>
220
+ </div>
221
+ );
222
+ }
@@ -145,6 +145,18 @@ export default function PurposeSelectionSection({
145
145
  ? t('whatDataToAccess')
146
146
  : t('whatDataToDelete')}
147
147
  </p>
148
+ <p style={{
149
+ marginTop: '0.25rem',
150
+ marginBottom: '0.5rem',
151
+ paddingLeft: getVar('--pc-spacing-sm'),
152
+ borderLeft: `2px solid ${getVar('--pc-primary')}`,
153
+ fontSize: pcStyles.textXs.fontSize,
154
+ color: getVar('--pc-text-secondary'),
155
+ lineHeight: 1.4,
156
+ }}>
157
+ {t('revocationNotDeletionNote') ||
158
+ 'Revoking consent does not delete data the organization already holds. You can still request access to or erasure of this data, including for purposes whose consent you have withdrawn.'}
159
+ </p>
148
160
  {!isErasure && (
149
161
  <PCCheckbox
150
162
  label={t('selectAll')}