@everymatrix/user-action-controller 1.32.4 → 1.33.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/dist/cjs/index-87049e21.js +1300 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/player-user-consents_2.cjs.entry.js +455 -0
- package/dist/cjs/user-action-controller.cjs.js +19 -0
- package/dist/collection/collection-manifest.json +19 -0
- package/dist/collection/components/user-action-controller/user-action-controller.css +89 -0
- package/dist/collection/components/user-action-controller/user-action-controller.js +440 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +60 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/player-user-consents.js +6 -0
- package/dist/components/player-user-consents2.js +199 -0
- package/dist/components/user-action-controller.d.ts +11 -0
- package/dist/components/user-action-controller.js +323 -0
- package/dist/esm/index-71f14530.js +1274 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/player-user-consents_2.entry.js +450 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/user-action-controller.js +17 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +2 -0
- package/dist/types/components/user-action-controller/user-action-controller.d.ts +78 -0
- package/dist/types/components.d.ts +125 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/locale.utils.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/dist/user-action-controller/index.esm.js +0 -0
- package/dist/user-action-controller/p-ba444709.js +1 -0
- package/dist/user-action-controller/p-d1fdbddb.entry.js +1 -0
- package/dist/user-action-controller/user-action-controller.esm.js +1 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +2 -3
- package/LICENSE +0 -21
|
@@ -0,0 +1,440 @@
|
|
|
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", { lang: this.lang, "translation-url": this.translationUrl, 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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|