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