@redacto.io/consent-sdk-react 10.2.2-beta.3 → 10.3.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,53 +1,336 @@
1
- import * as react from 'react';
2
- import react__default from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import { A as AppearanceStyle, N as NoticeControlStyle, a as NoticeMobileLayout, b as NoticeDesktopPosition, c as NoticeBackdrop, d as NoticePhoneFooter, e as NoticeTextScale, f as NoticeAppearance } from './types-Bwtzvz4W.mjs';
3
4
  import { f as NoticeFontOptions } from './types-xaCyZUfo.mjs';
4
5
 
5
- type Settings$1 = {
6
- button: {
7
- /** Styles the "accept selected" button. */
8
- accept: {
9
- backgroundColor: string;
10
- textColor: string;
11
- };
12
- /** Optional: the accept-all shortcut falls back to `accept` when unset. */
13
- acceptAll?: {
14
- backgroundColor: string;
15
- textColor: string;
6
+ /**
7
+ * Horizontal alignment of the brand logo in the notice header, chosen in the
8
+ * admin console and served on `active_config.logo_position`.
9
+ */
10
+ type LogoPosition = "left" | "center" | "right";
11
+ /**
12
+ * Which purposes the banner opens with already ticked, chosen in the admin
13
+ * console and served on `active_config.purpose_preselection`.
14
+ *
15
+ * The server applies no ticks itself — it only carries the choice. Deriving
16
+ * which purposes are mandatory (those holding a `required` + `enabled` data
17
+ * element) and applying the ticks is this SDK's job.
18
+ */
19
+ type PurposePreselection = "NONE" | "MANDATORY" | "ALL";
20
+ type PurposeSelection = {
21
+ selected: boolean;
22
+ /**
23
+ * ACTIVE | EXPIRED | WITHDRAW | DECLINED | INACTIVE.
24
+ *
25
+ * INACTIVE is the "no decision recorded" value, and it is the common case:
26
+ * both notice reads build this map over *every* purpose on the notice once
27
+ * the caller's identifier resolves to a known data principal, so an entry
28
+ * here does not by itself mean the subject has decided anything. Test it
29
+ * with `hasRecordedPurposeState`, not for truthiness.
30
+ */
31
+ status: string;
32
+ needs_reconsent: boolean;
33
+ /** Empty for a purpose absent from the principal's consent history. */
34
+ data_elements: Record<string, DataElementSelection>;
35
+ };
36
+ type DataElementSelection = {
37
+ selected: boolean;
38
+ enabled: boolean;
39
+ required: boolean;
40
+ };
41
+ type ConsentContent = {
42
+ code: number;
43
+ status: string;
44
+ detail: {
45
+ uuid: string;
46
+ name: string;
47
+ organisation_uuid: string;
48
+ workspace_uuid: string;
49
+ collection_point_uuids: string[];
50
+ collection_points: {
51
+ uuid: string;
52
+ organisation_uuid: string;
53
+ workspace_uuid: string;
54
+ name: string;
55
+ created_at: string;
56
+ updated_at: string;
57
+ }[];
58
+ active_config: {
59
+ uuid: string;
60
+ notice_uuid: string;
61
+ organisation_uuid: string;
62
+ workspace_uuid: string;
63
+ version: number;
64
+ status: string;
65
+ notice_text: string;
66
+ additional_text: string;
67
+ /**
68
+ * Optional: absent from an older consent-server. The notice falls back to
69
+ * the bundled English defaults in `constants.ts`.
70
+ */
71
+ accept_all_button_text?: string;
72
+ /** The "accept selected" slot — submits exactly what the user ticked. */
73
+ confirm_button_text: string;
74
+ decline_button_text: string;
75
+ logo_url: string;
76
+ privacy_policy_url: string;
77
+ privacy_center_url: string;
78
+ primary_color: string;
79
+ secondary_color: string;
80
+ font_preference: string;
81
+ /**
82
+ * Optional: absent from an older consent-server and from notices
83
+ * published before the field existed. Resolved via `resolveLogoPosition`,
84
+ * which falls back to "left".
85
+ */
86
+ logo_position?: LogoPosition;
87
+ /** Every product this notice covers. Absent from an older ledger. */
88
+ products?: NoticeProduct[];
89
+ /**
90
+ * Purpose uuids in render order, keyed by product uuid. A product with no
91
+ * entry renders in the order of `purposes` itself.
92
+ */
93
+ product_purpose_order?: Record<string, string[]>;
94
+ purposes: {
95
+ uuid: string;
96
+ /** Products this purpose applies to; absent or empty means all. */
97
+ product_uuids?: string[];
98
+ name: string;
99
+ description: string;
100
+ industries?: string;
101
+ data_elements: {
102
+ uuid: string;
103
+ name: string;
104
+ description: string | null;
105
+ industries?: string | null;
106
+ enabled: boolean;
107
+ required: boolean;
108
+ }[];
109
+ }[];
110
+ /**
111
+ * Optional: absent from an older consent-server and from notices
112
+ * published before the field existed. Resolved via
113
+ * `resolvePurposePreselection`, which falls back to "NONE" — nothing
114
+ * pre-ticked, the behaviour every notice had before this setting.
115
+ */
116
+ purpose_preselection?: PurposePreselection;
117
+ default_language: string;
118
+ supported_languages_and_translations: {
119
+ [key: string]: {
120
+ notice_text: string;
121
+ additional_text: string;
122
+ accept_all_button_text?: string;
123
+ confirm_button_text: string;
124
+ decline_button_text: string;
125
+ privacy_policy_prefix_text: string;
126
+ privacy_policy_anchor_text: string;
127
+ privacy_center_anchor_text?: string;
128
+ purpose_section_heading: string;
129
+ notice_banner_heading: string;
130
+ data_elements: {
131
+ [key: string]: string;
132
+ };
133
+ purposes: {
134
+ [key: string]: string | {
135
+ name: string;
136
+ description: string;
137
+ };
138
+ };
139
+ products?: {
140
+ [key: string]: string | {
141
+ name: string;
142
+ description: string;
143
+ };
144
+ };
145
+ dpo_info?: DpoInfoTranslation;
146
+ };
147
+ };
148
+ created_at: string;
149
+ updated_at: string;
150
+ deployed_at: string;
151
+ privacy_policy_prefix_text: string;
152
+ privacy_policy_anchor_text: string;
153
+ privacy_center_anchor_text?: string;
154
+ /** {product_uuid: url}, for notices whose products are separate entities. */
155
+ product_privacy_policies?: Record<string, string>;
156
+ purpose_section_heading: string;
157
+ notice_banner_heading: string;
158
+ dpo_info?: DpoInfo;
159
+ /**
160
+ * The look the admin set in the Redacto console: style, palette, radius,
161
+ * selection control and the talkback highlight. Empty (or absent on an
162
+ * older server) means classic, drawn from primary/secondary colour.
163
+ */
164
+ appearance?: NoticeAppearance;
16
165
  };
17
- decline: {
18
- backgroundColor: string;
19
- textColor: string;
166
+ notice_type?: string;
167
+ compliance_requirement?: string;
168
+ is_minor?: boolean;
169
+ purpose_selections?: Record<string, PurposeSelection>;
170
+ /**
171
+ * `purpose_selections` keyed by product, then purpose. Absent when the
172
+ * ledger has nothing more to say than the flat map does -- a
173
+ * single-product notice, or before submit fan-out is on. A product missing
174
+ * from it has no state recorded against it; that is not a declined
175
+ * consent, so fall back to `purpose_selections` for it.
176
+ */
177
+ product_purpose_selections?: Record<string, Record<string, PurposeSelection>>;
178
+ reconsent_required?: boolean;
179
+ created_at: string;
180
+ updated_at: string;
181
+ };
182
+ };
183
+ type SettingsButtonColors = {
184
+ backgroundColor?: string;
185
+ textColor?: string;
186
+ };
187
+ /**
188
+ * The colours `settings` can set: the top-level palette, and the dark palette
189
+ * under `settings.darkPalette`. Colours are any CSS colour and are used as given.
190
+ */
191
+ type SettingsPalette = {
192
+ button: {
193
+ /**
194
+ * The brand accent (checkboxes, switches, focus rings and Accept
195
+ * Selected's outline), and Accept All's colour when `acceptAll` is unset.
196
+ */
197
+ accept?: SettingsButtonColors;
198
+ /** The Accept All button; falls back to `accept`. */
199
+ acceptAll?: SettingsButtonColors;
200
+ /** The Accept Selected button itself. */
201
+ acceptSelected?: SettingsButtonColors;
202
+ decline?: SettingsButtonColors & {
203
+ borderColor?: string;
20
204
  };
21
- language: {
22
- backgroundColor: string;
23
- textColor: string;
205
+ language?: {
206
+ backgroundColor?: string;
207
+ textColor?: string;
24
208
  selectedBackgroundColor?: string;
25
209
  selectedTextColor?: string;
26
210
  };
27
211
  };
28
212
  link: string;
213
+ backgroundColor?: string;
214
+ /** Raised surfaces: menus and panels, and the tint of the glass style. */
215
+ surfaceColor?: string;
216
+ headingColor?: string;
217
+ textColor?: string;
218
+ /** Descriptions and hints. */
219
+ mutedTextColor?: string;
220
+ borderColor?: string;
221
+ /** The page dim behind the notice. */
222
+ overlayColor?: string;
223
+ toggle?: {
224
+ onColor?: string;
225
+ offColor?: string;
226
+ knobColor?: string;
227
+ };
228
+ /** The element being read aloud by text-to-speech. */
229
+ ttsHighlight?: {
230
+ backgroundColor?: string;
231
+ textColor?: string;
232
+ };
233
+ };
234
+ /**
235
+ * Code-side styling for the notice. Everything here is optional and overrides,
236
+ * key by key, the appearance set in the Redacto console (`active_config.appearance`):
237
+ * host settings, then the console, then the notice's brand colours and the SDK
238
+ * defaults.
239
+ */
240
+ type Settings = SettingsPalette & {
241
+ /**
242
+ * Visual style: `"classic"`, `"glass"`, `"minimal"` or `"soft"`. Unknown
243
+ * values are ignored and the console's style (else classic) applies.
244
+ */
245
+ theme?: AppearanceStyle;
29
246
  /**
30
247
  * Defaults to "checkbox". Applies to the purpose rows and the product
31
248
  * section headings, not to individual data elements.
32
249
  */
33
250
  selectionControl?: SelectionControlType;
251
+ /**
252
+ * How checkbox rows are drawn, in any style: `"checkbox"` or `"switch"`.
253
+ * Unset keeps checkboxes, in every style.
254
+ */
255
+ controlStyle?: NoticeControlStyle;
34
256
  /**
35
257
  * Asks "are you sure" before Accept All, Accept Selected or Decline submits.
36
258
  * Defaults to false, so the one-click path is unchanged.
37
259
  */
38
260
  confirmBeforeSubmit?: boolean;
39
261
  borderRadius?: string;
40
- backgroundColor?: string;
41
- headingColor?: string;
42
- textColor?: string;
43
- borderColor?: string;
262
+ /** Phones: `"modal"` (centred) or `"sheet"` (docked to the bottom edge). */
263
+ mobileLayout?: NoticeMobileLayout;
264
+ /** Wider screens: `"center"`, `"bottom-right"`, `"bottom-left"` or `"bottom-bar"`. */
265
+ desktopPosition?: NoticeDesktopPosition;
266
+ /** `"dim"` darkens the page behind the notice; `"none"` leaves it as is. */
267
+ backdrop?: NoticeBackdrop;
268
+ /** Collapse the notice text and the DPO block into disclosures. */
269
+ collapsibleSections?: boolean;
270
+ /** Phones: `"stacked"` buttons, or `"paired"` (Accept All over the other two). */
271
+ phoneFooter?: NoticePhoneFooter;
272
+ /** Follow the device's dark mode with `darkPalette` (else the console's). */
273
+ autoDark?: boolean;
274
+ darkPalette?: Partial<SettingsPalette>;
275
+ /** Desktop card width, any CSS length. */
276
+ maxWidth?: string;
277
+ /** Logo height, any CSS length. */
278
+ logoSize?: string;
279
+ /** `"sm"`, `"md"` or `"lg"`: scales every text size. */
280
+ textScale?: NoticeTextScale;
281
+ /** `false` turns entrances and transitions off. */
282
+ motion?: boolean;
283
+ /**
284
+ * CSS scoped to this notice. Target parts with `[data-redacto-part="…"]`;
285
+ * refused whole if it carries a disallowed token (`@import`, `javascript:`…).
286
+ */
287
+ customCss?: string;
44
288
  font?: string;
45
289
  };
290
+ /** A product a notice covers. */
291
+ type NoticeProduct = {
292
+ uuid: string;
293
+ name: string;
294
+ description?: string | null;
295
+ /**
296
+ * Whether the confirm gate must enforce this product's mandatory purposes.
297
+ * Resolved server-side from the caller's scope claim, not derived here.
298
+ *
299
+ * Optional because a consent server predating the field sends nothing, and
300
+ * absence is not `false`: see `serverMarksMandatoryProducts`, which keeps the
301
+ * pre-field gate rather than reading silence as "nothing is required".
302
+ */
303
+ mandatory?: boolean;
304
+ };
46
305
  /**
47
306
  * How a visitor answers a purpose or a product section. Checkbox is the shipped
48
307
  * default and the only variant with a partly-ticked state to draw.
49
308
  */
50
309
  type SelectionControlType = "checkbox" | "radio" | "dropdown";
310
+ type DpoInfo = {
311
+ grievance_text: string;
312
+ grievance_anchor_text: string;
313
+ grievance_url: string;
314
+ grievance_email: string;
315
+ grievance_email_connector_text?: string;
316
+ dp_board_text: string;
317
+ dp_board_anchor_text: string;
318
+ dp_board_url: string;
319
+ dpo_text: string;
320
+ dpo_anchor_text: string;
321
+ /** Not set by the console, which links the DPO by `dpo_email`. */
322
+ dpo_url?: string;
323
+ dpo_email?: string;
324
+ };
325
+ type DpoInfoTranslation = {
326
+ grievance_text?: string;
327
+ grievance_anchor_text?: string;
328
+ grievance_email_connector_text?: string;
329
+ dp_board_text?: string;
330
+ dp_board_anchor_text?: string;
331
+ dpo_text?: string;
332
+ dpo_anchor_text?: string;
333
+ };
51
334
  /**
52
335
  * Error codes from guardian verification
53
336
  */
@@ -95,7 +378,12 @@ type Props$1 = Readonly<{
95
378
  workspaceUuid?: string;
96
379
  baseUrl?: string;
97
380
  ledgerBaseUrl?: string;
98
- settings?: Partial<Settings$1>;
381
+ /**
382
+ * Optional code-side styling. The notice's look is set in the Redacto
383
+ * console (Display settings, Appearance); anything set here overrides the
384
+ * console for that key only.
385
+ */
386
+ settings?: Partial<Settings>;
99
387
  language?: string;
100
388
  blockUI?: boolean;
101
389
  onAccept: () => void;
@@ -134,6 +422,19 @@ type Props$1 = Readonly<{
134
422
  */
135
423
  defaultOpenProducts?: string[];
136
424
  }>;
425
+ type ColorScheme = "light" | "dark";
426
+ type RedactoNoticePreviewProps = Readonly<{
427
+ /** The notice as the public read serves it, built from the console form. */
428
+ content: ConsentContent;
429
+ /** Draws the phone layout (bottom sheet, stacked footer) when true. */
430
+ isMobile?: boolean;
431
+ /**
432
+ * The device scheme to preview; `"dark"` shows the dark palette when the
433
+ * appearance turns automatic dark mode on. Unset follows the device.
434
+ */
435
+ colorScheme?: ColorScheme;
436
+ language?: string;
437
+ }>;
137
438
 
138
439
  /**
139
440
  * Redacto Notice Consent Component
@@ -143,40 +444,7 @@ type Props$1 = Readonly<{
143
444
  * and needs-consent purposes.
144
445
  */
145
446
 
146
- /**
147
- * RedactoNoticeConsent
148
- *
149
- * Main consent management component that provides a comprehensive UI for users
150
- * to view and manage their consent preferences. Supports both initial consent
151
- * collection and reconsent flows.
152
- */
153
- declare const RedactoNoticeConsent: ({ noticeId, accessToken, refreshToken, token, email, mobile, ucic, organisationUuid, workspaceUuid, baseUrl, ledgerBaseUrl, language, blockUI, onAccept, onDecline, onError, otpGate, settings, applicationId, validateAgainst, digilockerMode, digilockerCallbackUrl, includeFullyConsentedData, reviewModeButtonText, defaultOpenProducts, }: Props$1) => react__default.JSX.Element;
154
-
155
- type Settings = {
156
- button: {
157
- accept: {
158
- backgroundColor: string;
159
- textColor: string;
160
- };
161
- decline: {
162
- backgroundColor: string;
163
- textColor: string;
164
- };
165
- language: {
166
- backgroundColor: string;
167
- textColor: string;
168
- selectedBackgroundColor?: string;
169
- selectedTextColor?: string;
170
- };
171
- };
172
- link: string;
173
- borderRadius?: string;
174
- backgroundColor?: string;
175
- headingColor?: string;
176
- textColor?: string;
177
- borderColor?: string;
178
- font?: string;
179
- };
447
+ declare const RedactoNoticeConsent: (props: Props$1) => React__default.JSX.Element;
180
448
 
181
449
  type Props = Readonly<{
182
450
  org_uuid: string;
@@ -186,6 +454,10 @@ type Props = Readonly<{
186
454
  refreshToken?: string;
187
455
  baseUrl?: string;
188
456
  ledgerBaseUrl?: string;
457
+ /**
458
+ * Optional code-side styling; overrides the appearance set in the Redacto
459
+ * console, key by key. The widget uses the colours and font it draws with.
460
+ */
189
461
  settings?: Partial<Settings>;
190
462
  language?: string;
191
463
  onAccept?: () => void;
@@ -195,8 +467,8 @@ type Props = Readonly<{
195
467
  applicationId?: string;
196
468
  }>;
197
469
 
198
- declare const RedactoConsentInline: react.MemoExoticComponent<{
199
- ({ org_uuid, workspace_uuid, notice_uuid, accessToken, baseUrl, ledgerBaseUrl, language, onAccept, onError, onValidationChange, settings, applicationId, }: Props): react.JSX.Element | null;
470
+ declare const RedactoConsentInline: React.MemoExoticComponent<{
471
+ ({ org_uuid, workspace_uuid, notice_uuid, accessToken, baseUrl, ledgerBaseUrl, language, onAccept, onError, onValidationChange, settings, applicationId, }: Props): React.JSX.Element | null;
200
472
  displayName: string;
201
473
  }>;
202
474
 
@@ -220,6 +492,12 @@ type RedactoNoticeAssistedProps = {
220
492
  onDecline?: () => void;
221
493
  /** Called when the agent clicks "Proceed" on the confirmed screen. */
222
494
  onComplete?: () => void;
495
+ /**
496
+ * Optional code-side styling; overrides the appearance set in the Redacto
497
+ * console, key by key. The flow uses its accent, link and talkback
498
+ * highlight colours, and the font.
499
+ */
500
+ settings?: Partial<Settings>;
223
501
  };
224
502
 
225
503
  /**
@@ -236,7 +514,15 @@ type RedactoNoticeAssistedProps = {
236
514
  * submit, `onComplete` fires immediately with no confirmation screen (mirroring
237
515
  * RedactoNoticeConsent's `onAccept`). Steps: `notice` → `verify` (with `otpSent`).
238
516
  */
239
- declare const RedactoNoticeAssisted: ({ organisationUuid, workspaceUuid, noticeUuid, baseUrl, ledgerBaseUrl, onDecline, onComplete, }: RedactoNoticeAssistedProps) => react.JSX.Element;
517
+ declare const RedactoNoticeAssisted: ({ organisationUuid, workspaceUuid, noticeUuid, baseUrl, ledgerBaseUrl, onDecline, onComplete, settings, }: RedactoNoticeAssistedProps) => React.JSX.Element;
518
+
519
+ /**
520
+ * The notice exactly as the SDK draws it, from content the Redacto console
521
+ * builds out of its form, so the Display settings preview cannot drift from
522
+ * what visitors see. Nothing is fetched, submitted, played or focused, and the
523
+ * frame contains the notice's fixed-position overlay.
524
+ */
525
+ declare const RedactoNoticePreview: ({ content, isMobile, colorScheme, language, }: RedactoNoticePreviewProps) => React.JSX.Element;
240
526
 
241
527
  /**
242
528
  * DigiLockerCallback Component
@@ -266,7 +552,7 @@ declare const RedactoNoticeAssisted: ({ organisationUuid, workspaceUuid, noticeU
266
552
  * - error_code: (if failed) Error code like GUARDIAN_UNDER_18, SESSION_EXPIRED, etc.
267
553
  */
268
554
 
269
- declare const DigiLockerCallback: react__default.FC<DigiLockerCallbackProps>;
555
+ declare const DigiLockerCallback: React__default.FC<DigiLockerCallbackProps>;
270
556
 
271
557
  /**
272
558
  * Shared API error handling for the consent-sdk-react package.
@@ -302,4 +588,4 @@ declare class ApiError extends Error {
302
588
  */
303
589
  declare const configureNoticeFonts: (options: NoticeFontOptions) => void;
304
590
 
305
- export { ApiError, type ApiErrorCode, type ConsentFlowState, DigiLockerCallback, type DigiLockerCallbackProps, type GuardianVerificationErrorCode, NoticeFontOptions, RedactoNoticeAssisted, type RedactoNoticeAssistedProps, RedactoNoticeConsent, RedactoConsentInline as RedactoNoticeConsentInline, configureNoticeFonts };
591
+ export { ApiError, type ApiErrorCode, type ConsentFlowState, DigiLockerCallback, type DigiLockerCallbackProps, type GuardianVerificationErrorCode, NoticeAppearance, NoticeFontOptions, RedactoNoticeAssisted, type RedactoNoticeAssistedProps, RedactoNoticeConsent, RedactoConsentInline as RedactoNoticeConsentInline, RedactoNoticePreview, type RedactoNoticePreviewProps, configureNoticeFonts };