@salla.sa/twilight-components 1.0.32 → 1.0.33

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 (41) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/salla-button_7.cjs.entry.js +6 -5
  3. package/dist/cjs/salla-rating.cjs.entry.js +29 -7
  4. package/dist/cjs/{salla-search-94d97bc0.js → salla-search-62921989.js} +1 -1
  5. package/dist/collection/components/salla-localization/salla-localization.js +2 -1
  6. package/dist/collection/components/salla-login/salla-login.js +1 -1
  7. package/dist/collection/components/salla-modal/salla-modal.js +3 -3
  8. package/dist/collection/components/salla-rating/salla-rating.js +34 -12
  9. package/dist/collection/plugins/tailwind-theme/index.js +1 -0
  10. package/dist/esm/index.js +1 -1
  11. package/dist/esm/salla-button_7.entry.js +6 -5
  12. package/dist/esm/salla-rating.entry.js +29 -7
  13. package/dist/esm/{salla-search-c72c4eb6.js → salla-search-96520d15.js} +1 -1
  14. package/dist/twilight-components/index.esm.js +1 -1
  15. package/dist/twilight-components/p-352ce785.js +1 -0
  16. package/dist/twilight-components/p-a841c013.entry.js +1 -0
  17. package/dist/twilight-components/p-fbfd14a6.entry.js +1 -0
  18. package/dist/twilight-components/twilight-components.esm.js +1 -1
  19. package/dist/types/components/salla-rating/salla-rating.d.ts +10 -0
  20. package/example/.DS_Store +0 -0
  21. package/example/assets/tailwind.css +1 -0
  22. package/example/auth/email/send_verification +0 -0
  23. package/example/auth/email/verify +11 -0
  24. package/example/auth/mobile/send_verification +0 -0
  25. package/example/auth/mobile/verify +9 -0
  26. package/example/dist/demo.js +69 -0
  27. package/example/dist/flags.png +0 -0
  28. package/example/dist/flags@2x.png +0 -0
  29. package/example/dist/intlTelInput.min.css +1 -0
  30. package/example/dist/tailwind.css +5 -0
  31. package/example/dist/translations.js +1 -0
  32. package/example/dist/twilight.js +2 -0
  33. package/example/index.html +63 -72
  34. package/example/rating/products +0 -0
  35. package/example/rating/rating.json +1 -0
  36. package/example/rating/shipping +0 -0
  37. package/example/rating/store +0 -0
  38. package/package.json +1 -1
  39. package/dist/twilight-components/p-622cae84.js +0 -1
  40. package/dist/twilight-components/p-744b4c0c.entry.js +0 -1
  41. package/dist/twilight-components/p-b6f8a19a.entry.js +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaSearch = require('./salla-search-94d97bc0.js');
5
+ const sallaSearch = require('./salla-search-62921989.js');
6
6
  require('./index-714023c8.js');
7
7
  require('./Helper-98cc9f18.js');
8
8
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-714023c8.js');
6
6
  const Helper = require('./Helper-98cc9f18.js');
7
- const sallaSearch = require('./salla-search-94d97bc0.js');
7
+ const sallaSearch = require('./salla-search-62921989.js');
8
8
 
9
9
  const sallaButtonCss = ":host{display:block}";
10
10
 
