@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
@@ -1,6 +1,6 @@
1
1
  import { Component, h, Method, Element, Host, State, Prop } from '@stencil/core';
2
2
  import Helper from "../../Helpers/Helper";
3
- export class SallaRating {
3
+ export class SallaRatingModal {
4
4
  constructor() {
5
5
  this.stepsCount = 0;
6
6
  this.currentIndex = 0;
@@ -52,11 +52,11 @@ export class SallaRating {
52
52
  initiateRating() {
53
53
  this.handleWizard();
54
54
  this.highlightSelectedStars();
55
- salla.document.event.onSubmit('.s-rating-stars-element', function (event) {
55
+ salla.document.event.onSubmit('.s-rating-modal-stars-element', function (event) {
56
56
  // Prevent form from submitting
57
57
  event.preventDefault();
58
58
  // Get the selected star - activeElement is not supported in safari
59
- let activeStars = event.target.querySelectorAll('.s-rating-btn-star.s-rating-hovered');
59
+ let activeStars = event.target.querySelectorAll('.s-rating-modal-btn-star.s-rating-modal-hovered');
60
60
  let selected = activeStars[activeStars.length - 1];
61
61
  if (!selected)
62
62
  return;
@@ -65,29 +65,29 @@ export class SallaRating {
65
65
  // Get all stars in this form (only search in the form, not the whole document)
66
66
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
67
67
  event.target
68
- .querySelectorAll('.s-rating-btn-star')
69
- .forEach((star, index) => Helper.toggleElement(star, 's-rating-selected', 's-rating-un-selected', () => index < selectedIndex));
68
+ .querySelectorAll('.s-rating-modal-btn-star')
69
+ .forEach((star, index) => Helper.toggleElement(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
70
70
  // Remove aria-pressed from any previously selected star
71
- event.target.querySelectorAll('.s-rating-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
71
+ event.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
72
72
  // Add aria-pressed role to the selected button
73
73
  selected.setAttribute('aria-pressed', '');
74
74
  });
75
75
  }
76
76
  // handle wizard
77
77
  handleWizard() {
78
- this.steps = this.host.querySelectorAll(".s-rating-step");
79
- this.dots = this.host.querySelectorAll(".s-rating-step-dot");
78
+ this.steps = this.host.querySelectorAll(".s-rating-modal-step");
79
+ this.dots = this.host.querySelectorAll(".s-rating-modal-step-dot");
80
80
  this.showActiveStep();
81
81
  }
82
82
  showActiveStep(current = null) {
83
83
  var _a;
84
84
  this.currentTab = current || this.steps[this.currentIndex];
85
- Helper.toggle('.s-rating-step-dot', 's-rating-bg-gray', 's-rating-bg-primary', dot => dot != this.dots[this.currentIndex])
86
- .toggle('.s-rating-step', 's-rating-active', 's-rating-hidden', tab => tab == this.currentTab);
85
+ Helper.toggle('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
86
+ .toggle('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
87
87
  if (this.currentIndex != 0) {
88
88
  // the animation
89
- Helper.toggleElement(this.currentTab, 's-rating-unactive', 's-rating-hidden', () => true);
90
- setTimeout(() => Helper.toggleElement(this.currentTab, 's-rating-active', 's-rating-unactive', () => true), 300);
89
+ Helper.toggleElement(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
90
+ setTimeout(() => Helper.toggleElement(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
91
91
  }
92
92
  // Btn text
93
93
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
@@ -96,9 +96,9 @@ export class SallaRating {
96
96
  setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
97
97
  }
98
98
  highlightSelectedStars() {
99
- let hover = ['s-rating-hovered'];
100
- Helper.all('.s-rating-stars-element', el => {
101
- let starElements = el.querySelectorAll('.s-rating-btn-star');
99
+ let hover = ['s-rating-modal-hovered'];
100
+ Helper.all('.s-rating-modal-stars-element', el => {
101
+ let starElements = el.querySelectorAll('.s-rating-modal-btn-star');
102
102
  // remove hovered state from stars ---
103
103
  el.addEventListener('mouseout', () => starElements.forEach(star => star.classList.remove(...hover)));
104
104
  starElements.forEach((starElement, index) => {
@@ -119,7 +119,7 @@ export class SallaRating {
119
119
  }
120
120
  previousTab() {
121
121
  this.currentIndex > 0 && this.currentIndex--;
122
- Helper.toggleElement(this.backBtn, 's-rating-unvisiable', 'block', () => this.currentIndex == 0);
122
+ Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
123
123
  this.showActiveStep();
124
124
  }
125
125
  submit() {
@@ -127,10 +127,10 @@ export class SallaRating {
127
127
  salla.config.canLeave = false;
128
128
  this.nextBtn.load()
129
129
  .then(() => this.submittedBefore() || this.sendFeedback())
130
- .then(() => this.currentTab.querySelectorAll('[name],.s-rating-btn-star').forEach(el => el.setAttribute('disabled', '')))
130
+ .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
131
131
  .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
132
132
  .then(() => this.showActiveStep())
133
- .then(() => Helper.toggle('#prev-btn', 'block', 's-rating-unvisiable', () => true))
133
+ .then(() => Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
134
134
  .finally(() => {
135
135
  this.nextBtn.stop();
136
136
  salla.config.canLeave = true;
@@ -147,8 +147,8 @@ export class SallaRating {
147
147
  }
148
148
  rating = rating || this.currentTab;
149
149
  let stars = rating.querySelector('.rating_hidden_input').value;
150
- let comment = rating.querySelector('.s-rating-comment');
151
- let validationMessage = rating.querySelector('.s-rating-validation-msg');
150
+ let comment = rating.querySelector('.s-rating-modal-comment');
151
+ let validationMessage = rating.querySelector('.s-rating-modal-validation-msg');
152
152
  if (stars && comment.value && comment.value.length > 3) {
153
153
  comment.classList.remove('s-has-error');
154
154
  validationMessage.innerHTML = '';
@@ -186,67 +186,67 @@ export class SallaRating {
186
186
  this.thanksTime.remove();
187
187
  this.hide().then(() => window.location.reload());
188
188
  }, 1000);
189
- this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
189
+ this.host.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
190
190
  this.showActiveStep(this.thanksTab);
191
191
  }
192
192
  renderRatingStars(size, name = 'rating') {
193
- return (h("form", { class: "s-rating-stars-element" },
193
+ return (h("form", { class: "s-rating-modal-stars-element" },
194
194
  h("input", { type: "hidden", class: "rating_hidden_input", name: name, value: "" }),
195
- [1, 2, 3, 4, 5].map(star => h("button", { type: "submit", class: `s-rating-btn-star s-rating-btn-star-` + size, "data-star": star },
195
+ [1, 2, 3, 4, 5].map(star => h("button", { type: "submit", class: `s-rating-modal-btn-star s-rating-modal-btn-star-` + size, "data-star": star },
196
196
  h("i", { class: "sicon-star2" })))));
197
197
  }
198
198
  // render
199
199
  render() {
200
200
  return (h(Host, { id: "s-rating" },
201
201
  h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
202
- ? [h("div", { class: "s-rating-wrapper", ref: el => this.body = el },
202
+ ? [h("div", { class: "s-rating-modal-wrapper", ref: el => this.body = el },
203
203
  this.order.testimonials_enabled ?
204
- h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" },
205
- h("div", { class: "s-rating-rounded-icon" },
206
- 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" })),
207
- h("h2", { class: "s-rating-title" }, this.rate_the_store),
208
- h("div", { class: "s-rating-stars-company" },
204
+ h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "store" },
205
+ h("div", { class: "s-rating-modal-rounded-icon" },
206
+ 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" })),
207
+ h("h2", { class: "s-rating-modal-title" }, this.rate_the_store),
208
+ h("div", { class: "s-rating-modal-stars-company" },
209
209
  " ",
210
210
  this.renderRatingStars('large')),
211
- h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: this.write_store_rate }),
212
- h("small", { class: "s-rating-validation-msg" }))
211
+ h("textarea", { id: "storeReview", name: "comment", class: "s-rating-modal-comment", placeholder: this.write_store_rate }),
212
+ h("small", { class: "s-rating-modal-validation-msg" }))
213
213
  : '',
214
214
  this.order.products_enabled
215
- ? 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 },
216
- h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }),
217
- h("div", { class: "s-rating-product-details" },
218
- h("h3", { class: "s-rating-product-title" },
215
+ ? h("section", { class: "s-rating-modal-step s-rating-modal-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-modal-product", "data-stars-error": this.rate_product_stars },
216
+ h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-modal-product-img" }),
217
+ h("div", { class: "s-rating-modal-product-details" },
218
+ h("h3", { class: "s-rating-modal-product-title" },
219
219
  " ",
220
220
  item.product.name),
221
- h("div", { class: "s-rating-stars-product" },
221
+ h("div", { class: "s-rating-modal-stars-product" },
222
222
  " ",
223
223
  this.renderRatingStars('small', `products[${index}][rating]`)),
224
224
  h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.product.id }),
225
- h("textarea", { placeholder: this.write_product_rate, name: `products[${index}][comment]`, class: "s-rating-comment" }),
226
- h("small", { class: "s-rating-validation-msg" })))))
225
+ h("textarea", { placeholder: this.write_product_rate, name: `products[${index}][comment]`, class: "s-rating-modal-comment" }),
226
+ h("small", { class: "s-rating-modal-validation-msg" })))))
227
227
  : '',
228
228
  this.order.shipping_enabled
229
- ? h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "shipping" },
229
+ ? h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "shipping" },
230
230
  h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }),
231
231
  this.order.shipping.company.logo
232
- ? h("div", { class: "s-rating-rounded-icon" },
233
- h("img", { src: this.order.shipping.company.logo, class: "s-rating-shipping-logo", alt: this.order.shipping.company.name }))
234
- : h("span", { class: "s-rating-icon sicon-shipping-fast" }),
235
- h("div", { class: "s-rating-title" },
232
+ ? h("div", { class: "s-rating-modal-rounded-icon" },
233
+ h("img", { src: this.order.shipping.company.logo, class: "s-rating-modal-shipping-logo", alt: this.order.shipping.company.name }))
234
+ : h("span", { class: "s-rating-modal-icon sicon-shipping-fast" }),
235
+ h("div", { class: "s-rating-modal-title" },
236
236
  " ",
237
237
  this.rate_shipping + ' ' + this.order.shipping.company.name),
238
- h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')),
239
- h("textarea", { name: "comment", class: "s-rating-comment", placeholder: this.write_shipping_rate }),
240
- h("small", { class: "s-rating-validation-msg" }))
238
+ h("div", { class: "s-rating-modal-stars-company" }, this.renderRatingStars('large')),
239
+ h("textarea", { name: "comment", class: "s-rating-modal-comment", placeholder: this.write_shipping_rate }),
240
+ h("small", { class: "s-rating-modal-validation-msg" }))
241
241
  : '',
242
- h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el },
243
- h("span", { class: "s-rating-icon sicon-check-circle2" }),
244
- h("h3", { class: "s-rating-thanks-title" }, this.thanks),
245
- h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }),
246
- h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
247
- h("div", { class: "s-rating-footer" },
248
- h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, this.back),
249
- 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' }))) : '',
242
+ h("div", { class: "s-rating-modal-thanks s-rating-modal-hidden", ref: el => this.thanksTab = el },
243
+ h("span", { class: "s-rating-modal-icon sicon-check-circle2" }),
244
+ h("h3", { class: "s-rating-modal-thanks-title" }, this.thanks),
245
+ h("div", { class: "s-rating-modal-thanks-msg", innerHTML: this.order.thanks_message }),
246
+ h("time", { class: "s-rating-modal-thanks-time", ref: el => this.thanksTime = el }))),
247
+ h("div", { class: "s-rating-modal-footer" },
248
+ h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-modal-btn s-rating-modal-unvisiable" }, this.back),
249
+ this.stepsCount > 1 ? h("ul", { class: "s-rating-modal-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => h("li", { class: 's-rating-modal-bg-gray s-rating-modal-step-dot' }))) : '',
250
250
  h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
251
251
  : '')));
252
252
  }
@@ -257,12 +257,12 @@ export class SallaRating {
257
257
  componentDidLoad() {
258
258
  salla.event.dispatch('rating::ready', this);
259
259
  }
260
- static get is() { return "salla-rating"; }
260
+ static get is() { return "salla-rating-modal"; }
261
261
  static get originalStyleUrls() { return {
262
- "$": ["salla-rating.scss"]
262
+ "$": ["salla-rating-modal.scss"]
263
263
  }; }
264
264
  static get styleUrls() { return {
265
- "$": ["salla-rating.css"]
265
+ "$": ["salla-rating-modal.css"]
266
266
  }; }
267
267
  static get properties() { return {
268
268
  "orderId": {
@@ -1,2 +1,2 @@
1
- export * from './components/salla-login/salla-login';
1
+ export * from './components/salla-login-modal/salla-login-modal';
2
2
  export * from './components/salla-search/salla-search';
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { S as SallaLogin, a as SallaSearch } from './salla-search-813732a1.js';
1
+ export { S as SallaLoginModal } from './salla-login-modal-187c1f98.js';
2
+ export { S as SallaSearch } from './salla-search-2e3e60cb.js';
2
3
  import './index-8b97d225.js';
3
4
  import './Helper-7162a06c.js';
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
13
+ return bootstrapLazy([["salla-button",[[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -0,0 +1,112 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
+ import { H as Helper } from './Helper-7162a06c.js';
3
+
4
+ const sallaButtonCss = "";
5
+
6
+ const SallaButton = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ /**
10
+ * Button Style
11
+ */
12
+ this.btnStyle = 'primary';
13
+ /**
14
+ * Is the button currently loading
15
+ */
16
+ this.loading = false;
17
+ /**
18
+ * Is the button currently disabled
19
+ */
20
+ this.disabled = false;
21
+ /**
22
+ * If there is need to change loader position, pass the position
23
+ */
24
+ this.loaderPosition = 'after';
25
+ /**
26
+ * Is the button wide
27
+ */
28
+ this.wide = false;
29
+ this.hostAttributes = {};
30
+ for (let i = 0; i < this.host.attributes.length; i++) {
31
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
32
+ }
33
+ this.hostAttributes.type = this.hostAttributes.type || 'button';
34
+ this.hostAttributes.class += ' s-button-btn btn--has-loading'
35
+ + ' s-button-' + this.btnStyle
36
+ + (this.wide ? ' s-button-wide ' : '')
37
+ + ' s-button-btn-loader-' + this.loaderPosition //todo:: it looks there is no need for this class🤔
38
+ + (this.loaderPosition == 'after' ? ' s-button-loader-after' : '');
39
+ delete this.hostAttributes['btn-style'];
40
+ delete this.hostAttributes['id'];
41
+ delete this.hostAttributes['data-on-click'];
42
+ if (this.wide) {
43
+ this.host.classList.add('s-button-wide');
44
+ }
45
+ }
46
+ /**
47
+ * Run loading animation
48
+ */
49
+ async load() {
50
+ if (this.loaderPosition == 'center')
51
+ this.text.classList.add('s-button-hide');
52
+ this.host.setAttribute('loading', '');
53
+ return this.host;
54
+ }
55
+ /**
56
+ * Stop loading animation
57
+ */
58
+ async stop() {
59
+ this.host.removeAttribute('loading');
60
+ if (this.loaderPosition == 'center')
61
+ this.text.classList.remove('s-button-hide');
62
+ return this.host;
63
+ }
64
+ /**
65
+ * Changing the body of the button
66
+ * @param html
67
+ */
68
+ async setText(html) {
69
+ this.text.innerHTML = html;
70
+ return this.host;
71
+ }
72
+ /**
73
+ * Add `disabled` attribute
74
+ */
75
+ async disable() {
76
+ this.host.setAttribute('disabled', '');
77
+ }
78
+ /**
79
+ * Remove `disabled` attribute
80
+ */
81
+ async enable() {
82
+ this.host.removeAttribute('disabled');
83
+ }
84
+ handleVisible(newKind, oldKind) {
85
+ //todo::use united styles
86
+ this.btn.classList.remove('btn-' + oldKind);
87
+ this.btn.classList.add('btn-' + newKind);
88
+ }
89
+ handleLoading(newVal) {
90
+ //todo::use united styles
91
+ Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
92
+ }
93
+ render() {
94
+ return (
95
+ //TODO:: use HOST then fake button behaviours
96
+ h(Host, { class: "s-button-wrap" }, h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: { 's-button-text': true, 's-button-hide': this.loaderPosition == 'center' && this.loading }, ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: {
97
+ //todo::use united styles
98
+ 's-button-loader': true,
99
+ 's-button-loader-start': this.loaderPosition === 'start',
100
+ 's-button-loader-end': this.loaderPosition === 'end',
101
+ 's-button-loader-center': this.loaderPosition === 'center',
102
+ } }) : '')));
103
+ }
104
+ get host() { return getElement(this); }
105
+ static get watchers() { return {
106
+ "btnStyle": ["handleVisible"],
107
+ "loading": ["handleLoading"]
108
+ }; }
109
+ };
110
+ SallaButton.style = sallaButtonCss;
111
+
112
+ export { SallaButton as salla_button };
@@ -0,0 +1,113 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
+ import { H as Helper } from './Helper-7162a06c.js';
3
+
4
+ const sallaLocalizationModalCss = "";
5
+
6
+ const SallaLocalizationModal = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ var _a, _b;
10
+ this.languages = [];
11
+ this.currencies = [];
12
+ this.isLoading = true;
13
+ this.language = salla.config.get('user.language_code');
14
+ this.currency = salla.config.get('user.currency_code');
15
+ Helper.setHost(this.host);
16
+ salla.event.on('localization::show', () => this.show());
17
+ salla.event.on('languages::translations.loaded', () => {
18
+ var _a;
19
+ this.languagesTitle = salla.lang.get('common.titles.language');
20
+ this.currenciesTitle = salla.lang.get('common.titles.currency');
21
+ (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok'));
22
+ });
23
+ /**
24
+ * letting developer to insert his own slot like:
25
+ * <salla-localization>
26
+ * <div slot="language">...{name}....</div>
27
+ * <div slot="currency">...{name}....</div>
28
+ * </salla-localization>
29
+ * Because scoped templates not supported in stencil );
30
+ * we made a workaround to pass language & currency attributes, then replace names in rendering
31
+ */
32
+ this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-modal-label" for="lang-{code}"><span>{name}</span><div class="s-localization-modal-flag flag iti__flag iti__{country_code}"></div></label>';
33
+ this.currencySlot = ((_b = Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-modal-label" for="currency-{code}"><span>{name}</span><small class="s-localization-modal-currency">{code}</small></label>';
34
+ }
35
+ /**
36
+ * Show the component
37
+ */
38
+ async show() {
39
+ return this.modal.show()
40
+ .then(() => this.getLanguages())
41
+ .then(() => this.getCurrencies())
42
+ .then(() => this.isLoading = false);
43
+ }
44
+ /**
45
+ * Hide the component
46
+ */
47
+ async hide() {
48
+ return this.modal.hide();
49
+ }
50
+ async getLanguages() {
51
+ this.language = this.language || salla.config.get('user.language_code');
52
+ return this.languages.length > 1 ? null : await salla.config.languages().then(data => this.languages = data);
53
+ }
54
+ async getCurrencies() {
55
+ this.currency = this.currency || salla.config.get('user.currency_code');
56
+ return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
57
+ }
58
+ onChangeCurrency(event) {
59
+ this.currency = event.target.value;
60
+ }
61
+ onChangeLanguage(event) {
62
+ this.language = event.target.value;
63
+ }
64
+ async submit() {
65
+ let url;
66
+ this.btn.load()
67
+ .then(() => {
68
+ if (!this.currency) {
69
+ salla.log('There is no currency!');
70
+ return;
71
+ }
72
+ if (this.currency === salla.config.get('user.currency_code', 'SAR')) {
73
+ return;
74
+ }
75
+ url = window.location.href;
76
+ return salla.currency.api.change(this.currency);
77
+ })
78
+ .then(() => this.language === salla.config.get('user.language_code', 'ar') || (url = salla.helpers.addParamToUrl('lang', this.language)))
79
+ .then(() => this.btn.stop())
80
+ .then(() => this.hide())
81
+ .then(() => url && (window.location.href = url));
82
+ }
83
+ render() {
84
+ return (h("salla-modal", { isLoading: this.isLoading, id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" }, !this.isLoading ?
85
+ h("div", { class: "s-localization-modal-inner" }, this.languages.length > 1 ?
86
+ h("div", { class: "s-localization-modal-section" }, h("label", { class: "s-localization-modal-title" }, this.languagesTitle), h("div", { class: "s-localization-modal-section-inner" }, this.languages.length < 6 ?
87
+ this.languages.map(lang => h("div", { class: "s-localization-modal-item" }, h("input", { class: "s-localization-modal-input", type: "radio", checked: this.language == lang.iso_code, onChange: () => this.language = lang.iso_code, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), h("div", { id: "language-slot", innerHTML: this.languageSlot
88
+ .replace(/\{name\}/g, lang.name)
89
+ .replace(/\{code\}/g, lang.code)
90
+ .replace(/\{country_code\}/g, lang.country_code) }))) :
91
+ h("select", { class: "s-localization-modal-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, this.languages.map(lang => h("option", { value: lang.code, selected: this.language == lang.code }, lang.name)))))
92
+ : '', this.currencies.length > 1 ?
93
+ h("div", { class: "s-localization-modal-section" }, h("label", { class: "s-localization-modal-title" }, this.currenciesTitle), h("div", { class: "s-localization-modal-section-inner" }, this.currencies.length < 6 ?
94
+ this.currencies.map(currency => h("div", { class: "s-localization-modal-item" }, h("input", { class: "s-localization-modal-input", type: "radio", name: "currency", checked: this.currency == currency.code, onChange: () => this.currency = currency.code, id: 'currency-' + currency.code, value: currency.code }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
95
+ .replace(/\{name\}/g, currency.name)
96
+ .replace(/\{code\}/g, currency.code)
97
+ .replace(/\{country_code\}/g, currency.country_code) }))) :
98
+ h("select", { class: "s-localization-modal-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => h("option", { value: currency.code, selected: this.currency == currency.code }, currency.name)))))
99
+ : '', h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.ok')))
100
+ : ''));
101
+ }
102
+ /**
103
+ * to reduce dom levels we will move slot data into the parent dom
104
+ */
105
+ componentDidRender() {
106
+ this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
107
+ this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
108
+ }
109
+ get host() { return getElement(this); }
110
+ };
111
+ SallaLocalizationModal.style = sallaLocalizationModalCss;
112
+
113
+ export { SallaLocalizationModal as salla_localization_modal };