@everymatrix/cashier-methods-list 1.24.4 → 1.24.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/cashier-methods-list",
3
- "version": "1.24.4",
3
+ "version": "1.24.5",
4
4
  "main": "index.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "6b5a6d6584217df74f6dfeed6858faa39a7f971d"
38
+ "gitHead": "9f40283344cfa9ed2c6a61b7a0c27af586f19c3b"
39
39
  }
@@ -3,7 +3,7 @@
3
3
  import { _, addNewMessages, setLocale } from './i18n';
4
4
  import { TRANSLATIONS } from './translations';
5
5
  import type { PaymentMethod } from './CashierMethodItem.types';
6
- import {createEventDispatcher} from "svelte";
6
+ import {createEventDispatcher, onMount} from "svelte";
7
7
 
8
8
  export let lang:string = 'en';
9
9
  export let endpoint:string;
@@ -23,8 +23,9 @@
23
23
  let displayNone:boolean = false;
24
24
  let customStylingContainer:HTMLElement;
25
25
  let selectedPaymentMethod: string;
26
- let methodsButtonToogleText: string = '';
26
+ let methodsButtonToggleText: string = '';
27
27
  let paymentMethodsToShow: PaymentMethod[] = [];
28
+ let showMerchantList: boolean = true;
28
29
 
29
30
  $: endpoint && session && customerid && getMetaData();
30
31
  $: lang && setActiveLanguage();
@@ -74,8 +75,8 @@
74
75
  ...payMeth,
75
76
  LogoUrl: payMeth.Logos && payMeth.Logos[0].LogoUrl ? `https:${payMeth.Logos[0].LogoUrl}` : '',
76
77
  }));
77
- methodsButtonToogleText = (numberofmethodsshown && +numberofmethodsshown > 0 && paymentMethods.length > +numberofmethodsshown) ? $_('showAll') : '';
78
- paymentMethodsToShow = methodsButtonToogleText ? paymentMethods.slice(0, +numberofmethodsshown) : paymentMethods;
78
+ methodsButtonToggleText = (numberofmethodsshown && +numberofmethodsshown > 0 && paymentMethods.length > +numberofmethodsshown) ? $_('showAll') : '';
79
+ paymentMethodsToShow = methodsButtonToggleText ? paymentMethods.slice(0, +numberofmethodsshown) : paymentMethods;
79
80
  })
80
81
  }
81
82
 
@@ -102,7 +103,7 @@
102
103
  }
103
104
  const showAllMethods = () => {
104
105
  paymentMethodsToShow = paymentMethods;
105
- methodsButtonToogleText = $_('showLess');
106
+ methodsButtonToggleText = $_('showLess');
106
107
  }
107
108
 
108
109
  const showLessMethods = () => {
@@ -110,8 +111,17 @@
110
111
  if (selectedPaymentMethod && !paymentMethodsToShow.find(item => item.Name === selectedPaymentMethod)) {
111
112
  paymentMethodsToShow.splice(0, 0, paymentMethods.find(item => item.Name === selectedPaymentMethod));
112
113
  }
113
- methodsButtonToogleText = $_('showAll');
114
+ methodsButtonToggleText = $_('showAll');
114
115
  }
116
+
117
+ const showMethodList = () => {
118
+ showMerchantList = true;
119
+ }
120
+
121
+ const hideMethodList = (e) => {
122
+ showMerchantList = !e.detail.hideMethodsList;
123
+ }
124
+
115
125
  const setClientStyling = ():void => {
116
126
  let sheet = document.createElement('style');
117
127
  sheet.innerHTML = clientstyling;
@@ -134,8 +144,20 @@
134
144
  });
135
145
  }
136
146
 
147
+ onMount(() => {
148
+ window.addEventListener('backToMethodList', showMethodList, false);
149
+ window.addEventListener('hideMethodsList', hideMethodList, false);
150
+
151
+ return () => {
152
+ window.removeEventListener('backToMethodList', showMethodList);
153
+ window.removeEventListener('paymentMethodLoaded', hideMethodList);
154
+ }
155
+ });
156
+
137
157
  </script>
138
- <div>
158
+
159
+ {#if showMerchantList }
160
+ <div class="CashierMethodListWidget" bind:this={customStylingContainer}>
139
161
  <div class="CashierMethodList">
140
162
  {#each paymentMethodsToShow as payMeth, index}
141
163
  <div class="SelectorWrapper" on:click={() => selectPayMeth(payMeth)}
@@ -153,10 +175,11 @@
153
175
  </div>
154
176
  {/each}
155
177
  </div>
156
- {#if methodsButtonToogleText}
157
- <div class="ShowAllButton" on:click={() => showAllMethodsToggle()}>{methodsButtonToogleText}</div>
178
+ {#if methodsButtonToggleText}
179
+ <div class="ShowAllButton" on:click={() => showAllMethodsToggle()}>{methodsButtonToggleText}</div>
158
180
  {/if}
159
181
  </div>
182
+ {/if}
160
183
  <style lang="scss">
161
184
 
162
185
  *,