@everymatrix/temporary-consents 1.12.1

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 (47) hide show
  1. package/dist/cjs/index-51051de1.js +1163 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/temporary-consents.cjs.entry.js +180 -0
  5. package/dist/cjs/temporary-consents.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/temporary-consents/temporary-consents.css +58 -0
  8. package/dist/collection/components/temporary-consents/temporary-consents.js +296 -0
  9. package/dist/collection/components/temporary-consents/temporary-consents.type.js +1 -0
  10. package/dist/collection/index.js +1 -0
  11. package/dist/collection/utils/locale.utils.js +36 -0
  12. package/dist/components/index.d.ts +26 -0
  13. package/dist/components/index.js +1 -0
  14. package/dist/components/temporary-consents.d.ts +11 -0
  15. package/dist/components/temporary-consents.js +204 -0
  16. package/dist/esm/index-0f95c245.js +1138 -0
  17. package/dist/esm/index.js +1 -0
  18. package/dist/esm/loader.js +17 -0
  19. package/dist/esm/polyfills/core-js.js +11 -0
  20. package/dist/esm/polyfills/css-shim.js +1 -0
  21. package/dist/esm/polyfills/dom.js +79 -0
  22. package/dist/esm/polyfills/es5-html-element.js +1 -0
  23. package/dist/esm/polyfills/index.js +34 -0
  24. package/dist/esm/polyfills/system.js +6 -0
  25. package/dist/esm/temporary-consents.entry.js +176 -0
  26. package/dist/esm/temporary-consents.js +17 -0
  27. package/dist/index.cjs.js +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/stencil.config.js +22 -0
  30. package/dist/temporary-consents/index.esm.js +0 -0
  31. package/dist/temporary-consents/p-c2ffe442.entry.js +1 -0
  32. package/dist/temporary-consents/p-c8fa79f6.js +1 -0
  33. package/dist/temporary-consents/temporary-consents.esm.js +1 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/temporary-consents/.stencil/packages/temporary-consents/stencil.config.d.ts +2 -0
  35. package/dist/types/components/temporary-consents/temporary-consents.d.ts +48 -0
  36. package/dist/types/components/temporary-consents/temporary-consents.type.d.ts +6 -0
  37. package/dist/types/components.d.ts +101 -0
  38. package/dist/types/index.d.ts +1 -0
  39. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  40. package/dist/types/utils/locale.utils.d.ts +6 -0
  41. package/loader/cdn.js +3 -0
  42. package/loader/index.cjs.js +3 -0
  43. package/loader/index.d.ts +12 -0
  44. package/loader/index.es2017.js +3 -0
  45. package/loader/index.js +4 -0
  46. package/loader/package.json +10 -0
  47. package/package.json +19 -0
