@salla.sa/twilight-components 1.0.16 → 1.0.17

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 (93) hide show
  1. package/dist/cjs/Helper-8852feaa.js +23 -0
  2. package/dist/cjs/index-0b5b5867.js +1656 -0
  3. package/dist/cjs/index.cjs.js +13 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-branches.cjs.entry.js +92 -0
  6. package/dist/cjs/salla-button_4.cjs.entry.js +299 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +80 -0
  8. package/dist/cjs/salla-login-342876b9.js +118 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +25 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +300 -0
  12. package/dist/cjs/salla-search-28da4616.js +81 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/twilight-components.cjs.js +19 -0
  15. package/dist/collection/Helpers/Helper.js +19 -0
  16. package/dist/collection/collection-manifest.json +21 -0
  17. package/dist/collection/components/generate-summary.js +35 -0
  18. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  19. package/dist/collection/components/salla-branches/salla-branches.js +233 -0
  20. package/dist/collection/components/salla-button/salla-button.css +3 -0
  21. package/dist/collection/components/salla-button/salla-button.js +246 -0
  22. package/dist/collection/components/salla-localization/salla-localization.js +206 -0
  23. package/dist/collection/components/salla-login/salla-login.js +348 -0
  24. package/dist/collection/components/salla-modal/salla-modal.js +459 -0
  25. package/dist/collection/components/salla-offer/salla-offer.js +40 -0
  26. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  27. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  28. package/dist/collection/components/salla-rating/salla-rating.js +483 -0
  29. package/dist/collection/components/salla-search/salla-search.js +132 -0
  30. package/dist/collection/components/salla-verify/salla-verify.js +238 -0
  31. package/dist/collection/index.js +2 -0
  32. package/dist/collection/interfaces/colors.js +1 -0
  33. package/dist/collection/interfaces/index.js +2 -0
  34. package/dist/collection/interfaces/ratio.js +1 -0
  35. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  36. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  37. package/dist/{twilight-components → esm}/Helper-81ac9a8c.js +0 -0
  38. package/dist/esm/index-8b97d225.js +1628 -0
  39. package/dist/esm/index.js +4 -0
  40. package/dist/esm/loader.js +17 -0
  41. package/dist/esm/polyfills/core-js.js +11 -0
  42. package/dist/esm/polyfills/css-shim.js +1 -0
  43. package/dist/esm/polyfills/dom.js +79 -0
  44. package/dist/esm/polyfills/es5-html-element.js +1 -0
  45. package/dist/esm/polyfills/index.js +34 -0
  46. package/dist/esm/polyfills/system.js +6 -0
  47. package/dist/{twilight-components → esm}/salla-branches.entry.js +6 -6
  48. package/dist/esm/salla-button_4.entry.js +292 -0
  49. package/dist/esm/salla-localization.entry.js +76 -0
  50. package/dist/esm/salla-login-32d25ffa.js +116 -0
  51. package/dist/esm/salla-offer.entry.js +21 -0
  52. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +2 -2
  53. package/dist/{twilight-components → esm}/salla-rating.entry.js +73 -70
  54. package/dist/{twilight-components/salla-search-5338c0a1.js → esm/salla-search-f552c487.js} +1 -1
  55. package/dist/esm/salla-search.entry.js +3 -0
  56. package/dist/esm/twilight-components.js +17 -0
  57. package/dist/index.cjs.js +1 -0
  58. package/dist/index.js +1 -0
  59. package/dist/twilight-components/index.esm.js +1 -4
  60. package/dist/twilight-components/p-33990e49.entry.js +1 -0
  61. package/dist/twilight-components/p-36683152.js +1 -0
  62. package/dist/twilight-components/p-3cfede65.entry.js +1 -0
  63. package/dist/twilight-components/p-648661c8.entry.js +1 -0
  64. package/dist/twilight-components/p-93c3ac79.js +1 -0
  65. package/dist/twilight-components/p-9bc28e0c.js +1 -0
  66. package/dist/twilight-components/p-a923a51e.entry.js +1 -0
  67. package/dist/twilight-components/p-bc278b0e.entry.js +1 -0
  68. package/dist/twilight-components/p-cb1c59a2.js +1 -0
  69. package/dist/twilight-components/p-fa04c4b6.entry.js +1 -0
  70. package/dist/twilight-components/p-fa2f0e64.entry.js +1 -0
  71. package/dist/twilight-components/twilight-components.css +1 -3
  72. package/dist/twilight-components/twilight-components.esm.js +1 -125
  73. package/dist/types/components/salla-button/salla-button.d.ts +3 -2
  74. package/dist/types/components/salla-localization/salla-localization.d.ts +8 -0
  75. package/dist/types/components/salla-login/salla-login.d.ts +39 -0
  76. package/dist/types/components/salla-modal/salla-modal.d.ts +12 -4
  77. package/dist/types/components/salla-offer/salla-offer.d.ts +8 -0
  78. package/dist/types/components/salla-rating/salla-rating.d.ts +17 -2
  79. package/dist/types/components/salla-verify/salla-verify.d.ts +16 -6
  80. package/dist/types/components.d.ts +94 -8
  81. package/package.json +2 -1
  82. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  83. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  84. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  85. package/dist/twilight-components/index-8966d27f.js +0 -3010
  86. package/dist/twilight-components/salla-button.entry.js +0 -73
  87. package/dist/twilight-components/salla-localization.entry.js +0 -73
  88. package/dist/twilight-components/salla-login-4d620368.js +0 -12
  89. package/dist/twilight-components/salla-login.entry.js +0 -2
  90. package/dist/twilight-components/salla-modal.entry.js +0 -91
  91. package/dist/twilight-components/salla-search.entry.js +0 -3
  92. package/dist/twilight-components/salla-verify.entry.js +0 -92
  93. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const sallaRatingCss = ":host{display:block}.unicode{unicode-bidi:plaintext}";
@@ -46,6 +46,18 @@ const SallaRating = class {
46
46
  storeLogo: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png",
47
47
  shippingLogo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU"
48
48
  };
49
+ /**
50
+ * Set to true to display store rating step
51
+ */
52
+ this.isStoreRating = false;
53
+ /**
54
+ * Set to true to display products rating step
55
+ */
56
+ this.isProductsRating = false;
57
+ /**
58
+ * Set to true to display shipping rating step
59
+ */
60
+ this.isShippingRating = false;
49
61
  this.ratingChain = Promise.resolve();
50
62
  this.stepsCount = 0;
51
63
  Helper.setHost(this.host);
@@ -65,88 +77,85 @@ const SallaRating = class {
65
77
  this.initiateRating();
66
78
  }
67
79
  initiateRating() {
80
+ this.handleWizard();
81
+ this.handleSubmitRating();
68
82
  this.starsRating();
69
83
  this.highlightSelectedStars();
70
- this.handleWizard();
71
- salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
72
- let seconds = 10;
73
- let timeToClose = setInterval(() => {
74
- seconds--;
75
- this.host.querySelector('.s-rating-thanks-time').innerHTML = `00:0${seconds}`;
76
- if (seconds == 0) {
77
- // this.hide();
78
- clearInterval(timeToClose);
79
- }
80
- }, 1000);
81
- this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
82
- Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
83
- Helper.toggle('.s-rating-thanks', 's-rating-unactive', 's-rating-hidden', () => true);
84
- const thankYouView = this.host.querySelector('.s-rating-thanks');
85
- this.setModalHeight(thankYouView);
86
- setTimeout(() => {
87
- Helper.toggleElement(thankYouView, 's-rating-active', 's-rating-unactive', () => true);
88
- }, 200);
89
- }));
90
84
  }
91
85
  // getdata
92
- getData() {
93
- salla.api.order.endpointsMethods.details = 'get';
94
- salla.order.api.details(salla.config.page.id).then(data => console.log(''));
95
- }
86
+ // private getData() {
87
+ // salla.api.order.endpointsMethods.details = 'get'
88
+ // salla.order.api.details(salla.config.page.id).then(data => console.log(''));
89
+ // }
96
90
  // handle wizard
97
91
  handleWizard() {
98
- var _a;
99
- let index = 0, steps = this.host.querySelectorAll(".s-rating-step"), dots = this.host.querySelectorAll(".s-rating-step-dot"), nextBtnText = this.host.querySelector('#next-btn .btn-text');
92
+ let index = 0, steps = this.host.querySelectorAll(".s-rating-step"), dots = this.host.querySelectorAll(".s-rating-step-dot"), nextBtnText = this.host.querySelector('#next-btn .s-button-text');
100
93
  this.setModalHeight(steps[0]);
101
- this.showActiveStep(steps, dots, index);
102
- nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
94
+ this.showActiveStep(steps, dots, index, nextBtnText);
103
95
  Helper.onClick("#prev-btn", () => {
104
- var _a;
105
96
  index > 0 && index--;
106
- this.showActiveStep(steps, dots, index);
107
- nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
97
+ this.showActiveStep(steps, dots, index, nextBtnText);
108
98
  index == 0 && Helper.toggle('#prev-btn', 's-rating-unvisiable', 'block', () => true);
109
99
  });
110
100
  Helper.onClick("#next-btn", () => {
111
- var _a;
112
101
  this.ratingValidation();
113
102
  if (index == this.stepsCount - 1) {
114
103
  salla.event.dispatch("submit::order-rating");
115
104
  }
116
105
  else {
117
106
  index < this.stepsCount - 1 && index++;
118
- this.showActiveStep(steps, dots, index);
119
- nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
107
+ this.showActiveStep(steps, dots, index, nextBtnText);
120
108
  Helper.toggle('#prev-btn', 'block', 's-rating-unvisiable', () => true);
121
109
  }
122
110
  });
123
111
  }
