@everymatrix/blog-articles-grid 1.31.2 → 1.32.4

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