@salla.sa/twilight-components 1.0.49 → 1.0.51

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 (63) hide show
  1. package/dist/cjs/index.cjs.js +3 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button.cjs.entry.js +116 -0
  4. package/dist/cjs/salla-localization-modal.cjs.entry.js +117 -0
  5. package/dist/cjs/{salla-search-a7147639.js → salla-login-modal-a2c7fa5d.js} +13 -87
  6. package/dist/cjs/salla-login-modal.cjs.entry.js +11 -0
  7. package/dist/cjs/salla-modal_2.cjs.entry.js +155 -0
  8. package/dist/cjs/{salla-offer.cjs.entry.js → salla-offer-modal.cjs.entry.js} +26 -26
  9. package/dist/cjs/{salla-rating.cjs.entry.js → salla-rating-modal.cjs.entry.js} +33 -33
  10. package/dist/cjs/salla-search-99d08b1f.js +79 -0
  11. package/dist/cjs/{salla-button_7.cjs.entry.js → salla-tel-input.cjs.entry.js} +0 -509
  12. package/dist/cjs/salla-verify-modal.cjs.entry.js +148 -0
  13. package/dist/cjs/twilight-components.cjs.js +1 -1
  14. package/dist/collection/collection-manifest.json +4 -4
  15. package/dist/collection/components/{salla-localization/salla-localization.css → salla-localization-modal/salla-localization-modal.css} +0 -0
  16. package/dist/collection/components/{salla-localization/salla-localization.js → salla-localization-modal/salla-localization-modal.js} +19 -19
  17. package/dist/collection/components/{salla-login/salla-login.css → salla-login-modal/salla-login-modal.css} +0 -0
  18. package/dist/collection/components/{salla-login/salla-login.js → salla-login-modal/salla-login-modal.js} +34 -34
  19. package/dist/collection/components/{salla-offer → salla-offer-modal}/offer-schema.js +0 -0
  20. package/dist/collection/components/{salla-offer/salla-offer.css → salla-offer-modal/salla-offer-modal.css} +4 -4
  21. package/dist/collection/components/{salla-offer/salla-offer.js → salla-offer-modal/salla-offer-modal.js} +34 -34
  22. package/dist/collection/components/{salla-rating → salla-rating-modal}/order-feedback-response.js +0 -0
  23. package/dist/collection/components/{salla-rating/salla-rating.css → salla-rating-modal/salla-rating-modal.css} +1 -1
  24. package/dist/collection/components/{salla-rating/salla-rating.js → salla-rating-modal/salla-rating-modal.js} +57 -57
  25. package/dist/collection/index.js +1 -1
  26. package/dist/esm/index.js +2 -1
  27. package/dist/esm/loader.js +1 -1
  28. package/dist/esm/salla-button.entry.js +112 -0
  29. package/dist/esm/salla-localization-modal.entry.js +113 -0
  30. package/dist/esm/{salla-search-813732a1.js → salla-login-modal-187c1f98.js} +13 -86
  31. package/dist/esm/salla-login-modal.entry.js +3 -0
  32. package/dist/esm/salla-modal_2.entry.js +150 -0
  33. package/dist/esm/{salla-offer.entry.js → salla-offer-modal.entry.js} +26 -26
  34. package/dist/esm/{salla-rating.entry.js → salla-rating-modal.entry.js} +33 -33
  35. package/dist/esm/salla-search-2e3e60cb.js +77 -0
  36. package/dist/esm/{salla-button_7.entry.js → salla-tel-input.entry.js} +2 -505
  37. package/dist/esm/salla-verify-modal.entry.js +144 -0
  38. package/dist/esm/twilight-components.js +1 -1
  39. package/dist/twilight-components/index.esm.js +1 -1
  40. package/dist/twilight-components/p-05dff05e.entry.js +1 -0
  41. package/dist/twilight-components/p-0b599094.js +1 -0
  42. package/dist/twilight-components/p-1f873057.entry.js +1 -0
  43. package/dist/twilight-components/p-2e03db57.entry.js +1 -0
  44. package/dist/twilight-components/p-5ffd56fb.js +1 -0
  45. package/dist/twilight-components/p-85427280.entry.js +1 -0
  46. package/dist/twilight-components/p-88d1bb89.entry.js +1 -0
  47. package/dist/twilight-components/p-8bfa19fb.entry.js +1 -0
  48. package/dist/twilight-components/p-ea455ae9.entry.js +1 -0
  49. package/dist/twilight-components/p-f0f51a3c.entry.js +1 -0
  50. package/dist/twilight-components/twilight-components.esm.js +1 -1
  51. package/dist/types/components/{salla-localization/salla-localization.d.ts → salla-localization-modal/salla-localization-modal.d.ts} +1 -1
  52. package/dist/types/components/{salla-login/salla-login.d.ts → salla-login-modal/salla-login-modal.d.ts} +1 -1
  53. package/dist/types/components/{salla-offer → salla-offer-modal}/offer-schema.d.ts +0 -0
  54. package/dist/types/components/{salla-offer/salla-offer.d.ts → salla-offer-modal/salla-offer-modal.d.ts} +1 -1
  55. package/dist/types/components/{salla-rating → salla-rating-modal}/order-feedback-response.d.ts +0 -0
  56. package/dist/types/components/{salla-rating/salla-rating.d.ts → salla-rating-modal/salla-rating-modal.d.ts} +1 -1
  57. package/dist/types/components.d.ts +36 -36
  58. package/dist/types/index.d.ts +1 -1
  59. package/package.json +1 -1
  60. package/dist/twilight-components/p-152b7287.entry.js +0 -1
  61. package/dist/twilight-components/p-4b774cf9.entry.js +0 -1
  62. package/dist/twilight-components/p-b584e892.entry.js +0 -1
  63. package/dist/twilight-components/p-b8ed7363.js +0 -1
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-0b5b5867.js');
6
6
  const Helper = require('./Helper-98cc9f18.js');
