@soyio/soyio-widget 3.4.0 → 3.5.0

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/README.md CHANGED
@@ -21,6 +21,7 @@ This package is validated by the Soyio SDK CI workflow.
21
21
  - [Modules](#modules)
22
22
  - [Consent Request Box](#consent-request-box)
23
23
  - [Privacy Center](#privacy-center)
24
+ - [Consent Form Box](#consent-form-box)
24
25
  - [Disclosure Request](#disclosure-request)
25
26
  - [Disclosure Request Box](#disclosure-request-box)
26
27
  - [Signature Attempt](#signature-attempt)
@@ -58,6 +59,7 @@ The Soyio Widget provides several modules that you can integrate into your appli
58
59
 
59
60
  - **Consent Request Box**: Embed consent requests directly within your webpage
60
61
  - **Privacy Center**: Embed the Privacy Center inside your page with customizable features
62
+ - **Consent Form Box**: Embed a multi-page consent form that captures field data alongside consent grants
61
63
  - **Disclosure Request**: Verify users and collect required data through validation or authentication
62
64
  - **Signature Attempt**: Enable users to digitally sign documents after authentication
63
65
  - **Auth Request**: Authenticate users using access keys or facial video
@@ -328,6 +330,110 @@ Note:
328
330
  - `eventName`: The name of the event, in this case, `'REQUEST_SUBMITTED'`.
329
331
  - `kind`: The kind of the Data Subject Request submitted. Supported values are: `access`, `opposition`, `rectification`, `suppression` and `portability`
330
332
 
333
+ ## Consent Form Box
334
+
335
+ > 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/consent-form/introduction)
336
+
337
+ The **`ConsentFormBox`** embeds a consent form hosted at `forms.soyio.id` directly within your page. A consent form bundles arbitrary input fields (text, email, NIN, etc.) with one or more consent grants and can be split across multiple pages. The host controls how the success CTA behaves, so embeds inside modals, drawers, or multi-step flows can keep navigation inside their own UI.
338
+
339
+ ```html
340
+ <!-- Add a container div where the consent form will be mounted -->
341
+ <div id="consent-form-box"></div>
342
+
343
+ <script>
344
+ import { ConsentFormBox } from "@soyio/soyio-widget";
345
+
346
+ const consentFormOptions = {
347
+ consentFormToken: "<cform_ token>",
348
+ locale: "en", // Optional, "es" | "en"
349
+ isSandbox: true, // Optional
350
+ appearance: {}, // Optional
351
+ subjectId: "<ent_ entity id>", // Optional
352
+ userReference: "<your-user-id>", // Optional
353
+ onReady: () => console.log("ConsentFormBox is ready"), // Optional
354
+ onEvent: (event) => {
355
+ switch (event.eventName) {
356
+ case "CONSENT_FORM_PAGE_CHANGE":
357
+ console.log(`Page ${event.currentPage}/${event.totalPages}`);
358
+ break;
359
+ case "CONSENT_FORM_SUBMITTED":
360
+ console.log("Entry created", event.entryToken);
361
+ break;
362
+ case "CONSENT_FORM_COMPLETED":
363
+ // Success CTA was clicked. Decide what to do with the redirect URL.
364
+ if (event.redirectUrl) window.top.location.assign(event.redirectUrl);
365
+ break;
366
+ }
367
+ },
368
+ };
369
+
370
+ document.addEventListener("DOMContentLoaded", () => {
371
+ const consentForm = new ConsentFormBox(consentFormOptions);
372
+ consentForm.mount("#consent-form-box");
373
+ });
374
+ </script>
375
+ ```
376
+
377
+ ### Consent Form Box Events
378
+
379
+ All events arrive through `onEvent` with the shapes below. `onReady` is a separate top-level callback fired once when the iframe finishes loading.
380
+
381
+ - **`CONSENT_FORM_LOAD_ERROR`**: Bootstrap failed (form not found, host not allowed, network error).
382
+ ```typescript
383
+ {
384
+ eventName: 'CONSENT_FORM_LOAD_ERROR',
385
+ kind: 'notFound' | 'hostNotAllowed' | 'loadFailed',
386
+ message?: string,
387
+ }
388
+ ```
389
+ - **`CONSENT_FORM_PAGE_CHANGE`**: Fires on initial render and every back/continue navigation. `currentPage` is 1-indexed.
390
+ ```typescript
391
+ {
392
+ eventName: 'CONSENT_FORM_PAGE_CHANGE',
393
+ currentPage: number,
394
+ totalPages: number,
395
+ }
396
+ ```
397
+ - **`CONSENT_FORM_SUBMIT_ERROR`**: The submission request failed after the user clicked submit.
398
+ ```typescript
399
+ {
400
+ eventName: 'CONSENT_FORM_SUBMIT_ERROR',
401
+ message: string,
402
+ }
403
+ ```
404
+ - **`CONSENT_FORM_SUBMITTED`**: A form entry was created. `redirectUrl` reflects the success screen's configured redirect (if any) so the host knows a final CTA is coming.
405
+ ```typescript
406
+ {
407
+ eventName: 'CONSENT_FORM_SUBMITTED',
408
+ entryToken: string,
409
+ redirectUrl: string | null,
410
+ }
411
+ ```
412
+ - **`CONSENT_FORM_COMPLETED`**: The success-screen CTA was clicked. In hosted mode the embed never navigates the iframe itself — the host decides what to do (close a modal, top-level navigation, fire analytics).
413
+ ```typescript
414
+ {
415
+ eventName: 'CONSENT_FORM_COMPLETED',
416
+ entryToken: string,
417
+ redirectUrl: string | null,
418
+ }
419
+ ```
420
+
421
+ ### Attribute Descriptions
422
+
423
+ - **`consentFormToken`**: Identifier of the consent form to render. Must start with `'cform_'`.
424
+ - **`locale`**: Language for built-in copy and validations. Supported values: `'es'`, `'en'`. Defaults to the form's configured language.
425
+ - **`subjectId`**: Optional Soyio entity id (starts with `'ent_'`) to link the resulting entry to an existing data subject.
426
+ - **`userReference`**: Optional integrator-provided reference that is persisted with the entry.
427
+ - **`isSandbox`**: Whether to use the sandbox environment. Defaults to `false`.
428
+ - **`appearance`**: Customize the iframe appearance. See the Appearance section below. The following `appearance.config.*` keys are specific to this module:
429
+ - `appearance.config.showLogo`: Show or hide the form's logo.
430
+ - `appearance.config.showHeader`: Show or hide the form title.
431
+ - `appearance.config.showDescription`: Show or hide the form description.
432
+ - `appearance.config.buttonAlignment`: `'left'` (default), `'center'`, or `'right'`.
433
+ - `appearance.config.icon.dataUseVariant`: Override the data-use icon style (`'duotone'`, `'line'`, `'solid'`).
434
+ - **`onEvent`**: Callback that receives every event fired by the form. See Consent Form Box Events above.
435
+ - **`onReady`**: Optional callback fired once when the iframe becomes ready.
436
+
331
437
  ## Disclosure Request
332
438
 
333
439
  > 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/disclosure/introduction)
package/dist/index.d.ts CHANGED
@@ -92,6 +92,60 @@ declare type ConsentConfig = BaseConfig & {
92
92
 
93
93
  declare type ConsentEvent = ConsentCheckboxChangeEvent;
94
94
 
95
+ export declare class ConsentFormBox extends BaseIframeBox<ConsentFormEvent, ConsentFormConfig> {
96
+ readonly defaultIframePrefix = "consent-form";
97
+ readonly defaultIframeCSSConfig: IframeCSSConfig;
98
+ get uniqueIdentifier(): string;
99
+ protected handleIframeReady(): Promise<void>;
100
+ iframeUrl(): string;
101
+ }
102
+
103
+ declare type ConsentFormCompletedEvent = {
104
+ eventName: 'CONSENT_FORM_COMPLETED';
105
+ entryToken: string;
106
+ redirectUrl: string | null;
107
+ };
108
+
109
+ declare type ConsentFormConfig = BaseConfig<ConsentFormEvent> & {
110
+ /** Form version identifier returned by the dashboard (`cform_...`). */
111
+ consentFormToken: `cform_${string}`;
112
+ /** Language used by the form's UI copy and built-in validations. */
113
+ locale?: ConsentFormLocale;
114
+ /** Optional Soyio entity id (`ent_...`) the entry should be linked to. */
115
+ subjectId?: string | null;
116
+ /** Optional integrator-provided reference that travels with the entry. */
117
+ userReference?: string | null;
118
+ };
119
+
120
+ declare type ConsentFormEvent = ConsentFormSubmittedEvent | ConsentFormCompletedEvent | ConsentFormLoadErrorEvent | ConsentFormSubmitErrorEvent | ConsentFormPageChangeEvent;
121
+
122
+ declare type ConsentFormLoadErrorEvent = {
123
+ eventName: 'CONSENT_FORM_LOAD_ERROR';
124
+ kind: ConsentFormLoadErrorKind;
125
+ message?: string;
126
+ };
127
+
128
+ declare type ConsentFormLoadErrorKind = 'notFound' | 'hostNotAllowed' | 'loadFailed';
129
+
130
+ declare type ConsentFormLocale = 'es' | 'en';
131
+
132
+ declare type ConsentFormPageChangeEvent = {
133
+ eventName: 'CONSENT_FORM_PAGE_CHANGE';
134
+ currentPage: number;
135
+ totalPages: number;
136
+ };
137
+
138
+ declare type ConsentFormSubmitErrorEvent = {
139
+ eventName: 'CONSENT_FORM_SUBMIT_ERROR';
140
+ message: string;
141
+ };
142
+
143
+ declare type ConsentFormSubmittedEvent = {
144
+ eventName: 'CONSENT_FORM_SUBMITTED';
145
+ entryToken: string;
146
+ redirectUrl: string | null;
147
+ };
148
+
95
149
  declare type ConsentState = {
96
150
  isSelected: boolean;
97
151
  actionToken: string | null;
@@ -445,6 +499,21 @@ declare interface SoyioAppearanceConfig {
445
499
  consentControl?: 'switch' | 'checkbox';
446
500
  showHeader?: boolean;
447
501
  showConsentManagementHeader?: boolean;
502
+ /**
503
+ * Show or hide the company/form logo above the content.
504
+ * Currently consumed by `ConsentFormBox`.
505
+ */
506
+ showLogo?: boolean;
507
+ /**
508
+ * Show or hide the supporting description text beneath the title.
509
+ * Currently consumed by `ConsentFormBox`.
510
+ */
511
+ showDescription?: boolean;
512
+ /**
513
+ * Alignment for primary CTA rows (e.g. "Submit", "Continue").
514
+ * Currently consumed by `ConsentFormBox`.
515
+ */
516
+ buttonAlignment?: 'left' | 'center' | 'right';
448
517
  /**
449
518
  * Icon name to use for hint/help tooltips on input labels.
450
519
  * Available icons: 'Question' (default), 'Info', 'QuestionMark', etc.
@@ -590,6 +659,15 @@ declare namespace SoyioTypes {
590
659
  ConsentEvent,
591
660
  ConsentConfig,
592
661
  PrivacyCenterConfig,
662
+ ConsentFormConfig,
663
+ ConsentFormEvent,
664
+ ConsentFormLocale,
665
+ ConsentFormLoadErrorKind,
666
+ ConsentFormSubmittedEvent,
667
+ ConsentFormCompletedEvent,
668
+ ConsentFormLoadErrorEvent,
669
+ ConsentFormSubmitErrorEvent,
670
+ ConsentFormPageChangeEvent,
593
671
  SoyioAppearance,
594
672
  SoyioAppearanceConfig,
595
673
  SoyioAppearanceVariables,