@everymatrix/lottery-draw-results 0.0.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/cjs/{index-03778cb9.js → index-62f030ff.js} +81 -7
  2. package/dist/cjs/loader.cjs.js +3 -3
  3. package/dist/cjs/lottery-bullet_3.cjs.entry.js +383 -0
  4. package/dist/cjs/lottery-draw-results.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +15 -2
  6. package/dist/collection/components/lottery-draw-results/lottery-draw-results.css +18 -7
  7. package/dist/collection/components/lottery-draw-results/lottery-draw-results.js +169 -56
  8. package/dist/collection/utils/locale.utils.js +14 -2
  9. package/dist/components/index.d.ts +5 -1
  10. package/dist/components/index.js +0 -1
  11. package/dist/components/lottery-bullet.js +6 -0
  12. package/dist/components/lottery-bullet2.js +56 -0
  13. package/dist/components/lottery-draw-results.js +73 -48
  14. package/dist/components/lottery-grid.js +6 -0
  15. package/dist/components/lottery-grid2.js +196 -0
  16. package/dist/esm/{index-17920f23.js → index-98326ddd.js} +81 -8
  17. package/dist/esm/loader.js +3 -3
  18. package/dist/esm/lottery-bullet_3.entry.js +377 -0
  19. package/dist/esm/lottery-draw-results.js +3 -3
  20. package/dist/lottery-draw-results/lottery-draw-results.esm.js +1 -1
  21. package/dist/lottery-draw-results/p-bb429486.js +1 -0
  22. package/dist/lottery-draw-results/p-d653e278.entry.js +1 -0
  23. package/dist/types/components/lottery-draw-results/lottery-draw-results.d.ts +28 -3
  24. package/dist/types/components.d.ts +56 -2
  25. package/package.json +1 -1
  26. package/dist/cjs/lottery-draw-results.cjs.entry.js +0 -179
  27. package/dist/esm/lottery-draw-results.entry.js +0 -175
  28. package/dist/lottery-draw-results/p-62092f31.js +0 -2
  29. package/dist/lottery-draw-results/p-c6628b24.entry.js +0 -1
@@ -1,5 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
- import '@everymatrix/lottery-grid';
2
+ import { d as defineCustomElement$3 } from './lottery-bullet2.js';
3
+ import { d as defineCustomElement$2 } from './lottery-grid2.js';
3
4
 
4
5
  const DEFAULT_LANGUAGE = 'en';
5
6
  const SUPPORTED_LANGUAGES = ['ro', 'en'];
@@ -13,7 +14,13 @@ const TRANSLATIONS = {
13
14
  drawNumbersGridTicket: 'Draw numbers Grid B',
14
15
  ticketResult: 'Ticket result',
15
16
  amountWon: 'Amount won',
16
- numberOfDraws: 'Number of draws'
17
+ numberOfDraws: 'Number of draws',
18
+ multiplier: 'Multiplier:',
19
+ ticketPurchaseDate: 'Ticket Purchase Date',
20
+ ticketStatus: 'Ticket Status',
21
+ ticketId: 'Ticket ID',
22
+ ticketAmount: 'Ticket Amount',
23
+ winUpTo: 'Win up to',
17
24
  },
18
25
  ro: {
19
26
  drawResultsHeader: 'Ultimele rezultate extragere',
@@ -24,7 +31,13 @@ const TRANSLATIONS = {
24
31
  drawNumbersGridTicket: 'Numerele extrase Grid B',
25
32
  ticketResult: 'Rezultatul biletului',
26
33
  amountWon: 'Suma castigata',
27
- numberOfDraws: 'Numarul de extrageri'
34
+ numberOfDraws: 'Numarul de extrageri',
35
+ multiplier: 'Multiplicator:',
36
+ ticketPurchaseDate: 'Data achizitionarii biletului',
37
+ ticketStatus: 'Statusul biletului',
38
+ ticketId: 'Id biletul',
39
+ ticketAmount: 'Valoarea biletului',
40
+ winUpTo: 'Poti castiga'
28
41
  },
29
42
  };
