@everymatrix/user-action-controller 1.31.2 → 1.32.4
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/LICENSE +21 -0
- package/package.json +3 -2
- package/dist/cjs/index-87049e21.js +0 -1300
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/cjs/player-user-consents_2.cjs.entry.js +0 -370
- package/dist/cjs/user-action-controller.cjs.js +0 -19
- package/dist/collection/collection-manifest.json +0 -19
- package/dist/collection/components/user-action-controller/user-action-controller.css +0 -89
- package/dist/collection/components/user-action-controller/user-action-controller.js +0 -440
- package/dist/collection/index.js +0 -1
- package/dist/collection/utils/locale.utils.js +0 -60
- package/dist/collection/utils/utils.js +0 -3
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/components/player-user-consents.js +0 -6
- package/dist/components/player-user-consents2.js +0 -114
- package/dist/components/user-action-controller.d.ts +0 -11
- package/dist/components/user-action-controller.js +0 -323
- package/dist/esm/index-71f14530.js +0 -1274
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +0 -17
- package/dist/esm/player-user-consents_2.entry.js +0 -365
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/user-action-controller.js +0 -17
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/stencil.config.js +0 -22
- package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +0 -2
- package/dist/types/components/user-action-controller/user-action-controller.d.ts +0 -78
- package/dist/types/components.d.ts +0 -125
- package/dist/types/index.d.ts +0 -1
- package/dist/types/stencil-public-runtime.d.ts +0 -1565
- package/dist/types/utils/locale.utils.d.ts +0 -2
- package/dist/types/utils/utils.d.ts +0 -1
- package/dist/user-action-controller/index.esm.js +0 -0
- package/dist/user-action-controller/p-711fa494.entry.js +0 -1
- package/dist/user-action-controller/p-ba444709.js +0 -1
- package/dist/user-action-controller/user-action-controller.esm.js +0 -1
- package/loader/cdn.js +0 -3
- package/loader/index.cjs.js +0 -3
- package/loader/index.d.ts +0 -12
- package/loader/index.es2017.js +0 -3
- package/loader/index.js +0 -4
- package/loader/package.json +0 -10
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { d as defineCustomElement$2 } from './player-user-consents2.js';
|
|
3
|
-
|
|
4
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
5
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en', 'cz', 'de', 'hr'];
|
|
6
|
-
const TRANSLATIONS = {
|
|
7
|
-
en: {
|
|
8
|
-
termsandconditions: 'Terms and Conditions',
|
|
9
|
-
sms: 'SMS marketing',
|
|
10
|
-
emailmarketing: 'Email marketing'
|
|
11
|
-
},
|
|
12
|
-
ro: {
|
|
13
|
-
termsandconditions: 'Terms and Conditions',
|
|
14
|
-
sms: 'SMS marketing',
|
|
15
|
-
emailmarketing: 'Email marketing'
|
|
16
|
-
},
|
|
17
|
-
hr: {
|
|
18
|
-
termsandconditions: 'Terms and Conditions',
|
|
19
|
-
sms: 'SMS marketing',
|
|
20
|
-
emailmarketing: 'Email marketing'
|
|
21
|
-
},
|
|
22
|
-
fr: {
|
|
23
|
-
termsandconditions: 'Terms and Conditions',
|
|
24
|
-
sms: 'SMS marketing',
|
|
25
|
-
emailmarketing: 'Email marketing'
|
|
26
|
-
},
|
|
27
|
-
cs: {
|
|
28
|
-
termsandconditions: 'Terms and Conditions',
|
|
29
|
-
sms: 'SMS marketing',
|
|
30
|
-
emailmarketing: 'Email marketing'
|
|
31
|
-
},
|
|
32
|
-
de: {
|
|
33
|
-
termsandconditions: 'Terms and Conditions',
|
|
34
|
-
sms: 'SMS marketing',
|
|
35
|
-
emailmarketing: 'Email marketing'
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
const getTranslations = (url) => {
|
|
39
|
-
// fetch url, get the data, replace the TRANSLATIONS content
|
|
40
|
-
return new Promise((resolve) => {
|
|
41
|
-
fetch(url)
|
|
42
|
-
.then((res) => res.json())
|
|
43
|
-
.then((data) => {
|
|
44
|
-
Object.keys(data).forEach((item) => {
|
|
45
|
-
for (let key in data[item]) {
|
|
46
|
-
TRANSLATIONS[item][key] = data[item][key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
resolve(true);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
const translate = (key, customLang, values) => {
|
|
54
|
-
const lang = customLang;
|
|
55
|
-
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
56
|
-
if (values !== undefined) {
|
|
57
|
-
for (const [key, value] of Object.entries(values.values)) {
|
|
58
|
-
const regex = new RegExp(`{${key}}`, 'g');
|
|
59
|
-
translation = translation.replace(regex, value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return translation;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const userActionControllerCss = ":host{display:block}.QueryReferenceContainer{height:100%;width:100%}.UserConsentNotice{font-size:1.2rem;font-weight:200;text-align:center}.CloseButton{width:25px;height:25px;align-self:flex-end}.UserActionController{font-family:Arial, Helvetica, sans-serif;font-weight:100;height:100%;width:100%;padding:1rem 1.5rem 2rem;background-color:#fff;display:flex;flex-direction:column;justify-content:space-between;border-radius:5%}.ConsentSubmitButton{font-size:1rem;padding:0.4rem 1.4rem;background:#fff;border:2px solid #000;color:#000;border-radius:5px;align-self:flex-end}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc}@media screen and (max-width: 320px){.QueryReferenceContainer{font-size:0.8rem;color:blue}}.spinner{animation:rotate 2s linear infinite;z-index:2;position:absolute;top:50%;left:50%;margin:-25px 0 0 -25px;width:50px;height:50px}.spinner .path{stroke:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));stroke-linecap:round;animation:dash 1.5s ease-in-out infinite}@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1, 150;stroke-dashoffset:0}50%{stroke-dasharray:90, 150;stroke-dashoffset:-35}100%{stroke-dasharray:90, 150;stroke-dashoffset:-124}}";
|
|
66
|
-
|
|
67
|
-
const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
68
|
-
constructor() {
|
|
69
|
-
super();
|
|
70
|
-
this.__registerHost();
|
|
71
|
-
this.__attachShadow();
|
|
72
|
-
/**
|
|
73
|
-
* Language
|
|
74
|
-
*/
|
|
75
|
-
this.lang = 'en';
|
|
76
|
-
/**
|
|
77
|
-
* Select GM version
|
|
78
|
-
*/
|
|
79
|
-
this.gmVersion = '';
|
|
80
|
-
/**
|
|
81
|
-
* Translation url
|
|
82
|
-
*/
|
|
83
|
-
this.translationUrl = '';
|
|
84
|
-
/**
|
|
85
|
-
* Client custom styling via inline style
|
|
86
|
-
*/
|
|
87
|
-
this.clientStyling = '';
|
|
88
|
-
/**
|
|
89
|
-
* Client custom styling via url
|
|
90
|
-
*/
|
|
91
|
-
this.clientStylingUrl = '';
|
|
92
|
-
/**
|
|
93
|
-
* Which actions are required in order to activate the "Apply" button. Other actions are considered optional.
|
|
94
|
-
*/
|
|
95
|
-
this.queryFired = false;
|
|
96
|
-
this.readyActionsCount = 0;
|
|
97
|
-
this.activeUserActions = [];
|
|
98
|
-
this.userActionsValidated = true;
|
|
99
|
-
this.receivedQueryResponses = 0;
|
|
100
|
-
this.limitStylingAppends = false;
|
|
101
|
-
this.isLoading = true;
|
|
102
|
-
this.mandatoryActionsChecked = 0;
|
|
103
|
-
//for now this variable is hardcoded bcs we have only terms and conditions mandatory and we dont receive with these new functionality the mandatory actions
|
|
104
|
-
this.mandatoryActions = ['termsandconditions'];
|
|
105
|
-
this.userActions = [];
|
|
106
|
-
this.consentTitles = {
|
|
107
|
-
termsandconditions: translate('termsandconditions', this.lang),
|
|
108
|
-
sms: translate('sms', this.lang),
|
|
109
|
-
emailmarketing: translate('emailmarketing', this.lang)
|
|
110
|
-
};
|
|
111
|
-
this.setClientStyling = () => {
|
|
112
|
-
let sheet = document.createElement('style');
|
|
113
|
-
sheet.innerHTML = this.clientStyling;
|
|
114
|
-
this.stylingContainer.prepend(sheet);
|
|
115
|
-
};
|
|
116
|
-
this.setClientStylingURL = () => {
|
|
117
|
-
let url = new URL(this.clientStylingUrl);
|
|
118
|
-
let cssFile = document.createElement('style');
|
|
119
|
-
fetch(url.href)
|
|
120
|
-
.then((res) => res.text())
|
|
121
|
-
.then((data) => {
|
|
122
|
-
this.clientStyling = data;
|
|
123
|
-
cssFile.innerHTML = data;
|
|
124
|
-
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
125
|
-
})
|
|
126
|
-
.catch((err) => {
|
|
127
|
-
console.log('error ', err);
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
handleNewTranslations() {
|
|
132
|
-
getTranslations(this.translationUrl);
|
|
133
|
-
}
|
|
134
|
-
handleQueryResponse() {
|
|
135
|
-
if (this.receivedQueryResponses === this.activeUserActions.length) {
|
|
136
|
-
this.updateUserConsents();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
userLegislationConsentHandler(event) {
|
|
140
|
-
const actionType = event.detail.type;
|
|
141
|
-
const actionTypeChecked = event.detail.value;
|
|
142
|
-
if (this.mandatoryActions.includes(actionType) && this.queryFired === false) {
|
|
143
|
-
actionTypeChecked === true ? this.mandatoryActionsChecked++ : this.mandatoryActionsChecked--;
|
|
144
|
-
}
|
|
145
|
-
// Register final user choices only if we're ready to update
|
|
146
|
-
if (this.queryFired) {
|
|
147
|
-
this.userActions.push({ tagCode: actionType, status: actionTypeChecked ? 'Accepted' : 'Denied' });
|
|
148
|
-
this.receivedQueryResponses++;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
determineUserActions() {
|
|
152
|
-
const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
|
|
153
|
-
const headers = new Headers();
|
|
154
|
-
headers.append('X-SessionId', this.userSession);
|
|
155
|
-
let requestOptions;
|
|
156
|
-
requestOptions = {
|
|
157
|
-
method: 'GET',
|
|
158
|
-
headers
|
|
159
|
-
};
|
|
160
|
-
if (url && requestOptions) {
|
|
161
|
-
return fetch(url.href, requestOptions)
|
|
162
|
-
.then(res => res.json())
|
|
163
|
-
.then(data => {
|
|
164
|
-
const actionItems = data.items;
|
|
165
|
-
actionItems.forEach(element => {
|
|
166
|
-
if (element.status === 'Expired') {
|
|
167
|
-
this.activeUserActions.push(element.tagCode);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
this.isLoading = false;
|
|
171
|
-
})
|
|
172
|
-
.catch(error => {
|
|
173
|
-
console.error('Error fetching data:', error);
|
|
174
|
-
this.isLoading = false;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
return Promise.reject('Unsupported endpoint');
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
updateUserConsents() {
|
|
182
|
-
let url;
|
|
183
|
-
let requestOptions;
|
|
184
|
-
url = (this.gmVersion === 'gmcore')
|
|
185
|
-
? new URL(`${this.endpoint}/v1/player/${this.userId}/consent`)
|
|
186
|
-
: new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
|
|
187
|
-
const body = (this.gmVersion === 'gmcore')
|
|
188
|
-
? {
|
|
189
|
-
items: this.userActions
|
|
190
|
-
}
|
|
191
|
-
: {
|
|
192
|
-
consents: [
|
|
193
|
-
{
|
|
194
|
-
tagCode: "termsandconditions",
|
|
195
|
-
note: "",
|
|
196
|
-
status: 1
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
};
|
|
200
|
-
requestOptions = {
|
|
201
|
-
method: 'POST',
|
|
202
|
-
headers: {
|
|
203
|
-
'Content-Type': 'application/json',
|
|
204
|
-
'Accept': 'application/json',
|
|
205
|
-
'X-SessionId': `${this.userSession}`,
|
|
206
|
-
},
|
|
207
|
-
body: JSON.stringify(body)
|
|
208
|
-
};
|
|
209
|
-
if (url && requestOptions) {
|
|
210
|
-
fetch(url.href, requestOptions)
|
|
211
|
-
.then(res => res.json())
|
|
212
|
-
.then(() => {
|
|
213
|
-
window.postMessage({
|
|
214
|
-
type: 'WidgetNotification',
|
|
215
|
-
data: {
|
|
216
|
-
type: 'success',
|
|
217
|
-
message: 'Consent update successful!'
|
|
218
|
-
}
|
|
219
|
-
}, window.location.href);
|
|
220
|
-
})
|
|
221
|
-
.catch((err) => {
|
|
222
|
-
window.postMessage({
|
|
223
|
-
type: 'WidgetNotification',
|
|
224
|
-
data: {
|
|
225
|
-
type: 'error',
|
|
226
|
-
message: 'Server might not be responding',
|
|
227
|
-
err
|
|
228
|
-
}
|
|
229
|
-
}, window.location.href);
|
|
230
|
-
})
|
|
231
|
-
.finally(() => {
|
|
232
|
-
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
handleApplyClick() {
|
|
237
|
-
this.queryFired = true;
|
|
238
|
-
}
|
|
239
|
-
async componentWillLoad() {
|
|
240
|
-
if (this.gmVersion === 'gmcore') {
|
|
241
|
-
return this.determineUserActions();
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
this.activeUserActions = ['termsandconditions'];
|
|
245
|
-
this.isLoading = false;
|
|
246
|
-
}
|
|
247
|
-
if (this.translationUrl.length > 2) {
|
|
248
|
-
await getTranslations(this.translationUrl);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
componentDidRender() {
|
|
252
|
-
// start custom styling area
|
|
253
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
254
|
-
if (this.clientStyling)
|
|
255
|
-
this.setClientStyling();
|
|
256
|
-
if (this.clientStylingUrl)
|
|
257
|
-
this.setClientStylingURL();
|
|
258
|
-
this.limitStylingAppends = true;
|
|
259
|
-
}
|
|
260
|
-
// end custom styling area
|
|
261
|
-
}
|
|
262
|
-
render() {
|
|
263
|
-
const isMandatoryPresent = this.mandatoryActions.every(action => this.activeUserActions.includes(action));
|
|
264
|
-
if (isMandatoryPresent) {
|
|
265
|
-
this.userActionsValidated = !(this.mandatoryActionsChecked === this.mandatoryActions.length);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
this.userActionsValidated = false;
|
|
269
|
-
}
|
|
270
|
-
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
|
|
271
|
-
&&
|
|
272
|
-
h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
|
|
273
|
-
h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
|
|
274
|
-
}
|
|
275
|
-
static get watchers() { return {
|
|
276
|
-
"translationUrl": ["handleNewTranslations"],
|
|
277
|
-
"receivedQueryResponses": ["handleQueryResponse"]
|
|
278
|
-
}; }
|
|
279
|
-
static get style() { return userActionControllerCss; }
|
|
280
|
-
}, [1, "user-action-controller", {
|
|
281
|
-
"endpoint": [513],
|
|
282
|
-
"userSession": [513, "user-session"],
|
|
283
|
-
"userId": [513, "user-id"],
|
|
284
|
-
"lang": [1537],
|
|
285
|
-
"includeSubmitButton": [516, "include-submit-button"],
|
|
286
|
-
"submitButtonText": [513, "submit-button-text"],
|
|
287
|
-
"userNoticeText": [513, "user-notice-text"],
|
|
288
|
-
"gmVersion": [1, "gm-version"],
|
|
289
|
-
"translationUrl": [513, "translation-url"],
|
|
290
|
-
"clientStyling": [1537, "client-styling"],
|
|
291
|
-
"clientStylingUrl": [513, "client-styling-url"],
|
|
292
|
-
"queryFired": [32],
|
|
293
|
-
"readyActionsCount": [32],
|
|
294
|
-
"activeUserActions": [32],
|
|
295
|
-
"userActionsValidated": [32],
|
|
296
|
-
"receivedQueryResponses": [32],
|
|
297
|
-
"limitStylingAppends": [32],
|
|
298
|
-
"isLoading": [32],
|
|
299
|
-
"mandatoryActionsChecked": [32]
|
|
300
|
-
}, [[0, "userLegislationConsent", "userLegislationConsentHandler"]]]);
|
|
301
|
-
function defineCustomElement$1() {
|
|
302
|
-
if (typeof customElements === "undefined") {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const components = ["user-action-controller", "player-user-consents"];
|
|
306
|
-
components.forEach(tagName => { switch (tagName) {
|
|
307
|
-
case "user-action-controller":
|
|
308
|
-
if (!customElements.get(tagName)) {
|
|
309
|
-
customElements.define(tagName, UserActionController$1);
|
|
310
|
-
}
|
|
311
|
-
break;
|
|
312
|
-
case "player-user-consents":
|
|
313
|
-
if (!customElements.get(tagName)) {
|
|
314
|
-
defineCustomElement$2();
|
|
315
|
-
}
|
|
316
|
-
break;
|
|
317
|
-
} });
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const UserActionController = UserActionController$1;
|
|
321
|
-
const defineCustomElement = defineCustomElement$1;
|
|
322
|
-
|
|
323
|
-
export { UserActionController, defineCustomElement };
|