@everymatrix/cashier-method-details 1.29.3 → 1.29.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-method-details",
3
- "version": "1.29.3",
3
+ "version": "1.29.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": "b35b07d0d019ab53162690eac785d06af1ad9de9"
38
+ "gitHead": "f2e3f1edbe2a15979fd224f987ea52d179bb95f0"
39
39
  }
@@ -15,7 +15,8 @@
15
15
  import flatpickr from "flatpickr";
16
16
  import "flatpickr/dist/flatpickr.min.css";
17
17
  import FlatpickrLanguages from "flatpickr/dist/l10n";
18
-
18
+ import dayjs from 'dayjs';
19
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
19
20
  import type {PaymentMethod} from "./CashierMethodDetails.types";
20
21
  export class PaymentMethodDetails {
21
22
  name: string;
@@ -279,7 +280,19 @@
279
280
  if(!el) {
280
281
  return;
281
282
  }
282
- flatpickr(flatpickrEl, {...dateOptions[el.dataset.type], maxDate: el.dataset.maxvalue, minDate: el.dataset.minvalue})
283
+ const field = JSON.parse(el.dataset.field);
284
+ flatpickr(el, {...dateOptions[field.type], maxDate: field.maxValue, minDate: field.minValue, defaultDate: field.defaultValue,
285
+ onReady: (selectedDates, dateStr) => {
286
+ prepareFields[field.name] = dateStr;
287
+ },
288
+ onClose: (selectedDates, dateStr, instance) => {
289
+ if(!fieldValidation[field.name]) {
290
+ prepareFields[field.name] = dateStr;
291
+ } else {
292
+ prepareFields[field.name] = '';
293
+ }
294
+ }
295
+ })
283
296
  });
284
297
  }
285
298
  const setActiveLanguage = ():void => {
@@ -377,7 +390,8 @@
377
390
  window.addEventListener('closeIframe', closeIframe, false);
378
391
  window.addEventListener('notificationButtonClick', retryRedirect, false);
379
392
  window.addEventListener('closeCashierReceiptPage', closeReceiptPage, false);
380
- document.addEventListener('click',closeAllLookups)
393
+ document.addEventListener('click',closeAllLookups);
394
+ dayjs.extend(customParseFormat);
381
395
 
382
396
  return () => {
383
397
  window.removeEventListener('closeModal', closeModal);
@@ -678,6 +692,19 @@
678
692
  amountIntError() || amountDecimalError();
679
693
  }
680
694
 
695
+ const dateTimeValidation = (field) => {
696
+ const value = prepareFields[field.name];
697
+ const format = field.placeholder;
698
+ const inputValue = dayjs(value, format);
699
+ const maxValue = dayjs(field.maxValue, format);
700
+ const minValue = dayjs(field.minValue, format);
701
+ if (inputValue.isBefore(minValue) || inputValue.isAfter(maxValue)) {
702
+ fieldValidation[field.name] = $_('invalidFieldError',{ values: { field: field.label }})
703
+ return;
704
+ }
705
+ fieldValidation[field.name] = showField(field) ? (emptyFieldError(field, value) || patternMatchesError(field, value)) : '';
706
+ }
707
+
681
708
  const validateField = (field) => {
682
709
  const value = prepareFields[field.name]
683
710
  fieldValidation[field.name] = showField(field) ? (emptyFieldError(field, value) || patternMatchesError(field, value)) : '';
@@ -762,15 +789,19 @@
762
789
  on:input="{() => { validateField(field) }}"
763
790
  on:blur="{() => { showError[field.name] = true; validateField(field) }}">
764
791
  {:else if field.type === FieldTypes.Time || field.type === FieldTypes.Date || field.type === FieldTypes.DateTime}
765
- <input type="text" bind:value={ prepareFields[field.name] } pattern={field.format}
766
- data-type={field.type}
767
- data-maxvalue={field.maxValue}
768
- data-minvalue={field.minValue}
792
+ <div class="DateInput">
793
+ <input class="DateTimePicker" type="text" bind:value={ prepareFields[field.name] } pattern={field.format}
794
+ data-field={JSON.stringify(field)}
769
795
  placeholder={field.placeholder}
770
- on:input={() => { validateField(field) }}
771
- on:change={() => { showError[field.name] = true; validateField(field) }}
796
+ on:input={() => { showError[field.name] = true; dateTimeValidation(field) }}
797
+ on:change={() => { showError[field.name] = true; dateTimeValidation(field) }}
798
+ on:blur={() => { showError[field.name] = true; dateTimeValidation(field) }}
772
799
  bind:this={flatpickrEl[flatpickrEl.length]}
773
800
  >
801
+ {#if isMobile(userAgent)}
802
+ <div class="MobileDateInput">{prepareFields[field.name]}</div>
803
+ {/if}
804
+ </div>
774
805
  {:else if field.type === FieldTypes.Number || field.type === FieldTypes.Money}
775
806
  <input type="number" placeholder="{field.placeholder}" bind:value={prepareFields[field.name]}
776
807
  on:input="{() => { validateField(field) }}"
@@ -786,7 +817,7 @@
786
817
 
787
818
  {:else if field.type === FieldTypes.Lookup}
788
819
  <div class="CustomSelect">
789
- <div class="Selected" id="{index}" on:click="{(e) => showLookup(e, field.name)}"> {getValueByFieldName(field.values, prepareFields[field.name])}</div>
820
+ <div class="Selected" id="{index}" on:click="{(e) => showLookup(e, field.name)}"> <span class="SelectedValue">{getValueByFieldName(field.values, prepareFields[field.name])}</span></div>
790
821
  <div class="OptionList"
791
822
  class:Opened={openedLookup === field.name}
792
823
  class:Top={openLookupTop}
@@ -946,12 +977,18 @@
946
977
  margin: 0;
947
978
  }
948
979
 
980
+ input::-webkit-date-and-time-value {
981
+ visibility: hidden;
982
+ }
983
+
949
984
  input[type=number] {
950
985
  -moz-appearance: textfield;
951
986
  }
952
987
  .CashierMethodDetails {
953
988
  width: 100%;
954
- height: 100%;
989
+ height: inherit;
990
+ container-name: method-details;
991
+ container-type: inline-size;
955
992
  }
956
993
  .ReceiptPage {
957
994
  background-color: var(--emw--color-gray-transparency-100, rgb(255, 255, 255));
@@ -1247,6 +1284,19 @@
1247
1284
  display: block;
1248
1285
  }
1249
1286
  }
1287
+ }
1288
+ .DateInput {
1289
+ position: relative;
1290
+ }
1291
+ .MobileDateInput {
1292
+ position: absolute;
1293
+ top: 50%;
1294
+ transform: translateY(-50%);
1295
+ left: 15px;
1296
+ }
1297
+ .DateTimePicker {
1298
+ width: -webkit-fill-available;
1299
+ width: -moz-available;
1250
1300
  }
