@everymatrix/general-news-notification 1.45.7

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 (47) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/general-news-notification-57b70677.js +206 -0
  3. package/dist/cjs/general-news-notification.cjs.entry.js +10 -0
  4. package/dist/cjs/general-news-notification.cjs.js +25 -0
  5. package/dist/cjs/index-95e31eec.js +1207 -0
  6. package/dist/cjs/index.cjs.js +10 -0
  7. package/dist/cjs/loader.cjs.js +15 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/general-news-notification/general-news-notification.css +110 -0
  10. package/dist/collection/components/general-news-notification/general-news-notification.js +330 -0
  11. package/dist/collection/components/general-news-notification/index.js +1 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +34 -0
  14. package/dist/collection/utils/utils.js +30 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/general-news-notification-c65ccc64.js +204 -0
  17. package/dist/esm/general-news-notification.entry.js +2 -0
  18. package/dist/esm/general-news-notification.js +20 -0
  19. package/dist/esm/index-cffad24d.js +1181 -0
  20. package/dist/esm/index.js +2 -0
  21. package/dist/esm/loader.js +11 -0
  22. package/dist/general-news-notification/general-news-notification.esm.js +1 -0
  23. package/dist/general-news-notification/index.esm.js +1 -0
  24. package/dist/general-news-notification/p-8b27880f.js +2 -0
  25. package/dist/general-news-notification/p-cfdc487f.js +1 -0
  26. package/dist/general-news-notification/p-e06cf24f.entry.js +1 -0
  27. package/dist/general-news-notification/p-e1255160.js +1 -0
  28. package/dist/index.cjs.js +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/stencil.config.dev.js +14 -0
  31. package/dist/stencil.config.js +17 -0
  32. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-news-notification/.stencil/packages/stencil/general-news-notification/stencil.config.d.ts +2 -0
  33. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-news-notification/.stencil/packages/stencil/general-news-notification/stencil.config.dev.d.ts +2 -0
  34. package/dist/types/components/general-news-notification/general-news-notification.d.ts +56 -0
  35. package/dist/types/components/general-news-notification/index.d.ts +1 -0
  36. package/dist/types/components.d.ts +109 -0
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  39. package/dist/types/utils/locale.utils.d.ts +2 -0
  40. package/dist/types/utils/utils.d.ts +3 -0
  41. package/loader/cdn.js +1 -0
  42. package/loader/index.cjs.js +1 -0
  43. package/loader/index.d.ts +24 -0
  44. package/loader/index.es2017.js +1 -0
  45. package/loader/index.js +2 -0
  46. package/loader/package.json +11 -0
  47. package/package.json +26 -0
@@ -0,0 +1,204 @@
1
+ import { r as registerInstance, h } from './index-cffad24d.js';
2
+
3
+ const getDevice = () => {
4
+ let userAgent = window.navigator.userAgent;
5
+ if (userAgent.toLowerCase().match(/android/i)) {
6
+ return 'Android';
7
+ }
8
+ if (userAgent.toLowerCase().match(/iphone/i)) {
9
+ return 'iPhone';
10
+ }
11
+ if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
12
+ return 'iPad';
13
+ }
14
+ return 'PC';
15
+ };
16
+ const getDevicePlatform = () => {
17
+ const device = getDevice();
18
+ if (device) {
19
+ if (device === 'PC') {
20
+ return 'dk';
21
+ }
22
+ else if (device === 'iPad' || device === 'iPhone') {
23
+ return 'ios';
24
+ }
25
+ else {
26
+ return 'mtWeb';
27
+ }
28
+ }
29
+ };
30
+
31
+ const DEFAULT_LANGUAGE = 'en';
32
+ const TRANSLATIONS = {
33
+ en: {
34
+ loading: 'Is Loading ...',
35
+ }
36
+ };
37
+ const getTranslations = (url) => {
38
+ return new Promise((resolve) => {
39
+ fetch(url)
40
+ .then((res) => res.json())
41
+ .then((data) => {
42
+ Object.keys(data).forEach((lang) => {
43
+ if (!TRANSLATIONS[lang]) {
44
+ TRANSLATIONS[lang] = {};
45
+ }
46
+ for (let key in data[lang]) {
47
+ TRANSLATIONS[lang][key] = data[lang][key];
48
+ }
49
+ });
50
+ resolve(true);
51
+ });
52
+ });
53
+ };
54
+ const translate = (key, customLang, values) => {
55
+ const lang = customLang;
56
+ let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
57
+ if (values !== undefined) {
58
+ for (const [key, value] of Object.entries(values.values)) {
59
+ const regex = new RegExp(`{${key}}`, 'g');
60
+ translation = translation.replace(regex, value);
61
+ }
62
+ }
63
+ return translation;
64
+ };
65
+
66
+ const generalNewsNotificationCss = ":host{display:block}.NotificationWrapper{background:var(--emw-header-color-background, var(--emw-color-background, #000000));color:var(--emfe-w-color-white, #FFFFFF);position:sticky;width:100%;text-align:center;overflow:hidden;z-index:298;display:flex;justify-content:flex-end;align-items:center;border-bottom:6px solid var(--emfe-w-color-primary, #22B04E);max-height:40px}.SlidingBar{transition:all 0.3s ease-in-out;width:100%}.Message{will-change:transform;margin:0 auto;padding:10px;width:90%}.ScrollLeft .Message{white-space:nowrap;animation:scroll-left 10s linear infinite;width:100%}.ScrollRight .Message{white-space:nowrap;animation:scroll-right 10s linear infinite;width:100%}.VisibleButtons .Message{display:flex}@keyframes scroll-left{from{transform:translateX(100%)}to{transform:translateX(-100%)}}@keyframes scroll-right{from{transform:translateX(-100%)}to{transform:translateX(100%)}}.SlidingBar:hover .Message{animation-play-state:paused}.CloseButton{padding-left:10px;background-color:var(--emw-header-color-background, var(--emw-color-background, #000000));display:flex;z-index:299;gap:10px}.ToggleButton{position:absolute;left:0}.ToggleButton .TriangleActive,.ToggleButton .TriangleInactive{display:block;transition:all 0.2s}.ToggleButton .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px);fill:var(--emw--color-primary, #52d004);margin-top:8px}.ToggleButton svg{fill:var(--emw-header-color-background, var(--emw-color-background, #000000));width:16px;transform:rotate(180deg)}.CloseButton{right:10px}button{background-color:var(--emfe-w-color-primary, #22B04E);color:var(--emw-header-color-background, var(--emw-color-background, #000000));border:none;width:40px;height:40px;cursor:pointer}.NotificationWrapper.Minimized{visibility:hidden}";
67
+ const GeneralNewsNotificationStyle0 = generalNewsNotificationCss;
68
+
69
+ const GeneralNewsNotification = class {
70
+ constructor(hostRef) {
71
+ registerInstance(this, hostRef);
72
+ this.componentDidLoad = () => {
73
+ // start custom styling area
74
+ if (this.stylingContainer) {
75
+ if (this.clientStyling)
76
+ this.setClientStyling();
77
+ if (this.clientStylingUrl)
78
+ this.setClientStylingURL();
79
+ }
80
+ // end custom styling area
81
+ };
82
+ this.connectedCallback = () => {
83
+ if (this.cmsEndpoint && this.language) {
84
+ this.getNotificationMessage();
85
+ }
86
+ };
87
+ this.setClientStyling = () => {
88
+ let sheet = document.createElement('style');
89
+ sheet.innerHTML = this.clientStyling;
90
+ this.stylingContainer.prepend(sheet);
91
+ };
92
+ this.setClientStylingURL = () => {
93
+ let url = new URL(this.clientStylingUrl);
94
+ let cssFile = document.createElement('style');
95
+ fetch(url.href)
96
+ .then((res) => res.text())
97
+ .then((data) => {
98
+ cssFile.innerHTML = data;
99
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
100
+ })
101
+ .catch((err) => {
102
+ console.log('error ', err);
103
+ });
104
+ };
105
+ this.getNotificationMessage = () => {
106
+ this.isLoading = true;
107
+ try {
108
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/header-notification`);
109
+ url.searchParams.append('device', getDevicePlatform());
110
+ url.searchParams.append('platform', getDevicePlatform());
111
+ fetch(url.href)
112
+ .then((res) => {
113
+ if (res.status === 200) {
114
+ return res.json();
115
+ }
116
+ else {
117
+ throw new Error("HTTP status " + res.status);
118
+ }
119
+ })
120
+ .then((data) => {
121
+ this.message = data.message;
122
+ })
123
+ .catch((err) => {
124
+ // Handle any errors
125
+ console.error(err);
126
+ })
127
+ .finally(() => this.isLoading = false);
128
+ }
129
+ catch (error) {
130
+ console.error('Error fetching message:', error);
131
+ }
132
+ };
133
+ this.toggleMinimize = () => {
134
+ this.isMinimized = !this.isMinimized;
135
+ };
136
+ this.closeNotification = () => {
137
+ this.isClosed = true;
138
+ };
139
+ this.cmsEndpoint = undefined;
140
+ this.language = undefined;
141
+ this.animationType = 'static';
142
+ this.speed = 30;
143
+ this.canMinimize = false;
144
+ this.canClose = false;
145
+ this.clientStyling = '';
146
+ this.clientStylingUrl = '';
147
+ this.translationUrl = '';
148
+ this.message = undefined;
149
+ this.isMinimized = false;
150
+ this.isClosed = false;
151
+ this.isLoading = true;
152
+ }
153
+ watchEndpoint(newValue, oldValue) {
154
+ if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
155
+ this.getNotificationMessage();
156
+ }
157
+ }
158
+ handleStylingChange(newValue, oldValue) {
159
+ if (newValue !== oldValue)
160
+ this.setClientStyling();
161
+ }
162
+ handleStylingUrlChange(newValue, oldValue) {
163
+ if (newValue !== oldValue)
164
+ this.setClientStylingURL();
165
+ }
166
+ handleNewTranslations() {
167
+ this.isLoading = true;
168
+ getTranslations(this.translationUrl).then(() => {
169
+ this.isLoading = false;
170
+ });
171
+ }
172
+ async componentWillLoad() {
173
+ if (this.translationUrl.length > 2) {
174
+ await getTranslations(this.translationUrl);
175
+ }
176
+ }
177
+ render() {
178
+ if (this.isClosed)
179
+ return null;
180
+ const animationDuration = `${this.speed}s`;
181
+ return (h("div", { ref: el => this.stylingContainer = el }, this.canMinimize && (h("button", { class: "ToggleButton", onClick: this.toggleMinimize }, h("span", { class: this.isMinimized ? 'TriangleActive' : 'TriangleInactive' }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" }, h("path", { id: "arrow", d: "M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z", transform: "translate(-274.511 -441.088)" }))))), h("div", { class: {
182
+ 'NotificationWrapper': true,
183
+ 'Minimized': this.isMinimized
184
+ } }, h("div", { class: {
185
+ 'SlidingBar': true,
186
+ 'Minimized': this.isMinimized,
187
+ 'ScrollLeft': this.animationType === 'scroll-left',
188
+ 'ScrollRight': this.animationType === 'scroll-right',
189
+ 'VisibleButtons': this.canMinimize || this.canClose === true
190
+ } }, h("div", { class: "Message", style: {
191
+ animationDuration: animationDuration,
192
+ } }, this.isLoading ? translate('loading', this.language) : this.message)), this.canClose && (h("div", { class: "CloseButton" }, h("button", { onClick: this.closeNotification }, "X"))))));
193
+ }
194
+ static get watchers() { return {
195
+ "cmsEndpoint": ["watchEndpoint"],
196
+ "language": ["watchEndpoint"],
197
+ "clientStyling": ["handleStylingChange"],
198
+ "clientStylingUrl": ["handleStylingUrlChange"],
199
+ "translationUrl": ["handleNewTranslations"]
200
+ }; }
201
+ };
202
+ GeneralNewsNotification.style = GeneralNewsNotificationStyle0;
203
+
204
+ export { GeneralNewsNotification as G };
@@ -0,0 +1,2 @@
1
+ export { G as general_news_notification } from './general-news-notification-c65ccc64.js';
2
+ import './index-cffad24d.js';
@@ -0,0 +1,20 @@
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-cffad24d.js';
2
+ export { s as setNonce } from './index-cffad24d.js';
3
+ import { g as globalScripts } from './app-globals-0f993ce5.js';
4
+
5
+ /*
6
+ Stencil Client Patch Browser v4.20.0 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ var patchBrowser = () => {
9
+ const importMeta = import.meta.url;
10
+ const opts = {};
11
+ if (importMeta !== "") {
12
+ opts.resourcesUrl = new URL(".", importMeta).href;
13
+ }
14
+ return promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(async (options) => {
18
+ await globalScripts();
19
+ return bootstrapLazy([["general-news-notification",[[1,"general-news-notification",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"animationType":[1,"animation-type"],"speed":[2],"canMinimize":[4,"can-minimize"],"canClose":[4,"can-close"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"translationUrl":[1,"translation-url"],"message":[32],"isMinimized":[32],"isClosed":[32],"isLoading":[32]},null,{"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"clientStyling":["handleStylingChange"],"clientStylingUrl":["handleStylingUrlChange"],"translationUrl":["handleNewTranslations"]}]]]], options);
20
+ });