@everymatrix/general-preview-social-posts 1.31.2 → 1.32.4

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +3 -2
  3. package/dist/cjs/general-preview-social-posts.cjs.entry.js +0 -363
  4. package/dist/cjs/general-preview-social-posts.cjs.js +0 -19
  5. package/dist/cjs/index-e178764e.js +0 -1223
  6. package/dist/cjs/index.cjs.js +0 -2
  7. package/dist/cjs/loader.cjs.js +0 -21
  8. package/dist/collection/collection-manifest.json +0 -12
  9. package/dist/collection/components/general-preview-social-posts/general-preview-social-posts.css +0 -114
  10. package/dist/collection/components/general-preview-social-posts/general-preview-social-posts.js +0 -580
  11. package/dist/collection/index.js +0 -1
  12. package/dist/collection/utils/locale.utils.js +0 -66
  13. package/dist/collection/utils/utils.js +0 -45
  14. package/dist/components/general-preview-social-posts.d.ts +0 -11
  15. package/dist/components/general-preview-social-posts.js +0 -398
  16. package/dist/components/index.d.ts +0 -26
  17. package/dist/components/index.js +0 -1
  18. package/dist/esm/general-preview-social-posts.entry.js +0 -359
  19. package/dist/esm/general-preview-social-posts.js +0 -17
  20. package/dist/esm/index-8a671ab9.js +0 -1197
  21. package/dist/esm/index.js +0 -1
  22. package/dist/esm/loader.js +0 -17
  23. package/dist/esm/polyfills/core-js.js +0 -11
  24. package/dist/esm/polyfills/css-shim.js +0 -1
  25. package/dist/esm/polyfills/dom.js +0 -79
  26. package/dist/esm/polyfills/es5-html-element.js +0 -1
  27. package/dist/esm/polyfills/index.js +0 -34
  28. package/dist/esm/polyfills/system.js +0 -6
  29. package/dist/general-preview-social-posts/general-preview-social-posts.esm.js +0 -1
  30. package/dist/general-preview-social-posts/index.esm.js +0 -0
  31. package/dist/general-preview-social-posts/p-c682801c.js +0 -1
  32. package/dist/general-preview-social-posts/p-e80aaa1d.entry.js +0 -1
  33. package/dist/index.cjs.js +0 -1
  34. package/dist/index.js +0 -1
  35. package/dist/stencil.config.js +0 -22
  36. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/general-preview-social-posts/.stencil/packages/general-preview-social-posts/stencil.config.d.ts +0 -2
  37. package/dist/types/components/general-preview-social-posts/general-preview-social-posts.d.ts +0 -84
  38. package/dist/types/components.d.ts +0 -152
  39. package/dist/types/index.d.ts +0 -1
  40. package/dist/types/stencil-public-runtime.d.ts +0 -1565
  41. package/dist/types/utils/locale.utils.d.ts +0 -2
  42. package/dist/types/utils/utils.d.ts +0 -9
  43. package/loader/cdn.js +0 -3
  44. package/loader/index.cjs.js +0 -3
  45. package/loader/index.d.ts +0 -12
  46. package/loader/index.es2017.js +0 -3
  47. package/loader/index.js +0 -4
  48. package/loader/package.json +0 -10
