@everymatrix/gamification-dropdown 1.44.0 → 1.54.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.
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/gamification-dropdown-0fd9c5b8.js +186 -0
- package/dist/cjs/gamification-dropdown.cjs.js +17 -11
- package/dist/cjs/gamification-dropdown_4.cjs.entry.js +408 -528
- package/dist/cjs/index-c535ed72.js +1796 -0
- package/dist/cjs/index.cjs.js +8 -0
- package/dist/cjs/loader.cjs.js +7 -13
- package/dist/cjs/{player-elevate-card-items-1cb6488c.js → player-elevate-card-items-42538012.js} +195 -180
- package/dist/cjs/player-elevate-card.cjs.entry.js +71 -70
- package/dist/cjs/player-elevate-pointcard.cjs.entry.js +79 -78
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +272 -257
- package/dist/collection/components/gamification-dropdown/index.js +1 -0
- package/dist/collection/index.js +1 -1
- package/dist/collection/utils/locale.utils.js +34 -34
- package/dist/collection/utils/utils.js +1 -1
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/gamification-dropdown-ae7b7c69.js +184 -0
- package/dist/esm/gamification-dropdown.js +14 -11
- package/dist/esm/gamification-dropdown_4.entry.js +408 -528
- package/dist/esm/index-ea7720e4.js +1766 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/loader.js +7 -13
- package/dist/esm/{player-elevate-card-items-5bf07fe3.js → player-elevate-card-items-9d490a3b.js} +196 -180
- package/dist/esm/player-elevate-card.entry.js +71 -70
- package/dist/esm/player-elevate-pointcard.entry.js +79 -78
- package/dist/gamification-dropdown/gamification-dropdown.esm.js +1 -1
- package/dist/gamification-dropdown/index.esm.js +1 -0
- package/dist/gamification-dropdown/p-10486e5b.entry.js +1 -0
- package/dist/gamification-dropdown/p-21507480.js +1 -0
- package/dist/gamification-dropdown/p-3f7623db.js +2 -0
- package/dist/gamification-dropdown/p-422d11f7.entry.js +1 -0
- package/dist/gamification-dropdown/p-4b1d42b5.entry.js +1 -0
- package/dist/gamification-dropdown/p-c5998a81.js +1 -0
- package/dist/gamification-dropdown/p-e1255160.js +1 -0
- package/dist/stencil.config.dev.js +15 -0
- package/dist/stencil.config.js +14 -19
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/gamification-dropdown/gamification-dropdown.d.ts +41 -41
- package/dist/types/components/gamification-dropdown/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/stencil-public-runtime.d.ts +148 -33
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/loader/package.json +1 -0
- package/package.json +11 -4
- package/dist/cjs/index-4aa14dda.js +0 -1717
- package/dist/components/gamification-dropdown.d.ts +0 -11
- package/dist/components/gamification-dropdown.js +0 -230
- package/dist/components/general-styling-wrapper.js +0 -6
- package/dist/components/general-styling-wrapper2.js +0 -103
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/components/player-elevate-card-data.js +0 -6
- package/dist/components/player-elevate-card-data2.js +0 -635
- package/dist/components/player-elevate-card-items.js +0 -2149
- package/dist/components/player-elevate-card.js +0 -126
- package/dist/components/player-elevate-loyaltycard.js +0 -6
- package/dist/components/player-elevate-loyaltycard2.js +0 -129
- package/dist/components/player-elevate-pointcard.js +0 -135
- package/dist/esm/index-a803f08b.js +0 -1688
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/gamification-dropdown/p-118adbd3.entry.js +0 -1
- package/dist/gamification-dropdown/p-1bea1936.js +0 -1
- package/dist/gamification-dropdown/p-727c8663.js +0 -1
- package/dist/gamification-dropdown/p-bf29bfd4.entry.js +0 -1
- package/dist/gamification-dropdown/p-cdf41413.entry.js +0 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/gamification-dropdown/.stencil/packages/gamification-dropdown/stencil.config.d.ts +0 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-c535ed72.js');
|
|
4
|
+
|
|
5
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
6
|
+
let TRANSLATIONS = {
|
|
7
|
+
en: {
|
|
8
|
+
gamificationNoPoints: "No points"
|
|
9
|
+
},
|
|
10
|
+
de: {
|
|
11
|
+
gamificationNoPoints: "No points"
|
|
12
|
+
},
|
|
13
|
+
ro: {
|
|
14
|
+
gamificationNoPoints: "No points"
|
|
15
|
+
},
|
|
16
|
+
fr: {
|
|
17
|
+
gamificationNoPoints: "No points"
|
|
18
|
+
},
|
|
19
|
+
ar: {
|
|
20
|
+
gamificationNoPoints: "No points"
|
|
21
|
+
},
|
|
22
|
+
hr: {
|
|
23
|
+
gamificationNoPoints: "No points"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getTranslations = (url) => {
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
fetch(url)
|
|
29
|
+
.then((res) => res.json())
|
|
30
|
+
.then((data) => {
|
|
31
|
+
Object.keys(data).forEach((lang) => {
|
|
32
|
+
if (!TRANSLATIONS[lang]) {
|
|
33
|
+
TRANSLATIONS[lang] = {};
|
|
34
|
+
}
|
|
35
|
+
for (let key in data[lang]) {
|
|
36
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
resolve(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const translate = (key, customLang) => {
|
|
44
|
+
const lang = customLang;
|
|
45
|
+
return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const gamificationDropdownCss = ":host{display:block}.GamificationDropdownContainer{position:relative}.GamificationDropdownContainer .GamificationDropdown{position:absolute;left:0;z-index:200;overflow:hidden;cursor:pointer}.GamificationDropdownButton{cursor:pointer;font-size:14px;height:20px;background-color:unset;color:var(--emw--color-typography, #FFFFFF);padding:0;border:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:flex;align-items:center;justify-content:center;line-height:0}.GamificationDropdownButton:hover{color:var(--emw--color-primary, #52d004)}.GamificationDropdownButton:hover svg{fill:var(--emw--color-primary, #52d004)}.GamificationDropdownButton.IsOpen{color:var(--emw--color-primary, #52d004)}.GamificationDropdownButton.IsOpen svg{fill:var(--emw--color-primary, #52d004)}.GamificationDropdownButton .TriangleActive,.GamificationDropdownButton .TriangleInactive{display:block;transition:all 0.2s}.GamificationDropdownButton .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px);fill:var(--emw--color-primary, #52d004);margin-top:4px}.GamificationDropdownButton svg{fill:var(--emw--color-typography, #FFFFFF);margin-left:8px;width:16px}";
|
|
49
|
+
const GamificationDropdownStyle0 = gamificationDropdownCss;
|
|
50
|
+
|
|
51
|
+
const GamificationDropdown = class {
|
|
52
|
+
constructor(hostRef) {
|
|
53
|
+
index.registerInstance(this, hostRef);
|
|
54
|
+
/**
|
|
55
|
+
* Language of the widget
|
|
56
|
+
*/
|
|
57
|
+
this.language = 'en';
|
|
58
|
+
/**
|
|
59
|
+
* Session of the user
|
|
60
|
+
*/
|
|
61
|
+
this.session = '';
|
|
62
|
+
/**
|
|
63
|
+
* Client custom styling via string
|
|
64
|
+
*/
|
|
65
|
+
this.clientStyling = '';
|
|
66
|
+
/**
|
|
67
|
+
* Client custom styling via url
|
|
68
|
+
*/
|
|
69
|
+
this.clientStylingUrl = '';
|
|
70
|
+
/**
|
|
71
|
+
* Translations via URL
|
|
72
|
+
*/
|
|
73
|
+
this.translationUrl = '';
|
|
74
|
+
this.isOpen = false;
|
|
75
|
+
this.isLoading = false;
|
|
76
|
+
this.stylingAppends = false;
|
|
77
|
+
this.setClientStyling = () => {
|
|
78
|
+
let sheet = document.createElement('style');
|
|
79
|
+
sheet.innerHTML = this.clientStyling;
|
|
80
|
+
this.stylingContainer.prepend(sheet);
|
|
81
|
+
};
|
|
82
|
+
this.setClientStylingURL = () => {
|
|
83
|
+
let url = new URL(this.clientStylingUrl);
|
|
84
|
+
let cssFile = document.createElement('style');
|
|
85
|
+
fetch(url.href)
|
|
86
|
+
.then((res) => res.text())
|
|
87
|
+
.then((data) => {
|
|
88
|
+
cssFile.innerHTML = data;
|
|
89
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
90
|
+
})
|
|
91
|
+
.catch((err) => {
|
|
92
|
+
console.log('error ', err);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
this.navigateToGamification = () => {
|
|
96
|
+
window.postMessage({ type: 'NavigateToGamification' }, window.location.href);
|
|
97
|
+
this.isOpen = false;
|
|
98
|
+
};
|
|
99
|
+
this.handleOutsideClick = (event) => {
|
|
100
|
+
const path = event.composedPath();
|
|
101
|
+
if (!path.includes(this.el)) {
|
|
102
|
+
this.isOpen = false;
|
|
103
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
this.handleDropdownClick = (event) => {
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
this.isOpen = !this.isOpen;
|
|
109
|
+
if (this.isOpen) {
|
|
110
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
handleNewTranslations() {
|
|
118
|
+
this.isLoading = true;
|
|
119
|
+
getTranslations(this.translationUrl).then(() => {
|
|
120
|
+
this.isLoading = false;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async componentWillLoad() {
|
|
124
|
+
if (this.translationUrl.length > 2) {
|
|
125
|
+
await getTranslations(this.translationUrl);
|
|
126
|
+
}
|
|
127
|
+
if (this.endpoint && this.language) {
|
|
128
|
+
return this.fetchPointsData();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
componentDidRender() {
|
|
132
|
+
// start custom styling area
|
|
133
|
+
if (!this.stylingAppends && this.stylingContainer) {
|
|
134
|
+
if (this.clientStyling)
|
|
135
|
+
this.setClientStyling();
|
|
136
|
+
if (this.clientStylingUrl)
|
|
137
|
+
this.setClientStylingURL();
|
|
138
|
+
this.stylingAppends = true;
|
|
139
|
+
}
|
|
140
|
+
// end custom styling area
|
|
141
|
+
}
|
|
142
|
+
fetchPointsData() {
|
|
143
|
+
let url = new URL(`${this.endpoint}/v1/elevate/playerInfo`);
|
|
144
|
+
url.searchParams.append('language', this.language);
|
|
145
|
+
const headers = new Headers();
|
|
146
|
+
headers.append('X-SessionId', this.session);
|
|
147
|
+
const options = {
|
|
148
|
+
method: 'GET',
|
|
149
|
+
headers
|
|
150
|
+
};
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
this.isLoading = true;
|
|
153
|
+
fetch(url.href, options)
|
|
154
|
+
.then((res) => res.json())
|
|
155
|
+
.then((data) => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
this.loyaltyPoints = (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.level) === null || _b === void 0 ? void 0 : _b.loyaltyPoints;
|
|
158
|
+
resolve(true);
|
|
159
|
+
}).catch((err) => {
|
|
160
|
+
console.error(err);
|
|
161
|
+
reject(err);
|
|
162
|
+
}).finally(() => {
|
|
163
|
+
this.isLoading = false;
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
render() {
|
|
168
|
+
if (this.isLoading) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
return (index.h("div", { ref: el => this.stylingContainer = el, class: "GamificationDropdownContainer" }, index.h("button", { class: `GamificationDropdownButton ${this.isOpen ? 'IsOpen' : ''}`, type: "button", onClick: (e) => this.handleDropdownClick(e), title: typeof this.loyaltyPoints === 'number'
|
|
173
|
+
? String(this.loyaltyPoints)
|
|
174
|
+
: translate('gamificationNoPoints', this.language) }, typeof this.loyaltyPoints === 'number'
|
|
175
|
+
? `${this.loyaltyPoints} XP`
|
|
176
|
+
: '...', index.h("span", { class: this.isOpen ? '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)" })))), this.isOpen && (index.h("div", { class: "GamificationDropdown", onClick: this.navigateToGamification }, index.h("player-elevate-loyaltycard", { endpoint: this.endpoint, session: this.session, language: this.language, "client-styling-url": this.clientStylingUrl, "client-styling": this.clientStyling })))));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
get el() { return index.getElement(this); }
|
|
180
|
+
static get watchers() { return {
|
|
181
|
+
"translationUrl": ["handleNewTranslations"]
|
|
182
|
+
}; }
|
|
183
|
+
};
|
|
184
|
+
GamificationDropdown.style = GamificationDropdownStyle0;
|
|
185
|
+
|
|
186
|
+
exports.GamificationDropdown = GamificationDropdown;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-c535ed72.js');
|
|
6
|
+
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
4
7
|
|
|
5
8
|
/*
|
|
6
|
-
Stencil Client Patch Browser
|
|
9
|
+
Stencil Client Patch Browser v4.25.1 | MIT Licensed | https://stenciljs.com
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
var patchBrowser = () => {
|
|
12
|
+
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('gamification-dropdown.cjs.js', document.baseURI).href));
|
|
13
|
+
const opts = {};
|
|
14
|
+
if (importMeta !== "") {
|
|
15
|
+
opts.resourcesUrl = new URL(".", importMeta).href;
|
|
16
|
+
}
|
|
17
|
+
return index.promiseResolve(opts);
|
|
15
18
|
};
|
|
16
19
|
|
|
17
|
-
patchBrowser().then(options => {
|
|
18
|
-
|
|
20
|
+
patchBrowser().then(async (options) => {
|
|
21
|
+
await appGlobals.globalScripts();
|
|
22
|
+
return index.bootstrapLazy([["gamification-dropdown_4.cjs",[[1,"gamification-dropdown",{"endpoint":[513],"language":[513],"session":[513],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"isOpen":[32],"isLoading":[32],"stylingAppends":[32],"loyaltyPoints":[32]},null,{"translationUrl":["handleNewTranslations"]}],[1,"player-elevate-loyaltycard",{"endpoint":[513],"theme":[513],"session":[513],"playerAvatarUrl":[513,"player-avatar-url"],"language":[513],"playerName":[513,"player-name"],"dateFormat":[513,"date-format"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"pointExpireString":[32],"playerElevateLevel":[32],"elevateWalletTotal":[32]},[[0,"playerElevateLeveLoaded","playerElevateLeveLoadedHandler"]],{"session":["onSessionOrEndpointChange"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]}],[0,"player-elevate-card-data",{"params":[8],"playerElevateLevel":[32],"pointExpireString":[32]},[[9,"resize","handleWindowResizs"],[8,"redeemGiftButton","redeemGiftButtonHandler"]],{"params":["onParamsChanged"]}]]],["player-elevate-card.cjs",[[1,"player-elevate-card",{"endpoint":[513],"theme":[513],"session":[513],"playerAvatarUrl":[513,"player-avatar-url"],"language":[513],"playerName":[513,"player-name"],"dateFormat":[513,"date-format"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"pointExpireString":[32],"playerLevelFlag":[32],"playerElevateLevel":[32],"elevateWalletTotal":[32]},[[0,"playerElevateLeveLoaded","playerElevateLeveLoadedHandler"]],{"session":["onSessionOrEndpointChange"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"]}]]],["player-elevate-pointcard.cjs",[[1,"player-elevate-pointcard",{"endpoint":[513],"theme":[513],"session":[513],"playerAvatarUrl":[513,"player-avatar-url"],"language":[513],"playerName":[513,"player-name"],"cardTitle":[513,"card-title"],"buttonType":[513,"button-type"],"dateFormat":[513,"date-format"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"pointExpireString":[32],"playerElevateLevel":[32],"elevateWalletTotal":[32],"elevateSPTotal":[32]},[[0,"playerElevateLeveLoaded","playerElevateLeveLoadedHandler"]],{"session":["onSessionOrEndpointChange"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"]}]]]], options);
|
|
19
23
|
});
|
|
24
|
+
|
|
25
|
+
exports.setNonce = index.setNonce;
|