124
- showActiveStep(steps, dots, currentIndex) {
125
- Helper.toggle('.s-rating-step-dot', 'bg-gray-200', 'bg-primay', () => true);
126
- this.stepsCount > 1 && Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
127
- // hide all steps
112
+ showActiveStep(steps, dots, index, nextBtnText) {
113
+ var _a;
114
+ // Active step
128
115
  Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
129
- Helper.toggleElement(steps[currentIndex], 'block', 's-rating-hidden', () => true); // remove class s-rating-hidde
130
- this.setModalHeight(steps[currentIndex]);
131
- setTimeout(() => {
132
- Helper.toggleElement(steps[currentIndex], 's-rating-active', 's-rating-unactive', () => true);
133
- }, 200);
116
+ Helper.toggleElement(steps[index], 's-rating-unactive', 's-rating-hidden', () => true);
117
+ setTimeout(() => Helper.toggleElement(steps[index], 's-rating-active', 's-rating-unactive', () => true), 200);
118
+ // Hanle dots
119
+ Helper.toggle('.s-rating-step-dot', 's-rating-bg-gray', 's-rating-bg-primary', () => true);
120
+ this.stepsCount > 1 && Helper.toggleElement(dots[index], 's-rating-bg-primary', 's-rating-bg-gray', () => true);
121
+ // Btn text
122
+ nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || salla.lang.get('pages.rating.send_ratings');
123
+ this.setModalHeight(steps[index]);
134
124
  }
135
125
  setModalHeight(current) {
136
126
  const wrapper = this.host.querySelector('.s-rating-wrapper');
137
- setTimeout(() => {
138
- wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px');
139
- });
127
+ setTimeout(() => wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px'));
128
+ }
129
+ // Listen to submit::order-rating event used in handleWizard()
130
+ handleSubmitRating() {
131
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
132
+ // Handle timer
133
+ let thankYouView = this.host.querySelector('.s-rating-thanks'), seconds = 10;
134
+ let timeToClose = setInterval(() => {
135
+ seconds--;
136
+ this.host.querySelector('.s-rating-thanks-time').innerHTML = `00:0${seconds}`;
137
+ if (seconds == 0) {
138
+ this.hide();
139
+ clearInterval(timeToClose);
140
+ }
141
+ }, 1000);
142
+ // Hide steps and show thanks msg
143
+ Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
144
+ this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
145
+ Helper.toggleElement(thankYouView, 's-rating-unactive', 's-rating-hidden', () => true);
146
+ setTimeout(() => Helper.toggleElement(thankYouView, 's-rating-active', 's-rating-unactive', () => true), 200);
147
+ this.setModalHeight(thankYouView);
148
+ }));
140
149
  }
141
150
  // handle star rating
