@everymatrix/lottery-ticket-controller 0.0.3 → 0.1.4
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.
- package/dist/cjs/helper-accordion_5.cjs.entry.js +514 -0
- package/dist/cjs/{index-498fdd8e.js → index-95915aab.js} +136 -12
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/lottery-ticket-controller.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +27 -2
- package/dist/components/helper-accordion.js +6 -0
- package/dist/components/helper-accordion2.js +115 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.js +0 -1
- package/dist/components/lottery-bullet.js +6 -0
- package/dist/components/lottery-bullet2.js +56 -0
- package/dist/components/lottery-grid.js +6 -0
- package/dist/components/lottery-grid2.js +196 -0
- package/dist/components/lottery-ticket-controller.js +25 -3
- package/dist/components/lottery-ticket.js +6 -0
- package/dist/components/lottery-ticket2.js +208 -0
- package/dist/esm/helper-accordion_5.entry.js +506 -0
- package/dist/esm/{index-4b81518c.js → index-e3877ca0.js} +136 -12
- package/dist/esm/loader.js +3 -3
- package/dist/esm/lottery-ticket-controller.js +3 -3
- package/dist/lottery-ticket-controller/lottery-ticket-controller.esm.js +1 -1
- package/dist/lottery-ticket-controller/p-3971b8e6.js +1 -0
- package/dist/lottery-ticket-controller/p-95406ad0.entry.js +1 -0
- package/dist/types/components.d.ts +1 -5
- package/package.json +1 -1
- package/dist/cjs/lottery-ticket-controller.cjs.entry.js +0 -71
- package/dist/esm/lottery-ticket-controller.entry.js +0 -67
- package/dist/lottery-ticket-controller/p-5186fd30.entry.js +0 -1
- package/dist/lottery-ticket-controller/p-fe83d21a.js +0 -2
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$1 } from './lottery-bullet2.js';
|
|
3
|
+
|
|
4
|
+
const lotteryGridCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GridContainer{display:flex;flex-direction:column;max-width:1200px}.Grid{margin-top:10px 0 10px 0;display:flex;flex-direction:row;flex-wrap:wrap;gap:25px}";
|
|
5
|
+
|
|
6
|
+
const LotteryGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.__attachShadow();
|
|
11
|
+
this.gridFilledEvent = createEvent(this, "gridFilled", 7);
|
|
12
|
+
this.gridDirtyEvent = createEvent(this, "gridDirty", 7);
|
|
13
|
+
/**
|
|
14
|
+
* Number of bullets of grid
|
|
15
|
+
*/
|
|
16
|
+
this.totalNumbers = 0;
|
|
17
|
+
/**
|
|
18
|
+
* Number of maximum bullets that can be selected
|
|
19
|
+
*/
|
|
20
|
+
this.maximumAllowed = 0;
|
|
21
|
+
/**
|
|
22
|
+
* Minimum allowed of bullets
|
|
23
|
+
*/
|
|
24
|
+
this.minimumAllowed = 1;
|
|
25
|
+
/**
|
|
26
|
+
* Allows the user to select numbers on the grid
|
|
27
|
+
*/
|
|
28
|
+
this.selectable = true;
|
|
29
|
+
/**
|
|
30
|
+
* Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
|
|
31
|
+
*/
|
|
32
|
+
this.selectedNumbers = '';
|
|
33
|
+
/**
|
|
34
|
+
* Show only selected numbers
|
|
35
|
+
*/
|
|
36
|
+
this.displaySelected = false;
|
|
37
|
+
/**
|
|
38
|
+
* Language
|
|
39
|
+
*/
|
|
40
|
+
this.language = 'en';
|
|
41
|
+
this.numbers = [];
|
|
42
|
+
this.selectedCounter = 0;
|
|
43
|
+
}
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
let selected = [];
|
|
46
|
+
if (this.selectedNumbers.length > 0) {
|
|
47
|
+
selected = this.selectedNumbers.split(',');
|
|
48
|
+
this.selectedCounter = selected.length;
|
|
49
|
+
}
|
|
50
|
+
if (this.displaySelected) {
|
|
51
|
+
selected.forEach((item) => {
|
|
52
|
+
this.numbers.push({
|
|
53
|
+
number: item,
|
|
54
|
+
selected: true,
|
|
55
|
+
selectable: this.selectable
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
[...Array(this.totalNumbers).keys()]
|
|
61
|
+
.map(number => (number + 1).toString())
|
|
62
|
+
.forEach((number) => {
|
|
63
|
+
this.numbers.push({
|
|
64
|
+
number,
|
|
65
|
+
selected: selected.indexOf(number) >= 0 ? true : false,
|
|
66
|
+
selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
lotteryBulletSelectionHandler(event) {
|
|
72
|
+
this.numbers = this.numbers.map((item) => {
|
|
73
|
+
if (item.number == event.detail.value) {
|
|
74
|
+
return {
|
|
75
|
+
number: item.number,
|
|
76
|
+
selected: event.detail.selected,
|
|
77
|
+
selectable: item.selectable
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
number: item.number,
|
|
82
|
+
selected: item.selected,
|
|
83
|
+
selectable: item.selectable
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
if (event.detail.selected) {
|
|
87
|
+
this.selectedCounter += 1;
|
|
88
|
+
if (this.selectedCounter == this.maximumAllowed) {
|
|
89
|
+
this.numbers = this.numbers.map((item) => {
|
|
90
|
+
return {
|
|
91
|
+
number: item.number,
|
|
92
|
+
selected: item.selected,
|
|
93
|
+
selectable: item.selected ? true : false
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
this.gridFilledEvent.emit({
|
|
97
|
+
id: this.ticketId,
|
|
98
|
+
index: this.gridIndex,
|
|
99
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (this.selectedCounter == this.maximumAllowed) {
|
|
105
|
+
this.numbers = this.numbers.map((item) => {
|
|
106
|
+
return {
|
|
107
|
+
number: item.number,
|
|
108
|
+
selected: item.selected,
|
|
109
|
+
selectable: true
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
this.gridDirtyEvent.emit({
|
|
113
|
+
id: this.ticketId,
|
|
114
|
+
index: this.gridIndex,
|
|
115
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
this.selectedCounter -= 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async resetSelectionHandler(event) {
|
|
122
|
+
if (event.detail && event.detail == this.ticketId) {
|
|
123
|
+
this.selectedCounter = 0;
|
|
124
|
+
this.numbers = this.numbers.map((item) => {
|
|
125
|
+
return {
|
|
126
|
+
number: item.number,
|
|
127
|
+
selected: false,
|
|
128
|
+
selectable: this.selectable
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
this.gridDirtyEvent.emit({
|
|
132
|
+
id: this.ticketId,
|
|
133
|
+
index: this.gridIndex,
|
|
134
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async autoSelectionHandler(event) {
|
|
139
|
+
if (event.detail && event.detail == this.ticketId) {
|
|
140
|
+
this.resetSelectionHandler(event);
|
|
141
|
+
let array = [...Array(this.totalNumbers).keys()]
|
|
142
|
+
.map(number => number + 1)
|
|
143
|
+
.sort(() => 0.5 - Math.random());
|
|
144
|
+
array = array.slice(0, this.minimumAllowed);
|
|
145
|
+
this.numbers = this.numbers.map((item) => {
|
|
146
|
+
return {
|
|
147
|
+
number: item.number,
|
|
148
|
+
selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
|
|
149
|
+
selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
this.gridFilledEvent.emit({
|
|
153
|
+
id: this.ticketId,
|
|
154
|
+
index: this.gridIndex,
|
|
155
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
156
|
+
});
|
|
157
|
+
this.selectedCounter = this.maximumAllowed;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
render() {
|
|
161
|
+
return (h("div", { class: "GridContainer" }, h("div", { class: "Grid" }, this.numbers.map((item) => h("div", null, h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected }))))));
|
|
162
|
+
}
|
|
163
|
+
static get style() { return lotteryGridCss; }
|
|
164
|
+
}, [1, "lottery-grid", {
|
|
165
|
+
"ticketId": [2, "ticket-id"],
|
|
166
|
+
"totalNumbers": [2, "total-numbers"],
|
|
167
|
+
"gameId": [1, "game-id"],
|
|
168
|
+
"maximumAllowed": [2, "maximum-allowed"],
|
|
169
|
+
"minimumAllowed": [2, "minimum-allowed"],
|
|
170
|
+
"selectable": [4],
|
|
171
|
+
"selectedNumbers": [1, "selected-numbers"],
|
|
172
|
+
"displaySelected": [4, "display-selected"],
|
|
173
|
+
"language": [1],
|
|
174
|
+
"gridIndex": [2, "grid-index"],
|
|
175
|
+
"numbers": [32]
|
|
176
|
+
}, [[0, "lotteryBulletSelection", "lotteryBulletSelectionHandler"], [4, "resetSelection", "resetSelectionHandler"], [4, "autoSelection", "autoSelectionHandler"]]]);
|
|
177
|
+
function defineCustomElement() {
|
|
178
|
+
if (typeof customElements === "undefined") {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const components = ["lottery-grid", "lottery-bullet"];
|
|
182
|
+
components.forEach(tagName => { switch (tagName) {
|
|
183
|
+
case "lottery-grid":
|
|
184
|
+
if (!customElements.get(tagName)) {
|
|
185
|
+
customElements.define(tagName, LotteryGrid);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case "lottery-bullet":
|
|
189
|
+
if (!customElements.get(tagName)) {
|
|
190
|
+
defineCustomElement$1();
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
} });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { LotteryGrid as L, defineCustomElement as d };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
2
|
+
import { d as defineCustomElement$5 } from './helper-accordion2.js';
|
|
3
|
+
import { d as defineCustomElement$4 } from './lottery-bullet2.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './lottery-grid2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './lottery-ticket2.js';
|
|
4
6
|
|
|
5
7
|
const lotteryTicketControllerCss = ":host{display:block}";
|
|
6
8
|
|
|
@@ -82,13 +84,33 @@ function defineCustomElement$1() {
|
|
|
82
84
|
if (typeof customElements === "undefined") {
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
|
-
const components = ["lottery-ticket-controller"];
|
|
87
|
+
const components = ["lottery-ticket-controller", "helper-accordion", "lottery-bullet", "lottery-grid", "lottery-ticket"];
|
|
86
88
|
components.forEach(tagName => { switch (tagName) {
|
|
87
89
|
case "lottery-ticket-controller":
|
|
88
90
|
if (!customElements.get(tagName)) {
|
|
89
91
|
customElements.define(tagName, LotteryTicketController$1);
|
|
90
92
|
}
|
|
91
93
|
break;
|
|
94
|
+
case "helper-accordion":
|
|
95
|
+
if (!customElements.get(tagName)) {
|
|
96
|
+
defineCustomElement$5();
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case "lottery-bullet":
|
|
100
|
+
if (!customElements.get(tagName)) {
|
|
101
|
+
defineCustomElement$4();
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case "lottery-grid":
|
|
105
|
+
if (!customElements.get(tagName)) {
|
|
106
|
+
defineCustomElement$3();
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case "lottery-ticket":
|
|
110
|
+
if (!customElements.get(tagName)) {
|
|
111
|
+
defineCustomElement$2();
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
92
114
|
} });
|
|
93
115
|
}
|
|
94
116
|
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$2 } from './lottery-bullet2.js';
|
|
3
|
+
import { d as defineCustomElement$1 } from './lottery-grid2.js';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
6
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
7
|
+
const TRANSLATIONS = {
|
|
8
|
+
en: {
|
|
9
|
+
loading: 'Loading, please wait ...',
|
|
10
|
+
error: 'It was an error while trying to fetch the data',
|
|
11
|
+
grid: 'Grid',
|
|
12
|
+
multiplier: 'Multiplier',
|
|
13
|
+
numberOfDraws: 'Number of draws',
|
|
14
|
+
wagerPerDraw: 'Wager per draw',
|
|
15
|
+
resetButton: 'Reset',
|
|
16
|
+
autoButton: 'I feel lucky'
|
|
17
|
+
},
|
|
18
|
+
ro: {
|
|
19
|
+
loading: 'Se incarca, va rugam asteptati ...',
|
|
20
|
+
error: 'A fost o eroare in timp ce asteptam datele',
|
|
21
|
+
grid: 'Grid',
|
|
22
|
+
multiplier: 'Multiplicator',
|
|
23
|
+
numberOfDraws: 'Numarul de extrageri',
|
|
24
|
+
wagerPerDraw: 'Pariul per extragere',
|
|
25
|
+
resetButton: 'Reseteaza',
|
|
26
|
+
autoButton: 'Ma simt norocos'
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const translate = (key, customLang) => {
|
|
30
|
+
const lang = customLang;
|
|
31
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
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}";
|
|
35
|
+
|
|
36
|
+
const LotteryTicket = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.__registerHost();
|
|
40
|
+
this.__attachShadow();
|
|
41
|
+
this.ticketCompleted = createEvent(this, "ticketCompleted", 7);
|
|
42
|
+
this.autoSelection = createEvent(this, "autoSelection", 7);
|
|
43
|
+
this.resetSelection = createEvent(this, "resetSelection", 7);
|
|
44
|
+
this.stakeChange = createEvent(this, "stakeChange", 7);
|
|
45
|
+
this.multiplierChange = createEvent(this, "multiplierChange", 7);
|
|
46
|
+
/**
|
|
47
|
+
* Number of grids of a ticket
|
|
48
|
+
*/
|
|
49
|
+
this.numberOfGrids = 1;
|
|
50
|
+
/**
|
|
51
|
+
* Option to have the ticket registered for multiple draws
|
|
52
|
+
*/
|
|
53
|
+
this.multipleDraws = true;
|
|
54
|
+
/**
|
|
55
|
+
* Shows the reset button
|
|
56
|
+
*/
|
|
57
|
+
this.resetButton = false;
|
|
58
|
+
/**
|
|
59
|
+
* Shows the auto-pick button
|
|
60
|
+
*/
|
|
61
|
+
this.autoPick = false;
|
|
62
|
+
/**
|
|
63
|
+
* Language
|
|
64
|
+
*/
|
|
65
|
+
this.language = 'en';
|
|
66
|
+
this.multiplier = false;
|
|
67
|
+
this.numberOfDraws = 1;
|
|
68
|
+
this.isLoading = true;
|
|
69
|
+
this.hasErrors = false;
|
|
70
|
+
this.ticketDone = false;
|
|
71
|
+
this.isCustomSelect = false;
|
|
72
|
+
this.amountInfo = {};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @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
|
|
76
|
+
*/
|
|
77
|
+
checkForClickOutside(ev) {
|
|
78
|
+
if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
|
|
79
|
+
this.isCustomSelect = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
connectedCallback() {
|
|
83
|
+
let url = new URL(`${this.endpoint}/games/${this.gameId}`);
|
|
84
|
+
fetch(url.href)
|
|
85
|
+
.then((response) => {
|
|
86
|
+
if (response.ok) {
|
|
87
|
+
return response.json();
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Throw error
|
|
91
|
+
this.hasErrors = true;
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
.then((data) => {
|
|
95
|
+
this.isLoading = false;
|
|
96
|
+
this.gameData = data;
|
|
97
|
+
this.grids = [...Array(data.rules.boards.length).keys()];
|
|
98
|
+
this.amountInfo = this.gameData.rules.stakes[0]; // initial value for select
|
|
99
|
+
})
|
|
100
|
+
.catch((err) => {
|
|
101
|
+
this.isLoading = false;
|
|
102
|
+
this.hasErrors = true;
|
|
103
|
+
console.error('Error!', err);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
multiplierChangeHandler(e) {
|
|
107
|
+
this.multiplier = e.target ? e.target.checked : false;
|
|
108
|
+
this.multiplierChange.emit(this.multiplier);
|
|
109
|
+
}
|
|
110
|
+
drawsChangeHandler(event) {
|
|
111
|
+
this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
|
|
112
|
+
this.ticketCompleted.emit(this.ticket);
|
|
113
|
+
}
|
|
114
|
+
gridFilledHandler(event) {
|
|
115
|
+
this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
|
|
116
|
+
this.ticketDone = true;
|
|
117
|
+
this.ticketCompleted.emit(this.ticket);
|
|
118
|
+
}
|
|
119
|
+
toggleAutoSelection() {
|
|
120
|
+
this.ticketDone = true;
|
|
121
|
+
this.autoSelection.emit(this.ticketId);
|
|
122
|
+
}
|
|
123
|
+
toggleResetSelection() {
|
|
124
|
+
this.ticketDone = false;
|
|
125
|
+
this.resetSelection.emit(this.ticketId);
|
|
126
|
+
}
|
|
127
|
+
changeStake(ticketid, amount) {
|
|
128
|
+
this.stakeChange.emit({
|
|
129
|
+
ticketId: ticketid,
|
|
130
|
+
stake: amount
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
toggleClass() {
|
|
134
|
+
this.isCustomSelect = !this.isCustomSelect;
|
|
135
|
+
}
|
|
136
|
+
setDropdownItem(item) {
|
|
137
|
+
this.amountInfo = {
|
|
138
|
+
amount: item.amount,
|
|
139
|
+
currency: item.currency
|
|
140
|
+
};
|
|
141
|
+
this.isCustomSelect = false;
|
|
142
|
+
this.changeStake(this.ticketId, item.amount);
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
if (this.isLoading) {
|
|
146
|
+
return (h("div", null, h("p", null, translate('loading', this.language))));
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
if (this.hasErrors) {
|
|
150
|
+
return (h("div", null, h("p", null, translate('error', this.language))));
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const { rules } = this.gameData;
|
|
154
|
+
return (h("div", { class: "TicketContainer" }, h("p", { class: "TicketTitle" }, this.gameData.name), this.resetButton && this.ticketDone &&
|
|
155
|
+
h("div", { class: "ButtonContainer" }, h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language))), this.autoPick && !this.ticketDone &&
|
|
156
|
+
h("div", { class: "ButtonContainer" }, h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language))), this.grids.map((item, index) => h("div", { class: "TicketGridBullets" }, h("p", { class: "TicketGridTitle" }, translate('grid', this.language), " ", item), h("lottery-grid", { "grid-index": index, "maximum-allowed": rules.boards[index].maximumAllowed, "minimum-allowed": rules.boards[index].minimumAllowed, "total-numbers": rules.boards[index].totalNumbers, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language }))), rules.multiplier &&
|
|
157
|
+
h("div", null, h("label", { class: "Toggle" }, h("label", { class: "Label" }, translate('multiplier', this.language), ": "), h("input", { class: "ToggleCheckbox", type: "checkbox", onInput: (e) => this.multiplierChangeHandler(e) }), h("div", { class: "ToggleSwitch" }))), this.multipleDraws &&
|
|
158
|
+
h("div", { class: "TicketDraws" }, h("label", { class: "Label" }, translate('numberOfDraws', this.language), ": "), h("div", { class: "NumberInput" }, h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), h("div", null, h("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), h("div", { class: "WagerInput" }, rules.stakes.length > 1 ?
|
|
159
|
+
(h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" }, h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() }, h("span", { "data-cluster": "SelectComponent" }, this.amountInfo.amount, " ", this.amountInfo.currency), h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")), h("div", { "data-cluster": "SelectComponent", class: "SelectContent" }, 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) }, item.amount, " ", item.currency)))))) : (h("div", null, h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }), h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))))));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
static get watchers() { return {
|
|
164
|
+
"numberOfDraws": ["drawsChangeHandler"]
|
|
165
|
+
}; }
|
|
166
|
+
static get style() { return lotteryTicketCss; }
|
|
167
|
+
}, [1, "lottery-ticket", {
|
|
168
|
+
"endpoint": [1],
|
|
169
|
+
"gameId": [1, "game-id"],
|
|
170
|
+
"numberOfGrids": [2, "number-of-grids"],
|
|
171
|
+
"multipleDraws": [4, "multiple-draws"],
|
|
172
|
+
"ticketId": [2, "ticket-id"],
|
|
173
|
+
"resetButton": [4, "reset-button"],
|
|
174
|
+
"autoPick": [4, "auto-pick"],
|
|
175
|
+
"language": [1],
|
|
176
|
+
"multiplier": [32],
|
|
177
|
+
"numberOfDraws": [32],
|
|
178
|
+
"isLoading": [32],
|
|
179
|
+
"hasErrors": [32],
|
|
180
|
+
"ticketDone": [32],
|
|
181
|
+
"isCustomSelect": [32],
|
|
182
|
+
"amountInfo": [32]
|
|
183
|
+
}, [[8, "click", "checkForClickOutside"], [0, "gridFilled", "gridFilledHandler"]]]);
|
|
184
|
+
function defineCustomElement() {
|
|
185
|
+
if (typeof customElements === "undefined") {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const components = ["lottery-ticket", "lottery-bullet", "lottery-grid"];
|
|
189
|
+
components.forEach(tagName => { switch (tagName) {
|
|
190
|
+
case "lottery-ticket":
|
|
191
|
+
if (!customElements.get(tagName)) {
|
|
192
|
+
customElements.define(tagName, LotteryTicket);
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case "lottery-bullet":
|
|
196
|
+
if (!customElements.get(tagName)) {
|
|
197
|
+
defineCustomElement$2();
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case "lottery-grid":
|
|
201
|
+
if (!customElements.get(tagName)) {
|
|
202
|
+
defineCustomElement$1();
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
} });
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { LotteryTicket as L, defineCustomElement as d };
|