@everymatrix/cashier-methods-list 1.44.0 → 1.45.2

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.
package/index.html DELETED
@@ -1,37 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset='utf-8'>
5
- <meta name='viewport' content='width=device-width,initial-scale=1'>
6
-
7
- <title>
8
- cashier-methods-list
9
- </title>
10
- <link rel="stylesheet" href="public/reset.css">
11
- <script src='dist/cashier-methods-list.js'></script>
12
- </head>
13
-
14
- <body>
15
- <style>
16
- html,body { margin: 0; padding: 0; height: 100%; font-family: "Helvetica Neue", "Helvetica", sans-serif; }
17
- .header { display: flex; justify-content: center; align-items: center; padding: 10px 20px; margin-bottom: 20px; background: #42a3e2; box-shadow: 3px 4px 5px 0px rgba(0,0,0, .2); }
18
- .header__logo svg { height: 50px; width: 50px; margin-right: 5px; }
19
- .header__name { color: #fff; }
20
- .header__name span { margin-right: 10px; font-weight: bold; }
21
- .webcomponent { padding: 10px 20px; }
22
- </style>
23
- <header class="header">
24
- <div class="header__logo">
25
- <svg xmlns="http://www.w3.org/2000/svg" width="161" height="132" viewBox="0 0 161 132"><defs><linearGradient x1="0%" y1="50%" y2="50%" id="a"><stop stop-color="#2A3B8F" offset="0%"/><stop stop-color="#29ABE2" offset="100%"/></linearGradient><linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="c"><stop stop-color="#B4D44E" offset="0%"/><stop stop-color="#E7F716" offset="100%"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><path fill="#166DA5" d="M160.6 65.9l-17.4 29.3-24.4-29.7 24.4-28.9z"/><path fill="#8FDB69" d="M141.3 100.2l-26.5-31.7-15.9 26.6 24.7 36.1z"/><path fill="#166DA5" d="M141 31.4l-26.2 31.8-15.9-26.6L123.6.9z"/><path fill="url(#a)" opacity=".95" d="M61.1 31.4H141L123.4.7H78.7z M114.8 63.3H159l-15.9-26.8H98.8"/><path fill="url(#c)" opacity=".95" d="M141.3 100.3H61l17.6 30.5h45z M114.8 68.4H159l-15.9 26.8H98.8"/><path fill="#010101" d="M78.6 130.8L41 65.8 79.1.8H37.9L.4 65.8l37.5 65z"/></g></svg>
26
- </div>
27
- <h1 class="header__name">
28
- <span>WEBCOMPONENT:</span> cashier-methods-list
29
- </h1>
30
- </header>
31
-
32
- <div class="webcomponent">
33
- <cashier-methods-list></cashier-methods-list>
34
- </div>
35
-
36
- </body>
37
- </html>
package/index.js DELETED
@@ -1 +0,0 @@
1
- import './dist/cashier-methods-list.js';
Binary file
package/public/reset.css DELETED
@@ -1,48 +0,0 @@
1
- /* http://meyerweb.com/eric/tools/css/reset/
2
- v2.0 | 20110126
3
- License: none (public domain)
4
- */
5
-
6
- html, body, div, span, applet, object, iframe,
7
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
- a, abbr, acronym, address, big, cite, code,
9
- del, dfn, em, img, ins, kbd, q, s, samp,
10
- small, strike, strong, sub, sup, tt, var,
11
- b, u, i, center,
12
- dl, dt, dd, ol, ul, li,
13
- fieldset, form, label, legend,
14
- table, caption, tbody, tfoot, thead, tr, th, td,
15
- article, aside, canvas, details, embed,
16
- figure, figcaption, footer, header, hgroup,
17
- menu, nav, output, ruby, section, summary,
18
- time, mark, audio, video {
19
- margin: 0;
20
- padding: 0;
21
- border: 0;
22
- font-size: 100%;
23
- font: inherit;
24
- vertical-align: baseline;
25
- }
26
- /* HTML5 display-role reset for older browsers */
27
- article, aside, details, figcaption, figure,
28
- footer, header, hgroup, menu, nav, section {
29
- display: block;
30
- }
31
- body {
32
- line-height: 1;
33
- }
34
- ol, ul {
35
- list-style: none;
36
- }
37
- blockquote, q {
38
- quotes: none;
39
- }
40
- blockquote:before, blockquote:after,
41
- q:before, q:after {
42
- content: '';
43
- content: none;
44
- }
45
- table {
46
- border-collapse: collapse;
47
- border-spacing: 0;
48
- }
package/rollup.config.js DELETED
@@ -1,59 +0,0 @@
1
- import svelte from 'rollup-plugin-svelte';
2
- import commonjs from '@rollup/plugin-commonjs';
3
- import resolve from '@rollup/plugin-node-resolve';
4
- import serve from 'rollup-plugin-dev-server';
5
- import livereload from 'rollup-plugin-livereload';
6
- import { terser } from 'rollup-plugin-terser';
7
- import sveltePreprocess from 'svelte-preprocess';
8
- import typescript from '@rollup/plugin-typescript';
9
- const production = process.env.NODE_ENV === 'production';
10
- const dev = process.env.NODE_ENV === 'development';
11
-
12
- export default {
13
- input: 'src/index.ts',
14
- output: {
15
- sourcemap: true,
16
- format: 'umd',
17
- name: 'app',
18
- file: 'dist/cashier-methods-list.js'
19
- },
20
- plugins: [
21
- svelte({
22
- preprocess: sveltePreprocess(),
23
- compilerOptions: {
24
- // enable run-time checks when not in production
25
- customElement: true,
26
- dev: !production
27
- }
28
- }),
29
- commonjs(),
30
- resolve({
31
- browser: true,
32
- dedupe: ['svelte']
33
- }),
34
- dev && serve({
35
- open: true,
36
- verbose: true,
37
- allowCrossOrigin: true,
38
- historyApiFallback: false,
39
- host: 'localhost',
40
- port: 5050,
41
- }),
42
- dev && livereload({ watch: ['', 'dist'] }),
43
- typescript({
44
- sourceMap: !production,
45
- inlineSources: !production,
46
- }),
47
- // If we're building for production (npm run build
48
- // instead of npm run dev), minify
49
- production &&
50
- terser({
51
- output: {
52
- comments: "all"
53
- },
54
- })
55
- ],
56
- watch: {
57
- clearScreen: false
58
- }
59
- };
@@ -1,15 +0,0 @@
1
- export interface Currency {
2
- Name: string;
3
- MinAmountLimit: number;
4
- MaxAmountLimit: number;
5
- }
6
-
7
- export interface PaymentMethod {
8
- Name: string;
9
- Label: string;
10
- MinLimit: number;
11
- MaxLimit: number;
12
- Currency: string;
13
- LogoUrl: string;
14
- DisplayCurrency: Currency
15
- }
@@ -1,376 +0,0 @@
1
- <svelte:options tag={null} />
2
- <script lang="ts">
3
- import { _, addNewMessages, setLocale } from './i18n';
4
- import { TRANSLATIONS } from './translations';
5
- import type { PaymentMethod } from './CashierMethodItem.types';
6
- import {createEventDispatcher, onMount} from "svelte";
7
- import dayjs from 'dayjs';
8
- import utc from 'dayjs/plugin/utc';
9
- dayjs.extend(utc);
10
-
11
- export let lang: string = 'en';
12
- export let local: string = 'en-US';
13
- export let endpoint: string;
14
- export let session: string;
15
- export let customerid: string;
16
- export let assetsurl: string;
17
- export let currency: string;
18
- export let numberofmethodsshown: string;
19
- export let translationurl: string='';
20
- export let clientstyling: string = '';
21
- export let clientstylingurl: string = '';
22
- export let ismobileview: string
23
-
24
- let paymentMethods: PaymentMethod[] = [];
25
- let isTranslationLoaded = false;
26
- let displayNone: boolean = false;
27
- let customStylingContainer:HTMLElement;
28
- let selectedPaymentMethod: string;
29
- let methodsButtonToggleText: string = '';
30
- let paymentMethodsToShow: PaymentMethod[] = [];
31
- let showMethodsList: boolean = true;
32
- let formatter = new Intl.NumberFormat(local, {minimumFractionDigits: 2 });
33
- let errorMessage = '';
34
- let errorResponseCode: string;
35
- let desktopView: boolean = true;
36
- let showSpinner: boolean = false;
37
-
38
- enum ResponseCode {
39
- PlayerSessionIsNotValid = 'PlayerSessionIsNotValid',
40
- Success = 'Success',
41
- JwtTokenError = 'JwtTokenError'
42
- }
43
-
44
- $: endpoint && session && customerid && getMetaData();
45
- $: lang && setActiveLanguage();
46
- $: clientstyling && customStylingContainer && setClientStyling();
47
- $: clientstylingurl && customStylingContainer && setClientStylingURL();
48
- $: ismobileview && setDevice();
49
- $: lang && translationurl && setTranslationUrl();
50
-
51
- const dispatch = createEventDispatcher();
52
-
53
- const setTranslationUrl = () => {
54
- let url:string = translationurl;
55
- if (url) {
56
- return fetch(url).then((res:any) => res.json())
57
- .then((res) => {
58
- Object.keys(res).forEach((item:any):void => {
59
- addNewMessages(item, res[item]);
60
- isTranslationLoaded = true;
61
- });
62
- }).catch((err:any) => {
63
- isTranslationLoaded = true;
64
- console.log(err);
65
- });
66
- }
67
- }
68
-
69
- Object.keys(TRANSLATIONS).forEach((item:any):void => {
70
- addNewMessages(item, TRANSLATIONS[item]);
71
- });
72
-
73
- const setActiveLanguage = ():void => {
74
- setLocale(lang);
75
- }
76
-
77
- const getMetaData = () => {
78
- showSpinner = true;
79
- const url:URL = new URL(`${endpoint}/v1/player/${customerid}/payment/GetPaymentMetadata`);
80
- const headers = new Headers();
81
- headers.append("accept", "application/json");
82
- headers.append("Content-Type", "application/json");
83
- headers.append("X-Client-Request-Timestamp", dayjs.utc().format("YYYY-MM-DD HH:mm:ss.SSS"));
84
- const requestParams:RequestInit = {
85
- method: "POST",
86
- headers: headers,
87
- body: JSON.stringify({
88
- "XPaymentSessionToken": session,
89
- "Currency": currency,
90
- })
91
- }
92
- fetch(url, requestParams).then(res => res.json()).then(data => {
93
- if (data.error) {
94
- errorMessage = data.error;
95
- return;
96
- }
97
- if (data.ResponseCode !== ResponseCode.Success) {
98
- errorResponseCode = data.ResponseCode;
99
- setErrorResponseCode();
100
- return;
101
- }
102
- paymentMethods = data.PaymentMethods?.Ordering ? payMethOrderedList(data) : payMethUnorderedList(data);
103
- methodsButtonToggleText = (numberofmethodsshown && +numberofmethodsshown > 0 && paymentMethods.length > +numberofmethodsshown) ? $_('showAll') : '';
104
- paymentMethodsToShow = methodsButtonToggleText ? paymentMethods.slice(0, +numberofmethodsshown) : paymentMethods;
105
- window.postMessage({ type: 'StartSessionCountdown', paymentMethodName: paymentMethods[0].Name, xPaymentSessionToken: data.XPaymentSessionToken }, window.location.href);
106
- }).finally(() => showSpinner = false)
107
- }
108
-
109
- const payMethOrderedList = (data: any) => {
110
- const payMeths = [];
111
- data.PaymentMethods.Ordering.DefaultPaymentMethodsOrder.forEach(Name => {
112
- const payMethData: any = data.PaymentMethods.PaymentMethods.find(item => item.Name === Name);
113
- if(payMethData) payMeths.push({...payMethData, LogoUrl: payMethData.Logos && payMethData.Logos.length && payMethData.Logos[0].LogoUrl ? `https:${payMethData.Logos[0].LogoUrl}` : ''});
114
- })
115
- return payMeths;
116
- }
117
-
118
- const payMethUnorderedList = (data: any) => {
119
- return data.PaymentMethods.PaymentMethods.map((payMeth) => ({
120
- ...payMeth,
121
- LogoUrl: payMeth.Logos && payMeth.Logos.length && payMeth.Logos[0].LogoUrl ? `https:${payMeth.Logos[0].LogoUrl}` : ''
122
- }));
123
- }
124
-
125
- const selectPayMeth = (payMeth: PaymentMethod): void => {
126
- selectedPaymentMethod = payMeth.Name;
127
- dispatchEvent(new CustomEvent('selectPayMeth', {
128
- detail: payMeth,
129
- bubbles: true,
130
- cancelable: true,
131
- composed: true
132
- }));
133
- }
134
-
135
- const setErrorResponseCode = () => {
136
- window.postMessage({type: 'ErrorResponseCode', errorResponseCode}, window.location.href);
137
- }
138
-
139
- const setDevice = () => {
140
- desktopView = ismobileview === 'false';
141
- }
142
-
143
- const showAllMethodsToggle = () => {
144
- paymentMethodsToShow == paymentMethods ? showLessMethods() : showAllMethods()
145
- }
146
-
147
- const showAllMethods = () => {
148
- paymentMethodsToShow = paymentMethods;
149
- methodsButtonToggleText = $_('showLess');
150
- }
151
-
152
- const showLessMethods = () => {
153
- paymentMethodsToShow = paymentMethods.slice(0, +numberofmethodsshown);
154
- if (selectedPaymentMethod && !paymentMethodsToShow.find(item => item.Name === selectedPaymentMethod)) {
155
- paymentMethodsToShow.splice(0, 0, paymentMethods.find(item => item.Name === selectedPaymentMethod));
156
- }
157
- methodsButtonToggleText = $_('showAll');
158
- }
159
-
160
- const showMethodList = () => {
161
- showMethodsList = true;
162
- }
163
-
164
- const hideMethodList = (e) => {
165
- showMethodsList = !e.detail.hideMethodsList;
166
- }
167
-
168
- const setClientStyling = ():void => {
169
- let sheet = document.createElement('style');
170
- sheet.innerHTML = clientstyling;
171
- customStylingContainer.appendChild(sheet);
172
- }
173
-
174
- const setClientStylingURL = ():void => {
175
- displayNone = true;
176
-
177
- let url:URL = new URL(clientstylingurl);
178
- let cssFile:HTMLElement = document.createElement('style');
179
-
180
- fetch(url.href)
181
- .then((res:any) => res.text())
182
- .then((data:any) => {
183
- cssFile.innerHTML = data
184
-
185
- setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
186
- setTimeout(() => { displayNone = false; }, 500);
187
- });
188
- }
189
-
190
- onMount(() => {
191
- window.addEventListener('backToMethodList', showMethodList, false);
192
- window.addEventListener('hideMethodsList', hideMethodList, false);
193
-
194
- return () => {
195
- window.removeEventListener('backToMethodList', showMethodList);
196
- window.removeEventListener('paymentMethodLoaded', hideMethodList);
197
- }
198
- });
199
-
200
- </script>
201
- {#if showSpinner}
202
- <cashier-spinner
203
- {clientstylingurl}
204
- {clientstyling}
205
- ></cashier-spinner>
206
- {/if}
207
- {#if showMethodsList || desktopView}
208
- <div class="CashierMethodListWidget" bind:this={customStylingContainer}>
209
- <div class="CashierMethodList">
210
- {#each paymentMethodsToShow as payMeth, index}
211
- <div class="SelectorWrapper" on:click={() => selectPayMeth(payMeth)}
212
- class:checked="{selectedPaymentMethod === payMeth.Name}" on:keyup={() => {}}>
213
- <div class="MethodLogo">
214
- <img src={payMeth.LogoUrl} alt={payMeth.Label} />
215
- </div>
216
- <div class="MethodTitle">
217
- <span>{payMeth.Label || payMeth.Name}</span>
218
- </div>
219
- <div class="MethodLimits">
220
- <span class="Limits">{$_('generalMin')} {formatter.format(payMeth.DisplayCurrency.MinAmountLimit)} {payMeth.DisplayCurrency.Name}</span>
221
- <span class="Limits">{$_('generalMax')} {formatter.format(payMeth.DisplayCurrency.MaxAmountLimit)} {payMeth.DisplayCurrency.Name}</span>
222
- </div>
223
- </div>
224
- {/each}
225
- </div>
226
- {#if methodsButtonToggleText}
227
- <div class="ShowAllButton" on:click={() => showAllMethodsToggle()}>{methodsButtonToggleText}</div>
228
- {/if}
229
- </div>
230
- {/if}
231
- {#if errorMessage}
232
- <cashier-error
233
- {lang}
234
- {assetsurl}
235
- {translationurl}
236
- {clientstylingurl}
237
- {clientstyling}
238
- hidebuttons="true"
239
- >
240
- <span slot="text">{errorMessage}</span>
241
- </cashier-error>
242
- {/if}
243
-
244
- <style lang="scss">
245
- $color-black-transparency-10: var(--mmw--color-black-transparency-10, rgba(0, 0, 0, .1));
246
- $border-radius-medium-plus: var(--mmw--border-radius-medium-plus, 6px);
247
-
248
- *,
249
- *::before,
250
- *::after {
251
- margin: 0;
252
- padding: 0;
253
- list-style: none;
254
- text-decoration: none;
255
- outline: none;
256
- box-sizing: border-box;
257
- }
258
- .CashierMethodList {
259
- display: flex;
260
- flex-direction: column;
261
- background: var(--emw--color-background, #fff);
262
- box-shadow: 0 0 4px $color-black-transparency-10;
263
- width: 100%;
264
- border-radius: $border-radius-medium-plus;
265
- container-name: method-list;
266
- container-type: inline-size;
267
- }
268
-
269
- .SelectorWrapper {
270
- display: flex;
271
- flex-direction: row;
272
- align-items: center;
273
- justify-content: left;
274
- cursor: pointer;
275
- position: relative;
276
- height: 52px;
277
- box-sizing: border-box;
278
- border-bottom: 1px solid var(--mmw--color-grey-105, #E8E9EB);
279
- padding: 0 var(--emw--spacing-small, 12px);
280
- &:first-child {
281
- border-radius: $border-radius-medium-plus $border-radius-medium-plus 0 0;
282
- }
283
- &:last-child {
284
- border-radius: 0 0 $border-radius-medium-plus $border-radius-medium-plus;
285
- }
286
- &.checked {
287
- background: var(--emw--color-background-secondary, #F9F8F8);
288
- }
289
- &:not(.checked):hover {
290
- background: linear-gradient(0, var(--emw--color-background-secondary, #F9F8F8) 0%, var(--emw--color-background, #fff) 100%);
291
- }
292
- }
293
-
294
- .MethodLogo {
295
- margin-right: var(--mmw--spacing-x-small-minus, 7px);
296
- width: 56px;
297
- height: 32px;
298
- background: var(--emw--color-background, #FFF);
299
- border: 1px solid var(--mmw--color-grey-105, #E8E9EB);
300
- border-radius: $border-radius-medium-plus;
301
- overflow: hidden;
302
- img {
303
- width: inherit;
304
- height: inherit;
305
- }
306
- }
307
-
308
- .MethodTitle {
309
- color: var(--mmw--color-grey-10, #111);
310
- font-size: var(--emw--font-size-small, 14px);
311
- word-break: break-all;
312
- }
313
-
314
- .MethodLimits {
315
- display: flex;
316
- flex-direction: column;
317
- align-items: flex-end;
318
- margin-left: auto;
319
- }
320
-
321
- .Limits {
322
- max-width: 100%;
323
- white-space: nowrap;
324
- font-size: var(--emw--font-size-2x-small-plus, 11px);
325
- line-height: var(--emw--size-small, 14px);
326
- color: var(--mmw--color-grey-290, #666);
327
- font-weight: var(--emw--font-weight-normal, 400);
328
- font-style: normal;
329
- }
330
-
331
- .ShowAllButton {
332
- cursor: pointer;
333
- color: var(--mmw--color-grey-290, #666);
334
- text-align: center;
335
- font-size: var(--emw--font-size-x-small, 12px);
336
- font-style: normal;
337
- font-weight: var(--emw--font-weight-semibold, 500);
338
- font-family: inherit;
339
- background: var(--emw--color-gray-50, #F7F8FA);
340
- line-height: normal;
341
- border: 1px solid var(--mmw--color-grey-105, #E8E9EB);
342
- border-radius: var(--emw--border-radius-medium, 4px);
343
- margin: var(--emw--spacing-small, 12px) auto;
344
- height: 36px;
345
- display: flex;
346
- align-items: center;
347
- justify-content: center;
348
- width: 80%;
349
- &:hover {
350
- background: var(--emw--color-background, #fff);
351
- }
352
- }
353
-
354
- @container method-list (width < 450px) {
355
- .MethodLogo {
356
- min-width: 56px;
357
- }
358
- .CashierMethodList .MethodTitle {
359
- display: inline-block;
360
- flex-grow: 1;
361
- font-size: var(--emw--font-size-x-small, 12px);
362
- overflow: hidden;
363
- white-space: nowrap;
364
- text-overflow: ellipsis;
365
- }
366
- .CashierMethodList .MethodLimits .Limits {
367
- flex-shrink: 0;
368
- font-size: var(--emw--font-size-2x-small, 10px);
369
- }
370
- }
371
- @container method-list (max-width: 300px) {
372
- .Limits {
373
- display: none;
374
- }
375
- }
376
- </style>
package/src/i18n.js DELETED
@@ -1,32 +0,0 @@
1
- import {
2
- dictionary,
3
- locale,
4
- init,
5
- addMessages,
6
- _
7
- } from 'svelte-i18n';
8
-
9
- init({
10
- fallbackLocale: 'en'
11
- });
12
-
13
- function setupI18n({ withLocale: _locale, translations }) {
14
- locale.subscribe((data) => {
15
- if (data == null) {
16
- dictionary.set(translations);
17
- locale.set(_locale);
18
- }
19
- }); // maybe we will need this to make sure that the i18n is set up only once
20
- /*dictionary.set(translations);
21
- locale.set(_locale);*/
22
- }
23
-
24
- function addNewMessages(lang, dict) {
25
- addMessages(lang, dict);
26
- }
27
-
28
- function setLocale(_locale) {
29
- locale.set(_locale);
30
- }
31
-
32
- export { _, setupI18n, addNewMessages, setLocale };
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- import CashierMethodsList from './CashierMethodsList.svelte';
2
-
3
- !customElements.get('cashier-methods-list') && customElements.define('cashier-methods-list', CashierMethodsList);
4
- export default CashierMethodsList;
@@ -1,24 +0,0 @@
1
- export const TRANSLATIONS = {
2
- "en": {
3
- "generalMin": "Min",
4
- "generalMax": "Max",
5
- "showAll": "SHOW ALL",
6
- "showLess": "SHOW LESS"
7
- },
8
- "uk": {
9
- "generalMin": "Мін",
10
- "generalMax": "Макс"
11
- },
12
- "hr": {
13
- "generalMin": "Minimalno",
14
- "generalMax": "Maksimalno",
15
- "showAll": "Prikaži sve",
16
- "showLess": "Prikaži manje"
17
- },
18
- "tr": {
19
- "generalMin": "Min",
20
- "generalMax": "Maks",
21
- "showAll": "HEPSİNİ GÖSTER",
22
- "showLess": "DAHA AZ GÖSTER"
23
- }
24
- }
@@ -1,13 +0,0 @@
1
- import { html } from 'lit-element';
2
-
3
- import CashierMethodsList from '../src/CashierMethodsList';
4
-
5
- // This default export determines where your story goes in the story list
6
- export default {
7
- title: 'CashierMethodsList',
8
- };
9
-
10
- // 👇 We create a “template” of how args map to rendering
11
- const CashierMethodsList = ({ aProperty }) => html`<cashier-methods-list></cashier-methods-list>`;
12
-
13
- export const FirstStory = CashierMethodsList.bind({});
package/tsconfig.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "@tsconfig/svelte/tsconfig.json",
3
-
4
- "include": ["src/**/*"],
5
- "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
6
- }