@everymatrix/casino-engagement-suite-challenges-list 1.35.0 → 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 (26) hide show
  1. package/dist/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.esm.js +1 -1
  2. package/dist/casino-engagement-suite-challenges-list/p-26d7de05.entry.js +1 -0
  3. package/dist/casino-engagement-suite-challenges-list/p-fad4589e.js +1 -0
  4. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.js +2 -2
  5. package/dist/cjs/casino-engagement-suite-challenges-list_2.cjs.entry.js +513 -0
  6. package/dist/cjs/{index-79c88755.js → index-0a011384.js} +38 -1
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +8 -1
  9. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.css +34 -0
  10. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.js +128 -38
  11. package/dist/collection/utils/locale.utils.js +1 -0
  12. package/dist/components/casino-engagement-suite-challenges-list.js +97 -791
  13. package/dist/components/casino-engagement-suite-progress-bar.js +6 -0
  14. package/dist/components/casino-engagement-suite-progress-bar2.js +94 -0
  15. package/dist/esm/casino-engagement-suite-challenges-list.js +2 -2
  16. package/dist/esm/casino-engagement-suite-challenges-list_2.entry.js +508 -0
  17. package/dist/esm/{index-70e47fe0.js → index-ddf7e990.js} +38 -1
  18. package/dist/esm/loader.js +2 -2
  19. package/dist/types/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.d.ts +11 -0
  20. package/dist/types/components.d.ts +16 -0
  21. package/dist/types/models/challenge.d.ts +3 -0
  22. package/package.json +1 -1
  23. package/dist/casino-engagement-suite-challenges-list/p-7e171791.js +0 -1
  24. package/dist/casino-engagement-suite-challenges-list/p-eb36cbe7.entry.js +0 -1
  25. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.entry.js +0 -1147
  26. package/dist/esm/casino-engagement-suite-challenges-list.entry.js +0 -1143
@@ -279,6 +279,31 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
279
279
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
280
280
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
281
281
  }
282
+ else if (memberName === 'style') {
283
+ // update style attribute, css properties and values
284
+ {
285
+ for (const prop in oldValue) {
286
+ if (!newValue || newValue[prop] == null) {
287
+ if (prop.includes('-')) {
288
+ elm.style.removeProperty(prop);
289
+ }
290
+ else {
291
+ elm.style[prop] = '';
292
+ }
293
+ }
294
+ }
295
+ }
296
+ for (const prop in newValue) {
297
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
298
+ if (prop.includes('-')) {
299
+ elm.style.setProperty(prop, newValue[prop]);
300
+ }
301
+ else {
302
+ elm.style[prop] = newValue[prop];
303
+ }
304
+ }
305
+ }
306
+ }
282
307
  else if (memberName === 'key')
283
308
  ;