30
43
  const translate = (key, customLang) => {
@@ -32,22 +45,8 @@ const translate = (key, customLang) => {
32
45
  return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
33
46
  };
34
47
 
35
- 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}";
48
+ 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}.DrawResultsArea{margin-top:15px}.DrawResultsSection{max-width:600px;margin:0px auto;border-radius:4px}.DrawResultsHeader{display:flex;justify-content:space-between;padding:10px 20px;background-color:#009993;color:#fff;font-size:14px;border-radius:4px 4px 0 0}.DrawResultsHeader h4{text-transform:uppercase;font-weight:400;margin:0;padding-top:15px}.DrawMultipler label{display:block;margin:15px 0}.DrawResultsBody{padding:0px 20px;margin-bottom:5px;border-radius:0 0 4px 4px;border:1px solid #009993}.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{line-height:12px;font-weight:lighter;width:100%;height:100%;max-height:70px;float:left;margin:0 0 20px 0;border:1px solid #f1f1f1;background:#fff;border-radius:4px;padding:10px;-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;box-shadow:rgba(99, 99, 99, 0.2) 0px 2px 8px 0px}.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}";
36
49
 
37
- const DEFAULT_VALUES = {
38
- gamename: 'Chrono',
39
- gamedate: '24/09/2022',
40
- state: 'Processing',
41
- amount: 304444,
42
- ticketid: '6963444',
43
- selection: '[5, 6, 7, 8, 9]',
44
- multiplier: 4.5,
45
- resultstatus: 'Processing',
46
- drawstatus: 'Won',
47
- drawamount: 1022,
48
- drawid: '54545555',
49
- drawdate: '24/09/2032'
50
- };
51
50
  const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
52
51
  constructor() {
53
52
  super();
@@ -61,9 +60,39 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
61
60
  * Shows only the last draw
62
61
  */
63
62
  this.drawMode = false;
63
+ /**
64
+ * The drawID (option)
65
+ */
66
+ this.drawId = '';
67
+ /**
68
+ * The game name
69
+ */
64
70
  this.gameName = '';
65
- this.multiplier = 5.434;
66
- this.ticketData = {};
71
+ /**
72
+ * The ticket submission date
73
+ */
74
+ this.ticketDate = '';
75
+ /**
76
+ * The ticket status
77
+ */
78
+ this.ticketStatus = '';
79
+ /**
80
+ * The ticket id
81
+ */
82
+ this.ticketId = '';
83
+ /**
84
+ * The ticket amount
85
+ */
86
+ this.ticketAmount = '';
87
+ /**
88
+ * The ticket multiplier
89
+ */
90
+ this.ticketMultiplier = false;
91
+ /**
92
+ * The ticket draw count
93
+ */
94
+ this.ticketDrawCount = 0;
95
+ this.multiplier = 3;
67
96
  this.isLoading = true;
68
97
  this.drawResults = [];
69
98
  this.rules = {};
@@ -85,9 +114,6 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
85
114
  connectedCallback() {
86
115
  let promises = [];
87
116
  promises.push(this.getGameData());
88
- if (this.playerId) {
89
- promises.push(this.getTicketData());
90
- }
91
117
  if (this.drawId) {
92
118
  promises.push(this.getDrawData());
93
119
  }
@@ -107,9 +133,11 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
107
133
  .then((data) => {
108
134
  this.drawData = data;
109
135
  resolve(true);
136
+ this.isLoading = false;
110
137
  })
111
138
  .catch((err) => {
112
139
  reject(err);
140
+ this.isLoading = false;
113
141
  });
114
142
  });
115
143
  }
@@ -126,6 +154,8 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
126
154
  totalNumbers: data.rules.boards[0].totalNumbers
127
155
  };
128
156
  resolve(true);
157
+ this.isLoading = false;
158
+ this.hasErrors = false;
129
159
  })
130
160
  .catch((err) => {
131
161
  this.isLoading = false;
@@ -135,26 +165,7 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
135
165
  });
136
166
  });
137
167
  }
