@everymatrix/lottery-ticket 0.0.3

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 (49) hide show
  1. package/dist/cjs/index-fc097c03.js +1250 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/lottery-ticket.cjs.entry.js +147 -0
  5. package/dist/cjs/lottery-ticket.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/lottery-ticket/lottery-ticket.css +193 -0
  8. package/dist/collection/components/lottery-ticket/lottery-ticket.js +384 -0
  9. package/dist/collection/components/lottery-ticket/lottery-ticket.types.js +1 -0
  10. package/dist/collection/index.js +1 -0
  11. package/dist/collection/utils/locale.utils.js +28 -0
  12. package/dist/collection/utils/utils.js +0 -0
  13. package/dist/components/index.d.ts +22 -0
  14. package/dist/components/index.js +2 -0
  15. package/dist/components/lottery-ticket.d.ts +11 -0
  16. package/dist/components/lottery-ticket.js +175 -0
  17. package/dist/esm/index-84f8a38a.js +1224 -0
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/loader.js +17 -0
  20. package/dist/esm/lottery-ticket.entry.js +143 -0
  21. package/dist/esm/lottery-ticket.js +17 -0
  22. package/dist/esm/polyfills/core-js.js +11 -0
  23. package/dist/esm/polyfills/css-shim.js +1 -0
  24. package/dist/esm/polyfills/dom.js +79 -0
  25. package/dist/esm/polyfills/es5-html-element.js +1 -0
  26. package/dist/esm/polyfills/index.js +34 -0
  27. package/dist/esm/polyfills/system.js +6 -0
  28. package/dist/index.cjs.js +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/lottery-ticket/index.esm.js +0 -0
  31. package/dist/lottery-ticket/lottery-ticket.esm.js +1 -0
  32. package/dist/lottery-ticket/p-7ea3fc34.entry.js +1 -0
  33. package/dist/lottery-ticket/p-b69ccce7.js +2 -0
  34. package/dist/stencil.config.js +22 -0
  35. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/lottery-ticket/.stencil/packages/lottery-ticket/stencil.config.d.ts +2 -0
  36. package/dist/types/components/lottery-ticket/lottery-ticket.d.ts +61 -0
  37. package/dist/types/components/lottery-ticket/lottery-ticket.types.d.ts +49 -0
  38. package/dist/types/components.d.ts +113 -0
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  41. package/dist/types/utils/locale.utils.d.ts +1 -0
  42. package/dist/types/utils/utils.d.ts +0 -0
  43. package/loader/cdn.js +3 -0
  44. package/loader/index.cjs.js +3 -0
  45. package/loader/index.d.ts +12 -0
  46. package/loader/index.es2017.js +3 -0
  47. package/loader/index.js +4 -0
  48. package/loader/package.json +10 -0
  49. package/package.json +19 -0
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-fc097c03.js');
6
+
7
+ /*
8
+ Stencil Client Patch Esm v2.17.0 | MIT Licensed | https://stenciljs.com
9
+ */
10
+ const patchEsm = () => {
11
+ return index.promiseResolve();
12
+ };
13
+
14
+ const defineCustomElements = (win, options) => {
15
+ if (typeof window === 'undefined') return Promise.resolve();
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]},[[0,"gridFilled","gridFilledHandler"]]]]]], options);
18
+ });
19
+ };
20
+
21
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,147 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-fc097c03.js');
6
+ require('@everymatrix/lottery-grid');
7
+
8
+ const DEFAULT_LANGUAGE = 'en';
9
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
10
+ const TRANSLATIONS = {
11
+ en: {
12
+ loading: 'Loading, please wait ...',
13
+ error: 'It was an error while trying to fetch the data',
14
+ grid: 'Grid',
15
+ multiplier: 'Multiplier',
16
+ numberOfDraws: 'Number of draws',
17
+ wagerPerDraw: 'Wager per draw',
18
+ resetButton: 'Reset',
19
+ autoButton: 'I feel lucky'
20
+ },
21
+ ro: {
22
+ loading: 'Se incarca, va rugam asteptati ...',
23
+ error: 'A fost o eroare in timp ce asteptam datele',
24
+ grid: 'Grid',
25
+ multiplier: 'Multiplicator',
26
+ numberOfDraws: 'Numarul de extrageri',
27
+ wagerPerDraw: 'Pariul per extragere',
28
+ resetButton: 'Reseteaza',
29
+ autoButton: 'Ma simt norocos'
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 lotteryTicketCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Toggle{cursor:pointer;margin-top:20px;display:inline-block}.ToggleSwitch{display:inline-block;background:#707070;border-radius:16px;width:58px;height:24px;position:relative;vertical-align:middle;transition:background 0.25s}.ToggleSwitch:before,.ToggleSwitch:after{content:\"\"}.ToggleSwitch:before{display:block;background:linear-gradient(to bottom, #fff 0%, #F1F1F1 100%);border-radius:50%;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25);width:16px;height:16px;position:absolute;top:4px;left:4px;transition:left 0.25s}.Toggle:hover .ToggleSwitch:before{background:linear-gradient(to bottom, #fff 0%, #fff 100%);box-shadow:0 0 0 1px rgba(0, 0, 0, 0.5)}.ToggleCheckbox:checked+.ToggleSwitch{background:#00ABA4}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{margin-right:5px;position:relative;top:2px;font-size:14px;font-weight:lighter;color:#000}input[type=number]{-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.NumberInput,.WagerInput{margin-top:10px;display:inline-flex;align-items:center}.NumberInput,.NumberInput *{box-sizing:border-box}.NumberInput button{cursor:pointer;outline:none;-webkit-appearance:none;background-color:transparent;border:none;align-items:center;justify-content:center;height:20px;margin:0;position:relative}.NumberInput button:after{display:inline-block;position:absolute;transform:translate(-50%, -50%) rotate(180deg);width:30px;align-items:center;text-align:center}.NumberInput button.Plus:after{transform:translate(-50%, -50%) rotate(0deg);width:30px;display:inline-flex;align-items:center;text-align:center}.NumberInput input[type=number],.WagerInput input[type=number]{max-width:50px;display:inline-flex;align-items:center;padding:4px 10px;text-align:center}.NumberInput input[type=number] .WagerInputTitle,.WagerInput input[type=number] .WagerInputTitle{font-size:14px;color:#000;padding:10px}.InputDefault{background-color:#F1F1F1;border-radius:4px;padding:5px;border:solid 1px #D4D4D4;color:#707070}.AutoButton{cursor:pointer;display:block;border-radius:4px;padding:8px 25px;width:max-content;margin:5px 0;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.AutoButton:active{background:#00958f;color:#FFF}.ResetButton{cursor:pointer;display:block;border-radius:4px;padding:8px 25px;width:max-content;margin:5px 0;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ResetButton:hover{background:#FF6536;border:1px solid #FF3D00}.TicketGridBullets{background:#f1f1f1;border-radius:4px;padding:20px;margin-top:5px}.TicketGridBullets .TicketGridTitle{margin-top:0px}";
38
+
39
+ const LotteryTicket = class {
40
+ constructor(hostRef) {
41
+ index.registerInstance(this, hostRef);
42
+ this.ticketCompleted = index.createEvent(this, "ticketCompleted", 7);
43
+ this.autoSelection = index.createEvent(this, "autoSelection", 7);
44
+ this.resetSelection = index.createEvent(this, "resetSelection", 7);
45
+ this.stakeChange = index.createEvent(this, "stakeChange", 7);
46
+ this.multiplierChange = index.createEvent(this, "multiplierChange", 7);
47
+ /**
48
+ * Number of grids of a ticket
49
+ */
50
+ this.numberOfGrids = 1;
51
+ /**
52
+ * Option to have the ticket registered for multiple draws
53
+ */
54
+ this.multipleDraws = true;
55
+ /**
56
+ * Shows the reset button
57
+ */
58
+ this.resetButton = false;
59
+ /**
60
+ * Shows the auto-pick button
61
+ */
62
+ this.autoPick = false;
63
+ /**
64
+ * Language
65
+ */
66
+ this.language = 'en';
67
+ this.multiplier = false;
68
+ this.numberOfDraws = 1;
69
+ this.isLoading = true;
70
+ this.hasErrors = false;
71
+ this.ticketDone = false;
72
+ }
73
+ connectedCallback() {
74
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
75
+ fetch(url.href)
76
+ .then((response) => {
77
+ if (response.ok) {
78
+ return response.json();
79
+ }
80
+ else {
81
+ // Throw error
82
+ this.hasErrors = true;
83
+ }
84
+ })
85
+ .then((data) => {
86
+ this.isLoading = false;
87
+ this.gameData = data;
88
+ this.grids = [...Array(data.rules.boards.length).keys()];
89
+ })
90
+ .catch((err) => {
91
+ this.isLoading = false;
92
+ this.hasErrors = true;
93
+ console.error('Error!', err);
94
+ });
95
+ }
96
+ multiplierChangeHandler(e) {
97
+ this.multiplier = e.target ? e.target.checked : false;
98
+ this.multiplierChange.emit(this.multiplier);
99
+ }
100
+ drawsChangeHandler(event) {
101
+ this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
102
+ this.ticketCompleted.emit(this.ticket);
103
+ }
104
+ gridFilledHandler(event) {
105
+ this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
106
+ this.ticketDone = true;
107
+ this.ticketCompleted.emit(this.ticket);
108
+ }
109
+ toggleAutoSelection() {
110
+ this.ticketDone = true;
111
+ this.autoSelection.emit(this.ticketId);
112
+ }
113
+ toggleResetSelection() {
114
+ this.ticketDone = false;
115
+ this.resetSelection.emit(this.ticketId);
116
+ }
117
+ changeStake(event) {
118
+ this.stakeChange.emit({
119
+ ticketId: this.ticketId,
120
+ stake: event.target.value
121
+ });
122
+ }
123
+ render() {
124
+ if (this.isLoading) {
125
+ return (index.h("div", null, index.h("p", null, translate('loading', this.language))));
126
+ }
127
+ else {
128
+ if (this.hasErrors) {
129
+ return (index.h("div", null, index.h("p", null, translate('error', this.language))));
130
+ }
131
+ else {
132
+ const { rules } = this.gameData;
133
+ return (index.h("div", { class: "TicketContainer" }, index.h("p", null, this.gameData.name), this.resetButton && this.ticketDone &&
134
+ index.h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate('resetButton', this.language)), this.autoPick && !this.ticketDone &&
135
+ index.h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate('autoButton', this.language)), this.grids.map((item, index$1) => index.h("div", { class: "TicketGridBullets" }, index.h("p", { class: "TicketGridTitle" }, translate('grid', this.language), " ", item), index.h("lottery-grid", { "grid-index": index$1, "maximum-allowed": rules.boards[index$1].maximumAllowed, "minimum-allowed": rules.boards[index$1].minimumAllowed, "total-numbers": rules.boards[index$1].totalNumbers, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language }))), rules.multiplier &&
136
+ 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 &&
137
+ index.h("div", { class: "TicketDraws" }, index.h("label", { class: "Label" }, translate('numberOfDraws', this.language), ": "), index.h("div", { class: "NumberInput" }, index.h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), index.h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), index.h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), index.h("label", { class: "Label" }, translate('wagerPerDraw', this.language), ": "), index.h("div", { class: "WagerInput" }, rules.stakes.length > 1 ? index.h("div", null, index.h("select", { class: "InputDefault", onChange: (event) => this.changeStake(event) }, rules.stakes.map((item) => index.h("option", { value: item.amount }, item.amount, " ", item.currency)))) : index.h("div", null, index.h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }), index.h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))));
138
+ }
139
+ }
140
+ }
141
+ static get watchers() { return {
142
+ "numberOfDraws": ["drawsChangeHandler"]
143
+ }; }
144
+ };
145
+ LotteryTicket.style = lotteryTicketCss;
146
+
147
+ exports.lottery_ticket = LotteryTicket;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-fc097c03.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.17.0 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ const patchBrowser = () => {
9
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('lottery-ticket.cjs.js', document.baseURI).href));
10
+ const opts = {};
11
+ if (importMeta !== '') {
12
+ opts.resourcesUrl = new URL('.', importMeta).href;
13
+ }
14
+ return index.promiseResolve(opts);
15
+ };
16
+
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]},[[0,"gridFilled","gridFilledHandler"]]]]]], options);
19
+ });
@@ -0,0 +1,12 @@
1
+ {
2
+ "entries": [
3
+ "./components/lottery-ticket/lottery-ticket.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "2.17.0",
8
+ "typescriptVersion": "4.5.4"
9
+ },
10
+ "collections": [],
11
+ "bundles": []
12
+ }
@@ -0,0 +1,193 @@
1
+ @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");
2
+ :host {
3
+ display: block;
4
+ font-family: "Roboto", sans-serif;
5
+ }
6
+
7
+ .Toggle {
8
+ cursor: pointer;
9
+ margin-top: 20px;
10
+ display: inline-block;
11
+ }
12
+
13
+ .ToggleSwitch {
14
+ display: inline-block;
15
+ background: #707070;
16
+ border-radius: 16px;
17
+ width: 58px;
18
+ height: 24px;
19
+ position: relative;
20
+ vertical-align: middle;
21
+ transition: background 0.25s;
22
+ }
23
+ .ToggleSwitch:before, .ToggleSwitch:after {
24
+ content: "";
25
+ }
26
+ .ToggleSwitch:before {
27
+ display: block;
28
+ background: linear-gradient(to bottom, #fff 0%, #F1F1F1 100%);
29
+ border-radius: 50%;
30
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
31
+ width: 16px;
32
+ height: 16px;
33
+ position: absolute;
34
+ top: 4px;
35
+ left: 4px;
36
+ transition: left 0.25s;
37
+ }
38
+
39
+ .Toggle:hover .ToggleSwitch:before {
40
+ background: linear-gradient(to bottom, #fff 0%, #fff 100%);
41
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
42
+ }
43
+
44
+ .ToggleCheckbox:checked + .ToggleSwitch {
45
+ background: #00ABA4;
46
+ }
47
+
48
+ .ToggleCheckbox:checked + .ToggleSwitch:before {
49
+ left: 38px;
50
+ }
51
+
52
+ .ToggleCheckbox {
53
+ position: absolute;
54
+ visibility: hidden;
55
+ }
56
+
57
+ .Label {
58
+ margin-right: 5px;
59
+ position: relative;
60
+ top: 2px;
61
+ font-size: 14px;
62
+ font-weight: lighter;
63
+ color: #000;
64
+ }
65
+
66
+ input[type=number] {
67
+ -webkit-appearance: textfield;
68
+ -moz-appearance: textfield;
69
+ appearance: textfield;
70
+ }
71
+
72
+ input[type=number]::-webkit-inner-spin-button,
73
+ input[type=number]::-webkit-outer-spin-button {
74
+ -webkit-appearance: none;
75
+ }
76
+
77
+ .NumberInput,
78
+ .WagerInput {
79
+ margin-top: 10px;
80
+ display: inline-flex;
81
+ align-items: center;
82
+ }
83
+
84
+ .NumberInput,
85
+ .NumberInput * {
86
+ box-sizing: border-box;
87
+ }
88
+
89
+ .NumberInput button {
90
+ cursor: pointer;
91
+ outline: none;
92
+ -webkit-appearance: none;
93
+ background-color: transparent;
94
+ border: none;
95
+ align-items: center;
96
+ justify-content: center;
97
+ height: 20px;
98
+ margin: 0;
99
+ position: relative;
100
+ }
101
+
102
+ .NumberInput button:after {
103
+ display: inline-block;
104
+ position: absolute;
105
+ transform: translate(-50%, -50%) rotate(180deg);
106
+ width: 30px;
107
+ align-items: center;
108
+ text-align: center;
109
+ }
110
+
111
+ .NumberInput button.Plus:after {
112
+ transform: translate(-50%, -50%) rotate(0deg);
113
+ width: 30px;
114
+ display: inline-flex;
115
+ align-items: center;
116
+ text-align: center;
117
+ }
118
+
119
+ .NumberInput input[type=number],
120
+ .WagerInput input[type=number] {
121
+ max-width: 50px;
122
+ display: inline-flex;
123
+ align-items: center;
124
+ padding: 4px 10px;
125
+ text-align: center;
126
+ }
127
+ .NumberInput input[type=number] .WagerInputTitle,
128
+ .WagerInput input[type=number] .WagerInputTitle {
129
+ font-size: 14px;
130
+ color: #000;
131
+ padding: 10px;
132
+ }
133
+
134
+ .InputDefault {
135
+ background-color: #F1F1F1;
136
+ border-radius: 4px;
137
+ padding: 5px;
138
+ border: solid 1px #D4D4D4;
139
+ color: #707070;
140
+ }
141
+
142
+ .AutoButton {
143
+ cursor: pointer;
144
+ display: block;
145
+ border-radius: 4px;
146
+ padding: 8px 25px;
147
+ width: max-content;
148
+ margin: 5px 0;
149
+ border: 1px solid #00958f;
150
+ background: #FFF;
151
+ color: #000;
152
+ font-size: 12px;
153
+ transition: all 0.2s linear;
154
+ text-transform: uppercase;
155
+ text-align: center;
156
+ letter-spacing: 0;
157
+ }
158
+ .AutoButton:active {
159
+ background: #00958f;
160
+ color: #FFF;
161
+ }
162
+
163
+ .ResetButton {
164
+ cursor: pointer;
165
+ display: block;
166
+ border-radius: 4px;
167
+ padding: 8px 25px;
168
+ width: max-content;
169
+ margin: 5px 0;
170
+ color: #000;
171
+ font-size: 12px;
172
+ transition: all 0.2s linear;
173
+ text-transform: uppercase;
174
+ text-align: center;
175
+ letter-spacing: 0;
176
+ background: #FF3D00;
177
+ border: 1px solid #FF3D00;
178
+ color: #FFF;
179
+ }
180
+ .ResetButton:hover {
181
+ background: #FF6536;
182
+ border: 1px solid #FF3D00;
183
+ }
184
+
185
+ .TicketGridBullets {
186
+ background: #f1f1f1;
187
+ border-radius: 4px;
188
+ padding: 20px;
189
+ margin-top: 5px;
190
+ }
191
+ .TicketGridBullets .TicketGridTitle {
192
+ margin-top: 0px;
193
+ }