284
309
  else if ((!isProp ) &&
@@ -547,11 +572,14 @@ const patch = (oldVNode, newVNode) => {
547
572
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
548
573
  const oldChildren = oldVNode.$children$;
549
574
  const newChildren = newVNode.$children$;
575
+ const tag = newVNode.$tag$;
550
576
  const text = newVNode.$text$;
551
577
  if (text === null) {
552
578
  // element node
553
579
  {
554
- {
580
+ if (tag === 'slot')
581
+ ;
582
+ else {
555
583
  // either this is the first render of an element OR it's an update
556
584
  // AND we already know it's possible it could have changed
557
585
  // this updates the element's css classes, attrs, props, listeners, etc.
@@ -819,6 +847,15 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
819
847
  const parsePropertyValue = (propValue, propType) => {
820
848
  // ensure this value is of the correct prop type
821
849
  if (propValue != null && !isComplexType(propValue)) {
850
+ if (propType & 4 /* Boolean */) {
851
+ // per the HTML spec, any string value means it is a boolean true value
852
+ // but we'll cheat here and say that the string "false" is the boolean false
853
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
854
+ }
855
+ if (propType & 2 /* Number */) {
856
+ // force it to be a number
857
+ return parseFloat(propValue);
858
+ }
822
859
  if (propType & 1 /* String */) {
823
860
  // could have been passed as a number or boolean
824
861
  // but we still want it as a string
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-79c88755.js');
5
+ const index = require('./index-0a011384.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["casino-engagement-suite-challenges-list.cjs",[[1,"casino-engagement-suite-challenges-list",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[1],"device":[1],"challenges":[1040],"tooltip":[32],"timers":[32],"limitStylingAppends":[32]},[[8,"message","handleEvent"]]]]]], options);
17
+ return index.bootstrapLazy([["casino-engagement-suite-challenges-list_2.cjs",[[1,"casino-engagement-suite-challenges-list",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[1],"device":[1],"challenges":[1040],"isJoiningToChallenge":[1028,"is-joining-to-challenge"],"inProgressChallenges":[1040],"tooltip":[32],"timers":[32],"limitStylingAppends":[32],"newChallengeIds":[32],"pausedChallengeIds":[32]},[[8,"message","handleEvent"]]],[1,"casino-engagement-suite-progress-bar",{"value":[2],"disabled":[4],"hidePercent":[4,"hide-percent"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"limitStylingAppends":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -7,6 +7,13 @@
7
7
  "version": "2.15.2",
8
8
  "typescriptVersion": "4.5.4"
9
9
  },
10
- "collections": [],
10
+ "collections": [
11
+ {
12
+ "name": "@everymatrix/casino-engagement-suite-progress-bar",
13
+ "tags": [
14
+ "casino-engagement-suite-progress-bar"
15
+ ]
16
+ }
17
+ ],
11
18
  "bundles": []
12
19
  }
@@ -70,6 +70,7 @@ button:focus {
70
70
  border: 1px solid var(--emw--button-border-color, #403956);
71
71
  border-radius: 6px;
72
72
  position: relative;
73
+ cursor: pointer;
73
74
  }
74
75
 
75
76
  .ChallengeJoinButton.Joined::before,
@@ -123,6 +124,12 @@ button:focus {
123
124
  border-radius: 99px;
124
125
  }
125
126
 
127
+ .Disabled {
128
+ opacity: 0.5;
129
+ pointer-events: none;
130
+ cursor: auto;
131
+ }
132
+
126
133
  .ChallengesListEmpty {
127
134
  padding: 20px 32px;
128
135
  }
@@ -149,6 +156,33 @@ button:focus {
149
156
  line-height: 12px;
150
157
  }
151
158
 
159
+ .ChallengeLabel {
160
+ min-width: 35px;
161
+ height: 18px;
162
+ background: linear-gradient(180deg, #FFB801 15.86%, #FEF746 31.36%, #FBFFE0 36.86%, #FFFA60 47.86%, #FF9400 87.36%);
163
+ border-radius: 2px;
164
+ display: none;
165
+ position: absolute;
166
+ top: -11px;
167
+ right: 11px;
168
+ padding: 0 2px;
169
+ align-items: center;
170
+ justify-content: center;
171
+ }
172
+ .ChallengeLabel span {
173
+ display: inline-block;
174
+ text-transform: uppercase;
175
+ font-size: 10px;
176
+ line-height: 10px;
177
+ font-weight: 700;
178
+ font-family: "Montserrat", sans-serif;
179
+ color: var(--emw--color-typography, #1E1638);
180
+ }
181
+
182
+ .ShowChallengeLabel {
183
+ display: inline-flex;
184
+ }
185
+
152
186
  .ChallengesTooltipBackdrop {
153
187
  padding: 48px 30px 0;
154
188
  position: absolute;
@@ -2,7 +2,6 @@ import { Component, Element, Event, h, Listen, Prop, State, Watch } from '@stenc
2
2
  import { ChallengeLevelProgressStatus, ChallengeProgressStatus } from '../../models/challenge';
3
3
  import { translate } from '../../utils/locale.utils';
4
4
  import '@everymatrix/casino-engagement-suite-progress-bar';
5
- import intervalToDuration from 'date-fns/intervalToDuration';
6
5
  import differenceInSeconds from 'date-fns/differenceInSeconds';
7
6
  export class CasinoEngagementSuiteChallengesList {
8
7
  constructor() {
@@ -29,6 +28,8 @@ export class CasinoEngagementSuiteChallengesList {
29
28
  this.tooltip = false;
30
29
  this.timers = {};
31
30
  this.limitStylingAppends = false;
31
+ this.newChallengeIds = [];
32
+ this.pausedChallengeIds = [];
32
33
  this.setClientStyling = () => {
33
34
  let sheet = document.createElement('style');
34
35
  sheet.innerHTML = this.clientStyling;
@@ -50,10 +51,12 @@ export class CasinoEngagementSuiteChallengesList {
50
51
  this.handleCloseClick = () => {
51
52
  this.close.emit();
52
53
  this.tooltip = false;
54
+ this.newChallengeIds = [];
53
55
  };
54
56
  this.handleChallengeClick = (ev) => {
55
57
  const id = +ev.currentTarget.getAttribute('data-id');
56
- window.postMessage({ type: `ChallengeClick`, id });
58
+ window.postMessage({ type: 'ChallengeClick', id });
59
+ this.newChallengeIds = this.newChallengeIds.filter(item => item !== id);
57
60
  };
58
61
  this.showTooltip = () => {
59
62
  this.tooltip = true;
@@ -61,6 +64,32 @@ export class CasinoEngagementSuiteChallengesList {
61
64
  this.hideTooltip = () => {
62
65
  this.tooltip = false;
63
66
  };
67
+ this.changeChallengeStatus = (e) => {
68
+ var _a, _b;
69
+ e.stopPropagation();
70
+ const id = +e.currentTarget.getAttribute('data-id');
71
+ if ((_a = this.inProgressChallenges) === null || _a === void 0 ? void 0 : _a.includes(id)) {
72
+ window.postMessage({
73
+ type: 'ShowConfirmationModal',
74
+ ProgressToDeactivate: id,
75
+ });
76
+ return;
77
+ }
78
+ if (((_b = this.inProgressChallenges) === null || _b === void 0 ? void 0 : _b.length) > 0) {
79
+ window.postMessage({
80
+ type: 'ShowConfirmationModal',
81
+ ProgressToActivate: id,
82
+ ProgressToDeactivate: this.inProgressChallenges[0],
83
+ });
84
+ return;
85
+ }
86
+ window.postMessage({
87
+ type: 'ChallengeJoinRequest',
88
+ data: {
89
+ ProgressToActivate: id,
90
+ },
91
+ });
92
+ };
64
93
  }
65
94
  challengesPropHandler(value) {
66
95
  if (!this.interval && value.length) {
@@ -72,19 +101,42 @@ export class CasinoEngagementSuiteChallengesList {
72
101
  }
73
102
  }
74
103
  handleEvent(e) {
75
- const newChallenge = e.data.data;
76
- if (e.data.type === 'ChallengeGrant') {
77
- const index = this.challenges.findIndex(challenge => differenceInSeconds(new Date(challenge.ExpirationTime), new Date(newChallenge.ExpirationTime)) > 0);
78
- if (index > -1) {
79
- this.challenges.splice(index, 0, newChallenge);
104
+ const type = e.data.type;
105
+ switch (type) {
106
+ case 'ChallengeGrant': {
107
+ const newChallenge = e.data.data;
108
+ const index = this.challenges.findIndex(challenge => differenceInSeconds(new Date(challenge.ExpirationTime), new Date(newChallenge.ExpirationTime)) > 0);
109
+ if (index > -1) {
110
+ this.challenges.splice(index, 0, newChallenge);
111
+ }
112
+ else {
113
+ this.challenges.unshift(newChallenge);
114
+ }
115
+ this.challenges = [...this.challenges];
116
+ this.newChallengeIds.push(newChallenge.Id);
117
+ window.postMessage({ type: 'UpdateChallenges' });
118
+ break;
80
119
  }
81
- else {
82
- this.challenges.unshift(newChallenge);
120
+ case 'ChallengeChangeStatusNotification': {
121
+ const isEnabled = e.data.data.IsEnabled;
122
+ const id = e.data.data.ChallengeId;
123
+ if (!isEnabled) {
124
+ this.pausedChallengeIds.push(id);
125
+ }
126
+ else {
127
+ this.pausedChallengeIds = this.pausedChallengeIds.filter(c => c !== id);
128
+ }
129
+ break;
83
130
  }
84
131
  }
85
132
  }
86
133
  componentWillLoad() {
134
+ var _a;
87
135
  this.challengesPropHandler(this.challenges);
136
+ if ((_a = this.challenges) === null || _a === void 0 ? void 0 : _a.length) {
137
+ this.newChallengeIds = this.challenges.filter(challenge => challenge.IsNew)
138
+ .map(challenge => challenge.Id);
139
+ }
88
140
  }
89
141
  componentDidRender() {
90
142
  if (!this.limitStylingAppends && this.host) {
@@ -104,23 +156,21 @@ export class CasinoEngagementSuiteChallengesList {
104
156
  }, 1000);
105
157
  }
106
158
  updateTimers() {
107
- const now = new Date();
159
+ const now = new Date().getTime();
108
160
  this.timers = this.challenges.filter(challenge => challenge.Status !== ChallengeProgressStatus.Expired).reduce((acc, challenge) => {
109
- const expirationDate = new Date(challenge.ExpirationTime);
110
- const diff = differenceInSeconds(expirationDate, now);
111
- const duration = intervalToDuration({
112
- start: now,
113
- end: expirationDate
114
- });
161
+ const expirationDate = new Date(challenge.ExpirationTime).getTime();
162
+ const diff = expirationDate - now;
115
163
  let countdown = '00h:00m:00s';
116
164
  if (diff < 1) {
117
165
  this.removeChallenge(challenge.Id);
118
166
  }
119
167
  else {
120
- const days = duration.days.toString().padStart(2, '0');
121
- const hours = duration.hours.toString().padStart(2, '0');
122
- const minutes = duration.minutes.toString().padStart(2, '0');
123
- const seconds = duration.seconds.toString().padStart(2, '0');
168
+ const { days, hours, minutes, seconds } = {
169
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
170
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
171
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
172
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
173
+ };
124
174
  countdown = days === '00'
125
175
  ? `${hours}h:${minutes}m:${seconds}s`
126
176
  : `${days}d:${hours}h:${minutes}m`;
@@ -138,14 +188,16 @@ export class CasinoEngagementSuiteChallengesList {
138
188
  getChallengeClasses(challenge) {
139
189
  return {
140
190
  ChallengeCard: true,
141
- InProgress: challenge.Status === ChallengeProgressStatus.InProgress,
191
+ InProgress: challenge.Status === ChallengeProgressStatus.InProgress
192
+ && !this.pausedChallengeIds.includes(challenge.Id),
142
193
  Completed: this.isChallengeCompleted(challenge),
143
194
  Paused: this.isChallengePaused(challenge)
144
195
  };
145
196
  }
146
197
  isChallengePaused(challenge) {
147
- return challenge.Status === ChallengeProgressStatus.Started
148
- && challenge.LevelProgresses[0].ProgressPercentage > 0;
198
+ return (challenge.Status === ChallengeProgressStatus.Started
199
+ && challenge.LevelProgresses[0].ProgressPercentage > 0)
200
+ || this.pausedChallengeIds.includes(challenge.Id);
149
201
  }
150
202
  isChallengeCompleted(challenge) {
151
203
  return challenge.Status === ChallengeProgressStatus.Completed
@@ -172,22 +224,27 @@ export class CasinoEngagementSuiteChallengesList {
172
224
  return -1;
173
225
  }
174
226
  getChallengeHeaderTemplate(challenge) {
227
+ const { Id } = challenge;
175
228
  return h("div", { class: "ChallengeCardHeader" },
176
229
  h("div", { class: "ChallengeName" }, challenge.ChallengePresentation.PresentationName),
177
- h("button", { class: challenge.Status === ChallengeProgressStatus.InProgress ? 'ChallengeJoinButton Joined' : 'ChallengeJoinButton' }, challenge.Status === ChallengeProgressStatus.InProgress
230
+ h("button", { class: `${challenge.Status === ChallengeProgressStatus.InProgress ?
231
+ 'ChallengeJoinButton Joined' : 'ChallengeJoinButton'} ${this.isJoiningToChallenge ? 'Disabled' : ''}`, onClick: this.changeChallengeStatus, "data-id": Id }, challenge.Status === ChallengeProgressStatus.InProgress
178
232
  ? translate('unjoin', this.language)
179
233
  : translate('join', this.language)));
180
234
  }
181
235
  getChallengeTemplate(challenge) {
182
236
  const challengeProgress = this.getChallengeProgress(challenge);
183
237
  const countdown = this.timers[challenge.Id];
238
+ const isNewChallenge = this.newChallengeIds.includes(challenge.Id);
184
239
  const progressTemplate = challengeProgress > -1
185
240
  ? h("casino-engagement-suite-progress-bar", { class: this.device, value: challengeProgress, disabled: this.isChallengePaused(challenge) },
186
241
  h("span", { slot: "Title", class: "ChallengeCountdown" }, countdown))
187
242
  : h("span", { class: "ChallengeCountdown" }, countdown);
188
243
  return (h("div", { class: this.getChallengeClasses(challenge), onClick: this.handleChallengeClick, key: challenge.Id, "data-id": challenge.Id },
189
244
  this.getChallengeHeaderTemplate(challenge),
190
- progressTemplate));
245
+ progressTemplate,
246
+ h("div", { class: `ChallengeLabel ${isNewChallenge ? 'ShowChallengeLabel' : ''}` },
247
+ h("span", null, translate('new', this.language)))));
191
248
  }
192
249
  getHeaderTemplate() {
193
250
  return h("header", { class: "ChallengesListPopupHeader" },
@@ -195,7 +252,7 @@ export class CasinoEngagementSuiteChallengesList {
195
252
  h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg", alt: "Show tooltip" })),
196
253
  h("div", { class: "ChallengesListPopupHeaderName" }, translate('challenges', this.language)),
197
254
  h("button", { class: "ChallengesIconButton", onClick: this.handleCloseClick },
198
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "\u0421lose challenges list" })));
255
+ h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close challenges list" })));
199
256
  }
200
257
  getListTemplate() {
201
258
  if (this.challenges.length) {
@@ -209,22 +266,17 @@ export class CasinoEngagementSuiteChallengesList {
209
266
  }
210
267
  }
211
268
  getTooltipTemplate() {
212
- if (this.tooltip) {
213
- return h("div", { class: "ChallengesTooltipBackdrop" },
214
- h("div", { class: "ChallengesTooltip" },
215
- h("button", { class: "ChallengesIconButton", onClick: this.hideTooltip },
216
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "\u0421lose tooltip" })),
217
- translate('tooltip', this.language)));
218
- }
219
- else {
220
- return '';
221
- }
269
+ return h("div", { class: "ChallengesTooltipBackdrop" },
270
+ h("div", { class: "ChallengesTooltip" },
271
+ h("button", { class: "ChallengesIconButton", onClick: this.hideTooltip },
272
+ h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close tooltip" })),
273
+ translate('tooltip', this.language)));
222
274
  }
223
275
  render() {
224
276
  return h("div", { class: `ChallengesListPopup ${this.device}` },
225
277
  this.getHeaderTemplate(),
226
278
  this.getListTemplate(),
227
- this.getTooltipTemplate());
279
+ this.tooltip && this.getTooltipTemplate());
228
280
  }
229
281
  static get is() { return "casino-engagement-suite-challenges-list"; }
230
282
  static get encapsulation() { return "shadow"; }
@@ -330,12 +382,50 @@ export class CasinoEngagementSuiteChallengesList {
330
382
  "text": "List of challenges"
331
383
  },
332
384
  "defaultValue": "[] as Array<Challenge>"
385
+ },
386
+ "isJoiningToChallenge": {
387
+ "type": "boolean",
388
+ "mutable": true,
389
+ "complexType": {
390
+ "original": "boolean",
391
+ "resolved": "boolean",
392
+ "references": {}
393
+ },
394
+ "required": false,
395
+ "optional": false,
396
+ "docs": {
397
+ "tags": [],
398
+ "text": "Is joining to challenge"
399
+ },
400
+ "attribute": "is-joining-to-challenge",
401
+ "reflect": false
402
+ },
403
+ "inProgressChallenges": {
404
+ "type": "unknown",
405
+ "mutable": true,
406
+ "complexType": {
407
+ "original": "Array<number>",
408
+ "resolved": "number[]",
409
+ "references": {
410
+ "Array": {
411
+ "location": "global"
412
+ }
413
+ }
414
+ },
415
+ "required": false,
416
+ "optional": false,
417
+ "docs": {
418
+ "tags": [],
419
+ "text": "Active challenges"
420
+ }
333
421
  }
334
422
  }; }
335
423
  static get states() { return {
336
424
  "tooltip": {},
337
425
  "timers": {},
338
- "limitStylingAppends": {}
426
+ "limitStylingAppends": {},
427
+ "newChallengeIds": {},
428
+ "pausedChallengeIds": {}
339
429
  }; }
340
430
  static get events() { return [{
341
431
  "method": "close",
@@ -5,6 +5,7 @@ const TRANSLATIONS = {
5
5
  challenges: 'Challenges',
6
6
  join: 'Join',
7
7
  unjoin: 'Unjoin',
8
+ new: 'new',
8
9
  noChallenges: 'No Challenges yet',
9
10
  tryOtherGames: 'Try winning Challenges as rewards or launching other booster games',
10
11
  tooltip: 'Competition where your real money bets contribute towards the level progress to achieve the level reward'