@everymatrix/blog-articles-grid 1.98.29 → 1.98.31

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.
@@ -8,43 +8,43 @@ export class BlogArticlesGrid {
8
8
  this.lastPage = 1;
9
9
  this.isInitialized = false;
10
10
  this.paginationDefaultStyling = `
11
- div#PaginationContainer {
11
+ nav#PaginationContainer {
12
12
  justify-content: right;
13
13
  }
14
- .LeftItems button .NavigationButton {
14
+ .LeftItems a .NavigationButton {
15
15
  display: none;
16
16
  }
17
- .LeftItems button:after, .RightItems button:after {
17
+ .LeftItems a:after, .RightItems a:after {
18
18
  padding: 7px 12px;
19
19
  font-size: 18px;
20
20
  font-weight: 700;
21
21
  line-height: 46px;
22
22
  }
23
- .LeftItems button:after {
23
+ .LeftItems a:after {
24
24
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='1.2em' viewBox='0 0 320 512'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z'/%3E%3C/svg%3E");
25
25
  }
26
- .RightItems button:after {
26
+ .RightItems a:after {
27
27
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='1.2em' viewBox='0 0 320 512'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d='M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z'/%3E%3C/svg%3E");
28
28
  display: block;
29
29
  height: 38px;
30
30
  }
31
- div.LeftItems button, div.RightItems button {
31
+ div.LeftItems a, div.RightItems a {
32
32
  width: unset;
33
33
  height: 40px;
34
34
  background-color: #fff;
35
35
  color: #000;
36
36
  border: 1px solid #000;
37
37
  overflow: hidden;
38
- &:disabled {
38
+ &[aria-disabled="true"] {
39
39
  background-color: #989898;
40
40
  }
41
41
  }
42
- div.LeftItems button {
42
+ div.LeftItems a {
43
43
  min-width: 60px;
44
44
  border-radius: 20px 0 0 20px;
45
45
  border-right: 0;
46
46
  }
47
- div.RightItems button {
47
+ div.RightItems a {
48
48
  display: flex;
49
49
  min-width: 100px;
50
50
  justify-content: space-evenly;
@@ -52,7 +52,7 @@ export class BlogArticlesGrid {
52
52
  border-radius: 0 20px 20px 0;
53
53
  text-transform: none;
54
54
  }
55
- .RightItems button .NavigationButton {
55
+ .RightItems a .NavigationButton {
56
56
  padding: 12px 0 12px 12px;
57
57
  font-weight: 700;
58
58
  }`;
@@ -67,6 +67,7 @@ export class BlogArticlesGrid {
67
67
  };
68
68
  this.cmsEndpoint = undefined;
69
69
  this.language = 'en';
70
+ this.translationUrl = '';
70
71
  this.userRoles = 'everyone';
71
72
  this.cmsEnv = 'stage';
72
73
  this.mbSource = undefined;
@@ -75,6 +76,8 @@ export class BlogArticlesGrid {
75
76
  this.showPublishingDate = true;
76
77
  this.showImage = true;
77
78
  this.showTitle = true;
79
+ this.showPageTitle = false;
80
+ this.showBreadcrumb = false;
78
81
  this.showContent = true;
79
82
  this.showButton = true;
80
83
  this.hideError = false;
@@ -87,6 +90,7 @@ export class BlogArticlesGrid {
87
90
  this.numberedNavActive = false;
88
91
  this.intlDateTimeFormat = '';
89
92
  this.page = '1';
93
+ this.pageQueryParam = undefined;
90
94
  this.eventId = undefined;
91
95
  this.paginationBlogList = {
92
96
  offset: 0
@@ -102,6 +106,7 @@ export class BlogArticlesGrid {
102
106
  this.paginationBlogResponse = undefined;
103
107
  this.allBlogResponse = undefined;
104
108
  this.totalBlogs = 0;
109
+ this.customTranslations = {};
105
110
  }
106
111
  getArticleId(event, post) {
107
112
  var _a;
@@ -140,6 +145,21 @@ export class BlogArticlesGrid {
140
145
  setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
141
146
  }
142
147
  }
148
+ async loadTranslations() {
149
+ if (!this.translationUrl) {
150
+ this.customTranslations = {};
151
+ return;
152
+ }
153
+ try {
154
+ const response = await fetch(this.translationUrl);
155
+ if (!response.ok)
156
+ throw new Error(`HTTP error! status: ${response.status}`);
157
+ this.customTranslations = await response.json();
158
+ }
159
+ catch (error) {
160
+ console.error('Failed to fetch or parse translations from URL:', error);
161
+ }
162
+ }
143
163
  hpPageChange(event) {
144
164
  var _a, _b;
145
165
  this.paginationBlogList = event.detail;
@@ -280,6 +300,7 @@ export class BlogArticlesGrid {
280
300
  this.getBlogArticleGrid();
281
301
  }
282
302
  }
303
+ return this.loadTranslations();
283
304
  }
284
305
  handleClientStyling() {
285
306
  if (window.emMessageBus !== undefined) {
@@ -320,7 +341,7 @@ export class BlogArticlesGrid {
320
341
  }
321
342
  render() {
322
343
  if (this.hasErrors) {
323
- return (h("div", { class: "BlogsContainer" }, !this.hideError && (h("div", { class: "ErrorMessage" }, translate('error', this.language)))));
344
+ return (h("div", { class: "BlogsContainer" }, !this.hideError && (h("div", { class: "ErrorMessage" }, translate('error', this.language, this.customTranslations)))));
324
345
  }
325
346
  // Create an array to store the placeholder elements for each card
326
347
  const placeholderCards = [];
@@ -330,14 +351,14 @@ export class BlogArticlesGrid {
330
351
  }
331
352
  const showPagination = Boolean(this.paginationActive) && this.totalBlogs > +this.blogsLimit;
332
353
  const paginationClientStyling = !this.mbSource ? (this.clientStyling || this.paginationDefaultStyling) : undefined;
333
- 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) &&
354
+ return (h("div", { ref: el => this.stylingContainer = el }, this.showBreadcrumb && (h("nav", { class: "breadcrumb", "aria-label": "Breadcrumb" }, h("a", { href: `/${encodeURIComponent(this.language)}` }, translate('home', this.language, this.customTranslations)), h("span", { "aria-hidden": "true" }, "\u203A"), h("span", { "aria-current": "page" }, translate('blog', this.language, this.customTranslations)))), this.showPageTitle && h("h1", { class: "BlogPageTitle" }, translate('blogPageTitle', this.language, this.customTranslations)), 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, "page-query-param": this.pageQueryParam, page: +this.page || 1 })), (!this.isLoading) &&
334
355
  h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage} ${this.device}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
335
356
  var _a, _b;
336
357
  return h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, this.showPublishingDate &&
337
358
  h("div", { class: "BlogDate" }, h("time", { dateTime: data.publishingDate }, this.formatDate(data.publishingDate))), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (h("img", { class: "VisualContent", src: this.setImage(data.image), alt: data.image.alt || data.title, width: "400", height: "225", loading: "lazy" })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (h("video", { class: "VisualContent", src: data.video.sources[this.device] })) : (h("span", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), h("div", { class: "GridSector" }, this.showTitle &&
338
359
  h("h2", { class: "BlogTitle" }, h("a", { class: "BlogCardLink", href: `/${encodeURIComponent(this.language)}/blog/${encodeURIComponent(data.customPath || data.slug)}`, onClick: event => this.getArticleId(event, data) }, data.title)), this.showContent &&
339
360
  this.renderContentConditionally(data.descriptionPreview), this.showButton &&
340
- h("span", { class: "BlogLink" }, translate('readmore', this.language)))));
361
+ h("span", { class: "BlogLink" }, translate('readmore', this.language, this.customTranslations)))));
341
362
  })), (this.isLoading) &&
