@soyio/soyio-widget 2.18.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 +85 -0
- package/dist/index.d.ts +31 -2
- package/dist/index.js +1585 -1538
- 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
|
|
|
@@ -523,6 +524,7 @@ interface Config {
|
|
|
523
524
|
};
|
|
524
525
|
iconRules?: Record<string, { weight?: IconWeight; size?: number }>;
|
|
525
526
|
mainPageColumns?: 1 | 2 | 3 | 4;
|
|
527
|
+
brandTheme?: 'default' | 'dark' | 'light';
|
|
526
528
|
}
|
|
527
529
|
```
|
|
528
530
|
|
|
@@ -534,6 +536,7 @@ interface Config {
|
|
|
534
536
|
| `icon.size` | Global default icon size in pixels | `24` |
|
|
535
537
|
| `iconRules` | Per-component icon style overrides | `{}` |
|
|
536
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"` |
|
|
537
540
|
|
|
538
541
|
#### Icons
|
|
539
542
|
|
|
@@ -828,6 +831,15 @@ The step indicator shows progress through multi-step forms.
|
|
|
828
831
|
- `.Chip--red` - Red chip variant.
|
|
829
832
|
- `.Chip--amber` - Amber chip variant.
|
|
830
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
|
+
|
|
831
843
|
### Example Configuration
|
|
832
844
|
|
|
833
845
|
```javascript
|
|
@@ -909,6 +921,79 @@ To use the `SoyioTypes` in your project, import it directly from the `@soyio/soy
|
|
|
909
921
|
import type { SoyioTypes } from "@soyio/soyio-widget";
|
|
910
922
|
```
|
|
911
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
|
+
|
|
912
997
|
## Server Side Rendering (SSR)
|
|
913
998
|
|
|
914
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;
|
|
@@ -244,6 +258,7 @@ declare type PrivacyCenterConfig = BaseConfig & {
|
|
|
244
258
|
enabledRights?: PrivacyCenterRight[];
|
|
245
259
|
dataSubjects?: DataSubject[];
|
|
246
260
|
requestReference?: string;
|
|
261
|
+
demo?: boolean;
|
|
247
262
|
fileRequisites?: {
|
|
248
263
|
allowedExtensions?: string[];
|
|
249
264
|
maxFileSize?: number;
|
|
@@ -277,7 +292,7 @@ declare type SignatureRequestConfig = {
|
|
|
277
292
|
developmentUrl?: string;
|
|
278
293
|
};
|
|
279
294
|
|
|
280
|
-
declare type SkeletonConstructor = new (id: string) => ISkeletonView;
|
|
295
|
+
declare type SkeletonConstructor = new (id: string, theme?: SoyioTheme) => ISkeletonView;
|
|
281
296
|
|
|
282
297
|
declare interface SoyioAppearance {
|
|
283
298
|
theme?: SoyioTheme;
|
|
@@ -318,6 +333,14 @@ declare interface SoyioAppearanceConfig {
|
|
|
318
333
|
* @default 2
|
|
319
334
|
*/
|
|
320
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';
|
|
321
344
|
}
|
|
322
345
|
|
|
323
346
|
declare interface SoyioAppearanceVariables {
|
|
@@ -356,6 +379,7 @@ declare interface SoyioAppearanceVariables {
|
|
|
356
379
|
colorDanger?: string;
|
|
357
380
|
colorDangerBg?: string;
|
|
358
381
|
colorOverlay?: string;
|
|
382
|
+
dataUseIconColor?: string;
|
|
359
383
|
}
|
|
360
384
|
|
|
361
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';
|
|
@@ -379,6 +403,11 @@ declare interface SoyioIconConfig {
|
|
|
379
403
|
* @default 24
|
|
380
404
|
*/
|
|
381
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';
|
|
382
411
|
}
|
|
383
412
|
|
|
384
413
|
declare type SoyioPseudoClass = ':hover' | ':focus' | ':active' | ':disabled' | ':autofill' | ':focus-visible';
|