142
151
  starsRating() {
143
- let selectedClasses = ['selected', 'text-theme-yellow'];
152
+ let selectedClasses = ['selected'];
144
153
  // Listen for form submissions
145
154
  salla.document.event.onSubmit('.s-rating-stars-element', function (event) {
146
155
  // Prevent form from submitting
147
156
  event.preventDefault();
148
157
  // Get the selected star - activeElement is not supported in safari
149
- var activeStars = event.target.querySelectorAll('.btn--star.hovered');
158
+ var activeStars = event.target.querySelectorAll('.s-rating-btn-star.hovered');
150
159
  var selected = activeStars[activeStars.length - 1];
151
160
  if (!selected)
152
161
  return;
@@ -155,7 +164,7 @@ const SallaRating = class {
155
164
  // Get all stars in this form (only search in the form, not the whole document)
156
165
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
157
166
  event.target
158
- .querySelectorAll('.btn--star')
167
+ .querySelectorAll('.s-rating-btn-star')
159
168
  .forEach(function (star, index) {
160
169
  if (index < selectedIndex) {
161
170
  // Selected star or before it, Add highlighting
@@ -166,7 +175,7 @@ const SallaRating = class {
166
175
  star.classList.remove(...selectedClasses);
167
176
  });
168
177
  // Remove aria-pressed from any previously selected star
169
- var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
178
+ var previousRating = event.target.querySelector('.s-rating-btn-star[aria-pressed="true"]');
170
179
  if (previousRating) {
171
180
  previousRating.removeAttribute('aria-pressed');
172
181
  }
@@ -175,11 +184,11 @@ const SallaRating = class {
175
184
  });
176
185
  }
177
186
  highlightSelectedStars() {
178
- let hover = ['hovered', 'text-theme-yellow'];
187
+ let hover = ['hovered'];
179
188
  Helper.all('.s-rating-stars-element', el => {
180
- let starElements = el.querySelectorAll('.btn--star');
189
+ let starElements = el.querySelectorAll('.s-rating-btn-star');
181
190
  // remove hovered state from stars ---
182
- el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
191
+ el.addEventListener('mouseout', () => starElements.forEach(star => star.classList.remove(...hover)));
183
192
  starElements.forEach((starElement, index) => {
184
193
  starElement.addEventListener('mouseover', () => {
185
194
  starElement.classList.add(...hover);
@@ -239,15 +248,15 @@ const SallaRating = class {
239
248
  let commentInput = rating.querySelector('.s-rating-comment');
240
249
  let validationMessage = rating.querySelector('.s-rating-validation-msg');
241
250
  if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
242
- commentInput.classList.remove('has-error');
251
+ commentInput.classList.remove('s-rating-has-error');
243
252
  validationMessage.innerHTML = '';
244
253
  return;
245
254
  }
246
255
  else if (commentInput.value && commentInput.value.length > 3) {
247
- commentInput.classList.remove('has-error');
256
+ commentInput.classList.remove('s-rating-has-error');
248
257
  }
249
258
  else {
250
- commentInput.classList.add('has-error');
259
+ commentInput.classList.add('s-rating-has-error');
251
260
  }
252
261
  errorMsg = ratingInput.value
253
262
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
@@ -257,34 +266,28 @@ const SallaRating = class {
257
266
  });
258
267
  //Fire error to prevent going to next step
259
268
  if (errorMsg) {
260
- // scroll to first error
261
- let ratingErrors = document.querySelectorAll('.has-error');
262
- if (ratingErrors.length) {
263
- let firstError = ratingErrors[0].offsetTop;
264
- window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
265
- }
266
269
  throw new Error(errorMsg);
267
270
  }
268
271
  }
269
272
  // render
270
273
  render() {
271
- return (h(Host, null, h("salla-modal", { class: "hidden", "modal-width": "w-[800px]", ref: modal => this.modal = modal, title: salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.orderId + ')</span>' }, h("div", { class: "s-rating-wrapper " }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), h("div", { class: "s-rating-footer" }, h("button", { id: "prev-btn", class: "s-rating-btn s-rating-unvisiable" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), this.stepsCount > 1 ?
272
- h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(index => h("li", { class: `${index == 0 ? 'bg-primary' : 'bg-gray-200'} s-rating-step-dot` }))) : '', h("salla-button", { id: "next-btn", class: "w-28", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
274
+ return (h(Host, null, h("salla-modal", { class: "hidden", "modal-width": "w-[800px]", ref: modal => this.modal = modal, title: salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.orderId + ')</span>' }, h("div", { class: "s-rating-wrapper " }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), h("div", { class: "s-rating-footer" }, h("button", { id: "prev-btn", class: "s-rating-btn s-rating-unvisiable" }, salla.lang.get('pages.order.rating_prev')), this.stepsCount > 1 ?
275
+ h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(index => h("li", { class: `${index == 0 ? 's-rating-bg-primary' : 's-rating-bg-gray'} s-rating-step-dot` }))) : '', h("salla-button", { id: "next-btn", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
273
276
  }
274
277
  renderStoreRating() {
275
- return (h("section", { class: "s-rating-step", "data-type": "store", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631" }, h("div", { class: "rating-outer-form s-rating-step-wrap", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "type", value: "store" }), h("div", { class: "s-rating-rounded-icon" }, h("img", { src: this.order.storeLogo, alt: "store name", class: "s-rating-store-logo" })), h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')), this.getStarsRating(), 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" }))));
278
+ return (h("section", { class: "s-rating-step", "data-type": "store", "data-step-name": salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.store') }, h("div", { class: "rating-outer-form s-rating-step-wrap", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "type", value: "store" }), h("div", { class: "s-rating-rounded-icon" }, h("img", { src: this.order.storeLogo, 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.getStarsRating('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" }))));
276
279
  }
277
280
  renderShippingRating() {
278
- return (h("section", { class: "s-rating-step", "data-type": "shipping", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" }, h("div", { class: "rating-outer-form s-rating-step-wrap", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), h("input", { type: "hidden", name: "type", value: "shipping" }), h("div", { class: "s-rating-rounded-icon" }, h("img", { src: this.order.shippingLogo, alt: "company name", class: "s-rating-shipping-logo" })), h("h2", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633"), this.getStarsRating(), h("textarea", { id: "shippingReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "s-rating-validation-msg" }))));
281
+ return (h("section", { class: "s-rating-step", "data-type": "shipping", "data-step-name": salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.shipping') }, h("div", { class: "rating-outer-form s-rating-step-wrap", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), h("input", { type: "hidden", name: "type", value: "shipping" }), h("div", { class: "s-rating-rounded-icon" }, h("img", { src: this.order.shippingLogo, alt: "company name", class: "s-rating-shipping-logo" })), h("h2", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633"), h("div", { class: "s-rating-stars-company" }, " ", this.getStarsRating('large')), h("textarea", { id: "shippingReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "s-rating-validation-msg" }))));
279
282
  }
280
283
  renderProductsRating() {
281
- return (h("section", { class: "s-rating-step", "data-type": "product", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A" }, 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', { "item": item.title }) }, h("img", { src: item.image, alt: item.title, class: "s-rating-product-img" }), h("div", { class: "flex-1" }, h("h3", { class: "s-rating-product-title" }, " ", item.title), this.getStarsRating(), h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }), h("input", { type: "hidden", name: "type", value: "products" }), h("textarea", { "data-product-id": item.id, name: `products[${index}][comment]`, id: `productReview_${item.id}`, class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_product_rate') }), h("small", { class: "s-rating-validation-msg" }))))));
284
+ return (h("section", { class: "s-rating-step", "data-type": "product", "data-step-name": salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.products') }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": salla.lang.get('pages.order.rate_product_stars') }, h("img", { src: item.image, alt: item.title, class: "s-rating-product-img" }), h("div", { class: "s-rating-product-details" }, h("h3", { class: "s-rating-product-title" }, " ", item.title), h("div", { class: "s-rating-stars-product" }, " ", this.getStarsRating('small')), h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }), h("input", { type: "hidden", name: "type", value: "products" }), h("textarea", { "data-product-id": item.id, name: `products[${index}][comment]`, id: `productReview_${item.id}`, class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_product_rate') }), h("small", { class: "s-rating-validation-msg" }))))));
282
285
  }
283
286
  renderThanksView() {
284
287
  return (h("div", { class: "s-rating-thanks s-rating-hidden" }, h("span", { class: "s-rating-thanks-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.thanksMsg }), h("a", { href: "#!", onClick: () => this.hide(), class: "s-rating-thanks-btn" }, "\u0639\u0648\u062F\u0629 \u0625\u0644\u064A \u062A\u0641\u0627\u0635\u064A\u0644 \u0627\u0644\u0637\u0644\u0628"), h("time", { class: "s-rating-thanks-time" })));
285
288
  }
286
- getStarsRating() {
287
- return (h("form", { class: "s-rating-stars-element" }, h("div", { class: "mb-1" }, h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), [1, 2, 3, 4, 5].map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-2xl text-gray-400 btn--star", "data-star": star }, h("i", { class: "sicon-star2" }))))));
289
+ getStarsRating(size) {
290
+ return (h("form", { class: "s-rating-stars-element" }, h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), [1, 2, 3, 4, 5].map((star) => h("button", { type: "submit", class: `s-rating-btn-star s-rating-btn-star-` + size, "data-star": star }, h("i", { class: "sicon-star2" })))));
288
291
  }
289
292
  get host() { return getElement(this); }
290
293
  };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaSearch = class {
@@ -0,0 +1,3 @@
1
+ export { S as salla_search } from './salla-search-f552c487.js';
2
+ import './index-8b97d225.js';
3
+ import './Helper-81ac9a8c.js';
@@ -0,0 +1,17 @@
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-8b97d225.js';
2
+
3
+ /*
4
+ Stencil Client Patch Browser v2.8.1 | MIT Licensed | https://stenciljs.com
5
+ */
6
+ const patchBrowser = () => {
7
+ const importMeta = import.meta.url;
8
+ const opts = {};
9
+ if (importMeta !== '') {
10
+ opts.resourcesUrl = new URL('.', importMeta).href;
11
+ }
12
+ return promiseResolve(opts);
13
+ };
14
+
15
+ patchBrowser().then(options => {
16
+ return bootstrapLazy([["salla-button_4",[[0,"salla-login",{"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"modalClosed","onModalClose"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"thanksMsg":[1,"thanks-msg"],"isStoreRating":[4,"is-store-rating"],"isProductsRating":[4,"is-products-rating"],"isShippingRating":[4,"is-shipping-rating"],"show":[64],"hide":[64]}]]],["salla-offer",[[4,"salla-offer",{"show":[64]}]]],["salla-search",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalClosed","onModalClose"]]]]]], options);
17
+ });
@@ -0,0 +1 @@
1
+ module.exports = require('./cjs/index.cjs.js');
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './esm/index.js';
@@ -1,4 +1 @@
1
- export { S as SallaLogin } from './salla-login-4d620368.js';
2
- export { S as SallaSearch } from './salla-search-5338c0a1.js';
3
- import './index-8966d27f.js';
4
- import './Helper-81ac9a8c.js';
1
+ export{S as SallaLogin}from"./p-93c3ac79.js";export{S as SallaSearch}from"./p-36683152.js";import"./p-cb1c59a2.js";import"./p-9bc28e0c.js";
@@ -0,0 +1 @@
1
+ import{r as t,h as s,H as i,g as l}from"./p-cb1c59a2.js";import{H as a}from"./p-9bc28e0c.js";const e=class{constructor(s){t(this,s),this.isUser=a.isUser(),this.buttonText=salla.lang.get("pages.products.notify_availability"),this.countryCode=salla.config.country_code||"SA",this.subscribeText=salla.lang.get("common.elements.submit"),this.cancelText=salla.lang.get("common.elements.cancel"),this.subTitle=salla.lang.get("pages.products.notify_availability_subtitle"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.mobilePlaceholder=salla.lang.get("common.elements.mobile_placeholder"),this.emailPlaceholder=salla.lang.get("common.elements.email_placeholder"),this.productId=salla.config.page.id,this.subscribedMessage=salla.lang.get("pages.products.notify_availability_success"),this.isSubscribed=!1,this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){this.channels_=t.split(",")}async submit(){if(this.isUser)return salla.api.product.availabilitySubscribe(this.productId).then((()=>this.isSubscribed=!0));let t={id:this.productId,country_code:this.countryCode};return""!==this.mobile.value&&(t.mobile=this.mobile.value),""!==this.email.value&&(t.email=this.email.value),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>this.isSubscribed=!0)).then((()=>this.btn.stop())).then((()=>this.modal.hide())).catch((()=>this.btn.stop()&&this.btn.enable()))}render(){return s(i,null,this.isSubscribed?s("div",{class:"s-product-availability-subscribed"},this.subscribedMessage):s("slot",null,s("salla-button",{wide:!0,onClick:()=>this.isUser?this.submit():this.modal.show()},this.buttonText)),this.isUser||this.isSubscribed?"":this.renderModal())}renderModal(){return s("salla-modal",{ref:t=>this.modal=t,title:this.title_,subTitle:this.subTitle,icon:"sicon-bell-ring",width:"md"},s("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[s("label",{class:"s-product-availability-label"},this.emailLabel),s("input",{class:"s-product-availability-input",placeholder:this.emailPlaceholder,ref:t=>this.email=t,type:"email"})]:"",this.channels_.includes("sms")?[s("label",{class:"s-product-availability-label"},this.mobileLabel),s("input",{class:"s-product-availability-input",placeholder:this.mobilePlaceholder,ref:t=>this.mobile=t,type:"text"}),s("input",{type:"hidden",value:this.countryCode})]:""),s("div",{slot:"footer",class:"s-product-availability-footer"},s("salla-button",{wide:!0,ref:t=>this.btn=t,onClick:()=>this.submit()},this.subscribeText),s("salla-button",{wide:!0,"btn-style":"outline"},this.cancelText)))}get host(){return l(this)}static get watchers(){return{channels:["channelsWatcher"]}}};export{e as salla_product_availability}
@@ -0,0 +1 @@
1
+ import{r as s,h as t,H as a,g as i}from"./p-cb1c59a2.js";import{H as e}from"./p-9bc28e0c.js";const r=class{constructor(t){var a,i;s(this,t),this.results=[],this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options"),e.setHost(this.host),this.buttonSlot=(null===(a=e.getElement('[slot="button"]'))||void 0===a?void 0:a.innerHTML)||'<i class="sicon-search"></i>',this.productSlot=(null===(i=e.getElement('[slot="product"]'))||void 0===i?void 0:i.innerHTML)||this.getDefaultProductSlot()}onModalClose(){e.getElement(".s-search-input").value="",this.results=[],this.afterSearching()}getDefaultProductSlot(){return'<a target="_blank" href={url} class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></a><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(e.hideElement(this.noResults),0===s.target.value.length)return this.results=[],void this.afterSearching();s.target.value.length<=2||(e.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s.results)).catch((s=>"Query Same As Previous!"!==s?this.results=[]:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){this.noResults.style.display=s||this.results.length>0?"none":"block",e.toggleElement(this.container,"s-search-container-open","no-results",(()=>this.results.length)).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return t(a,{class:"s-search"},t("button",{onClick:()=>this.modal.show(),class:"s-search-button",innerHTML:this.buttonSlot}),t("salla-modal",{ref:s=>this.modal=s},t("div",{class:"s-search-container",slot:"body",ref:s=>this.container=s},t("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),t("span",{class:"s-search-icon"},t("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),t("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.map((s=>{var a;return t("div",{class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.title).replace(/\{price\}/g,null===(a=s.price)||void 0===a?void 0:a.after).replace(/\{url\}/g,s.url).replace(/\{image\}/g,s.thumb)})})),t("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText)))))}componentDidLoad(){this.afterSearching()}get host(){return i(this)}};export{r as S}
@@ -0,0 +1 @@
1
+ import{r as t,h as s,H as a,g as i}from"./p-cb1c59a2.js";import{H as e}from"./p-9bc28e0c.js";const r=class{constructor(s){t(this,s),this.order={shipping:{id:5622},products:[{title:"ميكروفون عالى الجودة",image:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",price:"‏10,978.00 ر.س",qty:"‏2",totalBefore:"‏1120 ر.س",discount:"-5%",total:"‏1064 ر.س",id:"2314513454",getOptimusRouteKey:"7351233357"},{title:"ميكروفون عالى الجودة",image:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",price:"‏10,978.00 ر.س",qty:"‏2",totalBefore:"‏1120 ر.س",discount:"-5%",total:"‏1064 ر.س",id:"2314513454",getOptimusRouteKey:"7351233357"},{title:"ساعة ذكية بنظام اندرويد",image:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",price:"‏10,978.00 ر.س",qty:"‏2",totalBefore:"‏1120 ر.س",discount:"-5%",total:"‏1064 ر.س",id:"679822376",getOptimusRouteKey:"73233357"}],storeLogo:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png",shippingLogo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU"},this.isStoreRating=!1,this.isProductsRating=!1,this.isShippingRating=!1,this.ratingChain=Promise.resolve(),this.stepsCount=0,e.setHost(this.host)}async show(){return this.modal.show()}async hide(){return this.modal.hide()}componentWillLoad(){this.stepsCount=[this.isStoreRating,this.isProductsRating,this.isShippingRating].filter((t=>t)).length}componentDidRender(){this.show(),this.initiateRating()}initiateRating(){this.handleWizard(),this.handleSubmitRating(),this.starsRating(),this.highlightSelectedStars()}handleWizard(){let t=0,s=this.host.querySelectorAll(".s-rating-step"),a=this.host.querySelectorAll(".s-rating-step-dot"),i=this.host.querySelector("#next-btn .s-button-text");this.setModalHeight(s[0]),this.showActiveStep(s,a,t,i),e.onClick("#prev-btn",(()=>{t>0&&t--,this.showActiveStep(s,a,t,i),0==t&&e.toggle("#prev-btn","s-rating-unvisiable","block",(()=>!0))})),e.onClick("#next-btn",(()=>{this.ratingValidation(),t==this.stepsCount-1?salla.event.dispatch("submit::order-rating"):(t<this.stepsCount-1&&t++,this.showActiveStep(s,a,t,i),e.toggle("#prev-btn","block","s-rating-unvisiable",(()=>!0)))}))}showActiveStep(t,s,a,i){var r;e.toggle(".s-rating-step","s-rating-hidden","s-rating-active",(()=>!0)),e.toggleElement(t[a],"s-rating-unactive","s-rating-hidden",(()=>!0)),setTimeout((()=>e.toggleElement(t[a],"s-rating-active","s-rating-unactive",(()=>!0))),200),e.toggle(".s-rating-step-dot","s-rating-bg-gray","s-rating-bg-primary",(()=>!0)),this.stepsCount>1&&e.toggleElement(s[a],"s-rating-bg-primary","s-rating-bg-gray",(()=>!0)),i.innerHTML=(null===(r=t[a+1])||void 0===r?void 0:r.dataset.stepName)||salla.lang.get("pages.rating.send_ratings"),this.setModalHeight(t[a])}setModalHeight(t){const s=this.host.querySelector(".s-rating-wrapper");setTimeout((()=>null==s?void 0:s.setAttribute("style","height:"+(null==t?void 0:t.scrollHeight)+"px")))}handleSubmitRating(){salla.event.on("submit::order-rating",(()=>this.sendRating().then((()=>{let t=this.host.querySelector(".s-rating-thanks"),s=10,a=setInterval((()=>{s--,this.host.querySelector(".s-rating-thanks-time").innerHTML=`00:0${s}`,0==s&&(this.hide(),clearInterval(a))}),1e3);e.toggle(".s-rating-step","s-rating-hidden","s-rating-active",(()=>!0)),this.host.querySelector(".s-rating-footer").classList.add("s-rating-unvisiable"),e.toggleElement(t,"s-rating-unactive","s-rating-hidden",(()=>!0)),setTimeout((()=>e.toggleElement(t,"s-rating-active","s-rating-unactive",(()=>!0))),200),this.setModalHeight(t)}))))}starsRating(){let t=["selected"];salla.document.event.onSubmit(".s-rating-stars-element",(function(s){s.preventDefault();var a=s.target.querySelectorAll(".s-rating-btn-star.hovered"),i=a[a.length-1];if(i){var e=parseInt(i.dataset.star,10);s.target.querySelector(".rating_hidden_input").value=e,s.target.querySelectorAll(".s-rating-btn-star").forEach((function(s,a){a<e?s.classList.add(...t):s.classList.remove(...t)}));var r=s.target.querySelector('.s-rating-btn-star[aria-pressed="true"]');r&&r.removeAttribute("aria-pressed"),i.setAttribute("aria-pressed",!0)}}))}highlightSelectedStars(){let t=["hovered"];e.all(".s-rating-stars-element",(s=>{let a=s.querySelectorAll(".s-rating-btn-star");s.addEventListener("mouseout",(()=>a.forEach((s=>s.classList.remove(...t))))),a.forEach(((s,i)=>{s.addEventListener("mouseover",(()=>{if(s.classList.add(...t),i<=1)"BUTTON"===s.previousElementSibling.tagName&&s.previousElementSibling.classList.add(...t);else for(let s=0;s<i;s++)a[s].classList.add(...t)})),s.addEventListener("mouseout",(()=>{s.classList.contains(...t)&&s.classList.remove(...t)}))}))}))}sendRating(){return e.all(".s-rating-step",(t=>{let s=t.dataset.type,a=[];t.querySelectorAll(".rating-outer-form").forEach((t=>{let i={};t.querySelectorAll("[name]").forEach((function(t){let s=salla.helpers.inputData(t.name,t.value,i);i[s.name]=s.value})),a=[],a.push(i),this.sendFeedback(s,a)}))})),this.ratingChain}sendFeedback(t,s){s&&0!=s.length&&(this.nextBtn.load(),salla.config.canLeave=!1,this.ratingChain=salla.feedback.api[t](s[0]).then((function(){salla.config.canLeave=!0})).catch((()=>salla.config.canLeave=!0)))}ratingValidation(){let t="";if(document.querySelectorAll(".s-rating-step.s-rating-active").forEach((s=>{s.querySelectorAll(".rating-outer-form").forEach((s=>{let a=s.querySelector(".rating_hidden_input"),i=s.querySelector(".s-rating-comment"),e=s.querySelector(".s-rating-validation-msg");if(a.value&&i.value&&i.value.length>3)return i.classList.remove("s-rating-has-error"),void(e.innerHTML="");i.value&&i.value.length>3?i.classList.remove("s-rating-has-error"):i.classList.add("s-rating-has-error"),t=a.value?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):s.dataset.starsError||salla.lang.get("pages.rating.rate_store_stars"),e.innerHTML=t}))})),t)throw new Error(t)}render(){return s(a,null,s("salla-modal",{class:"hidden","modal-width":"w-[800px]",ref:t=>this.modal=t,title:salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.orderId+")</span>"},s("div",{class:"s-rating-wrapper "},this.isStoreRating&&this.renderStoreRating(),this.isProductsRating&&this.renderProductsRating(),this.isShippingRating&&this.renderShippingRating(),this.renderThanksView()),s("div",{class:"s-rating-footer"},s("button",{id:"prev-btn",class:"s-rating-btn s-rating-unvisiable"},salla.lang.get("pages.order.rating_prev")),this.stepsCount>1?s("ul",{class:"s-rating-dots"},[0,1,2].slice(0,this.stepsCount).map((t=>s("li",{class:(0==t?"s-rating-bg-primary":"s-rating-bg-gray")+" s-rating-step-dot"})))):"",s("salla-button",{id:"next-btn",ref:t=>this.nextBtn=t},"التالي"))))}renderStoreRating(){return s("section",{class:"s-rating-step","data-type":"store","data-step-name":salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating.store")},s("div",{class:"rating-outer-form s-rating-step-wrap","data-stars-error":salla.lang.get("pages.rating.rate_store_stars")},s("input",{type:"hidden",name:"order_id",value:this.orderId}),s("input",{type:"hidden",name:"type",value:"store"}),s("div",{class:"s-rating-rounded-icon"},s("img",{src:this.order.storeLogo,alt:"store name",class:"s-rating-store-logo"})),s("h2",{class:"s-rating-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-stars-company"}," ",this.getStarsRating("large")),s("textarea",{id:"storeReview",name:"comment",class:"s-rating-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-validation-msg"})))}renderShippingRating(){return s("section",{class:"s-rating-step","data-type":"shipping","data-step-name":salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating.shipping")},s("div",{class:"rating-outer-form s-rating-step-wrap","data-stars-error":salla.lang.get("pages.rating.rate_shipping_stars")},s("input",{type:"hidden",name:"order_id",value:this.orderId}),s("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.id}),s("input",{type:"hidden",name:"type",value:"shipping"}),s("div",{class:"s-rating-rounded-icon"},s("img",{src:this.order.shippingLogo,alt:"company name",class:"s-rating-shipping-logo"})),s("h2",{class:"s-rating-title"}," ",salla.lang.get("pages.rating.rate_shipping")," ارامكس"),s("div",{class:"s-rating-stars-company"}," ",this.getStarsRating("large")),s("textarea",{id:"shippingReview",name:"comment",class:"s-rating-comment",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-validation-msg"})))}renderProductsRating(){return s("section",{class:"s-rating-step","data-type":"product","data-step-name":salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating.products")},this.order.products.map(((t,a)=>s("div",{class:"rating-outer-form s-rating-product","data-stars-error":salla.lang.get("pages.order.rate_product_stars")},s("img",{src:t.image,alt:t.title,class:"s-rating-product-img"}),s("div",{class:"s-rating-product-details"},s("h3",{class:"s-rating-product-title"}," ",t.title),s("div",{class:"s-rating-stars-product"}," ",this.getStarsRating("small")),s("input",{type:"hidden",name:"order_id",value:this.orderId}),s("input",{type:"hidden",name:`products[${a}][product_id]`,value:t.getOptimusRouteKey}),s("input",{type:"hidden",name:"type",value:"products"}),s("textarea",{"data-product-id":t.id,name:`products[${a}][comment]`,id:`productReview_${t.id}`,class:"s-rating-comment",placeholder:salla.lang.get("pages.rating.write_product_rate")}),s("small",{class:"s-rating-validation-msg"}))))))}renderThanksView(){return s("div",{class:"s-rating-thanks s-rating-hidden"},s("span",{class:"s-rating-thanks-icon sicon-check-circle2"}),s("h3",{class:"s-rating-thanks-title"},salla.lang.get("pages.rating.thanks")),s("div",{class:"s-rating-thanks-msg",innerHTML:this.thanksMsg}),s("a",{href:"#!",onClick:()=>this.hide(),class:"s-rating-thanks-btn"},"عودة إلي تفاصيل الطلب"),s("time",{class:"s-rating-thanks-time"}))}getStarsRating(t){return s("form",{class:"s-rating-stars-element"},s("input",{type:"hidden",class:"rating_hidden_input",name:"rating",value:""}),[1,2,3,4,5].map((a=>s("button",{type:"submit",class:"s-rating-btn-star s-rating-btn-star-"+t,"data-star":a},s("i",{class:"sicon-star2"})))))}get host(){return i(this)}};r.style=":host{display:block}.unicode{unicode-bidi:plaintext}";export{r as salla_rating}
@@ -0,0 +1 @@
1
+ import{r as s,h as o,g as t}from"./p-cb1c59a2.js";const a=class{constructor(o){s(this,o),salla.offer.event.onExisted((s=>this.show(s.offer.offer_id)))}async show(s){this.modal.show(),console.log(s)}render(){return o("salla-modal",{ref:s=>this.modal=s,"is-loading":!0},o("slot",null))}componentDidLoad(){}get host(){return t(this)}};export{a as salla_offer}
@@ -0,0 +1 @@
1
+ import{r as s,h as i,g as l}from"./p-cb1c59a2.js";import{H as t}from"./p-9bc28e0c.js";const e=class{constructor(i){s(this,i),this.regType="sms",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.backText=salla.lang.get("common.elements.back"),this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.auth.event.onVerificationFailed((()=>{}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.tab5);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!")}onModalClose(){this.showTab(this.tab1)}async show(){return this.modal.show()}showTab(s){[this.tab1,this.tab2,this.tab3,this.tab4,this.tab5].map((i=>t.toggleElement(i,"visible","hidden",(()=>i==s)))),[this.tab2,this.tab3].includes(s)&&(this.regType=s===this.tab2?"sms":"email");let i=s==this.tab5;return this.modal.setTitle(i?salla.lang.get("common.titles.registration"):this.title),i||t.toggleElement(this.regMobileBlock,"s-hidden","s-block",(()=>"sms"===this.regType)).toggleElement(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}loginByEmail(){if(!t.isValidEmail(this.email.value))return this.email.classList.add("s-has-error"),void(this.email.nextElementSibling.innerText="* "+salla.lang.get("common.elements.email_is_valid"));this.email.nextElementSibling.innerText="",this.email.classList.remove("s-has-error"),salla.auth.api.login({type:"email",email:this.email.value}).then((()=>this.showTab(this.tab4))).then((()=>(this.tab4.by="email")&&(this.tab4.url="auth/email/verify"))).then((()=>this.tab4.show({email:this.email.value})))}loginBySMS(){if(this.mobile.value.length<6)return this.mobile.classList.add("s-has-error"),void(this.mobile.nextElementSibling.innerText="* "+salla.lang.get("mobile_app.strings.incorrect_mobile"));this.mobile.nextElementSibling.innerText="",this.mobile.classList.remove("s-has-error"),salla.auth.api.login({type:"sms",mobile:this.mobile.value}).then((()=>this.showTab(this.tab4))).then((()=>(this.tab4.by="sms")&&(this.tab4.url="auth/mobile/verify"))).then((()=>this.tab4.show({mobile:this.mobile.value,country_code:"SA"})))}typing({target:s}){"tel"===s.type&&salla.helpers.digitsOnly(s),s.classList.remove("s-has-error"),s.nextElementSibling.innerText=""}newUser(){this.tab4.getCode().then((s=>salla.auth.api.register({first_name:this.firstName.value,last_name:this.lastName.value,phone:this.regMobile.value||this.mobile.value,email:this.regEmail.value||this.email.value,country_code:"",country_key:"",code:s,verified_by:this.regType})))}render(){return i("salla-modal",{id:"salla-login",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-tab",ref:s=>this.tab1=s},i("p",{class:"s-login-sub-title"},this.loginTypeTitle),i("a",{href:"#",class:"s-login-main-btn",onClick:()=>this.showTab(this.tab2)},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:()=>this.showTab(this.tab3)},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"}))),i("div",{class:"s-login-tab",ref:s=>this.tab2=s},i("label",{class:"s-login-label"},this.mobileLabel),i("input",{type:"tel",ref:s=>this.mobile=s,onInput:this.typing,placeholder:"5xx xxx xxx",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{wide:!0,onClick:()=>this.loginBySMS()},this.enterText),i("a",{href:"#",onClick:()=>this.showTab(this.tab3),class:"s-login-link"},this.byEmailText)),i("div",{class:"s-login-tab",ref:s=>this.tab3=s},i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.email=s,onInput:this.typing,placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{wide:!0,onClick:()=>this.loginByEmail()},this.enterText),i("a",{href:"#",onClick:()=>this.showTab(this.tab2),class:"s-login-link"},this.bySMSText)),i("salla-verify",{"without-modal":!0,ref:s=>this.tab4=s,autoReload:!1}),i("div",{ref:s=>this.tab5=s},i("label",{class:"s-login-label"},salla.lang.get("blocks.header.your_name")),i("div",{class:"s-login-input-group"},i("input",{type:"text",class:"s-login-input",ref:s=>this.firstName=s,placeholder:salla.lang.get("pages.profile.first_name")}),i("input",{type:"text",class:"s-login-input",ref:s=>this.lastName=s,placeholder:salla.lang.get("pages.profile.last_name")})),i("div",{ref:s=>this.regMobileBlock=s},i("label",{class:"s-login-label"},this.mobileLabel),i("input",{type:"tel",ref:s=>this.regMobile=s,onInput:this.typing,placeholder:"5xx xxx xxx",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("div",{ref:s=>this.regEmailBlock=s},i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onInput:this.typing,placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("salla-button",{wide:!0,onClick:()=>this.newUser()},salla.lang.get("blocks.header.register"))))}componentDidRender(){this.showTab(this.tab1)}get host(){return l(this)}};export{e as S}
@@ -0,0 +1 @@
1
+ class t extends salla.AppHelpers{setHost(t){this.host=t}getElement(t){return this.host.querySelector(t)}getAttribute(t,e){var s;return null===(s=this.getElement(t))||void 0===s?void 0:s.getAttribute(e)}val(t){return this.getAttribute(t,"value")}isUser(){return!!salla.config.is_user}}const e=new t;export{e as H}
@@ -0,0 +1 @@
1
+ import{r as a,h as s,g as l}from"./p-cb1c59a2.js";import{H as i}from"./p-9bc28e0c.js";const t=class{constructor(s){var l,t;a(this,s),this.language=salla.config.language||{},this.currency=salla.config.currency||{},this.languagesTitle=salla.lang.get("common.titles.language"),this.currenciesTitle=salla.lang.get("common.titles.currency"),this.ok=salla.lang.get("common.elements.ok"),i.setHost(this.host),salla.event.on("localization::show",(()=>this.show())),this.languageSlot=(null===(l=i.getElement('[slot="language"]'))||void 0===l?void 0:l.innerHTML)||'<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>',this.currencySlot=(null===(t=i.getElement('[slot="currency"]'))||void 0===t?void 0:t.innerHTML)||'<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>'}async show(){return this.modal.show()}async hide(){return this.modal.hide()}onChangeCurrency(a){this.currency=salla.config.currencies.filter((s=>s.code==a.target.value))[0]}onChangeLanguage(a){this.language=salla.config.languages.filter((s=>s.code==a.target.value))[0]}async submit(){let a;console.log("this.currency.code::::",this.currency,this.currency.code),this.btn.load().then((()=>this.currency.code===salla.config.currency.code||(a=window.location.href)&&salla.currency.api.change(this.currency.code))).then((()=>this.language.code===salla.config.language.code||(a=this.language.url))).then((()=>this.btn.stop())).then((()=>this.hide())).then((()=>a&&(window.location.href=a)))}render(){return s("salla-modal",{id:"salla-localization",class:"hidden",ref:a=>this.modal=a,"modal-width":"xs"},s("div",{slot:"header"},s("slot",{name:"header"})),s("div",{class:"s-localization-inner"},salla.config.languages?s("div",{class:"s-localization-section"},s("label",{class:"s-localization-title"},this.languagesTitle),s("div",{class:"s-localization-section-inner"},salla.config.languages.length<6?salla.config.languages.map((a=>s("div",{class:"s-localization-item"},s("input",{class:"s-localization-input",type:"radio",checked:this.language.code==a.code,onChange:()=>this.language=a,name:"language",id:"lang-"+a.code.toLowerCase(),value:a.code}),s("div",{id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,a.name).replace(/\{code\}/g,a.code).replace(/\{country_code\}/g,a.country_code)})))):s("select",{class:"s-branches-select",name:"currency",onChange:a=>this.onChangeLanguage(a)},salla.config.languages.map((a=>s("option",{value:a.code,selected:this.language.code==a.code},a.name)))))):"",salla.config.currencies?s("div",{class:"s-localization-section"},s("label",{class:"s-localization-title"},this.currenciesTitle),s("div",{class:"s-localization-section-inner"},salla.config.currencies.length<6?salla.config.currencies.map((a=>s("div",{class:"s-localization-item"},s("input",{class:"s-localization-input",type:"radio",name:"currency",checked:this.currency.code==a.code,onChange:()=>this.currency=a,id:"currency-"+a.code,value:a.code}),s("div",{id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,a.name).replace(/\{code\}/g,a.code).replace(/\{country_code\}/g,a.country_code)})))):s("select",{class:"s-branches-select",name:"currency",onChange:a=>this.onChangeCurrency(a)},salla.config.currencies.map((a=>s("option",{value:a.code,selected:this.currency.code==a.code},a.name)))))):""),s("slot",{name:"footer"},s("salla-button",{wide:!0,ref:a=>this.btn=a,onClick:()=>this.submit()},this.ok)))}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((a=>a.replaceWith(a.firstChild))),this.host.querySelectorAll("#language-slot").forEach((a=>a.replaceWith(a.firstChild)))}get host(){return l(this)}};export{t as salla_localization}
@@ -0,0 +1 @@
1
+ export{S as salla_search}from"./p-36683152.js";import"./p-cb1c59a2.js";import"./p-9bc28e0c.js";
@@ -0,0 +1 @@
1
+ let e,t,l=!1,n=!1,o=!1,s=!1;const i="undefined"!=typeof window?window:{},r=i.document||{head:{}},c={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,l,n)=>e.addEventListener(t,l,n),rel:(e,t,l,n)=>e.removeEventListener(t,l,n),ce:(e,t)=>new CustomEvent(e,t)},f=e=>Promise.resolve(e),a=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),u=(e,t,l)=>{l&&l.map((([l,n,o])=>{const s=e,i=$(t,o),r=d(l);c.ael(s,n,i,r),(t.o=t.o||[]).push((()=>c.rel(s,n,i,r)))}))},$=(e,t)=>l=>{try{256&e.t?e.i[t](l):(e.u=e.u||[]).push([t,l])}catch(e){se(e)}},d=e=>0!=(2&e),h="http://www.w3.org/1999/xlink",y=new WeakMap,p=e=>"sc-"+e.$,m={},b=e=>"object"==(e=typeof e)||"function"===e,w=(e,t,...l)=>{let n=null,o=null,s=null,i=!1,r=!1,c=[];const f=t=>{for(let l=0;l<t.length;l++)n=t[l],Array.isArray(n)?f(n):null!=n&&"boolean"!=typeof n&&((i="function"!=typeof e&&!b(n))&&(n+=""),i&&r?c[c.length-1].h+=n:c.push(i?k(null,n):n),r=i)};if(f(l),t){t.key&&(o=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}const a=k(e,null);return a.p=t,c.length>0&&(a.m=c),a.k=o,a.g=s,a},k=(e,t)=>({t:0,S:e,h:t,v:null,m:null,p:null,k:null,g:null}),g={},S=(e,t,l,n,o,s)=>{if(l!==n){let r=oe(e,t),f=t.toLowerCase();if("class"===t){const t=e.classList,o=j(l),s=j(n);t.remove(...o.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!o.includes(e))))}else if("style"===t){for(const t in l)n&&null!=n[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in n)l&&n[t]===l[t]||(t.includes("-")?e.style.setProperty(t,n[t]):e.style[t]=n[t])}else if("key"===t);else if("ref"===t)n&&n(e);else if(r||"o"!==t[0]||"n"!==t[1]){const i=b(n);if((r||i&&null!==n)&&!o)try{if(e.tagName.includes("-"))e[t]=n;else{let o=null==n?"":n;"list"===t?r=!1:null!=l&&e[t]==o||(e[t]=o)}}catch(e){}let c=!1;f!==(f=f.replace(/^xlink\:?/,""))&&(t=f,c=!0),null==n||!1===n?!1===n&&""!==e.getAttribute(t)||(c?e.removeAttributeNS(h,t):e.removeAttribute(t)):(!r||4&s||o)&&!i&&(n=!0===n?"":n,c?e.setAttributeNS(h,t,n):e.setAttribute(t,n))}else t="-"===t[2]?t.slice(3):oe(i,f)?f.slice(2):f[2]+t.slice(3),l&&c.rel(e,t,l,!1),n&&c.ael(e,t,n,!1)}},v=/\s/,j=e=>e?e.split(v):[],M=(e,t,l,n)=>{const o=11===t.v.nodeType&&t.v.host?t.v.host:t.v,s=e&&e.p||m,i=t.p||m;for(n in s)n in i||S(o,n,s[n],void 0,l,t.t);for(n in i)S(o,n,s[n],i[n],l,t.t)},O=(n,s,i)=>{let c,f,a,u=s.m[i],$=0;if(l||(o=!0,"slot"===u.S&&(u.t|=u.m?2:1)),null!==u.h)c=u.v=r.createTextNode(u.h);else if(1&u.t)c=u.v=r.createTextNode("");else if(c=u.v=r.createElement(2&u.t?"slot-fb":u.S),M(null,u,!1),u.m)for($=0;$<u.m.length;++$)f=O(n,u,$),f&&c.appendChild(f);return c["s-hn"]=t,3&u.t&&(c["s-sr"]=!0,c["s-cr"]=e,c["s-sn"]=u.g||"",a=n&&n.m&&n.m[i],a&&a.S===u.S&&n.v&&C(n.v,!1)),c},C=(e,l)=>{c.t|=1;const n=e.childNodes;for(let e=n.length-1;e>=0;e--){const s=n[e];s["s-hn"]!==t&&s["s-ol"]&&(L(s).insertBefore(s,T(s)),s["s-ol"].remove(),s["s-ol"]=void 0,o=!0),l&&C(s,l)}c.t&=-2},R=(e,t,l,n,o,s)=>{let i,r=e["s-cr"]&&e["s-cr"].parentNode||e;for(;o<=s;++o)n[o]&&(i=O(null,l,o),i&&(n[o].v=i,r.insertBefore(i,T(t))))},x=(e,t,l,o,s)=>{for(;t<=l;++t)(o=e[t])&&(s=o.v,H(o),n=!0,s["s-ol"]?s["s-ol"].remove():C(s,!0),s.remove())},P=(e,t)=>e.S===t.S&&("slot"===e.S?e.g===t.g:e.k===t.k),T=e=>e&&e["s-ol"]||e,L=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,E=(e,t)=>{const l=t.v=e.v,n=e.m,o=t.m,s=t.h;let i;null===s?("slot"===t.S||M(e,t,!1),null!==n&&null!==o?((e,t,l,n)=>{let o,s,i=0,r=0,c=0,f=0,a=t.length-1,u=t[0],$=t[a],d=n.length-1,h=n[0],y=n[d];for(;i<=a&&r<=d;)if(null==u)u=t[++i];else if(null==$)$=t[--a];else if(null==h)h=n[++r];else if(null==y)y=n[--d];else if(P(u,h))E(u,h),u=t[++i],h=n[++r];else if(P($,y))E($,y),$=t[--a],y=n[--d];else if(P(u,y))"slot"!==u.S&&"slot"!==y.S||C(u.v.parentNode,!1),E(u,y),e.insertBefore(u.v,$.v.nextSibling),u=t[++i],y=n[--d];else if(P($,h))"slot"!==u.S&&"slot"!==y.S||C($.v.parentNode,!1),E($,h),e.insertBefore($.v,u.v),$=t[--a],h=n[++r];else{for(c=-1,f=i;f<=a;++f)if(t[f]&&null!==t[f].k&&t[f].k===h.k){c=f;break}c>=0?(s=t[c],s.S!==h.S?o=O(t&&t[r],l,c):(E(s,h),t[c]=void 0,o=s.v),h=n[++r]):(o=O(t&&t[r],l,r),h=n[++r]),o&&L(u.v).insertBefore(o,T(u.v))}i>a?R(e,null==n[d+1]?null:n[d+1].v,l,n,r,d):r>d&&x(t,i,a)})(l,n,t,o):null!==o?(null!==e.h&&(l.textContent=""),R(l,null,t,o,0,o.length-1)):null!==n&&x(n,0,n.length-1)):(i=l["s-cr"])?i.parentNode.textContent=s:e.h!==s&&(l.data=s)},W=e=>{let t,l,n,o,s,i,r=e.childNodes;for(l=0,n=r.length;l<n;l++)if(t=r[l],1===t.nodeType){if(t["s-sr"])for(s=t["s-sn"],t.hidden=!1,o=0;o<n;o++)if(i=r[o].nodeType,r[o]["s-hn"]!==t["s-hn"]||""!==s){if(1===i&&s===r[o].getAttribute("slot")){t.hidden=!0;break}}else if(1===i||3===i&&""!==r[o].textContent.trim()){t.hidden=!0;break}W(t)}},A=[],D=e=>{let t,l,o,s,i,r,c=0,f=e.childNodes,a=f.length;for(;c<a;c++){if(t=f[c],t["s-sr"]&&(l=t["s-cr"])&&l.parentNode)for(o=l.parentNode.childNodes,s=t["s-sn"],r=o.length-1;r>=0;r--)l=o[r],l["s-cn"]||l["s-nr"]||l["s-hn"]===t["s-hn"]||(F(l,s)?(i=A.find((e=>e.j===l)),n=!0,l["s-sn"]=l["s-sn"]||s,i?i.M=t:A.push({M:t,j:l}),l["s-sr"]&&A.map((e=>{F(e.j,l["s-sn"])&&(i=A.find((e=>e.j===l)),i&&!e.M&&(e.M=i.M))}))):A.some((e=>e.j===l))||A.push({j:l}));1===t.nodeType&&D(t)}},F=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,H=e=>{e.p&&e.p.ref&&e.p.ref(null),e.m&&e.m.map(H)},N=e=>te(e).O,U=(e,t,l)=>{const n=N(e);return{emit:e=>q(n,t,{bubbles:!!(4&l),composed:!!(2&l),cancelable:!!(1&l),detail:e})}},q=(e,t,l)=>{const n=c.ce(t,l);return e.dispatchEvent(n),n},V=(e,t)=>{t&&!e.C&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.C=t)))},_=(e,t)=>{if(e.t|=16,!(4&e.t))return V(e,e.R),ye((()=>z(e,t)));e.t|=512},z=(e,t)=>{const l=e.i;let n;return t&&(e.t|=256,e.u&&(e.u.map((([e,t])=>K(l,e,t))),e.u=null),n=K(l,"componentWillLoad")),Q(n,(()=>B(e,l,t)))},B=async(e,t,l)=>{const n=e.O,o=n["s-rc"];l&&(e=>{const t=e.P;((e,t)=>{let l=p(t),n=ce.get(l);if(e=11===e.nodeType?e:r,n)if("string"==typeof n){let t,o=y.get(e=e.head||e);o||y.set(e,o=new Set),o.has(l)||(t=r.createElement("style"),t.innerHTML=n,e.insertBefore(t,e.querySelector("link")),o&&o.add(l))}else e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n])})(e.O.getRootNode(),t)})(e);G(e,t),o&&(o.map((e=>e())),n["s-rc"]=void 0);{const t=n["s-p"],l=()=>I(e);0===t.length?l():(Promise.all(t).then(l),e.t|=4,t.length=0)}},G=(s,i)=>{try{i=i.render(),s.t&=-17,s.t|=2,((s,i)=>{const f=s.O,a=s.P,u=s.T||k(null,null),$=(e=>e&&e.S===g)(i)?i:w(null,null,i);if(t=f.tagName,a.L&&($.p=$.p||{},a.L.map((([e,t])=>$.p[t]=f[e]))),$.S=null,$.t|=4,s.T=$,$.v=u.v=f,e=f["s-cr"],l=0!=(1&a.t),n=!1,E(u,$),c.t|=1,o){let e,t,l,n,o,s;D($.v);let i=0;for(;i<A.length;i++)e=A[i],t=e.j,t["s-ol"]||(l=r.createTextNode(""),l["s-nr"]=t,t.parentNode.insertBefore(t["s-ol"]=l,t));for(i=0;i<A.length;i++)if(e=A[i],t=e.j,e.M){for(n=e.M.parentNode,o=e.M.nextSibling,l=t["s-ol"];l=l.previousSibling;)if(s=l["s-nr"],s&&s["s-sn"]===t["s-sn"]&&n===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&n!==t.parentNode||t.nextSibling!==o)&&t!==o&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),n.insertBefore(t,o))}else 1===t.nodeType&&(t.hidden=!0)}n&&W($.v),c.t&=-2,A.length=0})(s,i)}catch(e){se(e,s.O)}return null},I=e=>{const t=e.O,l=e.i,n=e.R;K(l,"componentDidRender"),64&e.t||(e.t|=64,X(t),K(l,"componentDidLoad"),e.W(t),n||J()),e.A(t),e.C&&(e.C(),e.C=void 0),512&e.t&&he((()=>_(e,!1))),e.t&=-517},J=()=>{X(r.documentElement),he((()=>q(i,"appload",{detail:{namespace:"twilight-components"}})))},K=(e,t,l)=>{if(e&&e[t])try{return e[t](l)}catch(e){se(e)}},Q=(e,t)=>e&&e.then?e.then(t):t(),X=e=>e.classList.add("hydrated"),Y=(e,t,l)=>{if(t.D){e.watchers&&(t.F=e.watchers);const n=Object.entries(t.D),o=e.prototype;if(n.map((([e,[n]])=>{31&n||2&l&&32&n?Object.defineProperty(o,e,{get(){return((e,t)=>te(this).H.get(t))(0,e)},set(l){((e,t,l,n)=>{const o=te(e),s=o.O,i=o.H.get(t),r=o.t,c=o.i;if(l=((e,t)=>null==e||b(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(l,n.D[t][0]),!(8&r&&void 0!==i||l===i)&&(o.H.set(t,l),c)){if(n.F&&128&r){const e=n.F[t];e&&e.map((e=>{try{c[e](l,i,t)}catch(e){se(e,s)}}))}2==(18&r)&&_(o,!1)}})(this,e,l,t)},configurable:!0,enumerable:!0}):1&l&&64&n&&Object.defineProperty(o,e,{value(...t){const l=te(this);return l.N.then((()=>l.i[e](...t)))}})})),1&l){const l=new Map;o.attributeChangedCallback=function(e,t,n){c.jmp((()=>{const t=l.get(e);this.hasOwnProperty(t)&&(n=this[t],delete this[t]),this[t]=(null!==n||"boolean"!=typeof this[t])&&n}))},e.observedAttributes=n.filter((([e,t])=>15&t[0])).map((([e,n])=>{const o=n[1]||e;return l.set(o,e),512&n[0]&&t.L.push([e,o]),o}))}}return e},Z=(e,t={})=>{const l=[],n=t.exclude||[],o=i.customElements,s=r.head,f=s.querySelector("meta[charset]"),$=r.createElement("style"),d=[];let h,y=!0;Object.assign(c,t),c.l=new URL(t.resourcesUrl||"./",r.baseURI).href,e.map((e=>e[1].map((t=>{const s={t:t[0],$:t[1],D:t[2],U:t[3]};s.D=t[2],s.U=t[3],s.L=[],s.F={};const i=s.$,f=class extends HTMLElement{constructor(e){super(e),ne(e=this,s)}connectedCallback(){h&&(clearTimeout(h),h=null),y?d.push(this):c.jmp((()=>(e=>{if(0==(1&c.t)){const t=te(e),l=t.P,n=()=>{};if(1&t.t)u(e,t,l.U);else{t.t|=1,12&l.t&&(e=>{const t=e["s-cr"]=r.createComment("");t["s-cn"]=!0,e.insertBefore(t,e.firstChild)})(e);{let l=e;for(;l=l.parentNode||l.host;)if(l["s-p"]){V(t,t.R=l);break}}l.D&&Object.entries(l.D).map((([t,[l]])=>{if(31&l&&e.hasOwnProperty(t)){const l=e[t];delete e[t],e[t]=l}})),(async(e,t,l,n,o)=>{if(0==(32&t.t)){{if(t.t|=32,(o=re(l)).then){const e=()=>{};o=await o,e()}o.isProxied||(l.F=o.watchers,Y(o,l,2),o.isProxied=!0);const e=()=>{};t.t|=8;try{new o(t)}catch(e){se(e)}t.t&=-9,t.t|=128,e()}if(o.style){let e=o.style;const t=p(l);if(!ce.has(t)){const n=()=>{};((e,t,l)=>{let n=ce.get(e);a&&l?(n=n||new CSSStyleSheet,n.replace(t)):n=t,ce.set(e,n)})(t,e,!!(1&l.t)),n()}}}const s=t.R,i=()=>_(t,!0);s&&s["s-rc"]?s["s-rc"].push(i):i()})(0,t,l)}n()}})(this)))}disconnectedCallback(){c.jmp((()=>(()=>{if(0==(1&c.t)){const e=te(this);e.o&&(e.o.map((e=>e())),e.o=void 0)}})()))}componentOnReady(){return te(this).q}};s.V=e[0],n.includes(i)||o.get(i)||(l.push(i),o.define(i,Y(f,s,1)))})))),$.innerHTML=l+"{visibility:hidden}.hydrated{visibility:inherit}",$.setAttribute("data-styles",""),s.insertBefore($,f?f.nextSibling:s.firstChild),y=!1,d.length?d.map((e=>e.connectedCallback())):c.jmp((()=>h=setTimeout(J,30)))},ee=new WeakMap,te=e=>ee.get(e),le=(e,t)=>ee.set(t.i=e,t),ne=(e,t)=>{const l={t:0,O:e,P:t,H:new Map};return l.N=new Promise((e=>l.A=e)),l.q=new Promise((e=>l.W=e)),e["s-p"]=[],e["s-rc"]=[],u(e,l,t.U),ee.set(e,l)},oe=(e,t)=>t in e,se=(e,t)=>(0,console.error)(e,t),ie=new Map,re=e=>{const t=e.$.replace(/-/g,"_"),l=e.V,n=ie.get(l);return n?n[t]:import(`./${l}.entry.js`).then((e=>(ie.set(l,e),e[t])),se)},ce=new Map,fe=[],ae=[],ue=(e,t)=>l=>{e.push(l),s||(s=!0,t&&4&c.t?he(de):c.raf(de))},$e=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){se(e)}e.length=0},de=()=>{$e(fe),$e(ae),(s=fe.length>0)&&c.raf(de)},he=e=>f().then(e),ye=ue(ae,!0);export{g as H,Z as b,U as c,N as g,w as h,f as p,le as r}
@@ -0,0 +1 @@
1
+ import{r as s,h as e,g as t}from"./p-cb1c59a2.js";let a=require("store/src/store-engine"),i=require("store/storages/sessionStorage"),h=a.createStore(i);const l=class{constructor(e){s(this,e),this.open=!1,this.isOpenedBefore=h.get("branch-choosed-before"),this.displayAs="default",this.browseProductsFrom="all",this.branches=[{id:1,name:"فرع الرياض",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:2,name:"فرع جدة",open:!1,available:!1,limited:!1,tag:"غير متوفر"},{id:3,name:"فرع مكة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:4,name:"فرع المدينة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:5,name:"فرع جازان",open:!0,available:!0,limited:!0,tag:"الكمية محدودة"}],this.current=1,this.currentBranch=s=>this.branches.filter((s=>s.id==this.current))[0][s],this.statusColor=(s=null)=>s?s.limited?"s-branches-color-red":s.available?"s-branches-color-green":"s-branches-color-gray":this.currentBranch("limited")?"s-branches-color-red":this.currentBranch("available")?"s-branches-color-green":"s-branches-color-gray",this.isChoiceable=()=>"all"!==this.browseProductsFrom&&"single"==this.position||"header"==this.position,this.formTitle=()=>this.isChoiceable()?"توفر المنتج في الفروع الآخرى":"التسوق من فرع آخر",salla.event.on("branches::show",(()=>this.show()))}async show(){return this.modal.show()}async hide(){return this.modal.hide()}handelChange(s){this.selected=s.target.value}handleSubmit(){this.btn.load().then((()=>{setTimeout((()=>location.reload()),2e3)})),h.set("branch-choosed-before",!0),this.show(),setTimeout((()=>{this.current=this.selected}),300)}render(){return e("salla-modal",{icon:"sicon-store-alt",title:"فرع الرياض","sub-title":"أنت الآن تتصفح المتجر من","sub-title-first":!0,"is-closable":this.isOpenedBefore||"popup"!=this.displayAs?"true":"false",ref:s=>this.modal=s,"modal-width":"sm",id:"s-branches-modal",class:"hidden"},e("h4",{class:"s-branches-title"},this.formTitle()),this.branches.length<=5?e("div",{class:"s-branches-space-v"},this.branches.map((s=>e("div",{class:"s-branches-input-wrap"},e("input",{id:this.position+"_branch_"+s.id,disabled:!s.open&&this.isChoiceable(),name:"lang",type:"radio",value:s.id,onChange:s=>this.handelChange(s),class:{"s-branches-input":!0,"opacity-50":!s.open,hidden:!this.isChoiceable()},checked:this.current==s.id}),e("label",{htmlFor:this.position+"_branch_"+s.id,class:{"s-branches-label":!0,"s-branches-clickable":this.isChoiceable()}},e("span",{class:{"s-branches-is-closed":!s.open}},s.name),this.isChoiceable()?e("small",{class:"s-branches-closed-badge"},s.open?"":"مُغلق"):e("span",{class:this.statusColor(s)},s.tag)))))):e("select",{class:"s-branches-select",onInput:s=>this.handelChange(s)},this.branches.map((s=>e("option",{value:s.id,disabled:!s.open,selected:this.selected==s.id},s.name," ",s.open?"":"- مُغلق")))),this.isChoiceable()?e("slot",{name:"footer"},e("salla-button",{ref:s=>this.btn=s,onClick:()=>this.handleSubmit(),class:"s-branches-submit",wide:!0},salla.lang.get("common.elements.ok"))):"")}componentDidRender(){this.isOpenedBefore||"popup"!=this.displayAs||this.show()}get host(){return t(this)}};l.style=":host{display:block}";export{l as salla_branches}
@@ -0,0 +1 @@
1
+ import{r as s,h as t,H as i,g as e,c as l}from"./p-cb1c59a2.js";import{H as a}from"./p-9bc28e0c.js";export{S as salla_login}from"./p-93c3ac79.js";const h=class{constructor(t){s(this,t),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="before",this.wide=!1,this.hostAttributes={};for(let s=0;s<this.host.attributes.length;s++)this.hostAttributes[this.host.attributes[s].name]=this.host.attributes[s].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading s-button-"+this.btnStyle+(this.wide?" s-button-wide ":"")+" loader-"+this.loaderPosition+("before"==this.loaderPosition?" s-button-loader-after":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(s,t){this.btn.classList.remove("btn-"+t),this.btn.classList.add("btn-"+s)}handleLoading(s){a.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>s))}render(){return t(i,{class:"s-button-host-tag"},t("button",Object.assign({ref:s=>this.btn=s,disabled:this.disabled},this.hostAttributes),t("span",{class:"s-button-text",ref:s=>this.text=s},t("slot",null)),this.loading?t("span",{class:{"s-button-loader":!0,"s-button-loader-start":"start"===this.loaderPosition,"s-button-loader-end":"end"===this.loaderPosition,"s-button-loader-center":"center"===this.loaderPosition}}):""))}get host(){return e(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};h.style=":host{display:block}";const o=class{constructor(t){var i;s(this,t),this.modalOpened=l(this,"modalOpened",7),this.modalClosed=l(this,"modalClosed",7),this.error=!1,this.success=!1,this.primary=!1,this.isClosable=!0,this.width="md",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.subTitle="",this.icon="",this.imageIcon="",a.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title"),null===(i=a.getElement("[slot=body]"))||void 0===i||i.classList.add("s-modal-body","s-modal-"+this.width)}handleVisible(s){if(!s)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.title=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(s){a.toggleElement(this.host.querySelector("[slot=body]")||this.host,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}render(){return this.host.id=this.host.id||"salla-modal",t(i,{class:"s-modal-container hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-wrapper"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),t("span",{class:"s-modal-spacer"},"​"),t("slot",{name:"body"},t("div",{class:"s-modal-body s-modal-"+this.width,slot:"body"},this.isLoading?t("span",null,"Loading..."):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close cursor-pointer",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.error||this.success||this.icon?t("div",{class:{"s-modal-icon":!0,"s-modal-bg-error":this.error,"s-modal-bg-success":this.success,"s-modal-bg-normal":!this.error&&!this.success,"s-modal-bg-primary":this.primary}},t("i",{class:{[this.icon]:!0,"s-modal-text-error":this.error,"s-modal-text-success":this.success}})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",this.title||this.subTitle?t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle})):""),t("slot",null),t("slot",{name:"footer"})]))))}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}},r=class{constructor(t){s(this,t),this.verified=l(this,"verified",7),this.url="profile/verify-mobile",this.by="sms",this.autoReload=!0,a.setHost(this.host),this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(s=>this.show(s)))}async getCode(){return this.code.value}async show(s){return this.data=s,this.resendTimer(),this.otpInputs=document.querySelectorAll(".s-verify-input"),this.otpInputs[0].focus(),a.on("input",".s-verify-input",(s=>salla.helpers.digitsOnly(s.target))),a.onKeyUp(".s-verify-input",(s=>{var t,i,e,l;let a=s.keyCode||s.charCode;s.target.value?(null===(t=s.target.nextElementSibling)||void 0===t||t.focus(),null===(i=s.target.nextElementSibling)||void 0===i||i.select()):[8,46].includes(a)&&(null===(e=s.target.previousElementSibling)||void 0===e||e.focus(),null===(l=s.target.previousElementSibling)||void 0===l||l.select()),this.toggleOTPSubmit()})),a.on("paste",".s-verify-input",(s=>{let t=s.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((s,i)=>s.value=t[i]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.modal.show()}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((t=>t.value&&s.push(t.value))),this.code.value=s.join(""),4===s.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}resendTimer(){a.showElement(this.resendMessage).hideElement(this.resend);let s=30,t=setInterval((()=>{-1===s?(clearTimeout(t),a.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${s>=10?s:"0"+s} : 00`,s--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){return this.btn.load().then((()=>this.btn.disable())).then((()=>salla.document.api.request(this.url,Object.assign({code:this.code.value},this.data)))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()))}render(){return this.withoutModal?this.myBody():t("salla-modal",{id:"s-verify",ref:s=>this.modal=s,title:salla.lang.get("pages.profile.verify_title")},this.myBody())}myBody(){return[t("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("label",{class:"s-verify-label"},salla.lang.get("pages.profile.verify_placeholder")),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),t("div",{class:"s-verify-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-footer"},t("salla-button",{class:"s-verify-submit",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-timer",ref:s=>this.timer=s})),t("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit")))]}get host(){return e(this)}};export{h as salla_button,o as salla_modal,r as salla_verify}
@@ -1,3 +1 @@
1
- salla-button[wide] {
2
- width: 100%;
3
- }
1
+ salla-button[wide]{width:100%}