@salla.sa/twilight-components 1.0.56 → 1.0.57

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 (44) hide show
  1. package/dist/cjs/index.cjs.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  4. package/dist/cjs/{salla-login-modal-d0fb6180.js → salla-login-modal-02e4e65e.js} +5 -5
  5. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  6. package/dist/cjs/salla-modal_2.cjs.entry.js +5 -5
  7. package/dist/cjs/salla-offer-modal.cjs.entry.js +8 -3
  8. package/dist/cjs/salla-rating-modal.cjs.entry.js +8 -8
  9. package/dist/cjs/{salla-search-f76c6d61.js → salla-search-9d17eb96.js} +3 -3
  10. package/dist/cjs/twilight-components.cjs.js +1 -1
  11. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +1 -1
  12. package/dist/collection/components/salla-login-modal/salla-login-modal.js +5 -5
  13. package/dist/collection/components/salla-modal/salla-modal.css +1 -4
  14. package/dist/collection/components/salla-modal/salla-modal.js +3 -3
  15. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +11 -4
  16. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +8 -8
  17. package/dist/collection/components/salla-search/salla-search.js +3 -3
  18. package/dist/esm/index.js +2 -2
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  21. package/dist/esm/{salla-login-modal-63f03766.js → salla-login-modal-7ad386c8.js} +5 -5
  22. package/dist/esm/salla-login-modal.entry.js +1 -1
  23. package/dist/esm/salla-modal_2.entry.js +5 -5
  24. package/dist/esm/salla-offer-modal.entry.js +8 -3
  25. package/dist/esm/salla-rating-modal.entry.js +8 -8
  26. package/dist/esm/{salla-search-7521be0c.js → salla-search-ce45eb5b.js} +3 -3
  27. package/dist/esm/twilight-components.js +1 -1
  28. package/dist/twilight-components/index.esm.js +1 -1
  29. package/dist/twilight-components/p-1514ed09.js +1 -0
  30. package/dist/twilight-components/p-64977eab.entry.js +1 -0
  31. package/dist/twilight-components/p-7c4ba872.entry.js +1 -0
  32. package/dist/twilight-components/p-84936d9d.entry.js +1 -0
  33. package/dist/twilight-components/{p-e306c6bb.entry.js → p-884a80ca.entry.js} +1 -1
  34. package/dist/twilight-components/p-ebd63ad4.js +1 -0
  35. package/dist/twilight-components/p-ee9d8563.entry.js +1 -0
  36. package/dist/twilight-components/twilight-components.esm.js +1 -1
  37. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +2 -0
  38. package/package.json +1 -1
  39. package/dist/twilight-components/p-05574321.entry.js +0 -1
  40. package/dist/twilight-components/p-134fa158.entry.js +0 -1
  41. package/dist/twilight-components/p-85427280.entry.js +0 -1
  42. package/dist/twilight-components/p-88dce1e4.js +0 -1
  43. package/dist/twilight-components/p-a26e2e12.entry.js +0 -1
  44. package/dist/twilight-components/p-e4f716b0.js +0 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLoginModal = require('./salla-login-modal-d0fb6180.js');
6
- const sallaSearch = require('./salla-search-f76c6d61.js');
5
+ const sallaLoginModal = require('./salla-login-modal-02e4e65e.js');
6
+ const sallaSearch = require('./salla-search-9d17eb96.js');
7
7
  require('./index-0b5b5867.js');
8
8
  require('./Helper-98cc9f18.js');
9
9
 
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
17
+ return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -46,7 +46,7 @@ const SallaInfiniteScroll = class {
46
46
  }
47
47
  loading(isLoading = true) {
48
48
  let btnText = this.status.querySelector('.s-button-text');
49
- Helper.Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
49
+ Helper.Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);
50
50
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
51
51
  }
