@everymatrix/blog-articles-grid 1.94.9 → 1.94.16

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.
@@ -1,13 +1,13 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { translate } from "../../utils/locale.utils";
3
3
  import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
4
- import { getDevicePlatform, getDeviceCustom } from "../../utils/utils";
4
+ import { getDevicePlatform, getDeviceType } from "../../../../../../../../libs/common/src/device/index";
5
5
  import "../../../../../helper-pagination/dist/types/index";
6
6
  export class BlogArticlesGrid {
7
7
  constructor() {
8
- this.clientStylingContent = '';
8
+ this.lastPage = 1;
9
9
  this.isInitialized = false;
10
- this.defaultStyling = `
10
+ this.paginationDefaultStyling = `
11
11
  div#PaginationContainer {
12
12
  justify-content: right;
13
13
  }
@@ -73,12 +73,9 @@ export class BlogArticlesGrid {
73
73
  };
74
74
  this.renderContentConditionally = (content) => {
75
75
  if (!content)
76
- return;
77
- const hasBanner = content.indexOf('<bannermatrix-banner') !== -1;
78
- if (!hasBanner) {
79
- return h("div", { class: "BlogContent", innerHTML: content });
80
- }
81
- if (this.bannerMatrixReady) {
76
+ return null;
77
+ const hasBanner = content.includes('<bannermatrix-banner');
78
+ if (!hasBanner || this.bannerMatrixReady) {
82
79
  return h("div", { class: "BlogContent", innerHTML: content });
83
80
  }
84
81
  return null;
@@ -99,9 +96,9 @@ export class BlogArticlesGrid {
99
96
  this.postMessageEvent = '';
100
97
  this.blogsLimit = '0';
101
98
  this.paginationActive = undefined;
102
- this.arrowsActive = undefined;
103
- this.secondaryArrowsActive = undefined;
104
- this.numberedNavActive = undefined;
99
+ this.arrowsActive = true;
100
+ this.secondaryArrowsActive = false;
101
+ this.numberedNavActive = false;
105
102
  this.intlDateTimeFormat = '';
106
103
  this.page = '1';
107
104
  this.eventId = undefined;
@@ -114,18 +111,19 @@ export class BlogArticlesGrid {
114
111
  this.bannerMatrixReady = false;
115
112
  this.nextPage = '';
116
113
  this.previousPage = '';
117
- this.device = '';
114
+ this.device = 'mobile';
118
115
  this.displayedBlogResponse = undefined;
119
116
  this.paginationBlogResponse = undefined;
120
117
  this.allBlogResponse = undefined;
121
118
  this.totalBlogs = 0;
122
119
  }
123
120
  getArticleId(postId, slug, customPath) {
121
+ var _a;
124
122
  if (this.usePostmessage) {
125
123
  window.postMessage({ type: this.postMessageEvent, postId: postId.toString(), slug, customPath });
126
124
  }
127
125
  else {
128
- this.articleActionButton.emit({ postId: postId.toString(), slug, customPath });
126
+ (_a = this.articleActionButton) === null || _a === void 0 ? void 0 : _a.emit({ postId: postId.toString(), slug, customPath });
129
127
  }
130
128
  }
131
129
  // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
@@ -142,12 +140,12 @@ export class BlogArticlesGrid {
142
140
  }
143
141
  }
144
142
  handleClientStylingChange(newValue, oldValue) {
145
- if (newValue != oldValue) {
143
+ if (newValue !== oldValue) {
146
144
  setClientStyling(this.stylingContainer, this.clientStyling);
147
145
  }
148
146
  }
149
147
  handleClientStylingChangeURL(newValue, oldValue) {
150
- if (newValue != oldValue) {
148
+ if (newValue !== oldValue) {
151
149
  if (this.clientStylingUrl)
152
150
  setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
153
151
  }
@@ -189,6 +187,8 @@ export class BlogArticlesGrid {
189
187
  return featuredItems[0];
190
188
  }
191
189
  moveLatestFeatureToStart(blogItems, latestFeatured) {
190
+ if (!latestFeatured)
191
+ return blogItems;
192
192
  const index = blogItems.indexOf(latestFeatured);
193
193
  if (index !== -1) {
194
194
  blogItems.splice(index, 1);
@@ -244,7 +244,7 @@ export class BlogArticlesGrid {
244
244
  // TODO: this is a temporary solution for filter blogPost by eventId from all blog posts.
245
245
  // apijson should have functionality to filter in backend side in future.
246
246
  const allBlogData = ((_a = this.allBlogResponse) === null || _a === void 0 ? void 0 : _a.items) ? this.allBlogResponse : await this.fetchBlogPosts(1, true);
247
- const filteredItems = allBlogData.items.filter(({ eventIds }) => eventIds.includes(this.eventId));
247
+ const filteredItems = allBlogData.items.filter(({ eventIds }) => { var _a; return eventIds.includes((_a = this.eventId) !== null && _a !== void 0 ? _a : '-'); });
248
248
  if (filteredItems.length) {
249
249
  blogResponse = Object.assign(Object.assign({}, allBlogData), { items: filteredItems, total: Math.min(parseInt(this.blogsLimit), filteredItems.length) });
250
250
  window.postMessage({
@@ -272,7 +272,7 @@ export class BlogArticlesGrid {
272
272
  }
273
273
  this.displayedBlogResponse = blogResponse;
274
274
  this.totalBlogs = blogResponse.total;
275
- this.lastPage = +((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1;
275
+ this.lastPage = +(((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1);
276
276
  this.nextPage = blogResponse.pages.next;
277
277
  this.previousPage = blogResponse.pages.previous;
278
278
  this.isLoading = false;
@@ -294,21 +294,21 @@ export class BlogArticlesGrid {
294
294
  }
295
295
  }
296
296
  }
297
- componentDidLoad() {
298
- if (this.stylingContainer) {
299
- if (window.emMessageBus != undefined) {
300
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
301
- }
302
- else {
303
- if (this.clientStyling)
304
- setClientStyling(this.stylingContainer, this.clientStyling);
305
- if (this.clientStylingUrl)
306
- setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
307
- }
297
+ handleClientStyling() {
298
+ if (window.emMessageBus !== undefined) {
299
+ this.stylingSubscription = setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription, true);
300
+ return;
308
301
  }
302
+ if (this.clientStyling)
303
+ setClientStyling(this.stylingContainer, this.clientStyling);
304
+ if (this.clientStylingUrl)
305
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
306
+ }
307
+ componentDidLoad() {
308
+ this.handleClientStyling();
309
309
  this.isInitialized = true;
310
310
  window.postMessage({ type: 'BlogArticlesGridLoaded' }, window.location.href);
311
- this.device = getDeviceCustom();
311
+ this.device = getDeviceType();
312
312
  }
313
313
  disconnectedCallback() {
314
314
  this.stylingSubscription && this.stylingSubscription.unsubscribe();
@@ -336,8 +336,10 @@ export class BlogArticlesGrid {
336
336
  for (let i = 0; i < parseInt(this.blogsLimit); i++) {
337
337
  placeholderCards.push(h("div", { class: "GridContainer FeaturedPost Skeleton" }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, h("div", { class: "VisualContent LoadingImage" })), h("div", { class: "GridSector" }, h("div", { class: "BlogTitle LoadingStripe LoadingSmallStripe" }), h("div", { class: "BlogDetails LoadingStripe LoadingMediumStripe" }), h("div", { class: "BlogLink LoadingStripe LoadingLongStripe" })))));
338
338
  }
339
- return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "BlogPageContainer" }, h("div", { class: "BlogGridPaginationWrapper" }, this.paginationActive == true && this.totalBlogs > +this.blogsLimit && h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "md-source": this.mbSource, "client-styling": this.clientStyling || this.defaultStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
340
- h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
339
+ const showPagination = Boolean(this.paginationActive) && this.totalBlogs > +this.blogsLimit;
340
+ const paginationClientStyling = !this.mbSource ? (this.clientStyling || this.paginationDefaultStyling) : undefined;
341
+ return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "BlogPageContainer" }, h("div", { class: "BlogGridPaginationWrapper" }, showPagination && h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "mb-source": this.mbSource, "client-styling": paginationClientStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive, "secondary-arrows-active": this.secondaryArrowsActive, "numbered-nav-active": this.numberedNavActive })), (!this.isLoading) &&
342
+ h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage} ${this.device}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
341
343
  var _a, _b;
342
344
  return h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, this.showPublishingDate &&
343
345
  h("div", { class: "BlogDate" }, this.formatDate(data === null || data === void 0 ? void 0 : data.publishingDate)), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (h("div", { class: "VisualContent", style: { background: `url(${this.setImage(data.image)}) no-repeat center center / cover` } })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (h("video", { class: "VisualContent", src: data.video.sources[this.device], controls: true })) : (h("h1", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), h("div", { class: "GridSector" }, this.showTitle &&
@@ -370,7 +372,7 @@ export class BlogArticlesGrid {
370
372
  "references": {}
371
373
  },
372
374
  "required": false,
373
- "optional": false,
375
+ "optional": true,
374
376
  "docs": {
375
377
  "tags": [],
376
378
  "text": "Endpoint URL for the source of data"
@@ -441,7 +443,7 @@ export class BlogArticlesGrid {
441
443
  "references": {}
442
444
  },
443
445
  "required": false,
444
- "optional": false,
446
+ "optional": true,
445
447
  "docs": {
446
448
  "tags": [],
447
449
  "text": "Client custom styling via streamStyling"
@@ -637,7 +639,7 @@ export class BlogArticlesGrid {
637
639
  "references": {}
638
640
  },
639
641
  "required": false,
640
- "optional": false,
642
+ "optional": true,
641
643
  "docs": {
642
644
  "tags": [],
643
645
  "text": "Customize pagination: Activate pagination"
@@ -660,7 +662,8 @@ export class BlogArticlesGrid {
660
662
  "text": "Customize pagination: Activate pagination arrows"
661
663
  },
662
664
  "attribute": "arrows-active",
663
- "reflect": true
665
+ "reflect": true,
666
+ "defaultValue": "true"
664
667
  },
665
668
  "secondaryArrowsActive": {
666
669
  "type": "boolean",
@@ -677,7 +680,8 @@ export class BlogArticlesGrid {
677
680
  "text": "Customize pagination: Activate pagination secondary arrows"
678
681
  },
679
682
  "attribute": "secondary-arrows-active",
680
- "reflect": true
683
+ "reflect": true,
684
+ "defaultValue": "false"
681
685
  },
682
686
  "numberedNavActive": {
683
687
  "type": "boolean",
@@ -694,7 +698,8 @@ export class BlogArticlesGrid {
694
698
  "text": "Customize pagination: Activate pagination numbered navigation"
695
699
  },
696
700
  "attribute": "numbered-nav-active",
697
- "reflect": true
701
+ "reflect": true,
702
+ "defaultValue": "false"
698
703
  },
699
704
  "intlDateTimeFormat": {
700
705
  "type": "string",
@@ -779,14 +784,9 @@ export class BlogArticlesGrid {
779
784
  "text": ""
780
785
  },
781
786
  "complexType": {
782
- "original": "Object",
783
- "resolved": "Object",
784
- "references": {
785
- "Object": {
786
- "location": "global",
787
- "id": "global::Object"
788
- }
789
- }
787
+ "original": "any",
788
+ "resolved": "any",
789
+ "references": {}
790
790
  }
791
791
  }];
792
792
  }
@@ -158,29 +158,67 @@ function getAdoptStyleSubscription(stylingContainer, domain) {
158
158
  });
159
159
  }
160
160
 
161
- function checkCustomDeviceWidth() {
162
- const width = screen.availWidth;
163
- if (width < 600) {
164
- return 'mobile';
165
- }
166
- else if (width >= 600 && width < 1100) {
167
- return 'tablet';
168
- }
169
- }
170
- function isIpad() {
171
- const userAgent = navigator.userAgent.toLowerCase();
172
- // Traditional iPad user agent
173
- if (userAgent.includes('ipad')) {
161
+ const MOBILE_MAX = 599;
162
+ const TABLET_MAX = 1099;
163
+ function isIPad(ua) {
164
+ // Classic iPad UA
165
+ if (ua.includes('ipad'))
174
166
  return true;
175
- }
176
- return userAgent.indexOf('macintosh') > -1 && navigator.maxTouchPoints && navigator.maxTouchPoints > 2;
167
+ // iPadOS 13+ Safari pretending to be macOS
168
+ return ua.includes('macintosh') && navigator.maxTouchPoints > 0;
169
+ }
170
+ function isIPhone(ua) {
171
+ return ua.includes('iphone') || ua.includes('ipod');
172
+ }
173
+ function isAndroid(ua) {
174
+ return ua.includes('android');
177
175
  }
178
- function getDeviceCustom() {
179
- const userAgent = navigator.userAgent.toLowerCase();
180
- let source = '';
181
- source = (userAgent.includes('android') || userAgent.includes('iphone') || isIpad()) ? checkCustomDeviceWidth() : 'desktop';
182
- return source;
176
+ function isAndroidMobile(ua, width) {
177
+ return isAndroid(ua) && (ua.includes('mobile') || ua.includes('mobi') || width <= MOBILE_MAX);
183
178
  }
179
+ function isAndroidTablet(ua, width) {
180
+ return isAndroid(ua) && !ua.includes('mobile') && !ua.includes('mobi') && width > MOBILE_MAX;
181
+ }
182
+ /**
183
+ * Detects the current device type using user agent and viewport width.
184
+ *
185
+ * By default, this function focuses on actual device/platform detection.
186
+ * Responsive width fallback is optional and mainly intended for
187
+ * responsive layout testing or browser emulation.
188
+ *
189
+ * Supports:
190
+ * - iPhone / iPad
191
+ * - Android mobile / tablet
192
+ *
193
+ * @param enableResponsiveFallback
194
+ * When enabled, classify unknown devices by viewport width.
195
+ *
196
+ * @returns `'mobile' | 'tablet' | 'desktop'`
197
+ */
198
+ const getDeviceType = (enableResponsiveFallback = false) => {
199
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
200
+ return 'desktop';
201
+ }
202
+ const ua = navigator.userAgent.toLowerCase();
203
+ const width = window.innerWidth;
204
+ // Apple devices
205
+ if (isIPad(ua))
206
+ return 'tablet';
207
+ if (isIPhone(ua))
208
+ return 'mobile';
209
+ // Android devices
210
+ if (isAndroidMobile(ua, width))
211
+ return 'mobile';
212
+ if (isAndroidTablet(ua, width))
213
+ return 'tablet';
214
+ if (enableResponsiveFallback) {
215
+ if (width <= MOBILE_MAX)
216
+ return 'mobile';
217
+ if (width <= TABLET_MAX)
218
+ return 'tablet';
219
+ }
220
+ return 'desktop';
221
+ };
184
222
  const getDevice = () => {
185
223
  let userAgent = window.navigator.userAgent;
186
224
  if (userAgent.toLowerCase().match(/android/i)) {
@@ -203,10 +241,8 @@ const getDevicePlatform = () => {
203
241
  else if (device === 'iPad' || device === 'iPhone') {
204
242
  return 'mtWeb';
205
243
  }
206
- else {
207
- return 'mtWeb';
208
- }
209
244
  }
245
+ return 'mtWeb';
210
246
  };
211
247
 
212
248
  const blogArticlesGridCss = ":host {\n display: block;\n}\n\n.BlogPageContainer {\n background: #0A0A17;\n padding: 20px;\n}\n\n.GridContainerWrapper {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 20px;\n}\n\n.BlogPage-0 .GridContainer.FeaturedPost:first-child {\n width: 100%;\n flex-basis: auto;\n}\n\n.GridContainer {\n container-type: inline-size;\n container-name: article;\n border-radius: 15px;\n color: #000;\n overflow: hidden;\n}\n.GridContainer.FeaturedPost:first-child {\n grid-column: 1/-1;\n width: 100%;\n}\n.GridContainer .GridWrapper {\n display: flex;\n flex-direction: row;\n height: 280px;\n background: var(--emw--color-white, #FFFFFF);\n}\n.GridContainer .GridSector {\n flex-basis: 50%;\n position: relative;\n}\n.GridContainer .GridSector:first-of-type {\n height: 280px;\n display: flex;\n}\n.GridContainer .GridSector:last-of-type {\n padding: 20px 40px;\n display: flex;\n flex-direction: column;\n}\n.GridContainer .VisualContent {\n width: 100%;\n}\n.GridContainer .BlogDate {\n position: absolute;\n bottom: 0px;\n left: 30px;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: var(--emw--color-white, #FFFFFF);\n background-color: #CD0B5E;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #000;\n padding-bottom: 10px;\n}\n.GridContainer .BlogContent {\n display: -webkit-box;\n font-size: 14px;\n line-height: 1.2em;\n -webkit-line-clamp: 6;\n color: #000;\n -webkit-box-orient: vertical;\n box-sizing: border-box;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n.GridContainer .BlogLink {\n color: #000;\n position: absolute;\n bottom: 16px;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #22B04E;\n cursor: pointer;\n}\n\n@container article (max-width: 550px) {\n .GridContainer .GridWrapper {\n height: 380px;\n flex-direction: column;\n }\n .GridContainer .GridWrapper .GridSector:first-of-type {\n height: 120px;\n flex-shrink: 0;\n flex-basis: 150px;\n }\n .GridContainer .GridWrapper .GridSector:last-of-type {\n padding: 20px 20px 40px;\n }\n}\n.LoadingImage {\n width: 100%;\n height: 100%;\n background-color: var(--emw--color-gray-100, #E6E6E6);\n}\n\n.LoadingStripe {\n border: 1px solid var(--emw--color-white, #FFFFFF);\n height: 20%;\n background-color: var(--emw--color-gray-100, #E6E6E6);\n margin-bottom: 5px;\n}\n\n.LoadingSmallStripe {\n width: 40%;\n}\n\n.LoadingMediumStripe {\n width: 70%;\n}\n\n.BlogLink.LoadingLongStripe {\n position: static;\n width: 100%;\n}\n\n.GridContainerWrapper.LoadingGrid .GridSector {\n justify-content: space-around;\n}\n\n.GridContainerWrapper.LoadingGrid .LoadingImage, .GridContainerWrapper.LoadingGrid .LoadingStripe {\n animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n -webkit-animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n}\n\n@keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}\n@-webkit-keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}";
@@ -216,9 +252,9 @@ const BlogArticlesGrid = class {
216
252
  constructor(hostRef) {
217
253
  registerInstance(this, hostRef);
218
254
  this.articleActionButton = createEvent(this, "articleActionButton", 7);
219
- this.clientStylingContent = '';
255
+ this.lastPage = 1;
220
256
  this.isInitialized = false;
221
- this.defaultStyling = `
257
+ this.paginationDefaultStyling = `
222
258
  div#PaginationContainer {
223
259
  justify-content: right;
224
260
  }
@@ -284,12 +320,9 @@ const BlogArticlesGrid = class {
284
320
  };
285
321
  this.renderContentConditionally = (content) => {
286
322
  if (!content)
287
- return;
288
- const hasBanner = content.indexOf('<bannermatrix-banner') !== -1;
289
- if (!hasBanner) {
290
- return h("div", { class: "BlogContent", innerHTML: content });
291
- }
292
- if (this.bannerMatrixReady) {
323
+ return null;
324
+ const hasBanner = content.includes('<bannermatrix-banner');
325
+ if (!hasBanner || this.bannerMatrixReady) {
293
326
  return h("div", { class: "BlogContent", innerHTML: content });
294
327
  }
295
328
  return null;
@@ -310,9 +343,9 @@ const BlogArticlesGrid = class {
310
343
  this.postMessageEvent = '';
311
344
  this.blogsLimit = '0';
312
345
  this.paginationActive = undefined;
313
- this.arrowsActive = undefined;
314
- this.secondaryArrowsActive = undefined;
315
- this.numberedNavActive = undefined;
346
+ this.arrowsActive = true;
347
+ this.secondaryArrowsActive = false;
348
+ this.numberedNavActive = false;
316
349
  this.intlDateTimeFormat = '';
317
350
  this.page = '1';
318
351
  this.eventId = undefined;
@@ -325,18 +358,19 @@ const BlogArticlesGrid = class {
325
358
  this.bannerMatrixReady = false;
326
359
  this.nextPage = '';
327
360
  this.previousPage = '';
328
- this.device = '';
361
+ this.device = 'mobile';
329
362
  this.displayedBlogResponse = undefined;
330
363
  this.paginationBlogResponse = undefined;
331
364
  this.allBlogResponse = undefined;
332
365
  this.totalBlogs = 0;
333
366
  }
334
367
  getArticleId(postId, slug, customPath) {
368
+ var _a;
335
369
  if (this.usePostmessage) {
336
370
  window.postMessage({ type: this.postMessageEvent, postId: postId.toString(), slug, customPath });
337
371
  }
338
372
  else {
339
- this.articleActionButton.emit({ postId: postId.toString(), slug, customPath });
373
+ (_a = this.articleActionButton) === null || _a === void 0 ? void 0 : _a.emit({ postId: postId.toString(), slug, customPath });
340
374
  }
341
375
  }
342
376
  // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
@@ -353,12 +387,12 @@ const BlogArticlesGrid = class {
353
387
  }
354
388
  }
355
389
  handleClientStylingChange(newValue, oldValue) {
356
- if (newValue != oldValue) {
390
+ if (newValue !== oldValue) {
357
391
  setClientStyling(this.stylingContainer, this.clientStyling);
358
392
  }
359
393
  }
360
394
  handleClientStylingChangeURL(newValue, oldValue) {
361
- if (newValue != oldValue) {
395
+ if (newValue !== oldValue) {
362
396
  if (this.clientStylingUrl)
363
397
  setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
364
398
  }
@@ -400,6 +434,8 @@ const BlogArticlesGrid = class {
400
434
  return featuredItems[0];
401
435
  }
402
436
  moveLatestFeatureToStart(blogItems, latestFeatured) {
437
+ if (!latestFeatured)
438
+ return blogItems;
403
439
  const index = blogItems.indexOf(latestFeatured);
404
440
  if (index !== -1) {
405
441
  blogItems.splice(index, 1);
@@ -455,7 +491,7 @@ const BlogArticlesGrid = class {
455
491
  // TODO: this is a temporary solution for filter blogPost by eventId from all blog posts.
456
492
  // apijson should have functionality to filter in backend side in future.
457
493
  const allBlogData = ((_a = this.allBlogResponse) === null || _a === void 0 ? void 0 : _a.items) ? this.allBlogResponse : await this.fetchBlogPosts(1, true);
458
- const filteredItems = allBlogData.items.filter(({ eventIds }) => eventIds.includes(this.eventId));
494
+ const filteredItems = allBlogData.items.filter(({ eventIds }) => { var _a; return eventIds.includes((_a = this.eventId) !== null && _a !== void 0 ? _a : '-'); });
459
495
  if (filteredItems.length) {
460
496
  blogResponse = Object.assign(Object.assign({}, allBlogData), { items: filteredItems, total: Math.min(parseInt(this.blogsLimit), filteredItems.length) });
461
497
  window.postMessage({
@@ -483,7 +519,7 @@ const BlogArticlesGrid = class {
483
519
  }
484
520
  this.displayedBlogResponse = blogResponse;
485
521
  this.totalBlogs = blogResponse.total;
486
- this.lastPage = +((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1;
522
+ this.lastPage = +(((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1);
487
523
  this.nextPage = blogResponse.pages.next;
488
524
  this.previousPage = blogResponse.pages.previous;
489
525
  this.isLoading = false;
@@ -505,21 +541,21 @@ const BlogArticlesGrid = class {
505
541
  }
506
542
  }
507
543
  }
508
- componentDidLoad() {
509
- if (this.stylingContainer) {
510
- if (window.emMessageBus != undefined) {
511
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
512
- }
513
- else {
514
- if (this.clientStyling)
515
- setClientStyling(this.stylingContainer, this.clientStyling);
516
- if (this.clientStylingUrl)
517
- setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
518
- }
544
+ handleClientStyling() {
545
+ if (window.emMessageBus !== undefined) {
546
+ this.stylingSubscription = setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription, true);
547
+ return;
519
548
  }
549
+ if (this.clientStyling)
550
+ setClientStyling(this.stylingContainer, this.clientStyling);
551
+ if (this.clientStylingUrl)
552
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
553
+ }
554
+ componentDidLoad() {
555
+ this.handleClientStyling();
520
556
  this.isInitialized = true;
521
557
  window.postMessage({ type: 'BlogArticlesGridLoaded' }, window.location.href);
522
- this.device = getDeviceCustom();
558
+ this.device = getDeviceType();
523
559
  }
524
560
  disconnectedCallback() {
525
561
  this.stylingSubscription && this.stylingSubscription.unsubscribe();
@@ -547,8 +583,10 @@ const BlogArticlesGrid = class {
547
583
  for (let i = 0; i < parseInt(this.blogsLimit); i++) {
548
584
  placeholderCards.push(h("div", { class: "GridContainer FeaturedPost Skeleton" }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, h("div", { class: "VisualContent LoadingImage" })), h("div", { class: "GridSector" }, h("div", { class: "BlogTitle LoadingStripe LoadingSmallStripe" }), h("div", { class: "BlogDetails LoadingStripe LoadingMediumStripe" }), h("div", { class: "BlogLink LoadingStripe LoadingLongStripe" })))));
549
585
  }
550
- return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "BlogPageContainer" }, h("div", { class: "BlogGridPaginationWrapper" }, this.paginationActive == true && this.totalBlogs > +this.blogsLimit && h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "md-source": this.mbSource, "client-styling": this.clientStyling || this.defaultStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
551
- h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
586
+ const showPagination = Boolean(this.paginationActive) && this.totalBlogs > +this.blogsLimit;
587
+ const paginationClientStyling = !this.mbSource ? (this.clientStyling || this.paginationDefaultStyling) : undefined;
588
+ return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "BlogPageContainer" }, h("div", { class: "BlogGridPaginationWrapper" }, showPagination && h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "mb-source": this.mbSource, "client-styling": paginationClientStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive, "secondary-arrows-active": this.secondaryArrowsActive, "numbered-nav-active": this.numberedNavActive })), (!this.isLoading) &&
589
+ h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage} ${this.device}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
552
590
  var _a, _b;
553
591
  return h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, this.showPublishingDate &&
554
592
  h("div", { class: "BlogDate" }, this.formatDate(data === null || data === void 0 ? void 0 : data.publishingDate)), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (h("div", { class: "VisualContent", style: { background: `url(${this.setImage(data.image)}) no-repeat center center / cover` } })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (h("video", { class: "VisualContent", src: data.video.sources[this.device], controls: true })) : (h("h1", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), h("div", { class: "GridSector" }, this.showTitle &&
@@ -643,6 +681,7 @@ const HelperPagination = class {
643
681
  * Navigation logic
644
682
  */
645
683
  this.navigateTo = (navigationPage) => {
684
+ var _a;
646
685
  switch (navigationPage) {
647
686
  case 'firstPage':
648
687
  this.offsetInt = 0;
@@ -666,12 +705,13 @@ const HelperPagination = class {
666
705
  break;
667
706
  }
668
707
  this.previousPage = !this.offsetInt ? false : true;
669
- this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
708
+ (_a = this.hpPageChange) === null || _a === void 0 ? void 0 : _a.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
670
709
  };
671
710
  /**
672
711
  * Handle navigation from here
673
712
  */
674
713
  this.paginationNavigation = (pageNumber, index) => {
714
+ var _a;
675
715
  this.previousPage = true;
676
716
  if (!isNaN(pageNumber)) {
677
717
  if (pageNumber === 1) {
@@ -693,7 +733,7 @@ const HelperPagination = class {
693
733
  this.navigateTo('fivePagesForward');
694
734
  }
695
735
  }
696
- this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
736
+ (_a = this.hpPageChange) === null || _a === void 0 ? void 0 : _a.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
697
737
  };
698
738
  this.nextPage = '';
699
739
  this.prevPage = '';
@@ -704,24 +744,24 @@ const HelperPagination = class {
704
744
  this.mbSource = undefined;
705
745
  this.clientStyling = '';
706
746
  this.clientStylingUrl = '';
707
- this.arrowsActive = undefined;
708
- this.secondaryArrowsActive = undefined;
709
- this.numberedNavActive = undefined;
710
- this.offsetInt = undefined;
747
+ this.arrowsActive = true;
748
+ this.secondaryArrowsActive = false;
749
+ this.numberedNavActive = false;
750
+ this.offsetInt = 0;
711
751
  this.lastPage = false;
712
752
  this.previousPage = false;
713
- this.limitInt = undefined;
714
- this.totalInt = undefined;
753
+ this.limitInt = 0;
754
+ this.totalInt = 0;
715
755
  this.pagesArray = [];
716
756
  this.endInt = 0;
717
757
  }
718
758
  handleClientStylingChange(newValue, oldValue) {
719
- if (newValue != oldValue) {
759
+ if (newValue !== oldValue) {
720
760
  setClientStyling(this.stylingContainer, this.clientStyling);
721
761
  }
722
762
  }
723
763
  handleClientStylingChangeURL(newValue, oldValue) {
724
- if (newValue != oldValue) {
764
+ if (newValue !== oldValue) {
725
765
  if (this.clientStylingUrl)
726
766
  setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
727
767
  }
@@ -751,18 +791,18 @@ const HelperPagination = class {
751
791
  this.pagesArray.unshift('...');
752
792
  }
753
793
  }
754
- componentDidLoad() {
755
- if (this.stylingContainer) {
756
- if (window.emMessageBus != undefined) {
757
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
758
- }
759
- else {
760
- if (this.clientStyling)
761
- setClientStyling(this.stylingContainer, this.clientStyling);
762
- if (this.clientStylingUrl)
763
- setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
764
- }
794
+ handleClientStyling() {
795
+ if (window.emMessageBus !== undefined) {
796
+ this.stylingSubscription = setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription, true);
797
+ return;
765
798
  }
799
+ if (this.clientStyling)
800
+ setClientStyling(this.stylingContainer, this.clientStyling);
801
+ if (this.clientStylingUrl)
802
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
803
+ }
804
+ componentDidLoad() {
805
+ this.handleClientStyling();
766
806
  }
767
807
  disconnectedCallback() {
768
808
  this.stylingSubscription && this.stylingSubscription.unsubscribe();
@@ -0,0 +1,21 @@
1
+ export type DevicePlatform = 'dk' | 'mtWeb';
2
+ export type Device = 'mobile' | 'tablet' | 'desktop';
3
+ /**
4
+ * Detects the current device type using user agent and viewport width.
5
+ *
6
+ * By default, this function focuses on actual device/platform detection.
7
+ * Responsive width fallback is optional and mainly intended for
8
+ * responsive layout testing or browser emulation.
9
+ *
10
+ * Supports:
11
+ * - iPhone / iPad
12
+ * - Android mobile / tablet
13
+ *
14
+ * @param enableResponsiveFallback
15
+ * When enabled, classify unknown devices by viewport width.
16
+ *
17
+ * @returns `'mobile' | 'tablet' | 'desktop'`
18
+ */
19
+ export declare const getDeviceType: (enableResponsiveFallback?: boolean) => Device;
20
+ export declare const getDevice: () => "Android" | "iPhone" | "iPad" | "PC";
21
+ export declare const getDevicePlatform: () => DevicePlatform;