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