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