138
- getTicketData() {
139
- return new Promise((resolve, reject) => {
140
- let url = new URL(`${this.endpoint}/tickets/player/${this.playerId}`);
141
- fetch(url.href)
142
- .then((response) => {
143
- return response.json();
144
- })
145
- .then((data) => {
146
- this.ticketData = data.length === 0 ? DEFAULT_VALUES : data[1];
147
- this.drawResults = this.ticketData.drawResults.map((item) => item);
148
- this.selection = this.ticketData.selection[0].join(',');
149
- resolve(true);
150
- })
151
- .catch((err) => {
152
- reject(err);
153
- });
154
- });
155
- }
156
168
  render() {
157
- var _a, _b, _c, _d, _e, _f;
158
169
  if (this.isLoading) {
159
170
  return (h("p", null, "Loading, please wait ..."));
160
171
  }
@@ -163,12 +174,11 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
163
174
  }
164
175
  else {
165
176
  return (h("section", { class: "DrawResultsSection" }, !this.drawMode ?
166
- h("div", { class: "DrawResultsArea" }, h("div", { class: "TicketInfo" }, h("div", { class: "TicketGameName" }, translate('drawName', this.language), ": ", h("span", null, this.gameName)), h("div", { class: "TicketDate" }, "Ticket Purchase Date: ", h("span", null, (_a = this.ticketData) === null || _a === void 0 ? void 0 : _a.createdAt.slice(0, 10))), h("div", { class: "TicketStatus" }, "Status: ", h("span", null, (_b = this.ticketData) === null || _b === void 0 ? void 0 : _b.state))), h("div", { class: "DrawResultsBody" }, h("div", { class: "TicketIdContainer" }, h("p", null, "Ticket id: ", h("span", null, (_c = this.ticketData) === null || _c === void 0 ? void 0 : _c.id))), h("div", { class: "TicketAmountContainer" }, h("p", null, "Ticket amount: ", h("span", null, (_d = this.ticketData) === null || _d === void 0 ? void 0 : _d.amount))), h("div", { class: "DrawNumbersGrid" }, h("p", null, translate('drawNumbersGridTicket', this.language), ":"), h("div", { class: "BulletContainer" }, 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 }))), h("div", { class: "DrawMultipler" }, h("label", { class: "Label" }, "Multiplier: ", h("span", null, JSON.stringify((_e = this.ticketData) === null || _e === void 0 ? void 0 : _e.multiplier)))), h("div", { class: "NumberOfDrawsContainer" }, h("p", null, translate('numberOfDraws', this.language), ": ", (_f = this.ticketData) === null || _f === void 0 ? void 0 :
167
- _f.drawCount), h("div", { class: "DrawTicketsContainer" }, this.drawResults.map((item, index) => h("div", { class: "ExpandableBoxes" }, h("div", { class: this.toggleDrawer[index] ? 'ExpandableBox ShowBox' : 'ExpandableBox', onClick: () => this.changeBox(index) }, h("div", { class: "TicketResultContainer" }, h("p", null, translate('ticketResult', this.language), ": ", item.status)), item.state == 'won' &&
168
- h("div", { class: "AmountWonContainer" }, h("p", null, translate('amountWon', this.language), ": ", Number(item.amount).toLocaleString('en'), " ", item.currency)), h("div", { class: "DrawIdContainer" }, h("p", null, translate('drawId', this.language), ": ", item.drawId)), h("div", { class: "DrawDateContainer" }, h("p", null, translate('drawDate', this.language), ": ", item.updatedAt.slice(0, 10), " | ", item.updatedAt.slice(11, 19))), h("div", { class: "DrawNumbersGrid" }), h("div", { class: "DrawMultipler" }, h("label", { class: "Label" }, "Multiplier: ", item.multiplier)))))))))
177
+ h("div", { class: "DrawResultsArea" }, h("div", { class: "TicketInfo" }, h("div", { class: "TicketGameName" }, translate('drawName', this.language), ": ", h("span", null, this.gameName)), h("div", { class: "TicketDate" }, translate('ticketPurchaseDate', this.language), ": ", h("span", null, this.ticketDate.slice(0, 10))), h("div", { class: "TicketStatus" }, translate('ticketStatus', this.language), ": ", h("span", null, this.ticketStatus))), h("div", { class: "DrawResultsBody" }, h("div", { class: "TicketIdContainer" }, h("p", null, translate('ticketId', this.language), ": ", h("span", null, this.ticketId))), h("div", { class: "TicketAmountContainer" }, h("p", null, translate('ticketAmount', this.language), " ", h("span", null, this.ticketAmount))), h("div", { class: "DrawNumbersGrid" }, h("p", null, translate('drawNumbersGridTicket', this.language), ":"), h("div", { class: "BulletContainer" }, 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 }))), h("div", { class: "DrawMultipler" }, h("label", { class: "Label" }, translate('winUpTo', this.language), " ", h("span", null, JSON.stringify(this.ticketMultiplier)))), h("div", { class: "NumberOfDrawsContainer" }, h("p", null, translate('numberOfDraws', this.language), ": ", this.ticketDrawCount), h("div", { class: "DrawTicketsContainer" }, this.drawResults.map((item, index) => h("div", { class: "ExpandableBoxes" }, h("div", { class: this.toggleDrawer[index] ? 'ExpandableBox ShowBox' : 'ExpandableBox', onClick: () => this.changeBox(index) }, h("div", { class: "TicketResultContainer" }, h("p", null, translate('ticketResult', this.language), ": ", item.status)), item.state == 'won' &&
178
+ h("div", { class: "AmountWonContainer" }, h("p", null, translate('amountWon', this.language), ": ", Number(item.amount).toLocaleString('en'), " ", item.currency)), h("div", { class: "DrawIdContainer" }, h("p", null, translate('drawId', this.language), ": ", item.drawId)), h("div", { class: "DrawDateContainer" }, h("p", null, translate('drawDate', this.language), ": ", item.updatedAt.slice(0, 10), " | ", item.updatedAt.slice(11, 19))), h("div", { class: "DrawNumbersGrid" }), h("div", { class: "DrawMultipler" }, h("label", { class: "Label" }, translate('winUpTo', this.language), " ", item.multiplier)))))))))
169
179
  :
