@everymatrix/lottery-draw-results 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.
- package/dist/cjs/{index-62f030ff.js → index-33a98fae.js} +1 -73
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/lottery-draw-results.cjs.entry.js +188 -0
- package/dist/cjs/lottery-draw-results.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +5 -12
- package/dist/collection/components/lottery-draw-results/lottery-draw-results.css +18 -7
- package/dist/collection/components/lottery-draw-results/lottery-draw-results.js +169 -56
- package/dist/collection/utils/locale.utils.js +14 -2
- package/dist/components/lottery-draw-results.js +63 -59
- package/dist/esm/{index-98326ddd.js → index-c6e6b7f8.js} +2 -73
- package/dist/esm/loader.js +2 -2
- package/dist/esm/lottery-draw-results.entry.js +184 -0
- package/dist/esm/lottery-draw-results.js +2 -2
- package/dist/lottery-draw-results/lottery-draw-results.esm.js +1 -1
- package/dist/lottery-draw-results/p-31e0953f.js +1 -0
- package/dist/lottery-draw-results/p-d7361a7b.entry.js +1 -0
- package/dist/stencil.config.js +3 -0
- package/dist/types/components/lottery-draw-results/lottery-draw-results.d.ts +28 -3
- package/dist/types/components.d.ts +56 -2
- package/package.json +2 -2
- package/dist/cjs/lottery-bullet_3.cjs.entry.js +0 -374
- package/dist/components/lottery-bullet.js +0 -6
- package/dist/components/lottery-bullet2.js +0 -56
- package/dist/components/lottery-grid.js +0 -6
- package/dist/components/lottery-grid2.js +0 -196
- package/dist/esm/lottery-bullet_3.entry.js +0 -368
- package/dist/lottery-draw-results/p-2b8529f6.entry.js +0 -1
- package/dist/lottery-draw-results/p-bb429486.js +0 -1
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-62f030ff.js');
|
|
6
|
-
|
|
7
|
-
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}";
|
|
8
|
-
|
|
9
|
-
const LotteryBullet = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
this.bulletEvent = index.createEvent(this, "lotteryBulletSelection", 7);
|
|
13
|
-
/**
|
|
14
|
-
* Value of the bullet
|
|
15
|
-
*/
|
|
16
|
-
this.value = '0';
|
|
17
|
-
/**
|
|
18
|
-
* Marks if the bullet should be selectable
|
|
19
|
-
*/
|
|
20
|
-
this.selectable = true;
|
|
21
|
-
/**
|
|
22
|
-
* Marks if the bullet should be selected
|
|
23
|
-
*/
|
|
24
|
-
this.isSelected = false;
|
|
25
|
-
this.select = () => {
|
|
26
|
-
if (this.selectable) {
|
|
27
|
-
this.isSelected = !this.isSelected;
|
|
28
|
-
this.bulletEvent.emit({
|
|
29
|
-
value: this.value,
|
|
30
|
-
selected: this.isSelected
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
render() {
|
|
36
|
-
return (index.h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select() }, this.value));
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
LotteryBullet.style = lotteryBulletCss;
|
|
40
|
-
|
|
41
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
42
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
43
|
-
const TRANSLATIONS = {
|
|
44
|
-
en: {
|
|
45
|
-
drawResultsHeader: 'Last draw results',
|
|
46
|
-
drawId: 'Draw ID',
|
|
47
|
-
drawName: 'Game name',
|
|
48
|
-
drawDate: 'Draw Date',
|
|
49
|
-
drawNumbersGridDraw: 'Draw numbers Grid A',
|
|
50
|
-
drawNumbersGridTicket: 'Draw numbers Grid B',
|
|
51
|
-
ticketResult: 'Ticket result',
|
|
52
|
-
amountWon: 'Amount won',
|
|
53
|
-
numberOfDraws: 'Number of draws'
|
|
54
|
-
},
|
|
55
|
-
ro: {
|
|
56
|
-
drawResultsHeader: 'Ultimele rezultate extragere',
|
|
57
|
-
drawId: 'Id extragere',
|
|
58
|
-
drawName: 'Numele jocului',
|
|
59
|
-
drawDate: 'Data extragerii',
|
|
60
|
-
drawNumbersGridDraw: 'Numerele extrase Grid A',
|
|
61
|
-
drawNumbersGridTicket: 'Numerele extrase Grid B',
|
|
62
|
-
ticketResult: 'Rezultatul biletului',
|
|
63
|
-
amountWon: 'Suma castigata',
|
|
64
|
-
numberOfDraws: 'Numarul de extrageri'
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
const translate = (key, customLang) => {
|
|
68
|
-
const lang = customLang;
|
|
69
|
-
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const lotteryDrawResultsCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.TicketInfo{display:flex;flex-direction:row;gap:15px;background-color:#009993;color:#fff;padding:12px;font-size:14px}.DrawResultsSection{max-width:500px;margin:0 auto;margin:0px auto 10px;border-radius:4px}.DrawResultsHeader{display:flex;justify-content:space-between;padding:10px 20px;background-color:#009993;color:#fff;font-size:14px}.DrawResultsHeader h4{text-transform:uppercase;font-weight:400;margin:0}.DrawMultipler label{display:block;margin:15px 0}.DrawResultsBody{padding:0 20px}.DrawResultsBody .DrawNumbersGrid{font-size:14px}.DrawResultsBody .NumberOfDrawsContainer{display:table;width:100%}.Toggle{cursor:pointer;display:inline-block}.ToggleSwitch{display:inline-block;background:#ccc;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%, #eee 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:#56c080}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{margin-right:5px;position:relative;top:2px}.DrawTicketsContainer{margin:30px auto}.ExpandableBoxes{position:relative}.ExpandableBox{width:100%;height:100%;max-height:100px;float:left;margin:0 0 20px 0;border:1px solid #009993;border-radius:4px;padding:10px;box-sizing:border-box;-webkit-transition:all 0.6s ease-in-out;-moz-transition:all 0.6s ease-in-out;-o-transition:all 0.6s ease-in-out;-ms-transition:all 0.6s ease-in-out;transition:all 0.6s ease-in-out;overflow:hidden}.ExpandableBox.ShowBox{max-height:400px;margin:0px 0px 20p 0px}.ExpandableBox.HideBox{width:0;height:0;overflow:hidden;border:none;padding:0;margin:0;opacity:0}";
|
|
73
|
-
|
|
74
|
-
const DEFAULT_VALUES = {
|
|
75
|
-
gamename: 'Chrono',
|
|
76
|
-
gamedate: '24/09/2022',
|
|
77
|
-
state: 'Processing',
|
|
78
|
-
amount: 304444,
|
|
79
|
-
ticketid: '6963444',
|
|
80
|
-
selection: '[5, 6, 7, 8, 9]',
|
|
81
|
-
multiplier: 4.5,
|
|
82
|
-
resultstatus: 'Processing',
|
|
83
|
-
drawstatus: 'Won',
|
|
84
|
-
drawamount: 1022,
|
|
85
|
-
drawid: '54545555',
|
|
86
|
-
drawdate: '24/09/2032'
|
|
87
|
-
};
|
|
88
|
-
const LotteryDrawResults = class {
|
|
89
|
-
constructor(hostRef) {
|
|
90
|
-
index.registerInstance(this, hostRef);
|
|
91
|
-
/**
|
|
92
|
-
* Language of the widget
|
|
93
|
-
*/
|
|
94
|
-
this.language = 'en';
|
|
95
|
-
/**
|
|
96
|
-
* Shows only the last draw
|
|
97
|
-
*/
|
|
98
|
-
this.drawMode = false;
|
|
99
|
-
this.gameName = '';
|
|
100
|
-
this.multiplier = 5.434;
|
|
101
|
-
this.ticketData = {};
|
|
102
|
-
this.isLoading = true;
|
|
103
|
-
this.drawResults = [];
|
|
104
|
-
this.rules = {};
|
|
105
|
-
this.toggleDrawer = [false];
|
|
106
|
-
this.hasErrors = false;
|
|
107
|
-
this.errorText = '';
|
|
108
|
-
this.changeBox = (index) => {
|
|
109
|
-
this.toggleDrawer = this.toggleDrawer.map((item, itemIndex) => {
|
|
110
|
-
if (itemIndex == index) {
|
|
111
|
-
return !item;
|
|
112
|
-
}
|
|
113
|
-
return item;
|
|
114
|
-
});
|
|
115
|
-
if (index >= this.toggleDrawer.length) {
|
|
116
|
-
this.toggleDrawer.push(true);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
connectedCallback() {
|
|
121
|
-
let promises = [];
|
|
122
|
-
promises.push(this.getGameData());
|
|
123
|
-
if (this.playerId) {
|
|
124
|
-
promises.push(this.getTicketData());
|
|
125
|
-
}
|
|
126
|
-
if (this.drawId) {
|
|
127
|
-
promises.push(this.getDrawData());
|
|
128
|
-
}
|
|
129
|
-
Promise.all(promises)
|
|
130
|
-
.then(() => {
|
|
131
|
-
this.isLoading = false;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
getDrawData() {
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
let url = new URL(`${this.endpoint}/games/${this.gameId}/draws/${this.drawId}`);
|
|
137
|
-
fetch(url.href)
|
|
138
|
-
.then((response) => {
|
|
139
|
-
// @TODO EXCEPTIONS
|
|
140
|
-
return response.json();
|
|
141
|
-
})
|
|
142
|
-
.then((data) => {
|
|
143
|
-
this.drawData = data;
|
|
144
|
-
resolve(true);
|
|
145
|
-
})
|
|
146
|
-
.catch((err) => {
|
|
147
|
-
reject(err);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
getGameData() {
|
|
152
|
-
return new Promise((resolve, reject) => {
|
|
153
|
-
let url = new URL(`${this.endpoint}/games/${this.gameId}`);
|
|
154
|
-
fetch(url.href)
|
|
155
|
-
.then((response) => {
|
|
156
|
-
return response.json();
|
|
157
|
-
})
|
|
158
|
-
.then((data) => {
|
|
159
|
-
this.rules = {
|
|
160
|
-
maximumAllowed: data.rules.boards[0].maximumAllowed,
|
|
161
|
-
totalNumbers: data.rules.boards[0].totalNumbers
|
|
162
|
-
};
|
|
163
|
-
resolve(true);
|
|
164
|
-
})
|
|
165
|
-
.catch((err) => {
|
|
166
|
-
this.isLoading = false;
|
|
167
|
-
this.hasErrors = true;
|
|
168
|
-
this.errorText = err;
|
|
169
|
-
reject(err);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
getTicketData() {
|
|
174
|
-
return new Promise((resolve, reject) => {
|
|
175
|
-
let url = new URL(`${this.endpoint}/tickets/player/${this.playerId}`);
|
|
176
|
-
fetch(url.href)
|
|
177
|
-
.then((response) => {
|
|
178
|
-
return response.json();
|
|
179
|
-
})
|
|
180
|
-
.then((data) => {
|
|
181
|
-
this.ticketData = data.length === 0 ? DEFAULT_VALUES : data[1];
|
|
182
|
-
this.drawResults = this.ticketData.drawResults.map((item) => item);
|
|
183
|
-
this.selection = this.ticketData.selection[0].join(',');
|
|
184
|
-
resolve(true);
|
|
185
|
-
})
|
|
186
|
-
.catch((err) => {
|
|
187
|
-
reject(err);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
render() {
|
|
192
|
-
var _a, _b, _c, _d, _e, _f;
|
|
193
|
-
if (this.isLoading) {
|
|
194
|
-
return (index.h("p", null, "Loading, please wait ..."));
|
|
195
|
-
}
|
|
196
|
-
else if (this.hasErrors) {
|
|
197
|
-
index.h("p", null, this.errorText);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
return (index.h("section", { class: "DrawResultsSection" }, !this.drawMode ?
|
|
201
|
-
index.h("div", { class: "DrawResultsArea" }, index.h("div", { class: "TicketInfo" }, index.h("div", { class: "TicketGameName" }, translate('drawName', this.language), ": ", index.h("span", null, this.gameName)), index.h("div", { class: "TicketDate" }, "Ticket Purchase Date: ", index.h("span", null, (_a = this.ticketData) === null || _a === void 0 ? void 0 : _a.createdAt.slice(0, 10))), index.h("div", { class: "TicketStatus" }, "Status: ", index.h("span", null, (_b = this.ticketData) === null || _b === void 0 ? void 0 : _b.state))), index.h("div", { class: "DrawResultsBody" }, index.h("div", { class: "TicketIdContainer" }, index.h("p", null, "Ticket id: ", index.h("span", null, (_c = this.ticketData) === null || _c === void 0 ? void 0 : _c.id))), index.h("div", { class: "TicketAmountContainer" }, index.h("p", null, "Ticket amount: ", index.h("span", null, (_d = this.ticketData) === null || _d === void 0 ? void 0 : _d.amount))), index.h("div", { class: "DrawNumbersGrid" }, index.h("p", null, translate('drawNumbersGridTicket', this.language), ":"), index.h("div", { class: "BulletContainer" }, index.h("lottery-grid", { "maximum-allowed": this.rules.maximumAllowed, "total-numbers": this.rules.totalNumbers, "selected-numbers": this.selection, selectable: false, "display-selected": true, language: this.language }))), index.h("div", { class: "DrawMultipler" }, index.h("label", { class: "Label" }, "Multiplier: ", index.h("span", null, JSON.stringify((_e = this.ticketData) === null || _e === void 0 ? void 0 : _e.multiplier)))), index.h("div", { class: "NumberOfDrawsContainer" }, index.h("p", null, translate('numberOfDraws', this.language), ": ", (_f = this.ticketData) === null || _f === void 0 ? void 0 :
|
|
202
|
-
_f.drawCount), index.h("div", { class: "DrawTicketsContainer" }, this.drawResults.map((item, index$1) => index.h("div", { class: "ExpandableBoxes" }, index.h("div", { class: this.toggleDrawer[index$1] ? 'ExpandableBox ShowBox' : 'ExpandableBox', onClick: () => this.changeBox(index$1) }, index.h("div", { class: "TicketResultContainer" }, index.h("p", null, translate('ticketResult', this.language), ": ", item.status)), item.state == 'won' &&
|
|
203
|
-
index.h("div", { class: "AmountWonContainer" }, index.h("p", null, translate('amountWon', this.language), ": ", Number(item.amount).toLocaleString('en'), " ", item.currency)), index.h("div", { class: "DrawIdContainer" }, index.h("p", null, translate('drawId', this.language), ": ", item.drawId)), index.h("div", { class: "DrawDateContainer" }, index.h("p", null, translate('drawDate', this.language), ": ", item.updatedAt.slice(0, 10), " | ", item.updatedAt.slice(11, 19))), index.h("div", { class: "DrawNumbersGrid" }), index.h("div", { class: "DrawMultipler" }, index.h("label", { class: "Label" }, "Multiplier: ", item.multiplier)))))))))
|
|
204
|
-
:
|
|
205
|
-
index.h("div", { class: "DrawResultsArea" }, this.drawData &&
|
|
206
|
-
index.h("div", null, index.h("div", { class: "DrawResultsHeader" }, index.h("span", null, translate('drawId', this.language), ": ", this.drawData.id), index.h("span", null, translate('drawDate', this.language), ": ", this.drawData.date.slice(0, 10))), index.h("div", { class: "DrawResultsBody" }, index.h("div", { class: "DrawNumbersGrid" }, index.h("p", null, translate('drawNumbersGridDraw', this.language), ":"), index.h("div", { class: "BulletContainer" }, index.h("lottery-grid", { "maximum-allowed": this.rules.maximumAllowed, "total-numbers": this.rules.totalNumbers, selectedNumbers: this.drawData.winningNumbers.join(','), "display-selected": true, selectable: false, language: this.language })), index.h("div", { class: "DrawMultipler" }, index.h("label", { class: "Label" }, "Multiplier: ", this.multiplier))))))));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
LotteryDrawResults.style = lotteryDrawResultsCss;
|
|
211
|
-
|
|
212
|
-
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}";
|
|
213
|
-
|
|
214
|
-
const LotteryGrid = class {
|
|
215
|
-
constructor(hostRef) {
|
|
216
|
-
index.registerInstance(this, hostRef);
|
|
217
|
-
this.gridFilledEvent = index.createEvent(this, "gridFilled", 7);
|
|
218
|
-
this.gridDirtyEvent = index.createEvent(this, "gridDirty", 7);
|
|
219
|
-
/**
|
|
220
|
-
* Number of bullets of grid
|
|
221
|
-
*/
|
|
222
|
-
this.totalNumbers = 0;
|
|
223
|
-
/**
|
|
224
|
-
* Number of maximum bullets that can be selected
|
|
225
|
-
*/
|
|
226
|
-
this.maximumAllowed = 0;
|
|
227
|
-
/**
|
|
228
|
-
* Minimum allowed of bullets
|
|
229
|
-
*/
|
|
230
|
-
this.minimumAllowed = 1;
|
|
231
|
-
/**
|
|
232
|
-
* Allows the user to select numbers on the grid
|
|
233
|
-
*/
|
|
234
|
-
this.selectable = true;
|
|
235
|
-
/**
|
|
236
|
-
* Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
|
|
237
|
-
*/
|
|
238
|
-
this.selectedNumbers = '';
|
|
239
|
-
/**
|
|
240
|
-
* Show only selected numbers
|
|
241
|
-
*/
|
|
242
|
-
this.displaySelected = false;
|
|
243
|
-
/**
|
|
244
|
-
* Language
|
|
245
|
-
*/
|
|
246
|
-
this.language = 'en';
|
|
247
|
-
this.numbers = [];
|
|
248
|
-
this.selectedCounter = 0;
|
|
249
|
-
}
|
|
250
|
-
connectedCallback() {
|
|
251
|
-
let selected = [];
|
|
252
|
-
if (this.selectedNumbers.length > 0) {
|
|
253
|
-
selected = this.selectedNumbers.split(',');
|
|
254
|
-
this.selectedCounter = selected.length;
|
|
255
|
-
}
|
|
256
|
-
if (this.displaySelected) {
|
|
257
|
-
selected.forEach((item) => {
|
|
258
|
-
this.numbers.push({
|
|
259
|
-
number: item,
|
|
260
|
-
selected: true,
|
|
261
|
-
selectable: this.selectable
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
[...Array(this.totalNumbers).keys()]
|
|
267
|
-
.map(number => (number + 1).toString())
|
|
268
|
-
.forEach((number) => {
|
|
269
|
-
this.numbers.push({
|
|
270
|
-
number,
|
|
271
|
-
selected: selected.indexOf(number) >= 0 ? true : false,
|
|
272
|
-
selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
lotteryBulletSelectionHandler(event) {
|
|
278
|
-
this.numbers = this.numbers.map((item) => {
|
|
279
|
-
if (item.number == event.detail.value) {
|
|
280
|
-
return {
|
|
281
|
-
number: item.number,
|
|
282
|
-
selected: event.detail.selected,
|
|
283
|
-
selectable: item.selectable
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
number: item.number,
|
|
288
|
-
selected: item.selected,
|
|
289
|
-
selectable: item.selectable
|
|
290
|
-
};
|
|
291
|
-
});
|
|
292
|
-
if (event.detail.selected) {
|
|
293
|
-
this.selectedCounter += 1;
|
|
294
|
-
if (this.selectedCounter == this.maximumAllowed) {
|
|
295
|
-
this.numbers = this.numbers.map((item) => {
|
|
296
|
-
return {
|
|
297
|
-
number: item.number,
|
|
298
|
-
selected: item.selected,
|
|
299
|
-
selectable: item.selected ? true : false
|
|
300
|
-
};
|
|
301
|
-
});
|
|
302
|
-
this.gridFilledEvent.emit({
|
|
303
|
-
id: this.ticketId,
|
|
304
|
-
index: this.gridIndex,
|
|
305
|
-
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
if (this.selectedCounter == this.maximumAllowed) {
|
|
311
|
-
this.numbers = this.numbers.map((item) => {
|
|
312
|
-
return {
|
|
313
|
-
number: item.number,
|
|
314
|
-
selected: item.selected,
|
|
315
|
-
selectable: true
|
|
316
|
-
};
|
|
317
|
-
});
|
|
318
|
-
this.gridDirtyEvent.emit({
|
|
319
|
-
id: this.ticketId,
|
|
320
|
-
index: this.gridIndex,
|
|
321
|
-
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
this.selectedCounter -= 1;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
async resetSelectionHandler(event) {
|
|
328
|
-
if (event.detail && event.detail == this.ticketId) {
|
|
329
|
-
this.selectedCounter = 0;
|
|
330
|
-
this.numbers = this.numbers.map((item) => {
|
|
331
|
-
return {
|
|
332
|
-
number: item.number,
|
|
333
|
-
selected: false,
|
|
334
|
-
selectable: this.selectable
|
|
335
|
-
};
|
|
336
|
-
});
|
|
337
|
-
this.gridDirtyEvent.emit({
|
|
338
|
-
id: this.ticketId,
|
|
339
|
-
index: this.gridIndex,
|
|
340
|
-
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
async autoSelectionHandler(event) {
|
|
345
|
-
if (event.detail && event.detail == this.ticketId) {
|
|
346
|
-
this.resetSelectionHandler(event);
|
|
347
|
-
let array = [...Array(this.totalNumbers).keys()]
|
|
348
|
-
.map(number => number + 1)
|
|
349
|
-
.sort(() => 0.5 - Math.random());
|
|
350
|
-
array = array.slice(0, this.minimumAllowed);
|
|
351
|
-
this.numbers = this.numbers.map((item) => {
|
|
352
|
-
return {
|
|
353
|
-
number: item.number,
|
|
354
|
-
selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
|
|
355
|
-
selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
|
|
356
|
-
};
|
|
357
|
-
});
|
|
358
|
-
this.gridFilledEvent.emit({
|
|
359
|
-
id: this.ticketId,
|
|
360
|
-
index: this.gridIndex,
|
|
361
|
-
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
362
|
-
});
|
|
363
|
-
this.selectedCounter = this.maximumAllowed;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
render() {
|
|
367
|
-
return (index.h("div", { class: "GridContainer" }, index.h("div", { class: "Grid" }, this.numbers.map((item) => index.h("div", null, index.h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected }))))));
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
LotteryGrid.style = lotteryGridCss;
|
|
371
|
-
|
|
372
|
-
exports.lottery_bullet = LotteryBullet;
|
|
373
|
-
exports.lottery_draw_results = LotteryDrawResults;
|
|
374
|
-
exports.lottery_grid = LotteryGrid;
|
|
@@ -1,56 +0,0 @@
|
|
|
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 };
|
|
@@ -1,196 +0,0 @@
|
|
|
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 };
|