@everymatrix/user-transaction-history 1.13.11

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 (67) hide show
  1. package/dist/cjs/index-206e75cb.js +1416 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/user-transaction-history.cjs.entry.js +333 -0
  5. package/dist/cjs/user-transaction-history.cjs.js +19 -0
  6. package/dist/collection/assets/filter.svg +4 -0
  7. package/dist/collection/assets/warning.svg +4 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/internal/filters.js +22 -0
  10. package/dist/collection/components/internal/loader.js +14 -0
  11. package/dist/collection/components/internal/page-size.js +7 -0
  12. package/dist/collection/components/internal/table.js +31 -0
  13. package/dist/collection/components/internal/transaction.js +14 -0
  14. package/dist/collection/components/user-transaction-history/user-transaction-history.css +406 -0
  15. package/dist/collection/components/user-transaction-history/user-transaction-history.js +357 -0
  16. package/dist/collection/contracts/translation.js +1 -0
  17. package/dist/collection/global/app.js +1 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/models/transactions-response.model.js +1 -0
  20. package/dist/collection/utils/currency.utils.js +18 -0
  21. package/dist/collection/utils/date.util.js +8 -0
  22. package/dist/collection/utils/locale.util.js +55 -0
  23. package/dist/components/index.d.ts +26 -0
  24. package/dist/components/index.js +1 -0
  25. package/dist/components/user-transaction-history.d.ts +11 -0
  26. package/dist/components/user-transaction-history.js +364 -0
  27. package/dist/esm/index-32e3ae05.js +1388 -0
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/loader.js +17 -0
  30. package/dist/esm/polyfills/core-js.js +11 -0
  31. package/dist/esm/polyfills/css-shim.js +1 -0
  32. package/dist/esm/polyfills/dom.js +79 -0
  33. package/dist/esm/polyfills/es5-html-element.js +1 -0
  34. package/dist/esm/polyfills/index.js +34 -0
  35. package/dist/esm/polyfills/system.js +6 -0
  36. package/dist/esm/user-transaction-history.entry.js +329 -0
  37. package/dist/esm/user-transaction-history.js +17 -0
  38. package/dist/index.cjs.js +1 -0
  39. package/dist/index.js +1 -0
  40. package/dist/stencil.config.js +22 -0
  41. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/user-transaction-history/.stencil/packages/user-transaction-history/stencil.config.d.ts +2 -0
  42. package/dist/types/components/internal/filters.d.ts +8 -0
  43. package/dist/types/components/internal/loader.d.ts +2 -0
  44. package/dist/types/components/internal/page-size.d.ts +9 -0
  45. package/dist/types/components/internal/table.d.ts +7 -0
  46. package/dist/types/components/internal/transaction.d.ts +3 -0
  47. package/dist/types/components/user-transaction-history/user-transaction-history.d.ts +40 -0
  48. package/dist/types/components.d.ts +53 -0
  49. package/dist/types/contracts/translation.d.ts +2 -0
  50. package/dist/types/global/app.d.ts +1 -0
  51. package/dist/types/index.d.ts +1 -0
  52. package/dist/types/models/transactions-response.model.d.ts +23 -0
  53. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  54. package/dist/types/utils/currency.utils.d.ts +4 -0
  55. package/dist/types/utils/date.util.d.ts +4 -0
  56. package/dist/types/utils/locale.util.d.ts +28 -0
  57. package/dist/user-transaction-history/index.esm.js +0 -0
  58. package/dist/user-transaction-history/p-10b5b959.js +1 -0
  59. package/dist/user-transaction-history/p-8e086032.entry.js +1 -0
  60. package/dist/user-transaction-history/user-transaction-history.esm.js +1 -0
  61. package/loader/cdn.js +3 -0
  62. package/loader/index.cjs.js +3 -0
  63. package/loader/index.d.ts +12 -0
  64. package/loader/index.es2017.js +3 -0
  65. package/loader/index.js +4 -0
  66. package/loader/package.json +10 -0
  67. 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-206e75cb.js');
