@everymatrix/lottery-ticket 0.1.2 → 0.1.6

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.
@@ -75,8 +75,8 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
75
75
  }
76
76
  };
77
77
  const getHostListenerTarget = (elm, flags) => {
78
- if (flags & 4 /* TargetDocument */)
79
- return doc;
78
+ if (flags & 8 /* TargetWindow */)
79
+ return win;
80
80
  return elm;
81
81
  };
82
82
  // prettier-ignore
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-3626c135.js');
5
+ const index = require('./index-7d839bfc.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([["lottery-bullet_3.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32]},[[0,"gridFilled","gridFilledHandler"]]],[1,"lottery-grid",{"ticketId":[2,"ticket-id"],"totalNumbers":[2,"total-numbers"],"gameId":[1,"game-id"],"maximumAllowed":[2,"maximum-allowed"],"minimumAllowed":[2,"minimum-allowed"],"selectable":[4],"selectedNumbers":[1,"selected-numbers"],"displaySelected":[4,"display-selected"],"language":[1],"gridIndex":[2,"grid-index"],"numbers":[32]},[[0,"lotteryBulletSelection","lotteryBulletSelectionHandler"],[4,"resetSelection","resetSelectionHandler"],[4,"autoSelection","autoSelectionHandler"]]],[1,"lottery-bullet",{"value":[1],"selectable":[4],"isSelected":[4,"is-selected"]}]]]], options);
17
+ return index.bootstrapLazy([["lottery-ticket.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32],"isCustomSelect":[32],"amountInfo":[32]},[[8,"click","checkForClickOutside"],[0,"gridFilled","gridFilledHandler"]]]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-7d839bfc.js');
6
+ require('@everymatrix/lottery-grid');
7
+
8
+ const DEFAULT_LANGUAGE = 'en';
9
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
10
+ const TRANSLATIONS = {
11
+ en: {
12
+ loading: 'Loading, please wait ...',
13
+ error: 'It was an error while trying to fetch the data',
14
+ grid: 'Grid',
15
+ multiplier: 'Multiplier',
16
+ numberOfDraws: 'Number of draws',
17
+ wagerPerDraw: 'Wager per draw',
18
+ resetButton: 'Reset',
19
+ autoButton: 'I feel lucky'
20
+ },
21
+ ro: {
22
+ loading: 'Se incarca, va rugam asteptati ...',
23
+ error: 'A fost o eroare in timp ce asteptam datele',
24
+ grid: 'Grid',
25
+ multiplier: 'Multiplicator',
26
+ numberOfDraws: 'Numarul de extrageri',
27
+ wagerPerDraw: 'Pariul per extragere',
28
+ resetButton: 'Reseteaza',
29
+ autoButton: 'Ma simt norocos'
30
+ },
31
+ };
32
+ const translate = (key, customLang) => {
33
+ const lang = customLang;
34
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
35
+ };
36
+
37
+ const lotteryTicketCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.TicketTitle{font-size:16px;font-weight:bold}.ButtonContainer{display:flex;justify-content:flex-end}.Toggle{cursor:pointer;margin-top:20px;display:inline-block}.ToggleSwitch{display:inline-block;background:#707070;border-radius:16px;width:58px;height:24px;position:relative;vertical-align:middle;transition:background 0.25s}.ToggleSwitch:before,.ToggleSwitch:after{content:\"\"}.ToggleSwitch:before{display:block;background:linear-gradient(to bottom, #fff 0%, #F1F1F1 100%);border-radius:50%;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25);width:16px;height:16px;position:absolute;top:4px;left:4px;transition:left 0.25s}.Toggle:hover .ToggleSwitch:before{background:linear-gradient(to bottom, #fff 0%, #fff 100%);box-shadow:0 0 0 1px rgba(0, 0, 0, 0.5)}.ToggleCheckbox:checked+.ToggleSwitch{background:#00ABA4}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{margin-right:5px;position:relative;top:2px;font-size:14px;font-weight:lighter;color:#000}input[type=number]{-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.NumberInput,.WagerInput{margin-top:10px;display:inline-flex;align-items:center}.NumberInput,.NumberInput *{box-sizing:border-box}.NumberInput button{cursor:pointer;outline:none;-webkit-appearance:none;border:none;align-items:center;justify-content:center;height:20px;position:relative}.NumberInput button:after{display:inline-block;position:absolute;transform:translate(-50%, -50%) rotate(180deg);align-items:center;text-align:center}.NumberInput button.Plus:after{transform:translate(-50%, -50%) rotate(0deg);width:30px;display:inline-flex;align-items:center;text-align:center}.NumberInput input[type=number],.WagerInput input[type=number]{max-width:50px;display:inline-flex;align-items:center;padding:4px 10px;text-align:center}.NumberInput input[type=number] .WagerInputTitle,.WagerInput input[type=number] .WagerInputTitle{font-size:14px;color:#000;padding:10px}.InputDefault{background-color:#F1F1F1;border-radius:4px;padding:5px;border:solid 1px #D4D4D4;color:#707070}.AutoButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.AutoButton:active{background:#00958f;color:#FFF}.ResetButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ResetButton:hover{background:#FF6536;border:1px solid #FF3D00}.TicketGridBullets{background:#f1f1f1;border-radius:4px;padding:20px;margin-top:5px}.TicketGridBullets .TicketGridTitle{margin-top:0px}.Minus{border-radius:4px;width:30px;height:24px !important;margin-right:10px;color:#FFF;background:#009993}.Plus{border-radius:4px;width:30px;height:24px !important;margin-left:10px;color:#FFF;background:#009993}.SelectWrapper{width:auto;padding:5px;margin:0 auto;border:1px solid #ccc;border-radius:5px;position:relative}.SelectButton,.SelectOptions li{display:flex;align-items:center;cursor:pointer}.SelectButton{display:flex;padding:0 5px;border-radius:7px;align-items:center;justify-content:space-between;font-size:14px}.SelectButton span:first-child{padding-right:10px}.SelectExpand{transition:transform 0.3s linear;font-size:12px}.SelectActive .SelectExpand{transform:rotate(180deg)}.SelectContent{display:none;padding:5px;border-radius:7px}.SelectWrapper.SelectActive .SelectContent{width:100%;display:block;position:absolute;left:0;top:32px;padding:0;border:1px solid #ccc;overflow:hidden;background:#fff}.SelectContent .SelectOptions{max-height:100px;margin:0;overflow-y:auto;padding:0}.SelectContent .SelectOptions .SelectedValue{background-color:#009993;color:#fff}.SelectOptions::-webkit-scrollbar{width:7px}.SelectOptions::-webkit-scrollbar-track{background:#f1f1f1;border-radius:25px}.SelectOptions::-webkit-scrollbar-thumb{background:#ccc;border-radius:25px}.SelectOptions li{height:20px;padding:0 13px;font-size:14px}.SelectOptions li:hover{background:#f2f2f2}";
38
+
39
+ const LotteryTicket = class {
40
+ constructor(hostRef) {
41
+ index.registerInstance(this, hostRef);
42
+ this.ticketCompleted = index.createEvent(this, "ticketCompleted", 7);
43
+ this.autoSelection = index.createEvent(this, "autoSelection", 7);
44
+ this.resetSelection = index.createEvent(this, "resetSelection", 7);
45
+ this.stakeChange = index.createEvent(this, "stakeChange", 7);
46
+ this.multiplierChange = index.createEvent(this, "multiplierChange", 7);
47
+ /**
48
+ * Number of grids of a ticket
49
+ */
50
+ this.numberOfGrids = 1;
51
+ /**
52
+ * Option to have the ticket registered for multiple draws
53
+ */
54
+ this.multipleDraws = true;
55
+ /**
56
+ * Shows the reset button
57
+ */
58
+ this.resetButton = false;
59
+ /**
60
+ * Shows the auto-pick button
61
+ */
62
+ this.autoPick = false;
63
+ /**
64
+ * Language
65
+ */
66
+ this.language = 'en';
67
+ this.multiplier = false;
68
+ this.numberOfDraws = 1;
69
+ this.isLoading = true;
70
+ this.hasErrors = false;
71
+ this.ticketDone = false;
72
+ this.isCustomSelect = false;
73
+ this.amountInfo = {};
74
+ }
75
+ /**
76
+ * @TODO find a better way to implement click outside the custom select, so that we don't have to use the 'data-cluster' attribute on each element
77
+ */
78
+ checkForClickOutside(ev) {
79
+ if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
80
+ this.isCustomSelect = false;
81
+ }
82
+ }
83
+ connectedCallback() {
84
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
85
+ fetch(url.href)
86
+ .then((response) => {
87
+ if (response.ok) {
88
+ return response.json();
89
+ }
90
+ else {
91
+ // Throw error
92
+ this.hasErrors = true;
93
+ }
94
+ })
95
+ .then((data) => {
96
+ this.isLoading = false;
97
+ this.gameData = data;
98
+ this.grids = [...Array(data.rules.boards.length).keys()];
99
+ this.amountInfo = this.gameData.rules.stakes[0]; // initial value for select
100
+ })
101
+ .catch((err) => {
102
+ this.isLoading = false;
103
+ this.hasErrors = true;
104
+ console.error('Error!', err);
105
+ });
106
+ }
107
+ multiplierChangeHandler(e) {
108
+ this.multiplier = e.target ? e.target.checked : false;
109
+ this.multiplierChange.emit(this.multiplier);
110
+ }
111
+ drawsChangeHandler(event) {
112
+ this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
113
+ this.ticketCompleted.emit(this.ticket);
114
+ }
115
+ gridFilledHandler(event) {
116
+ this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
117
+ this.ticketDone = true;
118
+ this.ticketCompleted.emit(this.ticket);
119
+ }
120
+ toggleAutoSelection() {
121
+ this.ticketDone = true;
122
+ this.autoSelection.emit(this.ticketId);
123
+ }
124
+ toggleResetSelection() {
125
+ this.ticketDone = false;
126
+ this.resetSelection.emit(this.ticketId);
127
+ }
128
+ changeStake(ticketid, amount) {
129
+ this.stakeChange.emit({
130
+ ticketId: ticketid,
131
+ stake: amount
132
+ });
133
+ }
134
+ toggleClass() {
135
+ this.isCustomSelect = !this.isCustomSelect;
136
+ }
137
+ setDropdownItem(item) {
138
+ this.amountInfo = {
139
+ amount: item.amount,
140
+ currency: item.currency
141
+ };
142
+ this.isCustomSelect = false;
143
+ this.changeStake(this.ticketId, item.amount);
144
+ }
145
+ render() {
146
+ if (this.isLoading) {
147
+ return (index.h("div", null, index.h("p", null, translate('loading', this.language))));
148
+ }
149
+ else {
150
+ if (this.hasErrors) {
151
+ return (index.h("div", null, index.h("p", null, translate('error', this.language))));
152
+ }
153
+ else {
154
+ const { rules } = this.gameData;
155
+ return (index.h("div", { class: "TicketContainer" }, index.h("p", { class: "TicketTitle" }, this.gameData.name), this.resetButton && this.ticketDone &&
156
+ index.h("div", { class: "ButtonContainer" }, index.h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language))), this.autoPick && !this.ticketDone &&
157
+ index.h("div", { class: "ButtonContainer" }, index.h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language))), this.grids.map((item, index$1) => index.h("div", { class: "TicketGridBullets" }, index.h("p", { class: "TicketGridTitle" }, translate('grid', this.language), " ", item), index.h("lottery-grid", { "grid-index": index$1, "maximum-allowed": rules.boards[index$1].maximumAllowed, "minimum-allowed": rules.boards[index$1].minimumAllowed, "total-numbers": rules.boards[index$1].totalNumbers, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language }))), rules.multiplier &&
158
+ index.h("div", null, index.h("label", { class: "Toggle" }, index.h("label", { class: "Label" }, translate('multiplier', this.language), ": "), index.h("input", { class: "ToggleCheckbox", type: "checkbox", onInput: (e) => this.multiplierChangeHandler(e) }), index.h("div", { class: "ToggleSwitch" }))), this.multipleDraws &&
159
+ index.h("div", { class: "TicketDraws" }, index.h("label", { class: "Label" }, translate('numberOfDraws', this.language), ": "), index.h("div", { class: "NumberInput" }, index.h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), index.h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), index.h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), index.h("div", null, index.h("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), index.h("div", { class: "WagerInput" }, rules.stakes.length > 1 ?
160
+ (index.h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" }, index.h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() }, index.h("span", { "data-cluster": "SelectComponent" }, this.amountInfo.amount, " ", this.amountInfo.currency), index.h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")), index.h("div", { "data-cluster": "SelectComponent", class: "SelectContent" }, index.h("ul", { "data-cluster": "SelectComponent", class: "SelectOptions" }, rules.stakes.map((item) => index.h("li", { "data-cluster": "SelectComponent", class: this.amountInfo.amount == item.amount ? 'SelectedValue' : '', value: item.amount, onClick: () => this.setDropdownItem(item) }, item.amount, " ", item.currency)))))) : (index.h("div", null, index.h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }), index.h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))))));
161
+ }
162
+ }
163
+ }
164
+ static get watchers() { return {
165
+ "numberOfDraws": ["drawsChangeHandler"]
166
+ }; }
167
+ };
168
+ LotteryTicket.style = lotteryTicketCss;
169
+
170
+ exports.lottery_ticket = LotteryTicket;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-3626c135.js');
3
+ const index = require('./index-7d839bfc.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["lottery-bullet_3.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32]},[[0,"gridFilled","gridFilledHandler"]]],[1,"lottery-grid",{"ticketId":[2,"ticket-id"],"totalNumbers":[2,"total-numbers"],"gameId":[1,"game-id"],"maximumAllowed":[2,"maximum-allowed"],"minimumAllowed":[2,"minimum-allowed"],"selectable":[4],"selectedNumbers":[1,"selected-numbers"],"displaySelected":[4,"display-selected"],"language":[1],"gridIndex":[2,"grid-index"],"numbers":[32]},[[0,"lotteryBulletSelection","lotteryBulletSelectionHandler"],[4,"resetSelection","resetSelectionHandler"],[4,"autoSelection","autoSelectionHandler"]]],[1,"lottery-bullet",{"value":[1],"selectable":[4],"isSelected":[4,"is-selected"]}]]]], options);
18
+ return index.bootstrapLazy([["lottery-ticket.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32],"isCustomSelect":[32],"amountInfo":[32]},[[8,"click","checkForClickOutside"],[0,"gridFilled","gridFilledHandler"]]]]]], options);
19
19
  });
@@ -7,19 +7,12 @@
7
7
  "version": "2.15.2",
8
8
  "typescriptVersion": "4.5.4"
9
9
  },
10
- "collections": [
10
+ "collections": [],
11
+ "bundles": [
11
12
  {
12
- "name": "@everymatrix/lottery-bullet",
13
- "tags": [
14
- "lottery-bullet"
15
- ]
16
- },
17
- {
18
- "name": "@everymatrix/lottery-grid",
19
- "tags": [
20
- "lottery-grid"
13
+ "components": [
14
+ "lottery-ticket"
21
15
  ]
22
16
  }
23
- ],
24
- "bundles": []
17
+ ]
25
18
  }
@@ -4,6 +4,16 @@
4
4
  font-family: "Roboto", sans-serif;
5
5
  }