170
180
  h("div", { class: "DrawResultsArea" }, this.drawData &&
171
- h("div", null, h("div", { class: "DrawResultsHeader" }, h("span", null, translate('drawId', this.language), ": ", this.drawData.id), h("span", null, translate('drawDate', this.language), ": ", this.drawData.date.slice(0, 10))), h("div", { class: "DrawResultsBody" }, h("div", { class: "DrawNumbersGrid" }, h("p", null, translate('drawNumbersGridDraw', this.language), ":"), h("div", { class: "BulletContainer" }, 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 })), h("div", { class: "DrawMultipler" }, h("label", { class: "Label" }, "Multiplier: ", this.multiplier))))))));
181
+ h("div", null, h("div", { class: "DrawResultsHeader" }, h("span", null, translate('drawId', this.language), ": ", this.drawData.id), h("span", null, translate('drawDate', this.language), ": ", this.drawData.date.slice(0, 10))), h("div", { class: "DrawResultsBody" }, h("div", { class: "DrawNumbersGrid" }, h("p", null, translate('drawNumbersGridDraw', this.language), ":"), h("div", { class: "BulletContainer" }, 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 })), h("div", { class: "DrawMultipler" }, h("label", { class: "Label" }, translate('multiplier', this.language), " ", this.multiplier))))))));
172
182
  }
173
183
  }
174
184
  static get style() { return lotteryDrawResultsCss; }
@@ -180,8 +190,13 @@ const LotteryDrawResults$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
180
190
  "drawMode": [4, "draw-mode"],
181
191
  "drawId": [1, "draw-id"],
182
192
  "gameName": [1, "game-name"],
193
+ "ticketDate": [1, "ticket-date"],
194
+ "ticketStatus": [1, "ticket-status"],
195
+ "ticketId": [1, "ticket-id"],
196
+ "ticketAmount": [1, "ticket-amount"],
197
+ "ticketMultiplier": [4, "ticket-multiplier"],
198
+ "ticketDrawCount": [2, "ticket-draw-count"],
183
199
  "multiplier": [32],
184
- "ticketData": [32],
185
200
  "isLoading": [32],
186
201
  "drawResults": [32],
187
202
  "rules": [32],
