@soyio/soyio-widget 2.18.0 → 2.20.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
@@ -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
 
@@ -181,6 +182,12 @@ The `PrivacyCenterBox` lets you embed the Privacy Center inside your page. You c
181
182
  maxFileSize: 5 * 1024 * 1024, // 5MB
182
183
  },
183
184
 
185
+ // Redec operation options (optional unless "redec" is in enabledRights)
186
+ redecOperationIds: [
187
+ { id: "op_update", label: "Update" },
188
+ { id: "op_rectification", label: "Rectification" },
189
+ ],
190
+
184
191
  // Common options
185
192
  onEvent: (event) => console.log(event),
186
193
  onReady: () => console.log("PrivacyCenterBox is ready"), // Optional
@@ -207,6 +214,7 @@ The `PrivacyCenterBox` lets you embed the Privacy Center inside your page. You c
207
214
  - `fileRequisites`: Optional object to configure file upload constraints.
208
215
  - `allowedExtensions`: Array of allowed file extensions (e.g. `['pdf', 'jpg']`). Default: `['pdf', 'png', 'jpeg', 'jpg']`.
209
216
  - `maxFileSize`: Maximum file size in bytes. Default: `5 * 1024 * 1024` (5MB).
217
+ - `redecOperationIds`: Optional array of `{ id, label }` values for the Redec operation select. Required if `redec` right is included in `enabledRights` param.
210
218
  - `isSandbox`: Whether to use the sandbox environment. Defaults to `false`.
211
219
  - `appearance`: Customize the iframe appearance. See Appearance section below.
212
220
  - `onEvent`: Callback that receives events from the iframe.
@@ -523,6 +531,7 @@ interface Config {
523
531
  };
524
532
  iconRules?: Record<string, { weight?: IconWeight; size?: number }>;
525
533
  mainPageColumns?: 1 | 2 | 3 | 4;
534
+ brandTheme?: 'default' | 'dark' | 'light';
526
535
  }
527
536
  ```
528
537
 
@@ -534,6 +543,7 @@ interface Config {
534
543
  | `icon.size` | Global default icon size in pixels | `24` |
535
544
  | `iconRules` | Per-component icon style overrides | `{}` |
536
545
  | `mainPageColumns` | Number of columns in the main page feature cards grid (1-4) | `2` |
546
+ | `brandTheme` | Theme variant for branded elements like the footer (`default`, `dark`, `light`) | `"default"` |
537
547
 
538
548
  #### Icons
539
549
 
@@ -828,6 +838,15 @@ The step indicator shows progress through multi-step forms.
828
838
  - `.Chip--red` - Red chip variant.
829
839
  - `.Chip--amber` - Amber chip variant.
830
840
 
841
+ ##### Consent Components
842
+
843
+ The following rules are specific to the **Consent Box** widget and allow customization of consent-related UI elements:
844
+
845
+ - `.CategoryTag` - Data use category identifier (e.g., "Compartir datos con terceros"). Appears above category descriptions in expanded consent views.
846
+ - `.Badge` - Optional/required label badge appearing on consent items.
847
+
848
+ > **Note:** These consent-specific rules are only available in the `ConsentBox` widget and will have no effect in other widgets like `PrivacyCenterBox`.
849
+
831
850
  ### Example Configuration
832
851
 
833
852
  ```javascript
@@ -909,6 +928,79 @@ To use the `SoyioTypes` in your project, import it directly from the `@soyio/soy
909
928
  import type { SoyioTypes } from "@soyio/soyio-widget";
910
929
  ```
911
930
 
931
+ ## JSON Schema Validation
932
+
933
+ The package includes JSON Schemas for validating configuration objects. This is useful for:
934
+ - **IDE Autocomplete**: Get IntelliSense in your editor when writing configurations
935
+ - **Runtime Validation**: Validate user-provided configurations before passing to the widget
936
+ - **Documentation**: Use schemas to generate API documentation
937
+
938
+ ### Available Schemas
939
+
940
+ #### Appearance Schema
941
+ Validates appearance customization objects (theme, variables, rules, config):
942
+
943
+ ```javascript
944
+ // Import the schema
945
+ import appearanceSchema from "@soyio/soyio-widget/schemas/appearance";
946
+
947
+ // Use with a validator like Ajv
948
+ import Ajv from "ajv";
949
+ const ajv = new Ajv();
950
+ const validate = ajv.compile(appearanceSchema);
951
+
952
+ const appearance = {
953
+ theme: "night",
954
+ variables: {
955
+ colorPrimary: "#007bff",
956
+ borderRadius: "8px"
957
+ }
958
+ };
959
+
960
+ if (validate(appearance)) {
961
+ console.log("✅ Valid appearance config");
962
+ } else {
963
+ console.error("❌ Invalid:", validate.errors);
964
+ }
965
+ ```
966
+
967
+ #### Config Schema
968
+ Validates complete widget configuration including Privacy Center and Consent Box options:
969
+
970
+ ```javascript
971
+ import configSchema from "@soyio/soyio-widget/schemas/config";
972
+
973
+ const validate = ajv.compile(configSchema);
974
+ const config = {
975
+ companyId: "com_example",
976
+ appearance: { /* ... */ },
977
+ onEvent: (event) => console.log(event)
978
+ };
979
+
980
+ if (validate(config)) {
981
+ const privacyCenter = new PrivacyCenterBox(config);
982
+ privacyCenter.mount("#container");
983
+ }
984
+ ```
985
+
986
+ ### Using Schemas with Monaco Editor
987
+
988
+ Perfect for building configuration editors:
989
+
990
+ ```javascript
991
+ import * as monaco from "monaco-editor";
992
+ import configSchema from "@soyio/soyio-widget/schemas/config";
993
+
994
+ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
995
+ validate: true,
996
+ schemas: [{
997
+ uri: "https://soyio.id/widget-config.json",
998
+ fileMatch: ["*"],
999
+ schema: configSchema
1000
+ }]
1001
+ });
1002
+ ```
1003
+
912
1004
  ## Server Side Rendering (SSR)