52
52
  componentWillLoad() {
@@ -65,7 +65,7 @@ const SallaLoginModal = class {
65
65
  .then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
66
66
  .then(() => this.emailBtn.stop() && this.emailBtn.enable())
67
67
  .then(() => this.showTab(this.verifyTab))
68
- .then(() => this.verifyTab.by = 'email')
68
+ .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
69
69
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
70
70
  };
71
71
  this.newUser = async () => {
@@ -159,8 +159,8 @@ const SallaLoginModal = class {
159
159
  var _a, _b;
160
160
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
161
161
  let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
162
- tabs.map(el => Helper.Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
163
- setTimeout(() => tabs.map(el => Helper.Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
162
+ tabs.map(el => Helper.Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
163
+ setTimeout(() => tabs.map(el => Helper.Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
164
164
  setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
165
165
  if ([this.mobileTab, this.emailTab].includes(tab)) {
166
166
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
@@ -169,8 +169,8 @@ const SallaLoginModal = class {
169
169
  isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
170
170
  (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
171
171
  if (!isRegistrationTab) {
172
- Helper.Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
173
- .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
172
+ Helper.Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
173
+ .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
174
174
  }
175
175
  return this;
176
176
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLoginModal = require('./salla-login-modal-d0fb6180.js');
5
+ const sallaLoginModal = require('./salla-login-modal-02e4e65e.js');
6
6
  require('./index-0b5b5867.js');
7
7
  require('./Helper-98cc9f18.js');
8
8
 
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0b5b5867.js');
6
6
  const Helper = require('./Helper-98cc9f18.js');
7
- const sallaSearch = require('./salla-search-f76c6d61.js');
7
+ const sallaSearch = require('./salla-search-9d17eb96.js');
8
8
 
9
- const sallaModalCss = ".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";
9
+ const sallaModalCss = "";
10
10
 
11
11
  const SallaModal = class {
12
12
  constructor(hostRef) {
@@ -96,10 +96,10 @@ const SallaModal = class {
96
96
  }
97
97
  toggleModal(isOpen) {
98
98
  const body = this.host.querySelector('.s-modal-body');
99
- Helper.Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
100
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
99
+ Helper.Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
100
+ .toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
101
101
  //todo:: use united class names
102
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
102
+ .toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
103
103
  if (!isOpen) {
104
104
  setTimeout(() => this.host.classList.add('s-hidden'), 350);
105
105
  }
@@ -14,10 +14,14 @@ const SallaOfferModal = class {
14
14
  this.offer = null;
15
15
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
16
16
  this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
17
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
18
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
17
19
  Helper.Helper.setHost(this.host);
18
20
  salla.event.on('languages::translations.loaded', () => {
19
21
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
20
22
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
23
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
24
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
21
25
  });
22
26
  this.categorySlot = ((_a = Helper.Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
23
27
  this.productSlot = ((_b = Helper.Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
@@ -46,6 +50,7 @@ const SallaOfferModal = class {
46
50
  this.offer = offer;
47
51
  this.offer_name = offer.name;
48
52
  this.offer_message = offer.message;
53
+ this.modal.setTitle(this.offer_name);
49
54
  return this.modal.show();
50
55
  }
51
56
  rememberMe(event) {
@@ -67,18 +72,18 @@ const SallaOfferModal = class {
67
72
  }
68
73
  render() {
69
74
  var _a, _b;
70
- return index.h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
75
+ return index.h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
71
76
  ? [index.h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, index.h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
72
77
  ? this.offer.get.categories.map(category => index.h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
73
78
  .replace(/\{name\}/g, category.name)
74
79
  .replace(/\{url\}/g, category.urls.customer) }))
75
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: "s-offer-modal-product s-offer-modal-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
80
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: { "s-offer-modal-product": true, "s-offer-modal-slider-item": true, "s-offer-modal-not-available": !product.is_available }, id: 'product_' + product.id, innerHTML: this.productSlot
76
81
  .replace(/\{name\}/g, product.name)
77
82
  .replace(/\{url\}/g, product.url)
78
83
  .replace(/\{image\}/g, product.thumbnail)
79
84
  .replace(/\{price\}/g, product.has_special_price
80
85
  ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
81
- : salla.money(product.price)) }, index.h("div", { class: "s-offer-modal-btn-wrap" }, index.h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))), index.h("div", { class: "s-offer-modal-slider-nav" }, index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
86
+ : salla.money(product.price)) }, index.h("div", { class: "s-offer-modal-btn-wrap" }, index.h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))), index.h("div", { class: "s-offer-modal-slider-nav" }, index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
82
87
  index.h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.expiry_date ?
83
88
  index.h("p", { class: "s-offer-modal-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
84
89
  : '', index.h("label", { class: "s-offer-modal-remember-label" }, index.h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", this.remember_my_choice)),
@@ -74,7 +74,7 @@ const SallaRatingModal = class {
74
74
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
75
75
  event.target
76
76
  .querySelectorAll('.s-rating-modal-btn-star')
77
- .forEach((star, index) => Helper.Helper.toggleElement(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
77
+ .forEach((star, index) => Helper.Helper.toggleElementClassIf(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
78
78
  // Remove aria-pressed from any previously selected star
79
79
  event.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
80
80
  // Add aria-pressed role to the selected button
@@ -90,12 +90,12 @@ const SallaRatingModal = class {
90
90
  showActiveStep(current = null) {
91
91
  var _a;
92
92
  this.currentTab = current || this.steps[this.currentIndex];
93
- Helper.Helper.toggle('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
94
- .toggle('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
93
+ Helper.Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
94
+ .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
95
95
  if (this.currentIndex != 0) {
96
96
  // the animation
97
- Helper.Helper.toggleElement(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
98
- setTimeout(() => Helper.Helper.toggleElement(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
97
+ Helper.Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
98
+ setTimeout(() => Helper.Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
99
99
  }
100
100
  // Btn text
101
101
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
@@ -127,7 +127,7 @@ const SallaRatingModal = class {
127
127
  }
128
128
  previousTab() {
129
129
  this.currentIndex > 0 && this.currentIndex--;
130
- Helper.Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
130
+ Helper.Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
131
131
  this.showActiveStep();
132
132
  }
133
133
  submit() {
@@ -138,7 +138,7 @@ const SallaRatingModal = class {
138
138
  .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
139
139
  .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
140
140
  .then(() => this.showActiveStep())
141
- .then(() => Helper.Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
141
+ .then(() => Helper.Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
142
142
  .finally(() => {
143
143
  this.nextBtn.stop();
144
144
  salla.config.canLeave = true;
@@ -163,7 +163,7 @@ const SallaRatingModal = class {
163
163
  return;
164
164
  }
165
165
  type = type || rating['dataset'].type;
166
- Helper.Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
166
+ Helper.Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
167
167
  throw validationMessage.innerHTML = stars
168
168
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
169
169
  : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
@@ -51,7 +51,7 @@ const SallaSearch = class {
51
51
  return;
52
52
  }
53
53
  //run loading spinner or stop it
54
- Helper.Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
54
+ Helper.Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
55
55
  salla.search.api.search(e.target.value)
56
56
  .then(response => this.results = response)
57
57
  .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
@@ -60,8 +60,8 @@ const SallaSearch = class {
60
60
  afterSearching(isEmpty = true) {
61
61
  var _a;
62
62
  this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
63
- Helper.Helper.toggleElement(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
64
- .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
63
+ Helper.Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
64
+ .toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
65
65
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
66
66
  this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
67
67
  }
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
18
+ return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
19
19
  });
@@ -40,7 +40,7 @@ export class SallaInfiniteScroll {
40
40
  }
41
41
  loading(isLoading = true) {
42
42
  let btnText = this.status.querySelector('.s-button-text');
43
- Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
43
+ Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);
44
44
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
45
45
  }
46
46
  componentWillLoad() {
@@ -70,7 +70,7 @@ export class SallaLoginModal {
70
70
  .then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
71
71
  .then(() => this.emailBtn.stop() && this.emailBtn.enable())
72
72
  .then(() => this.showTab(this.verifyTab))
73
- .then(() => this.verifyTab.by = 'email')
73
+ .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
74
74
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
75
75
  };
76
76
  this.newUser = async () => {
@@ -164,8 +164,8 @@ export class SallaLoginModal {
164
164
  var _a, _b;
165
165
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
166
166
  let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
167
- tabs.map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
168
- setTimeout(() => tabs.map(el => Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
167
+ tabs.map(el => Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
168
+ setTimeout(() => tabs.map(el => Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
169
169
  setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
170
170
  if ([this.mobileTab, this.emailTab].includes(tab)) {
171
171
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
@@ -174,8 +174,8 @@ export class SallaLoginModal {
174
174
  isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
175
175
  (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
176
176
  if (!isRegistrationTab) {
177
- Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
178
- .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
177
+ Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
178
+ .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
179
179
  }
180
180
  return this;
181
181
  }
@@ -10,7 +10,4 @@
10
10
  /*
11
11
  * Salla Modal Component: popup modal used in most parts of the theme
12
12
  * You can use these classes to target the elements in the component.
13
- */
14
- .salla-modal .s-modal-wrapper {
15
- height: calc(var(--vh, 1vh) * 100);
16
- }
13
+ */
@@ -88,10 +88,10 @@ export class SallaModal {
88
88
  }
89
89
  toggleModal(isOpen) {
90
90
  const body = this.host.querySelector('.s-modal-body');
91
- Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
92
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
91
+ Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
92
+ .toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
93
93
  //todo:: use united class names
94
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
94
+ .toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
95
95
  if (!isOpen) {
96
96
  setTimeout(() => this.host.classList.add('s-hidden'), 350);
97
97
  }
@@ -11,10 +11,14 @@ export class SallaOfferModal {
11
11
  this.offer = null;
12
12
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
13
13
  this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
14
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
15
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
14
16
  Helper.setHost(this.host);
15
17
  salla.event.on('languages::translations.loaded', () => {
16
18
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
17
19
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
20
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
21
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
18
22
  });
19
23
  this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
20
24
  this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
@@ -43,6 +47,7 @@ export class SallaOfferModal {
43
47
  this.offer = offer;
44
48
  this.offer_name = offer.name;
45
49
  this.offer_message = offer.message;
50
+ this.modal.setTitle(this.offer_name);
46
51
  return this.modal.show();
47
52
  }
48
53
  rememberMe(event) {
@@ -64,13 +69,13 @@ export class SallaOfferModal {
64
69
  }
65
70
  render() {
66
71
  var _a, _b;
67
- return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
72
+ return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
68
73
  ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
69
74
  h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
70
75
  ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
71
76
  .replace(/\{name\}/g, category.name)
72
77
  .replace(/\{url\}/g, category.urls.customer) }))
73
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-modal-product s-offer-modal-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
78
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: { "s-offer-modal-product": true, "s-offer-modal-slider-item": true, "s-offer-modal-not-available": !product.is_available }, id: 'product_' + product.id, innerHTML: this.productSlot
74
79
  .replace(/\{name\}/g, product.name)
75
80
  .replace(/\{url\}/g, product.url)
76
81
  .replace(/\{image\}/g, product.thumbnail)
@@ -78,7 +83,7 @@ export class SallaOfferModal {
78
83
  ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
79
84
  : salla.money(product.price)) },
80
85
  h("div", { class: "s-offer-modal-btn-wrap" },
81
- h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))),
86
+ h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))),
82
87
  h("div", { class: "s-offer-modal-slider-nav" },
83
88
  h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" },
84
89
  h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })),
@@ -155,7 +160,9 @@ export class SallaOfferModal {
155
160
  "offer_name": {},
156
161
  "offer_message": {},
157
162
  "offer_expires_in": {},
158
- "remember_my_choice": {}
163
+ "remember_my_choice": {},
164
+ "add_to_cart": {},
165
+ "out_of_stock": {}
159
166
  }; }
160
167
  static get methods() { return {
161
168
  "show": {
@@ -66,7 +66,7 @@ export class SallaRatingModal {
66
66
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
67
67
  event.target
68
68
  .querySelectorAll('.s-rating-modal-btn-star')
69
- .forEach((star, index) => Helper.toggleElement(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
69
+ .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
70
70
  // Remove aria-pressed from any previously selected star
71
71
  event.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
72
72
  // Add aria-pressed role to the selected button
@@ -82,12 +82,12 @@ export class SallaRatingModal {
82
82
  showActiveStep(current = null) {
83
83
  var _a;
84
84
  this.currentTab = current || this.steps[this.currentIndex];
85
- Helper.toggle('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
86
- .toggle('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
85
+ Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
86
+ .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
87
87
  if (this.currentIndex != 0) {
88
88
  // the animation
89
- Helper.toggleElement(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
90
- setTimeout(() => Helper.toggleElement(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
89
+ Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
90
+ setTimeout(() => Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
91
91
  }
92
92
  // Btn text
93
93
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
@@ -119,7 +119,7 @@ export class SallaRatingModal {
119
119
  }
120
120
  previousTab() {
121
121
  this.currentIndex > 0 && this.currentIndex--;
122
- Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
122
+ Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
123
123
  this.showActiveStep();
124
124
  }
125
125
  submit() {
@@ -130,7 +130,7 @@ export class SallaRatingModal {
130
130
  .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
131
131
  .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
132
132
  .then(() => this.showActiveStep())
133
- .then(() => Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
133
+ .then(() => Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
134
134
  .finally(() => {
135
135
  this.nextBtn.stop();
136
136
  salla.config.canLeave = true;
@@ -155,7 +155,7 @@ export class SallaRatingModal {
155
155
  return;
156
156
  }
157
157
  type = type || rating['dataset'].type;
158
- Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
158
+ Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
159
159
  throw validationMessage.innerHTML = stars
160
160
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
161
161
  : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
@@ -48,7 +48,7 @@ export class SallaSearch {
48
48
  return;
49
49
  }
50
50
  //run loading spinner or stop it
51
- Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
51
+ Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
52
52
  salla.search.api.search(e.target.value)
53
53
  .then(response => this.results = response)
54
54
  .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
@@ -57,8 +57,8 @@ export class SallaSearch {
57
57
  afterSearching(isEmpty = true) {
58
58
  var _a;
59
59
  this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
60
- Helper.toggleElement(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
61
- .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
60
+ Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
61
+ .toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
62
62
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
63
63
  this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
64
64
  }
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { S as SallaLoginModal } from './salla-login-modal-63f03766.js';
2
- export { S as SallaSearch } from './salla-search-7521be0c.js';
1
+ export { S as SallaLoginModal } from './salla-login-modal-7ad386c8.js';
2
+ export { S as SallaSearch } from './salla-search-ce45eb5b.js';
3
3
  import './index-8b97d225.js';
4
4
  import './Helper-7162a06c.js';
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["salla-button",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
13
+ return bootstrapLazy([["salla-button",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -42,7 +42,7 @@ const SallaInfiniteScroll = class {
42
42
  }
43
43
  loading(isLoading = true) {
44
44
  let btnText = this.status.querySelector('.s-button-text');
45
- Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
45
+ Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);
46
46
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
47
47
  }
48
48
  componentWillLoad() {
@@ -63,7 +63,7 @@ const SallaLoginModal = class {
63
63
  .then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
64
64
  .then(() => this.emailBtn.stop() && this.emailBtn.enable())
65
65
  .then(() => this.showTab(this.verifyTab))
66
- .then(() => this.verifyTab.by = 'email')
66
+ .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
67
67
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
68
68
  };
69
69
  this.newUser = async () => {
@@ -157,8 +157,8 @@ const SallaLoginModal = class {
157
157
  var _a, _b;
158
158
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
159
159
  let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
160
- tabs.map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
161
- setTimeout(() => tabs.map(el => Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
160
+ tabs.map(el => Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
161
+ setTimeout(() => tabs.map(el => Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
162
162
  setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
163
163
  if ([this.mobileTab, this.emailTab].includes(tab)) {
164
164
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
@@ -167,8 +167,8 @@ const SallaLoginModal = class {
167
167
  isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
168
168
  (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
169
169
  if (!isRegistrationTab) {
170
- Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
171
- .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
170
+ Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
171
+ .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
172
172
  }
173
173
  return this;
174
174
  }
@@ -1,3 +1,3 @@
1
- export { S as salla_login_modal } from './salla-login-modal-63f03766.js';
1
+ export { S as salla_login_modal } from './salla-login-modal-7ad386c8.js';
2
2
  import './index-8b97d225.js';
3
3
  import './Helper-7162a06c.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-7162a06c.js';
3
- export { S as salla_search } from './salla-search-7521be0c.js';
3
+ export { S as salla_search } from './salla-search-ce45eb5b.js';
4
4
 
5
- const sallaModalCss = ".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";
5
+ const sallaModalCss = "";
6
6
 
7
7
  const SallaModal = class {
8
8
  constructor(hostRef) {
@@ -92,10 +92,10 @@ const SallaModal = class {
92
92
  }
93
93
  toggleModal(isOpen) {
94
94
  const body = this.host.querySelector('.s-modal-body');
95
- Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
96
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
95
+ Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
96
+ .toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
97
97
  //todo:: use united class names
98
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
98
+ .toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
99
99
  if (!isOpen) {
100
100
  setTimeout(() => this.host.classList.add('s-hidden'), 350);
101
101
  }
@@ -10,10 +10,14 @@ const SallaOfferModal = class {
10
10
  this.offer = null;
11
11
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
12
12
  this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
13
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
14
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
13
15
  Helper.setHost(this.host);
14
16
  salla.event.on('languages::translations.loaded', () => {
15
17
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
16
18
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
19
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
20
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
17
21
  });
18
22
  this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
19
23
  this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
@@ -42,6 +46,7 @@ const SallaOfferModal = class {
42
46
  this.offer = offer;
43
47
  this.offer_name = offer.name;
44
48
  this.offer_message = offer.message;
49
+ this.modal.setTitle(this.offer_name);
45
50
  return this.modal.show();
46
51
  }
47
52
  rememberMe(event) {
@@ -63,18 +68,18 @@ const SallaOfferModal = class {
63
68
  }
64
69
  render() {
65
70
  var _a, _b;
66
- return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
71
+ return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
67
72
  ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
68
73
  ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
69
74
  .replace(/\{name\}/g, category.name)
70
75
  .replace(/\{url\}/g, category.urls.customer) }))
71
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-modal-product s-offer-modal-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
76
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: { "s-offer-modal-product": true, "s-offer-modal-slider-item": true, "s-offer-modal-not-available": !product.is_available }, id: 'product_' + product.id, innerHTML: this.productSlot
72
77
  .replace(/\{name\}/g, product.name)
73
78
  .replace(/\{url\}/g, product.url)
74
79
  .replace(/\{image\}/g, product.thumbnail)
75
80
  .replace(/\{price\}/g, product.has_special_price
76
81
  ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
77
- : salla.money(product.price)) }, h("div", { class: "s-offer-modal-btn-wrap" }, h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))), h("div", { class: "s-offer-modal-slider-nav" }, h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
82
+ : salla.money(product.price)) }, h("div", { class: "s-offer-modal-btn-wrap" }, h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))), h("div", { class: "s-offer-modal-slider-nav" }, h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
78
83
  h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.expiry_date ?
79
84
  h("p", { class: "s-offer-modal-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
80
85
  : '', h("label", { class: "s-offer-modal-remember-label" }, h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", this.remember_my_choice)),
@@ -70,7 +70,7 @@ const SallaRatingModal = class {
70
70
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
71
71
  event.target
72
72
  .querySelectorAll('.s-rating-modal-btn-star')
73
- .forEach((star, index) => Helper.toggleElement(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
73
+ .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
74
74
  // Remove aria-pressed from any previously selected star
75
75
  event.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
76
76
  // Add aria-pressed role to the selected button
@@ -86,12 +86,12 @@ const SallaRatingModal = class {
86
86
  showActiveStep(current = null) {
87
87
  var _a;
88
88
  this.currentTab = current || this.steps[this.currentIndex];
89
- Helper.toggle('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
90
- .toggle('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
89
+ Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
90
+ .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
91
91
  if (this.currentIndex != 0) {
92
92
  // the animation
93
- Helper.toggleElement(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
94
- setTimeout(() => Helper.toggleElement(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
93
+ Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
94
+ setTimeout(() => Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
95
95
  }
96
96
  // Btn text
97
97
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
@@ -123,7 +123,7 @@ const SallaRatingModal = class {
123
123
  }
124
124
  previousTab() {
125
125
  this.currentIndex > 0 && this.currentIndex--;
126
- Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
126
+ Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
127
127
  this.showActiveStep();
128
128
  }
129
129
  submit() {
@@ -134,7 +134,7 @@ const SallaRatingModal = class {
134
134
  .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
135
135
  .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
136
136
  .then(() => this.showActiveStep())
137
- .then(() => Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
137
+ .then(() => Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
138
138
  .finally(() => {
139
139
  this.nextBtn.stop();
140
140
  salla.config.canLeave = true;
@@ -159,7 +159,7 @@ const SallaRatingModal = class {
159
159
  return;
160
160
  }
161
161
  type = type || rating['dataset'].type;
162
- Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
162
+ Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
163
163
  throw validationMessage.innerHTML = stars
164
164
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
165
165
  : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
@@ -49,7 +49,7 @@ const SallaSearch = class {
49
49
  return;
50
50
  }
51
51
  //run loading spinner or stop it
52
- Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
52
+ Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
53
53
  salla.search.api.search(e.target.value)
54
54
  .then(response => this.results = response)
55
55
  .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
@@ -58,8 +58,8 @@ const SallaSearch = class {
58
58
  afterSearching(isEmpty = true) {
59
59
  var _a;
60
60
  this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
61
- Helper.toggleElement(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
62
- .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
61
+ Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
62
+ .toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
63
63
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
64
64
  this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
65
65
  }
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["salla-button",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
16
+ return bootstrapLazy([["salla-button",[[4,"salla-button",{"buttonType":[513,"button-type"],"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]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
17
17
  });
@@ -1 +1 @@
1
- export{S as SallaLoginModal}from"./p-88dce1e4.js";export{S as SallaSearch}from"./p-e4f716b0.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
1
+ export{S as SallaLoginModal}from"./p-ebd63ad4.js";export{S as SallaSearch}from"./p-1514ed09.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
@@ -0,0 +1 @@
1
+ import{r as s,h as a,g as e}from"./p-cb1c59a2.js";import{H as r}from"./p-ed1c00c5.js";const i=class{constructor(a){var e;s(this,a),this.inputValue="",this.inline=!1,this.oval=!1,this.height=60,r.setHost(this.host),this.productSlot=(null===(e=r.getElement('[slot="product"]'))||void 0===e?void 0:e.innerHTML)||this.getDefaultProductSlot(),salla.event.on("search::show",(()=>this.modal.show())),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching(),this.container.classList.remove("s-search-no-results")}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(this.inputValue=s.target.value,r.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(r.toggleElementClassIf(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s)).catch((s=>"Query Same As Previous!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var a;this.noResults.style.display=s||(null===(a=this.results)||void 0===a?void 0:a.data.length)>0?"none":"block",r.toggleElementClassIf(this.container,"s-search-container-open","s-search-no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElementClassIf(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery="",0==this.inputValue.length&&this.container.classList.remove("s-search-no-results")}render(){var s;const e=a("div",{class:{"s-search-container":!0,"s-search-inline":this.inline},ref:s=>this.container=s,style:this.oval?{borderRadius:this.height/2+"px"}:{}},a("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s),style:{height:this.height+"px"}}),a("span",{class:"s-search-icon-wrap"},a("i",{class:"s-search-icon sicon-search",ref:s=>this.searchIcon=s})),a("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>a("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price).replace(/\{image\}/g,s.image_url)}))),a("p",{ref:s=>this.noResults=s,class:"s-search-no-results-placeholder"},this.noResultsText)));return this.inline?a("div",{id:"s-search-modal"},e):a("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},e)}componentDidLoad(){this.afterSearching()}get host(){return e(this)}};i.style="#s-search-modal .s-search-inline{border:1px solid #eee}#s-search-modal .s-search-no-results .s-search-input,#s-search-modal .s-search-container-open .s-search-input{border-bottom:1px solid #f4f4f5}#s-search-modal .s-search-product-image[src=null]{opacity:0}#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem;background:transparent;overflow:visible}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";export{i as S}
@@ -0,0 +1 @@
1
+ import{r as s,c as i,h as t,H as a,g as l}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";export{S as salla_search}from"./p-1514ed09.js";const o=class{constructor(t){s(this,t),this.modalOpened=i(this,"modalOpened",7),this.modalClosed=i(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",e.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title")}handleVisible(s){if(!s)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.title=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(s){const i=this.host.querySelector(".s-modal-body");e.toggleElementClassIf(i,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElementClassIf(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElementClassIf(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",t(a,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},"​"),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?t("div",{class:"s-modal-loader-wrap"},t("span",{class:"s-modal-loader"})):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?t("div",{class:this.iconBlockClasses()},t("i",{class:this.iconClasses()})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return l(this)}static get watchers(){return{visible:["handleVisible"]}}};o.style="";export{o as salla_modal}
@@ -0,0 +1 @@
1
+ export{S as salla_login_modal}from"./p-ebd63ad4.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
@@ -0,0 +1 @@
1
+ import{r as s,h as a,g as o}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";const l=class{constructor(a){var o,l;s(this,a),this.offer=null,this.offer_expires_in=salla.lang.get("pages.products.offer_expires_in"),this.remember_my_choice=salla.lang.get("commone.remember_my_choice"),this.add_to_cart=salla.lang.get("pages.cart.add_to_cart"),this.out_of_stock=salla.lang.get("pages.products.out_of_stock"),e.setHost(this.host),salla.event.on("languages::translations.loaded",(()=>{this.offer_expires_in=salla.lang.get("pages.products.offer_expires_in"),this.remember_my_choice=salla.lang.get("common.remember_my_choice"),this.add_to_cart=salla.lang.get("pages.cart.add_to_cart"),this.out_of_stock=salla.lang.get("pages.products.out_of_stock")})),this.categorySlot=(null===(o=e.getElement('[slot="category"]'))||void 0===o?void 0:o.innerHTML)||'<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>',this.productSlot=(null===(l=e.getElement('[slot="product"]'))||void 0===l?void 0:l.innerHTML)||this.defaultProductSlot(),salla.offer.event.onExisted((s=>{salla.storage.get("remember-offer-"+s.id)?salla.log("User selected to don't show this offer again."):this.show(s.product_id)}))}async show(s){return salla.api.offer.details(s).then((s=>this.showOffer(s.data[0])))}async showOffer(s){return this.offer=s,this.offer_name=s.name,this.offer_message=s.message,this.modal.setTitle(this.offer_name),this.modal.show()}rememberMe(s){salla.storage.set("remember-offer-"+this.offer.id,s.target.checked)}addItem(){return this.load(),salla.cart.api.quickAdd(this.dataset.id).finally((()=>this.stop()))}defaultProductSlot(){return'<a href={url} class="s-offer-modal-product-image-wrap"><img class="s-offer-modal-product-image" src="{image}" /></a><div class="s-offer-modal-product-info"> <a href={url} class="s-offer-modal-product-name">{name}</a> <div class="s-offer-modal-product-price">{price}</div></div>'}render(){var s,o;return a("salla-modal",{id:"salla-offer-modal","sub-title-first":!0,icon:"sicon-special-discount","sub-title":this.offer_message,ref:s=>this.modal=s,"is-loading":null===this.offer},null!==this.offer?[a("div",{class:"s-offer-modal-scrolled-slider-wrap"},a("div",{class:"s-offer-modal-body s-offer-modal-scrolled-slider"},(null===(s=this.offer.get.categories)||void 0===s?void 0:s.length)>0?this.offer.get.categories.map((s=>a("a",{href:s.urls.customer,class:"s-offer-modal-badge s-offer-modal-slider-item",innerHTML:this.categorySlot.replace(/\{name\}/g,s.name).replace(/\{url\}/g,s.urls.customer)}))):null===(o=this.offer.get.products)||void 0===o?void 0:o.map((s=>a("div",{class:{"s-offer-modal-product":!0,"s-offer-modal-slider-item":!0,"s-offer-modal-not-available":!s.is_available},id:"product_"+s.id,innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{url\}/g,s.url).replace(/\{image\}/g,s.thumbnail).replace(/\{price\}/g,s.has_special_price?salla.money(s.price)+'<span class="s-offer-modal-product-old-price">'+salla.money(s.regular_price)+"</span>":salla.money(s.price))},a("div",{class:"s-offer-modal-btn-wrap"},a("salla-button",{width:"wide",fill:"outline","data-id":s.id,disabled:!s.is_available,"loader-position":"center",onClick:this.addItem},s.is_available?this.add_to_cart:this.out_of_stock)))))),a("div",{class:"s-offer-modal-slider-nav"},a("button",{class:"s-offer-modal-nav-btn s-offer-modal-prev-btn"},a("span",{class:"s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right"})),a("button",{class:"s-offer-modal-nav-btn s-offer-modal-next-btn"},a("span",{class:"s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left"})))),a("div",{class:"s-offer-modal-footer",slot:"footer"},this.offer.expiry_date?a("p",{class:"s-offer-modal-expiry"},this.offer_expires_in," ",this.offer.expiry_date):"",a("label",{class:"s-offer-modal-remember-label"},a("input",{type:"checkbox",onChange:s=>this.rememberMe(s),class:"s-offer-modal-remember-input"}),"  ",this.remember_my_choice))]:"")}componentDidRender(){if(this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden"))),this.offer&&window.screen.width>639){let s=this.host.querySelector(".s-offer-modal-scrolled-slider-wrap"),a=this.host.querySelector(".s-offer-modal-scrolled-slider"),o=this.host.querySelectorAll(".s-offer-modal-nav-btn"),e=this.host.querySelector(".s-offer-modal-next-btn"),l=this.host.querySelector(".s-offer-modal-prev-btn"),r=this.host.querySelectorAll(".s-offer-modal-slider-item"),t=20,i=0,d=3,f=r[0].offsetWidth,n=r.length*f,c=s.offsetWidth,m=n-c,h=!!document.body.classList.contains("rtl");m>t&&e.classList.add("s-offer-modal-btn-is-active"),window.onresize=function(){c=s.offsetWidth,m=n-c},a.addEventListener("scroll",(function(){let s=Math.abs(a.scrollLeft),o=m-t;s<=t?(e.classList.add("s-offer-modal-btn-is-active"),l.classList.remove("s-offer-modal-btn-is-active")):s<o?(e.classList.add("s-offer-modal-btn-is-active"),l.classList.add("s-offer-modal-btn-is-active")):s>=o&&(e.classList.remove("s-offer-modal-btn-is-active"),l.classList.add("s-offer-modal-btn-is-active"))})),o.forEach((s=>{s.addEventListener("click",(function(){s.classList.contains("s-offer-modal-next-btn")?i++:i--,a.scrollTo({top:0,left:f*d*i*(h?-1:1),behavior:"smooth"})}))}))}}get host(){return o(this)}};l.style="#salla-offer-modal .s-offer-modal-body{-webkit-overflow-scrolling:touch}#salla-offer-modal .s-offer-modal-body::-webkit-scrollbar{display:none}#salla-offer-modal .s-offer-modal-next-btn{background:linear-gradient(90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}#salla-offer-modal .s-offer-modal-prev-btn{background:linear-gradient(-90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}";export{l as salla_offer_modal}
@@ -1 +1 @@
1
- import{r as t,h as s,H as n,g as i}from"./p-cb1c59a2.js";import{H as l}from"./p-ed1c00c5.js";const e=class{constructor(s){t(this,s),this.nextPage="",this.nextPageAutoload=!1,this.container=".s-infinite-scroll-container",this.item=".list-block",l.setHost(this.host),this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn btn--has-loading s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.event.on("languages::translations.loaded",(()=>{this.status.querySelector(".s-button-text").innerHTML=salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(t=!0){let s=this.status.querySelector(".s-button-text");l.toggleElement(s,"s-button-hide","s-button-show",(()=>t)),this.btnLoader.style.display=t?"inherit":"none"}componentWillLoad(){var t;this.nextPageAutoload=["","true"].includes(null===(t=this.host.getAttribute("next-page.autoload"))||void 0===t?void 0:t.toLowerCase())}render(){return this.nextPage.length>1?s(n,{class:"s-infinite-scroll-container"},s("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let t=this,s=salla.infiniteScroll.initiate(this.container,{history:!!this.nextPageAutoload&&"push",scrollThreshold:!!this.nextPageAutoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return t.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==s.pageIndex&&s.option({loadOnScroll:!1}),3==s.pageIndex&&s.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return i(this)}};e.style="";export{e as salla_infinite_scroll}
1
+ import{r as t,h as s,H as n,g as i}from"./p-cb1c59a2.js";import{H as l}from"./p-ed1c00c5.js";const e=class{constructor(s){t(this,s),this.nextPage="",this.nextPageAutoload=!1,this.container=".s-infinite-scroll-container",this.item=".list-block",l.setHost(this.host),this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn btn--has-loading s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.event.on("languages::translations.loaded",(()=>{this.status.querySelector(".s-button-text").innerHTML=salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(t=!0){let s=this.status.querySelector(".s-button-text");l.toggleElementClassIf(s,"s-button-hide","s-button-show",(()=>t)),this.btnLoader.style.display=t?"inherit":"none"}componentWillLoad(){var t;this.nextPageAutoload=["","true"].includes(null===(t=this.host.getAttribute("next-page.autoload"))||void 0===t?void 0:t.toLowerCase())}render(){return this.nextPage.length>1?s(n,{class:"s-infinite-scroll-container"},s("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let t=this,s=salla.infiniteScroll.initiate(this.container,{history:!!this.nextPageAutoload&&"push",scrollThreshold:!!this.nextPageAutoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return t.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==s.pageIndex&&s.option({loadOnScroll:!1}),3==s.pageIndex&&s.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return i(this)}};e.style="";export{e as salla_infinite_scroll}
@@ -0,0 +1 @@
1
+ import{r as s,h as i,g as l}from"./p-cb1c59a2.js";import{H as t}from"./p-ed1c00c5.js";const a=class{constructor(i){s(this,i),this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!0),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!0),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!1),this.regType="phone",this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),this.typing=(s,i)=>{const l=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==l?void 0:l.classList.contains("s-login-modal-error-message"))&&(l.innerText=""),"Enter"==s.key&&i()},this.loginBySMS=async()=>{const{mobile:s,countryCode:i}=await this.loginTelInput.getValues();await this.loginTelInput.isValid()&&this.smsBtn.load().then((()=>this.smsBtn.disable())).then((()=>salla.auth.api.login({type:"mobile",phone:s,country_code:i}))).then((()=>this.smsBtn.stop()&&this.smsBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>(this.verifyTab.by="sms")&&(this.verifyTab.url="auth/mobile/verify"))).then((()=>this.verifyTab.show({phone:s,country_code:i})))},this.loginByEmail=()=>{t.isValidEmail(this.loginEmail.value)?this.emailBtn.load().then((()=>this.emailBtn.disable())).then((()=>salla.auth.api.login({type:"email",email:this.loginEmail.value}))).then((()=>this.emailBtn.stop()&&this.emailBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>(this.verifyTab.by="email")&&(this.verifyTab.url="auth/email/verify"))).then((()=>this.verifyTab.show({email:this.loginEmail.value}))):this.validateField(this.loginEmail,this.emailErrorMsg)},this.newUser=async()=>{var s;const{mobile:i,countryCode:l,countryKey:t}="email"==this.regType?await this.regTelInput.getValues():await this.loginTelInput.getValues(),a=this.regEmail.value||(null===(s=this.loginEmail)||void 0===s?void 0:s.value);await this.newUserValidation(),await this.regBtn.load(),await this.regBtn.disable();let e={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.mobile,country_code:l,country_key:t,verified_by:this.regType};a&&(e=Object.assign(Object.assign({},e),{email:a})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},e),{code:s})))).then((()=>window.location.reload())).catch((()=>this.regBtn.stop()&&this.regBtn.enable()))},this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.event.on("languages::translations.loaded",(()=>{var s,i,l,t;this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.smsBtn)||void 0===i||i.setText(salla.lang.get("blocks.header.enter")),null===(l=this.emailBtn)||void 0===l||l.setText(salla.lang.get("blocks.header.enter")),null===(t=this.regBtn)||void 0===t||t.setText(salla.lang.get("blocks.header.register"))})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show())),salla.event.on("twilight::initiated",(()=>{this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!!this.isEmailAllowed),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!!this.isMobileAllowed),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!!this.isEmailRequired)}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}async show(){return this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.show()}showTab(s,i){var l,a;null==i||i.preventDefault();let e=[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab];e.map((i=>t.toggleElementClassIf(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>e.map((i=>t.toggleElementClassIf(i,"s-login-modal-active","s-login-modal-unactive",(()=>i==s))))),200),setTimeout((()=>this.host.querySelector(".s-login-modal-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px"))),[this.mobileTab,this.emailTab].includes(s)&&(this.regType=s===this.mobileTab?"phone":"email");let o=s==this.registrationTab;return o&&(null===(l=this.firstName)||void 0===l||l.focus()),null===(a=this.modal)||void 0===a||a.setTitle(o?salla.lang.get("common.titles.registration"):this.title),o||t.toggleElementClassIf(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElementClassIf(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}async newUserValidation(){const s="phone"==this.regType,i=this.regEmail.value||"email"==this.regType&&this.loginEmail.value,l=t.isValidEmail(i),a=this.firstName.value.length>0,e=this.lastName.value.length>0,o=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&l||!i&&!this.isEmailRequired)&&o&&a&&e))throw!l&&this.validateField(this.regEmail,this.emailErrorMsg),!a&&this.validateField(this.firstName,this.firstNameErrorMsg),!e&&this.validateField(this.lastName,this.lastNameErrorMsg),"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i("salla-modal",{id:"salla-login",icon:"sicon-user",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-modal-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-modal-sub-title"},this.loginTypeTitle),i("slot",{name:"before-login-type"}),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-phone"}),i("span",{class:"s-login-modal-main-btn-text"},this.smsLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-mail"}),i("span",{class:"s-login-modal-main-btn-text"},this.emailLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("slot",{name:"after-login-type"})):"",this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.mobileTab=s},i("slot",{name:"before-login-mobile"}),i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.loginTelInput=s,onKeyDown:s=>this.typing(s,this.loginBySMS)}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},salla.lang.get("blocks.header.enter")),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-modal-link"},this.byEmailText):"",i("slot",{name:"after-login-mobile"})):"",this.isEmailAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.emailTab=s},i("slot",{name:"before-login-email"}),i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.loginEmail=s,onKeyDown:s=>this.typing(s,this.loginByEmail),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},salla.lang.get("blocks.header.enter")),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-modal-link"},this.bySMSText):"",i("slot",{name:"after-login-email"})):"",i("salla-verify-modal",{withoutModal:!0,ref:s=>this.verifyTab=s,autoReload:!1},i("a",{onClick:()=>this.showTab("phone"==this.regType?this.mobileTab:this.emailTab),class:"s-verify-modal-back sicon-arrow-right",slot:"after-footer",href:"#"})),i("div",{ref:s=>this.registrationTab=s},i("slot",{name:"before-registration"}),i("label",{class:"s-login-modal-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.firstName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.first_name")}),i("span",{class:"s-login-modal-error-message"}),i("label",{class:"s-login-modal-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.lastName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.last_name")}),i("span",{class:"s-login-modal-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.regTelInput=s,onKeyDown:s=>this.typing(s,this.newUser)})),i("div",{ref:s=>this.regEmailBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"})),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")),i("slot",{name:"after-registration"}))))}get host(){return l(this)}};a.style="[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";export{a as S}
@@ -0,0 +1 @@
1
+ import{r as s,h as t,H as a,g as i}from"./p-cb1c59a2.js";import{H as r}from"./p-ed1c00c5.js";const e=class{constructor(t){s(this,t),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),r.setHost(this.host),salla.event.on("rating::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async show(){return this.modal.show().then((()=>this.order||salla.feedback.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.initiateRating()),100)))}async hide(){return this.modal.hide()}initiateRating(){this.handleWizard(),this.highlightSelectedStars(),salla.document.event.onSubmit(".s-rating-modal-stars-element",(function(s){s.preventDefault();let t=s.target.querySelectorAll(".s-rating-modal-btn-star.s-rating-modal-hovered"),a=t[t.length-1];if(!a)return;let i=parseInt(a.dataset.star,10);s.target.querySelector(".rating_hidden_input").value=i,s.target.querySelectorAll(".s-rating-modal-btn-star").forEach(((s,t)=>r.toggleElementClassIf(s,"s-rating-modal-selected","s-rating-modal-un-selected",(()=>t<i)))),s.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach((s=>s.removeAttribute("aria-pressed"))),a.setAttribute("aria-pressed","")}))}handleWizard(){this.steps=this.host.querySelectorAll(".s-rating-modal-step"),this.dots=this.host.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var t;this.currentTab=s||this.steps[this.currentIndex],r.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(r.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>r.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let a=null===(t=this.steps[this.currentIndex+1])||void 0===t?void 0:t.dataset.type;this.nextBtn.setText(a?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+a):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}highlightSelectedStars(){let s=["s-rating-modal-hovered"];r.all(".s-rating-modal-stars-element",(t=>{let a=t.querySelectorAll(".s-rating-modal-btn-star");t.addEventListener("mouseout",(()=>a.forEach((t=>t.classList.remove(...s))))),a.forEach(((t,i)=>{t.addEventListener("mouseover",(()=>{if(t.classList.add(...s),i<=1)"BUTTON"===t.previousElementSibling.tagName&&t.previousElementSibling.classList.add(...s);else for(let t=0;t<i;t++)a[t].classList.add(...s)})),t.addEventListener("mouseout",(()=>t.classList.remove(...s)))}))}))}previousTab(){this.currentIndex>0&&this.currentIndex--,r.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>r.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,t=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let a=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),e=s.querySelector(".s-rating-modal-validation-msg");if(a&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(e.innerHTML="");throw t=t||s.dataset.type,r.toggleElementClassIf(i,"save","s-has-error",(s=>s.value.length>3)),e.innerHTML=a?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${t}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((t=>{let a=salla.helpers.inputData(t.name,t.value,s);s[a.name]=a.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.feedback.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,t=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(t),this.thanksTime.remove(),this.hide().then((()=>window.location.reload())))}),1e3);this.host.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}renderRatingStars(s,a="rating"){return t("form",{class:"s-rating-modal-stars-element"},t("input",{type:"hidden",class:"rating_hidden_input",name:a,value:""}),[1,2,3,4,5].map((a=>t("button",{type:"submit",class:"s-rating-modal-btn-star s-rating-modal-btn-star-"+s,"data-star":a},t("i",{class:"sicon-star2"})))))}render(){return t(a,{id:"s-rating"},t("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[t("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?t("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},t("div",{class:"s-rating-modal-rounded-icon"},t("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),t("h2",{class:"s-rating-modal-title"},this.rate_the_store),t("div",{class:"s-rating-modal-stars-company"}," ",this.renderRatingStars("large")),t("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),t("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?t("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,a)=>t("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},t("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"}),t("div",{class:"s-rating-modal-product-details"},t("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),t("div",{class:"s-rating-modal-stars-product"}," ",this.renderRatingStars("small",`products[${a}][rating]`)),t("input",{type:"hidden",name:`products[${a}][product_id]`,value:s.product.id}),t("textarea",{placeholder:this.write_product_rate,name:`products[${a}][comment]`,class:"s-rating-modal-comment"}),t("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?t("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},t("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?t("div",{class:"s-rating-modal-rounded-icon"},t("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):t("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),t("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),t("div",{class:"s-rating-modal-stars-company"},this.renderRatingStars("large")),t("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),t("small",{class:"s-rating-modal-validation-msg"})):"",t("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},t("span",{class:"s-rating-modal-icon sicon-check-circle2"}),t("h3",{class:"s-rating-modal-thanks-title"},this.thanks),t("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),t("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),t("div",{class:"s-rating-modal-footer"},t("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?t("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>t("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",t("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidRender(){this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden")))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};e.style="#s-rating-modal .unicode{unicode-bidi:plaintext}";export{e as salla_rating_modal}
@@ -1 +1 @@
1
- import{p as e,b as o}from"./p-cb1c59a2.js";(()=>{const o=import.meta.url,l={};return""!==o&&(l.resourcesUrl=new URL(".",o).href),e(l)})().then((e=>o([["p-646fbb7f",[[4,"salla-button",{buttonType:[513,"button-type"],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]}]]],["p-134fa158",[[0,"salla-search",{inline:[4],oval:[4],height:[2],results:[32],placeholder:[32],noResultsText:[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],title:[32],show:[64],hide:[64],setTitle:[64],loading:[64],stopLoading:[64]}]]],["p-05574321",[[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],show:[64]},[[0,"verified","onVerified"]]]]],["p-2f3f4cce",[[4,"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]}]]],["p-2a032b88",[[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]}]]],["p-c51984d6",[[0,"salla-localization-modal",{language:[1537],currency:[1537],languages:[32],currencies:[32],languagesTitle:[32],currenciesTitle:[32],isLoading:[32],show:[64],hide:[64],submit:[64]}]]],["p-a26e2e12",[[0,"salla-offer-modal",{offer:[32],offer_name:[32],offer_message:[32],offer_expires_in:[32],remember_my_choice:[32],show:[64],showOffer:[64]}]]],["p-85427280",[[0,"salla-rating-modal",{orderId:[2,"order-id"],order:[32],show:[64],hide:[64]}]]],["p-e306c6bb",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],nextPageAutoload:[1028,"next-page-autoload"],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]],["p-635c08a7",[[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],url:[513],by:[1],autoReload:[4,"auto-reload"],title:[32],getCode:[64],show:[64]}]]],["p-79ab1ed9",[[0,"salla-tel-input",{mobile:[1025],countryCode:[1025,"country-code"],countryKey:[1025,"country-key"],mobileRequired:[32],countryCodeLabel:[32],mobileLabel:[32],tooShort:[32],tooLong:[32],invalidCountryCode:[32],invalidNumber:[32],errorMap:[32],getValues:[64],isValid:[64]}]]]],e)));
1
+ import{p as e,b as o}from"./p-cb1c59a2.js";(()=>{const o=import.meta.url,l={};return""!==o&&(l.resourcesUrl=new URL(".",o).href),e(l)})().then((e=>o([["p-646fbb7f",[[4,"salla-button",{buttonType:[513,"button-type"],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]}]]],["p-64977eab",[[0,"salla-search",{inline:[4],oval:[4],height:[2],results:[32],placeholder:[32],noResultsText:[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],title:[32],show:[64],hide:[64],setTitle:[64],loading:[64],stopLoading:[64]}]]],["p-7c4ba872",[[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],show:[64]},[[0,"verified","onVerified"]]]]],["p-2f3f4cce",[[4,"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]}]]],["p-2a032b88",[[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]}]]],["p-c51984d6",[[0,"salla-localization-modal",{language:[1537],currency:[1537],languages:[32],currencies:[32],languagesTitle:[32],currenciesTitle:[32],isLoading:[32],show:[64],hide:[64],submit:[64]}]]],["p-84936d9d",[[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],show:[64],showOffer:[64]}]]],["p-ee9d8563",[[0,"salla-rating-modal",{orderId:[2,"order-id"],order:[32],show:[64],hide:[64]}]]],["p-884a80ca",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],nextPageAutoload:[1028,"next-page-autoload"],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]],["p-635c08a7",[[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],url:[513],by:[1],autoReload:[4,"auto-reload"],title:[32],getCode:[64],show:[64]}]]],["p-79ab1ed9",[[0,"salla-tel-input",{mobile:[1025],countryCode:[1025,"country-code"],countryKey:[1025,"country-key"],mobileRequired:[32],countryCodeLabel:[32],mobileLabel:[32],tooShort:[32],tooLong:[32],invalidCountryCode:[32],invalidNumber:[32],errorMap:[32],getValues:[64],isValid:[64]}]]]],e)));
@@ -15,6 +15,8 @@ export declare class SallaOfferModal {
15
15
  constructor();
16
16
  offer_expires_in: string;
17
17
  remember_my_choice: string;
18
+ add_to_cart: string;
19
+ out_of_stock: string;
18
20
  /**
19
21
  * Show the available offers for the product
20
22
  * @param product_id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-components",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "twilight",
@@ -1 +0,0 @@
1
- export{S as salla_login_modal}from"./p-88dce1e4.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
@@ -1 +0,0 @@
1
- import{r as s,c as i,h as t,H as a,g as l}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";export{S as salla_search}from"./p-e4f716b0.js";const o=class{constructor(t){s(this,t),this.modalOpened=i(this,"modalOpened",7),this.modalClosed=i(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",e.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title")}handleVisible(s){if(!s)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.title=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(s){const i=this.host.querySelector(".s-modal-body");e.toggleElement(i,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",t(a,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},"​"),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?t("div",{class:"s-modal-loader-wrap"},t("span",{class:"s-modal-loader"})):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?t("div",{class:this.iconBlockClasses()},t("i",{class:this.iconClasses()})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return l(this)}static get watchers(){return{visible:["handleVisible"]}}};o.style=".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";export{o as salla_modal}
@@ -1 +0,0 @@
1
- import{r as s,h as t,H as a,g as i}from"./p-cb1c59a2.js";import{H as r}from"./p-ed1c00c5.js";const e=class{constructor(t){s(this,t),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),r.setHost(this.host),salla.event.on("rating::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async show(){return this.modal.show().then((()=>this.order||salla.feedback.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.initiateRating()),100)))}async hide(){return this.modal.hide()}initiateRating(){this.handleWizard(),this.highlightSelectedStars(),salla.document.event.onSubmit(".s-rating-modal-stars-element",(function(s){s.preventDefault();let t=s.target.querySelectorAll(".s-rating-modal-btn-star.s-rating-modal-hovered"),a=t[t.length-1];if(!a)return;let i=parseInt(a.dataset.star,10);s.target.querySelector(".rating_hidden_input").value=i,s.target.querySelectorAll(".s-rating-modal-btn-star").forEach(((s,t)=>r.toggleElement(s,"s-rating-modal-selected","s-rating-modal-un-selected",(()=>t<i)))),s.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach((s=>s.removeAttribute("aria-pressed"))),a.setAttribute("aria-pressed","")}))}handleWizard(){this.steps=this.host.querySelectorAll(".s-rating-modal-step"),this.dots=this.host.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var t;this.currentTab=s||this.steps[this.currentIndex],r.toggle(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggle(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(r.toggleElement(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>r.toggleElement(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let a=null===(t=this.steps[this.currentIndex+1])||void 0===t?void 0:t.dataset.type;this.nextBtn.setText(a?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+a):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}highlightSelectedStars(){let s=["s-rating-modal-hovered"];r.all(".s-rating-modal-stars-element",(t=>{let a=t.querySelectorAll(".s-rating-modal-btn-star");t.addEventListener("mouseout",(()=>a.forEach((t=>t.classList.remove(...s))))),a.forEach(((t,i)=>{t.addEventListener("mouseover",(()=>{if(t.classList.add(...s),i<=1)"BUTTON"===t.previousElementSibling.tagName&&t.previousElementSibling.classList.add(...s);else for(let t=0;t<i;t++)a[t].classList.add(...s)})),t.addEventListener("mouseout",(()=>t.classList.remove(...s)))}))}))}previousTab(){this.currentIndex>0&&this.currentIndex--,r.toggleElement(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>r.toggle("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,t=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let a=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),e=s.querySelector(".s-rating-modal-validation-msg");if(a&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(e.innerHTML="");throw t=t||s.dataset.type,r.toggleElement(i,"save","s-has-error",(s=>s.value.length>3)),e.innerHTML=a?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${t}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((t=>{let a=salla.helpers.inputData(t.name,t.value,s);s[a.name]=a.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.feedback.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,t=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(t),this.thanksTime.remove(),this.hide().then((()=>window.location.reload())))}),1e3);this.host.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}renderRatingStars(s,a="rating"){return t("form",{class:"s-rating-modal-stars-element"},t("input",{type:"hidden",class:"rating_hidden_input",name:a,value:""}),[1,2,3,4,5].map((a=>t("button",{type:"submit",class:"s-rating-modal-btn-star s-rating-modal-btn-star-"+s,"data-star":a},t("i",{class:"sicon-star2"})))))}render(){return t(a,{id:"s-rating"},t("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[t("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?t("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},t("div",{class:"s-rating-modal-rounded-icon"},t("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),t("h2",{class:"s-rating-modal-title"},this.rate_the_store),t("div",{class:"s-rating-modal-stars-company"}," ",this.renderRatingStars("large")),t("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),t("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?t("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,a)=>t("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},t("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"}),t("div",{class:"s-rating-modal-product-details"},t("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),t("div",{class:"s-rating-modal-stars-product"}," ",this.renderRatingStars("small",`products[${a}][rating]`)),t("input",{type:"hidden",name:`products[${a}][product_id]`,value:s.product.id}),t("textarea",{placeholder:this.write_product_rate,name:`products[${a}][comment]`,class:"s-rating-modal-comment"}),t("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?t("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},t("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?t("div",{class:"s-rating-modal-rounded-icon"},t("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):t("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),t("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),t("div",{class:"s-rating-modal-stars-company"},this.renderRatingStars("large")),t("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),t("small",{class:"s-rating-modal-validation-msg"})):"",t("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},t("span",{class:"s-rating-modal-icon sicon-check-circle2"}),t("h3",{class:"s-rating-modal-thanks-title"},this.thanks),t("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),t("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),t("div",{class:"s-rating-modal-footer"},t("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?t("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>t("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",t("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidRender(){this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden")))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};e.style="#s-rating-modal .unicode{unicode-bidi:plaintext}";export{e as salla_rating_modal}
@@ -1 +0,0 @@
1
- import{r as s,h as i,g as l}from"./p-cb1c59a2.js";import{H as t}from"./p-ed1c00c5.js";const a=class{constructor(i){s(this,i),this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!0),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!0),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!1),this.regType="phone",this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),this.typing=(s,i)=>{const l=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==l?void 0:l.classList.contains("s-login-modal-error-message"))&&(l.innerText=""),"Enter"==s.key&&i()},this.loginBySMS=async()=>{const{mobile:s,countryCode:i}=await this.loginTelInput.getValues();await this.loginTelInput.isValid()&&this.smsBtn.load().then((()=>this.smsBtn.disable())).then((()=>salla.auth.api.login({type:"mobile",phone:s,country_code:i}))).then((()=>this.smsBtn.stop()&&this.smsBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>(this.verifyTab.by="sms")&&(this.verifyTab.url="auth/mobile/verify"))).then((()=>this.verifyTab.show({phone:s,country_code:i})))},this.loginByEmail=()=>{t.isValidEmail(this.loginEmail.value)?this.emailBtn.load().then((()=>this.emailBtn.disable())).then((()=>salla.auth.api.login({type:"email",email:this.loginEmail.value}))).then((()=>this.emailBtn.stop()&&this.emailBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.by="email")).then((()=>this.verifyTab.show({email:this.loginEmail.value}))):this.validateField(this.loginEmail,this.emailErrorMsg)},this.newUser=async()=>{var s;const{mobile:i,countryCode:l,countryKey:t}="email"==this.regType?await this.regTelInput.getValues():await this.loginTelInput.getValues(),a=this.regEmail.value||(null===(s=this.loginEmail)||void 0===s?void 0:s.value);await this.newUserValidation(),await this.regBtn.load(),await this.regBtn.disable();let e={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.mobile,country_code:l,country_key:t,verified_by:this.regType};a&&(e=Object.assign(Object.assign({},e),{email:a})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},e),{code:s})))).then((()=>window.location.reload())).catch((()=>this.regBtn.stop()&&this.regBtn.enable()))},this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.event.on("languages::translations.loaded",(()=>{var s,i,l,t;this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.smsBtn)||void 0===i||i.setText(salla.lang.get("blocks.header.enter")),null===(l=this.emailBtn)||void 0===l||l.setText(salla.lang.get("blocks.header.enter")),null===(t=this.regBtn)||void 0===t||t.setText(salla.lang.get("blocks.header.register"))})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show())),salla.event.on("twilight::initiated",(()=>{this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!!this.isEmailAllowed),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!!this.isMobileAllowed),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!!this.isEmailRequired)}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}async show(){return this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.show()}showTab(s,i){var l,a;null==i||i.preventDefault();let e=[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab];e.map((i=>t.toggleElement(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>e.map((i=>t.toggleElement(i,"s-login-modal-active","s-login-modal-unactive",(()=>i==s))))),200),setTimeout((()=>this.host.querySelector(".s-login-modal-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px"))),[this.mobileTab,this.emailTab].includes(s)&&(this.regType=s===this.mobileTab?"phone":"email");let o=s==this.registrationTab;return o&&(null===(l=this.firstName)||void 0===l||l.focus()),null===(a=this.modal)||void 0===a||a.setTitle(o?salla.lang.get("common.titles.registration"):this.title),o||t.toggleElement(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElement(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}async newUserValidation(){const s="phone"==this.regType,i=this.regEmail.value||"email"==this.regType&&this.loginEmail.value,l=t.isValidEmail(i),a=this.firstName.value.length>0,e=this.lastName.value.length>0,o=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&l||!i&&!this.isEmailRequired)&&o&&a&&e))throw!l&&this.validateField(this.regEmail,this.emailErrorMsg),!a&&this.validateField(this.firstName,this.firstNameErrorMsg),!e&&this.validateField(this.lastName,this.lastNameErrorMsg),"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i("salla-modal",{id:"salla-login",icon:"sicon-user",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-modal-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-modal-sub-title"},this.loginTypeTitle),i("slot",{name:"before-login-type"}),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-phone"}),i("span",{class:"s-login-modal-main-btn-text"},this.smsLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-mail"}),i("span",{class:"s-login-modal-main-btn-text"},this.emailLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("slot",{name:"after-login-type"})):"",this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.mobileTab=s},i("slot",{name:"before-login-mobile"}),i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.loginTelInput=s,onKeyDown:s=>this.typing(s,this.loginBySMS)}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},salla.lang.get("blocks.header.enter")),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-modal-link"},this.byEmailText):"",i("slot",{name:"after-login-mobile"})):"",this.isEmailAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.emailTab=s},i("slot",{name:"before-login-email"}),i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.loginEmail=s,onKeyDown:s=>this.typing(s,this.loginByEmail),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},salla.lang.get("blocks.header.enter")),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-modal-link"},this.bySMSText):"",i("slot",{name:"after-login-email"})):"",i("salla-verify-modal",{withoutModal:!0,ref:s=>this.verifyTab=s,autoReload:!1},i("a",{onClick:()=>this.showTab("phone"==this.regType?this.mobileTab:this.emailTab),class:"s-verify-modal-back sicon-arrow-right",slot:"after-footer",href:"#"})),i("div",{ref:s=>this.registrationTab=s},i("slot",{name:"before-registration"}),i("label",{class:"s-login-modal-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.firstName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.first_name")}),i("span",{class:"s-login-modal-error-message"}),i("label",{class:"s-login-modal-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.lastName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.last_name")}),i("span",{class:"s-login-modal-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.regTelInput=s,onKeyDown:s=>this.typing(s,this.newUser)})),i("div",{ref:s=>this.regEmailBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"})),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")),i("slot",{name:"after-registration"}))))}get host(){return l(this)}};a.style="[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";export{a as S}
@@ -1 +0,0 @@
1
- import{r as s,h as a,g as o}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";const l=class{constructor(a){var o,l;s(this,a),this.offer=null,this.offer_expires_in=salla.lang.get("pages.products.offer_expires_in"),this.remember_my_choice=salla.lang.get("commone.remember_my_choice"),e.setHost(this.host),salla.event.on("languages::translations.loaded",(()=>{this.offer_expires_in=salla.lang.get("pages.products.offer_expires_in"),this.remember_my_choice=salla.lang.get("common.remember_my_choice")})),this.categorySlot=(null===(o=e.getElement('[slot="category"]'))||void 0===o?void 0:o.innerHTML)||'<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>',this.productSlot=(null===(l=e.getElement('[slot="product"]'))||void 0===l?void 0:l.innerHTML)||this.defaultProductSlot(),salla.offer.event.onExisted((s=>{salla.storage.get("remember-offer-"+s.id)?salla.log("User selected to don't show this offer again."):this.show(s.product_id)}))}async show(s){return salla.api.offer.details(s).then((s=>this.showOffer(s.data[0])))}async showOffer(s){return this.offer=s,this.offer_name=s.name,this.offer_message=s.message,this.modal.show()}rememberMe(s){salla.storage.set("remember-offer-"+this.offer.id,s.target.checked)}addItem(){return this.load(),salla.cart.api.quickAdd(this.dataset.id).finally((()=>this.stop()))}defaultProductSlot(){return'<a href={url} class="s-offer-modal-product-image-wrap"><img class="s-offer-modal-product-image" src="{image}" /></a><div class="s-offer-modal-product-info"> <a href={url} class="s-offer-modal-product-name">{name}</a> <div class="s-offer-modal-product-price">{price}</div></div>'}render(){var s,o;return a("salla-modal",{id:"salla-offer-modal","sub-title-first":!0,icon:"sicon-special-discount",title:"عروض رائعة في انتظارك، ماذا نتنظر!","sub-title":this.offer_message,ref:s=>this.modal=s,"is-loading":null===this.offer},null!==this.offer?[a("div",{class:"s-offer-modal-scrolled-slider-wrap"},a("div",{class:"s-offer-modal-body s-offer-modal-scrolled-slider"},(null===(s=this.offer.get.categories)||void 0===s?void 0:s.length)>0?this.offer.get.categories.map((s=>a("a",{href:s.urls.customer,class:"s-offer-modal-badge s-offer-modal-slider-item",innerHTML:this.categorySlot.replace(/\{name\}/g,s.name).replace(/\{url\}/g,s.urls.customer)}))):null===(o=this.offer.get.products)||void 0===o?void 0:o.map((s=>a("div",{class:"s-offer-modal-product s-offer-modal-slider-item",id:"product_"+s.id,innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{url\}/g,s.url).replace(/\{image\}/g,s.thumbnail).replace(/\{price\}/g,s.has_special_price?salla.money(s.price)+'<span class="s-offer-modal-product-old-price">'+salla.money(s.regular_price)+"</span>":salla.money(s.price))},a("div",{class:"s-offer-modal-btn-wrap"},a("salla-button",{wide:!0,"btn-style":"outline-primary","data-id":s.id,"loader-position":"center",onClick:this.addItem},salla.lang.get("pages.cart.add_to_cart"))))))),a("div",{class:"s-offer-modal-slider-nav"},a("button",{class:"s-offer-modal-nav-btn s-offer-modal-prev-btn"},a("span",{class:"s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right"})),a("button",{class:"s-offer-modal-nav-btn s-offer-modal-next-btn"},a("span",{class:"s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left"})))),a("div",{class:"s-offer-modal-footer",slot:"footer"},this.offer.expiry_date?a("p",{class:"s-offer-modal-expiry"},this.offer_expires_in," ",this.offer.expiry_date):"",a("label",{class:"s-offer-modal-remember-label"},a("input",{type:"checkbox",onChange:s=>this.rememberMe(s),class:"s-offer-modal-remember-input"}),"  ",this.remember_my_choice))]:"")}componentDidRender(){if(this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden"))),this.offer&&window.screen.width>639){let s=this.host.querySelector(".s-offer-modal-scrolled-slider-wrap"),a=this.host.querySelector(".s-offer-modal-scrolled-slider"),o=this.host.querySelectorAll(".s-offer-modal-nav-btn"),e=this.host.querySelector(".s-offer-modal-next-btn"),l=this.host.querySelector(".s-offer-modal-prev-btn"),r=this.host.querySelectorAll(".s-offer-modal-slider-item"),t=20,i=0,d=3,f=r[0].offsetWidth,n=r.length*f,c=s.offsetWidth,m=n-c,h=!!document.body.classList.contains("rtl");m>t&&e.classList.add("s-offer-modal-btn-is-active"),window.onresize=function(){c=s.offsetWidth,m=n-c},a.addEventListener("scroll",(function(){let s=Math.abs(a.scrollLeft),o=m-t;s<=t?(e.classList.add("s-offer-modal-btn-is-active"),l.classList.remove("s-offer-modal-btn-is-active")):s<o?(e.classList.add("s-offer-modal-btn-is-active"),l.classList.add("s-offer-modal-btn-is-active")):s>=o&&(e.classList.remove("s-offer-modal-btn-is-active"),l.classList.add("s-offer-modal-btn-is-active"))})),o.forEach((s=>{s.addEventListener("click",(function(){s.classList.contains("s-offer-modal-next-btn")?i++:i--,a.scrollTo({top:0,left:f*d*i*(h?-1:1),behavior:"smooth"})}))}))}}get host(){return o(this)}};l.style="#salla-offer-modal .s-offer-modal-body{-webkit-overflow-scrolling:touch}#salla-offer-modal .s-offer-modal-body::-webkit-scrollbar{display:none}#salla-offer-modal .s-offer-modal-next-btn{background:linear-gradient(90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}#salla-offer-modal .s-offer-modal-prev-btn{background:linear-gradient(-90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}";export{l as salla_offer_modal}
@@ -1 +0,0 @@
1
- import{r as s,h as a,g as e}from"./p-cb1c59a2.js";import{H as r}from"./p-ed1c00c5.js";const i=class{constructor(a){var e;s(this,a),this.inputValue="",this.inline=!1,this.oval=!1,this.height=60,r.setHost(this.host),this.productSlot=(null===(e=r.getElement('[slot="product"]'))||void 0===e?void 0:e.innerHTML)||this.getDefaultProductSlot(),salla.event.on("search::show",(()=>this.modal.show())),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching(),this.container.classList.remove("s-search-no-results")}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(this.inputValue=s.target.value,r.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(r.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s)).catch((s=>"Query Same As Previous!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var a;this.noResults.style.display=s||(null===(a=this.results)||void 0===a?void 0:a.data.length)>0?"none":"block",r.toggleElement(this.container,"s-search-container-open","s-search-no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery="",0==this.inputValue.length&&this.container.classList.remove("s-search-no-results")}render(){var s;const e=a("div",{class:{"s-search-container":!0,"s-search-inline":this.inline},ref:s=>this.container=s,style:this.oval?{borderRadius:this.height/2+"px"}:{}},a("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s),style:{height:this.height+"px"}}),a("span",{class:"s-search-icon-wrap"},a("i",{class:"s-search-icon sicon-search",ref:s=>this.searchIcon=s})),a("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>a("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price).replace(/\{image\}/g,s.image_url)}))),a("p",{ref:s=>this.noResults=s,class:"s-search-no-results-placeholder"},this.noResultsText)));return this.inline?a("div",{id:"s-search-modal"},e):a("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},e)}componentDidLoad(){this.afterSearching()}get host(){return e(this)}};i.style="#s-search-modal .s-search-inline{border:1px solid #eee}#s-search-modal .s-search-no-results .s-search-input,#s-search-modal .s-search-container-open .s-search-input{border-bottom:1px solid #f4f4f5}#s-search-modal .s-search-product-image[src=null]{opacity:0}#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem;background:transparent;overflow:visible}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";export{i as S}