@@ -1,398 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
-
3
- const DEFAULT_LANGUAGE = 'en';
4
- const SUPPORTED_LANGUAGES = ['de', 'en', 'hr'];
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
- hr: {
37
- loading: 'Učitavanje…',
38
- viewAll: 'Pogledaj sve …',
39
- moreInfo: 'VIŠE INFORMACIJA',
40
- playNow: 'IGRAJ SADA'
41
- }
42
- };
43
- const getTranslations = (url) => {
44
- // fetch url, get the data, replace the TRANSLATIONS content
45
- return new Promise((resolve) => {
46
- fetch(url)
47
- .then((res) => res.json())
48
- .then((data) => {
49
- Object.keys(data).forEach((item) => {
50
- for (let key in data[item]) {
51
- TRANSLATIONS[item][key] = data[item][key];
52
- }
53
- });
54
- resolve(true);
55
- });
56
- });
57
- };
58
- const translate = (key, customLang, values) => {
59
- const lang = customLang;
60
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
61
- if (values !== undefined) {
62
- for (const [key, value] of Object.entries(values.values)) {
63
- const regex = new RegExp(`{${key}}`, 'g');
64
- translation = translation.replace(regex, value);
65
- }
66
- }
67
- return translation;
68
- };
69
-
70
- /**
71
- * @name isMobile
72
- * @description A method that returns if the browser used to access the app is from a mobile device or not
73
- * @param {String} userAgent window.navigator.userAgent
74
- * @returns {Boolean} true or false
75
- */
76
- const getDevice = () => {
77
- let userAgent = window.navigator.userAgent;
78
- if (userAgent.toLowerCase().match(/android/i)) {
79
- return 'Android';
80
- }
81
- if (userAgent.toLocaleLowerCase().match(/customnative:ios/)) {
82
- return 'nativeIOS';
83
- }
84
- if (userAgent.toLowerCase().match(/iphone/i)) {
85
- return 'iPhone';
86
- }
87
- if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
88
- return 'iPad';
89
- }
90
- return 'PC';
91
- };
92
- const getDevicePlatform = () => {
93
- const device = getDevice();
94
- if (device) {
95
- if (device === 'PC') {
96
- return 'dk';
97
- }
98
- else if (device == 'nativeIOS') {
99
- return 'ios';
100
- }
101
- else if (device === 'iPad' || device === 'iPhone') {
102
- return 'mtWeb';
103
- }
104
- else {
105
- return 'mtWeb';
106
- }
107
- }
108
- };
109
-
110
- 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}";
111
-
112
- const SocialSlider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
113
- constructor() {
114
- super();
115
- this.__registerHost();
116
- this.__attachShadow();
117
- this.moreInfo = createEvent(this, "moreInfo", 7);
118
- this.playNow = createEvent(this, "playNow", 7);
119
- this.viewAll = createEvent(this, "viewAll", 7);
120
- /**
121
- * The userId
122
- */
123
- this.userId = '';
124
- /**
125
- * The session
126
- */
127
- this.session = '';
128
- /**
129
- * The Posts Title
130
- */
131
- this.postsTitle = '';
132
- /**
133
- * The max cards displayed
134
- */
135
- this.maxCards = '';
136
- /**
137
- * The language
138
- */
139
- this.language = 'en';
140
- /**
141
- * The datasource
142
- */
143
- this.datasource = '';
144
- /**
145
- * The NorWAy endpoint
146
- */
147
- this.endpoint = '';
148
- /**
149
- * The NorWAy endpoint
150
- */
151
- this.cmsEndpoint = '';
152
- /**
153
- * The userRoles
154
- */
155
- this.userRoles = '';
156
- /**
157
- * The translationurl
158
- */
159
- this.translationUrl = '';
160
- /**
161
- * Client custom styling via string
162
- */
163
- this.clientStyling = '';
164
- /**
165
- * Client custom styling via url content
166
- */
167
- this.clientStylingUrl = '';
168
- /**
169
- * CMS Endpoint stage
170
- */
171
- this.cmsEnv = 'stage';
172
- /**
173
- * The page parameter for the cms call
174
- */
175
- this.pageName = 'casino';
176
- this.posts = []; // State to store fetched posts
177
- this.stylingAppends = false;
178
- this.isLoading = false;
179
- this.isLoggedIn = false;
180
- this.dataImages = []; // State to store fetched images
181
- this.gameIds = ''; // State to store fetched images
182
- this.platform = getDevicePlatform();
183
- this.setClientStyling = () => {
184
- let sheet = document.createElement('style');
185
- sheet.innerHTML = this.clientStyling;
186
- this.stylingContainer.prepend(sheet);
187
- };
188
- this.setClientStylingURL = () => {
189
- let url = new URL(this.clientStylingUrl);
190
- let cssFile = document.createElement('style');
191
- fetch(url.href)
192
- .then((res) => res.text())
193
- .then((data) => {
194
- cssFile.innerHTML = data;
195
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
196
- })
197
- .catch((err) => {
198
- console.log('error ', err);
199
- });
200
- };
201
- }
202
- handleNewTranslations() {
203
- this.isLoading = true;
204
- getTranslations(this.translationUrl).then(() => {
205
- this.isLoading = false;
206
- });
207
- }
208
- async componentWillLoad() {
209
- if (this.translationUrl.length > 2) {
210
- await getTranslations(this.translationUrl);
211
- }
212
- }
213
- watchSession(newValue, oldValue) {
214
- if (newValue !== oldValue) {
215
- this.isLoggedIn = newValue !== '';
216
- }
217
- }
218
- connectedCallback() {
219
- if (this.session) {
220
- this.isLoggedIn = true;
221
- }
222
- }
223
- componentDidRender() {
224
- // start custom styling area
225
- if (!this.stylingAppends && this.stylingContainer) {
226
- if (this.clientStyling)
227
- this.setClientStyling();
228
- if (this.clientStylingUrl)
229
- this.setClientStylingURL();
230
- this.stylingAppends = true;
231
- }
232
- // end custom styling area
233
- }
234
- getDataImage(ids) {
235
- try {
236
- let url = new URL(`${this.endpoint}/v2/casino/groups/${this.datasource}`);
237
- url.searchParams.append("language", this.language);
238
- url.searchParams.append("expand", 'games');
239
- url.searchParams.append("fields", 'games(id,thumbnail,launchUrl)');
240
- url.searchParams.append("filter", ids);
241
- url.searchParams.append('device', this.platform);
242
- const options = {
243
- 'method': 'GET',
244
- 'Content-Type': 'application/json'
245
- };
246
- fetch(url.href, options)
247
- .then((res) => {
248
- if (res.status === 200) {
249
- return res.json();
250
- }
251
- else {
252
- throw new Error("HTTP status " + res.status);
253
- }
254
- })
255
- .then((data) => {
256
- data.items.forEach((item) => {
257
- item.games.items.forEach(element => {
258
- let { id, launchUrl, thumbnail } = element;
259
- this.dataImages = [{ id, launchUrl, thumbnail }];
260
- let index = this.posts.findIndex(post => post.gameId === id);
261
- if (index !== -1) {
262
- this.posts[index].images = this.dataImages;
263
- }
264
- });
265
- });
266
- })
267
- .catch((err) => {
268
- // Handle any errors
269
- console.error(err);
270
- });
271
- }
272
- catch (error) {
273
- console.error('Error fetching verification types:', error);
274
- }
275
- }
276
- async componentDidLoad() {
277
- try {
278
- let url = new URL(`${this.cmsEndpoint}/${this.language}/content/social-posts`);
279
- url.searchParams.append("device", this.platform);
280
- url.searchParams.append("page", this.pageName);
281
- url.searchParams.append("language", this.language);
282
- url.searchParams.append("userRoles", this.userRoles);
283
- url.searchParams.append('env', this.cmsEnv);
284
- const options = {
285
- 'method': 'GET',
286
- 'Content-Type': 'application/json'
287
- };
288
- fetch(url.href, options)
289
- .then((res) => {
290
- if (res.status === 200) {
291
- return res.json();
292
- }
293
- else {
294
- throw new Error("HTTP status " + res.status);
295
- }
296
- })
297
- .then((data) => {
298
- data.forEach(element => {
299
- var _a;
300
- const slug = element.slug;
301
- const postId = element.id;
302
- const { gameId, title, description, subtitle } = (_a = element.previewCard) !== null && _a !== void 0 ? _a : {};
303
- if (gameId) {
304
- this.gameIds += `games(id=${gameId}),`;
305
- }
306
- this.posts.push({ postId, gameId, title, description, subtitle, slug });
307
- });
308
- if (this.gameIds.length > 0) {
309
- this.gameIds = this.gameIds.slice(0, -1); // Removes the last comma
310
- this.gameIds = '$or(' + this.gameIds + ')';
311
- }
312
- this.getDataImage(this.gameIds);
313
- })
314
- .catch((err) => {
315
- // Handle any errors
316
- console.error(err);
317
- });
318
- }
319
- catch (error) {
320
- console.error('Error fetching verification types:', error);
321
- }
322
- }
323
- hasUndefinedValues(obj) {
324
- return Object.values(obj).some((value) => value === undefined);
325
- }
326
- render() {
327
- if (this.isLoading) {
328
- return (h("div", null, h("p", null, translate('loading', this.language))));
329
- }
330
- else {
331
- 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
332
- .filter((post) => !this.hasUndefinedValues(post)) // Filter out posts with undefined values
333
- .slice(0, +(this.maxCards || this.posts.length))
334
- .map((post) => {
335
- var _a, _b, _c, _d;
336
- 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" })))
337
- : null, h("div", { class: "titleSubtitle" }, post.title && h("h3", null, post.title), post.subtitle && h("p", { innerHTML: post.subtitle }))), post.description &&
338
- h("div", { class: "Description" }, h("p", { innerHTML: post.description })), h("div", { class: "buttons" }, h("button", { class: "moreInfoButton", onClick: () => this.onMoreInfoClick(post.gameId, post.postId, post.title, post.slug) }, translate('moreInfo', this.language)), this.isLoggedIn && post.gameId && h("button", { class: "playNowButton", onClick: () => this.onPlayNowClick(post.gameId) }, translate('playNow', this.language)))));
339
- })))));
340
- }
341
- }
342
- onViewAllClick() {
343
- this.viewAll.emit();
344
- window.postMessage({ type: 'viewAllSocialPosts' }, window.location.href);
345
- }
346
- onMoreInfoClick(gameId, postId, postTitle, slug) {
347
- this.moreInfo.emit();
348
- window.postMessage({ type: 'moreInfoSocialPost', gameId, postId, postTitle, slug }, window.location.href);
349
- }
350
- onPlayNowClick(gameId) {
351
- this.playNow.emit(gameId);
352
- window.postMessage({ type: 'playNowSocialPost', gameId: gameId }, window.location.href);
353
- }
354
- static get watchers() { return {
355
- "translationUrl": ["handleNewTranslations"],
356
- "session": ["watchSession"]
357
- }; }
358
- static get style() { return generalPreviewSocialPostsCss; }
359
- }, [1, "general-preview-social-posts", {
360
- "userId": [513, "user-id"],
361
- "session": [513],
362
- "postsTitle": [513, "posts-title"],
363
- "maxCards": [513, "max-cards"],
364
- "language": [513],
365
- "datasource": [513],
366
- "endpoint": [513],
367
- "cmsEndpoint": [513, "cms-endpoint"],
368
- "userRoles": [513, "user-roles"],
369
- "translationUrl": [513, "translation-url"],
370
- "clientStyling": [513, "client-styling"],
371
- "clientStylingUrl": [513, "client-styling-url"],
372
- "cmsEnv": [513, "cms-env"],
373
- "pageName": [513, "page-name"],
374
- "posts": [32],
375
- "stylingAppends": [32],
376
- "isLoading": [32],
377
- "isLoggedIn": [32],
378
- "dataImages": [32],
379
- "gameIds": [32]
380
- }]);
381
- function defineCustomElement$1() {
382
- if (typeof customElements === "undefined") {
383
- return;
384
- }
385
- const components = ["general-preview-social-posts"];
386
- components.forEach(tagName => { switch (tagName) {
387
- case "general-preview-social-posts":
388
- if (!customElements.get(tagName)) {
389
- customElements.define(tagName, SocialSlider);
390
- }
391
- break;
392
- } });
393
- }
394
-
395
- const GeneralPreviewSocialPosts = SocialSlider;
396
- const defineCustomElement = defineCustomElement$1;
397
-
398
- export { GeneralPreviewSocialPosts, defineCustomElement };
@@ -1,26 +0,0 @@
1
- /* GeneralPreviewSocialPosts custom elements */
2
-
3
- import type { Components, JSX } from "../types/components";
4
-
5
- /**
6
- * Used to manually set the base path where assets can be found.
7
- * If the script is used as "module", it's recommended to use "import.meta.url",
8
- * such as "setAssetPath(import.meta.url)". Other options include
9
- * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
10
- * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
11
- * But do note that this configuration depends on how your script is bundled, or lack of
12
- * bundling, and where your assets can be loaded from. Additionally custom bundling
13
- * will have to ensure the static assets are copied to its build directory.
14
- */
15
- export declare const setAssetPath: (path: string) => void;
16
-
17
- export interface SetPlatformOptions {
18
- raf?: (c: FrameRequestCallback) => number;
19
- ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
20
- rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
21
- }
22
- export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
23
-
24
- export type { Components, JSX };
25
-
26
- export * from '../types';
@@ -1 +0,0 @@
1
- export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';