6
+
7
+ /*
8
+ Stencil Client Patch Esm v2.15.2 | 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([["user-transaction-history.cjs",[[1,"user-transaction-history",{"endpoint":[513],"session":[513],"language":[513],"userId":[513,"user-id"],"translationUrl":[513,"translation-url"],"mobile":[516],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"page":[32],"pageSize":[32],"showMobileFilter":[32],"to":[32],"from":[32],"type":[32],"transactions":[32],"showLoader":[32]},[[9,"resize","getComponentHeight"]]]]]], options);
18
+ });
19
+ };
20
+
21
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,333 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-206e75cb.js');
6
+
7
+ const DEFAULT_TRANSLATIONS = {
8
+ "en": {
9
+ "deposit": "Deposit",
10
+ "withdrawals": "Withdrawals",
11
+ "show": "Show",
12
+ "from": "From",
13
+ "to": "To",
14
+ "filter": "Filter",
15
+ "transactionId": "Transaction ID",
16
+ "date": "Date",
17
+ "amount": "Amount",
18
+ "productType": "Product Type",
19
+ "status": "Status",
20
+ "noData": "There are no account activities"
21
+ }
22
+ };
23
+ class Localization {
24
+ constructor() { }
25
+ static async loadCustomTranslations(translationUrl) {
26
+ try {
27
+ const response = await fetch(translationUrl, {
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ });
32
+ if (!response.ok) {
33
+ const err = await response.text();
34
+ throw new Error(err);
35
+ }
36
+ const translations = await response.json();
37
+ Localization.updateTranslations(translations);
38
+ }
39
+ catch (ex) {
40
+ console.error(`Failed to load translations ${translationUrl}. ${ex.message}`);
41
+ }
42
+ }
43
+ static translate(key, locale) {
44
+ var _a, _b;
45
+ const avaliableLocales = Localization.getAvaliableLanguages(locale);
46
+ return ((_b = (_a = Localization.customTranslation) === null || _a === void 0 ? void 0 : _a[avaliableLocales.customLanguage]) === null || _b === void 0 ? void 0 : _b[key]) || Localization.defaultTranslation[avaliableLocales.predefinedLanguage][key];
47
+ }
48
+ static getAvaliableLanguages(locale) {
49
+ var _a;
50
+ const customLanguage = ((_a = Localization.customLanguages) === null || _a === void 0 ? void 0 : _a.includes(locale)) ? locale : Localization.defaultLanguage;
51
+ const predefinedLanguage = Localization.supportedLanguages.includes(locale) ? locale : Localization.defaultLanguage;
52
+ return { predefinedLanguage, customLanguage };
53
+ }
54
+ static updateTranslations(translations) {
55
+ Localization.customLanguages = Array.from(new Set([...Localization.supportedLanguages, ...Object.keys(translations).map(k => k.toLowerCase())]));
56
+ Localization.customTranslation = translations;
57
+ }
58
+ }
59
+ Localization.defaultLanguage = 'en';
60
+ Localization.supportedLanguages = ['en'];
61
+ Localization.defaultTranslation = DEFAULT_TRANSLATIONS;
62
+
63
+ const Loader = () => (index.h("div", { class: "loader" },
64
+ index.h("div", null),
65
+ index.h("div", null),
66
+ index.h("div", null),
67
+ index.h("div", null),
68
+ index.h("div", null),
69
+ index.h("div", null),
70
+ index.h("div", null),
71
+ index.h("div", null),
72
+ index.h("div", null),
73
+ index.h("div", null),
74
+ index.h("div", null),
75
+ index.h("div", null)));
76
+
77
+ class DateTransformer {
78
+ constructor() { }
79
+ static dateToFormatedString(date) {
80
+ const dateStr = date.toLocaleDateString('en-gb');
81
+ const timeStr = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
82
+ return `${dateStr}, ${timeStr}`;
83
+ }
84
+ }
85
+
86
+ class CurrencyFormatter {
87
+ constructor() { }
88
+ static format(currency, value) {
89
+ let result = `${value} ${currency}`;
90
+ try {
91
+ const formatter = new Intl.NumberFormat('en-US', {
92
+ style: 'currency',
93
+ currency: currency,
94
+ });
95
+ result = formatter.format(value);
96
+ }
97
+ catch (_a) {
98
+ // If we here formatter do not support that currency.
99
+ // Just ignore that and use the currency name instead of it symbol.
100
+ }
101
+ return result;
102
+ }
103
+ }
104
+
105
+ const TransactionComponent = (transaction) => (index.h("div", { class: "data-transaction" },
106
+ index.h("p", null, transaction.productType),
107
+ index.h("p", { class: "text-style text-style-status" },
108
+ index.h("span", { class: transaction.status.toLowerCase() }, transaction.status)),
109
+ index.h("p", { class: "date" },
110
+ transaction.transId,
111
+ " | ",
112
+ DateTransformer.dateToFormatedString(new Date(transaction.created))),
113
+ index.h("p", { class: "text-style" },
114
+ CurrencyFormatter.format(transaction.currency, transaction.realAmount),
115
+ " ")));
116
+
117
+ const PageSize = (props) => {
118
+ return (index.h("div", { class: "page-size" },
119
+ index.h("span", null, Localization.translate('show', props.language)),
120
+ props.pageSizes.map(pageSize => (index.h("button", { class: props.currentPageSize === pageSize ? 'active' : '', onClick: () => props.changePageSize(pageSize) }, pageSize)))));
121
+ };
122
+
123
+ const Filters = ({ from, to, applyFilters, language }) => {
124
+ let fromPicker;
125
+ let toPicker;
126
+ const fromChange = () => {
127
+ from = fromPicker.value;
128
+ };
129
+ const toChange = () => {
130
+ to = toPicker.value;
131
+ };
132
+ return (index.h("div", { class: "period" },
133
+ index.h("div", { class: "period-content" },
134
+ index.h("div", { class: "date-input" },
135
+ index.h("vaadin-date-picker", { value: from, ref: el => (fromPicker = el), label: Localization.translate('from', language), onChange: fromChange })),
136
+ index.h("span", null,
137
+ index.h("svg", { width: "24px", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
138
+ index.h("path", { d: "m21 11.75c0-.414-.336-.75-.75-.75h-16.5c-.414 0-.75.336-.75.75s.336.75.75.75h16.5c.414 0 .75-.336.75-.75z", "fill-rule": "nonzero", fill: '#5d687b' }))),
139
+ index.h("div", { class: "date-input" },
140
+ index.h("vaadin-date-picker", { value: to, ref: el => (toPicker = el), label: Localization.translate('to', language), onChange: toChange })),
141
+ index.h("button", { class: "filter-btn", onClick: () => applyFilters(from, to) }, Localization.translate('filter', language)))));
142
+ };
143
+
144
+ const TableComponent = ({ source, language }) => {
145
+ const columns = [
146
+ { name: Localization.translate('transactionId', language) },
147
+ {
148
+ name: Localization.translate('date', language),
149
+ },
150
+ {
151
+ name: Localization.translate('amount', language),
152
+ },
153
+ { name: Localization.translate('productType', language) },
154
+ {
155
+ name: Localization.translate('status', language),
156
+ },
157
+ ];
158
+ return (index.h("table", null,
159
+ index.h("thead", null,
160
+ index.h("tr", null, columns.map(column => index.h("th", null, column.name)))),
161
+ index.h("tbody", null, source.map(transaction => index.h("tr", null,
162
+ index.h("td", null, transaction.transId),
163
+ index.h("td", null, DateTransformer.dateToFormatedString(new Date(transaction.created))),
164
+ index.h("td", null,
165
+ CurrencyFormatter.format(transaction.currency, transaction.realAmount),
166
+ " "),
167
+ index.h("td", null, transaction.productType),
168
+ index.h("td", null,
169
+ index.h("span", { class: transaction.status.toLowerCase() }, transaction.status)))))));
170
+ };
171
+
172
+ const userTransactionHistoryCss = ":host{--activeButtonBackground:#7ec51e;--activeButtonFont:#002149;--hoverBackground:#ffffff;--background:#e4e6e8;--success:#7ac345;--heightScrollableContainer:400px;--borderColor:#d3d3d3;--borderColorButton:#c4c4c4;--textColor:#002554;--textColorHover:#7ac345;--errorColor:#c23b21;--loaderColor:#7ac345;--headerTableBackground:#cdcdcd;--borderTable:#dedede;--shadowBorderTable:#f1f1f1;--backgroundTable:#ffffff;font-family:Roboto, Arial, sans-serif;font-size:14px;color:var(--textColor);display:block;background-color:var(--background)}:host .wrapper{height:100%;padding:1rem}:host .types{display:flex;width:100%;gap:5px}:host .transaction-type{background:inherit;font-weight:600;padding:0.6rem 1.6rem;border:1px solid #6c757d;cursor:pointer}:host .transaction-type:hover{color:var(--activeButtonBackground);border-color:var(--activeButtonBackground);background:var(--hoverBackground)}:host .clicked{background-color:var(--activeButtonBackground);border-color:var(--activeButtonBackground)}:host .types-mobile{justify-content:center;margin-bottom:15px}:host .types-desktop{justify-content:flex-end;margin-bottom:3rem}:host .page-size{display:flex;width:100%;justify-content:flex-end;align-items:center}:host .page-size button{background:transparent;border:none;cursor:pointer;margin:0.4rem;width:2rem;height:2rem}:host .page-size button:hover{color:var(--textColorHover)}:host .page-size button.active{background:var(--activeButtonBackground);color:var(--textColor);font-weight:600;border-radius:0.4rem}:host .period{display:flex;width:100%;align-items:flex-end;justify-content:center;gap:10px;background:#f0f0f0;border-bottom:2px solid #e9e9e9;padding:1.6rem 0 0;margin-bottom:4rem}@media (max-width: 801px){:host .period{margin-bottom:0;flex-direction:column;align-items:stretch;width:auto;padding:1.4rem 2.8rem;box-shadow:0 4px 5px 0 rgba(90, 90, 90, 0.24)}}:host .period .range{color:var(--errorColor)}:host .period .filter-btn{height:40px;background:transparent;border:0.1rem solid var(--borderColorButton);min-width:12rem;max-width:17rem;cursor:pointer}@media (max-width: 801px){:host .period .filter-btn{max-width:none;min-width:none;margin-top:1rem}}:host .period .filter-btn:hover{border:none;background:var(--hoverBackground)}:host .period .duet-date__input{padding:7px 60px 7px 7px}:host .period+button{padding:9px 15px}:host .period-content{display:flex;flex-direction:row;width:100%;justify-content:center;align-items:flex-end;margin:0 auto 1.6rem}@media (max-width: 801px){:host .period-content{flex-direction:column;align-items:stretch}}:host .period-content span{height:40px;display:flex;align-items:center;justify-content:center}@media (max-width: 801px){:host .period-content span{display:none}}:host .period-content .filter-btn{margin-left:60px}@media (max-width: 801px){:host .period-content .filter-btn{margin-left:0}}:host .period-content .date-input{padding:0 4px}@media (max-width: 801px){:host .period-content .date-input{width:auto}:host .period-content .date-input:first-child{margin-bottom:0.5rem}}:host .period-content .date-input label{display:inline-block;margin-bottom:0.9rem}:host .period-content .date-input input{border:0.1rem solid var(--borderColor);box-sizing:border-box;border-radius:0.2rem}:host .pagination{display:flex;width:100%;justify-content:center;margin-top:1.5rem}:host .pagination button{cursor:pointer;border:none;background-color:var(--activeButtonBackground);color:#fff;opacity:0.5;padding:7px 12px}:host .pagination button:hover{opacity:1}:host .pagination button:focus{opacity:1}:host button.active{color:var(--activeButtonFont);background-color:var(--activeButtonBackground)}.mobile-filter-button{display:flex;justify-content:center;align-items:center;width:100%;height:2.8rem;background:inherit;border:1px solid var(--borderColorButton)}.mobile-filter-button img{height:50%;margin-right:0.5rem}.noData{display:flex;align-items:center;box-shadow:0 0.4rem 0.4rem rgba(0, 0, 0, 0.25);padding:1.1rem;border-radius:0.6rem}.noData span{margin-left:0.5rem}.table{height:var(--heightScrollableContainer);overflow-y:auto}.table .mobile-table{height:100%}.data-transaction{border-bottom:1px solid var(--borderColor);background-color:var(--hoverBackground);padding:0 20px;display:grid;grid-template-columns:repeat(2, 1fr)}.data-transaction .text-style-status{font-weight:600}.data-transaction .text-style-status .success{color:var(--success)}.data-transaction .text-style-status .error{color:var(--errorColor)}.data-transaction .text-style{text-align:end}.data-transaction .date{font-size:12px;display:flex;align-items:center}.loader{display:inline-block;position:absolute;width:80px;height:80px;top:calc(50% - 40px);left:calc(50% - 40px);z-index:999}.loader::before{content:\"\";position:fixed;top:0;bottom:0;left:0;right:0;background-color:rgba(255, 255, 255, 0.6)}.loader div{position:absolute;width:6px;height:6px;background:var(--loaderColor);border-radius:50%;animation:loader 1.2s linear infinite}.loader div:nth-child(1){animation-delay:0s;top:37px;left:66px}.loader div:nth-child(2){animation-delay:-0.1s;top:22px;left:62px}.loader div:nth-child(3){animation-delay:-0.2s;top:11px;left:52px}.loader div:nth-child(4){animation-delay:-0.3s;top:7px;left:37px}.loader div:nth-child(5){animation-delay:-0.4s;top:11px;left:22px}.loader div:nth-child(6){animation-delay:-0.5s;top:22px;left:11px}.loader div:nth-child(7){animation-delay:-0.6s;top:37px;left:7px}.loader div:nth-child(8){animation-delay:-0.7s;top:52px;left:11px}.loader div:nth-child(9){animation-delay:-0.8s;top:62px;left:22px}.loader div:nth-child(10){animation-delay:-0.9s;top:66px;left:37px}.loader div:nth-child(11){animation-delay:-1s;top:62px;left:52px}.loader div:nth-child(12){animation-delay:-1.1s;top:52px;left:62px}@keyframes loader{0%,20%,80%,100%{transform:scale(1)}50%{transform:scale(1.5)}}.table thead th{position:sticky;top:0}table{border-collapse:collapse;width:100%}table th{padding:14px 24px;text-align:left;font-weight:600;color:var(--textColor);background:var(--headerTableBackground)}table td{padding:1rem 1.7rem;box-shadow:0 -1px 0 0 var(--shadowBorderTable) inset;border-bottom:0.1rem solid var(--borderTable);text-align:left;color:var(--textColor)}table tbody{background:var(--backgroundTable)}table .success{color:var(--success)}table .error{color:var(--errorColor)}vaadin-date-picker{min-width:320px}@media (max-width: 1261px){vaadin-date-picker{width:auto;min-width:auto}}@media (max-width: 801px){vaadin-date-picker{width:100%}}";
173
+
174
+ const TransactionHistoryWidget = class {
175
+ constructor(hostRef) {
176
+ index.registerInstance(this, hostRef);
177
+ this.pageSizes = [10, 25, 50];
178
+ this.pagination = null;
179
+ this.stylingAppended = false;
180
+ /*
181
+ * Language of the application.
182
+ */
183
+ this.language = Localization.defaultLanguage;
184
+ /*
185
+ * Is mobile mode on. Default value `false`.
186
+ */
187
+ this.mobile = false;
188
+ /*
189
+ * Client styling via inline styles.
190
+ */
191
+ this.clientStyling = null;
192
+ /*
193
+ * The path to file with styles in `css` format.
194
+ */
195
+ this.clientStylingUrl = null;
196
+ this.page = 0;
197
+ this.pageSize = this.pageSizes[0];
198
+ this.showMobileFilter = false;
199
+ this.type = '0';
200
+ this.showLoader = true;
201
+ }
202
+ watchMultiple() {
203
+ this.loadTransactions();
204
+ }
205
+ async componentWillLoad() {
206
+ if (this.translationUrl) {
207
+ await Localization.loadCustomTranslations(this.translationUrl);
208
+ }
209
+ this.loadTransactions();
210
+ }
211
+ componentDidRender() {
212
+ this.getComponentHeight();
213
+ if (!this.stylingAppended && this.stylingContainer) {
214
+ if (this.clientStyling) {
215
+ this.setStyles(this.clientStyling);
216
+ }
217
+ if (this.clientStylingUrl) {
218
+ this.setClientStylingByURL();
219
+ }
220
+ this.stylingAppended = true;
221
+ }
222
+ }
223
+ getComponentHeight() {
224
+ var _a;
225
+ if (this.mobile) {
226
+ let height = this.el.getBoundingClientRect().height - ((_a = this.el.shadowRoot.querySelector('.table')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().y);
227
+ this.el.style.setProperty('--heightScrollableContainer', height + 'px');
228
+ }
229
+ }
230
+ setHeightTableProperty() {
231
+ let height = this.getComponentHeight();
232
+ this.el.style.setProperty('--heightScrollableContainer', height + 'px');
233
+ }
234
+ changeTransactionsType(type) {
235
+ this.type = type;
236
+ }
237
+ changePageSize(pageSize) {
238
+ this.pageSize = pageSize;
239
+ }
240
+ prev() {
241
+ var _a;
242
+ if (!((_a = this.pagination) === null || _a === void 0 ? void 0 : _a.previous)) {
243
+ return;
244
+ }
245
+ this.page--;
246
+ }
247
+ next() {
248
+ var _a;
249
+ if (!((_a = this.pagination) === null || _a === void 0 ? void 0 : _a.next)) {
250
+ return;
251
+ }
252
+ this.page++;
253
+ }
254
+ applyFilters(from, to) {
255
+ this.from = from ? new Date(from).toISOString() : null;
256
+ this.to = to ? new Date(to).toISOString() : null;
257
+ this.loadTransactions();
258
+ }
259
+ showFilter() {
260
+ this.showMobileFilter = !this.showMobileFilter;
261
+ }
262
+ render() {
263
+ var _a;
264
+ const filterSrc = index.getAssetPath('../assets/filter.svg');
265
+ const warningSrc = index.getAssetPath('../assets/warning.svg');
266
+ return (index.h(index.Host, null, this.showLoader ? index.h(Loader, null) : '', index.h("div", { class: "wrapper", ref: el => (this.stylingContainer = el) }, index.h("div", { class: { 'types types-mobile': this.mobile, 'types types-desktop': !this.mobile } }, index.h("button", { class: 'transaction-type' + ' ' + (this.type === '0' ? 'clicked' : ''), onClick: () => this.changeTransactionsType('0') }, Localization.translate('deposit', this.language)), index.h("button", { class: 'transaction-type' + ' ' + (this.type === '1' ? 'clicked' : ''), onClick: () => this.changeTransactionsType('1') }, Localization.translate('withdrawals', this.language))), !this.mobile ? index.h(PageSize, { language: this.language, pageSizes: this.pageSizes, currentPageSize: this.pageSize, changePageSize: s => this.changePageSize(s) }) : '', this.mobile ? (index.h("button", { class: "mobile-filter-button", onClick: () => this.showFilter() }, index.h("img", { src: filterSrc, alt: "Filter" }), Localization.translate('filter', this.language))) : (''), !this.mobile || (this.showMobileFilter && this.mobile) ? index.h(Filters, { language: this.language, applyFilters: (from, to) => this.applyFilters(from, to) }) : '', ((_a = this.transactions) === null || _a === void 0 ? void 0 : _a.length) > 0 ? (index.h("div", { class: "table" }, this.mobile ? (index.h("div", { class: "mobile-table" }, this.transactions.map(transaction => (index.h(TransactionComponent, Object.assign({}, transaction)))))) : (index.h(TableComponent, { source: this.transactions, language: this.language })))) : (index.h("div", { class: "noData" }, index.h("img", { src: warningSrc, alt: "Warning" }), index.h("span", null, Localization.translate('noData', this.language)))), index.h("div", { class: "pagination" }, index.h("button", { onClick: () => this.prev() }, '<'), index.h("button", { onClick: () => this.next() }, '>')))));
267
+ }
268
+ async loadTransactions() {
269
+ this.showLoader = true;
270
+ try {
271
+ const url = `${this.endpoint}/v1/player/${this.userId}/transactions/banking?${this.getParams()}`;
272
+ const response = await fetch(url, {
273
+ headers: {
274
+ 'X-Sessionid': this.session,
275
+ 'Content-Type': 'application/json'
276
+ }
277
+ });
278
+ if (!response.ok) {
279
+ const err = await response.text();
280
+ throw new Error(err);
281
+ }
282
+ const data = await response.json();
283
+ this.pagination = data.pagination;
284
+ this.transactions = data.transactions;
285
+ }
286
+ catch (ex) {
287
+ console.error(ex);
288
+ }
289
+ finally {
290
+ this.showLoader = false;
291
+ }
292
+ }
293
+ getParams() {
294
+ var _a, _b;
295
+ const now = new Date();
296
+ const offset = (this.page * this.pageSize).toString();
297
+ const startDate = (_a = this.from) !== null && _a !== void 0 ? _a : new Date(now.getFullYear(), now.getMonth(), 1).toISOString();
298
+ const endDate = (_b = this.to) !== null && _b !== void 0 ? _b : new Date(now.getFullYear(), now.getMonth() + 1, 0).toISOString();
299
+ return `offset=${offset}&endDate=${endDate}&startDate=${startDate}&type=${this.type}&limit=${this.pageSize}`;
300
+ }
301
+ setStyles(styles) {
302
+ const cssFile = document.createElement('style');
303
+ cssFile.innerHTML = styles;
304
+ this.stylingContainer.prepend(cssFile);
305
+ }
306
+ async setClientStylingByURL() {
307
+ try {
308
+ const response = await fetch(this.clientStylingUrl);
309
+ if (!response.ok) {
310
+ const err = await response.text();
311
+ throw new Error(err);
312
+ }
313
+ const styles = await response.text();
314
+ this.setStyles(styles);
315
+ }
316
+ catch (ex) {
317
+ console.error(`Failed to load client styles ${this.clientStylingUrl}`, ex);
318
+ }
319
+ }
320
+ static get assetsDirs() { return ["../assets"]; }
321
+ get el() { return index.getElement(this); }
322
+ static get watchers() { return {
323
+ "page": ["watchMultiple"],
324
+ "type": ["watchMultiple"],
325
+ "session": ["watchMultiple"],
326
+ "userId": ["watchMultiple"],
327
+ "pageSize": ["watchMultiple"],
328
+ "showMobileFilter": ["getComponentHeight"]
329
+ }; }
330
+ };
331
+ TransactionHistoryWidget.style = userTransactionHistoryCss;
332
+
333
+ exports.user_transaction_history = TransactionHistoryWidget;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-206e75cb.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.15.2 | 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('user-transaction-history.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([["user-transaction-history.cjs",[[1,"user-transaction-history",{"endpoint":[513],"session":[513],"language":[513],"userId":[513,"user-id"],"translationUrl":[513,"translation-url"],"mobile":[516],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"page":[32],"pageSize":[32],"showMobileFilter":[32],"to":[32],"from":[32],"type":[32],"transactions":[32],"showLoader":[32]},[[9,"resize","getComponentHeight"]]]]]], options);
19
+ });
@@ -0,0 +1,4 @@
1
+ <svg viewBox="0 0 48 48" id="filter" width="48" height="48"
2
+ xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M4 10h7.09a6 6 0 0 0 11.82 0H44a1 1 0 0 0 0-2H22.91A6 6 0 0 0 11.09 8H4a1 1 0 0 0 0 2zM17 5a4 4 0 1 1-4 4A4 4 0 0 1 17 5zM44 23H36.91a6 6 0 0 0-11.82 0H4a1 1 0 0 0 0 2H25.09a6 6 0 0 0 11.82 0H44a1 1 0 0 0 0-2zM31 28a4 4 0 1 1 4-4A4 4 0 0 1 31 28zM44 38H22.91a6 6 0 0 0-11.82 0H4a1 1 0 0 0 0 2h7.09a6 6 0 0 0 11.82 0H44a1 1 0 0 0 0-2zM17 43a4 4 0 1 1 4-4A4 4 0 0 1 17 43z" data-name="Layer 15"></path>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="22" height="20" viewBox="0 0 22 20" fill="none"
2
+ xmlns="http://www.w3.org/2000/svg">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M22 19.5L11 0.5L0 19.5H22ZM10 16.5V14.5H12V16.5H10ZM10 12.5H12V8.5H10V12.5Z" fill="black" />
4
+ </svg>
@@ -0,0 +1,12 @@
1
+ {
2
+ "entries": [
3
+ "./components/user-transaction-history/user-transaction-history.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "2.15.2",
8
+ "typescriptVersion": "4.5.4"
9
+ },
10
+ "collections": [],
11
+ "bundles": []
12
+ }
@@ -0,0 +1,22 @@
1
+ import { h } from '@stencil/core';
2
+ import { Localization } from '../../utils/locale.util';
3
+ export const Filters = ({ from, to, applyFilters, language }) => {
4
+ let fromPicker;
5
+ let toPicker;
6
+ const fromChange = () => {
7
+ from = fromPicker.value;
8
+ };
9
+ const toChange = () => {
10
+ to = toPicker.value;
11
+ };
12
+ return (h("div", { class: "period" },
13
+ h("div", { class: "period-content" },
14
+ h("div", { class: "date-input" },
15
+ h("vaadin-date-picker", { value: from, ref: el => (fromPicker = el), label: Localization.translate('from', language), onChange: fromChange })),
16
+ h("span", null,
17
+ h("svg", { width: "24px", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
18
+ h("path", { d: "m21 11.75c0-.414-.336-.75-.75-.75h-16.5c-.414 0-.75.336-.75.75s.336.75.75.75h16.5c.414 0 .75-.336.75-.75z", "fill-rule": "nonzero", fill: '#5d687b' }))),
19
+ h("div", { class: "date-input" },
20
+ h("vaadin-date-picker", { value: to, ref: el => (toPicker = el), label: Localization.translate('to', language), onChange: toChange })),
21
+ h("button", { class: "filter-btn", onClick: () => applyFilters(from, to) }, Localization.translate('filter', language)))));
22
+ };
@@ -0,0 +1,14 @@
1
+ import { h } from '@stencil/core';
2
+ export const Loader = () => (h("div", { class: "loader" },
3
+ h("div", null),
4
+ h("div", null),
5
+ h("div", null),
6
+ h("div", null),
7
+ h("div", null),
8
+ h("div", null),
9
+ h("div", null),
10
+ h("div", null),
11
+ h("div", null),
12
+ h("div", null),
13
+ h("div", null),
14
+ h("div", null)));
@@ -0,0 +1,7 @@
1
+ import { h } from '@stencil/core';
2
+ import { Localization } from '../../utils/locale.util';
3
+ export const PageSize = (props) => {
4
+ return (h("div", { class: "page-size" },
5
+ h("span", null, Localization.translate('show', props.language)),
6
+ props.pageSizes.map(pageSize => (h("button", { class: props.currentPageSize === pageSize ? 'active' : '', onClick: () => props.changePageSize(pageSize) }, pageSize)))));
7
+ };
@@ -0,0 +1,31 @@
1
+ import { h } from '@stencil/core';
2
+ import { CurrencyFormatter } from '../../utils/currency.utils';
3
+ import { DateTransformer } from '../../utils/date.util';
4
+ import { Localization } from '../../utils/locale.util';
5
+ export const TableComponent = ({ source, language }) => {
6
+ const columns = [
7
+ { name: Localization.translate('transactionId', language) },
8
+ {
9
+ name: Localization.translate('date', language),
10
+ },
11
+ {
12
+ name: Localization.translate('amount', language),
13
+ },
14
+ { name: Localization.translate('productType', language) },
15
+ {
16
+ name: Localization.translate('status', language),
17
+ },
18
+ ];
19
+ return (h("table", null,
20
+ h("thead", null,
21
+ h("tr", null, columns.map(column => h("th", null, column.name)))),
22
+ h("tbody", null, source.map(transaction => h("tr", null,
23
+ h("td", null, transaction.transId),
24
+ h("td", null, DateTransformer.dateToFormatedString(new Date(transaction.created))),
25
+ h("td", null,
26
+ CurrencyFormatter.format(transaction.currency, transaction.realAmount),
27
+ " "),
28
+ h("td", null, transaction.productType),
29
+ h("td", null,
30
+ h("span", { class: transaction.status.toLowerCase() }, transaction.status)))))));
31
+ };
@@ -0,0 +1,14 @@
1
+ import { h } from '@stencil/core';
2
+ import { DateTransformer } from '../../utils/date.util';
3
+ import { CurrencyFormatter } from '../../utils/currency.utils';
4
+ export const TransactionComponent = (transaction) => (h("div", { class: "data-transaction" },
5
+ h("p", null, transaction.productType),
6
+ h("p", { class: "text-style text-style-status" },
7
+ h("span", { class: transaction.status.toLowerCase() }, transaction.status)),
8
+ h("p", { class: "date" },
9
+ transaction.transId,
10
+ " | ",
11
+ DateTransformer.dateToFormatedString(new Date(transaction.created))),
12
+ h("p", { class: "text-style" },
13
+ CurrencyFormatter.format(transaction.currency, transaction.realAmount),
14
+ " ")));