@everymatrix/blog-article-details 1.13.4 → 1.13.6
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.
- package/dist/blog-article-details/blog-article-details.esm.js +1 -1
- package/dist/blog-article-details/p-493d4f13.entry.js +1 -0
- package/dist/cjs/blog-article-details.cjs.entry.js +18 -7
- package/dist/cjs/blog-article-details.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/blog-article-details/blog-article-details.js +21 -10
- package/dist/components/blog-article-details.js +20 -9
- package/dist/esm/blog-article-details.entry.js +18 -7
- package/dist/esm/blog-article-details.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/blog-article-details/blog-article-details.d.ts +3 -2
- package/package.json +1 -1
- package/dist/blog-article-details/p-32c04b78.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as n}from"./p-b3ab7cf8.js";(()=>{const n=import.meta.url,t={};return""!==n&&(t.resourcesUrl=new URL(".",n).href),e(t)})().then((e=>n([["p-
|
|
1
|
+
import{p as e,b as n}from"./p-b3ab7cf8.js";(()=>{const n=import.meta.url,t={};return""!==n&&(t.resourcesUrl=new URL(".",n).href),e(t)})().then((e=>n([["p-493d4f13",[[1,"blog-article-details",{cmsEndpoint:[1,"cms-endpoint"],language:[1],handleClick:[1,"handle-click"],clientStyling:[1,"client-styling"],clientStylingUrl:[1,"client-styling-url"],showPublishingDate:[4,"show-publishing-date"],showImage:[4,"show-image"],showTitle:[4,"show-title"],showContent:[4,"show-content"],postMessageEvent:[1,"post-message-event"],postId:[2,"post-id"],hasErrors:[32],limitStylingAppends:[32],isLoading:[32],bannerMatrixReady:[32]},[[8,"WebComponentsReady","handleBannerReady"]]]]]],e)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,h as i}from"./p-b3ab7cf8.js";const n=["ro","en","fr","ar"],r={en:{error:"Error"},ro:{error:"Eroare"},fr:{error:"Error"},ar:{error:"خطأ"}},o=class{constructor(n){t(this,n),this.language="en",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.postMessageEvent="articleActionButton",this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.bannerMatrixReady=!1,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=>{var n,r;return-1!==(null==t?void 0:t.indexOf("<bannermatrix-banner"))?this.bannerMatrixReady?i("div",{class:"BlogContent",innerHTML:null===(r=this.blogData)||void 0===r?void 0:r.content}):null:i("div",{class:"BlogContent",innerHTML:null===(n=this.blogData)||void 0===n?void 0:n.content})}}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&&isNaN(this.postId))throw this.hasErrors=!0,new Error("The postId parameter is missing!");this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);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=>{this.blogData=t,this.blogData.publishingDate=new Date(this.blogData.publishingDate).toLocaleDateString(),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)}render(){var t,o,s,e;return this.hasErrors?i("div",{class:"BlogArticleDetails"},i("div",{class:"Title"},(()=>{const t=this.language;return r[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"},null===(t=this.blogData)||void 0===t?void 0:t.publishingDate),this.showImage&&i("div",{class:"BlogBanner"},i("img",{src:this.blogData.image.src,alt:null===(o=this.blogData)||void 0===o?void 0:o.title})),this.showTitle&&i("div",{class:"BlogTitle"},null===(s=this.blogData)||void 0===s?void 0:s.title),this.showContent&&this.renderContentConditionally(null===(e=this.blogData)||void 0===e?void 0:e.content)))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};o.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}\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{o as blog_article_details}
|
|
@@ -65,7 +65,7 @@ const BlogArticleDetails = class {
|
|
|
65
65
|
this.hasErrors = false;
|
|
66
66
|
this.limitStylingAppends = false;
|
|
67
67
|
this.isLoading = true;
|
|
68
|
-
this.
|
|
68
|
+
this.bannerMatrixReady = false;
|
|
69
69
|
this.setClientStyling = () => {
|
|
70
70
|
let sheet = document.createElement('style');
|
|
71
71
|
sheet.innerHTML = this.clientStyling;
|
|
@@ -84,10 +84,21 @@ const BlogArticleDetails = class {
|
|
|
84
84
|
console.log('error ', err);
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
+
this.renderContentConditionally = (content) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const hasBanner = (content === null || content === void 0 ? void 0 : content.indexOf('<bannermatrix-banner')) !== -1;
|
|
90
|
+
if (!hasBanner) {
|
|
91
|
+
return index.h("div", { class: "BlogContent", innerHTML: (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.content });
|
|
92
|
+
}
|
|
93
|
+
if (this.bannerMatrixReady) {
|
|
94
|
+
return index.h("div", { class: "BlogContent", innerHTML: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.content });
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
87
98
|
}
|
|
88
99
|
// Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
|
|
89
|
-
|
|
90
|
-
this.
|
|
100
|
+
handleBannerReady() {
|
|
101
|
+
this.bannerMatrixReady = true;
|
|
91
102
|
}
|
|
92
103
|
watchEndpoint(newValue, oldValue) {
|
|
93
104
|
if (newValue && newValue != oldValue && this.cmsEndpoint) {
|
|
@@ -137,15 +148,15 @@ const BlogArticleDetails = class {
|
|
|
137
148
|
// end custom styling area
|
|
138
149
|
}
|
|
139
150
|
render() {
|
|
151
|
+
var _a, _b, _c, _d;
|
|
140
152
|
if (this.hasErrors) {
|
|
141
153
|
return (index.h("div", { class: "BlogArticleDetails" }, index.h("div", { class: "Title" }, translate('error', this.language))));
|
|
142
154
|
}
|
|
143
155
|
if (!this.isLoading) {
|
|
144
156
|
return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "GridContainer" }, this.showPublishingDate &&
|
|
145
|
-
index.h("div", { class: "BlogDate" }, this.blogData.publishingDate), this.showImage &&
|
|
146
|
-
index.h("div", { class: "BlogBanner" }, index.h("img", { src: this.blogData.image.src, alt: this.blogData.title })), this.showTitle &&
|
|
147
|
-
index.h("div", { class: "BlogTitle" }, this.blogData.title), this.showContent &&
|
|
148
|
-
index.h("div", { class: "BlogContent", innerHTML: this.blogData.content }))));
|
|
157
|
+
index.h("div", { class: "BlogDate" }, (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate), this.showImage &&
|
|
158
|
+
index.h("div", { class: "BlogBanner" }, index.h("img", { src: this.blogData.image.src, alt: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.title })), this.showTitle &&
|
|
159
|
+
index.h("div", { class: "BlogTitle" }, (_c = this.blogData) === null || _c === void 0 ? void 0 : _c.title), this.showContent && this.renderContentConditionally((_d = this.blogData) === null || _d === void 0 ? void 0 : _d.content))));
|
|
149
160
|
}
|
|
150
161
|
}
|
|
151
162
|
static get watchers() { return {
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"
|
|
18
|
+
return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32]},[[8,"WebComponentsReady","handleBannerReady"]]]]]], options);
|
|
19
19
|
});
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"
|
|
17
|
+
return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32]},[[8,"WebComponentsReady","handleBannerReady"]]]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -37,7 +37,7 @@ export class BlogArticleDetails {
|
|
|
37
37
|
this.hasErrors = false;
|
|
38
38
|
this.limitStylingAppends = false;
|
|
39
39
|
this.isLoading = true;
|
|
40
|
-
this.
|
|
40
|
+
this.bannerMatrixReady = false;
|
|
41
41
|
this.setClientStyling = () => {
|
|
42
42
|
let sheet = document.createElement('style');
|
|
43
43
|
sheet.innerHTML = this.clientStyling;
|
|
@@ -56,10 +56,21 @@ export class BlogArticleDetails {
|
|
|
56
56
|
console.log('error ', err);
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
|
+
this.renderContentConditionally = (content) => {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const hasBanner = (content === null || content === void 0 ? void 0 : content.indexOf('<bannermatrix-banner')) !== -1;
|
|
62
|
+
if (!hasBanner) {
|
|
63
|
+
return h("div", { class: "BlogContent", innerHTML: (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.content });
|
|
64
|
+
}
|
|
65
|
+
if (this.bannerMatrixReady) {
|
|
66
|
+
return h("div", { class: "BlogContent", innerHTML: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.content });
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
59
70
|
}
|
|
60
71
|
// Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
|
|
61
|
-
|
|
62
|
-
this.
|
|
72
|
+
handleBannerReady() {
|
|
73
|
+
this.bannerMatrixReady = true;
|
|
63
74
|
}
|
|
64
75
|
watchEndpoint(newValue, oldValue) {
|
|
65
76
|
if (newValue && newValue != oldValue && this.cmsEndpoint) {
|
|
@@ -109,6 +120,7 @@ export class BlogArticleDetails {
|
|
|
109
120
|
// end custom styling area
|
|
110
121
|
}
|
|
111
122
|
render() {
|
|
123
|
+
var _a, _b, _c, _d;
|
|
112
124
|
if (this.hasErrors) {
|
|
113
125
|
return (h("div", { class: "BlogArticleDetails" },
|
|
114
126
|
h("div", { class: "Title" }, translate('error', this.language))));
|
|
@@ -117,14 +129,13 @@ export class BlogArticleDetails {
|
|
|
117
129
|
return (h("div", { ref: el => this.stylingContainer = el },
|
|
118
130
|
h("div", { class: "GridContainer" },
|
|
119
131
|
this.showPublishingDate &&
|
|
120
|
-
h("div", { class: "BlogDate" }, this.blogData.publishingDate),
|
|
132
|
+
h("div", { class: "BlogDate" }, (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate),
|
|
121
133
|
this.showImage &&
|
|
122
134
|
h("div", { class: "BlogBanner" },
|
|
123
|
-
h("img", { src: this.blogData.image.src, alt: this.blogData.title })),
|
|
135
|
+
h("img", { src: this.blogData.image.src, alt: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.title })),
|
|
124
136
|
this.showTitle &&
|
|
125
|
-
h("div", { class: "BlogTitle" }, this.blogData.title),
|
|
126
|
-
this.showContent &&
|
|
127
|
-
h("div", { class: "BlogContent", innerHTML: this.blogData.content }))));
|
|
137
|
+
h("div", { class: "BlogTitle" }, (_c = this.blogData) === null || _c === void 0 ? void 0 : _c.title),
|
|
138
|
+
this.showContent && this.renderContentConditionally((_d = this.blogData) === null || _d === void 0 ? void 0 : _d.content))));
|
|
128
139
|
}
|
|
129
140
|
}
|
|
130
141
|
static get is() { return "blog-article-details"; }
|
|
@@ -336,7 +347,7 @@ export class BlogArticleDetails {
|
|
|
336
347
|
"hasErrors": {},
|
|
337
348
|
"limitStylingAppends": {},
|
|
338
349
|
"isLoading": {},
|
|
339
|
-
"
|
|
350
|
+
"bannerMatrixReady": {}
|
|
340
351
|
}; }
|
|
341
352
|
static get watchers() { return [{
|
|
342
353
|
"propName": "cmsEndpoint",
|
|
@@ -347,7 +358,7 @@ export class BlogArticleDetails {
|
|
|
347
358
|
}]; }
|
|
348
359
|
static get listeners() { return [{
|
|
349
360
|
"name": "WebComponentsReady",
|
|
350
|
-
"method": "
|
|
361
|
+
"method": "handleBannerReady",
|
|
351
362
|
"target": "window",
|
|
352
363
|
"capture": false,
|
|
353
364
|
"passive": false
|
|
@@ -63,7 +63,7 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
|
63
63
|
this.hasErrors = false;
|
|
64
64
|
this.limitStylingAppends = false;
|
|
65
65
|
this.isLoading = true;
|
|
66
|
-
this.
|
|
66
|
+
this.bannerMatrixReady = false;
|
|
67
67
|
this.setClientStyling = () => {
|
|
68
68
|
let sheet = document.createElement('style');
|
|
69
69
|
sheet.innerHTML = this.clientStyling;
|
|
@@ -82,10 +82,21 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
|
82
82
|
console.log('error ', err);
|
|
83
83
|
});
|
|
84
84
|
};
|
|
85
|
+
this.renderContentConditionally = (content) => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
const hasBanner = (content === null || content === void 0 ? void 0 : content.indexOf('<bannermatrix-banner')) !== -1;
|
|
88
|
+
if (!hasBanner) {
|
|
89
|
+
return h("div", { class: "BlogContent", innerHTML: (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.content });
|
|
90
|
+
}
|
|
91
|
+
if (this.bannerMatrixReady) {
|
|
92
|
+
return h("div", { class: "BlogContent", innerHTML: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.content });
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
85
96
|
}
|
|
86
97
|
// Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
|
|
87
|
-
|
|
88
|
-
this.
|
|
98
|
+
handleBannerReady() {
|
|
99
|
+
this.bannerMatrixReady = true;
|
|
89
100
|
}
|
|
90
101
|
watchEndpoint(newValue, oldValue) {
|
|
91
102
|
if (newValue && newValue != oldValue && this.cmsEndpoint) {
|
|
@@ -135,15 +146,15 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
|
135
146
|
// end custom styling area
|
|
136
147
|
}
|
|
137
148
|
render() {
|
|
149
|
+
var _a, _b, _c, _d;
|
|
138
150
|
if (this.hasErrors) {
|
|
139
151
|
return (h("div", { class: "BlogArticleDetails" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
140
152
|
}
|
|
141
153
|
if (!this.isLoading) {
|
|
142
154
|
return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "GridContainer" }, this.showPublishingDate &&
|
|
143
|
-
h("div", { class: "BlogDate" }, this.blogData.publishingDate), this.showImage &&
|
|
144
|
-
h("div", { class: "BlogBanner" }, h("img", { src: this.blogData.image.src, alt: this.blogData.title })), this.showTitle &&
|
|
145
|
-
h("div", { class: "BlogTitle" }, this.blogData.title), this.showContent &&
|
|
146
|
-
h("div", { class: "BlogContent", innerHTML: this.blogData.content }))));
|
|
155
|
+
h("div", { class: "BlogDate" }, (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate), this.showImage &&
|
|
156
|
+
h("div", { class: "BlogBanner" }, h("img", { src: this.blogData.image.src, alt: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.title })), this.showTitle &&
|
|
157
|
+
h("div", { class: "BlogTitle" }, (_c = this.blogData) === null || _c === void 0 ? void 0 : _c.title), this.showContent && this.renderContentConditionally((_d = this.blogData) === null || _d === void 0 ? void 0 : _d.content))));
|
|
147
158
|
}
|
|
148
159
|
}
|
|
149
160
|
static get watchers() { return {
|
|
@@ -166,8 +177,8 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
|
166
177
|
"hasErrors": [32],
|
|
167
178
|
"limitStylingAppends": [32],
|
|
168
179
|
"isLoading": [32],
|
|
169
|
-
"
|
|
170
|
-
}, [[8, "WebComponentsReady", "
|
|
180
|
+
"bannerMatrixReady": [32]
|
|
181
|
+
}, [[8, "WebComponentsReady", "handleBannerReady"]]]);
|
|
171
182
|
function defineCustomElement$1() {
|
|
172
183
|
if (typeof customElements === "undefined") {
|
|
173
184
|
return;
|
|
@@ -61,7 +61,7 @@ const BlogArticleDetails = class {
|
|
|
61
61
|
this.hasErrors = false;
|
|
62
62
|
this.limitStylingAppends = false;
|
|
63
63
|
this.isLoading = true;
|
|
64
|
-
this.
|
|
64
|
+
this.bannerMatrixReady = false;
|
|
65
65
|
this.setClientStyling = () => {
|
|
66
66
|
let sheet = document.createElement('style');
|
|
67
67
|
sheet.innerHTML = this.clientStyling;
|
|
@@ -80,10 +80,21 @@ const BlogArticleDetails = class {
|
|
|
80
80
|
console.log('error ', err);
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
|
+
this.renderContentConditionally = (content) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const hasBanner = (content === null || content === void 0 ? void 0 : content.indexOf('<bannermatrix-banner')) !== -1;
|
|
86
|
+
if (!hasBanner) {
|
|
87
|
+
return h("div", { class: "BlogContent", innerHTML: (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.content });
|
|
88
|
+
}
|
|
89
|
+
if (this.bannerMatrixReady) {
|
|
90
|
+
return h("div", { class: "BlogContent", innerHTML: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.content });
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
};
|
|
83
94
|
}
|
|
84
95
|
// Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
|
|
85
|
-
|
|
86
|
-
this.
|
|
96
|
+
handleBannerReady() {
|
|
97
|
+
this.bannerMatrixReady = true;
|
|
87
98
|
}
|
|
88
99
|
watchEndpoint(newValue, oldValue) {
|
|
89
100
|
if (newValue && newValue != oldValue && this.cmsEndpoint) {
|
|
@@ -133,15 +144,15 @@ const BlogArticleDetails = class {
|
|
|
133
144
|
// end custom styling area
|
|
134
145
|
}
|
|
135
146
|
render() {
|
|
147
|
+
var _a, _b, _c, _d;
|
|
136
148
|
if (this.hasErrors) {
|
|
137
149
|
return (h("div", { class: "BlogArticleDetails" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
138
150
|
}
|
|
139
151
|
if (!this.isLoading) {
|
|
140
152
|
return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "GridContainer" }, this.showPublishingDate &&
|
|
141
|
-
h("div", { class: "BlogDate" }, this.blogData.publishingDate), this.showImage &&
|
|
142
|
-
h("div", { class: "BlogBanner" }, h("img", { src: this.blogData.image.src, alt: this.blogData.title })), this.showTitle &&
|
|
143
|
-
h("div", { class: "BlogTitle" }, this.blogData.title), this.showContent &&
|
|
144
|
-
h("div", { class: "BlogContent", innerHTML: this.blogData.content }))));
|
|
153
|
+
h("div", { class: "BlogDate" }, (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate), this.showImage &&
|
|
154
|
+
h("div", { class: "BlogBanner" }, h("img", { src: this.blogData.image.src, alt: (_b = this.blogData) === null || _b === void 0 ? void 0 : _b.title })), this.showTitle &&
|
|
155
|
+
h("div", { class: "BlogTitle" }, (_c = this.blogData) === null || _c === void 0 ? void 0 : _c.title), this.showContent && this.renderContentConditionally((_d = this.blogData) === null || _d === void 0 ? void 0 : _d.content))));
|
|
145
156
|
}
|
|
146
157
|
}
|
|
147
158
|
static get watchers() { return {
|
|
@@ -13,5 +13,5 @@ const patchBrowser = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"
|
|
16
|
+
return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32]},[[8,"WebComponentsReady","handleBannerReady"]]]]]], options);
|
|
17
17
|
});
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"
|
|
13
|
+
return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32]},[[8,"WebComponentsReady","handleBannerReady"]]]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -46,8 +46,8 @@ export declare class BlogArticleDetails {
|
|
|
46
46
|
private hasErrors;
|
|
47
47
|
private limitStylingAppends;
|
|
48
48
|
private isLoading;
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
bannerMatrixReady: boolean;
|
|
50
|
+
handleBannerReady(): void;
|
|
51
51
|
watchEndpoint(newValue: string, oldValue: string): void;
|
|
52
52
|
private stylingContainer;
|
|
53
53
|
private blogData;
|
|
@@ -56,5 +56,6 @@ export declare class BlogArticleDetails {
|
|
|
56
56
|
componentDidRender(): void;
|
|
57
57
|
setClientStyling: () => void;
|
|
58
58
|
setClientStylingURL: () => void;
|
|
59
|
+
renderContentConditionally: (content: string) => HTMLElement;
|
|
59
60
|
render(): void;
|
|
60
61
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as i}from"./p-b3ab7cf8.js";const n=["ro","en","fr","ar"],r={en:{error:"Error"},ro:{error:"Eroare"},fr:{error:"Error"},ar:{error:"خطأ"}},s=class{constructor(i){t(this,i),this.language="en",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.postMessageEvent="articleActionButton",this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.reRender=!1,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)}))}}reRenderForBannerMatrix(){this.reRender=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.getBlogArticleDetails()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getBlogArticleDetails()}getBlogArticleDetails(){if(!this.postId&&isNaN(this.postId))throw this.hasErrors=!0,new Error("The postId parameter is missing!");this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);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=>{this.blogData=t,this.blogData.publishingDate=new Date(this.blogData.publishingDate).toLocaleDateString(),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)}render(){return this.hasErrors?i("div",{class:"BlogArticleDetails"},i("div",{class:"Title"},(()=>{const t=this.language;return r[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.blogData.publishingDate),this.showImage&&i("div",{class:"BlogBanner"},i("img",{src:this.blogData.image.src,alt:this.blogData.title})),this.showTitle&&i("div",{class:"BlogTitle"},this.blogData.title),this.showContent&&i("div",{class:"BlogContent",innerHTML:this.blogData.content})))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};s.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}\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{s as blog_article_details}
|