@everymatrix/user-action-controller 1.0.0 → 1.0.69

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.
Files changed (57) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-c5061e5a.js +1315 -0
  3. package/dist/cjs/loader.cjs.js +7 -13
  4. package/dist/cjs/player-user-consents_2.cjs.entry.js +504 -0
  5. package/dist/cjs/user-action-controller.cjs.js +17 -11
  6. package/dist/collection/collection-manifest.json +5 -11
  7. package/dist/collection/components/user-action-controller/index.js +1 -0
  8. package/dist/collection/components/user-action-controller/user-action-controller.css +37 -0
  9. package/dist/collection/components/user-action-controller/user-action-controller.js +418 -328
  10. package/dist/collection/utils/locale.utils.js +66 -0
  11. package/dist/collection/utils/utils.js +1 -1
  12. package/dist/esm/app-globals-0f993ce5.js +3 -0
  13. package/dist/esm/index-02b86e76.js +1288 -0
  14. package/dist/esm/loader.js +7 -13
  15. package/dist/esm/player-user-consents_2.entry.js +499 -0
  16. package/dist/esm/user-action-controller.js +14 -11
  17. package/dist/stencil.config.dev.js +17 -0
  18. package/dist/stencil.config.js +14 -19
  19. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-action-controller/.stencil/packages/stencil/user-action-controller/stencil.config.d.ts +2 -0
  20. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-action-controller/.stencil/packages/stencil/user-action-controller/stencil.config.dev.d.ts +2 -0
  21. package/dist/types/components/user-action-controller/index.d.ts +1 -0
  22. package/dist/types/components/user-action-controller/user-action-controller.d.ts +68 -68
  23. package/dist/types/components.d.ts +28 -40
  24. package/dist/types/stencil-public-runtime.d.ts +142 -33
  25. package/dist/types/utils/locale.utils.d.ts +2 -0
  26. package/dist/user-action-controller/p-4bd71dba.entry.js +1 -0
  27. package/dist/user-action-controller/p-b996e8b8.js +2 -0
  28. package/dist/user-action-controller/p-e1255160.js +1 -0
  29. package/dist/user-action-controller/user-action-controller.esm.js +1 -1
  30. package/loader/cdn.js +1 -3
  31. package/loader/index.cjs.js +1 -3
  32. package/loader/index.d.ts +13 -1
  33. package/loader/index.es2017.js +1 -3
  34. package/loader/index.js +1 -3
  35. package/loader/package.json +1 -0
  36. package/package.json +16 -3
  37. package/dist/cjs/generic-user-consent_3.cjs.entry.js +0 -210
  38. package/dist/cjs/index-5b463836.js +0 -1285
  39. package/dist/components/generic-user-consent.js +0 -6
  40. package/dist/components/generic-user-consent2.js +0 -93
  41. package/dist/components/index.d.ts +0 -26
  42. package/dist/components/index.js +0 -1
  43. package/dist/components/legislation-wrapper.js +0 -6
  44. package/dist/components/legislation-wrapper2.js +0 -33
  45. package/dist/components/user-action-controller.d.ts +0 -11
  46. package/dist/components/user-action-controller.js +0 -168
  47. package/dist/esm/generic-user-consent_3.entry.js +0 -204
  48. package/dist/esm/index-e34db4b0.js +0 -1259
  49. package/dist/esm/polyfills/core-js.js +0 -11
  50. package/dist/esm/polyfills/css-shim.js +0 -1
  51. package/dist/esm/polyfills/dom.js +0 -79
  52. package/dist/esm/polyfills/es5-html-element.js +0 -1
  53. package/dist/esm/polyfills/index.js +0 -34
  54. package/dist/esm/polyfills/system.js +0 -6
  55. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +0 -2
  56. package/dist/user-action-controller/p-20213f37.js +0 -1
  57. package/dist/user-action-controller/p-2a14a5fe.entry.js +0 -1