6
6
 
7
+ .TicketTitle {
8
+ font-size: 16px;
9
+ font-weight: bold;
10
+ }
11
+
12
+ .ButtonContainer {
13
+ display: flex;
14
+ justify-content: flex-end;
15
+ }
16
+
7
17
  .Toggle {
8
18
  cursor: pointer;
9
19
  margin-top: 20px;
@@ -90,12 +100,10 @@ input[type=number]::-webkit-outer-spin-button {
90
100
  cursor: pointer;
91
101
  outline: none;
92
102
  -webkit-appearance: none;
93
- background-color: transparent;
94
103
  border: none;
95
104
  align-items: center;
96
105
  justify-content: center;
97
106
  height: 20px;
98
- margin: 0;
99
107
  position: relative;
100
108
  }
101
109
 
@@ -103,7 +111,6 @@ input[type=number]::-webkit-outer-spin-button {
103
111
  display: inline-block;
104
112
  position: absolute;
105
113
  transform: translate(-50%, -50%) rotate(180deg);
106
- width: 30px;
107
114
  align-items: center;
108
115
  text-align: center;
109
116
  }
@@ -141,9 +148,9 @@ input[type=number]::-webkit-outer-spin-button {
141
148
 
142
149
  .AutoButton {
143
150
  cursor: pointer;
144
- display: block;
151
+ display: inline-block;
145
152
  border-radius: 4px;
146
- padding: 8px 25px;
153
+ padding: 8px 20px;
147
154
  width: max-content;
148
155
  margin: 5px 0;
149
156
  border: 1px solid #00958f;
@@ -162,9 +169,9 @@ input[type=number]::-webkit-outer-spin-button {
162
169
 
163
170
  .ResetButton {
164
171
  cursor: pointer;
165
- display: block;
172
+ display: inline-block;
166
173
  border-radius: 4px;
167
- padding: 8px 25px;
174
+ padding: 8px 20px;
168
175
  width: max-content;
169
176
  margin: 5px 0;
170
177
  color: #000;
@@ -190,4 +197,111 @@ input[type=number]::-webkit-outer-spin-button {
190
197
  }
191
198
  .TicketGridBullets .TicketGridTitle {
192
199
  margin-top: 0px;
200
+ }
201
+
202
+ .Minus {
203
+ border-radius: 4px;
204
+ width: 30px;
205
+ height: 24px !important;
206
+ margin-right: 10px;
207
+ color: #FFF;
208
+ background: #009993;
209
+ }
210
+
211
+ .Plus {
212
+ border-radius: 4px;
213
+ width: 30px;
214
+ height: 24px !important;
215
+ margin-left: 10px;
216
+ color: #FFF;
217
+ background: #009993;
218
+ }
219
+
220
+ .SelectWrapper {
221
+ width: auto;
222
+ padding: 5px;
223
+ margin: 0 auto;
224
+ border: 1px solid #ccc;
225
+ border-radius: 5px;
226
+ position: relative;
227
+ }
228
+
229
+ .SelectButton, .SelectOptions li {
230
+ display: flex;
231
+ align-items: center;
232
+ cursor: pointer;
233
+ }
234
+
235
+ .SelectButton {
236
+ display: flex;
237
+ padding: 0 5px;
238
+ border-radius: 7px;
239
+ align-items: center;
240
+ justify-content: space-between;
241
+ font-size: 14px;
242
+ }
243
+ .SelectButton span:first-child {
244
+ padding-right: 10px;
245
+ }
246
+
247
+ .SelectExpand {
248
+ transition: transform 0.3s linear;
249
+ font-size: 12px;
250
+ }
251
+
252
+ .SelectActive .SelectExpand {
253
+ transform: rotate(180deg);
254
+ }
255
+
256
+ .SelectContent {
257
+ display: none;
258
+ padding: 5px;
259
+ border-radius: 7px;
260
+ }
261
+
262
+ .SelectWrapper.SelectActive .SelectContent {
263
+ width: 100%;
264
+ display: block;
265
+ position: absolute;
266
+ left: 0;
267
+ top: 32px;
268
+ padding: 0;
269
+ border: 1px solid #ccc;
270
+ overflow: hidden;
271
+ background: #fff;
272
+ }
273
+
274
+ .SelectContent .SelectOptions {
275
+ max-height: 100px;
276
+ margin: 0;
277
+ overflow-y: auto;
278
+ padding: 0;
279
+ }
280
+ .SelectContent .SelectOptions .SelectedValue {
281
+ background-color: #009993;
282
+ color: #fff;
283
+ }
284
+
285
+ .SelectOptions::-webkit-scrollbar {
286
+ width: 7px;
287
+ }
288
+
289
+ .SelectOptions::-webkit-scrollbar-track {
290
+ background: #f1f1f1;
291
+ border-radius: 25px;
292
+ }
293
+
294
+ .SelectOptions::-webkit-scrollbar-thumb {
295
+ background: #ccc;
296
+ border-radius: 25px;
297
+ }
298
+
299
+ .SelectOptions li {
300
+ height: 20px;
301
+ padding: 0 13px;
302
+ font-size: 14px;
303
+ }
304
+
305
+ .SelectOptions li:hover {
306
+ background: #f2f2f2;
193
307
  }
@@ -28,6 +28,16 @@ export class LotteryTicket {
28
28
  this.isLoading = true;
29
29
  this.hasErrors = false;
30
30
  this.ticketDone = false;
31
+ this.isCustomSelect = false;
32
+ this.amountInfo = {};
33
+ }
34
+ /**
35
+ * @TODO find a better way to implement click outside the custom select, so that we don't have to use the 'data-cluster' attribute on each element
36
+ */
37
+ checkForClickOutside(ev) {
38
+ if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
39
+ this.isCustomSelect = false;
40
+ }
31
41
  }
32
42
  connectedCallback() {
33
43
  let url = new URL(`${this.endpoint}/games/${this.gameId}`);
@@ -45,6 +55,7 @@ export class LotteryTicket {
45
55
  this.isLoading = false;
46
56
  this.gameData = data;
47
57
  this.grids = [...Array(data.rules.boards.length).keys()];
58
+ this.amountInfo = this.gameData.rules.stakes[0]; // initial value for select
48
59
  })
49
60
  .catch((err) => {
50
61
  this.isLoading = false;
@@ -73,12 +84,23 @@ export class LotteryTicket {
73
84
  this.ticketDone = false;
74
85
  this.resetSelection.emit(this.ticketId);
75
86
  }
76
- changeStake(event) {
87
+ changeStake(ticketid, amount) {
77
88
  this.stakeChange.emit({
78
- ticketId: this.ticketId,
79
- stake: event.target.value
89
+ ticketId: ticketid,
90
+ stake: amount
80
91
  });
81
92
  }
93
+ toggleClass() {
94
+ this.isCustomSelect = !this.isCustomSelect;
95
+ }
96
+ setDropdownItem(item) {
97
+ this.amountInfo = {
98
+ amount: item.amount,
99
+ currency: item.currency
100
+ };
101
+ this.isCustomSelect = false;
102
+ this.changeStake(this.ticketId, item.amount);
103
+ }
82
104
  render() {
83
105
  if (this.isLoading) {
84
106
  return (h("div", null,
@@ -92,11 +114,13 @@ export class LotteryTicket {
92
114
  else {
93
115
  const { rules } = this.gameData;
94
116
  return (h("div", { class: "TicketContainer" },
95
- h("p", null, this.gameData.name),
117
+ h("p", { class: "TicketTitle" }, this.gameData.name),
96
118
  this.resetButton && this.ticketDone &&
97
- h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language)),
119
+ h("div", { class: "ButtonContainer" },
120
+ h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language))),
98
121
  this.autoPick && !this.ticketDone &&
99
- h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language)),
122
+ h("div", { class: "ButtonContainer" },
123
+ h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language))),
100
124
  this.grids.map((item, index) => h("div", { class: "TicketGridBullets" },
101
125
  h("p", { class: "TicketGridTitle" },
102
126
  translate('grid', this.language),
@@ -120,16 +144,25 @@ export class LotteryTicket {
120
144
  h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"),
121
145
  h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }),
122
146
  h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))),
123
- h("label", { class: "Label" },
124
- translate('wagerPerDraw', this.language),
125
- ": "),
126
- h("div", { class: "WagerInput" }, rules.stakes.length > 1 ? h("div", null,
127
- h("select", { class: "InputDefault", onChange: (event) => this.changeStake(event) }, rules.stakes.map((item) => h("option", { value: item.amount },
128
- item.amount,
129
- " ",
130
- item.currency)))) : h("div", null,
131
- h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }),
132
- h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))));
147
+ h("div", null,
148
+ h("label", { class: "Label" },
149
+ translate('wagerPerDraw', this.language),
150
+ ": "),
151
+ h("div", { class: "WagerInput" }, rules.stakes.length > 1 ?
152
+ (h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" },
153
+ h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() },
154
+ h("span", { "data-cluster": "SelectComponent" },
155
+ this.amountInfo.amount,
156
+ " ",
157
+ this.amountInfo.currency),
158
+ h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")),
159
+ h("div", { "data-cluster": "SelectComponent", class: "SelectContent" },
160
+ h("ul", { "data-cluster": "SelectComponent", class: "SelectOptions" }, rules.stakes.map((item) => h("li", { "data-cluster": "SelectComponent", class: this.amountInfo.amount == item.amount ? 'SelectedValue' : '', value: item.amount, onClick: () => this.setDropdownItem(item) },
161
+ item.amount,
162
+ " ",
163
+ item.currency)))))) : (h("div", null,
164
+ h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }),
165
+ h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))))));
133
166
  }
134
167
  }
135
168
  }
@@ -289,7 +322,9 @@ export class LotteryTicket {
289
322
  "numberOfDraws": {},
290
323
  "isLoading": {},
291
324
  "hasErrors": {},
292
- "ticketDone": {}
325
+ "ticketDone": {},
326
+ "isCustomSelect": {},
327
+ "amountInfo": {}
293
328
  }; }
294
329
  static get events() { return [{
295
330
  "method": "ticketCompleted",
@@ -375,6 +410,12 @@ export class LotteryTicket {
375
410
  "methodName": "drawsChangeHandler"
376
411
  }]; }
377
412
  static get listeners() { return [{
413
+ "name": "click",
414
+ "method": "checkForClickOutside",
415
+ "target": "window",
416
+ "capture": false,
417
+ "passive": false
418
+ }, {
378
419
  "name": "gridFilled",
379
420
  "method": "gridFilledHandler",
380
421
  "target": undefined,