@everymatrix/blog-article-details 1.27.0 → 1.27.2

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 +1 @@
1
- import{p as t,b as e}from"./p-68e0210a.js";(()=>{const e=import.meta.url,s={};return""!==e&&(s.resourcesUrl=new URL(".",e).href),t(s)})().then((t=>e([["p-07387433",[[1,"blog-article-details",{cmsEndpoint:[513,"cms-endpoint"],language:[513],userRoles:[513,"user-roles"],cmsEnv:[513,"cms-env"],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"],postMessageEvent:[513,"post-message-event"],postId:[514,"post-id"],postSlug:[513,"post-slug"],postCustomPath:[513,"post-custom-path"],intlDateTimeFormat:[1,"intl-date-time-format"],hasErrors:[32],limitStylingAppends:[32],isLoading:[32],bannerMatrixReady:[32],device:[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]],t)));
1
+ import{p as t,b as e}from"./p-68e0210a.js";(()=>{const e=import.meta.url,s={};return""!==e&&(s.resourcesUrl=new URL(".",e).href),t(s)})().then((t=>e([["p-9d4b45aa",[[1,"blog-article-details",{cmsEndpoint:[513,"cms-endpoint"],language:[513],userRoles:[513,"user-roles"],cmsEnv:[513,"cms-env"],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"],postMessageEvent:[513,"post-message-event"],postId:[514,"post-id"],postSlug:[513,"post-slug"],postCustomPath:[513,"post-custom-path"],intlDateTimeFormat:[1,"intl-date-time-format"],hasErrors:[32],limitStylingAppends:[32],isLoading:[32],bannerMatrixReady:[32],device:[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]],t)));
@@ -0,0 +1 @@
1
+ import{r as t,h as i}from"./p-68e0210a.js";const n=["ro","en","fr","ar","hr"],e={en:{error:"Error"},ro:{error:"Eroare"},fr:{error:"Error"},ar:{error:"خطأ"},hr:{error:"Greška"}};const r=class{constructor(n){t(this,n),this.language="en",this.userRoles="everyone",this.cmsEnv="stage",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.postMessageEvent="articleActionButton",this.intlDateTimeFormat="",this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.device="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),i=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{i.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(i)}),1)})).catch((t=>{console.log("Error ",t)}))},this.renderContentConditionally=t=>-1!==(null==t?void 0:t.indexOf("<bannermatrix-banner"))?this.bannerMatrixReady?i("div",{class:"BlogContent",innerHTML:t}):null:i("div",{class:"BlogContent",innerHTML:t}),this.setImage=t=>{let i="";switch(this.device){case"mobile":i=t.sources[0].pictureSource;break;case"tablet":i=t.sources[1].pictureSource;break;case"desktop":i=t.sources[2].pictureSource}return i}}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.getBlogArticleDetails()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getBlogArticleDetails()}getBlogArticleDetails(){if(!this.postId&&!this.postSlug&&!this.postCustomPath)throw this.hasErrors=!0,new Error("postId, postSlug or postCustomPath parameter has to be provided!");this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts${this.postCustomPath?"":this.postSlug||this.postId}`);t.searchParams.append("env",this.cmsEnv),t.searchParams.append("userRoles",this.userRoles),t.searchParams.append("device",(()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"mtWeb"})()),this.postCustomPath&&t.searchParams.append("customURL",this.postCustomPath),fetch(t.href).then((t=>{if(t.status>=300)throw this.hasErrors=!0,new Error("There was an error while fetching the data");return t.json()})).then((t=>{if(t.count>1&&this.postCustomPath){let i=new Date(t.items[0].publishingDate),n=0;for(let e=1;e<t.items.length;e++){const r=new Date(t.items[e].publishingDate);i.getTime()<r.getTime()&&(i=r,n=e)}this.blogData=t.items[n]}else this.blogData=this.postCustomPath?t.items[0]:t;this.isLoading=!1})).catch((t=>{this.hasErrors=!0,console.log("Error",t)})).finally((()=>this.isLoading=!1))}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}componentDidLoad(){this.detectAndAlertDeviceType()}detectAndAlertDeviceType(){this.device=function(){const t=navigator.userAgent.toLowerCase();let i="";return i=t.includes("android")||t.includes("iphone")||t.includes("ipad")?function(){const t=screen.availWidth;return t<600?"mobile":t>=600&&t<1100?"tablet":void 0}():"desktop",i}()}formatDate(t){return new Intl.DateTimeFormat(this.intlDateTimeFormat||"en-GB").format(new Date(t))}render(){var t,r,s,o,h;return this.hasErrors?i("div",{class:"BlogArticleDetails"},i("div",{class:"Title"},(()=>{const t=this.language;return e[void 0!==t&&n.includes(t)?t:"en"].error})())):this.isLoading?void 0:i("div",{ref:t=>this.stylingContainer=t},i("div",{class:"GridContainer"},this.showPublishingDate&&i("div",{class:"BlogDate"},this.formatDate(null===(t=this.blogData)||void 0===t?void 0:t.publishingDate)),this.showImage&&i("div",{class:"BlogBanner"},(null===(r=this.blogData.image)||void 0===r?void 0:r.src)?i("img",{src:this.setImage(this.blogData.image),alt:this.blogData.image.slug}):(null===(s=this.blogData.video)||void 0===s?void 0:s.sources[this.device])?i("video",{src:this.blogData.video.sources[this.device],controls:!0}):i("h1",{style:{color:"white"}},"No Image")),this.showTitle&&i("div",{class:"BlogTitle"},null===(o=this.blogData)||void 0===o?void 0:o.title),this.showContent&&this.renderContentConditionally(null===(h=this.blogData)||void 0===h?void 0:h.content)))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};r.style=":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";export{r as blog_article_details}
@@ -140,7 +140,7 @@ const BlogArticleDetails = class {
140
140
  setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
141
141
  })
142
142
  .catch((err) => {
143
- console.log('error ', err);
143
+ console.log('Error ', err);
144
144
  });
145
145
  };
146
146
  this.renderContentConditionally = (content) => {
@@ -189,7 +189,7 @@ const BlogArticleDetails = class {
189
189
  throw new Error('postId, postSlug or postCustomPath parameter has to be provided!');
190
190
  }
191
191
  this.isLoading = true;
192
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postCustomPath ? '' : this.postSlug || this.postId}`);
192
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts${this.postCustomPath ? '' : this.postSlug || this.postId}`);
193
193
  url.searchParams.append('env', this.cmsEnv);
194
194
  url.searchParams.append('userRoles', this.userRoles);
195
195
  url.searchParams.append('device', getDevicePlatform());
@@ -206,12 +206,12 @@ const BlogArticleDetails = class {
206
206
  })
207
207
  .then((blogContent) => {
208
208
  if (blogContent.count > 1 && this.postCustomPath) {
209
- let difference = new Date(blogContent.items[0].publishingDate);
210
- let indexOfLatestPublished;
209
+ let firstBlogPublishDate = new Date(blogContent.items[0].publishingDate);
210
+ let indexOfLatestPublished = 0;
211
211
  for (let i = 1; i < blogContent.items.length; i++) {
212
- const givenDate = new Date(blogContent.items[i].publishingDate);
213
- if (difference < givenDate) {
214
- difference = givenDate;
212
+ const blogDate = new Date(blogContent.items[i].publishingDate);
213
+ if (firstBlogPublishDate.getTime() < blogDate.getTime()) {
214
+ firstBlogPublishDate = blogDate;
215
215
  indexOfLatestPublished = i;
216
216
  }
217
217
  }
@@ -67,7 +67,7 @@ export class BlogArticleDetails {
67
67
  setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
68
68
  })
69
69
  .catch((err) => {
70
- console.log('error ', err);
70
+ console.log('Error ', err);
71
71
  });
72
72
  };
73
73
  this.renderContentConditionally = (content) => {
@@ -116,7 +116,7 @@ export class BlogArticleDetails {
116
116
  throw new Error('postId, postSlug or postCustomPath parameter has to be provided!');
117
117
  }
118
118
  this.isLoading = true;
119
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postCustomPath ? '' : this.postSlug || this.postId}`);
119
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts${this.postCustomPath ? '' : this.postSlug || this.postId}`);
120
120
  url.searchParams.append('env', this.cmsEnv);
121
121
  url.searchParams.append('userRoles', this.userRoles);
122
122
  url.searchParams.append('device', getDevicePlatform());
@@ -133,12 +133,12 @@ export class BlogArticleDetails {
133
133
  })
134
134
  .then((blogContent) => {
135
135
  if (blogContent.count > 1 && this.postCustomPath) {
136
- let difference = new Date(blogContent.items[0].publishingDate);
137
- let indexOfLatestPublished;
136
+ let firstBlogPublishDate = new Date(blogContent.items[0].publishingDate);
137
+ let indexOfLatestPublished = 0;
138
138
  for (let i = 1; i < blogContent.items.length; i++) {
139
- const givenDate = new Date(blogContent.items[i].publishingDate);
140
- if (difference < givenDate) {
141
- difference = givenDate;
139
+ const blogDate = new Date(blogContent.items[i].publishingDate);
140
+ if (firstBlogPublishDate.getTime() < blogDate.getTime()) {
141
+ firstBlogPublishDate = blogDate;
142
142
  indexOfLatestPublished = i;
143
143
  }
144
144
  }
@@ -138,7 +138,7 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
138
138
  setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
139
139
  })
140
140
  .catch((err) => {
141
- console.log('error ', err);
141
+ console.log('Error ', err);
142
142
  });
143
143
  };
144
144
  this.renderContentConditionally = (content) => {
@@ -187,7 +187,7 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
187
187
  throw new Error('postId, postSlug or postCustomPath parameter has to be provided!');
188
188
  }
189
189
  this.isLoading = true;
190
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postCustomPath ? '' : this.postSlug || this.postId}`);
190
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts${this.postCustomPath ? '' : this.postSlug || this.postId}`);
191
191
  url.searchParams.append('env', this.cmsEnv);
192
192
  url.searchParams.append('userRoles', this.userRoles);
193
193
  url.searchParams.append('device', getDevicePlatform());
@@ -204,12 +204,12 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
204
204
  })
205
205
  .then((blogContent) => {
206
206
  if (blogContent.count > 1 && this.postCustomPath) {
207
- let difference = new Date(blogContent.items[0].publishingDate);
208
- let indexOfLatestPublished;
207
+ let firstBlogPublishDate = new Date(blogContent.items[0].publishingDate);
208
+ let indexOfLatestPublished = 0;
209
209
  for (let i = 1; i < blogContent.items.length; i++) {
210
- const givenDate = new Date(blogContent.items[i].publishingDate);
211
- if (difference < givenDate) {
212
- difference = givenDate;
210
+ const blogDate = new Date(blogContent.items[i].publishingDate);
211
+ if (firstBlogPublishDate.getTime() < blogDate.getTime()) {
212
+ firstBlogPublishDate = blogDate;
213
213
  indexOfLatestPublished = i;
214
214
  }
215
215
  }
@@ -136,7 +136,7 @@ const BlogArticleDetails = class {
136
136
  setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
137
137
  })
138
138
  .catch((err) => {
139
- console.log('error ', err);
139
+ console.log('Error ', err);
140
140
  });
141
141
  };
142
142
  this.renderContentConditionally = (content) => {
@@ -185,7 +185,7 @@ const BlogArticleDetails = class {
185
185
  throw new Error('postId, postSlug or postCustomPath parameter has to be provided!');
186
186
  }
187
187
  this.isLoading = true;
188
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postCustomPath ? '' : this.postSlug || this.postId}`);
188
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts${this.postCustomPath ? '' : this.postSlug || this.postId}`);
189
189
  url.searchParams.append('env', this.cmsEnv);
190
190
  url.searchParams.append('userRoles', this.userRoles);
191
191
  url.searchParams.append('device', getDevicePlatform());
@@ -202,12 +202,12 @@ const BlogArticleDetails = class {
202
202
  })
203
203
  .then((blogContent) => {
204
204
  if (blogContent.count > 1 && this.postCustomPath) {
205
- let difference = new Date(blogContent.items[0].publishingDate);
206
- let indexOfLatestPublished;
205
+ let firstBlogPublishDate = new Date(blogContent.items[0].publishingDate);
206
+ let indexOfLatestPublished = 0;
207
207
  for (let i = 1; i < blogContent.items.length; i++) {
208
- const givenDate = new Date(blogContent.items[i].publishingDate);
209
- if (difference < givenDate) {
210
- difference = givenDate;
208
+ const blogDate = new Date(blogContent.items[i].publishingDate);
209
+ if (firstBlogPublishDate.getTime() < blogDate.getTime()) {
210
+ firstBlogPublishDate = blogDate;
211
211
  indexOfLatestPublished = i;
212
212
  }
213
213
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/blog-article-details",
3
- "version": "1.27.0",
3
+ "version": "1.27.2",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1 +0,0 @@
1
- import{r as t,h as i}from"./p-68e0210a.js";const n=["ro","en","fr","ar","hr"],e={en:{error:"Error"},ro:{error:"Eroare"},fr:{error:"Error"},ar:{error:"خطأ"},hr:{error:"Greška"}};const r=class{constructor(n){t(this,n),this.language="en",this.userRoles="everyone",this.cmsEnv="stage",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.postMessageEvent="articleActionButton",this.intlDateTimeFormat="",this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.device="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),i=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{i.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(i)}),1)})).catch((t=>{console.log("error ",t)}))},this.renderContentConditionally=t=>-1!==(null==t?void 0:t.indexOf("<bannermatrix-banner"))?this.bannerMatrixReady?i("div",{class:"BlogContent",innerHTML:t}):null:i("div",{class:"BlogContent",innerHTML:t}),this.setImage=t=>{let i="";switch(this.device){case"mobile":i=t.sources[0].pictureSource;break;case"tablet":i=t.sources[1].pictureSource;break;case"desktop":i=t.sources[2].pictureSource}return i}}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.getBlogArticleDetails()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getBlogArticleDetails()}getBlogArticleDetails(){if(!this.postId&&!this.postSlug&&!this.postCustomPath)throw this.hasErrors=!0,new Error("postId, postSlug or postCustomPath parameter has to be provided!");this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postCustomPath?"":this.postSlug||this.postId}`);t.searchParams.append("env",this.cmsEnv),t.searchParams.append("userRoles",this.userRoles),t.searchParams.append("device",(()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"mtWeb"})()),this.postCustomPath&&t.searchParams.append("customURL",this.postCustomPath),fetch(t.href).then((t=>{if(t.status>=300)throw this.hasErrors=!0,new Error("There was an error while fetching the data");return t.json()})).then((t=>{if(t.count>1&&this.postCustomPath){let i,n=new Date(t.items[0].publishingDate);for(let e=1;e<t.items.length;e++){const r=new Date(t.items[e].publishingDate);n<r&&(n=r,i=e)}this.blogData=t.items[i]}else this.blogData=this.postCustomPath?t.items[0]:t;this.isLoading=!1})).catch((t=>{this.hasErrors=!0,console.log("Error",t)})).finally((()=>this.isLoading=!1))}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}componentDidLoad(){this.detectAndAlertDeviceType()}detectAndAlertDeviceType(){this.device=function(){const t=navigator.userAgent.toLowerCase();let i="";return i=t.includes("android")||t.includes("iphone")||t.includes("ipad")?function(){const t=screen.availWidth;return t<600?"mobile":t>=600&&t<1100?"tablet":void 0}():"desktop",i}()}formatDate(t){return new Intl.DateTimeFormat(this.intlDateTimeFormat||"en-GB").format(new Date(t))}render(){var t,r,s,o,h;return this.hasErrors?i("div",{class:"BlogArticleDetails"},i("div",{class:"Title"},(()=>{const t=this.language;return e[void 0!==t&&n.includes(t)?t:"en"].error})())):this.isLoading?void 0:i("div",{ref:t=>this.stylingContainer=t},i("div",{class:"GridContainer"},this.showPublishingDate&&i("div",{class:"BlogDate"},this.formatDate(null===(t=this.blogData)||void 0===t?void 0:t.publishingDate)),this.showImage&&i("div",{class:"BlogBanner"},(null===(r=this.blogData.image)||void 0===r?void 0:r.src)?i("img",{src:this.setImage(this.blogData.image),alt:this.blogData.image.slug}):(null===(s=this.blogData.video)||void 0===s?void 0:s.sources[this.device])?i("video",{src:this.blogData.video.sources[this.device],controls:!0}):i("h1",{style:{color:"white"}},"No Image")),this.showTitle&&i("div",{class:"BlogTitle"},null===(o=this.blogData)||void 0===o?void 0:o.title),this.showContent&&this.renderContentConditionally(null===(h=this.blogData)||void 0===h?void 0:h.content)))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};r.style=":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";export{r as blog_article_details}