@salla.sa/twilight-components 1.0.95 → 1.0.97

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 (38) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-add-product-button_6.cjs.entry.js +10 -8
  3. package/dist/cjs/salla-installment.cjs.entry.js +0 -2
  4. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  5. package/dist/cjs/salla-verify-modal.cjs.entry.js +11 -7
  6. package/dist/cjs/twilight-components.cjs.js +1 -1
  7. package/dist/collection/components/salla-installment/salla-installment.js +0 -2
  8. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +1 -1
  9. package/dist/collection/components/salla-modal/salla-modal.js +5 -34
  10. package/dist/collection/components/salla-search/salla-search.js +6 -17
  11. package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
  12. package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +12 -7
  13. package/dist/components/salla-installment.js +0 -2
  14. package/dist/components/salla-localization-modal.js +1 -1
  15. package/dist/components/salla-modal2.js +5 -5
  16. package/dist/components/salla-search.js +6 -4
  17. package/dist/components/salla-tel-input2.js +1 -1
  18. package/dist/components/salla-verify-modal2.js +12 -7
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/salla-add-product-button_6.entry.js +10 -8
  21. package/dist/esm/salla-installment.entry.js +0 -2
  22. package/dist/esm/salla-localization-modal.entry.js +1 -1
  23. package/dist/esm/salla-verify-modal.entry.js +11 -7
  24. package/dist/esm/twilight-components.js +1 -1
  25. package/dist/twilight-components/p-6a736d5c.entry.js +4 -0
  26. package/dist/twilight-components/p-7fae6b84.entry.js +4 -0
  27. package/dist/twilight-components/p-8c69a096.entry.js +4 -0
  28. package/dist/twilight-components/p-9e05640e.entry.js +4 -0
  29. package/dist/twilight-components/twilight-components.esm.js +1 -1
  30. package/dist/types/components/salla-modal/salla-modal.d.ts +0 -3
  31. package/dist/types/components/salla-search/salla-search.d.ts +1 -0
  32. package/dist/types/components/salla-verify-modal/salla-verify-modal.d.ts +1 -0
  33. package/dist/types/components.d.ts +0 -2
  34. package/package.json +1 -1
  35. package/dist/twilight-components/p-04c4dadb.entry.js +0 -4
  36. package/dist/twilight-components/p-31afd49a.entry.js +0 -4
  37. package/dist/twilight-components/p-74df54ad.entry.js +0 -4
  38. package/dist/twilight-components/p-8264d586.entry.js +0 -4
