@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
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-c560cdc6.js');
|
|
6
|
+
|
|
7
|
+
const DEFAULT_LANGUAGE$1 = 'en';
|
|
8
|
+
const SUPPORTED_LANGUAGES$1 = ['ro', 'en'];
|
|
9
|
+
const TRANSLATIONS$1 = {
|
|
10
|
+
en: {
|
|
11
|
+
deleteTicket: 'Delete ticket'
|
|
12
|
+
},
|
|
13
|
+
ro: {
|
|
14
|
+
deleteTicket: 'Sterge biletul'
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const translate$1 = (key, customLang) => {
|
|
18
|
+
const lang = customLang;
|
|
19
|
+
return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
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}";
|
|
23
|
+
|
|
24
|
+
const Accordion = class {
|
|
25
|
+
constructor(hostRef) {
|
|
26
|
+
index.registerInstance(this, hostRef);
|
|
27
|
+
this.accordionEvent = index.createEvent(this, "helperAccordionAction", 7);
|
|
28
|
+
/**
|
|
29
|
+
* Title (top header)
|
|
30
|
+
*/
|
|
31
|
+
this.headerTitle = '';
|
|
32
|
+
/**
|
|
33
|
+
* SubTitle (top header)
|
|
34
|
+
*/
|
|
35
|
+
this.headerSubtitle = '';
|
|
36
|
+
/**
|
|
37
|
+
* Description
|
|
38
|
+
*/
|
|
39
|
+
this.description = '';
|
|
40
|
+
/**
|
|
41
|
+
* Enables footer content
|
|
42
|
+
*/
|
|
43
|
+
this.footer = false;
|
|
44
|
+
/**
|
|
45
|
+
* Enables footer button for tab deletion
|
|
46
|
+
*/
|
|
47
|
+
this.deleteTab = false;
|
|
48
|
+
/**
|
|
49
|
+
* Activates postMessages as events for actions from the widget
|
|
50
|
+
*/
|
|
51
|
+
this.postMessage = false;
|
|
52
|
+
/**
|
|
53
|
+
* Name of the event emitter by the action button
|
|
54
|
+
*/
|
|
55
|
+
this.eventName = 'helperAccordionAction';
|
|
56
|
+
/**
|
|
57
|
+
* Collapsed
|
|
58
|
+
*/
|
|
59
|
+
this.collapsed = true;
|
|
60
|
+
/**
|
|
61
|
+
* Language
|
|
62
|
+
*/
|
|
63
|
+
this.language = 'en';
|
|
64
|
+
}
|
|
65
|
+
// @TODO fix the `any` type :)
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
this.showContent = !this.collapsed;
|
|
68
|
+
}
|
|
69
|
+
toggleContent() {
|
|
70
|
+
this.showContent = !this.showContent;
|
|
71
|
+
}
|
|
72
|
+
deleteAction() {
|
|
73
|
+
if (this.postMessage) {
|
|
74
|
+
// @TODO maybe change the name type, this one sucks
|
|
75
|
+
window.postMessage({ type: this.eventName }, window.location.href);
|
|
76
|
+
}
|
|
77
|
+
this.accordionEvent.emit();
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
return (index.h("div", { class: "Wrapper" }, index.h("div", { class: "Header" }, index.h("p", { class: "Title" }, this.headerTitle), index.h("p", { class: "Subtitle" }, this.headerSubtitle), index.h("p", { class: "Subtitle" }, this.description), index.h("span", { class: "Expand", onClick: () => this.toggleContent() }, this.showContent ? '<' : '>')), this.showContent &&
|
|
81
|
+
index.h("div", null, index.h("div", { class: "Content" }, index.h("slot", { name: 'accordionContent' }), this.footer && this.showContent &&
|
|
82
|
+
index.h("div", null, this.deleteTab &&
|
|
83
|
+
index.h("span", { class: "ActionButton", onClick: () => this.deleteAction() }, translate$1('deleteTicket', this.language)))))));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
Accordion.style = helperAccordionCss;
|
|
87
|
+
|
|
88
|
+
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}";
|
|
89
|
+
|
|
90
|
+
const LotteryBullet = class {
|
|
91
|
+
constructor(hostRef) {
|
|
92
|
+
index.registerInstance(this, hostRef);
|
|
93
|
+
this.bulletEvent = index.createEvent(this, "lotteryBulletSelection", 7);
|
|
94
|
+
/**
|
|
95
|
+
* Value of the bullet
|
|
96
|
+
*/
|
|
97
|
+
this.value = '0';
|
|
98
|
+
/**
|
|
99
|
+
* Marks if the bullet should be selectable
|
|
100
|
+
*/
|
|
101
|
+
this.selectable = true;
|
|
102
|
+
/**
|
|
103
|
+
* Marks if the bullet should be selected
|
|
104
|
+
*/
|
|
105
|
+
this.isSelected = false;
|
|
106
|
+
this.select = () => {
|
|
107
|
+
if (this.selectable) {
|
|
108
|
+
this.isSelected = !this.isSelected;
|
|
109
|
+
this.bulletEvent.emit({
|
|
110
|
+
value: this.value,
|
|
111
|
+
selected: this.isSelected
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
render() {
|
|
117
|
+
return (index.h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select() }, this.value));
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
LotteryBullet.style = lotteryBulletCss;
|
|
121
|
+
|
|
122
|
+
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}";
|
|
123
|
+
|
|
124
|
+
const LotteryGrid = class {
|
|
125
|
+
constructor(hostRef) {
|
|
126
|
+
index.registerInstance(this, hostRef);
|
|
127
|
+
this.gridFilledEvent = index.createEvent(this, "gridFilled", 7);
|
|
128
|
+
this.gridDirtyEvent = index.createEvent(this, "gridDirty", 7);
|
|
129
|
+
/**
|
|
130
|
+
* Number of bullets of grid
|
|
131
|
+
*/
|
|
132
|
+
this.totalNumbers = 0;
|
|
133
|
+
/**
|
|
134
|
+
* Number of maximum bullets that can be selected
|
|
135
|
+
*/
|
|
136
|
+
this.maximumAllowed = 0;
|
|
137
|
+
/**
|
|
138
|
+
* Minimum allowed of bullets
|
|
139
|
+
*/
|
|
140
|
+
this.minimumAllowed = 1;
|
|
141
|
+
/**
|
|
142
|
+
* Allows the user to select numbers on the grid
|
|
143
|
+
*/
|
|
144
|
+
this.selectable = true;
|
|
145
|
+
/**
|
|
146
|
+
* Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
|
|
147
|
+
*/
|
|
148
|
+
this.selectedNumbers = '';
|
|
149
|
+
/**
|
|
150
|
+
* Show only selected numbers
|
|
151
|
+
*/
|
|
152
|
+
this.displaySelected = false;
|
|
153
|
+
/**
|
|
154
|
+
* Language
|
|
155
|
+
*/
|
|
156
|
+
this.language = 'en';
|
|
157
|
+
this.numbers = [];
|
|
158
|
+
this.selectedCounter = 0;
|
|
159
|
+
}
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
let selected = [];
|
|
162
|
+
if (this.selectedNumbers.length > 0) {
|
|
163
|
+
selected = this.selectedNumbers.split(',');
|
|
164
|
+
this.selectedCounter = selected.length;
|
|
165
|
+
}
|
|
166
|
+
if (this.displaySelected) {
|
|
167
|
+
selected.forEach((item) => {
|
|
168
|
+
this.numbers.push({
|
|
169
|
+
number: item,
|
|
170
|
+
selected: true,
|
|
171
|
+
selectable: this.selectable
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
[...Array(this.totalNumbers).keys()]
|
|
177
|
+
.map(number => (number + 1).toString())
|
|
178
|
+
.forEach((number) => {
|
|
179
|
+
this.numbers.push({
|
|
180
|
+
number,
|
|
181
|
+
selected: selected.indexOf(number) >= 0 ? true : false,
|
|
182
|
+
selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
lotteryBulletSelectionHandler(event) {
|
|
188
|
+
this.numbers = this.numbers.map((item) => {
|
|
189
|
+
if (item.number == event.detail.value) {
|
|
190
|
+
return {
|
|
191
|
+
number: item.number,
|
|
192
|
+
selected: event.detail.selected,
|
|
193
|
+
selectable: item.selectable
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
number: item.number,
|
|
198
|
+
selected: item.selected,
|
|
199
|
+
selectable: item.selectable
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
if (event.detail.selected) {
|
|
203
|
+
this.selectedCounter += 1;
|
|
204
|
+
if (this.selectedCounter == this.maximumAllowed) {
|
|
205
|
+
this.numbers = this.numbers.map((item) => {
|
|
206
|
+
return {
|
|
207
|
+
number: item.number,
|
|
208
|
+
selected: item.selected,
|
|
209
|
+
selectable: item.selected ? true : false
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
this.gridFilledEvent.emit({
|
|
213
|
+
id: this.ticketId,
|
|
214
|
+
index: this.gridIndex,
|
|
215
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
if (this.selectedCounter == this.maximumAllowed) {
|
|
221
|
+
this.numbers = this.numbers.map((item) => {
|
|
222
|
+
return {
|
|
223
|
+
number: item.number,
|
|
224
|
+
selected: item.selected,
|
|
225
|
+
selectable: true
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
this.gridDirtyEvent.emit({
|
|
229
|
+
id: this.ticketId,
|
|
230
|
+
index: this.gridIndex,
|
|
231
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
this.selectedCounter -= 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async resetSelectionHandler(event) {
|
|
238
|
+
if (event.detail && event.detail == this.ticketId) {
|
|
239
|
+
this.selectedCounter = 0;
|
|
240
|
+
this.numbers = this.numbers.map((item) => {
|
|
241
|
+
return {
|
|
242
|
+
number: item.number,
|
|
243
|
+
selected: false,
|
|
244
|
+
selectable: this.selectable
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
this.gridDirtyEvent.emit({
|
|
248
|
+
id: this.ticketId,
|
|
249
|
+
index: this.gridIndex,
|
|
250
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async autoSelectionHandler(event) {
|
|
255
|
+
if (event.detail && event.detail == this.ticketId) {
|
|
256
|
+
this.resetSelectionHandler(event);
|
|
257
|
+
let array = [...Array(this.totalNumbers).keys()]
|
|
258
|
+
.map(number => number + 1)
|
|
259
|
+
.sort(() => 0.5 - Math.random());
|
|
260
|
+
array = array.slice(0, this.minimumAllowed);
|
|
261
|
+
this.numbers = this.numbers.map((item) => {
|
|
262
|
+
return {
|
|
263
|
+
number: item.number,
|
|
264
|
+
selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
|
|
265
|
+
selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
this.gridFilledEvent.emit({
|
|
269
|
+
id: this.ticketId,
|
|
270
|
+
index: this.gridIndex,
|
|
271
|
+
selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
|
|
272
|
+
});
|
|
273
|
+
this.selectedCounter = this.maximumAllowed;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
render() {
|
|
277
|
+
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 }))))));
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
LotteryGrid.style = lotteryGridCss;
|
|
281
|
+
|
|
282
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
283
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
284
|
+
const TRANSLATIONS = {
|
|
285
|
+
en: {
|
|
286
|
+
loading: 'Loading, please wait ...',
|
|
287
|
+
error: 'It was an error while trying to fetch the data',
|
|
288
|
+
grid: 'Grid',
|
|
289
|
+
multiplier: 'Multiplier',
|
|
290
|
+
numberOfDraws: 'Number of draws',
|
|
291
|
+
wagerPerDraw: 'Wager per draw',
|
|
292
|
+
resetButton: 'Reset',
|
|
293
|
+
autoButton: 'I feel lucky'
|
|
294
|
+
},
|
|
295
|
+
ro: {
|
|
296
|
+
loading: 'Se incarca, va rugam asteptati ...',
|
|
297
|
+
error: 'A fost o eroare in timp ce asteptam datele',
|
|
298
|
+
grid: 'Grid',
|
|
299
|
+
multiplier: 'Multiplicator',
|
|
300
|
+
numberOfDraws: 'Numarul de extrageri',
|
|
301
|
+
wagerPerDraw: 'Pariul per extragere',
|
|
302
|
+
resetButton: 'Reseteaza',
|
|
303
|
+
autoButton: 'Ma simt norocos'
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
const translate = (key, customLang) => {
|
|
307
|
+
const lang = customLang;
|
|
308
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
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}";
|
|
312
|
+
|
|
313
|
+
const LotteryTicket = class {
|
|
314
|
+
constructor(hostRef) {
|
|
315
|
+
index.registerInstance(this, hostRef);
|
|
316
|
+
this.ticketCompleted = index.createEvent(this, "ticketCompleted", 7);
|
|
317
|
+
this.autoSelection = index.createEvent(this, "autoSelection", 7);
|
|
318
|
+
this.resetSelection = index.createEvent(this, "resetSelection", 7);
|
|
319
|
+
this.stakeChange = index.createEvent(this, "stakeChange", 7);
|
|
320
|
+
this.multiplierChange = index.createEvent(this, "multiplierChange", 7);
|
|
321
|
+
/**
|
|
322
|
+
* Number of grids of a ticket
|
|
323
|
+
*/
|
|
324
|
+
this.numberOfGrids = 1;
|
|
325
|
+
/**
|
|
326
|
+
* Option to have the ticket registered for multiple draws
|
|
327
|
+
*/
|
|
328
|
+
this.multipleDraws = true;
|
|
329
|
+
/**
|
|
330
|
+
* Shows the reset button
|
|
331
|
+
*/
|
|
332
|
+
this.resetButton = false;
|
|
333
|
+
/**
|
|
334
|
+
* Shows the auto-pick button
|
|
335
|
+
*/
|
|
336
|
+
this.autoPick = false;
|
|
337
|
+
/**
|
|
338
|
+
* Language
|
|
339
|
+
*/
|
|
340
|
+
this.language = 'en';
|
|
341
|
+
this.multiplier = false;
|
|
342
|
+
this.numberOfDraws = 1;
|
|
343
|
+
this.isLoading = true;
|
|
344
|
+
this.hasErrors = false;
|
|
345
|
+
this.ticketDone = false;
|
|
346
|
+
}
|
|
347
|
+
connectedCallback() {
|
|
348
|
+
let url = new URL(`${this.endpoint}/games/${this.gameId}`);
|
|
349
|
+
fetch(url.href)
|
|
350
|
+
.then((response) => {
|
|
351
|
+
if (response.ok) {
|
|
352
|
+
return response.json();
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
// Throw error
|
|
356
|
+
this.hasErrors = true;
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
.then((data) => {
|
|
360
|
+
this.isLoading = false;
|
|
361
|
+
this.gameData = data;
|
|
362
|
+
this.grids = [...Array(data.rules.boards.length).keys()];
|
|
363
|
+
})
|
|
364
|
+
.catch((err) => {
|
|
365
|
+
this.isLoading = false;
|
|
366
|
+
this.hasErrors = true;
|
|
367
|
+
console.error('Error!', err);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
multiplierChangeHandler(e) {
|
|
371
|
+
this.multiplier = e.target ? e.target.checked : false;
|
|
372
|
+
this.multiplierChange.emit(this.multiplier);
|
|
373
|
+
}
|
|
374
|
+
drawsChangeHandler(event) {
|
|
375
|
+
this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
|
|
376
|
+
this.ticketCompleted.emit(this.ticket);
|
|
377
|
+
}
|
|
378
|
+
gridFilledHandler(event) {
|
|
379
|
+
this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
|
|
380
|
+
this.ticketDone = true;
|
|
381
|
+
this.ticketCompleted.emit(this.ticket);
|
|
382
|
+
}
|
|
383
|
+
toggleAutoSelection() {
|
|
384
|
+
this.ticketDone = true;
|
|
385
|
+
this.autoSelection.emit(this.ticketId);
|
|
386
|
+
}
|
|
387
|
+
toggleResetSelection() {
|
|
388
|
+
this.ticketDone = false;
|
|
389
|
+
this.resetSelection.emit(this.ticketId);
|
|
390
|
+
}
|
|
391
|
+
changeStake(event) {
|
|
392
|
+
this.stakeChange.emit({
|
|
393
|
+
ticketId: this.ticketId,
|
|
394
|
+
stake: event.target.value
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
render() {
|
|
398
|
+
if (this.isLoading) {
|
|
399
|
+
return (index.h("div", null, index.h("p", null, translate('loading', this.language))));
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
if (this.hasErrors) {
|
|
403
|
+
return (index.h("div", null, index.h("p", null, translate('error', this.language))));
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
const { rules } = this.gameData;
|
|
407
|
+
return (index.h("div", { class: "TicketContainer" }, index.h("p", null, this.gameData.name), this.resetButton && this.ticketDone &&
|
|
408
|
+
index.h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language)), this.autoPick && !this.ticketDone &&
|
|
409
|
+
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 &&
|
|
410
|
+
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 &&
|
|
411
|
+
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("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), index.h("div", { class: "WagerInput" }, rules.stakes.length > 1 ? index.h("div", null, index.h("select", { class: "InputDefault", onChange: (event) => this.changeStake(event) }, rules.stakes.map((item) => index.h("option", { value: item.amount }, 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)))));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
static get watchers() { return {
|
|
416
|
+
"numberOfDraws": ["drawsChangeHandler"]
|
|
417
|
+
}; }
|
|
418
|
+
};
|
|
419
|
+
LotteryTicket.style = lotteryTicketCss;
|
|
420
|
+
|
|
421
|
+
const lotteryTicketControllerCss = ":host{display:block}";
|
|
422
|
+
|
|
423
|
+
const LotteryTicketController = class {
|
|
424
|
+
constructor(hostRef) {
|
|
425
|
+
index.registerInstance(this, hostRef);
|
|
426
|
+
this.deleteTicketEvent = index.createEvent(this, "deleteTicket", 7);
|
|
427
|
+
/**
|
|
428
|
+
* Endpoint URL for the source of data (NorWAy standard)
|
|
429
|
+
*/
|
|
430
|
+
this.endpoint = '';
|
|
431
|
+
/**
|
|
432
|
+
* Ticket number
|
|
433
|
+
*/
|
|
434
|
+
this.ticketId = 1;
|
|
435
|
+
/**
|
|
436
|
+
* Activates postMessages as events for actions from the widget
|
|
437
|
+
*/
|
|
438
|
+
this.postMessage = false;
|
|
439
|
+
/**
|
|
440
|
+
* Name of the event emitter by the action button
|
|
441
|
+
*/
|
|
442
|
+
this.eventName = 'deleteTicketAction';
|
|
443
|
+
/**
|
|
444
|
+
* Collapsed
|
|
445
|
+
*/
|
|
446
|
+
this.collapsed = true;
|
|
447
|
+
/**
|
|
448
|
+
* Number of grids?
|
|
449
|
+
*/
|
|
450
|
+
this.numberOfGrids = 1;
|
|
451
|
+
/**
|
|
452
|
+
* This toggles if the last ticket added should be expanded or not
|
|
453
|
+
*/
|
|
454
|
+
this.last = false;
|
|
455
|
+
/**
|
|
456
|
+
* Language
|
|
457
|
+
*/
|
|
458
|
+
this.language = 'en';
|
|
459
|
+
/**
|
|
460
|
+
* Shows the auto-pick button
|
|
461
|
+
*/
|
|
462
|
+
this.autoPick = false;
|
|
463
|
+
/**
|
|
464
|
+
* Shows the reset button
|
|
465
|
+
*/
|
|
466
|
+
this.resetButton = false;
|
|
467
|
+
}
|
|
468
|
+
// @TODO fix the `any` type
|
|
469
|
+
helperAccordionActionHandler() {
|
|
470
|
+
if (this.postMessage) {
|
|
471
|
+
window.postMessage({ type: this.eventName }, window.location.href);
|
|
472
|
+
}
|
|
473
|
+
this.deleteTicketEvent.emit({
|
|
474
|
+
ticketId: this.ticketId
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
render() {
|
|
478
|
+
return (index.h("div", null, index.h("helper-accordion", { "header-title": 'Ticket ' + this.ticketId, "header-subtitle": this.ticketDescription, footer: true, "delete-tab": true, collapsed: !this.last || this.collapsed, language: this.language }, index.h("div", { slot: "accordionContent" }, index.h("lottery-ticket", { endpoint: this.endpoint, "game-id": this.gameId, "ticket-id": this.ticketId, "number-of-grids": this.numberOfGrids, language: this.language, "reset-button": this.resetButton, "auto-pick": this.autoPick })))));
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
LotteryTicketController.style = lotteryTicketControllerCss;
|
|
482
|
+
|
|
483
|
+
exports.helper_accordion = Accordion;
|
|
484
|
+
exports.lottery_bullet = LotteryBullet;
|
|
485
|
+
exports.lottery_grid = LotteryGrid;
|
|
486
|
+
exports.lottery_ticket = LotteryTicket;
|
|
487
|
+
exports.lottery_ticket_controller = LotteryTicketController;
|
|
@@ -50,7 +50,7 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
|
50
50
|
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
51
51
|
if (listeners) {
|
|
52
52
|
listeners.map(([flags, name, method]) => {
|
|
53
|
-
const target = elm;
|
|
53
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
54
54
|
const handler = hostListenerProxy(hostRef, method);
|
|
55
55
|
const opts = hostListenerOpts(flags);
|
|
56
56
|
plt.ael(target, name, handler, opts);
|
|
@@ -74,6 +74,11 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
|
74
74
|
consoleError(e);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
78
|
+
if (flags & 4 /* TargetDocument */)
|
|
79
|
+
return doc;
|
|
80
|
+
return elm;
|
|
81
|
+
};
|
|
77
82
|
// prettier-ignore
|
|
78
83
|
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
79
84
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
@@ -790,6 +795,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
790
795
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
791
796
|
// check our new property value against our internal value
|
|
792
797
|
const hostRef = getHostRef(ref);
|
|
798
|
+
const elm = hostRef.$hostElement$ ;
|
|
793
799
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
794
800
|
const flags = hostRef.$flags$;
|
|
795
801
|
const instance = hostRef.$lazyInstance$ ;
|
|
@@ -802,6 +808,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
802
808
|
// set our new value!
|
|
803
809
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
804
810
|
if (instance) {
|
|
811
|
+
// get an array of method names of watch functions to call
|
|
812
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
813
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
814
|
+
if (watchMethods) {
|
|
815
|
+
// this instance is watching for when this property changed
|
|
816
|
+
watchMethods.map((watchMethodName) => {
|
|
817
|
+
try {
|
|
818
|
+
// fire off each of the watch methods that are watching this property
|
|
819
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
820
|
+
}
|
|
821
|
+
catch (e) {
|
|
822
|
+
consoleError(e, elm);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
}
|
|
805
827
|
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
806
828
|
// looks like this value actually changed, so we've got work to do!
|
|
807
829
|
// but only if we've already rendered, otherwise just chill out
|
|
@@ -814,6 +836,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
814
836
|
};
|
|
815
837
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
816
838
|
if (cmpMeta.$members$) {
|
|
839
|
+
if (Cstr.watchers) {
|
|
840
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
841
|
+
}
|
|
817
842
|
// It's better to have a const than two Object.entries()
|
|
818
843
|
const members = Object.entries(cmpMeta.$members$);
|
|
819
844
|
const prototype = Cstr.prototype;
|
|
@@ -918,6 +943,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
918
943
|
endLoad();
|
|
919
944
|
}
|
|
920
945
|
if (!Cstr.isProxied) {
|
|
946
|
+
// we've never proxied this Constructor before
|
|
947
|
+
// let's add the getters/setters to its prototype before
|
|
948
|
+
// the first time we create an instance of the implementation
|
|
949
|
+
{
|
|
950
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
951
|
+
}
|
|
921
952
|
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
922
953
|
Cstr.isProxied = true;
|
|
923
954
|
}
|
|
@@ -941,6 +972,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
941
972
|
{
|
|
942
973
|
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
943
974
|
}
|
|
975
|
+
{
|
|
976
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
977
|
+
}
|
|
944
978
|
endNewInstance();
|
|
945
979
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
946
980
|
}
|
|
@@ -1063,6 +1097,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1063
1097
|
{
|
|
1064
1098
|
cmpMeta.$listeners$ = compactMeta[3];
|
|
1065
1099
|
}
|
|
1100
|
+
{
|
|
1101
|
+
cmpMeta.$watchers$ = {};
|
|
1102
|
+
}
|
|
1066
1103
|
const tagName = cmpMeta.$tagName$;
|
|
1067
1104
|
const HostElement = class extends HTMLElement {
|
|
1068
1105
|
// StencilLazyHost
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-c560cdc6.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([["helper-
|
|
17
|
+
return index.bootstrapLazy([["helper-accordion_5.cjs",[[1,"lottery-ticket-controller",{"endpoint":[1],"ticketId":[2,"ticket-id"],"ticketDescription":[1,"ticket-description"],"gameId":[1,"game-id"],"postMessage":[4,"post-message"],"eventName":[1,"event-name"],"collapsed":[4],"numberOfGrids":[2,"number-of-grids"],"last":[4],"language":[1],"autoPick":[4,"auto-pick"],"resetButton":[4,"reset-button"]},[[0,"helperAccordionAction","helperAccordionActionHandler"]]],[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,"helper-accordion",{"headerTitle":[1,"header-title"],"headerSubtitle":[1,"header-subtitle"],"description":[1],"footer":[4],"deleteTab":[4,"delete-tab"],"postMessage":[4,"post-message"],"eventName":[1,"event-name"],"collapsed":[4],"language":[1],"showContent":[32]}],[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
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-c560cdc6.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([["helper-
|
|
18
|
+
return index.bootstrapLazy([["helper-accordion_5.cjs",[[1,"lottery-ticket-controller",{"endpoint":[1],"ticketId":[2,"ticket-id"],"ticketDescription":[1,"ticket-description"],"gameId":[1,"game-id"],"postMessage":[4,"post-message"],"eventName":[1,"event-name"],"collapsed":[4],"numberOfGrids":[2,"number-of-grids"],"last":[4],"language":[1],"autoPick":[4,"auto-pick"],"resetButton":[4,"reset-button"]},[[0,"helperAccordionAction","helperAccordionActionHandler"]]],[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,"helper-accordion",{"headerTitle":[1,"header-title"],"headerSubtitle":[1,"header-subtitle"],"description":[1],"footer":[4],"deleteTab":[4,"delete-tab"],"postMessage":[4,"post-message"],"eventName":[1,"event-name"],"collapsed":[4],"language":[1],"showContent":[32]}],[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);
|
|
19
19
|
});
|
|
@@ -13,6 +13,24 @@
|
|
|
13
13
|
"tags": [
|
|
14
14
|
"helper-accordion"
|
|
15
15
|
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "@everymatrix/lottery-bullet",
|
|
19
|
+
"tags": [
|
|
20
|
+
"lottery-bullet"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "@everymatrix/lottery-grid",
|
|
25
|
+
"tags": [
|
|
26
|
+
"lottery-grid"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "@everymatrix/lottery-ticket",
|
|
31
|
+
"tags": [
|
|
32
|
+
"lottery-ticket"
|
|
33
|
+
]
|
|
16
34
|
}
|
|
17
35
|
],
|
|
18
36
|
"bundles": []
|