@everymatrix/general-preview-social-posts 1.43.4 → 1.45.0

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