@everymatrix/lottery-oddsbom-latest-result-group 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 (59) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/helper-date-navigator_6.cjs.entry.js +10586 -0
  3. package/dist/cjs/index-6e8dce5e.js +1265 -0
  4. package/dist/cjs/index.cjs.js +10 -0
  5. package/dist/cjs/loader.cjs.js +15 -0
  6. package/dist/cjs/lottery-oddsbom-latest-result-group-51987144.js +451 -0
  7. package/dist/cjs/lottery-oddsbom-latest-result-group.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +43 -0
  9. package/dist/collection/components/lottery-oddsbom-latest-result-group/index.js +1 -0
  10. package/dist/collection/components/lottery-oddsbom-latest-result-group/lottery-oddsbom-latest-result-group.css +64 -0
  11. package/dist/collection/components/lottery-oddsbom-latest-result-group/lottery-oddsbom-latest-result-group.js +306 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/models/index.js +1 -0
  14. package/dist/collection/utils/api.js +39 -0
  15. package/dist/collection/utils/utils.js +134 -0
  16. package/dist/esm/app-globals-0f993ce5.js +3 -0
  17. package/dist/esm/helper-date-navigator_6.entry.js +10578 -0
  18. package/dist/esm/index-f1cb78c1.js +1237 -0
  19. package/dist/esm/index.js +2 -0
  20. package/dist/esm/loader.js +11 -0
  21. package/dist/esm/lottery-oddsbom-latest-result-group-7f3fc378.js +442 -0
  22. package/dist/esm/lottery-oddsbom-latest-result-group.js +20 -0
  23. package/dist/index.cjs.js +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/lottery-oddsbom-latest-result-group/app-globals-0f993ce5.js +1 -0
  26. package/dist/lottery-oddsbom-latest-result-group/helper-date-navigator_6.entry.js +6657 -0
  27. package/dist/lottery-oddsbom-latest-result-group/index-f1cb78c1.js +2 -0
  28. package/dist/lottery-oddsbom-latest-result-group/index.esm.js +1 -0
  29. package/dist/lottery-oddsbom-latest-result-group/lottery-oddsbom-latest-result-group-7f3fc378.js +1 -0
  30. package/dist/lottery-oddsbom-latest-result-group/lottery-oddsbom-latest-result-group.esm.js +1 -0
  31. package/dist/stencil.config.dev.js +19 -0
  32. package/dist/stencil.config.js +19 -0
  33. package/dist/storybook/main.js +43 -0
  34. package/dist/storybook/preview.js +9 -0
  35. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/packages/stencil/lottery-oddsbom-latest-result-group/stencil.config.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/packages/stencil/lottery-oddsbom-latest-result-group/stencil.config.dev.d.ts +2 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/packages/stencil/lottery-oddsbom-latest-result-group/storybook/main.d.ts +3 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/packages/stencil/lottery-oddsbom-latest-result-group/storybook/preview.d.ts +70 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/tools/plugins/index.d.ts +4 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  44. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result-group/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  45. package/dist/types/components/lottery-oddsbom-latest-result-group/index.d.ts +1 -0
  46. package/dist/types/components/lottery-oddsbom-latest-result-group/lottery-oddsbom-latest-result-group.d.ts +60 -0
  47. package/dist/types/components.d.ts +103 -0
  48. package/dist/types/index.d.ts +1 -0
  49. package/dist/types/models/index.d.ts +156 -0
  50. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  51. package/dist/types/utils/api.d.ts +7 -0
  52. package/dist/types/utils/utils.d.ts +7 -0
  53. package/loader/cdn.js +1 -0
  54. package/loader/index.cjs.js +1 -0
  55. package/loader/index.d.ts +24 -0
  56. package/loader/index.es2017.js +1 -0
  57. package/loader/index.js +2 -0
  58. package/loader/package.json +11 -0
  59. package/package.json +27 -0
