@soyio/soyio-widget 2.15.2 → 2.16.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 +353 -179
- package/dist/index.d.ts +19 -1
- package/dist/index.js +303 -303
- package/dist/index.umd.cjs +11 -11
- package/package.json +15 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<h1 align="center">Soyio
|
|
1
|
+
<h1 align="center">Soyio Widget</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<em>
|
|
5
|
-
|
|
5
|
+
Our SDK for web based integrations
|
|
6
6
|
</em>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
</a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Modules](#modules)
|
|
20
|
+
- [Consent Request Box](#consent-request-box)
|
|
21
|
+
- [Privacy Center](#privacy-center)
|
|
22
|
+
- [Disclosure Request](#disclosure-request)
|
|
23
|
+
- [Signature Attempt](#signature-attempt)
|
|
24
|
+
- [Auth Request](#auth-request)
|
|
25
|
+
- [Appearance](#appearance)
|
|
26
|
+
- [TypeScript](#typescript)
|
|
27
|
+
- [Server Side Rendering (SSR)](#server-side-rendering-ssr)
|
|
28
|
+
|
|
29
|
+
|
|
15
30
|
## Installation
|
|
16
31
|
|
|
17
32
|
Install using npm! (or your favorite package manager)
|
|
@@ -22,18 +37,183 @@ npm install @soyio/soyio-widget
|
|
|
22
37
|
|
|
23
38
|
# Using yarn
|
|
24
39
|
yarn add @soyio/soyio-widget
|
|
40
|
+
|
|
41
|
+
# Using pnpm
|
|
42
|
+
pnpm add @soyio/soyio-widget
|
|
25
43
|
```
|
|
26
44
|
|
|
27
45
|
## Usage
|
|
28
46
|
|
|
29
47
|
Integrate the widget into your frontend framework using the script below. Ensure to replace placeholders (e.g., \<request>, \<company id>) with actual values relevant to your implementation.
|
|
30
48
|
|
|
31
|
-
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Modules
|
|
52
|
+
|
|
53
|
+
The Soyio Widget provides several modules that you can integrate into your application:
|
|
54
|
+
|
|
55
|
+
- **Consent Request Box**: Embed consent requests directly within your webpage
|
|
56
|
+
- **Privacy Center**: Embed the Privacy Center inside your page with customizable features
|
|
57
|
+
- **Disclosure Request**: Verify users and collect required data through validation or authentication
|
|
58
|
+
- **Signature Attempt**: Enable users to digitally sign documents after authentication
|
|
59
|
+
- **Auth Request**: Authenticate users using access keys or facial video
|
|
60
|
+
|
|
61
|
+
## Consent Request Box
|
|
62
|
+
|
|
63
|
+
> 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/consent/introduction)
|
|
64
|
+
|
|
65
|
+
The **`ConsentBox`** is a component that allows you to embed a consent request directly within your webpage, rather than opening it in a popup window. This is particularly useful when you want to integrate the consent flow seamlessly into your application's interface.
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<!-- Add a container div where the consent request will be mounted -->
|
|
69
|
+
<div id="consent-request-box"></div>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
import { ConsentBox } from "@soyio/soyio-widget";
|
|
73
|
+
|
|
74
|
+
// Configuration for the consent request
|
|
75
|
+
const consentOptions = {
|
|
76
|
+
consentTemplateId: "<consent template id>",
|
|
77
|
+
onEvent: (data) => console.log(data),
|
|
78
|
+
isSandbox: true, // Optional
|
|
79
|
+
appearance: {}, // Optional
|
|
80
|
+
actionToken: "<action token>", // Optional
|
|
81
|
+
entityId: "<entity id>", // Optional
|
|
82
|
+
context: "<context>", // Optional
|
|
83
|
+
onReady: () => console.log("ConsentBox is ready"), // Optional
|
|
84
|
+
optionalReconsentBehavior: "notice", // Optional
|
|
85
|
+
mandatoryReconsentBehavior: "notice", // Optional
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Wait for DOM to be fully loaded
|
|
89
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
90
|
+
// Create and mount the consent request box
|
|
91
|
+
const consentBox = new ConsentBox(consentOptions);
|
|
92
|
+
consentBox.mount("#consent-request-box");
|
|
93
|
+
});
|
|
94
|
+
</script>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Consent Request Box Events
|
|
32
98
|
|
|
33
|
-
|
|
99
|
+
The `onEvent` follows the following format:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
{
|
|
103
|
+
eventName: 'CONSENT_CHECKBOX_CHANGE',
|
|
104
|
+
isSelected: boolean,
|
|
105
|
+
actionToken: string,
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Methods
|
|
110
|
+
|
|
111
|
+
- **`getState()`**: Returns the current state of the consent box. The returned object has the following structure:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
{
|
|
115
|
+
isSelected: boolean,
|
|
116
|
+
actionToken: string | null,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Attribute Descriptions
|
|
122
|
+
|
|
123
|
+
- **`consentTemplateId`**: Identifier of consent template. It must start with `'constpl_'`.
|
|
124
|
+
- **`isSelected`**: Boolean value indicating whether the consent checkbox is selected or not.
|
|
125
|
+
- **`appearance`**: Customize the appearance of the iframe. [Learn more](https://docs.soyio.id/docs/integration-guide/modules/consent).
|
|
126
|
+
- **`actionToken`**: In case of losing the state of the consent (i.e. page reload), you can use a previously generated `actionToken` to restore the state of the consent.
|
|
127
|
+
- **`entityId`**: Identifier of the `entity` associated with a `ConsentAction`. If provided and a consent was previously granted by this entity, the UI will display a message indicating that consent has already been given.
|
|
128
|
+
- **`context`**: Additional information that will be saved with the consent. Useful when you want to track the consent from a specific context.
|
|
129
|
+
- **`onReady`**: Optional callback that executes when the consent box is ready to use. You can use this to handle logic when the iframe is not mounted yet.
|
|
130
|
+
- **`optionalReconsentBehavior`**: What should happen when the consent is initialized with an `entityId` that has already given consent on an optional category.
|
|
131
|
+
- `notice` will show a message letting the user know that they have already given consent,
|
|
132
|
+
- `askAgain` will show the consent as if it wasn't given in the first place,
|
|
133
|
+
- `hide` will not show the consent at all.
|
|
134
|
+
|
|
135
|
+
We strongly recommend using `notice` so the user doesn't have to give the consent again and knows what they have already given consent to.
|
|
136
|
+
- **`mandatoryReconsentBehavior`**: What should happen when the consent is initialized with an `entityId` that has already given consent on a mandatory category.
|
|
137
|
+
- `notice` will show a message letting the user know that they have already given consent,
|
|
138
|
+
- `askAgain` will show the consent as if it wasn't given in the first place,
|
|
139
|
+
|
|
140
|
+
We don't support hiding the mandatory consent, and we strongly recommend using `notice` so the user doesn't have to give the consent again and knows what they have already given consent to.
|
|
141
|
+
|
|
142
|
+
## Privacy Center
|
|
143
|
+
|
|
144
|
+
> 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/privacy-center/introduction)
|
|
145
|
+
|
|
146
|
+
The `PrivacyCenterBox` lets you embed the Privacy Center inside your page. You can scope which features to show and which data subjects are relevant to your interface. For more info check [our docs](https://docs.soyio.id/).
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<!-- Add a container div where the Privacy Center will be mounted -->
|
|
150
|
+
<div id="privacy-center-box"></div>
|
|
151
|
+
|
|
152
|
+
<script>
|
|
153
|
+
import { PrivacyCenterBox } from "@soyio/soyio-widget";
|
|
154
|
+
|
|
155
|
+
// Configuration for the Privacy Center
|
|
156
|
+
const privacyCenterOptions = {
|
|
157
|
+
// Choose ONE of the following authentication modes:
|
|
158
|
+
// 1) Public mode
|
|
159
|
+
companyId: "<company id>", // e.g. com_...
|
|
160
|
+
|
|
161
|
+
// 2) Authenticated mode
|
|
162
|
+
// sessionToken: "<session token>",
|
|
163
|
+
|
|
164
|
+
// Feature flags (optional)
|
|
165
|
+
enabledFeatures: ["DataSubjectRequest", "ConsentManagement"],
|
|
166
|
+
|
|
167
|
+
// Request reference (optional)
|
|
168
|
+
// Will be attached to data subject requests
|
|
169
|
+
requestReference: "<reference>", // e.g. some uuid or id to match our created records with your frontend flows
|
|
170
|
+
|
|
171
|
+
// Limit consent view to specific data subjects (optional)
|
|
172
|
+
dataSubjects: ["customer", "employee"],
|
|
173
|
+
|
|
174
|
+
// Common options
|
|
175
|
+
onEvent: (event) => console.log(event),
|
|
176
|
+
onReady: () => console.log("PrivacyCenterBox is ready"), // Optional
|
|
177
|
+
isSandbox: true, // Optional
|
|
178
|
+
appearance: {}, // Optional
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Wait for DOM to be fully loaded
|
|
182
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
183
|
+
const privacyCenter = new PrivacyCenterBox(privacyCenterOptions);
|
|
184
|
+
privacyCenter.mount("#privacy-center-box");
|
|
185
|
+
});
|
|
186
|
+
</script>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Attribute Descriptions
|
|
190
|
+
|
|
191
|
+
- `sessionToken`: Use this to authenticate a session directly.
|
|
192
|
+
- `companyId`: The company identifier. Must start with `com_`. Use this when Privacy Center is mounted in a non authenticated environment.
|
|
193
|
+
- `enabledFeatures`: Optional array of features to show. Supported values: `"DataSubjectRequest"`, `"ConsentManagement"`.
|
|
194
|
+
- `requestReference`: Optional string, intended to be a reference of the current session. It will be attached to created data subject requests.
|
|
195
|
+
- `dataSubjects`: Optional array of data subject categories. When present, the consent management view only shows consent for the specified categories. Supported values include: `"anonymous_user"`, `"citizen_voter"`, `"commuter"`, `"consultant"`, `"customer"`, `"employee"`, `"job_applicant"`, `"next_of_kin"`, `"passenger"`, `"patient"`, `"prospect"`, `"shareholder"`, `"supplier_vendor"`, `"trainee"`, `"visitor"`.
|
|
196
|
+
- `isSandbox`: Whether to use the sandbox environment. Defaults to `false`.
|
|
197
|
+
- `appearance`: Customize the iframe appearance. See Appearance section below.
|
|
198
|
+
- `onEvent`: Callback that receives events from the iframe.
|
|
199
|
+
- `onReady`: Optional callback fired when the iframe becomes ready.
|
|
200
|
+
|
|
201
|
+
Note:
|
|
202
|
+
- When `sessionToken` is provided, do not pass `companyId`.
|
|
203
|
+
|
|
204
|
+
### Privacy Center Events
|
|
205
|
+
|
|
206
|
+
- **`REQUEST_SUBMITTED`**: This event occurs when a user successfully submits a Data Subject Request. The event object includes:
|
|
207
|
+
- `eventName`: The name of the event, in this case, `'REQUEST_SUBMITTED'`.
|
|
208
|
+
- `kind`: The kind of the Data Subject Request submitted. Supported values are: `access`, `opposition`, `rectification`, `suppression` and `portability`
|
|
34
209
|
|
|
35
210
|
## Disclosure Request
|
|
36
211
|
|
|
212
|
+
> 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/disclosure/introduction)
|
|
213
|
+
|
|
214
|
+
> [!NOTE]
|
|
215
|
+
> In Safari browsers, disclosure requests can only be opened as a result of a direct user interaction (like a click event). This is due to Safari's security policies regarding popup windows. Always ensure the disclosure request initialization is triggered by a user action when supporting Safari browsers.
|
|
216
|
+
|
|
37
217
|
A **`disclosure_request`** is a process that a user goes through where they are verified, and then they share the necessary data as required by each company.
|
|
38
218
|
This verification can happen in one of the following two ways:
|
|
39
219
|
|
|
@@ -162,6 +342,8 @@ The `onEvent` callback is designed to handle various events that occur during wi
|
|
|
162
342
|
|
|
163
343
|
## Signature Attempt
|
|
164
344
|
|
|
345
|
+
> 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/signature/introduction)
|
|
346
|
+
|
|
165
347
|
The **`signature_attempt`** is a process where, using a previously created `signature_attempt_id`, a request is initiated in which a user can digitally sign a document. To sign the document, the user must be authenticated. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
|
|
166
348
|
|
|
167
349
|
```html
|
|
@@ -211,6 +393,7 @@ Optional props:
|
|
|
211
393
|
|
|
212
394
|
### Signature Attempt Attribute Descriptions
|
|
213
395
|
|
|
396
|
+
|
|
214
397
|
- **`signatureAttemptId`**: Identifier of signature attempt obtained when creating the `SignatureAttempt`. It must start with `'sa_'`.
|
|
215
398
|
- **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
|
|
216
399
|
- **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
|
|
@@ -218,6 +401,8 @@ Optional props:
|
|
|
218
401
|
|
|
219
402
|
## Auth Request
|
|
220
403
|
|
|
404
|
+
> 📖 [Integration Guide](https://docs.soyio.id/docs/integration-guide/authentication/introduction)
|
|
405
|
+
|
|
221
406
|
The **`auth_request`** is a process where, using a previously created `auth_request_id`, a request is initiated in which a user can authenticate. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
|
|
222
407
|
|
|
223
408
|
```html
|
|
@@ -260,157 +445,11 @@ Optional props:
|
|
|
260
445
|
- **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
|
|
261
446
|
- **`customColor`**: A hex code string that specifies the base color of the interface.
|
|
262
447
|
|
|
263
|
-
##
|
|
264
|
-
|
|
265
|
-
The **`ConsentBox`** is a component that allows you to embed a consent request directly within your webpage, rather than opening it in a popup window. This is particularly useful when you want to integrate the consent flow seamlessly into your application's interface.
|
|
266
|
-
|
|
267
|
-
```html
|
|
268
|
-
<!-- Add a container div where the consent request will be mounted -->
|
|
269
|
-
<div id="consent-request-box"></div>
|
|
270
|
-
|
|
271
|
-
<script>
|
|
272
|
-
import { ConsentBox } from "@soyio/soyio-widget";
|
|
273
|
-
|
|
274
|
-
// Configuration for the consent request
|
|
275
|
-
const consentOptions = {
|
|
276
|
-
consentTemplateId: "<consent template id>",
|
|
277
|
-
onEvent: (data) => console.log(data),
|
|
278
|
-
isSandbox: true, // Optional
|
|
279
|
-
appearance: {}, // Optional
|
|
280
|
-
actionToken: "<action token>", // Optional
|
|
281
|
-
entityId: "<entity id>", // Optional
|
|
282
|
-
context: "<context>", // Optional
|
|
283
|
-
onReady: () => console.log("ConsentBox is ready"), // Optional
|
|
284
|
-
optionalReconsentBehavior: "notice", // Optional
|
|
285
|
-
mandatoryReconsentBehavior: "notice", // Optional
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
// Wait for DOM to be fully loaded
|
|
289
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
290
|
-
// Create and mount the consent request box
|
|
291
|
-
const consentBox = new ConsentBox(consentOptions);
|
|
292
|
-
consentBox.mount("#consent-request-box");
|
|
293
|
-
});
|
|
294
|
-
</script>
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### Consent Request Box Events
|
|
298
|
-
|
|
299
|
-
The `onEvent` follows the following format:
|
|
300
|
-
|
|
301
|
-
```typescript
|
|
302
|
-
{
|
|
303
|
-
eventName: 'CONSENT_CHECKBOX_CHANGE',
|
|
304
|
-
isSelected: boolean
|
|
305
|
-
actionToken: string,
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
### Methods
|
|
310
|
-
|
|
311
|
-
- **`getState()`**: Returns the current state of the consent box. The returned object has the following structure:
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
{
|
|
315
|
-
isSelected: boolean,
|
|
316
|
-
actionToken: string | null,
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Attribute Descriptions
|
|
322
|
-
|
|
323
|
-
- **`consentTemplateId`**: Identifier of consent template. It must start with `'constpl_'`.
|
|
324
|
-
- **`isSelected`**: Boolean value indicating whether the consent checkbox is selected or not.
|
|
325
|
-
- **`actionToken`**: token containing necessary information for creation of the consent commit. [Learn more](https://docs.soyio.id/docs/api/resources/create-consent-request).
|
|
326
|
-
- **`appearance`**: Customize the appearance of the iframe. [Learn more](https://docs.soyio.id/docs/integration-guide/modules/consent).
|
|
327
|
-
- **`actionToken`**: In case of losing the state of the consent (i.e. page reload), you can use a previously generated `actionToken` to restore the state of the consent.
|
|
328
|
-
- **`entityId`**: Identifier of the `entity` associated with a `ConsentAction`. If provided and a consent was previously granted by this entity, the UI will display a message indicating that consent has already been given.
|
|
329
|
-
- **`context`**: Additional information that will be saved with the consent. Useful when you want to track the consent from a specific context.
|
|
330
|
-
- **`onReady`**: Optional callback that executes when the consent box is ready to use. You can use this to handle logic when the iframe is not mounted yet.
|
|
331
|
-
- **`optionalReconsentBehavior`**: What should happen when the consent is initialized with an `entityId` that has already given consent on an optional category.
|
|
332
|
-
- `notice` will show a message letting the user know that they have already given consent,
|
|
333
|
-
- `askAgain` will show the consent as if it wasn't given in the first place,
|
|
334
|
-
- `hide` will not show the consent at all.
|
|
335
|
-
|
|
336
|
-
We strongly recommend using `notice` so the user doesn't have to give the consent again and knows what they have already given consent to.
|
|
337
|
-
- **`mandatoryReconsentBehavior`**: What should happen when the consent is initialized with an `entityId` that has already given consent on a mandatory category.
|
|
338
|
-
- `notice` will show a message letting the user know that they have already given consent,
|
|
339
|
-
- `askAgain` will show the consent as if it wasn't given in the first place,
|
|
340
|
-
|
|
341
|
-
We don't support hiding the mandatory consent, and we strongly recommend using `notice` so the user doesn't have to give the consent again and knows what they have already given consent to.
|
|
342
|
-
|
|
343
|
-
## Privacy Center
|
|
344
|
-
|
|
345
|
-
The `PrivacyCenterBox` lets you embed the Privacy Center inside your page. You can scope which features to show and which data subjects are relevant to your interface. For more info check [our docs](https://docs.soyio.id/).
|
|
346
|
-
|
|
347
|
-
```html
|
|
348
|
-
<!-- Add a container div where the Privacy Center will be mounted -->
|
|
349
|
-
<div id="privacy-center-box"></div>
|
|
350
|
-
|
|
351
|
-
<script>
|
|
352
|
-
import { PrivacyCenterBox } from "@soyio/soyio-widget";
|
|
353
|
-
|
|
354
|
-
// Configuration for the Privacy Center
|
|
355
|
-
const privacyCenterOptions = {
|
|
356
|
-
// Choose ONE of the following authentication modes:
|
|
357
|
-
// 1) Public mode
|
|
358
|
-
companyId: "<company id>", // e.g. com_...
|
|
359
|
-
|
|
360
|
-
// 2) Authenticated mode
|
|
361
|
-
// sessionToken: "<session token>",
|
|
362
|
-
|
|
363
|
-
// Feature flags (optional)
|
|
364
|
-
enabledFeatures: ["DataSubjectRequest", "ConsentManagement"],
|
|
365
|
-
|
|
366
|
-
// Request reference (optional)
|
|
367
|
-
// Will be attached to data subject requests
|
|
368
|
-
requestReference: "<reference>", // e.g. some uuid or id to match our created records with your frontend flows
|
|
369
|
-
|
|
370
|
-
// Limit consent view to specific data subjects (optional)
|
|
371
|
-
dataSubjects: ["customer", "employee"],
|
|
372
|
-
|
|
373
|
-
// Common options
|
|
374
|
-
onEvent: (event) => console.log(event),
|
|
375
|
-
onReady: () => console.log("PrivacyCenterBox is ready"), // Optional
|
|
376
|
-
isSandbox: true, // Optional
|
|
377
|
-
appearance: {}, // Optional
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
// Wait for DOM to be fully loaded
|
|
381
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
382
|
-
const privacyCenter = new PrivacyCenterBox(privacyCenterOptions);
|
|
383
|
-
privacyCenter.mount("#privacy-center-box");
|
|
384
|
-
});
|
|
385
|
-
</script>
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
### Attribute Descriptions
|
|
389
|
-
|
|
390
|
-
- `sessionToken`: Use this to authenticate a session directly.
|
|
391
|
-
- `companyId`: The company identifier. Must start with `com_`. Use this when Privacy Center is mounted in a non authenticated environment.
|
|
392
|
-
- `enabledFeatures`: Optional array of features to show. Supported values: `"DataSubjectRequest"`, `"ConsentManagement"`.
|
|
393
|
-
- `requestReference`: Optional string, intended to be a reference of the current session. It will be attached to created data subject requests.
|
|
394
|
-
- `dataSubjects`: Optional array of data subject categories. When present, the consent management view only shows consent for the specified categories. Supported values include: `"anonymous_user"`, `"citizen_voter"`, `"commuter"`, `"consultant"`, `"customer"`, `"employee"`, `"job_applicant"`, `"next_of_kin"`, `"passenger"`, `"patient"`, `"prospect"`, `"shareholder"`, `"supplier_vendor"`, `"trainee"`, `"visitor"`.
|
|
395
|
-
- `isSandbox`: Whether to use the sandbox environment. Defaults to `false`.
|
|
396
|
-
- `appearance`: Customize the iframe appearance. See Appearance section below.
|
|
397
|
-
- `onEvent`: Callback that receives events from the iframe.
|
|
398
|
-
- `onReady`: Optional callback fired when the iframe becomes ready.
|
|
399
|
-
|
|
400
|
-
Note:
|
|
401
|
-
- When `sessionToken` is provided, do not pass `companyId`.
|
|
402
|
-
|
|
403
|
-
### Privacy Center Events
|
|
404
|
-
|
|
405
|
-
- **`REQUEST_SUBMITTED`**: This event occurs when a user successfully submits a Data Subject Request. The event object includes:
|
|
406
|
-
- `eventName`: The name of the event, in this case, `'REQUEST_SUBMITTED'`.
|
|
407
|
-
- `kind`: The kind of the Data Subject Request submitted. Supported values are: `access`, `opposition`, `rectification`, `suppression` and `portability`
|
|
408
|
-
|
|
409
|
-
# Appearance
|
|
448
|
+
## Appearance
|
|
410
449
|
|
|
411
450
|
Customize the look and feel of Soyio UI components by passing an `appearance` object to the configuration. The appearance object supports themes, CSS variables, and CSS rules for granular control over the styling.
|
|
412
451
|
|
|
413
|
-
|
|
452
|
+
### Structure
|
|
414
453
|
|
|
415
454
|
The appearance object consists of three main sections:
|
|
416
455
|
|
|
@@ -422,61 +461,163 @@ const appearance = {
|
|
|
422
461
|
};
|
|
423
462
|
```
|
|
424
463
|
|
|
425
|
-
|
|
464
|
+
### Themes
|
|
426
465
|
|
|
427
466
|
Currently supported themes:
|
|
428
467
|
|
|
429
468
|
- `"soyio"` (default) - The standard Soyio theme
|
|
430
469
|
|
|
431
|
-
|
|
470
|
+
### Variables
|
|
432
471
|
|
|
433
472
|
Use variables to adjust common visual attributes across all components.
|
|
434
473
|
|
|
435
474
|
```javascript
|
|
436
475
|
interface Variables {
|
|
437
476
|
fontFamily?: string;
|
|
477
|
+
fontSizeBase?: string;
|
|
438
478
|
colorPrimary?: string;
|
|
479
|
+
colorSecondary?: string;
|
|
439
480
|
colorBackground?: string;
|
|
440
481
|
colorText?: string;
|
|
482
|
+
colorTextSecondary?: string;
|
|
483
|
+
colorTextSubtle?: string;
|
|
484
|
+
colorTextInverted?: string;
|
|
485
|
+
colorPrimarySurface?: string;
|
|
486
|
+
colorSurface?: string;
|
|
487
|
+
colorSurfaceMuted?: string;
|
|
488
|
+
colorSurfaceStrong?: string;
|
|
489
|
+
colorBorder?: string;
|
|
490
|
+
colorBorderMuted?: string;
|
|
491
|
+
colorSwitchBorder?: string;
|
|
492
|
+
colorInfo?: string;
|
|
493
|
+
colorInfoBg?: string;
|
|
494
|
+
colorSuccess?: string;
|
|
495
|
+
colorSuccessBg?: string;
|
|
496
|
+
colorWarning?: string;
|
|
497
|
+
colorWarningBg?: string;
|
|
498
|
+
colorDanger?: string;
|
|
499
|
+
colorDangerBg?: string;
|
|
500
|
+
colorOverlay?: string;
|
|
441
501
|
borderRadius?: string;
|
|
442
502
|
borderWidth?: string;
|
|
443
503
|
borderStyle?: string;
|
|
444
504
|
}
|
|
445
505
|
```
|
|
446
506
|
|
|
447
|
-
|
|
507
|
+
#### Available Variables
|
|
448
508
|
|
|
449
509
|
| Variable | Description | Default |
|
|
450
510
|
| ----------------- | ---------------------------------------- | ------------------------- |
|
|
451
|
-
| `fontFamily`
|
|
452
|
-
| `colorPrimary`
|
|
453
|
-
| `
|
|
454
|
-
| `
|
|
455
|
-
| `
|
|
456
|
-
| `
|
|
457
|
-
| `
|
|
458
|
-
| `
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
511
|
+
| `fontFamily` | The font stack to use for text | `"system-ui, sans-serif"` |
|
|
512
|
+
| `colorPrimary` | Primary color for interactive elements | `"#0570DE"` |
|
|
513
|
+
| `colorPrimarySurface` | Background color for primary elements (e.g. active tab) | `"#EEF2FF"` |
|
|
514
|
+
| `colorSecondary` | Secondary color for interactive elements | `"#A180F0"` |
|
|
515
|
+
| `colorBackground` | Background color | `"#FFFFFF"` |
|
|
516
|
+
| `colorSurface` | Surface color for cards and sections | `"#F9FAFB"` |
|
|
517
|
+
| `colorSurfaceMuted` | Muted surface color | `"#F3F4F6"` |
|
|
518
|
+
| `colorSurfaceStrong` | Strong surface color | `"#E5E7EB"` |
|
|
519
|
+
| `colorBorder` | Border color | `"#D1D5DB"` |
|
|
520
|
+
| `colorBorderMuted` | Muted border color | `"#E5E7EB"` |
|
|
521
|
+
| `colorSwitchBorder` | Border color for Switch component (unchecked) | `"#000000"` |
|
|
522
|
+
| `colorText` | Main text color | `"#1E1B4B"` |
|
|
523
|
+
| `colorTextSecondary` | Secondary text color | `"#6B7280"` |
|
|
524
|
+
| `colorTextSubtle` | Subtle text color | `"#9CA3AF"` |
|
|
525
|
+
| `colorTextInverted` | Inverted text color | `"#FFFFFF"` |
|
|
526
|
+
| `colorInfo` | Info status color | `"#1E40AF"` |
|
|
527
|
+
| `colorInfoBg` | Info status background color | `"#E0E7FF"` |
|
|
528
|
+
| `colorSuccess` | Success status color | `"#15803D"` |
|
|
529
|
+
| `colorSuccessBg` | Success status background color | `"#DCFCE7"` |
|
|
530
|
+
| `colorWarning` | Warning status color | `"#B45309"` |
|
|
531
|
+
| `colorWarningBg` | Warning status background color | `"#FEF3C7"` |
|
|
532
|
+
| `colorDanger` | Danger status color | `"#EF4444"` |
|
|
533
|
+
| `colorDangerBg` | Danger status background color | `"#FEF2F2"` |
|
|
534
|
+
| `colorOverlay` | Overlay color | `"rgba(0, 0, 0, 0.5)"` |
|
|
535
|
+
| `borderRadius` | Base border radius (scales proportionally for different sizes) | `"0.25rem"` |
|
|
536
|
+
| `borderWidth` | Border width for elements | `"1px"` |
|
|
537
|
+
| `borderStyle` | Border style for elements | `"solid"` |
|
|
538
|
+
|
|
539
|
+
> **Note on Border Radius:** The `borderRadius` variable serves as a base unit. Larger components (like Inputs and Buttons) use a multiple of this value (typically 2x), while smaller elements use a fraction or the base value itself. This ensures consistent scaling across all UI elements.
|
|
540
|
+
|
|
541
|
+
### Rules
|
|
542
|
+
|
|
543
|
+
The `rules` object allows you to apply custom CSS to specific elements. Soyio supports styling for various components including inputs, buttons, switches, and more.
|
|
544
|
+
|
|
545
|
+
#### Supported rules
|
|
546
|
+
|
|
547
|
+
The rules are grouped by component category:
|
|
548
|
+
|
|
549
|
+
##### Layout
|
|
550
|
+
- `.MainContainer` - The main container.
|
|
551
|
+
- `.Card` - Card containers.
|
|
552
|
+
- `.Dialog` - Dialog containers.
|
|
553
|
+
- `.DialogOverlay` - Dialog overlays.
|
|
554
|
+
- `.DialogContent` - Dialog content areas.
|
|
555
|
+
|
|
556
|
+
##### Typography
|
|
557
|
+
- `.Title` - Title text.
|
|
558
|
+
- `.Description` - Description text.
|
|
559
|
+
|
|
560
|
+
##### Inputs
|
|
561
|
+
- `.Input` - Input fields.
|
|
562
|
+
- `.Label` - Labels.
|
|
563
|
+
- `.TextArea` - Text area inputs.
|
|
564
|
+
- `.Select` - Select dropdowns.
|
|
565
|
+
- `.Combobox` - Combobox inputs.
|
|
566
|
+
- `.NinInput` - Styles the input field for national identity numbers.
|
|
567
|
+
|
|
568
|
+
##### Buttons & Links
|
|
467
569
|
- `.Button` - The button component.
|
|
468
|
-
- `.
|
|
469
|
-
- `.CheckboxInput` - The checkbox input element.
|
|
470
|
-
- `.CheckboxLabel` - The checkbox label.
|
|
570
|
+
- `.Link` - Links.
|
|
471
571
|
|
|
472
|
-
|
|
572
|
+
##### Selection Controls
|
|
473
573
|
|
|
474
|
-
|
|
574
|
+
**Checkbox**
|
|
575
|
+

|
|
475
576
|
|
|
577
|
+
- `.Checkbox` - The checkbox container.
|
|
578
|
+
- `.CheckboxInput` - The styled checkbox element (supports `borderRadius`, `borderColor`, `backgroundColor`).
|
|
579
|
+
- `.CheckboxLabel` - The checkbox label.
|
|
580
|
+
- `.CheckboxCheck` - The checkmark icon inside the checkbox.
|
|
476
581
|
- `.CheckboxInput--checked` - The checked state of the checkbox
|
|
582
|
+
- `.CheckboxInput--focus` - Focus state of the checkbox (visible focus ring)
|
|
477
583
|
- `.CheckboxInput:hover` - Hover state of the checkbox
|
|
478
|
-
|
|
479
|
-
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
**Radio**
|
|
587
|
+
- `.Radio` - Radio button containers.
|
|
588
|
+
- `.RadioLabel` - Radio button labels.
|
|
589
|
+
|
|
590
|
+
**Switch**
|
|
591
|
+
- `.Switch` - Switch toggles (wrapper).
|
|
592
|
+
- `.SwitchRoot` - Switch control (track).
|
|
593
|
+
- `.SwitchThumb` - Switch thumb (circle).
|
|
594
|
+
- `.SwitchIcon` - Switch icons (check/cross).
|
|
595
|
+
- `.SwitchRoot--checked` - Checked state of the switch track
|
|
596
|
+
- `.SwitchThumb--checked` - Checked state of the switch thumb
|
|
597
|
+
|
|
598
|
+
**Radio Card**
|
|
599
|
+
- `.RadioCard` - Styles the wrapper card element of a radio card item.
|
|
600
|
+
- `.RadioCardIndicator` - Styles the container of the radio indicator (circle) inside a radio card.
|
|
601
|
+
- `.RadioCardIndicatorPoint` - Styles the inner point of the radio indicator inside a radio card.
|
|
602
|
+
|
|
603
|
+
##### Feedback
|
|
604
|
+
- `.Loader` - Loading indicators.
|
|
605
|
+
- `.ErrorMessage` - Error message text.
|
|
606
|
+
- `.TooltipContent` - Styles the content popover of a tooltip.
|
|
607
|
+
|
|
608
|
+
**Alert**
|
|
609
|
+
- `.Alert` - Alert boxes.
|
|
610
|
+
- `.Alert--error` - Error alert variant.
|
|
611
|
+
- `.Alert--warning` - Warning alert variant.
|
|
612
|
+
- `.Alert--information` - Information alert variant.
|
|
613
|
+
- `.Alert--success` - Success alert variant.
|
|
614
|
+
|
|
615
|
+
**Chip**
|
|
616
|
+
- `.Chip` - Chips/Tags.
|
|
617
|
+
- `.Chip--info` - Info chip variant.
|
|
618
|
+
- `.Chip--green` - Green chip variant.
|
|
619
|
+
- `.Chip--red` - Red chip variant.
|
|
620
|
+
- `.Chip--amber` - Amber chip variant.
|
|
480
621
|
|
|
481
622
|
### Example Configuration
|
|
482
623
|
|
|
@@ -526,6 +667,22 @@ const appearance = {
|
|
|
526
667
|
outline: "none",
|
|
527
668
|
boxShadow: "0 0 0 2px var(--colorPrimary)",
|
|
528
669
|
},
|
|
670
|
+
".SwitchRoot": {
|
|
671
|
+
backgroundColor: "#e5e7eb",
|
|
672
|
+
borderRadius: "9999px",
|
|
673
|
+
boxShadow: "none", // Remove default shadow
|
|
674
|
+
},
|
|
675
|
+
".SwitchRoot--checked": {
|
|
676
|
+
backgroundColor: "var(--colorPrimary)",
|
|
677
|
+
},
|
|
678
|
+
".SwitchThumb": {
|
|
679
|
+
backgroundColor: "white",
|
|
680
|
+
borderRadius: "9999px",
|
|
681
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
|
|
682
|
+
},
|
|
683
|
+
".SwitchIcon": {
|
|
684
|
+
display: "none", // Hide the check/cross icons
|
|
685
|
+
},
|
|
529
686
|
},
|
|
530
687
|
};
|
|
531
688
|
```
|
|
@@ -640,7 +797,7 @@ export default function PrivacyCenterContainer() {
|
|
|
640
797
|
|
|
641
798
|
return (
|
|
642
799
|
<div>
|
|
643
|
-
{isClient &&
|
|
800
|
+
{isClient &&
|
|
644
801
|
<React.Suspense fallback={
|
|
645
802
|
<div>
|
|
646
803
|
Loading...
|
|
@@ -653,3 +810,20 @@ export default function PrivacyCenterContainer() {
|
|
|
653
810
|
)
|
|
654
811
|
}
|
|
655
812
|
```
|
|
813
|
+
|
|
814
|
+
## Development
|
|
815
|
+
|
|
816
|
+
To run the widget customization smoke test locally:
|
|
817
|
+
|
|
818
|
+
```sh
|
|
819
|
+
yarn run smoke
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
The smoke test configuration is loaded from `smoke-test/.env.development`. You can modify this file to change the default values:
|
|
823
|
+
|
|
824
|
+
```bash
|
|
825
|
+
VITE_COMPANY_ID=com_test
|
|
826
|
+
VITE_PRIVACY_CENTER_URL=http://localhost:5173
|
|
827
|
+
VITE_CONSENT_URL=http://localhost:5173
|
|
828
|
+
VITE_CONSENT_TEMPLATE_ID=constpl_test
|
|
829
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -258,9 +258,27 @@ declare interface SoyioAppearanceVariables {
|
|
|
258
258
|
colorBackground?: string;
|
|
259
259
|
colorText?: string;
|
|
260
260
|
colorTextSecondary?: string;
|
|
261
|
+
colorTextSubtle?: string;
|
|
262
|
+
colorTextInverted?: string;
|
|
263
|
+
colorPrimarySurface?: string;
|
|
264
|
+
colorSurface?: string;
|
|
265
|
+
colorSurfaceMuted?: string;
|
|
266
|
+
colorSurfaceStrong?: string;
|
|
267
|
+
colorBorder?: string;
|
|
268
|
+
colorBorderMuted?: string;
|
|
269
|
+
colorSwitchBorder?: string;
|
|
270
|
+
colorInfo?: string;
|
|
271
|
+
colorInfoBg?: string;
|
|
272
|
+
colorSuccess?: string;
|
|
273
|
+
colorSuccessBg?: string;
|
|
274
|
+
colorWarning?: string;
|
|
275
|
+
colorWarningBg?: string;
|
|
276
|
+
colorDanger?: string;
|
|
277
|
+
colorDangerBg?: string;
|
|
278
|
+
colorOverlay?: string;
|
|
261
279
|
}
|
|
262
280
|
|
|
263
|
-
declare type SoyioBaseRule = '.MainContainer' | '.Button' | '.Checkbox' | '.CheckboxInput' | '.CheckboxLabel';
|
|
281
|
+
declare type SoyioBaseRule = '.MainContainer' | '.Button' | '.Checkbox' | '.CheckboxInput' | '.CheckboxLabel' | '.Input' | '.Label' | '.Title' | '.Link' | '.Card' | '.Select' | '.Loader' | '.TextArea' | '.ErrorMessage' | '.Description' | '.Switch' | '.SwitchRoot' | '.SwitchThumb' | '.SwitchIcon' | '.Alert' | '.Alert--error' | '.Alert--warning' | '.Alert--information' | '.Alert--success' | '.Radio' | '.RadioLabel' | '.Chip' | '.Chip--info' | '.Chip--green' | '.Chip--red' | '.Chip--amber' | '.Dialog' | '.DialogOverlay' | '.DialogContent' | '.Combobox' | '.NinInput' | '.RadioCard' | '.RadioCardIndicator' | '.RadioCardIndicatorPoint' | '.TooltipContent';
|
|
264
282
|
|
|
265
283
|
declare type SoyioElementState = '--checked';
|
|
266
284
|
|