@everymatrix/casino-engagement-suite-jackpot-details 1.36.1

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 (53) hide show
  1. package/dist/casino-engagement-suite-jackpot-details/casino-engagement-suite-jackpot-details.esm.js +1 -0
  2. package/dist/casino-engagement-suite-jackpot-details/index.esm.js +0 -0
  3. package/dist/casino-engagement-suite-jackpot-details/p-9764b08b.entry.js +1 -0
  4. package/dist/casino-engagement-suite-jackpot-details/p-e36472df.js +1 -0
  5. package/dist/casino-engagement-suite-jackpot-details/p-e8978b77.entry.js +1 -0
  6. package/dist/cjs/casino-engagement-suite-jackpot-details.cjs.entry.js +285 -0
  7. package/dist/cjs/casino-engagement-suite-jackpot-details.cjs.js +19 -0
  8. package/dist/cjs/casino-engagement-suite-progress-bar.cjs.entry.js +76 -0
  9. package/dist/cjs/index-8f767151.js +1317 -0
  10. package/dist/cjs/index.cjs.js +2 -0
  11. package/dist/cjs/loader.cjs.js +21 -0
  12. package/dist/collection/collection-manifest.json +19 -0
  13. package/dist/collection/components/casino-engagement-suite-jackpot-details/casino-engagement-suite-jackpot-details.css +358 -0
  14. package/dist/collection/components/casino-engagement-suite-jackpot-details/casino-engagement-suite-jackpot-details.js +460 -0
  15. package/dist/collection/index.js +1 -0
  16. package/dist/collection/models/index.js +1 -0
  17. package/dist/collection/utils/index.js +5 -0
  18. package/dist/collection/utils/locale.utils.js +22 -0
  19. package/dist/components/casino-engagement-suite-jackpot-details.d.ts +11 -0
  20. package/dist/components/casino-engagement-suite-jackpot-details.js +316 -0
  21. package/dist/components/casino-engagement-suite-progress-bar.js +97 -0
  22. package/dist/components/index.d.ts +26 -0
  23. package/dist/components/index.js +1 -0
  24. package/dist/esm/casino-engagement-suite-jackpot-details.entry.js +281 -0
  25. package/dist/esm/casino-engagement-suite-jackpot-details.js +17 -0
  26. package/dist/esm/casino-engagement-suite-progress-bar.entry.js +72 -0
  27. package/dist/esm/index-ec30ecaa.js +1290 -0
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/loader.js +17 -0
  30. package/dist/esm/polyfills/core-js.js +11 -0
  31. package/dist/esm/polyfills/css-shim.js +1 -0
  32. package/dist/esm/polyfills/dom.js +79 -0
  33. package/dist/esm/polyfills/es5-html-element.js +1 -0
  34. package/dist/esm/polyfills/index.js +34 -0
  35. package/dist/esm/polyfills/system.js +6 -0
  36. package/dist/index.cjs.js +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/stencil.config.js +22 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-engagement-suite-jackpot-details/.stencil/packages/casino-engagement-suite-jackpot-details/stencil.config.d.ts +2 -0
  40. package/dist/types/components/casino-engagement-suite-jackpot-details/casino-engagement-suite-jackpot-details.d.ts +82 -0
  41. package/dist/types/components.d.ts +88 -0
  42. package/dist/types/index.d.ts +1 -0
  43. package/dist/types/models/index.d.ts +49 -0
  44. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  45. package/dist/types/utils/index.d.ts +1 -0
  46. package/dist/types/utils/locale.utils.d.ts +1 -0
  47. package/loader/cdn.js +3 -0
  48. package/loader/index.cjs.js +3 -0
  49. package/loader/index.d.ts +12 -0
  50. package/loader/index.es2017.js +3 -0
  51. package/loader/index.js +4 -0
  52. package/loader/package.json +10 -0
  53. package/package.json +19 -0
