@everymatrix/blog-article-details 1.44.0 → 1.45.2

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 (48) hide show
  1. package/dist/blog-article-details/blog-article-details.esm.js +1 -1
  2. package/dist/blog-article-details/p-0783b0ba.js +2 -0
  3. package/dist/blog-article-details/p-e1255160.js +1 -0
  4. package/dist/blog-article-details/p-f02359f3.entry.js +1 -0
  5. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  6. package/dist/cjs/blog-article-details.cjs.entry.js +223 -248
  7. package/dist/cjs/blog-article-details.cjs.js +17 -11
  8. package/dist/cjs/index-ade27b33.js +1254 -0
  9. package/dist/cjs/loader.cjs.js +7 -13
  10. package/dist/collection/collection-manifest.json +3 -3
  11. package/dist/collection/components/blog-article-details/blog-article-details.js +463 -485
  12. package/dist/collection/components/blog-article-details/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +23 -23
  14. package/dist/collection/utils/utils.js +48 -48
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/blog-article-details.entry.js +223 -248
  17. package/dist/esm/blog-article-details.js +14 -11
  18. package/dist/esm/index-9d94198d.js +1228 -0
  19. package/dist/esm/loader.js +7 -13
  20. package/dist/stencil.config.dev.js +17 -0
  21. package/dist/stencil.config.js +14 -19
  22. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/blog-article-details/.stencil/packages/stencil/blog-article-details/stencil.config.d.ts +2 -0
  23. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/blog-article-details/.stencil/packages/stencil/blog-article-details/stencil.config.dev.d.ts +2 -0
  24. package/dist/types/components/blog-article-details/blog-article-details.d.ts +78 -78
  25. package/dist/types/components/blog-article-details/index.d.ts +1 -0
  26. package/dist/types/stencil-public-runtime.d.ts +142 -33
  27. package/loader/cdn.js +1 -3
  28. package/loader/index.cjs.js +1 -3
  29. package/loader/index.d.ts +13 -1
  30. package/loader/index.es2017.js +1 -3
  31. package/loader/index.js +1 -3
  32. package/loader/package.json +1 -0
  33. package/package.json +8 -6
  34. package/dist/blog-article-details/p-68e0210a.js +0 -1
  35. package/dist/blog-article-details/p-b8c9de45.entry.js +0 -1
  36. package/dist/cjs/index-d983d0f8.js +0 -1255
  37. package/dist/components/blog-article-details.d.ts +0 -11
  38. package/dist/components/blog-article-details.js +0 -317
  39. package/dist/components/index.d.ts +0 -26
  40. package/dist/components/index.js +0 -1
  41. package/dist/esm/index-a6d43dfd.js +0 -1230
  42. package/dist/esm/polyfills/core-js.js +0 -11
  43. package/dist/esm/polyfills/css-shim.js +0 -1
  44. package/dist/esm/polyfills/dom.js +0 -79
  45. package/dist/esm/polyfills/es5-html-element.js +0 -1
  46. package/dist/esm/polyfills/index.js +0 -34
  47. package/dist/esm/polyfills/system.js +0 -6
  48. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/blog-article-details/.stencil/packages/blog-article-details/stencil.config.d.ts +0 -2
@@ -1,11 +0,0 @@
1
- import type { Components, JSX } from "../types/components";
2
-
3
- interface BlogArticleDetails extends Components.BlogArticleDetails, HTMLElement {}
4
- export const BlogArticleDetails: {
5
- prototype: BlogArticleDetails;
6
- new (): BlogArticleDetails;
7
- };
8
- /**
9
- * Used to define this component and all nested components recursively.
10
- */
11
- export const defineCustomElement: () => void;
@@ -1,317 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
-
3
- const DEFAULT_LANGUAGE = 'en';
4
- const TRANSLATIONS = {
5
- en: {
6
- error: 'Error',
7
- },
8
- ro: {
9
- error: 'Eroare',
10
- },
11
- fr: {
12
- error: 'Error',
13
- },
14
- ar: {
15
- error: 'خطأ',
16
- },
17
- hr: {
18
- error: 'Greška',
19
- },
20
- 'pt-br': {
21
- error: 'Erro'
22
- },
23
- 'es-mx': {
24
- error: 'Error'
25
- }
26
- };
27
- const translate = (key, customLang) => {
28
- const lang = customLang;
29
- return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
30
- };
31
-
32
- const getDevice = () => {
33
- let userAgent = window.navigator.userAgent;
34
- if (userAgent.toLowerCase().match(/android/i)) {
35
- return 'Android';
36
- }
37
- if (userAgent.toLowerCase().match(/iphone/i)) {
38
- return 'iPhone';
39
- }
40
- if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
41
- return 'iPad';
42
- }
43
- return 'PC';
44
- };
45
- function checkCustomDeviceWidth() {
46
- const width = screen.availWidth;
47
- if (width < 600) {
48
- return 'mobile';
49
- }
50
- else if (width >= 600 && width < 1100) {
51
- return 'tablet';
52
- }
53
- }
54
- function getDeviceCustom() {
55
- const userAgent = navigator.userAgent.toLowerCase();
56
- let source = '';
57
- source = (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) ? checkCustomDeviceWidth() : 'desktop';
58
- return source;
59
- }
60
- const getDevicePlatform = () => {
61
- const device = getDevice();
62
- if (device) {
63
- if (device === 'PC') {
64
- return 'dk';
65
- }
66
- else if (device === 'iPad' || device === 'iPhone') {
67
- return 'mtWeb';
68
- }
69
- else {
70
- return 'mtWeb';
71
- }
72
- }
73
- };
74
-
75
- const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.DetailsContainer {\n background-color: #07072A;\n color: #fff;\n display: flex;\n flex-direction: column;\n}\n.DetailsContainer .BlogBanner div {\n height: 400px;\n}\n.DetailsContainer .DetailsHeadWrapper {\n position: relative;\n}\n.DetailsContainer .DetailsBodyWrapper {\n padding: 30px;\n}\n.DetailsContainer .BlogDate {\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n position: absolute;\n bottom: 0;\n left: 30px;\n}\n.DetailsContainer .BlogTitle {\n font-size: 24px;\n}\n.DetailsContainer .BlogContent {\n font-size: 14px;\n}\n.DetailsContainer .BlogContent p:last-child {\n margin-bottom: 0;\n}\n\n@container (max-width: 475px) {\n .DetailsContainer {\n font-size: 12px;\n }\n}";
76
-
77
- const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
78
- constructor() {
79
- super();
80
- this.__registerHost();
81
- this.__attachShadow();
82
- /**
83
- * Language of the widget
84
- */
85
- this.language = 'en';
86
- /**
87
- * User roles
88
- */
89
- this.userRoles = 'everyone';
90
- /**
91
- * CMS Endpoint stage
92
- */
93
- this.cmsEnv = 'stage';
94
- /**
95
- * Client custom styling via string
96
- */
97
- this.clientStyling = '';
98
- /**
99
- * Client custom styling via url
100
- */
101
- this.clientStylingUrl = '';
102
- /**
103
- * Property used to display the publishing date
104
- */
105
- this.showPublishingDate = true;
106
- /**
107
- * Property used to display the image
108
- */
109
- this.showImage = true;
110
- /**
111
- * Property used to display the image
112
- */
113
- this.showTitle = true;
114
- /**
115
- * Property used to display the description
116
- */
117
- this.showContent = true;
118
- /**
119
- * Intl date format
120
- */
121
- this.intlDateTimeFormat = '';
122
- this.hasErrors = false;
123
- this.limitStylingAppends = false;
124
- this.isLoading = true;
125
- this.bannerMatrixReady = false;
126
- this.device = '';
127
- this.setClientStyling = () => {
128
- let sheet = document.createElement('style');
129
- sheet.innerHTML = this.clientStyling;
130
- this.stylingContainer.prepend(sheet);
131
- };
132
- this.setClientStylingURL = () => {
133
- let url = new URL(this.clientStylingUrl);
134
- let cssFile = document.createElement('style');
135
- fetch(url.href)
136
- .then((res) => res.text())
137
- .then((data) => {
138
- cssFile.innerHTML = data;
139
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
140
- })
141
- .catch((err) => {
142
- console.log('Error ', err);
143
- });
144
- };
145
- this.renderContentConditionally = (content) => {
146
- const hasBanner = (content === null || content === void 0 ? void 0 : content.indexOf('<bannermatrix-banner')) !== -1;
147
- if (!hasBanner) {
148
- return h("div", { class: "BlogContent", innerHTML: content });
149
- }
150
- if (this.bannerMatrixReady) {
151
- return h("div", { class: "BlogContent", innerHTML: content });
152
- }
153
- return null;
154
- };
155
- this.setImage = (image) => {
156
- let source = '';
157
- switch (this.device) {
158
- case 'mobile':
159
- source = image.sources[0].pictureSource;
160
- break;
161
- case 'tablet':
162
- source = image.sources[1].pictureSource;
163
- break;
164
- case 'desktop':
165
- source = image.sources[2].pictureSource;
166
- break;
167
- }
168
- return source;
169
- };
170
- }
171
- // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
172
- handleBannerReady() {
173
- this.bannerMatrixReady = true;
174
- }
175
- watchEndpoint(newValue, oldValue) {
176
- if (newValue && newValue != oldValue && this.cmsEndpoint && this.language && (this.postCustomPath || this.postSlug || this.postId)) {
177
- this.getBlogArticleDetails();
178
- }
179
- }
180
- handleStylingChange(newValue, oldValue) {
181
- if (newValue !== oldValue)
182
- this.setClientStyling();
183
- }
184
- handleStylingUrlChange(newValue, oldValue) {
185
- if (newValue !== oldValue)
186
- this.setClientStylingURL();
187
- }
188
- connectedCallback() {
189
- if (this.cmsEndpoint && this.language && (this.postCustomPath || this.postSlug || this.postId)) {
190
- this.getBlogArticleDetails();
191
- }
192
- }
193
- getBlogArticleDetails() {
194
- if (!this.postId && !this.postSlug && !this.postCustomPath) {
195
- this.hasErrors = true;
196
- throw new Error('postId, postSlug or postCustomPath parameter has to be provided!');
197
- }
198
- this.isLoading = true;
199
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts${this.postCustomPath ? '' : '/' + this.postSlug || '/' + this.postId}`);
200
- url.searchParams.append('env', this.cmsEnv);
201
- url.searchParams.append('userRoles', this.userRoles);
202
- url.searchParams.append('device', getDevicePlatform());
203
- if (this.postCustomPath) {
204
- url.searchParams.append('customURL', this.postCustomPath);
205
- }
206
- fetch(url.href)
207
- .then((res) => {
208
- if (res.status >= 300) {
209
- this.hasErrors = true;
210
- throw new Error('There was an error while fetching the data');
211
- }
212
- return res.json();
213
- })
214
- .then((blogContent) => {
215
- if (blogContent.count >= 1 && this.postCustomPath) {
216
- let firstBlogPublishDate = new Date(blogContent.items[0].publishingDate);
217
- let indexOfLatestPublished = 0;
218
- for (let i = 1; i < blogContent.items.length; i++) {
219
- const blogDate = new Date(blogContent.items[i].publishingDate);
220
- if (firstBlogPublishDate.getTime() < blogDate.getTime()) {
221
- firstBlogPublishDate = blogDate;
222
- indexOfLatestPublished = i;
223
- }
224
- }
225
- this.blogData = blogContent.items[indexOfLatestPublished];
226
- }
227
- else {
228
- this.blogData = blogContent;
229
- }
230
- this.isLoading = false;
231
- })
232
- .catch((err) => {
233
- this.hasErrors = true;
234
- console.log('Error', err);
235
- })
236
- .finally(() => this.isLoading = false);
237
- }
238
- componentDidRender() {
239
- // start custom styling area
240
- if (!this.limitStylingAppends && this.stylingContainer) {
241
- if (this.clientStyling)
242
- this.setClientStyling();
243
- if (this.clientStylingUrl)
244
- this.setClientStylingURL();
245
- this.limitStylingAppends = true;
246
- }
247
- // end custom styling area
248
- }
249
- componentDidLoad() {
250
- this.detectAndAlertDeviceType();
251
- }
252
- detectAndAlertDeviceType() {
253
- this.device = getDeviceCustom();
254
- }
255
- formatDate(dateString) {
256
- return new Intl.DateTimeFormat(this.intlDateTimeFormat || 'en-GB').format(new Date(dateString));
257
- }
258
- render() {
259
- var _a, _b, _c, _d, _e;
260
- if (this.hasErrors) {
261
- return (h("div", { class: "BlogArticleDetails" }, h("div", { class: "Title" }, translate('error', this.language))));
262
- }
263
- if (!this.isLoading) {
264
- return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "DetailsContainer" }, h("div", { class: "DetailsHeadWrapper" }, this.showPublishingDate && this.blogData.publishingDate &&
265
- h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("div", { style: { background: `url(${this.setImage(this.blogData.image)}) no-repeat center center / cover` } })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image")))))), h("div", { class: "DetailsBodyWrapper" }, this.showTitle &&
266
- h("div", { class: "BlogTitle" }, (_d = this.blogData) === null || _d === void 0 ? void 0 : _d.title), this.showContent && this.renderContentConditionally((_e = this.blogData) === null || _e === void 0 ? void 0 : _e.content)))));
267
- }
268
- }
269
- static get watchers() { return {
270
- "postId": ["watchEndpoint"],
271
- "postSlug": ["watchEndpoint"],
272
- "postCustomPath": ["watchEndpoint"],
273
- "cmsEndpoint": ["watchEndpoint"],
274
- "language": ["watchEndpoint"],
275
- "clientStyling": ["handleStylingChange"],
276
- "clientStylingUrl": ["handleStylingUrlChange"]
277
- }; }
278
- static get style() { return blogArticleDetailsCss; }
279
- }, [1, "blog-article-details", {
280
- "cmsEndpoint": [513, "cms-endpoint"],
281
- "language": [513],
282
- "userRoles": [513, "user-roles"],
283
- "cmsEnv": [513, "cms-env"],
284
- "clientStyling": [513, "client-styling"],
285
- "clientStylingUrl": [513, "client-styling-url"],
286
- "showPublishingDate": [516, "show-publishing-date"],
287
- "showImage": [516, "show-image"],
288
- "showTitle": [516, "show-title"],
289
- "showContent": [516, "show-content"],
290
- "postId": [514, "post-id"],
291
- "postSlug": [513, "post-slug"],
292
- "postCustomPath": [513, "post-custom-path"],
293
- "intlDateTimeFormat": [1, "intl-date-time-format"],
294
- "hasErrors": [32],
295
- "limitStylingAppends": [32],
296
- "isLoading": [32],
297
- "bannerMatrixReady": [32],
298
- "device": [32]
299
- }, [[8, "BannerMatrixReady", "handleBannerReady"]]]);
300
- function defineCustomElement$1() {
301
- if (typeof customElements === "undefined") {
302
- return;
303
- }
304
- const components = ["blog-article-details"];
305
- components.forEach(tagName => { switch (tagName) {
306
- case "blog-article-details":
307
- if (!customElements.get(tagName)) {
308
- customElements.define(tagName, BlogArticleDetails$1);
309
- }
310
- break;
311
- } });
312
- }
313
-
314
- const BlogArticleDetails = BlogArticleDetails$1;
315
- const defineCustomElement = defineCustomElement$1;
316
-
317
- export { BlogArticleDetails, defineCustomElement };
@@ -1,26 +0,0 @@
1
- /* BlogArticleDetails custom elements */
2
-
3
- import type { Components, JSX } from "../types/components";
4
-
5
- /**
6
- * Used to manually set the base path where assets can be found.
7
- * If the script is used as "module", it's recommended to use "import.meta.url",
8
- * such as "setAssetPath(import.meta.url)". Other options include
9
- * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
10
- * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
11
- * But do note that this configuration depends on how your script is bundled, or lack of
12
- * bundling, and where your assets can be loaded from. Additionally custom bundling
13
- * will have to ensure the static assets are copied to its build directory.
14
- */
15
- export declare const setAssetPath: (path: string) => void;
16
-
17
- export interface SetPlatformOptions {
18
- raf?: (c: FrameRequestCallback) => number;
19
- ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
20
- rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
21
- }
22
- export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
23
-
24
- export type { Components, JSX };
25
-
26
- export * from '../types';
@@ -1 +0,0 @@
1
- export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';