@@ -17,7 +17,7 @@ const patchEsm = () => {
17
17
  const defineCustomElements = (win, options) => {
18
18
  if (typeof window === 'undefined') return Promise.resolve();
19
19
  return patchEsm().then(() => {
20
- return index.bootstrapLazy([["salla-add-product-button_6.cjs",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table.cjs",[[1,"salla-sizes-table"]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars.cjs",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
20
+ return index.bootstrapLazy([["salla-add-product-button_6.cjs",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table.cjs",[[1,"salla-sizes-table"]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars.cjs",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
21
21
  });
22
22
  };
23
23
 
@@ -200,8 +200,6 @@ const sallaModalCss = "";
200
200
  const SallaModal = class {
201
201
  constructor(hostRef) {
202
202
  index.registerInstance(this, hostRef);
203
- this.modalOpened = index.createEvent(this, "modalOpened", 7);
204
- this.modalClosed = index.createEvent(this, "modalClosed", 7);
205
203
  this.isClosable = true; //todo::rename unclude
206
204
  /**
207
205
  * The size of the modal
@@ -235,16 +233,18 @@ const SallaModal = class {
235
233
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.open());
236
234
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.close());
237
235
  this.modalTitle = this.host.getAttribute('modal-title');
236
+ // close modal on Escape button clicked
237
+ Helper.Helper.onKeyUp(document.body, e => e.keyCode === 27 && this.closeModal());
238
238
  }
239
239
  handleVisible(newValue) {
240
240
  if (!newValue) {
241
+ salla.event.dispatch('modalClosed');
241
242
  this.toggleModal(false);
242
- this.modalClosed.emit();
243
243
  return;
244
244
  }
245
+ salla.event.dispatch('modalOpened');
245
246
  this.host.classList.remove('s-hidden');
246
247
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
247
- this.modalOpened.emit();
248
248
  }
249
249
  /**
250
250
  * Open the modal
@@ -474,12 +474,14 @@ const SallaSearch = class {
474
474
  this.placeholder = salla.lang.get('blocks.header.search_placeholder');
475
475
  this.noResultsText = salla.lang.get('common.elements.no_options');
476
476
  });
477
+ salla.event.on('modalOpened', () => this.onModalOpen());
478
+ salla.event.on('modalClosed', () => this.onModalClose());
477
479
  }
478
480
  onModalOpen() {
479
- this.modal.querySelector('.s-search-input').focus();
481
+ setTimeout(() => this.searchInput.focus(), 300);
480
482
  }
481
483
  onModalClose() {
482
- this.modal.querySelector('.s-search-input').value = '';
484
+ this.searchInput.value = '';
483
485
  this.results = undefined;
484
486
  this.afterSearching();
485
487
  this.container.classList.remove('s-search-no-results');
@@ -520,7 +522,7 @@ const SallaSearch = class {
520
522
  }
521
523
  render() {
522
524
  var _a;
523
- const searchContent = index.h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), index.h("span", { class: "s-search-icon-wrap" }, index.h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
525
+ const searchContent = index.h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' }, ref: input => this.searchInput = input }), index.h("span", { class: "s-search-icon-wrap" }, index.h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
524
526
  _a.data.map(item => index.h("a", { href: item.url, class: { "s-search-product": true, 's-search-product-not-available': !item.is_available }, innerHTML: this.productSlot
525
527
  .replace(/\{name\}/g, item.name)
526
528
  .replace(/\{price\}/g, salla.money(item.price))
@@ -1990,7 +1992,7 @@ const SallaTelInput = class {
1990
1992
  this.countryCodeInput.value = data.iso2.toUpperCase();
1991
1993
  });
1992
1994
  // on blur: validate
1993
- this.phoneInput.addEventListener('blur', () => this.isValid());
1995
+ // this.phoneInput.addEventListener('blur', () => this.isValid());
1994
1996
  // on keyup / change flag: reset
1995
1997
  this.phoneInput.addEventListener('input', e => {
1996
1998
  salla.helpers.inputDigitsOnly(e.target);
@@ -22,7 +22,6 @@ const SallaInstallment = class {
22
22
  this.currency = salla.config.get('user.currency_code');
23
23
  salla.onReady(() => {
24
24
  const installment = salla.config.get('store.settings.installments');
25
- console.log("🚀 ~ file: salla-installment.tsx ~ line 12 ~ SallaInstallment ~ salla.onReady ~ installment", installment);
26
25
  this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
27
26
  this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
28
27
  this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
@@ -77,7 +76,6 @@ const SallaInstallment = class {
77
76
  };
78
77
  var script = document.createElement('script');
79
78
  // script.setAttribute('src', 'https://store.test/themes/default/assets/js/price-widget-ar-salla.js');
80
- console.log("🚀 ~ file: salla-installment.tsx ~ line 106 ~ SallaInstallment ~ componentDidLoad ~ ;", salla.url.cdn('js/price-widget-ar-salla.js'));
81
79
  script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));
82
80
  document.head.appendChild(script);
83
81
  }
@@ -60,7 +60,7 @@ const SallaLocalizationModal = class {
60
60
  }
61
61
  async getCurrencies() {
62
62
  this.currency = this.currency || salla.config.get('user.currency_code');
63
- return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
63
+ return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = Object.values(data || {}));
64
64
  }
65
65
  onChangeCurrency(event) {
66
66
  this.currency = event.target.value;
@@ -23,6 +23,7 @@ const SallaVerifyModal = class {
23
23
  * should auto reloading the page after success verification
24
24
  */
25
25
  this.autoReload = true;
26
+ this.resendAfter = 30;
26
27
  /**
27
28
  * to use: `salla.api.auth.verify` or `salla.profile.verify`
28
29
  */
@@ -45,6 +46,10 @@ const SallaVerifyModal = class {
45
46
  this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + data.type);
46
47
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
47
48
  });
49
+ salla.event.on('modalClosed', () => {
50
+ this.resendAfter = 0;
51
+ this.timer.innerHTML = '30 : 00';
52
+ });
48
53
  }
49
54
  /**
50
55
  * Get current code
@@ -110,15 +115,15 @@ const SallaVerifyModal = class {
110
115
  }
111
116
  resendTimer() {
112
117
  Helper.Helper.showElement(this.resendMessage).hideElement(this.resend);
113
- let resendAfter = 30;
118
+ this.resendAfter = 30;
114
119
  let timerId = setInterval(() => {
115
- if (resendAfter === -1) {
116
- clearTimeout(timerId);
120
+ if (this.resendAfter <= 0) {
121
+ clearInterval(timerId);
117
122
  Helper.Helper.hideElement(this.resendMessage).showElement(this.resend);
118
123
  }
119
124
  else {
120
- this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
121
- resendAfter--;
125
+ this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
126
+ this.resendAfter--;
122
127
  }
123
128
  }, 1000);
124
129
  }
@@ -130,8 +135,7 @@ const SallaVerifyModal = class {
130
135
  this.otpInputs[0].focus();
131
136
  })
132
137
  .then(() => salla.api.auth.resend(this.data))
133
- .then(() => this.resendTimer())
134
- .catch(() => this.resendTimer());
138
+ .finally(() => this.resendTimer());
135
139
  }
136
140
  submit() {
137
141
  let data = Object.assign({ code: this.code.value }, this.data);
@@ -18,5 +18,5 @@ const patchBrowser = () => {
18
18
  };
19
19
 
20
20
  patchBrowser().then(options => {
21
- return index.bootstrapLazy([["salla-add-product-button_6.cjs",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table.cjs",[[1,"salla-sizes-table"]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars.cjs",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
21
+ return index.bootstrapLazy([["salla-add-product-button_6.cjs",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table.cjs",[[1,"salla-sizes-table"]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars.cjs",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
22
22
  });
@@ -14,7 +14,6 @@ export class SallaInstallment {
14
14
  this.currency = salla.config.get('user.currency_code');
15
15
  salla.onReady(() => {
16
16
  const installment = salla.config.get('store.settings.installments');
17
- console.log("🚀 ~ file: salla-installment.tsx ~ line 12 ~ SallaInstallment ~ salla.onReady ~ installment", installment);
18
17
  this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
19
18
  this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
20
19
  this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
@@ -74,7 +73,6 @@ export class SallaInstallment {
74
73
  };
75
74
  var script = document.createElement('script');
76
75
  // script.setAttribute('src', 'https://store.test/themes/default/assets/js/price-widget-ar-salla.js');
77
- console.log("🚀 ~ file: salla-installment.tsx ~ line 106 ~ SallaInstallment ~ componentDidLoad ~ ;", salla.url.cdn('js/price-widget-ar-salla.js'));
78
76
  script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));
79
77
  document.head.appendChild(script);
80
78
  }
@@ -58,7 +58,7 @@ export class SallaLocalizationModal {
58
58
  }
59
59
  async getCurrencies() {
60
60
  this.currency = this.currency || salla.config.get('user.currency_code');
61
- return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
61
+ return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = Object.values(data || {}));
62
62
  }
63
63
  onChangeCurrency(event) {
64
64
  this.currency = event.target.value;
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { Component, h, Prop, Host, Element, Event, Watch, Method, State } from '@stencil/core';
4
+ import { Component, h, Prop, Host, Element, Watch, Method, State } from '@stencil/core';
5
5
  import Helper from "../../Helpers/Helper";
6
6
  /**
7
7
  * @slot footer - The footer of modal
@@ -41,16 +41,18 @@ export class SallaModal {
41
41
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.open());
42
42
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.close());
43
43
  this.modalTitle = this.host.getAttribute('modal-title');
44
+ // close modal on Escape button clicked
45
+ Helper.onKeyUp(document.body, e => e.keyCode === 27 && this.closeModal());
44
46
  }
45
47
  handleVisible(newValue) {
46
48
  if (!newValue) {
49
+ salla.event.dispatch('modalClosed');
47
50
  this.toggleModal(false);
48
- this.modalClosed.emit();
49
51
  return;
50
52
  }
53
+ salla.event.dispatch('modalOpened');
51
54
  this.host.classList.remove('s-hidden');
52
55
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
53
- this.modalOpened.emit();
54
56
  }
55
57
  /**
56
58
  * Open the modal
@@ -364,37 +366,6 @@ export class SallaModal {
364
366
  static get states() { return {
365
367
  "modalTitle": {}
366
368
  }; }
367
- static get events() { return [{
368
- "method": "modalOpened",
369
- "name": "modalOpened",
370
- "bubbles": true,
371
- "cancelable": true,
372
- "composed": true,
373
- "docs": {
374
- "tags": [],
375
- "text": ""
376
- },
377
- "complexType": {
378
- "original": "any",
379
- "resolved": "any",
380
- "references": {}
381
- }
382
- }, {
383
- "method": "modalClosed",
384
- "name": "modalClosed",
385
- "bubbles": true,
386
- "cancelable": true,
387
- "composed": true,
388
- "docs": {
389
- "tags": [],
390
- "text": ""
391
- },
392
- "complexType": {
393
- "original": "any",
394
- "resolved": "any",
395
- "references": {}
396
- }
397
- }]; }
398
369
  static get methods() { return {
399
370
  "open": {
400
371
  "complexType": {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { Component, Prop, h, State, Element, Listen } from '@stencil/core';
4
+ import { Component, Prop, h, State, Element } from '@stencil/core';
5
5
  import Helper from "../../Helpers/Helper";
6
6
  /**
7
7
  * @slot product - Replaces products card in the results, has replaceable props `{name}`, `{price}`, `{regular_price}`, `{image}`.
@@ -20,12 +20,14 @@ export class SallaSearch {
20
20
  this.placeholder = salla.lang.get('blocks.header.search_placeholder');
21
21
  this.noResultsText = salla.lang.get('common.elements.no_options');
22
22
  });
23
+ salla.event.on('modalOpened', () => this.onModalOpen());
24
+ salla.event.on('modalClosed', () => this.onModalClose());
23
25
  }
24
26
  onModalOpen() {
25
- this.modal.querySelector('.s-search-input').focus();
27
+ setTimeout(() => this.searchInput.focus(), 300);
26
28
  }
27
29
  onModalClose() {
28
- this.modal.querySelector('.s-search-input').value = '';
30
+ this.searchInput.value = '';
29
31
  this.results = undefined;
30
32
  this.afterSearching();
31
33
  this.container.classList.remove('s-search-no-results');
@@ -67,7 +69,7 @@ export class SallaSearch {
67
69
  render() {
68
70
  var _a;
69
71
  const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} },
70
- h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }),
72
+ h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' }, ref: input => this.searchInput = input }),
71
73
  h("span", { class: "s-search-icon-wrap" },
72
74
  h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })),
73
75
  h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
@@ -157,17 +159,4 @@ export class SallaSearch {
157
159
  "noResultsText": {}
158
160
  }; }
159
161
  static get elementRef() { return "host"; }
160
- static get listeners() { return [{
161
- "name": "modalOpened",
162
- "method": "onModalOpen",
163
- "target": undefined,
164
- "capture": false,
165
- "passive": false
166
- }, {
167
- "name": "modalClosed",
168
- "method": "onModalClose",
169
- "target": undefined,
170
- "capture": false,
171
- "passive": false
172
- }]; }
173
162
  }
@@ -76,7 +76,7 @@ export class SallaTelInput {
76
76
  this.countryCodeInput.value = data.iso2.toUpperCase();
77
77
  });
78
78
  // on blur: validate
79
- this.phoneInput.addEventListener('blur', () => this.isValid());
79
+ // this.phoneInput.addEventListener('blur', () => this.isValid());
80
80
  // on keyup / change flag: reset
81
81
  this.phoneInput.addEventListener('input', e => {
82
82
  salla.helpers.inputDigitsOnly(e.target);
@@ -18,6 +18,7 @@ export class SallaVerifyModal {
18
18
  * should auto reloading the page after success verification
19
19
  */
20
20
  this.autoReload = true;
21
+ this.resendAfter = 30;
21
22
  /**
22
23
  * to use: `salla.api.auth.verify` or `salla.profile.verify`
23
24
  */
@@ -40,6 +41,10 @@ export class SallaVerifyModal {
40
41
  this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + data.type);
41
42
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
42
43
  });
44
+ salla.event.on('modalClosed', () => {
45
+ this.resendAfter = 0;
46
+ this.timer.innerHTML = '30 : 00';
47
+ });
43
48
  }
44
49
  /**
45
50
  * Get current code
@@ -105,15 +110,15 @@ export class SallaVerifyModal {
105
110
  }
106
111
  resendTimer() {
107
112
  Helper.showElement(this.resendMessage).hideElement(this.resend);
108
- let resendAfter = 30;
113
+ this.resendAfter = 30;
109
114
  let timerId = setInterval(() => {
110
- if (resendAfter === -1) {
111
- clearTimeout(timerId);
115
+ if (this.resendAfter <= 0) {
116
+ clearInterval(timerId);
112
117
  Helper.hideElement(this.resendMessage).showElement(this.resend);
113
118
  }
114
119
  else {
115
- this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
116
- resendAfter--;
120
+ this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
121
+ this.resendAfter--;
117
122
  }
118
123
  }, 1000);
119
124
  }
@@ -125,8 +130,7 @@ export class SallaVerifyModal {
125
130
  this.otpInputs[0].focus();
126
131
  })
127
132
  .then(() => salla.api.auth.resend(this.data))
128
- .then(() => this.resendTimer())
129
- .catch(() => this.resendTimer());
133
+ .finally(() => this.resendTimer());
130
134
  }
131
135
  submit() {
132
136
  let data = Object.assign({ code: this.code.value }, this.data);
@@ -220,6 +224,7 @@ export class SallaVerifyModal {
220
224
  }; }
221
225
  static get states() { return {
222
226
  "title": {},
227
+ "resendAfter": {},
223
228
  "isProfileVerify": {}
224
229
  }; }
225
230
  static get events() { return [{
@@ -19,7 +19,6 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
19
19
  this.currency = salla.config.get('user.currency_code');
20
20
  salla.onReady(() => {
21
21
  const installment = salla.config.get('store.settings.installments');
22
- console.log("🚀 ~ file: salla-installment.tsx ~ line 12 ~ SallaInstallment ~ salla.onReady ~ installment", installment);
23
22
  this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
24
23
  this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
25
24
  this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
@@ -74,7 +73,6 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
74
73
  };
75
74
  var script = document.createElement('script');
76
75
  // script.setAttribute('src', 'https://store.test/themes/default/assets/js/price-widget-ar-salla.js');
77
- console.log("🚀 ~ file: salla-installment.tsx ~ line 106 ~ SallaInstallment ~ componentDidLoad ~ ;", salla.url.cdn('js/price-widget-ar-salla.js'));
78
76
  script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));
79
77
  document.head.appendChild(script);
80
78
  }
@@ -59,7 +59,7 @@ const SallaLocalizationModal$1 = /*@__PURE__*/ proxyCustomElement(class extends
59
59
  }
60
60
  async getCurrencies() {
61
61
  this.currency = this.currency || salla.config.get('user.currency_code');
62
- return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
62
+ return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = Object.values(data || {}));
63
63
  }
64
64
  onChangeCurrency(event) {
65
65
  this.currency = event.target.value;
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
4
+ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5
5
  import { H as Helper } from './Helper.js';
6
6
 
7
7
  const sallaModalCss = "";
@@ -10,8 +10,6 @@ const SallaModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
10
10
  constructor() {
11
11
  super();
12
12
  this.__registerHost();
13
- this.modalOpened = createEvent(this, "modalOpened", 7);
14
- this.modalClosed = createEvent(this, "modalClosed", 7);
15
13
  this.isClosable = true; //todo::rename unclude
16
14
  /**
17
15
  * The size of the modal
@@ -45,16 +43,18 @@ const SallaModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
45
43
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.open());
46
44
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.close());
47
45
  this.modalTitle = this.host.getAttribute('modal-title');
46
+ // close modal on Escape button clicked
47
+ Helper.onKeyUp(document.body, e => e.keyCode === 27 && this.closeModal());
48
48
  }
49
49
  handleVisible(newValue) {
50
50
  if (!newValue) {
51
+ salla.event.dispatch('modalClosed');
51
52
  this.toggleModal(false);
52
- this.modalClosed.emit();
53
53
  return;
54
54
  }
55
+ salla.event.dispatch('modalOpened');
55
56
  this.host.classList.remove('s-hidden');
56
57
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
57
- this.modalOpened.emit();
58
58
  }
59
59
  /**
60
60
  * Open the modal
@@ -23,12 +23,14 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
23
23
  this.placeholder = salla.lang.get('blocks.header.search_placeholder');
24
24
  this.noResultsText = salla.lang.get('common.elements.no_options');
25
25
  });
26
+ salla.event.on('modalOpened', () => this.onModalOpen());
27
+ salla.event.on('modalClosed', () => this.onModalClose());
26
28
  }
27
29
  onModalOpen() {
28
- this.modal.querySelector('.s-search-input').focus();
30
+ setTimeout(() => this.searchInput.focus(), 300);
29
31
  }
30
32
  onModalClose() {
31
- this.modal.querySelector('.s-search-input').value = '';
33
+ this.searchInput.value = '';
32
34
  this.results = undefined;
33
35
  this.afterSearching();
34
36
  this.container.classList.remove('s-search-no-results');
@@ -69,7 +71,7 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
69
71
  }
70
72
  render() {
71
73
  var _a;
72
- const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), h("span", { class: "s-search-icon-wrap" }, h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
74
+ const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' }, ref: input => this.searchInput = input }), h("span", { class: "s-search-icon-wrap" }, h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
73
75
  _a.data.map(item => h("a", { href: item.url, class: { "s-search-product": true, 's-search-product-not-available': !item.is_available }, innerHTML: this.productSlot
74
76
  .replace(/\{name\}/g, item.name)
75
77
  .replace(/\{price\}/g, salla.money(item.price))
@@ -95,7 +97,7 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
95
97
  "results": [32],
96
98
  "placeholder": [32],
97
99
  "noResultsText": [32]
98
- }, [[0, "modalOpened", "onModalOpen"], [0, "modalClosed", "onModalClose"]]]);
100
+ }]);
99
101
  function defineCustomElement$1() {
100
102
  if (typeof customElements === "undefined") {
101
103
  return;
@@ -1454,7 +1454,7 @@ const SallaTelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
1454
1454
  this.countryCodeInput.value = data.iso2.toUpperCase();
1455
1455
  });
1456
1456
  // on blur: validate
1457
- this.phoneInput.addEventListener('blur', () => this.isValid());
1457
+ // this.phoneInput.addEventListener('blur', () => this.isValid());
1458
1458
  // on keyup / change flag: reset
1459
1459
  this.phoneInput.addEventListener('input', e => {
1460
1460
  salla.helpers.inputDigitsOnly(e.target);
@@ -22,6 +22,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
22
22
  * should auto reloading the page after success verification
23
23
  */
24
24
  this.autoReload = true;
25
+ this.resendAfter = 30;
25
26
  /**
26
27
  * to use: `salla.api.auth.verify` or `salla.profile.verify`
27
28
  */
@@ -44,6 +45,10 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
44
45
  this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + data.type);
45
46
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
46
47
  });
48
+ salla.event.on('modalClosed', () => {
49
+ this.resendAfter = 0;
50
+ this.timer.innerHTML = '30 : 00';
51
+ });
47
52
  }
