@everymatrix/lottery-ticket 0.1.6 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,6 +75,8 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
75
75
  }
76
76
  };
77
77
  const getHostListenerTarget = (elm, flags) => {
78
+ if (flags & 4 /* TargetDocument */)
79
+ return doc;
78
80
  if (flags & 8 /* TargetWindow */)
79
81
  return win;
80
82
  return elm;
@@ -268,6 +270,12 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
268
270
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
269
271
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
270
272
  }
273
+ else if (memberName === 'ref') {
274
+ // minifier will clean this up
275
+ if (newValue) {
276
+ newValue(elm);
277
+ }
278
+ }
271
279
  else if ((!isProp ) &&
272
280
  memberName[0] === 'o' &&
273
281
  memberName[1] === 'n') {
@@ -424,6 +432,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
424
432
  for (; startIdx <= endIdx; ++startIdx) {
425
433
  if ((vnode = vnodes[startIdx])) {
426
434
  elm = vnode.$elm$;
435
+ callNodeRefs(vnode);
427
436
  // remove the vnode's element from the dom
428
437
  elm.remove();
429
438
  }
@@ -542,6 +551,12 @@ const patch = (oldVNode, newVNode) => {
542
551
  elm.data = text;
543
552
  }
544
553
  };
554
+ const callNodeRefs = (vNode) => {
555
+ {
556
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
557
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
558
+ }
559
+ };
545
560
  const renderVdom = (hostRef, renderFnResults) => {
546
561
  const hostElm = hostRef.$hostElement$;
547
562
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
@@ -683,7 +698,11 @@ const postUpdateComponent = (hostRef) => {
683
698
  const tagName = hostRef.$cmpMeta$.$tagName$;
684
699
  const elm = hostRef.$hostElement$;
685
700
  const endPostUpdate = createTime('postUpdate', tagName);
701
+ const instance = hostRef.$lazyInstance$ ;
686
702
  const ancestorComponent = hostRef.$ancestorComponent$;
703
+ {
704
+ safeCall(instance, 'componentDidRender');
705
+ }
687
706
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
688
707
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
689
708
  {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-7d839bfc.js');
5
+ const index = require('./index-6033a99f.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["lottery-ticket.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32],"isCustomSelect":[32],"amountInfo":[32]},[[8,"click","checkForClickOutside"],[0,"gridFilled","gridFilledHandler"]]]]]], options);
17
+ return index.bootstrapLazy([["lottery-bullet_3.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32],"isCustomSelect":[32],"amountInfo":[32],"limitStylingAppends":[32]},[[8,"click","checkForClickOutside"],[0,"gridFilled","gridFilledHandler"]]],[1,"lottery-grid",{"ticketId":[2,"ticket-id"],"totalNumbers":[2,"total-numbers"],"gameId":[1,"game-id"],"maximumAllowed":[2,"maximum-allowed"],"minimumAllowed":[2,"minimum-allowed"],"selectable":[4],"selectedNumbers":[1,"selected-numbers"],"displaySelected":[4,"display-selected"],"language":[1],"gridIndex":[2,"grid-index"],"gridType":[1,"grid-type"],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"numbers":[32],"limitStylingAppends":[32]},[[0,"lotteryBulletSelection","lotteryBulletSelectionHandler"],[4,"resetSelection","resetSelectionHandler"],[4,"autoSelection","autoSelectionHandler"]]],[1,"lottery-bullet",{"value":[1],"selectable":[4],"isSelected":[4,"is-selected"],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"limitStylingAppends":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -0,0 +1,465 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-6033a99f.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}@-webkit-keyframes Circle{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes Circle{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes hover-rotate{0%{-webkit-transform:scale(1) rotateZ(0);transform:scale(1) rotateZ(0)}50%{-webkit-transform:scale(1.2) rotateZ(180deg);transform:scale(1.22) rotateZ(180deg)}100%{-webkit-transform:scale(1) rotateZ(360deg);transform:scale(1) rotateZ(360deg)}}@keyframes hover-rotate{0%{-webkit-transform:scale(1) rotateZ(0);transform:scale(1) rotateZ(0)}50%{-webkit-transform:scale(1.2) rotateZ(180deg);transform:scale(1.2) rotateZ(180deg)}100%{-webkit-transform:scale(1) rotateZ(360deg);transform:scale(1) rotateZ(360deg)}}@-webkit-keyframes selected-scaleUp{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1.2);transform:scale(1.2)}}@keyframes selected-scaleUp{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}.Circle{-webkit-animation:Circle 0.8s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:Circle 0.8s cubic-bezier(0.39, 0.575, 0.565, 1) both;cursor:pointer;color:#000000;display:block;height:30px;width:30px;margin:0;display:flex;align-items:center;justify-content:center;justify-content:center;align-items:center;border:solid 2px #ffffff;background:radial-gradient(circle at top, white 0%, white 100%);font-weight:bold;border-radius:50%;box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.5);user-select:none;font-size:16px;line-height:16px;font-weight:600;position:relative}.Circle:hover{-webkit-animation:hover-rotate 0.4s linear both;animation:hover-rotate 0.4s linear both;background:radial-gradient(circle at top, white 0%, #f1f1f1 100%)}.Circle.Selected{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;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{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#f1f1f1;background:#D4D4D4;border:solid 2px #D4D4D4;cursor:default}.Circle.DisabledSelected{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#f1f1f1;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 #D4D4D4;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
+ /**
26
+ * Client custom styling via string
27
+ */
28
+ this.clientStyling = '';
29
+ /**
30
+ * Client custom styling via url content
31
+ */
32
+ this.clientStylingUrlContent = '';
33
+ this.limitStylingAppends = false;
34
+ this.select = () => {
35
+ if (this.selectable) {
36
+ this.isSelected = !this.isSelected;
37
+ this.bulletEvent.emit({
38
+ value: this.value,
39
+ selected: this.isSelected
40
+ });
41
+ }
42
+ };
43
+ this.setClientStyling = () => {
44
+ let sheet = document.createElement('style');
45
+ sheet.innerHTML = this.clientStyling;
46
+ this.stylingContainer.prepend(sheet);
47
+ };
48
+ this.setClientStylingURL = () => {
49
+ let cssFile = document.createElement('style');
50
+ setTimeout(() => {
51
+ cssFile.innerHTML = this.clientStylingUrlContent;
52
+ this.stylingContainer.prepend(cssFile);
53
+ }, 1);
54
+ };
55
+ }
56
+ componentDidRender() {
57
+ // start custom styling area
58
+ if (!this.limitStylingAppends && this.stylingContainer) {
59
+ if (this.clientStyling)
60
+ this.setClientStyling();
61
+ if (this.clientStylingUrlContent)
62
+ this.setClientStylingURL();
63
+ this.limitStylingAppends = true;
64
+ }
65
+ // end custom styling area
66
+ }
67
+ render() {
68
+ return (index.h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select(), ref: el => this.stylingContainer = el }, this.value));
69
+ }
70
+ };
71
+ LotteryBullet.style = lotteryBulletCss;
72
+
73
+ const lotteryGridCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GridContainer{display:flex;flex-direction:column;max-width:1200px}.Grid{margin-top:10px 0 10px 0;display:flex;flex-direction:row;flex-wrap:wrap;gap:20px}.Grid.TicketGrid{gap:5px}";
74
+
75
+ const LotteryGrid = class {
76
+ constructor(hostRef) {
77
+ index.registerInstance(this, hostRef);
78
+ this.gridFilledEvent = index.createEvent(this, "gridFilled", 7);
79
+ this.gridDirtyEvent = index.createEvent(this, "gridDirty", 7);
80
+ /**
81
+ * Number of bullets of grid
82
+ */
83
+ this.totalNumbers = 0;
84
+ /**
85
+ * Number of maximum bullets that can be selected
86
+ */
87
+ this.maximumAllowed = 0;
88
+ /**
89
+ * Minimum allowed of bullets
90
+ */
91
+ this.minimumAllowed = 1;
92
+ /**
93
+ * Allows the user to select numbers on the grid
94
+ */
95
+ this.selectable = true;
96
+ /**
97
+ * Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
98
+ */
99
+ this.selectedNumbers = '';
100
+ /**
101
+ * Show only selected numbers
102
+ */
103
+ this.displaySelected = false;
104
+ /**
105
+ * Language
106
+ */
107
+ this.language = 'en';
108
+ /**
109
+ * Personalize grid for ticket
110
+ */
111
+ this.gridType = '';
112
+ /**
113
+ * Client custom styling via string
114
+ */
115
+ this.clientStyling = '';
116
+ /**
117
+ * Client custom styling via url content
118
+ */
119
+ this.clientStylingUrlContent = '';
120
+ this.numbers = [];
121
+ this.limitStylingAppends = false;
122
+ this.selectedCounter = 0;
123
+ this.setClientStyling = () => {
124
+ let sheet = document.createElement('style');
125
+ sheet.innerHTML = this.clientStyling;
126
+ this.stylingContainer.prepend(sheet);
127
+ };
128
+ this.setClientStylingURL = () => {
129
+ let cssFile = document.createElement('style');
130
+ setTimeout(() => {
131
+ cssFile.innerHTML = this.clientStylingUrlContent;
132
+ this.stylingContainer.prepend(cssFile);
133
+ }, 1);
134
+ };
135
+ }
136
+ connectedCallback() {
137
+ let selected = [];
138
+ if (this.selectedNumbers.length > 0) {
139
+ selected = this.selectedNumbers.split(',');
140
+ this.selectedCounter = selected.length;
141
+ }
142
+ if (this.displaySelected) {
143
+ selected.forEach((item) => {
144
+ this.numbers.push({
145
+ number: item,
146
+ selected: true,
147
+ selectable: this.selectable
148
+ });
149
+ });
150
+ }
151
+ else {
152
+ [...Array(this.totalNumbers).keys()]
153
+ .map(number => (number + 1).toString())
154
+ .forEach((number) => {
155
+ this.numbers.push({
156
+ number,
157
+ selected: selected.indexOf(number) >= 0 ? true : false,
158
+ selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
159
+ });
160
+ });
161
+ }
162
+ }
163
+ componentDidRender() {
164
+ // start custom styling area
165
+ if (!this.limitStylingAppends && this.stylingContainer) {
166
+ if (this.clientStyling)
167
+ this.setClientStyling();
168
+ if (this.clientStylingUrlContent)
169
+ this.setClientStylingURL();
170
+ this.limitStylingAppends = true;
171
+ }
172
+ // end custom styling area
173
+ }
174
+ lotteryBulletSelectionHandler(event) {
175
+ this.numbers = this.numbers.map((item) => {
176
+ if (item.number == event.detail.value) {
177
+ return {
178
+ number: item.number,
179
+ selected: event.detail.selected,
180
+ selectable: item.selectable
181
+ };
182
+ }
183
+ return {
184
+ number: item.number,
185
+ selected: item.selected,
186
+ selectable: item.selectable
187
+ };
188
+ });
189
+ if (event.detail.selected) {
190
+ this.selectedCounter += 1;
191
+ if (this.selectedCounter == this.maximumAllowed) {
192
+ this.numbers = this.numbers.map((item) => {
193
+ return {
194
+ number: item.number,
195
+ selected: item.selected,
196
+ selectable: item.selected ? true : false
197
+ };
198
+ });
199
+ this.gridFilledEvent.emit({
200
+ id: this.ticketId,
201
+ index: this.gridIndex,
202
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
203
+ });
204
+ }
205
+ }
206
+ else {
207
+ if (this.selectedCounter == this.maximumAllowed) {
208
+ this.numbers = this.numbers.map((item) => {
209
+ return {
210
+ number: item.number,
211
+ selected: item.selected,
212
+ selectable: true
213
+ };
214
+ });
215
+ this.gridDirtyEvent.emit({
216
+ id: this.ticketId,
217
+ index: this.gridIndex,
218
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
219
+ });
220
+ }
221
+ this.selectedCounter -= 1;
222
+ }
223
+ }
224
+ async resetSelectionHandler(event) {
225
+ if (event.detail && event.detail == this.ticketId) {
226
+ this.selectedCounter = 0;
227
+ this.numbers = this.numbers.map((item) => {
228
+ return {
229
+ number: item.number,
230
+ selected: false,
231
+ selectable: this.selectable
232
+ };
233
+ });
234
+ this.gridDirtyEvent.emit({
235
+ id: this.ticketId,
236
+ index: this.gridIndex,
237
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
238
+ });
239
+ }
240
+ }
241
+ async autoSelectionHandler(event) {
242
+ if (event.detail && event.detail == this.ticketId) {
243
+ this.resetSelectionHandler(event);
244
+ let array = [...Array(this.totalNumbers).keys()]
245
+ .map(number => number + 1)
246
+ .sort(() => 0.5 - Math.random());
247
+ array = array.slice(0, this.minimumAllowed);
248
+ this.numbers = this.numbers.map((item) => {
249
+ return {
250
+ number: item.number,
251
+ selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
252
+ selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
253
+ };
254
+ });
255
+ this.gridFilledEvent.emit({
256
+ id: this.ticketId,
257
+ index: this.gridIndex,
258
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
259
+ });
260
+ this.selectedCounter = this.maximumAllowed;
261
+ }
262
+ }
263
+ render() {
264
+ return (index.h("div", { class: "GridContainer", ref: el => this.stylingContainer = el }, index.h("div", { class: this.gridType === 'ticket' ? 'Grid TicketGrid' : 'Grid' }, this.numbers.map((item) => index.h("div", null, index.h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }))))));
265
+ }
266
+ };
267
+ LotteryGrid.style = lotteryGridCss;
268
+
269
+ const DEFAULT_LANGUAGE = 'en';
270
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
271
+ const TRANSLATIONS = {
272
+ en: {
273
+ loading: 'Loading, please wait ...',
274
+ error: 'It was an error while trying to fetch the data',
275
+ grid: 'Grid',
276
+ multiplier: 'Multiplier',
277
+ numberOfDraws: 'Number of draws',
278
+ wagerPerDraw: 'Wager per draw',
279
+ resetButton: 'Reset',
280
+ autoButton: 'I feel lucky'
281
+ },
282
+ ro: {
283
+ loading: 'Se incarca, va rugam asteptati ...',
284
+ error: 'A fost o eroare in timp ce asteptam datele',
285
+ grid: 'Grid',
286
+ multiplier: 'Multiplicator',
287
+ numberOfDraws: 'Numarul de extrageri',
288
+ wagerPerDraw: 'Pariul per extragere',
289
+ resetButton: 'Reseteaza',
290
+ autoButton: 'Ma simt norocos'
291
+ },
292
+ };
293
+ const translate = (key, customLang) => {
294
+ const lang = customLang;
295
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
296
+ };
297
+
298
+ const lotteryTicketCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.TicketTitle{font-size:16px;font-weight:bold}.ButtonContainer{display:flex;justify-content:flex-end}.Toggle{cursor:pointer;margin-top:20px;display:inline-block}.ToggleSwitch{display:inline-block;background:#707070;border-radius:16px;width:58px;height:24px;position:relative;vertical-align:middle;transition:background 0.25s}.ToggleSwitch:before,.ToggleSwitch:after{content:\"\"}.ToggleSwitch:before{display:block;background:linear-gradient(to bottom, #fff 0%, #F1F1F1 100%);border-radius:50%;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25);width:16px;height:16px;position:absolute;top:4px;left:4px;transition:left 0.25s}.Toggle:hover .ToggleSwitch:before{background:linear-gradient(to bottom, #fff 0%, #fff 100%);box-shadow:0 0 0 1px rgba(0, 0, 0, 0.5)}.ToggleCheckbox:checked+.ToggleSwitch{background:#00ABA4}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{margin-right:5px;position:relative;top:2px;font-size:14px;font-weight:lighter;color:#000}input[type=number]{-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.NumberInput,.WagerInput{margin-top:10px;display:inline-flex;align-items:center}.NumberInput,.NumberInput *{box-sizing:border-box}.NumberInput button{cursor:pointer;outline:none;-webkit-appearance:none;border:none;align-items:center;justify-content:center;height:20px;position:relative}.NumberInput button:after{display:inline-block;position:absolute;transform:translate(-50%, -50%) rotate(180deg);align-items:center;text-align:center}.NumberInput button.Plus:after{transform:translate(-50%, -50%) rotate(0deg);width:30px;display:inline-flex;align-items:center;text-align:center}.NumberInput input[type=number],.WagerInput input[type=number]{max-width:50px;display:inline-flex;align-items:center;padding:4px 10px;text-align:center}.NumberInput input[type=number] .WagerInputTitle,.WagerInput input[type=number] .WagerInputTitle{font-size:14px;color:#000;padding:10px}.InputDefault{background-color:#F1F1F1;border-radius:4px;padding:5px;border:solid 1px #D4D4D4;color:#707070}.AutoButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.AutoButton:active{background:#00958f;color:#FFF}.ResetButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ResetButton:hover{background:#FF6536;border:1px solid #FF3D00}.TicketGridBullets{background:#f1f1f1;border-radius:4px;padding:20px;margin-top:5px}.TicketGridBullets .TicketGridTitle{margin-top:0px}.Minus{border-radius:4px;width:30px;height:24px !important;margin-right:10px;color:#FFF;background:#009993}.Plus{border-radius:4px;width:30px;height:24px !important;margin-left:10px;color:#FFF;background:#009993}.SelectWrapper{width:auto;padding:5px;margin:0 auto;border:1px solid #ccc;border-radius:5px;position:relative}.SelectButton,.SelectOptions li{display:flex;align-items:center;cursor:pointer}.SelectButton{display:flex;padding:0 5px;border-radius:7px;align-items:center;justify-content:space-between;font-size:14px}.SelectButton span:first-child{padding-right:10px}.SelectExpand{transition:transform 0.3s linear;font-size:12px}.SelectActive .SelectExpand{transform:rotate(180deg)}.SelectContent{display:none;padding:5px;border-radius:7px}.SelectWrapper.SelectActive .SelectContent{width:100%;display:block;position:absolute;left:0;top:32px;padding:0;border:1px solid #ccc;overflow:hidden;background:#fff}.SelectContent .SelectOptions{max-height:100px;margin:0;overflow-y:auto;padding:0}.SelectContent .SelectOptions .SelectedValue{background-color:#009993;color:#fff}.SelectOptions::-webkit-scrollbar{width:7px}.SelectOptions::-webkit-scrollbar-track{background:#f1f1f1;border-radius:25px}.SelectOptions::-webkit-scrollbar-thumb{background:#ccc;border-radius:25px}.SelectOptions li{height:20px;padding:0 13px;font-size:14px}.SelectOptions li:hover{background:#f2f2f2}";
299
+
300
+ const LotteryTicket = class {
301
+ constructor(hostRef) {
302
+ index.registerInstance(this, hostRef);
303
+ this.ticketCompleted = index.createEvent(this, "ticketCompleted", 7);
304
+ this.autoSelection = index.createEvent(this, "autoSelection", 7);
305
+ this.resetSelection = index.createEvent(this, "resetSelection", 7);
306
+ this.stakeChange = index.createEvent(this, "stakeChange", 7);
307
+ this.multiplierChange = index.createEvent(this, "multiplierChange", 7);
308
+ /**
309
+ * Number of grids of a ticket
310
+ */
311
+ this.numberOfGrids = 1;
312
+ /**
313
+ * Option to have the ticket registered for multiple draws
314
+ */
315
+ this.multipleDraws = true;
316
+ /**
317
+ * Shows the reset button
318
+ */
319
+ this.resetButton = false;
320
+ /**
321
+ * Shows the auto-pick button
322
+ */
323
+ this.autoPick = false;
324
+ /**
325
+ * Language
326
+ */
327
+ this.language = 'en';
328
+ /**
329
+ * Client custom styling via string
330
+ */
331
+ this.clientStyling = '';
332
+ /**
333
+ * Client custom styling via url content
334
+ */
335
+ this.clientStylingUrlContent = '';
336
+ this.multiplier = false;
337
+ this.numberOfDraws = 1;
338
+ this.isLoading = true;
339
+ this.hasErrors = false;
340
+ this.ticketDone = false;
341
+ this.isCustomSelect = false;
342
+ this.amountInfo = {};
343
+ this.limitStylingAppends = false;
344
+ this.setClientStyling = () => {
345
+ let sheet = document.createElement('style');
346
+ sheet.innerHTML = this.clientStyling;
347
+ this.stylingContainer.prepend(sheet);
348
+ };
349
+ this.setClientStylingURL = () => {
350
+ let cssFile = document.createElement('style');
351
+ setTimeout(() => {
352
+ cssFile.innerHTML = this.clientStylingUrlContent;
353
+ this.stylingContainer.prepend(cssFile);
354
+ }, 1);
355
+ };
356
+ }
357
+ /**
358
+ * @TODO find a better way to implement click outside the custom select, so that we don't have to use the 'data-cluster' attribute on each element
359
+ */
360
+ checkForClickOutside(ev) {
361
+ if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
362
+ this.isCustomSelect = false;
363
+ }
364
+ }
365
+ connectedCallback() {
366
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
367
+ fetch(url.href)
368
+ .then((response) => {
369
+ if (response.ok) {
370
+ return response.json();
371
+ }
372
+ else {
373
+ // Throw error
374
+ this.hasErrors = true;
375
+ }
376
+ })
377
+ .then((data) => {
378
+ this.isLoading = false;
379
+ this.gameData = data;
380
+ this.grids = [...Array(data.rules.boards.length).keys()];
381
+ this.amountInfo = this.gameData.rules.stakes[0]; // initial value for select
382
+ })
383
+ .catch((err) => {
384
+ this.isLoading = false;
385
+ this.hasErrors = true;
386
+ console.error('Error!', err);
387
+ });
388
+ }
389
+ componentDidRender() {
390
+ // start custom styling area
391
+ if (!this.limitStylingAppends && this.stylingContainer) {
392
+ if (this.clientStyling)
393
+ this.setClientStyling();
394
+ if (this.clientStylingUrlContent)
395
+ this.setClientStylingURL();
396
+ this.limitStylingAppends = true;
397
+ }
398
+ // end custom styling area
399
+ }
400
+ multiplierChangeHandler(e) {
401
+ this.multiplier = e.target ? e.target.checked : false;
402
+ this.multiplierChange.emit(this.multiplier);
403
+ }
404
+ drawsChangeHandler(event) {
405
+ this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
406
+ this.ticketCompleted.emit(this.ticket);
407
+ }
408
+ gridFilledHandler(event) {
409
+ this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
410
+ this.ticketDone = true;
411
+ this.ticketCompleted.emit(this.ticket);
412
+ }
413
+ toggleAutoSelection() {
414
+ this.ticketDone = true;
415
+ this.autoSelection.emit(this.ticketId);
416
+ }
417
+ toggleResetSelection() {
418
+ this.ticketDone = false;
419
+ this.resetSelection.emit(this.ticketId);
420
+ }
421
+ changeStake(ticketid, amount) {
422
+ this.stakeChange.emit({
423
+ ticketId: ticketid,
424
+ stake: amount
425
+ });
426
+ }
427
+ toggleClass() {
428
+ this.isCustomSelect = !this.isCustomSelect;
429
+ }
430
+ setDropdownItem(item) {
431
+ this.amountInfo = {
432
+ amount: item.amount,
433
+ currency: item.currency
434
+ };
435
+ this.isCustomSelect = false;
436
+ this.changeStake(this.ticketId, item.amount);
437
+ }
438
+ render() {
439
+ if (this.isLoading) {
440
+ return (index.h("div", null, index.h("p", null, translate('loading', this.language))));
441
+ }
442
+ else {
443
+ if (this.hasErrors) {
444
+ return (index.h("div", null, index.h("p", null, translate('error', this.language))));
445
+ }
446
+ else {
447
+ const { rules } = this.gameData;
448
+ return (index.h("div", { class: "TicketContainer", ref: el => this.stylingContainer = el }, index.h("p", { class: "TicketTitle" }, this.gameData.name), this.resetButton && this.ticketDone &&
449
+ index.h("div", { class: "ButtonContainer" }, index.h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language))), this.autoPick && !this.ticketDone &&
450
+ index.h("div", { class: "ButtonContainer" }, index.h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language))), this.grids.map((item, index$1) => index.h("div", { class: "TicketGridBullets" }, index.h("p", { class: "TicketGridTitle" }, translate('grid', this.language), " ", item), index.h("lottery-grid", { "grid-index": index$1, "maximum-allowed": rules.boards[index$1].maximumAllowed, "minimum-allowed": rules.boards[index$1].minimumAllowed, "total-numbers": rules.boards[index$1].totalNumbers, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }))), rules.multiplier &&
451
+ 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 &&
452
+ index.h("div", { class: "TicketDraws" }, index.h("label", { class: "Label" }, translate('numberOfDraws', this.language), ": "), index.h("div", { class: "NumberInput" }, index.h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), index.h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), index.h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), index.h("div", null, index.h("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), index.h("div", { class: "WagerInput" }, rules.stakes.length > 1 ?
453
+ (index.h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" }, index.h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() }, index.h("span", { "data-cluster": "SelectComponent" }, this.amountInfo.amount, " ", this.amountInfo.currency), index.h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")), index.h("div", { "data-cluster": "SelectComponent", class: "SelectContent" }, index.h("ul", { "data-cluster": "SelectComponent", class: "SelectOptions" }, rules.stakes.map((item) => index.h("li", { "data-cluster": "SelectComponent", class: this.amountInfo.amount == item.amount ? 'SelectedValue' : '', value: item.amount, onClick: () => this.setDropdownItem(item) }, item.amount, " ", item.currency)))))) : (index.h("div", null, index.h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }), index.h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))))));
454
+ }
455
+ }
456
+ }
457
+ static get watchers() { return {
458
+ "numberOfDraws": ["drawsChangeHandler"]
459
+ }; }
460
+ };
461
+ LotteryTicket.style = lotteryTicketCss;
462
+
463
+ exports.lottery_bullet = LotteryBullet;
464
+ exports.lottery_grid = LotteryGrid;
465
+ exports.lottery_ticket = LotteryTicket;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-7d839bfc.js');
3
+ const index = require('./index-6033a99f.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["lottery-ticket.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32],"isCustomSelect":[32],"amountInfo":[32]},[[8,"click","checkForClickOutside"],[0,"gridFilled","gridFilledHandler"]]]]]], options);
18
+ return index.bootstrapLazy([["lottery-bullet_3.cjs",[[1,"lottery-ticket",{"endpoint":[1],"gameId":[1,"game-id"],"numberOfGrids":[2,"number-of-grids"],"multipleDraws":[4,"multiple-draws"],"ticketId":[2,"ticket-id"],"resetButton":[4,"reset-button"],"autoPick":[4,"auto-pick"],"language":[1],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"multiplier":[32],"numberOfDraws":[32],"isLoading":[32],"hasErrors":[32],"ticketDone":[32],"isCustomSelect":[32],"amountInfo":[32],"limitStylingAppends":[32]},[[8,"click","checkForClickOutside"],[0,"gridFilled","gridFilledHandler"]]],[1,"lottery-grid",{"ticketId":[2,"ticket-id"],"totalNumbers":[2,"total-numbers"],"gameId":[1,"game-id"],"maximumAllowed":[2,"maximum-allowed"],"minimumAllowed":[2,"minimum-allowed"],"selectable":[4],"selectedNumbers":[1,"selected-numbers"],"displaySelected":[4,"display-selected"],"language":[1],"gridIndex":[2,"grid-index"],"gridType":[1,"grid-type"],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"numbers":[32],"limitStylingAppends":[32]},[[0,"lotteryBulletSelection","lotteryBulletSelectionHandler"],[4,"resetSelection","resetSelectionHandler"],[4,"autoSelection","autoSelectionHandler"]]],[1,"lottery-bullet",{"value":[1],"selectable":[4],"isSelected":[4,"is-selected"],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"limitStylingAppends":[32]}]]]], options);
19
19
  });
@@ -7,12 +7,19 @@
7
7
  "version": "2.15.2",
8
8
  "typescriptVersion": "4.5.4"
9
9
  },
10
- "collections": [],
11
- "bundles": [
10
+ "collections": [
12
11
  {
13
- "components": [
14
- "lottery-ticket"
12
+ "name": "@everymatrix/lottery-bullet",
13
+ "tags": [
14
+ "lottery-bullet"
15
+ ]
16
+ },
17
+ {
18
+ "name": "@everymatrix/lottery-grid",
19
+ "tags": [
20
+ "lottery-grid"
15
21
  ]
16
22
  }
17
- ]
23
+ ],
24
+ "bundles": []
18
25
  }