@@ -0,0 +1,204 @@
1
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
+
3
+ const DEFAULT_LANGUAGE = 'en';
4
+ const SUPPORTED_LANGUAGES = ['en'];
5
+ let TRANSLATIONS = {
6
+ en: {
7
+ title: 'Participation conditions',
8
+ description: 'Important: Full verification is required in order to be able to use our entire offer. If verification is not completed, it is not possible to withdraw and the betting account will be locked in {daysUntilLockout} days.',
9
+ declineButton: 'Decline and log out',
10
+ acceptButton: 'Accept',
11
+ loading: 'Please wait, loading...'
12
+ }
13
+ };
14
+ const getTranslations = (url) => {
15
+ return new Promise((resolve) => {
16
+ fetch(url)
17
+ .then((res) => res.json())
18
+ .then((data) => {
19
+ Object.keys(data).forEach((item) => {
20
+ for (let key in data[item]) {
21
+ TRANSLATIONS[item][key] = data[item][key];
22
+ }
23
+ });
24
+ resolve(true);
25
+ });
26
+ });
27
+ };
28
+ const translate = (key, customLang, values) => {
29
+ const lang = customLang;
30
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
31
+ if (values !== undefined) {
32
+ for (const [key, value] of Object.entries(values.values)) {
33
+ const regex = new RegExp(`{${key}}`, 'g');
34
+ translation = translation.replace(regex, value);
35
+ }
36
+ }
37
+ return translation;
38
+ };
39
+
40
+ const temporaryConsentsCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0}:host{display:block}.TemporaryConsents{max-width:500px;display:flex;gap:35px;flex-direction:column;box-shadow:0px 1px 5px 1px rgba(0, 0, 0, 0.1);padding:20px;font-family:sans-serif}.TemporaryConsentsTitle{text-align:left;font-family:inherit;color:#000;font-weight:400;font-size:18px;display:block;border-bottom:1px solid #000;padding-bottom:10px}.TemporaryConsentsText{font-family:inherit;font-weight:300;font-size:16px}.TemporaryConsentsButtonsWrapper{display:flex;justify-content:space-evenly;gap:50px}.TemporaryConsentsButton{font-family:inherit;font-weight:300;font-size:14px;border:none;padding:10px;min-width:150px;border-radius:4px}.TemporaryConsentsButtonDecline{background-color:transparent;border:1px solid #000}.TemporaryConsentsButtonAccept{color:white;background-color:#000}";
41
+
42
+ const TemporaryConsents$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
43
+ constructor() {
44
+ super();
45
+ this.__registerHost();
46
+ this.__attachShadow();
47
+ /**
48
+ * Client custom styling via inline styles
49
+ */
50
+ this.clientStyling = '';
51
+ /**
52
+ * Client custom styling via url
53
+ */
54
+ this.clientStylingUrl = '';
55
+ /**
56
+ * Translation via url
57
+ */
58
+ this.translationUrl = '';
59
+ this.stylingAppends = false;
60
+ this.isLoading = false;
61
+ this.setClientStyling = () => {
62
+ let sheet = document.createElement('style');
63
+ sheet.innerHTML = this.clientStyling;
64
+ this.stylingContainer.prepend(sheet);
65
+ };
66
+ this.setClientStylingURL = () => {
67
+ let url = new URL(this.clientStylingUrl);
68
+ let cssFile = document.createElement('style');
69
+ fetch(url.href)
70
+ .then((res) => res.text())
71
+ .then((data) => {
72
+ cssFile.innerHTML = data;
73
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
74
+ })
75
+ .catch((err) => {
76
+ console.log('error ', err);
77
+ });
78
+ };
79
+ }
80
+ componentWillLoad() {
81
+ const promises = [];
82
+ if (this.endpoint && this.userId) {
83
+ const consentsPromise = this.getConsents().then((consents) => {
84
+ this.temporaryAccountConsent = consents.consents.some((consent) => consent.tagCode == 'temporaryaccountconsent');
85
+ });
86
+ promises.push(consentsPromise);
87
+ }
88
+ if (this.translationUrl) {
89
+ const translationPromise = getTranslations(this.translationUrl);
90
+ promises.push(translationPromise);
91
+ }
92
+ return Promise.all(promises);
93
+ }
94
+ componentDidRender() {
95
+ // start custom styling area
96
+ if (!this.stylingAppends && this.stylingContainer) {
97
+ if (this.clientStyling)
98
+ this.setClientStyling();
99
+ if (this.clientStylingUrl)
100
+ this.setClientStylingURL();
101
+ this.stylingAppends = true;
102
+ }
103
+ // end custom styling area
104
+ }
105
+ getConsents() {
106
+ const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
107
+ const headers = new Headers();
108
+ headers.append('X-SessionId', this.sessionId);
109
+ headers.append('Accept', 'application/json');
110
+ const options = {
111
+ method: 'GET',
112
+ headers
113
+ };
114
+ return new Promise((resolve, reject) => {
115
+ this.isLoading = true;
116
+ fetch(url.href, options)
117
+ .then((res) => res.json())
118
+ .then((consents) => {
119
+ resolve(consents);
120
+ }).catch((err) => {
121
+ console.error(err);
122
+ reject(err);
123
+ }).finally(() => {
124
+ this.isLoading = false;
125
+ });
126
+ });
127
+ }
128
+ setConsents() {
129
+ const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
130
+ const headers = new Headers();
131
+ headers.append('X-SessionId', this.sessionId);
132
+ headers.append('Accept', 'application/json');
133
+ headers.append('Content-Type', 'application/json');
134
+ const body = {
135
+ consents: [{
136
+ tagCode: 'temporaryaccountconsent',
137
+ note: '',
138
+ status: 1
139
+ }]
140
+ };
141
+ const options = {
142
+ method: 'POST',
143
+ headers,
144
+ body: JSON.stringify(body)
145
+ };
146
+ return new Promise((resolve, reject) => {
147
+ this.isLoading = true;
148
+ fetch(url.href, options)
149
+ .then((res) => res.json())
150
+ .then((res) => {
151
+ resolve(res);
152
+ }).catch((err) => {
153
+ console.error(err);
154
+ reject(err);
155
+ }).finally(() => {
156
+ this.isLoading = false;
157
+ });
158
+ });
159
+ }
160
+ handleDecline() {
161
+ window.postMessage({ type: 'TemporaryConsentsDeclined' }, window.location.href);
162
+ }
163
+ handleAccept() {
164
+ this.setConsents();
165
+ window.postMessage({ type: 'TemporaryConsentsAccepted' }, window.location.href);
166
+ }
167
+ render() {
168
+ if (this.temporaryAccountConsent) {
169
+ if (this.isLoading) {
170
+ return h("p", null, translate('loading', this.lang));
171
+ }
172
+ return h("div", { class: 'TemporaryConsents', ref: el => this.stylingContainer = el }, h("h2", { class: 'TemporaryConsentsTitle' }, " ", translate('title', this.lang), " "), h("p", { class: 'TemporaryConsentsText' }, " ", translate('description', this.lang, { values: { daysUntilLockout: this.daysUntilLockout } }), " "), h("div", { class: 'TemporaryConsentsButtonsWrapper' }, h("button", { class: 'TemporaryConsentsButton TemporaryConsentsButtonDecline', onClick: () => this.handleDecline() }, translate('declineButton', this.lang)), h("button", { class: 'TemporaryConsentsButton TemporaryConsentsButtonAccept', onClick: this.handleAccept }, translate('acceptButton', this.lang))));
173
+ }
174
+ }
175
+ static get style() { return temporaryConsentsCss; }
176
+ }, [1, "temporary-consents", {
177
+ "endpoint": [513],
178
+ "userId": [513, "user-id"],
179
+ "sessionId": [513, "session-id"],
180
+ "daysUntilLockout": [513, "days-until-lockout"],
181
+ "lang": [513],
182
+ "clientStyling": [513, "client-styling"],
183
+ "clientStylingUrl": [513, "client-styling-url"],
184
+ "translationUrl": [513, "translation-url"],
185
+ "stylingAppends": [32]
186
+ }]);
187
+ function defineCustomElement$1() {
188
+ if (typeof customElements === "undefined") {
189
+ return;
190
+ }
191
+ const components = ["temporary-consents"];
192
+ components.forEach(tagName => { switch (tagName) {
193
+ case "temporary-consents":
194
+ if (!customElements.get(tagName)) {
195
+ customElements.define(tagName, TemporaryConsents$1);
196
+ }
197
+ break;
198
+ } });
199
+ }
200
+
201
+ const TemporaryConsents = TemporaryConsents$1;
202
+ const defineCustomElement = defineCustomElement$1;
203
+
204
+ export { TemporaryConsents, defineCustomElement };