48
53
  /**
49
54
  * Get current code
@@ -109,15 +114,15 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
109
114
  }
110
115
  resendTimer() {
111
116
  Helper.showElement(this.resendMessage).hideElement(this.resend);
112
- let resendAfter = 30;
117
+ this.resendAfter = 30;
113
118
  let timerId = setInterval(() => {
114
- if (resendAfter === -1) {
115
- clearTimeout(timerId);
119
+ if (this.resendAfter <= 0) {
120
+ clearInterval(timerId);
116
121
  Helper.hideElement(this.resendMessage).showElement(this.resend);
117
122
  }
118
123
  else {
119
- this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
120
- resendAfter--;
124
+ this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
125
+ this.resendAfter--;
121
126
  }
122
127
  }, 1000);
123
128
  }
@@ -129,8 +134,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
129
134
  this.otpInputs[0].focus();
130
135
  })
131
136
  .then(() => salla.api.auth.resend(this.data))
132
- .then(() => this.resendTimer())
133
- .catch(() => this.resendTimer());
137
+ .finally(() => this.resendTimer());
134
138
  }
135
139
  submit() {
136
140
  let data = Object.assign({ code: this.code.value }, this.data);
@@ -157,6 +161,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
157
161
  "type": [1025],
158
162
  "autoReload": [4, "auto-reload"],
159
163
  "title": [32],
164
+ "resendAfter": [32],
160
165
  "isProfileVerify": [32],
161
166
  "getCode": [64],
162
167
  "open": [64]
@@ -13,7 +13,7 @@ const patchEsm = () => {
13
13
  const defineCustomElements = (win, options) => {
14
14
  if (typeof window === 'undefined') return Promise.resolve();
15
15
  return patchEsm().then(() => {
16
- return bootstrapLazy([["salla-add-product-button_6",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table",[[1,"salla-sizes-table"]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
16
+ return bootstrapLazy([["salla-add-product-button_6",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table",[[1,"salla-sizes-table"]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
17
17
  });
18
18
  };
19
19