@@ -92,9 +92,10 @@ const SallaLocalization = class {
92
92
  Helper.Helper.setHost(this.host);
93
93
  salla.event.on('localization::show', () => this.show());
94
94
  salla.event.on('languages::translations.loaded', () => {
95
+ var _a;
95
96
  this.languagesTitle = salla.lang.get('common.titles.language');
96
97
  this.currenciesTitle = salla.lang.get('common.titles.currency');
97
- this.btn.setText(salla.lang.get('common.elements.ok'));
98
+ (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok'));
98
99
  });
99
100
  /**
100
101
  * letting developer to insert his own slot like:
@@ -194,7 +195,7 @@ const SallaModal = class {
194
195
  this.modalClosed.emit();
195
196
  return;
196
197
  }
197
- this.host.classList.remove('hidden');
198
+ this.host.classList.remove('s-hidden');
198
199
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
199
200
  this.modalOpened.emit();
200
201
  }
@@ -226,7 +227,7 @@ const SallaModal = class {
226
227
  //todo:: use united class names
227
228
  .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
228
229
  if (!isOpen) {
229
- setTimeout(() => this.host.classList.add('hidden'), 350);
230
+ setTimeout(() => this.host.classList.add('s-hidden'), 350);
230
231
  }
231
232
  }
232
233
  closeModal() {
@@ -240,7 +241,7 @@ const SallaModal = class {
240
241
  this.host.id = this.host.id || 'salla-modal';
241
242
  return (
242
243
  //todo:: use suitable class name instead of hidden
243
- index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
244
+ index.h(index.Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
244
245
  ? index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
245
246
  :
246
247
  [index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
@@ -13,13 +13,32 @@ const SallaRating = class {
13
13
  this.stepsCount = 0;
14
14
  this.currentIndex = 0;
15
15
  this.submitted = [];
16
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
17
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
18
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
19
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
20
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
21
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
22
+ this.thanks = salla.lang.get('pages.rating.thanks');
23
+ this.back = salla.lang.get('common.elements.back');
24
+ this.next = salla.lang.get('common.elements.next');
16
25
  Helper.Helper.setHost(this.host);
17
26
  salla.event.on('rating::show', () => this.show());
27
+ salla.event.on('languages::translations.loaded', () => {
28
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
29
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
30
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
31
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
32
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
33
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
34
+ this.thanks = salla.lang.get('pages.rating.thanks');
35
+ this.back = salla.lang.get('common.elements.back');
36
+ this.next = salla.lang.get('common.elements.next');
37
+ });
18
38
  }
19
39
  async show() {
20
40
  return this.modal.show()
21
- .then(() => salla.feedback.api.order(salla.config.get('page.id')))
22
- .then(res => this.order = res.data)
41
+ .then(() => this.order || salla.feedback.api.order(salla.config.get('page.id')).then(res => this.order = res.data))
23
42
  .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
24
43
  .then(() => this.modal.stopLoading())
25
44
  .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
@@ -176,21 +195,24 @@ const SallaRating = class {
176
195
  render() {
177
196
  return (index.h(index.Host, null, index.h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
178
197
  ? [index.h("div", { class: "s-rating-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
179
- 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'), alt: "store name", class: "s-rating-store-logo" })), index.h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.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: salla.lang.get('pages.rating.write_store_rate') }), index.h("small", { class: "s-rating-validation-msg" }))
198
+ 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" }))
180
199
  : '', this.order.products_enabled
181
- ? 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": salla.lang.get('pages.rating.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: salla.lang.get('pages.rating.write_product_rate'), name: `products[${index$1}][comment]`, class: "s-rating-comment" }), index.h("small", { class: "s-rating-validation-msg" })))))
200
+ ? 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" })))))
182
201
  : '', this.order.shipping_enabled
183
202
  ? 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
184
203
  ? 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 }))
185
- : index.h("span", { class: "s-rating-icon sicon-shipping-fast" }), index.h("div", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.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: salla.lang.get('pages.rating.write_shipping_rate') }), index.h("small", { class: "s-rating-validation-msg" }))
186
- : '', 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" }, salla.lang.get('pages.rating.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 }))),
187
- 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" }, salla.lang.get('common.elements.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() }, salla.lang.get('common.elements.next'))),]
204
+ : 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" }))
205
+ : '', 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 }))),
206
+ 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)),]
188
207
  : '')));
189
208
  }
190
209
  componentDidRender() {
191
210
  //todo:: know from where there is hidden attributes to the doms🤔
192
211
  this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
193
212
  }
213
+ componentDidLoad() {
214
+ salla.event.dispatch('rating::ready', this);
215
+ }
194
216
  get host() { return index.getElement(this); }
195
217
  };
196
218
  SallaRating.style = sallaRatingCss;
@@ -139,7 +139,7 @@ const SallaLogin = class {
139
139
  showTab(tab, evt) {
140
140
  var _a, _b;
141
141
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
142
- [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
142
+ [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
143
143
  setTimeout(() => {
144
144
  [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab));
145
145
  }, 200);
@@ -14,9 +14,10 @@ export class SallaLocalization {
14
14
  Helper.setHost(this.host);
15
15
  salla.event.on('localization::show', () => this.show());
16
16
  salla.event.on('languages::translations.loaded', () => {
17
+ var _a;
17
18
  this.languagesTitle = salla.lang.get('common.titles.language');
18
19
  this.currenciesTitle = salla.lang.get('common.titles.currency');
19
- this.btn.setText(salla.lang.get('common.elements.ok'));
20
+ (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok'));
20
21
  });
21
22
  /**
22
23
  * letting developer to insert his own slot like:
@@ -133,7 +133,7 @@ export class SallaLogin {
133
133
  showTab(tab, evt) {
134
134
  var _a, _b;
135
135
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
136
- [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
136
+ [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
137
137
  setTimeout(() => {
138
138
  [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab));
139
139
  }, 200);
@@ -34,7 +34,7 @@ export class SallaModal {
34
34
  this.modalClosed.emit();
35
35
  return;
36
36
  }
37
- this.host.classList.remove('hidden');
37
+ this.host.classList.remove('s-hidden');
38
38
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
39
39
  this.modalOpened.emit();
40
40
  }
@@ -66,7 +66,7 @@ export class SallaModal {
66
66
  //todo:: use united class names
67
67
  .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
68
68
  if (!isOpen) {
69
- setTimeout(() => this.host.classList.add('hidden'), 350);
69
+ setTimeout(() => this.host.classList.add('s-hidden'), 350);
70
70
  }
71
71
  }
72
72
  closeModal() {
@@ -80,7 +80,7 @@ export class SallaModal {
80
80
  this.host.id = this.host.id || 'salla-modal';
81
81
  return (
82
82
  //todo:: use suitable class name instead of hidden
83
- h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" },
83
+ h(Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" },
84
84
  h("div", { class: "s-modal-wrapper" },
85
85
  h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }),
86
86
  h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"),
@@ -5,13 +5,32 @@ export class SallaRating {
5
5
  this.stepsCount = 0;
6
6
  this.currentIndex = 0;
7
7
  this.submitted = [];
8
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
9
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
10
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
11
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
12
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
13
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
14
+ this.thanks = salla.lang.get('pages.rating.thanks');
15
+ this.back = salla.lang.get('common.elements.back');
16
+ this.next = salla.lang.get('common.elements.next');
8
17
  Helper.setHost(this.host);
9
18
  salla.event.on('rating::show', () => this.show());
19
+ salla.event.on('languages::translations.loaded', () => {
20
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
21
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
22
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
23
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
24
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
25
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
26
+ this.thanks = salla.lang.get('pages.rating.thanks');
27
+ this.back = salla.lang.get('common.elements.back');
28
+ this.next = salla.lang.get('common.elements.next');
29
+ });
10
30
  }
11
31
  async show() {
12
32
  return this.modal.show()
13
- .then(() => salla.feedback.api.order(salla.config.get('page.id')))
14
- .then(res => this.order = res.data)
33
+ .then(() => this.order || salla.feedback.api.order(salla.config.get('page.id')).then(res => this.order = res.data))
15
34
  .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
16
35
  .then(() => this.modal.stopLoading())
17
36
  .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
@@ -175,16 +194,16 @@ export class SallaRating {
175
194
  this.order.testimonials_enabled ?
176
195
  h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" },
177
196
  h("div", { class: "s-rating-rounded-icon" },
178
- h("img", { src: salla.config.get('store.logo'), alt: "store name", class: "s-rating-store-logo" })),
179
- h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')),
197
+ 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" })),
198
+ h("h2", { class: "s-rating-title" }, this.rate_the_store),
180
199
  h("div", { class: "s-rating-stars-company" },
181
200
  " ",
182
201
  this.renderRatingStars('large')),
183
- h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }),
202
+ h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: this.write_store_rate }),
184
203
  h("small", { class: "s-rating-validation-msg" }))
185
204
  : '',
186
205
  this.order.products_enabled
187
- ? h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars') },
206
+ ? h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": this.rate_product_stars },
188
207
  h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }),
189
208
  h("div", { class: "s-rating-product-details" },
190
209
  h("h3", { class: "s-rating-product-title" },
@@ -194,7 +213,7 @@ export class SallaRating {
194
213
  " ",
195
214
  this.renderRatingStars('small', `products[${index}][rating]`)),
196
215
  h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.product.id }),
197
- h("textarea", { placeholder: salla.lang.get('pages.rating.write_product_rate'), name: `products[${index}][comment]`, class: "s-rating-comment" }),
216
+ h("textarea", { placeholder: this.write_product_rate, name: `products[${index}][comment]`, class: "s-rating-comment" }),
198
217
  h("small", { class: "s-rating-validation-msg" })))))
199
218
  : '',
200
219
  this.order.shipping_enabled
@@ -206,26 +225,29 @@ export class SallaRating {
206
225
  : h("span", { class: "s-rating-icon sicon-shipping-fast" }),
207
226
  h("div", { class: "s-rating-title" },
208
227
  " ",
209
- salla.lang.get('pages.rating.rate_shipping') + ' ' + this.order.shipping.company.name),
228
+ this.rate_shipping + ' ' + this.order.shipping.company.name),
210
229
  h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')),
211
- h("textarea", { name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }),
230
+ h("textarea", { name: "comment", class: "s-rating-comment", placeholder: this.write_shipping_rate }),
212
231
  h("small", { class: "s-rating-validation-msg" }))
213
232
  : '',
214
233
  h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el },
215
234
  h("span", { class: "s-rating-icon sicon-check-circle2" }),
216
- h("h3", { class: "s-rating-thanks-title" }, salla.lang.get('pages.rating.thanks')),
235
+ h("h3", { class: "s-rating-thanks-title" }, this.thanks),
217
236
  h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }),
218
237
  h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
219
238
  h("div", { class: "s-rating-footer" },
220
- h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, salla.lang.get('common.elements.back')),
239
+ h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, this.back),
221
240
  this.stepsCount > 1 ? h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => h("li", { class: 's-rating-bg-gray s-rating-step-dot' }))) : '',
222
- h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, salla.lang.get('common.elements.next'))),]
241
+ h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
223
242
  : '')));
224
243
  }
225
244
  componentDidRender() {
226
245
  //todo:: know from where there is hidden attributes to the doms🤔
227
246
  this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
228
247
  }
248
+ componentDidLoad() {
249
+ salla.event.dispatch('rating::ready', this);
250
+ }
229
251
  static get is() { return "salla-rating"; }
230
252
  static get originalStyleUrls() { return {
231
253
  "$": ["salla-rating.css"]
@@ -2,6 +2,7 @@ module.exports = require('tailwindcss/plugin').withOptions(() => {
2
2
  return function ({addUtilities}) {
3
3
  addUtilities({
4
4
  // TODO :: find if there are used and defined them here if its.
5
+ '.s-hidden' : {'@apply hidden': {}},
5
6
  '.text-md' : {},
6
7
  '.has-error' : {'@apply border-red-400 focus:border-red-500': {}},
7
8
  '.rounded-icon' : {'@apply w-16 h-16 flex justify-center items-center rounded-full text-3xl': {}},
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { S as SallaLogin, a as SallaSearch } from './salla-search-c72c4eb6.js';
1
+ export { S as SallaLogin, a as SallaSearch } from './salla-search-96520d15.js';
2
2
  import './index-a1bf769d.js';
3
3
  import './Helper-7162a06c.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-a1bf769d.js';
2
2
  import { H as Helper } from './Helper-7162a06c.js';
3
- export { S as salla_login, a as salla_search } from './salla-search-c72c4eb6.js';
3
+ export { S as salla_login, a as salla_search } from './salla-search-96520d15.js';
4
4
 
5
5
  const sallaButtonCss = ":host{display:block}";
6
6
 
@@ -88,9 +88,10 @@ const SallaLocalization = class {
88
88
  Helper.setHost(this.host);
89
89
  salla.event.on('localization::show', () => this.show());
90
90
  salla.event.on('languages::translations.loaded', () => {
91
+ var _a;
91
92
  this.languagesTitle = salla.lang.get('common.titles.language');
92
93
  this.currenciesTitle = salla.lang.get('common.titles.currency');
93
- this.btn.setText(salla.lang.get('common.elements.ok'));
94
+ (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok'));
94
95
  });
95
96
  /**
96
97
  * letting developer to insert his own slot like:
@@ -190,7 +191,7 @@ const SallaModal = class {
190
191
  this.modalClosed.emit();
191
192
  return;
192
193
  }
193
- this.host.classList.remove('hidden');
194
+ this.host.classList.remove('s-hidden');
194
195
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
195
196
  this.modalOpened.emit();
196
197
  }
@@ -222,7 +223,7 @@ const SallaModal = class {
222
223
  //todo:: use united class names
223
224
  .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
224
225
  if (!isOpen) {
225
- setTimeout(() => this.host.classList.add('hidden'), 350);
226
+ setTimeout(() => this.host.classList.add('s-hidden'), 350);
226
227
  }
227
228
  }
228
229
  closeModal() {
@@ -236,7 +237,7 @@ const SallaModal = class {
236
237
  this.host.id = this.host.id || 'salla-modal';
237
238
  return (
238
239
  //todo:: use suitable class name instead of hidden
239
- h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
240
+ h(Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
240
241
  ? h("div", { class: "s-modal-loader-wrap" }, h("span", { class: "s-modal-loader" }))
241
242
  :
242
243
  [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
@@ -9,13 +9,32 @@ const SallaRating = class {
9
9
  this.stepsCount = 0;
10
10
  this.currentIndex = 0;
11
11
  this.submitted = [];
12
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
13
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
14
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
15
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
16
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
17
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
18
+ this.thanks = salla.lang.get('pages.rating.thanks');
19
+ this.back = salla.lang.get('common.elements.back');
20
+ this.next = salla.lang.get('common.elements.next');
12
21
  Helper.setHost(this.host);
13
22
  salla.event.on('rating::show', () => this.show());
23
+ salla.event.on('languages::translations.loaded', () => {
24
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
25
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
26
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
27
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
28
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
29
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
30
+ this.thanks = salla.lang.get('pages.rating.thanks');
31
+ this.back = salla.lang.get('common.elements.back');
32
+ this.next = salla.lang.get('common.elements.next');
33
+ });
14
34
  }
15
35
  async show() {
16
36
  return this.modal.show()
17
- .then(() => salla.feedback.api.order(salla.config.get('page.id')))
18
- .then(res => this.order = res.data)
37
+ .then(() => this.order || salla.feedback.api.order(salla.config.get('page.id')).then(res => this.order = res.data))
19
38
  .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
20
39
  .then(() => this.modal.stopLoading())
21
40
  .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
@@ -172,21 +191,24 @@ const SallaRating = class {
172
191
  render() {
173
192
  return (h(Host, null, h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
174
193
  ? [h("div", { class: "s-rating-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
175
- h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" }, h("div", { class: "s-rating-rounded-icon" }, h("img", { src: salla.config.get('store.logo'), alt: "store name", class: "s-rating-store-logo" })), h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')), h("div", { class: "s-rating-stars-company" }, " ", this.renderRatingStars('large')), h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "s-rating-validation-msg" }))
194
+ h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" }, h("div", { class: "s-rating-rounded-icon" }, 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" })), h("h2", { class: "s-rating-title" }, this.rate_the_store), h("div", { class: "s-rating-stars-company" }, " ", this.renderRatingStars('large')), h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: this.write_store_rate }), h("small", { class: "s-rating-validation-msg" }))
176
195
  : '', this.order.products_enabled
177
- ? h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars') }, h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }), h("div", { class: "s-rating-product-details" }, h("h3", { class: "s-rating-product-title" }, " ", item.product.name), h("div", { class: "s-rating-stars-product" }, " ", this.renderRatingStars('small', `products[${index}][rating]`)), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.product.id }), h("textarea", { placeholder: salla.lang.get('pages.rating.write_product_rate'), name: `products[${index}][comment]`, class: "s-rating-comment" }), h("small", { class: "s-rating-validation-msg" })))))
196
+ ? h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": this.rate_product_stars }, h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }), h("div", { class: "s-rating-product-details" }, h("h3", { class: "s-rating-product-title" }, " ", item.product.name), h("div", { class: "s-rating-stars-product" }, " ", this.renderRatingStars('small', `products[${index}][rating]`)), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.product.id }), h("textarea", { placeholder: this.write_product_rate, name: `products[${index}][comment]`, class: "s-rating-comment" }), h("small", { class: "s-rating-validation-msg" })))))
178
197
  : '', this.order.shipping_enabled
179
198
  ? h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "shipping" }, h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }), this.order.shipping.company.logo
180
199
  ? h("div", { class: "s-rating-rounded-icon" }, h("img", { src: this.order.shipping.company.logo, class: "s-rating-shipping-logo", alt: this.order.shipping.company.name }))
181
- : h("span", { class: "s-rating-icon sicon-shipping-fast" }), h("div", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.rate_shipping') + ' ' + this.order.shipping.company.name), h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')), h("textarea", { name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "s-rating-validation-msg" }))
182
- : '', h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el }, h("span", { class: "s-rating-icon sicon-check-circle2" }), h("h3", { class: "s-rating-thanks-title" }, salla.lang.get('pages.rating.thanks')), h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }), h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
183
- h("div", { class: "s-rating-footer" }, h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, salla.lang.get('common.elements.back')), this.stepsCount > 1 ? h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => h("li", { class: 's-rating-bg-gray s-rating-step-dot' }))) : '', h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, salla.lang.get('common.elements.next'))),]
200
+ : h("span", { class: "s-rating-icon sicon-shipping-fast" }), h("div", { class: "s-rating-title" }, " ", this.rate_shipping + ' ' + this.order.shipping.company.name), h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')), h("textarea", { name: "comment", class: "s-rating-comment", placeholder: this.write_shipping_rate }), h("small", { class: "s-rating-validation-msg" }))
201
+ : '', h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el }, h("span", { class: "s-rating-icon sicon-check-circle2" }), h("h3", { class: "s-rating-thanks-title" }, this.thanks), h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }), h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
202
+ h("div", { class: "s-rating-footer" }, h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, this.back), this.stepsCount > 1 ? h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => h("li", { class: 's-rating-bg-gray s-rating-step-dot' }))) : '', h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
184
203
  : '')));
185
204
  }
186
205
  componentDidRender() {
187
206
  //todo:: know from where there is hidden attributes to the doms🤔
188
207
  this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
189
208
  }
209
+ componentDidLoad() {
210
+ salla.event.dispatch('rating::ready', this);
211
+ }
190
212
  get host() { return getElement(this); }
191
213
  };
192
214
  SallaRating.style = sallaRatingCss;
@@ -137,7 +137,7 @@ const SallaLogin = class {
137
137
  showTab(tab, evt) {
138
138
  var _a, _b;
139
139
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
140
- [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
140
+ [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
141
141
  setTimeout(() => {
142
142
  [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab));
143
143
  }, 200);
@@ -1 +1 @@
1
- export{S as SallaLogin,a as SallaSearch}from"./p-622cae84.js";import"./p-6a5be894.js";import"./p-ed1c00c5.js";
1
+ export{S as SallaLogin,a as SallaSearch}from"./p-352ce785.js";import"./p-6a5be894.js";import"./p-ed1c00c5.js";
@@ -0,0 +1 @@
1
+ import{r as s,h as i,g as t}from"./p-6a5be894.js";import{H as a}from"./p-ed1c00c5.js";const l=class{constructor(i){s(this,i),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 t=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==t?void 0:t.classList.contains("s-login-error-message"))&&(t.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=()=>{a.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:t,countryKey:a}=await this.regTelInput.getValues(),l=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:t,country_key:a,verified_by:this.regType};l&&(e=Object.assign(Object.assign({},e),{email:l})),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;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}),null===(s=this.modal)||void 0===s||s.setTitle(this.title)})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show()))}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!")}onbackClicked(){this.showTab("phone"==this.regType?this.mobileTab:this.emailTab)}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 t,l;null==i||i.preventDefault(),[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab].map((i=>a.toggleElement(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>{[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab].map((i=>a.toggleElement(i,"s-login-active","s-login-unactive",(()=>i==s))))}),200),setTimeout((()=>{this.host.querySelector(".s-login-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 e=s==this.registrationTab;return e&&(null===(t=this.firstName)||void 0===t||t.focus()),null===(l=this.modal)||void 0===l||l.setTitle(e?salla.lang.get("common.titles.registration"):this.title),e||a.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,t=a.isValidEmail(i),l=this.firstName.value.length>0,e=this.lastName.value.length>0,h=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&t||!i&&!this.isEmailRequired)&&h&&l&&e))throw!t&&this.validateField(this.regEmail,this.emailErrorMsg),!l&&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-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-sub-title"},this.loginTypeTitle),i("a",{href:"#",class:"s-login-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-main-btn-icon sicon-phone"}),i("span",{class:"s-login-main-btn-text"},this.smsLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("a",{href:"#",class:"s-login-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-main-btn-icon sicon-mail"}),i("span",{class:"s-login-main-btn-text"},this.emailLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"}))):"",this.isMobileAllowed?i("div",{class:"s-login-tab",ref:s=>this.mobileTab=s},i("label",{class:"s-login-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",wide:!0,onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},this.enterText),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-link"},this.byEmailText):""):"",this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.emailTab=s},i("label",{class:"s-login-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-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},this.enterText),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-link"},this.bySMSText):""):"",i("salla-verify",{"without-modal":!0,ref:s=>this.verifyTab=s,autoReload:!1,"is-show-back":!0}),i("div",{ref:s=>this.registrationTab=s},i("label",{class:"s-login-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-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-error-message"}),i("label",{class:"s-login-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-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-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-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-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-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("salla-button",{"loader-position":"center",wide:!0,onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")))))}get host(){return t(this)}};l.style="salla-verify{display:block}#salla-login .s-modal-body{overflow:inherit}";const e=class{constructor(i){var t;s(this,i),a.setHost(this.host),this.productSlot=(null===(t=a.getElement('[slot="product"]'))||void 0===t?void 0:t.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()}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-name">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(a.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(a.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 i;this.noResults.style.display=s||(null===(i=this.results)||void 0===i?void 0:i.data.length)>0?"none":"block",a.toggleElement(this.container,"s-search-container-open","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=""}render(){var s;return i("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},i("div",{class:"s-search-container",ref:s=>this.container=s},i("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),i("span",{class:"s-search-icon"},i("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),i("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>i("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)}))),i("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText))))}componentDidLoad(){this.afterSearching()}get host(){return t(this)}};e.style="#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:1rem}";export{l as S,e as a}
@@ -0,0 +1 @@
1
+ import{r as s,h as t,H as a,g as i}from"./p-6a5be894.js";import{H as e}from"./p-ed1c00c5.js";const r=class{constructor(t){s(this,t),this.stepsCount=0,this.currentIndex=0,this.submitted=[],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"),e.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(salla.config.get("page.id")).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-stars-element",(function(s){s.preventDefault();let t=s.target.querySelectorAll(".s-rating-btn-star.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-btn-star").forEach(((s,t)=>e.toggleElement(s,"selected","un-selected",(()=>t<i)))),s.target.querySelectorAll('.s-rating-btn-star[aria-pressed="true"]').forEach((s=>s.removeAttribute("aria-pressed"))),a.setAttribute("aria-pressed","")}))}handleWizard(){this.steps=this.host.querySelectorAll(".s-rating-step"),this.dots=this.host.querySelectorAll(".s-rating-step-dot"),this.showActiveStep()}showActiveStep(s=null){var t;this.currentTab=s||this.steps[this.currentIndex],e.toggle(".s-rating-step-dot","s-rating-bg-gray","s-rating-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggle(".s-rating-step","s-rating-active","s-rating-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(e.toggleElement(this.currentTab,"s-rating-unactive","s-rating-hidden",(()=>!0)),setTimeout((()=>e.toggleElement(this.currentTab,"s-rating-active","s-rating-unactive",(()=>!0))),300));let a=null===(t=this.steps[this.currentIndex+1])||void 0===t?void 0:t.dataset.type;this.nextBtn.querySelector(".s-button-text").innerHTML=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=["hovered"];e.all(".s-rating-stars-element",(t=>{let a=t.querySelectorAll(".s-rating-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--,e.toggleElement(this.backBtn,"s-rating-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-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>e.toggle("#prev-btn","block","s-rating-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-comment"),r=s.querySelector(".s-rating-validation-msg");if(a&&i.value&&i.value.length>3)return i.classList.remove("s-rating-has-error"),void(r.innerHTML="");throw t=t||s.dataset.type,e.toggleElement(i,"save","s-rating-has-error",(s=>s.value.length>3)),r.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=salla.config.get("page.id"),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-footer").classList.add("s-rating-unvisiable"),this.showActiveStep(this.thanksTab)}renderRatingStars(s,a="rating"){return t("form",{class:"s-rating-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-btn-star s-rating-btn-star-"+s,"data-star":a},t("i",{class:"sicon-star2"})))))}render(){return t(a,null,t("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[t("div",{class:"s-rating-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?t("div",{class:"rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden","data-type":"store"},t("div",{class:"s-rating-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-store-logo"})),t("h2",{class:"s-rating-title"},this.rate_the_store),t("div",{class:"s-rating-stars-company"}," ",this.renderRatingStars("large")),t("textarea",{id:"storeReview",name:"comment",class:"s-rating-comment",placeholder:this.write_store_rate}),t("small",{class:"s-rating-validation-msg"})):"",this.order.products_enabled?t("section",{class:"s-rating-step s-rating-hidden","data-type":"products"},this.order.products.map(((s,a)=>t("div",{class:"rating-outer-form s-rating-product","data-stars-error":this.rate_product_stars},t("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-product-img"}),t("div",{class:"s-rating-product-details"},t("h3",{class:"s-rating-product-title"}," ",s.product.name),t("div",{class:"s-rating-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-comment"}),t("small",{class:"s-rating-validation-msg"})))))):"",this.order.shipping_enabled?t("div",{class:"rating-outer-form s-rating-step-wrap s-rating-step s-rating-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-rounded-icon"},t("img",{src:this.order.shipping.company.logo,class:"s-rating-shipping-logo",alt:this.order.shipping.company.name})):t("span",{class:"s-rating-icon sicon-shipping-fast"}),t("div",{class:"s-rating-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),t("div",{class:"s-rating-stars-company"},this.renderRatingStars("large")),t("textarea",{name:"comment",class:"s-rating-comment",placeholder:this.write_shipping_rate}),t("small",{class:"s-rating-validation-msg"})):"",t("div",{class:"s-rating-thanks s-rating-hidden",ref:s=>this.thanksTab=s},t("span",{class:"s-rating-icon sicon-check-circle2"}),t("h3",{class:"s-rating-thanks-title"},this.thanks),t("div",{class:"s-rating-thanks-msg",innerHTML:this.order.thanks_message}),t("time",{class:"s-rating-thanks-time",ref:s=>this.thanksTime=s}))),t("div",{class:"s-rating-footer"},t("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-btn s-rating-unvisiable"},this.back),this.stepsCount>1?t("ul",{class:"s-rating-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>t("li",{class:"s-rating-bg-gray s-rating-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)}};r.style=":host{display:block}.unicode{unicode-bidi:plaintext}";export{r as salla_rating}