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