1251
1301
  .CustomSelect {
1252
1302
  width: 100%;
@@ -1256,6 +1306,9 @@
1256
1306
  display: flex;
1257
1307
  align-items: center;
1258
1308
  cursor: pointer;
1309
+ .SelectedValue {
1310
+ max-width: 95%;
1311
+ }
1259
1312
  &:after {
1260
1313
  position: absolute;
1261
1314
  content: "";
@@ -1296,4 +1349,31 @@
1296
1349
  display: block;
1297
1350
  }
1298
1351
  }
1352
+ @container method-details (width < 699px) {
1353
+ .FormLogo .SelectedLogoDescription {
1354
+ font-size: var(--emw--font-size-x-small, 12px);
1355
+ display: -webkit-box;
1356
+ -webkit-line-clamp: 2;
1357
+ -webkit-box-orient: vertical;
1358
+ overflow: hidden;
1359
+ text-overflow: ellipsis;
1360
+ }
1361
+
1362
+ label, input, .Description, .FormLogo .ChangePaymeth, .OptionList div {
1363
+ font-size: var(--emw--font-size-x-small, 12px);
1364
+ }
1365
+ .SelectedMethodDescription, .AmountLimits {
1366
+ font-size: var(--emw--font-size-2x-small, 10px);
1367
+ }
1368
+
1369
+ .DateTimePicker {
1370
+ -webkit-appearance: none;
1371
+ -moz-appearance: none;
1372
+ font-size: inherit;
1373
+ background: none;
1374
+ width: -webkit-fill-available;
1375
+ font-size: 0;
1376
+ width: -moz-available;
1377
+ }
1378
+ }
1299
1379
  </style>
@@ -2,8 +2,8 @@ export const TRANSLATIONS = {
2
2
  "en": {
3
3
  "loading": "Loading...",
4
4
  "amountLabel": "Amount",
5
- "redirectTitle": "You are redirected to the payment\'s provider page",
6
- "redirectMessage": "Please complete your transaction on the payment\'s provider page.",
5
+ "redirectTitle": "You are redirected to the payment's provider page",
6
+ "redirectMessage": "Please complete your transaction on the payment's provider page.",
7
7
  "backToPayment": "Close",
8
8
  "retryText": "Please note that your popup blocker may prevent the payment window from appearing",
9
9
  "retryButton": "RETRY",
@@ -23,13 +23,13 @@ export const TRANSLATIONS = {
23
23
  "backToMethodList": "BACK TO PAYMENT METHODS",
24
24
  "deposit": {
25
25
  "makeTxnButton": "DEPOSIT",
26
- "confirmText": "You\'re going to deposit {amount} {currency} to your account",
27
- "confirmButton": "Ok",
26
+ "confirmText": "You're going to deposit {amount} {currency} to your account",
27
+ "confirmButton": "Ok"
28
28
  },
29
29
  "withdraw": {
30
30
  "makeTxnButton": "WITHDRAW",
31
- "confirmText": "You\'re going to withdraw {amount} {currency} from your account",
32
- "confirmButton": "Ok",
31
+ "confirmText": "You're going to withdraw {amount} {currency} from your account",
32
+ "confirmButton": "Ok"
33
33
  }
34
34
  }
35
- };
35
+ }