@everymatrix/general-preview-social-posts 1.16.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/general-preview-social-posts.cjs.entry.js +349 -0
  2. package/dist/cjs/general-preview-social-posts.cjs.js +19 -0
  3. package/dist/cjs/index-e178764e.js +1223 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/general-preview-social-posts/general-preview-social-posts.css +114 -0
  8. package/dist/collection/components/general-preview-social-posts/general-preview-social-posts.js +578 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/locale.utils.js +60 -0
  11. package/dist/collection/utils/utils.js +39 -0
  12. package/dist/components/general-preview-social-posts.d.ts +11 -0
  13. package/dist/components/general-preview-social-posts.js +384 -0
  14. package/dist/components/index.d.ts +26 -0
  15. package/dist/components/index.js +1 -0
  16. package/dist/esm/general-preview-social-posts.entry.js +345 -0
  17. package/dist/esm/general-preview-social-posts.js +17 -0
  18. package/dist/esm/index-8a671ab9.js +1197 -0
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/loader.js +17 -0
  21. package/dist/esm/polyfills/core-js.js +11 -0
  22. package/dist/esm/polyfills/css-shim.js +1 -0
  23. package/dist/esm/polyfills/dom.js +79 -0
  24. package/dist/esm/polyfills/es5-html-element.js +1 -0
  25. package/dist/esm/polyfills/index.js +34 -0
  26. package/dist/esm/polyfills/system.js +6 -0
  27. package/dist/general-preview-social-posts/general-preview-social-posts.esm.js +1 -0
  28. package/dist/general-preview-social-posts/index.esm.js +0 -0
  29. package/dist/general-preview-social-posts/p-b79fd2fe.entry.js +1 -0
  30. package/dist/general-preview-social-posts/p-c682801c.js +1 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/stencil.config.js +22 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-preview-social-posts/.stencil/packages/general-preview-social-posts/stencil.config.d.ts +2 -0
  35. package/dist/types/components/general-preview-social-posts/general-preview-social-posts.d.ts +84 -0
  36. package/dist/types/components.d.ts +152 -0
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  39. package/dist/types/utils/locale.utils.d.ts +2 -0
  40. package/dist/types/utils/utils.d.ts +9 -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,349 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-e178764e.js');
