@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,74 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-1c31b1d6.js');
6
+ const playerElevateCardItems = require('./player-elevate-card-items-77750a62.js');
7
+
8
+ const playerElevateCardCss = "@container (max-width: 270px) {\n .Card .Inner {\n flex-direction: column;\n }\n .Card .Inner .Content {\n padding: 9px;\n }\n .Inner .Row .ExpirationPoints {\n order: 1;\n }\n}\n.Card .PlayerImg {\n order: 0;\n}\n.Card .ExpirationPoints {\n order: 3;\n}\n.Card .LevelInfo {\n order: 2;\n}\n.Card .Inner .Row .PlayerImg {\n flex-direction: column;\n}\n.Card .Inner .Row .PointsInfo {\n width: 100%;\n text-align: center;\n display: flex;\n flex-direction: column;\n max-height: 50%;\n}\n.Card .Inner .PlayerAvatar .Badge {\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n right: 5px;\n bottom: -5px;\n width: 40%;\n height: 40%;\n overflow: visible;\n}\n.Card .Inner .Row .ExpirationPoints {\n text-align: left;\n color: var(--emfe-w-color-red, red);\n}\n.Card .Inner .Row .Points {\n text-wrap: nowrap;\n}\n.Card .Inner .LevelInfo .ElevateLevel {\n flex-direction: column;\n}\n.Card .Inner .LevelInfo .ElevateLevel .LevelName {\n width: calc(100% - 20px);\n text-align: left;\n font-size: 13px;\n padding-left: 20px;\n margin: 10px 0;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpirationDate {\n text-align: center;\n font-size: smaller;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpireTime {\n margin-left: 5px;\n}";
9
+ const PlayerElevateCardStyle0 = playerElevateCardCss;
10
+
11
+ const PlayerElevateCard = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.endpoint = undefined;
15
+ this.theme = 'Dark';
16
+ this.session = undefined;
17
+ this.playerAvatarUrl = undefined;
18
+ this.language = 'en';
19
+ this.playerName = undefined;
20
+ this.dateFormat = 'yyyy-MM-dd';
21
+ this.clientStyling = '';
22
+ this.clientStylingUrl = '';
23
+ this.translationUrl = '';
24
+ this.pointExpireString = undefined;
25
+ this.playerLevelFlag = 0;
26
+ this.playerElevateLevel = undefined;
27
+ this.elevateWalletTotal = undefined;
28
+ }
29
+ onSessionOrEndpointChange() {
30
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
31
+ }
32
+ playerElevateLeveLoadedHandler(event) {
33
+ if (!event.detail) {
34
+ return;
35
+ }
36
+ if (event.detail['elevateLevelWalletTotal']) {
37
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
38
+ }
39
+ if (event.detail['elevateLevel']) {
40
+ this.playerElevateLevel = event.detail['elevateLevel'];
41
+ }
42
+ if (event.detail['pointExpireString']) {
43
+ this.pointExpireString = event.detail.xpExpireString;
44
+ }
45
+ if (event.detail.calculatedLevelFlag) {
46
+ this.playerLevelFlag = event.detail.calculatedLevelFlag;
47
+ }
48
+ }
49
+ onRedeemClick() {
50
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
51
+ }
52
+ componentWillLoad() {
53
+ this.paramProxy = {
54
+ endpoint: this.endpoint,
55
+ session: this.session,
56
+ language: this.language,
57
+ calculateLevelFlag: true,
58
+ };
59
+ }
60
+ render() {
61
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
62
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
63
+ return (index.h("div", { key: '278a328dd084ee73b2707b93a57bccae64a2c9c7', class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { key: '68c885baf533447a7c77fd887bbec11e53768277', class: "Card Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { key: '4066253a70cdd5e712ca244a708e7c1600c83071', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: playerElevateCardItems.TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { key: '64cda2a267c752056b3c7e3134cc324fa96bc261', params: this.paramProxy }), index.h("div", { key: 'c63ae83b401a35f5a78acd83dc3d7296c25141d7', class: "OuterCover Inner", style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, this.playerElevateLevel && (index.h(index.Fragment, { key: 'ba16e5bb54259c17fd9e5aa0e3c03c2ec5d4263c' }, index.h("div", { key: 'fa1bf74f45e28318c95266cc42c54541bde92718', class: 'Content Row' }, index.h("div", { key: '7ede46f91bcc0d894b2b633627a4ca97d15fbe90', class: "PlayerImg" }, index.h(playerElevateCardItems.PlayerAvatar, { key: 'b6d0bac085e0178512b8a63ba8fccae7d4cc8399', playerAvatarUrl: this.playerAvatarUrl, loyaltyIconUrl: this.playerElevateLevel.presentation.asset }), index.h(playerElevateCardItems.PlayerPoints, { key: '88c445dbcd7dbe426a8de18beea02aecc03e26f3', loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language })), this.pointExpireString && (index.h("div", { key: '4d985e486ecb74a6c916b28e619de83cb3d77ac1', class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), index.h("div", { key: '34e051ee1ff79b825fca57db958e1e5684a0aca1', class: `LevelInfo Level${this.playerLevelFlag} ${this.playerElevateLevel.presentation.displayName}` }, index.h(playerElevateCardItems.PlayerNameDiv, { key: 'fa1b1f16e0b25c6adfba4c215e4ed377e05699b2', playerName: this.playerName }), index.h(playerElevateCardItems.PlayerElevateLoyaltyLevel, { key: '6d18b1422db202363ebcd56cc56946e0e071937b', hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), index.h(playerElevateCardItems.PlayerLoyaltyProcess, { key: '7dae355c4a5a9e28c70dced0ac061608f1753020' }), index.h(playerElevateCardItems.PlayerElevateCardRedeem, { key: '7e5f830b612c962a828c58f20a88dc97d315c910', onRedeemClick: this.onRedeemClick, language: this.language })))))))));
64
+ }
65
+ static get assetsDirs() { return ["../static"]; }
66
+ static get watchers() { return {
67
+ "session": ["onSessionOrEndpointChange"],
68
+ "endpoint": ["onSessionOrEndpointChange"],
69
+ "language": ["onSessionOrEndpointChange"]
70
+ }; }
71
+ };
72
+ PlayerElevateCard.style = PlayerElevateCardStyle0;
73
+
74
+ exports.player_elevate_card = PlayerElevateCard;
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-1c31b1d6.js');
6
+ const playerElevateCardItems = require('./player-elevate-card-items-77750a62.js');
7
+
8
+ const playerElevatePointcardCss = ":host{display:block}.PointsCard .Inner .Row .ExpirationPoints{text-align:left}.PointsCard .Inner .PlayerAvatar .Avatar{display:none}.PointsCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%;position:inherit}.PointsCard .Inner .PointsTxt{display:flex;flex-direction:row;justify-content:space-between}.PointsCard .Inner .DetailButton{background:linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%), linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));border-radius:5px;box-shadow:0px 4px 4px 0px rgba(0, 0, 0, 0.25);border:2px solid;font-size:11px;width:108px;padding:4px;cursor:pointer;margin-top:5px;height:16px;min-width:45px;text-align:center}.PointsCard .Inner .DetailButton span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .DetailButton span{display:inline-block;vertical-align:middle}.PointsCard .Inner .DetailButton:hover span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .LevelInfo{gap:15px;width:70%}.PointsCard .Inner .LevelInfo .PointsTxt{font-size:15px}.PointsCard .Inner .LevelInfo .PointsTxt.Label{display:none}.PointsCard .Inner .LevelInfo .PointsTxt.SPPoints{padding-top:15px}.PointsCard .Inner .LevelInfo .PointsTxt .TC{font-size:x-small;color:var(--emw--color-gray-300, #58586B);display:flex;align-content:center;height:100%;flex-wrap:wrap;text-decoration:underline;cursor:pointer;display:none}";
9
+ const PlayerElevatePointcardStyle0 = playerElevatePointcardCss;
10
+
11
+ const PlayerElevatePointcard = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.isPointDetailCard = this.buttonType === 'earningRule';
15
+ this.endpoint = undefined;
16
+ this.theme = 'Dark';
17
+ this.session = undefined;
18
+ this.playerAvatarUrl = undefined;
19
+ this.language = 'en';
20
+ this.playerName = undefined;
21
+ this.cardTitle = undefined;
22
+ this.buttonType = 'earningRule';
23
+ this.dateFormat = 'yyyy-MM-dd';
24
+ this.clientStyling = '';
25
+ this.clientStylingUrl = '';
26
+ this.translationUrl = '';
27
+ this.pointExpireString = undefined;
28
+ this.playerElevateLevel = undefined;
29
+ this.elevateWalletTotal = undefined;
30
+ this.elevateSPTotal = undefined;
31
+ }
32
+ onSessionOrEndpointChange() {
33
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
34
+ }
35
+ playerElevateLeveLoadedHandler(event) {
36
+ if (!event.detail) {
37
+ return;
38
+ }
39
+ if (event.detail['elevateLevelWalletTotal']) {
40
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
41
+ this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
42
+ }
43
+ if (event.detail['elevateLevel']) {
44
+ this.playerElevateLevel = event.detail['elevateLevel'];
45
+ }
46
+ if (event.detail['pointExpireString']) {
47
+ this.pointExpireString = event.detail.pointExpireString;
48
+ }
49
+ }
50
+ onDetailsClick() {
51
+ window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
52
+ path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
53
+ }
54
+ componentWillLoad() {
55
+ this.paramProxy = {
56
+ endpoint: this.endpoint,
57
+ session: this.session,
58
+ language: this.language,
59
+ };
60
+ }
61
+ render() {
62
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
63
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
64
+ return (index.h("div", { key: '13461fc9cf8b777337a539c15da4bb2781f5a837', class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { key: '526e72c0ada871f74ba4a07f0a125bc25840c09c', class: "PointsCard Outer ", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { key: '95e358ceb8fa3c247660f7ca15a4684b132874be', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: playerElevateCardItems.TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { key: '24c765d743446ac597a9dcc9cd22515e7e39e6db', params: this.paramProxy }), index.h("div", { key: '309db4bbfc244a7fb97827774d9d4383109ca0d7', class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, index.h("div", { key: '9d5614ded2f73b505e60900675a7d95b3cfbcbc6', class: 'Content Row' }, this.playerElevateLevel && (index.h(index.Fragment, { key: '9a17e809083e61aad19f7ffef5d5ee5885ae8b4d' }, index.h("div", { key: '47068df3c0070ee2785b0d0201b08766fe0d71e8', class: "PlayerImg" }, index.h(playerElevateCardItems.PlayerAvatar, { key: '40115f8b190d871c85f9531fbf0bafb8fbd739e2', onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), index.h("div", { key: '278cd70c23ecb48655e90810af570ce5366d13d5', class: `LevelInfo ${this.playerElevateLevel.name}` }, index.h("div", { key: 'ce682ff881c5b12ed0b736ffcc67ad07b3713999', class: "PointsTxt Label" }, this.cardTitle ? this.cardTitle : playerElevateCardItems.translate('spendablePoints')), index.h("div", { key: 'eeebc5c468cf6e3d566f708fd47a19956ad9defe', class: 'PointsTxt SPPoints' }, index.h(playerElevateCardItems.PlayerPoints, { key: 'ad58990b7fa789cf2d5c524191447196e97c8a16', spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), index.h("a", { key: '0dbdd6cd84e1cb43dac4485f4e3eec3130d6c65c', class: "TC", onClick: () => {
65
+ this.onDetailsClick();
66
+ } }, playerElevateCardItems.translate('termAndConditions', this.language))), this.pointExpireString && (index.h("div", { key: '45c3267d390995fabe34974913adf97b112cf8c2', class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
67
+ }
68
+ static get watchers() { return {
69
+ "session": ["onSessionOrEndpointChange"],
70
+ "endpoint": ["onSessionOrEndpointChange"],
71
+ "language": ["onSessionOrEndpointChange"]
72
+ }; }
73
+ };
74
+ PlayerElevatePointcard.style = PlayerElevatePointcardStyle0;
75
+
76
+ exports.player_elevate_pointcard = PlayerElevatePointcard;
@@ -0,0 +1,28 @@
1
+ {
2
+ "entries": [
3
+ "components/gamification-dropdown/gamification-dropdown.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "4.20.0",
8
+ "typescriptVersion": "5.5.3"
9
+ },
10
+ "collections": [
11
+ {
12
+ "name": "@everymatrix/general-styling-wrapper",
13
+ "tags": [
14
+ "general-styling-wrapper"
15
+ ]
16
+ },
17
+ {
18
+ "name": "@everymatrix/player-elevate-card",
19
+ "tags": [
20
+ "player-elevate-card",
21
+ "player-elevate-card-data",
22
+ "player-elevate-loyaltycard",
23
+ "player-elevate-pointcard"
24
+ ]
25
+ }
26
+ ],
27
+ "bundles": []
28
+ }
@@ -0,0 +1,57 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .GamificationDropdownContainer {
6
+ position: relative;
7
+ }
8
+ .GamificationDropdownContainer .GamificationDropdown {
9
+ position: absolute;
10
+ left: 0;
11
+ z-index: 200;
12
+ overflow: hidden;
13
+ cursor: pointer;
14
+ }
15
+
16
+ .GamificationDropdownButton {
17
+ cursor: pointer;
18
+ font-size: 14px;
19
+ height: 20px;
20
+ background-color: unset;
21
+ color: var(--emw--color-typography, #FFFFFF);
22
+ padding: 0;
23
+ border: none;
24
+ overflow: hidden;
25
+ white-space: nowrap;
26
+ text-overflow: ellipsis;
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ line-height: 0;
31
+ }
32
+ .GamificationDropdownButton:hover {
33
+ color: var(--emw--color-primary, #52d004);
34
+ }
35
+ .GamificationDropdownButton:hover svg {
36
+ fill: var(--emw--color-primary, #52d004);
37
+ }
38
+ .GamificationDropdownButton.IsOpen {
39
+ color: var(--emw--color-primary, #52d004);
40
+ }
41
+ .GamificationDropdownButton.IsOpen svg {
42
+ fill: var(--emw--color-primary, #52d004);
43
+ }
44
+ .GamificationDropdownButton .TriangleActive, .GamificationDropdownButton .TriangleInactive {
45
+ display: block;
46
+ transition: all 0.2s;
47
+ }
48
+ .GamificationDropdownButton .TriangleActive {
49
+ transform: scale(1.1) rotateX(180deg) translateY(3px);
50
+ fill: var(--emw--color-primary, #52d004);
51
+ margin-top: 4px;
52
+ }
53
+ .GamificationDropdownButton svg {
54
+ fill: var(--emw--color-typography, #FFFFFF);
55
+ margin-left: 8px;
56
+ width: 16px;
57
+ }
@@ -0,0 +1,256 @@
1
+ import { h } from "@stencil/core";
2
+ import { getTranslations, translate } from "../../utils/locale.utils";
3
+ import "../../../../../player-elevate-card/dist/types/index";
4
+ export class GamificationDropdown {
5
+ constructor() {
6
+ this.setClientStyling = () => {
7
+ let sheet = document.createElement('style');
8
+ sheet.innerHTML = this.clientStyling;
9
+ this.stylingContainer.prepend(sheet);
10
+ };
11
+ this.setClientStylingURL = () => {
12
+ let url = new URL(this.clientStylingUrl);
13
+ let cssFile = document.createElement('style');
14
+ fetch(url.href)
15
+ .then((res) => res.text())
16
+ .then((data) => {
17
+ cssFile.innerHTML = data;
18
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
19
+ })
20
+ .catch((err) => {
21
+ console.log('error ', err);
22
+ });
23
+ };
24
+ this.navigateToGamification = () => {
25
+ window.postMessage({ type: 'NavigateToGamification' }, window.location.href);
26
+ this.isOpen = false;
27
+ };
28
+ this.handleOutsideClick = (event) => {
29
+ const path = event.composedPath();
30
+ if (!path.includes(this.el)) {
31
+ this.isOpen = false;
32
+ document.removeEventListener('click', this.handleOutsideClick);
33
+ }
34
+ };
35
+ this.handleDropdownClick = (event) => {
36
+ event.stopPropagation();
37
+ this.isOpen = !this.isOpen;
38
+ if (this.isOpen) {
39
+ document.addEventListener('click', this.handleOutsideClick);
40
+ }
41
+ else {
42
+ document.removeEventListener('click', this.handleOutsideClick);
43
+ }
44
+ };
45
+ this.endpoint = undefined;
46
+ this.language = 'en';
47
+ this.session = '';
48
+ this.clientStyling = '';
49
+ this.clientStylingUrl = '';
50
+ this.translationUrl = '';
51
+ this.isOpen = false;
52
+ this.isLoading = false;
53
+ this.stylingAppends = false;
54
+ this.loyaltyPoints = undefined;
55
+ }
56
+ handleNewTranslations() {
57
+ this.isLoading = true;
58
+ getTranslations(this.translationUrl).then(() => {
59
+ this.isLoading = false;
60
+ });
61
+ }
62
+ async componentWillLoad() {
63
+ if (this.translationUrl.length > 2) {
64
+ await getTranslations(this.translationUrl);
65
+ }
66
+ if (this.endpoint && this.language) {
67
+ return this.fetchPointsData();
68
+ }
69
+ }
70
+ componentDidRender() {
71
+ // start custom styling area
72
+ if (!this.stylingAppends && this.stylingContainer) {
73
+ if (this.clientStyling)
74
+ this.setClientStyling();
75
+ if (this.clientStylingUrl)
76
+ this.setClientStylingURL();
77
+ this.stylingAppends = true;
78
+ }
79
+ // end custom styling area
80
+ }
81
+ fetchPointsData() {
82
+ let url = new URL(`${this.endpoint}/v1/elevate/playerInfo`);
83
+ url.searchParams.append('language', this.language);
84
+ const headers = new Headers();
85
+ headers.append('X-SessionId', this.session);
86
+ const options = {
87
+ method: 'GET',
88
+ headers
89
+ };
90
+ return new Promise((resolve, reject) => {
91
+ this.isLoading = true;
92
+ fetch(url.href, options)
93
+ .then((res) => res.json())
94
+ .then((data) => {
95
+ var _a, _b;
96
+ 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;
97
+ resolve(true);
98
+ }).catch((err) => {
99
+ console.error(err);
100
+ reject(err);
101
+ }).finally(() => {
102
+ this.isLoading = false;
103
+ });
104
+ });
105
+ }
106
+ render() {
107
+ if (this.isLoading) {
108
+ return null;
109
+ }
110
+ else {
111
+ 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'
112
+ ? String(this.loyaltyPoints)
113
+ : translate('gamificationNoPoints', this.language) }, typeof this.loyaltyPoints === 'number'
114
+ ? `${this.loyaltyPoints} XP`
115
+ : '...', 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 })))));
116
+ }
117
+ }
118
+ static get is() { return "gamification-dropdown"; }
119
+ static get encapsulation() { return "shadow"; }
120
+ static get originalStyleUrls() {
121
+ return {
122
+ "$": ["gamification-dropdown.scss"]
123
+ };
124
+ }
125
+ static get styleUrls() {
126
+ return {
127
+ "$": ["gamification-dropdown.css"]
128
+ };
129
+ }
130
+ static get properties() {
131
+ return {
132
+ "endpoint": {
133
+ "type": "string",
134
+ "mutable": false,
135
+ "complexType": {
136
+ "original": "string",
137
+ "resolved": "string",
138
+ "references": {}
139
+ },
140
+ "required": false,
141
+ "optional": false,
142
+ "docs": {
143
+ "tags": [],
144
+ "text": "Endpoint URL for the source of data"
145
+ },
146
+ "attribute": "endpoint",
147
+ "reflect": true
148
+ },
149
+ "language": {
150
+ "type": "string",
151
+ "mutable": false,
152
+ "complexType": {
153
+ "original": "string",
154
+ "resolved": "string",
155
+ "references": {}
156
+ },
157
+ "required": false,
158
+ "optional": false,
159
+ "docs": {
160
+ "tags": [],
161
+ "text": "Language of the widget"
162
+ },
163
+ "attribute": "language",
164
+ "reflect": true,
165
+ "defaultValue": "'en'"
166
+ },
167
+ "session": {
168
+ "type": "string",
169
+ "mutable": false,
170
+ "complexType": {
171
+ "original": "string",
172
+ "resolved": "string",
173
+ "references": {}
174
+ },
175
+ "required": false,
176
+ "optional": false,
177
+ "docs": {
178
+ "tags": [],
179
+ "text": "Session of the user"
180
+ },
181
+ "attribute": "session",
182
+ "reflect": true,
183
+ "defaultValue": "''"
184
+ },
185
+ "clientStyling": {
186
+ "type": "string",
187
+ "mutable": false,
188
+ "complexType": {
189
+ "original": "string",
190
+ "resolved": "string",
191
+ "references": {}
192
+ },
193
+ "required": false,
194
+ "optional": false,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": "Client custom styling via string"
198
+ },
199
+ "attribute": "client-styling",
200
+ "reflect": true,
201
+ "defaultValue": "''"
202
+ },
203
+ "clientStylingUrl": {
204
+ "type": "string",
205
+ "mutable": false,
206
+ "complexType": {
207
+ "original": "string",
208
+ "resolved": "string",
209
+ "references": {}
210
+ },
211
+ "required": false,
212
+ "optional": false,
213
+ "docs": {
214
+ "tags": [],
215
+ "text": "Client custom styling via url"
216
+ },
217
+ "attribute": "client-styling-url",
218
+ "reflect": true,
219
+ "defaultValue": "''"
220
+ },
221
+ "translationUrl": {
222
+ "type": "string",
223
+ "mutable": false,
224
+ "complexType": {
225
+ "original": "string",
226
+ "resolved": "string",
227
+ "references": {}
228
+ },
229
+ "required": false,
230
+ "optional": false,
231
+ "docs": {
232
+ "tags": [],
233
+ "text": "Translations via URL"
234
+ },
235
+ "attribute": "translation-url",
236
+ "reflect": true,
237
+ "defaultValue": "''"
238
+ }
239
+ };
240
+ }
241
+ static get states() {
242
+ return {
243
+ "isOpen": {},
244
+ "isLoading": {},
245
+ "stylingAppends": {},
246
+ "loyaltyPoints": {}
247
+ };
248
+ }
249
+ static get elementRef() { return "el"; }
250
+ static get watchers() {
251
+ return [{
252
+ "propName": "translationUrl",
253
+ "methodName": "handleNewTranslations"
254
+ }];
255
+ }
256
+ }
@@ -0,0 +1 @@
1
+ export { GamificationDropdown } from './gamification-dropdown';
@@ -0,0 +1 @@
1
+ export * from './components/gamification-dropdown';
@@ -0,0 +1,42 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ let TRANSLATIONS = {
3
+ en: {
4
+ gamificationNoPoints: "No points"
5
+ },
6
+ de: {
7
+ gamificationNoPoints: "No points"
8
+ },
9
+ ro: {
10
+ gamificationNoPoints: "No points"
11
+ },
12
+ fr: {
13
+ gamificationNoPoints: "No points"
14
+ },
15
+ ar: {
16
+ gamificationNoPoints: "No points"
17
+ },
18
+ hr: {
19
+ gamificationNoPoints: "No points"
20
+ }
21
+ };
22
+ export const getTranslations = (url) => {
23
+ return new Promise((resolve) => {
24
+ fetch(url)
25
+ .then((res) => res.json())
26
+ .then((data) => {
27
+ Object.keys(data).forEach((lang) => {
28
+ if (!TRANSLATIONS[lang]) {
29
+ TRANSLATIONS[lang] = {};
30
+ }
31
+ for (let key in data[lang]) {
32
+ TRANSLATIONS[lang][key] = data[lang][key];
33
+ }
34
+ });
35
+ resolve(true);
36
+ });
37
+ });
38
+ };
39
+ export const translate = (key, customLang) => {
40
+ const lang = customLang;
41
+ return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
42
+ };
@@ -0,0 +1,3 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };