@everymatrix/lottery-order-summary 0.0.1

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 (57) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-b1042ae5.js +1307 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-button_2.cjs.entry.js +179 -0
  6. package/dist/cjs/lottery-order-summary-9c494983.js +292 -0
  7. package/dist/cjs/lottery-order-summary.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +19 -0
  9. package/dist/collection/components/lottery-order-summary/index.js +1 -0
  10. package/dist/collection/components/lottery-order-summary/lottery-order-summary.css +67 -0
  11. package/dist/collection/components/lottery-order-summary/lottery-order-summary.js +442 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/model/index.js +7 -0
  14. package/dist/collection/utils/utils.js +38 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-8e69c8be.js +1279 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/lottery-button_2.entry.js +175 -0
  20. package/dist/esm/lottery-order-summary-1c477f07.js +287 -0
  21. package/dist/esm/lottery-order-summary.js +20 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/lottery-order-summary/app-globals-0f993ce5.js +1 -0
  25. package/dist/lottery-order-summary/index-8e69c8be.js +2 -0
  26. package/dist/lottery-order-summary/index.esm.js +1 -0
  27. package/dist/lottery-order-summary/lottery-button_2.entry.js +1 -0
  28. package/dist/lottery-order-summary/lottery-order-summary-1c477f07.js +1 -0
  29. package/dist/lottery-order-summary/lottery-order-summary.esm.js +1 -0
  30. package/dist/stencil.config.dev.js +19 -0
  31. package/dist/stencil.config.js +19 -0
  32. package/dist/storybook/main.js +43 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/stencil.config.d.ts +2 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/storybook/main.d.ts +3 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/storybook/preview.d.ts +70 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/index.d.ts +4 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  44. package/dist/types/components/lottery-order-summary/index.d.ts +1 -0
  45. package/dist/types/components/lottery-order-summary/lottery-order-summary.d.ts +87 -0
  46. package/dist/types/components.d.ts +175 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/model/index.d.ts +34 -0
  49. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  50. package/dist/types/utils/utils.d.ts +3 -0
  51. package/loader/cdn.js +1 -0
  52. package/loader/index.cjs.js +1 -0
  53. package/loader/index.d.ts +24 -0
  54. package/loader/index.es2017.js +1 -0
  55. package/loader/index.js +2 -0
  56. package/loader/package.json +11 -0
  57. package/package.json +27 -0