@@ -193,13 +208,23 @@ function defineCustomElement$1() {
193
208
  if (typeof customElements === "undefined") {
194
209
  return;
195
210
  }
196
- const components = ["lottery-draw-results"];
211
+ const components = ["lottery-draw-results", "lottery-bullet", "lottery-grid"];
197
212
  components.forEach(tagName => { switch (tagName) {
198
213
  case "lottery-draw-results":
199
214
  if (!customElements.get(tagName)) {
200
215
  customElements.define(tagName, LotteryDrawResults$1);
201
216
  }
202
217
  break;
218
+ case "lottery-bullet":
219
+ if (!customElements.get(tagName)) {
220
+ defineCustomElement$3();
221
+ }
222
+ break;
223
+ case "lottery-grid":
224
+ if (!customElements.get(tagName)) {
225
+ defineCustomElement$2();
226
+ }
227
+ break;
203
228
  } });
204
229
  }
205
230
 
@@ -0,0 +1,6 @@
1
+ import { L as LotteryGrid$1, d as defineCustomElement$1 } from './lottery-grid2.js';
2
+
3
+ const LotteryGrid = LotteryGrid$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { LotteryGrid, defineCustomElement };
@@ -0,0 +1,196 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { d as defineCustomElement$1 } from './lottery-bullet2.js';
3
+
4
+ const lotteryGridCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GridContainer{display:flex;flex-direction:column;max-width:1200px}.Grid{margin-top:10px 0 10px 0;display:flex;flex-direction:row;flex-wrap:wrap;gap:25px}";
5
+
6
+ const LotteryGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.gridFilledEvent = createEvent(this, "gridFilled", 7);
12
+ this.gridDirtyEvent = createEvent(this, "gridDirty", 7);
13
+ /**
14
+ * Number of bullets of grid
15
+ */
16
+ this.totalNumbers = 0;
17
+ /**
18
+ * Number of maximum bullets that can be selected
19
+ */
20
+ this.maximumAllowed = 0;
21
+ /**
22
+ * Minimum allowed of bullets
23
+ */
24
+ this.minimumAllowed = 1;
25
+ /**
26
+ * Allows the user to select numbers on the grid
27
+ */
28
+ this.selectable = true;
29
+ /**
30
+ * Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
31
+ */
32
+ this.selectedNumbers = '';
33
+ /**
34
+ * Show only selected numbers
35
+ */
36
+ this.displaySelected = false;
37
+ /**
38
+ * Language
39
+ */
40
+ this.language = 'en';
41
+ this.numbers = [];
42
+ this.selectedCounter = 0;
43
+ }
44
+ connectedCallback() {
45
+ let selected = [];
46
+ if (this.selectedNumbers.length > 0) {
47
+ selected = this.selectedNumbers.split(',');
48
+ this.selectedCounter = selected.length;
49
+ }
50
+ if (this.displaySelected) {
51
+ selected.forEach((item) => {
52
+ this.numbers.push({
53
+ number: item,
54
+ selected: true,
55
+ selectable: this.selectable
56
+ });
57
+ });
58
+ }
59
+ else {
60
+ [...Array(this.totalNumbers).keys()]
61
+ .map(number => (number + 1).toString())
62
+ .forEach((number) => {
63
+ this.numbers.push({
64
+ number,
65
+ selected: selected.indexOf(number) >= 0 ? true : false,
66
+ selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
67
+ });
68
+ });
69
+ }
70
+ }
71
+ lotteryBulletSelectionHandler(event) {
72
+ this.numbers = this.numbers.map((item) => {
73
+ if (item.number == event.detail.value) {
74
+ return {
75
+ number: item.number,
76
+ selected: event.detail.selected,
77
+ selectable: item.selectable
78
+ };
79
+ }
80
+ return {
81
+ number: item.number,
82
+ selected: item.selected,
83
+ selectable: item.selectable
84
+ };
85
+ });
86
+ if (event.detail.selected) {
87
+ this.selectedCounter += 1;
88
+ if (this.selectedCounter == this.maximumAllowed) {
89
+ this.numbers = this.numbers.map((item) => {
90
+ return {
91
+ number: item.number,
92
+ selected: item.selected,
93
+ selectable: item.selected ? true : false
94
+ };
95
+ });
96
+ this.gridFilledEvent.emit({
97
+ id: this.ticketId,
98
+ index: this.gridIndex,
99
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
100
+ });
101
+ }
102
+ }
103
+ else {
104
+ if (this.selectedCounter == this.maximumAllowed) {
105
+ this.numbers = this.numbers.map((item) => {
106
+ return {
107
+ number: item.number,
108
+ selected: item.selected,
109
+ selectable: true
110
+ };
111
+ });
112
+ this.gridDirtyEvent.emit({
113
+ id: this.ticketId,
114
+ index: this.gridIndex,
115
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
116
+ });
117
+ }
118
+ this.selectedCounter -= 1;
119
+ }
120
+ }
121
+ async resetSelectionHandler(event) {
122
+ if (event.detail && event.detail == this.ticketId) {
123
+ this.selectedCounter = 0;
124
+ this.numbers = this.numbers.map((item) => {
125
+ return {
126
+ number: item.number,
127
+ selected: false,
128
+ selectable: this.selectable
129
+ };
130
+ });
131
+ this.gridDirtyEvent.emit({
132
+ id: this.ticketId,
133
+ index: this.gridIndex,
134
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
135
+ });
136
+ }
137
+ }
138
+ async autoSelectionHandler(event) {
139
+ if (event.detail && event.detail == this.ticketId) {
140
+ this.resetSelectionHandler(event);
141
+ let array = [...Array(this.totalNumbers).keys()]
142
+ .map(number => number + 1)
143
+ .sort(() => 0.5 - Math.random());
144
+ array = array.slice(0, this.minimumAllowed);
145
+ this.numbers = this.numbers.map((item) => {
146
+ return {
147
+ number: item.number,
148
+ selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
149
+ selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
150
+ };
151
+ });
152
+ this.gridFilledEvent.emit({
153
+ id: this.ticketId,
154
+ index: this.gridIndex,
155
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
156
+ });
157
+ this.selectedCounter = this.maximumAllowed;
158
+ }
159
+ }
160
+ render() {
161
+ return (h("div", { class: "GridContainer" }, h("div", { class: "Grid" }, this.numbers.map((item) => h("div", null, h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected }))))));
162
+ }
163
+ static get style() { return lotteryGridCss; }
164
+ }, [1, "lottery-grid", {
165
+ "ticketId": [2, "ticket-id"],
166
+ "totalNumbers": [2, "total-numbers"],
167
+ "gameId": [1, "game-id"],
168
+ "maximumAllowed": [2, "maximum-allowed"],
169
+ "minimumAllowed": [2, "minimum-allowed"],
170
+ "selectable": [4],
171
+ "selectedNumbers": [1, "selected-numbers"],
172
+ "displaySelected": [4, "display-selected"],
173
+ "language": [1],
174
+ "gridIndex": [2, "grid-index"],
175
+ "numbers": [32]
176
+ }, [[0, "lotteryBulletSelection", "lotteryBulletSelectionHandler"], [4, "resetSelection", "resetSelectionHandler"], [4, "autoSelection", "autoSelectionHandler"]]]);
177
+ function defineCustomElement() {
178
+ if (typeof customElements === "undefined") {
179
+ return;
180
+ }
181
+ const components = ["lottery-grid", "lottery-bullet"];
182
+ components.forEach(tagName => { switch (tagName) {
183
+ case "lottery-grid":
184
+ if (!customElements.get(tagName)) {
185
+ customElements.define(tagName, LotteryGrid);
186
+ }
187
+ break;
188
+ case "lottery-bullet":
189
+ if (!customElements.get(tagName)) {
190
+ defineCustomElement$1();
191
+ }
192
+ break;
193
+ } });
194
+ }
195
+
196
+ export { LotteryGrid as L, defineCustomElement as d };
@@ -25,6 +25,40 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
25
25
  return false;
