@soyio/soyio-widget 2.17.0 → 2.19.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 +90 -0
- package/dist/index.d.ts +34 -2
- package/dist/index.js +1576 -1529
- package/dist/index.umd.cjs +61 -50
- package/package.json +9 -4
- package/src/schemas/appearance.schema.json +2189 -0
- package/src/schemas/config.schema.json +2473 -0
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- [Auth Request](#auth-request)
|
|
25
25
|
- [Appearance](#appearance)
|
|
26
26
|
- [TypeScript](#typescript)
|
|
27
|
+
- [JSON Schema Validation](#json-schema-validation)
|
|
27
28
|
- [Server Side Rendering (SSR)](#server-side-rendering-ssr)
|
|
28
29
|
|
|
29
30
|
|
|
@@ -164,6 +165,10 @@ The `PrivacyCenterBox` lets you embed the Privacy Center inside your page. You c
|
|
|
164
165
|
// Feature flags (optional)
|
|
165
166
|
enabledFeatures: ["DataSubjectRequest", "ConsentManagement"],
|
|
166
167
|
|
|
168
|
+
// DSR rights to show (optional)
|
|
169
|
+
// When omitted, the DSR form will use arsop right as default
|
|
170
|
+
enabledRights: ["arsop"],
|
|
171
|
+
|
|
167
172
|
// Request reference (optional)
|
|
168
173
|
// Will be attached to data subject requests
|
|
169
174
|
requestReference: "<reference>", // e.g. some uuid or id to match our created records with your frontend flows
|
|
@@ -197,6 +202,7 @@ The `PrivacyCenterBox` lets you embed the Privacy Center inside your page. You c
|
|
|
197
202
|
- `sessionToken`: Use this to authenticate a session directly.
|
|
198
203
|
- `companyId`: The company identifier. Must start with `com_`. Use this when Privacy Center is mounted in a non authenticated environment.
|
|
199
204
|
- `enabledFeatures`: Optional array of features to show. Supported values: `"DataSubjectRequest"`, `"ConsentManagement"`.
|
|
205
|
+
- `enabledRights`: Optional array of rights for the Data Subject Request (DSR) form. Supported values: `"arsop"`, `"redec"`. When multiple values are provided, the form starts with a right selection step. When a single value is provided, the selection step is skipped. When omitted, the form defaults to arsop rights.
|
|
200
206
|
- `requestReference`: Optional string, intended to be a reference of the current session. It will be attached to created data subject requests.
|
|
201
207
|
- `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"`.
|
|
202
208
|
- `fileRequisites`: Optional object to configure file upload constraints.
|
|
@@ -518,6 +524,7 @@ interface Config {
|
|
|
518
524
|
};
|
|
519
525
|
iconRules?: Record<string, { weight?: IconWeight; size?: number }>;
|
|
520
526
|
mainPageColumns?: 1 | 2 | 3 | 4;
|
|
527
|
+
brandTheme?: 'default' | 'dark' | 'light';
|
|
521
528
|
}
|
|
522
529
|
```
|
|
523
530
|
|
|
@@ -529,6 +536,7 @@ interface Config {
|
|
|
529
536
|
| `icon.size` | Global default icon size in pixels | `24` |
|
|
530
537
|
| `iconRules` | Per-component icon style overrides | `{}` |
|
|
531
538
|
| `mainPageColumns` | Number of columns in the main page feature cards grid (1-4) | `2` |
|
|
539
|
+
| `brandTheme` | Theme variant for branded elements like the footer (`default`, `dark`, `light`) | `"default"` |
|
|
532
540
|
|
|
533
541
|
#### Icons
|
|
534
542
|
|
|
@@ -823,6 +831,15 @@ The step indicator shows progress through multi-step forms.
|
|
|
823
831
|
- `.Chip--red` - Red chip variant.
|
|
824
832
|
- `.Chip--amber` - Amber chip variant.
|
|
825
833
|
|
|
834
|
+
##### Consent Components
|
|
835
|
+
|
|
836
|
+
The following rules are specific to the **Consent Box** widget and allow customization of consent-related UI elements:
|
|
837
|
+
|
|
838
|
+
- `.CategoryTag` - Data use category identifier (e.g., "Compartir datos con terceros"). Appears above category descriptions in expanded consent views.
|
|
839
|
+
- `.Badge` - Optional/required label badge appearing on consent items.
|
|
840
|
+
|
|
841
|
+
> **Note:** These consent-specific rules are only available in the `ConsentBox` widget and will have no effect in other widgets like `PrivacyCenterBox`.
|
|
842
|
+
|
|
826
843
|
### Example Configuration
|
|
827
844
|
|
|
828
845
|
```javascript
|
|
@@ -904,6 +921,79 @@ To use the `SoyioTypes` in your project, import it directly from the `@soyio/soy
|
|
|
904
921
|
import type { SoyioTypes } from "@soyio/soyio-widget";
|
|
905
922
|
```
|
|
906
923
|
|
|
924
|
+
## JSON Schema Validation
|
|
925
|
+
|
|
926
|
+
The package includes JSON Schemas for validating configuration objects. This is useful for:
|
|
927
|
+
- **IDE Autocomplete**: Get IntelliSense in your editor when writing configurations
|
|
928
|
+
- **Runtime Validation**: Validate user-provided configurations before passing to the widget
|
|
929
|
+
- **Documentation**: Use schemas to generate API documentation
|
|
930
|
+
|
|
931
|
+
### Available Schemas
|
|
932
|
+
|
|
933
|
+
#### Appearance Schema
|
|
934
|
+
Validates appearance customization objects (theme, variables, rules, config):
|
|
935
|
+
|
|
936
|
+
```javascript
|
|
937
|
+
// Import the schema
|
|
938
|
+
import appearanceSchema from "@soyio/soyio-widget/schemas/appearance";
|
|
939
|
+
|
|
940
|
+
// Use with a validator like Ajv
|
|
941
|
+
import Ajv from "ajv";
|
|
942
|
+
const ajv = new Ajv();
|
|
943
|
+
const validate = ajv.compile(appearanceSchema);
|
|
944
|
+
|
|
945
|
+
const appearance = {
|
|
946
|
+
theme: "night",
|
|
947
|
+
variables: {
|
|
948
|
+
colorPrimary: "#007bff",
|
|
949
|
+
borderRadius: "8px"
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
if (validate(appearance)) {
|
|
954
|
+
console.log("✅ Valid appearance config");
|
|
955
|
+
} else {
|
|
956
|
+
console.error("❌ Invalid:", validate.errors);
|
|
957
|
+
}
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
#### Config Schema
|
|
961
|
+
Validates complete widget configuration including Privacy Center and Consent Box options:
|
|
962
|
+
|
|
963
|
+
```javascript
|
|
964
|
+
import configSchema from "@soyio/soyio-widget/schemas/config";
|
|
965
|
+
|
|
966
|
+
const validate = ajv.compile(configSchema);
|
|
967
|
+
const config = {
|
|
968
|
+
companyId: "com_example",
|
|
969
|
+
appearance: { /* ... */ },
|
|
970
|
+
onEvent: (event) => console.log(event)
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
if (validate(config)) {
|
|
974
|
+
const privacyCenter = new PrivacyCenterBox(config);
|
|
975
|
+
privacyCenter.mount("#container");
|
|
976
|
+
}
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
### Using Schemas with Monaco Editor
|
|
980
|
+
|
|
981
|
+
Perfect for building configuration editors:
|
|
982
|
+
|
|
983
|
+
```javascript
|
|
984
|
+
import * as monaco from "monaco-editor";
|
|
985
|
+
import configSchema from "@soyio/soyio-widget/schemas/config";
|
|
986
|
+
|
|
987
|
+
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
988
|
+
validate: true,
|
|
989
|
+
schemas: [{
|
|
990
|
+
uri: "https://soyio.id/widget-config.json",
|
|
991
|
+
fileMatch: ["*"],
|
|
992
|
+
schema: configSchema
|
|
993
|
+
}]
|
|
994
|
+
});
|
|
995
|
+
```
|
|
996
|
+
|
|
907
997
|
## Server Side Rendering (SSR)
|
|
908
998
|
|
|
909
999
|
This package is not directly compatible with SSR because of `post-robot`, but there are workarounds that allow you to use it without disrupting the build process. Below are examples on popular SSR frameworks.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { default as appearanceSchema } from './schemas/appearance.schema.json';
|
|
2
|
+
import { default as configSchema } from './schemas/config.schema.json';
|
|
3
|
+
|
|
4
|
+
export { appearanceSchema }
|
|
5
|
+
|
|
1
6
|
declare type AuthRequestConfig = {
|
|
2
7
|
request: 'authentication_request';
|
|
3
8
|
configProps: AuthRequestProps;
|
|
@@ -21,12 +26,14 @@ declare type BaseConfig = {
|
|
|
21
26
|
|
|
22
27
|
declare abstract class BaseIframeBox<T extends BaseConfig> {
|
|
23
28
|
protected iframe: HTMLIFrameElement | null;
|
|
29
|
+
protected wrapper: HTMLDivElement | null;
|
|
24
30
|
protected skeleton: ISkeletonView | null;
|
|
25
31
|
protected readonly options: T;
|
|
26
|
-
protected
|
|
32
|
+
protected appearance: SoyioAppearance | null;
|
|
27
33
|
protected readonly tooltipManager: _TooltipManager;
|
|
28
34
|
readonly defaultIframeCSSConfig: IframeCSSConfig;
|
|
29
35
|
protected Skeleton: SkeletonConstructor | null;
|
|
36
|
+
private isIframeReady;
|
|
30
37
|
private readonly defaultUniqueId;
|
|
31
38
|
abstract readonly defaultIframePrefix: string;
|
|
32
39
|
constructor(options: T);
|
|
@@ -40,10 +47,17 @@ declare abstract class BaseIframeBox<T extends BaseConfig> {
|
|
|
40
47
|
protected setupListeners(): Promise<void>;
|
|
41
48
|
mount(selector: string): Promise<this>;
|
|
42
49
|
unmount(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Update the appearance of the widget without remounting.
|
|
52
|
+
* This sends the new appearance config to the already-mounted iframe.
|
|
53
|
+
*/
|
|
54
|
+
updateAppearance(appearance: SoyioAppearance): Promise<void>;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
declare const CLOSED_EVENT = "WIDGET_CLOSED";
|
|
46
58
|
|
|
59
|
+
export { configSchema }
|
|
60
|
+
|
|
47
61
|
export declare class ConsentBox extends BaseIframeBox<ConsentConfig> {
|
|
48
62
|
readonly defaultIframePrefix = "consent-box";
|
|
49
63
|
readonly defaultIframeCSSConfig: IframeCSSConfig;
|
|
@@ -241,8 +255,10 @@ export declare class PrivacyCenterBox extends BaseIframeBox<PrivacyCenterConfig>
|
|
|
241
255
|
|
|
242
256
|
declare type PrivacyCenterConfig = BaseConfig & {
|
|
243
257
|
enabledFeatures?: PrivacyManagerFeature[];
|
|
258
|
+
enabledRights?: PrivacyCenterRight[];
|
|
244
259
|
dataSubjects?: DataSubject[];
|
|
245
260
|
requestReference?: string;
|
|
261
|
+
demo?: boolean;
|
|
246
262
|
fileRequisites?: {
|
|
247
263
|
allowedExtensions?: string[];
|
|
248
264
|
maxFileSize?: number;
|
|
@@ -255,6 +271,8 @@ declare type PrivacyCenterConfig = BaseConfig & {
|
|
|
255
271
|
companyId?: never;
|
|
256
272
|
});
|
|
257
273
|
|
|
274
|
+
declare type PrivacyCenterRight = 'arsop' | 'redec';
|
|
275
|
+
|
|
258
276
|
declare type PrivacyManagerFeature = 'DataSubjectRequest' | 'ConsentManagement' | 'RequestTracking';
|
|
259
277
|
|
|
260
278
|
declare type Request_2 = 'disclosure' | 'signature' | 'authentication';
|
|
@@ -274,7 +292,7 @@ declare type SignatureRequestConfig = {
|
|
|
274
292
|
developmentUrl?: string;
|
|
275
293
|
};
|
|
276
294
|
|
|
277
|
-
declare type SkeletonConstructor = new (id: string) => ISkeletonView;
|
|
295
|
+
declare type SkeletonConstructor = new (id: string, theme?: SoyioTheme) => ISkeletonView;
|
|
278
296
|
|
|
279
297
|
declare interface SoyioAppearance {
|
|
280
298
|
theme?: SoyioTheme;
|
|
@@ -315,6 +333,14 @@ declare interface SoyioAppearanceConfig {
|
|
|
315
333
|
* @default 2
|
|
316
334
|
*/
|
|
317
335
|
mainPageColumns?: 1 | 2 | 3 | 4;
|
|
336
|
+
/**
|
|
337
|
+
* Theme variant for branded elements like the footer.
|
|
338
|
+
* - 'default': Standard Soyio brand colors (purple/indigo)
|
|
339
|
+
* - 'dark': Dark mode with gray tones
|
|
340
|
+
* - 'light': Mono color light version
|
|
341
|
+
* @default 'default'
|
|
342
|
+
*/
|
|
343
|
+
brandTheme?: 'default' | 'dark' | 'light';
|
|
318
344
|
}
|
|
319
345
|
|
|
320
346
|
declare interface SoyioAppearanceVariables {
|
|
@@ -353,6 +379,7 @@ declare interface SoyioAppearanceVariables {
|
|
|
353
379
|
colorDanger?: string;
|
|
354
380
|
colorDangerBg?: string;
|
|
355
381
|
colorOverlay?: string;
|
|
382
|
+
dataUseIconColor?: string;
|
|
356
383
|
}
|
|
357
384
|
|
|
358
385
|
declare type SoyioBaseRule = '.MainContainer' | '.Button' | '.Checkbox' | '.CheckboxInput' | '.CheckboxLabel' | '.Input' | '.Label' | '.HintIcon' | '.Title' | '.StepTitle' | '.Link' | '.Card' | '.CardTitle' | '.Select' | '.Loader' | '.TextArea' | '.ErrorMessage' | '.Description' | '.Switch' | '.SwitchRoot' | '.SwitchThumb' | '.SwitchIcon' | '.Alert' | '.AlertIcon' | '.AlertContent' | '.Radio' | '.RadioButton' | '.RadioIndicator' | '.RadioLabel' | '.Chip' | '.Dialog' | '.DialogOverlay' | '.DialogContent' | '.DialogTitle' | '.DialogDescription' | '.Combobox' | '.NinInput' | '.TrackingCodeInput' | '.TrackingCodeInputCell' | '.TrackingCodeInputSeparator' | '.RadioCard' | '.RadioCardButton' | '.RadioCardIndicator' | '.RadioCardTitle' | '.StepIndicatorContainer' | '.StepIndicator' | '.StepIndicatorLine' | '.StepIndicatorIcon' | '.StepIndicatorDot' | '.StepIndicatorNumber' | '.TooltipContent';
|
|
@@ -376,6 +403,11 @@ declare interface SoyioIconConfig {
|
|
|
376
403
|
* @default 24
|
|
377
404
|
*/
|
|
378
405
|
size?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Override variant for data use icons in consent management.
|
|
408
|
+
* If not set, uses the company's configured iconVariant.
|
|
409
|
+
*/
|
|
410
|
+
dataUseVariant?: 'duotone' | 'outline' | 'solid';
|
|
379
411
|
}
|
|
380
412
|
|
|
381
413
|
declare type SoyioPseudoClass = ':hover' | ':focus' | ':active' | ':disabled' | ':autofill' | ':focus-visible';
|