@everymatrix/player-user-consents 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.
Files changed (46) hide show
  1. package/dist/cjs/index-e77a2edf.js +1215 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/player-user-consents.cjs.entry.js +178 -0
  5. package/dist/cjs/player-user-consents.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/player-user-consents/player-user-consents.css +28 -0
  8. package/dist/collection/components/player-user-consents/player-user-consents.js +250 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/utils.js +83 -0
  11. package/dist/components/index.d.ts +26 -0
  12. package/dist/components/index.js +1 -0
  13. package/dist/components/player-user-consents.d.ts +11 -0
  14. package/dist/components/player-user-consents.js +202 -0
  15. package/dist/esm/index-b34076ff.js +1189 -0
  16. package/dist/esm/index.js +1 -0
  17. package/dist/esm/loader.js +17 -0
  18. package/dist/esm/player-user-consents.entry.js +174 -0
  19. package/dist/esm/player-user-consents.js +17 -0
  20. package/dist/esm/polyfills/core-js.js +11 -0
  21. package/dist/esm/polyfills/css-shim.js +1 -0
  22. package/dist/esm/polyfills/dom.js +79 -0
  23. package/dist/esm/polyfills/es5-html-element.js +1 -0
  24. package/dist/esm/polyfills/index.js +34 -0
  25. package/dist/esm/polyfills/system.js +6 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/player-user-consents/index.esm.js +0 -0
  29. package/dist/player-user-consents/p-6a20deb9.entry.js +1 -0
  30. package/dist/player-user-consents/p-b1139724.js +1 -0
  31. package/dist/player-user-consents/player-user-consents.esm.js +1 -0
  32. package/dist/stencil.config.js +22 -0
  33. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/player-user-consents/.stencil/packages/player-user-consents/stencil.config.d.ts +2 -0
  34. package/dist/types/components/player-user-consents/player-user-consents.d.ts +48 -0
  35. package/dist/types/components.d.ts +94 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  38. package/dist/types/utils/utils.d.ts +2 -0
  39. package/loader/cdn.js +3 -0
  40. package/loader/index.cjs.js +3 -0
  41. package/loader/index.d.ts +12 -0
  42. package/loader/index.es2017.js +3 -0
  43. package/loader/index.js +4 -0
  44. package/loader/package.json +10 -0
  45. package/package.json +2 -3
  46. package/LICENSE +0 -21
