@everymatrix/lottery-ticket-controller 0.1.1 → 0.1.2
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 +487 -0
- package/dist/cjs/{index-4814ed9d.js → index-c560cdc6.js} +38 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/lottery-ticket-controller.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +18 -0
- package/dist/components/helper-accordion2.js +2 -7
- 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 +20 -3
- package/dist/components/lottery-ticket.js +6 -0
- package/dist/components/lottery-ticket2.js +183 -0
- package/dist/esm/helper-accordion_5.entry.js +479 -0
- package/dist/esm/{index-116c3025.js → index-0b72e6e4.js} +38 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/lottery-ticket-controller.js +2 -2
- package/dist/lottery-ticket-controller/lottery-ticket-controller.esm.js +1 -1
- package/dist/lottery-ticket-controller/p-62871984.entry.js +1 -0
- package/dist/lottery-ticket-controller/p-e0a7e661.js +1 -0
- package/package.json +1 -1
- package/dist/cjs/helper-accordion_2.cjs.entry.js +0 -156
- package/dist/esm/helper-accordion_2.entry.js +0 -151
- package/dist/lottery-ticket-controller/p-b4ec0994.js +0 -1
- package/dist/lottery-ticket-controller/p-efb11dcf.entry.js +0 -1
|
@@ -15,7 +15,7 @@ const translate = (key, customLang) => {
|
|
|
15
15
|
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const helperAccordionCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Header{border-radius:4px
|
|
18
|
+
const helperAccordionCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Header{border-radius:4px;margin-bottom:1px;background:#009993;display:flex;gap:30px;border:1px solid #009993;padding:8px 10px;user-select:none}.Header:hover{background:#00ABA4}.Header .Title,.Header .Subtitle,.Header .Description{margin:0;font-size:14px;color:#fff}.Header .Expand{margin-left:auto;color:#FFF;width:17px;height:17px;cursor:pointer;text-align:center;transform:rotate(90deg);font-size:20px;user-select:none}.Content{border-radius:4px;background:#fff;border:1px solid #009993;padding:10px 15px;user-select:none;color:#000;margin-bottom:10px}.ActionButton{border-radius:4px;margin-top:10px;cursor:pointer;text-transform:capitalize;display:block;font-size:12px;text-align:center;padding:8px 20px;width:80px;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ActionButton:hover{background:#FF6536;border:1px solid #FF3D00}";
|
|
19
19
|
|
|
20
20
|
const Accordion = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
21
21
|
constructor() {
|
|
@@ -23,10 +23,6 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
23
23
|
this.__registerHost();
|
|
24
24
|
this.__attachShadow();
|
|
25
25
|
this.accordionEvent = createEvent(this, "helperAccordionAction", 7);
|
|
26
|
-
/**
|
|
27
|
-
* Flag for ticket history
|
|
28
|
-
*/
|
|
29
|
-
this.ticketHistoryFlag = false;
|
|
30
26
|
/**
|
|
31
27
|
* Title (top header)
|
|
32
28
|
*/
|
|
@@ -79,14 +75,13 @@ const Accordion = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
79
75
|
this.accordionEvent.emit();
|
|
80
76
|
}
|
|
81
77
|
render() {
|
|
82
|
-
return (h("div", { class: "Wrapper" }, h("div", { class:
|
|
78
|
+
return (h("div", { class: "Wrapper" }, h("div", { class: "Header" }, h("p", { class: "Title" }, this.headerTitle), h("p", { class: "Subtitle" }, this.headerSubtitle), h("p", { class: "Subtitle" }, this.description), h("span", { class: "Expand", onClick: () => this.toggleContent() }, this.showContent ? '<' : '>')), this.showContent &&
|
|
83
79
|
h("div", null, h("div", { class: "Content" }, h("slot", { name: 'accordionContent' }), this.footer && this.showContent &&
|
|
84
80
|
h("div", null, this.deleteTab &&
|
|
85
81
|
h("span", { class: "ActionButton", onClick: () => this.deleteAction() }, translate('deleteTicket', this.language)))))));
|
|
86
82
|
}
|
|
87
83
|
static get style() { return helperAccordionCss; }
|
|
88
84
|
}, [1, "helper-accordion", {
|
|
89
|
-
"ticketHistoryFlag": [4, "ticket-history-flag"],
|
|
90
85
|
"headerTitle": [1, "header-title"],
|
|
91
86
|
"headerSubtitle": [1, "header-subtitle"],
|
|
92
87
|
"description": [1],
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const lotteryBulletCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Circle{cursor:pointer;color:#000000;display:block;background:#FFF;border:solid 2px #00958f;height:20px;width:20px;border-radius:50%;margin:0;display:flex;align-items:center;justify-content:center;user-select:none;font-size:12px;font-weight:600;position:relative}.Circle:hover{background:#aee4e2}.Circle.Selected{color:#ffffff;background:#9EC258;background:-webkit-radial-gradient(top, #00958f, #004D4A);background:-moz-radial-gradient(top, #00958f, #004D4A);background:radial-gradient(to bottom, #00958f, #004D4A);border:solid 2px #00958f}.Circle.Disabled{color:#707070;background:#D4D4D4;border:solid 2px #707070;cursor:default}.Circle.DisabledSelected{color:#ffffff;background:#9EC258;background:-webkit-radial-gradient(top, #00958f, #004D4A);background:-moz-radial-gradient(top, #00958f, #004D4A);background:radial-gradient(to bottom, #00958f, #004D4A);border:solid 2px #707070;cursor:default}";
|
|
4
|
+
|
|
5
|
+
const LotteryBullet = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.__registerHost();
|
|
9
|
+
this.__attachShadow();
|
|
10
|
+
this.bulletEvent = createEvent(this, "lotteryBulletSelection", 7);
|
|
11
|
+
/**
|
|
12
|
+
* Value of the bullet
|
|
13
|
+
*/
|
|
14
|
+
this.value = '0';
|
|
15
|
+
/**
|
|
16
|
+
* Marks if the bullet should be selectable
|
|
17
|
+
*/
|
|
18
|
+
this.selectable = true;
|
|
19
|
+
/**
|
|
20
|
+
* Marks if the bullet should be selected
|
|
21
|
+
*/
|
|
22
|
+
this.isSelected = false;
|
|
23
|
+
this.select = () => {
|
|
24
|
+
if (this.selectable) {
|
|
25
|
+
this.isSelected = !this.isSelected;
|
|
26
|
+
this.bulletEvent.emit({
|
|
27
|
+
value: this.value,
|
|
28
|
+
selected: this.isSelected
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return (h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select() }, this.value));
|
|
35
|
+
}
|
|
36
|
+
static get style() { return lotteryBulletCss; }
|
|
37
|
+
}, [1, "lottery-bullet", {
|
|
38
|
+
"value": [1],
|
|
39
|
+
"selectable": [4],
|
|
40
|
+
"isSelected": [4, "is-selected"]
|
|
41
|
+
}]);
|
|
42
|
+
function defineCustomElement() {
|
|
43
|
+
if (typeof customElements === "undefined") {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const components = ["lottery-bullet"];
|
|
47
|
+
components.forEach(tagName => { switch (tagName) {
|
|
48
|
+
case "lottery-bullet":
|
|
49
|
+
if (!customElements.get(tagName)) {
|
|
50
|
+
customElements.define(tagName, LotteryBullet);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
} });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { LotteryBullet as L, defineCustomElement as d };
|
|
@@ -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:350px}.Grid{margin-top:10px 0 10px 0;display:flex;flex-direction:row;flex-wrap:wrap;gap:10px}";
|
|
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 { d as defineCustomElement$
|
|
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,7 +84,7 @@ function defineCustomElement$1() {
|
|
|
82
84
|
if (typeof customElements === "undefined") {
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
|
-
const components = ["lottery-ticket-controller", "helper-accordion"];
|
|
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)) {
|
|
@@ -90,6 +92,21 @@ function defineCustomElement$1() {
|
|
|
90
92
|
}
|
|
91
93
|
break;
|
|
92
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":
|
|
93
110
|
if (!customElements.get(tagName)) {
|
|
94
111
|
defineCustomElement$2();
|
|
95
112
|
}
|
|
@@ -0,0 +1,183 @@
|
|
|
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}.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;background-color:transparent;border:none;align-items:center;justify-content:center;height:20px;margin:0;position:relative}.NumberInput button:after{display:inline-block;position:absolute;transform:translate(-50%, -50%) rotate(180deg);width:30px;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:block;border-radius:4px;padding:8px 25px;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:block;border-radius:4px;padding:8px 25px;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}";
|
|
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
|
+
}
|
|
72
|
+
connectedCallback() {
|
|
73
|
+
let url = new URL(`${this.endpoint}/games/${this.gameId}`);
|
|
74
|
+
fetch(url.href)
|
|
75
|
+
.then((response) => {
|
|
76
|
+
if (response.ok) {
|
|
77
|
+
return response.json();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Throw error
|
|
81
|
+
this.hasErrors = true;
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.then((data) => {
|
|
85
|
+
this.isLoading = false;
|
|
86
|
+
this.gameData = data;
|
|
87
|
+
this.grids = [...Array(data.rules.boards.length).keys()];
|
|
88
|
+
})
|
|
89
|
+
.catch((err) => {
|
|
90
|
+
this.isLoading = false;
|
|
91
|
+
this.hasErrors = true;
|
|
92
|
+
console.error('Error!', err);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
multiplierChangeHandler(e) {
|
|
96
|
+
this.multiplier = e.target ? e.target.checked : false;
|
|
97
|
+
this.multiplierChange.emit(this.multiplier);
|
|
98
|
+
}
|
|
99
|
+
drawsChangeHandler(event) {
|
|
100
|
+
this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
|
|
101
|
+
this.ticketCompleted.emit(this.ticket);
|
|
102
|
+
}
|
|
103
|
+
gridFilledHandler(event) {
|
|
104
|
+
this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
|
|
105
|
+
this.ticketDone = true;
|
|
106
|
+
this.ticketCompleted.emit(this.ticket);
|
|
107
|
+
}
|
|
108
|
+
toggleAutoSelection() {
|
|
109
|
+
this.ticketDone = true;
|
|
110
|
+
this.autoSelection.emit(this.ticketId);
|
|
111
|
+
}
|
|
112
|
+
toggleResetSelection() {
|
|
113
|
+
this.ticketDone = false;
|
|
114
|
+
this.resetSelection.emit(this.ticketId);
|
|
115
|
+
}
|
|
116
|
+
changeStake(event) {
|
|
117
|
+
this.stakeChange.emit({
|
|
118
|
+
ticketId: this.ticketId,
|
|
119
|
+
stake: event.target.value
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
if (this.isLoading) {
|
|
124
|
+
return (h("div", null, h("p", null, translate('loading', this.language))));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
if (this.hasErrors) {
|
|
128
|
+
return (h("div", null, h("p", null, translate('error', this.language))));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const { rules } = this.gameData;
|
|
132
|
+
return (h("div", { class: "TicketContainer" }, h("p", null, this.gameData.name), this.resetButton && this.ticketDone &&
|
|
133
|
+
h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language)), this.autoPick && !this.ticketDone &&
|
|
134
|
+
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 &&
|
|
135
|
+
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 &&
|
|
136
|
+
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("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), h("div", { class: "WagerInput" }, rules.stakes.length > 1 ? h("div", null, h("select", { class: "InputDefault", onChange: (event) => this.changeStake(event) }, rules.stakes.map((item) => h("option", { value: item.amount }, 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)))));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
static get watchers() { return {
|
|
141
|
+
"numberOfDraws": ["drawsChangeHandler"]
|
|
142
|
+
}; }
|
|
143
|
+
static get style() { return lotteryTicketCss; }
|
|
144
|
+
}, [1, "lottery-ticket", {
|
|
145
|
+
"endpoint": [1],
|
|
146
|
+
"gameId": [1, "game-id"],
|
|
147
|
+
"numberOfGrids": [2, "number-of-grids"],
|
|
148
|
+
"multipleDraws": [4, "multiple-draws"],
|
|
149
|
+
"ticketId": [2, "ticket-id"],
|
|
150
|
+
"resetButton": [4, "reset-button"],
|
|
151
|
+
"autoPick": [4, "auto-pick"],
|
|
152
|
+
"language": [1],
|
|
153
|
+
"multiplier": [32],
|
|
154
|
+
"numberOfDraws": [32],
|
|
155
|
+
"isLoading": [32],
|
|
156
|
+
"hasErrors": [32],
|
|
157
|
+
"ticketDone": [32]
|
|
158
|
+
}, [[0, "gridFilled", "gridFilledHandler"]]]);
|
|
159
|
+
function defineCustomElement() {
|
|
160
|
+
if (typeof customElements === "undefined") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const components = ["lottery-ticket", "lottery-bullet", "lottery-grid"];
|
|
164
|
+
components.forEach(tagName => { switch (tagName) {
|
|
165
|
+
case "lottery-ticket":
|
|
166
|
+
if (!customElements.get(tagName)) {
|
|
167
|
+
customElements.define(tagName, LotteryTicket);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
case "lottery-bullet":
|
|
171
|
+
if (!customElements.get(tagName)) {
|
|
172
|
+
defineCustomElement$2();
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
case "lottery-grid":
|
|
176
|
+
if (!customElements.get(tagName)) {
|
|
177
|
+
defineCustomElement$1();
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
} });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { LotteryTicket as L, defineCustomElement as d };
|