@soyio/soyio-widget 2.4.0 → 2.4.2

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
@@ -319,7 +319,7 @@ The `onEvent` follows the following format:
319
319
  {
320
320
  eventName: 'CONSENT_CHECKBOX_CHANGE',
321
321
  isSelected: boolean
322
- token: string,
322
+ actionToken: string,
323
323
  }
324
324
  ```
325
325
 
@@ -327,7 +327,7 @@ The `onEvent` follows the following format:
327
327
 
328
328
  - **`consentTemplateId`**: Identifier of consent template. It must start with `'constpl_'`.
329
329
  - **`isSelected`**: Boolean value indicating whether the consent checkbox is selected or not.
330
- - **`token`**: Unique identifier for the consent. Contains necessary information for creation of the consent request. [Learn more](https://docs.soyio.id/docs/api/resources/create-consent-request).
330
+ - **`actionToken`**: token containing necessary information for creation of the consent commit. [Learn more](https://docs.soyio.id/docs/api/resources/create-consent-request).
331
331
 
332
332
  ## TypeScript
333
333
 
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var R = Object.defineProperty;
2
- var C = (t, e, n) => e in t ? R(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var u = (t, e, n) => (C(t, typeof e != "symbol" ? e + "" : e, n), n), N = (t, e, n) => {
4
- if (!e.has(t))
2
+ var C = (e, t, n) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var u = (e, t, n) => (C(e, typeof t != "symbol" ? t + "" : t, n), n), N = (e, t, n) => {
4
+ if (!t.has(e))
5
5
  throw TypeError("Cannot " + n);
6
6
  };
7
- var w = (t, e, n) => {
8
- if (e.has(t))
7
+ var w = (e, t, n) => {
8
+ if (t.has(e))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
10
+ t instanceof WeakSet ? t.add(e) : t.set(e, n);
11
11
  };
12
- var I = (t, e, n) => (N(t, e, "access private method"), n);
13
- const v = "soyio-consent-iframe", T = "https://app.soyio.id", _ = "https://sandbox.soyio.id", U = [
12
+ var I = (e, t, n) => (N(e, t, "access private method"), n);
13
+ const v = "soyio-consent-iframe", g = "https://app.soyio.id", y = "https://sandbox.soyio.id", U = [
14
14
  "DISCLOSURE_REQUEST_SUCCESSFUL",
15
15
  "IDENTITY_REGISTERED",
16
16
  "IDENTITY_SIGNATURE",
@@ -19,114 +19,118 @@ const v = "soyio-consent-iframe", T = "https://app.soyio.id", _ = "https://sandb
19
19
  "REJECTED_SIGNATURE"
20
20
  ], D = "WIDGET_CLOSED";
21
21
  function H() {
22
- const t = document.getElementById(v);
23
- t && (console.warn("ConsentBox iframe already exists. Removing existing before mounting new one."), t.remove());
24
- }
25
- function O(t) {
26
- const e = document.querySelector(t);
27
- if (!e)
28
- throw new Error(`Iframe div container with id '${t}' not found`);
29
- if (e.tagName.toLowerCase() !== "div")
30
- throw new Error(`Iframe container with id '${t}' must be a <div> element`);
31
- const n = e;
22
+ const e = document.getElementById(v);
23
+ e && (console.warn("ConsentBox iframe already exists. Removing existing before mounting new one."), e.remove());
24
+ }
25
+ function x(e) {
26
+ const t = document.querySelector(e);
27
+ if (!t)
28
+ throw new Error(`Iframe div container with id '${e}' not found`);
29
+ if (t.tagName.toLowerCase() !== "div")
30
+ throw new Error(`Iframe container with id '${e}' must be a <div> element`);
31
+ const n = t;
32
32
  return n.style.position = "relative", n.style.cssText += `
33
33
  padding: 0 !important;
34
34
  margin: 0 !important;
35
- display: block !important;
35
+ display: flex !important;
36
+ justify-content: center !important;
37
+ align-items: center !important;
36
38
  border: none !important;