@@ -1,210 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-5b463836.js');
6
-
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
-
9
- const GenericUserConsent = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.userLegislationConsent = index.createEvent(this, "userLegislationConsent", 7);
13
- /**
14
- * 'true' when parent expects component to emit it's current value
15
- */
16
- this.queried = false;
17
- /**
18
- * the type of the consent, used to determine render details
19
- */
20
- this.consentType = '';
21
- /**
22
- * wether or not this consent is mandatory. Used for render details
23
- */
24
- this.mandatory = false;
25
- /**
26
- * the title of the consent to be displayed
27
- */
28
- this.consentTitle = '';
29
- /**
30
- * link to the t&c page
31
- */
32
- this.tcLink = '#';
33
- /**
34
- * link to privacy policy page
35
- */
36
- this.privacyLink = '#';
37
- /**
38
- * the text content to be rendered by the component. Determined at runtime
39
- */
40
- this.textContent = '';
41
- // Maybe switch this out with a localization source
42
- this.stringVariants = {
43
- termsandconditions1: "I accept the ",
44
- termsandconditions2: ", I have read and understood the ",
45
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
46
- tc: "Terms and Conditions",
47
- privacy: "Privacy Policy",
48
- sms: "I consent to receive marketing communication via SMS.",
49
- emailmarketing: "I consent to receive marketing communication via Email."
50
- };
51
- }
52
- determineTextContent() {
53
- let result = this.consentType === 'termsandconditions' ?
54
- index.h("span", null, this.stringVariants['termsandconditions1'], index.h("a", { href: this.tcLink }, this.stringVariants['tc']), this.stringVariants['termsandconditions2'], index.h("a", { href: this.privacyLink }, this.stringVariants['privacy']), this.stringVariants['termsandconditions3'])
55
- : index.h("span", null, this.stringVariants[this.consentType]);
56
- return result;
57
- }
58
- userLegislationConsentHandler() {
59
- this.userLegislationConsent.emit({
60
- type: this.consentType,
61
- value: this.checkboxInput.checked
62
- });
63
- }
64
- render() {
65
- if (this.queried) {
66
- this.userLegislationConsentHandler();
67
- }
68
- this.textContent = this.determineTextContent();
69
- return (index.h("div", null, 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
- }
71
- };
72
- GenericUserConsent.style = genericUserConsentCss;
73
-
74
- const legislationWrapperCss = ":host{display:block}";
75
-
76
- const LegislationWrapper = class {
77
- constructor(hostRef) {
78
- index.registerInstance(this, hostRef);
79
- }
80
- render() {
81
- const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
82
- return (index.h("div", { class: "LegislationWrapper" }, activeUAList.map(action => (index.h("slot", { name: action })))));
83
- }
84
- };
85
- LegislationWrapper.style = legislationWrapperCss;
86
-
87
- 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
-
89
- const UserActionController = class {
90
- constructor(hostRef) {
91
- index.registerInstance(this, hostRef);
92
- this.closeButtonEvent = index.createEvent(this, "closeButtonClicked", 7);
93
- /**
94
- * Event name to be sent when the button is clicked
95
- */
96
- this.postMessageEvent = 'closeButtonClicked';
97
- this.consentTitles = {
98
- termsandconditions: "Terms and Conditions",
99
- sms: "SMS marketing",
100
- emailmarketing: "Email marketing"
101
- };
102
- /**
103
- * Which actions are required in order to activate the "Apply" button. Other actions are considered optional.
104
- */
105
- this.queryFired = false;
106
- this.readyActionsCount = 0;
107
- this.receivedQueryResponses = 0;
108
- this.mandatoryActions = ['termsandconditions'];
109
- this.requiredActionsCount = 0;
110
- this.expectedQueryResponses = 0;
111
- this.userActions = [];
112
- }
113
- determineMandatoryActions() {
114
- let url = new URL(`${this.endpoint}v1/player/consentRequirements`);
115
- return fetch(url.href)
116
- .then(res => res.json())
117
- .then(data => {
118
- data.items.forEach(action => {
119
- action.mustAccept && this.mandatoryActions.push(action.tagCode);
120
- });
121
- });
122
- }
123
- handleQueryResponse() {
124
- if (this.receivedQueryResponses === this.expectedQueryResponses) {
125
- this.updateUserConsents();
126
- }
127
- }
128
- updateUserConsents() {
129
- const url = new URL(`${this.endpoint}v1/player/${this.userId}/consent`);
130
- let body = {
131
- items: this.userActions
132
- };
133
- let options = {
134
- method: 'POST',
135
- headers: {
136
- 'Content-Type': 'application/json',
137
- 'Accept': 'application/json',
138
- 'X-SessionId': `${this.userSession}`,
139
- },
140
- body: JSON.stringify(body)
141
- };
142
- fetch(url.href, options)
143
- .then(res => res.json())
144
- .then(() => {
145
- /**
146
- * @TODO document this
147
- */
148
- window.postMessage({ type: 'WidgetNotification', data: {
149
- type: 'success',
150
- message: 'Consent update successfull!'
151
- } }, window.location.href);
152
- })
153
- .catch((err) => {
154
- /**
155
- * @TODO document this
156
- */
157
- window.postMessage({ type: 'WidgetNotification', data: {
158
- type: 'error',
159
- message: 'Server might not be responding',
160
- err
161
- } }, window.location.href);
162
- })
163
- .finally(() => {
164
- window.postMessage({ type: "UserActionsCompleted" }, window.location.href);
165
- });
166
- }
167
- handleApplyClick() {
168
- this.queryFired = true;
169
- }
170
- handleClose() {
171
- if (this.usePostmessage) {
172
- window.postMessage({ type: this.postMessageEvent });
173
- }
174
- this.closeButtonEvent.emit();
175
- }
176
- userLegislationConsentHandler(event) {
177
- // Increase / Decrease the amount of mandatory actions taken
178
- if (this.mandatoryActions.includes(event.detail.type)) {
179
- if (event.detail.value)
180
- this.readyActionsCount++;
181
- else
182
- this.readyActionsCount--;
183
- }
184
- // Register final user choices only if we're ready to update
185
- if (this.queryFired) {
186
- this.userActions.push({ tagCode: event.detail.type, status: event.detail.value ? 'Accepted' : 'Denied' });
187
- this.receivedQueryResponses++;
188
- }
189
- }
190
- // Returning a promise here will ensure that the fetch completes before we render the component
191
- componentWillLoad() {
192
- return this.determineMandatoryActions();
193
- }
194
- render() {
195
- const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
196
- this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
197
- this.expectedQueryResponses = activeUAList.length;
198
- return (index.h("div", { class: "QueryReferenceContainer" }, index.h("div", { class: "UserActionController" }, this.showCloseButton &&
199
- 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 }, activeUAList.map(item => (index.h("generic-user-consent", { slot: item, consentType: item, consentTitle: this.consentTitles[item], queried: this.queryFired, mandatory: this.mandatoryActions.includes(item) })))), this.includeSubmitButton &&
200
- index.h("button", { class: "ConsentSubmitButton", disabled: this.readyActionsCount === this.requiredActionsCount ? false : true, onClick: () => this.handleApplyClick() }, this.submitButtonText))));
201
- }
202
- static get watchers() { return {
203
- "receivedQueryResponses": ["handleQueryResponse"]
204
- }; }
205
- };
206
- UserActionController.style = userActionControllerCss;
207
-
208
- exports.generic_user_consent = GenericUserConsent;
209
- exports.legislation_wrapper = LegislationWrapper;
210
- exports.user_action_controller = UserActionController;