@@ -0,0 +1,202 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+
3
+ const DEFAULT_LANGUAGE = 'en';
4
+ const TRANSLATIONS = {
5
+ en: {
6
+ termsandconditions1: "I accept the ",
7
+ termsandconditions2: ", I have read and understood the ",
8
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
9
+ tc: "Terms and Conditions",
10
+ privacy: "Privacy Policy",
11
+ sms: "I consent to receive marketing communication via SMS.",
12
+ emailmarketing: "I consent to receive marketing communication via Email."
13
+ },
14
+ ro: {
15
+ termsandconditions1: "I accept the ",
16
+ termsandconditions2: ", I have read and understood the ",
17
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
18
+ tc: "Terms and Conditions",
19
+ privacy: "Privacy Policy",
20
+ sms: "I consent to receive marketing communication via SMS.",
21
+ emailmarketing: "I consent to receive marketing communication via Email."
22
+ },
23
+ hr: {
24
+ termsandconditions1: "I accept the ",
25
+ termsandconditions2: ", I have read and understood the ",
26
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
27
+ tc: "Terms and Conditions",
28
+ privacy: "Privacy Policy",
29
+ sms: "I consent to receive marketing communication via SMS.",
30
+ emailmarketing: "I consent to receive marketing communication via Email."
31
+ },
32
+ fr: {
33
+ termsandconditions1: "I accept the ",
34
+ termsandconditions2: ", I have read and understood the ",
35
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
36
+ tc: "Terms and Conditions",
37
+ privacy: "Privacy Policy",
38
+ sms: "I consent to receive marketing communication via SMS.",
39
+ emailmarketing: "I consent to receive marketing communication via Email."
40
+ },
41
+ cs: {
42
+ termsandconditions1: "I accept the ",
43
+ termsandconditions2: ", I have read and understood the ",
44
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
45
+ tc: "Terms and Conditions",
46
+ privacy: "Privacy Policy",
47
+ sms: "I consent to receive marketing communication via SMS.",
48
+ emailmarketing: "I consent to receive marketing communication via Email."
49
+ },
50
+ de: {
51
+ termsandconditions1: "I accept the ",
52
+ termsandconditions2: ", I have read and understood the ",
53
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
54
+ tc: "Terms and Conditions",
55
+ privacy: "Privacy Policy",
56
+ sms: "I consent to receive marketing communication via SMS.",
57
+ emailmarketing: "I consent to receive marketing communication via Email."
58
+ },
59
+ };
60
+ const getTranslations = (url) => {
61
+ // fetch url, get the data, replace the TRANSLATIONS content
62
+ return new Promise((resolve) => {
63
+ fetch(url)
64
+ .then((res) => res.json())
65
+ .then((data) => {
66
+ Object.keys(data).forEach((item) => {
67
+ for (let key in data[item]) {
68
+ TRANSLATIONS[item][key] = data[item][key];
69
+ }
70
+ });
71
+ resolve(true);
72
+ });
73
+ });
74
+ };
75
+ const translate = (key, customLang, values) => {
76
+ const lang = customLang;
77
+ let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
78
+ if (values !== undefined) {
79
+ for (const [key, value] of Object.entries(values.values)) {
80
+ const regex = new RegExp(`{${key}}`, 'g');
81
+ translation = translation.replace(regex, value);
82
+ }
83
+ }
84
+ return translation;
85
+ };
86
+
87
+ const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.UserConsent:hover{cursor:pointer}.UserConsent{display:flex;align-items:baseline}.MandatoryItem{color:#f00;font-size:1.2rem}.ConsentLink{text-decoration:underline;color:var(--emfe-w-color-primary);font-weight:bold}";
88
+
89
+ const PlayerUserConsents$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
90
+ constructor() {
91
+ super();
92
+ this.__registerHost();
93
+ this.__attachShadow();
94
+ this.userLegislationConsent = createEvent(this, "userLegislationConsent", 7);
95
+ /**
96
+ * Language
97
+ */
98
+ this.lang = 'en';
99
+ /**
100
+ * 'true' when parent expects component to emit it's current value
101
+ */
102
+ this.queried = false;
103
+ /**
104
+ * the type of the consent, used to determine render details
105
+ */
106
+ this.consentType = '';
107
+ /**
108
+ * wether or not this consent is mandatory. Used for render details
109
+ */
110
+ this.mandatory = false;
111
+ /**
112
+ * the title of the consent to be displayed
113
+ */
114
+ this.consentTitle = '';
115
+ /**
116
+ * Client custom styling via inline style
117
+ */
118
+ this.clientStyling = '';
119
+ /**
120
+ * Translation url
121
+ */
122
+ this.translationUrl = '';
123
+ /**
124
+ * the text content to be rendered by the component. Determined at runtime
125
+ */
126
+ this.textContent = '';
127
+ this.limitStylingAppends = false;
128
+ this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
129
+ this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
130
+ this.setClientStyling = () => {
131
+ let sheet = document.createElement('style');
132
+ sheet.innerHTML = this.clientStyling;
133
+ this.stylingContainer.prepend(sheet);
134
+ };
135
+ }
136
+ handleNewTranslations() {
137
+ getTranslations(this.translationUrl);
138
+ }
139
+ async componentWillLoad() {
140
+ if (this.translationUrl.length > 2) {
141
+ await getTranslations(this.translationUrl);
142
+ }
143
+ }
144
+ userLegislationConsentHandler() {
145
+ this.userLegislationConsent.emit({
146
+ type: this.consentType,
147
+ value: this.checkboxInput.checked
148
+ });
149
+ }
150
+ componentDidRender() {
151
+ // start custom styling area
152
+ if (!this.limitStylingAppends && this.stylingContainer) {
153
+ if (this.clientStyling)
154
+ this.setClientStyling();
155
+ this.limitStylingAppends = true;
156
+ }
157
+ // end custom styling area
158
+ }
159
+ determineTextContent() {
160
+ return this.consentType === 'termsandconditions' ?
161
+ h("p", null, translate('termsandconditions1', this.lang), h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate('tc', this.lang)), translate('termsandconditions2', this.lang), h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate('privacy', this.lang)), translate('termsandconditions3', this.lang))
162
+ : h("p", null, translate('consentType', this.lang));
163
+ }
164
+ render() {
165
+ if (this.queried) {
166
+ this.userLegislationConsentHandler();
167
+ }
168
+ 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.determineTextContent(), this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
169
+ }
170
+ static get watchers() { return {
171
+ "translationUrl": ["handleNewTranslations"]
172
+ }; }
173
+ static get style() { return playerUserConsentsCss; }
174
+ }, [1, "player-user-consents", {
175
+ "lang": [1537],
176
+ "queried": [516],
177
+ "consentType": [513, "consent-type"],
178
+ "mandatory": [516],
179
+ "consentTitle": [513, "consent-title"],
180
+ "clientStyling": [1, "client-styling"],
181
+ "translationUrl": [513, "translation-url"],
182
+ "textContent": [32],
183
+ "limitStylingAppends": [32]
184
+ }]);
185
+ function defineCustomElement$1() {
186
+ if (typeof customElements === "undefined") {
187
+ return;
188
+ }
189
+ const components = ["player-user-consents"];
190
+ components.forEach(tagName => { switch (tagName) {
191
+ case "player-user-consents":
192
+ if (!customElements.get(tagName)) {
193
+ customElements.define(tagName, PlayerUserConsents$1);
194
+ }
195
+ break;
196
+ } });
197
+ }
198
+
199
+ const PlayerUserConsents = PlayerUserConsents$1;
200
+ const defineCustomElement = defineCustomElement$1;
201
+
202
+ export { PlayerUserConsents, defineCustomElement };