@everymatrix/general-preview-social-posts 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 (44) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/general-preview-social-posts.cjs.entry.js +322 -0
  3. package/dist/cjs/general-preview-social-posts.cjs.js +25 -0
  4. package/dist/cjs/index-3a1dd540.js +1200 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +15 -0
  7. package/dist/collection/collection-manifest.json +12 -0
  8. package/dist/collection/components/general-preview-social-posts/general-preview-social-posts.css +112 -0
  9. package/dist/collection/components/general-preview-social-posts/general-preview-social-posts.js +533 -0
  10. package/dist/collection/components/general-preview-social-posts/index.js +1 -0
  11. package/dist/collection/index.js +1 -0
  12. package/dist/collection/utils/locale.utils.js +66 -0
  13. package/dist/collection/utils/utils.js +45 -0
  14. package/dist/esm/app-globals-0f993ce5.js +3 -0
  15. package/dist/esm/general-preview-social-posts.entry.js +318 -0
  16. package/dist/esm/general-preview-social-posts.js +20 -0
  17. package/dist/esm/index-16f33f52.js +1173 -0
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/loader.js +11 -0
  20. package/dist/general-preview-social-posts/general-preview-social-posts.esm.js +1 -0
  21. package/dist/general-preview-social-posts/index.esm.js +0 -0
  22. package/dist/general-preview-social-posts/p-1f296318.js +2 -0
  23. package/dist/general-preview-social-posts/p-5434bb4a.entry.js +1 -0
  24. package/dist/general-preview-social-posts/p-e1255160.js +1 -0
  25. package/dist/index.cjs.js +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/stencil.config.dev.js +17 -0
  28. package/dist/stencil.config.js +17 -0
  29. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/general-preview-social-posts/.stencil/packages/stencil/general-preview-social-posts/stencil.config.d.ts +2 -0
  30. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/general-preview-social-posts/.stencil/packages/stencil/general-preview-social-posts/stencil.config.dev.d.ts +2 -0
  31. package/dist/types/components/general-preview-social-posts/general-preview-social-posts.d.ts +84 -0
  32. package/dist/types/components/general-preview-social-posts/index.d.ts +1 -0
  33. package/dist/types/components.d.ts +169 -0
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  36. package/dist/types/utils/locale.utils.d.ts +2 -0
  37. package/dist/types/utils/utils.d.ts +9 -0
  38. package/loader/cdn.js +1 -0
  39. package/loader/index.cjs.js +1 -0
  40. package/loader/index.d.ts +24 -0
  41. package/loader/index.es2017.js +1 -0
  42. package/loader/index.js +2 -0
  43. package/loader/package.json +11 -0
  44. package/package.json +26 -0
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const globalScripts = () => {};
4
+
5
+ exports.globalScripts = globalScripts;
@@ -0,0 +1,322 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-3a1dd540.js');
6
+
7
+ const DEFAULT_LANGUAGE = 'en';
8
+ const SUPPORTED_LANGUAGES = ['de', 'en', 'hr'];
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
+ hr: {
41
+ loading: 'Učitavanje…',
42
+ viewAll: 'Pogledaj sve …',
43
+ moreInfo: 'VIŠE INFORMACIJA',
44
+ playNow: 'IGRAJ SADA'
45
+ }
46
+ };
47
+ const getTranslations = (url) => {
48
+ // fetch url, get the data, replace the TRANSLATIONS content
49
+ return new Promise((resolve) => {
50
+ fetch(url)
51
+ .then((res) => res.json())
52
+ .then((data) => {
53
+ Object.keys(data).forEach((item) => {
54
+ for (let key in data[item]) {
55
+ TRANSLATIONS[item][key] = data[item][key];
56
+ }
57
+ });
58
+ resolve(true);
59
+ });
60
+ });
61
+ };
62
+ const translate = (key, customLang, values) => {
63
+ const lang = customLang;
64
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
65
+ if (values !== undefined) {
66
+ for (const [key, value] of Object.entries(values.values)) {
67
+ const regex = new RegExp(`{${key}}`, 'g');
68
+ translation = translation.replace(regex, value);
69
+ }
70
+ }
71
+ return translation;
72
+ };
73
+
74
+ /**
75
+ * @name isMobile
76
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
77
+ * @param {String} userAgent window.navigator.userAgent
78
+ * @returns {Boolean} true or false
79
+ */
80
+ const getDevice = () => {
81
+ let userAgent = window.navigator.userAgent;
82
+ if (userAgent.toLowerCase().match(/android/i)) {
83
+ return 'Android';
84
+ }
85
+ if (userAgent.toLocaleLowerCase().match(/customnative:ios/)) {
86
+ return 'nativeIOS';
87
+ }
88
+ if (userAgent.toLowerCase().match(/iphone/i)) {
89
+ return 'iPhone';
90
+ }
91
+ if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
92
+ return 'iPad';
93
+ }
94
+ return 'PC';
95
+ };
96
+ const getDevicePlatform = () => {
97
+ const device = getDevice();
98
+ if (device) {
99
+ if (device === 'PC') {
100
+ return 'dk';
101
+ }
102
+ else if (device == 'nativeIOS') {
103
+ return 'ios';
104
+ }
105
+ else if (device === 'iPad' || device === 'iPhone') {
106
+ return 'mtWeb';
107
+ }
108
+ else {
109
+ return 'mtWeb';
110
+ }
111
+ }
112
+ };
113
+
114
+ 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: rgb(142, 142, 142);\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: rgb(244, 244, 244);\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: rgb(244, 244, 244);\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: rgb(91, 91, 91);\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 h3, h4 {\n font-size: 16px;\n }\n p {\n font-size: 12px;\n }\n}";
115
+ const GeneralPreviewSocialPostsStyle0 = generalPreviewSocialPostsCss;
116
+
117
+ const GeneralPreviewSocialPosts = class {
118
+ constructor(hostRef) {
119
+ index.registerInstance(this, hostRef);
120
+ this.moreInfo = index.createEvent(this, "moreInfo", 7);
121
+ this.playNow = index.createEvent(this, "playNow", 7);
122
+ this.viewAll = index.createEvent(this, "viewAll", 7);
123
+ this.platform = getDevicePlatform();
124
+ this.setClientStyling = () => {
125
+ let sheet = document.createElement('style');
126
+ sheet.innerHTML = this.clientStyling;
127
+ this.stylingContainer.prepend(sheet);
128
+ };
129
+ this.setClientStylingURL = () => {
130
+ let url = new URL(this.clientStylingUrl);
131
+ let cssFile = document.createElement('style');
132
+ fetch(url.href)
133
+ .then((res) => res.text())
134
+ .then((data) => {
135
+ cssFile.innerHTML = data;
136
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
137
+ })
138
+ .catch((err) => {
139
+ console.log('error ', err);
140
+ });
141
+ };
142
+ this.userId = '';
143
+ this.session = '';
144
+ this.postsTitle = '';
145
+ this.maxCards = '';
146
+ this.language = 'en';
147
+ this.datasource = '';
148
+ this.endpoint = '';
149
+ this.cmsEndpoint = '';
150
+ this.userRoles = '';
151
+ this.translationUrl = '';
152
+ this.clientStyling = '';
153
+ this.clientStylingUrl = '';
154
+ this.cmsEnv = 'stage';
155
+ this.pageName = 'casino';
156
+ this.posts = [];
157
+ this.stylingAppends = false;
158
+ this.isLoading = false;
159
+ this.isLoggedIn = false;
160
+ this.dataImages = [];
161
+ this.gameIds = '';
162
+ }
163
+ handleNewTranslations() {
164
+ this.isLoading = true;
165
+ getTranslations(this.translationUrl).then(() => {
166
+ this.isLoading = false;
167
+ });
168
+ }
169
+ async componentWillLoad() {
170
+ if (this.translationUrl.length > 2) {
171
+ await getTranslations(this.translationUrl);
172
+ }
173
+ }
174
+ watchSession(newValue, oldValue) {
175
+ if (newValue !== oldValue) {
176
+ this.isLoggedIn = newValue !== '';
177
+ }
178
+ }
179
+ connectedCallback() {
180
+ if (this.session) {
181
+ this.isLoggedIn = true;
182
+ }
183
+ }
184
+ componentDidRender() {
185
+ // start custom styling area
186
+ if (!this.stylingAppends && this.stylingContainer) {
187
+ if (this.clientStyling)
188
+ this.setClientStyling();
189
+ if (this.clientStylingUrl)
190
+ this.setClientStylingURL();
191
+ this.stylingAppends = true;
192
+ }
193
+ // end custom styling area
194
+ }
195
+ getDataImage(ids) {
196
+ try {
197
+ let url = new URL(`${this.endpoint}/v2/casino/groups/${this.datasource}`);
198
+ url.searchParams.append("language", this.language);
199
+ url.searchParams.append("expand", 'games');
200
+ url.searchParams.append("fields", 'games(id,thumbnail,launchUrl)');
201
+ url.searchParams.append("filter", ids);
202
+ url.searchParams.append('device', this.platform);
203
+ const options = {
204
+ 'method': 'GET',
205
+ 'Content-Type': 'application/json'
206
+ };
207
+ fetch(url.href, options)
208
+ .then((res) => {
209
+ if (res.status === 200) {
210
+ return res.json();
211
+ }
212
+ else {
213
+ throw new Error("HTTP status " + res.status);
214
+ }
215
+ })
216
+ .then((data) => {
217
+ data.items.forEach((item) => {
218
+ item.games.items.forEach(element => {
219
+ let { id, launchUrl, thumbnail } = element;
220
+ this.dataImages = [{ id, launchUrl, thumbnail }];
221
+ let index = this.posts.findIndex(post => post.gameId === id);
222
+ if (index !== -1) {
223
+ this.posts[index].images = this.dataImages;
224
+ }
225
+ });
226
+ });
227
+ })
228
+ .catch((err) => {
229
+ // Handle any errors
230
+ console.error(err);
231
+ });
232
+ }
233
+ catch (error) {
234
+ console.error('Error fetching verification types:', error);
235
+ }
236
+ }
237
+ async componentDidLoad() {
238
+ try {
239
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/content/social-posts`);
240
+ url.searchParams.append("device", this.platform);
241
+ url.searchParams.append("page", this.pageName);
242
+ url.searchParams.append("language", this.language);
243
+ url.searchParams.append("userRoles", this.userRoles);
244
+ url.searchParams.append('env', this.cmsEnv);
245
+ const options = {
246
+ 'method': 'GET',
247
+ 'Content-Type': 'application/json'
248
+ };
249
+ fetch(url.href, options)
250
+ .then((res) => {
251
+ if (res.status === 200) {
252
+ return res.json();
253
+ }
254
+ else {
255
+ throw new Error("HTTP status " + res.status);
256
+ }
257
+ })
258
+ .then((data) => {
259
+ data.forEach(element => {
260
+ var _a;
261
+ const slug = element.slug;
262
+ const postId = element.id;
263
+ const { gameId, title, description, subtitle } = (_a = element.previewCard) !== null && _a !== void 0 ? _a : {};
264
+ if (gameId) {
265
+ this.gameIds += `games(id=${gameId}),`;
266
+ }
267
+ this.posts.push({ postId, gameId, title, description, subtitle, slug });
268
+ });
269
+ if (this.gameIds.length > 0) {
270
+ this.gameIds = this.gameIds.slice(0, -1); // Removes the last comma
271
+ this.gameIds = '$or(' + this.gameIds + ')';
272
+ }
273
+ this.getDataImage(this.gameIds);
274
+ })
275
+ .catch((err) => {
276
+ // Handle any errors
277
+ console.error(err);
278
+ });
279
+ }
280
+ catch (error) {
281
+ console.error('Error fetching verification types:', error);
282
+ }
283
+ }
284
+ hasUndefinedValues(obj) {
285
+ return Object.values(obj).some((value) => value === undefined);
286
+ }
287
+ render() {
288
+ if (this.isLoading) {
289
+ return (index.h("div", null, index.h("p", null, translate('loading', this.language))));
290
+ }
291
+ else {
292
+ 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
293
+ .filter((post) => !this.hasUndefinedValues(post)) // Filter out posts with undefined values
294
+ .slice(0, +(this.maxCards || this.posts.length))
295
+ .map((post) => {
296
+ var _a, _b, _c, _d;
297
+ 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" })))
298
+ : null, index.h("div", { class: "titleSubtitle" }, post.title && index.h("h3", null, post.title), post.subtitle && index.h("p", { innerHTML: post.subtitle }))), post.description &&
299
+ index.h("div", { class: "Description" }, index.h("p", { innerHTML: post.description })), index.h("div", { class: "buttons" }, index.h("button", { class: "moreInfoButton", onClick: () => this.onMoreInfoClick(post.gameId, post.postId, post.title, post.slug) }, translate('moreInfo', this.language)), this.isLoggedIn && post.gameId && index.h("button", { class: "playNowButton", onClick: () => this.onPlayNowClick(post.gameId) }, translate('playNow', this.language)))));
300
+ })))));
301
+ }
302
+ }
303
+ onViewAllClick() {
304
+ this.viewAll.emit();
305
+ window.postMessage({ type: 'viewAllSocialPosts' }, window.location.href);
306
+ }
307
+ onMoreInfoClick(gameId, postId, postTitle, slug) {
308
+ this.moreInfo.emit();
309
+ window.postMessage({ type: 'moreInfoSocialPost', gameId, postId, postTitle, slug }, window.location.href);
310
+ }
311
+ onPlayNowClick(gameId) {
312
+ this.playNow.emit(gameId);
313
+ window.postMessage({ type: 'playNowSocialPost', gameId: gameId }, window.location.href);
314
+ }
315
+ static get watchers() { return {
316
+ "translationUrl": ["handleNewTranslations"],
317
+ "session": ["watchSession"]
318
+ }; }
319
+ };
320
+ GeneralPreviewSocialPosts.style = GeneralPreviewSocialPostsStyle0;
321
+
322
+ exports.general_preview_social_posts = GeneralPreviewSocialPosts;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-3a1dd540.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ /*
9
+ Stencil Client Patch Browser v4.20.0 | MIT Licensed | https://stenciljs.com
10
+ */
11
+ var patchBrowser = () => {
12
+ 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));
13
+ const opts = {};
14
+ if (importMeta !== "") {
15
+ opts.resourcesUrl = new URL(".", importMeta).href;
16
+ }
17
+ return index.promiseResolve(opts);
18
+ };
19
+
20
+ patchBrowser().then(async (options) => {
21
+ await appGlobals.globalScripts();
22
+ 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]},null,{"translationUrl":["handleNewTranslations"],"session":["watchSession"]}]]]], options);
23
+ });
24
+
25
+ exports.setNonce = index.setNonce;