@everymatrix/cashier-methods-list 1.20.10

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 ADDED
@@ -0,0 +1,37 @@
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 ADDED
@@ -0,0 +1 @@
1
+ import './dist/cashier-methods-list.js';
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@everymatrix/cashier-methods-list",
3
+ "version": "1.20.10",
4
+ "main": "index.js",
5
+ "svelte": "src/index.ts",
6
+ "scripts": {
7
+ "start": "sirv public",
8
+ "build": "cross-env NODE_ENV=production rollup -c",
9
+ "dev": "cross-env NODE_ENV=\"development\" rollup -c -w",
10
+ "validate": "svelte-check",
11
+ "test": "echo"
12
+ },
13
+ "devDependencies": {
14
+ "@rollup/plugin-babel": "^5.3.0",
15
+ "@rollup/plugin-commonjs": "^16.0.0",
16
+ "@rollup/plugin-node-resolve": "^10.0.0",
17
+ "@rollup/plugin-typescript": "^6.0.0",
18
+ "@tsconfig/svelte": "^1.0.0",
19
+ "rollup": "^2.3.4",
20
+ "rollup-plugin-dev-server": "^0.4.3",
21
+ "rollup-plugin-livereload": "^2.0.0",
22
+ "rollup-plugin-svelte": "^7.0.0",
23
+ "rollup-plugin-terser": "^7.0.0",
24
+ "rollup-plugin-uglify": "^6.0.4",
25
+ "svelte-check": "^1.0.0",
26
+ "svelte-preprocess": "^5.0.0",
27
+ "tslib": "^2.0.0",
28
+ "typescript": "^3.9.3"
29
+ },
30
+ "dependencies": {
31
+ "cross-env": "^7.0.3",
32
+ "sirv-cli": "^1.0.0",
33
+ "svelte": "^3.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "gitHead": "90ba6c4378f429df47a59fecc6bc15675ebcfbf9"
39
+ }
Binary file
@@ -0,0 +1,48 @@
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
+ }
@@ -0,0 +1,59 @@
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
+ };
@@ -0,0 +1,9 @@
1
+ export interface PaymentMethod {
2
+ Name: string;
3
+ Label: string;
4
+ MinLimit: number;
5
+ MaxLimit: number;
6
+ Currency: string;
7
+ LimitString?: string;
8
+ LogoUrl: string;
9
+ }
@@ -0,0 +1,283 @@
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} from "svelte";
7
+
8
+ export let lang:string = 'en';
9
+ export let endpoint:string;
10
+ export let accesstoken:string;
11
+ export let xpaymentsessiontoken:string;
12
+ export let merchantid: string;
13
+ export let customerid: string;
14
+ export let currency: string;
15
+ export let translationurl:string='';
16
+ export let clientstyling:string = '';
17
+ export let clientstylingurl:string = ''
18
+
19
+ let paymethnames = [];
20
+ let logoSrc = '';
21
+ let limitString = '';
22
+ let paymentMethods: PaymentMethod[] = [];
23
+ let isTranslationLoaded = false;
24
+ let displayNone:boolean = false;
25
+ let customStylingContainer:HTMLElement;
26
+ let selectedPaymentMethod: string;
27
+
28
+ $: endpoint && accesstoken && xpaymentsessiontoken && merchantid && customerid && getMetaData();
29
+
30
+ const dispatch = createEventDispatcher();
31
+ const setTranslationUrl = () => {
32
+ let url:string = translationurl;
33
+ if (url) {
34
+ return fetch(url).then((res:any) => res.json())
35
+ .then((res) => {
36
+ Object.keys(res).forEach((item:any):void => {
37
+ addNewMessages(item, res[item]);
38
+ isTranslationLoaded = true;
39
+ });
40
+ }).catch((err:any) => {
41
+ isTranslationLoaded = true;
42
+ console.log(err);
43
+ });
44
+ }
45
+ }
46
+
47
+ Object.keys(TRANSLATIONS).forEach((item:any):void => {
48
+ addNewMessages(item, TRANSLATIONS[item]);
49
+ });
50
+
51
+ const setActiveLanguage = ():void => {
52
+ setLocale(lang);
53
+ }
54
+
55
+ const getMetaData = () => {
56
+ const url:URL = new URL(`${endpoint}/Payment/GetPaymentMetadata`);
57
+ const headers = new Headers();
58
+ headers.append("accept", "application/json");
59
+ headers.append("Content-Type", "application/json");
60
+ headers.append('Authorization', `Bearer ${accesstoken}`);
61
+ headers.append("X-Payment-Session-Token", `${xpaymentsessiontoken}`);
62
+ const requestParams:RequestInit = {
63
+ method: "POST",
64
+ mode: "cors",
65
+ headers: headers,
66
+ body: JSON.stringify({
67
+ "MerchantId": merchantid,
68
+ "CustomerId": `${customerid}`,
69
+ "Currency": currency,
70
+ })
71
+ }
72
+ fetch(url, requestParams).then(res => res.json()).then(data => {
73
+ paymentMethods = data.PaymentMethods.PaymentMethods.map((payMeth) => ({
74
+ ...payMeth,
75
+ LimitString: setLimit(payMeth),
76
+ LogoUrl: payMeth.Logos && payMeth.Logos[0].LogoUrl ? `https:${payMeth.Logos[0].LogoUrl}` : '',
77
+ }));
78
+ })
79
+ }
80
+
81
+ const setLimit = (payMeth): string => {
82
+ const minLabel = $_('generalMin');
83
+ const maxLabel = $_('generalMax');
84
+ const min = payMeth.DisplayCurrency.MinAmountLimit ? `${minLabel}: ${payMeth.DisplayCurrency.MinAmountLimit} ${payMeth.DisplayCurrency.Name}` : '';
85
+ const max = payMeth.DisplayCurrency.MaxAmountLimit ? `${maxLabel}: ${payMeth.DisplayCurrency.MaxAmountLimit} ${payMeth.DisplayCurrency.Name}` : '';
86
+ return `${min} ${payMeth.DisplayCurrency.MinAmountLimit && payMeth.DisplayCurrency.MaxAmountLimit ? '/' : ''} ${max}`;
87
+ }
88
+
89
+ const selectPayMeth = (payMeth: PaymentMethod): void => {
90
+ selectedPaymentMethod = payMeth.Name;
91
+ dispatchEvent(new CustomEvent('selectPayMeth', {
92
+ detail: payMeth,
93
+ bubbles: true,
94
+ cancelable: true,
95
+ composed: true // makes the event jump shadow DOM boundary
96
+ }));
97
+ }
98
+
99
+ const setClientStyling = ():void => {
100
+ let sheet = document.createElement('style');
101
+ sheet.innerHTML = clientstyling;
102
+ customStylingContainer.appendChild(sheet);
103
+ }
104
+
105
+ const setClientStylingURL = ():void => {
106
+ displayNone = true;
107
+
108
+ let url:URL = new URL(clientstylingurl);
109
+ let cssFile:HTMLElement = document.createElement('style');
110
+
111
+ fetch(url.href)
112
+ .then((res:any) => res.text())
113
+ .then((data:any) => {
114
+ cssFile.innerHTML = data
115
+
116
+ setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
117
+ setTimeout(() => { displayNone = false; }, 500);
118
+ });
119
+ }
120
+
121
+ $: lang && setActiveLanguage();
122
+ $: translationurl && setTranslationUrl();
123
+ $: clientstyling && customStylingContainer && setClientStyling();
124
+ $: clientstylingurl && customStylingContainer && setClientStylingURL();
125
+
126
+ </script>
127
+
128
+ <div class="CashierMethodItem">
129
+ {#each paymentMethods as payMeth, index}
130
+ <div class="SelectorWrapper" on:click={() => selectPayMeth(payMeth)}
131
+ class:checked="{selectedPaymentMethod === payMeth.Name}" on:keyup={() => {}}>
132
+ <div class="LogoSelector">
133
+ <div class="MethodLogo">
134
+ <img src={payMeth.LogoUrl} alt={payMeth.Label} />
135
+ </div>
136
+ <div class="MethodInfo">
137
+ <div class="MethodTitle">
138
+ <span>{payMeth.Label || payMeth.Name}</span>
139
+ </div>
140
+ <div class="MethodLimits">
141
+ <span class="Limits">{payMeth.LimitString}</span>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ <div class="RadioButtonSelector">
146
+ <input type=radio id={index} name="radioGroup"
147
+ bind:group={paymethnames} value={payMeth.Name}>
148
+ <label for={index}></label>
149
+ </div>
150
+ </div>
151
+ {/each}
152
+ </div>
153
+
154
+ <style lang="scss">
155
+
156
+
157
+ *,
158
+ *::before,
159
+ *::after {
160
+ margin: 0;
161
+ padding: 0;
162
+ list-style: none;
163
+ text-decoration: none;
164
+ outline: none;
165
+ box-sizing: border-box;
166
+ }
167
+ .CashierMethodItem {
168
+ display: flex;
169
+ flex-direction: column;
170
+ gap: 10px;
171
+ .SelectorWrapper {
172
+ display: flex;
173
+ flex-direction: row;
174
+ align-items: center;
175
+ justify-content: space-between;
176
+ cursor: pointer;
177
+ position: relative;
178
+ height: 71px;
179
+ width: 390px;
180
+ background: var(--mm-selector-background-color, #F8F9FA);
181
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
182
+ box-sizing: border-box;
183
+ border-radius: 5px;
184
+ padding: 1% 1% 1% 2%;
185
+ .LogoSelector {
186
+ width: calc(100% - 19px);
187
+ overflow: hidden;
188
+ display: flex;
189
+ flex-direction: row;
190
+ align-items: center;
191
+ justify-content: flex-start;
192
+ }
193
+ .MethodLogo {
194
+ margin-right: 19px;
195
+ width: 82px;
196
+ height: 47px;
197
+ border: 1px solid var(--mm-selector-label-color, #CED4DA);
198
+ box-sizing: content-box;
199
+ border-radius: 2px;
200
+ img {
201
+ width: inherit;
202
+ height: inherit;
203
+ }
204
+ }
205
+ .MethodInfo {
206
+ display: flex;
207
+ flex-direction: column;
208
+ width: calc(100% - 70px);
209
+ gap: 8px;
210
+ }
211
+ .MethodLimits {
212
+ height: 16px;
213
+ display: flex;
214
+ flex-direction: row;
215
+ align-items: center;
216
+ .Limits {
217
+ max-width: 100%;
218
+ white-space: nowrap;
219
+ font-size: 14px;
220
+ color: var(--mm-selector-limits-color, #495057);
221
+ font-weight: 400;
222
+ font-style: normal;
223
+ }
224
+ }
225
+ .RadioButtonSelector {
226
+ position: static;
227
+ height: 30px;
228
+ width: 30px;
229
+ input {
230
+ height: 0;
231
+ width: revert;
232
+ padding: 0;
233
+ border: none;
234
+ display: none;
235
+ }
236
+ label {
237
+ pointer-events: none;
238
+ position: relative;
239
+ cursor: pointer;
240
+ line-height: 20px;
241
+ display: block;
242
+ color: var(--mm-selector-label-color, #CED4DA);
243
+ }
244
+ label::before {
245
+ left: 0;
246
+ content: "";
247
+ position: absolute;
248
+ top: 0;
249
+ width: 30px;
250
+ height: 30px;
251
+ border: 3px solid var(--mm-selector-label-color, #CED4DA);
252
+ border-radius: 100%;
253
+ background: var(--emfe-w-color-white, #FFFFFF);
254
+ box-sizing: border-box;
255
+ }
256
+ label::after {
257
+ left: 6px;
258
+ opacity: 1;
259
+ content: "";
260
+ width: 18px;
261
+ height: 18px;
262
+ background: var(--mm-selector-color-selected, #388D79);
263
+ position: absolute;
264
+ top: 6px;
265
+ border-radius: 100%;
266
+ transition: all 0.2s ease;
267
+ }
268
+ }
269
+ &.checked {
270
+ border: 1px solid var(--mm-selector-color-selected, #388D79);
271
+ input + label:after {
272
+ opacity: 1;
273
+ }
274
+ }
275
+ &:not(.checked) {
276
+ input + label:after {
277
+ opacity: 0;
278
+ }
279
+ }
280
+ }
281
+ }
282
+
283
+ </style>
package/src/i18n.js ADDED
@@ -0,0 +1,27 @@
1
+ import {
2
+ dictionary,
3
+ locale,
4
+ addMessages,
5
+ _
6
+ } from 'svelte-i18n';
7
+
8
+ function setupI18n({ withLocale: _locale, translations }) {
9
+ locale.subscribe((data) => {
10
+ if (data == null) {
11
+ dictionary.set(translations);
12
+ locale.set(_locale);
13
+ }
14
+ }); // maybe we will need this to make sure that the i18n is set up only once
15
+ /*dictionary.set(translations);
16
+ locale.set(_locale);*/
17
+ }
18
+
19
+ function addNewMessages(lang, dict) {
20
+ addMessages(lang, dict);
21
+ }
22
+
23
+ function setLocale(_locale) {
24
+ locale.set(_locale);
25
+ }
26
+
27
+ export { _, setupI18n, addNewMessages, setLocale };
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import CashierMethodsList from './CashierMethodsList.svelte';
2
+
3
+ !customElements.get('cashier-methods-list') && customElements.define('cashier-methods-list', CashierMethodsList);
4
+ export default CashierMethodsList;
@@ -0,0 +1,10 @@
1
+ export const TRANSLATIONS = {
2
+ "en": {
3
+ "generalMin": "Min",
4
+ "generalMax": "Max"
5
+ },
6
+ "uk": {
7
+ "generalMin": "Мін",
8
+ "generalMax": "Макс"
9
+ }
10
+ };
@@ -0,0 +1,13 @@
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 ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "@tsconfig/svelte/tsconfig.json",
3
+
4
+ "include": ["src/**/*"],
5
+ "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
6
+ }