26
26
  })()
27
27
  ;
28
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
29
+ if (listeners) {
30
+ listeners.map(([flags, name, method]) => {
31
+ const target = getHostListenerTarget(elm, flags) ;
32
+ const handler = hostListenerProxy(hostRef, method);
33
+ const opts = hostListenerOpts(flags);
34
+ plt.ael(target, name, handler, opts);
35
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
36
+ });
37
+ }
38
+ };
39
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
40
+ try {
41
+ {
42
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
43
+ // instance is ready, let's call it's member method for this event
44
+ hostRef.$lazyInstance$[methodName](ev);
45
+ }
46
+ else {
47
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
48
+ }
49
+ }
50
+ }
51
+ catch (e) {
52
+ consoleError(e);
53
+ }
54
+ };
55
+ const getHostListenerTarget = (elm, flags) => {
56
+ if (flags & 4 /* TargetDocument */)
57
+ return doc;
58
+ return elm;
59
+ };
60
+ // prettier-ignore
61
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
28
62
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
29
63
  const createTime = (fnName, tagName = '') => {
30
64
  {
@@ -54,7 +88,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
54
88
  };
55
89
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
56
90
  let scopeId = getScopeId(cmpMeta);
57
- const style = styles.get(scopeId);
91
+ let style = styles.get(scopeId);
58
92
  // if an element is NOT connected then getRootNode() will return the wrong root node
59
93
  // so the fallback is to always use the document for the root node in those cases
60
94
  styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
@@ -134,7 +168,7 @@ const h = (nodeName, vnodeData, ...children) => {
134
168
  let child = null;
135
169
  let simple = false;
136
170
  let lastSimple = false;
137
- const vNodeChildren = [];
171
+ let vNodeChildren = [];
138
172
  const walk = (c) => {
139
173
  for (let i = 0; i < c.length; i++) {
140
174
  child = c[i];
@@ -257,7 +291,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
257
291
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
258
292
  try {
259
293
  if (!elm.tagName.includes('-')) {
260
- const n = newValue == null ? '' : newValue;
294
+ let n = newValue == null ? '' : newValue;
261
295
  // Workaround for Safari, moving the <input> caret when re-assigning the same valued
262
296
  if (memberName === 'list') {
263
297
  isProp = false;
@@ -314,7 +348,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
314
348
  };
315
349
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
316
350
  // tslint:disable-next-line: prefer-const
317
- const newVNode = newParentVNode.$children$[childIndex];
351
+ let newVNode = newParentVNode.$children$[childIndex];
318
352
  let i = 0;
319
353
  let elm;
320
354
  let childNode;
@@ -501,6 +535,20 @@ const renderVdom = (hostRef, renderFnResults) => {
501
535
  // synchronous patch
502
536
  patch(oldVNode, rootVnode);
503
537
  };
538
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
539
+ const createEvent = (ref, name, flags) => {
540
+ const elm = getElement(ref);
541
+ return {
542
+ emit: (detail) => {
543
+ return emitEvent(elm, name, {
544
+ bubbles: !!(flags & 4 /* Bubbles */),
545
+ composed: !!(flags & 2 /* Composed */),
546
+ cancelable: !!(flags & 1 /* Cancellable */),
547
+ detail,
548
+ });
549
+ },
550
+ };
551
+ };
504
552
  /**
505
553
  * Helper function to create & dispatch a custom Event on a provided target
506
554
  * @param elm the target of the Event
@@ -537,6 +585,15 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
537
585
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
538
586
  const instance = hostRef.$lazyInstance$ ;
539
587
  let promise;
588
+ if (isInitialLoad) {
589
+ {
590
+ hostRef.$flags$ |= 256 /* isListenReady */;
591
+ if (hostRef.$queuedListeners$) {
592
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
593
+ hostRef.$queuedListeners$ = null;
594
+ }
595
+ }
596
+ }
540
597
  endSchedule();
541
598
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
542
599
  };
@@ -693,6 +750,10 @@ const parsePropertyValue = (propValue, propType) => {
693
750
  // but we'll cheat here and say that the string "false" is the boolean false
694
751
  return propValue === 'false' ? false : propValue === '' || !!propValue;
695
752
  }
753
+ if (propType & 2 /* Number */) {
754
+ // force it to be a number
755
+ return parseFloat(propValue);
756
+ }
696
757
  if (propType & 1 /* String */) {
697
758
  // could have been passed as a number or boolean
698
759
  // but we still want it as a string
@@ -934,6 +995,10 @@ const connectedCallback = (elm) => {
934
995
  }
935
996
  }
936
997
  else {
998
+ // not the first time this has connected
999
+ // reattach any event listeners to the host
1000
+ // since they would have been removed when disconnected
1001
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
937
1002
  // fire off connectedCallback() on component instance
938
1003
  fireConnectedCallback(hostRef.$lazyInstance$);
939
1004
  }
@@ -942,7 +1007,13 @@ const connectedCallback = (elm) => {
942
1007
  };
943
1008
  const disconnectedCallback = (elm) => {
944
1009
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
945
- getHostRef(elm);
1010
+ const hostRef = getHostRef(elm);
1011
+ {
1012
+ if (hostRef.$rmListeners$) {
1013
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1014
+ hostRef.$rmListeners$ = undefined;
1015
+ }
1016
+ }
946
1017
  }
947
1018
  };
948
1019
  const bootstrapLazy = (lazyBundles, options = {}) => {
@@ -969,6 +1040,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
969
1040
  {
970
1041
  cmpMeta.$members$ = compactMeta[2];
971
1042
  }
1043
+ {
1044
+ cmpMeta.$listeners$ = compactMeta[3];
1045
+ }
972
1046
  const tagName = cmpMeta.$tagName$;
973
1047
  const HostElement = class extends HTMLElement {
974
1048
  // StencilLazyHost
@@ -1049,6 +1123,7 @@ const registerHost = (elm, cmpMeta) => {
1049
1123
  elm['s-p'] = [];
1050
1124
  elm['s-rc'] = [];
1051
1125
  }
1126
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1052
1127
  return hostRefs.set(elm, hostRef);
1053
1128
  };
1054
1129
  const isMemberInElement = (elm, memberName) => memberName in elm;
@@ -1062,9 +1137,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1062
1137
  if (module) {
1063
1138
  return module[exportName];
1064
1139
  }
1065
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1066
1140
  return import(
1067
- /* @vite-ignore */
1068
1141
  /* webpackInclude: /\.entry\.js$/ */
1069
1142
  /* webpackExclude: /\.system\.entry\.js$/ */
1070
1143
  /* webpackMode: "lazy" */
@@ -1119,4 +1192,4 @@ const flush = () => {
1119
1192
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1120
1193
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1121
1194
 
1122
- export { bootstrapLazy as b, h, promiseResolve as p, registerInstance as r };
1195
+ export { bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };
@@ -1,7 +1,7 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-17920f23.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-98326ddd.js';
2
2
 
3
3
  /*
4
- Stencil Client Patch Esm v2.17.0 | MIT Licensed | https://stenciljs.com
4
+ Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
5
5
  */
6
6
  const patchEsm = () => {
7
7
  return promiseResolve();
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["lottery-draw-results",[[1,"lottery-draw-results",{"endpoint":[1],"gameId":[1,"game-id"],"language":[1],"playerId":[1,"player-id"],"drawMode":[4,"draw-mode"],"drawId":[1,"draw-id"],"gameName":[1,"game-name"],"multiplier":[32],"ticketData":[32],"isLoading":[32],"drawResults":[32],"rules":[32],"toggleDrawer":[32],"hasErrors":[32],"errorText":[32]}]]]], options);
13
+ return bootstrapLazy([["lottery-bullet_3",[[1,"lottery-draw-results",{"endpoint":[1],"gameId":[1,"game-id"],"language":[1],"playerId":[1,"player-id"],"drawMode":[4,"draw-mode"],"drawId":[1,"draw-id"],"gameName":[1,"game-name"],"ticketDate":[1,"ticket-date"],"ticketStatus":[1,"ticket-status"],"ticketId":[1,"ticket-id"],"ticketAmount":[1,"ticket-amount"],"ticketMultiplier":[4,"ticket-multiplier"],"ticketDrawCount":[2,"ticket-draw-count"],"multiplier":[32],"isLoading":[32],"drawResults":[32],"rules":[32],"toggleDrawer":[32],"hasErrors":[32],"errorText":[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);
14
14
  });
15
15
  };
16
16