913
1005
 
914
1006
  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.
@@ -1040,6 +1132,20 @@ VITE_CONSENT_URL=http://localhost:5173
1040
1132
  VITE_CONSENT_TEMPLATE_ID=constpl_test
1041
1133
  ```
1042
1134
 
1135
+ To test DSR rights in the Privacy Center tab, add these parameters to the JSON config in the editor:
1136
+
1137
+ ```json
1138
+ {
1139
+ "enabledRights": ["arsop", "redec"],
1140
+ "redecOperationIds": [
1141
+ { "id": "op_update", "label": "Update" },
1142
+ { "id": "op_rectification", "label": "Rectification" }
1143
+ ]
1144
+ }
1145
+ ```
1146
+
1147
+ `redecOperationIds` is required when `redec` is included in `enabledRights`.
1148
+
1043
1149
  ### Presets Management
1044
1150
 
1045
1151
  The smoke test includes preset management functionality that allows you to save, load, and share widget configurations:
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 readonly appearance: SoyioAppearance | null;
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;
@@ -236,6 +250,7 @@ export declare class PrivacyCenterBox extends BaseIframeBox<PrivacyCenterConfig>
236
250
  protected readonly _uniqueIdentifier = "privacy-center";
237
251
  readonly defaultIframeCSSConfig: IframeCSSConfig;
238
252
  get uniqueIdentifier(): string;
253
+ protected handleIframeReady(): Promise<void>;
239
254
  iframeUrl(): string;
240
255
  }
241
256
 
@@ -244,10 +259,12 @@ declare type PrivacyCenterConfig = BaseConfig & {
244
259
  enabledRights?: PrivacyCenterRight[];
245
260
  dataSubjects?: DataSubject[];
246
261
  requestReference?: string;
262
+ demo?: boolean;
247
263
  fileRequisites?: {
248
264
  allowedExtensions?: string[];
249
265
  maxFileSize?: number;
250
266
  };
267
+ redecOperationIds?: RedecOperationId[];
251
268
  } & ({
252
269
  companyId: `com_${string}`;
253
270
  sessionToken?: never;
@@ -260,6 +277,11 @@ declare type PrivacyCenterRight = 'arsop' | 'redec';
260
277
 
261
278
  declare type PrivacyManagerFeature = 'DataSubjectRequest' | 'ConsentManagement' | 'RequestTracking';
262
279
 
280
+ declare type RedecOperationId = {
281
+ id: string;
282
+ label: string;
283
+ };
284
+
263
285
  declare type Request_2 = 'disclosure' | 'signature' | 'authentication';
264
286
 
265
287
  declare type RequestConfig = DisclosureRequestConfig | SignatureRequestConfig | AuthRequestConfig;
@@ -277,7 +299,7 @@ declare type SignatureRequestConfig = {
277
299
  developmentUrl?: string;
278
300
  };
279
301
 
280
- declare type SkeletonConstructor = new (id: string) => ISkeletonView;
302
+ declare type SkeletonConstructor = new (id: string, theme?: SoyioTheme) => ISkeletonView;
281
303
 
282
304
  declare interface SoyioAppearance {
283
305
  theme?: SoyioTheme;
@@ -318,6 +340,14 @@ declare interface SoyioAppearanceConfig {
318
340
  * @default 2
319
341
  */
320
342
  mainPageColumns?: 1 | 2 | 3 | 4;
343
+ /**
344
+ * Theme variant for branded elements like the footer.
345
+ * - 'default': Standard Soyio brand colors (purple/indigo)
346
+ * - 'dark': Dark mode with gray tones
347
+ * - 'light': Mono color light version
348
+ * @default 'default'
349
+ */
350
+ brandTheme?: 'default' | 'dark' | 'light';
321
351
  }
322
352
 
323
353
  declare interface SoyioAppearanceVariables {
@@ -356,6 +386,7 @@ declare interface SoyioAppearanceVariables {
356
386
  colorDanger?: string;
357
387
  colorDangerBg?: string;
358
388
  colorOverlay?: string;
389
+ dataUseIconColor?: string;
359
390
  }
360
391
 
361
392
  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';
@@ -379,6 +410,11 @@ declare interface SoyioIconConfig {
379
410
  * @default 24
380
411
  */
381
412
  size?: number;
413
+ /**
414
+ * Override variant for data use icons in consent management.
415
+ * If not set, uses the company's configured iconVariant.
416
+ */
417
+ dataUseVariant?: 'duotone' | 'outline' | 'solid';
382
418
  }
383
419
 
384
420
  declare type SoyioPseudoClass = ':hover' | ':focus' | ':active' | ':disabled' | ':autofill' | ':focus-visible';