7
7
 
8
- const sallaOfferCss = "#salla-offer-modal .s-offer-body{-webkit-overflow-scrolling:touch}#salla-offer-modal .s-offer-body::-webkit-scrollbar{display:none}#salla-offer-modal .s-offer-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-prev-btn{background:linear-gradient(-90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}";
8
+ const sallaOfferModalCss = "#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%)}";
9
9
 
10
- const SallaOffer = class {
10
+ const SallaOfferModal = class {
11
11
  constructor(hostRef) {
12
12
  index.registerInstance(this, hostRef);
13
13
  var _a, _b;
@@ -19,7 +19,7 @@ const SallaOffer = class {
19
19
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
20
20
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
21
21
  });
22
- this.categorySlot = ((_a = Helper.Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-badge-icon sicon-tag"></i><span class="s-offer-badge-text">{name}</span>';
22
+ 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
23
  this.productSlot = ((_b = Helper.Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
24
24
  salla.offer.event.onExisted(data => {
25
25
  //TODO:: use the best, should we hide the offer by product Id or Offer id🤔
@@ -60,29 +60,29 @@ const SallaOffer = class {
60
60
  .finally(() => this['stop']());
61
61
  }
62
62
  defaultProductSlot() {
63
- return '<a href={url} class="s-offer-product-image-wrap"><img class="s-offer-product-image" src="{image}" /></a>' +
64
- '<div class="s-offer-product-info">' +
65
- ' <a href={url} class="s-offer-product-name">{name}</a>' +
66
- ' <div class="s-offer-product-price">{price}</div>' +
63
+ return '<a href={url} class="s-offer-modal-product-image-wrap"><img class="s-offer-modal-product-image" src="{image}" /></a>' +
64
+ '<div class="s-offer-modal-product-info">' +
65
+ ' <a href={url} class="s-offer-modal-product-name">{name}</a>' +
66
+ ' <div class="s-offer-modal-product-price">{price}</div>' +
67
67
  '</div>';
68
68
  }
69
69
  render() {
70
70
  var _a, _b;
71
71
  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
72
- ? [index.h("div", { class: "s-offer-scrolled-slider-wrap" }, index.h("div", { class: "s-offer-body s-offer-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
73
- ? this.offer.get.categories.map(category => index.h("a", { href: category.urls.customer, class: "s-offer-badge s-offer-slider-item", innerHTML: this.categorySlot
72
+ ? [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
73
+ ? 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
74
74
  .replace(/\{name\}/g, category.name)
75
75
  .replace(/\{url\}/g, category.urls.customer) }))
76
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: "s-offer-product s-offer-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
76
+ : (_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
77
77
  .replace(/\{name\}/g, product.name)
78
78
  .replace(/\{url\}/g, product.url)
79
79
  .replace(/\{image\}/g, product.thumbnail)
80
80
  .replace(/\{price\}/g, product.has_special_price
81
- ? salla.money(product.price) + '<span class="s-offer-product-old-price">' + salla.money(product.regular_price) + '</span>'
82
- : salla.money({ amount: product.price, currency: salla.config.get('user').currency_code })) }, index.h("div", { class: "s-offer-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-slider-nav" }, index.h("button", { class: "s-offer-nav-btn s-offer-prev-btn" }, index.h("span", { class: "s-offer-nav-btn-icon sicon-keyboard_arrow_right" })), index.h("button", { class: "s-offer-nav-btn s-offer-next-btn" }, index.h("span", { class: "s-offer-nav-btn-icon sicon-keyboard_arrow_left" })))),
83
- index.h("div", { class: "s-offer-footer", slot: "footer" }, this.offer.expiry_date ?
84
- index.h("p", { class: "s-offer-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
85
- : '', index.h("label", { class: "s-offer-remember-label" }, index.h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-remember-input" }), "\u00A0 ", this.remember_my_choice)),
81
+ ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
82
+ : 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" })))),
83
+ index.h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.expiry_date ?
84
+ index.h("p", { class: "s-offer-modal-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
85
+ : '', 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)),
86
86
  ] : '');
87
87
  }
88
88
  componentDidRender() {
@@ -91,11 +91,11 @@ const SallaOffer = class {
91
91
  this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
92
92
  // Sooo mini Slider
93
93
  if (this.offer && window.screen.width > 639) {
94
- let sliderWrap = this.host.querySelector('.s-offer-scrolled-slider-wrap'), slider = this.host.querySelector('.s-offer-scrolled-slider'), navButtons = this.host.querySelectorAll('.s-offer-nav-btn'), nexBtn = this.host.querySelector('.s-offer-next-btn'), prevBtn = this.host.querySelector('.s-offer-prev-btn'), items = this.host.querySelectorAll('.s-offer-slider-item'), sliderNavMargin = 20, // space before displaying the next/prev btns.
94
+ let sliderWrap = this.host.querySelector('.s-offer-modal-scrolled-slider-wrap'), slider = this.host.querySelector('.s-offer-modal-scrolled-slider'), navButtons = this.host.querySelectorAll('.s-offer-modal-nav-btn'), nexBtn = this.host.querySelector('.s-offer-modal-next-btn'), prevBtn = this.host.querySelector('.s-offer-modal-prev-btn'), items = this.host.querySelectorAll('.s-offer-modal-slider-item'), sliderNavMargin = 20, // space before displaying the next/prev btns.
95
95
  current = 0, // current slide
96
96
  slidesToScroll = 3, itemsLength = items.length, itemSize = items[0].offsetWidth, sliderSize = itemsLength * itemSize, sliderWrapperSize = sliderWrap.offsetWidth, sliderInvisibleSize = sliderSize - sliderWrapperSize, isRTL = document.body.classList.contains('rtl') ? true : false;
97
97
  if (sliderInvisibleSize > sliderNavMargin)
98
- nexBtn.classList.add('s-offer-btn-is-active');
98
+ nexBtn.classList.add('s-offer-modal-btn-is-active');
99
99
  window.onresize = function () {
100
100
  sliderWrapperSize = sliderWrap.offsetWidth;
101
101
  sliderInvisibleSize = sliderSize - sliderWrapperSize;
@@ -105,23 +105,23 @@ const SallaOffer = class {
105
105
  let sliderEndOffset = sliderInvisibleSize - sliderNavMargin;
106
106
  // show & hide the navigation btns depending on scroll position
107
107
  if (sliderPosition <= sliderNavMargin) {
108
- nexBtn.classList.add('s-offer-btn-is-active');
109
- prevBtn.classList.remove('s-offer-btn-is-active');
108
+ nexBtn.classList.add('s-offer-modal-btn-is-active');
109
+ prevBtn.classList.remove('s-offer-modal-btn-is-active');
110
110
  }
111
111
  else if (sliderPosition < sliderEndOffset) {
112
112
  // show both btns in the middle
113
- nexBtn.classList.add('s-offer-btn-is-active');
114
- prevBtn.classList.add('s-offer-btn-is-active');
113
+ nexBtn.classList.add('s-offer-modal-btn-is-active');
114
+ prevBtn.classList.add('s-offer-modal-btn-is-active');
115
115
  }
116
116
  else if (sliderPosition >= sliderEndOffset) {
117
- nexBtn.classList.remove('s-offer-btn-is-active');
118
- prevBtn.classList.add('s-offer-btn-is-active');
117
+ nexBtn.classList.remove('s-offer-modal-btn-is-active');
118
+ prevBtn.classList.add('s-offer-modal-btn-is-active');
119
119
  }
120
120
  });
121
121
  // Navigation
122
122
  navButtons.forEach(btn => {
123
123
  btn.addEventListener('click', function () {
124
- btn.classList.contains('s-offer-next-btn') ? current++ : current--;
124
+ btn.classList.contains('s-offer-modal-next-btn') ? current++ : current--;
125
125
  slider.scrollTo({
126
126
  top: 0,
127
127
  left: itemSize * slidesToScroll * current * (isRTL ? -1 : 1),
@@ -133,6 +133,6 @@ const SallaOffer = class {
133
133
  }
134
134
  get host() { return index.getElement(this); }
135
135
  };
136
- SallaOffer.style = sallaOfferCss;
136
+ SallaOfferModal.style = sallaOfferModalCss;
137
137
 
138
- exports.salla_offer = SallaOffer;
138
+ exports.salla_offer_modal = SallaOfferModal;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-0b5b5867.js');
6
6
  const Helper = require('./Helper-98cc9f18.js');
7
7
 
8
- const sallaRatingCss = "#s-rating .unicode{unicode-bidi:plaintext}";
8
+ const sallaRatingModalCss = "#s-rating-modal .unicode{unicode-bidi:plaintext}";
9
9
 
10
- const SallaRating = class {
10
+ const SallaRatingModal = class {
11
11
  constructor(hostRef) {
12
12
  index.registerInstance(this, hostRef);
13
13
  this.stepsCount = 0;
@@ -60,11 +60,11 @@ const SallaRating = class {
60
60
  initiateRating() {
61
61
  this.handleWizard();
62
62
  this.highlightSelectedStars();
63
- salla.document.event.onSubmit('.s-rating-stars-element', function (event) {
63
+ salla.document.event.onSubmit('.s-rating-modal-stars-element', function (event) {
64
64
  // Prevent form from submitting
65
65
  event.preventDefault();
66
66
  // Get the selected star - activeElement is not supported in safari
67
- let activeStars = event.target.querySelectorAll('.s-rating-btn-star.s-rating-hovered');
67
+ let activeStars = event.target.querySelectorAll('.s-rating-modal-btn-star.s-rating-modal-hovered');
68
68
  let selected = activeStars[activeStars.length - 1];
69
69
  if (!selected)
70
70
  return;
@@ -73,29 +73,29 @@ const SallaRating = class {
73
73
  // Get all stars in this form (only search in the form, not the whole document)
74
74
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
75
75
  event.target
76
- .querySelectorAll('.s-rating-btn-star')
77
- .forEach((star, index) => Helper.Helper.toggleElement(star, 's-rating-selected', 's-rating-un-selected', () => index < selectedIndex));
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));
78
78
  // Remove aria-pressed from any previously selected star
79
- event.target.querySelectorAll('.s-rating-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
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
81
81
  selected.setAttribute('aria-pressed', '');
82
82
  });
83
83
  }
84
84
  // handle wizard
85
85
  handleWizard() {
86
- this.steps = this.host.querySelectorAll(".s-rating-step");
87
- this.dots = this.host.querySelectorAll(".s-rating-step-dot");
86
+ this.steps = this.host.querySelectorAll(".s-rating-modal-step");
87
+ this.dots = this.host.querySelectorAll(".s-rating-modal-step-dot");
88
88
  this.showActiveStep();
89
89
  }
90
90
  showActiveStep(current = null) {
91
91
  var _a;
92
92
  this.currentTab = current || this.steps[this.currentIndex];
93
- Helper.Helper.toggle('.s-rating-step-dot', 's-rating-bg-gray', 's-rating-bg-primary', dot => dot != this.dots[this.currentIndex])
94
- .toggle('.s-rating-step', 's-rating-active', 's-rating-hidden', tab => tab == this.currentTab);
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);
95
95
  if (this.currentIndex != 0) {
96
96
  // the animation
97
- Helper.Helper.toggleElement(this.currentTab, 's-rating-unactive', 's-rating-hidden', () => true);
98
- setTimeout(() => Helper.Helper.toggleElement(this.currentTab, 's-rating-active', 's-rating-unactive', () => true), 300);
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);
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;
@@ -104,9 +104,9 @@ const SallaRating = class {
104
104
  setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
105
105
  }
106
106
  highlightSelectedStars() {
107
- let hover = ['s-rating-hovered'];
108
- Helper.Helper.all('.s-rating-stars-element', el => {
109
- let starElements = el.querySelectorAll('.s-rating-btn-star');
107
+ let hover = ['s-rating-modal-hovered'];
108
+ Helper.Helper.all('.s-rating-modal-stars-element', el => {
109
+ let starElements = el.querySelectorAll('.s-rating-modal-btn-star');
110
110
  // remove hovered state from stars ---
111
111
  el.addEventListener('mouseout', () => starElements.forEach(star => star.classList.remove(...hover)));
112
112
  starElements.forEach((starElement, index) => {
@@ -127,7 +127,7 @@ const SallaRating = class {
127
127
  }
128
128
  previousTab() {
129
129
  this.currentIndex > 0 && this.currentIndex--;
130
- Helper.Helper.toggleElement(this.backBtn, 's-rating-unvisiable', 'block', () => this.currentIndex == 0);
130
+ Helper.Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
131
131
  this.showActiveStep();
132
132
  }
133
133
  submit() {
@@ -135,10 +135,10 @@ const SallaRating = class {
135
135
  salla.config.canLeave = false;
136
136
  this.nextBtn.load()
137
137
  .then(() => this.submittedBefore() || this.sendFeedback())
138
- .then(() => this.currentTab.querySelectorAll('[name],.s-rating-btn-star').forEach(el => el.setAttribute('disabled', '')))
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-unvisiable', () => true))
141
+ .then(() => Helper.Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
142
142
  .finally(() => {
143
143
  this.nextBtn.stop();
144
144
  salla.config.canLeave = true;
@@ -155,8 +155,8 @@ const SallaRating = class {
155
155
  }
156
156
  rating = rating || this.currentTab;
157
157
  let stars = rating.querySelector('.rating_hidden_input').value;
158
- let comment = rating.querySelector('.s-rating-comment');
159
- let validationMessage = rating.querySelector('.s-rating-validation-msg');
158
+ let comment = rating.querySelector('.s-rating-modal-comment');
159
+ let validationMessage = rating.querySelector('.s-rating-modal-validation-msg');
160
160
  if (stars && comment.value && comment.value.length > 3) {
161
161
  comment.classList.remove('s-has-error');
162
162
  validationMessage.innerHTML = '';
@@ -194,25 +194,25 @@ const SallaRating = class {
194
194
  this.thanksTime.remove();
195
195
  this.hide().then(() => window.location.reload());
196
196
  }, 1000);
197
- this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
197
+ this.host.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
198
198
  this.showActiveStep(this.thanksTab);
199
199
  }
200
200
  renderRatingStars(size, name = 'rating') {
201
- return (index.h("form", { class: "s-rating-stars-element" }, index.h("input", { type: "hidden", class: "rating_hidden_input", name: name, value: "" }), [1, 2, 3, 4, 5].map(star => index.h("button", { type: "submit", class: `s-rating-btn-star s-rating-btn-star-` + size, "data-star": star }, index.h("i", { class: "sicon-star2" })))));
201
+ return (index.h("form", { class: "s-rating-modal-stars-element" }, index.h("input", { type: "hidden", class: "rating_hidden_input", name: name, value: "" }), [1, 2, 3, 4, 5].map(star => index.h("button", { type: "submit", class: `s-rating-modal-btn-star s-rating-modal-btn-star-` + size, "data-star": star }, index.h("i", { class: "sicon-star2" })))));
202
202
  }
203
203
  // render
204
204
  render() {
205
205
  return (index.h(index.Host, { id: "s-rating" }, index.h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
206
- ? [index.h("div", { class: "s-rating-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
207
- index.h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" }, index.h("div", { class: "s-rating-rounded-icon" }, index.h("img", { src: salla.config.get('store.logo', 'https://assets.salla.sa/cp/assets/images/logo-new.png'), alt: "store name", class: "s-rating-store-logo" })), index.h("h2", { class: "s-rating-title" }, this.rate_the_store), index.h("div", { class: "s-rating-stars-company" }, " ", this.renderRatingStars('large')), index.h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: this.write_store_rate }), index.h("small", { class: "s-rating-validation-msg" }))
206
+ ? [index.h("div", { class: "s-rating-modal-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
207
+ index.h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "store" }, index.h("div", { class: "s-rating-modal-rounded-icon" }, index.h("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" })), index.h("h2", { class: "s-rating-modal-title" }, this.rate_the_store), index.h("div", { class: "s-rating-modal-stars-company" }, " ", this.renderRatingStars('large')), index.h("textarea", { id: "storeReview", name: "comment", class: "s-rating-modal-comment", placeholder: this.write_store_rate }), index.h("small", { class: "s-rating-modal-validation-msg" }))
208
208
  : '', this.order.products_enabled
209
- ? index.h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index$1) => index.h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": this.rate_product_stars }, index.h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }), index.h("div", { class: "s-rating-product-details" }, index.h("h3", { class: "s-rating-product-title" }, " ", item.product.name), index.h("div", { class: "s-rating-stars-product" }, " ", this.renderRatingStars('small', `products[${index$1}][rating]`)), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.product.id }), index.h("textarea", { placeholder: this.write_product_rate, name: `products[${index$1}][comment]`, class: "s-rating-comment" }), index.h("small", { class: "s-rating-validation-msg" })))))
209
+ ? index.h("section", { class: "s-rating-modal-step s-rating-modal-hidden", "data-type": "products" }, this.order.products.map((item, index$1) => index.h("div", { class: "rating-outer-form s-rating-modal-product", "data-stars-error": this.rate_product_stars }, index.h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-modal-product-img" }), index.h("div", { class: "s-rating-modal-product-details" }, index.h("h3", { class: "s-rating-modal-product-title" }, " ", item.product.name), index.h("div", { class: "s-rating-modal-stars-product" }, " ", this.renderRatingStars('small', `products[${index$1}][rating]`)), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.product.id }), index.h("textarea", { placeholder: this.write_product_rate, name: `products[${index$1}][comment]`, class: "s-rating-modal-comment" }), index.h("small", { class: "s-rating-modal-validation-msg" })))))
210
210
  : '', this.order.shipping_enabled
211
- ? index.h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "shipping" }, index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }), this.order.shipping.company.logo
212
- ? index.h("div", { class: "s-rating-rounded-icon" }, index.h("img", { src: this.order.shipping.company.logo, class: "s-rating-shipping-logo", alt: this.order.shipping.company.name }))
213
- : index.h("span", { class: "s-rating-icon sicon-shipping-fast" }), index.h("div", { class: "s-rating-title" }, " ", this.rate_shipping + ' ' + this.order.shipping.company.name), index.h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')), index.h("textarea", { name: "comment", class: "s-rating-comment", placeholder: this.write_shipping_rate }), index.h("small", { class: "s-rating-validation-msg" }))
214
- : '', index.h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el }, index.h("span", { class: "s-rating-icon sicon-check-circle2" }), index.h("h3", { class: "s-rating-thanks-title" }, this.thanks), index.h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }), index.h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
215
- index.h("div", { class: "s-rating-footer" }, index.h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, this.back), this.stepsCount > 1 ? index.h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => index.h("li", { class: 's-rating-bg-gray s-rating-step-dot' }))) : '', index.h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
211
+ ? index.h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "shipping" }, index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }), this.order.shipping.company.logo
212
+ ? index.h("div", { class: "s-rating-modal-rounded-icon" }, index.h("img", { src: this.order.shipping.company.logo, class: "s-rating-modal-shipping-logo", alt: this.order.shipping.company.name }))
213
+ : index.h("span", { class: "s-rating-modal-icon sicon-shipping-fast" }), index.h("div", { class: "s-rating-modal-title" }, " ", this.rate_shipping + ' ' + this.order.shipping.company.name), index.h("div", { class: "s-rating-modal-stars-company" }, this.renderRatingStars('large')), index.h("textarea", { name: "comment", class: "s-rating-modal-comment", placeholder: this.write_shipping_rate }), index.h("small", { class: "s-rating-modal-validation-msg" }))
214
+ : '', index.h("div", { class: "s-rating-modal-thanks s-rating-modal-hidden", ref: el => this.thanksTab = el }, index.h("span", { class: "s-rating-modal-icon sicon-check-circle2" }), index.h("h3", { class: "s-rating-modal-thanks-title" }, this.thanks), index.h("div", { class: "s-rating-modal-thanks-msg", innerHTML: this.order.thanks_message }), index.h("time", { class: "s-rating-modal-thanks-time", ref: el => this.thanksTime = el }))),
215
+ index.h("div", { class: "s-rating-modal-footer" }, index.h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-modal-btn s-rating-modal-unvisiable" }, this.back), this.stepsCount > 1 ? index.h("ul", { class: "s-rating-modal-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => index.h("li", { class: 's-rating-modal-bg-gray s-rating-modal-step-dot' }))) : '', index.h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
216
216
  : '')));
217
217
  }
218
218
  componentDidRender() {
@@ -224,6 +224,6 @@ const SallaRating = class {
224
224
  }
225
225
  get host() { return index.getElement(this); }
226
226
  };
227
- SallaRating.style = sallaRatingCss;
227
+ SallaRatingModal.style = sallaRatingModalCss;
228
228
 
229
- exports.salla_rating = SallaRating;
229
+ exports.salla_rating_modal = SallaRatingModal;
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-0b5b5867.js');
4
+ const Helper = require('./Helper-98cc9f18.js');
5
+
6
+ const sallaSearchCss = "#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}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";
7
+
8
+ const SallaSearch = class {
9
+ constructor(hostRef) {
10
+ index.registerInstance(this, hostRef);
11
+ var _a;
12
+ Helper.Helper.setHost(this.host);
13
+ this.productSlot = ((_a = Helper.Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
14
+ salla.event.on('search::show', () => this.modal.show());
15
+ salla.event.on('languages::translations.loaded', () => {
16
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
17
+ this.noResultsText = salla.lang.get('common.elements.no_options');
18
+ });
19
+ }
20
+ onModalOpen() {
21
+ this.modal.querySelector('.s-search-input').focus();
22
+ }
23
+ onModalClose() {
24
+ this.modal.querySelector('.s-search-input').value = '';
25
+ this.results = undefined;
26
+ this.afterSearching();
27
+ }
28
+ getDefaultProductSlot() {
29
+ return '<div class="s-search-product-image-container">' +
30
+ ' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
31
+ '</div>' +
32
+ '<div class="s-search-product-details">' +
33
+ ' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
34
+ '</div>';
35
+ }
36
+ //todo:: reset data when closing
37
+ search(e) {
38
+ Helper.Helper.hideElement(this.noResults);
39
+ if (e.target.value.length === 0) {
40
+ this.results = undefined;
41
+ this.afterSearching();
42
+ return;
43
+ }
44
+ if (e.target.value.length <= 2) {
45
+ return;
46
+ }
47
+ //run loading spinner or stop it
48
+ Helper.Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
49
+ salla.search.api.search(e.target.value)
50
+ .then(response => this.results = response)
51
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
52
+ .finally(() => this.afterSearching(/*isEmpty*/ false));
53
+ }
54
+ afterSearching(isEmpty = true) {
55
+ var _a;
56
+ this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
57
+ Helper.Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
58
+ .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
59
+ salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
60
+ }
61
+ render() {
62
+ var _a;
63
+ return (index.h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, index.h("div", { class: "s-search-container", ref: container => this.container = container }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), index.h("span", { class: "s-search-icon" }, index.h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
64
+ _a.data.map(item => index.h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
65
+ .replace(/\{name\}/g, item.name)
66
+ .replace(/\{price\}/g, item.price) //todo:: get discounted price too
67
+ .replace(/\{image\}/g, item.image_url) })), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
68
+ }
69
+ /**
70
+ * Run it one time after load
71
+ */
72
+ componentDidLoad() {
73
+ this.afterSearching();
74
+ }
75
+ get host() { return index.getElement(this); }
76
+ };
77
+ SallaSearch.style = sallaSearchCss;
78
+
79
+ exports.SallaSearch = SallaSearch;