@@ -0,0 +1,306 @@
1
+ import "../../../../../helper-date-navigator/dist/types/index";
2
+ import "../../../../../lottery-oddsbom-latest-result/dist/types/index";
3
+ import { h } from "@stencil/core";
4
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
5
+ import { fetchData } from "../../utils/api";
6
+ import { findLatestDateIdx, getUniqueDatesOptions } from "../../utils/utils";
7
+ export class LotteryOddsbomLatestResultGroup {
8
+ constructor() {
9
+ this.mbSource = undefined;
10
+ this.clientStyling = undefined;
11
+ this.clientStylingUrl = undefined;
12
+ this.translationUrl = '';
13
+ this.language = 'en';
14
+ this.endpoint = undefined;
15
+ this.sessionId = undefined;
16
+ this.playerId = '';
17
+ this.gameIds = undefined;
18
+ this.gameIdArr = [];
19
+ this.drawDatesOptions = [];
20
+ this.curDate = undefined;
21
+ this.isLoading = false;
22
+ this.drawResultsObj = {};
23
+ }
24
+ handleClientStylingChange(newValue, oldValue) {
25
+ if (newValue != oldValue) {
26
+ setClientStyling(this.stylingContainer, this.clientStyling);
27
+ }
28
+ }
29
+ handleClientStylingUrlChange(newValue, oldValue) {
30
+ if (newValue != oldValue) {
31
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
32
+ }
33
+ }
34
+ handleMbSourceChange(newValue, oldValue) {
35
+ if (newValue != oldValue) {
36
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
37
+ }
38
+ }
39
+ handleGameIdStringChange(newValue, oldValue) {
40
+ var _a;
41
+ if (newValue != oldValue) {
42
+ this.gameIdArr = ((_a = this.gameIds) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
43
+ this.getData();
44
+ }
45
+ }
46
+ componentDidLoad() {
47
+ var _a;
48
+ this.gameIdArr = ((_a = this.gameIds) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
49
+ this.getData();
50
+ if (this.stylingContainer) {
51
+ if (this.mbSource)
52
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
53
+ if (this.clientStyling)
54
+ setClientStyling(this.stylingContainer, this.clientStyling);
55
+ if (this.clientStylingUrl)
56
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
57
+ }
58
+ }
59
+ disconnectedCallback() {
60
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
61
+ }
62
+ getData() {
63
+ this.isLoading = true;
64
+ fetchData({ endpoint: this.endpoint, gameIds: this.gameIdArr })
65
+ .then((res) => {
66
+ this.drawResultsObj = res;
67
+ const dates = Object.values(res)
68
+ .map((i) => i.drawDatesOptions)
69
+ .filter(Boolean)
70
+ .flat();
71
+ this.drawDatesOptions = getUniqueDatesOptions([], dates);
72
+ this.curDate = this.drawDatesOptions[findLatestDateIdx(this.drawDatesOptions)];
73
+ })
74
+ .finally(() => {
75
+ this.isLoading = false;
76
+ });
77
+ }
78
+ handleChange(e) {
79
+ const idx = e.detail;
80
+ this.curDate = this.drawDatesOptions[idx];
81
+ }
82
+ handleNext() {
83
+ if (this.curDate) {
84
+ const idx = this.drawDatesOptions.findIndex((v) => v === this.curDate);
85
+ if (idx < this.drawDatesOptions.length - 1) {
86
+ this.curDate = this.drawDatesOptions[idx + 1];
87
+ }
88
+ }
89
+ }
90
+ handlePrev() {
91
+ if (this.curDate) {
92
+ const idx = this.drawDatesOptions.findIndex((v) => v === this.curDate);
93
+ if (idx > 0) {
94
+ this.curDate = this.drawDatesOptions[idx - 1];
95
+ }
96
+ }
97
+ }
98
+ renderLoading() {
99
+ return (h("div", { class: "loading-wrap" }, h("section", { class: "dots-container" }, h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }))));
100
+ }
101
+ renderMainContent() {
102
+ return (h("div", null, this.curDate && (h("helper-date-navigator", { language: this.language, "mb-source": this.mbSource, "client-styling": this.clientStyling, "client-styling-url": this.clientStylingUrl, "translation-url": this.translationUrl, date: this.curDate, "default-highlight-dates": JSON.stringify(this.drawDatesOptions || []), onNext: this.handleNext.bind(this), onPrev: this.handlePrev.bind(this), onChangeDate: this.handleChange.bind(this) })), h("div", { class: "games-container" }, this.gameIdArr.map((gameId) => {
103
+ var _a, _b;
104
+ return (h("lottery-oddsbom-latest-result", { endpoint: this.endpoint, "game-id": gameId, "cur-date": this.curDate, drawResults: JSON.stringify((_b = (_a = this.drawResultsObj) === null || _a === void 0 ? void 0 : _a[gameId]) === null || _b === void 0 ? void 0 : _b.drawResultsList), "is-passing-data": true, "show-loading": false, "hide-wrapper-empty": true, language: this.language, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-url": this.clientStylingUrl, "mb-source": this.mbSource, "session-id": this.sessionId, "player-id": this.playerId }));
105
+ }))));
106
+ }
107
+ render() {
108
+ return (h("div", { key: 'e576645b260f4a713cce833aae814ce7edad137e', ref: (el) => (this.stylingContainer = el), class: "lottery-tipping-latest-result-group" }, this.isLoading ? this.renderLoading() : this.renderMainContent()));
109
+ }
110
+ static get is() { return "lottery-oddsbom-latest-result-group"; }
111
+ static get encapsulation() { return "shadow"; }
112
+ static get originalStyleUrls() {
113
+ return {
114
+ "$": ["lottery-oddsbom-latest-result-group.scss"]
115
+ };
116
+ }
117
+ static get styleUrls() {
118
+ return {
119
+ "$": ["lottery-oddsbom-latest-result-group.css"]
120
+ };
121
+ }
122
+ static get properties() {
123
+ return {
124
+ "mbSource": {
125
+ "type": "string",
126
+ "mutable": false,
127
+ "complexType": {
128
+ "original": "string",
129
+ "resolved": "string",
130
+ "references": {}
131
+ },
132
+ "required": false,
133
+ "optional": false,
134
+ "docs": {
135
+ "tags": [],
136
+ "text": "Client custom styling via message bus"
137
+ },
138
+ "attribute": "mb-source",
139
+ "reflect": true
140
+ },
141
+ "clientStyling": {
142
+ "type": "string",
143
+ "mutable": false,
144
+ "complexType": {
145
+ "original": "string",
146
+ "resolved": "string",
147
+ "references": {}
148
+ },
149
+ "required": false,
150
+ "optional": false,
151
+ "docs": {
152
+ "tags": [],
153
+ "text": "Client custom styling via string"
154
+ },
155
+ "attribute": "client-styling",
156
+ "reflect": true
157
+ },
158
+ "clientStylingUrl": {
159
+ "type": "string",
160
+ "mutable": false,
161
+ "complexType": {
162
+ "original": "string",
163
+ "resolved": "string",
164
+ "references": {}
165
+ },
166
+ "required": false,
167
+ "optional": false,
168
+ "docs": {
169
+ "tags": [],
170
+ "text": "Client custom styling via css file url"
171
+ },
172
+ "attribute": "client-styling-url",
173
+ "reflect": true
174
+ },
175
+ "translationUrl": {
176
+ "type": "string",
177
+ "mutable": false,
178
+ "complexType": {
179
+ "original": "string",
180
+ "resolved": "string",
181
+ "references": {}
182
+ },
183
+ "required": false,
184
+ "optional": false,
185
+ "docs": {
186
+ "tags": [],
187
+ "text": "Client custom translation via json file url"
188
+ },
189
+ "attribute": "translation-url",
190
+ "reflect": true,
191
+ "defaultValue": "''"
192
+ },
193
+ "language": {
194
+ "type": "string",
195
+ "mutable": false,
196
+ "complexType": {
197
+ "original": "string",
198
+ "resolved": "string",
199
+ "references": {}
200
+ },
201
+ "required": false,
202
+ "optional": false,
203
+ "docs": {
204
+ "tags": [],
205
+ "text": "Client custom language for translation"
206
+ },
207
+ "attribute": "language",
208
+ "reflect": true,
209
+ "defaultValue": "'en'"
210
+ },
211
+ "endpoint": {
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": ""
224
+ },
225
+ "attribute": "endpoint",
226
+ "reflect": true
227
+ },
228
+ "sessionId": {
229
+ "type": "string",
230
+ "mutable": false,
231
+ "complexType": {
232
+ "original": "string",
233
+ "resolved": "string",
234
+ "references": {}
235
+ },
236
+ "required": false,
237
+ "optional": false,
238
+ "docs": {
239
+ "tags": [],
240
+ "text": "GIC Session"
241
+ },
242
+ "attribute": "session-id",
243
+ "reflect": true
244
+ },
245
+ "playerId": {
246
+ "type": "string",
247
+ "mutable": false,
248
+ "complexType": {
249
+ "original": "string",
250
+ "resolved": "string",
251
+ "references": {}
252
+ },
253
+ "required": false,
254
+ "optional": false,
255
+ "docs": {
256
+ "tags": [],
257
+ "text": "ID of the pool game"
258
+ },
259
+ "attribute": "player-id",
260
+ "reflect": true,
261
+ "defaultValue": "''"
262
+ },
263
+ "gameIds": {
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": "GameID list of the games"
276
+ },
277
+ "attribute": "game-ids",
278
+ "reflect": true
279
+ }
280
+ };
281
+ }
282
+ static get states() {
283
+ return {
284
+ "gameIdArr": {},
285
+ "drawDatesOptions": {},
286
+ "curDate": {},
287
+ "isLoading": {},
288
+ "drawResultsObj": {}
289
+ };
290
+ }
291
+ static get watchers() {
292
+ return [{
293
+ "propName": "clientStyling",
294
+ "methodName": "handleClientStylingChange"
295
+ }, {
296
+ "propName": "clientStylingUrl",
297
+ "methodName": "handleClientStylingUrlChange"
298
+ }, {
299
+ "propName": "mbSource",
300
+ "methodName": "handleMbSourceChange"
301
+ }, {
302
+ "propName": "gameIds",
303
+ "methodName": "handleGameIdStringChange"
304
+ }];
305
+ }
306
+ }
@@ -0,0 +1 @@
1
+ export * from './components/lottery-oddsbom-latest-result-group';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import { fetchRequest, toQueryParams } from "./utils";
2
+ async function fetchDrawsInfo({ endpoint, gameId }) {
3
+ if (!(endpoint && gameId))
4
+ return;
5
+ const GAME_DRAW_LIMIT = 9999;
6
+ const filterData = { status: 'PAYABLE', limit: GAME_DRAW_LIMIT };
7
+ const { items: drawList } = await fetchRequest(`${endpoint}/games/${gameId}/draws${toQueryParams(filterData)}`);
8
+ if (!drawList || drawList.length === 0)
9
+ return {};
10
+ const settledDrawList = drawList.sort((a, b) => a === null || a === void 0 ? void 0 : a.date.localeCompare(b === null || b === void 0 ? void 0 : b.date));
11
+ const drawDatesOptions = settledDrawList.map((item) => item.date);
12
+ return {
13
+ drawDatesOptions,
14
+ drawResultsList: settledDrawList
15
+ };
16
+ }
17
+ export function fetchData({ endpoint, gameIds }) {
18
+ if (!(endpoint && gameIds))
19
+ return;
20
+ return Promise.allSettled(gameIds.map((gameId) => fetchDrawsInfo({ endpoint, gameId })
21
+ .then((res) => {
22
+ return { gameId, drawResultsList: res.drawResultsList, drawDatesOptions: res.drawDatesOptions };
23
+ })
24
+ .catch((error) => {
25
+ console.error(`Failed to fetch data for gameId: ${gameId}`, error);
26
+ return { gameId, drawResultsList: [], drawDatesOptions: [] };
27
+ }))).then((results) => {
28
+ return results.reduce((pre, cur) => {
29
+ if (cur.status === 'fulfilled') {
30
+ const { gameId, drawResultsList, drawDatesOptions } = cur.value;
31
+ pre[gameId] = {
32
+ drawResultsList,
33
+ drawDatesOptions
34
+ };
35
+ return pre;
36
+ }
37
+ }, {});
38
+ });
39
+ }
@@ -0,0 +1,134 @@
1
+ import { differenceInMilliseconds } from "date-fns";
2
+ export function format(first, middle, last) {
3
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
4
+ }
5
+ export const generateUUID = () => {
6
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
7
+ var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
8
+ return v.toString(16);
9
+ });
10
+ };
11
+ export function fetchRequest(url, method = 'GET', body = null, headers = {}) {
12
+ return new Promise((resolve, reject) => {
13
+ const uuid = generateUUID();
14
+ const headersOrigin = Object.assign({ 'Content-Type': 'application/json' }, headers);
15
+ if (method !== 'GET' && method !== 'HEAD') {
16
+ headersOrigin['X-Idempotency-Key'] = uuid;
17
+ }
18
+ const options = {
19
+ method,
20
+ headers: headersOrigin,
21
+ body: null
22
+ };
23
+ if (body && method !== 'GET' && method !== 'HEAD') {
24
+ options.body = JSON.stringify(body);
25
+ }
26
+ else {
27
+ delete options.body;
28
+ }
29
+ fetch(url, options)
30
+ .then((response) => {
31
+ if (!response.ok) {
32
+ reject(`HTTP error! Status: ${response.status}`);
33
+ throw new Error(`HTTP error! Status: ${response.status}`);
34
+ }
35
+ return response.json();
36
+ })
37
+ .then((data) => resolve(data))
38
+ .catch((error) => reject(error));
39
+ });
40
+ }
41
+ export function toQueryParams(params) {
42
+ function isEmptyValueOfArray(arr) {
43
+ if (arr.length === 0) {
44
+ return true;
45
+ }
46
+ const len = arr.length;
47
+ let count = 0;
48
+ for (let i = 0; i < len; i++) {
49
+ if (isEmptyValue(arr[i])) {
50
+ count++;
51
+ }
52
+ else {
53
+ return false;
54
+ }
55
+ }
56
+ if (count === len) {
57
+ return true;
58
+ }
59
+ return false;
60
+ }
61
+ function isEmptyValueOfObject(obj) {
62
+ if (Object.keys(obj).length === 0) {
63
+ return true;
64
+ }
65
+ const len = Object.keys(obj).length;
66
+ let count = 0;
67
+ for (const val of Object.values(obj)) {
68
+ if (isEmptyValue(val)) {
69
+ count++;
70
+ }
71
+ else {
72
+ return false;
73
+ }
74
+ }
75
+ if (count === len) {
76
+ return true;
77
+ }
78
+ return false;
79
+ }
80
+ function isEmptyValue(value, allowZero) {
81
+ if (value === null || value === undefined || value === '') {
82
+ return true;
83
+ }
84
+ else if (value === 0 && allowZero) {
85
+ return false;
86
+ }
87
+ else if (Array.isArray(value)) {
88
+ return isEmptyValueOfArray(value);
89
+ }
90
+ else if (Object.prototype.toString.call(value) === '[object Object]') {
91
+ return isEmptyValueOfObject(value);
92
+ }
93
+ else {
94
+ return !value;
95
+ }
96
+ }
97
+ const finalParams = {};
98
+ Object.entries(params).forEach(([key, value]) => {
99
+ if (!isEmptyValue(value, true)) {
100
+ finalParams[key] = value;
101
+ }
102
+ });
103
+ const queryString = Object.entries(finalParams)
104
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
105
+ .join('&');
106
+ return queryString ? `?${queryString}` : '';
107
+ }
108
+ export function findLatestDateIdx(dateArr) {
109
+ const currentDate = new Date();
110
+ let closestIndex = 0;
111
+ let minDiff = Infinity;
112
+ dateArr.forEach((dateStr, index) => {
113
+ const date = new Date(dateStr);
114
+ const diff = Math.abs(differenceInMilliseconds(currentDate, date));
115
+ if (diff < minDiff) {
116
+ minDiff = diff;
117
+ closestIndex = index;
118
+ }
119
+ });
120
+ return closestIndex;
121
+ }
122
+ export function getUniqueDatesOptions(preDates = [], dates = []) {
123
+ const dateSet = new Set();
124
+ dates.forEach((date) => {
125
+ if (!dateSet.has(date)) {
126
+ dateSet.add(date);
127
+ preDates.push(date);
128
+ }
129
+ });
130
+ return preDates.length ? [...sortDates(preDates)] : [];
131
+ }
132
+ export function sortDates(dateArray) {
133
+ return dateArray.slice().sort((a, b) => a.localeCompare(b));
134
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };