@everymatrix/blog-articles-grid 1.34.2 → 1.34.3

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +1 -1
  3. package/dist/blog-articles-grid/blog-articles-grid.esm.js +0 -1
  4. package/dist/blog-articles-grid/index.esm.js +0 -0
  5. package/dist/blog-articles-grid/p-13642dde.js +0 -1
  6. package/dist/blog-articles-grid/p-430e371b.entry.js +0 -1
  7. package/dist/cjs/blog-articles-grid.cjs.js +0 -19
  8. package/dist/cjs/blog-articles-grid_2.cjs.entry.js +0 -681
  9. package/dist/cjs/index-a88a1a42.js +0 -1352
  10. package/dist/cjs/index.cjs.js +0 -2
  11. package/dist/cjs/loader.cjs.js +0 -21
  12. package/dist/collection/collection-manifest.json +0 -19
  13. package/dist/collection/components/blog-articles-grid/blog-articles-grid.css +0 -167
  14. package/dist/collection/components/blog-articles-grid/blog-articles-grid.js +0 -773
  15. package/dist/collection/index.js +0 -1
  16. package/dist/collection/utils/locale.utils.js +0 -40
  17. package/dist/collection/utils/utils.js +0 -67
  18. package/dist/components/blog-articles-grid.d.ts +0 -11
  19. package/dist/components/blog-articles-grid.js +0 -482
  20. package/dist/components/helper-pagination.js +0 -6
  21. package/dist/components/helper-pagination2.js +0 -288
  22. package/dist/components/index.d.ts +0 -26
  23. package/dist/components/index.js +0 -1
  24. package/dist/esm/blog-articles-grid.js +0 -17
  25. package/dist/esm/blog-articles-grid_2.entry.js +0 -676
  26. package/dist/esm/index-3600ba1b.js +0 -1326
  27. package/dist/esm/index.js +0 -1
  28. package/dist/esm/loader.js +0 -17
  29. package/dist/esm/polyfills/core-js.js +0 -11
  30. package/dist/esm/polyfills/css-shim.js +0 -1
  31. package/dist/esm/polyfills/dom.js +0 -79
  32. package/dist/esm/polyfills/es5-html-element.js +0 -1
  33. package/dist/esm/polyfills/index.js +0 -34
  34. package/dist/esm/polyfills/system.js +0 -6
  35. package/dist/index.cjs.js +0 -1
  36. package/dist/index.js +0 -1
  37. package/dist/stencil.config.js +0 -22
  38. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/blog-articles-grid/.stencil/packages/blog-articles-grid/stencil.config.d.ts +0 -2
  39. package/dist/types/components/blog-articles-grid/blog-articles-grid.d.ts +0 -116
  40. package/dist/types/components.d.ts +0 -198
  41. package/dist/types/index.d.ts +0 -1
  42. package/dist/types/stencil-public-runtime.d.ts +0 -1565
  43. package/dist/types/utils/locale.utils.d.ts +0 -1
  44. package/dist/types/utils/utils.d.ts +0 -4
  45. package/loader/cdn.js +0 -3
  46. package/loader/index.cjs.js +0 -3
  47. package/loader/index.d.ts +0 -12
  48. package/loader/index.es2017.js +0 -3
  49. package/loader/index.js +0 -4
  50. package/loader/package.json +0 -10