37
39
  transition: height 0.35s !important;
38
40
  opacity: 1 !important;
39
41
  `, n;
40
42
  }
41
- function L(t) {
42
- const e = document.createElement("iframe");
43
- return e.id = v, e.src = t, e.style.cssText += `
43
+ function O(e) {
44
+ const t = document.createElement("iframe");
45
+ return t.id = v, t.src = e, t.style.cssText += `
44
46
  width: 100% !important;
47
+ min-width: 25rem !important;
48
+ max-width: 36rem !important;
45
49
  border: none !important;
46
- height: 110px !important;
50
+ height: 120px !important;
47
51
  overflow: hidden !important;
48
52
  opacity: 1;
49
53
  transition: height 0.35s,
50
54
  opacity 0.4s 0.1s;
51
- `, e;
55
+ `, t;
52
56
  }
53
- function x(t) {
54
- const e = t.isSandbox ?? !1;
55
- return `${t.developmentUrl || (e ? _ : T)}/embed/consents/${t.consentTemplateId}`;
57
+ function L(e) {
58
+ const t = e.isSandbox ?? !1;
59
+ return `${e.developmentUrl || (t ? y : g)}/embed/consents/${e.consentTemplateId}`;
56
60
  }
57
61
  const A = "IFRAME_EVENT", $ = "IFRAME_HEIGHT_CHANGE";
58
62
  let a = null, l = null;
59
- function g() {
63
+ function T() {
60
64
  a == null || a.cancel(), a = null, l == null || l.cancel(), l = null;
61
65
  }
62
- async function G(t) {
63
- const { onEvent: e, onHeightChange: n } = t, o = await import("./index-yZw-yxuV.js").then((i) => i.i);
64
- g(), a = o.on(A, async (i) => {
66
+ async function G(e) {
67
+ const { onEvent: t, onHeightChange: n } = e, o = await import("./index-yZw-yxuV.js").then((i) => i.i);
68
+ T(), a = o.on(A, async (i) => {
65
69
  const s = i.data;
66
- e(s);
70
+ t(s);
67
71
  }), l = o.on($, async (i) => {
68
72
  const s = i.data;
69
73
  n(s.height);
70
74
  });
71
75
  }
72
76
  class z {
73
- constructor(e) {
77
+ constructor(t) {
74
78
  u(this, "options");
75
79
  u(this, "iframe", null);
76
- this.options = e, G({
80
+ this.options = t, G({
77
81
  onEvent: this.options.onEvent.bind(this),
78
82
  onHeightChange: this.handleHeightChange.bind(this)
79
83
  });
80
84
  }
81
- handleHeightChange(e) {
82
- this.iframe && (this.iframe.style.height = `${e}px`);
85
+ handleHeightChange(t) {
86
+ this.iframe && (this.iframe.style.height = `${t}px`);
83
87
  }
84
- mount(e) {
88
+ mount(t) {
85
89
  H();
86
- const n = O(e), o = x(this.options);
87
- return this.iframe = L(o), n.appendChild(this.iframe), this;
90
+ const n = x(t), o = L(this.options);
91
+ return this.iframe = O(o), n.appendChild(this.iframe), this;
88
92
  }
89
93
  unmount() {
90
- g(), this.iframe && (this.iframe.remove(), this.iframe = null);
94
+ T(), this.iframe && (this.iframe.remove(), this.iframe = null);
91
95
  }
92
96
  }
93
97
  const J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
94
98
  __proto__: null
95
99
  }, Symbol.toStringTag, { value: "Module" }));
96
- function M(t) {
97
- let e = "widget/";
98
- return "disclosureRequestId" in t.configProps ? e += ["disclosures", t.configProps.disclosureRequestId].join("/") : e += t.request, e;
100
+ function M(e) {
101
+ let t = "widget/";
102
+ return "disclosureRequestId" in e.configProps ? t += ["disclosures", e.configProps.disclosureRequestId].join("/") : t += e.request, t;
99
103
  }
100
- function W(t) {
101
- const e = t.isSandbox ?? !1, n = t.developmentUrl || (e ? _ : T), o = Object.entries(t.configProps).filter(([s, c]) => c || s === "disclosureRequestId").map(([s, c]) => `${s}=${encodeURIComponent(c)}`).join("&"), i = M(t);
104
+ function W(e) {
105
+ const t = e.isSandbox ?? !1, n = e.developmentUrl || (t ? y : g), o = Object.entries(e.configProps).filter(([s, c]) => c || s === "disclosureRequestId").map(([s, c]) => `${s}=${encodeURIComponent(c)}`).join("&"), i = M(e);
102
106
  return `${n}/${i}?sdk=web&${o}`;
103
107
  }
104
108
  const F = !!(typeof window < "u" && window.document && window.document.createElement);
105
- let r = null, m = null;
106
- function f(t = null) {
107
- r && !r.closed && r.focus(), t == null || t.preventDefault();
109
+ let r = null, f = null;
110
+ function E(e = null) {
111
+ r && !r.closed && r.focus(), e == null || e.preventDefault();
108
112
  }
109
113
  function h() {
110
- document.body.style.filter = "", document.body.removeEventListener("click", f);
114
+ document.body.style.filter = "", document.body.removeEventListener("click", E);
111
115
  }
112
116
  function V() {
113
- m = setInterval(() => {
114
- (!r || r.closed) && (m && clearInterval(m), h());
117
+ f = setInterval(() => {
118
+ (!r || r.closed) && (f && clearInterval(f), h());
115
119
  }, 500);
116
120
  }
117
- function k(t) {
118
- const e = W(t), n = 420, o = 720, i = window.screenLeft !== void 0 ? window.screenLeft : window.screenX, s = window.screenTop !== void 0 ? window.screenTop : window.screenY, c = window.innerWidth || document.documentElement.clientWidth || window.screen.width, b = window.innerHeight || document.documentElement.clientHeight || window.screen.height, p = c / window.screen.availWidth, P = (c - n) / 2 / p + i, S = (b - o) / 2 / p + s;
119
- document.body.style.filter = "blur(5px)", document.body.addEventListener("click", f), r = window.open(
120
- e,
121
+ function j(e) {
122
+ const t = W(e), n = 420, o = 720, i = window.screenLeft !== void 0 ? window.screenLeft : window.screenX, s = window.screenTop !== void 0 ? window.screenTop : window.screenY, c = window.innerWidth || document.documentElement.clientWidth || window.screen.width, P = window.innerHeight || document.documentElement.clientHeight || window.screen.height, p = c / window.screen.availWidth, S = (c - n) / 2 / p + i, b = (P - o) / 2 / p + s;
123
+ document.body.style.filter = "blur(5px)", document.body.addEventListener("click", E), r = window.open(
124
+ t,
121
125
  "Soyio",
122
126
  `scrollbars=yes,
123
127
  width=${n},
124
128
  height=${o},
125
- top=${S},
126
- left=${P}`
127
- ), f(), V();
129
+ top=${b},
130
+ left=${S}`
131
+ ), E(), V();
128
132
  }
