@everymatrix/user-action-controller 0.0.1 → 1.13.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/dist/cjs/generic-user-consent_3.cjs.entry.js +113 -8
- package/dist/cjs/{index-4a3038bd.js → index-3529682c.js} +35 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/user-action-controller.cjs.js +2 -2
- package/dist/collection/components/user-action-controller/user-action-controller.css +6 -0
- package/dist/collection/components/user-action-controller/user-action-controller.js +181 -7
- package/dist/components/generic-user-consent2.js +23 -2
- package/dist/components/legislation-wrapper2.js +23 -2
- package/dist/components/user-action-controller.js +80 -7
- package/dist/esm/generic-user-consent_3.entry.js +113 -8
- package/dist/esm/{index-9eef5ef8.js → index-f118067b.js} +35 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/user-action-controller.js +2 -2
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/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 +31 -0
- package/dist/types/components.d.ts +44 -0
- package/dist/user-action-controller/p-a9c2a73d.js +1 -0
- package/dist/user-action-controller/p-aa12aa8d.entry.js +1 -0
- package/dist/user-action-controller/user-action-controller.esm.js +1 -1
- package/package.json +2 -5
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +0 -2
- package/dist/user-action-controller/p-013051ff.entry.js +0 -1
- package/dist/user-action-controller/p-54386d36.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-3529682c.js');
|
|
6
6
|
|
|
7
7
|
const genericUserConsentCss = ":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}";
|
|
8
8
|
|
|
@@ -34,10 +34,15 @@ const GenericUserConsent = class {
|
|
|
34
34
|
* link to privacy policy page
|
|
35
35
|
*/
|
|
36
36
|
this.privacyLink = '#';
|
|
37
|
+
/**
|
|
38
|
+
* Client custom styling via inline style
|
|
39
|
+
*/
|
|
40
|
+
this.clientStyling = '';
|
|
37
41
|
/**
|
|
38
42
|
* the text content to be rendered by the component. Determined at runtime
|
|
39
43
|
*/
|
|
40
44
|
this.textContent = '';
|
|
45
|
+
this.limitStylingAppends = false;
|
|
41
46
|
// Maybe switch this out with a localization source
|
|
42
47
|
this.stringVariants = {
|
|
43
48
|
termsandconditions1: "I accept the ",
|
|
@@ -48,6 +53,11 @@ const GenericUserConsent = class {
|
|
|
48
53
|
sms: "I consent to receive marketing communication via SMS.",
|
|
49
54
|
emailmarketing: "I consent to receive marketing communication via Email."
|
|
50
55
|
};
|
|
56
|
+
this.setClientStyling = () => {
|
|
57
|
+
let sheet = document.createElement('style');
|
|
58
|
+
sheet.innerHTML = this.clientStyling;
|
|
59
|
+
this.stylingContainer.prepend(sheet);
|
|
60
|
+
};
|
|
51
61
|
}
|
|
52
62
|
determineTextContent() {
|
|
53
63
|
let result = this.consentType === 'termsandconditions' ?
|
|
@@ -61,12 +71,21 @@ const GenericUserConsent = class {
|
|
|
61
71
|
value: this.checkboxInput.checked
|
|
62
72
|
});
|
|
63
73
|
}
|
|
74
|
+
componentDidRender() {
|
|
75
|
+
// start custom styling area
|
|
76
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
77
|
+
if (this.clientStyling)
|
|
78
|
+
this.setClientStyling();
|
|
79
|
+
this.limitStylingAppends = true;
|
|
80
|
+
}
|
|
81
|
+
// end custom styling area
|
|
82
|
+
}
|
|
64
83
|
render() {
|
|
65
84
|
if (this.queried) {
|
|
66
85
|
this.userLegislationConsentHandler();
|
|
67
86
|
}
|
|
68
87
|
this.textContent = this.determineTextContent();
|
|
69
|
-
return (index.h("div",
|
|
88
|
+
return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("p", { class: "ConsentTitle" }, this.consentTitle), index.h("label", { class: "userConsent", htmlFor: "userConsent" }, index.h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.textContent, this.mandatory && index.h("span", { class: "MandatoryItem" }, "*"))));
|
|
70
89
|
}
|
|
71
90
|
};
|
|
72
91
|
GenericUserConsent.style = genericUserConsentCss;
|
|
@@ -76,19 +95,51 @@ const legislationWrapperCss = ":host{display:block}";
|
|
|
76
95
|
const LegislationWrapper = class {
|
|
77
96
|
constructor(hostRef) {
|
|
78
97
|
index.registerInstance(this, hostRef);
|
|
98
|
+
/**
|
|
99
|
+
* Client custom styling via inline style
|
|
100
|
+
*/
|
|
101
|
+
this.clientStyling = '';
|
|
102
|
+
this.limitStylingAppends = false;
|
|
103
|
+
this.setClientStyling = () => {
|
|
104
|
+
let sheet = document.createElement('style');
|
|
105
|
+
sheet.innerHTML = this.clientStyling;
|
|
106
|
+
this.stylingContainer.prepend(sheet);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
componentDidRender() {
|
|
110
|
+
// start custom styling area
|
|
111
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
112
|
+
if (this.clientStyling)
|
|
113
|
+
this.setClientStyling();
|
|
114
|
+
this.limitStylingAppends = true;
|
|
115
|
+
}
|
|
116
|
+
// end custom styling area
|
|
79
117
|
}
|
|
80
118
|
render() {
|
|
81
119
|
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
82
|
-
return (index.h("div", { class: "LegislationWrapper" }, activeUAList.map(action => (index.h("slot", { name: action })))));
|
|
120
|
+
return (index.h("div", { class: "LegislationWrapper", ref: el => this.stylingContainer = el }, activeUAList.map(action => (index.h("slot", { name: action })))));
|
|
83
121
|
}
|
|
84
122
|
};
|
|
85
123
|
LegislationWrapper.style = legislationWrapperCss;
|
|
86
124
|
|
|
87
|
-
const userActionControllerCss = ":host{display:block}.QueryReferenceContainer{height:100%;width:100%}.UserConsentNotice{font-size:1.2rem;font-weight:200;text-align:center}.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}}";
|
|
125
|
+
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}}";
|
|
88
126
|
|
|
89
127
|
const UserActionController = class {
|
|
90
128
|
constructor(hostRef) {
|
|
91
129
|
index.registerInstance(this, hostRef);
|
|
130
|
+
this.closeButtonEvent = index.createEvent(this, "closeButtonClicked", 7);
|
|
131
|
+
/**
|
|
132
|
+
* Event name to be sent when the button is clicked
|
|
133
|
+
*/
|
|
134
|
+
this.postMessageEvent = 'closeButtonClicked';
|
|
135
|
+
/**
|
|
136
|
+
* Client custom styling via inline style
|
|
137
|
+
*/
|
|
138
|
+
this.clientStyling = '';
|
|
139
|
+
/**
|
|
140
|
+
* Client custom styling via url
|
|
141
|
+
*/
|
|
142
|
+
this.clientStylingUrl = '';
|
|
92
143
|
this.consentTitles = {
|
|
93
144
|
termsandconditions: "Terms and Conditions",
|
|
94
145
|
sms: "SMS marketing",
|
|
@@ -100,10 +151,30 @@ const UserActionController = class {
|
|
|
100
151
|
this.queryFired = false;
|
|
101
152
|
this.readyActionsCount = 0;
|
|
102
153
|
this.receivedQueryResponses = 0;
|
|
154
|
+
this.limitStylingAppends = false;
|
|
103
155
|
this.mandatoryActions = ['termsandconditions'];
|
|
104
156
|
this.requiredActionsCount = 0;
|
|
105
157
|
this.expectedQueryResponses = 0;
|
|
106
158
|
this.userActions = [];
|
|
159
|
+
this.setClientStyling = () => {
|
|
160
|
+
let sheet = document.createElement('style');
|
|
161
|
+
sheet.innerHTML = this.clientStyling;
|
|
162
|
+
this.stylingContainer.prepend(sheet);
|
|
163
|
+
};
|
|
164
|
+
this.setClientStylingURL = () => {
|
|
165
|
+
let url = new URL(this.clientStylingUrl);
|
|
166
|
+
let cssFile = document.createElement('style');
|
|
167
|
+
fetch(url.href)
|
|
168
|
+
.then((res) => res.text())
|
|
169
|
+
.then((data) => {
|
|
170
|
+
this.clientStyling = data;
|
|
171
|
+
cssFile.innerHTML = data;
|
|
172
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
173
|
+
})
|
|
174
|
+
.catch((err) => {
|
|
175
|
+
console.log('error ', err);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
107
178
|
}
|
|
108
179
|
determineMandatoryActions() {
|
|
109
180
|
let url = new URL(`${this.endpoint}v1/player/consentRequirements`);
|
|
@@ -136,9 +207,25 @@ const UserActionController = class {
|
|
|
136
207
|
};
|
|
137
208
|
fetch(url.href, options)
|
|
138
209
|
.then(res => res.json())
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
210
|
+
.then(() => {
|
|
211
|
+
/**
|
|
212
|
+
* @TODO document this
|
|
213
|
+
*/
|
|
214
|
+
window.postMessage({ type: 'WidgetNotification', data: {
|
|
215
|
+
type: 'success',
|
|
216
|
+
message: 'Consent update successfull!'
|
|
217
|
+
} }, window.location.href);
|
|
218
|
+
})
|
|
219
|
+
.catch((err) => {
|
|
220
|
+
/**
|
|
221
|
+
* @TODO document this
|
|
222
|
+
*/
|
|
223
|
+
window.postMessage({ type: 'WidgetNotification', data: {
|
|
224
|
+
type: 'error',
|
|
225
|
+
message: 'Server might not be responding',
|
|
226
|
+
err
|
|
227
|
+
} }, window.location.href);
|
|
228
|
+
})
|
|
142
229
|
.finally(() => {
|
|
143
230
|
window.postMessage({ type: "UserActionsCompleted" }, window.location.href);
|
|
144
231
|
});
|
|
@@ -146,6 +233,12 @@ const UserActionController = class {
|
|
|
146
233
|
handleApplyClick() {
|
|
147
234
|
this.queryFired = true;
|
|
148
235
|
}
|
|
236
|
+
handleClose() {
|
|
237
|
+
if (this.usePostmessage) {
|
|
238
|
+
window.postMessage({ type: this.postMessageEvent });
|
|
239
|
+
}
|
|
240
|
+
this.closeButtonEvent.emit();
|
|
241
|
+
}
|
|
149
242
|
userLegislationConsentHandler(event) {
|
|
150
243
|
// Increase / Decrease the amount of mandatory actions taken
|
|
151
244
|
if (this.mandatoryActions.includes(event.detail.type)) {
|
|
@@ -164,11 +257,23 @@ const UserActionController = class {
|
|
|
164
257
|
componentWillLoad() {
|
|
165
258
|
return this.determineMandatoryActions();
|
|
166
259
|
}
|
|
260
|
+
componentDidRender() {
|
|
261
|
+
// start custom styling area
|
|
262
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
263
|
+
if (this.clientStyling)
|
|
264
|
+
this.setClientStyling();
|
|
265
|
+
if (this.clientStylingUrl)
|
|
266
|
+
this.setClientStylingURL();
|
|
267
|
+
this.limitStylingAppends = true;
|
|
268
|
+
}
|
|
269
|
+
// end custom styling area
|
|
270
|
+
}
|
|
167
271
|
render() {
|
|
168
272
|
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
169
273
|
this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
|
|
170
274
|
this.expectedQueryResponses = activeUAList.length;
|
|
171
|
-
return (index.h("div", { class: "QueryReferenceContainer"
|
|
275
|
+
return (index.h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, index.h("div", { class: "UserActionController" }, this.showCloseButton &&
|
|
276
|
+
index.h("div", { class: "CloseButton", onClick: () => this.handleClose() }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "25", height: "25", fill: "currentColor", viewBox: "0 0 16 16" }, index.h("path", { d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" }))), index.h("h2", { class: "UserConsentNotice" }, this.userNoticeText), index.h("legislation-wrapper", { "active-user-actions": this.activeUserActions, "client-styling": this.clientStyling }, activeUAList.map(item => (index.h("generic-user-consent", { slot: item, consentType: item, consentTitle: this.consentTitles[item], queried: this.queryFired, mandatory: this.mandatoryActions.includes(item), "client-styling": this.clientStyling })))), this.includeSubmitButton &&
|
|
172
277
|
index.h("button", { class: "ConsentSubmitButton", disabled: this.readyActionsCount === this.requiredActionsCount ? false : true, onClick: () => this.handleApplyClick() }, this.submitButtonText))));
|
|
173
278
|
}
|
|
174
279
|
static get watchers() { return {
|
|
@@ -164,6 +164,11 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
|
164
164
|
* Don't add values to these!!
|
|
165
165
|
*/
|
|
166
166
|
const EMPTY_OBJ = {};
|
|
167
|
+
/**
|
|
168
|
+
* Namespaces
|
|
169
|
+
*/
|
|
170
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
171
|
+
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
167
172
|
const isDef = (v) => v != null;
|
|
168
173
|
const isComplexType = (o) => {
|
|
169
174
|
// https://jsperf.com/typeof-fn-object/5
|
|
@@ -380,8 +385,15 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
380
385
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
381
386
|
}
|
|
382
387
|
else {
|
|
388
|
+
if (!isSvgMode) {
|
|
389
|
+
isSvgMode = newVNode.$tag$ === 'svg';
|
|
390
|
+
}
|
|
383
391
|
// create element
|
|
384
|
-
elm = newVNode.$elm$ = (doc.
|
|
392
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
|
|
393
|
+
);
|
|
394
|
+
if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
|
395
|
+
isSvgMode = false;
|
|
396
|
+
}
|
|
385
397
|
// add css classes, attrs, props, listeners, etc.
|
|
386
398
|
{
|
|
387
399
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -402,6 +414,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
402
414
|
}
|
|
403
415
|
}
|
|
404
416
|
}
|
|
417
|
+
{
|
|
418
|
+
if (newVNode.$tag$ === 'svg') {
|
|
419
|
+
// Only reset the SVG context when we're exiting <svg> element
|
|
420
|
+
isSvgMode = false;
|
|
421
|
+
}
|
|
422
|
+
else if (elm.tagName === 'foreignObject') {
|
|
423
|
+
// Reenter SVG context when we're exiting <foreignObject> element
|
|
424
|
+
isSvgMode = true;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
405
427
|
}
|
|
406
428
|
return elm;
|
|
407
429
|
};
|
|
@@ -512,6 +534,11 @@ const patch = (oldVNode, newVNode) => {
|
|
|
512
534
|
const tag = newVNode.$tag$;
|
|
513
535
|
const text = newVNode.$text$;
|
|
514
536
|
if (text === null) {
|
|
537
|
+
{
|
|
538
|
+
// test if we're rendering an svg element, or still rendering nodes inside of one
|
|
539
|
+
// only add this to the when the compiler sees we're using an svg somewhere
|
|
540
|
+
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
541
|
+
}
|
|
515
542
|
// element node
|
|
516
543
|
{
|
|
517
544
|
if (tag === 'slot')
|
|
@@ -540,6 +567,9 @@ const patch = (oldVNode, newVNode) => {
|
|
|
540
567
|
// no new child vnodes, but there are old child vnodes to remove
|
|
541
568
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
542
569
|
}
|
|
570
|
+
if (isSvgMode && tag === 'svg') {
|
|
571
|
+
isSvgMode = false;
|
|
572
|
+
}
|
|
543
573
|
}
|
|
544
574
|
else if (oldVNode.$text$ !== text) {
|
|
545
575
|
// update the text content for the text only vnode
|
|
@@ -697,7 +727,11 @@ const postUpdateComponent = (hostRef) => {
|
|
|
697
727
|
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
698
728
|
const elm = hostRef.$hostElement$;
|
|
699
729
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
730
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
700
731
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
732
|
+
{
|
|
733
|
+
safeCall(instance, 'componentDidRender');
|
|
734
|
+
}
|
|
701
735
|
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
702
736
|
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
703
737
|
{
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-3529682c.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["generic-user-consent_3.cjs",[[1,"user-action-controller",{"endpoint":[1],"userSession":[1,"user-session"],"userId":[1,"user-id"],"includeSubmitButton":[4,"include-submit-button"],"submitButtonText":[1,"submit-button-text"],"userNoticeText":[1,"user-notice-text"],"activeUserActions":[1,"active-user-actions"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"generic-user-consent",{"queried":[4],"consentType":[1,"consent-type"],"mandatory":[4],"consentTitle":[1,"consent-title"],"tcLink":[1,"tc-link"],"privacyLink":[1,"privacy-link"],"textContent":[32]}],[1,"legislation-wrapper",{"activeUserActions":[1,"active-user-actions"]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["generic-user-consent_3.cjs",[[1,"user-action-controller",{"endpoint":[1],"userSession":[1,"user-session"],"userId":[1,"user-id"],"includeSubmitButton":[4,"include-submit-button"],"submitButtonText":[1,"submit-button-text"],"userNoticeText":[1,"user-notice-text"],"activeUserActions":[1,"active-user-actions"],"showCloseButton":[4,"show-close-button"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"clientStyling":[1025,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"generic-user-consent",{"queried":[4],"consentType":[1,"consent-type"],"mandatory":[4],"consentTitle":[1,"consent-title"],"tcLink":[1,"tc-link"],"privacyLink":[1,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}],[1,"legislation-wrapper",{"activeUserActions":[1,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-3529682c.js');
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["generic-user-consent_3.cjs",[[1,"user-action-controller",{"endpoint":[1],"userSession":[1,"user-session"],"userId":[1,"user-id"],"includeSubmitButton":[4,"include-submit-button"],"submitButtonText":[1,"submit-button-text"],"userNoticeText":[1,"user-notice-text"],"activeUserActions":[1,"active-user-actions"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"generic-user-consent",{"queried":[4],"consentType":[1,"consent-type"],"mandatory":[4],"consentTitle":[1,"consent-title"],"tcLink":[1,"tc-link"],"privacyLink":[1,"privacy-link"],"textContent":[32]}],[1,"legislation-wrapper",{"activeUserActions":[1,"active-user-actions"]}]]]], options);
|
|
18
|
+
return index.bootstrapLazy([["generic-user-consent_3.cjs",[[1,"user-action-controller",{"endpoint":[1],"userSession":[1,"user-session"],"userId":[1,"user-id"],"includeSubmitButton":[4,"include-submit-button"],"submitButtonText":[1,"submit-button-text"],"userNoticeText":[1,"user-notice-text"],"activeUserActions":[1,"active-user-actions"],"showCloseButton":[4,"show-close-button"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"clientStyling":[1025,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"generic-user-consent",{"queried":[4],"consentType":[1,"consent-type"],"mandatory":[4],"consentTitle":[1,"consent-title"],"tcLink":[1,"tc-link"],"privacyLink":[1,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}],[1,"legislation-wrapper",{"activeUserActions":[1,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { Component, h, Prop, Listen, State, Watch } from '@stencil/core';
|
|
1
|
+
import { Component, h, Prop, Listen, State, Watch, Event } from '@stencil/core';
|
|
2
2
|
import '@everymatrix/legislation-wrapper';
|
|
3
3
|
import '@everymatrix/generic-user-consent';
|
|
4
4
|
export class UserActionController {
|
|
5
5
|
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
* Event name to be sent when the button is clicked
|
|
8
|
+
*/
|
|
9
|
+
this.postMessageEvent = 'closeButtonClicked';
|
|
10
|
+
/**
|
|
11
|
+
* Client custom styling via inline style
|
|
12
|
+
*/
|
|
13
|
+
this.clientStyling = '';
|
|
14
|
+
/**
|
|
15
|
+
* Client custom styling via url
|
|
16
|
+
*/
|
|
17
|
+
this.clientStylingUrl = '';
|
|
6
18
|
this.consentTitles = {
|
|
7
19
|
termsandconditions: "Terms and Conditions",
|
|
8
20
|
sms: "SMS marketing",
|
|
@@ -14,10 +26,30 @@ export class UserActionController {
|
|
|
14
26
|
this.queryFired = false;
|
|
15
27
|
this.readyActionsCount = 0;
|
|
16
28
|
this.receivedQueryResponses = 0;
|
|
29
|
+
this.limitStylingAppends = false;
|
|
17
30
|
this.mandatoryActions = ['termsandconditions'];
|
|
18
31
|
this.requiredActionsCount = 0;
|
|
19
32
|
this.expectedQueryResponses = 0;
|
|
20
33
|
this.userActions = [];
|
|
34
|
+
this.setClientStyling = () => {
|
|
35
|
+
let sheet = document.createElement('style');
|
|
36
|
+
sheet.innerHTML = this.clientStyling;
|
|
37
|
+
this.stylingContainer.prepend(sheet);
|
|
38
|
+
};
|
|
39
|
+
this.setClientStylingURL = () => {
|
|
40
|
+
let url = new URL(this.clientStylingUrl);
|
|
41
|
+
let cssFile = document.createElement('style');
|
|
42
|
+
fetch(url.href)
|
|
43
|
+
.then((res) => res.text())
|
|
44
|
+
.then((data) => {
|
|
45
|
+
this.clientStyling = data;
|
|
46
|
+
cssFile.innerHTML = data;
|
|
47
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
48
|
+
})
|
|
49
|
+
.catch((err) => {
|
|
50
|
+
console.log('error ', err);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
21
53
|
}
|
|
22
54
|
determineMandatoryActions() {
|
|
23
55
|
let url = new URL(`${this.endpoint}v1/player/consentRequirements`);
|
|
@@ -50,9 +82,25 @@ export class UserActionController {
|
|
|
50
82
|
};
|
|
51
83
|
fetch(url.href, options)
|
|
52
84
|
.then(res => res.json())
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
85
|
+
.then(() => {
|
|
86
|
+
/**
|
|
87
|
+
* @TODO document this
|
|
88
|
+
*/
|
|
89
|
+
window.postMessage({ type: 'WidgetNotification', data: {
|
|
90
|
+
type: 'success',
|
|
91
|
+
message: 'Consent update successfull!'
|
|
92
|
+
} }, window.location.href);
|
|
93
|
+
})
|
|
94
|
+
.catch((err) => {
|
|
95
|
+
/**
|
|
96
|
+
* @TODO document this
|
|
97
|
+
*/
|
|
98
|
+
window.postMessage({ type: 'WidgetNotification', data: {
|
|
99
|
+
type: 'error',
|
|
100
|
+
message: 'Server might not be responding',
|
|
101
|
+
err
|
|
102
|
+
} }, window.location.href);
|
|
103
|
+
})
|
|
56
104
|
.finally(() => {
|
|
57
105
|
window.postMessage({ type: "UserActionsCompleted" }, window.location.href);
|
|
58
106
|
});
|
|
@@ -60,6 +108,12 @@ export class UserActionController {
|
|
|
60
108
|
handleApplyClick() {
|
|
61
109
|
this.queryFired = true;
|
|
62
110
|
}
|
|
111
|
+
handleClose() {
|
|
112
|
+
if (this.usePostmessage) {
|
|
113
|
+
window.postMessage({ type: this.postMessageEvent });
|
|
114
|
+
}
|
|
115
|
+
this.closeButtonEvent.emit();
|
|
116
|
+
}
|
|
63
117
|
userLegislationConsentHandler(event) {
|
|
64
118
|
// Increase / Decrease the amount of mandatory actions taken
|
|
65
119
|
if (this.mandatoryActions.includes(event.detail.type)) {
|
|
@@ -78,14 +132,29 @@ export class UserActionController {
|
|
|
78
132
|
componentWillLoad() {
|
|
79
133
|
return this.determineMandatoryActions();
|
|
80
134
|
}
|
|
135
|
+
componentDidRender() {
|
|
136
|
+
// start custom styling area
|
|
137
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
138
|
+
if (this.clientStyling)
|
|
139
|
+
this.setClientStyling();
|
|
140
|
+
if (this.clientStylingUrl)
|
|
141
|
+
this.setClientStylingURL();
|
|
142
|
+
this.limitStylingAppends = true;
|
|
143
|
+
}
|
|
144
|
+
// end custom styling area
|
|
145
|
+
}
|
|
81
146
|
render() {
|
|
82
147
|
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
83
148
|
this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
|
|
84
149
|
this.expectedQueryResponses = activeUAList.length;
|
|
85
|
-
return (h("div", { class: "QueryReferenceContainer" },
|
|
150
|
+
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el },
|
|
86
151
|
h("div", { class: "UserActionController" },
|
|
152
|
+
this.showCloseButton &&
|
|
153
|
+
h("div", { class: "CloseButton", onClick: () => this.handleClose() },
|
|
154
|
+
h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "25", height: "25", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
155
|
+
h("path", { d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" }))),
|
|
87
156
|
h("h2", { class: "UserConsentNotice" }, this.userNoticeText),
|
|
88
|
-
h("legislation-wrapper", { "active-user-actions": this.activeUserActions }, activeUAList.map(item => (h("generic-user-consent", { slot: item, consentType: item, consentTitle: this.consentTitles[item], queried: this.queryFired, mandatory: this.mandatoryActions.includes(item) })))),
|
|
157
|
+
h("legislation-wrapper", { "active-user-actions": this.activeUserActions, "client-styling": this.clientStyling }, activeUAList.map(item => (h("generic-user-consent", { slot: item, consentType: item, consentTitle: this.consentTitles[item], queried: this.queryFired, mandatory: this.mandatoryActions.includes(item), "client-styling": this.clientStyling })))),
|
|
89
158
|
this.includeSubmitButton &&
|
|
90
159
|
h("button", { class: "ConsentSubmitButton", disabled: this.readyActionsCount === this.requiredActionsCount ? false : true, onClick: () => this.handleApplyClick() }, this.submitButtonText))));
|
|
91
160
|
}
|
|
@@ -216,13 +285,118 @@ export class UserActionController {
|
|
|
216
285
|
},
|
|
217
286
|
"attribute": "active-user-actions",
|
|
218
287
|
"reflect": false
|
|
288
|
+
},
|
|
289
|
+
"showCloseButton": {
|
|
290
|
+
"type": "boolean",
|
|
291
|
+
"mutable": false,
|
|
292
|
+
"complexType": {
|
|
293
|
+
"original": "boolean",
|
|
294
|
+
"resolved": "boolean",
|
|
295
|
+
"references": {}
|
|
296
|
+
},
|
|
297
|
+
"required": true,
|
|
298
|
+
"optional": false,
|
|
299
|
+
"docs": {
|
|
300
|
+
"tags": [],
|
|
301
|
+
"text": "Property used to display the close/cancel button"
|
|
302
|
+
},
|
|
303
|
+
"attribute": "show-close-button",
|
|
304
|
+
"reflect": false
|
|
305
|
+
},
|
|
306
|
+
"usePostmessage": {
|
|
307
|
+
"type": "boolean",
|
|
308
|
+
"mutable": false,
|
|
309
|
+
"complexType": {
|
|
310
|
+
"original": "boolean",
|
|
311
|
+
"resolved": "boolean",
|
|
312
|
+
"references": {}
|
|
313
|
+
},
|
|
314
|
+
"required": true,
|
|
315
|
+
"optional": false,
|
|
316
|
+
"docs": {
|
|
317
|
+
"tags": [],
|
|
318
|
+
"text": "Use postMessage event to communicate"
|
|
319
|
+
},
|
|
320
|
+
"attribute": "use-postmessage",
|
|
321
|
+
"reflect": false
|
|
322
|
+
},
|
|
323
|
+
"postMessageEvent": {
|
|
324
|
+
"type": "string",
|
|
325
|
+
"mutable": false,
|
|
326
|
+
"complexType": {
|
|
327
|
+
"original": "string",
|
|
328
|
+
"resolved": "string",
|
|
329
|
+
"references": {}
|
|
330
|
+
},
|
|
331
|
+
"required": false,
|
|
332
|
+
"optional": false,
|
|
333
|
+
"docs": {
|
|
334
|
+
"tags": [],
|
|
335
|
+
"text": "Event name to be sent when the button is clicked"
|
|
336
|
+
},
|
|
337
|
+
"attribute": "post-message-event",
|
|
338
|
+
"reflect": false,
|
|
339
|
+
"defaultValue": "'closeButtonClicked'"
|
|
340
|
+
},
|
|
341
|
+
"clientStyling": {
|
|
342
|
+
"type": "string",
|
|
343
|
+
"mutable": true,
|
|
344
|
+
"complexType": {
|
|
345
|
+
"original": "string",
|
|
346
|
+
"resolved": "string",
|
|
347
|
+
"references": {}
|
|
348
|
+
},
|
|
349
|
+
"required": false,
|
|
350
|
+
"optional": false,
|
|
351
|
+
"docs": {
|
|
352
|
+
"tags": [],
|
|
353
|
+
"text": "Client custom styling via inline style"
|
|
354
|
+
},
|
|
355
|
+
"attribute": "client-styling",
|
|
356
|
+
"reflect": false,
|
|
357
|
+
"defaultValue": "''"
|
|
358
|
+
},
|
|
359
|
+
"clientStylingUrl": {
|
|
360
|
+
"type": "string",
|
|
361
|
+
"mutable": false,
|
|
362
|
+
"complexType": {
|
|
363
|
+
"original": "string",
|
|
364
|
+
"resolved": "string",
|
|
365
|
+
"references": {}
|
|
366
|
+
},
|
|
367
|
+
"required": false,
|
|
368
|
+
"optional": false,
|
|
369
|
+
"docs": {
|
|
370
|
+
"tags": [],
|
|
371
|
+
"text": "Client custom styling via url"
|
|
372
|
+
},
|
|
373
|
+
"attribute": "client-styling-url",
|
|
374
|
+
"reflect": false,
|
|
375
|
+
"defaultValue": "''"
|
|
219
376
|
}
|
|
220
377
|
}; }
|
|
221
378
|
static get states() { return {
|
|
222
379
|
"queryFired": {},
|
|
223
380
|
"readyActionsCount": {},
|
|
224
|
-
"receivedQueryResponses": {}
|
|
381
|
+
"receivedQueryResponses": {},
|
|
382
|
+
"limitStylingAppends": {}
|
|
225
383
|
}; }
|
|
384
|
+
static get events() { return [{
|
|
385
|
+
"method": "closeButtonEvent",
|
|
386
|
+
"name": "closeButtonClicked",
|
|
387
|
+
"bubbles": true,
|
|
388
|
+
"cancelable": true,
|
|
389
|
+
"composed": true,
|
|
390
|
+
"docs": {
|
|
391
|
+
"tags": [],
|
|
392
|
+
"text": "Event emitted when the close button is clicked"
|
|
393
|
+
},
|
|
394
|
+
"complexType": {
|
|
395
|
+
"original": "any",
|
|
396
|
+
"resolved": "any",
|
|
397
|
+
"references": {}
|
|
398
|
+
}
|
|
399
|
+
}]; }
|
|
226
400
|
static get watchers() { return [{
|
|
227
401
|
"propName": "receivedQueryResponses",
|
|
228
402
|
"methodName": "handleQueryResponse"
|
|
@@ -32,10 +32,15 @@ const GenericUserConsent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
32
32
|
* link to privacy policy page
|
|
33
33
|
*/
|
|
34
34
|
this.privacyLink = '#';
|
|
35
|
+
/**
|
|
36
|
+
* Client custom styling via inline style
|
|
37
|
+
*/
|
|
38
|
+
this.clientStyling = '';
|
|
35
39
|
/**
|
|
36
40
|
* the text content to be rendered by the component. Determined at runtime
|
|
37
41
|
*/
|
|
38
42
|
this.textContent = '';
|
|
43
|
+
this.limitStylingAppends = false;
|
|
39
44
|
// Maybe switch this out with a localization source
|
|
40
45
|
this.stringVariants = {
|
|
41
46
|
termsandconditions1: "I accept the ",
|
|
@@ -46,6 +51,11 @@ const GenericUserConsent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
46
51
|
sms: "I consent to receive marketing communication via SMS.",
|
|
47
52
|
emailmarketing: "I consent to receive marketing communication via Email."
|
|
48
53
|
};
|
|
54
|
+
this.setClientStyling = () => {
|
|
55
|
+
let sheet = document.createElement('style');
|
|
56
|
+
sheet.innerHTML = this.clientStyling;
|
|
57
|
+
this.stylingContainer.prepend(sheet);
|
|
58
|
+
};
|
|
49
59
|
}
|
|
50
60
|
determineTextContent() {
|
|
51
61
|
let result = this.consentType === 'termsandconditions' ?
|
|
@@ -59,12 +69,21 @@ const GenericUserConsent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
59
69
|
value: this.checkboxInput.checked
|
|
60
70
|
});
|
|
61
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
|
+
}
|
|
62
81
|
render() {
|
|
63
82
|
if (this.queried) {
|
|
64
83
|
this.userLegislationConsentHandler();
|
|
65
84
|
}
|
|
66
85
|
this.textContent = this.determineTextContent();
|
|
67
|
-
return (h("div",
|
|
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" }, "*"))));
|
|
68
87
|
}
|
|
69
88
|
static get style() { return genericUserConsentCss; }
|
|
70
89
|
}, [1, "generic-user-consent", {
|
|
@@ -74,7 +93,9 @@ const GenericUserConsent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
74
93
|
"consentTitle": [1, "consent-title"],
|
|
75
94
|
"tcLink": [1, "tc-link"],
|
|
76
95
|
"privacyLink": [1, "privacy-link"],
|
|
77
|
-
"
|
|
96
|
+
"clientStyling": [1, "client-styling"],
|
|
97
|
+
"textContent": [32],
|
|
98
|
+
"limitStylingAppends": [32]
|
|
78
99
|
}]);
|
|
79
100
|
function defineCustomElement() {
|
|
80
101
|
if (typeof customElements === "undefined") {
|