@@ -1,681 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-a88a1a42.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
-
101
- const BlogArticlesGrid = class {
102
- constructor(hostRef) {
103
- index.registerInstance(this, hostRef);
104
- this.ArticleActionButton = index.createEvent(this, "ArticleActionButton", 7);
105
- /**
106
- * Language of the widget
107
- */
108
- this.language = 'en';
109
- /**
110
- * User roles
111
- */
112
- this.userRoles = 'everyone';
113
- /**
114
- * CMS Endpoint stage
115
- */
116
- this.cmsEnv = 'stage';
117
- /**
118
- * Client custom styling via string
119
- */
120
- this.clientStyling = '';
121
- /**
122
- * Client custom styling via url
123
- */
124
- this.clientStylingUrl = '';
125
- /**
126
- * Property used to display the publishing date
127
- */
128
- this.showPublishingDate = true;
129
- /**
130
- * Property used to display the image
131
- */
132
- this.showImage = true;
133
- /**
134
- * Property used to display the image
135
- */
136
- this.showTitle = true;
137
- /**
138
- * Property used to display the description
139
- */
140
- this.showContent = true;
141
- /**
142
- * Property used to display the button
143
- */
144
- this.showButton = true;
145
- /**
146
- * Event name to be sent when the button is clicked
147
- */
148
- this.postMessageEvent = '';
149
- /**
150
- * Customize pagination: Activate pagination numbered navigation
151
- */
152
- this.blogsLimit = '0';
153
- /**
154
- * Intl date format
155
- */
156
- this.intlDateTimeFormat = '';
157
- /**
158
- * Page to particularly be opened on start
159
- */
160
- this.page = '1';
161
- this.paginationBlogList = {
162
- offset: 0
163
- };
164
- this.currentPage = 0;
165
- this.hasErrors = false;
166
- this.limitStylingAppends = false;
167
- this.isLoading = true;
168
- this.bannerMatrixReady = false;
169
- this.nextPage = '';
170
- this.previousPage = '';
171
- this.device = '';
172
- this.totalBlogs = 0;
173
- this.defaultStyling = `
174
- div#PaginationContainer {
175
- justify-content: right;
176
- }
177
- .LeftItems button .NavigationButton {
178
- display: none;
179
- }
180
- .LeftItems button:after, .RightItems button:after {
181
- padding: 7px 12px;
182
- font-size: 18px;
183
- font-weight: 700;
184
- line-height: 46px;
185
- }
186
- .LeftItems button:after {
187
- 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");
188
- }
189
- .RightItems button:after {
190
- 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");
191
- display: block;
192
- height: 38px;
193
- }
194
- div.LeftItems button, div.RightItems button {
195
- width: unset;
196
- height: 40px;
197
- background-color: #fff;
198
- color: #000;
199
- border: 1px solid #000;
200
- overflow: hidden;
201
- &:disabled {
202
- background-color: #989898;
203
- }
204
- }
205
- div.LeftItems button {
206
- min-width: 60px;
207
- border-radius: 20px 0 0 20px;
208
- border-right: 0;
209
- }
210
- div.RightItems button {
211
- display: flex;
212
- min-width: 100px;
213
- justify-content: space-evenly;
214
- align-items: center;
215
- border-radius: 0 20px 20px 0;
216
- text-transform: none;
217
- }
218
- .RightItems button .NavigationButton {
219
- padding: 12px 0 12px 12px;
220
- font-weight: 700;
221
- }`;
222
- this.setClientStyling = () => {
223
- let sheet = document.createElement('style');
224
- sheet.innerHTML = this.clientStyling;
225
- this.stylingContainer.prepend(sheet);
226
- };
227
- this.setClientStylingURL = () => {
228
- let url = new URL(this.clientStylingUrl);
229
- let cssFile = document.createElement('style');
230
- fetch(url.href)
231
- .then((res) => res.text())
232
- .then((data) => {
233
- cssFile.innerHTML = data;
234
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
235
- })
236
- .catch((err) => {
237
- console.log('Error ', err);
238
- });
239
- };
240
- this.setImage = (image) => {
241
- let source = '';
242
- switch (this.device) {
243
- case 'mobile':
244
- source = image.sources[0].pictureSource;
245
- break;
246
- case 'tablet':
247
- source = image.sources[1].pictureSource;
248
- break;
249
- case 'desktop':
250
- source = image.sources[2].pictureSource;
251
- break;
252
- }
253
- return source;
254
- };
255
- this.renderContentConditionally = (content) => {
256
- if (!content)
257
- return;
258
- const hasBanner = content.indexOf('<bannermatrix-banner') !== -1;
259
- if (!hasBanner) {
260
- return index.h("div", { class: "BlogContent", innerHTML: content });
261
- }
262
- if (this.bannerMatrixReady) {
263
- return index.h("div", { class: "BlogContent", innerHTML: content });
264
- }
265
- return null;
266
- };
267
- }
268
- getArticleId(postId, slug, customPath) {
269
- if (this.usePostmessage) {
270
- window.postMessage({ type: this.postMessageEvent, postId, slug, customPath });
271
- }
272
- else {
273
- this.ArticleActionButton.emit({ postId, slug, customPath });
274
- }
275
- }
276
- // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
277
- handleBannerReady() {
278
- this.bannerMatrixReady = true;
279
- }
280
- watchEndpoint(newValue, oldValue) {
281
- this.currentPage = parseInt(this.page) - 1;
282
- if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
283
- this.getBlogArticleGrid();
284
- }
285
- }
286
- hpPageChange(event) {
287
- var _a, _b;
288
- this.paginationBlogList = event.detail;
289
- 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));
290
- if (this.page) {
291
- this.currentPage = this.currentPage + +this.page - 1;
292
- }
293
- if (this.currentPage + 1 > this.lastPage) {
294
- this.nextPage = null;
295
- return;
296
- }
297
- if (this.currentPage < 0) {
298
- this.previousPage = null;
299
- return;
300
- }
301
- window.postMessage({ type: 'BlogArticlesGridActivePagination', currentPage: this.currentPage }, window.location.href);
302
- this.getBlogArticleGrid();
303
- }
304
- connectedCallback() {
305
- if (this.cmsEndpoint && this.language && this.blogsLimit) {
306
- if (this.page) {
307
- this.currentPage = this.currentPage + +this.page - 1;
308
- this.getBlogArticleGrid(+this.page);
309
- }
310
- else {
311
- this.getBlogArticleGrid();
312
- }
313
- }
314
- }
315
- componentDidLoad() {
316
- window.postMessage({ type: 'BlogArticlesGridLoaded' }, window.location.href);
317
- this.device = getDeviceCustom();
318
- }
319
- sortArticlesByDate(arr) {
320
- arr.sort((a, b) => {
321
- if (a.publishingDate > b.publishingDate)
322
- return -1;
323
- if (a.publishingDate < b.publishingDate)
324
- return 1;
325
- return 0;
326
- });
327
- return arr;
328
- }
329
- findLatestFeatured(array) {
330
- let featuredItems = array.filter(item => item.isFeaturedPost);
331
- if (featuredItems.length === 0) {
332
- return null;
333
- }
334
- featuredItems = this.sortArticlesByDate(featuredItems);
335
- return featuredItems[0];
336
- }
337
- moveLatestFeatureToStart(articlesArray, latestFeatured) {
338
- const index = articlesArray.indexOf(latestFeatured);
339
- if (index !== -1) {
340
- articlesArray.splice(index, 1);
341
- articlesArray.unshift(latestFeatured);
342
- }
343
- return articlesArray;
344
- }
345
- getBlogArticleGrid(page) {
346
- this.isLoading = true;
347
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
348
- url.searchParams.append('per_page', this.blogsLimit);
349
- url.searchParams.append('page', JSON.stringify(page ? page : this.currentPage + 1));
350
- url.searchParams.append('env', this.cmsEnv);
351
- url.searchParams.append('userRoles', this.userRoles);
352
- url.searchParams.append('device', getDevicePlatform());
353
- fetch(url.href)
354
- .then((res) => {
355
- if (res.status >= 300) {
356
- this.hasErrors = true;
357
- throw new Error('There was an error while fetching the data');
358
- }
359
- return res.json();
360
- })
361
- .then((blogContent) => {
362
- this.lastPage = +blogContent.pages.last.match(/&page=(\d+)/)[1];
363
- let blogItems = blogContent.items;
364
- this.nextPage = blogContent.pages.next;
365
- this.previousPage = blogContent.pages.previous;
366
- this.totalBlogs = blogContent.total;
367
- const latestFeatured = this.findLatestFeatured(blogItems);
368
- this.blogData = this.sortArticlesByDate(blogItems);
369
- this.blogData = this.moveLatestFeatureToStart(blogItems, latestFeatured);
370
- this.blogData.items = blogItems.map((item) => {
371
- return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
372
- });
373
- this.isLoading = false;
374
- this.hasErrors = false;
375
- })
376
- .catch((err) => {
377
- this.hasErrors = true;
378
- console.log('Error', err);
379
- })
380
- .finally(() => this.isLoading = false);
381
- }
382
- componentDidRender() {
383
- // start custom styling area
384
- if (!this.limitStylingAppends && this.stylingContainer) {
385
- if (this.clientStyling)
386
- this.setClientStyling();
387
- if (this.clientStylingUrl)
388
- this.setClientStylingURL();
389
- this.limitStylingAppends = true;
390
- }
391
- // end custom styling area
392
- }
393
- formatDate(dateString) {
394
- return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
395
- }
396
- render() {
397
- var _a, _b;
398
- if (this.hasErrors) {
399
- return (index.h("div", { class: "BlogsContainer" }, index.h("div", { class: "ErrorMessage" }, translate$1('error', this.language))));
400
- }
401
- // Create an array to store the placeholder elements for each card
402
- const placeholderCards = [];
403
- // Loop through the blogsLimit in order to generate the desired number of cards
404
- for (let i = 0; i < parseInt(this.blogsLimit); i++) {
405
- placeholderCards.push(index.h("div", { class: "GridContainer FeaturedPost" }, 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" })))));
406
- }
407
- 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: this.blogsLimit, 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) &&
408
- index.h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.blogData && this.blogData.map((data) => {
409
- var _a, _b;
410
- 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 &&
411
- 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 &&
412
- index.h("div", { class: "BlogTitle" }, data === null || data === void 0 ? void 0 : data.title), this.showContent &&
413
- this.renderContentConditionally(data === null || data === void 0 ? void 0 : data.descriptionPreview), this.showButton &&
414
- 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))))));
415
- })), (this.isLoading) &&
416
- index.h("div", { class: "GridContainerWrapper LoadingGrid" }, placeholderCards))));
417
- }
418
- static get watchers() { return {
419
- "page": ["watchEndpoint"],
420
- "hasErrors": ["watchEndpoint"],
421
- "cmsEndpoint": ["watchEndpoint"],
422
- "language": ["watchEndpoint"],
423
- "cmsEnv": ["watchEndpoint"],
424
- "userRoles": ["watchEndpoint"],
425
- "blogsLimit": ["watchEndpoint"]
426
- }; }
427
- };
428
- BlogArticlesGrid.style = blogArticlesGridCss;
429
-
430
- /**
431
- * @name isMobile
432
- * @description A method that returns if the browser used to access the app is from a mobile device or not
433
- * @param {String} userAgent window.navigator.userAgent
434
- * @returns {Boolean} true or false
435
- */
436
- const isMobile = (userAgent) => {
437
- return !!(userAgent.toLowerCase().match(/android/i) ||
438
- userAgent.toLowerCase().match(/blackberry|bb/i) ||
439
- userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
440
- userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
441
- };
442
-
443
- const DEFAULT_LANGUAGE = 'en';
444
- const SUPPORTED_LANGUAGES = ['ro', 'en', 'hu', 'hr'];
445
- const TRANSLATIONS = {
446
- en: {
447
- firstPage: 'First',
448
- previousPage: 'Previous',
449
- nextPage: 'Next',
450
- lastPage: 'Last'
451
- },
452
- ro: {
453
- firstPage: 'Prima',
454
- previousPage: 'Anterior',
455
- nextPage: 'Urmatoarea',
456
- lastPage: 'Ultima'
457
- },
458
- fr: {
459
- firstPage: 'First',
460
- previousPage: 'Previous',
461
- nextPage: 'Next',
462
- lastPage: 'Last'
463
- },
464
- ar: {
465
- firstPage: 'First',
466
- previousPage: 'Previous',
467
- nextPage: 'Next',
468
- lastPage: 'Last'
469
- },
470
- hu: {
471
- firstPage: 'First',
472
- previousPage: 'Previous',
473
- nextPage: 'Következő',
474
- lastPage: 'Last'
475
- },
476
- hr: {
477
- firstPage: 'Prva',
478
- previousPage: 'Prethodna',
479
- nextPage: 'Slijedeća',
480
- lastPage: 'Zadnja'
481
- }
482
- };
483
- const translate = (key, customLang) => {
484
- const lang = customLang;
485
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
486
- };
487
-
488
- 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}}";
489
-
490
- const HelperPagination = class {
491
- constructor(hostRef) {
492
- index.registerInstance(this, hostRef);
493
- this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
494
- /**
495
- * Next page string value - determines if the next page is disabled or active
496
- */
497
- this.nextPage = '';
498
- /**
499
- * Previous page string value - determines if the previous page is disabled or active
500
- */
501
- this.prevPage = '';
502
- /**
503
- * The received offset
504
- */
505
- this.offset = 0;
506
- /**
507
- * The received limit for the number of pages
508
- */
509
- this.limit = 1;
510
- /**
511
- * The received total number of pages
512
- */
513
- this.total = 1;
514
- /**
515
- * Language
516
- */
517
- this.language = 'en';
518
- /**
519
- * Client custom styling via string
520
- */
521
- this.clientStyling = '';
522
- /**
523
- * Client custom styling via url content
524
- */
525
- this.clientStylingUrlContent = '';
526
- /**
527
- * Component working variable for last page
528
- */
529
- this.lastPage = false;
530
- /**
531
- * Component working variable for prvious page
532
- */
533
- this.previousPage = false;
534
- /**
535
- * In component working variable for the array of pages
536
- */
537
- this.pagesArray = [];
538
- /**
539
- * In component working variable for last page
540
- */
541
- this.endInt = 0;
542
- this.userAgent = window.navigator.userAgent;
543
- this.currentPage = 1;
544
- this.limitStylingAppends = false;
545
- /**
546
- * Navigation logic
547
- */
548
- this.navigateTo = (navigationPage) => {
549
- switch (navigationPage) {
550
- case 'firstPage':
551
- this.offsetInt = 0;
552
- break;
553
- case 'lastPage':
554
- this.offsetInt = this.endInt * this.limitInt;
555
- break;
556
- case 'previousPage':
557
- this.offsetInt -= this.limitInt;
558
- break;
559
- case 'nextPage':
560
- this.offsetInt += this.limitInt;
561
- break;
562
- case 'fivePagesBack':
563
- this.offsetInt -= this.limitInt * 5;
564
- this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
565
- break;
566
- case 'fivePagesForward':
567
- this.offsetInt += this.limitInt * 5;
568
- this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
569
- break;
570
- }
571
- this.previousPage = !this.offsetInt ? false : true;
572
- this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
573
- };
574
- /**
575
- * Handle navigation from here
576
- */
577
- this.paginationNavigation = (pageNumber, index) => {
578
- this.previousPage = true;
579
- if (!isNaN(pageNumber)) {
580
- if (pageNumber === 1) {
581
- this.offsetInt = pageNumber - 1;
582
- this.previousPage = false;
583
- }
584
- else {
585
- this.offsetInt = (pageNumber - 1) * this.limitInt;
586
- }
587
- }
588
- else {
589
- if (index === 0 && this.currentPage <= 4) {
590
- this.navigateTo('firstPage');
591
- }
592
- else if (index === 0 && this.currentPage > 4) {
593
- this.navigateTo('fivePagesBack');
594
- }
595
- else if (index === 4 && this.endInt - this.currentPage >= 2) {
596
- this.navigateTo('fivePagesForward');
597
- }
598
- }
599
- this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
600
- };
601
- this.setClientStyling = () => {
602
- let sheet = document.createElement('style');
603
- sheet.innerHTML = this.clientStyling;
604
- this.stylingContainer.prepend(sheet);
605
- };
606
- this.setClientStylingURL = () => {
607
- let cssFile = document.createElement('style');
608
- setTimeout(() => {
609
- cssFile.innerHTML = this.clientStylingUrlContent;
610
- this.stylingContainer.prepend(cssFile);
611
- }, 1);
612
- };
613
- }
614
- componentWillRender() {
615
- this.offsetInt = this.offset;
616
- this.limitInt = this.limit;
617
- this.currentPage = (this.offsetInt / this.limitInt) + 1;
618
- this.limitInt = this.limit;
619
- this.totalInt = this.total;
620
- this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
621
- this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
622
- /**
623
- * Construct numbered navigation area based on current page position
624
- */
625
- if (this.currentPage == 1 || this.currentPage == 2) {
626
- this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
627
- this.pagesArray.push('...');
628
- }
629
- else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
630
- this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
631
- this.pagesArray.push('...');
632
- this.pagesArray.unshift('...');
633
- }
634
- else if ((this.endInt - this.currentPage) < 3) {
635
- this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
636
- this.pagesArray.unshift('...');
637
- }
638
- }
639
- componentDidRender() {
640
- // start custom styling area
641
- if (!this.limitStylingAppends && this.stylingContainer) {
642
- if (this.clientStyling)
643
- this.setClientStyling();
644
- if (this.clientStylingUrlContent)
645
- this.setClientStylingURL();
646
- this.limitStylingAppends = true;
647
- }
648
- // end custom styling area
649
- }
650
- render() {
651
- /**
652
- * Center navigation area
653
- */
654
- let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
655
- 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))));
656
- }));
657
- /**
658
- * Left navigation area
659
- */
660
- 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" }));
661
- 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" })));
662
- if (isMobile(this.userAgent)) {
663
- buttonsLeftSide =
664
- 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" })));
665
- }
666
- /**
667
- * Right navigation area
668
- */
669
- 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" }));
670
- 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);
671
- if (isMobile(this.userAgent)) {
672
- buttonsRightSide =
673
- 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" })));
674
- }
675
- return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
676
- }
677
- };
678
- HelperPagination.style = helperPaginationCss;
679
-
680
- exports.blog_articles_grid = BlogArticlesGrid;
681
- exports.helper_pagination = HelperPagination;