@@ -0,0 +1,460 @@
1
+ import { Component, Element, Event, h, Listen, Prop, State } from '@stencil/core';
2
+ import { translate } from '../../utils/locale.utils';
3
+ import '@everymatrix/casino-engagement-suite-progress-bar';
4
+ import { formatBalance } from '../../utils';
5
+ export class CasinoEngagementSuiteJackpotDetails {
6
+ constructor() {
7
+ /**
8
+ * Client custom styling via string
9
+ */
10
+ this.clientStyling = '';
11
+ /**
12
+ * Client custom styling via url
13
+ */
14
+ this.clientStylingUrl = '';
15
+ /**
16
+ * Language of the widget
17
+ */
18
+ this.language = 'en';
19
+ /**
20
+ * Current game slug
21
+ */
22
+ this.gameSlug = '';
23
+ /**
24
+ * User's device type
25
+ */
26
+ this.device = 'Mobile';
27
+ this.limitStylingAppends = false;
28
+ this.timer = '';
29
+ this.disabledStatus = '';
30
+ this.activeTab = 1;
31
+ this.visibleGames = [];
32
+ this.loading = false;
33
+ this.enabled = false;
34
+ this.showDetails = false;
35
+ this.maxVisibleGames = 0;
36
+ this.handleTabChange = (e) => {
37
+ this.activeTab = +(e.target.getAttribute('data-index'));
38
+ this.visibleGames = [];
39
+ this.maxVisibleGames = 0;
40
+ };
41
+ this.handleLoadMore = () => {
42
+ this.visibleGames = this.jackpot.GamesInfo.slice(0, this.visibleGames.length + this.maxVisibleGames);
43
+ };
44
+ this.toggleShowDetails = () => {
45
+ this.showDetails = !this.showDetails;
46
+ };
47
+ this.changeJackpotStatus = (ev) => {
48
+ ev.stopPropagation();
49
+ window.postMessage({
50
+ type: 'JackpotChangeStatusRequest',
51
+ data: {
52
+ [this.jackpot.Id]: !this.jackpot.Enabled,
53
+ },
54
+ });
55
+ this.loading = true;
56
+ };
57
+ this.setClientStyling = () => {
58
+ let sheet = document.createElement('style');
59
+ sheet.innerHTML = this.clientStyling;
60
+ this.host.prepend(sheet);
61
+ };
62
+ this.setClientStylingURL = () => {
63
+ let url = new URL(this.clientStylingUrl);
64
+ let cssFile = document.createElement('style');
65
+ fetch(url.href)
66
+ .then((res) => res.text())
67
+ .then((data) => {
68
+ cssFile.innerHTML = data;
69
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
70
+ })
71
+ .catch((err) => {
72
+ console.log('Error ', err);
73
+ });
74
+ };
75
+ this.handleCloseClick = () => {
76
+ this.close.emit();
77
+ };
78
+ this.handleBackClick = () => {
79
+ this.back.emit();
80
+ };
81
+ this.onGameClick = (ev) => {
82
+ const slug = ev.currentTarget.getAttribute('data-slug');
83
+ if (slug) {
84
+ window.postMessage({
85
+ type: 'EngagementSuiteGameRedirect',
86
+ data: {
87
+ Slug: slug
88
+ }
89
+ });
90
+ }
91
+ };
92
+ }
93
+ handleEvent(e) {
94
+ const { type, data } = e === null || e === void 0 ? void 0 : e.data;
95
+ switch (type) {
96
+ case 'UpdateJackpotStatus': {
97
+ this.updateJackpotStatus(e.data.data);
98
+ break;
99
+ }
100
+ case 'JoinJackpotResult': {
101
+ const res = data;
102
+ if (res.Success && this.jackpot.Id in res.JackpotIds) {
103
+ this.enabled = this.jackpot.Enabled = res.JackpotIds[this.jackpot.Id];
104
+ }
105
+ this.loading = false;
106
+ break;
107
+ }
108
+ case 'UpdateJackpotBalance': {
109
+ const jackpotUpdate = data
110
+ .find((updateMessage => updateMessage.JackpotId === this.jackpot.Id));
111
+ if (jackpotUpdate) {
112
+ this.balance = this.jackpot.Balance = jackpotUpdate.Balance;
113
+ this.winBalance = this.jackpot.WinBalance = jackpotUpdate.WinBalance;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ componentWillLoad() {
119
+ this.startCountdown();
120
+ this.enabled = this.jackpot.Enabled;
121
+ this.balance = this.jackpot.Balance;
122
+ this.winBalance = this.jackpot.WinBalance;
123
+ }
124
+ componentDidRender() {
125
+ if (!this.limitStylingAppends && this.host) {
126
+ if (this.clientStyling)
127
+ this.setClientStyling();
128
+ if (this.clientStylingUrl)
129
+ this.setClientStylingURL();
130
+ this.limitStylingAppends = true;
131
+ }
132
+ if (this.activeTab === 2 && !this.maxVisibleGames) {
133
+ const gap = this.device === 'Mobile' ? 10 : 12;
134
+ const gamesPerRow = this.device === 'Mobile' ? 4 : 5;
135
+ const availableWidth = this.gamesListWrapperEl.offsetWidth - (gap * (gamesPerRow - 1));
136
+ const gameElWidth = availableWidth / gamesPerRow;
137
+ const gameElHeight = (gameElWidth / 74 * 40) + gap;
138
+ this.maxVisibleGames = Math.floor(this.gamesListWrapperEl.offsetHeight / gameElHeight) * gamesPerRow;
139
+ this.visibleGames = this.jackpot.GamesInfo.slice(0, this.maxVisibleGames);
140
+ }
141
+ }
142
+ disconnectedCallback() {
143
+ this.clearInterval();
144
+ }
145
+ clearInterval() {
146
+ if (this.interval) {
147
+ clearInterval(this.interval);
148
+ this.interval = null;
149
+ }
150
+ }
151
+ updateJackpotStatus(event) {
152
+ if (event.IsClosed) {
153
+ this.clearInterval();
154
+ this.disabledStatus = event.Reason;
155
+ this.activeTab = 1;
156
+ }
157
+ else {
158
+ this.disabledStatus = '';
159
+ this.jackpot.JackpotEndTime = event.JackpotEndTime;
160
+ this.startCountdown();
161
+ }
162
+ }
163
+ getTopNavigationTemplate() {
164
+ return (h("div", { class: "JackpotDetailsNavigation" },
165
+ h("button", { class: "JackpotIconButton", onClick: this.handleBackClick },
166
+ h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/back.svg", alt: "back" })),
167
+ h("div", { class: "JackpotPopupName" }, translate('jackpots', this.language)),
168
+ h("button", { class: "JackpotIconButton", onClick: this.handleCloseClick },
169
+ h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "close" }))));
170
+ }
171
+ getJackpotBalance() {
172
+ return formatBalance(this.winBalance || this.balance, this.jackpot.Currency);
173
+ }
174
+ getJoinButtonClasses() {
175
+ return {
176
+ PopupButton: true,
177
+ Active: this.enabled,
178
+ Loading: this.loading
179
+ };
180
+ }
181
+ getJackpotDetailsHeaderTemplate() {
182
+ return (h("div", { class: "JackpotDetailsHeader" },
183
+ h("div", null,
184
+ h("div", { class: "JackpotType" }, this.jackpot.Type),
185
+ h("div", { class: "JackpotBalance" }, this.getJackpotBalance())),
186
+ h("div", { class: "JackpotDetailsHeaderSecondCol" },
187
+ h("button", { disabled: !!this.disabledStatus, onClick: this.changeJackpotStatus, class: this.getJoinButtonClasses() }, this.enabled
188
+ ? translate('unjoin', this.language)
189
+ : translate('join', this.language)),
190
+ this.winBalance && h("div", { class: "JackpotIsWon" }, translate('jackpotIsWon', this.language)))));
191
+ }
192
+ getTabsTemplate() {
193
+ return h("div", { class: "JackpotDetailsTabs" },
194
+ h("div", { "data-index": "1", onClick: this.handleTabChange, class: `JackpotDetailsTab ${this.activeTab === 1 ? 'Active' : ''}` }, translate('info', this.language)),
195
+ h("div", { "data-index": "2", onClick: this.handleTabChange, class: `JackpotDetailsTab ${this.activeTab === 2 ? 'Active' : ''}` }, translate('games', this.language)));
196
+ }
197
+ getTabsContentTemplate() {
198
+ return this.activeTab === 1
199
+ ? this.getJackpotInfoTemplate()
200
+ : this.getGamesTemplate();
201
+ }
202
+ getJackpotDetailsTemplate() {
203
+ return h("div", null,
204
+ h("div", { class: "JackpotDetailsButton", onClick: this.toggleShowDetails },
205
+ h("div", { class: `Toggle ${this.showDetails ? 'Closed' : 'Open'}` }),
206
+ h("span", null, translate('jackpotDetails', this.language))),
207
+ this.showDetails && h("p", { class: "JackpotDescription" }, this.jackpot.Description));
208
+ }
209
+ getJackpotInfoTemplate() {
210
+ return h("div", null,
211
+ this.jackpot.Description && this.getJackpotDetailsTemplate(),
212
+ h("div", { class: "JackpotInfo" },
213
+ h("div", { class: "JackpotInfoItem" },
214
+ translate('operatorContribution', this.language),
215
+ ":\u00A0",
216
+ h("span", null,
217
+ this.jackpot.OperatorContributionPercent,
218
+ "%")),
219
+ h("div", { class: "JackpotInfoItem" },
220
+ translate('type', this.language),
221
+ ":\u00A0",
222
+ h("span", null, this.jackpot.JackpotTypePresentation)),
223
+ h("div", { class: "JackpotInfoItem" },
224
+ translate('winningProbability', this.language),
225
+ ":\u00A0",
226
+ h("span", null,
227
+ "1:",
228
+ this.jackpot.Probability)),
229
+ this.jackpot.JackpotRulesUrl && h("div", { class: "JackpotInfoItem" },
230
+ h("a", { class: "tc", href: this.jackpot.JackpotRulesUrl, target: "_blank" }, translate('tc', this.jackpot.JackpotRulesUrl)))));
231
+ }
232
+ getGamesTemplate() {
233
+ const list = this.visibleGames.map((game) => {
234
+ return h("div", { onClick: this.onGameClick, class: `JackpotGamesListItem ${game.GameSlug === this.gameSlug ? 'Disabled' : ''}`, key: game.CasinoGameId, "data-slug": game.GameSlug, style: { background: `center / cover url(${game.GameIcon}) no-repeat` }, title: game.GameName });
235
+ });
236
+ return [
237
+ h("div", { class: "JackpotGamesListWrapper", ref: el => this.gamesListWrapperEl = el },
238
+ h("div", { class: "JackpotGamesList" }, list)),
239
+ this.visibleGames.length < this.jackpot.GamesInfo.length
240
+ ? h("button", { class: "PopupButton Active JackpotGamesButton", onClick: this.handleLoadMore }, translate('loadMore', this.language))
241
+ : ''
242
+ ];
243
+ }
244
+ getJackpotCountdown() {
245
+ const timerMessage = this.disabledStatus || this.timer;
246
+ return (h("div", { class: `JackpotCountdown ${this.disabledStatus ? 'Suspended' : ''}` }, timerMessage));
247
+ }
248
+ startCountdown() {
249
+ this.updateTimer();
250
+ this.interval = setInterval(() => {
251
+ this.updateTimer();
252
+ }, 1000);
253
+ }
254
+ updateTimer() {
255
+ const expirationTime = new Date(this.jackpot.JackpotEndTime).getTime();
256
+ const now = new Date().getTime();
257
+ const distance = expirationTime - now;
258
+ if (distance < 1) {
259
+ this.clearInterval();
260
+ return;
261
+ }
262
+ const { days, hours, minutes, seconds } = {
263
+ days: String(Math.floor(distance / (1000 * 60 * 60 * 24))).padStart(2, '0'),
264
+ hours: String(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
265
+ minutes: String(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
266
+ seconds: String(Math.floor((distance % (1000 * 60)) / 1000)).padStart(2, '0')
267
+ };
268
+ this.timer = days === '00'
269
+ ? `${hours}h:${minutes}m:${seconds}s`
270
+ : `${days}d:${hours}h:${minutes}m`;
271
+ }
272
+ getPopupClasses() {
273
+ return {
274
+ JackpotDetailsPopup: true,
275
+ Disabled: !!this.disabledStatus,
276
+ [this.device]: true,
277
+ [this.jackpot.Type.charAt(0).toUpperCase() + this.jackpot.Type.slice(1)]: true
278
+ };
279
+ }
280
+ render() {
281
+ return h("div", { class: this.getPopupClasses() },
282
+ this.getTopNavigationTemplate(),
283
+ h("div", { class: "JackpotDetailsPopupContent" },
284
+ this.getJackpotDetailsHeaderTemplate(),
285
+ this.getJackpotCountdown(),
286
+ this.getTabsTemplate(),
287
+ this.getTabsContentTemplate()));
288
+ }
289
+ static get is() { return "casino-engagement-suite-jackpot-details"; }
290
+ static get encapsulation() { return "shadow"; }
291
+ static get originalStyleUrls() { return {
292
+ "$": ["casino-engagement-suite-jackpot-details.scss"]
293
+ }; }
294
+ static get styleUrls() { return {
295
+ "$": ["casino-engagement-suite-jackpot-details.css"]
296
+ }; }
297
+ static get properties() { return {
298
+ "clientStyling": {
299
+ "type": "string",
300
+ "mutable": false,
301
+ "complexType": {
302
+ "original": "string",
303
+ "resolved": "string",
304
+ "references": {}
305
+ },
306
+ "required": false,
307
+ "optional": false,
308
+ "docs": {
309
+ "tags": [],
310
+ "text": "Client custom styling via string"
311
+ },
312
+ "attribute": "client-styling",
313
+ "reflect": true,
314
+ "defaultValue": "''"
315
+ },
316
+ "clientStylingUrl": {
317
+ "type": "string",
318
+ "mutable": false,
319
+ "complexType": {
320
+ "original": "string",
321
+ "resolved": "string",
322
+ "references": {}
323
+ },
324
+ "required": false,
325
+ "optional": false,
326
+ "docs": {
327
+ "tags": [],
328
+ "text": "Client custom styling via url"
329
+ },
330
+ "attribute": "client-styling-url",
331
+ "reflect": true,
332
+ "defaultValue": "''"
333
+ },
334
+ "jackpot": {
335
+ "type": "unknown",
336
+ "mutable": false,
337
+ "complexType": {
338
+ "original": "Jackpot",
339
+ "resolved": "Jackpot",
340
+ "references": {
341
+ "Jackpot": {
342
+ "location": "import",
343
+ "path": "../../models"
344
+ }
345
+ }
346
+ },
347
+ "required": false,
348
+ "optional": false,
349
+ "docs": {
350
+ "tags": [],
351
+ "text": "Selected jackpot"
352
+ }
353
+ },
354
+ "language": {
355
+ "type": "string",
356
+ "mutable": false,
357
+ "complexType": {
358
+ "original": "string",
359
+ "resolved": "string",
360
+ "references": {}
361
+ },
362
+ "required": false,
363
+ "optional": false,
364
+ "docs": {
365
+ "tags": [],
366
+ "text": "Language of the widget"
367
+ },
368
+ "attribute": "language",
369
+ "reflect": false,
370
+ "defaultValue": "'en'"
371
+ },
372
+ "gameSlug": {
373
+ "type": "string",
374
+ "mutable": false,
375
+ "complexType": {
376
+ "original": "string",
377
+ "resolved": "string",
378
+ "references": {}
379
+ },
380
+ "required": false,
381
+ "optional": false,
382
+ "docs": {
383
+ "tags": [],
384
+ "text": "Current game slug"
385
+ },
386
+ "attribute": "game-slug",
387
+ "reflect": false,
388
+ "defaultValue": "''"
389
+ },
390
+ "device": {
391
+ "type": "string",
392
+ "mutable": false,
393
+ "complexType": {
394
+ "original": "\"Mobile\" | \"Tablet\" | \"Desktop\"",
395
+ "resolved": "\"Desktop\" | \"Mobile\" | \"Tablet\"",
396
+ "references": {}
397
+ },
398
+ "required": false,
399
+ "optional": false,
400
+ "docs": {
401
+ "tags": [],
402
+ "text": "User's device type"
403
+ },
404
+ "attribute": "device",
405
+ "reflect": false,
406
+ "defaultValue": "'Mobile' as 'Mobile' | 'Tablet' | 'Desktop'"
407
+ }
408
+ }; }
409
+ static get states() { return {
410
+ "limitStylingAppends": {},
411
+ "timer": {},
412
+ "disabledStatus": {},
413
+ "activeTab": {},
414
+ "visibleGames": {},
415
+ "loading": {},
416
+ "enabled": {},
417
+ "balance": {},
418
+ "winBalance": {},
419
+ "showDetails": {}
420
+ }; }
421
+ static get events() { return [{
422
+ "method": "close",
423
+ "name": "close",
424
+ "bubbles": true,
425
+ "cancelable": true,
426
+ "composed": true,
427
+ "docs": {
428
+ "tags": [],
429
+ "text": ""
430
+ },
431
+ "complexType": {
432
+ "original": "void",
433
+ "resolved": "void",
434
+ "references": {}
435
+ }
436
+ }, {
437
+ "method": "back",
438
+ "name": "back",
439
+ "bubbles": true,
440
+ "cancelable": true,
441
+ "composed": true,
442
+ "docs": {
443
+ "tags": [],
444
+ "text": ""
445
+ },
446
+ "complexType": {
447
+ "original": "void",
448
+ "resolved": "void",
449
+ "references": {}
450
+ }
451
+ }]; }
452
+ static get elementRef() { return "host"; }
453
+ static get listeners() { return [{
454
+ "name": "message",
455
+ "method": "handleEvent",
456
+ "target": "window",
457
+ "capture": false,
458
+ "passive": false
459
+ }]; }
460
+ }
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export function formatBalance(amount, currency, maxAmount = 99999999) {
2
+ amount = Math.min(amount, maxAmount);
3
+ return `${currency} ${new Intl.NumberFormat('en', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
4
+ .format(amount)}`;
5
+ }
@@ -0,0 +1,22 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const SUPPORTED_LANGUAGES = ['en'];
3
+ const TRANSLATIONS = {
4
+ en: {
5
+ jackpots: 'Jackpots',
6
+ join: 'Join',
7
+ unjoin: 'Unjoin',
8
+ info: 'Info',
9
+ games: 'Games',
10
+ operatorContribution: 'Operator Contribution',
11
+ type: 'Type',
12
+ winningProbability: 'Winning Probability',
13
+ tc: 'Terms & Conditions',
14
+ jackpotIsWon: 'Jackpot’s won!',
15
+ loadMore: 'Load More',
16
+ jackpotDetails: 'Jackpot Details',
17
+ }
18
+ };
19
+ export const translate = (key, customLang) => {
20
+ const lang = customLang;
21
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
22
+ };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface CasinoEngagementSuiteJackpotDetails extends Components.CasinoEngagementSuiteJackpotDetails, HTMLElement {}
4
+ export const CasinoEngagementSuiteJackpotDetails: {
5
+ prototype: CasinoEngagementSuiteJackpotDetails;
6
+ new (): CasinoEngagementSuiteJackpotDetails;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;