@everymatrix/blog-articles-grid 1.0.69

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.
Files changed (44) hide show
  1. package/dist/blog-articles-grid/blog-articles-grid.esm.js +1 -0
  2. package/dist/blog-articles-grid/index.esm.js +0 -0
  3. package/dist/blog-articles-grid/p-786304d4.js +2 -0
  4. package/dist/blog-articles-grid/p-b88c9233.entry.js +1 -0
  5. package/dist/blog-articles-grid/p-e1255160.js +1 -0
  6. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  7. package/dist/cjs/blog-articles-grid.cjs.js +25 -0
  8. package/dist/cjs/blog-articles-grid_2.cjs.entry.js +623 -0
  9. package/dist/cjs/index-fad8e671.js +1332 -0
  10. package/dist/cjs/index.cjs.js +2 -0
  11. package/dist/cjs/loader.cjs.js +15 -0
  12. package/dist/collection/collection-manifest.json +19 -0
  13. package/dist/collection/components/blog-articles-grid/blog-articles-grid.css +167 -0
  14. package/dist/collection/components/blog-articles-grid/blog-articles-grid.js +740 -0
  15. package/dist/collection/components/blog-articles-grid/index.js +1 -0
  16. package/dist/collection/index.js +1 -0
  17. package/dist/collection/utils/locale.utils.js +40 -0
  18. package/dist/collection/utils/utils.js +67 -0
  19. package/dist/esm/app-globals-0f993ce5.js +3 -0
  20. package/dist/esm/blog-articles-grid.js +20 -0
  21. package/dist/esm/blog-articles-grid_2.entry.js +618 -0
  22. package/dist/esm/index-2c19cd94.js +1305 -0
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/loader.js +11 -0
  25. package/dist/index.cjs.js +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/stencil.config.dev.js +17 -0
  28. package/dist/stencil.config.js +17 -0
  29. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/stencil.config.d.ts +2 -0
  30. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/stencil.config.dev.d.ts +2 -0
  31. package/dist/types/components/blog-articles-grid/blog-articles-grid.d.ts +117 -0
  32. package/dist/types/components/blog-articles-grid/index.d.ts +1 -0
  33. package/dist/types/components.d.ts +213 -0
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  36. package/dist/types/utils/locale.utils.d.ts +1 -0
  37. package/dist/types/utils/utils.d.ts +4 -0
  38. package/loader/cdn.js +1 -0
  39. package/loader/index.cjs.js +1 -0
  40. package/loader/index.d.ts +24 -0
  41. package/loader/index.es2017.js +1 -0
  42. package/loader/index.js +2 -0
  43. package/loader/package.json +11 -0
  44. package/package.json +29 -0
@@ -0,0 +1,623 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-fad8e671.js');
6
+
7
+ const DEFAULT_LANGUAGE$1 = 'en';
8
+ const SUPPORTED_LANGUAGES$1 = ['ro', 'en', 'fr', 'ar', 'hu', 'hr'];
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
+ hu: {
27
+ error: 'خطأ',
28
+ readmore: 'Tovább olvasom',
29
+ },
30
+ hr: {
31
+ error: 'Greška',
32
+ readmore: 'Pročitaj više'
33
+ },
34
+ 'pt-br': {
35
+ error: 'Erro',
36
+ readmore: 'Ler mais'
37
+ },
38
+ 'es-mx': {
39
+ error: 'Error',
40
+ readmore: 'Leer más'
41
+ }
42
+ };
43
+ const translate$1 = (key, customLang) => {
44
+ const lang = customLang;
45
+ return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
46
+ };
47
+
48
+ function checkCustomDeviceWidth() {
49
+ const width = screen.availWidth;
50
+ if (width < 600) {
51
+ return 'mobile';
52
+ }
53
+ else if (width >= 600 && width < 1100) {
54
+ return 'tablet';
55
+ }
56
+ }
57
+ function isIpad() {
58
+ const userAgent = navigator.userAgent.toLowerCase();
59
+ // Traditional iPad user agent
60
+ if (userAgent.includes('ipad')) {
61
+ return true;
62
+ }
63
+ return userAgent.indexOf('macintosh') > -1 && navigator.maxTouchPoints && navigator.maxTouchPoints > 2;
64
+ }
65
+ function getDeviceCustom() {
66
+ const userAgent = navigator.userAgent.toLowerCase();
67
+ let source = '';
68
+ source = (userAgent.includes('android') || userAgent.includes('iphone') || isIpad()) ? checkCustomDeviceWidth() : 'desktop';
69
+ return source;
70
+ }
71
+ const getDevice = () => {
72
+ let userAgent = window.navigator.userAgent;
73
+ if (userAgent.toLowerCase().match(/android/i)) {
74
+ return 'Android';
75
+ }
76
+ if (userAgent.toLowerCase().match(/iphone/i)) {
77
+ return 'iPhone';
78
+ }
79
+ if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
80
+ return 'iPad';
81
+ }
82
+ return 'PC';
83
+ };
84
+ const getDevicePlatform = () => {
85
+ const device = getDevice();
86
+ if (device) {
87
+ if (device === 'PC') {
88
+ return 'dk';
89
+ }
90
+ else if (device === 'iPad' || device === 'iPhone') {
91
+ return 'mtWeb';
92
+ }
93
+ else {
94
+ return 'mtWeb';
95
+ }
96
+ }
97
+ };
98
+
99
+ const blogArticlesGridCss = ":host {\n display: block;\n}\n\n.BlogPageContainer {\n background: #0A0A17;\n padding: 20px;\n}\n\n.GridContainerWrapper {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 20px;\n}\n\n.BlogPage-0 .GridContainer.FeaturedPost:first-child {\n width: 100%;\n flex-basis: auto;\n}\n\n.GridContainer {\n container-type: inline-size;\n container-name: article;\n border-radius: 15px;\n color: #000;\n overflow: hidden;\n}\n.GridContainer.FeaturedPost:first-child {\n grid-column: 1/-1;\n width: 100%;\n}\n.GridContainer .GridWrapper {\n display: flex;\n flex-direction: row;\n height: 280px;\n background: var(--emfe-w-color-white, #FFFFFF);\n}\n.GridContainer .GridSector {\n flex-basis: 50%;\n position: relative;\n}\n.GridContainer .GridSector:first-of-type {\n height: 280px;\n display: flex;\n}\n.GridContainer .GridSector:last-of-type {\n padding: 20px 40px;\n display: flex;\n flex-direction: column;\n}\n.GridContainer .VisualContent {\n width: 100%;\n}\n.GridContainer .BlogDate {\n position: absolute;\n bottom: 0px;\n left: 30px;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: var(--emfe-w-color-white, #FFFFFF);\n background-color: #CD0B5E;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #000;\n padding-bottom: 10px;\n}\n.GridContainer .BlogContent {\n display: -webkit-box;\n font-size: 14px;\n line-height: 1.2em;\n -webkit-line-clamp: 6;\n color: #000;\n -webkit-box-orient: vertical;\n box-sizing: border-box;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n.GridContainer .BlogLink {\n color: #000;\n position: absolute;\n bottom: 16px;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #D0046C;\n cursor: pointer;\n}\n\n@container article (max-width: 550px) {\n .GridContainer .GridWrapper {\n height: 380px;\n flex-direction: column;\n }\n .GridContainer .GridWrapper .GridSector:first-of-type {\n height: 120px;\n flex-shrink: 0;\n flex-basis: 150px;\n }\n .GridContainer .GridWrapper .GridSector:last-of-type {\n padding: 20px 20px 40px;\n }\n}\n.LoadingImage {\n width: 100%;\n height: 100%;\n background-color: var(--emfe-w-color-gray-100, #E6E6E6);\n}\n\n.LoadingStripe {\n border: 1px solid var(--emfe-w-color-white, #FFFFFF);\n height: 20%;\n background-color: var(--emfe-w-color-gray-100, #E6E6E6);\n margin-bottom: 5px;\n}\n\n.LoadingSmallStripe {\n width: 40%;\n}\n\n.LoadingMediumStripe {\n width: 70%;\n}\n\n.BlogLink.LoadingLongStripe {\n position: static;\n width: 100%;\n}\n\n.GridContainerWrapper.LoadingGrid .GridSector {\n justify-content: space-around;\n}\n\n.GridContainerWrapper.LoadingGrid .LoadingImage, .GridContainerWrapper.LoadingGrid .LoadingStripe {\n animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n -webkit-animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n}\n\n@keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}\n@-webkit-keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}";
100
+ const BlogArticlesGridStyle0 = blogArticlesGridCss;
101
+
102
+ const BlogArticlesGrid = class {
103
+ constructor(hostRef) {
104
+ index.registerInstance(this, hostRef);
105
+ this.articleActionButton = index.createEvent(this, "articleActionButton", 7);
106
+ this.clientStylingContent = '';
107
+ this.defaultStyling = `
108
+ div#PaginationContainer {
109
+ justify-content: right;
110
+ }
111
+ .LeftItems button .NavigationButton {
112
+ display: none;
113
+ }
114
+ .LeftItems button:after, .RightItems button:after {
115
+ padding: 7px 12px;
116
+ font-size: 18px;
117
+ font-weight: 700;
118
+ line-height: 46px;
119
+ }
120
+ .LeftItems button:after {
121
+ 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");
122
+ }
123
+ .RightItems button:after {
124
+ 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");
125
+ display: block;
126
+ height: 38px;
127
+ }
128
+ div.LeftItems button, div.RightItems button {
129
+ width: unset;
130
+ height: 40px;
131
+ background-color: #fff;
132
+ color: #000;
133
+ border: 1px solid #000;
134
+ overflow: hidden;
135
+ &:disabled {
136
+ background-color: #989898;
137
+ }
138
+ }
139
+ div.LeftItems button {
140
+ min-width: 60px;
141
+ border-radius: 20px 0 0 20px;
142
+ border-right: 0;
143
+ }
144
+ div.RightItems button {
145
+ display: flex;
146
+ min-width: 100px;
147
+ justify-content: space-evenly;
148
+ align-items: center;
149
+ border-radius: 0 20px 20px 0;
150
+ text-transform: none;
151
+ }
152
+ .RightItems button .NavigationButton {
153
+ padding: 12px 0 12px 12px;
154
+ font-weight: 700;
155
+ }`;
156
+ this.setClientStyling = () => {
157
+ this.clientStylingContent += this.clientStyling;
158
+ const sheet = document.createElement('style');
159
+ sheet.innerHTML = this.clientStylingContent;
160
+ this.stylingContainer.prepend(sheet);
161
+ };
162
+ this.setImage = (image) => {
163
+ let source = '';
164
+ switch (this.device) {
165
+ case 'mobile':
166
+ source = image.sources[0].pictureSource;
167
+ break;
168
+ case 'tablet':
169
+ source = image.sources[1].pictureSource;
170
+ break;
171
+ case 'desktop':
172
+ source = image.sources[2].pictureSource;
173
+ break;
174
+ }
175
+ return source;
176
+ };
177
+ this.renderContentConditionally = (content) => {
178
+ if (!content)
179
+ return;
180
+ const hasBanner = content.indexOf('<bannermatrix-banner') !== -1;
181
+ if (!hasBanner) {
182
+ return index.h("div", { class: "BlogContent", innerHTML: content });
183
+ }
184
+ if (this.bannerMatrixReady) {
185
+ return index.h("div", { class: "BlogContent", innerHTML: content });
186
+ }
187
+ return null;
188
+ };
189
+ this.cmsEndpoint = undefined;
190
+ this.language = 'en';
191
+ this.userRoles = 'everyone';
192
+ this.cmsEnv = 'stage';
193
+ this.clientStyling = '';
194
+ this.clientStylingUrl = '';
195
+ this.showPublishingDate = true;
196
+ this.showImage = true;
197
+ this.showTitle = true;
198
+ this.showContent = true;
199
+ this.showButton = true;
200
+ this.usePostmessage = undefined;
201
+ this.postMessageEvent = '';
202
+ this.blogsLimit = '0';
203
+ this.paginationActive = undefined;
204
+ this.arrowsActive = undefined;
205
+ this.secondaryArrowsActive = undefined;
206
+ this.numberedNavActive = undefined;
207
+ this.intlDateTimeFormat = '';
208
+ this.page = '1';
209
+ this.paginationBlogList = {
210
+ offset: 0
211
+ };
212
+ this.currentPage = 0;
213
+ this.hasErrors = false;
214
+ this.isLoading = true;
215
+ this.bannerMatrixReady = false;
216
+ this.nextPage = '';
217
+ this.previousPage = '';
218
+ this.device = '';
219
+ this.blogData = undefined;
220
+ this.totalBlogs = 0;
221
+ }
222
+ getArticleId(postId, slug, customPath) {
223
+ if (this.usePostmessage) {
224
+ window.postMessage({ type: this.postMessageEvent, postId, slug, customPath });
225
+ }
226
+ else {
227
+ this.articleActionButton.emit({ postId, slug, customPath });
228
+ }
229
+ }
230
+ // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
231
+ handleBannerReady() {
232
+ this.bannerMatrixReady = true;
233
+ }
234
+ watchEndpoint(newValue, oldValue) {
235
+ this.currentPage = parseInt(this.page) - 1;
236
+ if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
237
+ this.getBlogArticleGrid();
238
+ }
239
+ }
240
+ handleStylingChange(newValue, oldValue) {
241
+ if (newValue !== oldValue) {
242
+ this.fetchClientStyling().then(_ => this.setClientStyling());
243
+ }
244
+ }
245
+ hpPageChange(event) {
246
+ var _a, _b;
247
+ this.paginationBlogList = event.detail;
248
+ 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));
249
+ if (this.page) {
250
+ this.currentPage = this.currentPage + +this.page - 1;
251
+ }
252
+ if (this.currentPage + 1 > this.lastPage) {
253
+ this.nextPage = null;
254
+ return;
255
+ }
256
+ if (this.currentPage < 0) {
257
+ this.previousPage = null;
258
+ return;
259
+ }
260
+ window.postMessage({ type: 'BlogArticlesGridActivePagination', currentPage: this.currentPage }, window.location.href);
261
+ this.getBlogArticleGrid();
262
+ }
263
+ sortArticlesByDate(arr) {
264
+ arr.sort((a, b) => {
265
+ if (a.publishingDate > b.publishingDate)
266
+ return -1;
267
+ if (a.publishingDate < b.publishingDate)
268
+ return 1;
269
+ return 0;
270
+ });
271
+ return arr;
272
+ }
273
+ findLatestFeatured(array) {
274
+ let featuredItems = array.filter(item => item.isFeaturedPost);
275
+ if (featuredItems.length === 0) {
276
+ return null;
277
+ }
278
+ featuredItems = this.sortArticlesByDate(featuredItems);
279
+ return featuredItems[0];
280
+ }
281
+ moveLatestFeatureToStart(articlesArray, latestFeatured) {
282
+ const index = articlesArray.indexOf(latestFeatured);
283
+ if (index !== -1) {
284
+ articlesArray.splice(index, 1);
285
+ articlesArray.unshift(latestFeatured);
286
+ }
287
+ return articlesArray;
288
+ }
289
+ getBlogArticleGrid(page) {
290
+ this.isLoading = true;
291
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
292
+ url.searchParams.append('per_page', this.blogsLimit);
293
+ url.searchParams.append('page', JSON.stringify(page ? page : this.currentPage + 1));
294
+ url.searchParams.append('env', this.cmsEnv);
295
+ url.searchParams.append('userRoles', this.userRoles);
296
+ url.searchParams.append('device', getDevicePlatform());
297
+ fetch(url.href)
298
+ .then((res) => {
299
+ if (res.status >= 300) {
300
+ this.hasErrors = true;
301
+ throw new Error('There was an error while fetching the data');
302
+ }
303
+ return res.json();
304
+ })
305
+ .then((blogContent) => {
306
+ this.lastPage = +blogContent.pages.last.match(/&page=(\d+)/)[1];
307
+ let blogItems = blogContent.items;
308
+ this.nextPage = blogContent.pages.next;
309
+ this.previousPage = blogContent.pages.previous;
310
+ this.totalBlogs = blogContent.total;
311
+ const latestFeatured = this.findLatestFeatured(blogItems);
312
+ this.blogData = this.sortArticlesByDate(blogItems);
313
+ this.blogData = this.moveLatestFeatureToStart(blogItems, latestFeatured);
314
+ this.blogData.items = blogItems.map((item) => {
315
+ return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
316
+ });
317
+ this.isLoading = false;
318
+ this.hasErrors = false;
319
+ })
320
+ .catch((err) => {
321
+ this.hasErrors = true;
322
+ console.log('Error', err);
323
+ })
324
+ .finally(() => this.isLoading = false);
325
+ }
326
+ connectedCallback() {
327
+ if (this.cmsEndpoint && this.language && this.blogsLimit) {
328
+ if (this.page) {
329
+ this.currentPage = this.currentPage + +this.page - 1;
330
+ this.getBlogArticleGrid(+this.page);
331
+ }
332
+ else {
333
+ this.getBlogArticleGrid();
334
+ }
335
+ }
336
+ }
337
+ componentWillLoad() {
338
+ if (this.clientStylingUrl)
339
+ return this.fetchClientStyling();
340
+ }
341
+ componentDidLoad() {
342
+ if (this.clientStyling || this.clientStylingUrl)
343
+ this.setClientStyling();
344
+ window.postMessage({ type: 'BlogArticlesGridLoaded' }, window.location.href);
345
+ this.device = getDeviceCustom();
346
+ }
347
+ fetchClientStyling() {
348
+ if (!this.clientStylingUrl)
349
+ return;
350
+ return new Promise(resolve => {
351
+ fetch(this.clientStylingUrl)
352
+ .then((res) => res.text())
353
+ .then((data) => {
354
+ resolve(data);
355
+ this.clientStylingContent += data;
356
+ })
357
+ .catch((err) => {
358
+ console.error('Error fetching Client Styling:', err);
359
+ });
360
+ });
361
+ }
362
+ formatDate(dateString) {
363
+ return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
364
+ }
365
+ render() {
366
+ var _a, _b;
367
+ if (this.hasErrors) {
368
+ return (index.h("div", { class: "BlogsContainer" }, index.h("div", { class: "ErrorMessage" }, translate$1('error', this.language))));
369
+ }
370
+ // Create an array to store the placeholder elements for each card
371
+ const placeholderCards = [];
372
+ // Loop through the blogsLimit in order to generate the desired number of cards
373
+ for (let i = 0; i < parseInt(this.blogsLimit); i++) {
374
+ placeholderCards.push(index.h("div", { class: "GridContainer FeaturedPost Skeleton" }, index.h("div", { class: "GridWrapper" }, index.h("div", { class: "GridSector" }, index.h("div", { class: "VisualContent LoadingImage" })), index.h("div", { class: "GridSector" }, index.h("div", { class: "BlogTitle LoadingStripe LoadingSmallStripe" }), index.h("div", { class: "BlogDetails LoadingStripe LoadingMediumStripe" }), index.h("div", { class: "BlogLink LoadingStripe LoadingLongStripe" })))));
375
+ }
376
+ return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "BlogPageContainer" }, index.h("div", { class: "BlogGridPaginationWrapper" }, this.paginationActive == true && this.totalBlogs > +this.blogsLimit && index.h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: (_b = (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length, language: this.language, "client-styling": this.clientStyling || this.defaultStyling, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
377
+ index.h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.blogData && this.blogData.map((data) => {
378
+ var _a, _b;
379
+ return index.h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, index.h("div", { class: "GridWrapper" }, index.h("div", { class: "GridSector" }, this.showPublishingDate &&
380
+ index.h("div", { class: "BlogDate" }, this.formatDate(data === null || data === void 0 ? void 0 : data.publishingDate)), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (index.h("div", { class: "VisualContent", style: { background: `url(${this.setImage(data.image)}) no-repeat center center / cover` } })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (index.h("video", { class: "VisualContent", src: data.video.sources[this.device], controls: true })) : (index.h("h1", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), index.h("div", { class: "GridSector" }, this.showTitle &&
381
+ index.h("div", { class: "BlogTitle" }, data === null || data === void 0 ? void 0 : data.title), this.showContent &&
382
+ this.renderContentConditionally(data === null || data === void 0 ? void 0 : data.descriptionPreview), this.showButton &&
383
+ index.h("div", { class: "BlogLink" }, index.h("button", { onClick: () => this.getArticleId(data === null || data === void 0 ? void 0 : data.postID, data === null || data === void 0 ? void 0 : data.slug, data === null || data === void 0 ? void 0 : data.customPath) }, translate$1('readmore', this.language))))));
384
+ })), (this.isLoading) &&
385
+ index.h("div", { class: "GridContainerWrapper LoadingGrid" }, placeholderCards))));
386
+ }
387
+ static get watchers() { return {
388
+ "page": ["watchEndpoint"],
389
+ "hasErrors": ["watchEndpoint"],
390
+ "cmsEndpoint": ["watchEndpoint"],
391
+ "language": ["watchEndpoint"],
392
+ "cmsEnv": ["watchEndpoint"],
393
+ "userRoles": ["watchEndpoint"],
394
+ "blogsLimit": ["watchEndpoint"],
395
+ "clientStyling": ["handleStylingChange"],
396
+ "clientStylingUrl": ["handleStylingChange"]
397
+ }; }
398
+ };
399
+ BlogArticlesGrid.style = BlogArticlesGridStyle0;
400
+
401
+ /**
402
+ * @name isMobile
403
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
404
+ * @param {String} userAgent window.navigator.userAgent
405
+ * @returns {Boolean} true or false
406
+ */
407
+ const isMobile = (userAgent) => {
408
+ return !!(userAgent.toLowerCase().match(/android/i) ||
409
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
410
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
411
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
412
+ };
413
+
414
+ const DEFAULT_LANGUAGE = 'en';
415
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'hu', 'hr'];
416
+ const TRANSLATIONS = {
417
+ en: {
418
+ firstPage: 'First',
419
+ previousPage: 'Previous',
420
+ nextPage: 'Next',
421
+ lastPage: 'Last'
422
+ },
423
+ ro: {
424
+ firstPage: 'Prima',
425
+ previousPage: 'Anterior',
426
+ nextPage: 'Urmatoarea',
427
+ lastPage: 'Ultima'
428
+ },
429
+ fr: {
430
+ firstPage: 'First',
431
+ previousPage: 'Previous',
432
+ nextPage: 'Next',
433
+ lastPage: 'Last'
434
+ },
435
+ ar: {
436
+ firstPage: 'First',
437
+ previousPage: 'Previous',
438
+ nextPage: 'Next',
439
+ lastPage: 'Last'
440
+ },
441
+ hu: {
442
+ firstPage: 'First',
443
+ previousPage: 'Previous',
444
+ nextPage: 'Következő',
445
+ lastPage: 'Last'
446
+ },
447
+ hr: {
448
+ firstPage: 'Prva',
449
+ previousPage: 'Prethodna',
450
+ nextPage: 'Slijedeća',
451
+ lastPage: 'Zadnja'
452
+ }
453
+ };
454
+ const translate = (key, customLang) => {
455
+ const lang = customLang;
456
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
457
+ };
458
+
459
+ 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}}";
460
+ const HelperPaginationStyle0 = helperPaginationCss;
461
+
462
+ const HelperPagination = class {
463
+ constructor(hostRef) {
464
+ index.registerInstance(this, hostRef);
465
+ this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
466
+ this.userAgent = window.navigator.userAgent;
467
+ this.currentPage = 1;
468
+ /**
469
+ * Navigation logic
470
+ */
471
+ this.navigateTo = (navigationPage) => {
472
+ switch (navigationPage) {
473
+ case 'firstPage':
474
+ this.offsetInt = 0;
475
+ break;
476
+ case 'lastPage':
477
+ this.offsetInt = this.endInt * this.limitInt;
478
+ break;
479
+ case 'previousPage':
480
+ this.offsetInt -= this.limitInt;
481
+ break;
482
+ case 'nextPage':
483
+ this.offsetInt += this.limitInt;
484
+ break;
485
+ case 'fivePagesBack':
486
+ this.offsetInt -= this.limitInt * 5;
487
+ this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
488
+ break;
489
+ case 'fivePagesForward':
490
+ this.offsetInt += this.limitInt * 5;
491
+ this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
492
+ break;
493
+ }
494
+ this.previousPage = !this.offsetInt ? false : true;
495
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
496
+ };
497
+ /**
498
+ * Handle navigation from here
499
+ */
500
+ this.paginationNavigation = (pageNumber, index) => {
501
+ this.previousPage = true;
502
+ if (!isNaN(pageNumber)) {
503
+ if (pageNumber === 1) {
504
+ this.offsetInt = pageNumber - 1;
505
+ this.previousPage = false;
506
+ }
507
+ else {
508
+ this.offsetInt = (pageNumber - 1) * this.limitInt;
509
+ }
510
+ }
511
+ else {
512
+ if (index === 0 && this.currentPage <= 4) {
513
+ this.navigateTo('firstPage');
514
+ }
515
+ else if (index === 0 && this.currentPage > 4) {
516
+ this.navigateTo('fivePagesBack');
517
+ }
518
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
519
+ this.navigateTo('fivePagesForward');
520
+ }
521
+ }
522
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
523
+ };
524
+ this.setClientStyling = () => {
525
+ let sheet = document.createElement('style');
526
+ sheet.innerHTML = this.clientStyling;
527
+ this.stylingContainer.prepend(sheet);
528
+ };
529
+ this.setClientStylingURL = () => {
530
+ let cssFile = document.createElement('style');
531
+ setTimeout(() => {
532
+ cssFile.innerHTML = this.clientStylingUrlContent;
533
+ this.stylingContainer.prepend(cssFile);
534
+ }, 1);
535
+ };
536
+ this.nextPage = '';
537
+ this.prevPage = '';
538
+ this.offset = 0;
539
+ this.limit = 1;
540
+ this.total = 1;
541
+ this.language = 'en';
542
+ this.clientStyling = '';
543
+ this.clientStylingUrlContent = '';
544
+ this.arrowsActive = undefined;
545
+ this.secondaryArrowsActive = undefined;
546
+ this.numberedNavActive = undefined;
547
+ this.offsetInt = undefined;
548
+ this.lastPage = false;
549
+ this.previousPage = false;
550
+ this.limitInt = undefined;
551
+ this.totalInt = undefined;
552
+ this.pagesArray = [];
553
+ this.endInt = 0;
554
+ this.limitStylingAppends = false;
555
+ }
556
+ componentWillRender() {
557
+ this.offsetInt = this.offset;
558
+ this.limitInt = this.limit;
559
+ this.currentPage = (this.offsetInt / this.limitInt) + 1;
560
+ this.limitInt = this.limit;
561
+ this.totalInt = this.total;
562
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
563
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
564
+ /**
565
+ * Construct numbered navigation area based on current page position
566
+ */
567
+ if (this.currentPage == 1 || this.currentPage == 2) {
568
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
569
+ this.pagesArray.push('...');
570
+ }
571
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
572
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
573
+ this.pagesArray.push('...');
574
+ this.pagesArray.unshift('...');
575
+ }
576
+ else if ((this.endInt - this.currentPage) < 3) {
577
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
578
+ this.pagesArray.unshift('...');
579
+ }
580
+ }
581
+ componentDidRender() {
582
+ // start custom styling area
583
+ if (!this.limitStylingAppends && this.stylingContainer) {
584
+ if (this.clientStyling)
585
+ this.setClientStyling();
586
+ if (this.clientStylingUrlContent)
587
+ this.setClientStylingURL();
588
+ this.limitStylingAppends = true;
589
+ }
590
+ // end custom styling area
591
+ }
592
+ render() {
593
+ /**
594
+ * Center navigation area
595
+ */
596
+ let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
597
+ 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))));
598
+ }));
599
+ /**
600
+ * Left navigation area
601
+ */
602
+ let buttonSecondaryLeftSide = index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, index.h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), index.h("span", { class: "NavigationIcon" }));
603
+ let buttonsLeftSide = index.h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
604
+ if (isMobile(this.userAgent)) {
605
+ buttonsLeftSide =
606
+ index.h("div", { class: "LeftItems" }, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
607
+ }
608
+ /**
609
+ * Right navigation area
610
+ */
611
+ let buttonSecondaryRightSide = index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') }, index.h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), index.h("span", { class: "NavigationIcon" }));
612
+ let buttonsRightSide = index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
613
+ if (isMobile(this.userAgent)) {
614
+ buttonsRightSide =
615
+ index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })));
616
+ }
617
+ return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
618
+ }
619
+ };
620
+ HelperPagination.style = HelperPaginationStyle0;
621
+
622
+ exports.blog_articles_grid = BlogArticlesGrid;
623
+ exports.helper_pagination = HelperPagination;