6
+
7
+ const DEFAULT_LANGUAGE = 'en';
8
+ const SUPPORTED_LANGUAGES = ['de', 'en'];
9
+ let TRANSLATIONS = {
10
+ en: {
11
+ loading: 'loading...',
12
+ viewAll: 'View All ...',
13
+ moreInfo: 'MORE INFO',
14
+ playNow: 'PLAY NOW',
15
+ },
16
+ de: {
17
+ loading: 'loading...',
18
+ viewAll: 'View All ...',
19
+ moreInfo: 'MORE INFO',
20
+ playNow: 'PLAY NOW',
21
+ },
22
+ ro: {
23
+ loading: 'loading...',
24
+ viewAll: 'View All ...',
25
+ moreInfo: 'MORE INFO',
26
+ playNow: 'PLAY NOW',
27
+ },
28
+ fr: {
29
+ loading: 'loading...',
30
+ viewAll: 'View All ...',
31
+ moreInfo: 'MORE INFO',
32
+ playNow: 'PLAY NOW',
33
+ },
34
+ ar: {
35
+ loading: 'loading...',
36
+ viewAll: 'View All ...',
37
+ moreInfo: 'MORE INFO',
38
+ playNow: 'PLAY NOW',
39
+ }
40
+ };
41
+ const getTranslations = (url) => {
42
+ // fetch url, get the data, replace the TRANSLATIONS content
43
+ return new Promise((resolve) => {
44
+ fetch(url)
45
+ .then((res) => res.json())
46
+ .then((data) => {
47
+ Object.keys(data).forEach((item) => {
48
+ for (let key in data[item]) {
49
+ TRANSLATIONS[item][key] = data[item][key];
50
+ }
51
+ });
52
+ resolve(true);
53
+ });
54
+ });
55
+ };
56
+ const translate = (key, customLang, values) => {
57
+ const lang = customLang;
58
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
59
+ if (values !== undefined) {
60
+ for (const [key, value] of Object.entries(values.values)) {
61
+ const regex = new RegExp(`{${key}}`, 'g');
62
+ translation = translation.replace(regex, value);
63
+ }
64
+ }
65
+ return translation;
66
+ };
67
+
68
+ /**
69
+ * @name isMobile
70
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
71
+ * @param {String} userAgent window.navigator.userAgent
72
+ * @returns {Boolean} true or false
73
+ */
74
+ const getDevice = () => {
75
+ let userAgent = window.navigator.userAgent;
76
+ if (userAgent.toLowerCase().match(/android/i)) {
77
+ return 'Android';
78
+ }
79
+ if (userAgent.toLowerCase().match(/iphone/i)) {
80
+ return 'iPhone';
81
+ }
82
+ if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
83
+ return 'iPad';
84
+ }
85
+ return 'PC';
86
+ };
87
+ const getDevicePlatform = () => {
88
+ const device = getDevice();
89
+ if (device) {
90
+ if (device === 'PC') {
91
+ return 'dk';
92
+ }
93
+ else if (device === 'iPad' || device === 'iPhone') {
94
+ return 'mtWeb';
95
+ }
96
+ else {
97
+ return 'mtWeb';
98
+ }
99
+ }
100
+ };
101
+
102
+ const generalPreviewSocialPostsCss = ":host {\n font-family: \"Roboto\", sans-serif;\n display: block;\n}\n\n.ModalContainer {\n container-type: inline-size;\n}\n\n.sliderWidget {\n display: block;\n max-width: 780px;\n margin: 0 auto;\n padding: 16px;\n max-height: 500px;\n}\n.sliderWidget h2 {\n font-size: 20px;\n}\n.sliderWidget .headerHontainer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n.sliderWidget .headerHontainer .viewAllButton {\n cursor: pointer;\n font-weight: bold;\n color: #8e8e8e;\n}\n.sliderWidget .postSlider {\n display: flex;\n overflow-x: auto;\n scroll-snap-type: x mandatory;\n gap: 24px;\n}\n.sliderWidget .postSlider .postCard {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n scroll-snap-align: start;\n padding: 20px;\n border-radius: 6px;\n min-width: 360px;\n background-color: #f4f4f4;\n}\n.sliderWidget .postSlider .postCard .Description {\n display: -webkit-box;\n -webkit-line-clamp: 5;\n -webkit-box-orient: vertical;\n overflow: hidden;\n margin-bottom: 14px;\n}\n.sliderWidget .postSlider .postCard .imageTitle {\n display: flex;\n justify-content: flex-start;\n gap: 20px;\n}\n.sliderWidget .postSlider .postCard .imageTitle img {\n height: 120px;\n width: 120px;\n border-radius: 6px;\n}\n.sliderWidget .postSlider .postCard .imageTitle .titleSubtitle {\n display: flex;\n flex-direction: column;\n}\n.sliderWidget .postSlider .postCard .buttons {\n display: flex;\n justify-content: center;\n gap: 12px;\n}\n.sliderWidget .postSlider .postCard .buttons .moreInfoButton, .sliderWidget .postSlider .postCard .buttons .playNowButton {\n width: 172px;\n display: block;\n padding: 8px 16px;\n border: 3px solid #63B250;\n border-radius: 6px;\n cursor: pointer;\n font-weight: bold;\n}\n.sliderWidget .postSlider .postCard .buttons .moreInfoButton {\n background-color: #f4f4f4;\n color: #63B250;\n}\n.sliderWidget .postSlider .postCard .buttons .playNowButton {\n background-color: #63B250;\n color: #fff;\n}\n\nh3, h4 {\n font-size: 18px;\n}\n\np {\n font-size: 14px;\n color: #5b5b5b;\n}\n\n@container (max-width: 480px) {\n .sliderWidget h2 {\n font-size: 18px;\n }\n .sliderWidget .postSlider .postCard {\n min-width: 250px;\n }\n\n h3, h4 {\n font-size: 16px;\n }\n\n p {\n font-size: 12px;\n }\n}";
103
+
104
+ const SocialSlider = class {
105
+ constructor(hostRef) {
106
+ index.registerInstance(this, hostRef);
107
+ this.moreInfo = index.createEvent(this, "moreInfo", 7);
108
+ this.playNow = index.createEvent(this, "playNow", 7);
109
+ this.viewAll = index.createEvent(this, "viewAll", 7);
110
+ /**
111
+ * The userId
112
+ */
113
+ this.userId = '';
114
+ /**
115
+ * The session
116
+ */
117
+ this.session = '';
118
+ /**
119
+ * The Posts Title
120
+ */
121
+ this.postsTitle = '';
122
+ /**
123
+ * The max cards displayed
124
+ */
125
+ this.maxCards = '';
126
+ /**
127
+ * The language
128
+ */
129
+ this.language = 'en';
130
+ /**
131
+ * The datasource
132
+ */
133
+ this.datasource = '';
134
+ /**
135
+ * The NorWAy endpoint
136
+ */
137
+ this.endpoint = '';
138
+ /**
139
+ * The NorWAy endpoint
140
+ */
141
+ this.cmsEndpoint = '';
142
+ /**
143
+ * The userRoles
144
+ */
145
+ this.userRoles = '';
146
+ /**
147
+ * The translationurl
148
+ */
149
+ this.translationUrl = '';
150
+ /**
151
+ * Client custom styling via string
152
+ */
153
+ this.clientStyling = '';
154
+ /**
155
+ * Client custom styling via url content
156
+ */
157
+ this.clientStylingUrl = '';
158
+ /**
159
+ * CMS Endpoint stage
160
+ */
161
+ this.cmsEnv = 'stage';
162
+ /**
163
+ * The page parameter for the cms call
164
+ */
165
+ this.pageName = 'casino';
166
+ this.posts = []; // State to store fetched posts
167
+ this.stylingAppends = false;
168
+ this.isLoading = false;
169
+ this.isLoggedIn = false;
170
+ this.dataImages = []; // State to store fetched images
171
+ this.gameIds = ''; // State to store fetched images
172
+ this.platform = getDevicePlatform();
173
+ this.setClientStyling = () => {
174
+ let sheet = document.createElement('style');
175
+ sheet.innerHTML = this.clientStyling;
176
+ this.stylingContainer.prepend(sheet);
177
+ };
178
+ this.setClientStylingURL = () => {
179
+ let url = new URL(this.clientStylingUrl);
180
+ let cssFile = document.createElement('style');
181
+ fetch(url.href)
182
+ .then((res) => res.text())
183
+ .then((data) => {
184
+ cssFile.innerHTML = data;
185
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
186
+ })
187
+ .catch((err) => {
188
+ console.log('error ', err);
189
+ });
190
+ };
191
+ }
192
+ handleNewTranslations() {
193
+ this.isLoading = true;
194
+ getTranslations(this.translationUrl).then(() => {
195
+ this.isLoading = false;
196
+ });
197
+ }
198
+ async componentWillLoad() {
199
+ if (this.translationUrl.length > 2) {
200
+ await getTranslations(this.translationUrl);
201
+ }
202
+ }
203
+ watchSession(newValue, oldValue) {
204
+ if (newValue !== oldValue) {
205
+ this.isLoggedIn = newValue !== '';
206
+ }
207
+ }
208
+ connectedCallback() {
209
+ if (this.session) {
210
+ this.isLoggedIn = true;
211
+ }
212
+ }
213
+ componentDidRender() {
214
+ // start custom styling area
215
+ if (!this.stylingAppends && this.stylingContainer) {
216
+ if (this.clientStyling)
217
+ this.setClientStyling();
218
+ if (this.clientStylingUrl)
219
+ this.setClientStylingURL();
220
+ this.stylingAppends = true;
221
+ }
222
+ // end custom styling area
223
+ }
224
+ getDataImage(ids) {
225
+ try {
226
+ let url = new URL(`${this.endpoint}/v2/casino/groups/${this.datasource}`);
227
+ url.searchParams.append("language", this.language);
228
+ url.searchParams.append("expand", 'games');
229
+ url.searchParams.append("fields", 'games(id,thumbnail,launchUrl)');
230
+ url.searchParams.append("filter", ids);
231
+ url.searchParams.append('device', this.platform);
232
+ const options = {
233
+ 'method': 'GET',
234
+ 'Content-Type': 'application/json'
235
+ };
236
+ fetch(url.href, options)
237
+ .then((res) => {
238
+ if (res.status === 200) {
239
+ return res.json();
240
+ }
241
+ else {
242
+ throw new Error("HTTP status " + res.status);
243
+ }
244
+ })
245
+ .then((data) => {
246
+ data.items.forEach((item) => {
247
+ item.games.items.forEach(element => {
248
+ let { id, launchUrl, thumbnail } = element;
249
+ this.dataImages = [{ id, launchUrl, thumbnail }];
250
+ let index = this.posts.findIndex(post => post.gameId === id);
251
+ if (index !== -1) {
252
+ this.posts[index].images = this.dataImages;
253
+ }
254
+ });
255
+ });
256
+ })
257
+ .catch((err) => {
258
+ // Handle any errors
259
+ console.error(err);
260
+ });
261
+ }
262
+ catch (error) {
263
+ console.error('Error fetching verification types:', error);
264
+ }
265
+ }
266
+ async componentDidLoad() {
267
+ try {
268
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/content/social-posts`);
269
+ url.searchParams.append("device", this.platform);
270
+ url.searchParams.append("page", this.pageName);
271
+ url.searchParams.append("language", this.language);
272
+ url.searchParams.append("userRoles", this.userRoles);
273
+ url.searchParams.append('env', this.cmsEnv);
274
+ const options = {
275
+ 'method': 'GET',
276
+ 'Content-Type': 'application/json'
277
+ };
278
+ fetch(url.href, options)
279
+ .then((res) => {
280
+ if (res.status === 200) {
281
+ return res.json();
282
+ }
283
+ else {
284
+ throw new Error("HTTP status " + res.status);
285
+ }
286
+ })
287
+ .then((data) => {
288
+ data.forEach(element => {
289
+ var _a;
290
+ const { gameId, title, description, subtitle } = (_a = element.previewCard) !== null && _a !== void 0 ? _a : {};
291
+ if (gameId) {
292
+ this.gameIds += `games(id=${gameId}),`;
293
+ }
294
+ this.posts.push({ gameId, title, description, subtitle });
295
+ });
296
+ if (this.gameIds.length > 0) {
297
+ this.gameIds = this.gameIds.slice(0, -1); // Removes the last comma
298
+ this.gameIds = '$or(' + this.gameIds + ')';
299
+ }
300
+ this.getDataImage(this.gameIds);
301
+ })
302
+ .catch((err) => {
303
+ // Handle any errors
304
+ console.error(err);
305
+ });
306
+ }
307
+ catch (error) {
308
+ console.error('Error fetching verification types:', error);
309
+ }
310
+ }
311
+ hasUndefinedValues(obj) {
312
+ return Object.values(obj).some((value) => value === undefined);
313
+ }
314
+ render() {
315
+ if (this.isLoading) {
316
+ return (index.h("div", null, index.h("p", null, translate('loading', this.language))));
317
+ }
318
+ else {
319
+ return (index.h("div", { class: "ModalContainer", ref: el => this.stylingContainer = el }, index.h("div", { class: "sliderWidget" }, index.h("div", { class: "headerHontainer" }, this.postsTitle && index.h("h2", null, this.postsTitle), index.h("div", { class: "viewAllButton", onClick: () => this.onViewAllClick() }, translate('viewAll', this.language))), index.h("div", { class: "postSlider" }, this.posts
320
+ .filter((post) => !this.hasUndefinedValues(post)) // Filter out posts with undefined values
321
+ .slice(0, +(this.maxCards || this.posts.length))
322
+ .map((post) => {
323
+ var _a, _b, _c, _d;
324
+ return (index.h("div", { class: "postCard" }, index.h("div", { class: "imageTitle" }, (post === null || post === void 0 ? void 0 : post.images) ? (index.h("a", { href: ((_b = (_a = post.images) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.launchUrl) || '', target: "_blank", rel: "noopener noreferrer" }, index.h("img", { src: ((_d = (_c = post.images) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.thumbnail) || '', alt: "Game Image" })))
325
+ : null, index.h("div", { class: "titleSubtitle" }, post.title && index.h("h3", null, post.title), post.subtitle && index.h("p", { innerHTML: post.subtitle }))), post.description &&
326
+ index.h("div", { class: "Description" }, index.h("p", { innerHTML: post.description })), index.h("div", { class: "buttons" }, index.h("button", { class: "moreInfoButton", onClick: () => this.onMoreInfoClick() }, translate('moreInfo', this.language)), this.isLoggedIn && post.gameId && index.h("button", { class: "playNowButton", onClick: () => this.onPlayNowClick(post.gameId) }, translate('playNow', this.language)))));
327
+ })))));
328
+ }
329
+ }
330
+ onViewAllClick() {
331
+ this.viewAll.emit();
332
+ window.postMessage({ type: 'viewAllSocialPosts' }, window.location.href);
333
+ }
334
+ onMoreInfoClick() {
335
+ this.moreInfo.emit();
336
+ window.postMessage({ type: 'moreInfoSocialPost' }, window.location.href);
337
+ }
338
+ onPlayNowClick(gameId) {
339
+ this.playNow.emit(gameId);
340
+ window.postMessage({ type: 'playNowSocialPost', gameId: gameId }, window.location.href);
341
+ }
342
+ static get watchers() { return {
343
+ "translationUrl": ["handleNewTranslations"],
344
+ "session": ["watchSession"]
345
+ }; }
346
+ };
347
+ SocialSlider.style = generalPreviewSocialPostsCss;
348
+
349
+ exports.general_preview_social_posts = SocialSlider;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-e178764e.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ const patchBrowser = () => {
9
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('general-preview-social-posts.cjs.js', document.baseURI).href));
10
+ const opts = {};
11
+ if (importMeta !== '') {
12
+ opts.resourcesUrl = new URL('.', importMeta).href;
13
+ }
14
+ return index.promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(options => {
18
+ return index.bootstrapLazy([["general-preview-social-posts.cjs",[[1,"general-preview-social-posts",{"userId":[513,"user-id"],"session":[513],"postsTitle":[513,"posts-title"],"maxCards":[513,"max-cards"],"language":[513],"datasource":[513],"endpoint":[513],"cmsEndpoint":[513,"cms-endpoint"],"userRoles":[513,"user-roles"],"translationUrl":[513,"translation-url"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"cmsEnv":[513,"cms-env"],"pageName":[513,"page-name"],"posts":[32],"stylingAppends":[32],"isLoading":[32],"isLoggedIn":[32],"dataImages":[32],"gameIds":[32]}]]]], options);
19
+ });