@everymatrix/lottery-game-page 0.1.5 → 0.1.9

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 (73) hide show
  1. package/dist/cjs/helper-accordion.cjs.entry.js +92 -0
  2. package/dist/cjs/{lottery-draw-results.cjs.entry.js → helper-filters_2.cjs.entry.js} +131 -2
  3. package/dist/cjs/helper-modal.cjs.entry.js +1 -1
  4. package/dist/cjs/helper-pagination.cjs.entry.js +188 -0
  5. package/dist/cjs/helper-tab.cjs.entry.js +36 -0
  6. package/dist/cjs/helper-tabs.cjs.entry.js +38 -0
  7. package/dist/cjs/{index-614098f4.js → index-5701a895.js} +47 -1
  8. package/dist/cjs/loader.cjs.js +2 -2
  9. package/dist/cjs/lottery-bullet_2.cjs.entry.js +202 -0
  10. package/dist/cjs/lottery-draw-results-history.cjs.entry.js +161 -0
  11. package/dist/cjs/lottery-game-details.cjs.entry.js +19 -0
  12. package/dist/cjs/lottery-game-page.cjs.entry.js +1 -4
  13. package/dist/cjs/lottery-game-page.cjs.js +2 -2
  14. package/dist/cjs/lottery-ticket-controller.cjs.entry.js +69 -0
  15. package/dist/cjs/lottery-ticket.cjs.entry.js +169 -0
  16. package/dist/collection/collection-manifest.json +61 -0
  17. package/dist/components/helper-accordion.js +6 -0
  18. package/dist/components/helper-accordion2.js +116 -0
  19. package/dist/components/helper-filters.js +6 -0
  20. package/dist/components/helper-filters2.js +166 -0
  21. package/dist/components/helper-pagination.js +216 -0
  22. package/dist/components/helper-tab.js +6 -0
  23. package/dist/components/helper-tab2.js +52 -0
  24. package/dist/components/helper-tabs.js +6 -0
  25. package/dist/components/helper-tabs2.js +63 -0
  26. package/dist/components/lottery-bullet.js +6 -0
  27. package/dist/components/lottery-bullet2.js +57 -0
  28. package/dist/components/lottery-draw-results-history.js +6 -0
  29. package/dist/components/lottery-draw-results-history2.js +216 -0
  30. package/dist/components/lottery-draw-results2.js +13 -2
  31. package/dist/components/lottery-game-details.js +6 -0
  32. package/dist/components/lottery-game-details2.js +49 -0
  33. package/dist/components/lottery-game-page.js +64 -7
  34. package/dist/components/lottery-grid.js +6 -0
  35. package/dist/components/lottery-grid2.js +197 -0
  36. package/dist/components/lottery-ticket-controller.js +6 -0
  37. package/dist/components/lottery-ticket-controller2.js +118 -0
  38. package/dist/components/lottery-ticket.js +6 -0
  39. package/dist/components/lottery-ticket2.js +209 -0
  40. package/dist/esm/helper-accordion.entry.js +88 -0
  41. package/dist/esm/{lottery-draw-results.entry.js → helper-filters_2.entry.js} +131 -3
  42. package/dist/esm/helper-modal.entry.js +1 -1
  43. package/dist/esm/helper-pagination.entry.js +184 -0
  44. package/dist/esm/helper-tab.entry.js +32 -0
  45. package/dist/esm/helper-tabs.entry.js +34 -0
  46. package/dist/esm/{index-0fa076cd.js → index-ade3d0ab.js} +47 -1
  47. package/dist/esm/loader.js +2 -2
  48. package/dist/esm/lottery-bullet_2.entry.js +197 -0
  49. package/dist/esm/lottery-draw-results-history.entry.js +157 -0
  50. package/dist/esm/lottery-game-details.entry.js +15 -0
  51. package/dist/esm/lottery-game-page.entry.js +1 -4
  52. package/dist/esm/lottery-game-page.js +2 -2
  53. package/dist/esm/lottery-ticket-controller.entry.js +65 -0
  54. package/dist/esm/lottery-ticket.entry.js +165 -0
  55. package/dist/lottery-game-page/lottery-game-page.esm.js +1 -1
  56. package/dist/lottery-game-page/p-07cca45e.entry.js +1 -0
  57. package/dist/lottery-game-page/p-1196396b.entry.js +1 -0
  58. package/dist/lottery-game-page/p-2197c8ae.entry.js +1 -0
  59. package/dist/lottery-game-page/p-2a4e9984.entry.js +1 -0
  60. package/dist/lottery-game-page/p-4b390390.entry.js +1 -0
  61. package/dist/lottery-game-page/p-4bfd0112.entry.js +1 -0
  62. package/dist/lottery-game-page/p-5e12dbf9.entry.js +1 -0
  63. package/dist/lottery-game-page/p-a10368b2.entry.js +1 -0
  64. package/dist/lottery-game-page/p-a26ebf45.entry.js +1 -0
  65. package/dist/lottery-game-page/p-b301a9d4.js +1 -0
  66. package/dist/lottery-game-page/{p-6183a920.entry.js → p-d4b6a11a.entry.js} +1 -1
  67. package/dist/lottery-game-page/p-dd63fcc6.entry.js +1 -0
  68. package/dist/lottery-game-page/p-f59dc9e1.entry.js +1 -0
  69. package/dist/stencil.config.js +0 -1
  70. package/package.json +2 -2
  71. package/dist/lottery-game-page/p-2d7ccc96.js +0 -1
  72. package/dist/lottery-game-page/p-9ca649d9.entry.js +0 -1
  73. package/dist/lottery-game-page/p-e98ee83a.entry.js +0 -1
@@ -0,0 +1,209 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { d as defineCustomElement$2 } from './lottery-bullet2.js';
3
+ import { d as defineCustomElement$1 } from './lottery-grid2.js';
4
+
5
+ const DEFAULT_LANGUAGE = 'en';
6
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
7
+ const TRANSLATIONS = {
8
+ en: {
9
+ loading: 'Loading, please wait ...',
10
+ error: 'It was an error while trying to fetch the data',
11
+ grid: 'Grid',
12
+ multiplier: 'Multiplier',
13
+ numberOfDraws: 'Number of draws',
14
+ wagerPerDraw: 'Wager per draw',
15
+ resetButton: 'Reset',
16
+ autoButton: 'I feel lucky'
17
+ },
18
+ ro: {
19
+ loading: 'Se incarca, va rugam asteptati ...',
20
+ error: 'A fost o eroare in timp ce asteptam datele',
21
+ grid: 'Grid',
22
+ multiplier: 'Multiplicator',
23
+ numberOfDraws: 'Numarul de extrageri',
24
+ wagerPerDraw: 'Pariul per extragere',
25
+ resetButton: 'Reseteaza',
26
+ autoButton: 'Ma simt norocos'
27
+ },
28
+ };
29
+ const translate = (key, customLang) => {
30
+ const lang = customLang;
31
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
32
+ };
33
+
34
+ const lotteryTicketCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.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}";
35
+
36
+ const LotteryTicket = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
37
+ constructor() {
38
+ super();
39
+ this.__registerHost();
40
+ this.__attachShadow();
41
+ this.ticketCompleted = createEvent(this, "ticketCompleted", 7);
42
+ this.autoSelection = createEvent(this, "autoSelection", 7);
43
+ this.resetSelection = createEvent(this, "resetSelection", 7);
44
+ this.stakeChange = createEvent(this, "stakeChange", 7);
45
+ this.multiplierChange = createEvent(this, "multiplierChange", 7);
46
+ /**
47
+ * Number of grids of a ticket
48
+ */
49
+ this.numberOfGrids = 1;
50
+ /**
51
+ * Option to have the ticket registered for multiple draws
52
+ */
53
+ this.multipleDraws = true;
54
+ /**
55
+ * Shows the reset button
56
+ */
57
+ this.resetButton = false;
58
+ /**
59
+ * Shows the auto-pick button
60
+ */
61
+ this.autoPick = false;
62
+ /**
63
+ * Language
64
+ */
65
+ this.language = 'en';
66
+ this.multiplier = false;
67
+ this.numberOfDraws = 1;
68
+ this.isLoading = true;
69
+ this.hasErrors = false;
70
+ this.ticketDone = false;
71
+ this.isCustomSelect = false;
72
+ this.amountInfo = {};
73
+ }
74
+ /**
75
+ * @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
76
+ */
77
+ checkForClickOutside(ev) {
78
+ if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
79
+ this.isCustomSelect = false;
80
+ }
81
+ }
82
+ connectedCallback() {
83
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
84
+ fetch(url.href)
85
+ .then((response) => {
86
+ if (response.ok) {
87
+ return response.json();
88
+ }
89
+ else {
90
+ // Throw error
91
+ this.hasErrors = true;
92
+ }
93
+ })
94
+ .then((data) => {
95
+ this.isLoading = false;
96
+ this.gameData = data;
97
+ this.grids = [...Array(data.rules.boards.length).keys()];
98
+ this.amountInfo = this.gameData.rules.stakes[0]; // initial value for select
99
+ })
100
+ .catch((err) => {
101
+ this.isLoading = false;
102
+ this.hasErrors = true;
103
+ console.error('Error!', err);
104
+ });
105
+ }
106
+ multiplierChangeHandler(e) {
107
+ this.multiplier = e.target ? e.target.checked : false;
108
+ this.multiplierChange.emit(this.multiplier);
109
+ }
110
+ drawsChangeHandler(event) {
111
+ this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
112
+ this.ticketCompleted.emit(this.ticket);
113
+ }
114
+ gridFilledHandler(event) {
115
+ this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
116
+ this.ticketDone = true;
117
+ this.ticketCompleted.emit(this.ticket);
118
+ }
119
+ toggleAutoSelection() {
120
+ this.ticketDone = true;
121
+ this.autoSelection.emit(this.ticketId);
122
+ }
123
+ toggleResetSelection() {
124
+ this.ticketDone = false;
125
+ this.resetSelection.emit(this.ticketId);
126
+ }
127
+ changeStake(ticketid, amount) {
128
+ this.stakeChange.emit({
129
+ ticketId: ticketid,
130
+ stake: amount
131
+ });
132
+ }
133
+ toggleClass() {
134
+ this.isCustomSelect = !this.isCustomSelect;
135
+ }
136
+ setDropdownItem(item) {
137
+ this.amountInfo = {
138
+ amount: item.amount,
139
+ currency: item.currency
140
+ };
141
+ this.isCustomSelect = false;
142
+ this.changeStake(this.ticketId, item.amount);
143
+ }
144
+ render() {
145
+ if (this.isLoading) {
146
+ return (h("div", null, h("p", null, translate('loading', this.language))));
147
+ }
148
+ else {
149
+ if (this.hasErrors) {
150
+ return (h("div", null, h("p", null, translate('error', this.language))));
151
+ }
152
+ else {
153
+ const { rules } = this.gameData;
154
+ return (h("div", { class: "TicketContainer" }, h("p", { class: "TicketTitle" }, this.gameData.name), this.resetButton && this.ticketDone &&
155
+ h("div", { class: "ButtonContainer" }, h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language))), this.autoPick && !this.ticketDone &&
156
+ h("div", { class: "ButtonContainer" }, h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language))), this.grids.map((item, index) => h("div", { class: "TicketGridBullets" }, h("p", { class: "TicketGridTitle" }, translate('grid', this.language), " ", item), h("lottery-grid", { "grid-index": index, "maximum-allowed": rules.boards[index].maximumAllowed, "minimum-allowed": rules.boards[index].minimumAllowed, "total-numbers": rules.boards[index].totalNumbers, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language }))), rules.multiplier &&
157
+ h("div", null, h("label", { class: "Toggle" }, h("label", { class: "Label" }, translate('multiplier', this.language), ": "), h("input", { class: "ToggleCheckbox", type: "checkbox", onInput: (e) => this.multiplierChangeHandler(e) }), h("div", { class: "ToggleSwitch" }))), this.multipleDraws &&
158
+ h("div", { class: "TicketDraws" }, h("label", { class: "Label" }, translate('numberOfDraws', this.language), ": "), h("div", { class: "NumberInput" }, h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), h("div", null, h("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), h("div", { class: "WagerInput" }, rules.stakes.length > 1 ?
159
+ (h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" }, h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() }, h("span", { "data-cluster": "SelectComponent" }, this.amountInfo.amount, " ", this.amountInfo.currency), h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")), h("div", { "data-cluster": "SelectComponent", class: "SelectContent" }, h("ul", { "data-cluster": "SelectComponent", class: "SelectOptions" }, rules.stakes.map((item) => h("li", { "data-cluster": "SelectComponent", class: this.amountInfo.amount == item.amount ? 'SelectedValue' : '', value: item.amount, onClick: () => this.setDropdownItem(item) }, item.amount, " ", item.currency)))))) : (h("div", null, h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }), h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))))));
160
+ }
161
+ }
162
+ }
163
+ static get watchers() { return {
164
+ "numberOfDraws": ["drawsChangeHandler"]
165
+ }; }
166
+ static get style() { return lotteryTicketCss; }
167
+ }, [1, "lottery-ticket", {
168
+ "endpoint": [1],
169
+ "gameId": [1, "game-id"],
170
+ "numberOfGrids": [2, "number-of-grids"],
171
+ "multipleDraws": [4, "multiple-draws"],
172
+ "ticketId": [2, "ticket-id"],
173
+ "resetButton": [4, "reset-button"],
174
+ "autoPick": [4, "auto-pick"],
175
+ "language": [1],
176
+ "multiplier": [32],
177
+ "numberOfDraws": [32],
178
+ "isLoading": [32],
179
+ "hasErrors": [32],
180
+ "ticketDone": [32],
181
+ "isCustomSelect": [32],
182
+ "amountInfo": [32]
183
+ }, [[8, "click", "checkForClickOutside"], [0, "gridFilled", "gridFilledHandler"]]]);
184
+ function defineCustomElement() {
185
+ if (typeof customElements === "undefined") {
186
+ return;
187
+ }
188
+ const components = ["lottery-ticket", "lottery-bullet", "lottery-grid"];
189
+ components.forEach(tagName => { switch (tagName) {
190
+ case "lottery-ticket":
191
+ if (!customElements.get(tagName)) {
192
+ customElements.define(tagName, LotteryTicket);
193
+ }
194
+ break;
195
+ case "lottery-bullet":
196
+ if (!customElements.get(tagName)) {
197
+ defineCustomElement$2();
198
+ }
199
+ break;
200
+ case "lottery-grid":
201
+ if (!customElements.get(tagName)) {
202
+ defineCustomElement$1();
203
+ }
204
+ break;
205
+ } });
206
+ }
207
+ defineCustomElement();
208
+
209
+ export { LotteryTicket as L, defineCustomElement as d };
@@ -0,0 +1,88 @@
1
+ import { r as registerInstance, c as createEvent, h } from './index-ade3d0ab.js';
2
+
3
+ const DEFAULT_LANGUAGE = 'en';
4
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
5
+ const TRANSLATIONS = {
6
+ en: {
7
+ deleteTicket: 'Delete ticket'
8
+ },
9
+ ro: {
10
+ deleteTicket: 'Sterge biletul'
11
+ },
12
+ };
13
+ const translate = (key, customLang) => {
14
+ const lang = customLang;
15
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
16
+ };
17
+
18
+ const helperAccordionCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Header{border-radius:4px 4px 0 0;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}.HeaderTicketHistory{border-radius:4px;background:#F1F1F1;display:flex;gap:30px;border:1px solid #009993;padding:8px 10px;user-select:none;margin-bottom:5px}.HeaderTicketHistory:hover{background:#00ABA4}.HeaderTicketHistory .Title,.HeaderTicketHistory .Subtitle,.HeaderTicketHistory .Description{margin:0;font-size:14px;color:#000}.HeaderTicketHistory .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:0 0 4px 4px;background:#fff;border:1px solid #009993;padding:10px 15px;user-select:none;color:#000;margin-bottom:10px}.ActionButton{cursor:pointer;display:inline-block;border-radius:4px;margin:20px 0 10px;text-transform:uppercase;font-size:12px;text-align:center;padding:8px 20px;min-width:80px;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ActionButton:hover{background:#FF6536;border:1px solid #FF3D00}";
19
+
20
+ const Accordion = class {
21
+ constructor(hostRef) {
22
+ registerInstance(this, hostRef);
23
+ this.accordionEvent = createEvent(this, "helperAccordionAction", 7);
24
+ /**
25
+ * Flag for ticket history
26
+ */
27
+ this.ticketHistoryFlag = false;
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 (h("div", { class: "Wrapper" }, h("div", { class: this.ticketHistoryFlag === true ? 'HeaderTicketHistory' : 'Header' }, h("p", { class: "Title" }, this.headerTitle), h("p", { class: "Subtitle" }, this.headerSubtitle), h("p", { class: "Subtitle" }, this.description), h("span", { class: "Expand", onClick: () => this.toggleContent() }, this.showContent ? '<' : '>')), this.showContent &&
81
+ h("div", null, h("div", { class: "Content" }, h("slot", { name: 'accordionContent' }), this.footer && this.showContent &&
82
+ h("div", null, this.deleteTab &&
83
+ h("span", { class: "ActionButton", onClick: () => this.deleteAction() }, translate('deleteTicket', this.language)))))));
84
+ }
85
+ };
86
+ Accordion.style = helperAccordionCss;
87
+
88
+ export { Accordion as helper_accordion };
@@ -1,5 +1,133 @@
1
- import { r as registerInstance, h } from './index-0fa076cd.js';
2
- import '@everymatrix/lottery-grid';
1
+ import { r as registerInstance, c as createEvent, h } from './index-ade3d0ab.js';
2
+
3
+ const DEFAULT_LANGUAGE$1 = 'en';
4
+ const SUPPORTED_LANGUAGES$1 = ['ro', 'en'];
5
+ const TRANSLATIONS$1 = {
6
+ en: {
7
+ filterOpen: 'Filter',
8
+ filterClear: 'Clear',
9
+ filterModalTicketTitle: 'Ticket Results',
10
+ filterModalDrawTitle: 'Draws Results History',
11
+ filterTicketPlaceholder: 'Search for a ticket ID',
12
+ filterDrawPlaceholder: 'Search for a draw ID',
13
+ filterDateRangePlaceholder: 'Date Range',
14
+ filterModalButton: 'Search',
15
+ filterFromCalendar: 'From',
16
+ filterToCalendar: 'To',
17
+ filterOrDate: 'or search by date'
18
+ },
19
+ ro: {
20
+ filterOpen: 'Filtrare',
21
+ filterClear: 'Stergere',
22
+ filterModalTicketTitle: 'Rezultatele biletelor',
23
+ filterModalDrawTitle: 'Rezultatele draw-urilor',
24
+ filterTicketPlaceholder: 'Cauta ID bilet',
25
+ filterDrawPlaceholder: 'Cauta ID draw',
26
+ filterDateRangePlaceholder: 'Perioada',
27
+ filterModalButton: 'Cauta',
28
+ filterOrDate: 'sau cauta dupa data'
29
+ },
30
+ };
31
+ const translate$1 = (key, customLang) => {
32
+ const lang = customLang;
33
+ return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
34
+ };
35
+
36
+ const helperFiltersCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.FilterButtonsWrapper{display:flex;justify-content:flex-end;gap:5px}.FilterButtonsWrapper .FilterOpen{cursor:pointer;border-radius:4px;padding:8px 15px;width:max-content;border:1px solid #00958f;background:#00958f;color:#FFF;font-size:12px;transition:all 0.2s linear;text-align:center;letter-spacing:0}.FilterButtonsWrapper .FilterOpen:hover{background:#00958f;color:#FFF}.FilterButtonsWrapper .FilterClear{cursor:pointer;border-radius:4px;padding:8px 15px;width:max-content;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-align:center;letter-spacing:0}.FilterButtonsWrapper .FilterClear:hover{background:#00958f;color:#FFF}.FilterModalHeader,.FilterModalBody,.FilterModalFooter{display:flex;flex-direction:column;gap:5px;align-items:center;margin:20px 0}.FilterModalHeader .FilterModalTitle,.FilterModalBody .FilterModalTitle,.FilterModalFooter .FilterModalTitle{margin:0;padding:0;font-weight:700;font-size:16px;color:#009993;text-transform:uppercase}.FilterModalHeader .FilterModalSearch,.FilterModalBody .FilterModalSearch,.FilterModalFooter .FilterModalSearch{border-radius:4px;background:#e8ebef;color:#263445;width:100%;height:26px;max-width:280px;padding:5px;font-size:15px;border:none;outline:#009993}.FilterModalHeader .FilterCalendarWrapper,.FilterModalBody .FilterCalendarWrapper,.FilterModalFooter .FilterCalendarWrapper{display:flex;gap:5px}.FilterModalHeader .FilterCalendarWrapper .VaadinDatePicker,.FilterModalBody .FilterCalendarWrapper .VaadinDatePicker,.FilterModalFooter .FilterCalendarWrapper .VaadinDatePicker{width:50%;max-width:143px}.FilterModalHeader .FilterModalButton,.FilterModalBody .FilterModalButton,.FilterModalFooter .FilterModalButton{cursor:pointer;border-radius:4px;padding:8px 60px;width:max-content;margin:5px;border:1px solid #00958f;background:#00958f;color:#FFF;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.FilterModalHeader .FilterModalButton:hover,.FilterModalBody .FilterModalButton:hover,.FilterModalFooter .FilterModalButton:hover{background:#00958f;color:#FFF}.FilterModalHeader p,.FilterModalBody p,.FilterModalFooter p{margin:5px 0}";
37
+
38
+ const HelperFilters = class {
39
+ constructor(hostRef) {
40
+ registerInstance(this, hostRef);
41
+ this.filterDraw = createEvent(this, "filterDraw", 7);
42
+ this.filterSelection = createEvent(this, "filterSelection", 7);
43
+ this.filterSelectionReset = createEvent(this, "filterSelectionReset", 7);
44
+ /**
45
+ * Check if show the filter option by id
46
+ */
47
+ this.showFilterId = true;
48
+ /**
49
+ * Choose if filter by draw ID or ticket ID. By default is draw ID.
50
+ */
51
+ this.activateTicketSearch = false;
52
+ /**
53
+ * Game ID
54
+ */
55
+ this.gameId = '';
56
+ /**
57
+ * Player ID
58
+ */
59
+ this.playerId = '';
60
+ /**
61
+ * Session ID
62
+ */
63
+ this.session = '';
64
+ /**
65
+ * Instead of customEvents the widget triggers postMessages
66
+ */
67
+ this.postMessage = false;
68
+ /**
69
+ * Language
70
+ */
71
+ this.language = 'en';
72
+ this.showFilterModal = false;
73
+ this.showClearButton = false;
74
+ this.filterData = {};
75
+ this.filterDataReset = { ticketDrawId: '', filterFromCalendar: '', filterToCalendar: '' };
76
+ }
77
+ // reset field values each time the filter modal opens
78
+ componentDidRender() {
79
+ this.filterData.ticketDrawId = null;
80
+ this.filterData.filterFromCalendar = null;
81
+ this.filterData.filterToCalendar = null;
82
+ // @TODO: to way binding?
83
+ if (document.getElementById('#FilterById'))
84
+ document.getElementById('#FilterById').value = '';
85
+ }
86
+ filterSelectionHandler(event) {
87
+ if (this.postMessage)
88
+ window.postMessage({ type: 'filterSelection', event }, window.location.href);
89
+ if (this.filterData.ticketDrawId)
90
+ this.filterDraw.emit(event);
91
+ if (this.filterData.filterFromCalendar || this.filterData.filterToCalendar)
92
+ this.filterSelection.emit(event);
93
+ }
94
+ filterSelectionResetHandler(event) {
95
+ if (this.postMessage)
96
+ window.postMessage({ type: 'filterSelectionReset', event }, window.location.href);
97
+ this.filterSelectionReset.emit(event);
98
+ }
99
+ modalCloseEvent() {
100
+ this.showFilterModal = false;
101
+ }
102
+ // Toggle filter modal
103
+ toggleFilterModal() {
104
+ this.showFilterModal = true;
105
+ }
106
+ // Filter search
107
+ filterSearch() {
108
+ this.modalCloseEvent();
109
+ this.showClearButton = true;
110
+ this.filterSelectionHandler(this.filterData);
111
+ }
112
+ resetSearch() {
113
+ this.showClearButton = false;
114
+ this.filterSelectionResetHandler(this.filterDataReset);
115
+ this.filterData = {};
116
+ }
117
+ handleTicketDrawId(event) {
118
+ this.filterData.ticketDrawId = event.target.value;
119
+ }
120
+ handleFilterFrom(event) {
121
+ this.filterData.filterFromCalendar = new Date(event.target.value).toISOString();
122
+ }
123
+ handleFilterTo(event) {
124
+ this.filterData.filterToCalendar = new Date(event.target.value).toISOString();
125
+ }
126
+ render() {
127
+ return (h("div", { class: "HelperFilters" }, h("div", { class: "FilterButtonsWrapper" }, h("button", { class: "FilterOpen", onClick: () => this.toggleFilterModal() }, translate$1('filterOpen', this.language)), this.showClearButton ? h("button", { class: "FilterClear", onClick: () => this.resetSearch() }, translate$1('filterClear', this.language)) : null), h("helper-modal", { "title-modal": "Filter Modal", visible: this.showFilterModal }, h("div", { class: "FilterModalHeader" }, h("h3", { class: "FilterModalTitle" }, this.activateTicketSearch ? translate$1('filterModalTicketTitle', this.language) : translate$1('filterModalDrawTitle', this.language))), h("div", { class: "FilterModalBody" }, h("input", { id: "FilterById", type: "text", value: this.filterData.ticketDrawId, onInput: (event) => this.handleTicketDrawId(event), class: "FilterModalSearch", placeholder: this.activateTicketSearch ? translate$1('filterTicketPlaceholder', this.language) : translate$1('filterDrawPlaceholder', this.language) }), h("p", null, translate$1('filterOrDate', this.language)), h("div", { class: "FilterCalendarWrapper" })), h("div", { class: "FilterModalFooter" }, h("button", { class: "FilterModalButton", onClick: () => this.filterSearch() }, translate$1('filterModalButton', this.language))))));
128
+ }
129
+ };
130
+ HelperFilters.style = helperFiltersCss;
3
131
 
4
132
  const DEFAULT_LANGUAGE = 'en';
5
133
  const SUPPORTED_LANGUAGES = ['ro', 'en'];
@@ -181,4 +309,4 @@ const LotteryDrawResults = class {
181
309
  };
182
310
  LotteryDrawResults.style = lotteryDrawResultsCss;
183
311
 
184
- export { LotteryDrawResults as lottery_draw_results };
312
+ export { HelperFilters as helper_filters, LotteryDrawResults as lottery_draw_results };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-0fa076cd.js';
1
+ import { r as registerInstance, c as createEvent, h } from './index-ade3d0ab.js';
2
2
 
3
3
  /**
4
4
  * @name isMobile
@@ -0,0 +1,184 @@
1
+ import { r as registerInstance, c as createEvent, h } from './index-ade3d0ab.js';
2
+
3
+ /**
4
+ * @name isMobile
5
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
6
+ * @param {String} userAgent window.navigator.userAgent
7
+ * @returns {Boolean} true or false
8
+ */
9
+ const isMobile = (userAgent) => {
10
+ return !!(userAgent.toLowerCase().match(/android/i) ||
11
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
12
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
13
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
14
+ };
15
+
16
+ const DEFAULT_LANGUAGE = 'en';
17
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
18
+ const TRANSLATIONS = {
19
+ en: {
20
+ firstPage: 'First',
21
+ previousPage: 'Previous',
22
+ nextPage: 'Next',
23
+ lastPage: 'Last'
24
+ },
25
+ ro: {
26
+ firstPage: 'Prima',
27
+ previousPage: 'Anterior',
28
+ nextPage: 'Urmatoarea',
29
+ lastPage: 'Ultima'
30
+ },
31
+ };
32
+ const translate = (key, customLang) => {
33
+ const lang = customLang;
34
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
35
+ };
36
+
37
+ const helperPaginationCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}#PaginationContainer{width:100%;margin-top:20px;display:inline-flex;justify-content:space-between;align-items:center}.LeftItems button:not(:first-child),.RightItems button:not(:last-child){margin:0 10px}.LeftItems button,.RightItems button{padding:0;background-color:#009993;border-color:#009993}.PaginationArea{display:inline-flex;gap:10px;list-style:none}.PaginationArea li{margin:0;padding:0}.PaginationArea li button{width:24px;height:24px;display:flex;border:0;padding:0;justify-content:center;align-items:center;background-color:transparent;color:#000;cursor:pointer;pointer-events:all}.PaginationItem.ActiveItem button{background:#009993;border-color:#009993;color:#fff}.PaginationItem.ActiveItem button:disabled{pointer-events:none;cursor:not-allowed}.PaginationItem button:hover,.PaginationItem button:active{background:#009993;border-color:#009993;color:#fff;opacity:0.8}button{width:100px;height:32px;border:1px solid #524e52;border-radius:5px;background:#524e52;color:#fff;font-size:14px;font:inherit;cursor:pointer;transition:all 0.1s linear;text-transform:uppercase;text-align:center;letter-spacing:0}button:hover,button:active{background:#004D4A;border-color:#004D4A}button:disabled{background-color:#ccc;border-color:#ccc;color:#fff;cursor:not-allowed}@media screen and (max-width: 720px){button{width:90px;font-size:12px}}@media screen and (max-width: 480px){button{width:70px;font-size:10px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:10px}.paginationArea{padding:5px;gap:5px}}@media (hover: none){.paginationItem button:hover{background:inherit;border-color:inherit;color:inherit;opacity:1}.paginationItem.activeItem button:hover{background:#009993;border-color:#009993;color:#fff}}";
38
+
39
+ const HelperPagination = class {
40
+ constructor(hostRef) {
41
+ registerInstance(this, hostRef);
42
+ this.hpPageChange = createEvent(this, "hpPageChange", 7);
43
+ /**
44
+ * First page boolean value - determines if the page is disabled or active
45
+ */
46
+ this.firstPage = false;
47
+ /**
48
+ * Previous page boolean value - determines if the page is disabled or active
49
+ */
50
+ this.previousPage = false;
51
+ /**
52
+ * The received offset
53
+ */
54
+ this.offset = 0;
55
+ /**
56
+ * The received limit for the number of pages
57
+ */
58
+ this.limit = 1;
59
+ /**
60
+ * The received total number of pages
61
+ */
62
+ this.total = 1;
63
+ /**
64
+ * Language
65
+ */
66
+ this.language = 'en';
67
+ /**
68
+ * In component working variable for the array of pages
69
+ */
70
+ this.pagesArray = [];
71
+ /**
72
+ * In component working variable for last page
73
+ */
74
+ this.endInt = 0;
75
+ this.userAgent = window.navigator.userAgent;
76
+ this.currentPage = 1;
77
+ /**
78
+ * Navigation logic
79
+ */
80
+ this.navigateTo = (navigationPage) => {
81
+ switch (navigationPage) {
82
+ case 'firstPage':
83
+ this.offsetInt = 0;
84
+ break;
85
+ case 'lastPage':
86
+ this.offsetInt = this.endInt * this.limitInt;
87
+ break;
88
+ case 'previousPage':
89
+ this.offsetInt -= 10;
90
+ break;
91
+ case 'nextPage':
92
+ this.offsetInt += 10;
93
+ break;
94
+ case 'fivePagesBack':
95
+ this.offsetInt -= 30;
96
+ this.offsetInt = this.offsetInt < 0 ? 0 : this.offsetInt;
97
+ break;
98
+ case 'fivePagesForward':
99
+ this.offsetInt += 30;
100
+ this.offsetInt = this.offsetInt / 10 >= this.endInt ? this.endInt * 10 : this.offsetInt;
101
+ break;
102
+ }
103
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
104
+ };
105
+ /**
106
+ * Handle navigation from here
107
+ */
108
+ this.paginationNavigation = (pageNumber, index) => {
109
+ if (!isNaN(pageNumber)) {
110
+ if (pageNumber === 1) {
111
+ this.offsetInt = pageNumber - 1;
112
+ }
113
+ else {
114
+ this.offsetInt = (pageNumber - 1) * 10;
115
+ }
116
+ }
117
+ else {
118
+ if (index === 0 && this.currentPage <= 4) {
119
+ this.navigateTo('firstPage');
120
+ }
121
+ else if (index === 0 && this.currentPage > 4) {
122
+ this.navigateTo('fivePagesBack');
123
+ }
124
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
125
+ this.navigateTo('fivePagesForward');
126
+ }
127
+ }
128
+ this.currentPage = this.offsetInt;
129
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
130
+ };
131
+ }
132
+ componentWillRender() {
133
+ this.offsetInt = this.offset;
134
+ this.currentPage = this.offsetInt / this.limitInt + 1;
135
+ this.limitInt = this.limit;
136
+ this.totalInt = this.total;
137
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
138
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
139
+ /**
140
+ * Construct numbered navigation area based on current page position
141
+ */
142
+ if (this.currentPage === 1 || this.currentPage === 2) {
143
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
144
+ this.pagesArray.push('...');
145
+ }
146
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
147
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
148
+ this.pagesArray.push('...');
149
+ this.pagesArray.unshift('...');
150
+ }
151
+ else if ((this.endInt - this.currentPage) < 3) {
152
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
153
+ this.pagesArray.unshift('...');
154
+ }
155
+ }
156
+ render() {
157
+ /**
158
+ * Center navigation area
159
+ */
160
+ let navigationArea = h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index) => {
161
+ return (h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index) }, h("span", null, item))));
162
+ }));
163
+ /**
164
+ * Left navigation area
165
+ */
166
+ let buttonsLeftSide = h("div", { class: "LeftItems" }, h("button", { disabled: !this.previousPage, onClick: this.navigateTo.bind(this, 'firstPage') }, translate('firstPage', this.language)), h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, translate('previousPage', this.language)));
167
+ if (isMobile(this.userAgent)) {
168
+ buttonsLeftSide =
169
+ h("div", { class: "LeftItems" }, h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, translate('previousPage', this.language)));
170
+ }
171
+ /**
172
+ * Right navigation area
173
+ */
174
+ let buttonsRightSide = h("div", { class: "RightItems" }, h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, translate('nextPage', this.language)), h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'lastPage') }, translate('lastPage', this.language)));
175
+ if (isMobile(this.userAgent)) {
176
+ buttonsRightSide =
177
+ h("div", { class: "RightItems" }, h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, translate('nextPage', this.language)));
178
+ }
179
+ return (h("div", { id: "PaginationContainer" }, buttonsLeftSide, navigationArea, buttonsRightSide));
180
+ }
181
+ };
182
+ HelperPagination.style = helperPaginationCss;
183
+
184
+ export { HelperPagination as helper_pagination };