@everymatrix/gamification-dropdown 0.1.0
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-b0044320.js +173 -0
- package/dist/cjs/gamification-dropdown.cjs.js +25 -0
- package/dist/cjs/gamification-dropdown_4.cjs.entry.js +559 -0
- package/dist/cjs/index-1c31b1d6.js +1675 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/player-elevate-card-items-77750a62.js +2364 -0
- package/dist/cjs/player-elevate-card.cjs.entry.js +74 -0
- package/dist/cjs/player-elevate-pointcard.cjs.entry.js +76 -0
- package/dist/collection/collection-manifest.json +28 -0
- package/dist/collection/components/gamification-dropdown/gamification-dropdown.css +57 -0
- package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +256 -0
- package/dist/collection/components/gamification-dropdown/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +42 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/gamification-dropdown-498ae904.js +171 -0
- package/dist/esm/gamification-dropdown.js +20 -0
- package/dist/esm/gamification-dropdown_4.entry.js +552 -0
- package/dist/esm/index-0ad2daf0.js +1645 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/player-elevate-card-items-50dbfe39.js +2351 -0
- package/dist/esm/player-elevate-card.entry.js +70 -0
- package/dist/esm/player-elevate-pointcard.entry.js +72 -0
- package/dist/gamification-dropdown/gamification-dropdown.esm.js +1 -0
- package/dist/gamification-dropdown/index.esm.js +1 -0
- package/dist/gamification-dropdown/p-09730cb4.entry.js +1 -0
- package/dist/gamification-dropdown/p-58a784a0.js +1 -0
- package/dist/gamification-dropdown/p-72844c24.js +1 -0
- package/dist/gamification-dropdown/p-95a21693.js +2 -0
- package/dist/gamification-dropdown/p-be2f5b0a.entry.js +1 -0
- package/dist/gamification-dropdown/p-d1603dd0.entry.js +1 -0
- package/dist/gamification-dropdown/p-e1255160.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/static/button-default.svg +42 -0
- package/dist/static/button-disabled.svg +4 -0
- package/dist/static/button-hover.svg +4 -0
- package/dist/static/button-level.svg +27 -0
- package/dist/static/button-pressed.svg +18 -0
- package/dist/static/button-redeem.svg +36 -0
- package/dist/static/card-ground-over.png +0 -0
- package/dist/static/card-ground-over.svg +903 -0
- package/dist/static/card-ground.png +0 -0
- package/dist/static/card-ground.svg +34 -0
- package/dist/static/info.svg +4 -0
- package/dist/static/level-badge.png +0 -0
- package/dist/static/level-percent.svg +80 -0
- package/dist/static/tips-info.svg +21 -0
- package/dist/static/user.svg +3 -0
- package/dist/stencil.config.dev.js +15 -0
- package/dist/stencil.config.js +17 -0
- package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.d.ts +2 -0
- package/dist/types/Users/maria.bumbar/Desktop/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 +43 -0
- package/dist/types/components/gamification-dropdown/index.d.ts +1 -0
- package/dist/types/components.d.ts +85 -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 +1 -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 +29 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { r as registerInstance, h, g as getElement } from './index-0ad2daf0.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
4
|
+
let TRANSLATIONS = {
|
|
5
|
+
en: {
|
|
6
|
+
gamificationNoPoints: "No points"
|
|
7
|
+
},
|
|
8
|
+
de: {
|
|
9
|
+
gamificationNoPoints: "No points"
|
|
10
|
+
},
|
|
11
|
+
ro: {
|
|
12
|
+
gamificationNoPoints: "No points"
|
|
13
|
+
},
|
|
14
|
+
fr: {
|
|
15
|
+
gamificationNoPoints: "No points"
|
|
16
|
+
},
|
|
17
|
+
ar: {
|
|
18
|
+
gamificationNoPoints: "No points"
|
|
19
|
+
},
|
|
20
|
+
hr: {
|
|
21
|
+
gamificationNoPoints: "No points"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const getTranslations = (url) => {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
fetch(url)
|
|
27
|
+
.then((res) => res.json())
|
|
28
|
+
.then((data) => {
|
|
29
|
+
Object.keys(data).forEach((lang) => {
|
|
30
|
+
if (!TRANSLATIONS[lang]) {
|
|
31
|
+
TRANSLATIONS[lang] = {};
|
|
32
|
+
}
|
|
33
|
+
for (let key in data[lang]) {
|
|
34
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
resolve(true);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const translate = (key, customLang) => {
|
|
42
|
+
const lang = customLang;
|
|
43
|
+
return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
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}";
|
|
47
|
+
const GamificationDropdownStyle0 = gamificationDropdownCss;
|
|
48
|
+
|
|
49
|
+
const GamificationDropdown = class {
|
|
50
|
+
constructor(hostRef) {
|
|
51
|
+
registerInstance(this, hostRef);
|
|
52
|
+
this.setClientStyling = () => {
|
|
53
|
+
let sheet = document.createElement('style');
|
|
54
|
+
sheet.innerHTML = this.clientStyling;
|
|
55
|
+
this.stylingContainer.prepend(sheet);
|
|
56
|
+
};
|
|
57
|
+
this.setClientStylingURL = () => {
|
|
58
|
+
let url = new URL(this.clientStylingUrl);
|
|
59
|
+
let cssFile = document.createElement('style');
|
|
60
|
+
fetch(url.href)
|
|
61
|
+
.then((res) => res.text())
|
|
62
|
+
.then((data) => {
|
|
63
|
+
cssFile.innerHTML = data;
|
|
64
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
console.log('error ', err);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
this.navigateToGamification = () => {
|
|
71
|
+
window.postMessage({ type: 'NavigateToGamification' }, window.location.href);
|
|
72
|
+
this.isOpen = false;
|
|
73
|
+
};
|
|
74
|
+
this.handleOutsideClick = (event) => {
|
|
75
|
+
const path = event.composedPath();
|
|
76
|
+
if (!path.includes(this.el)) {
|
|
77
|
+
this.isOpen = false;
|
|
78
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this.handleDropdownClick = (event) => {
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
this.isOpen = !this.isOpen;
|
|
84
|
+
if (this.isOpen) {
|
|
85
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
this.endpoint = undefined;
|
|
92
|
+
this.language = 'en';
|
|
93
|
+
this.session = '';
|
|
94
|
+
this.clientStyling = '';
|
|
95
|
+
this.clientStylingUrl = '';
|
|
96
|
+
this.translationUrl = '';
|
|
97
|
+
this.isOpen = false;
|
|
98
|
+
this.isLoading = false;
|
|
99
|
+
this.stylingAppends = false;
|
|
100
|
+
this.loyaltyPoints = undefined;
|
|
101
|
+
}
|
|
102
|
+
handleNewTranslations() {
|
|
103
|
+
this.isLoading = true;
|
|
104
|
+
getTranslations(this.translationUrl).then(() => {
|
|
105
|
+
this.isLoading = false;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async componentWillLoad() {
|
|
109
|
+
if (this.translationUrl.length > 2) {
|
|
110
|
+
await getTranslations(this.translationUrl);
|
|
111
|
+
}
|
|
112
|
+
if (this.endpoint && this.language) {
|
|
113
|
+
return this.fetchPointsData();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
componentDidRender() {
|
|
117
|
+
// start custom styling area
|
|
118
|
+
if (!this.stylingAppends && this.stylingContainer) {
|
|
119
|
+
if (this.clientStyling)
|
|
120
|
+
this.setClientStyling();
|
|
121
|
+
if (this.clientStylingUrl)
|
|
122
|
+
this.setClientStylingURL();
|
|
123
|
+
this.stylingAppends = true;
|
|
124
|
+
}
|
|
125
|
+
// end custom styling area
|
|
126
|
+
}
|
|
127
|
+
fetchPointsData() {
|
|
128
|
+
let url = new URL(`${this.endpoint}/v1/elevate/playerInfo`);
|
|
129
|
+
url.searchParams.append('language', this.language);
|
|
130
|
+
const headers = new Headers();
|
|
131
|
+
headers.append('X-SessionId', this.session);
|
|
132
|
+
const options = {
|
|
133
|
+
method: 'GET',
|
|
134
|
+
headers
|
|
135
|
+
};
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
this.isLoading = true;
|
|
138
|
+
fetch(url.href, options)
|
|
139
|
+
.then((res) => res.json())
|
|
140
|
+
.then((data) => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
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;
|
|
143
|
+
resolve(true);
|
|
144
|
+
}).catch((err) => {
|
|
145
|
+
console.error(err);
|
|
146
|
+
reject(err);
|
|
147
|
+
}).finally(() => {
|
|
148
|
+
this.isLoading = false;
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
render() {
|
|
153
|
+
if (this.isLoading) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return (h("div", { ref: el => this.stylingContainer = el, class: "GamificationDropdownContainer" }, h("button", { class: `GamificationDropdownButton ${this.isOpen ? 'IsOpen' : ''}`, type: "button", onClick: (e) => this.handleDropdownClick(e), title: typeof this.loyaltyPoints === 'number'
|
|
158
|
+
? String(this.loyaltyPoints)
|
|
159
|
+
: translate('gamificationNoPoints', this.language) }, typeof this.loyaltyPoints === 'number'
|
|
160
|
+
? `${this.loyaltyPoints} XP`
|
|
161
|
+
: '...', h("span", { class: this.isOpen ? '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)" })))), this.isOpen && (h("div", { class: "GamificationDropdown", onClick: this.navigateToGamification }, h("player-elevate-loyaltycard", { endpoint: this.endpoint, session: this.session, language: this.language, "client-styling-url": this.clientStylingUrl, "client-styling": this.clientStyling })))));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
get el() { return getElement(this); }
|
|
165
|
+
static get watchers() { return {
|
|
166
|
+
"translationUrl": ["handleNewTranslations"]
|
|
167
|
+
}; }
|
|
168
|
+
};
|
|
169
|
+
GamificationDropdown.style = GamificationDropdownStyle0;
|
|
170
|
+
|
|
171
|
+
export { GamificationDropdown as G };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-0ad2daf0.js';
|
|
2
|
+
export { s as setNonce } from './index-0ad2daf0.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([["gamification-dropdown_4",[[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"]],{"params":["onParamsChanged"]}]]],["player-elevate-card",[[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",[[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);
|
|
20
|
+
});
|