342
363
  h("div", { class: "GridContainerWrapper LoadingGrid" }, placeholderCards))));
343
364
  }
@@ -390,6 +411,24 @@ export class BlogArticlesGrid {
390
411
  "reflect": true,
391
412
  "defaultValue": "'en'"
392
413
  },
414
+ "translationUrl": {
415
+ "type": "string",
416
+ "mutable": false,
417
+ "complexType": {
418
+ "original": "string",
419
+ "resolved": "string",
420
+ "references": {}
421
+ },
422
+ "required": false,
423
+ "optional": false,
424
+ "docs": {
425
+ "tags": [],
426
+ "text": "Override translations using a language-keyed JSON file"
427
+ },
428
+ "attribute": "translation-url",
429
+ "reflect": true,
430
+ "defaultValue": "''"
431
+ },
393
432
  "userRoles": {
394
433
  "type": "string",
395
434
  "mutable": false,
@@ -533,6 +572,42 @@ export class BlogArticlesGrid {
533
572
  "reflect": true,
534
573
  "defaultValue": "true"
535
574
  },
575
+ "showPageTitle": {
576
+ "type": "boolean",
577
+ "mutable": false,
578
+ "complexType": {
579
+ "original": "boolean",
580
+ "resolved": "boolean",
581
+ "references": {}
582
+ },
583
+ "required": false,
584
+ "optional": false,
585
+ "docs": {
586
+ "tags": [],
587
+ "text": "Display the blog page heading independently of card titles"
588
+ },
589
+ "attribute": "show-page-title",
590
+ "reflect": true,
591
+ "defaultValue": "false"
592
+ },
593
+ "showBreadcrumb": {
594
+ "type": "boolean",
595
+ "mutable": false,
596
+ "complexType": {
597
+ "original": "boolean",
598
+ "resolved": "boolean",
599
+ "references": {}
600
+ },
601
+ "required": false,
602
+ "optional": false,
603
+ "docs": {
604
+ "tags": [],
605
+ "text": "Display breadcrumb navigation"
606
+ },
607
+ "attribute": "show-breadcrumb",
608
+ "reflect": true,
609
+ "defaultValue": "false"
610
+ },
536
611
  "showContent": {
537
612
  "type": "boolean",
538
613
  "mutable": false,
@@ -747,6 +822,23 @@ export class BlogArticlesGrid {
747
822
  "reflect": true,
748
823
  "defaultValue": "'1'"
749
824
  },
825
+ "pageQueryParam": {
826
+ "type": "string",
827
+ "mutable": false,
828
+ "complexType": {
829
+ "original": "string",
830
+ "resolved": "string",
831
+ "references": {}
832
+ },
833
+ "required": false,
834
+ "optional": true,
835
+ "docs": {
836
+ "tags": [],
837
+ "text": ""
838
+ },
839
+ "attribute": "page-query-param",
840
+ "reflect": false
841
+ },
750
842
  "eventId": {
751
843
  "type": "string",
752
844
  "mutable": false,
@@ -779,7 +871,8 @@ export class BlogArticlesGrid {
779
871
  "displayedBlogResponse": {},
780
872
  "paginationBlogResponse": {},
781
873
  "allBlogResponse": {},
782
- "totalBlogs": {}
874
+ "totalBlogs": {},
875
+ "customTranslations": {}
783
876
  };
784
877
  }
785
878
  static get events() {
@@ -836,6 +929,9 @@ export class BlogArticlesGrid {
836
929
  }, {
837
930
  "propName": "clientStylingUrl",
838
931
  "methodName": "handleClientStylingChangeURL"
932
+ }, {
933
+ "propName": "translationUrl",
934
+ "methodName": "loadTranslations"
839
935
  }];
840
936
  }
841
937
  static get listeners() {
@@ -3,37 +3,63 @@ const TRANSLATIONS = {
3
3
  en: {
4
4
  error: 'Error',
5
5
  readmore: 'Read more',
6
+ home: 'Home',
7
+ blog: 'Blog',
8
+ blogPageTitle: 'Blog',
6
9
  },
7
10
  ro: {
8
11
  error: 'Eroare',
9
12
  readmore: 'Read more',
13
+ home: 'Acasă',
14
+ blog: 'Blog',
15
+ blogPageTitle: 'Blog',
10
16
  },
11
17
  fr: {
12
18
  error: 'Error',
13
19
  readmore: 'Read more',
20
+ home: 'Accueil',
21
+ blog: 'Blog',
22
+ blogPageTitle: 'Blog',
14
23
  },
15
24
  ar: {
16
25
  error: 'خطأ',
17
26
  readmore: 'Read more',
27
+ home: 'الرئيسية',
28
+ blog: 'المدونة',
29
+ blogPageTitle: 'المدونة',
18
30
  },
19
31
  hu: {
20
32
  error: 'خطأ',
21
33
  readmore: 'Tovább olvasom',
34
+ home: 'Kezdőlap',
35
+ blog: 'Blog',
36
+ blogPageTitle: 'Blog',
22
37
  },
23
38
  hr: {
24
39
  error: 'Greška',
25
- readmore: 'Pročitaj više'
40
+ readmore: 'Pročitaj više',
41
+ home: 'Početna',
42
+ blog: 'Blog',
43
+ blogPageTitle: 'Blog',
26
44
  },
27
45
  'pt-br': {
28
46
  error: 'Erro',
29
- readmore: 'Ler mais'
47
+ readmore: 'Ler mais',
48
+ home: 'Início',
49
+ blog: 'Blog',
50
+ blogPageTitle: 'Blog',
30
51
  },
31
52
  'es-mx': {
32
53
  error: 'Error',
33
- readmore: 'Leer más'
54
+ readmore: 'Leer más',
55
+ home: 'Inicio',
56
+ blog: 'Blog',
57
+ blogPageTitle: 'Blog',
34
58
  }
35
59
  };
36
- export const translate = (key, customLang) => {
37
- const lang = customLang;
38
- return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
60
+ export const translate = (key, customLang, customTranslations) => {
61
+ var _a;
62
+ const lang = customLang !== null && customLang !== void 0 ? customLang : DEFAULT_LANGUAGE;
63
+ const override = (_a = customTranslations === null || customTranslations === void 0 ? void 0 : customTranslations[lang]) === null || _a === void 0 ? void 0 : _a[key];
64
+ return typeof override === 'string' ? override : TRANSLATIONS[lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
39
65
  };
@@ -16,5 +16,5 @@ var patchBrowser = () => {
16
16
 
17
17
  patchBrowser().then(async (options) => {
18
18
  await globalScripts();
19
- return bootstrapLazy([["blog-articles-grid_2",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"hideError":[516,"hide-error"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"displayedBlogResponse":[32],"paginationBlogResponse":[32],"allBlogResponse":[32],"totalBlogs":[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{"page":["watchEndpoint"],"hasErrors":["watchEndpoint"],"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"cmsEnv":["watchEndpoint"],"userRoles":["watchEndpoint"],"blogsLimit":["watchEndpoint"],"eventId":["watchEndpoint"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}],[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"mbSource":[1,"mb-source"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[1537,"client-styling-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
19
+ return bootstrapLazy([["blog-articles-grid_2",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"translationUrl":[513,"translation-url"],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showPageTitle":[516,"show-page-title"],"showBreadcrumb":[516,"show-breadcrumb"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"hideError":[516,"hide-error"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"pageQueryParam":[1,"page-query-param"],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"displayedBlogResponse":[32],"paginationBlogResponse":[32],"allBlogResponse":[32],"totalBlogs":[32],"customTranslations":[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{"page":["watchEndpoint"],"hasErrors":["watchEndpoint"],"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"cmsEnv":["watchEndpoint"],"userRoles":["watchEndpoint"],"blogsLimit":["watchEndpoint"],"eventId":["watchEndpoint"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"],"translationUrl":["loadTranslations"]}],[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"mbSource":[1,"mb-source"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[1537,"client-styling-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"pageQueryParam":[1,"page-query-param"],"page":[2],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
20
20
  });