@@ -0,0 +1,442 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { fetchRequest } from "../../utils/utils";
4
+ import { TicketStatus } from "../../model/index";
5
+ import "../../../../../lottery-button/dist/types/index";
6
+ export class LotteryOrderSummary {
7
+ constructor() {
8
+ this.endpoint = undefined;
9
+ this.sessionId = undefined;
10
+ this.mbSource = undefined;
11
+ this.clientStyling = undefined;
12
+ this.clientStylingUrl = undefined;
13
+ this.language = 'en';
14
+ this.orderSummaryTitle = undefined;
15
+ this.ticketsLabel = undefined;
16
+ this.totalLabel = undefined;
17
+ this.showColon = true;
18
+ this.showDivider = false;
19
+ this.submitDisabled = false;
20
+ this.submitButtonText = undefined;
21
+ this.submitLoading = false;
22
+ }
23
+ handleClientStylingChange(newValue, oldValue) {
24
+ if (newValue != oldValue) {
25
+ setClientStyling(this.stylingContainer, this.clientStyling);
26
+ }
27
+ }
28
+ handleClientStylingUrlChange(newValue, oldValue) {
29
+ if (newValue != oldValue) {
30
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
31
+ }
32
+ }
33
+ handleMbSourceChange(newValue, oldValue) {
34
+ if (newValue != oldValue) {
35
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
36
+ }
37
+ }
38
+ componentDidLoad() {
39
+ if (this.stylingContainer) {
40
+ if (this.mbSource)
41
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
42
+ if (this.clientStyling)
43
+ setClientStyling(this.stylingContainer, this.clientStyling);
44
+ if (this.clientStylingUrl)
45
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
46
+ }
47
+ }
48
+ disconnectedCallback() {
49
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
50
+ }
51
+ handleLotteryTicketParamsReady(event) {
52
+ if (event.detail && this.isValidTicketSubmitParam(event.detail)) {
53
+ this.handleSubmitTickets(event.detail);
54
+ }
55
+ }
56
+ isValidTicketSubmitParam(detail) {
57
+ return (detail &&
58
+ detail.playerId &&
59
+ Array.isArray(detail.tickets) &&
60
+ detail.tickets.length > 0 &&
61
+ detail.tickets.every((ticket) => this.isValidTicketParam(ticket)));
62
+ }
63
+ isValidTicketParam(ticket) {
64
+ return (ticket &&
65
+ ticket.amount !== undefined &&
66
+ ticket.multiplier !== undefined &&
67
+ ticket.multiplierNum !== undefined &&
68
+ typeof ticket.quickPick === 'boolean' &&
69
+ ticket.selection !== undefined);
70
+ }
71
+ async handleSubmitTickets(body) {
72
+ try {
73
+ this.submitLoading = true;
74
+ const res = await fetchRequest(`${this.endpoint}/tickets`, 'POST', body, {
75
+ Authorization: `Bearer ${this.sessionId}`
76
+ });
77
+ if (!res.tickets.every((ticket) => ticket.state === TicketStatus.PURCHASED)) {
78
+ this.submitError.emit({
79
+ message: 'Failed to purchase ticket',
80
+ dataOrigin: res,
81
+ status: 200
82
+ });
83
+ }
84
+ else {
85
+ this.submitSuccess.emit({
86
+ dataOrigin: res,
87
+ status: 200
88
+ });
89
+ }
90
+ }
91
+ catch (e) {
92
+ if (e.status === 401) {
93
+ this.sessionExpired.emit();
94
+ }
95
+ if (e.status > 300 || !e.status) {
96
+ this.submitError.emit({
97
+ dataOrigin: e,
98
+ status: e.status || 0
99
+ });
100
+ }
101
+ }
102
+ finally {
103
+ this.submitLoading = false;
104
+ }
105
+ }
106
+ handleSubmit() {
107
+ this.orderSummarySubmit.emit();
108
+ }
109
+ render() {
110
+ return (h("div", { key: 'efdb1636656b63aec159e534475fd666769fd4ca', ref: (el) => (this.stylingContainer = el) }, h("div", { key: '6d4c031bc462d721e18b3e652724835ba8fd690a', class: "order-summary" }, h("h3", { key: '16ce86d321b12b51bab202ab336d64968bf9ff89', class: "order-summary__title" }, this.orderSummaryTitle), h("div", { key: '198532d79c47577006ac5d11f90394ccc513c329', class: "order-summary__ticket" }, h("div", { key: '042e62b7d14a6edd406a14d617d17a1a113f5aae', class: "order-summary__ticket-info" }, h("div", { key: '7e52751fb547ba8b8383456c520228b2b02f5753', class: "order-summary__ticket-label" }, h("div", { key: '90684f3d39ba97a1abd9d8c63e2674b36e4b8678', class: "order-summary__ticket" }, this.ticketsLabel), h("span", { key: '16b27f067a674f75fb14b50dcaaaa4c85eb7ebf2', class: "order-summary__colon" }, this.showColon ? ':' : null)), h("div", { key: 'a197e3f00bc600a048b37f90ad3a8e37d57dbb13', class: "order-summary__details" }, h("slot", { key: '2ae61d6ba689093da155390d7fe85c3c96bb8ba0', name: "orderSummaryTicketDetail" }))), this.showDivider && h("hr", { key: 'a27f9309ef46d2d99edc2dd24c1cbe61153548c8', class: "order-summary__divider" }), h("div", { key: 'd7574288d92159b7f455c0ce610e0b44c6a5d5fb', class: "order-summary__ticket-info" }, h("div", { key: '160290be8ee8267c24372fcccc0172fbde699e54', class: "order-summary__ticket-label" }, h("div", { key: '2489842ef3993d180dbda4304d9bf0dd60c5179d', class: "order-summary__ticket" }, this.totalLabel), h("span", { key: 'f58319a518511ff51402e26d897ea60de1bf9dce', class: "order-summary__colon" }, this.showColon ? ':' : null)), h("span", { key: '7f01d9a780150d81e777702635d66aa04aa9b6da', class: "order-summary__details" }, h("slot", { key: 'f72248a4423c6edf89555d0c53d29cd0d4cedf7a', name: "orderSummaryTotalDetail" })))), h("slot", { key: 'a5da30406e02ea7dbdbf1f37fc89106b08bd8d3d', name: "orderSummaryChoice" }), h("div", { key: 'ed9429dd65495cea075910c5d41f0b9f7785cbb3', class: "order-summary__button-wrapper" }, h("lottery-button", { key: '5a31daaeb0faad9127e5c383fc1196a6763278d1', onClick: this.handleSubmit.bind(this), loading: this.submitLoading, disabled: this.submitDisabled, text: this.submitButtonText })))));
111
+ }
112
+ static get is() { return "lottery-order-summary"; }
113
+ static get encapsulation() { return "shadow"; }
114
+ static get originalStyleUrls() {
115
+ return {
116
+ "$": ["lottery-order-summary.scss"]
117
+ };
118
+ }
119
+ static get styleUrls() {
120
+ return {
121
+ "$": ["lottery-order-summary.css"]
122
+ };
123
+ }
124
+ static get properties() {
125
+ return {
126
+ "endpoint": {
127
+ "type": "string",
128
+ "mutable": false,
129
+ "complexType": {
130
+ "original": "string",
131
+ "resolved": "string",
132
+ "references": {}
133
+ },
134
+ "required": false,
135
+ "optional": false,
136
+ "docs": {
137
+ "tags": [],
138
+ "text": "Endpoint URL for the source of data"
139
+ },
140
+ "attribute": "endpoint",
141
+ "reflect": true
142
+ },
143
+ "sessionId": {
144
+ "type": "string",
145
+ "mutable": false,
146
+ "complexType": {
147
+ "original": "string",
148
+ "resolved": "string",
149
+ "references": {}
150
+ },
151
+ "required": false,
152
+ "optional": false,
153
+ "docs": {
154
+ "tags": [],
155
+ "text": "GIC Session"
156
+ },
157
+ "attribute": "session-id",
158
+ "reflect": true
159
+ },
160
+ "mbSource": {
161
+ "type": "string",
162
+ "mutable": false,
163
+ "complexType": {
164
+ "original": "string",
165
+ "resolved": "string",
166
+ "references": {}
167
+ },
168
+ "required": false,
169
+ "optional": false,
170
+ "docs": {
171
+ "tags": [],
172
+ "text": "Client custom styling via message bus"
173
+ },
174
+ "attribute": "mb-source",
175
+ "reflect": true
176
+ },
177
+ "clientStyling": {
178
+ "type": "string",
179
+ "mutable": false,
180
+ "complexType": {
181
+ "original": "string",
182
+ "resolved": "string",
183
+ "references": {}
184
+ },
185
+ "required": false,
186
+ "optional": false,
187
+ "docs": {
188
+ "tags": [],
189
+ "text": "Client custom styling via string"
190
+ },
191
+ "attribute": "client-styling",
192
+ "reflect": true
193
+ },
194
+ "clientStylingUrl": {
195
+ "type": "string",
196
+ "mutable": false,
197
+ "complexType": {
198
+ "original": "string",
199
+ "resolved": "string",
200
+ "references": {}
201
+ },
202
+ "required": false,
203
+ "optional": false,
204
+ "docs": {
205
+ "tags": [],
206
+ "text": "Client custom styling via css file url"
207
+ },
208
+ "attribute": "client-styling-url",
209
+ "reflect": true
210
+ },
211
+ "language": {
212
+ "type": "string",
213
+ "mutable": false,
214
+ "complexType": {
215
+ "original": "string",
216
+ "resolved": "string",
217
+ "references": {}
218
+ },
219
+ "required": false,
220
+ "optional": false,
221
+ "docs": {
222
+ "tags": [],
223
+ "text": "Client custom language for translation"
224
+ },
225
+ "attribute": "language",
226
+ "reflect": true,
227
+ "defaultValue": "'en'"
228
+ },
229
+ "orderSummaryTitle": {
230
+ "type": "string",
231
+ "mutable": false,
232
+ "complexType": {
233
+ "original": "string",
234
+ "resolved": "string",
235
+ "references": {}
236
+ },
237
+ "required": false,
238
+ "optional": false,
239
+ "docs": {
240
+ "tags": [],
241
+ "text": "Title of the order summary"
242
+ },
243
+ "attribute": "order-summary-title",
244
+ "reflect": false
245
+ },
246
+ "ticketsLabel": {
247
+ "type": "string",
248
+ "mutable": false,
249
+ "complexType": {
250
+ "original": "string",
251
+ "resolved": "string",
252
+ "references": {}
253
+ },
254
+ "required": false,
255
+ "optional": false,
256
+ "docs": {
257
+ "tags": [],
258
+ "text": "Label for the tickets row"
259
+ },
260
+ "attribute": "tickets-label",
261
+ "reflect": false
262
+ },
263
+ "totalLabel": {
264
+ "type": "string",
265
+ "mutable": false,
266
+ "complexType": {
267
+ "original": "string",
268
+ "resolved": "string",
269
+ "references": {}
270
+ },
271
+ "required": false,
272
+ "optional": false,
273
+ "docs": {
274
+ "tags": [],
275
+ "text": "Label for the total row"
276
+ },
277
+ "attribute": "total-label",
278
+ "reflect": false
279
+ },
280
+ "showColon": {
281
+ "type": "boolean",
282
+ "mutable": false,
283
+ "complexType": {
284
+ "original": "boolean",
285
+ "resolved": "boolean",
286
+ "references": {}
287
+ },
288
+ "required": false,
289
+ "optional": false,
290
+ "docs": {
291
+ "tags": [],
292
+ "text": "Whether to show a colon after labels"
293
+ },
294
+ "attribute": "show-colon",
295
+ "reflect": false,
296
+ "defaultValue": "true"
297
+ },
298
+ "showDivider": {
299
+ "type": "boolean",
300
+ "mutable": false,
301
+ "complexType": {
302
+ "original": "boolean",
303
+ "resolved": "boolean",
304
+ "references": {}
305
+ },
306
+ "required": false,
307
+ "optional": false,
308
+ "docs": {
309
+ "tags": [],
310
+ "text": "Whether to show divider"
311
+ },
312
+ "attribute": "show-divider",
313
+ "reflect": false,
314
+ "defaultValue": "false"
315
+ },
316
+ "submitDisabled": {
317
+ "type": "boolean",
318
+ "mutable": false,
319
+ "complexType": {
320
+ "original": "boolean",
321
+ "resolved": "boolean",
322
+ "references": {}
323
+ },
324
+ "required": false,
325
+ "optional": false,
326
+ "docs": {
327
+ "tags": [],
328
+ "text": "Whether the submit button is disabled"
329
+ },
330
+ "attribute": "submit-disabled",
331
+ "reflect": false,
332
+ "defaultValue": "false"
333
+ },
334
+ "submitButtonText": {
335
+ "type": "string",
336
+ "mutable": false,
337
+ "complexType": {
338
+ "original": "string",
339
+ "resolved": "string",
340
+ "references": {}
341
+ },
342
+ "required": false,
343
+ "optional": false,
344
+ "docs": {
345
+ "tags": [],
346
+ "text": "Text to display on the submit button"
347
+ },
348
+ "attribute": "submit-button-text",
349
+ "reflect": false
350
+ }
351
+ };
352
+ }
353
+ static get states() {
354
+ return {
355
+ "submitLoading": {}
356
+ };
357
+ }
358
+ static get events() {
359
+ return [{
360
+ "method": "orderSummarySubmit",
361
+ "name": "orderSummarySubmit",
362
+ "bubbles": true,
363
+ "cancelable": true,
364
+ "composed": true,
365
+ "docs": {
366
+ "tags": [],
367
+ "text": "Emitted when the submit button is clicked"
368
+ },
369
+ "complexType": {
370
+ "original": "any",
371
+ "resolved": "any",
372
+ "references": {}
373
+ }
374
+ }, {
375
+ "method": "submitSuccess",
376
+ "name": "lotteryTicketSubmitSuccess",
377
+ "bubbles": true,
378
+ "cancelable": true,
379
+ "composed": true,
380
+ "docs": {
381
+ "tags": [],
382
+ "text": "Emitted when a ticket is successfully submitted"
383
+ },
384
+ "complexType": {
385
+ "original": "any",
386
+ "resolved": "any",
387
+ "references": {}
388
+ }
389
+ }, {
390
+ "method": "submitError",
391
+ "name": "lotteryTicketSubmitError",
392
+ "bubbles": true,
393
+ "cancelable": true,
394
+ "composed": true,
395
+ "docs": {
396
+ "tags": [],
397
+ "text": "Emitted when a ticket submission fails"
398
+ },
399
+ "complexType": {
400
+ "original": "any",
401
+ "resolved": "any",
402
+ "references": {}
403
+ }
404
+ }, {
405
+ "method": "sessionExpired",
406
+ "name": "sessionExpired",
407
+ "bubbles": true,
408
+ "cancelable": true,
409
+ "composed": true,
410
+ "docs": {
411
+ "tags": [],
412
+ "text": "Emitted when the player's session is expired"
413
+ },
414
+ "complexType": {
415
+ "original": "void",
416
+ "resolved": "void",
417
+ "references": {}
418
+ }
419
+ }];
420
+ }
421
+ static get watchers() {
422
+ return [{
423
+ "propName": "clientStyling",
424
+ "methodName": "handleClientStylingChange"
425
+ }, {
426
+ "propName": "clientStylingUrl",
427
+ "methodName": "handleClientStylingUrlChange"
428
+ }, {
429
+ "propName": "mbSource",
430
+ "methodName": "handleMbSourceChange"
431
+ }];
432
+ }
433
+ static get listeners() {
434
+ return [{
435
+ "name": "lotteryTicketParamsReady",
436
+ "method": "handleLotteryTicketParamsReady",
437
+ "target": "window",
438
+ "capture": false,
439
+ "passive": false
440
+ }];
441
+ }
442
+ }
@@ -0,0 +1 @@
1
+ export * from './components/lottery-order-summary';
@@ -0,0 +1,7 @@
1
+ export var TicketStatus;
2
+ (function (TicketStatus) {
3
+ TicketStatus["PURCHASED"] = "Purchased";
4
+ TicketStatus["SETTLED"] = "Settled";
5
+ TicketStatus["CANCELED"] = "Canceled";
6
+ TicketStatus["ERROR"] = "Error";
7
+ })(TicketStatus || (TicketStatus = {}));
@@ -0,0 +1,38 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
4
+ export const generateUUID = () => {
5
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
6
+ var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
7
+ return v.toString(16);
8
+ });
9
+ };
10
+ export function fetchRequest(url, method = 'GET', body = null, headers = {}) {
11
+ return new Promise((resolve, reject) => {
12
+ const uuid = generateUUID();
13
+ const headersOrigin = Object.assign({ 'Content-Type': 'application/json' }, headers);
14
+ if (method !== 'GET' && method !== 'HEAD') {
15
+ headersOrigin['X-Idempotency-Key'] = uuid;
16
+ }
17
+ const options = {
18
+ method,
19
+ headers: headersOrigin,
20
+ body: null
21
+ };
22
+ if (body && method !== 'GET' && method !== 'HEAD') {
23
+ options.body = JSON.stringify(body);
24
+ }
25
+ else {
26
+ delete options.body;
27
+ }
28
+ fetch(url, options)
29
+ .then((response) => {
30
+ if (!response.ok) {
31
+ return reject(response);
32
+ }
33
+ return response.json();
34
+ })
35
+ .then((data) => resolve(data))
36
+ .catch((error) => reject(error));
37
+ });
38
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };