@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,440 +0,0 @@
|
|
|
1
|
-
import { Component, h, Prop, Listen, State, Watch } from '@stencil/core';
|
|
2
|
-
import { getTranslations, translate } from '../../utils/locale.utils';
|
|
3
|
-
import '@everymatrix/player-user-consents';
|
|
4
|
-
export class UserActionController {
|
|
5
|
-
constructor() {
|
|
6
|
-
/**
|
|
7
|
-
* Language
|
|
8
|
-
*/
|
|
9
|
-
this.lang = 'en';
|
|
10
|
-
/**
|
|
11
|
-
* Select GM version
|
|
12
|
-
*/
|
|
13
|
-
this.gmVersion = '';
|
|
14
|
-
/**
|
|
15
|
-
* Translation url
|
|
16
|
-
*/
|
|
17
|
-
this.translationUrl = '';
|
|
18
|
-
/**
|
|
19
|
-
* Client custom styling via inline style
|
|
20
|
-
*/
|
|
21
|
-
this.clientStyling = '';
|
|
22
|
-
/**
|
|
23
|
-
* Client custom styling via url
|
|
24
|
-
*/
|
|
25
|
-
this.clientStylingUrl = '';
|
|
26
|
-
/**
|
|
27
|
-
* Which actions are required in order to activate the "Apply" button. Other actions are considered optional.
|
|
28
|
-
*/
|
|
29
|
-
this.queryFired = false;
|
|
30
|
-
this.readyActionsCount = 0;
|
|
31
|
-
this.activeUserActions = [];
|
|
32
|
-
this.userActionsValidated = true;
|
|
33
|
-
this.receivedQueryResponses = 0;
|
|
34
|
-
this.limitStylingAppends = false;
|
|
35
|
-
this.isLoading = true;
|
|
36
|
-
this.mandatoryActionsChecked = 0;
|
|
37
|
-
//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
|
|
38
|
-
this.mandatoryActions = ['termsandconditions'];
|
|
39
|
-
this.userActions = [];
|
|
40
|
-
this.consentTitles = {
|
|
41
|
-
termsandconditions: translate('termsandconditions', this.lang),
|
|
42
|
-
sms: translate('sms', this.lang),
|
|
43
|
-
emailmarketing: translate('emailmarketing', this.lang)
|
|
44
|
-
};
|
|
45
|
-
this.setClientStyling = () => {
|
|
46
|
-
let sheet = document.createElement('style');
|
|
47
|
-
sheet.innerHTML = this.clientStyling;
|
|
48
|
-
this.stylingContainer.prepend(sheet);
|
|
49
|
-
};
|
|
50
|
-
this.setClientStylingURL = () => {
|
|
51
|
-
let url = new URL(this.clientStylingUrl);
|
|
52
|
-
let cssFile = document.createElement('style');
|
|
53
|
-
fetch(url.href)
|
|
54
|
-
.then((res) => res.text())
|
|
55
|
-
.then((data) => {
|
|
56
|
-
this.clientStyling = data;
|
|
57
|
-
cssFile.innerHTML = data;
|
|
58
|
-
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
59
|
-
})
|
|
60
|
-
.catch((err) => {
|
|
61
|
-
console.log('error ', err);
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
handleNewTranslations() {
|
|
66
|
-
getTranslations(this.translationUrl);
|
|
67
|
-
}
|
|
68
|
-
handleQueryResponse() {
|
|
69
|
-
if (this.receivedQueryResponses === this.activeUserActions.length) {
|
|
70
|
-
this.updateUserConsents();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
userLegislationConsentHandler(event) {
|
|
74
|
-
const actionType = event.detail.type;
|
|
75
|
-
const actionTypeChecked = event.detail.value;
|
|
76
|
-
if (this.mandatoryActions.includes(actionType) && this.queryFired === false) {
|
|
77
|
-
actionTypeChecked === true ? this.mandatoryActionsChecked++ : this.mandatoryActionsChecked--;
|
|
78
|
-
}
|
|
79
|
-
// Register final user choices only if we're ready to update
|
|
80
|
-
if (this.queryFired) {
|
|
81
|
-
this.userActions.push({ tagCode: actionType, status: actionTypeChecked ? 'Accepted' : 'Denied' });
|
|
82
|
-
this.receivedQueryResponses++;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
determineUserActions() {
|
|
86
|
-
const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
|
|
87
|
-
const headers = new Headers();
|
|
88
|
-
headers.append('X-SessionId', this.userSession);
|
|
89
|
-
let requestOptions;
|
|
90
|
-
requestOptions = {
|
|
91
|
-
method: 'GET',
|
|
92
|
-
headers
|
|
93
|
-
};
|
|
94
|
-
if (url && requestOptions) {
|
|
95
|
-
return fetch(url.href, requestOptions)
|
|
96
|
-
.then(res => res.json())
|
|
97
|
-
.then(data => {
|
|
98
|
-
const actionItems = data.items;
|
|
99
|
-
actionItems.forEach(element => {
|
|
100
|
-
if (element.status === 'Expired') {
|
|
101
|
-
this.activeUserActions.push(element.tagCode);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
this.isLoading = false;
|
|
105
|
-
})
|
|
106
|
-
.catch(error => {
|
|
107
|
-
console.error('Error fetching data:', error);
|
|
108
|
-
this.isLoading = false;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
return Promise.reject('Unsupported endpoint');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
updateUserConsents() {
|
|
116
|
-
let url;
|
|
117
|
-
let requestOptions;
|
|
118
|
-
url = (this.gmVersion === 'gmcore')
|
|
119
|
-
? new URL(`${this.endpoint}/v1/player/${this.userId}/consent`)
|
|
120
|
-
: new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
|
|
121
|
-
const body = (this.gmVersion === 'gmcore')
|
|
122
|
-
? {
|
|
123
|
-
items: this.userActions
|
|
124
|
-
}
|
|
125
|
-
: {
|
|
126
|
-
consents: [
|
|
127
|
-
{
|
|
128
|
-
tagCode: "termsandconditions",
|
|
129
|
-
note: "",
|
|
130
|
-
status: 1
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
};
|
|
134
|
-
requestOptions = {
|
|
135
|
-
method: 'POST',
|
|
136
|
-
headers: {
|
|
137
|
-
'Content-Type': 'application/json',
|
|
138
|
-
'Accept': 'application/json',
|
|
139
|
-
'X-SessionId': `${this.userSession}`,
|
|
140
|
-
},
|
|
141
|
-
body: JSON.stringify(body)
|
|
142
|
-
};
|
|
143
|
-
if (url && requestOptions) {
|
|
144
|
-
fetch(url.href, requestOptions)
|
|
145
|
-
.then(res => res.json())
|
|
146
|
-
.then(() => {
|
|
147
|
-
window.postMessage({
|
|
148
|
-
type: 'WidgetNotification',
|
|
149
|
-
data: {
|
|
150
|
-
type: 'success',
|
|
151
|
-
message: 'Consent update successful!'
|
|
152
|
-
}
|
|
153
|
-
}, window.location.href);
|
|
154
|
-
})
|
|
155
|
-
.catch((err) => {
|
|
156
|
-
window.postMessage({
|
|
157
|
-
type: 'WidgetNotification',
|
|
158
|
-
data: {
|
|
159
|
-
type: 'error',
|
|
160
|
-
message: 'Server might not be responding',
|
|
161
|
-
err
|
|
162
|
-
}
|
|
163
|
-
}, window.location.href);
|
|
164
|
-
})
|
|
165
|
-
.finally(() => {
|
|
166
|
-
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
handleApplyClick() {
|
|
171
|
-
this.queryFired = true;
|
|
172
|
-
}
|
|
173
|
-
async componentWillLoad() {
|
|
174
|
-
if (this.gmVersion === 'gmcore') {
|
|
175
|
-
return this.determineUserActions();
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
this.activeUserActions = ['termsandconditions'];
|
|
179
|
-
this.isLoading = false;
|
|
180
|
-
}
|
|
181
|
-
if (this.translationUrl.length > 2) {
|
|
182
|
-
await getTranslations(this.translationUrl);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
componentDidRender() {
|
|
186
|
-
// start custom styling area
|
|
187
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
188
|
-
if (this.clientStyling)
|
|
189
|
-
this.setClientStyling();
|
|
190
|
-
if (this.clientStylingUrl)
|
|
191
|
-
this.setClientStylingURL();
|
|
192
|
-
this.limitStylingAppends = true;
|
|
193
|
-
}
|
|
194
|
-
// end custom styling area
|
|
195
|
-
}
|
|
196
|
-
render() {
|
|
197
|
-
const isMandatoryPresent = this.mandatoryActions.every(action => this.activeUserActions.includes(action));
|
|
198
|
-
if (isMandatoryPresent) {
|
|
199
|
-
this.userActionsValidated = !(this.mandatoryActionsChecked === this.mandatoryActions.length);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
this.userActionsValidated = false;
|
|
203
|
-
}
|
|
204
|
-
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
|
|
205
|
-
&&
|
|
206
|
-
h("svg", { class: "spinner", viewBox: "0 0 50 50" },
|
|
207
|
-
h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" },
|
|
208
|
-
h("h2", { class: "UserConsentNotice" }, this.userNoticeText),
|
|
209
|
-
h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action },
|
|
210
|
-
h("player-user-consents", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))),
|
|
211
|
-
this.includeSubmitButton &&
|
|
212
|
-
h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
|
|
213
|
-
}
|
|
214
|
-
static get is() { return "user-action-controller"; }
|
|
215
|
-
static get encapsulation() { return "shadow"; }
|
|
216
|
-
static get originalStyleUrls() { return {
|
|
217
|
-
"$": ["user-action-controller.scss"]
|
|
218
|
-
}; }
|
|
219
|
-
static get styleUrls() { return {
|
|
220
|
-
"$": ["user-action-controller.css"]
|
|
221
|
-
}; }
|
|
222
|
-
static get properties() { return {
|
|
223
|
-
"endpoint": {
|
|
224
|
-
"type": "string",
|
|
225
|
-
"mutable": false,
|
|
226
|
-
"complexType": {
|
|
227
|
-
"original": "string",
|
|
228
|
-
"resolved": "string",
|
|
229
|
-
"references": {}
|
|
230
|
-
},
|
|
231
|
-
"required": true,
|
|
232
|
-
"optional": false,
|
|
233
|
-
"docs": {
|
|
234
|
-
"tags": [],
|
|
235
|
-
"text": "the endpoint required for the update call"
|
|
236
|
-
},
|
|
237
|
-
"attribute": "endpoint",
|
|
238
|
-
"reflect": true
|
|
239
|
-
},
|
|
240
|
-
"userSession": {
|
|
241
|
-
"type": "string",
|
|
242
|
-
"mutable": false,
|
|
243
|
-
"complexType": {
|
|
244
|
-
"original": "string",
|
|
245
|
-
"resolved": "string",
|
|
246
|
-
"references": {}
|
|
247
|
-
},
|
|
248
|
-
"required": true,
|
|
249
|
-
"optional": false,
|
|
250
|
-
"docs": {
|
|
251
|
-
"tags": [],
|
|
252
|
-
"text": "user session required for the update call"
|
|
253
|
-
},
|
|
254
|
-
"attribute": "user-session",
|
|
255
|
-
"reflect": true
|
|
256
|
-
},
|
|
257
|
-
"userId": {
|
|
258
|
-
"type": "string",
|
|
259
|
-
"mutable": false,
|
|
260
|
-
"complexType": {
|
|
261
|
-
"original": "string",
|
|
262
|
-
"resolved": "string",
|
|
263
|
-
"references": {}
|
|
264
|
-
},
|
|
265
|
-
"required": true,
|
|
266
|
-
"optional": false,
|
|
267
|
-
"docs": {
|
|
268
|
-
"tags": [],
|
|
269
|
-
"text": "user id required for the update call"
|
|
270
|
-
},
|
|
271
|
-
"attribute": "user-id",
|
|
272
|
-
"reflect": true
|
|
273
|
-
},
|
|
274
|
-
"lang": {
|
|
275
|
-
"type": "string",
|
|
276
|
-
"mutable": true,
|
|
277
|
-
"complexType": {
|
|
278
|
-
"original": "string",
|
|
279
|
-
"resolved": "string",
|
|
280
|
-
"references": {}
|
|
281
|
-
},
|
|
282
|
-
"required": false,
|
|
283
|
-
"optional": false,
|
|
284
|
-
"docs": {
|
|
285
|
-
"tags": [],
|
|
286
|
-
"text": "Language"
|
|
287
|
-
},
|
|
288
|
-
"attribute": "lang",
|
|
289
|
-
"reflect": true,
|
|
290
|
-
"defaultValue": "'en'"
|
|
291
|
-
},
|
|
292
|
-
"includeSubmitButton": {
|
|
293
|
-
"type": "boolean",
|
|
294
|
-
"mutable": false,
|
|
295
|
-
"complexType": {
|
|
296
|
-
"original": "boolean",
|
|
297
|
-
"resolved": "boolean",
|
|
298
|
-
"references": {}
|
|
299
|
-
},
|
|
300
|
-
"required": true,
|
|
301
|
-
"optional": false,
|
|
302
|
-
"docs": {
|
|
303
|
-
"tags": [],
|
|
304
|
-
"text": "whether or not to include the submit button (in case we want to compose a different )"
|
|
305
|
-
},
|
|
306
|
-
"attribute": "include-submit-button",
|
|
307
|
-
"reflect": true
|
|
308
|
-
},
|
|
309
|
-
"submitButtonText": {
|
|
310
|
-
"type": "string",
|
|
311
|
-
"mutable": false,
|
|
312
|
-
"complexType": {
|
|
313
|
-
"original": "string",
|
|
314
|
-
"resolved": "string",
|
|
315
|
-
"references": {}
|
|
316
|
-
},
|
|
317
|
-
"required": false,
|
|
318
|
-
"optional": false,
|
|
319
|
-
"docs": {
|
|
320
|
-
"tags": [],
|
|
321
|
-
"text": "the text of the button, if button is enabled"
|
|
322
|
-
},
|
|
323
|
-
"attribute": "submit-button-text",
|
|
324
|
-
"reflect": true
|
|
325
|
-
},
|
|
326
|
-
"userNoticeText": {
|
|
327
|
-
"type": "string",
|
|
328
|
-
"mutable": false,
|
|
329
|
-
"complexType": {
|
|
330
|
-
"original": "string",
|
|
331
|
-
"resolved": "string",
|
|
332
|
-
"references": {}
|
|
333
|
-
},
|
|
334
|
-
"required": false,
|
|
335
|
-
"optional": false,
|
|
336
|
-
"docs": {
|
|
337
|
-
"tags": [],
|
|
338
|
-
"text": "the title of the action group"
|
|
339
|
-
},
|
|
340
|
-
"attribute": "user-notice-text",
|
|
341
|
-
"reflect": true
|
|
342
|
-
},
|
|
343
|
-
"gmVersion": {
|
|
344
|
-
"type": "string",
|
|
345
|
-
"mutable": false,
|
|
346
|
-
"complexType": {
|
|
347
|
-
"original": "string",
|
|
348
|
-
"resolved": "string",
|
|
349
|
-
"references": {}
|
|
350
|
-
},
|
|
351
|
-
"required": false,
|
|
352
|
-
"optional": false,
|
|
353
|
-
"docs": {
|
|
354
|
-
"tags": [],
|
|
355
|
-
"text": "Select GM version"
|
|
356
|
-
},
|
|
357
|
-
"attribute": "gm-version",
|
|
358
|
-
"reflect": false,
|
|
359
|
-
"defaultValue": "''"
|
|
360
|
-
},
|
|
361
|
-
"translationUrl": {
|
|
362
|
-
"type": "string",
|
|
363
|
-
"mutable": false,
|
|
364
|
-
"complexType": {
|
|
365
|
-
"original": "string",
|
|
366
|
-
"resolved": "string",
|
|
367
|
-
"references": {}
|
|
368
|
-
},
|
|
369
|
-
"required": false,
|
|
370
|
-
"optional": false,
|
|
371
|
-
"docs": {
|
|
372
|
-
"tags": [],
|
|
373
|
-
"text": "Translation url"
|
|
374
|
-
},
|
|
375
|
-
"attribute": "translation-url",
|
|
376
|
-
"reflect": true,
|
|
377
|
-
"defaultValue": "''"
|
|
378
|
-
},
|
|
379
|
-
"clientStyling": {
|
|
380
|
-
"type": "string",
|
|
381
|
-
"mutable": true,
|
|
382
|
-
"complexType": {
|
|
383
|
-
"original": "string",
|
|
384
|
-
"resolved": "string",
|
|
385
|
-
"references": {}
|
|
386
|
-
},
|
|
387
|
-
"required": false,
|
|
388
|
-
"optional": false,
|
|
389
|
-
"docs": {
|
|
390
|
-
"tags": [],
|
|
391
|
-
"text": "Client custom styling via inline style"
|
|
392
|
-
},
|
|
393
|
-
"attribute": "client-styling",
|
|
394
|
-
"reflect": true,
|
|
395
|
-
"defaultValue": "''"
|
|
396
|
-
},
|
|
397
|
-
"clientStylingUrl": {
|
|
398
|
-
"type": "string",
|
|
399
|
-
"mutable": false,
|
|
400
|
-
"complexType": {
|
|
401
|
-
"original": "string",
|
|
402
|
-
"resolved": "string",
|
|
403
|
-
"references": {}
|
|
404
|
-
},
|
|
405
|
-
"required": false,
|
|
406
|
-
"optional": false,
|
|
407
|
-
"docs": {
|
|
408
|
-
"tags": [],
|
|
409
|
-
"text": "Client custom styling via url"
|
|
410
|
-
},
|
|
411
|
-
"attribute": "client-styling-url",
|
|
412
|
-
"reflect": true,
|
|
413
|
-
"defaultValue": "''"
|
|
414
|
-
}
|
|
415
|
-
}; }
|
|
416
|
-
static get states() { return {
|
|
417
|
-
"queryFired": {},
|
|
418
|
-
"readyActionsCount": {},
|
|
419
|
-
"activeUserActions": {},
|
|
420
|
-
"userActionsValidated": {},
|
|
421
|
-
"receivedQueryResponses": {},
|
|
422
|
-
"limitStylingAppends": {},
|
|
423
|
-
"isLoading": {},
|
|
424
|
-
"mandatoryActionsChecked": {}
|
|
425
|
-
}; }
|
|
426
|
-
static get watchers() { return [{
|
|
427
|
-
"propName": "translationUrl",
|
|
428
|
-
"methodName": "handleNewTranslations"
|
|
429
|
-
}, {
|
|
430
|
-
"propName": "receivedQueryResponses",
|
|
431
|
-
"methodName": "handleQueryResponse"
|
|
432
|
-
}]; }
|
|
433
|
-
static get listeners() { return [{
|
|
434
|
-
"name": "userLegislationConsent",
|
|
435
|
-
"method": "userLegislationConsentHandler",
|
|
436
|
-
"target": undefined,
|
|
437
|
-
"capture": false,
|
|
438
|
-
"passive": false
|
|
439
|
-
}]; }
|
|
440
|
-
}
|
package/dist/collection/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en', 'cz', 'de', 'hr'];
|
|
3
|
-
const TRANSLATIONS = {
|
|
4
|
-
en: {
|
|
5
|
-
termsandconditions: 'Terms and Conditions',
|
|
6
|
-
sms: 'SMS marketing',
|
|
7
|
-
emailmarketing: 'Email marketing'
|
|
8
|
-
},
|
|
9
|
-
ro: {
|
|
10
|
-
termsandconditions: 'Terms and Conditions',
|
|
11
|
-
sms: 'SMS marketing',
|
|
12
|
-
emailmarketing: 'Email marketing'
|
|
13
|
-
},
|
|
14
|
-
hr: {
|
|
15
|
-
termsandconditions: 'Terms and Conditions',
|
|
16
|
-
sms: 'SMS marketing',
|
|
17
|
-
emailmarketing: 'Email marketing'
|
|
18
|
-
},
|
|
19
|
-
fr: {
|
|
20
|
-
termsandconditions: 'Terms and Conditions',
|
|
21
|
-
sms: 'SMS marketing',
|
|
22
|
-
emailmarketing: 'Email marketing'
|
|
23
|
-
},
|
|
24
|
-
cs: {
|
|
25
|
-
termsandconditions: 'Terms and Conditions',
|
|
26
|
-
sms: 'SMS marketing',
|
|
27
|
-
emailmarketing: 'Email marketing'
|
|
28
|
-
},
|
|
29
|
-
de: {
|
|
30
|
-
termsandconditions: 'Terms and Conditions',
|
|
31
|
-
sms: 'SMS marketing',
|
|
32
|
-
emailmarketing: 'Email marketing'
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
export const getTranslations = (url) => {
|
|
36
|
-
// fetch url, get the data, replace the TRANSLATIONS content
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
fetch(url)
|
|
39
|
-
.then((res) => res.json())
|
|
40
|
-
.then((data) => {
|
|
41
|
-
Object.keys(data).forEach((item) => {
|
|
42
|
-
for (let key in data[item]) {
|
|
43
|
-
TRANSLATIONS[item][key] = data[item][key];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
resolve(true);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
export const translate = (key, customLang, values) => {
|
|
51
|
-
const lang = customLang;
|
|
52
|
-
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
53
|
-
if (values !== undefined) {
|
|
54
|
-
for (const [key, value] of Object.entries(values.values)) {
|
|
55
|
-
const regex = new RegExp(`{${key}}`, 'g');
|
|
56
|
-
translation = translation.replace(regex, value);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return translation;
|
|
60
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* UserActionController custom elements */
|
|
2
|
-
|
|
3
|
-
import type { Components, JSX } from "../types/components";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Used to manually set the base path where assets can be found.
|
|
7
|
-
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
-
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
-
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
-
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
-
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
-
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
-
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
-
*/
|
|
15
|
-
export declare const setAssetPath: (path: string) => void;
|
|
16
|
-
|
|
17
|
-
export interface SetPlatformOptions {
|
|
18
|
-
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
-
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
-
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
-
}
|
|
22
|
-
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
-
|
|
24
|
-
export type { Components, JSX };
|
|
25
|
-
|
|
26
|
-
export * from '../types';
|
package/dist/components/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
|
|
3
|
-
const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";
|
|
4
|
-
|
|
5
|
-
const PlayerUserConsents = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.__registerHost();
|
|
9
|
-
this.__attachShadow();
|
|
10
|
-
this.userLegislationConsent = createEvent(this, "userLegislationConsent", 7);
|
|
11
|
-
/**
|
|
12
|
-
* 'true' when parent expects component to emit it's current value
|
|
13
|
-
*/
|
|
14
|
-
this.queried = false;
|
|
15
|
-
/**
|
|
16
|
-
* the type of the consent, used to determine render details
|
|
17
|
-
*/
|
|
18
|
-
this.consentType = '';
|
|
19
|
-
/**
|
|
20
|
-
* wether or not this consent is mandatory. Used for render details
|
|
21
|
-
*/
|
|
22
|
-
this.mandatory = false;
|
|
23
|
-
/**
|
|
24
|
-
* the title of the consent to be displayed
|
|
25
|
-
*/
|
|
26
|
-
this.consentTitle = '';
|
|
27
|
-
/**
|
|
28
|
-
* link to the t&c page
|
|
29
|
-
*/
|
|
30
|
-
this.tcLink = '#';
|
|
31
|
-
/**
|
|
32
|
-
* link to privacy policy page
|
|
33
|
-
*/
|
|
34
|
-
this.privacyLink = '#';
|
|
35
|
-
/**
|
|
36
|
-
* Client custom styling via inline style
|
|
37
|
-
*/
|
|
38
|
-
this.clientStyling = '';
|
|
39
|
-
/**
|
|
40
|
-
* the text content to be rendered by the component. Determined at runtime
|
|
41
|
-
*/
|
|
42
|
-
this.textContent = '';
|
|
43
|
-
this.limitStylingAppends = false;
|
|
44
|
-
// Maybe switch this out with a localization source
|
|
45
|
-
this.stringVariants = {
|
|
46
|
-
termsandconditions1: "I accept the ",
|
|
47
|
-
termsandconditions2: ", I have read and understood the ",
|
|
48
|
-
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
49
|
-
tc: "Terms and Conditions",
|
|
50
|
-
privacy: "Privacy Policy",
|
|
51
|
-
sms: "I consent to receive marketing communication via SMS.",
|
|
52
|
-
emailmarketing: "I consent to receive marketing communication via Email."
|
|
53
|
-
};
|
|
54
|
-
this.setClientStyling = () => {
|
|
55
|
-
let sheet = document.createElement('style');
|
|
56
|
-
sheet.innerHTML = this.clientStyling;
|
|
57
|
-
this.stylingContainer.prepend(sheet);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
determineTextContent() {
|
|
61
|
-
let result = this.consentType === 'termsandconditions' ?
|
|
62
|
-
h("span", null, this.stringVariants['termsandconditions1'], h("a", { href: this.tcLink }, this.stringVariants['tc']), this.stringVariants['termsandconditions2'], h("a", { href: this.privacyLink }, this.stringVariants['privacy']), this.stringVariants['termsandconditions3'])
|
|
63
|
-
: h("span", null, this.stringVariants[this.consentType]);
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
userLegislationConsentHandler() {
|
|
67
|
-
this.userLegislationConsent.emit({
|
|
68
|
-
type: this.consentType,
|
|
69
|
-
value: this.checkboxInput.checked
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
componentDidRender() {
|
|
73
|
-
// start custom styling area
|
|
74
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
75
|
-
if (this.clientStyling)
|
|
76
|
-
this.setClientStyling();
|
|
77
|
-
this.limitStylingAppends = true;
|
|
78
|
-
}
|
|
79
|
-
// end custom styling area
|
|
80
|
-
}
|
|
81
|
-
render() {
|
|
82
|
-
if (this.queried) {
|
|
83
|
-
this.userLegislationConsentHandler();
|
|
84
|
-
}
|
|
85
|
-
this.textContent = this.determineTextContent();
|
|
86
|
-
return (h("div", { ref: el => this.stylingContainer = el }, h("p", { class: "ConsentTitle" }, this.consentTitle), h("label", { class: "userConsent", htmlFor: "userConsent" }, h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.textContent, this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
|
|
87
|
-
}
|
|
88
|
-
static get style() { return playerUserConsentsCss; }
|
|
89
|
-
}, [1, "player-user-consents", {
|
|
90
|
-
"queried": [516],
|
|
91
|
-
"consentType": [513, "consent-type"],
|
|
92
|
-
"mandatory": [516],
|
|
93
|
-
"consentTitle": [513, "consent-title"],
|
|
94
|
-
"tcLink": [513, "tc-link"],
|
|
95
|
-
"privacyLink": [513, "privacy-link"],
|
|
96
|
-
"clientStyling": [1, "client-styling"],
|
|
97
|
-
"textContent": [32],
|
|
98
|
-
"limitStylingAppends": [32]
|
|
99
|
-
}]);
|
|
100
|
-
function defineCustomElement() {
|
|
101
|
-
if (typeof customElements === "undefined") {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const components = ["player-user-consents"];
|
|
105
|
-
components.forEach(tagName => { switch (tagName) {
|
|
106
|
-
case "player-user-consents":
|
|
107
|
-
if (!customElements.get(tagName)) {
|
|
108
|
-
customElements.define(tagName, PlayerUserConsents);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
} });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export { PlayerUserConsents as P, defineCustomElement as d };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Components, JSX } from "../types/components";
|
|
2
|
-
|
|
3
|
-
interface UserActionController extends Components.UserActionController, HTMLElement {}
|
|
4
|
-
export const UserActionController: {
|
|
5
|
-
prototype: UserActionController;
|
|
6
|
-
new (): UserActionController;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Used to define this component and all nested components recursively.
|
|
10
|
-
*/
|
|
11
|
-
export const defineCustomElement: () => void;
|