@everymatrix/gamification-dropdown 1.40.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 (80) hide show
  1. package/dist/cjs/gamification-dropdown.cjs.js +19 -0
  2. package/dist/cjs/gamification-dropdown_4.cjs.entry.js +751 -0
  3. package/dist/cjs/index-afa95f63.js +1704 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/player-elevate-card-items-37501652.js +2376 -0
  7. package/dist/cjs/player-elevate-card.cjs.entry.js +85 -0
  8. package/dist/cjs/player-elevate-pointcard.cjs.entry.js +92 -0
  9. package/dist/collection/collection-manifest.json +28 -0
  10. package/dist/collection/components/gamification-dropdown/gamification-dropdown.css +47 -0
  11. package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +259 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +48 -0
  14. package/dist/collection/utils/utils.js +3 -0
  15. package/dist/components/gamification-dropdown.d.ts +11 -0
  16. package/dist/components/gamification-dropdown.js +229 -0
  17. package/dist/components/general-styling-wrapper.js +6 -0
  18. package/dist/components/general-styling-wrapper2.js +103 -0
  19. package/dist/components/index.d.ts +26 -0
  20. package/dist/components/index.js +1 -0
  21. package/dist/components/player-elevate-card-data.js +6 -0
  22. package/dist/components/player-elevate-card-data2.js +632 -0
  23. package/dist/components/player-elevate-card-items.js +2149 -0
  24. package/dist/components/player-elevate-card.js +126 -0
  25. package/dist/components/player-elevate-loyaltycard.js +6 -0
  26. package/dist/components/player-elevate-loyaltycard2.js +129 -0
  27. package/dist/components/player-elevate-pointcard.js +135 -0
  28. package/dist/esm/gamification-dropdown.js +17 -0
  29. package/dist/esm/gamification-dropdown_4.entry.js +744 -0
  30. package/dist/esm/index-76ec399c.js +1675 -0
  31. package/dist/esm/index.js +1 -0
  32. package/dist/esm/loader.js +17 -0
  33. package/dist/esm/player-elevate-card-items-5d6e44ca.js +2363 -0
  34. package/dist/esm/player-elevate-card.entry.js +81 -0
  35. package/dist/esm/player-elevate-pointcard.entry.js +88 -0
  36. package/dist/esm/polyfills/core-js.js +11 -0
  37. package/dist/esm/polyfills/css-shim.js +1 -0
  38. package/dist/esm/polyfills/dom.js +79 -0
  39. package/dist/esm/polyfills/es5-html-element.js +1 -0
  40. package/dist/esm/polyfills/index.js +34 -0
  41. package/dist/esm/polyfills/system.js +6 -0
  42. package/dist/gamification-dropdown/gamification-dropdown.esm.js +1 -0
  43. package/dist/gamification-dropdown/index.esm.js +0 -0
  44. package/dist/gamification-dropdown/p-2d5bddc0.js +1 -0
  45. package/dist/gamification-dropdown/p-4eba8e43.entry.js +1 -0
  46. package/dist/gamification-dropdown/p-5e3064ce.js +1 -0
  47. package/dist/gamification-dropdown/p-62327671.entry.js +1 -0
  48. package/dist/gamification-dropdown/p-bbd6d5a3.entry.js +1 -0
  49. package/dist/index.cjs.js +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/static/button-default.svg +42 -0
  52. package/dist/static/button-disabled.svg +4 -0
  53. package/dist/static/button-hover.svg +4 -0
  54. package/dist/static/button-level.svg +27 -0
  55. package/dist/static/button-pressed.svg +18 -0
  56. package/dist/static/button-redeem.svg +36 -0
  57. package/dist/static/card-ground-over.png +0 -0
  58. package/dist/static/card-ground-over.svg +903 -0
  59. package/dist/static/card-ground.png +0 -0
  60. package/dist/static/card-ground.svg +34 -0
  61. package/dist/static/info.svg +4 -0
  62. package/dist/static/level-badge.png +0 -0
  63. package/dist/static/level-percent.svg +80 -0
  64. package/dist/static/tips-info.svg +21 -0
  65. package/dist/static/user.svg +3 -0
  66. package/dist/stencil.config.js +22 -0
  67. package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/gamification-dropdown/.stencil/packages/gamification-dropdown/stencil.config.d.ts +2 -0
  68. package/dist/types/components/gamification-dropdown/gamification-dropdown.d.ts +41 -0
  69. package/dist/types/components.d.ts +85 -0
  70. package/dist/types/index.d.ts +1 -0
  71. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  72. package/dist/types/utils/locale.utils.d.ts +2 -0
  73. package/dist/types/utils/utils.d.ts +1 -0
  74. package/loader/cdn.js +3 -0
  75. package/loader/index.cjs.js +3 -0
  76. package/loader/index.d.ts +12 -0
  77. package/loader/index.es2017.js +3 -0
  78. package/loader/index.js +4 -0
  79. package/loader/package.json +10 -0
  80. package/package.json +22 -0
@@ -0,0 +1,229 @@
1
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
+ import { d as defineCustomElement$4 } from './general-styling-wrapper2.js';
3
+ import { d as defineCustomElement$3 } from './player-elevate-card-data2.js';
4
+ import { d as defineCustomElement$2 } from './player-elevate-loyaltycard2.js';
5
+
6
+ const DEFAULT_LANGUAGE = 'en';
7
+ const SUPPORTED_LANGUAGES = ['de', 'en', 'hr'];
8
+ let TRANSLATIONS = {
9
+ en: {
10
+ gamificationNoPoints: "No points"
11
+ },
12
+ de: {
13
+ gamificationNoPoints: "No points"
14
+ },
15
+ ro: {
16
+ gamificationNoPoints: "No points"
17
+ },
18
+ fr: {
19
+ gamificationNoPoints: "No points"
20
+ },
21
+ ar: {
22
+ gamificationNoPoints: "No points"
23
+ },
24
+ hr: {
25
+ gamificationNoPoints: "No points"
26
+ }
27
+ };
28
+ const getTranslations = (url) => {
29
+ // fetch url, get the data, replace the TRANSLATIONS content
30
+ return new Promise((resolve) => {
31
+ fetch(url)
32
+ .then((res) => res.json())
33
+ .then((data) => {
34
+ Object.keys(data).forEach((item) => {
35
+ for (let key in data[item]) {
36
+ TRANSLATIONS[item][key] = data[item][key];
37
+ }
38
+ });
39
+ resolve(true);
40
+ });
41
+ });
42
+ };
43
+ const translate = (key, customLang, values) => {
44
+ const lang = customLang;
45
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
46
+ if (values !== undefined) {
47
+ for (const [key, value] of Object.entries(values.values)) {
48
+ const regex = new RegExp(`{${key}}`, 'g');
49
+ translation = translation.replace(regex, value);
50
+ }
51
+ }
52
+ return translation;
53
+ };
54
+
55
+ const gamificationDropdownCss = ":host{display:block}.GamificationDropdownContainer{position:relative}.GamificationDropdownContainer .GamificationDropdown{position:absolute;left:0;z-index:999;overflow:hidden}.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 svg{fill:var(--emw--color-typography, #FFFFFF);margin-left:8px;width:16px}";
56
+
57
+ const GamificationDropdown$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
58
+ constructor() {
59
+ super();
60
+ this.__registerHost();
61
+ this.__attachShadow();
62
+ /**
63
+ * Language of the widget
64
+ */
65
+ this.language = 'en';
66
+ /**
67
+ * Session of the user
68
+ */
69
+ this.session = '';
70
+ /**
71
+ * Client custom styling via string
72
+ */
73
+ this.clientStyling = '';
74
+ /**
75
+ * Client custom styling via url
76
+ */
77
+ this.clientStylingUrl = '';
78
+ /**
79
+ * Translations via URL
80
+ */
81
+ this.translationUrl = '';
82
+ this.isLoading = false;
83
+ this.stylingAppends = false;
84
+ this.setClientStyling = () => {
85
+ let sheet = document.createElement('style');
86
+ sheet.innerHTML = this.clientStyling;
87
+ this.stylingContainer.prepend(sheet);
88
+ };
89
+ this.setClientStylingURL = () => {
90
+ let url = new URL(this.clientStylingUrl);
91
+ let cssFile = document.createElement('style');
92
+ fetch(url.href)
93
+ .then((res) => res.text())
94
+ .then((data) => {
95
+ cssFile.innerHTML = data;
96
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
97
+ })
98
+ .catch((err) => {
99
+ console.log('error ', err);
100
+ });
101
+ };
102
+ this.handleOutsideClick = (event) => {
103
+ const dropdownElement = document.querySelector('gamification-dropdown');
104
+ if (dropdownElement && !dropdownElement.contains(event.target)) {
105
+ this.isOpen = false;
106
+ document.removeEventListener('click', this.handleOutsideClick);
107
+ }
108
+ };
109
+ this.handleDropdownClick = () => {
110
+ this.isOpen = !this.isOpen;
111
+ if (this.isOpen) {
112
+ document.addEventListener('click', this.handleOutsideClick);
113
+ }
114
+ else {
115
+ document.removeEventListener('click', this.handleOutsideClick);
116
+ }
117
+ };
118
+ }
119
+ handleNewTranslations() {
120
+ this.isLoading = true;
121
+ getTranslations(this.translationUrl).then(() => {
122
+ this.isLoading = false;
123
+ });
124
+ }
125
+ async componentWillLoad() {
126
+ if (this.translationUrl.length > 2) {
127
+ await getTranslations(this.translationUrl);
128
+ }
129
+ if (this.endpoint && this.language) {
130
+ return this.fetchPointsData();
131
+ }
132
+ }
133
+ componentDidRender() {
134
+ // start custom styling area
135
+ if (!this.stylingAppends && this.stylingContainer) {
136
+ if (this.clientStyling)
137
+ this.setClientStyling();
138
+ if (this.clientStylingUrl)
139
+ this.setClientStylingURL();
140
+ this.stylingAppends = true;
141
+ }
142
+ // end custom styling area
143
+ }
144
+ fetchPointsData() {
145
+ let url = new URL(`${this.endpoint}/v1/elevate/playerInfo`);
146
+ url.searchParams.append('language', this.language);
147
+ const headers = new Headers();
148
+ headers.append('X-SessionId', this.session);
149
+ const options = {
150
+ method: 'GET',
151
+ headers
152
+ };
153
+ return new Promise((resolve, reject) => {
154
+ this.isLoading = true;
155
+ fetch(url.href, options)
156
+ .then((res) => res.json())
157
+ .then((data) => {
158
+ var _a, _b;
159
+ 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;
160
+ resolve(true);
161
+ }).catch((err) => {
162
+ console.error(err);
163
+ reject(err);
164
+ }).finally(() => {
165
+ this.isLoading = false;
166
+ });
167
+ });
168
+ }
169
+ render() {
170
+ if (this.isLoading) {
171
+ return null;
172
+ }
173
+ else {
174
+ return (h("div", { class: "GamificationDropdownContainer" }, h("button", { class: `GamificationDropdownButton ${this.isOpen ? 'IsOpen' : ''}`, type: "button", onClick: this.handleDropdownClick, title: typeof this.loyaltyPoints === 'number'
175
+ ? String(this.loyaltyPoints)
176
+ : translate('gamificationNoPoints', this.language) }, typeof this.loyaltyPoints === 'number'
177
+ ? `${Math.floor(this.loyaltyPoints)} XP`
178
+ : '...', h("span", null, 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" }, h("player-elevate-loyaltycard", { endpoint: this.endpoint, session: this.session, language: this.language, "client-styling-url": this.clientStylingUrl, "client-styling": this.clientStyling })))));
179
+ }
180
+ }
181
+ static get watchers() { return {
182
+ "translationUrl": ["handleNewTranslations"]
183
+ }; }
184
+ static get style() { return gamificationDropdownCss; }
185
+ }, [1, "gamification-dropdown", {
186
+ "endpoint": [513],
187
+ "language": [513],
188
+ "session": [513],
189
+ "clientStyling": [513, "client-styling"],
190
+ "clientStylingUrl": [513, "client-styling-url"],
191
+ "translationUrl": [513, "translation-url"],
192
+ "isOpen": [32],
193
+ "isLoading": [32],
194
+ "stylingAppends": [32],
195
+ "loyaltyPoints": [32]
196
+ }]);
197
+ function defineCustomElement$1() {
198
+ if (typeof customElements === "undefined") {
199
+ return;
200
+ }
201
+ const components = ["gamification-dropdown", "general-styling-wrapper", "player-elevate-card-data", "player-elevate-loyaltycard"];
202
+ components.forEach(tagName => { switch (tagName) {
203
+ case "gamification-dropdown":
204
+ if (!customElements.get(tagName)) {
205
+ customElements.define(tagName, GamificationDropdown$1);
206
+ }
207
+ break;
208
+ case "general-styling-wrapper":
209
+ if (!customElements.get(tagName)) {
210
+ defineCustomElement$4();
211
+ }
212
+ break;
213
+ case "player-elevate-card-data":
214
+ if (!customElements.get(tagName)) {
215
+ defineCustomElement$3();
216
+ }
217
+ break;
218
+ case "player-elevate-loyaltycard":
219
+ if (!customElements.get(tagName)) {
220
+ defineCustomElement$2();
221
+ }
222
+ break;
223
+ } });
224
+ }
225
+
226
+ const GamificationDropdown = GamificationDropdown$1;
227
+ const defineCustomElement = defineCustomElement$1;
228
+
229
+ export { GamificationDropdown, defineCustomElement };
@@ -0,0 +1,6 @@
1
+ import { G as GeneralStylingWrapper$1, d as defineCustomElement$1 } from './general-styling-wrapper2.js';
2
+
3
+ const GeneralStylingWrapper = GeneralStylingWrapper$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { GeneralStylingWrapper, defineCustomElement };
@@ -0,0 +1,103 @@
1
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
+
3
+ const mergeTranslations = (url, target) => {
4
+ return new Promise((resolve) => {
5
+ fetch(url)
6
+ .then((res) => res.json())
7
+ .then((data) => {
8
+ Object.keys(data).forEach((item) => {
9
+ target[item] = target[item] ? target[item] : {};
10
+ for (let key in data[item]) {
11
+ target[item][key] = data[item][key];
12
+ }
13
+ });
14
+ resolve(true);
15
+ });
16
+ });
17
+ };
18
+
19
+ const generalStylingWrapperCss = ":host{display:block}";
20
+
21
+ const GeneralStylingWrapper = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
22
+ constructor() {
23
+ super();
24
+ this.__registerHost();
25
+ /**
26
+ * Client custom styling via inline styles
27
+ */
28
+ this.clientStyling = '';
29
+ /**
30
+ * Client custom styling via url
31
+ */
32
+ this.clientStylingUrl = '';
33
+ /**
34
+ * Translation via url
35
+ */
36
+ this.translationUrl = '';
37
+ this.stylingAppends = false;
38
+ this.setClientStyling = () => {
39
+ let sheet = document.createElement('style');
40
+ sheet.innerHTML = this.clientStyling;
41
+ this.el.prepend(sheet);
42
+ };
43
+ this.setClientStylingURL = () => {
44
+ let url = new URL(this.clientStylingUrl);
45
+ let cssFile = document.createElement('style');
46
+ fetch(url.href)
47
+ .then((res) => res.text())
48
+ .then((data) => {
49
+ cssFile.innerHTML = data;
50
+ setTimeout(() => {
51
+ this.el.prepend(cssFile);
52
+ }, 1);
53
+ })
54
+ .catch((err) => {
55
+ console.log('error ', err);
56
+ });
57
+ };
58
+ }
59
+ componentDidRender() {
60
+ // start custom styling area
61
+ if (!this.stylingAppends) {
62
+ if (this.clientStyling)
63
+ this.setClientStyling();
64
+ if (this.clientStylingUrl)
65
+ this.setClientStylingURL();
66
+ this.stylingAppends = true;
67
+ }
68
+ // end custom styling area
69
+ }
70
+ async componentWillLoad() {
71
+ const promises = [];
72
+ if (this.translationUrl) {
73
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
74
+ promises.push(translationPromise);
75
+ }
76
+ return await Promise.all(promises);
77
+ }
78
+ render() {
79
+ return (h("div", { class: "StyleShell" }, h("slot", { name: "mainContent" })));
80
+ }
81
+ get el() { return this; }
82
+ static get style() { return generalStylingWrapperCss; }
83
+ }, [4, "general-styling-wrapper", {
84
+ "clientStyling": [1, "client-styling"],
85
+ "clientStylingUrl": [1, "client-styling-url"],
86
+ "translationUrl": [1, "translation-url"],
87
+ "targetTranslations": [16]
88
+ }]);
89
+ function defineCustomElement() {
90
+ if (typeof customElements === "undefined") {
91
+ return;
92
+ }
93
+ const components = ["general-styling-wrapper"];
94
+ components.forEach(tagName => { switch (tagName) {
95
+ case "general-styling-wrapper":
96
+ if (!customElements.get(tagName)) {
97
+ customElements.define(tagName, GeneralStylingWrapper);
98
+ }
99
+ break;
100
+ } });
101
+ }
102
+
103
+ export { GeneralStylingWrapper as G, defineCustomElement as d };
@@ -0,0 +1,26 @@
1
+ /* GamificationDropdown custom elements */
2
+
3
+ import type { Components, JSX } from "../types/components";
4
+
5
+ /**
6
+ * Used to manually set the base path where assets can be found.
7
+ * If the script is used as "module", it's recommended to use "import.meta.url",
8
+ * such as "setAssetPath(import.meta.url)". Other options include
9
+ * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
10
+ * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
11
+ * But do note that this configuration depends on how your script is bundled, or lack of
12
+ * bundling, and where your assets can be loaded from. Additionally custom bundling
13
+ * will have to ensure the static assets are copied to its build directory.
14
+ */
15
+ export declare const setAssetPath: (path: string) => void;
16
+
17
+ export interface SetPlatformOptions {
18
+ raf?: (c: FrameRequestCallback) => number;
19
+ ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
20
+ rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
21
+ }
22
+ export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
23
+
24
+ export type { Components, JSX };
25
+
26
+ export * from '../types';
@@ -0,0 +1 @@
1
+ export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
@@ -0,0 +1,6 @@
1
+ import { P as PlayerElevateCardData$1, d as defineCustomElement$1 } from './player-elevate-card-data2.js';
2
+
3
+ const PlayerElevateCardData = PlayerElevateCardData$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { PlayerElevateCardData, defineCustomElement };