@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.
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/general-news-notification-57b70677.js +206 -0
- package/dist/cjs/general-news-notification.cjs.entry.js +10 -0
- package/dist/cjs/general-news-notification.cjs.js +25 -0
- package/dist/cjs/index-95e31eec.js +1207 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/general-news-notification/general-news-notification.css +110 -0
- package/dist/collection/components/general-news-notification/general-news-notification.js +330 -0
- package/dist/collection/components/general-news-notification/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +34 -0
- package/dist/collection/utils/utils.js +30 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/general-news-notification-c65ccc64.js +204 -0
- package/dist/esm/general-news-notification.entry.js +2 -0
- package/dist/esm/general-news-notification.js +20 -0
- package/dist/esm/index-cffad24d.js +1181 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/general-news-notification/general-news-notification.esm.js +1 -0
- package/dist/general-news-notification/index.esm.js +1 -0
- package/dist/general-news-notification/p-8b27880f.js +2 -0
- package/dist/general-news-notification/p-cfdc487f.js +1 -0
- package/dist/general-news-notification/p-e06cf24f.entry.js +1 -0
- package/dist/general-news-notification/p-e1255160.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +14 -0
- package/dist/stencil.config.js +17 -0
- 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
- 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
- package/dist/types/components/general-news-notification/general-news-notification.d.ts +56 -0
- package/dist/types/components/general-news-notification/index.d.ts +1 -0
- package/dist/types/components.d.ts +109 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +3 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +26 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-95e31eec.js');
|
|
4
|
+
|
|
5
|
+
const getDevice = () => {
|
|
6
|
+
let userAgent = window.navigator.userAgent;
|
|
7
|
+
if (userAgent.toLowerCase().match(/android/i)) {
|
|
8
|
+
return 'Android';
|
|
9
|
+
}
|
|
10
|
+
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
11
|
+
return 'iPhone';
|
|
12
|
+
}
|
|
13
|
+
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
14
|
+
return 'iPad';
|
|
15
|
+
}
|
|
16
|
+
return 'PC';
|
|
17
|
+
};
|
|
18
|
+
const getDevicePlatform = () => {
|
|
19
|
+
const device = getDevice();
|
|
20
|
+
if (device) {
|
|
21
|
+
if (device === 'PC') {
|
|
22
|
+
return 'dk';
|
|
23
|
+
}
|
|
24
|
+
else if (device === 'iPad' || device === 'iPhone') {
|
|
25
|
+
return 'ios';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return 'mtWeb';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
34
|
+
const TRANSLATIONS = {
|
|
35
|
+
en: {
|
|
36
|
+
loading: 'Is Loading ...',
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const getTranslations = (url) => {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
fetch(url)
|
|
42
|
+
.then((res) => res.json())
|
|
43
|
+
.then((data) => {
|
|
44
|
+
Object.keys(data).forEach((lang) => {
|
|
45
|
+
if (!TRANSLATIONS[lang]) {
|
|
46
|
+
TRANSLATIONS[lang] = {};
|
|
47
|
+
}
|
|
48
|
+
for (let key in data[lang]) {
|
|
49
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
resolve(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const translate = (key, customLang, values) => {
|
|
57
|
+
const lang = customLang;
|
|
58
|
+
let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
59
|
+
if (values !== undefined) {
|
|
60
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
61
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
62
|
+
translation = translation.replace(regex, value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return translation;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
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}";
|
|
69
|
+
const GeneralNewsNotificationStyle0 = generalNewsNotificationCss;
|
|
70
|
+
|
|
71
|
+
const GeneralNewsNotification = class {
|
|
72
|
+
constructor(hostRef) {
|
|
73
|
+
index.registerInstance(this, hostRef);
|
|
74
|
+
this.componentDidLoad = () => {
|
|
75
|
+
// start custom styling area
|
|
76
|
+
if (this.stylingContainer) {
|
|
77
|
+
if (this.clientStyling)
|
|
78
|
+
this.setClientStyling();
|
|
79
|
+
if (this.clientStylingUrl)
|
|
80
|
+
this.setClientStylingURL();
|
|
81
|
+
}
|
|
82
|
+
// end custom styling area
|
|
83
|
+
};
|
|
84
|
+
this.connectedCallback = () => {
|
|
85
|
+
if (this.cmsEndpoint && this.language) {
|
|
86
|
+
this.getNotificationMessage();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this.setClientStyling = () => {
|
|
90
|
+
let sheet = document.createElement('style');
|
|
91
|
+
sheet.innerHTML = this.clientStyling;
|
|
92
|
+
this.stylingContainer.prepend(sheet);
|
|
93
|
+
};
|
|
94
|
+
this.setClientStylingURL = () => {
|
|
95
|
+
let url = new URL(this.clientStylingUrl);
|
|
96
|
+
let cssFile = document.createElement('style');
|
|
97
|
+
fetch(url.href)
|
|
98
|
+
.then((res) => res.text())
|
|
99
|
+
.then((data) => {
|
|
100
|
+
cssFile.innerHTML = data;
|
|
101
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
102
|
+
})
|
|
103
|
+
.catch((err) => {
|
|
104
|
+
console.log('error ', err);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
this.getNotificationMessage = () => {
|
|
108
|
+
this.isLoading = true;
|
|
109
|
+
try {
|
|
110
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/header-notification`);
|
|
111
|
+
url.searchParams.append('device', getDevicePlatform());
|
|
112
|
+
url.searchParams.append('platform', getDevicePlatform());
|
|
113
|
+
fetch(url.href)
|
|
114
|
+
.then((res) => {
|
|
115
|
+
if (res.status === 200) {
|
|
116
|
+
return res.json();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error("HTTP status " + res.status);
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
.then((data) => {
|
|
123
|
+
this.message = data.message;
|
|
124
|
+
})
|
|
125
|
+
.catch((err) => {
|
|
126
|
+
// Handle any errors
|
|
127
|
+
console.error(err);
|
|
128
|
+
})
|
|
129
|
+
.finally(() => this.isLoading = false);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error('Error fetching message:', error);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
this.toggleMinimize = () => {
|
|
136
|
+
this.isMinimized = !this.isMinimized;
|
|
137
|
+
};
|
|
138
|
+
this.closeNotification = () => {
|
|
139
|
+
this.isClosed = true;
|
|
140
|
+
};
|
|
141
|
+
this.cmsEndpoint = undefined;
|
|
142
|
+
this.language = undefined;
|
|
143
|
+
this.animationType = 'static';
|
|
144
|
+
this.speed = 30;
|
|
145
|
+
this.canMinimize = false;
|
|
146
|
+
this.canClose = false;
|
|
147
|
+
this.clientStyling = '';
|
|
148
|
+
this.clientStylingUrl = '';
|
|
149
|
+
this.translationUrl = '';
|
|
150
|
+
this.message = undefined;
|
|
151
|
+
this.isMinimized = false;
|
|
152
|
+
this.isClosed = false;
|
|
153
|
+
this.isLoading = true;
|
|
154
|
+
}
|
|
155
|
+
watchEndpoint(newValue, oldValue) {
|
|
156
|
+
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
157
|
+
this.getNotificationMessage();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
handleStylingChange(newValue, oldValue) {
|
|
161
|
+
if (newValue !== oldValue)
|
|
162
|
+
this.setClientStyling();
|
|
163
|
+
}
|
|
164
|
+
handleStylingUrlChange(newValue, oldValue) {
|
|
165
|
+
if (newValue !== oldValue)
|
|
166
|
+
this.setClientStylingURL();
|
|
167
|
+
}
|
|
168
|
+
handleNewTranslations() {
|
|
169
|
+
this.isLoading = true;
|
|
170
|
+
getTranslations(this.translationUrl).then(() => {
|
|
171
|
+
this.isLoading = false;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async componentWillLoad() {
|
|
175
|
+
if (this.translationUrl.length > 2) {
|
|
176
|
+
await getTranslations(this.translationUrl);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
render() {
|
|
180
|
+
if (this.isClosed)
|
|
181
|
+
return null;
|
|
182
|
+
const animationDuration = `${this.speed}s`;
|
|
183
|
+
return (index.h("div", { ref: el => this.stylingContainer = el }, this.canMinimize && (index.h("button", { class: "ToggleButton", onClick: this.toggleMinimize }, index.h("span", { class: this.isMinimized ? 'TriangleActive' : 'TriangleInactive' }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" }, index.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)" }))))), index.h("div", { class: {
|
|
184
|
+
'NotificationWrapper': true,
|
|
185
|
+
'Minimized': this.isMinimized
|
|
186
|
+
} }, index.h("div", { class: {
|
|
187
|
+
'SlidingBar': true,
|
|
188
|
+
'Minimized': this.isMinimized,
|
|
189
|
+
'ScrollLeft': this.animationType === 'scroll-left',
|
|
190
|
+
'ScrollRight': this.animationType === 'scroll-right',
|
|
191
|
+
'VisibleButtons': this.canMinimize || this.canClose === true
|
|
192
|
+
} }, index.h("div", { class: "Message", style: {
|
|
193
|
+
animationDuration: animationDuration,
|
|
194
|
+
} }, this.isLoading ? translate('loading', this.language) : this.message)), this.canClose && (index.h("div", { class: "CloseButton" }, index.h("button", { onClick: this.closeNotification }, "X"))))));
|
|
195
|
+
}
|
|
196
|
+
static get watchers() { return {
|
|
197
|
+
"cmsEndpoint": ["watchEndpoint"],
|
|
198
|
+
"language": ["watchEndpoint"],
|
|
199
|
+
"clientStyling": ["handleStylingChange"],
|
|
200
|
+
"clientStylingUrl": ["handleStylingUrlChange"],
|
|
201
|
+
"translationUrl": ["handleNewTranslations"]
|
|
202
|
+
}; }
|
|
203
|
+
};
|
|
204
|
+
GeneralNewsNotification.style = GeneralNewsNotificationStyle0;
|
|
205
|
+
|
|
206
|
+
exports.GeneralNewsNotification = GeneralNewsNotification;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const generalNewsNotification = require('./general-news-notification-57b70677.js');
|
|
6
|
+
require('./index-95e31eec.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.general_news_notification = generalNewsNotification.GeneralNewsNotification;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-95e31eec.js');
|
|
6
|
+
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
Stencil Client Patch Browser v4.20.0 | MIT Licensed | https://stenciljs.com
|
|
10
|
+
*/
|
|
11
|
+
var patchBrowser = () => {
|
|
12
|
+
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('general-news-notification.cjs.js', document.baseURI).href));
|
|
13
|
+
const opts = {};
|
|
14
|
+
if (importMeta !== "") {
|
|
15
|
+
opts.resourcesUrl = new URL(".", importMeta).href;
|
|
16
|
+
}
|
|
17
|
+
return index.promiseResolve(opts);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
patchBrowser().then(async (options) => {
|
|
21
|
+
await appGlobals.globalScripts();
|
|
22
|
+
return index.bootstrapLazy([["general-news-notification.cjs",[[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);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.setNonce = index.setNonce;
|