@everymatrix/blog-articles-grid 1.13.4 → 1.13.5

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 s,b as t}from"./p-f20eb014.js";(()=>{const t=import.meta.url,e={};return""!==t&&(e.resourcesUrl=new URL(".",t).href),s(e)})().then((s=>t([["p-72a6c169",[[1,"blog-articles-grid",{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"],showButton:[4,"show-button"],usePostmessage:[4,"use-postmessage"],postMessageEvent:[1,"post-message-event"],hasErrors:[32],limitStylingAppends:[32],isLoading:[32]}]]]],s)));
1
+ import{p as e,b as t}from"./p-f0d2badc.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((e=>t([["p-5f1404bf",[[1,"blog-articles-grid",{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"],showButton:[4,"show-button"],usePostmessage:[4,"use-postmessage"],postMessageEvent:[1,"post-message-event"],blogsLimit:[514,"blogs-limit"],paginationActive:[516,"pagination-active"],arrowsActive:[516,"arrows-active"],secondaryArrowsActive:[516,"secondary-arrows-active"],numberedNavActive:[516,"numbered-nav-active"],paginationBlogList:[32],currentPage:[32],hasErrors:[32],limitStylingAppends:[32],isLoading:[32],bannerMatrixReady:[32]},[[8,"WebComponentsReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]]],[1,"helper-pagination",{firstPage:[1540,"first-page"],previousPage:[1540,"previous-page"],offset:[1538],limit:[1538],total:[1538],language:[1537],clientStyling:[1537,"client-styling"],clientStylingUrlContent:[1537,"client-styling-url-content"],arrowsActive:[1540,"arrows-active"],secondaryArrowsActive:[1540,"secondary-arrows-active"],numberedNavActive:[1540,"numbered-nav-active"],offsetInt:[32],lastPage:[32],limitInt:[32],totalInt:[32],pagesArray:[32],endInt:[32],limitStylingAppends:[32]}]]]],e)));
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as n}from"./p-f0d2badc.js";const s=["ro","en","fr","ar"],e={en:{error:"Error",readmore:"Read more"},ro:{error:"Eroare",readmore:"Read more"},fr:{error:"Error",readmore:"Read more"},ar:{error:"خطأ",readmore:"Read more"}},o=(t,i)=>{const n=i;return e[void 0!==n&&s.includes(n)?n:"en"][t]},r=class{constructor(s){t(this,s),this.articleActionButton=i(this,"articleActionButton",7),this.language="en",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.showButton=!0,this.postMessageEvent="articleActionButton",this.paginationBlogList={offset:0},this.currentPage=0,this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.blogsLists=[],this.defaultStyling="\n div#PaginationContainer {\n justify-content: right;\n }\n .LeftItems button .NavigationButton {\n display: none;\n }\n .LeftItems button:after, .RightItems button:after {\n padding: 7px 12px;\n font-size: 18px;\n font-weight: 700;\n line-height: 46px;\n }\n .LeftItems button:after {\n 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\");\n }\n .RightItems button:after {\n 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\");\n display: block;\n height: 38px;\n }\n div.LeftItems button, div.RightItems button {\n width: unset;\n height: 40px;\n background-color: #fff;\n color: #000;\n border: 1px solid #000;\n overflow: hidden;\n &:disabled {\n background-color: #989898;\n }\n }\n div.LeftItems button {\n min-width: 60px;\n border-radius: 20px 0 0 20px;\n border-right: 0;\n }\n div.RightItems button {\n display: flex;\n min-width: 100px;\n justify-content: space-evenly;\n align-items: center;\n border-radius: 0 20px 20px 0;\n text-transform: none;\n }\n .RightItems button .NavigationButton {\n padding: 12px 0 12px 12px;\n font-weight: 700;\n }",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!==t.indexOf("<bannermatrix-banner")?this.bannerMatrixReady?n("div",{class:"BlogContent",innerHTML:this.blogData.content}):null:n("div",{class:"BlogContent",innerHTML:this.blogData.content})}getArticleId(t){this.articleActionButton.emit({postId:t}),this.usePostmessage&&window.postMessage({type:this.postMessageEvent,postId:t})}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.getBlogArticleGrid()}hpPageChange(t){var i,n;this.paginationBlogList=t.detail,this.currentPage=Math.floor((null===(i=this.paginationBlogList)||void 0===i?void 0:i.offset)/(null===(n=this.paginationBlogList)||void 0===n?void 0:n.limit))}handleAction(t){this.getArticleId(t)}connectedCallback(){this.cmsEndpoint&&this.language&&this.getBlogArticleGrid()}componentDidLoad(){window.postMessage({type:"BlogArticlesGridLoaded"},window.location.href)}getBlogArticleGrid(){this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);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.map((t=>Object.assign(Object.assign({},t),{publishingDate:new Date(t.publishingDate).toLocaleDateString()})));const i=this.blogData.map((t=>Object.assign({},t)));for(;i.length>0;)this.blogsLists.push(i.splice(0,this.blogsLimit));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?n("div",{class:"BlogArticleDetails"},n("div",{class:"Title"},o("error",this.language))):this.isLoading?void 0:n("div",{ref:t=>this.stylingContainer=t},n("div",{class:"TicketsHistoryPaginationWrapper"},this.blogData.length>this.blogsLimit-1&&this.paginationActive&&n("helper-pagination",{"first-page":!1,"previous-page":!1,offset:this.paginationBlogList.offset,limit:this.blogsLimit,total:this.blogData.length,language:this.language,"client-styling":this.clientStyling||this.defaultStyling,"arrows-active":this.arrowsActive||!1,"secondary-arrows-active":this.secondaryArrowsActive||!1,"numbered-nav-active":this.numberedNavActive||!1})),n("div",{class:"GridContainerWrapper"},this.blogsLists[this.currentPage].map((t=>n("div",{class:"GridContainer"},this.showPublishingDate&&n("div",{class:"BlogDate"},t.publishingDate),this.showImage&&n("div",{class:"BlogBanner"},n("img",{src:t.image.src,alt:t.title})),this.showTitle&&n("div",{class:"BlogTitle"},t.title),this.showContent&&this.renderContentConditionally(t.content),this.showButton&&n("div",{class:"BlogLink"},n("button",{onClick:()=>this.handleAction(t.postID)},o("readmore",this.language))))))))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};r.style=":host {\n display: block;\n}\n\n.GridContainerWrapper {\n display: grid;\n}\n\n.GridContainer {\n margin: auto;\n width: 100%;\n height: 280px;\n border-radius: 15px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n gap: 30px;\n grid-template-rows: 1fr 4fr 1fr 1fr;\n grid-template-columns: 30px 1fr 1fr 30px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/3;\n grid-row: 1/5;\n}\n.GridContainer .BlogBanner img {\n border-radius: 5px 0 0 5px;\n width: 100%;\n height: 280px;\n}\n.GridContainer .BlogDate {\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFFFFF;\n background-color: #0D0D4D;\n grid-column: 2/2;\n grid-row: 4/4;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #FFF;\n margin-top: 20px;\n grid-column: 3/5;\n}\n.GridContainer .BlogContent {\n font-size: 14px;\n color: #FFF;\n width: 90%;\n max-height: 80px;\n overflow: hidden;\n text-overflow: ellipsis;\n grid-column: 3/5;\n}\n.GridContainer .BlogLink {\n grid-column: 3/5;\n color: #FFF;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #D0046C;\n cursor: pointer;\n}\n\n@container (max-width: 475px) {\n .GridContainerWrapper {\n display: grid;\n }\n\n .GridContainer {\n margin: auto;\n width: 100%;\n min-height: 400px;\n gap: 10%;\n padding-bottom: 30px;\n border-radius: 5px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n grid-template-rows: repeat(auto-fit, minmax(50px, 1fr));\n grid-template-rows: auto auto auto 50px;\n grid-template-columns: 15px auto auto 15px;\n gap: 10px;\n }\n .GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n margin: 0;\n }\n .GridContainer .BlogBanner img {\n width: 100%;\n height: 232px;\n border-radius: 5px 5px 0 0;\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: #FFFFFF;\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 .GridContainer .BlogLink {\n grid-column: 2/4;\n color: #FFF;\n cursor: pointer;\n }\n .GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n background: none;\n color: #D0046C;\n cursor: pointer;\n }\n}";const a=t=>!!(t.toLowerCase().match(/android/i)||t.toLowerCase().match(/blackberry|bb/i)||t.toLowerCase().match(/iphone|ipad|ipod/i)||t.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),h=["ro","en"],d={en:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},ro:{firstPage:"Prima",previousPage:"Anterior",nextPage:"Urmatoarea",lastPage:"Ultima"},fr:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},ar:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"}},l=(t,i)=>{const n=i;return d[void 0!==n&&h.includes(n)?n:"en"][t]},c=class{constructor(n){t(this,n),this.hpPageChange=i(this,"hpPageChange",7),this.firstPage=!1,this.previousPage=!1,this.offset=0,this.limit=1,this.total=1,this.language="en",this.clientStyling="",this.clientStylingUrlContent="",this.pagesArray=[],this.endInt=0,this.userAgent=window.navigator.userAgent,this.currentPage=1,this.limitStylingAppends=!1,this.navigateTo=t=>{switch(t){case"firstPage":this.offsetInt=0;break;case"lastPage":this.offsetInt=this.endInt*this.limitInt;break;case"previousPage":this.offsetInt-=this.limitInt;break;case"nextPage":this.offsetInt+=this.limitInt;break;case"fivePagesBack":this.offsetInt-=5*this.limitInt,this.offsetInt=this.offsetInt<=0?0:this.offsetInt;break;case"fivePagesForward":this.offsetInt+=5*this.limitInt,this.offsetInt=this.offsetInt/this.limitInt>=this.endInt?this.endInt*this.limitInt:this.offsetInt}this.previousPage=!!this.offsetInt,this.hpPageChange.emit({offset:this.offsetInt,limit:this.limitInt,total:this.totalInt})},this.paginationNavigation=(t,i)=>{this.previousPage=!0,isNaN(t)?0===i&&this.currentPage<=4?this.navigateTo("firstPage"):0===i&&this.currentPage>4?this.navigateTo("fivePagesBack"):4===i&&this.endInt-this.currentPage>=2&&this.navigateTo("fivePagesForward"):1===t?(this.offsetInt=t-1,this.previousPage=!1):this.offsetInt=(t-1)*this.limitInt,this.hpPageChange.emit({offset:this.offsetInt,limit:this.limitInt,total:this.totalInt})},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=document.createElement("style");setTimeout((()=>{t.innerHTML=this.clientStylingUrlContent,this.stylingContainer.prepend(t)}),1)}}componentWillRender(){this.offsetInt=this.offset,this.limitInt=this.limit,this.currentPage=this.offsetInt/this.limitInt+1,this.limitInt=this.limit,this.totalInt=this.total,this.endInt=Math.ceil(this.totalInt/this.limitInt)-1,this.lastPage=!(this.offsetInt>=this.endInt*this.limitInt),1==this.currentPage||2==this.currentPage?(this.pagesArray=Array.from({length:4},((t,i)=>i+1)),this.pagesArray.push("...")):this.currentPage>=3&&this.endInt-this.currentPage>=2?(this.pagesArray=Array.from({length:3},((t,i)=>this.currentPage+i-1)),this.pagesArray.push("..."),this.pagesArray.unshift("...")):this.endInt-this.currentPage<3&&(this.pagesArray=Array.from({length:4},((t,i)=>this.endInt-2+i)),this.pagesArray.unshift("..."))}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrlContent&&this.setClientStylingURL(),this.limitStylingAppends=!0)}render(){let t=n("ul",{class:"PaginationArea"},this.pagesArray.map(((t,i)=>n("li",{class:"PaginationItem"+(t===this.currentPage?" ActiveItem":" ")+" "+(a(this.userAgent)?"MobileButtons":"")},n("button",{disabled:t===this.currentPage,onClick:this.paginationNavigation.bind(this,t,i)},n("span",null,t)))))),i=n("button",{disabled:!this.previousPage,onClick:this.navigateTo.bind(this,"firstPage")},n("span",{class:"NavigationButton"},l("firstPage",this.language)),n("span",{class:"NavigationIcon"})),s=n("div",{class:"LeftItems"},this.secondaryArrowsActive&&i,n("button",{disabled:!this.previousPage,onClick:this.navigateTo.bind(this,"previousPage")},n("span",{class:"NavigationButton"},l("previousPage",this.language)),n("span",{class:"NavigationIcon"})));a(this.userAgent)&&(s=n("div",{class:"LeftItems"},n("button",{disabled:!this.previousPage,onClick:this.navigateTo.bind(this,"previousPage")},n("span",{class:"NavigationButton"},l("previousPage",this.language)),n("span",{class:"NavigationIcon"}))));let e=n("button",{disabled:!this.lastPage,onClick:this.navigateTo.bind(this,"lastPage")},n("span",{class:"NavigationButton"},l("lastPage",this.language)),n("span",{class:"NavigationIcon"})),o=n("div",{class:"RightItems"},n("button",{disabled:!this.lastPage,onClick:this.navigateTo.bind(this,"nextPage")},n("span",{class:"NavigationButton"},l("nextPage",this.language)),n("span",{class:"NavigationIcon"})),this.secondaryArrowsActive&&e);return a(this.userAgent)&&(o=n("div",{class:"RightItems"},n("button",{disabled:!this.lastPage,onClick:this.navigateTo.bind(this,"nextPage")},n("span",{class:"NavigationButton"},l("nextPage",this.language)),n("span",{class:"NavigationIcon"})))),n("div",{id:"PaginationContainer",ref:t=>this.stylingContainer=t},this.arrowsActive&&s,this.numberedNavActive&&t,this.arrowsActive&&o)}};c.style='@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");:host{display:block;font-family:"Roboto", sans-serif}#PaginationContainer{width:100%;margin:20px 0;display:inline-flex;justify-content:space-between;align-items:center}.LeftItems button:not(:first-child),.RightItems button:not(:last-child){margin:0 10px}.LeftItems button,.RightItems button{padding:0;background-color:#009993;border-color:#009993}.PaginationArea{display:inline-flex;gap:10px;list-style:none}.PaginationArea li{margin:0;padding:0}.PaginationArea li button{width:24px;height:24px;display:flex;border:0;padding:0;justify-content:center;align-items:center;background-color:transparent;color:#000;cursor:pointer;pointer-events:all}.PaginationItem.ActiveItem button{background:#009993;border-color:#009993;color:#fff}.PaginationItem.ActiveItem button:disabled{pointer-events:none;cursor:not-allowed}.PaginationItem button:hover,.PaginationItem button:active{background:#009993;border-color:#009993;color:#fff;opacity:0.8}button{width:100px;height:32px;border:1px solid #524e52;border-radius:5px;background:#524e52;color:#fff;font-size:14px;font:inherit;cursor:pointer;transition:all 0.1s linear;text-transform:uppercase;text-align:center;letter-spacing:0}button:hover,button:active{background:#004D4A;border-color:#004D4A}button:disabled{background-color:#ccc;border-color:#ccc;color:#fff;cursor:not-allowed}@media screen and (max-width: 720px){button{width:90px;font-size:14px}}@media screen and (max-width: 480px){button{width:70px;font-size:14px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:12px}.paginationArea{padding:5px;gap:5px}}@media (hover: none){.paginationItem button:hover{background:inherit;border-color:inherit;color:inherit;opacity:1}.paginationItem.activeItem button:hover{background:#009993;border-color:#009993;color:#fff}}';export{r as blog_articles_grid,c as helper_pagination}
@@ -0,0 +1 @@
1
+ let e,t,n=!1;const l="undefined"!=typeof window?window:{},s=l.document||{head:{}},o={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},c=e=>Promise.resolve(e),r=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),i=(e,t,n)=>{n&&n.map((([n,l,s])=>{const c=u(e,n),r=a(t,s),i=f(n);o.ael(c,l,r,i),(t.o=t.o||[]).push((()=>o.rel(c,l,r,i)))}))},a=(e,t)=>n=>{try{256&e.t?e.i[t](n):(e.u=e.u||[]).push([t,n])}catch(e){K(e)}},u=(e,t)=>8&t?l:e,f=e=>0!=(2&e),d=new WeakMap,h=e=>"sc-"+e.h,$={},m=e=>"object"==(e=typeof e)||"function"===e,p=(e,t,...n)=>{let l=null,s=!1,o=!1,c=[];const r=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?r(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof e&&!m(l))&&(l+=""),s&&o?c[c.length-1].$+=l:c.push(s?y(null,l):l),o=s)};if(r(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}const i=y(e,null);return i.m=t,c.length>0&&(i.p=c),i},y=(e,t)=>({t:0,S:e,$:t,g:null,p:null,m:null}),b={},w=(e,t,n,s,c,r)=>{if(n!==s){let i=J(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,l=g(n),o=g(s);t.remove(...l.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!l.includes(e))))}else if("ref"===t)s&&s(e);else if(i||"o"!==t[0]||"n"!==t[1]){const l=m(s);if((i||l&&null!==s)&&!c)try{if(e.tagName.includes("-"))e[t]=s;else{let l=null==s?"":s;"list"===t?i=!1:null!=n&&e[t]==l||(e[t]=l)}}catch(e){}null==s||!1===s?!1===s&&""!==e.getAttribute(t)||e.removeAttribute(t):(!i||4&r||c)&&!l&&e.setAttribute(t,s=!0===s?"":s)}else t="-"===t[2]?t.slice(3):J(l,a)?a.slice(2):a[2]+t.slice(3),n&&o.rel(e,t,n,!1),s&&o.ael(e,t,s,!1)}},S=/\s/,g=e=>e?e.split(S):[],j=(e,t,n,l)=>{const s=11===t.g.nodeType&&t.g.host?t.g.host:t.g,o=e&&e.m||$,c=t.m||$;for(l in o)l in c||w(s,l,o[l],void 0,n,t.t);for(l in c)w(s,l,o[l],c[l],n,t.t)},v=(t,n,l)=>{let o,c,r=n.p[l],i=0;if(null!==r.$)o=r.g=s.createTextNode(r.$);else if(o=r.g=s.createElement(r.S),j(null,r,!1),null!=e&&o["s-si"]!==e&&o.classList.add(o["s-si"]=e),r.p)for(i=0;i<r.p.length;++i)c=v(t,r,i),c&&o.appendChild(c);return o},M=(e,n,l,s,o,c)=>{let r,i=e;for(i.shadowRoot&&i.tagName===t&&(i=i.shadowRoot);o<=c;++o)s[o]&&(r=v(null,l,o),r&&(s[o].g=r,i.insertBefore(r,n)))},k=(e,t,n,l,s)=>{for(;t<=n;++t)(l=e[t])&&(s=l.g,P(l),s.remove())},C=(e,t)=>e.S===t.S,O=(e,t)=>{const n=t.g=e.g,l=e.p,s=t.p,o=t.$;null===o?(j(e,t,!1),null!==l&&null!==s?((e,t,n,l)=>{let s,o=0,c=0,r=t.length-1,i=t[0],a=t[r],u=l.length-1,f=l[0],d=l[u];for(;o<=r&&c<=u;)null==i?i=t[++o]:null==a?a=t[--r]:null==f?f=l[++c]:null==d?d=l[--u]:C(i,f)?(O(i,f),i=t[++o],f=l[++c]):C(a,d)?(O(a,d),a=t[--r],d=l[--u]):C(i,d)?(O(i,d),e.insertBefore(i.g,a.g.nextSibling),i=t[++o],d=l[--u]):C(a,f)?(O(a,f),e.insertBefore(a.g,i.g),a=t[--r],f=l[++c]):(s=v(t&&t[c],n,c),f=l[++c],s&&i.g.parentNode.insertBefore(s,i.g));o>r?M(e,null==l[u+1]?null:l[u+1].g,n,l,c,u):c>u&&k(t,o,r)})(n,l,t,s):null!==s?(null!==e.$&&(n.textContent=""),M(n,null,t,s,0,s.length-1)):null!==l&&k(l,0,l.length-1)):e.$!==o&&(n.data=o)},P=e=>{e.m&&e.m.ref&&e.m.ref(null),e.p&&e.p.map(P)},R=(e,t,n)=>{const l=(e=>B(e).j)(e);return{emit:e=>x(l,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},x=(e,t,n)=>{const l=o.ce(t,n);return e.dispatchEvent(l),l},E=(e,t)=>{t&&!e.v&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.v=t)))},L=(e,t)=>{if(e.t|=16,!(4&e.t))return E(e,e.M),oe((()=>N(e,t)));e.t|=512},N=(e,t)=>{const n=e.i;let l;return t&&(e.t|=256,e.u&&(e.u.map((([e,t])=>F(n,e,t))),e.u=null)),l=U(l,(()=>F(n,"componentWillRender"))),U(l,(()=>T(e,n,t)))},T=async(e,t,n)=>{const l=e.j,o=l["s-rc"];n&&(e=>{const t=e.k,n=e.j,l=t.t,o=((e,t)=>{let n=h(t),l=Y.get(n);if(e=11===e.nodeType?e:s,l)if("string"==typeof l){let t,o=d.get(e=e.head||e);o||d.set(e,o=new Set),o.has(n)||(t=s.createElement("style"),t.innerHTML=l,e.insertBefore(t,e.querySelector("link")),o&&o.add(n))}else e.adoptedStyleSheets.includes(l)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,l]);return n})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(e);W(e,t),o&&(o.map((e=>e())),l["s-rc"]=void 0);{const t=l["s-p"],n=()=>A(e);0===t.length?n():(Promise.all(t).then(n),e.t|=4,t.length=0)}},W=(n,l)=>{try{l=l.render(),n.t&=-17,n.t|=2,((n,l)=>{const s=n.j,o=n.k,c=n.C||y(null,null),r=(e=>e&&e.S===b)(l)?l:p(null,null,l);t=s.tagName,o.O&&(r.m=r.m||{},o.O.map((([e,t])=>r.m[t]=s[e]))),r.S=null,r.t|=4,n.C=r,r.g=c.g=s.shadowRoot||s,e=s["s-sc"],O(c,r)})(n,l)}catch(e){K(e,n.j)}return null},A=e=>{const t=e.j,n=e.i,l=e.M;F(n,"componentDidRender"),64&e.t||(e.t|=64,q(t),F(n,"componentDidLoad"),e.P(t),l||D()),e.v&&(e.v(),e.v=void 0),512&e.t&&se((()=>L(e,!1))),e.t&=-517},D=()=>{q(s.documentElement),se((()=>x(l,"appload",{detail:{namespace:"blog-articles-grid"}})))},F=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){K(e)}},U=(e,t)=>e&&e.then?e.then(t):t(),q=e=>e.classList.add("hydrated"),H=(e,t,n)=>{if(t.R){e.watchers&&(t.L=e.watchers);const l=Object.entries(t.R),s=e.prototype;if(l.map((([e,[l]])=>{(31&l||2&n&&32&l)&&Object.defineProperty(s,e,{get(){return((e,t)=>B(this).N.get(t))(0,e)},set(n){((e,t,n,l)=>{const s=B(e),o=s.j,c=s.N.get(t),r=s.t,i=s.i;if(n=((e,t)=>null==e||m(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(n,l.R[t][0]),(!(8&r)||void 0===c)&&n!==c&&(!Number.isNaN(c)||!Number.isNaN(n))&&(s.N.set(t,n),i)){if(l.L&&128&r){const e=l.L[t];e&&e.map((e=>{try{i[e](n,c,t)}catch(e){K(e,o)}}))}2==(18&r)&&L(s,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0})})),1&n){const n=new Map;s.attributeChangedCallback=function(e,t,l){o.jmp((()=>{const t=n.get(e);if(this.hasOwnProperty(t))l=this[t],delete this[t];else if(s.hasOwnProperty(t)&&"number"==typeof this[t]&&this[t]==l)return;this[t]=(null!==l||"boolean"!=typeof this[t])&&l}))},e.observedAttributes=l.filter((([e,t])=>15&t[0])).map((([e,l])=>{const s=l[1]||e;return n.set(s,e),512&l[0]&&t.O.push([e,s]),s}))}}return e},V=e=>{F(e,"connectedCallback")},_=(e,t={})=>{const n=[],c=t.exclude||[],a=l.customElements,u=s.head,f=u.querySelector("meta[charset]"),d=s.createElement("style"),$=[];let m,p=!0;Object.assign(o,t),o.l=new URL(t.resourcesUrl||"./",s.baseURI).href,e.map((e=>{e[1].map((t=>{const l={t:t[0],h:t[1],R:t[2],T:t[3]};l.R=t[2],l.T=t[3],l.O=[],l.L={};const s=l.h,u=class extends HTMLElement{constructor(e){super(e),I(e=this,l),1&l.t&&e.attachShadow({mode:"open"})}connectedCallback(){m&&(clearTimeout(m),m=null),p?$.push(this):o.jmp((()=>(e=>{if(0==(1&o.t)){const t=B(e),n=t.k,l=()=>{};if(1&t.t)i(e,t,n.T),V(t.i);else{t.t|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){E(t,t.M=n);break}}n.R&&Object.entries(n.R).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,l,s)=>{if(0==(32&t.t)){{if(t.t|=32,(s=X(n)).then){const e=()=>{};s=await s,e()}s.isProxied||(n.L=s.watchers,H(s,n,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(e){K(e)}t.t&=-9,t.t|=128,e(),V(t.i)}if(s.style){let e=s.style;const t=h(n);if(!Y.has(t)){const l=()=>{};((e,t,n)=>{let l=Y.get(e);r&&n?(l=l||new CSSStyleSheet,l.replace(t)):l=t,Y.set(e,l)})(t,e,!!(1&n.t)),l()}}}const o=t.M,c=()=>L(t,!0);o&&o["s-rc"]?o["s-rc"].push(c):c()})(0,t,n)}l()}})(this)))}disconnectedCallback(){o.jmp((()=>(()=>{if(0==(1&o.t)){const e=B(this);e.o&&(e.o.map((e=>e())),e.o=void 0)}})()))}componentOnReady(){return B(this).W}};l.A=e[0],c.includes(s)||a.get(s)||(n.push(s),a.define(s,H(u,l,1)))}))})),d.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",d.setAttribute("data-styles",""),u.insertBefore(d,f?f.nextSibling:u.firstChild),p=!1,$.length?$.map((e=>e.connectedCallback())):o.jmp((()=>m=setTimeout(D,30)))},z=new WeakMap,B=e=>z.get(e),G=(e,t)=>z.set(t.i=e,t),I=(e,t)=>{const n={t:0,j:e,k:t,N:new Map};return n.W=new Promise((e=>n.P=e)),e["s-p"]=[],e["s-rc"]=[],i(e,n,t.T),z.set(e,n)},J=(e,t)=>t in e,K=(e,t)=>(0,console.error)(e,t),Q=new Map,X=e=>{const t=e.h.replace(/-/g,"_"),n=e.A,l=Q.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(Q.set(n,e),e[t])),K)},Y=new Map,Z=[],ee=[],te=(e,t)=>l=>{e.push(l),n||(n=!0,t&&4&o.t?se(le):o.raf(le))},ne=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){K(e)}e.length=0},le=()=>{ne(Z),ne(ee),(n=Z.length>0)&&o.raf(le)},se=e=>c().then(e),oe=te(ee,!0);export{_ as b,R as c,p as h,c as p,G as r}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-354d58ac.js');
3
+ const index = require('./index-a19b0ad2.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["blog-articles-grid.cjs",[[1,"blog-articles-grid",{"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"],"showButton":[4,"show-button"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32]}]]]], options);
18
+ return index.bootstrapLazy([["blog-articles-grid_2.cjs",[[1,"blog-articles-grid",{"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"],"showButton":[4,"show-button"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"blogsLimit":[514,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32]},[[8,"WebComponentsReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]]],[1,"helper-pagination",{"firstPage":[1540,"first-page"],"previousPage":[1540,"previous-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"clientStyling":[1537,"client-styling"],"clientStylingUrlContent":[1537,"client-styling-url-content"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32],"limitStylingAppends":[32]}]]]], options);
19
19
  });
@@ -0,0 +1,483 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-a19b0ad2.js');
6
+
7
+ const DEFAULT_LANGUAGE$1 = 'en';
8
+ const SUPPORTED_LANGUAGES$1 = ['ro', 'en', 'fr', 'ar'];
9
+ const TRANSLATIONS$1 = {
10
+ en: {
11
+ error: 'Error',
12
+ readmore: 'Read more',
13
+ },
14
+ ro: {
15
+ error: 'Eroare',
16
+ readmore: 'Read more',
17
+ },
18
+ fr: {
19
+ error: 'Error',
20
+ readmore: 'Read more',
21
+ },
22
+ ar: {
23
+ error: 'خطأ',
24
+ readmore: 'Read more',
25
+ }
26
+ };
27
+ const translate$1 = (key, customLang) => {
28
+ const lang = customLang;
29
+ return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
30
+ };
31
+
32
+ const blogArticlesGridCss = ":host {\n display: block;\n}\n\n.GridContainerWrapper {\n display: grid;\n}\n\n.GridContainer {\n margin: auto;\n width: 100%;\n height: 280px;\n border-radius: 15px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n gap: 30px;\n grid-template-rows: 1fr 4fr 1fr 1fr;\n grid-template-columns: 30px 1fr 1fr 30px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/3;\n grid-row: 1/5;\n}\n.GridContainer .BlogBanner img {\n border-radius: 5px 0 0 5px;\n width: 100%;\n height: 280px;\n}\n.GridContainer .BlogDate {\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFFFFF;\n background-color: #0D0D4D;\n grid-column: 2/2;\n grid-row: 4/4;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #FFF;\n margin-top: 20px;\n grid-column: 3/5;\n}\n.GridContainer .BlogContent {\n font-size: 14px;\n color: #FFF;\n width: 90%;\n max-height: 80px;\n overflow: hidden;\n text-overflow: ellipsis;\n grid-column: 3/5;\n}\n.GridContainer .BlogLink {\n grid-column: 3/5;\n color: #FFF;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #D0046C;\n cursor: pointer;\n}\n\n@container (max-width: 475px) {\n .GridContainerWrapper {\n display: grid;\n }\n\n .GridContainer {\n margin: auto;\n width: 100%;\n min-height: 400px;\n gap: 10%;\n padding-bottom: 30px;\n border-radius: 5px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n grid-template-rows: repeat(auto-fit, minmax(50px, 1fr));\n grid-template-rows: auto auto auto 50px;\n grid-template-columns: 15px auto auto 15px;\n gap: 10px;\n }\n .GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n margin: 0;\n }\n .GridContainer .BlogBanner img {\n width: 100%;\n height: 232px;\n border-radius: 5px 5px 0 0;\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: #FFFFFF;\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 .GridContainer .BlogLink {\n grid-column: 2/4;\n color: #FFF;\n cursor: pointer;\n }\n .GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n background: none;\n color: #D0046C;\n cursor: pointer;\n }\n}";
33
+
34
+ const BlogArticlesGrid = class {
35
+ constructor(hostRef) {
36
+ index.registerInstance(this, hostRef);
37
+ this.articleActionButton = index.createEvent(this, "articleActionButton", 7);
38
+ /**
39
+ * Language of the widget
40
+ */
41
+ this.language = 'en';
42
+ /**
43
+ * Client custom styling via string
44
+ */
45
+ this.clientStyling = '';
46
+ /**
47
+ * Client custom styling via url
48
+ */
49
+ this.clientStylingUrl = '';
50
+ /**
51
+ * Property used to display the publishing date
52
+ */
53
+ this.showPublishingDate = true;
54
+ /**
55
+ * Property used to display the image
56
+ */
57
+ this.showImage = true;
58
+ /**
59
+ * Property used to display the image
60
+ */
61
+ this.showTitle = true;
62
+ /**
63
+ * Property used to display the description
64
+ */
65
+ this.showContent = true;
66
+ /**
67
+ * Property used to display the button
68
+ */
69
+ this.showButton = true;
70
+ /**
71
+ * Event name to be sent when the button is clicked
72
+ */
73
+ this.postMessageEvent = 'articleActionButton';
74
+ this.paginationBlogList = {
75
+ offset: 0
76
+ };
77
+ this.currentPage = 0;
78
+ this.hasErrors = false;
79
+ this.limitStylingAppends = false;
80
+ this.isLoading = true;
81
+ this.bannerMatrixReady = false;
82
+ this.blogsLists = [];
83
+ this.defaultStyling = `
84
+ div#PaginationContainer {
85
+ justify-content: right;
86
+ }
87
+ .LeftItems button .NavigationButton {
88
+ display: none;
89
+ }
90
+ .LeftItems button:after, .RightItems button:after {
91
+ padding: 7px 12px;
92
+ font-size: 18px;
93
+ font-weight: 700;
94
+ line-height: 46px;
95
+ }
96
+ .LeftItems button:after {
97
+ 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");
98
+ }
99
+ .RightItems button:after {
100
+ 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");
101
+ display: block;
102
+ height: 38px;
103
+ }
104
+ div.LeftItems button, div.RightItems button {
105
+ width: unset;
106
+ height: 40px;
107
+ background-color: #fff;
108
+ color: #000;
109
+ border: 1px solid #000;
110
+ overflow: hidden;
111
+ &:disabled {
112
+ background-color: #989898;
113
+ }
114
+ }
115
+ div.LeftItems button {
116
+ min-width: 60px;
117
+ border-radius: 20px 0 0 20px;
118
+ border-right: 0;
119
+ }
120
+ div.RightItems button {
121
+ display: flex;
122
+ min-width: 100px;
123
+ justify-content: space-evenly;
124
+ align-items: center;
125
+ border-radius: 0 20px 20px 0;
126
+ text-transform: none;
127
+ }
128
+ .RightItems button .NavigationButton {
129
+ padding: 12px 0 12px 12px;
130
+ font-weight: 700;
131
+ }`;
132
+ this.setClientStyling = () => {
133
+ let sheet = document.createElement('style');
134
+ sheet.innerHTML = this.clientStyling;
135
+ this.stylingContainer.prepend(sheet);
136
+ };
137
+ this.setClientStylingURL = () => {
138
+ let url = new URL(this.clientStylingUrl);
139
+ let cssFile = document.createElement('style');
140
+ fetch(url.href)
141
+ .then((res) => res.text())
142
+ .then((data) => {
143
+ cssFile.innerHTML = data;
144
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
145
+ })
146
+ .catch((err) => {
147
+ console.log('error ', err);
148
+ });
149
+ };
150
+ this.renderContentConditionally = (content) => {
151
+ const hasBanner = content.indexOf('<bannermatrix-banner') !== -1;
152
+ if (!hasBanner) {
153
+ return index.h("div", { class: "BlogContent", innerHTML: this.blogData.content });
154
+ }
155
+ if (this.bannerMatrixReady) {
156
+ return index.h("div", { class: "BlogContent", innerHTML: this.blogData.content });
157
+ }
158
+ return null;
159
+ };
160
+ }
161
+ getArticleId(postId) {
162
+ this.articleActionButton.emit({ postId });
163
+ if (this.usePostmessage) {
164
+ window.postMessage({ type: this.postMessageEvent, postId });
165
+ }
166
+ }
167
+ // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
168
+ handleBannerReady() {
169
+ this.bannerMatrixReady = true;
170
+ }
171
+ watchEndpoint(newValue, oldValue) {
172
+ if (newValue && newValue != oldValue && this.cmsEndpoint) {
173
+ this.getBlogArticleGrid();
174
+ }
175
+ }
176
+ hpPageChange(event) {
177
+ var _a, _b;
178
+ this.paginationBlogList = event.detail;
179
+ this.currentPage = Math.floor(((_a = this.paginationBlogList) === null || _a === void 0 ? void 0 : _a.offset) / ((_b = this.paginationBlogList) === null || _b === void 0 ? void 0 : _b.limit));
180
+ }
181
+ handleAction(postId) {
182
+ this.getArticleId(postId);
183
+ }
184
+ connectedCallback() {
185
+ if (this.cmsEndpoint && this.language) {
186
+ this.getBlogArticleGrid();
187
+ }
188
+ }
189
+ componentDidLoad() {
190
+ window.postMessage({ type: 'BlogArticlesGridLoaded' }, window.location.href);
191
+ }
192
+ getBlogArticleGrid() {
193
+ this.isLoading = true;
194
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
195
+ fetch(url.href)
196
+ .then((res) => {
197
+ if (res.status >= 300) {
198
+ this.hasErrors = true;
199
+ throw new Error('There was an error while fetching the data');
200
+ }
201
+ return res.json();
202
+ })
203
+ .then((blogContent) => {
204
+ this.blogData = blogContent.map((item) => {
205
+ return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
206
+ });
207
+ // start api call mock structure for pagination
208
+ const newArray = this.blogData.map(a => (Object.assign({}, a)));
209
+ while (newArray.length > 0) {
210
+ this.blogsLists.push(newArray.splice(0, this.blogsLimit));
211
+ }
212
+ // end api call mock structure for pagination
213
+ this.isLoading = false;
214
+ })
215
+ .catch((err) => {
216
+ this.hasErrors = true;
217
+ console.log('Error', err);
218
+ })
219
+ .finally(() => this.isLoading = false);
220
+ }
221
+ componentDidRender() {
222
+ // start custom styling area
223
+ if (!this.limitStylingAppends && this.stylingContainer) {
224
+ if (this.clientStyling)
225
+ this.setClientStyling();
226
+ if (this.clientStylingUrl)
227
+ this.setClientStylingURL();
228
+ this.limitStylingAppends = true;
229
+ }
230
+ // end custom styling area
231
+ }
232
+ render() {
233
+ if (this.hasErrors) {
234
+ return (index.h("div", { class: "BlogArticleDetails" }, index.h("div", { class: "Title" }, translate$1('error', this.language))));
235
+ }
236
+ if (!this.isLoading) {
237
+ return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "TicketsHistoryPaginationWrapper" }, (this.blogData.length > this.blogsLimit - 1) && this.paginationActive && index.h("helper-pagination", { "first-page": false, "previous-page": false, offset: this.paginationBlogList.offset, limit: this.blogsLimit, total: this.blogData.length, language: this.language, "client-styling": this.clientStyling || this.defaultStyling, "arrows-active": this.arrowsActive || false, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), index.h("div", { class: "GridContainerWrapper" }, this.blogsLists[this.currentPage].map((data) => index.h("div", { class: "GridContainer" }, this.showPublishingDate &&
238
+ index.h("div", { class: "BlogDate" }, data.publishingDate), this.showImage &&
239
+ index.h("div", { class: "BlogBanner" }, index.h("img", { src: data.image.src, alt: data.title })), this.showTitle &&
240
+ index.h("div", { class: "BlogTitle" }, data.title), this.showContent &&
241
+ this.renderContentConditionally(data.content), this.showButton &&
242
+ index.h("div", { class: "BlogLink" }, index.h("button", { onClick: () => this.handleAction(data.postID) }, translate$1('readmore', this.language))))))));
243
+ }
244
+ }
245
+ static get watchers() { return {
246
+ "cmsEndpoint": ["watchEndpoint"],
247
+ "language": ["watchEndpoint"]
248
+ }; }
249
+ };
250
+ BlogArticlesGrid.style = blogArticlesGridCss;
251
+
252
+ /**
253
+ * @name isMobile
254
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
255
+ * @param {String} userAgent window.navigator.userAgent
256
+ * @returns {Boolean} true or false
257
+ */
258
+ const isMobile = (userAgent) => {
259
+ return !!(userAgent.toLowerCase().match(/android/i) ||
260
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
261
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
262
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
263
+ };
264
+
265
+ const DEFAULT_LANGUAGE = 'en';
266
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
267
+ const TRANSLATIONS = {
268
+ en: {
269
+ firstPage: 'First',
270
+ previousPage: 'Previous',
271
+ nextPage: 'Next',
272
+ lastPage: 'Last'
273
+ },
274
+ ro: {
275
+ firstPage: 'Prima',
276
+ previousPage: 'Anterior',
277
+ nextPage: 'Urmatoarea',
278
+ lastPage: 'Ultima'
279
+ },
280
+ fr: {
281
+ firstPage: 'First',
282
+ previousPage: 'Previous',
283
+ nextPage: 'Next',
284
+ lastPage: 'Last'
285
+ },
286
+ ar: {
287
+ firstPage: 'First',
288
+ previousPage: 'Previous',
289
+ nextPage: 'Next',
290
+ lastPage: 'Last'
291
+ }
292
+ };
293
+ const translate = (key, customLang) => {
294
+ const lang = customLang;
295
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
296
+ };
297
+
298
+ const helperPaginationCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}#PaginationContainer{width:100%;margin:20px 0;display:inline-flex;justify-content:space-between;align-items:center}.LeftItems button:not(:first-child),.RightItems button:not(:last-child){margin:0 10px}.LeftItems button,.RightItems button{padding:0;background-color:#009993;border-color:#009993}.PaginationArea{display:inline-flex;gap:10px;list-style:none}.PaginationArea li{margin:0;padding:0}.PaginationArea li button{width:24px;height:24px;display:flex;border:0;padding:0;justify-content:center;align-items:center;background-color:transparent;color:#000;cursor:pointer;pointer-events:all}.PaginationItem.ActiveItem button{background:#009993;border-color:#009993;color:#fff}.PaginationItem.ActiveItem button:disabled{pointer-events:none;cursor:not-allowed}.PaginationItem button:hover,.PaginationItem button:active{background:#009993;border-color:#009993;color:#fff;opacity:0.8}button{width:100px;height:32px;border:1px solid #524e52;border-radius:5px;background:#524e52;color:#fff;font-size:14px;font:inherit;cursor:pointer;transition:all 0.1s linear;text-transform:uppercase;text-align:center;letter-spacing:0}button:hover,button:active{background:#004D4A;border-color:#004D4A}button:disabled{background-color:#ccc;border-color:#ccc;color:#fff;cursor:not-allowed}@media screen and (max-width: 720px){button{width:90px;font-size:14px}}@media screen and (max-width: 480px){button{width:70px;font-size:14px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:12px}.paginationArea{padding:5px;gap:5px}}@media (hover: none){.paginationItem button:hover{background:inherit;border-color:inherit;color:inherit;opacity:1}.paginationItem.activeItem button:hover{background:#009993;border-color:#009993;color:#fff}}";
299
+
300
+ const HelperPagination = class {
301
+ constructor(hostRef) {
302
+ index.registerInstance(this, hostRef);
303
+ this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
304
+ /**
305
+ * First page boolean value - determines if the page is disabled or active
306
+ */
307
+ this.firstPage = false;
308
+ /**
309
+ * Previous page boolean value - determines if the page is disabled or active
310
+ */
311
+ this.previousPage = false;
312
+ /**
313
+ * The received offset
314
+ */
315
+ this.offset = 0;
316
+ /**
317
+ * The received limit for the number of pages
318
+ */
319
+ this.limit = 1;
320
+ /**
321
+ * The received total number of pages
322
+ */
323
+ this.total = 1;
324
+ /**
325
+ * Language
326
+ */
327
+ this.language = 'en';
328
+ /**
329
+ * Client custom styling via string
330
+ */
331
+ this.clientStyling = '';
332
+ /**
333
+ * Client custom styling via url content
334
+ */
335
+ this.clientStylingUrlContent = '';
336
+ /**
337
+ * In component working variable for the array of pages
338
+ */
339
+ this.pagesArray = [];
340
+ /**
341
+ * In component working variable for last page
342
+ */
343
+ this.endInt = 0;
344
+ this.userAgent = window.navigator.userAgent;
345
+ this.currentPage = 1;
346
+ this.limitStylingAppends = false;
347
+ /**
348
+ * Navigation logic
349
+ */
350
+ this.navigateTo = (navigationPage) => {
351
+ switch (navigationPage) {
352
+ case 'firstPage':
353
+ this.offsetInt = 0;
354
+ break;
355
+ case 'lastPage':
356
+ this.offsetInt = this.endInt * this.limitInt;
357
+ break;
358
+ case 'previousPage':
359
+ this.offsetInt -= this.limitInt;
360
+ break;
361
+ case 'nextPage':
362
+ this.offsetInt += this.limitInt;
363
+ break;
364
+ case 'fivePagesBack':
365
+ this.offsetInt -= this.limitInt * 5;
366
+ this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
367
+ break;
368
+ case 'fivePagesForward':
369
+ this.offsetInt += this.limitInt * 5;
370
+ this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
371
+ break;
372
+ }
373
+ this.previousPage = !this.offsetInt ? false : true;
374
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
375
+ };
376
+ /**
377
+ * Handle navigation from here
378
+ */
379
+ this.paginationNavigation = (pageNumber, index) => {
380
+ this.previousPage = true;
381
+ if (!isNaN(pageNumber)) {
382
+ if (pageNumber === 1) {
383
+ this.offsetInt = pageNumber - 1;
384
+ this.previousPage = false;
385
+ }
386
+ else {
387
+ this.offsetInt = (pageNumber - 1) * this.limitInt;
388
+ }
389
+ }
390
+ else {
391
+ if (index === 0 && this.currentPage <= 4) {
392
+ this.navigateTo('firstPage');
393
+ }
394
+ else if (index === 0 && this.currentPage > 4) {
395
+ this.navigateTo('fivePagesBack');
396
+ }
397
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
398
+ this.navigateTo('fivePagesForward');
399
+ }
400
+ }
401
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
402
+ };
403
+ this.setClientStyling = () => {
404
+ let sheet = document.createElement('style');
405
+ sheet.innerHTML = this.clientStyling;
406
+ this.stylingContainer.prepend(sheet);
407
+ };
408
+ this.setClientStylingURL = () => {
409
+ let cssFile = document.createElement('style');
410
+ setTimeout(() => {
411
+ cssFile.innerHTML = this.clientStylingUrlContent;
412
+ this.stylingContainer.prepend(cssFile);
413
+ }, 1);
414
+ };
415
+ }
416
+ componentWillRender() {
417
+ this.offsetInt = this.offset;
418
+ this.limitInt = this.limit;
419
+ this.currentPage = (this.offsetInt / this.limitInt) + 1;
420
+ this.limitInt = this.limit;
421
+ this.totalInt = this.total;
422
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
423
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
424
+ /**
425
+ * Construct numbered navigation area based on current page position
426
+ */
427
+ if (this.currentPage == 1 || this.currentPage == 2) {
428
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
429
+ this.pagesArray.push('...');
430
+ }
431
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
432
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
433
+ this.pagesArray.push('...');
434
+ this.pagesArray.unshift('...');
435
+ }
436
+ else if ((this.endInt - this.currentPage) < 3) {
437
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
438
+ this.pagesArray.unshift('...');
439
+ }
440
+ }
441
+ componentDidRender() {
442
+ // start custom styling area
443
+ if (!this.limitStylingAppends && this.stylingContainer) {
444
+ if (this.clientStyling)
445
+ this.setClientStyling();
446
+ if (this.clientStylingUrlContent)
447
+ this.setClientStylingURL();
448
+ this.limitStylingAppends = true;
449
+ }
450
+ // end custom styling area
451
+ }
452
+ render() {
453
+ /**
454
+ * Center navigation area
455
+ */
456
+ let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
457
+ return (index.h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, index.h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index$1) }, index.h("span", null, item))));
458
+ }));
459
+ /**
460
+ * Left navigation area
461
+ */
462
+ let buttonSecondaryLeftSide = index.h("button", { disabled: !this.previousPage, onClick: this.navigateTo.bind(this, 'firstPage') }, index.h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), index.h("span", { class: "NavigationIcon" }));
463
+ let buttonsLeftSide = index.h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, index.h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
464
+ if (isMobile(this.userAgent)) {
465
+ buttonsLeftSide =
466
+ index.h("div", { class: "LeftItems" }, index.h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
467
+ }
468
+ /**
469
+ * Right navigation area
470
+ */
471
+ let buttonSecondaryRightSide = index.h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'lastPage') }, index.h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), index.h("span", { class: "NavigationIcon" }));
472
+ let buttonsRightSide = index.h("div", { class: "RightItems" }, index.h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
473
+ if (isMobile(this.userAgent)) {
474
+ buttonsRightSide =
475
+ index.h("div", { class: "RightItems" }, index.h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })));
476
+ }
477
+ return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
478
+ }
479
+ };
480
+ HelperPagination.style = helperPaginationCss;
481
+
482
+ exports.blog_articles_grid = BlogArticlesGrid;
483
+ exports.helper_pagination = HelperPagination;