129
- function j() {
133
+ function k() {
130
134
  r && (r.close(), r = null), h();
131
135
  }
132
136
  const q = "WIDGET_EVENT";
@@ -134,27 +138,27 @@ let d = null;
134
138
  function B() {
135
139
  d && (d.cancel(), d = null);
136
140
  }
137
- async function X(t) {
138
- const { onEvent: e } = t, n = await import("./index-yZw-yxuV.js").then((o) => o.i);
141
+ async function X(e) {
142
+ const { onEvent: t } = e, n = await import("./index-yZw-yxuV.js").then((o) => o.i);
139
143
  d && B(), d = n.on(q, async (o) => {
140
- e(o.data), U.includes(o.data.eventName) ? j() : o.data.eventName === D && h();
144
+ t(o.data), U.includes(o.data.eventName) ? k() : o.data.eventName === D && h();
141
145
  });
142
146
  }
143
- function Y(t) {
144
- X(t);
147
+ function Y(e) {
148
+ X(e);
145
149
  }
146
- var E, y;
150
+ var m, _;
147
151
  class Q {
148
- constructor(e) {
149
- w(this, E);
152
+ constructor(t) {
153
+ w(this, m);
150
154
  u(this, "onEvent");
151
- this.onEvent = e.onEvent, F && (k(e), Y({
152
- onEvent: I(this, E, y).bind(this)
155
+ this.onEvent = t.onEvent, F && (j(t), Y({
156
+ onEvent: I(this, m, _).bind(this)
153
157
  }));
154
158
  }
155
159
  }
156
- E = new WeakSet(), y = function(e) {
157
- this.onEvent(e);
160
+ m = new WeakSet(), _ = function(t) {
161
+ this.onEvent(t);
158
162
  };
159
163
  export {
160
164
  z as ConsentBox,
@@ -1,14 +1,18 @@
1
1
  (function(R,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(R=typeof globalThis<"u"?globalThis:R||self,N(R["soyio-widget"]={}))})(this,function(R){"use strict";var Pt=Object.defineProperty;var It=(R,N,M)=>N in R?Pt(R,N,{enumerable:!0,configurable:!0,writable:!0,value:M}):R[N]=M;var Pn=(R,N,M)=>(It(R,typeof N!="symbol"?N+"":N,M),M),Ot=(R,N,M)=>{if(!N.has(R))throw TypeError("Cannot "+M)};var Ie=(R,N,M)=>{if(N.has(R))throw TypeError("Cannot add the same private member more than once");N instanceof WeakSet?N.add(R):N.set(R,M)};var Oe=(R,N,M)=>(Ot(R,N,"access private method"),M);var mn,De;function N(v,W){for(var A=0;A<W.length;A++){const p=W[A];if(typeof p!="string"&&!Array.isArray(p)){for(const m in p)if(m!=="default"&&!(m in v)){const w=Object.getOwnPropertyDescriptor(p,m);w&&Object.defineProperty(v,m,w.get?w:{enumerable:!0,get:()=>p[m]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}const M="soyio-consent-iframe",Un="https://app.soyio.id",Bn="https://sandbox.soyio.id",Ae=["DISCLOSURE_REQUEST_SUCCESSFUL","IDENTITY_REGISTERED","IDENTITY_SIGNATURE","UNEXPECTED_ERROR","DENIED_CAMERA_PERMISSION","REJECTED_SIGNATURE"],Re="WIDGET_CLOSED",Ne=420,Te=720,Ce=500;function je(){const v=document.getElementById(M);v&&(console.warn("ConsentBox iframe already exists. Removing existing before mounting new one."),v.remove())}function ze(v){const W=document.querySelector(v);if(!W)throw new Error(`Iframe div container with id '${v}' not found`);if(W.tagName.toLowerCase()!=="div")throw new Error(`Iframe container with id '${v}' must be a <div> element`);const A=W;return A.style.position="relative",A.style.cssText+=`
2
2
  padding: 0 !important;
3
3
  margin: 0 !important;
4
- display: block !important;
4
+ display: flex !important;
5
+ justify-content: center !important;
6
+ align-items: center !important;
5
7
  border: none !important;
6
8
  transition: height 0.35s !important;
7
9
  opacity: 1 !important;
8
10
  `,A}function Me(v){const W=document.createElement("iframe");return W.id=M,W.src=v,W.style.cssText+=`
9
11
  width: 100% !important;
12
+ min-width: 25rem !important;
13
+ max-width: 36rem !important;
10
14
  border: none !important;
11
- height: 110px !important;
15
+ height: 120px !important;
12
16
  overflow: hidden !important;
13
17
  opacity: 1;
14
18
  transition: height 0.35s,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-widget",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",